devices.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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_STI)
  57. #define OMAP2_STI_BASE IO_ADDRESS(0x48068000)
  58. #define OMAP2_STI_CHANNEL_BASE 0x54000000
  59. #define OMAP2_STI_IRQ 4
  60. static struct resource sti_resources[] = {
  61. {
  62. .start = OMAP2_STI_BASE,
  63. .end = OMAP2_STI_BASE + 0x7ff,
  64. .flags = IORESOURCE_MEM,
  65. },
  66. {
  67. .start = OMAP2_STI_CHANNEL_BASE,
  68. .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
  69. .flags = IORESOURCE_MEM,
  70. },
  71. {
  72. .start = OMAP2_STI_IRQ,
  73. .flags = IORESOURCE_IRQ,
  74. }
  75. };
  76. static struct platform_device sti_device = {
  77. .name = "sti",
  78. .id = -1,
  79. .num_resources = ARRAY_SIZE(sti_resources),
  80. .resource = sti_resources,
  81. };
  82. static inline void omap_init_sti(void)
  83. {
  84. platform_device_register(&sti_device);
  85. }
  86. #else
  87. static inline void omap_init_sti(void) {}
  88. #endif
  89. #if defined(CONFIG_SPI_OMAP24XX)
  90. #include <asm/arch/mcspi.h>
  91. #define OMAP2_MCSPI1_BASE 0x48098000
  92. #define OMAP2_MCSPI2_BASE 0x4809a000
  93. /* FIXME: use resources instead */
  94. static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
  95. .base = io_p2v(OMAP2_MCSPI1_BASE),
  96. .num_cs = 4,
  97. };
  98. struct platform_device omap2_mcspi1 = {
  99. .name = "omap2_mcspi",
  100. .id = 1,
  101. .dev = {
  102. .platform_data = &omap2_mcspi1_config,
  103. },
  104. };
  105. static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
  106. .base = io_p2v(OMAP2_MCSPI2_BASE),
  107. .num_cs = 2,
  108. };
  109. struct platform_device omap2_mcspi2 = {
  110. .name = "omap2_mcspi",
  111. .id = 2,
  112. .dev = {
  113. .platform_data = &omap2_mcspi2_config,
  114. },
  115. };
  116. static void omap_init_mcspi(void)
  117. {
  118. platform_device_register(&omap2_mcspi1);
  119. platform_device_register(&omap2_mcspi2);
  120. }
  121. #else
  122. static inline void omap_init_mcspi(void) {}
  123. #endif
  124. /*-------------------------------------------------------------------------*/
  125. static int __init omap2_init_devices(void)
  126. {
  127. /* please keep these calls, and their implementations above,
  128. * in alphabetical order so they're easier to sort through.
  129. */
  130. omap_init_i2c();
  131. omap_init_mcspi();
  132. omap_init_sti();
  133. return 0;
  134. }
  135. arch_initcall(omap2_init_devices);