devices.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. /*-------------------------------------------------------------------------*/
  87. /*
  88. * This gets called after board-specific INIT_MACHINE, and initializes most
  89. * on-chip peripherals accessible on this board (except for few like USB):
  90. *
  91. * (a) Does any "standard config" pin muxing needed. Board-specific
  92. * code will have muxed GPIO pins and done "nonstandard" setup;
  93. * that code could live in the boot loader.
  94. * (b) Populating board-specific platform_data with the data drivers
  95. * rely on to handle wiring variations.
  96. * (c) Creating platform devices as meaningful on this board and
  97. * with this kernel configuration.
  98. *
  99. * Claiming GPIOs, and setting their direction and initial values, is the
  100. * responsibility of the device drivers. So is responding to probe().
  101. *
  102. * Board-specific knowlege like creating devices or pin setup is to be
  103. * kept out of drivers as much as possible. In particular, pin setup
  104. * may be handled by the boot loader, and drivers should expect it will
  105. * normally have been done by the time they're probed.
  106. */
  107. static int __init omap1_init_devices(void)
  108. {
  109. /* please keep these calls, and their implementations above,
  110. * in alphabetical order so they're easier to sort through.
  111. */
  112. omap_init_irda();
  113. omap_init_rtc();
  114. return 0;
  115. }
  116. arch_initcall(omap1_init_devices);