Re: [PATCH v2 1/4] i2c: sunxi: Add Reduced Serial Bus (RSB) support

2015-03-05 Thread Wolfram Sang

> From that regard, RSB is a multiple device bus, using addresses, just
> like I2C. The way it communicates is basically the one used by P2WI.

I am not keen to allow everything which "is a bus and has addresses"
into the I2C realm. The addresses are 12 bit, whilst I2C has at maximum
10 bit which is rarely used, so mostly 7 bit are used. It has a runtime
readdressing mechanism which is not present in standard I2C. And if you
look at the protocol with no acks but parities, IMO it doesn't look
closer to I2C than to other two wire protocols. So, being in I2C needs
more arguments.

And while the outcome could be that it really makes sense to add RSB to
I2C with I2C_FUNCS_RSB added, it could also be that there is a more
suitable place for custom busses in the kernel.

Also, the fact that P2WI is in I2C is not an argument IMO. It could have
been a mistake to pick it up.

> So really, it just is more I2C-alike than P2WI has ever been.

Because it has addresses? I disagree.

> Good thing that we are not talking about a full review then, but more
> a philosophical discussion.

Exactly. This is why I wanted to bring this in early.



signature.asc
Description: Digital signature


Re: [PATCH v2 1/4] i2c: sunxi: Add Reduced Serial Bus (RSB) support

2015-03-05 Thread Maxime Ripard
On Thu, Mar 05, 2015 at 07:40:44PM +0100, Wolfram Sang wrote:
> 
> > > I don't have the bandwidth for a full review right now. However, I
> > > already wanted to tell you guys that my gut feeling is that this
> > > protocol is quite far away from I2C. P2WI was already at the edge.
> > > Maybe there is a better place for such custom stuff? I dunno yet.
> > 
> > That's unfortunate, especially since it looks closer to SPI than what
> > P2WI even was.
> 
> SPI? I assume you mean I2C. Can you elaborate your reasoning?

Yeah, I obviously meant I2C, sorry.

P2WI had no address. It was a single-device bus. However, the way it
communicated with the device was very close to I2C, apart from a
parity bit instead of the ACK.

From that regard, RSB is a multiple device bus, using addresses, just
like I2C. The way it communicates is basically the one used by P2WI.

So really, it just is more I2C-alike than P2WI has ever been.

> > What would be your suggestion?
> 
> Let me quote:
> 
> "I don't have the bandwidth for a full review right now... I dunno
> yet."

Good thing that we are not talking about a full review then, but more
a philosophical discussion.

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


signature.asc
Description: Digital signature


Re: [PATCH v2 1/4] i2c: sunxi: Add Reduced Serial Bus (RSB) support

2015-03-05 Thread Wolfram Sang

> > I don't have the bandwidth for a full review right now. However, I
> > already wanted to tell you guys that my gut feeling is that this
> > protocol is quite far away from I2C. P2WI was already at the edge.
> > Maybe there is a better place for such custom stuff? I dunno yet.
> 
> That's unfortunate, especially since it looks closer to SPI than what
> P2WI even was.

SPI? I assume you mean I2C. Can you elaborate your reasoning?

> What would be your suggestion?

Let me quote:

"I don't have the bandwidth for a full review right now... I dunno
yet."


signature.asc
Description: Digital signature


Re: [PATCH v2 1/4] i2c: sunxi: Add Reduced Serial Bus (RSB) support

2015-03-05 Thread Maxime Ripard
Hi Wolfram,

On Wed, Mar 04, 2015 at 06:27:11PM +0100, Wolfram Sang wrote:
> On Mon, Mar 02, 2015 at 04:24:43PM +0800, Chen-Yu Tsai wrote:
> > The RSB controller looks like an SMBus controller which only supports byte
> > and word data transfers. It can also do double-word data transfers, but the
> > I2C subsystem does not support this, nor have we seen devices using this.
> > 
> > The RSB differs from standard SMBus protocol on several aspects:
> > - it uses addresses set at runtime to address slaves. Runtime addresses
> >   are sent to slaves using their 12bit hardware addresses. Up to 15
> >   runtime addresses are available.
> > - it adds a parity bit every 8bits of data and address for read and
> >   write accesses; this replaces the ack bit
> > - only one read access is required to read a byte (instead of a write
> >   followed by a read access in standard SMBus protocol)
> > - there's no Ack bit after each read access
> > 
> > This means this bus cannot be used to interface with standard SMBus
> > devices (known devices supporting this interface are the AXP223, AXP806,
> > AXP809 PMICs and the AC100 codec/RTC). However the RSB protocol is an
> > extension of P2WI, which was close enough to SMBus to be integrated into
> > the I2C subsystem in commit 3e833490fae5 ("i2c: sunxi: add P2WI (Push/Pull
> > 2 Wire Interface) controller support").
> > 
> > Signed-off-by: Chen-Yu Tsai 
> 
> I don't have the bandwidth for a full review right now. However, I
> already wanted to tell you guys that my gut feeling is that this
> protocol is quite far away from I2C. P2WI was already at the edge.
> Maybe there is a better place for such custom stuff? I dunno yet.

That's unfortunate, especially since it looks closer to SPI than what
P2WI even was.

What would be your suggestion?

Thanks,
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


signature.asc
Description: Digital signature


Re: [PATCH v2 1/4] i2c: sunxi: Add Reduced Serial Bus (RSB) support

