dsp.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * TI's OMAP DSP platform device registration
  3. *
  4. * Copyright (C) 2005-2006 Texas Instruments, Inc.
  5. * Copyright (C) 2009 Nokia Corporation
  6. *
  7. * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. /*
  14. * XXX The function pointers to the PRM/CM functions are incorrect and
  15. * should be removed. No device driver should be changing PRM/CM bits
  16. * directly; that's a layering violation -- those bits are the responsibility
  17. * of the OMAP PM core code.
  18. */
  19. #include <linux/module.h>
  20. #include <linux/platform_device.h>
  21. #include <asm/memblock.h>
  22. #include "control.h"
  23. #include "cm2xxx_3xxx.h"
  24. #include "prm2xxx_3xxx.h"
  25. #ifdef CONFIG_BRIDGE_DVFS
  26. #include <plat/omap-pm.h>
  27. #endif
  28. #include <plat/dsp.h>
  29. static struct platform_device *omap_dsp_pdev;
  30. static struct omap_dsp_platform_data omap_dsp_pdata __initdata = {
  31. #ifdef CONFIG_BRIDGE_DVFS
  32. .dsp_set_min_opp = omap_pm_dsp_set_min_opp,
  33. .dsp_get_opp = omap_pm_dsp_get_opp,
  34. .cpu_set_freq = omap_pm_cpu_set_freq,
  35. .cpu_get_freq = omap_pm_cpu_get_freq,
  36. #endif
  37. .dsp_prm_read = omap2_prm_read_mod_reg,
  38. .dsp_prm_write = omap2_prm_write_mod_reg,
  39. .dsp_prm_rmw_bits = omap2_prm_rmw_mod_reg_bits,
  40. .dsp_cm_read = omap2_cm_read_mod_reg,
  41. .dsp_cm_write = omap2_cm_write_mod_reg,
  42. .dsp_cm_rmw_bits = omap2_cm_rmw_mod_reg_bits,
  43. .set_bootaddr = omap_ctrl_write_dsp_boot_addr,
  44. .set_bootmode = omap_ctrl_write_dsp_boot_mode,
  45. };
  46. static phys_addr_t omap_dsp_phys_mempool_base;
  47. void __init omap_dsp_reserve_sdram_memblock(void)
  48. {
  49. phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
  50. phys_addr_t paddr;
  51. if (!size)
  52. return;
  53. paddr = arm_memblock_steal(size, SZ_1M);
  54. if (!paddr) {
  55. pr_err("%s: failed to reserve %llx bytes\n",
  56. __func__, (unsigned long long)size);
  57. return;
  58. }
  59. omap_dsp_phys_mempool_base = paddr;
  60. }
  61. static phys_addr_t omap_dsp_get_mempool_base(void)
  62. {
  63. return omap_dsp_phys_mempool_base;
  64. }
  65. static int __init omap_dsp_init(void)
  66. {
  67. struct platform_device *pdev;
  68. int err = -ENOMEM;
  69. struct omap_dsp_platform_data *pdata = &omap_dsp_pdata;
  70. pdata->phys_mempool_base = omap_dsp_get_mempool_base();
  71. if (pdata->phys_mempool_base) {
  72. pdata->phys_mempool_size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
  73. pr_info("%s: %llx bytes @ %llx\n", __func__,
  74. (unsigned long long)pdata->phys_mempool_size,
  75. (unsigned long long)pdata->phys_mempool_base);
  76. }
  77. pdev = platform_device_alloc("omap-dsp", -1);
  78. if (!pdev)
  79. goto err_out;
  80. err = platform_device_add_data(pdev, pdata, sizeof(*pdata));
  81. if (err)
  82. goto err_out;
  83. err = platform_device_add(pdev);
  84. if (err)
  85. goto err_out;
  86. omap_dsp_pdev = pdev;
  87. return 0;
  88. err_out:
  89. platform_device_put(pdev);
  90. return err;
  91. }
  92. module_init(omap_dsp_init);
  93. static void __exit omap_dsp_exit(void)
  94. {
  95. platform_device_unregister(omap_dsp_pdev);
  96. }
  97. module_exit(omap_dsp_exit);
  98. MODULE_AUTHOR("Hiroshi DOYU");
  99. MODULE_DESCRIPTION("TI's OMAP DSP platform device registration");
  100. MODULE_LICENSE("GPL");