Skip to contentSkip to conversation

Fixes for Turris Omnia

PATCH Superseded Marek Behún 3 participants 9 messages Apr 25, 2019 – Apr 29, 2019 I2C

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Fixes for Turris Omnia

Hi Stefan, could you please review and apply these patches for Turris Omnia?

Marek

Marek Behún (3):
i2c: mvtwsi: fix disabling i2c slave on Armada 38x
mvebu: turris_omnia: remove redundant code
arm: mvebu: turris_omnia: add XHCI to defconfig

Pierre Bourdon (1):
mvebu: turris_omnia: fix eeprom/mcu device names

 board/CZ.NIC/turris_omnia/turris_omnia.c | 15 ++-------------
 configs/turris_omnia_defconfig           |  2 ++
 drivers/i2c/mvtwsi.c                     | 16 ++++------------
 3 files changed, 8 insertions(+), 25 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/4 i2c: mvtwsi: fix disabling i2c slave on Armada 38x

Commit 173ec351 ("i2c: mvtwsi: disable i2c slave on Armada 38x") adds slave disabling code on port 0 into bind method. This does not work on Turris Omnia in SPL, because at the time the bind method is called in SPL, arch/arm/mach-mvebu/spl.c has not yet set DM translation offset, so the bind function reads from bad memory place, which causes a fault.

Move the i2c slave disabling code into the probe method of mvtwsi, by that time dm_set_translation_offset is already called.

Cc Baruch Siach <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Chris Packham <[email protected]>
Cc Stefan Roese <[email protected]>
---
 drivers/i2c/mvtwsi.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/i2c/mvtwsi.c +4 -12
index 74ac0a4aa7..b0f7c3e057 100644
@@ -804,22 +804,15 @@ static void twsi_disable_i2c_slave(struct mvtwsi_registers *twsi)
 	clrbits_le32(&twsi->debug, BIT(18));
 }
 
-static int mvtwsi_i2c_bind(struct udevice *bus)
+static int mvtwsi_i2c_probe(struct udevice *bus)
 {
-	struct mvtwsi_registers *twsi = devfdt_get_addr_ptr(bus);
+	struct mvtwsi_i2c_dev *dev = dev_get_priv(bus);
+	uint actual_speed;
 
 	/* Disable the hidden slave in i2c0 of these platforms */
 	if ((IS_ENABLED(CONFIG_ARMADA_38X) || IS_ENABLED(CONFIG_KIRKWOOD))
 			&& bus->req_seq == 0)
-		twsi_disable_i2c_slave(twsi);
-
-	return 0;
-}
-
-static int mvtwsi_i2c_probe(struct udevice *bus)
-{
-	struct mvtwsi_i2c_dev *dev = dev_get_priv(bus);
-	uint actual_speed;
+		twsi_disable_i2c_slave(dev->base);
 
 	__twsi_i2c_init(dev->base, dev->speed, dev->slaveadd, &actual_speed);
 	dev->speed = actual_speed;
@@ -871,7 +864,6 @@ U_BOOT_DRIVER(i2c_mvtwsi) = {
 	.name = "i2c_mvtwsi",
 	.id = UCLASS_I2C,
 	.of_match = mvtwsi_i2c_ids,
-	.bind = mvtwsi_i2c_bind,
 	.probe = mvtwsi_i2c_probe,
 	.ofdata_to_platdata = mvtwsi_i2c_ofdata_to_platdata,
 	.priv_auto_alloc_size = sizeof(struct mvtwsi_i2c_dev),
Signature · 1 line
2.21.0
#2 lore raw

PATCH 1/4 i2c: mvtwsi: fix disabling i2c slave on Armada 38x

Quoted 9 lines · Marek Behún

Commit 173ec351 ("i2c: mvtwsi: disable i2c slave on Armada 38x") adds slave disabling code on port 0 into bind method. This does not work on Turris Omnia in SPL, because at the time the bind method is called in SPL, arch/arm/mach-mvebu/spl.c has not yet set DM translation offset, so the bind function reads from bad memory place, which causes a fault.

Move the i2c slave disabling code into the probe method of mvtwsi, by that time dm_set_translation_offset is already called.

https://patchwork.ozlabs.org/patch/1084776/ implements a better fix for this issue and has been merged in master with the latest DM pull 2h ago.

--
Pierre Bourdon <[email protected]>
Software Engineer @ Zürich, Switzerland
https://delroth.net/

#3 lore raw

PATCH 1/4 i2c: mvtwsi: fix disabling i2c slave on Armada 38x

:) I did not know about that, thanks.

Quoted 21 lines · On Thu, 25 Apr 2019 15:35:10 +0200 Pierre Bourdon <[email protected]> wrote:
Quoted 10 lines · Marek Behún

Commit 173ec351 ("i2c: mvtwsi: disable i2c slave on Armada 38x") adds slave disabling code on port 0 into bind method. This does not work on Turris Omnia in SPL, because at the time the bind method is called in SPL, arch/arm/mach-mvebu/spl.c has not yet set DM translation offset, so the bind function reads from bad memory place, which causes a fault.

Move the i2c slave disabling code into the probe method of mvtwsi, by that time dm_set_translation_offset is already called.

https://patchwork.ozlabs.org/patch/1084776/ implements a better fix for this issue and has been merged in master with the latest DM pull 2h ago.

--
Pierre Bourdon <[email protected]>
Software Engineer @ Zürich, Switzerland
https://delroth.net/

#4 lore raw

PATCH 2/4 mvebu: turris_omnia: remove redundant code

In reply to Marek Behún

The i2c slave disabling is done by mvtwsi driver and is not needed here.

---
 board/CZ.NIC/turris_omnia/turris_omnia.c | 11 -----------
 1 file changed, 11 deletions(-)
board/CZ.NIC/turris_omnia/turris_omnia.c +0 -11
index c21d2f3ffa..c446f471a6 100644
@@ -297,8 +297,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,15 +319,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.
-	 * Note: that would be redundant once Turris Omnia migrates to DM_I2C,
-	 * because the mvtwsi driver includes equivalent code.
-	 */
-	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;
 }
 
