[U-Boot] [PATCH] arm: mvebu: move i2c slave disable to generic SPL code

Chris Packham judge.packham at gmail.com
Mon May 28 08:55:22 UTC 2018


Hi Baruch,

On Mon, May 28, 2018 at 8:22 PM Baruch Siach <baruch at tkos.co.il> wrote:

> Hi Chris,

> On Mon, May 28, 2018 at 08:11:39PM +1200, Chris Packham wrote:
> > On Mon, May 28, 2018 at 3:27 AM Baruch Siach <baruch at tkos.co.il> wrote:
> > > The hidden i2c slave that interferes the i2c bus is not board
specific.
> > > All Armada 38x SoCs are affected. Move the code disabling this slave
to
> > > generic code to make it work on all affected hardware.
> >
> > I can't find a definition of this but the register seems to work for
> > kirkwood as well (not surprising since it's probably a common IP
block). Is
> > there any chance we can find a home for this that's available to boards
> > that don't use SPL?

> This workaround is Armada 38x specific. Are you aware of any 38x SoC based
> system that does not use SPL?

> As far as I can see 38x support requires SPL. CONFIG_ARMADA_38X selects
> CONFIG_ARMADA_32BIT that in turn selects CONFIG_SPL_DM. CONFIG_SPL_DM
depends
> on CONFIG_SPL.

The original workaround was implemented for the Turris Omnia board, as
you've highlighted this is debug register is documented for Armada-385. On
a hunch I tried clearing bit 18 of register 0xf101108c on a Kirkwood based
board and found that it also works to suppress the 0x64 self address. It's
highly likely that the i2c block is common to many Marvell SoCs and it just
happens to be documented on A-385.

If we could get this into the mvtwsi.c driver we could allow other SoCs to
disable the self address. Because it's only documented on A-385 we probably
don't want to do this unconditionally (unless someone on Marvell's SoC team
can confirm this register is valid) but I can confirm it works for Kirkwood.


> baruch

> > > Cc: Marek BehĂșn <marek.behun at nic.cz>
> > > Cc: Rabeeh Khoury <rabeeh at solid-run.com>
> > > Signed-off-by: Baruch Siach <baruch at tkos.co.il>
> > > ---
> > >   arch/arm/mach-mvebu/spl.c                | 16 ++++++++++++++++
> > >   board/CZ.NIC/turris_omnia/turris_omnia.c |  9 ---------
> > >   2 files changed, 16 insertions(+), 9 deletions(-)
> >
> > > diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
> > > index 50b24f5760b7..cbd900fee5d1 100644
> > > --- a/arch/arm/mach-mvebu/spl.c
> > > +++ b/arch/arm/mach-mvebu/spl.c
> > > @@ -8,10 +8,13 @@
> > >   #include <debug_uart.h>
> > >   #include <fdtdec.h>
> > >   #include <spl.h>
> > > +#include <linux/bitops.h>
> > >   #include <asm/io.h>
> > >   #include <asm/arch/cpu.h>
> > >   #include <asm/arch/soc.h>
> >
> > > +#define MVTWSI_ARMADA_DEBUG_REG        0x8c
> > > +
> > >   static u32 get_boot_device(void)
> > >   {
> > >          u32 val;
> > > @@ -69,10 +72,23 @@ u32 spl_boot_device(void)
> > >          return get_boot_device();
> > >   }
> >
> > > +static void disable_i2c_slave(void)
> > > +{
> > > +       u32 i2c_debug_reg;
> > > +
> > > +       /* Disable I2C debug mode blocking 0x64 I2C address */
> > > +       i2c_debug_reg = readl(MVEBU_TWSI_BASE +
MVTWSI_ARMADA_DEBUG_REG);
> > > +       i2c_debug_reg &= ~BIT(18);
> > > +       writel(i2c_debug_reg, MVEBU_TWSI_BASE +
MVTWSI_ARMADA_DEBUG_REG);
> > > +}
> > > +
> > >   void board_init_f(ulong dummy)
> > >   {
> > >          int ret;
> >
> > > +       if (IS_ENABLED(CONFIG_ARMADA_38X))
> > > +               disable_i2c_slave();
> > > +
> > >          /*
> > >           * Pin muxing needs to be done before UART output, since
> > >           * on A38x the UART pins need some re-muxing for output
> > > diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c
> > b/board/CZ.NIC/turris_omnia/turris_omnia.c
> > > index da663cf1bb0c..044c959d1b13 100644
> > > --- a/board/CZ.NIC/turris_omnia/turris_omnia.c
> > > +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
> > > @@ -50,8 +50,6 @@ DECLARE_GLOBAL_DATA_PTR;
> > >   #define OMNIA_ATSHA204_OTP_MAC0                3
> > >   #define OMNIA_ATSHA204_OTP_MAC1                4
> >
> > > -#define MVTWSI_ARMADA_DEBUG_REG                0x8c
> > > -
> > >   /*
> > >    * Those values and defines are taken from the Marvell U-Boot
version
> > >    * "u-boot-2013.01-2014_T3.0"
> > > @@ -297,8 +295,6 @@ static int set_regdomain(void)
> >
> > >   int board_early_init_f(void)
> > >   {
> > > -       u32 i2c_debug_reg;
> > > -
> > >          /* Configure MPP */
> > >          writel(0x11111111, MVEBU_MPP_BASE + 0x00);
> > >          writel(0x11111111, MVEBU_MPP_BASE + 0x04);
> > > @@ -321,11 +317,6 @@ int board_early_init_f(void)
> > >          writel(OMNIA_GPP_OUT_ENA_LOW, MVEBU_GPIO0_BASE + 0x04);
> > >          writel(OMNIA_GPP_OUT_ENA_MID, MVEBU_GPIO1_BASE + 0x04);
> >
> > > -       /* Disable I2C debug mode blocking 0x64 I2C address */
> > > -       i2c_debug_reg = readl(MVEBU_TWSI_BASE +
MVTWSI_ARMADA_DEBUG_REG);
> > > -       i2c_debug_reg &= ~(1<<18);
> > > -       writel(i2c_debug_reg, MVEBU_TWSI_BASE +
MVTWSI_ARMADA_DEBUG_REG);
> > > -
> > >          return 0;
> > >   }

> --
>       http://baruch.siach.name/blog/                  ~. .~   Tk Open
Systems

=}------------------------------------------------ooO--U--Ooo------------{=
>     - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


More information about the U-Boot mailing list