devices.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * linux/arch/arm/plat-omap/devices.c
  3. *
  4. * Common platform device setup/initialization for OMAP1 and OMAP2
  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/gpio.h>
  12. #include <linux/module.h>
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/io.h>
  17. #include <linux/slab.h>
  18. #include <linux/memblock.h>
  19. #include <mach/hardware.h>
  20. #include <asm/mach-types.h>
  21. #include <asm/mach/map.h>
  22. #include <asm/memblock.h>
  23. #include <plat/tc.h>
  24. #include <plat/board.h>
  25. #include <plat/mmc.h>
  26. #include <plat/menelaus.h>
  27. #include <plat/omap44xx.h>
  28. #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
  29. defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
  30. #define OMAP_MMC_NR_RES 2
  31. /*
  32. * Register MMC devices. Called from mach-omap1 and mach-omap2 device init.
  33. */
  34. int __init omap_mmc_add(const char *name, int id, unsigned long base,
  35. unsigned long size, unsigned int irq,
  36. struct omap_mmc_platform_data *data)
  37. {
  38. struct platform_device *pdev;
  39. struct resource res[OMAP_MMC_NR_RES];
  40. int ret;
  41. pdev = platform_device_alloc(name, id);
  42. if (!pdev)
  43. return -ENOMEM;
  44. memset(res, 0, OMAP_MMC_NR_RES * sizeof(struct resource));
  45. res[0].start = base;
  46. res[0].end = base + size - 1;
  47. res[0].flags = IORESOURCE_MEM;
  48. res[1].start = res[1].end = irq;
  49. res[1].flags = IORESOURCE_IRQ;
  50. ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
  51. if (ret == 0)
  52. ret = platform_device_add_data(pdev, data, sizeof(*data));
  53. if (ret)
  54. goto fail;
  55. ret = platform_device_add(pdev);
  56. if (ret)
  57. goto fail;
  58. /* return device handle to board setup code */
  59. data->dev = &pdev->dev;
  60. return 0;
  61. fail:
  62. platform_device_put(pdev);
  63. return ret;
  64. }
  65. #endif
  66. /*-------------------------------------------------------------------------*/
  67. #if defined(CONFIG_HW_RANDOM_OMAP) || defined(CONFIG_HW_RANDOM_OMAP_MODULE)
  68. #ifdef CONFIG_ARCH_OMAP2
  69. #define OMAP_RNG_BASE 0x480A0000
  70. #else
  71. #define OMAP_RNG_BASE 0xfffe5000
  72. #endif
  73. static struct resource rng_resources[] = {
  74. {
  75. .start = OMAP_RNG_BASE,
  76. .end = OMAP_RNG_BASE + 0x4f,
  77. .flags = IORESOURCE_MEM,
  78. },
  79. };
  80. static struct platform_device omap_rng_device = {
  81. .name = "omap_rng",
  82. .id = -1,
  83. .num_resources = ARRAY_SIZE(rng_resources),
  84. .resource = rng_resources,
  85. };
  86. static void omap_init_rng(void)
  87. {
  88. (void) platform_device_register(&omap_rng_device);
  89. }
  90. #else
  91. static inline void omap_init_rng(void) {}
  92. #endif
  93. /*-------------------------------------------------------------------------*/
  94. /* Numbering for the SPI-capable controllers when used for SPI:
  95. * spi = 1
  96. * uwire = 2
  97. * mmc1..2 = 3..4
  98. * mcbsp1..3 = 5..7
  99. */
  100. #if defined(CONFIG_SPI_OMAP_UWIRE) || defined(CONFIG_SPI_OMAP_UWIRE_MODULE)
  101. #define OMAP_UWIRE_BASE 0xfffb3000
  102. static struct resource uwire_resources[] = {
  103. {
  104. .start = OMAP_UWIRE_BASE,
  105. .end = OMAP_UWIRE_BASE + 0x20,
  106. .flags = IORESOURCE_MEM,
  107. },
  108. };
  109. static struct platform_device omap_uwire_device = {
  110. .name = "omap_uwire",
  111. .id = -1,
  112. .num_resources = ARRAY_SIZE(uwire_resources),
  113. .resource = uwire_resources,
  114. };
  115. static void omap_init_uwire(void)
  116. {
  117. /* FIXME define and use a boot tag; not all boards will be hooking
  118. * up devices to the microwire controller, and multi-board configs
  119. * mean that CONFIG_SPI_OMAP_UWIRE may be configured anyway...
  120. */
  121. /* board-specific code must configure chipselects (only a few
  122. * are normally used) and SCLK/SDI/SDO (each has two choices).
  123. */
  124. (void) platform_device_register(&omap_uwire_device);
  125. }
  126. #else
  127. static inline void omap_init_uwire(void) {}
  128. #endif
  129. #if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
  130. static phys_addr_t omap_dsp_phys_mempool_base;
  131. void __init omap_dsp_reserve_sdram_memblock(void)
  132. {
  133. phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
  134. phys_addr_t paddr;
  135. if (!size)
  136. return;
  137. paddr = arm_memblock_steal(size, SZ_1M);
  138. if (!paddr) {
  139. pr_err("%s: failed to reserve %x bytes\n",
  140. __func__, size);
  141. return;
  142. }
  143. omap_dsp_phys_mempool_base = paddr;
  144. }
  145. phys_addr_t omap_dsp_get_mempool_base(void)
  146. {
  147. return omap_dsp_phys_mempool_base;
  148. }
  149. EXPORT_SYMBOL(omap_dsp_get_mempool_base);
  150. #endif
  151. /*
  152. * This gets called after board-specific INIT_MACHINE, and initializes most
  153. * on-chip peripherals accessible on this board (except for few like USB):
  154. *
  155. * (a) Does any "standard config" pin muxing needed. Board-specific
  156. * code will have muxed GPIO pins and done "nonstandard" setup;
  157. * that code could live in the boot loader.
  158. * (b) Populating board-specific platform_data with the data drivers
  159. * rely on to handle wiring variations.
  160. * (c) Creating platform devices as meaningful on this board and
  161. * with this kernel configuration.
  162. *
  163. * Claiming GPIOs, and setting their direction and initial values, is the
  164. * responsibility of the device drivers. So is responding to probe().
  165. *
  166. * Board-specific knowledge like creating devices or pin setup is to be
  167. * kept out of drivers as much as possible. In particular, pin setup
  168. * may be handled by the boot loader, and drivers should expect it will
  169. * normally have been done by the time they're probed.
  170. */
  171. static int __init omap_init_devices(void)
  172. {
  173. /* please keep these calls, and their implementations above,
  174. * in alphabetical order so they're easier to sort through.
  175. */
  176. omap_init_rng();
  177. omap_init_uwire();
  178. return 0;
  179. }
  180. arch_initcall(omap_init_devices);