2015-03-05 Thread Maxime Ripard
On Thu, Mar 05, 2015 at 07:40:44PM +0100, Wolfram Sang wrote:
 
   I don't have the bandwidth for a full review right now. However, I
   already wanted to tell you guys that my gut feeling is that this
   protocol is quite far away from I2C. P2WI was already at the edge.
   Maybe there is a better place for such custom stuff? I dunno yet.
  
  That's unfortunate, especially since it looks closer to SPI than what
  P2WI even was.
 
 SPI? I assume you mean I2C. Can you elaborate your reasoning?

Yeah, I obviously meant I2C, sorry.

P2WI had no address. It was a single-device bus. However, the way it
communicated with the device was very close to I2C, apart from a
parity bit instead of the ACK.

From that regard, RSB is a multiple device bus, using addresses, just
like I2C. The way it communicates is basically the one used by P2WI.

So really, it just is more I2C-alike than P2WI has ever been.

  What would be your suggestion?
 
 Let me quote:
 
 I don't have the bandwidth for a full review right now... I dunno
 yet.

Good thing that we are not talking about a full review then, but more
a philosophical discussion.

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


signature.asc
Description: Digital signature


Re: [PATCH v2 1/4] i2c: sunxi: Add Reduced Serial Bus (RSB) support

2015-03-05 Thread Wolfram Sang

 From that regard, RSB is a multiple device bus, using addresses, just
 like I2C. The way it communicates is basically the one used by P2WI.

I am not keen to allow everything which is a bus and has addresses
into the I2C realm. The addresses are 12 bit, whilst I2C has at maximum
10 bit which is rarely used, so mostly 7 bit are used. It has a runtime
readdressing mechanism which is not present in standard I2C. And if you
look at the protocol with no acks but parities, IMO it doesn't look
closer to I2C than to other two wire protocols. So, being in I2C needs
more arguments.

And while the outcome could be that it really makes sense to add RSB to
I2C with I2C_FUNCS_RSB added, it could also be that there is a more
suitable place for custom busses in the kernel.

Also, the fact that P2WI is in I2C is not an argument IMO. It could have
been a mistake to pick it up.

 So really, it just is more I2C-alike than P2WI has ever been.

Because it has addresses? I disagree.

 Good thing that we are not talking about a full review then, but more
 a philosophical discussion.

Exactly. This is why I wanted to bring this in early.



signature.asc
Description: Digital signature


Re: [PATCH v2 1/4] i2c: sunxi: Add Reduced Serial Bus (RSB) support

2015-03-05 Thread Maxime Ripard
Hi Wolfram,

On Wed, Mar 04, 2015 at 06:27:11PM +0100, Wolfram Sang wrote:
 On Mon, Mar 02, 2015 at 04:24:43PM +0800, Chen-Yu Tsai wrote:
  The RSB controller looks like an SMBus controller which only supports byte
  and word data transfers. It can also do double-word data transfers, but the
  I2C subsystem does not support this, nor have we seen devices using this.
  
  The RSB differs from standard SMBus protocol on several aspects:
  - it uses addresses set at runtime to address slaves. Runtime addresses
are sent to slaves using their 12bit hardware addresses. Up to 15
runtime addresses are available.
  - it adds a parity bit every 8bits of data and address for read and
write accesses; this replaces the ack bit
  - only one read access is required to read a byte (instead of a write
followed by a read access in standard SMBus protocol)
  - there's no Ack bit after each read access
  
  This means this bus cannot be used to interface with standard SMBus
  devices (known devices supporting this interface are the AXP223, AXP806,
  AXP809 PMICs and the AC100 codec/RTC). However the RSB protocol is an
  extension of P2WI, which was close enough to SMBus to be integrated into
  the I2C subsystem in commit 3e833490fae5 (i2c: sunxi: add P2WI (Push/Pull
  2 Wire Interface) controller support).
  
  Signed-off-by: Chen-Yu Tsai w...@csie.org
 
 I don't have the bandwidth for a full review right now. However, I
 already wanted to tell you guys that my gut feeling is that this
 protocol is quite far away from I2C. P2WI was already at the edge.
 Maybe there is a better place for such custom stuff? I dunno yet.

That's unfortunate, especially since it looks closer to SPI than what
P2WI even was.

What would be your suggestion?

Thanks,
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


signature.asc
Description: Digital signature


Re: [PATCH v2 1/4] i2c: sunxi: Add Reduced Serial Bus (RSB) support

2015-03-05 Thread Wolfram Sang

  I don't have the bandwidth for a full review right now. However, I
  already wanted to tell you guys that my gut feeling is that this
  protocol is quite far away from I2C. P2WI was already at the edge.
  Maybe there is a better place for such custom stuff? I dunno yet.
 
 That's unfortunate, especially since it looks closer to SPI than what
 P2WI even was.

SPI? I assume you mean I2C. Can you elaborate your reasoning?

 What would be your suggestion?

Let me quote:

I don't have the bandwidth for a full review right now... I dunno
yet.


signature.asc
Description: Digital signature


Re: [PATCH v2 1/4] i2c: sunxi: Add Reduced Serial Bus (RSB) support

