Skip to contentSkip to conversation

v4.16 backports of M3-N PFC, Stout and RAVB

PATCH In review Magnus Damm 2 participants 5 messages Apr 18, 2018

Subsystems (7)
lore
Share & tools
lore

Magnus Damm

author maintainer
#0 lore raw

cover v4.16 backports of M3-N PFC, Stout and RAVB

v4.16 backports of M3-N PFC, Stout and RAVB

[PATCH 01/03] pinctrl: sh-pfc: r8a77965: Initial support including SCIF [PATCH 02/03] ravb: MTU support and minor fix
[PATCH 03/03] ARM: shmobile: stout: Initial support and regulator quirk

This series contain various backports useful for testing on v4.16 in case latest upstream kernel remains unstable.

The series contains support for:
- R-Car M3-N PFC support (Initial support and SCIF device support)
- Ethernet AVB updates (MTU support and fix)
- Stout board support (Initial support and regulator quirk)

Thanks to Niklas, Jacopo and Marek for their efforts with the upstreaming.

---

Fits on top of v4.16 mainline

 Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt |    1 
 arch/arm/boot/dts/Makefile                                        |    1 
 arch/arm/boot/dts/r8a7790-stout.dts                               |  363 +
 arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c                |   23 
 drivers/net/ethernet/renesas/ravb.h                               |    1 
 drivers/net/ethernet/renesas/ravb_main.c                          |   33 
 drivers/pinctrl/sh-pfc/Kconfig                                    |    5 
 drivers/pinctrl/sh-pfc/Makefile                                   |    1 
 drivers/pinctrl/sh-pfc/core.c                                     |    6 
 drivers/pinctrl/sh-pfc/pfc-r8a77965.c                             | 3022 ++++++++++
 drivers/pinctrl/sh-pfc/sh_pfc.h                                   |    1 
 11 files changed, 3443 insertions(+), 14 deletions(-)
author maintainer
#1 lore raw

PATCH 2/3 ravb: MTU support and minor fix

From: Magnus Damm <[email protected]>

This is a back port to v4.16 of the following commits merged in v4.17-rc1:
5c3d0fd4b2c0 ravb: remove erroneous comment
75efa06f457b ravb: add support for changing MTU

Thanks to Niklas, Sergei and Dave Miller for the upstreaming efforts.

---

 drivers/net/ethernet/renesas/ravb.h      |    1 
 drivers/net/ethernet/renesas/ravb_main.c |   33 +++++++++++++++++++++++-------
 2 files changed, 27 insertions(+), 7 deletions(-)
drivers/net/ethernet/renesas/ravb.h +1 -0
@@ -1018,6 +1018,7 @@ struct ravb_private {
 	u32 dirty_rx[NUM_RX_QUEUE];	/* Producer ring indices */
 	u32 cur_tx[NUM_TX_QUEUE];
 	u32 dirty_tx[NUM_TX_QUEUE];
+	u32 rx_buf_sz;			/* Based on MTU+slack. */
 	struct napi_struct napi[NUM_RX_QUEUE];
 	struct work_struct work;
 	/* MII transceiver section. */
drivers/net/ethernet/renesas/ravb_main.c +26 -7
@@ -238,7 +238,7 @@ static void ravb_ring_free(struct net_de
 					       le32_to_cpu(desc->dptr)))
 				dma_unmap_single(ndev->dev.parent,
 						 le32_to_cpu(desc->dptr),
-						 PKT_BUF_SZ,
+						 priv->rx_buf_sz,
 						 DMA_FROM_DEVICE);
 		}
 		ring_size = sizeof(struct ravb_ex_rx_desc) *
