devices.c 4.3 KB

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