summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-09-07 16:51:13 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-07 16:51:13 -0400
commit968c61f7da3cf6d58a49587cfe00d899ca72c1ad (patch)
treeb5f7adb38c01234d34e000f6f7ad9da432e663e5
parent9d71941d39fb876271df72394518a98ae079e5a3 (diff)
parentb01e9348e106544e50691252bf58cde239681f19 (diff)
Merge tag 'mfd-next-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd
Pull MFD updates from Lee Jones: "New Drivers - RK805 Power Management IC (PMIC) - ROHM BD9571MWV-M MFD Power Management IC (PMIC) - Texas Instruments TPS68470 Power Management IC (PMIC) & LEDs New Device Support: - Add support for HiSilicon Hi6421v530 to hi6421-pmic-core - Add support for X-Powers AXP806 to axp20x - Add support for X-Powers AXP813 to axp20x - Add support for Intel Sunrise Point LPSS to intel-lpss-pci New Functionality: - Amend API to provide register layout; atmel-smc Fix-ups: - DT re-work; omap, nokia - Header file location change {I2C => MFD}; dm355evm_msp, tps65010 - Fix chip ID formatting issue(s); rk808 - Optionally register touchscreen devices; da9052-core - Documentation improvements; twl-core - Constification; rtsx_pcr, ab8500-core, da9055-i2c, da9052-spi - Drop unnecessary static declaration; max8925-i2c - Kconfig changes (missing deps and remove module support) - Slim down oversized licence statement; hi6421-pmic-core - Use managed resources (devm_*); lp87565 - Supply proper error checking/handling; t7l66xb Bug Fixes: - Fix counter duplication issue; da9052-core - Fix potential NULL deference issue; max8998 - Leave SPI-NOR write-protection bit alone; lpc_ich - Ensure device is put into reset during suspend; intel-lpss - Correct register offset variable size; omap-usb-tll" * tag 'mfd-next-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (61 commits) mfd: intel_soc_pmic: Differentiate between Bay and Cherry Trail CRC variants mfd: intel_soc_pmic: Export separate mfd-cell configs for BYT and CHT dt-bindings: mfd: Add bindings for ZII RAVE devices mfd: omap-usb-tll: Fix register offsets mfd: da9052: Constify spi_device_id mfd: intel-lpss: Put I2C and SPI controllers into reset state on suspend mfd: da9055: Constify i2c_device_id mfd: intel-lpss: Add missing PCI ID for Intel Sunrise Point LPSS devices mfd: t7l66xb: Handle return value of clk_prepare_enable mfd: Add ROHM BD9571MWV-M PMIC DT bindings mfd: intel_soc_pmic_chtwc: Turn Kconfig option into a bool mfd: lp87565: Convert to use devm_mfd_add_devices() mfd: Add support for TPS68470 device mfd: lpc_ich: Do not touch SPI-NOR write protection bit on Haswell/Broadwell mfd: syscon: atmel-smc: Add helper to retrieve register layout mfd: axp20x: Use correct platform device ID for many PEK dt-bindings: mfd: axp20x: Introduce bindings for AXP813 mfd: axp20x: Add support for AXP813 PMIC dt-bindings: mfd: axp20x: Add AXP806 to supported list of chips mfd: Add ROHM BD9571MWV-M MFD PMIC driver ...
-rw-r--r--Documentation/ABI/testing/sysfs-bus-iio-lptimer-stm3257
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt4
-rw-r--r--Documentation/devicetree/bindings/iio/counter/stm32-lptimer-cnt.txt27
-rw-r--r--Documentation/devicetree/bindings/iio/timer/stm32-lptimer-trigger.txt23
-rw-r--r--Documentation/devicetree/bindings/mfd/atmel-smc.txt1
-rw-r--r--Documentation/devicetree/bindings/mfd/axp20x.txt50
-rw-r--r--Documentation/devicetree/bindings/mfd/bd9571mwv.txt49
-rw-r--r--Documentation/devicetree/bindings/mfd/da9052-i2c.txt8
-rw-r--r--Documentation/devicetree/bindings/mfd/retu.txt25
-rw-r--r--Documentation/devicetree/bindings/mfd/rk808.txt22
-rw-r--r--Documentation/devicetree/bindings/mfd/stm32-lptimer.txt48
-rw-r--r--Documentation/devicetree/bindings/mfd/tps6105x.txt17
-rw-r--r--Documentation/devicetree/bindings/mfd/zii,rave-sp.txt39
-rw-r--r--Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt63
-rw-r--r--Documentation/devicetree/bindings/pwm/pwm-stm32-lp.txt24
-rw-r--r--MAINTAINERS11
-rw-r--r--arch/arm/boot/dts/omap2420-n8x0-common.dtsi4
-rw-r--r--arch/arm/boot/dts/ste-hrefprev60.dtsi2
-rw-r--r--arch/arm/mach-omap1/board-h2-mmc.c2
-rw-r--r--arch/arm/mach-omap1/board-h2.c2
-rw-r--r--arch/arm/mach-omap1/board-h3-mmc.c2
-rw-r--r--arch/arm/mach-omap1/board-h3.c2
-rw-r--r--arch/arm/mach-omap1/board-nokia770.c4
-rw-r--r--arch/arm/mach-omap1/board-osk.c2
-rw-r--r--arch/arm/mach-omap2/common.h2
-rw-r--r--arch/arm/mach-omap2/omap_twl.c2
-rw-r--r--arch/arm/mach-s3c24xx/mach-osiris-dvs.c2
-rw-r--r--arch/arm/mach-s3c24xx/mach-osiris.c2
-rw-r--r--drivers/gpio/gpio-twl4030.c2
-rw-r--r--drivers/iio/adc/stm32-adc.c14
-rw-r--r--drivers/iio/adc/twl4030-madc.c2
-rw-r--r--drivers/iio/adc/twl6030-gpadc.c2
-rw-r--r--drivers/iio/counter/Kconfig9
-rw-r--r--drivers/iio/counter/Makefile1
-rw-r--r--drivers/iio/counter/stm32-lptimer-cnt.c383
-rw-r--r--drivers/iio/trigger/Kconfig11
-rw-r--r--drivers/iio/trigger/Makefile1
-rw-r--r--drivers/iio/trigger/stm32-lptimer-trigger.c118
-rw-r--r--drivers/input/keyboard/twl4030_keypad.c2
-rw-r--r--drivers/input/misc/dm355evm_keys.c2
-rw-r--r--drivers/input/misc/twl4030-pwrbutton.c2
-rw-r--r--drivers/input/misc/twl4030-vibra.c2
-rw-r--r--drivers/memory/atmel-ebi.c13
-rw-r--r--drivers/mfd/Kconfig57
-rw-r--r--drivers/mfd/Makefile3
-rw-r--r--drivers/mfd/ab8500-core.c6
-rw-r--r--drivers/mfd/atmel-smc.c67
-rw-r--r--drivers/mfd/axp20x-rsb.c1
-rw-r--r--drivers/mfd/axp20x.c32
-rw-r--r--drivers/mfd/bd9571mwv.c230
-rw-r--r--drivers/mfd/da9052-core.c2
-rw-r--r--drivers/mfd/da9052-spi.c2
-rw-r--r--drivers/mfd/da9055-i2c.c2
-rw-r--r--drivers/mfd/dm355evm_msp.c2
-rw-r--r--drivers/mfd/hi6421-pmic-core.c89
-rw-r--r--drivers/mfd/intel-lpss-pci.c1
-rw-r--r--drivers/mfd/intel-lpss.c8
-rw-r--r--drivers/mfd/intel_soc_pmic_core.c34
-rw-r--r--drivers/mfd/intel_soc_pmic_core.h3
-rw-r--r--drivers/mfd/intel_soc_pmic_crc.c27
-rw-r--r--drivers/mfd/lp87565.c7
-rw-r--r--drivers/mfd/lpc_ich.c10
-rw-r--r--drivers/mfd/max8925-i2c.c2
-rw-r--r--drivers/mfd/max8998.c6
-rw-r--r--drivers/mfd/omap-usb-tll.c4
-rw-r--r--drivers/mfd/retu-mfd.c12
-rw-r--r--drivers/mfd/rk808.c147
-rw-r--r--drivers/mfd/rtsx_pcr.c4
-rw-r--r--drivers/mfd/stm32-lptimer.c107
-rw-r--r--drivers/mfd/t7l66xb.c17
-rw-r--r--drivers/mfd/tps6105x.c8
-rw-r--r--drivers/mfd/tps65010.c2
-rw-r--r--drivers/mfd/tps68470.c106
-rw-r--r--drivers/mfd/twl-core.c10
-rw-r--r--drivers/mfd/twl4030-audio.c2
-rw-r--r--drivers/mfd/twl4030-irq.c2
-rw-r--r--drivers/mfd/twl4030-power.c2
-rw-r--r--drivers/mfd/twl6030-irq.c2
-rw-r--r--drivers/mtd/nand/atmel/nand-controller.c10
-rw-r--r--drivers/phy/ti/phy-twl4030-usb.c2
-rw-r--r--drivers/pinctrl/Kconfig9
-rw-r--r--drivers/pinctrl/Makefile1
-rw-r--r--drivers/pinctrl/pinctrl-rk805.c493
-rw-r--r--drivers/power/supply/twl4030_charger.c2
-rw-r--r--drivers/pwm/Kconfig10
-rw-r--r--drivers/pwm/Makefile1
-rw-r--r--drivers/pwm/pwm-stm32-lp.c246
-rw-r--r--drivers/pwm/pwm-twl-led.c2
-rw-r--r--drivers/pwm/pwm-twl.c2
-rw-r--r--drivers/regulator/Kconfig4
-rw-r--r--drivers/regulator/rk808-regulator.c130
-rw-r--r--drivers/regulator/twl-regulator.c2
-rw-r--r--drivers/regulator/twl6030-regulator.c2
-rw-r--r--drivers/rtc/rtc-dm355evm.c2
-rw-r--r--drivers/rtc/rtc-twl.c2
-rw-r--r--drivers/usb/host/ohci-omap.c2
-rw-r--r--drivers/usb/phy/phy-isp1301-omap.c2
-rw-r--r--drivers/usb/phy/phy-twl6030-usb.c2
-rw-r--r--drivers/video/backlight/pandora_bl.c2
-rw-r--r--drivers/video/fbdev/omap/lcd_h3.c2
-rw-r--r--drivers/watchdog/twl4030_wdt.c2
-rw-r--r--include/linux/iio/timer/stm32-lptim-trigger.h27
-rw-r--r--include/linux/mfd/axp20x.h29
-rw-r--r--include/linux/mfd/bd9571mwv.h115
-rw-r--r--include/linux/mfd/dm355evm_msp.h (renamed from include/linux/i2c/dm355evm_msp.h)0
-rw-r--r--include/linux/mfd/hi6421-pmic.h5
-rw-r--r--include/linux/mfd/rk808.h121
-rw-r--r--include/linux/mfd/stm32-lptimer.h62
-rw-r--r--include/linux/mfd/syscon/atmel-smc.h32
-rw-r--r--include/linux/mfd/tps65010.h (renamed from include/linux/i2c/tps65010.h)2
-rw-r--r--include/linux/mfd/tps68470.h97
-rw-r--r--include/linux/mfd/twl.h (renamed from include/linux/i2c/twl.h)0
-rw-r--r--sound/soc/codecs/twl4030.c2
113 files changed, 3318 insertions, 182 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-iio-lptimer-stm32 b/Documentation/ABI/testing/sysfs-bus-iio-lptimer-stm32
new file mode 100644
index 000000000000..ad2cc63e4bf8
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-iio-lptimer-stm32
@@ -0,0 +1,57 @@
1What: /sys/bus/iio/devices/iio:deviceX/in_count0_preset
2KernelVersion: 4.13
3Contact: fabrice.gasnier@st.com
4Description:
5 Reading returns the current preset value. Writing sets the
6 preset value. Encoder counts continuously from 0 to preset
7 value, depending on direction (up/down).
8
9What: /sys/bus/iio/devices/iio:deviceX/in_count_quadrature_mode_available
10KernelVersion: 4.13
11Contact: fabrice.gasnier@st.com
12Description:
13 Reading returns the list possible quadrature modes.
14
15What: /sys/bus/iio/devices/iio:deviceX/in_count0_quadrature_mode
16KernelVersion: 4.13
17Contact: fabrice.gasnier@st.com
18Description:
19 Configure the device counter quadrature modes:
20 - non-quadrature:
21 Encoder IN1 input servers as the count input (up
22 direction).
23 - quadrature:
24 Encoder IN1 and IN2 inputs are mixed to get direction
25 and count.
26
27What: /sys/bus/iio/devices/iio:deviceX/in_count_polarity_available
28KernelVersion: 4.13
29Contact: fabrice.gasnier@st.com
30Description:
31 Reading returns the list possible active edges.
32
33What: /sys/bus/iio/devices/iio:deviceX/in_count0_polarity
34KernelVersion: 4.13
35Contact: fabrice.gasnier@st.com
36Description:
37 Configure the device encoder/counter active edge:
38 - rising-edge
39 - falling-edge
40 - both-edges
41
42 In non-quadrature mode, device counts up on active edge.
43 In quadrature mode, encoder counting scenarios are as follows:
44 ----------------------------------------------------------------
45 | Active | Level on | IN1 signal | IN2 signal |
46 | edge | opposite |------------------------------------------
47 | | signal | Rising | Falling | Rising | Falling |
48 ----------------------------------------------------------------
49 | Rising | High -> | Down | - | Up | - |
50 | edge | Low -> | Up | - | Down | - |
51 ----------------------------------------------------------------
52 | Falling | High -> | - | Up | - | Down |
53 | edge | Low -> | - | Down | - | Up |
54 ----------------------------------------------------------------
55 | Both | High -> | Down | Up | Up | Down |
56 | edges | Low -> | Up | Down | Down | Up |
57 ----------------------------------------------------------------
diff --git a/Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt b/Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt
index 8ce9cd2855b5..c143948b2a37 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt
@@ -20,8 +20,8 @@ i2c@0 {
20 #address-cells = <1>; 20 #address-cells = <1>;
21 #size-cells = <0>; 21 #size-cells = <0>;
22 22
23 retu-mfd: retu@1 { 23 retu: retu@1 {
24 compatible = "retu-mfd"; 24 compatible = "nokia,retu";
25 reg = <0x1>; 25 reg = <0x1>;
26 }; 26 };
27}; 27};
diff --git a/Documentation/devicetree/bindings/iio/counter/stm32-lptimer-cnt.txt b/Documentation/devicetree/bindings/iio/counter/stm32-lptimer-cnt.txt
new file mode 100644
index 000000000000..a04aa5c04103
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/counter/stm32-lptimer-cnt.txt
@@ -0,0 +1,27 @@
1STMicroelectronics STM32 Low-Power Timer quadrature encoder and counter
2
3STM32 Low-Power Timer provides several counter modes. It can be used as:
4- quadrature encoder to detect angular position and direction of rotary
5 elements, from IN1 and IN2 input signals.
6- simple counter from IN1 input signal.
7
8Must be a sub-node of an STM32 Low-Power Timer device tree node.
9See ../mfd/stm32-lptimer.txt for details about the parent node.
10
11Required properties:
12- compatible: Must be "st,stm32-lptimer-counter".
13- pinctrl-names: Set to "default".
14- pinctrl-0: List of phandles pointing to pin configuration nodes,
15 to set IN1/IN2 pins in mode of operation for Low-Power
16 Timer input on external pin.
17
18Example:
19 timer@40002400 {
20 compatible = "st,stm32-lptimer";
21 ...
22 counter {
23 compatible = "st,stm32-lptimer-counter";
24 pinctrl-names = "default";
25 pinctrl-0 = <&lptim1_in_pins>;
26 };
27 };
diff --git a/Documentation/devicetree/bindings/iio/timer/stm32-lptimer-trigger.txt b/Documentation/devicetree/bindings/iio/timer/stm32-lptimer-trigger.txt
new file mode 100644
index 000000000000..85e6806b17d7
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/timer/stm32-lptimer-trigger.txt
@@ -0,0 +1,23 @@
1STMicroelectronics STM32 Low-Power Timer Trigger
2
3STM32 Low-Power Timer provides trigger source (LPTIM output) that can be used
4by STM32 internal ADC and/or DAC.
5
6Must be a sub-node of an STM32 Low-Power Timer device tree node.
7See ../mfd/stm32-lptimer.txt for details about the parent node.
8
9Required properties:
10- compatible: Must be "st,stm32-lptimer-trigger".
11- reg: Identify trigger hardware block. Must be 0, 1 or 2
12 respectively for lptimer1, lptimer2 or lptimer3
13 trigger output.
14
15Example:
16 timer@40002400 {
17 compatible = "st,stm32-lptimer";
18 ...
19 trigger@0 {
20 compatible = "st,stm32-lptimer-trigger";
21 reg = <0>;
22 };
23 };
diff --git a/Documentation/devicetree/bindings/mfd/atmel-smc.txt b/Documentation/devicetree/bindings/mfd/atmel-smc.txt
index 26eeed373934..1103ce2030fb 100644
--- a/Documentation/devicetree/bindings/mfd/atmel-smc.txt
+++ b/Documentation/devicetree/bindings/mfd/atmel-smc.txt
@@ -8,6 +8,7 @@ Required properties:
8- compatible: Should be one of the following 8- compatible: Should be one of the following
9 "atmel,at91sam9260-smc", "syscon" 9 "atmel,at91sam9260-smc", "syscon"
10 "atmel,sama5d3-smc", "syscon" 10 "atmel,sama5d3-smc", "syscon"
11 "atmel,sama5d2-smc", "syscon"
11- reg: Contains offset/length value of the SMC memory 12- reg: Contains offset/length value of the SMC memory
12 region. 13 region.
13 14
diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
index aca09af66514..9455503b0299 100644
--- a/Documentation/devicetree/bindings/mfd/axp20x.txt
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -7,7 +7,14 @@ axp209 (X-Powers)
7axp221 (X-Powers) 7axp221 (X-Powers)
8axp223 (X-Powers) 8axp223 (X-Powers)
9axp803 (X-Powers) 9axp803 (X-Powers)
10axp806 (X-Powers)
10axp809 (X-Powers) 11axp809 (X-Powers)
12axp813 (X-Powers)
13
14The AXP813 is 2 chips packaged into 1. The 2 chips do not share anything
15other than the packaging. Pins are routed separately. As such they should
16be treated as separate entities. The other half is an AC100 RTC/codec
17combo chip. Please see ./ac100.txt for its bindings.
11 18
12Required properties: 19Required properties:
13- compatible: should be one of: 20- compatible: should be one of:
@@ -19,6 +26,7 @@ Required properties:
19 * "x-powers,axp803" 26 * "x-powers,axp803"
20 * "x-powers,axp806" 27 * "x-powers,axp806"
21 * "x-powers,axp809" 28 * "x-powers,axp809"
29 * "x-powers,axp813"
22- reg: The I2C slave address or RSB hardware address for the AXP chip 30- reg: The I2C slave address or RSB hardware address for the AXP chip
23- interrupt-parent: The parent interrupt controller 31- interrupt-parent: The parent interrupt controller
24- interrupts: SoC NMI / GPIO interrupt connected to the PMIC's IRQ pin 32- interrupts: SoC NMI / GPIO interrupt connected to the PMIC's IRQ pin
@@ -28,12 +36,14 @@ Required properties:
28Optional properties: 36Optional properties:
29- x-powers,dcdc-freq: defines the work frequency of DC-DC in KHz 37- x-powers,dcdc-freq: defines the work frequency of DC-DC in KHz
30 AXP152/20X: range: 750-1875, Default: 1.5 MHz 38 AXP152/20X: range: 750-1875, Default: 1.5 MHz
31 AXP22X/80X: range: 1800-4050, Default: 3 MHz 39 AXP22X/8XX: range: 1800-4050, Default: 3 MHz
32 40
33- x-powers,drive-vbus-en: axp221 / axp223 only boolean, set this when the 41- x-powers,drive-vbus-en: boolean, set this when the N_VBUSEN pin is
34 N_VBUSEN pin is used as an output pin to control an external 42 used as an output pin to control an external
35 regulator to drive the OTG VBus, rather then as an input pin 43 regulator to drive the OTG VBus, rather then
36 which signals whether the board is driving OTG VBus or not. 44 as an input pin which signals whether the
45 board is driving OTG VBus or not.
46 (axp221 / axp223 / axp813 only)
37 47
38- x-powers,master-mode: Boolean (axp806 only). Set this when the PMIC is 48- x-powers,master-mode: Boolean (axp806 only). Set this when the PMIC is
39 wired for master mode. The default is slave mode. 49 wired for master mode. The default is slave mode.
@@ -171,6 +181,36 @@ LDO_IO1 : LDO : ips-supply : GPIO 1
171RTC_LDO : LDO : ips-supply : always on 181RTC_LDO : LDO : ips-supply : always on
172SW : On/Off Switch : swin-supply 182SW : On/Off Switch : swin-supply
173 183
184AXP813 regulators, type, and corresponding input supply names:
185
186Regulator Type Supply Name Notes
187--------- ---- ----------- -----
188DCDC1 : DC-DC buck : vin1-supply
189DCDC2 : DC-DC buck : vin2-supply : poly-phase capable
190DCDC3 : DC-DC buck : vin3-supply : poly-phase capable
191DCDC4 : DC-DC buck : vin4-supply
192DCDC5 : DC-DC buck : vin5-supply : poly-phase capable
193DCDC6 : DC-DC buck : vin6-supply : poly-phase capable
194DCDC7 : DC-DC buck : vin7-supply
195ALDO1 : LDO : aldoin-supply : shared supply
196ALDO2 : LDO : aldoin-supply : shared supply
197ALDO3 : LDO : aldoin-supply : shared supply
198DLDO1 : LDO : dldoin-supply : shared supply
199DLDO2 : LDO : dldoin-supply : shared supply
200DLDO3 : LDO : dldoin-supply : shared supply
201DLDO4 : LDO : dldoin-supply : shared supply
202ELDO1 : LDO : eldoin-supply : shared supply
203ELDO2 : LDO : eldoin-supply : shared supply
204ELDO3 : LDO : eldoin-supply : shared supply
205FLDO1 : LDO : fldoin-supply : shared supply
206FLDO2 : LDO : fldoin-supply : shared supply
207FLDO3 : LDO : fldoin-supply : shared supply
208LDO_IO0 : LDO : ips-supply : GPIO 0
209LDO_IO1 : LDO : ips-supply : GPIO 1
210RTC_LDO : LDO : ips-supply : always on
211SW : On/Off Switch : swin-supply
212DRIVEVBUS : Enable output : drivevbus-supply : external regulator
213
174Example: 214Example:
175 215
176axp209: pmic@34 { 216axp209: pmic@34 {
diff --git a/Documentation/devicetree/bindings/mfd/bd9571mwv.txt b/Documentation/devicetree/bindings/mfd/bd9571mwv.txt
new file mode 100644
index 000000000000..9ab216a851d5
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/bd9571mwv.txt
@@ -0,0 +1,49 @@
1* ROHM BD9571MWV Power Management Integrated Circuit (PMIC) bindings
2
3Required properties:
4 - compatible : Should be "rohm,bd9571mwv".
5 - reg : I2C slave address.
6 - interrupt-parent : Phandle to the parent interrupt controller.
7 - interrupts : The interrupt line the device is connected to.
8 - interrupt-controller : Marks the device node as an interrupt controller.
9 - #interrupt-cells : The number of cells to describe an IRQ, should be 2.
10 The first cell is the IRQ number.
11 The second cell is the flags, encoded as trigger
12 masks from ../interrupt-controller/interrupts.txt.
13 - gpio-controller : Marks the device node as a GPIO Controller.
14 - #gpio-cells : Should be two. The first cell is the pin number and
15 the second cell is used to specify flags.
16 See ../gpio/gpio.txt for more information.
17 - regulators: : List of child nodes that specify the regulator
18 initialization data. Child nodes must be named
19 after their hardware counterparts:
20 - vd09
21 - vd18
22 - vd25
23 - vd33
24 - dvfs
25 Each child node is defined using the standard
26 binding for regulators.
27
28Example:
29
30 pmic: pmic@30 {
31 compatible = "rohm,bd9571mwv";
32 reg = <0x30>;
33 interrupt-parent = <&gpio2>;
34 interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
35 interrupt-controller;
36 #interrupt-cells = <2>;
37 gpio-controller;
38 #gpio-cells = <2>;
39
40 regulators {
41 dvfs: dvfs {
42 regulator-name = "dvfs";
43 regulator-min-microvolt = <750000>;
44 regulator-max-microvolt = <1030000>;
45 regulator-boot-on;
46 regulator-always-on;
47 };
48 };
49 };
diff --git a/Documentation/devicetree/bindings/mfd/da9052-i2c.txt b/Documentation/devicetree/bindings/mfd/da9052-i2c.txt
index 9554292dc6cb..57fa74e65664 100644
--- a/Documentation/devicetree/bindings/mfd/da9052-i2c.txt
+++ b/Documentation/devicetree/bindings/mfd/da9052-i2c.txt
@@ -4,6 +4,14 @@ Required properties:
4- compatible : Should be "dlg,da9052", "dlg,da9053-aa", 4- compatible : Should be "dlg,da9052", "dlg,da9053-aa",
5 "dlg,da9053-ab", or "dlg,da9053-bb" 5 "dlg,da9053-ab", or "dlg,da9053-bb"
6 6
7Optional properties:
8- dlg,tsi-as-adc : Boolean, if set the X+, X-, Y+, Y- touchscreen
9 input lines are used as general purpose analogue
10 input.
11- tsiref-supply: Phandle to the regulator, which provides the reference
12 voltage for the TSIREF pin. Must be provided when the
13 touchscreen pins are used for ADC purposes.
14
7Sub-nodes: 15Sub-nodes:
8- regulators : Contain the regulator nodes. The DA9052/53 regulators are 16- regulators : Contain the regulator nodes. The DA9052/53 regulators are
9 bound using their names as listed below: 17 bound using their names as listed below:
diff --git a/Documentation/devicetree/bindings/mfd/retu.txt b/Documentation/devicetree/bindings/mfd/retu.txt
new file mode 100644
index 000000000000..876242394a16
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/retu.txt
@@ -0,0 +1,25 @@
1* Device tree bindings for Nokia Retu and Tahvo multi-function device
2
3Retu and Tahvo are a multi-function devices found on Nokia Internet
4Tablets (770, N800 and N810). The Retu chip provides watchdog timer
5and power button control functionalities while Tahvo chip provides
6USB transceiver functionality.
7
8Required properties:
9- compatible: "nokia,retu" or "nokia,tahvo"
10- reg: Specifies the CBUS slave address of the ASIC chip
11- interrupts: The interrupt line the device is connected to
12- interrupt-parent: The parent interrupt controller
13
14Example:
15
16cbus0 {
17 compatible = "i2c-cbus-gpio";
18 ...
19 retu: retu@1 {
20 compatible = "nokia,retu";
21 interrupt-parent = <&gpio4>;
22 interrupts = <12 IRQ_TYPE_EDGE_RISING>;
23 reg = <0x1>;
24 };
25};
diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt b/Documentation/devicetree/bindings/mfd/rk808.txt
index 9636ae8d8d41..91b65227afeb 100644
--- a/Documentation/devicetree/bindings/mfd/rk808.txt
+++ b/Documentation/devicetree/bindings/mfd/rk808.txt
@@ -1,11 +1,14 @@
1RK8XX Power Management Integrated Circuit 1RK8XX Power Management Integrated Circuit
2 2
3The rk8xx family current members: 3The rk8xx family current members:
4rk805
4rk808 5rk808
5rk818 6rk818
6 7
7Required properties: 8Required properties:
8- compatible: "rockchip,rk808", "rockchip,rk818" 9- compatible: "rockchip,rk805"
10- compatible: "rockchip,rk808"
11- compatible: "rockchip,rk818"
9- reg: I2C slave address 12- reg: I2C slave address
10- interrupt-parent: The parent interrupt controller. 13- interrupt-parent: The parent interrupt controller.
11- interrupts: the interrupt outputs of the controller. 14- interrupts: the interrupt outputs of the controller.
@@ -18,6 +21,14 @@ Optional properties:
18- rockchip,system-power-controller: Telling whether or not this pmic is controlling 21- rockchip,system-power-controller: Telling whether or not this pmic is controlling
19 the system power. 22 the system power.
20 23
24Optional RK805 properties:
25- vcc1-supply: The input supply for DCDC_REG1
26- vcc2-supply: The input supply for DCDC_REG2
27- vcc3-supply: The input supply for DCDC_REG3
28- vcc4-supply: The input supply for DCDC_REG4
29- vcc5-supply: The input supply for LDO_REG1 and LDO_REG2
30- vcc6-supply: The input supply for LDO_REG3
31
21Optional RK808 properties: 32Optional RK808 properties:
22- vcc1-supply: The input supply for DCDC_REG1 33- vcc1-supply: The input supply for DCDC_REG1
23- vcc2-supply: The input supply for DCDC_REG2 34- vcc2-supply: The input supply for DCDC_REG2
@@ -56,6 +67,15 @@ by a child node of the 'regulators' node.
56 /* standard regulator bindings here */ 67 /* standard regulator bindings here */
57 }; 68 };
58 69
70Following regulators of the RK805 PMIC regulators are supported. Note that
71the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
72number as described in RK805 datasheet.
73
74 - DCDC_REGn
75 - valid values for n are 1 to 4.
76 - LDO_REGn
77 - valid values for n are 1 to 3
78
59Following regulators of the RK808 PMIC block are supported. Note that 79Following regulators of the RK808 PMIC block are supported. Note that
60the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO 80the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
61number as described in RK808 datasheet. 81number as described in RK808 datasheet.
diff --git a/Documentation/devicetree/bindings/mfd/stm32-lptimer.txt b/Documentation/devicetree/bindings/mfd/stm32-lptimer.txt
new file mode 100644
index 000000000000..2a9ff29db9c9
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/stm32-lptimer.txt
@@ -0,0 +1,48 @@
1STMicroelectronics STM32 Low-Power Timer
2
3The STM32 Low-Power Timer (LPTIM) is a 16-bit timer that provides several
4functions:
5- PWM output (with programmable prescaler, configurable polarity)
6- Quadrature encoder, counter
7- Trigger source for STM32 ADC/DAC (LPTIM_OUT)
8
9Required properties:
10- compatible: Must be "st,stm32-lptimer".
11- reg: Offset and length of the device's register set.
12- clocks: Phandle to the clock used by the LP Timer module.
13- clock-names: Must be "mux".
14- #address-cells: Should be '<1>'.
15- #size-cells: Should be '<0>'.
16
17Optional subnodes:
18- pwm: See ../pwm/pwm-stm32-lp.txt
19- counter: See ../iio/timer/stm32-lptimer-cnt.txt
20- trigger: See ../iio/timer/stm32-lptimer-trigger.txt
21
22Example:
23
24 timer@40002400 {
25 compatible = "st,stm32-lptimer";
26 reg = <0x40002400 0x400>;
27 clocks = <&timer_clk>;
28 clock-names = "mux";
29 #address-cells = <1>;
30 #size-cells = <0>;
31
32 pwm {
33 compatible = "st,stm32-pwm-lp";
34 pinctrl-names = "default";
35 pinctrl-0 = <&lppwm1_pins>;
36 };
37
38 trigger@0 {
39 compatible = "st,stm32-lptimer-trigger";
40 reg = <0>;
41 };
42
43 counter {
44 compatible = "st,stm32-lptimer-counter";
45 pinctrl-names = "default";
46 pinctrl-0 = <&lptim1_in_pins>;
47 };
48 };
diff --git a/Documentation/devicetree/bindings/mfd/tps6105x.txt b/Documentation/devicetree/bindings/mfd/tps6105x.txt
new file mode 100644
index 000000000000..93602c7a19c8
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/tps6105x.txt
@@ -0,0 +1,17 @@
1* Device tree bindings for TI TPS61050/61052 Boost Converters
2
3The TP61050/TPS61052 is a high-power "white LED driver". The
4device provides LED, GPIO and regulator functionalities.
5
6Required properties:
7- compatible: "ti,tps61050" or "ti,tps61052"
8- reg: Specifies the I2C slave address
9
10Example:
11
12i2c0 {
13 tps61052@33 {
14 compatible = "ti,tps61052";
15 reg = <0x33>;
16 };
17};
diff --git a/Documentation/devicetree/bindings/mfd/zii,rave-sp.txt b/Documentation/devicetree/bindings/mfd/zii,rave-sp.txt
new file mode 100644
index 000000000000..088eff9ddb78
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/zii,rave-sp.txt
@@ -0,0 +1,39 @@
1Zodiac Inflight Innovations RAVE Supervisory Processor
2
3RAVE Supervisory Processor communicates with SoC over UART. It is
4expected that its Device Tree node is specified as a child of a node
5corresponding to UART controller used for communication.
6
7Required parent device properties:
8
9 - compatible: Should be one of:
10 - "zii,rave-sp-niu"
11 - "zii,rave-sp-mezz"
12 - "zii,rave-sp-esb"
13 - "zii,rave-sp-rdu1"
14 - "zii,rave-sp-rdu2"
15
16 - current-speed: Should be set to baud rate SP device is using
17
18RAVE SP consists of the following sub-devices:
19
20Device Description
21------ -----------
22rave-sp-wdt : Watchdog
23rave-sp-nvmem : Interface to onborad EEPROM
24rave-sp-backlight : Display backlight
25rave-sp-hwmon : Interface to onboard hardware sensors
26rave-sp-leds : Interface to onboard LEDs
27rave-sp-input : Interface to onboard power button
28
29Example of usage:
30
31 rdu {
32 compatible = "zii,rave-sp-rdu2";
33 current-speed = <1000000>;
34
35 watchdog {
36 compatible = "zii,rave-sp-watchdog";
37 };
38 };
39
diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
new file mode 100644
index 000000000000..eee3dc260934
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
@@ -0,0 +1,63 @@
1Pincontrol driver for RK805 Power management IC.
2
3RK805 has 2 pins which can be configured as GPIO output only.
4
5Please refer file <devicetree/bindings/pinctrl/pinctrl-bindings.txt>
6for details of the common pinctrl bindings used by client devices,
7including the meaning of the phrase "pin configuration node".
8
9Optional Pinmux properties:
10--------------------------
11Following properties are required if default setting of pins are required
12at boot.
13- pinctrl-names: A pinctrl state named per <pinctrl-binding.txt>.
14- pinctrl[0...n]: Properties to contain the phandle for pinctrl states per
15 <pinctrl-binding.txt>.
16
17The pin configurations are defined as child of the pinctrl states node. Each
18sub-node have following properties:
19
20Required properties:
21------------------
22- #gpio-cells: Should be two. The first cell is the pin number and the
23 second is the GPIO flags.
24
25- gpio-controller: Marks the device node as a GPIO controller.
26
27- pins: List of pins. Valid values of pins properties are: gpio0, gpio1.
28
29First 2 properties must be added in the RK805 PMIC node, documented in
30Documentation/devicetree/bindings/mfd/rk808.txt
31
32Optional properties:
33-------------------
34Following are optional properties defined as pinmux DT binding document
35<pinctrl-bindings.txt>. Absence of properties will leave the configuration
36on default.
37 function,
38 output-low,
39 output-high.
40
41Valid values for function properties are: gpio.
42
43Theres is also not customised properties for any GPIO.
44
45Example:
46--------
47rk805: rk805@18 {
48 compatible = "rockchip,rk805";
49 ...
50 gpio-controller;
51 #gpio-cells = <2>;
52
53 pinctrl-names = "default";
54 pinctrl-0 = <&pmic_int_l>, <&rk805_default>;
55
56 rk805_default: pinmux {
57 gpio01 {
58 pins = "gpio0", "gpio1";
59 function = "gpio";
60 output-high;
61 };
62 };
63};
diff --git a/Documentation/devicetree/bindings/pwm/pwm-stm32-lp.txt b/Documentation/devicetree/bindings/pwm/pwm-stm32-lp.txt
new file mode 100644
index 000000000000..f8338d11fd2b
--- /dev/null
+++ b/Documentation/devicetree/bindings/pwm/pwm-stm32-lp.txt
@@ -0,0 +1,24 @@
1STMicroelectronics STM32 Low-Power Timer PWM
2
3STM32 Low-Power Timer provides single channel PWM.
4
5Must be a sub-node of an STM32 Low-Power Timer device tree node.
6See ../mfd/stm32-lptimer.txt for details about the parent node.
7
8Required parameters:
9- compatible: Must be "st,stm32-pwm-lp".
10
11Optional properties:
12- pinctrl-names: Set to "default".
13- pinctrl-0: Phandle pointing to pin configuration node for PWM.
14
15Example:
16 timer@40002400 {
17 compatible = "st,stm32-lptimer";
18 ...
19 pwm {
20 compatible = "st,stm32-pwm-lp";
21 pinctrl-names = "default";
22 pinctrl-0 = <&lppwm1_pins>;
23 };
24 };
diff --git a/MAINTAINERS b/MAINTAINERS
index b07232679a66..ac2dfb26d899 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11432,6 +11432,17 @@ L: linux-serial@vger.kernel.org
11432S: Odd Fixes 11432S: Odd Fixes
11433F: drivers/tty/serial/rp2.* 11433F: drivers/tty/serial/rp2.*
11434 11434
11435ROHM MULTIFUNCTION BD9571MWV-M PMIC DEVICE DRIVERS
11436M: Marek Vasut <marek.vasut+renesas@gmail.com>
11437L: linux-kernel@vger.kernel.org
11438L: linux-renesas-soc@vger.kernel.org
11439S: Supported
11440F: drivers/mfd/bd9571mwv.c
11441F: drivers/regulator/bd9571mwv-regulator.c
11442F: drivers/gpio/gpio-bd9571mwv.c
11443F: include/linux/mfd/bd9571mwv.h
11444F: Documentation/devicetree/bindings/mfd/bd9571mwv.txt
11445
11435ROSE NETWORK LAYER 11446ROSE NETWORK LAYER
11436M: Ralf Baechle <ralf@linux-mips.org> 11447M: Ralf Baechle <ralf@linux-mips.org>
11437L: linux-hams@vger.kernel.org 11448L: linux-hams@vger.kernel.org
diff --git a/arch/arm/boot/dts/omap2420-n8x0-common.dtsi b/arch/arm/boot/dts/omap2420-n8x0-common.dtsi
index 7e5ffc583c90..91886231e5a8 100644
--- a/arch/arm/boot/dts/omap2420-n8x0-common.dtsi
+++ b/arch/arm/boot/dts/omap2420-n8x0-common.dtsi
@@ -15,8 +15,8 @@
15 >; 15 >;
16 #address-cells = <1>; 16 #address-cells = <1>;
17 #size-cells = <0>; 17 #size-cells = <0>;
18 retu_mfd: retu@1 { 18 retu: retu@1 {
19 compatible = "retu-mfd"; 19 compatible = "nokia,retu";
20 interrupt-parent = <&gpio4>; 20 interrupt-parent = <&gpio4>;
21 interrupts = <12 IRQ_TYPE_EDGE_RISING>; 21 interrupts = <12 IRQ_TYPE_EDGE_RISING>;
22 reg = <0x1>; 22 reg = <0x1>;
diff --git a/arch/arm/boot/dts/ste-hrefprev60.dtsi b/arch/arm/boot/dts/ste-hrefprev60.dtsi
index 5882a2606ac3..3f14b4df69b4 100644
--- a/arch/arm/boot/dts/ste-hrefprev60.dtsi
+++ b/arch/arm/boot/dts/ste-hrefprev60.dtsi
@@ -30,7 +30,7 @@
30 30
31 i2c@80004000 { 31 i2c@80004000 {
32 tps61052@33 { 32 tps61052@33 {
33 compatible = "tps61052"; 33 compatible = "ti,tps61052";
34 reg = <0x33>; 34 reg = <0x33>;
35 }; 35 };
36 36
diff --git a/arch/arm/mach-omap1/board-h2-mmc.c b/arch/arm/mach-omap1/board-h2-mmc.c
index 357be2debc9d..91bda9c802ff 100644
--- a/arch/arm/mach-omap1/board-h2-mmc.c
+++ b/arch/arm/mach-omap1/board-h2-mmc.c
@@ -14,7 +14,7 @@
14#include <linux/gpio.h> 14#include <linux/gpio.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/platform_data/gpio-omap.h> 16#include <linux/platform_data/gpio-omap.h>
17#include <linux/i2c/tps65010.h> 17#include <linux/mfd/tps65010.h>
18 18
19#include "board-h2.h" 19#include "board-h2.h"
20#include "mmc.h" 20#include "mmc.h"
diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index 675254ee4b1e..dece47d76282 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -28,7 +28,7 @@
28#include <linux/mtd/partitions.h> 28#include <linux/mtd/partitions.h>
29#include <linux/mtd/physmap.h> 29#include <linux/mtd/physmap.h>
30#include <linux/input.h> 30#include <linux/input.h>
31#include <linux/i2c/tps65010.h> 31#include <linux/mfd/tps65010.h>
32#include <linux/smc91x.h> 32#include <linux/smc91x.h>
33#include <linux/omapfb.h> 33#include <linux/omapfb.h>
34#include <linux/platform_data/gpio-omap.h> 34#include <linux/platform_data/gpio-omap.h>
diff --git a/arch/arm/mach-omap1/board-h3-mmc.c b/arch/arm/mach-omap1/board-h3-mmc.c
index 4f58bfa5e754..692c267a9a90 100644
--- a/arch/arm/mach-omap1/board-h3-mmc.c
+++ b/arch/arm/mach-omap1/board-h3-mmc.c
@@ -14,7 +14,7 @@
14#include <linux/gpio.h> 14#include <linux/gpio.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16 16
17#include <linux/i2c/tps65010.h> 17#include <linux/mfd/tps65010.h>
18 18
19#include "common.h" 19#include "common.h"
20#include "board-h3.h" 20#include "board-h3.h"
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index e62f9d454f10..6d32beeb2d88 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -28,7 +28,7 @@
28#include <linux/mtd/physmap.h> 28#include <linux/mtd/physmap.h>
29#include <linux/input.h> 29#include <linux/input.h>
30#include <linux/spi/spi.h> 30#include <linux/spi/spi.h>
31#include <linux/i2c/tps65010.h> 31#include <linux/mfd/tps65010.h>
32#include <linux/smc91x.h> 32#include <linux/smc91x.h>
33#include <linux/omapfb.h> 33#include <linux/omapfb.h>
34#include <linux/platform_data/gpio-omap.h> 34#include <linux/platform_data/gpio-omap.h>
diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index ee8d9f553db4..06243c0b12d2 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -233,10 +233,10 @@ static struct platform_device nokia770_cbus_device = {
233 233
234static struct i2c_board_info nokia770_i2c_board_info_2[] __initdata = { 234static struct i2c_board_info nokia770_i2c_board_info_2[] __initdata = {
235 { 235 {
236 I2C_BOARD_INFO("retu-mfd", 0x01), 236 I2C_BOARD_INFO("retu", 0x01),
237 }, 237 },
238 { 238 {
239 I2C_BOARD_INFO("tahvo-mfd", 0x02), 239 I2C_BOARD_INFO("tahvo", 0x02),
240 }, 240 },
241}; 241};
242 242
diff --git a/arch/arm/mach-omap1/board-osk.c b/arch/arm/mach-omap1/board-osk.c
index 95ac1929aede..d579f4e04137 100644
--- a/arch/arm/mach-omap1/board-osk.c
+++ b/arch/arm/mach-omap1/board-osk.c
@@ -38,7 +38,7 @@
38#include <linux/mtd/mtd.h> 38#include <linux/mtd/mtd.h>
39#include <linux/mtd/partitions.h> 39#include <linux/mtd/partitions.h>
40#include <linux/mtd/physmap.h> 40#include <linux/mtd/physmap.h>
41#include <linux/i2c/tps65010.h> 41#include <linux/mfd/tps65010.h>
42#include <linux/platform_data/gpio-omap.h> 42#include <linux/platform_data/gpio-omap.h>
43#include <linux/platform_data/omap1_bl.h> 43#include <linux/platform_data/omap1_bl.h>
44 44
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
index 8cc6338fcb12..b5ad7fcb80ed 100644
--- a/arch/arm/mach-omap2/common.h
+++ b/arch/arm/mach-omap2/common.h
@@ -29,7 +29,7 @@
29#include <linux/irq.h> 29#include <linux/irq.h>
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/i2c.h> 31#include <linux/i2c.h>
32#include <linux/i2c/twl.h> 32#include <linux/mfd/twl.h>
33#include <linux/i2c-omap.h> 33#include <linux/i2c-omap.h>
34#include <linux/reboot.h> 34#include <linux/reboot.h>
35#include <linux/irqchip/irq-omap-intc.h> 35#include <linux/irqchip/irq-omap-intc.h>
diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
index 1346b3ab34a5..295124b248ae 100644
--- a/arch/arm/mach-omap2/omap_twl.c
+++ b/arch/arm/mach-omap2/omap_twl.c
@@ -16,7 +16,7 @@
16#include <linux/err.h> 16#include <linux/err.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/i2c/twl.h> 19#include <linux/mfd/twl.h>
20 20
21#include "soc.h" 21#include "soc.h"
22#include "voltage.h" 22#include "voltage.h"
diff --git a/arch/arm/mach-s3c24xx/mach-osiris-dvs.c b/arch/arm/mach-s3c24xx/mach-osiris-dvs.c
index 262ab0744748..6cac7da15e2b 100644
--- a/arch/arm/mach-s3c24xx/mach-osiris-dvs.c
+++ b/arch/arm/mach-s3c24xx/mach-osiris-dvs.c
@@ -17,7 +17,7 @@
17#include <linux/cpufreq.h> 17#include <linux/cpufreq.h>
18#include <linux/gpio.h> 18#include <linux/gpio.h>
19 19
20#include <linux/i2c/tps65010.h> 20#include <linux/mfd/tps65010.h>
21 21
22#include <plat/cpu-freq.h> 22#include <plat/cpu-freq.h>
23#include <mach/gpio-samsung.h> 23#include <mach/gpio-samsung.h>
diff --git a/arch/arm/mach-s3c24xx/mach-osiris.c b/arch/arm/mach-s3c24xx/mach-osiris.c
index 70b0eb7d3134..64b1a0b7b803 100644
--- a/arch/arm/mach-s3c24xx/mach-osiris.c
+++ b/arch/arm/mach-s3c24xx/mach-osiris.c
@@ -24,7 +24,7 @@
24#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26 26
27#include <linux/i2c/tps65010.h> 27#include <linux/mfd/tps65010.h>
28 28
29#include <asm/mach-types.h> 29#include <asm/mach-types.h>
30#include <asm/mach/arch.h> 30#include <asm/mach/arch.h>
diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index 24f388ed46d4..9b511df5450e 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -35,7 +35,7 @@
35#include <linux/of.h> 35#include <linux/of.h>
36#include <linux/irqdomain.h> 36#include <linux/irqdomain.h>
37 37
38#include <linux/i2c/twl.h> 38#include <linux/mfd/twl.h>
39 39
40/* 40/*
41 * The GPIO "subchip" supports 18 GPIOs which can be configured as 41 * The GPIO "subchip" supports 18 GPIOs which can be configured as
diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
index 6bc602891f2f..e3c15f88075f 100644
--- a/drivers/iio/adc/stm32-adc.c
+++ b/drivers/iio/adc/stm32-adc.c
@@ -25,6 +25,7 @@
25#include <linux/dmaengine.h> 25#include <linux/dmaengine.h>
26#include <linux/iio/iio.h> 26#include <linux/iio/iio.h>
27#include <linux/iio/buffer.h> 27#include <linux/iio/buffer.h>
28#include <linux/iio/timer/stm32-lptim-trigger.h>
28#include <linux/iio/timer/stm32-timer-trigger.h> 29#include <linux/iio/timer/stm32-timer-trigger.h>
29#include <linux/iio/trigger.h> 30#include <linux/iio/trigger.h>
30#include <linux/iio/trigger_consumer.h> 31#include <linux/iio/trigger_consumer.h>
@@ -185,6 +186,11 @@ enum stm32_adc_extsel {
185 STM32_EXT13, 186 STM32_EXT13,
186 STM32_EXT14, 187 STM32_EXT14,
187 STM32_EXT15, 188 STM32_EXT15,
189 STM32_EXT16,
190 STM32_EXT17,
191 STM32_EXT18,
192 STM32_EXT19,
193 STM32_EXT20,
188}; 194};
189 195
190/** 196/**
@@ -526,6 +532,9 @@ static struct stm32_adc_trig_info stm32h7_adc_trigs[] = {
526 { TIM4_TRGO, STM32_EXT12 }, 532 { TIM4_TRGO, STM32_EXT12 },
527 { TIM6_TRGO, STM32_EXT13 }, 533 { TIM6_TRGO, STM32_EXT13 },
528 { TIM3_CH4, STM32_EXT15 }, 534 { TIM3_CH4, STM32_EXT15 },
535 { LPTIM1_OUT, STM32_EXT18 },
536 { LPTIM2_OUT, STM32_EXT19 },
537 { LPTIM3_OUT, STM32_EXT20 },
529 {}, 538 {},
530}; 539};
531 540
@@ -1082,7 +1091,8 @@ static int stm32_adc_get_trig_extsel(struct iio_dev *indio_dev,
1082 * Checking both stm32 timer trigger type and trig name 1091 * Checking both stm32 timer trigger type and trig name
1083 * should be safe against arbitrary trigger names. 1092 * should be safe against arbitrary trigger names.
1084 */ 1093 */
1085 if (is_stm32_timer_trigger(trig) && 1094 if ((is_stm32_timer_trigger(trig) ||
1095 is_stm32_lptim_trigger(trig)) &&
1086 !strcmp(adc->cfg->trigs[i].name, trig->name)) { 1096 !strcmp(adc->cfg->trigs[i].name, trig->name)) {
1087 return adc->cfg->trigs[i].extsel; 1097 return adc->cfg->trigs[i].extsel;
1088 } 1098 }
@@ -1764,7 +1774,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
1764 indio_dev->dev.parent = &pdev->dev; 1774 indio_dev->dev.parent = &pdev->dev;
1765 indio_dev->dev.of_node = pdev->dev.of_node; 1775 indio_dev->dev.of_node = pdev->dev.of_node;
1766 indio_dev->info = &stm32_adc_iio_info; 1776 indio_dev->info = &stm32_adc_iio_info;
1767 indio_dev->modes = INDIO_DIRECT_MODE; 1777 indio_dev->modes = INDIO_DIRECT_MODE | INDIO_HARDWARE_TRIGGERED;
1768 1778
1769 platform_set_drvdata(pdev, adc); 1779 platform_set_drvdata(pdev, adc);
1770 1780
diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c
index bd3d37fc2144..1edd99f0c5e5 100644
--- a/drivers/iio/adc/twl4030-madc.c
+++ b/drivers/iio/adc/twl4030-madc.c
@@ -35,7 +35,7 @@
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/platform_device.h> 36#include <linux/platform_device.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/i2c/twl.h> 38#include <linux/mfd/twl.h>
39#include <linux/module.h> 39#include <linux/module.h>
40#include <linux/stddef.h> 40#include <linux/stddef.h>
41#include <linux/mutex.h> 41#include <linux/mutex.h>
diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c
index becbb0aef232..bc0e60b9da45 100644
--- a/drivers/iio/adc/twl6030-gpadc.c
+++ b/drivers/iio/adc/twl6030-gpadc.c
@@ -33,7 +33,7 @@
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/platform_device.h> 34#include <linux/platform_device.h>
35#include <linux/of_platform.h> 35#include <linux/of_platform.h>
36#include <linux/i2c/twl.h> 36#include <linux/mfd/twl.h>
37#include <linux/iio/iio.h> 37#include <linux/iio/iio.h>
38#include <linux/iio/sysfs.h> 38#include <linux/iio/sysfs.h>
39 39
diff --git a/drivers/iio/counter/Kconfig b/drivers/iio/counter/Kconfig
index b37e5fc03149..474e1ac4e7c0 100644
--- a/drivers/iio/counter/Kconfig
+++ b/drivers/iio/counter/Kconfig
@@ -21,4 +21,13 @@ config 104_QUAD_8
21 The base port addresses for the devices may be configured via the base 21 The base port addresses for the devices may be configured via the base
22 array module parameter. 22 array module parameter.
23 23
24config STM32_LPTIMER_CNT
25 tristate "STM32 LP Timer encoder counter driver"
26 depends on MFD_STM32_LPTIMER || COMPILE_TEST
27 help
28 Select this option to enable STM32 Low-Power Timer quadrature encoder
29 and counter driver.
30
31 To compile this driver as a module, choose M here: the
32 module will be called stm32-lptimer-cnt.
24endmenu 33endmenu
diff --git a/drivers/iio/counter/Makefile b/drivers/iio/counter/Makefile
index 007e88411648..1b9a896eb488 100644
--- a/drivers/iio/counter/Makefile
+++ b/drivers/iio/counter/Makefile
@@ -5,3 +5,4 @@
5# When adding new entries keep the list in alphabetical order 5# When adding new entries keep the list in alphabetical order
6 6
7obj-$(CONFIG_104_QUAD_8) += 104-quad-8.o 7obj-$(CONFIG_104_QUAD_8) += 104-quad-8.o
8obj-$(CONFIG_STM32_LPTIMER_CNT) += stm32-lptimer-cnt.o
diff --git a/drivers/iio/counter/stm32-lptimer-cnt.c b/drivers/iio/counter/stm32-lptimer-cnt.c
new file mode 100644
index 000000000000..1c5909bb1605
--- /dev/null
+++ b/drivers/iio/counter/stm32-lptimer-cnt.c
@@ -0,0 +1,383 @@
1/*
2 * STM32 Low-Power Timer Encoder and Counter driver
3 *
4 * Copyright (C) STMicroelectronics 2017
5 *
6 * Author: Fabrice Gasnier <fabrice.gasnier@st.com>
7 *
8 * Inspired by 104-quad-8 and stm32-timer-trigger drivers.
9 *
10 * License terms: GNU General Public License (GPL), version 2
11 */
12
13#include <linux/bitfield.h>
14#include <linux/iio/iio.h>
15#include <linux/mfd/stm32-lptimer.h>
16#include <linux/module.h>
17#include <linux/platform_device.h>
18
19struct stm32_lptim_cnt {
20 struct device *dev;
21 struct regmap *regmap;
22 struct clk *clk;
23 u32 preset;
24 u32 polarity;
25 u32 quadrature_mode;
26};
27
28static int stm32_lptim_is_enabled(struct stm32_lptim_cnt *priv)
29{
30 u32 val;
31 int ret;
32
33 ret = regmap_read(priv->regmap, STM32_LPTIM_CR, &val);
34 if (ret)
35 return ret;
36
37 return FIELD_GET(STM32_LPTIM_ENABLE, val);
38}
39
40static int stm32_lptim_set_enable_state(struct stm32_lptim_cnt *priv,
41 int enable)
42{
43 int ret;
44 u32 val;
45
46 val = FIELD_PREP(STM32_LPTIM_ENABLE, enable);
47 ret = regmap_write(priv->regmap, STM32_LPTIM_CR, val);
48 if (ret)
49 return ret;
50
51 if (!enable) {
52 clk_disable(priv->clk);
53 return 0;
54 }
55
56 /* LP timer must be enabled before writing CMP & ARR */
57 ret = regmap_write(priv->regmap, STM32_LPTIM_ARR, priv->preset);
58 if (ret)
59 return ret;
60
61 ret = regmap_write(priv->regmap, STM32_LPTIM_CMP, 0);
62 if (ret)
63 return ret;
64
65 /* ensure CMP & ARR registers are properly written */
66 ret = regmap_read_poll_timeout(priv->regmap, STM32_LPTIM_ISR, val,
67 (val & STM32_LPTIM_CMPOK_ARROK),
68 100, 1000);
69 if (ret)
70 return ret;
71
72 ret = regmap_write(priv->regmap, STM32_LPTIM_ICR,
73 STM32_LPTIM_CMPOKCF_ARROKCF);
74 if (ret)
75 return ret;
76
77 ret = clk_enable(priv->clk);
78 if (ret) {
79 regmap_write(priv->regmap, STM32_LPTIM_CR, 0);
80 return ret;
81 }
82
83 /* Start LP timer in continuous mode */
84 return regmap_update_bits(priv->regmap, STM32_LPTIM_CR,
85 STM32_LPTIM_CNTSTRT, STM32_LPTIM_CNTSTRT);
86}
87
88static int stm32_lptim_setup(struct stm32_lptim_cnt *priv, int enable)
89{
90 u32 mask = STM32_LPTIM_ENC | STM32_LPTIM_COUNTMODE |
91 STM32_LPTIM_CKPOL | STM32_LPTIM_PRESC;
92 u32 val;
93
94 /* Setup LP timer encoder/counter and polarity, without prescaler */
95 if (priv->quadrature_mode)
96 val = enable ? STM32_LPTIM_ENC : 0;
97 else
98 val = enable ? STM32_LPTIM_COUNTMODE : 0;
99 val |= FIELD_PREP(STM32_LPTIM_CKPOL, enable ? priv->polarity : 0);
100
101 return regmap_update_bits(priv->regmap, STM32_LPTIM_CFGR, mask, val);
102}
103
104static int stm32_lptim_write_raw(struct iio_dev *indio_dev,
105 struct iio_chan_spec const *chan,
106 int val, int val2, long mask)
107{
108 struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
109 int ret;
110
111 switch (mask) {
112 case IIO_CHAN_INFO_ENABLE:
113 if (val < 0 || val > 1)
114 return -EINVAL;
115
116 /* Check nobody uses the timer, or already disabled/enabled */
117 ret = stm32_lptim_is_enabled(priv);
118 if ((ret < 0) || (!ret && !val))
119 return ret;
120 if (val && ret)
121 return -EBUSY;
122
123 ret = stm32_lptim_setup(priv, val);
124 if (ret)
125 return ret;
126 return stm32_lptim_set_enable_state(priv, val);
127
128 default:
129 return -EINVAL;
130 }
131}
132
133static int stm32_lptim_read_raw(struct iio_dev *indio_dev,
134 struct iio_chan_spec const *chan,
135 int *val, int *val2, long mask)
136{
137 struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
138 u32 dat;
139 int ret;
140
141 switch (mask) {
142 case IIO_CHAN_INFO_RAW:
143 ret = regmap_read(priv->regmap, STM32_LPTIM_CNT, &dat);
144 if (ret)
145 return ret;
146 *val = dat;
147 return IIO_VAL_INT;
148
149 case IIO_CHAN_INFO_ENABLE:
150 ret = stm32_lptim_is_enabled(priv);
151 if (ret < 0)
152 return ret;
153 *val = ret;
154 return IIO_VAL_INT;
155
156 case IIO_CHAN_INFO_SCALE:
157 /* Non-quadrature mode: scale = 1 */
158 *val = 1;
159 *val2 = 0;
160 if (priv->quadrature_mode) {
161 /*
162 * Quadrature encoder mode:
163 * - both edges, quarter cycle, scale is 0.25
164 * - either rising/falling edge scale is 0.5
165 */
166 if (priv->polarity > 1)
167 *val2 = 2;
168 else
169 *val2 = 1;
170 }
171 return IIO_VAL_FRACTIONAL_LOG2;
172
173 default:
174 return -EINVAL;
175 }
176}
177
178static const struct iio_info stm32_lptim_cnt_iio_info = {
179 .read_raw = stm32_lptim_read_raw,
180 .write_raw = stm32_lptim_write_raw,
181 .driver_module = THIS_MODULE,
182};
183
184static const char *const stm32_lptim_quadrature_modes[] = {
185 "non-quadrature",
186 "quadrature",
187};
188
189static int stm32_lptim_get_quadrature_mode(struct iio_dev *indio_dev,
190 const struct iio_chan_spec *chan)
191{
192 struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
193
194 return priv->quadrature_mode;
195}
196
197static int stm32_lptim_set_quadrature_mode(struct iio_dev *indio_dev,
198 const struct iio_chan_spec *chan,
199 unsigned int type)
200{
201 struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
202
203 if (stm32_lptim_is_enabled(priv))
204 return -EBUSY;
205
206 priv->quadrature_mode = type;
207
208 return 0;
209}
210
211static const struct iio_enum stm32_lptim_quadrature_mode_en = {
212 .items = stm32_lptim_quadrature_modes,
213 .num_items = ARRAY_SIZE(stm32_lptim_quadrature_modes),
214 .get = stm32_lptim_get_quadrature_mode,
215 .set = stm32_lptim_set_quadrature_mode,
216};
217
218static const char * const stm32_lptim_cnt_polarity[] = {
219 "rising-edge", "falling-edge", "both-edges",
220};
221
222static int stm32_lptim_cnt_get_polarity(struct iio_dev *indio_dev,
223 const struct iio_chan_spec *chan)
224{
225 struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
226
227 return priv->polarity;
228}
229
230static int stm32_lptim_cnt_set_polarity(struct iio_dev *indio_dev,
231 const struct iio_chan_spec *chan,
232 unsigned int type)
233{
234 struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
235
236 if (stm32_lptim_is_enabled(priv))
237 return -EBUSY;
238
239 priv->polarity = type;
240
241 return 0;
242}
243
244static const struct iio_enum stm32_lptim_cnt_polarity_en = {
245 .items = stm32_lptim_cnt_polarity,
246 .num_items = ARRAY_SIZE(stm32_lptim_cnt_polarity),
247 .get = stm32_lptim_cnt_get_polarity,
248 .set = stm32_lptim_cnt_set_polarity,
249};
250
251static ssize_t stm32_lptim_cnt_get_preset(struct iio_dev *indio_dev,
252 uintptr_t private,
253 const struct iio_chan_spec *chan,
254 char *buf)
255{
256 struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
257
258 return snprintf(buf, PAGE_SIZE, "%u\n", priv->preset);
259}
260
261static ssize_t stm32_lptim_cnt_set_preset(struct iio_dev *indio_dev,
262 uintptr_t private,
263 const struct iio_chan_spec *chan,
264 const char *buf, size_t len)
265{
266 struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
267 int ret;
268
269 if (stm32_lptim_is_enabled(priv))
270 return -EBUSY;
271
272 ret = kstrtouint(buf, 0, &priv->preset);
273 if (ret)
274 return ret;
275
276 if (priv->preset > STM32_LPTIM_MAX_ARR)
277 return -EINVAL;
278
279 return len;
280}
281
282/* LP timer with encoder */
283static const struct iio_chan_spec_ext_info stm32_lptim_enc_ext_info[] = {
284 {
285 .name = "preset",
286 .shared = IIO_SEPARATE,
287 .read = stm32_lptim_cnt_get_preset,
288 .write = stm32_lptim_cnt_set_preset,
289 },
290 IIO_ENUM("polarity", IIO_SEPARATE, &stm32_lptim_cnt_polarity_en),
291 IIO_ENUM_AVAILABLE("polarity", &stm32_lptim_cnt_polarity_en),
292 IIO_ENUM("quadrature_mode", IIO_SEPARATE,
293 &stm32_lptim_quadrature_mode_en),
294 IIO_ENUM_AVAILABLE("quadrature_mode", &stm32_lptim_quadrature_mode_en),
295 {}
296};
297
298static const struct iio_chan_spec stm32_lptim_enc_channels = {
299 .type = IIO_COUNT,
300 .channel = 0,
301 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
302 BIT(IIO_CHAN_INFO_ENABLE) |
303 BIT(IIO_CHAN_INFO_SCALE),
304 .ext_info = stm32_lptim_enc_ext_info,
305 .indexed = 1,
306};
307
308/* LP timer without encoder (counter only) */
309static const struct iio_chan_spec_ext_info stm32_lptim_cnt_ext_info[] = {
310 {
311 .name = "preset",
312 .shared = IIO_SEPARATE,
313 .read = stm32_lptim_cnt_get_preset,
314 .write = stm32_lptim_cnt_set_preset,
315 },
316 IIO_ENUM("polarity", IIO_SEPARATE, &stm32_lptim_cnt_polarity_en),
317 IIO_ENUM_AVAILABLE("polarity", &stm32_lptim_cnt_polarity_en),
318 {}
319};
320
321static const struct iio_chan_spec stm32_lptim_cnt_channels = {
322 .type = IIO_COUNT,
323 .channel = 0,
324 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
325 BIT(IIO_CHAN_INFO_ENABLE) |
326 BIT(IIO_CHAN_INFO_SCALE),
327 .ext_info = stm32_lptim_cnt_ext_info,
328 .indexed = 1,
329};
330
331static int stm32_lptim_cnt_probe(struct platform_device *pdev)
332{
333 struct stm32_lptimer *ddata = dev_get_drvdata(pdev->dev.parent);
334 struct stm32_lptim_cnt *priv;
335 struct iio_dev *indio_dev;
336
337 if (IS_ERR_OR_NULL(ddata))
338 return -EINVAL;
339
340 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*priv));
341 if (!indio_dev)
342 return -ENOMEM;
343
344 priv = iio_priv(indio_dev);
345 priv->dev = &pdev->dev;
346 priv->regmap = ddata->regmap;
347 priv->clk = ddata->clk;
348 priv->preset = STM32_LPTIM_MAX_ARR;
349
350 indio_dev->name = dev_name(&pdev->dev);
351 indio_dev->dev.parent = &pdev->dev;
352 indio_dev->dev.of_node = pdev->dev.of_node;
353 indio_dev->info = &stm32_lptim_cnt_iio_info;
354 if (ddata->has_encoder)
355 indio_dev->channels = &stm32_lptim_enc_channels;
356 else
357 indio_dev->channels = &stm32_lptim_cnt_channels;
358 indio_dev->num_channels = 1;
359
360 platform_set_drvdata(pdev, priv);
361
362 return devm_iio_device_register(&pdev->dev, indio_dev);
363}
364
365static const struct of_device_id stm32_lptim_cnt_of_match[] = {
366 { .compatible = "st,stm32-lptimer-counter", },
367 {},
368};
369MODULE_DEVICE_TABLE(of, stm32_lptim_cnt_of_match);
370
371static struct platform_driver stm32_lptim_cnt_driver = {
372 .probe = stm32_lptim_cnt_probe,
373 .driver = {
374 .name = "stm32-lptimer-counter",
375 .of_match_table = stm32_lptim_cnt_of_match,
376 },
377};
378module_platform_driver(stm32_lptim_cnt_driver);
379
380MODULE_AUTHOR("Fabrice Gasnier <fabrice.gasnier@st.com>");
381MODULE_ALIAS("platform:stm32-lptimer-counter");
382MODULE_DESCRIPTION("STMicroelectronics STM32 LPTIM counter driver");
383MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/trigger/Kconfig b/drivers/iio/trigger/Kconfig
index e4d4e63434db..a633d2c8e805 100644
--- a/drivers/iio/trigger/Kconfig
+++ b/drivers/iio/trigger/Kconfig
@@ -24,6 +24,17 @@ config IIO_INTERRUPT_TRIGGER
24 To compile this driver as a module, choose M here: the 24 To compile this driver as a module, choose M here: the
25 module will be called iio-trig-interrupt. 25 module will be called iio-trig-interrupt.
26 26
27config IIO_STM32_LPTIMER_TRIGGER
28 tristate "STM32 Low-Power Timer Trigger"
29 depends on MFD_STM32_LPTIMER || COMPILE_TEST
30 help
31 Select this option to enable STM32 Low-Power Timer Trigger.
32 This can be used as trigger source for STM32 internal ADC
33 and/or DAC.
34
35 To compile this driver as a module, choose M here: the
36 module will be called stm32-lptimer-trigger.
37
27config IIO_STM32_TIMER_TRIGGER 38config IIO_STM32_TIMER_TRIGGER
28 tristate "STM32 Timer Trigger" 39 tristate "STM32 Timer Trigger"
29 depends on (ARCH_STM32 && OF && MFD_STM32_TIMERS) || COMPILE_TEST 40 depends on (ARCH_STM32 && OF && MFD_STM32_TIMERS) || COMPILE_TEST
diff --git a/drivers/iio/trigger/Makefile b/drivers/iio/trigger/Makefile
index 5c4ecd380653..0a72a2a76cb2 100644
--- a/drivers/iio/trigger/Makefile
+++ b/drivers/iio/trigger/Makefile
@@ -6,6 +6,7 @@
6 6
7obj-$(CONFIG_IIO_HRTIMER_TRIGGER) += iio-trig-hrtimer.o 7obj-$(CONFIG_IIO_HRTIMER_TRIGGER) += iio-trig-hrtimer.o
8obj-$(CONFIG_IIO_INTERRUPT_TRIGGER) += iio-trig-interrupt.o 8obj-$(CONFIG_IIO_INTERRUPT_TRIGGER) += iio-trig-interrupt.o
9obj-$(CONFIG_IIO_STM32_LPTIMER_TRIGGER) += stm32-lptimer-trigger.o
9obj-$(CONFIG_IIO_STM32_TIMER_TRIGGER) += stm32-timer-trigger.o 10obj-$(CONFIG_IIO_STM32_TIMER_TRIGGER) += stm32-timer-trigger.o
10obj-$(CONFIG_IIO_SYSFS_TRIGGER) += iio-trig-sysfs.o 11obj-$(CONFIG_IIO_SYSFS_TRIGGER) += iio-trig-sysfs.o
11obj-$(CONFIG_IIO_TIGHTLOOP_TRIGGER) += iio-trig-loop.o 12obj-$(CONFIG_IIO_TIGHTLOOP_TRIGGER) += iio-trig-loop.o
diff --git a/drivers/iio/trigger/stm32-lptimer-trigger.c b/drivers/iio/trigger/stm32-lptimer-trigger.c
new file mode 100644
index 000000000000..241eae6a4306
--- /dev/null
+++ b/drivers/iio/trigger/stm32-lptimer-trigger.c
@@ -0,0 +1,118 @@
1/*
2 * STM32 Low-Power Timer Trigger driver
3 *
4 * Copyright (C) STMicroelectronics 2017
5 *
6 * Author: Fabrice Gasnier <fabrice.gasnier@st.com>.
7 *
8 * License terms: GNU General Public License (GPL), version 2
9 *
10 * Inspired by Benjamin Gaignard's stm32-timer-trigger driver
11 */
12
13#include <linux/iio/timer/stm32-lptim-trigger.h>
14#include <linux/mfd/stm32-lptimer.h>
15#include <linux/module.h>
16#include <linux/platform_device.h>
17
18/* List Low-Power Timer triggers */
19static const char * const stm32_lptim_triggers[] = {
20 LPTIM1_OUT,
21 LPTIM2_OUT,
22 LPTIM3_OUT,
23};
24
25struct stm32_lptim_trigger {
26 struct device *dev;
27 const char *trg;
28};
29
30static int stm32_lptim_validate_device(struct iio_trigger *trig,
31 struct iio_dev *indio_dev)
32{
33 if (indio_dev->modes & INDIO_HARDWARE_TRIGGERED)
34 return 0;
35
36 return -EINVAL;
37}
38
39static const struct iio_trigger_ops stm32_lptim_trigger_ops = {
40 .owner = THIS_MODULE,
41 .validate_device = stm32_lptim_validate_device,
42};
43
44/**
45 * is_stm32_lptim_trigger
46 * @trig: trigger to be checked
47 *
48 * return true if the trigger is a valid STM32 IIO Low-Power Timer Trigger
49 * either return false
50 */
51bool is_stm32_lptim_trigger(struct iio_trigger *trig)
52{
53 return (trig->ops == &stm32_lptim_trigger_ops);
54}
55EXPORT_SYMBOL(is_stm32_lptim_trigger);
56
57static int stm32_lptim_setup_trig(struct stm32_lptim_trigger *priv)
58{
59 struct iio_trigger *trig;
60
61 trig = devm_iio_trigger_alloc(priv->dev, "%s", priv->trg);
62 if (!trig)
63 return -ENOMEM;
64
65 trig->dev.parent = priv->dev->parent;
66 trig->ops = &stm32_lptim_trigger_ops;
67 iio_trigger_set_drvdata(trig, priv);
68
69 return devm_iio_trigger_register(priv->dev, trig);
70}
71
72static int stm32_lptim_trigger_probe(struct platform_device *pdev)
73{
74 struct stm32_lptim_trigger *priv;
75 u32 index;
76 int ret;
77
78 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
79 if (!priv)
80 return -ENOMEM;
81
82 if (of_property_read_u32(pdev->dev.of_node, "reg", &index))
83 return -EINVAL;
84
85 if (index >= ARRAY_SIZE(stm32_lptim_triggers))
86 return -EINVAL;
87
88 priv->dev = &pdev->dev;
89 priv->trg = stm32_lptim_triggers[index];
90
91 ret = stm32_lptim_setup_trig(priv);
92 if (ret)
93 return ret;
94
95 platform_set_drvdata(pdev, priv);
96
97 return 0;
98}
99
100static const struct of_device_id stm32_lptim_trig_of_match[] = {
101 { .compatible = "st,stm32-lptimer-trigger", },
102 {},
103};
104MODULE_DEVICE_TABLE(of, stm32_lptim_trig_of_match);
105
106static struct platform_driver stm32_lptim_trigger_driver = {
107 .probe = stm32_lptim_trigger_probe,
108 .driver = {
109 .name = "stm32-lptimer-trigger",
110 .of_match_table = stm32_lptim_trig_of_match,
111 },
112};
113module_platform_driver(stm32_lptim_trigger_driver);
114
115MODULE_AUTHOR("Fabrice Gasnier <fabrice.gasnier@st.com>");
116MODULE_ALIAS("platform:stm32-lptimer-trigger");
117MODULE_DESCRIPTION("STMicroelectronics STM32 LPTIM trigger driver");
118MODULE_LICENSE("GPL v2");
diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
index 39e72b3219d8..f9f98ef1d98e 100644
--- a/drivers/input/keyboard/twl4030_keypad.c
+++ b/drivers/input/keyboard/twl4030_keypad.c
@@ -30,7 +30,7 @@
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
31#include <linux/input.h> 31#include <linux/input.h>
32#include <linux/platform_device.h> 32#include <linux/platform_device.h>
33#include <linux/i2c/twl.h> 33#include <linux/mfd/twl.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/of.h> 35#include <linux/of.h>
36 36
diff --git a/drivers/input/misc/dm355evm_keys.c b/drivers/input/misc/dm355evm_keys.c
index bab256ef32b9..c803db64a376 100644
--- a/drivers/input/misc/dm355evm_keys.c
+++ b/drivers/input/misc/dm355evm_keys.c
@@ -15,7 +15,7 @@
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17 17
18#include <linux/i2c/dm355evm_msp.h> 18#include <linux/mfd/dm355evm_msp.h>
19#include <linux/module.h> 19#include <linux/module.h>
20 20
21 21
diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c
index 1c13005b228f..b307cca17022 100644
--- a/drivers/input/misc/twl4030-pwrbutton.c
+++ b/drivers/input/misc/twl4030-pwrbutton.c
@@ -27,7 +27,7 @@
27#include <linux/input.h> 27#include <linux/input.h>
28#include <linux/interrupt.h> 28#include <linux/interrupt.h>
29#include <linux/platform_device.h> 29#include <linux/platform_device.h>
30#include <linux/i2c/twl.h> 30#include <linux/mfd/twl.h>
31 31
32#define PWR_PWRON_IRQ (1 << 0) 32#define PWR_PWRON_IRQ (1 << 0)
33 33
diff --git a/drivers/input/misc/twl4030-vibra.c b/drivers/input/misc/twl4030-vibra.c
index caa5a62c42fb..6c51d404874b 100644
--- a/drivers/input/misc/twl4030-vibra.c
+++ b/drivers/input/misc/twl4030-vibra.c
@@ -28,7 +28,7 @@
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/of.h> 29#include <linux/of.h>
30#include <linux/workqueue.h> 30#include <linux/workqueue.h>
31#include <linux/i2c/twl.h> 31#include <linux/mfd/twl.h>
32#include <linux/mfd/twl4030-audio.h> 32#include <linux/mfd/twl4030-audio.h>
33#include <linux/input.h> 33#include <linux/input.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c
index ebf69ff48ae2..c00a7c7f460a 100644
--- a/drivers/memory/atmel-ebi.c
+++ b/drivers/memory/atmel-ebi.c
@@ -51,6 +51,7 @@ struct atmel_ebi {
51 struct { 51 struct {
52 struct regmap *regmap; 52 struct regmap *regmap;
53 struct clk *clk; 53 struct clk *clk;
54 const struct atmel_hsmc_reg_layout *layout;
54 } smc; 55 } smc;
55 56
56 struct device *dev; 57 struct device *dev;
@@ -84,8 +85,8 @@ static void at91sam9_ebi_get_config(struct atmel_ebi_dev *ebid,
84static void sama5_ebi_get_config(struct atmel_ebi_dev *ebid, 85static void sama5_ebi_get_config(struct atmel_ebi_dev *ebid,
85 struct atmel_ebi_dev_config *conf) 86 struct atmel_ebi_dev_config *conf)
86{ 87{
87 atmel_hsmc_cs_conf_get(ebid->ebi->smc.regmap, conf->cs, 88 atmel_hsmc_cs_conf_get(ebid->ebi->smc.regmap, ebid->ebi->smc.layout,
88 &conf->smcconf); 89 conf->cs, &conf->smcconf);
89} 90}
90 91
91static const struct atmel_smc_timing_xlate timings_xlate_table[] = { 92static const struct atmel_smc_timing_xlate timings_xlate_table[] = {
@@ -287,8 +288,8 @@ static void at91sam9_ebi_apply_config(struct atmel_ebi_dev *ebid,
287static void sama5_ebi_apply_config(struct atmel_ebi_dev *ebid, 288static void sama5_ebi_apply_config(struct atmel_ebi_dev *ebid,
288 struct atmel_ebi_dev_config *conf) 289 struct atmel_ebi_dev_config *conf)
289{ 290{
290 atmel_hsmc_cs_conf_apply(ebid->ebi->smc.regmap, conf->cs, 291 atmel_hsmc_cs_conf_apply(ebid->ebi->smc.regmap, ebid->ebi->smc.layout,
291 &conf->smcconf); 292 conf->cs, &conf->smcconf);
292} 293}
293 294
294static int atmel_ebi_dev_setup(struct atmel_ebi *ebi, struct device_node *np, 295static int atmel_ebi_dev_setup(struct atmel_ebi *ebi, struct device_node *np,
@@ -527,6 +528,10 @@ static int atmel_ebi_probe(struct platform_device *pdev)
527 if (IS_ERR(ebi->smc.regmap)) 528 if (IS_ERR(ebi->smc.regmap))
528 return PTR_ERR(ebi->smc.regmap); 529 return PTR_ERR(ebi->smc.regmap);
529 530
531 ebi->smc.layout = atmel_hsmc_get_reg_layout(smc_np);
532 if (IS_ERR(ebi->smc.layout))
533 return PTR_ERR(ebi->smc.layout);
534
530 ebi->smc.clk = of_clk_get(smc_np, 0); 535 ebi->smc.clk = of_clk_get(smc_np, 0);
531 if (IS_ERR(ebi->smc.clk)) { 536 if (IS_ERR(ebi->smc.clk)) {
532 if (PTR_ERR(ebi->smc.clk) != -ENOENT) 537 if (PTR_ERR(ebi->smc.clk) != -ENOENT)
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 94ad2c1c3d90..fc5e4fef89d2 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -133,6 +133,20 @@ config MFD_BCM590XX
133 help 133 help
134 Support for the BCM590xx PMUs from Broadcom 134 Support for the BCM590xx PMUs from Broadcom
135 135
136config MFD_BD9571MWV
137 tristate "ROHM BD9571MWV PMIC"
138 select MFD_CORE
139 select REGMAP_I2C
140 select REGMAP_IRQ
141 depends on I2C
142 help
143 Support for the ROHM BD9571MWV PMIC, which contains single
144 voltage regulator, voltage sampling units, GPIO block and
145 watchdog block.
146
147 This driver can also be built as a module. If so, the module
148 will be called bd9571mwv.
149
136config MFD_AC100 150config MFD_AC100
137 tristate "X-Powers AC100" 151 tristate "X-Powers AC100"
138 select MFD_CORE 152 select MFD_CORE
@@ -453,12 +467,12 @@ config LPC_SCH
453 467
454config INTEL_SOC_PMIC 468config INTEL_SOC_PMIC
455 bool "Support for Crystal Cove PMIC" 469 bool "Support for Crystal Cove PMIC"
456 depends on HAS_IOMEM && I2C=y && GPIOLIB && COMMON_CLK 470 depends on ACPI && HAS_IOMEM && I2C=y && GPIOLIB && COMMON_CLK
457 depends on X86 || COMPILE_TEST 471 depends on X86 || COMPILE_TEST
458 select MFD_CORE 472 select MFD_CORE
459 select REGMAP_I2C 473 select REGMAP_I2C
460 select REGMAP_IRQ 474 select REGMAP_IRQ
461 select I2C_DESIGNWARE_PLATFORM if ACPI 475 select I2C_DESIGNWARE_PLATFORM
462 help 476 help
463 Select this option to enable support for Crystal Cove PMIC 477 Select this option to enable support for Crystal Cove PMIC
464 on some Intel SoC systems. The PMIC provides ADC, GPIO, 478 on some Intel SoC systems. The PMIC provides ADC, GPIO,
@@ -481,7 +495,7 @@ config INTEL_SOC_PMIC_BXTWC
481 on these systems. 495 on these systems.
482 496
483config INTEL_SOC_PMIC_CHTWC 497config INTEL_SOC_PMIC_CHTWC
484 tristate "Support for Intel Cherry Trail Whiskey Cove PMIC" 498 bool "Support for Intel Cherry Trail Whiskey Cove PMIC"
485 depends on ACPI && HAS_IOMEM && I2C=y && COMMON_CLK 499 depends on ACPI && HAS_IOMEM && I2C=y && COMMON_CLK
486 depends on X86 || COMPILE_TEST 500 depends on X86 || COMPILE_TEST
487 select MFD_CORE 501 select MFD_CORE
@@ -951,13 +965,13 @@ config MFD_RC5T583
951 different functionality of the device. 965 different functionality of the device.
952 966
953config MFD_RK808 967config MFD_RK808
954 tristate "Rockchip RK808/RK818 Power Management Chip" 968 tristate "Rockchip RK805/RK808/RK818 Power Management Chip"
955 depends on I2C && OF 969 depends on I2C && OF
956 select MFD_CORE 970 select MFD_CORE
957 select REGMAP_I2C 971 select REGMAP_I2C
958 select REGMAP_IRQ 972 select REGMAP_IRQ
959 help 973 help
960 If you say yes here you get support for the RK808 and RK818 974 If you say yes here you get support for the RK805, RK808 and RK818
961 Power Management chips. 975 Power Management chips.
962 This driver provides common support for accessing the device 976 This driver provides common support for accessing the device
963 through I2C interface. The device supports multiple sub-devices 977 through I2C interface. The device supports multiple sub-devices
@@ -1294,6 +1308,7 @@ config TPS6507X
1294 1308
1295config MFD_TPS65086 1309config MFD_TPS65086
1296 tristate "TI TPS65086 Power Management Integrated Chips (PMICs)" 1310 tristate "TI TPS65086 Power Management Integrated Chips (PMICs)"
1311 select MFD_CORE
1297 select REGMAP 1312 select REGMAP
1298 select REGMAP_IRQ 1313 select REGMAP_IRQ
1299 select REGMAP_I2C 1314 select REGMAP_I2C
@@ -1337,6 +1352,24 @@ config MFD_TPS65217
1337 This driver can also be built as a module. If so, the module 1352 This driver can also be built as a module. If so, the module
1338 will be called tps65217. 1353 will be called tps65217.
1339 1354
1355config MFD_TPS68470
1356 bool "TI TPS68470 Power Management / LED chips"
1357 depends on ACPI && I2C=y
1358 select MFD_CORE
1359 select REGMAP_I2C
1360 select I2C_DESIGNWARE_PLATFORM
1361 help
1362 If you say yes here you get support for the TPS68470 series of
1363 Power Management / LED chips.
1364
1365 These include voltage regulators, LEDs and other features
1366 that are often used in portable devices.
1367
1368 This option is a bool as it provides an ACPI operation
1369 region, which must be available before any of the devices
1370 using this are probed. This option also configures the
1371 designware-i2c driver to be built-in, for the same reason.
1372
1340config MFD_TI_LP873X 1373config MFD_TI_LP873X
1341 tristate "TI LP873X Power Management IC" 1374 tristate "TI LP873X Power Management IC"
1342 depends on I2C 1375 depends on I2C
@@ -1723,6 +1756,20 @@ config MFD_STW481X
1723 in various ST Microelectronics and ST-Ericsson embedded 1756 in various ST Microelectronics and ST-Ericsson embedded
1724 Nomadik series. 1757 Nomadik series.
1725 1758
1759config MFD_STM32_LPTIMER
1760 tristate "Support for STM32 Low-Power Timer"
1761 depends on (ARCH_STM32 && OF) || COMPILE_TEST
1762 select MFD_CORE
1763 select REGMAP
1764 select REGMAP_MMIO
1765 help
1766 Select this option to enable STM32 Low-Power Timer driver
1767 used for PWM, IIO Trigger, IIO Encoder and Counter. Shared
1768 resources are also dealt with here.
1769
1770 To compile this driver as a module, choose M here: the
1771 module will be called stm32-lptimer.
1772
1726config MFD_STM32_TIMERS 1773config MFD_STM32_TIMERS
1727 tristate "Support for STM32 Timers" 1774 tristate "Support for STM32 Timers"
1728 depends on (ARCH_STM32 && OF) || COMPILE_TEST 1775 depends on (ARCH_STM32 && OF) || COMPILE_TEST
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 080793b3fd0e..c3d0a1b39bb6 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_MFD_ACT8945A) += act8945a.o
10obj-$(CONFIG_MFD_SM501) += sm501.o 10obj-$(CONFIG_MFD_SM501) += sm501.o
11obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o 11obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o
12obj-$(CONFIG_MFD_BCM590XX) += bcm590xx.o 12obj-$(CONFIG_MFD_BCM590XX) += bcm590xx.o
13obj-$(CONFIG_MFD_BD9571MWV) += bd9571mwv.o
13cros_ec_core-objs := cros_ec.o 14cros_ec_core-objs := cros_ec.o
14cros_ec_core-$(CONFIG_ACPI) += cros_ec_acpi_gpe.o 15cros_ec_core-$(CONFIG_ACPI) += cros_ec_acpi_gpe.o
15obj-$(CONFIG_MFD_CROS_EC) += cros_ec_core.o 16obj-$(CONFIG_MFD_CROS_EC) += cros_ec_core.o
@@ -83,6 +84,7 @@ obj-$(CONFIG_MFD_TPS65910) += tps65910.o
83obj-$(CONFIG_MFD_TPS65912) += tps65912-core.o 84obj-$(CONFIG_MFD_TPS65912) += tps65912-core.o
84obj-$(CONFIG_MFD_TPS65912_I2C) += tps65912-i2c.o 85obj-$(CONFIG_MFD_TPS65912_I2C) += tps65912-i2c.o
85obj-$(CONFIG_MFD_TPS65912_SPI) += tps65912-spi.o 86obj-$(CONFIG_MFD_TPS65912_SPI) += tps65912-spi.o
87obj-$(CONFIG_MFD_TPS68470) += tps68470.o
86obj-$(CONFIG_MFD_TPS80031) += tps80031.o 88obj-$(CONFIG_MFD_TPS80031) += tps80031.o
87obj-$(CONFIG_MENELAUS) += menelaus.o 89obj-$(CONFIG_MENELAUS) += menelaus.o
88 90
@@ -221,5 +223,6 @@ obj-$(CONFIG_MFD_MT6397) += mt6397-core.o
221obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o 223obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o
222obj-$(CONFIG_MFD_SUN4I_GPADC) += sun4i-gpadc.o 224obj-$(CONFIG_MFD_SUN4I_GPADC) += sun4i-gpadc.o
223 225
226obj-$(CONFIG_MFD_STM32_LPTIMER) += stm32-lptimer.o
224obj-$(CONFIG_MFD_STM32_TIMERS) += stm32-timers.o 227obj-$(CONFIG_MFD_STM32_TIMERS) += stm32-timers.o
225obj-$(CONFIG_MFD_MXS_LRADC) += mxs-lradc.o 228obj-$(CONFIG_MFD_MXS_LRADC) += mxs-lradc.o
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index 8511c068a610..30d09d177171 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -1059,15 +1059,15 @@ static struct attribute *ab9540_sysfs_entries[] = {
1059 NULL, 1059 NULL,
1060}; 1060};
1061 1061
1062static struct attribute_group ab8500_attr_group = { 1062static const struct attribute_group ab8500_attr_group = {
1063 .attrs = ab8500_sysfs_entries, 1063 .attrs = ab8500_sysfs_entries,
1064}; 1064};
1065 1065
1066static struct attribute_group ab8505_attr_group = { 1066static const struct attribute_group ab8505_attr_group = {
1067 .attrs = ab8505_sysfs_entries, 1067 .attrs = ab8505_sysfs_entries,
1068}; 1068};
1069 1069
1070static struct attribute_group ab9540_attr_group = { 1070static const struct attribute_group ab9540_attr_group = {
1071 .attrs = ab9540_sysfs_entries, 1071 .attrs = ab9540_sysfs_entries,
1072}; 1072};
1073 1073
diff --git a/drivers/mfd/atmel-smc.c b/drivers/mfd/atmel-smc.c
index 20cc0ea470fa..7d77948567d7 100644
--- a/drivers/mfd/atmel-smc.c
+++ b/drivers/mfd/atmel-smc.c
@@ -258,19 +258,21 @@ EXPORT_SYMBOL_GPL(atmel_smc_cs_conf_apply);
258 * atmel_hsmc_cs_conf_apply - apply an SMC CS conf 258 * atmel_hsmc_cs_conf_apply - apply an SMC CS conf
259 * @regmap: the HSMC regmap 259 * @regmap: the HSMC regmap
260 * @cs: the CS id 260 * @cs: the CS id
261 * @layout: the layout of registers
261 * @conf the SMC CS conf to apply 262 * @conf the SMC CS conf to apply
262 * 263 *
263 * Applies an SMC CS configuration. 264 * Applies an SMC CS configuration.
264 * Only valid on post-sama5 SoCs. 265 * Only valid on post-sama5 SoCs.
265 */ 266 */
266void atmel_hsmc_cs_conf_apply(struct regmap *regmap, int cs, 267void atmel_hsmc_cs_conf_apply(struct regmap *regmap,
267 const struct atmel_smc_cs_conf *conf) 268 const struct atmel_hsmc_reg_layout *layout,
269 int cs, const struct atmel_smc_cs_conf *conf)
268{ 270{
269 regmap_write(regmap, ATMEL_HSMC_SETUP(cs), conf->setup); 271 regmap_write(regmap, ATMEL_HSMC_SETUP(layout, cs), conf->setup);
270 regmap_write(regmap, ATMEL_HSMC_PULSE(cs), conf->pulse); 272 regmap_write(regmap, ATMEL_HSMC_PULSE(layout, cs), conf->pulse);
271 regmap_write(regmap, ATMEL_HSMC_CYCLE(cs), conf->cycle); 273 regmap_write(regmap, ATMEL_HSMC_CYCLE(layout, cs), conf->cycle);
272 regmap_write(regmap, ATMEL_HSMC_TIMINGS(cs), conf->timings); 274 regmap_write(regmap, ATMEL_HSMC_TIMINGS(layout, cs), conf->timings);
273 regmap_write(regmap, ATMEL_HSMC_MODE(cs), conf->mode); 275 regmap_write(regmap, ATMEL_HSMC_MODE(layout, cs), conf->mode);
274} 276}
275EXPORT_SYMBOL_GPL(atmel_hsmc_cs_conf_apply); 277EXPORT_SYMBOL_GPL(atmel_hsmc_cs_conf_apply);
276 278
@@ -297,18 +299,55 @@ EXPORT_SYMBOL_GPL(atmel_smc_cs_conf_get);
297 * atmel_hsmc_cs_conf_get - retrieve the current SMC CS conf 299 * atmel_hsmc_cs_conf_get - retrieve the current SMC CS conf
298 * @regmap: the HSMC regmap 300 * @regmap: the HSMC regmap
299 * @cs: the CS id 301 * @cs: the CS id
302 * @layout: the layout of registers
300 * @conf: the SMC CS conf object to store the current conf 303 * @conf: the SMC CS conf object to store the current conf
301 * 304 *
302 * Retrieve the SMC CS configuration. 305 * Retrieve the SMC CS configuration.
303 * Only valid on post-sama5 SoCs. 306 * Only valid on post-sama5 SoCs.
304 */ 307 */
305void atmel_hsmc_cs_conf_get(struct regmap *regmap, int cs, 308void atmel_hsmc_cs_conf_get(struct regmap *regmap,
306 struct atmel_smc_cs_conf *conf) 309 const struct atmel_hsmc_reg_layout *layout,
310 int cs, struct atmel_smc_cs_conf *conf)
307{ 311{
308 regmap_read(regmap, ATMEL_HSMC_SETUP(cs), &conf->setup); 312 regmap_read(regmap, ATMEL_HSMC_SETUP(layout, cs), &conf->setup);
309 regmap_read(regmap, ATMEL_HSMC_PULSE(cs), &conf->pulse); 313 regmap_read(regmap, ATMEL_HSMC_PULSE(layout, cs), &conf->pulse);
310 regmap_read(regmap, ATMEL_HSMC_CYCLE(cs), &conf->cycle); 314 regmap_read(regmap, ATMEL_HSMC_CYCLE(layout, cs), &conf->cycle);
311 regmap_read(regmap, ATMEL_HSMC_TIMINGS(cs), &conf->timings); 315 regmap_read(regmap, ATMEL_HSMC_TIMINGS(layout, cs), &conf->timings);
312 regmap_read(regmap, ATMEL_HSMC_MODE(cs), &conf->mode); 316 regmap_read(regmap, ATMEL_HSMC_MODE(layout, cs), &conf->mode);
313} 317}
314EXPORT_SYMBOL_GPL(atmel_hsmc_cs_conf_get); 318EXPORT_SYMBOL_GPL(atmel_hsmc_cs_conf_get);
319
320static const struct atmel_hsmc_reg_layout sama5d3_reg_layout = {
321 .timing_regs_offset = 0x600,
322};
323
324static const struct atmel_hsmc_reg_layout sama5d2_reg_layout = {
325 .timing_regs_offset = 0x700,
326};
327
328static const struct of_device_id atmel_smc_ids[] = {
329 { .compatible = "atmel,at91sam9260-smc", .data = NULL },
330 { .compatible = "atmel,sama5d3-smc", .data = &sama5d3_reg_layout },
331 { .compatible = "atmel,sama5d2-smc", .data = &sama5d2_reg_layout },
332 { /* sentinel */ },
333};
334
335/**
336 * atmel_hsmc_get_reg_layout - retrieve the layout of HSMC registers
337 * @np: the HSMC regmap
338 *
339 * Retrieve the layout of HSMC registers.
340 *
341 * Returns NULL in case of SMC, a struct atmel_hsmc_reg_layout pointer
342 * in HSMC case, otherwise ERR_PTR(-EINVAL).
343 */
344const struct atmel_hsmc_reg_layout *
345atmel_hsmc_get_reg_layout(struct device_node *np)
346{
347 const struct of_device_id *match;
348
349 match = of_match_node(atmel_smc_ids, np);
350
351 return match ? match->data : ERR_PTR(-EINVAL);
352}
353EXPORT_SYMBOL_GPL(atmel_hsmc_get_reg_layout);
diff --git a/drivers/mfd/axp20x-rsb.c b/drivers/mfd/axp20x-rsb.c
index fd5c7267b136..7ddbd9e8dd03 100644
--- a/drivers/mfd/axp20x-rsb.c
+++ b/drivers/mfd/axp20x-rsb.c
@@ -64,6 +64,7 @@ static const struct of_device_id axp20x_rsb_of_match[] = {
64 { .compatible = "x-powers,axp803", .data = (void *)AXP803_ID }, 64 { .compatible = "x-powers,axp803", .data = (void *)AXP803_ID },
65 { .compatible = "x-powers,axp806", .data = (void *)AXP806_ID }, 65 { .compatible = "x-powers,axp806", .data = (void *)AXP806_ID },
66 { .compatible = "x-powers,axp809", .data = (void *)AXP809_ID }, 66 { .compatible = "x-powers,axp809", .data = (void *)AXP809_ID },
67 { .compatible = "x-powers,axp813", .data = (void *)AXP813_ID },
67 { }, 68 { },
68}; 69};
69MODULE_DEVICE_TABLE(of, axp20x_rsb_of_match); 70MODULE_DEVICE_TABLE(of, axp20x_rsb_of_match);
diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index 917b6ddc4f15..336de66ca408 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -44,6 +44,7 @@ static const char * const axp20x_model_names[] = {
44 "AXP803", 44 "AXP803",
45 "AXP806", 45 "AXP806",
46 "AXP809", 46 "AXP809",
47 "AXP813",
47}; 48};
48 49
49static const struct regmap_range axp152_writeable_ranges[] = { 50static const struct regmap_range axp152_writeable_ranges[] = {
@@ -676,7 +677,7 @@ static struct mfd_cell axp20x_cells[] = {
676 677
677static struct mfd_cell axp221_cells[] = { 678static struct mfd_cell axp221_cells[] = {
678 { 679 {
679 .name = "axp20x-pek", 680 .name = "axp221-pek",
680 .num_resources = ARRAY_SIZE(axp22x_pek_resources), 681 .num_resources = ARRAY_SIZE(axp22x_pek_resources),
681 .resources = axp22x_pek_resources, 682 .resources = axp22x_pek_resources,
682 }, { 683 }, {
@@ -701,7 +702,7 @@ static struct mfd_cell axp221_cells[] = {
701 702
702static struct mfd_cell axp223_cells[] = { 703static struct mfd_cell axp223_cells[] = {
703 { 704 {
704 .name = "axp20x-pek", 705 .name = "axp221-pek",
705 .num_resources = ARRAY_SIZE(axp22x_pek_resources), 706 .num_resources = ARRAY_SIZE(axp22x_pek_resources),
706 .resources = axp22x_pek_resources, 707 .resources = axp22x_pek_resources,
707 }, { 708 }, {
@@ -834,7 +835,7 @@ static struct mfd_cell axp288_cells[] = {
834 .resources = axp288_fuel_gauge_resources, 835 .resources = axp288_fuel_gauge_resources,
835 }, 836 },
836 { 837 {
837 .name = "axp20x-pek", 838 .name = "axp221-pek",
838 .num_resources = ARRAY_SIZE(axp288_power_button_resources), 839 .num_resources = ARRAY_SIZE(axp288_power_button_resources),
839 .resources = axp288_power_button_resources, 840 .resources = axp288_power_button_resources,
840 }, 841 },
@@ -845,7 +846,7 @@ static struct mfd_cell axp288_cells[] = {
845 846
846static struct mfd_cell axp803_cells[] = { 847static struct mfd_cell axp803_cells[] = {
847 { 848 {
848 .name = "axp20x-pek", 849 .name = "axp221-pek",
849 .num_resources = ARRAY_SIZE(axp803_pek_resources), 850 .num_resources = ARRAY_SIZE(axp803_pek_resources),
850 .resources = axp803_pek_resources, 851 .resources = axp803_pek_resources,
851 }, 852 },
@@ -861,7 +862,7 @@ static struct mfd_cell axp806_cells[] = {
861 862
862static struct mfd_cell axp809_cells[] = { 863static struct mfd_cell axp809_cells[] = {
863 { 864 {
864 .name = "axp20x-pek", 865 .name = "axp221-pek",
865 .num_resources = ARRAY_SIZE(axp809_pek_resources), 866 .num_resources = ARRAY_SIZE(axp809_pek_resources),
866 .resources = axp809_pek_resources, 867 .resources = axp809_pek_resources,
867 }, { 868 }, {
@@ -870,6 +871,14 @@ static struct mfd_cell axp809_cells[] = {
870 }, 871 },
871}; 872};
872 873
874static struct mfd_cell axp813_cells[] = {
875 {
876 .name = "axp221-pek",
877 .num_resources = ARRAY_SIZE(axp803_pek_resources),
878 .resources = axp803_pek_resources,
879 }
880};
881
873static struct axp20x_dev *axp20x_pm_power_off; 882static struct axp20x_dev *axp20x_pm_power_off;
874static void axp20x_power_off(void) 883static void axp20x_power_off(void)
875{ 884{
@@ -956,6 +965,19 @@ int axp20x_match_device(struct axp20x_dev *axp20x)
956 axp20x->regmap_cfg = &axp22x_regmap_config; 965 axp20x->regmap_cfg = &axp22x_regmap_config;
957 axp20x->regmap_irq_chip = &axp809_regmap_irq_chip; 966 axp20x->regmap_irq_chip = &axp809_regmap_irq_chip;
958 break; 967 break;
968 case AXP813_ID:
969 axp20x->nr_cells = ARRAY_SIZE(axp813_cells);
970 axp20x->cells = axp813_cells;
971 axp20x->regmap_cfg = &axp288_regmap_config;
972 /*
973 * The IRQ table given in the datasheet is incorrect.
974 * In IRQ enable/status registers 1, there are separate
975 * IRQs for ACIN and VBUS, instead of bits [7:5] being
976 * the same as bits [4:2]. So it shares the same IRQs
977 * as the AXP803, rather than the AXP288.
978 */
979 axp20x->regmap_irq_chip = &axp803_regmap_irq_chip;
980 break;
959 default: 981 default:
960 dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant); 982 dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant);
961 return -EINVAL; 983 return -EINVAL;
diff --git a/drivers/mfd/bd9571mwv.c b/drivers/mfd/bd9571mwv.c
new file mode 100644
index 000000000000..64e088dfe7b0
--- /dev/null
+++ b/drivers/mfd/bd9571mwv.c
@@ -0,0 +1,230 @@
1/*
2 * ROHM BD9571MWV-M MFD driver
3 *
4 * Copyright (C) 2017 Marek Vasut <marek.vasut+renesas@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether expressed or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License version 2 for more details.
14 *
15 * Based on the TPS65086 driver
16 */
17
18#include <linux/i2c.h>
19#include <linux/interrupt.h>
20#include <linux/mfd/core.h>
21#include <linux/module.h>
22
23#include <linux/mfd/bd9571mwv.h>
24
25static const struct mfd_cell bd9571mwv_cells[] = {
26 { .name = "bd9571mwv-regulator", },
27 { .name = "bd9571mwv-gpio", },
28};
29
30static const struct regmap_range bd9571mwv_readable_yes_ranges[] = {
31 regmap_reg_range(BD9571MWV_VENDOR_CODE, BD9571MWV_PRODUCT_REVISION),
32 regmap_reg_range(BD9571MWV_AVS_SET_MONI, BD9571MWV_AVS_DVFS_VID(3)),
33 regmap_reg_range(BD9571MWV_VD18_VID, BD9571MWV_VD33_VID),
34 regmap_reg_range(BD9571MWV_DVFS_VINIT, BD9571MWV_DVFS_VINIT),
35 regmap_reg_range(BD9571MWV_DVFS_SETVMAX, BD9571MWV_DVFS_MONIVDAC),
36 regmap_reg_range(BD9571MWV_GPIO_IN, BD9571MWV_GPIO_IN),
37 regmap_reg_range(BD9571MWV_GPIO_INT, BD9571MWV_GPIO_INTMASK),
38 regmap_reg_range(BD9571MWV_INT_INTREQ, BD9571MWV_INT_INTMASK),
39};
40
41static const struct regmap_access_table bd9571mwv_readable_table = {
42 .yes_ranges = bd9571mwv_readable_yes_ranges,
43 .n_yes_ranges = ARRAY_SIZE(bd9571mwv_readable_yes_ranges),
44};
45
46static const struct regmap_range bd9571mwv_writable_yes_ranges[] = {
47 regmap_reg_range(BD9571MWV_AVS_VD09_VID(0), BD9571MWV_AVS_VD09_VID(3)),
48 regmap_reg_range(BD9571MWV_DVFS_SETVID, BD9571MWV_DVFS_SETVID),
49 regmap_reg_range(BD9571MWV_GPIO_DIR, BD9571MWV_GPIO_OUT),
50 regmap_reg_range(BD9571MWV_GPIO_INT_SET, BD9571MWV_GPIO_INTMASK),
51 regmap_reg_range(BD9571MWV_INT_INTREQ, BD9571MWV_INT_INTMASK),
52};
53
54static const struct regmap_access_table bd9571mwv_writable_table = {
55 .yes_ranges = bd9571mwv_writable_yes_ranges,
56 .n_yes_ranges = ARRAY_SIZE(bd9571mwv_writable_yes_ranges),
57};
58
59static const struct regmap_range bd9571mwv_volatile_yes_ranges[] = {
60 regmap_reg_range(BD9571MWV_GPIO_IN, BD9571MWV_GPIO_IN),
61 regmap_reg_range(BD9571MWV_GPIO_INT, BD9571MWV_GPIO_INT),
62 regmap_reg_range(BD9571MWV_INT_INTREQ, BD9571MWV_INT_INTREQ),
63};
64
65static const struct regmap_access_table bd9571mwv_volatile_table = {
66 .yes_ranges = bd9571mwv_volatile_yes_ranges,
67 .n_yes_ranges = ARRAY_SIZE(bd9571mwv_volatile_yes_ranges),
68};
69
70static const struct regmap_config bd9571mwv_regmap_config = {
71 .reg_bits = 8,
72 .val_bits = 8,
73 .cache_type = REGCACHE_RBTREE,
74 .rd_table = &bd9571mwv_readable_table,
75 .wr_table = &bd9571mwv_writable_table,
76 .volatile_table = &bd9571mwv_volatile_table,
77 .max_register = 0xff,
78};
79
80static const struct regmap_irq bd9571mwv_irqs[] = {
81 REGMAP_IRQ_REG(BD9571MWV_IRQ_MD1, 0,
82 BD9571MWV_INT_INTREQ_MD1_INT),
83 REGMAP_IRQ_REG(BD9571MWV_IRQ_MD2_E1, 0,
84 BD9571MWV_INT_INTREQ_MD2_E1_INT),
85 REGMAP_IRQ_REG(BD9571MWV_IRQ_MD2_E2, 0,
86 BD9571MWV_INT_INTREQ_MD2_E2_INT),
87 REGMAP_IRQ_REG(BD9571MWV_IRQ_PROT_ERR, 0,
88 BD9571MWV_INT_INTREQ_PROT_ERR_INT),
89 REGMAP_IRQ_REG(BD9571MWV_IRQ_GP, 0,
90 BD9571MWV_INT_INTREQ_GP_INT),
91 REGMAP_IRQ_REG(BD9571MWV_IRQ_128H_OF, 0,
92 BD9571MWV_INT_INTREQ_128H_OF_INT),
93 REGMAP_IRQ_REG(BD9571MWV_IRQ_WDT_OF, 0,
94 BD9571MWV_INT_INTREQ_WDT_OF_INT),
95 REGMAP_IRQ_REG(BD9571MWV_IRQ_BKUP_TRG, 0,
96 BD9571MWV_INT_INTREQ_BKUP_TRG_INT),
97};
98
99static struct regmap_irq_chip bd9571mwv_irq_chip = {
100 .name = "bd9571mwv",
101 .status_base = BD9571MWV_INT_INTREQ,
102 .mask_base = BD9571MWV_INT_INTMASK,
103 .ack_base = BD9571MWV_INT_INTREQ,
104 .init_ack_masked = true,
105 .num_regs = 1,
106 .irqs = bd9571mwv_irqs,
107 .num_irqs = ARRAY_SIZE(bd9571mwv_irqs),
108};
109
110static int bd9571mwv_identify(struct bd9571mwv *bd)
111{
112 struct device *dev = bd->dev;
113 unsigned int value;
114 int ret;
115
116 ret = regmap_read(bd->regmap, BD9571MWV_VENDOR_CODE, &value);
117 if (ret) {
118 dev_err(dev, "Failed to read vendor code register (ret=%i)\n",
119 ret);
120 return ret;
121 }
122
123 if (value != BD9571MWV_VENDOR_CODE_VAL) {
124 dev_err(dev, "Invalid vendor code ID %02x (expected %02x)\n",
125 value, BD9571MWV_VENDOR_CODE_VAL);
126 return -EINVAL;
127 }
128
129 ret = regmap_read(bd->regmap, BD9571MWV_PRODUCT_CODE, &value);
130 if (ret) {
131 dev_err(dev, "Failed to read product code register (ret=%i)\n",
132 ret);
133 return ret;
134 }
135
136 if (value != BD9571MWV_PRODUCT_CODE_VAL) {
137 dev_err(dev, "Invalid product code ID %02x (expected %02x)\n",
138 value, BD9571MWV_PRODUCT_CODE_VAL);
139 return -EINVAL;
140 }
141
142 ret = regmap_read(bd->regmap, BD9571MWV_PRODUCT_REVISION, &value);
143 if (ret) {
144 dev_err(dev, "Failed to read revision register (ret=%i)\n",
145 ret);
146 return ret;
147 }
148
149 dev_info(dev, "Device: BD9571MWV rev. %d\n", value & 0xff);
150
151 return 0;
152}
153
154static int bd9571mwv_probe(struct i2c_client *client,
155 const struct i2c_device_id *ids)
156{
157 struct bd9571mwv *bd;
158 int ret;
159
160 bd = devm_kzalloc(&client->dev, sizeof(*bd), GFP_KERNEL);
161 if (!bd)
162 return -ENOMEM;
163
164 i2c_set_clientdata(client, bd);
165 bd->dev = &client->dev;
166 bd->irq = client->irq;
167
168 bd->regmap = devm_regmap_init_i2c(client, &bd9571mwv_regmap_config);
169 if (IS_ERR(bd->regmap)) {
170 dev_err(bd->dev, "Failed to initialize register map\n");
171 return PTR_ERR(bd->regmap);
172 }
173
174 ret = bd9571mwv_identify(bd);
175 if (ret)
176 return ret;
177
178 ret = regmap_add_irq_chip(bd->regmap, bd->irq, IRQF_ONESHOT, 0,
179 &bd9571mwv_irq_chip, &bd->irq_data);
180 if (ret) {
181 dev_err(bd->dev, "Failed to register IRQ chip\n");
182 return ret;
183 }
184
185 ret = mfd_add_devices(bd->dev, PLATFORM_DEVID_AUTO, bd9571mwv_cells,
186 ARRAY_SIZE(bd9571mwv_cells), NULL, 0,
187 regmap_irq_get_domain(bd->irq_data));
188 if (ret) {
189 regmap_del_irq_chip(bd->irq, bd->irq_data);
190 return ret;
191 }
192
193 return 0;
194}
195
196static int bd9571mwv_remove(struct i2c_client *client)
197{
198 struct bd9571mwv *bd = i2c_get_clientdata(client);
199
200 regmap_del_irq_chip(bd->irq, bd->irq_data);
201
202 return 0;
203}
204
205static const struct of_device_id bd9571mwv_of_match_table[] = {
206 { .compatible = "rohm,bd9571mwv", },
207 { /* sentinel */ }
208};
209MODULE_DEVICE_TABLE(of, bd9571mwv_of_match_table);
210
211static const struct i2c_device_id bd9571mwv_id_table[] = {
212 { "bd9571mwv", 0 },
213 { /* sentinel */ }
214};
215MODULE_DEVICE_TABLE(i2c, bd9571mwv_id_table);
216
217static struct i2c_driver bd9571mwv_driver = {
218 .driver = {
219 .name = "bd9571mwv",
220 .of_match_table = bd9571mwv_of_match_table,
221 },
222 .probe = bd9571mwv_probe,
223 .remove = bd9571mwv_remove,
224 .id_table = bd9571mwv_id_table,
225};
226module_i2c_driver(bd9571mwv_driver);
227
228MODULE_AUTHOR("Marek Vasut <marek.vasut+renesas@gmail.com>");
229MODULE_DESCRIPTION("BD9571MWV PMIC Driver");
230MODULE_LICENSE("GPL v2");
diff --git a/drivers/mfd/da9052-core.c b/drivers/mfd/da9052-core.c
index a23a3a1c7061..433add43a0a9 100644
--- a/drivers/mfd/da9052-core.c
+++ b/drivers/mfd/da9052-core.c
@@ -387,6 +387,8 @@ int da9052_adc_manual_read(struct da9052 *da9052, unsigned char channel)
387 387
388 mutex_lock(&da9052->auxadc_lock); 388 mutex_lock(&da9052->auxadc_lock);
389 389
390 reinit_completion(&da9052->done);
391
390 /* Channel gets activated on enabling the Conversion bit */ 392 /* Channel gets activated on enabling the Conversion bit */
391 mux_sel = chan_mux[channel] | DA9052_ADC_MAN_MAN_CONV; 393 mux_sel = chan_mux[channel] | DA9052_ADC_MAN_MAN_CONV;
392 394
diff --git a/drivers/mfd/da9052-spi.c b/drivers/mfd/da9052-spi.c
index b9ea1b27db64..abfb11818fdc 100644
--- a/drivers/mfd/da9052-spi.c
+++ b/drivers/mfd/da9052-spi.c
@@ -67,7 +67,7 @@ static int da9052_spi_remove(struct spi_device *spi)
67 return 0; 67 return 0;
68} 68}
69 69
70static struct spi_device_id da9052_spi_id[] = { 70static const struct spi_device_id da9052_spi_id[] = {
71 {"da9052", DA9052}, 71 {"da9052", DA9052},
72 {"da9053-aa", DA9053_AA}, 72 {"da9053-aa", DA9053_AA},
73 {"da9053-ba", DA9053_BA}, 73 {"da9053-ba", DA9053_BA},
diff --git a/drivers/mfd/da9055-i2c.c b/drivers/mfd/da9055-i2c.c
index b53e100f577c..8169a5c2fa20 100644
--- a/drivers/mfd/da9055-i2c.c
+++ b/drivers/mfd/da9055-i2c.c
@@ -62,7 +62,7 @@ static int da9055_i2c_remove(struct i2c_client *i2c)
62 * purposes separate). As a result there are specific DA9055 ids for PMIC 62 * purposes separate). As a result there are specific DA9055 ids for PMIC
63 * and CODEC, which must be different to operate together. 63 * and CODEC, which must be different to operate together.
64 */ 64 */
65static struct i2c_device_id da9055_i2c_id[] = { 65static const struct i2c_device_id da9055_i2c_id[] = {
66 {"da9055-pmic", 0}, 66 {"da9055-pmic", 0},
67 { } 67 { }
68}; 68};
diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c
index 86eca614507b..2a2756709f22 100644
--- a/drivers/mfd/dm355evm_msp.c
+++ b/drivers/mfd/dm355evm_msp.c
@@ -18,7 +18,7 @@
18#include <linux/gpio.h> 18#include <linux/gpio.h>
19#include <linux/leds.h> 19#include <linux/leds.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/i2c/dm355evm_msp.h> 21#include <linux/mfd/dm355evm_msp.h>
22 22
23 23
24/* 24/*
diff --git a/drivers/mfd/hi6421-pmic-core.c b/drivers/mfd/hi6421-pmic-core.c
index 3fd703fe3aba..6fb7ba272e09 100644
--- a/drivers/mfd/hi6421-pmic-core.c
+++ b/drivers/mfd/hi6421-pmic-core.c
@@ -1,40 +1,35 @@
1/* 1/*
2 * Device driver for Hi6421 IC 2 * Device driver for Hi6421 PMIC
3 * 3 *
4 * Copyright (c) <2011-2014> HiSilicon Technologies Co., Ltd. 4 * Copyright (c) <2011-2014> HiSilicon Technologies Co., Ltd.
5 * http://www.hisilicon.com 5 * http://www.hisilicon.com
6 * Copyright (c) <2013-2014> Linaro Ltd. 6 * Copyright (c) <2013-2017> Linaro Ltd.
7 * http://www.linaro.org 7 * http://www.linaro.org
8 * 8 *
9 * Author: Guodong Xu <guodong.xu@linaro.org> 9 * Author: Guodong Xu <guodong.xu@linaro.org>
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by 12 * it under the terms of the GNU General Public License version 2 as
13 * the Free Software Foundation; either version 2 of the License, or 13 * published by the Free Software Foundation.
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 */ 14 */
24 15
25#include <linux/device.h> 16#include <linux/device.h>
26#include <linux/err.h> 17#include <linux/err.h>
27#include <linux/mfd/core.h> 18#include <linux/mfd/core.h>
19#include <linux/mfd/hi6421-pmic.h>
28#include <linux/module.h> 20#include <linux/module.h>
29#include <linux/of.h> 21#include <linux/of_device.h>
30#include <linux/platform_device.h> 22#include <linux/platform_device.h>
31#include <linux/regmap.h> 23#include <linux/regmap.h>
32#include <linux/mfd/hi6421-pmic.h>
33 24
34static const struct mfd_cell hi6421_devs[] = { 25static const struct mfd_cell hi6421_devs[] = {
35 { .name = "hi6421-regulator", }, 26 { .name = "hi6421-regulator", },
36}; 27};
37 28
29static const struct mfd_cell hi6421v530_devs[] = {
30 { .name = "hi6421v530-regulator", },
31};
32
38static const struct regmap_config hi6421_regmap_config = { 33static const struct regmap_config hi6421_regmap_config = {
39 .reg_bits = 32, 34 .reg_bits = 32,
40 .reg_stride = 4, 35 .reg_stride = 4,
@@ -42,12 +37,33 @@ static const struct regmap_config hi6421_regmap_config = {
42 .max_register = HI6421_REG_TO_BUS_ADDR(HI6421_REG_MAX), 37 .max_register = HI6421_REG_TO_BUS_ADDR(HI6421_REG_MAX),
43}; 38};
44 39
40static const struct of_device_id of_hi6421_pmic_match[] = {
41 {
42 .compatible = "hisilicon,hi6421-pmic",
43 .data = (void *)HI6421
44 },
45 {
46 .compatible = "hisilicon,hi6421v530-pmic",
47 .data = (void *)HI6421_V530
48 },
49 { },
50};
51MODULE_DEVICE_TABLE(of, of_hi6421_pmic_match);
52
45static int hi6421_pmic_probe(struct platform_device *pdev) 53static int hi6421_pmic_probe(struct platform_device *pdev)
46{ 54{
47 struct hi6421_pmic *pmic; 55 struct hi6421_pmic *pmic;
48 struct resource *res; 56 struct resource *res;
57 const struct of_device_id *id;
58 const struct mfd_cell *subdevs;
59 enum hi6421_type type;
49 void __iomem *base; 60 void __iomem *base;
50 int ret; 61 int n_subdevs, ret;
62
63 id = of_match_device(of_hi6421_pmic_match, &pdev->dev);
64 if (!id)
65 return -EINVAL;
66 type = (enum hi6421_type)id->data;
51 67
52 pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL); 68 pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL);
53 if (!pmic) 69 if (!pmic)
@@ -61,41 +77,50 @@ static int hi6421_pmic_probe(struct platform_device *pdev)
61 pmic->regmap = devm_regmap_init_mmio_clk(&pdev->dev, NULL, base, 77 pmic->regmap = devm_regmap_init_mmio_clk(&pdev->dev, NULL, base,
62 &hi6421_regmap_config); 78 &hi6421_regmap_config);
63 if (IS_ERR(pmic->regmap)) { 79 if (IS_ERR(pmic->regmap)) {
64 dev_err(&pdev->dev, 80 dev_err(&pdev->dev, "Failed to initialise Regmap: %ld\n",
65 "regmap init failed: %ld\n", PTR_ERR(pmic->regmap)); 81 PTR_ERR(pmic->regmap));
66 return PTR_ERR(pmic->regmap); 82 return PTR_ERR(pmic->regmap);
67 } 83 }
68 84
69 /* set over-current protection debounce 8ms */ 85 platform_set_drvdata(pdev, pmic);
70 regmap_update_bits(pmic->regmap, HI6421_OCP_DEB_CTRL_REG, 86
87 switch (type) {
88 case HI6421:
89 /* set over-current protection debounce 8ms */
90 regmap_update_bits(pmic->regmap, HI6421_OCP_DEB_CTRL_REG,
71 (HI6421_OCP_DEB_SEL_MASK 91 (HI6421_OCP_DEB_SEL_MASK
72 | HI6421_OCP_EN_DEBOUNCE_MASK 92 | HI6421_OCP_EN_DEBOUNCE_MASK
73 | HI6421_OCP_AUTO_STOP_MASK), 93 | HI6421_OCP_AUTO_STOP_MASK),
74 (HI6421_OCP_DEB_SEL_8MS 94 (HI6421_OCP_DEB_SEL_8MS
75 | HI6421_OCP_EN_DEBOUNCE_ENABLE)); 95 | HI6421_OCP_EN_DEBOUNCE_ENABLE));
76 96
77 platform_set_drvdata(pdev, pmic); 97 subdevs = hi6421_devs;
98 n_subdevs = ARRAY_SIZE(hi6421_devs);
99 break;
100 case HI6421_V530:
101 subdevs = hi6421v530_devs;
102 n_subdevs = ARRAY_SIZE(hi6421v530_devs);
103 break;
104 default:
105 dev_err(&pdev->dev, "Unknown device type %d\n",
106 (unsigned int)type);
107 return -EINVAL;
108 }
78 109
79 ret = devm_mfd_add_devices(&pdev->dev, 0, hi6421_devs, 110 ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE,
80 ARRAY_SIZE(hi6421_devs), NULL, 0, NULL); 111 subdevs, n_subdevs, NULL, 0, NULL);
81 if (ret) { 112 if (ret) {
82 dev_err(&pdev->dev, "add mfd devices failed: %d\n", ret); 113 dev_err(&pdev->dev, "Failed to add child devices: %d\n", ret);
83 return ret; 114 return ret;
84 } 115 }
85 116
86 return 0; 117 return 0;
87} 118}
88 119
89static const struct of_device_id of_hi6421_pmic_match_tbl[] = {
90 { .compatible = "hisilicon,hi6421-pmic", },
91 { },
92};
93MODULE_DEVICE_TABLE(of, of_hi6421_pmic_match_tbl);
94
95static struct platform_driver hi6421_pmic_driver = { 120static struct platform_driver hi6421_pmic_driver = {
96 .driver = { 121 .driver = {
97 .name = "hi6421_pmic", 122 .name = "hi6421_pmic",
98 .of_match_table = of_hi6421_pmic_match_tbl, 123 .of_match_table = of_hi6421_pmic_match,
99 }, 124 },
100 .probe = hi6421_pmic_probe, 125 .probe = hi6421_pmic_probe,
101}; 126};
diff --git a/drivers/mfd/intel-lpss-pci.c b/drivers/mfd/intel-lpss-pci.c
index ad388bb056cd..d1c46de89eb4 100644
--- a/drivers/mfd/intel-lpss-pci.c
+++ b/drivers/mfd/intel-lpss-pci.c
@@ -221,6 +221,7 @@ static const struct pci_device_id intel_lpss_pci_ids[] = {
221 { PCI_VDEVICE(INTEL, 0xa12a), (kernel_ulong_t)&spt_info }, 221 { PCI_VDEVICE(INTEL, 0xa12a), (kernel_ulong_t)&spt_info },
222 { PCI_VDEVICE(INTEL, 0xa160), (kernel_ulong_t)&spt_i2c_info }, 222 { PCI_VDEVICE(INTEL, 0xa160), (kernel_ulong_t)&spt_i2c_info },
223 { PCI_VDEVICE(INTEL, 0xa161), (kernel_ulong_t)&spt_i2c_info }, 223 { PCI_VDEVICE(INTEL, 0xa161), (kernel_ulong_t)&spt_i2c_info },
224 { PCI_VDEVICE(INTEL, 0xa162), (kernel_ulong_t)&spt_i2c_info },
224 { PCI_VDEVICE(INTEL, 0xa166), (kernel_ulong_t)&spt_uart_info }, 225 { PCI_VDEVICE(INTEL, 0xa166), (kernel_ulong_t)&spt_uart_info },
225 /* KBL-H */ 226 /* KBL-H */
226 { PCI_VDEVICE(INTEL, 0xa2a7), (kernel_ulong_t)&spt_uart_info }, 227 { PCI_VDEVICE(INTEL, 0xa2a7), (kernel_ulong_t)&spt_uart_info },
diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c
index 70c646b0097d..0e0ab9bb1530 100644
--- a/drivers/mfd/intel-lpss.c
+++ b/drivers/mfd/intel-lpss.c
@@ -502,6 +502,14 @@ int intel_lpss_suspend(struct device *dev)
502 for (i = 0; i < LPSS_PRIV_REG_COUNT; i++) 502 for (i = 0; i < LPSS_PRIV_REG_COUNT; i++)
503 lpss->priv_ctx[i] = readl(lpss->priv + i * 4); 503 lpss->priv_ctx[i] = readl(lpss->priv + i * 4);
504 504
505 /*
506 * If the device type is not UART, then put the controller into
507 * reset. UART cannot be put into reset since S3/S0ix fail when
508 * no_console_suspend flag is enabled.
509 */
510 if (lpss->type != LPSS_DEV_UART)
511 writel(0, lpss->priv + LPSS_PRIV_RESETS);
512
505 return 0; 513 return 0;
506} 514}
507EXPORT_SYMBOL_GPL(intel_lpss_suspend); 515EXPORT_SYMBOL_GPL(intel_lpss_suspend);
diff --git a/drivers/mfd/intel_soc_pmic_core.c b/drivers/mfd/intel_soc_pmic_core.c
index 13737be6df35..36adf9e8153e 100644
--- a/drivers/mfd/intel_soc_pmic_core.c
+++ b/drivers/mfd/intel_soc_pmic_core.c
@@ -16,6 +16,7 @@
16 * Author: Zhu, Lejun <lejun.zhu@linux.intel.com> 16 * Author: Zhu, Lejun <lejun.zhu@linux.intel.com>
17 */ 17 */
18 18
19#include <linux/acpi.h>
19#include <linux/module.h> 20#include <linux/module.h>
20#include <linux/mfd/core.h> 21#include <linux/mfd/core.h>
21#include <linux/i2c.h> 22#include <linux/i2c.h>
@@ -28,6 +29,10 @@
28#include <linux/pwm.h> 29#include <linux/pwm.h>
29#include "intel_soc_pmic_core.h" 30#include "intel_soc_pmic_core.h"
30 31
32/* Crystal Cove PMIC shares same ACPI ID between different platforms */
33#define BYT_CRC_HRV 2
34#define CHT_CRC_HRV 3
35
31/* Lookup table for the Panel Enable/Disable line as GPIO signals */ 36/* Lookup table for the Panel Enable/Disable line as GPIO signals */
32static struct gpiod_lookup_table panel_gpio_table = { 37static struct gpiod_lookup_table panel_gpio_table = {
33 /* Intel GFX is consumer */ 38 /* Intel GFX is consumer */
@@ -48,16 +53,33 @@ static int intel_soc_pmic_i2c_probe(struct i2c_client *i2c,
48 const struct i2c_device_id *i2c_id) 53 const struct i2c_device_id *i2c_id)
49{ 54{
50 struct device *dev = &i2c->dev; 55 struct device *dev = &i2c->dev;
51 const struct acpi_device_id *id;
52 struct intel_soc_pmic_config *config; 56 struct intel_soc_pmic_config *config;
53 struct intel_soc_pmic *pmic; 57 struct intel_soc_pmic *pmic;
58 unsigned long long hrv;
59 acpi_status status;
54 int ret; 60 int ret;
55 61
56 id = acpi_match_device(dev->driver->acpi_match_table, dev); 62 /*
57 if (!id || !id->driver_data) 63 * There are 2 different Crystal Cove PMICs a Bay Trail and Cherry
64 * Trail version, use _HRV to differentiate between the 2.
65 */
66 status = acpi_evaluate_integer(ACPI_HANDLE(dev), "_HRV", NULL, &hrv);
67 if (ACPI_FAILURE(status)) {
68 dev_err(dev, "Failed to get PMIC hardware revision\n");
58 return -ENODEV; 69 return -ENODEV;
59 70 }
60 config = (struct intel_soc_pmic_config *)id->driver_data; 71
72 switch (hrv) {
73 case BYT_CRC_HRV:
74 config = &intel_soc_pmic_config_byt_crc;
75 break;
76 case CHT_CRC_HRV:
77 config = &intel_soc_pmic_config_cht_crc;
78 break;
79 default:
80 dev_warn(dev, "Unknown hardware rev %llu, assuming BYT\n", hrv);
81 config = &intel_soc_pmic_config_byt_crc;
82 }
61 83
62 pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL); 84 pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL);
63 if (!pmic) 85 if (!pmic)
@@ -157,7 +179,7 @@ MODULE_DEVICE_TABLE(i2c, intel_soc_pmic_i2c_id);
157 179
158#if defined(CONFIG_ACPI) 180#if defined(CONFIG_ACPI)
159static const struct acpi_device_id intel_soc_pmic_acpi_match[] = { 181static const struct acpi_device_id intel_soc_pmic_acpi_match[] = {
160 {"INT33FD", (kernel_ulong_t)&intel_soc_pmic_config_crc}, 182 { "INT33FD" },
161 { }, 183 { },
162}; 184};
163MODULE_DEVICE_TABLE(acpi, intel_soc_pmic_acpi_match); 185MODULE_DEVICE_TABLE(acpi, intel_soc_pmic_acpi_match);
diff --git a/drivers/mfd/intel_soc_pmic_core.h b/drivers/mfd/intel_soc_pmic_core.h
index ff2464bc172f..90a1416d4dac 100644
--- a/drivers/mfd/intel_soc_pmic_core.h
+++ b/drivers/mfd/intel_soc_pmic_core.h
@@ -27,6 +27,7 @@ struct intel_soc_pmic_config {
27 const struct regmap_irq_chip *irq_chip; 27 const struct regmap_irq_chip *irq_chip;
28}; 28};
29 29
30extern struct intel_soc_pmic_config intel_soc_pmic_config_crc; 30extern struct intel_soc_pmic_config intel_soc_pmic_config_byt_crc;
31extern struct intel_soc_pmic_config intel_soc_pmic_config_cht_crc;
31 32
32#endif /* __INTEL_SOC_PMIC_CORE_H__ */ 33#endif /* __INTEL_SOC_PMIC_CORE_H__ */
diff --git a/drivers/mfd/intel_soc_pmic_crc.c b/drivers/mfd/intel_soc_pmic_crc.c
index 4a7494872da2..6d19a6d0fb97 100644
--- a/drivers/mfd/intel_soc_pmic_crc.c
+++ b/drivers/mfd/intel_soc_pmic_crc.c
@@ -80,7 +80,7 @@ static struct resource bcu_resources[] = {
80 }, 80 },
81}; 81};
82 82
83static struct mfd_cell crystal_cove_dev[] = { 83static struct mfd_cell crystal_cove_byt_dev[] = {
84 { 84 {
85 .name = "crystal_cove_pwrsrc", 85 .name = "crystal_cove_pwrsrc",
86 .num_resources = ARRAY_SIZE(pwrsrc_resources), 86 .num_resources = ARRAY_SIZE(pwrsrc_resources),
@@ -114,6 +114,17 @@ static struct mfd_cell crystal_cove_dev[] = {
114 }, 114 },
115}; 115};
116 116
117static struct mfd_cell crystal_cove_cht_dev[] = {
118 {
119 .name = "crystal_cove_gpio",
120 .num_resources = ARRAY_SIZE(gpio_resources),
121 .resources = gpio_resources,
122 },
123 {
124 .name = "crystal_cove_pwm",
125 },
126};
127
117static const struct regmap_config crystal_cove_regmap_config = { 128static const struct regmap_config crystal_cove_regmap_config = {
118 .reg_bits = 8, 129 .reg_bits = 8,
119 .val_bits = 8, 130 .val_bits = 8,
@@ -155,10 +166,18 @@ static const struct regmap_irq_chip crystal_cove_irq_chip = {
155 .mask_base = CRYSTAL_COVE_REG_MIRQLVL1, 166 .mask_base = CRYSTAL_COVE_REG_MIRQLVL1,
156}; 167};
157 168
158struct intel_soc_pmic_config intel_soc_pmic_config_crc = { 169struct intel_soc_pmic_config intel_soc_pmic_config_byt_crc = {
170 .irq_flags = IRQF_TRIGGER_RISING,
171 .cell_dev = crystal_cove_byt_dev,
172 .n_cell_devs = ARRAY_SIZE(crystal_cove_byt_dev),
173 .regmap_config = &crystal_cove_regmap_config,
174 .irq_chip = &crystal_cove_irq_chip,
175};
176
177struct intel_soc_pmic_config intel_soc_pmic_config_cht_crc = {
159 .irq_flags = IRQF_TRIGGER_RISING, 178 .irq_flags = IRQF_TRIGGER_RISING,
160 .cell_dev = crystal_cove_dev, 179 .cell_dev = crystal_cove_cht_dev,
161 .n_cell_devs = ARRAY_SIZE(crystal_cove_dev), 180 .n_cell_devs = ARRAY_SIZE(crystal_cove_cht_dev),
162 .regmap_config = &crystal_cove_regmap_config, 181 .regmap_config = &crystal_cove_regmap_config,
163 .irq_chip = &crystal_cove_irq_chip, 182 .irq_chip = &crystal_cove_irq_chip,
164}; 183};
diff --git a/drivers/mfd/lp87565.c b/drivers/mfd/lp87565.c
index 340ad0c63744..32d2a07d4354 100644
--- a/drivers/mfd/lp87565.c
+++ b/drivers/mfd/lp87565.c
@@ -73,10 +73,9 @@ static int lp87565_probe(struct i2c_client *client,
73 73
74 i2c_set_clientdata(client, lp87565); 74 i2c_set_clientdata(client, lp87565);
75 75
76 ret = mfd_add_devices(lp87565->dev, PLATFORM_DEVID_AUTO, lp87565_cells, 76 return devm_mfd_add_devices(lp87565->dev, PLATFORM_DEVID_AUTO,
77 ARRAY_SIZE(lp87565_cells), NULL, 0, NULL); 77 lp87565_cells, ARRAY_SIZE(lp87565_cells),
78 78 NULL, 0, NULL);
79 return ret;
80} 79}
81 80
82static const struct i2c_device_id lp87565_id_table[] = { 81static const struct i2c_device_id lp87565_id_table[] = {
diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c
index 773f1554d2f9..450ae36645aa 100644
--- a/drivers/mfd/lpc_ich.c
+++ b/drivers/mfd/lpc_ich.c
@@ -1119,17 +1119,7 @@ static int lpc_ich_init_spi(struct pci_dev *dev)
1119 res->start = spi_base + SPIBASE_LPT; 1119 res->start = spi_base + SPIBASE_LPT;
1120 res->end = res->start + SPIBASE_LPT_SZ - 1; 1120 res->end = res->start + SPIBASE_LPT_SZ - 1;
1121 1121
1122 /*
1123 * Try to make the flash chip writeable now by
1124 * setting BCR_WPD. It it fails we tell the driver
1125 * that it can only read the chip.
1126 */
1127 pci_read_config_dword(dev, BCR, &bcr); 1122 pci_read_config_dword(dev, BCR, &bcr);
1128 if (!(bcr & BCR_WPD)) {
1129 bcr |= BCR_WPD;
1130 pci_write_config_dword(dev, BCR, bcr);
1131 pci_read_config_dword(dev, BCR, &bcr);
1132 }
1133 info->writeable = !!(bcr & BCR_WPD); 1123 info->writeable = !!(bcr & BCR_WPD);
1134 } 1124 }
1135 break; 1125 break;
diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
index 5c80aea3211f..10063236132c 100644
--- a/drivers/mfd/max8925-i2c.c
+++ b/drivers/mfd/max8925-i2c.c
@@ -151,7 +151,7 @@ static int max8925_probe(struct i2c_client *client,
151 const struct i2c_device_id *id) 151 const struct i2c_device_id *id)
152{ 152{
153 struct max8925_platform_data *pdata = dev_get_platdata(&client->dev); 153 struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
154 static struct max8925_chip *chip; 154 struct max8925_chip *chip;
155 struct device_node *node = client->dev.of_node; 155 struct device_node *node = client->dev.of_node;
156 156
157 if (node && !pdata) { 157 if (node && !pdata) {
diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c
index 4c33b8063bc3..b1d3f70782d9 100644
--- a/drivers/mfd/max8998.c
+++ b/drivers/mfd/max8998.c
@@ -192,10 +192,8 @@ static int max8998_i2c_probe(struct i2c_client *i2c,
192 192
193 if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) { 193 if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) {
194 pdata = max8998_i2c_parse_dt_pdata(&i2c->dev); 194 pdata = max8998_i2c_parse_dt_pdata(&i2c->dev);
195 if (IS_ERR(pdata)) { 195 if (IS_ERR(pdata))
196 ret = PTR_ERR(pdata); 196 return PTR_ERR(pdata);
197 goto err;
198 }
199 } 197 }
200 198
201 i2c_set_clientdata(i2c, max8998); 199 i2c_set_clientdata(i2c, max8998);
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 6f5300b0eb31..44a5d66314c6 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -131,12 +131,12 @@ static inline u32 usbtll_read(void __iomem *base, u32 reg)
131 return readl_relaxed(base + reg); 131 return readl_relaxed(base + reg);
132} 132}
133 133
134static inline void usbtll_writeb(void __iomem *base, u8 reg, u8 val) 134static inline void usbtll_writeb(void __iomem *base, u32 reg, u8 val)
135{ 135{
136 writeb_relaxed(val, base + reg); 136 writeb_relaxed(val, base + reg);
137} 137}
138 138
139static inline u8 usbtll_readb(void __iomem *base, u8 reg) 139static inline u8 usbtll_readb(void __iomem *base, u32 reg)
140{ 140{
141 return readb_relaxed(base + reg); 141 return readb_relaxed(base + reg);
142} 142}
diff --git a/drivers/mfd/retu-mfd.c b/drivers/mfd/retu-mfd.c
index d4c114abeb75..e7d27b7861c1 100644
--- a/drivers/mfd/retu-mfd.c
+++ b/drivers/mfd/retu-mfd.c
@@ -302,15 +302,23 @@ static int retu_remove(struct i2c_client *i2c)
302} 302}
303 303
304static const struct i2c_device_id retu_id[] = { 304static const struct i2c_device_id retu_id[] = {
305 { "retu-mfd", 0 }, 305 { "retu", 0 },
306 { "tahvo-mfd", 0 }, 306 { "tahvo", 0 },
307 { } 307 { }
308}; 308};
309MODULE_DEVICE_TABLE(i2c, retu_id); 309MODULE_DEVICE_TABLE(i2c, retu_id);
310 310
311static const struct of_device_id retu_of_match[] = {
312 { .compatible = "nokia,retu" },
313 { .compatible = "nokia,tahvo" },
314 { }
315};
316MODULE_DEVICE_TABLE(of, retu_of_match);
317
311static struct i2c_driver retu_driver = { 318static struct i2c_driver retu_driver = {
312 .driver = { 319 .driver = {
313 .name = "retu-mfd", 320 .name = "retu-mfd",
321 .of_match_table = retu_of_match,
314 }, 322 },
315 .probe = retu_probe, 323 .probe = retu_probe,
316 .remove = retu_remove, 324 .remove = retu_remove,
diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index fd087cbb0bde..216fbf6adec9 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -70,6 +70,14 @@ static const struct regmap_config rk818_regmap_config = {
70 .volatile_reg = rk808_is_volatile_reg, 70 .volatile_reg = rk808_is_volatile_reg,
71}; 71};
72 72
73static const struct regmap_config rk805_regmap_config = {
74 .reg_bits = 8,
75 .val_bits = 8,
76 .max_register = RK805_OFF_SOURCE_REG,
77 .cache_type = REGCACHE_RBTREE,
78 .volatile_reg = rk808_is_volatile_reg,
79};
80
73static const struct regmap_config rk808_regmap_config = { 81static const struct regmap_config rk808_regmap_config = {
74 .reg_bits = 8, 82 .reg_bits = 8,
75 .val_bits = 8, 83 .val_bits = 8,
@@ -86,6 +94,34 @@ static struct resource rtc_resources[] = {
86 } 94 }
87}; 95};
88 96
97static struct resource rk805_key_resources[] = {
98 {
99 .start = RK805_IRQ_PWRON_FALL,
100 .end = RK805_IRQ_PWRON_FALL,
101 .flags = IORESOURCE_IRQ,
102 },
103 {
104 .start = RK805_IRQ_PWRON_RISE,
105 .end = RK805_IRQ_PWRON_RISE,
106 .flags = IORESOURCE_IRQ,
107 }
108};
109
110static const struct mfd_cell rk805s[] = {
111 { .name = "rk808-clkout", },
112 { .name = "rk808-regulator", },
113 { .name = "rk805-pinctrl", },
114 {
115 .name = "rk808-rtc",
116 .num_resources = ARRAY_SIZE(rtc_resources),
117 .resources = &rtc_resources[0],
118 },
119 { .name = "rk805-pwrkey",
120 .num_resources = ARRAY_SIZE(rk805_key_resources),
121 .resources = &rk805_key_resources[0],
122 },
123};
124
89static const struct mfd_cell rk808s[] = { 125static const struct mfd_cell rk808s[] = {
90 { .name = "rk808-clkout", }, 126 { .name = "rk808-clkout", },
91 { .name = "rk808-regulator", }, 127 { .name = "rk808-regulator", },
@@ -106,6 +142,20 @@ static const struct mfd_cell rk818s[] = {
106 }, 142 },
107}; 143};
108 144
145static const struct rk808_reg_data rk805_pre_init_reg[] = {
146 {RK805_BUCK1_CONFIG_REG, RK805_BUCK1_2_ILMAX_MASK,
147 RK805_BUCK1_2_ILMAX_4000MA},
148 {RK805_BUCK2_CONFIG_REG, RK805_BUCK1_2_ILMAX_MASK,
149 RK805_BUCK1_2_ILMAX_4000MA},
150 {RK805_BUCK3_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK,
151 RK805_BUCK3_ILMAX_3000MA},
152 {RK805_BUCK4_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK,
153 RK805_BUCK4_ILMAX_3500MA},
154 {RK805_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_400MA},
155 {RK805_GPIO_IO_POL_REG, SLP_SD_MSK, SLEEP_FUN},
156 {RK805_THERMAL_REG, TEMP_HOTDIE_MSK, TEMP115C},
157};
158
109static const struct rk808_reg_data rk808_pre_init_reg[] = { 159static const struct rk808_reg_data rk808_pre_init_reg[] = {
110 { RK808_BUCK3_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_150MA }, 160 { RK808_BUCK3_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_150MA },
111 { RK808_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_200MA }, 161 { RK808_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_200MA },
@@ -135,6 +185,41 @@ static const struct rk808_reg_data rk818_pre_init_reg[] = {
135 VB_LO_SEL_3500MV }, 185 VB_LO_SEL_3500MV },
136}; 186};
137 187
188static const struct regmap_irq rk805_irqs[] = {
189 [RK805_IRQ_PWRON_RISE] = {
190 .mask = RK805_IRQ_PWRON_RISE_MSK,
191 .reg_offset = 0,
192 },
193 [RK805_IRQ_VB_LOW] = {
194 .mask = RK805_IRQ_VB_LOW_MSK,
195 .reg_offset = 0,
196 },
197 [RK805_IRQ_PWRON] = {
198 .mask = RK805_IRQ_PWRON_MSK,
199 .reg_offset = 0,
200 },
201 [RK805_IRQ_PWRON_LP] = {
202 .mask = RK805_IRQ_PWRON_LP_MSK,
203 .reg_offset = 0,
204 },
205 [RK805_IRQ_HOTDIE] = {
206 .mask = RK805_IRQ_HOTDIE_MSK,
207 .reg_offset = 0,
208 },
209 [RK805_IRQ_RTC_ALARM] = {
210 .mask = RK805_IRQ_RTC_ALARM_MSK,
211 .reg_offset = 0,
212 },
213 [RK805_IRQ_RTC_PERIOD] = {
214 .mask = RK805_IRQ_RTC_PERIOD_MSK,
215 .reg_offset = 0,
216 },
217 [RK805_IRQ_PWRON_FALL] = {
218 .mask = RK805_IRQ_PWRON_FALL_MSK,
219 .reg_offset = 0,
220 },
221};
222
138static const struct regmap_irq rk808_irqs[] = { 223static const struct regmap_irq rk808_irqs[] = {
139 /* INT_STS */ 224 /* INT_STS */
140 [RK808_IRQ_VOUT_LO] = { 225 [RK808_IRQ_VOUT_LO] = {
@@ -247,6 +332,17 @@ static const struct regmap_irq rk818_irqs[] = {
247 }, 332 },
248}; 333};
249 334
335static struct regmap_irq_chip rk805_irq_chip = {
336 .name = "rk805",
337 .irqs = rk805_irqs,
338 .num_irqs = ARRAY_SIZE(rk805_irqs),
339 .num_regs = 1,
340 .status_base = RK805_INT_STS_REG,
341 .mask_base = RK805_INT_STS_MSK_REG,
342 .ack_base = RK805_INT_STS_REG,
343 .init_ack_masked = true,
344};
345
250static const struct regmap_irq_chip rk808_irq_chip = { 346static const struct regmap_irq_chip rk808_irq_chip = {
251 .name = "rk808", 347 .name = "rk808",
252 .irqs = rk808_irqs, 348 .irqs = rk808_irqs,
@@ -272,6 +368,25 @@ static const struct regmap_irq_chip rk818_irq_chip = {
272}; 368};
273 369
274static struct i2c_client *rk808_i2c_client; 370static struct i2c_client *rk808_i2c_client;
371
372static void rk805_device_shutdown(void)
373{
374 int ret;
375 struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
376
377 if (!rk808) {
378 dev_warn(&rk808_i2c_client->dev,
379 "have no rk805, so do nothing here\n");
380 return;
381 }
382
383 ret = regmap_update_bits(rk808->regmap,
384 RK805_DEV_CTRL_REG,
385 DEV_OFF, DEV_OFF);
386 if (ret)
387 dev_err(&rk808_i2c_client->dev, "power off error!\n");
388}
389
275static void rk808_device_shutdown(void) 390static void rk808_device_shutdown(void)
276{ 391{
277 int ret; 392 int ret;
@@ -309,6 +424,7 @@ static void rk818_device_shutdown(void)
309} 424}
310 425
311static const struct of_device_id rk808_of_match[] = { 426static const struct of_device_id rk808_of_match[] = {
427 { .compatible = "rockchip,rk805" },
312 { .compatible = "rockchip,rk808" }, 428 { .compatible = "rockchip,rk808" },
313 { .compatible = "rockchip,rk818" }, 429 { .compatible = "rockchip,rk818" },
314 { }, 430 { },
@@ -325,7 +441,7 @@ static int rk808_probe(struct i2c_client *client,
325 void (*pm_pwroff_fn)(void); 441 void (*pm_pwroff_fn)(void);
326 int nr_pre_init_regs; 442 int nr_pre_init_regs;
327 int nr_cells; 443 int nr_cells;
328 int pm_off = 0; 444 int pm_off = 0, msb, lsb;
329 int ret; 445 int ret;
330 int i; 446 int i;
331 447
@@ -333,16 +449,34 @@ static int rk808_probe(struct i2c_client *client,
333 if (!rk808) 449 if (!rk808)
334 return -ENOMEM; 450 return -ENOMEM;
335 451
336 rk808->variant = i2c_smbus_read_word_data(client, RK808_ID_MSB); 452 /* Read chip variant */
337 if (rk808->variant < 0) { 453 msb = i2c_smbus_read_byte_data(client, RK808_ID_MSB);
338 dev_err(&client->dev, "Failed to read the chip id at 0x%02x\n", 454 if (msb < 0) {
455 dev_err(&client->dev, "failed to read the chip id at 0x%x\n",
339 RK808_ID_MSB); 456 RK808_ID_MSB);
340 return rk808->variant; 457 return msb;
458 }
459
460 lsb = i2c_smbus_read_byte_data(client, RK808_ID_LSB);
461 if (lsb < 0) {
462 dev_err(&client->dev, "failed to read the chip id at 0x%x\n",
463 RK808_ID_LSB);
464 return lsb;
341 } 465 }
342 466
343 dev_dbg(&client->dev, "Chip id: 0x%x\n", (unsigned int)rk808->variant); 467 rk808->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
468 dev_info(&client->dev, "chip id: 0x%x\n", (unsigned int)rk808->variant);
344 469
345 switch (rk808->variant) { 470 switch (rk808->variant) {
471 case RK805_ID:
472 rk808->regmap_cfg = &rk805_regmap_config;
473 rk808->regmap_irq_chip = &rk805_irq_chip;
474 pre_init_reg = rk805_pre_init_reg;
475 nr_pre_init_regs = ARRAY_SIZE(rk805_pre_init_reg);
476 cells = rk805s;
477 nr_cells = ARRAY_SIZE(rk805s);
478 pm_pwroff_fn = rk805_device_shutdown;
479 break;
346 case RK808_ID: 480 case RK808_ID:
347 rk808->regmap_cfg = &rk808_regmap_config; 481 rk808->regmap_cfg = &rk808_regmap_config;
348 rk808->regmap_irq_chip = &rk808_irq_chip; 482 rk808->regmap_irq_chip = &rk808_irq_chip;
@@ -435,6 +569,7 @@ static int rk808_remove(struct i2c_client *client)
435} 569}
436 570
437static const struct i2c_device_id rk808_ids[] = { 571static const struct i2c_device_id rk808_ids[] = {
572 { "rk805" },
438 { "rk808" }, 573 { "rk808" },
439 { "rk818" }, 574 { "rk818" },
440 { }, 575 { },
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index a0ac89dfdf0f..3cf69e5c5703 100644
--- a/drivers/mfd/rtsx_pcr.c
+++ b/drivers/mfd/rtsx_pcr.c
@@ -644,7 +644,7 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
644{ 644{
645 int err, clk; 645 int err, clk;
646 u8 n, clk_divider, mcu_cnt, div; 646 u8 n, clk_divider, mcu_cnt, div;
647 u8 depth[] = { 647 static const u8 depth[] = {
648 [RTSX_SSC_DEPTH_4M] = SSC_DEPTH_4M, 648 [RTSX_SSC_DEPTH_4M] = SSC_DEPTH_4M,
649 [RTSX_SSC_DEPTH_2M] = SSC_DEPTH_2M, 649 [RTSX_SSC_DEPTH_2M] = SSC_DEPTH_2M,
650 [RTSX_SSC_DEPTH_1M] = SSC_DEPTH_1M, 650 [RTSX_SSC_DEPTH_1M] = SSC_DEPTH_1M,
@@ -768,7 +768,7 @@ EXPORT_SYMBOL_GPL(rtsx_pci_card_power_off);
768 768
769int rtsx_pci_card_exclusive_check(struct rtsx_pcr *pcr, int card) 769int rtsx_pci_card_exclusive_check(struct rtsx_pcr *pcr, int card)
770{ 770{
771 unsigned int cd_mask[] = { 771 static const unsigned int cd_mask[] = {
772 [RTSX_SD_CARD] = SD_EXIST, 772 [RTSX_SD_CARD] = SD_EXIST,
773 [RTSX_MS_CARD] = MS_EXIST 773 [RTSX_MS_CARD] = MS_EXIST
774 }; 774 };
diff --git a/drivers/mfd/stm32-lptimer.c b/drivers/mfd/stm32-lptimer.c
new file mode 100644
index 000000000000..075330a25f61
--- /dev/null
+++ b/drivers/mfd/stm32-lptimer.c
@@ -0,0 +1,107 @@
1/*
2 * STM32 Low-Power Timer parent driver.
3 *
4 * Copyright (C) STMicroelectronics 2017
5 *
6 * Author: Fabrice Gasnier <fabrice.gasnier@st.com>
7 *
8 * Inspired by Benjamin Gaignard's stm32-timers driver
9 *
10 * License terms: GNU General Public License (GPL), version 2
11 */
12
13#include <linux/mfd/stm32-lptimer.h>
14#include <linux/module.h>
15#include <linux/of_platform.h>
16
17#define STM32_LPTIM_MAX_REGISTER 0x3fc
18
19static const struct regmap_config stm32_lptimer_regmap_cfg = {
20 .reg_bits = 32,
21 .val_bits = 32,
22 .reg_stride = sizeof(u32),
23 .max_register = STM32_LPTIM_MAX_REGISTER,
24};
25
26static int stm32_lptimer_detect_encoder(struct stm32_lptimer *ddata)
27{
28 u32 val;
29 int ret;
30
31 /*
32 * Quadrature encoder mode bit can only be written and read back when
33 * Low-Power Timer supports it.
34 */
35 ret = regmap_update_bits(ddata->regmap, STM32_LPTIM_CFGR,
36 STM32_LPTIM_ENC, STM32_LPTIM_ENC);
37 if (ret)
38 return ret;
39
40 ret = regmap_read(ddata->regmap, STM32_LPTIM_CFGR, &val);
41 if (ret)
42 return ret;
43
44 ret = regmap_update_bits(ddata->regmap, STM32_LPTIM_CFGR,
45 STM32_LPTIM_ENC, 0);
46 if (ret)
47 return ret;
48
49 ddata->has_encoder = !!(val & STM32_LPTIM_ENC);
50
51 return 0;
52}
53
54static int stm32_lptimer_probe(struct platform_device *pdev)
55{
56 struct device *dev = &pdev->dev;
57 struct stm32_lptimer *ddata;
58 struct resource *res;
59 void __iomem *mmio;
60 int ret;
61
62 ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
63 if (!ddata)
64 return -ENOMEM;
65
66 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
67 mmio = devm_ioremap_resource(dev, res);
68 if (IS_ERR(mmio))
69 return PTR_ERR(mmio);
70
71 ddata->regmap = devm_regmap_init_mmio_clk(dev, "mux", mmio,
72 &stm32_lptimer_regmap_cfg);
73 if (IS_ERR(ddata->regmap))
74 return PTR_ERR(ddata->regmap);
75
76 ddata->clk = devm_clk_get(dev, NULL);
77 if (IS_ERR(ddata->clk))
78 return PTR_ERR(ddata->clk);
79
80 ret = stm32_lptimer_detect_encoder(ddata);
81 if (ret)
82 return ret;
83
84 platform_set_drvdata(pdev, ddata);
85
86 return devm_of_platform_populate(&pdev->dev);
87}
88
89static const struct of_device_id stm32_lptimer_of_match[] = {
90 { .compatible = "st,stm32-lptimer", },
91 {},
92};
93MODULE_DEVICE_TABLE(of, stm32_lptimer_of_match);
94
95static struct platform_driver stm32_lptimer_driver = {
96 .probe = stm32_lptimer_probe,
97 .driver = {
98 .name = "stm32-lptimer",
99 .of_match_table = stm32_lptimer_of_match,
100 },
101};
102module_platform_driver(stm32_lptimer_driver);
103
104MODULE_AUTHOR("Fabrice Gasnier <fabrice.gasnier@st.com>");
105MODULE_DESCRIPTION("STMicroelectronics STM32 Low-Power Timer");
106MODULE_ALIAS("platform:stm32-lptimer");
107MODULE_LICENSE("GPL v2");
diff --git a/drivers/mfd/t7l66xb.c b/drivers/mfd/t7l66xb.c
index 22c811396edc..43d8683266de 100644
--- a/drivers/mfd/t7l66xb.c
+++ b/drivers/mfd/t7l66xb.c
@@ -86,8 +86,11 @@ static int t7l66xb_mmc_enable(struct platform_device *mmc)
86 struct t7l66xb *t7l66xb = platform_get_drvdata(dev); 86 struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
87 unsigned long flags; 87 unsigned long flags;
88 u8 dev_ctl; 88 u8 dev_ctl;
89 int ret;
89 90
90 clk_prepare_enable(t7l66xb->clk32k); 91 ret = clk_prepare_enable(t7l66xb->clk32k);
92 if (ret)
93 return ret;
91 94
92 raw_spin_lock_irqsave(&t7l66xb->lock, flags); 95 raw_spin_lock_irqsave(&t7l66xb->lock, flags);
93 96
@@ -286,8 +289,12 @@ static int t7l66xb_resume(struct platform_device *dev)
286{ 289{
287 struct t7l66xb *t7l66xb = platform_get_drvdata(dev); 290 struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
288 struct t7l66xb_platform_data *pdata = dev_get_platdata(&dev->dev); 291 struct t7l66xb_platform_data *pdata = dev_get_platdata(&dev->dev);
292 int ret;
293
294 ret = clk_prepare_enable(t7l66xb->clk48m);
295 if (ret)
296 return ret;
289 297
290 clk_prepare_enable(t7l66xb->clk48m);
291 if (pdata && pdata->resume) 298 if (pdata && pdata->resume)
292 pdata->resume(dev); 299 pdata->resume(dev);
293 300
@@ -361,7 +368,9 @@ static int t7l66xb_probe(struct platform_device *dev)
361 goto err_ioremap; 368 goto err_ioremap;
362 } 369 }
363 370
364 clk_prepare_enable(t7l66xb->clk48m); 371 ret = clk_prepare_enable(t7l66xb->clk48m);
372 if (ret)
373 goto err_clk_enable;
365 374
366 if (pdata->enable) 375 if (pdata->enable)
367 pdata->enable(dev); 376 pdata->enable(dev);
@@ -386,6 +395,8 @@ static int t7l66xb_probe(struct platform_device *dev)
386 return 0; 395 return 0;
387 396
388 t7l66xb_detach_irq(dev); 397 t7l66xb_detach_irq(dev);
398 clk_disable_unprepare(t7l66xb->clk48m);
399err_clk_enable:
389 iounmap(t7l66xb->scr); 400 iounmap(t7l66xb->scr);
390err_ioremap: 401err_ioremap:
391 release_resource(&t7l66xb->rscr); 402 release_resource(&t7l66xb->rscr);
diff --git a/drivers/mfd/tps6105x.c b/drivers/mfd/tps6105x.c
index baa12ea666fb..187848c93779 100644
--- a/drivers/mfd/tps6105x.c
+++ b/drivers/mfd/tps6105x.c
@@ -173,9 +173,17 @@ static const struct i2c_device_id tps6105x_id[] = {
173}; 173};
174MODULE_DEVICE_TABLE(i2c, tps6105x_id); 174MODULE_DEVICE_TABLE(i2c, tps6105x_id);
175 175
176static const struct of_device_id tps6105x_of_match[] = {
177 { .compatible = "ti,tps61050" },
178 { .compatible = "ti,tps61052" },
179 { },
180};
181MODULE_DEVICE_TABLE(of, tps6105x_of_match);
182
176static struct i2c_driver tps6105x_driver = { 183static struct i2c_driver tps6105x_driver = {
177 .driver = { 184 .driver = {
178 .name = "tps6105x", 185 .name = "tps6105x",
186 .of_match_table = tps6105x_of_match,
179 }, 187 },
180 .probe = tps6105x_probe, 188 .probe = tps6105x_probe,
181 .remove = tps6105x_remove, 189 .remove = tps6105x_remove,
diff --git a/drivers/mfd/tps65010.c b/drivers/mfd/tps65010.c
index d829a6131f09..2ab67386b4ef 100644
--- a/drivers/mfd/tps65010.c
+++ b/drivers/mfd/tps65010.c
@@ -32,7 +32,7 @@
32#include <linux/mutex.h> 32#include <linux/mutex.h>
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34 34
35#include <linux/i2c/tps65010.h> 35#include <linux/mfd/tps65010.h>
36 36
37#include <linux/gpio/driver.h> 37#include <linux/gpio/driver.h>
38 38
diff --git a/drivers/mfd/tps68470.c b/drivers/mfd/tps68470.c
new file mode 100644
index 000000000000..189efaea054c
--- /dev/null
+++ b/drivers/mfd/tps68470.c
@@ -0,0 +1,106 @@
1/*
2 * TPS68470 chip Parent driver
3 *
4 * Copyright (C) 2017 Intel Corporation
5 *
6 * Authors:
7 * Rajmohan Mani <rajmohan.mani@intel.com>
8 * Tianshu Qiu <tian.shu.qiu@intel.com>
9 * Jian Xu Zheng <jian.xu.zheng@intel.com>
10 * Yuning Pu <yuning.pu@intel.com>
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation version 2.
15 *
16 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
17 * kind, whether express or implied; without even the implied warranty
18 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 */
21
22#include <linux/acpi.h>
23#include <linux/delay.h>
24#include <linux/i2c.h>
25#include <linux/init.h>
26#include <linux/mfd/core.h>
27#include <linux/mfd/tps68470.h>
28#include <linux/regmap.h>
29
30static const struct mfd_cell tps68470s[] = {
31 { .name = "tps68470-gpio" },
32 { .name = "tps68470_pmic_opregion" },
33};
34
35static const struct regmap_config tps68470_regmap_config = {
36 .reg_bits = 8,
37 .val_bits = 8,
38 .max_register = TPS68470_REG_MAX,
39};
40
41static int tps68470_chip_init(struct device *dev, struct regmap *regmap)
42{
43 unsigned int version;
44 int ret;
45
46 /* Force software reset */
47 ret = regmap_write(regmap, TPS68470_REG_RESET, TPS68470_REG_RESET_MASK);
48 if (ret)
49 return ret;
50
51 ret = regmap_read(regmap, TPS68470_REG_REVID, &version);
52 if (ret) {
53 dev_err(dev, "Failed to read revision register: %d\n", ret);
54 return ret;
55 }
56
57 dev_info(dev, "TPS68470 REVID: 0x%x\n", version);
58
59 return 0;
60}
61
62static int tps68470_probe(struct i2c_client *client)
63{
64 struct device *dev = &client->dev;
65 struct regmap *regmap;
66 int ret;
67
68 regmap = devm_regmap_init_i2c(client, &tps68470_regmap_config);
69 if (IS_ERR(regmap)) {
70 dev_err(dev, "devm_regmap_init_i2c Error %ld\n",
71 PTR_ERR(regmap));
72 return PTR_ERR(regmap);
73 }
74
75 i2c_set_clientdata(client, regmap);
76
77 ret = tps68470_chip_init(dev, regmap);
78 if (ret < 0) {
79 dev_err(dev, "TPS68470 Init Error %d\n", ret);
80 return ret;
81 }
82
83 ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE, tps68470s,
84 ARRAY_SIZE(tps68470s), NULL, 0, NULL);
85 if (ret < 0) {
86 dev_err(dev, "devm_mfd_add_devices failed: %d\n", ret);
87 return ret;
88 }
89
90 return 0;
91}
92
93static const struct acpi_device_id tps68470_acpi_ids[] = {
94 {"INT3472"},
95 {},
96};
97MODULE_DEVICE_TABLE(acpi, tps68470_acpi_ids);
98
99static struct i2c_driver tps68470_driver = {
100 .driver = {
101 .name = "tps68470",
102 .acpi_match_table = tps68470_acpi_ids,
103 },
104 .probe_new = tps68470_probe,
105};
106builtin_i2c_driver(tps68470_driver);
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index c64615dca2bd..d3133a371e27 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -44,7 +44,7 @@
44#include <linux/regulator/machine.h> 44#include <linux/regulator/machine.h>
45 45
46#include <linux/i2c.h> 46#include <linux/i2c.h>
47#include <linux/i2c/twl.h> 47#include <linux/mfd/twl.h>
48 48
49/* Register descriptions for audio */ 49/* Register descriptions for audio */
50#include <linux/mfd/twl4030-audio.h> 50#include <linux/mfd/twl4030-audio.h>
@@ -173,7 +173,7 @@ static struct twl_private *twl_priv;
173static struct twl_mapping twl4030_map[] = { 173static struct twl_mapping twl4030_map[] = {
174 /* 174 /*
175 * NOTE: don't change this table without updating the 175 * NOTE: don't change this table without updating the
176 * <linux/i2c/twl.h> defines for TWL4030_MODULE_* 176 * <linux/mfd/twl.h> defines for TWL4030_MODULE_*
177 * so they continue to match the order in this table. 177 * so they continue to match the order in this table.
178 */ 178 */
179 179
@@ -344,7 +344,7 @@ static const struct regmap_config twl4030_regmap_config[4] = {
344static struct twl_mapping twl6030_map[] = { 344static struct twl_mapping twl6030_map[] = {
345 /* 345 /*
346 * NOTE: don't change this table without updating the 346 * NOTE: don't change this table without updating the
347 * <linux/i2c/twl.h> defines for TWL4030_MODULE_* 347 * <linux/mfd/twl.h> defines for TWL4030_MODULE_*
348 * so they continue to match the order in this table. 348 * so they continue to match the order in this table.
349 */ 349 */
350 350
@@ -448,7 +448,7 @@ static struct regmap *twl_get_regmap(u8 mod_no)
448 * @reg: register address (just offset will do) 448 * @reg: register address (just offset will do)
449 * @num_bytes: number of bytes to transfer 449 * @num_bytes: number of bytes to transfer
450 * 450 *
451 * Returns the result of operation - 0 is success 451 * Returns 0 on success or else a negative error code.
452 */ 452 */
453int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) 453int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
454{ 454{
@@ -476,7 +476,7 @@ EXPORT_SYMBOL(twl_i2c_write);
476 * @reg: register address (just offset will do) 476 * @reg: register address (just offset will do)
477 * @num_bytes: number of bytes to transfer 477 * @num_bytes: number of bytes to transfer
478 * 478 *
479 * Returns result of operation - num_bytes is success else failure. 479 * Returns 0 on success or else a negative error code.
480 */ 480 */
481int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) 481int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
482{ 482{
diff --git a/drivers/mfd/twl4030-audio.c b/drivers/mfd/twl4030-audio.c
index 0a1606480023..da16bf45fab4 100644
--- a/drivers/mfd/twl4030-audio.c
+++ b/drivers/mfd/twl4030-audio.c
@@ -30,7 +30,7 @@
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/of.h> 31#include <linux/of.h>
32#include <linux/of_platform.h> 32#include <linux/of_platform.h>
33#include <linux/i2c/twl.h> 33#include <linux/mfd/twl.h>
34#include <linux/mfd/core.h> 34#include <linux/mfd/core.h>
35#include <linux/mfd/twl4030-audio.h> 35#include <linux/mfd/twl4030-audio.h>
36 36
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index 378c02d43bf7..b16c16f194fd 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -33,7 +33,7 @@
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/of.h> 34#include <linux/of.h>
35#include <linux/irqdomain.h> 35#include <linux/irqdomain.h>
36#include <linux/i2c/twl.h> 36#include <linux/mfd/twl.h>
37 37
38#include "twl-core.h" 38#include "twl-core.h"
39 39
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index f4b2c29d77e3..6b36932263ba 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -25,7 +25,7 @@
25 25
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/pm.h> 27#include <linux/pm.h>
28#include <linux/i2c/twl.h> 28#include <linux/mfd/twl.h>
29#include <linux/platform_device.h> 29#include <linux/platform_device.h>
30#include <linux/of.h> 30#include <linux/of.h>
31#include <linux/of_device.h> 31#include <linux/of_device.h>
diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
index 53574508a613..e3ec8dfa9f1e 100644
--- a/drivers/mfd/twl6030-irq.c
+++ b/drivers/mfd/twl6030-irq.c
@@ -35,7 +35,7 @@
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/irq.h> 36#include <linux/irq.h>
37#include <linux/kthread.h> 37#include <linux/kthread.h>
38#include <linux/i2c/twl.h> 38#include <linux/mfd/twl.h>
39#include <linux/platform_device.h> 39#include <linux/platform_device.h>
40#include <linux/suspend.h> 40#include <linux/suspend.h>
41#include <linux/of.h> 41#include <linux/of.h>
diff --git a/drivers/mtd/nand/atmel/nand-controller.c b/drivers/mtd/nand/atmel/nand-controller.c
index ceec21bd30c4..1913ce18fb1c 100644
--- a/drivers/mtd/nand/atmel/nand-controller.c
+++ b/drivers/mtd/nand/atmel/nand-controller.c
@@ -247,6 +247,7 @@ struct atmel_hsmc_nand_controller {
247 void __iomem *virt; 247 void __iomem *virt;
248 dma_addr_t dma; 248 dma_addr_t dma;
249 } sram; 249 } sram;
250 const struct atmel_hsmc_reg_layout *hsmc_layout;
250 struct regmap *io; 251 struct regmap *io;
251 struct atmel_nfc_op op; 252 struct atmel_nfc_op op;
252 struct completion complete; 253 struct completion complete;
@@ -1442,12 +1443,12 @@ static int atmel_hsmc_nand_setup_data_interface(struct atmel_nand *nand,
1442 int csline, 1443 int csline,
1443 const struct nand_data_interface *conf) 1444 const struct nand_data_interface *conf)
1444{ 1445{
1445 struct atmel_nand_controller *nc; 1446 struct atmel_hsmc_nand_controller *nc;
1446 struct atmel_smc_cs_conf smcconf; 1447 struct atmel_smc_cs_conf smcconf;
1447 struct atmel_nand_cs *cs; 1448 struct atmel_nand_cs *cs;
1448 int ret; 1449 int ret;
1449 1450
1450 nc = to_nand_controller(nand->base.controller); 1451 nc = to_hsmc_nand_controller(nand->base.controller);
1451 1452
1452 ret = atmel_smc_nand_prepare_smcconf(nand, conf, &smcconf); 1453 ret = atmel_smc_nand_prepare_smcconf(nand, conf, &smcconf);
1453 if (ret) 1454 if (ret)
@@ -1462,7 +1463,8 @@ static int atmel_hsmc_nand_setup_data_interface(struct atmel_nand *nand,
1462 if (cs->rb.type == ATMEL_NAND_NATIVE_RB) 1463 if (cs->rb.type == ATMEL_NAND_NATIVE_RB)
1463 cs->smcconf.timings |= ATMEL_HSMC_TIMINGS_RBNSEL(cs->rb.id); 1464 cs->smcconf.timings |= ATMEL_HSMC_TIMINGS_RBNSEL(cs->rb.id);
1464 1465
1465 atmel_hsmc_cs_conf_apply(nc->smc, cs->id, &cs->smcconf); 1466 atmel_hsmc_cs_conf_apply(nc->base.smc, nc->hsmc_layout, cs->id,
1467 &cs->smcconf);
1466 1468
1467 return 0; 1469 return 0;
1468} 1470}
@@ -2177,6 +2179,8 @@ atmel_hsmc_nand_controller_init(struct atmel_hsmc_nand_controller *nc)
2177 return -EINVAL; 2179 return -EINVAL;
2178 } 2180 }
2179 2181
2182 nc->hsmc_layout = atmel_hsmc_get_reg_layout(np);
2183
2180 nc->irq = of_irq_get(np, 0); 2184 nc->irq = of_irq_get(np, 0);
2181 of_node_put(np); 2185 of_node_put(np);
2182 if (nc->irq < 0) { 2186 if (nc->irq < 0) {
diff --git a/drivers/phy/ti/phy-twl4030-usb.c b/drivers/phy/ti/phy-twl4030-usb.c
index 0e9013868188..a44680d64f9b 100644
--- a/drivers/phy/ti/phy-twl4030-usb.c
+++ b/drivers/phy/ti/phy-twl4030-usb.c
@@ -36,7 +36,7 @@
36#include <linux/pm_runtime.h> 36#include <linux/pm_runtime.h>
37#include <linux/usb/musb.h> 37#include <linux/usb/musb.h>
38#include <linux/usb/ulpi.h> 38#include <linux/usb/ulpi.h>
39#include <linux/i2c/twl.h> 39#include <linux/mfd/twl.h>
40#include <linux/regulator/consumer.h> 40#include <linux/regulator/consumer.h>
41#include <linux/err.h> 41#include <linux/err.h>
42#include <linux/slab.h> 42#include <linux/slab.h>
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 34ad10873452..1778cf4f81c7 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -338,6 +338,15 @@ config PINCTRL_INGENIC
338 select GENERIC_PINMUX_FUNCTIONS 338 select GENERIC_PINMUX_FUNCTIONS
339 select REGMAP_MMIO 339 select REGMAP_MMIO
340 340
341config PINCTRL_RK805
342 tristate "Pinctrl and GPIO driver for RK805 PMIC"
343 depends on MFD_RK808
344 select GPIOLIB
345 select PINMUX
346 select GENERIC_PINCONF
347 help
348 This selects the pinctrl driver for RK805.
349
341source "drivers/pinctrl/aspeed/Kconfig" 350source "drivers/pinctrl/aspeed/Kconfig"
342source "drivers/pinctrl/bcm/Kconfig" 351source "drivers/pinctrl/bcm/Kconfig"
343source "drivers/pinctrl/berlin/Kconfig" 352source "drivers/pinctrl/berlin/Kconfig"
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index 4c44703ac97f..c16e27900dbb 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -43,6 +43,7 @@ obj-$(CONFIG_PINCTRL_TB10X) += pinctrl-tb10x.o
43obj-$(CONFIG_PINCTRL_ST) += pinctrl-st.o 43obj-$(CONFIG_PINCTRL_ST) += pinctrl-st.o
44obj-$(CONFIG_PINCTRL_ZYNQ) += pinctrl-zynq.o 44obj-$(CONFIG_PINCTRL_ZYNQ) += pinctrl-zynq.o
45obj-$(CONFIG_PINCTRL_INGENIC) += pinctrl-ingenic.o 45obj-$(CONFIG_PINCTRL_INGENIC) += pinctrl-ingenic.o
46obj-$(CONFIG_PINCTRL_RK805) += pinctrl-rk805.o
46 47
47obj-$(CONFIG_ARCH_ASPEED) += aspeed/ 48obj-$(CONFIG_ARCH_ASPEED) += aspeed/
48obj-y += bcm/ 49obj-y += bcm/
diff --git a/drivers/pinctrl/pinctrl-rk805.c b/drivers/pinctrl/pinctrl-rk805.c
new file mode 100644
index 000000000000..b0bfd3082a1b
--- /dev/null
+++ b/drivers/pinctrl/pinctrl-rk805.c
@@ -0,0 +1,493 @@
1/*
2 * Pinctrl driver for Rockchip RK805 PMIC
3 *
4 * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
5 *
6 * Author: Joseph Chen <chenjh@rock-chips.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * Based on the pinctrl-as3722 driver
14 */
15
16#include <linux/gpio/driver.h>
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/mfd/rk808.h>
20#include <linux/of.h>
21#include <linux/of_device.h>
22#include <linux/platform_device.h>
23#include <linux/pinctrl/consumer.h>
24#include <linux/pinctrl/machine.h>
25#include <linux/pinctrl/pinctrl.h>
26#include <linux/pinctrl/pinconf-generic.h>
27#include <linux/pinctrl/pinconf.h>
28#include <linux/pinctrl/pinmux.h>
29#include <linux/pm.h>
30#include <linux/slab.h>
31
32#include "core.h"
33#include "pinconf.h"
34#include "pinctrl-utils.h"
35
36struct rk805_pin_function {
37 const char *name;
38 const char *const *groups;
39 unsigned int ngroups;
40 int mux_option;
41};
42
43struct rk805_pin_group {
44 const char *name;
45 const unsigned int pins[1];
46 unsigned int npins;
47};
48
49/*
50 * @reg: gpio setting register;
51 * @fun_mask: functions select mask value, when set is gpio;
52 * @dir_mask: input or output mask value, when set is output, otherwise input;
53 * @val_mask: gpio set value, when set is level high, otherwise low;
54 *
55 * Different PMIC has different pin features, belowing 3 mask members are not
56 * all necessary for every PMIC. For example, RK805 has 2 pins that can be used
57 * as output only GPIOs, so func_mask and dir_mask are not needed. RK816 has 1
58 * pin that can be used as TS/GPIO, so fun_mask, dir_mask and val_mask are all
59 * necessary.
60 */
61struct rk805_pin_config {
62 u8 reg;
63 u8 fun_msk;
64 u8 dir_msk;
65 u8 val_msk;
66};
67
68struct rk805_pctrl_info {
69 struct rk808 *rk808;
70 struct device *dev;
71 struct pinctrl_dev *pctl;
72 struct gpio_chip gpio_chip;
73 struct pinctrl_desc pinctrl_desc;
74 const struct rk805_pin_function *functions;
75 unsigned int num_functions;
76 const struct rk805_pin_group *groups;
77 int num_pin_groups;
78 const struct pinctrl_pin_desc *pins;
79 unsigned int num_pins;
80 struct rk805_pin_config *pin_cfg;
81};
82
83enum rk805_pinmux_option {
84 RK805_PINMUX_GPIO,
85};
86
87enum {
88 RK805_GPIO0,
89 RK805_GPIO1,
90};
91
92static const char *const rk805_gpio_groups[] = {
93 "gpio0",
94 "gpio1",
95};
96
97/* RK805: 2 output only GPIOs */
98static const struct pinctrl_pin_desc rk805_pins_desc[] = {
99 PINCTRL_PIN(RK805_GPIO0, "gpio0"),
100 PINCTRL_PIN(RK805_GPIO1, "gpio1"),
101};
102
103static const struct rk805_pin_function rk805_pin_functions[] = {
104 {
105 .name = "gpio",
106 .groups = rk805_gpio_groups,
107 .ngroups = ARRAY_SIZE(rk805_gpio_groups),
108 .mux_option = RK805_PINMUX_GPIO,
109 },
110};
111
112static const struct rk805_pin_group rk805_pin_groups[] = {
113 {
114 .name = "gpio0",
115 .pins = { RK805_GPIO0 },
116 .npins = 1,
117 },
118 {
119 .name = "gpio1",
120 .pins = { RK805_GPIO1 },
121 .npins = 1,
122 },
123};
124
125#define RK805_GPIO0_VAL_MSK BIT(0)
126#define RK805_GPIO1_VAL_MSK BIT(1)
127
128static struct rk805_pin_config rk805_gpio_cfgs[] = {
129 {
130 .reg = RK805_OUT_REG,
131 .val_msk = RK805_GPIO0_VAL_MSK,
132 },
133 {
134 .reg = RK805_OUT_REG,
135 .val_msk = RK805_GPIO1_VAL_MSK,
136 },
137};
138
139/* generic gpio chip */
140static int rk805_gpio_get(struct gpio_chip *chip, unsigned int offset)
141{
142 struct rk805_pctrl_info *pci = gpiochip_get_data(chip);
143 int ret, val;
144
145 ret = regmap_read(pci->rk808->regmap, pci->pin_cfg[offset].reg, &val);
146 if (ret) {
147 dev_err(pci->dev, "get gpio%d value failed\n", offset);
148 return ret;
149 }
150
151 return !!(val & pci->pin_cfg[offset].val_msk);
152}
153
154static void rk805_gpio_set(struct gpio_chip *chip,
155 unsigned int offset,
156 int value)
157{
158 struct rk805_pctrl_info *pci = gpiochip_get_data(chip);
159 int ret;
160
161 ret = regmap_update_bits(pci->rk808->regmap,
162 pci->pin_cfg[offset].reg,
163 pci->pin_cfg[offset].val_msk,
164 value ? pci->pin_cfg[offset].val_msk : 0);
165 if (ret)
166 dev_err(pci->dev, "set gpio%d value %d failed\n",
167 offset, value);
168}
169
170static int rk805_gpio_direction_input(struct gpio_chip *chip,
171 unsigned int offset)
172{
173 return pinctrl_gpio_direction_input(chip->base + offset);
174}
175
176static int rk805_gpio_direction_output(struct gpio_chip *chip,
177 unsigned int offset, int value)
178{
179 rk805_gpio_set(chip, offset, value);
180 return pinctrl_gpio_direction_output(chip->base + offset);
181}
182
183static int rk805_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
184{
185 struct rk805_pctrl_info *pci = gpiochip_get_data(chip);
186 unsigned int val;
187 int ret;
188
189 /* default output*/
190 if (!pci->pin_cfg[offset].dir_msk)
191 return 0;
192
193 ret = regmap_read(pci->rk808->regmap,
194 pci->pin_cfg[offset].reg,
195 &val);
196 if (ret) {
197 dev_err(pci->dev, "get gpio%d direction failed\n", offset);
198 return ret;
199 }
200
201 return !(val & pci->pin_cfg[offset].dir_msk);
202}
203
204static struct gpio_chip rk805_gpio_chip = {
205 .label = "rk805-gpio",
206 .request = gpiochip_generic_request,
207 .free = gpiochip_generic_free,
208 .get_direction = rk805_gpio_get_direction,
209 .get = rk805_gpio_get,
210 .set = rk805_gpio_set,
211 .direction_input = rk805_gpio_direction_input,
212 .direction_output = rk805_gpio_direction_output,
213 .can_sleep = true,
214 .base = -1,
215 .owner = THIS_MODULE,
216};
217
218/* generic pinctrl */
219static int rk805_pinctrl_get_groups_count(struct pinctrl_dev *pctldev)
220{
221 struct rk805_pctrl_info *pci = pinctrl_dev_get_drvdata(pctldev);
222
223 return pci->num_pin_groups;
224}
225
226static const char *rk805_pinctrl_get_group_name(struct pinctrl_dev *pctldev,
227 unsigned int group)
228{
229 struct rk805_pctrl_info *pci = pinctrl_dev_get_drvdata(pctldev);
230
231 return pci->groups[group].name;
232}
233
234static int rk805_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
235 unsigned int group,
236 const unsigned int **pins,
237 unsigned int *num_pins)
238{
239 struct rk805_pctrl_info *pci = pinctrl_dev_get_drvdata(pctldev);
240
241 *pins = pci->groups[group].pins;
242 *num_pins = pci->groups[group].npins;
243
244 return 0;
245}
246
247static const struct pinctrl_ops rk805_pinctrl_ops = {
248 .get_groups_count = rk805_pinctrl_get_groups_count,
249 .get_group_name = rk805_pinctrl_get_group_name,
250 .get_group_pins = rk805_pinctrl_get_group_pins,
251 .dt_node_to_map = pinconf_generic_dt_node_to_map_pin,
252 .dt_free_map = pinctrl_utils_free_map,
253};
254
255static int rk805_pinctrl_get_funcs_count(struct pinctrl_dev *pctldev)
256{
257 struct rk805_pctrl_info *pci = pinctrl_dev_get_drvdata(pctldev);
258
259 return pci->num_functions;
260}
261
262static const char *rk805_pinctrl_get_func_name(struct pinctrl_dev *pctldev,
263 unsigned int function)
264{
265 struct rk805_pctrl_info *pci = pinctrl_dev_get_drvdata(pctldev);
266
267 return pci->functions[function].name;
268}
269
270static int rk805_pinctrl_get_func_groups(struct pinctrl_dev *pctldev,
271 unsigned int function,
272 const char *const **groups,
273 unsigned int *const num_groups)
274{
275 struct rk805_pctrl_info *pci = pinctrl_dev_get_drvdata(pctldev);
276
277 *groups = pci->functions[function].groups;
278 *num_groups = pci->functions[function].ngroups;
279
280 return 0;
281}
282
283static int _rk805_pinctrl_set_mux(struct pinctrl_dev *pctldev,
284 unsigned int offset,
285 int mux)
286{
287 struct rk805_pctrl_info *pci = pinctrl_dev_get_drvdata(pctldev);
288 int ret;
289
290 if (!pci->pin_cfg[offset].fun_msk)
291 return 0;
292
293 if (mux == RK805_PINMUX_GPIO) {
294 ret = regmap_update_bits(pci->rk808->regmap,
295 pci->pin_cfg[offset].reg,
296 pci->pin_cfg[offset].fun_msk,
297 pci->pin_cfg[offset].fun_msk);
298 if (ret) {
299 dev_err(pci->dev, "set gpio%d GPIO failed\n", offset);
300 return ret;
301 }
302 } else {
303 dev_err(pci->dev, "Couldn't find function mux %d\n", mux);
304 return -EINVAL;
305 }
306
307 return 0;
308}
309
310static int rk805_pinctrl_set_mux(struct pinctrl_dev *pctldev,
311 unsigned int function,
312 unsigned int group)
313{
314 struct rk805_pctrl_info *pci = pinctrl_dev_get_drvdata(pctldev);
315 int mux = pci->functions[function].mux_option;
316 int offset = group;
317
318 return _rk805_pinctrl_set_mux(pctldev, offset, mux);
319}
320
321static int rk805_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
322 struct pinctrl_gpio_range *range,
323 unsigned int offset, bool input)
324{
325 struct rk805_pctrl_info *pci = pinctrl_dev_get_drvdata(pctldev);
326 int ret;
327
328 /* switch to gpio function */
329 ret = _rk805_pinctrl_set_mux(pctldev, offset, RK805_PINMUX_GPIO);
330 if (ret) {
331 dev_err(pci->dev, "set gpio%d mux failed\n", offset);
332 return ret;
333 }
334
335 /* set direction */
336 if (!pci->pin_cfg[offset].dir_msk)
337 return 0;
338
339 ret = regmap_update_bits(pci->rk808->regmap,
340 pci->pin_cfg[offset].reg,
341 pci->pin_cfg[offset].dir_msk,
342 input ? 0 : pci->pin_cfg[offset].dir_msk);
343 if (ret) {
344 dev_err(pci->dev, "set gpio%d direction failed\n", offset);
345 return ret;
346 }
347
348 return ret;
349}
350
351static const struct pinmux_ops rk805_pinmux_ops = {
352 .get_functions_count = rk805_pinctrl_get_funcs_count,
353 .get_function_name = rk805_pinctrl_get_func_name,
354 .get_function_groups = rk805_pinctrl_get_func_groups,
355 .set_mux = rk805_pinctrl_set_mux,
356 .gpio_set_direction = rk805_pmx_gpio_set_direction,
357};
358
359static int rk805_pinconf_get(struct pinctrl_dev *pctldev,
360 unsigned int pin, unsigned long *config)
361{
362 struct rk805_pctrl_info *pci = pinctrl_dev_get_drvdata(pctldev);
363 enum pin_config_param param = pinconf_to_config_param(*config);
364 u32 arg = 0;
365
366 switch (param) {
367 case PIN_CONFIG_OUTPUT:
368 arg = rk805_gpio_get(&pci->gpio_chip, pin);
369 break;
370 default:
371 dev_err(pci->dev, "Properties not supported\n");
372 return -ENOTSUPP;
373 }
374
375 *config = pinconf_to_config_packed(param, (u16)arg);
376
377 return 0;
378}
379
380static int rk805_pinconf_set(struct pinctrl_dev *pctldev,
381 unsigned int pin, unsigned long *configs,
382 unsigned int num_configs)
383{
384 struct rk805_pctrl_info *pci = pinctrl_dev_get_drvdata(pctldev);
385 enum pin_config_param param;
386 u32 i, arg = 0;
387
388 for (i = 0; i < num_configs; i++) {
389 param = pinconf_to_config_param(configs[i]);
390 arg = pinconf_to_config_argument(configs[i]);
391
392 switch (param) {
393 case PIN_CONFIG_OUTPUT:
394 rk805_gpio_set(&pci->gpio_chip, pin, arg);
395 rk805_pmx_gpio_set_direction(pctldev, NULL, pin, false);
396 break;
397 default:
398 dev_err(pci->dev, "Properties not supported\n");
399 return -ENOTSUPP;
400 }
401 }
402
403 return 0;
404}
405
406static const struct pinconf_ops rk805_pinconf_ops = {
407 .pin_config_get = rk805_pinconf_get,
408 .pin_config_set = rk805_pinconf_set,
409};
410
411static struct pinctrl_desc rk805_pinctrl_desc = {
412 .name = "rk805-pinctrl",
413 .pctlops = &rk805_pinctrl_ops,
414 .pmxops = &rk805_pinmux_ops,
415 .confops = &rk805_pinconf_ops,
416 .owner = THIS_MODULE,
417};
418
419static int rk805_pinctrl_probe(struct platform_device *pdev)
420{
421 struct rk805_pctrl_info *pci;
422 int ret;
423
424 pci = devm_kzalloc(&pdev->dev, sizeof(*pci), GFP_KERNEL);
425 if (!pci)
426 return -ENOMEM;
427
428 pci->dev = &pdev->dev;
429 pci->dev->of_node = pdev->dev.parent->of_node;
430 pci->rk808 = dev_get_drvdata(pdev->dev.parent);
431
432 pci->pinctrl_desc = rk805_pinctrl_desc;
433 pci->gpio_chip = rk805_gpio_chip;
434 pci->gpio_chip.parent = &pdev->dev;
435 pci->gpio_chip.of_node = pdev->dev.parent->of_node;
436
437 platform_set_drvdata(pdev, pci);
438
439 switch (pci->rk808->variant) {
440 case RK805_ID:
441 pci->pins = rk805_pins_desc;
442 pci->num_pins = ARRAY_SIZE(rk805_pins_desc);
443 pci->functions = rk805_pin_functions;
444 pci->num_functions = ARRAY_SIZE(rk805_pin_functions);
445 pci->groups = rk805_pin_groups;
446 pci->num_pin_groups = ARRAY_SIZE(rk805_pin_groups);
447 pci->pinctrl_desc.pins = rk805_pins_desc;
448 pci->pinctrl_desc.npins = ARRAY_SIZE(rk805_pins_desc);
449 pci->pin_cfg = rk805_gpio_cfgs;
450 pci->gpio_chip.ngpio = ARRAY_SIZE(rk805_gpio_cfgs);
451 break;
452 default:
453 dev_err(&pdev->dev, "unsupported RK805 ID %lu\n",
454 pci->rk808->variant);
455 return -EINVAL;
456 }
457
458 /* Add gpio chip */
459 ret = devm_gpiochip_add_data(&pdev->dev, &pci->gpio_chip, pci);
460 if (ret < 0) {
461 dev_err(&pdev->dev, "Couldn't add gpiochip\n");
462 return ret;
463 }
464
465 /* Add pinctrl */
466 pci->pctl = devm_pinctrl_register(&pdev->dev, &pci->pinctrl_desc, pci);
467 if (IS_ERR(pci->pctl)) {
468 dev_err(&pdev->dev, "Couldn't add pinctrl\n");
469 return PTR_ERR(pci->pctl);
470 }
471
472 /* Add pin range */
473 ret = gpiochip_add_pin_range(&pci->gpio_chip, dev_name(&pdev->dev),
474 0, 0, pci->gpio_chip.ngpio);
475 if (ret < 0) {
476 dev_err(&pdev->dev, "Couldn't add gpiochip pin range\n");
477 return ret;
478 }
479
480 return 0;
481}
482
483static struct platform_driver rk805_pinctrl_driver = {
484 .probe = rk805_pinctrl_probe,
485 .driver = {
486 .name = "rk805-pinctrl",
487 },
488};
489module_platform_driver(rk805_pinctrl_driver);
490
491MODULE_DESCRIPTION("RK805 pin control and GPIO driver");
492MODULE_AUTHOR("Joseph Chen <chenjh@rock-chips.com>");
493MODULE_LICENSE("GPL v2");
diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c
index 9dff1b4b85fc..a5915f498eea 100644
--- a/drivers/power/supply/twl4030_charger.c
+++ b/drivers/power/supply/twl4030_charger.c
@@ -18,7 +18,7 @@
18#include <linux/err.h> 18#include <linux/err.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/i2c/twl.h> 21#include <linux/mfd/twl.h>
22#include <linux/power_supply.h> 22#include <linux/power_supply.h>
23#include <linux/notifier.h> 23#include <linux/notifier.h>
24#include <linux/usb/otg.h> 24#include <linux/usb/otg.h>
diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index 313c10789ca2..7cb982b54c8c 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -417,6 +417,16 @@ config PWM_STM32
417 To compile this driver as a module, choose M here: the module 417 To compile this driver as a module, choose M here: the module
418 will be called pwm-stm32. 418 will be called pwm-stm32.
419 419
420config PWM_STM32_LP
421 tristate "STMicroelectronics STM32 PWM LP"
422 depends on MFD_STM32_LPTIMER || COMPILE_TEST
423 help
424 Generic PWM framework driver for STMicroelectronics STM32 SoCs
425 with Low-Power Timer (LPTIM).
426
427 To compile this driver as a module, choose M here: the module
428 will be called pwm-stm32-lp.
429
420config PWM_STMPE 430config PWM_STMPE
421 bool "STMPE expander PWM export" 431 bool "STMPE expander PWM export"
422 depends on MFD_STMPE 432 depends on MFD_STMPE
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
index 93da1f79a3b8..a3a4beef6daa 100644
--- a/drivers/pwm/Makefile
+++ b/drivers/pwm/Makefile
@@ -40,6 +40,7 @@ obj-$(CONFIG_PWM_SAMSUNG) += pwm-samsung.o
40obj-$(CONFIG_PWM_SPEAR) += pwm-spear.o 40obj-$(CONFIG_PWM_SPEAR) += pwm-spear.o
41obj-$(CONFIG_PWM_STI) += pwm-sti.o 41obj-$(CONFIG_PWM_STI) += pwm-sti.o
42obj-$(CONFIG_PWM_STM32) += pwm-stm32.o 42obj-$(CONFIG_PWM_STM32) += pwm-stm32.o
43obj-$(CONFIG_PWM_STM32_LP) += pwm-stm32-lp.o
43obj-$(CONFIG_PWM_STMPE) += pwm-stmpe.o 44obj-$(CONFIG_PWM_STMPE) += pwm-stmpe.o
44obj-$(CONFIG_PWM_SUN4I) += pwm-sun4i.o 45obj-$(CONFIG_PWM_SUN4I) += pwm-sun4i.o
45obj-$(CONFIG_PWM_TEGRA) += pwm-tegra.o 46obj-$(CONFIG_PWM_TEGRA) += pwm-tegra.o
diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c
new file mode 100644
index 000000000000..9793b296108f
--- /dev/null
+++ b/drivers/pwm/pwm-stm32-lp.c
@@ -0,0 +1,246 @@
1/*
2 * STM32 Low-Power Timer PWM driver
3 *
4 * Copyright (C) STMicroelectronics 2017
5 *
6 * Author: Gerald Baeza <gerald.baeza@st.com>
7 *
8 * License terms: GNU General Public License (GPL), version 2
9 *
10 * Inspired by Gerald Baeza's pwm-stm32 driver
11 */
12
13#include <linux/bitfield.h>
14#include <linux/mfd/stm32-lptimer.h>
15#include <linux/module.h>
16#include <linux/of.h>
17#include <linux/platform_device.h>
18#include <linux/pwm.h>
19
20struct stm32_pwm_lp {
21 struct pwm_chip chip;
22 struct clk *clk;
23 struct regmap *regmap;
24};
25
26static inline struct stm32_pwm_lp *to_stm32_pwm_lp(struct pwm_chip *chip)
27{
28 return container_of(chip, struct stm32_pwm_lp, chip);
29}
30
31/* STM32 Low-Power Timer is preceded by a configurable power-of-2 prescaler */
32#define STM32_LPTIM_MAX_PRESCALER 128
33
34static int stm32_pwm_lp_apply(struct pwm_chip *chip, struct pwm_device *pwm,
35 struct pwm_state *state)
36{
37 struct stm32_pwm_lp *priv = to_stm32_pwm_lp(chip);
38 unsigned long long prd, div, dty;
39 struct pwm_state cstate;
40 u32 val, mask, cfgr, presc = 0;
41 bool reenable;
42 int ret;
43
44 pwm_get_state(pwm, &cstate);
45 reenable = !cstate.enabled;
46
47 if (!state->enabled) {
48 if (cstate.enabled) {
49 /* Disable LP timer */
50 ret = regmap_write(priv->regmap, STM32_LPTIM_CR, 0);
51 if (ret)
52 return ret;
53 /* disable clock to PWM counter */
54 clk_disable(priv->clk);
55 }
56 return 0;
57 }
58
59 /* Calculate the period and prescaler value */
60 div = (unsigned long long)clk_get_rate(priv->clk) * state->period;
61 do_div(div, NSEC_PER_SEC);
62 prd = div;
63 while (div > STM32_LPTIM_MAX_ARR) {
64 presc++;
65 if ((1 << presc) > STM32_LPTIM_MAX_PRESCALER) {
66 dev_err(priv->chip.dev, "max prescaler exceeded\n");
67 return -EINVAL;
68 }
69 div = prd >> presc;
70 }
71 prd = div;
72
73 /* Calculate the duty cycle */
74 dty = prd * state->duty_cycle;
75 do_div(dty, state->period);
76
77 if (!cstate.enabled) {
78 /* enable clock to drive PWM counter */
79 ret = clk_enable(priv->clk);
80 if (ret)
81 return ret;
82 }
83
84 ret = regmap_read(priv->regmap, STM32_LPTIM_CFGR, &cfgr);
85 if (ret)
86 goto err;
87
88 if ((FIELD_GET(STM32_LPTIM_PRESC, cfgr) != presc) ||
89 (FIELD_GET(STM32_LPTIM_WAVPOL, cfgr) != state->polarity)) {
90 val = FIELD_PREP(STM32_LPTIM_PRESC, presc);
91 val |= FIELD_PREP(STM32_LPTIM_WAVPOL, state->polarity);
92 mask = STM32_LPTIM_PRESC | STM32_LPTIM_WAVPOL;
93
94 /* Must disable LP timer to modify CFGR */
95 reenable = true;
96 ret = regmap_write(priv->regmap, STM32_LPTIM_CR, 0);
97 if (ret)
98 goto err;
99
100 ret = regmap_update_bits(priv->regmap, STM32_LPTIM_CFGR, mask,
101 val);
102 if (ret)
103 goto err;
104 }
105
106 if (reenable) {
107 /* Must (re)enable LP timer to modify CMP & ARR */
108 ret = regmap_write(priv->regmap, STM32_LPTIM_CR,
109 STM32_LPTIM_ENABLE);
110 if (ret)
111 goto err;
112 }
113
114 ret = regmap_write(priv->regmap, STM32_LPTIM_ARR, prd - 1);
115 if (ret)
116 goto err;
117
118 ret = regmap_write(priv->regmap, STM32_LPTIM_CMP, prd - (1 + dty));
119 if (ret)
120 goto err;
121
122 /* ensure CMP & ARR registers are properly written */
123 ret = regmap_read_poll_timeout(priv->regmap, STM32_LPTIM_ISR, val,
124 (val & STM32_LPTIM_CMPOK_ARROK),
125 100, 1000);
126 if (ret) {
127 dev_err(priv->chip.dev, "ARR/CMP registers write issue\n");
128 goto err;
129 }
130 ret = regmap_write(priv->regmap, STM32_LPTIM_ICR,
131 STM32_LPTIM_CMPOKCF_ARROKCF);
132 if (ret)
133 goto err;
134
135 if (reenable) {
136 /* Start LP timer in continuous mode */
137 ret = regmap_update_bits(priv->regmap, STM32_LPTIM_CR,
138 STM32_LPTIM_CNTSTRT,
139 STM32_LPTIM_CNTSTRT);
140 if (ret) {
141 regmap_write(priv->regmap, STM32_LPTIM_CR, 0);
142 goto err;
143 }
144 }
145
146 return 0;
147err:
148 if (!cstate.enabled)
149 clk_disable(priv->clk);
150
151 return ret;
152}
153
154static void stm32_pwm_lp_get_state(struct pwm_chip *chip,
155 struct pwm_device *pwm,
156 struct pwm_state *state)
157{
158 struct stm32_pwm_lp *priv = to_stm32_pwm_lp(chip);
159 unsigned long rate = clk_get_rate(priv->clk);
160 u32 val, presc, prd;
161 u64 tmp;
162
163 regmap_read(priv->regmap, STM32_LPTIM_CR, &val);
164 state->enabled = !!FIELD_GET(STM32_LPTIM_ENABLE, val);
165 /* Keep PWM counter clock refcount in sync with PWM initial state */
166 if (state->enabled)
167 clk_enable(priv->clk);
168
169 regmap_read(priv->regmap, STM32_LPTIM_CFGR, &val);
170 presc = FIELD_GET(STM32_LPTIM_PRESC, val);
171 state->polarity = FIELD_GET(STM32_LPTIM_WAVPOL, val);
172
173 regmap_read(priv->regmap, STM32_LPTIM_ARR, &prd);
174 tmp = prd + 1;
175 tmp = (tmp << presc) * NSEC_PER_SEC;
176 state->period = DIV_ROUND_CLOSEST_ULL(tmp, rate);
177
178 regmap_read(priv->regmap, STM32_LPTIM_CMP, &val);
179 tmp = prd - val;
180 tmp = (tmp << presc) * NSEC_PER_SEC;
181 state->duty_cycle = DIV_ROUND_CLOSEST_ULL(tmp, rate);
182}
183
184static const struct pwm_ops stm32_pwm_lp_ops = {
185 .owner = THIS_MODULE,
186 .apply = stm32_pwm_lp_apply,
187 .get_state = stm32_pwm_lp_get_state,
188};
189
190static int stm32_pwm_lp_probe(struct platform_device *pdev)
191{
192 struct stm32_lptimer *ddata = dev_get_drvdata(pdev->dev.parent);
193 struct stm32_pwm_lp *priv;
194 int ret;
195
196 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
197 if (!priv)
198 return -ENOMEM;
199
200 priv->regmap = ddata->regmap;
201 priv->clk = ddata->clk;
202 priv->chip.base = -1;
203 priv->chip.dev = &pdev->dev;
204 priv->chip.ops = &stm32_pwm_lp_ops;
205 priv->chip.npwm = 1;
206
207 ret = pwmchip_add(&priv->chip);
208 if (ret < 0)
209 return ret;
210
211 platform_set_drvdata(pdev, priv);
212
213 return 0;
214}
215
216static int stm32_pwm_lp_remove(struct platform_device *pdev)
217{
218 struct stm32_pwm_lp *priv = platform_get_drvdata(pdev);
219 unsigned int i;
220
221 for (i = 0; i < priv->chip.npwm; i++)
222 if (pwm_is_enabled(&priv->chip.pwms[i]))
223 pwm_disable(&priv->chip.pwms[i]);
224
225 return pwmchip_remove(&priv->chip);
226}
227
228static const struct of_device_id stm32_pwm_lp_of_match[] = {
229 { .compatible = "st,stm32-pwm-lp", },
230 {},
231};
232MODULE_DEVICE_TABLE(of, stm32_pwm_lp_of_match);
233
234static struct platform_driver stm32_pwm_lp_driver = {
235 .probe = stm32_pwm_lp_probe,
236 .remove = stm32_pwm_lp_remove,
237 .driver = {
238 .name = "stm32-pwm-lp",
239 .of_match_table = of_match_ptr(stm32_pwm_lp_of_match),
240 },
241};
242module_platform_driver(stm32_pwm_lp_driver);
243
244MODULE_ALIAS("platform:stm32-pwm-lp");
245MODULE_DESCRIPTION("STMicroelectronics STM32 PWM LP driver");
246MODULE_LICENSE("GPL v2");
diff --git a/drivers/pwm/pwm-twl-led.c b/drivers/pwm/pwm-twl-led.c
index 21eff991d0e3..01153622778b 100644
--- a/drivers/pwm/pwm-twl-led.c
+++ b/drivers/pwm/pwm-twl-led.c
@@ -24,7 +24,7 @@
24#include <linux/of.h> 24#include <linux/of.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/pwm.h> 26#include <linux/pwm.h>
27#include <linux/i2c/twl.h> 27#include <linux/mfd/twl.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29 29
30/* 30/*
diff --git a/drivers/pwm/pwm-twl.c b/drivers/pwm/pwm-twl.c
index 9de617b76680..b7a45be99815 100644
--- a/drivers/pwm/pwm-twl.c
+++ b/drivers/pwm/pwm-twl.c
@@ -21,7 +21,7 @@
21#include <linux/of.h> 21#include <linux/of.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/pwm.h> 23#include <linux/pwm.h>
24#include <linux/i2c/twl.h> 24#include <linux/mfd/twl.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26 26
27/* 27/*
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index e740a66cb1d6..0fd6195601ba 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -696,11 +696,11 @@ config REGULATOR_RC5T583
696 outputs which can be controlled by i2c communication. 696 outputs which can be controlled by i2c communication.
697 697
698config REGULATOR_RK808 698config REGULATOR_RK808
699 tristate "Rockchip RK808/RK818 Power regulators" 699 tristate "Rockchip RK805/RK808/RK818 Power regulators"
700 depends on MFD_RK808 700 depends on MFD_RK808
701 help 701 help
702 Select this option to enable the power regulator of ROCKCHIP 702 Select this option to enable the power regulator of ROCKCHIP
703 PMIC RK808 and RK818. 703 PMIC RK805,RK808 and RK818.
704 This driver supports the control of different power rails of device 704 This driver supports the control of different power rails of device
705 through regulator interface. The device supports multiple DCDC/LDO 705 through regulator interface. The device supports multiple DCDC/LDO
706 outputs which can be controlled by i2c communication. 706 outputs which can be controlled by i2c communication.
diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c
index a16d81420612..213b68743cc8 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -65,6 +65,27 @@
65/* max steps for increase voltage of Buck1/2, equal 100mv*/ 65/* max steps for increase voltage of Buck1/2, equal 100mv*/
66#define MAX_STEPS_ONE_TIME 8 66#define MAX_STEPS_ONE_TIME 8
67 67
68#define RK805_DESC(_id, _match, _supply, _min, _max, _step, _vreg, \
69 _vmask, _ereg, _emask, _etime) \
70 [_id] = { \
71 .name = (_match), \
72 .supply_name = (_supply), \
73 .of_match = of_match_ptr(_match), \
74 .regulators_node = of_match_ptr("regulators"), \
75 .type = REGULATOR_VOLTAGE, \
76 .id = (_id), \
77 .n_voltages = (((_max) - (_min)) / (_step) + 1), \
78 .owner = THIS_MODULE, \
79 .min_uV = (_min) * 1000, \
80 .uV_step = (_step) * 1000, \
81 .vsel_reg = (_vreg), \
82 .vsel_mask = (_vmask), \
83 .enable_reg = (_ereg), \
84 .enable_mask = (_emask), \
85 .enable_time = (_etime), \
86 .ops = &rk805_reg_ops, \
87 }
88
68#define RK8XX_DESC(_id, _match, _supply, _min, _max, _step, _vreg, \ 89#define RK8XX_DESC(_id, _match, _supply, _min, _max, _step, _vreg, \
69 _vmask, _ereg, _emask, _etime) \ 90 _vmask, _ereg, _emask, _etime) \
70 [_id] = { \ 91 [_id] = { \
@@ -298,6 +319,28 @@ static int rk808_set_suspend_voltage_range(struct regulator_dev *rdev, int uv)
298 sel); 319 sel);
299} 320}
300 321
322static int rk805_set_suspend_enable(struct regulator_dev *rdev)
323{
324 unsigned int reg;
325
326 reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
327
328 return regmap_update_bits(rdev->regmap, reg,
329 rdev->desc->enable_mask,
330 rdev->desc->enable_mask);
331}
332
333static int rk805_set_suspend_disable(struct regulator_dev *rdev)
334{
335 unsigned int reg;
336
337 reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
338
339 return regmap_update_bits(rdev->regmap, reg,
340 rdev->desc->enable_mask,
341 0);
342}
343
301static int rk808_set_suspend_enable(struct regulator_dev *rdev) 344static int rk808_set_suspend_enable(struct regulator_dev *rdev)
302{ 345{
303 unsigned int reg; 346 unsigned int reg;
@@ -320,6 +363,27 @@ static int rk808_set_suspend_disable(struct regulator_dev *rdev)
320 rdev->desc->enable_mask); 363 rdev->desc->enable_mask);
321} 364}
322 365
366static struct regulator_ops rk805_reg_ops = {
367 .list_voltage = regulator_list_voltage_linear,
368 .map_voltage = regulator_map_voltage_linear,
369 .get_voltage_sel = regulator_get_voltage_sel_regmap,
370 .set_voltage_sel = regulator_set_voltage_sel_regmap,
371 .enable = regulator_enable_regmap,
372 .disable = regulator_disable_regmap,
373 .is_enabled = regulator_is_enabled_regmap,
374 .set_suspend_voltage = rk808_set_suspend_voltage,
375 .set_suspend_enable = rk805_set_suspend_enable,
376 .set_suspend_disable = rk805_set_suspend_disable,
377};
378
379static struct regulator_ops rk805_switch_ops = {
380 .enable = regulator_enable_regmap,
381 .disable = regulator_disable_regmap,
382 .is_enabled = regulator_is_enabled_regmap,
383 .set_suspend_enable = rk805_set_suspend_enable,
384 .set_suspend_disable = rk805_set_suspend_disable,
385};
386
323static struct regulator_ops rk808_buck1_2_ops = { 387static struct regulator_ops rk808_buck1_2_ops = {
324 .list_voltage = regulator_list_voltage_linear, 388 .list_voltage = regulator_list_voltage_linear,
325 .map_voltage = regulator_map_voltage_linear, 389 .map_voltage = regulator_map_voltage_linear,
@@ -369,6 +433,68 @@ static struct regulator_ops rk808_switch_ops = {
369 .set_suspend_disable = rk808_set_suspend_disable, 433 .set_suspend_disable = rk808_set_suspend_disable,
370}; 434};
371 435
436static const struct regulator_desc rk805_reg[] = {
437 {
438 .name = "DCDC_REG1",
439 .supply_name = "vcc1",
440 .of_match = of_match_ptr("DCDC_REG1"),
441 .regulators_node = of_match_ptr("regulators"),
442 .id = RK805_ID_DCDC1,
443 .ops = &rk805_reg_ops,
444 .type = REGULATOR_VOLTAGE,
445 .min_uV = 712500,
446 .uV_step = 12500,
447 .n_voltages = 64,
448 .vsel_reg = RK805_BUCK1_ON_VSEL_REG,
449 .vsel_mask = RK818_BUCK_VSEL_MASK,
450 .enable_reg = RK805_DCDC_EN_REG,
451 .enable_mask = BIT(0),
452 .owner = THIS_MODULE,
453 }, {
454 .name = "DCDC_REG2",
455 .supply_name = "vcc2",
456 .of_match = of_match_ptr("DCDC_REG2"),
457 .regulators_node = of_match_ptr("regulators"),
458 .id = RK805_ID_DCDC2,
459 .ops = &rk805_reg_ops,
460 .type = REGULATOR_VOLTAGE,
461 .min_uV = 712500,
462 .uV_step = 12500,
463 .n_voltages = 64,
464 .vsel_reg = RK805_BUCK2_ON_VSEL_REG,
465 .vsel_mask = RK818_BUCK_VSEL_MASK,
466 .enable_reg = RK805_DCDC_EN_REG,
467 .enable_mask = BIT(1),
468 .owner = THIS_MODULE,
469 }, {
470 .name = "DCDC_REG3",
471 .supply_name = "vcc3",
472 .of_match = of_match_ptr("DCDC_REG3"),
473 .regulators_node = of_match_ptr("regulators"),
474 .id = RK805_ID_DCDC3,
475 .ops = &rk805_switch_ops,
476 .type = REGULATOR_VOLTAGE,
477 .n_voltages = 1,
478 .enable_reg = RK805_DCDC_EN_REG,
479 .enable_mask = BIT(2),
480 .owner = THIS_MODULE,
481 },
482
483 RK805_DESC(RK805_ID_DCDC4, "DCDC_REG4", "vcc4", 800, 3400, 100,
484 RK805_BUCK4_ON_VSEL_REG, RK818_BUCK4_VSEL_MASK,
485 RK805_DCDC_EN_REG, BIT(3), 0),
486
487 RK805_DESC(RK805_ID_LDO1, "LDO_REG1", "vcc5", 800, 3400, 100,
488 RK805_LDO1_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK805_LDO_EN_REG,
489 BIT(0), 400),
490 RK805_DESC(RK805_ID_LDO2, "LDO_REG2", "vcc5", 800, 3400, 100,
491 RK805_LDO2_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK805_LDO_EN_REG,
492 BIT(1), 400),
493 RK805_DESC(RK805_ID_LDO3, "LDO_REG3", "vcc6", 800, 3400, 100,
494 RK805_LDO3_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK805_LDO_EN_REG,
495 BIT(2), 400),
496};
497
372static const struct regulator_desc rk808_reg[] = { 498static const struct regulator_desc rk808_reg[] = {
373 { 499 {
374 .name = "DCDC_REG1", 500 .name = "DCDC_REG1",
@@ -625,6 +751,10 @@ static int rk808_regulator_probe(struct platform_device *pdev)
625 platform_set_drvdata(pdev, pdata); 751 platform_set_drvdata(pdev, pdata);
626 752
627 switch (rk808->variant) { 753 switch (rk808->variant) {
754 case RK805_ID:
755 regulators = rk805_reg;
756 nregulators = RK805_NUM_REGULATORS;
757 break;
628 case RK808_ID: 758 case RK808_ID:
629 regulators = rk808_reg; 759 regulators = rk808_reg;
630 nregulators = RK808_NUM_REGULATORS; 760 nregulators = RK808_NUM_REGULATORS;
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 6c9ec84121bd..a4456db5849d 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -20,7 +20,7 @@
20#include <linux/regulator/driver.h> 20#include <linux/regulator/driver.h>
21#include <linux/regulator/machine.h> 21#include <linux/regulator/machine.h>
22#include <linux/regulator/of_regulator.h> 22#include <linux/regulator/of_regulator.h>
23#include <linux/i2c/twl.h> 23#include <linux/mfd/twl.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25 25
26/* 26/*
diff --git a/drivers/regulator/twl6030-regulator.c b/drivers/regulator/twl6030-regulator.c
index 56aada387887..219cbd910dbf 100644
--- a/drivers/regulator/twl6030-regulator.c
+++ b/drivers/regulator/twl6030-regulator.c
@@ -21,7 +21,7 @@
21#include <linux/regulator/driver.h> 21#include <linux/regulator/driver.h>
22#include <linux/regulator/machine.h> 22#include <linux/regulator/machine.h>
23#include <linux/regulator/of_regulator.h> 23#include <linux/regulator/of_regulator.h>
24#include <linux/i2c/twl.h> 24#include <linux/mfd/twl.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26 26
27struct twlreg_info { 27struct twlreg_info {
diff --git a/drivers/rtc/rtc-dm355evm.c b/drivers/rtc/rtc-dm355evm.c
index f225cd873ff6..97d8259b9494 100644
--- a/drivers/rtc/rtc-dm355evm.c
+++ b/drivers/rtc/rtc-dm355evm.c
@@ -13,7 +13,7 @@
13#include <linux/rtc.h> 13#include <linux/rtc.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15 15
16#include <linux/i2c/dm355evm_msp.h> 16#include <linux/mfd/dm355evm_msp.h>
17#include <linux/module.h> 17#include <linux/module.h>
18 18
19 19
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index c18c39212ce6..3472e79f2b17 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -31,7 +31,7 @@
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <linux/of.h> 32#include <linux/of.h>
33 33
34#include <linux/i2c/twl.h> 34#include <linux/mfd/twl.h>
35 35
36enum twl_class { 36enum twl_class {
37 TWL_4030 = 0, 37 TWL_4030 = 0,
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index a4d814b7f380..91393ec7d850 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -53,7 +53,7 @@
53#define DRIVER_DESC "OHCI OMAP driver" 53#define DRIVER_DESC "OHCI OMAP driver"
54 54
55#ifdef CONFIG_TPS65010 55#ifdef CONFIG_TPS65010
56#include <linux/i2c/tps65010.h> 56#include <linux/mfd/tps65010.h>
57#else 57#else
58 58
59#define LOW 0 59#define LOW 0
diff --git a/drivers/usb/phy/phy-isp1301-omap.c b/drivers/usb/phy/phy-isp1301-omap.c
index 042c5a8fd423..c6052c814bcc 100644
--- a/drivers/usb/phy/phy-isp1301-omap.c
+++ b/drivers/usb/phy/phy-isp1301-omap.c
@@ -96,7 +96,7 @@ struct isp1301 {
96 96
97#if IS_REACHABLE(CONFIG_TPS65010) 97#if IS_REACHABLE(CONFIG_TPS65010)
98 98
99#include <linux/i2c/tps65010.h> 99#include <linux/mfd/tps65010.h>
100 100
101#else 101#else
102 102
diff --git a/drivers/usb/phy/phy-twl6030-usb.c b/drivers/usb/phy/phy-twl6030-usb.c
index 628b600b02b1..b5dc077ed7d3 100644
--- a/drivers/usb/phy/phy-twl6030-usb.c
+++ b/drivers/usb/phy/phy-twl6030-usb.c
@@ -28,7 +28,7 @@
28#include <linux/usb/musb.h> 28#include <linux/usb/musb.h>
29#include <linux/usb/phy_companion.h> 29#include <linux/usb/phy_companion.h>
30#include <linux/phy/omap_usb.h> 30#include <linux/phy/omap_usb.h>
31#include <linux/i2c/twl.h> 31#include <linux/mfd/twl.h>
32#include <linux/regulator/consumer.h> 32#include <linux/regulator/consumer.h>
33#include <linux/err.h> 33#include <linux/err.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
diff --git a/drivers/video/backlight/pandora_bl.c b/drivers/video/backlight/pandora_bl.c
index 5d8bb8b20183..a186bc677c7d 100644
--- a/drivers/video/backlight/pandora_bl.c
+++ b/drivers/video/backlight/pandora_bl.c
@@ -16,7 +16,7 @@
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/fb.h> 17#include <linux/fb.h>
18#include <linux/backlight.h> 18#include <linux/backlight.h>
19#include <linux/i2c/twl.h> 19#include <linux/mfd/twl.h>
20#include <linux/err.h> 20#include <linux/err.h>
21 21
22#define TWL_PWM0_ON 0x00 22#define TWL_PWM0_ON 0x00
diff --git a/drivers/video/fbdev/omap/lcd_h3.c b/drivers/video/fbdev/omap/lcd_h3.c
index 9d2da146813e..796f4634c4c6 100644
--- a/drivers/video/fbdev/omap/lcd_h3.c
+++ b/drivers/video/fbdev/omap/lcd_h3.c
@@ -21,7 +21,7 @@
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/i2c/tps65010.h> 24#include <linux/mfd/tps65010.h>
25#include <linux/gpio.h> 25#include <linux/gpio.h>
26 26
27#include "omapfb.h" 27#include "omapfb.h"
diff --git a/drivers/watchdog/twl4030_wdt.c b/drivers/watchdog/twl4030_wdt.c
index 9bf3cc0f3961..569fe85e52da 100644
--- a/drivers/watchdog/twl4030_wdt.c
+++ b/drivers/watchdog/twl4030_wdt.c
@@ -24,7 +24,7 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/watchdog.h> 25#include <linux/watchdog.h>
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/i2c/twl.h> 27#include <linux/mfd/twl.h>
28 28
29#define TWL4030_WATCHDOG_CFG_REG_OFFS 0x3 29#define TWL4030_WATCHDOG_CFG_REG_OFFS 0x3
30 30
diff --git a/include/linux/iio/timer/stm32-lptim-trigger.h b/include/linux/iio/timer/stm32-lptim-trigger.h
new file mode 100644
index 000000000000..34d59bfdce2d
--- /dev/null
+++ b/include/linux/iio/timer/stm32-lptim-trigger.h
@@ -0,0 +1,27 @@
1/*
2 * Copyright (C) STMicroelectronics 2017
3 *
4 * Author: Fabrice Gasnier <fabrice.gasnier@st.com>
5 *
6 * License terms: GNU General Public License (GPL), version 2
7 */
8
9#ifndef _STM32_LPTIM_TRIGGER_H_
10#define _STM32_LPTIM_TRIGGER_H_
11
12#include <linux/iio/iio.h>
13#include <linux/iio/trigger.h>
14
15#define LPTIM1_OUT "lptim1_out"
16#define LPTIM2_OUT "lptim2_out"
17#define LPTIM3_OUT "lptim3_out"
18
19#if IS_ENABLED(CONFIG_IIO_STM32_LPTIMER_TRIGGER)
20bool is_stm32_lptim_trigger(struct iio_trigger *trig);
21#else
22static inline bool is_stm32_lptim_trigger(struct iio_trigger *trig)
23{
24 return false;
25}
26#endif
27#endif
diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
index 965b027e31b3..e9c908c4fba8 100644
--- a/include/linux/mfd/axp20x.h
+++ b/include/linux/mfd/axp20x.h
@@ -23,6 +23,7 @@ enum axp20x_variants {
23 AXP803_ID, 23 AXP803_ID,
24 AXP806_ID, 24 AXP806_ID,
25 AXP809_ID, 25 AXP809_ID,
26 AXP813_ID,
26 NR_AXP20X_VARIANTS, 27 NR_AXP20X_VARIANTS,
27}; 28};
28 29
@@ -387,6 +388,34 @@ enum {
387 AXP803_REG_ID_MAX, 388 AXP803_REG_ID_MAX,
388}; 389};
389 390
391enum {
392 AXP813_DCDC1 = 0,
393 AXP813_DCDC2,
394 AXP813_DCDC3,
395 AXP813_DCDC4,
396 AXP813_DCDC5,
397 AXP813_DCDC6,
398 AXP813_DCDC7,
399 AXP813_ALDO1,
400 AXP813_ALDO2,
401 AXP813_ALDO3,
402 AXP813_DLDO1,
403 AXP813_DLDO2,
404 AXP813_DLDO3,
405 AXP813_DLDO4,
406 AXP813_ELDO1,
407 AXP813_ELDO2,
408 AXP813_ELDO3,
409 AXP813_FLDO1,
410 AXP813_FLDO2,
411 AXP813_FLDO3,
412 AXP813_RTC_LDO,
413 AXP813_LDO_IO0,
414 AXP813_LDO_IO1,
415 AXP813_SW,
416 AXP813_REG_ID_MAX,
417};
418
390/* IRQs */ 419/* IRQs */
391enum { 420enum {
392 AXP152_IRQ_LDO0IN_CONNECT = 1, 421 AXP152_IRQ_LDO0IN_CONNECT = 1,
diff --git a/include/linux/mfd/bd9571mwv.h b/include/linux/mfd/bd9571mwv.h
new file mode 100644
index 000000000000..f0708ba4cbba
--- /dev/null
+++ b/include/linux/mfd/bd9571mwv.h
@@ -0,0 +1,115 @@
1/*
2 * ROHM BD9571MWV-M driver
3 *
4 * Copyright (C) 2017 Marek Vasut <marek.vasut+renesas@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether expressed or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License version 2 for more details.
14 *
15 * Based on the TPS65086 driver
16 */
17
18#ifndef __LINUX_MFD_BD9571MWV_H
19#define __LINUX_MFD_BD9571MWV_H
20
21#include <linux/device.h>
22#include <linux/regmap.h>
23
24/* List of registers for BD9571MWV */
25#define BD9571MWV_VENDOR_CODE 0x00
26#define BD9571MWV_VENDOR_CODE_VAL 0xdb
27#define BD9571MWV_PRODUCT_CODE 0x01
28#define BD9571MWV_PRODUCT_CODE_VAL 0x60
29#define BD9571MWV_PRODUCT_REVISION 0x02
30
31#define BD9571MWV_I2C_FUSA_MODE 0x10
32#define BD9571MWV_I2C_MD2_E1_BIT_1 0x11
33#define BD9571MWV_I2C_MD2_E1_BIT_2 0x12
34
35#define BD9571MWV_BKUP_MODE_CNT 0x20
36#define BD9571MWV_BKUP_MODE_STATUS 0x21
37#define BD9571MWV_BKUP_RECOVERY_CNT 0x22
38#define BD9571MWV_BKUP_CTRL_TIM_CNT 0x23
39#define BD9571MWV_WAITBKUP_WDT_CNT 0x24
40#define BD9571MWV_128H_TIM_CNT 0x26
41#define BD9571MWV_QLLM_CNT 0x27
42
43#define BD9571MWV_AVS_SET_MONI 0x31
44#define BD9571MWV_AVS_SET_MONI_MASK 0x3
45#define BD9571MWV_AVS_VD09_VID(n) (0x32 + (n))
46#define BD9571MWV_AVS_DVFS_VID(n) (0x36 + (n))
47
48#define BD9571MWV_VD18_VID 0x42
49#define BD9571MWV_VD25_VID 0x43
50#define BD9571MWV_VD33_VID 0x44
51
52#define BD9571MWV_DVFS_VINIT 0x50
53#define BD9571MWV_DVFS_SETVMAX 0x52
54#define BD9571MWV_DVFS_BOOSTVID 0x53
55#define BD9571MWV_DVFS_SETVID 0x54
56#define BD9571MWV_DVFS_MONIVDAC 0x55
57#define BD9571MWV_DVFS_PGD_CNT 0x56
58
59#define BD9571MWV_GPIO_DIR 0x60
60#define BD9571MWV_GPIO_OUT 0x61
61#define BD9571MWV_GPIO_IN 0x62
62#define BD9571MWV_GPIO_DEB 0x63
63#define BD9571MWV_GPIO_INT_SET 0x64
64#define BD9571MWV_GPIO_INT 0x65
65#define BD9571MWV_GPIO_INTMASK 0x66
66
67#define BD9571MWV_REG_KEEP(n) (0x70 + (n))
68
69#define BD9571MWV_PMIC_INTERNAL_STATUS 0x80
70#define BD9571MWV_PROT_ERROR_STATUS0 0x81
71#define BD9571MWV_PROT_ERROR_STATUS1 0x82
72#define BD9571MWV_PROT_ERROR_STATUS2 0x83
73#define BD9571MWV_PROT_ERROR_STATUS3 0x84
74#define BD9571MWV_PROT_ERROR_STATUS4 0x85
75
76#define BD9571MWV_INT_INTREQ 0x90
77#define BD9571MWV_INT_INTREQ_MD1_INT BIT(0)
78#define BD9571MWV_INT_INTREQ_MD2_E1_INT BIT(1)
79#define BD9571MWV_INT_INTREQ_MD2_E2_INT BIT(2)
80#define BD9571MWV_INT_INTREQ_PROT_ERR_INT BIT(3)
81#define BD9571MWV_INT_INTREQ_GP_INT BIT(4)
82#define BD9571MWV_INT_INTREQ_128H_OF_INT BIT(5)
83#define BD9571MWV_INT_INTREQ_WDT_OF_INT BIT(6)
84#define BD9571MWV_INT_INTREQ_BKUP_TRG_INT BIT(7)
85#define BD9571MWV_INT_INTMASK 0x91
86
87#define BD9571MWV_ACCESS_KEY 0xff
88
89/* Define the BD9571MWV IRQ numbers */
90enum bd9571mwv_irqs {
91 BD9571MWV_IRQ_MD1,
92 BD9571MWV_IRQ_MD2_E1,
93 BD9571MWV_IRQ_MD2_E2,
94 BD9571MWV_IRQ_PROT_ERR,
95 BD9571MWV_IRQ_GP,
96 BD9571MWV_IRQ_128H_OF,
97 BD9571MWV_IRQ_WDT_OF,
98 BD9571MWV_IRQ_BKUP_TRG,
99};
100
101/**
102 * struct bd9571mwv - state holder for the bd9571mwv driver
103 *
104 * Device data may be used to access the BD9571MWV chip
105 */
106struct bd9571mwv {
107 struct device *dev;
108 struct regmap *regmap;
109
110 /* IRQ Data */
111 int irq;
112 struct regmap_irq_chip_data *irq_data;
113};
114
115#endif /* __LINUX_MFD_BD9571MWV_H */
diff --git a/include/linux/i2c/dm355evm_msp.h b/include/linux/mfd/dm355evm_msp.h
index 372470350fab..372470350fab 100644
--- a/include/linux/i2c/dm355evm_msp.h
+++ b/include/linux/mfd/dm355evm_msp.h
diff --git a/include/linux/mfd/hi6421-pmic.h b/include/linux/mfd/hi6421-pmic.h
index 587273e35acf..2580c08db7b1 100644
--- a/include/linux/mfd/hi6421-pmic.h
+++ b/include/linux/mfd/hi6421-pmic.h
@@ -38,4 +38,9 @@ struct hi6421_pmic {
38 struct regmap *regmap; 38 struct regmap *regmap;
39}; 39};
40 40
41enum hi6421_type {
42 HI6421 = 0,
43 HI6421_V530,
44};
45
41#endif /* __HI6421_PMIC_H */ 46#endif /* __HI6421_PMIC_H */
diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 83701ef7d3c7..d3156594674c 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -206,6 +206,97 @@ enum rk818_reg {
206#define RK818_USB_ILMIN_2000MA 0x7 206#define RK818_USB_ILMIN_2000MA 0x7
207#define RK818_USB_CHG_SD_VSEL_MASK 0x70 207#define RK818_USB_CHG_SD_VSEL_MASK 0x70
208 208
209/* RK805 */
210enum rk805_reg {
211 RK805_ID_DCDC1,
212 RK805_ID_DCDC2,
213 RK805_ID_DCDC3,
214 RK805_ID_DCDC4,
215 RK805_ID_LDO1,
216 RK805_ID_LDO2,
217 RK805_ID_LDO3,
218};
219
220/* CONFIG REGISTER */
221#define RK805_VB_MON_REG 0x21
222#define RK805_THERMAL_REG 0x22
223
224/* POWER CHANNELS ENABLE REGISTER */
225#define RK805_DCDC_EN_REG 0x23
226#define RK805_SLP_DCDC_EN_REG 0x25
227#define RK805_SLP_LDO_EN_REG 0x26
228#define RK805_LDO_EN_REG 0x27
229
230/* BUCK AND LDO CONFIG REGISTER */
231#define RK805_BUCK_LDO_SLP_LP_EN_REG 0x2A
232#define RK805_BUCK1_CONFIG_REG 0x2E
233#define RK805_BUCK1_ON_VSEL_REG 0x2F
234#define RK805_BUCK1_SLP_VSEL_REG 0x30
235#define RK805_BUCK2_CONFIG_REG 0x32
236#define RK805_BUCK2_ON_VSEL_REG 0x33
237#define RK805_BUCK2_SLP_VSEL_REG 0x34
238#define RK805_BUCK3_CONFIG_REG 0x36
239#define RK805_BUCK4_CONFIG_REG 0x37
240#define RK805_BUCK4_ON_VSEL_REG 0x38
241#define RK805_BUCK4_SLP_VSEL_REG 0x39
242#define RK805_LDO1_ON_VSEL_REG 0x3B
243#define RK805_LDO1_SLP_VSEL_REG 0x3C
244#define RK805_LDO2_ON_VSEL_REG 0x3D
245#define RK805_LDO2_SLP_VSEL_REG 0x3E
246#define RK805_LDO3_ON_VSEL_REG 0x3F
247#define RK805_LDO3_SLP_VSEL_REG 0x40
248
249/* INTERRUPT REGISTER */
250#define RK805_PWRON_LP_INT_TIME_REG 0x47
251#define RK805_PWRON_DB_REG 0x48
252#define RK805_DEV_CTRL_REG 0x4B
253#define RK805_INT_STS_REG 0x4C
254#define RK805_INT_STS_MSK_REG 0x4D
255#define RK805_GPIO_IO_POL_REG 0x50
256#define RK805_OUT_REG 0x52
257#define RK805_ON_SOURCE_REG 0xAE
258#define RK805_OFF_SOURCE_REG 0xAF
259
260#define RK805_NUM_REGULATORS 7
261
262#define RK805_PWRON_FALL_RISE_INT_EN 0x0
263#define RK805_PWRON_FALL_RISE_INT_MSK 0x81
264
265/* RK805 IRQ Definitions */
266#define RK805_IRQ_PWRON_RISE 0
267#define RK805_IRQ_VB_LOW 1
268#define RK805_IRQ_PWRON 2
269#define RK805_IRQ_PWRON_LP 3
270#define RK805_IRQ_HOTDIE 4
271#define RK805_IRQ_RTC_ALARM 5
272#define RK805_IRQ_RTC_PERIOD 6
273#define RK805_IRQ_PWRON_FALL 7
274
275#define RK805_IRQ_PWRON_RISE_MSK BIT(0)
276#define RK805_IRQ_VB_LOW_MSK BIT(1)
277#define RK805_IRQ_PWRON_MSK BIT(2)
278#define RK805_IRQ_PWRON_LP_MSK BIT(3)
279#define RK805_IRQ_HOTDIE_MSK BIT(4)
280#define RK805_IRQ_RTC_ALARM_MSK BIT(5)
281#define RK805_IRQ_RTC_PERIOD_MSK BIT(6)
282#define RK805_IRQ_PWRON_FALL_MSK BIT(7)
283
284#define RK805_PWR_RISE_INT_STATUS BIT(0)
285#define RK805_VB_LOW_INT_STATUS BIT(1)
286#define RK805_PWRON_INT_STATUS BIT(2)
287#define RK805_PWRON_LP_INT_STATUS BIT(3)
288#define RK805_HOTDIE_INT_STATUS BIT(4)
289#define RK805_ALARM_INT_STATUS BIT(5)
290#define RK805_PERIOD_INT_STATUS BIT(6)
291#define RK805_PWR_FALL_INT_STATUS BIT(7)
292
293#define RK805_BUCK1_2_ILMAX_MASK (3 << 6)
294#define RK805_BUCK3_4_ILMAX_MASK (3 << 3)
295#define RK805_RTC_PERIOD_INT_MASK (1 << 6)
296#define RK805_RTC_ALARM_INT_MASK (1 << 5)
297#define RK805_INT_ALARM_EN (1 << 3)
298#define RK805_INT_TIMER_EN (1 << 2)
299
209/* RK808 IRQ Definitions */ 300/* RK808 IRQ Definitions */
210#define RK808_IRQ_VOUT_LO 0 301#define RK808_IRQ_VOUT_LO 0
211#define RK808_IRQ_VB_LO 1 302#define RK808_IRQ_VB_LO 1
@@ -298,6 +389,14 @@ enum rk818_reg {
298#define VOUT_LO_INT BIT(0) 389#define VOUT_LO_INT BIT(0)
299#define CLK32KOUT2_EN BIT(0) 390#define CLK32KOUT2_EN BIT(0)
300 391
392#define TEMP115C 0x0c
393#define TEMP_HOTDIE_MSK 0x0c
394#define SLP_SD_MSK (0x3 << 2)
395#define SHUTDOWN_FUN (0x2 << 2)
396#define SLEEP_FUN (0x1 << 2)
397#define RK8XX_ID_MSK 0xfff0
398#define FPWM_MODE BIT(7)
399
301enum { 400enum {
302 BUCK_ILMIN_50MA, 401 BUCK_ILMIN_50MA,
303 BUCK_ILMIN_100MA, 402 BUCK_ILMIN_100MA,
@@ -321,6 +420,28 @@ enum {
321}; 420};
322 421
323enum { 422enum {
423 RK805_BUCK1_2_ILMAX_2500MA,
424 RK805_BUCK1_2_ILMAX_3000MA,
425 RK805_BUCK1_2_ILMAX_3500MA,
426 RK805_BUCK1_2_ILMAX_4000MA,
427};
428
429enum {
430 RK805_BUCK3_ILMAX_1500MA,
431 RK805_BUCK3_ILMAX_2000MA,
432 RK805_BUCK3_ILMAX_2500MA,
433 RK805_BUCK3_ILMAX_3000MA,
434};
435
436enum {
437 RK805_BUCK4_ILMAX_2000MA,
438 RK805_BUCK4_ILMAX_2500MA,
439 RK805_BUCK4_ILMAX_3000MA,
440 RK805_BUCK4_ILMAX_3500MA,
441};
442
443enum {
444 RK805_ID = 0x8050,
324 RK808_ID = 0x0000, 445 RK808_ID = 0x0000,
325 RK818_ID = 0x8181, 446 RK818_ID = 0x8181,
326}; 447};
diff --git a/include/linux/mfd/stm32-lptimer.h b/include/linux/mfd/stm32-lptimer.h
new file mode 100644
index 000000000000..77c7cf40d9b4
--- /dev/null
+++ b/include/linux/mfd/stm32-lptimer.h
@@ -0,0 +1,62 @@
1/*
2 * STM32 Low-Power Timer parent driver.
3 *
4 * Copyright (C) STMicroelectronics 2017
5 *
6 * Author: Fabrice Gasnier <fabrice.gasnier@st.com>
7 *
8 * Inspired by Benjamin Gaignard's stm32-timers driver
9 *
10 * License terms: GNU General Public License (GPL), version 2
11 */
12
13#ifndef _LINUX_STM32_LPTIMER_H_
14#define _LINUX_STM32_LPTIMER_H_
15
16#include <linux/clk.h>
17#include <linux/regmap.h>
18
19#define STM32_LPTIM_ISR 0x00 /* Interrupt and Status Reg */
20#define STM32_LPTIM_ICR 0x04 /* Interrupt Clear Reg */
21#define STM32_LPTIM_IER 0x08 /* Interrupt Enable Reg */
22#define STM32_LPTIM_CFGR 0x0C /* Configuration Reg */
23#define STM32_LPTIM_CR 0x10 /* Control Reg */
24#define STM32_LPTIM_CMP 0x14 /* Compare Reg */
25#define STM32_LPTIM_ARR 0x18 /* Autoreload Reg */
26#define STM32_LPTIM_CNT 0x1C /* Counter Reg */
27
28/* STM32_LPTIM_ISR - bit fields */
29#define STM32_LPTIM_CMPOK_ARROK GENMASK(4, 3)
30#define STM32_LPTIM_ARROK BIT(4)
31#define STM32_LPTIM_CMPOK BIT(3)
32
33/* STM32_LPTIM_ICR - bit fields */
34#define STM32_LPTIM_CMPOKCF_ARROKCF GENMASK(4, 3)
35
36/* STM32_LPTIM_CR - bit fields */
37#define STM32_LPTIM_CNTSTRT BIT(2)
38#define STM32_LPTIM_ENABLE BIT(0)
39
40/* STM32_LPTIM_CFGR - bit fields */
41#define STM32_LPTIM_ENC BIT(24)
42#define STM32_LPTIM_COUNTMODE BIT(23)
43#define STM32_LPTIM_WAVPOL BIT(21)
44#define STM32_LPTIM_PRESC GENMASK(11, 9)
45#define STM32_LPTIM_CKPOL GENMASK(2, 1)
46
47/* STM32_LPTIM_ARR */
48#define STM32_LPTIM_MAX_ARR 0xFFFF
49
50/**
51 * struct stm32_lptimer - STM32 Low-Power Timer data assigned by parent device
52 * @clk: clock reference for this instance
53 * @regmap: register map reference for this instance
54 * @has_encoder: indicates this Low-Power Timer supports encoder mode
55 */
56struct stm32_lptimer {
57 struct clk *clk;
58 struct regmap *regmap;
59 bool has_encoder;
60};
61
62#endif
diff --git a/include/linux/mfd/syscon/atmel-smc.h b/include/linux/mfd/syscon/atmel-smc.h
index afa266169800..7a367f34b66a 100644
--- a/include/linux/mfd/syscon/atmel-smc.h
+++ b/include/linux/mfd/syscon/atmel-smc.h
@@ -15,21 +15,26 @@
15#define _LINUX_MFD_SYSCON_ATMEL_SMC_H_ 15#define _LINUX_MFD_SYSCON_ATMEL_SMC_H_
16 16
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/of.h>
18#include <linux/regmap.h> 19#include <linux/regmap.h>
19 20
20#define ATMEL_SMC_SETUP(cs) (((cs) * 0x10)) 21#define ATMEL_SMC_SETUP(cs) (((cs) * 0x10))
21#define ATMEL_HSMC_SETUP(cs) (0x600 + ((cs) * 0x14)) 22#define ATMEL_HSMC_SETUP(layout, cs) \
23 ((layout)->timing_regs_offset + ((cs) * 0x14))
22#define ATMEL_SMC_PULSE(cs) (((cs) * 0x10) + 0x4) 24#define ATMEL_SMC_PULSE(cs) (((cs) * 0x10) + 0x4)
23#define ATMEL_HSMC_PULSE(cs) (0x600 + ((cs) * 0x14) + 0x4) 25#define ATMEL_HSMC_PULSE(layout, cs) \
26 ((layout)->timing_regs_offset + ((cs) * 0x14) + 0x4)
24#define ATMEL_SMC_CYCLE(cs) (((cs) * 0x10) + 0x8) 27#define ATMEL_SMC_CYCLE(cs) (((cs) * 0x10) + 0x8)
25#define ATMEL_HSMC_CYCLE(cs) (0x600 + ((cs) * 0x14) + 0x8) 28#define ATMEL_HSMC_CYCLE(layout, cs) \
29 ((layout)->timing_regs_offset + ((cs) * 0x14) + 0x8)
26#define ATMEL_SMC_NWE_SHIFT 0 30#define ATMEL_SMC_NWE_SHIFT 0
27#define ATMEL_SMC_NCS_WR_SHIFT 8 31#define ATMEL_SMC_NCS_WR_SHIFT 8
28#define ATMEL_SMC_NRD_SHIFT 16 32#define ATMEL_SMC_NRD_SHIFT 16
29#define ATMEL_SMC_NCS_RD_SHIFT 24 33#define ATMEL_SMC_NCS_RD_SHIFT 24
30 34
31#define ATMEL_SMC_MODE(cs) (((cs) * 0x10) + 0xc) 35#define ATMEL_SMC_MODE(cs) (((cs) * 0x10) + 0xc)
32#define ATMEL_HSMC_MODE(cs) (0x600 + ((cs) * 0x14) + 0x10) 36#define ATMEL_HSMC_MODE(layout, cs) \
37 ((layout)->timing_regs_offset + ((cs) * 0x14) + 0x10)
33#define ATMEL_SMC_MODE_READMODE_MASK BIT(0) 38#define ATMEL_SMC_MODE_READMODE_MASK BIT(0)
34#define ATMEL_SMC_MODE_READMODE_NCS (0 << 0) 39#define ATMEL_SMC_MODE_READMODE_NCS (0 << 0)
35#define ATMEL_SMC_MODE_READMODE_NRD (1 << 0) 40#define ATMEL_SMC_MODE_READMODE_NRD (1 << 0)
@@ -59,7 +64,8 @@
59#define ATMEL_SMC_MODE_PS_16 (2 << 28) 64#define ATMEL_SMC_MODE_PS_16 (2 << 28)
60#define ATMEL_SMC_MODE_PS_32 (3 << 28) 65#define ATMEL_SMC_MODE_PS_32 (3 << 28)
61 66
62#define ATMEL_HSMC_TIMINGS(cs) (0x600 + ((cs) * 0x14) + 0xc) 67#define ATMEL_HSMC_TIMINGS(layout, cs) \
68 ((layout)->timing_regs_offset + ((cs) * 0x14) + 0xc)
63#define ATMEL_HSMC_TIMINGS_OCMS BIT(12) 69#define ATMEL_HSMC_TIMINGS_OCMS BIT(12)
64#define ATMEL_HSMC_TIMINGS_RBNSEL(x) ((x) << 28) 70#define ATMEL_HSMC_TIMINGS_RBNSEL(x) ((x) << 28)
65#define ATMEL_HSMC_TIMINGS_NFSEL BIT(31) 71#define ATMEL_HSMC_TIMINGS_NFSEL BIT(31)
@@ -69,6 +75,10 @@
69#define ATMEL_HSMC_TIMINGS_TRR_SHIFT 16 75#define ATMEL_HSMC_TIMINGS_TRR_SHIFT 16
70#define ATMEL_HSMC_TIMINGS_TWB_SHIFT 24 76#define ATMEL_HSMC_TIMINGS_TWB_SHIFT 24
71 77
78struct atmel_hsmc_reg_layout {
79 unsigned int timing_regs_offset;
80};
81
72/** 82/**
73 * struct atmel_smc_cs_conf - SMC CS config as described in the datasheet. 83 * struct atmel_smc_cs_conf - SMC CS config as described in the datasheet.
74 * @setup: NCS/NWE/NRD setup timings (not applicable to at91rm9200) 84 * @setup: NCS/NWE/NRD setup timings (not applicable to at91rm9200)
@@ -98,11 +108,15 @@ int atmel_smc_cs_conf_set_cycle(struct atmel_smc_cs_conf *conf,
98 unsigned int shift, unsigned int ncycles); 108 unsigned int shift, unsigned int ncycles);
99void atmel_smc_cs_conf_apply(struct regmap *regmap, int cs, 109void atmel_smc_cs_conf_apply(struct regmap *regmap, int cs,
100 const struct atmel_smc_cs_conf *conf); 110 const struct atmel_smc_cs_conf *conf);
101void atmel_hsmc_cs_conf_apply(struct regmap *regmap, int cs, 111void atmel_hsmc_cs_conf_apply(struct regmap *regmap,
102 const struct atmel_smc_cs_conf *conf); 112 const struct atmel_hsmc_reg_layout *reglayout,
113 int cs, const struct atmel_smc_cs_conf *conf);
103void atmel_smc_cs_conf_get(struct regmap *regmap, int cs, 114void atmel_smc_cs_conf_get(struct regmap *regmap, int cs,
104 struct atmel_smc_cs_conf *conf); 115 struct atmel_smc_cs_conf *conf);
105void atmel_hsmc_cs_conf_get(struct regmap *regmap, int cs, 116void atmel_hsmc_cs_conf_get(struct regmap *regmap,
106 struct atmel_smc_cs_conf *conf); 117 const struct atmel_hsmc_reg_layout *reglayout,
118 int cs, struct atmel_smc_cs_conf *conf);
119const struct atmel_hsmc_reg_layout *
120atmel_hsmc_get_reg_layout(struct device_node *np);
107 121
108#endif /* _LINUX_MFD_SYSCON_ATMEL_SMC_H_ */ 122#endif /* _LINUX_MFD_SYSCON_ATMEL_SMC_H_ */
diff --git a/include/linux/i2c/tps65010.h b/include/linux/mfd/tps65010.h
index 08aa92278d71..a1fb9bc5311d 100644
--- a/include/linux/i2c/tps65010.h
+++ b/include/linux/mfd/tps65010.h
@@ -1,4 +1,4 @@
1/* linux/i2c/tps65010.h 1/* linux/mfd/tps65010.h
2 * 2 *
3 * Functions to access TPS65010 power management device. 3 * Functions to access TPS65010 power management device.
4 * 4 *
diff --git a/include/linux/mfd/tps68470.h b/include/linux/mfd/tps68470.h
new file mode 100644
index 000000000000..44f9d9f647ed
--- /dev/null
+++ b/include/linux/mfd/tps68470.h
@@ -0,0 +1,97 @@
1/*
2 * Copyright (c) 2017 Intel Corporation
3 *
4 * Functions to access TPS68470 power management chip.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation version 2.
9 *
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef __LINUX_MFD_TPS68470_H
17#define __LINUX_MFD_TPS68470_H
18
19/* Register addresses */
20#define TPS68470_REG_POSTDIV2 0x06
21#define TPS68470_REG_BOOSTDIV 0x07
22#define TPS68470_REG_BUCKDIV 0x08
23#define TPS68470_REG_PLLSWR 0x09
24#define TPS68470_REG_XTALDIV 0x0A
25#define TPS68470_REG_PLLDIV 0x0B
26#define TPS68470_REG_POSTDIV 0x0C
27#define TPS68470_REG_PLLCTL 0x0D
28#define TPS68470_REG_PLLCTL2 0x0E
29#define TPS68470_REG_CLKCFG1 0x0F
30#define TPS68470_REG_CLKCFG2 0x10
31#define TPS68470_REG_GPCTL0A 0x14
32#define TPS68470_REG_GPCTL0B 0x15
33#define TPS68470_REG_GPCTL1A 0x16
34#define TPS68470_REG_GPCTL1B 0x17
35#define TPS68470_REG_GPCTL2A 0x18
36#define TPS68470_REG_GPCTL2B 0x19
37#define TPS68470_REG_GPCTL3A 0x1A
38#define TPS68470_REG_GPCTL3B 0x1B
39#define TPS68470_REG_GPCTL4A 0x1C
40#define TPS68470_REG_GPCTL4B 0x1D
41#define TPS68470_REG_GPCTL5A 0x1E
42#define TPS68470_REG_GPCTL5B 0x1F
43#define TPS68470_REG_GPCTL6A 0x20
44#define TPS68470_REG_GPCTL6B 0x21
45#define TPS68470_REG_SGPO 0x22
46#define TPS68470_REG_GPDI 0x26
47#define TPS68470_REG_GPDO 0x27
48#define TPS68470_REG_VCMVAL 0x3C
49#define TPS68470_REG_VAUX1VAL 0x3D
50#define TPS68470_REG_VAUX2VAL 0x3E
51#define TPS68470_REG_VIOVAL 0x3F
52#define TPS68470_REG_VSIOVAL 0x40
53#define TPS68470_REG_VAVAL 0x41
54#define TPS68470_REG_VDVAL 0x42
55#define TPS68470_REG_S_I2C_CTL 0x43
56#define TPS68470_REG_VCMCTL 0x44
57#define TPS68470_REG_VAUX1CTL 0x45
58#define TPS68470_REG_VAUX2CTL 0x46
59#define TPS68470_REG_VACTL 0x47
60#define TPS68470_REG_VDCTL 0x48
61#define TPS68470_REG_RESET 0x50
62#define TPS68470_REG_REVID 0xFF
63
64#define TPS68470_REG_MAX TPS68470_REG_REVID
65
66/* Register field definitions */
67
68#define TPS68470_REG_RESET_MASK GENMASK(7, 0)
69#define TPS68470_VAVAL_AVOLT_MASK GENMASK(6, 0)
70
71#define TPS68470_VDVAL_DVOLT_MASK GENMASK(5, 0)
72#define TPS68470_VCMVAL_VCVOLT_MASK GENMASK(6, 0)
73#define TPS68470_VIOVAL_IOVOLT_MASK GENMASK(6, 0)
74#define TPS68470_VSIOVAL_IOVOLT_MASK GENMASK(6, 0)
75#define TPS68470_VAUX1VAL_AUX1VOLT_MASK GENMASK(6, 0)
76#define TPS68470_VAUX2VAL_AUX2VOLT_MASK GENMASK(6, 0)
77
78#define TPS68470_VACTL_EN_MASK GENMASK(0, 0)
79#define TPS68470_VDCTL_EN_MASK GENMASK(0, 0)
80#define TPS68470_VCMCTL_EN_MASK GENMASK(0, 0)
81#define TPS68470_S_I2C_CTL_EN_MASK GENMASK(1, 0)
82#define TPS68470_VAUX1CTL_EN_MASK GENMASK(0, 0)
83#define TPS68470_VAUX2CTL_EN_MASK GENMASK(0, 0)
84#define TPS68470_PLL_EN_MASK GENMASK(0, 0)
85
86#define TPS68470_CLKCFG1_MODE_A_MASK GENMASK(1, 0)
87#define TPS68470_CLKCFG1_MODE_B_MASK GENMASK(3, 2)
88
89#define TPS68470_GPIO_CTL_REG_A(x) (TPS68470_REG_GPCTL0A + (x) * 2)
90#define TPS68470_GPIO_CTL_REG_B(x) (TPS68470_REG_GPCTL0B + (x) * 2)
91#define TPS68470_GPIO_MODE_MASK GENMASK(1, 0)
92#define TPS68470_GPIO_MODE_IN 0
93#define TPS68470_GPIO_MODE_IN_PULLUP 1
94#define TPS68470_GPIO_MODE_OUT_CMOS 2
95#define TPS68470_GPIO_MODE_OUT_ODRAIN 3
96
97#endif /* __LINUX_MFD_TPS68470_H */
diff --git a/include/linux/i2c/twl.h b/include/linux/mfd/twl.h
index 9ad7828d9d34..9ad7828d9d34 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/mfd/twl.h
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index d439c4c6fe50..c482b2e7a7d2 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -28,7 +28,7 @@
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/of.h> 29#include <linux/of.h>
30#include <linux/of_gpio.h> 30#include <linux/of_gpio.h>
31#include <linux/i2c/twl.h> 31#include <linux/mfd/twl.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/gpio.h> 33#include <linux/gpio.h>
34#include <sound/core.h> 34#include <sound/core.h>