Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH v2] gpio: mpc8xxx: Add new platforms GPIO DT node description
From: Hui Song @ 2019-08-06  2:49 UTC (permalink / raw)
  To: Shawn Guo, Li Yang, Rob Herring, Mark Rutland, Linus Walleij,
	Bartosz Golaszewski
  Cc: linux-arm-kernel, devicetree, linux-kernel, linux-gpio, Song Hui

From: Song Hui <hui.song_1@nxp.com>

Update the NXP GPIO node dt-binding file for QorIQ and
Layerscape platforms, and add one more example with
ls1028a GPIO node.

Signed-off-by: Song Hui <hui.song_1@nxp.com>
---
 Documentation/devicetree/bindings/gpio/gpio-mpc8xxx.txt | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/Documentation/devicetree/bindings/gpio/gpio-mpc8xxx.txt b/Documentation/devicetree/bindings/gpio/gpio-mpc8xxx.txt
index 69d4616..2df5fc0 100644
--- a/Documentation/devicetree/bindings/gpio/gpio-mpc8xxx.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio-mpc8xxx.txt
@@ -37,3 +37,17 @@ gpio0: gpio@2300000 {
 	interrupt-controller;
 	#interrupt-cells = <2>;
 };
+
+
+Example of gpio-controller node for a ls1028a SoC:
+
+gpio1: gpio@2300000 {
+	compatible = "fsl,ls1028a-gpio","fsl,qoriq-gpio";
+	reg = <0x0 0x2300000 0x0 0x10000>;
+	interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
+	gpio-controller;
+	#gpio-cells = <2>;
+	interrupt-controller;
+	#interrupt-cells = <2>;
+	little-endian;
+};
-- 
2.9.5


^ permalink raw reply related

* Re: [PATCH] pinctrl: spear: spear: Add of_node_put() before return
From: Viresh Kumar @ 2019-08-06  3:42 UTC (permalink / raw)
  To: Nishka Dasgupta; +Cc: vireshk, linus.walleij, linux-arm-kernel, linux-gpio
In-Reply-To: <20190804154948.4584-1-nishkadg.linux@gmail.com>

On 04-08-19, 21:19, Nishka Dasgupta wrote:
> Each iteration of for_each_child_of_node puts the previous node, but in
> the case of a return from the middle of the loop, there is no put, thus
> causing a memory leak. Hence add an of_node_put before the return in
> two places.
> Issue found with Coccinelle.
> 
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---
>  drivers/pinctrl/spear/pinctrl-spear.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pinctrl/spear/pinctrl-spear.c b/drivers/pinctrl/spear/pinctrl-spear.c
> index c4f850345dc4..7ec19c73f870 100644
> --- a/drivers/pinctrl/spear/pinctrl-spear.c
> +++ b/drivers/pinctrl/spear/pinctrl-spear.c
> @@ -157,12 +157,16 @@ static int spear_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	/* calculate number of maps required */
>  	for_each_child_of_node(np_config, np) {
>  		ret = of_property_read_string(np, "st,function", &function);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			of_node_put(np);
>  			return ret;
> +		}
>  
>  		ret = of_property_count_strings(np, "st,pins");
> -		if (ret < 0)
> +		if (ret < 0) {
> +			of_node_put(np);
>  			return ret;
> +		}
>  
>  		count += ret;
>  	}

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply

* linusw/for-next build: 6 builds: 0 failed, 6 passed, 13 warnings (gpio-v5.3-3-18-g52d4cb72f265)
From: kernelci.org bot @ 2019-08-06  4:26 UTC (permalink / raw)
  To: linux-gpio, fellows

linusw/for-next build: 6 builds: 0 failed, 6 passed, 13 warnings (gpio-v5.3-3-18-g52d4cb72f265)

Full Build Summary: https://kernelci.org/build/linusw/branch/for-next/kernel/gpio-v5.3-3-18-g52d4cb72f265/

Tree: linusw
Branch: for-next
Git Describe: gpio-v5.3-3-18-g52d4cb72f265
Git Commit: 52d4cb72f26530572a9a1377ba8427d0203b76e6
Git URL: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git/
Built: 6 unique architectures

Warnings Detected:

arc:
    nsim_hs_defconfig (gcc-8): 2 warnings

arm64:

arm:
    multi_v7_defconfig (gcc-8): 6 warnings

mips:
    32r2el_defconfig (gcc-8): 3 warnings

riscv:
    defconfig (gcc-8): 2 warnings

x86_64:


Warnings summary:

    7    <stdin>:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp]
    1    arch/arm/boot/dts/bcm47094-linksys-panamera.dts:129.4-18: Warning (reg_format): /mdio-bus-mux/mdio@200:reg: property has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1)
    1    arch/arm/boot/dts/bcm47094-linksys-panamera.dts:128.22-132.5: Warning (avoid_default_addr_size): /mdio-bus-mux/mdio@200: Relying on default #size-cells value
    1    arch/arm/boot/dts/bcm47094-linksys-panamera.dts:128.22-132.5: Warning (avoid_default_addr_size): /mdio-bus-mux/mdio@200: Relying on default #address-cells value
    1    arch/arm/boot/dts/bcm47094-linksys-panamera.dtb: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
    1    arch/arm/boot/dts/bcm47094-linksys-panamera.dtb: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
    1    arch/arm/boot/dts/bcm47094-linksys-panamera.dtb: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'

================================================================================

Detailed per-defconfig build reports:

--------------------------------------------------------------------------------
32r2el_defconfig (mips, gcc-8) — PASS, 0 errors, 3 warnings, 0 section mismatches

Warnings:
    <stdin>:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp]
    <stdin>:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp]
    <stdin>:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp]

--------------------------------------------------------------------------------
defconfig (riscv, gcc-8) — PASS, 0 errors, 2 warnings, 0 section mismatches

Warnings:
    <stdin>:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp]
    <stdin>:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp]

--------------------------------------------------------------------------------
defconfig (arm64, gcc-8) — PASS, 0 errors, 0 warnings, 0 section mismatches

--------------------------------------------------------------------------------
multi_v7_defconfig (arm, gcc-8) — PASS, 0 errors, 6 warnings, 0 section mismatches

Warnings:
    arch/arm/boot/dts/bcm47094-linksys-panamera.dts:129.4-18: Warning (reg_format): /mdio-bus-mux/mdio@200:reg: property has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1)
    arch/arm/boot/dts/bcm47094-linksys-panamera.dtb: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
    arch/arm/boot/dts/bcm47094-linksys-panamera.dtb: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
    arch/arm/boot/dts/bcm47094-linksys-panamera.dtb: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
    arch/arm/boot/dts/bcm47094-linksys-panamera.dts:128.22-132.5: Warning (avoid_default_addr_size): /mdio-bus-mux/mdio@200: Relying on default #address-cells value
    arch/arm/boot/dts/bcm47094-linksys-panamera.dts:128.22-132.5: Warning (avoid_default_addr_size): /mdio-bus-mux/mdio@200: Relying on default #size-cells value

--------------------------------------------------------------------------------
nsim_hs_defconfig (arc, gcc-8) — PASS, 0 errors, 2 warnings, 0 section mismatches

Warnings:
    <stdin>:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp]
    <stdin>:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp]

--------------------------------------------------------------------------------
x86_64_defconfig (x86_64, gcc-8) — PASS, 0 errors, 0 warnings, 0 section mismatches

---
For more info write to <info@kernelci.org>

^ permalink raw reply

* linusw/for-next boot: 41 boots: 1 failed, 39 passed with 1 untried/unknown (gpio-v5.3-3-18-g52d4cb72f265)
From: kernelci.org bot @ 2019-08-06  5:10 UTC (permalink / raw)
  To: linux-gpio, fellows

linusw/for-next boot: 41 boots: 1 failed, 39 passed with 1 untried/unknown (gpio-v5.3-3-18-g52d4cb72f265)

Full Boot Summary: https://kernelci.org/boot/all/job/linusw/branch/for-next/kernel/gpio-v5.3-3-18-g52d4cb72f265/
Full Build Summary: https://kernelci.org/build/linusw/branch/for-next/kernel/gpio-v5.3-3-18-g52d4cb72f265/

Tree: linusw
Branch: for-next
Git Describe: gpio-v5.3-3-18-g52d4cb72f265
Git Commit: 52d4cb72f26530572a9a1377ba8427d0203b76e6
Git URL: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git/
Tested: 30 unique boards, 13 SoC families, 3 builds out of 6

Boot Regressions Detected:

arm:

    multi_v7_defconfig:
        gcc-8:
          sun8i-h2-plus-orangepi-r1:
              lab-baylibre: new failure (last pass: v5.3-rc1-13-gfb9152b494a9)

arm64:

    defconfig:
        gcc-8:
          apq8016-sbc:
              lab-mhart: failing since 7 days (last pass: v5.2-10813-g88785b7fa74a - first fail: v5.3-rc1-10-gd2a561ae1961)

Boot Failure Detected:

arm64:
    defconfig:
        gcc-8:
            apq8016-sbc: 1 failed lab

---
For more info write to <info@kernelci.org>

^ permalink raw reply

* [PATCH v3 1/2] dt-bindings: pinctrl: qcom: Add SC7180 pinctrl binding
From: Rajendra Nayak @ 2019-08-06  6:05 UTC (permalink / raw)
  To: linus.walleij, bjorn.andersson
  Cc: linux-arm-msm, agross, robh+dt, linux-gpio, devicetree,
	linux-kernel, Jitendra Sharma, Vivek Gautam, Rajendra Nayak,
	Vinod Koul

From: Jitendra Sharma <shajit@codeaurora.org>

Add the binding for the TLMM pinctrl block found in the SC7180 platform

Signed-off-by: Jitendra Sharma <shajit@codeaurora.org>
Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
[rnayak: Fix some copy-paste issues, sort and fix functions]
Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Vinod Koul <vkoul@kernel.org>
---
v3: Minor typo fixes as pointed out by Vinod on v2.
    Added Vinods Reviewed-by:

 .../bindings/pinctrl/qcom,sc7180-pinctrl.txt  | 186 ++++++++++++++++++
 1 file changed, 186 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/qcom,sc7180-pinctrl.txt

diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,sc7180-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/qcom,sc7180-pinctrl.txt
new file mode 100644
index 000000000000..b5767ee82ee6
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,sc7180-pinctrl.txt
@@ -0,0 +1,186 @@
+Qualcomm Technologies, Inc. SC7180 TLMM block
+
+This binding describes the Top Level Mode Multiplexer block found in the
+SC7180 platform.
+
+- compatible:
+	Usage: required
+	Value type: <string>
+	Definition: must be "qcom,sc7180-pinctrl"
+
+- reg:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: the base address and size of the north, south and west
+		    TLMM tiles
+
+- reg-names:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: names for the cells of reg, must contain "north", "south"
+		    and "west".
+
+- interrupts:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: should specify the TLMM summary IRQ.
+
+- interrupt-controller:
+	Usage: required
+	Value type: <none>
+	Definition: identifies this node as an interrupt controller
+
+- #interrupt-cells:
+	Usage: required
+	Value type: <u32>
+	Definition: must be 2. Specifying the pin number and flags, as defined
+		    in <dt-bindings/interrupt-controller/irq.h>
+
+- gpio-controller:
+	Usage: required
+	Value type: <none>
+	Definition: identifies this node as a gpio controller
+
+- #gpio-cells:
+	Usage: required
+	Value type: <u32>
+	Definition: must be 2. Specifying the pin number and flags, as defined
+		    in <dt-bindings/gpio/gpio.h>
+
+- gpio-ranges:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition:  see ../gpio/gpio.txt
+
+- gpio-reserved-ranges:
+	Usage: optional
+	Value type: <prop-encoded-array>
+	Definition: see ../gpio/gpio.txt
+
+Please refer to ../gpio/gpio.txt and ../interrupt-controller/interrupts.txt for
+a general description of GPIO and interrupt bindings.
+
+Please refer to pinctrl-bindings.txt in this directory for details of the
+common pinctrl bindings used by client devices, including the meaning of the
+phrase "pin configuration node".
+
+The pin configuration nodes act as a container for an arbitrary number of
+subnodes. Each of these subnodes represents some desired configuration for a
+pin, a group, or a list of pins or groups. This configuration can include the
+mux function to select on those pin(s)/group(s), and various pin configuration
+parameters, such as pull-up, drive strength, etc.
+
+
+PIN CONFIGURATION NODES:
+
+The name of each subnode is not important; all subnodes should be enumerated
+and processed purely based on their content.
+
+Each subnode only affects those parameters that are explicitly listed. In
+other words, a subnode that lists a mux function but no pin configuration
+parameters implies no information about any pin configuration parameters.
+Similarly, a pin subnode that describes a pullup parameter implies no
+information about e.g. the mux function.
+
+
+The following generic properties as defined in pinctrl-bindings.txt are valid
+to specify in a pin configuration subnode:
+
+- pins:
+	Usage: required
+	Value type: <string-array>
+	Definition: List of gpio pins affected by the properties specified in
+		    this subnode.
+
+		    Valid pins are:
+		      gpio0-gpio118
+		        Supports mux, bias and drive-strength
+
+		      sdc1_clk, sdc1_cmd, sdc1_data sdc2_clk, sdc2_cmd,
+		      sdc2_data sdc1_rclk
+		        Supports bias and drive-strength
+
+		      ufs_reset
+			Supports bias and drive-strength
+
+- function:
+	Usage: required
+	Value type: <string>
+	Definition: Specify the alternative function to be configured for the
+		    specified pins. Functions are only valid for gpio pins.
+		    Valid values are:
+
+		    adsp_ext, agera_pll, aoss_cti, atest_char, atest_char0,
+		    atest_char1, atest_char2, atest_char3, atest_tsens,
+		    atest_tsens2, atest_usb1, atest_usb10, atest_usb11,
+		    atest_usb12, atest_usb13, atest_usb2, atest_usb20,
+		    atest_usb21, atest_usb22, atest_usb23, audio_ref,
+		    btfm_slimbus, cam_mclk, cci_async, cci_i2c, cci_timer0,
+		    cci_timer1, cci_timer2, cci_timer3, cci_timer4,
+		    cri_trng, dbg_out, ddr_bist, ddr_pxi0, ddr_pxi1,
+		    ddr_pxi2, ddr_pxi3, dp_hot, edp_lcd, gcc_gp1, gcc_gp2,
+		    gcc_gp3, gpio, gp_pdm0, gp_pdm1, gp_pdm2, gps_tx,
+		    jitter_bist, ldo_en, ldo_update, lpass_ext, mdp_vsync,
+		    mdp_vsync0, mdp_vsync1, mdp_vsync2, mdp_vsync3, mi2s_0,
+		    mi2s_1, mi2s_2, mss_lte, m_voc, pa_indicator, phase_flag,
+		    PLL_BIST, pll_bypassnl, pll_reset, prng_rosc, qdss,
+		    qdss_cti, qlink_enable, qlink_request, qspi_clk, qspi_cs,
+		    qspi_data, qup00, qup01, qup02, qup03, qup04, qup05,
+		    qup10, qup11, qup12, qup13, qup14, qup15, sdc1_tb,
+		    sdc2_tb, sd_write, sp_cmu, tgu_ch0, tgu_ch1, tgu_ch2,
+		    tgu_ch3, tsense_pwm1, tsense_pwm2, uim1, uim2, uim_batt,
+		    usb_phy, vfr_1, _V_GPIO, _V_PPS_IN, _V_PPS_OUT,
+		    vsense_trigger, wlan1_adc0, wlan1_adc1, wlan2_adc0,
+		    wlan2_adc1,
+
+- bias-disable:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins should be configured as no pull.
+
+- bias-pull-down:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins should be configured as pull down.
+
+- bias-pull-up:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins should be configured as pull up.
+
+- output-high:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins are configured in output mode, driven
+		    high.
+		    Not valid for sdc pins.
+
+- output-low:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins are configured in output mode, driven
+		    low.
+		    Not valid for sdc pins.
+
+- drive-strength:
+	Usage: optional
+	Value type: <u32>
+	Definition: Selects the drive strength for the specified pins, in mA.
+		    Valid values are: 2, 4, 6, 8, 10, 12, 14 and 16
+
+Example:
+
+	tlmm: pinctrl@3500000 {
+		compatible = "qcom,sc7180-pinctrl";
+		reg = <0x3500000 0x300000>,
+		      <0x3900000 0x300000>,
+		      <0x3D00000 0x300000>;
+		reg-names = "west", "north", "south";
+		interrupts = <GIC_SPI 208 IRQ_TYPE_LEVEL_HIGH>;
+		gpio-controller;
+		#gpio-cells = <2>;
+		gpio-ranges = <&tlmm 0 0 119>;
+		gpio-reserved-ranges = <0 4>, <106 4>;
+		interrupt-controller;
+		#interrupt-cells = <2>;
+	};
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


^ permalink raw reply related

* [PATCH v3 2/2] pinctrl: qcom: Add SC7180 pinctrl driver
From: Rajendra Nayak @ 2019-08-06  6:05 UTC (permalink / raw)
  To: linus.walleij, bjorn.andersson
  Cc: linux-arm-msm, agross, robh+dt, linux-gpio, devicetree,
	linux-kernel, Jitendra Sharma, Vivek Gautam, Rajendra Nayak,
	Vinod Koul
In-Reply-To: <20190806060536.18094-1-rnayak@codeaurora.org>

From: Jitendra Sharma <shajit@codeaurora.org>

Add initial pinctrl driver to support pin configuration with
pinctrl framework for SC7180

Signed-off-by: Jitendra Sharma <shajit@codeaurora.org>
Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
[rnayak: modify to use upstream tile support
	 sort and squash some functions]
Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Vinod Koul <vkoul@kernel.org>
---
v3: No change since v2 except for adding Vinods Reviewed-by:

 drivers/pinctrl/qcom/Kconfig          |    9 +
 drivers/pinctrl/qcom/Makefile         |    1 +
 drivers/pinctrl/qcom/pinctrl-sc7180.c | 1146 +++++++++++++++++++++++++
 3 files changed, 1156 insertions(+)
 create mode 100644 drivers/pinctrl/qcom/pinctrl-sc7180.c

diff --git a/drivers/pinctrl/qcom/Kconfig b/drivers/pinctrl/qcom/Kconfig
index 8e14a5f2e970..af44dafc35e7 100644
--- a/drivers/pinctrl/qcom/Kconfig
+++ b/drivers/pinctrl/qcom/Kconfig
@@ -158,6 +158,15 @@ config PINCTRL_QCOM_SSBI_PMIC
          which are using SSBI for communication with SoC. Example PMIC's
          devices are pm8058 and pm8921.
 
+config PINCTRL_SC7180
+	tristate "Qualcomm Technologies Inc SC7180 pin controller driver"
+	depends on GPIOLIB && OF
+	select PINCTRL_MSM
+	help
+	  This is the pinctrl, pinmux, pinconf and gpiolib driver for the
+	  Qualcomm Technologies Inc TLMM block found on the Qualcomm
+	  Technologies Inc SC7180 platform.
+
 config PINCTRL_SDM660
        tristate "Qualcomm Technologies Inc SDM660 pin controller driver"
        depends on GPIOLIB && OF
diff --git a/drivers/pinctrl/qcom/Makefile b/drivers/pinctrl/qcom/Makefile
index ebe906872272..f8bb0c265381 100644
--- a/drivers/pinctrl/qcom/Makefile
+++ b/drivers/pinctrl/qcom/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_PINCTRL_QCOM_SPMI_PMIC) += pinctrl-spmi-gpio.o
 obj-$(CONFIG_PINCTRL_QCOM_SPMI_PMIC) += pinctrl-spmi-mpp.o
 obj-$(CONFIG_PINCTRL_QCOM_SSBI_PMIC) += pinctrl-ssbi-gpio.o
 obj-$(CONFIG_PINCTRL_QCOM_SSBI_PMIC) += pinctrl-ssbi-mpp.o
+obj-$(CONFIG_PINCTRL_SC7180)	+= pinctrl-sc7180.o
 obj-$(CONFIG_PINCTRL_SDM660)   += pinctrl-sdm660.o
 obj-$(CONFIG_PINCTRL_SDM845) += pinctrl-sdm845.o
 obj-$(CONFIG_PINCTRL_SM8150) += pinctrl-sm8150.o
