pcm037.c 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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/ipu.h>
  41. #include <mach/board-pcm037.h>
  42. #include <mach/mx3fb.h>
  43. #include <mach/mxc_nand.h>
  44. #include <mach/mmc.h>
  45. #ifdef CONFIG_I2C_IMX
  46. #include <mach/i2c.h>
  47. #endif
  48. #include "devices.h"
  49. static unsigned int pcm037_pins[] = {
  50. /* I2C */
  51. MX31_PIN_CSPI2_MOSI__SCL,
  52. MX31_PIN_CSPI2_MISO__SDA,
  53. /* SDHC1 */
  54. MX31_PIN_SD1_DATA3__SD1_DATA3,
  55. MX31_PIN_SD1_DATA2__SD1_DATA2,
  56. MX31_PIN_SD1_DATA1__SD1_DATA1,
  57. MX31_PIN_SD1_DATA0__SD1_DATA0,
  58. MX31_PIN_SD1_CLK__SD1_CLK,
  59. MX31_PIN_SD1_CMD__SD1_CMD,
  60. IOMUX_MODE(MX31_PIN_SCK6, IOMUX_CONFIG_GPIO), /* card detect */
  61. IOMUX_MODE(MX31_PIN_SFS6, IOMUX_CONFIG_GPIO), /* write protect */
  62. /* SPI1 */
  63. MX31_PIN_CSPI1_MOSI__MOSI,
  64. MX31_PIN_CSPI1_MISO__MISO,
  65. MX31_PIN_CSPI1_SCLK__SCLK,
  66. MX31_PIN_CSPI1_SPI_RDY__SPI_RDY,
  67. MX31_PIN_CSPI1_SS0__SS0,
  68. MX31_PIN_CSPI1_SS1__SS1,
  69. MX31_PIN_CSPI1_SS2__SS2,
  70. /* UART1 */
  71. MX31_PIN_CTS1__CTS1,
  72. MX31_PIN_RTS1__RTS1,
  73. MX31_PIN_TXD1__TXD1,
  74. MX31_PIN_RXD1__RXD1,
  75. /* UART2 */
  76. MX31_PIN_TXD2__TXD2,
  77. MX31_PIN_RXD2__RXD2,
  78. MX31_PIN_CTS2__CTS2,
  79. MX31_PIN_RTS2__RTS2,
  80. /* UART3 */
  81. MX31_PIN_CSPI3_MOSI__RXD3,
  82. MX31_PIN_CSPI3_MISO__TXD3,
  83. MX31_PIN_CSPI3_SCLK__RTS3,
  84. MX31_PIN_CSPI3_SPI_RDY__CTS3,
  85. /* LAN9217 irq pin */
  86. IOMUX_MODE(MX31_PIN_GPIO3_1, IOMUX_CONFIG_GPIO),
  87. /* Onewire */
  88. MX31_PIN_BATT_LINE__OWIRE,
  89. /* Framebuffer */
  90. MX31_PIN_LD0__LD0,
  91. MX31_PIN_LD1__LD1,
  92. MX31_PIN_LD2__LD2,
  93. MX31_PIN_LD3__LD3,
  94. MX31_PIN_LD4__LD4,
  95. MX31_PIN_LD5__LD5,
  96. MX31_PIN_LD6__LD6,
  97. MX31_PIN_LD7__LD7,
  98. MX31_PIN_LD8__LD8,
  99. MX31_PIN_LD9__LD9,
  100. MX31_PIN_LD10__LD10,
  101. MX31_PIN_LD11__LD11,
  102. MX31_PIN_LD12__LD12,
  103. MX31_PIN_LD13__LD13,
  104. MX31_PIN_LD14__LD14,
  105. MX31_PIN_LD15__LD15,
  106. MX31_PIN_LD16__LD16,
  107. MX31_PIN_LD17__LD17,
  108. MX31_PIN_VSYNC3__VSYNC3,
  109. MX31_PIN_HSYNC__HSYNC,
  110. MX31_PIN_FPSHIFT__FPSHIFT,
  111. MX31_PIN_DRDY0__DRDY0,
  112. MX31_PIN_D3_REV__D3_REV,
  113. MX31_PIN_CONTRAST__CONTRAST,
  114. MX31_PIN_D3_SPL__D3_SPL,
  115. MX31_PIN_D3_CLS__D3_CLS,
  116. MX31_PIN_LCS0__GPI03_23,
  117. };
  118. static struct physmap_flash_data pcm037_flash_data = {
  119. .width = 2,
  120. };
  121. static struct resource pcm037_flash_resource = {
  122. .start = 0xa0000000,
  123. .end = 0xa1ffffff,
  124. .flags = IORESOURCE_MEM,
  125. };
  126. static struct platform_device pcm037_flash = {
  127. .name = "physmap-flash",
  128. .id = 0,
  129. .dev = {
  130. .platform_data = &pcm037_flash_data,
  131. },
  132. .resource = &pcm037_flash_resource,
  133. .num_resources = 1,
  134. };
  135. static struct imxuart_platform_data uart_pdata = {
  136. .flags = IMXUART_HAVE_RTSCTS,
  137. };
  138. static struct resource smsc911x_resources[] = {
  139. [0] = {
  140. .start = CS1_BASE_ADDR + 0x300,
  141. .end = CS1_BASE_ADDR + 0x300 + SZ_64K - 1,
  142. .flags = IORESOURCE_MEM,
  143. },
  144. [1] = {
  145. .start = IOMUX_TO_IRQ(MX31_PIN_GPIO3_1),
  146. .end = IOMUX_TO_IRQ(MX31_PIN_GPIO3_1),
  147. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  148. },
  149. };
  150. static struct smsc911x_platform_config smsc911x_info = {
  151. .flags = SMSC911X_USE_32BIT | SMSC911X_FORCE_INTERNAL_PHY |
  152. SMSC911X_SAVE_MAC_ADDRESS,
  153. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  154. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  155. .phy_interface = PHY_INTERFACE_MODE_MII,
  156. };
  157. static struct platform_device pcm037_eth = {
  158. .name = "smsc911x",
  159. .id = -1,
  160. .num_resources = ARRAY_SIZE(smsc911x_resources),
  161. .resource = smsc911x_resources,
  162. .dev = {
  163. .platform_data = &smsc911x_info,
  164. },
  165. };
  166. static struct platdata_mtd_ram pcm038_sram_data = {
  167. .bankwidth = 2,
  168. };
  169. static struct resource pcm038_sram_resource = {
  170. .start = CS4_BASE_ADDR,
  171. .end = CS4_BASE_ADDR + 512 * 1024 - 1,
  172. .flags = IORESOURCE_MEM,
  173. };
  174. static struct platform_device pcm037_sram_device = {
  175. .name = "mtd-ram",
  176. .id = 0,
  177. .dev = {
  178. .platform_data = &pcm038_sram_data,
  179. },
  180. .num_resources = 1,
  181. .resource = &pcm038_sram_resource,
  182. };
  183. static struct mxc_nand_platform_data pcm037_nand_board_info = {
  184. .width = 1,
  185. .hw_ecc = 1,
  186. };
  187. #ifdef CONFIG_I2C_IMX
  188. static struct imxi2c_platform_data pcm037_i2c_1_data = {
  189. .bitrate = 100000,
  190. };
  191. static struct at24_platform_data board_eeprom = {
  192. .byte_len = 4096,
  193. .page_size = 32,
  194. .flags = AT24_FLAG_ADDR16,
  195. };
  196. static struct i2c_board_info pcm037_i2c_devices[] = {
  197. {
  198. I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */
  199. .platform_data = &board_eeprom,
  200. }, {
  201. I2C_BOARD_INFO("rtc-pcf8563", 0x51),
  202. .type = "pcf8563",
  203. }
  204. };
  205. #endif
  206. /* Not connected by default */
  207. #ifdef PCM970_SDHC_RW_SWITCH
  208. static int pcm970_sdhc1_get_ro(struct device *dev)
  209. {
  210. return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_SFS6));
  211. }
  212. #endif
  213. static int pcm970_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
  214. void *data)
  215. {
  216. int ret;
  217. int gpio_det, gpio_wp;
  218. gpio_det = IOMUX_TO_GPIO(MX31_PIN_SCK6);
  219. gpio_wp = IOMUX_TO_GPIO(MX31_PIN_SFS6);
  220. gpio_direction_input(gpio_det);
  221. gpio_direction_input(gpio_wp);
  222. ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_SCK6), detect_irq,
  223. IRQF_DISABLED | IRQF_TRIGGER_FALLING,
  224. "sdhc-detect", data);
  225. return ret;
  226. }
  227. static void pcm970_sdhc1_exit(struct device *dev, void *data)
  228. {
  229. free_irq(IOMUX_TO_IRQ(MX31_PIN_SCK6), data);
  230. }
  231. static struct imxmmc_platform_data sdhc_pdata = {
  232. #ifdef PCM970_SDHC_RW_SWITCH
  233. .get_ro = pcm970_sdhc1_get_ro,
  234. #endif
  235. .init = pcm970_sdhc1_init,
  236. .exit = pcm970_sdhc1_exit,
  237. };
  238. static struct platform_device *devices[] __initdata = {
  239. &pcm037_flash,
  240. &pcm037_eth,
  241. &pcm037_sram_device,
  242. };
  243. static struct ipu_platform_data mx3_ipu_data = {
  244. .irq_base = MXC_IPU_IRQ_START,
  245. };
  246. static const struct fb_videomode fb_modedb[] = {
  247. {
  248. /* 240x320 @ 60 Hz Sharp */
  249. .name = "Sharp-LQ035Q7DH06-QVGA",
  250. .refresh = 60,
  251. .xres = 240,
  252. .yres = 320,
  253. .pixclock = 185925,
  254. .left_margin = 9,
  255. .right_margin = 16,
  256. .upper_margin = 7,
  257. .lower_margin = 9,
  258. .hsync_len = 1,
  259. .vsync_len = 1,
  260. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_SHARP_MODE |
  261. FB_SYNC_CLK_INVERT | FB_SYNC_CLK_IDLE_EN,
  262. .vmode = FB_VMODE_NONINTERLACED,
  263. .flag = 0,
  264. }, {
  265. /* 240x320 @ 60 Hz */
  266. .name = "TX090",
  267. .refresh = 60,
  268. .xres = 240,
  269. .yres = 320,
  270. .pixclock = 38255,
  271. .left_margin = 144,
  272. .right_margin = 0,
  273. .upper_margin = 7,
  274. .lower_margin = 40,
  275. .hsync_len = 96,
  276. .vsync_len = 1,
  277. .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_OE_ACT_HIGH,
  278. .vmode = FB_VMODE_NONINTERLACED,
  279. .flag = 0,
  280. },
  281. };
  282. static struct mx3fb_platform_data mx3fb_pdata = {
  283. .dma_dev = &mx3_ipu.dev,
  284. .name = "Sharp-LQ035Q7DH06-QVGA",
  285. .mode = fb_modedb,
  286. .num_modes = ARRAY_SIZE(fb_modedb),
  287. };
  288. /*
  289. * Board specific initialization.
  290. */
  291. static void __init mxc_board_init(void)
  292. {
  293. mxc_iomux_setup_multiple_pins(pcm037_pins, ARRAY_SIZE(pcm037_pins),
  294. "pcm037");
  295. platform_add_devices(devices, ARRAY_SIZE(devices));
  296. mxc_register_device(&mxc_uart_device0, &uart_pdata);
  297. mxc_register_device(&mxc_uart_device1, &uart_pdata);
  298. mxc_register_device(&mxc_uart_device2, &uart_pdata);
  299. mxc_register_device(&mxc_w1_master_device, NULL);
  300. /* LAN9217 IRQ pin */
  301. gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO3_1));
  302. #ifdef CONFIG_I2C_IMX
  303. i2c_register_board_info(1, pcm037_i2c_devices,
  304. ARRAY_SIZE(pcm037_i2c_devices));
  305. mxc_register_device(&mxc_i2c_device1, &pcm037_i2c_1_data);
  306. #endif
  307. mxc_register_device(&mxc_nand_device, &pcm037_nand_board_info);
  308. mxc_register_device(&mxcsdhc_device0, &sdhc_pdata);
  309. mxc_register_device(&mx3_ipu, &mx3_ipu_data);
  310. mxc_register_device(&mx3_fb, &mx3fb_pdata);
  311. }
  312. static void __init pcm037_timer_init(void)
  313. {
  314. mx31_clocks_init(26000000);
  315. }
  316. struct sys_timer pcm037_timer = {
  317. .init = pcm037_timer_init,
  318. };
  319. MACHINE_START(PCM037, "Phytec Phycore pcm037")
  320. /* Maintainer: Pengutronix */
  321. .phys_io = AIPS1_BASE_ADDR,
  322. .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
  323. .boot_params = PHYS_OFFSET + 0x100,
  324. .map_io = mx31_map_io,
  325. .init_irq = mxc_init_irq,
  326. .init_machine = mxc_board_init,
  327. .timer = &pcm037_timer,
  328. MACHINE_END