From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 1/4] usb: otg: Add function to set dr_mode
Date: Mon, 20 Apr 2026 11:02:17 +0200 [thread overview]
Message-ID: <20260420-usb-typec-stusb160x-v1-1-5875bbae80ab@pengutronix.de> (raw)
In-Reply-To: <20260420-usb-typec-stusb160x-v1-0-5875bbae80ab@pengutronix.de>
So far we can only set the dr_mode on the command line. Add a function
for it.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/usb/otg/otgdev.c | 20 ++++++++++++++++++++
include/linux/usb/usb.h | 1 +
2 files changed, 21 insertions(+)
diff --git a/drivers/usb/otg/otgdev.c b/drivers/usb/otg/otgdev.c
index 5a86263430..50d8105be3 100644
--- a/drivers/usb/otg/otgdev.c
+++ b/drivers/usb/otg/otgdev.c
@@ -74,6 +74,26 @@ int otg_device_get_mode(struct device *dev)
return otg->cur_mode;
}
+int otg_device_set_dr_mode(struct device *dev, enum usb_dr_mode mode)
+{
+ struct otg_mode *otg;
+ int ret;
+
+ if (dev->bus != &otg_bus_type)
+ return -ENODEV;
+
+ otg = dev->priv;
+
+ ret = otg->set_mode_callback(otg->ctx, mode);
+ if (ret)
+ return ret;
+
+ otg->cur_mode = mode;
+ otg->var_mode = mode;
+
+ return 0;
+}
+
int usb_register_otg_device(struct device *parent,
int (*set_mode)(void *ctx, enum usb_dr_mode mode), void *ctx)
{
diff --git a/include/linux/usb/usb.h b/include/linux/usb/usb.h
index c25f3d73c3..6aa9e55cc9 100644
--- a/include/linux/usb/usb.h
+++ b/include/linux/usb/usb.h
@@ -477,6 +477,7 @@ int usb_register_otg_device(struct device *parent,
int (*set_mode)(void *ctx, enum usb_dr_mode mode), void *ctx);
int otg_device_get_mode(struct device *dev);
+int otg_device_set_dr_mode(struct device *dev, enum usb_dr_mode mode);
extern struct bus_type otg_bus_type;
--
2.47.3
next prev parent reply other threads:[~2026-04-20 9:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 9:02 [PATCH 0/4] usb: typec: STUSB160x support Sascha Hauer
2026-04-20 9:02 ` Sascha Hauer [this message]
2026-04-20 10:42 ` [PATCH 1/4] usb: otg: Add function to set dr_mode Ahmad Fatoum
2026-04-20 9:02 ` [PATCH 2/4] usb: typec: wire USB role changes to OTG device Sascha Hauer
2026-04-20 11:08 ` Ahmad Fatoum
2026-04-20 12:02 ` Sascha Hauer
2026-04-20 9:02 ` [PATCH 3/4] usb: typec: add typec_find_port_power_role() and typec_find_pwr_opmode() Sascha Hauer
2026-04-20 9:02 ` [PATCH 4/4] USB: typec: Add STUSB160x driver Sascha Hauer
2026-04-20 11:14 ` Ahmad Fatoum
2026-04-20 11:30 ` Sascha Hauer
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=20260420-usb-typec-stusb160x-v1-1-5875bbae80ab@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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