diff options
author | Marek Vasut <marex@denx.de> | 2012-08-22 16:38:35 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-09-05 19:45:53 -0400 |
commit | e64d07a2dae569fc3c938adac777562a1d6f151e (patch) | |
tree | e0afe0d63e206c50bb43cd6521879be3b6b68785 /drivers/spi | |
parent | f13639dc6043eb67e308aa5cf96717a86c10f8b9 (diff) |
spi/mxs: Make the SPI block clock speed configurable via DT
Add "clock-frequency" property, which allows configuring the SPI block's
base speed.
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-mxs.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c index 556e5ef907fa..edf1360ab09e 100644 --- a/drivers/spi/spi-mxs.c +++ b/drivers/spi/spi-mxs.c | |||
@@ -520,10 +520,17 @@ static int __devinit mxs_spi_probe(struct platform_device *pdev) | |||
520 | struct pinctrl *pinctrl; | 520 | struct pinctrl *pinctrl; |
521 | struct clk *clk; | 521 | struct clk *clk; |
522 | void __iomem *base; | 522 | void __iomem *base; |
523 | int devid, dma_channel; | 523 | int devid, dma_channel, clk_freq; |
524 | int ret = 0, irq_err, irq_dma; | 524 | int ret = 0, irq_err, irq_dma; |
525 | dma_cap_mask_t mask; | 525 | dma_cap_mask_t mask; |
526 | 526 | ||
527 | /* | ||
528 | * Default clock speed for the SPI core. 160MHz seems to | ||
529 | * work reasonably well with most SPI flashes, so use this | ||
530 | * as a default. Override with "clock-frequency" DT prop. | ||
531 | */ | ||
532 | const int clk_freq_default = 160000000; | ||
533 | |||
527 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 534 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
528 | irq_err = platform_get_irq(pdev, 0); | 535 | irq_err = platform_get_irq(pdev, 0); |
529 | irq_dma = platform_get_irq(pdev, 1); | 536 | irq_dma = platform_get_irq(pdev, 1); |
@@ -555,12 +562,18 @@ static int __devinit mxs_spi_probe(struct platform_device *pdev) | |||
555 | "Failed to get DMA channel\n"); | 562 | "Failed to get DMA channel\n"); |
556 | return -EINVAL; | 563 | return -EINVAL; |
557 | } | 564 | } |
565 | |||
566 | ret = of_property_read_u32(np, "clock-frequency", | ||
567 | &clk_freq); | ||
568 | if (ret) | ||
569 | clk_freq = clk_freq_default; | ||
558 | } else { | 570 | } else { |
559 | dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); | 571 | dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); |
560 | if (!dmares) | 572 | if (!dmares) |
561 | return -EINVAL; | 573 | return -EINVAL; |
562 | devid = pdev->id_entry->driver_data; | 574 | devid = pdev->id_entry->driver_data; |
563 | dma_channel = dmares->start; | 575 | dma_channel = dmares->start; |
576 | clk_freq = clk_freq_default; | ||
564 | } | 577 | } |
565 | 578 | ||
566 | master = spi_alloc_master(&pdev->dev, sizeof(*spi)); | 579 | master = spi_alloc_master(&pdev->dev, sizeof(*spi)); |
@@ -598,12 +611,8 @@ static int __devinit mxs_spi_probe(struct platform_device *pdev) | |||
598 | goto out_master_free; | 611 | goto out_master_free; |
599 | } | 612 | } |
600 | 613 | ||
601 | /* | ||
602 | * Crank up the clock to 120MHz, this will be further divided onto a | ||
603 | * proper speed. | ||
604 | */ | ||
605 | clk_prepare_enable(ssp->clk); | 614 | clk_prepare_enable(ssp->clk); |
606 | clk_set_rate(ssp->clk, 120 * 1000 * 1000); | 615 | clk_set_rate(ssp->clk, clk_freq); |
607 | ssp->clk_rate = clk_get_rate(ssp->clk) / 1000; | 616 | ssp->clk_rate = clk_get_rate(ssp->clk) / 1000; |
608 | 617 | ||
609 | stmp_reset_block(ssp->base); | 618 | stmp_reset_block(ssp->base); |