Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3377757imu; Mon, 7 Jan 2019 02:09:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN6pTKUnnoZpCRyFKZbivAote90oDPVRtANa8F5Sob6Lcwd5cmTVw0lrfMpD6yvUhAalSIVi X-Received: by 2002:a63:d949:: with SMTP id e9mr10470094pgj.24.1546855797176; Mon, 07 Jan 2019 02:09:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546855797; cv=none; d=google.com; s=arc-20160816; b=C/lKA5dlTFPS2TvNyfPuWAMfgZYCTKf/5Q7COjJqYp3FNqZebXV3uQHilk9oKo3+KU 0TFROBbKNZQEE9estgwod4SrK7GjGeBFoFm4vvesb1D7jmJiHlWJG+KidrFbUgBe0tm1 eUHYcm+Dvcb+D1qCNjqEoXLhXRUXTzFNk7IT/J6aujlS54f0I9ilxdJP0NPVTyXZduAl ZRlrayBfJTcus3XndnY6AU3mU5PTsX2VuP/OhxwBUiuw4/qiXIUXtYYHdHIumGuWk/nJ dhgHfufu9F0TUkQ/TY96mcM8++SLvOiCCv6dQBh7n2uCbckA5zfe/kmgT3z5ZpcRHiFa u//A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=PXsrrmvNR8CYBSr1WXUoLp97FgE8zX4jRdYb/Eoh5dk=; b=OixPoIzIMja2ikyqsBmTl0K+Nged9dhw+OQUP4c8hKXQy51y/ji0vPpEpi7UxB//3g SQnUFIhm3N3jZ3R9bEb/kQDleCC0YTUGLpqr+z+Nc4Q2AwLP7NMcwP+W/oDmrnGYbjP9 myDC8kz9iWiQHGFijkNHbqiEzPjNpb7QZXygqCIzenbSeURL2SYUDVPKkt5Y6iosQp/a U4V52P40V+uUzlv50/VbshjYeX4iXrbXWNWlVmq3RxHKx+3jRUyfu5MBlDoRtUTSfAKu 7mLOCkGswh4uvOJw/TwLflNWjSWn6nTB/DTCjEZL6e4pJRhVRU0tU021XWpDOJecO6YN bWHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 19si2295555pgq.215.2019.01.07.02.09.39; Mon, 07 Jan 2019 02:09:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726811AbfAGKIW (ORCPT + 99 others); Mon, 7 Jan 2019 05:08:22 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:22870 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726715AbfAGKIU (ORCPT ); Mon, 7 Jan 2019 05:08:20 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x07A4mRI019386; Mon, 7 Jan 2019 11:07:59 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2ptt11qy11-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 07 Jan 2019 11:07:59 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B246E3A; Mon, 7 Jan 2019 10:07:58 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node3.st.com [10.75.127.15]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8831D2A00; Mon, 7 Jan 2019 10:07:58 +0000 (GMT) Received: from localhost (10.75.127.45) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Mon, 7 Jan 2019 11:07:57 +0100 From: Fabrice Gasnier To: , CC: , , , , , , , , , Subject: [RESEND PATCH v2 2/3] mfd: syscon: Add optional clock support Date: Mon, 7 Jan 2019 11:07:44 +0100 Message-ID: <1546855665-26218-3-git-send-email-fabrice.gasnier@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1546855665-26218-1-git-send-email-fabrice.gasnier@st.com> References: <1546855665-26218-1-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG5NODE3.st.com (10.75.127.15) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-07_04:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some system control registers need to be clocked, so the registers can be accessed. Add an optional clock and attach it to regmap. Signed-off-by: Fabrice Gasnier --- drivers/mfd/syscon.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index b6d05cd..a0ba4ff 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c @@ -12,6 +12,7 @@ * (at your option) any later version. */ +#include #include #include #include @@ -45,6 +46,7 @@ struct syscon { static struct syscon *of_syscon_register(struct device_node *np) { + struct clk *clk; struct syscon *syscon; struct regmap *regmap; void __iomem *base; @@ -119,6 +121,18 @@ static struct syscon *of_syscon_register(struct device_node *np) goto err_regmap; } + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) { + ret = PTR_ERR(clk); + /* clock is optional */ + if (ret != -ENOENT) + goto err_clk; + } else { + ret = regmap_mmio_attach_clk(regmap, clk); + if (ret) + goto err_attach; + } + syscon->regmap = regmap; syscon->np = np; @@ -128,6 +142,11 @@ static struct syscon *of_syscon_register(struct device_node *np) return syscon; +err_attach: + if (!IS_ERR(clk)) + clk_put(clk); +err_clk: + regmap_exit(regmap); err_regmap: iounmap(base); err_map: -- 1.9.1