Skip to contentSkip to conversation

Add Ether support for R8A7791/Koelsch board

PATCH New Sergei Shtylyov 4 participants 11 messages Dec 8, 2013 – Dec 12, 2013 SuperH

lore
Share & tools
lore
#0 lore raw

v3 cover Add Ether support for R8A7791/Koelsch board

Hello.

Here's the set of 3 patches against Simon Horman's 'renesas.git' repo,
'renesas-devel-v3.13-rc2-20131205' tag. Here we add the Ether support to the R8A7791/Koelsch board. The patchset requires the 'sh_eth' driver R8A7791 support patch posted earlier in order to work.

[1/3] ARM: shmobile: r8a7791: add Ether clock [2/3] ARM: shmobile: Koelsch: add Ether support [3/3] ARM: shmobile: Koelsch: enable Ether in defconfig

WBR, Sergei

#1 lore raw

PATCH v3 1/3 ARM: shmobile: r8a7791: add Ether clock

Add support for R8A7791 Ether clock.

---
Changes in version 3:
- changed "r8a779x-ether" wildcard device name to "r8a7791-ether";
- resolved rejects.

Changes in version 2:
- changed Ether device name to "r8a779x-ether".

 arch/arm/mach-shmobile/clock-r8a7791.c |    3 +++
 1 file changed, 3 insertions(+)

Index: renesas/arch/arm/mach-shmobile/clock-r8a7791.c =================================--- renesas.orig/arch/arm/mach-shmobile/clock-r8a7791.c +++ renesas/arch/arm/mach-shmobile/clock-r8a7791.c
@@ -122,6 +122,7 @@ static struct clk *main_clks[] = {

/* MSTP */
enum {
+ MSTP813,
MSTP726, MSTP724, MSTP723, MSTP721, MSTP720, MSTP719, MSTP718, MSTP715, MSTP714, MSTP522,
@@ -132,6 +133,7 @@ enum {
};

static struct clk mstp_clks[MSTP_NR] = {
+ [MSTP813] = SH_CLK_MSTP32(&p_clk, SMSTPCR8, 13, 0), /* Ether */
[MSTP726] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 26, 0), /* LVDS0 */ [MSTP724] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 24, 0), /* DU0 */ [MSTP723] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 23, 0), /* DU1 */
@@ -192,6 +194,7 @@ static struct clk_lookup lookups[] = {
CLKDEV_DEV_ID("sh_cmt.0", &mstp_clks[MSTP124]), CLKDEV_DEV_ID("e61f0000.thermal", &mstp_clks[MSTP522]), CLKDEV_DEV_ID("rcar_thermal", &mstp_clks[MSTP522]),
+ CLKDEV_DEV_ID("r8a7791-ether", &mstp_clks[MSTP813]), /* Ether */
};

#define R8A7791_CLOCK_ROOT(e, m, p0, p1, p30, p31) \

#2 lore raw

PATCH v3 2/3 ARM: shmobile: Koelsch: add Ether support

In reply to Sergei Shtylyov

Register Ether platform device and pin data on the Koelsch board. Register platform fixup for Micrel KSZ8041 PHY, just like on the Lager board.

---
Changes in version 3:
- changed "r8a779x-ether" wildcard device name to "r8a7791-ether";
- added PFC data for IRQ0 pin used by KSZ8041 PHY;
- resolved rejects, refreshed the patch.

Changes in version 2:
- added *if* (IS_ENABLED(CONFIG_PHYLIB)) around phy_register_fixup_for_id() call;
- changed Ether device name to "r8a779x-ether".

 arch/arm/mach-shmobile/board-koelsch.c |   57 ++++++++++++++++++++++++++++++++-
 1 file changed, 56 insertions(+), 1 deletion(-)

