From: Hiroshi DOYU Date: Thu, 21 Sep 2006 14:41:44 +0000 (+0300) Subject: ARM: OMAP: DSPGW: Use device model X-Git-Tag: v2.6.18-omap1~46 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=48fb11a24aff6890886db8fb67955c5e51544157;p=linux-2.6-omap-h63xx.git ARM: OMAP: DSPGW: Use device model - use device model for IRQ detection. - use "dsp_device" as a pointer for "struct device" - some whitespaces are cleaned up. Signed-off-by: Hiroshi DOYU Signed-off-by: Juha Yrjola --- diff --git a/arch/arm/plat-omap/devices.c b/arch/arm/plat-omap/devices.c index dbc3f44e07a..e3e2bd50aa4 100644 --- a/arch/arm/plat-omap/devices.c +++ b/arch/arm/plat-omap/devices.c @@ -25,7 +25,51 @@ #include #include -#if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE) +#if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE) + +#include "../plat-omap/dsp/dsp_common.h" + +static struct resource omap_dsp_resources[] = { + { + .name = "dsp_mmu", + .start = -1, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct platform_device omap_dsp_device = { + .name = "dsp", + .id = -1, + .num_resources = ARRAY_SIZE(omap_dsp_resources), + .resource = omap_dsp_resources, +}; + + +static inline void omap_init_dsp(void) +{ + struct resource *res; + int irq; + + if (cpu_is_omap15xx()) + irq = INT_1510_DSP_MMU; + else if (cpu_is_omap16xx()) + irq = INT_1610_DSP_MMU; + else if (cpu_is_omap24xx()) + irq = INT_24XX_DSP_MMU; + + res = platform_get_resource_byname(&omap_dsp_device, + IORESOURCE_IRQ, "dsp_mmu"); + res->start = irq; + + platform_device_register(&omap_dsp_device); +} +#else +static inline void omap_init_dsp(void) { } +#endif + +/*-------------------------------------------------------------------------*/ + +#if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE) #define OMAP1_I2C_BASE 0xfffb3800 #define OMAP2_I2C_BASE1 0x48070000 @@ -48,8 +92,8 @@ static struct resource i2c_resources1[] = { /* DMA not used; works around erratum writing to non-empty i2c fifo */ static struct platform_device omap_i2c_device1 = { - .name = "i2c_omap", - .id = 1, + .name = "i2c_omap", + .id = 1, .num_resources = ARRAY_SIZE(i2c_resources1), .resource = i2c_resources1, }; @@ -432,6 +476,7 @@ static int __init omap_init_devices(void) /* please keep these calls, and their implementations above, * in alphabetical order so they're easier to sort through. */ + omap_init_dsp(); omap_init_i2c(); omap_init_kp(); omap_init_mmc(); @@ -442,4 +487,3 @@ static int __init omap_init_devices(void) return 0; } arch_initcall(omap_init_devices); - diff --git a/arch/arm/plat-omap/dsp/dsp.h b/arch/arm/plat-omap/dsp/dsp.h index 3e97f710837..ec24be72adf 100644 --- a/arch/arm/plat-omap/dsp/dsp.h +++ b/arch/arm/plat-omap/dsp/dsp.h @@ -241,4 +241,4 @@ extern char *subcmd_name(struct mbcmd *mb); extern void mblog_add(struct mbcmd *mb, arm_dsp_dir_t dir); -extern struct platform_device dsp_device; +extern struct device *dsp_device; diff --git a/arch/arm/plat-omap/dsp/dsp_common.c b/arch/arm/plat-omap/dsp/dsp_common.c index c65089d8ea5..e48a47dfd11 100644 --- a/arch/arm/plat-omap/dsp/dsp_common.c +++ b/arch/arm/plat-omap/dsp/dsp_common.c @@ -373,7 +373,7 @@ static void dsp_cpustat_update(void) __dsp_core_enable(); #endif cpustat.stat = CPUSTAT_RUN; - enable_irq(INT_DSP_MMU); + enable_irq(dsp_mmu_irq); } return; } @@ -381,7 +381,7 @@ static void dsp_cpustat_update(void) /* cpustat.req < CPUSTAT_RUN */ if (cpustat.stat == CPUSTAT_RUN) { - disable_irq(INT_DSP_MMU); + disable_irq(dsp_mmu_irq); #ifdef CONFIG_ARCH_OMAP1 clk_disable(api_ck_handle); #endif diff --git a/arch/arm/plat-omap/dsp/dsp_common.h b/arch/arm/plat-omap/dsp/dsp_common.h index 7da8c500bef..a1765042bdb 100644 --- a/arch/arm/plat-omap/dsp/dsp_common.h +++ b/arch/arm/plat-omap/dsp/dsp_common.h @@ -39,14 +39,6 @@ #define omap_set_bits_regl(val,mask,r) \ do { omap_writel((omap_readl(r) & ~(mask)) | (val), (r)); } while(0) -#if defined(CONFIG_ARCH_OMAP15XX) -#define INT_DSP_MMU INT_1510_DSP_MMU -#elif defined(CONFIG_ARCH_OMAP16XX) -#define INT_DSP_MMU INT_1610_DSP_MMU -#elif defined(CONFIG_ARCH_OMAP24XX) -#define INT_DSP_MMU INT_24XX_DSP_MMU -#endif - #define dspword_to_virt(dw) ((void *)(dspmem_base + ((dw) << 1))) #define dspbyte_to_virt(db) ((void *)(dspmem_base + (db))) #define virt_to_dspword(va) \ @@ -166,4 +158,6 @@ static inline void dsp_clk_autoidle(void) } #endif +extern int dsp_mmu_irq; + #endif /* DRIVER_DSP_COMMON_H */ diff --git a/arch/arm/plat-omap/dsp/dsp_core.c b/arch/arm/plat-omap/dsp/dsp_core.c index f0b303f9c66..76a9383a80d 100644 --- a/arch/arm/plat-omap/dsp/dsp_core.c +++ b/arch/arm/plat-omap/dsp/dsp_core.c @@ -40,6 +40,9 @@ MODULE_AUTHOR("Toshihiro Kobayashi "); MODULE_DESCRIPTION("OMAP DSP driver module"); MODULE_LICENSE("GPL"); +struct device *dsp_device; +int dsp_mmu_irq; + struct omap_mbox *mbox_dsp; static struct sync_seq *mbseq; static u16 mbseq_expect_tmp; @@ -390,13 +393,6 @@ extern void mblog_exit(void); extern int dsp_taskmod_init(void); extern void dsp_taskmod_exit(void); -/* - * device functions - */ -static void dsp_dev_release(struct device *dev) -{ -} - /* * driver functions */ @@ -404,7 +400,14 @@ static int __init dsp_drv_probe(struct platform_device *pdev) { int ret; - printk(KERN_INFO "OMAP DSP driver initialization\n"); + dev_info(&pdev->dev, "OMAP DSP driver initialization\n"); + + dsp_device = &pdev->dev; + + dsp_mmu_irq = platform_get_irq_byname(pdev, "dsp_mmu"); + if (dsp_mmu_irq < 0) + return -ENXIO; + #ifdef CONFIG_ARCH_OMAP2 clk_enable(dsp_fck_handle); clk_enable(dsp_ick_handle); @@ -481,23 +484,6 @@ static int dsp_drv_resume(struct platform_device *pdev) #define dsp_drv_resume NULL #endif /* CONFIG_PM */ -static struct resource dsp_resources[] = { - { - .start = INT_DSP_MMU, - .flags = IORESOURCE_IRQ, - }, -}; - -struct platform_device dsp_device = { - .name = "dsp", - .id = -1, - .dev = { - .release = dsp_dev_release, - }, - .num_resources = ARRAY_SIZE(&dsp_resources), - .resource = dsp_resources, -}; - static struct platform_driver dsp_driver = { .probe = dsp_drv_probe, .remove = dsp_drv_remove, @@ -510,38 +496,12 @@ static struct platform_driver dsp_driver = { static int __init omap_dsp_mod_init(void) { - int ret; - - mbox_dsp = mbox_get("DSP"); - if (IS_ERR(mbox_dsp)) { - printk(KERN_ERR "failed to get mailbox handler for DSP.\n"); - goto fail1; - } - - ret = platform_device_register(&dsp_device); - if (ret) { - printk(KERN_ERR "failed to register the DSP device: %d\n", ret); - goto fail1; - } - - ret = platform_driver_register(&dsp_driver); - if (ret) { - printk(KERN_ERR "failed to register the DSP driver: %d\n", ret); - goto fail2; - } - - return 0; - -fail2: - platform_device_unregister(&dsp_device); -fail1: - return -ENODEV; + return platform_driver_register(&dsp_driver); } static void __exit omap_dsp_mod_exit(void) { platform_driver_unregister(&dsp_driver); - platform_device_unregister(&dsp_device); } module_init(omap_dsp_mod_init); diff --git a/arch/arm/plat-omap/dsp/dsp_ctl.c b/arch/arm/plat-omap/dsp/dsp_ctl.c index d4dfc48287e..ba7cc2b8b89 100644 --- a/arch/arm/plat-omap/dsp/dsp_ctl.c +++ b/arch/arm/plat-omap/dsp/dsp_ctl.c @@ -273,7 +273,7 @@ static int dsp_cfg(void) goto out; /* create runtime sysfs entries */ - device_create_file(&dsp_device.dev, &dev_attr_loadinfo); + device_create_file(dsp_device, &dev_attr_loadinfo); out: dsp_mem_disable((void *)dspmem_base); @@ -290,7 +290,7 @@ static int dsp_uncfg(void) /* FIXME: lock task module */ /* remove runtime sysfs entries */ - device_remove_file(&dsp_device.dev, &dev_attr_loadinfo); + device_remove_file(dsp_device, &dev_attr_loadinfo); dsp_mbox_stop(); dsp_twch_stop(); @@ -1038,14 +1038,14 @@ out: void __init dsp_ctl_init(void) { - device_create_file(&dsp_device.dev, &dev_attr_ifver); - device_create_file(&dsp_device.dev, &dev_attr_cpustat); - device_create_file(&dsp_device.dev, &dev_attr_icrmask); + device_create_file(dsp_device, &dev_attr_ifver); + device_create_file(dsp_device, &dev_attr_cpustat); + device_create_file(dsp_device, &dev_attr_icrmask); } void dsp_ctl_exit(void) { - device_remove_file(&dsp_device.dev, &dev_attr_ifver); - device_remove_file(&dsp_device.dev, &dev_attr_cpustat); - device_remove_file(&dsp_device.dev, &dev_attr_icrmask); + device_remove_file(dsp_device, &dev_attr_ifver); + device_remove_file(dsp_device, &dev_attr_cpustat); + device_remove_file(dsp_device, &dev_attr_icrmask); } diff --git a/arch/arm/plat-omap/dsp/dsp_mem.c b/arch/arm/plat-omap/dsp/dsp_mem.c index 4b21c386385..88aebdb635e 100644 --- a/arch/arm/plat-omap/dsp/dsp_mem.c +++ b/arch/arm/plat-omap/dsp/dsp_mem.c @@ -2313,7 +2313,7 @@ static void do_mmu_int(void) printk(KERN_DEBUG "fault address = %#08x\n", dsp_fault_adr); } - enable_irq(INT_DSP_MMU); + enable_irq(dsp_mmu_irq); return; } @@ -2408,7 +2408,7 @@ static void do_mmu_int(void) dsp_mmu_enable(); #endif - enable_irq(INT_DSP_MMU); + enable_irq(dsp_mmu_irq); } static DECLARE_WORK(mmu_int_work, (void (*)(void *))do_mmu_int, NULL); @@ -2420,7 +2420,7 @@ static DECLARE_WORK(mmu_int_work, (void (*)(void *))do_mmu_int, NULL); static irqreturn_t dsp_mmu_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - disable_irq(INT_DSP_MMU); + disable_irq(dsp_mmu_irq); schedule_work(&mmu_int_work); return IRQ_HANDLED; } @@ -2490,8 +2490,8 @@ int __init dsp_mem_init(void) /* * DSP MMU interrupt setup */ - ret = request_irq(INT_DSP_MMU, dsp_mmu_interrupt, SA_INTERRUPT, "dsp", - &devid_mmu); + ret = request_irq(dsp_mmu_irq, dsp_mmu_interrupt, SA_INTERRUPT, + "dsp_mmu", &devid_mmu); if (ret) { printk(KERN_ERR "failed to register DSP MMU interrupt: %d\n", ret); @@ -2499,11 +2499,11 @@ int __init dsp_mem_init(void) } /* MMU interrupt is not enabled until DSP runs */ - disable_irq(INT_DSP_MMU); + disable_irq(dsp_mmu_irq); - device_create_file(&dsp_device.dev, &dev_attr_mmu); - device_create_file(&dsp_device.dev, &dev_attr_exmap); - device_create_file(&dsp_device.dev, &dev_attr_mempool); + device_create_file(dsp_device, &dev_attr_mmu); + device_create_file(dsp_device, &dev_attr_exmap); + device_create_file(dsp_device, &dev_attr_mempool); return 0; @@ -2519,10 +2519,10 @@ fail: void dsp_mem_exit(void) { - free_irq(INT_DSP_MMU, &devid_mmu); + free_irq(dsp_mmu_irq, &devid_mmu); /* recover disable_depth */ - enable_irq(INT_DSP_MMU); + enable_irq(dsp_mmu_irq); #ifdef CONFIG_ARCH_OMAP1 dsp_reset_idle_boot_base(); @@ -2535,7 +2535,7 @@ void dsp_mem_exit(void) dspvect_page = NULL; } - device_remove_file(&dsp_device.dev, &dev_attr_mmu); - device_remove_file(&dsp_device.dev, &dev_attr_exmap); - device_remove_file(&dsp_device.dev, &dev_attr_mempool); + device_remove_file(dsp_device, &dev_attr_mmu); + device_remove_file(dsp_device, &dev_attr_exmap); + device_remove_file(dsp_device, &dev_attr_mempool); } diff --git a/arch/arm/plat-omap/dsp/error.c b/arch/arm/plat-omap/dsp/error.c index 88886eed892..4720e93ce16 100644 --- a/arch/arm/plat-omap/dsp/error.c +++ b/arch/arm/plat-omap/dsp/error.c @@ -105,13 +105,13 @@ struct file_operations dsp_err_fops = { /* DSP MMU */ static void dsp_err_mmu_set(unsigned long arg) { - disable_irq(INT_DSP_MMU); + disable_irq(dsp_mmu_irq); mmu_fadr = (u32)arg; } static void dsp_err_mmu_clr(void) { - enable_irq(INT_DSP_MMU); + enable_irq(dsp_mmu_irq); } /* WDT */ diff --git a/arch/arm/plat-omap/dsp/ipbuf.c b/arch/arm/plat-omap/dsp/ipbuf.c index 605c18ca1f1..cdffc2f4bb4 100644 --- a/arch/arm/plat-omap/dsp/ipbuf.c +++ b/arch/arm/plat-omap/dsp/ipbuf.c @@ -42,7 +42,7 @@ void ipbuf_stop(void) { int i; - device_remove_file(&dsp_device.dev, &dev_attr_ipbuf); + device_remove_file(dsp_device, &dev_attr_ipbuf); spin_lock(&ipb_free.lock); RESET_IPBLINK(&ipb_free); @@ -116,7 +116,7 @@ int ipbuf_config(u16 ln, u16 lsz, void *base) " %d words * %d lines at 0x%p.\n", ipbcfg.lsz, ipbcfg.ln, ipbcfg.base); - device_create_file(&dsp_device.dev, &dev_attr_ipbuf); + device_create_file(dsp_device, &dev_attr_ipbuf); return ret; diff --git a/arch/arm/plat-omap/dsp/mblog.c b/arch/arm/plat-omap/dsp/mblog.c index 95c4d7a7e95..aa68d6b0230 100644 --- a/arch/arm/plat-omap/dsp/mblog.c +++ b/arch/arm/plat-omap/dsp/mblog.c @@ -259,10 +259,10 @@ static struct device_attribute dev_attr_mblog = __ATTR_RO(mblog); void __init mblog_init(void) { - device_create_file(&dsp_device.dev, &dev_attr_mblog); + device_create_file(dsp_device, &dev_attr_mblog); } void mblog_exit(void) { - device_remove_file(&dsp_device.dev, &dev_attr_mblog); + device_remove_file(dsp_device, &dev_attr_mblog); } diff --git a/arch/arm/plat-omap/dsp/task.c b/arch/arm/plat-omap/dsp/task.c index 118f7a52e55..78b8064950d 100644 --- a/arch/arm/plat-omap/dsp/task.c +++ b/arch/arm/plat-omap/dsp/task.c @@ -1811,7 +1811,7 @@ static int taskdev_init(struct taskdev *dev, char *name, unsigned char minor) mutex_init(&dev->usecount_lock); memcpy(&dev->fops, &dsp_task_fops, sizeof(struct file_operations)); - dev->dev.parent = &dsp_device.dev; + dev->dev.parent = dsp_device; dev->dev.bus = &dsptask_bus; sprintf(dev->dev.bus_id, "dsptask%d", minor); dev->dev.release = dsptask_dev_release;