From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Cc: Marek Vasut <marex@denx.de>, Tim Harvey <tharvey@gateworks.com>,
Fabio Estevam <festevam@gmail.com>, Peng Fan <peng.fan@nxp.com>,
Stefano Babic <sbabic@denx.de>
Subject: [PATCH v2 20/23] phy: phy-imx8mq-usb: Add support for i.MX8MP USB PHY
Date: Mon, 11 Apr 2022 21:45:40 +0200 [thread overview]
Message-ID: <20220411194543.730647-20-marex@denx.de> (raw)
In-Reply-To: <20220411194543.730647-1-marex@denx.de>
Add initial support for i.MX8MP USB PHY, i.MX8MP USB is similar to
the i.MX8MQ, except for clock and power domain design customization.
Tested-By: Tim Harvey <tharvey@gateworks.com> #imx8mp-venice-gw74xx
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
---
V2: Add TB from Tim
---
drivers/phy/Kconfig | 6 ++--
drivers/phy/phy-imx8mq-usb.c | 66 +++++++++++++++++++++++++++++++++---
2 files changed, 65 insertions(+), 7 deletions(-)
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index d79798429b1..c01d9e09b90 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -275,11 +275,11 @@ config PHY_MTK_TPHY
so you can easily distinguish them by banks layout.
config PHY_IMX8MQ_USB
- bool "NXP i.MX8MQ USB PHY Driver"
+ bool "NXP i.MX8MQ/i.MX8MP USB PHY Driver"
depends on PHY
- depends on IMX8MQ
+ depends on IMX8MQ || IMX8MP
help
- Support the USB3.0 PHY in NXP i.MX8MQ SoC
+ Support the USB3.0 PHY in NXP i.MX8MQ or i.MX8MP SoC
config PHY_XILINX_ZYNQMP
tristate "Xilinx ZynqMP PHY driver"
diff --git a/drivers/phy/phy-imx8mq-usb.c b/drivers/phy/phy-imx8mq-usb.c
index afbc7ad8dd4..69f01de5553 100644
--- a/drivers/phy/phy-imx8mq-usb.c
+++ b/drivers/phy/phy-imx8mq-usb.c
@@ -9,7 +9,9 @@
#include <dm.h>
#include <errno.h>
#include <generic-phy.h>
+#include <linux/bitfield.h>
#include <linux/bitops.h>
+#include <linux/delay.h>
#include <linux/err.h>
#include <clk.h>
@@ -68,17 +70,22 @@
#define PHY_STS0_FSVPLUS BIT(3)
#define PHY_STS0_FSVMINUS BIT(2)
+enum imx8mpq_phy_type {
+ IMX8MQ_PHY,
+ IMX8MP_PHY,
+};
+
struct imx8mq_usb_phy {
#if CONFIG_IS_ENABLED(CLK)
struct clk phy_clk;
#endif
void __iomem *base;
+ enum imx8mpq_phy_type type;
};
static const struct udevice_id imx8mq_usb_phy_of_match[] = {
- {
- .compatible = "fsl,imx8mq-usb-phy",
- },
+ { .compatible = "fsl,imx8mq-usb-phy", .data = IMX8MQ_PHY },
+ { .compatible = "fsl,imx8mp-usb-phy", .data = IMX8MP_PHY },
{},
};
@@ -111,6 +118,56 @@ static int imx8mq_usb_phy_init(struct phy *usb_phy)
return 0;
}
+static int imx8mp_usb_phy_init(struct phy *usb_phy)
+{
+ struct udevice *dev = usb_phy->dev;
+ struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
+ u32 value;
+
+ /* USB3.0 PHY signal fsel for 24M ref */
+ value = readl(imx_phy->base + PHY_CTRL0);
+ value &= ~PHY_CTRL0_FSEL_MASK;
+ value |= FIELD_PREP(PHY_CTRL0_FSEL_MASK, PHY_CTRL0_FSEL_24M);
+ writel(value, imx_phy->base + PHY_CTRL0);
+
+ /* Disable alt_clk_en and use internal MPLL clocks */
+ value = readl(imx_phy->base + PHY_CTRL6);
+ value &= ~(PHY_CTRL6_ALT_CLK_SEL | PHY_CTRL6_ALT_CLK_EN);
+ writel(value, imx_phy->base + PHY_CTRL6);
+
+ value = readl(imx_phy->base + PHY_CTRL1);
+ value &= ~(PHY_CTRL1_VDATSRCENB0 | PHY_CTRL1_VDATDETENB0);
+ value |= PHY_CTRL1_RESET | PHY_CTRL1_ATERESET;
+ writel(value, imx_phy->base + PHY_CTRL1);
+
+ value = readl(imx_phy->base + PHY_CTRL0);
+ value |= PHY_CTRL0_REF_SSP_EN;
+ writel(value, imx_phy->base + PHY_CTRL0);
+
+ value = readl(imx_phy->base + PHY_CTRL2);
+ value |= PHY_CTRL2_TXENABLEN0 | PHY_CTRL2_OTG_DISABLE;
+ writel(value, imx_phy->base + PHY_CTRL2);
+
+ udelay(10);
+
+ value = readl(imx_phy->base + PHY_CTRL1);
+ value &= ~(PHY_CTRL1_RESET | PHY_CTRL1_ATERESET);
+ writel(value, imx_phy->base + PHY_CTRL1);
+
+ return 0;
+}
+
+static int imx8mpq_usb_phy_init(struct phy *usb_phy)
+{
+ struct udevice *dev = usb_phy->dev;
+ struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
+
+ if (imx_phy->type == IMX8MP_PHY)
+ return imx8mp_usb_phy_init(usb_phy);
+ else
+ return imx8mq_usb_phy_init(usb_phy);
+}
+
static int imx8mq_usb_phy_power_on(struct phy *usb_phy)
{
struct udevice *dev = usb_phy->dev;
@@ -158,7 +215,7 @@ static int imx8mq_usb_phy_exit(struct phy *usb_phy)
}
struct phy_ops imx8mq_usb_phy_ops = {
- .init = imx8mq_usb_phy_init,
+ .init = imx8mpq_usb_phy_init,
.power_on = imx8mq_usb_phy_power_on,
.power_off = imx8mq_usb_phy_power_off,
.exit = imx8mq_usb_phy_exit,
@@ -168,6 +225,7 @@ int imx8mq_usb_phy_probe(struct udevice *dev)
{
struct imx8mq_usb_phy *priv = dev_get_priv(dev);
+ priv->type = dev_get_driver_data(dev);
priv->base = dev_read_addr_ptr(dev);
if (!priv->base)
--
2.35.1
next prev parent reply other threads:[~2022-04-11 19:50 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-11 19:45 [PATCH v2 01/23] mmc: fsl_esdhc_imx: Add i.MX8MP compatible string Marek Vasut
2022-04-11 19:45 ` [PATCH v2 02/23] ARM: dts: net: dwc_eth_qos: Fix " Marek Vasut
2022-04-11 19:45 ` [PATCH v2 03/23] ARM: imx: imx8m: Add 933 MHz PLL settings Marek Vasut
2022-04-12 18:45 ` sbabic
2022-04-11 19:45 ` [PATCH v2 04/23] imx8m: ddrphy_utils: Add 3732 MT/s mode Marek Vasut
2022-04-12 18:46 ` sbabic
2022-04-11 19:45 ` [PATCH v2 05/23] pmic: pca9450: Add PCA9450C compatible string Marek Vasut
2022-04-12 18:43 ` sbabic
2022-04-11 19:45 ` [PATCH v2 06/23] pmic: pca9450: Add upstream regulators subnode match Marek Vasut
2022-04-18 0:10 ` Jaehoon Chung
2022-04-11 19:45 ` [PATCH v2 07/23] pmic: pca9450: Add regulator driver Marek Vasut
2022-04-18 0:13 ` Jaehoon Chung
2022-04-11 19:45 ` [PATCH v2 08/23] spi: nxp_fspi: Add i.MX8MP compatible string Marek Vasut
2022-04-11 19:45 ` [PATCH v2 09/23] ARM: dts: imx: Add flexspi node to i.MX8MP Marek Vasut
2022-04-11 19:45 ` [PATCH v2 10/23] ARM: imx: Decode ECSPI env location from i.MX8M ROMAPI tables Marek Vasut
2022-04-11 19:45 ` [PATCH v2 11/23] ARM: imx: Get rid of only i.MX8M SMCCC arch call Marek Vasut
2022-04-11 19:45 ` [PATCH v2 12/23] power-domain: Return 0 if ops unimplemented and remove empty functions Marek Vasut
2022-04-18 0:14 ` Jaehoon Chung
2022-04-11 19:45 ` [PATCH v2 13/23] imx: power-domain: Descend into pgc subnode if present Marek Vasut
2022-04-11 19:45 ` [PATCH v2 14/23] imx: power-domain: Inline arch-imx8m/power-domain.h Marek Vasut
2022-04-18 0:23 ` Jaehoon Chung
2022-04-11 19:45 ` [PATCH v2 15/23] imx: power-domain: Get rid of SMCCC dependency Marek Vasut
2022-04-11 19:45 ` [PATCH v2 16/23] power_domain: Add power_domain_get_by_name() Marek Vasut
2022-04-11 19:45 ` [PATCH v2 17/23] imx: power-domain: Add i.MX8MP support Marek Vasut
2022-04-11 19:45 ` [PATCH v3 18/23] imx: power-domain: Add i.MX8MP HSIOMIX driver Marek Vasut
2022-04-11 19:45 ` [PATCH v3 19/23] clk: imx8mp: Fill in DWC3 USB, USB PHY, HSIOMIX clock Marek Vasut
2022-04-11 19:45 ` Marek Vasut [this message]
2022-04-12 18:44 ` [PATCH v2 20/23] phy: phy-imx8mq-usb: Add support for i.MX8MP USB PHY sbabic
2022-04-11 19:45 ` [PATCH v2 21/23] usb: dwc3: Rename .select_dr_mode to .glue_configure Marek Vasut
2022-04-11 19:45 ` [PATCH v2 22/23] usb: dwc3: Implement .glue_configure for i.MX8MP Marek Vasut
2022-04-11 19:45 ` [PATCH v2 23/23] arm: dts: imx8mp: Import GPCv2 subset, HSIOMIX and USB PD Marek Vasut
2022-04-12 18:56 ` [PATCH v2 01/23] mmc: fsl_esdhc_imx: Add i.MX8MP compatible string Stefano Babic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220411194543.730647-20-marex@denx.de \
--to=marex@denx.de \
--cc=festevam@gmail.com \
--cc=peng.fan@nxp.com \
--cc=sbabic@denx.de \
--cc=tharvey@gateworks.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox