pca100.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /*
  2. * Copyright 2007 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix
  3. * Copyright (C) 2009 Sascha Hauer (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/io.h>
  21. #include <linux/i2c.h>
  22. #include <linux/i2c/at24.h>
  23. #include <linux/dma-mapping.h>
  24. #include <linux/spi/spi.h>
  25. #include <linux/spi/eeprom.h>
  26. #include <linux/irq.h>
  27. #include <linux/gpio.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach-types.h>
  30. #include <mach/common.h>
  31. #include <mach/hardware.h>
  32. #include <mach/iomux.h>
  33. #include <mach/i2c.h>
  34. #include <asm/mach/time.h>
  35. #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
  36. #include <mach/spi.h>
  37. #endif
  38. #include <mach/imx-uart.h>
  39. #include <mach/mxc_nand.h>
  40. #include <mach/irqs.h>
  41. #include <mach/mmc.h>
  42. #include "devices.h"
  43. static int pca100_pins[] = {
  44. /* UART1 */
  45. PE12_PF_UART1_TXD,
  46. PE13_PF_UART1_RXD,
  47. PE14_PF_UART1_CTS,
  48. PE15_PF_UART1_RTS,
  49. /* SDHC */
  50. PB4_PF_SD2_D0,
  51. PB5_PF_SD2_D1,
  52. PB6_PF_SD2_D2,
  53. PB7_PF_SD2_D3,
  54. PB8_PF_SD2_CMD,
  55. PB9_PF_SD2_CLK,
  56. /* FEC */
  57. PD0_AIN_FEC_TXD0,
  58. PD1_AIN_FEC_TXD1,
  59. PD2_AIN_FEC_TXD2,
  60. PD3_AIN_FEC_TXD3,
  61. PD4_AOUT_FEC_RX_ER,
  62. PD5_AOUT_FEC_RXD1,
  63. PD6_AOUT_FEC_RXD2,
  64. PD7_AOUT_FEC_RXD3,
  65. PD8_AF_FEC_MDIO,
  66. PD9_AIN_FEC_MDC,
  67. PD10_AOUT_FEC_CRS,
  68. PD11_AOUT_FEC_TX_CLK,
  69. PD12_AOUT_FEC_RXD0,
  70. PD13_AOUT_FEC_RX_DV,
  71. PD14_AOUT_FEC_RX_CLK,
  72. PD15_AOUT_FEC_COL,
  73. PD16_AIN_FEC_TX_ER,
  74. PF23_AIN_FEC_TX_EN,
  75. /* SSI1 */
  76. PC20_PF_SSI1_FS,
  77. PC21_PF_SSI1_RXD,
  78. PC22_PF_SSI1_TXD,
  79. PC23_PF_SSI1_CLK,
  80. /* onboard I2C */
  81. PC5_PF_I2C2_SDA,
  82. PC6_PF_I2C2_SCL,
  83. /* external I2C */
  84. PD17_PF_I2C_DATA,
  85. PD18_PF_I2C_CLK,
  86. /* SPI1 */
  87. PD25_PF_CSPI1_RDY,
  88. PD29_PF_CSPI1_SCLK,
  89. PD30_PF_CSPI1_MISO,
  90. PD31_PF_CSPI1_MOSI,
  91. };
  92. static struct imxuart_platform_data uart_pdata = {
  93. .flags = IMXUART_HAVE_RTSCTS,
  94. };
  95. static struct mxc_nand_platform_data pca100_nand_board_info = {
  96. .width = 1,
  97. .hw_ecc = 1,
  98. };
  99. static struct platform_device *platform_devices[] __initdata = {
  100. &mxc_w1_master_device,
  101. &mxc_fec_device,
  102. };
  103. static struct imxi2c_platform_data pca100_i2c_1_data = {
  104. .bitrate = 100000,
  105. };
  106. static struct at24_platform_data board_eeprom = {
  107. .byte_len = 4096,
  108. .page_size = 32,
  109. .flags = AT24_FLAG_ADDR16,
  110. };
  111. static struct i2c_board_info pca100_i2c_devices[] = {
  112. {
  113. I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */
  114. .platform_data = &board_eeprom,
  115. }, {
  116. I2C_BOARD_INFO("rtc-pcf8563", 0x51),
  117. .type = "pcf8563"
  118. }, {
  119. I2C_BOARD_INFO("lm75", 0x4a),
  120. .type = "lm75"
  121. }
  122. };
  123. #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
  124. static struct spi_eeprom at25320 = {
  125. .name = "at25320an",
  126. .byte_len = 4096,
  127. .page_size = 32,
  128. .flags = EE_ADDR2,
  129. };
  130. static struct spi_board_info pca100_spi_board_info[] __initdata = {
  131. {
  132. .modalias = "at25",
  133. .max_speed_hz = 30000,
  134. .bus_num = 0,
  135. .chip_select = 1,
  136. .platform_data = &at25320,
  137. },
  138. };
  139. static int pca100_spi_cs[] = {GPIO_PORTD + 28, GPIO_PORTD + 27};
  140. static struct spi_imx_master pca100_spi_0_data = {
  141. .chipselect = pca100_spi_cs,
  142. .num_chipselect = ARRAY_SIZE(pca100_spi_cs),
  143. };
  144. #endif
  145. static int pca100_sdhc2_init(struct device *dev, irq_handler_t detect_irq,
  146. void *data)
  147. {
  148. int ret;
  149. ret = request_irq(IRQ_GPIOC(29), detect_irq,
  150. IRQF_DISABLED | IRQF_TRIGGER_FALLING,
  151. "imx-mmc-detect", data);
  152. if (ret)
  153. printk(KERN_ERR
  154. "pca100: Failed to reuest irq for sd/mmc detection\n");
  155. return ret;
  156. }
  157. static void pca100_sdhc2_exit(struct device *dev, void *data)
  158. {
  159. free_irq(IRQ_GPIOC(29), data);
  160. }
  161. static struct imxmmc_platform_data sdhc_pdata = {
  162. .init = pca100_sdhc2_init,
  163. .exit = pca100_sdhc2_exit,
  164. };
  165. static void __init pca100_init(void)
  166. {
  167. int ret;
  168. ret = mxc_gpio_setup_multiple_pins(pca100_pins,
  169. ARRAY_SIZE(pca100_pins), "PCA100");
  170. if (ret)
  171. printk(KERN_ERR "pca100: Failed to setup pins (%d)\n", ret);
  172. mxc_register_device(&mxc_uart_device0, &uart_pdata);
  173. mxc_gpio_mode(GPIO_PORTC | 29 | GPIO_GPIO | GPIO_IN);
  174. mxc_register_device(&mxc_sdhc_device1, &sdhc_pdata);
  175. mxc_register_device(&mxc_nand_device, &pca100_nand_board_info);
  176. /* only the i2c master 1 is used on this CPU card */
  177. i2c_register_board_info(1, pca100_i2c_devices,
  178. ARRAY_SIZE(pca100_i2c_devices));
  179. mxc_register_device(&mxc_i2c_device1, &pca100_i2c_1_data);
  180. mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT);
  181. mxc_gpio_mode(GPIO_PORTD | 27 | GPIO_GPIO | GPIO_OUT);
  182. /* GPIO0_IRQ */
  183. mxc_gpio_mode(GPIO_PORTC | 31 | GPIO_GPIO | GPIO_IN);
  184. /* GPIO1_IRQ */
  185. mxc_gpio_mode(GPIO_PORTC | 25 | GPIO_GPIO | GPIO_IN);
  186. /* GPIO2_IRQ */
  187. mxc_gpio_mode(GPIO_PORTE | 5 | GPIO_GPIO | GPIO_IN);
  188. #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
  189. spi_register_board_info(pca100_spi_board_info,
  190. ARRAY_SIZE(pca100_spi_board_info));
  191. mxc_register_device(&mxc_spi_device0, &pca100_spi_0_data);
  192. #endif
  193. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  194. }
  195. static void __init pca100_timer_init(void)
  196. {
  197. mx27_clocks_init(26000000);
  198. }
  199. static struct sys_timer pca100_timer = {
  200. .init = pca100_timer_init,
  201. };
  202. MACHINE_START(PCA100, "phyCARD-i.MX27")
  203. .phys_io = AIPI_BASE_ADDR,
  204. .io_pg_offst = ((AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
  205. .boot_params = PHYS_OFFSET + 0x100,
  206. .map_io = mx27_map_io,
  207. .init_irq = mxc_init_irq,
  208. .init_machine = pca100_init,
  209. .timer = &pca100_timer,
  210. MACHINE_END