From patchwork Sun Feb 19 20:35:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9581823 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 69D7F604A0 for ; Sun, 19 Feb 2017 20:36:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 599E2286C6 for ; Sun, 19 Feb 2017 20:36:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C3C82870B; Sun, 19 Feb 2017 20:36:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C09F2286C6 for ; Sun, 19 Feb 2017 20:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aycolGwQv6Pap2lscdwGXY8ZfxPQwZpv3Va2/DS7Coo=; b=Wc4gjZk7uHJl1a A/jJx7zS7C/JZTtpzhduNWmsEQRwqVOAD57Tn+whxwShen/QOZ93OTOcwtP17CP7tuQhTEnw9no0/ VinQ5kT96idZAdFmF7Td7kbvcQp5mEUB2RgNby1+ysZaQH6LLhHhlHRcACjux6sPos9YrSYavO8HN b5OAI7ykHuIuqtvMSqoOu4bOa7tKxh6w4xm7k9eC7bPnNXWLV06LN8kDsvBeNkohBfiDXnFeobK35 N5uW8QhOxE3wFH/YnouzEOm37SaJSQCyho0zyDUebaiaNP4G8WA3gRDENYFB3gYSGniB9vd/Eaf0x LexxbvND9dGiNSHevfNQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cfYDc-0000Pd-0k; Sun, 19 Feb 2017 20:36:28 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cfYDU-0000EE-Re for linux-amlogic@lists.infradead.org; Sun, 19 Feb 2017 20:36:25 +0000 Received: by mail-wm0-x241.google.com with SMTP id v77so11175237wmv.0 for ; Sun, 19 Feb 2017 12:35:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=HzxKi6djqDkz9jdJSgmkRl0Ijb7iHexbadBNgbMxVrA=; b=mqXfElSQUn9efAfuJMW+mrhb7rsUGeWdcV9N7hsryfCi84r8rO6vS9ytWt7E5hIYjX yWcXJbPzr1Bwdek8pKHNks+cp3I4DNinc1oTV87jmYm4/FZzUcdR56w0wDejSZ8tGUuY X3p9gShaCb1kxs7pcH+pNSb92rX0Y8V5biJMJJZtyLgPcjg/mdk7dbIDFu4BQggjxdBS AEHtQxqeXDt9cgcK8Uf2r1Yuf0sApWK/yehy09tIvOLGVOZQ/ydmkFElKCzjGl970d/4 3yg5b7N7971p+EUdunmkIJ79uwJwOsgdq2o2XpZ7UwPWdXMlM4KWVRPLcn2w/cM5c7kO 2AMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=HzxKi6djqDkz9jdJSgmkRl0Ijb7iHexbadBNgbMxVrA=; b=rite+M7EwwGpLr4fsGVPaR1Xyw6qlWLHm0mBTiosjMvuVcUsW2QTgiuVPUpQAiHUfz s9wEXGO70l4SzOrvTjUz0X2rsDmB5AZwrYIQl25EWjRWzDPNvTJQmYeXegGH7FboXs1S TCLkekAvGquPuzDXchQjipmKIPnExHMrUgutICxEbbThRRoEMnG2nu79mf2Uf7peYmHF GuFOJ4w1oWiScu1TEZ60/yHnJM3GvjpdgLD2HA53KYdaky1lAaFdsjBTAGX6KD4uy/Oy NcwVT7MtlBdWXUkhwveN0tzV6m1/ksMRdi1tCRCIVABmED0uYfPiEYcQ4DL6o/j9pu7M PE6g== X-Gm-Message-State: AMke39nY8aZRvAqOAtL0XgW14Pu3d/XMRknIUhhUThca5v7v2alCiw4G1CmGkpTQHrlhzQ== X-Received: by 10.28.35.142 with SMTP id j136mr14742906wmj.11.1487536556621; Sun, 19 Feb 2017 12:35:56 -0800 (PST) Received: from ?IPv6:2003:c6:ebdc:4000:b54a:e921:753c:183c? (p200300C6EBDC4000B54AE921753C183C.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:b54a:e921:753c:183c]) by smtp.googlemail.com with ESMTPSA id y97sm10709135wmh.24.2017.02.19.12.35.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Feb 2017 12:35:56 -0800 (PST) Subject: [PATCH 2/2] hwrng: meson: add clock handling to driver To: Kevin Hilman , Herbert Xu References: <00b2a4cc-686e-0cc0-43e8-552b70a1e868@gmail.com> From: Heiner Kallweit Message-ID: Date: Sun, 19 Feb 2017 21:35:52 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <00b2a4cc-686e-0cc0-43e8-552b70a1e868@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170219_123621_060020_5BC4CBD2 X-CRM114-Status: GOOD ( 10.86 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-crypto@vger.kernel.org, Neil Armstrong Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add handling of RNG0 clock to the driver. Signed-off-by: Heiner Kallweit --- drivers/char/hw_random/meson-rng.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/char/hw_random/meson-rng.c b/drivers/char/hw_random/meson-rng.c index 119d6984..1f586e48 100644 --- a/drivers/char/hw_random/meson-rng.c +++ b/drivers/char/hw_random/meson-rng.c @@ -62,6 +62,7 @@ #include #include #include +#include #define RNG_DATA 0x00 @@ -69,6 +70,7 @@ struct meson_rng_data { void __iomem *base; struct platform_device *pdev; struct hwrng rng; + struct clk *core_clk; }; static int meson_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait) @@ -86,6 +88,7 @@ static int meson_rng_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct meson_rng_data *data; struct resource *res; + int ret; data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) @@ -98,12 +101,33 @@ static int meson_rng_probe(struct platform_device *pdev) if (IS_ERR(data->base)) return PTR_ERR(data->base); + data->core_clk = devm_clk_get(dev, "core"); + if (IS_ERR(data->core_clk)) + return PTR_ERR(data->core_clk); + + ret = clk_prepare_enable(data->core_clk); + if (ret) + return ret; + data->rng.name = pdev->name; data->rng.read = meson_rng_read; platform_set_drvdata(pdev, data); - return devm_hwrng_register(dev, &data->rng); + ret = devm_hwrng_register(dev, &data->rng); + if (ret) + clk_disable_unprepare(data->core_clk); + + return ret; +} + +static int meson_rng_remove(struct platform_device *pdev) +{ + struct meson_rng_data *data = platform_get_drvdata(pdev); + + clk_disable_unprepare(data->core_clk); + + return 0; } static const struct of_device_id meson_rng_of_match[] = { @@ -114,6 +138,7 @@ MODULE_DEVICE_TABLE(of, meson_rng_of_match); static struct platform_driver meson_rng_driver = { .probe = meson_rng_probe, + .remove = meson_rng_remove, .driver = { .name = "meson-rng", .of_match_table = meson_rng_of_match,