mach-mx31_3ds.c 7.1 KB

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