From patchwork Tue May 29 12:36:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 922051 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="QtlxF483"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wCy1171Jz9s0W for ; Tue, 29 May 2018 22:40:57 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id CDF32C21D8A; Tue, 29 May 2018 12:39:24 +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=RCVD_IN_DNSWL_BLOCKED, 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 4E45CC21DB5; Tue, 29 May 2018 12:37:20 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B50A3C21E60; Tue, 29 May 2018 12:37:09 +0000 (UTC) Received: from fllnx209.ext.ti.com (fllnx209.ext.ti.com [198.47.19.16]) by lists.denx.de (Postfix) with ESMTPS id B8DCAC21E50 for ; Tue, 29 May 2018 12:37:02 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id w4TCax2e009729; Tue, 29 May 2018 07:36:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1527597419; bh=4f6OANdJ29Mai2ZI0HdE2DrjuXZx2+I4YGNhVn2Vs2Q=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=QtlxF483ZQWAsg9TbTGayV+5NflmA4GehBa7wLX1q65wAhe/bBz+vLDThoDOJ6EM8 qgujZ6/VY7EiPAjjP+fMThaQObyOyfkZ/XPEqOM1VKhC7GMxd3sMyy9p049Oso5Wx2 GBquXSTjepw80K/XXO/qcsSmoPjXY/B528ImnvIU= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w4TCaxaT016510; Tue, 29 May 2018 07:36:59 -0500 Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Tue, 29 May 2018 07:36:59 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Tue, 29 May 2018 07:36:59 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w4TCawI7000990; Tue, 29 May 2018 07:36:59 -0500 From: Jean-Jacques Hiblot To: , Date: Tue, 29 May 2018 14:36:47 +0200 Message-ID: <1527597407-27991-8-git-send-email-jjhiblot@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527597407-27991-1-git-send-email-jjhiblot@ti.com> References: <1527597407-27991-1-git-send-email-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] [PATCH v2 7/7] dwc3-generic: Add select_dr_mode operation 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" The select_dr_mode operation is executed when the glue driver is probed. The role of this optional function is to configure the operating mode of the controller at the glue level. Signed-off-by: Jean-Jacques Hiblot --- Changes in v2: None drivers/usb/dwc3/dwc3-generic.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index 2c27dbc..169188c 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -111,6 +112,12 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = { struct dwc3_glue_data { struct clk_bulk clks; struct reset_ctl_bulk resets; + fdt_addr_t regs; +}; + +struct dwc3_glue_ops { + void (*select_dr_mode)(struct udevice *dev, int index, + enum usb_dr_mode mode); }; static int dwc3_glue_bind(struct udevice *parent) @@ -206,9 +213,14 @@ static int dwc3_glue_clk_init(struct udevice *dev, static int dwc3_glue_probe(struct udevice *dev) { + struct dwc3_glue_ops *ops = (struct dwc3_glue_ops *)dev_get_driver_data(dev); struct dwc3_glue_data *glue = dev_get_platdata(dev); + struct udevice *child = NULL; + int index = 0; int ret; + glue->regs = dev_read_addr(dev); + ret = dwc3_glue_clk_init(dev, glue); if (ret) return ret; @@ -217,6 +229,20 @@ static int dwc3_glue_probe(struct udevice *dev) if (ret) return ret; + ret = device_find_first_child(dev, &child); + if (ret) + return ret; + + while (child) { + enum usb_dr_mode dr_mode; + + dr_mode = usb_get_dr_mode(dev_of_offset(child)); + device_find_next_child(&child); + if (ops && ops->select_dr_mode) + ops->select_dr_mode(dev, index, dr_mode); + index++; + } + return 0; }