From patchwork Thu Jun 27 13:06:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 1123357 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="u/Ag/tko"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45ZL1B1YDXz9sCJ for ; Thu, 27 Jun 2019 23:13:02 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id D2C7EC21D56; Thu, 27 Jun 2019 13:09:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 8462BC21E12; Thu, 27 Jun 2019 13:07:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 08A98C21E16; Thu, 27 Jun 2019 13:06:55 +0000 (UTC) Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lists.denx.de (Postfix) with ESMTPS id 2352AC21E02 for ; Thu, 27 Jun 2019 13:06:52 +0000 (UTC) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id x5RD6nk8054898; Thu, 27 Jun 2019 08:06:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1561640809; bh=UuizM524yiwnlNcPbj6uRB7E3qTXwmpUCpROcUeFXnk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=u/Ag/tkohKh/8npNuDtp/sFVS67X0sVJF/xX9uD2K/974iMyTjg+dRDead3xWve86 K7vGGeh/ARYHgXoAi55xW429zwtXmJ9mQ7YZ+anEypop8ZLIpyEBUUZNk9O7TFYR71 RUnysNbEgvQa9DQXbIP2P/IJUpbXkzfmegNv039s= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x5RD6nMv124859 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 27 Jun 2019 08:06:49 -0500 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 27 Jun 2019 08:06:48 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 27 Jun 2019 08:06:48 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x5RD6l80007866; Thu, 27 Jun 2019 08:06:48 -0500 From: Jean-Jacques Hiblot To: , Date: Thu, 27 Jun 2019 15:06:24 +0200 Message-ID: <20190627130634.28166-9-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190627130634.28166-1-jjhiblot@ti.com> References: <20190627130634.28166-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [RESEND PATCH v3 08/18] usb: dwc3-generic: use platdata X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Separate platform data from the private data. This is one step toward adding host support. Signed-off-by: Jean-Jacques Hiblot --- Changes in v3: None Changes in v2: None drivers/usb/dwc3/dwc3-generic.c | 37 ++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index 406bf0b362..f29b93d191 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -22,17 +22,22 @@ #include #include +struct dwc3_generic_plat { + fdt_addr_t base; + u32 maximum_speed; + enum usb_dr_mode dr_mode; +}; + #if CONFIG_IS_ENABLED(DM_USB_GADGET) -struct dwc3_generic_peripheral { +struct dwc3_generic_priv { struct dwc3 dwc3; struct phy *phys; int num_phys; - fdt_addr_t base; }; int dm_usb_gadget_handle_interrupts(struct udevice *dev) { - struct dwc3_generic_peripheral *priv = dev_get_priv(dev); + struct dwc3_generic_priv *priv = dev_get_priv(dev); struct dwc3 *dwc3 = &priv->dwc3; dwc3_gadget_uboot_handle_interrupt(dwc3); @@ -43,14 +48,18 @@ int dm_usb_gadget_handle_interrupts(struct udevice *dev) static int dwc3_generic_peripheral_probe(struct udevice *dev) { int rc; - struct dwc3_generic_peripheral *priv = dev_get_priv(dev); + struct dwc3_generic_priv *priv = dev_get_priv(dev); + struct dwc3_generic_plat *plat = dev_get_platdata(dev); struct dwc3 *dwc3 = &priv->dwc3; + dwc3->maximum_speed = plat->maximum_speed; + dwc3->dr_mode = plat->dr_mode; + rc = dwc3_setup_phy(dev, &priv->phys, &priv->num_phys); if (rc) return rc; - dwc3->regs = map_physmem(priv->base, DWC3_OTG_REGS_END, MAP_NOCACHE); + dwc3->regs = map_physmem(plat->base, DWC3_OTG_REGS_END, MAP_NOCACHE); dwc3->regs += DWC3_GLOBALS_REGS_START; dwc3->dev = dev; @@ -65,7 +74,7 @@ static int dwc3_generic_peripheral_probe(struct udevice *dev) static int dwc3_generic_peripheral_remove(struct udevice *dev) { - struct dwc3_generic_peripheral *priv = dev_get_priv(dev); + struct dwc3_generic_priv *priv = dev_get_priv(dev); struct dwc3 *dwc3 = &priv->dwc3; dwc3_remove(dwc3); @@ -77,20 +86,19 @@ static int dwc3_generic_peripheral_remove(struct udevice *dev) static int dwc3_generic_peripheral_ofdata_to_platdata(struct udevice *dev) { - struct dwc3_generic_peripheral *priv = dev_get_priv(dev); - struct dwc3 *dwc3 = &priv->dwc3; + struct dwc3_generic_plat *plat = dev_get_platdata(dev); int node = dev_of_offset(dev); - priv->base = devfdt_get_addr(dev); + plat->base = devfdt_get_addr(dev); - dwc3->maximum_speed = usb_get_maximum_speed(node); - if (dwc3->maximum_speed == USB_SPEED_UNKNOWN) { + plat->maximum_speed = usb_get_maximum_speed(node); + if (plat->maximum_speed == USB_SPEED_UNKNOWN) { pr_err("Invalid usb maximum speed\n"); return -ENODEV; } - dwc3->dr_mode = usb_get_dr_mode(node); - if (dwc3->dr_mode == USB_DR_MODE_UNKNOWN) { + plat->dr_mode = usb_get_dr_mode(node); + if (plat->dr_mode == USB_DR_MODE_UNKNOWN) { pr_err("Invalid usb mode setup\n"); return -ENODEV; } @@ -104,7 +112,8 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = { .ofdata_to_platdata = dwc3_generic_peripheral_ofdata_to_platdata, .probe = dwc3_generic_peripheral_probe, .remove = dwc3_generic_peripheral_remove, - .priv_auto_alloc_size = sizeof(struct dwc3_generic_peripheral), + .priv_auto_alloc_size = sizeof(struct dwc3_generic_priv), + .platdata_auto_alloc_size = sizeof(struct dwc3_generic_plat), }; #endif