mx1ads.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. * arch/arm/mach-imx/mx1ads.c
  3. *
  4. * Initially based on:
  5. * linux-2.6.7-imx/arch/arm/mach-imx/scb9328.c
  6. * Copyright (c) 2004 Sascha Hauer <sascha@saschahauer.de>
  7. *
  8. * 2004 (c) MontaVista Software, Inc.
  9. *
  10. * This file is licensed under the terms of the GNU General Public
  11. * License version 2. This program is licensed "as is" without any
  12. * warranty of any kind, whether express or implied.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/mtd/physmap.h>
  18. #include <linux/i2c.h>
  19. #include <linux/i2c/pcf857x.h>
  20. #include <asm/mach-types.h>
  21. #include <asm/mach/arch.h>
  22. #include <asm/mach/time.h>
  23. #include <mach/irqs.h>
  24. #include <mach/hardware.h>
  25. #include <mach/common.h>
  26. #include <mach/imx-uart.h>
  27. #include <mach/irqs.h>
  28. #ifdef CONFIG_I2C_IMX
  29. #include <mach/i2c.h>
  30. #endif
  31. #include <mach/iomux.h>
  32. #include "devices.h"
  33. /*
  34. * UARTs platform data
  35. */
  36. static int mxc_uart1_pins[] = {
  37. PC9_PF_UART1_CTS,
  38. PC10_PF_UART1_RTS,
  39. PC11_PF_UART1_TXD,
  40. PC12_PF_UART1_RXD,
  41. };
  42. static int uart1_mxc_init(struct platform_device *pdev)
  43. {
  44. return mxc_gpio_setup_multiple_pins(mxc_uart1_pins,
  45. ARRAY_SIZE(mxc_uart1_pins), "UART1");
  46. }
  47. static int uart1_mxc_exit(struct platform_device *pdev)
  48. {
  49. mxc_gpio_release_multiple_pins(mxc_uart1_pins,
  50. ARRAY_SIZE(mxc_uart1_pins));
  51. return 0;
  52. }
  53. static int mxc_uart2_pins[] = {
  54. PB28_PF_UART2_CTS,
  55. PB29_PF_UART2_RTS,
  56. PB30_PF_UART2_TXD,
  57. PB31_PF_UART2_RXD,
  58. };
  59. static int uart2_mxc_init(struct platform_device *pdev)
  60. {
  61. return mxc_gpio_setup_multiple_pins(mxc_uart2_pins,
  62. ARRAY_SIZE(mxc_uart2_pins), "UART2");
  63. }
  64. static int uart2_mxc_exit(struct platform_device *pdev)
  65. {
  66. mxc_gpio_release_multiple_pins(mxc_uart2_pins,
  67. ARRAY_SIZE(mxc_uart2_pins));
  68. return 0;
  69. }
  70. static struct imxuart_platform_data uart_pdata[] = {
  71. {
  72. .init = uart1_mxc_init,
  73. .exit = uart1_mxc_exit,
  74. .flags = IMXUART_HAVE_RTSCTS,
  75. }, {
  76. .init = uart2_mxc_init,
  77. .exit = uart2_mxc_exit,
  78. .flags = IMXUART_HAVE_RTSCTS,
  79. },
  80. };
  81. /*
  82. * Physmap flash
  83. */
  84. static struct physmap_flash_data mx1ads_flash_data = {
  85. .width = 4, /* bankwidth in bytes */
  86. };
  87. static struct resource flash_resource = {
  88. .start = IMX_CS0_PHYS,
  89. .end = IMX_CS0_PHYS + SZ_32M - 1,
  90. .flags = IORESOURCE_MEM,
  91. };
  92. static struct platform_device flash_device = {
  93. .name = "physmap-flash",
  94. .id = 0,
  95. .resource = &flash_resource,
  96. .num_resources = 1,
  97. };
  98. /*
  99. * I2C
  100. */
  101. #ifdef CONFIG_I2C_IMX
  102. static int i2c_pins[] = {
  103. PA15_PF_I2C_SDA,
  104. PA16_PF_I2C_SCL,
  105. };
  106. static int i2c_init(struct device *dev)
  107. {
  108. return mxc_gpio_setup_multiple_pins(i2c_pins,
  109. ARRAY_SIZE(i2c_pins), "I2C");
  110. }
  111. static void i2c_exit(struct device *dev)
  112. {
  113. mxc_gpio_release_multiple_pins(i2c_pins,
  114. ARRAY_SIZE(i2c_pins));
  115. }
  116. static struct pcf857x_platform_data pcf857x_data[] = {
  117. {
  118. .gpio_base = 4 * 32,
  119. }, {
  120. .gpio_base = 4 * 32 + 16,
  121. }
  122. };
  123. static struct imxi2c_platform_data mx1ads_i2c_data = {
  124. .bitrate = 100000,
  125. .init = i2c_init,
  126. .exit = i2c_exit,
  127. };
  128. static struct i2c_board_info mx1ads_i2c_devices[] = {
  129. {
  130. I2C_BOARD_INFO("pcf857x", 0x22),
  131. .type = "pcf8575",
  132. .platform_data = &pcf857x_data[0],
  133. }, {
  134. I2C_BOARD_INFO("pcf857x", 0x24),
  135. .type = "pcf8575",
  136. .platform_data = &pcf857x_data[1],
  137. },
  138. };
  139. #endif
  140. /*
  141. * Board init
  142. */
  143. static void __init mx1ads_init(void)
  144. {
  145. /* UART */
  146. mxc_register_device(&imx_uart1_device, &uart_pdata[0]);
  147. mxc_register_device(&imx_uart2_device, &uart_pdata[1]);
  148. /* Physmap flash */
  149. mxc_register_device(&flash_device, &mx1ads_flash_data);
  150. /* I2C */
  151. #ifdef CONFIG_I2C_IMX
  152. i2c_register_board_info(0, mx1ads_i2c_devices,
  153. ARRAY_SIZE(mx1ads_i2c_devices));
  154. mxc_register_device(&imx_i2c_device, &mx1ads_i2c_data);
  155. #endif
  156. }
  157. static void __init mx1ads_timer_init(void)
  158. {
  159. mx1_clocks_init(32000);
  160. }
  161. struct sys_timer mx1ads_timer = {
  162. .init = mx1ads_timer_init,
  163. };
  164. MACHINE_START(MX1ADS, "Freescale MX1ADS")
  165. /* Maintainer: Sascha Hauer, Pengutronix */
  166. .phys_io = IMX_IO_PHYS,
  167. .io_pg_offst = (IMX_IO_BASE >> 18) & 0xfffc,
  168. .boot_params = PHYS_OFFSET + 0x100,
  169. .map_io = mxc_map_io,
  170. .init_irq = mxc_init_irq,
  171. .timer = &mx1ads_timer,
  172. .init_machine = mx1ads_init,
  173. MACHINE_END
  174. MACHINE_START(MXLADS, "Freescale MXLADS")
  175. .phys_io = IMX_IO_PHYS,
  176. .io_pg_offst = (IMX_IO_BASE >> 18) & 0xfffc,
  177. .boot_params = PHYS_OFFSET + 0x100,
  178. .map_io = mxc_map_io,
  179. .init_irq = mxc_init_irq,
  180. .timer = &mx1ads_timer,
  181. .init_machine = mx1ads_init,
  182. MACHINE_END