devices.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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 <asm/hardware.h>
  16. #include <asm/io.h>
  17. #include <asm/mach-types.h>
  18. #include <asm/mach/map.h>
  19. #include <asm/arch/tc.h>
  20. #include <asm/arch/board.h>
  21. #include <asm/arch/mux.h>
  22. #include <asm/arch/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. omap_cfg_reg(J15_24XX_I2C2_SCL);
  50. omap_cfg_reg(H19_24XX_I2C2_SDA);
  51. (void) platform_device_register(&omap_i2c_device2);
  52. }
  53. #else
  54. static void omap_init_i2c(void) {}
  55. #endif
  56. #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
  57. #define OMAP2_MBOX_BASE IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
  58. static struct resource mbox_resources[] = {
  59. {
  60. .start = OMAP2_MBOX_BASE,
  61. .end = OMAP2_MBOX_BASE + 0x11f,
  62. .flags = IORESOURCE_MEM,
  63. },
  64. {
  65. .start = INT_24XX_MAIL_U0_MPU,
  66. .flags = IORESOURCE_IRQ,
  67. },
  68. {
  69. .start = INT_24XX_MAIL_U3_MPU,
  70. .flags = IORESOURCE_IRQ,
  71. },
  72. };
  73. static struct platform_device mbox_device = {
  74. .name = "mailbox",
  75. .id = -1,
  76. .num_resources = ARRAY_SIZE(mbox_resources),
  77. .resource = mbox_resources,
  78. };
  79. static inline void omap_init_mbox(void)
  80. {
  81. platform_device_register(&mbox_device);
  82. }
  83. #else
  84. static inline void omap_init_mbox(void) { }
  85. #endif
  86. #if defined(CONFIG_OMAP_STI)
  87. #define OMAP2_STI_BASE IO_ADDRESS(0x48068000)
  88. #define OMAP2_STI_CHANNEL_BASE 0x54000000
  89. #define OMAP2_STI_IRQ 4
  90. static struct resource sti_resources[] = {
  91. {
  92. .start = OMAP2_STI_BASE,
  93. .end = OMAP2_STI_BASE + 0x7ff,
  94. .flags = IORESOURCE_MEM,
  95. },
  96. {
  97. .start = OMAP2_STI_CHANNEL_BASE,
  98. .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
  99. .flags = IORESOURCE_MEM,
  100. },
  101. {
  102. .start = OMAP2_STI_IRQ,
  103. .flags = IORESOURCE_IRQ,
  104. }
  105. };
  106. static struct platform_device sti_device = {
  107. .name = "sti",
  108. .id = -1,
  109. .num_resources = ARRAY_SIZE(sti_resources),
  110. .resource = sti_resources,
  111. };
  112. static inline void omap_init_sti(void)
  113. {
  114. platform_device_register(&sti_device);
  115. }
  116. #else
  117. static inline void omap_init_sti(void) {}
  118. #endif
  119. #if defined(CONFIG_SPI_OMAP24XX)
  120. #include <asm/arch/mcspi.h>
  121. #define OMAP2_MCSPI1_BASE 0x48098000
  122. #define OMAP2_MCSPI2_BASE 0x4809a000
  123. static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
  124. .num_cs = 4,
  125. };
  126. static struct resource omap2_mcspi1_resources[] = {
  127. {
  128. .start = OMAP2_MCSPI1_BASE,
  129. .end = OMAP2_MCSPI1_BASE + 0xff,
  130. .flags = IORESOURCE_MEM,
  131. },
  132. };
  133. struct platform_device omap2_mcspi1 = {
  134. .name = "omap2_mcspi",
  135. .id = 1,
  136. .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
  137. .resource = omap2_mcspi1_resources,
  138. .dev = {
  139. .platform_data = &omap2_mcspi1_config,
  140. },
  141. };
  142. static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
  143. .num_cs = 2,
  144. };
  145. static struct resource omap2_mcspi2_resources[] = {
  146. {
  147. .start = OMAP2_MCSPI2_BASE,
  148. .end = OMAP2_MCSPI2_BASE + 0xff,
  149. .flags = IORESOURCE_MEM,
  150. },
  151. };
  152. struct platform_device omap2_mcspi2 = {
  153. .name = "omap2_mcspi",
  154. .id = 2,
  155. .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
  156. .resource = omap2_mcspi2_resources,
  157. .dev = {
  158. .platform_data = &omap2_mcspi2_config,
  159. },
  160. };
  161. static void omap_init_mcspi(void)
  162. {
  163. platform_device_register(&omap2_mcspi1);
  164. platform_device_register(&omap2_mcspi2);
  165. }
  166. #else
  167. static inline void omap_init_mcspi(void) {}
  168. #endif
  169. /*-------------------------------------------------------------------------*/
  170. static int __init omap2_init_devices(void)
  171. {
  172. /* please keep these calls, and their implementations above,
  173. * in alphabetical order so they're easier to sort through.
  174. */
  175. omap_init_i2c();
  176. omap_init_mbox();
  177. omap_init_mcspi();
  178. omap_init_sti();
  179. return 0;
  180. }
  181. arch_initcall(omap2_init_devices);