2015-03-04 Thread Wolfram Sang
On Mon, Mar 02, 2015 at 04:24:43PM +0800, Chen-Yu Tsai wrote:
> The RSB controller looks like an SMBus controller which only supports byte
> and word data transfers. It can also do double-word data transfers, but the
> I2C subsystem does not support this, nor have we seen devices using this.
> 
> The RSB differs from standard SMBus protocol on several aspects:
> - it uses addresses set at runtime to address slaves. Runtime addresses
>   are sent to slaves using their 12bit hardware addresses. Up to 15
>   runtime addresses are available.
> - it adds a parity bit every 8bits of data and address for read and
>   write accesses; this replaces the ack bit
> - only one read access is required to read a byte (instead of a write
>   followed by a read access in standard SMBus protocol)
> - there's no Ack bit after each read access
> 
> This means this bus cannot be used to interface with standard SMBus
> devices (known devices supporting this interface are the AXP223, AXP806,
> AXP809 PMICs and the AC100 codec/RTC). However the RSB protocol is an
> extension of P2WI, which was close enough to SMBus to be integrated into
> the I2C subsystem in commit 3e833490fae5 ("i2c: sunxi: add P2WI (Push/Pull
> 2 Wire Interface) controller support").
> 
> Signed-off-by: Chen-Yu Tsai 

I don't have the bandwidth for a full review right now. However, I
already wanted to tell you guys that my gut feeling is that this
protocol is quite far away from I2C. P2WI was already at the edge.
Maybe there is a better place for such custom stuff? I dunno yet.

Thanks,

   Wolfram

