From 97a7968448cb0ef5c15e3d395746b108b1a55556 Mon Sep 17 00:00:00 2001 From: Chris Brandt Date: Wed, 15 May 2019 10:20:41 -0500 Subject: usb: renesas_usbhs: move flags to param Move options from 'flags' field in private structure to param structure where other options are already being kept. Signed-off-by: Chris Brandt Reviewed-by: Yoshihiro Shimoda Reviewed-by: Simon Horman Signed-off-by: Greg Kroah-Hartman --- include/linux/usb/renesas_usbhs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/linux/usb') diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h index 53924f8e840c..17fae6e504cc 100644 --- a/include/linux/usb/renesas_usbhs.h +++ b/include/linux/usb/renesas_usbhs.h @@ -189,6 +189,7 @@ struct renesas_usbhs_driver_param { u32 has_otg:1; /* for controlling PWEN/EXTLP */ u32 has_sudmac:1; /* for SUDMAC */ u32 has_usb_dmac:1; /* for USB-DMAC */ + u32 runtime_pwctrl:1; #define USBHS_USB_DMAC_XFER_SIZE 32 /* hardcode the xfer size */ }; -- cgit v1.2.3-58-ga151 From 2195e3af9079ea067079e98446ea6a457c81a98c Mon Sep 17 00:00:00 2001 From: Chris Brandt Date: Wed, 15 May 2019 10:20:42 -0500 Subject: usb: renesas_usbhs: add support for CNEN bit For some SoC, CNEN must be set for USB Device mode operation. Signed-off-by: Chris Brandt Reviewed-by: Yoshihiro Shimoda Reviewed-by: Simon Horman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/renesas_usbhs/common.c | 6 ++++++ drivers/usb/renesas_usbhs/common.h | 1 + include/linux/usb/renesas_usbhs.h | 1 + 3 files changed, 8 insertions(+) (limited to 'include/linux/usb') diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index 1de7a44f3415..734fb4e542c5 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -114,6 +114,12 @@ void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable) u16 mask = DCFM | DRPD | DPRPU | HSE | USBE; u16 val = HSE | USBE; + /* CNEN bit is required for function operation */ + if (usbhs_get_dparam(priv, has_cnen)) { + mask |= CNEN; + val |= CNEN; + } + /* * if enable * diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h index 1fbffb7bbc8f..de74ebd1a347 100644 --- a/drivers/usb/renesas_usbhs/common.h +++ b/drivers/usb/renesas_usbhs/common.h @@ -104,6 +104,7 @@ struct usbhs_priv; /* SYSCFG */ #define SCKE (1 << 10) /* USB Module Clock Enable */ +#define CNEN (1 << 8) /* Single-ended receiver operation Enable */ #define HSE (1 << 7) /* High-Speed Operation Enable */ #define DCFM (1 << 6) /* Controller Function Select */ #define DRPD (1 << 5) /* D+ Line/D- Line Resistance Control */ diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h index 17fae6e504cc..9097a38fcda8 100644 --- a/include/linux/usb/renesas_usbhs.h +++ b/include/linux/usb/renesas_usbhs.h @@ -190,6 +190,7 @@ struct renesas_usbhs_driver_param { u32 has_sudmac:1; /* for SUDMAC */ u32 has_usb_dmac:1; /* for USB-DMAC */ u32 runtime_pwctrl:1; + u32 has_cnen:1; #define USBHS_USB_DMAC_XFER_SIZE 32 /* hardcode the xfer size */ }; -- cgit v1.2.3-58-ga151 From f756066990607dbe8ea5579c925b48e646891f3e Mon Sep 17 00:00:00 2001 From: Chris Brandt Date: Wed, 15 May 2019 10:20:43 -0500 Subject: usb: renesas_usbhs: support byte addressable CFIFO Some SoC have a CFIFO register that is byte addressable. This means when the CFIFO access is set to 32-bit, you can write 8-bit values to addresses CFIFO+0, CFIFO+1, CFIFO+2, CFIFO+3. Signed-off-by: Chris Brandt Reviewed-by: Yoshihiro Shimoda Reviewed-by: Simon Horman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/renesas_usbhs/fifo.c | 9 +++++++-- include/linux/usb/renesas_usbhs.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'include/linux/usb') diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index 39fa2fc1b8b7..452b456ac24e 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c @@ -543,8 +543,13 @@ static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done) } /* the rest operation */ - for (i = 0; i < len; i++) - iowrite8(buf[i], addr + (0x03 - (i & 0x03))); + 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))); + } /* * variable update diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h index 9097a38fcda8..87043fd21d54 100644 --- a/include/linux/usb/renesas_usbhs.h +++ b/include/linux/usb/renesas_usbhs.h @@ -191,6 +191,7 @@ struct renesas_usbhs_driver_param { u32 has_usb_dmac:1; /* for USB-DMAC */ u32 runtime_pwctrl:1; u32 has_cnen:1; + u32 cfifo_byte_addr:1; /* CFIFO is byte addressable */ #define USBHS_USB_DMAC_XFER_SIZE 32 /* hardcode the xfer size */ }; -- cgit v1.2.3-58-ga151 From b69dce6341053cd51f3692a2ab3825140fad6ab8 Mon Sep 17 00:00:00 2001 From: Chris Brandt Date: Wed, 15 May 2019 10:20:44 -0500 Subject: usb: renesas_usbhs: Add support for RZ/A2 The RZ/A2 is similar to the R-Car Gen3 with some small differences. Signed-off-by: Chris Brandt Reviewed-by: Simon Horman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/renesas_usbhs/Makefile | 2 +- drivers/usb/renesas_usbhs/common.c | 15 ++++++++ drivers/usb/renesas_usbhs/rza.h | 1 + drivers/usb/renesas_usbhs/rza2.c | 72 ++++++++++++++++++++++++++++++++++++++ include/linux/usb/renesas_usbhs.h | 1 + 5 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/renesas_usbhs/rza2.c (limited to 'include/linux/usb') diff --git a/drivers/usb/renesas_usbhs/Makefile b/drivers/usb/renesas_usbhs/Makefile index 5c5b51bb48ef..a1fed56b0957 100644 --- a/drivers/usb/renesas_usbhs/Makefile +++ b/drivers/usb/renesas_usbhs/Makefile @@ -5,7 +5,7 @@ obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs.o -renesas_usbhs-y := common.o mod.o pipe.o fifo.o rcar2.o rcar3.o rza.o +renesas_usbhs-y := common.o mod.o pipe.o fifo.o rcar2.o rcar3.o rza.o rza2.o ifneq ($(CONFIG_USB_RENESAS_USBHS_HCD),) renesas_usbhs-y += mod_host.o diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index 734fb4e542c5..c7c9c5d75a56 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -571,6 +571,17 @@ static const struct usbhs_of_data rza1_data = { } }; +static const struct usbhs_of_data rza2_data = { + .platform_callback = &usbhs_rza2_ops, + .param = { + .type = USBHS_TYPE_RZA2, + .has_cnen = 1, + .cfifo_byte_addr = 1, + .pipe_configs = usbhsc_new_pipe, + .pipe_size = ARRAY_SIZE(usbhsc_new_pipe), + } +}; + /* * platform functions */ @@ -619,6 +630,10 @@ static const struct of_device_id usbhs_of_match[] = { .compatible = "renesas,rza1-usbhs", .data = &rza1_data, }, + { + .compatible = "renesas,rza2-usbhs", + .data = &rza2_data, + }, { }, }; MODULE_DEVICE_TABLE(of, usbhs_of_match); diff --git a/drivers/usb/renesas_usbhs/rza.h b/drivers/usb/renesas_usbhs/rza.h index ca917ca54f6d..073a53d1d442 100644 --- a/drivers/usb/renesas_usbhs/rza.h +++ b/drivers/usb/renesas_usbhs/rza.h @@ -2,3 +2,4 @@ #include "common.h" extern const struct renesas_usbhs_platform_callback usbhs_rza1_ops; +extern const struct renesas_usbhs_platform_callback usbhs_rza2_ops; diff --git a/drivers/usb/renesas_usbhs/rza2.c b/drivers/usb/renesas_usbhs/rza2.c new file mode 100644 index 000000000000..9d8551f93533 --- /dev/null +++ b/drivers/usb/renesas_usbhs/rza2.c @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Renesas USB driver RZ/A2 initialization and power control + * + * Copyright (C) 2019 Chris Brandt + * Copyright (C) 2019 Renesas Electronics Corporation + */ + +#include +#include +#include +#include +#include "common.h" +#include "rza.h" + +static int usbhs_rza2_hardware_init(struct platform_device *pdev) +{ + struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); + struct phy *phy = phy_get(&pdev->dev, "usb"); + + if (IS_ERR(phy)) + return PTR_ERR(phy); + + priv->phy = phy; + return 0; +} + +static int usbhs_rza2_hardware_exit(struct platform_device *pdev) +{ + struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); + + phy_put(priv->phy); + priv->phy = NULL; + + return 0; +} + +static int usbhs_rza2_power_ctrl(struct platform_device *pdev, + void __iomem *base, int enable) +{ + struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); + int retval = 0; + + if (!priv->phy) + return -ENODEV; + + if (enable) { + retval = phy_init(priv->phy); + usbhs_bset(priv, SUSPMODE, SUSPM, SUSPM); + udelay(100); /* Wait for PLL to become stable */ + if (!retval) + retval = phy_power_on(priv->phy); + } else { + usbhs_bset(priv, SUSPMODE, SUSPM, 0); + phy_power_off(priv->phy); + phy_exit(priv->phy); + } + + return retval; +} + +static int usbhs_rza2_get_id(struct platform_device *pdev) +{ + return USBHS_GADGET; +} + +const struct renesas_usbhs_platform_callback usbhs_rza2_ops = { + .hardware_init = usbhs_rza2_hardware_init, + .hardware_exit = usbhs_rza2_hardware_exit, + .power_ctrl = usbhs_rza2_power_ctrl, + .get_id = usbhs_rza2_get_id, +}; diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h index 87043fd21d54..3f53043fb56b 100644 --- a/include/linux/usb/renesas_usbhs.h +++ b/include/linux/usb/renesas_usbhs.h @@ -199,6 +199,7 @@ struct renesas_usbhs_driver_param { #define USBHS_TYPE_RCAR_GEN3 2 #define USBHS_TYPE_RCAR_GEN3_WITH_PLL 3 #define USBHS_TYPE_RZA1 4 +#define USBHS_TYPE_RZA2 5 /* * option: -- cgit v1.2.3-58-ga151 From 32a6cfdfd168982cd7cd2898372da5eb49e56daf Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Wed, 5 Jun 2019 15:16:21 +0900 Subject: usb: renesas_usbhs: remove sudmac support SUDMAC feature was supported in v3.10, but was never used by any platform. So, this patch removes it. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Geert Uytterhoeven Reviewed-by: Simon Horman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/renesas_usbhs/fifo.c | 6 +----- include/linux/usb/renesas_usbhs.h | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'include/linux/usb') diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index 452b456ac24e..e84d2ac2a30a 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c @@ -12,7 +12,6 @@ #include "pipe.h" #define usbhsf_get_cfifo(p) (&((p)->fifo_info.cfifo)) -#define usbhsf_is_cfifo(p, f) (usbhsf_get_cfifo(p) == f) #define usbhsf_fifo_is_busy(f) ((f)->pipe) /* see usbhs_pipe_select_fifo */ @@ -325,10 +324,7 @@ static int usbhsf_fifo_select(struct usbhs_pipe *pipe, } /* "base" will be used below */ - if (usbhs_get_dparam(priv, has_sudmac) && !usbhsf_is_cfifo(priv, fifo)) - usbhs_write(priv, fifo->sel, base); - else - usbhs_write(priv, fifo->sel, base | MBW_32); + usbhs_write(priv, fifo->sel, base | MBW_32); /* check ISEL and CURPIPE value */ while (timeout--) { diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h index 3f53043fb56b..a2481f4da841 100644 --- a/include/linux/usb/renesas_usbhs.h +++ b/include/linux/usb/renesas_usbhs.h @@ -187,7 +187,6 @@ struct renesas_usbhs_driver_param { * option: */ u32 has_otg:1; /* for controlling PWEN/EXTLP */ - u32 has_sudmac:1; /* for SUDMAC */ u32 has_usb_dmac:1; /* for USB-DMAC */ u32 runtime_pwctrl:1; u32 has_cnen:1; -- cgit v1.2.3-58-ga151 From e60e982375244026ca46feeba0fb5bb4d51b5a67 Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Wed, 5 Jun 2019 15:16:22 +0900 Subject: usb: renesas_usbhs: remove controlling PWEN/EXTLP support Controlling PWMEN/EXTLP (named as "has_otg") was supported in v3.2, but the last user (kzm9g) was removed by the commit 30f8925a57d8ad49 ("ARM: shmobile: Remove legacy board code for KZM-A9-GT"). So, this patch remove it. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Geert Uytterhoeven Reviewed-by: Simon Horman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/renesas_usbhs/common.c | 4 ---- include/linux/usb/renesas_usbhs.h | 1 - 2 files changed, 5 deletions(-) (limited to 'include/linux/usb') diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index c7c9c5d75a56..a501ea609019 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -95,10 +95,6 @@ void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable) { u16 mask = DCFM | DRPD | DPRPU | HSE | USBE; u16 val = DCFM | DRPD | HSE | USBE; - int has_otg = usbhs_get_dparam(priv, has_otg); - - if (has_otg) - usbhs_bset(priv, DVSTCTR, (EXTLP | PWEN), (EXTLP | PWEN)); /* * if enable diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h index a2481f4da841..b2cba7c74444 100644 --- a/include/linux/usb/renesas_usbhs.h +++ b/include/linux/usb/renesas_usbhs.h @@ -186,7 +186,6 @@ struct renesas_usbhs_driver_param { /* * option: */ - u32 has_otg:1; /* for controlling PWEN/EXTLP */ u32 has_usb_dmac:1; /* for USB-DMAC */ u32 runtime_pwctrl:1; u32 has_cnen:1; -- cgit v1.2.3-58-ga151 From d1609c312d42f3bdfe7df9d4dd9d5b2c7ace90f4 Mon Sep 17 00:00:00 2001 From: Peter Chen Date: Sun, 28 Apr 2019 10:35:31 +0800 Subject: usb: chipidea: imx: add imx7ulp support In this commit, we add CI_HDRC_PMQOS to avoid system entering idle, at imx7ulp, if the system enters idle, the DMA will stop, so the USB transfer can't work at this case. Signed-off-by: Peter Chen --- drivers/usb/chipidea/ci_hdrc_imx.c | 28 +++++++++++++++++++++++++++- drivers/usb/chipidea/usbmisc_imx.c | 4 ++++ include/linux/usb/chipidea.h | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) (limited to 'include/linux/usb') diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c index ceec8d5985d4..a76708501236 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "ci.h" #include "ci_hdrc_imx.h" @@ -63,6 +64,11 @@ static const struct ci_hdrc_imx_platform_flag imx7d_usb_data = { .flags = CI_HDRC_SUPPORTS_RUNTIME_PM, }; +static const struct ci_hdrc_imx_platform_flag imx7ulp_usb_data = { + .flags = CI_HDRC_SUPPORTS_RUNTIME_PM | + CI_HDRC_PMQOS, +}; + static const struct of_device_id ci_hdrc_imx_dt_ids[] = { { .compatible = "fsl,imx23-usb", .data = &imx23_usb_data}, { .compatible = "fsl,imx28-usb", .data = &imx28_usb_data}, @@ -72,6 +78,7 @@ static const struct of_device_id ci_hdrc_imx_dt_ids[] = { { .compatible = "fsl,imx6sx-usb", .data = &imx6sx_usb_data}, { .compatible = "fsl,imx6ul-usb", .data = &imx6ul_usb_data}, { .compatible = "fsl,imx7d-usb", .data = &imx7d_usb_data}, + { .compatible = "fsl,imx7ulp-usb", .data = &imx7ulp_usb_data}, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, ci_hdrc_imx_dt_ids); @@ -93,6 +100,8 @@ struct ci_hdrc_imx_data { struct clk *clk_ahb; struct clk *clk_per; /* --------------------------------- */ + struct pm_qos_request pm_qos_req; + const struct ci_hdrc_imx_platform_flag *plat_data; }; /* Common functions shared by usbmisc drivers */ @@ -309,6 +318,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) if (!data) return -ENOMEM; + data->plat_data = imx_platform_flag; + pdata.flags |= imx_platform_flag->flags; platform_set_drvdata(pdev, data); data->usbmisc_data = usbmisc_get_init_data(dev); if (IS_ERR(data->usbmisc_data)) @@ -369,6 +380,11 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) } } } + + if (pdata.flags & CI_HDRC_PMQOS) + pm_qos_add_request(&data->pm_qos_req, + PM_QOS_CPU_DMA_LATENCY, 0); + ret = imx_get_clks(dev); if (ret) goto disable_hsic_regulator; @@ -396,7 +412,6 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) usb_phy_init(pdata.usb_phy); } - pdata.flags |= imx_platform_flag->flags; if (pdata.flags & CI_HDRC_SUPPORTS_RUNTIME_PM) data->supports_runtime_pm = true; @@ -439,6 +454,8 @@ err_clk: disable_hsic_regulator: if (data->hsic_pad_regulator) ret = regulator_disable(data->hsic_pad_regulator); + if (pdata.flags & CI_HDRC_PMQOS) + pm_qos_remove_request(&data->pm_qos_req); return ret; } @@ -455,6 +472,8 @@ static int ci_hdrc_imx_remove(struct platform_device *pdev) if (data->override_phy_control) usb_phy_shutdown(data->phy); imx_disable_unprepare_clks(&pdev->dev); + if (data->plat_data->flags & CI_HDRC_PMQOS) + pm_qos_remove_request(&data->pm_qos_req); if (data->hsic_pad_regulator) regulator_disable(data->hsic_pad_regulator); @@ -480,6 +499,9 @@ static int __maybe_unused imx_controller_suspend(struct device *dev) } imx_disable_unprepare_clks(dev); + if (data->plat_data->flags & CI_HDRC_PMQOS) + pm_qos_remove_request(&data->pm_qos_req); + data->in_lpm = true; return 0; @@ -497,6 +519,10 @@ static int __maybe_unused imx_controller_resume(struct device *dev) return 0; } + if (data->plat_data->flags & CI_HDRC_PMQOS) + pm_qos_add_request(&data->pm_qos_req, + PM_QOS_CPU_DMA_LATENCY, 0); + ret = imx_prepare_enable_clks(dev); if (ret) return ret; diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index d8b67e150b12..b7a5727d0c8a 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -763,6 +763,10 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = { .compatible = "fsl,imx7d-usbmisc", .data = &imx7d_usbmisc_ops, }, + { + .compatible = "fsl,imx7ulp-usbmisc", + .data = &imx7d_usbmisc_ops, + }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, usbmisc_imx_dt_ids); diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h index 911e05af671e..edd89b7c8f18 100644 --- a/include/linux/usb/chipidea.h +++ b/include/linux/usb/chipidea.h @@ -61,6 +61,7 @@ struct ci_hdrc_platform_data { #define CI_HDRC_OVERRIDE_PHY_CONTROL BIT(12) /* Glue layer manages phy */ #define CI_HDRC_REQUIRES_ALIGNED_DMA BIT(13) #define CI_HDRC_IMX_IS_HSIC BIT(14) +#define CI_HDRC_PMQOS BIT(15) enum usb_dr_mode dr_mode; #define CI_HDRC_CONTROLLER_RESET_EVENT 0 #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1 -- cgit v1.2.3-58-ga151 From 4ed9890c4c44d2ead7b57ad65425e3fbe9b9d42a Mon Sep 17 00:00:00 2001 From: Anurag Kumar Vulisha Date: Fri, 10 May 2019 12:37:27 +0530 Subject: usb: gadget: send usb_gadget as an argument in get_config_params Passing struct usb_gadget * as an extra argument in get_config_params makes gadget drivers to easily update the U1DevExitLat & U2DevExitLat values based on the values passed from the device tree. This patch does the same Signed-off-by: Anurag Kumar Vulisha Signed-off-by: Felipe Balbi --- drivers/usb/gadget/composite.c | 2 +- include/linux/usb/gadget.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'include/linux/usb') diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index b8a15840b4ff..9118b42c70b6 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -653,7 +653,7 @@ static int bos_desc(struct usb_composite_dev *cdev) /* Get Controller configuration */ if (cdev->gadget->ops->get_config_params) { - cdev->gadget->ops->get_config_params( + cdev->gadget->ops->get_config_params(cdev->gadget, &dcd_config_params); } else { dcd_config_params.bU1devExitLat = diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 7595056b96c1..fb19141151d8 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -310,7 +310,8 @@ struct usb_gadget_ops { int (*pullup) (struct usb_gadget *, int is_on); int (*ioctl)(struct usb_gadget *, unsigned code, unsigned long param); - void (*get_config_params)(struct usb_dcd_config_params *); + void (*get_config_params)(struct usb_gadget *, + struct usb_dcd_config_params *); int (*udc_start)(struct usb_gadget *, struct usb_gadget_driver *); int (*udc_stop)(struct usb_gadget *); -- cgit v1.2.3-58-ga151 From 0966648dd5a5f4037d29d233866b7a4db39d07f7 Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Tue, 25 Jun 2019 14:38:46 +0900 Subject: usb: renesas_usbhs: remove notify_hotplug callback The notify_hotplug callback was supported in v3.10, but the last user (armadillo800eva) was removed by the commit 1fa59bda21c7 ("ARM: shmobile: Remove legacy board code for Armadillo-800 EVA"). So, this patch removes it. Signed-off-by: Yoshihiro Shimoda Signed-off-by: Greg Kroah-Hartman --- drivers/usb/renesas_usbhs/common.c | 16 ++++------------ drivers/usb/renesas_usbhs/common.h | 2 ++ drivers/usb/renesas_usbhs/mod.c | 3 ++- drivers/usb/renesas_usbhs/mod_gadget.c | 3 ++- include/linux/usb/renesas_usbhs.h | 26 +------------------------- 5 files changed, 11 insertions(+), 39 deletions(-) (limited to 'include/linux/usb') diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index ebbe322182bd..f6b136a4f91e 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -3,6 +3,7 @@ * Renesas USB driver * * Copyright (C) 2011 Renesas Solutions Corp. + * Copyright (C) 2019 Renesas Electronics Corporation * Kuninori Morimoto */ #include @@ -513,7 +514,7 @@ static void usbhsc_notify_hotplug(struct work_struct *work) usbhsc_hotplug(priv); } -static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev) +int usbhsc_schedule_notify_hotplug(struct platform_device *pdev) { struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); int delay = usbhs_get_dparam(priv, detection_delay); @@ -667,7 +668,6 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev) static int usbhs_probe(struct platform_device *pdev) { struct renesas_usbhs_platform_info *info = renesas_usbhs_get_info(pdev); - struct renesas_usbhs_driver_callback *dfunc; struct usbhs_priv *priv; struct resource *res, *irq_res; int ret; @@ -721,10 +721,6 @@ static int usbhs_probe(struct platform_device *pdev) } priv->pfunc = info->platform_callback; - /* set driver callback functions for platform */ - dfunc = &info->driver_callback; - dfunc->notify_hotplug = usbhsc_drvcllbck_notify_hotplug; - /* set default param if platform doesn't have */ if (!priv->dparam.pipe_configs) { priv->dparam.pipe_configs = usbhsc_default_pipe; @@ -818,7 +814,7 @@ static int usbhs_probe(struct platform_device *pdev) /* * manual call notify_hotplug for cold plug */ - usbhsc_drvcllbck_notify_hotplug(pdev); + usbhsc_schedule_notify_hotplug(pdev); dev_info(&pdev->dev, "probed\n"); @@ -843,13 +839,9 @@ probe_end_pipe_exit: static int usbhs_remove(struct platform_device *pdev) { struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); - struct renesas_usbhs_platform_info *info = renesas_usbhs_get_info(pdev); - struct renesas_usbhs_driver_callback *dfunc = &info->driver_callback; dev_dbg(&pdev->dev, "usb remove\n"); - dfunc->notify_hotplug = NULL; - /* power off */ if (!usbhs_get_dparam(priv, runtime_pwctrl)) usbhsc_power_ctrl(priv, 0); @@ -894,7 +886,7 @@ static __maybe_unused int usbhsc_resume(struct device *dev) usbhs_platform_call(priv, phy_reset, pdev); - usbhsc_drvcllbck_notify_hotplug(pdev); + usbhsc_schedule_notify_hotplug(pdev); return 0; } diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h index de74ebd1a347..b2b21fbb7ce2 100644 --- a/drivers/usb/renesas_usbhs/common.h +++ b/drivers/usb/renesas_usbhs/common.h @@ -3,6 +3,7 @@ * Renesas USB driver * * Copyright (C) 2011 Renesas Solutions Corp. + * Copyright (C) 2019 Renesas Electronics Corporation * Kuninori Morimoto */ #ifndef RENESAS_USB_DRIVER_H @@ -317,6 +318,7 @@ void usbhs_bus_send_sof_enable(struct usbhs_priv *priv); void usbhs_bus_send_reset(struct usbhs_priv *priv); int usbhs_bus_get_speed(struct usbhs_priv *priv); int usbhs_vbus_ctrl(struct usbhs_priv *priv, int enable); +int usbhsc_schedule_notify_hotplug(struct platform_device *pdev); /* * frame diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c index 7475c4f64724..540472abb23a 100644 --- a/drivers/usb/renesas_usbhs/mod.c +++ b/drivers/usb/renesas_usbhs/mod.c @@ -3,6 +3,7 @@ * Renesas USB driver * * Copyright (C) 2011 Renesas Solutions Corp. + * Copyright (C) 2019 Renesas Electronics Corporation * Kuninori Morimoto */ #include @@ -41,7 +42,7 @@ static int usbhsm_autonomy_irq_vbus(struct usbhs_priv *priv, { struct platform_device *pdev = usbhs_priv_to_pdev(priv); - renesas_usbhs_call_notify_hotplug(pdev); + usbhsc_schedule_notify_hotplug(pdev); return 0; } diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 59cac40aafcc..0c1e8fa528fc 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c @@ -3,6 +3,7 @@ * Renesas USB driver * * Copyright (C) 2011 Renesas Solutions Corp. + * Copyright (C) 2019 Renesas Electronics Corporation * Kuninori Morimoto */ #include @@ -1023,7 +1024,7 @@ static int usbhsg_vbus_session(struct usb_gadget *gadget, int is_active) gpriv->vbus_active = !!is_active; - renesas_usbhs_call_notify_hotplug(pdev); + usbhsc_schedule_notify_hotplug(pdev); return 0; } diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h index b2cba7c74444..ac601be95ec0 100644 --- a/include/linux/usb/renesas_usbhs.h +++ b/include/linux/usb/renesas_usbhs.h @@ -3,6 +3,7 @@ * Renesas USB * * Copyright (C) 2011 Renesas Solutions Corp. + * Copyright (C) 2019 Renesas Electronics Corporation * Kuninori Morimoto * * This program is distributed in the hope that it will be useful, @@ -32,17 +33,6 @@ enum { USBHS_MAX, }; -/* - * callback functions table for driver - * - * These functions are called from platform for driver. - * Callback function's pointer will be set before - * renesas_usbhs_platform_callback :: hardware_init was called - */ -struct renesas_usbhs_driver_callback { - int (*notify_hotplug)(struct platform_device *pdev); -}; - /* * callback functions for platform * @@ -213,12 +203,6 @@ struct renesas_usbhs_platform_info { */ struct renesas_usbhs_platform_callback platform_callback; - /* - * driver set these callback functions pointer. - * platform can use it on callback functions - */ - struct renesas_usbhs_driver_callback driver_callback; - /* * option: * @@ -232,12 +216,4 @@ struct renesas_usbhs_platform_info { */ #define renesas_usbhs_get_info(pdev)\ ((struct renesas_usbhs_platform_info *)(pdev)->dev.platform_data) - -#define renesas_usbhs_call_notify_hotplug(pdev) \ - ({ \ - struct renesas_usbhs_driver_callback *dc; \ - dc = &(renesas_usbhs_get_info(pdev)->driver_callback); \ - if (dc && dc->notify_hotplug) \ - dc->notify_hotplug(pdev); \ - }) #endif /* RENESAS_USB_H */ -- cgit v1.2.3-58-ga151 From df9f2c278b69fcd8b04c89612310f0036d21ec4c Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Tue, 25 Jun 2019 14:38:49 +0900 Subject: usb: renesas_usbhs: Use a specific flag instead of type for multi_clks To remove the type of renesas_usbhs_driver_param in the future, this patch uses a specific flag "multi_clks". Signed-off-by: Yoshihiro Shimoda Signed-off-by: Greg Kroah-Hartman --- drivers/usb/renesas_usbhs/common.c | 8 +++----- include/linux/usb/renesas_usbhs.h | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'include/linux/usb') diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index 739fe4b4c1d5..530e2eb7ab08 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -288,11 +288,7 @@ static void usbhsc_set_buswait(struct usbhs_priv *priv) static bool usbhsc_is_multi_clks(struct usbhs_priv *priv) { - if (priv->dparam.type == USBHS_TYPE_RCAR_GEN3 || - priv->dparam.type == USBHS_TYPE_RCAR_GEN3_WITH_PLL) - return true; - - return false; + return priv->dparam.multi_clks; } static int usbhsc_clk_get(struct device *dev, struct usbhs_priv *priv) @@ -544,6 +540,7 @@ static const struct usbhs_of_data rcar_gen3_data = { .param = { .type = USBHS_TYPE_RCAR_GEN3, .has_usb_dmac = 1, + .multi_clks = 1, .pipe_configs = usbhsc_new_pipe, .pipe_size = ARRAY_SIZE(usbhsc_new_pipe), } @@ -554,6 +551,7 @@ static const struct usbhs_of_data rcar_gen3_with_pll_data = { .param = { .type = USBHS_TYPE_RCAR_GEN3_WITH_PLL, .has_usb_dmac = 1, + .multi_clks = 1, .pipe_configs = usbhsc_new_pipe, .pipe_size = ARRAY_SIZE(usbhsc_new_pipe), } diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h index ac601be95ec0..e249c217cad1 100644 --- a/include/linux/usb/renesas_usbhs.h +++ b/include/linux/usb/renesas_usbhs.h @@ -181,6 +181,7 @@ struct renesas_usbhs_driver_param { u32 has_cnen:1; u32 cfifo_byte_addr:1; /* CFIFO is byte addressable */ #define USBHS_USB_DMAC_XFER_SIZE 32 /* hardcode the xfer size */ + u32 multi_clks:1; }; #define USBHS_TYPE_RCAR_GEN2 1 -- cgit v1.2.3-58-ga151 From a4027b409fa98dc47418dacd3dcb5c99c5a76e4d Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Tue, 25 Jun 2019 14:38:50 +0900 Subject: usb: renesas_usbhs: Remove type member from renesas_usbhs_driver_param Now no one uses the type member so that this patch removes it. Signed-off-by: Yoshihiro Shimoda Signed-off-by: Greg Kroah-Hartman --- drivers/usb/renesas_usbhs/common.c | 5 ----- include/linux/usb/renesas_usbhs.h | 7 ------- 2 files changed, 12 deletions(-) (limited to 'include/linux/usb') diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index 530e2eb7ab08..18727561fa65 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -528,7 +528,6 @@ int usbhsc_schedule_notify_hotplug(struct platform_device *pdev) static const struct usbhs_of_data rcar_gen2_data = { .platform_callback = &usbhs_rcar2_ops, .param = { - .type = USBHS_TYPE_RCAR_GEN2, .has_usb_dmac = 1, .pipe_configs = usbhsc_new_pipe, .pipe_size = ARRAY_SIZE(usbhsc_new_pipe), @@ -538,7 +537,6 @@ static const struct usbhs_of_data rcar_gen2_data = { static const struct usbhs_of_data rcar_gen3_data = { .platform_callback = &usbhs_rcar3_ops, .param = { - .type = USBHS_TYPE_RCAR_GEN3, .has_usb_dmac = 1, .multi_clks = 1, .pipe_configs = usbhsc_new_pipe, @@ -549,7 +547,6 @@ static const struct usbhs_of_data rcar_gen3_data = { static const struct usbhs_of_data rcar_gen3_with_pll_data = { .platform_callback = &usbhs_rcar3_with_pll_ops, .param = { - .type = USBHS_TYPE_RCAR_GEN3_WITH_PLL, .has_usb_dmac = 1, .multi_clks = 1, .pipe_configs = usbhsc_new_pipe, @@ -560,7 +557,6 @@ static const struct usbhs_of_data rcar_gen3_with_pll_data = { static const struct usbhs_of_data rza1_data = { .platform_callback = &usbhs_rza1_ops, .param = { - .type = USBHS_TYPE_RZA1, .pipe_configs = usbhsc_new_pipe, .pipe_size = ARRAY_SIZE(usbhsc_new_pipe), } @@ -569,7 +565,6 @@ static const struct usbhs_of_data rza1_data = { static const struct usbhs_of_data rza2_data = { .platform_callback = &usbhs_rza2_ops, .param = { - .type = USBHS_TYPE_RZA2, .has_cnen = 1, .cfifo_byte_addr = 1, .pipe_configs = usbhsc_new_pipe, diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h index e249c217cad1..fee84b7d4d2a 100644 --- a/include/linux/usb/renesas_usbhs.h +++ b/include/linux/usb/renesas_usbhs.h @@ -170,7 +170,6 @@ struct renesas_usbhs_driver_param { */ int pio_dma_border; /* default is 64byte */ - uintptr_t type; u32 enable_gpio; /* @@ -184,12 +183,6 @@ struct renesas_usbhs_driver_param { u32 multi_clks:1; }; -#define USBHS_TYPE_RCAR_GEN2 1 -#define USBHS_TYPE_RCAR_GEN3 2 -#define USBHS_TYPE_RCAR_GEN3_WITH_PLL 3 -#define USBHS_TYPE_RZA1 4 -#define USBHS_TYPE_RZA2 5 - /* * option: * -- cgit v1.2.3-58-ga151 From 98e86506c24932a30f50ffcfcbc98b04e3c9bc60 Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Tue, 25 Jun 2019 14:38:52 +0900 Subject: usb: renesas_usbhs: Add has_new_pipe_configs flag In the future, each struct renesas_usbhs_driver_param is stored on the each platform related source code (e.g. rcar3.c). So, to simplify the source code, this patch adds a new flag has_new_pipe_configs. Signed-off-by: Yoshihiro Shimoda Signed-off-by: Greg Kroah-Hartman --- drivers/usb/renesas_usbhs/common.c | 20 +++++++++----------- include/linux/usb/renesas_usbhs.h | 1 + 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'include/linux/usb') diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index 35b06e7d4eb4..f9476a07b0e9 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -529,8 +529,7 @@ static const struct usbhs_of_data rcar_gen2_data = { .platform_callback = &usbhs_rcar2_ops, .param = { .has_usb_dmac = 1, - .pipe_configs = usbhsc_new_pipe, - .pipe_size = ARRAY_SIZE(usbhsc_new_pipe), + .has_new_pipe_configs = 1, } }; @@ -539,8 +538,7 @@ static const struct usbhs_of_data rcar_gen3_data = { .param = { .has_usb_dmac = 1, .multi_clks = 1, - .pipe_configs = usbhsc_new_pipe, - .pipe_size = ARRAY_SIZE(usbhsc_new_pipe), + .has_new_pipe_configs = 1, } }; @@ -549,16 +547,14 @@ static const struct usbhs_of_data rcar_gen3_with_pll_data = { .param = { .has_usb_dmac = 1, .multi_clks = 1, - .pipe_configs = usbhsc_new_pipe, - .pipe_size = ARRAY_SIZE(usbhsc_new_pipe), + .has_new_pipe_configs = 1, } }; static const struct usbhs_of_data rza1_data = { .platform_callback = &usbhs_rza1_ops, .param = { - .pipe_configs = usbhsc_new_pipe, - .pipe_size = ARRAY_SIZE(usbhsc_new_pipe), + .has_new_pipe_configs = 1, } }; @@ -567,8 +563,7 @@ static const struct usbhs_of_data rza2_data = { .param = { .has_cnen = 1, .cfifo_byte_addr = 1, - .pipe_configs = usbhsc_new_pipe, - .pipe_size = ARRAY_SIZE(usbhsc_new_pipe), + .has_new_pipe_configs = 1, } }; @@ -715,7 +710,10 @@ static int usbhs_probe(struct platform_device *pdev) priv->pfunc = info->platform_callback; /* set default param if platform doesn't have */ - if (!priv->dparam.pipe_configs) { + if (usbhs_get_dparam(priv, has_new_pipe_configs)) { + priv->dparam.pipe_configs = usbhsc_new_pipe; + priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_new_pipe); + } else if (!priv->dparam.pipe_configs) { priv->dparam.pipe_configs = usbhsc_default_pipe; priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_default_pipe); } diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h index fee84b7d4d2a..6914475bbc86 100644 --- a/include/linux/usb/renesas_usbhs.h +++ b/include/linux/usb/renesas_usbhs.h @@ -181,6 +181,7 @@ struct renesas_usbhs_driver_param { u32 cfifo_byte_addr:1; /* CFIFO is byte addressable */ #define USBHS_USB_DMAC_XFER_SIZE 32 /* hardcode the xfer size */ u32 multi_clks:1; + u32 has_new_pipe_configs:1; }; /* -- cgit v1.2.3-58-ga151 From 3db1b636c07e15ff7410db782832dc2e7ffd2bce Mon Sep 17 00:00:00 2001 From: Pawel Laszczak Date: Tue, 2 Jul 2019 14:37:58 +0100 Subject: usb:gadget Separated decoding functions from dwc3 driver. Patch moves some decoding functions from driver/usb/dwc3/debug.h driver to driver/usb/gadget/debug.c file. These moved functions include: dwc3_decode_get_status dwc3_decode_set_clear_feature dwc3_decode_set_address dwc3_decode_get_set_descriptor dwc3_decode_get_configuration dwc3_decode_set_configuration dwc3_decode_get_intf dwc3_decode_set_intf dwc3_decode_synch_frame dwc3_decode_set_sel dwc3_decode_set_isoch_delay dwc3_decode_ctrl These functions are used also in inroduced cdns3 driver. All functions prefixes were changed from dwc3 to usb. Also, function's parameters has been extended according to the name of fields in standard SETUP packet. Additionally, patch adds usb_decode_ctrl function to include/linux/usb/gadget.h file. Signed-off-by: Pawel Laszczak Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/debug.h | 252 ----------------------------------------- drivers/usb/dwc3/trace.h | 2 +- drivers/usb/gadget/Makefile | 1 + drivers/usb/gadget/debug.c | 268 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/gadget.h | 26 +++++ 5 files changed, 296 insertions(+), 253 deletions(-) create mode 100644 drivers/usb/gadget/debug.c (limited to 'include/linux/usb') diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h index 068259fdfb0c..9baabed87d61 100644 --- a/drivers/usb/dwc3/debug.h +++ b/drivers/usb/dwc3/debug.h @@ -246,258 +246,6 @@ static inline const char *dwc3_gadget_event_string(char *str, size_t size, return str; } -static inline void dwc3_decode_get_status(__u8 t, __u16 i, __u16 l, char *str, - size_t size) -{ - switch (t & USB_RECIP_MASK) { - case USB_RECIP_DEVICE: - snprintf(str, size, "Get Device Status(Length = %d)", l); - break; - case USB_RECIP_INTERFACE: - snprintf(str, size, "Get Interface Status(Intf = %d, Length = %d)", - i, l); - break; - case USB_RECIP_ENDPOINT: - snprintf(str, size, "Get Endpoint Status(ep%d%s)", - i & ~USB_DIR_IN, - i & USB_DIR_IN ? "in" : "out"); - break; - } -} - -static inline void dwc3_decode_set_clear_feature(__u8 t, __u8 b, __u16 v, - __u16 i, char *str, size_t size) -{ - switch (t & USB_RECIP_MASK) { - case USB_RECIP_DEVICE: - snprintf(str, size, "%s Device Feature(%s%s)", - b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", - ({char *s; - switch (v) { - case USB_DEVICE_SELF_POWERED: - s = "Self Powered"; - break; - case USB_DEVICE_REMOTE_WAKEUP: - s = "Remote Wakeup"; - break; - case USB_DEVICE_TEST_MODE: - s = "Test Mode"; - break; - case USB_DEVICE_U1_ENABLE: - s = "U1 Enable"; - break; - case USB_DEVICE_U2_ENABLE: - s = "U2 Enable"; - break; - case USB_DEVICE_LTM_ENABLE: - s = "LTM Enable"; - break; - default: - s = "UNKNOWN"; - } s; }), - v == USB_DEVICE_TEST_MODE ? - ({ char *s; - switch (i) { - case TEST_J: - s = ": TEST_J"; - break; - case TEST_K: - s = ": TEST_K"; - break; - case TEST_SE0_NAK: - s = ": TEST_SE0_NAK"; - break; - case TEST_PACKET: - s = ": TEST_PACKET"; - break; - case TEST_FORCE_EN: - s = ": TEST_FORCE_EN"; - break; - default: - s = ": UNKNOWN"; - } s; }) : ""); - break; - case USB_RECIP_INTERFACE: - snprintf(str, size, "%s Interface Feature(%s)", - b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", - v == USB_INTRF_FUNC_SUSPEND ? - "Function Suspend" : "UNKNOWN"); - break; - case USB_RECIP_ENDPOINT: - snprintf(str, size, "%s Endpoint Feature(%s ep%d%s)", - b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", - v == USB_ENDPOINT_HALT ? "Halt" : "UNKNOWN", - i & ~USB_DIR_IN, - i & USB_DIR_IN ? "in" : "out"); - break; - } -} - -static inline void dwc3_decode_set_address(__u16 v, char *str, size_t size) -{ - snprintf(str, size, "Set Address(Addr = %02x)", v); -} - -static inline void dwc3_decode_get_set_descriptor(__u8 t, __u8 b, __u16 v, - __u16 i, __u16 l, char *str, size_t size) -{ - snprintf(str, size, "%s %s Descriptor(Index = %d, Length = %d)", - b == USB_REQ_GET_DESCRIPTOR ? "Get" : "Set", - ({ char *s; - switch (v >> 8) { - case USB_DT_DEVICE: - s = "Device"; - break; - case USB_DT_CONFIG: - s = "Configuration"; - break; - case USB_DT_STRING: - s = "String"; - break; - case USB_DT_INTERFACE: - s = "Interface"; - break; - case USB_DT_ENDPOINT: - s = "Endpoint"; - break; - case USB_DT_DEVICE_QUALIFIER: - s = "Device Qualifier"; - break; - case USB_DT_OTHER_SPEED_CONFIG: - s = "Other Speed Config"; - break; - case USB_DT_INTERFACE_POWER: - s = "Interface Power"; - break; - case USB_DT_OTG: - s = "OTG"; - break; - case USB_DT_DEBUG: - s = "Debug"; - break; - case USB_DT_INTERFACE_ASSOCIATION: - s = "Interface Association"; - break; - case USB_DT_BOS: - s = "BOS"; - break; - case USB_DT_DEVICE_CAPABILITY: - s = "Device Capability"; - break; - case USB_DT_PIPE_USAGE: - s = "Pipe Usage"; - break; - case USB_DT_SS_ENDPOINT_COMP: - s = "SS Endpoint Companion"; - break; - case USB_DT_SSP_ISOC_ENDPOINT_COMP: - s = "SSP Isochronous Endpoint Companion"; - break; - default: - s = "UNKNOWN"; - break; - } s; }), v & 0xff, l); -} - - -static inline void dwc3_decode_get_configuration(__u16 l, char *str, - size_t size) -{ - snprintf(str, size, "Get Configuration(Length = %d)", l); -} - -static inline void dwc3_decode_set_configuration(__u8 v, char *str, size_t size) -{ - snprintf(str, size, "Set Configuration(Config = %d)", v); -} - -static inline void dwc3_decode_get_intf(__u16 i, __u16 l, char *str, - size_t size) -{ - snprintf(str, size, "Get Interface(Intf = %d, Length = %d)", i, l); -} - -static inline void dwc3_decode_set_intf(__u8 v, __u16 i, char *str, size_t size) -{ - snprintf(str, size, "Set Interface(Intf = %d, Alt.Setting = %d)", i, v); -} - -static inline void dwc3_decode_synch_frame(__u16 i, __u16 l, char *str, - size_t size) -{ - snprintf(str, size, "Synch Frame(Endpoint = %d, Length = %d)", i, l); -} - -static inline void dwc3_decode_set_sel(__u16 l, char *str, size_t size) -{ - snprintf(str, size, "Set SEL(Length = %d)", l); -} - -static inline void dwc3_decode_set_isoch_delay(__u8 v, char *str, size_t size) -{ - snprintf(str, size, "Set Isochronous Delay(Delay = %d ns)", v); -} - -/** - * dwc3_decode_ctrl - returns a string represetion of ctrl request - */ -static inline const char *dwc3_decode_ctrl(char *str, size_t size, - __u8 bRequestType, __u8 bRequest, __u16 wValue, __u16 wIndex, - __u16 wLength) -{ - switch (bRequest) { - case USB_REQ_GET_STATUS: - dwc3_decode_get_status(bRequestType, wIndex, wLength, str, - size); - break; - case USB_REQ_CLEAR_FEATURE: - case USB_REQ_SET_FEATURE: - dwc3_decode_set_clear_feature(bRequestType, bRequest, wValue, - wIndex, str, size); - break; - case USB_REQ_SET_ADDRESS: - dwc3_decode_set_address(wValue, str, size); - break; - case USB_REQ_GET_DESCRIPTOR: - case USB_REQ_SET_DESCRIPTOR: - dwc3_decode_get_set_descriptor(bRequestType, bRequest, wValue, - wIndex, wLength, str, size); - break; - case USB_REQ_GET_CONFIGURATION: - dwc3_decode_get_configuration(wLength, str, size); - break; - case USB_REQ_SET_CONFIGURATION: - dwc3_decode_set_configuration(wValue, str, size); - break; - case USB_REQ_GET_INTERFACE: - dwc3_decode_get_intf(wIndex, wLength, str, size); - break; - case USB_REQ_SET_INTERFACE: - dwc3_decode_set_intf(wValue, wIndex, str, size); - break; - case USB_REQ_SYNCH_FRAME: - dwc3_decode_synch_frame(wIndex, wLength, str, size); - break; - case USB_REQ_SET_SEL: - dwc3_decode_set_sel(wLength, str, size); - break; - case USB_REQ_SET_ISOCH_DELAY: - dwc3_decode_set_isoch_delay(wValue, str, size); - break; - default: - snprintf(str, size, "%02x %02x %02x %02x %02x %02x %02x %02x", - bRequestType, bRequest, - cpu_to_le16(wValue) & 0xff, - cpu_to_le16(wValue) >> 8, - cpu_to_le16(wIndex) & 0xff, - cpu_to_le16(wIndex) >> 8, - cpu_to_le16(wLength) & 0xff, - cpu_to_le16(wLength) >> 8); - } - - return str; -} - /** * dwc3_ep_event_string - returns event name * @event: then event code diff --git a/drivers/usb/dwc3/trace.h b/drivers/usb/dwc3/trace.h index 818a63da1a44..9edff17111f7 100644 --- a/drivers/usb/dwc3/trace.h +++ b/drivers/usb/dwc3/trace.h @@ -86,7 +86,7 @@ DECLARE_EVENT_CLASS(dwc3_log_ctrl, __entry->wIndex = le16_to_cpu(ctrl->wIndex); __entry->wLength = le16_to_cpu(ctrl->wLength); ), - TP_printk("%s", dwc3_decode_ctrl(__get_str(str), DWC3_MSG_MAX, + TP_printk("%s", usb_decode_ctrl(__get_str(str), DWC3_MSG_MAX, __entry->bRequestType, __entry->bRequest, __entry->wValue, __entry->wIndex, __entry->wLength) diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 130dad7130b6..500a5a592abe 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -9,5 +9,6 @@ ccflags-y += -I$(srctree)/drivers/usb/gadget/udc obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o libcomposite-y := usbstring.o config.o epautoconf.o libcomposite-y += composite.o functions.o configfs.o u_f.o +libcomposite-y += debug.o obj-$(CONFIG_USB_GADGET) += udc/ function/ legacy/ diff --git a/drivers/usb/gadget/debug.c b/drivers/usb/gadget/debug.c new file mode 100644 index 000000000000..d5a469bc67a3 --- /dev/null +++ b/drivers/usb/gadget/debug.c @@ -0,0 +1,268 @@ +// SPDX-License-Identifier: GPL-2.0 +/** + * Common USB debugging functions + * + * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com + * + * Authors: Felipe Balbi , + * Sebastian Andrzej Siewior + */ + +#include + +static void usb_decode_get_status(__u8 bRequestType, __u16 wIndex, + __u16 wLength, char *str, size_t size) +{ + switch (bRequestType & USB_RECIP_MASK) { + case USB_RECIP_DEVICE: + snprintf(str, size, "Get Device Status(Length = %d)", wLength); + break; + case USB_RECIP_INTERFACE: + snprintf(str, size, + "Get Interface Status(Intf = %d, Length = %d)", + wIndex, wLength); + break; + case USB_RECIP_ENDPOINT: + snprintf(str, size, "Get Endpoint Status(ep%d%s)", + wIndex & ~USB_DIR_IN, + wIndex & USB_DIR_IN ? "in" : "out"); + break; + } +} + +static void usb_decode_set_clear_feature(__u8 bRequestType, __u8 bRequest, + __u16 wValue, __u16 wIndex, + char *str, size_t size) +{ + switch (bRequestType & USB_RECIP_MASK) { + case USB_RECIP_DEVICE: + snprintf(str, size, "%s Device Feature(%s%s)", + bRequest == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", + ({char *s; + switch (wValue) { + case USB_DEVICE_SELF_POWERED: + s = "Self Powered"; + break; + case USB_DEVICE_REMOTE_WAKEUP: + s = "Remote Wakeup"; + break; + case USB_DEVICE_TEST_MODE: + s = "Test Mode"; + break; + case USB_DEVICE_U1_ENABLE: + s = "U1 Enable"; + break; + case USB_DEVICE_U2_ENABLE: + s = "U2 Enable"; + break; + case USB_DEVICE_LTM_ENABLE: + s = "LTM Enable"; + break; + default: + s = "UNKNOWN"; + } s; }), + wValue == USB_DEVICE_TEST_MODE ? + ({ char *s; + switch (wIndex) { + case TEST_J: + s = ": TEST_J"; + break; + case TEST_K: + s = ": TEST_K"; + break; + case TEST_SE0_NAK: + s = ": TEST_SE0_NAK"; + break; + case TEST_PACKET: + s = ": TEST_PACKET"; + break; + case TEST_FORCE_EN: + s = ": TEST_FORCE_EN"; + break; + default: + s = ": UNKNOWN"; + } s; }) : ""); + break; + case USB_RECIP_INTERFACE: + snprintf(str, size, "%s Interface Feature(%s)", + bRequest == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", + wValue == USB_INTRF_FUNC_SUSPEND ? + "Function Suspend" : "UNKNOWN"); + break; + case USB_RECIP_ENDPOINT: + snprintf(str, size, "%s Endpoint Feature(%s ep%d%s)", + bRequest == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", + wValue == USB_ENDPOINT_HALT ? "Halt" : "UNKNOWN", + wIndex & ~USB_DIR_IN, + wIndex & USB_DIR_IN ? "in" : "out"); + break; + } +} + +static void usb_decode_set_address(__u16 wValue, char *str, size_t size) +{ + snprintf(str, size, "Set Address(Addr = %02x)", wValue); +} + +static void usb_decode_get_set_descriptor(__u8 bRequestType, __u8 bRequest, + __u16 wValue, __u16 wIndex, + __u16 wLength, char *str, size_t size) +{ + snprintf(str, size, "%s %s Descriptor(Index = %d, Length = %d)", + bRequest == USB_REQ_GET_DESCRIPTOR ? "Get" : "Set", + ({ char *s; + switch (wValue >> 8) { + case USB_DT_DEVICE: + s = "Device"; + break; + case USB_DT_CONFIG: + s = "Configuration"; + break; + case USB_DT_STRING: + s = "String"; + break; + case USB_DT_INTERFACE: + s = "Interface"; + break; + case USB_DT_ENDPOINT: + s = "Endpoint"; + break; + case USB_DT_DEVICE_QUALIFIER: + s = "Device Qualifier"; + break; + case USB_DT_OTHER_SPEED_CONFIG: + s = "Other Speed Config"; + break; + case USB_DT_INTERFACE_POWER: + s = "Interface Power"; + break; + case USB_DT_OTG: + s = "OTG"; + break; + case USB_DT_DEBUG: + s = "Debug"; + break; + case USB_DT_INTERFACE_ASSOCIATION: + s = "Interface Association"; + break; + case USB_DT_BOS: + s = "BOS"; + break; + case USB_DT_DEVICE_CAPABILITY: + s = "Device Capability"; + break; + case USB_DT_PIPE_USAGE: + s = "Pipe Usage"; + break; + case USB_DT_SS_ENDPOINT_COMP: + s = "SS Endpoint Companion"; + break; + case USB_DT_SSP_ISOC_ENDPOINT_COMP: + s = "SSP Isochronous Endpoint Companion"; + break; + default: + s = "UNKNOWN"; + break; + } s; }), wValue & 0xff, wLength); +} + +static void usb_decode_get_configuration(__u16 wLength, char *str, size_t size) +{ + snprintf(str, size, "Get Configuration(Length = %d)", wLength); +} + +static void usb_decode_set_configuration(__u8 wValue, char *str, size_t size) +{ + snprintf(str, size, "Set Configuration(Config = %d)", wValue); +} + +static void usb_decode_get_intf(__u16 wIndex, __u16 wLength, char *str, + size_t size) +{ + snprintf(str, size, "Get Interface(Intf = %d, Length = %d)", + wIndex, wLength); +} + +static void usb_decode_set_intf(__u8 wValue, __u16 wIndex, char *str, + size_t size) +{ + snprintf(str, size, "Set Interface(Intf = %d, Alt.Setting = %d)", + wIndex, wValue); +} + +static void usb_decode_synch_frame(__u16 wIndex, __u16 wLength, + char *str, size_t size) +{ + snprintf(str, size, "Synch Frame(Endpoint = %d, Length = %d)", + wIndex, wLength); +} + +static void usb_decode_set_sel(__u16 wLength, char *str, size_t size) +{ + snprintf(str, size, "Set SEL(Length = %d)", wLength); +} + +static void usb_decode_set_isoch_delay(__u8 wValue, char *str, size_t size) +{ + snprintf(str, size, "Set Isochronous Delay(Delay = %d ns)", wValue); +} + +/** + * usb_decode_ctrl - returns a string representation of ctrl request + */ +const char *usb_decode_ctrl(char *str, size_t size, __u8 bRequestType, + __u8 bRequest, __u16 wValue, __u16 wIndex, + __u16 wLength) +{ + switch (bRequest) { + case USB_REQ_GET_STATUS: + usb_decode_get_status(bRequestType, wIndex, wLength, str, size); + break; + case USB_REQ_CLEAR_FEATURE: + case USB_REQ_SET_FEATURE: + usb_decode_set_clear_feature(bRequestType, bRequest, wValue, + wIndex, str, size); + break; + case USB_REQ_SET_ADDRESS: + usb_decode_set_address(wValue, str, size); + break; + case USB_REQ_GET_DESCRIPTOR: + case USB_REQ_SET_DESCRIPTOR: + usb_decode_get_set_descriptor(bRequestType, bRequest, wValue, + wIndex, wLength, str, size); + break; + case USB_REQ_GET_CONFIGURATION: + usb_decode_get_configuration(wLength, str, size); + break; + case USB_REQ_SET_CONFIGURATION: + usb_decode_set_configuration(wValue, str, size); + break; + case USB_REQ_GET_INTERFACE: + usb_decode_get_intf(wIndex, wLength, str, size); + break; + case USB_REQ_SET_INTERFACE: + usb_decode_set_intf(wValue, wIndex, str, size); + break; + case USB_REQ_SYNCH_FRAME: + usb_decode_synch_frame(wIndex, wLength, str, size); + break; + case USB_REQ_SET_SEL: + usb_decode_set_sel(wLength, str, size); + break; + case USB_REQ_SET_ISOCH_DELAY: + usb_decode_set_isoch_delay(wValue, str, size); + break; + default: + snprintf(str, size, "%02x %02x %02x %02x %02x %02x %02x %02x", + bRequestType, bRequest, + (u8)(cpu_to_le16(wValue) & 0xff), + (u8)(cpu_to_le16(wValue) >> 8), + (u8)(cpu_to_le16(wIndex) & 0xff), + (u8)(cpu_to_le16(wIndex) >> 8), + (u8)(cpu_to_le16(wLength) & 0xff), + (u8)(cpu_to_le16(wLength) >> 8)); + } + + return str; +} +EXPORT_SYMBOL_GPL(usb_decode_ctrl); diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index fb19141151d8..42902fcc8696 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -889,4 +889,30 @@ extern void usb_ep_autoconfig_release(struct usb_ep *); extern void usb_ep_autoconfig_reset(struct usb_gadget *); +/*-------------------------------------------------------------------------*/ +/** + * usb_decode_ctrl - Returns human readable representation of control request. + * @str: buffer to return a human-readable representation of control request. + * This buffer should have about 200 bytes. + * @size: size of str buffer. + * @bRequestType: matches the USB bmRequestType field + * @bRequest: matches the USB bRequest field + * @wValue: matches the USB wValue field (CPU byte order) + * @wIndex: matches the USB wIndex field (CPU byte order) + * @wLength: matches the USB wLength field (CPU byte order) + * + * Function returns decoded, formatted and human-readable description of + * control request packet. + * + * The usage scenario for this is for tracepoints, so function as a return + * use the same value as in parameters. This approach allows to use this + * function in TP_printk + * + * Important: wValue, wIndex, wLength parameters before invoking this function + * should be processed by le16_to_cpu macro. + */ +extern const char *usb_decode_ctrl(char *str, size_t size, __u8 bRequestType, + __u8 bRequest, __u16 wValue, __u16 wIndex, + __u16 wLength); + #endif /* __LINUX_USB_GADGET_H */ -- cgit v1.2.3-58-ga151 From 332694f8a4f7e49b8b7278734d0ce331f954b20e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 4 Jul 2019 13:02:09 +0200 Subject: Revert "usb:gadget Separated decoding functions from dwc3 driver." This reverts commit 3db1b636c07e15ff7410db782832dc2e7ffd2bce. It's broken. Reported-by: Stephen Rothwell Cc: Felipe Balbi Cc: Pawel Laszczak Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/debug.h | 252 +++++++++++++++++++++++++++++++++++++++++ drivers/usb/dwc3/trace.h | 2 +- drivers/usb/gadget/Makefile | 1 - drivers/usb/gadget/debug.c | 268 -------------------------------------------- include/linux/usb/gadget.h | 26 ----- 5 files changed, 253 insertions(+), 296 deletions(-) delete mode 100644 drivers/usb/gadget/debug.c (limited to 'include/linux/usb') diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h index 9baabed87d61..068259fdfb0c 100644 --- a/drivers/usb/dwc3/debug.h +++ b/drivers/usb/dwc3/debug.h @@ -246,6 +246,258 @@ static inline const char *dwc3_gadget_event_string(char *str, size_t size, return str; } +static inline void dwc3_decode_get_status(__u8 t, __u16 i, __u16 l, char *str, + size_t size) +{ + switch (t & USB_RECIP_MASK) { + case USB_RECIP_DEVICE: + snprintf(str, size, "Get Device Status(Length = %d)", l); + break; + case USB_RECIP_INTERFACE: + snprintf(str, size, "Get Interface Status(Intf = %d, Length = %d)", + i, l); + break; + case USB_RECIP_ENDPOINT: + snprintf(str, size, "Get Endpoint Status(ep%d%s)", + i & ~USB_DIR_IN, + i & USB_DIR_IN ? "in" : "out"); + break; + } +} + +static inline void dwc3_decode_set_clear_feature(__u8 t, __u8 b, __u16 v, + __u16 i, char *str, size_t size) +{ + switch (t & USB_RECIP_MASK) { + case USB_RECIP_DEVICE: + snprintf(str, size, "%s Device Feature(%s%s)", + b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", + ({char *s; + switch (v) { + case USB_DEVICE_SELF_POWERED: + s = "Self Powered"; + break; + case USB_DEVICE_REMOTE_WAKEUP: + s = "Remote Wakeup"; + break; + case USB_DEVICE_TEST_MODE: + s = "Test Mode"; + break; + case USB_DEVICE_U1_ENABLE: + s = "U1 Enable"; + break; + case USB_DEVICE_U2_ENABLE: + s = "U2 Enable"; + break; + case USB_DEVICE_LTM_ENABLE: + s = "LTM Enable"; + break; + default: + s = "UNKNOWN"; + } s; }), + v == USB_DEVICE_TEST_MODE ? + ({ char *s; + switch (i) { + case TEST_J: + s = ": TEST_J"; + break; + case TEST_K: + s = ": TEST_K"; + break; + case TEST_SE0_NAK: + s = ": TEST_SE0_NAK"; + break; + case TEST_PACKET: + s = ": TEST_PACKET"; + break; + case TEST_FORCE_EN: + s = ": TEST_FORCE_EN"; + break; + default: + s = ": UNKNOWN"; + } s; }) : ""); + break; + case USB_RECIP_INTERFACE: + snprintf(str, size, "%s Interface Feature(%s)", + b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", + v == USB_INTRF_FUNC_SUSPEND ? + "Function Suspend" : "UNKNOWN"); + break; + case USB_RECIP_ENDPOINT: + snprintf(str, size, "%s Endpoint Feature(%s ep%d%s)", + b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", + v == USB_ENDPOINT_HALT ? "Halt" : "UNKNOWN", + i & ~USB_DIR_IN, + i & USB_DIR_IN ? "in" : "out"); + break; + } +} + +static inline void dwc3_decode_set_address(__u16 v, char *str, size_t size) +{ + snprintf(str, size, "Set Address(Addr = %02x)", v); +} + +static inline void dwc3_decode_get_set_descriptor(__u8 t, __u8 b, __u16 v, + __u16 i, __u16 l, char *str, size_t size) +{ + snprintf(str, size, "%s %s Descriptor(Index = %d, Length = %d)", + b == USB_REQ_GET_DESCRIPTOR ? "Get" : "Set", + ({ char *s; + switch (v >> 8) { + case USB_DT_DEVICE: + s = "Device"; + break; + case USB_DT_CONFIG: + s = "Configuration"; + break; + case USB_DT_STRING: + s = "String"; + break; + case USB_DT_INTERFACE: + s = "Interface"; + break; + case USB_DT_ENDPOINT: + s = "Endpoint"; + break; + case USB_DT_DEVICE_QUALIFIER: + s = "Device Qualifier"; + break; + case USB_DT_OTHER_SPEED_CONFIG: + s = "Other Speed Config"; + break; + case USB_DT_INTERFACE_POWER: + s = "Interface Power"; + break; + case USB_DT_OTG: + s = "OTG"; + break; + case USB_DT_DEBUG: + s = "Debug"; + break; + case USB_DT_INTERFACE_ASSOCIATION: + s = "Interface Association"; + break; + case USB_DT_BOS: + s = "BOS"; + break; + case USB_DT_DEVICE_CAPABILITY: + s = "Device Capability"; + break; + case USB_DT_PIPE_USAGE: + s = "Pipe Usage"; + break; + case USB_DT_SS_ENDPOINT_COMP: + s = "SS Endpoint Companion"; + break; + case USB_DT_SSP_ISOC_ENDPOINT_COMP: + s = "SSP Isochronous Endpoint Companion"; + break; + default: + s = "UNKNOWN"; + break; + } s; }), v & 0xff, l); +} + + +static inline void dwc3_decode_get_configuration(__u16 l, char *str, + size_t size) +{ + snprintf(str, size, "Get Configuration(Length = %d)", l); +} + +static inline void dwc3_decode_set_configuration(__u8 v, char *str, size_t size) +{ + snprintf(str, size, "Set Configuration(Config = %d)", v); +} + +static inline void dwc3_decode_get_intf(__u16 i, __u16 l, char *str, + size_t size) +{ + snprintf(str, size, "Get Interface(Intf = %d, Length = %d)", i, l); +} + +static inline void dwc3_decode_set_intf(__u8 v, __u16 i, char *str, size_t size) +{ + snprintf(str, size, "Set Interface(Intf = %d, Alt.Setting = %d)", i, v); +} + +static inline void dwc3_decode_synch_frame(__u16 i, __u16 l, char *str, + size_t size) +{ + snprintf(str, size, "Synch Frame(Endpoint = %d, Length = %d)", i, l); +} + +static inline void dwc3_decode_set_sel(__u16 l, char *str, size_t size) +{ + snprintf(str, size, "Set SEL(Length = %d)", l); +} + +static inline void dwc3_decode_set_isoch_delay(__u8 v, char *str, size_t size) +{ + snprintf(str, size, "Set Isochronous Delay(Delay = %d ns)", v); +} + +/** + * dwc3_decode_ctrl - returns a string represetion of ctrl request + */ +static inline const char *dwc3_decode_ctrl(char *str, size_t size, + __u8 bRequestType, __u8 bRequest, __u16 wValue, __u16 wIndex, + __u16 wLength) +{ + switch (bRequest) { + case USB_REQ_GET_STATUS: + dwc3_decode_get_status(bRequestType, wIndex, wLength, str, + size); + break; + case USB_REQ_CLEAR_FEATURE: + case USB_REQ_SET_FEATURE: + dwc3_decode_set_clear_feature(bRequestType, bRequest, wValue, + wIndex, str, size); + break; + case USB_REQ_SET_ADDRESS: + dwc3_decode_set_address(wValue, str, size); + break; + case USB_REQ_GET_DESCRIPTOR: + case USB_REQ_SET_DESCRIPTOR: + dwc3_decode_get_set_descriptor(bRequestType, bRequest, wValue, + wIndex, wLength, str, size); + break; + case USB_REQ_GET_CONFIGURATION: + dwc3_decode_get_configuration(wLength, str, size); + break; + case USB_REQ_SET_CONFIGURATION: + dwc3_decode_set_configuration(wValue, str, size); + break; + case USB_REQ_GET_INTERFACE: + dwc3_decode_get_intf(wIndex, wLength, str, size); + break; + case USB_REQ_SET_INTERFACE: + dwc3_decode_set_intf(wValue, wIndex, str, size); + break; + case USB_REQ_SYNCH_FRAME: + dwc3_decode_synch_frame(wIndex, wLength, str, size); + break; + case USB_REQ_SET_SEL: + dwc3_decode_set_sel(wLength, str, size); + break; + case USB_REQ_SET_ISOCH_DELAY: + dwc3_decode_set_isoch_delay(wValue, str, size); + break; + default: + snprintf(str, size, "%02x %02x %02x %02x %02x %02x %02x %02x", + bRequestType, bRequest, + cpu_to_le16(wValue) & 0xff, + cpu_to_le16(wValue) >> 8, + cpu_to_le16(wIndex) & 0xff, + cpu_to_le16(wIndex) >> 8, + cpu_to_le16(wLength) & 0xff, + cpu_to_le16(wLength) >> 8); + } + + return str; +} + /** * dwc3_ep_event_string - returns event name * @event: then event code diff --git a/drivers/usb/dwc3/trace.h b/drivers/usb/dwc3/trace.h index 9edff17111f7..818a63da1a44 100644 --- a/drivers/usb/dwc3/trace.h +++ b/drivers/usb/dwc3/trace.h @@ -86,7 +86,7 @@ DECLARE_EVENT_CLASS(dwc3_log_ctrl, __entry->wIndex = le16_to_cpu(ctrl->wIndex); __entry->wLength = le16_to_cpu(ctrl->wLength); ), - TP_printk("%s", usb_decode_ctrl(__get_str(str), DWC3_MSG_MAX, + TP_printk("%s", dwc3_decode_ctrl(__get_str(str), DWC3_MSG_MAX, __entry->bRequestType, __entry->bRequest, __entry->wValue, __entry->wIndex, __entry->wLength) diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 500a5a592abe..130dad7130b6 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -9,6 +9,5 @@ ccflags-y += -I$(srctree)/drivers/usb/gadget/udc obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o libcomposite-y := usbstring.o config.o epautoconf.o libcomposite-y += composite.o functions.o configfs.o u_f.o -libcomposite-y += debug.o obj-$(CONFIG_USB_GADGET) += udc/ function/ legacy/ diff --git a/drivers/usb/gadget/debug.c b/drivers/usb/gadget/debug.c deleted file mode 100644 index d5a469bc67a3..000000000000 --- a/drivers/usb/gadget/debug.c +++ /dev/null @@ -1,268 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/** - * Common USB debugging functions - * - * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com - * - * Authors: Felipe Balbi , - * Sebastian Andrzej Siewior - */ - -#include - -static void usb_decode_get_status(__u8 bRequestType, __u16 wIndex, - __u16 wLength, char *str, size_t size) -{ - switch (bRequestType & USB_RECIP_MASK) { - case USB_RECIP_DEVICE: - snprintf(str, size, "Get Device Status(Length = %d)", wLength); - break; - case USB_RECIP_INTERFACE: - snprintf(str, size, - "Get Interface Status(Intf = %d, Length = %d)", - wIndex, wLength); - break; - case USB_RECIP_ENDPOINT: - snprintf(str, size, "Get Endpoint Status(ep%d%s)", - wIndex & ~USB_DIR_IN, - wIndex & USB_DIR_IN ? "in" : "out"); - break; - } -} - -static void usb_decode_set_clear_feature(__u8 bRequestType, __u8 bRequest, - __u16 wValue, __u16 wIndex, - char *str, size_t size) -{ - switch (bRequestType & USB_RECIP_MASK) { - case USB_RECIP_DEVICE: - snprintf(str, size, "%s Device Feature(%s%s)", - bRequest == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", - ({char *s; - switch (wValue) { - case USB_DEVICE_SELF_POWERED: - s = "Self Powered"; - break; - case USB_DEVICE_REMOTE_WAKEUP: - s = "Remote Wakeup"; - break; - case USB_DEVICE_TEST_MODE: - s = "Test Mode"; - break; - case USB_DEVICE_U1_ENABLE: - s = "U1 Enable"; - break; - case USB_DEVICE_U2_ENABLE: - s = "U2 Enable"; - break; - case USB_DEVICE_LTM_ENABLE: - s = "LTM Enable"; - break; - default: - s = "UNKNOWN"; - } s; }), - wValue == USB_DEVICE_TEST_MODE ? - ({ char *s; - switch (wIndex) { - case TEST_J: - s = ": TEST_J"; - break; - case TEST_K: - s = ": TEST_K"; - break; - case TEST_SE0_NAK: - s = ": TEST_SE0_NAK"; - break; - case TEST_PACKET: - s = ": TEST_PACKET"; - break; - case TEST_FORCE_EN: - s = ": TEST_FORCE_EN"; - break; - default: - s = ": UNKNOWN"; - } s; }) : ""); - break; - case USB_RECIP_INTERFACE: - snprintf(str, size, "%s Interface Feature(%s)", - bRequest == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", - wValue == USB_INTRF_FUNC_SUSPEND ? - "Function Suspend" : "UNKNOWN"); - break; - case USB_RECIP_ENDPOINT: - snprintf(str, size, "%s Endpoint Feature(%s ep%d%s)", - bRequest == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", - wValue == USB_ENDPOINT_HALT ? "Halt" : "UNKNOWN", - wIndex & ~USB_DIR_IN, - wIndex & USB_DIR_IN ? "in" : "out"); - break; - } -} - -static void usb_decode_set_address(__u16 wValue, char *str, size_t size) -{ - snprintf(str, size, "Set Address(Addr = %02x)", wValue); -} - -static void usb_decode_get_set_descriptor(__u8 bRequestType, __u8 bRequest, - __u16 wValue, __u16 wIndex, - __u16 wLength, char *str, size_t size) -{ - snprintf(str, size, "%s %s Descriptor(Index = %d, Length = %d)", - bRequest == USB_REQ_GET_DESCRIPTOR ? "Get" : "Set", - ({ char *s; - switch (wValue >> 8) { - case USB_DT_DEVICE: - s = "Device"; - break; - case USB_DT_CONFIG: - s = "Configuration"; - break; - case USB_DT_STRING: - s = "String"; - break; - case USB_DT_INTERFACE: - s = "Interface"; - break; - case USB_DT_ENDPOINT: - s = "Endpoint"; - break; - case USB_DT_DEVICE_QUALIFIER: - s = "Device Qualifier"; - break; - case USB_DT_OTHER_SPEED_CONFIG: - s = "Other Speed Config"; - break; - case USB_DT_INTERFACE_POWER: - s = "Interface Power"; - break; - case USB_DT_OTG: - s = "OTG"; - break; - case USB_DT_DEBUG: - s = "Debug"; - break; - case USB_DT_INTERFACE_ASSOCIATION: - s = "Interface Association"; - break; - case USB_DT_BOS: - s = "BOS"; - break; - case USB_DT_DEVICE_CAPABILITY: - s = "Device Capability"; - break; - case USB_DT_PIPE_USAGE: - s = "Pipe Usage"; - break; - case USB_DT_SS_ENDPOINT_COMP: - s = "SS Endpoint Companion"; - break; - case USB_DT_SSP_ISOC_ENDPOINT_COMP: - s = "SSP Isochronous Endpoint Companion"; - break; - default: - s = "UNKNOWN"; - break; - } s; }), wValue & 0xff, wLength); -} - -static void usb_decode_get_configuration(__u16 wLength, char *str, size_t size) -{ - snprintf(str, size, "Get Configuration(Length = %d)", wLength); -} - -static void usb_decode_set_configuration(__u8 wValue, char *str, size_t size) -{ - snprintf(str, size, "Set Configuration(Config = %d)", wValue); -} - -static void usb_decode_get_intf(__u16 wIndex, __u16 wLength, char *str, - size_t size) -{ - snprintf(str, size, "Get Interface(Intf = %d, Length = %d)", - wIndex, wLength); -} - -static void usb_decode_set_intf(__u8 wValue, __u16 wIndex, char *str, - size_t size) -{ - snprintf(str, size, "Set Interface(Intf = %d, Alt.Setting = %d)", - wIndex, wValue); -} - -static void usb_decode_synch_frame(__u16 wIndex, __u16 wLength, - char *str, size_t size) -{ - snprintf(str, size, "Synch Frame(Endpoint = %d, Length = %d)", - wIndex, wLength); -} - -static void usb_decode_set_sel(__u16 wLength, char *str, size_t size) -{ - snprintf(str, size, "Set SEL(Length = %d)", wLength); -} - -static void usb_decode_set_isoch_delay(__u8 wValue, char *str, size_t size) -{ - snprintf(str, size, "Set Isochronous Delay(Delay = %d ns)", wValue); -} - -/** - * usb_decode_ctrl - returns a string representation of ctrl request - */ -const char *usb_decode_ctrl(char *str, size_t size, __u8 bRequestType, - __u8 bRequest, __u16 wValue, __u16 wIndex, - __u16 wLength) -{ - switch (bRequest) { - case USB_REQ_GET_STATUS: - usb_decode_get_status(bRequestType, wIndex, wLength, str, size); - break; - case USB_REQ_CLEAR_FEATURE: - case USB_REQ_SET_FEATURE: - usb_decode_set_clear_feature(bRequestType, bRequest, wValue, - wIndex, str, size); - break; - case USB_REQ_SET_ADDRESS: - usb_decode_set_address(wValue, str, size); - break; - case USB_REQ_GET_DESCRIPTOR: - case USB_REQ_SET_DESCRIPTOR: - usb_decode_get_set_descriptor(bRequestType, bRequest, wValue, - wIndex, wLength, str, size); - break; - case USB_REQ_GET_CONFIGURATION: - usb_decode_get_configuration(wLength, str, size); - break; - case USB_REQ_SET_CONFIGURATION: - usb_decode_set_configuration(wValue, str, size); - break; - case USB_REQ_GET_INTERFACE: - usb_decode_get_intf(wIndex, wLength, str, size); - break; - case USB_REQ_SET_INTERFACE: - usb_decode_set_intf(wValue, wIndex, str, size); - break; - case USB_REQ_SYNCH_FRAME: - usb_decode_synch_frame(wIndex, wLength, str, size); - break; - case USB_REQ_SET_SEL: - usb_decode_set_sel(wLength, str, size); - break; - case USB_REQ_SET_ISOCH_DELAY: - usb_decode_set_isoch_delay(wValue, str, size); - break; - default: - snprintf(str, size, "%02x %02x %02x %02x %02x %02x %02x %02x", - bRequestType, bRequest, - (u8)(cpu_to_le16(wValue) & 0xff), - (u8)(cpu_to_le16(wValue) >> 8), - (u8)(cpu_to_le16(wIndex) & 0xff), - (u8)(cpu_to_le16(wIndex) >> 8), - (u8)(cpu_to_le16(wLength) & 0xff), - (u8)(cpu_to_le16(wLength) >> 8)); - } - - return str; -} -EXPORT_SYMBOL_GPL(usb_decode_ctrl); diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 42902fcc8696..fb19141151d8 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -889,30 +889,4 @@ extern void usb_ep_autoconfig_release(struct usb_ep *); extern void usb_ep_autoconfig_reset(struct usb_gadget *); -/*-------------------------------------------------------------------------*/ -/** - * usb_decode_ctrl - Returns human readable representation of control request. - * @str: buffer to return a human-readable representation of control request. - * This buffer should have about 200 bytes. - * @size: size of str buffer. - * @bRequestType: matches the USB bmRequestType field - * @bRequest: matches the USB bRequest field - * @wValue: matches the USB wValue field (CPU byte order) - * @wIndex: matches the USB wIndex field (CPU byte order) - * @wLength: matches the USB wLength field (CPU byte order) - * - * Function returns decoded, formatted and human-readable description of - * control request packet. - * - * The usage scenario for this is for tracepoints, so function as a return - * use the same value as in parameters. This approach allows to use this - * function in TP_printk - * - * Important: wValue, wIndex, wLength parameters before invoking this function - * should be processed by le16_to_cpu macro. - */ -extern const char *usb_decode_ctrl(char *str, size_t size, __u8 bRequestType, - __u8 bRequest, __u16 wValue, __u16 wIndex, - __u16 wLength); - #endif /* __LINUX_USB_GADGET_H */ -- cgit v1.2.3-58-ga151