devices.c 4.2 KB

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