diff --git a/drivers/pinctrl/qcom/pinctrl-sc7180.c b/drivers/pinctrl/qcom/pinctrl-sc7180.c
new file mode 100644
index 000000000000..6399c8a2bc22
--- /dev/null
+++ b/drivers/pinctrl/qcom/pinctrl-sc7180.c
@@ -0,0 +1,1146 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2019, The Linux Foundation. All rights reserved.
+
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/pinctrl/pinctrl.h>
+
+#include "pinctrl-msm.h"
+
+static const char * const sc7180_tiles[] = {
+	"north",
+	"south",
+	"west",
+};
+
+enum {
+	NORTH,
+	SOUTH,
+	WEST
+};
+
+#define FUNCTION(fname)					\
+	[msm_mux_##fname] = {				\
+		.name = #fname,				\
+		.groups = fname##_groups,		\
+		.ngroups = ARRAY_SIZE(fname##_groups),	\
+	}
+
+#define PINGROUP(id, _tile, f1, f2, f3, f4, f5, f6, f7, f8, f9)	\
+	{						\
+		.name = "gpio" #id,			\
+		.pins = gpio##id##_pins,		\
+		.npins = ARRAY_SIZE(gpio##id##_pins),	\
+		.funcs = (int[]){			\
+			msm_mux_gpio, /* gpio mode */	\
+			msm_mux_##f1,			\
+			msm_mux_##f2,			\
+			msm_mux_##f3,			\
+			msm_mux_##f4,			\
+			msm_mux_##f5,			\
+			msm_mux_##f6,			\
+			msm_mux_##f7,			\
+			msm_mux_##f8,			\
+			msm_mux_##f9			\
+		},					\
+		.nfuncs = 10,				\
+		.ctl_reg = 0x1000 * id,		\
+		.io_reg = 0x1000 * id + 0x4,		\
+		.intr_cfg_reg = 0x1000 * id + 0x8,	\
+		.intr_status_reg = 0x1000 * id + 0xc,	\
+		.intr_target_reg = 0x1000 * id + 0x8,	\
+		.tile = _tile,			\
+		.mux_bit = 2,			\
+		.pull_bit = 0,			\
+		.drv_bit = 6,			\
+		.oe_bit = 9,			\
+		.in_bit = 0,			\
+		.out_bit = 1,			\
+		.intr_enable_bit = 0,		\
+		.intr_status_bit = 0,		\
+		.intr_target_bit = 5,		\
+		.intr_target_kpss_val = 3,	\
+		.intr_raw_status_bit = 4,	\
+		.intr_polarity_bit = 1,		\
+		.intr_detection_bit = 2,	\
+		.intr_detection_width = 2,	\
+	}
+
+#define SDC_QDSD_PINGROUP(pg_name, ctl, pull, drv)	\
+	{						\
+		.name = #pg_name,			\
+		.pins = pg_name##_pins,			\
+		.npins = ARRAY_SIZE(pg_name##_pins),	\
+		.ctl_reg = ctl,				\
+		.io_reg = 0,				\
+		.intr_cfg_reg = 0,			\
+		.intr_status_reg = 0,			\
+		.intr_target_reg = 0,			\
+		.mux_bit = -1,				\
+		.pull_bit = pull,			\
+		.drv_bit = drv,				\
+		.oe_bit = -1,				\
+		.in_bit = -1,				\
+		.out_bit = -1,				\
+		.intr_enable_bit = -1,			\
+		.intr_status_bit = -1,			\
+		.intr_target_bit = -1,			\
+		.intr_raw_status_bit = -1,		\
+		.intr_polarity_bit = -1,		\
+		.intr_detection_bit = -1,		\
+		.intr_detection_width = -1,		\
+	}
+
+#define UFS_RESET(pg_name, offset)				\
+	{						\
+		.name = #pg_name,			\
+		.pins = pg_name##_pins,			\
+		.npins = ARRAY_SIZE(pg_name##_pins),	\
+		.ctl_reg = offset,			\
+		.io_reg = offset + 0x4,			\
+		.intr_cfg_reg = 0,			\
+		.intr_status_reg = 0,			\
+		.intr_target_reg = 0,			\
+		.mux_bit = -1,				\
+		.pull_bit = 3,				\
+		.drv_bit = 0,				\
+		.oe_bit = -1,				\
+		.in_bit = -1,				\
+		.out_bit = 0,				\
+		.intr_enable_bit = -1,			\
+		.intr_status_bit = -1,			\
+		.intr_target_bit = -1,			\
+		.intr_raw_status_bit = -1,		\
+		.intr_polarity_bit = -1,		\
+		.intr_detection_bit = -1,		\
+		.intr_detection_width = -1,		\
+	}
+static const struct pinctrl_pin_desc sc7180_pins[] = {
+	PINCTRL_PIN(0, "GPIO_0"),
+	PINCTRL_PIN(1, "GPIO_1"),
+	PINCTRL_PIN(2, "GPIO_2"),
+	PINCTRL_PIN(3, "GPIO_3"),
+	PINCTRL_PIN(4, "GPIO_4"),
+	PINCTRL_PIN(5, "GPIO_5"),
+	PINCTRL_PIN(6, "GPIO_6"),
+	PINCTRL_PIN(7, "GPIO_7"),
+	PINCTRL_PIN(8, "GPIO_8"),
+	PINCTRL_PIN(9, "GPIO_9"),
+	PINCTRL_PIN(10, "GPIO_10"),
+	PINCTRL_PIN(11, "GPIO_11"),
+	PINCTRL_PIN(12, "GPIO_12"),
+	PINCTRL_PIN(13, "GPIO_13"),
+	PINCTRL_PIN(14, "GPIO_14"),
+	PINCTRL_PIN(15, "GPIO_15"),
+	PINCTRL_PIN(16, "GPIO_16"),
+	PINCTRL_PIN(17, "GPIO_17"),
+	PINCTRL_PIN(18, "GPIO_18"),
+	PINCTRL_PIN(19, "GPIO_19"),
+	PINCTRL_PIN(20, "GPIO_20"),
+	PINCTRL_PIN(21, "GPIO_21"),
+	PINCTRL_PIN(22, "GPIO_22"),
+	PINCTRL_PIN(23, "GPIO_23"),
+	PINCTRL_PIN(24, "GPIO_24"),
+	PINCTRL_PIN(25, "GPIO_25"),
+	PINCTRL_PIN(26, "GPIO_26"),
+	PINCTRL_PIN(27, "GPIO_27"),
+	PINCTRL_PIN(28, "GPIO_28"),
+	PINCTRL_PIN(29, "GPIO_29"),
+	PINCTRL_PIN(30, "GPIO_30"),
+	PINCTRL_PIN(31, "GPIO_31"),
+	PINCTRL_PIN(32, "GPIO_32"),
+	PINCTRL_PIN(33, "GPIO_33"),
+	PINCTRL_PIN(34, "GPIO_34"),
+	PINCTRL_PIN(35, "GPIO_35"),
+	PINCTRL_PIN(36, "GPIO_36"),
+	PINCTRL_PIN(37, "GPIO_37"),
+	PINCTRL_PIN(38, "GPIO_38"),
+	PINCTRL_PIN(39, "GPIO_39"),
+	PINCTRL_PIN(40, "GPIO_40"),
+	PINCTRL_PIN(41, "GPIO_41"),
+	PINCTRL_PIN(42, "GPIO_42"),
+	PINCTRL_PIN(43, "GPIO_43"),
+	PINCTRL_PIN(44, "GPIO_44"),
+	PINCTRL_PIN(45, "GPIO_45"),
+	PINCTRL_PIN(46, "GPIO_46"),
+	PINCTRL_PIN(47, "GPIO_47"),
+	PINCTRL_PIN(48, "GPIO_48"),
+	PINCTRL_PIN(49, "GPIO_49"),
+	PINCTRL_PIN(50, "GPIO_50"),
+	PINCTRL_PIN(51, "GPIO_51"),
+	PINCTRL_PIN(52, "GPIO_52"),
+	PINCTRL_PIN(53, "GPIO_53"),
+	PINCTRL_PIN(54, "GPIO_54"),
+	PINCTRL_PIN(55, "GPIO_55"),
+	PINCTRL_PIN(56, "GPIO_56"),
+	PINCTRL_PIN(57, "GPIO_57"),
+	PINCTRL_PIN(58, "GPIO_58"),
+	PINCTRL_PIN(59, "GPIO_59"),
+	PINCTRL_PIN(60, "GPIO_60"),
+	PINCTRL_PIN(61, "GPIO_61"),
+	PINCTRL_PIN(62, "GPIO_62"),
+	PINCTRL_PIN(63, "GPIO_63"),
+	PINCTRL_PIN(64, "GPIO_64"),
+	PINCTRL_PIN(65, "GPIO_65"),
+	PINCTRL_PIN(66, "GPIO_66"),
+	PINCTRL_PIN(67, "GPIO_67"),
+	PINCTRL_PIN(68, "GPIO_68"),
+	PINCTRL_PIN(69, "GPIO_69"),
+	PINCTRL_PIN(70, "GPIO_70"),
+	PINCTRL_PIN(71, "GPIO_71"),
+	PINCTRL_PIN(72, "GPIO_72"),
+	PINCTRL_PIN(73, "GPIO_73"),
+	PINCTRL_PIN(74, "GPIO_74"),
+	PINCTRL_PIN(75, "GPIO_75"),
+	PINCTRL_PIN(76, "GPIO_76"),
+	PINCTRL_PIN(77, "GPIO_77"),
+	PINCTRL_PIN(78, "GPIO_78"),
+	PINCTRL_PIN(79, "GPIO_79"),
+	PINCTRL_PIN(80, "GPIO_80"),
+	PINCTRL_PIN(81, "GPIO_81"),
+	PINCTRL_PIN(82, "GPIO_82"),
+	PINCTRL_PIN(83, "GPIO_83"),
+	PINCTRL_PIN(84, "GPIO_84"),
+	PINCTRL_PIN(85, "GPIO_85"),
+	PINCTRL_PIN(86, "GPIO_86"),
+	PINCTRL_PIN(87, "GPIO_87"),
+	PINCTRL_PIN(88, "GPIO_88"),
+	PINCTRL_PIN(89, "GPIO_89"),
+	PINCTRL_PIN(90, "GPIO_90"),
+	PINCTRL_PIN(91, "GPIO_91"),
+	PINCTRL_PIN(92, "GPIO_92"),
+	PINCTRL_PIN(93, "GPIO_93"),
+	PINCTRL_PIN(94, "GPIO_94"),
+	PINCTRL_PIN(95, "GPIO_95"),
+	PINCTRL_PIN(96, "GPIO_96"),
+	PINCTRL_PIN(97, "GPIO_97"),
+	PINCTRL_PIN(98, "GPIO_98"),
+	PINCTRL_PIN(99, "GPIO_99"),
+	PINCTRL_PIN(100, "GPIO_100"),
+	PINCTRL_PIN(101, "GPIO_101"),
+	PINCTRL_PIN(102, "GPIO_102"),
+	PINCTRL_PIN(103, "GPIO_103"),
+	PINCTRL_PIN(104, "GPIO_104"),
+	PINCTRL_PIN(105, "GPIO_105"),
+	PINCTRL_PIN(106, "GPIO_106"),
+	PINCTRL_PIN(107, "GPIO_107"),
+	PINCTRL_PIN(108, "GPIO_108"),
+	PINCTRL_PIN(109, "GPIO_109"),
+	PINCTRL_PIN(110, "GPIO_110"),
+	PINCTRL_PIN(111, "GPIO_111"),
+	PINCTRL_PIN(112, "GPIO_112"),
+	PINCTRL_PIN(113, "GPIO_113"),
+	PINCTRL_PIN(114, "GPIO_114"),
+	PINCTRL_PIN(115, "GPIO_115"),
+	PINCTRL_PIN(116, "GPIO_116"),
+	PINCTRL_PIN(117, "GPIO_117"),
+	PINCTRL_PIN(118, "GPIO_118"),
+	PINCTRL_PIN(119, "UFS_RESET"),
+	PINCTRL_PIN(120, "SDC1_RCLK"),
+	PINCTRL_PIN(121, "SDC1_CLK"),
+	PINCTRL_PIN(122, "SDC1_CMD"),
+	PINCTRL_PIN(123, "SDC1_DATA"),
+	PINCTRL_PIN(124, "SDC2_CLK"),
+	PINCTRL_PIN(125, "SDC2_CMD"),
+	PINCTRL_PIN(126, "SDC2_DATA"),
+};
+
+#define DECLARE_MSM_GPIO_PINS(pin) \
+	static const unsigned int gpio##pin##_pins[] = { pin }
+DECLARE_MSM_GPIO_PINS(0);
+DECLARE_MSM_GPIO_PINS(1);
+DECLARE_MSM_GPIO_PINS(2);
+DECLARE_MSM_GPIO_PINS(3);
+DECLARE_MSM_GPIO_PINS(4);
+DECLARE_MSM_GPIO_PINS(5);
+DECLARE_MSM_GPIO_PINS(6);
+DECLARE_MSM_GPIO_PINS(7);
+DECLARE_MSM_GPIO_PINS(8);
+DECLARE_MSM_GPIO_PINS(9);
+DECLARE_MSM_GPIO_PINS(10);
+DECLARE_MSM_GPIO_PINS(11);
+DECLARE_MSM_GPIO_PINS(12);
+DECLARE_MSM_GPIO_PINS(13);
+DECLARE_MSM_GPIO_PINS(14);
+DECLARE_MSM_GPIO_PINS(15);
+DECLARE_MSM_GPIO_PINS(16);
+DECLARE_MSM_GPIO_PINS(17);
+DECLARE_MSM_GPIO_PINS(18);
+DECLARE_MSM_GPIO_PINS(19);
+DECLARE_MSM_GPIO_PINS(20);
+DECLARE_MSM_GPIO_PINS(21);
+DECLARE_MSM_GPIO_PINS(22);
+DECLARE_MSM_GPIO_PINS(23);
+DECLARE_MSM_GPIO_PINS(24);
+DECLARE_MSM_GPIO_PINS(25);
+DECLARE_MSM_GPIO_PINS(26);
+DECLARE_MSM_GPIO_PINS(27);
+DECLARE_MSM_GPIO_PINS(28);
+DECLARE_MSM_GPIO_PINS(29);
+DECLARE_MSM_GPIO_PINS(30);
+DECLARE_MSM_GPIO_PINS(31);
+DECLARE_MSM_GPIO_PINS(32);
+DECLARE_MSM_GPIO_PINS(33);
+DECLARE_MSM_GPIO_PINS(34);
+DECLARE_MSM_GPIO_PINS(35);
+DECLARE_MSM_GPIO_PINS(36);
+DECLARE_MSM_GPIO_PINS(37);
+DECLARE_MSM_GPIO_PINS(38);
+DECLARE_MSM_GPIO_PINS(39);
+DECLARE_MSM_GPIO_PINS(40);
+DECLARE_MSM_GPIO_PINS(41);
+DECLARE_MSM_GPIO_PINS(42);
+DECLARE_MSM_GPIO_PINS(43);
+DECLARE_MSM_GPIO_PINS(44);
+DECLARE_MSM_GPIO_PINS(45);
+DECLARE_MSM_GPIO_PINS(46);
+DECLARE_MSM_GPIO_PINS(47);
+DECLARE_MSM_GPIO_PINS(48);
+DECLARE_MSM_GPIO_PINS(49);
+DECLARE_MSM_GPIO_PINS(50);
+DECLARE_MSM_GPIO_PINS(51);
+DECLARE_MSM_GPIO_PINS(52);
+DECLARE_MSM_GPIO_PINS(53);
+DECLARE_MSM_GPIO_PINS(54);
+DECLARE_MSM_GPIO_PINS(55);
+DECLARE_MSM_GPIO_PINS(56);
+DECLARE_MSM_GPIO_PINS(57);
+DECLARE_MSM_GPIO_PINS(58);
+DECLARE_MSM_GPIO_PINS(59);
+DECLARE_MSM_GPIO_PINS(60);
+DECLARE_MSM_GPIO_PINS(61);
+DECLARE_MSM_GPIO_PINS(62);
+DECLARE_MSM_GPIO_PINS(63);
+DECLARE_MSM_GPIO_PINS(64);
+DECLARE_MSM_GPIO_PINS(65);
+DECLARE_MSM_GPIO_PINS(66);
+DECLARE_MSM_GPIO_PINS(67);
+DECLARE_MSM_GPIO_PINS(68);
+DECLARE_MSM_GPIO_PINS(69);
+DECLARE_MSM_GPIO_PINS(70);
+DECLARE_MSM_GPIO_PINS(71);
+DECLARE_MSM_GPIO_PINS(72);
+DECLARE_MSM_GPIO_PINS(73);
+DECLARE_MSM_GPIO_PINS(74);
+DECLARE_MSM_GPIO_PINS(75);
+DECLARE_MSM_GPIO_PINS(76);
+DECLARE_MSM_GPIO_PINS(77);
+DECLARE_MSM_GPIO_PINS(78);
+DECLARE_MSM_GPIO_PINS(79);
+DECLARE_MSM_GPIO_PINS(80);
+DECLARE_MSM_GPIO_PINS(81);
+DECLARE_MSM_GPIO_PINS(82);
+DECLARE_MSM_GPIO_PINS(83);
+DECLARE_MSM_GPIO_PINS(84);
+DECLARE_MSM_GPIO_PINS(85);
+DECLARE_MSM_GPIO_PINS(86);
+DECLARE_MSM_GPIO_PINS(87);
+DECLARE_MSM_GPIO_PINS(88);
+DECLARE_MSM_GPIO_PINS(89);
+DECLARE_MSM_GPIO_PINS(90);
+DECLARE_MSM_GPIO_PINS(91);
+DECLARE_MSM_GPIO_PINS(92);
+DECLARE_MSM_GPIO_PINS(93);
+DECLARE_MSM_GPIO_PINS(94);
+DECLARE_MSM_GPIO_PINS(95);
+DECLARE_MSM_GPIO_PINS(96);
+DECLARE_MSM_GPIO_PINS(97);
+DECLARE_MSM_GPIO_PINS(98);
+DECLARE_MSM_GPIO_PINS(99);
+DECLARE_MSM_GPIO_PINS(100);
+DECLARE_MSM_GPIO_PINS(101);
+DECLARE_MSM_GPIO_PINS(102);
+DECLARE_MSM_GPIO_PINS(103);
+DECLARE_MSM_GPIO_PINS(104);
+DECLARE_MSM_GPIO_PINS(105);
+DECLARE_MSM_GPIO_PINS(106);
+DECLARE_MSM_GPIO_PINS(107);
+DECLARE_MSM_GPIO_PINS(108);
+DECLARE_MSM_GPIO_PINS(109);
+DECLARE_MSM_GPIO_PINS(110);
+DECLARE_MSM_GPIO_PINS(111);
+DECLARE_MSM_GPIO_PINS(112);
+DECLARE_MSM_GPIO_PINS(113);
+DECLARE_MSM_GPIO_PINS(114);
+DECLARE_MSM_GPIO_PINS(115);
+DECLARE_MSM_GPIO_PINS(116);
+DECLARE_MSM_GPIO_PINS(117);
+DECLARE_MSM_GPIO_PINS(118);
+
+static const unsigned int ufs_reset_pins[] = { 119 };
+static const unsigned int sdc1_rclk_pins[] = { 120 };
+static const unsigned int sdc1_clk_pins[] = { 121 };
+static const unsigned int sdc1_cmd_pins[] = { 122 };
+static const unsigned int sdc1_data_pins[] = { 123 };
+static const unsigned int sdc2_clk_pins[] = { 124 };
+static const unsigned int sdc2_cmd_pins[] = { 125 };
+static const unsigned int sdc2_data_pins[] = { 126 };
+
+enum sc7180_functions {
+	msm_mux_adsp_ext,
+	msm_mux_agera_pll,
+	msm_mux_aoss_cti,
+	msm_mux_atest_char,
+	msm_mux_atest_char0,
+	msm_mux_atest_char1,
+	msm_mux_atest_char2,
+	msm_mux_atest_char3,
+	msm_mux_atest_tsens,
+	msm_mux_atest_tsens2,
+	msm_mux_atest_usb1,
+	msm_mux_atest_usb2,
+	msm_mux_atest_usb10,
+	msm_mux_atest_usb11,
+	msm_mux_atest_usb12,
+	msm_mux_atest_usb13,
+	msm_mux_atest_usb20,
+	msm_mux_atest_usb21,
+	msm_mux_atest_usb22,
+	msm_mux_atest_usb23,
+	msm_mux_audio_ref,
+	msm_mux_btfm_slimbus,
+	msm_mux_cam_mclk,
+	msm_mux_cci_async,
+	msm_mux_cci_i2c,
+	msm_mux_cci_timer0,
+	msm_mux_cci_timer1,
+	msm_mux_cci_timer2,
+	msm_mux_cci_timer3,
+	msm_mux_cci_timer4,
+	msm_mux_cri_trng,
+	msm_mux_dbg_out,
+	msm_mux_ddr_bist,
+	msm_mux_ddr_pxi0,
+	msm_mux_ddr_pxi1,
+	msm_mux_ddr_pxi2,
+	msm_mux_ddr_pxi3,
+	msm_mux_dp_hot,
+	msm_mux_edp_lcd,
+	msm_mux_gcc_gp1,
+	msm_mux_gcc_gp2,
+	msm_mux_gcc_gp3,
+	msm_mux_gpio,
+	msm_mux_gp_pdm0,
+	msm_mux_gp_pdm1,
+	msm_mux_gp_pdm2,
+	msm_mux_gps_tx,
+	msm_mux_jitter_bist,
+	msm_mux_ldo_en,
+	msm_mux_ldo_update,
+	msm_mux_lpass_ext,
+	msm_mux_mdp_vsync,
+	msm_mux_mdp_vsync0,
+	msm_mux_mdp_vsync1,
+	msm_mux_mdp_vsync2,
+	msm_mux_mdp_vsync3,
+	msm_mux_mi2s_1,
+	msm_mux_mi2s_0,
+	msm_mux_mi2s_2,
+	msm_mux_mss_lte,
+	msm_mux_m_voc,
+	msm_mux_pa_indicator,
+	msm_mux_phase_flag,
+	msm_mux_PLL_BIST,
+	msm_mux_pll_bypassnl,
+	msm_mux_pll_reset,
+	msm_mux_prng_rosc,
+	msm_mux_qdss,
+	msm_mux_qdss_cti,
+	msm_mux_qlink_enable,
+	msm_mux_qlink_request,
+	msm_mux_qspi_clk,
+	msm_mux_qspi_cs,
+	msm_mux_qspi_data,
+	msm_mux_qup00,
+	msm_mux_qup01,
+	msm_mux_qup02,
+	msm_mux_qup03,
+	msm_mux_qup04,
+	msm_mux_qup05,
+	msm_mux_qup10,
+	msm_mux_qup11,
+	msm_mux_qup12,
+	msm_mux_qup13,
+	msm_mux_qup14,
+	msm_mux_qup15,
+	msm_mux_sdc1_tb,
+	msm_mux_sdc2_tb,
+	msm_mux_sd_write,
+	msm_mux_sp_cmu,
+	msm_mux_tgu_ch0,
+	msm_mux_tgu_ch1,
+	msm_mux_tgu_ch2,
+	msm_mux_tgu_ch3,
+	msm_mux_tsense_pwm1,
+	msm_mux_tsense_pwm2,
+	msm_mux_uim1,
+	msm_mux_uim2,
+	msm_mux_uim_batt,
+	msm_mux_usb_phy,
+	msm_mux_vfr_1,
+	msm_mux__V_GPIO,
+	msm_mux__V_PPS_IN,
+	msm_mux__V_PPS_OUT,
+	msm_mux_vsense_trigger,
+	msm_mux_wlan1_adc0,
+	msm_mux_wlan1_adc1,
+	msm_mux_wlan2_adc0,
+	msm_mux_wlan2_adc1,
+	msm_mux__,
+};
+
+static const char * const qup01_groups[] = {
+	"gpio0", "gpio1", "gpio2", "gpio3", "gpio12", "gpio94",
+};
+static const char * const gpio_groups[] = {
+	"gpio0", "gpio1", "gpio2", "gpio3", "gpio4", "gpio5", "gpio6", "gpio7",
+	"gpio8", "gpio9", "gpio10", "gpio11", "gpio12", "gpio13", "gpio14",
+	"gpio15", "gpio16", "gpio17", "gpio18", "gpio19", "gpio20", "gpio21",
+	"gpio22", "gpio23", "gpio24", "gpio25", "gpio26", "gpio27", "gpio28",
+	"gpio29", "gpio30", "gpio31", "gpio32", "gpio33", "gpio34", "gpio35",
+	"gpio36", "gpio37", "gpio38", "gpio39", "gpio40", "gpio41", "gpio42",
+	"gpio43", "gpio44", "gpio45", "gpio46", "gpio47", "gpio48", "gpio49",
+	"gpio50", "gpio51", "gpio52", "gpio53", "gpio54", "gpio55", "gpio56",
+	"gpio57", "gpio58", "gpio59", "gpio60", "gpio61", "gpio62", "gpio63",
+	"gpio64", "gpio65", "gpio66", "gpio67", "gpio68", "gpio69", "gpio70",
+	"gpio71", "gpio72", "gpio73", "gpio74", "gpio75", "gpio76", "gpio77",
+	"gpio78", "gpio79", "gpio80", "gpio81", "gpio82", "gpio83", "gpio84",
+	"gpio85", "gpio86", "gpio87", "gpio88", "gpio89", "gpio90", "gpio91",
+	"gpio92", "gpio93", "gpio94", "gpio95", "gpio96", "gpio97", "gpio98",
+	"gpio99", "gpio100", "gpio101", "gpio102", "gpio103", "gpio104",
+	"gpio105", "gpio106", "gpio107", "gpio108", "gpio109", "gpio110",
+	"gpio111", "gpio112", "gpio113", "gpio114", "gpio115", "gpio116",
+	"gpio117", "gpio118",
+};
+static const char * const phase_flag_groups[] = {
+	"gpio0", "gpio1", "gpio2", "gpio8", "gpio9",
+	"gpio11", "gpio12", "gpio17", "gpio18", "gpio19",
+	"gpio20", "gpio25", "gpio26", "gpio27", "gpio28",
+	"gpio32", "gpio33", "gpio34", "gpio35", "gpio36",
+	"gpio37", "gpio38", "gpio39", "gpio42", "gpio44",
+	"gpio56", "gpio57", "gpio58", "gpio63", "gpio64",
+	"gpio108", "gpio109",
+};
+static const char * const cri_trng_groups[] = {
+	"gpio0", "gpio1", "gpio2",
+};
+static const char * const sp_cmu_groups[] = {
+	"gpio3",
+};
+static const char * const dbg_out_groups[] = {
+	"gpio3",
+};
+static const char * const qdss_cti_groups[] = {
+	"gpio3", "gpio4", "gpio8", "gpio9", "gpio33", "gpio44", "gpio45",
+	"gpio72",
+};
+static const char * const sdc1_tb_groups[] = {
+	"gpio4",
+};
+static const char * const sdc2_tb_groups[] = {
+	"gpio5",
+};
+static const char * const qup11_groups[] = {
+	"gpio6", "gpio7",
+};
+static const char * const ddr_bist_groups[] = {
+	"gpio7", "gpio8", "gpio9", "gpio10",
+};
+static const char * const gp_pdm1_groups[] = {
+	"gpio8", "gpio50",
+};
+static const char * const mdp_vsync_groups[] = {
+	"gpio10", "gpio11", "gpio12", "gpio70", "gpio71",
+};
+static const char * const edp_lcd_groups[] = {
+	"gpio11",
+};
+static const char * const ddr_pxi2_groups[] = {
+	"gpio11", "gpio26",
+};
+static const char * const m_voc_groups[] = {
+	"gpio12",
+};
+static const char * const wlan2_adc0_groups[] = {
+	"gpio12",
+};
+static const char * const atest_usb10_groups[] = {
+	"gpio12",
+};
+static const char * const ddr_pxi3_groups[] = {
+	"gpio12", "gpio108",
+};
+static const char * const cam_mclk_groups[] = {
+	"gpio13", "gpio14", "gpio15", "gpio16", "gpio23",
+};
+static const char * const pll_bypassnl_groups[] = {
+	"gpio13",
+};
+static const char * const qdss_groups[] = {
+	"gpio13", "gpio86", "gpio14", "gpio87",
+	"gpio15", "gpio88", "gpio16", "gpio89",
+	"gpio17", "gpio90", "gpio18", "gpio91",
+	"gpio19", "gpio21", "gpio20", "gpio22",
+	"gpio23", "gpio54", "gpio24", "gpio36",
+	"gpio25", "gpio57", "gpio26", "gpio31",
+	"gpio27", "gpio56", "gpio28", "gpio29",
+	"gpio30", "gpio35", "gpio93", "gpio104",
+	"gpio34", "gpio53", "gpio37", "gpio55",
+};
+static const char * const pll_reset_groups[] = {
+	"gpio14",
+};
+static const char * const qup02_groups[] = {
+	"gpio15", "gpio16",
+};
+static const char * const cci_i2c_groups[] = {
+	"gpio17", "gpio18", "gpio19", "gpio20", "gpio27", "gpio28",
+};
+static const char * const wlan1_adc0_groups[] = {
+	"gpio17",
+};
+static const char * const atest_usb12_groups[] = {
+	"gpio17",
+};
+static const char * const ddr_pxi1_groups[] = {
+	"gpio17", "gpio44",
+};
+static const char * const atest_char_groups[] = {
+	"gpio17",
+};
+static const char * const agera_pll_groups[] = {
+	"gpio18",
+};
+static const char * const vsense_trigger_groups[] = {
+	"gpio18",
+};
+static const char * const ddr_pxi0_groups[] = {
+	"gpio18", "gpio27",
+};
+static const char * const atest_char3_groups[] = {
+	"gpio18",
+};
+static const char * const atest_char2_groups[] = {
+	"gpio19",
+};
+static const char * const atest_char1_groups[] = {
+	"gpio20",
+};
+static const char * const cci_timer0_groups[] = {
+	"gpio21",
+};
+static const char * const gcc_gp2_groups[] = {
+	"gpio21",
+};
+static const char * const atest_char0_groups[] = {
+	"gpio21",
+};
+static const char * const cci_timer1_groups[] = {
+	"gpio22",
+};
+static const char * const gcc_gp3_groups[] = {
+	"gpio22",
+};
+static const char * const cci_timer2_groups[] = {
+	"gpio23",
+};
+static const char * const cci_timer3_groups[] = {
+	"gpio24",
+};
+static const char * const cci_async_groups[] = {
+	"gpio24", "gpio25", "gpio26",
+};
+static const char * const cci_timer4_groups[] = {
+	"gpio25",
+};
+static const char * const qup05_groups[] = {
+	"gpio25", "gpio26", "gpio27", "gpio28",
+};
+static const char * const atest_tsens_groups[] = {
+	"gpio26",
+};
+static const char * const atest_usb11_groups[] = {
+	"gpio26",
+};
+static const char * const PLL_BIST_groups[] = {
+	"gpio27",
+};
+static const char * const sd_write_groups[] = {
+	"gpio33",
+};
+static const char * const qup00_groups[] = {
+	"gpio34", "gpio35", "gpio36", "gpio37",
+};
+static const char * const gp_pdm0_groups[] = {
+	"gpio37", "gpio68",
+};
+static const char * const qup03_groups[] = {
+	"gpio38", "gpio39", "gpio40", "gpio41",
+};
+static const char * const atest_tsens2_groups[] = {
+	"gpio39",
+};
+static const char * const wlan2_adc1_groups[] = {
+	"gpio39",
+};
+static const char * const atest_usb1_groups[] = {
+	"gpio39",
+};
+static const char * const qup12_groups[] = {
+	"gpio42", "gpio43", "gpio44", "gpio45",
+};
+static const char * const wlan1_adc1_groups[] = {
+	"gpio44",
+};
+static const char * const atest_usb13_groups[] = {
+	"gpio44",
+};
+static const char * const qup13_groups[] = {
+	"gpio46", "gpio47",
+};
+static const char * const gcc_gp1_groups[] = {
+	"gpio48", "gpio56",
+};
+static const char * const mi2s_1_groups[] = {
+	"gpio49", "gpio50", "gpio51", "gpio52",
+};
+static const char * const btfm_slimbus_groups[] = {
+	"gpio49", "gpio50", "gpio51", "gpio52",
+};
+static const char * const atest_usb2_groups[] = {
+	"gpio51",
+};
+static const char * const atest_usb23_groups[] = {
+	"gpio52",
+};
+static const char * const mi2s_0_groups[] = {
+	"gpio53", "gpio54", "gpio55", "gpio56",
+};
+static const char * const qup15_groups[] = {
+	"gpio53", "gpio54", "gpio55", "gpio56",
+};
+static const char * const atest_usb22_groups[] = {
+	"gpio53",
+};
+static const char * const atest_usb21_groups[] = {
+	"gpio54",
+};
+static const char * const atest_usb20_groups[] = {
+	"gpio55",
+};
+static const char * const lpass_ext_groups[] = {
+	"gpio57", "gpio58",
+};
+static const char * const audio_ref_groups[] = {
+	"gpio57",
+};
+static const char * const jitter_bist_groups[] = {
+	"gpio57",
+};
+static const char * const gp_pdm2_groups[] = {
+	"gpio57",
+};
+static const char * const qup10_groups[] = {
+	"gpio59", "gpio60", "gpio61", "gpio62", "gpio68", "gpio72",
+};
+static const char * const tgu_ch3_groups[] = {
+	"gpio62",
+};
+static const char * const qspi_clk_groups[] = {
+	"gpio63",
+};
+static const char * const mdp_vsync0_groups[] = {
+	"gpio63",
+};
+static const char * const mi2s_2_groups[] = {
+	"gpio63", "gpio64", "gpio65", "gpio66",
+};
+static const char * const mdp_vsync1_groups[] = {
+	"gpio63",
+};
+static const char * const mdp_vsync2_groups[] = {
+	"gpio63",
+};
+static const char * const mdp_vsync3_groups[] = {
+	"gpio63",
+};
+static const char * const tgu_ch0_groups[] = {
+	"gpio63",
+};
+static const char * const qspi_data_groups[] = {
+	"gpio64", "gpio65", "gpio66", "gpio67",
+};
+static const char * const tgu_ch1_groups[] = {
+	"gpio64",
+};
+static const char * const vfr_1_groups[] = {
+	"gpio65",
+};
+static const char * const tgu_ch2_groups[] = {
+	"gpio65",
+};
+static const char * const qspi_cs_groups[] = {
+	"gpio68", "gpio72",
+};
+static const char * const ldo_en_groups[] = {
+	"gpio70",
+};
+static const char * const ldo_update_groups[] = {
+	"gpio71",
+};
+static const char * const prng_rosc_groups[] = {
+	"gpio72",
+};
+static const char * const uim2_groups[] = {
+	"gpio75", "gpio76", "gpio77", "gpio78",
+};
+static const char * const uim1_groups[] = {
+	"gpio79", "gpio80", "gpio81", "gpio82",
+};
+static const char * const _V_GPIO_groups[] = {
+	"gpio83", "gpio84", "gpio107",
+};
+static const char * const _V_PPS_IN_groups[] = {
+	"gpio83", "gpio84", "gpio107",
+};
+static const char * const _V_PPS_OUT_groups[] = {
+	"gpio83", "gpio84", "gpio107",
+};
+static const char * const gps_tx_groups[] = {
+	"gpio83", "gpio84", "gpio107", "gpio109",
+};
+static const char * const uim_batt_groups[] = {
+	"gpio85",
+};
+static const char * const dp_hot_groups[] = {
+	"gpio85", "gpio117",
+};
+static const char * const aoss_cti_groups[] = {
+	"gpio85",
+};
+static const char * const qup14_groups[] = {
+	"gpio86", "gpio87", "gpio88", "gpio89", "gpio90", "gpio91",
+};
+static const char * const adsp_ext_groups[] = {
+	"gpio87",
+};
+static const char * const tsense_pwm1_groups[] = {
+	"gpio88",
+};
+static const char * const tsense_pwm2_groups[] = {
+	"gpio88",
+};
+static const char * const qlink_request_groups[] = {
+	"gpio96",
+};
+static const char * const qlink_enable_groups[] = {
+	"gpio97",
+};
+static const char * const pa_indicator_groups[] = {
+	"gpio99",
+};
+static const char * const usb_phy_groups[] = {
+	"gpio104",
+};
+static const char * const mss_lte_groups[] = {
+	"gpio108", "gpio109",
+};
+static const char * const qup04_groups[] = {
+	"gpio115", "gpio116",
+};
+
+static const struct msm_function sc7180_functions[] = {
+	FUNCTION(adsp_ext),
+	FUNCTION(agera_pll),
+	FUNCTION(aoss_cti),
+	FUNCTION(atest_char),
+	FUNCTION(atest_char0),
+	FUNCTION(atest_char1),
+	FUNCTION(atest_char2),
+	FUNCTION(atest_char3),
+	FUNCTION(atest_tsens),
+	FUNCTION(atest_tsens2),
+	FUNCTION(atest_usb1),
+	FUNCTION(atest_usb2),
+	FUNCTION(atest_usb10),
+	FUNCTION(atest_usb11),
+	FUNCTION(atest_usb12),
+	FUNCTION(atest_usb13),
+	FUNCTION(atest_usb20),
+	FUNCTION(atest_usb21),
+	FUNCTION(atest_usb22),
+	FUNCTION(atest_usb23),
+	FUNCTION(audio_ref),
+	FUNCTION(btfm_slimbus),
+	FUNCTION(cam_mclk),
+	FUNCTION(cci_async),
+	FUNCTION(cci_i2c),
+	FUNCTION(cci_timer0),
+	FUNCTION(cci_timer1),
+	FUNCTION(cci_timer2),
+	FUNCTION(cci_timer3),
+	FUNCTION(cci_timer4),
+	FUNCTION(cri_trng),
+	FUNCTION(dbg_out),
+	FUNCTION(ddr_bist),
+	FUNCTION(ddr_pxi0),
+	FUNCTION(ddr_pxi1),
+	FUNCTION(ddr_pxi2),
+	FUNCTION(ddr_pxi3),
+	FUNCTION(dp_hot),
+	FUNCTION(edp_lcd),
+	FUNCTION(gcc_gp1),
+	FUNCTION(gcc_gp2),
+	FUNCTION(gcc_gp3),
+	FUNCTION(gpio),
+	FUNCTION(gp_pdm0),
+	FUNCTION(gp_pdm1),
+	FUNCTION(gp_pdm2),
+	FUNCTION(gps_tx),
+	FUNCTION(jitter_bist),
+	FUNCTION(ldo_en),
+	FUNCTION(ldo_update),
+	FUNCTION(lpass_ext),
+	FUNCTION(mdp_vsync),
+	FUNCTION(mdp_vsync0),
+	FUNCTION(mdp_vsync1),
+	FUNCTION(mdp_vsync2),
+	FUNCTION(mdp_vsync3),
+	FUNCTION(mi2s_0),
+	FUNCTION(mi2s_1),
+	FUNCTION(mi2s_2),
+	FUNCTION(mss_lte),
+	FUNCTION(m_voc),
+	FUNCTION(pa_indicator),
+	FUNCTION(phase_flag),
+	FUNCTION(PLL_BIST),
+	FUNCTION(pll_bypassnl),
+	FUNCTION(pll_reset),
+	FUNCTION(prng_rosc),
+	FUNCTION(qdss),
+	FUNCTION(qdss_cti),
+	FUNCTION(qlink_enable),
+	FUNCTION(qlink_request),
+	FUNCTION(qspi_clk),
+	FUNCTION(qspi_cs),
+	FUNCTION(qspi_data),
+	FUNCTION(qup00),
+	FUNCTION(qup01),
+	FUNCTION(qup02),
+	FUNCTION(qup03),
+	FUNCTION(qup04),
+	FUNCTION(qup05),
+	FUNCTION(qup10),
+	FUNCTION(qup11),
+	FUNCTION(qup12),
+	FUNCTION(qup13),
+	FUNCTION(qup14),
+	FUNCTION(qup15),
+	FUNCTION(sdc1_tb),
+	FUNCTION(sdc2_tb),
+	FUNCTION(sd_write),
+	FUNCTION(sp_cmu),
+	FUNCTION(tgu_ch0),
+	FUNCTION(tgu_ch1),
+	FUNCTION(tgu_ch2),
+	FUNCTION(tgu_ch3),
+	FUNCTION(tsense_pwm1),
+	FUNCTION(tsense_pwm2),
+	FUNCTION(uim1),
+	FUNCTION(uim2),
+	FUNCTION(uim_batt),
+	FUNCTION(usb_phy),
+	FUNCTION(vfr_1),
+	FUNCTION(_V_GPIO),
+	FUNCTION(_V_PPS_IN),
+	FUNCTION(_V_PPS_OUT),
+	FUNCTION(vsense_trigger),
+	FUNCTION(wlan1_adc0),
+	FUNCTION(wlan1_adc1),
+	FUNCTION(wlan2_adc0),
+	FUNCTION(wlan2_adc1),
+};
+
+/* Every pin is maintained as a single group, and missing or non-existing pin
+ * would be maintained as dummy group to synchronize pin group index with
+ * pin descriptor registered with pinctrl core.
+ * Clients would not be able to request these dummy pin groups.
+ */
+static const struct msm_pingroup sc7180_groups[] = {
+	[0] = PINGROUP(0, SOUTH, qup01, cri_trng, _, phase_flag, _, _, _, _, _),
+	[1] = PINGROUP(1, SOUTH, qup01, cri_trng, _, phase_flag, _, _, _, _, _),
+	[2] = PINGROUP(2, SOUTH, qup01, cri_trng, _, phase_flag, _, _, _, _, _),
+	[3] = PINGROUP(3, SOUTH, qup01, sp_cmu, dbg_out, qdss_cti, _, _, _, _, _),
+	[4] = PINGROUP(4, NORTH, sdc1_tb, _, qdss_cti, _, _, _, _, _, _),
+	[5] = PINGROUP(5, NORTH, sdc2_tb, _, _, _, _, _, _, _, _),
+	[6] = PINGROUP(6, NORTH, qup11, qup11, _, _, _, _, _, _, _),
+	[7] = PINGROUP(7, NORTH, qup11, qup11, ddr_bist, _, _, _, _, _, _),
+	[8] = PINGROUP(8, NORTH, gp_pdm1, ddr_bist, _, phase_flag, qdss_cti, _, _, _, _),
+	[9] = PINGROUP(9, NORTH, ddr_bist, _, phase_flag, qdss_cti, _, _, _, _, _),
+	[10] = PINGROUP(10, NORTH, mdp_vsync, ddr_bist, _, _, _, _, _, _, _),
+	[11] = PINGROUP(11, NORTH, mdp_vsync, edp_lcd, _, phase_flag, ddr_pxi2, _, _, _, _),
+	[12] = PINGROUP(12, SOUTH, mdp_vsync, m_voc, qup01, _, phase_flag, wlan2_adc0, atest_usb10, ddr_pxi3, _),
+	[13] = PINGROUP(13, SOUTH, cam_mclk, pll_bypassnl, qdss, _, _, _, _, _, _),
+	[14] = PINGROUP(14, SOUTH, cam_mclk, pll_reset, qdss, _, _, _, _, _, _),
+	[15] = PINGROUP(15, SOUTH, cam_mclk, qup02, qup02, qdss, _, _, _, _, _),
+	[16] = PINGROUP(16, SOUTH, cam_mclk, qup02, qup02, qdss, _, _, _, _, _),
+	[17] = PINGROUP(17, SOUTH, cci_i2c, _, phase_flag, qdss, _, wlan1_adc0, atest_usb12, ddr_pxi1, atest_char),
+	[18] = PINGROUP(18, SOUTH, cci_i2c, agera_pll, _, phase_flag, qdss, vsense_trigger, ddr_pxi0, atest_char3, _),
+	[19] = PINGROUP(19, SOUTH, cci_i2c, _, phase_flag, qdss, atest_char2, _, _, _, _),
+	[20] = PINGROUP(20, SOUTH, cci_i2c, _, phase_flag, qdss, atest_char1, _, _, _, _),
+	[21] = PINGROUP(21, NORTH, cci_timer0, gcc_gp2, _, qdss, atest_char0, _, _, _, _),
+	[22] = PINGROUP(22, NORTH, cci_timer1, gcc_gp3, _, qdss, _, _, _, _, _),
+	[23] = PINGROUP(23, SOUTH, cci_timer2, cam_mclk, qdss, _, _, _, _, _, _),
+	[24] = PINGROUP(24, SOUTH, cci_timer3, cci_async, qdss, _, _, _, _, _, _),
+	[25] = PINGROUP(25, SOUTH, cci_timer4, cci_async, qup05, _, phase_flag, qdss, _, _, _),
+	[26] = PINGROUP(26, SOUTH, cci_async, qup05, _, phase_flag, qdss, atest_tsens, atest_usb11, ddr_pxi2, _),
+	[27] = PINGROUP(27, SOUTH, cci_i2c, qup05, PLL_BIST, _, phase_flag, qdss, ddr_pxi0, _, _),
+	[28] = PINGROUP(28, SOUTH, cci_i2c, qup05, _, phase_flag, qdss, _, _, _, _),
+	[29] = PINGROUP(29, NORTH, _, qdss, _, _, _, _, _, _, _),
+	[30] = PINGROUP(30, SOUTH, qdss, _, _, _, _, _, _, _, _),
+	[31] = PINGROUP(31, NORTH, _, qdss, _, _, _, _, _, _, _),
+	[32] = PINGROUP(32, NORTH, _, phase_flag, _, _, _, _, _, _, _),
+	[33] = PINGROUP(33, NORTH, sd_write, _, phase_flag, qdss_cti, _, _, _, _, _),
+	[34] = PINGROUP(34, SOUTH, qup00, _, phase_flag, qdss, _, _, _, _, _),
+	[35] = PINGROUP(35, SOUTH, qup00, _, phase_flag, qdss, _, _, _, _, _),
+	[36] = PINGROUP(36, SOUTH, qup00, _, phase_flag, qdss, _, _, _, _, _),
+	[37] = PINGROUP(37, SOUTH, qup00, gp_pdm0, _, phase_flag, qdss, _, _, _, _),
+	[38] = PINGROUP(38, SOUTH, qup03, _, phase_flag, _, _, _, _, _, _),
+	[39] = PINGROUP(39, SOUTH, qup03, _, phase_flag, atest_tsens2, wlan2_adc1, atest_usb1, _, _, _),
+	[40] = PINGROUP(40, SOUTH, qup03, _, _, _, _, _, _, _, _),
+	[41] = PINGROUP(41, SOUTH, qup03, _, _, _, _, _, _, _, _),
+	[42] = PINGROUP(42, NORTH, qup12, _, phase_flag, _, _, _, _, _, _),
+	[43] = PINGROUP(43, NORTH, qup12, _, _, _, _, _, _, _, _),
+	[44] = PINGROUP(44, NORTH, qup12, _, phase_flag, qdss_cti, wlan1_adc1, atest_usb13, ddr_pxi1, _, _),
+	[45] = PINGROUP(45, NORTH, qup12, qdss_cti, _, _, _, _, _, _, _),
+	[46] = PINGROUP(46, NORTH, qup13, qup13, _, _, _, _, _, _, _),
+	[47] = PINGROUP(47, NORTH, qup13, qup13, _, _, _, _, _, _, _),
+	[48] = PINGROUP(48, NORTH, gcc_gp1, _, _, _, _, _, _, _, _),
+	[49] = PINGROUP(49, WEST, mi2s_1, btfm_slimbus, _, _, _, _, _, _, _),
+	[50] = PINGROUP(50, WEST, mi2s_1, btfm_slimbus, gp_pdm1, _, _, _, _, _, _),
+	[51] = PINGROUP(51, WEST, mi2s_1, btfm_slimbus, atest_usb2, _, _, _, _, _, _),
+	[52] = PINGROUP(52, WEST, mi2s_1, btfm_slimbus, atest_usb23, _, _, _, _, _, _),
+	[53] = PINGROUP(53, WEST, mi2s_0, qup15, qdss, atest_usb22, _, _, _, _, _),
+	[54] = PINGROUP(54, WEST, mi2s_0, qup15, qdss, atest_usb21, _, _, _, _, _),
+	[55] = PINGROUP(55, WEST, mi2s_0, qup15, qdss, atest_usb20, _, _, _, _, _),
+	[56] = PINGROUP(56, WEST, mi2s_0, qup15, gcc_gp1, _, phase_flag, qdss, _, _, _),
+	[57] = PINGROUP(57, WEST, lpass_ext, audio_ref, jitter_bist, gp_pdm2, _, phase_flag, qdss, _, _),
+	[58] = PINGROUP(58, WEST, lpass_ext, _, phase_flag, _, _, _, _, _, _),
+	[59] = PINGROUP(59, NORTH, qup10, _, _, _, _, _, _, _, _),
+	[60] = PINGROUP(60, NORTH, qup10, _, _, _, _, _, _, _, _),
+	[61] = PINGROUP(61, NORTH, qup10, _, _, _, _, _, _, _, _),
+	[62] = PINGROUP(62, NORTH, qup10, tgu_ch3, _, _, _, _, _, _, _),
+	[63] = PINGROUP(63, NORTH, qspi_clk, mdp_vsync0, mi2s_2, mdp_vsync1, mdp_vsync2, mdp_vsync3, tgu_ch0, _, phase_flag),
+	[64] = PINGROUP(64, NORTH, qspi_data, mi2s_2, tgu_ch1, _, phase_flag, _, _, _, _),
+	[65] = PINGROUP(65, NORTH, qspi_data, mi2s_2, vfr_1, tgu_ch2, _, _, _, _, _),
+	[66] = PINGROUP(66, NORTH, qspi_data, mi2s_2, _, _, _, _, _, _, _),
+	[67] = PINGROUP(67, NORTH, qspi_data, _, _, _, _, _, _, _, _),
+	[68] = PINGROUP(68, NORTH, qspi_cs, qup10, gp_pdm0, _, _, _, _, _, _),
+	[69] = PINGROUP(69, WEST, _, _, _, _, _, _, _, _, _),
+	[70] = PINGROUP(70, NORTH, _, _, mdp_vsync, ldo_en, _, _, _, _, _),
+	[71] = PINGROUP(71, NORTH, _, mdp_vsync, ldo_update, _, _, _, _, _, _),
+	[72] = PINGROUP(72, NORTH, qspi_cs, qup10, prng_rosc, _, qdss_cti, _, _, _, _),
+	[73] = PINGROUP(73, WEST, _, _, _, _, _, _, _, _, _),
+	[74] = PINGROUP(74, WEST, _, _, _, _, _, _, _, _, _),
+	[75] = PINGROUP(75, WEST, uim2, _, _, _, _, _, _, _, _),
+	[76] = PINGROUP(76, WEST, uim2, _, _, _, _, _, _, _, _),
+	[77] = PINGROUP(77, WEST, uim2, _, _, _, _, _, _, _, _),
+	[78] = PINGROUP(78, WEST, uim2, _, _, _, _, _, _, _, _),
+	[79] = PINGROUP(79, WEST, uim1, _, _, _, _, _, _, _, _),
+	[80] = PINGROUP(80, WEST, uim1, _, _, _, _, _, _, _, _),
+	[81] = PINGROUP(81, WEST, uim1, _, _, _, _, _, _, _, _),
+	[82] = PINGROUP(82, WEST, uim1, _, _, _, _, _, _, _, _),
+	[83] = PINGROUP(83, WEST, _, _V_GPIO, _V_PPS_IN, _V_PPS_OUT, gps_tx, _, _, _, _),
+	[84] = PINGROUP(84, WEST, _, _V_GPIO, _V_PPS_IN, _V_PPS_OUT, gps_tx, _, _, _, _),
+	[85] = PINGROUP(85, WEST, uim_batt, dp_hot, aoss_cti, _, _, _, _, _, _),
+	[86] = PINGROUP(86, NORTH, qup14, qdss, _, _, _, _, _, _, _),
+	[87] = PINGROUP(87, NORTH, qup14, adsp_ext, qdss, _, _, _, _, _, _),
+	[88] = PINGROUP(88, NORTH, qup14, qdss, tsense_pwm1, tsense_pwm2, _, _, _, _, _),
+	[89] = PINGROUP(89, NORTH, qup14, qdss, _, _, _, _, _, _, _),
+	[90] = PINGROUP(90, NORTH, qup14, qdss, _, _, _, _, _, _, _),
+	[91] = PINGROUP(91, NORTH, qup14, qdss, _, _, _, _, _, _, _),
+	[92] = PINGROUP(92, NORTH, _, _, _, _, _, _, _, _, _),
+	[93] = PINGROUP(93, NORTH, qdss, _, _, _, _, _, _, _, _),
+	[94] = PINGROUP(94, SOUTH, qup01, _, _, _, _, _, _, _, _),
+	[95] = PINGROUP(95, WEST, _, _, _, _, _, _, _, _, _),
+	[96] = PINGROUP(96, WEST, qlink_request, _, _, _, _, _, _, _, _),
+	[97] = PINGROUP(97, WEST, qlink_enable, _, _, _, _, _, _, _, _),
+	[98] = PINGROUP(98, WEST, _, _, _, _, _, _, _, _, _),
+	[99] = PINGROUP(99, WEST, _, pa_indicator, _, _, _, _, _, _, _),
+	[100] = PINGROUP(100, WEST, _, _, _, _, _, _, _, _, _),
+	[101] = PINGROUP(101, NORTH, _, _, _, _, _, _, _, _, _),
+	[102] = PINGROUP(102, NORTH, _, _, _, _, _, _, _, _, _),
+	[103] = PINGROUP(103, NORTH, _, _, _, _, _, _, _, _, _),
+	[104] = PINGROUP(104, WEST, usb_phy, _, qdss, _, _, _, _, _, _),
+	[105] = PINGROUP(105, NORTH, _, _, _, _, _, _, _, _, _),
+	[106] = PINGROUP(106, NORTH, _, _, _, _, _, _, _, _, _),
+	[107] = PINGROUP(107, WEST, _, _V_GPIO, _V_PPS_IN, _V_PPS_OUT, gps_tx, _, _, _, _),
+	[108] = PINGROUP(108, SOUTH, mss_lte, _, phase_flag, ddr_pxi3, _, _, _, _, _),
+	[109] = PINGROUP(109, SOUTH, mss_lte, gps_tx, _, phase_flag, _, _, _, _, _),
+	[110] = PINGROUP(110, NORTH, _, _, _, _, _, _, _, _, _),
+	[111] = PINGROUP(111, NORTH, _, _, _, _, _, _, _, _, _),
+	[112] = PINGROUP(112, NORTH, _, _, _, _, _, _, _, _, _),
+	[113] = PINGROUP(113, NORTH, _, _, _, _, _, _, _, _, _),
+	[114] = PINGROUP(114, NORTH, _, _, _, _, _, _, _, _, _),
+	[115] = PINGROUP(115, WEST, qup04, qup04, _, _, _, _, _, _, _),
+	[116] = PINGROUP(116, WEST, qup04, qup04, _, _, _, _, _, _, _),
+	[117] = PINGROUP(117, WEST, dp_hot, _, _, _, _, _, _, _, _),
+	[118] = PINGROUP(118, WEST, _, _, _, _, _, _, _, _, _),
+	[119] = UFS_RESET(ufs_reset, 0x97f000),
+	[120] = SDC_QDSD_PINGROUP(sdc1_rclk, 0x97a000, 15, 0),
+	[121] = SDC_QDSD_PINGROUP(sdc1_clk, 0x97a000, 13, 6),
+	[122] = SDC_QDSD_PINGROUP(sdc1_cmd, 0x97a000, 11, 3),
+	[123] = SDC_QDSD_PINGROUP(sdc1_data, 0x97a000, 9, 0),
+	[124] = SDC_QDSD_PINGROUP(sdc2_clk, 0x97b000, 14, 6),
+	[125] = SDC_QDSD_PINGROUP(sdc2_cmd, 0x97b000, 11, 3),
+	[126] = SDC_QDSD_PINGROUP(sdc2_data, 0x97b000, 9, 0),
+};
+
+static const struct msm_pinctrl_soc_data sc7180_pinctrl = {
+	.pins = sc7180_pins,
+	.npins = ARRAY_SIZE(sc7180_pins),
+	.functions = sc7180_functions,
+	.nfunctions = ARRAY_SIZE(sc7180_functions),
+	.groups = sc7180_groups,
+	.ngroups = ARRAY_SIZE(sc7180_groups),
+	.ngpios = 120,
+	.tiles = sc7180_tiles,
+	.ntiles = ARRAY_SIZE(sc7180_tiles),
+};
+
+static int sc7180_pinctrl_probe(struct platform_device *pdev)
+{
+	return msm_pinctrl_probe(pdev, &sc7180_pinctrl);
+}
+
+static const struct of_device_id sc7180_pinctrl_of_match[] = {
+	{ .compatible = "qcom,sc7180-pinctrl", },
+	{ },
+};
+
+static struct platform_driver sc7180_pinctrl_driver = {
+	.driver = {
+		.name = "sc7180-pinctrl",
+		.pm = &msm_pinctrl_dev_pm_ops,
+		.of_match_table = sc7180_pinctrl_of_match,
+	},
+	.probe = sc7180_pinctrl_probe,
+	.remove = msm_pinctrl_remove,
+};
+
+static int __init sc7180_pinctrl_init(void)
+{
+	return platform_driver_register(&sc7180_pinctrl_driver);
+}
+arch_initcall(sc7180_pinctrl_init);
+
+static void __exit sc7180_pinctrl_exit(void)
+{
+	platform_driver_unregister(&sc7180_pinctrl_driver);
+}
+module_exit(sc7180_pinctrl_exit);
+
+MODULE_DESCRIPTION("QTI sc7180 pinctrl driver");
+MODULE_LICENSE("GPL v2");
+MODULE_DEVICE_TABLE(of, sc7180_pinctrl_of_match);
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


^ permalink raw reply related

* Re: [PATCH 1/2] dt-bindings: pinctrl: qcom: Add SC7180 pinctrl binding
From: Rajendra Nayak @ 2019-08-06  6:09 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Bjorn Andersson, MSM, Andy Gross, Rob Herring,
	open list:GPIO SUBSYSTEM,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linux-kernel@vger.kernel.org, Jitendra Sharma, Vivek Gautam
In-Reply-To: <CACRpkdaoOuyUmysb3OmErbLJ6zZuHGGt7RRzG9wULDkg=hLCAw@mail.gmail.com>



On 8/5/2019 5:05 PM, Linus Walleij wrote:
> On Mon, Aug 5, 2019 at 1:34 PM Linus Walleij <linus.walleij@linaro.org> wrote:
>> On Thu, Aug 1, 2019 at 12:07 PM Rajendra Nayak <rnayak@codeaurora.org> wrote:
>>
>>> From: Jitendra Sharma <shajit@codeaurora.org>
>>>
>>> Add the binding for the TLMM pinctrl block found in the SC7180 platform
>>>
>>> Signed-off-by: Jitendra Sharma <shajit@codeaurora.org>
>>> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
>>> [rnayak: Fix some copy-paste issues, sort and fix functions]
>>> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
>>
>> Patch applied with Bjorn's ACK.
> 
> Ooops there is v2 and even v3 coming, OK I wait for v3 and
> backed this out.

Hi Linus, I just posted the v3 out with all the ACKs added.
They should be good to pick up now.
thanks,
Rajendra

> 
> Yours,
> Linus Walleij
> 

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation

^ permalink raw reply

* [gpio:gpio-descriptors-spi 5/5] drivers/spi/spi-pl022.c:1852:4: error: implicit declaration of function 'of_property_read_u32'; did you mean '__percpu_read_32'?
From: kbuild test robot @ 2019-08-06  6:24 UTC (permalink / raw)
  To: Linus Walleij; +Cc: kbuild-all, linux-gpio

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=unknown-8bit, Size: 80576 bytes --]

tree:   https://kernel.googlesource.com/pub/scm/linux/kernel/git/linusw/linux-gpio.git gpio-descriptors-spi
head:   6e5614b6476001adb8ce6e2859bc2ca0a4339398
commit: 6e5614b6476001adb8ce6e2859bc2ca0a4339398 [5/5] slask
config: arm64-allmodconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 6e5614b6476001adb8ce6e2859bc2ca0a4339398
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=arm64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/linux/bitops.h:5:0,
                    from include/linux/kernel.h:12,
                    from include/linux/list.h:9,
                    from include/linux/module.h:9,
                    from drivers/spi/spi-pl022.c:17:
   drivers/spi/spi-pl022.c: In function 'pl022_set_cs':
   drivers/spi/spi-pl022.c:442:22: error: 'struct pl022' has no member named 'cur_cs'; did you mean 'cur_msg'?
      tmp &= ~BIT(pl022->cur_cs);
                         ^
   include/linux/bits.h:8:30: note: in definition of macro 'BIT'
    #define BIT(nr)   (UL(1) << (nr))
                                 ^~
   drivers/spi/spi-pl022.c:444:21: error: 'struct pl022' has no member named 'cur_cs'; did you mean 'cur_msg'?
      tmp |= BIT(pl022->cur_cs);
                        ^
   include/linux/bits.h:8:30: note: in definition of macro 'BIT'
    #define BIT(nr)   (UL(1) << (nr))
                                 ^~
   drivers/spi/spi-pl022.c: In function 'giveback':
   drivers/spi/spi-pl022.c:493:4: error: implicit declaration of function 'pl022_cs_control'; did you mean 'pl022_set_cs'? [-Werror=implicit-function-declaration]
       pl022_cs_control(pl022, SSP_CHIP_DESELECT);
       ^~~~~~~~~~~~~~~~
       pl022_set_cs
   drivers/spi/spi-pl022.c: In function 'pl022_transfer_one_message':
   drivers/spi/spi-pl022.c:1571:9: error: 'struct pl022' has no member named 'cur_cs'; did you mean 'cur_msg'?
     pl022->cur_cs = pl022->chipselects[msg->spi->chip_select];
            ^~~~~~
            cur_msg
   drivers/spi/spi-pl022.c:1571:23: error: 'struct pl022' has no member named 'chipselects'
     pl022->cur_cs = pl022->chipselects[msg->spi->chip_select];
                          ^~
   drivers/spi/spi-pl022.c: In function 'pl022_setup':
>> drivers/spi/spi-pl022.c:1852:4: error: implicit declaration of function 'of_property_read_u32'; did you mean '__percpu_read_32'? [-Werror=implicit-function-declaration]
       of_property_read_u32(np, "pl022,interface",
       ^~~~~~~~~~~~~~~~~~~~
       __percpu_read_32
   drivers/spi/spi-pl022.c:1914:7: error: implicit declaration of function 'gpio_is_valid'; did you mean 'uuid_is_valid'? [-Werror=implicit-function-declaration]
     if (!gpio_is_valid(pl022->chipselects[spi->chip_select]))
          ^~~~~~~~~~~~~
          uuid_is_valid
   drivers/spi/spi-pl022.c:1914:26: error: 'struct pl022' has no member named 'chipselects'
     if (!gpio_is_valid(pl022->chipselects[spi->chip_select]))
                             ^~
   drivers/spi/spi-pl022.c: In function 'pl022_platform_data_dt_get':
   drivers/spi/spi-pl022.c:2081:11: error: implicit declaration of function 'of_property_read_bool' [-Werror=implicit-function-declaration]
     pd->rt = of_property_read_bool(np, "pl022,rt");
              ^~~~~~~~~~~~~~~~~~~~~
   drivers/spi/spi-pl022.c: In function 'pl022_probe':
   drivers/spi/spi-pl022.c:2125:7: error: 'struct pl022' has no member named 'chipselects'
     pl022->chipselects = devm_kcalloc(dev, num_cs, sizeof(int),
          ^~
   drivers/spi/spi-pl022.c:2127:12: error: 'struct pl022' has no member named 'chipselects'
     if (!pl022->chipselects) {
               ^~
   drivers/spi/spi-pl022.c:2137:8: warning: statement with no effect [-Wunused-value]
     master->use_gpio_descriptors;
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
   drivers/spi/spi-pl022.c:2150:9: error: 'struct pl022' has no member named 'chipselects'
       pl022->chipselects[i] = i;
            ^~
   drivers/spi/spi-pl022.c:2153:18: error: implicit declaration of function 'of_get_named_gpio'; did you mean 'fwnode_get_named_gpiod'? [-Werror=implicit-function-declaration]
       int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
                     ^~~~~~~~~~~~~~~~~
                     fwnode_get_named_gpiod
   drivers/spi/spi-pl022.c:2160:9: error: 'struct pl022' has no member named 'chipselects'
       pl022->chipselects[i] = cs_gpio;
            ^~
   drivers/spi/spi-pl022.c:2163:9: error: implicit declaration of function 'devm_gpio_request'; did you mean 'devm_gpiod_put'? [-Werror=implicit-function-declaration]
        if (devm_gpio_request(dev, cs_gpio, "ssp-pl022"))
            ^~~~~~~~~~~~~~~~~
            devm_gpiod_put
   drivers/spi/spi-pl022.c:2167:14: error: implicit declaration of function 'gpio_direction_output'; did you mean 'gpiod_direction_output'? [-Werror=implicit-function-declaration]
        else if (gpio_direction_output(cs_gpio, 1))
                 ^~~~~~~~~~~~~~~~~~~~~
                 gpiod_direction_output
   cc1: some warnings being treated as errors

vim +1852 drivers/spi/spi-pl022.c

f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1805  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1806  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1807   * pl022_setup - setup function registered to SPI master framework
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1808   * @spi: spi device which is requesting setup
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1809   *
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1810   * This function is registered to the SPI framework for this SPI master
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1811   * controller. If it is the first time when setup is called by this device,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1812   * this function will initialize the runtime state for this chip and save
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1813   * the same in the device structure. Else it will update the runtime info
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1814   * with the updated chip info. Nothing is really being written to the
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1815   * controller hardware here, that is not done until the actual transfer
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1816   * commence.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1817   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1818  static int pl022_setup(struct spi_device *spi)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1819  {
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1820  	struct pl022_config_chip const *chip_info;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1821  	struct pl022_config_chip chip_info_dt;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1822  	struct chip_data *chip;
c4a4784308f5cb8 drivers/spi/spi-pl022.c  Jonas Aaberg             2011-02-28  1823  	struct ssp_clock_params clk_freq = { .cpsdvsr = 0, .scr = 0};
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1824  	int status = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1825  	struct pl022 *pl022 = spi_master_get_devdata(spi->master);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1826  	unsigned int bits = spi->bits_per_word;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1827  	u32 tmp;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1828  	struct device_node *np = spi->dev.of_node;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1829  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1830  	if (!spi->max_speed_hz)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1831  		return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1832  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1833  	/* Get controller_state if one is supplied */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1834  	chip = spi_get_ctldata(spi);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1835  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1836  	if (chip == NULL) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1837  		chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
77538f4a98dc542 drivers/spi/spi-pl022.c  Jingoo Han               2014-04-29  1838  		if (!chip)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1839  			return -ENOMEM;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1840  		dev_dbg(&spi->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1841  			"allocated memory for controller's runtime state\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1842  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1843  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1844  	/* Get controller data if one is supplied */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1845  	chip_info = spi->controller_data;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1846  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1847  	if (chip_info == NULL) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1848  		if (np) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1849  			chip_info_dt = pl022_default_chip_info;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1850  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1851  			chip_info_dt.hierarchy = SSP_MASTER;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22 @1852  			of_property_read_u32(np, "pl022,interface",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1853  				&chip_info_dt.iface);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1854  			of_property_read_u32(np, "pl022,com-mode",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1855  				&chip_info_dt.com_mode);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1856  			of_property_read_u32(np, "pl022,rx-level-trig",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1857  				&chip_info_dt.rx_lev_trig);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1858  			of_property_read_u32(np, "pl022,tx-level-trig",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1859  				&chip_info_dt.tx_lev_trig);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1860  			of_property_read_u32(np, "pl022,ctrl-len",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1861  				&chip_info_dt.ctrl_len);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1862  			of_property_read_u32(np, "pl022,wait-state",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1863  				&chip_info_dt.wait_state);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1864  			of_property_read_u32(np, "pl022,duplex",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1865  				&chip_info_dt.duplex);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1866  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1867  			chip_info = &chip_info_dt;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1868  		} else {
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1869  			chip_info = &pl022_default_chip_info;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1870  			/* spi_board_info.controller_data not is supplied */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1871  			dev_dbg(&spi->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1872  				"using default controller_data settings\n");
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1873  		}
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1874  	} else
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1875  		dev_dbg(&spi->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1876  			"using user supplied controller_data settings\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1877  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1878  	/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1879  	 * We can override with custom divisors, else we use the board
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1880  	 * frequency setting
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1881  	 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1882  	if ((0 == chip_info->clk_freq.cpsdvsr)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1883  	    && (0 == chip_info->clk_freq.scr)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1884  		status = calculate_effective_freq(pl022,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1885  						  spi->max_speed_hz,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1886  						  &clk_freq);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1887  		if (status < 0)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1888  			goto err_config_params;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1889  	} else {
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1890  		memcpy(&clk_freq, &chip_info->clk_freq, sizeof(clk_freq));
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1891  		if ((clk_freq.cpsdvsr % 2) != 0)
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1892  			clk_freq.cpsdvsr =
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1893  				clk_freq.cpsdvsr - 1;
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1894  	}
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1895  	if ((clk_freq.cpsdvsr < CPSDVR_MIN)
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1896  	    || (clk_freq.cpsdvsr > CPSDVR_MAX)) {
e3f88ae99609205 drivers/spi/amba-pl022.c Virupax Sadashivpetimath 2011-06-13  1897  		status = -EINVAL;
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1898  		dev_err(&spi->dev,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1899  			"cpsdvsr is configured incorrectly\n");
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1900  		goto err_config_params;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1901  	}
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1902  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1903  	status = verify_controller_parameters(pl022, chip_info);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1904  	if (status) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1905  		dev_err(&spi->dev, "controller data is incorrect");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1906  		goto err_config_params;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1907  	}
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1908  
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1909  	pl022->rx_lev_trig = chip_info->rx_lev_trig;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1910  	pl022->tx_lev_trig = chip_info->tx_lev_trig;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1911  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1912  	/* Now set controller state based on controller data */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1913  	chip->xfer_type = chip_info->com_mode;
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1914  	if (!gpio_is_valid(pl022->chipselects[spi->chip_select]))
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1915  		dev_warn(&spi->dev,
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1916  			 "invalid chip select\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1917  
eb798c641a34ae9 drivers/spi/spi-pl022.c  Vinit Shenoy             2012-04-17  1918  	/* Check bits per word with vendor specific range */
eb798c641a34ae9 drivers/spi/spi-pl022.c  Vinit Shenoy             2012-04-17  1919  	if ((bits <= 3) || (bits > pl022->vendor->max_bpw)) {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1920  		status = -ENOTSUPP;
eb798c641a34ae9 drivers/spi/spi-pl022.c  Vinit Shenoy             2012-04-17  1921  		dev_err(&spi->dev, "illegal data size for this controller!\n");
eb798c641a34ae9 drivers/spi/spi-pl022.c  Vinit Shenoy             2012-04-17  1922  		dev_err(&spi->dev, "This controller can only handle 4 <= n <= %d bit words\n",
eb798c641a34ae9 drivers/spi/spi-pl022.c  Vinit Shenoy             2012-04-17  1923  				pl022->vendor->max_bpw);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1924  		goto err_config_params;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1925  	} else if (bits <= 8) {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1926  		dev_dbg(&spi->dev, "4 <= n <=8 bits per word\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1927  		chip->n_bytes = 1;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1928  		chip->read = READING_U8;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1929  		chip->write = WRITING_U8;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1930  	} else if (bits <= 16) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1931  		dev_dbg(&spi->dev, "9 <= n <= 16 bits per word\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1932  		chip->n_bytes = 2;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1933  		chip->read = READING_U16;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1934  		chip->write = WRITING_U16;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1935  	} else {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1936  		dev_dbg(&spi->dev, "17 <= n <= 32 bits per word\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1937  		chip->n_bytes = 4;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1938  		chip->read = READING_U32;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1939  		chip->write = WRITING_U32;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1940  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1941  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1942  	/* Now Initialize all register settings required for this chip */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1943  	chip->cr0 = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1944  	chip->cr1 = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1945  	chip->dmacr = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1946  	chip->cpsr = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1947  	if ((chip_info->com_mode == DMA_TRANSFER)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1948  	    && ((pl022->master_info)->enable_dma)) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1949  		chip->enable_dma = true;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1950  		dev_dbg(&spi->dev, "DMA mode set in controller state\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1951  		SSP_WRITE_BITS(chip->dmacr, SSP_DMA_ENABLED,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1952  			       SSP_DMACR_MASK_RXDMAE, 0);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1953  		SSP_WRITE_BITS(chip->dmacr, SSP_DMA_ENABLED,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1954  			       SSP_DMACR_MASK_TXDMAE, 1);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1955  	} else {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1956  		chip->enable_dma = false;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1957  		dev_dbg(&spi->dev, "DMA mode NOT set in controller state\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1958  		SSP_WRITE_BITS(chip->dmacr, SSP_DMA_DISABLED,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1959  			       SSP_DMACR_MASK_RXDMAE, 0);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1960  		SSP_WRITE_BITS(chip->dmacr, SSP_DMA_DISABLED,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1961  			       SSP_DMACR_MASK_TXDMAE, 1);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1962  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1963  
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1964  	chip->cpsr = clk_freq.cpsdvsr;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1965  
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1966  	/* Special setup for the ST micro extended control registers */
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1967  	if (pl022->vendor->extended_cr) {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1968  		u32 etx;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1969  
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1970  		if (pl022->vendor->pl023) {
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1971  			/* These bits are only in the PL023 */
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1972  			SSP_WRITE_BITS(chip->cr1, chip_info->clkdelay,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1973  				       SSP_CR1_MASK_FBCLKDEL_ST, 13);
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1974  		} else {
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1975  			/* These bits are in the PL022 but not PL023 */
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1976  			SSP_WRITE_BITS(chip->cr0, chip_info->duplex,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1977  				       SSP_CR0_MASK_HALFDUP_ST, 5);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1978  			SSP_WRITE_BITS(chip->cr0, chip_info->ctrl_len,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1979  				       SSP_CR0_MASK_CSS_ST, 16);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1980  			SSP_WRITE_BITS(chip->cr0, chip_info->iface,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1981  				       SSP_CR0_MASK_FRF_ST, 21);
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1982  			SSP_WRITE_BITS(chip->cr1, chip_info->wait_state,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1983  				       SSP_CR1_MASK_MWAIT_ST, 6);
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1984  		}
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1985  		SSP_WRITE_BITS(chip->cr0, bits - 1,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1986  			       SSP_CR0_MASK_DSS_ST, 0);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1987  
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1988  		if (spi->mode & SPI_LSB_FIRST) {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1989  			tmp = SSP_RX_LSB;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1990  			etx = SSP_TX_LSB;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1991  		} else {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1992  			tmp = SSP_RX_MSB;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1993  			etx = SSP_TX_MSB;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1994  		}
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1995  		SSP_WRITE_BITS(chip->cr1, tmp, SSP_CR1_MASK_RENDN_ST, 4);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1996  		SSP_WRITE_BITS(chip->cr1, etx, SSP_CR1_MASK_TENDN_ST, 5);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1997  		SSP_WRITE_BITS(chip->cr1, chip_info->rx_lev_trig,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1998  			       SSP_CR1_MASK_RXIFLSEL_ST, 7);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1999  		SSP_WRITE_BITS(chip->cr1, chip_info->tx_lev_trig,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2000  			       SSP_CR1_MASK_TXIFLSEL_ST, 10);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2001  	} else {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2002  		SSP_WRITE_BITS(chip->cr0, bits - 1,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2003  			       SSP_CR0_MASK_DSS, 0);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2004  		SSP_WRITE_BITS(chip->cr0, chip_info->iface,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2005  			       SSP_CR0_MASK_FRF, 4);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2006  	}
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2007  
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2008  	/* Stuff that is common for all versions */
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2009  	if (spi->mode & SPI_CPOL)
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2010  		tmp = SSP_CLK_POL_IDLE_HIGH;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2011  	else
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2012  		tmp = SSP_CLK_POL_IDLE_LOW;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2013  	SSP_WRITE_BITS(chip->cr0, tmp, SSP_CR0_MASK_SPO, 6);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2014  
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2015  	if (spi->mode & SPI_CPHA)
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2016  		tmp = SSP_CLK_SECOND_EDGE;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2017  	else
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2018  		tmp = SSP_CLK_FIRST_EDGE;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2019  	SSP_WRITE_BITS(chip->cr0, tmp, SSP_CR0_MASK_SPH, 7);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2020  
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  2021  	SSP_WRITE_BITS(chip->cr0, clk_freq.scr, SSP_CR0_MASK_SCR, 8);
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2022  	/* Loopback is available on all versions except PL023 */
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2023  	if (pl022->vendor->loopback) {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2024  		if (spi->mode & SPI_LOOP)
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2025  			tmp = LOOPBACK_ENABLED;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2026  		else
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2027  			tmp = LOOPBACK_DISABLED;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2028  		SSP_WRITE_BITS(chip->cr1, tmp, SSP_CR1_MASK_LBM, 0);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2029  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2030  	SSP_WRITE_BITS(chip->cr1, SSP_DISABLED, SSP_CR1_MASK_SSE, 1);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2031  	SSP_WRITE_BITS(chip->cr1, chip_info->hierarchy, SSP_CR1_MASK_MS, 2);
f1e45f86ed93b9e drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  2032  	SSP_WRITE_BITS(chip->cr1, chip_info->slave_tx_disable, SSP_CR1_MASK_SOD,
f1e45f86ed93b9e drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  2033  		3);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2034  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2035  	/* Save controller_state */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2036  	spi_set_ctldata(spi, chip);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2037  	return status;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2038   err_config_params:
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2039  	spi_set_ctldata(spi, NULL);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2040  	kfree(chip);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2041  	return status;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2042  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2043  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2044  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2045   * pl022_cleanup - cleanup function registered to SPI master framework
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2046   * @spi: spi device which is requesting cleanup
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2047   *
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2048   * This function is registered to the SPI framework for this SPI master
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2049   * controller. It will free the runtime state of chip.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2050   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2051  static void pl022_cleanup(struct spi_device *spi)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2052  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2053  	struct chip_data *chip = spi_get_ctldata(spi);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2054  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2055  	spi_set_ctldata(spi, NULL);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2056  	kfree(chip);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2057  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2058  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2059  static struct pl022_ssp_controller *
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2060  pl022_platform_data_dt_get(struct device *dev)
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2061  {
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2062  	struct device_node *np = dev->of_node;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2063  	struct pl022_ssp_controller *pd;
849794c50b24b93 drivers/spi/spi-pl022.c  Rabin Vincent            2017-04-06  2064  	u32 tmp = 0;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2065  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2066  	if (!np) {
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2067  		dev_err(dev, "no dt node defined\n");
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2068  		return NULL;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2069  	}
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2070  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2071  	pd = devm_kzalloc(dev, sizeof(struct pl022_ssp_controller), GFP_KERNEL);
77538f4a98dc542 drivers/spi/spi-pl022.c  Jingoo Han               2014-04-29  2072  	if (!pd)
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2073  		return NULL;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2074  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2075  	pd->bus_id = -1;
dbd897b9c6fac8b drivers/spi/spi-pl022.c  Linus Walleij            2013-05-23  2076  	pd->enable_dma = 1;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2077  	of_property_read_u32(np, "num-cs", &tmp);
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2078  	pd->num_chipselect = tmp;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2079  	of_property_read_u32(np, "pl022,autosuspend-delay",
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2080  			     &pd->autosuspend_delay);
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2081  	pd->rt = of_property_read_bool(np, "pl022,rt");
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2082  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2083  	return pd;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2084  }
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2085  
fd4a319bc933ae9 drivers/spi/spi-pl022.c  Grant Likely             2012-12-07  2086  static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2087  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2088  	struct device *dev = &adev->dev;
8074cf063e410a2 drivers/spi/spi-pl022.c  Jingoo Han               2013-07-30  2089  	struct pl022_ssp_controller *platform_info =
8074cf063e410a2 drivers/spi/spi-pl022.c  Jingoo Han               2013-07-30  2090  			dev_get_platdata(&adev->dev);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2091  	struct spi_master *master;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2092  	struct pl022 *pl022 = NULL;	/*Data for this driver */
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2093  	struct device_node *np = adev->dev.of_node;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2094  	int status = 0, i, num_cs;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2095  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2096  	dev_info(&adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2097  		 "ARM PL022 driver, device ID: 0x%08x\n", adev->periphid);
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2098  	if (!platform_info && IS_ENABLED(CONFIG_OF))
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2099  		platform_info = pl022_platform_data_dt_get(dev);
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2100  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2101  	if (!platform_info) {
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2102  		dev_err(dev, "probe: no platform data defined\n");
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2103  		return -ENODEV;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2104  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2105  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2106  	if (platform_info->num_chipselect) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2107  		num_cs = platform_info->num_chipselect;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2108  	} else {
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2109  		dev_err(dev, "probe: no chip select defined\n");
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2110  		return -ENODEV;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2111  	}
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2112  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2113  	/* Allocate master with space for data */
b4b8482690d97ea drivers/spi/spi-pl022.c  Roland Stigge            2012-09-03  2114  	master = spi_alloc_master(dev, sizeof(struct pl022));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2115  	if (master == NULL) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2116  		dev_err(&adev->dev, "probe - cannot alloc SPI master\n");
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2117  		return -ENOMEM;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2118  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2119  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2120  	pl022 = spi_master_get_devdata(master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2121  	pl022->master = master;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2122  	pl022->master_info = platform_info;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2123  	pl022->adev = adev;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2124  	pl022->vendor = id->data;
a86854d0c599b32 drivers/spi/spi-pl022.c  Kees Cook                2018-06-12  2125  	pl022->chipselects = devm_kcalloc(dev, num_cs, sizeof(int),
b4b8482690d97ea drivers/spi/spi-pl022.c  Roland Stigge            2012-09-03  2126  					  GFP_KERNEL);
73e3f1eb5188830 drivers/spi/spi-pl022.c  Kiran Padwal             2014-09-18  2127  	if (!pl022->chipselects) {
73e3f1eb5188830 drivers/spi/spi-pl022.c  Kiran Padwal             2014-09-18  2128  		status = -ENOMEM;
73e3f1eb5188830 drivers/spi/spi-pl022.c  Kiran Padwal             2014-09-18  2129  		goto err_no_mem;
73e3f1eb5188830 drivers/spi/spi-pl022.c  Kiran Padwal             2014-09-18  2130  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2131  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2132  	/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2133  	 * Bus Number Which has been Assigned to this SSP controller
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2134  	 * on this board
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2135  	 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2136  	master->bus_num = platform_info->bus_id;
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25  2137  	master->use_gpio_descriptors;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2138  	master->num_chipselect = num_cs;
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25  2139  	master->set_cs = pl022_set_cs;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2140  	master->cleanup = pl022_cleanup;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2141  	master->setup = pl022_setup;
29b6e906a70a47c drivers/spi/spi-pl022.c  Mark Brown               2013-07-28  2142  	master->auto_runtime_pm = true;
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2143  	master->transfer_one_message = pl022_transfer_one_message;
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2144  	master->unprepare_transfer_hardware = pl022_unprepare_transfer_hardware;
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2145  	master->rt = platform_info->rt;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2146  	master->dev.of_node = dev->of_node;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2147  
516843702bb5fd8 drivers/spi/spi-pl022.c  Linus Walleij            2019-04-28  2148  	if (pl022->vendor->internal_cs_ctrl) {
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2149  		for (i = 0; i < num_cs; i++)
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2150  			pl022->chipselects[i] = i;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2151  	} else if (IS_ENABLED(CONFIG_OF)) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2152  		for (i = 0; i < num_cs; i++) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2153  			int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2154  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2155  			if (cs_gpio == -EPROBE_DEFER) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2156  				status = -EPROBE_DEFER;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2157  				goto err_no_gpio;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2158  			}
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2159  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2160  			pl022->chipselects[i] = cs_gpio;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2161  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2162  			if (gpio_is_valid(cs_gpio)) {
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2163  				if (devm_gpio_request(dev, cs_gpio, "ssp-pl022"))
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2164  					dev_err(&adev->dev,
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2165  						"could not request %d gpio\n",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2166  						cs_gpio);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2167  				else if (gpio_direction_output(cs_gpio, 1))
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2168  					dev_err(&adev->dev,
61e89e65e31516c drivers/spi/spi-pl022.c  Roland Stigge            2014-09-09  2169  						"could not set gpio %d as output\n",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2170  						cs_gpio);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2171  			}
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2172  		}
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2173  	}
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2174  
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2175  	/*
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2176  	 * Supports mode 0-3, loopback, and active low CS. Transfers are
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2177  	 * always MS bit first on the original pl022.
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2178  	 */
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2179  	master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LOOP;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2180  	if (pl022->vendor->extended_cr)
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2181  		master->mode_bits |= SPI_LSB_FIRST;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2182  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2183  	dev_dbg(&adev->dev, "BUSNO: %d\n", master->bus_num);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2184  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2185  	status = amba_request_regions(adev, NULL);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2186  	if (status)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2187  		goto err_no_ioregion;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2188  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2189  	pl022->phybase = adev->res.start;
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2190  	pl022->virtbase = devm_ioremap(dev, adev->res.start,
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2191  				       resource_size(&adev->res));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2192  	if (pl022->virtbase == NULL) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2193  		status = -ENOMEM;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2194  		goto err_no_ioremap;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2195  	}
2c067509a1e3540 drivers/spi/spi-pl022.c  Jingoo Han               2013-10-11  2196  	dev_info(&adev->dev, "mapped registers from %pa to %p\n",
7085f403517615c drivers/spi/spi-pl022.c  Fabio Estevam            2013-08-21  2197  		&adev->res.start, pl022->virtbase);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2198  
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2199  	pl022->clk = devm_clk_get(&adev->dev, NULL);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2200  	if (IS_ERR(pl022->clk)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2201  		status = PTR_ERR(pl022->clk);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2202  		dev_err(&adev->dev, "could not retrieve SSP/SPI bus clock\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2203  		goto err_no_clk;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2204  	}
7ff6bcf048e6a98 drivers/spi/spi-pl022.c  Russell King             2011-09-22  2205  
6cac167b826eced drivers/spi/spi-pl022.c  Ulf Hansson              2014-02-04  2206  	status = clk_prepare_enable(pl022->clk);
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2207  	if (status) {
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2208  		dev_err(&adev->dev, "could not enable SSP/SPI bus clock\n");
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2209  		goto err_no_clk_en;
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2210  	}
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2211  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2212  	/* Initialize transfer pump */
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2213  	tasklet_init(&pl022->pump_transfers, pump_transfers,
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2214  		     (unsigned long)pl022);
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2215  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2216  	/* Disable SSP */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2217  	writew((readw(SSP_CR1(pl022->virtbase)) & (~SSP_CR1_MASK_SSE)),
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2218  	       SSP_CR1(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2219  	load_ssp_default_config(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2220  
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2221  	status = devm_request_irq(dev, adev->irq[0], pl022_interrupt_handler,
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2222  				  0, "pl022", pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2223  	if (status < 0) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2224  		dev_err(&adev->dev, "probe - cannot get IRQ (%d)\n", status);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2225  		goto err_no_irq;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2226  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2227  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2228  	/* Get DMA channels, try autoconfiguration first */
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2229  	status = pl022_dma_autoprobe(pl022);
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  2230  	if (status == -EPROBE_DEFER) {
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  2231  		dev_dbg(dev, "deferring probe to get DMA channel\n");
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  2232  		goto err_no_irq;
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  2233  	}
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2234  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2235  	/* If that failed, use channels from platform_info */
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2236  	if (status == 0)
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2237  		platform_info->enable_dma = 1;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2238  	else if (platform_info->enable_dma) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2239  		status = pl022_dma_probe(pl022);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2240  		if (status != 0)
43c640157d4366a drivers/spi/amba-pl022.c Viresh Kumar             2011-05-16  2241  			platform_info->enable_dma = 0;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2242  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2243  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2244  	/* Register with the SPI framework */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2245  	amba_set_drvdata(adev, pl022);
35794a77168b739 drivers/spi/spi-pl022.c  Jingoo Han               2013-09-24  2246  	status = devm_spi_register_master(&adev->dev, master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2247  	if (status != 0) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2248  		dev_err(&adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2249  			"probe - problem registering spi master\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2250  		goto err_spi_register;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2251  	}
25985edcedea639 drivers/spi/amba-pl022.c Lucas De Marchi          2011-03-30  2252  	dev_dbg(dev, "probe succeeded\n");
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2253  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2254  	/* let runtime pm put suspend */
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2255  	if (platform_info->autosuspend_delay > 0) {
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2256  		dev_info(&adev->dev,
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2257  			"will use autosuspend for runtime pm, delay %dms\n",
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2258  			platform_info->autosuspend_delay);
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2259  		pm_runtime_set_autosuspend_delay(dev,
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2260  			platform_info->autosuspend_delay);
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2261  		pm_runtime_use_autosuspend(dev);
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2262  	}
0df349945752bf0 drivers/spi/spi-pl022.c  Ulf Hansson              2012-10-17  2263  	pm_runtime_put(dev);
0df349945752bf0 drivers/spi/spi-pl022.c  Ulf Hansson              2012-10-17  2264  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2265  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2266  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2267   err_spi_register:
3e3ea716270dc64 drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  2268  	if (platform_info->enable_dma)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2269  		pl022_dma_remove(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2270   err_no_irq:
6cac167b826eced drivers/spi/spi-pl022.c  Ulf Hansson              2014-02-04  2271  	clk_disable_unprepare(pl022->clk);
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2272   err_no_clk_en:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2273   err_no_clk:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2274   err_no_ioremap:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2275  	amba_release_regions(adev);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2276   err_no_ioregion:
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2277   err_no_gpio:
73e3f1eb5188830 drivers/spi/spi-pl022.c  Kiran Padwal             2014-09-18  2278   err_no_mem:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2279  	spi_master_put(master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2280  	return status;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2281  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2282  
fd4a319bc933ae9 drivers/spi/spi-pl022.c  Grant Likely             2012-12-07  2283  static int
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2284  pl022_remove(struct amba_device *adev)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2285  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2286  	struct pl022 *pl022 = amba_get_drvdata(adev);
50658b6602dad6d drivers/spi/spi-pl022.c  Linus Walleij            2011-08-02  2287  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2288  	if (!pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2289  		return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2290  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2291  	/*
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2292  	 * undo pm_runtime_put() in probe.  I assume that we're not
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2293  	 * accessing the primecell here.
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2294  	 */
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2295  	pm_runtime_get_noresume(&adev->dev);
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2296  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2297  	load_ssp_default_config(pl022);
3e3ea716270dc64 drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  2298  	if (pl022->master_info->enable_dma)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2299  		pl022_dma_remove(pl022);
3e3ea716270dc64 drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  2300  
6cac167b826eced drivers/spi/spi-pl022.c  Ulf Hansson              2014-02-04  2301  	clk_disable_unprepare(pl022->clk);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2302  	amba_release_regions(adev);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2303  	tasklet_disable(&pl022->pump_transfers);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2304  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2305  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2306  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2307  #ifdef CONFIG_PM_SLEEP
6cfa6279edbffa9 drivers/spi/spi-pl022.c  Peter Hüwe               2011-09-05  2308  static int pl022_suspend(struct device *dev)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2309  {
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2310  	struct pl022 *pl022 = dev_get_drvdata(dev);
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2311  	int ret;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2312  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2313  	ret = spi_master_suspend(pl022->master);
7c5d8a249acadc3 drivers/spi/spi-pl022.c  Geert Uytterhoeven       2018-09-05  2314  	if (ret)
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2315  		return ret;
4964a26df72c4a8 drivers/spi/spi-pl022.c  Ulf Hansson              2012-10-17  2316  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2317  	ret = pm_runtime_force_suspend(dev);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2318  	if (ret) {
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2319  		spi_master_resume(pl022->master);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2320  		return ret;
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2321  	}
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2322  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2323  	pinctrl_pm_select_sleep_state(dev);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2324  
6cfa6279edbffa9 drivers/spi/spi-pl022.c  Peter Hüwe               2011-09-05  2325  	dev_dbg(dev, "suspended\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2326  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2327  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2328  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2329  static int pl022_resume(struct device *dev)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2330  {
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2331  	struct pl022 *pl022 = dev_get_drvdata(dev);
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2332  	int ret;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2333  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2334  	ret = pm_runtime_force_resume(dev);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2335  	if (ret)
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2336  		dev_err(dev, "problem resuming\n");
ada7aec7eec0ca2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2337  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2338  	/* Start the queue running */
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2339  	ret = spi_master_resume(pl022->master);
7c5d8a249acadc3 drivers/spi/spi-pl022.c  Geert Uytterhoeven       2018-09-05  2340  	if (!ret)
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2341  		dev_dbg(dev, "resumed\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2342  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2343  	return ret;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2344  }
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2345  #endif
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2346  
736198b0486c8d5 drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2347  #ifdef CONFIG_PM
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2348  static int pl022_runtime_suspend(struct device *dev)
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2349  {
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2350  	struct pl022 *pl022 = dev_get_drvdata(dev);
4f5e1b370845a0a drivers/spi/spi-pl022.c  Patrice Chotard          2012-09-19  2351  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2352  	clk_disable_unprepare(pl022->clk);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2353  	pinctrl_pm_select_idle_state(dev);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2354  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2355  	return 0;
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2356  }
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2357  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2358  static int pl022_runtime_resume(struct device *dev)
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2359  {
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2360  	struct pl022 *pl022 = dev_get_drvdata(dev);
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2361  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2362  	pinctrl_pm_select_default_state(dev);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2363  	clk_prepare_enable(pl022->clk);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2364  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2365  	return 0;
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2366  }
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2367  #endif
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2368  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2369  static const struct dev_pm_ops pl022_dev_pm_ops = {
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2370  	SET_SYSTEM_SLEEP_PM_OPS(pl022_suspend, pl022_resume)
6ed23b806e73bdd drivers/spi/spi-pl022.c  Rafael J. Wysocki        2014-12-04  2371  	SET_RUNTIME_PM_OPS(pl022_runtime_suspend, pl022_runtime_resume, NULL)
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2372  };
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2373  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2374  static struct vendor_data vendor_arm = {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2375  	.fifodepth = 8,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2376  	.max_bpw = 16,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2377  	.unidir = false,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2378  	.extended_cr = false,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2379  	.pl023 = false,
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2380  	.loopback = true,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2381  	.internal_cs_ctrl = false,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2382  };
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2383  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2384  static struct vendor_data vendor_st = {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2385  	.fifodepth = 32,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2386  	.max_bpw = 32,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2387  	.unidir = false,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2388  	.extended_cr = true,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2389  	.pl023 = false,
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2390  	.loopback = true,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2391  	.internal_cs_ctrl = false,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2392  };
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2393  
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2394  static struct vendor_data vendor_st_pl023 = {
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2395  	.fifodepth = 32,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2396  	.max_bpw = 32,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2397  	.unidir = false,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2398  	.extended_cr = true,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2399  	.pl023 = true,
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2400  	.loopback = false,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2401  	.internal_cs_ctrl = false,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2402  };
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2403  
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2404  static struct vendor_data vendor_lsi = {
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2405  	.fifodepth = 8,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2406  	.max_bpw = 16,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2407  	.unidir = false,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2408  	.extended_cr = false,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2409  	.pl023 = false,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2410  	.loopback = true,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2411  	.internal_cs_ctrl = true,
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2412  };
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2413  
5b8d5ad2308d2d5 drivers/spi/spi-pl022.c  Arvind Yadav             2017-08-23  2414  static const struct amba_id pl022_ids[] = {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2415  	{
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2416  		/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2417  		 * ARM PL022 variant, this has a 16bit wide
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2418  		 * and 8 locations deep TX/RX FIFO
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2419  		 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2420  		.id	= 0x00041022,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2421  		.mask	= 0x000fffff,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2422  		.data	= &vendor_arm,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2423  	},
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2424  	{
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2425  		/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2426  		 * ST Micro derivative, this has 32bit wide
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2427  		 * and 32 locations deep TX/RX FIFO
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2428  		 */
e89e04fcdce6146 drivers/spi/amba-pl022.c Srinidhi Kasagar         2009-10-05  2429  		.id	= 0x01080022,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2430  		.mask	= 0xffffffff,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2431  		.data	= &vendor_st,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2432  	},
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2433  	{
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2434  		/*
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2435  		 * ST-Ericsson derivative "PL023" (this is not
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2436  		 * an official ARM number), this is a PL022 SSP block
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2437  		 * stripped to SPI mode only, it has 32bit wide
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2438  		 * and 32 locations deep TX/RX FIFO but no extended
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2439  		 * CR0/CR1 register
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2440  		 */
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2441  		.id	= 0x00080023,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2442  		.mask	= 0xffffffff,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2443  		.data	= &vendor_st_pl023,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2444  	},
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2445  	{
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2446  		/*
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2447  		 * PL022 variant that has a chip select control register whih
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2448  		 * allows control of 5 output signals nCS[0:4].
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2449  		 */
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2450  		.id	= 0x000b6022,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2451  		.mask	= 0x000fffff,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2452  		.data	= &vendor_lsi,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2453  	},
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2454  	{ 0, 0 },
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2455  };
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2456  
7eeac71b9fc9b3d drivers/spi/spi-pl022.c  Dave Martin              2011-10-05  2457  MODULE_DEVICE_TABLE(amba, pl022_ids);
7eeac71b9fc9b3d drivers/spi/spi-pl022.c  Dave Martin              2011-10-05  2458  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2459  static struct amba_driver pl022_driver = {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2460  	.drv = {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2461  		.name	= "ssp-pl022",
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2462  		.pm	= &pl022_dev_pm_ops,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2463  	},
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2464  	.id_table	= pl022_ids,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2465  	.probe		= pl022_probe,
fd4a319bc933ae9 drivers/spi/spi-pl022.c  Grant Likely             2012-12-07  2466  	.remove		= pl022_remove,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2467  };
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2468  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2469  static int __init pl022_init(void)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2470  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2471  	return amba_driver_register(&pl022_driver);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2472  }
25c8e03bdb769df drivers/spi/amba-pl022.c Linus Walleij            2010-09-06  2473  subsys_initcall(pl022_init);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2474  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2475  static void __exit pl022_exit(void)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2476  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2477  	amba_driver_unregister(&pl022_driver);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2478  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2479  module_exit(pl022_exit);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2480  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2481  MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2482  MODULE_DESCRIPTION("PL022 SSP Controller Driver");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2483  MODULE_LICENSE("GPL");

:::::: The code at line 1852 was first introduced by commit
:::::: 6d3952a7dfa80919842bbe01ac7f693d40a1eb84 spi/pl022: Add devicetree support

:::::: TO: Roland Stigge <stigge@antcom.de>
:::::: CC: Mark Brown <broonie@opensource.wolfsonmicro.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 66320 bytes --]

^ permalink raw reply

* [gpio:gpio-descriptors-spi 5/5] drivers//spi/spi-pl022.c:442:22: error: 'struct pl022' has no member named 'cur_cs'; did you mean 'cur_msg'?
From: kbuild test robot @ 2019-08-06  6:28 UTC (permalink / raw)
  To: Linus Walleij; +Cc: kbuild-all, linux-gpio

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=unknown-8bit, Size: 236134 bytes --]

tree:   https://kernel.googlesource.com/pub/scm/linux/kernel/git/linusw/linux-gpio.git gpio-descriptors-spi
head:   6e5614b6476001adb8ce6e2859bc2ca0a4339398
commit: 6e5614b6476001adb8ce6e2859bc2ca0a4339398 [5/5] slask
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 6e5614b6476001adb8ce6e2859bc2ca0a4339398
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/linux/bitops.h:5:0,
                    from include/linux/kernel.h:12,
                    from include/linux/list.h:9,
                    from include/linux/module.h:9,
                    from drivers//spi/spi-pl022.c:17:
   drivers//spi/spi-pl022.c: In function 'pl022_set_cs':
>> drivers//spi/spi-pl022.c:442:22: error: 'struct pl022' has no member named 'cur_cs'; did you mean 'cur_msg'?
      tmp &= ~BIT(pl022->cur_cs);
                         ^
   include/linux/bits.h:8:30: note: in definition of macro 'BIT'
    #define BIT(nr)   (UL(1) << (nr))
                                 ^~
   drivers//spi/spi-pl022.c:444:21: error: 'struct pl022' has no member named 'cur_cs'; did you mean 'cur_msg'?
      tmp |= BIT(pl022->cur_cs);
                        ^
   include/linux/bits.h:8:30: note: in definition of macro 'BIT'
    #define BIT(nr)   (UL(1) << (nr))
                                 ^~
   drivers//spi/spi-pl022.c: In function 'giveback':
>> drivers//spi/spi-pl022.c:493:4: error: implicit declaration of function 'pl022_cs_control'; did you mean 'pl022_set_cs'? [-Werror=implicit-function-declaration]
       pl022_cs_control(pl022, SSP_CHIP_DESELECT);
       ^~~~~~~~~~~~~~~~
       pl022_set_cs
   drivers//spi/spi-pl022.c: In function 'pl022_transfer_one_message':
   drivers//spi/spi-pl022.c:1571:9: error: 'struct pl022' has no member named 'cur_cs'; did you mean 'cur_msg'?
     pl022->cur_cs = pl022->chipselects[msg->spi->chip_select];
            ^~~~~~
            cur_msg
>> drivers//spi/spi-pl022.c:1571:23: error: 'struct pl022' has no member named 'chipselects'
     pl022->cur_cs = pl022->chipselects[msg->spi->chip_select];
                          ^~
   drivers//spi/spi-pl022.c: In function 'pl022_setup':
>> drivers//spi/spi-pl022.c:1852:4: error: implicit declaration of function 'of_property_read_u32' [-Werror=implicit-function-declaration]
       of_property_read_u32(np, "pl022,interface",
       ^~~~~~~~~~~~~~~~~~~~
>> drivers//spi/spi-pl022.c:1914:7: error: implicit declaration of function 'gpio_is_valid'; did you mean 'uuid_is_valid'? [-Werror=implicit-function-declaration]
     if (!gpio_is_valid(pl022->chipselects[spi->chip_select]))
          ^~~~~~~~~~~~~
          uuid_is_valid
   drivers//spi/spi-pl022.c:1914:26: error: 'struct pl022' has no member named 'chipselects'
     if (!gpio_is_valid(pl022->chipselects[spi->chip_select]))
                             ^~
   drivers//spi/spi-pl022.c: In function 'pl022_platform_data_dt_get':
>> drivers//spi/spi-pl022.c:2081:11: error: implicit declaration of function 'of_property_read_bool' [-Werror=implicit-function-declaration]
     pd->rt = of_property_read_bool(np, "pl022,rt");
              ^~~~~~~~~~~~~~~~~~~~~
   drivers//spi/spi-pl022.c: In function 'pl022_probe':
   drivers//spi/spi-pl022.c:2125:7: error: 'struct pl022' has no member named 'chipselects'
     pl022->chipselects = devm_kcalloc(dev, num_cs, sizeof(int),
          ^~
   drivers//spi/spi-pl022.c:2127:12: error: 'struct pl022' has no member named 'chipselects'
     if (!pl022->chipselects) {
               ^~
   drivers//spi/spi-pl022.c:2137:8: warning: statement with no effect [-Wunused-value]
     master->use_gpio_descriptors;
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
   drivers//spi/spi-pl022.c:2150:9: error: 'struct pl022' has no member named 'chipselects'
       pl022->chipselects[i] = i;
            ^~
>> drivers//spi/spi-pl022.c:2153:18: error: implicit declaration of function 'of_get_named_gpio'; did you mean 'fwnode_get_named_gpiod'? [-Werror=implicit-function-declaration]
       int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
                     ^~~~~~~~~~~~~~~~~
                     fwnode_get_named_gpiod
   drivers//spi/spi-pl022.c:2160:9: error: 'struct pl022' has no member named 'chipselects'
       pl022->chipselects[i] = cs_gpio;
            ^~
>> drivers//spi/spi-pl022.c:2163:9: error: implicit declaration of function 'devm_gpio_request'; did you mean 'devm_gpiod_put'? [-Werror=implicit-function-declaration]
        if (devm_gpio_request(dev, cs_gpio, "ssp-pl022"))
            ^~~~~~~~~~~~~~~~~
            devm_gpiod_put
>> drivers//spi/spi-pl022.c:2167:14: error: implicit declaration of function 'gpio_direction_output'; did you mean 'gpiod_direction_output'? [-Werror=implicit-function-declaration]
        else if (gpio_direction_output(cs_gpio, 1))
                 ^~~~~~~~~~~~~~~~~~~~~
                 gpiod_direction_output
   cc1: some warnings being treated as errors

vim +442 drivers//spi/spi-pl022.c

b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   421  
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   422  static void pl022_set_cs(struct spi_device *spi, bool enable)
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17   423  {
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   424  	struct pl022 *pl022 = spi_controller_get_devdata(spi->controller);
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17   425  	u32 tmp;
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17   426  
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   427  	/*
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   428  	 * This callback will ONLY be called of no GPIO descriptors were found
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   429  	 * for the device, so we know we are dealing exclusively with variants
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   430  	 * that have internal CS control here, but just to be sure: extra check
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   431  	 * for now.
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   432  	 */
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   433  	if (!pl022->vendor->internal_cs_ctrl) {
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   434  		dev_err(&spi->dev,
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   435  			"called internal CS control on unsupported device\n");
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   436  		return;
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   437  	}
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   438  
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   439  	/* We draw a line low here to imply we enable it */
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17   440  	tmp = readw(SSP_CSR(pl022->virtbase));
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25   441  	if (enable)
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  @442  		tmp &= ~BIT(pl022->cur_cs);
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17   443  	else
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  @444  		tmp |= BIT(pl022->cur_cs);
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17   445  	writew(tmp, SSP_CSR(pl022->virtbase));
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17   446  }
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17   447  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   448  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   449   * giveback - current spi_message is over, schedule next message and call
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   450   * callback of this message. Assumes that caller already
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   451   * set message->status; dma and pio irqs are blocked
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   452   * @pl022: SSP driver private data structure
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   453   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   454  static void giveback(struct pl022 *pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   455  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   456  	struct spi_transfer *last_transfer;
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   457  	pl022->next_msg_cs_active = false;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   458  
23e2c2aa45a213e drivers/spi/spi-pl022.c  Axel Lin                 2014-02-12   459  	last_transfer = list_last_entry(&pl022->cur_msg->transfers,
23e2c2aa45a213e drivers/spi/spi-pl022.c  Axel Lin                 2014-02-12   460  					struct spi_transfer, transfer_list);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   461  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   462  	/* Delay if requested before any change in chip select */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   463  	if (last_transfer->delay_usecs)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   464  		/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   465  		 * FIXME: This runs in interrupt context.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   466  		 * Is this really smart?
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   467  		 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   468  		udelay(last_transfer->delay_usecs);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   469  
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   470  	if (!last_transfer->cs_change) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   471  		struct spi_message *next_msg;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   472  
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   473  		/*
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   474  		 * cs_change was not set. We can keep the chip select
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   475  		 * enabled if there is message in the queue and it is
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   476  		 * for the same spi device.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   477  		 *
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   478  		 * We cannot postpone this until pump_messages, because
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   479  		 * after calling msg->complete (below) the driver that
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   480  		 * sent the current message could be unloaded, which
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   481  		 * could invalidate the cs_control() callback...
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   482  		 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   483  		/* get a pointer to the next message, if any */
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22   484  		next_msg = spi_get_next_queued_message(pl022->master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   485  
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   486  		/*
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   487  		 * see if the next and current messages point
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   488  		 * to the same spi device.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   489  		 */
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   490  		if (next_msg && next_msg->spi != pl022->cur_msg->spi)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   491  			next_msg = NULL;
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   492  		if (!next_msg || pl022->cur_msg->state == STATE_ERROR)
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  @493  			pl022_cs_control(pl022, SSP_CHIP_DESELECT);
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   494  		else
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   495  			pl022->next_msg_cs_active = true;
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22   496  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   497  	}
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   498  
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   499  	pl022->cur_msg = NULL;
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   500  	pl022->cur_transfer = NULL;
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10   501  	pl022->cur_chip = NULL;
fd316941cfee1fb drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2012-06-12   502  
fd316941cfee1fb drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2012-06-12   503  	/* disable the SPI/SSP operation */
fd316941cfee1fb drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2012-06-12   504  	writew((readw(SSP_CR1(pl022->virtbase)) &
fd316941cfee1fb drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2012-06-12   505  		(~SSP_CR1_MASK_SSE)), SSP_CR1(pl022->virtbase));
fd316941cfee1fb drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2012-06-12   506  
cd6fa8d2ca53cac drivers/spi/spi-pl022.c  Alexander Sverdlin       2015-02-27   507  	spi_finalize_current_message(pl022->master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   508  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   509  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   510  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   511   * flush - flush the FIFO to reach a clean state
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   512   * @pl022: SSP driver private data structure
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   513   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   514  static int flush(struct pl022 *pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   515  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   516  	unsigned long limit = loops_per_jiffy << 1;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   517  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   518  	dev_dbg(&pl022->adev->dev, "flush\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   519  	do {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   520  		while (readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_RNE)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   521  			readw(SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   522  	} while ((readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_BSY) && limit--);
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   523  
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   524  	pl022->exp_fifo_level = 0;
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   525  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   526  	return limit;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   527  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   528  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   529  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   530   * restore_state - Load configuration of current chip
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   531   * @pl022: SSP driver private data structure
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   532   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   533  static void restore_state(struct pl022 *pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   534  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   535  	struct chip_data *chip = pl022->cur_chip;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   536  
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   537  	if (pl022->vendor->extended_cr)
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   538  		writel(chip->cr0, SSP_CR0(pl022->virtbase));
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   539  	else
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   540  		writew(chip->cr0, SSP_CR0(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   541  	writew(chip->cr1, SSP_CR1(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   542  	writew(chip->dmacr, SSP_DMACR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   543  	writew(chip->cpsr, SSP_CPSR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   544  	writew(DISABLE_ALL_INTERRUPTS, SSP_IMSC(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   545  	writew(CLEAR_ALL_INTERRUPTS, SSP_ICR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   546  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   547  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   548  /*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   549   * Default SSP Register Values
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   550   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   551  #define DEFAULT_SSP_REG_CR0 ( \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   552  	GEN_MASK_BITS(SSP_DATA_BITS_12, SSP_CR0_MASK_DSS, 0)	| \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   553  	GEN_MASK_BITS(SSP_INTERFACE_MOTOROLA_SPI, SSP_CR0_MASK_FRF, 4) | \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   554  	GEN_MASK_BITS(SSP_CLK_POL_IDLE_LOW, SSP_CR0_MASK_SPO, 6) | \
ee2b805c8eb6459 drivers/spi/amba-pl022.c Linus Walleij            2009-08-15   555  	GEN_MASK_BITS(SSP_CLK_SECOND_EDGE, SSP_CR0_MASK_SPH, 7) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   556  	GEN_MASK_BITS(SSP_DEFAULT_CLKRATE, SSP_CR0_MASK_SCR, 8) \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   557  )
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   558  
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   559  /* ST versions have slightly different bit layout */
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   560  #define DEFAULT_SSP_REG_CR0_ST ( \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   561  	GEN_MASK_BITS(SSP_DATA_BITS_12, SSP_CR0_MASK_DSS_ST, 0)	| \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   562  	GEN_MASK_BITS(SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, SSP_CR0_MASK_HALFDUP_ST, 5) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   563  	GEN_MASK_BITS(SSP_CLK_POL_IDLE_LOW, SSP_CR0_MASK_SPO, 6) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   564  	GEN_MASK_BITS(SSP_CLK_SECOND_EDGE, SSP_CR0_MASK_SPH, 7) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   565  	GEN_MASK_BITS(SSP_DEFAULT_CLKRATE, SSP_CR0_MASK_SCR, 8) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   566  	GEN_MASK_BITS(SSP_BITS_8, SSP_CR0_MASK_CSS_ST, 16)	| \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   567  	GEN_MASK_BITS(SSP_INTERFACE_MOTOROLA_SPI, SSP_CR0_MASK_FRF_ST, 21) \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   568  )
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   569  
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   570  /* The PL023 version is slightly different again */
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   571  #define DEFAULT_SSP_REG_CR0_ST_PL023 ( \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   572  	GEN_MASK_BITS(SSP_DATA_BITS_12, SSP_CR0_MASK_DSS_ST, 0)	| \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   573  	GEN_MASK_BITS(SSP_CLK_POL_IDLE_LOW, SSP_CR0_MASK_SPO, 6) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   574  	GEN_MASK_BITS(SSP_CLK_SECOND_EDGE, SSP_CR0_MASK_SPH, 7) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   575  	GEN_MASK_BITS(SSP_DEFAULT_CLKRATE, SSP_CR0_MASK_SCR, 8) \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   576  )
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   577  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   578  #define DEFAULT_SSP_REG_CR1 ( \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   579  	GEN_MASK_BITS(LOOPBACK_DISABLED, SSP_CR1_MASK_LBM, 0) | \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   580  	GEN_MASK_BITS(SSP_DISABLED, SSP_CR1_MASK_SSE, 1) | \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   581  	GEN_MASK_BITS(SSP_MASTER, SSP_CR1_MASK_MS, 2) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   582  	GEN_MASK_BITS(DO_NOT_DRIVE_TX, SSP_CR1_MASK_SOD, 3) \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   583  )
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   584  
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   585  /* ST versions extend this register to use all 16 bits */
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   586  #define DEFAULT_SSP_REG_CR1_ST ( \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   587  	DEFAULT_SSP_REG_CR1 | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   588  	GEN_MASK_BITS(SSP_RX_MSB, SSP_CR1_MASK_RENDN_ST, 4) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   589  	GEN_MASK_BITS(SSP_TX_MSB, SSP_CR1_MASK_TENDN_ST, 5) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   590  	GEN_MASK_BITS(SSP_MWIRE_WAIT_ZERO, SSP_CR1_MASK_MWAIT_ST, 6) |\
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   591  	GEN_MASK_BITS(SSP_RX_1_OR_MORE_ELEM, SSP_CR1_MASK_RXIFLSEL_ST, 7) | \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   592  	GEN_MASK_BITS(SSP_TX_1_OR_MORE_EMPTY_LOC, SSP_CR1_MASK_TXIFLSEL_ST, 10) \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   593  )
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   594  
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   595  /*
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   596   * The PL023 variant has further differences: no loopback mode, no microwire
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   597   * support, and a new clock feedback delay setting.
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   598   */
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   599  #define DEFAULT_SSP_REG_CR1_ST_PL023 ( \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   600  	GEN_MASK_BITS(SSP_DISABLED, SSP_CR1_MASK_SSE, 1) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   601  	GEN_MASK_BITS(SSP_MASTER, SSP_CR1_MASK_MS, 2) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   602  	GEN_MASK_BITS(DO_NOT_DRIVE_TX, SSP_CR1_MASK_SOD, 3) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   603  	GEN_MASK_BITS(SSP_RX_MSB, SSP_CR1_MASK_RENDN_ST, 4) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   604  	GEN_MASK_BITS(SSP_TX_MSB, SSP_CR1_MASK_TENDN_ST, 5) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   605  	GEN_MASK_BITS(SSP_RX_1_OR_MORE_ELEM, SSP_CR1_MASK_RXIFLSEL_ST, 7) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   606  	GEN_MASK_BITS(SSP_TX_1_OR_MORE_EMPTY_LOC, SSP_CR1_MASK_TXIFLSEL_ST, 10) | \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   607  	GEN_MASK_BITS(SSP_FEEDBACK_CLK_DELAY_NONE, SSP_CR1_MASK_FBCLKDEL_ST, 13) \
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   608  )
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   609  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   610  #define DEFAULT_SSP_REG_CPSR ( \
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   611  	GEN_MASK_BITS(SSP_DEFAULT_PRESCALE, SSP_CPSR_MASK_CPSDVSR, 0) \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   612  )
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   613  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   614  #define DEFAULT_SSP_REG_DMACR (\
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   615  	GEN_MASK_BITS(SSP_DMA_DISABLED, SSP_DMACR_MASK_RXDMAE, 0) | \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   616  	GEN_MASK_BITS(SSP_DMA_DISABLED, SSP_DMACR_MASK_TXDMAE, 1) \
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   617  )
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   618  
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   619  /**
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   620   * load_ssp_default_config - Load default configuration for SSP
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   621   * @pl022: SSP driver private data structure
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   622   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   623  static void load_ssp_default_config(struct pl022 *pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   624  {
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   625  	if (pl022->vendor->pl023) {
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   626  		writel(DEFAULT_SSP_REG_CR0_ST_PL023, SSP_CR0(pl022->virtbase));
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   627  		writew(DEFAULT_SSP_REG_CR1_ST_PL023, SSP_CR1(pl022->virtbase));
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07   628  	} else if (pl022->vendor->extended_cr) {
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   629  		writel(DEFAULT_SSP_REG_CR0_ST, SSP_CR0(pl022->virtbase));
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   630  		writew(DEFAULT_SSP_REG_CR1_ST, SSP_CR1(pl022->virtbase));
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   631  	} else {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   632  		writew(DEFAULT_SSP_REG_CR0, SSP_CR0(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   633  		writew(DEFAULT_SSP_REG_CR1, SSP_CR1(pl022->virtbase));
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05   634  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   635  	writew(DEFAULT_SSP_REG_DMACR, SSP_DMACR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   636  	writew(DEFAULT_SSP_REG_CPSR, SSP_CPSR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   637  	writew(DISABLE_ALL_INTERRUPTS, SSP_IMSC(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   638  	writew(CLEAR_ALL_INTERRUPTS, SSP_ICR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   639  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   640  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   641  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   642   * This will write to TX and read from RX according to the parameters
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   643   * set in pl022.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   644   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   645  static void readwriter(struct pl022 *pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   646  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   647  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   648  	/*
25985edcedea639 drivers/spi/amba-pl022.c Lucas De Marchi          2011-03-30   649  	 * The FIFO depth is different between primecell variants.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   650  	 * I believe filling in too much in the FIFO might cause
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   651  	 * errons in 8bit wide transfers on ARM variants (just 8 words
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   652  	 * FIFO, means only 8x8 = 64 bits in FIFO) at least.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   653  	 *
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   654  	 * To prevent this issue, the TX FIFO is only filled to the
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   655  	 * unused RX FIFO fill length, regardless of what the TX
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   656  	 * FIFO status flag indicates.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   657  	 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   658  	dev_dbg(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   659  		"%s, rx: %p, rxend: %p, tx: %p, txend: %p\n",
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   660  		__func__, pl022->rx, pl022->rx_end, pl022->tx, pl022->tx_end);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   661  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   662  	/* Read as much as you can */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   663  	while ((readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_RNE)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   664  	       && (pl022->rx < pl022->rx_end)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   665  		switch (pl022->read) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   666  		case READING_NULL:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   667  			readw(SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   668  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   669  		case READING_U8:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   670  			*(u8 *) (pl022->rx) =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   671  				readw(SSP_DR(pl022->virtbase)) & 0xFFU;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   672  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   673  		case READING_U16:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   674  			*(u16 *) (pl022->rx) =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   675  				(u16) readw(SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   676  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   677  		case READING_U32:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   678  			*(u32 *) (pl022->rx) =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   679  				readl(SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   680  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   681  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   682  		pl022->rx += (pl022->cur_chip->n_bytes);
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   683  		pl022->exp_fifo_level--;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   684  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   685  	/*
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   686  	 * Write as much as possible up to the RX FIFO size
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   687  	 */
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   688  	while ((pl022->exp_fifo_level < pl022->vendor->fifodepth)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   689  	       && (pl022->tx < pl022->tx_end)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   690  		switch (pl022->write) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   691  		case WRITING_NULL:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   692  			writew(0x0, SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   693  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   694  		case WRITING_U8:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   695  			writew(*(u8 *) (pl022->tx), SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   696  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   697  		case WRITING_U16:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   698  			writew((*(u16 *) (pl022->tx)), SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   699  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   700  		case WRITING_U32:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   701  			writel(*(u32 *) (pl022->tx), SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   702  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   703  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   704  		pl022->tx += (pl022->cur_chip->n_bytes);
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   705  		pl022->exp_fifo_level++;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   706  		/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   707  		 * This inner reader takes care of things appearing in the RX
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   708  		 * FIFO as we're transmitting. This will happen a lot since the
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   709  		 * clock starts running when you put things into the TX FIFO,
25985edcedea639 drivers/spi/amba-pl022.c Lucas De Marchi          2011-03-30   710  		 * and then things are continuously clocked into the RX FIFO.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   711  		 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   712  		while ((readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_RNE)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   713  		       && (pl022->rx < pl022->rx_end)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   714  			switch (pl022->read) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   715  			case READING_NULL:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   716  				readw(SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   717  				break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   718  			case READING_U8:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   719  				*(u8 *) (pl022->rx) =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   720  					readw(SSP_DR(pl022->virtbase)) & 0xFFU;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   721  				break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   722  			case READING_U16:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   723  				*(u16 *) (pl022->rx) =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   724  					(u16) readw(SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   725  				break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   726  			case READING_U32:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   727  				*(u32 *) (pl022->rx) =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   728  					readl(SSP_DR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   729  				break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   730  			}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   731  			pl022->rx += (pl022->cur_chip->n_bytes);
fc05475f867624d drivers/spi/amba-pl022.c Linus Walleij            2010-01-22   732  			pl022->exp_fifo_level--;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   733  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   734  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   735  	/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   736  	 * When we exit here the TX FIFO should be full and the RX FIFO
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   737  	 * should be empty
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   738  	 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   739  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   740  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   741  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   742   * next_transfer - Move to the Next transfer in the current spi message
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   743   * @pl022: SSP driver private data structure
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   744   *
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   745   * This function moves though the linked list of spi transfers in the
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   746   * current spi message and returns with the state of current spi
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   747   * message i.e whether its last transfer is done(STATE_DONE) or
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   748   * Next transfer is ready(STATE_RUNNING)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   749   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   750  static void *next_transfer(struct pl022 *pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   751  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   752  	struct spi_message *msg = pl022->cur_msg;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   753  	struct spi_transfer *trans = pl022->cur_transfer;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   754  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   755  	/* Move to next transfer */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   756  	if (trans->transfer_list.next != &msg->transfers) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   757  		pl022->cur_transfer =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   758  		    list_entry(trans->transfer_list.next,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   759  			       struct spi_transfer, transfer_list);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   760  		return STATE_RUNNING;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   761  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   762  	return STATE_DONE;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09   763  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   764  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   765  /*
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   766   * This DMA functionality is only compiled in if we have
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   767   * access to the generic DMA devices/DMA engine.
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   768   */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   769  #ifdef CONFIG_DMA_ENGINE
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   770  static void unmap_free_dma_scatter(struct pl022 *pl022)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   771  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   772  	/* Unmap and free the SG tables */
b729889686afb7d drivers/spi/amba-pl022.c Linus Walleij            2010-12-22   773  	dma_unmap_sg(pl022->dma_tx_channel->device->dev, pl022->sgt_tx.sgl,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   774  		     pl022->sgt_tx.nents, DMA_TO_DEVICE);
b729889686afb7d drivers/spi/amba-pl022.c Linus Walleij            2010-12-22   775  	dma_unmap_sg(pl022->dma_rx_channel->device->dev, pl022->sgt_rx.sgl,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   776  		     pl022->sgt_rx.nents, DMA_FROM_DEVICE);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   777  	sg_free_table(&pl022->sgt_rx);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   778  	sg_free_table(&pl022->sgt_tx);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   779  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   780  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   781  static void dma_callback(void *data)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   782  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   783  	struct pl022 *pl022 = data;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   784  	struct spi_message *msg = pl022->cur_msg;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   785  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   786  	BUG_ON(!pl022->sgt_rx.sgl);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   787  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   788  #ifdef VERBOSE_DEBUG
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   789  	/*
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   790  	 * Optionally dump out buffers to inspect contents, this is
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   791  	 * good if you want to convince yourself that the loopback
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   792  	 * read/write contents are the same, when adopting to a new
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   793  	 * DMA engine.
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   794  	 */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   795  	{
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   796  		struct scatterlist *sg;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   797  		unsigned int i;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   798  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   799  		dma_sync_sg_for_cpu(&pl022->adev->dev,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   800  				    pl022->sgt_rx.sgl,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   801  				    pl022->sgt_rx.nents,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   802  				    DMA_FROM_DEVICE);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   803  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   804  		for_each_sg(pl022->sgt_rx.sgl, sg, pl022->sgt_rx.nents, i) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   805  			dev_dbg(&pl022->adev->dev, "SPI RX SG ENTRY: %d", i);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   806  			print_hex_dump(KERN_ERR, "SPI RX: ",
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   807  				       DUMP_PREFIX_OFFSET,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   808  				       16,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   809  				       1,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   810  				       sg_virt(sg),
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   811  				       sg_dma_len(sg),
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   812  				       1);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   813  		}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   814  		for_each_sg(pl022->sgt_tx.sgl, sg, pl022->sgt_tx.nents, i) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   815  			dev_dbg(&pl022->adev->dev, "SPI TX SG ENTRY: %d", i);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   816  			print_hex_dump(KERN_ERR, "SPI TX: ",
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   817  				       DUMP_PREFIX_OFFSET,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   818  				       16,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   819  				       1,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   820  				       sg_virt(sg),
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   821  				       sg_dma_len(sg),
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   822  				       1);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   823  		}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   824  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   825  #endif
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   826  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   827  	unmap_free_dma_scatter(pl022);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   828  
25985edcedea639 drivers/spi/amba-pl022.c Lucas De Marchi          2011-03-30   829  	/* Update total bytes transferred */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   830  	msg->actual_length += pl022->cur_transfer->len;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   831  	/* Move to next transfer */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   832  	msg->state = next_transfer(pl022);
c0b07605f1a0285 drivers/spi/spi-pl022.c  Fredrik Ternerot         2018-11-13   833  	if (msg->state != STATE_DONE && pl022->cur_transfer->cs_change)
c0b07605f1a0285 drivers/spi/spi-pl022.c  Fredrik Ternerot         2018-11-13   834  		pl022_cs_control(pl022, SSP_CHIP_DESELECT);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   835  	tasklet_schedule(&pl022->pump_transfers);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   836  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   837  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   838  static void setup_dma_scatter(struct pl022 *pl022,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   839  			      void *buffer,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   840  			      unsigned int length,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   841  			      struct sg_table *sgtab)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   842  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   843  	struct scatterlist *sg;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   844  	int bytesleft = length;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   845  	void *bufp = buffer;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   846  	int mapbytes;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   847  	int i;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   848  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   849  	if (buffer) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   850  		for_each_sg(sgtab->sgl, sg, sgtab->nents, i) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   851  			/*
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   852  			 * If there are less bytes left than what fits
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   853  			 * in the current page (plus page alignment offset)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   854  			 * we just feed in this, else we stuff in as much
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   855  			 * as we can.
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   856  			 */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   857  			if (bytesleft < (PAGE_SIZE - offset_in_page(bufp)))
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   858  				mapbytes = bytesleft;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   859  			else
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   860  				mapbytes = PAGE_SIZE - offset_in_page(bufp);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   861  			sg_set_page(sg, virt_to_page(bufp),
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   862  				    mapbytes, offset_in_page(bufp));
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   863  			bufp += mapbytes;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   864  			bytesleft -= mapbytes;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   865  			dev_dbg(&pl022->adev->dev,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   866  				"set RX/TX target page @ %p, %d bytes, %d left\n",
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   867  				bufp, mapbytes, bytesleft);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   868  		}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   869  	} else {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   870  		/* Map the dummy buffer on every page */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   871  		for_each_sg(sgtab->sgl, sg, sgtab->nents, i) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   872  			if (bytesleft < PAGE_SIZE)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   873  				mapbytes = bytesleft;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   874  			else
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   875  				mapbytes = PAGE_SIZE;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   876  			sg_set_page(sg, virt_to_page(pl022->dummypage),
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   877  				    mapbytes, 0);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   878  			bytesleft -= mapbytes;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   879  			dev_dbg(&pl022->adev->dev,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   880  				"set RX/TX to dummy page %d bytes, %d left\n",
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   881  				mapbytes, bytesleft);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   882  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   883  		}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   884  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   885  	BUG_ON(bytesleft);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   886  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   887  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   888  /**
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   889   * configure_dma - configures the channels for the next transfer
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   890   * @pl022: SSP driver's private data structure
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   891   */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   892  static int configure_dma(struct pl022 *pl022)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   893  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   894  	struct dma_slave_config rx_conf = {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   895  		.src_addr = SSP_DR(pl022->phybase),
a485df4b4404379 drivers/spi/spi-pl022.c  Vinod Koul               2011-10-14   896  		.direction = DMA_DEV_TO_MEM,
258aea76f552cc7 drivers/spi/spi-pl022.c  Viresh Kumar             2012-02-01   897  		.device_fc = false,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   898  	};
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   899  	struct dma_slave_config tx_conf = {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   900  		.dst_addr = SSP_DR(pl022->phybase),
a485df4b4404379 drivers/spi/spi-pl022.c  Vinod Koul               2011-10-14   901  		.direction = DMA_MEM_TO_DEV,
258aea76f552cc7 drivers/spi/spi-pl022.c  Viresh Kumar             2012-02-01   902  		.device_fc = false,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   903  	};
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   904  	unsigned int pages;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   905  	int ret;
082086f2ce53c69 drivers/spi/amba-pl022.c Linus Walleij            2010-12-22   906  	int rx_sglen, tx_sglen;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   907  	struct dma_chan *rxchan = pl022->dma_rx_channel;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   908  	struct dma_chan *txchan = pl022->dma_tx_channel;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   909  	struct dma_async_tx_descriptor *rxdesc;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   910  	struct dma_async_tx_descriptor *txdesc;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   911  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   912  	/* Check that the channels are available */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   913  	if (!rxchan || !txchan)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   914  		return -ENODEV;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   915  
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   916  	/*
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   917  	 * If supplied, the DMA burstsize should equal the FIFO trigger level.
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   918  	 * Notice that the DMA engine uses one-to-one mapping. Since we can
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   919  	 * not trigger on 2 elements this needs explicit mapping rather than
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   920  	 * calculation.
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   921  	 */
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   922  	switch (pl022->rx_lev_trig) {
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   923  	case SSP_RX_1_OR_MORE_ELEM:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   924  		rx_conf.src_maxburst = 1;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   925  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   926  	case SSP_RX_4_OR_MORE_ELEM:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   927  		rx_conf.src_maxburst = 4;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   928  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   929  	case SSP_RX_8_OR_MORE_ELEM:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   930  		rx_conf.src_maxburst = 8;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   931  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   932  	case SSP_RX_16_OR_MORE_ELEM:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   933  		rx_conf.src_maxburst = 16;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   934  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   935  	case SSP_RX_32_OR_MORE_ELEM:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   936  		rx_conf.src_maxburst = 32;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   937  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   938  	default:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   939  		rx_conf.src_maxburst = pl022->vendor->fifodepth >> 1;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   940  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   941  	}
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   942  
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   943  	switch (pl022->tx_lev_trig) {
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   944  	case SSP_TX_1_OR_MORE_EMPTY_LOC:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   945  		tx_conf.dst_maxburst = 1;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   946  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   947  	case SSP_TX_4_OR_MORE_EMPTY_LOC:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   948  		tx_conf.dst_maxburst = 4;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   949  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   950  	case SSP_TX_8_OR_MORE_EMPTY_LOC:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   951  		tx_conf.dst_maxburst = 8;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   952  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   953  	case SSP_TX_16_OR_MORE_EMPTY_LOC:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   954  		tx_conf.dst_maxburst = 16;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   955  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   956  	case SSP_TX_32_OR_MORE_EMPTY_LOC:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   957  		tx_conf.dst_maxburst = 32;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   958  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   959  	default:
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   960  		tx_conf.dst_maxburst = pl022->vendor->fifodepth >> 1;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   961  		break;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   962  	}
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16   963  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   964  	switch (pl022->read) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   965  	case READING_NULL:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   966  		/* Use the same as for writing */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   967  		rx_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_UNDEFINED;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   968  		break;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   969  	case READING_U8:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   970  		rx_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   971  		break;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   972  	case READING_U16:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   973  		rx_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   974  		break;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   975  	case READING_U32:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   976  		rx_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   977  		break;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   978  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   979  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   980  	switch (pl022->write) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   981  	case WRITING_NULL:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   982  		/* Use the same as for reading */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   983  		tx_conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_UNDEFINED;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   984  		break;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   985  	case WRITING_U8:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   986  		tx_conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   987  		break;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   988  	case WRITING_U16:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   989  		tx_conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   990  		break;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   991  	case WRITING_U32:
bc3f67a3e1b2075 drivers/spi/amba-pl022.c Joe Perches              2010-11-14   992  		tx_conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   993  		break;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   994  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   995  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   996  	/* SPI pecularity: we need to read and write the same width */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   997  	if (rx_conf.src_addr_width == DMA_SLAVE_BUSWIDTH_UNDEFINED)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   998  		rx_conf.src_addr_width = tx_conf.dst_addr_width;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29   999  	if (tx_conf.dst_addr_width == DMA_SLAVE_BUSWIDTH_UNDEFINED)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1000  		tx_conf.dst_addr_width = rx_conf.src_addr_width;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1001  	BUG_ON(rx_conf.src_addr_width != tx_conf.dst_addr_width);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1002  
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1003  	dmaengine_slave_config(rxchan, &rx_conf);
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1004  	dmaengine_slave_config(txchan, &tx_conf);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1005  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1006  	/* Create sglists for the transfers */
b181565ee6a0f89 drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1007  	pages = DIV_ROUND_UP(pl022->cur_transfer->len, PAGE_SIZE);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1008  	dev_dbg(&pl022->adev->dev, "using %d pages for transfer\n", pages);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1009  
538a18dc189ef5d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1010  	ret = sg_alloc_table(&pl022->sgt_rx, pages, GFP_ATOMIC);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1011  	if (ret)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1012  		goto err_alloc_rx_sg;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1013  
538a18dc189ef5d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1014  	ret = sg_alloc_table(&pl022->sgt_tx, pages, GFP_ATOMIC);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1015  	if (ret)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1016  		goto err_alloc_tx_sg;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1017  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1018  	/* Fill in the scatterlists for the RX+TX buffers */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1019  	setup_dma_scatter(pl022, pl022->rx,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1020  			  pl022->cur_transfer->len, &pl022->sgt_rx);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1021  	setup_dma_scatter(pl022, pl022->tx,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1022  			  pl022->cur_transfer->len, &pl022->sgt_tx);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1023  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1024  	/* Map DMA buffers */
082086f2ce53c69 drivers/spi/amba-pl022.c Linus Walleij            2010-12-22  1025  	rx_sglen = dma_map_sg(rxchan->device->dev, pl022->sgt_rx.sgl,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1026  			   pl022->sgt_rx.nents, DMA_FROM_DEVICE);
082086f2ce53c69 drivers/spi/amba-pl022.c Linus Walleij            2010-12-22  1027  	if (!rx_sglen)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1028  		goto err_rx_sgmap;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1029  
082086f2ce53c69 drivers/spi/amba-pl022.c Linus Walleij            2010-12-22  1030  	tx_sglen = dma_map_sg(txchan->device->dev, pl022->sgt_tx.sgl,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1031  			   pl022->sgt_tx.nents, DMA_TO_DEVICE);
082086f2ce53c69 drivers/spi/amba-pl022.c Linus Walleij            2010-12-22  1032  	if (!tx_sglen)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1033  		goto err_tx_sgmap;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1034  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1035  	/* Send both scatterlists */
16052827d98fbc1 drivers/spi/spi-pl022.c  Alexandre Bounine        2012-03-08  1036  	rxdesc = dmaengine_prep_slave_sg(rxchan,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1037  				      pl022->sgt_rx.sgl,
082086f2ce53c69 drivers/spi/amba-pl022.c Linus Walleij            2010-12-22  1038  				      rx_sglen,
a485df4b4404379 drivers/spi/spi-pl022.c  Vinod Koul               2011-10-14  1039  				      DMA_DEV_TO_MEM,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1040  				      DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1041  	if (!rxdesc)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1042  		goto err_rxdesc;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1043  
16052827d98fbc1 drivers/spi/spi-pl022.c  Alexandre Bounine        2012-03-08  1044  	txdesc = dmaengine_prep_slave_sg(txchan,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1045  				      pl022->sgt_tx.sgl,
082086f2ce53c69 drivers/spi/amba-pl022.c Linus Walleij            2010-12-22  1046  				      tx_sglen,
a485df4b4404379 drivers/spi/spi-pl022.c  Vinod Koul               2011-10-14  1047  				      DMA_MEM_TO_DEV,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1048  				      DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1049  	if (!txdesc)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1050  		goto err_txdesc;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1051  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1052  	/* Put the callback on the RX transfer only, that should finish last */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1053  	rxdesc->callback = dma_callback;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1054  	rxdesc->callback_param = pl022;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1055  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1056  	/* Submit and fire RX and TX with TX last so we're ready to read! */
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1057  	dmaengine_submit(rxdesc);
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1058  	dmaengine_submit(txdesc);
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1059  	dma_async_issue_pending(rxchan);
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1060  	dma_async_issue_pending(txchan);
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1061  	pl022->dma_running = true;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1062  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1063  	return 0;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1064  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1065  err_txdesc:
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1066  	dmaengine_terminate_all(txchan);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1067  err_rxdesc:
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1068  	dmaengine_terminate_all(rxchan);
b729889686afb7d drivers/spi/amba-pl022.c Linus Walleij            2010-12-22  1069  	dma_unmap_sg(txchan->device->dev, pl022->sgt_tx.sgl,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1070  		     pl022->sgt_tx.nents, DMA_TO_DEVICE);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1071  err_tx_sgmap:
b729889686afb7d drivers/spi/amba-pl022.c Linus Walleij            2010-12-22  1072  	dma_unmap_sg(rxchan->device->dev, pl022->sgt_rx.sgl,
3ffa6158f002e09 drivers/spi/spi-pl022.c  Ray Jui                  2014-10-09  1073  		     pl022->sgt_rx.nents, DMA_FROM_DEVICE);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1074  err_rx_sgmap:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1075  	sg_free_table(&pl022->sgt_tx);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1076  err_alloc_tx_sg:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1077  	sg_free_table(&pl022->sgt_rx);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1078  err_alloc_rx_sg:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1079  	return -ENOMEM;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1080  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1081  
fd4a319bc933ae9 drivers/spi/spi-pl022.c  Grant Likely             2012-12-07  1082  static int pl022_dma_probe(struct pl022 *pl022)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1083  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1084  	dma_cap_mask_t mask;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1085  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1086  	/* Try to acquire a generic DMA engine slave channel */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1087  	dma_cap_zero(mask);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1088  	dma_cap_set(DMA_SLAVE, mask);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1089  	/*
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1090  	 * We need both RX and TX channels to do DMA, else do none
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1091  	 * of them.
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1092  	 */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1093  	pl022->dma_rx_channel = dma_request_channel(mask,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1094  					    pl022->master_info->dma_filter,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1095  					    pl022->master_info->dma_rx_param);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1096  	if (!pl022->dma_rx_channel) {
43c640157d4366a drivers/spi/amba-pl022.c Viresh Kumar             2011-05-16  1097  		dev_dbg(&pl022->adev->dev, "no RX DMA channel!\n");
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1098  		goto err_no_rxchan;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1099  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1100  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1101  	pl022->dma_tx_channel = dma_request_channel(mask,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1102  					    pl022->master_info->dma_filter,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1103  					    pl022->master_info->dma_tx_param);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1104  	if (!pl022->dma_tx_channel) {
43c640157d4366a drivers/spi/amba-pl022.c Viresh Kumar             2011-05-16  1105  		dev_dbg(&pl022->adev->dev, "no TX DMA channel!\n");
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1106  		goto err_no_txchan;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1107  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1108  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1109  	pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL);
77538f4a98dc542 drivers/spi/spi-pl022.c  Jingoo Han               2014-04-29  1110  	if (!pl022->dummypage)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1111  		goto err_no_dummypage;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1112  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1113  	dev_info(&pl022->adev->dev, "setup for DMA on RX %s, TX %s\n",
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1114  		 dma_chan_name(pl022->dma_rx_channel),
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1115  		 dma_chan_name(pl022->dma_tx_channel));
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1116  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1117  	return 0;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1118  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1119  err_no_dummypage:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1120  	dma_release_channel(pl022->dma_tx_channel);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1121  err_no_txchan:
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1122  	dma_release_channel(pl022->dma_rx_channel);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1123  	pl022->dma_rx_channel = NULL;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1124  err_no_rxchan:
43c640157d4366a drivers/spi/amba-pl022.c Viresh Kumar             2011-05-16  1125  	dev_err(&pl022->adev->dev,
43c640157d4366a drivers/spi/amba-pl022.c Viresh Kumar             2011-05-16  1126  			"Failed to work in dma mode, work without dma!\n");
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1127  	return -ENODEV;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1128  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1129  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1130  static int pl022_dma_autoprobe(struct pl022 *pl022)
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1131  {
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1132  	struct device *dev = &pl022->adev->dev;
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1133  	struct dma_chan *chan;
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1134  	int err;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1135  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1136  	/* automatically configure DMA channels from platform, normally using DT */
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1137  	chan = dma_request_slave_channel_reason(dev, "rx");
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1138  	if (IS_ERR(chan)) {
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1139  		err = PTR_ERR(chan);
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1140  		goto err_no_rxchan;
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1141  	}
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1142  
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1143  	pl022->dma_rx_channel = chan;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1144  
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1145  	chan = dma_request_slave_channel_reason(dev, "tx");
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1146  	if (IS_ERR(chan)) {
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1147  		err = PTR_ERR(chan);
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1148  		goto err_no_txchan;
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1149  	}
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1150  
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1151  	pl022->dma_tx_channel = chan;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1152  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1153  	pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL);
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1154  	if (!pl022->dummypage) {
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1155  		err = -ENOMEM;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1156  		goto err_no_dummypage;
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1157  	}
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1158  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1159  	return 0;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1160  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1161  err_no_dummypage:
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1162  	dma_release_channel(pl022->dma_tx_channel);
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1163  	pl022->dma_tx_channel = NULL;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1164  err_no_txchan:
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1165  	dma_release_channel(pl022->dma_rx_channel);
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1166  	pl022->dma_rx_channel = NULL;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1167  err_no_rxchan:
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  1168  	return err;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1169  }
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1170  		
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1171  static void terminate_dma(struct pl022 *pl022)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1172  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1173  	struct dma_chan *rxchan = pl022->dma_rx_channel;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1174  	struct dma_chan *txchan = pl022->dma_tx_channel;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1175  
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1176  	dmaengine_terminate_all(rxchan);
ecd442fd9e388a3 drivers/spi/amba-pl022.c Linus Walleij            2011-02-08  1177  	dmaengine_terminate_all(txchan);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1178  	unmap_free_dma_scatter(pl022);
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1179  	pl022->dma_running = false;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1180  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1181  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1182  static void pl022_dma_remove(struct pl022 *pl022)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1183  {
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1184  	if (pl022->dma_running)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1185  		terminate_dma(pl022);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1186  	if (pl022->dma_tx_channel)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1187  		dma_release_channel(pl022->dma_tx_channel);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1188  	if (pl022->dma_rx_channel)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1189  		dma_release_channel(pl022->dma_rx_channel);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1190  	kfree(pl022->dummypage);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1191  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1192  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1193  #else
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1194  static inline int configure_dma(struct pl022 *pl022)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1195  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1196  	return -ENODEV;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1197  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1198  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1199  static inline int pl022_dma_autoprobe(struct pl022 *pl022)
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1200  {
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1201  	return 0;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1202  }
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  1203  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1204  static inline int pl022_dma_probe(struct pl022 *pl022)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1205  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1206  	return 0;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1207  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1208  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1209  static inline void pl022_dma_remove(struct pl022 *pl022)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1210  {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1211  }
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1212  #endif
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1213  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1214  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1215   * pl022_interrupt_handler - Interrupt handler for SSP controller
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1216   *
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1217   * This function handles interrupts generated for an interrupt based transfer.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1218   * If a receive overrun (ROR) interrupt is there then we disable SSP, flag the
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1219   * current message's state as STATE_ERROR and schedule the tasklet
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1220   * pump_transfers which will do the postprocessing of the current message by
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1221   * calling giveback(). Otherwise it reads data from RX FIFO till there is no
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1222   * more data, and writes data in TX FIFO till it is not full. If we complete
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1223   * the transfer we move to the next transfer and schedule the tasklet.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1224   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1225  static irqreturn_t pl022_interrupt_handler(int irq, void *dev_id)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1226  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1227  	struct pl022 *pl022 = dev_id;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1228  	struct spi_message *msg = pl022->cur_msg;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1229  	u16 irq_status = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1230  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1231  	if (unlikely(!msg)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1232  		dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1233  			"bad message state in interrupt handler");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1234  		/* Never fail */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1235  		return IRQ_HANDLED;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1236  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1237  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1238  	/* Read the Interrupt Status Register */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1239  	irq_status = readw(SSP_MIS(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1240  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1241  	if (unlikely(!irq_status))
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1242  		return IRQ_NONE;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1243  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1244  	/*
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1245  	 * This handles the FIFO interrupts, the timeout
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1246  	 * interrupts are flatly ignored, they cannot be
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1247  	 * trusted.
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1248  	 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1249  	if (unlikely(irq_status & SSP_MIS_MASK_RORMIS)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1250  		/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1251  		 * Overrun interrupt - bail out since our Data has been
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1252  		 * corrupted
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1253  		 */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1254  		dev_err(&pl022->adev->dev, "FIFO overrun\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1255  		if (readw(SSP_SR(pl022->virtbase)) & SSP_SR_MASK_RFF)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1256  			dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1257  				"RXFIFO is full\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1258  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1259  		/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1260  		 * Disable and clear interrupts, disable SSP,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1261  		 * mark message with bad status so it can be
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1262  		 * retried.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1263  		 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1264  		writew(DISABLE_ALL_INTERRUPTS,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1265  		       SSP_IMSC(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1266  		writew(CLEAR_ALL_INTERRUPTS, SSP_ICR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1267  		writew((readw(SSP_CR1(pl022->virtbase)) &
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1268  			(~SSP_CR1_MASK_SSE)), SSP_CR1(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1269  		msg->state = STATE_ERROR;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1270  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1271  		/* Schedule message queue handler */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1272  		tasklet_schedule(&pl022->pump_transfers);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1273  		return IRQ_HANDLED;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1274  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1275  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1276  	readwriter(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1277  
7183d1ebda477c4 drivers/spi/spi-pl022.c  Alexander Sverdlin       2015-02-27  1278  	if (pl022->tx == pl022->tx_end) {
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1279  		/* Disable Transmit interrupt, enable receive interrupt */
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1280  		writew((readw(SSP_IMSC(pl022->virtbase)) &
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1281  		       ~SSP_IMSC_MASK_TXIM) | SSP_IMSC_MASK_RXIM,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1282  		       SSP_IMSC(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1283  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1284  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1285  	/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1286  	 * Since all transactions must write as much as shall be read,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1287  	 * we can conclude the entire transaction once RX is complete.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1288  	 * At this point, all TX will always be finished.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1289  	 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1290  	if (pl022->rx >= pl022->rx_end) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1291  		writew(DISABLE_ALL_INTERRUPTS,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1292  		       SSP_IMSC(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1293  		writew(CLEAR_ALL_INTERRUPTS, SSP_ICR(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1294  		if (unlikely(pl022->rx > pl022->rx_end)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1295  			dev_warn(&pl022->adev->dev, "read %u surplus "
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1296  				 "bytes (did you request an odd "
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1297  				 "number of bytes on a 16bit bus?)\n",
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1298  				 (u32) (pl022->rx - pl022->rx_end));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1299  		}
25985edcedea639 drivers/spi/amba-pl022.c Lucas De Marchi          2011-03-30  1300  		/* Update total bytes transferred */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1301  		msg->actual_length += pl022->cur_transfer->len;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1302  		/* Move to next transfer */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1303  		msg->state = next_transfer(pl022);
c0b07605f1a0285 drivers/spi/spi-pl022.c  Fredrik Ternerot         2018-11-13  1304  		if (msg->state != STATE_DONE && pl022->cur_transfer->cs_change)
c0b07605f1a0285 drivers/spi/spi-pl022.c  Fredrik Ternerot         2018-11-13  1305  			pl022_cs_control(pl022, SSP_CHIP_DESELECT);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1306  		tasklet_schedule(&pl022->pump_transfers);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1307  		return IRQ_HANDLED;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1308  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1309  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1310  	return IRQ_HANDLED;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1311  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1312  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1313  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1314   * This sets up the pointers to memory for the next message to
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1315   * send out on the SPI bus.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1316   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1317  static int set_up_next_transfer(struct pl022 *pl022,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1318  				struct spi_transfer *transfer)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1319  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1320  	int residue;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1321  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1322  	/* Sanity check the message for this bus width */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1323  	residue = pl022->cur_transfer->len % pl022->cur_chip->n_bytes;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1324  	if (unlikely(residue != 0)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1325  		dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1326  			"message of %u bytes to transmit but the current "
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1327  			"chip bus has a data width of %u bytes!\n",
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1328  			pl022->cur_transfer->len,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1329  			pl022->cur_chip->n_bytes);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1330  		dev_err(&pl022->adev->dev, "skipping this message\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1331  		return -EIO;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1332  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1333  	pl022->tx = (void *)transfer->tx_buf;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1334  	pl022->tx_end = pl022->tx + pl022->cur_transfer->len;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1335  	pl022->rx = (void *)transfer->rx_buf;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1336  	pl022->rx_end = pl022->rx + pl022->cur_transfer->len;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1337  	pl022->write =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1338  	    pl022->tx ? pl022->cur_chip->write : WRITING_NULL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1339  	pl022->read = pl022->rx ? pl022->cur_chip->read : READING_NULL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1340  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1341  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1342  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1343  /**
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1344   * pump_transfers - Tasklet function which schedules next transfer
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1345   * when running in interrupt or DMA transfer mode.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1346   * @data: SSP driver private data structure
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1347   *
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1348   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1349  static void pump_transfers(unsigned long data)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1350  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1351  	struct pl022 *pl022 = (struct pl022 *) data;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1352  	struct spi_message *message = NULL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1353  	struct spi_transfer *transfer = NULL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1354  	struct spi_transfer *previous = NULL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1355  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1356  	/* Get current state information */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1357  	message = pl022->cur_msg;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1358  	transfer = pl022->cur_transfer;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1359  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1360  	/* Handle for abort */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1361  	if (message->state == STATE_ERROR) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1362  		message->status = -EIO;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1363  		giveback(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1364  		return;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1365  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1366  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1367  	/* Handle end of message */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1368  	if (message->state == STATE_DONE) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1369  		message->status = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1370  		giveback(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1371  		return;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1372  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1373  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1374  	/* Delay if requested at end of transfer before CS change */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1375  	if (message->state == STATE_RUNNING) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1376  		previous = list_entry(transfer->transfer_list.prev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1377  					struct spi_transfer,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1378  					transfer_list);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1379  		if (previous->delay_usecs)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1380  			/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1381  			 * FIXME: This runs in interrupt context.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1382  			 * Is this really smart?
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1383  			 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1384  			udelay(previous->delay_usecs);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1385  
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10  1386  		/* Reselect chip select only if cs_change was requested */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1387  		if (previous->cs_change)
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1388  			pl022_cs_control(pl022, SSP_CHIP_SELECT);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1389  	} else {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1390  		/* STATE_START */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1391  		message->state = STATE_RUNNING;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1392  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1393  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1394  	if (set_up_next_transfer(pl022, transfer)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1395  		message->state = STATE_ERROR;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1396  		message->status = -EIO;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1397  		giveback(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1398  		return;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1399  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1400  	/* Flush the FIFOs and let's go! */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1401  	flush(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1402  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1403  	if (pl022->cur_chip->enable_dma) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1404  		if (configure_dma(pl022)) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1405  			dev_dbg(&pl022->adev->dev,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1406  				"configuration of DMA failed, fall back to interrupt mode\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1407  			goto err_config_dma;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1408  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1409  		return;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1410  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1411  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1412  err_config_dma:
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1413  	/* enable all interrupts except RX */
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1414  	writew(ENABLE_ALL_INTERRUPTS & ~SSP_IMSC_MASK_RXIM, SSP_IMSC(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1415  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1416  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1417  static void do_interrupt_dma_transfer(struct pl022 *pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1418  {
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1419  	/*
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1420  	 * Default is to enable all interrupts except RX -
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1421  	 * this will be enabled once TX is complete
172289df4004ccc drivers/spi/spi-pl022.c  Chris Blair              2011-06-04  1422  	 */
d555ea05f9d8ebf drivers/spi/spi-pl022.c  Mark Brown               2014-08-01  1423  	u32 irqflags = (u32)(ENABLE_ALL_INTERRUPTS & ~SSP_IMSC_MASK_RXIM);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1424  
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10  1425  	/* Enable target chip, if not already active */
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10  1426  	if (!pl022->next_msg_cs_active)
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1427  		pl022_cs_control(pl022, SSP_CHIP_SELECT);
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10  1428  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1429  	if (set_up_next_transfer(pl022, pl022->cur_transfer)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1430  		/* Error path */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1431  		pl022->cur_msg->state = STATE_ERROR;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1432  		pl022->cur_msg->status = -EIO;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1433  		giveback(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1434  		return;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1435  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1436  	/* If we're using DMA, set up DMA here */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1437  	if (pl022->cur_chip->enable_dma) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1438  		/* Configure DMA transfer */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1439  		if (configure_dma(pl022)) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1440  			dev_dbg(&pl022->adev->dev,
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1441  				"configuration of DMA failed, fall back to interrupt mode\n");
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1442  			goto err_config_dma;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1443  		}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1444  		/* Disable interrupts in DMA mode, IRQ from DMA controller */
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1445  		irqflags = DISABLE_ALL_INTERRUPTS;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1446  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1447  err_config_dma:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1448  	/* Enable SSP, turn on interrupts */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1449  	writew((readw(SSP_CR1(pl022->virtbase)) | SSP_CR1_MASK_SSE),
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1450  	       SSP_CR1(pl022->virtbase));
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1451  	writew(irqflags, SSP_IMSC(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1452  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1453  
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1454  static void print_current_status(struct pl022 *pl022)
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1455  {
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1456  	u32 read_cr0;
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1457  	u16 read_cr1, read_dmacr, read_sr;
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1458  
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1459  	if (pl022->vendor->extended_cr)
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1460  		read_cr0 = readl(SSP_CR0(pl022->virtbase));
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1461  	else
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1462  		read_cr0 = readw(SSP_CR0(pl022->virtbase));
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1463  	read_cr1 = readw(SSP_CR1(pl022->virtbase));
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1464  	read_dmacr = readw(SSP_DMACR(pl022->virtbase));
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1465  	read_sr = readw(SSP_SR(pl022->virtbase));
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1466  
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1467  	dev_warn(&pl022->adev->dev, "spi-pl022 CR0: %x\n", read_cr0);
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1468  	dev_warn(&pl022->adev->dev, "spi-pl022 CR1: %x\n", read_cr1);
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1469  	dev_warn(&pl022->adev->dev, "spi-pl022 DMACR: %x\n", read_dmacr);
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1470  	dev_warn(&pl022->adev->dev, "spi-pl022 SR: %x\n", read_sr);
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1471  	dev_warn(&pl022->adev->dev,
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1472  			"spi-pl022 exp_fifo_level/fifodepth: %u/%d\n",
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1473  			pl022->exp_fifo_level,
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1474  			pl022->vendor->fifodepth);
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1475  
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1476  }
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1477  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1478  static void do_polling_transfer(struct pl022 *pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1479  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1480  	struct spi_message *message = NULL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1481  	struct spi_transfer *transfer = NULL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1482  	struct spi_transfer *previous = NULL;
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1483  	unsigned long time, timeout;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1484  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1485  	message = pl022->cur_msg;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1486  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1487  	while (message->state != STATE_DONE) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1488  		/* Handle for abort */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1489  		if (message->state == STATE_ERROR)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1490  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1491  		transfer = pl022->cur_transfer;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1492  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1493  		/* Delay if requested at end of transfer */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1494  		if (message->state == STATE_RUNNING) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1495  			previous =
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1496  			    list_entry(transfer->transfer_list.prev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1497  				       struct spi_transfer, transfer_list);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1498  			if (previous->delay_usecs)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1499  				udelay(previous->delay_usecs);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1500  			if (previous->cs_change)
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1501  				pl022_cs_control(pl022, SSP_CHIP_SELECT);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1502  		} else {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1503  			/* STATE_START */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1504  			message->state = STATE_RUNNING;
8b8d719161c3866 drivers/spi/spi-pl022.c  Virupax Sadashivpetimath 2011-11-10  1505  			if (!pl022->next_msg_cs_active)
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1506  				pl022_cs_control(pl022, SSP_CHIP_SELECT);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1507  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1508  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1509  		/* Configuration Changing Per Transfer */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1510  		if (set_up_next_transfer(pl022, transfer)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1511  			/* Error path */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1512  			message->state = STATE_ERROR;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1513  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1514  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1515  		/* Flush FIFOs and enable SSP */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1516  		flush(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1517  		writew((readw(SSP_CR1(pl022->virtbase)) | SSP_CR1_MASK_SSE),
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1518  		       SSP_CR1(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1519  
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1520  		dev_dbg(&pl022->adev->dev, "polling transfer ongoing ...\n");
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1521  
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1522  		timeout = jiffies + msecs_to_jiffies(SPI_POLLING_TIMEOUT);
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1523  		while (pl022->tx < pl022->tx_end || pl022->rx < pl022->rx_end) {
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1524  			time = jiffies;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1525  			readwriter(pl022);
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1526  			if (time_after(time, timeout)) {
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1527  				dev_warn(&pl022->adev->dev,
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1528  				"%s: timeout!\n", __func__);
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1529  				message->state = STATE_TIMEOUT;
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1530  				print_current_status(pl022);
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1531  				goto out;
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1532  			}
521999bd4a8c47a drivers/spi/amba-pl022.c Linus Walleij            2011-05-19  1533  			cpu_relax();
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1534  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1535  
25985edcedea639 drivers/spi/amba-pl022.c Lucas De Marchi          2011-03-30  1536  		/* Update total byte transferred */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1537  		message->actual_length += pl022->cur_transfer->len;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1538  		/* Move to next transfer */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1539  		message->state = next_transfer(pl022);
c0b07605f1a0285 drivers/spi/spi-pl022.c  Fredrik Ternerot         2018-11-13  1540  		if (message->state != STATE_DONE
c0b07605f1a0285 drivers/spi/spi-pl022.c  Fredrik Ternerot         2018-11-13  1541  		    && pl022->cur_transfer->cs_change)
c0b07605f1a0285 drivers/spi/spi-pl022.c  Fredrik Ternerot         2018-11-13  1542  			pl022_cs_control(pl022, SSP_CHIP_DESELECT);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1543  	}
a18c266f8e43004 drivers/spi/amba-pl022.c Magnus Templing          2011-05-19  1544  out:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1545  	/* Handle end of message */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1546  	if (message->state == STATE_DONE)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1547  		message->status = 0;
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1548  	else if (message->state == STATE_TIMEOUT)
7aef2b646b24247 drivers/spi/spi-pl022.c  Jiwei Sun                2019-01-18  1549  		message->status = -EAGAIN;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1550  	else
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1551  		message->status = -EIO;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1552  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1553  	giveback(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1554  	return;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1555  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1556  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1557  static int pl022_transfer_one_message(struct spi_master *master,
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1558  				      struct spi_message *msg)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1559  {
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1560  	struct pl022 *pl022 = spi_master_get_devdata(master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1561  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1562  	/* Initial message state */
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1563  	pl022->cur_msg = msg;
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1564  	msg->state = STATE_START;
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1565  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1566  	pl022->cur_transfer = list_entry(msg->transfers.next,
f1e45f86ed93b9e drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1567  					 struct spi_transfer, transfer_list);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1568  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1569  	/* Setup the SPI using the per chip configuration */
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1570  	pl022->cur_chip = spi_get_ctldata(msg->spi);
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1571  	pl022->cur_cs = pl022->chipselects[msg->spi->chip_select];
d4b6af2e0e29278 drivers/spi/spi-pl022.c  Chris Blair              2011-11-04  1572  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1573  	restore_state(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1574  	flush(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1575  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1576  	if (pl022->cur_chip->xfer_type == POLLING_TRANSFER)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1577  		do_polling_transfer(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1578  	else
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1579  		do_interrupt_dma_transfer(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1580  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1581  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1582  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1583  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1584  static int pl022_unprepare_transfer_hardware(struct spi_master *master)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1585  {
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1586  	struct pl022 *pl022 = spi_master_get_devdata(master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1587  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1588  	/* nothing more to do - disable spi/ssp and power off */
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1589  	writew((readw(SSP_CR1(pl022->virtbase)) &
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  1590  		(~SSP_CR1_MASK_SSE)), SSP_CR1(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1591  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1592  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1593  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1594  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1595  static int verify_controller_parameters(struct pl022 *pl022,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1596  				struct pl022_config_chip const *chip_info)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1597  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1598  	if ((chip_info->iface < SSP_INTERFACE_MOTOROLA_SPI)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1599  	    || (chip_info->iface > SSP_INTERFACE_UNIDIRECTIONAL)) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1600  		dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1601  			"interface is configured incorrectly\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1602  		return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1603  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1604  	if ((chip_info->iface == SSP_INTERFACE_UNIDIRECTIONAL) &&
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1605  	    (!pl022->vendor->unidir)) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1606  		dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1607  			"unidirectional mode not supported in this "
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1608  			"hardware version\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1609  		return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1610  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1611  	if ((chip_info->hierarchy != SSP_MASTER)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1612  	    && (chip_info->hierarchy != SSP_SLAVE)) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1613  		dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1614  			"hierarchy is configured incorrectly\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1615  		return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1616  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1617  	if ((chip_info->com_mode != INTERRUPT_TRANSFER)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1618  	    && (chip_info->com_mode != DMA_TRANSFER)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1619  	    && (chip_info->com_mode != POLLING_TRANSFER)) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1620  		dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1621  			"Communication mode is configured incorrectly\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1622  		return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1623  	}
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1624  	switch (chip_info->rx_lev_trig) {
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1625  	case SSP_RX_1_OR_MORE_ELEM:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1626  	case SSP_RX_4_OR_MORE_ELEM:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1627  	case SSP_RX_8_OR_MORE_ELEM:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1628  		/* These are always OK, all variants can handle this */
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1629  		break;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1630  	case SSP_RX_16_OR_MORE_ELEM:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1631  		if (pl022->vendor->fifodepth < 16) {
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1632  			dev_err(&pl022->adev->dev,
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1633  			"RX FIFO Trigger Level is configured incorrectly\n");
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1634  			return -EINVAL;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1635  		}
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1636  		break;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1637  	case SSP_RX_32_OR_MORE_ELEM:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1638  		if (pl022->vendor->fifodepth < 32) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1639  			dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1640  			"RX FIFO Trigger Level is configured incorrectly\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1641  			return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1642  		}
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1643  		break;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1644  	default:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1645  		dev_err(&pl022->adev->dev,
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1646  			"RX FIFO Trigger Level is configured incorrectly\n");
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1647  		return -EINVAL;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1648  	}
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1649  	switch (chip_info->tx_lev_trig) {
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1650  	case SSP_TX_1_OR_MORE_EMPTY_LOC:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1651  	case SSP_TX_4_OR_MORE_EMPTY_LOC:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1652  	case SSP_TX_8_OR_MORE_EMPTY_LOC:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1653  		/* These are always OK, all variants can handle this */
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1654  		break;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1655  	case SSP_TX_16_OR_MORE_EMPTY_LOC:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1656  		if (pl022->vendor->fifodepth < 16) {
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1657  			dev_err(&pl022->adev->dev,
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1658  			"TX FIFO Trigger Level is configured incorrectly\n");
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1659  			return -EINVAL;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1660  		}
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1661  		break;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1662  	case SSP_TX_32_OR_MORE_EMPTY_LOC:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1663  		if (pl022->vendor->fifodepth < 32) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1664  			dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1665  			"TX FIFO Trigger Level is configured incorrectly\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1666  			return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1667  		}
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1668  		break;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1669  	default:
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1670  		dev_err(&pl022->adev->dev,
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1671  			"TX FIFO Trigger Level is configured incorrectly\n");
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1672  		return -EINVAL;
78b2b911bf70203 drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1673  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1674  	if (chip_info->iface == SSP_INTERFACE_NATIONAL_MICROWIRE) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1675  		if ((chip_info->ctrl_len < SSP_BITS_4)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1676  		    || (chip_info->ctrl_len > SSP_BITS_32)) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1677  			dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1678  				"CTRL LEN is configured incorrectly\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1679  			return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1680  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1681  		if ((chip_info->wait_state != SSP_MWIRE_WAIT_ZERO)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1682  		    && (chip_info->wait_state != SSP_MWIRE_WAIT_ONE)) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1683  			dev_err(&pl022->adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1684  				"Wait State is configured incorrectly\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1685  			return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1686  		}
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1687  		/* Half duplex is only available in the ST Micro version */
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1688  		if (pl022->vendor->extended_cr) {
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1689  			if ((chip_info->duplex !=
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1690  			     SSP_MICROWIRE_CHANNEL_FULL_DUPLEX)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1691  			    && (chip_info->duplex !=
4a4fd47155ac49b drivers/spi/amba-pl022.c Julia Lawall             2010-09-29  1692  				SSP_MICROWIRE_CHANNEL_HALF_DUPLEX)) {
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1693  				dev_err(&pl022->adev->dev,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1694  					"Microwire duplex mode is configured incorrectly\n");
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1695  				return -EINVAL;
4a4fd47155ac49b drivers/spi/amba-pl022.c Julia Lawall             2010-09-29  1696  			}
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1697  		} else {
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1698  			if (chip_info->duplex != SSP_MICROWIRE_CHANNEL_FULL_DUPLEX)
5a1c98be1de165c drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1699  				dev_err(&pl022->adev->dev,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1700  					"Microwire half duplex mode requested,"
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1701  					" but this is only available in the"
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1702  					" ST version of PL022\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1703  			return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1704  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1705  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1706  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1707  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1708  
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1709  static inline u32 spi_rate(u32 rate, u16 cpsdvsr, u16 scr)
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1710  {
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1711  	return rate / (cpsdvsr * (1 + scr));
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1712  }
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1713  
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1714  static int calculate_effective_freq(struct pl022 *pl022, int freq, struct
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1715  				    ssp_clock_params * clk_freq)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1716  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1717  	/* Lets calculate the frequency parameters */
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1718  	u16 cpsdvsr = CPSDVR_MIN, scr = SCR_MIN;
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1719  	u32 rate, max_tclk, min_tclk, best_freq = 0, best_cpsdvsr = 0,
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1720  		best_scr = 0, tmp, found = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1721  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1722  	rate = clk_get_rate(pl022->clk);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1723  	/* cpsdvscr = 2 & scr 0 */
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1724  	max_tclk = spi_rate(rate, CPSDVR_MIN, SCR_MIN);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1725  	/* cpsdvsr = 254 & scr = 255 */
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1726  	min_tclk = spi_rate(rate, CPSDVR_MAX, SCR_MAX);
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1727  
ea505bc99f77f3f drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1728  	if (freq > max_tclk)
ea505bc99f77f3f drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1729  		dev_warn(&pl022->adev->dev,
ea505bc99f77f3f drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1730  			"Max speed that can be programmed is %d Hz, you requested %d\n",
ea505bc99f77f3f drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1731  			max_tclk, freq);
ea505bc99f77f3f drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1732  
ea505bc99f77f3f drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1733  	if (freq < min_tclk) {
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1734  		dev_err(&pl022->adev->dev,
ea505bc99f77f3f drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1735  			"Requested frequency: %d Hz is less than minimum possible %d Hz\n",
ea505bc99f77f3f drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1736  			freq, min_tclk);
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1737  		return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1738  	}
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1739  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1740  	/*
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1741  	 * best_freq will give closest possible available rate (<= requested
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1742  	 * freq) for all values of scr & cpsdvsr.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1743  	 */
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1744  	while ((cpsdvsr <= CPSDVR_MAX) && !found) {
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1745  		while (scr <= SCR_MAX) {
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1746  			tmp = spi_rate(rate, cpsdvsr, scr);
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1747  
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1748  			if (tmp > freq) {
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1749  				/* we need lower freq */
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1750  				scr++;
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1751  				continue;
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1752  			}
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1753  
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1754  			/*
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1755  			 * If found exact value, mark found and break.
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1756  			 * If found more closer value, update and break.
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1757  			 */
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1758  			if (tmp > best_freq) {
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1759  				best_freq = tmp;
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1760  				best_cpsdvsr = cpsdvsr;
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1761  				best_scr = scr;
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1762  
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1763  				if (tmp == freq)
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1764  					found = 1;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1765  			}
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1766  			/*
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1767  			 * increased scr will give lower rates, which are not
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1768  			 * required
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1769  			 */
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1770  			break;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1771  		}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1772  		cpsdvsr += 2;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1773  		scr = SCR_MIN;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1774  	}
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1775  
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1776  	WARN(!best_freq, "pl022: Matching cpsdvsr and scr not found for %d Hz rate \n",
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1777  			freq);
5eb806a3a68920a drivers/spi/spi-pl022.c  Viresh Kumar             2012-04-19  1778  
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1779  	clk_freq->cpsdvsr = (u8) (best_cpsdvsr & 0xFF);
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1780  	clk_freq->scr = (u8) (best_scr & 0xFF);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1781  	dev_dbg(&pl022->adev->dev,
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1782  		"SSP Target Frequency is: %u, Effective Frequency is %u\n",
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1783  		freq, best_freq);
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1784  	dev_dbg(&pl022->adev->dev, "SSP cpsdvsr = %d, scr = %d\n",
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1785  		clk_freq->cpsdvsr, clk_freq->scr);
0379b2a33a8a03d drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  1786  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1787  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1788  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1789  
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1790  /*
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1791   * A piece of default chip info unless the platform
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1792   * supplies it.
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1793   */
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1794  static const struct pl022_config_chip pl022_default_chip_info = {
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1795  	.com_mode = POLLING_TRANSFER,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1796  	.iface = SSP_INTERFACE_MOTOROLA_SPI,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1797  	.hierarchy = SSP_SLAVE,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1798  	.slave_tx_disable = DO_NOT_DRIVE_TX,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1799  	.rx_lev_trig = SSP_RX_1_OR_MORE_ELEM,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1800  	.tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1801  	.ctrl_len = SSP_BITS_8,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1802  	.wait_state = SSP_MWIRE_WAIT_ZERO,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1803  	.duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1804  };
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1805  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1806  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1807   * pl022_setup - setup function registered to SPI master framework
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1808   * @spi: spi device which is requesting setup
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1809   *
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1810   * This function is registered to the SPI framework for this SPI master
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1811   * controller. If it is the first time when setup is called by this device,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1812   * this function will initialize the runtime state for this chip and save
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1813   * the same in the device structure. Else it will update the runtime info
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1814   * with the updated chip info. Nothing is really being written to the
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1815   * controller hardware here, that is not done until the actual transfer
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1816   * commence.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1817   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1818  static int pl022_setup(struct spi_device *spi)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1819  {
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1820  	struct pl022_config_chip const *chip_info;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1821  	struct pl022_config_chip chip_info_dt;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1822  	struct chip_data *chip;
c4a4784308f5cb8 drivers/spi/spi-pl022.c  Jonas Aaberg             2011-02-28  1823  	struct ssp_clock_params clk_freq = { .cpsdvsr = 0, .scr = 0};
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1824  	int status = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1825  	struct pl022 *pl022 = spi_master_get_devdata(spi->master);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1826  	unsigned int bits = spi->bits_per_word;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1827  	u32 tmp;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1828  	struct device_node *np = spi->dev.of_node;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1829  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1830  	if (!spi->max_speed_hz)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1831  		return -EINVAL;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1832  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1833  	/* Get controller_state if one is supplied */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1834  	chip = spi_get_ctldata(spi);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1835  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1836  	if (chip == NULL) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1837  		chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
77538f4a98dc542 drivers/spi/spi-pl022.c  Jingoo Han               2014-04-29  1838  		if (!chip)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1839  			return -ENOMEM;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1840  		dev_dbg(&spi->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1841  			"allocated memory for controller's runtime state\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1842  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1843  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1844  	/* Get controller data if one is supplied */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1845  	chip_info = spi->controller_data;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1846  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1847  	if (chip_info == NULL) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1848  		if (np) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1849  			chip_info_dt = pl022_default_chip_info;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1850  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1851  			chip_info_dt.hierarchy = SSP_MASTER;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1852  			of_property_read_u32(np, "pl022,interface",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1853  				&chip_info_dt.iface);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1854  			of_property_read_u32(np, "pl022,com-mode",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1855  				&chip_info_dt.com_mode);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1856  			of_property_read_u32(np, "pl022,rx-level-trig",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1857  				&chip_info_dt.rx_lev_trig);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1858  			of_property_read_u32(np, "pl022,tx-level-trig",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1859  				&chip_info_dt.tx_lev_trig);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1860  			of_property_read_u32(np, "pl022,ctrl-len",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1861  				&chip_info_dt.ctrl_len);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1862  			of_property_read_u32(np, "pl022,wait-state",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1863  				&chip_info_dt.wait_state);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1864  			of_property_read_u32(np, "pl022,duplex",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1865  				&chip_info_dt.duplex);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1866  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1867  			chip_info = &chip_info_dt;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1868  		} else {
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1869  			chip_info = &pl022_default_chip_info;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1870  			/* spi_board_info.controller_data not is supplied */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1871  			dev_dbg(&spi->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1872  				"using default controller_data settings\n");
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1873  		}
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1874  	} else
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1875  		dev_dbg(&spi->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1876  			"using user supplied controller_data settings\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1877  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1878  	/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1879  	 * We can override with custom divisors, else we use the board
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1880  	 * frequency setting
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1881  	 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1882  	if ((0 == chip_info->clk_freq.cpsdvsr)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1883  	    && (0 == chip_info->clk_freq.scr)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1884  		status = calculate_effective_freq(pl022,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1885  						  spi->max_speed_hz,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1886  						  &clk_freq);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1887  		if (status < 0)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1888  			goto err_config_params;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1889  	} else {
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1890  		memcpy(&clk_freq, &chip_info->clk_freq, sizeof(clk_freq));
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1891  		if ((clk_freq.cpsdvsr % 2) != 0)
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1892  			clk_freq.cpsdvsr =
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1893  				clk_freq.cpsdvsr - 1;
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1894  	}
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1895  	if ((clk_freq.cpsdvsr < CPSDVR_MIN)
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1896  	    || (clk_freq.cpsdvsr > CPSDVR_MAX)) {
e3f88ae99609205 drivers/spi/amba-pl022.c Virupax Sadashivpetimath 2011-06-13  1897  		status = -EINVAL;
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1898  		dev_err(&spi->dev,
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1899  			"cpsdvsr is configured incorrectly\n");
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1900  		goto err_config_params;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1901  	}
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1902  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1903  	status = verify_controller_parameters(pl022, chip_info);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1904  	if (status) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1905  		dev_err(&spi->dev, "controller data is incorrect");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1906  		goto err_config_params;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1907  	}
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1908  
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1909  	pl022->rx_lev_trig = chip_info->rx_lev_trig;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1910  	pl022->tx_lev_trig = chip_info->tx_lev_trig;
083be3f05371b8f drivers/spi/spi-pl022.c  Linus Walleij            2011-06-16  1911  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1912  	/* Now set controller state based on controller data */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1913  	chip->xfer_type = chip_info->com_mode;
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1914  	if (!gpio_is_valid(pl022->chipselects[spi->chip_select]))
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1915  		dev_warn(&spi->dev,
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  1916  			 "invalid chip select\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1917  
eb798c641a34ae9 drivers/spi/spi-pl022.c  Vinit Shenoy             2012-04-17  1918  	/* Check bits per word with vendor specific range */
eb798c641a34ae9 drivers/spi/spi-pl022.c  Vinit Shenoy             2012-04-17  1919  	if ((bits <= 3) || (bits > pl022->vendor->max_bpw)) {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1920  		status = -ENOTSUPP;
eb798c641a34ae9 drivers/spi/spi-pl022.c  Vinit Shenoy             2012-04-17  1921  		dev_err(&spi->dev, "illegal data size for this controller!\n");
eb798c641a34ae9 drivers/spi/spi-pl022.c  Vinit Shenoy             2012-04-17  1922  		dev_err(&spi->dev, "This controller can only handle 4 <= n <= %d bit words\n",
eb798c641a34ae9 drivers/spi/spi-pl022.c  Vinit Shenoy             2012-04-17  1923  				pl022->vendor->max_bpw);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1924  		goto err_config_params;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1925  	} else if (bits <= 8) {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1926  		dev_dbg(&spi->dev, "4 <= n <=8 bits per word\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1927  		chip->n_bytes = 1;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1928  		chip->read = READING_U8;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1929  		chip->write = WRITING_U8;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1930  	} else if (bits <= 16) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1931  		dev_dbg(&spi->dev, "9 <= n <= 16 bits per word\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1932  		chip->n_bytes = 2;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1933  		chip->read = READING_U16;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1934  		chip->write = WRITING_U16;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1935  	} else {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1936  		dev_dbg(&spi->dev, "17 <= n <= 32 bits per word\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1937  		chip->n_bytes = 4;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1938  		chip->read = READING_U32;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1939  		chip->write = WRITING_U32;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1940  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1941  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1942  	/* Now Initialize all register settings required for this chip */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1943  	chip->cr0 = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1944  	chip->cr1 = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1945  	chip->dmacr = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1946  	chip->cpsr = 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1947  	if ((chip_info->com_mode == DMA_TRANSFER)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1948  	    && ((pl022->master_info)->enable_dma)) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1949  		chip->enable_dma = true;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1950  		dev_dbg(&spi->dev, "DMA mode set in controller state\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1951  		SSP_WRITE_BITS(chip->dmacr, SSP_DMA_ENABLED,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1952  			       SSP_DMACR_MASK_RXDMAE, 0);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1953  		SSP_WRITE_BITS(chip->dmacr, SSP_DMA_ENABLED,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1954  			       SSP_DMACR_MASK_TXDMAE, 1);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1955  	} else {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  1956  		chip->enable_dma = false;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1957  		dev_dbg(&spi->dev, "DMA mode NOT set in controller state\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1958  		SSP_WRITE_BITS(chip->dmacr, SSP_DMA_DISABLED,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1959  			       SSP_DMACR_MASK_RXDMAE, 0);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1960  		SSP_WRITE_BITS(chip->dmacr, SSP_DMA_DISABLED,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1961  			       SSP_DMACR_MASK_TXDMAE, 1);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1962  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1963  
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  1964  	chip->cpsr = clk_freq.cpsdvsr;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  1965  
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1966  	/* Special setup for the ST micro extended control registers */
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1967  	if (pl022->vendor->extended_cr) {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1968  		u32 etx;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1969  
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1970  		if (pl022->vendor->pl023) {
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1971  			/* These bits are only in the PL023 */
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1972  			SSP_WRITE_BITS(chip->cr1, chip_info->clkdelay,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1973  				       SSP_CR1_MASK_FBCLKDEL_ST, 13);
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1974  		} else {
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1975  			/* These bits are in the PL022 but not PL023 */
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1976  			SSP_WRITE_BITS(chip->cr0, chip_info->duplex,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1977  				       SSP_CR0_MASK_HALFDUP_ST, 5);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1978  			SSP_WRITE_BITS(chip->cr0, chip_info->ctrl_len,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1979  				       SSP_CR0_MASK_CSS_ST, 16);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1980  			SSP_WRITE_BITS(chip->cr0, chip_info->iface,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1981  				       SSP_CR0_MASK_FRF_ST, 21);
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1982  			SSP_WRITE_BITS(chip->cr1, chip_info->wait_state,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1983  				       SSP_CR1_MASK_MWAIT_ST, 6);
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1984  		}
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1985  		SSP_WRITE_BITS(chip->cr0, bits - 1,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  1986  			       SSP_CR0_MASK_DSS_ST, 0);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1987  
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1988  		if (spi->mode & SPI_LSB_FIRST) {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1989  			tmp = SSP_RX_LSB;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1990  			etx = SSP_TX_LSB;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1991  		} else {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1992  			tmp = SSP_RX_MSB;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1993  			etx = SSP_TX_MSB;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1994  		}
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1995  		SSP_WRITE_BITS(chip->cr1, tmp, SSP_CR1_MASK_RENDN_ST, 4);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  1996  		SSP_WRITE_BITS(chip->cr1, etx, SSP_CR1_MASK_TENDN_ST, 5);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1997  		SSP_WRITE_BITS(chip->cr1, chip_info->rx_lev_trig,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1998  			       SSP_CR1_MASK_RXIFLSEL_ST, 7);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  1999  		SSP_WRITE_BITS(chip->cr1, chip_info->tx_lev_trig,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2000  			       SSP_CR1_MASK_TXIFLSEL_ST, 10);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2001  	} else {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2002  		SSP_WRITE_BITS(chip->cr0, bits - 1,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2003  			       SSP_CR0_MASK_DSS, 0);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2004  		SSP_WRITE_BITS(chip->cr0, chip_info->iface,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2005  			       SSP_CR0_MASK_FRF, 4);
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2006  	}
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2007  
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2008  	/* Stuff that is common for all versions */
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2009  	if (spi->mode & SPI_CPOL)
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2010  		tmp = SSP_CLK_POL_IDLE_HIGH;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2011  	else
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2012  		tmp = SSP_CLK_POL_IDLE_LOW;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2013  	SSP_WRITE_BITS(chip->cr0, tmp, SSP_CR0_MASK_SPO, 6);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2014  
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2015  	if (spi->mode & SPI_CPHA)
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2016  		tmp = SSP_CLK_SECOND_EDGE;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2017  	else
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2018  		tmp = SSP_CLK_FIRST_EDGE;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2019  	SSP_WRITE_BITS(chip->cr0, tmp, SSP_CR0_MASK_SPH, 7);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2020  
f9d629c737cb668 drivers/spi/amba-pl022.c Linus Walleij            2010-10-01  2021  	SSP_WRITE_BITS(chip->cr0, clk_freq.scr, SSP_CR0_MASK_SCR, 8);
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2022  	/* Loopback is available on all versions except PL023 */
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2023  	if (pl022->vendor->loopback) {
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2024  		if (spi->mode & SPI_LOOP)
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2025  			tmp = LOOPBACK_ENABLED;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2026  		else
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2027  			tmp = LOOPBACK_DISABLED;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2028  		SSP_WRITE_BITS(chip->cr1, tmp, SSP_CR1_MASK_LBM, 0);
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2029  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2030  	SSP_WRITE_BITS(chip->cr1, SSP_DISABLED, SSP_CR1_MASK_SSE, 1);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2031  	SSP_WRITE_BITS(chip->cr1, chip_info->hierarchy, SSP_CR1_MASK_MS, 2);
f1e45f86ed93b9e drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  2032  	SSP_WRITE_BITS(chip->cr1, chip_info->slave_tx_disable, SSP_CR1_MASK_SOD,
f1e45f86ed93b9e drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  2033  		3);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2034  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2035  	/* Save controller_state */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2036  	spi_set_ctldata(spi, chip);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2037  	return status;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2038   err_config_params:
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2039  	spi_set_ctldata(spi, NULL);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2040  	kfree(chip);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2041  	return status;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2042  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2043  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2044  /**
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2045   * pl022_cleanup - cleanup function registered to SPI master framework
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2046   * @spi: spi device which is requesting cleanup
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2047   *
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2048   * This function is registered to the SPI framework for this SPI master
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2049   * controller. It will free the runtime state of chip.
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2050   */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2051  static void pl022_cleanup(struct spi_device *spi)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2052  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2053  	struct chip_data *chip = spi_get_ctldata(spi);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2054  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2055  	spi_set_ctldata(spi, NULL);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2056  	kfree(chip);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2057  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2058  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2059  static struct pl022_ssp_controller *
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2060  pl022_platform_data_dt_get(struct device *dev)
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2061  {
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2062  	struct device_node *np = dev->of_node;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2063  	struct pl022_ssp_controller *pd;
849794c50b24b93 drivers/spi/spi-pl022.c  Rabin Vincent            2017-04-06  2064  	u32 tmp = 0;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2065  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2066  	if (!np) {
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2067  		dev_err(dev, "no dt node defined\n");
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2068  		return NULL;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2069  	}
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2070  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2071  	pd = devm_kzalloc(dev, sizeof(struct pl022_ssp_controller), GFP_KERNEL);
77538f4a98dc542 drivers/spi/spi-pl022.c  Jingoo Han               2014-04-29  2072  	if (!pd)
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2073  		return NULL;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2074  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2075  	pd->bus_id = -1;
dbd897b9c6fac8b drivers/spi/spi-pl022.c  Linus Walleij            2013-05-23  2076  	pd->enable_dma = 1;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2077  	of_property_read_u32(np, "num-cs", &tmp);
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2078  	pd->num_chipselect = tmp;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2079  	of_property_read_u32(np, "pl022,autosuspend-delay",
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2080  			     &pd->autosuspend_delay);
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2081  	pd->rt = of_property_read_bool(np, "pl022,rt");
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2082  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2083  	return pd;
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2084  }
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2085  
fd4a319bc933ae9 drivers/spi/spi-pl022.c  Grant Likely             2012-12-07  2086  static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2087  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2088  	struct device *dev = &adev->dev;
8074cf063e410a2 drivers/spi/spi-pl022.c  Jingoo Han               2013-07-30  2089  	struct pl022_ssp_controller *platform_info =
8074cf063e410a2 drivers/spi/spi-pl022.c  Jingoo Han               2013-07-30  2090  			dev_get_platdata(&adev->dev);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2091  	struct spi_master *master;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2092  	struct pl022 *pl022 = NULL;	/*Data for this driver */
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2093  	struct device_node *np = adev->dev.of_node;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2094  	int status = 0, i, num_cs;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2095  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2096  	dev_info(&adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2097  		 "ARM PL022 driver, device ID: 0x%08x\n", adev->periphid);
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2098  	if (!platform_info && IS_ENABLED(CONFIG_OF))
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2099  		platform_info = pl022_platform_data_dt_get(dev);
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2100  
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2101  	if (!platform_info) {
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2102  		dev_err(dev, "probe: no platform data defined\n");
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2103  		return -ENODEV;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2104  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2105  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2106  	if (platform_info->num_chipselect) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2107  		num_cs = platform_info->num_chipselect;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2108  	} else {
39a6ac11df6579d drivers/spi/spi-pl022.c  Roland Stigge            2012-09-18  2109  		dev_err(dev, "probe: no chip select defined\n");
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2110  		return -ENODEV;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2111  	}
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2112  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2113  	/* Allocate master with space for data */
b4b8482690d97ea drivers/spi/spi-pl022.c  Roland Stigge            2012-09-03  2114  	master = spi_alloc_master(dev, sizeof(struct pl022));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2115  	if (master == NULL) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2116  		dev_err(&adev->dev, "probe - cannot alloc SPI master\n");
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2117  		return -ENOMEM;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2118  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2119  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2120  	pl022 = spi_master_get_devdata(master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2121  	pl022->master = master;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2122  	pl022->master_info = platform_info;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2123  	pl022->adev = adev;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2124  	pl022->vendor = id->data;
a86854d0c599b32 drivers/spi/spi-pl022.c  Kees Cook                2018-06-12  2125  	pl022->chipselects = devm_kcalloc(dev, num_cs, sizeof(int),
b4b8482690d97ea drivers/spi/spi-pl022.c  Roland Stigge            2012-09-03  2126  					  GFP_KERNEL);
73e3f1eb5188830 drivers/spi/spi-pl022.c  Kiran Padwal             2014-09-18  2127  	if (!pl022->chipselects) {
73e3f1eb5188830 drivers/spi/spi-pl022.c  Kiran Padwal             2014-09-18  2128  		status = -ENOMEM;
73e3f1eb5188830 drivers/spi/spi-pl022.c  Kiran Padwal             2014-09-18  2129  		goto err_no_mem;
73e3f1eb5188830 drivers/spi/spi-pl022.c  Kiran Padwal             2014-09-18  2130  	}
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2131  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2132  	/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2133  	 * Bus Number Which has been Assigned to this SSP controller
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2134  	 * on this board
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2135  	 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2136  	master->bus_num = platform_info->bus_id;
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25  2137  	master->use_gpio_descriptors;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2138  	master->num_chipselect = num_cs;
6e5614b6476001a drivers/spi/spi-pl022.c  Linus Walleij            2019-06-25  2139  	master->set_cs = pl022_set_cs;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2140  	master->cleanup = pl022_cleanup;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2141  	master->setup = pl022_setup;
29b6e906a70a47c drivers/spi/spi-pl022.c  Mark Brown               2013-07-28  2142  	master->auto_runtime_pm = true;
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2143  	master->transfer_one_message = pl022_transfer_one_message;
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2144  	master->unprepare_transfer_hardware = pl022_unprepare_transfer_hardware;
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2145  	master->rt = platform_info->rt;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2146  	master->dev.of_node = dev->of_node;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2147  
516843702bb5fd8 drivers/spi/spi-pl022.c  Linus Walleij            2019-04-28  2148  	if (pl022->vendor->internal_cs_ctrl) {
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2149  		for (i = 0; i < num_cs; i++)
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2150  			pl022->chipselects[i] = i;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2151  	} else if (IS_ENABLED(CONFIG_OF)) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2152  		for (i = 0; i < num_cs; i++) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2153  			int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2154  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2155  			if (cs_gpio == -EPROBE_DEFER) {
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2156  				status = -EPROBE_DEFER;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2157  				goto err_no_gpio;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2158  			}
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2159  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2160  			pl022->chipselects[i] = cs_gpio;
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2161  
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2162  			if (gpio_is_valid(cs_gpio)) {
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2163  				if (devm_gpio_request(dev, cs_gpio, "ssp-pl022"))
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2164  					dev_err(&adev->dev,
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2165  						"could not request %d gpio\n",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2166  						cs_gpio);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2167  				else if (gpio_direction_output(cs_gpio, 1))
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2168  					dev_err(&adev->dev,
61e89e65e31516c drivers/spi/spi-pl022.c  Roland Stigge            2014-09-09  2169  						"could not set gpio %d as output\n",
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2170  						cs_gpio);
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2171  			}
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2172  		}
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2173  	}
f6f46de1063c882 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2174  
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2175  	/*
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2176  	 * Supports mode 0-3, loopback, and active low CS. Transfers are
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2177  	 * always MS bit first on the original pl022.
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2178  	 */
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2179  	master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LOOP;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2180  	if (pl022->vendor->extended_cr)
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2181  		master->mode_bits |= SPI_LSB_FIRST;
bde435a9ca376d0 drivers/spi/amba-pl022.c Kevin Wells              2010-09-16  2182  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2183  	dev_dbg(&adev->dev, "BUSNO: %d\n", master->bus_num);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2184  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2185  	status = amba_request_regions(adev, NULL);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2186  	if (status)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2187  		goto err_no_ioregion;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2188  
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2189  	pl022->phybase = adev->res.start;
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2190  	pl022->virtbase = devm_ioremap(dev, adev->res.start,
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2191  				       resource_size(&adev->res));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2192  	if (pl022->virtbase == NULL) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2193  		status = -ENOMEM;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2194  		goto err_no_ioremap;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2195  	}
2c067509a1e3540 drivers/spi/spi-pl022.c  Jingoo Han               2013-10-11  2196  	dev_info(&adev->dev, "mapped registers from %pa to %p\n",
7085f403517615c drivers/spi/spi-pl022.c  Fabio Estevam            2013-08-21  2197  		&adev->res.start, pl022->virtbase);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2198  
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2199  	pl022->clk = devm_clk_get(&adev->dev, NULL);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2200  	if (IS_ERR(pl022->clk)) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2201  		status = PTR_ERR(pl022->clk);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2202  		dev_err(&adev->dev, "could not retrieve SSP/SPI bus clock\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2203  		goto err_no_clk;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2204  	}
7ff6bcf048e6a98 drivers/spi/spi-pl022.c  Russell King             2011-09-22  2205  
6cac167b826eced drivers/spi/spi-pl022.c  Ulf Hansson              2014-02-04  2206  	status = clk_prepare_enable(pl022->clk);
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2207  	if (status) {
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2208  		dev_err(&adev->dev, "could not enable SSP/SPI bus clock\n");
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2209  		goto err_no_clk_en;
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2210  	}
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2211  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2212  	/* Initialize transfer pump */
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2213  	tasklet_init(&pl022->pump_transfers, pump_transfers,
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2214  		     (unsigned long)pl022);
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2215  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2216  	/* Disable SSP */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2217  	writew((readw(SSP_CR1(pl022->virtbase)) & (~SSP_CR1_MASK_SSE)),
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2218  	       SSP_CR1(pl022->virtbase));
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2219  	load_ssp_default_config(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2220  
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2221  	status = devm_request_irq(dev, adev->irq[0], pl022_interrupt_handler,
aeef9915b9a40d2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2222  				  0, "pl022", pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2223  	if (status < 0) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2224  		dev_err(&adev->dev, "probe - cannot get IRQ (%d)\n", status);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2225  		goto err_no_irq;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2226  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2227  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2228  	/* Get DMA channels, try autoconfiguration first */
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2229  	status = pl022_dma_autoprobe(pl022);
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  2230  	if (status == -EPROBE_DEFER) {
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  2231  		dev_dbg(dev, "deferring probe to get DMA channel\n");
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  2232  		goto err_no_irq;
f3d4bb3342630cd drivers/spi/spi-pl022.c  Rabin Vincent            2015-11-23  2233  	}
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2234  
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2235  	/* If that failed, use channels from platform_info */
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2236  	if (status == 0)
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2237  		platform_info->enable_dma = 1;
dc715452e914515 drivers/spi/spi-pl022.c  Arnd Bergmann            2013-01-28  2238  	else if (platform_info->enable_dma) {
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2239  		status = pl022_dma_probe(pl022);
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2240  		if (status != 0)
43c640157d4366a drivers/spi/amba-pl022.c Viresh Kumar             2011-05-16  2241  			platform_info->enable_dma = 0;
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2242  	}
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2243  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2244  	/* Register with the SPI framework */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2245  	amba_set_drvdata(adev, pl022);
35794a77168b739 drivers/spi/spi-pl022.c  Jingoo Han               2013-09-24  2246  	status = devm_spi_register_master(&adev->dev, master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2247  	if (status != 0) {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2248  		dev_err(&adev->dev,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2249  			"probe - problem registering spi master\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2250  		goto err_spi_register;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2251  	}
25985edcedea639 drivers/spi/amba-pl022.c Lucas De Marchi          2011-03-30  2252  	dev_dbg(dev, "probe succeeded\n");
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2253  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2254  	/* let runtime pm put suspend */
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2255  	if (platform_info->autosuspend_delay > 0) {
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2256  		dev_info(&adev->dev,
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2257  			"will use autosuspend for runtime pm, delay %dms\n",
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2258  			platform_info->autosuspend_delay);
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2259  		pm_runtime_set_autosuspend_delay(dev,
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2260  			platform_info->autosuspend_delay);
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2261  		pm_runtime_use_autosuspend(dev);
53e4acea0e819a6 drivers/spi/spi-pl022.c  Chris Blair              2011-11-08  2262  	}
0df349945752bf0 drivers/spi/spi-pl022.c  Ulf Hansson              2012-10-17  2263  	pm_runtime_put(dev);
0df349945752bf0 drivers/spi/spi-pl022.c  Ulf Hansson              2012-10-17  2264  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2265  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2266  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2267   err_spi_register:
3e3ea716270dc64 drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  2268  	if (platform_info->enable_dma)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2269  		pl022_dma_remove(pl022);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2270   err_no_irq:
6cac167b826eced drivers/spi/spi-pl022.c  Ulf Hansson              2014-02-04  2271  	clk_disable_unprepare(pl022->clk);
71e63e748ee6f4b drivers/spi/spi-pl022.c  Ulf Hansson              2011-11-04  2272   err_no_clk_en:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2273   err_no_clk:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2274   err_no_ioremap:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2275  	amba_release_regions(adev);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2276   err_no_ioregion:
6d3952a7dfa8091 drivers/spi/spi-pl022.c  Roland Stigge            2012-08-22  2277   err_no_gpio:
73e3f1eb5188830 drivers/spi/spi-pl022.c  Kiran Padwal             2014-09-18  2278   err_no_mem:
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2279  	spi_master_put(master);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2280  	return status;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2281  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2282  
fd4a319bc933ae9 drivers/spi/spi-pl022.c  Grant Likely             2012-12-07  2283  static int
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2284  pl022_remove(struct amba_device *adev)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2285  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2286  	struct pl022 *pl022 = amba_get_drvdata(adev);
50658b6602dad6d drivers/spi/spi-pl022.c  Linus Walleij            2011-08-02  2287  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2288  	if (!pl022)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2289  		return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2290  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2291  	/*
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2292  	 * undo pm_runtime_put() in probe.  I assume that we're not
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2293  	 * accessing the primecell here.
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2294  	 */
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2295  	pm_runtime_get_noresume(&adev->dev);
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2296  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2297  	load_ssp_default_config(pl022);
3e3ea716270dc64 drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  2298  	if (pl022->master_info->enable_dma)
b1b6b9aa6fd32db drivers/spi/amba-pl022.c Linus Walleij            2010-09-29  2299  		pl022_dma_remove(pl022);
3e3ea716270dc64 drivers/spi/spi-pl022.c  Viresh Kumar             2011-08-10  2300  
6cac167b826eced drivers/spi/spi-pl022.c  Ulf Hansson              2014-02-04  2301  	clk_disable_unprepare(pl022->clk);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2302  	amba_release_regions(adev);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2303  	tasklet_disable(&pl022->pump_transfers);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2304  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2305  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2306  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2307  #ifdef CONFIG_PM_SLEEP
6cfa6279edbffa9 drivers/spi/spi-pl022.c  Peter Hüwe               2011-09-05  2308  static int pl022_suspend(struct device *dev)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2309  {
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2310  	struct pl022 *pl022 = dev_get_drvdata(dev);
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2311  	int ret;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2312  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2313  	ret = spi_master_suspend(pl022->master);
7c5d8a249acadc3 drivers/spi/spi-pl022.c  Geert Uytterhoeven       2018-09-05  2314  	if (ret)
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2315  		return ret;
4964a26df72c4a8 drivers/spi/spi-pl022.c  Ulf Hansson              2012-10-17  2316  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2317  	ret = pm_runtime_force_suspend(dev);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2318  	if (ret) {
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2319  		spi_master_resume(pl022->master);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2320  		return ret;
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2321  	}
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2322  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2323  	pinctrl_pm_select_sleep_state(dev);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2324  
6cfa6279edbffa9 drivers/spi/spi-pl022.c  Peter Hüwe               2011-09-05  2325  	dev_dbg(dev, "suspended\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2326  	return 0;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2327  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2328  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2329  static int pl022_resume(struct device *dev)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2330  {
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2331  	struct pl022 *pl022 = dev_get_drvdata(dev);
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2332  	int ret;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2333  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2334  	ret = pm_runtime_force_resume(dev);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2335  	if (ret)
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2336  		dev_err(dev, "problem resuming\n");
ada7aec7eec0ca2 drivers/spi/spi-pl022.c  Linus Walleij            2012-09-26  2337  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2338  	/* Start the queue running */
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2339  	ret = spi_master_resume(pl022->master);
7c5d8a249acadc3 drivers/spi/spi-pl022.c  Geert Uytterhoeven       2018-09-05  2340  	if (!ret)
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2341  		dev_dbg(dev, "resumed\n");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2342  
ffbbdd21329f3e1 drivers/spi/spi-pl022.c  Linus Walleij            2012-02-22  2343  	return ret;
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2344  }
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2345  #endif
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2346  
736198b0486c8d5 drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2347  #ifdef CONFIG_PM
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2348  static int pl022_runtime_suspend(struct device *dev)
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2349  {
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2350  	struct pl022 *pl022 = dev_get_drvdata(dev);
4f5e1b370845a0a drivers/spi/spi-pl022.c  Patrice Chotard          2012-09-19  2351  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2352  	clk_disable_unprepare(pl022->clk);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2353  	pinctrl_pm_select_idle_state(dev);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2354  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2355  	return 0;
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2356  }
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2357  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2358  static int pl022_runtime_resume(struct device *dev)
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2359  {
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2360  	struct pl022 *pl022 = dev_get_drvdata(dev);
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2361  
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2362  	pinctrl_pm_select_default_state(dev);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2363  	clk_prepare_enable(pl022->clk);
84a5dc41f64faad drivers/spi/spi-pl022.c  Ulf Hansson              2014-03-01  2364  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2365  	return 0;
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2366  }
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2367  #endif
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2368  
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2369  static const struct dev_pm_ops pl022_dev_pm_ops = {
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2370  	SET_SYSTEM_SLEEP_PM_OPS(pl022_suspend, pl022_resume)
6ed23b806e73bdd drivers/spi/spi-pl022.c  Rafael J. Wysocki        2014-12-04  2371  	SET_RUNTIME_PM_OPS(pl022_runtime_suspend, pl022_runtime_resume, NULL)
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2372  };
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2373  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2374  static struct vendor_data vendor_arm = {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2375  	.fifodepth = 8,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2376  	.max_bpw = 16,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2377  	.unidir = false,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2378  	.extended_cr = false,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2379  	.pl023 = false,
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2380  	.loopback = true,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2381  	.internal_cs_ctrl = false,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2382  };
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2383  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2384  static struct vendor_data vendor_st = {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2385  	.fifodepth = 32,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2386  	.max_bpw = 32,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2387  	.unidir = false,
556f4aeb7d9dfac drivers/spi/amba-pl022.c Linus Walleij            2010-05-05  2388  	.extended_cr = true,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2389  	.pl023 = false,
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2390  	.loopback = true,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2391  	.internal_cs_ctrl = false,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2392  };
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2393  
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2394  static struct vendor_data vendor_st_pl023 = {
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2395  	.fifodepth = 32,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2396  	.max_bpw = 32,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2397  	.unidir = false,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2398  	.extended_cr = true,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2399  	.pl023 = true,
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2400  	.loopback = false,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2401  	.internal_cs_ctrl = false,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2402  };
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2403  
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2404  static struct vendor_data vendor_lsi = {
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2405  	.fifodepth = 8,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2406  	.max_bpw = 16,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2407  	.unidir = false,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2408  	.extended_cr = false,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2409  	.pl023 = false,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2410  	.loopback = true,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2411  	.internal_cs_ctrl = true,
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2412  };
06fb01fd1dc624d drivers/spi/amba-pl022.c Philippe Langlais        2011-03-23  2413  
5b8d5ad2308d2d5 drivers/spi/spi-pl022.c  Arvind Yadav             2017-08-23  2414  static const struct amba_id pl022_ids[] = {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2415  	{
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2416  		/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2417  		 * ARM PL022 variant, this has a 16bit wide
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2418  		 * and 8 locations deep TX/RX FIFO
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2419  		 */
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2420  		.id	= 0x00041022,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2421  		.mask	= 0x000fffff,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2422  		.data	= &vendor_arm,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2423  	},
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2424  	{
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2425  		/*
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2426  		 * ST Micro derivative, this has 32bit wide
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2427  		 * and 32 locations deep TX/RX FIFO
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2428  		 */
e89e04fcdce6146 drivers/spi/amba-pl022.c Srinidhi Kasagar         2009-10-05  2429  		.id	= 0x01080022,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2430  		.mask	= 0xffffffff,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2431  		.data	= &vendor_st,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2432  	},
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2433  	{
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2434  		/*
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2435  		 * ST-Ericsson derivative "PL023" (this is not
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2436  		 * an official ARM number), this is a PL022 SSP block
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2437  		 * stripped to SPI mode only, it has 32bit wide
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2438  		 * and 32 locations deep TX/RX FIFO but no extended
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2439  		 * CR0/CR1 register
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2440  		 */
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2441  		.id	= 0x00080023,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2442  		.mask	= 0xffffffff,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2443  		.data	= &vendor_st_pl023,
781c7b129b1beb8 drivers/spi/amba-pl022.c Linus Walleij            2010-05-07  2444  	},
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2445  	{
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2446  		/*
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2447  		 * PL022 variant that has a chip select control register whih
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2448  		 * allows control of 5 output signals nCS[0:4].
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2449  		 */
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2450  		.id	= 0x000b6022,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2451  		.mask	= 0x000fffff,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2452  		.data	= &vendor_lsi,
db4fa45ed3182d8 drivers/spi/spi-pl022.c  Anders Berg              2014-09-17  2453  	},
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2454  	{ 0, 0 },
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2455  };
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2456  
7eeac71b9fc9b3d drivers/spi/spi-pl022.c  Dave Martin              2011-10-05  2457  MODULE_DEVICE_TABLE(amba, pl022_ids);
7eeac71b9fc9b3d drivers/spi/spi-pl022.c  Dave Martin              2011-10-05  2458  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2459  static struct amba_driver pl022_driver = {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2460  	.drv = {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2461  		.name	= "ssp-pl022",
92b97f0aaccbf9d drivers/spi/spi-pl022.c  Russell King             2011-08-14  2462  		.pm	= &pl022_dev_pm_ops,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2463  	},
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2464  	.id_table	= pl022_ids,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2465  	.probe		= pl022_probe,
fd4a319bc933ae9 drivers/spi/spi-pl022.c  Grant Likely             2012-12-07  2466  	.remove		= pl022_remove,
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2467  };
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2468  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2469  static int __init pl022_init(void)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2470  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2471  	return amba_driver_register(&pl022_driver);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2472  }
25c8e03bdb769df drivers/spi/amba-pl022.c Linus Walleij            2010-09-06  2473  subsys_initcall(pl022_init);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2474  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2475  static void __exit pl022_exit(void)
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2476  {
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2477  	amba_driver_unregister(&pl022_driver);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2478  }
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2479  module_exit(pl022_exit);
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2480  
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2481  MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2482  MODULE_DESCRIPTION("PL022 SSP Controller Driver");
b43d65f7e818485 drivers/spi/amba-pl022.c Linus Walleij            2009-06-09  2483  MODULE_LICENSE("GPL");

:::::: The code at line 442 was first introduced by commit
:::::: db4fa45ed3182d8206af241811dfc99369ffa849 spi: pl022: Add support for chip select extension

:::::: TO: Anders Berg <anders.berg@avagotech.com>
:::::: CC: Mark Brown <broonie@kernel.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 71383 bytes --]

^ permalink raw reply

* Re: [pinctrl:devel 16/46] drivers/pinctrl/bcm/pinctrl-bcm2835.c:995:10: error: incompatible types when assigning to type 'volatile struct SHIFTER' from type 'unsigned int'
From: Geert Uytterhoeven @ 2019-08-06  7:33 UTC (permalink / raw)
  To: kbuild test robot
  Cc: Stefan Wahren, kbuild-all, open list:GPIO SUBSYSTEM,
	Linus Walleij, linux-m68k
In-Reply-To: <201908061021.pQY2TnEK%lkp@intel.com>

CC linux-m68k (shifter too generic a name?)

On Tue, Aug 6, 2019 at 5:00 AM kbuild test robot <lkp@intel.com> wrote:
>
> tree:   https://kernel.googlesource.com/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
> head:   d55b7fdd58ac12e76ef65979af4a13b9c15fc00d
> commit: e38a9a437fb93ddafab5030165e4c6a3a5021669 [16/46] pinctrl: bcm2835: Add support for BCM2711 pull-up functionality
> config: m68k-allmodconfig (attached as .config)
> compiler: m68k-linux-gcc (GCC) 7.4.0
> reproduce:
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         git checkout e38a9a437fb93ddafab5030165e4c6a3a5021669
>         # save the attached .config to linux build tree
>         GCC_VERSION=7.4.0 make.cross ARCH=m68k
>
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@intel.com>
>
> All error/warnings (new ones prefixed by >>):
>
>    In file included from arch/m68k/include/asm/io_mm.h:32:0,
>                     from arch/m68k/include/asm/io.h:8,
>                     from include/linux/io.h:13,
>                     from include/linux/irq.h:20,
>                     from include/linux/gpio/driver.h:7,
>                     from drivers/pinctrl/bcm/pinctrl-bcm2835.c:17:
>    drivers/pinctrl/bcm/pinctrl-bcm2835.c: In function 'bcm2711_pull_config_set':
> >> arch/m68k/include/asm/atarihw.h:190:22: error: expected identifier or '(' before 'volatile'
>     # define shifter ((*(volatile struct SHIFTER *)SHF_BAS))
>                          ^
> >> drivers/pinctrl/bcm/pinctrl-bcm2835.c:990:6: note: in expansion of macro 'shifter'
>      u32 shifter;
>          ^~~~~~~
> >> arch/m68k/include/asm/atarihw.h:172:17: error: expected ')' before '(' token
>     #define SHF_BAS (0xffff8200)
>                     ^
> >> arch/m68k/include/asm/atarihw.h:190:48: note: in expansion of macro 'SHF_BAS'
>     # define shifter ((*(volatile struct SHIFTER *)SHF_BAS))
>                                                    ^~~~~~~
> >> drivers/pinctrl/bcm/pinctrl-bcm2835.c:990:6: note: in expansion of macro 'shifter'
>      u32 shifter;
>          ^~~~~~~
> >> drivers/pinctrl/bcm/pinctrl-bcm2835.c:995:10: error: incompatible types when assigning to type 'volatile struct SHIFTER' from type 'unsigned int'
>      shifter = PUD_2711_REG_SHIFT(pin);
>              ^
> >> drivers/pinctrl/bcm/pinctrl-bcm2835.c:998:27: error: invalid operands to binary << (have 'int' and 'volatile struct SHIFTER')
>      value &= ~(PUD_2711_MASK << shifter);
>                               ^~
> >> drivers/pinctrl/bcm/pinctrl-bcm2835.c:999:16: error: invalid operands to binary << (have 'unsigned int' and 'volatile struct SHIFTER')
>      value |= (arg << shifter);
>                    ^~
> --
>    In file included from arch/m68k/include/asm/io_mm.h:32:0,
>                     from arch/m68k/include/asm/io.h:8,
>                     from include/linux/io.h:13,
>                     from include/linux/irq.h:20,
>                     from include/linux/gpio/driver.h:7,
>                     from drivers/pinctrl//bcm/pinctrl-bcm2835.c:17:
>    drivers/pinctrl//bcm/pinctrl-bcm2835.c: In function 'bcm2711_pull_config_set':
> >> arch/m68k/include/asm/atarihw.h:190:22: error: expected identifier or '(' before 'volatile'
>     # define shifter ((*(volatile struct SHIFTER *)SHF_BAS))
>                          ^
>    drivers/pinctrl//bcm/pinctrl-bcm2835.c:990:6: note: in expansion of macro 'shifter'
>      u32 shifter;
>          ^~~~~~~
> >> arch/m68k/include/asm/atarihw.h:172:17: error: expected ')' before '(' token
>     #define SHF_BAS (0xffff8200)
>                     ^
> >> arch/m68k/include/asm/atarihw.h:190:48: note: in expansion of macro 'SHF_BAS'
>     # define shifter ((*(volatile struct SHIFTER *)SHF_BAS))
>                                                    ^~~~~~~
>    drivers/pinctrl//bcm/pinctrl-bcm2835.c:990:6: note: in expansion of macro 'shifter'
>      u32 shifter;
>          ^~~~~~~
>    drivers/pinctrl//bcm/pinctrl-bcm2835.c:995:10: error: incompatible types when assigning to type 'volatile struct SHIFTER' from type 'unsigned int'
>      shifter = PUD_2711_REG_SHIFT(pin);
>              ^
>    drivers/pinctrl//bcm/pinctrl-bcm2835.c:998:27: error: invalid operands to binary << (have 'int' and 'volatile struct SHIFTER')
>      value &= ~(PUD_2711_MASK << shifter);
>                               ^~
>    drivers/pinctrl//bcm/pinctrl-bcm2835.c:999:16: error: invalid operands to binary << (have 'unsigned int' and 'volatile struct SHIFTER')
>      value |= (arg << shifter);
>                    ^~
>
> vim +995 drivers/pinctrl/bcm/pinctrl-bcm2835.c
>
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply

* Re: [PATCH RFC 1/7] pinctrl: sh-pfc: add new flags into struct sh_pfc_pin_config
From: Geert Uytterhoeven @ 2019-08-06  8:46 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: Linus Walleij, Geert Uytterhoeven, Thierry Reding, Rob Herring,
	Mark Rutland, open list:GPIO SUBSYSTEM, Linux PWM List,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Linux-Renesas
In-Reply-To: <1562576868-8124-2-git-send-email-yoshihiro.shimoda.uh@renesas.com>

On Mon, Jul 8, 2019 at 11:08 AM Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
> To clean/modify the code up later, this patch just adds new flags
> "mux_set" and "gpio_enabled" into the struct sh_pfc_pin_config.
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* Re: [PATCH RFC 2/7] pinctrl: sh-pfc: remove incomplete flag "cfg->type"
From: Geert Uytterhoeven @ 2019-08-06  8:49 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: Linus Walleij, Geert Uytterhoeven, thierry.reding@gmail.com,
	Rob Herring, Mark Rutland, open list:GPIO SUBSYSTEM,
	linux-pwm@vger.kernel.org,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Linux-Renesas
In-Reply-To: <TYAPR01MB4544031C6A027A3690FFFB77D8DD0@TYAPR01MB4544.jpnprd01.prod.outlook.com>

Hi Shimoda-san,

On Mon, Jul 29, 2019 at 7:16 AM Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
> > From: Linus Walleij, Sent: Monday, July 29, 2019 8:02 AM
> >
> > On Mon, Jul 8, 2019 at 11:08 AM Yoshihiro Shimoda
> > <yoshihiro.shimoda.uh@renesas.com> wrote:
> >
> > > The old commit c58d9c1b26e3 ("sh-pfc: Implement generic pinconf
> > > support") broke the cfg->type flag to PINMUX_TYPE_FUNCTION because
> > > sh_pfc_pinconf_set() didn't call sh_pfc_reconfig_pin().
> > > Now if we fix the cfg->type condition, it gets worse because:
> > >  - Some drivers might be deferred so that .set_mux() will be called
> > >    multiple times.
> > >  - In such the case, the sh-pfc driver returns -EBUSY even if
> > >    the group is the same, and then that driver fails to probe.
> > >
> > > Since the pinctrl subsystem already has such conditions according
> > > to @set_mux and @gpio_request_enable, this patch just remove
> > > the incomplete flag from sh-pfc/pinctrl.c.
> > >
> > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> >
> > This looks like it should have a Fixes: tag as well.
>
> I got it. The Fixes tag should be:
>
> Fixes: c58d9c1b26e3 ("sh-pfc: Implement generic pinconf support")

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

> > Geert will decide what to do with this.
>
> I got it.
>
> > Can all the pinctrl patches be applied independently of the other
> > changes so Geert can apply and send me those patches in his pull
> > requests?
>
> The pinctrl patches (1/7 through 3/7) can be applied on next-20190726
> so I think Geert can apply these patches into his repo.

Looks mostly OK to me (I have some comments on 3/7).
I'll apply it to my local tree, so it will receive some testing on all
boards I have.

Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* Re: [PATCH RFC 3/7] pinctrl: sh-pfc: Rollback to mux if requires when the gpio is freed
From: Geert Uytterhoeven @ 2019-08-06  9:02 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: Linus Walleij, Geert Uytterhoeven, Thierry Reding, Rob Herring,
	Mark Rutland, open list:GPIO SUBSYSTEM, Linux PWM List,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Linux-Renesas
In-Reply-To: <1562576868-8124-4-git-send-email-yoshihiro.shimoda.uh@renesas.com>

Hi Shimoda-san,

On Mon, Jul 8, 2019 at 11:08 AM Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
> R-Car PWM controller requires the gpio to output zero duty,
> this patch allows to roll it back from gpio to mux when the gpio
> is freed.
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Thanks for your patch!

> --- a/drivers/pinctrl/sh-pfc/pinctrl.c
> +++ b/drivers/pinctrl/sh-pfc/pinctrl.c
> @@ -26,6 +26,7 @@
>  #include "../pinconf.h"
>
>  struct sh_pfc_pin_config {
> +       unsigned int mux_mark;

Due to padding, adding this field will increase memory consumption by
6 bytes per pin.
Probably sh_pfc_pin_group.{pins,mux} should be changed from unsigned int
to u16, but that's out of scope for this patch.

>         bool mux_set;
>         bool gpio_enabled;
>  };
> @@ -353,6 +354,15 @@ static int sh_pfc_func_set_mux(struct pinctrl_dev *pctldev, unsigned selector,
>         spin_lock_irqsave(&pfc->lock, flags);
>
>         for (i = 0; i < grp->nr_pins; ++i) {
> +               int idx = sh_pfc_get_pin_index(pfc, grp->pins[i]);
> +               struct sh_pfc_pin_config *cfg = &pmx->configs[idx];
> +
> +               /*
> +                * This doesn't assume the order which gpios are enabled
> +                * and then mux is set.

I'm sorry, I don't understand what you mean?
Can you please reword or elaborate?

> +                */
> +               WARN_ON(cfg->gpio_enabled);

Can this actually happen?
Should this cause a failure instead?

> +
>                 ret = sh_pfc_config_mux(pfc, grp->mux[i], PINMUX_TYPE_FUNCTION);
>                 if (ret < 0)
>                         goto done;
> @@ -364,6 +374,7 @@ static int sh_pfc_func_set_mux(struct pinctrl_dev *pctldev, unsigned selector,
>                 struct sh_pfc_pin_config *cfg = &pmx->configs[idx];
>
>                 cfg->mux_set = true;
> +               cfg->mux_mark = grp->mux[i];
>         }
>
>  done:
> @@ -417,6 +428,9 @@ static void sh_pfc_gpio_disable_free(struct pinctrl_dev *pctldev,
>
>         spin_lock_irqsave(&pfc->lock, flags);
>         cfg->gpio_enabled = false;
> +       /* If mux is already set, this configure it here */

configures

> +       if (cfg->mux_set)
> +               sh_pfc_config_mux(pfc, cfg->mux_mark, PINMUX_TYPE_FUNCTION);

Have you considered the case where more than one pin of a pinmux group
was used as a GPIO? In that case sh_pfc_gpio_disable_free() will be called
multiple times, possibly with the same mux_mark.

I don't think this will cause issues, though.

>         spin_unlock_irqrestore(&pfc->lock, flags);
>  }

Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* Re: [PATCH RFC 5/7] pwm: rcar: remove a redundant condition in rcar_pwm_apply()
From: Geert Uytterhoeven @ 2019-08-06  9:05 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: Linus Walleij, Geert Uytterhoeven, Thierry Reding, Rob Herring,
	Mark Rutland, open list:GPIO SUBSYSTEM, Linux PWM List,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Linux-Renesas
In-Reply-To: <1562576868-8124-6-git-send-email-yoshihiro.shimoda.uh@renesas.com>

Hi Shimoda-san,

On Mon, Jul 8, 2019 at 11:08 AM Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
> Since the rcar_pwm_apply() has already check whehter state->enabled
> is not set or not, this patch removes a redundant condition.
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

This is completely independent from the rest of the series, and can be applied
immediately, right?

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* Re: [PATCH RFC 4/7] dt-bindings: pwm: rcar: Add specific gpios property to output duty zero
From: Geert Uytterhoeven @ 2019-08-06  9:21 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: Linus Walleij, Geert Uytterhoeven, Thierry Reding, Rob Herring,
	Mark Rutland, open list:GPIO SUBSYSTEM, Linux PWM List,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Linux-Renesas
In-Reply-To: <1562576868-8124-5-git-send-email-yoshihiro.shimoda.uh@renesas.com>

Hi Shimoda-san,

On Mon, Jul 8, 2019 at 11:08 AM Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
> The R-Car SoCs PWM Timer cannot output duty zero. So, this patch
> adds a specific gpio property to output it.
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Thanks for your patch!

> --- a/Documentation/devicetree/bindings/pwm/renesas,pwm-rcar.txt
> +++ b/Documentation/devicetree/bindings/pwm/renesas,pwm-rcar.txt
> @@ -26,6 +26,9 @@ Required Properties:
>  - pinctrl-0: phandle, referring to a default pin configuration node.
>  - pinctrl-names: Set to "default".
>
> +Optional properties:
> +- renesas,duty-zero-gpios: Specify GPIO for outputting duty zero.
> +
>  Example: R8A7743 (RZ/G1M) PWM Timer node
>
>         pwm0: pwm@e6e30000 {

I'm not so fond of adding a property to specify this explicitly: the PFC
driver already knows the mapping from the PWM output pin to the GPIO
number. However, I agree it is not easy to obtain this in a generic way.

For a PWM block with a single pin, it's easy: the pin you want to switch
between GPIO and pin function is the single pin in the single pin
control group specified in the board DT.

For blocks with multiple pins (e.g. SPI, UART), it is more complex, and
depends on the granularity of the pin control groups.
E.g. for UART, Renesas SoCs typically use 3 pin control groups ("data"
for RXD/TXD, "ctrl" for RTS/CTS, and "clk" for clock), and the pin
control driver (at least for sh-pfc) does not know which pin corresponds
to which GPIO inside each group.  Perhaps this information should be
added, with an API to retrieve it?

Anyone who has a good suggestion?
Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* Re: [PATCH RFC 2/7] pinctrl: sh-pfc: remove incomplete flag "cfg->type"
From: Geert Uytterhoeven @ 2019-08-06  9:23 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: Linus Walleij, Geert Uytterhoeven, Thierry Reding, Rob Herring,
	Mark Rutland, open list:GPIO SUBSYSTEM, Linux PWM List,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Linux-Renesas
In-Reply-To: <1562576868-8124-3-git-send-email-yoshihiro.shimoda.uh@renesas.com>

Hi Shimoda-san,

On Mon, Jul 8, 2019 at 11:08 AM Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
> The old commit c58d9c1b26e3 ("sh-pfc: Implement generic pinconf
> support") broke the cfg->type flag to PINMUX_TYPE_FUNCTION because
> sh_pfc_pinconf_set() didn't call sh_pfc_reconfig_pin().
> Now if we fix the cfg->type condition, it gets worse because:
>  - Some drivers might be deferred so that .set_mux() will be called
>    multiple times.
>  - In such the case, the sh-pfc driver returns -EBUSY even if
>    the group is the same, and then that driver fails to probe.
>
> Since the pinctrl subsystem already has such conditions according
> to @set_mux and @gpio_request_enable, this patch just remove
> the incomplete flag from sh-pfc/pinctrl.c.

Do we need to set sh_pfc_pinmux_ops.strict = true?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* Re: [PATCH v1] pinctrl: intel: Use NSEC_PER_USEC for debounce calculus
From: Mika Westerberg @ 2019-08-06 10:14 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Linus Walleij, linux-gpio
In-Reply-To: <20190723155431.65095-1-andriy.shevchenko@linux.intel.com>

On Tue, Jul 23, 2019 at 06:54:31PM +0300, Andy Shevchenko wrote:
> Replace hard coded constants with self-explanatory names, i.e.
> use NSEC_PER_USEC for debounce calculus.
> 
> While here, add a unit suffix to debounce period constant.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/pinctrl/intel/pinctrl-intel.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
> index 3a7876efd4a6..99c5bca789eb 100644
> --- a/drivers/pinctrl/intel/pinctrl-intel.c
> +++ b/drivers/pinctrl/intel/pinctrl-intel.c
> @@ -8,12 +8,13 @@
>   */
>  
>  #include <linux/acpi.h>
> -#include <linux/module.h>
>  #include <linux/interrupt.h>
>  #include <linux/gpio/driver.h>
>  #include <linux/log2.h>
> +#include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/property.h>
> +#include <linux/time.h>
>  
>  #include <linux/pinctrl/pinctrl.h>
>  #include <linux/pinctrl/pinmux.h>
> @@ -71,7 +72,7 @@
>  #define PADCFG2_DEBOUNCE_SHIFT		1
>  #define PADCFG2_DEBOUNCE_MASK		GENMASK(4, 1)
>  
> -#define DEBOUNCE_PERIOD			31250 /* ns */
> +#define DEBOUNCE_PERIOD_NS		31250

Should this be called DEBOUNCE_PERIOD_NSEC to be consistent with
NSEC_PER_USEC?

Otherwise looks good.

>  
>  struct intel_pad_context {
>  	u32 padcfg0;
> @@ -566,7 +567,7 @@ static int intel_config_get(struct pinctrl_dev *pctldev, unsigned int pin,
>  			return -EINVAL;
>  
>  		v = (v & PADCFG2_DEBOUNCE_MASK) >> PADCFG2_DEBOUNCE_SHIFT;
> -		arg = BIT(v) * DEBOUNCE_PERIOD / 1000;
> +		arg = BIT(v) * DEBOUNCE_PERIOD_NS / NSEC_PER_USEC;
>  
>  		break;
>  	}
> @@ -683,7 +684,7 @@ static int intel_config_set_debounce(struct intel_pinctrl *pctrl,
>  	if (debounce) {
>  		unsigned long v;
>  
> -		v = order_base_2(debounce * 1000 / DEBOUNCE_PERIOD);
> +		v = order_base_2(debounce * NSEC_PER_USEC / DEBOUNCE_PERIOD_NS);
>  		if (v < 3 || v > 15) {
>  			ret = -EINVAL;
>  			goto exit_unlock;
> -- 
> 2.20.1

^ permalink raw reply

* Re: [PATCH v1] pinctrl: intel: Simplify offset validation in intel_get_padcfg()
From: Mika Westerberg @ 2019-08-06 10:16 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Linus Walleij, linux-gpio
In-Reply-To: <20190723155514.65177-1-andriy.shevchenko@linux.intel.com>

On Tue, Jul 23, 2019 at 06:55:14PM +0300, Andy Shevchenko wrote:
> There is more generic and simpler validation just against the nregs.
> Using it allows to drop customization from the intel_get_padcfg().
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply

* Re: [PATCH v1 1/8] pinctrl: broxton: Provide Interrupt Status register offset
From: Mika Westerberg @ 2019-08-06 10:30 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Linus Walleij, linux-gpio
In-Reply-To: <20190723155633.65232-1-andriy.shevchenko@linux.intel.com>

On Tue, Jul 23, 2019 at 06:56:26PM +0300, Andy Shevchenko wrote:
> Since some of the GPIO controllers use different Interrupt Status offset,
> it make sense to provide it explicitly in the driver.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

For this and the rest of the patches in this series,

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply

* Re: [PATCH v1] pinctrl: baytrail: Re-use data structures from pinctrl-intel.h (part 2)
From: Mika Westerberg @ 2019-08-06 10:44 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-gpio, Linus Walleij
In-Reply-To: <20190726201636.53129-1-andriy.shevchenko@linux.intel.com>

On Fri, Jul 26, 2019 at 11:16:36PM +0300, Andy Shevchenko wrote:
> We have some data structures duplicated across the drivers.
> Let's deduplicate them by using ones that being provided by
> pinctrl-intel.h.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply

* Re: [PATCH v1] pinctrl: intel: Allow to request locked pins
From: Mika Westerberg @ 2019-08-06 11:01 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-gpio, Linus Walleij
In-Reply-To: <20190726200830.52728-1-andriy.shevchenko@linux.intel.com>

On Fri, Jul 26, 2019 at 11:08:30PM +0300, Andy Shevchenko wrote:
> Some firmwares would like to protect pins from being modified by OS
> and at the same time provide them to OS as a resource. So, the driver
> in such circumstances may request pin and may not change its state.

This is definitely good idea.

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/pinctrl/intel/pinctrl-intel.c | 55 +++++++++++++++++++--------
>  1 file changed, 39 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
> index 3a945997b8eb..567fe43b238f 100644
> --- a/drivers/pinctrl/intel/pinctrl-intel.c
> +++ b/drivers/pinctrl/intel/pinctrl-intel.c
> @@ -220,22 +220,30 @@ static bool intel_pad_acpi_mode(struct intel_pinctrl *pctrl, unsigned int pin)
>  	return !(readl(hostown) & BIT(gpp_offset));
>  }
>  
> -static bool intel_pad_locked(struct intel_pinctrl *pctrl, unsigned int pin)
> +enum {
> +	PAD_UNLOCKED	= 0,
> +	PAD_LOCKED	= 1,
> +	PAD_LOCKED_TX	= 2,
> +	PAD_LOCKED_FULL	= PAD_LOCKED | PAD_LOCKED_TX,
> +};
> +
> +static int intel_pad_locked(struct intel_pinctrl *pctrl, unsigned int pin)
>  {
>  	struct intel_community *community;
>  	const struct intel_padgroup *padgrp;
>  	unsigned int offset, gpp_offset;
>  	u32 value;
> +	int ret = PAD_UNLOCKED;
>  
>  	community = intel_get_community(pctrl, pin);
>  	if (!community)
> -		return true;
> +		return PAD_LOCKED_FULL;
>  	if (!community->padcfglock_offset)
> -		return false;
> +		return PAD_UNLOCKED;
>  
>  	padgrp = intel_community_get_padgroup(community, pin);
>  	if (!padgrp)
> -		return true;
> +		return PAD_LOCKED_FULL;
>  
>  	gpp_offset = padgroup_offset(padgrp, pin);
>  
> @@ -244,23 +252,27 @@ static bool intel_pad_locked(struct intel_pinctrl *pctrl, unsigned int pin)
>  	 * the pad is considered unlocked. Any other case means that it is
>  	 * either fully or partially locked and we don't touch it.

I think you should update the above comment as well.

>  	 */
> -	offset = community->padcfglock_offset + padgrp->reg_num * 8;
> +	offset = community->padcfglock_offset + 0 + padgrp->reg_num * 8;
>  	value = readl(community->regs + offset);
>  	if (value & BIT(gpp_offset))
> -		return true;
> +		ret |= PAD_LOCKED;
>  
>  	offset = community->padcfglock_offset + 4 + padgrp->reg_num * 8;
>  	value = readl(community->regs + offset);
>  	if (value & BIT(gpp_offset))
> -		return true;
> +		ret |= PAD_LOCKED_TX;
>  
> -	return false;
> +	return ret;
> +}
> +
> +static bool intel_pad_is_unlocked(struct intel_pinctrl *pctrl, unsigned int pin)
> +{
> +	return (intel_pad_locked(pctrl, pin) & PAD_LOCKED) == PAD_UNLOCKED;
>  }
>  
>  static bool intel_pad_usable(struct intel_pinctrl *pctrl, unsigned int pin)
>  {
> -	return intel_pad_owned_by_host(pctrl, pin) &&
> -		!intel_pad_locked(pctrl, pin);
> +	return intel_pad_owned_by_host(pctrl, pin) && intel_pad_is_unlocked(pctrl, pin);
>  }
>  
>  static int intel_get_groups_count(struct pinctrl_dev *pctldev)
> @@ -294,7 +306,8 @@ static void intel_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
>  	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
>  	void __iomem *padcfg;
>  	u32 cfg0, cfg1, mode;
> -	bool locked, acpi;
> +	int locked;
> +	bool acpi;
>  
>  	if (!intel_pad_owned_by_host(pctrl, pin)) {
>  		seq_puts(s, "not available");
> @@ -322,11 +335,16 @@ static void intel_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
>  
>  	if (locked || acpi) {
>  		seq_puts(s, " [");
> -		if (locked) {
> +		if (locked)
>  			seq_puts(s, "LOCKED");
> -			if (acpi)
> -				seq_puts(s, ", ");
> -		}
> +		if ((locked & PAD_LOCKED_FULL) == PAD_LOCKED_TX)
> +			seq_puts(s, " TX");
> +		else if ((locked & PAD_LOCKED_FULL) == PAD_LOCKED_FULL)
> +			seq_puts(s, " FULL");
> +
> +		if (locked && acpi)
> +			seq_puts(s, ", ");
> +
>  		if (acpi)
>  			seq_puts(s, "ACPI");
>  		seq_puts(s, "]");
> @@ -448,11 +466,16 @@ static int intel_gpio_request_enable(struct pinctrl_dev *pctldev,
>  
>  	raw_spin_lock_irqsave(&pctrl->lock, flags);
>  
> -	if (!intel_pad_usable(pctrl, pin)) {
> +	if (!intel_pad_owned_by_host(pctrl, pin)) {
>  		raw_spin_unlock_irqrestore(&pctrl->lock, flags);
>  		return -EBUSY;
>  	}
>  
> +	if (!intel_pad_is_unlocked(pctrl, pin)) {
> +		raw_spin_unlock_irqrestore(&pctrl->lock, flags);
> +		return 0;

Hmm, if I'm reading this right it still does not allow requesting locked
pins. What I'm missing here?

> +	}
> +
>  	padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0);
>  	intel_gpio_set_gpio_mode(padcfg0);
>  	/* Disable TX buffer and enable RX (this will be input) */
> -- 
> 2.20.1

^ permalink raw reply

* RE: [PATCH RFC 3/7] pinctrl: sh-pfc: Rollback to mux if requires when the gpio is freed
From: Yoshihiro Shimoda @ 2019-08-06 11:38 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Walleij, Geert Uytterhoeven, Thierry Reding, Rob Herring,
	Mark Rutland, open list:GPIO SUBSYSTEM, Linux PWM List,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Linux-Renesas
In-Reply-To: <CAMuHMdUAVGbvn0D=UkqhY6RpO70MR-4GBC8i931a+fV9f6+njg@mail.gmail.com>

Hi Geert-san,

Thank you for your review!

> From: Geert Uytterhoeven, Sent: Tuesday, August 6, 2019 6:03 PM
> 
> Hi Shimoda-san,
> 
> On Mon, Jul 8, 2019 at 11:08 AM Yoshihiro Shimoda
> <yoshihiro.shimoda.uh@renesas.com> wrote:
> > R-Car PWM controller requires the gpio to output zero duty,
> > this patch allows to roll it back from gpio to mux when the gpio
> > is freed.
> >
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> 
> Thanks for your patch!
> 
> > --- a/drivers/pinctrl/sh-pfc/pinctrl.c
> > +++ b/drivers/pinctrl/sh-pfc/pinctrl.c
> > @@ -26,6 +26,7 @@
> >  #include "../pinconf.h"
> >
> >  struct sh_pfc_pin_config {
> > +       unsigned int mux_mark;
> 
> Due to padding, adding this field will increase memory consumption by
> 6 bytes per pin.

I see.

> Probably sh_pfc_pin_group.{pins,mux} should be changed from unsigned int
> to u16, but that's out of scope for this patch.

I got it.

> >         bool mux_set;
> >         bool gpio_enabled;
> >  };
> > @@ -353,6 +354,15 @@ static int sh_pfc_func_set_mux(struct pinctrl_dev *pctldev, unsigned selector,
> >         spin_lock_irqsave(&pfc->lock, flags);
> >
> >         for (i = 0; i < grp->nr_pins; ++i) {
> > +               int idx = sh_pfc_get_pin_index(pfc, grp->pins[i]);
> > +               struct sh_pfc_pin_config *cfg = &pmx->configs[idx];
> > +
> > +               /*
> > +                * This doesn't assume the order which gpios are enabled
> > +                * and then mux is set.
> 
> I'm sorry, I don't understand what you mean?
> Can you please reword or elaborate?

I was also difficult to remember what I meant...
Anyway, this meant,
 1) if a device has the default pinctrl-0 property, the set_mux() ops is called
    before the device driver's probe() function is called by pinctrl_bind_pins() first,
 2) so that any device drivers cannot call gpiod_get() before the 1).

However, this comments don't cover an imbalance pinctrl/gpio handling.
For example (as pseudo):
 - SCIF driver uses SCIF2 pinctrl,
 - but, IOMMU driver gets the SCIF2 pins before SCIF driver is probed.

So, I'd like to revise the comments as following. What do you think?

--
This driver cannot manage both gpio and mux when the gpio pin
is already enabled. So, this function failed.
--

> > +                */
> > +               WARN_ON(cfg->gpio_enabled);
> 
> Can this actually happen?

This cannot happen actually.

> Should this cause a failure instead?

I think so.

> > +
> >                 ret = sh_pfc_config_mux(pfc, grp->mux[i], PINMUX_TYPE_FUNCTION);
> >                 if (ret < 0)
> >                         goto done;
> > @@ -364,6 +374,7 @@ static int sh_pfc_func_set_mux(struct pinctrl_dev *pctldev, unsigned selector,
> >                 struct sh_pfc_pin_config *cfg = &pmx->configs[idx];
> >
> >                 cfg->mux_set = true;
> > +               cfg->mux_mark = grp->mux[i];
> >         }
> >
> >  done:
> > @@ -417,6 +428,9 @@ static void sh_pfc_gpio_disable_free(struct pinctrl_dev *pctldev,
> >
> >         spin_lock_irqsave(&pfc->lock, flags);
> >         cfg->gpio_enabled = false;
> > +       /* If mux is already set, this configure it here */
> 
> configures

Oops! I'll fix it.

> > +       if (cfg->mux_set)
> > +               sh_pfc_config_mux(pfc, cfg->mux_mark, PINMUX_TYPE_FUNCTION);
> 
> Have you considered the case where more than one pin of a pinmux group
> was used as a GPIO? In that case sh_pfc_gpio_disable_free() will be called
> multiple times, possibly with the same mux_mark.

I haven't considered the case. But, about the mux_mark, I checked the values and then
they are not the same.

For example (debug printk patch):
diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c
index bc29066..fdac71b 100644
--- a/drivers/pinctrl/sh-pfc/pinctrl.c
+++ b/drivers/pinctrl/sh-pfc/pinctrl.c
@@ -349,7 +349,7 @@ static int sh_pfc_func_set_mux(struct pinctrl_dev *pctldev, unsigned selector,
 	unsigned int i;
 	int ret = 0;
 
-	dev_dbg(pctldev->dev, "Configuring pin group %s\n", grp->name);
+	dev_info(pctldev->dev, "Configuring pin group %s\n", grp->name);
 
 	spin_lock_irqsave(&pfc->lock, flags);
 
@@ -375,6 +375,7 @@ static int sh_pfc_func_set_mux(struct pinctrl_dev *pctldev, unsigned selector,
 
 		cfg->mux_set = true;
 		cfg->mux_mark = grp->mux[i];
+		dev_info(pctldev->dev, "%d: %x\n", i, cfg->mux_mark);
 	}
 
 done:
-- 
2.7.4

For example (log):
[    0.497647] sh-pfc e6060000.pin-controller: Configuring pin group scif2_data_a
[    0.497711] sh-pfc e6060000.pin-controller: 0: 77b
[    0.497715] sh-pfc e6060000.pin-controller: 1: 760

Best regards,
Yoshihiro Shimoda

> I don't think this will cause issues, though.
> 
> >         spin_unlock_irqrestore(&pfc->lock, flags);
> >  }
> 
> Thanks!
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds

^ permalink raw reply related

* RE: [PATCH RFC 5/7] pwm: rcar: remove a redundant condition in rcar_pwm_apply()
From: Yoshihiro Shimoda @ 2019-08-06 11:39 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Walleij, Geert Uytterhoeven, Thierry Reding, Rob Herring,
	Mark Rutland, open list:GPIO SUBSYSTEM, Linux PWM List,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Linux-Renesas
In-Reply-To: <CAMuHMdWw1Gh_CxgiO5gd+MY0vUvWX_ACDj+L3_Wcomkaf5Oo4Q@mail.gmail.com>

Hi Geert-san,

> From: Geert Uytterhoeven, Sent: Tuesday, August 6, 2019 6:06 PM
> 
> Hi Shimoda-san,
> 
> On Mon, Jul 8, 2019 at 11:08 AM Yoshihiro Shimoda
> <yoshihiro.shimoda.uh@renesas.com> wrote:
> > Since the rcar_pwm_apply() has already check whehter state->enabled
> > is not set or not, this patch removes a redundant condition.
> >
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> 
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thank you for your review!

> This is completely independent from the rest of the series, and can be applied
> immediately, right?

That's right.

Best regards,
Yoshihiro Shimoda

> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds

^ permalink raw reply

* Re: [PATCH v1] pinctrl: intel: Use NSEC_PER_USEC for debounce calculus
From: Andy Shevchenko @ 2019-08-06 11:39 UTC (permalink / raw)
  To: Mika Westerberg; +Cc: Linus Walleij, linux-gpio
In-Reply-To: <20190806101412.GJ2548@lahna.fi.intel.com>

On Tue, Aug 06, 2019 at 01:14:12PM +0300, Mika Westerberg wrote:
> On Tue, Jul 23, 2019 at 06:54:31PM +0300, Andy Shevchenko wrote:
> > Replace hard coded constants with self-explanatory names, i.e.
> > use NSEC_PER_USEC for debounce calculus.
> > 
> > While here, add a unit suffix to debounce period constant.

> > -#define DEBOUNCE_PERIOD			31250 /* ns */
> > +#define DEBOUNCE_PERIOD_NS		31250
> 
> Should this be called DEBOUNCE_PERIOD_NSEC to be consistent with
> NSEC_PER_USEC?

Either will good look to me.

> Otherwise looks good.

Will fix for v2.

Thanks!

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply

* [PATCH] gpiolib: never report open-drain/source lines as 'input' to user-space
From: Bartosz Golaszewski @ 2019-08-06 11:41 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-gpio, linux-kernel, Bartosz Golaszewski, stable

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

If the driver doesn't support open-drain/source config options, we
emulate this behavior when setting the direction by calling
gpiod_direction_input() if the default value is 0 (open-source) or
1 (open-drain), thus not actively driving the line in those cases.

This however clears the FLAG_IS_OUT bit for the GPIO line descriptor
and makes the LINEINFO ioctl() incorrectly report this line's mode as
'input' to user-space.

This commit modifies the ioctl() to always set the GPIOLINE_FLAG_IS_OUT
bit in the lineinfo structure's flags field. Since it's impossible to
use the input mode and open-drain/source options at the same time, we
can be sure the reported information will be correct.

Fixes: 521a2ad6f862 ("gpio: add userspace ABI for GPIO line information")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpiolib.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index f497003f119c..80a2a2cb673b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1091,9 +1091,11 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		if (test_bit(FLAG_ACTIVE_LOW, &desc->flags))
 			lineinfo.flags |= GPIOLINE_FLAG_ACTIVE_LOW;
 		if (test_bit(FLAG_OPEN_DRAIN, &desc->flags))
-			lineinfo.flags |= GPIOLINE_FLAG_OPEN_DRAIN;
+			lineinfo.flags |= (GPIOLINE_FLAG_OPEN_DRAIN |
+					   GPIOLINE_FLAG_IS_OUT);
 		if (test_bit(FLAG_OPEN_SOURCE, &desc->flags))
-			lineinfo.flags |= GPIOLINE_FLAG_OPEN_SOURCE;
+			lineinfo.flags |= (GPIOLINE_FLAG_OPEN_SOURCE |
+					   GPIOLINE_FLAG_IS_OUT);
 
 		if (copy_to_user(ip, &lineinfo, sizeof(lineinfo)))
 			return -EFAULT;
-- 
2.21.0


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox