devices.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. * linux/arch/arm/mach-omap2/devices.c
  3. *
  4. * OMAP2 platform device setup/initialization
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/io.h>
  16. #include <mach/hardware.h>
  17. #include <asm/mach-types.h>
  18. #include <asm/mach/map.h>
  19. #include <mach/tc.h>
  20. #include <mach/board.h>
  21. #include <mach/mux.h>
  22. #include <mach/gpio.h>
  23. #if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
  24. #define OMAP2_I2C_BASE2 0x48072000
  25. #define OMAP2_I2C_INT2 57
  26. static struct resource i2c_resources2[] = {
  27. {
  28. .start = OMAP2_I2C_BASE2,
  29. .end = OMAP2_I2C_BASE2 + 0x3f,
  30. .flags = IORESOURCE_MEM,
  31. },
  32. {
  33. .start = OMAP2_I2C_INT2,
  34. .flags = IORESOURCE_IRQ,
  35. },
  36. };
  37. static struct platform_device omap_i2c_device2 = {
  38. .name = "i2c_omap",
  39. .id = 2,
  40. .num_resources = ARRAY_SIZE(i2c_resources2),
  41. .resource = i2c_resources2,
  42. };
  43. /* See also arch/arm/plat-omap/devices.c for first I2C on 24xx */
  44. static void omap_init_i2c(void)
  45. {
  46. /* REVISIT: Second I2C not in use on H4? */
  47. if (machine_is_omap_h4())
  48. return;
  49. if (!cpu_is_omap2430()) {
  50. omap_cfg_reg(J15_24XX_I2C2_SCL);
  51. omap_cfg_reg(H19_24XX_I2C2_SDA);
  52. }
  53. (void) platform_device_register(&omap_i2c_device2);
  54. }
  55. #else
  56. static void omap_init_i2c(void) {}
  57. #endif
  58. #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
  59. #define OMAP2_MBOX_BASE IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
  60. static struct resource mbox_resources[] = {
  61. {
  62. .start = OMAP2_MBOX_BASE,
  63. .end = OMAP2_MBOX_BASE + 0x11f,
  64. .flags = IORESOURCE_MEM,
  65. },
  66. {
  67. .start = INT_24XX_MAIL_U0_MPU,
  68. .flags = IORESOURCE_IRQ,
  69. },
  70. {
  71. .start = INT_24XX_MAIL_U3_MPU,
  72. .flags = IORESOURCE_IRQ,
  73. },
  74. };
  75. static struct platform_device mbox_device = {
  76. .name = "mailbox",
  77. .id = -1,
  78. .num_resources = ARRAY_SIZE(mbox_resources),
  79. .resource = mbox_resources,
  80. };
  81. static inline void omap_init_mbox(void)
  82. {
  83. platform_device_register(&mbox_device);
  84. }
  85. #else
  86. static inline void omap_init_mbox(void) { }
  87. #endif
  88. #if defined(CONFIG_OMAP_STI)
  89. #define OMAP2_STI_BASE IO_ADDRESS(0x48068000)
  90. #define OMAP2_STI_CHANNEL_BASE 0x54000000
  91. #define OMAP2_STI_IRQ 4
  92. static struct resource sti_resources[] = {
  93. {
  94. .start = OMAP2_STI_BASE,
  95. .end = OMAP2_STI_BASE + 0x7ff,
  96. .flags = IORESOURCE_MEM,
  97. },
  98. {
  99. .start = OMAP2_STI_CHANNEL_BASE,
  100. .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
  101. .flags = IORESOURCE_MEM,
  102. },
  103. {
  104. .start = OMAP2_STI_IRQ,
  105. .flags = IORESOURCE_IRQ,
  106. }
  107. };
  108. static struct platform_device sti_device = {
  109. .name = "sti",
  110. .id = -1,
  111. .num_resources = ARRAY_SIZE(sti_resources),
  112. .resource = sti_resources,
  113. };
  114. static inline void omap_init_sti(void)
  115. {
  116. platform_device_register(&sti_device);
  117. }
  118. #else
  119. static inline void omap_init_sti(void) {}
  120. #endif
  121. #if defined(CONFIG_SPI_OMAP24XX)
  122. #include <mach/mcspi.h>
  123. #define OMAP2_MCSPI1_BASE 0x48098000
  124. #define OMAP2_MCSPI2_BASE 0x4809a000
  125. static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
  126. .num_cs = 4,
  127. };
  128. static struct resource omap2_mcspi1_resources[] = {
  129. {
  130. .start = OMAP2_MCSPI1_BASE,
  131. .end = OMAP2_MCSPI1_BASE + 0xff,
  132. .flags = IORESOURCE_MEM,
  133. },
  134. };
  135. struct platform_device omap2_mcspi1 = {
  136. .name = "omap2_mcspi",
  137. .id = 1,
  138. .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
  139. .resource = omap2_mcspi1_resources,
  140. .dev = {
  141. .platform_data = &omap2_mcspi1_config,
  142. },
  143. };
  144. static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
  145. .num_cs = 2,
  146. };
  147. static struct resource omap2_mcspi2_resources[] = {
  148. {
  149. .start = OMAP2_MCSPI2_BASE,
  150. .end = OMAP2_MCSPI2_BASE + 0xff,
  151. .flags = IORESOURCE_MEM,
  152. },
  153. };
  154. struct platform_device omap2_mcspi2 = {
  155. .name = "omap2_mcspi",
  156. .id = 2,
  157. .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
  158. .resource = omap2_mcspi2_resources,
  159. .dev = {
  160. .platform_data = &omap2_mcspi2_config,
  161. },
  162. };
  163. static void omap_init_mcspi(void)
  164. {
  165. platform_device_register(&omap2_mcspi1);
  166. platform_device_register(&omap2_mcspi2);
  167. }
  168. #else
  169. static inline void omap_init_mcspi(void) {}
  170. #endif
  171. /*-------------------------------------------------------------------------*/
  172. static int __init omap2_init_devices(void)
  173. {
  174. /* please keep these calls, and their implementations above,
  175. * in alphabetical order so they're easier to sort through.
  176. */
  177. omap_init_i2c();
  178. omap_init_mbox();
  179. omap_init_mcspi();
  180. omap_init_sti();
  181. return 0;
  182. }
  183. arch_initcall(omap2_init_devices);