From: Andre Przywara <andre.przywara@arm.com>
To: Jagan Teki <jagan@amarulasolutions.com>
Cc: Samuel Holland <samuel@sholland.org>,
Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
Hans de Goede <hdegoede@redhat.com>,
Olliver Schinagl <oliver@schinagl.nl>,
Iain Paton <ipaton0@gmail.com>,
Marcus Cooper <codekipper@gmail.com>,
Stefan Mavrodiev <stefan@olimex.com>,
Paul Kocialkowski <contact@paulk.fr>,
Chen-Yu Tsai <wens@csie.org>, Maxime Ripard <mripard@kernel.org>,
Ian Campbell <ijc@hellion.org.uk>, Adam Sampson <ats@offog.org>,
Zoltan Herpai <wigyori@uid0.hu>,
Siarhei Siamashka <siarhei.siamashka@gmail.com>,
VishnuPatekar <vishnupatekar0510@gmail.com>,
Rask Ingemann Lambertsen <rask@formelder.dk>,
Aleksei Mamlin <mamlinav@gmail.com>,
Peter Korsgaard <peter@korsgaard.com>,
Michal Suchanek <hramrach@gmail.com>,
Icenowy Zheng <icenowy@aosc.xyz>, Stefan Roese <sr@denx.de>,
Phil Han <pengphei@sina.com>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Quentin Schulz <quentin.schulz@free-electrons.com>,
Jonas Smedegaard <dr@jones.dk>,
Jaehoon Chung <jh80.chung@samsung.com>,
Heiko Schocher <hs@denx.de>,
u-boot@lists.denx.de, linux-sunxi@lists.linux.dev
Subject: [PATCH v2 7/8] phy: sun4i-usb: Determine USB OTG detection pin from devicetree
Date: Wed, 9 Apr 2025 01:20:35 +0100 [thread overview]
Message-ID: <20250409002036.12212-8-andre.przywara@arm.com> (raw)
In-Reply-To: <20250409002036.12212-1-andre.przywara@arm.com>
So far Allwinner boards controlled the USB OTG ID detection via the
respective GPIO pin specified in Kconfig, as a string. All boards should
have the same GPIO already specified in the devicetree, in the
usb0_id_det-gpios property.
Convert the usage of the Kconfig configured GPIO over to query that
information from the devicetree, then use the existing DM GPIO
infrastructure to request the GPIO.
Only PHY0 supports USB-OTG, so limit the GPIO request to that PHY, to
avoid claiming it multiple times.
This removes the need to name that GPIO in the defconfig file.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
drivers/phy/allwinner/phy-sun4i-usb.c | 35 ++++++---------------------
1 file changed, 8 insertions(+), 27 deletions(-)
diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
index 42e67b47328..3acffb40b0b 100644
--- a/drivers/phy/allwinner/phy-sun4i-usb.c
+++ b/drivers/phy/allwinner/phy-sun4i-usb.c
@@ -85,23 +85,6 @@ struct sun4i_usb_phy_cfg {
int missing_phys;
};
-struct sun4i_usb_phy_info {
- const char *gpio_id_det;
-} phy_info[] = {
- {
- .gpio_id_det = CONFIG_USB0_ID_DET,
- },
- {
- .gpio_id_det = NULL,
- },
- {
- .gpio_id_det = NULL,
- },
- {
- .gpio_id_det = NULL,
- },
-};
-
struct sun4i_usb_phy_plat {
void __iomem *pmu;
struct gpio_desc gpio_vbus_det;
@@ -475,7 +458,6 @@ static int sun4i_usb_phy_probe(struct udevice *dev)
data->usb_phy = plat;
for (i = 0; i < data->cfg->num_phys; i++) {
struct sun4i_usb_phy_plat *phy = &plat[i];
- struct sun4i_usb_phy_info *info = &phy_info[i];
char name[32];
if (data->cfg->missing_phys & BIT(i))
@@ -499,17 +481,16 @@ static int sun4i_usb_phy_probe(struct udevice *dev)
ret);
return ret;
}
- }
- ret = dm_gpio_lookup_name(info->gpio_id_det, &phy->gpio_id_det);
- if (ret == 0) {
- ret = dm_gpio_request(&phy->gpio_id_det, "usb_id_det");
- if (ret)
- return ret;
- ret = dm_gpio_set_dir_flags(&phy->gpio_id_det,
- GPIOD_IS_IN | GPIOD_PULL_UP);
- if (ret)
+ ret = gpio_request_by_name(dev, "usb0_id_det-gpios", 0,
+ &phy->gpio_id_det,
+ GPIOD_IS_IN | GPIOD_PULL_UP);
+ if (ret && ret != -ENOENT) {
+ dev_err(dev,
+ "failed to get ID detect GPIO: %d\n",
+ ret);
return ret;
+ }
}
if (data->cfg->dedicated_clocks)
--
2.46.3
next prev parent reply other threads:[~2025-04-09 0:21 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-09 0:20 [PATCH v2 0/8] sunxi: Control USB pins and supplies via DT regulators Andre Przywara
2025-04-09 0:20 ` [PATCH v2 1/8] power: regulator: Add a driver for the AXP PMIC drivevbus Andre Przywara
2025-04-10 7:04 ` Jernej Škrabec
2025-04-10 9:23 ` Andre Przywara
2025-04-09 0:20 ` [PATCH v2 2/8] sunxi: Enable PMIC drivevbus regulator support for USB supplies Andre Przywara
2025-04-10 7:08 ` Jernej Škrabec
2025-04-09 0:20 ` [PATCH v2 3/8] phy: sun4i-usb: Control supplies via the regulator uclass Andre Przywara
2025-04-10 7:11 ` Jernej Škrabec
2025-04-09 0:20 ` [PATCH v2 4/8] sunxi: Remove obsolete USBx_VBUS_PIN Kconfig symbols Andre Przywara
2025-04-10 7:12 ` Jernej Škrabec
2025-04-09 0:20 ` [PATCH v2 5/8] gpio: axp: Remove virtual VBUS enable GPIO Andre Przywara
2025-04-10 7:17 ` Jernej Škrabec
2025-04-09 0:20 ` [PATCH v2 6/8] phy: sun4i-usb: Determine VBUS detection pin from devicetree Andre Przywara
2025-04-10 7:18 ` Jernej Škrabec
2025-04-09 0:20 ` Andre Przywara [this message]
2025-04-10 7:19 ` [PATCH v2 7/8] phy: sun4i-usb: Determine USB OTG " Jernej Škrabec
2025-04-09 0:20 ` [PATCH v2 8/8] sunxi: Kconfig: Remove obsolete USBx_* pin symbols Andre Przywara
2025-04-10 7:20 ` Jernej Škrabec
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=20250409002036.12212-8-andre.przywara@arm.com \
--to=andre.przywara@arm.com \
--cc=ats@offog.org \
--cc=codekipper@gmail.com \
--cc=contact@paulk.fr \
--cc=dr@jones.dk \
--cc=hdegoede@redhat.com \
--cc=hramrach@gmail.com \
--cc=hs@denx.de \
--cc=icenowy@aosc.xyz \
--cc=ijc@hellion.org.uk \
--cc=ipaton0@gmail.com \
--cc=jagan@amarulasolutions.com \
--cc=jernej.skrabec@gmail.com \
--cc=jh80.chung@samsung.com \
--cc=linux-sunxi@lists.linux.dev \
--cc=mamlinav@gmail.com \
--cc=mripard@kernel.org \
--cc=oliver@schinagl.nl \
--cc=pengphei@sina.com \
--cc=peter@korsgaard.com \
--cc=quentin.schulz@free-electrons.com \
--cc=rask@formelder.dk \
--cc=samuel@sholland.org \
--cc=siarhei.siamashka@gmail.com \
--cc=sjg@chromium.org \
--cc=sr@denx.de \
--cc=stefan@olimex.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=vishnupatekar0510@gmail.com \
--cc=wens@csie.org \
--cc=wigyori@uid0.hu \
/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