[PATCH v2 4/5] usb: dwc3-meson-g12a: support OTG switch for all IP versions

neil.armstrong at linaro.org neil.armstrong at linaro.org
Tue Apr 18 04:42:45 PDT 2023


On 18/04/2023 13:16, Dmitry Rokosov wrote:
>  From now, the Amlogic A1 USB controller is capable of switching between
> host and gadget modes based on the status of the OTG_ID signal or via
> manual USB role change.
> Previously, only the Amlogic A1 IP version did not use OTG support for
> host only mode, but this is no longer applicable.
> Therefore, the 'otg_switch_supported' option can now be removed as
> it is no longer required.
> 
> Signed-off-by: Dmitry Rokosov <ddrokosov at sberdevices.ru>
> ---
>   drivers/usb/dwc3/dwc3-meson-g12a.c | 16 +++-------------
>   1 file changed, 3 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
> index b282ad0e69c6..a13afdb219e8 100644
> --- a/drivers/usb/dwc3/dwc3-meson-g12a.c
> +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
> @@ -140,7 +140,6 @@ static const char * const meson_a1_phy_names[] = {
>   struct dwc3_meson_g12a;
>   
>   struct dwc3_meson_g12a_drvdata {
> -	bool otg_switch_supported;
>   	bool otg_phy_host_port_disable;
>   	struct clk_bulk_data *clks;
>   	int num_clks;
> @@ -189,7 +188,6 @@ static int dwc3_meson_gxl_usb_post_init(struct dwc3_meson_g12a *priv);
>    */
>   
>   static const struct dwc3_meson_g12a_drvdata gxl_drvdata = {
> -	.otg_switch_supported = true,
>   	.otg_phy_host_port_disable = true,
>   	.clks = meson_gxl_clocks,
>   	.num_clks = ARRAY_SIZE(meson_g12a_clocks),
> @@ -203,7 +201,6 @@ static const struct dwc3_meson_g12a_drvdata gxl_drvdata = {
>   };
>   
>   static const struct dwc3_meson_g12a_drvdata gxm_drvdata = {
> -	.otg_switch_supported = true,
>   	.otg_phy_host_port_disable = true,
>   	.clks = meson_gxl_clocks,
>   	.num_clks = ARRAY_SIZE(meson_g12a_clocks),
> @@ -217,7 +214,6 @@ static const struct dwc3_meson_g12a_drvdata gxm_drvdata = {
>   };
>   
>   static const struct dwc3_meson_g12a_drvdata axg_drvdata = {
> -	.otg_switch_supported = true,
>   	.clks = meson_gxl_clocks,
>   	.num_clks = ARRAY_SIZE(meson_gxl_clocks),
>   	.phy_names = meson_a1_phy_names,
> @@ -230,7 +226,6 @@ static const struct dwc3_meson_g12a_drvdata axg_drvdata = {
>   };
>   
>   static const struct dwc3_meson_g12a_drvdata g12a_drvdata = {
> -	.otg_switch_supported = true,
>   	.clks = meson_g12a_clocks,
>   	.num_clks = ARRAY_SIZE(meson_g12a_clocks),
>   	.phy_names = meson_g12a_phy_names,
> @@ -242,7 +237,6 @@ static const struct dwc3_meson_g12a_drvdata g12a_drvdata = {
>   };
>   
>   static const struct dwc3_meson_g12a_drvdata a1_drvdata = {
> -	.otg_switch_supported = false,
>   	.clks = meson_a1_clocks,
>   	.num_clks = ARRAY_SIZE(meson_a1_clocks),
>   	.phy_names = meson_a1_phy_names,
> @@ -307,7 +301,7 @@ static int dwc3_meson_g12a_usb2_init_phy(struct dwc3_meson_g12a *priv, int i,
>   			U2P_R0_POWER_ON_RESET,
>   			U2P_R0_POWER_ON_RESET);
>   
> -	if (priv->drvdata->otg_switch_supported && i == USB2_OTG_PHY) {
> +	if (i == USB2_OTG_PHY) {
>   		regmap_update_bits(priv->u2p_regmap[i], U2P_R0,
>   				   U2P_R0_ID_PULLUP | U2P_R0_DRV_VBUS,
>   				   U2P_R0_ID_PULLUP | U2P_R0_DRV_VBUS);
> @@ -490,7 +484,7 @@ static int dwc3_meson_g12a_otg_mode_set(struct dwc3_meson_g12a *priv,
>   {
>   	int ret;
>   
> -	if (!priv->drvdata->otg_switch_supported || !priv->phys[USB2_OTG_PHY])
> +	if (!priv->phys[USB2_OTG_PHY])
>   		return -EINVAL;
>   
>   	if (mode == PHY_MODE_USB_HOST)
> @@ -589,9 +583,6 @@ static int dwc3_meson_g12a_otg_init(struct platform_device *pdev,
>   	int ret, irq;
>   	struct device *dev = &pdev->dev;
>   
> -	if (!priv->drvdata->otg_switch_supported)
> -		return 0;
> -
>   	if (priv->otg_mode == USB_DR_MODE_OTG) {
>   		/* Ack irq before registering */
>   		regmap_update_bits(priv->usb_glue_regmap, USB_R5,
> @@ -841,8 +832,7 @@ static int dwc3_meson_g12a_remove(struct platform_device *pdev)
>   	struct device *dev = &pdev->dev;
>   	int i;
>   
> -	if (priv->drvdata->otg_switch_supported)
> -		usb_role_switch_unregister(priv->role_switch);
> +	usb_role_switch_unregister(priv->role_switch);
>   
>   	of_platform_depopulate(dev);
>   

Reviewed-by: Neil Armstrong <neil.armstrong at linaro.org>



More information about the linux-amlogic mailing list