diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-11 10:20:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-11 10:20:17 -0400 |
commit | 883cad5ba8cc2d9b740b4ad0a8a91063c99c75a3 (patch) | |
tree | f91886f6747bbcf239c42cd1c8d55f86f546e8e7 | |
parent | 8d08c0554244f95076cfe2a722e5207d974cd92d (diff) | |
parent | 556c242045f0c1613aac2e64dc5b2ff0e4bc89e1 (diff) |
Merge tag 'mfd-next-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd
Pull MFD updates from Lee Jones:
"New Device Support:
- Add support for AXP813 ADC to AXP20x
- Add support for PM8005, PM8998 and PMI8998
New Functionality:
- Add support for Battery Power Supply to AXP813
- Add support for SYSCON to SPARD SC27XX SPI
- Add support for RTC to ChromeOS Embedded-Controller
Fix-ups:
- Remove unused code; exynos{4,5}-pmu, cros_ec, cros_ec_acpi_gpe
- Remove duplicate error messages (-ENOMEM, etc); htc-i2cpld,
janz-cmodio, max8997, rc5t583, sm501, smsc-ece1099, abx500-core,
si476x-i2c, ti_am335x_tscadc, tps65090, tps6586x, tps65910,
tps80031, twl6030-irq, viperboard
- Succinctly use ptr to struct in sizeof(); rc5t583, abx500-core,
sm501, smsc-ece1099
- Simplify syntax for NULL ptr checking; abx500-core, sm501
- No not unnecessarily initialise variables; tps65910, tps65910
- Reorganise and simplify driver data; omap-usb-tll
- Move to SPDX license statement; tps68470
- Probe ADCs via DT; axp20x
- Use new GPIOD API; arizona-core
- Constify things; axp20x
- Reduce code-size (use MACROS, etc); axp20x, omap-usb-host
- Add DT support/docs; motorola-cpcap
- Remove VLAs; rave-sp
- Use devm_* managed resources; cros_ec
- Interrogate HW for firmware version; rave-sp
- Provide ACPI support for ChromeOS Embedded-Controller
Bug Fixes:
- Reorder ordered (enum) device list; tps65218
- Only accept valid data from the offset; rave-sp
- Refrain from copying junk from failed SPI read; cros_ec_dev
- Fix potential memory leaks; pcf50633-core
- Fix clock initialisation; twl-core
- Fix build-issue; tps65911
- Fix off-by-one error; tps65911
- Fix code ordering issues; intel-lpss
- Fix COMPILE_TEST related issues; pwm-stm32
- Fix broken MMC card detection; asic3
- Fix clocking related issues; intel-lpss-pci"
* tag 'mfd-next-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (84 commits)
mfd: cros_ec: Remove unused __remove function
mfd: wm97xx-core: Platform data can be NULL
mfd: cros_ec_dev: Don't advertise junk features on failure
mfd: cros_ec: Use devm_kzalloc for private data
mfd: intel-lpss: Fix Intel Cannon Lake LPSS I2C input clock
mfd: asic3: Fix broken MMC card detection
mfd: timberdale: Fix spelling mistake "Uknown" -> "Unknown"
mfd: omap-usb-host: Use match_string() helper
mfd: stm32-timers: Fix pwm-stm32 linker issue with COMPILE_TEST
pwm: stm32: Initialize raw local variables
mfd: arizona: Update DT doc to support more standard Reset binding
dt-bindings: mfd: Add bindings for DA9063L
mfd: intel-lpss: Correct names of RESETS register bits
mfd: qcom-spmi-pmic: Add support for pm8005, pm8998 and pmi8998
mfd: intel-lpss: Program REMAP register in PIO mode
mfd: cros_ec_i2c: Moving the system sleep pm ops to late
mfd: cros_ec_i2c: Add ACPI module device table
mfd: cros_ec_dev: Register shutdown function for debugfs
mfd: cros_ec_dev: Register cros-ec-rtc driver as a subdevice
mfd: cros_ec: Don't try to grab log when suspended
...
64 files changed, 1574 insertions, 994 deletions
diff --git a/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt new file mode 100644 index 000000000000..2888d07c2ef0 --- /dev/null +++ b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt | |||
@@ -0,0 +1,43 @@ | |||
1 | MediaTek MT6397/MT6323 PMIC Keys Device Driver | ||
2 | |||
3 | There are two key functions provided by MT6397/MT6323 PMIC, pwrkey | ||
4 | and homekey. The key functions are defined as the subnode of the function | ||
5 | node provided by MT6397/MT6323 PMIC that is being defined as one kind | ||
6 | of Muti-Function Device (MFD) | ||
7 | |||
8 | For MT6397/MT6323 MFD bindings see: | ||
9 | Documentation/devicetree/bindings/mfd/mt6397.txt | ||
10 | |||
11 | Required properties: | ||
12 | - compatible: "mediatek,mt6397-keys" or "mediatek,mt6323-keys" | ||
13 | - linux,keycodes: See Documentation/devicetree/bindings/input/keys.txt | ||
14 | |||
15 | Optional Properties: | ||
16 | - wakeup-source: See Documentation/devicetree/bindings/power/wakeup-source.txt | ||
17 | - mediatek,long-press-mode: Long press key shutdown setting, 1 for | ||
18 | pwrkey only, 2 for pwrkey/homekey together, others for disabled. | ||
19 | - power-off-time-sec: See Documentation/devicetree/bindings/input/keys.txt | ||
20 | |||
21 | Example: | ||
22 | |||
23 | pmic: mt6397 { | ||
24 | compatible = "mediatek,mt6397"; | ||
25 | |||
26 | ... | ||
27 | |||
28 | mt6397keys: mt6397keys { | ||
29 | compatible = "mediatek,mt6397-keys"; | ||
30 | mediatek,long-press-mode = <1>; | ||
31 | power-off-time-sec = <0>; | ||
32 | |||
33 | power { | ||
34 | linux,keycodes = <116>; | ||
35 | wakeup-source; | ||
36 | }; | ||
37 | |||
38 | home { | ||
39 | linux,keycodes = <114>; | ||
40 | }; | ||
41 | }; | ||
42 | |||
43 | }; | ||
diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt index bdd017686ea5..a014afb07902 100644 --- a/Documentation/devicetree/bindings/mfd/arizona.txt +++ b/Documentation/devicetree/bindings/mfd/arizona.txt | |||
@@ -50,7 +50,7 @@ Required properties: | |||
50 | 50 | ||
51 | Optional properties: | 51 | Optional properties: |
52 | 52 | ||
53 | - wlf,reset : GPIO specifier for the GPIO controlling /RESET | 53 | - reset-gpios : GPIO specifier for the GPIO controlling /RESET |
54 | 54 | ||
55 | - clocks: Should reference the clocks supplied on MCLK1 and MCLK2 | 55 | - clocks: Should reference the clocks supplied on MCLK1 and MCLK2 |
56 | - clock-names: Should contains two strings: | 56 | - clock-names: Should contains two strings: |
@@ -70,6 +70,10 @@ Optional properties: | |||
70 | Documentation/devicetree/bindings/regulator/regulator.txt | 70 | Documentation/devicetree/bindings/regulator/regulator.txt |
71 | (wm5102, wm5110, wm8280, wm8997, wm8998, wm1814) | 71 | (wm5102, wm5110, wm8280, wm8997, wm8998, wm1814) |
72 | 72 | ||
73 | Deprecated properties: | ||
74 | |||
75 | - wlf,reset : GPIO specifier for the GPIO controlling /RESET | ||
76 | |||
73 | Also see child specific device properties: | 77 | Also see child specific device properties: |
74 | Regulator - ../regulator/arizona-regulator.txt | 78 | Regulator - ../regulator/arizona-regulator.txt |
75 | Extcon - ../extcon/extcon-arizona.txt | 79 | Extcon - ../extcon/extcon-arizona.txt |
diff --git a/Documentation/devicetree/bindings/mfd/da9063.txt b/Documentation/devicetree/bindings/mfd/da9063.txt index 05b21bcb8543..443e68286957 100644 --- a/Documentation/devicetree/bindings/mfd/da9063.txt +++ b/Documentation/devicetree/bindings/mfd/da9063.txt | |||
@@ -1,4 +1,4 @@ | |||
1 | * Dialog DA9063 Power Management Integrated Circuit (PMIC) | 1 | * Dialog DA9063/DA9063L Power Management Integrated Circuit (PMIC) |
2 | 2 | ||
3 | DA9093 consists of a large and varied group of sub-devices (I2C Only): | 3 | DA9093 consists of a large and varied group of sub-devices (I2C Only): |
4 | 4 | ||
@@ -6,14 +6,14 @@ Device Supply Names Description | |||
6 | ------ ------------ ----------- | 6 | ------ ------------ ----------- |
7 | da9063-regulator : : LDOs & BUCKs | 7 | da9063-regulator : : LDOs & BUCKs |
8 | da9063-onkey : : On Key | 8 | da9063-onkey : : On Key |
9 | da9063-rtc : : Real-Time Clock | 9 | da9063-rtc : : Real-Time Clock (DA9063 only) |
10 | da9063-watchdog : : Watchdog | 10 | da9063-watchdog : : Watchdog |
11 | 11 | ||
12 | ====== | 12 | ====== |
13 | 13 | ||
14 | Required properties: | 14 | Required properties: |
15 | 15 | ||
16 | - compatible : Should be "dlg,da9063" | 16 | - compatible : Should be "dlg,da9063" or "dlg,da9063l" |
17 | - reg : Specifies the I2C slave address (this defaults to 0x58 but it can be | 17 | - reg : Specifies the I2C slave address (this defaults to 0x58 but it can be |
18 | modified to match the chip's OTP settings). | 18 | modified to match the chip's OTP settings). |
19 | - interrupt-parent : Specifies the reference to the interrupt controller for | 19 | - interrupt-parent : Specifies the reference to the interrupt controller for |
@@ -23,8 +23,8 @@ Required properties: | |||
23 | 23 | ||
24 | Sub-nodes: | 24 | Sub-nodes: |
25 | 25 | ||
26 | - regulators : This node defines the settings for the LDOs and BUCKs. The | 26 | - regulators : This node defines the settings for the LDOs and BUCKs. |
27 | DA9063 regulators are bound using their names listed below: | 27 | The DA9063(L) regulators are bound using their names listed below: |
28 | 28 | ||
29 | bcore1 : BUCK CORE1 | 29 | bcore1 : BUCK CORE1 |
30 | bcore2 : BUCK CORE2 | 30 | bcore2 : BUCK CORE2 |
@@ -32,16 +32,16 @@ Sub-nodes: | |||
32 | bmem : BUCK MEM | 32 | bmem : BUCK MEM |
33 | bio : BUCK IO | 33 | bio : BUCK IO |
34 | bperi : BUCK PERI | 34 | bperi : BUCK PERI |
35 | ldo1 : LDO_1 | 35 | ldo1 : LDO_1 (DA9063 only) |
36 | ldo2 : LDO_2 | 36 | ldo2 : LDO_2 (DA9063 only) |
37 | ldo3 : LDO_3 | 37 | ldo3 : LDO_3 |
38 | ldo4 : LDO_4 | 38 | ldo4 : LDO_4 (DA9063 only) |
39 | ldo5 : LDO_5 | 39 | ldo5 : LDO_5 (DA9063 only) |
40 | ldo6 : LDO_6 | 40 | ldo6 : LDO_6 (DA9063 only) |
41 | ldo7 : LDO_7 | 41 | ldo7 : LDO_7 |
42 | ldo8 : LDO_8 | 42 | ldo8 : LDO_8 |
43 | ldo9 : LDO_9 | 43 | ldo9 : LDO_9 |
44 | ldo10 : LDO_10 | 44 | ldo10 : LDO_10 (DA9063 only) |
45 | ldo11 : LDO_11 | 45 | ldo11 : LDO_11 |
46 | 46 | ||
47 | The component follows the standard regulator framework and the bindings | 47 | The component follows the standard regulator framework and the bindings |
@@ -49,8 +49,9 @@ Sub-nodes: | |||
49 | Documentation/devicetree/bindings/regulator/regulator.txt | 49 | Documentation/devicetree/bindings/regulator/regulator.txt |
50 | 50 | ||
51 | - rtc : This node defines settings for the Real-Time Clock associated with | 51 | - rtc : This node defines settings for the Real-Time Clock associated with |
52 | the DA9063. There are currently no entries in this binding, however | 52 | the DA9063 only. The RTC is not present in DA9063L. There are currently |
53 | compatible = "dlg,da9063-rtc" should be added if a node is created. | 53 | no entries in this binding, however compatible = "dlg,da9063-rtc" should |
54 | be added if a node is created. | ||
54 | 55 | ||
55 | - onkey : This node defines the OnKey settings for controlling the key | 56 | - onkey : This node defines the OnKey settings for controlling the key |
56 | functionality of the device. The node should contain the compatible property | 57 | functionality of the device. The node should contain the compatible property |
@@ -65,8 +66,9 @@ Sub-nodes: | |||
65 | and KEY_SLEEP. | 66 | and KEY_SLEEP. |
66 | 67 | ||
67 | - watchdog : This node defines settings for the Watchdog timer associated | 68 | - watchdog : This node defines settings for the Watchdog timer associated |
68 | with the DA9063. There are currently no entries in this binding, however | 69 | with the DA9063 and DA9063L. There are currently no entries in this |
69 | compatible = "dlg,da9063-watchdog" should be added if a node is created. | 70 | binding, however compatible = "dlg,da9063-watchdog" should be added |
71 | if a node is created. | ||
70 | 72 | ||
71 | 73 | ||
72 | Example: | 74 | Example: |
diff --git a/Documentation/devicetree/bindings/mfd/motorola-cpcap.txt b/Documentation/devicetree/bindings/mfd/motorola-cpcap.txt index 15bc885f9df4..c639705a98ef 100644 --- a/Documentation/devicetree/bindings/mfd/motorola-cpcap.txt +++ b/Documentation/devicetree/bindings/mfd/motorola-cpcap.txt | |||
@@ -12,6 +12,30 @@ Required properties: | |||
12 | - spi-max-frequency : Typically set to 3000000 | 12 | - spi-max-frequency : Typically set to 3000000 |
13 | - spi-cs-high : SPI chip select direction | 13 | - spi-cs-high : SPI chip select direction |
14 | 14 | ||
15 | Optional subnodes: | ||
16 | |||
17 | The sub-functions of CPCAP get their own node with their own compatible values, | ||
18 | which are described in the following files: | ||
19 | |||
20 | - ../power/supply/cpcap-battery.txt | ||
21 | - ../power/supply/cpcap-charger.txt | ||
22 | - ../regulator/cpcap-regulator.txt | ||
23 | - ../phy/phy-cpcap-usb.txt | ||
24 | - ../input/cpcap-pwrbutton.txt | ||
25 | - ../rtc/cpcap-rtc.txt | ||
26 | - ../leds/leds-cpcap.txt | ||
27 | - ../iio/adc/cpcap-adc.txt | ||
28 | |||
29 | The only exception is the audio codec. Instead of a compatible value its | ||
30 | node must be named "audio-codec". | ||
31 | |||
32 | Required properties for the audio-codec subnode: | ||
33 | |||
34 | - #sound-dai-cells = <1>; | ||
35 | |||
36 | The audio-codec provides two DAIs. The first one is connected to the | ||
37 | Stereo HiFi DAC and the second one is connected to the Voice DAC. | ||
38 | |||
15 | Example: | 39 | Example: |
16 | 40 | ||
17 | &mcspi1 { | 41 | &mcspi1 { |
@@ -26,6 +50,24 @@ Example: | |||
26 | #size-cells = <0>; | 50 | #size-cells = <0>; |
27 | spi-max-frequency = <3000000>; | 51 | spi-max-frequency = <3000000>; |
28 | spi-cs-high; | 52 | spi-cs-high; |
53 | |||
54 | audio-codec { | ||
55 | #sound-dai-cells = <1>; | ||
56 | |||
57 | /* HiFi */ | ||
58 | port@0 { | ||
59 | endpoint { | ||
60 | remote-endpoint = <&cpu_dai1>; | ||
61 | }; | ||
62 | }; | ||
63 | |||
64 | /* Voice */ | ||
65 | port@1 { | ||
66 | endpoint { | ||
67 | remote-endpoint = <&cpu_dai2>; | ||
68 | }; | ||
69 | }; | ||
70 | }; | ||
29 | }; | 71 | }; |
30 | }; | 72 | }; |
31 | 73 | ||
diff --git a/Documentation/devicetree/bindings/mfd/mt6397.txt b/Documentation/devicetree/bindings/mfd/mt6397.txt index 522a3bbf1bac..d1df77f4d655 100644 --- a/Documentation/devicetree/bindings/mfd/mt6397.txt +++ b/Documentation/devicetree/bindings/mfd/mt6397.txt | |||
@@ -7,6 +7,7 @@ MT6397/MT6323 is a multifunction device with the following sub modules: | |||
7 | - GPIO | 7 | - GPIO |
8 | - Clock | 8 | - Clock |
9 | - LED | 9 | - LED |
10 | - Keys | ||
10 | 11 | ||
11 | It is interfaced to host controller using SPI interface by a proprietary hardware | 12 | It is interfaced to host controller using SPI interface by a proprietary hardware |
12 | called PMIC wrapper or pwrap. MT6397/MT6323 MFD is a child device of pwrap. | 13 | called PMIC wrapper or pwrap. MT6397/MT6323 MFD is a child device of pwrap. |
@@ -40,6 +41,11 @@ Optional subnodes: | |||
40 | - compatible: "mediatek,mt6323-led" | 41 | - compatible: "mediatek,mt6323-led" |
41 | see Documentation/devicetree/bindings/leds/leds-mt6323.txt | 42 | see Documentation/devicetree/bindings/leds/leds-mt6323.txt |
42 | 43 | ||
44 | - keys | ||
45 | Required properties: | ||
46 | - compatible: "mediatek,mt6397-keys" or "mediatek,mt6323-keys" | ||
47 | see Documentation/devicetree/bindings/input/mtk-pmic-keys.txt | ||
48 | |||
43 | Example: | 49 | Example: |
44 | pwrap: pwrap@1000f000 { | 50 | pwrap: pwrap@1000f000 { |
45 | compatible = "mediatek,mt8135-pwrap"; | 51 | compatible = "mediatek,mt8135-pwrap"; |
diff --git a/Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.txt b/Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.txt index 6ac06c1b9aec..143706222a51 100644 --- a/Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.txt +++ b/Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.txt | |||
@@ -29,6 +29,9 @@ Required properties: | |||
29 | "qcom,pm8916", | 29 | "qcom,pm8916", |
30 | "qcom,pm8004", | 30 | "qcom,pm8004", |
31 | "qcom,pm8909", | 31 | "qcom,pm8909", |
32 | "qcom,pm8998", | ||
33 | "qcom,pmi8998", | ||
34 | "qcom,pm8005", | ||
32 | or generalized "qcom,spmi-pmic". | 35 | or generalized "qcom,spmi-pmic". |
33 | - reg: Specifies the SPMI USID slave address for this device. | 36 | - reg: Specifies the SPMI USID slave address for this device. |
34 | For more information see: | 37 | For more information see: |
diff --git a/MAINTAINERS b/MAINTAINERS index 2c7069037a15..8fcfc9a4a71d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -13562,6 +13562,16 @@ T: git git://linuxtv.org/media_tree.git | |||
13562 | S: Maintained | 13562 | S: Maintained |
13563 | F: drivers/media/usb/stk1160/ | 13563 | F: drivers/media/usb/stk1160/ |
13564 | 13564 | ||
13565 | STM32 TIMER/LPTIMER DRIVERS | ||
13566 | M: Fabrice Gasnier <fabrice.gasnier@st.com> | ||
13567 | S: Maintained | ||
13568 | F: drivers/*/stm32-*timer* | ||
13569 | F: drivers/pwm/pwm-stm32* | ||
13570 | F: include/linux/*/stm32-*tim* | ||
13571 | F: Documentation/ABI/testing/*timer-stm32 | ||
13572 | F: Documentation/devicetree/bindings/*/stm32-*timer | ||
13573 | F: Documentation/devicetree/bindings/pwm/pwm-stm32* | ||
13574 | |||
13565 | STMMAC ETHERNET DRIVER | 13575 | STMMAC ETHERNET DRIVER |
13566 | M: Giuseppe Cavallaro <peppe.cavallaro@st.com> | 13576 | M: Giuseppe Cavallaro <peppe.cavallaro@st.com> |
13567 | M: Alexandre Torgue <alexandre.torgue@st.com> | 13577 | M: Alexandre Torgue <alexandre.torgue@st.com> |
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 2b469cc47a78..6bd97ffee761 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig | |||
@@ -747,4 +747,13 @@ config KEYBOARD_BCM | |||
747 | To compile this driver as a module, choose M here: the | 747 | To compile this driver as a module, choose M here: the |
748 | module will be called bcm-keypad. | 748 | module will be called bcm-keypad. |
749 | 749 | ||
750 | config KEYBOARD_MTK_PMIC | ||
751 | tristate "MediaTek PMIC keys support" | ||
752 | depends on MFD_MT6397 | ||
753 | help | ||
754 | Say Y here if you want to use the pmic keys (powerkey/homekey). | ||
755 | |||
756 | To compile this driver as a module, choose M here: the | ||
757 | module will be called pmic-keys. | ||
758 | |||
750 | endif | 759 | endif |
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index 8fab920afa58..182e92985dbf 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile | |||
@@ -40,6 +40,7 @@ obj-$(CONFIG_KEYBOARD_MATRIX) += matrix_keypad.o | |||
40 | obj-$(CONFIG_KEYBOARD_MAX7359) += max7359_keypad.o | 40 | obj-$(CONFIG_KEYBOARD_MAX7359) += max7359_keypad.o |
41 | obj-$(CONFIG_KEYBOARD_MCS) += mcs_touchkey.o | 41 | obj-$(CONFIG_KEYBOARD_MCS) += mcs_touchkey.o |
42 | obj-$(CONFIG_KEYBOARD_MPR121) += mpr121_touchkey.o | 42 | obj-$(CONFIG_KEYBOARD_MPR121) += mpr121_touchkey.o |
43 | obj-$(CONFIG_KEYBOARD_MTK_PMIC) += mtk-pmic-keys.o | ||
43 | obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o | 44 | obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o |
44 | obj-$(CONFIG_KEYBOARD_NOMADIK) += nomadik-ske-keypad.o | 45 | obj-$(CONFIG_KEYBOARD_NOMADIK) += nomadik-ske-keypad.o |
45 | obj-$(CONFIG_KEYBOARD_NSPIRE) += nspire-keypad.o | 46 | obj-$(CONFIG_KEYBOARD_NSPIRE) += nspire-keypad.o |
diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c new file mode 100644 index 000000000000..02c67a1749fc --- /dev/null +++ b/drivers/input/keyboard/mtk-pmic-keys.c | |||
@@ -0,0 +1,339 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2017 MediaTek, Inc. | ||
3 | * | ||
4 | * Author: Chen Zhong <chen.zhong@mediatek.com> | ||
5 | * | ||
6 | * This software is licensed under the terms of the GNU General Public | ||
7 | * License version 2, as published by the Free Software Foundation, and | ||
8 | * may be copied, distributed, and modified under those terms. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | */ | ||
16 | |||
17 | #include <linux/module.h> | ||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/input.h> | ||
20 | #include <linux/interrupt.h> | ||
21 | #include <linux/platform_device.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/of.h> | ||
24 | #include <linux/of_device.h> | ||
25 | #include <linux/regmap.h> | ||
26 | #include <linux/mfd/mt6323/registers.h> | ||
27 | #include <linux/mfd/mt6397/registers.h> | ||
28 | #include <linux/mfd/mt6397/core.h> | ||
29 | |||
30 | #define MTK_PMIC_PWRKEY_RST_EN_MASK 0x1 | ||
31 | #define MTK_PMIC_PWRKEY_RST_EN_SHIFT 6 | ||
32 | #define MTK_PMIC_HOMEKEY_RST_EN_MASK 0x1 | ||
33 | #define MTK_PMIC_HOMEKEY_RST_EN_SHIFT 5 | ||
34 | #define MTK_PMIC_RST_DU_MASK 0x3 | ||
35 | #define MTK_PMIC_RST_DU_SHIFT 8 | ||
36 | |||
37 | #define MTK_PMIC_PWRKEY_RST \ | ||
38 | (MTK_PMIC_PWRKEY_RST_EN_MASK << MTK_PMIC_PWRKEY_RST_EN_SHIFT) | ||
39 | #define MTK_PMIC_HOMEKEY_RST \ | ||
40 | (MTK_PMIC_HOMEKEY_RST_EN_MASK << MTK_PMIC_HOMEKEY_RST_EN_SHIFT) | ||
41 | |||
42 | #define MTK_PMIC_PWRKEY_INDEX 0 | ||
43 | #define MTK_PMIC_HOMEKEY_INDEX 1 | ||
44 | #define MTK_PMIC_MAX_KEY_COUNT 2 | ||
45 | |||
46 | struct mtk_pmic_keys_regs { | ||
47 | u32 deb_reg; | ||
48 | u32 deb_mask; | ||
49 | u32 intsel_reg; | ||
50 | u32 intsel_mask; | ||
51 | }; | ||
52 | |||
53 | #define MTK_PMIC_KEYS_REGS(_deb_reg, _deb_mask, \ | ||
54 | _intsel_reg, _intsel_mask) \ | ||
55 | { \ | ||
56 | .deb_reg = _deb_reg, \ | ||
57 | .deb_mask = _deb_mask, \ | ||
58 | .intsel_reg = _intsel_reg, \ | ||
59 | .intsel_mask = _intsel_mask, \ | ||
60 | } | ||
61 | |||
62 | struct mtk_pmic_regs { | ||
63 | const struct mtk_pmic_keys_regs keys_regs[MTK_PMIC_MAX_KEY_COUNT]; | ||
64 | u32 pmic_rst_reg; | ||
65 | }; | ||
66 | |||
67 | static const struct mtk_pmic_regs mt6397_regs = { | ||
68 | .keys_regs[MTK_PMIC_PWRKEY_INDEX] = | ||
69 | MTK_PMIC_KEYS_REGS(MT6397_CHRSTATUS, | ||
70 | 0x8, MT6397_INT_RSV, 0x10), | ||
71 | .keys_regs[MTK_PMIC_HOMEKEY_INDEX] = | ||
72 | MTK_PMIC_KEYS_REGS(MT6397_OCSTATUS2, | ||
73 | 0x10, MT6397_INT_RSV, 0x8), | ||
74 | .pmic_rst_reg = MT6397_TOP_RST_MISC, | ||
75 | }; | ||
76 | |||
77 | static const struct mtk_pmic_regs mt6323_regs = { | ||
78 | .keys_regs[MTK_PMIC_PWRKEY_INDEX] = | ||
79 | MTK_PMIC_KEYS_REGS(MT6323_CHRSTATUS, | ||
80 | 0x2, MT6323_INT_MISC_CON, 0x10), | ||
81 | .keys_regs[MTK_PMIC_HOMEKEY_INDEX] = | ||
82 | MTK_PMIC_KEYS_REGS(MT6323_CHRSTATUS, | ||
83 | 0x4, MT6323_INT_MISC_CON, 0x8), | ||
84 | .pmic_rst_reg = MT6323_TOP_RST_MISC, | ||
85 | }; | ||
86 | |||
87 | struct mtk_pmic_keys_info { | ||
88 | struct mtk_pmic_keys *keys; | ||
89 | const struct mtk_pmic_keys_regs *regs; | ||
90 | unsigned int keycode; | ||
91 | int irq; | ||
92 | bool wakeup:1; | ||
93 | }; | ||
94 | |||
95 | struct mtk_pmic_keys { | ||
96 | struct input_dev *input_dev; | ||
97 | struct device *dev; | ||
98 | struct regmap *regmap; | ||
99 | struct mtk_pmic_keys_info keys[MTK_PMIC_MAX_KEY_COUNT]; | ||
100 | }; | ||
101 | |||
102 | enum mtk_pmic_keys_lp_mode { | ||
103 | LP_DISABLE, | ||
104 | LP_ONEKEY, | ||
105 | LP_TWOKEY, | ||
106 | }; | ||
107 | |||
108 | static void mtk_pmic_keys_lp_reset_setup(struct mtk_pmic_keys *keys, | ||
109 | u32 pmic_rst_reg) | ||
110 | { | ||
111 | int ret; | ||
112 | u32 long_press_mode, long_press_debounce; | ||
113 | |||
114 | ret = of_property_read_u32(keys->dev->of_node, | ||
115 | "power-off-time-sec", &long_press_debounce); | ||
116 | if (ret) | ||
117 | long_press_debounce = 0; | ||
118 | |||
119 | regmap_update_bits(keys->regmap, pmic_rst_reg, | ||
120 | MTK_PMIC_RST_DU_MASK << MTK_PMIC_RST_DU_SHIFT, | ||
121 | long_press_debounce << MTK_PMIC_RST_DU_SHIFT); | ||
122 | |||
123 | ret = of_property_read_u32(keys->dev->of_node, | ||
124 | "mediatek,long-press-mode", &long_press_mode); | ||
125 | if (ret) | ||
126 | long_press_mode = LP_DISABLE; | ||
127 | |||
128 | switch (long_press_mode) { | ||
129 | case LP_ONEKEY: | ||
130 | regmap_update_bits(keys->regmap, pmic_rst_reg, | ||
131 | MTK_PMIC_PWRKEY_RST, | ||
132 | MTK_PMIC_PWRKEY_RST); | ||
133 | regmap_update_bits(keys->regmap, pmic_rst_reg, | ||
134 | MTK_PMIC_HOMEKEY_RST, | ||
135 | 0); | ||
136 | break; | ||
137 | case LP_TWOKEY: | ||
138 | regmap_update_bits(keys->regmap, pmic_rst_reg, | ||
139 | MTK_PMIC_PWRKEY_RST, | ||
140 | MTK_PMIC_PWRKEY_RST); | ||
141 | regmap_update_bits(keys->regmap, pmic_rst_reg, | ||
142 | MTK_PMIC_HOMEKEY_RST, | ||
143 | MTK_PMIC_HOMEKEY_RST); | ||
144 | break; | ||
145 | case LP_DISABLE: | ||
146 | regmap_update_bits(keys->regmap, pmic_rst_reg, | ||
147 | MTK_PMIC_PWRKEY_RST, | ||
148 | 0); | ||
149 | regmap_update_bits(keys->regmap, pmic_rst_reg, | ||
150 | MTK_PMIC_HOMEKEY_RST, | ||
151 | 0); | ||
152 | break; | ||
153 | default: | ||
154 | break; | ||
155 | } | ||
156 | } | ||
157 | |||
158 | static irqreturn_t mtk_pmic_keys_irq_handler_thread(int irq, void *data) | ||
159 | { | ||
160 | struct mtk_pmic_keys_info *info = data; | ||
161 | u32 key_deb, pressed; | ||
162 | |||
163 | regmap_read(info->keys->regmap, info->regs->deb_reg, &key_deb); | ||
164 | |||
165 | key_deb &= info->regs->deb_mask; | ||
166 | |||
167 | pressed = !key_deb; | ||
168 | |||
169 | input_report_key(info->keys->input_dev, info->keycode, pressed); | ||
170 | input_sync(info->keys->input_dev); | ||
171 | |||
172 | dev_dbg(info->keys->dev, "(%s) key =%d using PMIC\n", | ||
173 | pressed ? "pressed" : "released", info->keycode); | ||
174 | |||
175 | return IRQ_HANDLED; | ||
176 | } | ||
177 | |||
178 | static int mtk_pmic_key_setup(struct mtk_pmic_keys *keys, | ||
179 | struct mtk_pmic_keys_info *info) | ||
180 | { | ||
181 | int ret; | ||
182 | |||
183 | info->keys = keys; | ||
184 | |||
185 | ret = regmap_update_bits(keys->regmap, info->regs->intsel_reg, | ||
186 | info->regs->intsel_mask, | ||
187 | info->regs->intsel_mask); | ||
188 | if (ret < 0) | ||
189 | return ret; | ||
190 | |||
191 | ret = devm_request_threaded_irq(keys->dev, info->irq, NULL, | ||
192 | mtk_pmic_keys_irq_handler_thread, | ||
193 | IRQF_ONESHOT | IRQF_TRIGGER_HIGH, | ||
194 | "mtk-pmic-keys", info); | ||
195 | if (ret) { | ||
196 | dev_err(keys->dev, "Failed to request IRQ: %d: %d\n", | ||
197 | info->irq, ret); | ||
198 | return ret; | ||
199 | } | ||
200 | |||
201 | input_set_capability(keys->input_dev, EV_KEY, info->keycode); | ||
202 | |||
203 | return 0; | ||
204 | } | ||
205 | |||
206 | static int __maybe_unused mtk_pmic_keys_suspend(struct device *dev) | ||
207 | { | ||
208 | struct mtk_pmic_keys *keys = dev_get_drvdata(dev); | ||
209 | int index; | ||
210 | |||
211 | for (index = 0; index < MTK_PMIC_MAX_KEY_COUNT; index++) { | ||
212 | if (keys->keys[index].wakeup) | ||
213 | enable_irq_wake(keys->keys[index].irq); | ||
214 | } | ||
215 | |||
216 | return 0; | ||
217 | } | ||
218 | |||
219 | static int __maybe_unused mtk_pmic_keys_resume(struct device *dev) | ||
220 | { | ||
221 | struct mtk_pmic_keys *keys = dev_get_drvdata(dev); | ||
222 | int index; | ||
223 | |||
224 | for (index = 0; index < MTK_PMIC_MAX_KEY_COUNT; index++) { | ||
225 | if (keys->keys[index].wakeup) | ||
226 | disable_irq_wake(keys->keys[index].irq); | ||
227 | } | ||
228 | |||
229 | return 0; | ||
230 | } | ||
231 | |||
232 | static SIMPLE_DEV_PM_OPS(mtk_pmic_keys_pm_ops, mtk_pmic_keys_suspend, | ||
233 | mtk_pmic_keys_resume); | ||
234 | |||
235 | static const struct of_device_id of_mtk_pmic_keys_match_tbl[] = { | ||
236 | { | ||
237 | .compatible = "mediatek,mt6397-keys", | ||
238 | .data = &mt6397_regs, | ||
239 | }, { | ||
240 | .compatible = "mediatek,mt6323-keys", | ||
241 | .data = &mt6323_regs, | ||
242 | }, { | ||
243 | /* sentinel */ | ||
244 | } | ||
245 | }; | ||
246 | MODULE_DEVICE_TABLE(of, of_mtk_pmic_keys_match_tbl); | ||
247 | |||
248 | static int mtk_pmic_keys_probe(struct platform_device *pdev) | ||
249 | { | ||
250 | int error, index = 0; | ||
251 | unsigned int keycount; | ||
252 | struct mt6397_chip *pmic_chip = dev_get_drvdata(pdev->dev.parent); | ||
253 | struct device_node *node = pdev->dev.of_node, *child; | ||
254 | struct mtk_pmic_keys *keys; | ||
255 | const struct mtk_pmic_regs *mtk_pmic_regs; | ||
256 | struct input_dev *input_dev; | ||
257 | const struct of_device_id *of_id = | ||
258 | of_match_device(of_mtk_pmic_keys_match_tbl, &pdev->dev); | ||
259 | |||
260 | keys = devm_kzalloc(&pdev->dev, sizeof(*keys), GFP_KERNEL); | ||
261 | if (!keys) | ||
262 | return -ENOMEM; | ||
263 | |||
264 | keys->dev = &pdev->dev; | ||
265 | keys->regmap = pmic_chip->regmap; | ||
266 | mtk_pmic_regs = of_id->data; | ||
267 | |||
268 | keys->input_dev = input_dev = devm_input_allocate_device(keys->dev); | ||
269 | if (!input_dev) { | ||
270 | dev_err(keys->dev, "input allocate device fail.\n"); | ||
271 | return -ENOMEM; | ||
272 | } | ||
273 | |||
274 | input_dev->name = "mtk-pmic-keys"; | ||
275 | input_dev->id.bustype = BUS_HOST; | ||
276 | input_dev->id.vendor = 0x0001; | ||
277 | input_dev->id.product = 0x0001; | ||
278 | input_dev->id.version = 0x0001; | ||
279 | |||
280 | keycount = of_get_available_child_count(node); | ||
281 | if (keycount > MTK_PMIC_MAX_KEY_COUNT) { | ||
282 | dev_err(keys->dev, "too many keys defined (%d)\n", keycount); | ||
283 | return -EINVAL; | ||
284 | } | ||
285 | |||
286 | for_each_child_of_node(node, child) { | ||
287 | keys->keys[index].regs = &mtk_pmic_regs->keys_regs[index]; | ||
288 | |||
289 | keys->keys[index].irq = platform_get_irq(pdev, index); | ||
290 | if (keys->keys[index].irq < 0) | ||
291 | return keys->keys[index].irq; | ||
292 | |||
293 | error = of_property_read_u32(child, | ||
294 | "linux,keycodes", &keys->keys[index].keycode); | ||
295 | if (error) { | ||
296 | dev_err(keys->dev, | ||
297 | "failed to read key:%d linux,keycode property: %d\n", | ||
298 | index, error); | ||
299 | return error; | ||
300 | } | ||
301 | |||
302 | if (of_property_read_bool(child, "wakeup-source")) | ||
303 | keys->keys[index].wakeup = true; | ||
304 | |||
305 | error = mtk_pmic_key_setup(keys, &keys->keys[index]); | ||
306 | if (error) | ||
307 | return error; | ||
308 | |||
309 | index++; | ||
310 | } | ||
311 | |||
312 | error = input_register_device(input_dev); | ||
313 | if (error) { | ||
314 | dev_err(&pdev->dev, | ||
315 | "register input device failed (%d)\n", error); | ||
316 | return error; | ||
317 | } | ||
318 | |||
319 | mtk_pmic_keys_lp_reset_setup(keys, mtk_pmic_regs->pmic_rst_reg); | ||
320 | |||
321 | platform_set_drvdata(pdev, keys); | ||
322 | |||
323 | return 0; | ||
324 | } | ||
325 | |||
326 | static struct platform_driver pmic_keys_pdrv = { | ||
327 | .probe = mtk_pmic_keys_probe, | ||
328 | .driver = { | ||
329 | .name = "mtk-pmic-keys", | ||
330 | .of_match_table = of_mtk_pmic_keys_match_tbl, | ||
331 | .pm = &mtk_pmic_keys_pm_ops, | ||
332 | }, | ||
333 | }; | ||
334 | |||
335 | module_platform_driver(pmic_keys_pdrv); | ||
336 | |||
337 | MODULE_LICENSE("GPL v2"); | ||
338 | MODULE_AUTHOR("Chen Zhong <chen.zhong@mediatek.com>"); | ||
339 | MODULE_DESCRIPTION("MTK pmic-keys driver v0.1"); | ||
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index d9d2cf0d32ef..e9fd20dba18d 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile | |||
@@ -13,7 +13,6 @@ obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o | |||
13 | obj-$(CONFIG_MFD_BCM590XX) += bcm590xx.o | 13 | obj-$(CONFIG_MFD_BCM590XX) += bcm590xx.o |
14 | obj-$(CONFIG_MFD_BD9571MWV) += bd9571mwv.o | 14 | obj-$(CONFIG_MFD_BD9571MWV) += bd9571mwv.o |
15 | cros_ec_core-objs := cros_ec.o | 15 | cros_ec_core-objs := cros_ec.o |
16 | cros_ec_core-$(CONFIG_ACPI) += cros_ec_acpi_gpe.o | ||
17 | obj-$(CONFIG_MFD_CROS_EC) += cros_ec_core.o | 16 | obj-$(CONFIG_MFD_CROS_EC) += cros_ec_core.o |
18 | obj-$(CONFIG_MFD_CROS_EC_I2C) += cros_ec_i2c.o | 17 | obj-$(CONFIG_MFD_CROS_EC_I2C) += cros_ec_i2c.o |
19 | obj-$(CONFIG_MFD_CROS_EC_SPI) += cros_ec_spi.o | 18 | obj-$(CONFIG_MFD_CROS_EC_SPI) += cros_ec_spi.o |
diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c index 8ba41073dd89..831a1ceb2ed2 100644 --- a/drivers/mfd/ab8500-debugfs.c +++ b/drivers/mfd/ab8500-debugfs.c | |||
@@ -2519,11 +2519,10 @@ static ssize_t ab8500_subscribe_write(struct file *file, | |||
2519 | if (!dev_attr[irq_index]) | 2519 | if (!dev_attr[irq_index]) |
2520 | return -ENOMEM; | 2520 | return -ENOMEM; |
2521 | 2521 | ||
2522 | event_name[irq_index] = kmalloc(count, GFP_KERNEL); | 2522 | event_name[irq_index] = kasprintf(GFP_KERNEL, "%lu", user_val); |
2523 | if (!event_name[irq_index]) | 2523 | if (!event_name[irq_index]) |
2524 | return -ENOMEM; | 2524 | return -ENOMEM; |
2525 | 2525 | ||
2526 | sprintf(event_name[irq_index], "%lu", user_val); | ||
2527 | dev_attr[irq_index]->show = show_irq; | 2526 | dev_attr[irq_index]->show = show_irq; |
2528 | dev_attr[irq_index]->store = NULL; | 2527 | dev_attr[irq_index]->store = NULL; |
2529 | dev_attr[irq_index]->attr.name = event_name[irq_index]; | 2528 | dev_attr[irq_index]->attr.name = event_name[irq_index]; |
diff --git a/drivers/mfd/abx500-core.c b/drivers/mfd/abx500-core.c index 0d3846a4767c..f282d39a5917 100644 --- a/drivers/mfd/abx500-core.c +++ b/drivers/mfd/abx500-core.c | |||
@@ -37,15 +37,12 @@ int abx500_register_ops(struct device *dev, struct abx500_ops *ops) | |||
37 | { | 37 | { |
38 | struct abx500_device_entry *dev_entry; | 38 | struct abx500_device_entry *dev_entry; |
39 | 39 | ||
40 | dev_entry = devm_kzalloc(dev, | 40 | dev_entry = devm_kzalloc(dev, sizeof(*dev_entry), GFP_KERNEL); |
41 | sizeof(struct abx500_device_entry), | 41 | if (!dev_entry) |
42 | GFP_KERNEL); | ||
43 | if (!dev_entry) { | ||
44 | dev_err(dev, "register_ops kzalloc failed"); | ||
45 | return -ENOMEM; | 42 | return -ENOMEM; |
46 | } | 43 | |
47 | dev_entry->dev = dev; | 44 | dev_entry->dev = dev; |
48 | memcpy(&dev_entry->ops, ops, sizeof(struct abx500_ops)); | 45 | memcpy(&dev_entry->ops, ops, sizeof(*ops)); |
49 | 46 | ||
50 | list_add_tail(&dev_entry->list, &abx500_list); | 47 | list_add_tail(&dev_entry->list, &abx500_list); |
51 | return 0; | 48 | return 0; |
@@ -68,7 +65,7 @@ int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg, | |||
68 | struct abx500_ops *ops; | 65 | struct abx500_ops *ops; |
69 | 66 | ||
70 | lookup_ops(dev->parent, &ops); | 67 | lookup_ops(dev->parent, &ops); |
71 | if ((ops != NULL) && (ops->set_register != NULL)) | 68 | if (ops && ops->set_register) |
72 | return ops->set_register(dev, bank, reg, value); | 69 | return ops->set_register(dev, bank, reg, value); |
73 | else | 70 | else |
74 | return -ENOTSUPP; | 71 | return -ENOTSUPP; |
@@ -81,7 +78,7 @@ int abx500_get_register_interruptible(struct device *dev, u8 bank, u8 reg, | |||
81 | struct abx500_ops *ops; | 78 | struct abx500_ops *ops; |
82 | 79 | ||
83 | lookup_ops(dev->parent, &ops); | 80 | lookup_ops(dev->parent, &ops); |
84 | if ((ops != NULL) && (ops->get_register != NULL)) | 81 | if (ops && ops->get_register) |
85 | return ops->get_register(dev, bank, reg, value); | 82 | return ops->get_register(dev, bank, reg, value); |
86 | else | 83 | else |
87 | return -ENOTSUPP; | 84 | return -ENOTSUPP; |
@@ -94,7 +91,7 @@ int abx500_get_register_page_interruptible(struct device *dev, u8 bank, | |||
94 | struct abx500_ops *ops; | 91 | struct abx500_ops *ops; |
95 | 92 | ||
96 | lookup_ops(dev->parent, &ops); | 93 | lookup_ops(dev->parent, &ops); |
97 | if ((ops != NULL) && (ops->get_register_page != NULL)) | 94 | if (ops && ops->get_register_page) |
98 | return ops->get_register_page(dev, bank, | 95 | return ops->get_register_page(dev, bank, |
99 | first_reg, regvals, numregs); | 96 | first_reg, regvals, numregs); |
100 | else | 97 | else |
@@ -108,7 +105,7 @@ int abx500_mask_and_set_register_interruptible(struct device *dev, u8 bank, | |||
108 | struct abx500_ops *ops; | 105 | struct abx500_ops *ops; |
109 | 106 | ||
110 | lookup_ops(dev->parent, &ops); | 107 | lookup_ops(dev->parent, &ops); |
111 | if ((ops != NULL) && (ops->mask_and_set_register != NULL)) | 108 | if (ops && ops->mask_and_set_register) |
112 | return ops->mask_and_set_register(dev, bank, | 109 | return ops->mask_and_set_register(dev, bank, |
113 | reg, bitmask, bitvalues); | 110 | reg, bitmask, bitvalues); |
114 | else | 111 | else |
@@ -121,7 +118,7 @@ int abx500_get_chip_id(struct device *dev) | |||
121 | struct abx500_ops *ops; | 118 | struct abx500_ops *ops; |
122 | 119 | ||
123 | lookup_ops(dev->parent, &ops); | 120 | lookup_ops(dev->parent, &ops); |
124 | if ((ops != NULL) && (ops->get_chip_id != NULL)) | 121 | if (ops && ops->get_chip_id) |
125 | return ops->get_chip_id(dev); | 122 | return ops->get_chip_id(dev); |
126 | else | 123 | else |
127 | return -ENOTSUPP; | 124 | return -ENOTSUPP; |
@@ -133,7 +130,7 @@ int abx500_event_registers_startup_state_get(struct device *dev, u8 *event) | |||
133 | struct abx500_ops *ops; | 130 | struct abx500_ops *ops; |
134 | 131 | ||
135 | lookup_ops(dev->parent, &ops); | 132 | lookup_ops(dev->parent, &ops); |
136 | if ((ops != NULL) && (ops->event_registers_startup_state_get != NULL)) | 133 | if (ops && ops->event_registers_startup_state_get) |
137 | return ops->event_registers_startup_state_get(dev, event); | 134 | return ops->event_registers_startup_state_get(dev, event); |
138 | else | 135 | else |
139 | return -ENOTSUPP; | 136 | return -ENOTSUPP; |
@@ -145,7 +142,7 @@ int abx500_startup_irq_enabled(struct device *dev, unsigned int irq) | |||
145 | struct abx500_ops *ops; | 142 | struct abx500_ops *ops; |
146 | 143 | ||
147 | lookup_ops(dev->parent, &ops); | 144 | lookup_ops(dev->parent, &ops); |
148 | if ((ops != NULL) && (ops->startup_irq_enabled != NULL)) | 145 | if (ops && ops->startup_irq_enabled) |
149 | return ops->startup_irq_enabled(dev, irq); | 146 | return ops->startup_irq_enabled(dev, irq); |
150 | else | 147 | else |
151 | return -ENOTSUPP; | 148 | return -ENOTSUPP; |
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index 77875250abe5..83f1c5a516d9 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c | |||
@@ -13,13 +13,12 @@ | |||
13 | #include <linux/clk.h> | 13 | #include <linux/clk.h> |
14 | #include <linux/delay.h> | 14 | #include <linux/delay.h> |
15 | #include <linux/err.h> | 15 | #include <linux/err.h> |
16 | #include <linux/gpio.h> | 16 | #include <linux/gpio/consumer.h> |
17 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
18 | #include <linux/mfd/core.h> | 18 | #include <linux/mfd/core.h> |
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/of.h> | 20 | #include <linux/of.h> |
21 | #include <linux/of_device.h> | 21 | #include <linux/of_device.h> |
22 | #include <linux/of_gpio.h> | ||
23 | #include <linux/pm_runtime.h> | 22 | #include <linux/pm_runtime.h> |
24 | #include <linux/regmap.h> | 23 | #include <linux/regmap.h> |
25 | #include <linux/regulator/consumer.h> | 24 | #include <linux/regulator/consumer.h> |
@@ -279,7 +278,7 @@ static int arizona_wait_for_boot(struct arizona *arizona) | |||
279 | static inline void arizona_enable_reset(struct arizona *arizona) | 278 | static inline void arizona_enable_reset(struct arizona *arizona) |
280 | { | 279 | { |
281 | if (arizona->pdata.reset) | 280 | if (arizona->pdata.reset) |
282 | gpio_set_value_cansleep(arizona->pdata.reset, 0); | 281 | gpiod_set_raw_value_cansleep(arizona->pdata.reset, 0); |
283 | } | 282 | } |
284 | 283 | ||
285 | static void arizona_disable_reset(struct arizona *arizona) | 284 | static void arizona_disable_reset(struct arizona *arizona) |
@@ -295,7 +294,7 @@ static void arizona_disable_reset(struct arizona *arizona) | |||
295 | break; | 294 | break; |
296 | } | 295 | } |
297 | 296 | ||
298 | gpio_set_value_cansleep(arizona->pdata.reset, 1); | 297 | gpiod_set_raw_value_cansleep(arizona->pdata.reset, 1); |
299 | usleep_range(1000, 5000); | 298 | usleep_range(1000, 5000); |
300 | } | 299 | } |
301 | } | 300 | } |
@@ -799,14 +798,27 @@ static int arizona_of_get_core_pdata(struct arizona *arizona) | |||
799 | struct arizona_pdata *pdata = &arizona->pdata; | 798 | struct arizona_pdata *pdata = &arizona->pdata; |
800 | int ret, i; | 799 | int ret, i; |
801 | 800 | ||
802 | pdata->reset = of_get_named_gpio(arizona->dev->of_node, "wlf,reset", 0); | 801 | /* Handle old non-standard DT binding */ |
803 | if (pdata->reset == -EPROBE_DEFER) { | 802 | pdata->reset = devm_gpiod_get_from_of_node(arizona->dev, |
804 | return pdata->reset; | 803 | arizona->dev->of_node, |
805 | } else if (pdata->reset < 0) { | 804 | "wlf,reset", 0, |
806 | dev_err(arizona->dev, "Reset GPIO missing/malformed: %d\n", | 805 | GPIOD_OUT_LOW, |
807 | pdata->reset); | 806 | "arizona /RESET"); |
807 | if (IS_ERR(pdata->reset)) { | ||
808 | ret = PTR_ERR(pdata->reset); | ||
808 | 809 | ||
809 | pdata->reset = 0; | 810 | /* |
811 | * Reset missing will be caught when other binding is read | ||
812 | * but all other errors imply this binding is in use but has | ||
813 | * encountered a problem so should be handled. | ||
814 | */ | ||
815 | if (ret == -EPROBE_DEFER) | ||
816 | return ret; | ||
817 | else if (ret != -ENOENT && ret != -ENOSYS) | ||
818 | dev_err(arizona->dev, "Reset GPIO malformed: %d\n", | ||
819 | ret); | ||
820 | |||
821 | pdata->reset = NULL; | ||
810 | } | 822 | } |
811 | 823 | ||
812 | ret = of_property_read_u32_array(arizona->dev->of_node, | 824 | ret = of_property_read_u32_array(arizona->dev->of_node, |
@@ -1050,14 +1062,19 @@ int arizona_dev_init(struct arizona *arizona) | |||
1050 | goto err_early; | 1062 | goto err_early; |
1051 | } | 1063 | } |
1052 | 1064 | ||
1053 | if (arizona->pdata.reset) { | 1065 | if (!arizona->pdata.reset) { |
1054 | /* Start out with /RESET low to put the chip into reset */ | 1066 | /* Start out with /RESET low to put the chip into reset */ |
1055 | ret = devm_gpio_request_one(arizona->dev, arizona->pdata.reset, | 1067 | arizona->pdata.reset = devm_gpiod_get(arizona->dev, "reset", |
1056 | GPIOF_DIR_OUT | GPIOF_INIT_LOW, | 1068 | GPIOD_OUT_LOW); |
1057 | "arizona /RESET"); | 1069 | if (IS_ERR(arizona->pdata.reset)) { |
1058 | if (ret != 0) { | 1070 | ret = PTR_ERR(arizona->pdata.reset); |
1059 | dev_err(dev, "Failed to request /RESET: %d\n", ret); | 1071 | if (ret == -EPROBE_DEFER) |
1060 | goto err_dcvdd; | 1072 | goto err_dcvdd; |
1073 | |||
1074 | dev_err(arizona->dev, | ||
1075 | "Reset GPIO missing/malformed: %d\n", ret); | ||
1076 | |||
1077 | arizona->pdata.reset = NULL; | ||
1061 | } | 1078 | } |
1062 | } | 1079 | } |
1063 | 1080 | ||
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c index cf2e25ab2940..1531302a50ec 100644 --- a/drivers/mfd/asic3.c +++ b/drivers/mfd/asic3.c | |||
@@ -31,6 +31,8 @@ | |||
31 | #include <linux/mfd/ds1wm.h> | 31 | #include <linux/mfd/ds1wm.h> |
32 | #include <linux/mfd/tmio.h> | 32 | #include <linux/mfd/tmio.h> |
33 | 33 | ||
34 | #include <linux/mmc/host.h> | ||
35 | |||
34 | enum { | 36 | enum { |
35 | ASIC3_CLOCK_SPI, | 37 | ASIC3_CLOCK_SPI, |
36 | ASIC3_CLOCK_OWM, | 38 | ASIC3_CLOCK_OWM, |
@@ -719,6 +721,7 @@ static void asic3_mmc_clk_div(struct platform_device *pdev, int state) | |||
719 | 721 | ||
720 | static struct tmio_mmc_data asic3_mmc_data = { | 722 | static struct tmio_mmc_data asic3_mmc_data = { |
721 | .hclk = 24576000, | 723 | .hclk = 24576000, |
724 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, | ||
722 | .set_pwr = asic3_mmc_pwr, | 725 | .set_pwr = asic3_mmc_pwr, |
723 | .set_clk_div = asic3_mmc_clk_div, | 726 | .set_clk_div = asic3_mmc_clk_div, |
724 | }; | 727 | }; |
diff --git a/drivers/mfd/atmel-smc.c b/drivers/mfd/atmel-smc.c index 7d77948567d7..0adbd2e796fe 100644 --- a/drivers/mfd/atmel-smc.c +++ b/drivers/mfd/atmel-smc.c | |||
@@ -12,6 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/mfd/syscon/atmel-smc.h> | 14 | #include <linux/mfd/syscon/atmel-smc.h> |
15 | #include <linux/string.h> | ||
15 | 16 | ||
16 | /** | 17 | /** |
17 | * atmel_smc_cs_conf_init - initialize a SMC CS conf | 18 | * atmel_smc_cs_conf_init - initialize a SMC CS conf |
diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index e94c72c2faa2..9a2ef3d9b8f8 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c | |||
@@ -169,131 +169,61 @@ static const struct regmap_access_table axp806_volatile_table = { | |||
169 | .n_yes_ranges = ARRAY_SIZE(axp806_volatile_ranges), | 169 | .n_yes_ranges = ARRAY_SIZE(axp806_volatile_ranges), |
170 | }; | 170 | }; |
171 | 171 | ||
172 | static struct resource axp152_pek_resources[] = { | 172 | static const struct resource axp152_pek_resources[] = { |
173 | DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_RIS_EDGE, "PEK_DBR"), | 173 | DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_RIS_EDGE, "PEK_DBR"), |
174 | DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_FAL_EDGE, "PEK_DBF"), | 174 | DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_FAL_EDGE, "PEK_DBF"), |
175 | }; | 175 | }; |
176 | 176 | ||
177 | static struct resource axp20x_ac_power_supply_resources[] = { | 177 | static const struct resource axp20x_ac_power_supply_resources[] = { |
178 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_PLUGIN, "ACIN_PLUGIN"), | 178 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_PLUGIN, "ACIN_PLUGIN"), |
179 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_REMOVAL, "ACIN_REMOVAL"), | 179 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_REMOVAL, "ACIN_REMOVAL"), |
180 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_OVER_V, "ACIN_OVER_V"), | 180 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_OVER_V, "ACIN_OVER_V"), |
181 | }; | 181 | }; |
182 | 182 | ||
183 | static struct resource axp20x_pek_resources[] = { | 183 | static const struct resource axp20x_pek_resources[] = { |
184 | { | 184 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_PEK_RIS_EDGE, "PEK_DBR"), |
185 | .name = "PEK_DBR", | 185 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_PEK_FAL_EDGE, "PEK_DBF"), |
186 | .start = AXP20X_IRQ_PEK_RIS_EDGE, | ||
187 | .end = AXP20X_IRQ_PEK_RIS_EDGE, | ||
188 | .flags = IORESOURCE_IRQ, | ||
189 | }, { | ||
190 | .name = "PEK_DBF", | ||
191 | .start = AXP20X_IRQ_PEK_FAL_EDGE, | ||
192 | .end = AXP20X_IRQ_PEK_FAL_EDGE, | ||
193 | .flags = IORESOURCE_IRQ, | ||
194 | }, | ||
195 | }; | 186 | }; |
196 | 187 | ||
197 | static struct resource axp20x_usb_power_supply_resources[] = { | 188 | static const struct resource axp20x_usb_power_supply_resources[] = { |
198 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"), | 189 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"), |
199 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"), | 190 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"), |
200 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_VALID, "VBUS_VALID"), | 191 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_VALID, "VBUS_VALID"), |
201 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_NOT_VALID, "VBUS_NOT_VALID"), | 192 | DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_NOT_VALID, "VBUS_NOT_VALID"), |
202 | }; | 193 | }; |
203 | 194 | ||
204 | static struct resource axp22x_usb_power_supply_resources[] = { | 195 | static const struct resource axp22x_usb_power_supply_resources[] = { |
205 | DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"), | 196 | DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"), |
206 | DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"), | 197 | DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"), |
207 | }; | 198 | }; |
208 | 199 | ||
209 | static struct resource axp22x_pek_resources[] = { | 200 | static const struct resource axp22x_pek_resources[] = { |
210 | { | 201 | DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_PEK_RIS_EDGE, "PEK_DBR"), |
211 | .name = "PEK_DBR", | 202 | DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_PEK_FAL_EDGE, "PEK_DBF"), |
212 | .start = AXP22X_IRQ_PEK_RIS_EDGE, | ||
213 | .end = AXP22X_IRQ_PEK_RIS_EDGE, | ||
214 | .flags = IORESOURCE_IRQ, | ||
215 | }, { | ||
216 | .name = "PEK_DBF", | ||
217 | .start = AXP22X_IRQ_PEK_FAL_EDGE, | ||
218 | .end = AXP22X_IRQ_PEK_FAL_EDGE, | ||
219 | .flags = IORESOURCE_IRQ, | ||
220 | }, | ||
221 | }; | 203 | }; |
222 | 204 | ||
223 | static struct resource axp288_power_button_resources[] = { | 205 | static const struct resource axp288_power_button_resources[] = { |
224 | { | 206 | DEFINE_RES_IRQ_NAMED(AXP288_IRQ_POKP, "PEK_DBR"), |
225 | .name = "PEK_DBR", | 207 | DEFINE_RES_IRQ_NAMED(AXP288_IRQ_POKN, "PEK_DBF"), |
226 | .start = AXP288_IRQ_POKP, | ||
227 | .end = AXP288_IRQ_POKP, | ||
228 | .flags = IORESOURCE_IRQ, | ||
229 | }, | ||
230 | { | ||
231 | .name = "PEK_DBF", | ||
232 | .start = AXP288_IRQ_POKN, | ||
233 | .end = AXP288_IRQ_POKN, | ||
234 | .flags = IORESOURCE_IRQ, | ||
235 | }, | ||
236 | }; | 208 | }; |
237 | 209 | ||
238 | static struct resource axp288_fuel_gauge_resources[] = { | 210 | static const struct resource axp288_fuel_gauge_resources[] = { |
239 | { | 211 | DEFINE_RES_IRQ(AXP288_IRQ_QWBTU), |
240 | .start = AXP288_IRQ_QWBTU, | 212 | DEFINE_RES_IRQ(AXP288_IRQ_WBTU), |
241 | .end = AXP288_IRQ_QWBTU, | 213 | DEFINE_RES_IRQ(AXP288_IRQ_QWBTO), |
242 | .flags = IORESOURCE_IRQ, | 214 | DEFINE_RES_IRQ(AXP288_IRQ_WBTO), |
243 | }, | 215 | DEFINE_RES_IRQ(AXP288_IRQ_WL2), |
244 | { | 216 | DEFINE_RES_IRQ(AXP288_IRQ_WL1), |
245 | .start = AXP288_IRQ_WBTU, | ||
246 | .end = AXP288_IRQ_WBTU, | ||
247 | .flags = IORESOURCE_IRQ, | ||
248 | }, | ||
249 | { | ||
250 | .start = AXP288_IRQ_QWBTO, | ||
251 | .end = AXP288_IRQ_QWBTO, | ||
252 | .flags = IORESOURCE_IRQ, | ||
253 | }, | ||
254 | { | ||
255 | .start = AXP288_IRQ_WBTO, | ||
256 | .end = AXP288_IRQ_WBTO, | ||
257 | .flags = IORESOURCE_IRQ, | ||
258 | }, | ||
259 | { | ||
260 | .start = AXP288_IRQ_WL2, | ||
261 | .end = AXP288_IRQ_WL2, | ||
262 | .flags = IORESOURCE_IRQ, | ||
263 | }, | ||
264 | { | ||
265 | .start = AXP288_IRQ_WL1, | ||
266 | .end = AXP288_IRQ_WL1, | ||
267 | .flags = IORESOURCE_IRQ, | ||
268 | }, | ||
269 | }; | 217 | }; |
270 | 218 | ||
271 | static struct resource axp803_pek_resources[] = { | 219 | static const struct resource axp803_pek_resources[] = { |
272 | { | 220 | DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_RIS_EDGE, "PEK_DBR"), |
273 | .name = "PEK_DBR", | 221 | DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_FAL_EDGE, "PEK_DBF"), |
274 | .start = AXP803_IRQ_PEK_RIS_EDGE, | ||
275 | .end = AXP803_IRQ_PEK_RIS_EDGE, | ||
276 | .flags = IORESOURCE_IRQ, | ||
277 | }, { | ||
278 | .name = "PEK_DBF", | ||
279 | .start = AXP803_IRQ_PEK_FAL_EDGE, | ||
280 | .end = AXP803_IRQ_PEK_FAL_EDGE, | ||
281 | .flags = IORESOURCE_IRQ, | ||
282 | }, | ||
283 | }; | 222 | }; |
284 | 223 | ||
285 | static struct resource axp809_pek_resources[] = { | 224 | static const struct resource axp809_pek_resources[] = { |
286 | { | 225 | DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_RIS_EDGE, "PEK_DBR"), |
287 | .name = "PEK_DBR", | 226 | DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_FAL_EDGE, "PEK_DBF"), |
288 | .start = AXP809_IRQ_PEK_RIS_EDGE, | ||
289 | .end = AXP809_IRQ_PEK_RIS_EDGE, | ||
290 | .flags = IORESOURCE_IRQ, | ||
291 | }, { | ||
292 | .name = "PEK_DBF", | ||
293 | .start = AXP809_IRQ_PEK_FAL_EDGE, | ||
294 | .end = AXP809_IRQ_PEK_FAL_EDGE, | ||
295 | .flags = IORESOURCE_IRQ, | ||
296 | }, | ||
297 | }; | 227 | }; |
298 | 228 | ||
299 | static const struct regmap_config axp152_regmap_config = { | 229 | static const struct regmap_config axp152_regmap_config = { |
@@ -520,11 +450,11 @@ static const struct regmap_irq axp806_regmap_irqs[] = { | |||
520 | INIT_REGMAP_IRQ(AXP806, DCDCC_V_LOW, 0, 5), | 450 | INIT_REGMAP_IRQ(AXP806, DCDCC_V_LOW, 0, 5), |
521 | INIT_REGMAP_IRQ(AXP806, DCDCD_V_LOW, 0, 6), | 451 | INIT_REGMAP_IRQ(AXP806, DCDCD_V_LOW, 0, 6), |
522 | INIT_REGMAP_IRQ(AXP806, DCDCE_V_LOW, 0, 7), | 452 | INIT_REGMAP_IRQ(AXP806, DCDCE_V_LOW, 0, 7), |
523 | INIT_REGMAP_IRQ(AXP806, PWROK_LONG, 1, 0), | 453 | INIT_REGMAP_IRQ(AXP806, POK_LONG, 1, 0), |
524 | INIT_REGMAP_IRQ(AXP806, PWROK_SHORT, 1, 1), | 454 | INIT_REGMAP_IRQ(AXP806, POK_SHORT, 1, 1), |
525 | INIT_REGMAP_IRQ(AXP806, WAKEUP, 1, 4), | 455 | INIT_REGMAP_IRQ(AXP806, WAKEUP, 1, 4), |
526 | INIT_REGMAP_IRQ(AXP806, PWROK_FALL, 1, 5), | 456 | INIT_REGMAP_IRQ(AXP806, POK_FALL, 1, 5), |
527 | INIT_REGMAP_IRQ(AXP806, PWROK_RISE, 1, 6), | 457 | INIT_REGMAP_IRQ(AXP806, POK_RISE, 1, 6), |
528 | }; | 458 | }; |
529 | 459 | ||
530 | static const struct regmap_irq axp809_regmap_irqs[] = { | 460 | static const struct regmap_irq axp809_regmap_irqs[] = { |
@@ -648,7 +578,7 @@ static const struct regmap_irq_chip axp809_regmap_irq_chip = { | |||
648 | .num_regs = 5, | 578 | .num_regs = 5, |
649 | }; | 579 | }; |
650 | 580 | ||
651 | static struct mfd_cell axp20x_cells[] = { | 581 | static const struct mfd_cell axp20x_cells[] = { |
652 | { | 582 | { |
653 | .name = "axp20x-gpio", | 583 | .name = "axp20x-gpio", |
654 | .of_compatible = "x-powers,axp209-gpio", | 584 | .of_compatible = "x-powers,axp209-gpio", |
@@ -660,6 +590,7 @@ static struct mfd_cell axp20x_cells[] = { | |||
660 | .name = "axp20x-regulator", | 590 | .name = "axp20x-regulator", |
661 | }, { | 591 | }, { |
662 | .name = "axp20x-adc", | 592 | .name = "axp20x-adc", |
593 | .of_compatible = "x-powers,axp209-adc", | ||
663 | }, { | 594 | }, { |
664 | .name = "axp20x-battery-power-supply", | 595 | .name = "axp20x-battery-power-supply", |
665 | .of_compatible = "x-powers,axp209-battery-power-supply", | 596 | .of_compatible = "x-powers,axp209-battery-power-supply", |
@@ -676,7 +607,7 @@ static struct mfd_cell axp20x_cells[] = { | |||
676 | }, | 607 | }, |
677 | }; | 608 | }; |
678 | 609 | ||
679 | static struct mfd_cell axp221_cells[] = { | 610 | static const struct mfd_cell axp221_cells[] = { |
680 | { | 611 | { |
681 | .name = "axp221-pek", | 612 | .name = "axp221-pek", |
682 | .num_resources = ARRAY_SIZE(axp22x_pek_resources), | 613 | .num_resources = ARRAY_SIZE(axp22x_pek_resources), |
@@ -684,7 +615,8 @@ static struct mfd_cell axp221_cells[] = { | |||
684 | }, { | 615 | }, { |
685 | .name = "axp20x-regulator", | 616 | .name = "axp20x-regulator", |
686 | }, { | 617 | }, { |
687 | .name = "axp22x-adc" | 618 | .name = "axp22x-adc", |
619 | .of_compatible = "x-powers,axp221-adc", | ||
688 | }, { | 620 | }, { |
689 | .name = "axp20x-ac-power-supply", | 621 | .name = "axp20x-ac-power-supply", |
690 | .of_compatible = "x-powers,axp221-ac-power-supply", | 622 | .of_compatible = "x-powers,axp221-ac-power-supply", |
@@ -701,13 +633,14 @@ static struct mfd_cell axp221_cells[] = { | |||
701 | }, | 633 | }, |
702 | }; | 634 | }; |
703 | 635 | ||
704 | static struct mfd_cell axp223_cells[] = { | 636 | static const struct mfd_cell axp223_cells[] = { |
705 | { | 637 | { |
706 | .name = "axp221-pek", | 638 | .name = "axp221-pek", |
707 | .num_resources = ARRAY_SIZE(axp22x_pek_resources), | 639 | .num_resources = ARRAY_SIZE(axp22x_pek_resources), |
708 | .resources = axp22x_pek_resources, | 640 | .resources = axp22x_pek_resources, |
709 | }, { | 641 | }, { |
710 | .name = "axp22x-adc", | 642 | .name = "axp22x-adc", |
643 | .of_compatible = "x-powers,axp221-adc", | ||
711 | }, { | 644 | }, { |
712 | .name = "axp20x-battery-power-supply", | 645 | .name = "axp20x-battery-power-supply", |
713 | .of_compatible = "x-powers,axp221-battery-power-supply", | 646 | .of_compatible = "x-powers,axp221-battery-power-supply", |
@@ -726,7 +659,7 @@ static struct mfd_cell axp223_cells[] = { | |||
726 | }, | 659 | }, |
727 | }; | 660 | }; |
728 | 661 | ||
729 | static struct mfd_cell axp152_cells[] = { | 662 | static const struct mfd_cell axp152_cells[] = { |
730 | { | 663 | { |
731 | .name = "axp20x-pek", | 664 | .name = "axp20x-pek", |
732 | .num_resources = ARRAY_SIZE(axp152_pek_resources), | 665 | .num_resources = ARRAY_SIZE(axp152_pek_resources), |
@@ -734,87 +667,30 @@ static struct mfd_cell axp152_cells[] = { | |||
734 | }, | 667 | }, |
735 | }; | 668 | }; |
736 | 669 | ||
737 | static struct resource axp288_adc_resources[] = { | 670 | static const struct resource axp288_adc_resources[] = { |
738 | { | 671 | DEFINE_RES_IRQ_NAMED(AXP288_IRQ_GPADC, "GPADC"), |
739 | .name = "GPADC", | ||
740 | .start = AXP288_IRQ_GPADC, | ||
741 | .end = AXP288_IRQ_GPADC, | ||
742 | .flags = IORESOURCE_IRQ, | ||
743 | }, | ||
744 | }; | 672 | }; |
745 | 673 | ||
746 | static struct resource axp288_extcon_resources[] = { | 674 | static const struct resource axp288_extcon_resources[] = { |
747 | { | 675 | DEFINE_RES_IRQ(AXP288_IRQ_VBUS_FALL), |
748 | .start = AXP288_IRQ_VBUS_FALL, | 676 | DEFINE_RES_IRQ(AXP288_IRQ_VBUS_RISE), |
749 | .end = AXP288_IRQ_VBUS_FALL, | 677 | DEFINE_RES_IRQ(AXP288_IRQ_MV_CHNG), |
750 | .flags = IORESOURCE_IRQ, | 678 | DEFINE_RES_IRQ(AXP288_IRQ_BC_USB_CHNG), |
751 | }, | ||
752 | { | ||
753 | .start = AXP288_IRQ_VBUS_RISE, | ||
754 | .end = AXP288_IRQ_VBUS_RISE, | ||
755 | .flags = IORESOURCE_IRQ, | ||
756 | }, | ||
757 | { | ||
758 | .start = AXP288_IRQ_MV_CHNG, | ||
759 | .end = AXP288_IRQ_MV_CHNG, | ||
760 | .flags = IORESOURCE_IRQ, | ||
761 | }, | ||
762 | { | ||
763 | .start = AXP288_IRQ_BC_USB_CHNG, | ||
764 | .end = AXP288_IRQ_BC_USB_CHNG, | ||
765 | .flags = IORESOURCE_IRQ, | ||
766 | }, | ||
767 | }; | 679 | }; |
768 | 680 | ||
769 | static struct resource axp288_charger_resources[] = { | 681 | static const struct resource axp288_charger_resources[] = { |
770 | { | 682 | DEFINE_RES_IRQ(AXP288_IRQ_OV), |
771 | .start = AXP288_IRQ_OV, | 683 | DEFINE_RES_IRQ(AXP288_IRQ_DONE), |
772 | .end = AXP288_IRQ_OV, | 684 | DEFINE_RES_IRQ(AXP288_IRQ_CHARGING), |
773 | .flags = IORESOURCE_IRQ, | 685 | DEFINE_RES_IRQ(AXP288_IRQ_SAFE_QUIT), |
774 | }, | 686 | DEFINE_RES_IRQ(AXP288_IRQ_SAFE_ENTER), |
775 | { | 687 | DEFINE_RES_IRQ(AXP288_IRQ_QCBTU), |
776 | .start = AXP288_IRQ_DONE, | 688 | DEFINE_RES_IRQ(AXP288_IRQ_CBTU), |
777 | .end = AXP288_IRQ_DONE, | 689 | DEFINE_RES_IRQ(AXP288_IRQ_QCBTO), |
778 | .flags = IORESOURCE_IRQ, | 690 | DEFINE_RES_IRQ(AXP288_IRQ_CBTO), |
779 | }, | ||
780 | { | ||
781 | .start = AXP288_IRQ_CHARGING, | ||
782 | .end = AXP288_IRQ_CHARGING, | ||
783 | .flags = IORESOURCE_IRQ, | ||
784 | }, | ||
785 | { | ||
786 | .start = AXP288_IRQ_SAFE_QUIT, | ||
787 | .end = AXP288_IRQ_SAFE_QUIT, | ||
788 | .flags = IORESOURCE_IRQ, | ||
789 | }, | ||
790 | { | ||
791 | .start = AXP288_IRQ_SAFE_ENTER, | ||
792 | .end = AXP288_IRQ_SAFE_ENTER, | ||
793 | .flags = IORESOURCE_IRQ, | ||
794 | }, | ||
795 | { | ||
796 | .start = AXP288_IRQ_QCBTU, | ||
797 | .end = AXP288_IRQ_QCBTU, | ||
798 | .flags = IORESOURCE_IRQ, | ||
799 | }, | ||
800 | { | ||
801 | .start = AXP288_IRQ_CBTU, | ||
802 | .end = AXP288_IRQ_CBTU, | ||
803 | .flags = IORESOURCE_IRQ, | ||
804 | }, | ||
805 | { | ||
806 | .start = AXP288_IRQ_QCBTO, | ||
807 | .end = AXP288_IRQ_QCBTO, | ||
808 | .flags = IORESOURCE_IRQ, | ||
809 | }, | ||
810 | { | ||
811 | .start = AXP288_IRQ_CBTO, | ||
812 | .end = AXP288_IRQ_CBTO, | ||
813 | .flags = IORESOURCE_IRQ, | ||
814 | }, | ||
815 | }; | 691 | }; |
816 | 692 | ||
817 | static struct mfd_cell axp288_cells[] = { | 693 | static const struct mfd_cell axp288_cells[] = { |
818 | { | 694 | { |
819 | .name = "axp288_adc", | 695 | .name = "axp288_adc", |
820 | .num_resources = ARRAY_SIZE(axp288_adc_resources), | 696 | .num_resources = ARRAY_SIZE(axp288_adc_resources), |
@@ -845,7 +721,7 @@ static struct mfd_cell axp288_cells[] = { | |||
845 | }, | 721 | }, |
846 | }; | 722 | }; |
847 | 723 | ||
848 | static struct mfd_cell axp803_cells[] = { | 724 | static const struct mfd_cell axp803_cells[] = { |
849 | { | 725 | { |
850 | .name = "axp221-pek", | 726 | .name = "axp221-pek", |
851 | .num_resources = ARRAY_SIZE(axp803_pek_resources), | 727 | .num_resources = ARRAY_SIZE(axp803_pek_resources), |
@@ -854,14 +730,14 @@ static struct mfd_cell axp803_cells[] = { | |||
854 | { .name = "axp20x-regulator" }, | 730 | { .name = "axp20x-regulator" }, |
855 | }; | 731 | }; |
856 | 732 | ||
857 | static struct mfd_cell axp806_cells[] = { | 733 | static const struct mfd_cell axp806_cells[] = { |
858 | { | 734 | { |
859 | .id = 2, | 735 | .id = 2, |
860 | .name = "axp20x-regulator", | 736 | .name = "axp20x-regulator", |
861 | }, | 737 | }, |
862 | }; | 738 | }; |
863 | 739 | ||
864 | static struct mfd_cell axp809_cells[] = { | 740 | static const struct mfd_cell axp809_cells[] = { |
865 | { | 741 | { |
866 | .name = "axp221-pek", | 742 | .name = "axp221-pek", |
867 | .num_resources = ARRAY_SIZE(axp809_pek_resources), | 743 | .num_resources = ARRAY_SIZE(axp809_pek_resources), |
@@ -872,7 +748,7 @@ static struct mfd_cell axp809_cells[] = { | |||
872 | }, | 748 | }, |
873 | }; | 749 | }; |
874 | 750 | ||
875 | static struct mfd_cell axp813_cells[] = { | 751 | static const struct mfd_cell axp813_cells[] = { |
876 | { | 752 | { |
877 | .name = "axp221-pek", | 753 | .name = "axp221-pek", |
878 | .num_resources = ARRAY_SIZE(axp803_pek_resources), | 754 | .num_resources = ARRAY_SIZE(axp803_pek_resources), |
@@ -882,7 +758,13 @@ static struct mfd_cell axp813_cells[] = { | |||
882 | }, { | 758 | }, { |
883 | .name = "axp20x-gpio", | 759 | .name = "axp20x-gpio", |
884 | .of_compatible = "x-powers,axp813-gpio", | 760 | .of_compatible = "x-powers,axp813-gpio", |
885 | } | 761 | }, { |
762 | .name = "axp813-adc", | ||
763 | .of_compatible = "x-powers,axp813-adc", | ||
764 | }, { | ||
765 | .name = "axp20x-battery-power-supply", | ||
766 | .of_compatible = "x-powers,axp813-battery-power-supply", | ||
767 | }, | ||
886 | }; | 768 | }; |
887 | 769 | ||
888 | static struct axp20x_dev *axp20x_pm_power_off; | 770 | static struct axp20x_dev *axp20x_pm_power_off; |
diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index 36156a41499c..65a9757a6d21 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c | |||
@@ -112,12 +112,16 @@ int cros_ec_register(struct cros_ec_device *ec_dev) | |||
112 | 112 | ||
113 | mutex_init(&ec_dev->lock); | 113 | mutex_init(&ec_dev->lock); |
114 | 114 | ||
115 | cros_ec_query_all(ec_dev); | 115 | err = cros_ec_query_all(ec_dev); |
116 | if (err) { | ||
117 | dev_err(dev, "Cannot identify the EC: error %d\n", err); | ||
118 | return err; | ||
119 | } | ||
116 | 120 | ||
117 | if (ec_dev->irq) { | 121 | if (ec_dev->irq) { |
118 | err = request_threaded_irq(ec_dev->irq, NULL, ec_irq_thread, | 122 | err = devm_request_threaded_irq(dev, ec_dev->irq, NULL, |
119 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | 123 | ec_irq_thread, IRQF_TRIGGER_LOW | IRQF_ONESHOT, |
120 | "chromeos-ec", ec_dev); | 124 | "chromeos-ec", ec_dev); |
121 | if (err) { | 125 | if (err) { |
122 | dev_err(dev, "Failed to request IRQ %d: %d", | 126 | dev_err(dev, "Failed to request IRQ %d: %d", |
123 | ec_dev->irq, err); | 127 | ec_dev->irq, err); |
@@ -131,7 +135,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev) | |||
131 | dev_err(dev, | 135 | dev_err(dev, |
132 | "Failed to register Embedded Controller subdevice %d\n", | 136 | "Failed to register Embedded Controller subdevice %d\n", |
133 | err); | 137 | err); |
134 | goto fail_mfd; | 138 | return err; |
135 | } | 139 | } |
136 | 140 | ||
137 | if (ec_dev->max_passthru) { | 141 | if (ec_dev->max_passthru) { |
@@ -149,7 +153,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev) | |||
149 | dev_err(dev, | 153 | dev_err(dev, |
150 | "Failed to register Power Delivery subdevice %d\n", | 154 | "Failed to register Power Delivery subdevice %d\n", |
151 | err); | 155 | err); |
152 | goto fail_mfd; | 156 | return err; |
153 | } | 157 | } |
154 | } | 158 | } |
155 | 159 | ||
@@ -158,7 +162,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev) | |||
158 | if (err) { | 162 | if (err) { |
159 | mfd_remove_devices(dev); | 163 | mfd_remove_devices(dev); |
160 | dev_err(dev, "Failed to register sub-devices\n"); | 164 | dev_err(dev, "Failed to register sub-devices\n"); |
161 | goto fail_mfd; | 165 | return err; |
162 | } | 166 | } |
163 | } | 167 | } |
164 | 168 | ||
@@ -173,14 +177,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev) | |||
173 | 177 | ||
174 | dev_info(dev, "Chrome EC device registered\n"); | 178 | dev_info(dev, "Chrome EC device registered\n"); |
175 | 179 | ||
176 | cros_ec_acpi_install_gpe_handler(dev); | ||
177 | |||
178 | return 0; | 180 | return 0; |
179 | |||
180 | fail_mfd: | ||
181 | if (ec_dev->irq) | ||
182 | free_irq(ec_dev->irq, ec_dev); | ||
183 | return err; | ||
184 | } | 181 | } |
185 | EXPORT_SYMBOL(cros_ec_register); | 182 | EXPORT_SYMBOL(cros_ec_register); |
186 | 183 | ||
@@ -188,11 +185,6 @@ int cros_ec_remove(struct cros_ec_device *ec_dev) | |||
188 | { | 185 | { |
189 | mfd_remove_devices(ec_dev->dev); | 186 | mfd_remove_devices(ec_dev->dev); |
190 | 187 | ||
191 | cros_ec_acpi_remove_gpe_handler(); | ||
192 | |||
193 | if (ec_dev->irq) | ||
194 | free_irq(ec_dev->irq, ec_dev); | ||
195 | |||
196 | return 0; | 188 | return 0; |
197 | } | 189 | } |
198 | EXPORT_SYMBOL(cros_ec_remove); | 190 | EXPORT_SYMBOL(cros_ec_remove); |
@@ -204,14 +196,9 @@ int cros_ec_suspend(struct cros_ec_device *ec_dev) | |||
204 | int ret; | 196 | int ret; |
205 | u8 sleep_event; | 197 | u8 sleep_event; |
206 | 198 | ||
207 | if (!IS_ENABLED(CONFIG_ACPI) || pm_suspend_via_firmware()) { | 199 | sleep_event = (!IS_ENABLED(CONFIG_ACPI) || pm_suspend_via_firmware()) ? |
208 | sleep_event = HOST_SLEEP_EVENT_S3_SUSPEND; | 200 | HOST_SLEEP_EVENT_S3_SUSPEND : |
209 | } else { | 201 | HOST_SLEEP_EVENT_S0IX_SUSPEND; |
210 | sleep_event = HOST_SLEEP_EVENT_S0IX_SUSPEND; | ||
211 | |||
212 | /* Clearing the GPE status for any pending event */ | ||
213 | cros_ec_acpi_clear_gpe(); | ||
214 | } | ||
215 | 202 | ||
216 | ret = cros_ec_sleep_event(ec_dev, sleep_event); | 203 | ret = cros_ec_sleep_event(ec_dev, sleep_event); |
217 | if (ret < 0) | 204 | if (ret < 0) |
diff --git a/drivers/mfd/cros_ec_acpi_gpe.c b/drivers/mfd/cros_ec_acpi_gpe.c deleted file mode 100644 index 56d305dab2d4..000000000000 --- a/drivers/mfd/cros_ec_acpi_gpe.c +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | /* | ||
2 | * ChromeOS EC multi-function device | ||
3 | * | ||
4 | * Copyright (C) 2017 Google, Inc | ||
5 | * | ||
6 | * This software is licensed under the terms of the GNU General Public | ||
7 | * License version 2, as published by the Free Software Foundation, and | ||
8 | * may be copied, distributed, and modified under those terms. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * The ChromeOS EC multi function device is used to mux all the requests | ||
16 | * to the EC device for its multiple features: keyboard controller, | ||
17 | * battery charging and regulator control, firmware update. | ||
18 | */ | ||
19 | #include <linux/acpi.h> | ||
20 | |||
21 | #define ACPI_LID_DEVICE "LID0" | ||
22 | |||
23 | static int ec_wake_gpe = -EINVAL; | ||
24 | |||
25 | /* | ||
26 | * This handler indicates to ACPI core that this GPE should stay enabled for | ||
27 | * lid to work in suspend to idle path. | ||
28 | */ | ||
29 | static u32 cros_ec_gpe_handler(acpi_handle gpe_device, u32 gpe_number, | ||
30 | void *data) | ||
31 | { | ||
32 | return ACPI_INTERRUPT_HANDLED | ACPI_REENABLE_GPE; | ||
33 | } | ||
34 | |||
35 | /* | ||
36 | * Get ACPI GPE for LID0 device. | ||
37 | */ | ||
38 | static int cros_ec_get_ec_wake_gpe(struct device *dev) | ||
39 | { | ||
40 | struct acpi_device *cros_acpi_dev; | ||
41 | struct acpi_device *adev; | ||
42 | acpi_handle handle; | ||
43 | acpi_status status; | ||
44 | int ret; | ||
45 | |||
46 | cros_acpi_dev = ACPI_COMPANION(dev); | ||
47 | |||
48 | if (!cros_acpi_dev || !cros_acpi_dev->parent || | ||
49 | !cros_acpi_dev->parent->handle) | ||
50 | return -EINVAL; | ||
51 | |||
52 | status = acpi_get_handle(cros_acpi_dev->parent->handle, ACPI_LID_DEVICE, | ||
53 | &handle); | ||
54 | if (ACPI_FAILURE(status)) | ||
55 | return -EINVAL; | ||
56 | |||
57 | ret = acpi_bus_get_device(handle, &adev); | ||
58 | if (ret) | ||
59 | return ret; | ||
60 | |||
61 | return adev->wakeup.gpe_number; | ||
62 | } | ||
63 | |||
64 | int cros_ec_acpi_install_gpe_handler(struct device *dev) | ||
65 | { | ||
66 | acpi_status status; | ||
67 | |||
68 | ec_wake_gpe = cros_ec_get_ec_wake_gpe(dev); | ||
69 | |||
70 | if (ec_wake_gpe < 0) | ||
71 | return ec_wake_gpe; | ||
72 | |||
73 | status = acpi_install_gpe_handler(NULL, ec_wake_gpe, | ||
74 | ACPI_GPE_EDGE_TRIGGERED, | ||
75 | &cros_ec_gpe_handler, NULL); | ||
76 | if (ACPI_FAILURE(status)) | ||
77 | return -ENODEV; | ||
78 | |||
79 | dev_info(dev, "Initialized, GPE = 0x%x\n", ec_wake_gpe); | ||
80 | |||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | void cros_ec_acpi_remove_gpe_handler(void) | ||
85 | { | ||
86 | acpi_status status; | ||
87 | |||
88 | if (ec_wake_gpe < 0) | ||
89 | return; | ||
90 | |||
91 | status = acpi_remove_gpe_handler(NULL, ec_wake_gpe, | ||
92 | &cros_ec_gpe_handler); | ||
93 | if (ACPI_FAILURE(status)) | ||
94 | pr_err("failed to remove gpe handler\n"); | ||
95 | } | ||
96 | |||
97 | void cros_ec_acpi_clear_gpe(void) | ||
98 | { | ||
99 | if (ec_wake_gpe < 0) | ||
100 | return; | ||
101 | |||
102 | acpi_clear_gpe(NULL, ec_wake_gpe); | ||
103 | } | ||
diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index eafd06f62a3a..4199cdd4ff89 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c | |||
@@ -113,10 +113,10 @@ static int cros_ec_check_features(struct cros_ec_dev *ec, int feature) | |||
113 | dev_warn(ec->dev, "cannot get EC features: %d/%d\n", | 113 | dev_warn(ec->dev, "cannot get EC features: %d/%d\n", |
114 | ret, msg->result); | 114 | ret, msg->result); |
115 | memset(ec->features, 0, sizeof(ec->features)); | 115 | memset(ec->features, 0, sizeof(ec->features)); |
116 | } else { | ||
117 | memcpy(ec->features, msg->data, sizeof(ec->features)); | ||
116 | } | 118 | } |
117 | 119 | ||
118 | memcpy(ec->features, msg->data, sizeof(ec->features)); | ||
119 | |||
120 | dev_dbg(ec->dev, "EC features %08x %08x\n", | 120 | dev_dbg(ec->dev, "EC features %08x %08x\n", |
121 | ec->features[0], ec->features[1]); | 121 | ec->features[0], ec->features[1]); |
122 | 122 | ||
@@ -262,13 +262,6 @@ static const struct file_operations fops = { | |||
262 | #endif | 262 | #endif |
263 | }; | 263 | }; |
264 | 264 | ||
265 | static void __remove(struct device *dev) | ||
266 | { | ||
267 | struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev, | ||
268 | class_dev); | ||
269 | kfree(ec); | ||
270 | } | ||
271 | |||
272 | static void cros_ec_sensors_register(struct cros_ec_dev *ec) | 265 | static void cros_ec_sensors_register(struct cros_ec_dev *ec) |
273 | { | 266 | { |
274 | /* | 267 | /* |
@@ -383,12 +376,16 @@ error: | |||
383 | kfree(msg); | 376 | kfree(msg); |
384 | } | 377 | } |
385 | 378 | ||
379 | static const struct mfd_cell cros_ec_rtc_cells[] = { | ||
380 | { .name = "cros-ec-rtc" } | ||
381 | }; | ||
382 | |||
386 | static int ec_device_probe(struct platform_device *pdev) | 383 | static int ec_device_probe(struct platform_device *pdev) |
387 | { | 384 | { |
388 | int retval = -ENOMEM; | 385 | int retval = -ENOMEM; |
389 | struct device *dev = &pdev->dev; | 386 | struct device *dev = &pdev->dev; |
390 | struct cros_ec_platform *ec_platform = dev_get_platdata(dev); | 387 | struct cros_ec_platform *ec_platform = dev_get_platdata(dev); |
391 | struct cros_ec_dev *ec = kzalloc(sizeof(*ec), GFP_KERNEL); | 388 | struct cros_ec_dev *ec = devm_kzalloc(dev, sizeof(*ec), GFP_KERNEL); |
392 | 389 | ||
393 | if (!ec) | 390 | if (!ec) |
394 | return retval; | 391 | return retval; |
@@ -410,7 +407,6 @@ static int ec_device_probe(struct platform_device *pdev) | |||
410 | ec->class_dev.devt = MKDEV(ec_major, pdev->id); | 407 | ec->class_dev.devt = MKDEV(ec_major, pdev->id); |
411 | ec->class_dev.class = &cros_class; | 408 | ec->class_dev.class = &cros_class; |
412 | ec->class_dev.parent = dev; | 409 | ec->class_dev.parent = dev; |
413 | ec->class_dev.release = __remove; | ||
414 | 410 | ||
415 | retval = dev_set_name(&ec->class_dev, "%s", ec_platform->ec_name); | 411 | retval = dev_set_name(&ec->class_dev, "%s", ec_platform->ec_name); |
416 | if (retval) { | 412 | if (retval) { |
@@ -422,6 +418,18 @@ static int ec_device_probe(struct platform_device *pdev) | |||
422 | if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE)) | 418 | if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE)) |
423 | cros_ec_sensors_register(ec); | 419 | cros_ec_sensors_register(ec); |
424 | 420 | ||
421 | /* Check whether this EC instance has RTC host command support */ | ||
422 | if (cros_ec_check_features(ec, EC_FEATURE_RTC)) { | ||
423 | retval = mfd_add_devices(ec->dev, PLATFORM_DEVID_AUTO, | ||
424 | cros_ec_rtc_cells, | ||
425 | ARRAY_SIZE(cros_ec_rtc_cells), | ||
426 | NULL, 0, NULL); | ||
427 | if (retval) | ||
428 | dev_err(ec->dev, | ||
429 | "failed to add cros-ec-rtc device: %d\n", | ||
430 | retval); | ||
431 | } | ||
432 | |||
425 | /* Take control of the lightbar from the EC. */ | 433 | /* Take control of the lightbar from the EC. */ |
426 | lb_manual_suspend_ctrl(ec, 1); | 434 | lb_manual_suspend_ctrl(ec, 1); |
427 | 435 | ||
@@ -456,9 +464,17 @@ static int ec_device_remove(struct platform_device *pdev) | |||
456 | return 0; | 464 | return 0; |
457 | } | 465 | } |
458 | 466 | ||
467 | static void ec_device_shutdown(struct platform_device *pdev) | ||
468 | { | ||
469 | struct cros_ec_dev *ec = dev_get_drvdata(&pdev->dev); | ||
470 | |||
471 | /* Be sure to clear up debugfs delayed works */ | ||
472 | cros_ec_debugfs_remove(ec); | ||
473 | } | ||
474 | |||
459 | static const struct platform_device_id cros_ec_id[] = { | 475 | static const struct platform_device_id cros_ec_id[] = { |
460 | { DRV_NAME, 0 }, | 476 | { DRV_NAME, 0 }, |
461 | { /* sentinel */ }, | 477 | { /* sentinel */ } |
462 | }; | 478 | }; |
463 | MODULE_DEVICE_TABLE(platform, cros_ec_id); | 479 | MODULE_DEVICE_TABLE(platform, cros_ec_id); |
464 | 480 | ||
@@ -466,6 +482,8 @@ static __maybe_unused int ec_device_suspend(struct device *dev) | |||
466 | { | 482 | { |
467 | struct cros_ec_dev *ec = dev_get_drvdata(dev); | 483 | struct cros_ec_dev *ec = dev_get_drvdata(dev); |
468 | 484 | ||
485 | cros_ec_debugfs_suspend(ec); | ||
486 | |||
469 | lb_suspend(ec); | 487 | lb_suspend(ec); |
470 | 488 | ||
471 | return 0; | 489 | return 0; |
@@ -475,6 +493,8 @@ static __maybe_unused int ec_device_resume(struct device *dev) | |||
475 | { | 493 | { |
476 | struct cros_ec_dev *ec = dev_get_drvdata(dev); | 494 | struct cros_ec_dev *ec = dev_get_drvdata(dev); |
477 | 495 | ||
496 | cros_ec_debugfs_resume(ec); | ||
497 | |||
478 | lb_resume(ec); | 498 | lb_resume(ec); |
479 | 499 | ||
480 | return 0; | 500 | return 0; |
@@ -494,6 +514,7 @@ static struct platform_driver cros_ec_dev_driver = { | |||
494 | }, | 514 | }, |
495 | .probe = ec_device_probe, | 515 | .probe = ec_device_probe, |
496 | .remove = ec_device_remove, | 516 | .remove = ec_device_remove, |
517 | .shutdown = ec_device_shutdown, | ||
497 | }; | 518 | }; |
498 | 519 | ||
499 | static int __init cros_ec_dev_init(void) | 520 | static int __init cros_ec_dev_init(void) |
diff --git a/drivers/mfd/cros_ec_i2c.c b/drivers/mfd/cros_ec_i2c.c index 9f70de1e4c70..ef9b4763356f 100644 --- a/drivers/mfd/cros_ec_i2c.c +++ b/drivers/mfd/cros_ec_i2c.c | |||
@@ -13,6 +13,7 @@ | |||
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/acpi.h> | ||
16 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
17 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
18 | #include <linux/module.h> | 19 | #include <linux/module.h> |
@@ -341,14 +342,17 @@ static int cros_ec_i2c_resume(struct device *dev) | |||
341 | } | 342 | } |
342 | #endif | 343 | #endif |
343 | 344 | ||
344 | static SIMPLE_DEV_PM_OPS(cros_ec_i2c_pm_ops, cros_ec_i2c_suspend, | 345 | static const struct dev_pm_ops cros_ec_i2c_pm_ops = { |
345 | cros_ec_i2c_resume); | 346 | SET_LATE_SYSTEM_SLEEP_PM_OPS(cros_ec_i2c_suspend, cros_ec_i2c_resume) |
347 | }; | ||
346 | 348 | ||
349 | #ifdef CONFIG_OF | ||
347 | static const struct of_device_id cros_ec_i2c_of_match[] = { | 350 | static const struct of_device_id cros_ec_i2c_of_match[] = { |
348 | { .compatible = "google,cros-ec-i2c", }, | 351 | { .compatible = "google,cros-ec-i2c", }, |
349 | { /* sentinel */ }, | 352 | { /* sentinel */ }, |
350 | }; | 353 | }; |
351 | MODULE_DEVICE_TABLE(of, cros_ec_i2c_of_match); | 354 | MODULE_DEVICE_TABLE(of, cros_ec_i2c_of_match); |
355 | #endif | ||
352 | 356 | ||
353 | static const struct i2c_device_id cros_ec_i2c_id[] = { | 357 | static const struct i2c_device_id cros_ec_i2c_id[] = { |
354 | { "cros-ec-i2c", 0 }, | 358 | { "cros-ec-i2c", 0 }, |
@@ -356,9 +360,18 @@ static const struct i2c_device_id cros_ec_i2c_id[] = { | |||
356 | }; | 360 | }; |
357 | MODULE_DEVICE_TABLE(i2c, cros_ec_i2c_id); | 361 | MODULE_DEVICE_TABLE(i2c, cros_ec_i2c_id); |
358 | 362 | ||
363 | #ifdef CONFIG_ACPI | ||
364 | static const struct acpi_device_id cros_ec_i2c_acpi_id[] = { | ||
365 | { "GOOG0008", 0 }, | ||
366 | { /* sentinel */ } | ||
367 | }; | ||
368 | MODULE_DEVICE_TABLE(acpi, cros_ec_i2c_acpi_id); | ||
369 | #endif | ||
370 | |||
359 | static struct i2c_driver cros_ec_driver = { | 371 | static struct i2c_driver cros_ec_driver = { |
360 | .driver = { | 372 | .driver = { |
361 | .name = "cros-ec-i2c", | 373 | .name = "cros-ec-i2c", |
374 | .acpi_match_table = ACPI_PTR(cros_ec_i2c_acpi_id), | ||
362 | .of_match_table = of_match_ptr(cros_ec_i2c_of_match), | 375 | .of_match_table = of_match_ptr(cros_ec_i2c_of_match), |
363 | .pm = &cros_ec_i2c_pm_ops, | 376 | .pm = &cros_ec_i2c_pm_ops, |
364 | }, | 377 | }, |
diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c index fe1811523e4a..9f6105906c09 100644 --- a/drivers/mfd/da9062-core.c +++ b/drivers/mfd/da9062-core.c | |||
@@ -365,186 +365,69 @@ static int da9062_get_device_type(struct da9062 *chip) | |||
365 | } | 365 | } |
366 | 366 | ||
367 | static const struct regmap_range da9061_aa_readable_ranges[] = { | 367 | static const struct regmap_range da9061_aa_readable_ranges[] = { |
368 | { | 368 | regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_STATUS_B), |
369 | .range_min = DA9062AA_PAGE_CON, | 369 | regmap_reg_range(DA9062AA_STATUS_D, DA9062AA_EVENT_C), |
370 | .range_max = DA9062AA_STATUS_B, | 370 | regmap_reg_range(DA9062AA_IRQ_MASK_A, DA9062AA_IRQ_MASK_C), |
371 | }, { | 371 | regmap_reg_range(DA9062AA_CONTROL_A, DA9062AA_GPIO_4), |
372 | .range_min = DA9062AA_STATUS_D, | 372 | regmap_reg_range(DA9062AA_GPIO_WKUP_MODE, DA9062AA_GPIO_OUT3_4), |
373 | .range_max = DA9062AA_EVENT_C, | 373 | regmap_reg_range(DA9062AA_BUCK1_CONT, DA9062AA_BUCK4_CONT), |
374 | }, { | 374 | regmap_reg_range(DA9062AA_BUCK3_CONT, DA9062AA_BUCK3_CONT), |
375 | .range_min = DA9062AA_IRQ_MASK_A, | 375 | regmap_reg_range(DA9062AA_LDO1_CONT, DA9062AA_LDO4_CONT), |
376 | .range_max = DA9062AA_IRQ_MASK_C, | 376 | regmap_reg_range(DA9062AA_DVC_1, DA9062AA_DVC_1), |
377 | }, { | 377 | regmap_reg_range(DA9062AA_SEQ, DA9062AA_ID_4_3), |
378 | .range_min = DA9062AA_CONTROL_A, | 378 | regmap_reg_range(DA9062AA_ID_12_11, DA9062AA_ID_16_15), |
379 | .range_max = DA9062AA_GPIO_4, | 379 | regmap_reg_range(DA9062AA_ID_22_21, DA9062AA_ID_32_31), |
380 | }, { | 380 | regmap_reg_range(DA9062AA_SEQ_A, DA9062AA_WAIT), |
381 | .range_min = DA9062AA_GPIO_WKUP_MODE, | 381 | regmap_reg_range(DA9062AA_RESET, DA9062AA_BUCK_ILIM_C), |
382 | .range_max = DA9062AA_GPIO_OUT3_4, | 382 | regmap_reg_range(DA9062AA_BUCK1_CFG, DA9062AA_BUCK3_CFG), |
383 | }, { | 383 | regmap_reg_range(DA9062AA_VBUCK1_A, DA9062AA_VBUCK4_A), |
384 | .range_min = DA9062AA_BUCK1_CONT, | 384 | regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A), |
385 | .range_max = DA9062AA_BUCK4_CONT, | 385 | regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A), |
386 | }, { | 386 | regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B), |
387 | .range_min = DA9062AA_BUCK3_CONT, | 387 | regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), |
388 | .range_max = DA9062AA_BUCK3_CONT, | 388 | regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), |
389 | }, { | 389 | regmap_reg_range(DA9062AA_INTERFACE, DA9062AA_CONFIG_E), |
390 | .range_min = DA9062AA_LDO1_CONT, | 390 | regmap_reg_range(DA9062AA_CONFIG_G, DA9062AA_CONFIG_K), |
391 | .range_max = DA9062AA_LDO4_CONT, | 391 | regmap_reg_range(DA9062AA_CONFIG_M, DA9062AA_CONFIG_M), |
392 | }, { | 392 | regmap_reg_range(DA9062AA_GP_ID_0, DA9062AA_GP_ID_19), |
393 | .range_min = DA9062AA_DVC_1, | 393 | regmap_reg_range(DA9062AA_DEVICE_ID, DA9062AA_CONFIG_ID), |
394 | .range_max = DA9062AA_DVC_1, | ||
395 | }, { | ||
396 | .range_min = DA9062AA_SEQ, | ||
397 | .range_max = DA9062AA_ID_4_3, | ||
398 | }, { | ||
399 | .range_min = DA9062AA_ID_12_11, | ||
400 | .range_max = DA9062AA_ID_16_15, | ||
401 | }, { | ||
402 | .range_min = DA9062AA_ID_22_21, | ||
403 | .range_max = DA9062AA_ID_32_31, | ||
404 | }, { | ||
405 | .range_min = DA9062AA_SEQ_A, | ||
406 | .range_max = DA9062AA_WAIT, | ||
407 | }, { | ||
408 | .range_min = DA9062AA_RESET, | ||
409 | .range_max = DA9062AA_BUCK_ILIM_C, | ||
410 | }, { | ||
411 | .range_min = DA9062AA_BUCK1_CFG, | ||
412 | .range_max = DA9062AA_BUCK3_CFG, | ||
413 | }, { | ||
414 | .range_min = DA9062AA_VBUCK1_A, | ||
415 | .range_max = DA9062AA_VBUCK4_A, | ||
416 | }, { | ||
417 | .range_min = DA9062AA_VBUCK3_A, | ||
418 | .range_max = DA9062AA_VBUCK3_A, | ||
419 | }, { | ||
420 | .range_min = DA9062AA_VLDO1_A, | ||
421 | .range_max = DA9062AA_VLDO4_A, | ||
422 | }, { | ||
423 | .range_min = DA9062AA_VBUCK1_B, | ||
424 | .range_max = DA9062AA_VBUCK4_B, | ||
425 | }, { | ||
426 | .range_min = DA9062AA_VBUCK3_B, | ||
427 | .range_max = DA9062AA_VBUCK3_B, | ||
428 | }, { | ||
429 | .range_min = DA9062AA_VLDO1_B, | ||
430 | .range_max = DA9062AA_VLDO4_B, | ||
431 | }, { | ||
432 | .range_min = DA9062AA_INTERFACE, | ||
433 | .range_max = DA9062AA_CONFIG_E, | ||
434 | }, { | ||
435 | .range_min = DA9062AA_CONFIG_G, | ||
436 | .range_max = DA9062AA_CONFIG_K, | ||
437 | }, { | ||
438 | .range_min = DA9062AA_CONFIG_M, | ||
439 | .range_max = DA9062AA_CONFIG_M, | ||
440 | }, { | ||
441 | .range_min = DA9062AA_GP_ID_0, | ||
442 | .range_max = DA9062AA_GP_ID_19, | ||
443 | }, { | ||
444 | .range_min = DA9062AA_DEVICE_ID, | ||
445 | .range_max = DA9062AA_CONFIG_ID, | ||
446 | }, | ||
447 | }; | 394 | }; |
448 | 395 | ||
449 | static const struct regmap_range da9061_aa_writeable_ranges[] = { | 396 | static const struct regmap_range da9061_aa_writeable_ranges[] = { |
450 | { | 397 | regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_PAGE_CON), |
451 | .range_min = DA9062AA_PAGE_CON, | 398 | regmap_reg_range(DA9062AA_FAULT_LOG, DA9062AA_EVENT_C), |
452 | .range_max = DA9062AA_PAGE_CON, | 399 | regmap_reg_range(DA9062AA_IRQ_MASK_A, DA9062AA_IRQ_MASK_C), |
453 | }, { | 400 | regmap_reg_range(DA9062AA_CONTROL_A, DA9062AA_GPIO_4), |
454 | .range_min = DA9062AA_FAULT_LOG, | 401 | regmap_reg_range(DA9062AA_GPIO_WKUP_MODE, DA9062AA_GPIO_OUT3_4), |
455 | .range_max = DA9062AA_EVENT_C, | 402 | regmap_reg_range(DA9062AA_BUCK1_CONT, DA9062AA_BUCK4_CONT), |
456 | }, { | 403 | regmap_reg_range(DA9062AA_BUCK3_CONT, DA9062AA_BUCK3_CONT), |
457 | .range_min = DA9062AA_IRQ_MASK_A, | 404 | regmap_reg_range(DA9062AA_LDO1_CONT, DA9062AA_LDO4_CONT), |
458 | .range_max = DA9062AA_IRQ_MASK_C, | 405 | regmap_reg_range(DA9062AA_DVC_1, DA9062AA_DVC_1), |
459 | }, { | 406 | regmap_reg_range(DA9062AA_SEQ, DA9062AA_ID_4_3), |
460 | .range_min = DA9062AA_CONTROL_A, | 407 | regmap_reg_range(DA9062AA_ID_12_11, DA9062AA_ID_16_15), |
461 | .range_max = DA9062AA_GPIO_4, | 408 | regmap_reg_range(DA9062AA_ID_22_21, DA9062AA_ID_32_31), |
462 | }, { | 409 | regmap_reg_range(DA9062AA_SEQ_A, DA9062AA_WAIT), |
463 | .range_min = DA9062AA_GPIO_WKUP_MODE, | 410 | regmap_reg_range(DA9062AA_RESET, DA9062AA_BUCK_ILIM_C), |
464 | .range_max = DA9062AA_GPIO_OUT3_4, | 411 | regmap_reg_range(DA9062AA_BUCK1_CFG, DA9062AA_BUCK3_CFG), |
465 | }, { | 412 | regmap_reg_range(DA9062AA_VBUCK1_A, DA9062AA_VBUCK4_A), |
466 | .range_min = DA9062AA_BUCK1_CONT, | 413 | regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A), |
467 | .range_max = DA9062AA_BUCK4_CONT, | 414 | regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A), |
468 | }, { | 415 | regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B), |
469 | .range_min = DA9062AA_BUCK3_CONT, | 416 | regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), |
470 | .range_max = DA9062AA_BUCK3_CONT, | 417 | regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), |
471 | }, { | 418 | regmap_reg_range(DA9062AA_GP_ID_0, DA9062AA_GP_ID_19), |
472 | .range_min = DA9062AA_LDO1_CONT, | ||
473 | .range_max = DA9062AA_LDO4_CONT, | ||
474 | }, { | ||
475 | .range_min = DA9062AA_DVC_1, | ||
476 | .range_max = DA9062AA_DVC_1, | ||
477 | }, { | ||
478 | .range_min = DA9062AA_SEQ, | ||
479 | .range_max = DA9062AA_ID_4_3, | ||
480 | }, { | ||
481 | .range_min = DA9062AA_ID_12_11, | ||
482 | .range_max = DA9062AA_ID_16_15, | ||
483 | }, { | ||
484 | .range_min = DA9062AA_ID_22_21, | ||
485 | .range_max = DA9062AA_ID_32_31, | ||
486 | }, { | ||
487 | .range_min = DA9062AA_SEQ_A, | ||
488 | .range_max = DA9062AA_WAIT, | ||
489 | }, { | ||
490 | .range_min = DA9062AA_RESET, | ||
491 | .range_max = DA9062AA_BUCK_ILIM_C, | ||
492 | }, { | ||
493 | .range_min = DA9062AA_BUCK1_CFG, | ||
494 | .range_max = DA9062AA_BUCK3_CFG, | ||
495 | }, { | ||
496 | .range_min = DA9062AA_VBUCK1_A, | ||
497 | .range_max = DA9062AA_VBUCK4_A, | ||
498 | }, { | ||
499 | .range_min = DA9062AA_VBUCK3_A, | ||
500 | .range_max = DA9062AA_VBUCK3_A, | ||
501 | }, { | ||
502 | .range_min = DA9062AA_VLDO1_A, | ||
503 | .range_max = DA9062AA_VLDO4_A, | ||
504 | }, { | ||
505 | .range_min = DA9062AA_VBUCK1_B, | ||
506 | .range_max = DA9062AA_VBUCK4_B, | ||
507 | }, { | ||
508 | .range_min = DA9062AA_VBUCK3_B, | ||
509 | .range_max = DA9062AA_VBUCK3_B, | ||
510 | }, { | ||
511 | .range_min = DA9062AA_VLDO1_B, | ||
512 | .range_max = DA9062AA_VLDO4_B, | ||
513 | }, { | ||
514 | .range_min = DA9062AA_GP_ID_0, | ||
515 | .range_max = DA9062AA_GP_ID_19, | ||
516 | }, | ||
517 | }; | 419 | }; |
518 | 420 | ||
519 | static const struct regmap_range da9061_aa_volatile_ranges[] = { | 421 | static const struct regmap_range da9061_aa_volatile_ranges[] = { |
520 | { | 422 | regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_STATUS_B), |
521 | .range_min = DA9062AA_PAGE_CON, | 423 | regmap_reg_range(DA9062AA_STATUS_D, DA9062AA_EVENT_C), |
522 | .range_max = DA9062AA_STATUS_B, | 424 | regmap_reg_range(DA9062AA_CONTROL_A, DA9062AA_CONTROL_B), |
523 | }, { | 425 | regmap_reg_range(DA9062AA_CONTROL_E, DA9062AA_CONTROL_F), |
524 | .range_min = DA9062AA_STATUS_D, | 426 | regmap_reg_range(DA9062AA_BUCK1_CONT, DA9062AA_BUCK4_CONT), |
525 | .range_max = DA9062AA_EVENT_C, | 427 | regmap_reg_range(DA9062AA_BUCK3_CONT, DA9062AA_BUCK3_CONT), |
526 | }, { | 428 | regmap_reg_range(DA9062AA_LDO1_CONT, DA9062AA_LDO4_CONT), |
527 | .range_min = DA9062AA_CONTROL_A, | 429 | regmap_reg_range(DA9062AA_DVC_1, DA9062AA_DVC_1), |
528 | .range_max = DA9062AA_CONTROL_B, | 430 | regmap_reg_range(DA9062AA_SEQ, DA9062AA_SEQ), |
529 | }, { | ||
530 | .range_min = DA9062AA_CONTROL_E, | ||
531 | .range_max = DA9062AA_CONTROL_F, | ||
532 | }, { | ||
533 | .range_min = DA9062AA_BUCK1_CONT, | ||
534 | .range_max = DA9062AA_BUCK4_CONT, | ||
535 | }, { | ||
536 | .range_min = DA9062AA_BUCK3_CONT, | ||
537 | .range_max = DA9062AA_BUCK3_CONT, | ||
538 | }, { | ||
539 | .range_min = DA9062AA_LDO1_CONT, | ||
540 | .range_max = DA9062AA_LDO4_CONT, | ||
541 | }, { | ||
542 | .range_min = DA9062AA_DVC_1, | ||
543 | .range_max = DA9062AA_DVC_1, | ||
544 | }, { | ||
545 | .range_min = DA9062AA_SEQ, | ||
546 | .range_max = DA9062AA_SEQ, | ||
547 | }, | ||
548 | }; | 431 | }; |
549 | 432 | ||
550 | static const struct regmap_access_table da9061_aa_readable_table = { | 433 | static const struct regmap_access_table da9061_aa_readable_table = { |
@@ -587,186 +470,69 @@ static struct regmap_config da9061_regmap_config = { | |||
587 | }; | 470 | }; |
588 | 471 | ||
589 | static const struct regmap_range da9062_aa_readable_ranges[] = { | 472 | static const struct regmap_range da9062_aa_readable_ranges[] = { |
590 | { | 473 | regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_STATUS_B), |
591 | .range_min = DA9062AA_PAGE_CON, | 474 | regmap_reg_range(DA9062AA_STATUS_D, DA9062AA_EVENT_C), |
592 | .range_max = DA9062AA_STATUS_B, | 475 | regmap_reg_range(DA9062AA_IRQ_MASK_A, DA9062AA_IRQ_MASK_C), |
593 | }, { | 476 | regmap_reg_range(DA9062AA_CONTROL_A, DA9062AA_GPIO_4), |
594 | .range_min = DA9062AA_STATUS_D, | 477 | regmap_reg_range(DA9062AA_GPIO_WKUP_MODE, DA9062AA_BUCK4_CONT), |
595 | .range_max = DA9062AA_EVENT_C, | 478 | regmap_reg_range(DA9062AA_BUCK3_CONT, DA9062AA_BUCK3_CONT), |
596 | }, { | 479 | regmap_reg_range(DA9062AA_LDO1_CONT, DA9062AA_LDO4_CONT), |
597 | .range_min = DA9062AA_IRQ_MASK_A, | 480 | regmap_reg_range(DA9062AA_DVC_1, DA9062AA_DVC_1), |
598 | .range_max = DA9062AA_IRQ_MASK_C, | 481 | regmap_reg_range(DA9062AA_COUNT_S, DA9062AA_SECOND_D), |
599 | }, { | 482 | regmap_reg_range(DA9062AA_SEQ, DA9062AA_ID_4_3), |
600 | .range_min = DA9062AA_CONTROL_A, | 483 | regmap_reg_range(DA9062AA_ID_12_11, DA9062AA_ID_16_15), |
601 | .range_max = DA9062AA_GPIO_4, | 484 | regmap_reg_range(DA9062AA_ID_22_21, DA9062AA_ID_32_31), |
602 | }, { | 485 | regmap_reg_range(DA9062AA_SEQ_A, DA9062AA_BUCK3_CFG), |
603 | .range_min = DA9062AA_GPIO_WKUP_MODE, | 486 | regmap_reg_range(DA9062AA_VBUCK2_A, DA9062AA_VBUCK4_A), |
604 | .range_max = DA9062AA_BUCK4_CONT, | 487 | regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A), |
605 | }, { | 488 | regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A), |
606 | .range_min = DA9062AA_BUCK3_CONT, | 489 | regmap_reg_range(DA9062AA_VBUCK2_B, DA9062AA_VBUCK4_B), |
607 | .range_max = DA9062AA_BUCK3_CONT, | 490 | regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), |
608 | }, { | 491 | regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), |
609 | .range_min = DA9062AA_LDO1_CONT, | 492 | regmap_reg_range(DA9062AA_BBAT_CONT, DA9062AA_BBAT_CONT), |
610 | .range_max = DA9062AA_LDO4_CONT, | 493 | regmap_reg_range(DA9062AA_INTERFACE, DA9062AA_CONFIG_E), |
611 | }, { | 494 | regmap_reg_range(DA9062AA_CONFIG_G, DA9062AA_CONFIG_K), |
612 | .range_min = DA9062AA_DVC_1, | 495 | regmap_reg_range(DA9062AA_CONFIG_M, DA9062AA_CONFIG_M), |
613 | .range_max = DA9062AA_DVC_1, | 496 | regmap_reg_range(DA9062AA_TRIM_CLDR, DA9062AA_GP_ID_19), |
614 | }, { | 497 | regmap_reg_range(DA9062AA_DEVICE_ID, DA9062AA_CONFIG_ID), |
615 | .range_min = DA9062AA_COUNT_S, | ||
616 | .range_max = DA9062AA_SECOND_D, | ||
617 | }, { | ||
618 | .range_min = DA9062AA_SEQ, | ||
619 | .range_max = DA9062AA_ID_4_3, | ||
620 | }, { | ||
621 | .range_min = DA9062AA_ID_12_11, | ||
622 | .range_max = DA9062AA_ID_16_15, | ||
623 | }, { | ||
624 | .range_min = DA9062AA_ID_22_21, | ||
625 | .range_max = DA9062AA_ID_32_31, | ||
626 | }, { | ||
627 | .range_min = DA9062AA_SEQ_A, | ||
628 | .range_max = DA9062AA_BUCK3_CFG, | ||
629 | }, { | ||
630 | .range_min = DA9062AA_VBUCK2_A, | ||
631 | .range_max = DA9062AA_VBUCK4_A, | ||
632 | }, { | ||
633 | .range_min = DA9062AA_VBUCK3_A, | ||
634 | .range_max = DA9062AA_VBUCK3_A, | ||
635 | }, { | ||
636 | .range_min = DA9062AA_VLDO1_A, | ||
637 | .range_max = DA9062AA_VLDO4_A, | ||
638 | }, { | ||
639 | .range_min = DA9062AA_VBUCK2_B, | ||
640 | .range_max = DA9062AA_VBUCK4_B, | ||
641 | }, { | ||
642 | .range_min = DA9062AA_VBUCK3_B, | ||
643 | .range_max = DA9062AA_VBUCK3_B, | ||
644 | }, { | ||
645 | .range_min = DA9062AA_VLDO1_B, | ||
646 | .range_max = DA9062AA_VLDO4_B, | ||
647 | }, { | ||
648 | .range_min = DA9062AA_BBAT_CONT, | ||
649 | .range_max = DA9062AA_BBAT_CONT, | ||
650 | }, { | ||
651 | .range_min = DA9062AA_INTERFACE, | ||
652 | .range_max = DA9062AA_CONFIG_E, | ||
653 | }, { | ||
654 | .range_min = DA9062AA_CONFIG_G, | ||
655 | .range_max = DA9062AA_CONFIG_K, | ||
656 | }, { | ||
657 | .range_min = DA9062AA_CONFIG_M, | ||
658 | .range_max = DA9062AA_CONFIG_M, | ||
659 | }, { | ||
660 | .range_min = DA9062AA_TRIM_CLDR, | ||
661 | .range_max = DA9062AA_GP_ID_19, | ||
662 | }, { | ||
663 | .range_min = DA9062AA_DEVICE_ID, | ||
664 | .range_max = DA9062AA_CONFIG_ID, | ||
665 | }, | ||
666 | }; | 498 | }; |
667 | 499 | ||
668 | static const struct regmap_range da9062_aa_writeable_ranges[] = { | 500 | static const struct regmap_range da9062_aa_writeable_ranges[] = { |
669 | { | 501 | regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_PAGE_CON), |
670 | .range_min = DA9062AA_PAGE_CON, | 502 | regmap_reg_range(DA9062AA_FAULT_LOG, DA9062AA_EVENT_C), |
671 | .range_max = DA9062AA_PAGE_CON, | 503 | regmap_reg_range(DA9062AA_IRQ_MASK_A, DA9062AA_IRQ_MASK_C), |
672 | }, { | 504 | regmap_reg_range(DA9062AA_CONTROL_A, DA9062AA_GPIO_4), |
673 | .range_min = DA9062AA_FAULT_LOG, | 505 | regmap_reg_range(DA9062AA_GPIO_WKUP_MODE, DA9062AA_BUCK4_CONT), |
674 | .range_max = DA9062AA_EVENT_C, | 506 | regmap_reg_range(DA9062AA_BUCK3_CONT, DA9062AA_BUCK3_CONT), |
675 | }, { | 507 | regmap_reg_range(DA9062AA_LDO1_CONT, DA9062AA_LDO4_CONT), |
676 | .range_min = DA9062AA_IRQ_MASK_A, | 508 | regmap_reg_range(DA9062AA_DVC_1, DA9062AA_DVC_1), |
677 | .range_max = DA9062AA_IRQ_MASK_C, | 509 | regmap_reg_range(DA9062AA_COUNT_S, DA9062AA_ALARM_Y), |
678 | }, { | 510 | regmap_reg_range(DA9062AA_SEQ, DA9062AA_ID_4_3), |
679 | .range_min = DA9062AA_CONTROL_A, | 511 | regmap_reg_range(DA9062AA_ID_12_11, DA9062AA_ID_16_15), |
680 | .range_max = DA9062AA_GPIO_4, | 512 | regmap_reg_range(DA9062AA_ID_22_21, DA9062AA_ID_32_31), |
681 | }, { | 513 | regmap_reg_range(DA9062AA_SEQ_A, DA9062AA_BUCK3_CFG), |
682 | .range_min = DA9062AA_GPIO_WKUP_MODE, | 514 | regmap_reg_range(DA9062AA_VBUCK2_A, DA9062AA_VBUCK4_A), |
683 | .range_max = DA9062AA_BUCK4_CONT, | 515 | regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A), |
684 | }, { | 516 | regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A), |
685 | .range_min = DA9062AA_BUCK3_CONT, | 517 | regmap_reg_range(DA9062AA_VBUCK2_B, DA9062AA_VBUCK4_B), |
686 | .range_max = DA9062AA_BUCK3_CONT, | 518 | regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B), |
687 | }, { | 519 | regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B), |
688 | .range_min = DA9062AA_LDO1_CONT, | 520 | regmap_reg_range(DA9062AA_BBAT_CONT, DA9062AA_BBAT_CONT), |
689 | .range_max = DA9062AA_LDO4_CONT, | 521 | regmap_reg_range(DA9062AA_GP_ID_0, DA9062AA_GP_ID_19), |
690 | }, { | ||
691 | .range_min = DA9062AA_DVC_1, | ||
692 | .range_max = DA9062AA_DVC_1, | ||
693 | }, { | ||
694 | .range_min = DA9062AA_COUNT_S, | ||
695 | .range_max = DA9062AA_ALARM_Y, | ||
696 | }, { | ||
697 | .range_min = DA9062AA_SEQ, | ||
698 | .range_max = DA9062AA_ID_4_3, | ||
699 | }, { | ||
700 | .range_min = DA9062AA_ID_12_11, | ||
701 | .range_max = DA9062AA_ID_16_15, | ||
702 | }, { | ||
703 | .range_min = DA9062AA_ID_22_21, | ||
704 | .range_max = DA9062AA_ID_32_31, | ||
705 | }, { | ||
706 | .range_min = DA9062AA_SEQ_A, | ||
707 | .range_max = DA9062AA_BUCK3_CFG, | ||
708 | }, { | ||
709 | .range_min = DA9062AA_VBUCK2_A, | ||
710 | .range_max = DA9062AA_VBUCK4_A, | ||
711 | }, { | ||
712 | .range_min = DA9062AA_VBUCK3_A, | ||
713 | .range_max = DA9062AA_VBUCK3_A, | ||
714 | }, { | ||
715 | .range_min = DA9062AA_VLDO1_A, | ||
716 | .range_max = DA9062AA_VLDO4_A, | ||
717 | }, { | ||
718 | .range_min = DA9062AA_VBUCK2_B, | ||
719 | .range_max = DA9062AA_VBUCK4_B, | ||
720 | }, { | ||
721 | .range_min = DA9062AA_VBUCK3_B, | ||
722 | .range_max = DA9062AA_VBUCK3_B, | ||
723 | }, { | ||
724 | .range_min = DA9062AA_VLDO1_B, | ||
725 | .range_max = DA9062AA_VLDO4_B, | ||
726 | }, { | ||
727 | .range_min = DA9062AA_BBAT_CONT, | ||
728 | .range_max = DA9062AA_BBAT_CONT, | ||
729 | }, { | ||
730 | .range_min = DA9062AA_GP_ID_0, | ||
731 | .range_max = DA9062AA_GP_ID_19, | ||
732 | }, | ||
733 | }; | 522 | }; |
734 | 523 | ||
735 | static const struct regmap_range da9062_aa_volatile_ranges[] = { | 524 | static const struct regmap_range da9062_aa_volatile_ranges[] = { |
736 | { | 525 | regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_STATUS_B), |
737 | .range_min = DA9062AA_PAGE_CON, | 526 | regmap_reg_range(DA9062AA_STATUS_D, DA9062AA_EVENT_C), |
738 | .range_max = DA9062AA_STATUS_B, | 527 | regmap_reg_range(DA9062AA_CONTROL_A, DA9062AA_CONTROL_B), |
739 | }, { | 528 | regmap_reg_range(DA9062AA_CONTROL_E, DA9062AA_CONTROL_F), |
740 | .range_min = DA9062AA_STATUS_D, | 529 | regmap_reg_range(DA9062AA_BUCK2_CONT, DA9062AA_BUCK4_CONT), |
741 | .range_max = DA9062AA_EVENT_C, | 530 | regmap_reg_range(DA9062AA_BUCK3_CONT, DA9062AA_BUCK3_CONT), |
742 | }, { | 531 | regmap_reg_range(DA9062AA_LDO1_CONT, DA9062AA_LDO4_CONT), |
743 | .range_min = DA9062AA_CONTROL_A, | 532 | regmap_reg_range(DA9062AA_DVC_1, DA9062AA_DVC_1), |
744 | .range_max = DA9062AA_CONTROL_B, | 533 | regmap_reg_range(DA9062AA_COUNT_S, DA9062AA_SECOND_D), |
745 | }, { | 534 | regmap_reg_range(DA9062AA_SEQ, DA9062AA_SEQ), |
746 | .range_min = DA9062AA_CONTROL_E, | 535 | regmap_reg_range(DA9062AA_EN_32K, DA9062AA_EN_32K), |
747 | .range_max = DA9062AA_CONTROL_F, | ||
748 | }, { | ||
749 | .range_min = DA9062AA_BUCK2_CONT, | ||
750 | .range_max = DA9062AA_BUCK4_CONT, | ||
751 | }, { | ||
752 | .range_min = DA9062AA_BUCK3_CONT, | ||
753 | .range_max = DA9062AA_BUCK3_CONT, | ||
754 | }, { | ||
755 | .range_min = DA9062AA_LDO1_CONT, | ||
756 | .range_max = DA9062AA_LDO4_CONT, | ||
757 | }, { | ||
758 | .range_min = DA9062AA_DVC_1, | ||
759 | .range_max = DA9062AA_DVC_1, | ||
760 | }, { | ||
761 | .range_min = DA9062AA_COUNT_S, | ||
762 | .range_max = DA9062AA_SECOND_D, | ||
763 | }, { | ||
764 | .range_min = DA9062AA_SEQ, | ||
765 | .range_max = DA9062AA_SEQ, | ||
766 | }, { | ||
767 | .range_min = DA9062AA_EN_32K, | ||
768 | .range_max = DA9062AA_EN_32K, | ||
769 | }, | ||
770 | }; | 536 | }; |
771 | 537 | ||
772 | static const struct regmap_access_table da9062_aa_readable_table = { | 538 | static const struct regmap_access_table da9062_aa_readable_table = { |
diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c index 3f9eee5f8fb9..4bf8b7781c77 100644 --- a/drivers/mfd/htc-i2cpld.c +++ b/drivers/mfd/htc-i2cpld.c | |||
@@ -479,10 +479,8 @@ static int htcpld_setup_chips(struct platform_device *pdev) | |||
479 | htcpld->nchips = pdata->num_chip; | 479 | htcpld->nchips = pdata->num_chip; |
480 | htcpld->chip = devm_kzalloc(dev, sizeof(struct htcpld_chip) * htcpld->nchips, | 480 | htcpld->chip = devm_kzalloc(dev, sizeof(struct htcpld_chip) * htcpld->nchips, |
481 | GFP_KERNEL); | 481 | GFP_KERNEL); |
482 | if (!htcpld->chip) { | 482 | if (!htcpld->chip) |
483 | dev_warn(dev, "Unable to allocate memory for chips\n"); | ||
484 | return -ENOMEM; | 483 | return -ENOMEM; |
485 | } | ||
486 | 484 | ||
487 | /* Add the chips as best we can */ | 485 | /* Add the chips as best we can */ |
488 | for (i = 0; i < htcpld->nchips; i++) { | 486 | for (i = 0; i < htcpld->nchips; i++) { |
diff --git a/drivers/mfd/intel-lpss-pci.c b/drivers/mfd/intel-lpss-pci.c index d1c46de89eb4..d9ae983095c5 100644 --- a/drivers/mfd/intel-lpss-pci.c +++ b/drivers/mfd/intel-lpss-pci.c | |||
@@ -124,6 +124,11 @@ static const struct intel_lpss_platform_info apl_i2c_info = { | |||
124 | .properties = apl_i2c_properties, | 124 | .properties = apl_i2c_properties, |
125 | }; | 125 | }; |
126 | 126 | ||
127 | static const struct intel_lpss_platform_info cnl_i2c_info = { | ||
128 | .clk_rate = 216000000, | ||
129 | .properties = spt_i2c_properties, | ||
130 | }; | ||
131 | |||
127 | static const struct pci_device_id intel_lpss_pci_ids[] = { | 132 | static const struct pci_device_id intel_lpss_pci_ids[] = { |
128 | /* BXT A-Step */ | 133 | /* BXT A-Step */ |
129 | { PCI_VDEVICE(INTEL, 0x0aac), (kernel_ulong_t)&bxt_i2c_info }, | 134 | { PCI_VDEVICE(INTEL, 0x0aac), (kernel_ulong_t)&bxt_i2c_info }, |
@@ -207,13 +212,13 @@ static const struct pci_device_id intel_lpss_pci_ids[] = { | |||
207 | { PCI_VDEVICE(INTEL, 0x9daa), (kernel_ulong_t)&spt_info }, | 212 | { PCI_VDEVICE(INTEL, 0x9daa), (kernel_ulong_t)&spt_info }, |
208 | { PCI_VDEVICE(INTEL, 0x9dab), (kernel_ulong_t)&spt_info }, | 213 | { PCI_VDEVICE(INTEL, 0x9dab), (kernel_ulong_t)&spt_info }, |
209 | { PCI_VDEVICE(INTEL, 0x9dfb), (kernel_ulong_t)&spt_info }, | 214 | { PCI_VDEVICE(INTEL, 0x9dfb), (kernel_ulong_t)&spt_info }, |
210 | { PCI_VDEVICE(INTEL, 0x9dc5), (kernel_ulong_t)&spt_i2c_info }, | 215 | { PCI_VDEVICE(INTEL, 0x9dc5), (kernel_ulong_t)&cnl_i2c_info }, |
211 | { PCI_VDEVICE(INTEL, 0x9dc6), (kernel_ulong_t)&spt_i2c_info }, | 216 | { PCI_VDEVICE(INTEL, 0x9dc6), (kernel_ulong_t)&cnl_i2c_info }, |
212 | { PCI_VDEVICE(INTEL, 0x9dc7), (kernel_ulong_t)&spt_uart_info }, | 217 | { PCI_VDEVICE(INTEL, 0x9dc7), (kernel_ulong_t)&spt_uart_info }, |
213 | { PCI_VDEVICE(INTEL, 0x9de8), (kernel_ulong_t)&spt_i2c_info }, | 218 | { PCI_VDEVICE(INTEL, 0x9de8), (kernel_ulong_t)&cnl_i2c_info }, |
214 | { PCI_VDEVICE(INTEL, 0x9de9), (kernel_ulong_t)&spt_i2c_info }, | 219 | { PCI_VDEVICE(INTEL, 0x9de9), (kernel_ulong_t)&cnl_i2c_info }, |
215 | { PCI_VDEVICE(INTEL, 0x9dea), (kernel_ulong_t)&spt_i2c_info }, | 220 | { PCI_VDEVICE(INTEL, 0x9dea), (kernel_ulong_t)&cnl_i2c_info }, |
216 | { PCI_VDEVICE(INTEL, 0x9deb), (kernel_ulong_t)&spt_i2c_info }, | 221 | { PCI_VDEVICE(INTEL, 0x9deb), (kernel_ulong_t)&cnl_i2c_info }, |
217 | /* SPT-H */ | 222 | /* SPT-H */ |
218 | { PCI_VDEVICE(INTEL, 0xa127), (kernel_ulong_t)&spt_uart_info }, | 223 | { PCI_VDEVICE(INTEL, 0xa127), (kernel_ulong_t)&spt_uart_info }, |
219 | { PCI_VDEVICE(INTEL, 0xa128), (kernel_ulong_t)&spt_uart_info }, | 224 | { PCI_VDEVICE(INTEL, 0xa128), (kernel_ulong_t)&spt_uart_info }, |
@@ -240,10 +245,10 @@ static const struct pci_device_id intel_lpss_pci_ids[] = { | |||
240 | { PCI_VDEVICE(INTEL, 0xa32b), (kernel_ulong_t)&spt_info }, | 245 | { PCI_VDEVICE(INTEL, 0xa32b), (kernel_ulong_t)&spt_info }, |
241 | { PCI_VDEVICE(INTEL, 0xa37b), (kernel_ulong_t)&spt_info }, | 246 | { PCI_VDEVICE(INTEL, 0xa37b), (kernel_ulong_t)&spt_info }, |
242 | { PCI_VDEVICE(INTEL, 0xa347), (kernel_ulong_t)&spt_uart_info }, | 247 | { PCI_VDEVICE(INTEL, 0xa347), (kernel_ulong_t)&spt_uart_info }, |
243 | { PCI_VDEVICE(INTEL, 0xa368), (kernel_ulong_t)&spt_i2c_info }, | 248 | { PCI_VDEVICE(INTEL, 0xa368), (kernel_ulong_t)&cnl_i2c_info }, |
244 | { PCI_VDEVICE(INTEL, 0xa369), (kernel_ulong_t)&spt_i2c_info }, | 249 | { PCI_VDEVICE(INTEL, 0xa369), (kernel_ulong_t)&cnl_i2c_info }, |
245 | { PCI_VDEVICE(INTEL, 0xa36a), (kernel_ulong_t)&spt_i2c_info }, | 250 | { PCI_VDEVICE(INTEL, 0xa36a), (kernel_ulong_t)&cnl_i2c_info }, |
246 | { PCI_VDEVICE(INTEL, 0xa36b), (kernel_ulong_t)&spt_i2c_info }, | 251 | { PCI_VDEVICE(INTEL, 0xa36b), (kernel_ulong_t)&cnl_i2c_info }, |
247 | { } | 252 | { } |
248 | }; | 253 | }; |
249 | MODULE_DEVICE_TABLE(pci, intel_lpss_pci_ids); | 254 | MODULE_DEVICE_TABLE(pci, intel_lpss_pci_ids); |
diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c index 9e545eb6e8b4..50bffc3382d7 100644 --- a/drivers/mfd/intel-lpss.c +++ b/drivers/mfd/intel-lpss.c | |||
@@ -40,8 +40,8 @@ | |||
40 | 40 | ||
41 | /* Offsets from lpss->priv */ | 41 | /* Offsets from lpss->priv */ |
42 | #define LPSS_PRIV_RESETS 0x04 | 42 | #define LPSS_PRIV_RESETS 0x04 |
43 | #define LPSS_PRIV_RESETS_FUNC BIT(2) | 43 | #define LPSS_PRIV_RESETS_IDMA BIT(2) |
44 | #define LPSS_PRIV_RESETS_IDMA 0x3 | 44 | #define LPSS_PRIV_RESETS_FUNC 0x3 |
45 | 45 | ||
46 | #define LPSS_PRIV_ACTIVELTR 0x10 | 46 | #define LPSS_PRIV_ACTIVELTR 0x10 |
47 | #define LPSS_PRIV_IDLELTR 0x14 | 47 | #define LPSS_PRIV_IDLELTR 0x14 |
@@ -275,11 +275,11 @@ static void intel_lpss_init_dev(const struct intel_lpss *lpss) | |||
275 | 275 | ||
276 | intel_lpss_deassert_reset(lpss); | 276 | intel_lpss_deassert_reset(lpss); |
277 | 277 | ||
278 | intel_lpss_set_remap_addr(lpss); | ||
279 | |||
278 | if (!intel_lpss_has_idma(lpss)) | 280 | if (!intel_lpss_has_idma(lpss)) |
279 | return; | 281 | return; |
280 | 282 | ||
281 | intel_lpss_set_remap_addr(lpss); | ||
282 | |||
283 | /* Make sure that SPI multiblock DMA transfers are re-enabled */ | 283 | /* Make sure that SPI multiblock DMA transfers are re-enabled */ |
284 | if (lpss->type == LPSS_DEV_SPI) | 284 | if (lpss->type == LPSS_DEV_SPI) |
285 | writel(value, lpss->priv + LPSS_PRIV_SSP_REG); | 285 | writel(value, lpss->priv + LPSS_PRIV_SSP_REG); |
diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c index ec1f46a6be3a..317a47ad5bb7 100644 --- a/drivers/mfd/janz-cmodio.c +++ b/drivers/mfd/janz-cmodio.c | |||
@@ -183,10 +183,8 @@ static int cmodio_pci_probe(struct pci_dev *dev, | |||
183 | int ret; | 183 | int ret; |
184 | 184 | ||
185 | priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL); | 185 | priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL); |
186 | if (!priv) { | 186 | if (!priv) |
187 | dev_err(&dev->dev, "unable to allocate private data\n"); | ||
188 | return -ENOMEM; | 187 | return -ENOMEM; |
189 | } | ||
190 | 188 | ||
191 | pci_set_drvdata(dev, priv); | 189 | pci_set_drvdata(dev, priv); |
192 | priv->pdev = dev; | 190 | priv->pdev = dev; |
diff --git a/drivers/mfd/jz4740-adc.c b/drivers/mfd/jz4740-adc.c index 798e44306382..f4cd14294b61 100644 --- a/drivers/mfd/jz4740-adc.c +++ b/drivers/mfd/jz4740-adc.c | |||
@@ -212,10 +212,8 @@ static int jz4740_adc_probe(struct platform_device *pdev) | |||
212 | int irq_base; | 212 | int irq_base; |
213 | 213 | ||
214 | adc = devm_kzalloc(&pdev->dev, sizeof(*adc), GFP_KERNEL); | 214 | adc = devm_kzalloc(&pdev->dev, sizeof(*adc), GFP_KERNEL); |
215 | if (!adc) { | 215 | if (!adc) |
216 | dev_err(&pdev->dev, "Failed to allocate driver structure\n"); | ||
217 | return -ENOMEM; | 216 | return -ENOMEM; |
218 | } | ||
219 | 217 | ||
220 | adc->irq = platform_get_irq(pdev, 0); | 218 | adc->irq = platform_get_irq(pdev, 0); |
221 | if (adc->irq < 0) { | 219 | if (adc->irq < 0) { |
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c index 2d6e2c392786..3f554c447521 100644 --- a/drivers/mfd/max8997.c +++ b/drivers/mfd/max8997.c | |||
@@ -148,10 +148,8 @@ static struct max8997_platform_data *max8997_i2c_parse_dt_pdata( | |||
148 | struct max8997_platform_data *pd; | 148 | struct max8997_platform_data *pd; |
149 | 149 | ||
150 | pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); | 150 | pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); |
151 | if (!pd) { | 151 | if (!pd) |
152 | dev_err(dev, "could not allocate memory for pdata\n"); | ||
153 | return ERR_PTR(-ENOMEM); | 152 | return ERR_PTR(-ENOMEM); |
154 | } | ||
155 | 153 | ||
156 | pd->ono = irq_of_parse_and_map(dev->of_node, 1); | 154 | pd->ono = irq_of_parse_and_map(dev->of_node, 1); |
157 | 155 | ||
diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c index 04a601f6aebe..77b64bd64df3 100644 --- a/drivers/mfd/mt6397-core.c +++ b/drivers/mfd/mt6397-core.c | |||
@@ -43,6 +43,16 @@ static const struct resource mt6397_rtc_resources[] = { | |||
43 | }, | 43 | }, |
44 | }; | 44 | }; |
45 | 45 | ||
46 | static const struct resource mt6323_keys_resources[] = { | ||
47 | DEFINE_RES_IRQ(MT6323_IRQ_STATUS_PWRKEY), | ||
48 | DEFINE_RES_IRQ(MT6323_IRQ_STATUS_FCHRKEY), | ||
49 | }; | ||
50 | |||
51 | static const struct resource mt6397_keys_resources[] = { | ||
52 | DEFINE_RES_IRQ(MT6397_IRQ_PWRKEY), | ||
53 | DEFINE_RES_IRQ(MT6397_IRQ_HOMEKEY), | ||
54 | }; | ||
55 | |||
46 | static const struct mfd_cell mt6323_devs[] = { | 56 | static const struct mfd_cell mt6323_devs[] = { |
47 | { | 57 | { |
48 | .name = "mt6323-regulator", | 58 | .name = "mt6323-regulator", |
@@ -50,6 +60,11 @@ static const struct mfd_cell mt6323_devs[] = { | |||
50 | }, { | 60 | }, { |
51 | .name = "mt6323-led", | 61 | .name = "mt6323-led", |
52 | .of_compatible = "mediatek,mt6323-led" | 62 | .of_compatible = "mediatek,mt6323-led" |
63 | }, { | ||
64 | .name = "mtk-pmic-keys", | ||
65 | .num_resources = ARRAY_SIZE(mt6323_keys_resources), | ||
66 | .resources = mt6323_keys_resources, | ||
67 | .of_compatible = "mediatek,mt6323-keys" | ||
53 | }, | 68 | }, |
54 | }; | 69 | }; |
55 | 70 | ||
@@ -71,7 +86,12 @@ static const struct mfd_cell mt6397_devs[] = { | |||
71 | }, { | 86 | }, { |
72 | .name = "mt6397-pinctrl", | 87 | .name = "mt6397-pinctrl", |
73 | .of_compatible = "mediatek,mt6397-pinctrl", | 88 | .of_compatible = "mediatek,mt6397-pinctrl", |
74 | }, | 89 | }, { |
90 | .name = "mtk-pmic-keys", | ||
91 | .num_resources = ARRAY_SIZE(mt6397_keys_resources), | ||
92 | .resources = mt6397_keys_resources, | ||
93 | .of_compatible = "mediatek,mt6397-keys" | ||
94 | } | ||
75 | }; | 95 | }; |
76 | 96 | ||
77 | static void mt6397_irq_lock(struct irq_data *data) | 97 | static void mt6397_irq_lock(struct irq_data *data) |
@@ -289,7 +309,7 @@ static int mt6397_probe(struct platform_device *pdev) | |||
289 | 309 | ||
290 | ret = devm_mfd_add_devices(&pdev->dev, -1, mt6323_devs, | 310 | ret = devm_mfd_add_devices(&pdev->dev, -1, mt6323_devs, |
291 | ARRAY_SIZE(mt6323_devs), NULL, | 311 | ARRAY_SIZE(mt6323_devs), NULL, |
292 | 0, NULL); | 312 | 0, pmic->irq_domain); |
293 | break; | 313 | break; |
294 | 314 | ||
295 | case MT6397_CID_CODE: | 315 | case MT6397_CID_CODE: |
@@ -304,7 +324,7 @@ static int mt6397_probe(struct platform_device *pdev) | |||
304 | 324 | ||
305 | ret = devm_mfd_add_devices(&pdev->dev, -1, mt6397_devs, | 325 | ret = devm_mfd_add_devices(&pdev->dev, -1, mt6397_devs, |
306 | ARRAY_SIZE(mt6397_devs), NULL, | 326 | ARRAY_SIZE(mt6397_devs), NULL, |
307 | 0, NULL); | 327 | 0, pmic->irq_domain); |
308 | break; | 328 | break; |
309 | 329 | ||
310 | default: | 330 | default: |
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c index 7aab376ecb84..e11ab12fbdf2 100644 --- a/drivers/mfd/omap-usb-host.c +++ b/drivers/mfd/omap-usb-host.c | |||
@@ -153,27 +153,6 @@ static const char * const port_modes[] = { | |||
153 | [OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM] = "ohci-tll-2pin-dpdm", | 153 | [OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM] = "ohci-tll-2pin-dpdm", |
154 | }; | 154 | }; |
155 | 155 | ||
156 | /** | ||
157 | * omap_usbhs_get_dt_port_mode - Get the 'enum usbhs_omap_port_mode' | ||
158 | * from the port mode string. | ||
159 | * @mode: The port mode string, usually obtained from device tree. | ||
160 | * | ||
161 | * The function returns the 'enum usbhs_omap_port_mode' that matches the | ||
162 | * provided port mode string as per the port_modes table. | ||
163 | * If no match is found it returns -ENODEV | ||
164 | */ | ||
165 | static int omap_usbhs_get_dt_port_mode(const char *mode) | ||
166 | { | ||
167 | int i; | ||
168 | |||
169 | for (i = 0; i < ARRAY_SIZE(port_modes); i++) { | ||
170 | if (!strcmp(mode, port_modes[i])) | ||
171 | return i; | ||
172 | } | ||
173 | |||
174 | return -ENODEV; | ||
175 | } | ||
176 | |||
177 | static struct platform_device *omap_usbhs_alloc_child(const char *name, | 156 | static struct platform_device *omap_usbhs_alloc_child(const char *name, |
178 | struct resource *res, int num_resources, void *pdata, | 157 | struct resource *res, int num_resources, void *pdata, |
179 | size_t pdata_size, struct device *dev) | 158 | size_t pdata_size, struct device *dev) |
@@ -529,7 +508,8 @@ static int usbhs_omap_get_dt_pdata(struct device *dev, | |||
529 | if (ret < 0) | 508 | if (ret < 0) |
530 | continue; | 509 | continue; |
531 | 510 | ||
532 | ret = omap_usbhs_get_dt_port_mode(mode); | 511 | /* get 'enum usbhs_omap_port_mode' from port mode string */ |
512 | ret = match_string(port_modes, ARRAY_SIZE(port_modes), mode); | ||
533 | if (ret < 0) { | 513 | if (ret < 0) { |
534 | dev_warn(dev, "Invalid port%d-mode \"%s\" in device tree\n", | 514 | dev_warn(dev, "Invalid port%d-mode \"%s\" in device tree\n", |
535 | i, mode); | 515 | i, mode); |
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c index 44a5d66314c6..446713dbee27 100644 --- a/drivers/mfd/omap-usb-tll.c +++ b/drivers/mfd/omap-usb-tll.c | |||
@@ -108,9 +108,9 @@ | |||
108 | (x) != OMAP_EHCI_PORT_MODE_PHY) | 108 | (x) != OMAP_EHCI_PORT_MODE_PHY) |
109 | 109 | ||
110 | struct usbtll_omap { | 110 | struct usbtll_omap { |
111 | int nch; /* num. of channels */ | 111 | void __iomem *base; |
112 | struct clk **ch_clk; | 112 | int nch; /* num. of channels */ |
113 | void __iomem *base; | 113 | struct clk *ch_clk[0]; /* must be the last member */ |
114 | }; | 114 | }; |
115 | 115 | ||
116 | /*-------------------------------------------------------------------------*/ | 116 | /*-------------------------------------------------------------------------*/ |
@@ -216,53 +216,49 @@ static int usbtll_omap_probe(struct platform_device *pdev) | |||
216 | struct device *dev = &pdev->dev; | 216 | struct device *dev = &pdev->dev; |
217 | struct resource *res; | 217 | struct resource *res; |
218 | struct usbtll_omap *tll; | 218 | struct usbtll_omap *tll; |
219 | int ret = 0; | 219 | void __iomem *base; |
220 | int i, ver; | 220 | int i, nch, ver; |
221 | 221 | ||
222 | dev_dbg(dev, "starting TI HSUSB TLL Controller\n"); | 222 | dev_dbg(dev, "starting TI HSUSB TLL Controller\n"); |
223 | 223 | ||
224 | tll = devm_kzalloc(dev, sizeof(struct usbtll_omap), GFP_KERNEL); | ||
225 | if (!tll) { | ||
226 | dev_err(dev, "Memory allocation failed\n"); | ||
227 | return -ENOMEM; | ||
228 | } | ||
229 | |||
230 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 224 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
231 | tll->base = devm_ioremap_resource(dev, res); | 225 | base = devm_ioremap_resource(dev, res); |
232 | if (IS_ERR(tll->base)) | 226 | if (IS_ERR(base)) |
233 | return PTR_ERR(tll->base); | 227 | return PTR_ERR(base); |
234 | 228 | ||
235 | platform_set_drvdata(pdev, tll); | ||
236 | pm_runtime_enable(dev); | 229 | pm_runtime_enable(dev); |
237 | pm_runtime_get_sync(dev); | 230 | pm_runtime_get_sync(dev); |
238 | 231 | ||
239 | ver = usbtll_read(tll->base, OMAP_USBTLL_REVISION); | 232 | ver = usbtll_read(base, OMAP_USBTLL_REVISION); |
240 | switch (ver) { | 233 | switch (ver) { |
241 | case OMAP_USBTLL_REV1: | 234 | case OMAP_USBTLL_REV1: |
242 | case OMAP_USBTLL_REV4: | 235 | case OMAP_USBTLL_REV4: |
243 | tll->nch = OMAP_TLL_CHANNEL_COUNT; | 236 | nch = OMAP_TLL_CHANNEL_COUNT; |
244 | break; | 237 | break; |
245 | case OMAP_USBTLL_REV2: | 238 | case OMAP_USBTLL_REV2: |
246 | case OMAP_USBTLL_REV3: | 239 | case OMAP_USBTLL_REV3: |
247 | tll->nch = OMAP_REV2_TLL_CHANNEL_COUNT; | 240 | nch = OMAP_REV2_TLL_CHANNEL_COUNT; |
248 | break; | 241 | break; |
249 | default: | 242 | default: |
250 | tll->nch = OMAP_TLL_CHANNEL_COUNT; | 243 | nch = OMAP_TLL_CHANNEL_COUNT; |
251 | dev_dbg(dev, | 244 | dev_dbg(dev, "rev 0x%x not recognized, assuming %d channels\n", |
252 | "USB TLL Rev : 0x%x not recognized, assuming %d channels\n", | 245 | ver, nch); |
253 | ver, tll->nch); | ||
254 | break; | 246 | break; |
255 | } | 247 | } |
256 | 248 | ||
257 | tll->ch_clk = devm_kzalloc(dev, sizeof(struct clk *) * tll->nch, | 249 | tll = devm_kzalloc(dev, sizeof(*tll) + sizeof(tll->ch_clk[nch]), |
258 | GFP_KERNEL); | 250 | GFP_KERNEL); |
259 | if (!tll->ch_clk) { | 251 | if (!tll) { |
260 | ret = -ENOMEM; | 252 | pm_runtime_put_sync(dev); |
261 | dev_err(dev, "Couldn't allocate memory for channel clocks\n"); | 253 | pm_runtime_disable(dev); |
262 | goto err_clk_alloc; | 254 | return -ENOMEM; |
263 | } | 255 | } |
264 | 256 | ||
265 | for (i = 0; i < tll->nch; i++) { | 257 | tll->base = base; |
258 | tll->nch = nch; | ||
259 | platform_set_drvdata(pdev, tll); | ||
260 | |||
261 | for (i = 0; i < nch; i++) { | ||
266 | char clkname[] = "usb_tll_hs_usb_chx_clk"; | 262 | char clkname[] = "usb_tll_hs_usb_chx_clk"; |
267 | 263 | ||
268 | snprintf(clkname, sizeof(clkname), | 264 | snprintf(clkname, sizeof(clkname), |
@@ -282,12 +278,6 @@ static int usbtll_omap_probe(struct platform_device *pdev) | |||
282 | spin_unlock(&tll_lock); | 278 | spin_unlock(&tll_lock); |
283 | 279 | ||
284 | return 0; | 280 | return 0; |
285 | |||
286 | err_clk_alloc: | ||
287 | pm_runtime_put_sync(dev); | ||
288 | pm_runtime_disable(dev); | ||
289 | |||
290 | return ret; | ||
291 | } | 281 | } |
292 | 282 | ||
293 | /** | 283 | /** |
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c index f952dff6765f..0d2a88d53eed 100644 --- a/drivers/mfd/pcf50633-core.c +++ b/drivers/mfd/pcf50633-core.c | |||
@@ -242,8 +242,10 @@ static int pcf50633_probe(struct i2c_client *client, | |||
242 | 242 | ||
243 | for (i = 0; i < PCF50633_NUM_REGULATORS; i++) { | 243 | for (i = 0; i < PCF50633_NUM_REGULATORS; i++) { |
244 | pdev = platform_device_alloc("pcf50633-regulator", i); | 244 | pdev = platform_device_alloc("pcf50633-regulator", i); |
245 | if (!pdev) | 245 | if (!pdev) { |
246 | return -ENOMEM; | 246 | ret = -ENOMEM; |
247 | goto err2; | ||
248 | } | ||
247 | 249 | ||
248 | pdev->dev.parent = pcf->dev; | 250 | pdev->dev.parent = pcf->dev; |
249 | ret = platform_device_add_data(pdev, &pdata->reg_init_data[i], | 251 | ret = platform_device_add_data(pdev, &pdata->reg_init_data[i], |
@@ -269,6 +271,7 @@ static int pcf50633_probe(struct i2c_client *client, | |||
269 | 271 | ||
270 | err: | 272 | err: |
271 | platform_device_put(pdev); | 273 | platform_device_put(pdev); |
274 | err2: | ||
272 | for (j = 0; j < i; j++) | 275 | for (j = 0; j < i; j++) |
273 | platform_device_put(pcf->regulator_pdev[j]); | 276 | platform_device_put(pcf->regulator_pdev[j]); |
274 | 277 | ||
diff --git a/drivers/mfd/qcom-spmi-pmic.c b/drivers/mfd/qcom-spmi-pmic.c index 2022bdfa7ab4..e2e95de649a4 100644 --- a/drivers/mfd/qcom-spmi-pmic.c +++ b/drivers/mfd/qcom-spmi-pmic.c | |||
@@ -39,6 +39,9 @@ | |||
39 | #define PM8916_SUBTYPE 0x0b | 39 | #define PM8916_SUBTYPE 0x0b |
40 | #define PM8004_SUBTYPE 0x0c | 40 | #define PM8004_SUBTYPE 0x0c |
41 | #define PM8909_SUBTYPE 0x0d | 41 | #define PM8909_SUBTYPE 0x0d |
42 | #define PM8998_SUBTYPE 0x14 | ||
43 | #define PMI8998_SUBTYPE 0x15 | ||
44 | #define PM8005_SUBTYPE 0x18 | ||
42 | 45 | ||
43 | static const struct of_device_id pmic_spmi_id_table[] = { | 46 | static const struct of_device_id pmic_spmi_id_table[] = { |
44 | { .compatible = "qcom,spmi-pmic", .data = (void *)COMMON_SUBTYPE }, | 47 | { .compatible = "qcom,spmi-pmic", .data = (void *)COMMON_SUBTYPE }, |
@@ -55,6 +58,9 @@ static const struct of_device_id pmic_spmi_id_table[] = { | |||
55 | { .compatible = "qcom,pm8916", .data = (void *)PM8916_SUBTYPE }, | 58 | { .compatible = "qcom,pm8916", .data = (void *)PM8916_SUBTYPE }, |
56 | { .compatible = "qcom,pm8004", .data = (void *)PM8004_SUBTYPE }, | 59 | { .compatible = "qcom,pm8004", .data = (void *)PM8004_SUBTYPE }, |
57 | { .compatible = "qcom,pm8909", .data = (void *)PM8909_SUBTYPE }, | 60 | { .compatible = "qcom,pm8909", .data = (void *)PM8909_SUBTYPE }, |
61 | { .compatible = "qcom,pm8998", .data = (void *)PM8998_SUBTYPE }, | ||
62 | { .compatible = "qcom,pmi8998", .data = (void *)PMI8998_SUBTYPE }, | ||
63 | { .compatible = "qcom,pm8005", .data = (void *)PM8005_SUBTYPE }, | ||
58 | { } | 64 | { } |
59 | }; | 65 | }; |
60 | 66 | ||
diff --git a/drivers/mfd/rave-sp.c b/drivers/mfd/rave-sp.c index 5c858e784a89..36dcd98977d6 100644 --- a/drivers/mfd/rave-sp.c +++ b/drivers/mfd/rave-sp.c | |||
@@ -45,7 +45,9 @@ | |||
45 | #define RAVE_SP_DLE 0x10 | 45 | #define RAVE_SP_DLE 0x10 |
46 | 46 | ||
47 | #define RAVE_SP_MAX_DATA_SIZE 64 | 47 | #define RAVE_SP_MAX_DATA_SIZE 64 |
48 | #define RAVE_SP_CHECKSUM_SIZE 2 /* Worst case scenario on RDU2 */ | 48 | #define RAVE_SP_CHECKSUM_8B2C 1 |
49 | #define RAVE_SP_CHECKSUM_CCITT 2 | ||
50 | #define RAVE_SP_CHECKSUM_SIZE RAVE_SP_CHECKSUM_CCITT | ||
49 | /* | 51 | /* |
50 | * We don't store STX, ETX and unescaped bytes, so Rx is only | 52 | * We don't store STX, ETX and unescaped bytes, so Rx is only |
51 | * DATA + CSUM | 53 | * DATA + CSUM |
@@ -160,6 +162,8 @@ struct rave_sp_variant { | |||
160 | * @variant: Device variant specific information | 162 | * @variant: Device variant specific information |
161 | * @event_notifier_list: Input event notification chain | 163 | * @event_notifier_list: Input event notification chain |
162 | * | 164 | * |
165 | * @part_number_firmware: Firmware version | ||
166 | * @part_number_bootloader: Bootloader version | ||
163 | */ | 167 | */ |
164 | struct rave_sp { | 168 | struct rave_sp { |
165 | struct serdev_device *serdev; | 169 | struct serdev_device *serdev; |
@@ -171,8 +175,40 @@ struct rave_sp { | |||
171 | 175 | ||
172 | const struct rave_sp_variant *variant; | 176 | const struct rave_sp_variant *variant; |
173 | struct blocking_notifier_head event_notifier_list; | 177 | struct blocking_notifier_head event_notifier_list; |
178 | |||
179 | const char *part_number_firmware; | ||
180 | const char *part_number_bootloader; | ||
174 | }; | 181 | }; |
175 | 182 | ||
183 | struct rave_sp_version { | ||
184 | u8 hardware; | ||
185 | __le16 major; | ||
186 | u8 minor; | ||
187 | u8 letter[2]; | ||
188 | } __packed; | ||
189 | |||
190 | struct rave_sp_status { | ||
191 | struct rave_sp_version bootloader_version; | ||
192 | struct rave_sp_version firmware_version; | ||
193 | u16 rdu_eeprom_flag; | ||
194 | u16 dds_eeprom_flag; | ||
195 | u8 pic_flag; | ||
196 | u8 orientation; | ||
197 | u32 etc; | ||
198 | s16 temp[2]; | ||
199 | u8 backlight_current[3]; | ||
200 | u8 dip_switch; | ||
201 | u8 host_interrupt; | ||
202 | u16 voltage_28; | ||
203 | u8 i2c_device_status; | ||
204 | u8 power_status; | ||
205 | u8 general_status; | ||
206 | u8 deprecated1; | ||
207 | u8 power_led_status; | ||
208 | u8 deprecated2; | ||
209 | u8 periph_power_shutoff; | ||
210 | } __packed; | ||
211 | |||
176 | static bool rave_sp_id_is_event(u8 code) | 212 | static bool rave_sp_id_is_event(u8 code) |
177 | { | 213 | { |
178 | return (code & 0xF0) == RAVE_SP_EVNT_BASE; | 214 | return (code & 0xF0) == RAVE_SP_EVNT_BASE; |
@@ -275,8 +311,8 @@ static int rave_sp_write(struct rave_sp *sp, const u8 *data, u8 data_size) | |||
275 | 311 | ||
276 | length = dest - frame; | 312 | length = dest - frame; |
277 | 313 | ||
278 | print_hex_dump(KERN_DEBUG, "rave-sp tx: ", DUMP_PREFIX_NONE, | 314 | print_hex_dump_debug("rave-sp tx: ", DUMP_PREFIX_NONE, |
279 | 16, 1, frame, length, false); | 315 | 16, 1, frame, length, false); |
280 | 316 | ||
281 | return serdev_device_write(sp->serdev, frame, length, HZ); | 317 | return serdev_device_write(sp->serdev, frame, length, HZ); |
282 | } | 318 | } |
@@ -415,10 +451,15 @@ static void rave_sp_receive_frame(struct rave_sp *sp, | |||
415 | const size_t payload_length = length - checksum_length; | 451 | const size_t payload_length = length - checksum_length; |
416 | const u8 *crc_reported = &data[payload_length]; | 452 | const u8 *crc_reported = &data[payload_length]; |
417 | struct device *dev = &sp->serdev->dev; | 453 | struct device *dev = &sp->serdev->dev; |
418 | u8 crc_calculated[checksum_length]; | 454 | u8 crc_calculated[RAVE_SP_CHECKSUM_SIZE]; |
455 | |||
456 | if (unlikely(checksum_length > sizeof(crc_calculated))) { | ||
457 | dev_warn(dev, "Checksum too long, dropping\n"); | ||
458 | return; | ||
459 | } | ||
419 | 460 | ||
420 | print_hex_dump(KERN_DEBUG, "rave-sp rx: ", DUMP_PREFIX_NONE, | 461 | print_hex_dump_debug("rave-sp rx: ", DUMP_PREFIX_NONE, |
421 | 16, 1, data, length, false); | 462 | 16, 1, data, length, false); |
422 | 463 | ||
423 | if (unlikely(length <= checksum_length)) { | 464 | if (unlikely(length <= checksum_length)) { |
424 | dev_warn(dev, "Dropping short frame\n"); | 465 | dev_warn(dev, "Dropping short frame\n"); |
@@ -512,8 +553,6 @@ static int rave_sp_receive_buf(struct serdev_device *serdev, | |||
512 | /* FALLTHROUGH */ | 553 | /* FALLTHROUGH */ |
513 | 554 | ||
514 | case RAVE_SP_EXPECT_ESCAPED_DATA: | 555 | case RAVE_SP_EXPECT_ESCAPED_DATA: |
515 | deframer->data[deframer->length++] = byte; | ||
516 | |||
517 | if (deframer->length == sizeof(deframer->data)) { | 556 | if (deframer->length == sizeof(deframer->data)) { |
518 | dev_warn(dev, "Bad frame: Too long\n"); | 557 | dev_warn(dev, "Bad frame: Too long\n"); |
519 | /* | 558 | /* |
@@ -528,6 +567,8 @@ static int rave_sp_receive_buf(struct serdev_device *serdev, | |||
528 | goto reset_framer; | 567 | goto reset_framer; |
529 | } | 568 | } |
530 | 569 | ||
570 | deframer->data[deframer->length++] = byte; | ||
571 | |||
531 | /* | 572 | /* |
532 | * We've extracted out special byte, now we | 573 | * We've extracted out special byte, now we |
533 | * can go back to regular data collecting | 574 | * can go back to regular data collecting |
@@ -609,6 +650,52 @@ static int rave_sp_default_cmd_translate(enum rave_sp_command command) | |||
609 | } | 650 | } |
610 | } | 651 | } |
611 | 652 | ||
653 | static const char *devm_rave_sp_version(struct device *dev, | ||
654 | struct rave_sp_version *version) | ||
655 | { | ||
656 | /* | ||
657 | * NOTE: The format string below uses %02d to display u16 | ||
658 | * intentionally for the sake of backwards compatibility with | ||
659 | * legacy software. | ||
660 | */ | ||
661 | return devm_kasprintf(dev, GFP_KERNEL, "%02d%02d%02d.%c%c\n", | ||
662 | version->hardware, | ||
663 | le16_to_cpu(version->major), | ||
664 | version->minor, | ||
665 | version->letter[0], | ||
666 | version->letter[1]); | ||
667 | } | ||
668 | |||
669 | static int rave_sp_get_status(struct rave_sp *sp) | ||
670 | { | ||
671 | struct device *dev = &sp->serdev->dev; | ||
672 | u8 cmd[] = { | ||
673 | [0] = RAVE_SP_CMD_STATUS, | ||
674 | [1] = 0 | ||
675 | }; | ||
676 | struct rave_sp_status status; | ||
677 | const char *version; | ||
678 | int ret; | ||
679 | |||
680 | ret = rave_sp_exec(sp, cmd, sizeof(cmd), &status, sizeof(status)); | ||
681 | if (ret) | ||
682 | return ret; | ||
683 | |||
684 | version = devm_rave_sp_version(dev, &status.firmware_version); | ||
685 | if (!version) | ||
686 | return -ENOMEM; | ||
687 | |||
688 | sp->part_number_firmware = version; | ||
689 | |||
690 | version = devm_rave_sp_version(dev, &status.bootloader_version); | ||
691 | if (!version) | ||
692 | return -ENOMEM; | ||
693 | |||
694 | sp->part_number_bootloader = version; | ||
695 | |||
696 | return 0; | ||
697 | } | ||
698 | |||
612 | static const struct rave_sp_checksum rave_sp_checksum_8b2c = { | 699 | static const struct rave_sp_checksum rave_sp_checksum_8b2c = { |
613 | .length = 1, | 700 | .length = 1, |
614 | .subroutine = csum_8b2c, | 701 | .subroutine = csum_8b2c, |
@@ -657,6 +744,7 @@ static const struct serdev_device_ops rave_sp_serdev_device_ops = { | |||
657 | static int rave_sp_probe(struct serdev_device *serdev) | 744 | static int rave_sp_probe(struct serdev_device *serdev) |
658 | { | 745 | { |
659 | struct device *dev = &serdev->dev; | 746 | struct device *dev = &serdev->dev; |
747 | const char *unknown = "unknown\n"; | ||
660 | struct rave_sp *sp; | 748 | struct rave_sp *sp; |
661 | u32 baud; | 749 | u32 baud; |
662 | int ret; | 750 | int ret; |
@@ -689,6 +777,20 @@ static int rave_sp_probe(struct serdev_device *serdev) | |||
689 | 777 | ||
690 | serdev_device_set_baudrate(serdev, baud); | 778 | serdev_device_set_baudrate(serdev, baud); |
691 | 779 | ||
780 | ret = rave_sp_get_status(sp); | ||
781 | if (ret) { | ||
782 | dev_warn(dev, "Failed to get firmware status: %d\n", ret); | ||
783 | sp->part_number_firmware = unknown; | ||
784 | sp->part_number_bootloader = unknown; | ||
785 | } | ||
786 | |||
787 | /* | ||
788 | * Those strings already have a \n embedded, so there's no | ||
789 | * need to have one in format string. | ||
790 | */ | ||
791 | dev_info(dev, "Firmware version: %s", sp->part_number_firmware); | ||
792 | dev_info(dev, "Bootloader version: %s", sp->part_number_bootloader); | ||
793 | |||
692 | return devm_of_platform_populate(dev); | 794 | return devm_of_platform_populate(dev); |
693 | } | 795 | } |
694 | 796 | ||
diff --git a/drivers/mfd/rc5t583.c b/drivers/mfd/rc5t583.c index d12243d5ecb8..fd46de02b715 100644 --- a/drivers/mfd/rc5t583.c +++ b/drivers/mfd/rc5t583.c | |||
@@ -258,11 +258,9 @@ static int rc5t583_i2c_probe(struct i2c_client *i2c, | |||
258 | return -EINVAL; | 258 | return -EINVAL; |
259 | } | 259 | } |
260 | 260 | ||
261 | rc5t583 = devm_kzalloc(&i2c->dev, sizeof(struct rc5t583), GFP_KERNEL); | 261 | rc5t583 = devm_kzalloc(&i2c->dev, sizeof(*rc5t583), GFP_KERNEL); |
262 | if (!rc5t583) { | 262 | if (!rc5t583) |
263 | dev_err(&i2c->dev, "Memory allocation failed\n"); | ||
264 | return -ENOMEM; | 263 | return -ENOMEM; |
265 | } | ||
266 | 264 | ||
267 | rc5t583->dev = &i2c->dev; | 265 | rc5t583->dev = &i2c->dev; |
268 | i2c_set_clientdata(i2c, rc5t583); | 266 | i2c_set_clientdata(i2c, rc5t583); |
diff --git a/drivers/mfd/si476x-i2c.c b/drivers/mfd/si476x-i2c.c index e6a3d999a376..2c5ec93333c3 100644 --- a/drivers/mfd/si476x-i2c.c +++ b/drivers/mfd/si476x-i2c.c | |||
@@ -697,11 +697,9 @@ static int si476x_core_probe(struct i2c_client *client, | |||
697 | int cell_num; | 697 | int cell_num; |
698 | 698 | ||
699 | core = devm_kzalloc(&client->dev, sizeof(*core), GFP_KERNEL); | 699 | core = devm_kzalloc(&client->dev, sizeof(*core), GFP_KERNEL); |
700 | if (!core) { | 700 | if (!core) |
701 | dev_err(&client->dev, | ||
702 | "failed to allocate 'struct si476x_core'\n"); | ||
703 | return -ENOMEM; | 701 | return -ENOMEM; |
704 | } | 702 | |
705 | core->client = client; | 703 | core->client = client; |
706 | 704 | ||
707 | core->regmap = devm_regmap_init_si476x(core); | 705 | core->regmap = devm_regmap_init_si476x(core); |
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c index ad774161a22d..55d19fd0994e 100644 --- a/drivers/mfd/sm501.c +++ b/drivers/mfd/sm501.c | |||
@@ -1050,13 +1050,13 @@ static int sm501_register_gpio(struct sm501_devdata *sm) | |||
1050 | spin_lock_init(&gpio->lock); | 1050 | spin_lock_init(&gpio->lock); |
1051 | 1051 | ||
1052 | gpio->regs_res = request_mem_region(iobase, 0x20, "sm501-gpio"); | 1052 | gpio->regs_res = request_mem_region(iobase, 0x20, "sm501-gpio"); |
1053 | if (gpio->regs_res == NULL) { | 1053 | if (!gpio->regs_res) { |
1054 | dev_err(sm->dev, "gpio: failed to request region\n"); | 1054 | dev_err(sm->dev, "gpio: failed to request region\n"); |
1055 | return -ENXIO; | 1055 | return -ENXIO; |
1056 | } | 1056 | } |
1057 | 1057 | ||
1058 | gpio->regs = ioremap(iobase, 0x20); | 1058 | gpio->regs = ioremap(iobase, 0x20); |
1059 | if (gpio->regs == NULL) { | 1059 | if (!gpio->regs) { |
1060 | dev_err(sm->dev, "gpio: failed to remap registers\n"); | 1060 | dev_err(sm->dev, "gpio: failed to remap registers\n"); |
1061 | ret = -ENXIO; | 1061 | ret = -ENXIO; |
1062 | goto err_claimed; | 1062 | goto err_claimed; |
@@ -1358,7 +1358,7 @@ static int sm501_init_dev(struct sm501_devdata *sm) | |||
1358 | sm501_register_gpio(sm); | 1358 | sm501_register_gpio(sm); |
1359 | } | 1359 | } |
1360 | 1360 | ||
1361 | if (pdata && pdata->gpio_i2c != NULL && pdata->gpio_i2c_nr > 0) { | 1361 | if (pdata && pdata->gpio_i2c && pdata->gpio_i2c_nr > 0) { |
1362 | if (!sm501_gpio_isregistered(sm)) | 1362 | if (!sm501_gpio_isregistered(sm)) |
1363 | dev_err(sm->dev, "no gpio available for i2c gpio.\n"); | 1363 | dev_err(sm->dev, "no gpio available for i2c gpio.\n"); |
1364 | else | 1364 | else |
@@ -1383,9 +1383,8 @@ static int sm501_plat_probe(struct platform_device *dev) | |||
1383 | struct sm501_devdata *sm; | 1383 | struct sm501_devdata *sm; |
1384 | int ret; | 1384 | int ret; |
1385 | 1385 | ||
1386 | sm = kzalloc(sizeof(struct sm501_devdata), GFP_KERNEL); | 1386 | sm = kzalloc(sizeof(*sm), GFP_KERNEL); |
1387 | if (sm == NULL) { | 1387 | if (!sm) { |
1388 | dev_err(&dev->dev, "no memory for device data\n"); | ||
1389 | ret = -ENOMEM; | 1388 | ret = -ENOMEM; |
1390 | goto err1; | 1389 | goto err1; |
1391 | } | 1390 | } |
@@ -1403,8 +1402,7 @@ static int sm501_plat_probe(struct platform_device *dev) | |||
1403 | 1402 | ||
1404 | sm->io_res = platform_get_resource(dev, IORESOURCE_MEM, 1); | 1403 | sm->io_res = platform_get_resource(dev, IORESOURCE_MEM, 1); |
1405 | sm->mem_res = platform_get_resource(dev, IORESOURCE_MEM, 0); | 1404 | sm->mem_res = platform_get_resource(dev, IORESOURCE_MEM, 0); |
1406 | 1405 | if (!sm->io_res || !sm->mem_res) { | |
1407 | if (sm->io_res == NULL || sm->mem_res == NULL) { | ||
1408 | dev_err(&dev->dev, "failed to get IO resource\n"); | 1406 | dev_err(&dev->dev, "failed to get IO resource\n"); |
1409 | ret = -ENOENT; | 1407 | ret = -ENOENT; |
1410 | goto err_res; | 1408 | goto err_res; |
@@ -1412,8 +1410,7 @@ static int sm501_plat_probe(struct platform_device *dev) | |||
1412 | 1410 | ||
1413 | sm->regs_claim = request_mem_region(sm->io_res->start, | 1411 | sm->regs_claim = request_mem_region(sm->io_res->start, |
1414 | 0x100, "sm501"); | 1412 | 0x100, "sm501"); |
1415 | 1413 | if (!sm->regs_claim) { | |
1416 | if (sm->regs_claim == NULL) { | ||
1417 | dev_err(&dev->dev, "cannot claim registers\n"); | 1414 | dev_err(&dev->dev, "cannot claim registers\n"); |
1418 | ret = -EBUSY; | 1415 | ret = -EBUSY; |
1419 | goto err_res; | 1416 | goto err_res; |
@@ -1422,8 +1419,7 @@ static int sm501_plat_probe(struct platform_device *dev) | |||
1422 | platform_set_drvdata(dev, sm); | 1419 | platform_set_drvdata(dev, sm); |
1423 | 1420 | ||
1424 | sm->regs = ioremap(sm->io_res->start, resource_size(sm->io_res)); | 1421 | sm->regs = ioremap(sm->io_res->start, resource_size(sm->io_res)); |
1425 | 1422 | if (!sm->regs) { | |
1426 | if (sm->regs == NULL) { | ||
1427 | dev_err(&dev->dev, "cannot remap registers\n"); | 1423 | dev_err(&dev->dev, "cannot remap registers\n"); |
1428 | ret = -EIO; | 1424 | ret = -EIO; |
1429 | goto err_claim; | 1425 | goto err_claim; |
@@ -1449,7 +1445,7 @@ static void sm501_set_power(struct sm501_devdata *sm, int on) | |||
1449 | { | 1445 | { |
1450 | struct sm501_platdata *pd = sm->platdata; | 1446 | struct sm501_platdata *pd = sm->platdata; |
1451 | 1447 | ||
1452 | if (pd == NULL) | 1448 | if (!pd) |
1453 | return; | 1449 | return; |
1454 | 1450 | ||
1455 | if (pd->get_power) { | 1451 | if (pd->get_power) { |
@@ -1573,9 +1569,8 @@ static int sm501_pci_probe(struct pci_dev *dev, | |||
1573 | struct sm501_devdata *sm; | 1569 | struct sm501_devdata *sm; |
1574 | int err; | 1570 | int err; |
1575 | 1571 | ||
1576 | sm = kzalloc(sizeof(struct sm501_devdata), GFP_KERNEL); | 1572 | sm = kzalloc(sizeof(*sm), GFP_KERNEL); |
1577 | if (sm == NULL) { | 1573 | if (!sm) { |
1578 | dev_err(&dev->dev, "no memory for device data\n"); | ||
1579 | err = -ENOMEM; | 1574 | err = -ENOMEM; |
1580 | goto err1; | 1575 | goto err1; |
1581 | } | 1576 | } |
@@ -1626,15 +1621,14 @@ static int sm501_pci_probe(struct pci_dev *dev, | |||
1626 | 1621 | ||
1627 | sm->regs_claim = request_mem_region(sm->io_res->start, | 1622 | sm->regs_claim = request_mem_region(sm->io_res->start, |
1628 | 0x100, "sm501"); | 1623 | 0x100, "sm501"); |
1629 | if (sm->regs_claim == NULL) { | 1624 | if (!sm->regs_claim) { |
1630 | dev_err(&dev->dev, "cannot claim registers\n"); | 1625 | dev_err(&dev->dev, "cannot claim registers\n"); |
1631 | err= -EBUSY; | 1626 | err= -EBUSY; |
1632 | goto err3; | 1627 | goto err3; |
1633 | } | 1628 | } |
1634 | 1629 | ||
1635 | sm->regs = pci_ioremap_bar(dev, 1); | 1630 | sm->regs = pci_ioremap_bar(dev, 1); |
1636 | 1631 | if (!sm->regs) { | |
1637 | if (sm->regs == NULL) { | ||
1638 | dev_err(&dev->dev, "cannot remap registers\n"); | 1632 | dev_err(&dev->dev, "cannot remap registers\n"); |
1639 | err = -EIO; | 1633 | err = -EIO; |
1640 | goto err4; | 1634 | goto err4; |
diff --git a/drivers/mfd/smsc-ece1099.c b/drivers/mfd/smsc-ece1099.c index 93a8297de52a..57b792eb58fd 100644 --- a/drivers/mfd/smsc-ece1099.c +++ b/drivers/mfd/smsc-ece1099.c | |||
@@ -37,12 +37,9 @@ static int smsc_i2c_probe(struct i2c_client *i2c, | |||
37 | int devid, rev, venid_l, venid_h; | 37 | int devid, rev, venid_l, venid_h; |
38 | int ret; | 38 | int ret; |
39 | 39 | ||
40 | smsc = devm_kzalloc(&i2c->dev, sizeof(struct smsc), | 40 | smsc = devm_kzalloc(&i2c->dev, sizeof(*smsc), GFP_KERNEL); |
41 | GFP_KERNEL); | 41 | if (!smsc) |
42 | if (!smsc) { | ||
43 | dev_err(&i2c->dev, "smsc mfd driver memory allocation failed\n"); | ||
44 | return -ENOMEM; | 42 | return -ENOMEM; |
45 | } | ||
46 | 43 | ||
47 | smsc->regmap = devm_regmap_init_i2c(i2c, &smsc_regmap_config); | 44 | smsc->regmap = devm_regmap_init_i2c(i2c, &smsc_regmap_config); |
48 | if (IS_ERR(smsc->regmap)) | 45 | if (IS_ERR(smsc->regmap)) |
diff --git a/drivers/mfd/sprd-sc27xx-spi.c b/drivers/mfd/sprd-sc27xx-spi.c index 56a4782f0569..3460ef07623c 100644 --- a/drivers/mfd/sprd-sc27xx-spi.c +++ b/drivers/mfd/sprd-sc27xx-spi.c | |||
@@ -111,6 +111,9 @@ static const struct mfd_cell sprd_pmic_devs[] = { | |||
111 | }, { | 111 | }, { |
112 | .name = "sc27xx-poweroff", | 112 | .name = "sc27xx-poweroff", |
113 | .of_compatible = "sprd,sc27xx-poweroff", | 113 | .of_compatible = "sprd,sc27xx-poweroff", |
114 | }, { | ||
115 | .name = "sc27xx-syscon", | ||
116 | .of_compatible = "sprd,sc27xx-syscon", | ||
114 | }, | 117 | }, |
115 | }; | 118 | }; |
116 | 119 | ||
diff --git a/drivers/mfd/stm32-timers.c b/drivers/mfd/stm32-timers.c index 1d347e5dfa79..efcd4b980c94 100644 --- a/drivers/mfd/stm32-timers.c +++ b/drivers/mfd/stm32-timers.c | |||
@@ -4,16 +4,156 @@ | |||
4 | * Author: Benjamin Gaignard <benjamin.gaignard@st.com> | 4 | * Author: Benjamin Gaignard <benjamin.gaignard@st.com> |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <linux/bitfield.h> | ||
7 | #include <linux/mfd/stm32-timers.h> | 8 | #include <linux/mfd/stm32-timers.h> |
8 | #include <linux/module.h> | 9 | #include <linux/module.h> |
9 | #include <linux/of_platform.h> | 10 | #include <linux/of_platform.h> |
10 | #include <linux/reset.h> | 11 | #include <linux/reset.h> |
11 | 12 | ||
13 | #define STM32_TIMERS_MAX_REGISTERS 0x3fc | ||
14 | |||
15 | /* DIER register DMA enable bits */ | ||
16 | static const u32 stm32_timers_dier_dmaen[STM32_TIMERS_MAX_DMAS] = { | ||
17 | TIM_DIER_CC1DE, | ||
18 | TIM_DIER_CC2DE, | ||
19 | TIM_DIER_CC3DE, | ||
20 | TIM_DIER_CC4DE, | ||
21 | TIM_DIER_UIE, | ||
22 | TIM_DIER_TDE, | ||
23 | TIM_DIER_COMDE | ||
24 | }; | ||
25 | |||
26 | static void stm32_timers_dma_done(void *p) | ||
27 | { | ||
28 | struct stm32_timers_dma *dma = p; | ||
29 | struct dma_tx_state state; | ||
30 | enum dma_status status; | ||
31 | |||
32 | status = dmaengine_tx_status(dma->chan, dma->chan->cookie, &state); | ||
33 | if (status == DMA_COMPLETE) | ||
34 | complete(&dma->completion); | ||
35 | } | ||
36 | |||
37 | /** | ||
38 | * stm32_timers_dma_burst_read - Read from timers registers using DMA. | ||
39 | * | ||
40 | * Read from STM32 timers registers using DMA on a single event. | ||
41 | * @dev: reference to stm32_timers MFD device | ||
42 | * @buf: DMA'able destination buffer | ||
43 | * @id: stm32_timers_dmas event identifier (ch[1..4], up, trig or com) | ||
44 | * @reg: registers start offset for DMA to read from (like CCRx for capture) | ||
45 | * @num_reg: number of registers to read upon each DMA request, starting @reg. | ||
46 | * @bursts: number of bursts to read (e.g. like two for pwm period capture) | ||
47 | * @tmo_ms: timeout (milliseconds) | ||
48 | */ | ||
49 | int stm32_timers_dma_burst_read(struct device *dev, u32 *buf, | ||
50 | enum stm32_timers_dmas id, u32 reg, | ||
51 | unsigned int num_reg, unsigned int bursts, | ||
52 | unsigned long tmo_ms) | ||
53 | { | ||
54 | struct stm32_timers *ddata = dev_get_drvdata(dev); | ||
55 | unsigned long timeout = msecs_to_jiffies(tmo_ms); | ||
56 | struct regmap *regmap = ddata->regmap; | ||
57 | struct stm32_timers_dma *dma = &ddata->dma; | ||
58 | size_t len = num_reg * bursts * sizeof(u32); | ||
59 | struct dma_async_tx_descriptor *desc; | ||
60 | struct dma_slave_config config; | ||
61 | dma_cookie_t cookie; | ||
62 | dma_addr_t dma_buf; | ||
63 | u32 dbl, dba; | ||
64 | long err; | ||
65 | int ret; | ||
66 | |||
67 | /* Sanity check */ | ||
68 | if (id < STM32_TIMERS_DMA_CH1 || id >= STM32_TIMERS_MAX_DMAS) | ||
69 | return -EINVAL; | ||
70 | |||
71 | if (!num_reg || !bursts || reg > STM32_TIMERS_MAX_REGISTERS || | ||
72 | (reg + num_reg * sizeof(u32)) > STM32_TIMERS_MAX_REGISTERS) | ||
73 | return -EINVAL; | ||
74 | |||
75 | if (!dma->chans[id]) | ||
76 | return -ENODEV; | ||
77 | mutex_lock(&dma->lock); | ||
78 | |||
79 | /* Select DMA channel in use */ | ||
80 | dma->chan = dma->chans[id]; | ||
81 | dma_buf = dma_map_single(dev, buf, len, DMA_FROM_DEVICE); | ||
82 | if (dma_mapping_error(dev, dma_buf)) { | ||
83 | ret = -ENOMEM; | ||
84 | goto unlock; | ||
85 | } | ||
86 | |||
87 | /* Prepare DMA read from timer registers, using DMA burst mode */ | ||
88 | memset(&config, 0, sizeof(config)); | ||
89 | config.src_addr = (dma_addr_t)dma->phys_base + TIM_DMAR; | ||
90 | config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | ||
91 | ret = dmaengine_slave_config(dma->chan, &config); | ||
92 | if (ret) | ||
93 | goto unmap; | ||
94 | |||
95 | desc = dmaengine_prep_slave_single(dma->chan, dma_buf, len, | ||
96 | DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT); | ||
97 | if (!desc) { | ||
98 | ret = -EBUSY; | ||
99 | goto unmap; | ||
100 | } | ||
101 | |||
102 | desc->callback = stm32_timers_dma_done; | ||
103 | desc->callback_param = dma; | ||
104 | cookie = dmaengine_submit(desc); | ||
105 | ret = dma_submit_error(cookie); | ||
106 | if (ret) | ||
107 | goto dma_term; | ||
108 | |||
109 | reinit_completion(&dma->completion); | ||
110 | dma_async_issue_pending(dma->chan); | ||
111 | |||
112 | /* Setup and enable timer DMA burst mode */ | ||
113 | dbl = FIELD_PREP(TIM_DCR_DBL, bursts - 1); | ||
114 | dba = FIELD_PREP(TIM_DCR_DBA, reg >> 2); | ||
115 | ret = regmap_write(regmap, TIM_DCR, dbl | dba); | ||
116 | if (ret) | ||
117 | goto dma_term; | ||
118 | |||
119 | /* Clear pending flags before enabling DMA request */ | ||
120 | ret = regmap_write(regmap, TIM_SR, 0); | ||
121 | if (ret) | ||
122 | goto dcr_clr; | ||
123 | |||
124 | ret = regmap_update_bits(regmap, TIM_DIER, stm32_timers_dier_dmaen[id], | ||
125 | stm32_timers_dier_dmaen[id]); | ||
126 | if (ret) | ||
127 | goto dcr_clr; | ||
128 | |||
129 | err = wait_for_completion_interruptible_timeout(&dma->completion, | ||
130 | timeout); | ||
131 | if (err == 0) | ||
132 | ret = -ETIMEDOUT; | ||
133 | else if (err < 0) | ||
134 | ret = err; | ||
135 | |||
136 | regmap_update_bits(regmap, TIM_DIER, stm32_timers_dier_dmaen[id], 0); | ||
137 | regmap_write(regmap, TIM_SR, 0); | ||
138 | dcr_clr: | ||
139 | regmap_write(regmap, TIM_DCR, 0); | ||
140 | dma_term: | ||
141 | dmaengine_terminate_all(dma->chan); | ||
142 | unmap: | ||
143 | dma_unmap_single(dev, dma_buf, len, DMA_FROM_DEVICE); | ||
144 | unlock: | ||
145 | dma->chan = NULL; | ||
146 | mutex_unlock(&dma->lock); | ||
147 | |||
148 | return ret; | ||
149 | } | ||
150 | EXPORT_SYMBOL_GPL(stm32_timers_dma_burst_read); | ||
151 | |||
12 | static const struct regmap_config stm32_timers_regmap_cfg = { | 152 | static const struct regmap_config stm32_timers_regmap_cfg = { |
13 | .reg_bits = 32, | 153 | .reg_bits = 32, |
14 | .val_bits = 32, | 154 | .val_bits = 32, |
15 | .reg_stride = sizeof(u32), | 155 | .reg_stride = sizeof(u32), |
16 | .max_register = 0x3fc, | 156 | .max_register = STM32_TIMERS_MAX_REGISTERS, |
17 | }; | 157 | }; |
18 | 158 | ||
19 | static void stm32_timers_get_arr_size(struct stm32_timers *ddata) | 159 | static void stm32_timers_get_arr_size(struct stm32_timers *ddata) |
@@ -27,12 +167,45 @@ static void stm32_timers_get_arr_size(struct stm32_timers *ddata) | |||
27 | regmap_write(ddata->regmap, TIM_ARR, 0x0); | 167 | regmap_write(ddata->regmap, TIM_ARR, 0x0); |
28 | } | 168 | } |
29 | 169 | ||
170 | static void stm32_timers_dma_probe(struct device *dev, | ||
171 | struct stm32_timers *ddata) | ||
172 | { | ||
173 | int i; | ||
174 | char name[4]; | ||
175 | |||
176 | init_completion(&ddata->dma.completion); | ||
177 | mutex_init(&ddata->dma.lock); | ||
178 | |||
179 | /* Optional DMA support: get valid DMA channel(s) or NULL */ | ||
180 | for (i = STM32_TIMERS_DMA_CH1; i <= STM32_TIMERS_DMA_CH4; i++) { | ||
181 | snprintf(name, ARRAY_SIZE(name), "ch%1d", i + 1); | ||
182 | ddata->dma.chans[i] = dma_request_slave_channel(dev, name); | ||
183 | } | ||
184 | ddata->dma.chans[STM32_TIMERS_DMA_UP] = | ||
185 | dma_request_slave_channel(dev, "up"); | ||
186 | ddata->dma.chans[STM32_TIMERS_DMA_TRIG] = | ||
187 | dma_request_slave_channel(dev, "trig"); | ||
188 | ddata->dma.chans[STM32_TIMERS_DMA_COM] = | ||
189 | dma_request_slave_channel(dev, "com"); | ||
190 | } | ||
191 | |||
192 | static void stm32_timers_dma_remove(struct device *dev, | ||
193 | struct stm32_timers *ddata) | ||
194 | { | ||
195 | int i; | ||
196 | |||
197 | for (i = STM32_TIMERS_DMA_CH1; i < STM32_TIMERS_MAX_DMAS; i++) | ||
198 | if (ddata->dma.chans[i]) | ||
199 | dma_release_channel(ddata->dma.chans[i]); | ||
200 | } | ||
201 | |||
30 | static int stm32_timers_probe(struct platform_device *pdev) | 202 | static int stm32_timers_probe(struct platform_device *pdev) |
31 | { | 203 | { |
32 | struct device *dev = &pdev->dev; | 204 | struct device *dev = &pdev->dev; |
33 | struct stm32_timers *ddata; | 205 | struct stm32_timers *ddata; |
34 | struct resource *res; | 206 | struct resource *res; |
35 | void __iomem *mmio; | 207 | void __iomem *mmio; |
208 | int ret; | ||
36 | 209 | ||
37 | ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); | 210 | ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); |
38 | if (!ddata) | 211 | if (!ddata) |
@@ -43,6 +216,9 @@ static int stm32_timers_probe(struct platform_device *pdev) | |||
43 | if (IS_ERR(mmio)) | 216 | if (IS_ERR(mmio)) |
44 | return PTR_ERR(mmio); | 217 | return PTR_ERR(mmio); |
45 | 218 | ||
219 | /* Timer physical addr for DMA */ | ||
220 | ddata->dma.phys_base = res->start; | ||
221 | |||
46 | ddata->regmap = devm_regmap_init_mmio_clk(dev, "int", mmio, | 222 | ddata->regmap = devm_regmap_init_mmio_clk(dev, "int", mmio, |
47 | &stm32_timers_regmap_cfg); | 223 | &stm32_timers_regmap_cfg); |
48 | if (IS_ERR(ddata->regmap)) | 224 | if (IS_ERR(ddata->regmap)) |
@@ -54,9 +230,29 @@ static int stm32_timers_probe(struct platform_device *pdev) | |||
54 | 230 | ||
55 | stm32_timers_get_arr_size(ddata); | 231 | stm32_timers_get_arr_size(ddata); |
56 | 232 | ||
233 | stm32_timers_dma_probe(dev, ddata); | ||
234 | |||
57 | platform_set_drvdata(pdev, ddata); | 235 | platform_set_drvdata(pdev, ddata); |
58 | 236 | ||
59 | return devm_of_platform_populate(&pdev->dev); | 237 | ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev); |
238 | if (ret) | ||
239 | stm32_timers_dma_remove(dev, ddata); | ||
240 | |||
241 | return ret; | ||
242 | } | ||
243 | |||
244 | static int stm32_timers_remove(struct platform_device *pdev) | ||
245 | { | ||
246 | struct stm32_timers *ddata = platform_get_drvdata(pdev); | ||
247 | |||
248 | /* | ||
249 | * Don't use devm_ here: enfore of_platform_depopulate() happens before | ||
250 | * DMA are released, to avoid race on DMA. | ||
251 | */ | ||
252 | of_platform_depopulate(&pdev->dev); | ||
253 | stm32_timers_dma_remove(&pdev->dev, ddata); | ||
254 | |||
255 | return 0; | ||
60 | } | 256 | } |
61 | 257 | ||
62 | static const struct of_device_id stm32_timers_of_match[] = { | 258 | static const struct of_device_id stm32_timers_of_match[] = { |
@@ -67,6 +263,7 @@ MODULE_DEVICE_TABLE(of, stm32_timers_of_match); | |||
67 | 263 | ||
68 | static struct platform_driver stm32_timers_driver = { | 264 | static struct platform_driver stm32_timers_driver = { |
69 | .probe = stm32_timers_probe, | 265 | .probe = stm32_timers_probe, |
266 | .remove = stm32_timers_remove, | ||
70 | .driver = { | 267 | .driver = { |
71 | .name = "stm32-timers", | 268 | .name = "stm32-timers", |
72 | .of_match_table = stm32_timers_of_match, | 269 | .of_match_table = stm32_timers_of_match, |
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index 7eaa40bc703f..b6d05cd934e6 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c | |||
@@ -106,9 +106,11 @@ static struct syscon *of_syscon_register(struct device_node *np) | |||
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | syscon_config.name = of_node_full_name(np); | ||
109 | syscon_config.reg_stride = reg_io_width; | 110 | syscon_config.reg_stride = reg_io_width; |
110 | syscon_config.val_bits = reg_io_width * 8; | 111 | syscon_config.val_bits = reg_io_width * 8; |
111 | syscon_config.max_register = resource_size(&res) - reg_io_width; | 112 | syscon_config.max_register = resource_size(&res) - reg_io_width; |
113 | syscon_config.name = of_node_full_name(np); | ||
112 | 114 | ||
113 | regmap = regmap_init_mmio(NULL, base, &syscon_config); | 115 | regmap = regmap_init_mmio(NULL, base, &syscon_config); |
114 | if (IS_ERR(regmap)) { | 116 | if (IS_ERR(regmap)) { |
diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c index 3cd958a31f36..47012c0899cd 100644 --- a/drivers/mfd/ti_am335x_tscadc.c +++ b/drivers/mfd/ti_am335x_tscadc.c | |||
@@ -169,10 +169,9 @@ static int ti_tscadc_probe(struct platform_device *pdev) | |||
169 | 169 | ||
170 | /* Allocate memory for device */ | 170 | /* Allocate memory for device */ |
171 | tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL); | 171 | tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL); |
172 | if (!tscadc) { | 172 | if (!tscadc) |
173 | dev_err(&pdev->dev, "failed to allocate memory.\n"); | ||
174 | return -ENOMEM; | 173 | return -ENOMEM; |
175 | } | 174 | |
176 | tscadc->dev = &pdev->dev; | 175 | tscadc->dev = &pdev->dev; |
177 | 176 | ||
178 | err = platform_get_irq(pdev, 0); | 177 | err = platform_get_irq(pdev, 0); |
diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index cd4a6d7d6750..7c13d2e7061c 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c | |||
@@ -777,7 +777,7 @@ static int timb_probe(struct pci_dev *dev, | |||
777 | &dev->resource[0], msix_entries[0].vector, NULL); | 777 | &dev->resource[0], msix_entries[0].vector, NULL); |
778 | break; | 778 | break; |
779 | default: | 779 | default: |
780 | dev_err(&dev->dev, "Uknown IP setup: %d.%d.%d\n", | 780 | dev_err(&dev->dev, "Unknown IP setup: %d.%d.%d\n", |
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; |
diff --git a/drivers/mfd/tps65090.c b/drivers/mfd/tps65090.c index d7ec318c40c3..f13e4cd06e89 100644 --- a/drivers/mfd/tps65090.c +++ b/drivers/mfd/tps65090.c | |||
@@ -192,10 +192,8 @@ static int tps65090_i2c_probe(struct i2c_client *client, | |||
192 | irq_base = pdata->irq_base; | 192 | irq_base = pdata->irq_base; |
193 | 193 | ||
194 | tps65090 = devm_kzalloc(&client->dev, sizeof(*tps65090), GFP_KERNEL); | 194 | tps65090 = devm_kzalloc(&client->dev, sizeof(*tps65090), GFP_KERNEL); |
195 | if (!tps65090) { | 195 | if (!tps65090) |
196 | dev_err(&client->dev, "mem alloc for tps65090 failed\n"); | ||
197 | return -ENOMEM; | 196 | return -ENOMEM; |
198 | } | ||
199 | 197 | ||
200 | tps65090->dev = &client->dev; | 198 | tps65090->dev = &client->dev; |
201 | i2c_set_clientdata(client, tps65090); | 199 | i2c_set_clientdata(client, tps65090); |
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c index 5628a6b5b19b..b89379782741 100644 --- a/drivers/mfd/tps6586x.c +++ b/drivers/mfd/tps6586x.c | |||
@@ -423,10 +423,8 @@ static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *clien | |||
423 | struct tps6586x_platform_data *pdata; | 423 | struct tps6586x_platform_data *pdata; |
424 | 424 | ||
425 | pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); | 425 | pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); |
426 | if (!pdata) { | 426 | if (!pdata) |
427 | dev_err(&client->dev, "Memory allocation failed\n"); | ||
428 | return NULL; | 427 | return NULL; |
429 | } | ||
430 | 428 | ||
431 | pdata->num_subdevs = 0; | 429 | pdata->num_subdevs = 0; |
432 | pdata->subdevs = NULL; | 430 | pdata->subdevs = NULL; |
diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c index 8263605f6d2f..bf16cbe6fd88 100644 --- a/drivers/mfd/tps65910.c +++ b/drivers/mfd/tps65910.c | |||
@@ -229,7 +229,7 @@ static struct regmap_irq_chip tps65910_irq_chip = { | |||
229 | static int tps65910_irq_init(struct tps65910 *tps65910, int irq, | 229 | static int tps65910_irq_init(struct tps65910 *tps65910, int irq, |
230 | struct tps65910_platform_data *pdata) | 230 | struct tps65910_platform_data *pdata) |
231 | { | 231 | { |
232 | int ret = 0; | 232 | int ret; |
233 | static struct regmap_irq_chip *tps6591x_irqs_chip; | 233 | static struct regmap_irq_chip *tps6591x_irqs_chip; |
234 | 234 | ||
235 | if (!irq) { | 235 | if (!irq) { |
@@ -312,14 +312,14 @@ static int tps65910_ck32k_init(struct tps65910 *tps65910, | |||
312 | static int tps65910_sleepinit(struct tps65910 *tps65910, | 312 | static int tps65910_sleepinit(struct tps65910 *tps65910, |
313 | struct tps65910_board *pmic_pdata) | 313 | struct tps65910_board *pmic_pdata) |
314 | { | 314 | { |
315 | struct device *dev = NULL; | 315 | struct device *dev; |
316 | int ret = 0; | 316 | int ret; |
317 | |||
318 | dev = tps65910->dev; | ||
319 | 317 | ||
320 | if (!pmic_pdata->en_dev_slp) | 318 | if (!pmic_pdata->en_dev_slp) |
321 | return 0; | 319 | return 0; |
322 | 320 | ||
321 | dev = tps65910->dev; | ||
322 | |||
323 | /* enabling SLEEP device state */ | 323 | /* enabling SLEEP device state */ |
324 | ret = tps65910_reg_set_bits(tps65910, TPS65910_DEVCTRL, | 324 | ret = tps65910_reg_set_bits(tps65910, TPS65910_DEVCTRL, |
325 | DEVCTRL_DEV_SLP_MASK); | 325 | DEVCTRL_DEV_SLP_MASK); |
@@ -383,7 +383,7 @@ static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client, | |||
383 | struct tps65910_board *board_info; | 383 | struct tps65910_board *board_info; |
384 | unsigned int prop; | 384 | unsigned int prop; |
385 | const struct of_device_id *match; | 385 | const struct of_device_id *match; |
386 | int ret = 0; | 386 | int ret; |
387 | 387 | ||
388 | match = of_match_device(tps65910_of_match, &client->dev); | 388 | match = of_match_device(tps65910_of_match, &client->dev); |
389 | if (!match) { | 389 | if (!match) { |
@@ -395,10 +395,8 @@ static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client, | |||
395 | 395 | ||
396 | board_info = devm_kzalloc(&client->dev, sizeof(*board_info), | 396 | board_info = devm_kzalloc(&client->dev, sizeof(*board_info), |
397 | GFP_KERNEL); | 397 | GFP_KERNEL); |
398 | if (!board_info) { | 398 | if (!board_info) |
399 | dev_err(&client->dev, "Failed to allocate pdata\n"); | ||
400 | return NULL; | 399 | return NULL; |
401 | } | ||
402 | 400 | ||
403 | ret = of_property_read_u32(np, "ti,vmbch-threshold", &prop); | 401 | ret = of_property_read_u32(np, "ti,vmbch-threshold", &prop); |
404 | if (!ret) | 402 | if (!ret) |
@@ -462,7 +460,7 @@ static int tps65910_i2c_probe(struct i2c_client *i2c, | |||
462 | struct tps65910_board *of_pmic_plat_data = NULL; | 460 | struct tps65910_board *of_pmic_plat_data = NULL; |
463 | struct tps65910_platform_data *init_data; | 461 | struct tps65910_platform_data *init_data; |
464 | unsigned long chip_id = id->driver_data; | 462 | unsigned long chip_id = id->driver_data; |
465 | int ret = 0; | 463 | int ret; |
466 | 464 | ||
467 | pmic_plat_data = dev_get_platdata(&i2c->dev); | 465 | pmic_plat_data = dev_get_platdata(&i2c->dev); |
468 | 466 | ||
diff --git a/drivers/mfd/tps65911-comparator.c b/drivers/mfd/tps65911-comparator.c index c0789f81a1c5..33591767fb9b 100644 --- a/drivers/mfd/tps65911-comparator.c +++ b/drivers/mfd/tps65911-comparator.c | |||
@@ -22,9 +22,8 @@ | |||
22 | #include <linux/gpio.h> | 22 | #include <linux/gpio.h> |
23 | #include <linux/mfd/tps65910.h> | 23 | #include <linux/mfd/tps65910.h> |
24 | 24 | ||
25 | #define COMP 0 | 25 | #define COMP1 0 |
26 | #define COMP1 1 | 26 | #define COMP2 1 |
27 | #define COMP2 2 | ||
28 | 27 | ||
29 | /* Comparator 1 voltage selection table in millivolts */ | 28 | /* Comparator 1 voltage selection table in millivolts */ |
30 | static const u16 COMP_VSEL_TABLE[] = { | 29 | static const u16 COMP_VSEL_TABLE[] = { |
@@ -63,9 +62,6 @@ static int comp_threshold_set(struct tps65910 *tps65910, int id, int voltage) | |||
63 | int ret; | 62 | int ret; |
64 | u8 index = 0, val; | 63 | u8 index = 0, val; |
65 | 64 | ||
66 | if (id == COMP) | ||
67 | return 0; | ||
68 | |||
69 | while (curr_voltage < tps_comp.uV_max) { | 65 | while (curr_voltage < tps_comp.uV_max) { |
70 | curr_voltage = tps_comp.vsel_table[index]; | 66 | curr_voltage = tps_comp.vsel_table[index]; |
71 | if (curr_voltage >= voltage) | 67 | if (curr_voltage >= voltage) |
@@ -78,7 +74,7 @@ static int comp_threshold_set(struct tps65910 *tps65910, int id, int voltage) | |||
78 | return -EINVAL; | 74 | return -EINVAL; |
79 | 75 | ||
80 | val = index << 1; | 76 | val = index << 1; |
81 | ret = tps65910->write(tps65910, tps_comp.reg, 1, &val); | 77 | ret = tps65910_reg_write(tps65910, tps_comp.reg, val); |
82 | 78 | ||
83 | return ret; | 79 | return ret; |
84 | } | 80 | } |
@@ -86,13 +82,10 @@ static int comp_threshold_set(struct tps65910 *tps65910, int id, int voltage) | |||
86 | static int comp_threshold_get(struct tps65910 *tps65910, int id) | 82 | static int comp_threshold_get(struct tps65910 *tps65910, int id) |
87 | { | 83 | { |
88 | struct comparator tps_comp = tps_comparators[id]; | 84 | struct comparator tps_comp = tps_comparators[id]; |
85 | unsigned int val; | ||
89 | int ret; | 86 | int ret; |
90 | u8 val; | ||
91 | |||
92 | if (id == COMP) | ||
93 | return 0; | ||
94 | 87 | ||
95 | ret = tps65910->read(tps65910, tps_comp.reg, 1, &val); | 88 | ret = tps65910_reg_read(tps65910, tps_comp.reg, &val); |
96 | if (ret < 0) | 89 | if (ret < 0) |
97 | return ret; | 90 | return ret; |
98 | 91 | ||
diff --git a/drivers/mfd/tps68470.c b/drivers/mfd/tps68470.c index 189efaea054c..a5981a79b29a 100644 --- a/drivers/mfd/tps68470.c +++ b/drivers/mfd/tps68470.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * TPS68470 chip Parent driver | 3 | * TPS68470 chip Parent driver |
3 | * | 4 | * |
@@ -8,15 +9,6 @@ | |||
8 | * Tianshu Qiu <tian.shu.qiu@intel.com> | 9 | * Tianshu Qiu <tian.shu.qiu@intel.com> |
9 | * Jian Xu Zheng <jian.xu.zheng@intel.com> | 10 | * Jian Xu Zheng <jian.xu.zheng@intel.com> |
10 | * Yuning Pu <yuning.pu@intel.com> | 11 | * Yuning Pu <yuning.pu@intel.com> |
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License as | ||
14 | * published by the Free Software Foundation version 2. | ||
15 | * | ||
16 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
17 | * kind, whether express or implied; without even the implied warranty | ||
18 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | */ | 12 | */ |
21 | 13 | ||
22 | #include <linux/acpi.h> | 14 | #include <linux/acpi.h> |
diff --git a/drivers/mfd/tps80031.c b/drivers/mfd/tps80031.c index 0812df3b0d47..608c7f77830e 100644 --- a/drivers/mfd/tps80031.c +++ b/drivers/mfd/tps80031.c | |||
@@ -431,10 +431,8 @@ static int tps80031_probe(struct i2c_client *client, | |||
431 | } | 431 | } |
432 | 432 | ||
433 | tps80031 = devm_kzalloc(&client->dev, sizeof(*tps80031), GFP_KERNEL); | 433 | tps80031 = devm_kzalloc(&client->dev, sizeof(*tps80031), GFP_KERNEL); |
434 | if (!tps80031) { | 434 | if (!tps80031) |
435 | dev_err(&client->dev, "Malloc failed for tps80031\n"); | ||
436 | return -ENOMEM; | 435 | return -ENOMEM; |
437 | } | ||
438 | 436 | ||
439 | for (i = 0; i < TPS80031_NUM_SLAVES; i++) { | 437 | for (i = 0; i < TPS80031_NUM_SLAVES; i++) { |
440 | if (tps80031_slave_address[i] == client->addr) | 438 | if (tps80031_slave_address[i] == client->addr) |
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index d3133a371e27..c649344fd7f2 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c | |||
@@ -1177,7 +1177,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1177 | twl_priv->ready = true; | 1177 | twl_priv->ready = true; |
1178 | 1178 | ||
1179 | /* setup clock framework */ | 1179 | /* setup clock framework */ |
1180 | clocks_init(&pdev->dev, pdata ? pdata->clock : NULL); | 1180 | clocks_init(&client->dev, pdata ? pdata->clock : NULL); |
1181 | 1181 | ||
1182 | /* read TWL IDCODE Register */ | 1182 | /* read TWL IDCODE Register */ |
1183 | if (twl_class_is_4030()) { | 1183 | if (twl_class_is_4030()) { |
diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c index e3ec8dfa9f1e..e939431ed10c 100644 --- a/drivers/mfd/twl6030-irq.c +++ b/drivers/mfd/twl6030-irq.c | |||
@@ -392,10 +392,8 @@ int twl6030_init_irq(struct device *dev, int irq_num) | |||
392 | nr_irqs = TWL6030_NR_IRQS; | 392 | nr_irqs = TWL6030_NR_IRQS; |
393 | 393 | ||
394 | twl6030_irq = devm_kzalloc(dev, sizeof(*twl6030_irq), GFP_KERNEL); | 394 | twl6030_irq = devm_kzalloc(dev, sizeof(*twl6030_irq), GFP_KERNEL); |
395 | if (!twl6030_irq) { | 395 | if (!twl6030_irq) |
396 | dev_err(dev, "twl6030_irq: Memory allocation failed\n"); | ||
397 | return -ENOMEM; | 396 | return -ENOMEM; |
398 | } | ||
399 | 397 | ||
400 | mask[0] = 0xFF; | 398 | mask[0] = 0xFF; |
401 | mask[1] = 0xFF; | 399 | mask[1] = 0xFF; |
diff --git a/drivers/mfd/viperboard.c b/drivers/mfd/viperboard.c index e6b3c70aeb22..e9f61262d583 100644 --- a/drivers/mfd/viperboard.c +++ b/drivers/mfd/viperboard.c | |||
@@ -59,10 +59,8 @@ static int vprbrd_probe(struct usb_interface *interface, | |||
59 | 59 | ||
60 | /* allocate memory for our device state and initialize it */ | 60 | /* allocate memory for our device state and initialize it */ |
61 | vb = kzalloc(sizeof(*vb), GFP_KERNEL); | 61 | vb = kzalloc(sizeof(*vb), GFP_KERNEL); |
62 | if (vb == NULL) { | 62 | if (!vb) |
63 | dev_err(&interface->dev, "Out of memory\n"); | ||
64 | return -ENOMEM; | 63 | return -ENOMEM; |
65 | } | ||
66 | 64 | ||
67 | mutex_init(&vb->lock); | 65 | mutex_init(&vb->lock); |
68 | 66 | ||
diff --git a/drivers/mfd/wm97xx-core.c b/drivers/mfd/wm97xx-core.c index 4141ee52a70b..f5a8347f837f 100644 --- a/drivers/mfd/wm97xx-core.c +++ b/drivers/mfd/wm97xx-core.c | |||
@@ -278,7 +278,7 @@ static int wm97xx_ac97_probe(struct ac97_codec_device *adev) | |||
278 | 278 | ||
279 | codec_pdata = &wm97xx->codec_pdata; | 279 | codec_pdata = &wm97xx->codec_pdata; |
280 | codec_pdata->ac97 = wm97xx->ac97; | 280 | codec_pdata->ac97 = wm97xx->ac97; |
281 | codec_pdata->batt_pdata = pdata->batt_pdata; | 281 | codec_pdata->batt_pdata = pdata ? pdata->batt_pdata : NULL; |
282 | 282 | ||
283 | switch (adev->vendor_id) { | 283 | switch (adev->vendor_id) { |
284 | case WM9705_VENDOR_ID: | 284 | case WM9705_VENDOR_ID: |
diff --git a/drivers/platform/chrome/cros_ec_debugfs.c b/drivers/platform/chrome/cros_ec_debugfs.c index cc265ed8deb7..c62ee8e610a0 100644 --- a/drivers/platform/chrome/cros_ec_debugfs.c +++ b/drivers/platform/chrome/cros_ec_debugfs.c | |||
@@ -470,3 +470,23 @@ void cros_ec_debugfs_remove(struct cros_ec_dev *ec) | |||
470 | cros_ec_cleanup_console_log(ec->debug_info); | 470 | cros_ec_cleanup_console_log(ec->debug_info); |
471 | } | 471 | } |
472 | EXPORT_SYMBOL(cros_ec_debugfs_remove); | 472 | EXPORT_SYMBOL(cros_ec_debugfs_remove); |
473 | |||
474 | void cros_ec_debugfs_suspend(struct cros_ec_dev *ec) | ||
475 | { | ||
476 | /* | ||
477 | * cros_ec_debugfs_init() failures are non-fatal; it's also possible | ||
478 | * that we initted things but decided that console log wasn't supported. | ||
479 | * We'll use the same set of checks that cros_ec_debugfs_remove() + | ||
480 | * cros_ec_cleanup_console_log() end up using to handle those cases. | ||
481 | */ | ||
482 | if (ec->debug_info && ec->debug_info->log_buffer.buf) | ||
483 | cancel_delayed_work_sync(&ec->debug_info->log_poll_work); | ||
484 | } | ||
485 | EXPORT_SYMBOL(cros_ec_debugfs_suspend); | ||
486 | |||
487 | void cros_ec_debugfs_resume(struct cros_ec_dev *ec) | ||
488 | { | ||
489 | if (ec->debug_info && ec->debug_info->log_buffer.buf) | ||
490 | schedule_delayed_work(&ec->debug_info->log_poll_work, 0); | ||
491 | } | ||
492 | EXPORT_SYMBOL(cros_ec_debugfs_resume); | ||
diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c index 2708212933f7..09383c6720fb 100644 --- a/drivers/pwm/pwm-stm32.c +++ b/drivers/pwm/pwm-stm32.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * pwm-atmel.c from Bo Shen | 8 | * pwm-atmel.c from Bo Shen |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/bitfield.h> | ||
11 | #include <linux/mfd/stm32-timers.h> | 12 | #include <linux/mfd/stm32-timers.h> |
12 | #include <linux/module.h> | 13 | #include <linux/module.h> |
13 | #include <linux/of.h> | 14 | #include <linux/of.h> |
@@ -25,6 +26,7 @@ struct stm32_pwm { | |||
25 | struct regmap *regmap; | 26 | struct regmap *regmap; |
26 | u32 max_arr; | 27 | u32 max_arr; |
27 | bool have_complementary_output; | 28 | bool have_complementary_output; |
29 | u32 capture[4] ____cacheline_aligned; /* DMA'able buffer */ | ||
28 | }; | 30 | }; |
29 | 31 | ||
30 | struct stm32_breakinput { | 32 | struct stm32_breakinput { |
@@ -62,6 +64,258 @@ static int write_ccrx(struct stm32_pwm *dev, int ch, u32 value) | |||
62 | return -EINVAL; | 64 | return -EINVAL; |
63 | } | 65 | } |
64 | 66 | ||
67 | #define TIM_CCER_CC12P (TIM_CCER_CC1P | TIM_CCER_CC2P) | ||
68 | #define TIM_CCER_CC12E (TIM_CCER_CC1E | TIM_CCER_CC2E) | ||
69 | #define TIM_CCER_CC34P (TIM_CCER_CC3P | TIM_CCER_CC4P) | ||
70 | #define TIM_CCER_CC34E (TIM_CCER_CC3E | TIM_CCER_CC4E) | ||
71 | |||
72 | /* | ||
73 | * Capture using PWM input mode: | ||
74 | * ___ ___ | ||
75 | * TI[1, 2, 3 or 4]: ........._| |________| | ||
76 | * ^0 ^1 ^2 | ||
77 | * . . . | ||
78 | * . . XXXXX | ||
79 | * . . XXXXX | | ||
80 | * . XXXXX . | | ||
81 | * XXXXX . . | | ||
82 | * COUNTER: ______XXXXX . . . |_XXX | ||
83 | * start^ . . . ^stop | ||
84 | * . . . . | ||
85 | * v v . v | ||
86 | * v | ||
87 | * CCR1/CCR3: tx..........t0...........t2 | ||
88 | * CCR2/CCR4: tx..............t1......... | ||
89 | * | ||
90 | * DMA burst transfer: | | | ||
91 | * v v | ||
92 | * DMA buffer: { t0, tx } { t2, t1 } | ||
93 | * DMA done: ^ | ||
94 | * | ||
95 | * 0: IC1/3 snapchot on rising edge: counter value -> CCR1/CCR3 | ||
96 | * + DMA transfer CCR[1/3] & CCR[2/4] values (t0, tx: doesn't care) | ||
97 | * 1: IC2/4 snapchot on falling edge: counter value -> CCR2/CCR4 | ||
98 | * 2: IC1/3 snapchot on rising edge: counter value -> CCR1/CCR3 | ||
99 | * + DMA transfer CCR[1/3] & CCR[2/4] values (t2, t1) | ||
100 | * | ||
101 | * DMA done, compute: | ||
102 | * - Period = t2 - t0 | ||
103 | * - Duty cycle = t1 - t0 | ||
104 | */ | ||
105 | static int stm32_pwm_raw_capture(struct stm32_pwm *priv, struct pwm_device *pwm, | ||
106 | unsigned long tmo_ms, u32 *raw_prd, | ||
107 | u32 *raw_dty) | ||
108 | { | ||
109 | struct device *parent = priv->chip.dev->parent; | ||
110 | enum stm32_timers_dmas dma_id; | ||
111 | u32 ccen, ccr; | ||
112 | int ret; | ||
113 | |||
114 | /* Ensure registers have been updated, enable counter and capture */ | ||
115 | regmap_update_bits(priv->regmap, TIM_EGR, TIM_EGR_UG, TIM_EGR_UG); | ||
116 | regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN, TIM_CR1_CEN); | ||
117 | |||
118 | /* Use cc1 or cc3 DMA resp for PWM input channels 1 & 2 or 3 & 4 */ | ||
119 | dma_id = pwm->hwpwm < 2 ? STM32_TIMERS_DMA_CH1 : STM32_TIMERS_DMA_CH3; | ||
120 | ccen = pwm->hwpwm < 2 ? TIM_CCER_CC12E : TIM_CCER_CC34E; | ||
121 | ccr = pwm->hwpwm < 2 ? TIM_CCR1 : TIM_CCR3; | ||
122 | regmap_update_bits(priv->regmap, TIM_CCER, ccen, ccen); | ||
123 | |||
124 | /* | ||
125 | * Timer DMA burst mode. Request 2 registers, 2 bursts, to get both | ||
126 | * CCR1 & CCR2 (or CCR3 & CCR4) on each capture event. | ||
127 | * We'll get two capture snapchots: { CCR1, CCR2 }, { CCR1, CCR2 } | ||
128 | * or { CCR3, CCR4 }, { CCR3, CCR4 } | ||
129 | */ | ||
130 | ret = stm32_timers_dma_burst_read(parent, priv->capture, dma_id, ccr, 2, | ||
131 | 2, tmo_ms); | ||
132 | if (ret) | ||
133 | goto stop; | ||
134 | |||
135 | /* Period: t2 - t0 (take care of counter overflow) */ | ||
136 | if (priv->capture[0] <= priv->capture[2]) | ||
137 | *raw_prd = priv->capture[2] - priv->capture[0]; | ||
138 | else | ||
139 | *raw_prd = priv->max_arr - priv->capture[0] + priv->capture[2]; | ||
140 | |||
141 | /* Duty cycle capture requires at least two capture units */ | ||
142 | if (pwm->chip->npwm < 2) | ||
143 | *raw_dty = 0; | ||
144 | else if (priv->capture[0] <= priv->capture[3]) | ||
145 | *raw_dty = priv->capture[3] - priv->capture[0]; | ||
146 | else | ||
147 | *raw_dty = priv->max_arr - priv->capture[0] + priv->capture[3]; | ||
148 | |||
149 | if (*raw_dty > *raw_prd) { | ||
150 | /* | ||
151 | * Race beetween PWM input and DMA: it may happen | ||
152 | * falling edge triggers new capture on TI2/4 before DMA | ||
153 | * had a chance to read CCR2/4. It means capture[1] | ||
154 | * contains period + duty_cycle. So, subtract period. | ||
155 | */ | ||
156 | *raw_dty -= *raw_prd; | ||
157 | } | ||
158 | |||
159 | stop: | ||
160 | regmap_update_bits(priv->regmap, TIM_CCER, ccen, 0); | ||
161 | regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN, 0); | ||
162 | |||
163 | return ret; | ||
164 | } | ||
165 | |||
166 | static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm, | ||
167 | struct pwm_capture *result, unsigned long tmo_ms) | ||
168 | { | ||
169 | struct stm32_pwm *priv = to_stm32_pwm_dev(chip); | ||
170 | unsigned long long prd, div, dty; | ||
171 | unsigned long rate; | ||
172 | unsigned int psc = 0, icpsc, scale; | ||
173 | u32 raw_prd = 0, raw_dty = 0; | ||
174 | int ret = 0; | ||
175 | |||
176 | mutex_lock(&priv->lock); | ||
177 | |||
178 | if (active_channels(priv)) { | ||
179 | ret = -EBUSY; | ||
180 | goto unlock; | ||
181 | } | ||
182 | |||
183 | ret = clk_enable(priv->clk); | ||
184 | if (ret) { | ||
185 | dev_err(priv->chip.dev, "failed to enable counter clock\n"); | ||
186 | goto unlock; | ||
187 | } | ||
188 | |||
189 | rate = clk_get_rate(priv->clk); | ||
190 | if (!rate) { | ||
191 | ret = -EINVAL; | ||
192 | goto clk_dis; | ||
193 | } | ||
194 | |||
195 | /* prescaler: fit timeout window provided by upper layer */ | ||
196 | div = (unsigned long long)rate * (unsigned long long)tmo_ms; | ||
197 | do_div(div, MSEC_PER_SEC); | ||
198 | prd = div; | ||
199 | while ((div > priv->max_arr) && (psc < MAX_TIM_PSC)) { | ||
200 | psc++; | ||
201 | div = prd; | ||
202 | do_div(div, psc + 1); | ||
203 | } | ||
204 | regmap_write(priv->regmap, TIM_ARR, priv->max_arr); | ||
205 | regmap_write(priv->regmap, TIM_PSC, psc); | ||
206 | |||
207 | /* Map TI1 or TI2 PWM input to IC1 & IC2 (or TI3/4 to IC3 & IC4) */ | ||
208 | regmap_update_bits(priv->regmap, | ||
209 | pwm->hwpwm < 2 ? TIM_CCMR1 : TIM_CCMR2, | ||
210 | TIM_CCMR_CC1S | TIM_CCMR_CC2S, pwm->hwpwm & 0x1 ? | ||
211 | TIM_CCMR_CC1S_TI2 | TIM_CCMR_CC2S_TI2 : | ||
212 | TIM_CCMR_CC1S_TI1 | TIM_CCMR_CC2S_TI1); | ||
213 | |||
214 | /* Capture period on IC1/3 rising edge, duty cycle on IC2/4 falling. */ | ||
215 | regmap_update_bits(priv->regmap, TIM_CCER, pwm->hwpwm < 2 ? | ||
216 | TIM_CCER_CC12P : TIM_CCER_CC34P, pwm->hwpwm < 2 ? | ||
217 | TIM_CCER_CC2P : TIM_CCER_CC4P); | ||
218 | |||
219 | ret = stm32_pwm_raw_capture(priv, pwm, tmo_ms, &raw_prd, &raw_dty); | ||
220 | if (ret) | ||
221 | goto stop; | ||
222 | |||
223 | /* | ||
224 | * Got a capture. Try to improve accuracy at high rates: | ||
225 | * - decrease counter clock prescaler, scale up to max rate. | ||
226 | * - use input prescaler, capture once every /2 /4 or /8 edges. | ||
227 | */ | ||
228 | if (raw_prd) { | ||
229 | u32 max_arr = priv->max_arr - 0x1000; /* arbitrary margin */ | ||
230 | |||
231 | scale = max_arr / min(max_arr, raw_prd); | ||
232 | } else { | ||
233 | scale = priv->max_arr; /* bellow resolution, use max scale */ | ||
234 | } | ||
235 | |||
236 | if (psc && scale > 1) { | ||
237 | /* 2nd measure with new scale */ | ||
238 | psc /= scale; | ||
239 | regmap_write(priv->regmap, TIM_PSC, psc); | ||
240 | ret = stm32_pwm_raw_capture(priv, pwm, tmo_ms, &raw_prd, | ||
241 | &raw_dty); | ||
242 | if (ret) | ||
243 | goto stop; | ||
244 | } | ||
245 | |||
246 | /* Compute intermediate period not to exceed timeout at low rates */ | ||
247 | prd = (unsigned long long)raw_prd * (psc + 1) * NSEC_PER_SEC; | ||
248 | do_div(prd, rate); | ||
249 | |||
250 | for (icpsc = 0; icpsc < MAX_TIM_ICPSC ; icpsc++) { | ||
251 | /* input prescaler: also keep arbitrary margin */ | ||
252 | if (raw_prd >= (priv->max_arr - 0x1000) >> (icpsc + 1)) | ||
253 | break; | ||
254 | if (prd >= (tmo_ms * NSEC_PER_MSEC) >> (icpsc + 2)) | ||
255 | break; | ||
256 | } | ||
257 | |||
258 | if (!icpsc) | ||
259 | goto done; | ||
260 | |||
261 | /* Last chance to improve period accuracy, using input prescaler */ | ||
262 | regmap_update_bits(priv->regmap, | ||
263 | pwm->hwpwm < 2 ? TIM_CCMR1 : TIM_CCMR2, | ||
264 | TIM_CCMR_IC1PSC | TIM_CCMR_IC2PSC, | ||
265 | FIELD_PREP(TIM_CCMR_IC1PSC, icpsc) | | ||
266 | FIELD_PREP(TIM_CCMR_IC2PSC, icpsc)); | ||
267 | |||
268 | ret = stm32_pwm_raw_capture(priv, pwm, tmo_ms, &raw_prd, &raw_dty); | ||
269 | if (ret) | ||
270 | goto stop; | ||
271 | |||
272 | if (raw_dty >= (raw_prd >> icpsc)) { | ||
273 | /* | ||
274 | * We may fall here using input prescaler, when input | ||
275 | * capture starts on high side (before falling edge). | ||
276 | * Example with icpsc to capture on each 4 events: | ||
277 | * | ||
278 | * start 1st capture 2nd capture | ||
279 | * v v v | ||
280 | * ___ _____ _____ _____ _____ ____ | ||
281 | * TI1..4 |__| |__| |__| |__| |__| | ||
282 | * v v . . . . . v v | ||
283 | * icpsc1/3: . 0 . 1 . 2 . 3 . 0 | ||
284 | * icpsc2/4: 0 1 2 3 0 | ||
285 | * v v v v | ||
286 | * CCR1/3 ......t0..............................t2 | ||
287 | * CCR2/4 ..t1..............................t1'... | ||
288 | * . . . | ||
289 | * Capture0: .<----------------------------->. | ||
290 | * Capture1: .<-------------------------->. . | ||
291 | * . . . | ||
292 | * Period: .<------> . . | ||
293 | * Low side: .<>. | ||
294 | * | ||
295 | * Result: | ||
296 | * - Period = Capture0 / icpsc | ||
297 | * - Duty = Period - Low side = Period - (Capture0 - Capture1) | ||
298 | */ | ||
299 | raw_dty = (raw_prd >> icpsc) - (raw_prd - raw_dty); | ||
300 | } | ||
301 | |||
302 | done: | ||
303 | prd = (unsigned long long)raw_prd * (psc + 1) * NSEC_PER_SEC; | ||
304 | result->period = DIV_ROUND_UP_ULL(prd, rate << icpsc); | ||
305 | dty = (unsigned long long)raw_dty * (psc + 1) * NSEC_PER_SEC; | ||
306 | result->duty_cycle = DIV_ROUND_UP_ULL(dty, rate); | ||
307 | stop: | ||
308 | regmap_write(priv->regmap, TIM_CCER, 0); | ||
309 | regmap_write(priv->regmap, pwm->hwpwm < 2 ? TIM_CCMR1 : TIM_CCMR2, 0); | ||
310 | regmap_write(priv->regmap, TIM_PSC, 0); | ||
311 | clk_dis: | ||
312 | clk_disable(priv->clk); | ||
313 | unlock: | ||
314 | mutex_unlock(&priv->lock); | ||
315 | |||
316 | return ret; | ||
317 | } | ||
318 | |||
65 | static int stm32_pwm_config(struct stm32_pwm *priv, int ch, | 319 | static int stm32_pwm_config(struct stm32_pwm *priv, int ch, |
66 | int duty_ns, int period_ns) | 320 | int duty_ns, int period_ns) |
67 | { | 321 | { |
@@ -230,6 +484,9 @@ static int stm32_pwm_apply_locked(struct pwm_chip *chip, struct pwm_device *pwm, | |||
230 | static const struct pwm_ops stm32pwm_ops = { | 484 | static const struct pwm_ops stm32pwm_ops = { |
231 | .owner = THIS_MODULE, | 485 | .owner = THIS_MODULE, |
232 | .apply = stm32_pwm_apply_locked, | 486 | .apply = stm32_pwm_apply_locked, |
487 | #if IS_ENABLED(CONFIG_DMA_ENGINE) | ||
488 | .capture = stm32_pwm_capture, | ||
489 | #endif | ||
233 | }; | 490 | }; |
234 | 491 | ||
235 | static int stm32_pwm_set_breakinput(struct stm32_pwm *priv, | 492 | static int stm32_pwm_set_breakinput(struct stm32_pwm *priv, |
diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c index 1a61fa56f3ad..385f8303bb41 100644 --- a/drivers/rtc/rtc-mt6397.c +++ b/drivers/rtc/rtc-mt6397.c | |||
@@ -322,10 +322,9 @@ static int mtk_rtc_probe(struct platform_device *pdev) | |||
322 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 322 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
323 | rtc->addr_base = res->start; | 323 | rtc->addr_base = res->start; |
324 | 324 | ||
325 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 325 | rtc->irq = platform_get_irq(pdev, 0); |
326 | rtc->irq = irq_create_mapping(mt6397_chip->irq_domain, res->start); | 326 | if (rtc->irq < 0) |
327 | if (rtc->irq <= 0) | 327 | return rtc->irq; |
328 | return -EINVAL; | ||
329 | 328 | ||
330 | rtc->regmap = mt6397_chip->regmap; | 329 | rtc->regmap = mt6397_chip->regmap; |
331 | rtc->dev = &pdev->dev; | 330 | rtc->dev = &pdev->dev; |
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h index f72dc53848d7..0013075d4cda 100644 --- a/include/linux/mfd/arizona/pdata.h +++ b/include/linux/mfd/arizona/pdata.h | |||
@@ -56,6 +56,7 @@ | |||
56 | #define ARIZONA_MAX_PDM_SPK 2 | 56 | #define ARIZONA_MAX_PDM_SPK 2 |
57 | 57 | ||
58 | struct regulator_init_data; | 58 | struct regulator_init_data; |
59 | struct gpio_desc; | ||
59 | 60 | ||
60 | struct arizona_micbias { | 61 | struct arizona_micbias { |
61 | int mV; /** Regulated voltage */ | 62 | int mV; /** Regulated voltage */ |
@@ -77,7 +78,7 @@ struct arizona_micd_range { | |||
77 | }; | 78 | }; |
78 | 79 | ||
79 | struct arizona_pdata { | 80 | struct arizona_pdata { |
80 | int reset; /** GPIO controlling /RESET, if any */ | 81 | struct gpio_desc *reset; /** GPIO controlling /RESET, if any */ |
81 | 82 | ||
82 | /** Regulator configuration for MICVDD */ | 83 | /** Regulator configuration for MICVDD */ |
83 | struct arizona_micsupp_pdata micvdd; | 84 | struct arizona_micsupp_pdata micvdd; |
diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h index 82bf7747b312..517e60eecbcb 100644 --- a/include/linux/mfd/axp20x.h +++ b/include/linux/mfd/axp20x.h | |||
@@ -592,11 +592,11 @@ enum axp806_irqs { | |||
592 | AXP806_IRQ_DCDCC_V_LOW, | 592 | AXP806_IRQ_DCDCC_V_LOW, |
593 | AXP806_IRQ_DCDCD_V_LOW, | 593 | AXP806_IRQ_DCDCD_V_LOW, |
594 | AXP806_IRQ_DCDCE_V_LOW, | 594 | AXP806_IRQ_DCDCE_V_LOW, |
595 | AXP806_IRQ_PWROK_LONG, | 595 | AXP806_IRQ_POK_LONG, |
596 | AXP806_IRQ_PWROK_SHORT, | 596 | AXP806_IRQ_POK_SHORT, |
597 | AXP806_IRQ_WAKEUP, | 597 | AXP806_IRQ_WAKEUP, |
598 | AXP806_IRQ_PWROK_FALL, | 598 | AXP806_IRQ_POK_FALL, |
599 | AXP806_IRQ_PWROK_RISE, | 599 | AXP806_IRQ_POK_RISE, |
600 | }; | 600 | }; |
601 | 601 | ||
602 | enum axp809_irqs { | 602 | enum axp809_irqs { |
@@ -642,7 +642,7 @@ struct axp20x_dev { | |||
642 | struct regmap_irq_chip_data *regmap_irqc; | 642 | struct regmap_irq_chip_data *regmap_irqc; |
643 | long variant; | 643 | long variant; |
644 | int nr_cells; | 644 | int nr_cells; |
645 | struct mfd_cell *cells; | 645 | const struct mfd_cell *cells; |
646 | const struct regmap_config *regmap_cfg; | 646 | const struct regmap_config *regmap_cfg; |
647 | const struct regmap_irq_chip *regmap_irq_chip; | 647 | const struct regmap_irq_chip *regmap_irq_chip; |
648 | }; | 648 | }; |
diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h index f09e9cf2e4ab..32421dfeb996 100644 --- a/include/linux/mfd/cros_ec.h +++ b/include/linux/mfd/cros_ec.h | |||
@@ -329,23 +329,7 @@ extern struct attribute_group cros_ec_vbc_attr_group; | |||
329 | /* debugfs stuff */ | 329 | /* debugfs stuff */ |
330 | int cros_ec_debugfs_init(struct cros_ec_dev *ec); | 330 | int cros_ec_debugfs_init(struct cros_ec_dev *ec); |
331 | void cros_ec_debugfs_remove(struct cros_ec_dev *ec); | 331 | void cros_ec_debugfs_remove(struct cros_ec_dev *ec); |
332 | 332 | void cros_ec_debugfs_suspend(struct cros_ec_dev *ec); | |
333 | /* ACPI GPE handler */ | 333 | void cros_ec_debugfs_resume(struct cros_ec_dev *ec); |
334 | #ifdef CONFIG_ACPI | ||
335 | |||
336 | int cros_ec_acpi_install_gpe_handler(struct device *dev); | ||
337 | void cros_ec_acpi_remove_gpe_handler(void); | ||
338 | void cros_ec_acpi_clear_gpe(void); | ||
339 | |||
340 | #else /* CONFIG_ACPI */ | ||
341 | |||
342 | static inline int cros_ec_acpi_install_gpe_handler(struct device *dev) | ||
343 | { | ||
344 | return -ENODEV; | ||
345 | } | ||
346 | static inline void cros_ec_acpi_remove_gpe_handler(void) {} | ||
347 | static inline void cros_ec_acpi_clear_gpe(void) {} | ||
348 | |||
349 | #endif /* CONFIG_ACPI */ | ||
350 | 334 | ||
351 | #endif /* __LINUX_MFD_CROS_EC_H */ | 335 | #endif /* __LINUX_MFD_CROS_EC_H */ |
diff --git a/include/linux/mfd/stm32-timers.h b/include/linux/mfd/stm32-timers.h index 2aadab6f34a1..067d14655c28 100644 --- a/include/linux/mfd/stm32-timers.h +++ b/include/linux/mfd/stm32-timers.h | |||
@@ -8,6 +8,8 @@ | |||
8 | #define _LINUX_STM32_GPTIMER_H_ | 8 | #define _LINUX_STM32_GPTIMER_H_ |
9 | 9 | ||
10 | #include <linux/clk.h> | 10 | #include <linux/clk.h> |
11 | #include <linux/dmaengine.h> | ||
12 | #include <linux/dma-mapping.h> | ||
11 | #include <linux/regmap.h> | 13 | #include <linux/regmap.h> |
12 | 14 | ||
13 | #define TIM_CR1 0x00 /* Control Register 1 */ | 15 | #define TIM_CR1 0x00 /* Control Register 1 */ |
@@ -27,6 +29,8 @@ | |||
27 | #define TIM_CCR3 0x3C /* Capt/Comp Register 3 */ | 29 | #define TIM_CCR3 0x3C /* Capt/Comp Register 3 */ |
28 | #define TIM_CCR4 0x40 /* Capt/Comp Register 4 */ | 30 | #define TIM_CCR4 0x40 /* Capt/Comp Register 4 */ |
29 | #define TIM_BDTR 0x44 /* Break and Dead-Time Reg */ | 31 | #define TIM_BDTR 0x44 /* Break and Dead-Time Reg */ |
32 | #define TIM_DCR 0x48 /* DMA control register */ | ||
33 | #define TIM_DMAR 0x4C /* DMA register for transfer */ | ||
30 | 34 | ||
31 | #define TIM_CR1_CEN BIT(0) /* Counter Enable */ | 35 | #define TIM_CR1_CEN BIT(0) /* Counter Enable */ |
32 | #define TIM_CR1_DIR BIT(4) /* Counter Direction */ | 36 | #define TIM_CR1_DIR BIT(4) /* Counter Direction */ |
@@ -36,17 +40,35 @@ | |||
36 | #define TIM_SMCR_SMS (BIT(0) | BIT(1) | BIT(2)) /* Slave mode selection */ | 40 | #define TIM_SMCR_SMS (BIT(0) | BIT(1) | BIT(2)) /* Slave mode selection */ |
37 | #define TIM_SMCR_TS (BIT(4) | BIT(5) | BIT(6)) /* Trigger selection */ | 41 | #define TIM_SMCR_TS (BIT(4) | BIT(5) | BIT(6)) /* Trigger selection */ |
38 | #define TIM_DIER_UIE BIT(0) /* Update interrupt */ | 42 | #define TIM_DIER_UIE BIT(0) /* Update interrupt */ |
43 | #define TIM_DIER_UDE BIT(8) /* Update DMA request Enable */ | ||
44 | #define TIM_DIER_CC1DE BIT(9) /* CC1 DMA request Enable */ | ||
45 | #define TIM_DIER_CC2DE BIT(10) /* CC2 DMA request Enable */ | ||
46 | #define TIM_DIER_CC3DE BIT(11) /* CC3 DMA request Enable */ | ||
47 | #define TIM_DIER_CC4DE BIT(12) /* CC4 DMA request Enable */ | ||
48 | #define TIM_DIER_COMDE BIT(13) /* COM DMA request Enable */ | ||
49 | #define TIM_DIER_TDE BIT(14) /* Trigger DMA request Enable */ | ||
39 | #define TIM_SR_UIF BIT(0) /* Update interrupt flag */ | 50 | #define TIM_SR_UIF BIT(0) /* Update interrupt flag */ |
40 | #define TIM_EGR_UG BIT(0) /* Update Generation */ | 51 | #define TIM_EGR_UG BIT(0) /* Update Generation */ |
41 | #define TIM_CCMR_PE BIT(3) /* Channel Preload Enable */ | 52 | #define TIM_CCMR_PE BIT(3) /* Channel Preload Enable */ |
42 | #define TIM_CCMR_M1 (BIT(6) | BIT(5)) /* Channel PWM Mode 1 */ | 53 | #define TIM_CCMR_M1 (BIT(6) | BIT(5)) /* Channel PWM Mode 1 */ |
54 | #define TIM_CCMR_CC1S (BIT(0) | BIT(1)) /* Capture/compare 1 sel */ | ||
55 | #define TIM_CCMR_IC1PSC GENMASK(3, 2) /* Input capture 1 prescaler */ | ||
56 | #define TIM_CCMR_CC2S (BIT(8) | BIT(9)) /* Capture/compare 2 sel */ | ||
57 | #define TIM_CCMR_IC2PSC GENMASK(11, 10) /* Input capture 2 prescaler */ | ||
58 | #define TIM_CCMR_CC1S_TI1 BIT(0) /* IC1/IC3 selects TI1/TI3 */ | ||
59 | #define TIM_CCMR_CC1S_TI2 BIT(1) /* IC1/IC3 selects TI2/TI4 */ | ||
60 | #define TIM_CCMR_CC2S_TI2 BIT(8) /* IC2/IC4 selects TI2/TI4 */ | ||
61 | #define TIM_CCMR_CC2S_TI1 BIT(9) /* IC2/IC4 selects TI1/TI3 */ | ||
43 | #define TIM_CCER_CC1E BIT(0) /* Capt/Comp 1 out Ena */ | 62 | #define TIM_CCER_CC1E BIT(0) /* Capt/Comp 1 out Ena */ |
44 | #define TIM_CCER_CC1P BIT(1) /* Capt/Comp 1 Polarity */ | 63 | #define TIM_CCER_CC1P BIT(1) /* Capt/Comp 1 Polarity */ |
45 | #define TIM_CCER_CC1NE BIT(2) /* Capt/Comp 1N out Ena */ | 64 | #define TIM_CCER_CC1NE BIT(2) /* Capt/Comp 1N out Ena */ |
46 | #define TIM_CCER_CC1NP BIT(3) /* Capt/Comp 1N Polarity */ | 65 | #define TIM_CCER_CC1NP BIT(3) /* Capt/Comp 1N Polarity */ |
47 | #define TIM_CCER_CC2E BIT(4) /* Capt/Comp 2 out Ena */ | 66 | #define TIM_CCER_CC2E BIT(4) /* Capt/Comp 2 out Ena */ |
67 | #define TIM_CCER_CC2P BIT(5) /* Capt/Comp 2 Polarity */ | ||
48 | #define TIM_CCER_CC3E BIT(8) /* Capt/Comp 3 out Ena */ | 68 | #define TIM_CCER_CC3E BIT(8) /* Capt/Comp 3 out Ena */ |
69 | #define TIM_CCER_CC3P BIT(9) /* Capt/Comp 3 Polarity */ | ||
49 | #define TIM_CCER_CC4E BIT(12) /* Capt/Comp 4 out Ena */ | 70 | #define TIM_CCER_CC4E BIT(12) /* Capt/Comp 4 out Ena */ |
71 | #define TIM_CCER_CC4P BIT(13) /* Capt/Comp 4 Polarity */ | ||
50 | #define TIM_CCER_CCXE (BIT(0) | BIT(4) | BIT(8) | BIT(12)) | 72 | #define TIM_CCER_CCXE (BIT(0) | BIT(4) | BIT(8) | BIT(12)) |
51 | #define TIM_BDTR_BKE BIT(12) /* Break input enable */ | 73 | #define TIM_BDTR_BKE BIT(12) /* Break input enable */ |
52 | #define TIM_BDTR_BKP BIT(13) /* Break input polarity */ | 74 | #define TIM_BDTR_BKP BIT(13) /* Break input polarity */ |
@@ -56,8 +78,11 @@ | |||
56 | #define TIM_BDTR_BK2F (BIT(20) | BIT(21) | BIT(22) | BIT(23)) | 78 | #define TIM_BDTR_BK2F (BIT(20) | BIT(21) | BIT(22) | BIT(23)) |
57 | #define TIM_BDTR_BK2E BIT(24) /* Break 2 input enable */ | 79 | #define TIM_BDTR_BK2E BIT(24) /* Break 2 input enable */ |
58 | #define TIM_BDTR_BK2P BIT(25) /* Break 2 input polarity */ | 80 | #define TIM_BDTR_BK2P BIT(25) /* Break 2 input polarity */ |
81 | #define TIM_DCR_DBA GENMASK(4, 0) /* DMA base addr */ | ||
82 | #define TIM_DCR_DBL GENMASK(12, 8) /* DMA burst len */ | ||
59 | 83 | ||
60 | #define MAX_TIM_PSC 0xFFFF | 84 | #define MAX_TIM_PSC 0xFFFF |
85 | #define MAX_TIM_ICPSC 0x3 | ||
61 | #define TIM_CR2_MMS_SHIFT 4 | 86 | #define TIM_CR2_MMS_SHIFT 4 |
62 | #define TIM_CR2_MMS2_SHIFT 20 | 87 | #define TIM_CR2_MMS2_SHIFT 20 |
63 | #define TIM_SMCR_TS_SHIFT 4 | 88 | #define TIM_SMCR_TS_SHIFT 4 |
@@ -65,9 +90,54 @@ | |||
65 | #define TIM_BDTR_BKF_SHIFT 16 | 90 | #define TIM_BDTR_BKF_SHIFT 16 |
66 | #define TIM_BDTR_BK2F_SHIFT 20 | 91 | #define TIM_BDTR_BK2F_SHIFT 20 |
67 | 92 | ||
93 | enum stm32_timers_dmas { | ||
94 | STM32_TIMERS_DMA_CH1, | ||
95 | STM32_TIMERS_DMA_CH2, | ||
96 | STM32_TIMERS_DMA_CH3, | ||
97 | STM32_TIMERS_DMA_CH4, | ||
98 | STM32_TIMERS_DMA_UP, | ||
99 | STM32_TIMERS_DMA_TRIG, | ||
100 | STM32_TIMERS_DMA_COM, | ||
101 | STM32_TIMERS_MAX_DMAS, | ||
102 | }; | ||
103 | |||
104 | /** | ||
105 | * struct stm32_timers_dma - STM32 timer DMA handling. | ||
106 | * @completion: end of DMA transfer completion | ||
107 | * @phys_base: control registers physical base address | ||
108 | * @lock: protect DMA access | ||
109 | * @chan: DMA channel in use | ||
110 | * @chans: DMA channels available for this timer instance | ||
111 | */ | ||
112 | struct stm32_timers_dma { | ||
113 | struct completion completion; | ||
114 | phys_addr_t phys_base; | ||
115 | struct mutex lock; | ||
116 | struct dma_chan *chan; | ||
117 | struct dma_chan *chans[STM32_TIMERS_MAX_DMAS]; | ||
118 | }; | ||
119 | |||
68 | struct stm32_timers { | 120 | struct stm32_timers { |
69 | struct clk *clk; | 121 | struct clk *clk; |
70 | struct regmap *regmap; | 122 | struct regmap *regmap; |
71 | u32 max_arr; | 123 | u32 max_arr; |
124 | struct stm32_timers_dma dma; /* Only to be used by the parent */ | ||
72 | }; | 125 | }; |
126 | |||
127 | #if IS_REACHABLE(CONFIG_MFD_STM32_TIMERS) | ||
128 | int stm32_timers_dma_burst_read(struct device *dev, u32 *buf, | ||
129 | enum stm32_timers_dmas id, u32 reg, | ||
130 | unsigned int num_reg, unsigned int bursts, | ||
131 | unsigned long tmo_ms); | ||
132 | #else | ||
133 | static inline int stm32_timers_dma_burst_read(struct device *dev, u32 *buf, | ||
134 | enum stm32_timers_dmas id, | ||
135 | u32 reg, | ||
136 | unsigned int num_reg, | ||
137 | unsigned int bursts, | ||
138 | unsigned long tmo_ms) | ||
139 | { | ||
140 | return -ENODEV; | ||
141 | } | ||
142 | #endif | ||
73 | #endif | 143 | #endif |
diff --git a/include/linux/mfd/syscon/exynos4-pmu.h b/include/linux/mfd/syscon/exynos4-pmu.h deleted file mode 100644 index 278b1b1549e9..000000000000 --- a/include/linux/mfd/syscon/exynos4-pmu.h +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Samsung Electronics Co., Ltd. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #ifndef _LINUX_MFD_SYSCON_PMU_EXYNOS4_H_ | ||
10 | #define _LINUX_MFD_SYSCON_PMU_EXYNOS4_H_ | ||
11 | |||
12 | /* Exynos4 PMU register definitions */ | ||
13 | |||
14 | /* MIPI_PHYn_CONTROL register offset: n = 0..1 */ | ||
15 | #define EXYNOS4_MIPI_PHY_CONTROL(n) (0x710 + (n) * 4) | ||
16 | #define EXYNOS4_MIPI_PHY_ENABLE (1 << 0) | ||
17 | #define EXYNOS4_MIPI_PHY_SRESETN (1 << 1) | ||
18 | #define EXYNOS4_MIPI_PHY_MRESETN (1 << 2) | ||
19 | #define EXYNOS4_MIPI_PHY_RESET_MASK (3 << 1) | ||
20 | |||
21 | #endif /* _LINUX_MFD_SYSCON_PMU_EXYNOS4_H_ */ | ||
diff --git a/include/linux/mfd/syscon/exynos5-pmu.h b/include/linux/mfd/syscon/exynos5-pmu.h deleted file mode 100644 index b4942a32b81d..000000000000 --- a/include/linux/mfd/syscon/exynos5-pmu.h +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | /* | ||
2 | * Exynos5 SoC series Power Management Unit (PMU) register offsets | ||
3 | * and bit definitions. | ||
4 | * | ||
5 | * Copyright (C) 2014 Samsung Electronics Co., Ltd. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #ifndef _LINUX_MFD_SYSCON_PMU_EXYNOS5_H_ | ||
13 | #define _LINUX_MFD_SYSCON_PMU_EXYNOS5_H_ | ||
14 | |||
15 | #define EXYNOS5_PHY_ENABLE BIT(0) | ||
16 | #define EXYNOS5_MIPI_PHY_S_RESETN BIT(1) | ||
17 | #define EXYNOS5_MIPI_PHY_M_RESETN BIT(2) | ||
18 | |||
19 | #endif /* _LINUX_MFD_SYSCON_PMU_EXYNOS5_H_ */ | ||
diff --git a/include/linux/mfd/tps65218.h b/include/linux/mfd/tps65218.h index f069c518c0ed..c204d9a79436 100644 --- a/include/linux/mfd/tps65218.h +++ b/include/linux/mfd/tps65218.h | |||
@@ -205,10 +205,10 @@ enum tps65218_regulator_id { | |||
205 | TPS65218_DCDC_4, | 205 | TPS65218_DCDC_4, |
206 | TPS65218_DCDC_5, | 206 | TPS65218_DCDC_5, |
207 | TPS65218_DCDC_6, | 207 | TPS65218_DCDC_6, |
208 | /* LS's */ | ||
209 | TPS65218_LS_3, | ||
210 | /* LDOs */ | 208 | /* LDOs */ |
211 | TPS65218_LDO_1, | 209 | TPS65218_LDO_1, |
210 | /* LS's */ | ||
211 | TPS65218_LS_3, | ||
212 | }; | 212 | }; |
213 | 213 | ||
214 | #define TPS65218_MAX_REG_ID TPS65218_LDO_1 | 214 | #define TPS65218_MAX_REG_ID TPS65218_LDO_1 |
diff --git a/include/linux/mfd/tps68470.h b/include/linux/mfd/tps68470.h index 44f9d9f647ed..ffe81127d91c 100644 --- a/include/linux/mfd/tps68470.h +++ b/include/linux/mfd/tps68470.h | |||
@@ -1,17 +1,6 @@ | |||
1 | /* | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | * Copyright (c) 2017 Intel Corporation | 2 | /* Copyright (C) 2017 Intel Corporation */ |
3 | * | 3 | /* Functions to access TPS68470 power management chip. */ |
4 | * Functions to access TPS68470 power management chip. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License as | ||
8 | * published by the Free Software Foundation version 2. | ||
9 | * | ||
10 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
11 | * kind, whether express or implied; without even the implied warranty | ||
12 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | */ | ||
15 | 4 | ||
16 | #ifndef __LINUX_MFD_TPS68470_H | 5 | #ifndef __LINUX_MFD_TPS68470_H |
17 | #define __LINUX_MFD_TPS68470_H | 6 | #define __LINUX_MFD_TPS68470_H |