From patchwork Fri Oct 13 10:22:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 115727 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp558300qgn; Fri, 13 Oct 2017 03:25:09 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCdYy0zVPmzGyW79oYEGZBSSccNAwc4jvj4e8voHAYkLHl5PDX7mO7ecf5Jm9UTKQhoxMbo X-Received: by 10.80.132.232 with SMTP id 95mr1524955edq.294.1507890309793; Fri, 13 Oct 2017 03:25:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507890309; cv=none; d=google.com; s=arc-20160816; b=DEdE44RuBuzGPoaq7vOnm5CtEUHWahYtzyEJ1qEZWCwGk2TMGBlD9jNzDUcHrYluc/ 3JHEBAi/h5tnrH/XXOKlO0Yif08L97eOsOQf+kOmdr7TLTE7Q+lHS0cucOr0tyXZrc/X Zn3LPaTw5B0CevhQRVnujuDZePuUvPTnPF91AjR2CmOEpQclzb+CtQzhJTHnKmba0IoQ dAxSFhfdjb6UalQfM3OwVX92auibYtGfxD3xfcwthz+5lfhhvwgG5Q1KBk4nEZiUk0f/ w7AXOn/3w17w/n4W7cwvJ3JMKaFVIFrLhBVk6fS+vbddjad+ysCiq35rZzBVzUU81vOA XniA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=fHT1z0Pq0YVRjIQtBKTDagtZ3mJKzguAiphUjdNNJJc=; b=HqvU+ePgL3aylEcuJxTomy17fE+vUEbHoMx+vfEtTyCMjKO3/SEiZDYDIje0JoCoOU NG/6wDfKFdq15GLD8rYYeVeV2wC5/wJf6Y6Lf4yq1j6kRXlXpgpHk4uJUkPPy4FwzPXA pxL+WOuMuQgxQ63hBkq8iGnVVO5J3ntEJx6uUY5UyC6MXh3evmPiwQ67ZBcy1HHG919B yHAOFqUEtXhYSTmItjhRcgmPL0FGgO0Wm7bN3P5IO4YNYY4/UASxF2k89afHHciijPEa i9AhKUxaiAv+swd7sKi7jQ723r6uFNhxbEbJAA98ftFeqdTMY/CYCibfEu+HlHhNtsV+ 779A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=PidcLzSs; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id p30si726527edb.501.2017.10.13.03.25.09; Fri, 13 Oct 2017 03:25:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=PidcLzSs; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 561A8C21F2C; Fri, 13 Oct 2017 10:23:30 +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 3A7C3C21F33; Fri, 13 Oct 2017 10:22:43 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A1A0AC21EEE; Fri, 13 Oct 2017 10:22:40 +0000 (UTC) Received: from conuserg-12.nifty.com (conuserg-12.nifty.com [210.131.2.79]) by lists.denx.de (Postfix) with ESMTPS id 9E0E8C21F03 for ; Fri, 13 Oct 2017 10:22:39 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id v9DAMGxI009903; Fri, 13 Oct 2017 19:22:24 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com v9DAMGxI009903 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1507890144; bh=F0NHNxI+x6bIbDTWi8kEerzZICIEgUz1fNqm4/vw1P4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PidcLzSsLlqGz84gumjcydX1nYA0krYKDaW4Iq9dI8YgY9C9h/mGapsWOS8mkbOdr JFttNqzPtwKHct/vPlkI6GJhXgNrpavnWkHZ7gFRcgnqVs9LtGrwVIPjrTXhk37bKN 3AUuUyYdCH+vsrKClu5MzXBrI2BemD4rokEkmq7vnObxO154o2ljaV976GxTNiCq52 YhZQ+GVqkUYIeuNomZJk2n3+WGyconrbrjhTiyLG5JwKTdGGyyHRrEmFZUtxSO1SDQ H5nR24f3O0Gh8pLehTFWwZeAiFLdM4D4NkgVgafjyNDLBUUTQQPAD8oEI22Ar8EFNe 672ycwyH6iTlw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Fri, 13 Oct 2017 19:22:04 +0900 Message-Id: <1507890129-1543-16-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507890129-1543-1-git-send-email-yamada.masahiro@socionext.com> References: <1507890129-1543-1-git-send-email-yamada.masahiro@socionext.com> Subject: [U-Boot] [PATCH 15/20] i2c: uniphier-f: use clk for enable and get_rate 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" Get clock rate from the clock driver instead of hard-coding it. Signed-off-by: Masahiro Yamada Reviewed-by: Heiko Schocher --- drivers/i2c/i2c-uniphier-f.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/i2c-uniphier-f.c b/drivers/i2c/i2c-uniphier-f.c index eb6c9f3..6f45cc5 100644 --- a/drivers/i2c/i2c-uniphier-f.c +++ b/drivers/i2c/i2c-uniphier-f.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -61,8 +62,6 @@ struct uniphier_fi2c_regs { #define I2C_BRST_RSCLO (1 << 0) /* release SCL low fixing */ }; -#define FIOCLK 50000000 - struct uniphier_fi2c_priv { struct udevice *dev; struct uniphier_fi2c_regs __iomem *regs; /* register base */ @@ -93,6 +92,8 @@ static int uniphier_fi2c_probe(struct udevice *dev) { fdt_addr_t addr; struct uniphier_fi2c_priv *priv = dev_get_priv(dev); + struct clk clk; + int ret; addr = devfdt_get_addr(dev); if (addr == FDT_ADDR_T_NONE) @@ -102,7 +103,19 @@ static int uniphier_fi2c_probe(struct udevice *dev) if (!priv->regs) return -ENOMEM; - priv->fioclk = FIOCLK; + ret = clk_get_by_index(dev, 0, &clk); + if (ret < 0) { + dev_err(dev, "failed to get clock\n"); + return ret; + } + + ret = clk_enable(&clk); + if (ret) { + dev_err(dev, "failed to enable clock\n"); + return ret; + } + + priv->fioclk = clk_get_rate(&clk); priv->dev = dev;