> ---
>  drivers/i2c/busses/Kconfig |  12 +
>  drivers/i2c/busses/Makefile|   1 +
>  drivers/i2c/busses/i2c-sunxi-rsb.c | 458 
> +
>  3 files changed, 471 insertions(+)
>  create mode 100644 drivers/i2c/busses/i2c-sunxi-rsb.c
> 
> diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
> index 22da9c2ffa22..cf9337877181 100644
> --- a/drivers/i2c/busses/Kconfig
> +++ b/drivers/i2c/busses/Kconfig
> @@ -840,6 +840,18 @@ config I2C_SUN6I_P2WI
> This interface is used to connect to specific PMIC devices (like the
> AXP221).
>  
> +config I2C_SUNXI_RSB
> + tristate "Allwinner Reduced Serial Bus controller"
> + depends on RESET_CONTROLLER
> + depends on MACH_SUN8I || MACH_SUN9I || COMPILE_TEST
> + help
> +   If you say yes to this option, support will be included for the
> +   Reduced Serial Bus controller embedded in some sunxi SOCs.
> +   The RSB looks like an SMBus controller (which supports only byte
> +   accesses), but requires setting runtime addresses for slave devices.
> +   This interface is used to connect to specific PMIC devices (like the
> +   AXP223) or peripherals (like the AC100).
> +
>  config I2C_TEGRA
>   tristate "NVIDIA Tegra internal I2C controller"
>   depends on ARCH_TEGRA
> diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
> index 3638feb6677e..f95d50315003 100644
> --- a/drivers/i2c/busses/Makefile
> +++ b/drivers/i2c/busses/Makefile
> @@ -81,6 +81,7 @@ obj-$(CONFIG_I2C_SIRF)  += i2c-sirf.o
>  obj-$(CONFIG_I2C_ST) += i2c-st.o
>  obj-$(CONFIG_I2C_STU300) += i2c-stu300.o
>  obj-$(CONFIG_I2C_SUN6I_P2WI) += i2c-sun6i-p2wi.o
> +obj-$(CONFIG_I2C_SUNXI_RSB)  += i2c-sunxi-rsb.o
>  obj-$(CONFIG_I2C_TEGRA)  += i2c-tegra.o
>  obj-$(CONFIG_I2C_VERSATILE)  += i2c-versatile.o
>  obj-$(CONFIG_I2C_WMT)+= i2c-wmt.o
> diff --git a/drivers/i2c/busses/i2c-sunxi-rsb.c 
> b/drivers/i2c/busses/i2c-sunxi-rsb.c
> new file mode 100644
> index ..7e9be3e14b8a
> --- /dev/null
> +++ b/drivers/i2c/busses/i2c-sunxi-rsb.c
> @@ -0,0 +1,458 @@
> +/*
> + * RSB (Reduced Serial Bus) driver.
> + *
> + * Author: Chen-Yu Tsai 
> + *
> + * This file is licensed under the terms of the GNU General Public License
> + * version 2.  This program is licensed "as is" without any warranty of any
> + * kind, whether express or implied.
> + *
> + * The RSB controller looks like an SMBus controller which only supports
> + * byte and word data transfers. But, it differs from standard SMBus
> + * protocol on several aspects:
> + * - it uses addresses set at runtime to address slaves. Runtime addresses
> + *   are sent to slaves using their 12bit hardware addresses. Up to 15
> + *   runtime addresses are available.
> + * - it adds a parity bit every 8bits of data and address for read and
> + *   write accesses; this replaces the ack bit
> + * - only one read access is required to read a byte (instead of a write
> + *   followed by a read access in standard SMBus protocol)
> + * - there's no Ack bit after each read access
> + *
> + * This means this bus cannot be used to interface with standard SMBus
> + * devices. Devices known to support this interface include the AXP223,
> + * AXP809, and AXP806 PMICs, and the AC100 audio codec, all from X-Powers.
> + *
> + * A description of the 

Re: [PATCH v2 1/4] i2c: sunxi: Add Reduced Serial Bus (RSB) support

2015-03-04 Thread Maxime Ripard
Hi,

On Mon, Mar 02, 2015 at 04:24:43PM +0800, Chen-Yu Tsai wrote:
> The RSB controller looks like an SMBus controller which only supports byte
> and word data transfers. It can also do double-word data transfers, but the
> I2C subsystem does not support this, nor have we seen devices using this.
> 
> The RSB differs from standard SMBus protocol on several aspects:
> - it uses addresses set at runtime to address slaves. Runtime addresses
>   are sent to slaves using their 12bit hardware addresses. Up to 15
>   runtime addresses are available.
> - it adds a parity bit every 8bits of data and address for read and
>   write accesses; this replaces the ack bit
> - only one read access is required to read a byte (instead of a write
>   followed by a read access in standard SMBus protocol)
> - there's no Ack bit after each read access
> 
> This means this bus cannot be used to interface with standard SMBus
> devices (known devices supporting this interface are the AXP223, AXP806,
> AXP809 PMICs and the AC100 codec/RTC). However the RSB protocol is an
> extension of P2WI, which was close enough to SMBus to be integrated into
> the I2C subsystem in commit 3e833490fae5 ("i2c: sunxi: add P2WI (Push/Pull
> 2 Wire Interface) controller support").
> 
> Signed-off-by: Chen-Yu Tsai 
> ---
>  drivers/i2c/busses/Kconfig |  12 +
>  drivers/i2c/busses/Makefile|   1 +
>  drivers/i2c/busses/i2c-sunxi-rsb.c | 458 
> +
>  3 files changed, 471 insertions(+)
>  create mode 100644 drivers/i2c/busses/i2c-sunxi-rsb.c
> 
> diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
> index 22da9c2ffa22..cf9337877181 100644
> --- a/drivers/i2c/busses/Kconfig
> +++ b/drivers/i2c/busses/Kconfig
> @@ -840,6 +840,18 @@ config I2C_SUN6I_P2WI
> This interface is used to connect to specific PMIC devices (like the
> AXP221).
>  
> +config I2C_SUNXI_RSB
> + tristate "Allwinner Reduced Serial Bus controller"
> + depends on RESET_CONTROLLER
> + depends on MACH_SUN8I || MACH_SUN9I || COMPILE_TEST
> + help
> +   If you say yes to this option, support will be included for the
> +   Reduced Serial Bus controller embedded in some sunxi SOCs.
> +   The RSB looks like an SMBus controller (which supports only byte
> +   accesses), but requires setting runtime addresses for slave devices.
> +   This interface is used to connect to specific PMIC devices (like the
> +   AXP223) or peripherals (like the AC100).
> +
>  config I2C_TEGRA
>   tristate "NVIDIA Tegra internal I2C controller"
>   depends on ARCH_TEGRA
> diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
> index 3638feb6677e..f95d50315003 100644
> --- a/drivers/i2c/busses/Makefile
> +++ b/drivers/i2c/busses/Makefile
> @@ -81,6 +81,7 @@ obj-$(CONFIG_I2C_SIRF)  += i2c-sirf.o
>  obj-$(CONFIG_I2C_ST) += i2c-st.o
>  obj-$(CONFIG_I2C_STU300) += i2c-stu300.o
>  obj-$(CONFIG_I2C_SUN6I_P2WI) += i2c-sun6i-p2wi.o
> +obj-$(CONFIG_I2C_SUNXI_RSB)  += i2c-sunxi-rsb.o
>  obj-$(CONFIG_I2C_TEGRA)  += i2c-tegra.o
>  obj-$(CONFIG_I2C_VERSATILE)  += i2c-versatile.o
>  obj-$(CONFIG_I2C_WMT)+= i2c-wmt.o
> diff --git a/drivers/i2c/busses/i2c-sunxi-rsb.c 
> b/drivers/i2c/busses/i2c-sunxi-rsb.c
> new file mode 100644
> index ..7e9be3e14b8a
> --- /dev/null
> +++ b/drivers/i2c/busses/i2c-sunxi-rsb.c
> @@ -0,0 +1,458 @@
> +/*
> + * RSB (Reduced Serial Bus) driver.
> + *
> + * Author: Chen-Yu Tsai 
> + *
> + * This file is licensed under the terms of the GNU General Public License
> + * version 2.  This program is licensed "as is" without any warranty of any
> + * kind, whether express or implied.
> + *
> + * The RSB controller looks like an SMBus controller which only supports
> + * byte and word data transfers. But, it differs from standard SMBus
> + * protocol on several aspects:
> + * - it uses addresses set at runtime to address slaves. Runtime addresses
> + *   are sent to slaves using their 12bit hardware addresses. Up to 15
> + *   runtime addresses are available.
> + * - it adds a parity bit every 8bits of data and address for read and
> + *   write accesses; this replaces the ack bit
> + * - only one read access is required to read a byte (instead of a write
> + *   followed by a read access in standard SMBus protocol)
> + * - there's no Ack bit after each read access
> + *
> + * This means this bus cannot be used to interface with standard SMBus
> + * devices. Devices known to support this interface include the AXP223,
> + * AXP809, and AXP806 PMICs, and the AC100 audio codec, all from X-Powers.
> + *
> + * A description of the operation and wire protocol can be found in the
> + * RSB section of Allwinner's A80 user manual, which can be found at
> + *
> + * https://github.com/allwinner-zh/documents/tree/master/A80
> + *
> + * This document is officially released by Allwinner.
> + *
> + * This driver is based 

Re: [PATCH v2 1/4] i2c: sunxi: Add Reduced Serial Bus (RSB) support

2015-03-04 Thread Wolfram Sang
On Mon, Mar 02, 2015 at 04:24:43PM +0800, Chen-Yu Tsai wrote:
 The RSB controller looks like an SMBus controller which only supports byte
 and word data transfers. It can also do double-word data transfers, but the
 I2C subsystem does not support this, nor have we seen devices using this.
 
 The RSB differs from standard SMBus protocol on several aspects:
 - it uses addresses set at runtime to address slaves. Runtime addresses
   are sent to slaves using their 12bit hardware addresses. Up to 15
   runtime addresses are available.
 - it adds a parity bit every 8bits of data and address for read and
   write accesses; this replaces the ack bit
 - only one read access is required to read a byte (instead of a write
   followed by a read access in standard SMBus protocol)
 - there's no Ack bit after each read access
 
 This means this bus cannot be used to interface with standard SMBus
 devices (known devices supporting this interface are the AXP223, AXP806,
 AXP809 PMICs and the AC100 codec/RTC). However the RSB protocol is an
 extension of P2WI, which was close enough to SMBus to be integrated into
 the I2C subsystem in commit 3e833490fae5 (i2c: sunxi: add P2WI (Push/Pull
 2 Wire Interface) controller support).
 
 Signed-off-by: Chen-Yu Tsai w...@csie.org

I don't have the bandwidth for a full review right now. However, I
already wanted to tell you guys that my gut feeling is that this
protocol is quite far away from I2C. P2WI was already at the edge.
Maybe there is a better place for such custom stuff? I dunno yet.

Thanks,

   Wolfram

 ---
  drivers/i2c/busses/Kconfig |  12 +
  drivers/i2c/busses/Makefile|   1 +
  drivers/i2c/busses/i2c-sunxi-rsb.c | 458 
 +
  3 files changed, 471 insertions(+)
  create mode 100644 drivers/i2c/busses/i2c-sunxi-rsb.c
 
 diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
 index 22da9c2ffa22..cf9337877181 100644
 --- a/drivers/i2c/busses/Kconfig
 +++ b/drivers/i2c/busses/Kconfig
 @@ -840,6 +840,18 @@ config I2C_SUN6I_P2WI
 This interface is used to connect to specific PMIC devices (like the
 AXP221).
  
 +config I2C_SUNXI_RSB
 + tristate Allwinner Reduced Serial Bus controller
 + depends on RESET_CONTROLLER
 + depends on MACH_SUN8I || MACH_SUN9I || COMPILE_TEST
 + help
 +   If you say yes to this option, support will be included for the
 +   Reduced Serial Bus controller embedded in some sunxi SOCs.
 +   The RSB looks like an SMBus controller (which supports only byte
 +   accesses), but requires setting runtime addresses for slave devices.
 +   This interface is used to connect to specific PMIC devices (like the
 +   AXP223) or peripherals (like the AC100).
 +
  config I2C_TEGRA
   tristate NVIDIA Tegra internal I2C controller
   depends on ARCH_TEGRA
 diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
 index 3638feb6677e..f95d50315003 100644
 --- a/drivers/i2c/busses/Makefile
 +++ b/drivers/i2c/busses/Makefile
 @@ -81,6 +81,7 @@ obj-$(CONFIG_I2C_SIRF)  += i2c-sirf.o
  obj-$(CONFIG_I2C_ST) += i2c-st.o
  obj-$(CONFIG_I2C_STU300) += i2c-stu300.o
  obj-$(CONFIG_I2C_SUN6I_P2WI) += i2c-sun6i-p2wi.o
 +obj-$(CONFIG_I2C_SUNXI_RSB)  += i2c-sunxi-rsb.o
  obj-$(CONFIG_I2C_TEGRA)  += i2c-tegra.o
  obj-$(CONFIG_I2C_VERSATILE)  += i2c-versatile.o
  obj-$(CONFIG_I2C_WMT)+= i2c-wmt.o
 diff --git a/drivers/i2c/busses/i2c-sunxi-rsb.c 
 b/drivers/i2c/busses/i2c-sunxi-rsb.c
 new file mode 100644
 index ..7e9be3e14b8a
 --- /dev/null
 +++ b/drivers/i2c/busses/i2c-sunxi-rsb.c
 @@ -0,0 +1,458 @@
 +/*
 + * RSB (Reduced Serial Bus) driver.
 + *
 + * Author: Chen-Yu Tsai w...@csie.org
 + *
 + * This file is licensed under the terms of the GNU General Public License
 + * version 2.  This program is licensed as is without any warranty of any
 + * kind, whether express or implied.
 + *
 + * The RSB controller looks like an SMBus controller which only supports
 + * byte and word data transfers. But, it differs from standard SMBus
 + * protocol on several aspects:
 + * - it uses addresses set at runtime to address slaves. Runtime addresses
 + *   are sent to slaves using their 12bit hardware addresses. Up to 15
 + *   runtime addresses are available.
 + * - it adds a parity bit every 8bits of data and address for read and
 + *   write accesses; this replaces the ack bit
 + * - only one read access is required to read a byte (instead of a write
 + *   followed by a read access in standard SMBus protocol)
 + * - there's no Ack bit after each read access
 + *
 + * This means this bus cannot be used to interface with standard SMBus
 + * devices. Devices known to support this interface include the AXP223,
 + * AXP809, and AXP806 PMICs, and the AC100 audio codec, all from X-Powers.
 + *
 + * A description of the operation and wire protocol can be found in the
 + * RSB section of Allwinner's A80 

Re: [PATCH v2 1/4] i2c: sunxi: Add Reduced Serial Bus (RSB) support

2015-03-04 Thread Maxime Ripard
Hi,

On Mon, Mar 02, 2015 at 04:24:43PM +0800, Chen-Yu Tsai wrote:
 The RSB controller looks like an SMBus controller which only supports byte
 and word data transfers. It can also do double-word data transfers, but the
 I2C subsystem does not support this, nor have we seen devices using this.
 
 The RSB differs from standard SMBus protocol on several aspects:
 - it uses addresses set at runtime to address slaves. Runtime addresses
   are sent to slaves using their 12bit hardware addresses. Up to 15
   runtime addresses are available.
 - it adds a parity bit every 8bits of data and address for read and
   write accesses; this replaces the ack bit
 - only one read access is required to read a byte (instead of a write
   followed by a read access in standard SMBus protocol)
 - there's no Ack bit after each read access
 
 This means this bus cannot be used to interface with standard SMBus
 devices (known devices supporting this interface are the AXP223, AXP806,
 AXP809 PMICs and the AC100 codec/RTC). However the RSB protocol is an
 extension of P2WI, which was close enough to SMBus to be integrated into
 the I2C subsystem in commit 3e833490fae5 (i2c: sunxi: add P2WI (Push/Pull
 2 Wire Interface) controller support).
 
 Signed-off-by: Chen-Yu Tsai w...@csie.org
 ---
  drivers/i2c/busses/Kconfig |  12 +
  drivers/i2c/busses/Makefile|   1 +
  drivers/i2c/busses/i2c-sunxi-rsb.c | 458 
 +
  3 files changed, 471 insertions(+)
  create mode 100644 drivers/i2c/busses/i2c-sunxi-rsb.c
 
 diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
 index 22da9c2ffa22..cf9337877181 100644
 --- a/drivers/i2c/busses/Kconfig
 +++ b/drivers/i2c/busses/Kconfig
 @@ -840,6 +840,18 @@ config I2C_SUN6I_P2WI
 This interface is used to connect to specific PMIC devices (like the
 AXP221).
  
 +config I2C_SUNXI_RSB
 + tristate Allwinner Reduced Serial Bus controller
 + depends on RESET_CONTROLLER
 + depends on MACH_SUN8I || MACH_SUN9I || COMPILE_TEST
 + help
 +   If you say yes to this option, support will be included for the
 +   Reduced Serial Bus controller embedded in some sunxi SOCs.
 +   The RSB looks like an SMBus controller (which supports only byte
 +   accesses), but requires setting runtime addresses for slave devices.
 +   This interface is used to connect to specific PMIC devices (like the
 +   AXP223) or peripherals (like the AC100).
 +
  config I2C_TEGRA
   tristate NVIDIA Tegra internal I2C controller
   depends on ARCH_TEGRA
 diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
 index 3638feb6677e..f95d50315003 100644
 --- a/drivers/i2c/busses/Makefile
 +++ b/drivers/i2c/busses/Makefile
 @@ -81,6 +81,7 @@ obj-$(CONFIG_I2C_SIRF)  += i2c-sirf.o
  obj-$(CONFIG_I2C_ST) += i2c-st.o
  obj-$(CONFIG_I2C_STU300) += i2c-stu300.o
  obj-$(CONFIG_I2C_SUN6I_P2WI) += i2c-sun6i-p2wi.o
 +obj-$(CONFIG_I2C_SUNXI_RSB)  += i2c-sunxi-rsb.o
  obj-$(CONFIG_I2C_TEGRA)  += i2c-tegra.o
  obj-$(CONFIG_I2C_VERSATILE)  += i2c-versatile.o
  obj-$(CONFIG_I2C_WMT)+= i2c-wmt.o
 diff --git a/drivers/i2c/busses/i2c-sunxi-rsb.c 
 b/drivers/i2c/busses/i2c-sunxi-rsb.c
 new file mode 100644
 index ..7e9be3e14b8a
 --- /dev/null
 +++ b/drivers/i2c/busses/i2c-sunxi-rsb.c
 @@ -0,0 +1,458 @@
 +/*
 + * RSB (Reduced Serial Bus) driver.
 + *
 + * Author: Chen-Yu Tsai w...@csie.org
 + *
 + * This file is licensed under the terms of the GNU General Public License
 + * version 2.  This program is licensed as is without any warranty of any
 + * kind, whether express or implied.
 + *
 + * The RSB controller looks like an SMBus controller which only supports
 + * byte and word data transfers. But, it differs from standard SMBus
 + * protocol on several aspects:
 + * - it uses addresses set at runtime to address slaves. Runtime addresses
 + *   are sent to slaves using their 12bit hardware addresses. Up to 15
 + *   runtime addresses are available.
 + * - it adds a parity bit every 8bits of data and address for read and
 + *   write accesses; this replaces the ack bit
 + * - only one read access is required to read a byte (instead of a write
 + *   followed by a read access in standard SMBus protocol)
 + * - there's no Ack bit after each read access
 + *
 + * This means this bus cannot be used to interface with standard SMBus
 + * devices. Devices known to support this interface include the AXP223,
 + * AXP809, and AXP806 PMICs, and the AC100 audio codec, all from X-Powers.
 + *
 + * A description of the operation and wire protocol can be found in the
 + * RSB section of Allwinner's A80 user manual, which can be found at
 + *
 + * https://github.com/allwinner-zh/documents/tree/master/A80
 + *
 + * This document is officially released by Allwinner.
 + *
 + * This driver is based on i2c-sun6i-p2wi.c, the P2WI bus driver.
 + *
 + */
 +#include linux/clk.h
 +#include 

