devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jayachandran C." <jayachandranc-oSioyQM9ZPnuBjGU1YDckgC/G2K4zDHf@public.gmane.org>
To: Shubhrajyoti Datta
	<omaplinuxkernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org,
	jacmet-OfajU3CKLf1/SzgSGea1oA@public.gmane.org,
	richard.rojfors-gfIc91nka+FZroRs9YW3xA@public.gmane.org,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org,
	Ganesan Ramalingam
	<ganesanr-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH v3 4/4] i2c: i2c-ocores: support for 16bit and 32bit IO
Date: Fri, 13 Jul 2012 19:28:48 +0530	[thread overview]
Message-ID: <20120713135848.GC18519@jayachandranc.netlogicmicro.com> (raw)
In-Reply-To: <CAM=Q2csMBP7YHgmMob0Npaxo70Quo3-76TNhQawE972zfiLiHA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Fri, Jul 13, 2012 at 07:18:35PM +0530, Shubhrajyoti Datta wrote:
> Hello,
> 
> On Fri, Jul 13, 2012 at 7:14 PM, Jayachandran C
> <jayachandranc-oSioyQM9ZPnuBjGU1YDckgC/G2K4zDHf@public.gmane.org> wrote:
> > From: Ganesan Ramalingam <ganesanr-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> >
> > Some architectures supports only 16-bit or 32-bit read/write access to
> > their IO space. Add a 'reg-io-width' platform and OF parameter which
> > specifies the IO width to support these platforms.
> >
> > reg-io-width can be specified as 1, 2 or 4, and has a default value
> > of 1 if it is unspecified.
> >
> > Signed-off-by: Ganesan Ramalingam <ganesanr-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> > Signed-off-by: Jayachandran C <jayachandranc-oSioyQM9ZPnuBjGU1YDckgC/G2K4zDHf@public.gmane.org>
> > ---
> >  .../devicetree/bindings/i2c/i2c-ocores.txt         |    2 ++
> >  drivers/i2c/busses/i2c-ocores.c                    |   21 ++++++++++++++++++--
> >  include/linux/i2c-ocores.h                         |    1 +
> >  3 files changed, 22 insertions(+), 2 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/i2c/i2c-ocores.txt b/Documentation/devicetree/bindings/i2c/i2c-ocores.txt
> > index 1c9334b..c15781f 100644
> > --- a/Documentation/devicetree/bindings/i2c/i2c-ocores.txt
> > +++ b/Documentation/devicetree/bindings/i2c/i2c-ocores.txt
> > @@ -10,6 +10,7 @@ Required properties:
> >
> >  Optional properties:
> >  - reg-shift       : device register offsets are shifted by this value
> > +- reg-io-width    : io register width in bytes (1, 2 or 4)
> >  - regstep         : deprecated, use reg-shift above
> >
> >  Example:
> > @@ -23,6 +24,7 @@ Example:
> >                 clock-frequency = <20000000>;
> >
> >                 reg-shift = <0>;        /* 8 bit registers */
> > +               reg-io-width = <1>;     /* 8 bit read/write */
> >
> >                 dummy@60 {
> >                         compatible = "dummy";
> > diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
> > index 721ead9..de3b119 100644
> > --- a/drivers/i2c/busses/i2c-ocores.c
> > +++ b/drivers/i2c/busses/i2c-ocores.c
> > @@ -30,6 +30,7 @@
> >  struct ocores_i2c {
> >         void __iomem *base;
> >         u32 reg_shift;
> > +       u32 reg_io_width;
> >         wait_queue_head_t wait;
> >         struct i2c_adapter adap;
> >         struct i2c_msg *msg;
> > @@ -72,12 +73,22 @@ struct ocores_i2c {
> >
> >  static inline void oc_setreg(struct ocores_i2c *i2c, int reg, u8 value)
> >  {
> > -       iowrite8(value, i2c->base + (reg << i2c->reg_shift));
> > +       if (i2c->reg_io_width == 4)
> > +               iowrite32(value, i2c->base + (reg << i2c->reg_shift));
> > +       else if (i2c->reg_io_width == 2)
> > +               iowrite16(value, i2c->base + (reg << i2c->reg_shift));
> > +       else
> > +               iowrite8(value, i2c->base + (reg << i2c->reg_shift));
> >  }
> >
> >  static inline u8 oc_getreg(struct ocores_i2c *i2c, int reg)
> 
> Should the return type be changed.
> Now that it is returning more that than 8 bits.
> 
> Did I miss something?

Only 8 bits of the register is significant, so even if we read 16 or 32
bits only the lowest 8 bits are returned.

JC.

  parent reply	other threads:[~2012-07-13 13:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-13 13:44 [PATCH v3 0/4] I2C Ocores updates Jayachandran C
     [not found] ` <1342187065-1651-1-git-send-email-jayachandranc-oSioyQM9ZPnuBjGU1YDckgC/G2K4zDHf@public.gmane.org>
2012-07-13 13:44   ` [PATCH v3 1/4] i2c: i2c-ocores - DT bindings and minor fixes Jayachandran C
     [not found]     ` <1342187065-1651-2-git-send-email-jayachandranc-oSioyQM9ZPnuBjGU1YDckgC/G2K4zDHf@public.gmane.org>
2012-07-16  3:42       ` Rajeev kumar
2012-07-13 13:44   ` [PATCH v3 2/4] i2c: i2c-ocores: Use reg-shift property Jayachandran C
     [not found]     ` <1342187065-1651-3-git-send-email-jayachandranc-oSioyQM9ZPnuBjGU1YDckgC/G2K4zDHf@public.gmane.org>
2012-07-16  3:45       ` Rajeev kumar
2012-07-13 13:44   ` [PATCH v3 3/4] V4L/DVB: mfd: use reg_shift instead of regstep Jayachandran C
2012-07-13 13:44   ` [PATCH v3 4/4] i2c: i2c-ocores: support for 16bit and 32bit IO Jayachandran C
     [not found]     ` <1342187065-1651-5-git-send-email-jayachandranc-oSioyQM9ZPnuBjGU1YDckgC/G2K4zDHf@public.gmane.org>
2012-07-13 13:48       ` Shubhrajyoti Datta
     [not found]         ` <CAM=Q2csMBP7YHgmMob0Npaxo70Quo3-76TNhQawE972zfiLiHA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-07-13 13:58           ` Jayachandran C. [this message]
2012-07-14 10:45   ` [PATCH v3 0/4] I2C Ocores updates Wolfram Sang

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=20120713135848.GC18519@jayachandranc.netlogicmicro.com \
    --to=jayachandranc-osioyqm9zpnubjgu1ydckgc/g2k4zdhf@public.gmane.org \
    --cc=devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org \
    --cc=ganesanr-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    --cc=jacmet-OfajU3CKLf1/SzgSGea1oA@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=omaplinuxkernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=richard.rojfors-gfIc91nka+FZroRs9YW3xA@public.gmane.org \
    --cc=w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).