From: Ben Dooks <ben-i2c-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
To: Sebastian Andrzej Siewior
<bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Cc: Ben Dooks <ben-SMNkleLxa3Z6Wcw2j4pizdi2O/JbrIOy@public.gmane.org>,
eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
sodaville-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org,
ben-i2c-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org,
linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [sodaville] [PATCH 1/6] i2c/pxa2xx: Don't touch ISAR on X86
Date: Mon, 06 Dec 2010 04:40:18 +0000 [thread overview]
Message-ID: <4CFC6932.5040502@fluff.org> (raw)
In-Reply-To: <20101204182209.GA23352-Hfxr4Dq0UpYb1SvskN2V4Q@public.gmane.org>
On 04/12/10 18:22, Sebastian Andrzej Siewior wrote:
> * Sebastian Andrzej Siewior | 2010-12-03 19:17:04 [+0100]:
>
>> Ben Dooks wrote:
>>>> +#ifndef CONFIG_X86
>>>> writel(i2c->slave_addr, _ISAR(i2c));
>>>> +#endif
>>
>>
>>> I'd prefer some way of changing based on either the device name (see
>>> some other drivers which bind on multiple names) to define things such
>>> as this, as well as possibly changing the register layout.
>>
>> Do you want me to also change the register access? This would be a
>> intrusive patch since I would have to touch every readl()/writel() line
>> in this file.
> I've been looking at the wrong code while writting this. Here are two
> variants. -variant2 containts the size using this patch. variant1 uses
>
> #define _IBMR(i2c) ((i2c)->reg_base + pxa_reg_layout[(i2c)->layout].ibmr)
>
> for the access.
>
> text data bss dec hex filename
> 3753 84 0 3837 efd i2c-pxa-org.o
> 4017 84 0 4101 1005 i2c-pxa-variant1.o
> 3525 84 0 3609 e19 i2c-pxa-variant2.o
>
> Are you fine with this?
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
> ---
> drivers/i2c/busses/i2c-pxa.c | 64 +++++++++++++++++++++++++++++++----------
> 1 files changed, 48 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> index f4c19a9..29ff876 100644
> --- a/drivers/i2c/busses/i2c-pxa.c
> +++ b/drivers/i2c/busses/i2c-pxa.c
> @@ -38,17 +38,40 @@
> #include <asm/irq.h>
> #include <plat/i2c.h>
>
> -/*
> - * I2C register offsets will be shifted 0 or 1 bit left, depending on
> - * different SoCs
> - */
> -#define REG_SHIFT_0 (0 << 0)
> -#define REG_SHIFT_1 (1 << 0)
> -#define REG_SHIFT(d) ((d) & 0x1)
> +
> +struct pxa_reg_layout {
> + u32 ibmr;
> + u32 idbr;
> + u32 icr;
> + u32 isr;
> + u32 isar;
> +};
> +
> +enum pxa_i2c_types {
> + REGS_PXA2XX,
> + REGS_PXA3XX,
> +};
> +
> +static struct pxa_reg_layout pxa_reg_layout[] = {
> + [REGS_PXA2XX] = {
> + .ibmr = 0x00,
> + .idbr = 0x10,
> + .icr = 0x20,
> + .isr = 0x30,
> + .isar = 0x40,
> +
> + }, [REGS_PXA3XX] = {
> + .ibmr = 0x00,
> + .idbr = 0x08,
> + .icr = 0x10,
> + .isr = 0x18,
> + .isar = 0x20,
> + },
> +};
>
> static const struct platform_device_id i2c_pxa_id_table[] = {
> - { "pxa2xx-i2c", REG_SHIFT_1 },
> - { "pxa3xx-pwri2c", REG_SHIFT_0 },
> + { "pxa2xx-i2c", REGS_PXA2XX },
> + { "pxa3xx-pwri2c", REGS_PXA3XX },
> { },
> };
> MODULE_DEVICE_TABLE(platform, i2c_pxa_id_table);
> @@ -111,7 +134,11 @@ struct pxa_i2c {
> u32 icrlog[32];
>
> void __iomem *reg_base;
> - unsigned int reg_shift;
> + void __iomem *reg_ibmr;
> + void __iomem *reg_idbr;
> + void __iomem *reg_icr;
> + void __iomem *reg_isr;
> + void __iomem *reg_isar;
>
> unsigned long iobase;
> unsigned long iosize;
> @@ -121,11 +148,11 @@ struct pxa_i2c {
> unsigned int fast_mode :1;
> };
>
> -#define _IBMR(i2c) ((i2c)->reg_base + (0x0 << (i2c)->reg_shift))
> -#define _IDBR(i2c) ((i2c)->reg_base + (0x4 << (i2c)->reg_shift))
> -#define _ICR(i2c) ((i2c)->reg_base + (0x8 << (i2c)->reg_shift))
> -#define _ISR(i2c) ((i2c)->reg_base + (0xc << (i2c)->reg_shift))
> -#define _ISAR(i2c) ((i2c)->reg_base + (0x10 << (i2c)->reg_shift))
> +#define _IBMR(i2c) ((i2c)->reg_ibmr)
> +#define _IDBR(i2c) ((i2c)->reg_idbr)
> +#define _ICR(i2c) ((i2c)->reg_icr)
> +#define _ISR(i2c) ((i2c)->reg_isr)
> +#define _ISAR(i2c) ((i2c)->reg_isar)
>
> /*
> * I2C Slave mode address
> @@ -1044,7 +1071,12 @@ static int i2c_pxa_probe(struct platform_device *dev)
> ret = -EIO;
> goto eremap;
> }
> - i2c->reg_shift = REG_SHIFT(id->driver_data);
> +
> + i2c->reg_ibmr = i2c->reg_base + pxa_reg_layout[id->driver_data].ibmr;
> + i2c->reg_idbr = i2c->reg_base + pxa_reg_layout[id->driver_data].idbr;
> + i2c->reg_icr = i2c->reg_base + pxa_reg_layout[id->driver_data].icr;
> + i2c->reg_isr = i2c->reg_base + pxa_reg_layout[id->driver_data].isr;
> + i2c->reg_isar = i2c->reg_base + pxa_reg_layout[id->driver_data].isar;
>
> i2c->iobase = res->start;
> i2c->iosize = resource_size(res);
Ok, this seems to be looking good.
I'll hold this for a few days before a final decision. will add to -next
tomorrow.
WARNING: multiple messages have this Message-ID (diff)
From: ben-i2c@fluff.org (Ben Dooks)
To: linux-arm-kernel@lists.infradead.org
Subject: [sodaville] [PATCH 1/6] i2c/pxa2xx: Don't touch ISAR on X86
Date: Mon, 06 Dec 2010 04:40:18 +0000 [thread overview]
Message-ID: <4CFC6932.5040502@fluff.org> (raw)
In-Reply-To: <20101204182209.GA23352@www.tglx.de>
On 04/12/10 18:22, Sebastian Andrzej Siewior wrote:
> * Sebastian Andrzej Siewior | 2010-12-03 19:17:04 [+0100]:
>
>> Ben Dooks wrote:
>>>> +#ifndef CONFIG_X86
>>>> writel(i2c->slave_addr, _ISAR(i2c));
>>>> +#endif
>>
>>
>>> I'd prefer some way of changing based on either the device name (see
>>> some other drivers which bind on multiple names) to define things such
>>> as this, as well as possibly changing the register layout.
>>
>> Do you want me to also change the register access? This would be a
>> intrusive patch since I would have to touch every readl()/writel() line
>> in this file.
> I've been looking at the wrong code while writting this. Here are two
> variants. -variant2 containts the size using this patch. variant1 uses
>
> #define _IBMR(i2c) ((i2c)->reg_base + pxa_reg_layout[(i2c)->layout].ibmr)
>
> for the access.
>
> text data bss dec hex filename
> 3753 84 0 3837 efd i2c-pxa-org.o
> 4017 84 0 4101 1005 i2c-pxa-variant1.o
> 3525 84 0 3609 e19 i2c-pxa-variant2.o
>
> Are you fine with this?
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> drivers/i2c/busses/i2c-pxa.c | 64 +++++++++++++++++++++++++++++++----------
> 1 files changed, 48 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> index f4c19a9..29ff876 100644
> --- a/drivers/i2c/busses/i2c-pxa.c
> +++ b/drivers/i2c/busses/i2c-pxa.c
> @@ -38,17 +38,40 @@
> #include <asm/irq.h>
> #include <plat/i2c.h>
>
> -/*
> - * I2C register offsets will be shifted 0 or 1 bit left, depending on
> - * different SoCs
> - */
> -#define REG_SHIFT_0 (0 << 0)
> -#define REG_SHIFT_1 (1 << 0)
> -#define REG_SHIFT(d) ((d) & 0x1)
> +
> +struct pxa_reg_layout {
> + u32 ibmr;
> + u32 idbr;
> + u32 icr;
> + u32 isr;
> + u32 isar;
> +};
> +
> +enum pxa_i2c_types {
> + REGS_PXA2XX,
> + REGS_PXA3XX,
> +};
> +
> +static struct pxa_reg_layout pxa_reg_layout[] = {
> + [REGS_PXA2XX] = {
> + .ibmr = 0x00,
> + .idbr = 0x10,
> + .icr = 0x20,
> + .isr = 0x30,
> + .isar = 0x40,
> +
> + }, [REGS_PXA3XX] = {
> + .ibmr = 0x00,
> + .idbr = 0x08,
> + .icr = 0x10,
> + .isr = 0x18,
> + .isar = 0x20,
> + },
> +};
>
> static const struct platform_device_id i2c_pxa_id_table[] = {
> - { "pxa2xx-i2c", REG_SHIFT_1 },
> - { "pxa3xx-pwri2c", REG_SHIFT_0 },
> + { "pxa2xx-i2c", REGS_PXA2XX },
> + { "pxa3xx-pwri2c", REGS_PXA3XX },
> { },
> };
> MODULE_DEVICE_TABLE(platform, i2c_pxa_id_table);
> @@ -111,7 +134,11 @@ struct pxa_i2c {
> u32 icrlog[32];
>
> void __iomem *reg_base;
> - unsigned int reg_shift;
> + void __iomem *reg_ibmr;
> + void __iomem *reg_idbr;
> + void __iomem *reg_icr;
> + void __iomem *reg_isr;
> + void __iomem *reg_isar;
>
> unsigned long iobase;
> unsigned long iosize;
> @@ -121,11 +148,11 @@ struct pxa_i2c {
> unsigned int fast_mode :1;
> };
>
> -#define _IBMR(i2c) ((i2c)->reg_base + (0x0 << (i2c)->reg_shift))
> -#define _IDBR(i2c) ((i2c)->reg_base + (0x4 << (i2c)->reg_shift))
> -#define _ICR(i2c) ((i2c)->reg_base + (0x8 << (i2c)->reg_shift))
> -#define _ISR(i2c) ((i2c)->reg_base + (0xc << (i2c)->reg_shift))
> -#define _ISAR(i2c) ((i2c)->reg_base + (0x10 << (i2c)->reg_shift))
> +#define _IBMR(i2c) ((i2c)->reg_ibmr)
> +#define _IDBR(i2c) ((i2c)->reg_idbr)
> +#define _ICR(i2c) ((i2c)->reg_icr)
> +#define _ISR(i2c) ((i2c)->reg_isr)
> +#define _ISAR(i2c) ((i2c)->reg_isar)
>
> /*
> * I2C Slave mode address
> @@ -1044,7 +1071,12 @@ static int i2c_pxa_probe(struct platform_device *dev)
> ret = -EIO;
> goto eremap;
> }
> - i2c->reg_shift = REG_SHIFT(id->driver_data);
> +
> + i2c->reg_ibmr = i2c->reg_base + pxa_reg_layout[id->driver_data].ibmr;
> + i2c->reg_idbr = i2c->reg_base + pxa_reg_layout[id->driver_data].idbr;
> + i2c->reg_icr = i2c->reg_base + pxa_reg_layout[id->driver_data].icr;
> + i2c->reg_isr = i2c->reg_base + pxa_reg_layout[id->driver_data].isr;
> + i2c->reg_isar = i2c->reg_base + pxa_reg_layout[id->driver_data].isar;
>
> i2c->iobase = res->start;
> i2c->iosize = resource_size(res);
Ok, this seems to be looking good.
I'll hold this for a few days before a final decision. will add to -next
tomorrow.
next prev parent reply other threads:[~2010-12-06 4:40 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-02 20:09 I2C support for CE4100, v2 Sebastian Andrzej Siewior
2010-12-02 20:09 ` Sebastian Andrzej Siewior
[not found] ` <1291320589-31570-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-12-02 20:09 ` [PATCH 1/6] i2c/pxa2xx: Don't touch ISAR on X86 Sebastian Andrzej Siewior
2010-12-02 20:09 ` Sebastian Andrzej Siewior
[not found] ` <1291320589-31570-2-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-12-03 1:44 ` Ben Dooks
2010-12-03 1:44 ` Ben Dooks
[not found] ` <20101203014424.GG24979-SMNkleLxa3Z6Wcw2j4pizdi2O/JbrIOy@public.gmane.org>
2010-12-03 18:17 ` Sebastian Andrzej Siewior
2010-12-03 18:17 ` Sebastian Andrzej Siewior
[not found] ` <4CF93420.9010006-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-12-04 18:22 ` [sodaville] " Sebastian Andrzej Siewior
2010-12-04 18:22 ` Sebastian Andrzej Siewior
[not found] ` <20101204182209.GA23352-Hfxr4Dq0UpYb1SvskN2V4Q@public.gmane.org>
2010-12-06 4:40 ` Ben Dooks [this message]
2010-12-06 4:40 ` Ben Dooks
2010-12-02 20:09 ` [PATCH 2/6] arm/pxa2xx: reorganize I2C files Sebastian Andrzej Siewior
2010-12-02 20:09 ` Sebastian Andrzej Siewior
2010-12-02 20:09 ` [PATCH 3/6] i2c/pxa2xx: Add PCI support for PXA I2C controller Sebastian Andrzej Siewior
2010-12-02 20:09 ` Sebastian Andrzej Siewior
[not found] ` <1291320589-31570-4-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-12-14 14:35 ` Florian Fainelli
2010-12-14 14:35 ` Florian Fainelli
[not found] ` <201012141535.30589.ffainelli-MmRyKUhfbQ9GWvitb5QawA@public.gmane.org>
2011-01-05 17:26 ` Sebastian Andrzej Siewior
2011-01-05 17:26 ` Sebastian Andrzej Siewior
2010-12-02 20:09 ` [PATCH 4/6] i2c/pxa2xx: add support for shared IRQ handler Sebastian Andrzej Siewior
2010-12-02 20:09 ` Sebastian Andrzej Siewior
2010-12-02 20:09 ` [PATCH 5/6] i2c/pxa2xx: check timeout correctly Sebastian Andrzej Siewior
2010-12-02 20:09 ` Sebastian Andrzej Siewior
2010-12-02 20:09 ` [PATCH 6/6] i2c/pxa2xx: pass of_node from platform driver to adapter and publish Sebastian Andrzej Siewior
2010-12-02 20:09 ` Sebastian Andrzej Siewior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4CFC6932.5040502@fluff.org \
--to=ben-i2c-elnmno+kys3ytjvyw6ydsg@public.gmane.org \
--cc=ben-SMNkleLxa3Z6Wcw2j4pizdi2O/JbrIOy@public.gmane.org \
--cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
--cc=bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
--cc=eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
--cc=sodaville-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.