* [PATCH] mfd: let asic3 use mem resource instead of bus_shift @ 2008-07-05 20:20 Philipp Zabel 2008-07-06 15:05 ` Philipp Zabel 0 siblings, 1 reply; 3+ messages in thread From: Philipp Zabel @ 2008-07-05 20:20 UTC (permalink / raw) To: LKML; +Cc: Samuel Ortiz The bus_shift parameter in platform_data is not needed as we can tell the driver with the IOMEM_RESOURCE whether the ASIC is located on a 16bit or 32bit memory bus. bus_shift as a configuration parameter is confusing at best because sometimes it means "shift register number left by n bits", sometimes it means "shift 32bit register address right by n bits" (see asic->bus_shift = 2 - pdata->bus_shift ...). The htc-egpio driver uses a more descriptive bus_width parameter, but for drivers where the register map size is fixed, we don't even need this. With this patch, the asic3 driver will calculate its bus_shift from the memory resource size (ASIC3_MAP_SIZE_16BIT or ASIC3_MAP_SIZE_32BIT). Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com> --- drivers/mfd/asic3.c | 11 +++++------ include/linux/mfd/asic3.h | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c index f2fb233..3b870e7 100644 --- a/drivers/mfd/asic3.c +++ b/drivers/mfd/asic3.c @@ -313,6 +313,7 @@ static int __init asic3_irq_probe(struct platform_device *pdev) struct asic3 *asic = platform_get_drvdata(pdev); unsigned long clksel = 0; unsigned int irq, irq_base; + int map_size; asic->irq_nr = platform_get_irq(pdev, 0); if (asic->irq_nr < 0) @@ -551,8 +552,8 @@ static int __init asic3_probe(struct platform_device *pdev) goto out_free; } - - asic->mapping = ioremap(mem->start, PAGE_SIZE); + map_size = mem->end - mem->start + 1; + asic->mapping = ioremap(mem->start, map_size); if (!asic->mapping) { ret = -ENOMEM; dev_err(asic->dev, "Couldn't ioremap\n"); @@ -561,10 +562,8 @@ static int __init asic3_probe(struct platform_device *pdev) asic->irq_base = pdata->irq_base; - if (pdata && pdata->bus_shift) - asic->bus_shift = 2 - pdata->bus_shift; - else - asic->bus_shift = 0; + /* calculate bus shift from mem resource */ + asic->bus_shift = 2 - (map_size >> 12); clksel = 0; asic3_write_register(asic, ASIC3_OFFSET(CLOCK, SEL), clksel); diff --git a/include/linux/mfd/asic3.h b/include/linux/mfd/asic3.h index 8f8c46c..2de526a 100644 --- a/include/linux/mfd/asic3.h +++ b/include/linux/mfd/asic3.h @@ -498,6 +498,7 @@ struct asic3_platform_data { #define ASIC3_SDIO_CTRL_LEDCtrl 0x7C #define ASIC3_SDIO_CTRL_SoftwareReset 0x1C0 -#define ASIC3_MAP_SIZE 0x2000 +#define ASIC3_MAP_SIZE_32BIT 0x2000 +#define ASIC3_MAP_SIZE_16BIT 0x1000 #endif /* __ASIC3_H__ */ -- 1.5.6 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mfd: let asic3 use mem resource instead of bus_shift 2008-07-05 20:20 [PATCH] mfd: let asic3 use mem resource instead of bus_shift Philipp Zabel @ 2008-07-06 15:05 ` Philipp Zabel 2008-07-10 0:30 ` Samuel Ortiz 0 siblings, 1 reply; 3+ messages in thread From: Philipp Zabel @ 2008-07-06 15:05 UTC (permalink / raw) To: LKML; +Cc: Samuel Ortiz Am Samstag, den 05.07.2008, 22:20 +0200 schrieb Philipp Zabel: > The bus_shift parameter in platform_data is not needed > as we can tell the driver with the IOMEM_RESOURCE whether > the ASIC is located on a 16bit or 32bit memory bus. > > bus_shift as a configuration parameter is confusing at best > because sometimes it means "shift register number left by n bits", > sometimes it means "shift 32bit register address right by n bits" > (see asic->bus_shift = 2 - pdata->bus_shift ...). > > The htc-egpio driver uses a more descriptive bus_width parameter, > but for drivers where the register map size is fixed, we don't even > need this. With this patch, the asic3 driver will calculate its > bus_shift from the memory resource size (ASIC3_MAP_SIZE_16BIT or > ASIC3_MAP_SIZE_32BIT). > > Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com> > --- > drivers/mfd/asic3.c | 11 +++++------ > include/linux/mfd/asic3.h | 3 ++- > 2 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c > index f2fb233..3b870e7 100644 > --- a/drivers/mfd/asic3.c > +++ b/drivers/mfd/asic3.c > @@ -313,6 +313,7 @@ static int __init asic3_irq_probe(struct platform_device *pdev) > struct asic3 *asic = platform_get_drvdata(pdev); > unsigned long clksel = 0; > unsigned int irq, irq_base; > + int map_size; > > asic->irq_nr = platform_get_irq(pdev, 0); > if (asic->irq_nr < 0) > @@ -551,8 +552,8 @@ static int __init asic3_probe(struct platform_device *pdev) > goto out_free; > } > > - > - asic->mapping = ioremap(mem->start, PAGE_SIZE); > + map_size = mem->end - mem->start + 1; > + asic->mapping = ioremap(mem->start, map_size); > if (!asic->mapping) { > ret = -ENOMEM; > dev_err(asic->dev, "Couldn't ioremap\n"); > @@ -561,10 +562,8 @@ static int __init asic3_probe(struct platform_device *pdev) > > asic->irq_base = pdata->irq_base; > > - if (pdata && pdata->bus_shift) > - asic->bus_shift = 2 - pdata->bus_shift; > - else > - asic->bus_shift = 0; > + /* calculate bus shift from mem resource */ > + asic->bus_shift = 2 - (map_size >> 12); > > clksel = 0; > asic3_write_register(asic, ASIC3_OFFSET(CLOCK, SEL), clksel); > diff --git a/include/linux/mfd/asic3.h b/include/linux/mfd/asic3.h > index 8f8c46c..2de526a 100644 > --- a/include/linux/mfd/asic3.h > +++ b/include/linux/mfd/asic3.h > @@ -498,6 +498,7 @@ struct asic3_platform_data { > #define ASIC3_SDIO_CTRL_LEDCtrl 0x7C > #define ASIC3_SDIO_CTRL_SoftwareReset 0x1C0 > > -#define ASIC3_MAP_SIZE 0x2000 > +#define ASIC3_MAP_SIZE_32BIT 0x2000 > +#define ASIC3_MAP_SIZE_16BIT 0x1000 > > #endif /* __ASIC3_H__ */ Second try. I forgot to remove bus_shift struct asic3_platform_data before. regards Philipp --- Subject: [PATCH] mfd: let asic3 use mem resource instead of bus_shift The bus_shift parameter in platform_data is not needed as we can tell the driver with the IOMEM_RESOURCE whether the ASIC is located on a 16bit or 32bit memory bus. The htc-egpio driver uses a more descriptive bus_width parameter, but for drivers where the register map size fixed, we don't even need this. bus_shift as a configuration parameter is confusing at best because sometimes it means "shift register number left by n bits", sometimes it means "shift 32bit register address right by n bits" (see asic->bus_shift = 2 - pdata->bus_shift ...). Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com> --- drivers/mfd/asic3.c | 11 +++++------ include/linux/mfd/asic3.h | 5 ++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c index f2fb233..3b870e7 100644 --- a/drivers/mfd/asic3.c +++ b/drivers/mfd/asic3.c @@ -313,6 +313,7 @@ static int __init asic3_irq_probe(struct platform_device *pdev) struct asic3 *asic = platform_get_drvdata(pdev); unsigned long clksel = 0; unsigned int irq, irq_base; + int map_size; asic->irq_nr = platform_get_irq(pdev, 0); if (asic->irq_nr < 0) @@ -551,8 +552,8 @@ static int __init asic3_probe(struct platform_device *pdev) goto out_free; } - - asic->mapping = ioremap(mem->start, PAGE_SIZE); + map_size = mem->end - mem->start + 1; + asic->mapping = ioremap(mem->start, map_size); if (!asic->mapping) { ret = -ENOMEM; dev_err(asic->dev, "Couldn't ioremap\n"); @@ -561,10 +562,8 @@ static int __init asic3_probe(struct platform_device *pdev) asic->irq_base = pdata->irq_base; - if (pdata && pdata->bus_shift) - asic->bus_shift = 2 - pdata->bus_shift; - else - asic->bus_shift = 0; + /* calculate bus shift from mem resource */ + asic->bus_shift = 2 - (map_size >> 12); clksel = 0; asic3_write_register(asic, ASIC3_OFFSET(CLOCK, SEL), clksel); diff --git a/include/linux/mfd/asic3.h b/include/linux/mfd/asic3.h index 8f8c46c..322cd6d 100644 --- a/include/linux/mfd/asic3.h +++ b/include/linux/mfd/asic3.h @@ -20,8 +20,6 @@ struct asic3_platform_data { u16 *gpio_config; unsigned int gpio_config_num; - unsigned int bus_shift; - unsigned int irq_base; unsigned int gpio_base; @@ -498,6 +496,7 @@ struct asic3_platform_data { #define ASIC3_SDIO_CTRL_LEDCtrl 0x7C #define ASIC3_SDIO_CTRL_SoftwareReset 0x1C0 -#define ASIC3_MAP_SIZE 0x2000 +#define ASIC3_MAP_SIZE_32BIT 0x2000 +#define ASIC3_MAP_SIZE_16BIT 0x1000 #endif /* __ASIC3_H__ */ -- 1.5.6 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mfd: let asic3 use mem resource instead of bus_shift 2008-07-06 15:05 ` Philipp Zabel @ 2008-07-10 0:30 ` Samuel Ortiz 0 siblings, 0 replies; 3+ messages in thread From: Samuel Ortiz @ 2008-07-10 0:30 UTC (permalink / raw) To: Philipp Zabel; +Cc: LKML Hi Philipp, On Sun, Jul 06, 2008 at 05:05:54PM +0200, Philipp Zabel wrote: > The bus_shift parameter in platform_data is not needed > as we can tell the driver with the IOMEM_RESOURCE whether > the ASIC is located on a 16bit or 32bit memory bus. > > The htc-egpio driver uses a more descriptive bus_width parameter, > but for drivers where the register map size fixed, we don't even > need this. > bus_shift as a configuration parameter is confusing at best > because sometimes it means "shift register number left by n bits", > sometimes it means "shift 32bit register address right by n bits" > (see asic->bus_shift = 2 - pdata->bus_shift ...). > > Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com> Looks good, thanks. Applied. Cheers, Samuel. > --- > drivers/mfd/asic3.c | 11 +++++------ > include/linux/mfd/asic3.h | 5 ++--- > 2 files changed, 7 insertions(+), 9 deletions(-) > > diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c > index f2fb233..3b870e7 100644 > --- a/drivers/mfd/asic3.c > +++ b/drivers/mfd/asic3.c > @@ -313,6 +313,7 @@ static int __init asic3_irq_probe(struct platform_device *pdev) > struct asic3 *asic = platform_get_drvdata(pdev); > unsigned long clksel = 0; > unsigned int irq, irq_base; > + int map_size; > > asic->irq_nr = platform_get_irq(pdev, 0); > if (asic->irq_nr < 0) > @@ -551,8 +552,8 @@ static int __init asic3_probe(struct platform_device *pdev) > goto out_free; > } > > - > - asic->mapping = ioremap(mem->start, PAGE_SIZE); > + map_size = mem->end - mem->start + 1; > + asic->mapping = ioremap(mem->start, map_size); > if (!asic->mapping) { > ret = -ENOMEM; > dev_err(asic->dev, "Couldn't ioremap\n"); > @@ -561,10 +562,8 @@ static int __init asic3_probe(struct platform_device *pdev) > > asic->irq_base = pdata->irq_base; > > - if (pdata && pdata->bus_shift) > - asic->bus_shift = 2 - pdata->bus_shift; > - else > - asic->bus_shift = 0; > + /* calculate bus shift from mem resource */ > + asic->bus_shift = 2 - (map_size >> 12); > > clksel = 0; > asic3_write_register(asic, ASIC3_OFFSET(CLOCK, SEL), clksel); > diff --git a/include/linux/mfd/asic3.h b/include/linux/mfd/asic3.h > index 8f8c46c..322cd6d 100644 > --- a/include/linux/mfd/asic3.h > +++ b/include/linux/mfd/asic3.h > @@ -20,8 +20,6 @@ struct asic3_platform_data { > u16 *gpio_config; > unsigned int gpio_config_num; > > - unsigned int bus_shift; > - > unsigned int irq_base; > > unsigned int gpio_base; > @@ -498,6 +496,7 @@ struct asic3_platform_data { > #define ASIC3_SDIO_CTRL_LEDCtrl 0x7C > #define ASIC3_SDIO_CTRL_SoftwareReset 0x1C0 > > -#define ASIC3_MAP_SIZE 0x2000 > +#define ASIC3_MAP_SIZE_32BIT 0x2000 > +#define ASIC3_MAP_SIZE_16BIT 0x1000 > > #endif /* __ASIC3_H__ */ > -- > 1.5.6 > > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-07-10 0:28 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-07-05 20:20 [PATCH] mfd: let asic3 use mem resource instead of bus_shift Philipp Zabel 2008-07-06 15:05 ` Philipp Zabel 2008-07-10 0:30 ` Samuel Ortiz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox