aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-08 23:02:54 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-08 23:02:54 -0500
commit3a7dbed7f23cdde8394e9adf92cc222856e0fc1e (patch)
treea83fa52d24d2457acadf4c1bc72ea3a3e294b57d
parentf2fb38049c724558c590c31e57627f6ba8d48a5b (diff)
parenta3b63979f8a32af9e975a793fd0f612d42072740 (diff)
Merge tag 'mfd-for-linus-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd
Pull MFD updates from Lee Jones: "Changes to the core: - Honour PLATFORM_DEVID_NONE and PLATFORM_DEVID_AUTO dev IDs Changes to existing drivers: - IRQ additions/fixes; axp20x, da9063-core - Code simplification; i2c-dln2 - Regmap additions/fixes; max77693 - Error checking/handling improvements; dln2, db8500-prcmu - Bug fixes; dln2, wm8350-core - DT support/documentation; max77693, max77686, tps65217, twl4030-power, gpio-tc3589x - Decouple syscon interface from platform devices - Use MFD hotplug registration; rtsx_usb, viperboard, hid-sensor-hub - Regulator fixups; sec-core - Power Management additions/fixes; rts5227, tc6393xb - Remove relic/redundant code; ab8500-sysctrl, lpc_sch, max77693-private - Clean-up/coding style changes; tps65090 - Clk additions/fixes; tc6393xb, tc6387xb, t7l66xb - Add USB-SPI support; dln2 - Trivial changes; max14577, arizona-spi, lpc_sch, wm8997-tables, wm5102-tables wm5110-tables, axp20x, atmel-hlcdc, rtsx_pci New drivers/supported devices: - axp288 PMIC support added to axp20x - s2mps13 support added to sec-core - New support for Diolan DLN-2 - New support for atmel-hlcdc" * tag 'mfd-for-linus-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (55 commits) mfd: rtsx: Add func to split u32 into register mfd: atmel-hlcdc: Add Kconfig option description and name mfd: da9063: Get irq base dynamically before registering device mfd: max14577: Fix obvious typo in company name in copyright mfd: axp20x: Constify axp20x_acpi_match and rid unused warning mfd: t7l66xb: prepare/unprepare clocks mfd: tc6387xb: prepare/unprepare clocks mfd: dln2: add support for USB-SPI module mfd: wm5110: Add missing registers for AIF2 channels 3-6 mfd: tc3589x: get rid of static base mfd: arizona: Document HP_CTRL_1L and HP_CTRL_1R registers mfd: wm8997: Mark INTERRUPT_STATUS_2_MASK as readable mfd: tc6393xb: Prepare/unprepare clocks mfd: tps65090: Fix bonkers indenting strategy mfd: tc6393xb: Fail ohci suspend if full state restore is required mfd: lpc_sch: Don't call mfd_remove_devices() mfd: wm8350-core: Fix probable mask then right shift defect mfd: ab8500-sysctrl: Drop ab8500_restart mfd: db8500-prcmu: Provide sane error path values mfd: db8500-prcmu: Check return of devm_ioremap for error ...
-rw-r--r--Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt51
-rw-r--r--Documentation/devicetree/bindings/mfd/max77686.txt6
-rw-r--r--Documentation/devicetree/bindings/mfd/max77693.txt21
-rw-r--r--Documentation/devicetree/bindings/mfd/s2mps11.txt22
-rw-r--r--drivers/clk/clk-s2mps11.c24
-rw-r--r--drivers/gpio/Kconfig12
-rw-r--r--drivers/gpio/Makefile1
-rw-r--r--drivers/gpio/gpio-dln2.c553
-rw-r--r--drivers/gpio/gpio-tc3589x.c2
-rw-r--r--drivers/hid/hid-sensor-hub.c8
-rw-r--r--drivers/i2c/busses/Kconfig10
-rw-r--r--drivers/i2c/busses/Makefile1
-rw-r--r--drivers/i2c/busses/i2c-dln2.c262
-rw-r--r--drivers/iio/adc/Kconfig8
-rw-r--r--drivers/iio/adc/Makefile1
-rw-r--r--drivers/iio/adc/axp288_adc.c261
-rw-r--r--drivers/mfd/Kconfig25
-rw-r--r--drivers/mfd/Makefile4
-rw-r--r--drivers/mfd/ab8500-sysctrl.c57
-rw-r--r--drivers/mfd/arizona-spi.c2
-rw-r--r--drivers/mfd/atmel-hlcdc.c122
-rw-r--r--drivers/mfd/axp20x.c361
-rw-r--r--drivers/mfd/da9063-core.c4
-rw-r--r--drivers/mfd/db8500-prcmu.c22
-rw-r--r--drivers/mfd/dln2.c781
-rw-r--r--drivers/mfd/lpc_sch.c6
-rw-r--r--drivers/mfd/max14577.c2
-rw-r--r--drivers/mfd/max77693.c31
-rw-r--r--drivers/mfd/mfd-core.c8
-rw-r--r--drivers/mfd/rts5227.c6
-rw-r--r--drivers/mfd/rts5249.c4
-rw-r--r--drivers/mfd/rtsx_gops.c37
-rw-r--r--drivers/mfd/rtsx_pcr.h3
-rw-r--r--drivers/mfd/rtsx_usb.c4
-rw-r--r--drivers/mfd/sec-core.c39
-rw-r--r--drivers/mfd/sec-irq.c23
-rw-r--r--drivers/mfd/syscon.c96
-rw-r--r--drivers/mfd/t7l66xb.c14
-rw-r--r--drivers/mfd/tc3589x.c9
-rw-r--r--drivers/mfd/tc6387xb.c10
-rw-r--r--drivers/mfd/tc6393xb.c23
-rw-r--r--drivers/mfd/tps65090.c62
-rw-r--r--drivers/mfd/tps65217.c2
-rw-r--r--drivers/mfd/twl4030-power.c3
-rw-r--r--drivers/mfd/viperboard.c5
-rw-r--r--drivers/mfd/wm5102-tables.c6
-rw-r--r--drivers/mfd/wm5110-tables.c20
-rw-r--r--drivers/mfd/wm8350-core.c2
-rw-r--r--drivers/mfd/wm8997-tables.c6
-rw-r--r--drivers/regulator/Kconfig10
-rw-r--r--drivers/regulator/s2mps11.c102
-rw-r--r--include/linux/mfd/abx500/ab8500-sysctrl.h1
-rw-r--r--include/linux/mfd/arizona/registers.h50
-rw-r--r--include/linux/mfd/atmel-hlcdc.h85
-rw-r--r--include/linux/mfd/axp20x.h59
-rw-r--r--include/linux/mfd/core.h7
-rw-r--r--include/linux/mfd/dln2.h103
-rw-r--r--include/linux/mfd/max77693-private.h1
-rw-r--r--include/linux/mfd/rtsx_pci.h37
-rw-r--r--include/linux/mfd/samsung/core.h2
-rw-r--r--include/linux/mfd/samsung/s2mps13.h186
-rw-r--r--include/linux/mfd/tc3589x.h8
-rw-r--r--include/linux/of.h11
63 files changed, 3431 insertions, 273 deletions
diff --git a/Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt b/Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt
new file mode 100644
index 000000000000..f64de95a8e8b
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/atmel-hlcdc.txt
@@ -0,0 +1,51 @@
1Device-Tree bindings for Atmel's HLCDC (High LCD Controller) MFD driver
2
3Required properties:
4 - compatible: value should be one of the following:
5 "atmel,sama5d3-hlcdc"
6 - reg: base address and size of the HLCDC device registers.
7 - clock-names: the name of the 3 clocks requested by the HLCDC device.
8 Should contain "periph_clk", "sys_clk" and "slow_clk".
9 - clocks: should contain the 3 clocks requested by the HLCDC device.
10 - interrupts: should contain the description of the HLCDC interrupt line
11
12The HLCDC IP exposes two subdevices:
13 - a PWM chip: see ../pwm/atmel-hlcdc-pwm.txt
14 - a Display Controller: see ../drm/atmel-hlcdc-dc.txt
15
16Example:
17
18 hlcdc: hlcdc@f0030000 {
19 compatible = "atmel,sama5d3-hlcdc";
20 reg = <0xf0030000 0x2000>;
21 clocks = <&lcdc_clk>, <&lcdck>, <&clk32k>;
22 clock-names = "periph_clk","sys_clk", "slow_clk";
23 interrupts = <36 IRQ_TYPE_LEVEL_HIGH 0>;
24 status = "disabled";
25
26 hlcdc-display-controller {
27 compatible = "atmel,hlcdc-display-controller";
28 pinctrl-names = "default";
29 pinctrl-0 = <&pinctrl_lcd_base &pinctrl_lcd_rgb888>;
30 #address-cells = <1>;
31 #size-cells = <0>;
32
33 port@0 {
34 #address-cells = <1>;
35 #size-cells = <0>;
36 reg = <0>;
37
38 hlcdc_panel_output: endpoint@0 {
39 reg = <0>;
40 remote-endpoint = <&panel_input>;
41 };
42 };
43 };
44
45 hlcdc_pwm: hlcdc-pwm {
46 compatible = "atmel,hlcdc-pwm";
47 pinctrl-names = "default";
48 pinctrl-0 = <&pinctrl_lcd_pwm>;
49 #pwm-cells = <3>;
50 };
51 };
diff --git a/Documentation/devicetree/bindings/mfd/max77686.txt b/Documentation/devicetree/bindings/mfd/max77686.txt
index 678f3cf0b8f0..75fdfaf41831 100644
--- a/Documentation/devicetree/bindings/mfd/max77686.txt
+++ b/Documentation/devicetree/bindings/mfd/max77686.txt
@@ -34,6 +34,12 @@ to get matched with their hardware counterparts as follow:
34 -BUCKn : for BUCKs, where n can lie in range 1 to 9. 34 -BUCKn : for BUCKs, where n can lie in range 1 to 9.
35 example: BUCK1, BUCK5, BUCK9. 35 example: BUCK1, BUCK5, BUCK9.
36 36
37 Regulators which can be turned off during system suspend:
38 -LDOn : 2, 6-8, 10-12, 14-16,
39 -BUCKn : 1-4.
40 Use standard regulator bindings for it ('regulator-off-in-suspend').
41
42
37Example: 43Example:
38 44
39 max77686@09 { 45 max77686@09 {
diff --git a/Documentation/devicetree/bindings/mfd/max77693.txt b/Documentation/devicetree/bindings/mfd/max77693.txt
index 11921cc417bf..01e9f30fe678 100644
--- a/Documentation/devicetree/bindings/mfd/max77693.txt
+++ b/Documentation/devicetree/bindings/mfd/max77693.txt
@@ -27,6 +27,20 @@ Optional properties:
27 27
28 [*] refer Documentation/devicetree/bindings/regulator/regulator.txt 28 [*] refer Documentation/devicetree/bindings/regulator/regulator.txt
29 29
30- haptic : The MAX77693 haptic device utilises a PWM controlled motor to provide
31 users with tactile feedback. PWM period and duty-cycle are varied in
32 order to provide the approprite level of feedback.
33
34 Required properties:
35 - compatible : Must be "maxim,max77693-hpatic"
36 - haptic-supply : power supply for the haptic motor
37 [*] refer Documentation/devicetree/bindings/regulator/regulator.txt
38 - pwms : phandle to the physical PWM(Pulse Width Modulation) device.
39 PWM properties should be named "pwms". And number of cell is different
40 for each pwm device.
41 To get more informations, please refer to documentaion.
42 [*] refer Documentation/devicetree/bindings/pwm/pwm.txt
43
30Example: 44Example:
31 max77693@66 { 45 max77693@66 {
32 compatible = "maxim,max77693"; 46 compatible = "maxim,max77693";
@@ -52,4 +66,11 @@ Example:
52 regulator-boot-on; 66 regulator-boot-on;
53 }; 67 };
54 }; 68 };
69
70 haptic {
71 compatible = "maxim,max77693-haptic";
72 haptic-supply = <&haptic_supply>;
73 pwms = <&pwm 0 40000 0>;
74 pwm-names = "haptic";
75 };
55 }; 76 };
diff --git a/Documentation/devicetree/bindings/mfd/s2mps11.txt b/Documentation/devicetree/bindings/mfd/s2mps11.txt
index 0e4026a6cbbf..57a045016fca 100644
--- a/Documentation/devicetree/bindings/mfd/s2mps11.txt
+++ b/Documentation/devicetree/bindings/mfd/s2mps11.txt
@@ -1,5 +1,5 @@
1 1
2* Samsung S2MPS11, S2MPS14 and S2MPU02 Voltage and Current Regulator 2* Samsung S2MPS11, S2MPS13, S2MPS14 and S2MPU02 Voltage and Current Regulator
3 3
4The Samsung S2MPS11 is a multi-function device which includes voltage and 4The Samsung S2MPS11 is a multi-function device which includes voltage and
5current regulators, RTC, charger controller and other sub-blocks. It is 5current regulators, RTC, charger controller and other sub-blocks. It is
@@ -7,8 +7,8 @@ interfaced to the host controller using an I2C interface. Each sub-block is
7addressed by the host system using different I2C slave addresses. 7addressed by the host system using different I2C slave addresses.
8 8
9Required properties: 9Required properties:
10- compatible: Should be "samsung,s2mps11-pmic" or "samsung,s2mps14-pmic" 10- compatible: Should be "samsung,s2mps11-pmic" or "samsung,s2mps13-pmic"
11 or "samsung,s2mpu02-pmic". 11 or "samsung,s2mps14-pmic" or "samsung,s2mpu02-pmic".
12- reg: Specifies the I2C slave address of the pmic block. It should be 0x66. 12- reg: Specifies the I2C slave address of the pmic block. It should be 0x66.
13 13
14Optional properties: 14Optional properties:
@@ -17,8 +17,8 @@ Optional properties:
17- interrupts: Interrupt specifiers for interrupt sources. 17- interrupts: Interrupt specifiers for interrupt sources.
18 18
19Optional nodes: 19Optional nodes:
20- clocks: s2mps11 and s5m8767 provide three(AP/CP/BT) buffered 32.768 KHz 20- clocks: s2mps11, s2mps13 and s5m8767 provide three(AP/CP/BT) buffered 32.768
21 outputs, so to register these as clocks with common clock framework 21 KHz outputs, so to register these as clocks with common clock framework
22 instantiate a sub-node named "clocks". It uses the common clock binding 22 instantiate a sub-node named "clocks". It uses the common clock binding
23 documented in : 23 documented in :
24 [Documentation/devicetree/bindings/clock/clock-bindings.txt] 24 [Documentation/devicetree/bindings/clock/clock-bindings.txt]
@@ -30,12 +30,12 @@ Optional nodes:
30 the clock which they consume. 30 the clock which they consume.
31 Clock ID Devices 31 Clock ID Devices
32 ---------------------------------------------------------- 32 ----------------------------------------------------------
33 32KhzAP 0 S2MPS11, S2MPS14, S5M8767 33 32KhzAP 0 S2MPS11, S2MPS13, S2MPS14, S5M8767
34 32KhzCP 1 S2MPS11, S5M8767 34 32KhzCP 1 S2MPS11, S2MPS13, S5M8767
35 32KhzBT 2 S2MPS11, S2MPS14, S5M8767 35 32KhzBT 2 S2MPS11, S2MPS13, S2MPS14, S5M8767
36 36
37 - compatible: Should be one of: "samsung,s2mps11-clk", "samsung,s2mps14-clk", 37 - compatible: Should be one of: "samsung,s2mps11-clk", "samsung,s2mps13-clk",
38 "samsung,s5m8767-clk" 38 "samsung,s2mps14-clk", "samsung,s5m8767-clk"
39 39
40- regulators: The regulators of s2mps11 that have to be instantiated should be 40- regulators: The regulators of s2mps11 that have to be instantiated should be
41included in a sub-node named 'regulators'. Regulator nodes included in this 41included in a sub-node named 'regulators'. Regulator nodes included in this
@@ -81,12 +81,14 @@ as per the datasheet of s2mps11.
81 - LDOn 81 - LDOn
82 - valid values for n are: 82 - valid values for n are:
83 - S2MPS11: 1 to 38 83 - S2MPS11: 1 to 38
84 - S2MPS13: 1 to 40
84 - S2MPS14: 1 to 25 85 - S2MPS14: 1 to 25
85 - S2MPU02: 1 to 28 86 - S2MPU02: 1 to 28
86 - Example: LDO1, LDO2, LDO28 87 - Example: LDO1, LDO2, LDO28
87 - BUCKn 88 - BUCKn
88 - valid values for n are: 89 - valid values for n are:
89 - S2MPS11: 1 to 10 90 - S2MPS11: 1 to 10
91 - S2MPS13: 1 to 10
90 - S2MPS14: 1 to 5 92 - S2MPS14: 1 to 5
91 - S2MPU02: 1 to 7 93 - S2MPU02: 1 to 7
92 - Example: BUCK1, BUCK2, BUCK9 94 - Example: BUCK1, BUCK2, BUCK9
diff --git a/drivers/clk/clk-s2mps11.c b/drivers/clk/clk-s2mps11.c
index b7797fb12e12..7bb13af8e214 100644
--- a/drivers/clk/clk-s2mps11.c
+++ b/drivers/clk/clk-s2mps11.c
@@ -23,6 +23,7 @@
23#include <linux/clk-provider.h> 23#include <linux/clk-provider.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/mfd/samsung/s2mps11.h> 25#include <linux/mfd/samsung/s2mps11.h>
26#include <linux/mfd/samsung/s2mps13.h>
26#include <linux/mfd/samsung/s2mps14.h> 27#include <linux/mfd/samsung/s2mps14.h>
27#include <linux/mfd/samsung/s5m8767.h> 28#include <linux/mfd/samsung/s5m8767.h>
28#include <linux/mfd/samsung/core.h> 29#include <linux/mfd/samsung/core.h>
@@ -120,6 +121,24 @@ static struct clk_init_data s2mps11_clks_init[S2MPS11_CLKS_NUM] = {
120 }, 121 },
121}; 122};
122 123
124static struct clk_init_data s2mps13_clks_init[S2MPS11_CLKS_NUM] = {
125 [S2MPS11_CLK_AP] = {
126 .name = "s2mps13_ap",
127 .ops = &s2mps11_clk_ops,
128 .flags = CLK_IS_ROOT,
129 },
130 [S2MPS11_CLK_CP] = {
131 .name = "s2mps13_cp",
132 .ops = &s2mps11_clk_ops,
133 .flags = CLK_IS_ROOT,
134 },
135 [S2MPS11_CLK_BT] = {
136 .name = "s2mps13_bt",
137 .ops = &s2mps11_clk_ops,
138 .flags = CLK_IS_ROOT,
139 },
140};
141
123static struct clk_init_data s2mps14_clks_init[S2MPS11_CLKS_NUM] = { 142static struct clk_init_data s2mps14_clks_init[S2MPS11_CLKS_NUM] = {
124 [S2MPS11_CLK_AP] = { 143 [S2MPS11_CLK_AP] = {
125 .name = "s2mps14_ap", 144 .name = "s2mps14_ap",
@@ -184,6 +203,10 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
184 s2mps11_reg = S2MPS11_REG_RTC_CTRL; 203 s2mps11_reg = S2MPS11_REG_RTC_CTRL;
185 clks_init = s2mps11_clks_init; 204 clks_init = s2mps11_clks_init;
186 break; 205 break;
206 case S2MPS13X:
207 s2mps11_reg = S2MPS13_REG_RTCCTRL;
208 clks_init = s2mps13_clks_init;
209 break;
187 case S2MPS14X: 210 case S2MPS14X:
188 s2mps11_reg = S2MPS14_REG_RTCCTRL; 211 s2mps11_reg = S2MPS14_REG_RTCCTRL;
189 clks_init = s2mps14_clks_init; 212 clks_init = s2mps14_clks_init;
@@ -279,6 +302,7 @@ static int s2mps11_clk_remove(struct platform_device *pdev)
279 302
280static const struct platform_device_id s2mps11_clk_id[] = { 303static const struct platform_device_id s2mps11_clk_id[] = {
281 { "s2mps11-clk", S2MPS11X}, 304 { "s2mps11-clk", S2MPS11X},
305 { "s2mps13-clk", S2MPS13X},
282 { "s2mps14-clk", S2MPS14X}, 306 { "s2mps14-clk", S2MPS14X},
283 { "s5m8767-clk", S5M8767X}, 307 { "s5m8767-clk", S5M8767X},
284 { }, 308 { },
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 0959ca9b6b27..23dfd5f59b39 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -905,4 +905,16 @@ config GPIO_VIPERBOARD
905 River Tech's viperboard.h for detailed meaning 905 River Tech's viperboard.h for detailed meaning
906 of the module parameters. 906 of the module parameters.
907 907
908config GPIO_DLN2
909 tristate "Diolan DLN2 GPIO support"
910 depends on MFD_DLN2
911 select GPIOLIB_IRQCHIP
912
913 help
914 Select this option to enable GPIO driver for the Diolan DLN2
915 board.
916
917 This driver can also be built as a module. If so, the module
918 will be called gpio-dln2.
919
908endif 920endif
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index e5d346cf3b6e..e60677b8ccb4 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_GPIO_CRYSTAL_COVE) += gpio-crystalcove.o
26obj-$(CONFIG_GPIO_DA9052) += gpio-da9052.o 26obj-$(CONFIG_GPIO_DA9052) += gpio-da9052.o
27obj-$(CONFIG_GPIO_DA9055) += gpio-da9055.o 27obj-$(CONFIG_GPIO_DA9055) += gpio-da9055.o
28obj-$(CONFIG_GPIO_DAVINCI) += gpio-davinci.o 28obj-$(CONFIG_GPIO_DAVINCI) += gpio-davinci.o
29obj-$(CONFIG_GPIO_DLN2) += gpio-dln2.o
29obj-$(CONFIG_GPIO_DWAPB) += gpio-dwapb.o 30obj-$(CONFIG_GPIO_DWAPB) += gpio-dwapb.o
30obj-$(CONFIG_GPIO_EM) += gpio-em.o 31obj-$(CONFIG_GPIO_EM) += gpio-em.o
31obj-$(CONFIG_GPIO_EP93XX) += gpio-ep93xx.o 32obj-$(CONFIG_GPIO_EP93XX) += gpio-ep93xx.o
diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c
new file mode 100644
index 000000000000..978b51eae2ec
--- /dev/null
+++ b/drivers/gpio/gpio-dln2.c
@@ -0,0 +1,553 @@
1/*
2 * Driver for the Diolan DLN-2 USB-GPIO adapter
3 *
4 * Copyright (c) 2014 Intel Corporation
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
11#include <linux/kernel.h>
12#include <linux/module.h>
13#include <linux/slab.h>
14#include <linux/types.h>
15#include <linux/irqdomain.h>
16#include <linux/irq.h>
17#include <linux/irqchip/chained_irq.h>
18#include <linux/gpio.h>
19#include <linux/gpio/driver.h>
20#include <linux/platform_device.h>
21#include <linux/mfd/dln2.h>
22
23#define DLN2_GPIO_ID 0x01
24
25#define DLN2_GPIO_GET_PIN_COUNT DLN2_CMD(0x01, DLN2_GPIO_ID)
26#define DLN2_GPIO_SET_DEBOUNCE DLN2_CMD(0x04, DLN2_GPIO_ID)
27#define DLN2_GPIO_GET_DEBOUNCE DLN2_CMD(0x05, DLN2_GPIO_ID)
28#define DLN2_GPIO_PORT_GET_VAL DLN2_CMD(0x06, DLN2_GPIO_ID)
29#define DLN2_GPIO_PIN_GET_VAL DLN2_CMD(0x0B, DLN2_GPIO_ID)
30#define DLN2_GPIO_PIN_SET_OUT_VAL DLN2_CMD(0x0C, DLN2_GPIO_ID)
31#define DLN2_GPIO_PIN_GET_OUT_VAL DLN2_CMD(0x0D, DLN2_GPIO_ID)
32#define DLN2_GPIO_CONDITION_MET_EV DLN2_CMD(0x0F, DLN2_GPIO_ID)
33#define DLN2_GPIO_PIN_ENABLE DLN2_CMD(0x10, DLN2_GPIO_ID)
34#define DLN2_GPIO_PIN_DISABLE DLN2_CMD(0x11, DLN2_GPIO_ID)
35#define DLN2_GPIO_PIN_SET_DIRECTION DLN2_CMD(0x13, DLN2_GPIO_ID)
36#define DLN2_GPIO_PIN_GET_DIRECTION DLN2_CMD(0x14, DLN2_GPIO_ID)
37#define DLN2_GPIO_PIN_SET_EVENT_CFG DLN2_CMD(0x1E, DLN2_GPIO_ID)
38#define DLN2_GPIO_PIN_GET_EVENT_CFG DLN2_CMD(0x1F, DLN2_GPIO_ID)
39
40#define DLN2_GPIO_EVENT_NONE 0
41#define DLN2_GPIO_EVENT_CHANGE 1
42#define DLN2_GPIO_EVENT_LVL_HIGH 2
43#define DLN2_GPIO_EVENT_LVL_LOW 3
44#define DLN2_GPIO_EVENT_CHANGE_RISING 0x11
45#define DLN2_GPIO_EVENT_CHANGE_FALLING 0x21
46#define DLN2_GPIO_EVENT_MASK 0x0F
47
48#define DLN2_GPIO_MAX_PINS 32
49
50struct dln2_irq_work {
51 struct work_struct work;
52 struct dln2_gpio *dln2;
53 int pin;
54 int type;
55};
56
57struct dln2_gpio {
58 struct platform_device *pdev;
59 struct gpio_chip gpio;
60
61 /*
62 * Cache pin direction to save us one transfer, since the hardware has
63 * separate commands to read the in and out values.
64 */
65 DECLARE_BITMAP(output_enabled, DLN2_GPIO_MAX_PINS);
66
67 DECLARE_BITMAP(irqs_masked, DLN2_GPIO_MAX_PINS);
68 DECLARE_BITMAP(irqs_enabled, DLN2_GPIO_MAX_PINS);
69 DECLARE_BITMAP(irqs_pending, DLN2_GPIO_MAX_PINS);
70 struct dln2_irq_work *irq_work;
71};
72
73struct dln2_gpio_pin {
74 __le16 pin;
75};
76
77struct dln2_gpio_pin_val {
78 __le16 pin __packed;
79 u8 value;
80};
81
82static int dln2_gpio_get_pin_count(struct platform_device *pdev)
83{
84 int ret;
85 __le16 count;
86 int len = sizeof(count);
87
88 ret = dln2_transfer_rx(pdev, DLN2_GPIO_GET_PIN_COUNT, &count, &len);
89 if (ret < 0)
90 return ret;
91 if (len < sizeof(count))
92 return -EPROTO;
93
94 return le16_to_cpu(count);
95}
96
97static int dln2_gpio_pin_cmd(struct dln2_gpio *dln2, int cmd, unsigned pin)
98{
99 struct dln2_gpio_pin req = {
100 .pin = cpu_to_le16(pin),
101 };
102
103 return dln2_transfer_tx(dln2->pdev, cmd, &req, sizeof(req));
104}
105
106static int dln2_gpio_pin_val(struct dln2_gpio *dln2, int cmd, unsigned int pin)
107{
108 int ret;
109 struct dln2_gpio_pin req = {
110 .pin = cpu_to_le16(pin),
111 };
112 struct dln2_gpio_pin_val rsp;
113 int len = sizeof(rsp);
114
115 ret = dln2_transfer(dln2->pdev, cmd, &req, sizeof(req), &rsp, &len);
116 if (ret < 0)
117 return ret;
118 if (len < sizeof(rsp) || req.pin != rsp.pin)
119 return -EPROTO;
120
121 return rsp.value;
122}
123
124static int dln2_gpio_pin_get_in_val(struct dln2_gpio *dln2, unsigned int pin)
125{
126 int ret;
127
128 ret = dln2_gpio_pin_val(dln2, DLN2_GPIO_PIN_GET_VAL, pin);
129 if (ret < 0)
130 return ret;
131 return !!ret;
132}
133
134static int dln2_gpio_pin_get_out_val(struct dln2_gpio *dln2, unsigned int pin)
135{
136 int ret;
137
138 ret = dln2_gpio_pin_val(dln2, DLN2_GPIO_PIN_GET_OUT_VAL, pin);
139 if (ret < 0)
140 return ret;
141 return !!ret;
142}
143
144static void dln2_gpio_pin_set_out_val(struct dln2_gpio *dln2,
145 unsigned int pin, int value)
146{
147 struct dln2_gpio_pin_val req = {
148 .pin = cpu_to_le16(pin),
149 .value = value,
150 };
151
152 dln2_transfer_tx(dln2->pdev, DLN2_GPIO_PIN_SET_OUT_VAL, &req,
153 sizeof(req));
154}
155
156#define DLN2_GPIO_DIRECTION_IN 0
157#define DLN2_GPIO_DIRECTION_OUT 1
158
159static int dln2_gpio_request(struct gpio_chip *chip, unsigned offset)
160{
161 struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio);
162 struct dln2_gpio_pin req = {
163 .pin = cpu_to_le16(offset),
164 };
165 struct dln2_gpio_pin_val rsp;
166 int len = sizeof(rsp);
167 int ret;
168
169 ret = dln2_gpio_pin_cmd(dln2, DLN2_GPIO_PIN_ENABLE, offset);
170 if (ret < 0)
171 return ret;
172
173 /* cache the pin direction */
174 ret = dln2_transfer(dln2->pdev, DLN2_GPIO_PIN_GET_DIRECTION,
175 &req, sizeof(req), &rsp, &len);
176 if (ret < 0)
177 return ret;
178 if (len < sizeof(rsp) || req.pin != rsp.pin) {
179 ret = -EPROTO;
180 goto out_disable;
181 }
182
183 switch (rsp.value) {
184 case DLN2_GPIO_DIRECTION_IN:
185 clear_bit(offset, dln2->output_enabled);
186 return 0;
187 case DLN2_GPIO_DIRECTION_OUT:
188 set_bit(offset, dln2->output_enabled);
189 return 0;
190 default:
191 ret = -EPROTO;
192 goto out_disable;
193 }
194
195out_disable:
196 dln2_gpio_pin_cmd(dln2, DLN2_GPIO_PIN_DISABLE, offset);
197 return ret;
198}
199
200static void dln2_gpio_free(struct gpio_chip *chip, unsigned offset)
201{
202 struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio);
203
204 dln2_gpio_pin_cmd(dln2, DLN2_GPIO_PIN_DISABLE, offset);
205}
206
207static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
208{
209 struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio);
210
211 if (test_bit(offset, dln2->output_enabled))
212 return GPIOF_DIR_OUT;
213
214 return GPIOF_DIR_IN;
215}
216
217static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
218{
219 struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio);
220 int dir;
221
222 dir = dln2_gpio_get_direction(chip, offset);
223 if (dir < 0)
224 return dir;
225
226 if (dir == GPIOF_DIR_IN)
227 return dln2_gpio_pin_get_in_val(dln2, offset);
228
229 return dln2_gpio_pin_get_out_val(dln2, offset);
230}
231
232static void dln2_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
233{
234 struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio);
235
236 dln2_gpio_pin_set_out_val(dln2, offset, value);
237}
238
239static int dln2_gpio_set_direction(struct gpio_chip *chip, unsigned offset,
240 unsigned dir)
241{
242 struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio);
243 struct dln2_gpio_pin_val req = {
244 .pin = cpu_to_le16(offset),
245 .value = dir,
246 };
247 int ret;
248
249 ret = dln2_transfer_tx(dln2->pdev, DLN2_GPIO_PIN_SET_DIRECTION,
250 &req, sizeof(req));
251 if (ret < 0)
252 return ret;
253
254 if (dir == DLN2_GPIO_DIRECTION_OUT)
255 set_bit(offset, dln2->output_enabled);
256 else
257 clear_bit(offset, dln2->output_enabled);
258
259 return ret;
260}
261
262static int dln2_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
263{
264 return dln2_gpio_set_direction(chip, offset, DLN2_GPIO_DIRECTION_IN);
265}
266
267static int dln2_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
268 int value)
269{
270 return dln2_gpio_set_direction(chip, offset, DLN2_GPIO_DIRECTION_OUT);
271}
272
273static int dln2_gpio_set_debounce(struct gpio_chip *chip, unsigned offset,
274 unsigned debounce)
275{
276 struct dln2_gpio *dln2 = container_of(chip, struct dln2_gpio, gpio);
277 __le32 duration = cpu_to_le32(debounce);
278
279 return dln2_transfer_tx(dln2->pdev, DLN2_GPIO_SET_DEBOUNCE,
280 &duration, sizeof(duration));
281}
282
283static int dln2_gpio_set_event_cfg(struct dln2_gpio *dln2, unsigned pin,
284 unsigned type, unsigned period)
285{
286 struct {
287 __le16 pin;
288 u8 type;
289 __le16 period;
290 } __packed req = {
291 .pin = cpu_to_le16(pin),
292 .type = type,
293 .period = cpu_to_le16(period),
294 };
295
296 return dln2_transfer_tx(dln2->pdev, DLN2_GPIO_PIN_SET_EVENT_CFG,
297 &req, sizeof(req));
298}
299
300static void dln2_irq_work(struct work_struct *w)
301{
302 struct dln2_irq_work *iw = container_of(w, struct dln2_irq_work, work);
303 struct dln2_gpio *dln2 = iw->dln2;
304 u8 type = iw->type & DLN2_GPIO_EVENT_MASK;
305
306 if (test_bit(iw->pin, dln2->irqs_enabled))
307 dln2_gpio_set_event_cfg(dln2, iw->pin, type, 0);
308 else
309 dln2_gpio_set_event_cfg(dln2, iw->pin, DLN2_GPIO_EVENT_NONE, 0);
310}
311
312static void dln2_irq_enable(struct irq_data *irqd)
313{
314 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
315 struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio);
316 int pin = irqd_to_hwirq(irqd);
317
318 set_bit(pin, dln2->irqs_enabled);
319 schedule_work(&dln2->irq_work[pin].work);
320}
321
322static void dln2_irq_disable(struct irq_data *irqd)
323{
324 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
325 struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio);
326 int pin = irqd_to_hwirq(irqd);
327
328 clear_bit(pin, dln2->irqs_enabled);
329 schedule_work(&dln2->irq_work[pin].work);
330}
331
332static void dln2_irq_mask(struct irq_data *irqd)
333{
334 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
335 struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio);
336 int pin = irqd_to_hwirq(irqd);
337
338 set_bit(pin, dln2->irqs_masked);
339}
340
341static void dln2_irq_unmask(struct irq_data *irqd)
342{
343 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
344 struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio);
345 struct device *dev = dln2->gpio.dev;
346 int pin = irqd_to_hwirq(irqd);
347
348 if (test_and_clear_bit(pin, dln2->irqs_pending)) {
349 int irq;
350
351 irq = irq_find_mapping(dln2->gpio.irqdomain, pin);
352 if (!irq) {
353 dev_err(dev, "pin %d not mapped to IRQ\n", pin);
354 return;
355 }
356
357 generic_handle_irq(irq);
358 }
359}
360
361static int dln2_irq_set_type(struct irq_data *irqd, unsigned type)
362{
363 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
364 struct dln2_gpio *dln2 = container_of(gc, struct dln2_gpio, gpio);
365 int pin = irqd_to_hwirq(irqd);
366
367 switch (type) {
368 case IRQ_TYPE_LEVEL_HIGH:
369 dln2->irq_work[pin].type = DLN2_GPIO_EVENT_LVL_HIGH;
370 break;
371 case IRQ_TYPE_LEVEL_LOW:
372 dln2->irq_work[pin].type = DLN2_GPIO_EVENT_LVL_LOW;
373 break;
374 case IRQ_TYPE_EDGE_BOTH:
375 dln2->irq_work[pin].type = DLN2_GPIO_EVENT_CHANGE;
376 break;
377 case IRQ_TYPE_EDGE_RISING:
378 dln2->irq_work[pin].type = DLN2_GPIO_EVENT_CHANGE_RISING;
379 break;
380 case IRQ_TYPE_EDGE_FALLING:
381 dln2->irq_work[pin].type = DLN2_GPIO_EVENT_CHANGE_FALLING;
382 break;
383 default:
384 return -EINVAL;
385 }
386
387 return 0;
388}
389
390static struct irq_chip dln2_gpio_irqchip = {
391 .name = "dln2-irq",
392 .irq_enable = dln2_irq_enable,
393 .irq_disable = dln2_irq_disable,
394 .irq_mask = dln2_irq_mask,
395 .irq_unmask = dln2_irq_unmask,
396 .irq_set_type = dln2_irq_set_type,
397};
398
399static void dln2_gpio_event(struct platform_device *pdev, u16 echo,
400 const void *data, int len)
401{
402 int pin, irq;
403 const struct {
404 __le16 count;
405 __u8 type;
406 __le16 pin;
407 __u8 value;
408 } __packed *event = data;
409 struct dln2_gpio *dln2 = platform_get_drvdata(pdev);
410
411 if (len < sizeof(*event)) {
412 dev_err(dln2->gpio.dev, "short event message\n");
413 return;
414 }
415
416 pin = le16_to_cpu(event->pin);
417 if (pin >= dln2->gpio.ngpio) {
418 dev_err(dln2->gpio.dev, "out of bounds pin %d\n", pin);
419 return;
420 }
421
422 irq = irq_find_mapping(dln2->gpio.irqdomain, pin);
423 if (!irq) {
424 dev_err(dln2->gpio.dev, "pin %d not mapped to IRQ\n", pin);
425 return;
426 }
427
428 if (!test_bit(pin, dln2->irqs_enabled))
429 return;
430 if (test_bit(pin, dln2->irqs_masked)) {
431 set_bit(pin, dln2->irqs_pending);
432 return;
433 }
434
435 switch (dln2->irq_work[pin].type) {
436 case DLN2_GPIO_EVENT_CHANGE_RISING:
437 if (event->value)
438 generic_handle_irq(irq);
439 break;
440 case DLN2_GPIO_EVENT_CHANGE_FALLING:
441 if (!event->value)
442 generic_handle_irq(irq);
443 break;
444 default:
445 generic_handle_irq(irq);
446 }
447}
448
449static int dln2_gpio_probe(struct platform_device *pdev)
450{
451 struct dln2_gpio *dln2;
452 struct device *dev = &pdev->dev;
453 int pins;
454 int i, ret;
455
456 pins = dln2_gpio_get_pin_count(pdev);
457 if (pins < 0) {
458 dev_err(dev, "failed to get pin count: %d\n", pins);
459 return pins;
460 }
461 if (pins > DLN2_GPIO_MAX_PINS) {
462 pins = DLN2_GPIO_MAX_PINS;
463 dev_warn(dev, "clamping pins to %d\n", DLN2_GPIO_MAX_PINS);
464 }
465
466 dln2 = devm_kzalloc(&pdev->dev, sizeof(*dln2), GFP_KERNEL);
467 if (!dln2)
468 return -ENOMEM;
469
470 dln2->irq_work = devm_kcalloc(&pdev->dev, pins,
471 sizeof(struct dln2_irq_work), GFP_KERNEL);
472 if (!dln2->irq_work)
473 return -ENOMEM;
474 for (i = 0; i < pins; i++) {
475 INIT_WORK(&dln2->irq_work[i].work, dln2_irq_work);
476 dln2->irq_work[i].pin = i;
477 dln2->irq_work[i].dln2 = dln2;
478 }
479
480 dln2->pdev = pdev;
481
482 dln2->gpio.label = "dln2";
483 dln2->gpio.dev = dev;
484 dln2->gpio.owner = THIS_MODULE;
485 dln2->gpio.base = -1;
486 dln2->gpio.ngpio = pins;
487 dln2->gpio.exported = true;
488 dln2->gpio.can_sleep = true;
489 dln2->gpio.irq_not_threaded = true;
490 dln2->gpio.set = dln2_gpio_set;
491 dln2->gpio.get = dln2_gpio_get;
492 dln2->gpio.request = dln2_gpio_request;
493 dln2->gpio.free = dln2_gpio_free;
494 dln2->gpio.get_direction = dln2_gpio_get_direction;
495 dln2->gpio.direction_input = dln2_gpio_direction_input;
496 dln2->gpio.direction_output = dln2_gpio_direction_output;
497 dln2->gpio.set_debounce = dln2_gpio_set_debounce;
498
499 platform_set_drvdata(pdev, dln2);
500
501 ret = gpiochip_add(&dln2->gpio);
502 if (ret < 0) {
503 dev_err(dev, "failed to add gpio chip: %d\n", ret);
504 goto out;
505 }
506
507 ret = gpiochip_irqchip_add(&dln2->gpio, &dln2_gpio_irqchip, 0,
508 handle_simple_irq, IRQ_TYPE_NONE);
509 if (ret < 0) {
510 dev_err(dev, "failed to add irq chip: %d\n", ret);
511 goto out_gpiochip_remove;
512 }
513
514 ret = dln2_register_event_cb(pdev, DLN2_GPIO_CONDITION_MET_EV,
515 dln2_gpio_event);
516 if (ret) {
517 dev_err(dev, "failed to register event cb: %d\n", ret);
518 goto out_gpiochip_remove;
519 }
520
521 return 0;
522
523out_gpiochip_remove:
524 gpiochip_remove(&dln2->gpio);
525out:
526 return ret;
527}
528
529static int dln2_gpio_remove(struct platform_device *pdev)
530{
531 struct dln2_gpio *dln2 = platform_get_drvdata(pdev);
532 int i;
533
534 dln2_unregister_event_cb(pdev, DLN2_GPIO_CONDITION_MET_EV);
535 for (i = 0; i < dln2->gpio.ngpio; i++)
536 flush_work(&dln2->irq_work[i].work);
537 gpiochip_remove(&dln2->gpio);
538
539 return 0;
540}
541
542static struct platform_driver dln2_gpio_driver = {
543 .driver.name = "dln2-gpio",
544 .probe = dln2_gpio_probe,
545 .remove = dln2_gpio_remove,
546};
547
548module_platform_driver(dln2_gpio_driver);
549
550MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com");
551MODULE_DESCRIPTION("Driver for the Diolan DLN2 GPIO interface");
552MODULE_LICENSE("GPL v2");
553MODULE_ALIAS("platform:dln2-gpio");
diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c
index ae0f6466eb09..abdcf58935f5 100644
--- a/drivers/gpio/gpio-tc3589x.c
+++ b/drivers/gpio/gpio-tc3589x.c
@@ -262,7 +262,7 @@ static int tc3589x_gpio_probe(struct platform_device *pdev)
262 tc3589x_gpio->chip = template_chip; 262 tc3589x_gpio->chip = template_chip;
263 tc3589x_gpio->chip.ngpio = tc3589x->num_gpio; 263 tc3589x_gpio->chip.ngpio = tc3589x->num_gpio;
264 tc3589x_gpio->chip.dev = &pdev->dev; 264 tc3589x_gpio->chip.dev = &pdev->dev;
265 tc3589x_gpio->chip.base = (pdata) ? pdata->gpio_base : -1; 265 tc3589x_gpio->chip.base = -1;
266 266
267#ifdef CONFIG_OF_GPIO 267#ifdef CONFIG_OF_GPIO
268 tc3589x_gpio->chip.of_node = np; 268 tc3589x_gpio->chip.of_node = np;
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index e6d8e18dae97..6a58b6c723aa 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -641,9 +641,6 @@ static int sensor_hub_probe(struct hid_device *hdev,
641 goto err_stop_hw; 641 goto err_stop_hw;
642 } 642 }
643 sd->hid_sensor_hub_client_devs[ 643 sd->hid_sensor_hub_client_devs[
644 sd->hid_sensor_client_cnt].id =
645 PLATFORM_DEVID_AUTO;
646 sd->hid_sensor_hub_client_devs[
647 sd->hid_sensor_client_cnt].name = name; 644 sd->hid_sensor_client_cnt].name = name;
648 sd->hid_sensor_hub_client_devs[ 645 sd->hid_sensor_hub_client_devs[
649 sd->hid_sensor_client_cnt].platform_data = 646 sd->hid_sensor_client_cnt].platform_data =
@@ -659,8 +656,9 @@ static int sensor_hub_probe(struct hid_device *hdev,
659 if (last_hsdev) 656 if (last_hsdev)
660 last_hsdev->end_collection_index = i; 657 last_hsdev->end_collection_index = i;
661 658
662 ret = mfd_add_devices(&hdev->dev, 0, sd->hid_sensor_hub_client_devs, 659 ret = mfd_add_hotplug_devices(&hdev->dev,
663 sd->hid_sensor_client_cnt, NULL, 0, NULL); 660 sd->hid_sensor_hub_client_devs,
661 sd->hid_sensor_client_cnt);
664 if (ret < 0) 662 if (ret < 0)
665 goto err_stop_hw; 663 goto err_stop_hw;
666 664
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 917c3585f45b..b4d135cc2f39 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -881,6 +881,16 @@ config I2C_DIOLAN_U2C
881 This driver can also be built as a module. If so, the module 881 This driver can also be built as a module. If so, the module
882 will be called i2c-diolan-u2c. 882 will be called i2c-diolan-u2c.
883 883
884config I2C_DLN2
885 tristate "Diolan DLN-2 USB I2C adapter"
886 depends on MFD_DLN2
887 help
888 If you say yes to this option, support will be included for Diolan
889 DLN2, a USB to I2C interface.
890
891 This driver can also be built as a module. If so, the module
892 will be called i2c-dln2.
893
884config I2C_PARPORT 894config I2C_PARPORT
885 tristate "Parallel port adapter" 895 tristate "Parallel port adapter"
886 depends on PARPORT 896 depends on PARPORT
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 78d56c54ba2b..cdac7f15eab5 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -87,6 +87,7 @@ obj-$(CONFIG_I2C_RCAR) += i2c-rcar.o
87 87
88# External I2C/SMBus adapter drivers 88# External I2C/SMBus adapter drivers
89obj-$(CONFIG_I2C_DIOLAN_U2C) += i2c-diolan-u2c.o 89obj-$(CONFIG_I2C_DIOLAN_U2C) += i2c-diolan-u2c.o
90obj-$(CONFIG_I2C_DLN2) += i2c-dln2.o
90obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o 91obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o
91obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o 92obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o
92obj-$(CONFIG_I2C_ROBOTFUZZ_OSIF) += i2c-robotfuzz-osif.o 93obj-$(CONFIG_I2C_ROBOTFUZZ_OSIF) += i2c-robotfuzz-osif.o
diff --git a/drivers/i2c/busses/i2c-dln2.c b/drivers/i2c/busses/i2c-dln2.c
new file mode 100644
index 000000000000..b3fb86af4cbb
--- /dev/null
+++ b/drivers/i2c/busses/i2c-dln2.c
@@ -0,0 +1,262 @@
1/*
2 * Driver for the Diolan DLN-2 USB-I2C adapter
3 *
4 * Copyright (c) 2014 Intel Corporation
5 *
6 * Derived from:
7 * i2c-diolan-u2c.c
8 * Copyright (c) 2010-2011 Ericsson AB
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation, version 2.
13 */
14
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/types.h>
18#include <linux/slab.h>
19#include <linux/i2c.h>
20#include <linux/platform_device.h>
21#include <linux/mfd/dln2.h>
22
23#define DLN2_I2C_MODULE_ID 0x03
24#define DLN2_I2C_CMD(cmd) DLN2_CMD(cmd, DLN2_I2C_MODULE_ID)
25
26/* I2C commands */
27#define DLN2_I2C_GET_PORT_COUNT DLN2_I2C_CMD(0x00)
28#define DLN2_I2C_ENABLE DLN2_I2C_CMD(0x01)
29#define DLN2_I2C_DISABLE DLN2_I2C_CMD(0x02)
30#define DLN2_I2C_IS_ENABLED DLN2_I2C_CMD(0x03)
31#define DLN2_I2C_WRITE DLN2_I2C_CMD(0x06)
32#define DLN2_I2C_READ DLN2_I2C_CMD(0x07)
33#define DLN2_I2C_SCAN_DEVICES DLN2_I2C_CMD(0x08)
34#define DLN2_I2C_PULLUP_ENABLE DLN2_I2C_CMD(0x09)
35#define DLN2_I2C_PULLUP_DISABLE DLN2_I2C_CMD(0x0A)
36#define DLN2_I2C_PULLUP_IS_ENABLED DLN2_I2C_CMD(0x0B)
37#define DLN2_I2C_TRANSFER DLN2_I2C_CMD(0x0C)
38#define DLN2_I2C_SET_MAX_REPLY_COUNT DLN2_I2C_CMD(0x0D)
39#define DLN2_I2C_GET_MAX_REPLY_COUNT DLN2_I2C_CMD(0x0E)
40
41#define DLN2_I2C_MAX_XFER_SIZE 256
42#define DLN2_I2C_BUF_SIZE (DLN2_I2C_MAX_XFER_SIZE + 16)
43
44struct dln2_i2c {
45 struct platform_device *pdev;
46 struct i2c_adapter adapter;
47 u8 port;
48 /*
49 * Buffer to hold the packet for read or write transfers. One is enough
50 * since we can't have multiple transfers in parallel on the i2c bus.
51 */
52 void *buf;
53};
54
55static int dln2_i2c_enable(struct dln2_i2c *dln2, bool enable)
56{
57 u16 cmd;
58 struct {
59 u8 port;
60 } tx;
61
62 tx.port = dln2->port;
63
64 if (enable)
65 cmd = DLN2_I2C_ENABLE;
66 else
67 cmd = DLN2_I2C_DISABLE;
68
69 return dln2_transfer_tx(dln2->pdev, cmd, &tx, sizeof(tx));
70}
71
72static int dln2_i2c_write(struct dln2_i2c *dln2, u8 addr,
73 u8 *data, u16 data_len)
74{
75 int ret;
76 struct {
77 u8 port;
78 u8 addr;
79 u8 mem_addr_len;
80 __le32 mem_addr;
81 __le16 buf_len;
82 u8 buf[DLN2_I2C_MAX_XFER_SIZE];
83 } __packed *tx = dln2->buf;
84 unsigned len;
85
86 BUILD_BUG_ON(sizeof(*tx) > DLN2_I2C_BUF_SIZE);
87
88 tx->port = dln2->port;
89 tx->addr = addr;
90 tx->mem_addr_len = 0;
91 tx->mem_addr = 0;
92 tx->buf_len = cpu_to_le16(data_len);
93 memcpy(tx->buf, data, data_len);
94
95 len = sizeof(*tx) + data_len - DLN2_I2C_MAX_XFER_SIZE;
96 ret = dln2_transfer_tx(dln2->pdev, DLN2_I2C_WRITE, tx, len);
97 if (ret < 0)
98 return ret;
99
100 return data_len;
101}
102
103static int dln2_i2c_read(struct dln2_i2c *dln2, u16 addr, u8 *data,
104 u16 data_len)
105{
106 int ret;
107 struct {
108 u8 port;
109 u8 addr;
110 u8 mem_addr_len;
111 __le32 mem_addr;
112 __le16 buf_len;
113 } __packed tx;
114 struct {
115 __le16 buf_len;
116 u8 buf[DLN2_I2C_MAX_XFER_SIZE];
117 } __packed *rx = dln2->buf;
118 unsigned rx_len = sizeof(*rx);
119
120 BUILD_BUG_ON(sizeof(*rx) > DLN2_I2C_BUF_SIZE);
121
122 tx.port = dln2->port;
123 tx.addr = addr;
124 tx.mem_addr_len = 0;
125 tx.mem_addr = 0;
126 tx.buf_len = cpu_to_le16(data_len);
127
128 ret = dln2_transfer(dln2->pdev, DLN2_I2C_READ, &tx, sizeof(tx),
129 rx, &rx_len);
130 if (ret < 0)
131 return ret;
132 if (rx_len < sizeof(rx->buf_len) + data_len)
133 return -EPROTO;
134 if (le16_to_cpu(rx->buf_len) != data_len)
135 return -EPROTO;
136
137 memcpy(data, rx->buf, data_len);
138
139 return data_len;
140}
141
142static int dln2_i2c_xfer(struct i2c_adapter *adapter,
143 struct i2c_msg *msgs, int num)
144{
145 struct dln2_i2c *dln2 = i2c_get_adapdata(adapter);
146 struct i2c_msg *pmsg;
147 struct device *dev = &dln2->adapter.dev;
148 int i;
149
150 for (i = 0; i < num; i++) {
151 int ret;
152
153 pmsg = &msgs[i];
154
155 if (pmsg->len > DLN2_I2C_MAX_XFER_SIZE) {
156 dev_warn(dev, "maximum transfer size exceeded\n");
157 return -EOPNOTSUPP;
158 }
159
160 if (pmsg->flags & I2C_M_RD) {
161 ret = dln2_i2c_read(dln2, pmsg->addr, pmsg->buf,
162 pmsg->len);
163 if (ret < 0)
164 return ret;
165
166 pmsg->len = ret;
167 } else {
168 ret = dln2_i2c_write(dln2, pmsg->addr, pmsg->buf,
169 pmsg->len);
170 if (ret != pmsg->len)
171 return -EPROTO;
172 }
173 }
174
175 return num;
176}
177
178static u32 dln2_i2c_func(struct i2c_adapter *a)
179{
180 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA |
181 I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_PROC_CALL |
182 I2C_FUNC_SMBUS_I2C_BLOCK;
183}
184
185static const struct i2c_algorithm dln2_i2c_usb_algorithm = {
186 .master_xfer = dln2_i2c_xfer,
187 .functionality = dln2_i2c_func,
188};
189
190static int dln2_i2c_probe(struct platform_device *pdev)
191{
192 int ret;
193 struct dln2_i2c *dln2;
194 struct device *dev = &pdev->dev;
195 struct dln2_platform_data *pdata = dev_get_platdata(&pdev->dev);
196
197 dln2 = devm_kzalloc(dev, sizeof(*dln2), GFP_KERNEL);
198 if (!dln2)
199 return -ENOMEM;
200
201 dln2->buf = devm_kmalloc(dev, DLN2_I2C_BUF_SIZE, GFP_KERNEL);
202 if (!dln2->buf)
203 return -ENOMEM;
204
205 dln2->pdev = pdev;
206 dln2->port = pdata->port;
207
208 /* setup i2c adapter description */
209 dln2->adapter.owner = THIS_MODULE;
210 dln2->adapter.class = I2C_CLASS_HWMON;
211 dln2->adapter.algo = &dln2_i2c_usb_algorithm;
212 dln2->adapter.dev.parent = dev;
213 i2c_set_adapdata(&dln2->adapter, dln2);
214 snprintf(dln2->adapter.name, sizeof(dln2->adapter.name), "%s-%s-%d",
215 "dln2-i2c", dev_name(pdev->dev.parent), dln2->port);
216
217 platform_set_drvdata(pdev, dln2);
218
219 /* initialize the i2c interface */
220 ret = dln2_i2c_enable(dln2, true);
221 if (ret < 0) {
222 dev_err(dev, "failed to initialize adapter: %d\n", ret);
223 return ret;
224 }
225
226 /* and finally attach to i2c layer */
227 ret = i2c_add_adapter(&dln2->adapter);
228 if (ret < 0) {
229 dev_err(dev, "failed to add I2C adapter: %d\n", ret);
230 goto out_disable;
231 }
232
233 return 0;
234
235out_disable:
236 dln2_i2c_enable(dln2, false);
237
238 return ret;
239}
240
241static int dln2_i2c_remove(struct platform_device *pdev)
242{
243 struct dln2_i2c *dln2 = platform_get_drvdata(pdev);
244
245 i2c_del_adapter(&dln2->adapter);
246 dln2_i2c_enable(dln2, false);
247
248 return 0;
249}
250
251static struct platform_driver dln2_i2c_driver = {
252 .driver.name = "dln2-i2c",
253 .probe = dln2_i2c_probe,
254 .remove = dln2_i2c_remove,
255};
256
257module_platform_driver(dln2_i2c_driver);
258
259MODULE_AUTHOR("Laurentiu Palcu <laurentiu.palcu@intel.com>");
260MODULE_DESCRIPTION("Driver for the Diolan DLN2 I2C master interface");
261MODULE_LICENSE("GPL v2");
262MODULE_ALIAS("platform:dln2-i2c");
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 88bdc8f612e2..bc4e787096e8 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -127,6 +127,14 @@ config AT91_ADC
127 help 127 help
128 Say yes here to build support for Atmel AT91 ADC. 128 Say yes here to build support for Atmel AT91 ADC.
129 129
130config AXP288_ADC
131 tristate "X-Powers AXP288 ADC driver"
132 depends on MFD_AXP20X
133 help
134 Say yes here to have support for X-Powers power management IC (PMIC) ADC
135 device. Depending on platform configuration, this general purpose ADC can
136 be used for sampling sensors such as thermal resistors.
137
130config EXYNOS_ADC 138config EXYNOS_ADC
131 tristate "Exynos ADC driver support" 139 tristate "Exynos ADC driver support"
132 depends on ARCH_EXYNOS || ARCH_S3C24XX || ARCH_S3C64XX || (OF && COMPILE_TEST) 140 depends on ARCH_EXYNOS || ARCH_S3C24XX || ARCH_S3C64XX || (OF && COMPILE_TEST)
diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
index cb88a6a23b8f..f30093f5b67a 100644
--- a/drivers/iio/adc/Makefile
+++ b/drivers/iio/adc/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_AD7793) += ad7793.o
14obj-$(CONFIG_AD7887) += ad7887.o 14obj-$(CONFIG_AD7887) += ad7887.o
15obj-$(CONFIG_AD799X) += ad799x.o 15obj-$(CONFIG_AD799X) += ad799x.o
16obj-$(CONFIG_AT91_ADC) += at91_adc.o 16obj-$(CONFIG_AT91_ADC) += at91_adc.o
17obj-$(CONFIG_AXP288_ADC) += axp288_adc.o
17obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o 18obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o
18obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o 19obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o
19obj-$(CONFIG_MAX1027) += max1027.o 20obj-$(CONFIG_MAX1027) += max1027.o
diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c
new file mode 100644
index 000000000000..08bcfb061ca5
--- /dev/null
+++ b/drivers/iio/adc/axp288_adc.c
@@ -0,0 +1,261 @@
1/*
2 * axp288_adc.c - X-Powers AXP288 PMIC ADC Driver
3 *
4 * Copyright (C) 2014 Intel Corporation
5 *
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 */
18
19#include <linux/module.h>
20#include <linux/kernel.h>
21#include <linux/device.h>
22#include <linux/regmap.h>
23#include <linux/mfd/axp20x.h>
24#include <linux/platform_device.h>
25
26#include <linux/iio/iio.h>
27#include <linux/iio/machine.h>
28#include <linux/iio/driver.h>
29
30#define AXP288_ADC_EN_MASK 0xF1
31#define AXP288_ADC_TS_PIN_GPADC 0xF2
32#define AXP288_ADC_TS_PIN_ON 0xF3
33
34enum axp288_adc_id {
35 AXP288_ADC_TS,
36 AXP288_ADC_PMIC,
37 AXP288_ADC_GP,
38 AXP288_ADC_BATT_CHRG_I,
39 AXP288_ADC_BATT_DISCHRG_I,
40 AXP288_ADC_BATT_V,
41 AXP288_ADC_NR_CHAN,
42};
43
44struct axp288_adc_info {
45 int irq;
46 struct regmap *regmap;
47};
48
49static const struct iio_chan_spec const axp288_adc_channels[] = {
50 {
51 .indexed = 1,
52 .type = IIO_TEMP,
53 .channel = 0,
54 .address = AXP288_TS_ADC_H,
55 .datasheet_name = "TS_PIN",
56 }, {
57 .indexed = 1,
58 .type = IIO_TEMP,
59 .channel = 1,
60 .address = AXP288_PMIC_ADC_H,
61 .datasheet_name = "PMIC_TEMP",
62 }, {
63 .indexed = 1,
64 .type = IIO_TEMP,
65 .channel = 2,
66 .address = AXP288_GP_ADC_H,
67 .datasheet_name = "GPADC",
68 }, {
69 .indexed = 1,
70 .type = IIO_CURRENT,
71 .channel = 3,
72 .address = AXP20X_BATT_CHRG_I_H,
73 .datasheet_name = "BATT_CHG_I",
74 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
75 }, {
76 .indexed = 1,
77 .type = IIO_CURRENT,
78 .channel = 4,
79 .address = AXP20X_BATT_DISCHRG_I_H,
80 .datasheet_name = "BATT_DISCHRG_I",
81 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
82 }, {
83 .indexed = 1,
84 .type = IIO_VOLTAGE,
85 .channel = 5,
86 .address = AXP20X_BATT_V_H,
87 .datasheet_name = "BATT_V",
88 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
89 },
90};
91
92#define AXP288_ADC_MAP(_adc_channel_label, _consumer_dev_name, \
93 _consumer_channel) \
94 { \
95 .adc_channel_label = _adc_channel_label, \
96 .consumer_dev_name = _consumer_dev_name, \
97 .consumer_channel = _consumer_channel, \
98 }
99
100/* for consumer drivers */
101static struct iio_map axp288_adc_default_maps[] = {
102 AXP288_ADC_MAP("TS_PIN", "axp288-batt", "axp288-batt-temp"),
103 AXP288_ADC_MAP("PMIC_TEMP", "axp288-pmic", "axp288-pmic-temp"),
104 AXP288_ADC_MAP("GPADC", "axp288-gpadc", "axp288-system-temp"),
105 AXP288_ADC_MAP("BATT_CHG_I", "axp288-chrg", "axp288-chrg-curr"),
106 AXP288_ADC_MAP("BATT_DISCHRG_I", "axp288-chrg", "axp288-chrg-d-curr"),
107 AXP288_ADC_MAP("BATT_V", "axp288-batt", "axp288-batt-volt"),
108 {},
109};
110
111static int axp288_adc_read_channel(int *val, unsigned long address,
112 struct regmap *regmap)
113{
114 u8 buf[2];
115
116 if (regmap_bulk_read(regmap, address, buf, 2))
117 return -EIO;
118 *val = (buf[0] << 4) + ((buf[1] >> 4) & 0x0F);
119
120 return IIO_VAL_INT;
121}
122
123static int axp288_adc_set_ts(struct regmap *regmap, unsigned int mode,
124 unsigned long address)
125{
126 /* channels other than GPADC do not need to switch TS pin */
127 if (address != AXP288_GP_ADC_H)
128 return 0;
129
130 return regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, mode);
131}
132
133static int axp288_adc_read_raw(struct iio_dev *indio_dev,
134 struct iio_chan_spec const *chan,
135 int *val, int *val2, long mask)
136{
137 int ret;
138 struct axp288_adc_info *info = iio_priv(indio_dev);
139
140 mutex_lock(&indio_dev->mlock);
141 switch (mask) {
142 case IIO_CHAN_INFO_RAW:
143 if (axp288_adc_set_ts(info->regmap, AXP288_ADC_TS_PIN_GPADC,
144 chan->address)) {
145 dev_err(&indio_dev->dev, "GPADC mode\n");
146 ret = -EINVAL;
147 break;
148 }
149 ret = axp288_adc_read_channel(val, chan->address, info->regmap);
150 if (axp288_adc_set_ts(info->regmap, AXP288_ADC_TS_PIN_ON,
151 chan->address))
152 dev_err(&indio_dev->dev, "TS pin restore\n");
153 break;
154 case IIO_CHAN_INFO_PROCESSED:
155 ret = axp288_adc_read_channel(val, chan->address, info->regmap);
156 break;
157 default:
158 ret = -EINVAL;
159 }
160 mutex_unlock(&indio_dev->mlock);
161
162 return ret;
163}
164
165static int axp288_adc_set_state(struct regmap *regmap)
166{
167 /* ADC should be always enabled for internal FG to function */
168 if (regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, AXP288_ADC_TS_PIN_ON))
169 return -EIO;
170
171 return regmap_write(regmap, AXP20X_ADC_EN1, AXP288_ADC_EN_MASK);
172}
173
174static const struct iio_info axp288_adc_iio_info = {
175 .read_raw = &axp288_adc_read_raw,
176 .driver_module = THIS_MODULE,
177};
178
179static int axp288_adc_probe(struct platform_device *pdev)
180{
181 int ret;
182 struct axp288_adc_info *info;
183 struct iio_dev *indio_dev;
184 struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
185
186 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
187 if (!indio_dev)
188 return -ENOMEM;
189
190 info = iio_priv(indio_dev);
191 info->irq = platform_get_irq(pdev, 0);
192 if (info->irq < 0) {
193 dev_err(&pdev->dev, "no irq resource?\n");
194 return info->irq;
195 }
196 platform_set_drvdata(pdev, indio_dev);
197 info->regmap = axp20x->regmap;
198 /*
199 * Set ADC to enabled state at all time, including system suspend.
200 * otherwise internal fuel gauge functionality may be affected.
201 */
202 ret = axp288_adc_set_state(axp20x->regmap);
203 if (ret) {
204 dev_err(&pdev->dev, "unable to enable ADC device\n");
205 return ret;
206 }
207
208 indio_dev->dev.parent = &pdev->dev;
209 indio_dev->name = pdev->name;
210 indio_dev->channels = axp288_adc_channels;
211 indio_dev->num_channels = ARRAY_SIZE(axp288_adc_channels);
212 indio_dev->info = &axp288_adc_iio_info;
213 indio_dev->modes = INDIO_DIRECT_MODE;
214 ret = iio_map_array_register(indio_dev, axp288_adc_default_maps);
215 if (ret < 0)
216 return ret;
217
218 ret = iio_device_register(indio_dev);
219 if (ret < 0) {
220 dev_err(&pdev->dev, "unable to register iio device\n");
221 goto err_array_unregister;
222 }
223 return 0;
224
225err_array_unregister:
226 iio_map_array_unregister(indio_dev);
227
228 return ret;
229}
230
231static int axp288_adc_remove(struct platform_device *pdev)
232{
233 struct iio_dev *indio_dev = platform_get_drvdata(pdev);
234
235 iio_device_unregister(indio_dev);
236 iio_map_array_unregister(indio_dev);
237
238 return 0;
239}
240
241static struct platform_device_id axp288_adc_id_table[] = {
242 { .name = "axp288_adc" },
243 {},
244};
245
246static struct platform_driver axp288_adc_driver = {
247 .probe = axp288_adc_probe,
248 .remove = axp288_adc_remove,
249 .id_table = axp288_adc_id_table,
250 .driver = {
251 .name = "axp288_adc",
252 },
253};
254
255MODULE_DEVICE_TABLE(platform, axp288_adc_id_table);
256
257module_platform_driver(axp288_adc_driver);
258
259MODULE_AUTHOR("Jacob Pan <jacob.jun.pan@linux.intel.com>");
260MODULE_DESCRIPTION("X-Powers AXP288 ADC Driver");
261MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 1456ea70bbc7..2e6b7311fabc 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -59,6 +59,17 @@ config MFD_AAT2870_CORE
59 additional drivers must be enabled in order to use the 59 additional drivers must be enabled in order to use the
60 functionality of the device. 60 functionality of the device.
61 61
62config MFD_ATMEL_HLCDC
63 tristate "Atmel HLCDC (High-end LCD Controller)"
64 select MFD_CORE
65 select REGMAP_MMIO
66 depends on OF
67 help
68 If you say yes here you get support for the HLCDC block.
69 This driver provides common support for accessing the device,
70 additional drivers must be enabled in order to use the
71 functionality of the device.
72
62config MFD_BCM590XX 73config MFD_BCM590XX
63 tristate "Broadcom BCM590xx PMUs" 74 tristate "Broadcom BCM590xx PMUs"
64 select MFD_CORE 75 select MFD_CORE
@@ -74,7 +85,8 @@ config MFD_AXP20X
74 select REGMAP_IRQ 85 select REGMAP_IRQ
75 depends on I2C=y 86 depends on I2C=y
76 help 87 help
77 If you say Y here you get support for the X-Powers AXP202 and AXP209. 88 If you say Y here you get support for the X-Powers AXP202, AXP209 and
89 AXP288 power management IC (PMIC).
78 This driver include only the core APIs. You have to select individual 90 This driver include only the core APIs. You have to select individual
79 components like regulators or the PEK (Power Enable Key) under the 91 components like regulators or the PEK (Power Enable Key) under the
80 corresponding menus. 92 corresponding menus.
@@ -183,6 +195,16 @@ config MFD_DA9063
183 Additional drivers must be enabled in order to use the functionality 195 Additional drivers must be enabled in order to use the functionality
184 of the device. 196 of the device.
185 197
198config MFD_DLN2
199 tristate "Diolan DLN2 support"
200 select MFD_CORE
201 depends on USB
202 help
203 This adds support for Diolan USB-I2C/SPI/GPIO Master Adapter
204 DLN-2. Additional drivers such as I2C_DLN2, GPIO_DLN2,
205 etc. must be enabled in order to use the functionality of
206 the device.
207
186config MFD_MC13XXX 208config MFD_MC13XXX
187 tristate 209 tristate
188 depends on (SPI_MASTER || I2C) 210 depends on (SPI_MASTER || I2C)
@@ -655,7 +677,6 @@ config MFD_SEC_CORE
655 select MFD_CORE 677 select MFD_CORE
656 select REGMAP_I2C 678 select REGMAP_I2C
657 select REGMAP_IRQ 679 select REGMAP_IRQ
658 select REGULATOR
659 help 680 help
660 Support for the Samsung Electronics MFD series. 681 Support for the Samsung Electronics MFD series.
661 This driver provides common support for accessing the device, 682 This driver provides common support for accessing the device,
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 8bd54b1253af..53467e211381 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -13,7 +13,7 @@ obj-$(CONFIG_MFD_CROS_EC) += cros_ec.o
13obj-$(CONFIG_MFD_CROS_EC_I2C) += cros_ec_i2c.o 13obj-$(CONFIG_MFD_CROS_EC_I2C) += cros_ec_i2c.o
14obj-$(CONFIG_MFD_CROS_EC_SPI) += cros_ec_spi.o 14obj-$(CONFIG_MFD_CROS_EC_SPI) += cros_ec_spi.o
15 15
16rtsx_pci-objs := rtsx_pcr.o rts5209.o rts5229.o rtl8411.o rts5227.o rts5249.o 16rtsx_pci-objs := rtsx_pcr.o rtsx_gops.o rts5209.o rts5229.o rtl8411.o rts5227.o rts5249.o
17obj-$(CONFIG_MFD_RTSX_PCI) += rtsx_pci.o 17obj-$(CONFIG_MFD_RTSX_PCI) += rtsx_pci.o
18obj-$(CONFIG_MFD_RTSX_USB) += rtsx_usb.o 18obj-$(CONFIG_MFD_RTSX_USB) += rtsx_usb.o
19 19
@@ -157,6 +157,7 @@ obj-$(CONFIG_MFD_SPMI_PMIC) += qcom-spmi-pmic.o
157obj-$(CONFIG_TPS65911_COMPARATOR) += tps65911-comparator.o 157obj-$(CONFIG_TPS65911_COMPARATOR) += tps65911-comparator.o
158obj-$(CONFIG_MFD_TPS65090) += tps65090.o 158obj-$(CONFIG_MFD_TPS65090) += tps65090.o
159obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o 159obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o
160obj-$(CONFIG_MFD_ATMEL_HLCDC) += atmel-hlcdc.o
160obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o 161obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o
161obj-$(CONFIG_MFD_PALMAS) += palmas.o 162obj-$(CONFIG_MFD_PALMAS) += palmas.o
162obj-$(CONFIG_MFD_VIPERBOARD) += viperboard.o 163obj-$(CONFIG_MFD_VIPERBOARD) += viperboard.o
@@ -174,6 +175,7 @@ obj-$(CONFIG_MFD_STW481X) += stw481x.o
174obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o 175obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o
175obj-$(CONFIG_MFD_MENF21BMC) += menf21bmc.o 176obj-$(CONFIG_MFD_MENF21BMC) += menf21bmc.o
176obj-$(CONFIG_MFD_HI6421_PMIC) += hi6421-pmic-core.o 177obj-$(CONFIG_MFD_HI6421_PMIC) += hi6421-pmic-core.o
178obj-$(CONFIG_MFD_DLN2) += dln2.o
177 179
178intel-soc-pmic-objs := intel_soc_pmic_core.o intel_soc_pmic_crc.o 180intel-soc-pmic-objs := intel_soc_pmic_core.o intel_soc_pmic_crc.o
179obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o 181obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o
diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c
index 8e0dae59844d..94dbcdd2a1ff 100644
--- a/drivers/mfd/ab8500-sysctrl.c
+++ b/drivers/mfd/ab8500-sysctrl.c
@@ -85,63 +85,6 @@ shutdown:
85 } 85 }
86} 86}
87 87
88/*
89 * Use the AB WD to reset the platform. It will perform a hard
90 * reset instead of a soft reset. Write the reset reason to
91 * the AB before reset, which can be read upon restart.
92 */
93void ab8500_restart(char mode, const char *cmd)
94{
95 struct ab8500_platform_data *plat;
96 struct ab8500_sysctrl_platform_data *pdata;
97 u16 reason = 0;
98 u8 val;
99
100 if (sysctrl_dev == NULL) {
101 pr_err("%s: sysctrl not initialized\n", __func__);
102 return;
103 }
104
105 plat = dev_get_platdata(sysctrl_dev->parent);
106 pdata = plat->sysctrl;
107 if (pdata && pdata->reboot_reason_code)
108 reason = pdata->reboot_reason_code(cmd);
109 else
110 pr_warn("[%s] No reboot reason set. Default reason %d\n",
111 __func__, reason);
112
113 /*
114 * Disable RTC alarm, just a precaution so that no alarm
115 * is running when WD reset is executed.
116 */
117 abx500_get_register_interruptible(sysctrl_dev, AB8500_RTC,
118 RTC_CTRL , &val);
119 abx500_set_register_interruptible(sysctrl_dev, AB8500_RTC,
120 RTC_CTRL , (val & ~RTC_ALARM_ENABLE));
121
122 /*
123 * Android is not using the RTC alarm registers during reboot
124 * so we borrow them for writing the reason of reset
125 */
126
127 /* reason[8 LSB] */
128 val = reason & 0xFF;
129 abx500_set_register_interruptible(sysctrl_dev, AB8500_RTC,
130 AB8500_ALARM_MIN_LOW , val);
131
132 /* reason[8 MSB] */
133 val = (reason>>8) & 0xFF;
134 abx500_set_register_interruptible(sysctrl_dev, AB8500_RTC,
135 AB8500_ALARM_MIN_MID , val);
136
137 /* Setting WD timeout to 0 */
138 ab8500_sysctrl_write(AB8500_MAINWDOGTIMER, 0xFF, 0x0);
139
140 /* Setting the parameters to AB8500 WD*/
141 ab8500_sysctrl_write(AB8500_MAINWDOGCTRL, 0xFF, (AB8500_ENABLE_WD |
142 AB8500_WD_RESTART_ON_EXPIRE | AB8500_KICK_WD));
143}
144
145static inline bool valid_bank(u8 bank) 88static inline bool valid_bank(u8 bank)
146{ 89{
147 return ((bank == AB8500_SYS_CTRL1_BLOCK) || 90 return ((bank == AB8500_SYS_CTRL1_BLOCK) ||
diff --git a/drivers/mfd/arizona-spi.c b/drivers/mfd/arizona-spi.c
index 5145d78bf07e..8ef58bcff193 100644
--- a/drivers/mfd/arizona-spi.c
+++ b/drivers/mfd/arizona-spi.c
@@ -75,7 +75,9 @@ static int arizona_spi_probe(struct spi_device *spi)
75static int arizona_spi_remove(struct spi_device *spi) 75static int arizona_spi_remove(struct spi_device *spi)
76{ 76{
77 struct arizona *arizona = spi_get_drvdata(spi); 77 struct arizona *arizona = spi_get_drvdata(spi);
78
78 arizona_dev_exit(arizona); 79 arizona_dev_exit(arizona);
80
79 return 0; 81 return 0;
80} 82}
81 83
diff --git a/drivers/mfd/atmel-hlcdc.c b/drivers/mfd/atmel-hlcdc.c
new file mode 100644
index 000000000000..cfd58f4cc5c3
--- /dev/null
+++ b/drivers/mfd/atmel-hlcdc.c
@@ -0,0 +1,122 @@
1/*
2 * Copyright (C) 2014 Free Electrons
3 * Copyright (C) 2014 Atmel
4 *
5 * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <linux/clk.h>
21#include <linux/mfd/atmel-hlcdc.h>
22#include <linux/mfd/core.h>
23#include <linux/module.h>
24#include <linux/platform_device.h>
25#include <linux/regmap.h>
26
27#define ATMEL_HLCDC_REG_MAX (0x4000 - 0x4)
28
29static const struct mfd_cell atmel_hlcdc_cells[] = {
30 {
31 .name = "atmel-hlcdc-pwm",
32 .of_compatible = "atmel,hlcdc-pwm",
33 },
34 {
35 .name = "atmel-hlcdc-dc",
36 .of_compatible = "atmel,hlcdc-display-controller",
37 },
38};
39
40static const struct regmap_config atmel_hlcdc_regmap_config = {
41 .reg_bits = 32,
42 .val_bits = 32,
43 .reg_stride = 4,
44 .max_register = ATMEL_HLCDC_REG_MAX,
45};
46
47static int atmel_hlcdc_probe(struct platform_device *pdev)
48{
49 struct device *dev = &pdev->dev;
50 struct atmel_hlcdc *hlcdc;
51 struct resource *res;
52 void __iomem *regs;
53
54 hlcdc = devm_kzalloc(dev, sizeof(*hlcdc), GFP_KERNEL);
55 if (!hlcdc)
56 return -ENOMEM;
57
58 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
59 regs = devm_ioremap_resource(dev, res);
60 if (IS_ERR(regs))
61 return PTR_ERR(regs);
62
63 hlcdc->irq = platform_get_irq(pdev, 0);
64 if (hlcdc->irq < 0)
65 return hlcdc->irq;
66
67 hlcdc->periph_clk = devm_clk_get(dev, "periph_clk");
68 if (IS_ERR(hlcdc->periph_clk)) {
69 dev_err(dev, "failed to get peripheral clock\n");
70 return PTR_ERR(hlcdc->periph_clk);
71 }
72
73 hlcdc->sys_clk = devm_clk_get(dev, "sys_clk");
74 if (IS_ERR(hlcdc->sys_clk)) {
75 dev_err(dev, "failed to get system clock\n");
76 return PTR_ERR(hlcdc->sys_clk);
77 }
78
79 hlcdc->slow_clk = devm_clk_get(dev, "slow_clk");
80 if (IS_ERR(hlcdc->slow_clk)) {
81 dev_err(dev, "failed to get slow clock\n");
82 return PTR_ERR(hlcdc->slow_clk);
83 }
84
85 hlcdc->regmap = devm_regmap_init_mmio(dev, regs,
86 &atmel_hlcdc_regmap_config);
87 if (IS_ERR(hlcdc->regmap))
88 return PTR_ERR(hlcdc->regmap);
89
90 dev_set_drvdata(dev, hlcdc);
91
92 return mfd_add_devices(dev, -1, atmel_hlcdc_cells,
93 ARRAY_SIZE(atmel_hlcdc_cells),
94 NULL, 0, NULL);
95}
96
97static int atmel_hlcdc_remove(struct platform_device *pdev)
98{
99 mfd_remove_devices(&pdev->dev);
100
101 return 0;
102}
103
104static const struct of_device_id atmel_hlcdc_match[] = {
105 { .compatible = "atmel,sama5d3-hlcdc" },
106 { /* sentinel */ },
107};
108
109static struct platform_driver atmel_hlcdc_driver = {
110 .probe = atmel_hlcdc_probe,
111 .remove = atmel_hlcdc_remove,
112 .driver = {
113 .name = "atmel-hlcdc",
114 .of_match_table = atmel_hlcdc_match,
115 },
116};
117module_platform_driver(atmel_hlcdc_driver);
118
119MODULE_ALIAS("platform:atmel-hlcdc");
120MODULE_AUTHOR("Boris Brezillon <boris.brezillon@free-electrons.com>");
121MODULE_DESCRIPTION("Atmel HLCDC driver");
122MODULE_LICENSE("GPL v2");
diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index 6231adbb295d..c522ee22b1c0 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * axp20x.c - MFD core driver for the X-Powers AXP202 and AXP209 2 * axp20x.c - MFD core driver for the X-Powers' Power Management ICs
3 * 3 *
4 * AXP20x comprises an adaptive USB-Compatible PWM charger, 2 BUCK DC-DC 4 * AXP20x typically comprises an adaptive USB-Compatible PWM charger, BUCK DC-DC
5 * converters, 5 LDOs, multiple 12-bit ADCs of voltage, current and temperature 5 * converters, LDOs, multiple 12-bit ADCs of voltage, current and temperature
6 * as well as 4 configurable GPIOs. 6 * as well as configurable GPIOs.
7 * 7 *
8 * Author: Carlo Caione <carlo@caione.org> 8 * Author: Carlo Caione <carlo@caione.org>
9 * 9 *
@@ -25,9 +25,16 @@
25#include <linux/mfd/core.h> 25#include <linux/mfd/core.h>
26#include <linux/of_device.h> 26#include <linux/of_device.h>
27#include <linux/of_irq.h> 27#include <linux/of_irq.h>
28#include <linux/acpi.h>
28 29
29#define AXP20X_OFF 0x80 30#define AXP20X_OFF 0x80
30 31
32static const char const *axp20x_model_names[] = {
33 "AXP202",
34 "AXP209",
35 "AXP288",
36};
37
31static const struct regmap_range axp20x_writeable_ranges[] = { 38static const struct regmap_range axp20x_writeable_ranges[] = {
32 regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE), 39 regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
33 regmap_reg_range(AXP20X_DCDC_MODE, AXP20X_FG_RES), 40 regmap_reg_range(AXP20X_DCDC_MODE, AXP20X_FG_RES),
@@ -47,6 +54,25 @@ static const struct regmap_access_table axp20x_volatile_table = {
47 .n_yes_ranges = ARRAY_SIZE(axp20x_volatile_ranges), 54 .n_yes_ranges = ARRAY_SIZE(axp20x_volatile_ranges),
48}; 55};
49 56
57static const struct regmap_range axp288_writeable_ranges[] = {
58 regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ6_STATE),
59 regmap_reg_range(AXP20X_DCDC_MODE, AXP288_FG_TUNE5),
60};
61
62static const struct regmap_range axp288_volatile_ranges[] = {
63 regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IPSOUT_V_HIGH_L),
64};
65
66static const struct regmap_access_table axp288_writeable_table = {
67 .yes_ranges = axp288_writeable_ranges,
68 .n_yes_ranges = ARRAY_SIZE(axp288_writeable_ranges),
69};
70
71static const struct regmap_access_table axp288_volatile_table = {
72 .yes_ranges = axp288_volatile_ranges,
73 .n_yes_ranges = ARRAY_SIZE(axp288_volatile_ranges),
74};
75
50static struct resource axp20x_pek_resources[] = { 76static struct resource axp20x_pek_resources[] = {
51 { 77 {
52 .name = "PEK_DBR", 78 .name = "PEK_DBR",
@@ -61,6 +87,39 @@ static struct resource axp20x_pek_resources[] = {
61 }, 87 },
62}; 88};
63 89
90static struct resource axp288_battery_resources[] = {
91 {
92 .start = AXP288_IRQ_QWBTU,
93 .end = AXP288_IRQ_QWBTU,
94 .flags = IORESOURCE_IRQ,
95 },
96 {
97 .start = AXP288_IRQ_WBTU,
98 .end = AXP288_IRQ_WBTU,
99 .flags = IORESOURCE_IRQ,
100 },
101 {
102 .start = AXP288_IRQ_QWBTO,
103 .end = AXP288_IRQ_QWBTO,
104 .flags = IORESOURCE_IRQ,
105 },
106 {
107 .start = AXP288_IRQ_WBTO,
108 .end = AXP288_IRQ_WBTO,
109 .flags = IORESOURCE_IRQ,
110 },
111 {
112 .start = AXP288_IRQ_WL2,
113 .end = AXP288_IRQ_WL2,
114 .flags = IORESOURCE_IRQ,
115 },
116 {
117 .start = AXP288_IRQ_WL1,
118 .end = AXP288_IRQ_WL1,
119 .flags = IORESOURCE_IRQ,
120 },
121};
122
64static const struct regmap_config axp20x_regmap_config = { 123static const struct regmap_config axp20x_regmap_config = {
65 .reg_bits = 8, 124 .reg_bits = 8,
66 .val_bits = 8, 125 .val_bits = 8,
@@ -70,47 +129,96 @@ static const struct regmap_config axp20x_regmap_config = {
70 .cache_type = REGCACHE_RBTREE, 129 .cache_type = REGCACHE_RBTREE,
71}; 130};
72 131
73#define AXP20X_IRQ(_irq, _off, _mask) \ 132static const struct regmap_config axp288_regmap_config = {
74 [AXP20X_IRQ_##_irq] = { .reg_offset = (_off), .mask = BIT(_mask) } 133 .reg_bits = 8,
134 .val_bits = 8,
135 .wr_table = &axp288_writeable_table,
136 .volatile_table = &axp288_volatile_table,
137 .max_register = AXP288_FG_TUNE5,
138 .cache_type = REGCACHE_RBTREE,
139};
140
141#define INIT_REGMAP_IRQ(_variant, _irq, _off, _mask) \
142 [_variant##_IRQ_##_irq] = { .reg_offset = (_off), .mask = BIT(_mask) }
75 143
76static const struct regmap_irq axp20x_regmap_irqs[] = { 144static const struct regmap_irq axp20x_regmap_irqs[] = {
77 AXP20X_IRQ(ACIN_OVER_V, 0, 7), 145 INIT_REGMAP_IRQ(AXP20X, ACIN_OVER_V, 0, 7),
78 AXP20X_IRQ(ACIN_PLUGIN, 0, 6), 146 INIT_REGMAP_IRQ(AXP20X, ACIN_PLUGIN, 0, 6),
79 AXP20X_IRQ(ACIN_REMOVAL, 0, 5), 147 INIT_REGMAP_IRQ(AXP20X, ACIN_REMOVAL, 0, 5),
80 AXP20X_IRQ(VBUS_OVER_V, 0, 4), 148 INIT_REGMAP_IRQ(AXP20X, VBUS_OVER_V, 0, 4),
81 AXP20X_IRQ(VBUS_PLUGIN, 0, 3), 149 INIT_REGMAP_IRQ(AXP20X, VBUS_PLUGIN, 0, 3),
82 AXP20X_IRQ(VBUS_REMOVAL, 0, 2), 150 INIT_REGMAP_IRQ(AXP20X, VBUS_REMOVAL, 0, 2),
83 AXP20X_IRQ(VBUS_V_LOW, 0, 1), 151 INIT_REGMAP_IRQ(AXP20X, VBUS_V_LOW, 0, 1),
84 AXP20X_IRQ(BATT_PLUGIN, 1, 7), 152 INIT_REGMAP_IRQ(AXP20X, BATT_PLUGIN, 1, 7),
85 AXP20X_IRQ(BATT_REMOVAL, 1, 6), 153 INIT_REGMAP_IRQ(AXP20X, BATT_REMOVAL, 1, 6),
86 AXP20X_IRQ(BATT_ENT_ACT_MODE, 1, 5), 154 INIT_REGMAP_IRQ(AXP20X, BATT_ENT_ACT_MODE, 1, 5),
87 AXP20X_IRQ(BATT_EXIT_ACT_MODE, 1, 4), 155 INIT_REGMAP_IRQ(AXP20X, BATT_EXIT_ACT_MODE, 1, 4),
88 AXP20X_IRQ(CHARG, 1, 3), 156 INIT_REGMAP_IRQ(AXP20X, CHARG, 1, 3),
89 AXP20X_IRQ(CHARG_DONE, 1, 2), 157 INIT_REGMAP_IRQ(AXP20X, CHARG_DONE, 1, 2),
90 AXP20X_IRQ(BATT_TEMP_HIGH, 1, 1), 158 INIT_REGMAP_IRQ(AXP20X, BATT_TEMP_HIGH, 1, 1),
91 AXP20X_IRQ(BATT_TEMP_LOW, 1, 0), 159 INIT_REGMAP_IRQ(AXP20X, BATT_TEMP_LOW, 1, 0),
92 AXP20X_IRQ(DIE_TEMP_HIGH, 2, 7), 160 INIT_REGMAP_IRQ(AXP20X, DIE_TEMP_HIGH, 2, 7),
93 AXP20X_IRQ(CHARG_I_LOW, 2, 6), 161 INIT_REGMAP_IRQ(AXP20X, CHARG_I_LOW, 2, 6),
94 AXP20X_IRQ(DCDC1_V_LONG, 2, 5), 162 INIT_REGMAP_IRQ(AXP20X, DCDC1_V_LONG, 2, 5),
95 AXP20X_IRQ(DCDC2_V_LONG, 2, 4), 163 INIT_REGMAP_IRQ(AXP20X, DCDC2_V_LONG, 2, 4),
96 AXP20X_IRQ(DCDC3_V_LONG, 2, 3), 164 INIT_REGMAP_IRQ(AXP20X, DCDC3_V_LONG, 2, 3),
97 AXP20X_IRQ(PEK_SHORT, 2, 1), 165 INIT_REGMAP_IRQ(AXP20X, PEK_SHORT, 2, 1),
98 AXP20X_IRQ(PEK_LONG, 2, 0), 166 INIT_REGMAP_IRQ(AXP20X, PEK_LONG, 2, 0),
99 AXP20X_IRQ(N_OE_PWR_ON, 3, 7), 167 INIT_REGMAP_IRQ(AXP20X, N_OE_PWR_ON, 3, 7),
100 AXP20X_IRQ(N_OE_PWR_OFF, 3, 6), 168 INIT_REGMAP_IRQ(AXP20X, N_OE_PWR_OFF, 3, 6),
101 AXP20X_IRQ(VBUS_VALID, 3, 5), 169 INIT_REGMAP_IRQ(AXP20X, VBUS_VALID, 3, 5),
102 AXP20X_IRQ(VBUS_NOT_VALID, 3, 4), 170 INIT_REGMAP_IRQ(AXP20X, VBUS_NOT_VALID, 3, 4),
103 AXP20X_IRQ(VBUS_SESS_VALID, 3, 3), 171 INIT_REGMAP_IRQ(AXP20X, VBUS_SESS_VALID, 3, 3),
104 AXP20X_IRQ(VBUS_SESS_END, 3, 2), 172 INIT_REGMAP_IRQ(AXP20X, VBUS_SESS_END, 3, 2),
105 AXP20X_IRQ(LOW_PWR_LVL1, 3, 1), 173 INIT_REGMAP_IRQ(AXP20X, LOW_PWR_LVL1, 3, 1),
106 AXP20X_IRQ(LOW_PWR_LVL2, 3, 0), 174 INIT_REGMAP_IRQ(AXP20X, LOW_PWR_LVL2, 3, 0),
107 AXP20X_IRQ(TIMER, 4, 7), 175 INIT_REGMAP_IRQ(AXP20X, TIMER, 4, 7),
108 AXP20X_IRQ(PEK_RIS_EDGE, 4, 6), 176 INIT_REGMAP_IRQ(AXP20X, PEK_RIS_EDGE, 4, 6),
109 AXP20X_IRQ(PEK_FAL_EDGE, 4, 5), 177 INIT_REGMAP_IRQ(AXP20X, PEK_FAL_EDGE, 4, 5),
110 AXP20X_IRQ(GPIO3_INPUT, 4, 3), 178 INIT_REGMAP_IRQ(AXP20X, GPIO3_INPUT, 4, 3),
111 AXP20X_IRQ(GPIO2_INPUT, 4, 2), 179 INIT_REGMAP_IRQ(AXP20X, GPIO2_INPUT, 4, 2),
112 AXP20X_IRQ(GPIO1_INPUT, 4, 1), 180 INIT_REGMAP_IRQ(AXP20X, GPIO1_INPUT, 4, 1),
113 AXP20X_IRQ(GPIO0_INPUT, 4, 0), 181 INIT_REGMAP_IRQ(AXP20X, GPIO0_INPUT, 4, 0),
182};
183
184/* some IRQs are compatible with axp20x models */
185static const struct regmap_irq axp288_regmap_irqs[] = {
186 INIT_REGMAP_IRQ(AXP288, VBUS_FALL, 0, 2),
187 INIT_REGMAP_IRQ(AXP288, VBUS_RISE, 0, 3),
188 INIT_REGMAP_IRQ(AXP288, OV, 0, 4),
189
190 INIT_REGMAP_IRQ(AXP288, DONE, 1, 2),
191 INIT_REGMAP_IRQ(AXP288, CHARGING, 1, 3),
192 INIT_REGMAP_IRQ(AXP288, SAFE_QUIT, 1, 4),
193 INIT_REGMAP_IRQ(AXP288, SAFE_ENTER, 1, 5),
194 INIT_REGMAP_IRQ(AXP288, ABSENT, 1, 6),
195 INIT_REGMAP_IRQ(AXP288, APPEND, 1, 7),
196
197 INIT_REGMAP_IRQ(AXP288, QWBTU, 2, 0),
198 INIT_REGMAP_IRQ(AXP288, WBTU, 2, 1),
199 INIT_REGMAP_IRQ(AXP288, QWBTO, 2, 2),
200 INIT_REGMAP_IRQ(AXP288, WBTO, 2, 3),
201 INIT_REGMAP_IRQ(AXP288, QCBTU, 2, 4),
202 INIT_REGMAP_IRQ(AXP288, CBTU, 2, 5),
203 INIT_REGMAP_IRQ(AXP288, QCBTO, 2, 6),
204 INIT_REGMAP_IRQ(AXP288, CBTO, 2, 7),
205
206 INIT_REGMAP_IRQ(AXP288, WL2, 3, 0),
207 INIT_REGMAP_IRQ(AXP288, WL1, 3, 1),
208 INIT_REGMAP_IRQ(AXP288, GPADC, 3, 2),
209 INIT_REGMAP_IRQ(AXP288, OT, 3, 7),
210
211 INIT_REGMAP_IRQ(AXP288, GPIO0, 4, 0),
212 INIT_REGMAP_IRQ(AXP288, GPIO1, 4, 1),
213 INIT_REGMAP_IRQ(AXP288, POKO, 4, 2),
214 INIT_REGMAP_IRQ(AXP288, POKL, 4, 3),
215 INIT_REGMAP_IRQ(AXP288, POKS, 4, 4),
216 INIT_REGMAP_IRQ(AXP288, POKN, 4, 5),
217 INIT_REGMAP_IRQ(AXP288, POKP, 4, 6),
218 INIT_REGMAP_IRQ(AXP288, TIMER, 4, 7),
219
220 INIT_REGMAP_IRQ(AXP288, MV_CHNG, 5, 0),
221 INIT_REGMAP_IRQ(AXP288, BC_USB_CHNG, 5, 1),
114}; 222};
115 223
116static const struct of_device_id axp20x_of_match[] = { 224static const struct of_device_id axp20x_of_match[] = {
@@ -128,16 +236,39 @@ static const struct i2c_device_id axp20x_i2c_id[] = {
128}; 236};
129MODULE_DEVICE_TABLE(i2c, axp20x_i2c_id); 237MODULE_DEVICE_TABLE(i2c, axp20x_i2c_id);
130 238
239static const struct acpi_device_id axp20x_acpi_match[] = {
240 {
241 .id = "INT33F4",
242 .driver_data = AXP288_ID,
243 },
244 { },
245};
246MODULE_DEVICE_TABLE(acpi, axp20x_acpi_match);
247
131static const struct regmap_irq_chip axp20x_regmap_irq_chip = { 248static const struct regmap_irq_chip axp20x_regmap_irq_chip = {
132 .name = "axp20x_irq_chip", 249 .name = "axp20x_irq_chip",
133 .status_base = AXP20X_IRQ1_STATE, 250 .status_base = AXP20X_IRQ1_STATE,
134 .ack_base = AXP20X_IRQ1_STATE, 251 .ack_base = AXP20X_IRQ1_STATE,
135 .mask_base = AXP20X_IRQ1_EN, 252 .mask_base = AXP20X_IRQ1_EN,
136 .num_regs = 5, 253 .mask_invert = true,
254 .init_ack_masked = true,
137 .irqs = axp20x_regmap_irqs, 255 .irqs = axp20x_regmap_irqs,
138 .num_irqs = ARRAY_SIZE(axp20x_regmap_irqs), 256 .num_irqs = ARRAY_SIZE(axp20x_regmap_irqs),
257 .num_regs = 5,
258
259};
260
261static const struct regmap_irq_chip axp288_regmap_irq_chip = {
262 .name = "axp288_irq_chip",
263 .status_base = AXP20X_IRQ1_STATE,
264 .ack_base = AXP20X_IRQ1_STATE,
265 .mask_base = AXP20X_IRQ1_EN,
139 .mask_invert = true, 266 .mask_invert = true,
140 .init_ack_masked = true, 267 .init_ack_masked = true,
268 .irqs = axp288_regmap_irqs,
269 .num_irqs = ARRAY_SIZE(axp288_regmap_irqs),
270 .num_regs = 6,
271
141}; 272};
142 273
143static struct mfd_cell axp20x_cells[] = { 274static struct mfd_cell axp20x_cells[] = {
@@ -150,36 +281,155 @@ static struct mfd_cell axp20x_cells[] = {
150 }, 281 },
151}; 282};
152 283
284static struct resource axp288_adc_resources[] = {
285 {
286 .name = "GPADC",
287 .start = AXP288_IRQ_GPADC,
288 .end = AXP288_IRQ_GPADC,
289 .flags = IORESOURCE_IRQ,
290 },
291};
292
293static struct resource axp288_charger_resources[] = {
294 {
295 .start = AXP288_IRQ_OV,
296 .end = AXP288_IRQ_OV,
297 .flags = IORESOURCE_IRQ,
298 },
299 {
300 .start = AXP288_IRQ_DONE,
301 .end = AXP288_IRQ_DONE,
302 .flags = IORESOURCE_IRQ,
303 },
304 {
305 .start = AXP288_IRQ_CHARGING,
306 .end = AXP288_IRQ_CHARGING,
307 .flags = IORESOURCE_IRQ,
308 },
309 {
310 .start = AXP288_IRQ_SAFE_QUIT,
311 .end = AXP288_IRQ_SAFE_QUIT,
312 .flags = IORESOURCE_IRQ,
313 },
314 {
315 .start = AXP288_IRQ_SAFE_ENTER,
316 .end = AXP288_IRQ_SAFE_ENTER,
317 .flags = IORESOURCE_IRQ,
318 },
319 {
320 .start = AXP288_IRQ_QCBTU,
321 .end = AXP288_IRQ_QCBTU,
322 .flags = IORESOURCE_IRQ,
323 },
324 {
325 .start = AXP288_IRQ_CBTU,
326 .end = AXP288_IRQ_CBTU,
327 .flags = IORESOURCE_IRQ,
328 },
329 {
330 .start = AXP288_IRQ_QCBTO,
331 .end = AXP288_IRQ_QCBTO,
332 .flags = IORESOURCE_IRQ,
333 },
334 {
335 .start = AXP288_IRQ_CBTO,
336 .end = AXP288_IRQ_CBTO,
337 .flags = IORESOURCE_IRQ,
338 },
339};
340
341static struct mfd_cell axp288_cells[] = {
342 {
343 .name = "axp288_adc",
344 .num_resources = ARRAY_SIZE(axp288_adc_resources),
345 .resources = axp288_adc_resources,
346 },
347 {
348 .name = "axp288_charger",
349 .num_resources = ARRAY_SIZE(axp288_charger_resources),
350 .resources = axp288_charger_resources,
351 },
352 {
353 .name = "axp288_battery",
354 .num_resources = ARRAY_SIZE(axp288_battery_resources),
355 .resources = axp288_battery_resources,
356 },
357};
358
153static struct axp20x_dev *axp20x_pm_power_off; 359static struct axp20x_dev *axp20x_pm_power_off;
154static void axp20x_power_off(void) 360static void axp20x_power_off(void)
155{ 361{
362 if (axp20x_pm_power_off->variant == AXP288_ID)
363 return;
364
156 regmap_write(axp20x_pm_power_off->regmap, AXP20X_OFF_CTRL, 365 regmap_write(axp20x_pm_power_off->regmap, AXP20X_OFF_CTRL,
157 AXP20X_OFF); 366 AXP20X_OFF);
158} 367}
159 368
369static int axp20x_match_device(struct axp20x_dev *axp20x, struct device *dev)
370{
371 const struct acpi_device_id *acpi_id;
372 const struct of_device_id *of_id;
373
374 if (dev->of_node) {
375 of_id = of_match_device(axp20x_of_match, dev);
376 if (!of_id) {
377 dev_err(dev, "Unable to match OF ID\n");
378 return -ENODEV;
379 }
380 axp20x->variant = (long) of_id->data;
381 } else {
382 acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev);
383 if (!acpi_id || !acpi_id->driver_data) {
384 dev_err(dev, "Unable to match ACPI ID and data\n");
385 return -ENODEV;
386 }
387 axp20x->variant = (long) acpi_id->driver_data;
388 }
389
390 switch (axp20x->variant) {
391 case AXP202_ID:
392 case AXP209_ID:
393 axp20x->nr_cells = ARRAY_SIZE(axp20x_cells);
394 axp20x->cells = axp20x_cells;
395 axp20x->regmap_cfg = &axp20x_regmap_config;
396 axp20x->regmap_irq_chip = &axp20x_regmap_irq_chip;
397 break;
398 case AXP288_ID:
399 axp20x->cells = axp288_cells;
400 axp20x->nr_cells = ARRAY_SIZE(axp288_cells);
401 axp20x->regmap_cfg = &axp288_regmap_config;
402 axp20x->regmap_irq_chip = &axp288_regmap_irq_chip;
403 break;
404 default:
405 dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant);
406 return -EINVAL;
407 }
408 dev_info(dev, "AXP20x variant %s found\n",
409 axp20x_model_names[axp20x->variant]);
410
411 return 0;
412}
413
160static int axp20x_i2c_probe(struct i2c_client *i2c, 414static int axp20x_i2c_probe(struct i2c_client *i2c,
161 const struct i2c_device_id *id) 415 const struct i2c_device_id *id)
162{ 416{
163 struct axp20x_dev *axp20x; 417 struct axp20x_dev *axp20x;
164 const struct of_device_id *of_id;
165 int ret; 418 int ret;
166 419
167 axp20x = devm_kzalloc(&i2c->dev, sizeof(*axp20x), GFP_KERNEL); 420 axp20x = devm_kzalloc(&i2c->dev, sizeof(*axp20x), GFP_KERNEL);
168 if (!axp20x) 421 if (!axp20x)
169 return -ENOMEM; 422 return -ENOMEM;
170 423
171 of_id = of_match_device(axp20x_of_match, &i2c->dev); 424 ret = axp20x_match_device(axp20x, &i2c->dev);
172 if (!of_id) { 425 if (ret)
173 dev_err(&i2c->dev, "Unable to setup AXP20X data\n"); 426 return ret;
174 return -ENODEV;
175 }
176 axp20x->variant = (long) of_id->data;
177 427
178 axp20x->i2c_client = i2c; 428 axp20x->i2c_client = i2c;
179 axp20x->dev = &i2c->dev; 429 axp20x->dev = &i2c->dev;
180 dev_set_drvdata(axp20x->dev, axp20x); 430 dev_set_drvdata(axp20x->dev, axp20x);
181 431
182 axp20x->regmap = devm_regmap_init_i2c(i2c, &axp20x_regmap_config); 432 axp20x->regmap = devm_regmap_init_i2c(i2c, axp20x->regmap_cfg);
183 if (IS_ERR(axp20x->regmap)) { 433 if (IS_ERR(axp20x->regmap)) {
184 ret = PTR_ERR(axp20x->regmap); 434 ret = PTR_ERR(axp20x->regmap);
185 dev_err(&i2c->dev, "regmap init failed: %d\n", ret); 435 dev_err(&i2c->dev, "regmap init failed: %d\n", ret);
@@ -188,15 +438,15 @@ static int axp20x_i2c_probe(struct i2c_client *i2c,
188 438
189 ret = regmap_add_irq_chip(axp20x->regmap, i2c->irq, 439 ret = regmap_add_irq_chip(axp20x->regmap, i2c->irq,
190 IRQF_ONESHOT | IRQF_SHARED, -1, 440 IRQF_ONESHOT | IRQF_SHARED, -1,
191 &axp20x_regmap_irq_chip, 441 axp20x->regmap_irq_chip,
192 &axp20x->regmap_irqc); 442 &axp20x->regmap_irqc);
193 if (ret) { 443 if (ret) {
194 dev_err(&i2c->dev, "failed to add irq chip: %d\n", ret); 444 dev_err(&i2c->dev, "failed to add irq chip: %d\n", ret);
195 return ret; 445 return ret;
196 } 446 }
197 447
198 ret = mfd_add_devices(axp20x->dev, -1, axp20x_cells, 448 ret = mfd_add_devices(axp20x->dev, -1, axp20x->cells,
199 ARRAY_SIZE(axp20x_cells), NULL, 0, NULL); 449 axp20x->nr_cells, NULL, 0, NULL);
200 450
201 if (ret) { 451 if (ret) {
202 dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret); 452 dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret);
@@ -234,6 +484,7 @@ static struct i2c_driver axp20x_i2c_driver = {
234 .name = "axp20x", 484 .name = "axp20x",
235 .owner = THIS_MODULE, 485 .owner = THIS_MODULE,
236 .of_match_table = of_match_ptr(axp20x_of_match), 486 .of_match_table = of_match_ptr(axp20x_of_match),
487 .acpi_match_table = ACPI_PTR(axp20x_acpi_match),
237 }, 488 },
238 .probe = axp20x_i2c_probe, 489 .probe = axp20x_i2c_probe,
239 .remove = axp20x_i2c_remove, 490 .remove = axp20x_i2c_remove,
diff --git a/drivers/mfd/da9063-core.c b/drivers/mfd/da9063-core.c
index 93db8bb8c8f0..f38bc98a3c57 100644
--- a/drivers/mfd/da9063-core.c
+++ b/drivers/mfd/da9063-core.c
@@ -118,7 +118,7 @@ int da9063_device_init(struct da9063 *da9063, unsigned int irq)
118 da9063->irq_base = pdata->irq_base; 118 da9063->irq_base = pdata->irq_base;
119 } else { 119 } else {
120 da9063->flags = 0; 120 da9063->flags = 0;
121 da9063->irq_base = 0; 121 da9063->irq_base = -1;
122 } 122 }
123 da9063->chip_irq = irq; 123 da9063->chip_irq = irq;
124 124
@@ -168,6 +168,8 @@ int da9063_device_init(struct da9063 *da9063, unsigned int irq)
168 return ret; 168 return ret;
169 } 169 }
170 170
171 da9063->irq_base = regmap_irq_chip_get_base(da9063->regmap_irq);
172
171 ret = mfd_add_devices(da9063->dev, -1, da9063_devs, 173 ret = mfd_add_devices(da9063->dev, -1, da9063_devs,
172 ARRAY_SIZE(da9063_devs), NULL, da9063->irq_base, 174 ARRAY_SIZE(da9063_devs), NULL, da9063->irq_base,
173 NULL); 175 NULL);
diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c
index 193cf168ba84..a8204730f01c 100644
--- a/drivers/mfd/db8500-prcmu.c
+++ b/drivers/mfd/db8500-prcmu.c
@@ -3150,23 +3150,28 @@ static int db8500_prcmu_probe(struct platform_device *pdev)
3150 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "prcmu"); 3150 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "prcmu");
3151 if (!res) { 3151 if (!res) {
3152 dev_err(&pdev->dev, "no prcmu memory region provided\n"); 3152 dev_err(&pdev->dev, "no prcmu memory region provided\n");
3153 return -ENOENT; 3153 return -EINVAL;
3154 } 3154 }
3155 prcmu_base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); 3155 prcmu_base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
3156 if (!prcmu_base) { 3156 if (!prcmu_base) {
3157 dev_err(&pdev->dev, 3157 dev_err(&pdev->dev,
3158 "failed to ioremap prcmu register memory\n"); 3158 "failed to ioremap prcmu register memory\n");
3159 return -ENOENT; 3159 return -ENOMEM;
3160 } 3160 }
3161 init_prcm_registers(); 3161 init_prcm_registers();
3162 dbx500_fw_version_init(pdev, pdata->version_offset); 3162 dbx500_fw_version_init(pdev, pdata->version_offset);
3163 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "prcmu-tcdm"); 3163 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "prcmu-tcdm");
3164 if (!res) { 3164 if (!res) {
3165 dev_err(&pdev->dev, "no prcmu tcdm region provided\n"); 3165 dev_err(&pdev->dev, "no prcmu tcdm region provided\n");
3166 return -ENOENT; 3166 return -EINVAL;
3167 } 3167 }
3168 tcdm_base = devm_ioremap(&pdev->dev, res->start, 3168 tcdm_base = devm_ioremap(&pdev->dev, res->start,
3169 resource_size(res)); 3169 resource_size(res));
3170 if (!tcdm_base) {
3171 dev_err(&pdev->dev,
3172 "failed to ioremap prcmu-tcdm register memory\n");
3173 return -ENOMEM;
3174 }
3170 3175
3171 /* Clean up the mailbox interrupts after pre-kernel code. */ 3176 /* Clean up the mailbox interrupts after pre-kernel code. */
3172 writel(ALL_MBOX_BITS, PRCM_ARM_IT1_CLR); 3177 writel(ALL_MBOX_BITS, PRCM_ARM_IT1_CLR);
@@ -3174,15 +3179,14 @@ static int db8500_prcmu_probe(struct platform_device *pdev)
3174 irq = platform_get_irq(pdev, 0); 3179 irq = platform_get_irq(pdev, 0);
3175 if (irq <= 0) { 3180 if (irq <= 0) {
3176 dev_err(&pdev->dev, "no prcmu irq provided\n"); 3181 dev_err(&pdev->dev, "no prcmu irq provided\n");
3177 return -ENOENT; 3182 return irq;
3178 } 3183 }
3179 3184
3180 err = request_threaded_irq(irq, prcmu_irq_handler, 3185 err = request_threaded_irq(irq, prcmu_irq_handler,
3181 prcmu_irq_thread_fn, IRQF_NO_SUSPEND, "prcmu", NULL); 3186 prcmu_irq_thread_fn, IRQF_NO_SUSPEND, "prcmu", NULL);
3182 if (err < 0) { 3187 if (err < 0) {
3183 pr_err("prcmu: Failed to allocate IRQ_DB8500_PRCMU1.\n"); 3188 pr_err("prcmu: Failed to allocate IRQ_DB8500_PRCMU1.\n");
3184 err = -EBUSY; 3189 return err;
3185 goto no_irq_return;
3186 } 3190 }
3187 3191
3188 db8500_irq_init(np); 3192 db8500_irq_init(np);
@@ -3206,7 +3210,7 @@ static int db8500_prcmu_probe(struct platform_device *pdev)
3206 if (err) { 3210 if (err) {
3207 mfd_remove_devices(&pdev->dev); 3211 mfd_remove_devices(&pdev->dev);
3208 pr_err("prcmu: Failed to add subdevices\n"); 3212 pr_err("prcmu: Failed to add subdevices\n");
3209 goto no_irq_return; 3213 return err;
3210 } 3214 }
3211 } 3215 }
3212 3216
@@ -3214,12 +3218,10 @@ static int db8500_prcmu_probe(struct platform_device *pdev)
3214 if (err) { 3218 if (err) {
3215 mfd_remove_devices(&pdev->dev); 3219 mfd_remove_devices(&pdev->dev);
3216 pr_err("prcmu: Failed to add ab8500 subdevice\n"); 3220 pr_err("prcmu: Failed to add ab8500 subdevice\n");
3217 goto no_irq_return; 3221 return err;
3218 } 3222 }
3219 3223
3220 pr_info("DB8500 PRCMU initialized\n"); 3224 pr_info("DB8500 PRCMU initialized\n");
3221
3222no_irq_return:
3223 return err; 3225 return err;
3224} 3226}
3225static const struct of_device_id db8500_prcmu_match[] = { 3227static const struct of_device_id db8500_prcmu_match[] = {
diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
new file mode 100644
index 000000000000..6d49685d4ee4
--- /dev/null
+++ b/drivers/mfd/dln2.c
@@ -0,0 +1,781 @@
1/*
2 * Driver for the Diolan DLN-2 USB adapter
3 *
4 * Copyright (c) 2014 Intel Corporation
5 *
6 * Derived from:
7 * i2c-diolan-u2c.c
8 * Copyright (c) 2010-2011 Ericsson AB
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation, version 2.
13 */
14
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/types.h>
18#include <linux/slab.h>
19#include <linux/usb.h>
20#include <linux/i2c.h>
21#include <linux/mutex.h>
22#include <linux/platform_device.h>
23#include <linux/mfd/core.h>
24#include <linux/mfd/dln2.h>
25#include <linux/rculist.h>
26
27struct dln2_header {
28 __le16 size;
29 __le16 id;
30 __le16 echo;
31 __le16 handle;
32};
33
34struct dln2_response {
35 struct dln2_header hdr;
36 __le16 result;
37};
38
39#define DLN2_GENERIC_MODULE_ID 0x00
40#define DLN2_GENERIC_CMD(cmd) DLN2_CMD(cmd, DLN2_GENERIC_MODULE_ID)
41#define CMD_GET_DEVICE_VER DLN2_GENERIC_CMD(0x30)
42#define CMD_GET_DEVICE_SN DLN2_GENERIC_CMD(0x31)
43
44#define DLN2_HW_ID 0x200
45#define DLN2_USB_TIMEOUT 200 /* in ms */
46#define DLN2_MAX_RX_SLOTS 16
47#define DLN2_MAX_URBS 16
48#define DLN2_RX_BUF_SIZE 512
49
50enum dln2_handle {
51 DLN2_HANDLE_EVENT = 0, /* don't change, hardware defined */
52 DLN2_HANDLE_CTRL,
53 DLN2_HANDLE_GPIO,
54 DLN2_HANDLE_I2C,
55 DLN2_HANDLE_SPI,
56 DLN2_HANDLES
57};
58
59/*
60 * Receive context used between the receive demultiplexer and the transfer
61 * routine. While sending a request the transfer routine will look for a free
62 * receive context and use it to wait for a response and to receive the URB and
63 * thus the response data.
64 */
65struct dln2_rx_context {
66 /* completion used to wait for a response */
67 struct completion done;
68
69 /* if non-NULL the URB contains the response */
70 struct urb *urb;
71
72 /* if true then this context is used to wait for a response */
73 bool in_use;
74};
75
76/*
77 * Receive contexts for a particular DLN2 module (i2c, gpio, etc.). We use the
78 * handle header field to identify the module in dln2_dev.mod_rx_slots and then
79 * the echo header field to index the slots field and find the receive context
80 * for a particular request.
81 */
82struct dln2_mod_rx_slots {
83 /* RX slots bitmap */
84 DECLARE_BITMAP(bmap, DLN2_MAX_RX_SLOTS);
85
86 /* used to wait for a free RX slot */
87 wait_queue_head_t wq;
88
89 /* used to wait for an RX operation to complete */
90 struct dln2_rx_context slots[DLN2_MAX_RX_SLOTS];
91
92 /* avoid races between alloc/free_rx_slot and dln2_rx_transfer */
93 spinlock_t lock;
94};
95
96struct dln2_dev {
97 struct usb_device *usb_dev;
98 struct usb_interface *interface;
99 u8 ep_in;
100 u8 ep_out;
101
102 struct urb *rx_urb[DLN2_MAX_URBS];
103 void *rx_buf[DLN2_MAX_URBS];
104
105 struct dln2_mod_rx_slots mod_rx_slots[DLN2_HANDLES];
106
107 struct list_head event_cb_list;
108 spinlock_t event_cb_lock;
109
110 bool disconnect;
111 int active_transfers;
112 wait_queue_head_t disconnect_wq;
113 spinlock_t disconnect_lock;
114};
115
116struct dln2_event_cb_entry {
117 struct list_head list;
118 u16 id;
119 struct platform_device *pdev;
120 dln2_event_cb_t callback;
121};
122
123int dln2_register_event_cb(struct platform_device *pdev, u16 id,
124 dln2_event_cb_t event_cb)
125{
126 struct dln2_dev *dln2 = dev_get_drvdata(pdev->dev.parent);
127 struct dln2_event_cb_entry *i, *entry;
128 unsigned long flags;
129 int ret = 0;
130
131 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
132 if (!entry)
133 return -ENOMEM;
134
135 entry->id = id;
136 entry->callback = event_cb;
137 entry->pdev = pdev;
138
139 spin_lock_irqsave(&dln2->event_cb_lock, flags);
140
141 list_for_each_entry(i, &dln2->event_cb_list, list) {
142 if (i->id == id) {
143 ret = -EBUSY;
144 break;
145 }
146 }
147
148 if (!ret)
149 list_add_rcu(&entry->list, &dln2->event_cb_list);
150
151 spin_unlock_irqrestore(&dln2->event_cb_lock, flags);
152
153 if (ret)
154 kfree(entry);
155
156 return ret;
157}
158EXPORT_SYMBOL(dln2_register_event_cb);
159
160void dln2_unregister_event_cb(struct platform_device *pdev, u16 id)
161{
162 struct dln2_dev *dln2 = dev_get_drvdata(pdev->dev.parent);
163 struct dln2_event_cb_entry *i;
164 unsigned long flags;
165 bool found = false;
166
167 spin_lock_irqsave(&dln2->event_cb_lock, flags);
168
169 list_for_each_entry(i, &dln2->event_cb_list, list) {
170 if (i->id == id) {
171 list_del_rcu(&i->list);
172 found = true;
173 break;
174 }
175 }
176
177 spin_unlock_irqrestore(&dln2->event_cb_lock, flags);
178
179 if (found) {
180 synchronize_rcu();
181 kfree(i);
182 }
183}
184EXPORT_SYMBOL(dln2_unregister_event_cb);
185
186/*
187 * Returns true if a valid transfer slot is found. In this case the URB must not
188 * be resubmitted immediately in dln2_rx as we need the data when dln2_transfer
189 * is woke up. It will be resubmitted there.
190 */
191static bool dln2_transfer_complete(struct dln2_dev *dln2, struct urb *urb,
192 u16 handle, u16 rx_slot)
193{
194 struct device *dev = &dln2->interface->dev;
195 struct dln2_mod_rx_slots *rxs = &dln2->mod_rx_slots[handle];
196 struct dln2_rx_context *rxc;
197 bool valid_slot = false;
198
199 if (rx_slot >= DLN2_MAX_RX_SLOTS)
200 goto out;
201
202 rxc = &rxs->slots[rx_slot];
203
204 /*
205 * No need to disable interrupts as this lock is not taken in interrupt
206 * context elsewhere in this driver. This function (or its callers) are
207 * also not exported to other modules.
208 */
209 spin_lock(&rxs->lock);
210 if (rxc->in_use && !rxc->urb) {
211 rxc->urb = urb;
212 complete(&rxc->done);
213 valid_slot = true;
214 }
215 spin_unlock(&rxs->lock);
216
217out:
218 if (!valid_slot)
219 dev_warn(dev, "bad/late response %d/%d\n", handle, rx_slot);
220
221 return valid_slot;
222}
223
224static void dln2_run_event_callbacks(struct dln2_dev *dln2, u16 id, u16 echo,
225 void *data, int len)
226{
227 struct dln2_event_cb_entry *i;
228
229 rcu_read_lock();
230
231 list_for_each_entry_rcu(i, &dln2->event_cb_list, list) {
232 if (i->id == id) {
233 i->callback(i->pdev, echo, data, len);
234 break;
235 }
236 }
237
238 rcu_read_unlock();
239}
240
241static void dln2_rx(struct urb *urb)
242{
243 struct dln2_dev *dln2 = urb->context;
244 struct dln2_header *hdr = urb->transfer_buffer;
245 struct device *dev = &dln2->interface->dev;
246 u16 id, echo, handle, size;
247 u8 *data;
248 int len;
249 int err;
250
251 switch (urb->status) {
252 case 0:
253 /* success */
254 break;
255 case -ECONNRESET:
256 case -ENOENT:
257 case -ESHUTDOWN:
258 case -EPIPE:
259 /* this urb is terminated, clean up */
260 dev_dbg(dev, "urb shutting down with status %d\n", urb->status);
261 return;
262 default:
263 dev_dbg(dev, "nonzero urb status received %d\n", urb->status);
264 goto out;
265 }
266
267 if (urb->actual_length < sizeof(struct dln2_header)) {
268 dev_err(dev, "short response: %d\n", urb->actual_length);
269 goto out;
270 }
271
272 handle = le16_to_cpu(hdr->handle);
273 id = le16_to_cpu(hdr->id);
274 echo = le16_to_cpu(hdr->echo);
275 size = le16_to_cpu(hdr->size);
276
277 if (size != urb->actual_length) {
278 dev_err(dev, "size mismatch: handle %x cmd %x echo %x size %d actual %d\n",
279 handle, id, echo, size, urb->actual_length);
280 goto out;
281 }
282
283 if (handle >= DLN2_HANDLES) {
284 dev_warn(dev, "invalid handle %d\n", handle);
285 goto out;
286 }
287
288 data = urb->transfer_buffer + sizeof(struct dln2_header);
289 len = urb->actual_length - sizeof(struct dln2_header);
290
291 if (handle == DLN2_HANDLE_EVENT) {
292 dln2_run_event_callbacks(dln2, id, echo, data, len);
293 } else {
294 /* URB will be re-submitted in _dln2_transfer (free_rx_slot) */
295 if (dln2_transfer_complete(dln2, urb, handle, echo))
296 return;
297 }
298
299out:
300 err = usb_submit_urb(urb, GFP_ATOMIC);
301 if (err < 0)
302 dev_err(dev, "failed to resubmit RX URB: %d\n", err);
303}
304
305static void *dln2_prep_buf(u16 handle, u16 cmd, u16 echo, const void *obuf,
306 int *obuf_len, gfp_t gfp)
307{
308 int len;
309 void *buf;
310 struct dln2_header *hdr;
311
312 len = *obuf_len + sizeof(*hdr);
313 buf = kmalloc(len, gfp);
314 if (!buf)
315 return NULL;
316
317 hdr = (struct dln2_header *)buf;
318 hdr->id = cpu_to_le16(cmd);
319 hdr->size = cpu_to_le16(len);
320 hdr->echo = cpu_to_le16(echo);
321 hdr->handle = cpu_to_le16(handle);
322
323 memcpy(buf + sizeof(*hdr), obuf, *obuf_len);
324
325 *obuf_len = len;
326
327 return buf;
328}
329
330static int dln2_send_wait(struct dln2_dev *dln2, u16 handle, u16 cmd, u16 echo,
331 const void *obuf, int obuf_len)
332{
333 int ret = 0;
334 int len = obuf_len;
335 void *buf;
336 int actual;
337
338 buf = dln2_prep_buf(handle, cmd, echo, obuf, &len, GFP_KERNEL);
339 if (!buf)
340 return -ENOMEM;
341
342 ret = usb_bulk_msg(dln2->usb_dev,
343 usb_sndbulkpipe(dln2->usb_dev, dln2->ep_out),
344 buf, len, &actual, DLN2_USB_TIMEOUT);
345
346 kfree(buf);
347
348 return ret;
349}
350
351static bool find_free_slot(struct dln2_dev *dln2, u16 handle, int *slot)
352{
353 struct dln2_mod_rx_slots *rxs;
354 unsigned long flags;
355
356 if (dln2->disconnect) {
357 *slot = -ENODEV;
358 return true;
359 }
360
361 rxs = &dln2->mod_rx_slots[handle];
362
363 spin_lock_irqsave(&rxs->lock, flags);
364
365 *slot = find_first_zero_bit(rxs->bmap, DLN2_MAX_RX_SLOTS);
366
367 if (*slot < DLN2_MAX_RX_SLOTS) {
368 struct dln2_rx_context *rxc = &rxs->slots[*slot];
369
370 set_bit(*slot, rxs->bmap);
371 rxc->in_use = true;
372 }
373
374 spin_unlock_irqrestore(&rxs->lock, flags);
375
376 return *slot < DLN2_MAX_RX_SLOTS;
377}
378
379static int alloc_rx_slot(struct dln2_dev *dln2, u16 handle)
380{
381 int ret;
382 int slot;
383
384 /*
385 * No need to timeout here, the wait is bounded by the timeout in
386 * _dln2_transfer.
387 */
388 ret = wait_event_interruptible(dln2->mod_rx_slots[handle].wq,
389 find_free_slot(dln2, handle, &slot));
390 if (ret < 0)
391 return ret;
392
393 return slot;
394}
395
396static void free_rx_slot(struct dln2_dev *dln2, u16 handle, int slot)
397{
398 struct dln2_mod_rx_slots *rxs;
399 struct urb *urb = NULL;
400 unsigned long flags;
401 struct dln2_rx_context *rxc;
402
403 rxs = &dln2->mod_rx_slots[handle];
404
405 spin_lock_irqsave(&rxs->lock, flags);
406
407 clear_bit(slot, rxs->bmap);
408
409 rxc = &rxs->slots[slot];
410 rxc->in_use = false;
411 urb = rxc->urb;
412 rxc->urb = NULL;
413 reinit_completion(&rxc->done);
414
415 spin_unlock_irqrestore(&rxs->lock, flags);
416
417 if (urb) {
418 int err;
419 struct device *dev = &dln2->interface->dev;
420
421 err = usb_submit_urb(urb, GFP_KERNEL);
422 if (err < 0)
423 dev_err(dev, "failed to resubmit RX URB: %d\n", err);
424 }
425
426 wake_up_interruptible(&rxs->wq);
427}
428
429static int _dln2_transfer(struct dln2_dev *dln2, u16 handle, u16 cmd,
430 const void *obuf, unsigned obuf_len,
431 void *ibuf, unsigned *ibuf_len)
432{
433 int ret = 0;
434 int rx_slot;
435 struct dln2_response *rsp;
436 struct dln2_rx_context *rxc;
437 struct device *dev = &dln2->interface->dev;
438 const unsigned long timeout = DLN2_USB_TIMEOUT * HZ / 1000;
439 struct dln2_mod_rx_slots *rxs = &dln2->mod_rx_slots[handle];
440 int size;
441
442 spin_lock(&dln2->disconnect_lock);
443 if (!dln2->disconnect)
444 dln2->active_transfers++;
445 else
446 ret = -ENODEV;
447 spin_unlock(&dln2->disconnect_lock);
448
449 if (ret)
450 return ret;
451
452 rx_slot = alloc_rx_slot(dln2, handle);
453 if (rx_slot < 0) {
454 ret = rx_slot;
455 goto out_decr;
456 }
457
458 ret = dln2_send_wait(dln2, handle, cmd, rx_slot, obuf, obuf_len);
459 if (ret < 0) {
460 dev_err(dev, "USB write failed: %d\n", ret);
461 goto out_free_rx_slot;
462 }
463
464 rxc = &rxs->slots[rx_slot];
465
466 ret = wait_for_completion_interruptible_timeout(&rxc->done, timeout);
467 if (ret <= 0) {
468 if (!ret)
469 ret = -ETIMEDOUT;
470 goto out_free_rx_slot;
471 } else {
472 ret = 0;
473 }
474
475 if (dln2->disconnect) {
476 ret = -ENODEV;
477 goto out_free_rx_slot;
478 }
479
480 /* if we got here we know that the response header has been checked */
481 rsp = rxc->urb->transfer_buffer;
482 size = le16_to_cpu(rsp->hdr.size);
483
484 if (size < sizeof(*rsp)) {
485 ret = -EPROTO;
486 goto out_free_rx_slot;
487 }
488
489 if (le16_to_cpu(rsp->result) > 0x80) {
490 dev_dbg(dev, "%d received response with error %d\n",
491 handle, le16_to_cpu(rsp->result));
492 ret = -EREMOTEIO;
493 goto out_free_rx_slot;
494 }
495
496 if (!ibuf)
497 goto out_free_rx_slot;
498
499 if (*ibuf_len > size - sizeof(*rsp))
500 *ibuf_len = size - sizeof(*rsp);
501
502 memcpy(ibuf, rsp + 1, *ibuf_len);
503
504out_free_rx_slot:
505 free_rx_slot(dln2, handle, rx_slot);
506out_decr:
507 spin_lock(&dln2->disconnect_lock);
508 dln2->active_transfers--;
509 spin_unlock(&dln2->disconnect_lock);
510 if (dln2->disconnect)
511 wake_up(&dln2->disconnect_wq);
512
513 return ret;
514}
515
516int dln2_transfer(struct platform_device *pdev, u16 cmd,
517 const void *obuf, unsigned obuf_len,
518 void *ibuf, unsigned *ibuf_len)
519{
520 struct dln2_platform_data *dln2_pdata;
521 struct dln2_dev *dln2;
522 u16 handle;
523
524 dln2 = dev_get_drvdata(pdev->dev.parent);
525 dln2_pdata = dev_get_platdata(&pdev->dev);
526 handle = dln2_pdata->handle;
527
528 return _dln2_transfer(dln2, handle, cmd, obuf, obuf_len, ibuf,
529 ibuf_len);
530}
531EXPORT_SYMBOL(dln2_transfer);
532
533static int dln2_check_hw(struct dln2_dev *dln2)
534{
535 int ret;
536 __le32 hw_type;
537 int len = sizeof(hw_type);
538
539 ret = _dln2_transfer(dln2, DLN2_HANDLE_CTRL, CMD_GET_DEVICE_VER,
540 NULL, 0, &hw_type, &len);
541 if (ret < 0)
542 return ret;
543 if (len < sizeof(hw_type))
544 return -EREMOTEIO;
545
546 if (le32_to_cpu(hw_type) != DLN2_HW_ID) {
547 dev_err(&dln2->interface->dev, "Device ID 0x%x not supported\n",
548 le32_to_cpu(hw_type));
549 return -ENODEV;
550 }
551
552 return 0;
553}
554
555static int dln2_print_serialno(struct dln2_dev *dln2)
556{
557 int ret;
558 __le32 serial_no;
559 int len = sizeof(serial_no);
560 struct device *dev = &dln2->interface->dev;
561
562 ret = _dln2_transfer(dln2, DLN2_HANDLE_CTRL, CMD_GET_DEVICE_SN, NULL, 0,
563 &serial_no, &len);
564 if (ret < 0)
565 return ret;
566 if (len < sizeof(serial_no))
567 return -EREMOTEIO;
568
569 dev_info(dev, "Diolan DLN2 serial %u\n", le32_to_cpu(serial_no));
570
571 return 0;
572}
573
574static int dln2_hw_init(struct dln2_dev *dln2)
575{
576 int ret;
577
578 ret = dln2_check_hw(dln2);
579 if (ret < 0)
580 return ret;
581
582 return dln2_print_serialno(dln2);
583}
584
585static void dln2_free_rx_urbs(struct dln2_dev *dln2)
586{
587 int i;
588
589 for (i = 0; i < DLN2_MAX_URBS; i++) {
590 usb_kill_urb(dln2->rx_urb[i]);
591 usb_free_urb(dln2->rx_urb[i]);
592 kfree(dln2->rx_buf[i]);
593 }
594}
595
596static void dln2_free(struct dln2_dev *dln2)
597{
598 dln2_free_rx_urbs(dln2);
599 usb_put_dev(dln2->usb_dev);
600 kfree(dln2);
601}
602
603static int dln2_setup_rx_urbs(struct dln2_dev *dln2,
604 struct usb_host_interface *hostif)
605{
606 int i;
607 int ret;
608 const int rx_max_size = DLN2_RX_BUF_SIZE;
609 struct device *dev = &dln2->interface->dev;
610
611 for (i = 0; i < DLN2_MAX_URBS; i++) {
612 dln2->rx_buf[i] = kmalloc(rx_max_size, GFP_KERNEL);
613 if (!dln2->rx_buf[i])
614 return -ENOMEM;
615
616 dln2->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
617 if (!dln2->rx_urb[i])
618 return -ENOMEM;
619
620 usb_fill_bulk_urb(dln2->rx_urb[i], dln2->usb_dev,
621 usb_rcvbulkpipe(dln2->usb_dev, dln2->ep_in),
622 dln2->rx_buf[i], rx_max_size, dln2_rx, dln2);
623
624 ret = usb_submit_urb(dln2->rx_urb[i], GFP_KERNEL);
625 if (ret < 0) {
626 dev_err(dev, "failed to submit RX URB: %d\n", ret);
627 return ret;
628 }
629 }
630
631 return 0;
632}
633
634static struct dln2_platform_data dln2_pdata_gpio = {
635 .handle = DLN2_HANDLE_GPIO,
636};
637
638/* Only one I2C port seems to be supported on current hardware */
639static struct dln2_platform_data dln2_pdata_i2c = {
640 .handle = DLN2_HANDLE_I2C,
641 .port = 0,
642};
643
644/* Only one SPI port supported */
645static struct dln2_platform_data dln2_pdata_spi = {
646 .handle = DLN2_HANDLE_SPI,
647 .port = 0,
648};
649
650static const struct mfd_cell dln2_devs[] = {
651 {
652 .name = "dln2-gpio",
653 .platform_data = &dln2_pdata_gpio,
654 .pdata_size = sizeof(struct dln2_platform_data),
655 },
656 {
657 .name = "dln2-i2c",
658 .platform_data = &dln2_pdata_i2c,
659 .pdata_size = sizeof(struct dln2_platform_data),
660 },
661 {
662 .name = "dln2-spi",
663 .platform_data = &dln2_pdata_spi,
664 .pdata_size = sizeof(struct dln2_platform_data),
665 },
666};
667
668static void dln2_disconnect(struct usb_interface *interface)
669{
670 struct dln2_dev *dln2 = usb_get_intfdata(interface);
671 int i, j;
672
673 /* don't allow starting new transfers */
674 spin_lock(&dln2->disconnect_lock);
675 dln2->disconnect = true;
676 spin_unlock(&dln2->disconnect_lock);
677
678 /* cancel in progress transfers */
679 for (i = 0; i < DLN2_HANDLES; i++) {
680 struct dln2_mod_rx_slots *rxs = &dln2->mod_rx_slots[i];
681 unsigned long flags;
682
683 spin_lock_irqsave(&rxs->lock, flags);
684
685 /* cancel all response waiters */
686 for (j = 0; j < DLN2_MAX_RX_SLOTS; j++) {
687 struct dln2_rx_context *rxc = &rxs->slots[j];
688
689 if (rxc->in_use)
690 complete(&rxc->done);
691 }
692
693 spin_unlock_irqrestore(&rxs->lock, flags);
694 }
695
696 /* wait for transfers to end */
697 wait_event(dln2->disconnect_wq, !dln2->active_transfers);
698
699 mfd_remove_devices(&interface->dev);
700
701 dln2_free(dln2);
702}
703
704static int dln2_probe(struct usb_interface *interface,
705 const struct usb_device_id *usb_id)
706{
707 struct usb_host_interface *hostif = interface->cur_altsetting;
708 struct device *dev = &interface->dev;
709 struct dln2_dev *dln2;
710 int ret;
711 int i, j;
712
713 if (hostif->desc.bInterfaceNumber != 0 ||
714 hostif->desc.bNumEndpoints < 2)
715 return -ENODEV;
716
717 dln2 = kzalloc(sizeof(*dln2), GFP_KERNEL);
718 if (!dln2)
719 return -ENOMEM;
720
721 dln2->ep_out = hostif->endpoint[0].desc.bEndpointAddress;
722 dln2->ep_in = hostif->endpoint[1].desc.bEndpointAddress;
723 dln2->usb_dev = usb_get_dev(interface_to_usbdev(interface));
724 dln2->interface = interface;
725 usb_set_intfdata(interface, dln2);
726 init_waitqueue_head(&dln2->disconnect_wq);
727
728 for (i = 0; i < DLN2_HANDLES; i++) {
729 init_waitqueue_head(&dln2->mod_rx_slots[i].wq);
730 spin_lock_init(&dln2->mod_rx_slots[i].lock);
731 for (j = 0; j < DLN2_MAX_RX_SLOTS; j++)
732 init_completion(&dln2->mod_rx_slots[i].slots[j].done);
733 }
734
735 spin_lock_init(&dln2->event_cb_lock);
736 spin_lock_init(&dln2->disconnect_lock);
737 INIT_LIST_HEAD(&dln2->event_cb_list);
738
739 ret = dln2_setup_rx_urbs(dln2, hostif);
740 if (ret)
741 goto out_cleanup;
742
743 ret = dln2_hw_init(dln2);
744 if (ret < 0) {
745 dev_err(dev, "failed to initialize hardware\n");
746 goto out_cleanup;
747 }
748
749 ret = mfd_add_hotplug_devices(dev, dln2_devs, ARRAY_SIZE(dln2_devs));
750 if (ret != 0) {
751 dev_err(dev, "failed to add mfd devices to core\n");
752 goto out_cleanup;
753 }
754
755 return 0;
756
757out_cleanup:
758 dln2_free(dln2);
759
760 return ret;
761}
762
763static const struct usb_device_id dln2_table[] = {
764 { USB_DEVICE(0xa257, 0x2013) },
765 { }
766};
767
768MODULE_DEVICE_TABLE(usb, dln2_table);
769
770static struct usb_driver dln2_driver = {
771 .name = "dln2",
772 .probe = dln2_probe,
773 .disconnect = dln2_disconnect,
774 .id_table = dln2_table,
775};
776
777module_usb_driver(dln2_driver);
778
779MODULE_AUTHOR("Octavian Purdila <octavian.purdila@intel.com>");
780MODULE_DESCRIPTION("Core driver for the Diolan DLN2 interface adapter");
781MODULE_LICENSE("GPL v2");
diff --git a/drivers/mfd/lpc_sch.c b/drivers/mfd/lpc_sch.c
index c980da479a35..5c38df35a84d 100644
--- a/drivers/mfd/lpc_sch.c
+++ b/drivers/mfd/lpc_sch.c
@@ -193,11 +193,7 @@ static int lpc_sch_probe(struct pci_dev *dev, const struct pci_device_id *id)
193 return -ENODEV; 193 return -ENODEV;
194 } 194 }
195 195
196 ret = mfd_add_devices(&dev->dev, 0, lpc_sch_cells, cells, NULL, 0, NULL); 196 return mfd_add_devices(&dev->dev, 0, lpc_sch_cells, cells, NULL, 0, NULL);
197 if (ret)
198 mfd_remove_devices(&dev->dev);
199
200 return ret;
201} 197}
202 198
203static void lpc_sch_remove(struct pci_dev *dev) 199static void lpc_sch_remove(struct pci_dev *dev)
diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
index de96b7fb1f6d..3bf8def82f1e 100644
--- a/drivers/mfd/max14577.c
+++ b/drivers/mfd/max14577.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * max14577.c - mfd core driver for the Maxim 14577/77836 2 * max14577.c - mfd core driver for the Maxim 14577/77836
3 * 3 *
4 * Copyright (C) 2014 Samsung Electrnoics 4 * Copyright (C) 2014 Samsung Electronics
5 * Chanwoo Choi <cw00.choi@samsung.com> 5 * Chanwoo Choi <cw00.choi@samsung.com>
6 * Krzysztof Kozlowski <k.kozlowski@samsung.com> 6 * Krzysztof Kozlowski <k.kozlowski@samsung.com>
7 * 7 *
diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c
index 711773e8e64b..a159593e27a0 100644
--- a/drivers/mfd/max77693.c
+++ b/drivers/mfd/max77693.c
@@ -43,9 +43,15 @@
43 43
44static const struct mfd_cell max77693_devs[] = { 44static const struct mfd_cell max77693_devs[] = {
45 { .name = "max77693-pmic", }, 45 { .name = "max77693-pmic", },
46 { .name = "max77693-charger", }, 46 {
47 .name = "max77693-charger",
48 .of_compatible = "maxim,max77693-charger",
49 },
47 { .name = "max77693-muic", }, 50 { .name = "max77693-muic", },
48 { .name = "max77693-haptic", }, 51 {
52 .name = "max77693-haptic",
53 .of_compatible = "maxim,max77693-haptic",
54 },
49 { 55 {
50 .name = "max77693-flash", 56 .name = "max77693-flash",
51 .of_compatible = "maxim,max77693-flash", 57 .of_compatible = "maxim,max77693-flash",
@@ -147,6 +153,12 @@ static const struct regmap_irq_chip max77693_muic_irq_chip = {
147 .num_irqs = ARRAY_SIZE(max77693_muic_irqs), 153 .num_irqs = ARRAY_SIZE(max77693_muic_irqs),
148}; 154};
149 155
156static const struct regmap_config max77693_regmap_haptic_config = {
157 .reg_bits = 8,
158 .val_bits = 8,
159 .max_register = MAX77693_HAPTIC_REG_END,
160};
161
150static int max77693_i2c_probe(struct i2c_client *i2c, 162static int max77693_i2c_probe(struct i2c_client *i2c,
151 const struct i2c_device_id *id) 163 const struct i2c_device_id *id)
152{ 164{
@@ -196,6 +208,15 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
196 } 208 }
197 i2c_set_clientdata(max77693->haptic, max77693); 209 i2c_set_clientdata(max77693->haptic, max77693);
198 210
211 max77693->regmap_haptic = devm_regmap_init_i2c(max77693->haptic,
212 &max77693_regmap_haptic_config);
213 if (IS_ERR(max77693->regmap_haptic)) {
214 ret = PTR_ERR(max77693->regmap_haptic);
215 dev_err(max77693->dev,
216 "failed to initialize haptic register map: %d\n", ret);
217 goto err_regmap;
218 }
219
199 /* 220 /*
200 * Initialize register map for MUIC device because use regmap-muic 221 * Initialize register map for MUIC device because use regmap-muic
201 * instance of MUIC device when irq of max77693 is initialized 222 * instance of MUIC device when irq of max77693 is initialized
@@ -207,7 +228,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
207 ret = PTR_ERR(max77693->regmap_muic); 228 ret = PTR_ERR(max77693->regmap_muic);
208 dev_err(max77693->dev, 229 dev_err(max77693->dev,
209 "failed to allocate register map: %d\n", ret); 230 "failed to allocate register map: %d\n", ret);
210 goto err_regmap_muic; 231 goto err_regmap;
211 } 232 }
212 233
213 ret = regmap_add_irq_chip(max77693->regmap, max77693->irq, 234 ret = regmap_add_irq_chip(max77693->regmap, max77693->irq,
@@ -217,7 +238,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
217 &max77693->irq_data_led); 238 &max77693->irq_data_led);
218 if (ret) { 239 if (ret) {
219 dev_err(max77693->dev, "failed to add irq chip: %d\n", ret); 240 dev_err(max77693->dev, "failed to add irq chip: %d\n", ret);
220 goto err_regmap_muic; 241 goto err_regmap;
221 } 242 }
222 243
223 ret = regmap_add_irq_chip(max77693->regmap, max77693->irq, 244 ret = regmap_add_irq_chip(max77693->regmap, max77693->irq,
@@ -280,7 +301,7 @@ err_irq_charger:
280 regmap_del_irq_chip(max77693->irq, max77693->irq_data_topsys); 301 regmap_del_irq_chip(max77693->irq, max77693->irq_data_topsys);
281err_irq_topsys: 302err_irq_topsys:
282 regmap_del_irq_chip(max77693->irq, max77693->irq_data_led); 303 regmap_del_irq_chip(max77693->irq, max77693->irq_data_led);
283err_regmap_muic: 304err_regmap:
284 i2c_unregister_device(max77693->haptic); 305 i2c_unregister_device(max77693->haptic);
285err_i2c_haptic: 306err_i2c_haptic:
286 i2c_unregister_device(max77693->muic); 307 i2c_unregister_device(max77693->muic);
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index f3338fe9d069..2a87f69be53d 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -125,9 +125,15 @@ static int mfd_add_device(struct device *parent, int id,
125 struct platform_device *pdev; 125 struct platform_device *pdev;
126 struct device_node *np = NULL; 126 struct device_node *np = NULL;
127 int ret = -ENOMEM; 127 int ret = -ENOMEM;
128 int platform_id;
128 int r; 129 int r;
129 130
130 pdev = platform_device_alloc(cell->name, id + cell->id); 131 if (id < 0)
132 platform_id = id;
133 else
134 platform_id = id + cell->id;
135
136 pdev = platform_device_alloc(cell->name, platform_id);
131 if (!pdev) 137 if (!pdev)
132 goto fail_alloc; 138 goto fail_alloc;
133 139
diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
index 9c8eec80ceed..32407404d838 100644
--- a/drivers/mfd/rts5227.c
+++ b/drivers/mfd/rts5227.c
@@ -130,6 +130,12 @@ static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)
130 130
131static int rts5227_optimize_phy(struct rtsx_pcr *pcr) 131static int rts5227_optimize_phy(struct rtsx_pcr *pcr)
132{ 132{
133 int err;
134
135 err = rtsx_gops_pm_reset(pcr);
136 if (err < 0)
137 return err;
138
133 /* Optimize RX sensitivity */ 139 /* Optimize RX sensitivity */
134 return rtsx_pci_write_phy_register(pcr, 0x00, 0xBA42); 140 return rtsx_pci_write_phy_register(pcr, 0x00, 0xBA42);
135} 141}
diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index 573de7bfcced..cf425cc959d5 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -130,6 +130,10 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
130{ 130{
131 int err; 131 int err;
132 132
133 err = rtsx_gops_pm_reset(pcr);
134 if (err < 0)
135 return err;
136
133 err = rtsx_pci_write_phy_register(pcr, PHY_REG_REV, 137 err = rtsx_pci_write_phy_register(pcr, PHY_REG_REV,
134 PHY_REG_REV_RESV | PHY_REG_REV_RXIDLE_LATCHED | 138 PHY_REG_REV_RESV | PHY_REG_REV_RXIDLE_LATCHED |
135 PHY_REG_REV_P1_EN | PHY_REG_REV_RXIDLE_EN | 139 PHY_REG_REV_P1_EN | PHY_REG_REV_RXIDLE_EN |
diff --git a/drivers/mfd/rtsx_gops.c b/drivers/mfd/rtsx_gops.c
new file mode 100644
index 000000000000..b1a98c678593
--- /dev/null
+++ b/drivers/mfd/rtsx_gops.c
@@ -0,0 +1,37 @@
1/* Driver for Realtek PCI-Express card reader
2 *
3 * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2, or (at your option) any
8 * later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, see <http://www.gnu.org/licenses/>.
17 *
18 * Author:
19 * Micky Ching <micky_ching@realsil.com.cn>
20 */
21
22#include <linux/mfd/rtsx_pci.h>
23#include "rtsx_pcr.h"
24
25int rtsx_gops_pm_reset(struct rtsx_pcr *pcr)
26{
27 int err;
28
29 /* init aspm */
30 rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, 0xFF, 0x00);
31 err = rtsx_pci_update_cfg_byte(pcr, LCTLR, ~LCTLR_ASPM_CTL_MASK, 0x00);
32 if (err < 0)
33 return err;
34
35 /* reset PM_CTRL3 before send buffer cmd */
36 return rtsx_pci_write_register(pcr, PM_CTRL3, D3_DELINK_MODE_EN, 0x00);
37}
diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h
index 07e4c2ebf05a..fe2bbb67defc 100644
--- a/drivers/mfd/rtsx_pcr.h
+++ b/drivers/mfd/rtsx_pcr.h
@@ -72,4 +72,7 @@ do { \
72 pcr->ms_pull_ctl_disable_tbl = __device##_ms_pull_ctl_disable_tbl; \ 72 pcr->ms_pull_ctl_disable_tbl = __device##_ms_pull_ctl_disable_tbl; \
73} while (0) 73} while (0)
74 74
75/* generic operations */
76int rtsx_gops_pm_reset(struct rtsx_pcr *pcr);
77
75#endif 78#endif
diff --git a/drivers/mfd/rtsx_usb.c b/drivers/mfd/rtsx_usb.c
index 9cf98d142d9a..dbdd0faeb6ce 100644
--- a/drivers/mfd/rtsx_usb.c
+++ b/drivers/mfd/rtsx_usb.c
@@ -647,8 +647,8 @@ static int rtsx_usb_probe(struct usb_interface *intf,
647 /* initialize USB SG transfer timer */ 647 /* initialize USB SG transfer timer */
648 setup_timer(&ucr->sg_timer, rtsx_usb_sg_timed_out, (unsigned long) ucr); 648 setup_timer(&ucr->sg_timer, rtsx_usb_sg_timed_out, (unsigned long) ucr);
649 649
650 ret = mfd_add_devices(&intf->dev, usb_dev->devnum, rtsx_usb_cells, 650 ret = mfd_add_hotplug_devices(&intf->dev, rtsx_usb_cells,
651 ARRAY_SIZE(rtsx_usb_cells), NULL, 0, NULL); 651 ARRAY_SIZE(rtsx_usb_cells));
652 if (ret) 652 if (ret)
653 goto out_init_fail; 653 goto out_init_fail;
654 654
diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
index dba7e2b6f8e9..0a7bc43db4e4 100644
--- a/drivers/mfd/sec-core.c
+++ b/drivers/mfd/sec-core.c
@@ -27,11 +27,11 @@
27#include <linux/mfd/samsung/irq.h> 27#include <linux/mfd/samsung/irq.h>
28#include <linux/mfd/samsung/s2mpa01.h> 28#include <linux/mfd/samsung/s2mpa01.h>
29#include <linux/mfd/samsung/s2mps11.h> 29#include <linux/mfd/samsung/s2mps11.h>
30#include <linux/mfd/samsung/s2mps13.h>
30#include <linux/mfd/samsung/s2mps14.h> 31#include <linux/mfd/samsung/s2mps14.h>
31#include <linux/mfd/samsung/s2mpu02.h> 32#include <linux/mfd/samsung/s2mpu02.h>
32#include <linux/mfd/samsung/s5m8763.h> 33#include <linux/mfd/samsung/s5m8763.h>
33#include <linux/mfd/samsung/s5m8767.h> 34#include <linux/mfd/samsung/s5m8767.h>
34#include <linux/regulator/machine.h>
35#include <linux/regmap.h> 35#include <linux/regmap.h>
36 36
37static const struct mfd_cell s5m8751_devs[] = { 37static const struct mfd_cell s5m8751_devs[] = {
@@ -74,6 +74,15 @@ static const struct mfd_cell s2mps11_devs[] = {
74 } 74 }
75}; 75};
76 76
77static const struct mfd_cell s2mps13_devs[] = {
78 { .name = "s2mps13-pmic", },
79 { .name = "s2mps13-rtc", },
80 {
81 .name = "s2mps13-clk",
82 .of_compatible = "samsung,s2mps13-clk",
83 },
84};
85
77static const struct mfd_cell s2mps14_devs[] = { 86static const struct mfd_cell s2mps14_devs[] = {
78 { 87 {
79 .name = "s2mps14-pmic", 88 .name = "s2mps14-pmic",
@@ -108,6 +117,9 @@ static const struct of_device_id sec_dt_match[] = {
108 .compatible = "samsung,s2mps11-pmic", 117 .compatible = "samsung,s2mps11-pmic",
109 .data = (void *)S2MPS11X, 118 .data = (void *)S2MPS11X,
110 }, { 119 }, {
120 .compatible = "samsung,s2mps13-pmic",
121 .data = (void *)S2MPS13X,
122 }, {
111 .compatible = "samsung,s2mps14-pmic", 123 .compatible = "samsung,s2mps14-pmic",
112 .data = (void *)S2MPS14X, 124 .data = (void *)S2MPS14X,
113 }, { 125 }, {
@@ -194,6 +206,15 @@ static const struct regmap_config s2mps11_regmap_config = {
194 .cache_type = REGCACHE_FLAT, 206 .cache_type = REGCACHE_FLAT,
195}; 207};
196 208
209static const struct regmap_config s2mps13_regmap_config = {
210 .reg_bits = 8,
211 .val_bits = 8,
212
213 .max_register = S2MPS13_REG_LDODSCH5,
214 .volatile_reg = s2mps11_volatile,
215 .cache_type = REGCACHE_FLAT,
216};
217
197static const struct regmap_config s2mps14_regmap_config = { 218static const struct regmap_config s2mps14_regmap_config = {
198 .reg_bits = 8, 219 .reg_bits = 8,
199 .val_bits = 8, 220 .val_bits = 8,
@@ -325,6 +346,9 @@ static int sec_pmic_probe(struct i2c_client *i2c,
325 case S2MPS11X: 346 case S2MPS11X:
326 regmap = &s2mps11_regmap_config; 347 regmap = &s2mps11_regmap_config;
327 break; 348 break;
349 case S2MPS13X:
350 regmap = &s2mps13_regmap_config;
351 break;
328 case S2MPS14X: 352 case S2MPS14X:
329 regmap = &s2mps14_regmap_config; 353 regmap = &s2mps14_regmap_config;
330 break; 354 break;
@@ -378,6 +402,10 @@ static int sec_pmic_probe(struct i2c_client *i2c,
378 sec_devs = s2mps11_devs; 402 sec_devs = s2mps11_devs;
379 num_sec_devs = ARRAY_SIZE(s2mps11_devs); 403 num_sec_devs = ARRAY_SIZE(s2mps11_devs);
380 break; 404 break;
405 case S2MPS13X:
406 sec_devs = s2mps13_devs;
407 num_sec_devs = ARRAY_SIZE(s2mps13_devs);
408 break;
381 case S2MPS14X: 409 case S2MPS14X:
382 sec_devs = s2mps14_devs; 410 sec_devs = s2mps14_devs;
383 num_sec_devs = ARRAY_SIZE(s2mps14_devs); 411 num_sec_devs = ARRAY_SIZE(s2mps14_devs);
@@ -432,15 +460,6 @@ static int sec_pmic_suspend(struct device *dev)
432 */ 460 */
433 disable_irq(sec_pmic->irq); 461 disable_irq(sec_pmic->irq);
434 462
435 switch (sec_pmic->device_type) {
436 case S2MPS14X:
437 case S2MPU02:
438 regulator_suspend_prepare(PM_SUSPEND_MEM);
439 break;
440 default:
441 break;
442 }
443
444 return 0; 463 return 0;
445} 464}
446 465
diff --git a/drivers/mfd/sec-irq.c b/drivers/mfd/sec-irq.c
index f9a57869e3ec..ba86a918c2da 100644
--- a/drivers/mfd/sec-irq.c
+++ b/drivers/mfd/sec-irq.c
@@ -389,14 +389,22 @@ static const struct regmap_irq_chip s2mps11_irq_chip = {
389 .ack_base = S2MPS11_REG_INT1, 389 .ack_base = S2MPS11_REG_INT1,
390}; 390};
391 391
392#define S2MPS1X_IRQ_CHIP_COMMON_DATA \
393 .irqs = s2mps14_irqs, \
394 .num_irqs = ARRAY_SIZE(s2mps14_irqs), \
395 .num_regs = 3, \
396 .status_base = S2MPS14_REG_INT1, \
397 .mask_base = S2MPS14_REG_INT1M, \
398 .ack_base = S2MPS14_REG_INT1 \
399
400static const struct regmap_irq_chip s2mps13_irq_chip = {
401 .name = "s2mps13",
402 S2MPS1X_IRQ_CHIP_COMMON_DATA,
403};
404
392static const struct regmap_irq_chip s2mps14_irq_chip = { 405static const struct regmap_irq_chip s2mps14_irq_chip = {
393 .name = "s2mps14", 406 .name = "s2mps14",
394 .irqs = s2mps14_irqs, 407 S2MPS1X_IRQ_CHIP_COMMON_DATA,
395 .num_irqs = ARRAY_SIZE(s2mps14_irqs),
396 .num_regs = 3,
397 .status_base = S2MPS14_REG_INT1,
398 .mask_base = S2MPS14_REG_INT1M,
399 .ack_base = S2MPS14_REG_INT1,
400}; 408};
401 409
402static const struct regmap_irq_chip s2mpu02_irq_chip = { 410static const struct regmap_irq_chip s2mpu02_irq_chip = {
@@ -452,6 +460,9 @@ int sec_irq_init(struct sec_pmic_dev *sec_pmic)
452 case S2MPS11X: 460 case S2MPS11X:
453 sec_irq_chip = &s2mps11_irq_chip; 461 sec_irq_chip = &s2mps11_irq_chip;
454 break; 462 break;
463 case S2MPS13X:
464 sec_irq_chip = &s2mps13_irq_chip;
465 break;
455 case S2MPS14X: 466 case S2MPS14X:
456 sec_irq_chip = &s2mps14_irq_chip; 467 sec_irq_chip = &s2mps14_irq_chip;
457 break; 468 break;
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index ca15878ce5c0..72373b113885 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -15,6 +15,7 @@
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/list.h>
18#include <linux/of.h> 19#include <linux/of.h>
19#include <linux/of_address.h> 20#include <linux/of_address.h>
20#include <linux/of_platform.h> 21#include <linux/of_platform.h>
@@ -22,31 +23,94 @@
22#include <linux/platform_device.h> 23#include <linux/platform_device.h>
23#include <linux/regmap.h> 24#include <linux/regmap.h>
24#include <linux/mfd/syscon.h> 25#include <linux/mfd/syscon.h>
26#include <linux/slab.h>
25 27
26static struct platform_driver syscon_driver; 28static struct platform_driver syscon_driver;
27 29
30static DEFINE_SPINLOCK(syscon_list_slock);
31static LIST_HEAD(syscon_list);
32
28struct syscon { 33struct syscon {
34 struct device_node *np;
29 struct regmap *regmap; 35 struct regmap *regmap;
36 struct list_head list;
37};
38
39static struct regmap_config syscon_regmap_config = {
40 .reg_bits = 32,
41 .val_bits = 32,
42 .reg_stride = 4,
30}; 43};
31 44
32static int syscon_match_node(struct device *dev, void *data) 45static struct syscon *of_syscon_register(struct device_node *np)
33{ 46{
34 struct device_node *dn = data; 47 struct syscon *syscon;
48 struct regmap *regmap;
49 void __iomem *base;
50 int ret;
51 struct regmap_config syscon_config = syscon_regmap_config;
52
53 if (!of_device_is_compatible(np, "syscon"))
54 return ERR_PTR(-EINVAL);
55
56 syscon = kzalloc(sizeof(*syscon), GFP_KERNEL);
57 if (!syscon)
58 return ERR_PTR(-ENOMEM);
59
60 base = of_iomap(np, 0);
61 if (!base) {
62 ret = -ENOMEM;
63 goto err_map;
64 }
65
66 /* Parse the device's DT node for an endianness specification */
67 if (of_property_read_bool(np, "big-endian"))
68 syscon_config.val_format_endian = REGMAP_ENDIAN_BIG;
69 else if (of_property_read_bool(np, "little-endian"))
70 syscon_config.val_format_endian = REGMAP_ENDIAN_LITTLE;
71
72 regmap = regmap_init_mmio(NULL, base, &syscon_config);
73 if (IS_ERR(regmap)) {
74 pr_err("regmap init failed\n");
75 ret = PTR_ERR(regmap);
76 goto err_regmap;
77 }
78
79 syscon->regmap = regmap;
80 syscon->np = np;
81
82 spin_lock(&syscon_list_slock);
83 list_add_tail(&syscon->list, &syscon_list);
84 spin_unlock(&syscon_list_slock);
35 85
36 return (dev->of_node == dn) ? 1 : 0; 86 return syscon;
87
88err_regmap:
89 iounmap(base);
90err_map:
91 kfree(syscon);
92 return ERR_PTR(ret);
37} 93}
38 94
39struct regmap *syscon_node_to_regmap(struct device_node *np) 95struct regmap *syscon_node_to_regmap(struct device_node *np)
40{ 96{
41 struct syscon *syscon; 97 struct syscon *entry, *syscon = NULL;
42 struct device *dev;
43 98
44 dev = driver_find_device(&syscon_driver.driver, NULL, np, 99 spin_lock(&syscon_list_slock);
45 syscon_match_node);
46 if (!dev)
47 return ERR_PTR(-EPROBE_DEFER);
48 100
49 syscon = dev_get_drvdata(dev); 101 list_for_each_entry(entry, &syscon_list, list)
102 if (entry->np == np) {
103 syscon = entry;
104 break;
105 }
106
107 spin_unlock(&syscon_list_slock);
108
109 if (!syscon)
110 syscon = of_syscon_register(np);
111
112 if (IS_ERR(syscon))
113 return ERR_CAST(syscon);
50 114
51 return syscon->regmap; 115 return syscon->regmap;
52} 116}
@@ -110,17 +174,6 @@ struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np,
110} 174}
111EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_phandle); 175EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_phandle);
112 176
113static const struct of_device_id of_syscon_match[] = {
114 { .compatible = "syscon", },
115 { },
116};
117
118static struct regmap_config syscon_regmap_config = {
119 .reg_bits = 32,
120 .val_bits = 32,
121 .reg_stride = 4,
122};
123
124static int syscon_probe(struct platform_device *pdev) 177static int syscon_probe(struct platform_device *pdev)
125{ 178{
126 struct device *dev = &pdev->dev; 179 struct device *dev = &pdev->dev;
@@ -167,7 +220,6 @@ static struct platform_driver syscon_driver = {
167 .driver = { 220 .driver = {
168 .name = "syscon", 221 .name = "syscon",
169 .owner = THIS_MODULE, 222 .owner = THIS_MODULE,
170 .of_match_table = of_syscon_match,
171 }, 223 },
172 .probe = syscon_probe, 224 .probe = syscon_probe,
173 .id_table = syscon_ids, 225 .id_table = syscon_ids,
diff --git a/drivers/mfd/t7l66xb.c b/drivers/mfd/t7l66xb.c
index 9e04a7485981..439d905bb219 100644
--- a/drivers/mfd/t7l66xb.c
+++ b/drivers/mfd/t7l66xb.c
@@ -87,7 +87,7 @@ static int t7l66xb_mmc_enable(struct platform_device *mmc)
87 unsigned long flags; 87 unsigned long flags;
88 u8 dev_ctl; 88 u8 dev_ctl;
89 89
90 clk_enable(t7l66xb->clk32k); 90 clk_prepare_enable(t7l66xb->clk32k);
91 91
92 spin_lock_irqsave(&t7l66xb->lock, flags); 92 spin_lock_irqsave(&t7l66xb->lock, flags);
93 93
@@ -118,7 +118,7 @@ static int t7l66xb_mmc_disable(struct platform_device *mmc)
118 118
119 spin_unlock_irqrestore(&t7l66xb->lock, flags); 119 spin_unlock_irqrestore(&t7l66xb->lock, flags);
120 120
121 clk_disable(t7l66xb->clk32k); 121 clk_disable_unprepare(t7l66xb->clk32k);
122 122
123 return 0; 123 return 0;
124} 124}
@@ -285,7 +285,7 @@ static int t7l66xb_suspend(struct platform_device *dev, pm_message_t state)
285 285
286 if (pdata && pdata->suspend) 286 if (pdata && pdata->suspend)
287 pdata->suspend(dev); 287 pdata->suspend(dev);
288 clk_disable(t7l66xb->clk48m); 288 clk_disable_unprepare(t7l66xb->clk48m);
289 289
290 return 0; 290 return 0;
291} 291}
@@ -295,7 +295,7 @@ static int t7l66xb_resume(struct platform_device *dev)
295 struct t7l66xb *t7l66xb = platform_get_drvdata(dev); 295 struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
296 struct t7l66xb_platform_data *pdata = dev_get_platdata(&dev->dev); 296 struct t7l66xb_platform_data *pdata = dev_get_platdata(&dev->dev);
297 297
298 clk_enable(t7l66xb->clk48m); 298 clk_prepare_enable(t7l66xb->clk48m);
299 if (pdata && pdata->resume) 299 if (pdata && pdata->resume)
300 pdata->resume(dev); 300 pdata->resume(dev);
301 301
@@ -369,7 +369,7 @@ static int t7l66xb_probe(struct platform_device *dev)
369 goto err_ioremap; 369 goto err_ioremap;
370 } 370 }
371 371
372 clk_enable(t7l66xb->clk48m); 372 clk_prepare_enable(t7l66xb->clk48m);
373 373
374 if (pdata && pdata->enable) 374 if (pdata && pdata->enable)
375 pdata->enable(dev); 375 pdata->enable(dev);
@@ -414,9 +414,9 @@ static int t7l66xb_remove(struct platform_device *dev)
414 int ret; 414 int ret;
415 415
416 ret = pdata->disable(dev); 416 ret = pdata->disable(dev);
417 clk_disable(t7l66xb->clk48m); 417 clk_disable_unprepare(t7l66xb->clk48m);
418 clk_put(t7l66xb->clk48m); 418 clk_put(t7l66xb->clk48m);
419 clk_disable(t7l66xb->clk32k); 419 clk_disable_unprepare(t7l66xb->clk32k);
420 clk_put(t7l66xb->clk32k); 420 clk_put(t7l66xb->clk32k);
421 t7l66xb_detach_irq(dev); 421 t7l66xb_detach_irq(dev);
422 iounmap(t7l66xb->scr); 422 iounmap(t7l66xb->scr);
diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c
index 0072e668c208..aacb3720065c 100644
--- a/drivers/mfd/tc3589x.c
+++ b/drivers/mfd/tc3589x.c
@@ -241,10 +241,8 @@ static struct irq_domain_ops tc3589x_irq_ops = {
241 241
242static int tc3589x_irq_init(struct tc3589x *tc3589x, struct device_node *np) 242static int tc3589x_irq_init(struct tc3589x *tc3589x, struct device_node *np)
243{ 243{
244 int base = tc3589x->irq_base;
245
246 tc3589x->domain = irq_domain_add_simple( 244 tc3589x->domain = irq_domain_add_simple(
247 np, TC3589x_NR_INTERNAL_IRQS, base, 245 np, TC3589x_NR_INTERNAL_IRQS, 0,
248 &tc3589x_irq_ops, tc3589x); 246 &tc3589x_irq_ops, tc3589x);
249 247
250 if (!tc3589x->domain) { 248 if (!tc3589x->domain) {
@@ -298,7 +296,7 @@ static int tc3589x_device_init(struct tc3589x *tc3589x)
298 if (blocks & TC3589x_BLOCK_GPIO) { 296 if (blocks & TC3589x_BLOCK_GPIO) {
299 ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_gpio, 297 ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_gpio,
300 ARRAY_SIZE(tc3589x_dev_gpio), NULL, 298 ARRAY_SIZE(tc3589x_dev_gpio), NULL,
301 tc3589x->irq_base, tc3589x->domain); 299 0, tc3589x->domain);
302 if (ret) { 300 if (ret) {
303 dev_err(tc3589x->dev, "failed to add gpio child\n"); 301 dev_err(tc3589x->dev, "failed to add gpio child\n");
304 return ret; 302 return ret;
@@ -309,7 +307,7 @@ static int tc3589x_device_init(struct tc3589x *tc3589x)
309 if (blocks & TC3589x_BLOCK_KEYPAD) { 307 if (blocks & TC3589x_BLOCK_KEYPAD) {
310 ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_keypad, 308 ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_keypad,
311 ARRAY_SIZE(tc3589x_dev_keypad), NULL, 309 ARRAY_SIZE(tc3589x_dev_keypad), NULL,
312 tc3589x->irq_base, tc3589x->domain); 310 0, tc3589x->domain);
313 if (ret) { 311 if (ret) {
314 dev_err(tc3589x->dev, "failed to keypad child\n"); 312 dev_err(tc3589x->dev, "failed to keypad child\n");
315 return ret; 313 return ret;
@@ -404,7 +402,6 @@ static int tc3589x_probe(struct i2c_client *i2c,
404 tc3589x->dev = &i2c->dev; 402 tc3589x->dev = &i2c->dev;
405 tc3589x->i2c = i2c; 403 tc3589x->i2c = i2c;
406 tc3589x->pdata = pdata; 404 tc3589x->pdata = pdata;
407 tc3589x->irq_base = pdata->irq_base;
408 405
409 switch (version) { 406 switch (version) {
410 case TC3589X_TC35893: 407 case TC3589X_TC35893:
diff --git a/drivers/mfd/tc6387xb.c b/drivers/mfd/tc6387xb.c
index e71f88000ae5..85fab3729102 100644
--- a/drivers/mfd/tc6387xb.c
+++ b/drivers/mfd/tc6387xb.c
@@ -52,7 +52,7 @@ static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state)
52 52
53 if (pdata && pdata->suspend) 53 if (pdata && pdata->suspend)
54 pdata->suspend(dev); 54 pdata->suspend(dev);
55 clk_disable(tc6387xb->clk32k); 55 clk_disable_unprepare(tc6387xb->clk32k);
56 56
57 return 0; 57 return 0;
58} 58}
@@ -62,7 +62,7 @@ static int tc6387xb_resume(struct platform_device *dev)
62 struct tc6387xb *tc6387xb = platform_get_drvdata(dev); 62 struct tc6387xb *tc6387xb = platform_get_drvdata(dev);
63 struct tc6387xb_platform_data *pdata = dev_get_platdata(&dev->dev); 63 struct tc6387xb_platform_data *pdata = dev_get_platdata(&dev->dev);
64 64
65 clk_enable(tc6387xb->clk32k); 65 clk_prepare_enable(tc6387xb->clk32k);
66 if (pdata && pdata->resume) 66 if (pdata && pdata->resume)
67 pdata->resume(dev); 67 pdata->resume(dev);
68 68
@@ -100,7 +100,7 @@ static int tc6387xb_mmc_enable(struct platform_device *mmc)
100 struct platform_device *dev = to_platform_device(mmc->dev.parent); 100 struct platform_device *dev = to_platform_device(mmc->dev.parent);
101 struct tc6387xb *tc6387xb = platform_get_drvdata(dev); 101 struct tc6387xb *tc6387xb = platform_get_drvdata(dev);
102 102
103 clk_enable(tc6387xb->clk32k); 103 clk_prepare_enable(tc6387xb->clk32k);
104 104
105 tmio_core_mmc_enable(tc6387xb->scr + 0x200, 0, 105 tmio_core_mmc_enable(tc6387xb->scr + 0x200, 0,
106 tc6387xb_mmc_resources[0].start & 0xfffe); 106 tc6387xb_mmc_resources[0].start & 0xfffe);
@@ -113,7 +113,7 @@ static int tc6387xb_mmc_disable(struct platform_device *mmc)
113 struct platform_device *dev = to_platform_device(mmc->dev.parent); 113 struct platform_device *dev = to_platform_device(mmc->dev.parent);
114 struct tc6387xb *tc6387xb = platform_get_drvdata(dev); 114 struct tc6387xb *tc6387xb = platform_get_drvdata(dev);
115 115
116 clk_disable(tc6387xb->clk32k); 116 clk_disable_unprepare(tc6387xb->clk32k);
117 117
118 return 0; 118 return 0;
119} 119}
@@ -214,7 +214,7 @@ static int tc6387xb_remove(struct platform_device *dev)
214 mfd_remove_devices(&dev->dev); 214 mfd_remove_devices(&dev->dev);
215 iounmap(tc6387xb->scr); 215 iounmap(tc6387xb->scr);
216 release_resource(&tc6387xb->rscr); 216 release_resource(&tc6387xb->rscr);
217 clk_disable(tc6387xb->clk32k); 217 clk_disable_unprepare(tc6387xb->clk32k);
218 clk_put(tc6387xb->clk32k); 218 clk_put(tc6387xb->clk32k);
219 kfree(tc6387xb); 219 kfree(tc6387xb);
220 220
diff --git a/drivers/mfd/tc6393xb.c b/drivers/mfd/tc6393xb.c
index 4fac16bcd732..d35f11fbeab7 100644
--- a/drivers/mfd/tc6393xb.c
+++ b/drivers/mfd/tc6393xb.c
@@ -263,6 +263,17 @@ static int tc6393xb_ohci_disable(struct platform_device *dev)
263 return 0; 263 return 0;
264} 264}
265 265
266static int tc6393xb_ohci_suspend(struct platform_device *dev)
267{
268 struct tc6393xb_platform_data *tcpd = dev_get_platdata(dev->dev.parent);
269
270 /* We can't properly store/restore OHCI state, so fail here */
271 if (tcpd->resume_restore)
272 return -EBUSY;
273
274 return tc6393xb_ohci_disable(dev);
275}
276
266static int tc6393xb_fb_enable(struct platform_device *dev) 277static int tc6393xb_fb_enable(struct platform_device *dev)
267{ 278{
268 struct tc6393xb *tc6393xb = dev_get_drvdata(dev->dev.parent); 279 struct tc6393xb *tc6393xb = dev_get_drvdata(dev->dev.parent);
@@ -403,7 +414,7 @@ static struct mfd_cell tc6393xb_cells[] = {
403 .num_resources = ARRAY_SIZE(tc6393xb_ohci_resources), 414 .num_resources = ARRAY_SIZE(tc6393xb_ohci_resources),
404 .resources = tc6393xb_ohci_resources, 415 .resources = tc6393xb_ohci_resources,
405 .enable = tc6393xb_ohci_enable, 416 .enable = tc6393xb_ohci_enable,
406 .suspend = tc6393xb_ohci_disable, 417 .suspend = tc6393xb_ohci_suspend,
407 .resume = tc6393xb_ohci_enable, 418 .resume = tc6393xb_ohci_enable,
408 .disable = tc6393xb_ohci_disable, 419 .disable = tc6393xb_ohci_disable,
409 }, 420 },
@@ -654,7 +665,7 @@ static int tc6393xb_probe(struct platform_device *dev)
654 goto err_ioremap; 665 goto err_ioremap;
655 } 666 }
656 667
657 ret = clk_enable(tc6393xb->clk); 668 ret = clk_prepare_enable(tc6393xb->clk);
658 if (ret) 669 if (ret)
659 goto err_clk_enable; 670 goto err_clk_enable;
660 671
@@ -717,7 +728,7 @@ err_gpio_add:
717 gpiochip_remove(&tc6393xb->gpio); 728 gpiochip_remove(&tc6393xb->gpio);
718 tcpd->disable(dev); 729 tcpd->disable(dev);
719err_enable: 730err_enable:
720 clk_disable(tc6393xb->clk); 731 clk_disable_unprepare(tc6393xb->clk);
721err_clk_enable: 732err_clk_enable:
722 iounmap(tc6393xb->scr); 733 iounmap(tc6393xb->scr);
723err_ioremap: 734err_ioremap:
@@ -748,7 +759,7 @@ static int tc6393xb_remove(struct platform_device *dev)
748 gpiochip_remove(&tc6393xb->gpio); 759 gpiochip_remove(&tc6393xb->gpio);
749 760
750 ret = tcpd->disable(dev); 761 ret = tcpd->disable(dev);
751 clk_disable(tc6393xb->clk); 762 clk_disable_unprepare(tc6393xb->clk);
752 iounmap(tc6393xb->scr); 763 iounmap(tc6393xb->scr);
753 release_resource(&tc6393xb->rscr); 764 release_resource(&tc6393xb->rscr);
754 clk_put(tc6393xb->clk); 765 clk_put(tc6393xb->clk);
@@ -776,7 +787,7 @@ static int tc6393xb_suspend(struct platform_device *dev, pm_message_t state)
776 ioread8(tc6393xb->scr + SCR_GPI_BCR(i)); 787 ioread8(tc6393xb->scr + SCR_GPI_BCR(i));
777 } 788 }
778 ret = tcpd->suspend(dev); 789 ret = tcpd->suspend(dev);
779 clk_disable(tc6393xb->clk); 790 clk_disable_unprepare(tc6393xb->clk);
780 791
781 return ret; 792 return ret;
782} 793}
@@ -788,7 +799,7 @@ static int tc6393xb_resume(struct platform_device *dev)
788 int ret; 799 int ret;
789 int i; 800 int i;
790 801
791 clk_enable(tc6393xb->clk); 802 clk_prepare_enable(tc6393xb->clk);
792 803
793 ret = tcpd->resume(dev); 804 ret = tcpd->resume(dev);
794 if (ret) 805 if (ret)
diff --git a/drivers/mfd/tps65090.c b/drivers/mfd/tps65090.c
index 1c3e6e2efe41..14b62e11aff4 100644
--- a/drivers/mfd/tps65090.c
+++ b/drivers/mfd/tps65090.c
@@ -76,58 +76,58 @@ static struct mfd_cell tps65090s[] = {
76static const struct regmap_irq tps65090_irqs[] = { 76static const struct regmap_irq tps65090_irqs[] = {
77 /* INT1 IRQs*/ 77 /* INT1 IRQs*/
78 [TPS65090_IRQ_VAC_STATUS_CHANGE] = { 78 [TPS65090_IRQ_VAC_STATUS_CHANGE] = {
79 .mask = TPS65090_INT1_MASK_VAC_STATUS_CHANGE, 79 .mask = TPS65090_INT1_MASK_VAC_STATUS_CHANGE,
80 }, 80 },
81 [TPS65090_IRQ_VSYS_STATUS_CHANGE] = { 81 [TPS65090_IRQ_VSYS_STATUS_CHANGE] = {
82 .mask = TPS65090_INT1_MASK_VSYS_STATUS_CHANGE, 82 .mask = TPS65090_INT1_MASK_VSYS_STATUS_CHANGE,
83 }, 83 },
84 [TPS65090_IRQ_BAT_STATUS_CHANGE] = { 84 [TPS65090_IRQ_BAT_STATUS_CHANGE] = {
85 .mask = TPS65090_INT1_MASK_BAT_STATUS_CHANGE, 85 .mask = TPS65090_INT1_MASK_BAT_STATUS_CHANGE,
86 }, 86 },
87 [TPS65090_IRQ_CHARGING_STATUS_CHANGE] = { 87 [TPS65090_IRQ_CHARGING_STATUS_CHANGE] = {
88 .mask = TPS65090_INT1_MASK_CHARGING_STATUS_CHANGE, 88 .mask = TPS65090_INT1_MASK_CHARGING_STATUS_CHANGE,
89 }, 89 },
90 [TPS65090_IRQ_CHARGING_COMPLETE] = { 90 [TPS65090_IRQ_CHARGING_COMPLETE] = {
91 .mask = TPS65090_INT1_MASK_CHARGING_COMPLETE, 91 .mask = TPS65090_INT1_MASK_CHARGING_COMPLETE,
92 }, 92 },
93 [TPS65090_IRQ_OVERLOAD_DCDC1] = { 93 [TPS65090_IRQ_OVERLOAD_DCDC1] = {
94 .mask = TPS65090_INT1_MASK_OVERLOAD_DCDC1, 94 .mask = TPS65090_INT1_MASK_OVERLOAD_DCDC1,
95 }, 95 },
96 [TPS65090_IRQ_OVERLOAD_DCDC2] = { 96 [TPS65090_IRQ_OVERLOAD_DCDC2] = {
97 .mask = TPS65090_INT1_MASK_OVERLOAD_DCDC2, 97 .mask = TPS65090_INT1_MASK_OVERLOAD_DCDC2,
98 }, 98 },
99 /* INT2 IRQs*/ 99 /* INT2 IRQs*/
100 [TPS65090_IRQ_OVERLOAD_DCDC3] = { 100 [TPS65090_IRQ_OVERLOAD_DCDC3] = {
101 .reg_offset = 1, 101 .reg_offset = 1,
102 .mask = TPS65090_INT2_MASK_OVERLOAD_DCDC3, 102 .mask = TPS65090_INT2_MASK_OVERLOAD_DCDC3,
103 }, 103 },
104 [TPS65090_IRQ_OVERLOAD_FET1] = { 104 [TPS65090_IRQ_OVERLOAD_FET1] = {
105 .reg_offset = 1, 105 .reg_offset = 1,
106 .mask = TPS65090_INT2_MASK_OVERLOAD_FET1, 106 .mask = TPS65090_INT2_MASK_OVERLOAD_FET1,
107 }, 107 },
108 [TPS65090_IRQ_OVERLOAD_FET2] = { 108 [TPS65090_IRQ_OVERLOAD_FET2] = {
109 .reg_offset = 1, 109 .reg_offset = 1,
110 .mask = TPS65090_INT2_MASK_OVERLOAD_FET2, 110 .mask = TPS65090_INT2_MASK_OVERLOAD_FET2,
111 }, 111 },
112 [TPS65090_IRQ_OVERLOAD_FET3] = { 112 [TPS65090_IRQ_OVERLOAD_FET3] = {
113 .reg_offset = 1, 113 .reg_offset = 1,
114 .mask = TPS65090_INT2_MASK_OVERLOAD_FET3, 114 .mask = TPS65090_INT2_MASK_OVERLOAD_FET3,
115 }, 115 },
116 [TPS65090_IRQ_OVERLOAD_FET4] = { 116 [TPS65090_IRQ_OVERLOAD_FET4] = {
117 .reg_offset = 1, 117 .reg_offset = 1,
118 .mask = TPS65090_INT2_MASK_OVERLOAD_FET4, 118 .mask = TPS65090_INT2_MASK_OVERLOAD_FET4,
119 }, 119 },
120 [TPS65090_IRQ_OVERLOAD_FET5] = { 120 [TPS65090_IRQ_OVERLOAD_FET5] = {
121 .reg_offset = 1, 121 .reg_offset = 1,
122 .mask = TPS65090_INT2_MASK_OVERLOAD_FET5, 122 .mask = TPS65090_INT2_MASK_OVERLOAD_FET5,
123 }, 123 },
124 [TPS65090_IRQ_OVERLOAD_FET6] = { 124 [TPS65090_IRQ_OVERLOAD_FET6] = {
125 .reg_offset = 1, 125 .reg_offset = 1,
126 .mask = TPS65090_INT2_MASK_OVERLOAD_FET6, 126 .mask = TPS65090_INT2_MASK_OVERLOAD_FET6,
127 }, 127 },
128 [TPS65090_IRQ_OVERLOAD_FET7] = { 128 [TPS65090_IRQ_OVERLOAD_FET7] = {
129 .reg_offset = 1, 129 .reg_offset = 1,
130 .mask = TPS65090_INT2_MASK_OVERLOAD_FET7, 130 .mask = TPS65090_INT2_MASK_OVERLOAD_FET7,
131 }, 131 },
132}; 132};
133 133
@@ -176,7 +176,7 @@ MODULE_DEVICE_TABLE(of, tps65090_of_match);
176#endif 176#endif
177 177
178static int tps65090_i2c_probe(struct i2c_client *client, 178static int tps65090_i2c_probe(struct i2c_client *client,
179 const struct i2c_device_id *id) 179 const struct i2c_device_id *id)
180{ 180{
181 struct tps65090_platform_data *pdata = dev_get_platdata(&client->dev); 181 struct tps65090_platform_data *pdata = dev_get_platdata(&client->dev);
182 int irq_base = 0; 182 int irq_base = 0;
@@ -210,11 +210,11 @@ static int tps65090_i2c_probe(struct i2c_client *client,
210 210
211 if (client->irq) { 211 if (client->irq) {
212 ret = regmap_add_irq_chip(tps65090->rmap, client->irq, 212 ret = regmap_add_irq_chip(tps65090->rmap, client->irq,
213 IRQF_ONESHOT | IRQF_TRIGGER_LOW, irq_base, 213 IRQF_ONESHOT | IRQF_TRIGGER_LOW, irq_base,
214 &tps65090_irq_chip, &tps65090->irq_data); 214 &tps65090_irq_chip, &tps65090->irq_data);
215 if (ret) { 215 if (ret) {
216 dev_err(&client->dev, 216 dev_err(&client->dev,
217 "IRQ init failed with err: %d\n", ret); 217 "IRQ init failed with err: %d\n", ret);
218 return ret; 218 return ret;
219 } 219 }
220 } else { 220 } else {
@@ -223,8 +223,8 @@ static int tps65090_i2c_probe(struct i2c_client *client,
223 } 223 }
224 224
225 ret = mfd_add_devices(tps65090->dev, -1, tps65090s, 225 ret = mfd_add_devices(tps65090->dev, -1, tps65090s,
226 ARRAY_SIZE(tps65090s), NULL, 226 ARRAY_SIZE(tps65090s), NULL,
227 0, regmap_irq_get_domain(tps65090->irq_data)); 227 0, regmap_irq_get_domain(tps65090->irq_data));
228 if (ret) { 228 if (ret) {
229 dev_err(&client->dev, "add mfd devices failed with err: %d\n", 229 dev_err(&client->dev, "add mfd devices failed with err: %d\n",
230 ret); 230 ret);
diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
index a8ee52c95f2f..80a919a8ca97 100644
--- a/drivers/mfd/tps65217.c
+++ b/drivers/mfd/tps65217.c
@@ -33,9 +33,11 @@
33static const struct mfd_cell tps65217s[] = { 33static const struct mfd_cell tps65217s[] = {
34 { 34 {
35 .name = "tps65217-pmic", 35 .name = "tps65217-pmic",
36 .of_compatible = "ti,tps65217-pmic",
36 }, 37 },
37 { 38 {
38 .name = "tps65217-bl", 39 .name = "tps65217-bl",
40 .of_compatible = "ti,tps65217-bl",
39 }, 41 },
40}; 42};
41 43
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 50f9091bcd38..7d63e324e6a8 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -831,6 +831,9 @@ static struct twl4030_power_data osc_off_idle = {
831 831
832static struct of_device_id twl4030_power_of_match[] = { 832static struct of_device_id twl4030_power_of_match[] = {
833 { 833 {
834 .compatible = "ti,twl4030-power",
835 },
836 {
834 .compatible = "ti,twl4030-power-reset", 837 .compatible = "ti,twl4030-power-reset",
835 .data = &omap3_reset, 838 .data = &omap3_reset,
836 }, 839 },
diff --git a/drivers/mfd/viperboard.c b/drivers/mfd/viperboard.c
index 3c2b8f9e3c84..e6b3c70aeb22 100644
--- a/drivers/mfd/viperboard.c
+++ b/drivers/mfd/viperboard.c
@@ -93,9 +93,8 @@ static int vprbrd_probe(struct usb_interface *interface,
93 version >> 8, version & 0xff, 93 version >> 8, version & 0xff,
94 vb->usb_dev->bus->busnum, vb->usb_dev->devnum); 94 vb->usb_dev->bus->busnum, vb->usb_dev->devnum);
95 95
96 ret = mfd_add_devices(&interface->dev, PLATFORM_DEVID_AUTO, 96 ret = mfd_add_hotplug_devices(&interface->dev, vprbrd_devs,
97 vprbrd_devs, ARRAY_SIZE(vprbrd_devs), NULL, 0, 97 ARRAY_SIZE(vprbrd_devs));
98 NULL);
99 if (ret != 0) { 98 if (ret != 0) {
100 dev_err(&interface->dev, "Failed to add mfd devices to core."); 99 dev_err(&interface->dev, "Failed to add mfd devices to core.");
101 goto error; 100 goto error;
diff --git a/drivers/mfd/wm5102-tables.c b/drivers/mfd/wm5102-tables.c
index d6f35bbf795b..b326a82017ee 100644
--- a/drivers/mfd/wm5102-tables.c
+++ b/drivers/mfd/wm5102-tables.c
@@ -336,8 +336,6 @@ static const struct reg_default wm5102_reg_default[] = {
336 { 0x00000218, 0x01A6 }, /* R536 - Mic Bias Ctrl 1 */ 336 { 0x00000218, 0x01A6 }, /* R536 - Mic Bias Ctrl 1 */
337 { 0x00000219, 0x01A6 }, /* R537 - Mic Bias Ctrl 2 */ 337 { 0x00000219, 0x01A6 }, /* R537 - Mic Bias Ctrl 2 */
338 { 0x0000021A, 0x01A6 }, /* R538 - Mic Bias Ctrl 3 */ 338 { 0x0000021A, 0x01A6 }, /* R538 - Mic Bias Ctrl 3 */
339 { 0x00000225, 0x0400 }, /* R549 - HP Ctrl 1L */
340 { 0x00000226, 0x0400 }, /* R550 - HP Ctrl 1R */
341 { 0x00000293, 0x0000 }, /* R659 - Accessory Detect Mode 1 */ 339 { 0x00000293, 0x0000 }, /* R659 - Accessory Detect Mode 1 */
342 { 0x0000029B, 0x0020 }, /* R667 - Headphone Detect 1 */ 340 { 0x0000029B, 0x0020 }, /* R667 - Headphone Detect 1 */
343 { 0x0000029C, 0x0000 }, /* R668 - Headphone Detect 2 */ 341 { 0x0000029C, 0x0000 }, /* R668 - Headphone Detect 2 */
@@ -1112,6 +1110,8 @@ static bool wm5102_readable_register(struct device *dev, unsigned int reg)
1112 case ARIZONA_MIC_BIAS_CTRL_1: 1110 case ARIZONA_MIC_BIAS_CTRL_1:
1113 case ARIZONA_MIC_BIAS_CTRL_2: 1111 case ARIZONA_MIC_BIAS_CTRL_2:
1114 case ARIZONA_MIC_BIAS_CTRL_3: 1112 case ARIZONA_MIC_BIAS_CTRL_3:
1113 case ARIZONA_HP_CTRL_1L:
1114 case ARIZONA_HP_CTRL_1R:
1115 case ARIZONA_ACCESSORY_DETECT_MODE_1: 1115 case ARIZONA_ACCESSORY_DETECT_MODE_1:
1116 case ARIZONA_HEADPHONE_DETECT_1: 1116 case ARIZONA_HEADPHONE_DETECT_1:
1117 case ARIZONA_HEADPHONE_DETECT_2: 1117 case ARIZONA_HEADPHONE_DETECT_2:
@@ -1949,6 +1949,8 @@ static bool wm5102_volatile_register(struct device *dev, unsigned int reg)
1949 case ARIZONA_DSP1_SCRATCH_1: 1949 case ARIZONA_DSP1_SCRATCH_1:
1950 case ARIZONA_DSP1_SCRATCH_2: 1950 case ARIZONA_DSP1_SCRATCH_2:
1951 case ARIZONA_DSP1_SCRATCH_3: 1951 case ARIZONA_DSP1_SCRATCH_3:
1952 case ARIZONA_HP_CTRL_1L:
1953 case ARIZONA_HP_CTRL_1R:
1952 case ARIZONA_HEADPHONE_DETECT_2: 1954 case ARIZONA_HEADPHONE_DETECT_2:
1953 case ARIZONA_HP_DACVAL: 1955 case ARIZONA_HP_DACVAL:
1954 case ARIZONA_MIC_DETECT_3: 1956 case ARIZONA_MIC_DETECT_3:
diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c
index 4642b5b816a0..12cad94b4035 100644
--- a/drivers/mfd/wm5110-tables.c
+++ b/drivers/mfd/wm5110-tables.c
@@ -895,8 +895,16 @@ static const struct reg_default wm5110_reg_default[] = {
895 { 0x00000548, 0x1818 }, /* R1352 - AIF2 Frame Ctrl 2 */ 895 { 0x00000548, 0x1818 }, /* R1352 - AIF2 Frame Ctrl 2 */
896 { 0x00000549, 0x0000 }, /* R1353 - AIF2 Frame Ctrl 3 */ 896 { 0x00000549, 0x0000 }, /* R1353 - AIF2 Frame Ctrl 3 */
897 { 0x0000054A, 0x0001 }, /* R1354 - AIF2 Frame Ctrl 4 */ 897 { 0x0000054A, 0x0001 }, /* R1354 - AIF2 Frame Ctrl 4 */
898 { 0x0000054B, 0x0002 }, /* R1355 - AIF2 Frame Ctrl 5 */
899 { 0x0000054C, 0x0003 }, /* R1356 - AIF2 Frame Ctrl 6 */
900 { 0x0000054D, 0x0004 }, /* R1357 - AIF2 Frame Ctrl 7 */
901 { 0x0000054E, 0x0005 }, /* R1358 - AIF2 Frame Ctrl 8 */
898 { 0x00000551, 0x0000 }, /* R1361 - AIF2 Frame Ctrl 11 */ 902 { 0x00000551, 0x0000 }, /* R1361 - AIF2 Frame Ctrl 11 */
899 { 0x00000552, 0x0001 }, /* R1362 - AIF2 Frame Ctrl 12 */ 903 { 0x00000552, 0x0001 }, /* R1362 - AIF2 Frame Ctrl 12 */
904 { 0x00000553, 0x0002 }, /* R1363 - AIF2 Frame Ctrl 13 */
905 { 0x00000554, 0x0003 }, /* R1364 - AIF2 Frame Ctrl 14 */
906 { 0x00000555, 0x0004 }, /* R1365 - AIF2 Frame Ctrl 15 */
907 { 0x00000556, 0x0005 }, /* R1366 - AIF2 Frame Ctrl 16 */
900 { 0x00000559, 0x0000 }, /* R1369 - AIF2 Tx Enables */ 908 { 0x00000559, 0x0000 }, /* R1369 - AIF2 Tx Enables */
901 { 0x0000055A, 0x0000 }, /* R1370 - AIF2 Rx Enables */ 909 { 0x0000055A, 0x0000 }, /* R1370 - AIF2 Rx Enables */
902 { 0x00000580, 0x000C }, /* R1408 - AIF3 BCLK Ctrl */ 910 { 0x00000580, 0x000C }, /* R1408 - AIF3 BCLK Ctrl */
@@ -1790,6 +1798,8 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg)
1790 case ARIZONA_MIC_BIAS_CTRL_1: 1798 case ARIZONA_MIC_BIAS_CTRL_1:
1791 case ARIZONA_MIC_BIAS_CTRL_2: 1799 case ARIZONA_MIC_BIAS_CTRL_2:
1792 case ARIZONA_MIC_BIAS_CTRL_3: 1800 case ARIZONA_MIC_BIAS_CTRL_3:
1801 case ARIZONA_HP_CTRL_1L:
1802 case ARIZONA_HP_CTRL_1R:
1793 case ARIZONA_ACCESSORY_DETECT_MODE_1: 1803 case ARIZONA_ACCESSORY_DETECT_MODE_1:
1794 case ARIZONA_HEADPHONE_DETECT_1: 1804 case ARIZONA_HEADPHONE_DETECT_1:
1795 case ARIZONA_HEADPHONE_DETECT_2: 1805 case ARIZONA_HEADPHONE_DETECT_2:
@@ -1934,8 +1944,16 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg)
1934 case ARIZONA_AIF2_FRAME_CTRL_2: 1944 case ARIZONA_AIF2_FRAME_CTRL_2:
1935 case ARIZONA_AIF2_FRAME_CTRL_3: 1945 case ARIZONA_AIF2_FRAME_CTRL_3:
1936 case ARIZONA_AIF2_FRAME_CTRL_4: 1946 case ARIZONA_AIF2_FRAME_CTRL_4:
1947 case ARIZONA_AIF2_FRAME_CTRL_5:
1948 case ARIZONA_AIF2_FRAME_CTRL_6:
1949 case ARIZONA_AIF2_FRAME_CTRL_7:
1950 case ARIZONA_AIF2_FRAME_CTRL_8:
1937 case ARIZONA_AIF2_FRAME_CTRL_11: 1951 case ARIZONA_AIF2_FRAME_CTRL_11:
1938 case ARIZONA_AIF2_FRAME_CTRL_12: 1952 case ARIZONA_AIF2_FRAME_CTRL_12:
1953 case ARIZONA_AIF2_FRAME_CTRL_13:
1954 case ARIZONA_AIF2_FRAME_CTRL_14:
1955 case ARIZONA_AIF2_FRAME_CTRL_15:
1956 case ARIZONA_AIF2_FRAME_CTRL_16:
1939 case ARIZONA_AIF2_TX_ENABLES: 1957 case ARIZONA_AIF2_TX_ENABLES:
1940 case ARIZONA_AIF2_RX_ENABLES: 1958 case ARIZONA_AIF2_RX_ENABLES:
1941 case ARIZONA_AIF3_BCLK_CTRL: 1959 case ARIZONA_AIF3_BCLK_CTRL:
@@ -2825,6 +2843,8 @@ static bool wm5110_volatile_register(struct device *dev, unsigned int reg)
2825 case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS: 2843 case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS:
2826 case ARIZONA_ASYNC_SAMPLE_RATE_2_STATUS: 2844 case ARIZONA_ASYNC_SAMPLE_RATE_2_STATUS:
2827 case ARIZONA_MIC_DETECT_3: 2845 case ARIZONA_MIC_DETECT_3:
2846 case ARIZONA_HP_CTRL_1L:
2847 case ARIZONA_HP_CTRL_1R:
2828 case ARIZONA_HEADPHONE_DETECT_2: 2848 case ARIZONA_HEADPHONE_DETECT_2:
2829 case ARIZONA_INPUT_ENABLES_STATUS: 2849 case ARIZONA_INPUT_ENABLES_STATUS:
2830 case ARIZONA_OUTPUT_STATUS_1: 2850 case ARIZONA_OUTPUT_STATUS_1:
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index 4ab527f5c53b..f5124a8acad8 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -308,7 +308,7 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
308 goto err; 308 goto err;
309 } 309 }
310 310
311 mode = id2 & WM8350_CONF_STS_MASK >> 10; 311 mode = (id2 & WM8350_CONF_STS_MASK) >> 10;
312 cust_id = id2 & WM8350_CUST_ID_MASK; 312 cust_id = id2 & WM8350_CUST_ID_MASK;
313 chip_rev = (id2 & WM8350_CHIP_REV_MASK) >> 12; 313 chip_rev = (id2 & WM8350_CHIP_REV_MASK) >> 12;
314 dev_info(wm8350->dev, 314 dev_info(wm8350->dev,
diff --git a/drivers/mfd/wm8997-tables.c b/drivers/mfd/wm8997-tables.c
index 510da3b52324..c0c25d75aacc 100644
--- a/drivers/mfd/wm8997-tables.c
+++ b/drivers/mfd/wm8997-tables.c
@@ -670,6 +670,7 @@ static const struct reg_default wm8997_reg_default[] = {
670 { 0x00000C23, 0x0000 }, /* R3107 - Misc Pad Ctrl 4 */ 670 { 0x00000C23, 0x0000 }, /* R3107 - Misc Pad Ctrl 4 */
671 { 0x00000C24, 0x0000 }, /* R3108 - Misc Pad Ctrl 5 */ 671 { 0x00000C24, 0x0000 }, /* R3108 - Misc Pad Ctrl 5 */
672 { 0x00000D08, 0xFFFF }, /* R3336 - Interrupt Status 1 Mask */ 672 { 0x00000D08, 0xFFFF }, /* R3336 - Interrupt Status 1 Mask */
673 { 0x00000D09, 0xFFFF }, /* R3337 - Interrupt Status 2 Mask */
673 { 0x00000D0A, 0xFFFF }, /* R3338 - Interrupt Status 3 Mask */ 674 { 0x00000D0A, 0xFFFF }, /* R3338 - Interrupt Status 3 Mask */
674 { 0x00000D0B, 0xFFFF }, /* R3339 - Interrupt Status 4 Mask */ 675 { 0x00000D0B, 0xFFFF }, /* R3339 - Interrupt Status 4 Mask */
675 { 0x00000D0C, 0xFEFF }, /* R3340 - Interrupt Status 5 Mask */ 676 { 0x00000D0C, 0xFEFF }, /* R3340 - Interrupt Status 5 Mask */
@@ -886,6 +887,8 @@ static bool wm8997_readable_register(struct device *dev, unsigned int reg)
886 case ARIZONA_MIC_BIAS_CTRL_1: 887 case ARIZONA_MIC_BIAS_CTRL_1:
887 case ARIZONA_MIC_BIAS_CTRL_2: 888 case ARIZONA_MIC_BIAS_CTRL_2:
888 case ARIZONA_MIC_BIAS_CTRL_3: 889 case ARIZONA_MIC_BIAS_CTRL_3:
890 case ARIZONA_HP_CTRL_1L:
891 case ARIZONA_HP_CTRL_1R:
889 case ARIZONA_ACCESSORY_DETECT_MODE_1: 892 case ARIZONA_ACCESSORY_DETECT_MODE_1:
890 case ARIZONA_HEADPHONE_DETECT_1: 893 case ARIZONA_HEADPHONE_DETECT_1:
891 case ARIZONA_HEADPHONE_DETECT_2: 894 case ARIZONA_HEADPHONE_DETECT_2:
@@ -1328,6 +1331,7 @@ static bool wm8997_readable_register(struct device *dev, unsigned int reg)
1328 case ARIZONA_INTERRUPT_STATUS_4: 1331 case ARIZONA_INTERRUPT_STATUS_4:
1329 case ARIZONA_INTERRUPT_STATUS_5: 1332 case ARIZONA_INTERRUPT_STATUS_5:
1330 case ARIZONA_INTERRUPT_STATUS_1_MASK: 1333 case ARIZONA_INTERRUPT_STATUS_1_MASK:
1334 case ARIZONA_INTERRUPT_STATUS_2_MASK:
1331 case ARIZONA_INTERRUPT_STATUS_3_MASK: 1335 case ARIZONA_INTERRUPT_STATUS_3_MASK:
1332 case ARIZONA_INTERRUPT_STATUS_4_MASK: 1336 case ARIZONA_INTERRUPT_STATUS_4_MASK:
1333 case ARIZONA_INTERRUPT_STATUS_5_MASK: 1337 case ARIZONA_INTERRUPT_STATUS_5_MASK:
@@ -1477,6 +1481,8 @@ static bool wm8997_volatile_register(struct device *dev, unsigned int reg)
1477 case ARIZONA_SAMPLE_RATE_3_STATUS: 1481 case ARIZONA_SAMPLE_RATE_3_STATUS:
1478 case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS: 1482 case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS:
1479 case ARIZONA_MIC_DETECT_3: 1483 case ARIZONA_MIC_DETECT_3:
1484 case ARIZONA_HP_CTRL_1L:
1485 case ARIZONA_HP_CTRL_1R:
1480 case ARIZONA_HEADPHONE_DETECT_2: 1486 case ARIZONA_HEADPHONE_DETECT_2:
1481 case ARIZONA_INPUT_ENABLES_STATUS: 1487 case ARIZONA_INPUT_ENABLES_STATUS:
1482 case ARIZONA_OUTPUT_STATUS_1: 1488 case ARIZONA_OUTPUT_STATUS_1:
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 55d7b7b0f2e0..5e061347be93 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -529,13 +529,13 @@ config REGULATOR_S2MPA01
529 via I2C bus. S2MPA01 has 10 Bucks and 26 LDO outputs. 529 via I2C bus. S2MPA01 has 10 Bucks and 26 LDO outputs.
530 530
531config REGULATOR_S2MPS11 531config REGULATOR_S2MPS11
532 tristate "Samsung S2MPS11/S2MPS14/S2MPU02 voltage regulator" 532 tristate "Samsung S2MPS11/S2MPS13/S2MPS14/S2MPU02 voltage regulator"
533 depends on MFD_SEC_CORE 533 depends on MFD_SEC_CORE
534 help 534 help
535 This driver supports a Samsung S2MPS11/S2MPS14/S2MPU02 voltage output 535 This driver supports a Samsung S2MPS11/S2MPS13/S2MPS14/S2MPU02 voltage
536 regulator via I2C bus. The chip is comprised of high efficient Buck 536 output regulator via I2C bus. The chip is comprised of high efficient
537 converters including Dual-Phase Buck converter, Buck-Boost converter, 537 Buck converters including Dual-Phase Buck converter, Buck-Boost
538 various LDOs. 538 converter, various LDOs.
539 539
540config REGULATOR_S5M8767 540config REGULATOR_S5M8767
541 tristate "Samsung S5M8767A voltage regulator" 541 tristate "Samsung S5M8767A voltage regulator"
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index adab82d5279f..738dc7763d47 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -30,6 +30,7 @@
30#include <linux/of_gpio.h> 30#include <linux/of_gpio.h>
31#include <linux/mfd/samsung/core.h> 31#include <linux/mfd/samsung/core.h>
32#include <linux/mfd/samsung/s2mps11.h> 32#include <linux/mfd/samsung/s2mps11.h>
33#include <linux/mfd/samsung/s2mps13.h>
33#include <linux/mfd/samsung/s2mps14.h> 34#include <linux/mfd/samsung/s2mps14.h>
34#include <linux/mfd/samsung/s2mpu02.h> 35#include <linux/mfd/samsung/s2mpu02.h>
35 36
@@ -45,10 +46,10 @@ struct s2mps11_info {
45 enum sec_device_type dev_type; 46 enum sec_device_type dev_type;
46 47
47 /* 48 /*
48 * One bit for each S2MPS14/S2MPU02 regulator whether the suspend mode 49 * One bit for each S2MPS13/S2MPS14/S2MPU02 regulator whether
49 * was enabled. 50 * the suspend mode was enabled.
50 */ 51 */
51 unsigned long long s2mps14_suspend_state:35; 52 unsigned long long s2mps14_suspend_state:50;
52 53
53 /* Array of size rdev_num with GPIO-s for external sleep control */ 54 /* Array of size rdev_num with GPIO-s for external sleep control */
54 int *ext_control_gpio; 55 int *ext_control_gpio;
@@ -369,12 +370,101 @@ static const struct regulator_desc s2mps11_regulators[] = {
369 regulator_desc_s2mps11_buck6_10(10, MIN_750_MV, STEP_12_5_MV), 370 regulator_desc_s2mps11_buck6_10(10, MIN_750_MV, STEP_12_5_MV),
370}; 371};
371 372
373static struct regulator_ops s2mps14_reg_ops;
374
375#define regulator_desc_s2mps13_ldo(num, min, step, min_sel) { \
376 .name = "LDO"#num, \
377 .id = S2MPS13_LDO##num, \
378 .ops = &s2mps14_reg_ops, \
379 .type = REGULATOR_VOLTAGE, \
380 .owner = THIS_MODULE, \
381 .min_uV = min, \
382 .uV_step = step, \
383 .linear_min_sel = min_sel, \
384 .n_voltages = S2MPS14_LDO_N_VOLTAGES, \
385 .vsel_reg = S2MPS13_REG_L1CTRL + num - 1, \
386 .vsel_mask = S2MPS14_LDO_VSEL_MASK, \
387 .enable_reg = S2MPS13_REG_L1CTRL + num - 1, \
388 .enable_mask = S2MPS14_ENABLE_MASK \
389}
390
391#define regulator_desc_s2mps13_buck(num, min, step, min_sel) { \
392 .name = "BUCK"#num, \
393 .id = S2MPS13_BUCK##num, \
394 .ops = &s2mps14_reg_ops, \
395 .type = REGULATOR_VOLTAGE, \
396 .owner = THIS_MODULE, \
397 .min_uV = min, \
398 .uV_step = step, \
399 .linear_min_sel = min_sel, \
400 .n_voltages = S2MPS14_BUCK_N_VOLTAGES, \
401 .ramp_delay = S2MPS13_BUCK_RAMP_DELAY, \
402 .vsel_reg = S2MPS13_REG_B1OUT + (num - 1) * 2, \
403 .vsel_mask = S2MPS14_BUCK_VSEL_MASK, \
404 .enable_reg = S2MPS13_REG_B1CTRL + (num - 1) * 2, \
405 .enable_mask = S2MPS14_ENABLE_MASK \
406}
407
408static const struct regulator_desc s2mps13_regulators[] = {
409 regulator_desc_s2mps13_ldo(1, MIN_800_MV, STEP_12_5_MV, 0x00),
410 regulator_desc_s2mps13_ldo(2, MIN_1400_MV, STEP_50_MV, 0x0C),
411 regulator_desc_s2mps13_ldo(3, MIN_1000_MV, STEP_25_MV, 0x08),
412 regulator_desc_s2mps13_ldo(4, MIN_800_MV, STEP_12_5_MV, 0x00),
413 regulator_desc_s2mps13_ldo(5, MIN_800_MV, STEP_12_5_MV, 0x00),
414 regulator_desc_s2mps13_ldo(6, MIN_800_MV, STEP_12_5_MV, 0x00),
415 regulator_desc_s2mps13_ldo(7, MIN_1000_MV, STEP_25_MV, 0x08),
416 regulator_desc_s2mps13_ldo(8, MIN_1000_MV, STEP_25_MV, 0x08),
417 regulator_desc_s2mps13_ldo(9, MIN_1000_MV, STEP_25_MV, 0x08),
418 regulator_desc_s2mps13_ldo(10, MIN_1400_MV, STEP_50_MV, 0x0C),
419 regulator_desc_s2mps13_ldo(11, MIN_800_MV, STEP_25_MV, 0x10),
420 regulator_desc_s2mps13_ldo(12, MIN_800_MV, STEP_25_MV, 0x10),
421 regulator_desc_s2mps13_ldo(13, MIN_800_MV, STEP_25_MV, 0x10),
422 regulator_desc_s2mps13_ldo(14, MIN_800_MV, STEP_12_5_MV, 0x00),
423 regulator_desc_s2mps13_ldo(15, MIN_800_MV, STEP_12_5_MV, 0x00),
424 regulator_desc_s2mps13_ldo(16, MIN_1400_MV, STEP_50_MV, 0x0C),
425 regulator_desc_s2mps13_ldo(17, MIN_1400_MV, STEP_50_MV, 0x0C),
426 regulator_desc_s2mps13_ldo(18, MIN_1000_MV, STEP_25_MV, 0x08),
427 regulator_desc_s2mps13_ldo(19, MIN_1000_MV, STEP_25_MV, 0x08),
428 regulator_desc_s2mps13_ldo(20, MIN_1400_MV, STEP_50_MV, 0x0C),
429 regulator_desc_s2mps13_ldo(21, MIN_1000_MV, STEP_25_MV, 0x08),
430 regulator_desc_s2mps13_ldo(22, MIN_1000_MV, STEP_25_MV, 0x08),
431 regulator_desc_s2mps13_ldo(23, MIN_800_MV, STEP_12_5_MV, 0x00),
432 regulator_desc_s2mps13_ldo(24, MIN_800_MV, STEP_12_5_MV, 0x00),
433 regulator_desc_s2mps13_ldo(25, MIN_1400_MV, STEP_50_MV, 0x0C),
434 regulator_desc_s2mps13_ldo(26, MIN_1400_MV, STEP_50_MV, 0x0C),
435 regulator_desc_s2mps13_ldo(27, MIN_1400_MV, STEP_50_MV, 0x0C),
436 regulator_desc_s2mps13_ldo(28, MIN_1000_MV, STEP_25_MV, 0x08),
437 regulator_desc_s2mps13_ldo(29, MIN_1400_MV, STEP_50_MV, 0x0C),
438 regulator_desc_s2mps13_ldo(30, MIN_1400_MV, STEP_50_MV, 0x0C),
439 regulator_desc_s2mps13_ldo(31, MIN_1000_MV, STEP_25_MV, 0x08),
440 regulator_desc_s2mps13_ldo(32, MIN_1000_MV, STEP_25_MV, 0x08),
441 regulator_desc_s2mps13_ldo(33, MIN_1400_MV, STEP_50_MV, 0x0C),
442 regulator_desc_s2mps13_ldo(34, MIN_1000_MV, STEP_25_MV, 0x08),
443 regulator_desc_s2mps13_ldo(35, MIN_1400_MV, STEP_50_MV, 0x0C),
444 regulator_desc_s2mps13_ldo(36, MIN_800_MV, STEP_12_5_MV, 0x00),
445 regulator_desc_s2mps13_ldo(37, MIN_1000_MV, STEP_25_MV, 0x08),
446 regulator_desc_s2mps13_ldo(38, MIN_1400_MV, STEP_50_MV, 0x0C),
447 regulator_desc_s2mps13_ldo(39, MIN_1000_MV, STEP_25_MV, 0x08),
448 regulator_desc_s2mps13_ldo(40, MIN_1400_MV, STEP_50_MV, 0x0C),
449 regulator_desc_s2mps13_buck(1, MIN_500_MV, STEP_6_25_MV, 0x10),
450 regulator_desc_s2mps13_buck(2, MIN_500_MV, STEP_6_25_MV, 0x10),
451 regulator_desc_s2mps13_buck(3, MIN_500_MV, STEP_6_25_MV, 0x10),
452 regulator_desc_s2mps13_buck(4, MIN_500_MV, STEP_6_25_MV, 0x10),
453 regulator_desc_s2mps13_buck(5, MIN_500_MV, STEP_6_25_MV, 0x10),
454 regulator_desc_s2mps13_buck(6, MIN_500_MV, STEP_6_25_MV, 0x10),
455 regulator_desc_s2mps13_buck(7, MIN_500_MV, STEP_6_25_MV, 0x10),
456 regulator_desc_s2mps13_buck(8, MIN_1000_MV, STEP_12_5_MV, 0x20),
457 regulator_desc_s2mps13_buck(9, MIN_1000_MV, STEP_12_5_MV, 0x20),
458 regulator_desc_s2mps13_buck(10, MIN_500_MV, STEP_6_25_MV, 0x10),
459};
460
372static int s2mps14_regulator_enable(struct regulator_dev *rdev) 461static int s2mps14_regulator_enable(struct regulator_dev *rdev)
373{ 462{
374 struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev); 463 struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev);
375 unsigned int val; 464 unsigned int val;
376 465
377 switch (s2mps11->dev_type) { 466 switch (s2mps11->dev_type) {
467 case S2MPS13X:
378 case S2MPS14X: 468 case S2MPS14X:
379 if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev))) 469 if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev)))
380 val = S2MPS14_ENABLE_SUSPEND; 470 val = S2MPS14_ENABLE_SUSPEND;
@@ -406,6 +496,7 @@ static int s2mps14_regulator_set_suspend_disable(struct regulator_dev *rdev)
406 496
407 /* Below LDO should be always on or does not support suspend mode. */ 497 /* Below LDO should be always on or does not support suspend mode. */
408 switch (s2mps11->dev_type) { 498 switch (s2mps11->dev_type) {
499 case S2MPS13X:
409 case S2MPS14X: 500 case S2MPS14X:
410 switch (rdev_id) { 501 switch (rdev_id) {
411 case S2MPS14_LDO3: 502 case S2MPS14_LDO3:
@@ -831,6 +922,10 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
831 s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators); 922 s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators);
832 regulators = s2mps11_regulators; 923 regulators = s2mps11_regulators;
833 break; 924 break;
925 case S2MPS13X:
926 s2mps11->rdev_num = ARRAY_SIZE(s2mps13_regulators);
927 regulators = s2mps13_regulators;
928 break;
834 case S2MPS14X: 929 case S2MPS14X:
835 s2mps11->rdev_num = ARRAY_SIZE(s2mps14_regulators); 930 s2mps11->rdev_num = ARRAY_SIZE(s2mps14_regulators);
836 regulators = s2mps14_regulators; 931 regulators = s2mps14_regulators;
@@ -927,6 +1022,7 @@ out:
927 1022
928static const struct platform_device_id s2mps11_pmic_id[] = { 1023static const struct platform_device_id s2mps11_pmic_id[] = {
929 { "s2mps11-pmic", S2MPS11X}, 1024 { "s2mps11-pmic", S2MPS11X},
1025 { "s2mps13-pmic", S2MPS13X},
930 { "s2mps14-pmic", S2MPS14X}, 1026 { "s2mps14-pmic", S2MPS14X},
931 { "s2mpu02-pmic", S2MPU02}, 1027 { "s2mpu02-pmic", S2MPU02},
932 { }, 1028 { },
diff --git a/include/linux/mfd/abx500/ab8500-sysctrl.h b/include/linux/mfd/abx500/ab8500-sysctrl.h
index adba89d9c660..689312745b2f 100644
--- a/include/linux/mfd/abx500/ab8500-sysctrl.h
+++ b/include/linux/mfd/abx500/ab8500-sysctrl.h
@@ -12,7 +12,6 @@
12 12
13int ab8500_sysctrl_read(u16 reg, u8 *value); 13int ab8500_sysctrl_read(u16 reg, u8 *value);
14int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value); 14int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value);
15void ab8500_restart(char mode, const char *cmd);
16 15
17#else 16#else
18 17
diff --git a/include/linux/mfd/arizona/registers.h b/include/linux/mfd/arizona/registers.h
index c0b075f6bc35..aacc10d7789c 100644
--- a/include/linux/mfd/arizona/registers.h
+++ b/include/linux/mfd/arizona/registers.h
@@ -125,6 +125,8 @@
125#define ARIZONA_MIC_BIAS_CTRL_1 0x218 125#define ARIZONA_MIC_BIAS_CTRL_1 0x218
126#define ARIZONA_MIC_BIAS_CTRL_2 0x219 126#define ARIZONA_MIC_BIAS_CTRL_2 0x219
127#define ARIZONA_MIC_BIAS_CTRL_3 0x21A 127#define ARIZONA_MIC_BIAS_CTRL_3 0x21A
128#define ARIZONA_HP_CTRL_1L 0x225
129#define ARIZONA_HP_CTRL_1R 0x226
128#define ARIZONA_ACCESSORY_DETECT_MODE_1 0x293 130#define ARIZONA_ACCESSORY_DETECT_MODE_1 0x293
129#define ARIZONA_HEADPHONE_DETECT_1 0x29B 131#define ARIZONA_HEADPHONE_DETECT_1 0x29B
130#define ARIZONA_HEADPHONE_DETECT_2 0x29C 132#define ARIZONA_HEADPHONE_DETECT_2 0x29C
@@ -279,8 +281,16 @@
279#define ARIZONA_AIF2_FRAME_CTRL_2 0x548 281#define ARIZONA_AIF2_FRAME_CTRL_2 0x548
280#define ARIZONA_AIF2_FRAME_CTRL_3 0x549 282#define ARIZONA_AIF2_FRAME_CTRL_3 0x549
281#define ARIZONA_AIF2_FRAME_CTRL_4 0x54A 283#define ARIZONA_AIF2_FRAME_CTRL_4 0x54A
284#define ARIZONA_AIF2_FRAME_CTRL_5 0x54B
285#define ARIZONA_AIF2_FRAME_CTRL_6 0x54C
286#define ARIZONA_AIF2_FRAME_CTRL_7 0x54D
287#define ARIZONA_AIF2_FRAME_CTRL_8 0x54E
282#define ARIZONA_AIF2_FRAME_CTRL_11 0x551 288#define ARIZONA_AIF2_FRAME_CTRL_11 0x551
283#define ARIZONA_AIF2_FRAME_CTRL_12 0x552 289#define ARIZONA_AIF2_FRAME_CTRL_12 0x552
290#define ARIZONA_AIF2_FRAME_CTRL_13 0x553
291#define ARIZONA_AIF2_FRAME_CTRL_14 0x554
292#define ARIZONA_AIF2_FRAME_CTRL_15 0x555
293#define ARIZONA_AIF2_FRAME_CTRL_16 0x556
284#define ARIZONA_AIF2_TX_ENABLES 0x559 294#define ARIZONA_AIF2_TX_ENABLES 0x559
285#define ARIZONA_AIF2_RX_ENABLES 0x55A 295#define ARIZONA_AIF2_RX_ENABLES 0x55A
286#define ARIZONA_AIF2_FORCE_WRITE 0x55B 296#define ARIZONA_AIF2_FORCE_WRITE 0x55B
@@ -2245,6 +2255,46 @@
2245#define ARIZONA_MICB3_ENA_WIDTH 1 /* MICB3_ENA */ 2255#define ARIZONA_MICB3_ENA_WIDTH 1 /* MICB3_ENA */
2246 2256
2247/* 2257/*
2258 * R549 (0x225) - HP Ctrl 1L
2259 */
2260#define ARIZONA_RMV_SHRT_HP1L 0x4000 /* RMV_SHRT_HP1L */
2261#define ARIZONA_RMV_SHRT_HP1L_MASK 0x4000 /* RMV_SHRT_HP1L */
2262#define ARIZONA_RMV_SHRT_HP1L_SHIFT 14 /* RMV_SHRT_HP1L */
2263#define ARIZONA_RMV_SHRT_HP1L_WIDTH 1 /* RMV_SHRT_HP1L */
2264#define ARIZONA_HP1L_FLWR 0x0004 /* HP1L_FLWR */
2265#define ARIZONA_HP1L_FLWR_MASK 0x0004 /* HP1L_FLWR */
2266#define ARIZONA_HP1L_FLWR_SHIFT 2 /* HP1L_FLWR */
2267#define ARIZONA_HP1L_FLWR_WIDTH 1 /* HP1L_FLWR */
2268#define ARIZONA_HP1L_SHRTI 0x0002 /* HP1L_SHRTI */
2269#define ARIZONA_HP1L_SHRTI_MASK 0x0002 /* HP1L_SHRTI */
2270#define ARIZONA_HP1L_SHRTI_SHIFT 1 /* HP1L_SHRTI */
2271#define ARIZONA_HP1L_SHRTI_WIDTH 1 /* HP1L_SHRTI */
2272#define ARIZONA_HP1L_SHRTO 0x0001 /* HP1L_SHRTO */
2273#define ARIZONA_HP1L_SHRTO_MASK 0x0001 /* HP1L_SHRTO */
2274#define ARIZONA_HP1L_SHRTO_SHIFT 0 /* HP1L_SHRTO */
2275#define ARIZONA_HP1L_SHRTO_WIDTH 1 /* HP1L_SHRTO */
2276
2277/*
2278 * R550 (0x226) - HP Ctrl 1R
2279 */
2280#define ARIZONA_RMV_SHRT_HP1R 0x4000 /* RMV_SHRT_HP1R */
2281#define ARIZONA_RMV_SHRT_HP1R_MASK 0x4000 /* RMV_SHRT_HP1R */
2282#define ARIZONA_RMV_SHRT_HP1R_SHIFT 14 /* RMV_SHRT_HP1R */
2283#define ARIZONA_RMV_SHRT_HP1R_WIDTH 1 /* RMV_SHRT_HP1R */
2284#define ARIZONA_HP1R_FLWR 0x0004 /* HP1R_FLWR */
2285#define ARIZONA_HP1R_FLWR_MASK 0x0004 /* HP1R_FLWR */
2286#define ARIZONA_HP1R_FLWR_SHIFT 2 /* HP1R_FLWR */
2287#define ARIZONA_HP1R_FLWR_WIDTH 1 /* HP1R_FLWR */
2288#define ARIZONA_HP1R_SHRTI 0x0002 /* HP1R_SHRTI */
2289#define ARIZONA_HP1R_SHRTI_MASK 0x0002 /* HP1R_SHRTI */
2290#define ARIZONA_HP1R_SHRTI_SHIFT 1 /* HP1R_SHRTI */
2291#define ARIZONA_HP1R_SHRTI_WIDTH 1 /* HP1R_SHRTI */
2292#define ARIZONA_HP1R_SHRTO 0x0001 /* HP1R_SHRTO */
2293#define ARIZONA_HP1R_SHRTO_MASK 0x0001 /* HP1R_SHRTO */
2294#define ARIZONA_HP1R_SHRTO_SHIFT 0 /* HP1R_SHRTO */
2295#define ARIZONA_HP1R_SHRTO_WIDTH 1 /* HP1R_SHRTO */
2296
2297/*
2248 * R659 (0x293) - Accessory Detect Mode 1 2298 * R659 (0x293) - Accessory Detect Mode 1
2249 */ 2299 */
2250#define ARIZONA_ACCDET_SRC 0x2000 /* ACCDET_SRC */ 2300#define ARIZONA_ACCDET_SRC 0x2000 /* ACCDET_SRC */
diff --git a/include/linux/mfd/atmel-hlcdc.h b/include/linux/mfd/atmel-hlcdc.h
new file mode 100644
index 000000000000..1279ab1644b5
--- /dev/null
+++ b/include/linux/mfd/atmel-hlcdc.h
@@ -0,0 +1,85 @@
1/*
2 * Copyright (C) 2014 Free Electrons
3 * Copyright (C) 2014 Atmel
4 *
5 * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef __LINUX_MFD_HLCDC_H
21#define __LINUX_MFD_HLCDC_H
22
23#include <linux/clk.h>
24#include <linux/regmap.h>
25
26#define ATMEL_HLCDC_CFG(i) ((i) * 0x4)
27#define ATMEL_HLCDC_SIG_CFG LCDCFG(5)
28#define ATMEL_HLCDC_HSPOL BIT(0)
29#define ATMEL_HLCDC_VSPOL BIT(1)
30#define ATMEL_HLCDC_VSPDLYS BIT(2)
31#define ATMEL_HLCDC_VSPDLYE BIT(3)
32#define ATMEL_HLCDC_DISPPOL BIT(4)
33#define ATMEL_HLCDC_DITHER BIT(6)
34#define ATMEL_HLCDC_DISPDLY BIT(7)
35#define ATMEL_HLCDC_MODE_MASK GENMASK(9, 8)
36#define ATMEL_HLCDC_PP BIT(10)
37#define ATMEL_HLCDC_VSPSU BIT(12)
38#define ATMEL_HLCDC_VSPHO BIT(13)
39#define ATMEL_HLCDC_GUARDTIME_MASK GENMASK(20, 16)
40
41#define ATMEL_HLCDC_EN 0x20
42#define ATMEL_HLCDC_DIS 0x24
43#define ATMEL_HLCDC_SR 0x28
44#define ATMEL_HLCDC_IER 0x2c
45#define ATMEL_HLCDC_IDR 0x30
46#define ATMEL_HLCDC_IMR 0x34
47#define ATMEL_HLCDC_ISR 0x38
48
49#define ATMEL_HLCDC_CLKPOL BIT(0)
50#define ATMEL_HLCDC_CLKSEL BIT(2)
51#define ATMEL_HLCDC_CLKPWMSEL BIT(3)
52#define ATMEL_HLCDC_CGDIS(i) BIT(8 + (i))
53#define ATMEL_HLCDC_CLKDIV_SHFT 16
54#define ATMEL_HLCDC_CLKDIV_MASK GENMASK(23, 16)
55#define ATMEL_HLCDC_CLKDIV(div) ((div - 2) << ATMEL_HLCDC_CLKDIV_SHFT)
56
57#define ATMEL_HLCDC_PIXEL_CLK BIT(0)
58#define ATMEL_HLCDC_SYNC BIT(1)
59#define ATMEL_HLCDC_DISP BIT(2)
60#define ATMEL_HLCDC_PWM BIT(3)
61#define ATMEL_HLCDC_SIP BIT(4)
62
63#define ATMEL_HLCDC_SOF BIT(0)
64#define ATMEL_HLCDC_SYNCDIS BIT(1)
65#define ATMEL_HLCDC_FIFOERR BIT(4)
66#define ATMEL_HLCDC_LAYER_STATUS(x) BIT((x) + 8)
67
68/**
69 * Structure shared by the MFD device and its subdevices.
70 *
71 * @regmap: register map used to access HLCDC IP registers
72 * @periph_clk: the hlcdc peripheral clock
73 * @sys_clk: the hlcdc system clock
74 * @slow_clk: the system slow clk
75 * @irq: the hlcdc irq
76 */
77struct atmel_hlcdc {
78 struct regmap *regmap;
79 struct clk *periph_clk;
80 struct clk *sys_clk;
81 struct clk *slow_clk;
82 int irq;
83};
84
85#endif /* __LINUX_MFD_HLCDC_H */
diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
index d0e31a2287ac..81589d176ae8 100644
--- a/include/linux/mfd/axp20x.h
+++ b/include/linux/mfd/axp20x.h
@@ -14,6 +14,8 @@
14enum { 14enum {
15 AXP202_ID = 0, 15 AXP202_ID = 0,
16 AXP209_ID, 16 AXP209_ID,
17 AXP288_ID,
18 NR_AXP20X_VARIANTS,
17}; 19};
18 20
19#define AXP20X_DATACACHE(m) (0x04 + (m)) 21#define AXP20X_DATACACHE(m) (0x04 + (m))
@@ -49,11 +51,13 @@ enum {
49#define AXP20X_IRQ3_EN 0x42 51#define AXP20X_IRQ3_EN 0x42
50#define AXP20X_IRQ4_EN 0x43 52#define AXP20X_IRQ4_EN 0x43
51#define AXP20X_IRQ5_EN 0x44 53#define AXP20X_IRQ5_EN 0x44
54#define AXP20X_IRQ6_EN 0x45
52#define AXP20X_IRQ1_STATE 0x48 55#define AXP20X_IRQ1_STATE 0x48
53#define AXP20X_IRQ2_STATE 0x49 56#define AXP20X_IRQ2_STATE 0x49
54#define AXP20X_IRQ3_STATE 0x4a 57#define AXP20X_IRQ3_STATE 0x4a
55#define AXP20X_IRQ4_STATE 0x4b 58#define AXP20X_IRQ4_STATE 0x4b
56#define AXP20X_IRQ5_STATE 0x4c 59#define AXP20X_IRQ5_STATE 0x4c
60#define AXP20X_IRQ6_STATE 0x4d
57 61
58/* ADC */ 62/* ADC */
59#define AXP20X_ACIN_V_ADC_H 0x56 63#define AXP20X_ACIN_V_ADC_H 0x56
@@ -116,6 +120,15 @@ enum {
116#define AXP20X_CC_CTRL 0xb8 120#define AXP20X_CC_CTRL 0xb8
117#define AXP20X_FG_RES 0xb9 121#define AXP20X_FG_RES 0xb9
118 122
123/* AXP288 specific registers */
124#define AXP288_PMIC_ADC_H 0x56
125#define AXP288_PMIC_ADC_L 0x57
126#define AXP288_ADC_TS_PIN_CTRL 0x84
127
128#define AXP288_PMIC_ADC_EN 0x84
129#define AXP288_FG_TUNE5 0xed
130
131
119/* Regulators IDs */ 132/* Regulators IDs */
120enum { 133enum {
121 AXP20X_LDO1 = 0, 134 AXP20X_LDO1 = 0,
@@ -169,12 +182,58 @@ enum {
169 AXP20X_IRQ_GPIO0_INPUT, 182 AXP20X_IRQ_GPIO0_INPUT,
170}; 183};
171 184
185enum axp288_irqs {
186 AXP288_IRQ_VBUS_FALL = 2,
187 AXP288_IRQ_VBUS_RISE,
188 AXP288_IRQ_OV,
189 AXP288_IRQ_FALLING_ALT,
190 AXP288_IRQ_RISING_ALT,
191 AXP288_IRQ_OV_ALT,
192 AXP288_IRQ_DONE = 10,
193 AXP288_IRQ_CHARGING,
194 AXP288_IRQ_SAFE_QUIT,
195 AXP288_IRQ_SAFE_ENTER,
196 AXP288_IRQ_ABSENT,
197 AXP288_IRQ_APPEND,
198 AXP288_IRQ_QWBTU,
199 AXP288_IRQ_WBTU,
200 AXP288_IRQ_QWBTO,
201 AXP288_IRQ_WBTO,
202 AXP288_IRQ_QCBTU,
203 AXP288_IRQ_CBTU,
204 AXP288_IRQ_QCBTO,
205 AXP288_IRQ_CBTO,
206 AXP288_IRQ_WL2,
207 AXP288_IRQ_WL1,
208 AXP288_IRQ_GPADC,
209 AXP288_IRQ_OT = 31,
210 AXP288_IRQ_GPIO0,
211 AXP288_IRQ_GPIO1,
212 AXP288_IRQ_POKO,
213 AXP288_IRQ_POKL,
214 AXP288_IRQ_POKS,
215 AXP288_IRQ_POKN,
216 AXP288_IRQ_POKP,
217 AXP288_IRQ_TIMER,
218 AXP288_IRQ_MV_CHNG,
219 AXP288_IRQ_BC_USB_CHNG,
220};
221
222#define AXP288_TS_ADC_H 0x58
223#define AXP288_TS_ADC_L 0x59
224#define AXP288_GP_ADC_H 0x5a
225#define AXP288_GP_ADC_L 0x5b
226
172struct axp20x_dev { 227struct axp20x_dev {
173 struct device *dev; 228 struct device *dev;
174 struct i2c_client *i2c_client; 229 struct i2c_client *i2c_client;
175 struct regmap *regmap; 230 struct regmap *regmap;
176 struct regmap_irq_chip_data *regmap_irqc; 231 struct regmap_irq_chip_data *regmap_irqc;
177 long variant; 232 long variant;
233 int nr_cells;
234 struct mfd_cell *cells;
235 const struct regmap_config *regmap_cfg;
236 const struct regmap_irq_chip *regmap_irq_chip;
178}; 237};
179 238
180#endif /* __LINUX_MFD_AXP20X_H */ 239#endif /* __LINUX_MFD_AXP20X_H */
diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h
index 73e1709d4c09..a76bc100bf97 100644
--- a/include/linux/mfd/core.h
+++ b/include/linux/mfd/core.h
@@ -111,6 +111,13 @@ extern int mfd_add_devices(struct device *parent, int id,
111 struct resource *mem_base, 111 struct resource *mem_base,
112 int irq_base, struct irq_domain *irq_domain); 112 int irq_base, struct irq_domain *irq_domain);
113 113
114static inline int mfd_add_hotplug_devices(struct device *parent,
115 const struct mfd_cell *cells, int n_devs)
116{
117 return mfd_add_devices(parent, PLATFORM_DEVID_AUTO, cells, n_devs,
118 NULL, 0, NULL);
119}
120
114extern void mfd_remove_devices(struct device *parent); 121extern void mfd_remove_devices(struct device *parent);
115 122
116#endif 123#endif
diff --git a/include/linux/mfd/dln2.h b/include/linux/mfd/dln2.h
new file mode 100644
index 000000000000..004b24576da8
--- /dev/null
+++ b/include/linux/mfd/dln2.h
@@ -0,0 +1,103 @@
1#ifndef __LINUX_USB_DLN2_H
2#define __LINUX_USB_DLN2_H
3
4#define DLN2_CMD(cmd, id) ((cmd) | ((id) << 8))
5
6struct dln2_platform_data {
7 u16 handle; /* sub-driver handle (internally used only) */
8 u8 port; /* I2C/SPI port */
9};
10
11/**
12 * dln2_event_cb_t - event callback function signature
13 *
14 * @pdev - the sub-device that registered this callback
15 * @echo - the echo header field received in the message
16 * @data - the data payload
17 * @len - the data payload length
18 *
19 * The callback function is called in interrupt context and the data payload is
20 * only valid during the call. If the user needs later access of the data, it
21 * must copy it.
22 */
23
24typedef void (*dln2_event_cb_t)(struct platform_device *pdev, u16 echo,
25 const void *data, int len);
26
27/**
28 * dl2n_register_event_cb - register a callback function for an event
29 *
30 * @pdev - the sub-device that registers the callback
31 * @event - the event for which to register a callback
32 * @event_cb - the callback function
33 *
34 * @return 0 in case of success, negative value in case of error
35 */
36int dln2_register_event_cb(struct platform_device *pdev, u16 event,
37 dln2_event_cb_t event_cb);
38
39/**
40 * dln2_unregister_event_cb - unregister the callback function for an event
41 *
42 * @pdev - the sub-device that registered the callback
43 * @event - the event for which to register a callback
44 */
45void dln2_unregister_event_cb(struct platform_device *pdev, u16 event);
46
47/**
48 * dln2_transfer - issue a DLN2 command and wait for a response and the
49 * associated data
50 *
51 * @pdev - the sub-device which is issuing this transfer
52 * @cmd - the command to be sent to the device
53 * @obuf - the buffer to be sent to the device; it can be NULL if the user
54 * doesn't need to transmit data with this command
55 * @obuf_len - the size of the buffer to be sent to the device
56 * @ibuf - any data associated with the response will be copied here; it can be
57 * NULL if the user doesn't need the response data
58 * @ibuf_len - must be initialized to the input buffer size; it will be modified
59 * to indicate the actual data transferred;
60 *
61 * @return 0 for success, negative value for errors
62 */
63int dln2_transfer(struct platform_device *pdev, u16 cmd,
64 const void *obuf, unsigned obuf_len,
65 void *ibuf, unsigned *ibuf_len);
66
67/**
68 * dln2_transfer_rx - variant of @dln2_transfer() where TX buffer is not needed
69 *
70 * @pdev - the sub-device which is issuing this transfer
71 * @cmd - the command to be sent to the device
72 * @ibuf - any data associated with the response will be copied here; it can be
73 * NULL if the user doesn't need the response data
74 * @ibuf_len - must be initialized to the input buffer size; it will be modified
75 * to indicate the actual data transferred;
76 *
77 * @return 0 for success, negative value for errors
78 */
79
80static inline int dln2_transfer_rx(struct platform_device *pdev, u16 cmd,
81 void *ibuf, unsigned *ibuf_len)
82{
83 return dln2_transfer(pdev, cmd, NULL, 0, ibuf, ibuf_len);
84}
85
86/**
87 * dln2_transfer_tx - variant of @dln2_transfer() where RX buffer is not needed
88 *
89 * @pdev - the sub-device which is issuing this transfer
90 * @cmd - the command to be sent to the device
91 * @obuf - the buffer to be sent to the device; it can be NULL if the
92 * user doesn't need to transmit data with this command
93 * @obuf_len - the size of the buffer to be sent to the device
94 *
95 * @return 0 for success, negative value for errors
96 */
97static inline int dln2_transfer_tx(struct platform_device *pdev, u16 cmd,
98 const void *obuf, unsigned obuf_len)
99{
100 return dln2_transfer(pdev, cmd, obuf, obuf_len, NULL, NULL);
101}
102
103#endif
diff --git a/include/linux/mfd/max77693-private.h b/include/linux/mfd/max77693-private.h
index 582e67f34054..08dae01258b9 100644
--- a/include/linux/mfd/max77693-private.h
+++ b/include/linux/mfd/max77693-private.h
@@ -26,7 +26,6 @@
26 26
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28 28
29#define MAX77693_NUM_IRQ_MUIC_REGS 3
30#define MAX77693_REG_INVALID (0xff) 29#define MAX77693_REG_INVALID (0xff)
31 30
32/* Slave addr = 0xCC: PMIC, Charger, Flash LED */ 31/* Slave addr = 0xCC: PMIC, Charger, Flash LED */
diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
index 74346d5e7899..0c12628e91c6 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -558,6 +558,7 @@
558#define SD_SAMPLE_POINT_CTL 0xFDA7 558#define SD_SAMPLE_POINT_CTL 0xFDA7
559#define SD_PUSH_POINT_CTL 0xFDA8 559#define SD_PUSH_POINT_CTL 0xFDA8
560#define SD_CMD0 0xFDA9 560#define SD_CMD0 0xFDA9
561#define SD_CMD_START 0x40
561#define SD_CMD1 0xFDAA 562#define SD_CMD1 0xFDAA
562#define SD_CMD2 0xFDAB 563#define SD_CMD2 0xFDAB
563#define SD_CMD3 0xFDAC 564#define SD_CMD3 0xFDAC
@@ -707,6 +708,14 @@
707#define PM_CTRL1 0xFF44 708#define PM_CTRL1 0xFF44
708#define PM_CTRL2 0xFF45 709#define PM_CTRL2 0xFF45
709#define PM_CTRL3 0xFF46 710#define PM_CTRL3 0xFF46
711#define SDIO_SEND_PME_EN 0x80
712#define FORCE_RC_MODE_ON 0x40
713#define FORCE_RX50_LINK_ON 0x20
714#define D3_DELINK_MODE_EN 0x10
715#define USE_PESRTB_CTL_DELINK 0x08
716#define DELAY_PIN_WAKE 0x04
717#define RESET_PIN_WAKE 0x02
718#define PM_WAKE_EN 0x01
710#define PM_CTRL4 0xFF47 719#define PM_CTRL4 0xFF47
711 720
712/* Memory mapping */ 721/* Memory mapping */
@@ -752,6 +761,14 @@
752#define PHY_DUM_REG 0x1F 761#define PHY_DUM_REG 0x1F
753 762
754#define LCTLR 0x80 763#define LCTLR 0x80
764#define LCTLR_EXT_SYNC 0x80
765#define LCTLR_COMMON_CLOCK_CFG 0x40
766#define LCTLR_RETRAIN_LINK 0x20
767#define LCTLR_LINK_DISABLE 0x10
768#define LCTLR_RCB 0x08
769#define LCTLR_RESERVED 0x04
770#define LCTLR_ASPM_CTL_MASK 0x03
771
755#define PCR_SETTING_REG1 0x724 772#define PCR_SETTING_REG1 0x724
756#define PCR_SETTING_REG2 0x814 773#define PCR_SETTING_REG2 0x814
757#define PCR_SETTING_REG3 0x747 774#define PCR_SETTING_REG3 0x747
@@ -967,4 +984,24 @@ static inline u8 *rtsx_pci_get_cmd_data(struct rtsx_pcr *pcr)
967 return (u8 *)(pcr->host_cmds_ptr); 984 return (u8 *)(pcr->host_cmds_ptr);
968} 985}
969 986
987static inline int rtsx_pci_update_cfg_byte(struct rtsx_pcr *pcr, int addr,
988 u8 mask, u8 append)
989{
990 int err;
991 u8 val;
992
993 err = pci_read_config_byte(pcr->pci, addr, &val);
994 if (err < 0)
995 return err;
996 return pci_write_config_byte(pcr->pci, addr, (val & mask) | append);
997}
998
999static inline void rtsx_pci_write_be32(struct rtsx_pcr *pcr, u16 reg, u32 val)
1000{
1001 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg, 0xFF, val >> 24);
1002 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 1, 0xFF, val >> 16);
1003 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 2, 0xFF, val >> 8);
1004 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 3, 0xFF, val);
1005}
1006
970#endif 1007#endif
diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
index 1825edacbda7..3fdb7cfbffb3 100644
--- a/include/linux/mfd/samsung/core.h
+++ b/include/linux/mfd/samsung/core.h
@@ -28,6 +28,7 @@
28#define MIN_800_MV 800000 28#define MIN_800_MV 800000
29#define MIN_750_MV 750000 29#define MIN_750_MV 750000
30#define MIN_600_MV 600000 30#define MIN_600_MV 600000
31#define MIN_500_MV 500000
31 32
32/* Macros to represent steps for LDO/BUCK */ 33/* Macros to represent steps for LDO/BUCK */
33#define STEP_50_MV 50000 34#define STEP_50_MV 50000
@@ -41,6 +42,7 @@ enum sec_device_type {
41 S5M8767X, 42 S5M8767X,
42 S2MPA01, 43 S2MPA01,
43 S2MPS11X, 44 S2MPS11X,
45 S2MPS13X,
44 S2MPS14X, 46 S2MPS14X,
45 S2MPU02, 47 S2MPU02,
46}; 48};
diff --git a/include/linux/mfd/samsung/s2mps13.h b/include/linux/mfd/samsung/s2mps13.h
new file mode 100644
index 000000000000..ce5dda8958fe
--- /dev/null
+++ b/include/linux/mfd/samsung/s2mps13.h
@@ -0,0 +1,186 @@
1/*
2 * s2mps13.h
3 *
4 * Copyright (c) 2014 Samsung Electronics Co., Ltd
5 * http://www.samsung.com
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */
18
19#ifndef __LINUX_MFD_S2MPS13_H
20#define __LINUX_MFD_S2MPS13_H
21
22/* S2MPS13 registers */
23enum s2mps13_reg {
24 S2MPS13_REG_ID,
25 S2MPS13_REG_INT1,
26 S2MPS13_REG_INT2,
27 S2MPS13_REG_INT3,
28 S2MPS13_REG_INT1M,
29 S2MPS13_REG_INT2M,
30 S2MPS13_REG_INT3M,
31 S2MPS13_REG_ST1,
32 S2MPS13_REG_ST2,
33 S2MPS13_REG_PWRONSRC,
34 S2MPS13_REG_OFFSRC,
35 S2MPS13_REG_BU_CHG,
36 S2MPS13_REG_RTCCTRL,
37 S2MPS13_REG_CTRL1,
38 S2MPS13_REG_CTRL2,
39 S2MPS13_REG_RSVD1,
40 S2MPS13_REG_RSVD2,
41 S2MPS13_REG_RSVD3,
42 S2MPS13_REG_RSVD4,
43 S2MPS13_REG_RSVD5,
44 S2MPS13_REG_RSVD6,
45 S2MPS13_REG_CTRL3,
46 S2MPS13_REG_RSVD7,
47 S2MPS13_REG_RSVD8,
48 S2MPS13_REG_WRSTBI,
49 S2MPS13_REG_B1CTRL,
50 S2MPS13_REG_B1OUT,
51 S2MPS13_REG_B2CTRL,
52 S2MPS13_REG_B2OUT,
53 S2MPS13_REG_B3CTRL,
54 S2MPS13_REG_B3OUT,
55 S2MPS13_REG_B4CTRL,
56 S2MPS13_REG_B4OUT,
57 S2MPS13_REG_B5CTRL,
58 S2MPS13_REG_B5OUT,
59 S2MPS13_REG_B6CTRL,
60 S2MPS13_REG_B6OUT,
61 S2MPS13_REG_B7CTRL,
62 S2MPS13_REG_B7OUT,
63 S2MPS13_REG_B8CTRL,
64 S2MPS13_REG_B8OUT,
65 S2MPS13_REG_B9CTRL,
66 S2MPS13_REG_B9OUT,
67 S2MPS13_REG_B10CTRL,
68 S2MPS13_REG_B10OUT,
69 S2MPS13_REG_BB1CTRL,
70 S2MPS13_REG_BB1OUT,
71 S2MPS13_REG_BUCK_RAMP1,
72 S2MPS13_REG_BUCK_RAMP2,
73 S2MPS13_REG_LDO_DVS1,
74 S2MPS13_REG_LDO_DVS2,
75 S2MPS13_REG_LDO_DVS3,
76 S2MPS13_REG_B6OUT2,
77 S2MPS13_REG_L1CTRL,
78 S2MPS13_REG_L2CTRL,
79 S2MPS13_REG_L3CTRL,
80 S2MPS13_REG_L4CTRL,
81 S2MPS13_REG_L5CTRL,
82 S2MPS13_REG_L6CTRL,
83 S2MPS13_REG_L7CTRL,
84 S2MPS13_REG_L8CTRL,
85 S2MPS13_REG_L9CTRL,
86 S2MPS13_REG_L10CTRL,
87 S2MPS13_REG_L11CTRL,
88 S2MPS13_REG_L12CTRL,
89 S2MPS13_REG_L13CTRL,
90 S2MPS13_REG_L14CTRL,
91 S2MPS13_REG_L15CTRL,
92 S2MPS13_REG_L16CTRL,
93 S2MPS13_REG_L17CTRL,
94 S2MPS13_REG_L18CTRL,
95 S2MPS13_REG_L19CTRL,
96 S2MPS13_REG_L20CTRL,
97 S2MPS13_REG_L21CTRL,
98 S2MPS13_REG_L22CTRL,
99 S2MPS13_REG_L23CTRL,
100 S2MPS13_REG_L24CTRL,
101 S2MPS13_REG_L25CTRL,
102 S2MPS13_REG_L26CTRL,
103 S2MPS13_REG_L27CTRL,
104 S2MPS13_REG_L28CTRL,
105 S2MPS13_REG_L30CTRL,
106 S2MPS13_REG_L31CTRL,
107 S2MPS13_REG_L32CTRL,
108 S2MPS13_REG_L33CTRL,
109 S2MPS13_REG_L34CTRL,
110 S2MPS13_REG_L35CTRL,
111 S2MPS13_REG_L36CTRL,
112 S2MPS13_REG_L37CTRL,
113 S2MPS13_REG_L38CTRL,
114 S2MPS13_REG_L39CTRL,
115 S2MPS13_REG_L40CTRL,
116 S2MPS13_REG_LDODSCH1,
117 S2MPS13_REG_LDODSCH2,
118 S2MPS13_REG_LDODSCH3,
119 S2MPS13_REG_LDODSCH4,
120 S2MPS13_REG_LDODSCH5,
121};
122
123/* regulator ids */
124enum s2mps13_regulators {
125 S2MPS13_LDO1,
126 S2MPS13_LDO2,
127 S2MPS13_LDO3,
128 S2MPS13_LDO4,
129 S2MPS13_LDO5,
130 S2MPS13_LDO6,
131 S2MPS13_LDO7,
132 S2MPS13_LDO8,
133 S2MPS13_LDO9,
134 S2MPS13_LDO10,
135 S2MPS13_LDO11,
136 S2MPS13_LDO12,
137 S2MPS13_LDO13,
138 S2MPS13_LDO14,
139 S2MPS13_LDO15,
140 S2MPS13_LDO16,
141 S2MPS13_LDO17,
142 S2MPS13_LDO18,
143 S2MPS13_LDO19,
144 S2MPS13_LDO20,
145 S2MPS13_LDO21,
146 S2MPS13_LDO22,
147 S2MPS13_LDO23,
148 S2MPS13_LDO24,
149 S2MPS13_LDO25,
150 S2MPS13_LDO26,
151 S2MPS13_LDO27,
152 S2MPS13_LDO28,
153 S2MPS13_LDO29,
154 S2MPS13_LDO30,
155 S2MPS13_LDO31,
156 S2MPS13_LDO32,
157 S2MPS13_LDO33,
158 S2MPS13_LDO34,
159 S2MPS13_LDO35,
160 S2MPS13_LDO36,
161 S2MPS13_LDO37,
162 S2MPS13_LDO38,
163 S2MPS13_LDO39,
164 S2MPS13_LDO40,
165 S2MPS13_BUCK1,
166 S2MPS13_BUCK2,
167 S2MPS13_BUCK3,
168 S2MPS13_BUCK4,
169 S2MPS13_BUCK5,
170 S2MPS13_BUCK6,
171 S2MPS13_BUCK7,
172 S2MPS13_BUCK8,
173 S2MPS13_BUCK9,
174 S2MPS13_BUCK10,
175
176 S2MPS13_REGULATOR_MAX,
177};
178
179/*
180 * Default ramp delay in uv/us. Datasheet says that ramp delay can be
181 * controlled however it does not specify which register is used for that.
182 * Let's assume that default value will be set.
183 */
184#define S2MPS13_BUCK_RAMP_DELAY 12500
185
186#endif /* __LINUX_MFD_S2MPS13_H */
diff --git a/include/linux/mfd/tc3589x.h b/include/linux/mfd/tc3589x.h
index e6088c2e2092..e1c12d84c26a 100644
--- a/include/linux/mfd/tc3589x.h
+++ b/include/linux/mfd/tc3589x.h
@@ -164,13 +164,10 @@ struct tc3589x_keypad_platform_data {
164 164
165/** 165/**
166 * struct tc3589x_gpio_platform_data - TC3589x GPIO platform data 166 * struct tc3589x_gpio_platform_data - TC3589x GPIO platform data
167 * @gpio_base: first gpio number assigned to TC3589x. A maximum of
168 * %TC3589x_NR_GPIOS GPIOs will be allocated.
169 * @setup: callback for board-specific initialization 167 * @setup: callback for board-specific initialization
170 * @remove: callback for board-specific teardown 168 * @remove: callback for board-specific teardown
171 */ 169 */
172struct tc3589x_gpio_platform_data { 170struct tc3589x_gpio_platform_data {
173 int gpio_base;
174 void (*setup)(struct tc3589x *tc3589x, unsigned gpio_base); 171 void (*setup)(struct tc3589x *tc3589x, unsigned gpio_base);
175 void (*remove)(struct tc3589x *tc3589x, unsigned gpio_base); 172 void (*remove)(struct tc3589x *tc3589x, unsigned gpio_base);
176}; 173};
@@ -178,18 +175,13 @@ struct tc3589x_gpio_platform_data {
178/** 175/**
179 * struct tc3589x_platform_data - TC3589x platform data 176 * struct tc3589x_platform_data - TC3589x platform data
180 * @block: bitmask of blocks to enable (use TC3589x_BLOCK_*) 177 * @block: bitmask of blocks to enable (use TC3589x_BLOCK_*)
181 * @irq_base: base IRQ number. %TC3589x_NR_IRQS irqs will be used.
182 * @gpio: GPIO-specific platform data 178 * @gpio: GPIO-specific platform data
183 * @keypad: keypad-specific platform data 179 * @keypad: keypad-specific platform data
184 */ 180 */
185struct tc3589x_platform_data { 181struct tc3589x_platform_data {
186 unsigned int block; 182 unsigned int block;
187 int irq_base;
188 struct tc3589x_gpio_platform_data *gpio; 183 struct tc3589x_gpio_platform_data *gpio;
189 const struct tc3589x_keypad_platform_data *keypad; 184 const struct tc3589x_keypad_platform_data *keypad;
190}; 185};
191 186
192#define TC3589x_NR_GPIOS 24
193#define TC3589x_NR_IRQS TC3589x_INT_GPIO(TC3589x_NR_GPIOS)
194
195#endif 187#endif
diff --git a/include/linux/of.h b/include/linux/of.h
index 29f0adc5f3e4..364a15858746 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -922,4 +922,15 @@ static inline int of_changeset_update_property(struct of_changeset *ocs,
922/* CONFIG_OF_RESOLVE api */ 922/* CONFIG_OF_RESOLVE api */
923extern int of_resolve_phandles(struct device_node *tree); 923extern int of_resolve_phandles(struct device_node *tree);
924 924
925/**
926 * of_system_has_poweroff_source - Tells if poweroff-source is found for device_node
927 * @np: Pointer to the given device_node
928 *
929 * return true if present false otherwise
930 */
931static inline bool of_system_has_poweroff_source(const struct device_node *np)
932{
933 return of_property_read_bool(np, "poweroff-source");
934}
935
925#endif /* _LINUX_OF_H */ 936#endif /* _LINUX_OF_H */