devices.c 6.3 KB

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