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