From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 04/33] net fec: do not depend on grouped clocks
Date: Wed, 25 Apr 2012 17:27:54 +0200 [thread overview]
Message-ID: <1335367703-19929-5-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1335367703-19929-1-git-send-email-s.hauer@pengutronix.de>
the current i.MX clock support groups together unrelated clocks
to a single clock which is then used by the driver. This can't
be accomplished with the generic clock framework so we instead
request the individual clocks in the driver. For i.MX there are
generally three different clocks:
ipg: bus clock (needed to access registers)
ahb: dma relevant clock, sometimes referred to as hclk in the datasheet
per: bit clock, pixel clock
This patch changes the driver to request the individual clocks.
Currently all clk_get will get the same clock until the SoCs
are converted to the generic clock framework
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/ethernet/freescale/fec.c | 35 ++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index a12b3f5..b249463 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -206,7 +206,8 @@ struct fec_enet_private {
struct net_device *netdev;
- struct clk *clk;
+ struct clk *clk_ipg;
+ struct clk *clk_ahb;
/* The saved address of a sent-in-place packet/buffer, for skfree(). */
unsigned char *tx_bounce[TX_RING_SIZE];
@@ -1064,7 +1065,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
* Reference Manual has an error on this, and gets fixed on i.MX6Q
* document.
*/
- fep->phy_speed = DIV_ROUND_UP(clk_get_rate(fep->clk), 5000000);
+ fep->phy_speed = DIV_ROUND_UP(clk_get_rate(fep->clk_ahb), 5000000);
if (id_entry->driver_data & FEC_QUIRK_ENET_MAC)
fep->phy_speed--;
fep->phy_speed <<= 1;
@@ -1609,12 +1610,20 @@ fec_probe(struct platform_device *pdev)
}
}
- fep->clk = clk_get(&pdev->dev, NULL);
- if (IS_ERR(fep->clk)) {
- ret = PTR_ERR(fep->clk);
+ fep->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+ if (IS_ERR(fep->clk_ipg)) {
+ ret = PTR_ERR(fep->clk_ipg);
goto failed_clk;
}
- clk_prepare_enable(fep->clk);
+
+ fep->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
+ if (IS_ERR(fep->clk_ahb)) {
+ ret = PTR_ERR(fep->clk_ahb);
+ goto failed_clk;
+ }
+
+ clk_prepare_enable(fep->clk_ahb);
+ clk_prepare_enable(fep->clk_ipg);
ret = fec_enet_init(ndev);
if (ret)
@@ -1637,8 +1646,8 @@ failed_register:
fec_enet_mii_remove(fep);
failed_mii_init:
failed_init:
- clk_disable_unprepare(fep->clk);
- clk_put(fep->clk);
+ clk_disable_unprepare(fep->clk_ahb);
+ clk_disable_unprepare(fep->clk_ipg);
failed_clk:
for (i = 0; i < FEC_IRQ_NUM; i++) {
irq = platform_get_irq(pdev, i);
@@ -1670,8 +1679,8 @@ fec_drv_remove(struct platform_device *pdev)
if (irq > 0)
free_irq(irq, ndev);
}
- clk_disable_unprepare(fep->clk);
- clk_put(fep->clk);
+ clk_disable_unprepare(fep->clk_ahb);
+ clk_disable_unprepare(fep->clk_ipg);
iounmap(fep->hwp);
free_netdev(ndev);
@@ -1695,7 +1704,8 @@ fec_suspend(struct device *dev)
fec_stop(ndev);
netif_device_detach(ndev);
}
- clk_disable_unprepare(fep->clk);
+ clk_disable_unprepare(fep->clk_ahb);
+ clk_disable_unprepare(fep->clk_ipg);
return 0;
}
@@ -1706,7 +1716,8 @@ fec_resume(struct device *dev)
struct net_device *ndev = dev_get_drvdata(dev);
struct fec_enet_private *fep = netdev_priv(ndev);
- clk_prepare_enable(fep->clk);
+ clk_prepare_enable(fep->clk_ahb);
+ clk_prepare_enable(fep->clk_ipg);
if (netif_running(ndev)) {
fec_restart(ndev, fep->full_duplex);
netif_device_attach(ndev);
--
1.7.10
next prev parent reply other threads:[~2012-04-25 15:27 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-25 15:27 [PATCH v2] Convert i.MX architecture to generic clock framework Sascha Hauer
2012-04-25 15:27 ` [PATCH 01/33] dmaengine i.MX SDMA: do not depend on grouped clocks Sascha Hauer
2012-04-25 15:27 ` [PATCH 02/33] spi i.MX: " Sascha Hauer
2012-04-25 15:27 ` [PATCH 03/33] video imxfb: " Sascha Hauer
2012-04-25 15:27 ` Sascha Hauer [this message]
2012-04-25 15:27 ` [PATCH 05/33] mmc mxcmmc: " Sascha Hauer
2012-04-25 15:27 ` [PATCH 06/33] mmc sdhc i.MX: " Sascha Hauer
2012-04-25 15:27 ` [PATCH 07/33] serial " Sascha Hauer
2012-04-25 15:27 ` [PATCH 08/33] mtd mxc_nand: prepare/unprepare clock Sascha Hauer
2012-04-25 15:27 ` [PATCH 09/33] USB ehci mxc: " Sascha Hauer
2012-04-25 15:28 ` [PATCH 10/33] USB ehci mxc: sanitize clock handling Sascha Hauer
2012-04-25 15:28 ` [PATCH 11/33] w1 i.MX: prepare/unprepare clock Sascha Hauer
2012-04-25 15:28 ` [PATCH 12/33] watchdog imx2: prepare clk before enabling it Sascha Hauer
2012-04-25 15:28 ` [PATCH 13/33] media mx3 camera: " Sascha Hauer
2012-04-25 15:28 ` [PATCH 14/33] dmaengine i.MX ipu: clk_prepare/unprepare clock Sascha Hauer
2012-04-25 15:28 ` [PATCH 15/33] rtc: imx dryice: Add missing clk_prepare Sascha Hauer
2012-04-25 15:28 ` [PATCH 16/33] ARM i.MX5: prepare gpc_dvfs_clk Sascha Hauer
2012-04-25 15:28 ` [PATCH 17/33] ARM i.MX timer: request correct clock Sascha Hauer
2012-04-25 15:28 ` [PATCH 18/33] ARM i.MX3: Make ccm base address a variable Sascha Hauer
2012-04-25 15:28 ` [PATCH 19/33] ARM i.MX: prepare for common clock framework Sascha Hauer
2012-04-27 6:40 ` Shawn Guo
2012-04-27 7:16 ` Sascha Hauer
2012-04-27 7:55 ` Shawn Guo
2012-04-27 8:09 ` Sascha Hauer
2012-04-25 15:28 ` [PATCH 20/33] ARM i.MX: Add common clock support for pllv1 Sascha Hauer
2012-04-25 15:28 ` [PATCH 21/33] ARM i.MX: Add common clock support for pllv2 Sascha Hauer
2012-04-25 15:28 ` [PATCH 22/33] ARM: imx: add common clock support for pllv3 Sascha Hauer
2012-04-27 6:21 ` Shawn Guo
2012-04-27 6:32 ` Sascha Hauer
2012-04-27 6:45 ` Shawn Guo
2012-04-25 15:28 ` [PATCH 23/33] ARM i.MX: Add common clock support for 2bit gate Sascha Hauer
2012-04-25 15:28 ` [PATCH 24/33] ARM: imx: add common clock support for pfd Sascha Hauer
2012-04-25 15:28 ` [PATCH 25/33] ARM: imx: add common clock support for clk busy Sascha Hauer
2012-04-25 15:28 ` [PATCH 26/33] ARM i.MX25: implement clocks using common clock framework Sascha Hauer
2012-04-25 15:28 ` [PATCH 27/33] ARM i.MX1: " Sascha Hauer
2012-04-25 15:28 ` [PATCH 28/33] ARM i.MX21: " Sascha Hauer
2012-04-25 15:28 ` [PATCH 29/33] ARM i.MX27: " Sascha Hauer
2012-04-25 15:28 ` [PATCH 30/33] ARM i.MX31: " Sascha Hauer
2012-04-25 15:28 ` [PATCH 31/33] ARM i.MX5: " Sascha Hauer
2012-04-26 12:48 ` Heiko Stübner
2012-04-26 13:02 ` Sascha Hauer
2012-04-26 14:21 ` Heiko Stübner
2012-05-03 3:21 ` Shawn Guo
2012-05-03 6:35 ` Sascha Hauer
2012-04-25 15:28 ` [PATCH 32/33] ARM i.MX35: " Sascha Hauer
2012-04-25 15:28 ` [PATCH 33/33] ARM: i.MX6: " Sascha Hauer
2012-04-26 2:48 ` Richard Zhao
2012-04-26 6:41 ` Sascha Hauer
2012-04-26 6:57 ` Richard Zhao
2012-04-26 7:14 ` Sascha Hauer
2012-04-26 8:04 ` Sascha Hauer
2012-04-26 9:27 ` Richard Zhao
2012-04-26 7:58 ` Shawn Guo
2012-04-26 9:30 ` Richard Zhao
2012-04-26 7:42 ` Shawn Guo
2012-04-26 9:37 ` Richard Zhao
2012-04-26 14:06 ` [PATCH v2] Convert i.MX architecture to generic " Dirk Behme
2012-04-26 14:25 ` Sascha Hauer
2012-04-27 2:28 ` Shawn Guo
2012-04-27 6:32 ` Dirk Behme
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1335367703-19929-5-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).