From patchwork Thu Apr 8 15:01:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: thomas.koeller@baslerweb.com X-Patchwork-Id: 91289 Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o38F5EB2002650 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 8 Apr 2010 15:05:50 GMT Received: from dlep35.itg.ti.com ([157.170.170.118]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id o38F3V28004657 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 8 Apr 2010 10:03:31 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id o38F3SVU018413; Thu, 8 Apr 2010 10:03:28 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 5F7208066A; Thu, 8 Apr 2010 10:03:12 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id 4CCFF80628 for ; Thu, 8 Apr 2010 10:02:16 -0500 (CDT) Received: from white.ext.ti.com (localhost [127.0.0.1]) by dflp51.itg.ti.com (8.13.7/8.13.7) with ESMTP id o38F2GiA020186 for ; Thu, 8 Apr 2010 10:02:16 -0500 (CDT) Received: from psmtp.com (na3sys009amx165.postini.com [74.125.149.91]) by white.ext.ti.com (8.13.7/8.13.7) with SMTP id o38F2Eoj027367 for ; Thu, 8 Apr 2010 10:02:14 -0500 Received: from source ([80.156.24.166]) by na3sys009amx165.postini.com ([74.125.148.10]) with SMTP; Thu, 08 Apr 2010 10:02:14 CDT Received: from unknown (HELO AHR075S.basler.corp) ([172.16.20.75]) by mail01-out.baslerweb.com with ESMTP; 08 Apr 2010 17:02:13 +0200 Received: from localhost.localdomain ([172.16.13.131]) by AHR075S.basler.corp with Microsoft SMTPSVC(6.0.3790.3959); Thu, 8 Apr 2010 17:02:08 +0200 From: thomas.koeller@baslerweb.com To: davinci-linux-open-source@linux.davincidsp.com Subject: [PATCH 4/4] DM365: Add platform resource management Date: Thu, 8 Apr 2010 17:01:58 +0200 Message-Id: <1270738918-30050-6-git-send-email-thomas.koeller@baslerweb.com> X-Mailer: git-send-email 1.7.0.3 In-Reply-To: <1270738918-30050-1-git-send-email-thomas.koeller@baslerweb.com> References: <1270738918-30050-1-git-send-email-thomas.koeller@baslerweb.com> X-OriginalArrivalTime: 08 Apr 2010 15:02:08.0308 (UTC) FILETIME=[757C1740:01CAD72C] X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:90.94803/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.5000) s cv gt3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 08 Apr 2010 15:05:50 +0000 (UTC) diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c index 0813dce..33be53e 100644 --- a/arch/arm/mach-davinci/dm365.c +++ b/arch/arm/mach-davinci/dm365.c @@ -617,6 +617,74 @@ EVT_CFG(DM365, EVT3_ASP_RX, 1, 1, 0, false) #endif }; +/* root resource for configuration register space */ +struct resource resource_cfg_root = { + .name = "DM365 peripherals", + .start = 0x01c00000, + .end = 0x01ffffff, + .flags = IORESOURCE_MEM +}; +EXPORT_SYMBOL(resource_cfg_root); + +/* root resource for DMA channels */ +struct resource resource_dma_root = { + .name = "DM365 DMA", + .start = 0, + .end = 63, + .flags = IORESOURCE_DMA +}; +EXPORT_SYMBOL(resource_dma_root); + +/* root resource for DMA event queues */ +struct resource resource_evq_root = { + .name = "DM365 EVQ", + .start = 0, + .end = 3, + .flags = IORESOURCE_DMA +}; +EXPORT_SYMBOL(resource_evq_root); + +/* root resource for IRQ numbers */ +struct resource resource_irq_root = { + .name = "DM365 IRQ", + .start = 0, + .end = 63, + .flags = IORESOURCE_IRQ +}; +EXPORT_SYMBOL(resource_irq_root); + +/* Allocate resources for platform device */ +static int alloc_platform_resources(const struct platform_device *dev) +{ + int n; + + for (n = 0; n < dev->num_resources; ++n) { + int res; + struct resource *rsrc = &dev->resource[n]; + + res = request_resource(rsrc->parent, rsrc); + if (likely(!res)) + continue; + + /* bail out */ + pr_warning("Resource allocation failed for '%s'\n", rsrc->name); + while (--n >= 0) { + struct resource *parent; + + /* preserve the parent pointer */ + rsrc = &dev->resource[n]; + parent = rsrc->parent; + release_resource(rsrc); + rsrc->parent = parent; + } + + return res; + } + + return 0; +} + + static u64 dm365_spi_dma_mask = DMA_BIT_MASK(32); enum dm365_spi_resource_index { @@ -627,100 +695,158 @@ enum dm365_spi_resource_index { spirsrc_evqdma }; +static const char + spi0_name[] = "SPI0", + spi1_name[] = "SPI1", + spi2_name[] = "SPI2", + spi3_name[] = "SPI3", + spi4_name[] = "SPI4"; -static struct resource dm365_spi_resources[spirsrc_evqdma + 1][5] = { - { + +static struct resource +dm365_spi_resources[spirsrc_evqdma + 1][5] = { + [0] = { [spirsrc_iomem] = { + .name = spi0_name, + .parent = &resource_cfg_root, .start = 0x01c66000, .end = 0x01c667ff, .flags = IORESOURCE_MEM, }, [spirsrc_irq] = { + .name = spi0_name, + .parent = &resource_irq_root, .flags = IORESOURCE_IRQ, }, [spirsrc_rxdma] = { + .name = spi0_name, + .parent = &resource_dma_root, .flags = IORESOURCE_DMA | IORESOURCE_DMA_RX_CHAN, }, [spirsrc_txdma] = { + .name = spi0_name, + .parent = &resource_dma_root, .flags = IORESOURCE_DMA | IORESOURCE_DMA_TX_CHAN, }, [spirsrc_evqdma] = { + .name = spi0_name, + .parent = &resource_evq_root, .flags = IORESOURCE_DMA | IORESOURCE_DMA_EVENT_Q, } }, - { + [1] = { [spirsrc_iomem] = { + .name = spi1_name, + .parent = &resource_cfg_root, .start = 0x01c66800, .end = 0x01c66fff, .flags = IORESOURCE_MEM, }, [spirsrc_irq] = { + .name = spi1_name, + .parent = &resource_irq_root, .flags = IORESOURCE_IRQ, }, [spirsrc_rxdma] = { + .name = spi1_name, + .parent = &resource_dma_root, .flags = IORESOURCE_DMA | IORESOURCE_DMA_RX_CHAN, }, [spirsrc_txdma] = { + .name = spi1_name, + .parent = &resource_dma_root, .flags = IORESOURCE_DMA | IORESOURCE_DMA_TX_CHAN, }, [spirsrc_evqdma] = { + .name = spi1_name, + .parent = &resource_evq_root, .flags = IORESOURCE_DMA | IORESOURCE_DMA_EVENT_Q, } }, - { + [2] = { [spirsrc_iomem] = { + .name = spi2_name, + .parent = &resource_cfg_root, .start = 0x01c67800, .end = 0x01c67fff, .flags = IORESOURCE_MEM, }, [spirsrc_irq] = { + .name = spi2_name, + .parent = &resource_irq_root, .flags = IORESOURCE_IRQ, }, [spirsrc_rxdma] = { + .name = spi2_name, + .parent = &resource_dma_root, .flags = IORESOURCE_DMA | IORESOURCE_DMA_RX_CHAN, }, [spirsrc_txdma] = { + .name = spi2_name, + .parent = &resource_dma_root, .flags = IORESOURCE_DMA | IORESOURCE_DMA_TX_CHAN, }, [spirsrc_evqdma] = { + .name = spi2_name, + .parent = &resource_evq_root, .flags = IORESOURCE_DMA | IORESOURCE_DMA_EVENT_Q, } }, - { + [3] = { [spirsrc_iomem] = { + .name = spi3_name, + .parent = &resource_cfg_root, .start = 0x01c68000, .end = 0x01c687ff, .flags = IORESOURCE_MEM, }, [spirsrc_irq] = { + .name = spi3_name, + .parent = &resource_irq_root, .flags = IORESOURCE_IRQ, }, [spirsrc_rxdma] = { + .name = spi3_name, + .parent = &resource_dma_root, .flags = IORESOURCE_DMA | IORESOURCE_DMA_RX_CHAN, }, [spirsrc_txdma] = { + .name = spi3_name, + .parent = &resource_dma_root, .flags = IORESOURCE_DMA | IORESOURCE_DMA_TX_CHAN, }, [spirsrc_evqdma] = { + .name = spi3_name, + .parent = &resource_evq_root, .flags = IORESOURCE_DMA | IORESOURCE_DMA_EVENT_Q, } }, - { + [4] = { [spirsrc_iomem] = { + .name = spi4_name, + .parent = &resource_cfg_root, .start = 0x01c23000, .end = 0x01c237ff, .flags = IORESOURCE_MEM, }, [spirsrc_irq] = { + .name = spi4_name, + .parent = &resource_irq_root, .flags = IORESOURCE_IRQ, }, [spirsrc_rxdma] = { + .name = spi4_name, + .parent = &resource_dma_root, .flags = IORESOURCE_DMA | IORESOURCE_DMA_RX_CHAN, }, [spirsrc_txdma] = { + .name = spi4_name, + .parent = &resource_dma_root, .flags = IORESOURCE_DMA | IORESOURCE_DMA_TX_CHAN, }, [spirsrc_evqdma] = { + .name = spi4_name, + .parent = &resource_evq_root, .flags = IORESOURCE_DMA | IORESOURCE_DMA_EVENT_Q, } } @@ -856,6 +982,11 @@ void __init dm365_init_spi(struct dm365_spi_unit_desc *unit, pdev->resource[spirsrc_evqdma].start = pdev->resource[spirsrc_evqdma].end = unit->dma_evtq; + if (alloc_platform_resources(pdev)) { + pr_err("Resource allocation failed for SPI%u\n", hwunit); + return; + }; + pr_debug("Creating SPI%u: irq = %u, dma_rx = %u, dma_tx = %u, " "dma_evq = %u", hwunit, unit->irq, unit->dma_rx_chan, unit->dma_tx_chan, @@ -874,6 +1005,8 @@ void __init dm365_init_spi(struct dm365_spi_unit_desc *unit, static u64 dm365_ipipeif_dma_mask = DMA_BIT_MASK(32); static struct resource dm365_ipipeif_resources[] = { { + .name = "IPIPEIF", + .parent = &resource_cfg_root, .start = 0x01C71200, .end = 0x01C71200 + 0x60, .flags = IORESOURCE_MEM, @@ -901,11 +1034,13 @@ static struct davinci_osd_platform_data dm365_osd_pdata = { static struct resource dm365_osd_resources[] = { { + .parent = &resource_irq_root, .start = IRQ_VENCINT, .end = IRQ_VENCINT, .flags = IORESOURCE_IRQ, }, { + .parent = &resource_cfg_root, .start = DM365_OSD_REG_BASE, .end = DM365_OSD_REG_BASE + OSD_REG_SIZE, .flags = IORESOURCE_MEM, @@ -931,9 +1066,12 @@ static struct davinci_venc_platform_data dm365_venc_pdata = { .soc = DM36x, }; +static const char venc_name[] = "davinci_venc"; static struct resource dm365_venc_resources[] = { { + .name = venc_name, + .parent = &resource_cfg_root, .start = DM365_VENC_REG_BASE, .end = DM365_VENC_REG_BASE + 0x180, .flags = IORESOURCE_MEM, @@ -941,7 +1079,7 @@ static struct resource dm365_venc_resources[] = { }; static struct platform_device dm365_venc_dev = { - .name = "davinci_venc", + .name = venc_name, .id = -1, .num_resources = ARRAY_SIZE(dm365_venc_resources), .resource = dm365_venc_resources, @@ -961,28 +1099,40 @@ static struct emac_platform_data dm365_emac_pdata = { .version = EMAC_VERSION_2, }; +static const char emac_name[] = "davinci_emac"; + static struct resource dm365_emac_resources[] = { { + .name = emac_name, + .parent = &resource_cfg_root, .start = DM365_EMAC_BASE, .end = DM365_EMAC_BASE + 0x47ff, .flags = IORESOURCE_MEM, }, { + .name = emac_name, + .parent = &resource_irq_root, .start = IRQ_DM365_EMAC_RXTHRESH, .end = IRQ_DM365_EMAC_RXTHRESH, .flags = IORESOURCE_IRQ, }, { + .name = emac_name, + .parent = &resource_irq_root, .start = IRQ_DM365_EMAC_RXPULSE, .end = IRQ_DM365_EMAC_RXPULSE, .flags = IORESOURCE_IRQ, }, { + .name = emac_name, + .parent = &resource_irq_root, .start = IRQ_DM365_EMAC_TXPULSE, .end = IRQ_DM365_EMAC_TXPULSE, .flags = IORESOURCE_IRQ, }, { + .name = emac_name, + .parent = &resource_irq_root, .start = IRQ_DM365_EMAC_MISCPULSE, .end = IRQ_DM365_EMAC_MISCPULSE, .flags = IORESOURCE_IRQ, @@ -990,7 +1140,7 @@ static struct resource dm365_emac_resources[] = { }; static struct platform_device dm365_emac_device = { - .name = "davinci_emac", + .name = emac_name, .id = 1, .dev = { .platform_data = &dm365_emac_pdata, @@ -1104,42 +1254,51 @@ static struct edma_soc_info dm365_edma_info[] = { static struct resource edma_resources[] = { { .name = "edma_cc0", + .parent = &resource_cfg_root, .start = 0x01c00000, .end = 0x01c00000 + SZ_64K - 1, .flags = IORESOURCE_MEM, }, { .name = "edma_tc0", + .parent = &resource_cfg_root, .start = 0x01c10000, .end = 0x01c10000 + SZ_1K - 1, .flags = IORESOURCE_MEM, }, { .name = "edma_tc1", + .parent = &resource_cfg_root, .start = 0x01c10400, .end = 0x01c10400 + SZ_1K - 1, .flags = IORESOURCE_MEM, }, { .name = "edma_tc2", + .parent = &resource_cfg_root, .start = 0x01c10800, .end = 0x01c10800 + SZ_1K - 1, .flags = IORESOURCE_MEM, }, { .name = "edma_tc3", + .parent = &resource_cfg_root, .start = 0x01c10c00, .end = 0x01c10c00 + SZ_1K - 1, .flags = IORESOURCE_MEM, }, { .name = "edma0", + .parent = &resource_irq_root, .start = IRQ_CCINT0, + .end = IRQ_CCINT0, .flags = IORESOURCE_IRQ, }, { .name = "edma0_err", + .parent = &resource_irq_root, .start = IRQ_CCERRINT, + .end = IRQ_CCERRINT, .flags = IORESOURCE_IRQ, }, /* not using TC*_ERR */ @@ -1153,18 +1312,26 @@ static struct platform_device dm365_edma_device = { .resource = edma_resources, }; +static const char asp_name[] = "davinci-asp"; + static struct resource dm365_asp_resources[] = { { + .name = asp_name, + .parent = &resource_cfg_root, .start = DAVINCI_DM365_ASP0_BASE, .end = DAVINCI_DM365_ASP0_BASE + SZ_8K - 1, .flags = IORESOURCE_MEM, }, { + .name = asp_name, + .parent = &resource_dma_root, .start = DAVINCI_DMA_ASP0_TX, .end = DAVINCI_DMA_ASP0_TX, .flags = IORESOURCE_DMA, }, { + .name = asp_name, + .parent = &resource_dma_root, .start = DAVINCI_DMA_ASP0_RX, .end = DAVINCI_DMA_ASP0_RX, .flags = IORESOURCE_DMA, @@ -1172,26 +1339,33 @@ static struct resource dm365_asp_resources[] = { }; static struct platform_device dm365_asp_device = { - .name = "davinci-asp", + .name = asp_name, .id = 0, .num_resources = ARRAY_SIZE(dm365_asp_resources), .resource = dm365_asp_resources, }; +static const char rtc_name[] = "rtc_davinci"; + static struct resource dm365_rtc_resources[] = { { - .start = DM365_RTC_BASE, - .end = DM365_RTC_BASE + SZ_1K - 1, - .flags = IORESOURCE_MEM, + .name = rtc_name, + .parent = &resource_cfg_root, + .start = DM365_RTC_BASE, + .end = DM365_RTC_BASE + SZ_1K - 1, + .flags = IORESOURCE_MEM, }, { - .start = IRQ_DM365_RTCINT, - .flags = IORESOURCE_IRQ, + .name = rtc_name, + .parent = &resource_irq_root, + .start = IRQ_DM365_RTCINT, + .end = IRQ_DM365_RTCINT, + .flags = IORESOURCE_IRQ, }, }; static struct platform_device dm365_rtc_device = { - .name = "rtc_davinci", + .name = rtc_name, .id = 0, .num_resources = ARRAY_SIZE(dm365_rtc_resources), .resource = dm365_rtc_resources, @@ -1213,23 +1387,29 @@ static struct map_desc dm365_io_desc[] = { }, }; +static const char ks_name[] = "davinci_keyscan"; + static struct resource dm365_ks_resources[] = { { /* registers */ - .start = DM365_KEYSCAN_BASE, - .end = DM365_KEYSCAN_BASE + SZ_1K - 1, - .flags = IORESOURCE_MEM, + .name = ks_name, + .parent = &resource_cfg_root, + .start = DM365_KEYSCAN_BASE, + .end = DM365_KEYSCAN_BASE + SZ_1K - 1, + .flags = IORESOURCE_MEM, }, { /* interrupt */ - .start = IRQ_DM365_KEYINT, - .end = IRQ_DM365_KEYINT, - .flags = IORESOURCE_IRQ, + .start = IRQ_DM365_KEYINT, + .parent = &resource_irq_root, + .start = IRQ_DM365_KEYINT, + .end = IRQ_DM365_KEYINT, + .flags = IORESOURCE_IRQ, }, }; static struct platform_device dm365_ks_device = { - .name = "davinci_keyscan", + .name = ks_name, .id = 0, .num_resources = ARRAY_SIZE(dm365_ks_resources), .resource = dm365_ks_resources, @@ -1257,7 +1437,7 @@ static void __iomem *dm365_psc_bases[] = { IO_ADDRESS(DAVINCI_PWR_SLEEP_CNTRL_BASE), }; -struct davinci_timer_info dm365_timer_info = { +static struct davinci_timer_info dm365_timer_info = { .timers = davinci_timer_instance, .clockevent_id = T0_BOT, .clocksource_id = T0_TOP, @@ -1331,7 +1511,8 @@ void __init dm365_init_asp(struct snd_platform_data *pdata) davinci_cfg_reg(DM365_EVT2_ASP_TX); davinci_cfg_reg(DM365_EVT3_ASP_RX); dm365_asp_device.dev.platform_data = pdata; - platform_device_register(&dm365_asp_device); + if (!alloc_platform_resources(&dm365_asp_device)) + platform_device_register(&dm365_asp_device); } void __init dm365_init_ks(struct davinci_ks_platform_data *pdata) @@ -1343,7 +1524,8 @@ void __init dm365_init_ks(struct davinci_ks_platform_data *pdata) void __init dm365_init_rtc(void) { davinci_cfg_reg(DM365_INT_PRTCSS); - platform_device_register(&dm365_rtc_device); + if (!alloc_platform_resources(&dm365_rtc_device)) + platform_device_register(&dm365_rtc_device); } void __init dm365_init(void) @@ -1351,17 +1533,21 @@ void __init dm365_init(void) davinci_common_init(&davinci_soc_info_dm365); } +static const char vpss_name[] = "vpss"; + static struct resource dm365_vpss_resources[] = { { /* VPSS ISP5 Base address */ - .name = "vpss", + .name = vpss_name, + .parent = &resource_cfg_root, .start = 0x01c70000, .end = 0x01c70000 + 0xff, .flags = IORESOURCE_MEM, }, { /* VPSS CLK Base address */ - .name = "vpss", + .name = vpss_name, + .parent = &resource_cfg_root, .start = 0x01c70200, .end = 0x01c70200 + 0xff, .flags = IORESOURCE_MEM, @@ -1369,20 +1555,26 @@ static struct resource dm365_vpss_resources[] = { }; static struct platform_device dm365_vpss_device = { - .name = "vpss", + .name = vpss_name, .id = -1, .dev.platform_data = "dm365_vpss", .num_resources = ARRAY_SIZE(dm365_vpss_resources), .resource = dm365_vpss_resources, }; +static const char cptr_name[] = CAPTURE_DRV_NAME; + static struct resource vpfe_resources[] = { { + .name = cptr_name, + .parent = &resource_irq_root, .start = IRQ_VDINT0, .end = IRQ_VDINT0, .flags = IORESOURCE_IRQ, }, { + .name = cptr_name, + .parent = &resource_irq_root, .start = IRQ_VDINT1, .end = IRQ_VDINT1, .flags = IORESOURCE_IRQ, @@ -1391,7 +1583,7 @@ static struct resource vpfe_resources[] = { static u64 vpfe_capture_dma_mask = DMA_BIT_MASK(32); static struct platform_device vpfe_capture_dev = { - .name = CAPTURE_DRV_NAME, + .name = cptr_name, .id = -1, .num_resources = ARRAY_SIZE(vpfe_resources), .resource = vpfe_resources, @@ -1401,28 +1593,36 @@ static struct platform_device vpfe_capture_dev = { }, }; +static const char isif_name[] = "dm365_isif"; + static struct resource isif_resource[] = { /* ISIF Base address */ { + .name = isif_name, + .parent = &resource_cfg_root, .start = 0x01c71000, .end = 0x01c71000 + 0x1ff, .flags = IORESOURCE_MEM, }, /* ISIF Linearization table 0 */ { + .name = isif_name, + .parent = &resource_cfg_root, .start = 0x1C7C000, .end = 0x1C7C000 + 0x2ff, .flags = IORESOURCE_MEM, }, /* ISIF Linearization table 1 */ { + .name = isif_name, + .parent = &resource_cfg_root, .start = 0x1C7C400, .end = 0x1C7C400 + 0x2ff, .flags = IORESOURCE_MEM, }, }; static struct platform_device dm365_isif_dev = { - .name = "dm365_isif", + .name = isif_name, .id = -1, .num_resources = ARRAY_SIZE(isif_resource), .resource = isif_resource, @@ -1437,24 +1637,35 @@ static int __init dm365_init_devices(void) if (!cpu_is_davinci_dm365()) return 0; + if (request_resource(&iomem_resource, &resource_cfg_root)) + BUG(); + davinci_cfg_reg(DM365_INT_EDMA_CC); - platform_device_register(&dm365_edma_device); - platform_device_register(&dm365_emac_device); + if (!alloc_platform_resources(&dm365_edma_device)) + platform_device_register(&dm365_edma_device); + if (!alloc_platform_resources(&dm365_emac_device)) + platform_device_register(&dm365_emac_device); /* * setup Mux configuration for vpfe input and register * vpfe capture platform device */ - platform_device_register(&dm365_vpss_device); - platform_device_register(&dm365_ipipeif_dev); - platform_device_register(&dm365_isif_dev); - platform_device_register(&vpfe_capture_dev); + if (!alloc_platform_resources(&dm365_vpss_device)) + platform_device_register(&dm365_vpss_device); + if (!alloc_platform_resources(&dm365_ipipeif_dev)) + platform_device_register(&dm365_ipipeif_dev); + if (!alloc_platform_resources(&dm365_isif_dev)) + platform_device_register(&dm365_isif_dev); + if (!alloc_platform_resources(&vpfe_capture_dev)) + platform_device_register(&vpfe_capture_dev); /* Register OSD device */ - platform_device_register(&dm365_osd_dev); + if (!alloc_platform_resources(&dm365_osd_dev)) + platform_device_register(&dm365_osd_dev); /* Register VENC device */ - platform_device_register(&dm365_venc_dev); + if (!alloc_platform_resources(&dm365_venc_dev)) + platform_device_register(&dm365_venc_dev); return 0; } diff --git a/arch/arm/mach-davinci/dma.c b/arch/arm/mach-davinci/dma.c index 5cd48fa..8abc707 100644 --- a/arch/arm/mach-davinci/dma.c +++ b/arch/arm/mach-davinci/dma.c @@ -1430,14 +1430,6 @@ static int __init edma_probe(struct platform_device *pdev) found = 1; len[j] = resource_size(r[j]); - - r[j] = request_mem_region(r[j]->start, len[j], - dev_name(&pdev->dev)); - if (!r[j]) { - status = -EBUSY; - goto fail1; - } - edmacc_regs_base[j] = ioremap(r[j]->start, len[j]); if (!edmacc_regs_base[j]) { status = -EBUSY; diff --git a/arch/arm/mach-davinci/include/mach/dm365.h b/arch/arm/mach-davinci/include/mach/dm365.h index 3d2a823..2cd1134 100644 --- a/arch/arm/mach-davinci/include/mach/dm365.h +++ b/arch/arm/mach-davinci/include/mach/dm365.h @@ -14,6 +14,7 @@ #define __ASM_ARCH_DM665_H #include +#include #include #include #include @@ -33,6 +34,13 @@ /* Base of key scan register bank */ #define DM365_KEYSCAN_BASE (0x01C69400) +/* Root resources */ +extern struct resource + resource_cfg_root, + resource_dma_root, + resource_irq_root, + resource_evq_root; + void __init dm365_init(void); void __init dm365_init_asp(struct snd_platform_data *pdata); void __init dm365_init_rtc(void); diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c index 67d88cc..4327ad9 100755 --- a/drivers/i2c/busses/i2c-davinci.c +++ b/drivers/i2c/busses/i2c-davinci.c @@ -520,7 +520,7 @@ static int davinci_i2c_probe(struct platform_device *pdev) { struct davinci_i2c_dev *dev; struct i2c_adapter *adap; - struct resource *mem, *irq, *ioarea; + struct resource *mem, *irq; int r; /* NOTE: driver uses the static register mapping */ @@ -536,13 +536,6 @@ static int davinci_i2c_probe(struct platform_device *pdev) return -ENODEV; } - ioarea = request_mem_region(mem->start, resource_size(mem), - pdev->name); - if (!ioarea) { - dev_err(&pdev->dev, "I2C region already claimed\n"); - return -EBUSY; - } - dev = kzalloc(sizeof(struct davinci_i2c_dev), GFP_KERNEL); if (!dev) { r = -ENOMEM; diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c index 1bf0587..cf69c2e 100644 --- a/drivers/mmc/host/davinci_mmc.c +++ b/drivers/mmc/host/davinci_mmc.c @@ -1183,9 +1183,7 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev) ret = -EBUSY; mem_size = resource_size(r); - mem = request_mem_region(r->start, mem_size, pdev->name); - if (!mem) - goto out; + mem = r; ret = -ENOMEM; mmc = mmc_alloc_host(sizeof(struct mmc_davinci_host), &pdev->dev); diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c index 02e1a76..a5211d8 100644 --- a/drivers/spi/davinci_spi.c +++ b/drivers/spi/davinci_spi.c @@ -874,7 +874,7 @@ static irqreturn_t davinci_spi_irq(s32 irq, void *context_data) return ret; } -resource_size_t davinci_spi_get_dma_by_flag(struct platform_device *dev, +static resource_size_t davinci_spi_get_dma_by_flag(struct platform_device *dev, unsigned long flag) { struct resource *r; @@ -907,7 +907,7 @@ static int davinci_spi_probe(struct platform_device *pdev) struct spi_master *master; struct davinci_spi *davinci_spi; struct davinci_spi_platform_data *pdata; - struct resource *r, *mem; + struct resource *r; resource_size_t dma_rx_chan = DAVINCI_SPI_NO_RESOURCE; resource_size_t dma_tx_chan = DAVINCI_SPI_NO_RESOURCE; resource_size_t dma_eventq = DAVINCI_SPI_NO_RESOURCE; @@ -942,19 +942,11 @@ static int davinci_spi_probe(struct platform_device *pdev) davinci_spi->pbase = r->start; davinci_spi->region_size = resource_size(r); davinci_spi->pdata = pdata; - - mem = request_mem_region(r->start, davinci_spi->region_size, - pdev->name); - if (mem == NULL) { - ret = -EBUSY; - goto free_master; - } - davinci_spi->base = (struct davinci_spi_reg __iomem *) ioremap(r->start, davinci_spi->region_size); if (davinci_spi->base == NULL) { ret = -ENOMEM; - goto release_region; + goto free_master; } davinci_spi->irq = platform_get_irq(pdev, 0); @@ -1094,8 +1086,6 @@ err1: free_irq(davinci_spi->irq, davinci_spi); unmap_io: iounmap(davinci_spi->base); -release_region: - release_mem_region(davinci_spi->pbase, davinci_spi->region_size); free_master: kfree(master); err: