pcm038.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. /*
  2. * Copyright 2007 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix
  3. * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  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., 51 Franklin Street, Fifth Floor, Boston,
  17. * MA 02110-1301, USA.
  18. */
  19. #include <linux/platform_device.h>
  20. #include <linux/mtd/physmap.h>
  21. #include <linux/mtd/plat-ram.h>
  22. #include <linux/io.h>
  23. #include <linux/i2c.h>
  24. #include <linux/i2c/at24.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach-types.h>
  27. #include <mach/common.h>
  28. #include <mach/hardware.h>
  29. #include <mach/iomux.h>
  30. #ifdef CONFIG_I2C_IMX
  31. #include <mach/i2c.h>
  32. #endif
  33. #include <asm/mach/time.h>
  34. #include <mach/imx-uart.h>
  35. #include <mach/board-pcm038.h>
  36. #include <mach/mxc_nand.h>
  37. #include "devices.h"
  38. /*
  39. * Phytec's PCM038 comes with 2MiB battery buffered SRAM,
  40. * 16 bit width
  41. */
  42. static struct platdata_mtd_ram pcm038_sram_data = {
  43. .bankwidth = 2,
  44. };
  45. static struct resource pcm038_sram_resource = {
  46. .start = CS1_BASE_ADDR,
  47. .end = CS1_BASE_ADDR + 512 * 1024 - 1,
  48. .flags = IORESOURCE_MEM,
  49. };
  50. static struct platform_device pcm038_sram_mtd_device = {
  51. .name = "mtd-ram",
  52. .id = 0,
  53. .dev = {
  54. .platform_data = &pcm038_sram_data,
  55. },
  56. .num_resources = 1,
  57. .resource = &pcm038_sram_resource,
  58. };
  59. /*
  60. * Phytec's phyCORE-i.MX27 comes with 32MiB flash,
  61. * 16 bit width
  62. */
  63. static struct physmap_flash_data pcm038_flash_data = {
  64. .width = 2,
  65. };
  66. static struct resource pcm038_flash_resource = {
  67. .start = 0xc0000000,
  68. .end = 0xc1ffffff,
  69. .flags = IORESOURCE_MEM,
  70. };
  71. static struct platform_device pcm038_nor_mtd_device = {
  72. .name = "physmap-flash",
  73. .id = 0,
  74. .dev = {
  75. .platform_data = &pcm038_flash_data,
  76. },
  77. .num_resources = 1,
  78. .resource = &pcm038_flash_resource,
  79. };
  80. static int mxc_uart0_pins[] = {
  81. PE12_PF_UART1_TXD,
  82. PE13_PF_UART1_RXD,
  83. PE14_PF_UART1_CTS,
  84. PE15_PF_UART1_RTS
  85. };
  86. static int uart_mxc_port0_init(struct platform_device *pdev)
  87. {
  88. return mxc_gpio_setup_multiple_pins(mxc_uart0_pins,
  89. ARRAY_SIZE(mxc_uart0_pins), "UART0");
  90. }
  91. static int uart_mxc_port0_exit(struct platform_device *pdev)
  92. {
  93. mxc_gpio_release_multiple_pins(mxc_uart0_pins,
  94. ARRAY_SIZE(mxc_uart0_pins));
  95. return 0;
  96. }
  97. static int mxc_uart1_pins[] = {
  98. PE3_PF_UART2_CTS,
  99. PE4_PF_UART2_RTS,
  100. PE6_PF_UART2_TXD,
  101. PE7_PF_UART2_RXD
  102. };
  103. static int uart_mxc_port1_init(struct platform_device *pdev)
  104. {
  105. return mxc_gpio_setup_multiple_pins(mxc_uart1_pins,
  106. ARRAY_SIZE(mxc_uart1_pins), "UART1");
  107. }
  108. static int uart_mxc_port1_exit(struct platform_device *pdev)
  109. {
  110. mxc_gpio_release_multiple_pins(mxc_uart1_pins,
  111. ARRAY_SIZE(mxc_uart1_pins));
  112. return 0;
  113. }
  114. static int mxc_uart2_pins[] = { PE8_PF_UART3_TXD,
  115. PE9_PF_UART3_RXD,
  116. PE10_PF_UART3_CTS,
  117. PE11_PF_UART3_RTS };
  118. static int uart_mxc_port2_init(struct platform_device *pdev)
  119. {
  120. return mxc_gpio_setup_multiple_pins(mxc_uart2_pins,
  121. ARRAY_SIZE(mxc_uart2_pins), "UART2");
  122. }
  123. static int uart_mxc_port2_exit(struct platform_device *pdev)
  124. {
  125. mxc_gpio_release_multiple_pins(mxc_uart2_pins,
  126. ARRAY_SIZE(mxc_uart2_pins));
  127. return 0;
  128. }
  129. static struct imxuart_platform_data uart_pdata[] = {
  130. {
  131. .init = uart_mxc_port0_init,
  132. .exit = uart_mxc_port0_exit,
  133. .flags = IMXUART_HAVE_RTSCTS,
  134. }, {
  135. .init = uart_mxc_port1_init,
  136. .exit = uart_mxc_port1_exit,
  137. .flags = IMXUART_HAVE_RTSCTS,
  138. }, {
  139. .init = uart_mxc_port2_init,
  140. .exit = uart_mxc_port2_exit,
  141. .flags = IMXUART_HAVE_RTSCTS,
  142. },
  143. };
  144. static int mxc_fec_pins[] = {
  145. PD0_AIN_FEC_TXD0,
  146. PD1_AIN_FEC_TXD1,
  147. PD2_AIN_FEC_TXD2,
  148. PD3_AIN_FEC_TXD3,
  149. PD4_AOUT_FEC_RX_ER,
  150. PD5_AOUT_FEC_RXD1,
  151. PD6_AOUT_FEC_RXD2,
  152. PD7_AOUT_FEC_RXD3,
  153. PD8_AF_FEC_MDIO,
  154. PD9_AIN_FEC_MDC,
  155. PD10_AOUT_FEC_CRS,
  156. PD11_AOUT_FEC_TX_CLK,
  157. PD12_AOUT_FEC_RXD0,
  158. PD13_AOUT_FEC_RX_DV,
  159. PD14_AOUT_FEC_RX_CLK,
  160. PD15_AOUT_FEC_COL,
  161. PD16_AIN_FEC_TX_ER,
  162. PF23_AIN_FEC_TX_EN
  163. };
  164. static void gpio_fec_active(void)
  165. {
  166. mxc_gpio_setup_multiple_pins(mxc_fec_pins,
  167. ARRAY_SIZE(mxc_fec_pins), "FEC");
  168. }
  169. static struct mxc_nand_platform_data pcm038_nand_board_info = {
  170. .width = 1,
  171. .hw_ecc = 1,
  172. };
  173. static struct platform_device *platform_devices[] __initdata = {
  174. &pcm038_nor_mtd_device,
  175. &mxc_w1_master_device,
  176. &mxc_fec_device,
  177. &pcm038_sram_mtd_device,
  178. };
  179. /* On pcm038 there's a sram attached to CS1, we enable the chipselect here and
  180. * setup other stuffs to access the sram. */
  181. static void __init pcm038_init_sram(void)
  182. {
  183. __raw_writel(0x0000d843, CSCR_U(1));
  184. __raw_writel(0x22252521, CSCR_L(1));
  185. __raw_writel(0x22220a00, CSCR_A(1));
  186. }
  187. #ifdef CONFIG_I2C_IMX
  188. static int mxc_i2c1_pins[] = {
  189. PC5_PF_I2C2_SDA,
  190. PC6_PF_I2C2_SCL
  191. };
  192. static int pcm038_i2c_1_init(struct device *dev)
  193. {
  194. return mxc_gpio_setup_multiple_pins(mxc_i2c1_pins, ARRAY_SIZE(mxc_i2c1_pins),
  195. "I2C1");
  196. }
  197. static void pcm038_i2c_1_exit(struct device *dev)
  198. {
  199. mxc_gpio_release_multiple_pins(mxc_i2c1_pins, ARRAY_SIZE(mxc_i2c1_pins));
  200. }
  201. static struct imxi2c_platform_data pcm038_i2c_1_data = {
  202. .bitrate = 100000,
  203. .init = pcm038_i2c_1_init,
  204. .exit = pcm038_i2c_1_exit,
  205. };
  206. static struct at24_platform_data board_eeprom = {
  207. .byte_len = 4096,
  208. .page_size = 32,
  209. .flags = AT24_FLAG_ADDR16,
  210. };
  211. static struct i2c_board_info pcm038_i2c_devices[] = {
  212. [0] = {
  213. I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */
  214. .platform_data = &board_eeprom,
  215. },
  216. [1] = {
  217. I2C_BOARD_INFO("rtc-pcf8563", 0x51),
  218. .type = "pcf8563"
  219. },
  220. [2] = {
  221. I2C_BOARD_INFO("lm75", 0x4a),
  222. .type = "lm75"
  223. }
  224. };
  225. #endif
  226. static void __init pcm038_init(void)
  227. {
  228. gpio_fec_active();
  229. pcm038_init_sram();
  230. mxc_register_device(&mxc_uart_device0, &uart_pdata[0]);
  231. mxc_register_device(&mxc_uart_device1, &uart_pdata[1]);
  232. mxc_register_device(&mxc_uart_device2, &uart_pdata[2]);
  233. mxc_gpio_mode(PE16_AF_OWIRE);
  234. mxc_register_device(&mxc_nand_device, &pcm038_nand_board_info);
  235. #ifdef CONFIG_I2C_IMX
  236. /* only the i2c master 1 is used on this CPU card */
  237. i2c_register_board_info(1, pcm038_i2c_devices,
  238. ARRAY_SIZE(pcm038_i2c_devices));
  239. mxc_register_device(&mxc_i2c_device1, &pcm038_i2c_1_data);
  240. #endif
  241. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  242. #ifdef CONFIG_MACH_PCM970_BASEBOARD
  243. pcm970_baseboard_init();
  244. #endif
  245. }
  246. static void __init pcm038_timer_init(void)
  247. {
  248. mx27_clocks_init(26000000);
  249. }
  250. static struct sys_timer pcm038_timer = {
  251. .init = pcm038_timer_init,
  252. };
  253. MACHINE_START(PCM038, "phyCORE-i.MX27")
  254. .phys_io = AIPI_BASE_ADDR,
  255. .io_pg_offst = ((AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
  256. .boot_params = PHYS_OFFSET + 0x100,
  257. .map_io = mxc_map_io,
  258. .init_irq = mxc_init_irq,
  259. .init_machine = pcm038_init,
  260. .timer = &pcm038_timer,
  261. MACHINE_END