pcm037.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /*
  2. * Copyright (C) 2008 Sascha Hauer, Pengutronix
  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. #include <linux/types.h>
  19. #include <linux/init.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/mtd/physmap.h>
  22. #include <linux/mtd/plat-ram.h>
  23. #include <linux/memory.h>
  24. #include <linux/gpio.h>
  25. #include <linux/smsc911x.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/i2c.h>
  28. #include <linux/i2c/at24.h>
  29. #include <linux/delay.h>
  30. #include <linux/spi/spi.h>
  31. #include <linux/irq.h>
  32. #include <mach/hardware.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/time.h>
  36. #include <asm/mach/map.h>
  37. #include <mach/common.h>
  38. #include <mach/imx-uart.h>
  39. #include <mach/iomux-mx3.h>
  40. #include <mach/board-pcm037.h>
  41. #include <mach/mxc_nand.h>
  42. #include <mach/mmc.h>
  43. #ifdef CONFIG_I2C_IMX
  44. #include <mach/i2c.h>
  45. #endif
  46. #include "devices.h"
  47. static unsigned int pcm037_pins[] = {
  48. /* I2C */
  49. MX31_PIN_CSPI2_MOSI__SCL,
  50. MX31_PIN_CSPI2_MISO__SDA,
  51. /* SDHC1 */
  52. MX31_PIN_SD1_DATA3__SD1_DATA3,
  53. MX31_PIN_SD1_DATA2__SD1_DATA2,
  54. MX31_PIN_SD1_DATA1__SD1_DATA1,
  55. MX31_PIN_SD1_DATA0__SD1_DATA0,
  56. MX31_PIN_SD1_CLK__SD1_CLK,
  57. MX31_PIN_SD1_CMD__SD1_CMD,
  58. IOMUX_MODE(MX31_PIN_SCK6, IOMUX_CONFIG_GPIO), /* card detect */
  59. IOMUX_MODE(MX31_PIN_SFS6, IOMUX_CONFIG_GPIO), /* write protect */
  60. /* SPI1 */
  61. MX31_PIN_CSPI1_MOSI__MOSI,
  62. MX31_PIN_CSPI1_MISO__MISO,
  63. MX31_PIN_CSPI1_SCLK__SCLK,
  64. MX31_PIN_CSPI1_SPI_RDY__SPI_RDY,
  65. MX31_PIN_CSPI1_SS0__SS0,
  66. MX31_PIN_CSPI1_SS1__SS1,
  67. MX31_PIN_CSPI1_SS2__SS2,
  68. /* UART1 */
  69. MX31_PIN_CTS1__CTS1,
  70. MX31_PIN_RTS1__RTS1,
  71. MX31_PIN_TXD1__TXD1,
  72. MX31_PIN_RXD1__RXD1,
  73. /* UART2 */
  74. MX31_PIN_TXD2__TXD2,
  75. MX31_PIN_RXD2__RXD2,
  76. MX31_PIN_CTS2__CTS2,
  77. MX31_PIN_RTS2__RTS2,
  78. /* UART3 */
  79. MX31_PIN_CSPI3_MOSI__RXD3,
  80. MX31_PIN_CSPI3_MISO__TXD3,
  81. MX31_PIN_CSPI3_SCLK__RTS3,
  82. MX31_PIN_CSPI3_SPI_RDY__CTS3,
  83. /* LAN9217 irq pin */
  84. IOMUX_MODE(MX31_PIN_GPIO3_1, IOMUX_CONFIG_GPIO),
  85. /* Onewire */
  86. MX31_PIN_BATT_LINE__OWIRE,
  87. /* Framebuffer */
  88. MX31_PIN_LD0__LD0,
  89. MX31_PIN_LD1__LD1,
  90. MX31_PIN_LD2__LD2,
  91. MX31_PIN_LD3__LD3,
  92. MX31_PIN_LD4__LD4,
  93. MX31_PIN_LD5__LD5,
  94. MX31_PIN_LD6__LD6,
  95. MX31_PIN_LD7__LD7,
  96. MX31_PIN_LD8__LD8,
  97. MX31_PIN_LD9__LD9,
  98. MX31_PIN_LD10__LD10,
  99. MX31_PIN_LD11__LD11,
  100. MX31_PIN_LD12__LD12,
  101. MX31_PIN_LD13__LD13,
  102. MX31_PIN_LD14__LD14,
  103. MX31_PIN_LD15__LD15,
  104. MX31_PIN_LD16__LD16,
  105. MX31_PIN_LD17__LD17,
  106. MX31_PIN_VSYNC3__VSYNC3,
  107. MX31_PIN_HSYNC__HSYNC,
  108. MX31_PIN_FPSHIFT__FPSHIFT,
  109. MX31_PIN_DRDY0__DRDY0,
  110. MX31_PIN_D3_REV__D3_REV,
  111. MX31_PIN_CONTRAST__CONTRAST,
  112. MX31_PIN_D3_SPL__D3_SPL,
  113. MX31_PIN_D3_CLS__D3_CLS,
  114. MX31_PIN_LCS0__GPI03_23,
  115. };
  116. static struct physmap_flash_data pcm037_flash_data = {
  117. .width = 2,
  118. };
  119. static struct resource pcm037_flash_resource = {
  120. .start = 0xa0000000,
  121. .end = 0xa1ffffff,
  122. .flags = IORESOURCE_MEM,
  123. };
  124. static struct platform_device pcm037_flash = {
  125. .name = "physmap-flash",
  126. .id = 0,
  127. .dev = {
  128. .platform_data = &pcm037_flash_data,
  129. },
  130. .resource = &pcm037_flash_resource,
  131. .num_resources = 1,
  132. };
  133. static struct imxuart_platform_data uart_pdata = {
  134. .flags = IMXUART_HAVE_RTSCTS,
  135. };
  136. static struct resource smsc911x_resources[] = {
  137. [0] = {
  138. .start = CS1_BASE_ADDR + 0x300,
  139. .end = CS1_BASE_ADDR + 0x300 + SZ_64K - 1,
  140. .flags = IORESOURCE_MEM,
  141. },
  142. [1] = {
  143. .start = IOMUX_TO_IRQ(MX31_PIN_GPIO3_1),
  144. .end = IOMUX_TO_IRQ(MX31_PIN_GPIO3_1),
  145. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  146. },
  147. };
  148. static struct smsc911x_platform_config smsc911x_info = {
  149. .flags = SMSC911X_USE_32BIT | SMSC911X_FORCE_INTERNAL_PHY |
  150. SMSC911X_SAVE_MAC_ADDRESS,
  151. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  152. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  153. .phy_interface = PHY_INTERFACE_MODE_MII,
  154. };
  155. static struct platform_device pcm037_eth = {
  156. .name = "smsc911x",
  157. .id = -1,
  158. .num_resources = ARRAY_SIZE(smsc911x_resources),
  159. .resource = smsc911x_resources,
  160. .dev = {
  161. .platform_data = &smsc911x_info,
  162. },
  163. };
  164. static struct platdata_mtd_ram pcm038_sram_data = {
  165. .bankwidth = 2,
  166. };
  167. static struct resource pcm038_sram_resource = {
  168. .start = CS4_BASE_ADDR,
  169. .end = CS4_BASE_ADDR + 512 * 1024 - 1,
  170. .flags = IORESOURCE_MEM,
  171. };
  172. static struct platform_device pcm037_sram_device = {
  173. .name = "mtd-ram",
  174. .id = 0,
  175. .dev = {
  176. .platform_data = &pcm038_sram_data,
  177. },
  178. .num_resources = 1,
  179. .resource = &pcm038_sram_resource,
  180. };
  181. static struct mxc_nand_platform_data pcm037_nand_board_info = {
  182. .width = 1,
  183. .hw_ecc = 1,
  184. };
  185. #ifdef CONFIG_I2C_IMX
  186. static struct imxi2c_platform_data pcm037_i2c_1_data = {
  187. .bitrate = 100000,
  188. };
  189. static struct at24_platform_data board_eeprom = {
  190. .byte_len = 4096,
  191. .page_size = 32,
  192. .flags = AT24_FLAG_ADDR16,
  193. };
  194. static struct i2c_board_info pcm037_i2c_devices[] = {
  195. {
  196. I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */
  197. .platform_data = &board_eeprom,
  198. }, {
  199. I2C_BOARD_INFO("rtc-pcf8563", 0x51),
  200. .type = "pcf8563",
  201. }
  202. };
  203. #endif
  204. /* Not connected by default */
  205. #ifdef PCM970_SDHC_RW_SWITCH
  206. static int pcm970_sdhc1_get_ro(struct device *dev)
  207. {
  208. return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_SFS6));
  209. }
  210. #endif
  211. static int pcm970_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
  212. void *data)
  213. {
  214. int ret;
  215. int gpio_det, gpio_wp;
  216. gpio_det = IOMUX_TO_GPIO(MX31_PIN_SCK6);
  217. gpio_wp = IOMUX_TO_GPIO(MX31_PIN_SFS6);
  218. gpio_direction_input(gpio_det);
  219. gpio_direction_input(gpio_wp);
  220. ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_SCK6), detect_irq,
  221. IRQF_DISABLED | IRQF_TRIGGER_FALLING,
  222. "sdhc-detect", data);
  223. return ret;
  224. }
  225. static void pcm970_sdhc1_exit(struct device *dev, void *data)
  226. {
  227. free_irq(IOMUX_TO_IRQ(MX31_PIN_SCK6), data);
  228. }
  229. static struct imxmmc_platform_data sdhc_pdata = {
  230. #ifdef PCM970_SDHC_RW_SWITCH
  231. .get_ro = pcm970_sdhc1_get_ro,
  232. #endif
  233. .init = pcm970_sdhc1_init,
  234. .exit = pcm970_sdhc1_exit,
  235. };
  236. static struct platform_device *devices[] __initdata = {
  237. &pcm037_flash,
  238. &pcm037_eth,
  239. &pcm037_sram_device,
  240. };
  241. /*
  242. * Board specific initialization.
  243. */
  244. static void __init mxc_board_init(void)
  245. {
  246. mxc_iomux_setup_multiple_pins(pcm037_pins, ARRAY_SIZE(pcm037_pins),
  247. "pcm037");
  248. platform_add_devices(devices, ARRAY_SIZE(devices));
  249. mxc_register_device(&mxc_uart_device0, &uart_pdata);
  250. mxc_register_device(&mxc_uart_device1, &uart_pdata);
  251. mxc_register_device(&mxc_uart_device2, &uart_pdata);
  252. mxc_register_device(&mxc_w1_master_device, NULL);
  253. /* LAN9217 IRQ pin */
  254. gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO3_1));
  255. #ifdef CONFIG_I2C_IMX
  256. i2c_register_board_info(1, pcm037_i2c_devices,
  257. ARRAY_SIZE(pcm037_i2c_devices));
  258. mxc_register_device(&mxc_i2c_device1, &pcm037_i2c_1_data);
  259. #endif
  260. mxc_register_device(&mxc_nand_device, &pcm037_nand_board_info);
  261. mxc_register_device(&mxcsdhc_device0, &sdhc_pdata);
  262. }
  263. static void __init pcm037_timer_init(void)
  264. {
  265. mx31_clocks_init(26000000);
  266. }
  267. struct sys_timer pcm037_timer = {
  268. .init = pcm037_timer_init,
  269. };
  270. MACHINE_START(PCM037, "Phytec Phycore pcm037")
  271. /* Maintainer: Pengutronix */
  272. .phys_io = AIPS1_BASE_ADDR,
  273. .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
  274. .boot_params = PHYS_OFFSET + 0x100,
  275. .map_io = mxc_map_io,
  276. .init_irq = mxc_init_irq,
  277. .init_machine = mxc_board_init,
  278. .timer = &pcm037_timer,
  279. MACHINE_END