Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 Eric Benard - eric@eukrea.com |
| 3 | * |
| 4 | * Based on pcm038.c which is : |
| 5 | * Copyright 2007 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix |
| 6 | * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License |
| 10 | * as published by the Free Software Foundation; either version 2 |
| 11 | * of the License, or (at your option) any later version. |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
| 20 | * MA 02110-1301, USA. |
| 21 | */ |
| 22 | |
| 23 | #include <linux/i2c.h> |
| 24 | #include <linux/io.h> |
| 25 | #include <linux/mtd/plat-ram.h> |
| 26 | #include <linux/mtd/physmap.h> |
| 27 | #include <linux/platform_device.h> |
| 28 | #include <linux/serial_8250.h> |
Eric Bénard | 9f2270d | 2010-05-19 18:46:02 +0200 | [diff] [blame] | 29 | #include <linux/usb/otg.h> |
| 30 | #include <linux/usb/ulpi.h> |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 31 | |
| 32 | #include <asm/mach-types.h> |
| 33 | #include <asm/mach/arch.h> |
| 34 | #include <asm/mach/time.h> |
| 35 | #include <asm/mach/map.h> |
| 36 | |
Eric Bénard | 95afd09 | 2010-07-23 14:56:40 +0200 | [diff] [blame] | 37 | #include <mach/eukrea-baseboards.h> |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 38 | #include <mach/common.h> |
| 39 | #include <mach/hardware.h> |
Uwe Kleine-König | e835d88 | 2010-02-16 11:07:49 +0100 | [diff] [blame] | 40 | #include <mach/iomux-mx27.h> |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 41 | #include <mach/mxc_nand.h> |
Eric Bénard | 9f2270d | 2010-05-19 18:46:02 +0200 | [diff] [blame] | 42 | #include <mach/ulpi.h> |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 43 | |
Uwe Kleine-König | 0e7a29a | 2010-06-16 07:35:31 +0200 | [diff] [blame] | 44 | #include "devices-imx27.h" |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 45 | |
Uwe Kleine-König | 6c80ee5 | 2010-09-28 21:53:31 +0200 | [diff] [blame] | 46 | static const int eukrea_cpuimx27_pins[] __initconst = { |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 47 | /* UART1 */ |
| 48 | PE12_PF_UART1_TXD, |
| 49 | PE13_PF_UART1_RXD, |
| 50 | PE14_PF_UART1_CTS, |
| 51 | PE15_PF_UART1_RTS, |
| 52 | /* UART4 */ |
Eric Bénard | 2d66c78 | 2010-05-19 18:45:59 +0200 | [diff] [blame] | 53 | #if defined(MACH_EUKREA_CPUIMX27_USEUART4) |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 54 | PB26_AF_UART4_RTS, |
| 55 | PB28_AF_UART4_TXD, |
| 56 | PB29_AF_UART4_CTS, |
| 57 | PB31_AF_UART4_RXD, |
Eric Bénard | 2d66c78 | 2010-05-19 18:45:59 +0200 | [diff] [blame] | 58 | #endif |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 59 | /* FEC */ |
| 60 | PD0_AIN_FEC_TXD0, |
| 61 | PD1_AIN_FEC_TXD1, |
| 62 | PD2_AIN_FEC_TXD2, |
| 63 | PD3_AIN_FEC_TXD3, |
| 64 | PD4_AOUT_FEC_RX_ER, |
| 65 | PD5_AOUT_FEC_RXD1, |
| 66 | PD6_AOUT_FEC_RXD2, |
| 67 | PD7_AOUT_FEC_RXD3, |
| 68 | PD8_AF_FEC_MDIO, |
| 69 | PD9_AIN_FEC_MDC, |
| 70 | PD10_AOUT_FEC_CRS, |
| 71 | PD11_AOUT_FEC_TX_CLK, |
| 72 | PD12_AOUT_FEC_RXD0, |
| 73 | PD13_AOUT_FEC_RX_DV, |
| 74 | PD14_AOUT_FEC_RX_CLK, |
| 75 | PD15_AOUT_FEC_COL, |
| 76 | PD16_AIN_FEC_TX_ER, |
| 77 | PF23_AIN_FEC_TX_EN, |
| 78 | /* I2C1 */ |
| 79 | PD17_PF_I2C_DATA, |
| 80 | PD18_PF_I2C_CLK, |
| 81 | /* SDHC2 */ |
Eric Bénard | 2d66c78 | 2010-05-19 18:45:59 +0200 | [diff] [blame] | 82 | #if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2) |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 83 | PB4_PF_SD2_D0, |
| 84 | PB5_PF_SD2_D1, |
| 85 | PB6_PF_SD2_D2, |
| 86 | PB7_PF_SD2_D3, |
| 87 | PB8_PF_SD2_CMD, |
| 88 | PB9_PF_SD2_CLK, |
Eric Bénard | 2d66c78 | 2010-05-19 18:45:59 +0200 | [diff] [blame] | 89 | #endif |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 90 | #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) |
| 91 | /* Quad UART's IRQ */ |
Eric Bénard | ebb4fc8 | 2010-05-19 18:46:00 +0200 | [diff] [blame] | 92 | GPIO_PORTB | 22 | GPIO_GPIO | GPIO_IN, |
| 93 | GPIO_PORTB | 23 | GPIO_GPIO | GPIO_IN, |
| 94 | GPIO_PORTB | 27 | GPIO_GPIO | GPIO_IN, |
| 95 | GPIO_PORTB | 30 | GPIO_GPIO | GPIO_IN, |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 96 | #endif |
Eric Bénard | 9f2270d | 2010-05-19 18:46:02 +0200 | [diff] [blame] | 97 | /* OTG */ |
| 98 | PC7_PF_USBOTG_DATA5, |
| 99 | PC8_PF_USBOTG_DATA6, |
| 100 | PC9_PF_USBOTG_DATA0, |
| 101 | PC10_PF_USBOTG_DATA2, |
| 102 | PC11_PF_USBOTG_DATA1, |
| 103 | PC12_PF_USBOTG_DATA4, |
| 104 | PC13_PF_USBOTG_DATA3, |
| 105 | PE0_PF_USBOTG_NXT, |
| 106 | PE1_PF_USBOTG_STP, |
| 107 | PE2_PF_USBOTG_DIR, |
| 108 | PE24_PF_USBOTG_CLK, |
| 109 | PE25_PF_USBOTG_DATA7, |
| 110 | /* USBH2 */ |
| 111 | PA0_PF_USBH2_CLK, |
| 112 | PA1_PF_USBH2_DIR, |
| 113 | PA2_PF_USBH2_DATA7, |
| 114 | PA3_PF_USBH2_NXT, |
| 115 | PA4_PF_USBH2_STP, |
| 116 | PD19_AF_USBH2_DATA4, |
| 117 | PD20_AF_USBH2_DATA3, |
| 118 | PD21_AF_USBH2_DATA6, |
| 119 | PD22_AF_USBH2_DATA0, |
| 120 | PD23_AF_USBH2_DATA2, |
| 121 | PD24_AF_USBH2_DATA1, |
| 122 | PD26_AF_USBH2_DATA5, |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | static struct physmap_flash_data eukrea_cpuimx27_flash_data = { |
| 126 | .width = 2, |
| 127 | }; |
| 128 | |
| 129 | static struct resource eukrea_cpuimx27_flash_resource = { |
| 130 | .start = 0xc0000000, |
| 131 | .end = 0xc3ffffff, |
| 132 | .flags = IORESOURCE_MEM, |
| 133 | }; |
| 134 | |
| 135 | static struct platform_device eukrea_cpuimx27_nor_mtd_device = { |
| 136 | .name = "physmap-flash", |
| 137 | .id = 0, |
| 138 | .dev = { |
| 139 | .platform_data = &eukrea_cpuimx27_flash_data, |
| 140 | }, |
| 141 | .num_resources = 1, |
| 142 | .resource = &eukrea_cpuimx27_flash_resource, |
| 143 | }; |
| 144 | |
Uwe Kleine-König | d5dac4a | 2010-06-23 09:36:01 +0200 | [diff] [blame] | 145 | static const struct imxuart_platform_data uart_pdata __initconst = { |
| 146 | .flags = IMXUART_HAVE_RTSCTS, |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 147 | }; |
| 148 | |
Uwe Kleine-König | 0e7a29a | 2010-06-16 07:35:31 +0200 | [diff] [blame] | 149 | static const struct mxc_nand_platform_data |
| 150 | cpuimx27_nand_board_info __initconst = { |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 151 | .width = 1, |
| 152 | .hw_ecc = 1, |
| 153 | }; |
| 154 | |
| 155 | static struct platform_device *platform_devices[] __initdata = { |
| 156 | &eukrea_cpuimx27_nor_mtd_device, |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 157 | }; |
| 158 | |
Uwe Kleine-König | c698715 | 2010-06-16 17:25:40 +0200 | [diff] [blame] | 159 | static const struct imxi2c_platform_data cpuimx27_i2c1_data __initconst = { |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 160 | .bitrate = 100000, |
| 161 | }; |
| 162 | |
| 163 | static struct i2c_board_info eukrea_cpuimx27_i2c_devices[] = { |
| 164 | { |
Sascha Hauer | cf87a6e | 2009-07-20 08:18:47 +0200 | [diff] [blame] | 165 | I2C_BOARD_INFO("pcf8563", 0x51), |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 166 | }, |
| 167 | }; |
| 168 | |
| 169 | #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) |
| 170 | static struct plat_serial8250_port serial_platform_data[] = { |
| 171 | { |
Uwe Kleine-König | 3f35d1f | 2009-12-09 11:32:11 +0100 | [diff] [blame] | 172 | .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x200000), |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 173 | .irq = IRQ_GPIOB(23), |
| 174 | .uartclk = 14745600, |
| 175 | .regshift = 1, |
| 176 | .iotype = UPIO_MEM, |
| 177 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, |
| 178 | }, { |
Uwe Kleine-König | 3f35d1f | 2009-12-09 11:32:11 +0100 | [diff] [blame] | 179 | .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x400000), |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 180 | .irq = IRQ_GPIOB(22), |
| 181 | .uartclk = 14745600, |
| 182 | .regshift = 1, |
| 183 | .iotype = UPIO_MEM, |
| 184 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, |
| 185 | }, { |
Uwe Kleine-König | 3f35d1f | 2009-12-09 11:32:11 +0100 | [diff] [blame] | 186 | .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x800000), |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 187 | .irq = IRQ_GPIOB(27), |
| 188 | .uartclk = 14745600, |
| 189 | .regshift = 1, |
| 190 | .iotype = UPIO_MEM, |
| 191 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, |
| 192 | }, { |
Uwe Kleine-König | 3f35d1f | 2009-12-09 11:32:11 +0100 | [diff] [blame] | 193 | .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x1000000), |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 194 | .irq = IRQ_GPIOB(30), |
| 195 | .uartclk = 14745600, |
| 196 | .regshift = 1, |
| 197 | .iotype = UPIO_MEM, |
| 198 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, |
| 199 | }, { |
| 200 | } |
| 201 | }; |
| 202 | |
| 203 | static struct platform_device serial_device = { |
| 204 | .name = "serial8250", |
| 205 | .id = 0, |
| 206 | .dev = { |
| 207 | .platform_data = serial_platform_data, |
| 208 | }, |
| 209 | }; |
| 210 | #endif |
| 211 | |
Eric Bénard | cbb052c | 2010-06-18 16:19:55 +0200 | [diff] [blame] | 212 | #if defined(CONFIG_USB_ULPI) |
Uwe Kleine-König | 2eb42d5 | 2010-11-05 18:52:09 +0100 | [diff] [blame] | 213 | static struct mxc_usbh_platform_data otg_pdata __initdata = { |
Eric Bénard | 9f2270d | 2010-05-19 18:46:02 +0200 | [diff] [blame] | 214 | .portsc = MXC_EHCI_MODE_ULPI, |
| 215 | .flags = MXC_EHCI_INTERFACE_DIFF_UNI, |
| 216 | }; |
| 217 | |
Uwe Kleine-König | 2eb42d5 | 2010-11-05 18:52:09 +0100 | [diff] [blame] | 218 | static struct mxc_usbh_platform_data usbh2_pdata __initdata = { |
Eric Bénard | 9f2270d | 2010-05-19 18:46:02 +0200 | [diff] [blame] | 219 | .portsc = MXC_EHCI_MODE_ULPI, |
| 220 | .flags = MXC_EHCI_INTERFACE_DIFF_UNI, |
| 221 | }; |
Eric Bénard | cbb052c | 2010-06-18 16:19:55 +0200 | [diff] [blame] | 222 | #endif |
Eric Bénard | 9f2270d | 2010-05-19 18:46:02 +0200 | [diff] [blame] | 223 | |
Uwe Kleine-König | bd455ed | 2010-11-09 17:52:14 +0100 | [diff] [blame] | 224 | static const struct fsl_usb2_platform_data otg_device_pdata __initconst = { |
Eric Bénard | 9f2270d | 2010-05-19 18:46:02 +0200 | [diff] [blame] | 225 | .operating_mode = FSL_USB2_DR_DEVICE, |
| 226 | .phy_mode = FSL_USB2_PHY_ULPI, |
| 227 | }; |
| 228 | |
| 229 | static int otg_mode_host; |
| 230 | |
| 231 | static int __init eukrea_cpuimx27_otg_mode(char *options) |
| 232 | { |
| 233 | if (!strcmp(options, "host")) |
| 234 | otg_mode_host = 1; |
| 235 | else if (!strcmp(options, "device")) |
| 236 | otg_mode_host = 0; |
| 237 | else |
| 238 | pr_info("otg_mode neither \"host\" nor \"device\". " |
| 239 | "Defaulting to device\n"); |
| 240 | return 0; |
| 241 | } |
| 242 | __setup("otg_mode=", eukrea_cpuimx27_otg_mode); |
| 243 | |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 244 | static void __init eukrea_cpuimx27_init(void) |
| 245 | { |
| 246 | mxc_gpio_setup_multiple_pins(eukrea_cpuimx27_pins, |
| 247 | ARRAY_SIZE(eukrea_cpuimx27_pins), "CPUIMX27"); |
| 248 | |
Uwe Kleine-König | d5dac4a | 2010-06-23 09:36:01 +0200 | [diff] [blame] | 249 | imx27_add_imx_uart0(&uart_pdata); |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 250 | |
Uwe Kleine-König | 0e7a29a | 2010-06-16 07:35:31 +0200 | [diff] [blame] | 251 | imx27_add_mxc_nand(&cpuimx27_nand_board_info); |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 252 | |
| 253 | i2c_register_board_info(0, eukrea_cpuimx27_i2c_devices, |
| 254 | ARRAY_SIZE(eukrea_cpuimx27_i2c_devices)); |
| 255 | |
Russell King | f779b7d | 2010-10-19 20:12:24 +0100 | [diff] [blame] | 256 | imx27_add_imx_i2c(0, &cpuimx27_i2c1_data); |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 257 | |
Uwe Kleine-König | 6bd96f3 | 2010-10-06 12:00:18 +0200 | [diff] [blame] | 258 | imx27_add_fec(NULL); |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 259 | platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); |
Uwe Kleine-König | e0a1961 | 2010-11-04 10:09:10 +0100 | [diff] [blame] | 260 | imx27_add_imx2_wdt(NULL); |
Uwe Kleine-König | ae71a56 | 2010-10-29 10:56:07 +0200 | [diff] [blame] | 261 | imx27_add_mxc_w1(NULL); |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 262 | |
| 263 | #if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2) |
| 264 | /* SDHC2 can be used for Wifi */ |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 265 | imx27_add_mxc_mmc(1, NULL); |
Eric Bénard | 2d66c78 | 2010-05-19 18:45:59 +0200 | [diff] [blame] | 266 | #endif |
| 267 | #if defined(MACH_EUKREA_CPUIMX27_USEUART4) |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 268 | /* in which case UART4 is also used for Bluetooth */ |
Uwe Kleine-König | d5dac4a | 2010-06-23 09:36:01 +0200 | [diff] [blame] | 269 | imx27_add_imx_uart3(&uart_pdata); |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 270 | #endif |
| 271 | |
| 272 | #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) |
| 273 | platform_device_register(&serial_device); |
| 274 | #endif |
| 275 | |
Eric Bénard | 9f2270d | 2010-05-19 18:46:02 +0200 | [diff] [blame] | 276 | #if defined(CONFIG_USB_ULPI) |
| 277 | if (otg_mode_host) { |
| 278 | otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops, |
Uwe Kleine-König | 70ddd47 | 2010-08-13 14:06:50 +0200 | [diff] [blame] | 279 | ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT); |
Eric Bénard | 9f2270d | 2010-05-19 18:46:02 +0200 | [diff] [blame] | 280 | |
Uwe Kleine-König | 2eb42d5 | 2010-11-05 18:52:09 +0100 | [diff] [blame] | 281 | imx27_add_mxc_ehci_otg(&otg_pdata); |
Eric Bénard | 9f2270d | 2010-05-19 18:46:02 +0200 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | usbh2_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops, |
Uwe Kleine-König | 70ddd47 | 2010-08-13 14:06:50 +0200 | [diff] [blame] | 285 | ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT); |
Eric Bénard | 9f2270d | 2010-05-19 18:46:02 +0200 | [diff] [blame] | 286 | |
Uwe Kleine-König | 2eb42d5 | 2010-11-05 18:52:09 +0100 | [diff] [blame] | 287 | imx27_add_mxc_ehci_hs(2, &usbh2_pdata); |
Eric Bénard | 9f2270d | 2010-05-19 18:46:02 +0200 | [diff] [blame] | 288 | #endif |
| 289 | if (!otg_mode_host) |
Uwe Kleine-König | bd455ed | 2010-11-09 17:52:14 +0100 | [diff] [blame] | 290 | imx27_add_fsl_usb2_udc(&otg_device_pdata); |
Eric Bénard | 9f2270d | 2010-05-19 18:46:02 +0200 | [diff] [blame] | 291 | |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 292 | #ifdef CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD |
| 293 | eukrea_mbimx27_baseboard_init(); |
| 294 | #endif |
| 295 | } |
| 296 | |
| 297 | static void __init eukrea_cpuimx27_timer_init(void) |
| 298 | { |
| 299 | mx27_clocks_init(26000000); |
| 300 | } |
| 301 | |
| 302 | static struct sys_timer eukrea_cpuimx27_timer = { |
| 303 | .init = eukrea_cpuimx27_timer_init, |
| 304 | }; |
| 305 | |
| 306 | MACHINE_START(CPUIMX27, "EUKREA CPUIMX27") |
Uwe Kleine-König | 3410123 | 2010-01-29 17:36:05 +0100 | [diff] [blame] | 307 | .boot_params = MX27_PHYS_OFFSET + 0x100, |
Eric Benard | af5b1df | 2009-07-16 16:26:33 +0200 | [diff] [blame] | 308 | .map_io = mx27_map_io, |
| 309 | .init_irq = mx27_init_irq, |
| 310 | .init_machine = eukrea_cpuimx27_init, |
| 311 | .timer = &eukrea_cpuimx27_timer, |
| 312 | MACHINE_END |