Skip to contentSkip to conversation

arm: mvebu: switch clearfog to use device-tree i2c and gpio

PATCH New Baruch Siach 4 participants 8 messages May 28, 2018 – Jun 5, 2018 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: mvebu: switch clearfog to use device-tree i2c and gpio

From: Jon Nettleton <[email protected]>

This switches the clearfog boards to use DM based gpio and i2c drivers. The io expanders are configured via their device-tree entries.

[baruch: add DT i2c aliases]

---

The context lines in this patch depend on the patch adding SATA support.

https://patchwork.ozlabs.org/patch/921400/

---
 arch/arm/dts/armada-388-clearfog.dts |  2 ++
 board/solidrun/clearfog/clearfog.c   | 22 ----------------------
 configs/clearfog_defconfig           |  6 ++++++
 include/configs/clearfog.h           |  7 -------
 4 files changed, 8 insertions(+), 29 deletions(-)
arch/arm/dts/armada-388-clearfog.dts +2 -0
index bc52bc0167d3..a0b566a5ae0e 100644
@@ -62,6 +62,8 @@
 		ethernet2 = &eth1;
 		ethernet3 = &eth2;
 		spi1 = &spi1;
+		i2c0 = &i2c0;
+		i2c1 = &i2c1;
 	};
 
 	chosen {
board/solidrun/clearfog/clearfog.c +0 -22
index ede303d4ebf9..4e1386c8a223 100644
@@ -32,22 +32,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #define BOARD_GPP_POL_LOW	0x0
 #define BOARD_GPP_POL_MID	0x0
 
-/* IO expander on Marvell GP board includes e.g. fan enabling */
-struct marvell_io_exp {
-	u8 chip;
-	u8 addr;
-	u8 val;
-};
-
-static struct marvell_io_exp io_exp[] = {
-	{ 0x20, 2, 0x40 },	/* Deassert both mini pcie reset signals */
-	{ 0x20, 6, 0xf9 },
-	{ 0x20, 2, 0x46 },	/* rst signals and ena USB3 current limiter */
-	{ 0x20, 6, 0xb9 },
-	{ 0x20, 3, 0x00 },	/* Set SFP_TX_DIS to zero */
-	{ 0x20, 7, 0xbf },	/* Drive SFP_TX_DIS to zero */
-};
-
 static struct serdes_map board_serdes_map[] = {
 	{SATA0, SERDES_SPEED_3_GBPS, SERDES_DEFAULT_MODE, 0, 0},
 	{SGMII1, SERDES_SPEED_1_25_GBPS, SERDES_DEFAULT_MODE, 0, 0},
@@ -126,8 +110,6 @@ int board_early_init_f(void)
 
 int board_init(void)
 {
-	int i;
-
 	/* Address of boot parameters */
 	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
@@ -142,10 +124,6 @@ int board_init(void)
 	setbits_le32(MVEBU_GPIO0_BASE + 0x0, BIT(19));
 	mdelay(10);
 
-	/* Init I2C IO expanders */
-	for (i = 0; i < ARRAY_SIZE(io_exp); i++)
-		i2c_write(io_exp[i].chip, io_exp[i].addr, 1, &io_exp[i].val, 1);
-
 	return 0;
 }
 
configs/clearfog_defconfig +6 -0
index 3972c31ef978..2baf33701bca 100644
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_ARCH_MVEBU=y
 CONFIG_SYS_TEXT_BASE=0x00800000
+CONFIG_SPL_GPIO_SUPPORT=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_SYS_MALLOC_F_LEN=0x2000
@@ -19,6 +20,7 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x141
 CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PCI=y
@@ -34,6 +36,10 @@ CONFIG_ENV_IS_IN_MMC=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_SCSI_AHCI=y
+CONFIG_DM_GPIO=y
+CONFIG_DM_PCA953X=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_MVTWSI=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_SDMA=y
 CONFIG_MMC_SDHCI_MV=y
include/configs/clearfog.h +0 -7
index ed6f000db16b..1141aee08b6e 100644
@@ -21,13 +21,6 @@
  * Commands configuration
  */
 
-/* I2C */
-#define CONFIG_SYS_I2C
-#define CONFIG_SYS_I2C_MVTWSI
-#define CONFIG_I2C_MVTWSI_BASE0		MVEBU_TWSI_BASE
-#define CONFIG_SYS_I2C_SLAVE		0x0
-#define CONFIG_SYS_I2C_SPEED		100000
-
 /* SPI NOR flash default params, used by sf commands */
 #define CONFIG_SF_DEFAULT_BUS		1
 
Signature · 1 line
2.17.0
#1 lore raw

PATCH 1/1 arm: mvebu: switch clearfog to use device-tree i2c and gpio

Quoted 14 lines · Baruch Siach

From: Jon Nettleton <[email protected]>

This switches the clearfog boards to use DM based gpio and i2c drivers. The io expanders are configured via their device-tree entries.

[baruch: add DT i2c aliases]

---

The context lines in this patch depend on the patch adding SATA support.

https://patchwork.ozlabs.org/patch/921400/

Review

Quoted 8 lines
---
  arch/arm/dts/armada-388-clearfog.dts |  2 ++
  board/solidrun/clearfog/clearfog.c   | 22 ----------------------
  configs/clearfog_defconfig           |  6 ++++++
  include/configs/clearfog.h           |  7 -------
  4 files changed, 8 insertions(+), 29 deletions(-)
(quoted diff) +0 -0

b/arch/arm/dts/armada-388-clearfog.dts

Review

Quoted 13 lines

index bc52bc0167d3..a0b566a5ae0e 100644

arch/arm/dts/armada-388-clearfog.dts +2 -0
@@ -62,6 +62,8 @@
                 ethernet2 = &eth1;
                 ethernet3 = &eth2;
                 spi1 = &spi1;
+               i2c0 = &i2c0;
+               i2c1 = &i2c1;
         };
 
         chosen {
(quoted diff) +0 -0

b/board/solidrun/clearfog/clearfog.c

Quoted 6 lines

index ede303d4ebf9..4e1386c8a223 100644

board/solidrun/clearfog/clearfog.c +0 -0
@@ -32,22 +32,6 @@ DECLARE_GLOBAL_DATA_PTR;
  #define BOARD_GPP_POL_LOW      0x0
  #define BOARD_GPP_POL_MID      0x0

board/solidrun/clearfog/clearfog.c DECLARE_GLOBAL_DATA_PTR; · line 43

Quoted 10 lines
board/solidrun/clearfog/clearfog.c +0 -9
 
-/* IO expander on Marvell GP board includes e.g. fan enabling */
-struct marvell_io_exp {
-       u8 chip;
-       u8 addr;
-       u8 val;
-};
-
-static struct marvell_io_exp io_exp[] = {
-       { 0x20, 2, 0x40 },      /* Deassert both mini pcie reset signals

*/

board/solidrun/clearfog/clearfog.c DECLARE_GLOBAL_DATA_PTR; · line 45

Quoted 2 lines
board/solidrun/clearfog/clearfog.c +0 -2
-       { 0x20, 6, 0xf9 },
-       { 0x20, 2, 0x46 },      /* rst signals and ena USB3 current

limiter */

board/solidrun/clearfog/clearfog.c DECLARE_GLOBAL_DATA_PTR; · line 50

Quoted 5 lines
board/solidrun/clearfog/clearfog.c +0 -5
-       { 0x20, 6, 0xb9 },
-       { 0x20, 3, 0x00 },      /* Set SFP_TX_DIS to zero */
-       { 0x20, 7, 0xbf },      /* Drive SFP_TX_DIS to zero */
-};
-

Will this actually work? As far as I can see u-boot lacks a gpio-hog implementation so despite the fact that these are all enumerated in the dts they won't have the same effect.

I'd be glad to be proven wrong because I'd like to use a gpio-hog for some other boards.

Quoted 13 lines
board/solidrun/clearfog/clearfog.c +0 -2
  static struct serdes_map board_serdes_map[] = {
         {SATA0, SERDES_SPEED_3_GBPS, SERDES_DEFAULT_MODE, 0, 0},
         {SGMII1, SERDES_SPEED_1_25_GBPS, SERDES_DEFAULT_MODE, 0, 0},
@@ -126,8 +110,6 @@ int board_early_init_f(void)
 
  int board_init(void)
  {
-       int i;
-
         /* Address of boot parameters */
         gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 

board/solidrun/clearfog/clearfog.c int board_init(void) · line 147

Quoted 6 lines
board/solidrun/clearfog/clearfog.c +0 -3
@@ -142,10 +124,6 @@ int board_init(void)
         setbits_le32(MVEBU_GPIO0_BASE + 0x0, BIT(19));
         mdelay(10);
 
-       /* Init I2C IO expanders */
-       for (i = 0; i < ARRAY_SIZE(io_exp); i++)
-               i2c_write(io_exp[i].chip, io_exp[i].addr, 1,

&io_exp[i].val, 1);

Quoted 60 lines
board/solidrun/clearfog/clearfog.c +0 -1
-
         return 0;
  }
 
configs/clearfog_defconfig +6 -0
index 3972c31ef978..2baf33701bca 100644
@@ -1,6 +1,7 @@
  CONFIG_ARM=y
  CONFIG_ARCH_MVEBU=y
  CONFIG_SYS_TEXT_BASE=0x00800000
+CONFIG_SPL_GPIO_SUPPORT=y
  CONFIG_SPL_LIBCOMMON_SUPPORT=y
  CONFIG_SPL_LIBGENERIC_SUPPORT=y
  CONFIG_SYS_MALLOC_F_LEN=0x2000
@@ -19,6 +20,7 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
  CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x141
  CONFIG_SPL_I2C_SUPPORT=y
  # CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
  CONFIG_CMD_I2C=y
  CONFIG_CMD_MMC=y
  CONFIG_CMD_PCI=y
@@ -34,6 +36,10 @@ CONFIG_ENV_IS_IN_MMC=y
  CONFIG_NET_RANDOM_ETHADDR=y
  CONFIG_SPL_OF_TRANSLATE=y
  CONFIG_SCSI_AHCI=y
+CONFIG_DM_GPIO=y
+CONFIG_DM_PCA953X=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_MVTWSI=y
  CONFIG_MMC_SDHCI=y
  CONFIG_MMC_SDHCI_SDMA=y
  CONFIG_MMC_SDHCI_MV=y
include/configs/clearfog.h +0 -8
index ed6f000db16b..1141aee08b6e 100644
@@ -21,13 +21,6 @@
   * Commands configuration
   */
 
-/* I2C */
-#define CONFIG_SYS_I2C
-#define CONFIG_SYS_I2C_MVTWSI
-#define CONFIG_I2C_MVTWSI_BASE0                MVEBU_TWSI_BASE
-#define CONFIG_SYS_I2C_SLAVE           0x0
-#define CONFIG_SYS_I2C_SPEED           100000
-
  /* SPI NOR flash default params, used by sf commands */
  #define CONFIG_SF_DEFAULT_BUS          1
 
--

2.17.0

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#2 lore raw

PATCH 1/1 arm: mvebu: switch clearfog to use device-tree i2c and gpio

Hi Chris,

Quoted 12 lines · Chris Packham
Quoted 10 lines · Baruch Siach

From: Jon Nettleton <[email protected]>

This switches the clearfog boards to use DM based gpio and i2c drivers. The io expanders are configured via their device-tree entries.

[baruch: add DT i2c aliases]

---

[snip]

Quoted 16 lines

Review

Quoted 2 lines
(quoted diff) +0 -2
-static struct marvell_io_exp io_exp[] = {
-       { 0x20, 2, 0x40 },      /* Deassert both mini pcie reset signals

*/

Review

Quoted 2 lines
(quoted diff) +0 -2
-       { 0x20, 6, 0xf9 },
-       { 0x20, 2, 0x46 },      /* rst signals and ena USB3 current

limiter */

board/solidrun/clearfog/clearfog.c DECLARE_GLOBAL_DATA_PTR; · line 50

Quoted 5 lines
board/solidrun/clearfog/clearfog.c +0 -5
-       { 0x20, 6, 0xb9 },
-       { 0x20, 3, 0x00 },      /* Set SFP_TX_DIS to zero */
-       { 0x20, 7, 0xbf },      /* Drive SFP_TX_DIS to zero */
-};
-

Will this actually work? As far as I can see u-boot lacks a gpio-hog implementation so despite the fact that these are all enumerated in the dts they won't have the same effect.

Quoted 2 lines

I'd be glad to be proven wrong because I'd like to use a gpio-hog for some other boards.

I asked Jon (back on Cc) exactly that before submitting this patch. His response:

I think that is fine. They can still be toggled and controlled via the gpio interface within u-boot. I assume once a proper patch is mainline this will just start to work.

My testing showed now regression because of this patch.

Thanks for reviewing,
baruch

Signature · 3 lines
     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 -
#3 lore raw

PATCH 1/1 arm: mvebu: switch clearfog to use device-tree i2c and gpio

Quoted 11 lines · Baruch Siach

Hi Chris,

Quoted 8 lines · Chris Packham
Quoted 5 lines · Baruch Siach

From: Jon Nettleton <[email protected]>

This switches the clearfog boards to use DM based gpio and i2c drivers. The io expanders are configured via their device-tree entries.

Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
[baruch: add DT i2c aliases]

---

[snip]

Quoted 2 lines
Quoted 2 lines
(quoted diff) +0 -2
-static struct marvell_io_exp io_exp[] = {
-       { 0x20, 2, 0x40 },      /* Deassert both mini pcie reset

signals

Quoted 4 lines
Quoted 4 lines

*/

Review

Quoted 2 lines
(quoted diff) +0 -2
-       { 0x20, 6, 0xf9 },
-       { 0x20, 2, 0x46 },      /* rst signals and ena USB3 current

limiter */

Quoted 8 lines
Quoted 8 lines

board/solidrun/clearfog/clearfog.c DECLARE_GLOBAL_DATA_PTR; · line 50

Quoted 5 lines
board/solidrun/clearfog/clearfog.c +0 -5
-       { 0x20, 6, 0xb9 },
-       { 0x20, 3, 0x00 },      /* Set SFP_TX_DIS to zero */
-       { 0x20, 7, 0xbf },      /* Drive SFP_TX_DIS to zero */
-};
-

Will this actually work? As far as I can see u-boot lacks a gpio-hog implementation so despite the fact that these are all enumerated in the

dts

Quoted 3 lines
Quoted 3 lines

they won't have the same effect.

I'd be glad to be proven wrong because I'd like to use a gpio-hog for

some

Quoted 6 lines
Quoted 1 line

other boards.

I asked Jon (back on Cc) exactly that before submitting this patch. His response:

I think that is fine. They can still be toggled and controlled via the

gpio

Quoted 1 line

interface within u-boot. I assume once a proper patch is mainline this

will

Quoted 3 lines

just start to work.

My testing showed now regression because of this patch.

OK. Did you test with a power cycle? I know some of the pca gpio chips don't have a reset line so the state may be different depending on if you power cycled or just used the reset/reboot command. It could also be that u-boot doesn't access these devices so there's no problem.

I kinda was hoping for "here's a gpio-hog implementation @ patchwork/1234" :) but I guess I'll have to look into making one myself.

Quoted 1 line

Thanks for reviewing,

Assuming there's no problem with power-on behaviour

Quoted 4 lines

baruch

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

Systems

=}------------------------------------------------ooO--U--Ooo------------{=

Quoted 1 line

- baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

#4 lore raw

PATCH 1/1 arm: mvebu: switch clearfog to use device-tree i2c and gpio

Quoted 53 lines · Chris Packham
Quoted 11 lines · Baruch Siach

Hi Chris,

Quoted 8 lines · Chris Packham
Quoted 5 lines · Baruch Siach

From: Jon Nettleton <[email protected]>

This switches the clearfog boards to use DM based gpio and i2c drivers. The io expanders are configured via their device-tree entries.

Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
[baruch: add DT i2c aliases]

---

[snip]

Quoted 2 lines
Quoted 2 lines
(quoted diff) +0 -2
-static struct marvell_io_exp io_exp[] = {
-       { 0x20, 2, 0x40 },      /* Deassert both mini pcie reset

signals

Quoted 4 lines
Quoted 4 lines

*/

Review

Quoted 2 lines
(quoted diff) +0 -2
-       { 0x20, 6, 0xf9 },
-       { 0x20, 2, 0x46 },      /* rst signals and ena USB3 current

limiter */

Quoted 8 lines
Quoted 8 lines

board/solidrun/clearfog/clearfog.c DECLARE_GLOBAL_DATA_PTR; · line 50

Quoted 5 lines
board/solidrun/clearfog/clearfog.c +0 -5
-       { 0x20, 6, 0xb9 },
-       { 0x20, 3, 0x00 },      /* Set SFP_TX_DIS to zero */
-       { 0x20, 7, 0xbf },      /* Drive SFP_TX_DIS to zero */
-};
-

Will this actually work? As far as I can see u-boot lacks a gpio-hog implementation so despite the fact that these are all enumerated in the

dts

Quoted 3 lines
Quoted 3 lines

they won't have the same effect.

I'd be glad to be proven wrong because I'd like to use a gpio-hog for

some

Quoted 6 lines
Quoted 1 line

other boards.

I asked Jon (back on Cc) exactly that before submitting this patch. His response:

I think that is fine. They can still be toggled and controlled via the

gpio

Quoted 1 line

interface within u-boot. I assume once a proper patch is mainline this

will

Quoted 3 lines

just start to work.

My testing showed now regression because of this patch.

Quoted 7 lines

OK. Did you test with a power cycle? I know some of the pca gpio chips don't have a reset line so the state may be different depending on if you power cycled or just used the reset/reboot command. It could also be that u-boot doesn't access these devices so there's no problem.

I kinda was hoping for "here's a gpio-hog implementation @ patchwork/1234" :) but I guess I'll have to look into making one myself.

I would prefer to not drop these I2C accesses from the ClearFog board C code now, as we don't have a way to do this via the DT right now. Why are they dropped with this patch? Because of the I2C API changes? Please move to the DM I2C API then (dm_i2c_read/write).

Thanks,
Stefan

#5 lore raw

PATCH 1/1 arm: mvebu: switch clearfog to use device-tree i2c and gpio

Quoted 66 lines · Stefan Roese
Quoted 6 lines · Chris Packham
Quoted 4 lines · Baruch Siach

Hi Chris,

Quoted 1 line · Chris Packham

On Tue, May 29, 2018 at 4:11 AM Baruch Siach <[email protected]>

Quoted 29 lines · wrote:
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines

From: Jon Nettleton <[email protected]>

This switches the clearfog boards to use DM based gpio and i2c drivers. The io expanders are configured via their device-tree entries.

[baruch: add DT i2c aliases]

---

Quoted 4 lines

[snip]

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +0 -2
-static struct marvell_io_exp io_exp[] = {
-       { 0x20, 2, 0x40 },      /* Deassert both mini pcie reset

signals

Quoted 4 lines
Quoted 4 lines

*/

Review

Quoted 2 lines
(quoted diff) +0 -2
-       { 0x20, 6, 0xf9 },
-       { 0x20, 2, 0x46 },      /* rst signals and ena USB3 current

limiter */

Quoted 8 lines
Quoted 8 lines

board/solidrun/clearfog/clearfog.c DECLARE_GLOBAL_DATA_PTR; · line 50

Quoted 5 lines
board/solidrun/clearfog/clearfog.c +0 -5
-       { 0x20, 6, 0xb9 },
-       { 0x20, 3, 0x00 },      /* Set SFP_TX_DIS to zero */
-       { 0x20, 7, 0xbf },      /* Drive SFP_TX_DIS to zero */
-};
-

Will this actually work? As far as I can see u-boot lacks a gpio-hog implementation so despite the fact that these are all enumerated in the

Quoted 11 lines

dts

Quoted 3 lines
Quoted 3 lines

they won't have the same effect.

I'd be glad to be proven wrong because I'd like to use a gpio-hog for

some

Quoted 6 lines
Quoted 1 line

other boards.

I asked Jon (back on Cc) exactly that before submitting this patch. His response:

I think that is fine. They can still be toggled and controlled via

the

Quoted 2 lines

gpio

Quoted 1 line

interface within u-boot. I assume once a proper patch is mainline

this

Quoted 11 lines

will

Quoted 3 lines

just start to work.

My testing showed now regression because of this patch.

OK. Did you test with a power cycle? I know some of the pca gpio chips don't have a reset line so the state may be different depending on if you power cycled or just used the reset/reboot command. It could also be that u-boot doesn't access these devices so there's no problem.

I kinda was hoping for "here's a gpio-hog implementation @

patchwork/1234"

Quoted 1 line

:) but I guess I'll have to look into making one myself.

