spi: img-spfi: check for max speed supported by the spfi block
authorSifan Naeem <sifan.naeem@imgtec.com>
Thu, 18 Jun 2015 12:27:12 +0000 (13:27 +0100)
committerMark Brown <broonie@kernel.org>
Tue, 7 Jul 2015 11:56:36 +0000 (12:56 +0100)
Maximum speed supported by spfi is limited to 1/4 of the spfi clock.

But in some SoCs the maximum speed supported by the spfi block can
be limited to less than 1/4 of the spfi clock. In such cases we have
to define the limit in the device tree so that the driver can pick
it up.

Signed-off-by: Sifan Naeem <sifan.naeem@imgtec.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Documentation/devicetree/bindings/spi/spi-img-spfi.txt
drivers/spi/spi-img-spfi.c

index e02fbf18c82cecad21a355cfacd3ae84c1676ac9..494db6012d02f29b3e17aec0f91f0ea6b0b65a28 100644 (file)
@@ -21,6 +21,7 @@ Required properties:
 Optional properties:
 - img,supports-quad-mode: Should be set if the interface supports quad mode
   SPI transfers.
+- spfi-max-frequency: Maximum speed supported by the spfi block.
 
 Example:
 
index 788e2b176a4f7707051bcc325538e7d2a6d599f4..f31d792a46620095b0e753f1e4bc2fd0f721561e 100644 (file)
@@ -546,6 +546,7 @@ static int img_spfi_probe(struct platform_device *pdev)
        struct img_spfi *spfi;
        struct resource *res;
        int ret;
+       u32 max_speed_hz;
 
        master = spi_alloc_master(&pdev->dev, sizeof(*spfi));
        if (!master)
@@ -610,6 +611,19 @@ static int img_spfi_probe(struct platform_device *pdev)
        master->max_speed_hz = clk_get_rate(spfi->spfi_clk) / 4;
        master->min_speed_hz = clk_get_rate(spfi->spfi_clk) / 512;
 
+       /*
+        * Maximum speed supported by spfi is limited to the lower value
+        * between 1/4 of the SPFI clock or to "spfi-max-frequency"
+        * defined in the device tree.
+        * If no value is defined in the device tree assume the maximum
+        * speed supported to be 1/4 of the SPFI clock.
+        */
+       if (!of_property_read_u32(spfi->dev->of_node, "spfi-max-frequency",
+                                 &max_speed_hz)) {
+               if (master->max_speed_hz > max_speed_hz)
+                       master->max_speed_hz = max_speed_hz;
+       }
+
        master->setup = img_spfi_setup;
        master->cleanup = img_spfi_cleanup;
        master->transfer_one = img_spfi_transfer_one;
This page took 0.031629 seconds and 5 git commands to generate.