pcm038.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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 <asm/mach/arch.h>
  23. #include <asm/mach-types.h>
  24. #include <mach/common.h>
  25. #include <mach/hardware.h>
  26. #include <mach/iomux-mx1-mx2.h>
  27. #include <asm/mach/time.h>
  28. #include <mach/imx-uart.h>
  29. #include <mach/board-pcm038.h>
  30. #include <mach/mxc_nand.h>
  31. #include "devices.h"
  32. /*
  33. * Phytec's PCM038 comes with 2MiB battery buffered SRAM,
  34. * 16 bit width
  35. */
  36. static struct platdata_mtd_ram pcm038_sram_data = {
  37. .bankwidth = 2,
  38. };
  39. static struct resource pcm038_sram_resource = {
  40. .start = CS1_BASE_ADDR,
  41. .end = CS1_BASE_ADDR + 512 * 1024 - 1,
  42. .flags = IORESOURCE_MEM,
  43. };
  44. static struct platform_device pcm038_sram_mtd_device = {
  45. .name = "mtd-ram",
  46. .id = 0,
  47. .dev = {
  48. .platform_data = &pcm038_sram_data,
  49. },
  50. .num_resources = 1,
  51. .resource = &pcm038_sram_resource,
  52. };
  53. /*
  54. * Phytec's phyCORE-i.MX27 comes with 32MiB flash,
  55. * 16 bit width
  56. */
  57. static struct physmap_flash_data pcm038_flash_data = {
  58. .width = 2,
  59. };
  60. static struct resource pcm038_flash_resource = {
  61. .start = 0xc0000000,
  62. .end = 0xc1ffffff,
  63. .flags = IORESOURCE_MEM,
  64. };
  65. static struct platform_device pcm038_nor_mtd_device = {
  66. .name = "physmap-flash",
  67. .id = 0,
  68. .dev = {
  69. .platform_data = &pcm038_flash_data,
  70. },
  71. .num_resources = 1,
  72. .resource = &pcm038_flash_resource,
  73. };
  74. static int mxc_uart0_pins[] = {
  75. PE12_PF_UART1_TXD,
  76. PE13_PF_UART1_RXD,
  77. PE14_PF_UART1_CTS,
  78. PE15_PF_UART1_RTS
  79. };
  80. static int uart_mxc_port0_init(struct platform_device *pdev)
  81. {
  82. return mxc_gpio_setup_multiple_pins(mxc_uart0_pins,
  83. ARRAY_SIZE(mxc_uart0_pins), "UART0");
  84. }
  85. static int uart_mxc_port0_exit(struct platform_device *pdev)
  86. {
  87. mxc_gpio_release_multiple_pins(mxc_uart0_pins,
  88. ARRAY_SIZE(mxc_uart0_pins));
  89. return 0;
  90. }
  91. static int mxc_uart1_pins[] = {
  92. PE3_PF_UART2_CTS,
  93. PE4_PF_UART2_RTS,
  94. PE6_PF_UART2_TXD,
  95. PE7_PF_UART2_RXD
  96. };
  97. static int uart_mxc_port1_init(struct platform_device *pdev)
  98. {
  99. return mxc_gpio_setup_multiple_pins(mxc_uart1_pins,
  100. ARRAY_SIZE(mxc_uart1_pins), "UART1");
  101. }
  102. static int uart_mxc_port1_exit(struct platform_device *pdev)
  103. {
  104. mxc_gpio_release_multiple_pins(mxc_uart1_pins,
  105. ARRAY_SIZE(mxc_uart1_pins));
  106. return 0;
  107. }
  108. static int mxc_uart2_pins[] = { PE10_PF_UART3_CTS,
  109. PE9_PF_UART3_RXD,
  110. PE10_PF_UART3_CTS,
  111. PE9_PF_UART3_RXD };
  112. static int uart_mxc_port2_init(struct platform_device *pdev)
  113. {
  114. return mxc_gpio_setup_multiple_pins(mxc_uart2_pins,
  115. ARRAY_SIZE(mxc_uart2_pins), "UART2");
  116. }
  117. static int uart_mxc_port2_exit(struct platform_device *pdev)
  118. {
  119. mxc_gpio_release_multiple_pins(mxc_uart2_pins,
  120. ARRAY_SIZE(mxc_uart2_pins));
  121. return 0;
  122. }
  123. static struct imxuart_platform_data uart_pdata[] = {
  124. {
  125. .init = uart_mxc_port0_init,
  126. .exit = uart_mxc_port0_exit,
  127. .flags = IMXUART_HAVE_RTSCTS,
  128. }, {
  129. .init = uart_mxc_port1_init,
  130. .exit = uart_mxc_port1_exit,
  131. .flags = IMXUART_HAVE_RTSCTS,
  132. }, {
  133. .init = uart_mxc_port2_init,
  134. .exit = uart_mxc_port2_exit,
  135. .flags = IMXUART_HAVE_RTSCTS,
  136. },
  137. };
  138. static int mxc_fec_pins[] = {
  139. PD0_AIN_FEC_TXD0,
  140. PD1_AIN_FEC_TXD1,
  141. PD2_AIN_FEC_TXD2,
  142. PD3_AIN_FEC_TXD3,
  143. PD4_AOUT_FEC_RX_ER,
  144. PD5_AOUT_FEC_RXD1,
  145. PD6_AOUT_FEC_RXD2,
  146. PD7_AOUT_FEC_RXD3,
  147. PD8_AF_FEC_MDIO,
  148. PD9_AIN_FEC_MDC,
  149. PD10_AOUT_FEC_CRS,
  150. PD11_AOUT_FEC_TX_CLK,
  151. PD12_AOUT_FEC_RXD0,
  152. PD13_AOUT_FEC_RX_DV,
  153. PD14_AOUT_FEC_CLR,
  154. PD15_AOUT_FEC_COL,
  155. PD16_AIN_FEC_TX_ER,
  156. PF23_AIN_FEC_TX_EN
  157. };
  158. static void gpio_fec_active(void)
  159. {
  160. mxc_gpio_setup_multiple_pins(mxc_fec_pins,
  161. ARRAY_SIZE(mxc_fec_pins), "FEC");
  162. }
  163. static void gpio_fec_inactive(void)
  164. {
  165. mxc_gpio_release_multiple_pins(mxc_fec_pins,
  166. ARRAY_SIZE(mxc_fec_pins));
  167. }
  168. static struct mxc_nand_platform_data pcm038_nand_board_info = {
  169. .width = 1,
  170. .hw_ecc = 1,
  171. };
  172. static struct platform_device *platform_devices[] __initdata = {
  173. &pcm038_nor_mtd_device,
  174. &mxc_w1_master_device,
  175. &pcm038_sram_mtd_device,
  176. };
  177. /* On pcm038 there's a sram attached to CS1, we enable the chipselect here and
  178. * setup other stuffs to access the sram. */
  179. static void __init pcm038_init_sram(void)
  180. {
  181. __raw_writel(0x0000d843, CSCR_U(1));
  182. __raw_writel(0x22252521, CSCR_L(1));
  183. __raw_writel(0x22220a00, CSCR_A(1));
  184. }
  185. static void __init pcm038_init(void)
  186. {
  187. gpio_fec_active();
  188. pcm038_init_sram();
  189. mxc_register_device(&mxc_uart_device0, &uart_pdata[0]);
  190. mxc_register_device(&mxc_uart_device1, &uart_pdata[1]);
  191. mxc_register_device(&mxc_uart_device2, &uart_pdata[2]);
  192. mxc_gpio_mode(PE16_AF_RTCK); /* OWIRE */
  193. mxc_register_device(&mxc_nand_device, &pcm038_nand_board_info);
  194. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  195. #ifdef CONFIG_MACH_PCM970_BASEBOARD
  196. pcm970_baseboard_init();
  197. #endif
  198. }
  199. static void __init pcm038_timer_init(void)
  200. {
  201. mxc_clocks_init(26000000);
  202. mxc_timer_init("gpt_clk.0");
  203. }
  204. struct sys_timer pcm038_timer = {
  205. .init = pcm038_timer_init,
  206. };
  207. MACHINE_START(PCM038, "phyCORE-i.MX27")
  208. .phys_io = AIPI_BASE_ADDR,
  209. .io_pg_offst = ((AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
  210. .boot_params = PHYS_OFFSET + 0x100,
  211. .map_io = mxc_map_io,
  212. .init_irq = mxc_init_irq,
  213. .init_machine = pcm038_init,
  214. .timer = &pcm038_timer,
  215. MACHINE_END