From patchwork Tue Jun 6 10:31:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meng Dongyang X-Patchwork-Id: 771748 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3whnxk6G6Cz9s5L for ; Tue, 6 Jun 2017 20:30:02 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 9E0A9C21D1F; Tue, 6 Jun 2017 10:28:59 +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_NONE 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 4F8B6C21CF7; Tue, 6 Jun 2017 10:28:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 43DBAC21C81; Tue, 6 Jun 2017 10:28:30 +0000 (UTC) Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.99.141]) by lists.denx.de (Postfix) with ESMTPS id C1952C21CD2 for ; Tue, 6 Jun 2017 10:28:25 +0000 (UTC) Received: from daniel.meng?rock-chips.com (unknown [192.168.167.84]) by regular1.263xmail.com (Postfix) with ESMTP id 1DBE387; Tue, 6 Jun 2017 18:28:22 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 9A78E3C0; Tue, 6 Jun 2017 18:28:21 +0800 (CST) X-RL-SENDER: daniel.meng@rock-chips.com X-FST-TO: sjg@chromium.org X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: daniel.meng@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: daniel.meng@rock-chips.com X-DNS-TYPE: 0 Received: from unknown (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith SMTP id 275573EMB53; Tue, 06 Jun 2017 18:28:22 +0800 (CST) From: Meng Dongyang To: sjg@chromium.org, marex@denx.de, u-boot@lists.denx.de Date: Tue, 6 Jun 2017 18:31:36 +0800 Message-Id: <1496745102-28267-5-git-send-email-daniel.meng@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1496745102-28267-1-git-send-email-daniel.meng@rock-chips.com> References: <1496745102-28267-1-git-send-email-daniel.meng@rock-chips.com> Cc: frank.wang@rock-chips.com, wulf@rock-chips.com, chenjh@rock-chips.com Subject: [U-Boot] [PATCH v3 04/10] usb: host: xhci-rockchip: add support for rk3328 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add the compatible "rockchip,rk3328-xhci" in match table for rk3328 to probe xhci controller. Use fixed regulator to control the voltage of vbus and turn off vbus when usb stop. Signed-off-by: Meng Dongyang Reviewed-by: Simon Glass --- Changes in v3: None Changes in v2: - Use fixed regulator to control vbus instead of gpio drivers/usb/host/xhci-rockchip.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/usb/host/xhci-rockchip.c b/drivers/usb/host/xhci-rockchip.c index f559830..dd3bb6c 100644 --- a/drivers/usb/host/xhci-rockchip.c +++ b/drivers/usb/host/xhci-rockchip.c @@ -11,10 +11,10 @@ #include #include #include -#include #include #include #include +#include #include "xhci.h" @@ -23,7 +23,7 @@ DECLARE_GLOBAL_DATA_PTR; struct rockchip_xhci_platdata { fdt_addr_t hcd_base; fdt_addr_t phy_base; - struct gpio_desc vbus_gpio; + struct udevice *vbus_supply; }; /* @@ -66,11 +66,13 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev) return -ENXIO; } - /* Vbus gpio */ - ret = gpio_request_by_name(dev, "rockchip,vbus-gpio", 0, - &plat->vbus_gpio, GPIOD_IS_OUT); +#if defined(CONFIG_DM_USB) && defined(CONFIG_DM_REGULATOR) + /* Vbus regulator */ + ret = device_get_supply_regulator(dev, "vbus-supply", + &plat->vbus_supply); if (ret) - debug("rockchip,vbus-gpio node missing!"); + debug("Can't get vbus supply\n"); +#endif return 0; } @@ -153,9 +155,11 @@ static int xhci_usb_probe(struct udevice *dev) hcor = (struct xhci_hcor *)((uint64_t)ctx->hcd + HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase))); - /* setup the Vbus gpio here */ - if (dm_gpio_is_valid(&plat->vbus_gpio)) - dm_gpio_set_value(&plat->vbus_gpio, 1); +#if defined(CONFIG_DM_USB) && defined(CONFIG_DM_REGULATOR) + ret = regulator_set_enable(plat->vbus_supply, true); + if (ret) + debug("XHCI: Failed to enable vbus supply\n"); +#endif ret = rockchip_xhci_core_init(ctx, dev); if (ret) { @@ -168,6 +172,7 @@ static int xhci_usb_probe(struct udevice *dev) static int xhci_usb_remove(struct udevice *dev) { + struct rockchip_xhci_platdata *plat = dev_get_platdata(dev); struct rockchip_xhci *ctx = dev_get_priv(dev); int ret; @@ -178,11 +183,18 @@ static int xhci_usb_remove(struct udevice *dev) if (ret) return ret; +#if defined(CONFIG_DM_USB) && defined(CONFIG_DM_REGULATOR) + ret = regulator_set_enable(plat->vbus_supply, false); + if (ret) + debug("XHCI: Failed to disable vbus supply\n"); +#endif + return 0; } static const struct udevice_id xhci_usb_ids[] = { { .compatible = "rockchip,rk3399-xhci" }, + { .compatible = "rockchip,rk3328-xhci" }, { } }; @@ -202,6 +214,7 @@ U_BOOT_DRIVER(usb_xhci) = { static const struct udevice_id usb_phy_ids[] = { { .compatible = "rockchip,rk3399-usb3-phy" }, + { .compatible = "rockchip,rk3328-usb3-phy" }, { } };