[PATCH v2 1/4] i2c: sunxi: Add Reduced Serial Bus (RSB) support

2015-03-02 Thread Chen-Yu Tsai
The RSB controller looks like an SMBus controller which only supports byte
and word data transfers. It can also do double-word data transfers, but the
I2C subsystem does not support this, nor have we seen devices using this.

The RSB differs from standard SMBus protocol on several aspects:
- it uses addresses set at runtime to address slaves. Runtime addresses
  are sent to slaves using their 12bit hardware addresses. Up to 15
  runtime addresses are available.
- it adds a parity bit every 8bits of data and address for read and
  write accesses; this replaces the ack bit
- only one read access is required to read a byte (instead of a write
  followed by a read access in standard SMBus protocol)
- there's no Ack bit after each read access

This means this bus cannot be used to interface with standard SMBus
devices (known devices supporting this interface are the AXP223, AXP806,
AXP809 PMICs and the AC100 codec/RTC). However the RSB protocol is an
extension of P2WI, which was close enough to SMBus to be integrated into
the I2C subsystem in commit 3e833490fae5 ("i2c: sunxi: add P2WI (Push/Pull
2 Wire Interface) controller support").

Signed-off-by: Chen-Yu Tsai 
---
 drivers/i2c/busses/Kconfig |  12 +
 drivers/i2c/busses/Makefile|   1 +
 drivers/i2c/busses/i2c-sunxi-rsb.c | 458 +
 3 files changed, 471 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-sunxi-rsb.c

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 22da9c2ffa22..cf9337877181 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -840,6 +840,18 @@ config I2C_SUN6I_P2WI
  This interface is used to connect to specific PMIC devices (like the
  AXP221).
 