Signature · 1 line
2.21.0
#5 lore raw

PATCH 2/4 mvebu: turris_omnia: remove redundant code

Hi Marek,

Quoted 22 lines · Marek Behún

The i2c slave disabling is done by mvtwsi driver and is not needed here.

---
 board/CZ.NIC/turris_omnia/turris_omnia.c | 11 -----------
 1 file changed, 11 deletions(-)
board/CZ.NIC/turris_omnia/turris_omnia.c +0 -2
index c21d2f3ffa..c446f471a6 100644
@@ -297,8 +297,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);

board/CZ.NIC/turris_omnia/turris_omnia.c int board_early_init_f(void) · line 328

Quoted 8 lines
board/CZ.NIC/turris_omnia/turris_omnia.c +0 -5
@@ -321,15 +319,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.
-	 * Note: that would be redundant once Turris Omnia migrates to DM_I2C,
-	 * because the mvtwsi driver includes equivalent code.
-	 */

As this comment notes, Turris Omnia needs to migrate to DM_I2C before removing this code. The non DM code path in the mvtwsi driver does not disable the debug I2C client.

Is there a pending patch that enables DM_I2C for Turris Omnia?

board/CZ.NIC/turris_omnia/turris_omnia.c int board_early_init_f(void) · line 323

Quoted 6 lines
board/CZ.NIC/turris_omnia/turris_omnia.c +0 -4
-	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;
 }

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 -
#6 lore raw

PATCH 2/4 mvebu: turris_omnia: remove redundant code

The next version of this patchseries will include patch with name "arm: mvebu: turris_omnia: move I2C dependencies to Kconfig", which adds
select DM_I2C
to
config TARGET_TURRIS_OMNIA

Marek

Quoted 49 lines · On Sun, 28 Apr 2019 14:59:10 +0300 Baruch Siach <[email protected]> wrote:

Hi Marek,

Quoted 22 lines · Marek Behún

The i2c slave disabling is done by mvtwsi driver and is not needed here.

---
 board/CZ.NIC/turris_omnia/turris_omnia.c | 11 -----------
 1 file changed, 11 deletions(-)
board/CZ.NIC/turris_omnia/turris_omnia.c +0 -2
index c21d2f3ffa..c446f471a6 100644
@@ -297,8 +297,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);

board/CZ.NIC/turris_omnia/turris_omnia.c int board_early_init_f(void) · line 328

Quoted 8 lines
board/CZ.NIC/turris_omnia/turris_omnia.c +0 -5
@@ -321,15 +319,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.
-	 * Note: that would be redundant once Turris Omnia migrates to DM_I2C,
-	 * because the mvtwsi driver includes equivalent code.
-	 */  

As this comment notes, Turris Omnia needs to migrate to DM_I2C before removing this code. The non DM code path in the mvtwsi driver does not disable the debug I2C client.

Is there a pending patch that enables DM_I2C for Turris Omnia?

board/CZ.NIC/turris_omnia/turris_omnia.c int board_early_init_f(void) · line 323

Quoted 6 lines
board/CZ.NIC/turris_omnia/turris_omnia.c +0 -4
-	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;
 }  

baruch

#7 lore raw

PATCH 3/4 mvebu: turris_omnia: fix eeprom/mcu device names

In reply to Marek Behún

From: Pierre Bourdon <[email protected]>

Commit c4bd12a7dad4 ("i2c: mux: Generate longer i2c mux name") changed the naming scheme of i2c devices within a mux. This broke references to i2c at 0 in the Turris Omnia board initialization code.

---
 board/CZ.NIC/turris_omnia/turris_omnia.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
board/CZ.NIC/turris_omnia/turris_omnia.c +2 -2
index c446f471a6..3bfd6fe4e4 100644
@@ -32,13 +32,13 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define OMNIA_I2C_EEPROM_DM_NAME	"i2c at 0"
+#define OMNIA_I2C_EEPROM_DM_NAME	"i2c at 11000->i2cmux at 70->i2c at 0"
 #define OMNIA_I2C_EEPROM		0x54
 #define OMNIA_I2C_EEPROM_CONFIG_ADDR	0x0
 #define OMNIA_I2C_EEPROM_ADDRLEN	2
 #define OMNIA_I2C_EEPROM_MAGIC		0x0341a034
 
-#define OMNIA_I2C_MCU_DM_NAME		"i2c at 0"
+#define OMNIA_I2C_MCU_DM_NAME		"i2c at 11000->i2cmux at 70->i2c at 0"
 #define OMNIA_I2C_MCU_ADDR_STATUS	0x1
 #define OMNIA_I2C_MCU_SATA		0x20
 #define OMNIA_I2C_MCU_CARDDET		0x10
Signature · 1 line
2.21.0
#8 lore raw

PATCH 4/4 arm: mvebu: turris_omnia: add XHCI to defconfig

In reply to Marek Behún

Add XHCI_HOST and XHCI_MVEBU to defconfig, so that user's can by default boot from USB on Turris Omnia.

---
 configs/turris_omnia_defconfig | 2 ++
 1 file changed, 2 insertions(+)
configs/turris_omnia_defconfig +2 -0
index 85f214148a..4b792d9a5a 100644
@@ -56,5 +56,7 @@ CONFIG_KIRKWOOD_SPI=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_MVEBU=y
 CONFIG_WDT=y
 CONFIG_WDT_ORION=y
Signature · 1 line
2.21.0