Quoted 8 lines

I would prefer to not drop these I2C accesses from the ClearFog board C code now, as we don't have a way to do this via the DT right now. Why are they dropped with this patch? Because of the I2C API changes? Please move to the DM I2C API then (dm_i2c_read/write).

Thanks,
Stefan

Stefan,

These do not need to be setup independently any longer. Moving to DM_GPIO allows the PCI driver to handle the reset lines. The USB3 reset and current limiter should be handled in board_xhci_enable() which can be done, although I have never seen an issue using USB3 with this configuration since I have implemented it. Since u-boot doesn't understand the SFP setup at all I would prefer if it left SFP configuration up to Linux. Just enabling TX on an SFP module without understanding any of the specifics of the configuration is a bit dangerous when dealing with modules that aren't just SGMII 1000base-Tx.

I will follow up with a patch for board_xhci_enable().

Thanks,
Jon

#6 lore raw

PATCH 1/1 arm: mvebu: switch clearfog to use device-tree i2c and gpio

Hi Jon,

Quoted 91 lines · Jon Nettleton

On Tue, May 29, 2018 at 7:37 AM Stefan Roese <[email protected] <mailto:[email protected]>> wrote:

    On 29.05.2018 07:10, Chris Packham wrote:
     > On Tue, May 29, 2018 at 4:58 PM Baruch Siach <[email protected]
    <mailto:[email protected]>> wrote:
     >
     >> Hi Chris,
     >
     >> On Tue, May 29, 2018 at 10:53:38AM +1200, Chris Packham wrote:
     >>> On Tue, May 29, 2018 at 4:11 AM Baruch Siach <[email protected]
    <mailto:[email protected]>> wrote:
     >>>
     >>>> From: Jon Nettleton <jon at solid-run.com <mailto:[email protected]>>
     >>>
     >>>> This switches the clearfog boards to use DM based gpio and i2c
     >>>> drivers.  The io expanders are configured via their device-tree
     >>>> entries.
     >>>
     >>>> Signed-off-by: Jon Nettleton <[email protected]
    <mailto:[email protected]>>
     >>>> [baruch: add DT i2c aliases]
     >>>> Signed-off-by: Baruch Siach <[email protected]
    <mailto:[email protected]>>
     >>>> ---
     >
     >> [snip]
     >
     >>>> -static struct marvell_io_exp io_exp[] = {
     >>>> -       { 0x20, 2, 0x40 },      /* Deassert both mini pcie reset
     > signals
     >>> */
     >>>> -       { 0x20, 6, 0xf9 },
     >>>> -       { 0x20, 2, 0x46 },      /* rst signals and ena USB3
    current
     >>> limiter */
     >>>> -       { 0x20, 6, 0xb9 },
     >>>> -       { 0x20, 3, 0x00 },      /* Set SFP_TX_DIS to zero */
     >>>> -       { 0x20, 7, 0xbf },      /* Drive SFP_TX_DIS to zero */
     >>>> -};
     >>>> -
     >>>
     >>> Will this actually work? As far as I can see u-boot lacks a
    gpio-hog
     >>> implementation so despite the fact that these are all
    enumerated in the
     > dts
     >>> they won't have the same effect.
     >>>
     >>> I'd be glad to be proven wrong because I'd like to use a
    gpio-hog for
     > some
     >>> other boards.
     >
     >> I asked Jon (back on Cc) exactly that before submitting this
    patch. His
     >> response:
     >
     >>     I think that is fine. They can still be toggled and
    controlled via the
     > gpio
     >>     interface within u-boot. I assume once a proper patch is
    mainline this
     > will
     >>     just start to work.
     >
     >> My testing showed now regression because of this patch.
     >
     > OK. Did you test with a power cycle? I know some of the pca gpio
    chips
     > don't have a reset line so the state may be different depending
    on if you
     > power cycled or just used the reset/reboot command. It could also
    be that
     > u-boot doesn't access these devices so there's no problem.
     >
     > I kinda was hoping for "here's a gpio-hog implementation @
    patchwork/1234"
     > :) but I guess I'll have to look into making one myself.

    I would prefer to not drop these I2C accesses from the ClearFog board
    C code now, as we don't have a way to do this via the DT right now.
    Why are they dropped with this patch? Because of the I2C API
    changes? Please move to the DM I2C API then (dm_i2c_read/write).

    Thanks,
    Stefan

Stefan,

Quoted 9 lines

These do not need to be setup independently any longer.  Moving to DM_GPIO allows the PCI driver to handle the reset lines.  The USB3 reset and current limiter should be handled in board_xhci_enable() which can be done, although I have never seen an issue using USB3 with this configuration since I have implemented it.  Since u-boot doesn't understand the SFP setup at all I would prefer if it left SFP configuration up to Linux.  Just enabling TX on an SFP module without understanding any of the specifics of the configuration is a bit dangerous when dealing with modules that aren't just SGMII 1000base-Tx.

Thanks for the explanation. With this I'm okay with removing the I2C code from the board file:

Quoted 1 line

I will follow up with a patch for board_xhci_enable().

Good.

Thanks,
Stefan

#7 lore raw

PATCH 1/1 arm: mvebu: switch clearfog to use device-tree i2c and gpio

In reply to Baruch Siach
Quoted 9 lines · Baruch Siach

From: Jon Nettleton <[email protected]>

This switches the clearfog boards to use DM based gpio and i2c drivers. The io expanders are configured via their device-tree entries.

[baruch: add DT i2c aliases]

Applied to u-boot-marvell/master.

Thanks,
Stefan