+config I2C_SUNXI_RSB
+   tristate "Allwinner Reduced Serial Bus controller"
+   depends on RESET_CONTROLLER
+   depends on MACH_SUN8I || MACH_SUN9I || COMPILE_TEST
+   help
+ If you say yes to this option, support will be included for the
+ Reduced Serial Bus controller embedded in some sunxi SOCs.
+ The RSB looks like an SMBus controller (which supports only byte
+ accesses), but requires setting runtime addresses for slave devices.
+ This interface is used to connect to specific PMIC devices (like the
+ AXP223) or peripherals (like the AC100).
+
 config I2C_TEGRA
tristate "NVIDIA Tegra internal I2C controller"
depends on ARCH_TEGRA
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 3638feb6677e..f95d50315003 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -81,6 +81,7 @@ obj-$(CONFIG_I2C_SIRF)+= i2c-sirf.o
 obj-$(CONFIG_I2C_ST)   += i2c-st.o
 obj-$(CONFIG_I2C_STU300)   += i2c-stu300.o
 obj-$(CONFIG_I2C_SUN6I_P2WI)   += i2c-sun6i-p2wi.o
+obj-$(CONFIG_I2C_SUNXI_RSB)+= i2c-sunxi-rsb.o
 obj-$(CONFIG_I2C_TEGRA)+= i2c-tegra.o
 obj-$(CONFIG_I2C_VERSATILE)+= i2c-versatile.o
 obj-$(CONFIG_I2C_WMT)  += i2c-wmt.o
