diff options
author | Andrew Lunn <andrew@lunn.ch> | 2012-04-06 11:17:26 -0400 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2012-05-08 19:33:55 -0400 |
commit | 4574b886698dfad6209102fed6136622b5fe1c21 (patch) | |
tree | 2f1deee540c68261f4531d09337a19a130a7ea45 /drivers/spi | |
parent | 2f129bf4aab684bef1e82e747b709a5025ecb698 (diff) |
ARM: Orion: SPI: Add clk/clkdev support.
Remove now redundant tclk from SPI platform data. This makes the platform
data empty, so remove it.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Jamie Lentin <jm@lentin.co.uk>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-orion.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index e496f799b7a9..dfd04e91fa6d 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c | |||
@@ -16,8 +16,8 @@ | |||
16 | #include <linux/err.h> | 16 | #include <linux/err.h> |
17 | #include <linux/io.h> | 17 | #include <linux/io.h> |
18 | #include <linux/spi/spi.h> | 18 | #include <linux/spi/spi.h> |
19 | #include <linux/spi/orion_spi.h> | ||
20 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/clk.h> | ||
21 | #include <asm/unaligned.h> | 21 | #include <asm/unaligned.h> |
22 | 22 | ||
23 | #define DRIVER_NAME "orion_spi" | 23 | #define DRIVER_NAME "orion_spi" |
@@ -46,6 +46,7 @@ struct orion_spi { | |||
46 | unsigned int max_speed; | 46 | unsigned int max_speed; |
47 | unsigned int min_speed; | 47 | unsigned int min_speed; |
48 | struct orion_spi_info *spi_info; | 48 | struct orion_spi_info *spi_info; |
49 | struct clk *clk; | ||
49 | }; | 50 | }; |
50 | 51 | ||
51 | static struct workqueue_struct *orion_spi_wq; | 52 | static struct workqueue_struct *orion_spi_wq; |
@@ -104,7 +105,7 @@ static int orion_spi_baudrate_set(struct spi_device *spi, unsigned int speed) | |||
104 | 105 | ||
105 | orion_spi = spi_master_get_devdata(spi->master); | 106 | orion_spi = spi_master_get_devdata(spi->master); |
106 | 107 | ||
107 | tclk_hz = orion_spi->spi_info->tclk; | 108 | tclk_hz = clk_get_rate(orion_spi->clk); |
108 | 109 | ||
109 | /* | 110 | /* |
110 | * the supported rates are: 4,6,8...30 | 111 | * the supported rates are: 4,6,8...30 |
@@ -450,6 +451,7 @@ static int __init orion_spi_probe(struct platform_device *pdev) | |||
450 | struct orion_spi *spi; | 451 | struct orion_spi *spi; |
451 | struct resource *r; | 452 | struct resource *r; |
452 | struct orion_spi_info *spi_info; | 453 | struct orion_spi_info *spi_info; |
454 | unsigned long tclk_hz; | ||
453 | int status = 0; | 455 | int status = 0; |
454 | 456 | ||
455 | spi_info = pdev->dev.platform_data; | 457 | spi_info = pdev->dev.platform_data; |
@@ -476,19 +478,28 @@ static int __init orion_spi_probe(struct platform_device *pdev) | |||
476 | spi->master = master; | 478 | spi->master = master; |
477 | spi->spi_info = spi_info; | 479 | spi->spi_info = spi_info; |
478 | 480 | ||
479 | spi->max_speed = DIV_ROUND_UP(spi_info->tclk, 4); | 481 | spi->clk = clk_get(&pdev->dev, NULL); |
480 | spi->min_speed = DIV_ROUND_UP(spi_info->tclk, 30); | 482 | if (IS_ERR(spi->clk)) { |
483 | status = PTR_ERR(spi->clk); | ||
484 | goto out; | ||
485 | } | ||
486 | |||
487 | clk_prepare(spi->clk); | ||
488 | clk_enable(spi->clk); | ||
489 | tclk_hz = clk_get_rate(spi->clk); | ||
490 | spi->max_speed = DIV_ROUND_UP(tclk_hz, 4); | ||
491 | spi->min_speed = DIV_ROUND_UP(tclk_hz, 30); | ||
481 | 492 | ||
482 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 493 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
483 | if (r == NULL) { | 494 | if (r == NULL) { |
484 | status = -ENODEV; | 495 | status = -ENODEV; |
485 | goto out; | 496 | goto out_rel_clk; |
486 | } | 497 | } |
487 | 498 | ||
488 | if (!request_mem_region(r->start, resource_size(r), | 499 | if (!request_mem_region(r->start, resource_size(r), |
489 | dev_name(&pdev->dev))) { | 500 | dev_name(&pdev->dev))) { |
490 | status = -EBUSY; | 501 | status = -EBUSY; |
491 | goto out; | 502 | goto out_rel_clk; |
492 | } | 503 | } |
493 | spi->base = ioremap(r->start, SZ_1K); | 504 | spi->base = ioremap(r->start, SZ_1K); |
494 | 505 | ||
@@ -508,7 +519,9 @@ static int __init orion_spi_probe(struct platform_device *pdev) | |||
508 | 519 | ||
509 | out_rel_mem: | 520 | out_rel_mem: |
510 | release_mem_region(r->start, resource_size(r)); | 521 | release_mem_region(r->start, resource_size(r)); |
511 | 522 | out_rel_clk: | |
523 | clk_disable_unprepare(spi->clk); | ||
524 | clk_put(spi->clk); | ||
512 | out: | 525 | out: |
513 | spi_master_put(master); | 526 | spi_master_put(master); |
514 | return status; | 527 | return status; |
@@ -526,6 +539,9 @@ static int __exit orion_spi_remove(struct platform_device *pdev) | |||
526 | 539 | ||
527 | cancel_work_sync(&spi->work); | 540 | cancel_work_sync(&spi->work); |
528 | 541 | ||
542 | clk_disable_unprepare(spi->clk); | ||
543 | clk_put(spi->clk); | ||
544 | |||
529 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 545 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
530 | release_mem_region(r->start, resource_size(r)); | 546 | release_mem_region(r->start, resource_size(r)); |
531 | 547 | ||