Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 Valentin Longchamp, EPFL Mobots group |
| 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 | |
Valentin Longchamp | b23f153 | 2009-08-10 18:33:11 +0200 | [diff] [blame] | 19 | #include <linux/delay.h> |
Valentin Longchamp | 88b0564 | 2009-08-10 18:33:12 +0200 | [diff] [blame] | 20 | #include <linux/fsl_devices.h> |
Valentin Longchamp | 45b131a | 2009-04-21 10:24:56 +0200 | [diff] [blame] | 21 | #include <linux/gpio.h> |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 22 | #include <linux/init.h> |
Valentin Longchamp | 45b131a | 2009-04-21 10:24:56 +0200 | [diff] [blame] | 23 | #include <linux/interrupt.h> |
Valentin Longchamp | 77aa561 | 2009-08-12 11:29:19 +0200 | [diff] [blame] | 24 | #include <linux/leds.h> |
Valentin Longchamp | 220bbce | 2009-04-17 15:20:25 +0200 | [diff] [blame] | 25 | #include <linux/memory.h> |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 26 | #include <linux/mtd/physmap.h> |
| 27 | #include <linux/mtd/partitions.h> |
Valentin Longchamp | 220bbce | 2009-04-17 15:20:25 +0200 | [diff] [blame] | 28 | #include <linux/platform_device.h> |
Valentin Longchamp | 65da979 | 2009-11-03 18:09:49 +0100 | [diff] [blame] | 29 | #include <linux/regulator/machine.h> |
| 30 | #include <linux/mfd/mc13783.h> |
| 31 | #include <linux/spi/spi.h> |
Valentin Longchamp | 220bbce | 2009-04-17 15:20:25 +0200 | [diff] [blame] | 32 | #include <linux/types.h> |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 33 | |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/mach/arch.h> |
| 36 | #include <asm/mach/time.h> |
| 37 | #include <asm/mach/map.h> |
Valentin Longchamp | 220bbce | 2009-04-17 15:20:25 +0200 | [diff] [blame] | 38 | #include <mach/board-mx31moboard.h> |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 39 | #include <mach/common.h> |
Valentin Longchamp | 220bbce | 2009-04-17 15:20:25 +0200 | [diff] [blame] | 40 | #include <mach/hardware.h> |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 41 | #include <mach/imx-uart.h> |
| 42 | #include <mach/iomux-mx3.h> |
Valentin Longchamp | 4dd7129 | 2009-11-03 18:09:50 +0100 | [diff] [blame^] | 43 | #include <mach/ipu.h> |
Valentin Longchamp | 4ec6ecc | 2009-04-21 10:24:22 +0200 | [diff] [blame] | 44 | #include <mach/i2c.h> |
Valentin Longchamp | 45b131a | 2009-04-21 10:24:56 +0200 | [diff] [blame] | 45 | #include <mach/mmc.h> |
Valentin Longchamp | 65da979 | 2009-11-03 18:09:49 +0100 | [diff] [blame] | 46 | #include <mach/mx3_camera.h> |
| 47 | #include <mach/spi.h> |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 48 | |
| 49 | #include "devices.h" |
| 50 | |
Valentin Longchamp | 220bbce | 2009-04-17 15:20:25 +0200 | [diff] [blame] | 51 | static unsigned int moboard_pins[] = { |
| 52 | /* UART0 */ |
Valentin Longchamp | 220bbce | 2009-04-17 15:20:25 +0200 | [diff] [blame] | 53 | MX31_PIN_TXD1__TXD1, MX31_PIN_RXD1__RXD1, |
Valentin Longchamp | 421bf82 | 2009-11-03 18:09:47 +0100 | [diff] [blame] | 54 | MX31_PIN_CTS1__GPIO2_7, |
Valentin Longchamp | 220bbce | 2009-04-17 15:20:25 +0200 | [diff] [blame] | 55 | /* UART4 */ |
| 56 | MX31_PIN_PC_RST__CTS5, MX31_PIN_PC_VS2__RTS5, |
| 57 | MX31_PIN_PC_BVD2__TXD5, MX31_PIN_PC_BVD1__RXD5, |
Valentin Longchamp | 56c7a45 | 2009-04-22 10:55:50 +0200 | [diff] [blame] | 58 | /* I2C0 */ |
| 59 | MX31_PIN_I2C_DAT__I2C1_SDA, MX31_PIN_I2C_CLK__I2C1_SCL, |
| 60 | /* I2C1 */ |
| 61 | MX31_PIN_DCD_DTE1__I2C2_SDA, MX31_PIN_RI_DTE1__I2C2_SCL, |
| 62 | /* SDHC1 */ |
| 63 | MX31_PIN_SD1_DATA3__SD1_DATA3, MX31_PIN_SD1_DATA2__SD1_DATA2, |
| 64 | MX31_PIN_SD1_DATA1__SD1_DATA1, MX31_PIN_SD1_DATA0__SD1_DATA0, |
| 65 | MX31_PIN_SD1_CLK__SD1_CLK, MX31_PIN_SD1_CMD__SD1_CMD, |
| 66 | MX31_PIN_ATA_CS0__GPIO3_26, MX31_PIN_ATA_CS1__GPIO3_27, |
Valentin Longchamp | b23f153 | 2009-08-10 18:33:11 +0200 | [diff] [blame] | 67 | /* USB reset */ |
| 68 | MX31_PIN_GPIO1_0__GPIO1_0, |
Valentin Longchamp | 88b0564 | 2009-08-10 18:33:12 +0200 | [diff] [blame] | 69 | /* USB OTG */ |
| 70 | MX31_PIN_USBOTG_DATA0__USBOTG_DATA0, |
| 71 | MX31_PIN_USBOTG_DATA1__USBOTG_DATA1, |
| 72 | MX31_PIN_USBOTG_DATA2__USBOTG_DATA2, |
| 73 | MX31_PIN_USBOTG_DATA3__USBOTG_DATA3, |
| 74 | MX31_PIN_USBOTG_DATA4__USBOTG_DATA4, |
| 75 | MX31_PIN_USBOTG_DATA5__USBOTG_DATA5, |
| 76 | MX31_PIN_USBOTG_DATA6__USBOTG_DATA6, |
| 77 | MX31_PIN_USBOTG_DATA7__USBOTG_DATA7, |
| 78 | MX31_PIN_USBOTG_CLK__USBOTG_CLK, MX31_PIN_USBOTG_DIR__USBOTG_DIR, |
| 79 | MX31_PIN_USBOTG_NXT__USBOTG_NXT, MX31_PIN_USBOTG_STP__USBOTG_STP, |
| 80 | MX31_PIN_USB_OC__GPIO1_30, |
Valentin Longchamp | 77aa561 | 2009-08-12 11:29:19 +0200 | [diff] [blame] | 81 | /* LEDs */ |
| 82 | MX31_PIN_SVEN0__GPIO2_0, MX31_PIN_STX0__GPIO2_1, |
| 83 | MX31_PIN_SRX0__GPIO2_2, MX31_PIN_SIMPD0__GPIO2_3, |
Valentin Longchamp | 8b1a540 | 2009-08-12 11:29:20 +0200 | [diff] [blame] | 84 | /* SEL */ |
| 85 | MX31_PIN_DTR_DCE1__GPIO2_8, MX31_PIN_DSR_DCE1__GPIO2_9, |
| 86 | MX31_PIN_RI_DCE1__GPIO2_10, MX31_PIN_DCD_DCE1__GPIO2_11, |
Valentin Longchamp | 65da979 | 2009-11-03 18:09:49 +0100 | [diff] [blame] | 87 | /* SPI1 */ |
| 88 | MX31_PIN_CSPI2_MOSI__MOSI, MX31_PIN_CSPI2_MISO__MISO, |
| 89 | MX31_PIN_CSPI2_SCLK__SCLK, MX31_PIN_CSPI2_SPI_RDY__SPI_RDY, |
| 90 | MX31_PIN_CSPI2_SS0__SS0, MX31_PIN_CSPI2_SS2__SS2, |
| 91 | /* Atlas IRQ */ |
| 92 | MX31_PIN_GPIO1_3__GPIO1_3, |
| 93 | /* SPI2 */ |
| 94 | MX31_PIN_CSPI3_MOSI__MOSI, MX31_PIN_CSPI3_MISO__MISO, |
| 95 | MX31_PIN_CSPI3_SCLK__SCLK, MX31_PIN_CSPI3_SPI_RDY__SPI_RDY, |
| 96 | MX31_PIN_CSPI2_SS1__CSPI3_SS1, |
Valentin Longchamp | 220bbce | 2009-04-17 15:20:25 +0200 | [diff] [blame] | 97 | }; |
| 98 | |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 99 | static struct physmap_flash_data mx31moboard_flash_data = { |
| 100 | .width = 2, |
| 101 | }; |
| 102 | |
| 103 | static struct resource mx31moboard_flash_resource = { |
| 104 | .start = 0xa0000000, |
| 105 | .end = 0xa1ffffff, |
| 106 | .flags = IORESOURCE_MEM, |
| 107 | }; |
| 108 | |
| 109 | static struct platform_device mx31moboard_flash = { |
| 110 | .name = "physmap-flash", |
| 111 | .id = 0, |
| 112 | .dev = { |
| 113 | .platform_data = &mx31moboard_flash_data, |
| 114 | }, |
| 115 | .resource = &mx31moboard_flash_resource, |
| 116 | .num_resources = 1, |
| 117 | }; |
| 118 | |
Valentin Longchamp | 421bf82 | 2009-11-03 18:09:47 +0100 | [diff] [blame] | 119 | static int moboard_uart0_init(struct platform_device *pdev) |
| 120 | { |
| 121 | gpio_request(IOMUX_TO_GPIO(MX31_PIN_CTS1), "uart0-cts-hack"); |
| 122 | gpio_direction_output(IOMUX_TO_GPIO(MX31_PIN_CTS1), 0); |
| 123 | return 0; |
| 124 | } |
| 125 | |
| 126 | static struct imxuart_platform_data uart0_pdata = { |
| 127 | .init = moboard_uart0_init, |
| 128 | }; |
| 129 | |
| 130 | static struct imxuart_platform_data uart4_pdata = { |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 131 | .flags = IMXUART_HAVE_RTSCTS, |
| 132 | }; |
| 133 | |
Valentin Longchamp | 4ec6ecc | 2009-04-21 10:24:22 +0200 | [diff] [blame] | 134 | static struct imxi2c_platform_data moboard_i2c0_pdata = { |
| 135 | .bitrate = 400000, |
| 136 | }; |
| 137 | |
| 138 | static struct imxi2c_platform_data moboard_i2c1_pdata = { |
| 139 | .bitrate = 100000, |
| 140 | }; |
| 141 | |
Valentin Longchamp | 65da979 | 2009-11-03 18:09:49 +0100 | [diff] [blame] | 142 | static int moboard_spi1_cs[] = { |
| 143 | MXC_SPI_CS(0), |
| 144 | MXC_SPI_CS(2), |
| 145 | }; |
| 146 | |
| 147 | static struct spi_imx_master moboard_spi1_master = { |
| 148 | .chipselect = moboard_spi1_cs, |
| 149 | .num_chipselect = ARRAY_SIZE(moboard_spi1_cs), |
| 150 | }; |
| 151 | |
| 152 | static struct regulator_consumer_supply sdhc_consumers[] = { |
| 153 | { |
| 154 | .dev = &mxcsdhc_device0.dev, |
| 155 | .supply = "sdhc0_vcc", |
| 156 | }, |
| 157 | { |
| 158 | .dev = &mxcsdhc_device1.dev, |
| 159 | .supply = "sdhc1_vcc", |
| 160 | }, |
| 161 | }; |
| 162 | |
| 163 | static struct regulator_init_data sdhc_vreg_data = { |
| 164 | .constraints = { |
| 165 | .min_uV = 2700000, |
| 166 | .max_uV = 3000000, |
| 167 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
| 168 | REGULATOR_CHANGE_MODE | REGULATOR_CHANGE_STATUS, |
| 169 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
| 170 | REGULATOR_MODE_FAST, |
| 171 | .always_on = 0, |
| 172 | .boot_on = 1, |
| 173 | }, |
| 174 | .num_consumer_supplies = ARRAY_SIZE(sdhc_consumers), |
| 175 | .consumer_supplies = sdhc_consumers, |
| 176 | }; |
| 177 | |
| 178 | static struct regulator_consumer_supply cam_consumers[] = { |
| 179 | { |
| 180 | .dev = &mx3_camera.dev, |
| 181 | .supply = "cam_vcc", |
| 182 | }, |
| 183 | }; |
| 184 | |
| 185 | static struct regulator_init_data cam_vreg_data = { |
| 186 | .constraints = { |
| 187 | .min_uV = 2700000, |
| 188 | .max_uV = 3000000, |
| 189 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
| 190 | REGULATOR_CHANGE_MODE | REGULATOR_CHANGE_STATUS, |
| 191 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
| 192 | REGULATOR_MODE_FAST, |
| 193 | .always_on = 0, |
| 194 | .boot_on = 1, |
| 195 | }, |
| 196 | .num_consumer_supplies = ARRAY_SIZE(cam_consumers), |
| 197 | .consumer_supplies = cam_consumers, |
| 198 | }; |
| 199 | |
| 200 | static struct mc13783_regulator_init_data moboard_regulators[] = { |
| 201 | { |
| 202 | .id = MC13783_REGU_VMMC1, |
| 203 | .init_data = &sdhc_vreg_data, |
| 204 | }, |
| 205 | { |
| 206 | .id = MC13783_REGU_VCAM, |
| 207 | .init_data = &cam_vreg_data, |
| 208 | }, |
| 209 | }; |
| 210 | |
| 211 | static struct mc13783_platform_data moboard_pmic = { |
| 212 | .regulators = moboard_regulators, |
| 213 | .num_regulators = ARRAY_SIZE(moboard_regulators), |
| 214 | .flags = MC13783_USE_REGULATOR | MC13783_USE_RTC, |
| 215 | }; |
| 216 | |
| 217 | static struct spi_board_info moboard_spi_board_info[] __initdata = { |
| 218 | { |
| 219 | .modalias = "mc13783", |
| 220 | .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3), |
| 221 | .max_speed_hz = 300000, |
| 222 | .bus_num = 1, |
| 223 | .chip_select = 0, |
| 224 | .platform_data = &moboard_pmic, |
| 225 | .mode = SPI_CS_HIGH, |
| 226 | }, |
| 227 | { |
| 228 | .modalias = "spidev", |
| 229 | .max_speed_hz = 300000, |
| 230 | .bus_num = 1, |
| 231 | .chip_select = 1, /* according spi1_cs[] ! */ |
| 232 | }, |
| 233 | }; |
| 234 | |
| 235 | static int moboard_spi2_cs[] = { |
| 236 | MXC_SPI_CS(1), |
| 237 | }; |
| 238 | |
| 239 | static struct spi_imx_master moboard_spi2_master = { |
| 240 | .chipselect = moboard_spi2_cs, |
| 241 | .num_chipselect = ARRAY_SIZE(moboard_spi2_cs), |
| 242 | }; |
| 243 | |
Valentin Longchamp | 45b131a | 2009-04-21 10:24:56 +0200 | [diff] [blame] | 244 | #define SDHC1_CD IOMUX_TO_GPIO(MX31_PIN_ATA_CS0) |
| 245 | #define SDHC1_WP IOMUX_TO_GPIO(MX31_PIN_ATA_CS1) |
| 246 | |
| 247 | static int moboard_sdhc1_get_ro(struct device *dev) |
| 248 | { |
Valentin Longchamp | 563abb4 | 2009-08-11 17:29:21 +0200 | [diff] [blame] | 249 | return !gpio_get_value(SDHC1_WP); |
Valentin Longchamp | 45b131a | 2009-04-21 10:24:56 +0200 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | static int moboard_sdhc1_init(struct device *dev, irq_handler_t detect_irq, |
| 253 | void *data) |
| 254 | { |
Sascha Hauer | 4f163eb | 2009-05-06 12:55:50 +0200 | [diff] [blame] | 255 | int ret; |
| 256 | |
| 257 | ret = gpio_request(SDHC1_CD, "sdhc-detect"); |
| 258 | if (ret) |
| 259 | return ret; |
| 260 | |
| 261 | gpio_direction_input(SDHC1_CD); |
| 262 | |
| 263 | ret = gpio_request(SDHC1_WP, "sdhc-wp"); |
| 264 | if (ret) |
| 265 | goto err_gpio_free; |
| 266 | gpio_direction_input(SDHC1_WP); |
| 267 | |
| 268 | ret = request_irq(gpio_to_irq(SDHC1_CD), detect_irq, |
Valentin Longchamp | 45b131a | 2009-04-21 10:24:56 +0200 | [diff] [blame] | 269 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
| 270 | "sdhc1-card-detect", data); |
Sascha Hauer | 4f163eb | 2009-05-06 12:55:50 +0200 | [diff] [blame] | 271 | if (ret) |
| 272 | goto err_gpio_free_2; |
| 273 | |
| 274 | return 0; |
| 275 | |
| 276 | err_gpio_free_2: |
| 277 | gpio_free(SDHC1_WP); |
| 278 | err_gpio_free: |
| 279 | gpio_free(SDHC1_CD); |
| 280 | |
| 281 | return ret; |
Valentin Longchamp | 45b131a | 2009-04-21 10:24:56 +0200 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | static void moboard_sdhc1_exit(struct device *dev, void *data) |
| 285 | { |
| 286 | free_irq(gpio_to_irq(SDHC1_CD), data); |
Sascha Hauer | 4f163eb | 2009-05-06 12:55:50 +0200 | [diff] [blame] | 287 | gpio_free(SDHC1_WP); |
| 288 | gpio_free(SDHC1_CD); |
Valentin Longchamp | 45b131a | 2009-04-21 10:24:56 +0200 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | static struct imxmmc_platform_data sdhc1_pdata = { |
| 292 | .get_ro = moboard_sdhc1_get_ro, |
| 293 | .init = moboard_sdhc1_init, |
| 294 | .exit = moboard_sdhc1_exit, |
| 295 | }; |
| 296 | |
Valentin Longchamp | b23f153 | 2009-08-10 18:33:11 +0200 | [diff] [blame] | 297 | /* |
| 298 | * this pin is dedicated for all mx31moboard systems, so we do it here |
| 299 | */ |
| 300 | #define USB_RESET_B IOMUX_TO_GPIO(MX31_PIN_GPIO1_0) |
| 301 | |
| 302 | static void usb_xcvr_reset(void) |
| 303 | { |
| 304 | gpio_request(USB_RESET_B, "usb-reset"); |
| 305 | gpio_direction_output(USB_RESET_B, 0); |
| 306 | mdelay(1); |
| 307 | gpio_set_value(USB_RESET_B, 1); |
| 308 | } |
| 309 | |
Valentin Longchamp | 88b0564 | 2009-08-10 18:33:12 +0200 | [diff] [blame] | 310 | #define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \ |
| 311 | PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU) |
| 312 | |
| 313 | #define OTG_EN_B IOMUX_TO_GPIO(MX31_PIN_USB_OC) |
| 314 | |
| 315 | static void moboard_usbotg_init(void) |
| 316 | { |
| 317 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA0, USB_PAD_CFG); |
| 318 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA1, USB_PAD_CFG); |
| 319 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA2, USB_PAD_CFG); |
| 320 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA3, USB_PAD_CFG); |
| 321 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA4, USB_PAD_CFG); |
| 322 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA5, USB_PAD_CFG); |
| 323 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA6, USB_PAD_CFG); |
| 324 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA7, USB_PAD_CFG); |
| 325 | mxc_iomux_set_pad(MX31_PIN_USBOTG_CLK, USB_PAD_CFG); |
| 326 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DIR, USB_PAD_CFG); |
| 327 | mxc_iomux_set_pad(MX31_PIN_USBOTG_NXT, USB_PAD_CFG); |
| 328 | mxc_iomux_set_pad(MX31_PIN_USBOTG_STP, USB_PAD_CFG); |
| 329 | |
| 330 | gpio_request(OTG_EN_B, "usb-udc-en"); |
| 331 | gpio_direction_output(OTG_EN_B, 0); |
| 332 | } |
| 333 | |
| 334 | static struct fsl_usb2_platform_data usb_pdata = { |
| 335 | .operating_mode = FSL_USB2_DR_DEVICE, |
| 336 | .phy_mode = FSL_USB2_PHY_ULPI, |
| 337 | }; |
| 338 | |
Valentin Longchamp | 77aa561 | 2009-08-12 11:29:19 +0200 | [diff] [blame] | 339 | static struct gpio_led mx31moboard_leds[] = { |
| 340 | { |
| 341 | .name = "coreboard-led-0:red:running", |
| 342 | .default_trigger = "heartbeat", |
| 343 | .gpio = IOMUX_TO_GPIO(MX31_PIN_SVEN0), |
| 344 | }, { |
| 345 | .name = "coreboard-led-1:red", |
| 346 | .gpio = IOMUX_TO_GPIO(MX31_PIN_STX0), |
| 347 | }, { |
| 348 | .name = "coreboard-led-2:red", |
| 349 | .gpio = IOMUX_TO_GPIO(MX31_PIN_SRX0), |
| 350 | }, { |
| 351 | .name = "coreboard-led-3:red", |
| 352 | .gpio = IOMUX_TO_GPIO(MX31_PIN_SIMPD0), |
| 353 | }, |
| 354 | }; |
| 355 | |
| 356 | static struct gpio_led_platform_data mx31moboard_led_pdata = { |
| 357 | .num_leds = ARRAY_SIZE(mx31moboard_leds), |
| 358 | .leds = mx31moboard_leds, |
| 359 | }; |
| 360 | |
| 361 | static struct platform_device mx31moboard_leds_device = { |
| 362 | .name = "leds-gpio", |
| 363 | .id = -1, |
| 364 | .dev = { |
| 365 | .platform_data = &mx31moboard_led_pdata, |
| 366 | }, |
| 367 | }; |
| 368 | |
Valentin Longchamp | 8b1a540 | 2009-08-12 11:29:20 +0200 | [diff] [blame] | 369 | #define SEL0 IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1) |
| 370 | #define SEL1 IOMUX_TO_GPIO(MX31_PIN_DSR_DCE1) |
| 371 | #define SEL2 IOMUX_TO_GPIO(MX31_PIN_RI_DCE1) |
| 372 | #define SEL3 IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1) |
| 373 | |
| 374 | static void mx31moboard_init_sel_gpios(void) |
| 375 | { |
| 376 | if (!gpio_request(SEL0, "sel0")) { |
| 377 | gpio_direction_input(SEL0); |
| 378 | gpio_export(SEL0, true); |
| 379 | } |
| 380 | |
| 381 | if (!gpio_request(SEL1, "sel1")) { |
| 382 | gpio_direction_input(SEL1); |
| 383 | gpio_export(SEL1, true); |
| 384 | } |
| 385 | |
| 386 | if (!gpio_request(SEL2, "sel2")) { |
| 387 | gpio_direction_input(SEL2); |
| 388 | gpio_export(SEL2, true); |
| 389 | } |
| 390 | |
| 391 | if (!gpio_request(SEL3, "sel3")) { |
| 392 | gpio_direction_input(SEL3); |
| 393 | gpio_export(SEL3, true); |
| 394 | } |
| 395 | } |
| 396 | |
Valentin Longchamp | 4dd7129 | 2009-11-03 18:09:50 +0100 | [diff] [blame^] | 397 | static struct ipu_platform_data mx3_ipu_data = { |
| 398 | .irq_base = MXC_IPU_IRQ_START, |
| 399 | }; |
| 400 | |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 401 | static struct platform_device *devices[] __initdata = { |
| 402 | &mx31moboard_flash, |
Valentin Longchamp | 77aa561 | 2009-08-12 11:29:19 +0200 | [diff] [blame] | 403 | &mx31moboard_leds_device, |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 404 | }; |
| 405 | |
Valentin Longchamp | e00f0b4 | 2009-02-16 12:47:51 +0100 | [diff] [blame] | 406 | static int mx31moboard_baseboard; |
| 407 | core_param(mx31moboard_baseboard, mx31moboard_baseboard, int, 0444); |
| 408 | |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 409 | /* |
| 410 | * Board specific initialization. |
| 411 | */ |
| 412 | static void __init mxc_board_init(void) |
| 413 | { |
Valentin Longchamp | 220bbce | 2009-04-17 15:20:25 +0200 | [diff] [blame] | 414 | mxc_iomux_setup_multiple_pins(moboard_pins, ARRAY_SIZE(moboard_pins), |
| 415 | "moboard"); |
| 416 | |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 417 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 418 | |
Valentin Longchamp | 421bf82 | 2009-11-03 18:09:47 +0100 | [diff] [blame] | 419 | mxc_register_device(&mxc_uart_device0, &uart0_pdata); |
| 420 | |
| 421 | mxc_register_device(&mxc_uart_device4, &uart4_pdata); |
Valentin Longchamp | e00f0b4 | 2009-02-16 12:47:51 +0100 | [diff] [blame] | 422 | |
Valentin Longchamp | 8b1a540 | 2009-08-12 11:29:20 +0200 | [diff] [blame] | 423 | mx31moboard_init_sel_gpios(); |
| 424 | |
Valentin Longchamp | 4ec6ecc | 2009-04-21 10:24:22 +0200 | [diff] [blame] | 425 | mxc_register_device(&mxc_i2c_device0, &moboard_i2c0_pdata); |
| 426 | mxc_register_device(&mxc_i2c_device1, &moboard_i2c1_pdata); |
| 427 | |
Valentin Longchamp | 65da979 | 2009-11-03 18:09:49 +0100 | [diff] [blame] | 428 | mxc_register_device(&mxc_spi_device1, &moboard_spi1_master); |
| 429 | mxc_register_device(&mxc_spi_device2, &moboard_spi2_master); |
| 430 | |
| 431 | gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_3), "pmic-irq"); |
| 432 | gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_3)); |
| 433 | spi_register_board_info(moboard_spi_board_info, |
| 434 | ARRAY_SIZE(moboard_spi_board_info)); |
| 435 | |
Valentin Longchamp | 45b131a | 2009-04-21 10:24:56 +0200 | [diff] [blame] | 436 | mxc_register_device(&mxcsdhc_device0, &sdhc1_pdata); |
| 437 | |
Valentin Longchamp | 4dd7129 | 2009-11-03 18:09:50 +0100 | [diff] [blame^] | 438 | mxc_register_device(&mx3_ipu, &mx3_ipu_data); |
| 439 | |
Valentin Longchamp | b23f153 | 2009-08-10 18:33:11 +0200 | [diff] [blame] | 440 | usb_xcvr_reset(); |
| 441 | |
Valentin Longchamp | 88b0564 | 2009-08-10 18:33:12 +0200 | [diff] [blame] | 442 | moboard_usbotg_init(); |
| 443 | mxc_register_device(&mxc_otg_udc_device, &usb_pdata); |
| 444 | |
Valentin Longchamp | e00f0b4 | 2009-02-16 12:47:51 +0100 | [diff] [blame] | 445 | switch (mx31moboard_baseboard) { |
| 446 | case MX31NOBOARD: |
| 447 | break; |
| 448 | case MX31DEVBOARD: |
| 449 | mx31moboard_devboard_init(); |
| 450 | break; |
| 451 | case MX31MARXBOT: |
| 452 | mx31moboard_marxbot_init(); |
| 453 | break; |
| 454 | default: |
Valentin Longchamp | 220bbce | 2009-04-17 15:20:25 +0200 | [diff] [blame] | 455 | printk(KERN_ERR "Illegal mx31moboard_baseboard type %d\n", |
| 456 | mx31moboard_baseboard); |
Valentin Longchamp | e00f0b4 | 2009-02-16 12:47:51 +0100 | [diff] [blame] | 457 | } |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 458 | } |
| 459 | |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 460 | static void __init mx31moboard_timer_init(void) |
| 461 | { |
Sascha Hauer | 30c730f | 2009-02-16 14:36:49 +0100 | [diff] [blame] | 462 | mx31_clocks_init(26000000); |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | struct sys_timer mx31moboard_timer = { |
| 466 | .init = mx31moboard_timer_init, |
| 467 | }; |
| 468 | |
| 469 | MACHINE_START(MX31MOBOARD, "EPFL Mobots mx31moboard") |
| 470 | /* Maintainer: Valentin Longchamp, EPFL Mobots group */ |
| 471 | .phys_io = AIPS1_BASE_ADDR, |
| 472 | .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc, |
| 473 | .boot_params = PHYS_OFFSET + 0x100, |
Sascha Hauer | cd4a05f | 2009-04-02 22:32:10 +0200 | [diff] [blame] | 474 | .map_io = mx31_map_io, |
Sascha Hauer | c5aa0ad | 2009-05-25 17:36:19 +0200 | [diff] [blame] | 475 | .init_irq = mx31_init_irq, |
Valentin Longchamp | 988d2d4 | 2008-11-23 17:35:08 +0100 | [diff] [blame] | 476 | .init_machine = mxc_board_init, |
| 477 | .timer = &mx31moboard_timer, |
| 478 | MACHINE_END |
| 479 | |