Felipe Contreras | 9017388 | 2010-10-04 19:09:14 +0300 | [diff] [blame] | 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 | |
Paul Walmsley | 59fb659 | 2010-12-21 15:30:55 -0700 | [diff] [blame] | 14 | /* |
| 15 | * XXX The function pointers to the PRM/CM functions are incorrect and |
| 16 | * should be removed. No device driver should be changing PRM/CM bits |
| 17 | * directly; that's a layering violation -- those bits are the responsibility |
| 18 | * of the OMAP PM core code. |
| 19 | */ |
| 20 | |
Tony Lindgren | a1bcc1d | 2011-11-07 12:27:10 -0800 | [diff] [blame] | 21 | #include <linux/module.h> |
Felipe Contreras | 9017388 | 2010-10-04 19:09:14 +0300 | [diff] [blame] | 22 | #include <linux/platform_device.h> |
Paul Walmsley | 59fb659 | 2010-12-21 15:30:55 -0700 | [diff] [blame] | 23 | #include "cm2xxx_3xxx.h" |
| 24 | #include "prm2xxx_3xxx.h" |
Felipe Contreras | 9017388 | 2010-10-04 19:09:14 +0300 | [diff] [blame] | 25 | #ifdef CONFIG_BRIDGE_DVFS |
| 26 | #include <plat/omap-pm.h> |
| 27 | #endif |
| 28 | |
| 29 | #include <plat/dsp.h> |
| 30 | |
Felipe Contreras | 9017388 | 2010-10-04 19:09:14 +0300 | [diff] [blame] | 31 | static struct platform_device *omap_dsp_pdev; |
| 32 | |
| 33 | static struct omap_dsp_platform_data omap_dsp_pdata __initdata = { |
| 34 | #ifdef CONFIG_BRIDGE_DVFS |
| 35 | .dsp_set_min_opp = omap_pm_dsp_set_min_opp, |
| 36 | .dsp_get_opp = omap_pm_dsp_get_opp, |
| 37 | .cpu_set_freq = omap_pm_cpu_set_freq, |
| 38 | .cpu_get_freq = omap_pm_cpu_get_freq, |
| 39 | #endif |
Paul Walmsley | c4d7e58 | 2010-12-21 21:05:14 -0700 | [diff] [blame] | 40 | .dsp_prm_read = omap2_prm_read_mod_reg, |
| 41 | .dsp_prm_write = omap2_prm_write_mod_reg, |
| 42 | .dsp_prm_rmw_bits = omap2_prm_rmw_mod_reg_bits, |
| 43 | .dsp_cm_read = omap2_cm_read_mod_reg, |
| 44 | .dsp_cm_write = omap2_cm_write_mod_reg, |
| 45 | .dsp_cm_rmw_bits = omap2_cm_rmw_mod_reg_bits, |
Felipe Contreras | 9017388 | 2010-10-04 19:09:14 +0300 | [diff] [blame] | 46 | }; |
| 47 | |
Tony Lindgren | 7f28427 | 2012-05-09 09:59:26 -0700 | [diff] [blame] | 48 | static phys_addr_t omap_dsp_phys_mempool_base; |
| 49 | |
| 50 | void __init omap_dsp_reserve_sdram_memblock(void) |
| 51 | { |
| 52 | phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE; |
| 53 | phys_addr_t paddr; |
| 54 | |
| 55 | if (!size) |
| 56 | return; |
| 57 | |
| 58 | paddr = arm_memblock_steal(size, SZ_1M); |
| 59 | if (!paddr) { |
| 60 | pr_err("%s: failed to reserve %llx bytes\n", |
| 61 | __func__, (unsigned long long)size); |
| 62 | return; |
| 63 | } |
| 64 | |
| 65 | omap_dsp_phys_mempool_base = paddr; |
| 66 | } |
| 67 | |
| 68 | static phys_addr_t omap_dsp_get_mempool_base(void) |
| 69 | { |
| 70 | return omap_dsp_phys_mempool_base; |
| 71 | } |
| 72 | |
Felipe Contreras | 9017388 | 2010-10-04 19:09:14 +0300 | [diff] [blame] | 73 | static int __init omap_dsp_init(void) |
| 74 | { |
| 75 | struct platform_device *pdev; |
| 76 | int err = -ENOMEM; |
| 77 | struct omap_dsp_platform_data *pdata = &omap_dsp_pdata; |
| 78 | |
| 79 | pdata->phys_mempool_base = omap_dsp_get_mempool_base(); |
| 80 | |
| 81 | if (pdata->phys_mempool_base) { |
| 82 | pdata->phys_mempool_size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE; |
Felipe Contreras | 28ee793 | 2012-05-08 16:31:12 -0700 | [diff] [blame] | 83 | pr_info("%s: %llx bytes @ %llx\n", __func__, |
| 84 | (unsigned long long)pdata->phys_mempool_size, |
| 85 | (unsigned long long)pdata->phys_mempool_base); |
Felipe Contreras | 9017388 | 2010-10-04 19:09:14 +0300 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | pdev = platform_device_alloc("omap-dsp", -1); |
| 89 | if (!pdev) |
| 90 | goto err_out; |
| 91 | |
| 92 | err = platform_device_add_data(pdev, pdata, sizeof(*pdata)); |
| 93 | if (err) |
| 94 | goto err_out; |
| 95 | |
| 96 | err = platform_device_add(pdev); |
| 97 | if (err) |
| 98 | goto err_out; |
| 99 | |
| 100 | omap_dsp_pdev = pdev; |
| 101 | return 0; |
| 102 | |
| 103 | err_out: |
| 104 | platform_device_put(pdev); |
| 105 | return err; |
| 106 | } |
| 107 | module_init(omap_dsp_init); |
| 108 | |
| 109 | static void __exit omap_dsp_exit(void) |
| 110 | { |
| 111 | platform_device_unregister(omap_dsp_pdev); |
| 112 | } |
| 113 | module_exit(omap_dsp_exit); |
| 114 | |
| 115 | MODULE_AUTHOR("Hiroshi DOYU"); |
| 116 | MODULE_DESCRIPTION("TI's OMAP DSP platform device registration"); |
| 117 | MODULE_LICENSE("GPL"); |