Skip to contentSkip to conversation

km_kirkwood: various bugfixes

PATCH New Valentin Longchamp 2 participants 9 messages Nov 13, 2015 – Nov 18, 2015

lore
Share & tools
lore
#0 lore raw

cover km_kirkwood: various bugfixes

A few bugfixes have been done for the km_kirkwood bards in the last months and this series collects them all to be sumbitted to mainline.

Patch 1/4 was already submitted to mainline in [1] and even marked as accepted but the kirkwood maintainer but it was unfortunately never pushed to mainline, so it is here sent again.

[1] http://patchwork.ozlabs.org/patch/399411/

Holger Brunck (1):
arm/mgcoge3un: check dip_switch at startup

Tobias M?ller (1):
arm/km: Fix LED configuration for 88E1118R PHY (PIGGY3)

Valentin Longchamp (2):
arm/km_kirkwood: remove KM_ENV_BUS and use CONFIG_I2C_ENV_EEPROM_BUS arm/km_kirkwood: fix the #ifdef for KM_COGE5UN dip switch

 board/keymile/km_arm/km_arm.c | 66 ++++++++++++++++++++++++++++++++++++++++---
 include/configs/km/km_arm.h   |  2 +-
 include/configs/km_kirkwood.h |  4 ---
 3 files changed, 63 insertions(+), 9 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/4 arm/km_kirkwood: remove KM_ENV_BUS and use CONFIG_I2C_ENV_EEPROM_BUS

KM_ENV_BUS was used for nothing else than an direct assignment to CONFIG_I2C_ENV_EEPROM_BUS. To avoid this, directly use CONFIG_I2C_ENV_EEPROM_BUS instead.

Patchwork: http://patchwork.ozlabs.org/patch/399411/

---

 include/configs/km/km_arm.h   | 2 +-
 include/configs/km_kirkwood.h | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)
include/configs/km/km_arm.h +1 -1
index 15fca1a..8fff381 100644
@@ -243,7 +243,7 @@ int get_scl(void);
 #define CONFIG_SYS_EEPROM_WREN
 #define CONFIG_ENV_OFFSET		0x0 /* no bracets! */
 #define CONFIG_ENV_SIZE			(0x2000 - CONFIG_ENV_OFFSET)
-#define CONFIG_I2C_ENV_EEPROM_BUS	KM_ENV_BUS
+#define CONFIG_I2C_ENV_EEPROM_BUS 5 /* I2C2 (Mux-Port 5) */
 #define CONFIG_ENV_OFFSET_REDUND	0x2000 /* no bracets! */
 #define CONFIG_ENV_SIZE_REDUND		(CONFIG_ENV_SIZE)
 #endif
include/configs/km_kirkwood.h +0 -4
index dc26155..a445aaf 100644
@@ -116,10 +116,6 @@
 /* include common defines/options for all arm based Keymile boards */
 #include "km/km_arm.h"
 