@@ -300,9 +300,9 @@ static void ravb_ring_format(struct net_
 	for (i = 0; i < priv->num_rx_ring[q]; i++) {
 		/* RX descriptor */
 		rx_desc = &priv->rx_ring[q][i];
-		rx_desc->ds_cc = cpu_to_le16(PKT_BUF_SZ);
+		rx_desc->ds_cc = cpu_to_le16(priv->rx_buf_sz);
 		dma_addr = dma_map_single(ndev->dev.parent, priv->rx_skb[q][i]->data,
-					  PKT_BUF_SZ,
+					  priv->rx_buf_sz,
 					  DMA_FROM_DEVICE);
 		/* We just set the data size to 0 for a failed mapping which
 		 * should prevent DMA from happening...
@@ -346,6 +346,9 @@ static int ravb_ring_init(struct net_dev
 	int ring_size;
 	int i;
 
+	priv->rx_buf_sz = (ndev->mtu <= 1492 ? PKT_BUF_SZ : ndev->mtu) +
+		ETH_HLEN + VLAN_HLEN;
+
 	/* Allocate RX and TX skb rings */
 	priv->rx_skb[q] = kcalloc(priv->num_rx_ring[q],
 				  sizeof(*priv->rx_skb[q]), GFP_KERNEL);
@@ -355,7 +358,7 @@ static int ravb_ring_init(struct net_dev
 		goto error;
 
 	for (i = 0; i < priv->num_rx_ring[q]; i++) {
-		skb = netdev_alloc_skb(ndev, PKT_BUF_SZ + RAVB_ALIGN - 1);
+		skb = netdev_alloc_skb(ndev, priv->rx_buf_sz + RAVB_ALIGN - 1);
 		if (!skb)
 			goto error;
 		ravb_set_buffer_align(skb);
@@ -586,7 +589,7 @@ static bool ravb_rx(struct net_device *n
 			skb = priv->rx_skb[q][entry];
 			priv->rx_skb[q][entry] = NULL;
 			dma_unmap_single(ndev->dev.parent, le32_to_cpu(desc->dptr),
-					 PKT_BUF_SZ,
+					 priv->rx_buf_sz,
 					 DMA_FROM_DEVICE);
 			get_ts &= (q == RAVB_NC) ?
 					RAVB_RXTSTAMP_TYPE_V2_L2_EVENT :
@@ -619,11 +622,12 @@ static bool ravb_rx(struct net_device *n
 	for (; priv->cur_rx[q] - priv->dirty_rx[q] > 0; priv->dirty_rx[q]++) {
 		entry = priv->dirty_rx[q] % priv->num_rx_ring[q];
 		desc = &priv->rx_ring[q][entry];
-		desc->ds_cc = cpu_to_le16(PKT_BUF_SZ);
+		desc->ds_cc = cpu_to_le16(priv->rx_buf_sz);
 
 		if (!priv->rx_skb[q][entry]) {
 			skb = netdev_alloc_skb(ndev,
-					       PKT_BUF_SZ + RAVB_ALIGN - 1);
+					       priv->rx_buf_sz +
+					       RAVB_ALIGN - 1);
 			if (!skb)
 				break;	/* Better luck next round. */
 			ravb_set_buffer_align(skb);
@@ -1854,6 +1858,17 @@ static int ravb_do_ioctl(struct net_devi
 	return phy_mii_ioctl(phydev, req, cmd);
 }
 
+static int ravb_change_mtu(struct net_device *ndev, int new_mtu)
+{
+	if (netif_running(ndev))
+		return -EBUSY;
+
+	ndev->mtu = new_mtu;
+	netdev_update_features(ndev);
+
+	return 0;
+}
+
 static void ravb_set_rx_csum(struct net_device *ndev, bool enable)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
@@ -1895,6 +1910,7 @@ static const struct net_device_ops ravb_
 	.ndo_set_rx_mode	= ravb_set_rx_mode,
 	.ndo_tx_timeout		= ravb_tx_timeout,
 	.ndo_do_ioctl		= ravb_do_ioctl,
+	.ndo_change_mtu		= ravb_change_mtu,
 	.ndo_validate_addr	= eth_validate_addr,
 	.ndo_set_mac_address	= eth_mac_addr,
 	.ndo_set_features	= ravb_set_features,
@@ -2117,6 +2133,9 @@ static int ravb_probe(struct platform_de
 		goto out_release;
 	}
 
+	ndev->max_mtu = 2048 - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN);
+	ndev->min_mtu = ETH_MIN_MTU;
+
 	/* Set function */
 	ndev->netdev_ops = &ravb_netdev_ops;
 	ndev->ethtool_ops = &ravb_ethtool_ops;
author maintainer
#2 lore raw

PATCH 3/3 ARM: shmobile: stout: Initial support and regulator quirk

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

This is a back port to v4.16 of the following commits merged in v4.17-rc1:
ff938cd14d67 ARM: shmobile: stout: enable R-Car Gen2 regulator quirk 92bcfdb334ca ARM: dts: stout: Initial r8a7790 Stout board support

Thanks to Marek, Wolfram and Simon for the upstreaming efforts.

---

 arch/arm/boot/dts/Makefile                         |    1 
 arch/arm/boot/dts/r8a7790-stout.dts                |  363 ++++++++++++++++++++
 arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c |   23 -
 3 files changed, 380 insertions(+), 7 deletions(-)
arch/arm/boot/dts/Makefile +1 -0
@@ -784,6 +784,7 @@ dtb-$(CONFIG_ARCH_RENESAS) += \
 	r8a7778-bockw.dtb \
 	r8a7779-marzen.dtb \
 	r8a7790-lager.dtb \
+	r8a7790-stout.dtb \
 	r8a7791-koelsch.dtb \
 	r8a7791-porter.dtb \
 	r8a7792-blanche.dtb \
arch/arm/boot/dts/r8a7790-stout.dts new file +363 -0

363 lines not on this page · raw message

arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c +16 -7
@@ -1,9 +1,9 @@
 /*
  * R-Car Generation 2 da9063/da9210 regulator quirk
  *
- * The r8a7790/lager and r8a7791/koelsch development boards have da9063 and
- * da9210 regulators.  Both regulators have their interrupt request lines tied
- * to the same interrupt pin (IRQ2) on the SoC.
+ * Certain Gen2 development boards have an da9063 and one or more da9210
+ * regulators. All of these regulators have their interrupt request lines
+ * tied to the same interrupt pin (IRQ2) on the SoC.
  *
  * After cold boot or da9063-induced restart, both the da9063 and da9210 seem
  * to assert their interrupt request lines.  Hence as soon as one driver
@@ -50,7 +50,7 @@ static void __iomem *irqc;
 static u8 da9063_irq_clr[] = { DA9063_REG_IRQ_MASK_A, 0xff, 0xff, 0xff, 0xff };
 static u8 da9210_irq_clr[] = { DA9210_REG_MASK_A, 0xff, 0xff };
 
-static struct i2c_msg da9xxx_msgs[2] = {
+static struct i2c_msg da9xxx_msgs[3] = {
 	{
 		.addr = 0x58,
 		.len = ARRAY_SIZE(da9063_irq_clr),
@@ -59,6 +59,10 @@ static struct i2c_msg da9xxx_msgs[2] = {
 		.addr = 0x68,
 		.len = ARRAY_SIZE(da9210_irq_clr),
 		.buf = da9210_irq_clr,
+	}, {
+		.addr = 0x70,
+		.len = ARRAY_SIZE(da9210_irq_clr),
+		.buf = da9210_irq_clr,
 	},
 };
 
@@ -85,11 +89,15 @@ static int regulator_quirk_notify(struct
 	dev_dbg(dev, "Detected %s\n", client->name);
 
 	if ((client->addr == 0x58 && !strcmp(client->name, "da9063")) ||
-	    (client->addr == 0x68 && !strcmp(client->name, "da9210"))) {
-		int ret;
+	    (client->addr == 0x68 && !strcmp(client->name, "da9210")) ||
+	    (client->addr == 0x70 && !strcmp(client->name, "da9210"))) {
+		int ret, len;
+
+		/* There are two DA9210 on Stout, one on the other boards. */
+		len = of_machine_is_compatible("renesas,stout") ? 3 : 2;
 
 		dev_info(&client->dev, "clearing da9063/da9210 interrupts\n");
-		ret = i2c_transfer(client->adapter, da9xxx_msgs, ARRAY_SIZE(da9xxx_msgs));
+		ret = i2c_transfer(client->adapter, da9xxx_msgs, len);
 		if (ret != ARRAY_SIZE(da9xxx_msgs))
 			dev_err(&client->dev, "i2c error %d\n", ret);
 	}
@@ -118,6 +126,7 @@ static int __init rcar_gen2_regulator_qu
 
 	if (!of_machine_is_compatible("renesas,koelsch") &&
 	    !of_machine_is_compatible("renesas,lager") &&
+	    !of_machine_is_compatible("renesas,stout") &&
 	    !of_machine_is_compatible("renesas,gose"))
 		return -ENODEV;
 
#3 lore raw

Re: [PATCH 03/03] ARM: shmobile: stout: Initial support and regulator quirk

Hi Magnus,

Quoted 5 lines · Magnus Damm

From: Magnus Damm <[email protected]>

This is a back port to v4.16 of the following commits merged in v4.17-rc1:
ff938cd14d67 ARM: shmobile: stout: enable R-Car Gen2 regulator quirk 92bcfdb334ca ARM: dts: stout: Initial r8a7790 Stout board support

I think you also want
60fc75bdf5b1b8ed ("ARM: shmobile: rcar-gen2: Fix error check in regulator quirk")

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
author maintainer
#4 lore raw

Re: [PATCH 03/03] ARM: shmobile: stout: Initial support and regulator quirk

Hi Geert,

Quoted 5 lines · Geert Uytterhoeven

Hi Magnus,

Quoted 2 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Quoted 7 lines
Quoted 3 lines

This is a back port to v4.16 of the following commits merged in v4.17-rc1:
ff938cd14d67 ARM: shmobile: stout: enable R-Car Gen2 regulator quirk 92bcfdb334ca ARM: dts: stout: Initial r8a7790 Stout board support

I think you also want
60fc75bdf5b1b8ed ("ARM: shmobile: rcar-gen2: Fix error check in regulator quirk")

Thanks - good point!

Cheers,

/ magnus