board-mx51_efikamx.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. * Copyright (C) 2010 Linaro Limited
  3. *
  4. * based on code from the following
  5. * Copyright 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
  6. * Copyright 2009-2010 Pegatron Corporation. All Rights Reserved.
  7. * Copyright 2009-2010 Genesi USA, Inc. All Rights Reserved.
  8. *
  9. * The code contained herein is licensed under the GNU General Public
  10. * License. You may obtain a copy of the GNU General Public License
  11. * Version 2 or later at the following locations:
  12. *
  13. * http://www.opensource.org/licenses/gpl-license.html
  14. * http://www.gnu.org/copyleft/gpl.html
  15. */
  16. #include <linux/init.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/i2c.h>
  19. #include <linux/gpio.h>
  20. #include <linux/delay.h>
  21. #include <linux/io.h>
  22. #include <linux/fsl_devices.h>
  23. #include <mach/common.h>
  24. #include <mach/hardware.h>
  25. #include <mach/iomux-mx51.h>
  26. #include <mach/i2c.h>
  27. #include <mach/mxc_ehci.h>
  28. #include <asm/irq.h>
  29. #include <asm/setup.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/time.h>
  33. #include "devices-imx51.h"
  34. #include "devices.h"
  35. #define MX51_USB_PLL_DIV_24_MHZ 0x01
  36. #define EFIKAMX_PCBID0 (2*32 + 16)
  37. #define EFIKAMX_PCBID1 (2*32 + 17)
  38. #define EFIKAMX_PCBID2 (2*32 + 11)
  39. /* the pci ids pin have pull up. they're driven low according to board id */
  40. #define MX51_PAD_PCBID0 IOMUX_PAD(0x518, 0x130, 3, 0x0, 0, PAD_CTL_PUS_100K_UP)
  41. #define MX51_PAD_PCBID1 IOMUX_PAD(0x51C, 0x134, 3, 0x0, 0, PAD_CTL_PUS_100K_UP)
  42. #define MX51_PAD_PCBID2 IOMUX_PAD(0x504, 0x128, 3, 0x0, 0, PAD_CTL_PUS_100K_UP)
  43. static iomux_v3_cfg_t mx51efikamx_pads[] = {
  44. /* UART1 */
  45. MX51_PAD_UART1_RXD__UART1_RXD,
  46. MX51_PAD_UART1_TXD__UART1_TXD,
  47. MX51_PAD_UART1_RTS__UART1_RTS,
  48. MX51_PAD_UART1_CTS__UART1_CTS,
  49. /* board id */
  50. MX51_PAD_PCBID0,
  51. MX51_PAD_PCBID1,
  52. MX51_PAD_PCBID2,
  53. /* SD 1 */
  54. MX51_PAD_SD1_CMD__SD1_CMD,
  55. MX51_PAD_SD1_CLK__SD1_CLK,
  56. MX51_PAD_SD1_DATA0__SD1_DATA0,
  57. MX51_PAD_SD1_DATA1__SD1_DATA1,
  58. MX51_PAD_SD1_DATA2__SD1_DATA2,
  59. MX51_PAD_SD1_DATA3__SD1_DATA3,
  60. /* SD 2 */
  61. MX51_PAD_SD2_CMD__SD2_CMD,
  62. MX51_PAD_SD2_CLK__SD2_CLK,
  63. MX51_PAD_SD2_DATA0__SD2_DATA0,
  64. MX51_PAD_SD2_DATA1__SD2_DATA1,
  65. MX51_PAD_SD2_DATA2__SD2_DATA2,
  66. MX51_PAD_SD2_DATA3__SD2_DATA3,
  67. /* SD/MMC WP/CD */
  68. MX51_PAD_GPIO_1_0__ESDHC1_CD,
  69. MX51_PAD_GPIO_1_1__ESDHC1_WP,
  70. MX51_PAD_GPIO_1_7__ESDHC2_WP,
  71. MX51_PAD_GPIO_1_8__ESDHC2_CD,
  72. };
  73. /* Serial ports */
  74. #if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE)
  75. static const struct imxuart_platform_data uart_pdata = {
  76. .flags = IMXUART_HAVE_RTSCTS,
  77. };
  78. static inline void mxc_init_imx_uart(void)
  79. {
  80. imx51_add_imx_uart(0, &uart_pdata);
  81. imx51_add_imx_uart(1, &uart_pdata);
  82. imx51_add_imx_uart(2, &uart_pdata);
  83. }
  84. #else /* !SERIAL_IMX */
  85. static inline void mxc_init_imx_uart(void)
  86. {
  87. }
  88. #endif /* SERIAL_IMX */
  89. /* This function is board specific as the bit mask for the plldiv will also
  90. * be different for other Freescale SoCs, thus a common bitmask is not
  91. * possible and cannot get place in /plat-mxc/ehci.c.
  92. */
  93. static int initialize_otg_port(struct platform_device *pdev)
  94. {
  95. u32 v;
  96. void __iomem *usb_base;
  97. void __iomem *usbother_base;
  98. usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K);
  99. usbother_base = (void __iomem *)(usb_base + MX5_USBOTHER_REGS_OFFSET);
  100. /* Set the PHY clock to 19.2MHz */
  101. v = __raw_readl(usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET);
  102. v &= ~MX5_USB_UTMI_PHYCTRL1_PLLDIV_MASK;
  103. v |= MX51_USB_PLL_DIV_24_MHZ;
  104. __raw_writel(v, usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET);
  105. iounmap(usb_base);
  106. return 0;
  107. }
  108. static struct mxc_usbh_platform_data dr_utmi_config = {
  109. .init = initialize_otg_port,
  110. .portsc = MXC_EHCI_UTMI_16BIT,
  111. .flags = MXC_EHCI_INTERNAL_PHY,
  112. };
  113. /* PCBID2 PCBID1 PCBID0 STATE
  114. 1 1 1 ER1:rev1.1
  115. 1 1 0 ER2:rev1.2
  116. 1 0 1 ER3:rev1.3
  117. 1 0 0 ER4:rev1.4
  118. */
  119. static void __init mx51_efikamx_board_id(void)
  120. {
  121. int id;
  122. /* things are taking time to settle */
  123. msleep(150);
  124. gpio_request(EFIKAMX_PCBID0, "pcbid0");
  125. gpio_direction_input(EFIKAMX_PCBID0);
  126. gpio_request(EFIKAMX_PCBID1, "pcbid1");
  127. gpio_direction_input(EFIKAMX_PCBID1);
  128. gpio_request(EFIKAMX_PCBID2, "pcbid2");
  129. gpio_direction_input(EFIKAMX_PCBID2);
  130. id = gpio_get_value(EFIKAMX_PCBID0);
  131. id |= gpio_get_value(EFIKAMX_PCBID1) << 1;
  132. id |= gpio_get_value(EFIKAMX_PCBID2) << 2;
  133. switch (id) {
  134. case 7:
  135. system_rev = 0x11;
  136. break;
  137. case 6:
  138. system_rev = 0x12;
  139. break;
  140. case 5:
  141. system_rev = 0x13;
  142. break;
  143. case 4:
  144. system_rev = 0x14;
  145. break;
  146. default:
  147. system_rev = 0x10;
  148. break;
  149. }
  150. if ((system_rev == 0x10)
  151. || (system_rev == 0x12)
  152. || (system_rev == 0x14)) {
  153. printk(KERN_WARNING
  154. "EfikaMX: Unsupported board revision 1.%u!\n",
  155. system_rev & 0xf);
  156. }
  157. }
  158. static void __init mxc_board_init(void)
  159. {
  160. mxc_iomux_v3_setup_multiple_pads(mx51efikamx_pads,
  161. ARRAY_SIZE(mx51efikamx_pads));
  162. mx51_efikamx_board_id();
  163. mxc_register_device(&mxc_usbdr_host_device, &dr_utmi_config);
  164. mxc_init_imx_uart();
  165. imx51_add_esdhc(0, NULL);
  166. /* on < 1.2 boards both SD controllers are used */
  167. if (system_rev < 0x12)
  168. imx51_add_esdhc(1, NULL);
  169. }
  170. static void __init mx51_efikamx_timer_init(void)
  171. {
  172. mx51_clocks_init(32768, 24000000, 22579200, 24576000);
  173. }
  174. static struct sys_timer mxc_timer = {
  175. .init = mx51_efikamx_timer_init,
  176. };
  177. MACHINE_START(MX51_EFIKAMX, "Genesi EfikaMX nettop")
  178. /* Maintainer: Amit Kucheria <amit.kucheria@linaro.org> */
  179. .boot_params = MX51_PHYS_OFFSET + 0x100,
  180. .map_io = mx51_map_io,
  181. .init_irq = mx51_init_irq,
  182. .init_machine = mxc_board_init,
  183. .timer = &mxc_timer,
  184. MACHINE_END