-#ifndef CONFIG_KM_ENV_IS_IN_SPI_NOR
-#define KM_ENV_BUS	5	/* I2C2 (Mux-Port 5)*/
-#endif
-
 #if defined(CONFIG_KM_PIGGY4_88E6352)
 /*
  * Some keymile boards like mgcoge5un & nusa1 have their PIGGY4 connected via
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 1/4 arm/km_kirkwood: remove KM_ENV_BUS and use CONFIG_I2C_ENV_EEPROM_BUS

Quoted 6 lines · Valentin Longchamp

KM_ENV_BUS was used for nothing else than an direct assignment to CONFIG_I2C_ENV_EEPROM_BUS. To avoid this, directly use CONFIG_I2C_ENV_EEPROM_BUS instead.

Patchwork: http://patchwork.ozlabs.org/patch/399411/

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/3ed7158f/attachment.sig>
#3 lore raw

PATCH 2/4 arm/km: Fix LED configuration for 88E1118R PHY (PIGGY3)

In reply to Valentin Longchamp

From: Tobias M?ller <[email protected]>

Configure PHY LED register for Marvell 88E1118R PHY used on PIGGY3 to match with printed descriptions on PCB

---

 board/keymile/km_arm/km_arm.c | 55 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
board/keymile/km_arm/km_arm.c +55 -0
index 2938861..a11474c 100644
@@ -37,6 +37,24 @@ DECLARE_GLOBAL_DATA_PTR;
 #define REG_IRQ_CIRQ2		0x2d
 #define MASK_RBI_DEFECT_16	0x01
 
+/*
+ * PHY registers definitions
+ */
+#define PHY_MARVELL_OUI					0x5043
+#define PHY_MARVELL_88E1118_MODEL			0x0022
+#define PHY_MARVELL_88E1118R_MODEL			0x0024
+
+#define PHY_MARVELL_PAGE_REG				0x0016
+#define PHY_MARVELL_DEFAULT_PAGE			0x0000
+
+#define PHY_MARVELL_88E1118R_LED_CRTL_PAGE		0x0003
+#define PHY_MARVELL_88E1118R_LED_CTRL_REG		0x0010
+
+#define PHY_MARVELL_88E1118R_LED_CTRL_RESERVED		0x1000
+#define PHY_MARVELL_88E1118R_LED_CTRL_LED0_1000MB	(0x7<<0)
+#define PHY_MARVELL_88E1118R_LED_CTRL_LED1_ACT		(0x3<<4)
+#define PHY_MARVELL_88E1118R_LED_CTRL_LED2_LINK		(0x0<<8)
+
 /* Multi-Purpose Pins Functionality configuration */
 static const u32 kwmpp_config[] = {
 	MPP0_NF_IO2,
@@ -409,6 +427,9 @@ void reset_phy(void)
 /* Configure and enable MV88E1118 PHY on the piggy*/
 void reset_phy(void)
 {
+	unsigned int oui;
+	unsigned char model, rev;
+
 	char *name = "egiga0";
 
 	if (miiphy_set_current_dev(name))
@@ -416,6 +437,40 @@ void reset_phy(void)
 
 	/* reset the phy */
 	miiphy_reset(name, CONFIG_PHY_BASE_ADR);
+
+	/* get PHY model */
+	if (miiphy_info(name, CONFIG_PHY_BASE_ADR, &oui, &model, &rev))
+		return;
+
+	/* check for Marvell 88E1118R Gigabit PHY (PIGGY3) */
+	if ((oui == PHY_MARVELL_OUI) &&
+	    (model == PHY_MARVELL_88E1118R_MODEL)) {
+		/* set page register to 3 */
+		if (miiphy_write(name, CONFIG_PHY_BASE_ADR,
+				 PHY_MARVELL_PAGE_REG,
+				 PHY_MARVELL_88E1118R_LED_CTRL_PAGE))
+			printf("Error writing PHY page reg\n");
+
+		/*
+		 * leds setup as printed on PCB:
+		 * LED2 (Link): 0x0 (On Link, Off No Link)
+		 * LED1 (Activity): 0x3 (On Activity, Off No Activity)
+		 * LED0 (Speed): 0x7 (On 1000 MBits, Off Else)
+		 */
+		if (miiphy_write(name, CONFIG_PHY_BASE_ADR,
+				 PHY_MARVELL_88E1118R_LED_CTRL_REG,
+				 PHY_MARVELL_88E1118R_LED_CTRL_RESERVED |
+				 PHY_MARVELL_88E1118R_LED_CTRL_LED0_1000MB |
+				 PHY_MARVELL_88E1118R_LED_CTRL_LED1_ACT |
+				 PHY_MARVELL_88E1118R_LED_CTRL_LED2_LINK))
+			printf("Error writing PHY LED reg\n");
+
+		/* set page register back to 0 */
+		if (miiphy_write(name, CONFIG_PHY_BASE_ADR,
+				 PHY_MARVELL_PAGE_REG,
+				 PHY_MARVELL_DEFAULT_PAGE))
+			printf("Error writing PHY page reg\n");
+	}
 }
 #endif
 
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 2/4 arm/km: Fix LED configuration for 88E1118R PHY (PIGGY3)

Quoted 7 lines · Valentin Longchamp

From: Tobias M?ller <[email protected]>

Configure PHY LED register for Marvell 88E1118R PHY used on PIGGY3 to match with printed descriptions on PCB

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/62c8ba79/attachment.sig>
#5 lore raw

PATCH 3/4 arm/mgcoge3un: check dip_switch at startup

In reply to Valentin Longchamp

From: Holger Brunck <[email protected]>

Similar to kmcoge5un we need to check the dip switch at startup connected to the kirkwood at MPP43. If it's set we need to set the actual_bank to zero to boot from SW bank zero. Additional to kmcoge5un we need to check also the pin in misc_init to decide wether we wait for the ne to start or not. If the dip_switch is set we don't wait and continue immediately.

---

 board/keymile/km_arm/km_arm.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
board/keymile/km_arm/km_arm.c +7 -4
index a11474c..b2ddab2 100644
@@ -55,6 +55,9 @@ DECLARE_GLOBAL_DATA_PTR;
 #define PHY_MARVELL_88E1118R_LED_CTRL_LED1_ACT		(0x3<<4)
 #define PHY_MARVELL_88E1118R_LED_CTRL_LED2_LINK		(0x0<<8)
 
+/* I/O pin to erase flash RGPP09 = MPP43 */
+#define KM_FLASH_ERASE_ENABLE	43
+
 /* Multi-Purpose Pins Functionality configuration */
 static const u32 kwmpp_config[] = {
 	MPP0_NF_IO2,
@@ -201,8 +204,10 @@ int misc_init_r(void)
 {
 #if defined(CONFIG_KM_MGCOGE3UN)
 	char *wait_for_ne;
+	u8 dip_switch = kw_gpio_get_value(KM_FLASH_ERASE_ENABLE);
 	wait_for_ne = getenv("waitforne");
-	if (wait_for_ne != NULL) {
+
+	if ((wait_for_ne != NULL) && (dip_switch == 0)) {
 		if (strcmp(wait_for_ne, "true") == 0) {
 			int cnt = 0;
 			int abort = 0;
@@ -291,9 +296,7 @@ int board_init(void)
 
 int board_late_init(void)
 {
-#if defined(CONFIG_KMCOGE5UN)
-/* I/O pin to erase flash RGPP09 = MPP43 */
-#define KM_FLASH_ERASE_ENABLE	43
+#if (defined(CONFIG_KMCOGE5UN) | defined(CONFIG_KM_MGCOGE3UN))
 	u8 dip_switch = kw_gpio_get_value(KM_FLASH_ERASE_ENABLE);
 
 	/* if pin 1 do full erase */
Signature · 1 line
1.8.3.1
#6 lore raw

PATCH 3/4 arm/mgcoge3un: check dip_switch at startup

Quoted 11 lines · Valentin Longchamp

From: Holger Brunck <[email protected]>

Similar to kmcoge5un we need to check the dip switch at startup connected to the kirkwood at MPP43. If it's set we need to set the actual_bank to zero to boot from SW bank zero. Additional to kmcoge5un we need to check also the pin in misc_init to decide wether we wait for the ne to start or not. If the dip_switch is set we don't wait and continue immediately.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/4ed175cb/attachment.sig>
#7 lore raw

PATCH 4/4 arm/km_kirkwood: fix the #ifdef for KM_COGE5UN dip switch

In reply to Valentin Longchamp

There was a small typo for KM_COGE5UN that resulted in the dip switch not to behave as expected.

---

 board/keymile/km_arm/km_arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/keymile/km_arm/km_arm.c +1 -1
index b2ddab2..03a1901 100644
@@ -296,7 +296,7 @@ int board_init(void)
 
 int board_late_init(void)
 {
-#if (defined(CONFIG_KMCOGE5UN) | defined(CONFIG_KM_MGCOGE3UN))
+#if (defined(CONFIG_KM_COGE5UN) | defined(CONFIG_KM_MGCOGE3UN))
 	u8 dip_switch = kw_gpio_get_value(KM_FLASH_ERASE_ENABLE);
 
 	/* if pin 1 do full erase */
Signature · 1 line
1.8.3.1
#8 lore raw

PATCH 4/4 arm/km_kirkwood: fix the #ifdef for KM_COGE5UN dip switch

Quoted 4 lines · Valentin Longchamp

There was a small typo for KM_COGE5UN that resulted in the dip switch not to behave as expected.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/2068a444/attachment.sig>