On Tue, Jul 10, 2012 at 11:40:58AM +0530, Jayachandran C wrote:
> From: Ganesan Ramalingam <[email protected]>
> 
> 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 <[email protected]>
> Signed-off-by: Jayachandran C <[email protected]>
> ---
>  .../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 9617ec1..034d1d5 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;
>       int reg_shift;
> +     int reg_io_width;

u32 again.

>       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));

Hmm, this could be a helper function, probably. But nothing you'd need
to do right now...

Thanks,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

Attachment: signature.asc
Description: Digital signature

Reply via email to