"Subrahmanya, Chaithrika" <[email protected]> writes: > Kevin, > > This ioremap call modification has to be done for all the four EMAC modules. > This version of patch fixes it only for one module ("ctrl_regs"). >
Thanks, Chaithrika. I guess I tried to get one too many patches out the door on Friday. Will rework. Kevin > ________________________________________ > From: Kevin Hilman [[email protected]] > Sent: Saturday, January 31, 2009 7:14 AM > To: [email protected] > Cc: Subrahmanya, Chaithrika > Subject: [PATCH v2 2/2] NET: davinci emac: convert to using ioremap() > > Cc: Chaithrika Subrahmanya <[email protected]> > Signed-off-by: Kevin Hilman <[email protected]> > --- > drivers/net/davinci_emac.c | 71 ++++++++++++++++++++++++++++++------------- > 1 files changed, 49 insertions(+), 22 deletions(-) > > diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c > index 1f86256..7316746 100644 > --- a/drivers/net/davinci_emac.c > +++ b/drivers/net/davinci_emac.c > @@ -29,9 +29,7 @@ > */ > > /** Pending Items in this driver: > - * 1. use ioremap(), remove davinci_readl()/etc, minimize __force > - * 2. Use Linux cache infrastcture for DMA'ed memory (dma_xxx functions) > - * 3. Add DM646x support (gigabit included) > + * 1. Use Linux cache infrastcture for DMA'ed memory (dma_xxx functions) > */ > > #include <linux/module.h> > @@ -485,8 +483,10 @@ struct emac_priv { > char mac_addr[6]; > spinlock_t tx_lock; > spinlock_t rx_lock; > - u32 emac_base_regs; > - u32 emac_ctrl_regs; > + u32 emac_base_phys; > + void __iomem *emac_base; > + u32 emac_ctrl_phys; > + void __iomem *ctrl_base; > void __iomem *emac_ctrl_ram; > u32 ctrl_ram_size; > struct emac_txch *txch[EMAC_DEF_MAX_TX_CH]; > @@ -557,16 +557,15 @@ static char *emac_rxhost_errcodes[16] = { > #define EMAC_DEV (&(priv)->ndev->dev) > > /* Helper macros */ > -#define emac_read(reg) davinci_readl((priv->emac_base_regs + (reg))) > -#define emac_write(reg, val) \ > - davinci_writel(val, (priv->emac_base_regs + (reg))) > +#define emac_read(reg) ioread32(priv->emac_base + (reg)) > +#define emac_write(reg, val) iowrite32(val, priv->emac_base + (reg)) > > -#define emac_ctrl_read(reg) davinci_readl((priv->emac_ctrl_regs + (reg))) > -#define emac_ctrl_write(reg, val) \ > - davinci_writel(val, (priv->emac_ctrl_regs + (reg))) > +#define emac_ctrl_read(reg) ioread32((priv->ctrl_base + (reg))) > +#define emac_ctrl_write(reg, val) iowrite32(val, (priv->ctrl_base + (reg))) > + > +#define emac_mdio_read(reg) ioread32(bus->priv + (reg)) > +#define emac_mdio_write(reg, val) iowrite32(val, (bus->priv + (reg))) > > -#define emac_mdio_read(reg) davinci_readl((bus->priv + (reg))) > -#define emac_mdio_write(reg, val) davinci_writel(val, (bus->priv + > (reg))) > /** > * emac_dump_regs: Dump important EMAC registers to debug terminal > * @priv: The DaVinci EMAC private adapter structure > @@ -2603,6 +2602,7 @@ static int __devinit davinci_emac_probe(struct > platform_device *pdev) > struct resource *res; > struct net_device *ndev; > struct emac_priv *priv; > + unsigned long size; > > /* obtain emac clock from kernel */ > emac_clk = clk_get(&pdev->dev, "EMACCLK"); > @@ -2644,16 +2644,22 @@ static int __devinit davinci_emac_probe(struct > platform_device *pdev) > rc = -ENOENT; > goto probe_quit; > } > - priv->emac_base_regs = res->start; > - ndev->base_addr = (unsigned long)IO_ADDRESS(res->start); > - if (!request_mem_region((u32)priv->emac_base_regs, > - (res->end - res->start + 1), > - ndev->name)) { > + priv->emac_base_phys = res->start; > + size = res->end - res->start + 1; > + if (!request_mem_region(priv->emac_base_phys, size, ndev->name)) { > dev_err(EMAC_DEV, "DaVinci EMAC: failed request_mem_region() \ > for ctrl regs\n"); > rc = -ENXIO; > goto probe_quit; > } > + priv->emac_base = ioremap(res->start, size); > + if (!priv->emac_base) { > + dev_err(EMAC_DEV, "Unable to map IO\n"); > + rc = -ENOMEM; > + release_mem_region(priv->emac_base_phys, size); > + goto probe_quit; > + } > + ndev->base_addr = (unsigned long)priv->emac_base; > > res = platform_get_resource_byname(pdev, > IORESOURCE_MEM, "ctrl_module_regs"); > @@ -2663,8 +2669,14 @@ static int __devinit davinci_emac_probe(struct > platform_device *pdev) > rc = -ENOENT; > goto no_ctrl_mod_res; > } > - priv->emac_ctrl_regs = res->start; > - if (!request_mem_region((u32)priv->emac_ctrl_regs, > + priv->emac_ctrl_phys = res->start; > + priv->ctrl_base = ioremap(res->start, res->end); > + if (!priv->ctrl_base) { > + dev_err(EMAC_DEV, "Unable to map ctrl regs\n"); > + rc = -ENOMEM; > + goto no_ctrl_mod_res; > + } > + if (!request_mem_region(priv->emac_ctrl_phys, > (res->end - res->start + 1), > ndev->name)) { > dev_err(EMAC_DEV, "DaVinci EMAC: failed request_mem_region() \ > @@ -2679,7 +2691,12 @@ static int __devinit davinci_emac_probe(struct > platform_device *pdev) > rc = -ENOENT; > goto no_ctrl_ram_res; > } > - priv->emac_ctrl_ram = IO_ADDRESS(res->start); > + priv->emac_ctrl_ram = ioremap(res->start, res->end); > + if (!priv->emac_ctrl_ram) { > + dev_err(EMAC_DEV, "Unable to map ctrl RAM\n"); > + rc = -ENOMEM; > + goto no_ctrl_ram_res; > + } > priv->ctrl_ram_size = res->end - res->start + 1; > if (!request_mem_region(res->start, > (res->end - res->start + 1), > @@ -2751,6 +2768,12 @@ static int __devinit davinci_emac_probe(struct > platform_device *pdev) > } > > emac_mii->priv = (void *)(res->start); > + emac_mii->priv = ioremap(res->start, res->end); > + if (!emac_mii->priv) { > + dev_err(EMAC_DEV, "Unable to map MDIO regs\n"); > + rc = -ENOMEM; > + goto no_mdio_res; > + } > if (!request_mem_region(res->start, > (res->end - res->start + 1), > ndev->name)) { > @@ -2771,7 +2794,7 @@ static int __devinit davinci_emac_probe(struct > platform_device *pdev) > if (netif_msg_probe(priv)) { > dev_notice(EMAC_DEV, "DaVinci EMAC Probe found device "\ > "(regs: %p, irq: %d)\n", > - (void *)priv->emac_base_regs, ndev->irq); > + (void *)priv->emac_base_phys, ndev->irq); > } > return 0; > > @@ -2831,6 +2854,10 @@ static int __devexit davinci_emac_remove(struct > platform_device *pdev) > > unregister_netdev(ndev); > free_netdev(ndev); > + iounmap(priv->emac_base); > + iounmap(priv->ctrl_base); > + iounmap(priv->emac_ctrl_ram); > + iounmap(emac_mii->priv); > clk_disable(emac_clk); > clk_put(emac_clk); > > -- > 1.6.1 _______________________________________________ Davinci-linux-open-source mailing list [email protected] http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
