21 #include <linux/types.h>
24 #include <linux/module.h>
25 #include <linux/device.h>
47 #ifdef CONFIG_TIDSPBRIDGE_DVFS
48 #include <mach-omap2/omap3-opp.h>
52 #define DSPBRIDGE_VERSION "0.3"
61 static struct cdev bridge_cdev;
63 static struct class *bridge_class;
65 static u32 driver_context;
66 static s32 driver_major;
67 static char *base_img;
69 static s32 shm_size = 0x500000;
70 static int tc_wordswapon;
71 #ifdef CONFIG_TIDSPBRIDGE_RECOVERY
72 #define REC_TIMEOUT 5000
82 struct omap34_xx_bridge_suspend_data {
87 static struct omap34_xx_bridge_suspend_data bridge_suspend_data;
89 static int omap34_xxbridge_suspend_lockout(
struct omap34_xx_bridge_suspend_data
124 static int bridge_open(
struct inode *
ip,
struct file *filp)
134 #ifdef CONFIG_TIDSPBRIDGE_RECOVERY
136 if (filp->
f_flags & O_NONBLOCK ||
169 #ifdef CONFIG_TIDSPBRIDGE_RECOVERY
185 static int bridge_release(
struct inode *ip,
struct file *filp)
206 #ifdef CONFIG_TIDSPBRIDGE_RECOVERY
214 static long bridge_ioctl(
struct file *filp,
unsigned int code,
221 #ifdef CONFIG_TIDSPBRIDGE_RECOVERY
228 status = omap34_xxbridge_suspend_lockout(&bridge_suspend_data, filp);
248 dev_dbg(bridge,
"%s: IOCTL Failed, code: 0x%x "
249 "status 0x%x\n", __func__, code, status);
267 dev_dbg(bridge,
"%s: vm filp %p start %lx end %lx page_prot %ulx "
268 "flags %lx\n", __func__, filp,
283 .release = bridge_release,
284 .unlocked_ioctl = bridge_ioctl,
290 static u32 time_out = 1000;
291 #ifdef CONFIG_TIDSPBRIDGE_DVFS
292 s32 dsp_max_opps = VDD1_OPP5;
297 #ifdef CONFIG_TIDSPBRIDGE_DVFS
298 const struct omap_opp vdd1_rate_table_bridge[] = {
301 {S125M, VDD1_OPP1, 0},
303 {S250M, VDD1_OPP2, 0},
305 {S500M, VDD1_OPP3, 0},
307 {S550M, VDD1_OPP4, 0},
309 {
S600M, VDD1_OPP5, 0},
319 {0, 90000, 0, 86000},
321 {0, 180000, 80000, 170000},
323 {0, 360000, 160000, 340000},
325 {0, 396000, 325000, 376000},
327 {0, 430000, 355000, 430000},
330 #ifdef CONFIG_TIDSPBRIDGE_RECOVERY
334 struct cfg_devnode *dev_node;
339 pr_info(
"%s:%d handle(s) still opened\n",
345 pr_err(
"DSP could not be restarted\n");
350 void bridge_recover_schedule(
void)
354 queue_work(bridge_rec_queue, &bridge_recovery_work);
357 #ifdef CONFIG_TIDSPBRIDGE_DVFS
359 unsigned long val,
void *
ptr)
362 omap_dspbridge_dev->
dev.platform_data;
387 u32 phys_membase, phys_memsize;
390 #ifdef CONFIG_TIDSPBRIDGE_RECOVERY
392 INIT_WORK(&bridge_recovery_work, bridge_recover);
398 bridge_suspend_data.suspended = 0;
401 #ifdef CONFIG_TIDSPBRIDGE_DVFS
402 for (
i = 0;
i < 6;
i++)
403 pdata->
mpu_speed[
i] = vdd1_rate_table_bridge[
i].rate;
408 pr_err(
"%s: clk_notifier_register failed for iva2_ck\n",
437 pr_err(
"%s: shm size must be at least 64 KB\n", __func__);
440 dev_dbg(bridge,
"%s: requested shm_size = 0x%x\n", __func__,
shm_size);
444 if (phys_membase > 0 && phys_memsize > 0)
448 dev_dbg(bridge,
"%s: TC Word Swap is enabled\n", __func__);
452 pr_err(
"DSP Bridge driver initialization failed\n");
465 #ifdef CONFIG_TIDSPBRIDGE_DVFS
478 #ifdef CONFIG_TIDSPBRIDGE_DVFS
482 omap_dspbridge_dev = pdev;
485 bridge = &omap_dspbridge_dev->
dev;
488 err = omap3_bridge_startup(pdev);
495 pr_err(
"%s: Can't get major %d\n", __func__, driver_major);
502 err =
cdev_add(&bridge_cdev, dev, 1);
504 pr_err(
"%s: Failed to add bridge device\n", __func__);
510 if (IS_ERR(bridge_class)) {
511 pr_err(
"%s: Error creating bridge class\n", __func__);
515 driver_major =
MAJOR(dev);
518 pr_info(
"DSP Bridge driver loaded\n");
539 pr_err(
"%s: Failed to retrieve the object handle\n", __func__);
543 #ifdef CONFIG_TIDSPBRIDGE_DVFS
546 pr_err(
"%s: cpufreq_unregister_notifier failed for iva2_ck\n",
550 if (driver_context) {
564 devno =
MKDEV(driver_major, 0);
586 bridge_suspend_data.suspended = 1;
598 bridge_suspend_data.suspended = 0;
599 wake_up(&bridge_suspend_data.suspend_wq);
608 .probe = omap34_xx_bridge_probe,
611 .suspend = bridge_suspend,
612 .resume = bridge_resume,