mx1ads.c 4.2 KB

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