]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ARM: OMAP: DSPGW: Use device model
authorHiroshi DOYU <Hiroshi.DOYU@nokia.com>
Thu, 21 Sep 2006 14:41:44 +0000 (17:41 +0300)
committerJuha Yrjola <juha.yrjola@solidboot.com>
Thu, 21 Sep 2006 15:45:57 +0000 (18:45 +0300)
- 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 <Hiroshi.DOYU@nokia.com>
Signed-off-by: Juha Yrjola <juha.yrjola@solidboot.com>
arch/arm/plat-omap/devices.c
arch/arm/plat-omap/dsp/dsp.h
arch/arm/plat-omap/dsp/dsp_common.c
arch/arm/plat-omap/dsp/dsp_common.h
arch/arm/plat-omap/dsp/dsp_core.c
arch/arm/plat-omap/dsp/dsp_ctl.c
arch/arm/plat-omap/dsp/dsp_mem.c
arch/arm/plat-omap/dsp/error.c
arch/arm/plat-omap/dsp/ipbuf.c
arch/arm/plat-omap/dsp/mblog.c
arch/arm/plat-omap/dsp/task.c

index dbc3f44e07a603f8b891c2901e1223a846dc34f1..e3e2bd50aa48539d8106425de2145428d5c8f487 100644 (file)
 #include <asm/arch/gpio.h>
 #include <asm/arch/menelaus.h>
 
-#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);
-
index 3e97f710837ffb6b81a23a6a3dcfa82779c63d03..ec24be72adf92956285f23a79a66d4200fea227a 100644 (file)
@@ -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;
index c65089d8ea57a310bb1e688e6bb4921ec065b516..e48a47dfd11051cb943e766850fc010e1fcee9ff 100644 (file)
@@ -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
index 7da8c500bef98688a2892a04872a2c378b4ccd30..a1765042bdb46c88d8799bb219eea8eb04f12902 100644 (file)
 #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 */
index f0b303f9c660e6497653693bd601de0e6a5fc42c..76a9383a80d289799d5cb3d0ac616bd57e9ba31d 100644 (file)
@@ -40,6 +40,9 @@ MODULE_AUTHOR("Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com>");
 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);
index d4dfc48287e0810f72d23e115c40fd0f41d6f6bf..ba7cc2b8b893e09cafd6c8eebb7a93db8575ceab 100644 (file)
@@ -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);
 }
index 4b21c3863857d3ee336ac24bd91b995c7941f0af..88aebdb635ed4b059b45cc80cdcf1aad1d5916cd 100644 (file)
@@ -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);
 }
index 88886eed89267690b0e4e0e8ca5939ac699c7277..4720e93ce16e04b33923547fd40a17e470b3a0ae 100644 (file)
@@ -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 */
index 605c18ca1f1b7b75cab367a6c3b19f36fbc3312c..cdffc2f4bb49392fa8ba4f106a203823a0f0a170 100644 (file)
@@ -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;
 
index 95c4d7a7e95d5168218561c0d2c01401a23eb775..aa68d6b0230ec7aaac17abab0cb988385afdec4d 100644 (file)
@@ -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);
 }
index 118f7a52e55022e7a0d262de04c1afb264e9a79b..78b8064950d3069d0ab4c36019af60eb6dc8d666 100644 (file)
@@ -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;