^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * linux/arch/arm/mach-pxa/colibri-evalboard.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Support for Toradex Colibri Evaluation Carrier Board
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Daniel Mack <daniel@caiaq.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Marek Vasut <marek.vasut@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/gpio/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <mach/hardware.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <asm/mach/arch.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/platform_data/i2c-pxa.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include "pxa27x.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include "colibri.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/platform_data/mmc-pxamci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/platform_data/usb-ohci-pxa27x.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include "pxa27x-udc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include "generic.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include "devices.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * SD/MMC card controller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static struct pxamci_platform_data colibri_mci_platform_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) .detect_delay_ms = 200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static struct gpiod_lookup_table colibri_pxa270_mci_gpio_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) .dev_id = "pxa2xx-mci.0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) .table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) GPIO_LOOKUP("gpio-pxa", GPIO0_COLIBRI_PXA270_SD_DETECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) "cd", GPIO_ACTIVE_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) { },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static struct gpiod_lookup_table colibri_pxa300_mci_gpio_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) .dev_id = "pxa2xx-mci.0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) .table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) GPIO_LOOKUP("gpio-pxa", GPIO13_COLIBRI_PXA300_SD_DETECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) "cd", GPIO_ACTIVE_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) { },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) static struct gpiod_lookup_table colibri_pxa320_mci_gpio_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) .dev_id = "pxa2xx-mci.0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) .table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) GPIO_LOOKUP("gpio-pxa", GPIO28_COLIBRI_PXA320_SD_DETECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) "cd", GPIO_ACTIVE_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) { },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static void __init colibri_mmc_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) if (machine_is_colibri()) /* PXA270 Colibri */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) gpiod_add_lookup_table(&colibri_pxa270_mci_gpio_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) if (machine_is_colibri300()) /* PXA300 Colibri */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) gpiod_add_lookup_table(&colibri_pxa300_mci_gpio_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) else /* PXA320 Colibri */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) gpiod_add_lookup_table(&colibri_pxa320_mci_gpio_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) pxa_set_mci_info(&colibri_mci_platform_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static inline void colibri_mmc_init(void) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * USB Host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) static int colibri_ohci_init(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) static struct pxaohci_platform_data colibri_ohci_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) .port_mode = PMM_PERPORT_MODE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) .flags = ENABLE_PORT1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) POWER_CONTROL_LOW | POWER_SENSE_LOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) .init = colibri_ohci_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) static void __init colibri_uhc_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /* Colibri PXA270 has two usb ports, TBA for 320 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) if (machine_is_colibri())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) colibri_ohci_info.flags |= ENABLE_PORT2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) pxa_set_ohci_info(&colibri_ohci_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static inline void colibri_uhc_init(void) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * I2C RTC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #if defined(CONFIG_RTC_DRV_DS1307) || defined(CONFIG_RTC_DRV_DS1307_MODULE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static struct i2c_board_info __initdata colibri_i2c_devs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) I2C_BOARD_INFO("m41t00", 0x68),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static void __init colibri_rtc_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) pxa_set_i2c_info(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) i2c_register_board_info(0, ARRAY_AND_SIZE(colibri_i2c_devs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static inline void colibri_rtc_init(void) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) void __init colibri_evalboard_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) pxa_set_ffuart_info(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) pxa_set_btuart_info(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) pxa_set_stuart_info(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) colibri_mmc_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) colibri_uhc_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) colibri_rtc_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }