]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
spi: tegra124: Remove the ready/busy polarity prop
authorVipin Kumar <vipink@nvidia.com>
Tue, 27 Jan 2015 15:35:48 +0000 (21:05 +0530)
committerLaxman Dewangan <ldewangan@nvidia.com>
Wed, 28 Jan 2015 05:27:32 +0000 (21:27 -0800)
The GPIO polarity can be passed along with gpio number itself. This
patch modifies the code to handle GPIO polarity in the code

bug 1585361

Change-Id: Iadbd827dd82576158145c7a3c53db8264593a586
Signed-off-by: Vipin Kumar <vipink@nvidia.com>
Reviewed-on: http://git-master/r/677826
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Documentation/devicetree/bindings/spi/nvidia,spi-slave-tegra124.txt
drivers/spi/spi-tegra124-slave.c
include/linux/spi/spi-tegra.h

index 4a81e699053b80ebeba14d6399b04e2241ce4f3c..c129285a75660f86129f203349edaa867a7e344e 100644 (file)
@@ -16,12 +16,10 @@ Optional properties:
 - nvidia,maximum-dma-buffer-size: Maximum dma buffer size per transfer.
        If this is not available then 16K will be default. The value should
        be unit of byte.
-- nvidia,gpio-slave-ready: OUT GPIO from slave to report slave status. This
+- nvidia,slave-ready-gpio: OUT GPIO from slave to report slave status. This
        GPIO, when asserted, implies slave controller is ready for transaction.
        When this GPIO is de-asserted, the master cannot initiate transaction
        with this slave.
-- nvidia,gpio-slave-ready-active-high: Set the slave ready GPIO polarity to
-       active high.
 
 Example:
 spi@7000d600 {
@@ -34,6 +32,5 @@ spi@7000d600 {
        #address-cells = <1>;
        #size-cells = <0>;
        status = "disabled";
-       nvidia,gpio-slave-ready = <&gpio TEGRA_GPIO(I, 3) 0>; /*PI3*/
-       nvidia,gpio-slave-ready-active-high;
+       nvidia,slave-ready-gpio = <&gpio TEGRA_GPIO(I, 3) GPIO_ACTIVE_LOW>; /*PI3*/
 };
index f3d1991b5d5d70fe85f7f2f13c27d4233638fa80..4955b8dcb1ada500add47f352042fb4463a36764 100644 (file)
@@ -303,7 +303,7 @@ struct tegra_spi_data {
 
        /* Slave Ready Polarity (true: Active High, false: Active Low) */
        int                                     gpio_slave_ready;
-       bool                                    slave_ready_pol;
+       bool                                    slave_ready_active_high;
 
        struct completion                       rx_dma_complete;
        struct completion                       tx_dma_complete;
@@ -783,7 +783,7 @@ static inline void tegra_spi_slave_busy(struct tegra_spi_data *tspi)
 {
        int deassert_val;
 
-       if (tspi->slave_ready_pol)
+       if (tspi->slave_ready_active_high)
                deassert_val = 0;
        else
                deassert_val = 1;
@@ -797,7 +797,7 @@ static inline void tegra_spi_slave_ready(struct tegra_spi_data *tspi)
 {
        int assert_val;
 
-       if (tspi->slave_ready_pol)
+       if (tspi->slave_ready_active_high)
                assert_val = 1;
        else
                assert_val = 0;
@@ -1601,6 +1601,7 @@ static struct tegra_spi_platform_data *tegra_spi_parse_dt(
        struct tegra_spi_platform_data *pdata;
        const unsigned int *prop;
        struct device_node *np = pdev->dev.of_node;
+       enum of_gpio_flags gpio_flags;
        u32 of_dma[2];
 
        pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
@@ -1629,13 +1630,13 @@ static struct tegra_spi_platform_data *tegra_spi_parse_dt(
                pdata->is_clkon_always = true;
 
        pdata->gpio_slave_ready =
-               of_get_named_gpio(np, "nvidia,gpio-slave-ready", 0);
+               of_get_named_gpio_flags(np, "nvidia,slave-ready-gpio", 0,
+                               &gpio_flags);
 
-       /* Set the polarity to active low by default */
-       pdata->slave_ready_pol = false;
-
-       if (of_find_property(np, "nvidia,gpio-slave-ready-active-high", NULL))
-               pdata->slave_ready_pol = true;
+       if (gpio_flags & OF_GPIO_ACTIVE_LOW)
+               pdata->slave_ready_active_high = false;
+       else
+               pdata->slave_ready_active_high = true;
 
        return pdata;
 }
@@ -1724,12 +1725,12 @@ static int tegra_spi_probe(struct platform_device *pdev)
                        tspi->gpio_slave_ready = -EINVAL;
                }
 
-       tspi->slave_ready_pol = pdata->slave_ready_pol;
+       tspi->slave_ready_active_high = pdata->slave_ready_active_high;
 
        if (gpio_is_valid(tspi->gpio_slave_ready)) {
                gpio_request(tspi->gpio_slave_ready, "gpio-spi-slave-ready");
 
-               if (tspi->slave_ready_pol)
+               if (tspi->slave_ready_active_high)
                        deassert_val = 0;
                else
                        deassert_val = 1;
index 2686379f3b5f2197a316f121957be5b73da312f1..a35edbb2358ccdc8b2485688dd8b574139cd8a73 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * spi-tegra.h: SPI interface for Nvidia slink/spi controller.
  *
- * Copyright (c) 2011-2014, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2011-2015, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@ struct tegra_spi_platform_data {
        int rx_trig_words;
        int ls_bit;
        int gpio_slave_ready;
-       bool slave_ready_pol;
+       bool slave_ready_active_high;
        int max_dma_buffer_size;
 };