devices.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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/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. extern void omap_nop_release(struct device *dev);
  25. /*-------------------------------------------------------------------------*/
  26. #if defined(CONFIG_OMAP1610_IR) || defined(CONFIG_OMAP161O_IR_MODULE)
  27. static u64 irda_dmamask = 0xffffffff;
  28. static struct platform_device omap1610ir_device = {
  29. .name = "omap1610-ir",
  30. .id = -1,
  31. .dev = {
  32. .release = omap_nop_release,
  33. .dma_mask = &irda_dmamask,
  34. },
  35. };
  36. static void omap_init_irda(void)
  37. {
  38. /* FIXME define and use a boot tag, members something like:
  39. * u8 uart; // uart1, or uart3
  40. * ... but driver only handles uart3 for now
  41. * s16 fir_sel; // gpio for SIR vs FIR
  42. * ... may prefer a callback for SIR/MIR/FIR mode select;
  43. * while h2 uses a GPIO, H3 uses a gpio expander
  44. */
  45. if (machine_is_omap_h2()
  46. || machine_is_omap_h3())
  47. (void) platform_device_register(&omap1610ir_device);
  48. }
  49. #else
  50. static inline void omap_init_irda(void) {}
  51. #endif
  52. /*-------------------------------------------------------------------------*/
  53. #if defined(CONFIG_OMAP_RTC) || defined(CONFIG_OMAP_RTC)
  54. #define OMAP_RTC_BASE 0xfffb4800
  55. static struct resource rtc_resources[] = {
  56. {
  57. .start = OMAP_RTC_BASE,
  58. .end = OMAP_RTC_BASE + 0x5f,
  59. .flags = IORESOURCE_MEM,
  60. },
  61. {
  62. .start = INT_RTC_TIMER,
  63. .flags = IORESOURCE_IRQ,
  64. },
  65. {
  66. .start = INT_RTC_ALARM,
  67. .flags = IORESOURCE_IRQ,
  68. },
  69. };
  70. static struct platform_device omap_rtc_device = {
  71. .name = "omap_rtc",
  72. .id = -1,
  73. .dev = {
  74. .release = omap_nop_release,
  75. },
  76. .num_resources = ARRAY_SIZE(rtc_resources),
  77. .resource = rtc_resources,
  78. };
  79. static void omap_init_rtc(void)
  80. {
  81. (void) platform_device_register(&omap_rtc_device);
  82. }
  83. #else
  84. static inline void omap_init_rtc(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. .dev = {
  109. .release = omap_nop_release,
  110. },
  111. .num_resources = ARRAY_SIZE(sti_resources),
  112. .resource = sti_resources,
  113. };
  114. static inline void omap_init_sti(void)
  115. {
  116. platform_device_register(&sti_device);
  117. }
  118. #else
  119. static inline void omap_init_sti(void) {}
  120. #endif
  121. /*-------------------------------------------------------------------------*/
  122. /*
  123. * This gets called after board-specific INIT_MACHINE, and initializes most
  124. * on-chip peripherals accessible on this board (except for few like USB):
  125. *
  126. * (a) Does any "standard config" pin muxing needed. Board-specific
  127. * code will have muxed GPIO pins and done "nonstandard" setup;
  128. * that code could live in the boot loader.
  129. * (b) Populating board-specific platform_data with the data drivers
  130. * rely on to handle wiring variations.
  131. * (c) Creating platform devices as meaningful on this board and
  132. * with this kernel configuration.
  133. *
  134. * Claiming GPIOs, and setting their direction and initial values, is the
  135. * responsibility of the device drivers. So is responding to probe().
  136. *
  137. * Board-specific knowlege like creating devices or pin setup is to be
  138. * kept out of drivers as much as possible. In particular, pin setup
  139. * may be handled by the boot loader, and drivers should expect it will
  140. * normally have been done by the time they're probed.
  141. */
  142. static int __init omap1_init_devices(void)
  143. {
  144. /* please keep these calls, and their implementations above,
  145. * in alphabetical order so they're easier to sort through.
  146. */
  147. omap_init_irda();
  148. omap_init_rtc();
  149. omap_init_sti();
  150. return 0;
  151. }
  152. arch_initcall(omap1_init_devices);