diff options
Diffstat (limited to 'arch/arm/mach-mx3/mx31moboard.c')
-rw-r--r-- | arch/arm/mach-mx3/mx31moboard.c | 249 |
1 files changed, 244 insertions, 5 deletions
diff --git a/arch/arm/mach-mx3/mx31moboard.c b/arch/arm/mach-mx3/mx31moboard.c index 9243de54041a..b70529145936 100644 --- a/arch/arm/mach-mx3/mx31moboard.c +++ b/arch/arm/mach-mx3/mx31moboard.c | |||
@@ -17,6 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
20 | #include <linux/dma-mapping.h> | ||
20 | #include <linux/fsl_devices.h> | 21 | #include <linux/fsl_devices.h> |
21 | #include <linux/gpio.h> | 22 | #include <linux/gpio.h> |
22 | #include <linux/init.h> | 23 | #include <linux/init.h> |
@@ -26,8 +27,14 @@ | |||
26 | #include <linux/mtd/physmap.h> | 27 | #include <linux/mtd/physmap.h> |
27 | #include <linux/mtd/partitions.h> | 28 | #include <linux/mtd/partitions.h> |
28 | #include <linux/platform_device.h> | 29 | #include <linux/platform_device.h> |
30 | #include <linux/regulator/machine.h> | ||
31 | #include <linux/mfd/mc13783.h> | ||
32 | #include <linux/spi/spi.h> | ||
29 | #include <linux/types.h> | 33 | #include <linux/types.h> |
30 | 34 | ||
35 | #include <linux/usb/otg.h> | ||
36 | #include <linux/usb/ulpi.h> | ||
37 | |||
31 | #include <asm/mach-types.h> | 38 | #include <asm/mach-types.h> |
32 | #include <asm/mach/arch.h> | 39 | #include <asm/mach/arch.h> |
33 | #include <asm/mach/time.h> | 40 | #include <asm/mach/time.h> |
@@ -37,16 +44,20 @@ | |||
37 | #include <mach/hardware.h> | 44 | #include <mach/hardware.h> |
38 | #include <mach/imx-uart.h> | 45 | #include <mach/imx-uart.h> |
39 | #include <mach/iomux-mx3.h> | 46 | #include <mach/iomux-mx3.h> |
47 | #include <mach/ipu.h> | ||
40 | #include <mach/i2c.h> | 48 | #include <mach/i2c.h> |
41 | #include <mach/mmc.h> | 49 | #include <mach/mmc.h> |
42 | #include <mach/mx31.h> | 50 | #include <mach/mxc_ehci.h> |
51 | #include <mach/mx3_camera.h> | ||
52 | #include <mach/spi.h> | ||
53 | #include <mach/ulpi.h> | ||
43 | 54 | ||
44 | #include "devices.h" | 55 | #include "devices.h" |
45 | 56 | ||
46 | static unsigned int moboard_pins[] = { | 57 | static unsigned int moboard_pins[] = { |
47 | /* UART0 */ | 58 | /* UART0 */ |
48 | MX31_PIN_CTS1__CTS1, MX31_PIN_RTS1__RTS1, | ||
49 | MX31_PIN_TXD1__TXD1, MX31_PIN_RXD1__RXD1, | 59 | MX31_PIN_TXD1__TXD1, MX31_PIN_RXD1__RXD1, |
60 | MX31_PIN_CTS1__GPIO2_7, | ||
50 | /* UART4 */ | 61 | /* UART4 */ |
51 | MX31_PIN_PC_RST__CTS5, MX31_PIN_PC_VS2__RTS5, | 62 | MX31_PIN_PC_RST__CTS5, MX31_PIN_PC_VS2__RTS5, |
52 | MX31_PIN_PC_BVD2__TXD5, MX31_PIN_PC_BVD1__RXD5, | 63 | MX31_PIN_PC_BVD2__TXD5, MX31_PIN_PC_BVD1__RXD5, |
@@ -73,12 +84,31 @@ static unsigned int moboard_pins[] = { | |||
73 | MX31_PIN_USBOTG_CLK__USBOTG_CLK, MX31_PIN_USBOTG_DIR__USBOTG_DIR, | 84 | MX31_PIN_USBOTG_CLK__USBOTG_CLK, MX31_PIN_USBOTG_DIR__USBOTG_DIR, |
74 | MX31_PIN_USBOTG_NXT__USBOTG_NXT, MX31_PIN_USBOTG_STP__USBOTG_STP, | 85 | MX31_PIN_USBOTG_NXT__USBOTG_NXT, MX31_PIN_USBOTG_STP__USBOTG_STP, |
75 | MX31_PIN_USB_OC__GPIO1_30, | 86 | MX31_PIN_USB_OC__GPIO1_30, |
87 | /* USB H2 */ | ||
88 | MX31_PIN_USBH2_DATA0__USBH2_DATA0, | ||
89 | MX31_PIN_USBH2_DATA1__USBH2_DATA1, | ||
90 | MX31_PIN_STXD3__USBH2_DATA2, MX31_PIN_SRXD3__USBH2_DATA3, | ||
91 | MX31_PIN_SCK3__USBH2_DATA4, MX31_PIN_SFS3__USBH2_DATA5, | ||
92 | MX31_PIN_STXD6__USBH2_DATA6, MX31_PIN_SRXD6__USBH2_DATA7, | ||
93 | MX31_PIN_USBH2_CLK__USBH2_CLK, MX31_PIN_USBH2_DIR__USBH2_DIR, | ||
94 | MX31_PIN_USBH2_NXT__USBH2_NXT, MX31_PIN_USBH2_STP__USBH2_STP, | ||
95 | MX31_PIN_SCK6__GPIO1_25, | ||
76 | /* LEDs */ | 96 | /* LEDs */ |
77 | MX31_PIN_SVEN0__GPIO2_0, MX31_PIN_STX0__GPIO2_1, | 97 | MX31_PIN_SVEN0__GPIO2_0, MX31_PIN_STX0__GPIO2_1, |
78 | MX31_PIN_SRX0__GPIO2_2, MX31_PIN_SIMPD0__GPIO2_3, | 98 | MX31_PIN_SRX0__GPIO2_2, MX31_PIN_SIMPD0__GPIO2_3, |
79 | /* SEL */ | 99 | /* SEL */ |
80 | MX31_PIN_DTR_DCE1__GPIO2_8, MX31_PIN_DSR_DCE1__GPIO2_9, | 100 | MX31_PIN_DTR_DCE1__GPIO2_8, MX31_PIN_DSR_DCE1__GPIO2_9, |
81 | MX31_PIN_RI_DCE1__GPIO2_10, MX31_PIN_DCD_DCE1__GPIO2_11, | 101 | MX31_PIN_RI_DCE1__GPIO2_10, MX31_PIN_DCD_DCE1__GPIO2_11, |
102 | /* SPI1 */ | ||
103 | MX31_PIN_CSPI2_MOSI__MOSI, MX31_PIN_CSPI2_MISO__MISO, | ||
104 | MX31_PIN_CSPI2_SCLK__SCLK, MX31_PIN_CSPI2_SPI_RDY__SPI_RDY, | ||
105 | MX31_PIN_CSPI2_SS0__SS0, MX31_PIN_CSPI2_SS2__SS2, | ||
106 | /* Atlas IRQ */ | ||
107 | MX31_PIN_GPIO1_3__GPIO1_3, | ||
108 | /* SPI2 */ | ||
109 | MX31_PIN_CSPI3_MOSI__MOSI, MX31_PIN_CSPI3_MISO__MISO, | ||
110 | MX31_PIN_CSPI3_SCLK__SCLK, MX31_PIN_CSPI3_SPI_RDY__SPI_RDY, | ||
111 | MX31_PIN_CSPI2_SS1__CSPI3_SS1, | ||
82 | }; | 112 | }; |
83 | 113 | ||
84 | static struct physmap_flash_data mx31moboard_flash_data = { | 114 | static struct physmap_flash_data mx31moboard_flash_data = { |
@@ -101,7 +131,18 @@ static struct platform_device mx31moboard_flash = { | |||
101 | .num_resources = 1, | 131 | .num_resources = 1, |
102 | }; | 132 | }; |
103 | 133 | ||
104 | static struct imxuart_platform_data uart_pdata = { | 134 | static int moboard_uart0_init(struct platform_device *pdev) |
135 | { | ||
136 | gpio_request(IOMUX_TO_GPIO(MX31_PIN_CTS1), "uart0-cts-hack"); | ||
137 | gpio_direction_output(IOMUX_TO_GPIO(MX31_PIN_CTS1), 0); | ||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | static struct imxuart_platform_data uart0_pdata = { | ||
142 | .init = moboard_uart0_init, | ||
143 | }; | ||
144 | |||
145 | static struct imxuart_platform_data uart4_pdata = { | ||
105 | .flags = IMXUART_HAVE_RTSCTS, | 146 | .flags = IMXUART_HAVE_RTSCTS, |
106 | }; | 147 | }; |
107 | 148 | ||
@@ -113,6 +154,103 @@ static struct imxi2c_platform_data moboard_i2c1_pdata = { | |||
113 | .bitrate = 100000, | 154 | .bitrate = 100000, |
114 | }; | 155 | }; |
115 | 156 | ||
157 | static int moboard_spi1_cs[] = { | ||
158 | MXC_SPI_CS(0), | ||
159 | MXC_SPI_CS(2), | ||
160 | }; | ||
161 | |||
162 | static struct spi_imx_master moboard_spi1_master = { | ||
163 | .chipselect = moboard_spi1_cs, | ||
164 | .num_chipselect = ARRAY_SIZE(moboard_spi1_cs), | ||
165 | }; | ||
166 | |||
167 | static struct regulator_consumer_supply sdhc_consumers[] = { | ||
168 | { | ||
169 | .dev = &mxcsdhc_device0.dev, | ||
170 | .supply = "sdhc0_vcc", | ||
171 | }, | ||
172 | { | ||
173 | .dev = &mxcsdhc_device1.dev, | ||
174 | .supply = "sdhc1_vcc", | ||
175 | }, | ||
176 | }; | ||
177 | |||
178 | static struct regulator_init_data sdhc_vreg_data = { | ||
179 | .constraints = { | ||
180 | .min_uV = 2700000, | ||
181 | .max_uV = 3000000, | ||
182 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | | ||
183 | REGULATOR_CHANGE_MODE | REGULATOR_CHANGE_STATUS, | ||
184 | .valid_modes_mask = REGULATOR_MODE_NORMAL | | ||
185 | REGULATOR_MODE_FAST, | ||
186 | .always_on = 0, | ||
187 | .boot_on = 1, | ||
188 | }, | ||
189 | .num_consumer_supplies = ARRAY_SIZE(sdhc_consumers), | ||
190 | .consumer_supplies = sdhc_consumers, | ||
191 | }; | ||
192 | |||
193 | static struct regulator_consumer_supply cam_consumers[] = { | ||
194 | { | ||
195 | .dev = &mx3_camera.dev, | ||
196 | .supply = "cam_vcc", | ||
197 | }, | ||
198 | }; | ||
199 | |||
200 | static struct regulator_init_data cam_vreg_data = { | ||
201 | .constraints = { | ||
202 | .min_uV = 2700000, | ||
203 | .max_uV = 3000000, | ||
204 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | | ||
205 | REGULATOR_CHANGE_MODE | REGULATOR_CHANGE_STATUS, | ||
206 | .valid_modes_mask = REGULATOR_MODE_NORMAL | | ||
207 | REGULATOR_MODE_FAST, | ||
208 | .always_on = 0, | ||
209 | .boot_on = 1, | ||
210 | }, | ||
211 | .num_consumer_supplies = ARRAY_SIZE(cam_consumers), | ||
212 | .consumer_supplies = cam_consumers, | ||
213 | }; | ||
214 | |||
215 | static struct mc13783_regulator_init_data moboard_regulators[] = { | ||
216 | { | ||
217 | .id = MC13783_REGU_VMMC1, | ||
218 | .init_data = &sdhc_vreg_data, | ||
219 | }, | ||
220 | { | ||
221 | .id = MC13783_REGU_VCAM, | ||
222 | .init_data = &cam_vreg_data, | ||
223 | }, | ||
224 | }; | ||
225 | |||
226 | static struct mc13783_platform_data moboard_pmic = { | ||
227 | .regulators = moboard_regulators, | ||
228 | .num_regulators = ARRAY_SIZE(moboard_regulators), | ||
229 | .flags = MC13783_USE_REGULATOR | MC13783_USE_RTC | | ||
230 | MC13783_USE_ADC, | ||
231 | }; | ||
232 | |||
233 | static struct spi_board_info moboard_spi_board_info[] __initdata = { | ||
234 | { | ||
235 | .modalias = "mc13783", | ||
236 | .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3), | ||
237 | .max_speed_hz = 300000, | ||
238 | .bus_num = 1, | ||
239 | .chip_select = 0, | ||
240 | .platform_data = &moboard_pmic, | ||
241 | .mode = SPI_CS_HIGH, | ||
242 | }, | ||
243 | }; | ||
244 | |||
245 | static int moboard_spi2_cs[] = { | ||
246 | MXC_SPI_CS(1), | ||
247 | }; | ||
248 | |||
249 | static struct spi_imx_master moboard_spi2_master = { | ||
250 | .chipselect = moboard_spi2_cs, | ||
251 | .num_chipselect = ARRAY_SIZE(moboard_spi2_cs), | ||
252 | }; | ||
253 | |||
116 | #define SDHC1_CD IOMUX_TO_GPIO(MX31_PIN_ATA_CS0) | 254 | #define SDHC1_CD IOMUX_TO_GPIO(MX31_PIN_ATA_CS0) |
117 | #define SDHC1_WP IOMUX_TO_GPIO(MX31_PIN_ATA_CS1) | 255 | #define SDHC1_WP IOMUX_TO_GPIO(MX31_PIN_ATA_CS1) |
118 | 256 | ||
@@ -208,6 +346,56 @@ static struct fsl_usb2_platform_data usb_pdata = { | |||
208 | .phy_mode = FSL_USB2_PHY_ULPI, | 346 | .phy_mode = FSL_USB2_PHY_ULPI, |
209 | }; | 347 | }; |
210 | 348 | ||
349 | #define USBH2_EN_B IOMUX_TO_GPIO(MX31_PIN_SCK6) | ||
350 | |||
351 | static int moboard_usbh2_hw_init(struct platform_device *pdev) | ||
352 | { | ||
353 | int ret = gpio_request(USBH2_EN_B, "usbh2-en"); | ||
354 | if (ret) | ||
355 | return ret; | ||
356 | |||
357 | mxc_iomux_set_gpr(MUX_PGP_UH2, true); | ||
358 | |||
359 | mxc_iomux_set_pad(MX31_PIN_USBH2_CLK, USB_PAD_CFG); | ||
360 | mxc_iomux_set_pad(MX31_PIN_USBH2_DIR, USB_PAD_CFG); | ||
361 | mxc_iomux_set_pad(MX31_PIN_USBH2_NXT, USB_PAD_CFG); | ||
362 | mxc_iomux_set_pad(MX31_PIN_USBH2_STP, USB_PAD_CFG); | ||
363 | mxc_iomux_set_pad(MX31_PIN_USBH2_DATA0, USB_PAD_CFG); | ||
364 | mxc_iomux_set_pad(MX31_PIN_USBH2_DATA1, USB_PAD_CFG); | ||
365 | mxc_iomux_set_pad(MX31_PIN_SRXD6, USB_PAD_CFG); | ||
366 | mxc_iomux_set_pad(MX31_PIN_STXD6, USB_PAD_CFG); | ||
367 | mxc_iomux_set_pad(MX31_PIN_SFS3, USB_PAD_CFG); | ||
368 | mxc_iomux_set_pad(MX31_PIN_SCK3, USB_PAD_CFG); | ||
369 | mxc_iomux_set_pad(MX31_PIN_SRXD3, USB_PAD_CFG); | ||
370 | mxc_iomux_set_pad(MX31_PIN_STXD3, USB_PAD_CFG); | ||
371 | |||
372 | gpio_direction_output(USBH2_EN_B, 0); | ||
373 | |||
374 | return 0; | ||
375 | } | ||
376 | |||
377 | static int moboard_usbh2_hw_exit(struct platform_device *pdev) | ||
378 | { | ||
379 | gpio_free(USBH2_EN_B); | ||
380 | return 0; | ||
381 | } | ||
382 | |||
383 | static struct mxc_usbh_platform_data usbh2_pdata = { | ||
384 | .init = moboard_usbh2_hw_init, | ||
385 | .exit = moboard_usbh2_hw_exit, | ||
386 | .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT, | ||
387 | .flags = MXC_EHCI_POWER_PINS_ENABLED, | ||
388 | }; | ||
389 | |||
390 | static int __init moboard_usbh2_init(void) | ||
391 | { | ||
392 | usbh2_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops, | ||
393 | USB_OTG_DRV_VBUS | USB_OTG_DRV_VBUS_EXT); | ||
394 | |||
395 | return mxc_register_device(&mx31_usbh2, &usbh2_pdata); | ||
396 | } | ||
397 | |||
398 | |||
211 | static struct gpio_led mx31moboard_leds[] = { | 399 | static struct gpio_led mx31moboard_leds[] = { |
212 | { | 400 | { |
213 | .name = "coreboard-led-0:red:running", | 401 | .name = "coreboard-led-0:red:running", |
@@ -266,11 +454,48 @@ static void mx31moboard_init_sel_gpios(void) | |||
266 | } | 454 | } |
267 | } | 455 | } |
268 | 456 | ||
457 | static struct ipu_platform_data mx3_ipu_data = { | ||
458 | .irq_base = MXC_IPU_IRQ_START, | ||
459 | }; | ||
460 | |||
269 | static struct platform_device *devices[] __initdata = { | 461 | static struct platform_device *devices[] __initdata = { |
270 | &mx31moboard_flash, | 462 | &mx31moboard_flash, |
271 | &mx31moboard_leds_device, | 463 | &mx31moboard_leds_device, |
272 | }; | 464 | }; |
273 | 465 | ||
466 | static struct mx3_camera_pdata camera_pdata = { | ||
467 | .dma_dev = &mx3_ipu.dev, | ||
468 | .flags = MX3_CAMERA_DATAWIDTH_8 | MX3_CAMERA_DATAWIDTH_10, | ||
469 | .mclk_10khz = 4800, | ||
470 | }; | ||
471 | |||
472 | #define CAMERA_BUF_SIZE (4*1024*1024) | ||
473 | |||
474 | static int __init mx31moboard_cam_alloc_dma(const size_t buf_size) | ||
475 | { | ||
476 | dma_addr_t dma_handle; | ||
477 | void *buf; | ||
478 | int dma; | ||
479 | |||
480 | if (buf_size < 2 * 1024 * 1024) | ||
481 | return -EINVAL; | ||
482 | |||
483 | buf = dma_alloc_coherent(NULL, buf_size, &dma_handle, GFP_KERNEL); | ||
484 | if (!buf) { | ||
485 | pr_err("%s: cannot allocate camera buffer-memory\n", __func__); | ||
486 | return -ENOMEM; | ||
487 | } | ||
488 | |||
489 | memset(buf, 0, buf_size); | ||
490 | |||
491 | dma = dma_declare_coherent_memory(&mx3_camera.dev, | ||
492 | dma_handle, dma_handle, buf_size, | ||
493 | DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); | ||
494 | |||
495 | /* The way we call dma_declare_coherent_memory only a malloc can fail */ | ||
496 | return dma & DMA_MEMORY_MAP ? 0 : -ENOMEM; | ||
497 | } | ||
498 | |||
274 | static int mx31moboard_baseboard; | 499 | static int mx31moboard_baseboard; |
275 | core_param(mx31moboard_baseboard, mx31moboard_baseboard, int, 0444); | 500 | core_param(mx31moboard_baseboard, mx31moboard_baseboard, int, 0444); |
276 | 501 | ||
@@ -284,20 +509,34 @@ static void __init mxc_board_init(void) | |||
284 | 509 | ||
285 | platform_add_devices(devices, ARRAY_SIZE(devices)); | 510 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
286 | 511 | ||
287 | mxc_register_device(&mxc_uart_device0, &uart_pdata); | 512 | mxc_register_device(&mxc_uart_device0, &uart0_pdata); |
288 | mxc_register_device(&mxc_uart_device4, &uart_pdata); | 513 | |
514 | mxc_register_device(&mxc_uart_device4, &uart4_pdata); | ||
289 | 515 | ||
290 | mx31moboard_init_sel_gpios(); | 516 | mx31moboard_init_sel_gpios(); |
291 | 517 | ||
292 | mxc_register_device(&mxc_i2c_device0, &moboard_i2c0_pdata); | 518 | mxc_register_device(&mxc_i2c_device0, &moboard_i2c0_pdata); |
293 | mxc_register_device(&mxc_i2c_device1, &moboard_i2c1_pdata); | 519 | mxc_register_device(&mxc_i2c_device1, &moboard_i2c1_pdata); |
294 | 520 | ||
521 | mxc_register_device(&mxc_spi_device1, &moboard_spi1_master); | ||
522 | mxc_register_device(&mxc_spi_device2, &moboard_spi2_master); | ||
523 | |||
524 | gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_3), "pmic-irq"); | ||
525 | gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_3)); | ||
526 | spi_register_board_info(moboard_spi_board_info, | ||
527 | ARRAY_SIZE(moboard_spi_board_info)); | ||
528 | |||
295 | mxc_register_device(&mxcsdhc_device0, &sdhc1_pdata); | 529 | mxc_register_device(&mxcsdhc_device0, &sdhc1_pdata); |
296 | 530 | ||
531 | mxc_register_device(&mx3_ipu, &mx3_ipu_data); | ||
532 | if (!mx31moboard_cam_alloc_dma(CAMERA_BUF_SIZE)) | ||
533 | mxc_register_device(&mx3_camera, &camera_pdata); | ||
534 | |||
297 | usb_xcvr_reset(); | 535 | usb_xcvr_reset(); |
298 | 536 | ||
299 | moboard_usbotg_init(); | 537 | moboard_usbotg_init(); |
300 | mxc_register_device(&mxc_otg_udc_device, &usb_pdata); | 538 | mxc_register_device(&mxc_otg_udc_device, &usb_pdata); |
539 | moboard_usbh2_init(); | ||
301 | 540 | ||
302 | switch (mx31moboard_baseboard) { | 541 | switch (mx31moboard_baseboard) { |
303 | case MX31NOBOARD: | 542 | case MX31NOBOARD: |