From patchwork Wed Feb 21 09:20:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 129002 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp409558ljc; Wed, 21 Feb 2018 01:21:32 -0800 (PST) X-Google-Smtp-Source: AH8x2269zsRNx60olfIiR8No0i0d2+EhuMd77sjQCaHmCUNjnTqIvOgxZsKLTzSyV0SUiSTwSkvU X-Received: by 10.98.111.9 with SMTP id k9mr2636250pfc.228.1519204892047; Wed, 21 Feb 2018 01:21:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519204892; cv=none; d=google.com; s=arc-20160816; b=evSzJxoQseKpvNRKUlsCV/m4/LaDQSkWHCheglwF5MTtI+9TfoM5touamkbBXzjU8y s+/+xrz/kXtVoJMad9MHOdWbeDcb1v3x6LcVj9gbuu7QjvCYVUQoIpgcuvu4ixj0IW85 r0T0rmyKdMObdBy3X2f8P4gVxAc6JQ5FthZPo34vum84wnzcuQ1r5wWwnDe2AyH9ATff kAm2emXVaM7HyBOssJWCf/+8ov6diCQb69+EZx52UOx9UZAriwZXg39s2QJxh8C33dw9 lS4jdZEmkfW0xwAgG2pOZBOM0i1poJWYDd2lLr6Tvzioy6BeFvmi7M/v+2oEHW/5+4CF iVsg== 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:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:references:in-reply-to :message-id:date:subject:to:from:delivered-to :arc-authentication-results; bh=ApxzwokqO70F374wIFMfrBvI7fHyDJ0ar6XqoxrH090=; b=k2UAPmI2z0a+VSclMtc72e495O4WXS7ZlDh1cjRYo6uYQB7Tt+bP0pNQtgWV6FbF5Y Xg3zvKXe6CJI00jT75pLIXrFqAnxBevUJv8AP/En2fHrLaCjTsJojoBQ3PpTup7B0MZs bcB6wObs45mS+FE+LIf5WPsSqYoMEFfSJT+lRmSjsjjfNKwBpMGQX14SZ7uVgu8LpuAp Y5GMX3Y9mj9FS+UoWToRLZ459MnjEv7/wM8613NIhaqj0dzjmQtqM3akqtY7SnuCFsFJ XRxLC24t14L1pd7T1Fr4MzUNBRDytct6IqAHyS5f3Aij2ySz/1/kIOkA2ty9bM4je/6P VJzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id bh5-v6si13001386plb.520.2018.02.21.01.21.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Feb 2018 01:21:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B22ED6E594; Wed, 21 Feb 2018 09:21:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by gabe.freedesktop.org (Postfix) with ESMTP id C9B486E594 for ; Wed, 21 Feb 2018 09:20:59 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 8E9B0207F7; Wed, 21 Feb 2018 10:20:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 70A9B207CB; Wed, 21 Feb 2018 10:20:39 +0100 (CET) From: Maxime Ripard To: Mark Brown , Thierry Reding , Chen-Yu Tsai , Maxime Ripard , Mark Rutland , Rob Herring Subject: [PATCH v2 01/10] regmap: mmio: Add function to attach a clock Date: Wed, 21 Feb 2018 10:20:25 +0100 Message-Id: <1155920db000d014fd1cd604ed48d1b9a8f64ac1.1519204731.git-series.maxime.ripard@bootlin.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Petazzoni , Daniel Vetter , Maxime Ripard , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Maxime Ripard regmap_init_mmio_clk allows to specify a clock that needs to be enabled while accessing the registers. However, that clock is retrieved through its clock ID, which means it will lookup that clock based on the current device that registers the regmap, and, in the DT case, will only look in that device OF node. This might be problematic if the clock to enable is stored in another node. Let's add a function that allows to attach a clock that has already been retrieved to a regmap in order to fix this. Signed-off-by: Maxime Ripard --- drivers/base/regmap/regmap-mmio.c | 24 ++++++++++++++++++++++++ include/linux/regmap.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c index 5189fd6182f6..5cadfd3394d8 100644 --- a/drivers/base/regmap/regmap-mmio.c +++ b/drivers/base/regmap/regmap-mmio.c @@ -28,6 +28,8 @@ struct regmap_mmio_context { void __iomem *regs; unsigned val_bytes; + + bool attached_clk; struct clk *clk; void (*reg_write)(struct regmap_mmio_context *ctx, @@ -363,4 +365,26 @@ struct regmap *__devm_regmap_init_mmio_clk(struct device *dev, } EXPORT_SYMBOL_GPL(__devm_regmap_init_mmio_clk); +int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk) +{ + struct regmap_mmio_context *ctx = map->bus_context; + + ctx->clk = clk; + ctx->attached_clk = true; + + return clk_prepare(ctx->clk); +} +EXPORT_SYMBOL_GPL(regmap_mmio_attach_clk); + +void regmap_mmio_detach_clk(struct regmap *map) +{ + struct regmap_mmio_context *ctx = map->bus_context; + + clk_unprepare(ctx->clk); + + ctx->attached_clk = false; + ctx->clk = NULL; +} +EXPORT_SYMBOL_GPL(regmap_mmio_detach_clk); + MODULE_LICENSE("GPL v2"); diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 6a3aeba40e9e..5f7ad0552c03 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -21,6 +21,7 @@ #include struct module; +struct clk; struct device; struct i2c_client; struct irq_domain; @@ -905,6 +906,8 @@ bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); __regmap_lockdep_wrapper(__devm_regmap_init_sdw, #config, \ sdw, config) +int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk); +void regmap_mmio_detach_clk(struct regmap *map); void regmap_exit(struct regmap *map); int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config);