mach-mx31_3ds.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /*
  2. * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
  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. #include <linux/delay.h>
  15. #include <linux/types.h>
  16. #include <linux/init.h>
  17. #include <linux/clk.h>
  18. #include <linux/irq.h>
  19. #include <linux/gpio.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/mfd/mc13783.h>
  22. #include <linux/spi/spi.h>
  23. #include <linux/regulator/machine.h>
  24. #include <mach/hardware.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach/time.h>
  28. #include <asm/memory.h>
  29. #include <asm/mach/map.h>
  30. #include <mach/common.h>
  31. #include <mach/iomux-mx3.h>
  32. #include <mach/3ds_debugboard.h>
  33. #include "devices-imx31.h"
  34. #include "devices.h"
  35. /* CPLD IRQ line for external uart, external ethernet etc */
  36. #define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_1)
  37. /*
  38. * This file contains the board-specific initialization routines.
  39. */
  40. static int mx31_3ds_pins[] = {
  41. /* UART1 */
  42. MX31_PIN_CTS1__CTS1,
  43. MX31_PIN_RTS1__RTS1,
  44. MX31_PIN_TXD1__TXD1,
  45. MX31_PIN_RXD1__RXD1,
  46. IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO),
  47. /* SPI 1 */
  48. MX31_PIN_CSPI2_SCLK__SCLK,
  49. MX31_PIN_CSPI2_MOSI__MOSI,
  50. MX31_PIN_CSPI2_MISO__MISO,
  51. MX31_PIN_CSPI2_SPI_RDY__SPI_RDY,
  52. MX31_PIN_CSPI2_SS0__SS0,
  53. MX31_PIN_CSPI2_SS2__SS2, /*CS for MC13783 */
  54. /* MC13783 IRQ */
  55. IOMUX_MODE(MX31_PIN_GPIO1_3, IOMUX_CONFIG_GPIO),
  56. /* USB OTG reset */
  57. IOMUX_MODE(MX31_PIN_USB_PWR, IOMUX_CONFIG_GPIO),
  58. /* USB OTG */
  59. MX31_PIN_USBOTG_DATA0__USBOTG_DATA0,
  60. MX31_PIN_USBOTG_DATA1__USBOTG_DATA1,
  61. MX31_PIN_USBOTG_DATA2__USBOTG_DATA2,
  62. MX31_PIN_USBOTG_DATA3__USBOTG_DATA3,
  63. MX31_PIN_USBOTG_DATA4__USBOTG_DATA4,
  64. MX31_PIN_USBOTG_DATA5__USBOTG_DATA5,
  65. MX31_PIN_USBOTG_DATA6__USBOTG_DATA6,
  66. MX31_PIN_USBOTG_DATA7__USBOTG_DATA7,
  67. MX31_PIN_USBOTG_CLK__USBOTG_CLK,
  68. MX31_PIN_USBOTG_DIR__USBOTG_DIR,
  69. MX31_PIN_USBOTG_NXT__USBOTG_NXT,
  70. MX31_PIN_USBOTG_STP__USBOTG_STP,
  71. /*Keyboard*/
  72. MX31_PIN_KEY_ROW0_KEY_ROW0,
  73. MX31_PIN_KEY_ROW1_KEY_ROW1,
  74. MX31_PIN_KEY_ROW2_KEY_ROW2,
  75. MX31_PIN_KEY_COL0_KEY_COL0,
  76. MX31_PIN_KEY_COL1_KEY_COL1,
  77. MX31_PIN_KEY_COL2_KEY_COL2,
  78. MX31_PIN_KEY_COL3_KEY_COL3,
  79. };
  80. /*
  81. * Matrix keyboard
  82. */
  83. static const uint32_t mx31_3ds_keymap[] = {
  84. KEY(0, 0, KEY_UP),
  85. KEY(0, 1, KEY_DOWN),
  86. KEY(1, 0, KEY_RIGHT),
  87. KEY(1, 1, KEY_LEFT),
  88. KEY(1, 2, KEY_ENTER),
  89. KEY(2, 0, KEY_F6),
  90. KEY(2, 1, KEY_F8),
  91. KEY(2, 2, KEY_F9),
  92. KEY(2, 3, KEY_F10),
  93. };
  94. static const struct matrix_keymap_data mx31_3ds_keymap_data __initconst = {
  95. .keymap = mx31_3ds_keymap,
  96. .keymap_size = ARRAY_SIZE(mx31_3ds_keymap),
  97. };
  98. /* Regulators */
  99. static struct regulator_init_data pwgtx_init = {
  100. .constraints = {
  101. .boot_on = 1,
  102. .always_on = 1,
  103. },
  104. };
  105. static struct mc13783_regulator_init_data mx31_3ds_regulators[] = {
  106. {
  107. .id = MC13783_REGU_PWGT1SPI, /* Power Gate for ARM core. */
  108. .init_data = &pwgtx_init,
  109. }, {
  110. .id = MC13783_REGU_PWGT2SPI, /* Power Gate for L2 Cache. */
  111. .init_data = &pwgtx_init,
  112. },
  113. };
  114. /* MC13783 */
  115. static struct mc13783_platform_data mc13783_pdata __initdata = {
  116. .regulators = mx31_3ds_regulators,
  117. .num_regulators = ARRAY_SIZE(mx31_3ds_regulators),
  118. .flags = MC13783_USE_REGULATOR,
  119. };
  120. /* SPI */
  121. static int spi1_internal_chipselect[] = {
  122. MXC_SPI_CS(0),
  123. MXC_SPI_CS(2),
  124. };
  125. static const struct spi_imx_master spi1_pdata __initconst = {
  126. .chipselect = spi1_internal_chipselect,
  127. .num_chipselect = ARRAY_SIZE(spi1_internal_chipselect),
  128. };
  129. static struct spi_board_info mx31_3ds_spi_devs[] __initdata = {
  130. {
  131. .modalias = "mc13783",
  132. .max_speed_hz = 1000000,
  133. .bus_num = 1,
  134. .chip_select = 1, /* SS2 */
  135. .platform_data = &mc13783_pdata,
  136. .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3),
  137. .mode = SPI_CS_HIGH,
  138. },
  139. };
  140. /*
  141. * NAND Flash
  142. */
  143. static const struct mxc_nand_platform_data
  144. mx31_3ds_nand_board_info __initconst = {
  145. .width = 1,
  146. .hw_ecc = 1,
  147. #ifdef MACH_MX31_3DS_MXC_NAND_USE_BBT
  148. .flash_bbt = 1,
  149. #endif
  150. };
  151. /*
  152. * USB OTG
  153. */
  154. #define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
  155. PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)
  156. #define USBOTG_RST_B IOMUX_TO_GPIO(MX31_PIN_USB_PWR)
  157. static int mx31_3ds_usbotg_init(void)
  158. {
  159. int err;
  160. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA0, USB_PAD_CFG);
  161. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA1, USB_PAD_CFG);
  162. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA2, USB_PAD_CFG);
  163. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA3, USB_PAD_CFG);
  164. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA4, USB_PAD_CFG);
  165. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA5, USB_PAD_CFG);
  166. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA6, USB_PAD_CFG);
  167. mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA7, USB_PAD_CFG);
  168. mxc_iomux_set_pad(MX31_PIN_USBOTG_CLK, USB_PAD_CFG);
  169. mxc_iomux_set_pad(MX31_PIN_USBOTG_DIR, USB_PAD_CFG);
  170. mxc_iomux_set_pad(MX31_PIN_USBOTG_NXT, USB_PAD_CFG);
  171. mxc_iomux_set_pad(MX31_PIN_USBOTG_STP, USB_PAD_CFG);
  172. err = gpio_request(USBOTG_RST_B, "otgusb-reset");
  173. if (err) {
  174. pr_err("Failed to request the USB OTG reset gpio\n");
  175. return err;
  176. }
  177. err = gpio_direction_output(USBOTG_RST_B, 0);
  178. if (err) {
  179. pr_err("Failed to drive the USB OTG reset gpio\n");
  180. goto usbotg_free_reset;
  181. }
  182. mdelay(1);
  183. gpio_set_value(USBOTG_RST_B, 1);
  184. return 0;
  185. usbotg_free_reset:
  186. gpio_free(USBOTG_RST_B);
  187. return err;
  188. }
  189. static const struct fsl_usb2_platform_data usbotg_pdata __initconst = {
  190. .operating_mode = FSL_USB2_DR_DEVICE,
  191. .phy_mode = FSL_USB2_PHY_ULPI,
  192. };
  193. static const struct imxuart_platform_data uart_pdata __initconst = {
  194. .flags = IMXUART_HAVE_RTSCTS,
  195. };
  196. /*
  197. * Set up static virtual mappings.
  198. */
  199. static void __init mx31_3ds_map_io(void)
  200. {
  201. mx31_map_io();
  202. }
  203. /*!
  204. * Board specific initialization.
  205. */
  206. static void __init mxc_board_init(void)
  207. {
  208. mxc_iomux_setup_multiple_pins(mx31_3ds_pins, ARRAY_SIZE(mx31_3ds_pins),
  209. "mx31_3ds");
  210. imx31_add_imx_uart0(&uart_pdata);
  211. imx31_add_mxc_nand(&mx31_3ds_nand_board_info);
  212. imx31_add_spi_imx1(&spi1_pdata);
  213. spi_register_board_info(mx31_3ds_spi_devs,
  214. ARRAY_SIZE(mx31_3ds_spi_devs));
  215. imx31_add_imx_keypad(&mx31_3ds_keymap_data);
  216. mx31_3ds_usbotg_init();
  217. imx31_add_fsl_usb2_udc(&usbotg_pdata);
  218. if (mxc_expio_init(MX31_CS5_BASE_ADDR, EXPIO_PARENT_INT))
  219. printk(KERN_WARNING "Init of the debug board failed, all "
  220. "devices on the debug board are unusable.\n");
  221. }
  222. static void __init mx31_3ds_timer_init(void)
  223. {
  224. mx31_clocks_init(26000000);
  225. }
  226. static struct sys_timer mx31_3ds_timer = {
  227. .init = mx31_3ds_timer_init,
  228. };
  229. /*
  230. * The following uses standard kernel macros defined in arch.h in order to
  231. * initialize __mach_desc_MX31_3DS data structure.
  232. */
  233. MACHINE_START(MX31_3DS, "Freescale MX31PDK (3DS)")
  234. /* Maintainer: Freescale Semiconductor, Inc. */
  235. .boot_params = MX3x_PHYS_OFFSET + 0x100,
  236. .map_io = mx31_3ds_map_io,
  237. .init_irq = mx31_init_irq,
  238. .init_machine = mxc_board_init,
  239. .timer = &mx31_3ds_timer,
  240. MACHINE_END