pcm038.c 5.7 KB

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