From patchwork Wed Jan 13 04:34:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 566817 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id E1710140BA4 for ; Wed, 13 Jan 2016 15:34:04 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 266E9A750E; Wed, 13 Jan 2016 05:34:02 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 91N_27AE6Wwp; Wed, 13 Jan 2016 05:34:01 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7C827A74D5; Wed, 13 Jan 2016 05:34:01 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 135F1A74D5 for ; Wed, 13 Jan 2016 05:33:58 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id t_KtxzAC3uJM for ; Wed, 13 Jan 2016 05:33:57 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from conuserg010-v.nifty.com (conuserg010.nifty.com [202.248.44.36]) by theia.denx.de (Postfix) with ESMTPS id 58B03A748A for ; Wed, 13 Jan 2016 05:33:53 +0100 (CET) Received: from beagle.diag.org (p14090-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.90]) (authenticated) by conuserg010-v.nifty.com with ESMTP id u0D4XNOD026369; Wed, 13 Jan 2016 13:33:23 +0900 X-Nifty-SrcIP: [153.142.97.90] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Wed, 13 Jan 2016 13:34:01 +0900 Message-Id: <1452659641-17599-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 Cc: Marek Vasut , Alexey Brodkin Subject: [U-Boot] [PATCH] usb: add clock support for generic EHCI X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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" This driver is designed so generic that clock should also be handled in a generic way. Like the one in Linux (drivers/usb/host/ehci-platform.c), get and enable clock(s) via Device Tree if present. Signed-off-by: Masahiro Yamada --- This patch depends on new features that are still under review: http://patchwork.ozlabs.org/patch/566809/ http://patchwork.ozlabs.org/patch/566812/ Please hold this one until they go in. drivers/usb/host/ehci-generic.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c index 1292caa..44bf70b 100644 --- a/drivers/usb/host/ehci-generic.c +++ b/drivers/usb/host/ehci-generic.c @@ -5,9 +5,12 @@ */ #include +#include #include #include "ehci.h" +#define EHCI_MAX_CLKS 3 + /* * Even though here we don't explicitly use "struct ehci_ctrl" * ehci_register() expects it to be the first thing that resides in @@ -15,12 +18,24 @@ */ struct generic_ehci { struct ehci_ctrl ctrl; + struct udevice *clk_devs[EHCI_MAX_CLKS]; + int clk_ids[EHCI_MAX_CLKS]; }; static int ehci_usb_probe(struct udevice *dev) { + struct generic_ehci *priv = dev_get_priv(dev); struct ehci_hccr *hccr = (struct ehci_hccr *)dev_get_addr(dev); struct ehci_hcor *hcor; + int i; + + for (i = 0; i < EHCI_MAX_CLKS; i++) { + priv->clk_ids[i] = fdt_clk_get(dev, i, &priv->clk_devs[i]); + if (priv->clk_ids[i] < 0) + break; + if (clk_enable(priv->clk_devs[i], priv->clk_ids[i])) + printf("failed to enable clock %d\n", priv->clk_ids[i]); + } hcor = (struct ehci_hcor *)((uintptr_t)hccr + HC_LENGTH(ehci_readl(&hccr->cr_capbase)));