Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1837862ybh; Sun, 15 Mar 2020 12:17:29 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsfp1VHxDit6j++mtoC1M0Z0MpNH5qzE2FoqdM1BV3N6hn5k5+oOGg0FZ39RW2WZik1apYa X-Received: by 2002:a05:6830:134b:: with SMTP id r11mr13926290otq.305.1584299849386; Sun, 15 Mar 2020 12:17:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584299849; cv=none; d=google.com; s=arc-20160816; b=d/NzkSt7H6DqebP3iO8wVTnrqFgU3pwsovElMRF4vhEO5N1aXFJgNHRDVDvGJsiFVK JvlDDknCBKeLwzEFc2vTTNhcL91kj9RnuD177CM4DPr/qLmp7iSpovUFv9GJ/hJvvCVg 2U5EQjvwzdkaWActcEGCJz3VoYafOscnHwg5/de+qkF86esxDUKeLuWQHEDQfzHHfJmf Ega/jNqcoB2hZuv+jjgNtUQ7u2K1NT7/cojMQH8ktIBDNmUAscEuF7KL+vYQ8nMr6ZRw xC7WLPhOlH61hk7sTCFLz1DkHj4U3zhBsAR4NZJj6XLRilgfU92upjZdciVGfLSicxHy 0SfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=HxxSTtrSU1OUBJi+Btc1qI+H62ceRlYBsDcUYNsAgNo=; b=TMt+g1jeWd8sq6S1pIXXRvWnssQ8KjxpLBb0oZhoA7XtUhZwoP1J1VLStBdGt+ds3b ecxOHSyISIkpWDaONIsdckIjEKOdWe10HCTU7UoH+c+A4zHZjlaqmYf1xWmqQ02KDjtq 37M9FkuQuhKmorV0i+PuOLk4yNPsyP97BB4i4Lgo+8w4sysIFW8WUzqS81l1ESRQfneu 3q9EjFMrDrlnipV6dvFP9xRLbZJcZeEe+gRfMhOKPR/y5O+kp42QL6kVf+KAkATqRjd1 UZkXhtMZs58jXA61+J/0olHYJBJ5xE8Xkb3K9IqAv3DOOp4yj+gkBFkivoHxHminZocN SKNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZyuiwfM+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z107si8298358otb.292.2020.03.15.12.17.17; Sun, 15 Mar 2020 12:17:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZyuiwfM+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729119AbgCOTQv (ORCPT + 99 others); Sun, 15 Mar 2020 15:16:51 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:45627 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729101AbgCOTQt (ORCPT ); Sun, 15 Mar 2020 15:16:49 -0400 Received: by mail-pl1-f196.google.com with SMTP id b22so6881097pls.12; 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=tyrbyDGascpwp+cNn55CtfOFIgkQNDqKEZLrVHQeaKbFBw8pSJ7pNE4mal/93nVBIP /Uc0sDkjMm15dKsgeEsR2tjkltwJ+/LNohnDQfdoK24QI3c24COSSlRh9xCdj1qV/Tp6 Jef7T/jWfZRlZpmfFgcthmQ4h1BZBG3aSoViD1hN7/6nuDSge6R/1xhl/LOWtD2hrlAK t7j95LEFIw0qVJ4wdC0wx9ybma4eVQied6tj9Q8D1arx9YTkWcuPJdE+r4FILmIrSmd6 KnylkqVu7O4mSNIHEnCRVx2N8ekocafZkQXtxYvP77yMjC+3rVNTZUAH/C4/+FtAqMsM FaOw== X-Gm-Message-State: ANhLgQ2BdLMZE+qeD5e9dJviIbXUn8MJU8gJoQqD5J5bFBmstInUhjSx gqtthaxpfR0XZtno7D3BVmw= 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 Cc: Tao Ren 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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, -- 2.17.1