From patchwork Mon Aug 29 18:22:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9304317 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 0795C601C0 for ; Mon, 29 Aug 2016 18:23:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF6E228751 for ; Mon, 29 Aug 2016 18:23:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1D0028954; Mon, 29 Aug 2016 18:23:52 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8FC1728751 for ; Mon, 29 Aug 2016 18:23:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1beRCX-0006MW-9B; Mon, 29 Aug 2016 18:22:29 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1beRCR-0006I2-Oc for linux-arm-kernel@lists.infradead.org; Mon, 29 Aug 2016 18:22:24 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4A3E661DAB; Mon, 29 Aug 2016 18:22:03 +0000 (UTC) Received: from localhost (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: sboyd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4442561DA4; Mon, 29 Aug 2016 18:22:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org 4442561DA4 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=sboyd@codeaurora.org Date: Mon, 29 Aug 2016 11:22:00 -0700 From: Stephen Boyd To: Masahiro Yamada Subject: Re: [PATCH v6 1/2] clk: uniphier: add core support code for UniPhier clock driver Message-ID: <20160829182200.GD19826@codeaurora.org> References: <1470112223-24835-1-git-send-email-yamada.masahiro@socionext.com> <1470112223-24835-2-git-send-email-yamada.masahiro@socionext.com> <20160819002507.GS361@codeaurora.org> <20160819191612.GU361@codeaurora.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160829_112223_869297_538EF3CB X-CRM114-Status: GOOD ( 24.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , Michael Turquette , Linux Kernel Mailing List , "David S. Miller" , Geert Uytterhoeven , Guenter Roeck , Andrew Morton , linux-clk , linux-arm-kernel Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On 08/29, Masahiro Yamada wrote: > Hi Stephen, > > > 2016-08-20 4:16 GMT+09:00 Stephen Boyd : > >> > >> >> + > >> >> + parent = of_get_parent(dev->of_node); /* parent should be syscon node */ > >> >> + regmap = syscon_node_to_regmap(parent); > >> >> + of_node_put(parent); > >> > > >> > devm_get_regmap(dev->parent) should work then? Why do we need to > >> > use OF APIs? > >> > >> "git grep devm_get_regmap" did not hit anything. > >> > >> Where is it defined? > >> > > > > Sorry I meant dev_get_regmap(). > > > > I tried this, but it did not work. > > To make dev_get_regmap() work, > the parent device needs to call dev_regmap_init_mmio() beforehand. > > > Since commit bdb0066df96e74a4002125467ebe459feff1ebef > (mfd: syscon: Decouple syscon interface from platform devices), > syscon_probe() is not called for platform devices, > so that never happens. > Ok. Is the syscon also a simple-mfd? It sounds like there's a device for the parent, but we've failed to attach a regmap to it. Maybe the core DT code should assign the regmap to the parent device when it creates it so that child devices don't need to know this detail? It could look for simple-mfd devices with compatible = "syscon" and then create the regmap? Here's a totally untested patch for that. ----8<---- diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index 2f2225e845ef..5f7d3f015b82 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c @@ -136,6 +136,17 @@ struct regmap *syscon_node_to_regmap(struct device_node *np) } EXPORT_SYMBOL_GPL(syscon_node_to_regmap); +int device_attach_syscon(struct device *dev) +{ + struct regmap *regmap; + + regmap = syscon_node_to_regmap(dev->of_node); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + + return regmap_attach_dev(dev, regmap, &syscon_regmap_config); +} + struct regmap *syscon_regmap_lookup_by_compatible(const char *s) { struct device_node *syscon_np; diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 8aa197691074..58a018e15006 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -25,6 +25,7 @@ #include #include #include +#include const struct of_device_id of_default_bus_match_table[] = { { .compatible = "simple-bus", }, @@ -383,7 +384,12 @@ static int of_platform_bus_create(struct device_node *bus, return 0; } + dev = of_platform_device_create_pdata(bus, bus_id, platform_data, parent); + if (of_device_is_compatible(bus, "simple-mfd") && + of_device_is_compatible(bus, "syscon")) + device_attach_syscon(&dev->dev); + if (!dev || !of_match_node(matches, bus)) return 0; diff --git a/include/linux/mfd/syscon.h b/include/linux/mfd/syscon.h index 40a76b97b7ab..e19e5d15f4e6 100644 --- a/include/linux/mfd/syscon.h +++ b/include/linux/mfd/syscon.h @@ -18,9 +18,11 @@ #include #include +struct device; struct device_node; #ifdef CONFIG_MFD_SYSCON +extern int device_attach_syscon(struct device *dev); extern struct regmap *syscon_node_to_regmap(struct device_node *np); extern struct regmap *syscon_regmap_lookup_by_compatible(const char *s); extern struct regmap *syscon_regmap_lookup_by_pdevname(const char *s); @@ -28,6 +30,11 @@ extern struct regmap *syscon_regmap_lookup_by_phandle( struct device_node *np, const char *property); #else +static inline int device_attach_syscon(struct device *dev) +{ + return 0; +} + static inline struct regmap *syscon_node_to_regmap(struct device_node *np) { return ERR_PTR(-ENOTSUPP);