pcm038.c 5.8 KB

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