From patchwork Tue Oct 2 11:57:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10623499 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EA95616B1 for ; Tue, 2 Oct 2018 11:58:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDBD428815 for ; Tue, 2 Oct 2018 11:58:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D17052884B; Tue, 2 Oct 2018 11:58:57 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D6B428815 for ; Tue, 2 Oct 2018 11:58:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727526AbeJBSlx (ORCPT ); Tue, 2 Oct 2018 14:41:53 -0400 Received: from mail-dm3nam03on0051.outbound.protection.outlook.com ([104.47.41.51]:20035 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727434AbeJBSlx (ORCPT ); Tue, 2 Oct 2018 14:41:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=itp/3M1YML+LgU8ljpwT1+pV8NZEDnE1/5+7wRx9sd4=; b=rk3Hk6DEe+EtlQ+WAPywRDsb7g0uhgqkTjHqoMwrsNQoKVNZMqAnbWBj+4tMrepexxGUKKZ10A3NyJDn+OyXPZYQFdKp6zoBAS/CiVULUB3e2nX7fReiVESWCz+PSJwqGACdLZt9CWYm5nI4eLo0yl6PrkCdSDfM59rFvGoTR50= Received: from BN6PR03CA0005.namprd03.prod.outlook.com (2603:10b6:404:23::15) by BL2PR03MB545.namprd03.prod.outlook.com (2a01:111:e400:c23::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.22; Tue, 2 Oct 2018 11:58:52 +0000 Received: from BN1AFFO11FD013.protection.gbl (2a01:111:f400:7c10::178) by BN6PR03CA0005.outlook.office365.com (2603:10b6:404:23::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1185.22 via Frontend Transport; Tue, 2 Oct 2018 11:58:52 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.57) smtp.mailfrom=analog.com; gmx.de; dkim=none (message not signed) header.d=none;gmx.de; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta4.analog.com; Received: from nwd2mta4.analog.com (137.71.25.57) by BN1AFFO11FD013.mail.protection.outlook.com (10.58.52.73) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1164.13 via Frontend Transport; Tue, 2 Oct 2018 11:58:52 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta4.analog.com (8.13.8/8.13.8) with ESMTP id w92BwpN2017543 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK); Tue, 2 Oct 2018 04:58:51 -0700 Received: from zeus.spd.analog.com (10.64.82.11) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.301.0; Tue, 2 Oct 2018 07:58:52 -0400 Received: from saturn.analog.com ([10.50.1.244]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id w92BwKjJ012604; Tue, 2 Oct 2018 07:58:43 -0400 From: Alexandru Ardelean To: , , , CC: , , Dragos Bogdan , Alexandru Ardelean Subject: [PATCH 3/4] staging: iio: ad5933: Use the clock framework for the external clock Date: Tue, 2 Oct 2018 14:57:59 +0300 Message-ID: <20181002115800.12399-3-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002115800.12399-1-alexandru.ardelean@analog.com> References: <20181002115800.12399-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(376002)(396003)(136003)(39860400002)(2980300002)(438002)(189003)(199004)(186003)(50466002)(6666003)(26005)(53416004)(486006)(7696005)(48376002)(110136005)(47776003)(36756003)(51416003)(77096007)(2201001)(1076002)(305945005)(7636002)(86362001)(446003)(76176011)(246002)(356003)(50226002)(106466001)(11346002)(126002)(426003)(476003)(5660300001)(2616005)(54906003)(316002)(16586007)(478600001)(8936002)(14444005)(2906002)(107886003)(336012)(4326008)(8676002)(106002)(44832011);DIR:OUT;SFP:1101;SCL:1;SRVR:BL2PR03MB545;H:nwd2mta4.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD013;1:NiKbuLHMT09rbZuhql8WfFopjSxjXb1IWLBGOsb2G3uPN5y5feM7KJe1YSsgn5hnVStFA8lYHk8CUGEayzqJawJgJJVuE0xW3NxOLZneHwi4ck2mQ6I3MQ7aKsnWWWXz X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a6e0cb43-57a4-4aa9-4420-08d6285e6bdd X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:BL2PR03MB545; X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB545;3:bTOsjitZkg783yzYm8dq7X1REf1si34jC24nhM6rrMV2l7ynJTu7V5T9A4OecV0GPjjuQKB81xXl2XzkdpxuAlLba0NsR633b1YgWv6c0oPxVZc/hJoFwnrAXN5hUfTlLE0v7Op0DSCO35+dJvOO2IxXf4jXk1lf5iwXS/YeML3CguXFUnuFp3S48Vbw48ML13yatQTzIvUGaECkrbPjOJuFd0eALLN6qxft0NkM7SQlfZjLcn4eUHwVnSTuRHfULwDyvGWG6GHFPjzAHCNsL0uk1eXBnbXveNxyLXGyZxXOpvjSQTVM/lVDH1/78RvPtWFTQDlvTgMW39MQ+1VACVtA01KYYpbqwa9X9ZNVd3o=;25:XSKdu+WxjAPM2glWHDZLRZiJv9szsME7ID88BQJhjxOC+rE21QEXNSwkV1C56TxKqsaCaD1sJRdxUFX5K+E4atXTflS/x+nerLbVBtXx6muqXG7PHwT2Z+6/UBCBEsDMt8k1fnZXAYFKwHBzDtk6LFfejqMtr+M0/D+Hc8wUT3z0Z0XLf74RD9eU7TPGJBEPdBa5HKHwtKj/AEoSdNPEvPJnuhuJntk4djZdczs3Rou/sb4tMkSC4OhvCmk7FyvE0k+Sp3ocizZnh5XM1xsWy2n+cHYVwqxEa6bzGezFAj3MkQ4GfRNYyjYoYpQ+OOQqMJT6kQBRT2pMwGBC5FVEVFV0DL/x3FpBh0GsGk9FRUk= X-MS-TrafficTypeDiagnostic: BL2PR03MB545: X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB545;31:GAALSuQPV4wuU2wexiqfRzF68IlTCzTELI4sLEBLXDmOz171oqKoJvrgwb0JH1/slZwTdWb+SxC4cMVJTBOd3bhEk8dOvIqGBqpyyi4pOhX2AJFP3xbLl9U+SlZ1DA+0cElIYv7pG2tPsMBkp+GQaPY5bSEP17x/WL2/LLA6F00hV1CjWeypm/Iv+6Tob7DrGbEa5T27ITfKdagzBYyyFnfQOfJCn91AESw1XsI/pGM=;20:U3eIhqVz3yExrlZ5iEFfNWhy28YkyYlCom1UOpXyKA5bwx6YO7nMsN37I2ewEC8dchTdQVd4KjjSTGHDZAEMEJ+ZQGOBzyfrmzmmKRm2pPrkq3IO5uZptZVHaMSkaN4EF3jxdGObIE3NhvoOCXf9HXUwsyKdO4h5hx6KhjxsRDYM4zT0QITQ34rr2lQL/5dWSXgNlJFLLTjgcNrgr4Dot/er/dRaBL3Fx7++V3P06SffWFpxvtocJ5yo7nTOeNnkDyifb+44O4a6BpSnetc73LrClq77Ds6ktXAKBIX05wvYBsAMs95H0AumHgW7Ae2iQxEGQaKtoQT1TJ7a+TZq8fdE3hzT1WsPvQ+aokndlHGx/aoP81wG1nr8ilqlST7s+Yj0IsdRWRVovnrcSHqs504jftv3w9OutuqIH9mpMsOYbqWiiGnet3BAOONlWrlqgoz/vIMrKbGuKtlELdQ2AL5DlDUXP7CWmflhvmSMR5q/oA/xcS1qV5R34ct5JXKa X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(232431446821674); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93004095)(3002001)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(201708071742011)(7699051);SRVR:BL2PR03MB545;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB545; X-Microsoft-Exchange-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q4ZfVn58fVbkcfQP1ZBMM6U8XDtSOTE1g4BwPSMdIVy4zVhZDmlnupuYQut12Pde+H0VB2bX2mgXauv1AB2HW+69l21eF6fuTt+9H+cbVwzhqPgt+RhT3RcW0WpCwn0/QhPt+BLym8fZaHD9qmobkPch2ha0LN9cgY36GHAKmHjx6tLsMDf0ULKQOFP5l3UD2nMMYhupvlOnulnqrEEbIcZZAlDhmD3edq4a15XVaTYqEQx7s1FEvq/OGo1EohqP1IIOoFdJ9w==;5:vrVYJHoAcw3fdXdN5+5tYHmMDcNm/SIYAEC1MGX99UEnSGz5ijhgwAzngRsbEm8pzO/QE4mDqEzd+iDk7BcYugXNTjgBU49oWTbWZImszMFnOEjIZDJAOScjCMJ9NOBV+b23lEXsPzczUTEnQ+2IH4r1V5K/yB8kpukmjZSjIbY=;7:cJ220M1PGSiM926vMokdG/oIGOX86UEWKKOLMlEXBb82C6P36QaEpDq+M/8m1uie6gOchgPuS7ItjIgaN31sSSox4BUXsvMw9OtxV+0klik1GC19MVc1/lHAil2shcKECEZpS1qOLWiJXVa/Fx6LB6gQ+I1lAXPbaV6gA3/SAW9Su9x38ELiDUWo36zQyZaEU4hT1XuKB244Tg4+kAkxH7oi0ddarg/LIZhT2qzHkV/X2H5D1/CVUj4xs6ykRO25 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2018 11:58:52.0111 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a6e0cb43-57a4-4aa9-4420-08d6285e6bdd X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta4.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR03MB545 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dragos Bogdan In order to add full device tree support, add the option of specifying the external clock (MCLK) using the clock framework. Signed-off-by: Dragos Bogdan Signed-off-by: Alexandru Ardelean --- .../staging/iio/impedance-analyzer/ad5933.c | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index ec54ab4471b9..04208a1df48e 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -98,6 +99,7 @@ struct ad5933_state { struct i2c_client *client; struct regulator *reg; struct regulator *vref; + struct clk *mclk; struct delayed_work work; struct mutex lock; /* Protect sensor state */ unsigned long mclk_hz; @@ -735,6 +737,19 @@ static int ad5933_probe(struct i2c_client *client, else st->vref_mv = pdata->vref_mv; + st->mclk = devm_clk_get(&client->dev, "mclk"); + if (IS_ERR(st->mclk) && PTR_ERR(st->mclk) != -ENOENT) { + ret = PTR_ERR(st->mclk); + goto error_disable_vref; + } + + if (!IS_ERR(st->mclk)) { + ret = clk_prepare_enable(st->mclk); + if (ret < 0) + goto error_disable_vref; + pdata->ext_clk_hz = clk_get_rate(st->mclk); + } + if (pdata->ext_clk_hz) { st->mclk_hz = pdata->ext_clk_hz; st->ctrl_lb = AD5933_CTRL_EXT_SYSCLK; @@ -756,7 +771,7 @@ static int ad5933_probe(struct i2c_client *client, ret = ad5933_register_ring_funcs_and_init(indio_dev); if (ret) - goto error_disable_vref; + goto error_disable_mclk; ret = ad5933_setup(st); if (ret) @@ -770,6 +785,8 @@ static int ad5933_probe(struct i2c_client *client, error_unreg_ring: iio_kfifo_free(indio_dev->buffer); +error_disable_mclk: + clk_disable_unprepare(st->mclk); error_disable_vref: regulator_disable(st->vref); error_disable_reg: @@ -787,6 +804,7 @@ static int ad5933_remove(struct i2c_client *client) iio_kfifo_free(indio_dev->buffer); regulator_disable(st->reg); regulator_disable(st->vref); + clk_disable_unprepare(st->mclk); return 0; }