diff --git a/drivers/i2c/busses/i2c-sunxi-rsb.c 
b/drivers/i2c/busses/i2c-sunxi-rsb.c
new file mode 100644
index ..7e9be3e14b8a
--- /dev/null
+++ b/drivers/i2c/busses/i2c-sunxi-rsb.c
@@ -0,0 +1,458 @@
+/*
+ * RSB (Reduced Serial Bus) driver.
+ *
+ * Author: Chen-Yu Tsai 
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2.  This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ *
+ * The RSB controller looks like an SMBus controller which only supports
+ * byte and word data transfers. But, it differs from standard SMBus
+ * protocol on several aspects:
+ * - it uses addresses set at runtime to address slaves. Runtime addresses
+ *   are sent to slaves using their 12bit hardware addresses. Up to 15
+ *   runtime addresses are available.
+ * - it adds a parity bit every 8bits of data and address for read and
+ *   write accesses; this replaces the ack bit
+ * - only one read access is required to read a byte (instead of a write
+ *   followed by a read access in standard SMBus protocol)
+ * - there's no Ack bit after each read access
+ *
+ * This means this bus cannot be used to interface with standard SMBus
+ * devices. Devices known to support this interface include the AXP223,
+ * AXP809, and AXP806 PMICs, and the AC100 audio codec, all from X-Powers.
+ *
+ * A description of the operation and wire protocol can be found in the
+ * RSB section of Allwinner's A80 user manual, which can be found at
+ *
+ * https://github.com/allwinner-zh/documents/tree/master/A80
+ *
+ * This document is officially released by Allwinner.
+ *
+ * This driver is based on i2c-sun6i-p2wi.c, the P2WI bus driver.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+
+/* RSB registers */
+#define RSB_CTRL   0x0 /* Global control */
+#define 

