]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
spi: cadence: Use max speed checks in the core
authorHarini Katakam <harini.katakam@xilinx.com>
Tue, 6 May 2014 09:29:00 +0000 (14:59 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Tue, 6 May 2014 10:51:20 +0000 (12:51 +0200)
Set master->max_speed_hz to let core perform necessary checks.
Remove checks in the driver.
If transfer speed is requested as zero after checks in the core,
dont set max speed, default to min speed.

Signed-off-by: Harini Katakam <harinik@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/spi/spi-cadence.c

index c3522377112aa3160c3f6cf926be41ad6c3479f4..2805f23d8b12a59881d586250d6295d020a83c79 100644 (file)
@@ -208,14 +208,9 @@ static void cdns_spi_config_clock(struct spi_device *spi,
                struct spi_transfer *transfer)
 {
        struct cdns_spi *xspi = spi_master_get_devdata(spi->master);
-       u32 ctrl_reg, req_hz, baud_rate_val;
+       u32 ctrl_reg, baud_rate_val;
        unsigned long frequency;
 
-       if (transfer && transfer->speed_hz)
-               req_hz = transfer->speed_hz;
-       else
-               req_hz = spi->max_speed_hz;
-
        frequency = clk_get_rate(xspi->ref_clk);
 
        cdns_spi_write(xspi->regs + CDNS_SPI_ER_OFFSET,
@@ -230,11 +225,11 @@ static void cdns_spi_config_clock(struct spi_device *spi,
                ctrl_reg |= CDNS_SPI_CR_CPOL_MASK;
 
        /* Set the clock frequency */
-       if (xspi->speed_hz != req_hz) {
+       if (xspi->speed_hz != transfer->speed_hz) {
                /* first valid value is 1 */
                baud_rate_val = CDNS_SPI_BAUD_DIV_MIN;
                while ((baud_rate_val < CDNS_SPI_BAUD_DIV_MAX) &&
-                      (frequency / (2 << baud_rate_val)) > req_hz)
+                      (frequency / (2 << baud_rate_val)) > transfer->speed_hz)
                        baud_rate_val++;
 
                ctrl_reg &= ~CDNS_SPI_CR_BAUD_DIV_MASK;
@@ -294,9 +289,6 @@ static int cdns_spi_setup_transfer(struct spi_device *spi,
  */
 static int cdns_spi_setup(struct spi_device *spi)
 {
-       if (!spi->max_speed_hz)
-               return -EINVAL;
-
        if (!spi->bits_per_word)
                spi->bits_per_word = 8;
 
@@ -651,7 +643,8 @@ static int cdns_spi_probe(struct platform_device *pdev)
        master->mode_bits = SPI_CPOL | SPI_CPHA;
 
        /* Set to default valid value */
-       xspi->speed_hz = clk_get_rate(xspi->ref_clk) / 4;
+       master->max_speed_hz = clk_get_rate(xspi->ref_clk) / 4;
+       xspi->speed_hz = master->max_speed_hz;
 
        xspi->driver_state = CDNS_SPI_DRIVER_STATE_READY;