mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-06-27 09:02:20 +00:00
phy: meson-gxl-usb: add set_mode call to force switch to peripheral mode
Add set_mode function in the Amlogic GXL PHYs that will be called by the arch code to switch PHYs from/to gadget mode. Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
This commit is contained in:
parent
c2b9aa98bf
commit
838c0af9d2
3 changed files with 70 additions and 16 deletions
16
arch/arm/include/asm/arch-meson/usb-gx.h
Normal file
16
arch/arm/include/asm/arch-meson/usb-gx.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||||
|
/*
|
||||||
|
* Copyright 2019 BayLibre SAS
|
||||||
|
* Author: Neil Armstrong <narmstrong@baylibre.com>
|
||||||
|
*/
|
||||||
|
#ifndef _ARCH_MESON_USB_GX_H_
|
||||||
|
#define _ARCH_MESON_USB_GX_H_
|
||||||
|
|
||||||
|
#include <generic-phy.h>
|
||||||
|
#include <linux/usb/otg.h>
|
||||||
|
|
||||||
|
/* TOFIX add set_mode to struct phy_ops */
|
||||||
|
void phy_meson_gxl_usb2_set_mode(struct phy *phy, enum usb_dr_mode mode);
|
||||||
|
void phy_meson_gxl_usb3_set_mode(struct phy *phy, enum usb_dr_mode mode);
|
||||||
|
|
||||||
|
#endif
|
|
@ -17,6 +17,9 @@
|
||||||
#include <regmap.h>
|
#include <regmap.h>
|
||||||
#include <power/regulator.h>
|
#include <power/regulator.h>
|
||||||
#include <clk.h>
|
#include <clk.h>
|
||||||
|
#include <linux/usb/otg.h>
|
||||||
|
|
||||||
|
#include <asm/arch/usb-gx.h>
|
||||||
|
|
||||||
#include <linux/bitops.h>
|
#include <linux/bitops.h>
|
||||||
#include <linux/compat.h>
|
#include <linux/compat.h>
|
||||||
|
@ -121,15 +124,30 @@ static void phy_meson_gxl_usb2_reset(struct phy_meson_gxl_usb2_priv *priv)
|
||||||
udelay(RESET_COMPLETE_TIME);
|
udelay(RESET_COMPLETE_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void phy_meson_gxl_usb2_set_mode(struct phy *phy, enum usb_dr_mode mode)
|
||||||
phy_meson_gxl_usb2_set_host_mode(struct phy_meson_gxl_usb2_priv *priv)
|
|
||||||
{
|
{
|
||||||
|
struct udevice *dev = phy->dev;
|
||||||
|
struct phy_meson_gxl_usb2_priv *priv = dev_get_priv(dev);
|
||||||
uint val;
|
uint val;
|
||||||
|
|
||||||
regmap_read(priv->regmap, U2P_R0, &val);
|
regmap_read(priv->regmap, U2P_R0, &val);
|
||||||
val |= U2P_R0_DM_PULLDOWN;
|
|
||||||
val |= U2P_R0_DP_PULLDOWN;
|
switch (mode) {
|
||||||
val &= ~U2P_R0_ID_PULLUP;
|
case USB_DR_MODE_UNKNOWN:
|
||||||
|
case USB_DR_MODE_HOST:
|
||||||
|
case USB_DR_MODE_OTG:
|
||||||
|
val |= U2P_R0_DM_PULLDOWN;
|
||||||
|
val |= U2P_R0_DP_PULLDOWN;
|
||||||
|
val &= ~U2P_R0_ID_PULLUP;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USB_DR_MODE_PERIPHERAL:
|
||||||
|
val &= ~U2P_R0_DM_PULLDOWN;
|
||||||
|
val &= ~U2P_R0_DP_PULLDOWN;
|
||||||
|
val |= U2P_R0_ID_PULLUP;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
regmap_write(priv->regmap, U2P_R0, val);
|
regmap_write(priv->regmap, U2P_R0, val);
|
||||||
|
|
||||||
phy_meson_gxl_usb2_reset(priv);
|
phy_meson_gxl_usb2_reset(priv);
|
||||||
|
@ -146,7 +164,7 @@ static int phy_meson_gxl_usb2_power_on(struct phy *phy)
|
||||||
val &= ~U2P_R0_POWER_ON_RESET;
|
val &= ~U2P_R0_POWER_ON_RESET;
|
||||||
regmap_write(priv->regmap, U2P_R0, val);
|
regmap_write(priv->regmap, U2P_R0, val);
|
||||||
|
|
||||||
phy_meson_gxl_usb2_set_host_mode(priv);
|
phy_meson_gxl_usb2_set_mode(phy, USB_DR_MODE_HOST);
|
||||||
|
|
||||||
#if CONFIG_IS_ENABLED(DM_REGULATOR)
|
#if CONFIG_IS_ENABLED(DM_REGULATOR)
|
||||||
if (priv->phy_supply) {
|
if (priv->phy_supply) {
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
#include <generic-phy.h>
|
#include <generic-phy.h>
|
||||||
#include <regmap.h>
|
#include <regmap.h>
|
||||||
#include <clk.h>
|
#include <clk.h>
|
||||||
|
#include <linux/usb/otg.h>
|
||||||
|
|
||||||
|
#include <asm/arch/usb-gx.h>
|
||||||
|
|
||||||
#include <linux/bitops.h>
|
#include <linux/bitops.h>
|
||||||
#include <linux/compat.h>
|
#include <linux/compat.h>
|
||||||
|
@ -93,20 +96,35 @@ struct phy_meson_gxl_usb3_priv {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
void phy_meson_gxl_usb3_set_mode(struct phy *phy, enum usb_dr_mode mode)
|
||||||
phy_meson_gxl_usb3_set_host_mode(struct phy_meson_gxl_usb3_priv *priv)
|
|
||||||
{
|
{
|
||||||
|
struct udevice *dev = phy->dev;
|
||||||
|
struct phy_meson_gxl_usb3_priv *priv = dev_get_priv(dev);
|
||||||
uint val;
|
uint val;
|
||||||
|
|
||||||
regmap_read(priv->regmap, USB_R0, &val);
|
switch (mode) {
|
||||||
val &= ~USB_R0_U2D_ACT;
|
case USB_DR_MODE_UNKNOWN:
|
||||||
regmap_write(priv->regmap, USB_R0, val);
|
case USB_DR_MODE_HOST:
|
||||||
|
case USB_DR_MODE_OTG:
|
||||||
|
regmap_read(priv->regmap, USB_R0, &val);
|
||||||
|
val &= ~USB_R0_U2D_ACT;
|
||||||
|
regmap_write(priv->regmap, USB_R0, val);
|
||||||
|
|
||||||
regmap_read(priv->regmap, USB_R4, &val);
|
regmap_read(priv->regmap, USB_R4, &val);
|
||||||
val &= ~USB_R4_P21_SLEEP_M0;
|
val &= ~USB_R4_P21_SLEEP_M0;
|
||||||
regmap_write(priv->regmap, USB_R4, val);
|
regmap_write(priv->regmap, USB_R4, val);
|
||||||
|
break;
|
||||||
|
|
||||||
return 0;
|
case USB_DR_MODE_PERIPHERAL:
|
||||||
|
regmap_read(priv->regmap, USB_R0, &val);
|
||||||
|
val |= USB_R0_U2D_ACT;
|
||||||
|
regmap_write(priv->regmap, USB_R0, val);
|
||||||
|
|
||||||
|
regmap_read(priv->regmap, USB_R4, &val);
|
||||||
|
val |= USB_R4_P21_SLEEP_M0;
|
||||||
|
regmap_write(priv->regmap, USB_R4, val);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int phy_meson_gxl_usb3_power_on(struct phy *phy)
|
static int phy_meson_gxl_usb3_power_on(struct phy *phy)
|
||||||
|
@ -122,7 +140,9 @@ static int phy_meson_gxl_usb3_power_on(struct phy *phy)
|
||||||
val |= FIELD_PREP(USB_R5_ID_DIG_TH_MASK, 0xff);
|
val |= FIELD_PREP(USB_R5_ID_DIG_TH_MASK, 0xff);
|
||||||
regmap_write(priv->regmap, USB_R5, val);
|
regmap_write(priv->regmap, USB_R5, val);
|
||||||
|
|
||||||
return phy_meson_gxl_usb3_set_host_mode(priv);
|
phy_meson_gxl_usb3_set_mode(phy, USB_DR_MODE_HOST);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int phy_meson_gxl_usb3_power_off(struct phy *phy)
|
static int phy_meson_gxl_usb3_power_off(struct phy *phy)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue