blob: 98388109f22afd91363428c7410dfb5687c79dc5 [file] [log] [blame]
Felipe Contreras90173882010-10-04 19:09:14 +03001/*
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 Walmsley59fb6592010-12-21 15:30:55 -070014/*
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 Lindgrena1bcc1d2011-11-07 12:27:10 -080021#include <linux/module.h>
Felipe Contreras90173882010-10-04 19:09:14 +030022#include <linux/platform_device.h>
Tony Lindgrenfebe9e02012-06-06 01:42:20 -070023
24#include <asm/memblock.h>
25
Omar Ramirez Luna3d3635c2012-06-18 16:18:10 -060026#include "control.h"
Paul Walmsley59fb6592010-12-21 15:30:55 -070027#include "cm2xxx_3xxx.h"
28#include "prm2xxx_3xxx.h"
Felipe Contreras90173882010-10-04 19:09:14 +030029#ifdef CONFIG_BRIDGE_DVFS
30#include <plat/omap-pm.h>
31#endif
32
Arnd Bergmann22037472012-08-24 15:21:06 +020033#include <linux/platform_data/dsp-omap.h>
Felipe Contreras90173882010-10-04 19:09:14 +030034
Felipe Contreras90173882010-10-04 19:09:14 +030035static struct platform_device *omap_dsp_pdev;
36
37static struct omap_dsp_platform_data omap_dsp_pdata __initdata = {
38#ifdef CONFIG_BRIDGE_DVFS
39 .dsp_set_min_opp = omap_pm_dsp_set_min_opp,
40 .dsp_get_opp = omap_pm_dsp_get_opp,
41 .cpu_set_freq = omap_pm_cpu_set_freq,
42 .cpu_get_freq = omap_pm_cpu_get_freq,
43#endif
Paul Walmsleyc4d7e582010-12-21 21:05:14 -070044 .dsp_prm_read = omap2_prm_read_mod_reg,
45 .dsp_prm_write = omap2_prm_write_mod_reg,
46 .dsp_prm_rmw_bits = omap2_prm_rmw_mod_reg_bits,
47 .dsp_cm_read = omap2_cm_read_mod_reg,
48 .dsp_cm_write = omap2_cm_write_mod_reg,
49 .dsp_cm_rmw_bits = omap2_cm_rmw_mod_reg_bits,
Omar Ramirez Luna3d3635c2012-06-18 16:18:10 -060050
51 .set_bootaddr = omap_ctrl_write_dsp_boot_addr,
52 .set_bootmode = omap_ctrl_write_dsp_boot_mode,
Felipe Contreras90173882010-10-04 19:09:14 +030053};
54
Tony Lindgren7f284272012-05-09 09:59:26 -070055static phys_addr_t omap_dsp_phys_mempool_base;
56
57void __init omap_dsp_reserve_sdram_memblock(void)
58{
59 phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
60 phys_addr_t paddr;
61
62 if (!size)
63 return;
64
65 paddr = arm_memblock_steal(size, SZ_1M);
66 if (!paddr) {
67 pr_err("%s: failed to reserve %llx bytes\n",
68 __func__, (unsigned long long)size);
69 return;
70 }
71
72 omap_dsp_phys_mempool_base = paddr;
73}
74
75static phys_addr_t omap_dsp_get_mempool_base(void)
76{
77 return omap_dsp_phys_mempool_base;
78}
79
Felipe Contreras90173882010-10-04 19:09:14 +030080static int __init omap_dsp_init(void)
81{
82 struct platform_device *pdev;
83 int err = -ENOMEM;
84 struct omap_dsp_platform_data *pdata = &omap_dsp_pdata;
85
86 pdata->phys_mempool_base = omap_dsp_get_mempool_base();
87
88 if (pdata->phys_mempool_base) {
89 pdata->phys_mempool_size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
Felipe Contreras28ee7932012-05-08 16:31:12 -070090 pr_info("%s: %llx bytes @ %llx\n", __func__,
91 (unsigned long long)pdata->phys_mempool_size,
92 (unsigned long long)pdata->phys_mempool_base);
Felipe Contreras90173882010-10-04 19:09:14 +030093 }
94
95 pdev = platform_device_alloc("omap-dsp", -1);
96 if (!pdev)
97 goto err_out;
98
99 err = platform_device_add_data(pdev, pdata, sizeof(*pdata));
100 if (err)
101 goto err_out;
102
103 err = platform_device_add(pdev);
104 if (err)
105 goto err_out;
106
107 omap_dsp_pdev = pdev;
108 return 0;
109
110err_out:
111 platform_device_put(pdev);
112 return err;
113}
114module_init(omap_dsp_init);
115
116static void __exit omap_dsp_exit(void)
117{
118 platform_device_unregister(omap_dsp_pdev);
119}
120module_exit(omap_dsp_exit);
121
122MODULE_AUTHOR("Hiroshi DOYU");
123MODULE_DESCRIPTION("TI's OMAP DSP platform device registration");
124MODULE_LICENSE("GPL");