mx1ads.c 4.2 KB

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