[PATCH v2 1/4] i2c: sunxi: Add Reduced Serial Bus (RSB) support

2015-03-02 Thread Chen-Yu Tsai
The RSB controller looks like an SMBus controller which only supports byte
and word data transfers. It can also do double-word data transfers, but the
I2C subsystem does not support this, nor have we seen devices using this.

The RSB differs from standard SMBus protocol on several aspects:
- it uses addresses set at runtime to address slaves. Runtime addresses
  are sent to slaves using their 12bit hardware addresses. Up to 15
  runtime addresses are available.
- it adds a parity bit every 8bits of data and address for read and
  write accesses; this replaces the ack bit
- only one read access is required to read a byte (instead of a write
  followed by a read access in standard SMBus protocol)
- there's no Ack bit after each read access

This means this bus cannot be used to interface with standard SMBus
devices (known devices supporting this interface are the AXP223, AXP806,
AXP809 PMICs and the AC100 codec/RTC). However the RSB protocol is an
extension of P2WI, which was close enough to SMBus to be integrated into
the I2C subsystem in commit 3e833490fae5 (i2c: sunxi: add P2WI (Push/Pull
2 Wire Interface) controller support).

Signed-off-by: Chen-Yu Tsai w...@csie.org
---
 drivers/i2c/busses/Kconfig |  12 +
 drivers/i2c/busses/Makefile|   1 +
 drivers/i2c/busses/i2c-sunxi-rsb.c | 458 +
 3 files changed, 471 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-sunxi-rsb.c

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 22da9c2ffa22..cf9337877181 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -840,6 +840,18 @@ config I2C_SUN6I_P2WI
  This interface is used to connect to specific PMIC devices (like the
  AXP221).
 
+config I2C_SUNXI_RSB
+   tristate Allwinner Reduced Serial Bus controller
+   depends on RESET_CONTROLLER
+   depends on MACH_SUN8I || MACH_SUN9I || COMPILE_TEST
+   help
+ If you say yes to this option, support will be included for the
+ Reduced Serial Bus controller embedded in some sunxi SOCs.
+ The RSB looks like an SMBus controller (which supports only byte
+ accesses), but requires setting runtime addresses for slave devices.
+ This interface is used to connect to specific PMIC devices (like the
+ AXP223) or peripherals (like the AC100).
+
 config I2C_TEGRA
tristate NVIDIA Tegra internal I2C controller
depends on ARCH_TEGRA
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 3638feb6677e..f95d50315003 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -81,6 +81,7 @@ obj-$(CONFIG_I2C_SIRF)+= i2c-sirf.o
 obj-$(CONFIG_I2C_ST)   += i2c-st.o
 obj-$(CONFIG_I2C_STU300)   += i2c-stu300.o
 obj-$(CONFIG_I2C_SUN6I_P2WI)   += i2c-sun6i-p2wi.o
+obj-$(CONFIG_I2C_SUNXI_RSB)+= i2c-sunxi-rsb.o
 obj-$(CONFIG_I2C_TEGRA)+= i2c-tegra.o
 obj-$(CONFIG_I2C_VERSATILE)+= i2c-versatile.o
 obj-$(CONFIG_I2C_WMT)  += i2c-wmt.o
diff --git a/drivers/i2c/busses/i2c-sunxi-rsb.c 
b/drivers/i2c/busses/i2c-sunxi-rsb.c
new file mode 100644
index ..7e9be3e14b8a
--- /dev/null
+++ b/drivers/i2c/busses/i2c-sunxi-rsb.c
@@ -0,0 +1,458 @@
+/*
+ * RSB (Reduced Serial Bus) driver.
+ *
+ * Author: Chen-Yu Tsai w...@csie.org
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2.  This program is licensed as is without any warranty of any
+ * kind, whether express or implied.
+ *
+ * The RSB controller looks like an SMBus controller which only supports
+ * byte and word data transfers. But, it differs from standard SMBus
+ * protocol on several aspects:
+ * - it uses addresses set at runtime to address slaves. Runtime addresses
+ *   are sent to slaves using their 12bit hardware addresses. Up to 15
+ *   runtime addresses are available.
+ * - it adds a parity bit every 8bits of data and address for read and
+ *   write accesses; this replaces the ack bit
+ * - only one read access is required to read a byte (instead of a write
+ *   followed by a read access in standard SMBus protocol)
+ * - there's no Ack bit after each read access
+ *
+ * This means this bus cannot be used to interface with standard SMBus
+ * devices. Devices known to support this interface include the AXP223,
+ * AXP809, and AXP806 PMICs, and the AC100 audio codec, all from X-Powers.
+ *
+ * A description of the operation and wire protocol can be found in the
+ * RSB section of Allwinner's A80 user manual, which can be found at
+ *
+ * https://github.com/allwinner-zh/documents/tree/master/A80
+ *
+ * This document is officially released by Allwinner.
+ *
+ * This driver is based on i2c-sun6i-p2wi.c, the P2WI bus driver.
+ *
+ */
+#include linux/clk.h
+#include linux/i2c.h
+#include linux/io.h
+#include linux/interrupt.h
+#include linux/jiffies.h
+#include linux/module.h
+#include linux/of.h