From: rentao.bupt@gmail.com
To: Felipe Balbi <balbi@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Joel Stanley <joel@jms.id.au>, Andrew Jeffery <andrew@aj.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Chunfeng Yun <chunfeng.yun@mediatek.com>,
Colin Ian King <colin.king@canonical.com>,
Stephen Boyd <swboyd@chromium.org>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org,
taoren@fb.com
Cc: Tao Ren <rentao.bupt@gmail.com>
Subject: [PATCH v2 4/6] usb: gadget: aspeed: allow to set device IDs in device tree
Date: Sun, 15 Mar 2020 12:16:30 -0700 [thread overview]
Message-ID: <20200315191632.12536-5-rentao.bupt@gmail.com> (raw)
In-Reply-To: <20200315191632.12536-1-rentao.bupt@gmail.com>
From: Tao Ren <rentao.bupt@gmail.com>
The patch overrides idVendor, idProduct and bcdDevice fields in vhub
Device Descriptor if according device tree properties are defined.
Signed-off-by: Tao Ren <rentao.bupt@gmail.com>
---
Changes in v2:
- update per-vhub device descriptor instance instead of the global
default descriptor.
drivers/usb/gadget/udc/aspeed-vhub/hub.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/usb/gadget/udc/aspeed-vhub/hub.c b/drivers/usb/gadget/udc/aspeed-vhub/hub.c
index 421631d86a17..13fba91aad6a 100644
--- a/drivers/usb/gadget/udc/aspeed-vhub/hub.c
+++ b/drivers/usb/gadget/udc/aspeed-vhub/hub.c
@@ -887,6 +887,26 @@ void ast_vhub_hub_reset(struct ast_vhub *vhub)
writel(0, vhub->regs + AST_VHUB_EP1_STS_CHG);
}
+static void ast_vhub_of_parse_dev_desc(struct ast_vhub *vhub,
+ const struct device_node *vhub_np)
+{
+ u16 id;
+ u32 data;
+
+ if (!of_property_read_u32(vhub_np, "vhub-vendor-id", &data)) {
+ id = (u16)data;
+ vhub->vhub_dev_desc.idVendor = cpu_to_le16(id);
+ }
+ if (!of_property_read_u32(vhub_np, "vhub-product-id", &data)) {
+ id = (u16)data;
+ vhub->vhub_dev_desc.idProduct = cpu_to_le16(id);
+ }
+ if (!of_property_read_u32(vhub_np, "vhub-device-revision", &data)) {
+ id = (u16)data;
+ vhub->vhub_dev_desc.bcdDevice = cpu_to_le16(id);
+ }
+}
+
static struct usb_gadget_string_container*
ast_vhub_str_container_alloc(struct ast_vhub *vhub)
{
@@ -1000,6 +1020,7 @@ static int ast_vhub_init_desc(struct ast_vhub *vhub)
/* Initialize vhub Device Descriptor. */
memcpy(&vhub->vhub_dev_desc, &ast_vhub_dev_desc,
sizeof(vhub->vhub_dev_desc));
+ ast_vhub_of_parse_dev_desc(vhub, vhub_np);
/* Initialize vhub Configuration Descriptor. */
memcpy(&vhub->vhub_conf_desc, &ast_vhub_conf_desc,
--
2.17.1
next prev parent reply other threads:[~2020-03-15 19:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-15 19:16 [PATCH v2 0/6] usb: gadget: aspeed: allow to customize vhub device rentao.bupt
2020-03-15 19:16 ` [PATCH v2 1/6] usb: gadget: aspeed: support multiple language strings rentao.bupt
2020-03-15 19:16 ` [PATCH v2 2/6] usb: gadget: add "usb_validate_langid" function rentao.bupt
2020-03-15 19:16 ` [PATCH v2 3/6] usb: gadget: aspeed: allow to set usb strings in device tree rentao.bupt
2020-03-15 19:16 ` rentao.bupt [this message]
2020-03-15 19:16 ` [PATCH v2 5/6] usb: gadget: aspeed: fixup usb1 device descriptor at init time rentao.bupt
2020-03-15 19:16 ` [PATCH v2 6/6] dt-bindings: usb: document aspeed vhub device ID/string properties rentao.bupt
2020-03-30 19:23 ` Rob Herring
2020-03-31 0:13 ` Benjamin Herrenschmidt
2020-03-31 16:21 ` Rob Herring
2020-04-01 0:47 ` Tao Ren
2020-04-02 10:37 ` Benjamin Herrenschmidt
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=20200315191632.12536-5-rentao.bupt@gmail.com \
--to=rentao.bupt@gmail.com \
--cc=andrew@aj.id.au \
--cc=balbi@kernel.org \
--cc=benh@kernel.crashing.org \
--cc=chunfeng.yun@mediatek.com \
--cc=colin.king@canonical.com \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=joel@jms.id.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=openbmc@lists.ozlabs.org \
--cc=robh+dt@kernel.org \
--cc=swboyd@chromium.org \
--cc=taoren@fb.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).