aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-09-07 23:14:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-07 23:14:19 -0400
commit8de4651abe61c6b6a94a70a57ef163020fed05ee (patch)
treea2455b59b7df7239a5819b9cf2248e27eef483c4
parent327fff3e1391a27dcc89de6e0481689a865361c9 (diff)
parent9c31e8840836de447e1e508a6d756af419790ed6 (diff)
Merge tag 'mfd-3.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-next
Pull MFD (multi-function device) updates from Samuel Ortiz: "For the 3.12 merge window we have one new driver for the DA9063 PMIC from Dialog Semiconductor. Besides that driver we also have: - Device tree support for the s2mps11 driver - More devm_* conversion for the pm8921, max89xx, menelaus, tps65010, wl1273 and pcf50633-adc drivers. - A conversion to threaded IRQ and IRQ domain for the twl6030 driver. - A fairly big update for the rtsx driver: Better power saving support, better vendor settings handling, and a few fixes. - Support for a couple more boards (COMe-bHL6 and COMe-cTH6) for the Kontron driver. - A conversion to the dev_get_platdata() API for all MFD drivers. - A removal of non-DT (legacy) support for the twl6040 driver. - A few fixes and additions (Mic detect level) to the wm5110 register tables. - Regmap support for the davinci_voicecodec driver. - The usual bunch of minor cleanups and janitorial fixes" * tag 'mfd-3.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-next: (81 commits) mfd: ucb1x00-core: Rewrite ucb1x00_add_dev() mfd: ab8500-debugfs: Apply a check for -ENOMEM after allocating memory for event name mfd: ab8500-debugfs: Apply a check for -ENOMEM after allocating memory for sysfs mfd: timberdale: Use module_pci_driver mfd: timberdale: Remove redundant break mfd: timberdale: Staticize local variables mfd: ab8500-debugfs: Staticize local variables mfd: db8500-prcmu: Staticize clk_mgt mfd: db8500-prcmu: Use ANSI function declaration mfd: omap-usb-host: Staticize usbhs_driver_name mfd: 88pm805: Fix potential NULL pdata dereference mfd: 88pm800: Fix potential NULL pdata dereference mfd: twl6040: Use regmap for register cache mfd: davinci_voicecodec: Provide a regmap for register I/O mfd: davinci_voicecodec: Remove unused read and write functions mmc: memstick: rtsx: Modify copyright comments mmc: rtsx: Clear SD_CLK toggle enable bit if switching voltage fail mfd: mmc: rtsx: Change default tx phase mfd: pcf50633-adc: Use devm_*() functions mfd: rtsx: Copyright modifications ...
-rw-r--r--Documentation/devicetree/bindings/mfd/palmas.txt2
-rw-r--r--Documentation/devicetree/bindings/mfd/s2mps11.txt109
-rw-r--r--Documentation/devicetree/bindings/regulator/palmas-pmic.txt5
-rw-r--r--drivers/memstick/host/rtsx_pci_ms.c3
-rw-r--r--drivers/mfd/88pm800.c12
-rw-r--r--drivers/mfd/88pm805.c4
-rw-r--r--drivers/mfd/88pm860x-core.c2
-rw-r--r--drivers/mfd/Kconfig14
-rw-r--r--drivers/mfd/Makefile3
-rw-r--r--drivers/mfd/aat2870-core.c2
-rw-r--r--drivers/mfd/ab3100-core.c2
-rw-r--r--drivers/mfd/ab8500-debugfs.c14
-rw-r--r--drivers/mfd/ab8500-gpadc.c4
-rw-r--r--drivers/mfd/adp5520.c2
-rw-r--r--drivers/mfd/arizona-core.c2
-rw-r--r--drivers/mfd/as3711.c2
-rw-r--r--drivers/mfd/asic3.c2
-rw-r--r--drivers/mfd/da903x.c2
-rw-r--r--drivers/mfd/da9052-core.c2
-rw-r--r--drivers/mfd/da9055-core.c7
-rw-r--r--drivers/mfd/da9055-i2c.c2
-rw-r--r--drivers/mfd/da9063-core.c185
-rw-r--r--drivers/mfd/da9063-i2c.c182
-rw-r--r--drivers/mfd/da9063-irq.c193
-rw-r--r--drivers/mfd/davinci_voicecodec.c23
-rw-r--r--drivers/mfd/db8500-prcmu.c4
-rw-r--r--drivers/mfd/dm355evm_msp.c4
-rw-r--r--drivers/mfd/ezx-pcap.c6
-rw-r--r--drivers/mfd/htc-egpio.c2
-rw-r--r--drivers/mfd/htc-i2cpld.c10
-rw-r--r--drivers/mfd/htc-pasic3.c2
-rw-r--r--drivers/mfd/intel_msic.c4
-rw-r--r--drivers/mfd/kempld-core.c30
-rw-r--r--drivers/mfd/lm3533-core.c8
-rw-r--r--drivers/mfd/lp8788.c2
-rw-r--r--drivers/mfd/lpc_ich.c2
-rw-r--r--drivers/mfd/max77686.c2
-rw-r--r--drivers/mfd/max77693.c2
-rw-r--r--drivers/mfd/max8925-i2c.c2
-rw-r--r--drivers/mfd/max8997.c18
-rw-r--r--drivers/mfd/max8998.c7
-rw-r--r--drivers/mfd/mcp-sa11x0.c2
-rw-r--r--drivers/mfd/menelaus.c22
-rw-r--r--drivers/mfd/mfd-core.c2
-rw-r--r--drivers/mfd/omap-usb-host.c6
-rw-r--r--drivers/mfd/palmas.c130
-rw-r--r--drivers/mfd/pcf50633-adc.c3
-rw-r--r--drivers/mfd/pcf50633-core.c2
-rw-r--r--drivers/mfd/pm8921-core.c14
-rw-r--r--drivers/mfd/rc5t583.c2
-rw-r--r--drivers/mfd/rtl8411.c94
-rw-r--r--drivers/mfd/rts5209.c63
-rw-r--r--drivers/mfd/rts5227.c115
-rw-r--r--drivers/mfd/rts5229.c53
-rw-r--r--drivers/mfd/rts5249.c110
-rw-r--r--drivers/mfd/rtsx_pcr.c76
-rw-r--r--drivers/mfd/rtsx_pcr.h32
-rw-r--r--drivers/mfd/sec-core.c40
-rw-r--r--drivers/mfd/si476x-i2c.c2
-rw-r--r--drivers/mfd/sm501.c6
-rw-r--r--drivers/mfd/sta2x11-mfd.c4
-rw-r--r--drivers/mfd/stmpe.c3
-rw-r--r--drivers/mfd/syscon.c8
-rw-r--r--drivers/mfd/t7l66xb.c8
-rw-r--r--drivers/mfd/tc3589x.c2
-rw-r--r--drivers/mfd/tc6387xb.c6
-rw-r--r--drivers/mfd/tc6393xb.c8
-rw-r--r--drivers/mfd/ti-ssp.c2
-rw-r--r--drivers/mfd/ti_am335x_tscadc.c32
-rw-r--r--drivers/mfd/timberdale.c34
-rw-r--r--drivers/mfd/tps6105x.c2
-rw-r--r--drivers/mfd/tps65010.c24
-rw-r--r--drivers/mfd/tps65090.c2
-rw-r--r--drivers/mfd/tps6586x.c2
-rw-r--r--drivers/mfd/tps65912-core.c2
-rw-r--r--drivers/mfd/tps80031.c2
-rw-r--r--drivers/mfd/twl-core.c2
-rw-r--r--drivers/mfd/twl4030-audio.c2
-rw-r--r--drivers/mfd/twl4030-madc.c2
-rw-r--r--drivers/mfd/twl4030-power.c8
-rw-r--r--drivers/mfd/twl6030-irq.c377
-rw-r--r--drivers/mfd/twl6040.c133
-rw-r--r--drivers/mfd/ucb1400_core.c2
-rw-r--r--drivers/mfd/ucb1x00-core.c34
-rw-r--r--drivers/mfd/wl1273-core.c8
-rw-r--r--drivers/mfd/wm5110-tables.c18
-rw-r--r--drivers/mfd/wm831x-core.c2
-rw-r--r--drivers/mfd/wm831x-irq.c2
-rw-r--r--drivers/mfd/wm831x-spi.c1
-rw-r--r--drivers/mfd/wm8350-i2c.c3
-rw-r--r--drivers/mfd/wm8400-core.c2
-rw-r--r--drivers/mfd/wm8994-core.c44
-rw-r--r--drivers/mfd/wm8994-irq.c2
-rw-r--r--drivers/mmc/host/rtsx_pci_sdmmc.c70
-rw-r--r--include/linux/mfd/da9063/core.h93
-rw-r--r--include/linux/mfd/da9063/pdata.h111
-rw-r--r--include/linux/mfd/da9063/registers.h1028
-rw-r--r--include/linux/mfd/davinci_voicecodec.h3
-rw-r--r--include/linux/mfd/mcp.h2
-rw-r--r--include/linux/mfd/palmas.h50
-rw-r--r--include/linux/mfd/rtsx_common.h3
-rw-r--r--include/linux/mfd/rtsx_pci.h66
-rw-r--r--include/linux/mfd/samsung/s2mps11.h6
-rw-r--r--include/linux/mfd/ti_am335x_tscadc.h1
-rw-r--r--include/linux/mfd/twl6040.h2
-rw-r--r--include/linux/mfd/ucb1x00.h1
106 files changed, 3222 insertions, 656 deletions
diff --git a/Documentation/devicetree/bindings/mfd/palmas.txt b/Documentation/devicetree/bindings/mfd/palmas.txt
index 892537d1a48f..e5f0f8303461 100644
--- a/Documentation/devicetree/bindings/mfd/palmas.txt
+++ b/Documentation/devicetree/bindings/mfd/palmas.txt
@@ -5,6 +5,7 @@ twl6035 (palmas)
5twl6037 (palmas) 5twl6037 (palmas)
6tps65913 (palmas) 6tps65913 (palmas)
7tps65914 (palmas) 7tps65914 (palmas)
8tps659038
8 9
9Required properties: 10Required properties:
10- compatible : Should be from the list 11- compatible : Should be from the list
@@ -14,6 +15,7 @@ Required properties:
14 ti,tps65913 15 ti,tps65913
15 ti,tps65914 16 ti,tps65914
16 ti,tps80036 17 ti,tps80036
18 ti,tps659038
17and also the generic series names 19and also the generic series names
18 ti,palmas 20 ti,palmas
19- interrupt-controller : palmas has its own internal IRQs 21- interrupt-controller : palmas has its own internal IRQs
diff --git a/Documentation/devicetree/bindings/mfd/s2mps11.txt b/Documentation/devicetree/bindings/mfd/s2mps11.txt
new file mode 100644
index 000000000000..c9332c626021
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/s2mps11.txt
@@ -0,0 +1,109 @@
1
2* Samsung S2MPS11 Voltage and Current Regulator
3
4The Samsung S2MP211 is a multi-function device which includes voltage and
5current regulators, RTC, charger controller and other sub-blocks. It is
6interfaced to the host controller using a I2C interface. Each sub-block is
7addressed by the host system using different I2C slave address.
8
9Required properties:
10- compatible: Should be "samsung,s2mps11-pmic".
11- reg: Specifies the I2C slave address of the pmic block. It should be 0x66.
12
13Optional properties:
14- interrupt-parent: Specifies the phandle of the interrupt controller to which
15 the interrupts from s2mps11 are delivered to.
16- interrupts: Interrupt specifiers for interrupt sources.
17
18Optional nodes:
19- clocks: s2mps11 provides three(AP/CP/BT) buffered 32.768 KHz outputs, so to
20 register these as clocks with common clock framework instantiate a sub-node
21 named "clocks". It uses the common clock binding documented in :
22 [Documentation/devicetree/bindings/clock/clock-bindings.txt]
23 - #clock-cells: should be 1.
24
25 - The following is the list of clocks generated by the controller. Each clock
26 is assigned an identifier and client nodes use this identifier to specify
27 the clock which they consume.
28 Clock ID
29 ----------------------
30 32KhzAP 0
31 32KhzCP 1
32 32KhzBT 2
33
34- regulators: The regulators of s2mps11 that have to be instantiated should be
35included in a sub-node named 'regulators'. Regulator nodes included in this
36sub-node should be of the format as listed below.
37
38 regulator_name {
39 [standard regulator constraints....];
40 };
41
42 regulator-ramp-delay for BUCKs = [6250/12500/25000(default)/50000] uV/us
43
44 BUCK[2/3/4/6] supports disabling ramp delay on hardware, so explictly
45 regulator-ramp-delay = <0> can be used for them to disable ramp delay.
46 In absence of regulator-ramp-delay property, default ramp delay will be used.
47
48NOTE: Some BUCKs share the ramp rate setting i.e. same ramp value will be set
49for a particular group of BUCKs. So provide same regulator-ramp-delay<value>.
50Grouping of BUCKs sharing ramp rate setting is as follow : BUCK[1, 6],
51BUCK[3, 4], and BUCK[7, 8, 10]
52
53The regulator constraints inside the regulator nodes use the standard regulator
54bindings which are documented elsewhere.
55
56The following are the names of the regulators that the s2mps11 pmic block
57supports. Note: The 'n' in LDOn and BUCKn represents the LDO or BUCK number
58as per the datasheet of s2mps11.
59
60 - LDOn
61 - valid values for n are 1 to 28
62 - Example: LDO0, LD01, LDO28
63 - BUCKn
64 - valid values for n are 1 to 9.
65 - Example: BUCK1, BUCK2, BUCK9
66
67Example:
68
69 s2mps11_pmic@66 {
70 compatible = "samsung,s2mps11-pmic";
71 reg = <0x66>;
72
73 s2m_osc: clocks{
74 #clock-cells = 1;
75 clock-output-names = "xx", "yy", "zz";
76 };
77
78 regulators {
79 ldo1_reg: LDO1 {
80 regulator-name = "VDD_ABB_3.3V";
81 regulator-min-microvolt = <3300000>;
82 regulator-max-microvolt = <3300000>;
83 };
84
85 ldo2_reg: LDO2 {
86 regulator-name = "VDD_ALIVE_1.1V";
87 regulator-min-microvolt = <1100000>;
88 regulator-max-microvolt = <1100000>;
89 regulator-always-on;
90 };
91
92 buck1_reg: BUCK1 {
93 regulator-name = "vdd_mif";
94 regulator-min-microvolt = <950000>;
95 regulator-max-microvolt = <1350000>;
96 regulator-always-on;
97 regulator-boot-on;
98 };
99
100 buck2_reg: BUCK2 {
101 regulator-name = "vdd_arm";
102 regulator-min-microvolt = <950000>;
103 regulator-max-microvolt = <1350000>;
104 regulator-always-on;
105 regulator-boot-on;
106 regulator-ramp-delay = <50000>;
107 };
108 };
109 };
diff --git a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt
index a22e4c70db5c..875639ae0606 100644
--- a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt
+++ b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt
@@ -36,6 +36,9 @@ Optional nodes:
36 ti,smps-range - OTP has the wrong range set for the hardware so override 36 ti,smps-range - OTP has the wrong range set for the hardware so override
37 0 - low range, 1 - high range. 37 0 - low range, 1 - high range.
38 38
39- ti,system-power-controller: Telling whether or not this pmic is controlling
40 the system power.
41
39Example: 42Example:
40 43
41#include <dt-bindings/interrupt-controller/irq.h> 44#include <dt-bindings/interrupt-controller/irq.h>
@@ -48,6 +51,8 @@ pmic {
48 51
49 ti,ldo6-vibrator; 52 ti,ldo6-vibrator;
50 53
54 ti,system-power-controller;
55
51 regulators { 56 regulators {
52 smps12_reg : smps12 { 57 smps12_reg : smps12 {
53 regulator-name = "smps12"; 58 regulator-name = "smps12";
diff --git a/drivers/memstick/host/rtsx_pci_ms.c b/drivers/memstick/host/rtsx_pci_ms.c
index 64a779c58a74..cf8bd727dfc7 100644
--- a/drivers/memstick/host/rtsx_pci_ms.c
+++ b/drivers/memstick/host/rtsx_pci_ms.c
@@ -1,6 +1,6 @@
1/* Realtek PCI-Express Memstick Card Interface driver 1/* Realtek PCI-Express Memstick Card Interface driver
2 * 2 *
3 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. 3 * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License as published by the
@@ -17,7 +17,6 @@
17 * 17 *
18 * Author: 18 * Author:
19 * Wei WANG <wei_wang@realsil.com.cn> 19 * Wei WANG <wei_wang@realsil.com.cn>
20 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
21 */ 20 */
22 21
23#include <linux/module.h> 22#include <linux/module.h>
diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c
index 6c954835d61e..a65447d65605 100644
--- a/drivers/mfd/88pm800.c
+++ b/drivers/mfd/88pm800.c
@@ -333,9 +333,11 @@ static int device_rtc_init(struct pm80x_chip *chip,
333{ 333{
334 int ret; 334 int ret;
335 335
336 rtc_devs[0].platform_data = pdata->rtc; 336 if (pdata) {
337 rtc_devs[0].pdata_size = 337 rtc_devs[0].platform_data = pdata->rtc;
338 pdata->rtc ? sizeof(struct pm80x_rtc_pdata) : 0; 338 rtc_devs[0].pdata_size =
339 pdata->rtc ? sizeof(struct pm80x_rtc_pdata) : 0;
340 }
339 ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0], 341 ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
340 ARRAY_SIZE(rtc_devs), NULL, 0, NULL); 342 ARRAY_SIZE(rtc_devs), NULL, 0, NULL);
341 if (ret) { 343 if (ret) {
@@ -541,7 +543,7 @@ static int pm800_probe(struct i2c_client *client,
541{ 543{
542 int ret = 0; 544 int ret = 0;
543 struct pm80x_chip *chip; 545 struct pm80x_chip *chip;
544 struct pm80x_platform_data *pdata = client->dev.platform_data; 546 struct pm80x_platform_data *pdata = dev_get_platdata(&client->dev);
545 struct pm80x_subchip *subchip; 547 struct pm80x_subchip *subchip;
546 548
547 ret = pm80x_init(client); 549 ret = pm80x_init(client);
@@ -578,7 +580,7 @@ static int pm800_probe(struct i2c_client *client,
578 goto err_device_init; 580 goto err_device_init;
579 } 581 }
580 582
581 if (pdata->plat_config) 583 if (pdata && pdata->plat_config)
582 pdata->plat_config(chip, pdata); 584 pdata->plat_config(chip, pdata);
583 585
584 return 0; 586 return 0;
diff --git a/drivers/mfd/88pm805.c b/drivers/mfd/88pm805.c
index 521602231c7b..8a5b6ffb5afb 100644
--- a/drivers/mfd/88pm805.c
+++ b/drivers/mfd/88pm805.c
@@ -227,7 +227,7 @@ static int pm805_probe(struct i2c_client *client,
227{ 227{
228 int ret = 0; 228 int ret = 0;
229 struct pm80x_chip *chip; 229 struct pm80x_chip *chip;
230 struct pm80x_platform_data *pdata = client->dev.platform_data; 230 struct pm80x_platform_data *pdata = dev_get_platdata(&client->dev);
231 231
232 ret = pm80x_init(client); 232 ret = pm80x_init(client);
233 if (ret) { 233 if (ret) {
@@ -243,7 +243,7 @@ static int pm805_probe(struct i2c_client *client,
243 goto err_805_init; 243 goto err_805_init;
244 } 244 }
245 245
246 if (pdata->plat_config) 246 if (pdata && pdata->plat_config)
247 pdata->plat_config(chip, pdata); 247 pdata->plat_config(chip, pdata);
248 248
249err_805_init: 249err_805_init:
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
index eeb481d426b5..7ebe9ef1eba6 100644
--- a/drivers/mfd/88pm860x-core.c
+++ b/drivers/mfd/88pm860x-core.c
@@ -1130,7 +1130,7 @@ static int pm860x_dt_init(struct device_node *np,
1130static int pm860x_probe(struct i2c_client *client, 1130static int pm860x_probe(struct i2c_client *client,
1131 const struct i2c_device_id *id) 1131 const struct i2c_device_id *id)
1132{ 1132{
1133 struct pm860x_platform_data *pdata = client->dev.platform_data; 1133 struct pm860x_platform_data *pdata = dev_get_platdata(&client->dev);
1134 struct device_node *node = client->dev.of_node; 1134 struct device_node *node = client->dev.of_node;
1135 struct pm860x_chip *chip; 1135 struct pm860x_chip *chip;
1136 int ret; 1136 int ret;
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index aecd6ddcbbbf..e0e46f50f95d 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -139,6 +139,18 @@ config MFD_DA9055
139 This driver can be built as a module. If built as a module it will be 139 This driver can be built as a module. If built as a module it will be
140 called "da9055" 140 called "da9055"
141 141
142config MFD_DA9063
143 bool "Dialog Semiconductor DA9063 PMIC Support"
144 select MFD_CORE
145 select REGMAP_I2C
146 select REGMAP_IRQ
147 depends on I2C=y && GENERIC_HARDIRQS
148 help
149 Say yes here for support for the Dialog Semiconductor DA9063 PMIC.
150 This includes the I2C driver and core APIs.
151 Additional drivers must be enabled in order to use the functionality
152 of the device.
153
142config MFD_MC13783 154config MFD_MC13783
143 tristate 155 tristate
144 156
@@ -1070,7 +1082,7 @@ config MFD_WM5110
1070 Support for Wolfson Microelectronics WM5110 low power audio SoC 1082 Support for Wolfson Microelectronics WM5110 low power audio SoC
1071 1083
1072config MFD_WM8997 1084config MFD_WM8997
1073 bool "Support Wolfson Microelectronics WM8997" 1085 bool "Wolfson Microelectronics WM8997"
1074 depends on MFD_ARIZONA 1086 depends on MFD_ARIZONA
1075 help 1087 help
1076 Support for Wolfson Microelectronics WM8997 low power audio SoC 1088 Support for Wolfson Microelectronics WM8997 low power audio SoC
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 3c90051ffa5a..15b905c6553c 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -107,6 +107,9 @@ obj-$(CONFIG_MFD_LP8788) += lp8788.o lp8788-irq.o
107da9055-objs := da9055-core.o da9055-i2c.o 107da9055-objs := da9055-core.o da9055-i2c.o
108obj-$(CONFIG_MFD_DA9055) += da9055.o 108obj-$(CONFIG_MFD_DA9055) += da9055.o
109 109
110da9063-objs := da9063-core.o da9063-irq.o da9063-i2c.o
111obj-$(CONFIG_MFD_DA9063) += da9063.o
112
110obj-$(CONFIG_MFD_MAX77686) += max77686.o max77686-irq.o 113obj-$(CONFIG_MFD_MAX77686) += max77686.o max77686-irq.o
111obj-$(CONFIG_MFD_MAX77693) += max77693.o max77693-irq.o 114obj-$(CONFIG_MFD_MAX77693) += max77693.o max77693-irq.o
112obj-$(CONFIG_MFD_MAX8907) += max8907.o 115obj-$(CONFIG_MFD_MAX8907) += max8907.o
diff --git a/drivers/mfd/aat2870-core.c b/drivers/mfd/aat2870-core.c
index d4f594517521..6f68472e0ca6 100644
--- a/drivers/mfd/aat2870-core.c
+++ b/drivers/mfd/aat2870-core.c
@@ -363,7 +363,7 @@ static inline void aat2870_uninit_debugfs(struct aat2870_data *aat2870)
363static int aat2870_i2c_probe(struct i2c_client *client, 363static int aat2870_i2c_probe(struct i2c_client *client,
364 const struct i2c_device_id *id) 364 const struct i2c_device_id *id)
365{ 365{
366 struct aat2870_platform_data *pdata = client->dev.platform_data; 366 struct aat2870_platform_data *pdata = dev_get_platdata(&client->dev);
367 struct aat2870_data *aat2870; 367 struct aat2870_data *aat2870;
368 int i, j; 368 int i, j;
369 int ret = 0; 369 int ret = 0;
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c
index ddc669d19530..b348ae520629 100644
--- a/drivers/mfd/ab3100-core.c
+++ b/drivers/mfd/ab3100-core.c
@@ -854,7 +854,7 @@ static int ab3100_probe(struct i2c_client *client,
854{ 854{
855 struct ab3100 *ab3100; 855 struct ab3100 *ab3100;
856 struct ab3100_platform_data *ab3100_plf_data = 856 struct ab3100_platform_data *ab3100_plf_data =
857 client->dev.platform_data; 857 dev_get_platdata(&client->dev);
858 int err; 858 int err;
859 int i; 859 int i;
860 860
diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index 7d1f1b08fc4b..e33e385af0a2 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -159,7 +159,7 @@ static struct hwreg_cfg hwreg_cfg = {
159 159
160static struct ab8500_prcmu_ranges *debug_ranges; 160static struct ab8500_prcmu_ranges *debug_ranges;
161 161
162struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = { 162static struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = {
163 [0x0] = { 163 [0x0] = {
164 .num_ranges = 0, 164 .num_ranges = 0,
165 .range = NULL, 165 .range = NULL,
@@ -488,7 +488,7 @@ struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = {
488 }, 488 },
489}; 489};
490 490
491struct ab8500_prcmu_ranges ab8505_debug_ranges[AB8500_NUM_BANKS] = { 491static struct ab8500_prcmu_ranges ab8505_debug_ranges[AB8500_NUM_BANKS] = {
492 [0x0] = { 492 [0x0] = {
493 .num_ranges = 0, 493 .num_ranges = 0,
494 .range = NULL, 494 .range = NULL,
@@ -847,7 +847,7 @@ struct ab8500_prcmu_ranges ab8505_debug_ranges[AB8500_NUM_BANKS] = {
847 }, 847 },
848}; 848};
849 849
850struct ab8500_prcmu_ranges ab8540_debug_ranges[AB8500_NUM_BANKS] = { 850static struct ab8500_prcmu_ranges ab8540_debug_ranges[AB8500_NUM_BANKS] = {
851 [AB8500_M_FSM_RANK] = { 851 [AB8500_M_FSM_RANK] = {
852 .num_ranges = 1, 852 .num_ranges = 1,
853 .range = (struct ab8500_reg_range[]) { 853 .range = (struct ab8500_reg_range[]) {
@@ -1377,7 +1377,7 @@ void ab8500_dump_all_banks(struct device *dev)
1377 1377
1378/* Space for 500 registers. */ 1378/* Space for 500 registers. */
1379#define DUMP_MAX_REGS 700 1379#define DUMP_MAX_REGS 700
1380struct ab8500_register_dump 1380static struct ab8500_register_dump
1381{ 1381{
1382 u8 bank; 1382 u8 bank;
1383 u8 reg; 1383 u8 reg;
@@ -2800,7 +2800,13 @@ static ssize_t ab8500_subscribe_write(struct file *file,
2800 */ 2800 */
2801 dev_attr[irq_index] = kmalloc(sizeof(struct device_attribute), 2801 dev_attr[irq_index] = kmalloc(sizeof(struct device_attribute),
2802 GFP_KERNEL); 2802 GFP_KERNEL);
2803 if (!dev_attr[irq_index])
2804 return -ENOMEM;
2805
2803 event_name[irq_index] = kmalloc(count, GFP_KERNEL); 2806 event_name[irq_index] = kmalloc(count, GFP_KERNEL);
2807 if (!event_name[irq_index])
2808 return -ENOMEM;
2809
2804 sprintf(event_name[irq_index], "%lu", user_val); 2810 sprintf(event_name[irq_index], "%lu", user_val);
2805 dev_attr[irq_index]->show = show_irq; 2811 dev_attr[irq_index]->show = show_irq;
2806 dev_attr[irq_index]->store = NULL; 2812 dev_attr[irq_index]->store = NULL;
diff --git a/drivers/mfd/ab8500-gpadc.c b/drivers/mfd/ab8500-gpadc.c
index 7623e9123828..36000f920981 100644
--- a/drivers/mfd/ab8500-gpadc.c
+++ b/drivers/mfd/ab8500-gpadc.c
@@ -867,6 +867,7 @@ static void ab8500_gpadc_read_calibration_data(struct ab8500_gpadc *gpadc)
867 gpadc->cal_data[ADC_INPUT_VBAT].offset); 867 gpadc->cal_data[ADC_INPUT_VBAT].offset);
868} 868}
869 869
870#ifdef CONFIG_PM_RUNTIME
870static int ab8500_gpadc_runtime_suspend(struct device *dev) 871static int ab8500_gpadc_runtime_suspend(struct device *dev)
871{ 872{
872 struct ab8500_gpadc *gpadc = dev_get_drvdata(dev); 873 struct ab8500_gpadc *gpadc = dev_get_drvdata(dev);
@@ -885,7 +886,9 @@ static int ab8500_gpadc_runtime_resume(struct device *dev)
885 dev_err(dev, "Failed to enable vtvout LDO: %d\n", ret); 886 dev_err(dev, "Failed to enable vtvout LDO: %d\n", ret);
886 return ret; 887 return ret;
887} 888}
889#endif
888 890
891#ifdef CONFIG_PM_SLEEP
889static int ab8500_gpadc_suspend(struct device *dev) 892static int ab8500_gpadc_suspend(struct device *dev)
890{ 893{
891 struct ab8500_gpadc *gpadc = dev_get_drvdata(dev); 894 struct ab8500_gpadc *gpadc = dev_get_drvdata(dev);
@@ -913,6 +916,7 @@ static int ab8500_gpadc_resume(struct device *dev)
913 mutex_unlock(&gpadc->ab8500_gpadc_lock); 916 mutex_unlock(&gpadc->ab8500_gpadc_lock);
914 return ret; 917 return ret;
915} 918}
919#endif
916 920
917static int ab8500_gpadc_probe(struct platform_device *pdev) 921static int ab8500_gpadc_probe(struct platform_device *pdev)
918{ 922{
diff --git a/drivers/mfd/adp5520.c b/drivers/mfd/adp5520.c
index 28346ad0b4a6..62501553d63c 100644
--- a/drivers/mfd/adp5520.c
+++ b/drivers/mfd/adp5520.c
@@ -207,7 +207,7 @@ static int adp5520_remove_subdevs(struct adp5520_chip *chip)
207static int adp5520_probe(struct i2c_client *client, 207static int adp5520_probe(struct i2c_client *client,
208 const struct i2c_device_id *id) 208 const struct i2c_device_id *id)
209{ 209{
210 struct adp5520_platform_data *pdata = client->dev.platform_data; 210 struct adp5520_platform_data *pdata = dev_get_platdata(&client->dev);
211 struct platform_device *pdev; 211 struct platform_device *pdev;
212 struct adp5520_chip *chip; 212 struct adp5520_chip *chip;
213 int ret; 213 int ret;
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 89a115301a0c..5ac3aa48473b 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -438,9 +438,9 @@ static int arizona_runtime_suspend(struct device *dev)
438 } 438 }
439 } 439 }
440 440
441 regulator_disable(arizona->dcvdd);
442 regcache_cache_only(arizona->regmap, true); 441 regcache_cache_only(arizona->regmap, true);
443 regcache_mark_dirty(arizona->regmap); 442 regcache_mark_dirty(arizona->regmap);
443 regulator_disable(arizona->dcvdd);
444 444
445 return 0; 445 return 0;
446} 446}
diff --git a/drivers/mfd/as3711.c b/drivers/mfd/as3711.c
index 01e414162702..abd3ab7c0908 100644
--- a/drivers/mfd/as3711.c
+++ b/drivers/mfd/as3711.c
@@ -129,7 +129,7 @@ static int as3711_i2c_probe(struct i2c_client *client,
129 int ret; 129 int ret;
130 130
131 if (!client->dev.of_node) { 131 if (!client->dev.of_node) {
132 pdata = client->dev.platform_data; 132 pdata = dev_get_platdata(&client->dev);
133 if (!pdata) 133 if (!pdata)
134 dev_dbg(&client->dev, "Platform data not found\n"); 134 dev_dbg(&client->dev, "Platform data not found\n");
135 } else { 135 } else {
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
index 9532f749412f..fa22154c84e4 100644
--- a/drivers/mfd/asic3.c
+++ b/drivers/mfd/asic3.c
@@ -952,7 +952,7 @@ static void asic3_mfd_remove(struct platform_device *pdev)
952/* Core */ 952/* Core */
953static int __init asic3_probe(struct platform_device *pdev) 953static int __init asic3_probe(struct platform_device *pdev)
954{ 954{
955 struct asic3_platform_data *pdata = pdev->dev.platform_data; 955 struct asic3_platform_data *pdata = dev_get_platdata(&pdev->dev);
956 struct asic3 *asic; 956 struct asic3 *asic;
957 struct resource *mem; 957 struct resource *mem;
958 unsigned long clksel; 958 unsigned long clksel;
diff --git a/drivers/mfd/da903x.c b/drivers/mfd/da903x.c
index f1a316e0d6a6..e0a2e0ee603b 100644
--- a/drivers/mfd/da903x.c
+++ b/drivers/mfd/da903x.c
@@ -494,7 +494,7 @@ failed:
494static int da903x_probe(struct i2c_client *client, 494static int da903x_probe(struct i2c_client *client,
495 const struct i2c_device_id *id) 495 const struct i2c_device_id *id)
496{ 496{
497 struct da903x_platform_data *pdata = client->dev.platform_data; 497 struct da903x_platform_data *pdata = dev_get_platdata(&client->dev);
498 struct da903x_chip *chip; 498 struct da903x_chip *chip;
499 unsigned int tmp; 499 unsigned int tmp;
500 int ret; 500 int ret;
diff --git a/drivers/mfd/da9052-core.c b/drivers/mfd/da9052-core.c
index a3c9613f9166..ea28a33576e4 100644
--- a/drivers/mfd/da9052-core.c
+++ b/drivers/mfd/da9052-core.c
@@ -534,7 +534,7 @@ EXPORT_SYMBOL_GPL(da9052_regmap_config);
534 534
535int da9052_device_init(struct da9052 *da9052, u8 chip_id) 535int da9052_device_init(struct da9052 *da9052, u8 chip_id)
536{ 536{
537 struct da9052_pdata *pdata = da9052->dev->platform_data; 537 struct da9052_pdata *pdata = dev_get_platdata(da9052->dev);
538 int ret; 538 int ret;
539 539
540 mutex_init(&da9052->auxadc_lock); 540 mutex_init(&da9052->auxadc_lock);
diff --git a/drivers/mfd/da9055-core.c b/drivers/mfd/da9055-core.c
index 49cb23d37469..d3670cd3c3c6 100644
--- a/drivers/mfd/da9055-core.c
+++ b/drivers/mfd/da9055-core.c
@@ -379,8 +379,9 @@ static struct regmap_irq_chip da9055_regmap_irq_chip = {
379 379
380int da9055_device_init(struct da9055 *da9055) 380int da9055_device_init(struct da9055 *da9055)
381{ 381{
382 struct da9055_pdata *pdata = da9055->dev->platform_data; 382 struct da9055_pdata *pdata = dev_get_platdata(da9055->dev);
383 int ret; 383 int ret;
384 uint8_t clear_events[3] = {0xFF, 0xFF, 0xFF};
384 385
385 if (pdata && pdata->init != NULL) 386 if (pdata && pdata->init != NULL)
386 pdata->init(da9055); 387 pdata->init(da9055);
@@ -390,6 +391,10 @@ int da9055_device_init(struct da9055 *da9055)
390 else 391 else
391 da9055->irq_base = pdata->irq_base; 392 da9055->irq_base = pdata->irq_base;
392 393
394 ret = da9055_group_write(da9055, DA9055_REG_EVENT_A, 3, clear_events);
395 if (ret < 0)
396 return ret;
397
393 ret = regmap_add_irq_chip(da9055->regmap, da9055->chip_irq, 398 ret = regmap_add_irq_chip(da9055->regmap, da9055->chip_irq,
394 IRQF_TRIGGER_LOW | IRQF_ONESHOT, 399 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
395 da9055->irq_base, &da9055_regmap_irq_chip, 400 da9055->irq_base, &da9055_regmap_irq_chip,
diff --git a/drivers/mfd/da9055-i2c.c b/drivers/mfd/da9055-i2c.c
index 607387ffe8ca..13af7e50021e 100644
--- a/drivers/mfd/da9055-i2c.c
+++ b/drivers/mfd/da9055-i2c.c
@@ -54,7 +54,7 @@ static int da9055_i2c_remove(struct i2c_client *i2c)
54} 54}
55 55
56static struct i2c_device_id da9055_i2c_id[] = { 56static struct i2c_device_id da9055_i2c_id[] = {
57 {"da9055-pmic", 0}, 57 {"da9055", 0},
58 { } 58 { }
59}; 59};
60 60
diff --git a/drivers/mfd/da9063-core.c b/drivers/mfd/da9063-core.c
new file mode 100644
index 000000000000..c9cf8d988406
--- /dev/null
+++ b/drivers/mfd/da9063-core.c
@@ -0,0 +1,185 @@
1/*
2 * da9063-core.c: Device access for Dialog DA9063 modules
3 *
4 * Copyright 2012 Dialog Semiconductors Ltd.
5 * Copyright 2013 Philipp Zabel, Pengutronix
6 *
7 * Author: Krystian Garbaciak <krystian.garbaciak@diasemi.com>,
8 * Michal Hajduk <michal.hajduk@diasemi.com>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/slab.h>
21#include <linux/device.h>
22#include <linux/delay.h>
23#include <linux/interrupt.h>
24#include <linux/mutex.h>
25#include <linux/mfd/core.h>
26#include <linux/regmap.h>
27
28#include <linux/mfd/da9063/core.h>
29#include <linux/mfd/da9063/pdata.h>
30#include <linux/mfd/da9063/registers.h>
31
32#include <linux/proc_fs.h>
33#include <linux/kthread.h>
34#include <linux/uaccess.h>
35
36
37static struct resource da9063_regulators_resources[] = {
38 {
39 .name = "LDO_LIM",
40 .start = DA9063_IRQ_LDO_LIM,
41 .end = DA9063_IRQ_LDO_LIM,
42 .flags = IORESOURCE_IRQ,
43 },
44};
45
46static struct resource da9063_rtc_resources[] = {
47 {
48 .name = "ALARM",
49 .start = DA9063_IRQ_ALARM,
50 .end = DA9063_IRQ_ALARM,
51 .flags = IORESOURCE_IRQ,
52 },
53 {
54 .name = "TICK",
55 .start = DA9063_IRQ_TICK,
56 .end = DA9063_IRQ_TICK,
57 .flags = IORESOURCE_IRQ,
58 }
59};
60
61static struct resource da9063_onkey_resources[] = {
62 {
63 .start = DA9063_IRQ_ONKEY,
64 .end = DA9063_IRQ_ONKEY,
65 .flags = IORESOURCE_IRQ,
66 },
67};
68
69static struct resource da9063_hwmon_resources[] = {
70 {
71 .start = DA9063_IRQ_ADC_RDY,
72 .end = DA9063_IRQ_ADC_RDY,
73 .flags = IORESOURCE_IRQ,
74 },
75};
76
77
78static struct mfd_cell da9063_devs[] = {
79 {
80 .name = DA9063_DRVNAME_REGULATORS,
81 .num_resources = ARRAY_SIZE(da9063_regulators_resources),
82 .resources = da9063_regulators_resources,
83 },
84 {
85 .name = DA9063_DRVNAME_LEDS,
86 },
87 {
88 .name = DA9063_DRVNAME_WATCHDOG,
89 },
90 {
91 .name = DA9063_DRVNAME_HWMON,
92 .num_resources = ARRAY_SIZE(da9063_hwmon_resources),
93 .resources = da9063_hwmon_resources,
94 },
95 {
96 .name = DA9063_DRVNAME_ONKEY,
97 .num_resources = ARRAY_SIZE(da9063_onkey_resources),
98 .resources = da9063_onkey_resources,
99 },
100 {
101 .name = DA9063_DRVNAME_RTC,
102 .num_resources = ARRAY_SIZE(da9063_rtc_resources),
103 .resources = da9063_rtc_resources,
104 },
105 {
106 .name = DA9063_DRVNAME_VIBRATION,
107 },
108};
109
110int da9063_device_init(struct da9063 *da9063, unsigned int irq)
111{
112 struct da9063_pdata *pdata = da9063->dev->platform_data;
113 int model, revision;
114 int ret;
115
116 if (pdata) {
117 da9063->flags = pdata->flags;
118 da9063->irq_base = pdata->irq_base;
119 } else {
120 da9063->flags = 0;
121 da9063->irq_base = 0;
122 }
123 da9063->chip_irq = irq;
124
125 if (pdata && pdata->init != NULL) {
126 ret = pdata->init(da9063);
127 if (ret != 0) {
128 dev_err(da9063->dev,
129 "Platform initialization failed.\n");
130 return ret;
131 }
132 }
133
134 ret = regmap_read(da9063->regmap, DA9063_REG_CHIP_ID, &model);
135 if (ret < 0) {
136 dev_err(da9063->dev, "Cannot read chip model id.\n");
137 return -EIO;
138 }
139 if (model != PMIC_DA9063) {
140 dev_err(da9063->dev, "Invalid chip model id: 0x%02x\n", model);
141 return -ENODEV;
142 }
143
144 ret = regmap_read(da9063->regmap, DA9063_REG_CHIP_VARIANT, &revision);
145 if (ret < 0) {
146 dev_err(da9063->dev, "Cannot read chip revision id.\n");
147 return -EIO;
148 }
149 revision >>= DA9063_CHIP_VARIANT_SHIFT;
150 if (revision != 3) {
151 dev_err(da9063->dev, "Unknown chip revision: %d\n", revision);
152 return -ENODEV;
153 }
154
155 da9063->model = model;
156 da9063->revision = revision;
157
158 dev_info(da9063->dev,
159 "Device detected (model-ID: 0x%02X rev-ID: 0x%02X)\n",
160 model, revision);
161
162 ret = da9063_irq_init(da9063);
163 if (ret) {
164 dev_err(da9063->dev, "Cannot initialize interrupts.\n");
165 return ret;
166 }
167
168 ret = mfd_add_devices(da9063->dev, -1, da9063_devs,
169 ARRAY_SIZE(da9063_devs), NULL, da9063->irq_base,
170 NULL);
171 if (ret)
172 dev_err(da9063->dev, "Cannot add MFD cells\n");
173
174 return ret;
175}
176
177void da9063_device_exit(struct da9063 *da9063)
178{
179 mfd_remove_devices(da9063->dev);
180 da9063_irq_exit(da9063);
181}
182
183MODULE_DESCRIPTION("PMIC driver for Dialog DA9063");
184MODULE_AUTHOR("Krystian Garbaciak <krystian.garbaciak@diasemi.com>, Michal Hajduk <michal.hajduk@diasemi.com>");
185MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/da9063-i2c.c b/drivers/mfd/da9063-i2c.c
new file mode 100644
index 000000000000..8db5c805c64f
--- /dev/null
+++ b/drivers/mfd/da9063-i2c.c
@@ -0,0 +1,182 @@
1/* da9063-i2c.c: Interrupt support for Dialog DA9063
2 *
3 * Copyright 2012 Dialog Semiconductor Ltd.
4 * Copyright 2013 Philipp Zabel, Pengutronix
5 *
6 * Author: Krystian Garbaciak <krystian.garbaciak@diasemi.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/i2c.h>
18#include <linux/regmap.h>
19#include <linux/delay.h>
20#include <linux/slab.h>
21#include <linux/err.h>
22
23#include <linux/mfd/core.h>
24#include <linux/mfd/da9063/core.h>
25#include <linux/mfd/da9063/pdata.h>
26#include <linux/mfd/da9063/registers.h>
27
28static const struct regmap_range da9063_readable_ranges[] = {
29 {
30 .range_min = DA9063_REG_PAGE_CON,
31 .range_max = DA9063_REG_SECOND_D,
32 }, {
33 .range_min = DA9063_REG_SEQ,
34 .range_max = DA9063_REG_ID_32_31,
35 }, {
36 .range_min = DA9063_REG_SEQ_A,
37 .range_max = DA9063_REG_AUTO3_LOW,
38 }, {
39 .range_min = DA9063_REG_T_OFFSET,
40 .range_max = DA9063_REG_GP_ID_19,
41 }, {
42 .range_min = DA9063_REG_CHIP_ID,
43 .range_max = DA9063_REG_CHIP_VARIANT,
44 },
45};
46
47static const struct regmap_range da9063_writeable_ranges[] = {
48 {
49 .range_min = DA9063_REG_PAGE_CON,
50 .range_max = DA9063_REG_PAGE_CON,
51 }, {
52 .range_min = DA9063_REG_FAULT_LOG,
53 .range_max = DA9063_REG_VSYS_MON,
54 }, {
55 .range_min = DA9063_REG_COUNT_S,
56 .range_max = DA9063_REG_ALARM_Y,
57 }, {
58 .range_min = DA9063_REG_SEQ,
59 .range_max = DA9063_REG_ID_32_31,
60 }, {
61 .range_min = DA9063_REG_SEQ_A,
62 .range_max = DA9063_REG_AUTO3_LOW,
63 }, {
64 .range_min = DA9063_REG_CONFIG_I,
65 .range_max = DA9063_REG_MON_REG_4,
66 }, {
67 .range_min = DA9063_REG_GP_ID_0,
68 .range_max = DA9063_REG_GP_ID_19,
69 },
70};
71
72static const struct regmap_range da9063_volatile_ranges[] = {
73 {
74 .range_min = DA9063_REG_STATUS_A,
75 .range_max = DA9063_REG_EVENT_D,
76 }, {
77 .range_min = DA9063_REG_CONTROL_F,
78 .range_max = DA9063_REG_CONTROL_F,
79 }, {
80 .range_min = DA9063_REG_ADC_MAN,
81 .range_max = DA9063_REG_ADC_MAN,
82 }, {
83 .range_min = DA9063_REG_ADC_RES_L,
84 .range_max = DA9063_REG_SECOND_D,
85 }, {
86 .range_min = DA9063_REG_MON_REG_5,
87 .range_max = DA9063_REG_MON_REG_6,
88 },
89};
90
91static const struct regmap_access_table da9063_readable_table = {
92 .yes_ranges = da9063_readable_ranges,
93 .n_yes_ranges = ARRAY_SIZE(da9063_readable_ranges),
94};
95
96static const struct regmap_access_table da9063_writeable_table = {
97 .yes_ranges = da9063_writeable_ranges,
98 .n_yes_ranges = ARRAY_SIZE(da9063_writeable_ranges),
99};
100
101static const struct regmap_access_table da9063_volatile_table = {
102 .yes_ranges = da9063_volatile_ranges,
103 .n_yes_ranges = ARRAY_SIZE(da9063_volatile_ranges),
104};
105
106static const struct regmap_range_cfg da9063_range_cfg[] = {
107 {
108 .range_min = DA9063_REG_PAGE_CON,
109 .range_max = DA9063_REG_CHIP_VARIANT,
110 .selector_reg = DA9063_REG_PAGE_CON,
111 .selector_mask = 1 << DA9063_I2C_PAGE_SEL_SHIFT,
112 .selector_shift = DA9063_I2C_PAGE_SEL_SHIFT,
113 .window_start = 0,
114 .window_len = 256,
115 }
116};
117
118static struct regmap_config da9063_regmap_config = {
119 .reg_bits = 8,
120 .val_bits = 8,
121 .ranges = da9063_range_cfg,
122 .num_ranges = ARRAY_SIZE(da9063_range_cfg),
123 .max_register = DA9063_REG_CHIP_VARIANT,
124
125 .cache_type = REGCACHE_RBTREE,
126
127 .rd_table = &da9063_readable_table,
128 .wr_table = &da9063_writeable_table,
129 .volatile_table = &da9063_volatile_table,
130};
131
132static int da9063_i2c_probe(struct i2c_client *i2c,
133 const struct i2c_device_id *id)
134{
135 struct da9063 *da9063;
136 int ret;
137
138 da9063 = devm_kzalloc(&i2c->dev, sizeof(struct da9063), GFP_KERNEL);
139 if (da9063 == NULL)
140 return -ENOMEM;
141
142 i2c_set_clientdata(i2c, da9063);
143 da9063->dev = &i2c->dev;
144 da9063->chip_irq = i2c->irq;
145
146 da9063->regmap = devm_regmap_init_i2c(i2c, &da9063_regmap_config);
147 if (IS_ERR(da9063->regmap)) {
148 ret = PTR_ERR(da9063->regmap);
149 dev_err(da9063->dev, "Failed to allocate register map: %d\n",
150 ret);
151 return ret;
152 }
153
154 return da9063_device_init(da9063, i2c->irq);
155}
156
157static int da9063_i2c_remove(struct i2c_client *i2c)
158{
159 struct da9063 *da9063 = i2c_get_clientdata(i2c);
160
161 da9063_device_exit(da9063);
162
163 return 0;
164}
165
166static const struct i2c_device_id da9063_i2c_id[] = {
167 {"da9063", PMIC_DA9063},
168 {},
169};
170MODULE_DEVICE_TABLE(i2c, da9063_i2c_id);
171
172static struct i2c_driver da9063_i2c_driver = {
173 .driver = {
174 .name = "da9063",
175 .owner = THIS_MODULE,
176 },
177 .probe = da9063_i2c_probe,
178 .remove = da9063_i2c_remove,
179 .id_table = da9063_i2c_id,
180};
181
182module_i2c_driver(da9063_i2c_driver);
diff --git a/drivers/mfd/da9063-irq.c b/drivers/mfd/da9063-irq.c
new file mode 100644
index 000000000000..822922602ce9
--- /dev/null
+++ b/drivers/mfd/da9063-irq.c
@@ -0,0 +1,193 @@
1/* da9063-irq.c: Interrupts support for Dialog DA9063
2 *
3 * Copyright 2012 Dialog Semiconductor Ltd.
4 * Copyright 2013 Philipp Zabel, Pengutronix
5 *
6 * Author: Michal Hajduk <michal.hajduk@diasemi.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/irq.h>
18#include <linux/mfd/core.h>
19#include <linux/interrupt.h>
20#include <linux/regmap.h>
21#include <linux/mfd/da9063/core.h>
22#include <linux/mfd/da9063/pdata.h>
23
24#define DA9063_REG_EVENT_A_OFFSET 0
25#define DA9063_REG_EVENT_B_OFFSET 1
26#define DA9063_REG_EVENT_C_OFFSET 2
27#define DA9063_REG_EVENT_D_OFFSET 3
28#define EVENTS_BUF_LEN 4
29
30static const u8 mask_events_buf[] = { [0 ... (EVENTS_BUF_LEN - 1)] = ~0 };
31
32struct da9063_irq_data {
33 u16 reg;
34 u8 mask;
35};
36
37static struct regmap_irq da9063_irqs[] = {
38 /* DA9063 event A register */
39 [DA9063_IRQ_ONKEY] = {
40 .reg_offset = DA9063_REG_EVENT_A_OFFSET,
41 .mask = DA9063_M_ONKEY,
42 },
43 [DA9063_IRQ_ALARM] = {
44 .reg_offset = DA9063_REG_EVENT_A_OFFSET,
45 .mask = DA9063_M_ALARM,
46 },
47 [DA9063_IRQ_TICK] = {
48 .reg_offset = DA9063_REG_EVENT_A_OFFSET,
49 .mask = DA9063_M_TICK,
50 },
51 [DA9063_IRQ_ADC_RDY] = {
52 .reg_offset = DA9063_REG_EVENT_A_OFFSET,
53 .mask = DA9063_M_ADC_RDY,
54 },
55 [DA9063_IRQ_SEQ_RDY] = {
56 .reg_offset = DA9063_REG_EVENT_A_OFFSET,
57 .mask = DA9063_M_SEQ_RDY,
58 },
59 /* DA9063 event B register */
60 [DA9063_IRQ_WAKE] = {
61 .reg_offset = DA9063_REG_EVENT_B_OFFSET,
62 .mask = DA9063_M_WAKE,
63 },
64 [DA9063_IRQ_TEMP] = {
65 .reg_offset = DA9063_REG_EVENT_B_OFFSET,
66 .mask = DA9063_M_TEMP,
67 },
68 [DA9063_IRQ_COMP_1V2] = {
69 .reg_offset = DA9063_REG_EVENT_B_OFFSET,
70 .mask = DA9063_M_COMP_1V2,
71 },
72 [DA9063_IRQ_LDO_LIM] = {
73 .reg_offset = DA9063_REG_EVENT_B_OFFSET,
74 .mask = DA9063_M_LDO_LIM,
75 },
76 [DA9063_IRQ_REG_UVOV] = {
77 .reg_offset = DA9063_REG_EVENT_B_OFFSET,
78 .mask = DA9063_M_UVOV,
79 },
80 [DA9063_IRQ_VDD_MON] = {
81 .reg_offset = DA9063_REG_EVENT_B_OFFSET,
82 .mask = DA9063_M_VDD_MON,
83 },
84 [DA9063_IRQ_WARN] = {
85 .reg_offset = DA9063_REG_EVENT_B_OFFSET,
86 .mask = DA9063_M_VDD_WARN,
87 },
88 /* DA9063 event C register */
89 [DA9063_IRQ_GPI0] = {
90 .reg_offset = DA9063_REG_EVENT_C_OFFSET,
91 .mask = DA9063_M_GPI0,
92 },
93 [DA9063_IRQ_GPI1] = {
94 .reg_offset = DA9063_REG_EVENT_C_OFFSET,
95 .mask = DA9063_M_GPI1,
96 },
97 [DA9063_IRQ_GPI2] = {
98 .reg_offset = DA9063_REG_EVENT_C_OFFSET,
99 .mask = DA9063_M_GPI2,
100 },
101 [DA9063_IRQ_GPI3] = {
102 .reg_offset = DA9063_REG_EVENT_C_OFFSET,
103 .mask = DA9063_M_GPI3,
104 },
105 [DA9063_IRQ_GPI4] = {
106 .reg_offset = DA9063_REG_EVENT_C_OFFSET,
107 .mask = DA9063_M_GPI4,
108 },
109 [DA9063_IRQ_GPI5] = {
110 .reg_offset = DA9063_REG_EVENT_C_OFFSET,
111 .mask = DA9063_M_GPI5,
112 },
113 [DA9063_IRQ_GPI6] = {
114 .reg_offset = DA9063_REG_EVENT_C_OFFSET,
115 .mask = DA9063_M_GPI6,
116 },
117 [DA9063_IRQ_GPI7] = {
118 .reg_offset = DA9063_REG_EVENT_C_OFFSET,
119 .mask = DA9063_M_GPI7,
120 },
121 /* DA9063 event D register */
122 [DA9063_IRQ_GPI8] = {
123 .reg_offset = DA9063_REG_EVENT_D_OFFSET,
124 .mask = DA9063_M_GPI8,
125 },
126 [DA9063_IRQ_GPI9] = {
127 .reg_offset = DA9063_REG_EVENT_D_OFFSET,
128 .mask = DA9063_M_GPI9,
129 },
130 [DA9063_IRQ_GPI10] = {
131 .reg_offset = DA9063_REG_EVENT_D_OFFSET,
132 .mask = DA9063_M_GPI10,
133 },
134 [DA9063_IRQ_GPI11] = {
135 .reg_offset = DA9063_REG_EVENT_D_OFFSET,
136 .mask = DA9063_M_GPI11,
137 },
138 [DA9063_IRQ_GPI12] = {
139 .reg_offset = DA9063_REG_EVENT_D_OFFSET,
140 .mask = DA9063_M_GPI12,
141 },
142 [DA9063_IRQ_GPI13] = {
143 .reg_offset = DA9063_REG_EVENT_D_OFFSET,
144 .mask = DA9063_M_GPI13,
145 },
146 [DA9063_IRQ_GPI14] = {
147 .reg_offset = DA9063_REG_EVENT_D_OFFSET,
148 .mask = DA9063_M_GPI14,
149 },
150 [DA9063_IRQ_GPI15] = {
151 .reg_offset = DA9063_REG_EVENT_D_OFFSET,
152 .mask = DA9063_M_GPI15,
153 },
154};
155
156static struct regmap_irq_chip da9063_irq_chip = {
157 .name = "da9063-irq",
158 .irqs = da9063_irqs,
159 .num_irqs = DA9063_NUM_IRQ,
160
161 .num_regs = 4,
162 .status_base = DA9063_REG_EVENT_A,
163 .mask_base = DA9063_REG_IRQ_MASK_A,
164 .ack_base = DA9063_REG_EVENT_A,
165 .init_ack_masked = true,
166};
167
168int da9063_irq_init(struct da9063 *da9063)
169{
170 int ret;
171
172 if (!da9063->chip_irq) {
173 dev_err(da9063->dev, "No IRQ configured\n");
174 return -EINVAL;
175 }
176
177 ret = regmap_add_irq_chip(da9063->regmap, da9063->chip_irq,
178 IRQF_TRIGGER_LOW | IRQF_ONESHOT | IRQF_SHARED,
179 da9063->irq_base, &da9063_irq_chip,
180 &da9063->regmap_irq);
181 if (ret) {
182 dev_err(da9063->dev, "Failed to reguest IRQ %d: %d\n",
183 da9063->chip_irq, ret);
184 return ret;
185 }
186
187 return 0;
188}
189
190void da9063_irq_exit(struct da9063 *da9063)
191{
192 regmap_del_irq_chip(da9063->chip_irq, da9063->regmap_irq);
193}
diff --git a/drivers/mfd/davinci_voicecodec.c b/drivers/mfd/davinci_voicecodec.c
index fb64398506e9..013ba8159dcd 100644
--- a/drivers/mfd/davinci_voicecodec.c
+++ b/drivers/mfd/davinci_voicecodec.c
@@ -27,21 +27,16 @@
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/clk.h> 29#include <linux/clk.h>
30#include <linux/regmap.h>
30 31
31#include <sound/pcm.h> 32#include <sound/pcm.h>
32 33
33#include <linux/mfd/davinci_voicecodec.h> 34#include <linux/mfd/davinci_voicecodec.h>
34 35
35u32 davinci_vc_read(struct davinci_vc *davinci_vc, int reg) 36static struct regmap_config davinci_vc_regmap = {
36{ 37 .reg_bits = 32,
37 return __raw_readl(davinci_vc->base + reg); 38 .val_bits = 32,
38} 39};
39
40void davinci_vc_write(struct davinci_vc *davinci_vc,
41 int reg, u32 val)
42{
43 __raw_writel(val, davinci_vc->base + reg);
44}
45 40
46static int __init davinci_vc_probe(struct platform_device *pdev) 41static int __init davinci_vc_probe(struct platform_device *pdev)
47{ 42{
@@ -74,6 +69,14 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
74 goto fail; 69 goto fail;
75 } 70 }
76 71
72 davinci_vc->regmap = devm_regmap_init_mmio(&pdev->dev,
73 davinci_vc->base,
74 &davinci_vc_regmap);
75 if (IS_ERR(davinci_vc->regmap)) {
76 ret = PTR_ERR(davinci_vc->regmap);
77 goto fail;
78 }
79
77 res = platform_get_resource(pdev, IORESOURCE_DMA, 0); 80 res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
78 if (!res) { 81 if (!res) {
79 dev_err(&pdev->dev, "no DMA resource\n"); 82 dev_err(&pdev->dev, "no DMA resource\n");
diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c
index 0d68eb1a5ec5..53f371dcbb6e 100644
--- a/drivers/mfd/db8500-prcmu.c
+++ b/drivers/mfd/db8500-prcmu.c
@@ -465,7 +465,7 @@ static DEFINE_SPINLOCK(clk_mgt_lock);
465 465
466#define CLK_MGT_ENTRY(_name, _branch, _clk38div)[PRCMU_##_name] = \ 466#define CLK_MGT_ENTRY(_name, _branch, _clk38div)[PRCMU_##_name] = \
467 { (PRCM_##_name##_MGT), 0 , _branch, _clk38div} 467 { (PRCM_##_name##_MGT), 0 , _branch, _clk38div}
468struct clk_mgt clk_mgt[PRCMU_NUM_REG_CLOCKS] = { 468static struct clk_mgt clk_mgt[PRCMU_NUM_REG_CLOCKS] = {
469 CLK_MGT_ENTRY(SGACLK, PLL_DIV, false), 469 CLK_MGT_ENTRY(SGACLK, PLL_DIV, false),
470 CLK_MGT_ENTRY(UARTCLK, PLL_FIX, true), 470 CLK_MGT_ENTRY(UARTCLK, PLL_FIX, true),
471 CLK_MGT_ENTRY(MSP02CLK, PLL_FIX, true), 471 CLK_MGT_ENTRY(MSP02CLK, PLL_FIX, true),
@@ -2319,7 +2319,7 @@ unlock_and_return:
2319/** 2319/**
2320 * prcmu_ac_sleep_req - called when ARM no longer needs to talk to modem 2320 * prcmu_ac_sleep_req - called when ARM no longer needs to talk to modem
2321 */ 2321 */
2322void prcmu_ac_sleep_req() 2322void prcmu_ac_sleep_req(void)
2323{ 2323{
2324 u32 val; 2324 u32 val;
2325 2325
diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c
index 7710227d284e..7a55c0071fa8 100644
--- a/drivers/mfd/dm355evm_msp.c
+++ b/drivers/mfd/dm355evm_msp.c
@@ -315,8 +315,8 @@ static int add_children(struct i2c_client *client)
315 } 315 }
316 316
317 /* MMC/SD inputs -- right after the last config input */ 317 /* MMC/SD inputs -- right after the last config input */
318 if (client->dev.platform_data) { 318 if (dev_get_platdata(&client->dev)) {
319 void (*mmcsd_setup)(unsigned) = client->dev.platform_data; 319 void (*mmcsd_setup)(unsigned) = dev_get_platdata(&client->dev);
320 320
321 mmcsd_setup(dm355evm_msp_gpio.base + 8 + 5); 321 mmcsd_setup(dm355evm_msp_gpio.base + 8 + 5);
322 } 322 }
diff --git a/drivers/mfd/ezx-pcap.c b/drivers/mfd/ezx-pcap.c
index 5502106ad515..7245b0c5b794 100644
--- a/drivers/mfd/ezx-pcap.c
+++ b/drivers/mfd/ezx-pcap.c
@@ -177,7 +177,7 @@ static void pcap_msr_work(struct work_struct *work)
177static void pcap_isr_work(struct work_struct *work) 177static void pcap_isr_work(struct work_struct *work)
178{ 178{
179 struct pcap_chip *pcap = container_of(work, struct pcap_chip, isr_work); 179 struct pcap_chip *pcap = container_of(work, struct pcap_chip, isr_work);
180 struct pcap_platform_data *pdata = pcap->spi->dev.platform_data; 180 struct pcap_platform_data *pdata = dev_get_platdata(&pcap->spi->dev);
181 u32 msr, isr, int_sel, service; 181 u32 msr, isr, int_sel, service;
182 int irq; 182 int irq;
183 183
@@ -394,7 +394,7 @@ static int pcap_add_subdev(struct pcap_chip *pcap,
394static int ezx_pcap_remove(struct spi_device *spi) 394static int ezx_pcap_remove(struct spi_device *spi)
395{ 395{
396 struct pcap_chip *pcap = spi_get_drvdata(spi); 396 struct pcap_chip *pcap = spi_get_drvdata(spi);
397 struct pcap_platform_data *pdata = spi->dev.platform_data; 397 struct pcap_platform_data *pdata = dev_get_platdata(&spi->dev);
398 int i, adc_irq; 398 int i, adc_irq;
399 399
400 /* remove all registered subdevs */ 400 /* remove all registered subdevs */
@@ -420,7 +420,7 @@ static int ezx_pcap_remove(struct spi_device *spi)
420 420
421static int ezx_pcap_probe(struct spi_device *spi) 421static int ezx_pcap_probe(struct spi_device *spi)
422{ 422{
423 struct pcap_platform_data *pdata = spi->dev.platform_data; 423 struct pcap_platform_data *pdata = dev_get_platdata(&spi->dev);
424 struct pcap_chip *pcap; 424 struct pcap_chip *pcap;
425 int i, adc_irq; 425 int i, adc_irq;
426 int ret = -ENODEV; 426 int ret = -ENODEV;
diff --git a/drivers/mfd/htc-egpio.c b/drivers/mfd/htc-egpio.c
index 26aca545084b..49f39feca784 100644
--- a/drivers/mfd/htc-egpio.c
+++ b/drivers/mfd/htc-egpio.c
@@ -261,7 +261,7 @@ static void egpio_write_cache(struct egpio_info *ei)
261 261
262static int __init egpio_probe(struct platform_device *pdev) 262static int __init egpio_probe(struct platform_device *pdev)
263{ 263{
264 struct htc_egpio_platform_data *pdata = pdev->dev.platform_data; 264 struct htc_egpio_platform_data *pdata = dev_get_platdata(&pdev->dev);
265 struct resource *res; 265 struct resource *res;
266 struct egpio_info *ei; 266 struct egpio_info *ei;
267 struct gpio_chip *chip; 267 struct gpio_chip *chip;
diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c
index c9dfce6ae0c2..d7b2a75aca3e 100644
--- a/drivers/mfd/htc-i2cpld.c
+++ b/drivers/mfd/htc-i2cpld.c
@@ -340,7 +340,7 @@ static int htcpld_setup_chip_irq(
340 int ret = 0; 340 int ret = 0;
341 341
342 /* Get the platform and driver data */ 342 /* Get the platform and driver data */
343 pdata = dev->platform_data; 343 pdata = dev_get_platdata(dev);
344 htcpld = platform_get_drvdata(pdev); 344 htcpld = platform_get_drvdata(pdev);
345 chip = &htcpld->chip[chip_index]; 345 chip = &htcpld->chip[chip_index];
346 plat_chip_data = &pdata->chip[chip_index]; 346 plat_chip_data = &pdata->chip[chip_index];
@@ -375,7 +375,7 @@ static int htcpld_register_chip_i2c(
375 struct i2c_board_info info; 375 struct i2c_board_info info;
376 376
377 /* Get the platform and driver data */ 377 /* Get the platform and driver data */
378 pdata = dev->platform_data; 378 pdata = dev_get_platdata(dev);
379 htcpld = platform_get_drvdata(pdev); 379 htcpld = platform_get_drvdata(pdev);
380 chip = &htcpld->chip[chip_index]; 380 chip = &htcpld->chip[chip_index];
381 plat_chip_data = &pdata->chip[chip_index]; 381 plat_chip_data = &pdata->chip[chip_index];
@@ -447,7 +447,7 @@ static int htcpld_register_chip_gpio(
447 int ret = 0; 447 int ret = 0;
448 448
449 /* Get the platform and driver data */ 449 /* Get the platform and driver data */
450 pdata = dev->platform_data; 450 pdata = dev_get_platdata(dev);
451 htcpld = platform_get_drvdata(pdev); 451 htcpld = platform_get_drvdata(pdev);
452 chip = &htcpld->chip[chip_index]; 452 chip = &htcpld->chip[chip_index];
453 plat_chip_data = &pdata->chip[chip_index]; 453 plat_chip_data = &pdata->chip[chip_index];
@@ -509,7 +509,7 @@ static int htcpld_setup_chips(struct platform_device *pdev)
509 int i; 509 int i;
510 510
511 /* Get the platform and driver data */ 511 /* Get the platform and driver data */
512 pdata = dev->platform_data; 512 pdata = dev_get_platdata(dev);
513 htcpld = platform_get_drvdata(pdev); 513 htcpld = platform_get_drvdata(pdev);
514 514
515 /* Setup each chip's output GPIOs */ 515 /* Setup each chip's output GPIOs */
@@ -574,7 +574,7 @@ static int htcpld_core_probe(struct platform_device *pdev)
574 if (!dev) 574 if (!dev)
575 return -ENODEV; 575 return -ENODEV;
576 576
577 pdata = dev->platform_data; 577 pdata = dev_get_platdata(dev);
578 if (!pdata) { 578 if (!pdata) {
579 dev_warn(dev, "Platform data not found for htcpld core!\n"); 579 dev_warn(dev, "Platform data not found for htcpld core!\n");
580 return -ENXIO; 580 return -ENXIO;
diff --git a/drivers/mfd/htc-pasic3.c b/drivers/mfd/htc-pasic3.c
index 0a5e85fd8517..6bf92a507b95 100644
--- a/drivers/mfd/htc-pasic3.c
+++ b/drivers/mfd/htc-pasic3.c
@@ -126,7 +126,7 @@ static struct mfd_cell ds1wm_cell __initdata = {
126 126
127static int __init pasic3_probe(struct platform_device *pdev) 127static int __init pasic3_probe(struct platform_device *pdev)
128{ 128{
129 struct pasic3_platform_data *pdata = pdev->dev.platform_data; 129 struct pasic3_platform_data *pdata = dev_get_platdata(&pdev->dev);
130 struct device *dev = &pdev->dev; 130 struct device *dev = &pdev->dev;
131 struct pasic3_data *asic; 131 struct pasic3_data *asic;
132 struct resource *r; 132 struct resource *r;
diff --git a/drivers/mfd/intel_msic.c b/drivers/mfd/intel_msic.c
index 4f2462f0963e..9203d47cdbb1 100644
--- a/drivers/mfd/intel_msic.c
+++ b/drivers/mfd/intel_msic.c
@@ -310,7 +310,7 @@ EXPORT_SYMBOL_GPL(intel_msic_irq_read);
310static int intel_msic_init_devices(struct intel_msic *msic) 310static int intel_msic_init_devices(struct intel_msic *msic)
311{ 311{
312 struct platform_device *pdev = msic->pdev; 312 struct platform_device *pdev = msic->pdev;
313 struct intel_msic_platform_data *pdata = pdev->dev.platform_data; 313 struct intel_msic_platform_data *pdata = dev_get_platdata(&pdev->dev);
314 int ret, i; 314 int ret, i;
315 315
316 if (pdata->gpio) { 316 if (pdata->gpio) {
@@ -372,7 +372,7 @@ static void intel_msic_remove_devices(struct intel_msic *msic)
372 372
373static int intel_msic_probe(struct platform_device *pdev) 373static int intel_msic_probe(struct platform_device *pdev)
374{ 374{
375 struct intel_msic_platform_data *pdata = pdev->dev.platform_data; 375 struct intel_msic_platform_data *pdata = dev_get_platdata(&pdev->dev);
376 struct intel_msic *msic; 376 struct intel_msic *msic;
377 struct resource *res; 377 struct resource *res;
378 u8 id0, id1; 378 u8 id0, id1;
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index 686a4565acb6..d3e23278d299 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -258,7 +258,7 @@ EXPORT_SYMBOL_GPL(kempld_write32);
258 */ 258 */
259void kempld_get_mutex(struct kempld_device_data *pld) 259void kempld_get_mutex(struct kempld_device_data *pld)
260{ 260{
261 struct kempld_platform_data *pdata = pld->dev->platform_data; 261 struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
262 262
263 mutex_lock(&pld->lock); 263 mutex_lock(&pld->lock);
264 pdata->get_hardware_mutex(pld); 264 pdata->get_hardware_mutex(pld);
@@ -271,7 +271,7 @@ EXPORT_SYMBOL_GPL(kempld_get_mutex);
271 */ 271 */
272void kempld_release_mutex(struct kempld_device_data *pld) 272void kempld_release_mutex(struct kempld_device_data *pld)
273{ 273{
274 struct kempld_platform_data *pdata = pld->dev->platform_data; 274 struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
275 275
276 pdata->release_hardware_mutex(pld); 276 pdata->release_hardware_mutex(pld);
277 mutex_unlock(&pld->lock); 277 mutex_unlock(&pld->lock);
@@ -288,7 +288,7 @@ EXPORT_SYMBOL_GPL(kempld_release_mutex);
288 */ 288 */
289static int kempld_get_info(struct kempld_device_data *pld) 289static int kempld_get_info(struct kempld_device_data *pld)
290{ 290{
291 struct kempld_platform_data *pdata = pld->dev->platform_data; 291 struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
292 292
293 return pdata->get_info(pld); 293 return pdata->get_info(pld);
294} 294}
@@ -302,7 +302,7 @@ static int kempld_get_info(struct kempld_device_data *pld)
302 */ 302 */
303static int kempld_register_cells(struct kempld_device_data *pld) 303static int kempld_register_cells(struct kempld_device_data *pld)
304{ 304{
305 struct kempld_platform_data *pdata = pld->dev->platform_data; 305 struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
306 306
307 return pdata->register_cells(pld); 307 return pdata->register_cells(pld);
308} 308}
@@ -357,7 +357,7 @@ static int kempld_detect_device(struct kempld_device_data *pld)
357 357
358static int kempld_probe(struct platform_device *pdev) 358static int kempld_probe(struct platform_device *pdev)
359{ 359{
360 struct kempld_platform_data *pdata = pdev->dev.platform_data; 360 struct kempld_platform_data *pdata = dev_get_platdata(&pdev->dev);
361 struct device *dev = &pdev->dev; 361 struct device *dev = &pdev->dev;
362 struct kempld_device_data *pld; 362 struct kempld_device_data *pld;
363 struct resource *ioport; 363 struct resource *ioport;
@@ -394,7 +394,7 @@ static int kempld_probe(struct platform_device *pdev)
394static int kempld_remove(struct platform_device *pdev) 394static int kempld_remove(struct platform_device *pdev)
395{ 395{
396 struct kempld_device_data *pld = platform_get_drvdata(pdev); 396 struct kempld_device_data *pld = platform_get_drvdata(pdev);
397 struct kempld_platform_data *pdata = pld->dev->platform_data; 397 struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
398 398
399 mfd_remove_devices(&pdev->dev); 399 mfd_remove_devices(&pdev->dev);
400 pdata->release_hardware_mutex(pld); 400 pdata->release_hardware_mutex(pld);
@@ -413,6 +413,15 @@ static struct platform_driver kempld_driver = {
413 413
414static struct dmi_system_id __initdata kempld_dmi_table[] = { 414static struct dmi_system_id __initdata kempld_dmi_table[] = {
415 { 415 {
416 .ident = "BHL6",
417 .matches = {
418 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
419 DMI_MATCH(DMI_BOARD_NAME, "COMe-bHL6"),
420 },
421 .driver_data = (void *)&kempld_platform_data_generic,
422 .callback = kempld_create_platform_device,
423 },
424 {
416 .ident = "CCR2", 425 .ident = "CCR2",
417 .matches = { 426 .matches = {
418 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), 427 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
@@ -596,6 +605,15 @@ static struct dmi_system_id __initdata kempld_dmi_table[] = {
596 .driver_data = (void *)&kempld_platform_data_generic, 605 .driver_data = (void *)&kempld_platform_data_generic,
597 .callback = kempld_create_platform_device, 606 .callback = kempld_create_platform_device,
598 }, 607 },
608 {
609 .ident = "UTH6",
610 .matches = {
611 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
612 DMI_MATCH(DMI_BOARD_NAME, "COMe-cTH6"),
613 },
614 .driver_data = (void *)&kempld_platform_data_generic,
615 .callback = kempld_create_platform_device,
616 },
599 {} 617 {}
600}; 618};
601MODULE_DEVICE_TABLE(dmi, kempld_dmi_table); 619MODULE_DEVICE_TABLE(dmi, kempld_dmi_table);
diff --git a/drivers/mfd/lm3533-core.c b/drivers/mfd/lm3533-core.c
index 4b7e6dac1de8..8c29f7b27324 100644
--- a/drivers/mfd/lm3533-core.c
+++ b/drivers/mfd/lm3533-core.c
@@ -384,7 +384,7 @@ static struct attribute_group lm3533_attribute_group = {
384 384
385static int lm3533_device_als_init(struct lm3533 *lm3533) 385static int lm3533_device_als_init(struct lm3533 *lm3533)
386{ 386{
387 struct lm3533_platform_data *pdata = lm3533->dev->platform_data; 387 struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
388 int ret; 388 int ret;
389 389
390 if (!pdata->als) 390 if (!pdata->als)
@@ -407,7 +407,7 @@ static int lm3533_device_als_init(struct lm3533 *lm3533)
407 407
408static int lm3533_device_bl_init(struct lm3533 *lm3533) 408static int lm3533_device_bl_init(struct lm3533 *lm3533)
409{ 409{
410 struct lm3533_platform_data *pdata = lm3533->dev->platform_data; 410 struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
411 int i; 411 int i;
412 int ret; 412 int ret;
413 413
@@ -436,7 +436,7 @@ static int lm3533_device_bl_init(struct lm3533 *lm3533)
436 436
437static int lm3533_device_led_init(struct lm3533 *lm3533) 437static int lm3533_device_led_init(struct lm3533 *lm3533)
438{ 438{
439 struct lm3533_platform_data *pdata = lm3533->dev->platform_data; 439 struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
440 int i; 440 int i;
441 int ret; 441 int ret;
442 442
@@ -481,7 +481,7 @@ static int lm3533_device_setup(struct lm3533 *lm3533,
481 481
482static int lm3533_device_init(struct lm3533 *lm3533) 482static int lm3533_device_init(struct lm3533 *lm3533)
483{ 483{
484 struct lm3533_platform_data *pdata = lm3533->dev->platform_data; 484 struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
485 int ret; 485 int ret;
486 486
487 dev_dbg(lm3533->dev, "%s\n", __func__); 487 dev_dbg(lm3533->dev, "%s\n", __func__);
diff --git a/drivers/mfd/lp8788.c b/drivers/mfd/lp8788.c
index c3d3c9b4d3ad..0f1221911018 100644
--- a/drivers/mfd/lp8788.c
+++ b/drivers/mfd/lp8788.c
@@ -173,7 +173,7 @@ static const struct regmap_config lp8788_regmap_config = {
173static int lp8788_probe(struct i2c_client *cl, const struct i2c_device_id *id) 173static int lp8788_probe(struct i2c_client *cl, const struct i2c_device_id *id)
174{ 174{
175 struct lp8788 *lp; 175 struct lp8788 *lp;
176 struct lp8788_platform_data *pdata = cl->dev.platform_data; 176 struct lp8788_platform_data *pdata = dev_get_platdata(&cl->dev);
177 int ret; 177 int ret;
178 178
179 lp = devm_kzalloc(&cl->dev, sizeof(struct lp8788), GFP_KERNEL); 179 lp = devm_kzalloc(&cl->dev, sizeof(struct lp8788), GFP_KERNEL);
diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c
index 24033324c17a..9483bc8472a5 100644
--- a/drivers/mfd/lpc_ich.c
+++ b/drivers/mfd/lpc_ich.c
@@ -213,7 +213,7 @@ enum lpc_chipsets {
213 LPC_COLETO, /* Coleto Creek */ 213 LPC_COLETO, /* Coleto Creek */
214}; 214};
215 215
216struct lpc_ich_info lpc_chipset_info[] = { 216static struct lpc_ich_info lpc_chipset_info[] = {
217 [LPC_ICH] = { 217 [LPC_ICH] = {
218 .name = "ICH", 218 .name = "ICH",
219 .iTCO_version = 1, 219 .iTCO_version = 1,
diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index f27a21831583..522be67b2e68 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -77,7 +77,7 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
77 const struct i2c_device_id *id) 77 const struct i2c_device_id *id)
78{ 78{
79 struct max77686_dev *max77686 = NULL; 79 struct max77686_dev *max77686 = NULL;
80 struct max77686_platform_data *pdata = i2c->dev.platform_data; 80 struct max77686_platform_data *pdata = dev_get_platdata(&i2c->dev);
81 unsigned int data; 81 unsigned int data;
82 int ret = 0; 82 int ret = 0;
83 83
diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c
index 9e60fed5ff82..c04723efc707 100644
--- a/drivers/mfd/max77693.c
+++ b/drivers/mfd/max77693.c
@@ -110,7 +110,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
110 const struct i2c_device_id *id) 110 const struct i2c_device_id *id)
111{ 111{
112 struct max77693_dev *max77693; 112 struct max77693_dev *max77693;
113 struct max77693_platform_data *pdata = i2c->dev.platform_data; 113 struct max77693_platform_data *pdata = dev_get_platdata(&i2c->dev);
114 u8 reg_data; 114 u8 reg_data;
115 int ret = 0; 115 int ret = 0;
116 116
diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
index 8042b3205eaa..de7fb80a6052 100644
--- a/drivers/mfd/max8925-i2c.c
+++ b/drivers/mfd/max8925-i2c.c
@@ -151,7 +151,7 @@ static int max8925_dt_init(struct device_node *np, struct device *dev,
151static int max8925_probe(struct i2c_client *client, 151static int max8925_probe(struct i2c_client *client,
152 const struct i2c_device_id *id) 152 const struct i2c_device_id *id)
153{ 153{
154 struct max8925_platform_data *pdata = client->dev.platform_data; 154 struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
155 static struct max8925_chip *chip; 155 static struct max8925_chip *chip;
156 struct device_node *node = client->dev.of_node; 156 struct device_node *node = client->dev.of_node;
157 157
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index 14714058f2d2..cee098c0dae3 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -51,7 +51,7 @@ static struct mfd_cell max8997_devs[] = {
51 51
52#ifdef CONFIG_OF 52#ifdef CONFIG_OF
53static struct of_device_id max8997_pmic_dt_match[] = { 53static struct of_device_id max8997_pmic_dt_match[] = {
54 { .compatible = "maxim,max8997-pmic", .data = TYPE_MAX8997 }, 54 { .compatible = "maxim,max8997-pmic", .data = (void *)TYPE_MAX8997 },
55 {}, 55 {},
56}; 56};
57#endif 57#endif
@@ -188,10 +188,11 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
188 const struct i2c_device_id *id) 188 const struct i2c_device_id *id)
189{ 189{
190 struct max8997_dev *max8997; 190 struct max8997_dev *max8997;
191 struct max8997_platform_data *pdata = i2c->dev.platform_data; 191 struct max8997_platform_data *pdata = dev_get_platdata(&i2c->dev);
192 int ret = 0; 192 int ret = 0;
193 193
194 max8997 = kzalloc(sizeof(struct max8997_dev), GFP_KERNEL); 194 max8997 = devm_kzalloc(&i2c->dev, sizeof(struct max8997_dev),
195 GFP_KERNEL);
195 if (max8997 == NULL) 196 if (max8997 == NULL)
196 return -ENOMEM; 197 return -ENOMEM;
197 198
@@ -203,14 +204,12 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
203 204
204 if (max8997->dev->of_node) { 205 if (max8997->dev->of_node) {
205 pdata = max8997_i2c_parse_dt_pdata(max8997->dev); 206 pdata = max8997_i2c_parse_dt_pdata(max8997->dev);
206 if (IS_ERR(pdata)) { 207 if (IS_ERR(pdata))
207 ret = PTR_ERR(pdata); 208 return PTR_ERR(pdata);
208 goto err;
209 }
210 } 209 }
211 210
212 if (!pdata) 211 if (!pdata)
213 goto err; 212 return ret;
214 213
215 max8997->pdata = pdata; 214 max8997->pdata = pdata;
216 max8997->ono = pdata->ono; 215 max8997->ono = pdata->ono;
@@ -250,8 +249,6 @@ err_mfd:
250 i2c_unregister_device(max8997->muic); 249 i2c_unregister_device(max8997->muic);
251 i2c_unregister_device(max8997->haptic); 250 i2c_unregister_device(max8997->haptic);
252 i2c_unregister_device(max8997->rtc); 251 i2c_unregister_device(max8997->rtc);
253err:
254 kfree(max8997);
255 return ret; 252 return ret;
256} 253}
257 254
@@ -263,7 +260,6 @@ static int max8997_i2c_remove(struct i2c_client *i2c)
263 i2c_unregister_device(max8997->muic); 260 i2c_unregister_device(max8997->muic);
264 i2c_unregister_device(max8997->haptic); 261 i2c_unregister_device(max8997->haptic);
265 i2c_unregister_device(max8997->rtc); 262 i2c_unregister_device(max8997->rtc);
266 kfree(max8997);
267 263
268 return 0; 264 return 0;
269} 265}
diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c
index 21af51a499f4..fe6332dcabee 100644
--- a/drivers/mfd/max8998.c
+++ b/drivers/mfd/max8998.c
@@ -184,11 +184,12 @@ static inline int max8998_i2c_get_driver_data(struct i2c_client *i2c,
184static int max8998_i2c_probe(struct i2c_client *i2c, 184static int max8998_i2c_probe(struct i2c_client *i2c,
185 const struct i2c_device_id *id) 185 const struct i2c_device_id *id)
186{ 186{
187 struct max8998_platform_data *pdata = i2c->dev.platform_data; 187 struct max8998_platform_data *pdata = dev_get_platdata(&i2c->dev);
188 struct max8998_dev *max8998; 188 struct max8998_dev *max8998;
189 int ret = 0; 189 int ret = 0;
190 190
191 max8998 = kzalloc(sizeof(struct max8998_dev), GFP_KERNEL); 191 max8998 = devm_kzalloc(&i2c->dev, sizeof(struct max8998_dev),
192 GFP_KERNEL);
192 if (max8998 == NULL) 193 if (max8998 == NULL)
193 return -ENOMEM; 194 return -ENOMEM;
194 195
@@ -246,7 +247,6 @@ err:
246 mfd_remove_devices(max8998->dev); 247 mfd_remove_devices(max8998->dev);
247 max8998_irq_exit(max8998); 248 max8998_irq_exit(max8998);
248 i2c_unregister_device(max8998->rtc); 249 i2c_unregister_device(max8998->rtc);
249 kfree(max8998);
250 return ret; 250 return ret;
251} 251}
252 252
@@ -257,7 +257,6 @@ static int max8998_i2c_remove(struct i2c_client *i2c)
257 mfd_remove_devices(max8998->dev); 257 mfd_remove_devices(max8998->dev);
258 max8998_irq_exit(max8998); 258 max8998_irq_exit(max8998);
259 i2c_unregister_device(max8998->rtc); 259 i2c_unregister_device(max8998->rtc);
260 kfree(max8998);
261 260
262 return 0; 261 return 0;
263} 262}
diff --git a/drivers/mfd/mcp-sa11x0.c b/drivers/mfd/mcp-sa11x0.c
index 13198d937e36..41c31b3ac940 100644
--- a/drivers/mfd/mcp-sa11x0.c
+++ b/drivers/mfd/mcp-sa11x0.c
@@ -156,7 +156,7 @@ static struct mcp_ops mcp_sa11x0 = {
156 156
157static int mcp_sa11x0_probe(struct platform_device *dev) 157static int mcp_sa11x0_probe(struct platform_device *dev)
158{ 158{
159 struct mcp_plat_data *data = dev->dev.platform_data; 159 struct mcp_plat_data *data = dev_get_platdata(&dev->dev);
160 struct resource *mem0, *mem1; 160 struct resource *mem0, *mem1;
161 struct mcp_sa11x0 *m; 161 struct mcp_sa11x0 *m;
162 struct mcp *mcp; 162 struct mcp *mcp;
diff --git a/drivers/mfd/menelaus.c b/drivers/mfd/menelaus.c
index 998ce8cb3065..ad25bfa3fb02 100644
--- a/drivers/mfd/menelaus.c
+++ b/drivers/mfd/menelaus.c
@@ -442,7 +442,7 @@ void menelaus_unregister_mmc_callback(void)
442 menelaus_remove_irq_work(MENELAUS_MMC_S2D1_IRQ); 442 menelaus_remove_irq_work(MENELAUS_MMC_S2D1_IRQ);
443 443
444 the_menelaus->mmc_callback = NULL; 444 the_menelaus->mmc_callback = NULL;
445 the_menelaus->mmc_callback_data = 0; 445 the_menelaus->mmc_callback_data = NULL;
446} 446}
447EXPORT_SYMBOL(menelaus_unregister_mmc_callback); 447EXPORT_SYMBOL(menelaus_unregister_mmc_callback);
448 448
@@ -466,7 +466,7 @@ static int menelaus_set_voltage(const struct menelaus_vtg *vtg, int mV,
466 struct i2c_client *c = the_menelaus->client; 466 struct i2c_client *c = the_menelaus->client;
467 467
468 mutex_lock(&the_menelaus->lock); 468 mutex_lock(&the_menelaus->lock);
469 if (vtg == 0) 469 if (!vtg)
470 goto set_voltage; 470 goto set_voltage;
471 471
472 ret = menelaus_read_reg(vtg->vtg_reg); 472 ret = menelaus_read_reg(vtg->vtg_reg);
@@ -1189,7 +1189,7 @@ static int menelaus_probe(struct i2c_client *client,
1189 int rev = 0, val; 1189 int rev = 0, val;
1190 int err = 0; 1190 int err = 0;
1191 struct menelaus_platform_data *menelaus_pdata = 1191 struct menelaus_platform_data *menelaus_pdata =
1192 client->dev.platform_data; 1192 dev_get_platdata(&client->dev);
1193 1193
1194 if (the_menelaus) { 1194 if (the_menelaus) {
1195 dev_dbg(&client->dev, "only one %s for now\n", 1195 dev_dbg(&client->dev, "only one %s for now\n",
@@ -1197,7 +1197,7 @@ static int menelaus_probe(struct i2c_client *client,
1197 return -ENODEV; 1197 return -ENODEV;
1198 } 1198 }
1199 1199
1200 menelaus = kzalloc(sizeof *menelaus, GFP_KERNEL); 1200 menelaus = devm_kzalloc(&client->dev, sizeof(*menelaus), GFP_KERNEL);
1201 if (!menelaus) 1201 if (!menelaus)
1202 return -ENOMEM; 1202 return -ENOMEM;
1203 1203
@@ -1210,8 +1210,7 @@ static int menelaus_probe(struct i2c_client *client,
1210 rev = menelaus_read_reg(MENELAUS_REV); 1210 rev = menelaus_read_reg(MENELAUS_REV);
1211 if (rev < 0) { 1211 if (rev < 0) {
1212 pr_err(DRIVER_NAME ": device not found"); 1212 pr_err(DRIVER_NAME ": device not found");
1213 err = -ENODEV; 1213 return -ENODEV;
1214 goto fail1;
1215 } 1214 }
1216 1215
1217 /* Ack and disable all Menelaus interrupts */ 1216 /* Ack and disable all Menelaus interrupts */
@@ -1231,7 +1230,7 @@ static int menelaus_probe(struct i2c_client *client,
1231 if (err) { 1230 if (err) {
1232 dev_dbg(&client->dev, "can't get IRQ %d, err %d\n", 1231 dev_dbg(&client->dev, "can't get IRQ %d, err %d\n",
1233 client->irq, err); 1232 client->irq, err);
1234 goto fail1; 1233 return err;
1235 } 1234 }
1236 } 1235 }
1237 1236
@@ -1242,7 +1241,7 @@ static int menelaus_probe(struct i2c_client *client,
1242 1241
1243 val = menelaus_read_reg(MENELAUS_VCORE_CTRL1); 1242 val = menelaus_read_reg(MENELAUS_VCORE_CTRL1);
1244 if (val < 0) 1243 if (val < 0)
1245 goto fail2; 1244 goto fail;
1246 if (val & (1 << 7)) 1245 if (val & (1 << 7))
1247 menelaus->vcore_hw_mode = 1; 1246 menelaus->vcore_hw_mode = 1;
1248 else 1247 else
@@ -1251,17 +1250,15 @@ static int menelaus_probe(struct i2c_client *client,
1251 if (menelaus_pdata != NULL && menelaus_pdata->late_init != NULL) { 1250 if (menelaus_pdata != NULL && menelaus_pdata->late_init != NULL) {
1252 err = menelaus_pdata->late_init(&client->dev); 1251 err = menelaus_pdata->late_init(&client->dev);
1253 if (err < 0) 1252 if (err < 0)
1254 goto fail2; 1253 goto fail;
1255 } 1254 }
1256 1255
1257 menelaus_rtc_init(menelaus); 1256 menelaus_rtc_init(menelaus);
1258 1257
1259 return 0; 1258 return 0;
1260fail2: 1259fail:
1261 free_irq(client->irq, menelaus); 1260 free_irq(client->irq, menelaus);
1262 flush_work(&menelaus->work); 1261 flush_work(&menelaus->work);
1263fail1:
1264 kfree(menelaus);
1265 return err; 1262 return err;
1266} 1263}
1267 1264
@@ -1271,7 +1268,6 @@ static int __exit menelaus_remove(struct i2c_client *client)
1271 1268
1272 free_irq(client->irq, menelaus); 1269 free_irq(client->irq, menelaus);
1273 flush_work(&menelaus->work); 1270 flush_work(&menelaus->work);
1274 kfree(menelaus);
1275 the_menelaus = NULL; 1271 the_menelaus = NULL;
1276 return 0; 1272 return 0;
1277} 1273}
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 7604f4e5df40..f421586f29fb 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -96,6 +96,8 @@ static int mfd_add_device(struct device *parent, int id,
96 96
97 pdev->dev.parent = parent; 97 pdev->dev.parent = parent;
98 pdev->dev.type = &mfd_dev_type; 98 pdev->dev.type = &mfd_dev_type;
99 pdev->dev.dma_mask = parent->dma_mask;
100 pdev->dev.dma_parms = parent->dma_parms;
99 101
100 if (parent->of_node && cell->of_compatible) { 102 if (parent->of_node && cell->of_compatible) {
101 for_each_child_of_node(parent->of_node, np) { 103 for_each_child_of_node(parent->of_node, np) {
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 759fae3ca7fb..29ee54d68512 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -114,7 +114,7 @@ struct usbhs_hcd_omap {
114}; 114};
115/*-------------------------------------------------------------------------*/ 115/*-------------------------------------------------------------------------*/
116 116
117const char usbhs_driver_name[] = USBHS_DRIVER_NAME; 117static const char usbhs_driver_name[] = USBHS_DRIVER_NAME;
118static u64 usbhs_dmamask = DMA_BIT_MASK(32); 118static u64 usbhs_dmamask = DMA_BIT_MASK(32);
119 119
120/*-------------------------------------------------------------------------*/ 120/*-------------------------------------------------------------------------*/
@@ -232,7 +232,7 @@ err_end:
232static int omap_usbhs_alloc_children(struct platform_device *pdev) 232static int omap_usbhs_alloc_children(struct platform_device *pdev)
233{ 233{
234 struct device *dev = &pdev->dev; 234 struct device *dev = &pdev->dev;
235 struct usbhs_omap_platform_data *pdata = dev->platform_data; 235 struct usbhs_omap_platform_data *pdata = dev_get_platdata(dev);
236 struct platform_device *ehci; 236 struct platform_device *ehci;
237 struct platform_device *ohci; 237 struct platform_device *ohci;
238 struct resource *res; 238 struct resource *res;
@@ -571,7 +571,7 @@ static struct of_device_id usbhs_child_match_table[] = {
571static int usbhs_omap_probe(struct platform_device *pdev) 571static int usbhs_omap_probe(struct platform_device *pdev)
572{ 572{
573 struct device *dev = &pdev->dev; 573 struct device *dev = &pdev->dev;
574 struct usbhs_omap_platform_data *pdata = dev->platform_data; 574 struct usbhs_omap_platform_data *pdata = dev_get_platdata(dev);
575 struct usbhs_hcd_omap *omap; 575 struct usbhs_hcd_omap *omap;
576 struct resource *res; 576 struct resource *res;
577 int ret = 0; 577 int ret = 0;
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index e4d1c706df8b..135afabe4ae2 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -25,6 +25,52 @@
25#include <linux/mfd/palmas.h> 25#include <linux/mfd/palmas.h>
26#include <linux/of_device.h> 26#include <linux/of_device.h>
27 27
28#define PALMAS_EXT_REQ (PALMAS_EXT_CONTROL_ENABLE1 | \
29 PALMAS_EXT_CONTROL_ENABLE2 | \
30 PALMAS_EXT_CONTROL_NSLEEP)
31
32struct palmas_sleep_requestor_info {
33 int id;
34 int reg_offset;
35 int bit_pos;
36};
37
38#define EXTERNAL_REQUESTOR(_id, _offset, _pos) \
39 [PALMAS_EXTERNAL_REQSTR_ID_##_id] = { \
40 .id = PALMAS_EXTERNAL_REQSTR_ID_##_id, \
41 .reg_offset = _offset, \
42 .bit_pos = _pos, \
43 }
44
45static struct palmas_sleep_requestor_info sleep_req_info[] = {
46 EXTERNAL_REQUESTOR(REGEN1, 0, 0),
47 EXTERNAL_REQUESTOR(REGEN2, 0, 1),
48 EXTERNAL_REQUESTOR(SYSEN1, 0, 2),
49 EXTERNAL_REQUESTOR(SYSEN2, 0, 3),
50 EXTERNAL_REQUESTOR(CLK32KG, 0, 4),
51 EXTERNAL_REQUESTOR(CLK32KGAUDIO, 0, 5),
52 EXTERNAL_REQUESTOR(REGEN3, 0, 6),
53 EXTERNAL_REQUESTOR(SMPS12, 1, 0),
54 EXTERNAL_REQUESTOR(SMPS3, 1, 1),
55 EXTERNAL_REQUESTOR(SMPS45, 1, 2),
56 EXTERNAL_REQUESTOR(SMPS6, 1, 3),
57 EXTERNAL_REQUESTOR(SMPS7, 1, 4),
58 EXTERNAL_REQUESTOR(SMPS8, 1, 5),
59 EXTERNAL_REQUESTOR(SMPS9, 1, 6),
60 EXTERNAL_REQUESTOR(SMPS10, 1, 7),
61 EXTERNAL_REQUESTOR(LDO1, 2, 0),
62 EXTERNAL_REQUESTOR(LDO2, 2, 1),
63 EXTERNAL_REQUESTOR(LDO3, 2, 2),
64 EXTERNAL_REQUESTOR(LDO4, 2, 3),
65 EXTERNAL_REQUESTOR(LDO5, 2, 4),
66 EXTERNAL_REQUESTOR(LDO6, 2, 5),
67 EXTERNAL_REQUESTOR(LDO7, 2, 6),
68 EXTERNAL_REQUESTOR(LDO8, 2, 7),
69 EXTERNAL_REQUESTOR(LDO9, 3, 0),
70 EXTERNAL_REQUESTOR(LDOLN, 3, 1),
71 EXTERNAL_REQUESTOR(LDOUSB, 3, 2),
72};
73
28static const struct regmap_config palmas_regmap_config[PALMAS_NUM_CLIENTS] = { 74static const struct regmap_config palmas_regmap_config[PALMAS_NUM_CLIENTS] = {
29 { 75 {
30 .reg_bits = 8, 76 .reg_bits = 8,
@@ -186,6 +232,57 @@ static struct regmap_irq_chip palmas_irq_chip = {
186 PALMAS_INT1_MASK), 232 PALMAS_INT1_MASK),
187}; 233};
188 234
235int palmas_ext_control_req_config(struct palmas *palmas,
236 enum palmas_external_requestor_id id, int ext_ctrl, bool enable)
237{
238 int preq_mask_bit = 0;
239 int reg_add = 0;
240 int bit_pos;
241 int ret;
242
243 if (!(ext_ctrl & PALMAS_EXT_REQ))
244 return 0;
245
246 if (id >= PALMAS_EXTERNAL_REQSTR_ID_MAX)
247 return 0;
248
249 if (ext_ctrl & PALMAS_EXT_CONTROL_NSLEEP) {
250 reg_add = PALMAS_NSLEEP_RES_ASSIGN;
251 preq_mask_bit = 0;
252 } else if (ext_ctrl & PALMAS_EXT_CONTROL_ENABLE1) {
253 reg_add = PALMAS_ENABLE1_RES_ASSIGN;
254 preq_mask_bit = 1;
255 } else if (ext_ctrl & PALMAS_EXT_CONTROL_ENABLE2) {
256 reg_add = PALMAS_ENABLE2_RES_ASSIGN;
257 preq_mask_bit = 2;
258 }
259
260 bit_pos = sleep_req_info[id].bit_pos;
261 reg_add += sleep_req_info[id].reg_offset;
262 if (enable)
263 ret = palmas_update_bits(palmas, PALMAS_RESOURCE_BASE,
264 reg_add, BIT(bit_pos), BIT(bit_pos));
265 else
266 ret = palmas_update_bits(palmas, PALMAS_RESOURCE_BASE,
267 reg_add, BIT(bit_pos), 0);
268 if (ret < 0) {
269 dev_err(palmas->dev, "Resource reg 0x%02x update failed %d\n",
270 reg_add, ret);
271 return ret;
272 }
273
274 /* Unmask the PREQ */
275 ret = palmas_update_bits(palmas, PALMAS_PMU_CONTROL_BASE,
276 PALMAS_POWER_CTRL, BIT(preq_mask_bit), 0);
277 if (ret < 0) {
278 dev_err(palmas->dev, "POWER_CTRL register update failed %d\n",
279 ret);
280 return ret;
281 }
282 return ret;
283}
284EXPORT_SYMBOL_GPL(palmas_ext_control_req_config);
285
189static int palmas_set_pdata_irq_flag(struct i2c_client *i2c, 286static int palmas_set_pdata_irq_flag(struct i2c_client *i2c,
190 struct palmas_platform_data *pdata) 287 struct palmas_platform_data *pdata)
191{ 288{
@@ -229,6 +326,32 @@ static void palmas_dt_to_pdata(struct i2c_client *i2c,
229 PALMAS_POWER_CTRL_ENABLE2_MASK; 326 PALMAS_POWER_CTRL_ENABLE2_MASK;
230 if (i2c->irq) 327 if (i2c->irq)
231 palmas_set_pdata_irq_flag(i2c, pdata); 328 palmas_set_pdata_irq_flag(i2c, pdata);
329
330 pdata->pm_off = of_property_read_bool(node,
331 "ti,system-power-controller");
332}
333
334static struct palmas *palmas_dev;
335static void palmas_power_off(void)
336{
337 unsigned int addr;
338 int ret, slave;
339
340 if (!palmas_dev)
341 return;
342
343 slave = PALMAS_BASE_TO_SLAVE(PALMAS_PMU_CONTROL_BASE);
344 addr = PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE, PALMAS_DEV_CTRL);
345
346 ret = regmap_update_bits(
347 palmas_dev->regmap[slave],
348 addr,
349 PALMAS_DEV_CTRL_DEV_ON,
350 0);
351
352 if (ret)
353 pr_err("%s: Unable to write to DEV_CTRL_DEV_ON: %d\n",
354 __func__, ret);
232} 355}
233 356
234static unsigned int palmas_features = PALMAS_PMIC_FEATURE_SMPS10_BOOST; 357static unsigned int palmas_features = PALMAS_PMIC_FEATURE_SMPS10_BOOST;
@@ -423,10 +546,13 @@ no_irq:
423 */ 546 */
424 if (node) { 547 if (node) {
425 ret = of_platform_populate(node, NULL, NULL, &i2c->dev); 548 ret = of_platform_populate(node, NULL, NULL, &i2c->dev);
426 if (ret < 0) 549 if (ret < 0) {
427 goto err_irq; 550 goto err_irq;
428 else 551 } else if (pdata->pm_off && !pm_power_off) {
552 palmas_dev = palmas;
553 pm_power_off = palmas_power_off;
429 return ret; 554 return ret;
555 }
430 } 556 }
431 557
432 return ret; 558 return ret;
diff --git a/drivers/mfd/pcf50633-adc.c b/drivers/mfd/pcf50633-adc.c
index 18b53cb72fea..b8941a556d71 100644
--- a/drivers/mfd/pcf50633-adc.c
+++ b/drivers/mfd/pcf50633-adc.c
@@ -203,7 +203,7 @@ static int pcf50633_adc_probe(struct platform_device *pdev)
203{ 203{
204 struct pcf50633_adc *adc; 204 struct pcf50633_adc *adc;
205 205
206 adc = kzalloc(sizeof(*adc), GFP_KERNEL); 206 adc = devm_kzalloc(&pdev->dev, sizeof(*adc), GFP_KERNEL);
207 if (!adc) 207 if (!adc)
208 return -ENOMEM; 208 return -ENOMEM;
209 209
@@ -236,7 +236,6 @@ static int pcf50633_adc_remove(struct platform_device *pdev)
236 kfree(adc->queue[i]); 236 kfree(adc->queue[i]);
237 237
238 mutex_unlock(&adc->queue_mutex); 238 mutex_unlock(&adc->queue_mutex);
239 kfree(adc);
240 239
241 return 0; 240 return 0;
242} 241}
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c
index d11567307fbe..6841d6805fd6 100644
--- a/drivers/mfd/pcf50633-core.c
+++ b/drivers/mfd/pcf50633-core.c
@@ -195,7 +195,7 @@ static int pcf50633_probe(struct i2c_client *client,
195 const struct i2c_device_id *ids) 195 const struct i2c_device_id *ids)
196{ 196{
197 struct pcf50633 *pcf; 197 struct pcf50633 *pcf;
198 struct pcf50633_platform_data *pdata = client->dev.platform_data; 198 struct pcf50633_platform_data *pdata = dev_get_platdata(&client->dev);
199 int i, ret; 199 int i, ret;
200 int version, variant; 200 int version, variant;
201 201
diff --git a/drivers/mfd/pm8921-core.c b/drivers/mfd/pm8921-core.c
index ecc137ffa8c3..a6841f77aa5e 100644
--- a/drivers/mfd/pm8921-core.c
+++ b/drivers/mfd/pm8921-core.c
@@ -14,6 +14,7 @@
14#define pr_fmt(fmt) "%s: " fmt, __func__ 14#define pr_fmt(fmt) "%s: " fmt, __func__
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/module.h>
17#include <linux/platform_device.h> 18#include <linux/platform_device.h>
18#include <linux/slab.h> 19#include <linux/slab.h>
19#include <linux/err.h> 20#include <linux/err.h>
@@ -106,7 +107,7 @@ static int pm8921_add_subdevices(const struct pm8921_platform_data
106 107
107static int pm8921_probe(struct platform_device *pdev) 108static int pm8921_probe(struct platform_device *pdev)
108{ 109{
109 const struct pm8921_platform_data *pdata = pdev->dev.platform_data; 110 const struct pm8921_platform_data *pdata = dev_get_platdata(&pdev->dev);
110 struct pm8921 *pmic; 111 struct pm8921 *pmic;
111 int rc; 112 int rc;
112 u8 val; 113 u8 val;
@@ -117,7 +118,7 @@ static int pm8921_probe(struct platform_device *pdev)
117 return -EINVAL; 118 return -EINVAL;
118 } 119 }
119 120
120 pmic = kzalloc(sizeof(struct pm8921), GFP_KERNEL); 121 pmic = devm_kzalloc(&pdev->dev, sizeof(struct pm8921), GFP_KERNEL);
121 if (!pmic) { 122 if (!pmic) {
122 pr_err("Cannot alloc pm8921 struct\n"); 123 pr_err("Cannot alloc pm8921 struct\n");
123 return -ENOMEM; 124 return -ENOMEM;
@@ -127,7 +128,7 @@ static int pm8921_probe(struct platform_device *pdev)
127 rc = ssbi_read(pdev->dev.parent, REG_HWREV, &val, sizeof(val)); 128 rc = ssbi_read(pdev->dev.parent, REG_HWREV, &val, sizeof(val));
128 if (rc) { 129 if (rc) {
129 pr_err("Failed to read hw rev reg %d:rc=%d\n", REG_HWREV, rc); 130 pr_err("Failed to read hw rev reg %d:rc=%d\n", REG_HWREV, rc);
130 goto err_read_rev; 131 return rc;
131 } 132 }
132 pr_info("PMIC revision 1: %02X\n", val); 133 pr_info("PMIC revision 1: %02X\n", val);
133 rev = val; 134 rev = val;
@@ -137,7 +138,7 @@ static int pm8921_probe(struct platform_device *pdev)
137 if (rc) { 138 if (rc) {
138 pr_err("Failed to read hw rev 2 reg %d:rc=%d\n", 139 pr_err("Failed to read hw rev 2 reg %d:rc=%d\n",
139 REG_HWREV_2, rc); 140 REG_HWREV_2, rc);
140 goto err_read_rev; 141 return rc;
141 } 142 }
142 pr_info("PMIC revision 2: %02X\n", val); 143 pr_info("PMIC revision 2: %02X\n", val);
143 rev |= val << BITS_PER_BYTE; 144 rev |= val << BITS_PER_BYTE;
@@ -159,9 +160,6 @@ static int pm8921_probe(struct platform_device *pdev)
159 160
160err: 161err:
161 mfd_remove_devices(pmic->dev); 162 mfd_remove_devices(pmic->dev);
162 platform_set_drvdata(pdev, NULL);
163err_read_rev:
164 kfree(pmic);
165 return rc; 163 return rc;
166} 164}
167 165
@@ -179,8 +177,6 @@ static int pm8921_remove(struct platform_device *pdev)
179 pm8xxx_irq_exit(pmic->irq_chip); 177 pm8xxx_irq_exit(pmic->irq_chip);
180 pmic->irq_chip = NULL; 178 pmic->irq_chip = NULL;
181 } 179 }
182 platform_set_drvdata(pdev, NULL);
183 kfree(pmic);
184 180
185 return 0; 181 return 0;
186} 182}
diff --git a/drivers/mfd/rc5t583.c b/drivers/mfd/rc5t583.c
index 14bdaccefbec..346330176afc 100644
--- a/drivers/mfd/rc5t583.c
+++ b/drivers/mfd/rc5t583.c
@@ -250,7 +250,7 @@ static int rc5t583_i2c_probe(struct i2c_client *i2c,
250 const struct i2c_device_id *id) 250 const struct i2c_device_id *id)
251{ 251{
252 struct rc5t583 *rc5t583; 252 struct rc5t583 *rc5t583;
253 struct rc5t583_platform_data *pdata = i2c->dev.platform_data; 253 struct rc5t583_platform_data *pdata = dev_get_platdata(&i2c->dev);
254 int ret; 254 int ret;
255 bool irq_init_success = false; 255 bool irq_init_success = false;
256 256
diff --git a/drivers/mfd/rtl8411.c b/drivers/mfd/rtl8411.c
index c436bf27e78d..52801351864d 100644
--- a/drivers/mfd/rtl8411.c
+++ b/drivers/mfd/rtl8411.c
@@ -1,6 +1,6 @@
1/* Driver for Realtek PCI-Express card reader 1/* Driver for Realtek PCI-Express card reader
2 * 2 *
3 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. 3 * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License as published by the
@@ -17,7 +17,7 @@
17 * 17 *
18 * Author: 18 * Author:
19 * Wei WANG <wei_wang@realsil.com.cn> 19 * Wei WANG <wei_wang@realsil.com.cn>
20 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China 20 * Roger Tseng <rogerable@realtek.com>
21 */ 21 */
22 22
23#include <linux/module.h> 23#include <linux/module.h>
@@ -47,19 +47,77 @@ static int rtl8411b_is_qfn48(struct rtsx_pcr *pcr)
47 return 0; 47 return 0;
48} 48}
49 49
50static void rtl8411_fetch_vendor_settings(struct rtsx_pcr *pcr)
51{
52 u32 reg1;
53 u8 reg3;
54
55 rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, &reg1);
56 dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg1);
57
58 if (!rtsx_vendor_setting_valid(reg1))
59 return;
60
61 pcr->aspm_en = rtsx_reg_to_aspm(reg1);
62 pcr->sd30_drive_sel_1v8 =
63 map_sd_drive(rtsx_reg_to_sd30_drive_sel_1v8(reg1));
64 pcr->card_drive_sel &= 0x3F;
65 pcr->card_drive_sel |= rtsx_reg_to_card_drive_sel(reg1);
66
67 rtsx_pci_read_config_byte(pcr, PCR_SETTING_REG3, &reg3);
68 dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG3, reg3);
69 pcr->sd30_drive_sel_3v3 = rtl8411_reg_to_sd30_drive_sel_3v3(reg3);
70}
71
72static void rtl8411b_fetch_vendor_settings(struct rtsx_pcr *pcr)
73{
74 u32 reg;
75
76 rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, &reg);
77 dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
78
79 if (!rtsx_vendor_setting_valid(reg))
80 return;
81
82 pcr->aspm_en = rtsx_reg_to_aspm(reg);
83 pcr->sd30_drive_sel_1v8 =
84 map_sd_drive(rtsx_reg_to_sd30_drive_sel_1v8(reg));
85 pcr->sd30_drive_sel_3v3 =
86 map_sd_drive(rtl8411b_reg_to_sd30_drive_sel_3v3(reg));
87}
88
89static void rtl8411_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
90{
91 rtsx_pci_write_register(pcr, FPDCTL, 0x07, 0x07);
92}
93
50static int rtl8411_extra_init_hw(struct rtsx_pcr *pcr) 94static int rtl8411_extra_init_hw(struct rtsx_pcr *pcr)
51{ 95{
52 return rtsx_pci_write_register(pcr, CD_PAD_CTL, 96 rtsx_pci_init_cmd(pcr);
97
98 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DRIVE_SEL,
99 0xFF, pcr->sd30_drive_sel_3v3);
100 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CD_PAD_CTL,
53 CD_DISABLE_MASK | CD_AUTO_DISABLE, CD_ENABLE); 101 CD_DISABLE_MASK | CD_AUTO_DISABLE, CD_ENABLE);
102
103 return rtsx_pci_send_cmd(pcr, 100);
54} 104}
55 105
56static int rtl8411b_extra_init_hw(struct rtsx_pcr *pcr) 106static int rtl8411b_extra_init_hw(struct rtsx_pcr *pcr)
57{ 107{
58 if (rtl8411b_is_qfn48(pcr)) 108 rtsx_pci_init_cmd(pcr);
59 rtsx_pci_write_register(pcr, CARD_PULL_CTL3, 0xFF, 0xF5);
60 109
61 return rtsx_pci_write_register(pcr, CD_PAD_CTL, 110 if (rtl8411b_is_qfn48(pcr))
111 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
112 CARD_PULL_CTL3, 0xFF, 0xF5);
113 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DRIVE_SEL,
114 0xFF, pcr->sd30_drive_sel_3v3);
115 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CD_PAD_CTL,
62 CD_DISABLE_MASK | CD_AUTO_DISABLE, CD_ENABLE); 116 CD_DISABLE_MASK | CD_AUTO_DISABLE, CD_ENABLE);
117 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, FUNC_FORCE_CTL,
118 0x06, 0x00);
119
120 return rtsx_pci_send_cmd(pcr, 100);
63} 121}
64 122
65static int rtl8411_turn_on_led(struct rtsx_pcr *pcr) 123static int rtl8411_turn_on_led(struct rtsx_pcr *pcr)
@@ -141,13 +199,13 @@ static int rtl8411_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
141 mask = (BPP_REG_TUNED18 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_MASK; 199 mask = (BPP_REG_TUNED18 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_MASK;
142 if (voltage == OUTPUT_3V3) { 200 if (voltage == OUTPUT_3V3) {
143 err = rtsx_pci_write_register(pcr, 201 err = rtsx_pci_write_register(pcr,
144 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_D); 202 SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_3v3);
145 if (err < 0) 203 if (err < 0)
146 return err; 204 return err;
147 val = (BPP_ASIC_3V3 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_3V3; 205 val = (BPP_ASIC_3V3 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_3V3;
148 } else if (voltage == OUTPUT_1V8) { 206 } else if (voltage == OUTPUT_1V8) {
149 err = rtsx_pci_write_register(pcr, 207 err = rtsx_pci_write_register(pcr,
150 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B); 208 SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_1v8);
151 if (err < 0) 209 if (err < 0)
152 return err; 210 return err;
153 val = (BPP_ASIC_1V8 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_1V8; 211 val = (BPP_ASIC_1V8 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_1V8;
@@ -222,6 +280,7 @@ static int rtl8411_conv_clk_and_div_n(int input, int dir)
222} 280}
223 281
224static const struct pcr_ops rtl8411_pcr_ops = { 282static const struct pcr_ops rtl8411_pcr_ops = {
283 .fetch_vendor_settings = rtl8411_fetch_vendor_settings,
225 .extra_init_hw = rtl8411_extra_init_hw, 284 .extra_init_hw = rtl8411_extra_init_hw,
226 .optimize_phy = NULL, 285 .optimize_phy = NULL,
227 .turn_on_led = rtl8411_turn_on_led, 286 .turn_on_led = rtl8411_turn_on_led,
@@ -233,9 +292,11 @@ static const struct pcr_ops rtl8411_pcr_ops = {
233 .switch_output_voltage = rtl8411_switch_output_voltage, 292 .switch_output_voltage = rtl8411_switch_output_voltage,
234 .cd_deglitch = rtl8411_cd_deglitch, 293 .cd_deglitch = rtl8411_cd_deglitch,
235 .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n, 294 .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n,
295 .force_power_down = rtl8411_force_power_down,
236}; 296};
237 297
238static const struct pcr_ops rtl8411b_pcr_ops = { 298static const struct pcr_ops rtl8411b_pcr_ops = {
299 .fetch_vendor_settings = rtl8411b_fetch_vendor_settings,
239 .extra_init_hw = rtl8411b_extra_init_hw, 300 .extra_init_hw = rtl8411b_extra_init_hw,
240 .optimize_phy = NULL, 301 .optimize_phy = NULL,
241 .turn_on_led = rtl8411_turn_on_led, 302 .turn_on_led = rtl8411_turn_on_led,
@@ -247,6 +308,7 @@ static const struct pcr_ops rtl8411b_pcr_ops = {
247 .switch_output_voltage = rtl8411_switch_output_voltage, 308 .switch_output_voltage = rtl8411_switch_output_voltage,
248 .cd_deglitch = rtl8411_cd_deglitch, 309 .cd_deglitch = rtl8411_cd_deglitch,
249 .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n, 310 .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n,
311 .force_power_down = rtl8411_force_power_down,
250}; 312};
251 313
252/* SD Pull Control Enable: 314/* SD Pull Control Enable:
@@ -385,6 +447,14 @@ void rtl8411_init_params(struct rtsx_pcr *pcr)
385 pcr->num_slots = 2; 447 pcr->num_slots = 2;
386 pcr->ops = &rtl8411_pcr_ops; 448 pcr->ops = &rtl8411_pcr_ops;
387 449
450 pcr->flags = 0;
451 pcr->card_drive_sel = RTL8411_CARD_DRIVE_DEFAULT;
452 pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B;
453 pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D;
454 pcr->aspm_en = ASPM_L1_EN;
455 pcr->tx_initial_phase = SET_CLOCK_PHASE(23, 7, 14);
456 pcr->rx_initial_phase = SET_CLOCK_PHASE(4, 3, 10);
457
388 pcr->ic_version = rtl8411_get_ic_version(pcr); 458 pcr->ic_version = rtl8411_get_ic_version(pcr);
389 pcr->sd_pull_ctl_enable_tbl = rtl8411_sd_pull_ctl_enable_tbl; 459 pcr->sd_pull_ctl_enable_tbl = rtl8411_sd_pull_ctl_enable_tbl;
390 pcr->sd_pull_ctl_disable_tbl = rtl8411_sd_pull_ctl_disable_tbl; 460 pcr->sd_pull_ctl_disable_tbl = rtl8411_sd_pull_ctl_disable_tbl;
@@ -398,6 +468,14 @@ void rtl8411b_init_params(struct rtsx_pcr *pcr)
398 pcr->num_slots = 2; 468 pcr->num_slots = 2;
399 pcr->ops = &rtl8411b_pcr_ops; 469 pcr->ops = &rtl8411b_pcr_ops;
400 470
471 pcr->flags = 0;
472 pcr->card_drive_sel = RTL8411_CARD_DRIVE_DEFAULT;
473 pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B;
474 pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D;
475 pcr->aspm_en = ASPM_L1_EN;
476 pcr->tx_initial_phase = SET_CLOCK_PHASE(23, 7, 14);
477 pcr->rx_initial_phase = SET_CLOCK_PHASE(4, 3, 10);
478
401 pcr->ic_version = rtl8411_get_ic_version(pcr); 479 pcr->ic_version = rtl8411_get_ic_version(pcr);
402 480
403 if (rtl8411b_is_qfn48(pcr)) { 481 if (rtl8411b_is_qfn48(pcr)) {
diff --git a/drivers/mfd/rts5209.c b/drivers/mfd/rts5209.c
index ec78d9fb0879..cb04174a8924 100644
--- a/drivers/mfd/rts5209.c
+++ b/drivers/mfd/rts5209.c
@@ -1,6 +1,6 @@
1/* Driver for Realtek PCI-Express card reader 1/* Driver for Realtek PCI-Express card reader
2 * 2 *
3 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. 3 * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License as published by the
@@ -17,7 +17,6 @@
17 * 17 *
18 * Author: 18 * Author:
19 * Wei WANG <wei_wang@realsil.com.cn> 19 * Wei WANG <wei_wang@realsil.com.cn>
20 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
21 */ 20 */
22 21
23#include <linux/module.h> 22#include <linux/module.h>
@@ -34,19 +33,34 @@ static u8 rts5209_get_ic_version(struct rtsx_pcr *pcr)
34 return val & 0x0F; 33 return val & 0x0F;
35} 34}
36 35
37static void rts5209_init_vendor_cfg(struct rtsx_pcr *pcr) 36static void rts5209_fetch_vendor_settings(struct rtsx_pcr *pcr)
38{ 37{
39 u32 val; 38 u32 reg;
40 39
41 rtsx_pci_read_config_dword(pcr, 0x724, &val); 40 rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, &reg);
42 dev_dbg(&(pcr->pci->dev), "Cfg 0x724: 0x%x\n", val); 41 dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
43 42
44 if (!(val & 0x80)) { 43 if (rts5209_vendor_setting1_valid(reg)) {
45 if (val & 0x08) 44 if (rts5209_reg_check_ms_pmos(reg))
46 pcr->ms_pmos = false; 45 pcr->flags |= PCR_MS_PMOS;
47 else 46 pcr->aspm_en = rts5209_reg_to_aspm(reg);
48 pcr->ms_pmos = true;
49 } 47 }
48
49 rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG2, &reg);
50 dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
51
52 if (rts5209_vendor_setting2_valid(reg)) {
53 pcr->sd30_drive_sel_1v8 =
54 rts5209_reg_to_sd30_drive_sel_1v8(reg);
55 pcr->sd30_drive_sel_3v3 =
56 rts5209_reg_to_sd30_drive_sel_3v3(reg);
57 pcr->card_drive_sel = rts5209_reg_to_card_drive_sel(reg);
58 }
59}
60
61static void rts5209_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
62{
63 rtsx_pci_write_register(pcr, FPDCTL, 0x07, 0x07);
50} 64}
51 65
52static int rts5209_extra_init_hw(struct rtsx_pcr *pcr) 66static int rts5209_extra_init_hw(struct rtsx_pcr *pcr)
@@ -55,8 +69,15 @@ static int rts5209_extra_init_hw(struct rtsx_pcr *pcr)
55 69
56 /* Turn off LED */ 70 /* Turn off LED */
57 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_GPIO, 0xFF, 0x03); 71 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_GPIO, 0xFF, 0x03);
72 /* Reset ASPM state to default value */
73 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, ASPM_FORCE_CTL, 0x3F, 0);
74 /* Force CLKREQ# PIN to drive 0 to request clock */
75 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0x08, 0x08);
58 /* Configure GPIO as output */ 76 /* Configure GPIO as output */
59 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_GPIO_DIR, 0xFF, 0x03); 77 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_GPIO_DIR, 0xFF, 0x03);
78 /* Configure driving */
79 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DRIVE_SEL,
80 0xFF, pcr->sd30_drive_sel_3v3);
60 81
61 return rtsx_pci_send_cmd(pcr, 100); 82 return rtsx_pci_send_cmd(pcr, 100);
62} 83}
@@ -95,7 +116,7 @@ static int rts5209_card_power_on(struct rtsx_pcr *pcr, int card)
95 partial_pwr_on = SD_PARTIAL_POWER_ON; 116 partial_pwr_on = SD_PARTIAL_POWER_ON;
96 pwr_on = SD_POWER_ON; 117 pwr_on = SD_POWER_ON;
97 118
98 if (pcr->ms_pmos && (card == RTSX_MS_CARD)) { 119 if ((pcr->flags & PCR_MS_PMOS) && (card == RTSX_MS_CARD)) {
99 pwr_mask = MS_POWER_MASK; 120 pwr_mask = MS_POWER_MASK;
100 partial_pwr_on = MS_PARTIAL_POWER_ON; 121 partial_pwr_on = MS_PARTIAL_POWER_ON;
101 pwr_on = MS_POWER_ON; 122 pwr_on = MS_POWER_ON;
@@ -131,7 +152,7 @@ static int rts5209_card_power_off(struct rtsx_pcr *pcr, int card)
131 pwr_mask = SD_POWER_MASK; 152 pwr_mask = SD_POWER_MASK;
132 pwr_off = SD_POWER_OFF; 153 pwr_off = SD_POWER_OFF;
133 154
134 if (pcr->ms_pmos && (card == RTSX_MS_CARD)) { 155 if ((pcr->flags & PCR_MS_PMOS) && (card == RTSX_MS_CARD)) {
135 pwr_mask = MS_POWER_MASK; 156 pwr_mask = MS_POWER_MASK;
136 pwr_off = MS_POWER_OFF; 157 pwr_off = MS_POWER_OFF;
137 } 158 }
@@ -140,7 +161,7 @@ static int rts5209_card_power_off(struct rtsx_pcr *pcr, int card)
140 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_PWR_CTL, 161 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_PWR_CTL,
141 pwr_mask | PMOS_STRG_MASK, pwr_off | PMOS_STRG_400mA); 162 pwr_mask | PMOS_STRG_MASK, pwr_off | PMOS_STRG_400mA);
142 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL, 163 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL,
143 LDO3318_PWR_MASK, 0X06); 164 LDO3318_PWR_MASK, 0x06);
144 return rtsx_pci_send_cmd(pcr, 100); 165 return rtsx_pci_send_cmd(pcr, 100);
145} 166}
146 167
@@ -150,7 +171,7 @@ static int rts5209_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
150 171
151 if (voltage == OUTPUT_3V3) { 172 if (voltage == OUTPUT_3V3) {
152 err = rtsx_pci_write_register(pcr, 173 err = rtsx_pci_write_register(pcr,
153 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_D); 174 SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_3v3);
154 if (err < 0) 175 if (err < 0)
155 return err; 176 return err;
156 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24); 177 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24);
@@ -158,7 +179,7 @@ static int rts5209_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
158 return err; 179 return err;
159 } else if (voltage == OUTPUT_1V8) { 180 } else if (voltage == OUTPUT_1V8) {
160 err = rtsx_pci_write_register(pcr, 181 err = rtsx_pci_write_register(pcr,
161 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B); 182 SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_1v8);
162 if (err < 0) 183 if (err < 0)
163 return err; 184 return err;
164 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24); 185 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24);
@@ -172,6 +193,7 @@ static int rts5209_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
172} 193}
173 194
174static const struct pcr_ops rts5209_pcr_ops = { 195static const struct pcr_ops rts5209_pcr_ops = {
196 .fetch_vendor_settings = rts5209_fetch_vendor_settings,
175 .extra_init_hw = rts5209_extra_init_hw, 197 .extra_init_hw = rts5209_extra_init_hw,
176 .optimize_phy = rts5209_optimize_phy, 198 .optimize_phy = rts5209_optimize_phy,
177 .turn_on_led = rts5209_turn_on_led, 199 .turn_on_led = rts5209_turn_on_led,
@@ -183,6 +205,7 @@ static const struct pcr_ops rts5209_pcr_ops = {
183 .switch_output_voltage = rts5209_switch_output_voltage, 205 .switch_output_voltage = rts5209_switch_output_voltage,
184 .cd_deglitch = NULL, 206 .cd_deglitch = NULL,
185 .conv_clk_and_div_n = NULL, 207 .conv_clk_and_div_n = NULL,
208 .force_power_down = rts5209_force_power_down,
186}; 209};
187 210
188/* SD Pull Control Enable: 211/* SD Pull Control Enable:
@@ -242,7 +265,13 @@ void rts5209_init_params(struct rtsx_pcr *pcr)
242 pcr->num_slots = 2; 265 pcr->num_slots = 2;
243 pcr->ops = &rts5209_pcr_ops; 266 pcr->ops = &rts5209_pcr_ops;
244 267
245 rts5209_init_vendor_cfg(pcr); 268 pcr->flags = 0;
269 pcr->card_drive_sel = RTS5209_CARD_DRIVE_DEFAULT;
270 pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B;
271 pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D;
272 pcr->aspm_en = ASPM_L1_EN;
273 pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 16);
274 pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5);
246 275
247 pcr->ic_version = rts5209_get_ic_version(pcr); 276 pcr->ic_version = rts5209_get_ic_version(pcr);
248 pcr->sd_pull_ctl_enable_tbl = rts5209_sd_pull_ctl_enable_tbl; 277 pcr->sd_pull_ctl_enable_tbl = rts5209_sd_pull_ctl_enable_tbl;
diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
index 164b7faa70c9..9c8eec80ceed 100644
--- a/drivers/mfd/rts5227.c
+++ b/drivers/mfd/rts5227.c
@@ -1,6 +1,6 @@
1/* Driver for Realtek PCI-Express card reader 1/* Driver for Realtek PCI-Express card reader
2 * 2 *
3 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. 3 * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License as published by the
@@ -17,10 +17,7 @@
17 * 17 *
18 * Author: 18 * Author:
19 * Wei WANG <wei_wang@realsil.com.cn> 19 * Wei WANG <wei_wang@realsil.com.cn>
20 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
21 *
22 * Roger Tseng <rogerable@realtek.com> 20 * Roger Tseng <rogerable@realtek.com>
23 * No. 2, Innovation Road II, Hsinchu Science Park, Hsinchu 300, Taiwan
24 */ 21 */
25 22
26#include <linux/module.h> 23#include <linux/module.h>
@@ -29,6 +26,73 @@
29 26
30#include "rtsx_pcr.h" 27#include "rtsx_pcr.h"
31 28
29static void rts5227_fill_driving(struct rtsx_pcr *pcr, u8 voltage)
30{
31 u8 driving_3v3[4][3] = {
32 {0x13, 0x13, 0x13},
33 {0x96, 0x96, 0x96},
34 {0x7F, 0x7F, 0x7F},
35 {0x96, 0x96, 0x96},
36 };
37 u8 driving_1v8[4][3] = {
38 {0x99, 0x99, 0x99},
39 {0xAA, 0xAA, 0xAA},
40 {0xFE, 0xFE, 0xFE},
41 {0xB3, 0xB3, 0xB3},
42 };
43 u8 (*driving)[3], drive_sel;
44
45 if (voltage == OUTPUT_3V3) {
46 driving = driving_3v3;
47 drive_sel = pcr->sd30_drive_sel_3v3;
48 } else {
49 driving = driving_1v8;
50 drive_sel = pcr->sd30_drive_sel_1v8;
51 }
52
53 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CLK_DRIVE_SEL,
54 0xFF, driving[drive_sel][0]);
55 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CMD_DRIVE_SEL,
56 0xFF, driving[drive_sel][1]);
57 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DAT_DRIVE_SEL,
58 0xFF, driving[drive_sel][2]);
59}
60
61static void rts5227_fetch_vendor_settings(struct rtsx_pcr *pcr)
62{
63 u32 reg;
64
65 rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, &reg);
66 dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
67
68 if (!rtsx_vendor_setting_valid(reg))
69 return;
70
71 pcr->aspm_en = rtsx_reg_to_aspm(reg);
72 pcr->sd30_drive_sel_1v8 = rtsx_reg_to_sd30_drive_sel_1v8(reg);
73 pcr->card_drive_sel &= 0x3F;
74 pcr->card_drive_sel |= rtsx_reg_to_card_drive_sel(reg);
75
76 rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG2, &reg);
77 dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
78 pcr->sd30_drive_sel_3v3 = rtsx_reg_to_sd30_drive_sel_3v3(reg);
79 if (rtsx_reg_check_reverse_socket(reg))
80 pcr->flags |= PCR_REVERSE_SOCKET;
81}
82
83static void rts5227_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
84{
85 /* Set relink_time to 0 */
86 rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, 0xFF, 0);
87 rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, 0xFF, 0);
88 rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0);
89
90 if (pm_state == HOST_ENTER_S3)
91 rtsx_pci_write_register(pcr, PM_CTRL3, 0x10, 0x10);
92
93 rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03);
94}
95
32static int rts5227_extra_init_hw(struct rtsx_pcr *pcr) 96static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)
33{ 97{
34 u16 cap; 98 u16 cap;
@@ -37,6 +101,8 @@ static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)
37 101
38 /* Configure GPIO as output */ 102 /* Configure GPIO as output */
39 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02); 103 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02);
104 /* Reset ASPM state to default value */
105 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, ASPM_FORCE_CTL, 0x3F, 0);
40 /* Switch LDO3318 source from DV33 to card_3v3 */ 106 /* Switch LDO3318 source from DV33 to card_3v3 */
41 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x00); 107 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x00);
42 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01); 108 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01);
@@ -48,17 +114,16 @@ static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)
48 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LTR_CTL, 0xFF, 0xA3); 114 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LTR_CTL, 0xFF, 0xA3);
49 /* Configure OBFF */ 115 /* Configure OBFF */
50 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OBFF_CFG, 0x03, 0x03); 116 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OBFF_CFG, 0x03, 0x03);
51 /* Configure force_clock_req 117 /* Configure driving */
52 * Maybe We should define 0xFF03 as some name 118 rts5227_fill_driving(pcr, OUTPUT_3V3);
53 */ 119 /* Configure force_clock_req */
54 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, 0xFF03, 0x08, 0x08); 120 if (pcr->flags & PCR_REVERSE_SOCKET)
55 /* Correct driving */ 121 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
56 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, 122 AUTOLOAD_CFG_BASE + 3, 0xB8, 0xB8);
57 SD30_CLK_DRIVE_SEL, 0xFF, 0x96); 123 else
58 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, 124 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
59 SD30_CMD_DRIVE_SEL, 0xFF, 0x96); 125 AUTOLOAD_CFG_BASE + 3, 0xB8, 0x88);
60 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, 126 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PM_CTRL3, 0x10, 0x00);
61 SD30_DAT_DRIVE_SEL, 0xFF, 0x96);
62 127
63 return rtsx_pci_send_cmd(pcr, 100); 128 return rtsx_pci_send_cmd(pcr, 100);
64} 129}
@@ -131,13 +196,11 @@ static int rts5227_card_power_off(struct rtsx_pcr *pcr, int card)
131static int rts5227_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) 196static int rts5227_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
132{ 197{
133 int err; 198 int err;
134 u8 drive_sel;
135 199
136 if (voltage == OUTPUT_3V3) { 200 if (voltage == OUTPUT_3V3) {
137 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24); 201 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24);
138 if (err < 0) 202 if (err < 0)
139 return err; 203 return err;
140 drive_sel = 0x96;
141 } else if (voltage == OUTPUT_1V8) { 204 } else if (voltage == OUTPUT_1V8) {
142 err = rtsx_pci_write_phy_register(pcr, 0x11, 0x3C02); 205 err = rtsx_pci_write_phy_register(pcr, 0x11, 0x3C02);
143 if (err < 0) 206 if (err < 0)
@@ -145,23 +208,18 @@ static int rts5227_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
145 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C80 | 0x24); 208 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C80 | 0x24);
146 if (err < 0) 209 if (err < 0)
147 return err; 210 return err;
148 drive_sel = 0xB3;
149 } else { 211 } else {
150 return -EINVAL; 212 return -EINVAL;
151 } 213 }
152 214
153 /* set pad drive */ 215 /* set pad drive */
154 rtsx_pci_init_cmd(pcr); 216 rtsx_pci_init_cmd(pcr);
155 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CLK_DRIVE_SEL, 217 rts5227_fill_driving(pcr, voltage);
156 0xFF, drive_sel);
157 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CMD_DRIVE_SEL,
158 0xFF, drive_sel);
159 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DAT_DRIVE_SEL,
160 0xFF, drive_sel);
161 return rtsx_pci_send_cmd(pcr, 100); 218 return rtsx_pci_send_cmd(pcr, 100);
162} 219}
163 220
164static const struct pcr_ops rts5227_pcr_ops = { 221static const struct pcr_ops rts5227_pcr_ops = {
222 .fetch_vendor_settings = rts5227_fetch_vendor_settings,
165 .extra_init_hw = rts5227_extra_init_hw, 223 .extra_init_hw = rts5227_extra_init_hw,
166 .optimize_phy = rts5227_optimize_phy, 224 .optimize_phy = rts5227_optimize_phy,
167 .turn_on_led = rts5227_turn_on_led, 225 .turn_on_led = rts5227_turn_on_led,
@@ -173,6 +231,7 @@ static const struct pcr_ops rts5227_pcr_ops = {
173 .switch_output_voltage = rts5227_switch_output_voltage, 231 .switch_output_voltage = rts5227_switch_output_voltage,
174 .cd_deglitch = NULL, 232 .cd_deglitch = NULL,
175 .conv_clk_and_div_n = NULL, 233 .conv_clk_and_div_n = NULL,
234 .force_power_down = rts5227_force_power_down,
176}; 235};
177 236
178/* SD Pull Control Enable: 237/* SD Pull Control Enable:
@@ -227,6 +286,14 @@ void rts5227_init_params(struct rtsx_pcr *pcr)
227 pcr->num_slots = 2; 286 pcr->num_slots = 2;
228 pcr->ops = &rts5227_pcr_ops; 287 pcr->ops = &rts5227_pcr_ops;
229 288
289 pcr->flags = 0;
290 pcr->card_drive_sel = RTSX_CARD_DRIVE_DEFAULT;
291 pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B;
292 pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B;
293 pcr->aspm_en = ASPM_L1_EN;
294 pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 15);
295 pcr->rx_initial_phase = SET_CLOCK_PHASE(30, 7, 7);
296
230 pcr->sd_pull_ctl_enable_tbl = rts5227_sd_pull_ctl_enable_tbl; 297 pcr->sd_pull_ctl_enable_tbl = rts5227_sd_pull_ctl_enable_tbl;
231 pcr->sd_pull_ctl_disable_tbl = rts5227_sd_pull_ctl_disable_tbl; 298 pcr->sd_pull_ctl_disable_tbl = rts5227_sd_pull_ctl_disable_tbl;
232 pcr->ms_pull_ctl_enable_tbl = rts5227_ms_pull_ctl_enable_tbl; 299 pcr->ms_pull_ctl_enable_tbl = rts5227_ms_pull_ctl_enable_tbl;
diff --git a/drivers/mfd/rts5229.c b/drivers/mfd/rts5229.c
index 58af4dbe3586..6353f5df087a 100644
--- a/drivers/mfd/rts5229.c
+++ b/drivers/mfd/rts5229.c
@@ -1,6 +1,6 @@
1/* Driver for Realtek PCI-Express card reader 1/* Driver for Realtek PCI-Express card reader
2 * 2 *
3 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. 3 * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License as published by the
@@ -17,7 +17,6 @@
17 * 17 *
18 * Author: 18 * Author:
19 * Wei WANG <wei_wang@realsil.com.cn> 19 * Wei WANG <wei_wang@realsil.com.cn>
20 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
21 */ 20 */
22 21
23#include <linux/module.h> 22#include <linux/module.h>
@@ -34,17 +33,51 @@ static u8 rts5229_get_ic_version(struct rtsx_pcr *pcr)
34 return val & 0x0F; 33 return val & 0x0F;
35} 34}
36 35
36static void rts5229_fetch_vendor_settings(struct rtsx_pcr *pcr)
37{
38 u32 reg;
39
40 rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, &reg);
41 dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
42
43 if (!rtsx_vendor_setting_valid(reg))
44 return;
45
46 pcr->aspm_en = rtsx_reg_to_aspm(reg);
47 pcr->sd30_drive_sel_1v8 =
48 map_sd_drive(rtsx_reg_to_sd30_drive_sel_1v8(reg));
49 pcr->card_drive_sel &= 0x3F;
50 pcr->card_drive_sel |= rtsx_reg_to_card_drive_sel(reg);
51
52 rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG2, &reg);
53 dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
54 pcr->sd30_drive_sel_3v3 =
55 map_sd_drive(rtsx_reg_to_sd30_drive_sel_3v3(reg));
56}
57
58static void rts5229_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
59{
60 rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03);
61}
62
37static int rts5229_extra_init_hw(struct rtsx_pcr *pcr) 63static int rts5229_extra_init_hw(struct rtsx_pcr *pcr)
38{ 64{
39 rtsx_pci_init_cmd(pcr); 65 rtsx_pci_init_cmd(pcr);
40 66
41 /* Configure GPIO as output */ 67 /* Configure GPIO as output */
42 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02); 68 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02);
69 /* Reset ASPM state to default value */
70 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, ASPM_FORCE_CTL, 0x3F, 0);
71 /* Force CLKREQ# PIN to drive 0 to request clock */
72 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0x08, 0x08);
43 /* Switch LDO3318 source from DV33 to card_3v3 */ 73 /* Switch LDO3318 source from DV33 to card_3v3 */
44 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x00); 74 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x00);
45 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01); 75 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01);
46 /* LED shine disabled, set initial shine cycle period */ 76 /* LED shine disabled, set initial shine cycle period */
47 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OLT_LED_CTL, 0x0F, 0x02); 77 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OLT_LED_CTL, 0x0F, 0x02);
78 /* Configure driving */
79 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DRIVE_SEL,
80 0xFF, pcr->sd30_drive_sel_3v3);
48 81
49 return rtsx_pci_send_cmd(pcr, 100); 82 return rtsx_pci_send_cmd(pcr, 100);
50} 83}
@@ -110,7 +143,7 @@ static int rts5229_card_power_off(struct rtsx_pcr *pcr, int card)
110 SD_POWER_MASK | PMOS_STRG_MASK, 143 SD_POWER_MASK | PMOS_STRG_MASK,
111 SD_POWER_OFF | PMOS_STRG_400mA); 144 SD_POWER_OFF | PMOS_STRG_400mA);
112 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL, 145 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL,
113 LDO3318_PWR_MASK, 0X00); 146 LDO3318_PWR_MASK, 0x00);
114 return rtsx_pci_send_cmd(pcr, 100); 147 return rtsx_pci_send_cmd(pcr, 100);
115} 148}
116 149
@@ -120,7 +153,7 @@ static int rts5229_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
120 153
121 if (voltage == OUTPUT_3V3) { 154 if (voltage == OUTPUT_3V3) {
122 err = rtsx_pci_write_register(pcr, 155 err = rtsx_pci_write_register(pcr,
123 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_D); 156 SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_3v3);
124 if (err < 0) 157 if (err < 0)
125 return err; 158 return err;
126 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24); 159 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24);
@@ -128,7 +161,7 @@ static int rts5229_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
128 return err; 161 return err;
129 } else if (voltage == OUTPUT_1V8) { 162 } else if (voltage == OUTPUT_1V8) {
130 err = rtsx_pci_write_register(pcr, 163 err = rtsx_pci_write_register(pcr,
131 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B); 164 SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_1v8);
132 if (err < 0) 165 if (err < 0)
133 return err; 166 return err;
134 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24); 167 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24);
@@ -142,6 +175,7 @@ static int rts5229_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
142} 175}
143 176
144static const struct pcr_ops rts5229_pcr_ops = { 177static const struct pcr_ops rts5229_pcr_ops = {
178 .fetch_vendor_settings = rts5229_fetch_vendor_settings,
145 .extra_init_hw = rts5229_extra_init_hw, 179 .extra_init_hw = rts5229_extra_init_hw,
146 .optimize_phy = rts5229_optimize_phy, 180 .optimize_phy = rts5229_optimize_phy,
147 .turn_on_led = rts5229_turn_on_led, 181 .turn_on_led = rts5229_turn_on_led,
@@ -153,6 +187,7 @@ static const struct pcr_ops rts5229_pcr_ops = {
153 .switch_output_voltage = rts5229_switch_output_voltage, 187 .switch_output_voltage = rts5229_switch_output_voltage,
154 .cd_deglitch = NULL, 188 .cd_deglitch = NULL,
155 .conv_clk_and_div_n = NULL, 189 .conv_clk_and_div_n = NULL,
190 .force_power_down = rts5229_force_power_down,
156}; 191};
157 192
158/* SD Pull Control Enable: 193/* SD Pull Control Enable:
@@ -221,6 +256,14 @@ void rts5229_init_params(struct rtsx_pcr *pcr)
221 pcr->num_slots = 2; 256 pcr->num_slots = 2;
222 pcr->ops = &rts5229_pcr_ops; 257 pcr->ops = &rts5229_pcr_ops;
223 258
259 pcr->flags = 0;
260 pcr->card_drive_sel = RTSX_CARD_DRIVE_DEFAULT;
261 pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B;
262 pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D;
263 pcr->aspm_en = ASPM_L1_EN;
264 pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 15);
265 pcr->rx_initial_phase = SET_CLOCK_PHASE(30, 6, 6);
266
224 pcr->ic_version = rts5229_get_ic_version(pcr); 267 pcr->ic_version = rts5229_get_ic_version(pcr);
225 if (pcr->ic_version == IC_VER_C) { 268 if (pcr->ic_version == IC_VER_C) {
226 pcr->sd_pull_ctl_enable_tbl = rts5229_sd_pull_ctl_enable_tbl2; 269 pcr->sd_pull_ctl_enable_tbl = rts5229_sd_pull_ctl_enable_tbl2;
diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
index 15dc848bc081..3b835f593e35 100644
--- a/drivers/mfd/rts5249.c
+++ b/drivers/mfd/rts5249.c
@@ -17,7 +17,6 @@
17 * 17 *
18 * Author: 18 * Author:
19 * Wei WANG <wei_wang@realsil.com.cn> 19 * Wei WANG <wei_wang@realsil.com.cn>
20 * No. 128, West Shenhu Road, Suzhou Industry Park, Suzhou, China
21 */ 20 */
22 21
23#include <linux/module.h> 22#include <linux/module.h>
@@ -34,24 +33,95 @@ static u8 rts5249_get_ic_version(struct rtsx_pcr *pcr)
34 return val & 0x0F; 33 return val & 0x0F;
35} 34}
36 35
36static void rts5249_fill_driving(struct rtsx_pcr *pcr, u8 voltage)
37{
38 u8 driving_3v3[4][3] = {
39 {0x11, 0x11, 0x11},
40 {0x55, 0x55, 0x5C},
41 {0x99, 0x99, 0x92},
42 {0x99, 0x99, 0x92},
43 };
44 u8 driving_1v8[4][3] = {
45 {0x3C, 0x3C, 0x3C},
46 {0xB3, 0xB3, 0xB3},
47 {0xFE, 0xFE, 0xFE},
48 {0xC4, 0xC4, 0xC4},
49 };
50 u8 (*driving)[3], drive_sel;
51
52 if (voltage == OUTPUT_3V3) {
53 driving = driving_3v3;
54 drive_sel = pcr->sd30_drive_sel_3v3;
55 } else {
56 driving = driving_1v8;
57 drive_sel = pcr->sd30_drive_sel_1v8;
58 }
59
60 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CLK_DRIVE_SEL,
61 0xFF, driving[drive_sel][0]);
62 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CMD_DRIVE_SEL,
63 0xFF, driving[drive_sel][1]);
64 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DAT_DRIVE_SEL,
65 0xFF, driving[drive_sel][2]);
66}
67
68static void rts5249_fetch_vendor_settings(struct rtsx_pcr *pcr)
69{
70 u32 reg;
71
72 rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, &reg);
73 dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
74
75 if (!rtsx_vendor_setting_valid(reg))
76 return;
77
78 pcr->aspm_en = rtsx_reg_to_aspm(reg);
79 pcr->sd30_drive_sel_1v8 = rtsx_reg_to_sd30_drive_sel_1v8(reg);
80 pcr->card_drive_sel &= 0x3F;
81 pcr->card_drive_sel |= rtsx_reg_to_card_drive_sel(reg);
82
83 rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG2, &reg);
84 dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
85 pcr->sd30_drive_sel_3v3 = rtsx_reg_to_sd30_drive_sel_3v3(reg);
86 if (rtsx_reg_check_reverse_socket(reg))
87 pcr->flags |= PCR_REVERSE_SOCKET;
88}
89
90static void rts5249_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
91{
92 /* Set relink_time to 0 */
93 rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, 0xFF, 0);
94 rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, 0xFF, 0);
95 rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0);
96
97 if (pm_state == HOST_ENTER_S3)
98 rtsx_pci_write_register(pcr, PM_CTRL3, 0x10, 0x10);
99
100 rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03);
101}
102
37static int rts5249_extra_init_hw(struct rtsx_pcr *pcr) 103static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)
38{ 104{
39 rtsx_pci_init_cmd(pcr); 105 rtsx_pci_init_cmd(pcr);
40 106
41 /* Configure GPIO as output */ 107 /* Configure GPIO as output */
42 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02); 108 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02);
109 /* Reset ASPM state to default value */
110 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, ASPM_FORCE_CTL, 0x3F, 0);
43 /* Switch LDO3318 source from DV33 to card_3v3 */ 111 /* Switch LDO3318 source from DV33 to card_3v3 */
44 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x00); 112 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x00);
45 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01); 113 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01);
46 /* LED shine disabled, set initial shine cycle period */ 114 /* LED shine disabled, set initial shine cycle period */
47 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OLT_LED_CTL, 0x0F, 0x02); 115 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OLT_LED_CTL, 0x0F, 0x02);
48 /* Correct driving */ 116 /* Configure driving */
49 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, 117 rts5249_fill_driving(pcr, OUTPUT_3V3);
50 SD30_CLK_DRIVE_SEL, 0xFF, 0x99); 118 if (pcr->flags & PCR_REVERSE_SOCKET)
51 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, 119 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
52 SD30_CMD_DRIVE_SEL, 0xFF, 0x99); 120 AUTOLOAD_CFG_BASE + 3, 0xB0, 0xB0);
53 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, 121 else
54 SD30_DAT_DRIVE_SEL, 0xFF, 0x92); 122 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
123 AUTOLOAD_CFG_BASE + 3, 0xB0, 0x80);
124 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PM_CTRL3, 0x10, 0x00);
55 125
56 return rtsx_pci_send_cmd(pcr, 100); 126 return rtsx_pci_send_cmd(pcr, 100);
57} 127}
@@ -129,15 +199,11 @@ static int rts5249_card_power_off(struct rtsx_pcr *pcr, int card)
129static int rts5249_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) 199static int rts5249_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
130{ 200{
131 int err; 201 int err;
132 u8 clk_drive, cmd_drive, dat_drive;
133 202
134 if (voltage == OUTPUT_3V3) { 203 if (voltage == OUTPUT_3V3) {
135 err = rtsx_pci_write_phy_register(pcr, PHY_TUNE, 0x4FC0 | 0x24); 204 err = rtsx_pci_write_phy_register(pcr, PHY_TUNE, 0x4FC0 | 0x24);
136 if (err < 0) 205 if (err < 0)
137 return err; 206 return err;
138 clk_drive = 0x99;
139 cmd_drive = 0x99;
140 dat_drive = 0x92;
141 } else if (voltage == OUTPUT_1V8) { 207 } else if (voltage == OUTPUT_1V8) {
142 err = rtsx_pci_write_phy_register(pcr, PHY_BACR, 0x3C02); 208 err = rtsx_pci_write_phy_register(pcr, PHY_BACR, 0x3C02);
143 if (err < 0) 209 if (err < 0)
@@ -145,25 +211,18 @@ static int rts5249_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
145 err = rtsx_pci_write_phy_register(pcr, PHY_TUNE, 0x4C40 | 0x24); 211 err = rtsx_pci_write_phy_register(pcr, PHY_TUNE, 0x4C40 | 0x24);
146 if (err < 0) 212 if (err < 0)
147 return err; 213 return err;
148 clk_drive = 0xb3;
149 cmd_drive = 0xb3;
150 dat_drive = 0xb3;
151 } else { 214 } else {
152 return -EINVAL; 215 return -EINVAL;
153 } 216 }
154 217
155 /* set pad drive */ 218 /* set pad drive */
156 rtsx_pci_init_cmd(pcr); 219 rtsx_pci_init_cmd(pcr);
157 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CLK_DRIVE_SEL, 220 rts5249_fill_driving(pcr, voltage);
158 0xFF, clk_drive);
159 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CMD_DRIVE_SEL,
160 0xFF, cmd_drive);
161 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DAT_DRIVE_SEL,
162 0xFF, dat_drive);
163 return rtsx_pci_send_cmd(pcr, 100); 221 return rtsx_pci_send_cmd(pcr, 100);
164} 222}
165 223
166static const struct pcr_ops rts5249_pcr_ops = { 224static const struct pcr_ops rts5249_pcr_ops = {
225 .fetch_vendor_settings = rts5249_fetch_vendor_settings,
167 .extra_init_hw = rts5249_extra_init_hw, 226 .extra_init_hw = rts5249_extra_init_hw,
168 .optimize_phy = rts5249_optimize_phy, 227 .optimize_phy = rts5249_optimize_phy,
169 .turn_on_led = rts5249_turn_on_led, 228 .turn_on_led = rts5249_turn_on_led,
@@ -173,6 +232,7 @@ static const struct pcr_ops rts5249_pcr_ops = {
173 .card_power_on = rts5249_card_power_on, 232 .card_power_on = rts5249_card_power_on,
174 .card_power_off = rts5249_card_power_off, 233 .card_power_off = rts5249_card_power_off,
175 .switch_output_voltage = rts5249_switch_output_voltage, 234 .switch_output_voltage = rts5249_switch_output_voltage,
235 .force_power_down = rts5249_force_power_down,
176}; 236};
177 237
178/* SD Pull Control Enable: 238/* SD Pull Control Enable:
@@ -233,6 +293,14 @@ void rts5249_init_params(struct rtsx_pcr *pcr)
233 pcr->num_slots = 2; 293 pcr->num_slots = 2;
234 pcr->ops = &rts5249_pcr_ops; 294 pcr->ops = &rts5249_pcr_ops;
235 295
296 pcr->flags = 0;
297 pcr->card_drive_sel = RTSX_CARD_DRIVE_DEFAULT;
298 pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_C;
299 pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B;
300 pcr->aspm_en = ASPM_L1_EN;
301 pcr->tx_initial_phase = SET_CLOCK_PHASE(1, 29, 16);
302 pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5);
303
236 pcr->ic_version = rts5249_get_ic_version(pcr); 304 pcr->ic_version = rts5249_get_ic_version(pcr);
237 pcr->sd_pull_ctl_enable_tbl = rts5249_sd_pull_ctl_enable_tbl; 305 pcr->sd_pull_ctl_enable_tbl = rts5249_sd_pull_ctl_enable_tbl;
238 pcr->sd_pull_ctl_disable_tbl = rts5249_sd_pull_ctl_disable_tbl; 306 pcr->sd_pull_ctl_disable_tbl = rts5249_sd_pull_ctl_disable_tbl;
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index dd186c4103c1..e6ae7720f9e1 100644
--- a/drivers/mfd/rtsx_pcr.c
+++ b/drivers/mfd/rtsx_pcr.c
@@ -1,6 +1,6 @@
1/* Driver for Realtek PCI-Express card reader 1/* Driver for Realtek PCI-Express card reader
2 * 2 *
3 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. 3 * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License as published by the
@@ -17,7 +17,6 @@
17 * 17 *
18 * Author: 18 * Author:
19 * Wei WANG <wei_wang@realsil.com.cn> 19 * Wei WANG <wei_wang@realsil.com.cn>
20 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
21 */ 20 */
22 21
23#include <linux/pci.h> 22#include <linux/pci.h>
@@ -73,6 +72,9 @@ void rtsx_pci_start_run(struct rtsx_pcr *pcr)
73 pcr->state = PDEV_STAT_RUN; 72 pcr->state = PDEV_STAT_RUN;
74 if (pcr->ops->enable_auto_blink) 73 if (pcr->ops->enable_auto_blink)
75 pcr->ops->enable_auto_blink(pcr); 74 pcr->ops->enable_auto_blink(pcr);
75
76 if (pcr->aspm_en)
77 rtsx_pci_write_config_byte(pcr, LCTLR, 0);
76 } 78 }
77 79
78 mod_delayed_work(system_wq, &pcr->idle_work, msecs_to_jiffies(200)); 80 mod_delayed_work(system_wq, &pcr->idle_work, msecs_to_jiffies(200));
@@ -717,7 +719,7 @@ int rtsx_pci_card_exclusive_check(struct rtsx_pcr *pcr, int card)
717 [RTSX_MS_CARD] = MS_EXIST 719 [RTSX_MS_CARD] = MS_EXIST
718 }; 720 };
719 721
720 if (!pcr->ms_pmos) { 722 if (!(pcr->flags & PCR_MS_PMOS)) {
721 /* When using single PMOS, accessing card is not permitted 723 /* When using single PMOS, accessing card is not permitted
722 * if the existing card is not the designated one. 724 * if the existing card is not the designated one.
723 */ 725 */
@@ -918,9 +920,27 @@ static void rtsx_pci_idle_work(struct work_struct *work)
918 if (pcr->ops->turn_off_led) 920 if (pcr->ops->turn_off_led)
919 pcr->ops->turn_off_led(pcr); 921 pcr->ops->turn_off_led(pcr);
920 922
923 if (pcr->aspm_en)
924 rtsx_pci_write_config_byte(pcr, LCTLR, pcr->aspm_en);
925
921 mutex_unlock(&pcr->pcr_mutex); 926 mutex_unlock(&pcr->pcr_mutex);
922} 927}
923 928
929static void rtsx_pci_power_off(struct rtsx_pcr *pcr, u8 pm_state)
930{
931 if (pcr->ops->turn_off_led)
932 pcr->ops->turn_off_led(pcr);
933
934 rtsx_pci_writel(pcr, RTSX_BIER, 0);
935 pcr->bier = 0;
936
937 rtsx_pci_write_register(pcr, PETXCFG, 0x08, 0x08);
938 rtsx_pci_write_register(pcr, HOST_SLEEP_STATE, 0x03, pm_state);
939
940 if (pcr->ops->force_power_down)
941 pcr->ops->force_power_down(pcr, pm_state);
942}
943
924static int rtsx_pci_init_hw(struct rtsx_pcr *pcr) 944static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)
925{ 945{
926 int err; 946 int err;
@@ -951,13 +971,11 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)
951 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, HOST_SLEEP_STATE, 0x03, 0x00); 971 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, HOST_SLEEP_STATE, 0x03, 0x00);
952 /* Disable card clock */ 972 /* Disable card clock */
953 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_CLK_EN, 0x1E, 0); 973 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_CLK_EN, 0x1E, 0);
954 /* Reset ASPM state to default value */
955 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, ASPM_FORCE_CTL, 0x3F, 0);
956 /* Reset delink mode */ 974 /* Reset delink mode */
957 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CHANGE_LINK_STATE, 0x0A, 0); 975 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CHANGE_LINK_STATE, 0x0A, 0);
958 /* Card driving select */ 976 /* Card driving select */
959 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DRIVE_SEL, 977 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_DRIVE_SEL,
960 0x07, DRIVER_TYPE_D); 978 0xFF, pcr->card_drive_sel);
961 /* Enable SSC Clock */ 979 /* Enable SSC Clock */
962 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_CTL1, 980 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_CTL1,
963 0xFF, SSC_8X_EN | SSC_SEL_4M); 981 0xFF, SSC_8X_EN | SSC_SEL_4M);
@@ -982,13 +1000,13 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)
982 * 0: ELBI interrupt flag[31:22] & [7:0] only can be write clear 1000 * 0: ELBI interrupt flag[31:22] & [7:0] only can be write clear
983 */ 1001 */
984 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, NFTS_TX_CTRL, 0x02, 0); 1002 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, NFTS_TX_CTRL, 0x02, 0);
985 /* Force CLKREQ# PIN to drive 0 to request clock */
986 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0x08, 0x08);
987 1003
988 err = rtsx_pci_send_cmd(pcr, 100); 1004 err = rtsx_pci_send_cmd(pcr, 100);
989 if (err < 0) 1005 if (err < 0)
990 return err; 1006 return err;
991 1007
1008 rtsx_pci_write_config_byte(pcr, LCTLR, 0);
1009
992 /* Enable clk_request_n to enable clock power management */ 1010 /* Enable clk_request_n to enable clock power management */
993 rtsx_pci_write_config_byte(pcr, 0x81, 1); 1011 rtsx_pci_write_config_byte(pcr, 0x81, 1);
994 /* Enter L1 when host tx idle */ 1012 /* Enter L1 when host tx idle */
@@ -1053,6 +1071,18 @@ static int rtsx_pci_init_chip(struct rtsx_pcr *pcr)
1053 if (!pcr->slots) 1071 if (!pcr->slots)
1054 return -ENOMEM; 1072 return -ENOMEM;
1055 1073
1074 if (pcr->ops->fetch_vendor_settings)
1075 pcr->ops->fetch_vendor_settings(pcr);
1076
1077 dev_dbg(&(pcr->pci->dev), "pcr->aspm_en = 0x%x\n", pcr->aspm_en);
1078 dev_dbg(&(pcr->pci->dev), "pcr->sd30_drive_sel_1v8 = 0x%x\n",
1079 pcr->sd30_drive_sel_1v8);
1080 dev_dbg(&(pcr->pci->dev), "pcr->sd30_drive_sel_3v3 = 0x%x\n",
1081 pcr->sd30_drive_sel_3v3);
1082 dev_dbg(&(pcr->pci->dev), "pcr->card_drive_sel = 0x%x\n",
1083 pcr->card_drive_sel);
1084 dev_dbg(&(pcr->pci->dev), "pcr->flags = 0x%x\n", pcr->flags);
1085
1056 pcr->state = PDEV_STAT_IDLE; 1086 pcr->state = PDEV_STAT_IDLE;
1057 err = rtsx_pci_init_hw(pcr); 1087 err = rtsx_pci_init_hw(pcr);
1058 if (err < 0) { 1088 if (err < 0) {
@@ -1235,7 +1265,6 @@ static int rtsx_pci_suspend(struct pci_dev *pcidev, pm_message_t state)
1235{ 1265{
1236 struct pcr_handle *handle; 1266 struct pcr_handle *handle;
1237 struct rtsx_pcr *pcr; 1267 struct rtsx_pcr *pcr;
1238 int ret = 0;
1239 1268
1240 dev_dbg(&(pcidev->dev), "--> %s\n", __func__); 1269 dev_dbg(&(pcidev->dev), "--> %s\n", __func__);
1241 1270
@@ -1247,14 +1276,7 @@ static int rtsx_pci_suspend(struct pci_dev *pcidev, pm_message_t state)
1247 1276
1248 mutex_lock(&pcr->pcr_mutex); 1277 mutex_lock(&pcr->pcr_mutex);
1249 1278
1250 if (pcr->ops->turn_off_led) 1279 rtsx_pci_power_off(pcr, HOST_ENTER_S3);
1251 pcr->ops->turn_off_led(pcr);
1252
1253 rtsx_pci_writel(pcr, RTSX_BIER, 0);
1254 pcr->bier = 0;
1255
1256 rtsx_pci_write_register(pcr, PETXCFG, 0x08, 0x08);
1257 rtsx_pci_write_register(pcr, HOST_SLEEP_STATE, 0x03, 0x02);
1258 1280
1259 pci_save_state(pcidev); 1281 pci_save_state(pcidev);
1260 pci_enable_wake(pcidev, pci_choose_state(pcidev, state), 0); 1282 pci_enable_wake(pcidev, pci_choose_state(pcidev, state), 0);
@@ -1262,7 +1284,7 @@ static int rtsx_pci_suspend(struct pci_dev *pcidev, pm_message_t state)
1262 pci_set_power_state(pcidev, pci_choose_state(pcidev, state)); 1284 pci_set_power_state(pcidev, pci_choose_state(pcidev, state));
1263 1285
1264 mutex_unlock(&pcr->pcr_mutex); 1286 mutex_unlock(&pcr->pcr_mutex);
1265 return ret; 1287 return 0;
1266} 1288}
1267 1289
1268static int rtsx_pci_resume(struct pci_dev *pcidev) 1290static int rtsx_pci_resume(struct pci_dev *pcidev)
@@ -1300,10 +1322,25 @@ out:
1300 return ret; 1322 return ret;
1301} 1323}
1302 1324
1325static void rtsx_pci_shutdown(struct pci_dev *pcidev)
1326{
1327 struct pcr_handle *handle;
1328 struct rtsx_pcr *pcr;
1329
1330 dev_dbg(&(pcidev->dev), "--> %s\n", __func__);
1331
1332 handle = pci_get_drvdata(pcidev);
1333 pcr = handle->pcr;
1334 rtsx_pci_power_off(pcr, HOST_ENTER_S1);
1335
1336 pci_disable_device(pcidev);
1337}
1338
1303#else /* CONFIG_PM */ 1339#else /* CONFIG_PM */
1304 1340
1305#define rtsx_pci_suspend NULL 1341#define rtsx_pci_suspend NULL
1306#define rtsx_pci_resume NULL 1342#define rtsx_pci_resume NULL
1343#define rtsx_pci_shutdown NULL
1307 1344
1308#endif /* CONFIG_PM */ 1345#endif /* CONFIG_PM */
1309 1346
@@ -1314,6 +1351,7 @@ static struct pci_driver rtsx_pci_driver = {
1314 .remove = rtsx_pci_remove, 1351 .remove = rtsx_pci_remove,
1315 .suspend = rtsx_pci_suspend, 1352 .suspend = rtsx_pci_suspend,
1316 .resume = rtsx_pci_resume, 1353 .resume = rtsx_pci_resume,
1354 .shutdown = rtsx_pci_shutdown,
1317}; 1355};
1318module_pci_driver(rtsx_pci_driver); 1356module_pci_driver(rtsx_pci_driver);
1319 1357
diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h
index c0cac7e8972f..947e79b05ceb 100644
--- a/drivers/mfd/rtsx_pcr.h
+++ b/drivers/mfd/rtsx_pcr.h
@@ -1,6 +1,6 @@
1/* Driver for Realtek PCI-Express card reader 1/* Driver for Realtek PCI-Express card reader
2 * 2 *
3 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. 3 * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License as published by the
@@ -17,7 +17,6 @@
17 * 17 *
18 * Author: 18 * Author:
19 * Wei WANG <wei_wang@realsil.com.cn> 19 * Wei WANG <wei_wang@realsil.com.cn>
20 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
21 */ 20 */
22 21
23#ifndef __RTSX_PCR_H 22#ifndef __RTSX_PCR_H
@@ -35,4 +34,33 @@ void rts5227_init_params(struct rtsx_pcr *pcr);
35void rts5249_init_params(struct rtsx_pcr *pcr); 34void rts5249_init_params(struct rtsx_pcr *pcr);
36void rtl8411b_init_params(struct rtsx_pcr *pcr); 35void rtl8411b_init_params(struct rtsx_pcr *pcr);
37 36
37static inline u8 map_sd_drive(int idx)
38{
39 u8 sd_drive[4] = {
40 0x01, /* Type D */
41 0x02, /* Type C */
42 0x05, /* Type A */
43 0x03 /* Type B */
44 };
45
46 return sd_drive[idx];
47}
48
49#define rtsx_vendor_setting_valid(reg) (!((reg) & 0x1000000))
50#define rts5209_vendor_setting1_valid(reg) (!((reg) & 0x80))
51#define rts5209_vendor_setting2_valid(reg) ((reg) & 0x80)
52
53#define rtsx_reg_to_aspm(reg) (((reg) >> 28) & 0x03)
54#define rtsx_reg_to_sd30_drive_sel_1v8(reg) (((reg) >> 26) & 0x03)
55#define rtsx_reg_to_sd30_drive_sel_3v3(reg) (((reg) >> 5) & 0x03)
56#define rtsx_reg_to_card_drive_sel(reg) ((((reg) >> 25) & 0x01) << 6)
57#define rtsx_reg_check_reverse_socket(reg) ((reg) & 0x4000)
58#define rts5209_reg_to_aspm(reg) (((reg) >> 5) & 0x03)
59#define rts5209_reg_check_ms_pmos(reg) (!((reg) & 0x08))
60#define rts5209_reg_to_sd30_drive_sel_1v8(reg) (((reg) >> 3) & 0x07)
61#define rts5209_reg_to_sd30_drive_sel_3v3(reg) ((reg) & 0x07)
62#define rts5209_reg_to_card_drive_sel(reg) ((reg) >> 8)
63#define rtl8411_reg_to_sd30_drive_sel_3v3(reg) (((reg) >> 5) & 0x07)
64#define rtl8411b_reg_to_sd30_drive_sel_3v3(reg) ((reg) & 0x03)
65
38#endif 66#endif
diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
index 79767681483a..f530e4b73f19 100644
--- a/drivers/mfd/sec-core.c
+++ b/drivers/mfd/sec-core.c
@@ -61,7 +61,9 @@ static struct mfd_cell s5m8767_devs[] = {
61static struct mfd_cell s2mps11_devs[] = { 61static struct mfd_cell s2mps11_devs[] = {
62 { 62 {
63 .name = "s2mps11-pmic", 63 .name = "s2mps11-pmic",
64 }, 64 }, {
65 .name = "s2mps11-clk",
66 }
65}; 67};
66 68
67#ifdef CONFIG_OF 69#ifdef CONFIG_OF
@@ -69,6 +71,9 @@ static struct of_device_id sec_dt_match[] = {
69 { .compatible = "samsung,s5m8767-pmic", 71 { .compatible = "samsung,s5m8767-pmic",
70 .data = (void *)S5M8767X, 72 .data = (void *)S5M8767X,
71 }, 73 },
74 { .compatible = "samsung,s2mps11-pmic",
75 .data = (void *)S2MPS11X,
76 },
72 {}, 77 {},
73}; 78};
74#endif 79#endif
@@ -103,6 +108,31 @@ int sec_reg_update(struct sec_pmic_dev *sec_pmic, u8 reg, u8 val, u8 mask)
103} 108}
104EXPORT_SYMBOL_GPL(sec_reg_update); 109EXPORT_SYMBOL_GPL(sec_reg_update);
105 110
111static bool s2mps11_volatile(struct device *dev, unsigned int reg)
112{
113 switch (reg) {
114 case S2MPS11_REG_INT1M:
115 case S2MPS11_REG_INT2M:
116 case S2MPS11_REG_INT3M:
117 return false;
118 default:
119 return true;
120 }
121}
122
123static bool s5m8763_volatile(struct device *dev, unsigned int reg)
124{
125 switch (reg) {
126 case S5M8763_REG_IRQM1:
127 case S5M8763_REG_IRQM2:
128 case S5M8763_REG_IRQM3:
129 case S5M8763_REG_IRQM4:
130 return false;
131 default:
132 return true;
133 }
134}
135
106static struct regmap_config sec_regmap_config = { 136static struct regmap_config sec_regmap_config = {
107 .reg_bits = 8, 137 .reg_bits = 8,
108 .val_bits = 8, 138 .val_bits = 8,
@@ -113,6 +143,8 @@ static struct regmap_config s2mps11_regmap_config = {
113 .val_bits = 8, 143 .val_bits = 8,
114 144
115 .max_register = S2MPS11_REG_L38CTRL, 145 .max_register = S2MPS11_REG_L38CTRL,
146 .volatile_reg = s2mps11_volatile,
147 .cache_type = REGCACHE_FLAT,
116}; 148};
117 149
118static struct regmap_config s5m8763_regmap_config = { 150static struct regmap_config s5m8763_regmap_config = {
@@ -120,6 +152,8 @@ static struct regmap_config s5m8763_regmap_config = {
120 .val_bits = 8, 152 .val_bits = 8,
121 153
122 .max_register = S5M8763_REG_LBCNFG2, 154 .max_register = S5M8763_REG_LBCNFG2,
155 .volatile_reg = s5m8763_volatile,
156 .cache_type = REGCACHE_FLAT,
123}; 157};
124 158
125static struct regmap_config s5m8767_regmap_config = { 159static struct regmap_config s5m8767_regmap_config = {
@@ -127,6 +161,8 @@ static struct regmap_config s5m8767_regmap_config = {
127 .val_bits = 8, 161 .val_bits = 8,
128 162
129 .max_register = S5M8767_REG_LDO28CTRL, 163 .max_register = S5M8767_REG_LDO28CTRL,
164 .volatile_reg = s2mps11_volatile,
165 .cache_type = REGCACHE_FLAT,
130}; 166};
131 167
132#ifdef CONFIG_OF 168#ifdef CONFIG_OF
@@ -182,7 +218,7 @@ static inline int sec_i2c_get_driver_data(struct i2c_client *i2c,
182static int sec_pmic_probe(struct i2c_client *i2c, 218static int sec_pmic_probe(struct i2c_client *i2c,
183 const struct i2c_device_id *id) 219 const struct i2c_device_id *id)
184{ 220{
185 struct sec_platform_data *pdata = i2c->dev.platform_data; 221 struct sec_platform_data *pdata = dev_get_platdata(&i2c->dev);
186 const struct regmap_config *regmap; 222 const struct regmap_config *regmap;
187 struct sec_pmic_dev *sec_pmic; 223 struct sec_pmic_dev *sec_pmic;
188 int ret; 224 int ret;
diff --git a/drivers/mfd/si476x-i2c.c b/drivers/mfd/si476x-i2c.c
index f5bc8e4bd4bf..0e4a76daf187 100644
--- a/drivers/mfd/si476x-i2c.c
+++ b/drivers/mfd/si476x-i2c.c
@@ -718,7 +718,7 @@ static int si476x_core_probe(struct i2c_client *client,
718 atomic_set(&core->is_alive, 0); 718 atomic_set(&core->is_alive, 0);
719 core->power_state = SI476X_POWER_DOWN; 719 core->power_state = SI476X_POWER_DOWN;
720 720
721 pdata = client->dev.platform_data; 721 pdata = dev_get_platdata(&client->dev);
722 if (pdata) { 722 if (pdata) {
723 memcpy(&core->power_up_parameters, 723 memcpy(&core->power_up_parameters,
724 &pdata->power_up_parameters, 724 &pdata->power_up_parameters,
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 9816c232e583..33f040c558d0 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -840,7 +840,7 @@ static int sm501_register_uart(struct sm501_devdata *sm, int devices)
840 if (!pdev) 840 if (!pdev)
841 return -ENOMEM; 841 return -ENOMEM;
842 842
843 uart_data = pdev->dev.platform_data; 843 uart_data = dev_get_platdata(&pdev->dev);
844 844
845 if (devices & SM501_USE_UART0) { 845 if (devices & SM501_USE_UART0) {
846 sm501_setup_uart_data(sm, uart_data++, 0x30000); 846 sm501_setup_uart_data(sm, uart_data++, 0x30000);
@@ -1167,7 +1167,7 @@ static int sm501_register_gpio_i2c_instance(struct sm501_devdata *sm,
1167 if (!pdev) 1167 if (!pdev)
1168 return -ENOMEM; 1168 return -ENOMEM;
1169 1169
1170 icd = pdev->dev.platform_data; 1170 icd = dev_get_platdata(&pdev->dev);
1171 1171
1172 /* We keep the pin_sda and pin_scl fields relative in case the 1172 /* We keep the pin_sda and pin_scl fields relative in case the
1173 * same platform data is passed to >1 SM501. 1173 * same platform data is passed to >1 SM501.
@@ -1403,7 +1403,7 @@ static int sm501_plat_probe(struct platform_device *dev)
1403 1403
1404 sm->dev = &dev->dev; 1404 sm->dev = &dev->dev;
1405 sm->pdev_id = dev->id; 1405 sm->pdev_id = dev->id;
1406 sm->platdata = dev->dev.platform_data; 1406 sm->platdata = dev_get_platdata(&dev->dev);
1407 1407
1408 ret = platform_get_irq(dev, 0); 1408 ret = platform_get_irq(dev, 0);
1409 if (ret < 0) { 1409 if (ret < 0) {
diff --git a/drivers/mfd/sta2x11-mfd.c b/drivers/mfd/sta2x11-mfd.c
index d70a343078fd..65c6fa671acb 100644
--- a/drivers/mfd/sta2x11-mfd.c
+++ b/drivers/mfd/sta2x11-mfd.c
@@ -133,7 +133,7 @@ int sta2x11_mfd_get_regs_data(struct platform_device *dev,
133 void __iomem **regs, 133 void __iomem **regs,
134 spinlock_t **lock) 134 spinlock_t **lock)
135{ 135{
136 struct pci_dev *pdev = *(struct pci_dev **)(dev->dev.platform_data); 136 struct pci_dev *pdev = *(struct pci_dev **)dev_get_platdata(&dev->dev);
137 struct sta2x11_mfd *mfd; 137 struct sta2x11_mfd *mfd;
138 138
139 if (!pdev) 139 if (!pdev)
@@ -312,7 +312,7 @@ static int sta2x11_mfd_platform_probe(struct platform_device *dev,
312 const char *name = sta2x11_mfd_names[index]; 312 const char *name = sta2x11_mfd_names[index];
313 struct regmap_config *regmap_config = sta2x11_mfd_regmap_configs[index]; 313 struct regmap_config *regmap_config = sta2x11_mfd_regmap_configs[index];
314 314
315 pdev = dev->dev.platform_data; 315 pdev = dev_get_platdata(&dev->dev);
316 mfd = sta2x11_mfd_find(*pdev); 316 mfd = sta2x11_mfd_find(*pdev);
317 if (!mfd) 317 if (!mfd)
318 return -ENODEV; 318 return -ENODEV;
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index 5d5e6f90424a..fff63a41862c 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -1106,7 +1106,8 @@ static int stmpe_devices_init(struct stmpe *stmpe)
1106 return ret; 1106 return ret;
1107} 1107}
1108 1108
1109void stmpe_of_probe(struct stmpe_platform_data *pdata, struct device_node *np) 1109static void stmpe_of_probe(struct stmpe_platform_data *pdata,
1110 struct device_node *np)
1110{ 1111{
1111 struct device_node *child; 1112 struct device_node *child;
1112 1113
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 962a6e17a01a..71841f9181bd 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -25,7 +25,6 @@
25static struct platform_driver syscon_driver; 25static struct platform_driver syscon_driver;
26 26
27struct syscon { 27struct syscon {
28 void __iomem *base;
29 struct regmap *regmap; 28 struct regmap *regmap;
30}; 29};
31 30
@@ -129,6 +128,7 @@ static int syscon_probe(struct platform_device *pdev)
129 struct device *dev = &pdev->dev; 128 struct device *dev = &pdev->dev;
130 struct syscon *syscon; 129 struct syscon *syscon;
131 struct resource *res; 130 struct resource *res;
131 void __iomem *base;
132 132
133 syscon = devm_kzalloc(dev, sizeof(*syscon), GFP_KERNEL); 133 syscon = devm_kzalloc(dev, sizeof(*syscon), GFP_KERNEL);
134 if (!syscon) 134 if (!syscon)
@@ -138,12 +138,12 @@ static int syscon_probe(struct platform_device *pdev)
138 if (!res) 138 if (!res)
139 return -ENOENT; 139 return -ENOENT;
140 140
141 syscon->base = devm_ioremap(dev, res->start, resource_size(res)); 141 base = devm_ioremap(dev, res->start, resource_size(res));
142 if (!syscon->base) 142 if (!base)
143 return -ENOMEM; 143 return -ENOMEM;
144 144
145 syscon_regmap_config.max_register = res->end - res->start - 3; 145 syscon_regmap_config.max_register = res->end - res->start - 3;
146 syscon->regmap = devm_regmap_init_mmio(dev, syscon->base, 146 syscon->regmap = devm_regmap_init_mmio(dev, base,
147 &syscon_regmap_config); 147 &syscon_regmap_config);
148 if (IS_ERR(syscon->regmap)) { 148 if (IS_ERR(syscon->regmap)) {
149 dev_err(dev, "regmap init failed\n"); 149 dev_err(dev, "regmap init failed\n");
diff --git a/drivers/mfd/t7l66xb.c b/drivers/mfd/t7l66xb.c
index a21bff283a98..9e04a7485981 100644
--- a/drivers/mfd/t7l66xb.c
+++ b/drivers/mfd/t7l66xb.c
@@ -281,7 +281,7 @@ static void t7l66xb_detach_irq(struct platform_device *dev)
281static int t7l66xb_suspend(struct platform_device *dev, pm_message_t state) 281static int t7l66xb_suspend(struct platform_device *dev, pm_message_t state)
282{ 282{
283 struct t7l66xb *t7l66xb = platform_get_drvdata(dev); 283 struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
284 struct t7l66xb_platform_data *pdata = dev->dev.platform_data; 284 struct t7l66xb_platform_data *pdata = dev_get_platdata(&dev->dev);
285 285
286 if (pdata && pdata->suspend) 286 if (pdata && pdata->suspend)
287 pdata->suspend(dev); 287 pdata->suspend(dev);
@@ -293,7 +293,7 @@ static int t7l66xb_suspend(struct platform_device *dev, pm_message_t state)
293static int t7l66xb_resume(struct platform_device *dev) 293static int t7l66xb_resume(struct platform_device *dev)
294{ 294{
295 struct t7l66xb *t7l66xb = platform_get_drvdata(dev); 295 struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
296 struct t7l66xb_platform_data *pdata = dev->dev.platform_data; 296 struct t7l66xb_platform_data *pdata = dev_get_platdata(&dev->dev);
297 297
298 clk_enable(t7l66xb->clk48m); 298 clk_enable(t7l66xb->clk48m);
299 if (pdata && pdata->resume) 299 if (pdata && pdata->resume)
@@ -313,7 +313,7 @@ static int t7l66xb_resume(struct platform_device *dev)
313 313
314static int t7l66xb_probe(struct platform_device *dev) 314static int t7l66xb_probe(struct platform_device *dev)
315{ 315{
316 struct t7l66xb_platform_data *pdata = dev->dev.platform_data; 316 struct t7l66xb_platform_data *pdata = dev_get_platdata(&dev->dev);
317 struct t7l66xb *t7l66xb; 317 struct t7l66xb *t7l66xb;
318 struct resource *iomem, *rscr; 318 struct resource *iomem, *rscr;
319 int ret; 319 int ret;
@@ -409,7 +409,7 @@ err_noirq:
409 409
410static int t7l66xb_remove(struct platform_device *dev) 410static int t7l66xb_remove(struct platform_device *dev)
411{ 411{
412 struct t7l66xb_platform_data *pdata = dev->dev.platform_data; 412 struct t7l66xb_platform_data *pdata = dev_get_platdata(&dev->dev);
413 struct t7l66xb *t7l66xb = platform_get_drvdata(dev); 413 struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
414 int ret; 414 int ret;
415 415
diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c
index 4cb92bb2aea2..70f4909fee13 100644
--- a/drivers/mfd/tc3589x.c
+++ b/drivers/mfd/tc3589x.c
@@ -325,7 +325,7 @@ static int tc3589x_of_probe(struct device_node *np,
325static int tc3589x_probe(struct i2c_client *i2c, 325static int tc3589x_probe(struct i2c_client *i2c,
326 const struct i2c_device_id *id) 326 const struct i2c_device_id *id)
327{ 327{
328 struct tc3589x_platform_data *pdata = i2c->dev.platform_data; 328 struct tc3589x_platform_data *pdata = dev_get_platdata(&i2c->dev);
329 struct device_node *np = i2c->dev.of_node; 329 struct device_node *np = i2c->dev.of_node;
330 struct tc3589x *tc3589x; 330 struct tc3589x *tc3589x;
331 int ret; 331 int ret;
diff --git a/drivers/mfd/tc6387xb.c b/drivers/mfd/tc6387xb.c
index 65c425a517c5..acd0f3a41044 100644
--- a/drivers/mfd/tc6387xb.c
+++ b/drivers/mfd/tc6387xb.c
@@ -48,7 +48,7 @@ static struct resource tc6387xb_mmc_resources[] = {
48static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state) 48static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state)
49{ 49{
50 struct tc6387xb *tc6387xb = platform_get_drvdata(dev); 50 struct tc6387xb *tc6387xb = platform_get_drvdata(dev);
51 struct tc6387xb_platform_data *pdata = dev->dev.platform_data; 51 struct tc6387xb_platform_data *pdata = dev_get_platdata(&dev->dev);
52 52
53 if (pdata && pdata->suspend) 53 if (pdata && pdata->suspend)
54 pdata->suspend(dev); 54 pdata->suspend(dev);
@@ -60,7 +60,7 @@ static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state)
60static int tc6387xb_resume(struct platform_device *dev) 60static int tc6387xb_resume(struct platform_device *dev)
61{ 61{
62 struct tc6387xb *tc6387xb = platform_get_drvdata(dev); 62 struct tc6387xb *tc6387xb = platform_get_drvdata(dev);
63 struct tc6387xb_platform_data *pdata = dev->dev.platform_data; 63 struct tc6387xb_platform_data *pdata = dev_get_platdata(&dev->dev);
64 64
65 clk_enable(tc6387xb->clk32k); 65 clk_enable(tc6387xb->clk32k);
66 if (pdata && pdata->resume) 66 if (pdata && pdata->resume)
@@ -140,7 +140,7 @@ static struct mfd_cell tc6387xb_cells[] = {
140 140
141static int tc6387xb_probe(struct platform_device *dev) 141static int tc6387xb_probe(struct platform_device *dev)
142{ 142{
143 struct tc6387xb_platform_data *pdata = dev->dev.platform_data; 143 struct tc6387xb_platform_data *pdata = dev_get_platdata(&dev->dev);
144 struct resource *iomem, *rscr; 144 struct resource *iomem, *rscr;
145 struct clk *clk32k; 145 struct clk *clk32k;
146 struct tc6387xb *tc6387xb; 146 struct tc6387xb *tc6387xb;
diff --git a/drivers/mfd/tc6393xb.c b/drivers/mfd/tc6393xb.c
index a563dfa3cf87..11c19e538551 100644
--- a/drivers/mfd/tc6393xb.c
+++ b/drivers/mfd/tc6393xb.c
@@ -604,7 +604,7 @@ static void tc6393xb_detach_irq(struct platform_device *dev)
604 604
605static int tc6393xb_probe(struct platform_device *dev) 605static int tc6393xb_probe(struct platform_device *dev)
606{ 606{
607 struct tc6393xb_platform_data *tcpd = dev->dev.platform_data; 607 struct tc6393xb_platform_data *tcpd = dev_get_platdata(&dev->dev);
608 struct tc6393xb *tc6393xb; 608 struct tc6393xb *tc6393xb;
609 struct resource *iomem, *rscr; 609 struct resource *iomem, *rscr;
610 int ret, temp; 610 int ret, temp;
@@ -733,7 +733,7 @@ err_kzalloc:
733 733
734static int tc6393xb_remove(struct platform_device *dev) 734static int tc6393xb_remove(struct platform_device *dev)
735{ 735{
736 struct tc6393xb_platform_data *tcpd = dev->dev.platform_data; 736 struct tc6393xb_platform_data *tcpd = dev_get_platdata(&dev->dev);
737 struct tc6393xb *tc6393xb = platform_get_drvdata(dev); 737 struct tc6393xb *tc6393xb = platform_get_drvdata(dev);
738 int ret; 738 int ret;
739 739
@@ -765,7 +765,7 @@ static int tc6393xb_remove(struct platform_device *dev)
765#ifdef CONFIG_PM 765#ifdef CONFIG_PM
766static int tc6393xb_suspend(struct platform_device *dev, pm_message_t state) 766static int tc6393xb_suspend(struct platform_device *dev, pm_message_t state)
767{ 767{
768 struct tc6393xb_platform_data *tcpd = dev->dev.platform_data; 768 struct tc6393xb_platform_data *tcpd = dev_get_platdata(&dev->dev);
769 struct tc6393xb *tc6393xb = platform_get_drvdata(dev); 769 struct tc6393xb *tc6393xb = platform_get_drvdata(dev);
770 int i, ret; 770 int i, ret;
771 771
@@ -788,7 +788,7 @@ static int tc6393xb_suspend(struct platform_device *dev, pm_message_t state)
788 788
789static int tc6393xb_resume(struct platform_device *dev) 789static int tc6393xb_resume(struct platform_device *dev)
790{ 790{
791 struct tc6393xb_platform_data *tcpd = dev->dev.platform_data; 791 struct tc6393xb_platform_data *tcpd = dev_get_platdata(&dev->dev);
792 struct tc6393xb *tc6393xb = platform_get_drvdata(dev); 792 struct tc6393xb *tc6393xb = platform_get_drvdata(dev);
793 int ret; 793 int ret;
794 int i; 794 int i;
diff --git a/drivers/mfd/ti-ssp.c b/drivers/mfd/ti-ssp.c
index 09a14cec351b..1c2b994e1f6c 100644
--- a/drivers/mfd/ti-ssp.c
+++ b/drivers/mfd/ti-ssp.c
@@ -318,7 +318,7 @@ static irqreturn_t ti_ssp_interrupt(int irq, void *dev_data)
318static int ti_ssp_probe(struct platform_device *pdev) 318static int ti_ssp_probe(struct platform_device *pdev)
319{ 319{
320 static struct ti_ssp *ssp; 320 static struct ti_ssp *ssp;
321 const struct ti_ssp_data *pdata = pdev->dev.platform_data; 321 const struct ti_ssp_data *pdata = dev_get_platdata(&pdev->dev);
322 int error = 0, prediv = 0xff, id; 322 int error = 0, prediv = 0xff, id;
323 unsigned long sysclk; 323 unsigned long sysclk;
324 struct device *dev = &pdev->dev; 324 struct device *dev = &pdev->dev;
diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index b003a16ba227..baaf5a8123bb 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -57,20 +57,20 @@ EXPORT_SYMBOL_GPL(am335x_tsc_se_update);
57void am335x_tsc_se_set(struct ti_tscadc_dev *tsadc, u32 val) 57void am335x_tsc_se_set(struct ti_tscadc_dev *tsadc, u32 val)
58{ 58{
59 spin_lock(&tsadc->reg_lock); 59 spin_lock(&tsadc->reg_lock);
60 tsadc->reg_se_cache = tscadc_readl(tsadc, REG_SE);
60 tsadc->reg_se_cache |= val; 61 tsadc->reg_se_cache |= val;
61 spin_unlock(&tsadc->reg_lock);
62
63 am335x_tsc_se_update(tsadc); 62 am335x_tsc_se_update(tsadc);
63 spin_unlock(&tsadc->reg_lock);
64} 64}
65EXPORT_SYMBOL_GPL(am335x_tsc_se_set); 65EXPORT_SYMBOL_GPL(am335x_tsc_se_set);
66 66
67void am335x_tsc_se_clr(struct ti_tscadc_dev *tsadc, u32 val) 67void am335x_tsc_se_clr(struct ti_tscadc_dev *tsadc, u32 val)
68{ 68{
69 spin_lock(&tsadc->reg_lock); 69 spin_lock(&tsadc->reg_lock);
70 tsadc->reg_se_cache = tscadc_readl(tsadc, REG_SE);
70 tsadc->reg_se_cache &= ~val; 71 tsadc->reg_se_cache &= ~val;
71 spin_unlock(&tsadc->reg_lock);
72
73 am335x_tsc_se_update(tsadc); 72 am335x_tsc_se_update(tsadc);
73 spin_unlock(&tsadc->reg_lock);
74} 74}
75EXPORT_SYMBOL_GPL(am335x_tsc_se_clr); 75EXPORT_SYMBOL_GPL(am335x_tsc_se_clr);
76 76
@@ -197,24 +197,21 @@ static int ti_tscadc_probe(struct platform_device *pdev)
197 clock_rate = clk_get_rate(clk); 197 clock_rate = clk_get_rate(clk);
198 clk_put(clk); 198 clk_put(clk);
199 clk_value = clock_rate / ADC_CLK; 199 clk_value = clock_rate / ADC_CLK;
200 if (clk_value < MAX_CLK_DIV) { 200
201 dev_err(&pdev->dev, "clock input less than min clock requirement\n");
202 err = -EINVAL;
203 goto err_disable_clk;
204 }
205 /* TSCADC_CLKDIV needs to be configured to the value minus 1 */ 201 /* TSCADC_CLKDIV needs to be configured to the value minus 1 */
206 clk_value = clk_value - 1; 202 clk_value = clk_value - 1;
207 tscadc_writel(tscadc, REG_CLKDIV, clk_value); 203 tscadc_writel(tscadc, REG_CLKDIV, clk_value);
208 204
209 /* Set the control register bits */ 205 /* Set the control register bits */
210 ctrl = CNTRLREG_STEPCONFIGWRT | 206 ctrl = CNTRLREG_STEPCONFIGWRT |
211 CNTRLREG_TSCENB | 207 CNTRLREG_STEPID;
212 CNTRLREG_STEPID | 208 if (tsc_wires > 0)
213 CNTRLREG_4WIRE; 209 ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB;
214 tscadc_writel(tscadc, REG_CTRL, ctrl); 210 tscadc_writel(tscadc, REG_CTRL, ctrl);
215 211
216 /* Set register bits for Idle Config Mode */ 212 /* Set register bits for Idle Config Mode */
217 tscadc_idle_config(tscadc); 213 if (tsc_wires > 0)
214 tscadc_idle_config(tscadc);
218 215
219 /* Enable the TSC module enable bit */ 216 /* Enable the TSC module enable bit */
220 ctrl = tscadc_readl(tscadc, REG_CTRL); 217 ctrl = tscadc_readl(tscadc, REG_CTRL);
@@ -294,10 +291,13 @@ static int tscadc_resume(struct device *dev)
294 pm_runtime_get_sync(dev); 291 pm_runtime_get_sync(dev);
295 292
296 /* context restore */ 293 /* context restore */
297 ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_TSCENB | 294 ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_STEPID;
298 CNTRLREG_STEPID | CNTRLREG_4WIRE; 295 if (tscadc_dev->tsc_cell != -1)
296 ctrl |= CNTRLREG_TSCENB | CNTRLREG_4WIRE;
299 tscadc_writel(tscadc_dev, REG_CTRL, ctrl); 297 tscadc_writel(tscadc_dev, REG_CTRL, ctrl);
300 tscadc_idle_config(tscadc_dev); 298
299 if (tscadc_dev->tsc_cell != -1)
300 tscadc_idle_config(tscadc_dev);
301 am335x_tsc_se_update(tscadc_dev); 301 am335x_tsc_se_update(tscadc_dev);
302 restore = tscadc_readl(tscadc_dev, REG_CTRL); 302 restore = tscadc_readl(tscadc_dev, REG_CTRL);
303 tscadc_writel(tscadc_dev, REG_CTRL, 303 tscadc_writel(tscadc_dev, REG_CTRL,
diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c
index 0c1fcbc23d04..a6755ec7bd6a 100644
--- a/drivers/mfd/timberdale.c
+++ b/drivers/mfd/timberdale.c
@@ -115,11 +115,11 @@ static const struct resource timberdale_ocores_resources[] = {
115 }, 115 },
116}; 116};
117 117
118const struct max7301_platform_data timberdale_max7301_platform_data = { 118static const struct max7301_platform_data timberdale_max7301_platform_data = {
119 .base = 200 119 .base = 200
120}; 120};
121 121
122const struct mc33880_platform_data timberdale_mc33880_platform_data = { 122static const struct mc33880_platform_data timberdale_mc33880_platform_data = {
123 .base = 100 123 .base = 100
124}; 124};
125 125
@@ -781,7 +781,6 @@ static int timb_probe(struct pci_dev *dev,
781 priv->fw.major, priv->fw.minor, ip_setup); 781 priv->fw.major, priv->fw.minor, ip_setup);
782 err = -ENODEV; 782 err = -ENODEV;
783 goto err_mfd; 783 goto err_mfd;
784 break;
785 } 784 }
786 785
787 if (err) { 786 if (err) {
@@ -869,34 +868,7 @@ static struct pci_driver timberdale_pci_driver = {
869 .remove = timb_remove, 868 .remove = timb_remove,
870}; 869};
871 870
872static int __init timberdale_init(void) 871module_pci_driver(timberdale_pci_driver);
873{
874 int err;
875
876 err = pci_register_driver(&timberdale_pci_driver);
877 if (err < 0) {
878 printk(KERN_ERR
879 "Failed to register PCI driver for %s device.\n",
880 timberdale_pci_driver.name);
881 return -ENODEV;
882 }
883
884 printk(KERN_INFO "Driver for %s has been successfully registered.\n",
885 timberdale_pci_driver.name);
886
887 return 0;
888}
889
890static void __exit timberdale_exit(void)
891{
892 pci_unregister_driver(&timberdale_pci_driver);
893
894 printk(KERN_INFO "Driver for %s has been successfully unregistered.\n",
895 timberdale_pci_driver.name);
896}
897
898module_init(timberdale_init);
899module_exit(timberdale_exit);
900 872
901MODULE_AUTHOR("Mocean Laboratories <info@mocean-labs.com>"); 873MODULE_AUTHOR("Mocean Laboratories <info@mocean-labs.com>");
902MODULE_VERSION(DRV_VERSION); 874MODULE_VERSION(DRV_VERSION);
diff --git a/drivers/mfd/tps6105x.c b/drivers/mfd/tps6105x.c
index 1d302f583adf..b5dfa6e4e692 100644
--- a/drivers/mfd/tps6105x.c
+++ b/drivers/mfd/tps6105x.c
@@ -147,7 +147,7 @@ static int tps6105x_probe(struct i2c_client *client,
147 147
148 i2c_set_clientdata(client, tps6105x); 148 i2c_set_clientdata(client, tps6105x);
149 tps6105x->client = client; 149 tps6105x->client = client;
150 pdata = client->dev.platform_data; 150 pdata = dev_get_platdata(&client->dev);
151 tps6105x->pdata = pdata; 151 tps6105x->pdata = pdata;
152 mutex_init(&tps6105x->lock); 152 mutex_init(&tps6105x->lock);
153 153
diff --git a/drivers/mfd/tps65010.c b/drivers/mfd/tps65010.c
index da2691f22e11..743fb524fc8a 100644
--- a/drivers/mfd/tps65010.c
+++ b/drivers/mfd/tps65010.c
@@ -242,8 +242,8 @@ static int dbg_show(struct seq_file *s, void *_)
242 seq_printf(s, "mask2 %s\n", buf); 242 seq_printf(s, "mask2 %s\n", buf);
243 /* ignore ackint2 */ 243 /* ignore ackint2 */
244 244
245 schedule_delayed_work(&tps->work, POWER_POLL_DELAY); 245 queue_delayed_work(system_power_efficient_wq, &tps->work,
246 246 POWER_POLL_DELAY);
247 247
248 /* VMAIN voltage, enable lowpower, etc */ 248 /* VMAIN voltage, enable lowpower, etc */
249 value = i2c_smbus_read_byte_data(tps->client, TPS_VDCDC1); 249 value = i2c_smbus_read_byte_data(tps->client, TPS_VDCDC1);
@@ -400,7 +400,8 @@ static void tps65010_interrupt(struct tps65010 *tps)
400 && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))) 400 && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC)))
401 poll = 1; 401 poll = 1;
402 if (poll) 402 if (poll)
403 schedule_delayed_work(&tps->work, POWER_POLL_DELAY); 403 queue_delayed_work(system_power_efficient_wq, &tps->work,
404 POWER_POLL_DELAY);
404 405
405 /* also potentially gpio-in rise or fall */ 406 /* also potentially gpio-in rise or fall */
406} 407}
@@ -448,7 +449,7 @@ static irqreturn_t tps65010_irq(int irq, void *_tps)
448 449
449 disable_irq_nosync(irq); 450 disable_irq_nosync(irq);
450 set_bit(FLAG_IRQ_ENABLE, &tps->flags); 451 set_bit(FLAG_IRQ_ENABLE, &tps->flags);
451 schedule_delayed_work(&tps->work, 0); 452 queue_delayed_work(system_power_efficient_wq, &tps->work, 0);
452 return IRQ_HANDLED; 453 return IRQ_HANDLED;
453} 454}
454 455
@@ -517,7 +518,7 @@ static struct tps65010 *the_tps;
517static int __exit tps65010_remove(struct i2c_client *client) 518static int __exit tps65010_remove(struct i2c_client *client)
518{ 519{
519 struct tps65010 *tps = i2c_get_clientdata(client); 520 struct tps65010 *tps = i2c_get_clientdata(client);
520 struct tps65010_board *board = client->dev.platform_data; 521 struct tps65010_board *board = dev_get_platdata(&client->dev);
521 522
522 if (board && board->teardown) { 523 if (board && board->teardown) {
523 int status = board->teardown(client, board->context); 524 int status = board->teardown(client, board->context);
@@ -529,7 +530,6 @@ static int __exit tps65010_remove(struct i2c_client *client)
529 free_irq(client->irq, tps); 530 free_irq(client->irq, tps);
530 cancel_delayed_work_sync(&tps->work); 531 cancel_delayed_work_sync(&tps->work);
531 debugfs_remove(tps->file); 532 debugfs_remove(tps->file);
532 kfree(tps);
533 the_tps = NULL; 533 the_tps = NULL;
534 return 0; 534 return 0;
535} 535}
@@ -539,7 +539,7 @@ static int tps65010_probe(struct i2c_client *client,
539{ 539{
540 struct tps65010 *tps; 540 struct tps65010 *tps;
541 int status; 541 int status;
542 struct tps65010_board *board = client->dev.platform_data; 542 struct tps65010_board *board = dev_get_platdata(&client->dev);
543 543
544 if (the_tps) { 544 if (the_tps) {
545 dev_dbg(&client->dev, "only one tps6501x chip allowed\n"); 545 dev_dbg(&client->dev, "only one tps6501x chip allowed\n");
@@ -549,7 +549,7 @@ static int tps65010_probe(struct i2c_client *client,
549 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 549 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
550 return -EINVAL; 550 return -EINVAL;
551 551
552 tps = kzalloc(sizeof *tps, GFP_KERNEL); 552 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
553 if (!tps) 553 if (!tps)
554 return -ENOMEM; 554 return -ENOMEM;
555 555
@@ -567,7 +567,7 @@ static int tps65010_probe(struct i2c_client *client,
567 if (status < 0) { 567 if (status < 0) {
568 dev_dbg(&client->dev, "can't get IRQ %d, err %d\n", 568 dev_dbg(&client->dev, "can't get IRQ %d, err %d\n",
569 client->irq, status); 569 client->irq, status);
570 goto fail1; 570 return status;
571 } 571 }
572 /* annoying race here, ideally we'd have an option 572 /* annoying race here, ideally we'd have an option
573 * to claim the irq now and enable it later. 573 * to claim the irq now and enable it later.
@@ -667,9 +667,6 @@ static int tps65010_probe(struct i2c_client *client,
667 } 667 }
668 668
669 return 0; 669 return 0;
670fail1:
671 kfree(tps);
672 return status;
673} 670}
674 671
675static const struct i2c_device_id tps65010_id[] = { 672static const struct i2c_device_id tps65010_id[] = {
@@ -718,7 +715,8 @@ int tps65010_set_vbus_draw(unsigned mA)
718 && test_and_set_bit( 715 && test_and_set_bit(
719 FLAG_VBUS_CHANGED, &the_tps->flags)) { 716 FLAG_VBUS_CHANGED, &the_tps->flags)) {
720 /* gadget drivers call this in_irq() */ 717 /* gadget drivers call this in_irq() */
721 schedule_delayed_work(&the_tps->work, 0); 718 queue_delayed_work(system_power_efficient_wq, &the_tps->work,
719 0);
722 } 720 }
723 local_irq_restore(flags); 721 local_irq_restore(flags);
724 722
diff --git a/drivers/mfd/tps65090.c b/drivers/mfd/tps65090.c
index fbd6ee67b5a5..e6f03a733879 100644
--- a/drivers/mfd/tps65090.c
+++ b/drivers/mfd/tps65090.c
@@ -172,7 +172,7 @@ MODULE_DEVICE_TABLE(of, tps65090_of_match);
172static int tps65090_i2c_probe(struct i2c_client *client, 172static int tps65090_i2c_probe(struct i2c_client *client,
173 const struct i2c_device_id *id) 173 const struct i2c_device_id *id)
174{ 174{
175 struct tps65090_platform_data *pdata = client->dev.platform_data; 175 struct tps65090_platform_data *pdata = dev_get_platdata(&client->dev);
176 int irq_base = 0; 176 int irq_base = 0;
177 struct tps65090 *tps65090; 177 struct tps65090 *tps65090;
178 int ret; 178 int ret;
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
index 4b93ed4d5cd6..f54fe4d4f77b 100644
--- a/drivers/mfd/tps6586x.c
+++ b/drivers/mfd/tps6586x.c
@@ -462,7 +462,7 @@ static void tps6586x_power_off(void)
462static int tps6586x_i2c_probe(struct i2c_client *client, 462static int tps6586x_i2c_probe(struct i2c_client *client,
463 const struct i2c_device_id *id) 463 const struct i2c_device_id *id)
464{ 464{
465 struct tps6586x_platform_data *pdata = client->dev.platform_data; 465 struct tps6586x_platform_data *pdata = dev_get_platdata(&client->dev);
466 struct tps6586x *tps6586x; 466 struct tps6586x *tps6586x;
467 int ret; 467 int ret;
468 468
diff --git a/drivers/mfd/tps65912-core.c b/drivers/mfd/tps65912-core.c
index 479886a4cf80..925a044cbdf6 100644
--- a/drivers/mfd/tps65912-core.c
+++ b/drivers/mfd/tps65912-core.c
@@ -123,7 +123,7 @@ EXPORT_SYMBOL_GPL(tps65912_reg_write);
123 123
124int tps65912_device_init(struct tps65912 *tps65912) 124int tps65912_device_init(struct tps65912 *tps65912)
125{ 125{
126 struct tps65912_board *pmic_plat_data = tps65912->dev->platform_data; 126 struct tps65912_board *pmic_plat_data = dev_get_platdata(tps65912->dev);
127 struct tps65912_platform_data *init_data; 127 struct tps65912_platform_data *init_data;
128 int ret, dcdc_avs, value; 128 int ret, dcdc_avs, value;
129 129
diff --git a/drivers/mfd/tps80031.c b/drivers/mfd/tps80031.c
index c90a2c450f51..f15ee6d5cfbf 100644
--- a/drivers/mfd/tps80031.c
+++ b/drivers/mfd/tps80031.c
@@ -418,7 +418,7 @@ static const struct regmap_config tps80031_regmap_configs[] = {
418static int tps80031_probe(struct i2c_client *client, 418static int tps80031_probe(struct i2c_client *client,
419 const struct i2c_device_id *id) 419 const struct i2c_device_id *id)
420{ 420{
421 struct tps80031_platform_data *pdata = client->dev.platform_data; 421 struct tps80031_platform_data *pdata = dev_get_platdata(&client->dev);
422 struct tps80031 *tps80031; 422 struct tps80031 *tps80031;
423 int ret; 423 int ret;
424 uint8_t es_version; 424 uint8_t es_version;
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 7f150d94d295..29473c2c95ae 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -1137,7 +1137,7 @@ static int twl_remove(struct i2c_client *client)
1137static int 1137static int
1138twl_probe(struct i2c_client *client, const struct i2c_device_id *id) 1138twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
1139{ 1139{
1140 struct twl4030_platform_data *pdata = client->dev.platform_data; 1140 struct twl4030_platform_data *pdata = dev_get_platdata(&client->dev);
1141 struct device_node *node = client->dev.of_node; 1141 struct device_node *node = client->dev.of_node;
1142 struct platform_device *pdev; 1142 struct platform_device *pdev;
1143 struct regmap_config *twl_regmap_config; 1143 struct regmap_config *twl_regmap_config;
diff --git a/drivers/mfd/twl4030-audio.c b/drivers/mfd/twl4030-audio.c
index a31fba96ef43..07fe542e6fc0 100644
--- a/drivers/mfd/twl4030-audio.c
+++ b/drivers/mfd/twl4030-audio.c
@@ -187,7 +187,7 @@ static bool twl4030_audio_has_vibra(struct twl4030_audio_data *pdata,
187static int twl4030_audio_probe(struct platform_device *pdev) 187static int twl4030_audio_probe(struct platform_device *pdev)
188{ 188{
189 struct twl4030_audio *audio; 189 struct twl4030_audio *audio;
190 struct twl4030_audio_data *pdata = pdev->dev.platform_data; 190 struct twl4030_audio_data *pdata = dev_get_platdata(&pdev->dev);
191 struct device_node *node = pdev->dev.of_node; 191 struct device_node *node = pdev->dev.of_node;
192 struct mfd_cell *cell = NULL; 192 struct mfd_cell *cell = NULL;
193 int ret, childs = 0; 193 int ret, childs = 0;
diff --git a/drivers/mfd/twl4030-madc.c b/drivers/mfd/twl4030-madc.c
index 1ea54d4d003a..4c583e471339 100644
--- a/drivers/mfd/twl4030-madc.c
+++ b/drivers/mfd/twl4030-madc.c
@@ -701,7 +701,7 @@ static int twl4030_madc_set_power(struct twl4030_madc_data *madc, int on)
701static int twl4030_madc_probe(struct platform_device *pdev) 701static int twl4030_madc_probe(struct platform_device *pdev)
702{ 702{
703 struct twl4030_madc_data *madc; 703 struct twl4030_madc_data *madc;
704 struct twl4030_madc_platform_data *pdata = pdev->dev.platform_data; 704 struct twl4030_madc_platform_data *pdata = dev_get_platdata(&pdev->dev);
705 int ret; 705 int ret;
706 u8 regval; 706 u8 regval;
707 707
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index a5fd3c738211..96162b62f3c0 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -493,7 +493,7 @@ int twl4030_remove_script(u8 flags)
493 return err; 493 return err;
494} 494}
495 495
496int twl4030_power_configure_scripts(struct twl4030_power_data *pdata) 496static int twl4030_power_configure_scripts(struct twl4030_power_data *pdata)
497{ 497{
498 int err; 498 int err;
499 int i; 499 int i;
@@ -509,7 +509,7 @@ int twl4030_power_configure_scripts(struct twl4030_power_data *pdata)
509 return 0; 509 return 0;
510} 510}
511 511
512int twl4030_power_configure_resources(struct twl4030_power_data *pdata) 512static int twl4030_power_configure_resources(struct twl4030_power_data *pdata)
513{ 513{
514 struct twl4030_resconfig *resconfig = pdata->resource_config; 514 struct twl4030_resconfig *resconfig = pdata->resource_config;
515 int err; 515 int err;
@@ -553,9 +553,9 @@ static bool twl4030_power_use_poweroff(struct twl4030_power_data *pdata,
553 return false; 553 return false;
554} 554}
555 555
556int twl4030_power_probe(struct platform_device *pdev) 556static int twl4030_power_probe(struct platform_device *pdev)
557{ 557{
558 struct twl4030_power_data *pdata = pdev->dev.platform_data; 558 struct twl4030_power_data *pdata = dev_get_platdata(&pdev->dev);
559 struct device_node *node = pdev->dev.of_node; 559 struct device_node *node = pdev->dev.of_node;
560 int err = 0; 560 int err = 0;
561 int err2 = 0; 561 int err2 = 0;
diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
index 277a8dba42d5..517eda832f79 100644
--- a/drivers/mfd/twl6030-irq.c
+++ b/drivers/mfd/twl6030-irq.c
@@ -41,6 +41,7 @@
41#include <linux/suspend.h> 41#include <linux/suspend.h>
42#include <linux/of.h> 42#include <linux/of.h>
43#include <linux/irqdomain.h> 43#include <linux/irqdomain.h>
44#include <linux/of_device.h>
44 45
45#include "twl-core.h" 46#include "twl-core.h"
46 47
@@ -84,39 +85,77 @@ static int twl6030_interrupt_mapping[24] = {
84 CHARGERFAULT_INTR_OFFSET, /* Bit 22 INT_CHRG */ 85 CHARGERFAULT_INTR_OFFSET, /* Bit 22 INT_CHRG */
85 RSV_INTR_OFFSET, /* Bit 23 Reserved */ 86 RSV_INTR_OFFSET, /* Bit 23 Reserved */
86}; 87};
88
89static int twl6032_interrupt_mapping[24] = {
90 PWR_INTR_OFFSET, /* Bit 0 PWRON */
91 PWR_INTR_OFFSET, /* Bit 1 RPWRON */
92 PWR_INTR_OFFSET, /* Bit 2 SYS_VLOW */
93 RTC_INTR_OFFSET, /* Bit 3 RTC_ALARM */
94 RTC_INTR_OFFSET, /* Bit 4 RTC_PERIOD */
95 HOTDIE_INTR_OFFSET, /* Bit 5 HOT_DIE */
96 SMPSLDO_INTR_OFFSET, /* Bit 6 VXXX_SHORT */
97 PWR_INTR_OFFSET, /* Bit 7 SPDURATION */
98
99 PWR_INTR_OFFSET, /* Bit 8 WATCHDOG */
100 BATDETECT_INTR_OFFSET, /* Bit 9 BAT */
101 SIMDETECT_INTR_OFFSET, /* Bit 10 SIM */
102 MMCDETECT_INTR_OFFSET, /* Bit 11 MMC */
103 MADC_INTR_OFFSET, /* Bit 12 GPADC_RT_EOC */
104 MADC_INTR_OFFSET, /* Bit 13 GPADC_SW_EOC */
105 GASGAUGE_INTR_OFFSET, /* Bit 14 CC_EOC */
106 GASGAUGE_INTR_OFFSET, /* Bit 15 CC_AUTOCAL */
107
108 USBOTG_INTR_OFFSET, /* Bit 16 ID_WKUP */
109 USBOTG_INTR_OFFSET, /* Bit 17 VBUS_WKUP */
110 USBOTG_INTR_OFFSET, /* Bit 18 ID */
111 USB_PRES_INTR_OFFSET, /* Bit 19 VBUS */
112 CHARGER_INTR_OFFSET, /* Bit 20 CHRG_CTRL */
113 CHARGERFAULT_INTR_OFFSET, /* Bit 21 EXT_CHRG */
114 CHARGERFAULT_INTR_OFFSET, /* Bit 22 INT_CHRG */
115 RSV_INTR_OFFSET, /* Bit 23 Reserved */
116};
117
87/*----------------------------------------------------------------------*/ 118/*----------------------------------------------------------------------*/
88 119
89static unsigned twl6030_irq_base; 120struct twl6030_irq {
90static int twl_irq; 121 unsigned int irq_base;
91static bool twl_irq_wake_enabled; 122 int twl_irq;
123 bool irq_wake_enabled;
124 atomic_t wakeirqs;
125 struct notifier_block pm_nb;
126 struct irq_chip irq_chip;
127 struct irq_domain *irq_domain;
128 const int *irq_mapping_tbl;
129};
92 130
93static struct completion irq_event; 131static struct twl6030_irq *twl6030_irq;
94static atomic_t twl6030_wakeirqs = ATOMIC_INIT(0);
95 132
96static int twl6030_irq_pm_notifier(struct notifier_block *notifier, 133static int twl6030_irq_pm_notifier(struct notifier_block *notifier,
97 unsigned long pm_event, void *unused) 134 unsigned long pm_event, void *unused)
98{ 135{
99 int chained_wakeups; 136 int chained_wakeups;
137 struct twl6030_irq *pdata = container_of(notifier, struct twl6030_irq,
138 pm_nb);
100 139
101 switch (pm_event) { 140 switch (pm_event) {
102 case PM_SUSPEND_PREPARE: 141 case PM_SUSPEND_PREPARE:
103 chained_wakeups = atomic_read(&twl6030_wakeirqs); 142 chained_wakeups = atomic_read(&pdata->wakeirqs);
104 143
105 if (chained_wakeups && !twl_irq_wake_enabled) { 144 if (chained_wakeups && !pdata->irq_wake_enabled) {
106 if (enable_irq_wake(twl_irq)) 145 if (enable_irq_wake(pdata->twl_irq))
107 pr_err("twl6030 IRQ wake enable failed\n"); 146 pr_err("twl6030 IRQ wake enable failed\n");
108 else 147 else
109 twl_irq_wake_enabled = true; 148 pdata->irq_wake_enabled = true;
110 } else if (!chained_wakeups && twl_irq_wake_enabled) { 149 } else if (!chained_wakeups && pdata->irq_wake_enabled) {
111 disable_irq_wake(twl_irq); 150 disable_irq_wake(pdata->twl_irq);
112 twl_irq_wake_enabled = false; 151 pdata->irq_wake_enabled = false;
113 } 152 }
114 153
115 disable_irq(twl_irq); 154 disable_irq(pdata->twl_irq);
116 break; 155 break;
117 156
118 case PM_POST_SUSPEND: 157 case PM_POST_SUSPEND:
119 enable_irq(twl_irq); 158 enable_irq(pdata->twl_irq);
120 break; 159 break;
121 160
122 default: 161 default:
@@ -126,124 +165,77 @@ static int twl6030_irq_pm_notifier(struct notifier_block *notifier,
126 return NOTIFY_DONE; 165 return NOTIFY_DONE;
127} 166}
128 167
129static struct notifier_block twl6030_irq_pm_notifier_block = {
130 .notifier_call = twl6030_irq_pm_notifier,
131};
132
133/* 168/*
134 * This thread processes interrupts reported by the Primary Interrupt Handler. 169* Threaded irq handler for the twl6030 interrupt.
135 */ 170* We query the interrupt controller in the twl6030 to determine
136static int twl6030_irq_thread(void *data) 171* which module is generating the interrupt request and call
172* handle_nested_irq for that module.
173*/
174static irqreturn_t twl6030_irq_thread(int irq, void *data)
137{ 175{
138 long irq = (long)data; 176 int i, ret;
139 static unsigned i2c_errors; 177 union {
140 static const unsigned max_i2c_errors = 100;
141 int ret;
142
143 while (!kthread_should_stop()) {
144 int i;
145 union {
146 u8 bytes[4]; 178 u8 bytes[4];
147 u32 int_sts; 179 u32 int_sts;
148 } sts; 180 } sts;
149 181 struct twl6030_irq *pdata = data;
150 /* Wait for IRQ, then read PIH irq status (also blocking) */ 182
151 wait_for_completion_interruptible(&irq_event); 183 /* read INT_STS_A, B and C in one shot using a burst read */
152 184 ret = twl_i2c_read(TWL_MODULE_PIH, sts.bytes, REG_INT_STS_A, 3);
153 /* read INT_STS_A, B and C in one shot using a burst read */ 185 if (ret) {
154 ret = twl_i2c_read(TWL_MODULE_PIH, sts.bytes, 186 pr_warn("twl6030_irq: I2C error %d reading PIH ISR\n", ret);
155 REG_INT_STS_A, 3); 187 return IRQ_HANDLED;
156 if (ret) { 188 }
157 pr_warning("twl6030: I2C error %d reading PIH ISR\n",
158 ret);
159 if (++i2c_errors >= max_i2c_errors) {
160 printk(KERN_ERR "Maximum I2C error count"
161 " exceeded. Terminating %s.\n",
162 __func__);
163 break;
164 }
165 complete(&irq_event);
166 continue;
167 }
168
169
170 189
171 sts.bytes[3] = 0; /* Only 24 bits are valid*/ 190 sts.bytes[3] = 0; /* Only 24 bits are valid*/
172 191
173 /* 192 /*
174 * Since VBUS status bit is not reliable for VBUS disconnect 193 * Since VBUS status bit is not reliable for VBUS disconnect
175 * use CHARGER VBUS detection status bit instead. 194 * use CHARGER VBUS detection status bit instead.
176 */ 195 */
177 if (sts.bytes[2] & 0x10) 196 if (sts.bytes[2] & 0x10)
178 sts.bytes[2] |= 0x08; 197 sts.bytes[2] |= 0x08;
179 198
180 for (i = 0; sts.int_sts; sts.int_sts >>= 1, i++) { 199 for (i = 0; sts.int_sts; sts.int_sts >>= 1, i++)
181 local_irq_disable(); 200 if (sts.int_sts & 0x1) {
182 if (sts.int_sts & 0x1) { 201 int module_irq =
183 int module_irq = twl6030_irq_base + 202 irq_find_mapping(pdata->irq_domain,
184 twl6030_interrupt_mapping[i]; 203 pdata->irq_mapping_tbl[i]);
185 generic_handle_irq(module_irq); 204 if (module_irq)
186 205 handle_nested_irq(module_irq);
187 } 206 else
188 local_irq_enable(); 207 pr_err("twl6030_irq: Unmapped PIH ISR %u detected\n",
208 i);
209 pr_debug("twl6030_irq: PIH ISR %u, virq%u\n",
210 i, module_irq);
189 } 211 }
190 212
191 /* 213 /*
192 * NOTE: 214 * NOTE:
193 * Simulation confirms that documentation is wrong w.r.t the 215 * Simulation confirms that documentation is wrong w.r.t the
194 * interrupt status clear operation. A single *byte* write to 216 * interrupt status clear operation. A single *byte* write to
195 * any one of STS_A to STS_C register results in all three 217 * any one of STS_A to STS_C register results in all three
196 * STS registers being reset. Since it does not matter which 218 * STS registers being reset. Since it does not matter which
197 * value is written, all three registers are cleared on a 219 * value is written, all three registers are cleared on a
198 * single byte write, so we just use 0x0 to clear. 220 * single byte write, so we just use 0x0 to clear.
199 */ 221 */
200 ret = twl_i2c_write_u8(TWL_MODULE_PIH, 0x00, REG_INT_STS_A); 222 ret = twl_i2c_write_u8(TWL_MODULE_PIH, 0x00, REG_INT_STS_A);
201 if (ret) 223 if (ret)
202 pr_warning("twl6030: I2C error in clearing PIH ISR\n"); 224 pr_warn("twl6030_irq: I2C error in clearing PIH ISR\n");
203
204 enable_irq(irq);
205 }
206
207 return 0;
208}
209 225
210/*
211 * handle_twl6030_int() is the desc->handle method for the twl6030 interrupt.
212 * This is a chained interrupt, so there is no desc->action method for it.
213 * Now we need to query the interrupt controller in the twl6030 to determine
214 * which module is generating the interrupt request. However, we can't do i2c
215 * transactions in interrupt context, so we must defer that work to a kernel
216 * thread. All we do here is acknowledge and mask the interrupt and wakeup
217 * the kernel thread.
218 */
219static irqreturn_t handle_twl6030_pih(int irq, void *devid)
220{
221 disable_irq_nosync(irq);
222 complete(devid);
223 return IRQ_HANDLED; 226 return IRQ_HANDLED;
224} 227}
225 228
226/*----------------------------------------------------------------------*/ 229/*----------------------------------------------------------------------*/
227 230
228static inline void activate_irq(int irq)
229{
230#ifdef CONFIG_ARM
231 /* ARM requires an extra step to clear IRQ_NOREQUEST, which it
232 * sets on behalf of every irq_chip. Also sets IRQ_NOPROBE.
233 */
234 set_irq_flags(irq, IRQF_VALID);
235#else
236 /* same effect on other architectures */
237 irq_set_noprobe(irq);
238#endif
239}
240
241static int twl6030_irq_set_wake(struct irq_data *d, unsigned int on) 231static int twl6030_irq_set_wake(struct irq_data *d, unsigned int on)
242{ 232{
233 struct twl6030_irq *pdata = irq_get_chip_data(d->irq);
234
243 if (on) 235 if (on)
244 atomic_inc(&twl6030_wakeirqs); 236 atomic_inc(&pdata->wakeirqs);
245 else 237 else
246 atomic_dec(&twl6030_wakeirqs); 238 atomic_dec(&pdata->wakeirqs);
247 239
248 return 0; 240 return 0;
249} 241}
@@ -318,7 +310,8 @@ int twl6030_mmc_card_detect_config(void)
318 return ret; 310 return ret;
319 } 311 }
320 312
321 return twl6030_irq_base + MMCDETECT_INTR_OFFSET; 313 return irq_find_mapping(twl6030_irq->irq_domain,
314 MMCDETECT_INTR_OFFSET);
322} 315}
323EXPORT_SYMBOL(twl6030_mmc_card_detect_config); 316EXPORT_SYMBOL(twl6030_mmc_card_detect_config);
324 317
@@ -347,99 +340,143 @@ int twl6030_mmc_card_detect(struct device *dev, int slot)
347} 340}
348EXPORT_SYMBOL(twl6030_mmc_card_detect); 341EXPORT_SYMBOL(twl6030_mmc_card_detect);
349 342
343static int twl6030_irq_map(struct irq_domain *d, unsigned int virq,
344 irq_hw_number_t hwirq)
345{
346 struct twl6030_irq *pdata = d->host_data;
347
348 irq_set_chip_data(virq, pdata);
349 irq_set_chip_and_handler(virq, &pdata->irq_chip, handle_simple_irq);
350 irq_set_nested_thread(virq, true);
351 irq_set_parent(virq, pdata->twl_irq);
352
353#ifdef CONFIG_ARM
354 /*
355 * ARM requires an extra step to clear IRQ_NOREQUEST, which it
356 * sets on behalf of every irq_chip. Also sets IRQ_NOPROBE.
357 */
358 set_irq_flags(virq, IRQF_VALID);
359#else
360 /* same effect on other architectures */
361 irq_set_noprobe(virq);
362#endif
363
364 return 0;
365}
366
367static void twl6030_irq_unmap(struct irq_domain *d, unsigned int virq)
368{
369#ifdef CONFIG_ARM
370 set_irq_flags(virq, 0);
371#endif
372 irq_set_chip_and_handler(virq, NULL, NULL);
373 irq_set_chip_data(virq, NULL);
374}
375
376static struct irq_domain_ops twl6030_irq_domain_ops = {
377 .map = twl6030_irq_map,
378 .unmap = twl6030_irq_unmap,
379 .xlate = irq_domain_xlate_onetwocell,
380};
381
382static const struct of_device_id twl6030_of_match[] = {
383 {.compatible = "ti,twl6030", &twl6030_interrupt_mapping},
384 {.compatible = "ti,twl6032", &twl6032_interrupt_mapping},
385 { },
386};
387
350int twl6030_init_irq(struct device *dev, int irq_num) 388int twl6030_init_irq(struct device *dev, int irq_num)
351{ 389{
352 struct device_node *node = dev->of_node; 390 struct device_node *node = dev->of_node;
353 int nr_irqs, irq_base, irq_end; 391 int nr_irqs;
354 struct task_struct *task; 392 int status;
355 static struct irq_chip twl6030_irq_chip;
356 int status = 0;
357 int i;
358 u8 mask[3]; 393 u8 mask[3];
394 const struct of_device_id *of_id;
359 395
360 nr_irqs = TWL6030_NR_IRQS; 396 of_id = of_match_device(twl6030_of_match, dev);
361 397 if (!of_id || !of_id->data) {
362 irq_base = irq_alloc_descs(-1, 0, nr_irqs, 0); 398 dev_err(dev, "Unknown TWL device model\n");
363 if (IS_ERR_VALUE(irq_base)) { 399 return -EINVAL;
364 dev_err(dev, "Fail to allocate IRQ descs\n");
365 return irq_base;
366 } 400 }
367 401
368 irq_domain_add_legacy(node, nr_irqs, irq_base, 0, 402 nr_irqs = TWL6030_NR_IRQS;
369 &irq_domain_simple_ops, NULL);
370 403
371 irq_end = irq_base + nr_irqs; 404 twl6030_irq = devm_kzalloc(dev, sizeof(*twl6030_irq), GFP_KERNEL);
405 if (!twl6030_irq) {
406 dev_err(dev, "twl6030_irq: Memory allocation failed\n");
407 return -ENOMEM;
408 }
372 409
373 mask[0] = 0xFF; 410 mask[0] = 0xFF;
374 mask[1] = 0xFF; 411 mask[1] = 0xFF;
375 mask[2] = 0xFF; 412 mask[2] = 0xFF;
376 413
377 /* mask all int lines */ 414 /* mask all int lines */
378 twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_MSK_LINE_A, 3); 415 status = twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_MSK_LINE_A, 3);
379 /* mask all int sts */ 416 /* mask all int sts */
380 twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_MSK_STS_A, 3); 417 status |= twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_MSK_STS_A, 3);
381 /* clear INT_STS_A,B,C */ 418 /* clear INT_STS_A,B,C */
382 twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_STS_A, 3); 419 status |= twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_STS_A, 3);
383 420
384 twl6030_irq_base = irq_base; 421 if (status < 0) {
422 dev_err(dev, "I2C err writing TWL_MODULE_PIH: %d\n", status);
423 return status;
424 }
385 425
386 /* 426 /*
387 * install an irq handler for each of the modules; 427 * install an irq handler for each of the modules;
388 * clone dummy irq_chip since PIH can't *do* anything 428 * clone dummy irq_chip since PIH can't *do* anything
389 */ 429 */
390 twl6030_irq_chip = dummy_irq_chip; 430 twl6030_irq->irq_chip = dummy_irq_chip;
391 twl6030_irq_chip.name = "twl6030"; 431 twl6030_irq->irq_chip.name = "twl6030";
392 twl6030_irq_chip.irq_set_type = NULL; 432 twl6030_irq->irq_chip.irq_set_type = NULL;
393 twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake; 433 twl6030_irq->irq_chip.irq_set_wake = twl6030_irq_set_wake;
394 434
395 for (i = irq_base; i < irq_end; i++) { 435 twl6030_irq->pm_nb.notifier_call = twl6030_irq_pm_notifier;
396 irq_set_chip_and_handler(i, &twl6030_irq_chip, 436 atomic_set(&twl6030_irq->wakeirqs, 0);
397 handle_simple_irq); 437 twl6030_irq->irq_mapping_tbl = of_id->data;
398 irq_set_chip_data(i, (void *)irq_num); 438
399 activate_irq(i); 439 twl6030_irq->irq_domain =
440 irq_domain_add_linear(node, nr_irqs,
441 &twl6030_irq_domain_ops, twl6030_irq);
442 if (!twl6030_irq->irq_domain) {
443 dev_err(dev, "Can't add irq_domain\n");
444 return -ENOMEM;
400 } 445 }
401 446
402 dev_info(dev, "PIH (irq %d) chaining IRQs %d..%d\n", 447 dev_info(dev, "PIH (irq %d) nested IRQs\n", irq_num);
403 irq_num, irq_base, irq_end);
404 448
405 /* install an irq handler to demultiplex the TWL6030 interrupt */ 449 /* install an irq handler to demultiplex the TWL6030 interrupt */
406 init_completion(&irq_event); 450 status = request_threaded_irq(irq_num, NULL, twl6030_irq_thread,
407 451 IRQF_ONESHOT, "TWL6030-PIH", twl6030_irq);
408 status = request_irq(irq_num, handle_twl6030_pih, 0, "TWL6030-PIH",
409 &irq_event);
410 if (status < 0) { 452 if (status < 0) {
411 dev_err(dev, "could not claim irq %d: %d\n", irq_num, status); 453 dev_err(dev, "could not claim irq %d: %d\n", irq_num, status);
412 goto fail_irq; 454 goto fail_irq;
413 } 455 }
414 456
415 task = kthread_run(twl6030_irq_thread, (void *)irq_num, "twl6030-irq"); 457 twl6030_irq->twl_irq = irq_num;
416 if (IS_ERR(task)) { 458 register_pm_notifier(&twl6030_irq->pm_nb);
417 dev_err(dev, "could not create irq %d thread!\n", irq_num); 459 return 0;
418 status = PTR_ERR(task);
419 goto fail_kthread;
420 }
421
422 twl_irq = irq_num;
423 register_pm_notifier(&twl6030_irq_pm_notifier_block);
424 return irq_base;
425
426fail_kthread:
427 free_irq(irq_num, &irq_event);
428 460
429fail_irq: 461fail_irq:
430 for (i = irq_base; i < irq_end; i++) 462 irq_domain_remove(twl6030_irq->irq_domain);
431 irq_set_chip_and_handler(i, NULL, NULL);
432
433 return status; 463 return status;
434} 464}
435 465
436int twl6030_exit_irq(void) 466int twl6030_exit_irq(void)
437{ 467{
438 unregister_pm_notifier(&twl6030_irq_pm_notifier_block); 468 if (twl6030_irq && twl6030_irq->twl_irq) {
439 469 unregister_pm_notifier(&twl6030_irq->pm_nb);
440 if (twl6030_irq_base) { 470 free_irq(twl6030_irq->twl_irq, NULL);
441 pr_err("twl6030: can't yet clean up IRQs?\n"); 471 /*
442 return -ENOSYS; 472 * TODO: IRQ domain and allocated nested IRQ descriptors
473 * should be freed somehow here. Now It can't be done, because
474 * child devices will not be deleted during removing of
475 * TWL Core driver and they will still contain allocated
476 * virt IRQs in their Resources tables.
477 * The same prevents us from using devm_request_threaded_irq()
478 * in this module.
479 */
443 } 480 }
444 return 0; 481 return 0;
445} 482}
diff --git a/drivers/mfd/twl6040.c b/drivers/mfd/twl6040.c
index 492ee2cd3400..daf66942071c 100644
--- a/drivers/mfd/twl6040.c
+++ b/drivers/mfd/twl6040.c
@@ -44,17 +44,12 @@
44#define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1) 44#define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1)
45#define TWL6040_NUM_SUPPLIES (2) 45#define TWL6040_NUM_SUPPLIES (2)
46 46
47static bool twl6040_has_vibra(struct twl6040_platform_data *pdata, 47static bool twl6040_has_vibra(struct device_node *node)
48 struct device_node *node)
49{ 48{
50 if (pdata && pdata->vibra)
51 return true;
52
53#ifdef CONFIG_OF 49#ifdef CONFIG_OF
54 if (of_find_node_by_name(node, "vibra")) 50 if (of_find_node_by_name(node, "vibra"))
55 return true; 51 return true;
56#endif 52#endif
57
58 return false; 53 return false;
59} 54}
60 55
@@ -63,15 +58,9 @@ int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg)
63 int ret; 58 int ret;
64 unsigned int val; 59 unsigned int val;
65 60
66 /* Vibra control registers from cache */ 61 ret = regmap_read(twl6040->regmap, reg, &val);
67 if (unlikely(reg == TWL6040_REG_VIBCTLL || 62 if (ret < 0)
68 reg == TWL6040_REG_VIBCTLR)) { 63 return ret;
69 val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)];
70 } else {
71 ret = regmap_read(twl6040->regmap, reg, &val);
72 if (ret < 0)
73 return ret;
74 }
75 64
76 return val; 65 return val;
77} 66}
@@ -82,9 +71,6 @@ int twl6040_reg_write(struct twl6040 *twl6040, unsigned int reg, u8 val)
82 int ret; 71 int ret;
83 72
84 ret = regmap_write(twl6040->regmap, reg, val); 73 ret = regmap_write(twl6040->regmap, reg, val);
85 /* Cache the vibra control registers */
86 if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR)
87 twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val;
88 74
89 return ret; 75 return ret;
90} 76}
@@ -461,9 +447,20 @@ EXPORT_SYMBOL(twl6040_get_sysclk);
461/* Get the combined status of the vibra control register */ 447/* Get the combined status of the vibra control register */
462int twl6040_get_vibralr_status(struct twl6040 *twl6040) 448int twl6040_get_vibralr_status(struct twl6040 *twl6040)
463{ 449{
450 unsigned int reg;
451 int ret;
464 u8 status; 452 u8 status;
465 453
466 status = twl6040->vibra_ctrl_cache[0] | twl6040->vibra_ctrl_cache[1]; 454 ret = regmap_read(twl6040->regmap, TWL6040_REG_VIBCTLL, &reg);
455 if (ret != 0)
456 return ret;
457 status = reg;
458
459 ret = regmap_read(twl6040->regmap, TWL6040_REG_VIBCTLR, &reg);
460 if (ret != 0)
461 return ret;
462 status |= reg;
463
467 status &= (TWL6040_VIBENA | TWL6040_VIBSEL); 464 status &= (TWL6040_VIBENA | TWL6040_VIBSEL);
468 465
469 return status; 466 return status;
@@ -490,12 +487,27 @@ static bool twl6040_readable_reg(struct device *dev, unsigned int reg)
490 return true; 487 return true;
491} 488}
492 489
490static bool twl6040_volatile_reg(struct device *dev, unsigned int reg)
491{
492 switch (reg) {
493 case TWL6040_REG_VIBCTLL:
494 case TWL6040_REG_VIBCTLR:
495 case TWL6040_REG_INTMR:
496 return false;
497 default:
498 return true;
499 }
500}
501
493static struct regmap_config twl6040_regmap_config = { 502static struct regmap_config twl6040_regmap_config = {
494 .reg_bits = 8, 503 .reg_bits = 8,
495 .val_bits = 8, 504 .val_bits = 8,
496 .max_register = TWL6040_REG_STATUS, /* 0x2e */ 505 .max_register = TWL6040_REG_STATUS, /* 0x2e */
497 506
498 .readable_reg = twl6040_readable_reg, 507 .readable_reg = twl6040_readable_reg,
508 .volatile_reg = twl6040_volatile_reg,
509
510 .cache_type = REGCACHE_RBTREE,
499}; 511};
500 512
501static const struct regmap_irq twl6040_irqs[] = { 513static const struct regmap_irq twl6040_irqs[] = {
@@ -520,14 +532,13 @@ static struct regmap_irq_chip twl6040_irq_chip = {
520static int twl6040_probe(struct i2c_client *client, 532static int twl6040_probe(struct i2c_client *client,
521 const struct i2c_device_id *id) 533 const struct i2c_device_id *id)
522{ 534{
523 struct twl6040_platform_data *pdata = client->dev.platform_data;
524 struct device_node *node = client->dev.of_node; 535 struct device_node *node = client->dev.of_node;
525 struct twl6040 *twl6040; 536 struct twl6040 *twl6040;
526 struct mfd_cell *cell = NULL; 537 struct mfd_cell *cell = NULL;
527 int irq, ret, children = 0; 538 int irq, ret, children = 0;
528 539
529 if (!pdata && !node) { 540 if (!node) {
530 dev_err(&client->dev, "Platform data is missing\n"); 541 dev_err(&client->dev, "of node is missing\n");
531 return -EINVAL; 542 return -EINVAL;
532 } 543 }
533 544
@@ -539,23 +550,19 @@ static int twl6040_probe(struct i2c_client *client,
539 550
540 twl6040 = devm_kzalloc(&client->dev, sizeof(struct twl6040), 551 twl6040 = devm_kzalloc(&client->dev, sizeof(struct twl6040),
541 GFP_KERNEL); 552 GFP_KERNEL);
542 if (!twl6040) { 553 if (!twl6040)
543 ret = -ENOMEM; 554 return -ENOMEM;
544 goto err;
545 }
546 555
547 twl6040->regmap = devm_regmap_init_i2c(client, &twl6040_regmap_config); 556 twl6040->regmap = devm_regmap_init_i2c(client, &twl6040_regmap_config);
548 if (IS_ERR(twl6040->regmap)) { 557 if (IS_ERR(twl6040->regmap))
549 ret = PTR_ERR(twl6040->regmap); 558 return PTR_ERR(twl6040->regmap);
550 goto err;
551 }
552 559
553 i2c_set_clientdata(client, twl6040); 560 i2c_set_clientdata(client, twl6040);
554 561
555 twl6040->supplies[0].supply = "vio"; 562 twl6040->supplies[0].supply = "vio";
556 twl6040->supplies[1].supply = "v2v1"; 563 twl6040->supplies[1].supply = "v2v1";
557 ret = devm_regulator_bulk_get(&client->dev, TWL6040_NUM_SUPPLIES, 564 ret = devm_regulator_bulk_get(&client->dev, TWL6040_NUM_SUPPLIES,
558 twl6040->supplies); 565 twl6040->supplies);
559 if (ret != 0) { 566 if (ret != 0) {
560 dev_err(&client->dev, "Failed to get supplies: %d\n", ret); 567 dev_err(&client->dev, "Failed to get supplies: %d\n", ret);
561 goto regulator_get_err; 568 goto regulator_get_err;
@@ -576,44 +583,40 @@ static int twl6040_probe(struct i2c_client *client,
576 twl6040->rev = twl6040_reg_read(twl6040, TWL6040_REG_ASICREV); 583 twl6040->rev = twl6040_reg_read(twl6040, TWL6040_REG_ASICREV);
577 584
578 /* ERRATA: Automatic power-up is not possible in ES1.0 */ 585 /* ERRATA: Automatic power-up is not possible in ES1.0 */
579 if (twl6040_get_revid(twl6040) > TWL6040_REV_ES1_0) { 586 if (twl6040_get_revid(twl6040) > TWL6040_REV_ES1_0)
580 if (pdata) 587 twl6040->audpwron = of_get_named_gpio(node,
581 twl6040->audpwron = pdata->audpwron_gpio; 588 "ti,audpwron-gpio", 0);
582 else 589 else
583 twl6040->audpwron = of_get_named_gpio(node,
584 "ti,audpwron-gpio", 0);
585 } else
586 twl6040->audpwron = -EINVAL; 590 twl6040->audpwron = -EINVAL;
587 591
588 if (gpio_is_valid(twl6040->audpwron)) { 592 if (gpio_is_valid(twl6040->audpwron)) {
589 ret = devm_gpio_request_one(&client->dev, twl6040->audpwron, 593 ret = devm_gpio_request_one(&client->dev, twl6040->audpwron,
590 GPIOF_OUT_INIT_LOW, "audpwron"); 594 GPIOF_OUT_INIT_LOW, "audpwron");
591 if (ret) 595 if (ret)
592 goto gpio_err; 596 goto gpio_err;
593 } 597 }
594 598
595 ret = regmap_add_irq_chip(twl6040->regmap, twl6040->irq, 599 ret = regmap_add_irq_chip(twl6040->regmap, twl6040->irq, IRQF_ONESHOT,
596 IRQF_ONESHOT, 0, &twl6040_irq_chip, 600 0, &twl6040_irq_chip,&twl6040->irq_data);
597 &twl6040->irq_data);
598 if (ret < 0) 601 if (ret < 0)
599 goto gpio_err; 602 goto gpio_err;
600 603
601 twl6040->irq_ready = regmap_irq_get_virq(twl6040->irq_data, 604 twl6040->irq_ready = regmap_irq_get_virq(twl6040->irq_data,
602 TWL6040_IRQ_READY); 605 TWL6040_IRQ_READY);
603 twl6040->irq_th = regmap_irq_get_virq(twl6040->irq_data, 606 twl6040->irq_th = regmap_irq_get_virq(twl6040->irq_data,
604 TWL6040_IRQ_TH); 607 TWL6040_IRQ_TH);
605 608
606 ret = devm_request_threaded_irq(twl6040->dev, twl6040->irq_ready, NULL, 609 ret = devm_request_threaded_irq(twl6040->dev, twl6040->irq_ready, NULL,
607 twl6040_readyint_handler, IRQF_ONESHOT, 610 twl6040_readyint_handler, IRQF_ONESHOT,
608 "twl6040_irq_ready", twl6040); 611 "twl6040_irq_ready", twl6040);
609 if (ret) { 612 if (ret) {
610 dev_err(twl6040->dev, "READY IRQ request failed: %d\n", ret); 613 dev_err(twl6040->dev, "READY IRQ request failed: %d\n", ret);
611 goto readyirq_err; 614 goto readyirq_err;
612 } 615 }
613 616
614 ret = devm_request_threaded_irq(twl6040->dev, twl6040->irq_th, NULL, 617 ret = devm_request_threaded_irq(twl6040->dev, twl6040->irq_th, NULL,
615 twl6040_thint_handler, IRQF_ONESHOT, 618 twl6040_thint_handler, IRQF_ONESHOT,
616 "twl6040_irq_th", twl6040); 619 "twl6040_irq_th", twl6040);
617 if (ret) { 620 if (ret) {
618 dev_err(twl6040->dev, "Thermal IRQ request failed: %d\n", ret); 621 dev_err(twl6040->dev, "Thermal IRQ request failed: %d\n", ret);
619 goto thirq_err; 622 goto thirq_err;
@@ -625,8 +628,6 @@ static int twl6040_probe(struct i2c_client *client,
625 /* 628 /*
626 * The main functionality of twl6040 to provide audio on OMAP4+ systems. 629 * The main functionality of twl6040 to provide audio on OMAP4+ systems.
627 * We can add the ASoC codec child whenever this driver has been loaded. 630 * We can add the ASoC codec child whenever this driver has been loaded.
628 * The ASoC codec can work without pdata, pass the platform_data only if
629 * it has been provided.
630 */ 631 */
631 irq = regmap_irq_get_virq(twl6040->irq_data, TWL6040_IRQ_PLUG); 632 irq = regmap_irq_get_virq(twl6040->irq_data, TWL6040_IRQ_PLUG);
632 cell = &twl6040->cells[children]; 633 cell = &twl6040->cells[children];
@@ -635,13 +636,10 @@ static int twl6040_probe(struct i2c_client *client,
635 twl6040_codec_rsrc[0].end = irq; 636 twl6040_codec_rsrc[0].end = irq;
636 cell->resources = twl6040_codec_rsrc; 637 cell->resources = twl6040_codec_rsrc;
637 cell->num_resources = ARRAY_SIZE(twl6040_codec_rsrc); 638 cell->num_resources = ARRAY_SIZE(twl6040_codec_rsrc);
638 if (pdata && pdata->codec) {
639 cell->platform_data = pdata->codec;
640 cell->pdata_size = sizeof(*pdata->codec);
641 }
642 children++; 639 children++;
643 640
644 if (twl6040_has_vibra(pdata, node)) { 641 /* Vibra input driver support */
642 if (twl6040_has_vibra(node)) {
645 irq = regmap_irq_get_virq(twl6040->irq_data, TWL6040_IRQ_VIB); 643 irq = regmap_irq_get_virq(twl6040->irq_data, TWL6040_IRQ_VIB);
646 644
647 cell = &twl6040->cells[children]; 645 cell = &twl6040->cells[children];
@@ -650,28 +648,13 @@ static int twl6040_probe(struct i2c_client *client,
650 twl6040_vibra_rsrc[0].end = irq; 648 twl6040_vibra_rsrc[0].end = irq;
651 cell->resources = twl6040_vibra_rsrc; 649 cell->resources = twl6040_vibra_rsrc;
652 cell->num_resources = ARRAY_SIZE(twl6040_vibra_rsrc); 650 cell->num_resources = ARRAY_SIZE(twl6040_vibra_rsrc);
653
654 if (pdata && pdata->vibra) {
655 cell->platform_data = pdata->vibra;
656 cell->pdata_size = sizeof(*pdata->vibra);
657 }
658 children++; 651 children++;
659 } 652 }
660 653
661 /* 654 /* GPO support */
662 * Enable the GPO driver in the following cases: 655 cell = &twl6040->cells[children];
663 * DT booted kernel or legacy boot with valid gpo platform_data 656 cell->name = "twl6040-gpo";
664 */ 657 children++;
665 if (!pdata || (pdata && pdata->gpo)) {
666 cell = &twl6040->cells[children];
667 cell->name = "twl6040-gpo";
668
669 if (pdata) {
670 cell->platform_data = pdata->gpo;
671 cell->pdata_size = sizeof(*pdata->gpo);
672 }
673 children++;
674 }
675 658
676 ret = mfd_add_devices(&client->dev, -1, twl6040->cells, children, 659 ret = mfd_add_devices(&client->dev, -1, twl6040->cells, children,
677 NULL, 0, NULL); 660 NULL, 0, NULL);
@@ -690,7 +673,7 @@ gpio_err:
690 regulator_bulk_disable(TWL6040_NUM_SUPPLIES, twl6040->supplies); 673 regulator_bulk_disable(TWL6040_NUM_SUPPLIES, twl6040->supplies);
691regulator_get_err: 674regulator_get_err:
692 i2c_set_clientdata(client, NULL); 675 i2c_set_clientdata(client, NULL);
693err: 676
694 return ret; 677 return ret;
695} 678}
696 679
diff --git a/drivers/mfd/ucb1400_core.c b/drivers/mfd/ucb1400_core.c
index e9031fa9d53d..ebb20edf9c17 100644
--- a/drivers/mfd/ucb1400_core.c
+++ b/drivers/mfd/ucb1400_core.c
@@ -52,7 +52,7 @@ static int ucb1400_core_probe(struct device *dev)
52 struct ucb1400_ts ucb_ts; 52 struct ucb1400_ts ucb_ts;
53 struct ucb1400_gpio ucb_gpio; 53 struct ucb1400_gpio ucb_gpio;
54 struct snd_ac97 *ac97; 54 struct snd_ac97 *ac97;
55 struct ucb1400_pdata *pdata = dev->platform_data; 55 struct ucb1400_pdata *pdata = dev_get_platdata(dev);
56 56
57 memset(&ucb_ts, 0, sizeof(ucb_ts)); 57 memset(&ucb_ts, 0, sizeof(ucb_ts));
58 memset(&ucb_gpio, 0, sizeof(ucb_gpio)); 58 memset(&ucb_gpio, 0, sizeof(ucb_gpio));
diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c
index 70f02daeb22a..d5966e6b5a7d 100644
--- a/drivers/mfd/ucb1x00-core.c
+++ b/drivers/mfd/ucb1x00-core.c
@@ -393,22 +393,24 @@ static struct irq_chip ucb1x00_irqchip = {
393static int ucb1x00_add_dev(struct ucb1x00 *ucb, struct ucb1x00_driver *drv) 393static int ucb1x00_add_dev(struct ucb1x00 *ucb, struct ucb1x00_driver *drv)
394{ 394{
395 struct ucb1x00_dev *dev; 395 struct ucb1x00_dev *dev;
396 int ret = -ENOMEM; 396 int ret;
397 397
398 dev = kmalloc(sizeof(struct ucb1x00_dev), GFP_KERNEL); 398 dev = kmalloc(sizeof(struct ucb1x00_dev), GFP_KERNEL);
399 if (dev) { 399 if (!dev)
400 dev->ucb = ucb; 400 return -ENOMEM;
401 dev->drv = drv; 401
402 402 dev->ucb = ucb;
403 ret = drv->add(dev); 403 dev->drv = drv;
404 404
405 if (ret == 0) { 405 ret = drv->add(dev);
406 list_add_tail(&dev->dev_node, &ucb->devs); 406 if (ret) {
407 list_add_tail(&dev->drv_node, &drv->devs); 407 kfree(dev);
408 } else { 408 return ret;
409 kfree(dev);
410 }
411 } 409 }
410
411 list_add_tail(&dev->dev_node, &ucb->devs);
412 list_add_tail(&dev->drv_node, &drv->devs);
413
412 return ret; 414 return ret;
413} 415}
414 416
@@ -669,9 +671,10 @@ void ucb1x00_unregister_driver(struct ucb1x00_driver *drv)
669 mutex_unlock(&ucb1x00_mutex); 671 mutex_unlock(&ucb1x00_mutex);
670} 672}
671 673
674#ifdef CONFIG_PM_SLEEP
672static int ucb1x00_suspend(struct device *dev) 675static int ucb1x00_suspend(struct device *dev)
673{ 676{
674 struct ucb1x00_plat_data *pdata = dev->platform_data; 677 struct ucb1x00_plat_data *pdata = dev_get_platdata(dev);
675 struct ucb1x00 *ucb = dev_get_drvdata(dev); 678 struct ucb1x00 *ucb = dev_get_drvdata(dev);
676 struct ucb1x00_dev *udev; 679 struct ucb1x00_dev *udev;
677 680
@@ -703,7 +706,7 @@ static int ucb1x00_suspend(struct device *dev)
703 706
704static int ucb1x00_resume(struct device *dev) 707static int ucb1x00_resume(struct device *dev)
705{ 708{
706 struct ucb1x00_plat_data *pdata = dev->platform_data; 709 struct ucb1x00_plat_data *pdata = dev_get_platdata(dev);
707 struct ucb1x00 *ucb = dev_get_drvdata(dev); 710 struct ucb1x00 *ucb = dev_get_drvdata(dev);
708 struct ucb1x00_dev *udev; 711 struct ucb1x00_dev *udev;
709 712
@@ -736,6 +739,7 @@ static int ucb1x00_resume(struct device *dev)
736 mutex_unlock(&ucb1x00_mutex); 739 mutex_unlock(&ucb1x00_mutex);
737 return 0; 740 return 0;
738} 741}
742#endif
739 743
740static const struct dev_pm_ops ucb1x00_pm_ops = { 744static const struct dev_pm_ops ucb1x00_pm_ops = {
741 SET_SYSTEM_SLEEP_PM_OPS(ucb1x00_suspend, ucb1x00_resume) 745 SET_SYSTEM_SLEEP_PM_OPS(ucb1x00_suspend, ucb1x00_resume)
diff --git a/drivers/mfd/wl1273-core.c b/drivers/mfd/wl1273-core.c
index edbe6c1b755a..f7c52d901040 100644
--- a/drivers/mfd/wl1273-core.c
+++ b/drivers/mfd/wl1273-core.c
@@ -172,12 +172,9 @@ static int wl1273_fm_set_volume(struct wl1273_core *core, unsigned int volume)
172 172
173static int wl1273_core_remove(struct i2c_client *client) 173static int wl1273_core_remove(struct i2c_client *client)
174{ 174{
175 struct wl1273_core *core = i2c_get_clientdata(client);
176
177 dev_dbg(&client->dev, "%s\n", __func__); 175 dev_dbg(&client->dev, "%s\n", __func__);
178 176
179 mfd_remove_devices(&client->dev); 177 mfd_remove_devices(&client->dev);
180 kfree(core);
181 178
182 return 0; 179 return 0;
183} 180}
@@ -185,7 +182,7 @@ static int wl1273_core_remove(struct i2c_client *client)
185static int wl1273_core_probe(struct i2c_client *client, 182static int wl1273_core_probe(struct i2c_client *client,
186 const struct i2c_device_id *id) 183 const struct i2c_device_id *id)
187{ 184{
188 struct wl1273_fm_platform_data *pdata = client->dev.platform_data; 185 struct wl1273_fm_platform_data *pdata = dev_get_platdata(&client->dev);
189 struct wl1273_core *core; 186 struct wl1273_core *core;
190 struct mfd_cell *cell; 187 struct mfd_cell *cell;
191 int children = 0; 188 int children = 0;
@@ -203,7 +200,7 @@ static int wl1273_core_probe(struct i2c_client *client,
203 return -EINVAL; 200 return -EINVAL;
204 } 201 }
205 202
206 core = kzalloc(sizeof(*core), GFP_KERNEL); 203 core = devm_kzalloc(&client->dev, sizeof(*core), GFP_KERNEL);
207 if (!core) 204 if (!core)
208 return -ENOMEM; 205 return -ENOMEM;
209 206
@@ -249,7 +246,6 @@ static int wl1273_core_probe(struct i2c_client *client,
249 246
250err: 247err:
251 pdata->free_resources(); 248 pdata->free_resources();
252 kfree(core);
253 249
254 dev_dbg(&client->dev, "%s\n", __func__); 250 dev_dbg(&client->dev, "%s\n", __func__);
255 251
diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c
index 2a7972349159..3113e39b318e 100644
--- a/drivers/mfd/wm5110-tables.c
+++ b/drivers/mfd/wm5110-tables.c
@@ -468,12 +468,14 @@ static const struct reg_default wm5110_reg_default[] = {
468 { 0x00000176, 0x0000 }, /* R374 - FLL1 Control 6 */ 468 { 0x00000176, 0x0000 }, /* R374 - FLL1 Control 6 */
469 { 0x00000177, 0x0281 }, /* R375 - FLL1 Loop Filter Test 1 */ 469 { 0x00000177, 0x0281 }, /* R375 - FLL1 Loop Filter Test 1 */
470 { 0x00000178, 0x0000 }, /* R376 - FLL1 NCO Test 0 */ 470 { 0x00000178, 0x0000 }, /* R376 - FLL1 NCO Test 0 */
471 { 0x00000179, 0x0000 }, /* R376 - FLL1 Control 7 */
471 { 0x00000181, 0x0000 }, /* R385 - FLL1 Synchroniser 1 */ 472 { 0x00000181, 0x0000 }, /* R385 - FLL1 Synchroniser 1 */
472 { 0x00000182, 0x0000 }, /* R386 - FLL1 Synchroniser 2 */ 473 { 0x00000182, 0x0000 }, /* R386 - FLL1 Synchroniser 2 */
473 { 0x00000183, 0x0000 }, /* R387 - FLL1 Synchroniser 3 */ 474 { 0x00000183, 0x0000 }, /* R387 - FLL1 Synchroniser 3 */
474 { 0x00000184, 0x0000 }, /* R388 - FLL1 Synchroniser 4 */ 475 { 0x00000184, 0x0000 }, /* R388 - FLL1 Synchroniser 4 */
475 { 0x00000185, 0x0000 }, /* R389 - FLL1 Synchroniser 5 */ 476 { 0x00000185, 0x0000 }, /* R389 - FLL1 Synchroniser 5 */
476 { 0x00000186, 0x0000 }, /* R390 - FLL1 Synchroniser 6 */ 477 { 0x00000186, 0x0000 }, /* R390 - FLL1 Synchroniser 6 */
478 { 0x00000187, 0x0001 }, /* R390 - FLL1 Synchroniser 7 */
477 { 0x00000189, 0x0000 }, /* R393 - FLL1 Spread Spectrum */ 479 { 0x00000189, 0x0000 }, /* R393 - FLL1 Spread Spectrum */
478 { 0x0000018A, 0x0004 }, /* R394 - FLL1 GPIO Clock */ 480 { 0x0000018A, 0x0004 }, /* R394 - FLL1 GPIO Clock */
479 { 0x00000191, 0x0000 }, /* R401 - FLL2 Control 1 */ 481 { 0x00000191, 0x0000 }, /* R401 - FLL2 Control 1 */
@@ -484,12 +486,14 @@ static const struct reg_default wm5110_reg_default[] = {
484 { 0x00000196, 0x0000 }, /* R406 - FLL2 Control 6 */ 486 { 0x00000196, 0x0000 }, /* R406 - FLL2 Control 6 */
485 { 0x00000197, 0x0000 }, /* R407 - FLL2 Loop Filter Test 1 */ 487 { 0x00000197, 0x0000 }, /* R407 - FLL2 Loop Filter Test 1 */
486 { 0x00000198, 0x0000 }, /* R408 - FLL2 NCO Test 0 */ 488 { 0x00000198, 0x0000 }, /* R408 - FLL2 NCO Test 0 */
489 { 0x00000199, 0x0000 }, /* R408 - FLL2 Control 7 */
487 { 0x000001A1, 0x0000 }, /* R417 - FLL2 Synchroniser 1 */ 490 { 0x000001A1, 0x0000 }, /* R417 - FLL2 Synchroniser 1 */
488 { 0x000001A2, 0x0000 }, /* R418 - FLL2 Synchroniser 2 */ 491 { 0x000001A2, 0x0000 }, /* R418 - FLL2 Synchroniser 2 */
489 { 0x000001A3, 0x0000 }, /* R419 - FLL2 Synchroniser 3 */ 492 { 0x000001A3, 0x0000 }, /* R419 - FLL2 Synchroniser 3 */
490 { 0x000001A4, 0x0000 }, /* R420 - FLL2 Synchroniser 4 */ 493 { 0x000001A4, 0x0000 }, /* R420 - FLL2 Synchroniser 4 */
491 { 0x000001A5, 0x0000 }, /* R421 - FLL2 Synchroniser 5 */ 494 { 0x000001A5, 0x0000 }, /* R421 - FLL2 Synchroniser 5 */
492 { 0x000001A6, 0x0000 }, /* R422 - FLL2 Synchroniser 6 */ 495 { 0x000001A6, 0x0000 }, /* R422 - FLL2 Synchroniser 6 */
496 { 0x000001A7, 0x0001 }, /* R422 - FLL2 Synchroniser 7 */
493 { 0x000001A9, 0x0000 }, /* R425 - FLL2 Spread Spectrum */ 497 { 0x000001A9, 0x0000 }, /* R425 - FLL2 Spread Spectrum */
494 { 0x000001AA, 0x0004 }, /* R426 - FLL2 GPIO Clock */ 498 { 0x000001AA, 0x0004 }, /* R426 - FLL2 GPIO Clock */
495 { 0x00000200, 0x0006 }, /* R512 - Mic Charge Pump 1 */ 499 { 0x00000200, 0x0006 }, /* R512 - Mic Charge Pump 1 */
@@ -503,6 +507,11 @@ static const struct reg_default wm5110_reg_default[] = {
503 { 0x0000029C, 0x0000 }, /* R668 - Headphone Detect 2 */ 507 { 0x0000029C, 0x0000 }, /* R668 - Headphone Detect 2 */
504 { 0x000002A3, 0x1102 }, /* R675 - Mic Detect 1 */ 508 { 0x000002A3, 0x1102 }, /* R675 - Mic Detect 1 */
505 { 0x000002A4, 0x009F }, /* R676 - Mic Detect 2 */ 509 { 0x000002A4, 0x009F }, /* R676 - Mic Detect 2 */
510 { 0x000002A5, 0x0000 }, /* R677 - Mic Detect 3 */
511 { 0x000002A6, 0x3737 }, /* R678 - Mic Detect Level 1 */
512 { 0x000002A7, 0x372C }, /* R679 - Mic Detect Level 2 */
513 { 0x000002A8, 0x1422 }, /* R680 - Mic Detect Level 3 */
514 { 0x000002A9, 0x300A }, /* R681 - Mic Detect Level 4 */
506 { 0x000002C3, 0x0000 }, /* R707 - Mic noise mix control 1 */ 515 { 0x000002C3, 0x0000 }, /* R707 - Mic noise mix control 1 */
507 { 0x000002D3, 0x0000 }, /* R723 - Jack detect analogue */ 516 { 0x000002D3, 0x0000 }, /* R723 - Jack detect analogue */
508 { 0x00000300, 0x0000 }, /* R768 - Input Enables */ 517 { 0x00000300, 0x0000 }, /* R768 - Input Enables */
@@ -1392,6 +1401,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg)
1392 case ARIZONA_FLL1_CONTROL_4: 1401 case ARIZONA_FLL1_CONTROL_4:
1393 case ARIZONA_FLL1_CONTROL_5: 1402 case ARIZONA_FLL1_CONTROL_5:
1394 case ARIZONA_FLL1_CONTROL_6: 1403 case ARIZONA_FLL1_CONTROL_6:
1404 case ARIZONA_FLL1_CONTROL_7:
1395 case ARIZONA_FLL1_LOOP_FILTER_TEST_1: 1405 case ARIZONA_FLL1_LOOP_FILTER_TEST_1:
1396 case ARIZONA_FLL1_NCO_TEST_0: 1406 case ARIZONA_FLL1_NCO_TEST_0:
1397 case ARIZONA_FLL1_SYNCHRONISER_1: 1407 case ARIZONA_FLL1_SYNCHRONISER_1:
@@ -1400,6 +1410,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg)
1400 case ARIZONA_FLL1_SYNCHRONISER_4: 1410 case ARIZONA_FLL1_SYNCHRONISER_4:
1401 case ARIZONA_FLL1_SYNCHRONISER_5: 1411 case ARIZONA_FLL1_SYNCHRONISER_5:
1402 case ARIZONA_FLL1_SYNCHRONISER_6: 1412 case ARIZONA_FLL1_SYNCHRONISER_6:
1413 case ARIZONA_FLL1_SYNCHRONISER_7:
1403 case ARIZONA_FLL1_SPREAD_SPECTRUM: 1414 case ARIZONA_FLL1_SPREAD_SPECTRUM:
1404 case ARIZONA_FLL1_GPIO_CLOCK: 1415 case ARIZONA_FLL1_GPIO_CLOCK:
1405 case ARIZONA_FLL2_CONTROL_1: 1416 case ARIZONA_FLL2_CONTROL_1:
@@ -1408,6 +1419,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg)
1408 case ARIZONA_FLL2_CONTROL_4: 1419 case ARIZONA_FLL2_CONTROL_4:
1409 case ARIZONA_FLL2_CONTROL_5: 1420 case ARIZONA_FLL2_CONTROL_5:
1410 case ARIZONA_FLL2_CONTROL_6: 1421 case ARIZONA_FLL2_CONTROL_6:
1422 case ARIZONA_FLL2_CONTROL_7:
1411 case ARIZONA_FLL2_LOOP_FILTER_TEST_1: 1423 case ARIZONA_FLL2_LOOP_FILTER_TEST_1:
1412 case ARIZONA_FLL2_NCO_TEST_0: 1424 case ARIZONA_FLL2_NCO_TEST_0:
1413 case ARIZONA_FLL2_SYNCHRONISER_1: 1425 case ARIZONA_FLL2_SYNCHRONISER_1:
@@ -1416,6 +1428,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg)
1416 case ARIZONA_FLL2_SYNCHRONISER_4: 1428 case ARIZONA_FLL2_SYNCHRONISER_4:
1417 case ARIZONA_FLL2_SYNCHRONISER_5: 1429 case ARIZONA_FLL2_SYNCHRONISER_5:
1418 case ARIZONA_FLL2_SYNCHRONISER_6: 1430 case ARIZONA_FLL2_SYNCHRONISER_6:
1431 case ARIZONA_FLL2_SYNCHRONISER_7:
1419 case ARIZONA_FLL2_SPREAD_SPECTRUM: 1432 case ARIZONA_FLL2_SPREAD_SPECTRUM:
1420 case ARIZONA_FLL2_GPIO_CLOCK: 1433 case ARIZONA_FLL2_GPIO_CLOCK:
1421 case ARIZONA_MIC_CHARGE_PUMP_1: 1434 case ARIZONA_MIC_CHARGE_PUMP_1:
@@ -1430,6 +1443,10 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg)
1430 case ARIZONA_MIC_DETECT_1: 1443 case ARIZONA_MIC_DETECT_1:
1431 case ARIZONA_MIC_DETECT_2: 1444 case ARIZONA_MIC_DETECT_2:
1432 case ARIZONA_MIC_DETECT_3: 1445 case ARIZONA_MIC_DETECT_3:
1446 case ARIZONA_MIC_DETECT_LEVEL_1:
1447 case ARIZONA_MIC_DETECT_LEVEL_2:
1448 case ARIZONA_MIC_DETECT_LEVEL_3:
1449 case ARIZONA_MIC_DETECT_LEVEL_4:
1433 case ARIZONA_MIC_NOISE_MIX_CONTROL_1: 1450 case ARIZONA_MIC_NOISE_MIX_CONTROL_1:
1434 case ARIZONA_JACK_DETECT_ANALOGUE: 1451 case ARIZONA_JACK_DETECT_ANALOGUE:
1435 case ARIZONA_INPUT_ENABLES: 1452 case ARIZONA_INPUT_ENABLES:
@@ -2332,6 +2349,7 @@ static bool wm5110_volatile_register(struct device *dev, unsigned int reg)
2332 case ARIZONA_IRQ_PIN_STATUS: 2349 case ARIZONA_IRQ_PIN_STATUS:
2333 case ARIZONA_AOD_IRQ1: 2350 case ARIZONA_AOD_IRQ1:
2334 case ARIZONA_AOD_IRQ2: 2351 case ARIZONA_AOD_IRQ2:
2352 case ARIZONA_FX_CTRL2:
2335 case ARIZONA_ASRC_STATUS: 2353 case ARIZONA_ASRC_STATUS:
2336 case ARIZONA_DSP_STATUS: 2354 case ARIZONA_DSP_STATUS:
2337 case ARIZONA_DSP1_CONTROL_1: 2355 case ARIZONA_DSP1_CONTROL_1:
diff --git a/drivers/mfd/wm831x-core.c b/drivers/mfd/wm831x-core.c
index 521340a708d3..5c459f469224 100644
--- a/drivers/mfd/wm831x-core.c
+++ b/drivers/mfd/wm831x-core.c
@@ -1618,7 +1618,7 @@ EXPORT_SYMBOL_GPL(wm831x_regmap_config);
1618 */ 1618 */
1619int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) 1619int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
1620{ 1620{
1621 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 1621 struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev);
1622 int rev, wm831x_num; 1622 int rev, wm831x_num;
1623 enum wm831x_parent parent; 1623 enum wm831x_parent parent;
1624 int ret, i; 1624 int ret, i;
diff --git a/drivers/mfd/wm831x-irq.c b/drivers/mfd/wm831x-irq.c
index 804e56ec99eb..64e512eadf17 100644
--- a/drivers/mfd/wm831x-irq.c
+++ b/drivers/mfd/wm831x-irq.c
@@ -571,7 +571,7 @@ static struct irq_domain_ops wm831x_irq_domain_ops = {
571 571
572int wm831x_irq_init(struct wm831x *wm831x, int irq) 572int wm831x_irq_init(struct wm831x *wm831x, int irq)
573{ 573{
574 struct wm831x_pdata *pdata = wm831x->dev->platform_data; 574 struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev);
575 struct irq_domain *domain; 575 struct irq_domain *domain;
576 int i, ret, irq_base; 576 int i, ret, irq_base;
577 577
diff --git a/drivers/mfd/wm831x-spi.c b/drivers/mfd/wm831x-spi.c
index e7ed14f661d8..07de3cc5a0d9 100644
--- a/drivers/mfd/wm831x-spi.c
+++ b/drivers/mfd/wm831x-spi.c
@@ -34,7 +34,6 @@ static int wm831x_spi_probe(struct spi_device *spi)
34 if (wm831x == NULL) 34 if (wm831x == NULL)
35 return -ENOMEM; 35 return -ENOMEM;
36 36
37 spi->bits_per_word = 16;
38 spi->mode = SPI_MODE_0; 37 spi->mode = SPI_MODE_0;
39 38
40 spi_set_drvdata(spi, wm831x); 39 spi_set_drvdata(spi, wm831x);
diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c
index 2e57101c8d3d..f919def05e24 100644
--- a/drivers/mfd/wm8350-i2c.c
+++ b/drivers/mfd/wm8350-i2c.c
@@ -27,6 +27,7 @@ static int wm8350_i2c_probe(struct i2c_client *i2c,
27 const struct i2c_device_id *id) 27 const struct i2c_device_id *id)
28{ 28{
29 struct wm8350 *wm8350; 29 struct wm8350 *wm8350;
30 struct wm8350_platform_data *pdata = dev_get_platdata(&i2c->dev);
30 int ret = 0; 31 int ret = 0;
31 32
32 wm8350 = devm_kzalloc(&i2c->dev, sizeof(struct wm8350), GFP_KERNEL); 33 wm8350 = devm_kzalloc(&i2c->dev, sizeof(struct wm8350), GFP_KERNEL);
@@ -44,7 +45,7 @@ static int wm8350_i2c_probe(struct i2c_client *i2c,
44 i2c_set_clientdata(i2c, wm8350); 45 i2c_set_clientdata(i2c, wm8350);
45 wm8350->dev = &i2c->dev; 46 wm8350->dev = &i2c->dev;
46 47
47 return wm8350_device_init(wm8350, i2c->irq, i2c->dev.platform_data); 48 return wm8350_device_init(wm8350, i2c->irq, pdata);
48} 49}
49 50
50static int wm8350_i2c_remove(struct i2c_client *i2c) 51static int wm8350_i2c_remove(struct i2c_client *i2c)
diff --git a/drivers/mfd/wm8400-core.c b/drivers/mfd/wm8400-core.c
index 639ca359242f..d66d256551fb 100644
--- a/drivers/mfd/wm8400-core.c
+++ b/drivers/mfd/wm8400-core.c
@@ -178,7 +178,7 @@ static int wm8400_i2c_probe(struct i2c_client *i2c,
178 wm8400->dev = &i2c->dev; 178 wm8400->dev = &i2c->dev;
179 i2c_set_clientdata(i2c, wm8400); 179 i2c_set_clientdata(i2c, wm8400);
180 180
181 ret = wm8400_init(wm8400, i2c->dev.platform_data); 181 ret = wm8400_init(wm8400, dev_get_platdata(&i2c->dev));
182 if (ret != 0) 182 if (ret != 0)
183 goto err; 183 goto err;
184 184
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
index 781115e8dca9..e1c283e6d4e5 100644
--- a/drivers/mfd/wm8994-core.c
+++ b/drivers/mfd/wm8994-core.c
@@ -201,35 +201,7 @@ static int wm8994_suspend(struct device *dev)
201 int ret; 201 int ret;
202 202
203 /* Don't actually go through with the suspend if the CODEC is 203 /* Don't actually go through with the suspend if the CODEC is
204 * still active (eg, for audio passthrough from CP. */ 204 * still active for accessory detect. */
205 ret = wm8994_reg_read(wm8994, WM8994_POWER_MANAGEMENT_1);
206 if (ret < 0) {
207 dev_err(dev, "Failed to read power status: %d\n", ret);
208 } else if (ret & WM8994_VMID_SEL_MASK) {
209 dev_dbg(dev, "CODEC still active, ignoring suspend\n");
210 return 0;
211 }
212
213 ret = wm8994_reg_read(wm8994, WM8994_POWER_MANAGEMENT_4);
214 if (ret < 0) {
215 dev_err(dev, "Failed to read power status: %d\n", ret);
216 } else if (ret & (WM8994_AIF2ADCL_ENA | WM8994_AIF2ADCR_ENA |
217 WM8994_AIF1ADC2L_ENA | WM8994_AIF1ADC2R_ENA |
218 WM8994_AIF1ADC1L_ENA | WM8994_AIF1ADC1R_ENA)) {
219 dev_dbg(dev, "CODEC still active, ignoring suspend\n");
220 return 0;
221 }
222
223 ret = wm8994_reg_read(wm8994, WM8994_POWER_MANAGEMENT_5);
224 if (ret < 0) {
225 dev_err(dev, "Failed to read power status: %d\n", ret);
226 } else if (ret & (WM8994_AIF2DACL_ENA | WM8994_AIF2DACR_ENA |
227 WM8994_AIF1DAC2L_ENA | WM8994_AIF1DAC2R_ENA |
228 WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA)) {
229 dev_dbg(dev, "CODEC still active, ignoring suspend\n");
230 return 0;
231 }
232
233 switch (wm8994->type) { 205 switch (wm8994->type) {
234 case WM8958: 206 case WM8958:
235 case WM1811: 207 case WM1811:
@@ -245,20 +217,6 @@ static int wm8994_suspend(struct device *dev)
245 break; 217 break;
246 } 218 }
247 219
248 switch (wm8994->type) {
249 case WM1811:
250 ret = wm8994_reg_read(wm8994, WM8994_ANTIPOP_2);
251 if (ret < 0) {
252 dev_err(dev, "Failed to read jackdet: %d\n", ret);
253 } else if (ret & WM1811_JACKDET_MODE_MASK) {
254 dev_dbg(dev, "CODEC still active, ignoring suspend\n");
255 return 0;
256 }
257 break;
258 default:
259 break;
260 }
261
262 /* Disable LDO pulldowns while the device is suspended if we 220 /* Disable LDO pulldowns while the device is suspended if we
263 * don't know that something will be driving them. */ 221 * don't know that something will be driving them. */
264 if (!wm8994->ldo_ena_always_driven) 222 if (!wm8994->ldo_ena_always_driven)
diff --git a/drivers/mfd/wm8994-irq.c b/drivers/mfd/wm8994-irq.c
index d3a184a240f5..e74dedda5b55 100644
--- a/drivers/mfd/wm8994-irq.c
+++ b/drivers/mfd/wm8994-irq.c
@@ -193,7 +193,7 @@ int wm8994_irq_init(struct wm8994 *wm8994)
193{ 193{
194 int ret; 194 int ret;
195 unsigned long irqflags; 195 unsigned long irqflags;
196 struct wm8994_pdata *pdata = wm8994->dev->platform_data; 196 struct wm8994_pdata *pdata = dev_get_platdata(wm8994->dev);
197 197
198 if (!wm8994->irq) { 198 if (!wm8994->irq) {
199 dev_warn(wm8994->dev, 199 dev_warn(wm8994->dev,
diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
index 82a35b91cdbc..375a880e0c5f 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -1,6 +1,6 @@
1/* Realtek PCI-Express SD/MMC Card Interface driver 1/* Realtek PCI-Express SD/MMC Card Interface driver
2 * 2 *
3 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. 3 * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License as published by the
@@ -17,7 +17,6 @@
17 * 17 *
18 * Author: 18 * Author:
19 * Wei WANG <wei_wang@realsil.com.cn> 19 * Wei WANG <wei_wang@realsil.com.cn>
20 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
21 */ 20 */
22 21
23#include <linux/module.h> 22#include <linux/module.h>
@@ -56,7 +55,6 @@ struct realtek_pci_sdmmc {
56 bool double_clk; 55 bool double_clk;
57 bool eject; 56 bool eject;
58 bool initial_mode; 57 bool initial_mode;
59 bool ddr_mode;
60 int power_state; 58 int power_state;
61#define SDMMC_POWER_ON 1 59#define SDMMC_POWER_ON 1
62#define SDMMC_POWER_OFF 0 60#define SDMMC_POWER_OFF 0
@@ -228,6 +226,7 @@ static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc *host,
228 int stat_idx = 0; 226 int stat_idx = 0;
229 u8 rsp_type; 227 u8 rsp_type;
230 int rsp_len = 5; 228 int rsp_len = 5;
229 bool clock_toggled = false;
231 230
232 dev_dbg(sdmmc_dev(host), "%s: SD/MMC CMD %d, arg = 0x%08x\n", 231 dev_dbg(sdmmc_dev(host), "%s: SD/MMC CMD %d, arg = 0x%08x\n",
233 __func__, cmd_idx, arg); 232 __func__, cmd_idx, arg);
@@ -271,6 +270,8 @@ static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc *host,
271 0xFF, SD_CLK_TOGGLE_EN); 270 0xFF, SD_CLK_TOGGLE_EN);
272 if (err < 0) 271 if (err < 0)
273 goto out; 272 goto out;
273
274 clock_toggled = true;
274 } 275 }
275 276
276 rtsx_pci_init_cmd(pcr); 277 rtsx_pci_init_cmd(pcr);
@@ -351,6 +352,10 @@ static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc *host,
351 352
352out: 353out:
353 cmd->error = err; 354 cmd->error = err;
355
356 if (err && clock_toggled)
357 rtsx_pci_write_register(pcr, SD_BUS_STAT,
358 SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0);
354} 359}
355 360
356static int sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq) 361static int sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq)
@@ -475,18 +480,24 @@ static void sd_normal_rw(struct realtek_pci_sdmmc *host,
475 kfree(buf); 480 kfree(buf);
476} 481}
477 482
478static int sd_change_phase(struct realtek_pci_sdmmc *host, u8 sample_point) 483static int sd_change_phase(struct realtek_pci_sdmmc *host,
484 u8 sample_point, bool rx)
479{ 485{
480 struct rtsx_pcr *pcr = host->pcr; 486 struct rtsx_pcr *pcr = host->pcr;
481 int err; 487 int err;
482 488
483 dev_dbg(sdmmc_dev(host), "%s: sample_point = %d\n", 489 dev_dbg(sdmmc_dev(host), "%s(%s): sample_point = %d\n",
484 __func__, sample_point); 490 __func__, rx ? "RX" : "TX", sample_point);
485 491
486 rtsx_pci_init_cmd(pcr); 492 rtsx_pci_init_cmd(pcr);
487 493
488 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CLK_CTL, CHANGE_CLK, CHANGE_CLK); 494 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CLK_CTL, CHANGE_CLK, CHANGE_CLK);
489 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_VPRX_CTL, 0x1F, sample_point); 495 if (rx)
496 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
497 SD_VPRX_CTL, 0x1F, sample_point);
498 else
499 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD,
500 SD_VPTX_CTL, 0x1F, sample_point);
490 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_VPCLK0_CTL, PHASE_NOT_RESET, 0); 501 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_VPCLK0_CTL, PHASE_NOT_RESET, 0);
491 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_VPCLK0_CTL, 502 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_VPCLK0_CTL,
492 PHASE_NOT_RESET, PHASE_NOT_RESET); 503 PHASE_NOT_RESET, PHASE_NOT_RESET);
@@ -602,7 +613,7 @@ static int sd_tuning_rx_cmd(struct realtek_pci_sdmmc *host,
602 int err; 613 int err;
603 u8 cmd[5] = {0}; 614 u8 cmd[5] = {0};
604 615
605 err = sd_change_phase(host, sample_point); 616 err = sd_change_phase(host, sample_point, true);
606 if (err < 0) 617 if (err < 0)
607 return err; 618 return err;
608 619
@@ -664,7 +675,7 @@ static int sd_tuning_rx(struct realtek_pci_sdmmc *host, u8 opcode)
664 if (final_phase == 0xFF) 675 if (final_phase == 0xFF)
665 return -EINVAL; 676 return -EINVAL;
666 677
667 err = sd_change_phase(host, final_phase); 678 err = sd_change_phase(host, final_phase, true);
668 if (err < 0) 679 if (err < 0)
669 return err; 680 return err;
670 } else { 681 } else {
@@ -833,14 +844,11 @@ static int sd_set_power_mode(struct realtek_pci_sdmmc *host,
833 return err; 844 return err;
834} 845}
835 846
836static int sd_set_timing(struct realtek_pci_sdmmc *host, 847static int sd_set_timing(struct realtek_pci_sdmmc *host, unsigned char timing)
837 unsigned char timing, bool *ddr_mode)
838{ 848{
839 struct rtsx_pcr *pcr = host->pcr; 849 struct rtsx_pcr *pcr = host->pcr;
840 int err = 0; 850 int err = 0;
841 851
842 *ddr_mode = false;
843
844 rtsx_pci_init_cmd(pcr); 852 rtsx_pci_init_cmd(pcr);
845 853
846 switch (timing) { 854 switch (timing) {
@@ -857,8 +865,6 @@ static int sd_set_timing(struct realtek_pci_sdmmc *host,
857 break; 865 break;
858 866
859 case MMC_TIMING_UHS_DDR50: 867 case MMC_TIMING_UHS_DDR50:
860 *ddr_mode = true;
861
862 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CFG1, 868 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CFG1,
863 0x0C | SD_ASYNC_FIFO_NOT_RST, 869 0x0C | SD_ASYNC_FIFO_NOT_RST,
864 SD_DDR_MODE | SD_ASYNC_FIFO_NOT_RST); 870 SD_DDR_MODE | SD_ASYNC_FIFO_NOT_RST);
@@ -926,7 +932,7 @@ static void sdmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
926 932
927 sd_set_bus_width(host, ios->bus_width); 933 sd_set_bus_width(host, ios->bus_width);
928 sd_set_power_mode(host, ios->power_mode); 934 sd_set_power_mode(host, ios->power_mode);
929 sd_set_timing(host, ios->timing, &host->ddr_mode); 935 sd_set_timing(host, ios->timing);
930 936
931 host->vpclk = false; 937 host->vpclk = false;
932 host->double_clk = true; 938 host->double_clk = true;
@@ -1121,11 +1127,11 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
1121 goto out; 1127 goto out;
1122 } 1128 }
1123 1129
1130out:
1124 /* Stop toggle SD clock in idle */ 1131 /* Stop toggle SD clock in idle */
1125 err = rtsx_pci_write_register(pcr, SD_BUS_STAT, 1132 err = rtsx_pci_write_register(pcr, SD_BUS_STAT,
1126 SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0); 1133 SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0);
1127 1134
1128out:
1129 mutex_unlock(&pcr->pcr_mutex); 1135 mutex_unlock(&pcr->pcr_mutex);
1130 1136
1131 return err; 1137 return err;
@@ -1148,9 +1154,35 @@ static int sdmmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
1148 1154
1149 rtsx_pci_start_run(pcr); 1155 rtsx_pci_start_run(pcr);
1150 1156
1151 if (!host->ddr_mode) 1157 /* Set initial TX phase */
1152 err = sd_tuning_rx(host, MMC_SEND_TUNING_BLOCK); 1158 switch (mmc->ios.timing) {
1159 case MMC_TIMING_UHS_SDR104:
1160 err = sd_change_phase(host, SDR104_TX_PHASE(pcr), false);
1161 break;
1162
1163 case MMC_TIMING_UHS_SDR50:
1164 err = sd_change_phase(host, SDR50_TX_PHASE(pcr), false);
1165 break;
1166
1167 case MMC_TIMING_UHS_DDR50:
1168 err = sd_change_phase(host, DDR50_TX_PHASE(pcr), false);
1169 break;
1170
1171 default:
1172 err = 0;
1173 }
1153 1174
1175 if (err)
1176 goto out;
1177
1178 /* Tuning RX phase */
1179 if ((mmc->ios.timing == MMC_TIMING_UHS_SDR104) ||
1180 (mmc->ios.timing == MMC_TIMING_UHS_SDR50))
1181 err = sd_tuning_rx(host, opcode);
1182 else if (mmc->ios.timing == MMC_TIMING_UHS_DDR50)
1183 err = sd_change_phase(host, DDR50_RX_PHASE(pcr), true);
1184
1185out:
1154 mutex_unlock(&pcr->pcr_mutex); 1186 mutex_unlock(&pcr->pcr_mutex);
1155 1187
1156 return err; 1188 return err;
diff --git a/include/linux/mfd/da9063/core.h b/include/linux/mfd/da9063/core.h
new file mode 100644
index 000000000000..2d2a0af675fd
--- /dev/null
+++ b/include/linux/mfd/da9063/core.h
@@ -0,0 +1,93 @@
1/*
2 * Definitions for DA9063 MFD driver
3 *
4 * Copyright 2012 Dialog Semiconductor Ltd.
5 *
6 * Author: Michal Hajduk <michal.hajduk@diasemi.com>
7 * Krystian Garbaciak <krystian.garbaciak@diasemi.com>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 */
15
16#ifndef __MFD_DA9063_CORE_H__
17#define __MFD_DA9063_CORE_H__
18
19#include <linux/interrupt.h>
20#include <linux/mfd/da9063/registers.h>
21
22/* DA9063 modules */
23#define DA9063_DRVNAME_CORE "da9063-core"
24#define DA9063_DRVNAME_REGULATORS "da9063-regulators"
25#define DA9063_DRVNAME_LEDS "da9063-leds"
26#define DA9063_DRVNAME_WATCHDOG "da9063-watchdog"
27#define DA9063_DRVNAME_HWMON "da9063-hwmon"
28#define DA9063_DRVNAME_ONKEY "da9063-onkey"
29#define DA9063_DRVNAME_RTC "da9063-rtc"
30#define DA9063_DRVNAME_VIBRATION "da9063-vibration"
31
32enum da9063_models {
33 PMIC_DA9063 = 0x61,
34};
35
36/* Interrupts */
37enum da9063_irqs {
38 DA9063_IRQ_ONKEY = 0,
39 DA9063_IRQ_ALARM,
40 DA9063_IRQ_TICK,
41 DA9063_IRQ_ADC_RDY,
42 DA9063_IRQ_SEQ_RDY,
43 DA9063_IRQ_WAKE,
44 DA9063_IRQ_TEMP,
45 DA9063_IRQ_COMP_1V2,
46 DA9063_IRQ_LDO_LIM,
47 DA9063_IRQ_REG_UVOV,
48 DA9063_IRQ_VDD_MON,
49 DA9063_IRQ_WARN,
50 DA9063_IRQ_GPI0,
51 DA9063_IRQ_GPI1,
52 DA9063_IRQ_GPI2,
53 DA9063_IRQ_GPI3,
54 DA9063_IRQ_GPI4,
55 DA9063_IRQ_GPI5,
56 DA9063_IRQ_GPI6,
57 DA9063_IRQ_GPI7,
58 DA9063_IRQ_GPI8,
59 DA9063_IRQ_GPI9,
60 DA9063_IRQ_GPI10,
61 DA9063_IRQ_GPI11,
62 DA9063_IRQ_GPI12,
63 DA9063_IRQ_GPI13,
64 DA9063_IRQ_GPI14,
65 DA9063_IRQ_GPI15,
66};
67
68#define DA9063_IRQ_BASE_OFFSET 0
69#define DA9063_NUM_IRQ (DA9063_IRQ_GPI15 + 1 - DA9063_IRQ_BASE_OFFSET)
70
71struct da9063 {
72 /* Device */
73 struct device *dev;
74 unsigned short model;
75 unsigned short revision;
76 unsigned int flags;
77
78 /* Control interface */
79 struct regmap *regmap;
80
81 /* Interrupts */
82 int chip_irq;
83 unsigned int irq_base;
84 struct regmap_irq_chip_data *regmap_irq;
85};
86
87int da9063_device_init(struct da9063 *da9063, unsigned int irq);
88int da9063_irq_init(struct da9063 *da9063);
89
90void da9063_device_exit(struct da9063 *da9063);
91void da9063_irq_exit(struct da9063 *da9063);
92
93#endif /* __MFD_DA9063_CORE_H__ */
diff --git a/include/linux/mfd/da9063/pdata.h b/include/linux/mfd/da9063/pdata.h
new file mode 100644
index 000000000000..95c8742215a7
--- /dev/null
+++ b/include/linux/mfd/da9063/pdata.h
@@ -0,0 +1,111 @@
1/*
2 * Platform configuration options for DA9063
3 *
4 * Copyright 2012 Dialog Semiconductor Ltd.
5 *
6 * Author: Michal Hajduk <michal.hajduk@diasemi.com>
7 * Author: Krystian Garbaciak <krystian.garbaciak@diasemi.com>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 */
15
16#ifndef __MFD_DA9063_PDATA_H__
17#define __MFD_DA9063_PDATA_H__
18
19#include <linux/regulator/machine.h>
20
21/*
22 * Regulator configuration
23 */
24/* DA9063 regulator IDs */
25enum {
26 /* BUCKs */
27 DA9063_ID_BCORE1,
28 DA9063_ID_BCORE2,
29 DA9063_ID_BPRO,
30 DA9063_ID_BMEM,
31 DA9063_ID_BIO,
32 DA9063_ID_BPERI,
33
34 /* BCORE1 and BCORE2 in merged mode */
35 DA9063_ID_BCORES_MERGED,
36 /* BMEM and BIO in merged mode */
37 DA9063_ID_BMEM_BIO_MERGED,
38 /* When two BUCKs are merged, they cannot be reused separately */
39
40 /* LDOs */
41 DA9063_ID_LDO1,
42 DA9063_ID_LDO2,
43 DA9063_ID_LDO3,
44 DA9063_ID_LDO4,
45 DA9063_ID_LDO5,
46 DA9063_ID_LDO6,
47 DA9063_ID_LDO7,
48 DA9063_ID_LDO8,
49 DA9063_ID_LDO9,
50 DA9063_ID_LDO10,
51 DA9063_ID_LDO11,
52};
53
54/* Regulators platform data */
55struct da9063_regulator_data {
56 int id;
57 struct regulator_init_data *initdata;
58};
59
60struct da9063_regulators_pdata {
61 unsigned n_regulators;
62 struct da9063_regulator_data *regulator_data;
63};
64
65
66/*
67 * RGB LED configuration
68 */
69/* LED IDs for flags in struct led_info. */
70enum {
71 DA9063_GPIO11_LED,
72 DA9063_GPIO14_LED,
73 DA9063_GPIO15_LED,
74
75 DA9063_LED_NUM
76};
77#define DA9063_LED_ID_MASK 0x3
78
79/* LED polarity for flags in struct led_info. */
80#define DA9063_LED_HIGH_LEVEL_ACTIVE 0x0
81#define DA9063_LED_LOW_LEVEL_ACTIVE 0x4
82
83
84/*
85 * General PMIC configuration
86 */
87/* HWMON ADC channels configuration */
88#define DA9063_FLG_FORCE_IN0_MANUAL_MODE 0x0010
89#define DA9063_FLG_FORCE_IN0_AUTO_MODE 0x0020
90#define DA9063_FLG_FORCE_IN1_MANUAL_MODE 0x0040
91#define DA9063_FLG_FORCE_IN1_AUTO_MODE 0x0080
92#define DA9063_FLG_FORCE_IN2_MANUAL_MODE 0x0100
93#define DA9063_FLG_FORCE_IN2_AUTO_MODE 0x0200
94#define DA9063_FLG_FORCE_IN3_MANUAL_MODE 0x0400
95#define DA9063_FLG_FORCE_IN3_AUTO_MODE 0x0800
96
97/* Disable register caching. */
98#define DA9063_FLG_NO_CACHE 0x0008
99
100struct da9063;
101
102/* DA9063 platform data */
103struct da9063_pdata {
104 int (*init)(struct da9063 *da9063);
105 int irq_base;
106 unsigned flags;
107 struct da9063_regulators_pdata *regulators_pdata;
108 struct led_platform_data *leds_pdata;
109};
110
111#endif /* __MFD_DA9063_PDATA_H__ */
diff --git a/include/linux/mfd/da9063/registers.h b/include/linux/mfd/da9063/registers.h
new file mode 100644
index 000000000000..5834813fb5f3
--- /dev/null
+++ b/include/linux/mfd/da9063/registers.h
@@ -0,0 +1,1028 @@
1/*
2 * Registers definition for DA9063 modules
3 *
4 * Copyright 2012 Dialog Semiconductor Ltd.
5 *
6 * Author: Michal Hajduk <michal.hajduk@diasemi.com>
7 * Krystian Garbaciak <krystian.garbaciak@diasemi.com>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 */
15
16#ifndef _DA9063_REG_H
17#define _DA9063_REG_H
18
19#define DA9063_I2C_PAGE_SEL_SHIFT 1
20
21#define DA9063_EVENT_REG_NUM 4
22#define DA9210_EVENT_REG_NUM 2
23#define DA9063_EXT_EVENT_REG_NUM (DA9063_EVENT_REG_NUM + \
24 DA9210_EVENT_REG_NUM)
25
26/* Page selection I2C or SPI always in the begining of any page. */
27/* Page 0 : I2C access 0x000 - 0x0FF SPI access 0x000 - 0x07F */
28/* Page 1 : SPI access 0x080 - 0x0FF */
29/* Page 2 : I2C access 0x100 - 0x1FF SPI access 0x100 - 0x17F */
30/* Page 3 : SPI access 0x180 - 0x1FF */
31#define DA9063_REG_PAGE_CON 0x00
32
33/* System Control and Event Registers */
34#define DA9063_REG_STATUS_A 0x01
35#define DA9063_REG_STATUS_B 0x02
36#define DA9063_REG_STATUS_C 0x03
37#define DA9063_REG_STATUS_D 0x04
38#define DA9063_REG_FAULT_LOG 0x05
39#define DA9063_REG_EVENT_A 0x06
40#define DA9063_REG_EVENT_B 0x07
41#define DA9063_REG_EVENT_C 0x08
42#define DA9063_REG_EVENT_D 0x09
43#define DA9063_REG_IRQ_MASK_A 0x0A
44#define DA9063_REG_IRQ_MASK_B 0x0B
45#define DA9063_REG_IRQ_MASK_C 0x0C
46#define DA9063_REG_IRQ_MASK_D 0x0D
47#define DA9063_REG_CONTROL_A 0x0E
48#define DA9063_REG_CONTROL_B 0x0F
49#define DA9063_REG_CONTROL_C 0x10
50#define DA9063_REG_CONTROL_D 0x11
51#define DA9063_REG_CONTROL_E 0x12
52#define DA9063_REG_CONTROL_F 0x13
53#define DA9063_REG_PD_DIS 0x14
54
55/* GPIO Control Registers */
56#define DA9063_REG_GPIO_0_1 0x15
57#define DA9063_REG_GPIO_2_3 0x16
58#define DA9063_REG_GPIO_4_5 0x17
59#define DA9063_REG_GPIO_6_7 0x18
60#define DA9063_REG_GPIO_8_9 0x19
61#define DA9063_REG_GPIO_10_11 0x1A
62#define DA9063_REG_GPIO_12_13 0x1B
63#define DA9063_REG_GPIO_14_15 0x1C
64#define DA9063_REG_GPIO_MODE_0_7 0x1D
65#define DA9063_REG_GPIO_MODE_8_15 0x1E
66#define DA9063_REG_GPIO_SWITCH_CONT 0x1F
67
68/* Regulator Control Registers */
69#define DA9063_REG_BCORE2_CONT 0x20
70#define DA9063_REG_BCORE1_CONT 0x21
71#define DA9063_REG_BPRO_CONT 0x22
72#define DA9063_REG_BMEM_CONT 0x23
73#define DA9063_REG_BIO_CONT 0x24
74#define DA9063_REG_BPERI_CONT 0x25
75#define DA9063_REG_LDO1_CONT 0x26
76#define DA9063_REG_LDO2_CONT 0x27
77#define DA9063_REG_LDO3_CONT 0x28
78#define DA9063_REG_LDO4_CONT 0x29
79#define DA9063_REG_LDO5_CONT 0x2A
80#define DA9063_REG_LDO6_CONT 0x2B
81#define DA9063_REG_LDO7_CONT 0x2C
82#define DA9063_REG_LDO8_CONT 0x2D
83#define DA9063_REG_LDO9_CONT 0x2E
84#define DA9063_REG_LDO10_CONT 0x2F
85#define DA9063_REG_LDO11_CONT 0x30
86#define DA9063_REG_VIB 0x31
87#define DA9063_REG_DVC_1 0x32
88#define DA9063_REG_DVC_2 0x33
89
90/* GP-ADC Control Registers */
91#define DA9063_REG_ADC_MAN 0x34
92#define DA9063_REG_ADC_CONT 0x35
93#define DA9063_REG_VSYS_MON 0x36
94#define DA9063_REG_ADC_RES_L 0x37
95#define DA9063_REG_ADC_RES_H 0x38
96#define DA9063_REG_VSYS_RES 0x39
97#define DA9063_REG_ADCIN1_RES 0x3A
98#define DA9063_REG_ADCIN2_RES 0x3B
99#define DA9063_REG_ADCIN3_RES 0x3C
100#define DA9063_REG_MON1_RES 0x3D
101#define DA9063_REG_MON2_RES 0x3E
102#define DA9063_REG_MON3_RES 0x3F
103
104/* RTC Calendar and Alarm Registers */
105#define DA9063_REG_COUNT_S 0x40
106#define DA9063_REG_COUNT_MI 0x41
107#define DA9063_REG_COUNT_H 0x42
108#define DA9063_REG_COUNT_D 0x43
109#define DA9063_REG_COUNT_MO 0x44
110#define DA9063_REG_COUNT_Y 0x45
111#define DA9063_REG_ALARM_MI 0x46
112#define DA9063_REG_ALARM_H 0x47
113#define DA9063_REG_ALARM_D 0x48
114#define DA9063_REG_ALARM_MO 0x49
115#define DA9063_REG_ALARM_Y 0x4A
116#define DA9063_REG_SECOND_A 0x4B
117#define DA9063_REG_SECOND_B 0x4C
118#define DA9063_REG_SECOND_C 0x4D
119#define DA9063_REG_SECOND_D 0x4E
120
121/* Sequencer Control Registers */
122#define DA9063_REG_SEQ 0x81
123#define DA9063_REG_SEQ_TIMER 0x82
124#define DA9063_REG_ID_2_1 0x83
125#define DA9063_REG_ID_4_3 0x84
126#define DA9063_REG_ID_6_5 0x85
127#define DA9063_REG_ID_8_7 0x86
128#define DA9063_REG_ID_10_9 0x87
129#define DA9063_REG_ID_12_11 0x88
130#define DA9063_REG_ID_14_13 0x89
131#define DA9063_REG_ID_16_15 0x8A
132#define DA9063_REG_ID_18_17 0x8B
133#define DA9063_REG_ID_20_19 0x8C
134#define DA9063_REG_ID_22_21 0x8D
135#define DA9063_REG_ID_24_23 0x8E
136#define DA9063_REG_ID_26_25 0x8F
137#define DA9063_REG_ID_28_27 0x90
138#define DA9063_REG_ID_30_29 0x91
139#define DA9063_REG_ID_32_31 0x92
140#define DA9063_REG_SEQ_A 0x95
141#define DA9063_REG_SEQ_B 0x96
142#define DA9063_REG_WAIT 0x97
143#define DA9063_REG_EN_32K 0x98
144#define DA9063_REG_RESET 0x99
145
146/* Regulator Setting Registers */
147#define DA9063_REG_BUCK_ILIM_A 0x9A
148#define DA9063_REG_BUCK_ILIM_B 0x9B
149#define DA9063_REG_BUCK_ILIM_C 0x9C
150#define DA9063_REG_BCORE2_CFG 0x9D
151#define DA9063_REG_BCORE1_CFG 0x9E
152#define DA9063_REG_BPRO_CFG 0x9F
153#define DA9063_REG_BIO_CFG 0xA0
154#define DA9063_REG_BMEM_CFG 0xA1
155#define DA9063_REG_BPERI_CFG 0xA2
156#define DA9063_REG_VBCORE2_A 0xA3
157#define DA9063_REG_VBCORE1_A 0xA4
158#define DA9063_REG_VBPRO_A 0xA5
159#define DA9063_REG_VBMEM_A 0xA6
160#define DA9063_REG_VBIO_A 0xA7
161#define DA9063_REG_VBPERI_A 0xA8
162#define DA9063_REG_VLDO1_A 0xA9
163#define DA9063_REG_VLDO2_A 0xAA
164#define DA9063_REG_VLDO3_A 0xAB
165#define DA9063_REG_VLDO4_A 0xAC
166#define DA9063_REG_VLDO5_A 0xAD
167#define DA9063_REG_VLDO6_A 0xAE
168#define DA9063_REG_VLDO7_A 0xAF
169#define DA9063_REG_VLDO8_A 0xB0
170#define DA9063_REG_VLDO9_A 0xB1
171#define DA9063_REG_VLDO10_A 0xB2
172#define DA9063_REG_VLDO11_A 0xB3
173#define DA9063_REG_VBCORE2_B 0xB4
174#define DA9063_REG_VBCORE1_B 0xB5
175#define DA9063_REG_VBPRO_B 0xB6
176#define DA9063_REG_VBMEM_B 0xB7
177#define DA9063_REG_VBIO_B 0xB8
178#define DA9063_REG_VBPERI_B 0xB9
179#define DA9063_REG_VLDO1_B 0xBA
180#define DA9063_REG_VLDO2_B 0xBB
181#define DA9063_REG_VLDO3_B 0xBC
182#define DA9063_REG_VLDO4_B 0xBD
183#define DA9063_REG_VLDO5_B 0xBE
184#define DA9063_REG_VLDO6_B 0xBF
185#define DA9063_REG_VLDO7_B 0xC0
186#define DA9063_REG_VLDO8_B 0xC1
187#define DA9063_REG_VLDO9_B 0xC2
188#define DA9063_REG_VLDO10_B 0xC3
189#define DA9063_REG_VLDO11_B 0xC4
190
191/* Backup Battery Charger Control Register */
192#define DA9063_REG_BBAT_CONT 0xC5
193
194/* GPIO PWM (LED) */
195#define DA9063_REG_GPO11_LED 0xC6
196#define DA9063_REG_GPO14_LED 0xC7
197#define DA9063_REG_GPO15_LED 0xC8
198
199/* GP-ADC Threshold Registers */
200#define DA9063_REG_ADC_CFG 0xC9
201#define DA9063_REG_AUTO1_HIGH 0xCA
202#define DA9063_REG_AUTO1_LOW 0xCB
203#define DA9063_REG_AUTO2_HIGH 0xCC
204#define DA9063_REG_AUTO2_LOW 0xCD
205#define DA9063_REG_AUTO3_HIGH 0xCE
206#define DA9063_REG_AUTO3_LOW 0xCF
207
208/* DA9063 Configuration registers */
209/* OTP */
210#define DA9063_REG_OPT_COUNT 0x101
211#define DA9063_REG_OPT_ADDR 0x102
212#define DA9063_REG_OPT_DATA 0x103
213
214/* Customer Trim and Configuration */
215#define DA9063_REG_T_OFFSET 0x104
216#define DA9063_REG_INTERFACE 0x105
217#define DA9063_REG_CONFIG_A 0x106
218#define DA9063_REG_CONFIG_B 0x107
219#define DA9063_REG_CONFIG_C 0x108
220#define DA9063_REG_CONFIG_D 0x109
221#define DA9063_REG_CONFIG_E 0x10A
222#define DA9063_REG_CONFIG_F 0x10B
223#define DA9063_REG_CONFIG_G 0x10C
224#define DA9063_REG_CONFIG_H 0x10D
225#define DA9063_REG_CONFIG_I 0x10E
226#define DA9063_REG_CONFIG_J 0x10F
227#define DA9063_REG_CONFIG_K 0x110
228#define DA9063_REG_CONFIG_L 0x111
229#define DA9063_REG_MON_REG_1 0x112
230#define DA9063_REG_MON_REG_2 0x113
231#define DA9063_REG_MON_REG_3 0x114
232#define DA9063_REG_MON_REG_4 0x115
233#define DA9063_REG_MON_REG_5 0x116
234#define DA9063_REG_MON_REG_6 0x117
235#define DA9063_REG_TRIM_CLDR 0x118
236
237/* General Purpose Registers */
238#define DA9063_REG_GP_ID_0 0x119
239#define DA9063_REG_GP_ID_1 0x11A
240#define DA9063_REG_GP_ID_2 0x11B
241#define DA9063_REG_GP_ID_3 0x11C
242#define DA9063_REG_GP_ID_4 0x11D
243#define DA9063_REG_GP_ID_5 0x11E
244#define DA9063_REG_GP_ID_6 0x11F
245#define DA9063_REG_GP_ID_7 0x120
246#define DA9063_REG_GP_ID_8 0x121
247#define DA9063_REG_GP_ID_9 0x122
248#define DA9063_REG_GP_ID_10 0x123
249#define DA9063_REG_GP_ID_11 0x124
250#define DA9063_REG_GP_ID_12 0x125
251#define DA9063_REG_GP_ID_13 0x126
252#define DA9063_REG_GP_ID_14 0x127
253#define DA9063_REG_GP_ID_15 0x128
254#define DA9063_REG_GP_ID_16 0x129
255#define DA9063_REG_GP_ID_17 0x12A
256#define DA9063_REG_GP_ID_18 0x12B
257#define DA9063_REG_GP_ID_19 0x12C
258
259/* Chip ID and variant */
260#define DA9063_REG_CHIP_ID 0x181
261#define DA9063_REG_CHIP_VARIANT 0x182
262
263/*
264 * PMIC registers bits
265 */
266/* DA9063_REG_PAGE_CON (addr=0x00) */
267#define DA9063_PEG_PAGE_SHIFT 0
268#define DA9063_REG_PAGE_MASK 0x07
269#define DA9063_REG_PAGE0 0x00
270#define DA9063_REG_PAGE2 0x02
271#define DA9063_PAGE_WRITE_MODE 0x00
272#define DA9063_REPEAT_WRITE_MODE 0x40
273#define DA9063_PAGE_REVERT 0x80
274
275/* DA9063_REG_STATUS_A (addr=0x01) */
276#define DA9063_NONKEY 0x01
277#define DA9063_WAKE 0x02
278#define DA9063_DVC_BUSY 0x04
279#define DA9063_COMP_1V2 0x08
280
281/* DA9063_REG_STATUS_B (addr=0x02) */
282#define DA9063_GPI0 0x01
283#define DA9063_GPI1 0x02
284#define DA9063_GPI2 0x04
285#define DA9063_GPI3 0x08
286#define DA9063_GPI4 0x10
287#define DA9063_GPI5 0x20
288#define DA9063_GPI6 0x40
289#define DA9063_GPI7 0x80
290
291/* DA9063_REG_STATUS_C (addr=0x03) */
292#define DA9063_GPI8 0x01
293#define DA9063_GPI9 0x02
294#define DA9063_GPI10 0x04
295#define DA9063_GPI11 0x08
296#define DA9063_GPI12 0x10
297#define DA9063_GPI13 0x20
298#define DA9063_GPI14 0x40
299#define DA9063_GPI15 0x80
300
301/* DA9063_REG_STATUS_D (addr=0x04) */
302#define DA9063_LDO3_LIM 0x08
303#define DA9063_LDO4_LIM 0x10
304#define DA9063_LDO7_LIM 0x20
305#define DA9063_LDO8_LIM 0x40
306#define DA9063_LDO11_LIM 0x80
307
308/* DA9063_REG_FAULT_LOG (addr=0x05) */
309#define DA9063_TWD_ERROR 0x01
310#define DA9063_POR 0x02
311#define DA9063_VDD_FAULT 0x04
312#define DA9063_VDD_START 0x08
313#define DA9063_TEMP_CRIT 0x10
314#define DA9063_KEY_RESET 0x20
315#define DA9063_NSHUTDOWN 0x40
316#define DA9063_WAIT_SHUT 0x80
317
318/* DA9063_REG_EVENT_A (addr=0x06) */
319#define DA9063_E_NONKEY 0x01
320#define DA9063_E_ALARM 0x02
321#define DA9063_E_TICK 0x04
322#define DA9063_E_ADC_RDY 0x08
323#define DA9063_E_SEQ_RDY 0x10
324#define DA9063_EVENTS_B 0x20
325#define DA9063_EVENTS_C 0x40
326#define DA9063_EVENTS_D 0x80
327
328/* DA9063_REG_EVENT_B (addr=0x07) */
329#define DA9063_E_WAKE 0x01
330#define DA9063_E_TEMP 0x02
331#define DA9063_E_COMP_1V2 0x04
332#define DA9063_E_LDO_LIM 0x08
333#define DA9063_E_REG_UVOV 0x10
334#define DA9063_E_DVC_RDY 0x20
335#define DA9063_E_VDD_MON 0x40
336#define DA9063_E_VDD_WARN 0x80
337
338/* DA9063_REG_EVENT_C (addr=0x08) */
339#define DA9063_E_GPI0 0x01
340#define DA9063_E_GPI1 0x02
341#define DA9063_E_GPI2 0x04
342#define DA9063_E_GPI3 0x08
343#define DA9063_E_GPI4 0x10
344#define DA9063_E_GPI5 0x20
345#define DA9063_E_GPI6 0x40
346#define DA9063_E_GPI7 0x80
347
348/* DA9063_REG_EVENT_D (addr=0x09) */
349#define DA9063_E_GPI8 0x01
350#define DA9063_E_GPI9 0x02
351#define DA9063_E_GPI10 0x04
352#define DA9063_E_GPI11 0x08
353#define DA9063_E_GPI12 0x10
354#define DA9063_E_GPI13 0x20
355#define DA9063_E_GPI14 0x40
356#define DA9063_E_GPI15 0x80
357
358/* DA9063_REG_IRQ_MASK_A (addr=0x0A) */
359#define DA9063_M_ONKEY 0x01
360#define DA9063_M_ALARM 0x02
361#define DA9063_M_TICK 0x04
362#define DA9063_M_ADC_RDY 0x08
363#define DA9063_M_SEQ_RDY 0x10
364
365/* DA9063_REG_IRQ_MASK_B (addr=0x0B) */
366#define DA9063_M_WAKE 0x01
367#define DA9063_M_TEMP 0x02
368#define DA9063_M_COMP_1V2 0x04
369#define DA9063_M_LDO_LIM 0x08
370#define DA9063_M_UVOV 0x10
371#define DA9063_M_DVC_RDY 0x20
372#define DA9063_M_VDD_MON 0x40
373#define DA9063_M_VDD_WARN 0x80
374
375/* DA9063_REG_IRQ_MASK_C (addr=0x0C) */
376#define DA9063_M_GPI0 0x01
377#define DA9063_M_GPI1 0x02
378#define DA9063_M_GPI2 0x04
379#define DA9063_M_GPI3 0x08
380#define DA9063_M_GPI4 0x10
381#define DA9063_M_GPI5 0x20
382#define DA9063_M_GPI6 0x40
383#define DA9063_M_GPI7 0x80
384
385/* DA9063_REG_IRQ_MASK_D (addr=0x0D) */
386#define DA9063_M_GPI8 0x01
387#define DA9063_M_GPI9 0x02
388#define DA9063_M_GPI10 0x04
389#define DA9063_M_GPI11 0x08
390#define DA9063_M_GPI12 0x10
391#define DA9063_M_GPI13 0x20
392#define DA9063_M_GPI14 0x40
393#define DA9063_M_GPI15 0x80
394
395/* DA9063_REG_CONTROL_A (addr=0x0E) */
396#define DA9063_SYSTEM_EN 0x01
397#define DA9063_POWER_EN 0x02
398#define DA9063_POWER1_EN 0x04
399#define DA9063_STANDBY 0x08
400#define DA9063_M_SYSTEM_EN 0x10
401#define DA9063_M_POWER_EN 0x20
402#define DA9063_M_POWER1_EN 0x40
403#define DA9063_CP_EN 0x80
404
405/* DA9063_REG_CONTROL_B (addr=0x0F) */
406#define DA9063_CHG_SEL 0x01
407#define DA9063_WATCHDOG_PD 0x02
408#define DA9063_NRES_MODE 0x08
409#define DA9063_NONKEY_LOCK 0x10
410
411/* DA9063_REG_CONTROL_C (addr=0x10) */
412#define DA9063_DEBOUNCING_MASK 0x07
413#define DA9063_DEBOUNCING_OFF 0x0
414#define DA9063_DEBOUNCING_0MS1 0x1
415#define DA9063_DEBOUNCING_1MS 0x2
416#define DA9063_DEBOUNCING_10MS24 0x3
417#define DA9063_DEBOUNCING_51MS2 0x4
418#define DA9063_DEBOUNCING_256MS 0x5
419#define DA9063_DEBOUNCING_512MS 0x6
420#define DA9063_DEBOUNCING_1024MS 0x7
421
422#define DA9063_AUTO_BOOT 0x08
423#define DA9063_OTPREAD_EN 0x10
424#define DA9063_SLEW_RATE_MASK 0x60
425#define DA9063_SLEW_RATE_4US 0x00
426#define DA9063_SLEW_RATE_3US 0x20
427#define DA9063_SLEW_RATE_1US 0x40
428#define DA9063_SLEW_RATE_0US5 0x60
429#define DA9063_DEF_SUPPLY 0x80
430
431/* DA9063_REG_CONTROL_D (addr=0x11) */
432#define DA9063_TWDSCALE_MASK 0x07
433#define DA9063_BLINK_FRQ_MASK 0x38
434#define DA9063_BLINK_FRQ_OFF 0x00
435#define DA9063_BLINK_FRQ_1S0 0x08
436#define DA9063_BLINK_FRQ_2S0 0x10
437#define DA9063_BLINK_FRQ_4S0 0x18
438#define DA9063_BLINK_FRQ_0S18 0x20
439#define DA9063_BLINK_FRQ_2S0_VDD 0x28
440#define DA9063_BLINK_FRQ_4S0_VDD 0x30
441#define DA9063_BLINK_FRQ_0S18_VDD 0x38
442
443#define DA9063_BLINK_DUR_MASK 0xC0
444#define DA9063_BLINK_DUR_10MS 0x00
445#define DA9063_BLINK_DUR_20MS 0x40
446#define DA9063_BLINK_DUR_40MS 0x80
447#define DA9063_BLINK_DUR_20MSDBL 0xC0
448
449/* DA9063_REG_CONTROL_E (addr=0x12) */
450#define DA9063_RTC_MODE_PD 0x01
451#define DA9063_RTC_MODE_SD 0x02
452#define DA9063_RTC_EN 0x04
453#define DA9063_ECO_MODE 0x08
454#define DA9063_PM_FB1_PIN 0x10
455#define DA9063_PM_FB2_PIN 0x20
456#define DA9063_PM_FB3_PIN 0x40
457#define DA9063_V_LOCK 0x80
458
459/* DA9063_REG_CONTROL_F (addr=0x13) */
460#define DA9063_WATCHDOG 0x01
461#define DA9063_SHUTDOWN 0x02
462#define DA9063_WAKE_UP 0x04
463
464/* DA9063_REG_PD_DIS (addr=0x14) */
465#define DA9063_GPI_DIS 0x01
466#define DA9063_GPADC_PAUSE 0x02
467#define DA9063_PMIF_DIS 0x04
468#define DA9063_HS2WIRE_DIS 0x08
469#define DA9063_BBAT_DIS 0x20
470#define DA9063_OUT_32K_PAUSE 0x40
471#define DA9063_PMCONT_DIS 0x80
472
473/* DA9063_REG_GPIO_0_1 (addr=0x15) */
474#define DA9063_GPIO0_PIN_MASK 0x03
475#define DA9063_GPIO0_PIN_ADCIN1 0x00
476#define DA9063_GPIO0_PIN_GPI 0x01
477#define DA9063_GPIO0_PIN_GPO_OD 0x02
478#define DA9063_GPIO0_PIN_GPO 0x03
479#define DA9063_GPIO0_TYPE 0x04
480#define DA9063_GPIO0_TYPE_GPI_ACT_LOW 0x00
481#define DA9063_GPIO0_TYPE_GPO_VDD_IO1 0x00
482#define DA9063_GPIO0_TYPE_GPI_ACT_HIGH 0x04
483#define DA9063_GPIO0_TYPE_GPO_VDD_IO2 0x04
484#define DA9063_GPIO0_NO_WAKEUP 0x08
485#define DA9063_GPIO1_PIN_MASK 0x30
486#define DA9063_GPIO1_PIN_ADCIN2_COMP 0x00
487#define DA9063_GPIO1_PIN_GPI 0x10
488#define DA9063_GPIO1_PIN_GPO_OD 0x20
489#define DA9063_GPIO1_PIN_GPO 0x30
490#define DA9063_GPIO1_TYPE 0x40
491#define DA9063_GPIO1_TYPE_GPI_ACT_LOW 0x00
492#define DA9063_GPIO1_TYPE_GPO_VDD_IO1 0x00
493#define DA9063_GPIO1_TYPE_GPI_ACT_HIGH 0x04
494#define DA9063_GPIO1_TYPE_GPO_VDD_IO2 0x04
495#define DA9063_GPIO1_NO_WAKEUP 0x80
496
497/* DA9063_REG_GPIO_2_3 (addr=0x16) */
498#define DA9063_GPIO2_PIN_MASK 0x03
499#define DA9063_GPIO2_PIN_ADCIN3 0x00
500#define DA9063_GPIO2_PIN_GPI 0x01
501#define DA9063_GPIO2_PIN_GPO_PSS 0x02
502#define DA9063_GPIO2_PIN_GPO 0x03
503#define DA9063_GPIO2_TYPE 0x04
504#define DA9063_GPIO2_TYPE_GPI_ACT_LOW 0x00
505#define DA9063_GPIO2_TYPE_GPO_VDD_IO1 0x00
506#define DA9063_GPIO2_TYPE_GPI_ACT_HIGH 0x04
507#define DA9063_GPIO2_TYPE_GPO_VDD_IO2 0x04
508#define DA9063_GPIO2_NO_WAKEUP 0x08
509#define DA9063_GPIO3_PIN_MASK 0x30
510#define DA9063_GPIO3_PIN_CORE_SW_G 0x00
511#define DA9063_GPIO3_PIN_GPI 0x10
512#define DA9063_GPIO3_PIN_GPO_OD 0x20
513#define DA9063_GPIO3_PIN_GPO 0x30
514#define DA9063_GPIO3_TYPE 0x40
515#define DA9063_GPIO3_TYPE_GPI_ACT_LOW 0x00
516#define DA9063_GPIO3_TYPE_GPO_VDD_IO1 0x00
517#define DA9063_GPIO3_TYPE_GPI_ACT_HIGH 0x04
518#define DA9063_GPIO3_TYPE_GPO_VDD_IO2 0x04
519#define DA9063_GPIO3_NO_WAKEUP 0x80
520
521/* DA9063_REG_GPIO_4_5 (addr=0x17) */
522#define DA9063_GPIO4_PIN_MASK 0x03
523#define DA9063_GPIO4_PIN_CORE_SW_S 0x00
524#define DA9063_GPIO4_PIN_GPI 0x01
525#define DA9063_GPIO4_PIN_GPO_OD 0x02
526#define DA9063_GPIO4_PIN_GPO 0x03
527#define DA9063_GPIO4_TYPE 0x04
528#define DA9063_GPIO4_TYPE_GPI_ACT_LOW 0x00
529#define DA9063_GPIO4_TYPE_GPO_VDD_IO1 0x00
530#define DA9063_GPIO4_TYPE_GPI_ACT_HIGH 0x04
531#define DA9063_GPIO4_TYPE_GPO_VDD_IO2 0x04
532#define DA9063_GPIO4_NO_WAKEUP 0x08
533#define DA9063_GPIO5_PIN_MASK 0x30
534#define DA9063_GPIO5_PIN_PERI_SW_G 0x00
535#define DA9063_GPIO5_PIN_GPI 0x10
536#define DA9063_GPIO5_PIN_GPO_OD 0x20
537#define DA9063_GPIO5_PIN_GPO 0x30
538#define DA9063_GPIO5_TYPE 0x40
539#define DA9063_GPIO5_TYPE_GPI_ACT_LOW 0x00
540#define DA9063_GPIO5_TYPE_GPO_VDD_IO1 0x00
541#define DA9063_GPIO5_TYPE_GPI_ACT_HIGH 0x04
542#define DA9063_GPIO5_TYPE_GPO_VDD_IO2 0x04
543#define DA9063_GPIO5_NO_WAKEUP 0x80
544
545/* DA9063_REG_GPIO_6_7 (addr=0x18) */
546#define DA9063_GPIO6_PIN_MASK 0x03
547#define DA9063_GPIO6_PIN_PERI_SW_S 0x00
548#define DA9063_GPIO6_PIN_GPI 0x01
549#define DA9063_GPIO6_PIN_GPO_OD 0x02
550#define DA9063_GPIO6_PIN_GPO 0x03
551#define DA9063_GPIO6_TYPE 0x04
552#define DA9063_GPIO6_TYPE_GPI_ACT_LOW 0x00
553#define DA9063_GPIO6_TYPE_GPO_VDD_IO1 0x00
554#define DA9063_GPIO6_TYPE_GPI_ACT_HIGH 0x04
555#define DA9063_GPIO6_TYPE_GPO_VDD_IO2 0x04
556#define DA9063_GPIO6_NO_WAKEUP 0x08
557#define DA9063_GPIO7_PIN_MASK 0x30
558#define DA9063_GPIO7_PIN_GPI 0x10
559#define DA9063_GPIO7_PIN_GPO_PSS 0x20
560#define DA9063_GPIO7_PIN_GPO 0x30
561#define DA9063_GPIO7_TYPE 0x40
562#define DA9063_GPIO7_TYPE_GPI_ACT_LOW 0x00
563#define DA9063_GPIO7_TYPE_GPO_VDD_IO1 0x00
564#define DA9063_GPIO7_TYPE_GPI_ACT_HIGH 0x04
565#define DA9063_GPIO7_TYPE_GPO_VDD_IO2 0x04
566#define DA9063_GPIO7_NO_WAKEUP 0x80
567
568/* DA9063_REG_GPIO_8_9 (addr=0x19) */
569#define DA9063_GPIO8_PIN_MASK 0x03
570#define DA9063_GPIO8_PIN_GPI_SYS_EN 0x00
571#define DA9063_GPIO8_PIN_GPI 0x01
572#define DA9063_GPIO8_PIN_GPO_PSS 0x02
573#define DA9063_GPIO8_PIN_GPO 0x03
574#define DA9063_GPIO8_TYPE 0x04
575#define DA9063_GPIO8_TYPE_GPI_ACT_LOW 0x00
576#define DA9063_GPIO8_TYPE_GPO_VDD_IO1 0x00
577#define DA9063_GPIO8_TYPE_GPI_ACT_HIGH 0x04
578#define DA9063_GPIO8_TYPE_GPO_VDD_IO2 0x04
579#define DA9063_GPIO8_NO_WAKEUP 0x08
580#define DA9063_GPIO9_PIN_MASK 0x30
581#define DA9063_GPIO9_PIN_GPI_PWR_EN 0x00
582#define DA9063_GPIO9_PIN_GPI 0x10
583#define DA9063_GPIO9_PIN_GPO_PSS 0x20
584#define DA9063_GPIO9_PIN_GPO 0x30
585#define DA9063_GPIO9_TYPE 0x40
586#define DA9063_GPIO9_TYPE_GPI_ACT_LOW 0x00
587#define DA9063_GPIO9_TYPE_GPO_VDD_IO1 0x00
588#define DA9063_GPIO9_TYPE_GPI_ACT_HIGH 0x04
589#define DA9063_GPIO9_TYPE_GPO_VDD_IO2 0x04
590#define DA9063_GPIO9_NO_WAKEUP 0x80
591
592/* DA9063_REG_GPIO_10_11 (addr=0x1A) */
593#define DA9063_GPIO10_PIN_MASK 0x03
594#define DA9063_GPIO10_PIN_GPI_PWR1_EN 0x00
595#define DA9063_GPIO10_PIN_GPI 0x01
596#define DA9063_GPIO10_PIN_GPO_OD 0x02
597#define DA9063_GPIO10_PIN_GPO 0x03
598#define DA9063_GPIO10_TYPE 0x04
599#define DA9063_GPIO10_TYPE_GPI_ACT_LOW 0x00
600#define DA9063_GPIO10_TYPE_GPO_VDD_IO1 0x00
601#define DA9063_GPIO10_TYPE_GPI_ACT_HIGH 0x04
602#define DA9063_GPIO10_TYPE_GPO_VDD_IO2 0x04
603#define DA9063_GPIO10_NO_WAKEUP 0x08
604#define DA9063_GPIO11_PIN_MASK 0x30
605#define DA9063_GPIO11_PIN_GPO_OD 0x00
606#define DA9063_GPIO11_PIN_GPI 0x10
607#define DA9063_GPIO11_PIN_GPO_PSS 0x20
608#define DA9063_GPIO11_PIN_GPO 0x30
609#define DA9063_GPIO11_TYPE 0x40
610#define DA9063_GPIO11_TYPE_GPI_ACT_LOW 0x00
611#define DA9063_GPIO11_TYPE_GPO_VDD_IO1 0x00
612#define DA9063_GPIO11_TYPE_GPI_ACT_HIGH 0x04
613#define DA9063_GPIO11_TYPE_GPO_VDD_IO2 0x04
614#define DA9063_GPIO11_NO_WAKEUP 0x80
615
616/* DA9063_REG_GPIO_12_13 (addr=0x1B) */
617#define DA9063_GPIO12_PIN_MASK 0x03
618#define DA9063_GPIO12_PIN_NVDDFLT_OUT 0x00
619#define DA9063_GPIO12_PIN_GPI 0x01
620#define DA9063_GPIO12_PIN_VSYSMON_OUT 0x02
621#define DA9063_GPIO12_PIN_GPO 0x03
622#define DA9063_GPIO12_TYPE 0x04
623#define DA9063_GPIO12_TYPE_GPI_ACT_LOW 0x00
624#define DA9063_GPIO12_TYPE_GPO_VDD_IO1 0x00
625#define DA9063_GPIO12_TYPE_GPI_ACT_HIGH 0x04
626#define DA9063_GPIO12_TYPE_GPO_VDD_IO2 0x04
627#define DA9063_GPIO12_NO_WAKEUP 0x08
628#define DA9063_GPIO13_PIN_MASK 0x30
629#define DA9063_GPIO13_PIN_GPFB1_OUT 0x00
630#define DA9063_GPIO13_PIN_GPI 0x10
631#define DA9063_GPIO13_PIN_GPFB1_OUTOD 0x20
632#define DA9063_GPIO13_PIN_GPO 0x30
633#define DA9063_GPIO13_TYPE 0x40
634#define DA9063_GPIO13_TYPE_GPFB1_OUT 0x00
635#define DA9063_GPIO13_TYPE_GPI 0x00
636#define DA9063_GPIO13_TYPE_GPFB1_OUTOD 0x04
637#define DA9063_GPIO13_TYPE_GPO 0x04
638#define DA9063_GPIO13_NO_WAKEUP 0x80
639
640/* DA9063_REG_GPIO_14_15 (addr=0x1C) */
641#define DA9063_GPIO14_PIN_MASK 0x03
642#define DA9063_GPIO14_PIN_GPO_OD 0x00
643#define DA9063_GPIO14_PIN_GPI 0x01
644#define DA9063_GPIO14_PIN_HS2DATA 0x02
645#define DA9063_GPIO14_PIN_GPO 0x03
646#define DA9063_GPIO14_TYPE 0x04
647#define DA9063_GPIO14_TYPE_GPI_ACT_LOW 0x00
648#define DA9063_GPIO14_TYPE_GPO_VDD_IO1 0x00
649#define DA9063_GPIO14_TYPE_GPI_ACT_HIGH 0x04
650#define DA9063_GPIO14_TYPE_GPO_VDD_IO2 0x04
651#define DA9063_GPIO14_NO_WAKEUP 0x08
652#define DA9063_GPIO15_PIN_MASK 0x30
653#define DA9063_GPIO15_PIN_GPO_OD 0x00
654#define DA9063_GPIO15_PIN_GPI 0x10
655#define DA9063_GPIO15_PIN_GPO 0x30
656#define DA9063_GPIO15_TYPE 0x40
657#define DA9063_GPIO15_TYPE_GPFB1_OUT 0x00
658#define DA9063_GPIO15_TYPE_GPI 0x00
659#define DA9063_GPIO15_TYPE_GPFB1_OUTOD 0x04
660#define DA9063_GPIO15_TYPE_GPO 0x04
661#define DA9063_GPIO15_NO_WAKEUP 0x80
662
663/* DA9063_REG_GPIO_MODE_0_7 (addr=0x1D) */
664#define DA9063_GPIO0_MODE 0x01
665#define DA9063_GPIO1_MODE 0x02
666#define DA9063_GPIO2_MODE 0x04
667#define DA9063_GPIO3_MODE 0x08
668#define DA9063_GPIO4_MODE 0x10
669#define DA9063_GPIO5_MODE 0x20
670#define DA9063_GPIO6_MODE 0x40
671#define DA9063_GPIO7_MODE 0x80
672
673/* DA9063_REG_GPIO_MODE_8_15 (addr=0x1E) */
674#define DA9063_GPIO8_MODE 0x01
675#define DA9063_GPIO9_MODE 0x02
676#define DA9063_GPIO10_MODE 0x04
677#define DA9063_GPIO11_MODE 0x08
678#define DA9063_GPIO11_MODE_LED_ACT_HIGH 0x00
679#define DA9063_GPIO11_MODE_LED_ACT_LOW 0x08
680#define DA9063_GPIO12_MODE 0x10
681#define DA9063_GPIO13_MODE 0x20
682#define DA9063_GPIO14_MODE 0x40
683#define DA9063_GPIO14_MODE_LED_ACT_HIGH 0x00
684#define DA9063_GPIO14_MODE_LED_ACT_LOW 0x40
685#define DA9063_GPIO15_MODE 0x80
686#define DA9063_GPIO15_MODE_LED_ACT_HIGH 0x00
687#define DA9063_GPIO15_MODE_LED_ACT_LOW 0x80
688
689/* DA9063_REG_SWITCH_CONT (addr=0x1F) */
690#define DA9063_CORE_SW_GPI_MASK 0x03
691#define DA9063_CORE_SW_GPI_OFF 0x00
692#define DA9063_CORE_SW_GPI_GPIO1 0x01
693#define DA9063_CORE_SW_GPI_GPIO2 0x02
694#define DA9063_CORE_SW_GPI_GPIO13 0x03
695#define DA9063_PERI_SW_GPI_MASK 0x0C
696#define DA9063_PERI_SW_GPI_OFF 0x00
697#define DA9063_PERI_SW_GPI_GPIO1 0x04
698#define DA9063_PERI_SW_GPI_GPIO2 0x08
699#define DA9063_PERI_SW_GPI_GPIO13 0x0C
700#define DA9063_SWITCH_SR_MASK 0x30
701#define DA9063_SWITCH_SR_1MV 0x00
702#define DA9063_SWITCH_SR_5MV 0x10
703#define DA9063_SWITCH_SR_10MV 0x20
704#define DA9063_SWITCH_SR_50MV 0x30
705#define DA9063_SWITCH_SR_DIS 0x40
706#define DA9063_CP_EN_MODE 0x80
707
708/* DA9063_REGL_Bxxxx_CONT common bits (addr=0x20-0x25) */
709#define DA9063_BUCK_EN 0x01
710#define DA9063_BUCK_GPI_MASK 0x06
711#define DA9063_BUCK_GPI_OFF 0x00
712#define DA9063_BUCK_GPI_GPIO1 0x02
713#define DA9063_BUCK_GPI_GPIO2 0x04
714#define DA9063_BUCK_GPI_GPIO13 0x06
715#define DA9063_BUCK_CONF 0x08
716#define DA9063_VBUCK_GPI_MASK 0x60
717#define DA9063_VBUCK_GPI_OFF 0x00
718#define DA9063_VBUCK_GPI_GPIO1 0x20
719#define DA9063_VBUCK_GPI_GPIO2 0x40
720#define DA9063_VBUCK_GPI_GPIO13 0x60
721
722/* DA9063_REG_BCORE1_CONT specific bits (addr=0x21) */
723#define DA9063_CORE_SW_EN 0x10
724#define DA9063_CORE_SW_CONF 0x80
725
726/* DA9063_REG_BPERI_CONT specific bits (addr=0x25) */
727#define DA9063_PERI_SW_EN 0x10
728#define DA9063_PERI_SW_CONF 0x80
729
730/* DA9063_REG_LDOx_CONT common bits (addr=0x26-0x30) */
731#define DA9063_LDO_EN 0x01
732#define DA9063_LDO_GPI_MASK 0x06
733#define DA9063_LDO_GPI_OFF 0x00
734#define DA9063_LDO_GPI_GPIO1 0x02
735#define DA9063_LDO_GPI_GPIO2 0x04
736#define DA9063_LDO_GPI_GPIO13 0x06
737#define DA9063_LDO_PD_DIS 0x08
738#define DA9063_VLDO_GPI_MASK 0x60
739#define DA9063_VLDO_GPI_OFF 0x00
740#define DA9063_VLDO_GPI_GPIO1 0x20
741#define DA9063_VLDO_GPI_GPIO2 0x40
742#define DA9063_VLDO_GPI_GPIO13 0x60
743#define DA9063_LDO_CONF 0x80
744
745/* DA9063_REG_LDO5_CONT specific bits (addr=0x2A) */
746#define DA9063_VLDO5_SEL 0x10
747
748/* DA9063_REG_LDO6_CONT specific bits (addr=0x2B) */
749#define DA9063_VLDO6_SEL 0x10
750
751/* DA9063_REG_LDO7_CONT specific bits (addr=0x2C) */
752#define DA9063_VLDO7_SEL 0x10
753
754/* DA9063_REG_LDO8_CONT specific bits (addr=0x2D) */
755#define DA9063_VLDO8_SEL 0x10
756
757/* DA9063_REG_LDO9_CONT specific bits (addr=0x2E) */
758#define DA9063_VLDO9_SEL 0x10
759
760/* DA9063_REG_LDO10_CONT specific bits (addr=0x2F) */
761#define DA9063_VLDO10_SEL 0x10
762
763/* DA9063_REG_LDO11_CONT specific bits (addr=0x30) */
764#define DA9063_VLDO11_SEL 0x10
765
766/* DA9063_REG_VIB (addr=0x31) */
767#define DA9063_VIB_SET_MASK 0x3F
768#define DA9063_VIB_SET_OFF 0
769#define DA9063_VIB_SET_MAX 0x3F
770
771/* DA9063_REG_DVC_1 (addr=0x32) */
772#define DA9063_VBCORE1_SEL 0x01
773#define DA9063_VBCORE2_SEL 0x02
774#define DA9063_VBPRO_SEL 0x04
775#define DA9063_VBMEM_SEL 0x08
776#define DA9063_VBPERI_SEL 0x10
777#define DA9063_VLDO1_SEL 0x20
778#define DA9063_VLDO2_SEL 0x40
779#define DA9063_VLDO3_SEL 0x80
780
781/* DA9063_REG_DVC_2 (addr=0x33) */
782#define DA9063_VBIO_SEL 0x01
783#define DA9063_VLDO4_SEL 0x80
784
785/* DA9063_REG_ADC_MAN (addr=0x34) */
786#define DA9063_ADC_MUX_MASK 0x0F
787#define DA9063_ADC_MUX_VSYS 0x00
788#define DA9063_ADC_MUX_ADCIN1 0x01
789#define DA9063_ADC_MUX_ADCIN2 0x02
790#define DA9063_ADC_MUX_ADCIN3 0x03
791#define DA9063_ADC_MUX_T_SENSE 0x04
792#define DA9063_ADC_MUX_VBBAT 0x05
793#define DA9063_ADC_MUX_LDO_G1 0x08
794#define DA9063_ADC_MUX_LDO_G2 0x09
795#define DA9063_ADC_MUX_LDO_G3 0x0A
796#define DA9063_ADC_MAN 0x10
797#define DA9063_ADC_MODE 0x20
798
799/* DA9063_REG_ADC_CONT (addr=0x35) */
800#define DA9063_ADC_AUTO_VSYS_EN 0x01
801#define DA9063_ADC_AUTO_AD1_EN 0x02
802#define DA9063_ADC_AUTO_AD2_EN 0x04
803#define DA9063_ADC_AUTO_AD3_EN 0x08
804#define DA9063_ADC_AD1_ISRC_EN 0x10
805#define DA9063_ADC_AD2_ISRC_EN 0x20
806#define DA9063_ADC_AD3_ISRC_EN 0x40
807#define DA9063_COMP1V2_EN 0x80
808
809/* DA9063_REG_VSYS_MON (addr=0x36) */
810#define DA9063_VSYS_VAL_MASK 0xFF
811#define DA9063_VSYS_VAL_BASE 0x00
812
813/* DA9063_REG_ADC_RES_L (addr=0x37) */
814#define DA9063_ADC_RES_L_BITS 2
815#define DA9063_ADC_RES_L_MASK 0xC0
816
817/* DA9063_REG_ADC_RES_H (addr=0x38) */
818#define DA9063_ADC_RES_M_BITS 8
819#define DA9063_ADC_RES_M_MASK 0xFF
820
821/* DA9063_REG_(xxx_RES/ADC_RES_H) (addr=0x39-0x3F) */
822#define DA9063_ADC_VAL_MASK 0xFF
823
824/* DA9063_REG_COUNT_S (addr=0x40) */
825#define DA9063_RTC_READ 0x80
826#define DA9063_COUNT_SEC_MASK 0x3F
827
828/* DA9063_REG_COUNT_MI (addr=0x41) */
829#define DA9063_COUNT_MIN_MASK 0x3F
830
831/* DA9063_REG_COUNT_H (addr=0x42) */
832#define DA9063_COUNT_HOUR_MASK 0x1F
833
834/* DA9063_REG_COUNT_D (addr=0x43) */
835#define DA9063_COUNT_DAY_MASK 0x1F
836
837/* DA9063_REG_COUNT_MO (addr=0x44) */
838#define DA9063_COUNT_MONTH_MASK 0x0F
839
840/* DA9063_REG_COUNT_Y (addr=0x45) */
841#define DA9063_COUNT_YEAR_MASK 0x3F
842#define DA9063_MONITOR 0x40
843
844/* DA9063_REG_ALARM_MI (addr=0x46) */
845#define DA9063_ALARM_STATUS_ALARM 0x80
846#define DA9063_ALARM_STATUS_TICK 0x40
847#define DA9063_ALARM_MIN_MASK 0x3F
848
849/* DA9063_REG_ALARM_H (addr=0x47) */
850#define DA9063_ALARM_HOUR_MASK 0x1F
851
852/* DA9063_REG_ALARM_D (addr=0x48) */
853#define DA9063_ALARM_DAY_MASK 0x1F
854
855/* DA9063_REG_ALARM_MO (addr=0x49) */
856#define DA9063_TICK_WAKE 0x20
857#define DA9063_TICK_TYPE 0x10
858#define DA9063_TICK_TYPE_SEC 0x00
859#define DA9063_TICK_TYPE_MIN 0x10
860#define DA9063_ALARM_MONTH_MASK 0x0F
861
862/* DA9063_REG_ALARM_Y (addr=0x4A) */
863#define DA9063_TICK_ON 0x80
864#define DA9063_ALARM_ON 0x40
865#define DA9063_ALARM_YEAR_MASK 0x3F
866
867/* DA9063_REG_WAIT (addr=0x97)*/
868#define DA9063_REG_WAIT_TIME_MASK 0xF
869#define DA9063_WAIT_TIME_0_US 0x0
870#define DA9063_WAIT_TIME_512_US 0x1
871#define DA9063_WAIT_TIME_1_MS 0x2
872#define DA9063_WAIT_TIME_2_MS 0x3
873#define DA9063_WAIT_TIME_4_1_MS 0x4
874#define DA9063_WAIT_TIME_8_2_MS 0x5
875#define DA9063_WAIT_TIME_16_4_MS 0x6
876#define DA9063_WAIT_TIME_32_8_MS 0x7
877#define DA9063_WAIT_TIME_65_5_MS 0x8
878#define DA9063_WAIT_TIME_128_MS 0x9
879#define DA9063_WAIT_TIME_256_MS 0xA
880#define DA9063_WAIT_TIME_512_MS 0xB
881#define DA9063_WAIT_TIME_1_S 0xC
882#define DA9063_WAIT_TIME_2_1_S 0xD
883
884/* DA9063_REG_EN_32K (addr=0x98)*/
885#define DA9063_STABILIZ_TIME_MASK 0x7
886#define DA9063_CRYSTAL 0x08
887#define DA9063_DELAY_MODE 0x10
888#define DA9063_OUT_CLOCK 0x20
889#define DA9063_RTC_CLOCK 0x40
890#define DA9063_OUT_32K_EN 0x80
891
892/* DA9063_REG_CHIP_VARIANT */
893#define DA9063_CHIP_VARIANT_SHIFT 4
894
895/* DA9063_REG_BUCK_ILIM_A (addr=0x9A) */
896#define DA9063_BIO_ILIM_MASK 0x0F
897#define DA9063_BMEM_ILIM_MASK 0xF0
898
899/* DA9063_REG_BUCK_ILIM_B (addr=0x9B) */
900#define DA9063_BPRO_ILIM_MASK 0x0F
901#define DA9063_BPERI_ILIM_MASK 0xF0
902
903/* DA9063_REG_BUCK_ILIM_C (addr=0x9C) */
904#define DA9063_BCORE1_ILIM_MASK 0x0F
905#define DA9063_BCORE2_ILIM_MASK 0xF0
906
907/* DA9063_REG_Bxxxx_CFG common bits (addr=0x9D-0xA2) */
908#define DA9063_BUCK_FB_MASK 0x07
909#define DA9063_BUCK_PD_DIS_SHIFT 5
910#define DA9063_BUCK_MODE_MASK 0xC0
911#define DA9063_BUCK_MODE_MANUAL 0x00
912#define DA9063_BUCK_MODE_SLEEP 0x40
913#define DA9063_BUCK_MODE_SYNC 0x80
914#define DA9063_BUCK_MODE_AUTO 0xC0
915
916/* DA9063_REG_BPRO_CFG (addr=0x9F) */
917#define DA9063_BPRO_VTTR_EN 0x08
918#define DA9063_BPRO_VTT_EN 0x10
919
920/* DA9063_REG_VBxxxx_A/B (addr=0xA3-0xA8, 0xB4-0xB9) */
921#define DA9063_VBUCK_MASK 0x7F
922#define DA9063_VBUCK_BIAS 0
923#define DA9063_BUCK_SL 0x80
924
925/* DA9063_REG_VLDOx_A/B (addr=0xA9-0x3, 0xBA-0xC4) */
926#define DA9063_LDO_SL 0x80
927
928/* DA9063_REG_VLDO1_A/B (addr=0xA9, 0xBA) */
929#define DA9063_VLDO1_MASK 0x3F
930#define DA9063_VLDO1_BIAS 0
931
932/* DA9063_REG_VLDO2_A/B (addr=0xAA, 0xBB) */
933#define DA9063_VLDO2_MASK 0x3F
934#define DA9063_VLDO2_BIAS 0
935
936/* DA9063_REG_VLDO3_A/B (addr=0xAB, 0xBC) */
937#define DA9063_VLDO3_MASK 0x7F
938#define DA9063_VLDO3_BIAS 0
939
940/* DA9063_REG_VLDO4_A/B (addr=0xAC, 0xBD) */
941#define DA9063_VLDO4_MASK 0x7F
942#define DA9063_VLDO4_BIAS 0
943
944/* DA9063_REG_VLDO5_A/B (addr=0xAD, 0xBE) */
945#define DA9063_VLDO5_MASK 0x3F
946#define DA9063_VLDO5_BIAS 2
947
948/* DA9063_REG_VLDO6_A/B (addr=0xAE, 0xBF) */
949#define DA9063_VLDO6_MASK 0x3F
950#define DA9063_VLDO6_BIAS 2
951
952/* DA9063_REG_VLDO7_A/B (addr=0xAF, 0xC0) */
953#define DA9063_VLDO7_MASK 0x3F
954#define DA9063_VLDO7_BIAS 2
955
956/* DA9063_REG_VLDO8_A/B (addr=0xB0, 0xC1) */
957#define DA9063_VLDO8_MASK 0x3F
958#define DA9063_VLDO8_BIAS 2
959
960/* DA9063_REG_VLDO9_A/B (addr=0xB1, 0xC2) */
961#define DA9063_VLDO9_MASK 0x3F
962#define DA9063_VLDO9_BIAS 3
963
964/* DA9063_REG_VLDO10_A/B (addr=0xB2, 0xC3) */
965#define DA9063_VLDO10_MASK 0x3F
966#define DA9063_VLDO10_BIAS 2
967
968/* DA9063_REG_VLDO11_A/B (addr=0xB3, 0xC4) */
969#define DA9063_VLDO11_MASK 0x3F
970#define DA9063_VLDO11_BIAS 2
971
972/* DA9063_REG_GPO11_LED (addr=0xC6) */
973/* DA9063_REG_GPO14_LED (addr=0xC7) */
974/* DA9063_REG_GPO15_LED (addr=0xC8) */
975#define DA9063_GPIO_DIM 0x80
976#define DA9063_GPIO_PWM_MASK 0x7F
977
978/* DA9063_REG_CONFIG_H (addr=0x10D) */
979#define DA9063_PWM_CLK_MASK 0x01
980#define DA9063_PWM_CLK_PWM2MHZ 0x00
981#define DA9063_PWM_CLK_PWM1MHZ 0x01
982#define DA9063_LDO8_MODE_MASK 0x02
983#define DA9063_LDO8_MODE_LDO 0
984#define DA9063_LDO8_MODE_VIBR 0x02
985#define DA9063_MERGE_SENSE_MASK 0x04
986#define DA9063_MERGE_SENSE_GP_FB2 0x00
987#define DA9063_MERGE_SENSE_GPIO4 0x04
988#define DA9063_BCORE_MERGE 0x08
989#define DA9063_BPRO_OD 0x10
990#define DA9063_BCORE2_OD 0x20
991#define DA9063_BCORE1_OD 0x40
992#define DA9063_BUCK_MERGE 0x80
993
994/* DA9063_REG_CONFIG_I (addr=0x10E) */
995#define DA9063_NONKEY_PIN_MASK 0x03
996#define DA9063_NONKEY_PIN_PORT 0x00
997#define DA9063_NONKEY_PIN_SWDOWN 0x01
998#define DA9063_NONKEY_PIN_AUTODOWN 0x02
999#define DA9063_NONKEY_PIN_AUTOFLPRT 0x03
1000
1001/* DA9063_REG_MON_REG_5 (addr=0x116) */
1002#define DA9063_MON_A8_IDX_MASK 0x07
1003#define DA9063_MON_A8_IDX_NONE 0x00
1004#define DA9063_MON_A8_IDX_BCORE1 0x01
1005#define DA9063_MON_A8_IDX_BCORE2 0x02
1006#define DA9063_MON_A8_IDX_BPRO 0x03
1007#define DA9063_MON_A8_IDX_LDO3 0x04
1008#define DA9063_MON_A8_IDX_LDO4 0x05
1009#define DA9063_MON_A8_IDX_LDO11 0x06
1010#define DA9063_MON_A9_IDX_MASK 0x70
1011#define DA9063_MON_A9_IDX_NONE 0x00
1012#define DA9063_MON_A9_IDX_BIO 0x01
1013#define DA9063_MON_A9_IDX_BMEM 0x02
1014#define DA9063_MON_A9_IDX_BPERI 0x03
1015#define DA9063_MON_A9_IDX_LDO1 0x04
1016#define DA9063_MON_A9_IDX_LDO2 0x05
1017#define DA9063_MON_A9_IDX_LDO5 0x06
1018
1019/* DA9063_REG_MON_REG_6 (addr=0x117) */
1020#define DA9063_MON_A10_IDX_MASK 0x07
1021#define DA9063_MON_A10_IDX_NONE 0x00
1022#define DA9063_MON_A10_IDX_LDO6 0x01
1023#define DA9063_MON_A10_IDX_LDO7 0x02
1024#define DA9063_MON_A10_IDX_LDO8 0x03
1025#define DA9063_MON_A10_IDX_LDO9 0x04
1026#define DA9063_MON_A10_IDX_LDO10 0x05
1027
1028#endif /* _DA9063_REG_H */
diff --git a/include/linux/mfd/davinci_voicecodec.h b/include/linux/mfd/davinci_voicecodec.h
index 13a1ee95a233..5166935ce66d 100644
--- a/include/linux/mfd/davinci_voicecodec.h
+++ b/include/linux/mfd/davinci_voicecodec.h
@@ -30,6 +30,8 @@
30 30
31#include <mach/hardware.h> 31#include <mach/hardware.h>
32 32
33struct regmap;
34
33/* 35/*
34 * Register values. 36 * Register values.
35 */ 37 */
@@ -113,6 +115,7 @@ struct davinci_vc {
113 115
114 /* Memory resources */ 116 /* Memory resources */
115 void __iomem *base; 117 void __iomem *base;
118 struct regmap *regmap;
116 119
117 /* MFD cells */ 120 /* MFD cells */
118 struct mfd_cell cells[DAVINCI_VC_CELLS]; 121 struct mfd_cell cells[DAVINCI_VC_CELLS];
diff --git a/include/linux/mfd/mcp.h b/include/linux/mfd/mcp.h
index a9e8bd157673..f682953043ba 100644
--- a/include/linux/mfd/mcp.h
+++ b/include/linux/mfd/mcp.h
@@ -10,6 +10,8 @@
10#ifndef MCP_H 10#ifndef MCP_H
11#define MCP_H 11#define MCP_H
12 12
13#include <linux/device.h>
14
13struct mcp_ops; 15struct mcp_ops;
14 16
15struct mcp { 17struct mcp {
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 37e48c957791..9974e387e483 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -184,6 +184,50 @@ enum palmas_regulators {
184 PALMAS_NUM_REGS, 184 PALMAS_NUM_REGS,
185}; 185};
186 186
187/* External controll signal name */
188enum {
189 PALMAS_EXT_CONTROL_ENABLE1 = 0x1,
190 PALMAS_EXT_CONTROL_ENABLE2 = 0x2,
191 PALMAS_EXT_CONTROL_NSLEEP = 0x4,
192};
193
194/*
195 * Palmas device resources can be controlled externally for
196 * enabling/disabling it rather than register write through i2c.
197 * Add the external controlled requestor ID for different resources.
198 */
199enum palmas_external_requestor_id {
200 PALMAS_EXTERNAL_REQSTR_ID_REGEN1,
201 PALMAS_EXTERNAL_REQSTR_ID_REGEN2,
202 PALMAS_EXTERNAL_REQSTR_ID_SYSEN1,
203 PALMAS_EXTERNAL_REQSTR_ID_SYSEN2,
204 PALMAS_EXTERNAL_REQSTR_ID_CLK32KG,
205 PALMAS_EXTERNAL_REQSTR_ID_CLK32KGAUDIO,
206 PALMAS_EXTERNAL_REQSTR_ID_REGEN3,
207 PALMAS_EXTERNAL_REQSTR_ID_SMPS12,
208 PALMAS_EXTERNAL_REQSTR_ID_SMPS3,
209 PALMAS_EXTERNAL_REQSTR_ID_SMPS45,
210 PALMAS_EXTERNAL_REQSTR_ID_SMPS6,
211 PALMAS_EXTERNAL_REQSTR_ID_SMPS7,
212 PALMAS_EXTERNAL_REQSTR_ID_SMPS8,
213 PALMAS_EXTERNAL_REQSTR_ID_SMPS9,
214 PALMAS_EXTERNAL_REQSTR_ID_SMPS10,
215 PALMAS_EXTERNAL_REQSTR_ID_LDO1,
216 PALMAS_EXTERNAL_REQSTR_ID_LDO2,
217 PALMAS_EXTERNAL_REQSTR_ID_LDO3,
218 PALMAS_EXTERNAL_REQSTR_ID_LDO4,
219 PALMAS_EXTERNAL_REQSTR_ID_LDO5,
220 PALMAS_EXTERNAL_REQSTR_ID_LDO6,
221 PALMAS_EXTERNAL_REQSTR_ID_LDO7,
222 PALMAS_EXTERNAL_REQSTR_ID_LDO8,
223 PALMAS_EXTERNAL_REQSTR_ID_LDO9,
224 PALMAS_EXTERNAL_REQSTR_ID_LDOLN,
225 PALMAS_EXTERNAL_REQSTR_ID_LDOUSB,
226
227 /* Last entry */
228 PALMAS_EXTERNAL_REQSTR_ID_MAX,
229};
230
187struct palmas_pmic_platform_data { 231struct palmas_pmic_platform_data {
188 /* An array of pointers to regulator init data indexed by regulator 232 /* An array of pointers to regulator init data indexed by regulator
189 * ID 233 * ID
@@ -259,6 +303,7 @@ struct palmas_platform_data {
259 */ 303 */
260 int mux_from_pdata; 304 int mux_from_pdata;
261 u8 pad1, pad2; 305 u8 pad1, pad2;
306 bool pm_off;
262 307
263 struct palmas_pmic_platform_data *pmic_pdata; 308 struct palmas_pmic_platform_data *pmic_pdata;
264 struct palmas_gpadc_platform_data *gpadc_pdata; 309 struct palmas_gpadc_platform_data *gpadc_pdata;
@@ -2878,4 +2923,9 @@ static inline int palmas_irq_get_virq(struct palmas *palmas, int irq)
2878 return regmap_irq_get_virq(palmas->irq_data, irq); 2923 return regmap_irq_get_virq(palmas->irq_data, irq);
2879} 2924}
2880 2925
2926
2927int palmas_ext_control_req_config(struct palmas *palmas,
2928 enum palmas_external_requestor_id ext_control_req_id,
2929 int ext_ctrl, bool enable);
2930
2881#endif /* __LINUX_MFD_PALMAS_H */ 2931#endif /* __LINUX_MFD_PALMAS_H */
diff --git a/include/linux/mfd/rtsx_common.h b/include/linux/mfd/rtsx_common.h
index 2b13970596f5..443176ee1ab0 100644
--- a/include/linux/mfd/rtsx_common.h
+++ b/include/linux/mfd/rtsx_common.h
@@ -1,6 +1,6 @@
1/* Driver for Realtek driver-based card reader 1/* Driver for Realtek driver-based card reader
2 * 2 *
3 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. 3 * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License as published by the
@@ -17,7 +17,6 @@
17 * 17 *
18 * Author: 18 * Author:
19 * Wei WANG <wei_wang@realsil.com.cn> 19 * Wei WANG <wei_wang@realsil.com.cn>
20 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
21 */ 20 */
22 21
23#ifndef __RTSX_COMMON_H 22#ifndef __RTSX_COMMON_H
diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
index 7a9f7089435d..d1382dfbeff0 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -1,6 +1,6 @@
1/* Driver for Realtek PCI-Express card reader 1/* Driver for Realtek PCI-Express card reader
2 * 2 *
3 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. 3 * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License as published by the
@@ -17,7 +17,6 @@
17 * 17 *
18 * Author: 18 * Author:
19 * Wei WANG <wei_wang@realsil.com.cn> 19 * Wei WANG <wei_wang@realsil.com.cn>
20 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
21 */ 20 */
22 21
23#ifndef __RTSX_PCI_H 22#ifndef __RTSX_PCI_H
@@ -25,8 +24,7 @@
25 24
26#include <linux/sched.h> 25#include <linux/sched.h>
27#include <linux/pci.h> 26#include <linux/pci.h>
28 27#include <linux/mfd/rtsx_common.h>
29#include "rtsx_common.h"
30 28
31#define MAX_RW_REG_CNT 1024 29#define MAX_RW_REG_CNT 1024
32 30
@@ -184,11 +182,26 @@
184#define CARD_SHARE_BAROSSA_SD 0x01 182#define CARD_SHARE_BAROSSA_SD 0x01
185#define CARD_SHARE_BAROSSA_MS 0x02 183#define CARD_SHARE_BAROSSA_MS 0x02
186 184
185/* CARD_DRIVE_SEL */
186#define MS_DRIVE_8mA (0x01 << 6)
187#define MMC_DRIVE_8mA (0x01 << 4)
188#define XD_DRIVE_8mA (0x01 << 2)
189#define GPIO_DRIVE_8mA 0x01
190#define RTS5209_CARD_DRIVE_DEFAULT (MS_DRIVE_8mA | MMC_DRIVE_8mA |\
191 XD_DRIVE_8mA | GPIO_DRIVE_8mA)
192#define RTL8411_CARD_DRIVE_DEFAULT (MS_DRIVE_8mA | MMC_DRIVE_8mA |\
193 XD_DRIVE_8mA)
194#define RTSX_CARD_DRIVE_DEFAULT (MS_DRIVE_8mA | GPIO_DRIVE_8mA)
195
187/* SD30_DRIVE_SEL */ 196/* SD30_DRIVE_SEL */
188#define DRIVER_TYPE_A 0x05 197#define DRIVER_TYPE_A 0x05
189#define DRIVER_TYPE_B 0x03 198#define DRIVER_TYPE_B 0x03
190#define DRIVER_TYPE_C 0x02 199#define DRIVER_TYPE_C 0x02
191#define DRIVER_TYPE_D 0x01 200#define DRIVER_TYPE_D 0x01
201#define CFG_DRIVER_TYPE_A 0x02
202#define CFG_DRIVER_TYPE_B 0x03
203#define CFG_DRIVER_TYPE_C 0x01
204#define CFG_DRIVER_TYPE_D 0x00
192 205
193/* FPDCTL */ 206/* FPDCTL */
194#define SSC_POWER_DOWN 0x01 207#define SSC_POWER_DOWN 0x01
@@ -521,6 +534,10 @@
521#define SAMPLE_VAR_CLK0 (0x01 << 4) 534#define SAMPLE_VAR_CLK0 (0x01 << 4)
522#define SAMPLE_VAR_CLK1 (0x02 << 4) 535#define SAMPLE_VAR_CLK1 (0x02 << 4)
523 536
537/* HOST_SLEEP_STATE */
538#define HOST_ENTER_S1 1
539#define HOST_ENTER_S3 2
540
524#define MS_CFG 0xFD40 541#define MS_CFG 0xFD40
525#define MS_TPC 0xFD41 542#define MS_TPC 0xFD41
526#define MS_TRANS_CFG 0xFD42 543#define MS_TRANS_CFG 0xFD42
@@ -669,6 +686,7 @@
669#define PME_FORCE_CTL 0xFE56 686#define PME_FORCE_CTL 0xFE56
670#define ASPM_FORCE_CTL 0xFE57 687#define ASPM_FORCE_CTL 0xFE57
671#define PM_CLK_FORCE_CTL 0xFE58 688#define PM_CLK_FORCE_CTL 0xFE58
689#define FUNC_FORCE_CTL 0xFE59
672#define PERST_GLITCH_WIDTH 0xFE5C 690#define PERST_GLITCH_WIDTH 0xFE5C
673#define CHANGE_LINK_STATE 0xFE5B 691#define CHANGE_LINK_STATE 0xFE5B
674#define RESET_LOAD_REG 0xFE5E 692#define RESET_LOAD_REG 0xFE5E
@@ -684,6 +702,13 @@
684 702
685#define DUMMY_REG_RESET_0 0xFE90 703#define DUMMY_REG_RESET_0 0xFE90
686 704
705#define AUTOLOAD_CFG_BASE 0xFF00
706
707#define PM_CTRL1 0xFF44
708#define PM_CTRL2 0xFF45
709#define PM_CTRL3 0xFF46
710#define PM_CTRL4 0xFF47
711
687/* Memory mapping */ 712/* Memory mapping */
688#define SRAM_BASE 0xE600 713#define SRAM_BASE 0xE600
689#define RBUF_BASE 0xF400 714#define RBUF_BASE 0xF400
@@ -726,6 +751,11 @@
726#define PHY_FLD4 0x1E 751#define PHY_FLD4 0x1E
727#define PHY_DUM_REG 0x1F 752#define PHY_DUM_REG 0x1F
728 753
754#define LCTLR 0x80
755#define PCR_SETTING_REG1 0x724
756#define PCR_SETTING_REG2 0x814
757#define PCR_SETTING_REG3 0x747
758
729#define rtsx_pci_init_cmd(pcr) ((pcr)->ci = 0) 759#define rtsx_pci_init_cmd(pcr) ((pcr)->ci = 0)
730 760
731struct rtsx_pcr; 761struct rtsx_pcr;
@@ -747,6 +777,8 @@ struct pcr_ops {
747 u8 voltage); 777 u8 voltage);
748 unsigned int (*cd_deglitch)(struct rtsx_pcr *pcr); 778 unsigned int (*cd_deglitch)(struct rtsx_pcr *pcr);
749 int (*conv_clk_and_div_n)(int clk, int dir); 779 int (*conv_clk_and_div_n)(int clk, int dir);
780 void (*fetch_vendor_settings)(struct rtsx_pcr *pcr);
781 void (*force_power_down)(struct rtsx_pcr *pcr, u8 pm_state);
750}; 782};
751 783
752enum PDEV_STAT {PDEV_STAT_IDLE, PDEV_STAT_RUN}; 784enum PDEV_STAT {PDEV_STAT_IDLE, PDEV_STAT_RUN};
@@ -788,7 +820,6 @@ struct rtsx_pcr {
788 struct completion *finish_me; 820 struct completion *finish_me;
789 821
790 unsigned int cur_clock; 822 unsigned int cur_clock;
791 bool ms_pmos;
792 bool remove_pci; 823 bool remove_pci;
793 bool msi_en; 824 bool msi_en;
794 825
@@ -806,6 +837,19 @@ struct rtsx_pcr {
806#define IC_VER_D 3 837#define IC_VER_D 3
807 u8 ic_version; 838 u8 ic_version;
808 839
840 u8 sd30_drive_sel_1v8;
841 u8 sd30_drive_sel_3v3;
842 u8 card_drive_sel;
843#define ASPM_L1_EN 0x02
844 u8 aspm_en;
845
846#define PCR_MS_PMOS (1 << 0)
847#define PCR_REVERSE_SOCKET (1 << 1)
848 u32 flags;
849
850 u32 tx_initial_phase;
851 u32 rx_initial_phase;
852
809 const u32 *sd_pull_ctl_enable_tbl; 853 const u32 *sd_pull_ctl_enable_tbl;
810 const u32 *sd_pull_ctl_disable_tbl; 854 const u32 *sd_pull_ctl_disable_tbl;
811 const u32 *ms_pull_ctl_enable_tbl; 855 const u32 *ms_pull_ctl_enable_tbl;
@@ -822,6 +866,18 @@ struct rtsx_pcr {
822#define PCI_VID(pcr) ((pcr)->pci->vendor) 866#define PCI_VID(pcr) ((pcr)->pci->vendor)
823#define PCI_PID(pcr) ((pcr)->pci->device) 867#define PCI_PID(pcr) ((pcr)->pci->device)
824 868
869#define SDR104_PHASE(val) ((val) & 0xFF)
870#define SDR50_PHASE(val) (((val) >> 8) & 0xFF)
871#define DDR50_PHASE(val) (((val) >> 16) & 0xFF)
872#define SDR104_TX_PHASE(pcr) SDR104_PHASE((pcr)->tx_initial_phase)
873#define SDR50_TX_PHASE(pcr) SDR50_PHASE((pcr)->tx_initial_phase)
874#define DDR50_TX_PHASE(pcr) DDR50_PHASE((pcr)->tx_initial_phase)
875#define SDR104_RX_PHASE(pcr) SDR104_PHASE((pcr)->rx_initial_phase)
876#define SDR50_RX_PHASE(pcr) SDR50_PHASE((pcr)->rx_initial_phase)
877#define DDR50_RX_PHASE(pcr) DDR50_PHASE((pcr)->rx_initial_phase)
878#define SET_CLOCK_PHASE(sdr104, sdr50, ddr50) \
879 (((ddr50) << 16) | ((sdr50) << 8) | (sdr104))
880
825void rtsx_pci_start_run(struct rtsx_pcr *pcr); 881void rtsx_pci_start_run(struct rtsx_pcr *pcr);
826int rtsx_pci_write_register(struct rtsx_pcr *pcr, u16 addr, u8 mask, u8 data); 882int rtsx_pci_write_register(struct rtsx_pcr *pcr, u16 addr, u8 mask, u8 data);
827int rtsx_pci_read_register(struct rtsx_pcr *pcr, u16 addr, u8 *data); 883int rtsx_pci_read_register(struct rtsx_pcr *pcr, u16 addr, u8 *data);
diff --git a/include/linux/mfd/samsung/s2mps11.h b/include/linux/mfd/samsung/s2mps11.h
index d0d52ea60074..b3ddf98dec37 100644
--- a/include/linux/mfd/samsung/s2mps11.h
+++ b/include/linux/mfd/samsung/s2mps11.h
@@ -167,11 +167,8 @@ enum s2mps11_regulators {
167 S2MPS11_BUCK8, 167 S2MPS11_BUCK8,
168 S2MPS11_BUCK9, 168 S2MPS11_BUCK9,
169 S2MPS11_BUCK10, 169 S2MPS11_BUCK10,
170 S2MPS11_AP_EN32KHZ,
171 S2MPS11_CP_EN32KHZ,
172 S2MPS11_BT_EN32KHZ,
173 170
174 S2MPS11_REG_MAX, 171 S2MPS11_REGULATOR_MAX,
175}; 172};
176 173
177#define S2MPS11_BUCK_MIN1 600000 174#define S2MPS11_BUCK_MIN1 600000
@@ -203,6 +200,5 @@ enum s2mps11_regulators {
203#define S2MPS11_BUCK4_RAMP_EN_SHIFT 1 200#define S2MPS11_BUCK4_RAMP_EN_SHIFT 1
204#define S2MPS11_BUCK6_RAMP_EN_SHIFT 0 201#define S2MPS11_BUCK6_RAMP_EN_SHIFT 0
205#define S2MPS11_PMIC_EN_SHIFT 6 202#define S2MPS11_PMIC_EN_SHIFT 6
206#define S2MPS11_REGULATOR_MAX (S2MPS11_REG_MAX - 3)
207 203
208#endif /* __LINUX_MFD_S2MPS11_H */ 204#endif /* __LINUX_MFD_S2MPS11_H */
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
index db1791bb997a..25f2c611ab01 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -121,7 +121,6 @@
121#define SEQ_STATUS BIT(5) 121#define SEQ_STATUS BIT(5)
122 122
123#define ADC_CLK 3000000 123#define ADC_CLK 3000000
124#define MAX_CLK_DIV 7
125#define TOTAL_STEPS 16 124#define TOTAL_STEPS 16
126#define TOTAL_CHANNELS 8 125#define TOTAL_CHANNELS 8
127 126
diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h
index 7e7fbce7a308..81f639bc1ae6 100644
--- a/include/linux/mfd/twl6040.h
+++ b/include/linux/mfd/twl6040.h
@@ -185,6 +185,7 @@
185 185
186#define TWL6040_GPO_MAX 3 186#define TWL6040_GPO_MAX 3
187 187
188/* TODO: All platform data struct can be removed */
188struct twl6040_codec_data { 189struct twl6040_codec_data {
189 u16 hs_left_step; 190 u16 hs_left_step;
190 u16 hs_right_step; 191 u16 hs_right_step;
@@ -229,7 +230,6 @@ struct twl6040 {
229 int audpwron; 230 int audpwron;
230 int power_count; 231 int power_count;
231 int rev; 232 int rev;
232 u8 vibra_ctrl_cache[2];
233 233
234 /* PLL configuration */ 234 /* PLL configuration */
235 int pll; 235 int pll;
diff --git a/include/linux/mfd/ucb1x00.h b/include/linux/mfd/ucb1x00.h
index 28af41756360..88f90cbf8e6a 100644
--- a/include/linux/mfd/ucb1x00.h
+++ b/include/linux/mfd/ucb1x00.h
@@ -10,6 +10,7 @@
10#ifndef UCB1200_H 10#ifndef UCB1200_H
11#define UCB1200_H 11#define UCB1200_H
12 12
13#include <linux/device.h>
13#include <linux/mfd/mcp.h> 14#include <linux/mfd/mcp.h>
14#include <linux/gpio.h> 15#include <linux/gpio.h>
15#include <linux/mutex.h> 16#include <linux/mutex.h>