From patchwork Sun Mar 15 19:16:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ren X-Patchwork-Id: 11439377 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3DE4D13B1 for ; Sun, 15 Mar 2020 19:17:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 66055206BE for ; Sun, 15 Mar 2020 19:17:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Y0iNLYx/"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cBdghDbS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 66055206BE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=4ms54WX/triN8Mm9hIwYKMO1qVoqsrfIgd7DIvBtBc8=; b=Y0iNLYx/fDe2N0zlGMZOkSJ/LJ rq9z3i9kyT+1smplFEXfaPrXiV6Yf3cMFkjFu3Yj+Eh+yGulz9j6IhNFezxl16xzpS8iqnnpJ5wG5 ZjIhPNg1o7OxymP1dPeXok1Munoa59lq+27F/K7pNx+78doL7PCLQQcb7Ke+G8HmRxOS2SYlJFoPi ir8wR5R/rjo+6Orr3mGkh9A43zbs6f/dS4t08GDf5ztS0iqYhPpxxS+dD2Nnb+YH7GeBeurjOvvtn MYfG5hAGi8OM9PMf6d7SFvwrpMkmwZ4/XJvFSioIFAZqAYArK61e1IxOg5zNSdP+SBRo/pX8GL0yK 7ULX4D6Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDYlC-0004S4-Bo; Sun, 15 Mar 2020 19:17:18 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDYkc-0003yB-EQ for linux-arm-kernel@lists.infradead.org; Sun, 15 Mar 2020 19:16:48 +0000 Received: by mail-pj1-x1044.google.com with SMTP id d8so7281337pje.4 for ; Sun, 15 Mar 2020 12:16:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DnIYVnf76ZNYZmrCVx2GCWCcgip2tcoobJFeUKy9s0c=; b=cBdghDbSno8+tc3fAGbBrhpYDRGvvF6/pdJn7N2K5P+DXxpLN45Nid6Vo4hmYqvNg+ uYJFLF8ZAs5J6RDOlKufIch4Ui9XNGkccMZhf7egBfA7UKMZHiOWMWgqG23xwi0qN1Hx RFKXy/pE735kBc/VjIbUlkNBqujo/vhgTit0V+HfRxadiEDHeRHjLBr09SdWfz4XiYhc yhaWrtu6L8+dWcrMPz4kUD2Io3eOB9FiYYW4dTkSSYz3NCtaqS2Lp8XiQgMXSiXwokxr ZBxry4sS7FRqxEghb0EqCs29YR7cor2vscxDCVmpV+Av4a4PPwpxA1x3O+BYu0wshOMF h3zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DnIYVnf76ZNYZmrCVx2GCWCcgip2tcoobJFeUKy9s0c=; b=m0xGPDjrcN82mmJO2iZqhsez/jSm+51URTMNUFidsiL9KR5x6sl0nkqrX8cG9GcoOz fzS5FdLqSBAqbJ05N1dyERnfTeoOwptFIg70n2PwGUadq63Z21EuE+RcP37UNSrwxOCS C2o9bJf9j5bksLBQwBikVM9hG1QNK9Py90vw6I6zhcoVBl9M0QBk3wgpZbYwpKW9iARx oI4orIDPxaTuyl7hr3Vmcnm6GI9YS4OyfGaQ6n/7TcFcb/QrAHf6QSvYpvgLL2P5QMrv /Bg+YA1Nz8qKXb8R9cPrNDIjiDc0/aIN5ZjFPLXYnhapiV5P9D0/803IeAVldTtCyW+s vBfw== X-Gm-Message-State: ANhLgQ08nKBJ0kGFmw6sszqDr2lb+y23d00F4VYBsazShmAPHWeDYsji 7XRK7EOKDAiNJjm3aFXalG8= X-Google-Smtp-Source: ADFU+vuho5YTWP6Ui5j7Fvi2auem5iPekXPLrXAnf6AP/wcV8sPiITmyw3QAB1hrpSgd6/bImz2nzg== X-Received: by 2002:a17:902:343:: with SMTP id 61mr23536939pld.332.1584299801405; Sun, 15 Mar 2020 12:16:41 -0700 (PDT) Received: from taoren-ubuntu-R90MNF91.thefacebook.com (c-24-4-25-55.hsd1.ca.comcast.net. [24.4.25.55]) by smtp.gmail.com with ESMTPSA id 13sm61431882pgo.13.2020.03.15.12.16.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2020 12:16:40 -0700 (PDT) From: rentao.bupt@gmail.com To: Felipe Balbi , Greg Kroah-Hartman , Joel Stanley , Andrew Jeffery , Benjamin Herrenschmidt , Chunfeng Yun , Colin Ian King , Stephen Boyd , Rob Herring , Mark Rutland , 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 Subject: [PATCH v2 1/6] usb: gadget: aspeed: support multiple language strings Date: Sun, 15 Mar 2020 12:16:27 -0700 Message-Id: <20200315191632.12536-2-rentao.bupt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200315191632.12536-1-rentao.bupt@gmail.com> References: <20200315191632.12536-1-rentao.bupt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200315_121642_516779_6F5445D9 X-CRM114-Status: GOOD ( 20.18 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1044 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [rentao.bupt[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tao Ren MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tao Ren This patch introduces a link list to store string descriptors with different languages, and "ast_vhub_rep_string" function is also improved to support multiple language usb strings. Signed-off-by: Tao Ren --- No change in v2: - the patch is added into the series since v2. drivers/usb/gadget/udc/aspeed-vhub/core.c | 4 +- drivers/usb/gadget/udc/aspeed-vhub/hub.c | 140 +++++++++++++++++++--- drivers/usb/gadget/udc/aspeed-vhub/vhub.h | 4 +- 3 files changed, 131 insertions(+), 17 deletions(-) diff --git a/drivers/usb/gadget/udc/aspeed-vhub/core.c b/drivers/usb/gadget/udc/aspeed-vhub/core.c index 555e8645fb1e..cdf96911e4b1 100644 --- a/drivers/usb/gadget/udc/aspeed-vhub/core.c +++ b/drivers/usb/gadget/udc/aspeed-vhub/core.c @@ -408,7 +408,9 @@ static int ast_vhub_probe(struct platform_device *pdev) goto err; /* Init hub emulation */ - ast_vhub_init_hub(vhub); + rc = ast_vhub_init_hub(vhub); + if (rc) + goto err; /* Initialize HW */ ast_vhub_init_hw(vhub); diff --git a/drivers/usb/gadget/udc/aspeed-vhub/hub.c b/drivers/usb/gadget/udc/aspeed-vhub/hub.c index 6e565c3dbb5b..35edf37553f0 100644 --- a/drivers/usb/gadget/udc/aspeed-vhub/hub.c +++ b/drivers/usb/gadget/udc/aspeed-vhub/hub.c @@ -50,6 +50,7 @@ #define KERNEL_VER bin2bcd(((LINUX_VERSION_CODE >> 8) & 0x0ff)) enum { + AST_VHUB_STR_INDEX_MAX = 4, AST_VHUB_STR_MANUF = 3, AST_VHUB_STR_PRODUCT = 2, AST_VHUB_STR_SERIAL = 1, @@ -310,23 +311,77 @@ static int ast_vhub_rep_desc(struct ast_vhub_ep *ep, return ast_vhub_reply(ep, NULL, len); } +static struct usb_gadget_strings* +ast_vhub_str_of_container(struct usb_gadget_string_container *container) +{ + return (struct usb_gadget_strings *)container->stash; +} + +static int ast_vhub_collect_languages(struct ast_vhub *vhub, void *buf, + size_t size) +{ + int rc, hdr_len, nlangs, max_langs; + struct usb_gadget_strings *lang_str; + struct usb_gadget_string_container *container; + struct usb_string_descriptor *sdesc = buf; + + nlangs = 0; + hdr_len = sizeof(struct usb_descriptor_header); + max_langs = (size - hdr_len) / sizeof(sdesc->wData[0]); + list_for_each_entry(container, &vhub->vhub_str_desc, list) { + if (nlangs >= max_langs) + break; + + lang_str = ast_vhub_str_of_container(container); + sdesc->wData[nlangs++] = cpu_to_le16(lang_str->language); + } + + rc = hdr_len + nlangs * sizeof(sdesc->wData[0]); + sdesc->bLength = rc; + sdesc->bDescriptorType = USB_DT_STRING; + + return rc; +} + +static struct usb_gadget_strings *ast_vhub_lookup_string(struct ast_vhub *vhub, + u16 lang_id) +{ + struct usb_gadget_strings *lang_str; + struct usb_gadget_string_container *container; + + list_for_each_entry(container, &vhub->vhub_str_desc, list) { + lang_str = ast_vhub_str_of_container(container); + if (lang_str->language == lang_id) + return lang_str; + } + + return NULL; +} + static int ast_vhub_rep_string(struct ast_vhub_ep *ep, u8 string_id, u16 lang_id, u16 len) { - int rc = usb_gadget_get_string(&ep->vhub->vhub_str_desc, - string_id, ep->buf); + int rc; + u8 buf[256]; + struct ast_vhub *vhub = ep->vhub; + struct usb_gadget_strings *lang_str; - /* - * This should never happen unless we put too big strings in - * the array above - */ - BUG_ON(rc >= AST_VHUB_EP0_MAX_PACKET); + if (string_id == 0) { + rc = ast_vhub_collect_languages(vhub, buf, sizeof(buf)); + } else { + lang_str = ast_vhub_lookup_string(vhub, lang_id); + if (!lang_str) + return std_req_stall; + + rc = usb_gadget_get_string(lang_str, string_id, buf); + } - if (rc < 0) + if (rc < 0 || rc >= AST_VHUB_EP0_MAX_PACKET) return std_req_stall; /* Shoot it from the EP buffer */ + memcpy(ep->buf, buf, rc); return ast_vhub_reply(ep, NULL, min_t(u16, rc, len)); } @@ -832,8 +887,64 @@ void ast_vhub_hub_reset(struct ast_vhub *vhub) writel(0, vhub->regs + AST_VHUB_EP1_STS_CHG); } -static void ast_vhub_init_desc(struct ast_vhub *vhub) +static struct usb_gadget_string_container* +ast_vhub_str_container_alloc(struct ast_vhub *vhub) +{ + unsigned int size; + struct usb_string *str_array; + struct usb_gadget_strings *lang_str; + struct usb_gadget_string_container *container; + + size = sizeof(*container); + size += sizeof(struct usb_gadget_strings); + size += sizeof(struct usb_string) * AST_VHUB_STR_INDEX_MAX; + container = devm_kzalloc(&vhub->pdev->dev, size, GFP_KERNEL); + if (!container) + return ERR_PTR(-ENOMEM); + + lang_str = ast_vhub_str_of_container(container); + str_array = (struct usb_string *)(lang_str + 1); + lang_str->strings = str_array; + return container; +} + +static void ast_vhub_str_deep_copy(struct usb_gadget_strings *dest, + const struct usb_gadget_strings *src) +{ + struct usb_string *src_array = src->strings; + struct usb_string *dest_array = dest->strings; + + dest->language = src->language; + if (src_array && dest_array) { + do { + *dest_array = *src_array; + dest_array++; + src_array++; + } while (src_array->s); + } +} + +static int ast_vhub_str_alloc_add(struct ast_vhub *vhub, + const struct usb_gadget_strings *src_str) { + struct usb_gadget_strings *dest_str; + struct usb_gadget_string_container *container; + + container = ast_vhub_str_container_alloc(vhub); + if (IS_ERR(container)) + return PTR_ERR(container); + + dest_str = ast_vhub_str_of_container(container); + ast_vhub_str_deep_copy(dest_str, src_str); + list_add_tail(&container->list, &vhub->vhub_str_desc); + + return 0; +} + +static int ast_vhub_init_desc(struct ast_vhub *vhub) +{ + int ret; + /* Initialize vhub Device Descriptor. */ memcpy(&vhub->vhub_dev_desc, &ast_vhub_dev_desc, sizeof(vhub->vhub_dev_desc)); @@ -848,15 +959,16 @@ static void ast_vhub_init_desc(struct ast_vhub *vhub) vhub->vhub_hub_desc.bNbrPorts = vhub->max_ports; /* Initialize vhub String Descriptors. */ - memcpy(&vhub->vhub_str_desc, &ast_vhub_strings, - sizeof(vhub->vhub_str_desc)); + INIT_LIST_HEAD(&vhub->vhub_str_desc); + ret = ast_vhub_str_alloc_add(vhub, &ast_vhub_strings); + + return ret; } -void ast_vhub_init_hub(struct ast_vhub *vhub) +int ast_vhub_init_hub(struct ast_vhub *vhub) { vhub->speed = USB_SPEED_UNKNOWN; INIT_WORK(&vhub->wake_work, ast_vhub_wake_work); - ast_vhub_init_desc(vhub); + return ast_vhub_init_desc(vhub); } - diff --git a/drivers/usb/gadget/udc/aspeed-vhub/vhub.h b/drivers/usb/gadget/udc/aspeed-vhub/vhub.h index 23a1ac91f8d2..2e5a1ef14a75 100644 --- a/drivers/usb/gadget/udc/aspeed-vhub/vhub.h +++ b/drivers/usb/gadget/udc/aspeed-vhub/vhub.h @@ -421,7 +421,7 @@ struct ast_vhub { struct usb_device_descriptor vhub_dev_desc; struct ast_vhub_full_cdesc vhub_conf_desc; struct usb_hub_descriptor vhub_hub_desc; - struct usb_gadget_strings vhub_str_desc; + struct list_head vhub_str_desc; }; /* Standard request handlers result codes */ @@ -531,7 +531,7 @@ int __ast_vhub_simple_reply(struct ast_vhub_ep *ep, int len, ...); __VA_ARGS__) /* hub.c */ -void ast_vhub_init_hub(struct ast_vhub *vhub); +int ast_vhub_init_hub(struct ast_vhub *vhub); enum std_req_rc ast_vhub_std_hub_request(struct ast_vhub_ep *ep, struct usb_ctrlrequest *crq); enum std_req_rc ast_vhub_class_hub_request(struct ast_vhub_ep *ep, From patchwork Sun Mar 15 19:16:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ren X-Patchwork-Id: 11439367 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 158DD13B1 for ; Sun, 15 Mar 2020 19:17:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AB7F620737 for ; Sun, 15 Mar 2020 19:17:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SJM8uK+9"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rjbNEwM/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB7F620737 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=pm2h8kmpsJOAKCL8wKPoX4IxUf3Qhll1cOpkhbzACMQ=; b=SJM8uK+90qzEti1bD72AoF8zsl WWu6fwE9SYaD+YNmHhEoNY5imJvMkKm2+f6rVXxkAsZV0rAjbH9kSDQVelXmsiw/OxWBhB4wf08kV mbdgqHUSsUQYvcKhLaYscmqOa/kxJ+6n7oXz8Wnc05/bH2S5c5dDSlJe1p6Sf+RG52WRm0Gr6R5dc QoD/WtdXyL3AIwjxU72ehWeKu8UVap4YNWG6oEY2quadYmNl/sdS2AdcqXAbkeHQk4Kt5wsFF42bb /To23EUGYZFz+UePL496vuSobdWqSSp8sIHA6NKU8PABDNCWeFI8dyO3AhOYv9htbsXAemeFGwuHV qwEdCa0Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDYks-0004Bv-Tc; Sun, 15 Mar 2020 19:16:58 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDYkd-0003zF-Pu for linux-arm-kernel@lists.infradead.org; Sun, 15 Mar 2020 19:16:47 +0000 Received: by mail-pl1-x641.google.com with SMTP id d9so6882268plo.11 for ; Sun, 15 Mar 2020 12:16:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5gxpV7JB+0bFUt/kU5rYLHIq/2ry55hJR4QU1nC9mRw=; b=rjbNEwM/XgZEinoND9gGIEJmVXVX0IanV6iiJpzvEKbgkrF/FYCqlwIoWUXcBa2+c/ yIYS7nZrQpACubLkCOlWVSzJcvGltPWfy6osRa8MiOCJFO74iwIYa5oAq2deqKWDAgx5 vJIwK1bDlkX8vEKx+6vXlGCoz+VaAiKCmyBGkVphf8x4yOueYmEXIfKIxNm16CN5cwv+ FN8kwokDMxYMHUGamnUhx3PK1KVr2j2v89KLITk1XOPZNqYqEZhBEkX0hDlHGROA/nV+ lztSZKFuoprzHWSvFf7mXNvbijq/sQRLZA2zHQqdbfuCJ8Bgw5MiF1ijls/NIobvhsop riIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5gxpV7JB+0bFUt/kU5rYLHIq/2ry55hJR4QU1nC9mRw=; b=q4JCniaFj7hdb8FIfAkTj4LmVJfHBWbgL0piWxlhYO4eLKpxoJhgAO3Fx8S8KJGgYX xggHop5HvQarGPXb70KQpturqBrT6vDXbVqma2JDL4CxDfSjPKHqr8HwYJrclvNb13UR bzOEK/NxDD71xmFwbW0ubPbZeDy5mUhwmyQOewNT0cuxhBjf5YPpWSUdoaqQK5nkOmN4 kYI3BFBbfeGDbv5Q8wvfmIzLH+oGn9TXxVtX1uk9llb/obt1I8Y+GMqQwS71P1UOzqz4 HXi5Y4e8ffqU6Gv/PODp+KV/k6ZxkoWokAh972F96pRWZHaG6xuYX0d11HMWccSXJ7yU 67jA== X-Gm-Message-State: ANhLgQ0CNBVfaU3ej8wd/hMeKBw08aVN5KCkULqrhfB5gBR2LRRRg29c XRRZNb9Fjcenf2/g6vH7esQ= X-Google-Smtp-Source: ADFU+vvPigWemmbDaZCwov3VlDQsV3Pr9WZu55/E9xaVXXoXBXL4qctLgdHRc/GF5GsrKHAcIT2RcA== X-Received: by 2002:a17:902:ee93:: with SMTP id a19mr11882497pld.258.1584299802773; Sun, 15 Mar 2020 12:16:42 -0700 (PDT) Received: from taoren-ubuntu-R90MNF91.thefacebook.com (c-24-4-25-55.hsd1.ca.comcast.net. [24.4.25.55]) by smtp.gmail.com with ESMTPSA id 13sm61431882pgo.13.2020.03.15.12.16.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2020 12:16:42 -0700 (PDT) From: rentao.bupt@gmail.com To: Felipe Balbi , Greg Kroah-Hartman , Joel Stanley , Andrew Jeffery , Benjamin Herrenschmidt , Chunfeng Yun , Colin Ian King , Stephen Boyd , Rob Herring , Mark Rutland , 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 Subject: [PATCH v2 2/6] usb: gadget: add "usb_validate_langid" function Date: Sun, 15 Mar 2020 12:16:28 -0700 Message-Id: <20200315191632.12536-3-rentao.bupt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200315191632.12536-1-rentao.bupt@gmail.com> References: <20200315191632.12536-1-rentao.bupt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200315_121643_871899_085A7350 X-CRM114-Status: GOOD ( 15.98 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:641 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [rentao.bupt[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tao Ren MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tao Ren The USB LANGID validation code in "check_user_usb_string" function is moved to "usb_validate_langid" function which can be used by other usb gadget drivers. Signed-off-by: Tao Ren --- No change in v2: - the patch is added into the series since v2. drivers/usb/gadget/configfs.c | 14 +------------- drivers/usb/gadget/usbstring.c | 24 ++++++++++++++++++++++++ include/linux/usb/gadget.h | 3 +++ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 32b637e3e1fa..822ef0470c5f 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -13,8 +13,6 @@ int check_user_usb_string(const char *name, struct usb_gadget_strings *stringtab_dev) { - unsigned primary_lang; - unsigned sub_lang; u16 num; int ret; @@ -22,17 +20,7 @@ int check_user_usb_string(const char *name, if (ret) return ret; - primary_lang = num & 0x3ff; - sub_lang = num >> 10; - - /* simple sanity check for valid langid */ - switch (primary_lang) { - case 0: - case 0x62 ... 0xfe: - case 0x100 ... 0x3ff: - return -EINVAL; - } - if (!sub_lang) + if (!usb_validate_langid(num)) return -EINVAL; stringtab_dev->language = num; diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c index 7c24d1ce1088..58a4d3325090 100644 --- a/drivers/usb/gadget/usbstring.c +++ b/drivers/usb/gadget/usbstring.c @@ -65,3 +65,27 @@ usb_gadget_get_string (const struct usb_gadget_strings *table, int id, u8 *buf) return buf [0]; } EXPORT_SYMBOL_GPL(usb_gadget_get_string); + +/** + * usb_validate_langid - validate usb language identifiers + * @lang: usb language identifier + * + * Returns true for valid language identifier, otherwise false. + */ +bool usb_validate_langid(u16 langid) +{ + u16 primary_lang = langid & 0x3ff; /* bit [9:0] */ + u16 sub_lang = langid >> 10; /* bit [15:10] */ + + switch (primary_lang) { + case 0: + case 0x62 ... 0xfe: + case 0x100 ... 0x3ff: + return false; + } + if (!sub_lang) + return false; + + return true; +} +EXPORT_SYMBOL_GPL(usb_validate_langid); diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 124462d65eac..1a05227bdfae 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -773,6 +773,9 @@ struct usb_gadget_string_container { /* put descriptor for string with that id into buf (buflen >= 256) */ int usb_gadget_get_string(const struct usb_gadget_strings *table, int id, u8 *buf); +/* check if the given language identifier is valid */ +bool usb_validate_langid(u16 langid); + /*-------------------------------------------------------------------------*/ /* utility to simplify managing config descriptors */ From patchwork Sun Mar 15 19:16:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ren X-Patchwork-Id: 11439379 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4CEA014B4 for ; Sun, 15 Mar 2020 19:17:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 28DC6206B1 for ; Sun, 15 Mar 2020 19:17:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="L8Hh3Aua"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RRcNDYRs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 28DC6206B1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=/19IOnfZ63p+HgdAfXWIpQfoJ4S979k85YOHndNEgBw=; b=L8Hh3Aua/dePt2m6S8LjnWqgvF DPROH+GrDTkT8hWdIHFRMEjKPeDNfgn4pLQa5SooNXed0MbIs4Eb4xOPl3AG4H1mw5M/sFvgnTMQl PrWaPv5ZzWBTFLYTSTl70jmNcbky8+fMjfndggB4C30p4RzCUbxOusXca6uhWNPoqxAfO+Iq2epwb 2ZRh0LVMAM5eNMDXMCageMNI0SXlzmtPKYH83E1jZceC1VDF6QQcoGstiB0CqZpuXnSzPhpu4hKv1 BQIOab3E+xKvwQEflAfATwRnfeFnUa89OC01EgdEo2XwsbTbbcV+2Tld+XsPcKfpCPN1ZQheEo0Uw ikLJw4kg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDYlR-0004fO-ST; Sun, 15 Mar 2020 19:17:33 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDYkf-00040K-Fk for linux-arm-kernel@lists.infradead.org; Sun, 15 Mar 2020 19:16:50 +0000 Received: by mail-pl1-x642.google.com with SMTP id ay11so6906188plb.0 for ; Sun, 15 Mar 2020 12:16:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eovzZ3kqQ8LWP7qRD6GFAmQY5h+MQlshBlGVHRZ0WS4=; b=RRcNDYRssy/5F/i6fSsXIrzZIurGe7f0t/4Mw66MPPKQffthBAgpxwOksDd9+dfgaQ he1hqnwJw8pX6Ae2IXDZ5BqhMoAP75d2X6iQ7XcyCaaxX69+gWFGmBOB0iZeLA0UVMrw hiFXCEsTh5j3aQv5+oe4hbvVchgdBGB3bKSFAQN5Da5ytD5w3yciM18yjVivsQfnPRUd 5Jlu8e4+48mHQUELnWlqVAVetxjKJ1J4pDHPgZQVE9XnBtKeAZ5lQjNlgMBAEFQaNZlM Dh5dvjE7eY+FJm9nhWYEe8pkYfHmvZB9mR2zl3De3Tn72c0ffbcD0+cI/o/MG8MxMe8c djdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eovzZ3kqQ8LWP7qRD6GFAmQY5h+MQlshBlGVHRZ0WS4=; b=Hyb73FOIdvVq7lvhP/njDDPqN1IJ5n1/T8YY+U+rM8sCaNyAW80rCuH1nfn1VFpG1C 1uwOQmm+nCYPDLrMGdvhXeHt92z8/FoDBlRMWoKk0ooz4/lAb4QNokFqC8KO8NugQzQA novVEqVw6+bB89sW4lE0B8Opq7sNVHBEMIFCZqaqUAte+zcvXbG/qHWez55m4YPtXoQL BCBflrpduAOqfFe17KaSWx+P5B9vQffUGv7JGkIMiZVDeD24mj6QCgShZgsB9xbE9gf+ OeCw5GERRgUmBkP5c+2BQKiMPnXmXRyRRgY8Vq1vldIhZ8ct/dA3zQ/d5DjUmXbdsmsk HbNg== X-Gm-Message-State: ANhLgQ1ZGN/N8ZhF5a2I7bpm0bW50wwfwqhDwiex8FdbdV10gajgm8n2 N6h7trd++RDybNYSGRayXWQ= X-Google-Smtp-Source: ADFU+vtGG84O3T3lRIFGnx5viv8DsI8lcGdsQ6bREhmqtjVIuQIaYeJAZgzlqOUyH0BhSNIlodiyAQ== X-Received: by 2002:a17:902:7c02:: with SMTP id x2mr5325875pll.30.1584299804620; Sun, 15 Mar 2020 12:16:44 -0700 (PDT) Received: from taoren-ubuntu-R90MNF91.thefacebook.com (c-24-4-25-55.hsd1.ca.comcast.net. [24.4.25.55]) by smtp.gmail.com with ESMTPSA id 13sm61431882pgo.13.2020.03.15.12.16.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2020 12:16:44 -0700 (PDT) From: rentao.bupt@gmail.com To: Felipe Balbi , Greg Kroah-Hartman , Joel Stanley , Andrew Jeffery , Benjamin Herrenschmidt , Chunfeng Yun , Colin Ian King , Stephen Boyd , Rob Herring , Mark Rutland , 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 Subject: [PATCH v2 3/6] usb: gadget: aspeed: allow to set usb strings in device tree Date: Sun, 15 Mar 2020 12:16:29 -0700 Message-Id: <20200315191632.12536-4-rentao.bupt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200315191632.12536-1-rentao.bupt@gmail.com> References: <20200315191632.12536-1-rentao.bupt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200315_121645_554531_68F2FA9D X-CRM114-Status: GOOD ( 16.87 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:642 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [rentao.bupt[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tao Ren MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tao Ren If "vhub,string-descriptor" device tree property is defined, the driver will load string descriptors from device tree; otherwise, the default string descriptors will be used. Signed-off-by: Tao Ren --- No change in v2: - the patch is added into the series since v2. drivers/usb/gadget/udc/aspeed-vhub/hub.c | 58 +++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/aspeed-vhub/hub.c b/drivers/usb/gadget/udc/aspeed-vhub/hub.c index 35edf37553f0..421631d86a17 100644 --- a/drivers/usb/gadget/udc/aspeed-vhub/hub.c +++ b/drivers/usb/gadget/udc/aspeed-vhub/hub.c @@ -941,9 +941,61 @@ static int ast_vhub_str_alloc_add(struct ast_vhub *vhub, return 0; } +static const struct { + const char *name; + u8 id; +} str_id_map[] = { + {"manufacturer", AST_VHUB_STR_MANUF}, + {"product", AST_VHUB_STR_PRODUCT}, + {"serial-number", AST_VHUB_STR_SERIAL}, + {}, +}; + +static int ast_vhub_of_parse_str_desc(struct ast_vhub *vhub, + const struct device_node *desc_np) +{ + u32 langid; + int ret = 0; + int i, offset; + const char *str; + struct device_node *child; + struct usb_string str_array[AST_VHUB_STR_INDEX_MAX]; + struct usb_gadget_strings lang_str = { + .strings = (struct usb_string *)str_array, + }; + + for_each_child_of_node(desc_np, child) { + if (of_property_read_u32(child, "reg", &langid)) + continue; /* no language identifier specified */ + + if (!usb_validate_langid(langid)) + continue; /* invalid language identifier */ + + lang_str.language = langid; + for (i = offset = 0; str_id_map[i].name; i++) { + str = of_get_property(child, str_id_map[i].name, NULL); + if (str) { + str_array[offset].s = str; + str_array[offset].id = str_id_map[i].id; + offset++; + } + } + str_array[offset].id = 0; + str_array[offset].s = NULL; + + ret = ast_vhub_str_alloc_add(vhub, &lang_str); + if (ret) + break; + } + + return ret; +} + static int ast_vhub_init_desc(struct ast_vhub *vhub) { int ret; + struct device_node *desc_np; + const struct device_node *vhub_np = vhub->pdev->dev.of_node; /* Initialize vhub Device Descriptor. */ memcpy(&vhub->vhub_dev_desc, &ast_vhub_dev_desc, @@ -960,7 +1012,11 @@ static int ast_vhub_init_desc(struct ast_vhub *vhub) /* Initialize vhub String Descriptors. */ INIT_LIST_HEAD(&vhub->vhub_str_desc); - ret = ast_vhub_str_alloc_add(vhub, &ast_vhub_strings); + desc_np = of_get_child_by_name(vhub_np, "vhub-strings"); + if (desc_np) + ret = ast_vhub_of_parse_str_desc(vhub, desc_np); + else + ret = ast_vhub_str_alloc_add(vhub, &ast_vhub_strings); return ret; } From patchwork Sun Mar 15 19:16:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ren X-Patchwork-Id: 11439381 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6CC4414B4 for ; Sun, 15 Mar 2020 19:17:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 44164206BE for ; Sun, 15 Mar 2020 19:17:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="txR1lJHW"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZyuiwfM+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44164206BE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=5SCAVeJC3oOgJxjaFyBbNLsluTOxn/bFYTNTKhEHjOA=; b=txR1lJHWTKT5pURKzyk7yiCUQW OcgqCBDpl5++81MEYL3yU8Qzs3ak+FuOZTAI7zLeXbpx1WP7jhVGwRpjSMukzotfjhxu24NyvApvH nXuWW33+HnqAzXADg1ivVCTQcTrc3V22w6G7iaf9GX2hXYiv6UqNArLyVxZA/zF3OKw9JblcN+m/u KtK9y0ji9gnd1PGRXKQthUlwNZbCDx7sXz1xUAkAU/j1D6aR8VpgictwZaxc8l+AfNDEpw9gyAY7v 3R+SvBFM3kpEyDCuGCPRmVhn93gHc8RFv3WIICvDl7FM3wSLtEqkK1nTLMbPe7bCv4MGJg2S8iBdO Y9ueQTkg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDYlh-0004v3-9M; Sun, 15 Mar 2020 19:17:49 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDYkh-00041b-9K for linux-arm-kernel@lists.infradead.org; Sun, 15 Mar 2020 19:16:50 +0000 Received: by mail-pl1-x644.google.com with SMTP id t14so6886002plr.8 for ; Sun, 15 Mar 2020 12:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HxxSTtrSU1OUBJi+Btc1qI+H62ceRlYBsDcUYNsAgNo=; b=ZyuiwfM+wsd2yK61TSSDV+f3USkgmEfbIMsJUYYfIVC8c3KUfxDklNV+sc5xGoI92Q aYJwJvwcwg7CX3P3cb28svAtzHXPL2Riv93ogQLpl19sQ1YJwt2YFv+UdRsmGn7ScnAK fF4djxEVIjoezFqgKUev9mCl3WSKcKZqOWcCRIdwLaGdUFtj0OqTLEU+I8HNmQ3ryMTb L1dvly+3xZS5sl6Qd8u38FcbsYmY9eMsbc74lTj6EunNXiof4OJDrLudwGNytTHsLSEu Xc4yT6pzYO3qBqobjN12+P4/DS112wgehF1bvbOn3k0TR0wVhWZ4BBDc0on/dmFvY793 dGqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HxxSTtrSU1OUBJi+Btc1qI+H62ceRlYBsDcUYNsAgNo=; b=H6mX0v49E8uaFL1qw2zA5aJ2jxbUbSM3I7vJmN1+G/3oYwffz6djLXj5UH618NAlr8 EeJu4/Axuirc68sFWFQfwOJ5bP1Q6PJly27UNNgRPUzpFkARAosMMzYx0RYzWndyKEo8 q/qa4lvLRms3m9FhiD6jkrfwupzEA+7uPDsiKusmPSBWgM7qFUq2mySrXSvMTcFe15OD JxlHzECpYEnQzTO5DsPM+hkmL5VZL6S+9KAfT0KUwOVs52DkjB9QCqC7CbRyKs91Zgxa T3adeRvG7KpWFTK1pmiJFk6D2Pv5pUnrMcFHzrklPE5zFr2+ExcTXDewLK1at6HLg9Nu fxrQ== X-Gm-Message-State: ANhLgQ219S3CygPtYFWr9PS9P/McZjil+KmZes0hmJmTlBiEHRjHV1QP LlTEVyIYdfsxAxYh2WOzOnG/BXlNLXM= X-Google-Smtp-Source: ADFU+vvkL4f9mQwxQwHT+G9COHjk//vx+BspxGwPvXJqnCfl+rVs7Od8EQCDULapoatPXSq7AKaI6Q== X-Received: by 2002:a17:90b:3109:: with SMTP id gc9mr7409912pjb.186.1584299806362; Sun, 15 Mar 2020 12:16:46 -0700 (PDT) Received: from taoren-ubuntu-R90MNF91.thefacebook.com (c-24-4-25-55.hsd1.ca.comcast.net. [24.4.25.55]) by smtp.gmail.com with ESMTPSA id 13sm61431882pgo.13.2020.03.15.12.16.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2020 12:16:45 -0700 (PDT) From: rentao.bupt@gmail.com To: Felipe Balbi , Greg Kroah-Hartman , Joel Stanley , Andrew Jeffery , Benjamin Herrenschmidt , Chunfeng Yun , Colin Ian King , Stephen Boyd , Rob Herring , Mark Rutland , 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 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 Message-Id: <20200315191632.12536-5-rentao.bupt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200315191632.12536-1-rentao.bupt@gmail.com> References: <20200315191632.12536-1-rentao.bupt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200315_121647_368308_2485F4B0 X-CRM114-Status: GOOD ( 11.75 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:644 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [rentao.bupt[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tao Ren MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tao Ren The patch overrides idVendor, idProduct and bcdDevice fields in vhub Device Descriptor if according device tree properties are defined. Signed-off-by: Tao Ren --- 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, From patchwork Sun Mar 15 19:16:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ren X-Patchwork-Id: 11439385 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 468C614B4 for ; Sun, 15 Mar 2020 19:18:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1AEA5206B1 for ; Sun, 15 Mar 2020 19:18:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TZ7+plhd"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hdX3ezZp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1AEA5206B1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=NW0nHO/Q2vD9y30dp3P83seMFMNZip5jTE39KWIL2ew=; b=TZ7+plhdRWsWEq/2FnCuL8lt9H duSu5slmd3Beyowy8aAZ8rvuVU3mjIm60iZ9Bqm72F3RPqSfXjQJF5xO4pqsC7pb3X4uVKQaczxGn rqkRyfTo2M7CLe515DkpfyCxvQFnEuIIqRQW1TE/jkQNX2SnBlRXZveII++vLMnVE+k8H+R9jGkk4 IczChubickEN3+xYIgkY2lq57LRSffp4aATdotD0qI+sBCbtCyJz7aE2ZA+3YF5Fk7FhLC7PeID7m vh8hFbORMPkwoP/SDTecteIr39JkEZJ0COk/d1rFwy1Lvj7yPEcF4TQC5VkQpdxTs6mJ4GMsd1h5A 4LJAlqAA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDYm8-0005NF-Ei; Sun, 15 Mar 2020 19:18:16 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDYkj-00043M-UH for linux-arm-kernel@lists.infradead.org; Sun, 15 Mar 2020 19:16:51 +0000 Received: by mail-pg1-x543.google.com with SMTP id b22so2357957pgb.6 for ; Sun, 15 Mar 2020 12:16:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3ftgzhaTcHumF1wl+zxzORyRVylT4QiROgG963NJrxE=; b=hdX3ezZpi2YDHwnAS48I6J3zhHF57KyVQEBULjcqbwkHFINN8RzdAuYHF+cUFowEes mdKXHoyh+/52Pe0RTFxqWSExz0pu/J1uqEIGvu19LZNHKRFNhFNrAjO0vGFl7ju3D8N8 77cefLPQeOOi6MRIAHATQ6Av1T4CfP7YABlRNQ3VuqYtLcHIensCUFskH3AjIFmx2/No fGKi2qeuqm79wR+0YyTzJx+aLGCbK/llUxsSLHGJ1DP2USQs7vPJ4jdTOmPbFlxHNCgo jKyeGjUFj/HvPHvWh6CeAiC2JdKCGtyNRN6JWKOVXQOdGlv8azQgRm7fvYfyDcK+L3sy iEAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3ftgzhaTcHumF1wl+zxzORyRVylT4QiROgG963NJrxE=; b=R+sr93FSyUJsBDJR3HtBpE4iYeV4bRXzG5VxZpiNe6KxO/W3upo2XJtAabmJTBnScX PAmG5L9b/jntUa9vuKvaRB7+8UHLCH6Qwzw/UqyGIUNoBg1OXbDODLmo5mgCLRWtwU1W hgGoseRVtD2sWfuJ9qi7koy/jQHMr5XUOd8Y/uPh/Ub6vLALaQX4Il3WZP5GAkB/+xH6 pMWTFqPWpeCO/wCWFSKz2AhSHiutQ2gogkSKdj28mNQF3chZi7mrJ+eCgGbxKSmcCjQM WH425AhBsZzx9aQV+ifSYPyLzX6sORdsT1gaiqZq0OckOLq3PhGtuKXaWMiU+mKFO3bD iPsQ== X-Gm-Message-State: ANhLgQ1Wh4YXsqz2+XpoQmiGkyMH+NaNWF0ebXetcdJ5sP0INA1c7goC ffko8j1ToLB4JgxXrgyAVQQ= X-Google-Smtp-Source: ADFU+vsIuGJ6NC3/lmhKrZurUH9P1d3lFbOZv5wVLK0E+vEjIvVQ8KXp+19oTFLLGwyXkL+Y/LD/kg== X-Received: by 2002:a63:3d45:: with SMTP id k66mr23203589pga.56.1584299808334; Sun, 15 Mar 2020 12:16:48 -0700 (PDT) Received: from taoren-ubuntu-R90MNF91.thefacebook.com (c-24-4-25-55.hsd1.ca.comcast.net. [24.4.25.55]) by smtp.gmail.com with ESMTPSA id 13sm61431882pgo.13.2020.03.15.12.16.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2020 12:16:47 -0700 (PDT) From: rentao.bupt@gmail.com To: Felipe Balbi , Greg Kroah-Hartman , Joel Stanley , Andrew Jeffery , Benjamin Herrenschmidt , Chunfeng Yun , Colin Ian King , Stephen Boyd , Rob Herring , Mark Rutland , 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 Subject: [PATCH v2 5/6] usb: gadget: aspeed: fixup usb1 device descriptor at init time Date: Sun, 15 Mar 2020 12:16:31 -0700 Message-Id: <20200315191632.12536-6-rentao.bupt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200315191632.12536-1-rentao.bupt@gmail.com> References: <20200315191632.12536-1-rentao.bupt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200315_121650_006436_4C7189DF X-CRM114-Status: GOOD ( 13.61 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:543 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [rentao.bupt[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tao Ren MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tao Ren This patch moves patch-usb1-dev-desc logic from get-descriptor handler to "ast_vhub_fixup_usb1_dev_desc" function so the code is executed only once (at vhub initial time). Signed-off-by: Tao Ren --- Changes in v2: - update per-vhub device descriptor instance instead of the global default descriptor. drivers/usb/gadget/udc/aspeed-vhub/hub.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/usb/gadget/udc/aspeed-vhub/hub.c b/drivers/usb/gadget/udc/aspeed-vhub/hub.c index 13fba91aad6a..6497185ec4e7 100644 --- a/drivers/usb/gadget/udc/aspeed-vhub/hub.c +++ b/drivers/usb/gadget/udc/aspeed-vhub/hub.c @@ -73,13 +73,6 @@ static const struct usb_device_descriptor ast_vhub_dev_desc = { .bNumConfigurations = 1, }; -/* Patches to the above when forcing USB1 mode */ -static void ast_vhub_patch_dev_desc_usb1(struct usb_device_descriptor *desc) -{ - desc->bcdUSB = cpu_to_le16(0x0100); - desc->bDeviceProtocol = 0; -} - /* * Configuration descriptor: same comments as above * regarding handling USB1 mode. @@ -303,10 +296,6 @@ static int ast_vhub_rep_desc(struct ast_vhub_ep *ep, if (len > dsize) len = dsize; - /* Patch it if forcing USB1 */ - if (desc_type == USB_DT_DEVICE && ep->vhub->force_usb1) - ast_vhub_patch_dev_desc_usb1(ep->buf); - /* Shoot it from the EP buffer */ return ast_vhub_reply(ep, NULL, len); } @@ -907,6 +896,12 @@ static void ast_vhub_of_parse_dev_desc(struct ast_vhub *vhub, } } +static void ast_vhub_fixup_usb1_dev_desc(struct ast_vhub *vhub) +{ + vhub->vhub_dev_desc.bcdUSB = cpu_to_le16(0x0100); + vhub->vhub_dev_desc.bDeviceProtocol = 0; +} + static struct usb_gadget_string_container* ast_vhub_str_container_alloc(struct ast_vhub *vhub) { @@ -1021,6 +1016,8 @@ static int ast_vhub_init_desc(struct ast_vhub *vhub) memcpy(&vhub->vhub_dev_desc, &ast_vhub_dev_desc, sizeof(vhub->vhub_dev_desc)); ast_vhub_of_parse_dev_desc(vhub, vhub_np); + if (vhub->force_usb1) + ast_vhub_fixup_usb1_dev_desc(vhub); /* Initialize vhub Configuration Descriptor. */ memcpy(&vhub->vhub_conf_desc, &ast_vhub_conf_desc, From patchwork Sun Mar 15 19:16:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ren X-Patchwork-Id: 11439383 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8867D13B1 for ; Sun, 15 Mar 2020 19:18:06 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5D206206B1 for ; Sun, 15 Mar 2020 19:18:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="W35JrO7G"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YLGpToUO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D206206B1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=SrJwPX2EZ0MKPt7T+RbhZXryA8uRlf6zsyp+SHmaF7Y=; b=W35JrO7GzL7wJMoX2GbsrKCH5q 6KGqBx81Ngb2lr/9i8GmG5bUwtfzM83sUNqxxrx/+I62mK5tE3XdYf/NvwekQJPQ2b6v8qoOGN/Pv 0IK1y8Ptzgu7f+9F9Em+5Qrx9xKxHpVEFXdlahr6mc3bB6MNmQCIoeke70Cg8lOtXHDcy/6AyXkdQ AFHANw8l247aI3Wqocor4qqylZ4v9FW332Pynd9byBEkVHsp9+hYXxyvNTT/I3gCcnLoMrUk/rg4o 4avP+snR8rI6wEqX+ollJjTmnHeA9GIo9fU6POXryaiyc8ZveEWJdt5qiygzKFlxeEjni6RR4tvTO iDGTqPuQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDYls-00057J-HW; Sun, 15 Mar 2020 19:18:00 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDYkk-00044v-Lf for linux-arm-kernel@lists.infradead.org; Sun, 15 Mar 2020 19:16:52 +0000 Received: by mail-pl1-x642.google.com with SMTP id t14so6886041plr.8 for ; Sun, 15 Mar 2020 12:16:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QWPsdEuJoivN766vayf9ZE52PL5bRfQfO8yDnpnpf80=; b=YLGpToUOVh3x/T3ca5Ku8LUvtlGg/mn9uDKg38pRDzUwGgZXJb8tGa0GGOPvsWFdMf mZd5tqxB422axuWgaufL7EmQEjw5RQwVD9s3NzGvyfqMA4krbmIvAClbW2HX3kKJ2JMm CVP6iXWti5VDFOYIT2elJBcf8xMrAaIg2ufWPnwKfoXTjUiM/up7rMEJYlidVPjy5UEu QyKoKUR06GJ0assWVYuG8pjwzWQ7oMkR5ldrFRSvE4KL3Bfh/aoHmVkvEixds7fQQawa rqGIrCK9BOyWlfI61kycfL7SJvjPxBdD7XNhyOwOV4TcJsZIZeobTAKULDIoXyCBZYSi pSGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QWPsdEuJoivN766vayf9ZE52PL5bRfQfO8yDnpnpf80=; b=qn7AemlSD1Nysm1M15bApAfJ8OpbHXWrtIeUxucC080Tg0wP6iJpgCnGogja+QgkvD 67dMn9MqPKv9VRvvAHEOP9pwxr205TwLY4T5+PZPCPnxs1cjbFOuyqtx4suoFyrJUkF9 v65GHBAoM9XYJEJ2udUDX82BhomnBClNExuRlz8pru27PQx/NDiBMl/dgie0l6CfnOWh 5ZCRsi2KNffz7lwH2RRTgrhvcHWAERks2C59boqwhrk1yXExugHkIZd8NdIiUIxNGriP hzZIlE7TrQGR2Y1qnaTo6GieP11sA0SOpCMlYRnnmWUmjRL20AwoJEmj1dt4O2oiMsC8 lLzw== X-Gm-Message-State: ANhLgQ11E85R20qykl1mx7cR8cwUBg7LHphAi/jXr6RD07LbyIFGwkdY PacvaHLA5J+UDbBk+5Eczjc= X-Google-Smtp-Source: ADFU+vvc/zMCOFtXWvlFmafRLLAhKGqwy8p4BQG+HR/PLdDqKpEPagGalL4+6egi+jCXG4xF5oyHvA== X-Received: by 2002:a17:90b:3742:: with SMTP id ne2mr21417380pjb.144.1584299809762; Sun, 15 Mar 2020 12:16:49 -0700 (PDT) Received: from taoren-ubuntu-R90MNF91.thefacebook.com (c-24-4-25-55.hsd1.ca.comcast.net. [24.4.25.55]) by smtp.gmail.com with ESMTPSA id 13sm61431882pgo.13.2020.03.15.12.16.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2020 12:16:49 -0700 (PDT) From: rentao.bupt@gmail.com To: Felipe Balbi , Greg Kroah-Hartman , Joel Stanley , Andrew Jeffery , Benjamin Herrenschmidt , Chunfeng Yun , Colin Ian King , Stephen Boyd , Rob Herring , Mark Rutland , 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 Subject: [PATCH v2 6/6] dt-bindings: usb: document aspeed vhub device ID/string properties Date: Sun, 15 Mar 2020 12:16:32 -0700 Message-Id: <20200315191632.12536-7-rentao.bupt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200315191632.12536-1-rentao.bupt@gmail.com> References: <20200315191632.12536-1-rentao.bupt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200315_121650_773620_062A68E7 X-CRM114-Status: GOOD ( 12.72 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:642 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [rentao.bupt[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tao Ren MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Tao Ren Update device tree binding document for aspeed vhub's device IDs and string properties. Signed-off-by: Tao Ren --- No change in v2: - the patch is added into the series since v2. .../bindings/usb/aspeed,usb-vhub.yaml | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/aspeed,usb-vhub.yaml b/Documentation/devicetree/bindings/usb/aspeed,usb-vhub.yaml index 06399ba0d9e4..5b2e8d867219 100644 --- a/Documentation/devicetree/bindings/usb/aspeed,usb-vhub.yaml +++ b/Documentation/devicetree/bindings/usb/aspeed,usb-vhub.yaml @@ -52,6 +52,59 @@ properties: minimum: 1 maximum: 21 + vhub-vendor-id: + description: vhub Vendor ID + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + - maximum: 65535 + + vhub-product-id: + description: vhub Product ID + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + - maximum: 65535 + + vhub-device-revision: + description: vhub Device Revision in binary-coded decimal + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + - maximum: 65535 + + vhub-strings: + type: object + + properties: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + patternProperties: + '^string@[0-9a-f]+$': + type: object + description: string descriptors of the specific language + + properties: + reg: + maxItems: 1 + description: 16-bit Language Identifier defined by USB-IF + + manufacturer: + description: vhub manufacturer + allOf: + - $ref: /schemas/types.yaml#/definitions/string + + product: + description: vhub product name + allOf: + - $ref: /schemas/types.yaml#/definitions/string + + serial-number: + description: vhub device serial number + allOf: + - $ref: /schemas/types.yaml#/definitions/string + required: - compatible - reg @@ -74,4 +127,19 @@ examples: aspeed,vhub-generic-endpoints = <15>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_usb2ad_default>; + + vhub-vendor-id = <0x1d6b>; + vhub-product-id = <0x0107>; + vhub-device-revision = <0x0100>; + vhub-strings { + #address-cells = <1>; + #size-cells = <0>; + + string@0409 { + reg = <0x0409>; + manufacturer = "ASPEED"; + product = "USB Virtual Hub"; + serial-number = "0000"; + }; + }; };