Commit f4f7561e authored by Andrew Lunn's avatar Andrew Lunn Committed by Mike Turquette

ARM: Orion: SDIO: Add support for clk.

Some orion devices can gate the SDIO clock. If the clock exists,
enable/disable it as appropriate.
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Tested-by: default avatarJamie Lentin <jm@lentin.co.uk>
Signed-off-by: default avatarMike Turquette <mturquette@linaro.org>
parent 9c2bd504
...@@ -86,7 +86,7 @@ static struct clk __init *kirkwood_register_gate(const char *name, u8 bit_idx) ...@@ -86,7 +86,7 @@ static struct clk __init *kirkwood_register_gate(const char *name, u8 bit_idx)
void __init kirkwood_clk_init(void) void __init kirkwood_clk_init(void)
{ {
struct clk *runit, *ge0, *ge1, *sata0, *sata1, *usb0; struct clk *runit, *ge0, *ge1, *sata0, *sata1, *usb0, *sdio;
tclk = clk_register_fixed_rate(NULL, "tclk", NULL, tclk = clk_register_fixed_rate(NULL, "tclk", NULL,
CLK_IS_ROOT, kirkwood_tclk); CLK_IS_ROOT, kirkwood_tclk);
...@@ -97,7 +97,7 @@ void __init kirkwood_clk_init(void) ...@@ -97,7 +97,7 @@ void __init kirkwood_clk_init(void)
sata0 = kirkwood_register_gate("sata0", CGC_BIT_SATA0); sata0 = kirkwood_register_gate("sata0", CGC_BIT_SATA0);
sata1 = kirkwood_register_gate("sata1", CGC_BIT_SATA1); sata1 = kirkwood_register_gate("sata1", CGC_BIT_SATA1);
usb0 = kirkwood_register_gate("usb0", CGC_BIT_USB0); usb0 = kirkwood_register_gate("usb0", CGC_BIT_USB0);
kirkwood_register_gate("sdio", CGC_BIT_SDIO); sdio = kirkwood_register_gate("sdio", CGC_BIT_SDIO);
kirkwood_register_gate("crypto", CGC_BIT_CRYPTO); kirkwood_register_gate("crypto", CGC_BIT_CRYPTO);
kirkwood_register_gate("xor0", CGC_BIT_XOR0); kirkwood_register_gate("xor0", CGC_BIT_XOR0);
kirkwood_register_gate("xor1", CGC_BIT_XOR1); kirkwood_register_gate("xor1", CGC_BIT_XOR1);
...@@ -117,6 +117,7 @@ void __init kirkwood_clk_init(void) ...@@ -117,6 +117,7 @@ void __init kirkwood_clk_init(void)
orion_clkdev_add("1", "sata_mv.0", sata1); orion_clkdev_add("1", "sata_mv.0", sata1);
orion_clkdev_add(NULL, "orion-ehci.0", usb0); orion_clkdev_add(NULL, "orion-ehci.0", usb0);
orion_clkdev_add(NULL, "orion_nand", runit); orion_clkdev_add(NULL, "orion_nand", runit);
orion_clkdev_add(NULL, "mvsdio", sdio);
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/clk.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/mmc/host.h> #include <linux/mmc/host.h>
...@@ -51,6 +52,7 @@ struct mvsd_host { ...@@ -51,6 +52,7 @@ struct mvsd_host {
struct device *dev; struct device *dev;
struct resource *res; struct resource *res;
int irq; int irq;
struct clk *clk;
int gpio_card_detect; int gpio_card_detect;
int gpio_write_protect; int gpio_write_protect;
}; };
...@@ -770,6 +772,13 @@ static int __init mvsd_probe(struct platform_device *pdev) ...@@ -770,6 +772,13 @@ static int __init mvsd_probe(struct platform_device *pdev)
} else } else
host->irq = irq; host->irq = irq;
/* Not all platforms can gate the clock, so it is not
an error if the clock does not exists. */
host->clk = clk_get(&pdev->dev, NULL);
if (!IS_ERR(host->clk)) {
clk_prepare_enable(host->clk);
}
if (mvsd_data->gpio_card_detect) { if (mvsd_data->gpio_card_detect) {
ret = gpio_request(mvsd_data->gpio_card_detect, ret = gpio_request(mvsd_data->gpio_card_detect,
DRIVER_NAME " cd"); DRIVER_NAME " cd");
...@@ -854,6 +863,11 @@ static int __exit mvsd_remove(struct platform_device *pdev) ...@@ -854,6 +863,11 @@ static int __exit mvsd_remove(struct platform_device *pdev)
mvsd_power_down(host); mvsd_power_down(host);
iounmap(host->base); iounmap(host->base);
release_resource(host->res); release_resource(host->res);
if (!IS_ERR(host->clk)) {
clk_disable_unprepare(host->clk);
clk_put(host->clk);
}
mmc_free_host(mmc); mmc_free_host(mmc);
} }
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment