From: Peter Chen <peter.chen@kernel.org>
To: Xu Yang <xu.yang_2@nxp.com>
Cc: gregkh@linuxfoundation.org, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de,
kernel@pengutronix.de, festevam@gmail.com,
linux-usb@vger.kernel.org, devicetree@vger.kernel.org,
imx@lists.linux.dev, jun.li@nxp.com
Subject: Re: [PATCH v4 4/6] usb: chipidea: imx: add HSIO Block Control wakeup setting
Date: Thu, 6 Mar 2025 16:53:05 +0800 [thread overview]
Message-ID: <Z8licaX8M_Nz6Dmz@nchen-desktop> (raw)
In-Reply-To: <20250303033344.1251076-5-xu.yang_2@nxp.com>
On 25-03-03 11:33:42, Xu Yang wrote:
> On i.MX95 platform, USB wakeup setting is controlled by HSIO Block
> Control:
>
> HSIO Block Control Overview:
> - The HSIO block control include configuration and status registers that
> provide miscellaneous top-level controls for clocking, beat limiter
> enables, wakeup signal enables and interrupt status for the PCIe and USB
> interfaces.
>
> The wakeup function of HSIO blkctl is basically same as non-core, except
> improvements about power lost cases. This will add the wakeup setting for
> HSIO blkctl on i.MX95. It will firstly ioremap hsio blkctl memory, then do
> wakeup setting as needs.
>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Reviewed-by: Jun Li <jun.li@nxp.com>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Acked-by: Peter Chen <peter.chen@kernel.org>
>
> ---
> Changes in v4:
> - add blkctl NULL checking
> - warning if no blkctl reg provided for imx95
> Changes in v3:
> - remove usbmisc_imx95_init(), use usbmisc_imx7d_init()
> Changes in v2:
> - add Rb tag
> ---
> drivers/usb/chipidea/usbmisc_imx.c | 77 ++++++++++++++++++++++++++++++
> 1 file changed, 77 insertions(+)
>
> diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
> index 1394881fde5f..3b35efd95cdb 100644
> --- a/drivers/usb/chipidea/usbmisc_imx.c
> +++ b/drivers/usb/chipidea/usbmisc_imx.c
> @@ -139,6 +139,22 @@
> #define MX6_USB_OTG_WAKEUP_BITS (MX6_BM_WAKEUP_ENABLE | MX6_BM_VBUS_WAKEUP | \
> MX6_BM_ID_WAKEUP | MX6SX_BM_DPDM_WAKEUP_EN)
>
> +/*
> + * HSIO Block Control Register
> + */
> +
> +#define BLKCTL_USB_WAKEUP_CTRL 0x0
> +#define BLKCTL_OTG_WAKE_ENABLE BIT(31)
> +#define BLKCTL_OTG_VBUS_SESSVALID BIT(4)
> +#define BLKCTL_OTG_ID_WAKEUP_EN BIT(2)
> +#define BLKCTL_OTG_VBUS_WAKEUP_EN BIT(1)
> +#define BLKCTL_OTG_DPDM_WAKEUP_EN BIT(0)
> +
> +#define BLKCTL_WAKEUP_SOURCE (BLKCTL_OTG_WAKE_ENABLE | \
> + BLKCTL_OTG_ID_WAKEUP_EN | \
> + BLKCTL_OTG_VBUS_WAKEUP_EN | \
> + BLKCTL_OTG_DPDM_WAKEUP_EN)
> +
> struct usbmisc_ops {
> /* It's called once when probe a usb device */
> int (*init)(struct imx_usbmisc_data *data);
> @@ -159,6 +175,7 @@ struct usbmisc_ops {
>
> struct imx_usbmisc {
> void __iomem *base;
> + void __iomem *blkctl;
> spinlock_t lock;
> const struct usbmisc_ops *ops;
> };
> @@ -1016,6 +1033,44 @@ static int usbmisc_imx6sx_power_lost_check(struct imx_usbmisc_data *data)
> return 0;
> }
>
> +static u32 usbmisc_blkctl_wakeup_setting(struct imx_usbmisc_data *data)
> +{
> + u32 wakeup_setting = BLKCTL_WAKEUP_SOURCE;
> +
> + if (data->ext_id || data->available_role != USB_DR_MODE_OTG)
> + wakeup_setting &= ~BLKCTL_OTG_ID_WAKEUP_EN;
> +
> + if (data->ext_vbus || data->available_role == USB_DR_MODE_HOST)
> + wakeup_setting &= ~BLKCTL_OTG_VBUS_WAKEUP_EN;
> +
> + /* Select session valid as VBUS wakeup source */
> + wakeup_setting |= BLKCTL_OTG_VBUS_SESSVALID;
> +
> + return wakeup_setting;
> +}
> +
> +static int usbmisc_imx95_set_wakeup(struct imx_usbmisc_data *data, bool enabled)
> +{
> + struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
> + unsigned long flags;
> + u32 val;
> +
> + if (!usbmisc->blkctl)
> + return 0;
> +
> + spin_lock_irqsave(&usbmisc->lock, flags);
> + val = readl(usbmisc->blkctl + BLKCTL_USB_WAKEUP_CTRL);
> + val &= ~BLKCTL_WAKEUP_SOURCE;
> +
> + if (enabled)
> + val |= usbmisc_blkctl_wakeup_setting(data);
> +
> + writel(val, usbmisc->blkctl + BLKCTL_USB_WAKEUP_CTRL);
> + spin_unlock_irqrestore(&usbmisc->lock, flags);
> +
> + return 0;
> +}
> +
> static const struct usbmisc_ops imx25_usbmisc_ops = {
> .init = usbmisc_imx25_init,
> .post = usbmisc_imx25_post,
> @@ -1068,6 +1123,14 @@ static const struct usbmisc_ops imx7ulp_usbmisc_ops = {
> .power_lost_check = usbmisc_imx7d_power_lost_check,
> };
>
> +static const struct usbmisc_ops imx95_usbmisc_ops = {
> + .init = usbmisc_imx7d_init,
> + .set_wakeup = usbmisc_imx95_set_wakeup,
> + .charger_detection = imx7d_charger_detection,
> + .power_lost_check = usbmisc_imx7d_power_lost_check,
> + .vbus_comparator_on = usbmisc_imx7d_vbus_comparator_on,
> +};
> +
> static inline bool is_imx53_usbmisc(struct imx_usbmisc_data *data)
> {
> struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
> @@ -1289,6 +1352,10 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = {
> .compatible = "fsl,imx8ulp-usbmisc",
> .data = &imx7ulp_usbmisc_ops,
> },
> + {
> + .compatible = "fsl,imx95-usbmisc",
> + .data = &imx95_usbmisc_ops,
> + },
> { /* sentinel */ }
> };
> MODULE_DEVICE_TABLE(of, usbmisc_imx_dt_ids);
> @@ -1296,6 +1363,7 @@ MODULE_DEVICE_TABLE(of, usbmisc_imx_dt_ids);
> static int usbmisc_imx_probe(struct platform_device *pdev)
> {
> struct imx_usbmisc *data;
> + struct resource *res;
>
> data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
> if (!data)
> @@ -1307,6 +1375,15 @@ static int usbmisc_imx_probe(struct platform_device *pdev)
> if (IS_ERR(data->base))
> return PTR_ERR(data->base);
>
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> + if (res) {
> + data->blkctl = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(data->blkctl))
> + return PTR_ERR(data->blkctl);
> + } else if (device_is_compatible(&pdev->dev, "fsl,imx95-usbmisc")) {
> + dev_warn(&pdev->dev, "wakeup setting is missing");
> + }
> +
> data->ops = of_device_get_match_data(&pdev->dev);
> platform_set_drvdata(pdev, data);
>
> --
> 2.34.1
>
--
Best regards,
Peter
next prev parent reply other threads:[~2025-03-06 8:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-03 3:33 [PATCH v4 0/6] add USB2.0 support for i.MX95-19x19 EVK board Xu Yang
2025-03-03 3:33 ` [PATCH v4 1/6] dt-bindings: usb: chipidea: Add i.MX95 compatible string 'fsl,imx95-usb' Xu Yang
2025-03-03 3:33 ` [PATCH v4 2/6] dt-bindings: usb: usbmisc-imx: add support for i.MX95 platform Xu Yang
2025-03-03 3:33 ` [PATCH v4 3/6] usb: chipidea: imx: add wakeup interrupt handling Xu Yang
2025-03-03 17:13 ` Frank Li
2025-03-04 13:42 ` Xu Yang
2025-03-04 15:20 ` Frank Li
2025-03-07 8:53 ` Xu Yang
2025-03-12 8:21 ` Xu Yang
2025-03-04 9:50 ` Alexander Stein
2025-03-04 13:44 ` Xu Yang
2025-03-03 3:33 ` [PATCH v4 4/6] usb: chipidea: imx: add HSIO Block Control wakeup setting Xu Yang
2025-03-06 8:53 ` Peter Chen [this message]
2025-03-03 3:33 ` [PATCH v4 5/6] arm64: dts: imx95: add USB2.0 nodes Xu Yang
2025-03-03 3:33 ` [PATCH v4 6/6] arm64: dts: imx95-19x19-evk: enable USB2.0 node Xu Yang
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=Z8licaX8M_Nz6Dmz@nchen-desktop \
--to=peter.chen@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=imx@lists.linux.dev \
--cc=jun.li@nxp.com \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=xu.yang_2@nxp.com \
/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;
as well as URLs for NNTP newsgroup(s).