Index: renesas/arch/arm/mach-shmobile/board-koelsch.c =================================--- renesas.orig/arch/arm/mach-shmobile/board-koelsch.c +++ renesas/arch/arm/mach-shmobile/board-koelsch.c
@@ -24,15 +24,31 @@
#include <linux/input.h>
#include <linux/kernel.h>
#include <linux/leds.h>
+#include <linux/phy.h>
#include <linux/pinctrl/machine.h>
#include <linux/platform_data/gpio-rcar.h>
#include <linux/platform_device.h>
+#include <linux/sh_eth.h>
#include <mach/common.h>
+#include <mach/irqs.h>
#include <mach/r8a7791.h>
#include <mach/rcar-gen2.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>

+/* Ether */
+static const struct sh_eth_plat_data ether_pdata __initconst = {
+ .phy = 0x1,
+ .edmac_endian = EDMAC_LITTLE_ENDIAN,
+ .phy_interface = PHY_INTERFACE_MODE_RMII,
+ .ether_link_active_low = 1,
+};
+
+static const struct resource ether_resources[] __initconst = {
+ DEFINE_RES_MEM(0xee700000, 0x400),
+ DEFINE_RES_IRQ(gic_spi(162)),
+};
+
/* LEDS */
static struct gpio_led koelsch_leds[] = {
{
@@ -80,6 +96,15 @@ static const struct gpio_keys_platform_d
};

static const struct pinctrl_map koelsch_pinctrl_map[] = {
+ /* Ether */
+ PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791",
+ "eth_link", "eth"),
+ PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791",
+ "eth_mdio", "eth"),
+ PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791",
+ "eth_rmii", "eth"),
+ PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791",
+ "intc_irq0", "intc"),
/* SCIF0 (CN19: DEBUG SERIAL0) */ PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7791",
"scif0_data_d", "scif0"),
@@ -95,6 +120,10 @@ static void __init koelsch_add_standard_
ARRAY_SIZE(koelsch_pinctrl_map));
r8a7791_pinmux_init(); r8a7791_add_standard_devices();
+ platform_device_register_resndata(&platform_bus, "r8a7791-ether", -1,

+					  ether_resources,
+					  ARRAY_SIZE(ether_resources),
+					  &ether_pdata, sizeof(ether_pdata));

platform_device_register_data(&platform_bus, "leds-gpio", -1,
&koelsch_leds_pdata, sizeof(koelsch_leds_pdata));
@@ -103,6 +132,32 @@ static void __init koelsch_add_standard_
sizeof(koelsch_keys_pdata));
}

+/*
+ * Ether LEDs on the Koelsch board are named LINK and ACTIVE which corresponds
+ * to non-default 01 setting of the Micrel KSZ8041 PHY control register 1 bits
+ * 14-15. We have to set them back to 01 from the default 00 value each time
+ * the PHY is reset. It's also important because the PHY's LED0 signal is
+ * connected to SoC's ETH_LINK signal and in the PHY's default mode it will
+ * bounce on and off after each packet, which we apparently want to avoid.
+ */
+static int koelsch_ksz8041_fixup(struct phy_device *phydev)
+{
+ u16 phyctrl1 = phy_read(phydev, 0x1e);
+
+ phyctrl1 &= ~0xc000;
+ phyctrl1 |= 0x4000;
+ return phy_write(phydev, 0x1e, phyctrl1);
+}
+
+static void __init koelsch_init(void)
+{
+ koelsch_add_standard_devices();
+
+ if (IS_ENABLED(CONFIG_PHYLIB))
+ phy_register_fixup_for_id("r8a7791-ether-ff:01",
+ koelsch_ksz8041_fixup);
+}
+
static const char * const koelsch_boards_compat_dt[] __initconst = {
"renesas,koelsch",
NULL,
@@ -112,7 +167,7 @@ DT_MACHINE_START(KOELSCH_DT, "koelsch")
.smp = smp_ops(r8a7791_smp_ops),
.init_early = r8a7791_init_early,
.init_time = rcar_gen2_timer_init,
- .init_machine = koelsch_add_standard_devices,
+ .init_machine = koelsch_init,
.init_late = shmobile_init_late,
.dt_compat = koelsch_boards_compat_dt,
MACHINE_END

#3 lore raw

PATCH v3 2/3 ARM: shmobile: Koelsch: add Ether support

Hi Sergei,

Quoted 7 lines · Sergei Shtylyov

Register Ether platform device and pin data on the Koelsch board. Register platform fixup for Micrel KSZ8041 PHY, just like on the Lager board.

arch/arm/mach-shmobile/board-koelsch.c

Quoted 8 lines
arch/arm/mach-shmobile/board-koelsch.c +7 -0
 
+/* Ether */
+static const struct sh_eth_plat_data ether_pdata __initconst = {
+       .phy                    = 0x1,
+       .edmac_endian           = EDMAC_LITTLE_ENDIAN,
+       .phy_interface          = PHY_INTERFACE_MODE_RMII,
+       .ether_link_active_low  = 1,
+};

With the above, NFS root is terrible slow, and ping indicates more than 10% packet loss. I was trying to debootstrap Debian jessie, but gave up after a few hours.

Based on earlier discussions I found in the mailing list archives, I replaced the
".ether_link_active_low = 1" by ".no_ether_link = 1", and the problem went away. Debootstrap completed in about one hour. No more noticable packet loss during normal operation.
I do still get "net eth0: Receive FIFO Overflow" once in a while, though (e.g. when running nuttcp).

# nuttcp -r amd64box
  112.8022 MB /  10.14 sec =   93.3131 Mbps 2 %TX 15 %RX 0 retrans 0.28 msRTT
# nuttcp -t amd64box
   94.1981 MB /  10.04 sec =   78.7000 Mbps 3 %TX 5 %RX 0 retrans

With ".ether_link_active_low = 1", performance is halved:

# nuttcp -r amd64box
   56.0736 MB /  10.11 sec =   46.5290 Mbps 0 %TX 8 %RX 0 retrans 996.39 msRTT
# nuttcp -t amd64box
   47.7191 MB /  10.03 sec =   39.8991 Mbps 1 %TX 2 %RX 0 retrans

BTW, I'm using renesas-devel-v3.13-rc2-20131205, with the following 4 patches from you applied on top:
sh_eth: add R8A7791 support
ARM: shmobile: r8a7791: add Ether clock
ARM: shmobile: Koelsch: add Ether support
ARM: shmobile: Koelsch: enable Ether in defconfig
Anything I'm missing?

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#4 lore raw

PATCH v3 2/3 ARM: shmobile: Koelsch: add Ether support

Hello.

Quoted 8 lines · Geert Uytterhoeven
Quoted 7 lines

Register Ether platform device and pin data on the Koelsch board. Register platform fixup for Micrel KSZ8041 PHY, just like on the Lager board.

arch/arm/mach-shmobile/board-koelsch.c +0 -0
Quoted 9 lines

arch/arm/mach-shmobile/board-koelsch.c

Quoted 7 lines
arch/arm/mach-shmobile/board-koelsch.c +7 -0
+/* Ether */
+static const struct sh_eth_plat_data ether_pdata __initconst = {
+       .phy                    = 0x1,
+       .edmac_endian           = EDMAC_LITTLE_ENDIAN,
+       .phy_interface          = PHY_INTERFACE_MODE_RMII,
+       .ether_link_active_low  = 1,
+};

With the above, NFS root is terrible slow,

Do you get NFS timeout(s) on booting? I do. It's a known issue.

Quoted 1 line

and ping indicates more than 10% packet loss.

Hm, that I didn't see...

Quoted 6 lines

I was trying to debootstrap Debian jessie, but gave up after a few hours.

Based on earlier discussions I found in the mailing list archives, I replaced the
".ether_link_active_low = 1" by ".no_ether_link = 1", and the problem went away.

That's one way to deal with the issue, but it's not quite correct because
it'll make Ether LEDs function in a way not matching to the intended one. I've added PHY platform fixup to force the LED mode to the intended one after PHY reset that the driver does. I've also submitted a somewhat naive patch to call the fixups after that PHY reset but it got refused by David Miller. That's why we have what we have now. Hopefully, this should get resolved in 3.14 if Florian Fainelli's patch series gets accepted:

http://marc.info/?l=linux-netdev&m8636384109141

Quoted 17 lines

Debootstrap completed in about one hour. No more noticable packet loss during normal operation.
I do still get "net eth0: Receive FIFO Overflow" once in a while, though (e.g. when running nuttcp).

# nuttcp -r amd64box
   112.8022 MB /  10.14 sec =   93.3131 Mbps 2 %TX 15 %RX 0 retrans 0.28 msRTT
# nuttcp -t amd64box
    94.1981 MB /  10.04 sec =   78.7000 Mbps 3 %TX 5 %RX 0 retrans

With ".ether_link_active_low = 1", performance is halved:

# nuttcp -r amd64box
    56.0736 MB /  10.11 sec =   46.5290 Mbps 0 %TX 8 %RX 0 retrans 996.39 msRTT
# nuttcp -t amd64box
    47.7191 MB /  10.03 sec =   39.8991 Mbps 1 %TX 2 %RX 0 retrans
Quoted 7 lines

BTW, I'm using renesas-devel-v3.13-rc2-20131205, with the following 4 patches from you applied on top:
sh_eth: add R8A7791 support
ARM: shmobile: r8a7791: add Ether clock
ARM: shmobile: Koelsch: add Ether support
ARM: shmobile: Koelsch: enable Ether in defconfig
Anything I'm missing?

You can try my simplistic 'sh_eth' driver patch:

http://marc.info/?l=linux-sh&m7911743723032

Quoted 5 lines

Thanks!

Gr{oetje,eeting}s,

Geert

WBR, Sergei

#5 lore raw

PATCH v3 2/3 ARM: shmobile: Koelsch: add Ether support

Quoted 14 lines · Sergei Shtylyov
Quoted 4 lines
Quoted 2 lines
arch/arm/mach-shmobile/board-koelsch.c +0 -0
Quoted 9 lines

arch/arm/mach-shmobile/board-koelsch.c

Quoted 7 lines
arch/arm/mach-shmobile/board-koelsch.c +7 -0
+/* Ether */
+static const struct sh_eth_plat_data ether_pdata __initconst = {
+       .phy                    = 0x1,
+       .edmac_endian           = EDMAC_LITTLE_ENDIAN,
+       .phy_interface          = PHY_INTERFACE_MODE_RMII,
+       .ether_link_active_low  = 1,
+};

With the above, NFS root is terrible slow,

Quoted 1 line

Do you get NFS timeout(s) on booting? I do. It's a known issue.

I only saw "NFS server not responding" once.

Quoted 3 lines

You can try my simplistic 'sh_eth' driver patch:

http://marc.info/?l=linux-sh&m=137911743723032

Thanks, that also fixes the problem!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#6 lore raw

PATCH v3 2/3 ARM: shmobile: Koelsch: add Ether support

Quoted 13 lines · Geert Uytterhoeven
Quoted 12 lines
Quoted 12 lines

arch/arm/mach-shmobile/board-koelsch.c

Quoted 10 lines
arch/arm/mach-shmobile/board-koelsch.c +7 -0
 
+/* Ether */
+static const struct sh_eth_plat_data ether_pdata __initconst = {
+       .phy                    = 0x1,
+       .edmac_endian           = EDMAC_LITTLE_ENDIAN,
+       .phy_interface          = PHY_INTERFACE_MODE_RMII,
+       .ether_link_active_low  = 1,
+};

With the above, NFS root is terrible slow,

Quoted 3 lines
Quoted 1 line

Do you get NFS timeout(s) on booting? I do. It's a known issue.

I only saw "NFS server not responding" once.

Yes, I meant that by NFS timeout. Sometimes I see 2 of them in a row.

Quoted 5 lines
Quoted 3 lines

You can try my simplistic 'sh_eth' driver patch:

http://marc.info/?l=linux-sh&m7911743723032

Thanks, that also fixes the problem!

Let's hope Florian's patches get queued for 3.14. You can also test them
meanwhile...

Quoted 3 lines

Gr{oetje,eeting}s,

Geert

WBR, Sergei

#7 lore raw

PATCH v3 2/3 ARM: shmobile: Koelsch: add Ether support

Quoted 8 lines · Sergei Shtylyov
Quoted 5 lines
Quoted 3 lines

You can try my simplistic 'sh_eth' driver patch:

http://marc.info/?l=linux-sh&m=137911743723032

Thanks, that also fixes the problem!

Let's hope Florian's patches get queued for 3.14. You can also test them
meanwhile...

I applied the whole series "net: phy: consolidate PHY reset", and sh_eth now works fine on Koelsch.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#8 lore raw

PATCH v3 2/3 ARM: shmobile: Koelsch: add Ether support

2013/12/10 Geert Uytterhoeven <[email protected]>:

Quoted 6 lines
Quoted 4 lines · Sergei Shtylyov
Quoted 3 lines
Quoted 3 lines

You can try my simplistic 'sh_eth' driver patch:

http://marc.info/?l=linux-sh&m=137911743723032

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Thanks, that also fixes the problem!

Let's hope Florian's patches get queued for 3.14. You can also test them
meanwhile...

I applied the whole series "net: phy: consolidate PHY reset", and sh_eth now works fine on Koelsch.

Great! Thanks Geert.
--
Florian

#9 lore raw

PATCH v3 3/3 ARM: shmobile: Koelsch: enable Ether in defconfig

In reply to Sergei Shtylyov

Enable the Ether driver in 'koelsch_defconfig' along with DHCP autoconfiguration and NFS root.

---
Changes in version 2:
- new patch in the series.

 arch/arm/configs/koelsch_defconfig |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Index: renesas/arch/arm/configs/koelsch_defconfig =================================--- renesas.orig/arch/arm/configs/koelsch_defconfig +++ renesas/arch/arm/configs/koelsch_defconfig
@@ -29,7 +29,27 @@ CONFIG_VFP=y
CONFIG_NEON=y
# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
CONFIG_PM_RUNTIME=y
+CONFIG_NET=y
+CONFIG_INET=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_NETDEVICES=y
+# CONFIG_NET_VENDOR_ARC is not set
+# CONFIG_NET_CADENCE is not set
+# CONFIG_NET_VENDOR_BROADCOM is not set
+# CONFIG_NET_VENDOR_CIRRUS is not set
+# CONFIG_NET_VENDOR_FARADAY is not set
+# CONFIG_NET_VENDOR_INTEL is not set
+# CONFIG_NET_VENDOR_MARVELL is not set
+# CONFIG_NET_VENDOR_MICREL is not set
+# CONFIG_NET_VENDOR_NATSEMI is not set
+CONFIG_SH_ETH=y
+# CONFIG_NET_VENDOR_SEEQ is not set
+# CONFIG_NET_VENDOR_SMSC is not set
+# CONFIG_NET_VENDOR_STMICRO is not set
+# CONFIG_NET_VENDOR_VIA is not set
+# CONFIG_NET_VENDOR_WIZNET is not set
# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
# CONFIG_INPUT_MOUSE is not set
# CONFIG_LEGACY_PTYS is not set
@@ -49,6 +69,8 @@ CONFIG_LEDS_CLASS=y
CONFIG_TMPFS=y
CONFIG_CONFIGFS_FS=y
# CONFIG_MISC_FILESYSTEMS is not set
+CONFIG_NFS_FS=y
+CONFIG_ROOT_NFS=y
# CONFIG_ENABLE_WARN_DEPRECATED is not set
# CONFIG_ENABLE_MUST_CHECK is not set
# CONFIG_ARM_UNWIND is not set

#10 lore raw

v3 cover Add Ether support for R8A7791/Koelsch board

In reply to Sergei Shtylyov
Quoted 10 lines · Sergei Shtylyov

Hello.

Here's the set of 3 patches against Simon Horman's 'renesas.git' repo,
'renesas-devel-v3.13-rc2-20131205' tag. Here we add the Ether support to the R8A7791/Koelsch board. The patchset requires the 'sh_eth' driver R8A7791 support patch posted earlier in order to work.

[1/3] ARM: shmobile: r8a7791: add Ether clock [2/3] ARM: shmobile: Koelsch: add Ether support [3/3] ARM: shmobile: Koelsch: enable Ether in defconfig

Thanks, I will queue these up.