From: Michael Grzeschik <mgr@pengutronix.de>
To: Jules Maselbas <jmaselbas@kalray.eu>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/4] usb: dwc2: Add support for optional usb phy
Date: Wed, 9 Dec 2020 20:14:51 +0100 [thread overview]
Message-ID: <20201209191451.GG27410@pengutronix.de> (raw)
In-Reply-To: <20201209145547.22655-1-jmaselbas@kalray.eu>
[-- Attachment #1.1: Type: text/plain, Size: 2819 bytes --]
On Wed, Dec 09, 2020 at 03:55:44PM +0100, Jules Maselbas wrote:
>Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
>---
> drivers/usb/dwc2/core.h | 2 ++
> drivers/usb/dwc2/dwc2.c | 21 +++++++++++++++++++++
> drivers/usb/dwc2/dwc2.h | 1 +
> 3 files changed, 24 insertions(+)
>
>diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
>index 090ca15fe..b9845b552 100644
>--- a/drivers/usb/dwc2/core.h
>+++ b/drivers/usb/dwc2/core.h
>@@ -466,6 +466,8 @@ struct dwc2 {
> struct dwc2_hw_params hw_params;
> struct dwc2_core_params params;
>
>+ struct phy *phy; /* optional */
>+
> #ifdef CONFIG_USB_DWC2_HOST
> struct usb_host host;
> u8 in_data_toggle[MAX_DEVICE][MAX_ENDPOINT];
>diff --git a/drivers/usb/dwc2/dwc2.c b/drivers/usb/dwc2/dwc2.c
>index 282e6754b..ae144698c 100644
>--- a/drivers/usb/dwc2/dwc2.c
>+++ b/drivers/usb/dwc2/dwc2.c
>@@ -50,6 +50,17 @@ static int dwc2_probe(struct device_d *dev)
> dwc2->regs = IOMEM(iores->start);
> dwc2->dev = dev;
>
>+ dwc2->phy = phy_optional_get(dev, "usb2-phy");
>+ if (!dwc2->phy)
>+ dwc2->phy = phy_optional_get(dev, "usb-phy");
>+ if (dwc2->phy) {
dwc2->phy could be of type PTR_ERR. So checking for IS_ERR is necessary.
>+ ret = phy_power_on(dwc2->phy);
>+ if (ret == 0)
>+ ret = phy_init(dwc2->phy);
>+ if (ret)
>+ goto error;
>+ }
>+
> ret = dwc2_core_snpsid(dwc2);
> if (ret)
> goto error;
>@@ -78,15 +89,25 @@ static int dwc2_probe(struct device_d *dev)
> ret = dwc2_set_mode(dwc2, dwc2->dr_mode);
>
> error:
>+ if (dwc2->phy)
>+ phy_power_off(dwc2->phy);
>+
Same here.
> return ret;
> }
>
> static void dwc2_remove(struct device_d *dev)
> {
> struct dwc2 *dwc2 = dev->priv;
>+ int ret;
>
> dwc2_host_uninit(dwc2);
> dwc2_gadget_uninit(dwc2);
>+
>+ if (dwc2->phy) {
>+ ret = phy_exit(dwc2->phy);
>+ if (ret == 0)
>+ phy_power_off(dwc2->phy);
>+ }
> }
>
> static const struct of_device_id dwc2_platform_dt_ids[] = {
>diff --git a/drivers/usb/dwc2/dwc2.h b/drivers/usb/dwc2/dwc2.h
>index 30ad90665..196f4a07f 100644
>--- a/drivers/usb/dwc2/dwc2.h
>+++ b/drivers/usb/dwc2/dwc2.h
>@@ -2,6 +2,7 @@
> #include <usb/usb.h>
> #include <usb/usb_defs.h>
> #include <usb/gadget.h>
>+#include <linux/phy/phy.h>
>
> #include "regs.h"
> #include "core.h"
>--
>2.17.1
>
>
>
>_______________________________________________
>barebox mailing list
>barebox@lists.infradead.org
>http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 149 bytes --]
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2020-12-09 19:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-09 14:55 Jules Maselbas
2020-12-09 14:55 ` [PATCH 2/4] usb: dwc2: Move static function prototypes into core.c Jules Maselbas
2020-12-10 10:05 ` Sascha Hauer
2020-12-10 10:18 ` Jules Maselbas
2020-12-09 14:55 ` [PATCH 3/4] usb: dwc2: Fix mode check in dwc2_get_dr_mode Jules Maselbas
2020-12-09 14:55 ` [PATCH 4/4] usb: dwc2: Rename dwc2_core_snpsid to dwc2_check_core_version Jules Maselbas
2020-12-09 19:14 ` Michael Grzeschik [this message]
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=20201209191451.GG27410@pengutronix.de \
--to=mgr@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=jmaselbas@kalray.eu \
/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