devices.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * linux/arch/arm/mach-omap1/devices.c
  3. *
  4. * OMAP1 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/map.h>
  18. #include <mach/tc.h>
  19. #include <mach/board.h>
  20. #include <mach/mux.h>
  21. #include <mach/gpio.h>
  22. /*-------------------------------------------------------------------------*/
  23. #if defined(CONFIG_RTC_DRV_OMAP) || defined(CONFIG_RTC_DRV_OMAP_MODULE)
  24. #define OMAP_RTC_BASE 0xfffb4800
  25. static struct resource rtc_resources[] = {
  26. {
  27. .start = OMAP_RTC_BASE,
  28. .end = OMAP_RTC_BASE + 0x5f,
  29. .flags = IORESOURCE_MEM,
  30. },
  31. {
  32. .start = INT_RTC_TIMER,
  33. .flags = IORESOURCE_IRQ,
  34. },
  35. {
  36. .start = INT_RTC_ALARM,
  37. .flags = IORESOURCE_IRQ,
  38. },
  39. };
  40. static struct platform_device omap_rtc_device = {
  41. .name = "omap_rtc",
  42. .id = -1,
  43. .num_resources = ARRAY_SIZE(rtc_resources),
  44. .resource = rtc_resources,
  45. };
  46. static void omap_init_rtc(void)
  47. {
  48. (void) platform_device_register(&omap_rtc_device);
  49. }
  50. #else
  51. static inline void omap_init_rtc(void) {}
  52. #endif
  53. #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
  54. #if defined(CONFIG_ARCH_OMAP15XX)
  55. # define OMAP1_MBOX_SIZE 0x23
  56. # define INT_DSP_MAILBOX1 INT_1510_DSP_MAILBOX1
  57. #elif defined(CONFIG_ARCH_OMAP16XX)
  58. # define OMAP1_MBOX_SIZE 0x2f
  59. # define INT_DSP_MAILBOX1 INT_1610_DSP_MAILBOX1
  60. #endif
  61. #define OMAP1_MBOX_BASE IO_ADDRESS(OMAP16XX_MAILBOX_BASE)
  62. static struct resource mbox_resources[] = {
  63. {
  64. .start = OMAP1_MBOX_BASE,
  65. .end = OMAP1_MBOX_BASE + OMAP1_MBOX_SIZE,
  66. .flags = IORESOURCE_MEM,
  67. },
  68. {
  69. .start = INT_DSP_MAILBOX1,
  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 OMAP1_STI_BASE IO_ADDRESS(0xfffea000)
  88. #define OMAP1_STI_CHANNEL_BASE (OMAP1_STI_BASE + 0x400)
  89. static struct resource sti_resources[] = {
  90. {
  91. .start = OMAP1_STI_BASE,
  92. .end = OMAP1_STI_BASE + SZ_1K - 1,
  93. .flags = IORESOURCE_MEM,
  94. },
  95. {
  96. .start = OMAP1_STI_CHANNEL_BASE,
  97. .end = OMAP1_STI_CHANNEL_BASE + SZ_1K - 1,
  98. .flags = IORESOURCE_MEM,
  99. },
  100. {
  101. .start = INT_1610_STI,
  102. .flags = IORESOURCE_IRQ,
  103. }
  104. };
  105. static struct platform_device sti_device = {
  106. .name = "sti",
  107. .id = -1,
  108. .num_resources = ARRAY_SIZE(sti_resources),
  109. .resource = sti_resources,
  110. };
  111. static inline void omap_init_sti(void)
  112. {
  113. platform_device_register(&sti_device);
  114. }
  115. #else
  116. static inline void omap_init_sti(void) {}
  117. #endif
  118. /*-------------------------------------------------------------------------*/
  119. /*
  120. * This gets called after board-specific INIT_MACHINE, and initializes most
  121. * on-chip peripherals accessible on this board (except for few like USB):
  122. *
  123. * (a) Does any "standard config" pin muxing needed. Board-specific
  124. * code will have muxed GPIO pins and done "nonstandard" setup;
  125. * that code could live in the boot loader.
  126. * (b) Populating board-specific platform_data with the data drivers
  127. * rely on to handle wiring variations.
  128. * (c) Creating platform devices as meaningful on this board and
  129. * with this kernel configuration.
  130. *
  131. * Claiming GPIOs, and setting their direction and initial values, is the
  132. * responsibility of the device drivers. So is responding to probe().
  133. *
  134. * Board-specific knowlege like creating devices or pin setup is to be
  135. * kept out of drivers as much as possible. In particular, pin setup
  136. * may be handled by the boot loader, and drivers should expect it will
  137. * normally have been done by the time they're probed.
  138. */
  139. static int __init omap1_init_devices(void)
  140. {
  141. /* please keep these calls, and their implementations above,
  142. * in alphabetical order so they're easier to sort through.
  143. */
  144. omap_init_mbox();
  145. omap_init_rtc();
  146. omap_init_sti();
  147. return 0;
  148. }
  149. arch_initcall(omap1_init_devices);