Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp227932imu; Tue, 27 Nov 2018 11:27:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/WUxv4u5ZY2CO8GFYfYvZ7/wApNAC1BOU7hq3/VIhGsWkmohu/pyY1zoP514EWV8otQGk7T X-Received: by 2002:a63:bd51:: with SMTP id d17mr30885764pgp.443.1543346865924; Tue, 27 Nov 2018 11:27:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543346865; cv=none; d=google.com; s=arc-20160816; b=O+aYGJQB46W9dRBPOf8Ru7CepTTYA18eQ8B13DkRjX2dKj60AT7p3J8PZ3t6yPhIdb axtovdLxgiJ/0JO6mSyItj5aI9NZsA53jDgQXw0CKDjCwhZEfhWp4H5J5vGYSM59gA/A Jx4/MhAX3e04dAjHAl+OJDSOGacX/pOeRE7wTtlNXOCr5c/xhlvg3jkRlITfQxdi0gM1 k+BxQCxz1+AbtaNBGkj0UldJdr2lZRG03KqJQlZYpee2o80+8Ew3W+cy1yN9uhV97P+g rdIoCg3Mt3I3GsCEQKDxxfKhksI958fFwAEEls+/ykHoGMVGPTfJJ3JdbjmYgYQ5rcup qROA== 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=DnxBWHa73J5vaWQcZzE5XO38a5V5qJp28FTX3QntFU3eoF+iItn8+D+rSJR89HFVIc oQnGnR1bF6jAbDrdfbwCkgCjXT31xZojIoRF7u/uXcfCO/2sdfBDOpjlydV9qXlXMOMi eXI51vdSMG/cZ+Bdi7DPLjLYwpl3mtqqF8w6/q2wK3qGoB4XbwE3T7yfvkgUJwnyv7CR LVEZWE8jKHUSCihPLLLC3oShVVi2ACIR3uI8CE4g5zWCg28BZCuSMqxKo0JDO59S4FvF dMh+CVJ3NnFIJ2KfazFJdz6Wkb+10r++yWtdWNI8lrhyOPqzBQFoj2y/6GWK5xDtTUVY HDfQ== 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 s5si4560780pfi.134.2018.11.27.11.27.30; Tue, 27 Nov 2018 11:27:45 -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 S1731366AbeK1DrV (ORCPT + 99 others); Tue, 27 Nov 2018 22:47:21 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:5191 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726772AbeK1DrU (ORCPT ); Tue, 27 Nov 2018 22:47:20 -0500 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id wARGdV5t008246; Tue, 27 Nov 2018 17:48:28 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2nxw9x1d13-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 27 Nov 2018 17:48:27 +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 816C1348; Tue, 27 Nov 2018 17:47:59 +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 404EA532D; Tue, 27 Nov 2018 16:48:27 +0000 (GMT) Received: from localhost (10.75.127.44) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 27 Nov 2018 17:48:26 +0100 From: Fabrice Gasnier To: , , CC: , , , , , , , , Subject: [PATCH 2/3] mfd: syscon: Add optional clock support Date: Tue, 27 Nov 2018 17:48:16 +0100 Message-ID: <1543337297-21873-3-git-send-email-fabrice.gasnier@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1543337297-21873-1-git-send-email-fabrice.gasnier@st.com> References: <1543337297-21873-1-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG7NODE3.st.com (10.75.127.21) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-11-27_14:,, 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