Commit 9c2bd504 authored by Andrew Lunn's avatar Andrew Lunn Committed by Mike Turquette

ARM: Orion: NAND: Add support for clk, if there is one.

Not all orion platforms can gate the clock, but if it does exist,
enable/disable it as appropriate.

v2: Fix the name of the clkdev entry.
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 8c869eda
...@@ -116,6 +116,7 @@ void __init kirkwood_clk_init(void) ...@@ -116,6 +116,7 @@ void __init kirkwood_clk_init(void)
orion_clkdev_add("0", "sata_mv.0", sata0); orion_clkdev_add("0", "sata_mv.0", sata0);
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);
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h> #include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/sizes.h> #include <asm/sizes.h>
#include <mach/hardware.h> #include <mach/hardware.h>
...@@ -77,6 +79,7 @@ static int __init orion_nand_probe(struct platform_device *pdev) ...@@ -77,6 +79,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
struct nand_chip *nc; struct nand_chip *nc;
struct orion_nand_data *board; struct orion_nand_data *board;
struct resource *res; struct resource *res;
struct clk *clk;
void __iomem *io_base; void __iomem *io_base;
int ret = 0; int ret = 0;
...@@ -123,6 +126,14 @@ static int __init orion_nand_probe(struct platform_device *pdev) ...@@ -123,6 +126,14 @@ static int __init orion_nand_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, mtd); platform_set_drvdata(pdev, mtd);
/* Not all platforms can gate the clock, so it is not
an error if the clock does not exists. */
clk = clk_get(&pdev->dev, NULL);
if (!IS_ERR(clk)) {
clk_prepare_enable(clk);
clk_put(clk);
}
if (nand_scan(mtd, 1)) { if (nand_scan(mtd, 1)) {
ret = -ENXIO; ret = -ENXIO;
goto no_dev; goto no_dev;
...@@ -151,6 +162,7 @@ static int __devexit orion_nand_remove(struct platform_device *pdev) ...@@ -151,6 +162,7 @@ static int __devexit orion_nand_remove(struct platform_device *pdev)
{ {
struct mtd_info *mtd = platform_get_drvdata(pdev); struct mtd_info *mtd = platform_get_drvdata(pdev);
struct nand_chip *nc = mtd->priv; struct nand_chip *nc = mtd->priv;
struct clk *clk;
nand_release(mtd); nand_release(mtd);
...@@ -158,6 +170,12 @@ static int __devexit orion_nand_remove(struct platform_device *pdev) ...@@ -158,6 +170,12 @@ static int __devexit orion_nand_remove(struct platform_device *pdev)
kfree(nc); kfree(nc);
clk = clk_get(&pdev->dev, NULL);
if (!IS_ERR(clk)) {
clk_disable_unprepare(clk);
clk_put(clk);
}
return 0; return 0;
} }
......
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