devices.c 4.2 KB

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