From patchwork Sat Jan 26 15:42:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Cooper X-Patchwork-Id: 2049861 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 6CEB6DF23A for ; Sat, 26 Jan 2013 15:46:04 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tz7uE-00049t-TW; Sat, 26 Jan 2013 15:42:58 +0000 Received: from mho-04-ewr.mailhop.org ([204.13.248.74] helo=mho-02-ewr.mailhop.org) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Tz7uB-00049Y-Kn for linux-arm-kernel@lists.infradead.org; Sat, 26 Jan 2013 15:42:56 +0000 Received: from pool-72-84-113-162.nrflva.fios.verizon.net ([72.84.113.162] helo=titan) by mho-02-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1Tz7uA-0008ZT-6F; Sat, 26 Jan 2013 15:42:54 +0000 Received: from titan.lakedaemon.net (localhost [127.0.0.1]) by titan (Postfix) with ESMTP id 634DD3E276F; Sat, 26 Jan 2013 10:42:51 -0500 (EST) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 72.84.113.162 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX18rJEu6W0G9TGua26CgWmy5GMoCjkxgHEU= Date: Sat, 26 Jan 2013 10:42:51 -0500 From: Jason Cooper To: Andrew Lunn Subject: Re: [PATCH V3 8/8] ARM: kirkwood: mv643xx_eth dt conversion Message-ID: <20130126154251.GM1758@titan.lakedaemon.net> References: <20130126123827.GA5786@lunn.ch> <5103D103.5040409@gmail.com> <20130126134012.GE29973@lunn.ch> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130126134012.GE29973@lunn.ch> User-Agent: Mutt/1.5.20 (2009-06-14) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130126_104255_734563_B32BC5C0 X-CRM114-Status: GOOD ( 25.77 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [204.13.248.74 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: olof@lixom.net, linux-arm-kernel@lists.infradead.org, arnd@arndb.de, Sebastian Hesselbarth X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org On Sat, Jan 26, 2013 at 02:40:12PM +0100, Andrew Lunn wrote: > On Sat, Jan 26, 2013 at 01:50:11PM +0100, Sebastian Hesselbarth wrote: > > On 01/26/2013 01:38 PM, Andrew Lunn wrote: > > >>diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c > > >>index 73b76e4..7ab92e5 100644 > > >>--- a/arch/arm/mach-kirkwood/board-dt.c > > >>+++ b/arch/arm/mach-kirkwood/board-dt.c > > >>@@ -48,7 +48,7 @@ static void __init kirkwood_legacy_clk_init(void) > > >> clkspec.args_count = 1; > > >> > > >> clkspec.args[0] = CGC_BIT_GE0; > > >>- orion_clkdev_add(NULL, "mv643xx_eth_port.0", > > >>+ orion_clkdev_add(NULL, "f1072000.egiga0", > > >> of_clk_get_from_provider(&clkspec)); > > >> > > >> clkspec.args[0] = CGC_BIT_PEX0; > > >>@@ -60,7 +60,7 @@ static void __init kirkwood_legacy_clk_init(void) > > >> of_clk_get_from_provider(&clkspec)); > > >> > > >> clkspec.args[0] = CGC_BIT_GE1; > > >>- orion_clkdev_add(NULL, "mv643xx_eth_port.1", > > >>+ orion_clkdev_add(NULL, "f1076000.egiga1", > > >> of_clk_get_from_provider(&clkspec)); > > >> } > > >> > > >These changes break any platform not yet converted, eg my QNAP box now > > >locks up solid. > > > > > >Something is not right here, or i'm not understanding something. DT > > >devices should not need code like this, only devices not yet using > > >DT.... > > > > Jason, Andrew, > > > > have a look at dove_legacy_clk_init() in arch/arm/mach-dove/common.c. > > This is how I handled non-DT clock aliases from DT provided clocks. > > Maybe you can also use it for kirkwood. > > Hi Sebastian > > The code here is based on dove_legacy_clk_init(). However the change > made by Jason is in order to make a DT device work, not an non-DT > device. > > The problem is the way the driver is getting the clock. > > mp->clk = clk_get(&pdev->dev, (pdev->id ? "1" : "0")); > > clk_get() then calls > > clk = of_clk_get_by_name(dev->of_node, con_id); > > * of_clk_get_by_name() - Parse and lookup a clock referenced by a device node > * @np: pointer to clock consumer node > * @name: name of consumer's clock input, or NULL for the first clock reference > > So it is looking for a clock called "0" or "1" in the node. This does > not exist, and so it falls. Jason's change then comes into affect and > it finds the clkdev entries added above. Exactly. > I will change the driver to use of_clk_get() when passed an np. something like this? (on top of this series): btw - I just booted this and it is working... $ cat ge0/clk_prepare_count 1 $ cat ge1/clk_prepare_count 1 $ --8<------- diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c index 7ab92e5..620c99f 100644 --- a/arch/arm/mach-kirkwood/board-dt.c +++ b/arch/arm/mach-kirkwood/board-dt.c @@ -47,10 +47,6 @@ static void __init kirkwood_legacy_clk_init(void) clkspec.np = np; clkspec.args_count = 1; - clkspec.args[0] = CGC_BIT_GE0; - orion_clkdev_add(NULL, "f1072000.egiga0", - of_clk_get_from_provider(&clkspec)); - clkspec.args[0] = CGC_BIT_PEX0; orion_clkdev_add("0", "pcie", of_clk_get_from_provider(&clkspec)); @@ -58,10 +54,6 @@ static void __init kirkwood_legacy_clk_init(void) clkspec.args[0] = CGC_BIT_PEX1; orion_clkdev_add("1", "pcie", of_clk_get_from_provider(&clkspec)); - - clkspec.args[0] = CGC_BIT_GE1; - orion_clkdev_add(NULL, "f1076000.egiga1", - of_clk_get_from_provider(&clkspec)); } static void __init kirkwood_of_clk_init(void) diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c index 7048d7c..8fb92d4 100644 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c @@ -2895,6 +2895,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev) if (pdev->dev.of_node) { struct device_node *np = NULL; + struct clk *clk = NULL; /* when all users of this driver use FDT, we can remove this */ pd = kzalloc(sizeof(*pd), GFP_KERNEL); @@ -2912,6 +2913,12 @@ static int mv643xx_eth_probe(struct platform_device *pdev) else pd->phy_addr = MV643XX_ETH_PHY_ADDR_DEFAULT; + clk = of_clk_get(pdev->dev.of_node, 0); + if (!IS_ERR(clk)) { + clk_prepare_enable(clk); + clk_put(clk); + } + np = of_parse_phandle(pdev->dev.of_node, "mdio", 0); if (np) { pd->shared = of_find_device_by_node(np);