Changes since v2: Added missing Signed-off-by tags.
Subsystems (2)
Re: [PATCH v3 1/2] regulator: rzg2l: implement connectivity notification
In reply to Michele BisognoQuoted 28 lines · Michele Bisogno
Implement
CON_CTRLmanual connectivity notification.
By settingSEL_CONNECTandCONNECT_1, the UTM+ core is notified of connection status in peripheral mode.Signed-off-by Michele Bisogno <[email protected]>--- drivers/power/regulator/rzg2l-usbphy-regulator.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/power/regulator/rzg2l-usbphy-regulator.c +4
-1@@ -9,16 +9,22 @@#include <renesas/rzg2l-usbphy.h> #define VBENCTL 0x03c +#define CON_CTRL 0x020#define VBENCTL_VBUS_SEL BIT(0) +#define SEL_CONNECT BIT(4) +#define CONNECT_1 BIT(0)static int rzg2l_usbphy_regulator_set_enable (struct udevice *dev,bool enable) {struct rzg2l_usbphy_ctrl_priv *priv =dev_get_priv (dev->parent); -if (enable) +if (enable) {
drivers/power/regulator/rzg2l-usbphy-regulator.c line 30
Quoted 10 lines
drivers/power/regulator/rzg2l-usbphy-regulator.c +4
-1clrbits_le32 (priv->regs +VBENCTL ,VBENCTL_VBUS_SEL ); - else +setbits_le32 (priv->regs +CON_CTRL ,SEL_CONNECT |CONNECT_1 ); + }else {setbits_le32 (priv->regs +VBENCTL ,VBENCTL_VBUS_SEL ); +clrbits_le32 (priv->regs +CON_CTRL ,SEL_CONNECT |CONNECT_1 ); + }return 0 ; }
Why does Linux not need a change like this to drivers/reset/reset-rzg2l-usbphy-ctrl.c ?
Re: [PATCH v3 2/2] usb: gadget: renesas: add support for RZ/G2L SoC
In reply to Michele BisognoQuoted 6 lines · Michele Bisogno
common: Add "renesas,rzg2l-usbhs" compatible and support reset deassertion. Fix a re-entrancy bug by calling
usb_del_gadget_udc()in the remove callback to prevent stale UDC list entries.
fifo: Refactor PIO push/pop logic to handle trailing bytes using iowrite8/ioread8. This ensures correct data alignment on RZ/G2L and simplifies the data transfer loop.
This looks like two separate changes.
Quoted 27 lines
Signed-off-by Michele Bisogno <[email protected]>--- drivers/usb/gadget/rcar/common.c | 15 +++++++++++++++ drivers/usb/gadget/rcar/fifo.c | 23 +++++++++++++---------- 2 files changed, 28 insertions(+), 10 deletions(-)drivers/usb/gadget/rcar/common.c +2
-0@@ -16,6 +16,7 @@#include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <usb.h> +#include <reset.h> #include "common.h" @@ -397,6 +398,7 @@ static int usbhs_udc_otg_probe(struct udevice *dev)struct usbhs_priv_otg_data *priv =dev_get_priv (dev);struct usb_gadget *gadget;struct clk_bulk clk_bulk; +struct reset_ctl_bulk reset_bulk;int ret = -EINVAL ; priv->base =dev_read_addr_ptr (dev);
drivers/usb/gadget/rcar/common.c static int usbhs_udc_otg_probe(struct udevice *dev) · line 422
Quoted 10 lines
drivers/usb/gadget/rcar/common.c +7
-0@@ -411,6 +413,14 @@ static int usbhs_udc_otg_probe(struct udevice *dev)if (ret)return ret; + ret =reset_get_bulk (dev, &reset_bulk); +if (ret) +return ret; + + ret =reset_deassert_bulk (&reset_bulk); +if (ret) +return ret;
This reset handling should be a separate patch.
drivers/usb/gadget/rcar/common.c err_clk: · line 464
Quoted 12 lines
drivers/usb/gadget/rcar/common.c +4
-0clrsetbits_le32 (priv->base +UGCTRL2 ,UGCTRL2_USB0SEL_MASK ,UGCTRL2_USB0SEL_EHCI );clrsetbits_le16 (priv->base +LPSTS ,LPSTS_SUSPM ,LPSTS_SUSPM );@@ -447,7 +457,11 @@ err_clk:static int usbhs_udc_otg_remove (struct udevice *dev) {struct usbhs_priv_otg_data *priv =dev_get_priv (dev); +struct usb_gadget *gadget; + gadget =usbhsg_get_gadget (&priv->usbhs_priv); +if (gadget) +usb_del_gadget_udc (gadget);
This also looks like a separate fix for some other issue ?
Also, reset_assert/put_bulk() is missing here ?
drivers/usb/gadget/rcar/common.c static int usbhs_udc_otg_remove(struct udevice *dev) · line 477
Quoted 8 lines
drivers/usb/gadget/rcar/common.c +1
-0usbhs_rcar3_power_ctrl (&priv->usbhs_priv, false);usbhs_mod_remove (&priv->usbhs_priv);usbhs_fifo_remove (&priv->usbhs_priv);@@ -460,6 +474,7 @@ static int usbhs_udc_otg_remove(struct udevice *dev)static const struct udevice_id usbhs_udc_otg_ids[] = { { .compatible ="renesas,rcar-gen3-usbhs" }, + { .compatible ="renesas,rzg2l-usbhs" },
Separate patch please, this should be last, after all the fixes.
drivers/usb/gadget/rcar/fifo.c
Quoted 6 lines
drivers/usb/gadget/rcar/common.c +0
-0{}, };drivers/usb/gadget/rcar/fifo.c +0
-1--- a/drivers/usb/gadget/rcar/fifo.c
This whole FIFO part should also be a separate patch, and it should also be implemented for the Linux kernel, otherwise the two code bases will diverge. Please submit a matching patch to Linux.
Quoted 41 lines
+++
b/drivers/usb/gadget/rcar/fifo.cdrivers/usb/gadget/rcar/fifo.c +13
-10@@ -535,18 +535,21 @@ static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done)* 32-bit access only */ if (len >=4 && !((unsigned long )buf &0x03 )) { -iowrite32_rep (addr, buf, len /4 ); - len %=4 ; - buf += total_len - len; +int words = len /4 ; + +iowrite32_rep (addr, buf, words); + buf += (words *4 ); + len -= (words *4 ); }/* the rest operation */ -if (usbhs_get_dparam (priv, cfifo_byte_addr)) { -for (i =0 ; i < len; i++) -iowrite8 (buf[i], addr + (i &0x03 )); - }else { -for (i =0 ; i < len; i++) -iowrite8 (buf[i], addr + (0x03 - (i &0x03 ))); +if (len >0 ) { +if (len ==2 && !((unsigned long )buf &0x01 )) { +iowrite16 (*(u16 *)buf, addr); + }else { +for (i =0 ; i < len; i++) +iowrite8 (buf[i], addr); + } }/* @@ -716,7 +719,7 @@ static int usbhsf_pio_try_pop(struct usbhs_pkt *pkt, int *is_done)if (!(i &0x03 )) data =ioread32 (addr); - buf[i] = (data >> ((i &0x03 ) *8 )) &0xff ; + buf[i] =ioread8 (addr); } usbhs_fifo_read_end:
[...]
Quoted 1 line · Michele Bisogno
Changes since v2: Added missing Signed-off-by tags.
The subject should describe what this series does, it shouldn't be a changelog.
Quoted 5 lines
Technical Justification:
While the Linux driver for RZ/G2L relies on DMA, this U-Boot implementation focuses on the PIO path. The refactoring infifo.cto use byte-level access (ioread8/iowrite8) is necessary to handle trailing bytes and alignment requirements specific to the RZ/G2L bus.
Can you please clarify exactly what kind of problem are you hitting with the current code and how is it triggered ? Details please.
Quoted 12 lines
Additionally, explicit reset deassertion is added to the probe sequence, and a re-entrancy fix (
usb_del_gadget_udc) is included to prevent crashes during repeated executions of gadget commands like 'ums'.Michele Bisogno (2):
regulator: rzg2l: implement connectivity notification
usb: gadget: renesas: add support for RZ/G2L SoC.../power/regulator/rzg2l-usbphy-regulator.c | 10 ++++++-- drivers/usb/gadget/rcar/common.c | 15 ++++++++++++ drivers/usb/gadget/rcar/fifo.c | 23 +++++++++++-------- 3 files changed, 36 insertions(+), 12 deletions(-)
[...]
v3 cover Changes since v2: Added missing Signed-off-by tags.
Changes since v2: Added missing Signed-off-by tags.
Technical Justification:
While the Linux driver for RZ/G2L relies on DMA, this U-Boot implementation focuses on the PIO path. The refactoring in fifo.c to use byte-level access (ioread8/iowrite8) is necessary to handle trailing bytes and alignment requirements specific to the RZ/G2L bus.
Additionally, explicit reset deassertion is added to the probe sequence, and a re-entrancy fix (usb_del_gadget_udc) is included to prevent crashes during repeated executions of gadget commands like 'ums'.
Michele Bisogno (2):
regulator: rzg2l: implement connectivity notification
usb: gadget: renesas: add support for RZ/G2L SoC
.../power/regulator/rzg2l-usbphy-regulator.c | 10 ++++++-- drivers/usb/gadget/rcar/common.c | 15 ++++++++++++ drivers/usb/gadget/rcar/fifo.c | 23 +++++++++++-------- 3 files changed, 36 insertions(+), 12 deletions(-)
Signature · 1 line
2.34.1
PATCH v3 1/2 regulator: rzg2l: implement connectivity notification
Implement CON_CTRL manual connectivity notification.
By setting SEL_CONNECT and CONNECT_1, the UTM+ core is notified of connection status in peripheral mode.
--- drivers/power/regulator/rzg2l-usbphy-regulator.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/power/regulator/rzg2l-usbphy-regulator.c +8 -2
@@ -9,16 +9,22 @@#include <renesas/rzg2l-usbphy.h> #define VBENCTL 0x03c +#define CON_CTRL 0x020#define VBENCTL_VBUS_SEL BIT(0) +#define SEL_CONNECT BIT(4) +#define CONNECT_1 BIT(0)static int rzg2l_usbphy_regulator_set_enable (struct udevice *dev,bool enable) {struct rzg2l_usbphy_ctrl_priv *priv =dev_get_priv (dev->parent); -if (enable) +if (enable) {clrbits_le32 (priv->regs +VBENCTL ,VBENCTL_VBUS_SEL ); -else +setbits_le32 (priv->regs +CON_CTRL ,SEL_CONNECT |CONNECT_1 ); + }else {setbits_le32 (priv->regs +VBENCTL ,VBENCTL_VBUS_SEL ); +clrbits_le32 (priv->regs +CON_CTRL ,SEL_CONNECT |CONNECT_1 ); + }return 0 ; }
Signature · 1 line
2.34.1
PATCH v3 2/2 usb: gadget: renesas: add support for RZ/G2L SoC
In reply to Michele Bisognocommon: Add "renesas,rzg2l-usbhs" compatible and support reset deassertion. Fix a re-entrancy bug by calling usb_del_gadget_udc() in the remove callback to prevent stale UDC list entries.
fifo: Refactor PIO push/pop logic to handle trailing bytes using iowrite8/ioread8. This ensures correct data alignment on RZ/G2L and simplifies the data transfer loop.
--- drivers/usb/gadget/rcar/common.c | 15 +++++++++++++++ drivers/usb/gadget/rcar/fifo.c | 23 +++++++++++++---------- 2 files changed, 28 insertions(+), 10 deletions(-)
drivers/usb/gadget/rcar/common.c +15 -0
@@ -16,6 +16,7 @@#include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <usb.h> +#include <reset.h> #include "common.h"
@@ -397,6 +398,7 @@ static int usbhs_udc_otg_probe(struct udevice *dev)struct usbhs_priv_otg_data *priv =dev_get_priv (dev);struct usb_gadget *gadget;struct clk_bulk clk_bulk; +struct reset_ctl_bulk reset_bulk;int ret = -EINVAL ; priv->base =dev_read_addr_ptr (dev);
@@ -411,6 +413,14 @@ static int usbhs_udc_otg_probe(struct udevice *dev)if (ret)return ret; + ret =reset_get_bulk (dev, &reset_bulk); +if (ret) +return ret; + + ret =reset_deassert_bulk (&reset_bulk); +if (ret) +return ret; +clrsetbits_le32 (priv->base +UGCTRL2 ,UGCTRL2_USB0SEL_MASK ,UGCTRL2_USB0SEL_EHCI );clrsetbits_le16 (priv->base +LPSTS ,LPSTS_SUSPM ,LPSTS_SUSPM );
@@ -447,7 +457,11 @@ err_clk:static int usbhs_udc_otg_remove (struct udevice *dev) {struct usbhs_priv_otg_data *priv =dev_get_priv (dev); +struct usb_gadget *gadget; + gadget =usbhsg_get_gadget (&priv->usbhs_priv); +if (gadget) +usb_del_gadget_udc (gadget);usbhs_rcar3_power_ctrl (&priv->usbhs_priv, false);usbhs_mod_remove (&priv->usbhs_priv);usbhs_fifo_remove (&priv->usbhs_priv);
@@ -460,6 +474,7 @@ static int usbhs_udc_otg_remove(struct udevice *dev)static const struct udevice_id usbhs_udc_otg_ids[] = { { .compatible ="renesas,rcar-gen3-usbhs" }, + { .compatible ="renesas,rzg2l-usbhs" }, {}, };
drivers/usb/gadget/rcar/fifo.c +13 -10
@@ -535,18 +535,21 @@ static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done)* 32-bit access only */ if (len >=4 && !((unsigned long )buf &0x03 )) { -iowrite32_rep (addr, buf, len /4 ); - len %=4 ; - buf += total_len - len; +int words = len /4 ; + +iowrite32_rep (addr, buf, words); + buf += (words *4 ); + len -= (words *4 ); }/* the rest operation */ -if (usbhs_get_dparam (priv, cfifo_byte_addr)) { -for (i =0 ; i < len; i++) -iowrite8 (buf[i], addr + (i &0x03 )); - }else { -for (i =0 ; i < len; i++) -iowrite8 (buf[i], addr + (0x03 - (i &0x03 ))); +if (len >0 ) { +if (len ==2 && !((unsigned long )buf &0x01 )) { +iowrite16 (*(u16 *)buf, addr); + }else { +for (i =0 ; i < len; i++) +iowrite8 (buf[i], addr); + } }/*
@@ -716,7 +719,7 @@ static int usbhsf_pio_try_pop(struct usbhs_pkt *pkt, int *is_done)if (!(i &0x03 )) data =ioread32 (addr); - buf[i] = (data >> ((i &0x03 ) *8 )) &0xff ; + buf[i] =ioread8 (addr); } usbhs_fifo_read_end:
Signature · 1 line
2.34.1