mx1ads.c 4.3 KB

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