From patchwork Tue Aug 30 10:52:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 9305185 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 20BA660756 for ; Tue, 30 Aug 2016 10:55:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1085428B44 for ; Tue, 30 Aug 2016 10:55:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04B5128B7F; Tue, 30 Aug 2016 10:55:50 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham 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 6093328B44 for ; Tue, 30 Aug 2016 10:55:49 +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 1beggL-000093-AJ; Tue, 30 Aug 2016 10:54:17 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1begfG-0007id-0t for linux-arm-kernel@lists.infradead.org; Tue, 30 Aug 2016 10:53:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Date:Sender:Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References:In-Reply-To; bh=2J3lLSrjsz+cESQCPKOba/Up6NGR78fNeLJAaAjvdgI=; b=XHr/kNmONPaZ3umqZolLA1TnLaiQmwjfU9AHh0xs5u0SHzgsv7xDRpKIJ4+mGkAHtGbOQL+XafqBYqosZ1r/c5enGFeba1qJdE5M4VdAeNO+F0rd7pIJeYSn67nN3NbCIOPnaqcRwO+GtWvin57SP9Ncdx96OG9Yo8AP8YgT1RY=; Received: from e0022681537dd.dyn.armlinux.org.uk ([2002:4e20:1eda:1:222:68ff:fe15:37dd]:59322 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1beget-0004Ur-S4; Tue, 30 Aug 2016 11:52:47 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1beger-000775-Hr; Tue, 30 Aug 2016 11:52:45 +0100 In-Reply-To: <20160830105117.GM1041@n2100.armlinux.org.uk> References: <20160830105117.GM1041@n2100.armlinux.org.uk> From: Russell King To: linux-arm-kernel@lists.infradead.org,netdev@vger.kernel.org Subject: [PATCH 3/4] ARM: sa1100/neponset: add ethernet oscillator MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Tue, 30 Aug 2016 11:52:45 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160830_035310_966960_81013366 X-CRM114-Status: GOOD ( 14.14 ) 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: Nicolas Pitre 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 Add the clock structure for the external SMC91x ethernet oscillator. This oscillator has an enable signal which allows the oscillator to be placed in low power mode when not required. Signed-off-by: Russell King --- arch/arm/mach-sa1100/neponset.c | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c index bff6efdfaeaf..700659cadebb 100644 --- a/arch/arm/mach-sa1100/neponset.c +++ b/arch/arm/mach-sa1100/neponset.c @@ -1,6 +1,8 @@ /* * linux/arch/arm/mach-sa1100/neponset.c */ +#include +#include #include #include #include @@ -78,6 +80,9 @@ struct neponset_drvdata { struct platform_device *smc91x; unsigned irq_base; struct gpio_chip *gpio[4]; + struct clk_hw *enet_osc_ck; + struct clk_hw *enet_osc_gate; + struct clk_lookup *enet_osc_cl; }; static struct gpiod_lookup_table neponset_uart1_gpio_table = { @@ -217,6 +222,38 @@ static int neponset_init_gpio(struct gpio_chip **gcp, return 0; } +static int neponset_init_enet(struct device *dev, struct neponset_drvdata *d) +{ + int ret; + + d->enet_osc_ck = clk_hw_register_fixed_rate(dev, "nep_enet_osc", + NULL, 0, 20000000); + if (IS_ERR(d->enet_osc_ck)) + return PTR_ERR(d->enet_osc_ck); + + d->enet_osc_gate = clk_hw_register_gpio_gate(dev, "nep_enet_gate", + "nep_enet_osc", + d->gpio[0]->base + 3, + false, 0); + if (IS_ERR(d->enet_osc_gate)) { + ret = PTR_ERR(d->enet_osc_gate); + goto err; + } + + d->enet_osc_cl = clkdev_hw_create(d->enet_osc_gate, NULL, "smc91x.0"); + if (!d->enet_osc_cl) { + ret = -ENOMEM; + goto err; + } + + return 0; + +err: + if (d->enet_osc_ck) + clk_hw_unregister_fixed_rate(d->enet_osc_ck); + return ret; +} + static struct sa1111_platform_data sa1111_info = { .disable_devs = SA1111_DEVID_PS2_MSE, }; @@ -333,6 +370,8 @@ static int neponset_probe(struct platform_device *dev) gpiod_add_lookup_table(&neponset_uart3_gpio_table); gpiod_add_lookup_table(&neponset_pcmcia_table); + neponset_init_enet(&dev->dev, d); + /* * We would set IRQ_GPIO25 to be a wake-up IRQ, but unfortunately * something on the Neponset activates this IRQ on sleep (eth?) @@ -385,6 +424,9 @@ static int neponset_remove(struct platform_device *dev) if (!IS_ERR(d->smc91x)) platform_device_unregister(d->smc91x); + clkdev_drop(d->enet_osc_cl); + clk_hw_unregister_fixed_rate(d->enet_osc_ck); + gpiod_remove_lookup_table(&neponset_pcmcia_table); gpiod_remove_lookup_table(&neponset_uart3_gpio_table); gpiod_remove_lookup_table(&neponset_uart1_gpio_table);