Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 Sascha Hauer, Pengutronix |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | */ |
| 18 | |
| 19 | #include <linux/types.h> |
| 20 | #include <linux/init.h> |
| 21 | |
| 22 | #include <linux/platform_device.h> |
| 23 | #include <linux/mtd/physmap.h> |
Sascha Hauer | 3dad21a | 2008-11-23 17:32:49 +0100 | [diff] [blame] | 24 | #include <linux/mtd/plat-ram.h> |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 25 | #include <linux/memory.h> |
Guennadi Liakhovetski | ba54b95 | 2008-11-11 15:12:00 +0100 | [diff] [blame] | 26 | #include <linux/gpio.h> |
Steve Glendinning | 4353318 | 2009-01-20 13:22:29 +0000 | [diff] [blame] | 27 | #include <linux/smsc911x.h> |
Guennadi Liakhovetski | ba54b95 | 2008-11-11 15:12:00 +0100 | [diff] [blame] | 28 | #include <linux/interrupt.h> |
Sascha Hauer | 7920675 | 2009-01-28 17:10:32 +0100 | [diff] [blame] | 29 | #include <linux/i2c.h> |
| 30 | #include <linux/i2c/at24.h> |
Sascha Hauer | dddd4a4 | 2009-03-10 11:56:10 +0100 | [diff] [blame^] | 31 | #include <linux/delay.h> |
| 32 | #include <linux/spi/spi.h> |
| 33 | #include <linux/irq.h> |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 34 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 35 | #include <mach/hardware.h> |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 36 | #include <asm/mach-types.h> |
| 37 | #include <asm/mach/arch.h> |
| 38 | #include <asm/mach/time.h> |
| 39 | #include <asm/mach/map.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 40 | #include <mach/common.h> |
| 41 | #include <mach/imx-uart.h> |
| 42 | #include <mach/iomux-mx3.h> |
| 43 | #include <mach/board-pcm037.h> |
Sascha Hauer | 3287abb | 2008-11-23 17:34:04 +0100 | [diff] [blame] | 44 | #include <mach/mxc_nand.h> |
Sascha Hauer | f2cb641 | 2008-11-11 15:03:28 +0100 | [diff] [blame] | 45 | #include <mach/mmc.h> |
Sascha Hauer | 7920675 | 2009-01-28 17:10:32 +0100 | [diff] [blame] | 46 | #ifdef CONFIG_I2C_IMX |
| 47 | #include <mach/i2c.h> |
| 48 | #endif |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 49 | |
Sascha Hauer | 5cf0942 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 50 | #include "devices.h" |
| 51 | |
Sascha Hauer | 01ac7d5 | 2009-03-13 19:52:41 +0100 | [diff] [blame] | 52 | static unsigned int pcm037_pins[] = { |
| 53 | /* I2C */ |
| 54 | MX31_PIN_CSPI2_MOSI__SCL, |
| 55 | MX31_PIN_CSPI2_MISO__SDA, |
| 56 | /* SDHC1 */ |
| 57 | MX31_PIN_SD1_DATA3__SD1_DATA3, |
| 58 | MX31_PIN_SD1_DATA2__SD1_DATA2, |
| 59 | MX31_PIN_SD1_DATA1__SD1_DATA1, |
| 60 | MX31_PIN_SD1_DATA0__SD1_DATA0, |
| 61 | MX31_PIN_SD1_CLK__SD1_CLK, |
| 62 | MX31_PIN_SD1_CMD__SD1_CMD, |
| 63 | IOMUX_MODE(MX31_PIN_SCK6, IOMUX_CONFIG_GPIO), /* card detect */ |
| 64 | IOMUX_MODE(MX31_PIN_SFS6, IOMUX_CONFIG_GPIO), /* write protect */ |
| 65 | /* SPI1 */ |
| 66 | MX31_PIN_CSPI1_MOSI__MOSI, |
| 67 | MX31_PIN_CSPI1_MISO__MISO, |
| 68 | MX31_PIN_CSPI1_SCLK__SCLK, |
| 69 | MX31_PIN_CSPI1_SPI_RDY__SPI_RDY, |
| 70 | MX31_PIN_CSPI1_SS0__SS0, |
| 71 | MX31_PIN_CSPI1_SS1__SS1, |
| 72 | MX31_PIN_CSPI1_SS2__SS2, |
| 73 | /* UART1 */ |
| 74 | MX31_PIN_CTS1__CTS1, |
| 75 | MX31_PIN_RTS1__RTS1, |
| 76 | MX31_PIN_TXD1__TXD1, |
| 77 | MX31_PIN_RXD1__RXD1, |
| 78 | /* UART2 */ |
| 79 | MX31_PIN_TXD2__TXD2, |
| 80 | MX31_PIN_RXD2__RXD2, |
| 81 | MX31_PIN_CTS2__CTS2, |
| 82 | MX31_PIN_RTS2__RTS2, |
| 83 | /* UART3 */ |
| 84 | MX31_PIN_CSPI3_MOSI__RXD3, |
| 85 | MX31_PIN_CSPI3_MISO__TXD3, |
| 86 | MX31_PIN_CSPI3_SCLK__RTS3, |
| 87 | MX31_PIN_CSPI3_SPI_RDY__CTS3, |
| 88 | /* LAN9217 irq pin */ |
| 89 | IOMUX_MODE(MX31_PIN_GPIO3_1, IOMUX_CONFIG_GPIO), |
| 90 | /* Onewire */ |
| 91 | MX31_PIN_BATT_LINE__OWIRE, |
| 92 | /* Framebuffer */ |
| 93 | MX31_PIN_LD0__LD0, |
| 94 | MX31_PIN_LD1__LD1, |
| 95 | MX31_PIN_LD2__LD2, |
| 96 | MX31_PIN_LD3__LD3, |
| 97 | MX31_PIN_LD4__LD4, |
| 98 | MX31_PIN_LD5__LD5, |
| 99 | MX31_PIN_LD6__LD6, |
| 100 | MX31_PIN_LD7__LD7, |
| 101 | MX31_PIN_LD8__LD8, |
| 102 | MX31_PIN_LD9__LD9, |
| 103 | MX31_PIN_LD10__LD10, |
| 104 | MX31_PIN_LD11__LD11, |
| 105 | MX31_PIN_LD12__LD12, |
| 106 | MX31_PIN_LD13__LD13, |
| 107 | MX31_PIN_LD14__LD14, |
| 108 | MX31_PIN_LD15__LD15, |
| 109 | MX31_PIN_LD16__LD16, |
| 110 | MX31_PIN_LD17__LD17, |
| 111 | MX31_PIN_VSYNC3__VSYNC3, |
| 112 | MX31_PIN_HSYNC__HSYNC, |
| 113 | MX31_PIN_FPSHIFT__FPSHIFT, |
| 114 | MX31_PIN_DRDY0__DRDY0, |
| 115 | MX31_PIN_D3_REV__D3_REV, |
| 116 | MX31_PIN_CONTRAST__CONTRAST, |
| 117 | MX31_PIN_D3_SPL__D3_SPL, |
| 118 | MX31_PIN_D3_CLS__D3_CLS, |
| 119 | MX31_PIN_LCS0__GPI03_23, |
| 120 | }; |
| 121 | |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 122 | static struct physmap_flash_data pcm037_flash_data = { |
| 123 | .width = 2, |
| 124 | }; |
| 125 | |
| 126 | static struct resource pcm037_flash_resource = { |
| 127 | .start = 0xa0000000, |
| 128 | .end = 0xa1ffffff, |
| 129 | .flags = IORESOURCE_MEM, |
| 130 | }; |
| 131 | |
| 132 | static struct platform_device pcm037_flash = { |
| 133 | .name = "physmap-flash", |
| 134 | .id = 0, |
| 135 | .dev = { |
| 136 | .platform_data = &pcm037_flash_data, |
| 137 | }, |
| 138 | .resource = &pcm037_flash_resource, |
| 139 | .num_resources = 1, |
| 140 | }; |
| 141 | |
| 142 | static struct imxuart_platform_data uart_pdata = { |
Sascha Hauer | a9b0623 | 2008-09-02 10:19:29 +0200 | [diff] [blame] | 143 | .flags = IMXUART_HAVE_RTSCTS, |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 144 | }; |
| 145 | |
Steve Glendinning | 4353318 | 2009-01-20 13:22:29 +0000 | [diff] [blame] | 146 | static struct resource smsc911x_resources[] = { |
Guennadi Liakhovetski | ba54b95 | 2008-11-11 15:12:00 +0100 | [diff] [blame] | 147 | [0] = { |
| 148 | .start = CS1_BASE_ADDR + 0x300, |
| 149 | .end = CS1_BASE_ADDR + 0x300 + SZ_64K - 1, |
| 150 | .flags = IORESOURCE_MEM, |
| 151 | }, |
| 152 | [1] = { |
| 153 | .start = IOMUX_TO_IRQ(MX31_PIN_GPIO3_1), |
| 154 | .end = IOMUX_TO_IRQ(MX31_PIN_GPIO3_1), |
Steve Glendinning | 4353318 | 2009-01-20 13:22:29 +0000 | [diff] [blame] | 155 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, |
Guennadi Liakhovetski | ba54b95 | 2008-11-11 15:12:00 +0100 | [diff] [blame] | 156 | }, |
| 157 | }; |
| 158 | |
Steve Glendinning | 4353318 | 2009-01-20 13:22:29 +0000 | [diff] [blame] | 159 | static struct smsc911x_platform_config smsc911x_info = { |
| 160 | .flags = SMSC911X_USE_32BIT | SMSC911X_FORCE_INTERNAL_PHY | |
| 161 | SMSC911X_SAVE_MAC_ADDRESS, |
| 162 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 163 | .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN, |
| 164 | .phy_interface = PHY_INTERFACE_MODE_MII, |
Guennadi Liakhovetski | ba54b95 | 2008-11-11 15:12:00 +0100 | [diff] [blame] | 165 | }; |
| 166 | |
| 167 | static struct platform_device pcm037_eth = { |
Steve Glendinning | 4353318 | 2009-01-20 13:22:29 +0000 | [diff] [blame] | 168 | .name = "smsc911x", |
Guennadi Liakhovetski | ba54b95 | 2008-11-11 15:12:00 +0100 | [diff] [blame] | 169 | .id = -1, |
Steve Glendinning | 4353318 | 2009-01-20 13:22:29 +0000 | [diff] [blame] | 170 | .num_resources = ARRAY_SIZE(smsc911x_resources), |
| 171 | .resource = smsc911x_resources, |
Guennadi Liakhovetski | ba54b95 | 2008-11-11 15:12:00 +0100 | [diff] [blame] | 172 | .dev = { |
Steve Glendinning | 4353318 | 2009-01-20 13:22:29 +0000 | [diff] [blame] | 173 | .platform_data = &smsc911x_info, |
Guennadi Liakhovetski | ba54b95 | 2008-11-11 15:12:00 +0100 | [diff] [blame] | 174 | }, |
| 175 | }; |
| 176 | |
Sascha Hauer | 3dad21a | 2008-11-23 17:32:49 +0100 | [diff] [blame] | 177 | static struct platdata_mtd_ram pcm038_sram_data = { |
| 178 | .bankwidth = 2, |
| 179 | }; |
| 180 | |
| 181 | static struct resource pcm038_sram_resource = { |
| 182 | .start = CS4_BASE_ADDR, |
| 183 | .end = CS4_BASE_ADDR + 512 * 1024 - 1, |
| 184 | .flags = IORESOURCE_MEM, |
| 185 | }; |
| 186 | |
| 187 | static struct platform_device pcm037_sram_device = { |
| 188 | .name = "mtd-ram", |
| 189 | .id = 0, |
| 190 | .dev = { |
| 191 | .platform_data = &pcm038_sram_data, |
| 192 | }, |
| 193 | .num_resources = 1, |
| 194 | .resource = &pcm038_sram_resource, |
| 195 | }; |
| 196 | |
Sascha Hauer | 3287abb | 2008-11-23 17:34:04 +0100 | [diff] [blame] | 197 | static struct mxc_nand_platform_data pcm037_nand_board_info = { |
| 198 | .width = 1, |
| 199 | .hw_ecc = 1, |
| 200 | }; |
| 201 | |
Sascha Hauer | 7920675 | 2009-01-28 17:10:32 +0100 | [diff] [blame] | 202 | #ifdef CONFIG_I2C_IMX |
Sascha Hauer | 7920675 | 2009-01-28 17:10:32 +0100 | [diff] [blame] | 203 | static struct imxi2c_platform_data pcm037_i2c_1_data = { |
| 204 | .bitrate = 100000, |
Sascha Hauer | 7920675 | 2009-01-28 17:10:32 +0100 | [diff] [blame] | 205 | }; |
| 206 | |
| 207 | static struct at24_platform_data board_eeprom = { |
| 208 | .byte_len = 4096, |
| 209 | .page_size = 32, |
| 210 | .flags = AT24_FLAG_ADDR16, |
| 211 | }; |
| 212 | |
| 213 | static struct i2c_board_info pcm037_i2c_devices[] = { |
| 214 | { |
| 215 | I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */ |
| 216 | .platform_data = &board_eeprom, |
| 217 | }, { |
| 218 | I2C_BOARD_INFO("rtc-pcf8563", 0x51), |
| 219 | .type = "pcf8563", |
| 220 | } |
| 221 | }; |
| 222 | #endif |
| 223 | |
Sascha Hauer | dddd4a4 | 2009-03-10 11:56:10 +0100 | [diff] [blame^] | 224 | /* Not connected by default */ |
| 225 | #ifdef PCM970_SDHC_RW_SWITCH |
| 226 | static int pcm970_sdhc1_get_ro(struct device *dev) |
Sascha Hauer | f2cb641 | 2008-11-11 15:03:28 +0100 | [diff] [blame] | 227 | { |
Sascha Hauer | dddd4a4 | 2009-03-10 11:56:10 +0100 | [diff] [blame^] | 228 | return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_SFS6)); |
| 229 | } |
| 230 | #endif |
| 231 | |
| 232 | static int pcm970_sdhc1_init(struct device *dev, irq_handler_t detect_irq, |
| 233 | void *data) |
| 234 | { |
| 235 | int ret; |
| 236 | int gpio_det, gpio_wp; |
| 237 | |
| 238 | gpio_det = IOMUX_TO_GPIO(MX31_PIN_SCK6); |
| 239 | gpio_wp = IOMUX_TO_GPIO(MX31_PIN_SFS6); |
| 240 | |
| 241 | gpio_direction_input(gpio_det); |
| 242 | gpio_direction_input(gpio_wp); |
| 243 | |
| 244 | ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_SCK6), detect_irq, |
| 245 | IRQF_DISABLED | IRQF_TRIGGER_FALLING, |
| 246 | "sdhc-detect", data); |
| 247 | return ret; |
Sascha Hauer | f2cb641 | 2008-11-11 15:03:28 +0100 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | static void pcm970_sdhc1_exit(struct device *dev, void *data) |
| 251 | { |
Sascha Hauer | dddd4a4 | 2009-03-10 11:56:10 +0100 | [diff] [blame^] | 252 | free_irq(IOMUX_TO_IRQ(MX31_PIN_SCK6), data); |
Sascha Hauer | f2cb641 | 2008-11-11 15:03:28 +0100 | [diff] [blame] | 253 | } |
| 254 | |
Sascha Hauer | f2cb641 | 2008-11-11 15:03:28 +0100 | [diff] [blame] | 255 | static struct imxmmc_platform_data sdhc_pdata = { |
Sascha Hauer | dddd4a4 | 2009-03-10 11:56:10 +0100 | [diff] [blame^] | 256 | #ifdef PCM970_SDHC_RW_SWITCH |
| 257 | .get_ro = pcm970_sdhc1_get_ro, |
| 258 | #endif |
Sascha Hauer | f2cb641 | 2008-11-11 15:03:28 +0100 | [diff] [blame] | 259 | .init = pcm970_sdhc1_init, |
| 260 | .exit = pcm970_sdhc1_exit, |
| 261 | }; |
| 262 | |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 263 | static struct platform_device *devices[] __initdata = { |
| 264 | &pcm037_flash, |
Guennadi Liakhovetski | ba54b95 | 2008-11-11 15:12:00 +0100 | [diff] [blame] | 265 | &pcm037_eth, |
Sascha Hauer | 3dad21a | 2008-11-23 17:32:49 +0100 | [diff] [blame] | 266 | &pcm037_sram_device, |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 267 | }; |
| 268 | |
| 269 | /* |
| 270 | * Board specific initialization. |
| 271 | */ |
| 272 | static void __init mxc_board_init(void) |
| 273 | { |
Sascha Hauer | 01ac7d5 | 2009-03-13 19:52:41 +0100 | [diff] [blame] | 274 | mxc_iomux_setup_multiple_pins(pcm037_pins, ARRAY_SIZE(pcm037_pins), |
| 275 | "pcm037"); |
| 276 | |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 277 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 278 | |
Sascha Hauer | 5cf0942 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 279 | mxc_register_device(&mxc_uart_device0, &uart_pdata); |
Sascha Hauer | 5cf0942 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 280 | mxc_register_device(&mxc_uart_device2, &uart_pdata); |
Sascha Hauer | d517cab | 2008-12-01 14:15:40 -0800 | [diff] [blame] | 281 | |
Sascha Hauer | d517cab | 2008-12-01 14:15:40 -0800 | [diff] [blame] | 282 | mxc_register_device(&mxc_w1_master_device, NULL); |
Guennadi Liakhovetski | ba54b95 | 2008-11-11 15:12:00 +0100 | [diff] [blame] | 283 | |
Sascha Hauer | f8e5143 | 2009-04-04 13:40:39 +0200 | [diff] [blame] | 284 | /* LAN9217 IRQ pin */ |
Sascha Hauer | 01ac7d5 | 2009-03-13 19:52:41 +0100 | [diff] [blame] | 285 | gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO3_1)); |
Sascha Hauer | 3287abb | 2008-11-23 17:34:04 +0100 | [diff] [blame] | 286 | |
Sascha Hauer | 7920675 | 2009-01-28 17:10:32 +0100 | [diff] [blame] | 287 | #ifdef CONFIG_I2C_IMX |
| 288 | i2c_register_board_info(1, pcm037_i2c_devices, |
| 289 | ARRAY_SIZE(pcm037_i2c_devices)); |
| 290 | |
| 291 | mxc_register_device(&mxc_i2c_device1, &pcm037_i2c_1_data); |
| 292 | #endif |
Sascha Hauer | 3287abb | 2008-11-23 17:34:04 +0100 | [diff] [blame] | 293 | mxc_register_device(&mxc_nand_device, &pcm037_nand_board_info); |
Sascha Hauer | f2cb641 | 2008-11-11 15:03:28 +0100 | [diff] [blame] | 294 | mxc_register_device(&mxcsdhc_device0, &sdhc_pdata); |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 295 | } |
| 296 | |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 297 | static void __init pcm037_timer_init(void) |
| 298 | { |
Sascha Hauer | 30c730f | 2009-02-16 14:36:49 +0100 | [diff] [blame] | 299 | mx31_clocks_init(26000000); |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | struct sys_timer pcm037_timer = { |
| 303 | .init = pcm037_timer_init, |
| 304 | }; |
| 305 | |
| 306 | MACHINE_START(PCM037, "Phytec Phycore pcm037") |
| 307 | /* Maintainer: Pengutronix */ |
| 308 | .phys_io = AIPS1_BASE_ADDR, |
| 309 | .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc, |
| 310 | .boot_params = PHYS_OFFSET + 0x100, |
Sascha Hauer | fb4416a | 2009-02-06 18:15:06 +0100 | [diff] [blame] | 311 | .map_io = mxc_map_io, |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 312 | .init_irq = mxc_init_irq, |
| 313 | .init_machine = mxc_board_init, |
| 314 | .timer = &pcm037_timer, |
| 315 | MACHINE_END |
| 316 | |