devices.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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/config.h>
  12. #include <linux/module.h>
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include <asm/hardware.h>
  17. #include <asm/io.h>
  18. #include <asm/mach-types.h>
  19. #include <asm/mach/map.h>
  20. #include <asm/arch/tc.h>
  21. #include <asm/arch/board.h>
  22. #include <asm/arch/mux.h>
  23. #include <asm/arch/gpio.h>
  24. #if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
  25. #define OMAP2_I2C_BASE2 0x48072000
  26. #define OMAP2_I2C_INT2 57
  27. static struct resource i2c_resources2[] = {
  28. {
  29. .start = OMAP2_I2C_BASE2,
  30. .end = OMAP2_I2C_BASE2 + 0x3f,
  31. .flags = IORESOURCE_MEM,
  32. },
  33. {
  34. .start = OMAP2_I2C_INT2,
  35. .flags = IORESOURCE_IRQ,
  36. },
  37. };
  38. static struct platform_device omap_i2c_device2 = {
  39. .name = "i2c_omap",
  40. .id = 2,
  41. .num_resources = ARRAY_SIZE(i2c_resources2),
  42. .resource = i2c_resources2,
  43. };
  44. /* See also arch/arm/plat-omap/devices.c for first I2C on 24xx */
  45. static void omap_init_i2c(void)
  46. {
  47. /* REVISIT: Second I2C not in use on H4? */
  48. if (machine_is_omap_h4())
  49. return;
  50. omap_cfg_reg(J15_24XX_I2C2_SCL);
  51. omap_cfg_reg(H19_24XX_I2C2_SDA);
  52. (void) platform_device_register(&omap_i2c_device2);
  53. }
  54. #else
  55. static void omap_init_i2c(void) {}
  56. #endif
  57. #if defined(CONFIG_OMAP_STI)
  58. #define OMAP2_STI_BASE IO_ADDRESS(0x48068000)
  59. #define OMAP2_STI_CHANNEL_BASE 0x54000000
  60. #define OMAP2_STI_IRQ 4
  61. static struct resource sti_resources[] = {
  62. {
  63. .start = OMAP2_STI_BASE,
  64. .end = OMAP2_STI_BASE + 0x7ff,
  65. .flags = IORESOURCE_MEM,
  66. },
  67. {
  68. .start = OMAP2_STI_CHANNEL_BASE,
  69. .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
  70. .flags = IORESOURCE_MEM,
  71. },
  72. {
  73. .start = OMAP2_STI_IRQ,
  74. .flags = IORESOURCE_IRQ,
  75. }
  76. };
  77. static struct platform_device sti_device = {
  78. .name = "sti",
  79. .id = -1,
  80. .num_resources = ARRAY_SIZE(sti_resources),
  81. .resource = sti_resources,
  82. };
  83. static inline void omap_init_sti(void)
  84. {
  85. platform_device_register(&sti_device);
  86. }
  87. #else
  88. static inline void omap_init_sti(void) {}
  89. #endif
  90. #if defined(CONFIG_SPI_OMAP24XX)
  91. #include <asm/arch/mcspi.h>
  92. #define OMAP2_MCSPI1_BASE 0x48098000
  93. #define OMAP2_MCSPI2_BASE 0x4809a000
  94. /* FIXME: use resources instead */
  95. static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
  96. .base = io_p2v(OMAP2_MCSPI1_BASE),
  97. .num_cs = 4,
  98. };
  99. struct platform_device omap2_mcspi1 = {
  100. .name = "omap2_mcspi",
  101. .id = 1,
  102. .dev = {
  103. .platform_data = &omap2_mcspi1_config,
  104. },
  105. };
  106. static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
  107. .base = io_p2v(OMAP2_MCSPI2_BASE),
  108. .num_cs = 2,
  109. };
  110. struct platform_device omap2_mcspi2 = {
  111. .name = "omap2_mcspi",
  112. .id = 2,
  113. .dev = {
  114. .platform_data = &omap2_mcspi2_config,
  115. },
  116. };
  117. static void omap_init_mcspi(void)
  118. {
  119. platform_device_register(&omap2_mcspi1);
  120. platform_device_register(&omap2_mcspi2);
  121. }
  122. #else
  123. static inline void omap_init_mcspi(void) {}
  124. #endif
  125. /*-------------------------------------------------------------------------*/
  126. static int __init omap2_init_devices(void)
  127. {
  128. /* please keep these calls, and their implementations above,
  129. * in alphabetical order so they're easier to sort through.
  130. */
  131. omap_init_i2c();
  132. omap_init_mcspi();
  133. omap_init_sti();
  134. return 0;
  135. }
  136. arch_initcall(omap2_init_devices);