pcm038.c 5.6 KB

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