Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'mfd-3.9-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6

Pull MFS updates from Samuel Ortiz:
"This is the MFD pull request for the 3.9 merge window.

No new drivers this time, but a bunch of fairly big cleanups:

- Roger Quadros worked on a OMAP USBHS and TLL platform data
consolidation, OMAP5 support and clock management code cleanup.

- The first step of a major sync for the ab8500 driver from Lee
Jones. In particular, the debugfs and the sysct interfaces got
extended and improved.

- Peter Ujfalusi sent a nice patchset for cleaning and fixing the
twl-core driver, with a much needed module id lookup code
improvement.

- The regular wm5102 and arizona cleanups and fixes from Mark Brown.

- Laxman Dewangan extended the palmas APIs in order to implement the
palmas GPIO and rt drivers.

- Laxman also added DT support for the tps65090 driver.

- The Intel SCH and ICH drivers got a couple fixes from Aaron Sierra
and Darren Hart.

- Linus Walleij patchset for the ab8500 driver allowed ab8500 and
ab9540 based devices to switch to the new abx500 pin-ctrl driver.

- The max8925 now has device tree and irqdomain support thanks to
Qing Xu.

- The recently added rtsx driver got a few cleanups and fixes for a
better card detection code path and now also supports the RTS5227
chipset, thanks to Wei Wang and Roger Tseng."

* tag 'mfd-3.9-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6: (109 commits)
mfd: lpc_ich: Use devres API to allocate private data
mfd: lpc_ich: Add Device IDs for Intel Wellsburg PCH
mfd: lpc_sch: Accomodate partial population of the MFD devices
mfd: da9052-i2c: Staticize da9052_i2c_fix()
mfd: syscon: Fix sparse warning
mfd: twl-core: Fix kernel panic on boot
mfd: rtsx: Fix issue that booting OS with SD card inserted
mfd: ab8500: Fix compile error
mfd: Add missing GENERIC_HARDIRQS dependecies
Documentation: Add docs for max8925 dt
mfd: max8925: Add dts
mfd: max8925: Support dt for backlight
mfd: max8925: Fix onkey driver irq base
mfd: max8925: Fix mfd device register failure
mfd: max8925: Add irqdomain for dt
mfd: vexpress: Allow vexpress-sysreg to self-initialise
mfd: rtsx: Support RTS5227
mfd: rtsx: Implement driving adjustment to device-dependent callbacks
mfd: vexpress: Add pseudo-GPIO based LEDs
mfd: ab8500: Rename ab8500 to abx500 for hwmon driver
...

+4311 -1063
+64
Documentation/devicetree/bindings/mfd/max8925.txt
··· 1 + * Maxim max8925 Power Management IC 2 + 3 + Required parent device properties: 4 + - compatible : "maxim,max8925" 5 + - reg : the I2C slave address for the max8925 chip 6 + - interrupts : IRQ line for the max8925 chip 7 + - interrupt-controller: describes the max8925 as an interrupt 8 + controller (has its own domain) 9 + - #interrupt-cells : should be 1. 10 + - The cell is the max8925 local IRQ number 11 + 12 + Optional parent device properties: 13 + - maxim,tsc-irq: there are 2 IRQ lines for max8925, one is indicated in 14 + interrupts property, the other is indicated here. 15 + 16 + max8925 consists of a large and varied group of sub-devices: 17 + 18 + Device Supply Names Description 19 + ------ ------------ ----------- 20 + max8925-onkey : : On key 21 + max8925-rtc : : RTC 22 + max8925-regulator : : Regulators 23 + max8925-backlight : : Backlight 24 + max8925-touch : : Touchscreen 25 + max8925-power : : Charger 26 + 27 + Example: 28 + 29 + pmic: max8925@3c { 30 + compatible = "maxim,max8925"; 31 + reg = <0x3c>; 32 + interrupts = <1>; 33 + interrupt-parent = <&intcmux4>; 34 + interrupt-controller; 35 + #interrupt-cells = <1>; 36 + maxim,tsc-irq = <0>; 37 + 38 + regulators { 39 + SDV1 { 40 + regulator-min-microvolt = <637500>; 41 + regulator-max-microvolt = <1425000>; 42 + regulator-boot-on; 43 + regulator-always-on; 44 + }; 45 + 46 + LDO1 { 47 + regulator-min-microvolt = <750000>; 48 + regulator-max-microvolt = <3900000>; 49 + regulator-boot-on; 50 + regulator-always-on; 51 + }; 52 + 53 + }; 54 + backlight { 55 + maxim,max8925-dual-string = <0>; 56 + }; 57 + charger { 58 + batt-detect = <0>; 59 + topoff-threshold = <1>; 60 + fast-charge = <7>; 61 + no-temp-support = <0>; 62 + no-insert-detect = <0>; 63 + }; 64 + };
+18
Documentation/devicetree/bindings/power_supply/max8925_batter.txt
··· 1 + max8925-battery bindings 2 + ~~~~~~~~~~~~~~~~ 3 + 4 + Optional properties : 5 + - batt-detect: whether support battery detect 6 + - topoff-threshold: set charging current in topoff mode 7 + - fast-charge: set charging current in fast mode 8 + - no-temp-support: whether support temperature protection detect 9 + - no-insert-detect: whether support insert detect 10 + 11 + Example: 12 + charger { 13 + batt-detect = <0>; 14 + topoff-threshold = <1>; 15 + fast-charge = <7>; 16 + no-temp-support = <0>; 17 + no-insert-detect = <0>; 18 + };
+122
Documentation/devicetree/bindings/regulator/tps65090.txt
··· 1 + TPS65090 regulators 2 + 3 + Required properties: 4 + - compatible: "ti,tps65090" 5 + - reg: I2C slave address 6 + - interrupts: the interrupt outputs of the controller 7 + - regulators: A node that houses a sub-node for each regulator within the 8 + device. Each sub-node is identified using the node's name, with valid 9 + values listed below. The content of each sub-node is defined by the 10 + standard binding for regulators; see regulator.txt. 11 + dcdc[1-3], fet[1-7] and ldo[1-2] respectively. 12 + - vsys[1-3]-supply: The input supply for DCDC[1-3] respectively. 13 + - infet[1-7]-supply: The input supply for FET[1-7] respectively. 14 + - vsys-l[1-2]-supply: The input supply for LDO[1-2] respectively. 15 + 16 + Optional properties: 17 + - ti,enable-ext-control: This is applicable for DCDC1, DCDC2 and DCDC3. 18 + If DCDCs are externally controlled then this property should be there. 19 + - "dcdc-ext-control-gpios: This is applicable for DCDC1, DCDC2 and DCDC3. 20 + If DCDCs are externally controlled and if it is from GPIO then GPIO 21 + number should be provided. If it is externally controlled and no GPIO 22 + entry then driver will just configure this rails as external control 23 + and will not provide any enable/disable APIs. 24 + 25 + Each regulator is defined using the standard binding for regulators. 26 + 27 + Example: 28 + 29 + tps65090@48 { 30 + compatible = "ti,tps65090"; 31 + reg = <0x48>; 32 + interrupts = <0 88 0x4>; 33 + 34 + vsys1-supply = <&some_reg>; 35 + vsys2-supply = <&some_reg>; 36 + vsys3-supply = <&some_reg>; 37 + infet1-supply = <&some_reg>; 38 + infet2-supply = <&some_reg>; 39 + infet3-supply = <&some_reg>; 40 + infet4-supply = <&some_reg>; 41 + infet5-supply = <&some_reg>; 42 + infet6-supply = <&some_reg>; 43 + infet7-supply = <&some_reg>; 44 + vsys_l1-supply = <&some_reg>; 45 + vsys_l2-supply = <&some_reg>; 46 + 47 + regulators { 48 + dcdc1 { 49 + regulator-name = "dcdc1"; 50 + regulator-boot-on; 51 + regulator-always-on; 52 + ti,enable-ext-control; 53 + dcdc-ext-control-gpios = <&gpio 10 0>; 54 + }; 55 + 56 + dcdc2 { 57 + regulator-name = "dcdc2"; 58 + regulator-boot-on; 59 + regulator-always-on; 60 + }; 61 + 62 + dcdc3 { 63 + regulator-name = "dcdc3"; 64 + regulator-boot-on; 65 + regulator-always-on; 66 + }; 67 + 68 + fet1 { 69 + regulator-name = "fet1"; 70 + regulator-boot-on; 71 + regulator-always-on; 72 + }; 73 + 74 + fet2 { 75 + regulator-name = "fet2"; 76 + regulator-boot-on; 77 + regulator-always-on; 78 + }; 79 + 80 + fet3 { 81 + regulator-name = "fet3"; 82 + regulator-boot-on; 83 + regulator-always-on; 84 + }; 85 + 86 + fet4 { 87 + regulator-name = "fet4"; 88 + regulator-boot-on; 89 + regulator-always-on; 90 + }; 91 + 92 + fet5 { 93 + regulator-name = "fet5"; 94 + regulator-boot-on; 95 + regulator-always-on; 96 + }; 97 + 98 + fet6 { 99 + regulator-name = "fet6"; 100 + regulator-boot-on; 101 + regulator-always-on; 102 + }; 103 + 104 + fet7 { 105 + regulator-name = "fet7"; 106 + regulator-boot-on; 107 + regulator-always-on; 108 + }; 109 + 110 + ldo1 { 111 + regulator-name = "ldo1"; 112 + regulator-boot-on; 113 + regulator-always-on; 114 + }; 115 + 116 + ldo2 { 117 + regulator-name = "ldo2"; 118 + regulator-boot-on; 119 + regulator-always-on; 120 + }; 121 + }; 122 + };
+10
Documentation/devicetree/bindings/video/backlight/max8925-backlight.txt
··· 1 + 88pm860x-backlight bindings 2 + 3 + Optional properties: 4 + - maxim,max8925-dual-string: whether support dual string 5 + 6 + Example: 7 + 8 + backlights { 9 + maxim,max8925-dual-string = <0>; 10 + };
+158
arch/arm/boot/dts/mmp2-brownstone.dts
··· 29 29 }; 30 30 twsi1: i2c@d4011000 { 31 31 status = "okay"; 32 + pmic: max8925@3c { 33 + compatible = "maxium,max8925"; 34 + reg = <0x3c>; 35 + interrupts = <1>; 36 + interrupt-parent = <&intcmux4>; 37 + interrupt-controller; 38 + #interrupt-cells = <1>; 39 + maxim,tsc-irq = <0>; 40 + 41 + regulators { 42 + SDV1 { 43 + regulator-min-microvolt = <637500>; 44 + regulator-max-microvolt = <1425000>; 45 + regulator-boot-on; 46 + regulator-always-on; 47 + }; 48 + SDV2 { 49 + regulator-min-microvolt = <650000>; 50 + regulator-max-microvolt = <2225000>; 51 + regulator-boot-on; 52 + regulator-always-on; 53 + }; 54 + SDV3 { 55 + regulator-min-microvolt = <750000>; 56 + regulator-max-microvolt = <3900000>; 57 + regulator-boot-on; 58 + regulator-always-on; 59 + }; 60 + LDO1 { 61 + regulator-min-microvolt = <750000>; 62 + regulator-max-microvolt = <3900000>; 63 + regulator-boot-on; 64 + regulator-always-on; 65 + }; 66 + LDO2 { 67 + regulator-min-microvolt = <650000>; 68 + regulator-max-microvolt = <2250000>; 69 + regulator-boot-on; 70 + regulator-always-on; 71 + }; 72 + LDO3 { 73 + regulator-min-microvolt = <650000>; 74 + regulator-max-microvolt = <2250000>; 75 + regulator-boot-on; 76 + regulator-always-on; 77 + }; 78 + LDO4 { 79 + regulator-min-microvolt = <750000>; 80 + regulator-max-microvolt = <3900000>; 81 + regulator-boot-on; 82 + regulator-always-on; 83 + }; 84 + LDO5 { 85 + regulator-min-microvolt = <750000>; 86 + regulator-max-microvolt = <3900000>; 87 + regulator-boot-on; 88 + regulator-always-on; 89 + }; 90 + LDO6 { 91 + regulator-min-microvolt = <750000>; 92 + regulator-max-microvolt = <3900000>; 93 + regulator-boot-on; 94 + regulator-always-on; 95 + }; 96 + LDO7 { 97 + regulator-min-microvolt = <750000>; 98 + regulator-max-microvolt = <3900000>; 99 + regulator-boot-on; 100 + regulator-always-on; 101 + }; 102 + LDO8 { 103 + regulator-min-microvolt = <750000>; 104 + regulator-max-microvolt = <3900000>; 105 + regulator-boot-on; 106 + regulator-always-on; 107 + }; 108 + LDO9 { 109 + regulator-min-microvolt = <750000>; 110 + regulator-max-microvolt = <3900000>; 111 + regulator-boot-on; 112 + regulator-always-on; 113 + }; 114 + LDO10 { 115 + regulator-min-microvolt = <750000>; 116 + regulator-max-microvolt = <3900000>; 117 + }; 118 + LDO11 { 119 + regulator-min-microvolt = <750000>; 120 + regulator-max-microvolt = <3900000>; 121 + regulator-boot-on; 122 + regulator-always-on; 123 + }; 124 + LDO12 { 125 + regulator-min-microvolt = <750000>; 126 + regulator-max-microvolt = <3900000>; 127 + regulator-boot-on; 128 + regulator-always-on; 129 + }; 130 + LDO13 { 131 + regulator-min-microvolt = <750000>; 132 + regulator-max-microvolt = <3900000>; 133 + regulator-boot-on; 134 + regulator-always-on; 135 + }; 136 + LDO14 { 137 + regulator-min-microvolt = <750000>; 138 + regulator-max-microvolt = <3900000>; 139 + regulator-boot-on; 140 + regulator-always-on; 141 + }; 142 + LDO15 { 143 + regulator-min-microvolt = <750000>; 144 + regulator-max-microvolt = <3900000>; 145 + regulator-boot-on; 146 + regulator-always-on; 147 + }; 148 + LDO16 { 149 + regulator-min-microvolt = <750000>; 150 + regulator-max-microvolt = <3900000>; 151 + regulator-boot-on; 152 + regulator-always-on; 153 + }; 154 + LDO17 { 155 + regulator-min-microvolt = <650000>; 156 + regulator-max-microvolt = <2250000>; 157 + regulator-boot-on; 158 + regulator-always-on; 159 + }; 160 + LDO18 { 161 + regulator-min-microvolt = <650000>; 162 + regulator-max-microvolt = <2250000>; 163 + regulator-boot-on; 164 + regulator-always-on; 165 + }; 166 + LDO19 { 167 + regulator-min-microvolt = <750000>; 168 + regulator-max-microvolt = <3900000>; 169 + regulator-boot-on; 170 + regulator-always-on; 171 + }; 172 + LDO20 { 173 + regulator-min-microvolt = <750000>; 174 + regulator-max-microvolt = <3900000>; 175 + regulator-boot-on; 176 + regulator-always-on; 177 + }; 178 + }; 179 + backlight { 180 + maxim,max8925-dual-string = <0>; 181 + }; 182 + charger { 183 + batt-detect = <0>; 184 + topoff-threshold = <1>; 185 + fast-charge = <7>; 186 + no-temp-support = <0>; 187 + no-insert-detect = <0>; 188 + }; 189 + }; 32 190 }; 33 191 rtc: rtc@d4010000 { 34 192 status = "okay";
+3 -1
arch/arm/boot/dts/mmp2.dtsi
··· 46 46 mrvl,intc-nr-irqs = <64>; 47 47 }; 48 48 49 - intcmux4@d4282150 { 49 + intcmux4: interrupt-controller@d4282150 { 50 50 compatible = "mrvl,mmp2-mux-intc"; 51 51 interrupts = <4>; 52 52 interrupt-controller; ··· 201 201 compatible = "mrvl,mmp-twsi"; 202 202 reg = <0xd4011000 0x1000>; 203 203 interrupts = <7>; 204 + #address-cells = <1>; 205 + #size-cells = <0>; 204 206 mrvl,i2c-fast-mode; 205 207 status = "disabled"; 206 208 };
+7 -7
arch/arm/mach-omap2/board-zoom-display.c
··· 49 49 { 50 50 } 51 51 52 - /* 53 - * PWMA/B register offsets (TWL4030_MODULE_PWMA) 54 - */ 52 + /* Register offsets in TWL4030_MODULE_INTBR */ 55 53 #define TWL_INTBR_PMBR1 0xD 56 54 #define TWL_INTBR_GPBR1 0xC 57 - #define TWL_LED_PWMON 0x0 58 - #define TWL_LED_PWMOFF 0x1 55 + 56 + /* Register offsets in TWL_MODULE_PWM */ 57 + #define TWL_LED_PWMON 0x3 58 + #define TWL_LED_PWMOFF 0x4 59 59 60 60 static int zoom_set_bl_intensity(struct omap_dss_device *dssdev, int level) 61 61 { ··· 93 93 } 94 94 95 95 c = ((50 * (100 - level)) / 100) + 1; 96 - twl_i2c_write_u8(TWL4030_MODULE_PWM1, 0x7F, TWL_LED_PWMOFF); 97 - twl_i2c_write_u8(TWL4030_MODULE_PWM1, c, TWL_LED_PWMON); 96 + twl_i2c_write_u8(TWL_MODULE_PWM, 0x7F, TWL_LED_PWMOFF); 97 + twl_i2c_write_u8(TWL_MODULE_PWM, c, TWL_LED_PWMON); 98 98 #else 99 99 pr_warn("Backlight not enabled\n"); 100 100 #endif
+7
drivers/gpio/Kconfig
··· 657 657 This driver provides support for driving the pins in output 658 658 mode only. Input mode is not supported. 659 659 660 + config GPIO_PALMAS 661 + bool "TI PALMAS series PMICs GPIO" 662 + depends on MFD_PALMAS 663 + help 664 + Select this option to enable GPIO driver for the TI PALMAS 665 + series chip family. 666 + 660 667 config GPIO_TPS6586X 661 668 bool "TPS6586X GPIO" 662 669 depends on MFD_TPS6586X
+1
drivers/gpio/Makefile
··· 68 68 obj-$(CONFIG_ARCH_TEGRA) += gpio-tegra.o 69 69 obj-$(CONFIG_GPIO_TIMBERDALE) += gpio-timberdale.o 70 70 obj-$(CONFIG_ARCH_DAVINCI_TNETV107X) += gpio-tnetv107x.o 71 + obj-$(CONFIG_GPIO_PALMAS) += gpio-palmas.o 71 72 obj-$(CONFIG_GPIO_TPS6586X) += gpio-tps6586x.o 72 73 obj-$(CONFIG_GPIO_TPS65910) += gpio-tps65910.o 73 74 obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o
+184
drivers/gpio/gpio-palmas.c
··· 1 + /* 2 + * TI Palma series PMIC's GPIO driver. 3 + * 4 + * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. 5 + * 6 + * Author: Laxman Dewangan <ldewangan@nvidia.com> 7 + * 8 + * This program is free software; you can redistribute it and/or modify it 9 + * under the terms and conditions of the GNU General Public License, 10 + * version 2, as published by the Free Software Foundation. 11 + * 12 + * This program is distributed in the hope it will be useful, but WITHOUT 13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 + * more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 + */ 20 + 21 + #include <linux/gpio.h> 22 + #include <linux/kernel.h> 23 + #include <linux/module.h> 24 + #include <linux/mfd/palmas.h> 25 + #include <linux/of.h> 26 + #include <linux/of_device.h> 27 + #include <linux/platform_device.h> 28 + 29 + struct palmas_gpio { 30 + struct gpio_chip gpio_chip; 31 + struct palmas *palmas; 32 + }; 33 + 34 + static inline struct palmas_gpio *to_palmas_gpio(struct gpio_chip *chip) 35 + { 36 + return container_of(chip, struct palmas_gpio, gpio_chip); 37 + } 38 + 39 + static int palmas_gpio_get(struct gpio_chip *gc, unsigned offset) 40 + { 41 + struct palmas_gpio *pg = to_palmas_gpio(gc); 42 + struct palmas *palmas = pg->palmas; 43 + unsigned int val; 44 + int ret; 45 + 46 + ret = palmas_read(palmas, PALMAS_GPIO_BASE, PALMAS_GPIO_DATA_IN, &val); 47 + if (ret < 0) { 48 + dev_err(gc->dev, "GPIO_DATA_IN read failed, err = %d\n", ret); 49 + return ret; 50 + } 51 + return !!(val & BIT(offset)); 52 + } 53 + 54 + static void palmas_gpio_set(struct gpio_chip *gc, unsigned offset, 55 + int value) 56 + { 57 + struct palmas_gpio *pg = to_palmas_gpio(gc); 58 + struct palmas *palmas = pg->palmas; 59 + int ret; 60 + 61 + if (value) 62 + ret = palmas_write(palmas, PALMAS_GPIO_BASE, 63 + PALMAS_GPIO_SET_DATA_OUT, BIT(offset)); 64 + else 65 + ret = palmas_write(palmas, PALMAS_GPIO_BASE, 66 + PALMAS_GPIO_CLEAR_DATA_OUT, BIT(offset)); 67 + if (ret < 0) 68 + dev_err(gc->dev, "%s write failed, err = %d\n", 69 + (value) ? "GPIO_SET_DATA_OUT" : "GPIO_CLEAR_DATA_OUT", 70 + ret); 71 + } 72 + 73 + static int palmas_gpio_output(struct gpio_chip *gc, unsigned offset, 74 + int value) 75 + { 76 + struct palmas_gpio *pg = to_palmas_gpio(gc); 77 + struct palmas *palmas = pg->palmas; 78 + int ret; 79 + 80 + /* Set the initial value */ 81 + palmas_gpio_set(gc, offset, value); 82 + 83 + ret = palmas_update_bits(palmas, PALMAS_GPIO_BASE, 84 + PALMAS_GPIO_DATA_DIR, BIT(offset), BIT(offset)); 85 + if (ret < 0) 86 + dev_err(gc->dev, "GPIO_DATA_DIR write failed, err = %d\n", ret); 87 + return ret; 88 + } 89 + 90 + static int palmas_gpio_input(struct gpio_chip *gc, unsigned offset) 91 + { 92 + struct palmas_gpio *pg = to_palmas_gpio(gc); 93 + struct palmas *palmas = pg->palmas; 94 + int ret; 95 + 96 + ret = palmas_update_bits(palmas, PALMAS_GPIO_BASE, 97 + PALMAS_GPIO_DATA_DIR, BIT(offset), 0); 98 + if (ret < 0) 99 + dev_err(gc->dev, "GPIO_DATA_DIR write failed, err = %d\n", ret); 100 + return ret; 101 + } 102 + 103 + static int palmas_gpio_to_irq(struct gpio_chip *gc, unsigned offset) 104 + { 105 + struct palmas_gpio *pg = to_palmas_gpio(gc); 106 + struct palmas *palmas = pg->palmas; 107 + 108 + return palmas_irq_get_virq(palmas, PALMAS_GPIO_0_IRQ + offset); 109 + } 110 + 111 + static int palmas_gpio_probe(struct platform_device *pdev) 112 + { 113 + struct palmas *palmas = dev_get_drvdata(pdev->dev.parent); 114 + struct palmas_platform_data *palmas_pdata; 115 + struct palmas_gpio *palmas_gpio; 116 + int ret; 117 + 118 + palmas_gpio = devm_kzalloc(&pdev->dev, 119 + sizeof(*palmas_gpio), GFP_KERNEL); 120 + if (!palmas_gpio) { 121 + dev_err(&pdev->dev, "Could not allocate palmas_gpio\n"); 122 + return -ENOMEM; 123 + } 124 + 125 + palmas_gpio->palmas = palmas; 126 + palmas_gpio->gpio_chip.owner = THIS_MODULE; 127 + palmas_gpio->gpio_chip.label = dev_name(&pdev->dev); 128 + palmas_gpio->gpio_chip.ngpio = 8; 129 + palmas_gpio->gpio_chip.can_sleep = 1; 130 + palmas_gpio->gpio_chip.direction_input = palmas_gpio_input; 131 + palmas_gpio->gpio_chip.direction_output = palmas_gpio_output; 132 + palmas_gpio->gpio_chip.to_irq = palmas_gpio_to_irq; 133 + palmas_gpio->gpio_chip.set = palmas_gpio_set; 134 + palmas_gpio->gpio_chip.get = palmas_gpio_get; 135 + palmas_gpio->gpio_chip.dev = &pdev->dev; 136 + #ifdef CONFIG_OF_GPIO 137 + palmas_gpio->gpio_chip.of_node = palmas->dev->of_node; 138 + #endif 139 + palmas_pdata = dev_get_platdata(palmas->dev); 140 + if (palmas_pdata && palmas_pdata->gpio_base) 141 + palmas_gpio->gpio_chip.base = palmas_pdata->gpio_base; 142 + else 143 + palmas_gpio->gpio_chip.base = -1; 144 + 145 + ret = gpiochip_add(&palmas_gpio->gpio_chip); 146 + if (ret < 0) { 147 + dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); 148 + return ret; 149 + } 150 + 151 + platform_set_drvdata(pdev, palmas_gpio); 152 + return ret; 153 + } 154 + 155 + static int palmas_gpio_remove(struct platform_device *pdev) 156 + { 157 + struct palmas_gpio *palmas_gpio = platform_get_drvdata(pdev); 158 + 159 + return gpiochip_remove(&palmas_gpio->gpio_chip); 160 + } 161 + 162 + static struct platform_driver palmas_gpio_driver = { 163 + .driver.name = "palmas-gpio", 164 + .driver.owner = THIS_MODULE, 165 + .probe = palmas_gpio_probe, 166 + .remove = palmas_gpio_remove, 167 + }; 168 + 169 + static int __init palmas_gpio_init(void) 170 + { 171 + return platform_driver_register(&palmas_gpio_driver); 172 + } 173 + subsys_initcall(palmas_gpio_init); 174 + 175 + static void __exit palmas_gpio_exit(void) 176 + { 177 + platform_driver_unregister(&palmas_gpio_driver); 178 + } 179 + module_exit(palmas_gpio_exit); 180 + 181 + MODULE_ALIAS("platform:palmas-gpio"); 182 + MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>"); 183 + MODULE_DESCRIPTION("GPIO driver for TI Palmas series PMICs"); 184 + MODULE_LICENSE("GPL v2");
-3
drivers/input/misc/max8925_onkey.c
··· 100 100 input->dev.parent = &pdev->dev; 101 101 input_set_capability(input, EV_KEY, KEY_POWER); 102 102 103 - irq[0] += chip->irq_base; 104 - irq[1] += chip->irq_base; 105 - 106 103 error = request_threaded_irq(irq[0], NULL, max8925_onkey_handler, 107 104 IRQF_ONESHOT, "onkey-down", info); 108 105 if (error < 0) {
+7
drivers/memstick/host/rtsx_pci_ms.c
··· 426 426 427 427 dev_dbg(ms_dev(host), "--> %s\n", __func__); 428 428 429 + if (rtsx_pci_card_exclusive_check(host->pcr, RTSX_MS_CARD)) 430 + return; 431 + 429 432 schedule_work(&host->handle_req); 430 433 } 431 434 ··· 443 440 444 441 dev_dbg(ms_dev(host), "%s: param = %d, value = %d\n", 445 442 __func__, param, value); 443 + 444 + err = rtsx_pci_card_exclusive_check(host->pcr, RTSX_MS_CARD); 445 + if (err) 446 + return err; 446 447 447 448 switch (param) { 448 449 case MEMSTICK_POWER:
+3 -7
drivers/mfd/88pm800.c
··· 531 531 ret = device_800_init(chip, pdata); 532 532 if (ret) { 533 533 dev_err(chip->dev, "%s id 0x%x failed!\n", __func__, chip->id); 534 - goto err_800_init; 534 + goto err_subchip_alloc; 535 535 } 536 536 537 537 ret = pm800_pages_init(chip); ··· 546 546 err_page_init: 547 547 mfd_remove_devices(chip->dev); 548 548 device_irq_exit_800(chip); 549 - err_800_init: 550 - devm_kfree(&client->dev, subchip); 551 549 err_subchip_alloc: 552 - pm80x_deinit(client); 550 + pm80x_deinit(); 553 551 out_init: 554 552 return ret; 555 553 } ··· 560 562 device_irq_exit_800(chip); 561 563 562 564 pm800_pages_exit(chip); 563 - devm_kfree(&client->dev, chip->subchip); 564 - 565 - pm80x_deinit(client); 565 + pm80x_deinit(); 566 566 567 567 return 0; 568 568 }
+2 -2
drivers/mfd/88pm805.c
··· 257 257 pdata->plat_config(chip, pdata); 258 258 259 259 err_805_init: 260 - pm80x_deinit(client); 260 + pm80x_deinit(); 261 261 out_init: 262 262 return ret; 263 263 } ··· 269 269 mfd_remove_devices(chip->dev); 270 270 device_irq_exit_805(chip); 271 271 272 - pm80x_deinit(client); 272 + pm80x_deinit(); 273 273 274 274 return 0; 275 275 }
+4 -18
drivers/mfd/88pm80x.c
··· 48 48 ret = PTR_ERR(map); 49 49 dev_err(&client->dev, "Failed to allocate register map: %d\n", 50 50 ret); 51 - goto err_regmap_init; 51 + return ret; 52 52 } 53 53 54 54 chip->id = id->driver_data; 55 - if (chip->id < CHIP_PM800 || chip->id > CHIP_PM805) { 56 - ret = -EINVAL; 57 - goto err_chip_id; 58 - } 55 + if (chip->id < CHIP_PM800 || chip->id > CHIP_PM805) 56 + return -EINVAL; 59 57 60 58 chip->client = client; 61 59 chip->regmap = map; ··· 80 82 } 81 83 82 84 return 0; 83 - 84 - err_chip_id: 85 - regmap_exit(map); 86 - err_regmap_init: 87 - devm_kfree(&client->dev, chip); 88 - return ret; 89 85 } 90 86 EXPORT_SYMBOL_GPL(pm80x_init); 91 87 92 - int pm80x_deinit(struct i2c_client *client) 88 + int pm80x_deinit(void) 93 89 { 94 - struct pm80x_chip *chip = i2c_get_clientdata(client); 95 - 96 90 /* 97 91 * workaround: clear the dependency between pm800 and pm805. 98 92 * would remove it after HW chip fixes the issue. ··· 93 103 g_pm80x_chip->companion = NULL; 94 104 else 95 105 g_pm80x_chip = NULL; 96 - 97 - regmap_exit(chip->regmap); 98 - devm_kfree(&client->dev, chip); 99 - 100 106 return 0; 101 107 } 102 108 EXPORT_SYMBOL_GPL(pm80x_deinit);
+38 -34
drivers/mfd/Kconfig
··· 65 65 66 66 config MFD_RTSX_PCI 67 67 tristate "Support for Realtek PCI-E card reader" 68 - depends on PCI 68 + depends on PCI && GENERIC_HARDIRQS 69 69 select MFD_CORE 70 70 help 71 71 This supports for Realtek PCI-Express card reader including rts5209, ··· 95 95 96 96 config MFD_TI_SSP 97 97 tristate "TI Sequencer Serial Port support" 98 - depends on ARCH_DAVINCI_TNETV107X 98 + depends on ARCH_DAVINCI_TNETV107X && GENERIC_HARDIRQS 99 99 select MFD_CORE 100 100 ---help--- 101 101 Say Y here if you want support for the Sequencer Serial Port ··· 109 109 select MFD_CORE 110 110 select REGMAP 111 111 select REGMAP_MMIO 112 + depends on GENERIC_HARDIRQS 112 113 help 113 114 If you say yes here you get support for Texas Instruments series 114 115 of Touch Screen /ADC chips. ··· 127 126 config HTC_PASIC3 128 127 tristate "HTC PASIC3 LED/DS1WM chip support" 129 128 select MFD_CORE 129 + depends on GENERIC_HARDIRQS 130 130 help 131 131 This core driver provides register access for the LED/DS1WM 132 132 chips labeled "AIC2" and "AIC3", found on HTC Blueangel and ··· 159 157 depends on I2C 160 158 select MFD_CORE 161 159 select REGMAP_I2C 160 + depends on GENERIC_HARDIRQS 162 161 help 163 162 Say yes here to enable support for National Semiconductor / TI 164 163 LM3533 Lighting Power chips. ··· 174 171 select REGULATOR 175 172 select MFD_CORE 176 173 select REGULATOR_FIXED_VOLTAGE 174 + depends on GENERIC_HARDIRQS 177 175 help 178 176 This option enables a driver for the TP61050/TPS61052 179 177 high-power "white LED driver". This boost converter is ··· 197 193 config TPS6507X 198 194 tristate "TPS6507x Power Management / Touch Screen chips" 199 195 select MFD_CORE 200 - depends on I2C 196 + depends on I2C && GENERIC_HARDIRQS 201 197 help 202 198 If you say yes here you get support for the TPS6507x series of 203 199 Power Management / Touch Screen chips. These include voltage ··· 208 204 209 205 config MFD_TPS65217 210 206 tristate "TPS65217 Power Management / White LED chips" 211 - depends on I2C 207 + depends on I2C && GENERIC_HARDIRQS 212 208 select MFD_CORE 213 209 select REGMAP_I2C 214 210 help ··· 238 234 239 235 config MFD_TPS65910 240 236 bool "TPS65910 Power Management chip" 241 - depends on I2C=y && GPIOLIB 237 + depends on I2C=y && GPIOLIB && GENERIC_HARDIRQS 242 238 select MFD_CORE 243 239 select REGMAP_I2C 244 240 select REGMAP_IRQ ··· 255 251 bool "TPS65912 Power Management chip with I2C" 256 252 select MFD_CORE 257 253 select MFD_TPS65912 258 - depends on I2C=y && GPIOLIB 254 + depends on I2C=y && GPIOLIB && GENERIC_HARDIRQS 259 255 help 260 256 If you say yes here you get support for the TPS65912 series of 261 257 PM chips with I2C interface. ··· 264 260 bool "TPS65912 Power Management chip with SPI" 265 261 select MFD_CORE 266 262 select MFD_TPS65912 267 - depends on SPI_MASTER && GPIOLIB 263 + depends on SPI_MASTER && GPIOLIB && GENERIC_HARDIRQS 268 264 help 269 265 If you say yes here you get support for the TPS65912 series of 270 266 PM chips with SPI interface. ··· 334 330 335 331 config MFD_TWL4030_AUDIO 336 332 bool 337 - depends on TWL4030_CORE 333 + depends on TWL4030_CORE && GENERIC_HARDIRQS 338 334 select MFD_CORE 339 335 default n 340 336 341 337 config TWL6040_CORE 342 338 bool "Support for TWL6040 audio codec" 343 - depends on I2C=y 339 + depends on I2C=y && GENERIC_HARDIRQS 344 340 select MFD_CORE 345 341 select REGMAP_I2C 346 342 select REGMAP_IRQ ··· 409 405 410 406 config MFD_T7L66XB 411 407 bool "Support Toshiba T7L66XB" 412 - depends on ARM && HAVE_CLK 408 + depends on ARM && HAVE_CLK && GENERIC_HARDIRQS 413 409 select MFD_CORE 414 410 select MFD_TMIO 415 411 help ··· 417 413 418 414 config MFD_SMSC 419 415 bool "Support for the SMSC ECE1099 series chips" 420 - depends on I2C=y 416 + depends on I2C=y && GENERIC_HARDIRQS 421 417 select MFD_CORE 422 418 select REGMAP_I2C 423 419 help ··· 464 460 select REGMAP_SPI 465 461 select REGMAP_IRQ 466 462 select PMIC_DA9052 467 - depends on SPI_MASTER=y 463 + depends on SPI_MASTER=y && GENERIC_HARDIRQS 468 464 help 469 465 Support for the Dialog Semiconductor DA9052 PMIC 470 466 when controlled using SPI. This driver provides common support ··· 476 472 select REGMAP_I2C 477 473 select REGMAP_IRQ 478 474 select PMIC_DA9052 479 - depends on I2C=y 475 + depends on I2C=y && GENERIC_HARDIRQS 480 476 help 481 477 Support for the Dialog Semiconductor DA9052 PMIC 482 478 when controlled using I2C. This driver provides common support ··· 489 485 select REGMAP_IRQ 490 486 select PMIC_DA9055 491 487 select MFD_CORE 492 - depends on I2C=y 488 + depends on I2C=y && GENERIC_HARDIRQS 493 489 help 494 490 Say yes here for support of Dialog Semiconductor DA9055. This is 495 491 a Power Management IC. This driver provides common support for ··· 512 508 513 509 config MFD_LP8788 514 510 bool "Texas Instruments LP8788 Power Management Unit Driver" 515 - depends on I2C=y 511 + depends on I2C=y && GENERIC_HARDIRQS 516 512 select MFD_CORE 517 513 select REGMAP_I2C 518 514 select IRQ_DOMAIN ··· 615 611 select MFD_ARIZONA 616 612 select MFD_CORE 617 613 select REGMAP_I2C 618 - depends on I2C 614 + depends on I2C && GENERIC_HARDIRQS 619 615 help 620 616 Support for the Wolfson Microelectronics Arizona platform audio SoC 621 617 core functionality controlled via I2C. ··· 625 621 select MFD_ARIZONA 626 622 select MFD_CORE 627 623 select REGMAP_SPI 628 - depends on SPI_MASTER 624 + depends on SPI_MASTER && GENERIC_HARDIRQS 629 625 help 630 626 Support for the Wolfson Microelectronics Arizona platform audio SoC 631 627 core functionality controlled via I2C. ··· 645 641 config MFD_WM8400 646 642 bool "Support Wolfson Microelectronics WM8400" 647 643 select MFD_CORE 648 - depends on I2C=y 644 + depends on I2C=y && GENERIC_HARDIRQS 649 645 select REGMAP_I2C 650 646 help 651 647 Support for the Wolfson Microelecronics WM8400 PMIC and audio ··· 789 785 790 786 config MFD_MC13XXX 791 787 tristate 792 - depends on SPI_MASTER || I2C 788 + depends on (SPI_MASTER || I2C) && GENERIC_HARDIRQS 793 789 select MFD_CORE 794 790 select MFD_MC13783 795 791 help ··· 800 796 801 797 config MFD_MC13XXX_SPI 802 798 tristate "Freescale MC13783 and MC13892 SPI interface" 803 - depends on SPI_MASTER 799 + depends on SPI_MASTER && GENERIC_HARDIRQS 804 800 select REGMAP_SPI 805 801 select MFD_MC13XXX 806 802 help ··· 808 804 809 805 config MFD_MC13XXX_I2C 810 806 tristate "Freescale MC13892 I2C interface" 811 - depends on I2C 807 + depends on I2C && GENERIC_HARDIRQS 812 808 select REGMAP_I2C 813 809 select MFD_MC13XXX 814 810 help ··· 826 822 827 823 config AB3100_CORE 828 824 bool "ST-Ericsson AB3100 Mixed Signal Circuit core functions" 829 - depends on I2C=y && ABX500_CORE 825 + depends on I2C=y && ABX500_CORE && GENERIC_HARDIRQS 830 826 select MFD_CORE 831 827 default y if ARCH_U300 832 828 help ··· 913 909 914 910 config LPC_SCH 915 911 tristate "Intel SCH LPC" 916 - depends on PCI 912 + depends on PCI && GENERIC_HARDIRQS 917 913 select MFD_CORE 918 914 help 919 915 LPC bridge function of the Intel SCH provides support for ··· 921 917 922 918 config LPC_ICH 923 919 tristate "Intel ICH LPC" 924 - depends on PCI 920 + depends on PCI && GENERIC_HARDIRQS 925 921 select MFD_CORE 926 922 help 927 923 The LPC bridge function of the Intel ICH provides support for ··· 932 928 config MFD_RDC321X 933 929 tristate "Support for RDC-R321x southbridge" 934 930 select MFD_CORE 935 - depends on PCI 931 + depends on PCI && GENERIC_HARDIRQS 936 932 help 937 933 Say yes here if you want to have support for the RDC R-321x SoC 938 934 southbridge which provides access to GPIOs and Watchdog using the ··· 941 937 config MFD_JANZ_CMODIO 942 938 tristate "Support for Janz CMOD-IO PCI MODULbus Carrier Board" 943 939 select MFD_CORE 944 - depends on PCI 940 + depends on PCI && GENERIC_HARDIRQS 945 941 help 946 942 This is the core driver for the Janz CMOD-IO PCI MODULbus 947 943 carrier board. This device is a PCI to MODULbus bridge which may ··· 959 955 960 956 config MFD_VX855 961 957 tristate "Support for VIA VX855/VX875 integrated south bridge" 962 - depends on PCI 958 + depends on PCI && GENERIC_HARDIRQS 963 959 select MFD_CORE 964 960 help 965 961 Say yes here to enable support for various functions of the ··· 968 964 969 965 config MFD_WL1273_CORE 970 966 tristate "Support for TI WL1273 FM radio." 971 - depends on I2C 967 + depends on I2C && GENERIC_HARDIRQS 972 968 select MFD_CORE 973 969 default n 974 970 help ··· 1032 1028 config MFD_AAT2870_CORE 1033 1029 bool "Support for the AnalogicTech AAT2870" 1034 1030 select MFD_CORE 1035 - depends on I2C=y && GPIOLIB 1031 + depends on I2C=y && GPIOLIB && GENERIC_HARDIRQS 1036 1032 help 1037 1033 If you say yes here you get support for the AAT2870. 1038 1034 This driver provides common support for accessing the device, ··· 1064 1060 1065 1061 config MFD_STA2X11 1066 1062 bool "STA2X11 multi function device support" 1067 - depends on STA2X11 1063 + depends on STA2X11 && GENERIC_HARDIRQS 1068 1064 select MFD_CORE 1069 1065 select REGMAP_MMIO 1070 1066 ··· 1081 1077 select MFD_CORE 1082 1078 select REGMAP_I2C 1083 1079 select REGMAP_IRQ 1084 - depends on I2C=y 1080 + depends on I2C=y && GENERIC_HARDIRQS 1085 1081 help 1086 1082 If you say yes here you get support for the Palmas 1087 1083 series of PMIC chips from Texas Instruments. ··· 1089 1085 config MFD_VIPERBOARD 1090 1086 tristate "Support for Nano River Technologies Viperboard" 1091 1087 select MFD_CORE 1092 - depends on USB 1088 + depends on USB && GENERIC_HARDIRQS 1093 1089 default n 1094 1090 help 1095 1091 Say yes here if you want support for Nano River Technologies ··· 1103 1099 config MFD_RETU 1104 1100 tristate "Support for Retu multi-function device" 1105 1101 select MFD_CORE 1106 - depends on I2C 1102 + depends on I2C && GENERIC_HARDIRQS 1107 1103 select REGMAP_IRQ 1108 1104 help 1109 1105 Retu is a multi-function device found on Nokia Internet Tablets ··· 1114 1110 select MFD_CORE 1115 1111 select REGMAP_I2C 1116 1112 select REGMAP_IRQ 1117 - depends on I2C=y 1113 + depends on I2C=y && GENERIC_HARDIRQS 1118 1114 help 1119 1115 Support for the AS3711 PMIC from AMS 1120 1116
+1 -1
drivers/mfd/Makefile
··· 9 9 obj-$(CONFIG_MFD_SM501) += sm501.o 10 10 obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o 11 11 12 - rtsx_pci-objs := rtsx_pcr.o rts5209.o rts5229.o rtl8411.o 12 + rtsx_pci-objs := rtsx_pcr.o rts5209.o rts5229.o rtl8411.o rts5227.o 13 13 obj-$(CONFIG_MFD_RTSX_PCI) += rtsx_pci.o 14 14 15 15 obj-$(CONFIG_HTC_EGPIO) += htc-egpio.o
+55 -6
drivers/mfd/ab8500-core.c
··· 320 320 .mask_and_set_register = ab8500_mask_and_set_register, 321 321 .event_registers_startup_state_get = NULL, 322 322 .startup_irq_enabled = NULL, 323 + .dump_all_banks = ab8500_dump_all_banks, 323 324 }; 324 325 325 326 static void ab8500_irq_lock(struct irq_data *data) ··· 369 368 int mask = 1 << (offset % 8); 370 369 371 370 ab8500->mask[index] |= mask; 371 + 372 + /* The AB8500 GPIOs have two interrupts each (rising & falling). */ 373 + if (offset >= AB8500_INT_GPIO6R && offset <= AB8500_INT_GPIO41R) 374 + ab8500->mask[index + 2] |= mask; 375 + if (offset >= AB9540_INT_GPIO50R && offset <= AB9540_INT_GPIO54R) 376 + ab8500->mask[index + 1] |= mask; 377 + if (offset == AB8540_INT_GPIO43R || offset == AB8540_INT_GPIO44R) 378 + /* Here the falling IRQ is one bit lower */ 379 + ab8500->mask[index] |= (mask << 1); 372 380 } 373 381 374 382 static void ab8500_irq_unmask(struct irq_data *data) 375 383 { 376 384 struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); 385 + unsigned int type = irqd_get_trigger_type(data); 377 386 int offset = data->hwirq; 378 387 int index = offset / 8; 379 388 int mask = 1 << (offset % 8); 380 389 381 - ab8500->mask[index] &= ~mask; 390 + if (type & IRQ_TYPE_EDGE_RISING) 391 + ab8500->mask[index] &= ~mask; 392 + 393 + /* The AB8500 GPIOs have two interrupts each (rising & falling). */ 394 + if (type & IRQ_TYPE_EDGE_FALLING) { 395 + if (offset >= AB8500_INT_GPIO6R && offset <= AB8500_INT_GPIO41R) 396 + ab8500->mask[index + 2] &= ~mask; 397 + else if (offset >= AB9540_INT_GPIO50R && offset <= AB9540_INT_GPIO54R) 398 + ab8500->mask[index + 1] &= ~mask; 399 + else if (offset == AB8540_INT_GPIO43R || offset == AB8540_INT_GPIO44R) 400 + /* Here the falling IRQ is one bit lower */ 401 + ab8500->mask[index] &= ~(mask << 1); 402 + else 403 + ab8500->mask[index] &= ~mask; 404 + } else { 405 + /* Satisfies the case where type is not set. */ 406 + ab8500->mask[index] &= ~mask; 407 + } 408 + } 409 + 410 + static int ab8500_irq_set_type(struct irq_data *data, unsigned int type) 411 + { 412 + return 0; 382 413 } 383 414 384 415 static struct irq_chip ab8500_irq_chip = { ··· 420 387 .irq_mask = ab8500_irq_mask, 421 388 .irq_disable = ab8500_irq_mask, 422 389 .irq_unmask = ab8500_irq_unmask, 390 + .irq_set_type = ab8500_irq_set_type, 423 391 }; 424 392 425 393 static int ab8500_handle_hierarchical_line(struct ab8500 *ab8500, ··· 444 410 445 411 line = (i << 3) + int_bit; 446 412 latch_val &= ~(1 << int_bit); 413 + 414 + /* 415 + * This handles the falling edge hwirqs from the GPIO 416 + * lines. Route them back to the line registered for the 417 + * rising IRQ, as this is merely a flag for the same IRQ 418 + * in linux terms. 419 + */ 420 + if (line >= AB8500_INT_GPIO6F && line <= AB8500_INT_GPIO41F) 421 + line -= 16; 422 + if (line >= AB9540_INT_GPIO50F && line <= AB9540_INT_GPIO54F) 423 + line -= 8; 424 + if (line == AB8540_INT_GPIO43F || line == AB8540_INT_GPIO44F) 425 + line += 1; 447 426 448 427 handle_nested_irq(ab8500->irq_base + line); 449 428 } while (latch_val); ··· 568 521 int virq = ab8500_irq_get_virq(ab8500, line); 569 522 570 523 handle_nested_irq(virq); 524 + ab8500_debug_register_interrupt(line); 571 525 value &= ~(1 << bit); 572 526 573 527 } while (value); ··· 977 929 978 930 static struct resource ab8500_temp_resources[] = { 979 931 { 980 - .name = "AB8500_TEMP_WARM", 932 + .name = "ABX500_TEMP_WARM", 981 933 .start = AB8500_INT_TEMP_WARM, 982 934 .end = AB8500_INT_TEMP_WARM, 983 935 .flags = IORESOURCE_IRQ, ··· 1053 1005 .of_compatible = "stericsson,ab8500-denc", 1054 1006 }, 1055 1007 { 1056 - .name = "ab8500-temp", 1057 - .of_compatible = "stericsson,ab8500-temp", 1008 + .name = "abx500-temp", 1009 + .of_compatible = "stericsson,abx500-temp", 1058 1010 .num_resources = ARRAY_SIZE(ab8500_temp_resources), 1059 1011 .resources = ab8500_temp_resources, 1060 1012 }, ··· 1097 1049 1098 1050 static struct mfd_cell ab8500_devs[] = { 1099 1051 { 1100 - .name = "ab8500-gpio", 1052 + .name = "pinctrl-ab8500", 1101 1053 .of_compatible = "stericsson,ab8500-gpio", 1102 1054 }, 1103 1055 { ··· 1114 1066 1115 1067 static struct mfd_cell ab9540_devs[] = { 1116 1068 { 1117 - .name = "ab8500-gpio", 1069 + .name = "pinctrl-ab9540", 1070 + .of_compatible = "stericsson,ab9540-gpio", 1118 1071 }, 1119 1072 { 1120 1073 .name = "ab9540-usb",
+1194 -54
drivers/mfd/ab8500-debugfs.c
··· 4 4 * Author: Mattias Wallin <mattias.wallin@stericsson.com> for ST-Ericsson. 5 5 * License Terms: GNU General Public License v2 6 6 */ 7 + /* 8 + * AB8500 register access 9 + * ====================== 10 + * 11 + * read: 12 + * # echo BANK > <debugfs>/ab8500/register-bank 13 + * # echo ADDR > <debugfs>/ab8500/register-address 14 + * # cat <debugfs>/ab8500/register-value 15 + * 16 + * write: 17 + * # echo BANK > <debugfs>/ab8500/register-bank 18 + * # echo ADDR > <debugfs>/ab8500/register-address 19 + * # echo VALUE > <debugfs>/ab8500/register-value 20 + * 21 + * read all registers from a bank: 22 + * # echo BANK > <debugfs>/ab8500/register-bank 23 + * # cat <debugfs>/ab8500/all-bank-register 24 + * 25 + * BANK target AB8500 register bank 26 + * ADDR target AB8500 register address 27 + * VALUE decimal or 0x-prefixed hexadecimal 28 + * 29 + * 30 + * User Space notification on AB8500 IRQ 31 + * ===================================== 32 + * 33 + * Allows user space entity to be notified when target AB8500 IRQ occurs. 34 + * When subscribed, a sysfs entry is created in ab8500.i2c platform device. 35 + * One can pool this file to get target IRQ occurence information. 36 + * 37 + * subscribe to an AB8500 IRQ: 38 + * # echo IRQ > <debugfs>/ab8500/irq-subscribe 39 + * 40 + * unsubscribe from an AB8500 IRQ: 41 + * # echo IRQ > <debugfs>/ab8500/irq-unsubscribe 42 + * 43 + * 44 + * AB8500 register formated read/write access 45 + * ========================================== 46 + * 47 + * Read: read data, data>>SHIFT, data&=MASK, output data 48 + * [0xABCDEF98] shift=12 mask=0xFFF => 0x00000CDE 49 + * Write: read data, data &= ~(MASK<<SHIFT), data |= (VALUE<<SHIFT), write data 50 + * [0xABCDEF98] shift=12 mask=0xFFF value=0x123 => [0xAB123F98] 51 + * 52 + * Usage: 53 + * # echo "CMD [OPTIONS] BANK ADRESS [VALUE]" > $debugfs/ab8500/hwreg 54 + * 55 + * CMD read read access 56 + * write write access 57 + * 58 + * BANK target reg bank 59 + * ADDRESS target reg address 60 + * VALUE (write) value to be updated 61 + * 62 + * OPTIONS 63 + * -d|-dec (read) output in decimal 64 + * -h|-hexa (read) output in 0x-hexa (default) 65 + * -l|-w|-b 32bit (default), 16bit or 8bit reg access 66 + * -m|-mask MASK 0x-hexa mask (default 0xFFFFFFFF) 67 + * -s|-shift SHIFT bit shift value (read:left, write:right) 68 + * -o|-offset OFFSET address offset to add to ADDRESS value 69 + * 70 + * Warning: bit shift operation is applied to bit-mask. 71 + * Warning: bit shift direction depends on read or right command. 72 + */ 7 73 8 74 #include <linux/seq_file.h> 9 75 #include <linux/uaccess.h> ··· 77 11 #include <linux/module.h> 78 12 #include <linux/debugfs.h> 79 13 #include <linux/platform_device.h> 14 + #include <linux/interrupt.h> 15 + #include <linux/kobject.h> 16 + #include <linux/slab.h> 80 17 81 18 #include <linux/mfd/abx500.h> 82 19 #include <linux/mfd/abx500/ab8500.h> 20 + #include <linux/mfd/abx500/ab8500-gpadc.h> 21 + 22 + #ifdef CONFIG_DEBUG_FS 23 + #include <linux/string.h> 24 + #include <linux/ctype.h> 25 + #endif 83 26 84 27 static u32 debug_bank; 85 28 static u32 debug_address; 29 + 30 + static int irq_first; 31 + static int irq_last; 32 + static u32 *irq_count; 33 + static int num_irqs; 34 + 35 + static struct device_attribute **dev_attr; 36 + static char **event_name; 86 37 87 38 /** 88 39 * struct ab8500_reg_range ··· 125 42 const struct ab8500_reg_range *range; 126 43 }; 127 44 45 + /* hwreg- "mask" and "shift" entries ressources */ 46 + struct hwreg_cfg { 47 + u32 bank; /* target bank */ 48 + u32 addr; /* target address */ 49 + uint fmt; /* format */ 50 + uint mask; /* read/write mask, applied before any bit shift */ 51 + int shift; /* bit shift (read:right shift, write:left shift */ 52 + }; 53 + /* fmt bit #0: 0=hexa, 1=dec */ 54 + #define REG_FMT_DEC(c) ((c)->fmt & 0x1) 55 + #define REG_FMT_HEX(c) (!REG_FMT_DEC(c)) 56 + 57 + static struct hwreg_cfg hwreg_cfg = { 58 + .addr = 0, /* default: invalid phys addr */ 59 + .fmt = 0, /* default: 32bit access, hex output */ 60 + .mask = 0xFFFFFFFF, /* default: no mask */ 61 + .shift = 0, /* default: no bit shift */ 62 + }; 63 + 128 64 #define AB8500_NAME_STRING "ab8500" 129 - #define AB8500_NUM_BANKS 22 65 + #define AB8500_ADC_NAME_STRING "gpadc" 66 + #define AB8500_NUM_BANKS 24 130 67 131 68 #define AB8500_REV_REG 0x80 132 69 133 70 static struct ab8500_prcmu_ranges debug_ranges[AB8500_NUM_BANKS] = { 134 71 [0x0] = { 135 72 .num_ranges = 0, 136 - .range = 0, 73 + .range = NULL, 137 74 }, 138 75 [AB8500_SYS_CTRL1_BLOCK] = { 139 76 .num_ranges = 3, ··· 318 215 }, 319 216 }, 320 217 [AB8500_CHARGER] = { 321 - .num_ranges = 8, 218 + .num_ranges = 9, 322 219 .range = (struct ab8500_reg_range[]) { 323 220 { 324 221 .first = 0x00, ··· 352 249 .first = 0xC0, 353 250 .last = 0xC2, 354 251 }, 252 + { 253 + .first = 0xf5, 254 + .last = 0xf6, 255 + }, 355 256 }, 356 257 }, 357 258 [AB8500_GAS_GAUGE] = { ··· 372 265 { 373 266 .first = 0x10, 374 267 .last = 0x14, 268 + }, 269 + }, 270 + }, 271 + [AB8500_DEVELOPMENT] = { 272 + .num_ranges = 1, 273 + .range = (struct ab8500_reg_range[]) { 274 + { 275 + .first = 0x00, 276 + .last = 0x00, 277 + }, 278 + }, 279 + }, 280 + [AB8500_DEBUG] = { 281 + .num_ranges = 1, 282 + .range = (struct ab8500_reg_range[]) { 283 + { 284 + .first = 0x05, 285 + .last = 0x07, 375 286 }, 376 287 }, 377 288 }, ··· 479 354 }, 480 355 }; 481 356 482 - static int ab8500_registers_print(struct seq_file *s, void *p) 357 + static irqreturn_t ab8500_debug_handler(int irq, void *data) 483 358 { 484 - struct device *dev = s->private; 359 + char buf[16]; 360 + struct kobject *kobj = (struct kobject *)data; 361 + unsigned int irq_abb = irq - irq_first; 362 + 363 + if (irq_abb < num_irqs) 364 + irq_count[irq_abb]++; 365 + /* 366 + * This makes it possible to use poll for events (POLLPRI | POLLERR) 367 + * from userspace on sysfs file named <irq-nr> 368 + */ 369 + sprintf(buf, "%d", irq); 370 + sysfs_notify(kobj, NULL, buf); 371 + 372 + return IRQ_HANDLED; 373 + } 374 + 375 + /* Prints to seq_file or log_buf */ 376 + static int ab8500_registers_print(struct device *dev, u32 bank, 377 + struct seq_file *s) 378 + { 485 379 unsigned int i; 486 - u32 bank = debug_bank; 487 380 488 - seq_printf(s, AB8500_NAME_STRING " register values:\n"); 489 - 490 - seq_printf(s, " bank %u:\n", bank); 491 381 for (i = 0; i < debug_ranges[bank].num_ranges; i++) { 492 382 u32 reg; 493 383 ··· 519 379 return err; 520 380 } 521 381 522 - err = seq_printf(s, " [%u/0x%02X]: 0x%02X\n", bank, 523 - reg, value); 524 - if (err < 0) { 525 - dev_err(dev, "seq_printf overflow\n"); 526 - /* Error is not returned here since 527 - * the output is wanted in any case */ 528 - return 0; 382 + if (s) { 383 + err = seq_printf(s, " [%u/0x%02X]: 0x%02X\n", 384 + bank, reg, value); 385 + if (err < 0) { 386 + dev_err(dev, 387 + "seq_printf overflow bank=%d reg=%d\n", 388 + bank, reg); 389 + /* Error is not returned here since 390 + * the output is wanted in any case */ 391 + return 0; 392 + } 393 + } else { 394 + printk(KERN_INFO" [%u/0x%02X]: 0x%02X\n", bank, 395 + reg, value); 529 396 } 530 397 } 531 398 } 532 399 return 0; 533 400 } 534 401 402 + static int ab8500_print_bank_registers(struct seq_file *s, void *p) 403 + { 404 + struct device *dev = s->private; 405 + u32 bank = debug_bank; 406 + 407 + seq_printf(s, AB8500_NAME_STRING " register values:\n"); 408 + 409 + seq_printf(s, " bank %u:\n", bank); 410 + 411 + ab8500_registers_print(dev, bank, s); 412 + return 0; 413 + } 414 + 535 415 static int ab8500_registers_open(struct inode *inode, struct file *file) 536 416 { 537 - return single_open(file, ab8500_registers_print, inode->i_private); 417 + return single_open(file, ab8500_print_bank_registers, inode->i_private); 538 418 } 539 419 540 420 static const struct file_operations ab8500_registers_fops = { 541 421 .open = ab8500_registers_open, 422 + .read = seq_read, 423 + .llseek = seq_lseek, 424 + .release = single_release, 425 + .owner = THIS_MODULE, 426 + }; 427 + 428 + static int ab8500_print_all_banks(struct seq_file *s, void *p) 429 + { 430 + struct device *dev = s->private; 431 + unsigned int i; 432 + int err; 433 + 434 + seq_printf(s, AB8500_NAME_STRING " register values:\n"); 435 + 436 + for (i = 1; i < AB8500_NUM_BANKS; i++) { 437 + err = seq_printf(s, " bank %u:\n", i); 438 + if (err < 0) 439 + dev_err(dev, "seq_printf overflow, bank=%d\n", i); 440 + 441 + ab8500_registers_print(dev, i, s); 442 + } 443 + return 0; 444 + } 445 + 446 + /* Dump registers to kernel log */ 447 + void ab8500_dump_all_banks(struct device *dev) 448 + { 449 + unsigned int i; 450 + 451 + printk(KERN_INFO"ab8500 register values:\n"); 452 + 453 + for (i = 1; i < AB8500_NUM_BANKS; i++) { 454 + printk(KERN_INFO" bank %u:\n", i); 455 + ab8500_registers_print(dev, i, NULL); 456 + } 457 + } 458 + 459 + static int ab8500_all_banks_open(struct inode *inode, struct file *file) 460 + { 461 + struct seq_file *s; 462 + int err; 463 + 464 + err = single_open(file, ab8500_print_all_banks, inode->i_private); 465 + if (!err) { 466 + /* Default buf size in seq_read is not enough */ 467 + s = (struct seq_file *)file->private_data; 468 + s->size = (PAGE_SIZE * 2); 469 + s->buf = kmalloc(s->size, GFP_KERNEL); 470 + if (!s->buf) { 471 + single_release(inode, file); 472 + err = -ENOMEM; 473 + } 474 + } 475 + return err; 476 + } 477 + 478 + static const struct file_operations ab8500_all_banks_fops = { 479 + .open = ab8500_all_banks_open, 542 480 .read = seq_read, 543 481 .llseek = seq_lseek, 544 482 .release = single_release, ··· 737 519 return count; 738 520 } 739 521 522 + /* 523 + * Interrupt status 524 + */ 525 + static u32 num_interrupts[AB8500_MAX_NR_IRQS]; 526 + static int num_interrupt_lines; 527 + 528 + void ab8500_debug_register_interrupt(int line) 529 + { 530 + if (line < num_interrupt_lines) 531 + num_interrupts[line]++; 532 + } 533 + 534 + static int ab8500_interrupts_print(struct seq_file *s, void *p) 535 + { 536 + int line; 537 + 538 + seq_printf(s, "irq: number of\n"); 539 + 540 + for (line = 0; line < num_interrupt_lines; line++) 541 + seq_printf(s, "%3i: %6i\n", line, num_interrupts[line]); 542 + 543 + return 0; 544 + } 545 + 546 + static int ab8500_interrupts_open(struct inode *inode, struct file *file) 547 + { 548 + return single_open(file, ab8500_interrupts_print, inode->i_private); 549 + } 550 + 551 + /* 552 + * - HWREG DB8500 formated routines 553 + */ 554 + static int ab8500_hwreg_print(struct seq_file *s, void *d) 555 + { 556 + struct device *dev = s->private; 557 + int ret; 558 + u8 regvalue; 559 + 560 + ret = abx500_get_register_interruptible(dev, 561 + (u8)hwreg_cfg.bank, (u8)hwreg_cfg.addr, &regvalue); 562 + if (ret < 0) { 563 + dev_err(dev, "abx500_get_reg fail %d, %d\n", 564 + ret, __LINE__); 565 + return -EINVAL; 566 + } 567 + 568 + if (hwreg_cfg.shift >= 0) 569 + regvalue >>= hwreg_cfg.shift; 570 + else 571 + regvalue <<= -hwreg_cfg.shift; 572 + regvalue &= hwreg_cfg.mask; 573 + 574 + if (REG_FMT_DEC(&hwreg_cfg)) 575 + seq_printf(s, "%d\n", regvalue); 576 + else 577 + seq_printf(s, "0x%02X\n", regvalue); 578 + return 0; 579 + } 580 + 581 + static int ab8500_hwreg_open(struct inode *inode, struct file *file) 582 + { 583 + return single_open(file, ab8500_hwreg_print, inode->i_private); 584 + } 585 + 586 + static int ab8500_gpadc_bat_ctrl_print(struct seq_file *s, void *p) 587 + { 588 + int bat_ctrl_raw; 589 + int bat_ctrl_convert; 590 + struct ab8500_gpadc *gpadc; 591 + 592 + gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); 593 + bat_ctrl_raw = ab8500_gpadc_read_raw(gpadc, BAT_CTRL); 594 + bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc, 595 + BAT_CTRL, bat_ctrl_raw); 596 + 597 + return seq_printf(s, "%d,0x%X\n", 598 + bat_ctrl_convert, bat_ctrl_raw); 599 + } 600 + 601 + static int ab8500_gpadc_bat_ctrl_open(struct inode *inode, struct file *file) 602 + { 603 + return single_open(file, ab8500_gpadc_bat_ctrl_print, inode->i_private); 604 + } 605 + 606 + static const struct file_operations ab8500_gpadc_bat_ctrl_fops = { 607 + .open = ab8500_gpadc_bat_ctrl_open, 608 + .read = seq_read, 609 + .llseek = seq_lseek, 610 + .release = single_release, 611 + .owner = THIS_MODULE, 612 + }; 613 + 614 + static int ab8500_gpadc_btemp_ball_print(struct seq_file *s, void *p) 615 + { 616 + int btemp_ball_raw; 617 + int btemp_ball_convert; 618 + struct ab8500_gpadc *gpadc; 619 + 620 + gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); 621 + btemp_ball_raw = ab8500_gpadc_read_raw(gpadc, BTEMP_BALL); 622 + btemp_ball_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL, 623 + btemp_ball_raw); 624 + 625 + return seq_printf(s, 626 + "%d,0x%X\n", btemp_ball_convert, btemp_ball_raw); 627 + } 628 + 629 + static int ab8500_gpadc_btemp_ball_open(struct inode *inode, 630 + struct file *file) 631 + { 632 + return single_open(file, ab8500_gpadc_btemp_ball_print, inode->i_private); 633 + } 634 + 635 + static const struct file_operations ab8500_gpadc_btemp_ball_fops = { 636 + .open = ab8500_gpadc_btemp_ball_open, 637 + .read = seq_read, 638 + .llseek = seq_lseek, 639 + .release = single_release, 640 + .owner = THIS_MODULE, 641 + }; 642 + 643 + static int ab8500_gpadc_main_charger_v_print(struct seq_file *s, void *p) 644 + { 645 + int main_charger_v_raw; 646 + int main_charger_v_convert; 647 + struct ab8500_gpadc *gpadc; 648 + 649 + gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); 650 + main_charger_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_V); 651 + main_charger_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, 652 + MAIN_CHARGER_V, main_charger_v_raw); 653 + 654 + return seq_printf(s, "%d,0x%X\n", 655 + main_charger_v_convert, main_charger_v_raw); 656 + } 657 + 658 + static int ab8500_gpadc_main_charger_v_open(struct inode *inode, 659 + struct file *file) 660 + { 661 + return single_open(file, ab8500_gpadc_main_charger_v_print, 662 + inode->i_private); 663 + } 664 + 665 + static const struct file_operations ab8500_gpadc_main_charger_v_fops = { 666 + .open = ab8500_gpadc_main_charger_v_open, 667 + .read = seq_read, 668 + .llseek = seq_lseek, 669 + .release = single_release, 670 + .owner = THIS_MODULE, 671 + }; 672 + 673 + static int ab8500_gpadc_acc_detect1_print(struct seq_file *s, void *p) 674 + { 675 + int acc_detect1_raw; 676 + int acc_detect1_convert; 677 + struct ab8500_gpadc *gpadc; 678 + 679 + gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); 680 + acc_detect1_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT1); 681 + acc_detect1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ACC_DETECT1, 682 + acc_detect1_raw); 683 + 684 + return seq_printf(s, "%d,0x%X\n", 685 + acc_detect1_convert, acc_detect1_raw); 686 + } 687 + 688 + static int ab8500_gpadc_acc_detect1_open(struct inode *inode, 689 + struct file *file) 690 + { 691 + return single_open(file, ab8500_gpadc_acc_detect1_print, 692 + inode->i_private); 693 + } 694 + 695 + static const struct file_operations ab8500_gpadc_acc_detect1_fops = { 696 + .open = ab8500_gpadc_acc_detect1_open, 697 + .read = seq_read, 698 + .llseek = seq_lseek, 699 + .release = single_release, 700 + .owner = THIS_MODULE, 701 + }; 702 + 703 + static int ab8500_gpadc_acc_detect2_print(struct seq_file *s, void *p) 704 + { 705 + int acc_detect2_raw; 706 + int acc_detect2_convert; 707 + struct ab8500_gpadc *gpadc; 708 + 709 + gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); 710 + acc_detect2_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT2); 711 + acc_detect2_convert = ab8500_gpadc_ad_to_voltage(gpadc, 712 + ACC_DETECT2, acc_detect2_raw); 713 + 714 + return seq_printf(s, "%d,0x%X\n", 715 + acc_detect2_convert, acc_detect2_raw); 716 + } 717 + 718 + static int ab8500_gpadc_acc_detect2_open(struct inode *inode, 719 + struct file *file) 720 + { 721 + return single_open(file, ab8500_gpadc_acc_detect2_print, 722 + inode->i_private); 723 + } 724 + 725 + static const struct file_operations ab8500_gpadc_acc_detect2_fops = { 726 + .open = ab8500_gpadc_acc_detect2_open, 727 + .read = seq_read, 728 + .llseek = seq_lseek, 729 + .release = single_release, 730 + .owner = THIS_MODULE, 731 + }; 732 + 733 + static int ab8500_gpadc_aux1_print(struct seq_file *s, void *p) 734 + { 735 + int aux1_raw; 736 + int aux1_convert; 737 + struct ab8500_gpadc *gpadc; 738 + 739 + gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); 740 + aux1_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX1); 741 + aux1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX1, 742 + aux1_raw); 743 + 744 + return seq_printf(s, "%d,0x%X\n", 745 + aux1_convert, aux1_raw); 746 + } 747 + 748 + static int ab8500_gpadc_aux1_open(struct inode *inode, struct file *file) 749 + { 750 + return single_open(file, ab8500_gpadc_aux1_print, inode->i_private); 751 + } 752 + 753 + static const struct file_operations ab8500_gpadc_aux1_fops = { 754 + .open = ab8500_gpadc_aux1_open, 755 + .read = seq_read, 756 + .llseek = seq_lseek, 757 + .release = single_release, 758 + .owner = THIS_MODULE, 759 + }; 760 + 761 + static int ab8500_gpadc_aux2_print(struct seq_file *s, void *p) 762 + { 763 + int aux2_raw; 764 + int aux2_convert; 765 + struct ab8500_gpadc *gpadc; 766 + 767 + gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); 768 + aux2_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX2); 769 + aux2_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX2, 770 + aux2_raw); 771 + 772 + return seq_printf(s, "%d,0x%X\n", 773 + aux2_convert, aux2_raw); 774 + } 775 + 776 + static int ab8500_gpadc_aux2_open(struct inode *inode, struct file *file) 777 + { 778 + return single_open(file, ab8500_gpadc_aux2_print, inode->i_private); 779 + } 780 + 781 + static const struct file_operations ab8500_gpadc_aux2_fops = { 782 + .open = ab8500_gpadc_aux2_open, 783 + .read = seq_read, 784 + .llseek = seq_lseek, 785 + .release = single_release, 786 + .owner = THIS_MODULE, 787 + }; 788 + 789 + static int ab8500_gpadc_main_bat_v_print(struct seq_file *s, void *p) 790 + { 791 + int main_bat_v_raw; 792 + int main_bat_v_convert; 793 + struct ab8500_gpadc *gpadc; 794 + 795 + gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); 796 + main_bat_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_BAT_V); 797 + main_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V, 798 + main_bat_v_raw); 799 + 800 + return seq_printf(s, "%d,0x%X\n", 801 + main_bat_v_convert, main_bat_v_raw); 802 + } 803 + 804 + static int ab8500_gpadc_main_bat_v_open(struct inode *inode, 805 + struct file *file) 806 + { 807 + return single_open(file, ab8500_gpadc_main_bat_v_print, inode->i_private); 808 + } 809 + 810 + static const struct file_operations ab8500_gpadc_main_bat_v_fops = { 811 + .open = ab8500_gpadc_main_bat_v_open, 812 + .read = seq_read, 813 + .llseek = seq_lseek, 814 + .release = single_release, 815 + .owner = THIS_MODULE, 816 + }; 817 + 818 + static int ab8500_gpadc_vbus_v_print(struct seq_file *s, void *p) 819 + { 820 + int vbus_v_raw; 821 + int vbus_v_convert; 822 + struct ab8500_gpadc *gpadc; 823 + 824 + gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); 825 + vbus_v_raw = ab8500_gpadc_read_raw(gpadc, VBUS_V); 826 + vbus_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, VBUS_V, 827 + vbus_v_raw); 828 + 829 + return seq_printf(s, "%d,0x%X\n", 830 + vbus_v_convert, vbus_v_raw); 831 + } 832 + 833 + static int ab8500_gpadc_vbus_v_open(struct inode *inode, struct file *file) 834 + { 835 + return single_open(file, ab8500_gpadc_vbus_v_print, inode->i_private); 836 + } 837 + 838 + static const struct file_operations ab8500_gpadc_vbus_v_fops = { 839 + .open = ab8500_gpadc_vbus_v_open, 840 + .read = seq_read, 841 + .llseek = seq_lseek, 842 + .release = single_release, 843 + .owner = THIS_MODULE, 844 + }; 845 + 846 + static int ab8500_gpadc_main_charger_c_print(struct seq_file *s, void *p) 847 + { 848 + int main_charger_c_raw; 849 + int main_charger_c_convert; 850 + struct ab8500_gpadc *gpadc; 851 + 852 + gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); 853 + main_charger_c_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_C); 854 + main_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc, 855 + MAIN_CHARGER_C, main_charger_c_raw); 856 + 857 + return seq_printf(s, "%d,0x%X\n", 858 + main_charger_c_convert, main_charger_c_raw); 859 + } 860 + 861 + static int ab8500_gpadc_main_charger_c_open(struct inode *inode, 862 + struct file *file) 863 + { 864 + return single_open(file, ab8500_gpadc_main_charger_c_print, 865 + inode->i_private); 866 + } 867 + 868 + static const struct file_operations ab8500_gpadc_main_charger_c_fops = { 869 + .open = ab8500_gpadc_main_charger_c_open, 870 + .read = seq_read, 871 + .llseek = seq_lseek, 872 + .release = single_release, 873 + .owner = THIS_MODULE, 874 + }; 875 + 876 + static int ab8500_gpadc_usb_charger_c_print(struct seq_file *s, void *p) 877 + { 878 + int usb_charger_c_raw; 879 + int usb_charger_c_convert; 880 + struct ab8500_gpadc *gpadc; 881 + 882 + gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); 883 + usb_charger_c_raw = ab8500_gpadc_read_raw(gpadc, USB_CHARGER_C); 884 + usb_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc, 885 + USB_CHARGER_C, usb_charger_c_raw); 886 + 887 + return seq_printf(s, "%d,0x%X\n", 888 + usb_charger_c_convert, usb_charger_c_raw); 889 + } 890 + 891 + static int ab8500_gpadc_usb_charger_c_open(struct inode *inode, 892 + struct file *file) 893 + { 894 + return single_open(file, ab8500_gpadc_usb_charger_c_print, 895 + inode->i_private); 896 + } 897 + 898 + static const struct file_operations ab8500_gpadc_usb_charger_c_fops = { 899 + .open = ab8500_gpadc_usb_charger_c_open, 900 + .read = seq_read, 901 + .llseek = seq_lseek, 902 + .release = single_release, 903 + .owner = THIS_MODULE, 904 + }; 905 + 906 + static int ab8500_gpadc_bk_bat_v_print(struct seq_file *s, void *p) 907 + { 908 + int bk_bat_v_raw; 909 + int bk_bat_v_convert; 910 + struct ab8500_gpadc *gpadc; 911 + 912 + gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); 913 + bk_bat_v_raw = ab8500_gpadc_read_raw(gpadc, BK_BAT_V); 914 + bk_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, 915 + BK_BAT_V, bk_bat_v_raw); 916 + 917 + return seq_printf(s, "%d,0x%X\n", 918 + bk_bat_v_convert, bk_bat_v_raw); 919 + } 920 + 921 + static int ab8500_gpadc_bk_bat_v_open(struct inode *inode, struct file *file) 922 + { 923 + return single_open(file, ab8500_gpadc_bk_bat_v_print, inode->i_private); 924 + } 925 + 926 + static const struct file_operations ab8500_gpadc_bk_bat_v_fops = { 927 + .open = ab8500_gpadc_bk_bat_v_open, 928 + .read = seq_read, 929 + .llseek = seq_lseek, 930 + .release = single_release, 931 + .owner = THIS_MODULE, 932 + }; 933 + 934 + static int ab8500_gpadc_die_temp_print(struct seq_file *s, void *p) 935 + { 936 + int die_temp_raw; 937 + int die_temp_convert; 938 + struct ab8500_gpadc *gpadc; 939 + 940 + gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); 941 + die_temp_raw = ab8500_gpadc_read_raw(gpadc, DIE_TEMP); 942 + die_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, DIE_TEMP, 943 + die_temp_raw); 944 + 945 + return seq_printf(s, "%d,0x%X\n", 946 + die_temp_convert, die_temp_raw); 947 + } 948 + 949 + static int ab8500_gpadc_die_temp_open(struct inode *inode, struct file *file) 950 + { 951 + return single_open(file, ab8500_gpadc_die_temp_print, inode->i_private); 952 + } 953 + 954 + static const struct file_operations ab8500_gpadc_die_temp_fops = { 955 + .open = ab8500_gpadc_die_temp_open, 956 + .read = seq_read, 957 + .llseek = seq_lseek, 958 + .release = single_release, 959 + .owner = THIS_MODULE, 960 + }; 961 + 962 + /* 963 + * return length of an ASCII numerical value, 0 is string is not a 964 + * numerical value. 965 + * string shall start at value 1st char. 966 + * string can be tailed with \0 or space or newline chars only. 967 + * value can be decimal or hexadecimal (prefixed 0x or 0X). 968 + */ 969 + static int strval_len(char *b) 970 + { 971 + char *s = b; 972 + if ((*s == '0') && ((*(s+1) == 'x') || (*(s+1) == 'X'))) { 973 + s += 2; 974 + for (; *s && (*s != ' ') && (*s != '\n'); s++) { 975 + if (!isxdigit(*s)) 976 + return 0; 977 + } 978 + } else { 979 + if (*s == '-') 980 + s++; 981 + for (; *s && (*s != ' ') && (*s != '\n'); s++) { 982 + if (!isdigit(*s)) 983 + return 0; 984 + } 985 + } 986 + return (int) (s-b); 987 + } 988 + 989 + /* 990 + * parse hwreg input data. 991 + * update global hwreg_cfg only if input data syntax is ok. 992 + */ 993 + static ssize_t hwreg_common_write(char *b, struct hwreg_cfg *cfg, 994 + struct device *dev) 995 + { 996 + uint write, val = 0; 997 + u8 regvalue; 998 + int ret; 999 + struct hwreg_cfg loc = { 1000 + .bank = 0, /* default: invalid phys addr */ 1001 + .addr = 0, /* default: invalid phys addr */ 1002 + .fmt = 0, /* default: 32bit access, hex output */ 1003 + .mask = 0xFFFFFFFF, /* default: no mask */ 1004 + .shift = 0, /* default: no bit shift */ 1005 + }; 1006 + 1007 + /* read or write ? */ 1008 + if (!strncmp(b, "read ", 5)) { 1009 + write = 0; 1010 + b += 5; 1011 + } else if (!strncmp(b, "write ", 6)) { 1012 + write = 1; 1013 + b += 6; 1014 + } else 1015 + return -EINVAL; 1016 + 1017 + /* OPTIONS -l|-w|-b -s -m -o */ 1018 + while ((*b == ' ') || (*b == '-')) { 1019 + if (*(b-1) != ' ') { 1020 + b++; 1021 + continue; 1022 + } 1023 + if ((!strncmp(b, "-d ", 3)) || 1024 + (!strncmp(b, "-dec ", 5))) { 1025 + b += (*(b+2) == ' ') ? 3 : 5; 1026 + loc.fmt |= (1<<0); 1027 + } else if ((!strncmp(b, "-h ", 3)) || 1028 + (!strncmp(b, "-hex ", 5))) { 1029 + b += (*(b+2) == ' ') ? 3 : 5; 1030 + loc.fmt &= ~(1<<0); 1031 + } else if ((!strncmp(b, "-m ", 3)) || 1032 + (!strncmp(b, "-mask ", 6))) { 1033 + b += (*(b+2) == ' ') ? 3 : 6; 1034 + if (strval_len(b) == 0) 1035 + return -EINVAL; 1036 + loc.mask = simple_strtoul(b, &b, 0); 1037 + } else if ((!strncmp(b, "-s ", 3)) || 1038 + (!strncmp(b, "-shift ", 7))) { 1039 + b += (*(b+2) == ' ') ? 3 : 7; 1040 + if (strval_len(b) == 0) 1041 + return -EINVAL; 1042 + loc.shift = simple_strtol(b, &b, 0); 1043 + } else { 1044 + return -EINVAL; 1045 + } 1046 + } 1047 + /* get arg BANK and ADDRESS */ 1048 + if (strval_len(b) == 0) 1049 + return -EINVAL; 1050 + loc.bank = simple_strtoul(b, &b, 0); 1051 + while (*b == ' ') 1052 + b++; 1053 + if (strval_len(b) == 0) 1054 + return -EINVAL; 1055 + loc.addr = simple_strtoul(b, &b, 0); 1056 + 1057 + if (write) { 1058 + while (*b == ' ') 1059 + b++; 1060 + if (strval_len(b) == 0) 1061 + return -EINVAL; 1062 + val = simple_strtoul(b, &b, 0); 1063 + } 1064 + 1065 + /* args are ok, update target cfg (mainly for read) */ 1066 + *cfg = loc; 1067 + 1068 + #ifdef ABB_HWREG_DEBUG 1069 + pr_warn("HWREG request: %s, %s, addr=0x%08X, mask=0x%X, shift=%d" 1070 + "value=0x%X\n", (write) ? "write" : "read", 1071 + REG_FMT_DEC(cfg) ? "decimal" : "hexa", 1072 + cfg->addr, cfg->mask, cfg->shift, val); 1073 + #endif 1074 + 1075 + if (!write) 1076 + return 0; 1077 + 1078 + ret = abx500_get_register_interruptible(dev, 1079 + (u8)cfg->bank, (u8)cfg->addr, &regvalue); 1080 + if (ret < 0) { 1081 + dev_err(dev, "abx500_get_reg fail %d, %d\n", 1082 + ret, __LINE__); 1083 + return -EINVAL; 1084 + } 1085 + 1086 + if (cfg->shift >= 0) { 1087 + regvalue &= ~(cfg->mask << (cfg->shift)); 1088 + val = (val & cfg->mask) << (cfg->shift); 1089 + } else { 1090 + regvalue &= ~(cfg->mask >> (-cfg->shift)); 1091 + val = (val & cfg->mask) >> (-cfg->shift); 1092 + } 1093 + val = val | regvalue; 1094 + 1095 + ret = abx500_set_register_interruptible(dev, 1096 + (u8)cfg->bank, (u8)cfg->addr, (u8)val); 1097 + if (ret < 0) { 1098 + pr_err("abx500_set_reg failed %d, %d", ret, __LINE__); 1099 + return -EINVAL; 1100 + } 1101 + 1102 + return 0; 1103 + } 1104 + 1105 + static ssize_t ab8500_hwreg_write(struct file *file, 1106 + const char __user *user_buf, size_t count, loff_t *ppos) 1107 + { 1108 + struct device *dev = ((struct seq_file *)(file->private_data))->private; 1109 + char buf[128]; 1110 + int buf_size, ret; 1111 + 1112 + /* Get userspace string and assure termination */ 1113 + buf_size = min(count, (sizeof(buf)-1)); 1114 + if (copy_from_user(buf, user_buf, buf_size)) 1115 + return -EFAULT; 1116 + buf[buf_size] = 0; 1117 + 1118 + /* get args and process */ 1119 + ret = hwreg_common_write(buf, &hwreg_cfg, dev); 1120 + return (ret) ? ret : buf_size; 1121 + } 1122 + 1123 + /* 1124 + * - irq subscribe/unsubscribe stuff 1125 + */ 1126 + static int ab8500_subscribe_unsubscribe_print(struct seq_file *s, void *p) 1127 + { 1128 + seq_printf(s, "%d\n", irq_first); 1129 + 1130 + return 0; 1131 + } 1132 + 1133 + static int ab8500_subscribe_unsubscribe_open(struct inode *inode, 1134 + struct file *file) 1135 + { 1136 + return single_open(file, ab8500_subscribe_unsubscribe_print, 1137 + inode->i_private); 1138 + } 1139 + 1140 + /* 1141 + * Userspace should use poll() on this file. When an event occur 1142 + * the blocking poll will be released. 1143 + */ 1144 + static ssize_t show_irq(struct device *dev, 1145 + struct device_attribute *attr, char *buf) 1146 + { 1147 + unsigned long name; 1148 + unsigned int irq_index; 1149 + int err; 1150 + 1151 + err = strict_strtoul(attr->attr.name, 0, &name); 1152 + if (err) 1153 + return err; 1154 + 1155 + irq_index = name - irq_first; 1156 + if (irq_index >= num_irqs) 1157 + return -EINVAL; 1158 + else 1159 + return sprintf(buf, "%u\n", irq_count[irq_index]); 1160 + } 1161 + 1162 + static ssize_t ab8500_subscribe_write(struct file *file, 1163 + const char __user *user_buf, 1164 + size_t count, loff_t *ppos) 1165 + { 1166 + struct device *dev = ((struct seq_file *)(file->private_data))->private; 1167 + char buf[32]; 1168 + int buf_size; 1169 + unsigned long user_val; 1170 + int err; 1171 + unsigned int irq_index; 1172 + 1173 + /* Get userspace string and assure termination */ 1174 + buf_size = min(count, (sizeof(buf)-1)); 1175 + if (copy_from_user(buf, user_buf, buf_size)) 1176 + return -EFAULT; 1177 + buf[buf_size] = 0; 1178 + 1179 + err = strict_strtoul(buf, 0, &user_val); 1180 + if (err) 1181 + return -EINVAL; 1182 + if (user_val < irq_first) { 1183 + dev_err(dev, "debugfs error input < %d\n", irq_first); 1184 + return -EINVAL; 1185 + } 1186 + if (user_val > irq_last) { 1187 + dev_err(dev, "debugfs error input > %d\n", irq_last); 1188 + return -EINVAL; 1189 + } 1190 + 1191 + irq_index = user_val - irq_first; 1192 + if (irq_index >= num_irqs) 1193 + return -EINVAL; 1194 + 1195 + /* 1196 + * This will create a sysfs file named <irq-nr> which userspace can 1197 + * use to select or poll and get the AB8500 events 1198 + */ 1199 + dev_attr[irq_index] = kmalloc(sizeof(struct device_attribute), 1200 + GFP_KERNEL); 1201 + event_name[irq_index] = kmalloc(buf_size, GFP_KERNEL); 1202 + sprintf(event_name[irq_index], "%lu", user_val); 1203 + dev_attr[irq_index]->show = show_irq; 1204 + dev_attr[irq_index]->store = NULL; 1205 + dev_attr[irq_index]->attr.name = event_name[irq_index]; 1206 + dev_attr[irq_index]->attr.mode = S_IRUGO; 1207 + err = sysfs_create_file(&dev->kobj, &dev_attr[irq_index]->attr); 1208 + if (err < 0) { 1209 + printk(KERN_ERR "sysfs_create_file failed %d\n", err); 1210 + return err; 1211 + } 1212 + 1213 + err = request_threaded_irq(user_val, NULL, ab8500_debug_handler, 1214 + IRQF_SHARED | IRQF_NO_SUSPEND, 1215 + "ab8500-debug", &dev->kobj); 1216 + if (err < 0) { 1217 + printk(KERN_ERR "request_threaded_irq failed %d, %lu\n", 1218 + err, user_val); 1219 + sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr); 1220 + return err; 1221 + } 1222 + 1223 + return buf_size; 1224 + } 1225 + 1226 + static ssize_t ab8500_unsubscribe_write(struct file *file, 1227 + const char __user *user_buf, 1228 + size_t count, loff_t *ppos) 1229 + { 1230 + struct device *dev = ((struct seq_file *)(file->private_data))->private; 1231 + char buf[32]; 1232 + int buf_size; 1233 + unsigned long user_val; 1234 + int err; 1235 + unsigned int irq_index; 1236 + 1237 + /* Get userspace string and assure termination */ 1238 + buf_size = min(count, (sizeof(buf)-1)); 1239 + if (copy_from_user(buf, user_buf, buf_size)) 1240 + return -EFAULT; 1241 + buf[buf_size] = 0; 1242 + 1243 + err = strict_strtoul(buf, 0, &user_val); 1244 + if (err) 1245 + return -EINVAL; 1246 + if (user_val < irq_first) { 1247 + dev_err(dev, "debugfs error input < %d\n", irq_first); 1248 + return -EINVAL; 1249 + } 1250 + if (user_val > irq_last) { 1251 + dev_err(dev, "debugfs error input > %d\n", irq_last); 1252 + return -EINVAL; 1253 + } 1254 + 1255 + irq_index = user_val - irq_first; 1256 + if (irq_index >= num_irqs) 1257 + return -EINVAL; 1258 + 1259 + /* Set irq count to 0 when unsubscribe */ 1260 + irq_count[irq_index] = 0; 1261 + 1262 + if (dev_attr[irq_index]) 1263 + sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr); 1264 + 1265 + 1266 + free_irq(user_val, &dev->kobj); 1267 + kfree(event_name[irq_index]); 1268 + kfree(dev_attr[irq_index]); 1269 + 1270 + return buf_size; 1271 + } 1272 + 1273 + /* 1274 + * - several deubgfs nodes fops 1275 + */ 1276 + 740 1277 static const struct file_operations ab8500_bank_fops = { 741 1278 .open = ab8500_bank_open, 742 1279 .write = ab8500_bank_write, ··· 1519 546 .owner = THIS_MODULE, 1520 547 }; 1521 548 549 + static const struct file_operations ab8500_interrupts_fops = { 550 + .open = ab8500_interrupts_open, 551 + .read = seq_read, 552 + .llseek = seq_lseek, 553 + .release = single_release, 554 + .owner = THIS_MODULE, 555 + }; 556 + 557 + static const struct file_operations ab8500_subscribe_fops = { 558 + .open = ab8500_subscribe_unsubscribe_open, 559 + .write = ab8500_subscribe_write, 560 + .read = seq_read, 561 + .llseek = seq_lseek, 562 + .release = single_release, 563 + .owner = THIS_MODULE, 564 + }; 565 + 566 + static const struct file_operations ab8500_unsubscribe_fops = { 567 + .open = ab8500_subscribe_unsubscribe_open, 568 + .write = ab8500_unsubscribe_write, 569 + .read = seq_read, 570 + .llseek = seq_lseek, 571 + .release = single_release, 572 + .owner = THIS_MODULE, 573 + }; 574 + 575 + static const struct file_operations ab8500_hwreg_fops = { 576 + .open = ab8500_hwreg_open, 577 + .write = ab8500_hwreg_write, 578 + .read = seq_read, 579 + .llseek = seq_lseek, 580 + .release = single_release, 581 + .owner = THIS_MODULE, 582 + }; 583 + 1522 584 static struct dentry *ab8500_dir; 1523 - static struct dentry *ab8500_reg_file; 1524 - static struct dentry *ab8500_bank_file; 1525 - static struct dentry *ab8500_address_file; 1526 - static struct dentry *ab8500_val_file; 585 + static struct dentry *ab8500_gpadc_dir; 1527 586 1528 587 static int ab8500_debug_probe(struct platform_device *plf) 1529 588 { 589 + struct dentry *file; 590 + int ret = -ENOMEM; 591 + struct ab8500 *ab8500; 1530 592 debug_bank = AB8500_MISC; 1531 593 debug_address = AB8500_REV_REG & 0x00FF; 1532 594 595 + ab8500 = dev_get_drvdata(plf->dev.parent); 596 + num_irqs = ab8500->mask_size; 597 + 598 + irq_count = kzalloc(sizeof(*irq_count)*num_irqs, GFP_KERNEL); 599 + if (!irq_count) 600 + return -ENOMEM; 601 + 602 + dev_attr = kzalloc(sizeof(*dev_attr)*num_irqs,GFP_KERNEL); 603 + if (!dev_attr) 604 + goto out_freeirq_count; 605 + 606 + event_name = kzalloc(sizeof(*event_name)*num_irqs, GFP_KERNEL); 607 + if (!event_name) 608 + goto out_freedev_attr; 609 + 610 + irq_first = platform_get_irq_byname(plf, "IRQ_FIRST"); 611 + if (irq_first < 0) { 612 + dev_err(&plf->dev, "First irq not found, err %d\n", 613 + irq_first); 614 + ret = irq_first; 615 + goto out_freeevent_name; 616 + } 617 + 618 + irq_last = platform_get_irq_byname(plf, "IRQ_LAST"); 619 + if (irq_last < 0) { 620 + dev_err(&plf->dev, "Last irq not found, err %d\n", 621 + irq_last); 622 + ret = irq_last; 623 + goto out_freeevent_name; 624 + } 625 + 1533 626 ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL); 1534 627 if (!ab8500_dir) 1535 - goto exit_no_debugfs; 628 + goto err; 1536 629 1537 - ab8500_reg_file = debugfs_create_file("all-bank-registers", 1538 - S_IRUGO, ab8500_dir, &plf->dev, &ab8500_registers_fops); 1539 - if (!ab8500_reg_file) 1540 - goto exit_destroy_dir; 630 + ab8500_gpadc_dir = debugfs_create_dir(AB8500_ADC_NAME_STRING, 631 + ab8500_dir); 632 + if (!ab8500_gpadc_dir) 633 + goto err; 1541 634 1542 - ab8500_bank_file = debugfs_create_file("register-bank", 1543 - (S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev, &ab8500_bank_fops); 1544 - if (!ab8500_bank_file) 1545 - goto exit_destroy_reg; 635 + file = debugfs_create_file("all-bank-registers", S_IRUGO, 636 + ab8500_dir, &plf->dev, &ab8500_registers_fops); 637 + if (!file) 638 + goto err; 1546 639 1547 - ab8500_address_file = debugfs_create_file("register-address", 1548 - (S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev, 1549 - &ab8500_address_fops); 1550 - if (!ab8500_address_file) 1551 - goto exit_destroy_bank; 640 + file = debugfs_create_file("all-banks", S_IRUGO, 641 + ab8500_dir, &plf->dev, &ab8500_all_banks_fops); 642 + if (!file) 643 + goto err; 1552 644 1553 - ab8500_val_file = debugfs_create_file("register-value", 1554 - (S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev, &ab8500_val_fops); 1555 - if (!ab8500_val_file) 1556 - goto exit_destroy_address; 645 + file = debugfs_create_file("register-bank", (S_IRUGO | S_IWUSR), 646 + ab8500_dir, &plf->dev, &ab8500_bank_fops); 647 + if (!file) 648 + goto err; 649 + 650 + file = debugfs_create_file("register-address", (S_IRUGO | S_IWUSR), 651 + ab8500_dir, &plf->dev, &ab8500_address_fops); 652 + if (!file) 653 + goto err; 654 + 655 + file = debugfs_create_file("register-value", (S_IRUGO | S_IWUSR), 656 + ab8500_dir, &plf->dev, &ab8500_val_fops); 657 + if (!file) 658 + goto err; 659 + 660 + file = debugfs_create_file("irq-subscribe", (S_IRUGO | S_IWUSR), 661 + ab8500_dir, &plf->dev, &ab8500_subscribe_fops); 662 + if (!file) 663 + goto err; 664 + 665 + if (is_ab8500(ab8500)) 666 + num_interrupt_lines = AB8500_NR_IRQS; 667 + else if (is_ab8505(ab8500)) 668 + num_interrupt_lines = AB8505_NR_IRQS; 669 + else if (is_ab9540(ab8500)) 670 + num_interrupt_lines = AB9540_NR_IRQS; 671 + 672 + file = debugfs_create_file("interrupts", (S_IRUGO), 673 + ab8500_dir, &plf->dev, &ab8500_interrupts_fops); 674 + if (!file) 675 + goto err; 676 + 677 + file = debugfs_create_file("irq-unsubscribe", (S_IRUGO | S_IWUSR), 678 + ab8500_dir, &plf->dev, &ab8500_unsubscribe_fops); 679 + if (!file) 680 + goto err; 681 + 682 + file = debugfs_create_file("hwreg", (S_IRUGO | S_IWUSR), 683 + ab8500_dir, &plf->dev, &ab8500_hwreg_fops); 684 + if (!file) 685 + goto err; 686 + 687 + file = debugfs_create_file("bat_ctrl", (S_IRUGO | S_IWUSR), 688 + ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_bat_ctrl_fops); 689 + if (!file) 690 + goto err; 691 + 692 + file = debugfs_create_file("btemp_ball", (S_IRUGO | S_IWUSR), 693 + ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_btemp_ball_fops); 694 + if (!file) 695 + goto err; 696 + 697 + file = debugfs_create_file("main_charger_v", (S_IRUGO | S_IWUSR), 698 + ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_charger_v_fops); 699 + if (!file) 700 + goto err; 701 + 702 + file = debugfs_create_file("acc_detect1", (S_IRUGO | S_IWUSR), 703 + ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_acc_detect1_fops); 704 + if (!file) 705 + goto err; 706 + 707 + file = debugfs_create_file("acc_detect2", (S_IRUGO | S_IWUSR), 708 + ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_acc_detect2_fops); 709 + if (!file) 710 + goto err; 711 + 712 + file = debugfs_create_file("adc_aux1", (S_IRUGO | S_IWUSR), 713 + ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_aux1_fops); 714 + if (!file) 715 + goto err; 716 + 717 + file = debugfs_create_file("adc_aux2", (S_IRUGO | S_IWUSR), 718 + ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_aux2_fops); 719 + if (!file) 720 + goto err; 721 + 722 + file = debugfs_create_file("main_bat_v", (S_IRUGO | S_IWUSR), 723 + ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_bat_v_fops); 724 + if (!file) 725 + goto err; 726 + 727 + file = debugfs_create_file("vbus_v", (S_IRUGO | S_IWUSR), 728 + ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_vbus_v_fops); 729 + if (!file) 730 + goto err; 731 + 732 + file = debugfs_create_file("main_charger_c", (S_IRUGO | S_IWUSR), 733 + ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_charger_c_fops); 734 + if (!file) 735 + goto err; 736 + 737 + file = debugfs_create_file("usb_charger_c", (S_IRUGO | S_IWUSR), 738 + ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_usb_charger_c_fops); 739 + if (!file) 740 + goto err; 741 + 742 + file = debugfs_create_file("bk_bat_v", (S_IRUGO | S_IWUSR), 743 + ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_bk_bat_v_fops); 744 + if (!file) 745 + goto err; 746 + 747 + file = debugfs_create_file("die_temp", (S_IRUGO | S_IWUSR), 748 + ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_die_temp_fops); 749 + if (!file) 750 + goto err; 1557 751 1558 752 return 0; 1559 753 1560 - exit_destroy_address: 1561 - debugfs_remove(ab8500_address_file); 1562 - exit_destroy_bank: 1563 - debugfs_remove(ab8500_bank_file); 1564 - exit_destroy_reg: 1565 - debugfs_remove(ab8500_reg_file); 1566 - exit_destroy_dir: 1567 - debugfs_remove(ab8500_dir); 1568 - exit_no_debugfs: 754 + err: 755 + if (ab8500_dir) 756 + debugfs_remove_recursive(ab8500_dir); 1569 757 dev_err(&plf->dev, "failed to create debugfs entries.\n"); 1570 - return -ENOMEM; 758 + out_freeevent_name: 759 + kfree(event_name); 760 + out_freedev_attr: 761 + kfree(dev_attr); 762 + out_freeirq_count: 763 + kfree(irq_count); 764 + 765 + return ret; 1571 766 } 1572 767 1573 768 static int ab8500_debug_remove(struct platform_device *plf) 1574 769 { 1575 - debugfs_remove(ab8500_val_file); 1576 - debugfs_remove(ab8500_address_file); 1577 - debugfs_remove(ab8500_bank_file); 1578 - debugfs_remove(ab8500_reg_file); 1579 - debugfs_remove(ab8500_dir); 770 + debugfs_remove_recursive(ab8500_dir); 771 + kfree(event_name); 772 + kfree(dev_attr); 773 + kfree(irq_count); 1580 774 1581 775 return 0; 1582 776 }
+71 -19
drivers/mfd/ab8500-gpadc.c
··· 12 12 #include <linux/interrupt.h> 13 13 #include <linux/spinlock.h> 14 14 #include <linux/delay.h> 15 + #include <linux/pm_runtime.h> 15 16 #include <linux/platform_device.h> 16 17 #include <linux/completion.h> 17 18 #include <linux/regulator/consumer.h> ··· 83 82 /* This is used to not lose precision when dividing to get gain and offset */ 84 83 #define CALIB_SCALE 1000 85 84 85 + /* Time in ms before disabling regulator */ 86 + #define GPADC_AUDOSUSPEND_DELAY 1 87 + 88 + #define CONVERSION_TIME 500 /* ms */ 89 + 86 90 enum cal_channels { 87 91 ADC_INPUT_VMAIN = 0, 88 92 ADC_INPUT_BTEMP, ··· 108 102 109 103 /** 110 104 * struct ab8500_gpadc - AB8500 GPADC device information 111 - * @chip_id ABB chip id 112 105 * @dev: pointer to the struct device 113 106 * @node: a list of AB8500 GPADCs, hence prepared for 114 107 reentrance 108 + * @parent: pointer to the struct ab8500 115 109 * @ab8500_gpadc_complete: pointer to the struct completion, to indicate 116 110 * the completion of gpadc conversion 117 111 * @ab8500_gpadc_lock: structure of type mutex ··· 120 114 * @cal_data array of ADC calibration data structs 121 115 */ 122 116 struct ab8500_gpadc { 123 - u8 chip_id; 124 117 struct device *dev; 125 118 struct list_head node; 119 + struct ab8500 *parent; 126 120 struct completion ab8500_gpadc_complete; 127 121 struct mutex ab8500_gpadc_lock; 128 122 struct regulator *regu; ··· 288 282 return -ENODEV; 289 283 290 284 mutex_lock(&gpadc->ab8500_gpadc_lock); 285 + 291 286 /* Enable VTVout LDO this is required for GPADC */ 292 - regulator_enable(gpadc->regu); 287 + pm_runtime_get_sync(gpadc->dev); 293 288 294 289 /* Check if ADC is not busy, lock and proceed */ 295 290 do { ··· 339 332 EN_BUF | EN_ICHAR); 340 333 break; 341 334 case BTEMP_BALL: 342 - if (gpadc->chip_id >= AB8500_CUT3P0) { 335 + if (!is_ab8500_2p0_or_earlier(gpadc->parent)) { 343 336 /* Turn on btemp pull-up on ABB 3.0 */ 344 337 ret = abx500_mask_and_set_register_interruptible( 345 338 gpadc->dev, ··· 351 344 * Delay might be needed for ABB8500 cut 3.0, if not, remove 352 345 * when hardware will be available 353 346 */ 354 - msleep(1); 347 + usleep_range(1000, 1000); 355 348 break; 356 349 } 357 350 /* Intentional fallthrough */ ··· 374 367 goto out; 375 368 } 376 369 /* wait for completion of conversion */ 377 - if (!wait_for_completion_timeout(&gpadc->ab8500_gpadc_complete, 2*HZ)) { 370 + if (!wait_for_completion_timeout(&gpadc->ab8500_gpadc_complete, 371 + msecs_to_jiffies(CONVERSION_TIME))) { 378 372 dev_err(gpadc->dev, 379 373 "timeout: didn't receive GPADC conversion interrupt\n"); 380 374 ret = -EINVAL; ··· 405 397 dev_err(gpadc->dev, "gpadc_conversion: disable gpadc failed\n"); 406 398 goto out; 407 399 } 408 - /* Disable VTVout LDO this is required for GPADC */ 409 - regulator_disable(gpadc->regu); 400 + 401 + pm_runtime_mark_last_busy(gpadc->dev); 402 + pm_runtime_put_autosuspend(gpadc->dev); 403 + 410 404 mutex_unlock(&gpadc->ab8500_gpadc_lock); 411 405 412 406 return (high_data << 8) | low_data; ··· 422 412 */ 423 413 (void) abx500_set_register_interruptible(gpadc->dev, AB8500_GPADC, 424 414 AB8500_GPADC_CTRL1_REG, DIS_GPADC); 425 - regulator_disable(gpadc->regu); 415 + 416 + pm_runtime_put(gpadc->dev); 417 + 426 418 mutex_unlock(&gpadc->ab8500_gpadc_lock); 427 419 dev_err(gpadc->dev, 428 420 "gpadc_conversion: Failed to AD convert channel %d\n", channel); ··· 583 571 gpadc->cal_data[ADC_INPUT_VBAT].offset); 584 572 } 585 573 574 + static int ab8500_gpadc_runtime_suspend(struct device *dev) 575 + { 576 + struct ab8500_gpadc *gpadc = dev_get_drvdata(dev); 577 + 578 + regulator_disable(gpadc->regu); 579 + return 0; 580 + } 581 + 582 + static int ab8500_gpadc_runtime_resume(struct device *dev) 583 + { 584 + struct ab8500_gpadc *gpadc = dev_get_drvdata(dev); 585 + 586 + regulator_enable(gpadc->regu); 587 + return 0; 588 + } 589 + 590 + static int ab8500_gpadc_runtime_idle(struct device *dev) 591 + { 592 + pm_runtime_suspend(dev); 593 + return 0; 594 + } 595 + 586 596 static int ab8500_gpadc_probe(struct platform_device *pdev) 587 597 { 588 598 int ret = 0; ··· 625 591 } 626 592 627 593 gpadc->dev = &pdev->dev; 594 + gpadc->parent = dev_get_drvdata(pdev->dev.parent); 628 595 mutex_init(&gpadc->ab8500_gpadc_lock); 629 596 630 597 /* Initialize completion used to notify completion of conversion */ ··· 642 607 goto fail; 643 608 } 644 609 645 - /* Get Chip ID of the ABB ASIC */ 646 - ret = abx500_get_chip_id(gpadc->dev); 647 - if (ret < 0) { 648 - dev_err(gpadc->dev, "failed to get chip ID\n"); 649 - goto fail_irq; 650 - } 651 - gpadc->chip_id = (u8) ret; 652 - 653 610 /* VTVout LDO used to power up ab8500-GPADC */ 654 611 gpadc->regu = regulator_get(&pdev->dev, "vddadc"); 655 612 if (IS_ERR(gpadc->regu)) { ··· 649 622 dev_err(gpadc->dev, "failed to get vtvout LDO\n"); 650 623 goto fail_irq; 651 624 } 625 + 626 + platform_set_drvdata(pdev, gpadc); 627 + 628 + regulator_enable(gpadc->regu); 629 + 630 + pm_runtime_set_autosuspend_delay(gpadc->dev, GPADC_AUDOSUSPEND_DELAY); 631 + pm_runtime_use_autosuspend(gpadc->dev); 632 + pm_runtime_set_active(gpadc->dev); 633 + pm_runtime_enable(gpadc->dev); 634 + 652 635 ab8500_gpadc_read_calibration_data(gpadc); 653 636 list_add_tail(&gpadc->node, &ab8500_gpadc_list); 654 637 dev_dbg(gpadc->dev, "probe success\n"); ··· 679 642 list_del(&gpadc->node); 680 643 /* remove interrupt - completion of Sw ADC conversion */ 681 644 free_irq(gpadc->irq, gpadc); 682 - /* disable VTVout LDO that is being used by GPADC */ 683 - regulator_put(gpadc->regu); 645 + 646 + pm_runtime_get_sync(gpadc->dev); 647 + pm_runtime_disable(gpadc->dev); 648 + 649 + regulator_disable(gpadc->regu); 650 + 651 + pm_runtime_set_suspended(gpadc->dev); 652 + 653 + pm_runtime_put_noidle(gpadc->dev); 654 + 684 655 kfree(gpadc); 685 656 gpadc = NULL; 686 657 return 0; 687 658 } 659 + 660 + static const struct dev_pm_ops ab8500_gpadc_pm_ops = { 661 + SET_RUNTIME_PM_OPS(ab8500_gpadc_runtime_suspend, 662 + ab8500_gpadc_runtime_resume, 663 + ab8500_gpadc_runtime_idle) 664 + }; 688 665 689 666 static struct platform_driver ab8500_gpadc_driver = { 690 667 .probe = ab8500_gpadc_probe, ··· 706 655 .driver = { 707 656 .name = "ab8500-gpadc", 708 657 .owner = THIS_MODULE, 658 + .pm = &ab8500_gpadc_pm_ops, 709 659 }, 710 660 }; 711 661
+92
drivers/mfd/ab8500-sysctrl.c
··· 7 7 #include <linux/err.h> 8 8 #include <linux/module.h> 9 9 #include <linux/platform_device.h> 10 + #include <linux/pm.h> 11 + #include <linux/reboot.h> 12 + #include <linux/signal.h> 13 + #include <linux/power_supply.h> 10 14 #include <linux/mfd/abx500.h> 11 15 #include <linux/mfd/abx500/ab8500.h> 12 16 #include <linux/mfd/abx500/ab8500-sysctrl.h> 13 17 14 18 static struct device *sysctrl_dev; 19 + 20 + void ab8500_power_off(void) 21 + { 22 + sigset_t old; 23 + sigset_t all; 24 + static char *pss[] = {"ab8500_ac", "ab8500_usb"}; 25 + int i; 26 + bool charger_present = false; 27 + union power_supply_propval val; 28 + struct power_supply *psy; 29 + int ret; 30 + 31 + /* 32 + * If we have a charger connected and we're powering off, 33 + * reboot into charge-only mode. 34 + */ 35 + 36 + for (i = 0; i < ARRAY_SIZE(pss); i++) { 37 + psy = power_supply_get_by_name(pss[i]); 38 + if (!psy) 39 + continue; 40 + 41 + ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val); 42 + 43 + if (!ret && val.intval) { 44 + charger_present = true; 45 + break; 46 + } 47 + } 48 + 49 + if (!charger_present) 50 + goto shutdown; 51 + 52 + /* Check if battery is known */ 53 + psy = power_supply_get_by_name("ab8500_btemp"); 54 + if (psy) { 55 + ret = psy->get_property(psy, POWER_SUPPLY_PROP_TECHNOLOGY, 56 + &val); 57 + if (!ret && val.intval != POWER_SUPPLY_TECHNOLOGY_UNKNOWN) { 58 + printk(KERN_INFO 59 + "Charger \"%s\" is connected with known battery." 60 + " Rebooting.\n", 61 + pss[i]); 62 + machine_restart("charging"); 63 + } 64 + } 65 + 66 + shutdown: 67 + sigfillset(&all); 68 + 69 + if (!sigprocmask(SIG_BLOCK, &all, &old)) { 70 + (void)ab8500_sysctrl_set(AB8500_STW4500CTRL1, 71 + AB8500_STW4500CTRL1_SWOFF | 72 + AB8500_STW4500CTRL1_SWRESET4500N); 73 + (void)sigprocmask(SIG_SETMASK, &old, NULL); 74 + } 75 + } 15 76 16 77 static inline bool valid_bank(u8 bank) 17 78 { ··· 94 33 return abx500_get_register_interruptible(sysctrl_dev, bank, 95 34 (u8)(reg & 0xFF), value); 96 35 } 36 + EXPORT_SYMBOL(ab8500_sysctrl_read); 97 37 98 38 int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value) 99 39 { ··· 110 48 return abx500_mask_and_set_register_interruptible(sysctrl_dev, bank, 111 49 (u8)(reg & 0xFF), mask, value); 112 50 } 51 + EXPORT_SYMBOL(ab8500_sysctrl_write); 113 52 114 53 static int ab8500_sysctrl_probe(struct platform_device *pdev) 115 54 { 55 + struct ab8500_platform_data *plat; 56 + struct ab8500_sysctrl_platform_data *pdata; 57 + 116 58 sysctrl_dev = &pdev->dev; 59 + plat = dev_get_platdata(pdev->dev.parent); 60 + if (plat->pm_power_off) 61 + pm_power_off = ab8500_power_off; 62 + 63 + pdata = plat->sysctrl; 64 + 65 + if (pdata) { 66 + int ret, i, j; 67 + 68 + for (i = AB8500_SYSCLKREQ1RFCLKBUF; 69 + i <= AB8500_SYSCLKREQ8RFCLKBUF; i++) { 70 + j = i - AB8500_SYSCLKREQ1RFCLKBUF; 71 + ret = ab8500_sysctrl_write(i, 0xff, 72 + pdata->initial_req_buf_config[j]); 73 + dev_dbg(&pdev->dev, 74 + "Setting SysClkReq%dRfClkBuf 0x%X\n", 75 + j + 1, 76 + pdata->initial_req_buf_config[j]); 77 + if (ret < 0) { 78 + dev_err(&pdev->dev, 79 + "unable to set sysClkReq%dRfClkBuf: " 80 + "%d\n", j + 1, ret); 81 + } 82 + } 83 + } 84 + 117 85 return 0; 118 86 } 119 87
+16
drivers/mfd/abx500-core.c
··· 153 153 } 154 154 EXPORT_SYMBOL(abx500_startup_irq_enabled); 155 155 156 + void abx500_dump_all_banks(void) 157 + { 158 + struct abx500_ops *ops; 159 + struct device dummy_child = {0}; 160 + struct abx500_device_entry *dev_entry; 161 + 162 + list_for_each_entry(dev_entry, &abx500_list, list) { 163 + dummy_child.parent = dev_entry->dev; 164 + ops = &dev_entry->ops; 165 + 166 + if ((ops != NULL) && (ops->dump_all_banks != NULL)) 167 + ops->dump_all_banks(&dummy_child); 168 + } 169 + } 170 + EXPORT_SYMBOL(abx500_dump_all_banks); 171 + 156 172 MODULE_AUTHOR("Mattias Wallin <mattias.wallin@stericsson.com>"); 157 173 MODULE_DESCRIPTION("ABX500 core driver"); 158 174 MODULE_LICENSE("GPL");
+52 -3
drivers/mfd/arizona-core.c
··· 115 115 if (val & ARIZONA_ADC_UNDERCLOCKED_STS) 116 116 dev_err(arizona->dev, "ADC underclocked\n"); 117 117 if (val & ARIZONA_MIXER_UNDERCLOCKED_STS) 118 - dev_err(arizona->dev, "Mixer underclocked\n"); 118 + dev_err(arizona->dev, "Mixer dropped sample\n"); 119 119 120 120 return IRQ_HANDLED; 121 121 } ··· 263 263 } 264 264 #endif 265 265 266 + #ifdef CONFIG_PM_SLEEP 267 + static int arizona_resume_noirq(struct device *dev) 268 + { 269 + struct arizona *arizona = dev_get_drvdata(dev); 270 + 271 + dev_dbg(arizona->dev, "Early resume, disabling IRQ\n"); 272 + disable_irq(arizona->irq); 273 + 274 + return 0; 275 + } 276 + 277 + static int arizona_resume(struct device *dev) 278 + { 279 + struct arizona *arizona = dev_get_drvdata(dev); 280 + 281 + dev_dbg(arizona->dev, "Late resume, reenabling IRQ\n"); 282 + enable_irq(arizona->irq); 283 + 284 + return 0; 285 + } 286 + #endif 287 + 266 288 const struct dev_pm_ops arizona_pm_ops = { 267 289 SET_RUNTIME_PM_OPS(arizona_runtime_suspend, 268 290 arizona_runtime_resume, 269 291 NULL) 292 + SET_SYSTEM_SLEEP_PM_OPS(NULL, arizona_resume) 293 + #ifdef CONFIG_PM_SLEEP 294 + .resume_noirq = arizona_resume_noirq, 295 + #endif 270 296 }; 271 297 EXPORT_SYMBOL_GPL(arizona_pm_ops); 272 298 ··· 301 275 }; 302 276 303 277 static struct mfd_cell wm5102_devs[] = { 278 + { .name = "arizona-micsupp" }, 304 279 { .name = "arizona-extcon" }, 305 280 { .name = "arizona-gpio" }, 306 281 { .name = "arizona-haptics" }, 307 - { .name = "arizona-micsupp" }, 308 282 { .name = "arizona-pwm" }, 309 283 { .name = "wm5102-codec" }, 310 284 }; 311 285 312 286 static struct mfd_cell wm5110_devs[] = { 287 + { .name = "arizona-micsupp" }, 313 288 { .name = "arizona-extcon" }, 314 289 { .name = "arizona-gpio" }, 315 290 { .name = "arizona-haptics" }, 316 - { .name = "arizona-micsupp" }, 317 291 { .name = "arizona-pwm" }, 318 292 { .name = "wm5110-codec" }, 319 293 }; ··· 508 482 arizona->pdata.clk32k_src); 509 483 ret = -EINVAL; 510 484 goto err_reset; 485 + } 486 + 487 + for (i = 0; i < ARIZONA_MAX_MICBIAS; i++) { 488 + if (!arizona->pdata.micbias[i].mV) 489 + continue; 490 + 491 + val = (arizona->pdata.micbias[i].mV - 1500) / 100; 492 + val <<= ARIZONA_MICB1_LVL_SHIFT; 493 + 494 + if (arizona->pdata.micbias[i].ext_cap) 495 + val |= ARIZONA_MICB1_EXT_CAP; 496 + 497 + if (arizona->pdata.micbias[i].discharge) 498 + val |= ARIZONA_MICB1_DISCH; 499 + 500 + if (arizona->pdata.micbias[i].fast_start) 501 + val |= ARIZONA_MICB1_RATE; 502 + 503 + regmap_update_bits(arizona->regmap, 504 + ARIZONA_MIC_BIAS_CTRL_1 + i, 505 + ARIZONA_MICB1_LVL_MASK | 506 + ARIZONA_MICB1_DISCH | 507 + ARIZONA_MICB1_RATE, val); 511 508 } 512 509 513 510 for (i = 0; i < ARIZONA_MAX_INPUT; i++) {
+1 -2
drivers/mfd/da9052-i2c.c
··· 60 60 * This fix is to follow any read or write with a dummy read to a safe 61 61 * register. 62 62 */ 63 - int da9052_i2c_fix(struct da9052 *da9052, unsigned char reg) 63 + static int da9052_i2c_fix(struct da9052 *da9052, unsigned char reg) 64 64 { 65 65 int val; 66 66 ··· 85 85 86 86 return 0; 87 87 } 88 - EXPORT_SYMBOL(da9052_i2c_fix); 89 88 90 89 static int da9052_i2c_enable_multiwrite(struct da9052 *da9052) 91 90 {
+17
drivers/mfd/db8500-prcmu.c
··· 33 33 #include <linux/regulator/db8500-prcmu.h> 34 34 #include <linux/regulator/machine.h> 35 35 #include <linux/cpufreq.h> 36 + #include <linux/platform_data/ux500_wdt.h> 36 37 #include <mach/hardware.h> 37 38 #include <mach/irqs.h> 38 39 #include <mach/db8500-regs.h> ··· 2208 2207 sleep_auto_off ? A9WDOG_AUTO_OFF_EN : 2209 2208 A9WDOG_AUTO_OFF_DIS); 2210 2209 } 2210 + EXPORT_SYMBOL(db8500_prcmu_config_a9wdog); 2211 2211 2212 2212 int db8500_prcmu_enable_a9wdog(u8 id) 2213 2213 { 2214 2214 return prcmu_a9wdog(MB4H_A9WDOG_EN, id, 0, 0, 0); 2215 2215 } 2216 + EXPORT_SYMBOL(db8500_prcmu_enable_a9wdog); 2216 2217 2217 2218 int db8500_prcmu_disable_a9wdog(u8 id) 2218 2219 { 2219 2220 return prcmu_a9wdog(MB4H_A9WDOG_DIS, id, 0, 0, 0); 2220 2221 } 2222 + EXPORT_SYMBOL(db8500_prcmu_disable_a9wdog); 2221 2223 2222 2224 int db8500_prcmu_kick_a9wdog(u8 id) 2223 2225 { 2224 2226 return prcmu_a9wdog(MB4H_A9WDOG_KICK, id, 0, 0, 0); 2225 2227 } 2228 + EXPORT_SYMBOL(db8500_prcmu_kick_a9wdog); 2226 2229 2227 2230 /* 2228 2231 * timeout is 28 bit, in ms. ··· 2244 2239 (u8)((timeout >> 12) & 0xff), 2245 2240 (u8)((timeout >> 20) & 0xff)); 2246 2241 } 2242 + EXPORT_SYMBOL(db8500_prcmu_load_a9wdog); 2247 2243 2248 2244 /** 2249 2245 * prcmu_abb_read() - Read register value(s) from the ABB. ··· 3100 3094 } 3101 3095 }; 3102 3096 3097 + static struct ux500_wdt_data db8500_wdt_pdata = { 3098 + .timeout = 600, /* 10 minutes */ 3099 + .has_28_bits_resolution = true, 3100 + }; 3101 + 3103 3102 static struct mfd_cell db8500_prcmu_devs[] = { 3104 3103 { 3105 3104 .name = "db8500-prcmu-regulators", ··· 3117 3106 .of_compatible = "stericsson,cpufreq-ux500", 3118 3107 .platform_data = &db8500_cpufreq_table, 3119 3108 .pdata_size = sizeof(db8500_cpufreq_table), 3109 + }, 3110 + { 3111 + .name = "ux500_wdt", 3112 + .platform_data = &db8500_wdt_pdata, 3113 + .pdata_size = sizeof(db8500_wdt_pdata), 3114 + .id = -1, 3120 3115 }, 3121 3116 { 3122 3117 .name = "ab8500-core",
+111 -33
drivers/mfd/lpc_ich.c
··· 50 50 * document number TBD : Panther Point 51 51 * document number TBD : Lynx Point 52 52 * document number TBD : Lynx Point-LP 53 + * document number TBD : Wellsburg 53 54 */ 54 55 55 56 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt ··· 76 75 #define ACPIBASE_GCS_OFF 0x3410 77 76 #define ACPIBASE_GCS_END 0x3414 78 77 79 - #define GPIOBASE 0x48 80 - #define GPIOCTRL 0x4C 78 + #define GPIOBASE_ICH0 0x58 79 + #define GPIOCTRL_ICH0 0x5C 80 + #define GPIOBASE_ICH6 0x48 81 + #define GPIOCTRL_ICH6 0x4C 81 82 82 83 #define RCBABASE 0xf0 83 84 ··· 87 84 #define wdt_mem_res(i) wdt_res(ICH_RES_MEM_OFF, i) 88 85 #define wdt_res(b, i) (&wdt_ich_res[(b) + (i)]) 89 86 90 - static int lpc_ich_acpi_save = -1; 91 - static int lpc_ich_gpio_save = -1; 87 + struct lpc_ich_cfg { 88 + int base; 89 + int ctrl; 90 + int save; 91 + }; 92 + 93 + struct lpc_ich_priv { 94 + int chipset; 95 + struct lpc_ich_cfg acpi; 96 + struct lpc_ich_cfg gpio; 97 + }; 92 98 93 99 static struct resource wdt_ich_res[] = { 94 100 /* ACPI - TCO */ ··· 206 194 LPC_PPT, /* Panther Point */ 207 195 LPC_LPT, /* Lynx Point */ 208 196 LPC_LPT_LP, /* Lynx Point-LP */ 197 + LPC_WBG, /* Wellsburg */ 209 198 }; 210 199 211 200 struct lpc_ich_info lpc_chipset_info[] = { ··· 487 474 .name = "Lynx Point_LP", 488 475 .iTCO_version = 2, 489 476 }, 477 + [LPC_WBG] = { 478 + .name = "Wellsburg", 479 + .iTCO_version = 2, 480 + }, 490 481 }; 491 482 492 483 /* ··· 672 655 { PCI_VDEVICE(INTEL, 0x9c45), LPC_LPT_LP}, 673 656 { PCI_VDEVICE(INTEL, 0x9c46), LPC_LPT_LP}, 674 657 { PCI_VDEVICE(INTEL, 0x9c47), LPC_LPT_LP}, 658 + { PCI_VDEVICE(INTEL, 0x8d40), LPC_WBG}, 659 + { PCI_VDEVICE(INTEL, 0x8d41), LPC_WBG}, 660 + { PCI_VDEVICE(INTEL, 0x8d42), LPC_WBG}, 661 + { PCI_VDEVICE(INTEL, 0x8d43), LPC_WBG}, 662 + { PCI_VDEVICE(INTEL, 0x8d44), LPC_WBG}, 663 + { PCI_VDEVICE(INTEL, 0x8d45), LPC_WBG}, 664 + { PCI_VDEVICE(INTEL, 0x8d46), LPC_WBG}, 665 + { PCI_VDEVICE(INTEL, 0x8d47), LPC_WBG}, 666 + { PCI_VDEVICE(INTEL, 0x8d48), LPC_WBG}, 667 + { PCI_VDEVICE(INTEL, 0x8d49), LPC_WBG}, 668 + { PCI_VDEVICE(INTEL, 0x8d4a), LPC_WBG}, 669 + { PCI_VDEVICE(INTEL, 0x8d4b), LPC_WBG}, 670 + { PCI_VDEVICE(INTEL, 0x8d4c), LPC_WBG}, 671 + { PCI_VDEVICE(INTEL, 0x8d4d), LPC_WBG}, 672 + { PCI_VDEVICE(INTEL, 0x8d4e), LPC_WBG}, 673 + { PCI_VDEVICE(INTEL, 0x8d4f), LPC_WBG}, 674 + { PCI_VDEVICE(INTEL, 0x8d50), LPC_WBG}, 675 + { PCI_VDEVICE(INTEL, 0x8d51), LPC_WBG}, 676 + { PCI_VDEVICE(INTEL, 0x8d52), LPC_WBG}, 677 + { PCI_VDEVICE(INTEL, 0x8d53), LPC_WBG}, 678 + { PCI_VDEVICE(INTEL, 0x8d54), LPC_WBG}, 679 + { PCI_VDEVICE(INTEL, 0x8d55), LPC_WBG}, 680 + { PCI_VDEVICE(INTEL, 0x8d56), LPC_WBG}, 681 + { PCI_VDEVICE(INTEL, 0x8d57), LPC_WBG}, 682 + { PCI_VDEVICE(INTEL, 0x8d58), LPC_WBG}, 683 + { PCI_VDEVICE(INTEL, 0x8d59), LPC_WBG}, 684 + { PCI_VDEVICE(INTEL, 0x8d5a), LPC_WBG}, 685 + { PCI_VDEVICE(INTEL, 0x8d5b), LPC_WBG}, 686 + { PCI_VDEVICE(INTEL, 0x8d5c), LPC_WBG}, 687 + { PCI_VDEVICE(INTEL, 0x8d5d), LPC_WBG}, 688 + { PCI_VDEVICE(INTEL, 0x8d5e), LPC_WBG}, 689 + { PCI_VDEVICE(INTEL, 0x8d5f), LPC_WBG}, 675 690 { 0, }, /* End of list */ 676 691 }; 677 692 MODULE_DEVICE_TABLE(pci, lpc_ich_ids); 678 693 679 694 static void lpc_ich_restore_config_space(struct pci_dev *dev) 680 695 { 681 - if (lpc_ich_acpi_save >= 0) { 682 - pci_write_config_byte(dev, ACPICTRL, lpc_ich_acpi_save); 683 - lpc_ich_acpi_save = -1; 696 + struct lpc_ich_priv *priv = pci_get_drvdata(dev); 697 + 698 + if (priv->acpi.save >= 0) { 699 + pci_write_config_byte(dev, priv->acpi.ctrl, priv->acpi.save); 700 + priv->acpi.save = -1; 684 701 } 685 702 686 - if (lpc_ich_gpio_save >= 0) { 687 - pci_write_config_byte(dev, GPIOCTRL, lpc_ich_gpio_save); 688 - lpc_ich_gpio_save = -1; 703 + if (priv->gpio.save >= 0) { 704 + pci_write_config_byte(dev, priv->gpio.ctrl, priv->gpio.save); 705 + priv->gpio.save = -1; 689 706 } 690 707 } 691 708 692 709 static void lpc_ich_enable_acpi_space(struct pci_dev *dev) 693 710 { 711 + struct lpc_ich_priv *priv = pci_get_drvdata(dev); 694 712 u8 reg_save; 695 713 696 - pci_read_config_byte(dev, ACPICTRL, &reg_save); 697 - pci_write_config_byte(dev, ACPICTRL, reg_save | 0x10); 698 - lpc_ich_acpi_save = reg_save; 714 + pci_read_config_byte(dev, priv->acpi.ctrl, &reg_save); 715 + pci_write_config_byte(dev, priv->acpi.ctrl, reg_save | 0x10); 716 + priv->acpi.save = reg_save; 699 717 } 700 718 701 719 static void lpc_ich_enable_gpio_space(struct pci_dev *dev) 702 720 { 721 + struct lpc_ich_priv *priv = pci_get_drvdata(dev); 703 722 u8 reg_save; 704 723 705 - pci_read_config_byte(dev, GPIOCTRL, &reg_save); 706 - pci_write_config_byte(dev, GPIOCTRL, reg_save | 0x10); 707 - lpc_ich_gpio_save = reg_save; 724 + pci_read_config_byte(dev, priv->gpio.ctrl, &reg_save); 725 + pci_write_config_byte(dev, priv->gpio.ctrl, reg_save | 0x10); 726 + priv->gpio.save = reg_save; 708 727 } 709 728 710 - static void lpc_ich_finalize_cell(struct mfd_cell *cell, 711 - const struct pci_device_id *id) 729 + static void lpc_ich_finalize_cell(struct pci_dev *dev, struct mfd_cell *cell) 712 730 { 713 - cell->platform_data = &lpc_chipset_info[id->driver_data]; 731 + struct lpc_ich_priv *priv = pci_get_drvdata(dev); 732 + 733 + cell->platform_data = &lpc_chipset_info[priv->chipset]; 714 734 cell->pdata_size = sizeof(struct lpc_ich_info); 715 735 } 716 736 ··· 775 721 return use_gpio ? use_gpio : ret; 776 722 } 777 723 778 - static int lpc_ich_init_gpio(struct pci_dev *dev, 779 - const struct pci_device_id *id) 724 + static int lpc_ich_init_gpio(struct pci_dev *dev) 780 725 { 726 + struct lpc_ich_priv *priv = pci_get_drvdata(dev); 781 727 u32 base_addr_cfg; 782 728 u32 base_addr; 783 729 int ret; ··· 785 731 struct resource *res; 786 732 787 733 /* Setup power management base register */ 788 - pci_read_config_dword(dev, ACPIBASE, &base_addr_cfg); 734 + pci_read_config_dword(dev, priv->acpi.base, &base_addr_cfg); 789 735 base_addr = base_addr_cfg & 0x0000ff80; 790 736 if (!base_addr) { 791 737 dev_notice(&dev->dev, "I/O space for ACPI uninitialized\n"); ··· 811 757 812 758 gpe0_done: 813 759 /* Setup GPIO base register */ 814 - pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); 760 + pci_read_config_dword(dev, priv->gpio.base, &base_addr_cfg); 815 761 base_addr = base_addr_cfg & 0x0000ff80; 816 762 if (!base_addr) { 817 763 dev_notice(&dev->dev, "I/O space for GPIO uninitialized\n"); ··· 822 768 /* Older devices provide fewer GPIO and have a smaller resource size. */ 823 769 res = &gpio_ich_res[ICH_RES_GPIO]; 824 770 res->start = base_addr; 825 - switch (lpc_chipset_info[id->driver_data].gpio_version) { 771 + switch (lpc_chipset_info[priv->chipset].gpio_version) { 826 772 case ICH_V5_GPIO: 827 773 case ICH_V10CORP_GPIO: 828 774 res->end = res->start + 128 - 1; ··· 838 784 acpi_conflict = true; 839 785 goto gpio_done; 840 786 } 841 - lpc_chipset_info[id->driver_data].use_gpio = ret; 787 + lpc_chipset_info[priv->chipset].use_gpio = ret; 842 788 lpc_ich_enable_gpio_space(dev); 843 789 844 - lpc_ich_finalize_cell(&lpc_ich_cells[LPC_GPIO], id); 790 + lpc_ich_finalize_cell(dev, &lpc_ich_cells[LPC_GPIO]); 845 791 ret = mfd_add_devices(&dev->dev, -1, &lpc_ich_cells[LPC_GPIO], 846 792 1, NULL, 0, NULL); 847 793 ··· 852 798 return ret; 853 799 } 854 800 855 - static int lpc_ich_init_wdt(struct pci_dev *dev, 856 - const struct pci_device_id *id) 801 + static int lpc_ich_init_wdt(struct pci_dev *dev) 857 802 { 803 + struct lpc_ich_priv *priv = pci_get_drvdata(dev); 858 804 u32 base_addr_cfg; 859 805 u32 base_addr; 860 806 int ret; 861 807 struct resource *res; 862 808 863 809 /* Setup power management base register */ 864 - pci_read_config_dword(dev, ACPIBASE, &base_addr_cfg); 810 + pci_read_config_dword(dev, priv->acpi.base, &base_addr_cfg); 865 811 base_addr = base_addr_cfg & 0x0000ff80; 866 812 if (!base_addr) { 867 813 dev_notice(&dev->dev, "I/O space for ACPI uninitialized\n"); ··· 884 830 * we have to read RCBA from PCI Config space 0xf0 and use 885 831 * it as base. GCS = RCBA + ICH6_GCS(0x3410). 886 832 */ 887 - if (lpc_chipset_info[id->driver_data].iTCO_version == 1) { 833 + if (lpc_chipset_info[priv->chipset].iTCO_version == 1) { 888 834 /* Don't register iomem for TCO ver 1 */ 889 835 lpc_ich_cells[LPC_WDT].num_resources--; 890 836 } else { ··· 901 847 res->end = base_addr + ACPIBASE_GCS_END; 902 848 } 903 849 904 - lpc_ich_finalize_cell(&lpc_ich_cells[LPC_WDT], id); 850 + lpc_ich_finalize_cell(dev, &lpc_ich_cells[LPC_WDT]); 905 851 ret = mfd_add_devices(&dev->dev, -1, &lpc_ich_cells[LPC_WDT], 906 852 1, NULL, 0, NULL); 907 853 ··· 912 858 static int lpc_ich_probe(struct pci_dev *dev, 913 859 const struct pci_device_id *id) 914 860 { 861 + struct lpc_ich_priv *priv; 915 862 int ret; 916 863 bool cell_added = false; 917 864 918 - ret = lpc_ich_init_wdt(dev, id); 865 + priv = devm_kzalloc(&dev->dev, 866 + sizeof(struct lpc_ich_priv), GFP_KERNEL); 867 + if (!priv) 868 + return -ENOMEM; 869 + 870 + priv->chipset = id->driver_data; 871 + priv->acpi.save = -1; 872 + priv->acpi.base = ACPIBASE; 873 + priv->acpi.ctrl = ACPICTRL; 874 + 875 + priv->gpio.save = -1; 876 + if (priv->chipset <= LPC_ICH5) { 877 + priv->gpio.base = GPIOBASE_ICH0; 878 + priv->gpio.ctrl = GPIOCTRL_ICH0; 879 + } else { 880 + priv->gpio.base = GPIOBASE_ICH6; 881 + priv->gpio.ctrl = GPIOCTRL_ICH6; 882 + } 883 + 884 + pci_set_drvdata(dev, priv); 885 + 886 + ret = lpc_ich_init_wdt(dev); 919 887 if (!ret) 920 888 cell_added = true; 921 889 922 - ret = lpc_ich_init_gpio(dev, id); 890 + ret = lpc_ich_init_gpio(dev); 923 891 if (!ret) 924 892 cell_added = true; 925 893 ··· 952 876 if (!cell_added) { 953 877 dev_warn(&dev->dev, "No MFD cells added\n"); 954 878 lpc_ich_restore_config_space(dev); 879 + pci_set_drvdata(dev, NULL); 955 880 return -ENODEV; 956 881 } 957 882 ··· 963 886 { 964 887 mfd_remove_devices(&dev->dev); 965 888 lpc_ich_restore_config_space(dev); 889 + pci_set_drvdata(dev, NULL); 966 890 } 967 891 968 892 static struct pci_driver lpc_ich_driver = {
+74 -79
drivers/mfd/lpc_sch.c
··· 45 45 .flags = IORESOURCE_IO, 46 46 }; 47 47 48 - 49 48 static struct resource gpio_sch_resource = { 50 49 .flags = IORESOURCE_IO, 51 - }; 52 - 53 - static struct mfd_cell lpc_sch_cells[] = { 54 - { 55 - .name = "isch_smbus", 56 - .num_resources = 1, 57 - .resources = &smbus_sch_resource, 58 - }, 59 - { 60 - .name = "sch_gpio", 61 - .num_resources = 1, 62 - .resources = &gpio_sch_resource, 63 - }, 64 50 }; 65 51 66 52 static struct resource wdt_sch_resource = { 67 53 .flags = IORESOURCE_IO, 68 54 }; 69 55 70 - static struct mfd_cell tunnelcreek_cells[] = { 71 - { 72 - .name = "ie6xx_wdt", 73 - .num_resources = 1, 74 - .resources = &wdt_sch_resource, 75 - }, 56 + static struct mfd_cell lpc_sch_cells[3]; 57 + 58 + static struct mfd_cell isch_smbus_cell = { 59 + .name = "isch_smbus", 60 + .num_resources = 1, 61 + .resources = &smbus_sch_resource, 62 + }; 63 + 64 + static struct mfd_cell sch_gpio_cell = { 65 + .name = "sch_gpio", 66 + .num_resources = 1, 67 + .resources = &gpio_sch_resource, 68 + }; 69 + 70 + static struct mfd_cell wdt_sch_cell = { 71 + .name = "ie6xx_wdt", 72 + .num_resources = 1, 73 + .resources = &wdt_sch_resource, 76 74 }; 77 75 78 76 static DEFINE_PCI_DEVICE_TABLE(lpc_sch_ids) = { ··· 86 88 { 87 89 unsigned int base_addr_cfg; 88 90 unsigned short base_addr; 89 - int i; 91 + int i, cells = 0; 90 92 int ret; 91 93 92 94 pci_read_config_dword(dev, SMBASE, &base_addr_cfg); 93 - if (!(base_addr_cfg & (1 << 31))) { 94 - dev_err(&dev->dev, "Decode of the SMBus I/O range disabled\n"); 95 - return -ENODEV; 96 - } 97 - base_addr = (unsigned short)base_addr_cfg; 98 - if (base_addr == 0) { 99 - dev_err(&dev->dev, "I/O space for SMBus uninitialized\n"); 100 - return -ENODEV; 101 - } 95 + base_addr = 0; 96 + if (!(base_addr_cfg & (1 << 31))) 97 + dev_warn(&dev->dev, "Decode of the SMBus I/O range disabled\n"); 98 + else 99 + base_addr = (unsigned short)base_addr_cfg; 102 100 103 - smbus_sch_resource.start = base_addr; 104 - smbus_sch_resource.end = base_addr + SMBUS_IO_SIZE - 1; 101 + if (base_addr == 0) { 102 + dev_warn(&dev->dev, "I/O space for SMBus uninitialized\n"); 103 + } else { 104 + lpc_sch_cells[cells++] = isch_smbus_cell; 105 + smbus_sch_resource.start = base_addr; 106 + smbus_sch_resource.end = base_addr + SMBUS_IO_SIZE - 1; 107 + } 105 108 106 109 pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); 107 - if (!(base_addr_cfg & (1 << 31))) { 108 - dev_err(&dev->dev, "Decode of the GPIO I/O range disabled\n"); 109 - return -ENODEV; 110 - } 111 - base_addr = (unsigned short)base_addr_cfg; 112 - if (base_addr == 0) { 113 - dev_err(&dev->dev, "I/O space for GPIO uninitialized\n"); 114 - return -ENODEV; 115 - } 116 - 117 - gpio_sch_resource.start = base_addr; 118 - 119 - if (id->device == PCI_DEVICE_ID_INTEL_CENTERTON_ILB) 120 - gpio_sch_resource.end = base_addr + GPIO_IO_SIZE_CENTERTON - 1; 110 + base_addr = 0; 111 + if (!(base_addr_cfg & (1 << 31))) 112 + dev_warn(&dev->dev, "Decode of the GPIO I/O range disabled\n"); 121 113 else 122 - gpio_sch_resource.end = base_addr + GPIO_IO_SIZE - 1; 114 + base_addr = (unsigned short)base_addr_cfg; 123 115 124 - for (i=0; i < ARRAY_SIZE(lpc_sch_cells); i++) 125 - lpc_sch_cells[i].id = id->device; 126 - 127 - ret = mfd_add_devices(&dev->dev, 0, 128 - lpc_sch_cells, ARRAY_SIZE(lpc_sch_cells), NULL, 129 - 0, NULL); 130 - if (ret) 131 - goto out_dev; 116 + if (base_addr == 0) { 117 + dev_warn(&dev->dev, "I/O space for GPIO uninitialized\n"); 118 + } else { 119 + lpc_sch_cells[cells++] = sch_gpio_cell; 120 + gpio_sch_resource.start = base_addr; 121 + if (id->device == PCI_DEVICE_ID_INTEL_CENTERTON_ILB) 122 + gpio_sch_resource.end = base_addr + GPIO_IO_SIZE_CENTERTON - 1; 123 + else 124 + gpio_sch_resource.end = base_addr + GPIO_IO_SIZE - 1; 125 + } 132 126 133 127 if (id->device == PCI_DEVICE_ID_INTEL_ITC_LPC 134 - || id->device == PCI_DEVICE_ID_INTEL_CENTERTON_ILB) { 128 + || id->device == PCI_DEVICE_ID_INTEL_CENTERTON_ILB) { 135 129 pci_read_config_dword(dev, WDTBASE, &base_addr_cfg); 136 - if (!(base_addr_cfg & (1 << 31))) { 137 - dev_err(&dev->dev, "Decode of the WDT I/O range disabled\n"); 138 - ret = -ENODEV; 139 - goto out_dev; 130 + base_addr = 0; 131 + if (!(base_addr_cfg & (1 << 31))) 132 + dev_warn(&dev->dev, "Decode of the WDT I/O range disabled\n"); 133 + else 134 + base_addr = (unsigned short)base_addr_cfg; 135 + if (base_addr == 0) 136 + dev_warn(&dev->dev, "I/O space for WDT uninitialized\n"); 137 + else { 138 + lpc_sch_cells[cells++] = wdt_sch_cell; 139 + wdt_sch_resource.start = base_addr; 140 + wdt_sch_resource.end = base_addr + WDT_IO_SIZE - 1; 140 141 } 141 - base_addr = (unsigned short)base_addr_cfg; 142 - if (base_addr == 0) { 143 - dev_err(&dev->dev, "I/O space for WDT uninitialized\n"); 144 - ret = -ENODEV; 145 - goto out_dev; 146 - } 147 - 148 - wdt_sch_resource.start = base_addr; 149 - wdt_sch_resource.end = base_addr + WDT_IO_SIZE - 1; 150 - 151 - for (i = 0; i < ARRAY_SIZE(tunnelcreek_cells); i++) 152 - tunnelcreek_cells[i].id = id->device; 153 - 154 - ret = mfd_add_devices(&dev->dev, 0, tunnelcreek_cells, 155 - ARRAY_SIZE(tunnelcreek_cells), NULL, 156 - 0, NULL); 157 142 } 158 143 159 - return ret; 160 - out_dev: 161 - mfd_remove_devices(&dev->dev); 144 + if (WARN_ON(cells > ARRAY_SIZE(lpc_sch_cells))) { 145 + dev_err(&dev->dev, "Cell count exceeds array size"); 146 + return -ENODEV; 147 + } 148 + 149 + if (cells == 0) { 150 + dev_err(&dev->dev, "All decode registers disabled.\n"); 151 + return -ENODEV; 152 + } 153 + 154 + for (i = 0; i < cells; i++) 155 + lpc_sch_cells[i].id = id->device; 156 + 157 + ret = mfd_add_devices(&dev->dev, 0, lpc_sch_cells, cells, NULL, 0, NULL); 158 + if (ret) 159 + mfd_remove_devices(&dev->dev); 160 + 162 161 return ret; 163 162 } 164 163
+51 -40
drivers/mfd/max8925-core.c
··· 14 14 #include <linux/i2c.h> 15 15 #include <linux/irq.h> 16 16 #include <linux/interrupt.h> 17 + #include <linux/irqdomain.h> 17 18 #include <linux/platform_device.h> 18 19 #include <linux/regulator/machine.h> 19 20 #include <linux/mfd/core.h> 20 21 #include <linux/mfd/max8925.h> 22 + #include <linux/of.h> 23 + #include <linux/of_platform.h> 21 24 22 25 static struct resource bk_resources[] = { 23 26 { 0x84, 0x84, "mode control", IORESOURCE_REG, }, ··· 642 639 .irq_disable = max8925_irq_disable, 643 640 }; 644 641 642 + static int max8925_irq_domain_map(struct irq_domain *d, unsigned int virq, 643 + irq_hw_number_t hw) 644 + { 645 + irq_set_chip_data(virq, d->host_data); 646 + irq_set_chip_and_handler(virq, &max8925_irq_chip, handle_edge_irq); 647 + irq_set_nested_thread(virq, 1); 648 + #ifdef CONFIG_ARM 649 + set_irq_flags(virq, IRQF_VALID); 650 + #else 651 + irq_set_noprobe(virq); 652 + #endif 653 + return 0; 654 + } 655 + 656 + static struct irq_domain_ops max8925_irq_domain_ops = { 657 + .map = max8925_irq_domain_map, 658 + .xlate = irq_domain_xlate_onetwocell, 659 + }; 660 + 661 + 645 662 static int max8925_irq_init(struct max8925_chip *chip, int irq, 646 663 struct max8925_platform_data *pdata) 647 664 { 648 665 unsigned long flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT; 649 - int i, ret; 650 - int __irq; 666 + int ret; 667 + struct device_node *node = chip->dev->of_node; 651 668 652 - if (!pdata || !pdata->irq_base) { 653 - dev_warn(chip->dev, "No interrupt support on IRQ base\n"); 654 - return -EINVAL; 655 - } 656 669 /* clear all interrupts */ 657 670 max8925_reg_read(chip->i2c, MAX8925_CHG_IRQ1); 658 671 max8925_reg_read(chip->i2c, MAX8925_CHG_IRQ2); ··· 686 667 max8925_reg_write(chip->rtc, MAX8925_RTC_IRQ_MASK, 0xff); 687 668 688 669 mutex_init(&chip->irq_lock); 670 + chip->irq_base = irq_alloc_descs(-1, 0, MAX8925_NR_IRQS, 0); 671 + if (chip->irq_base < 0) { 672 + dev_err(chip->dev, "Failed to allocate interrupts, ret:%d\n", 673 + chip->irq_base); 674 + return -EBUSY; 675 + } 676 + 677 + irq_domain_add_legacy(node, MAX8925_NR_IRQS, chip->irq_base, 0, 678 + &max8925_irq_domain_ops, chip); 679 + 680 + /* request irq handler for pmic main irq*/ 689 681 chip->core_irq = irq; 690 - chip->irq_base = pdata->irq_base; 691 - 692 - /* register with genirq */ 693 - for (i = 0; i < ARRAY_SIZE(max8925_irqs); i++) { 694 - __irq = i + chip->irq_base; 695 - irq_set_chip_data(__irq, chip); 696 - irq_set_chip_and_handler(__irq, &max8925_irq_chip, 697 - handle_edge_irq); 698 - irq_set_nested_thread(__irq, 1); 699 - #ifdef CONFIG_ARM 700 - set_irq_flags(__irq, IRQF_VALID); 701 - #else 702 - irq_set_noprobe(__irq); 703 - #endif 704 - } 705 - if (!irq) { 706 - dev_warn(chip->dev, "No interrupt support on core IRQ\n"); 707 - goto tsc_irq; 708 - } 709 - 682 + if (!chip->core_irq) 683 + return -EBUSY; 710 684 ret = request_threaded_irq(irq, NULL, max8925_irq, flags | IRQF_ONESHOT, 711 685 "max8925", chip); 712 686 if (ret) { 713 687 dev_err(chip->dev, "Failed to request core IRQ: %d\n", ret); 714 688 chip->core_irq = 0; 689 + return -EBUSY; 715 690 } 716 691 717 - tsc_irq: 692 + /* request irq handler for pmic tsc irq*/ 693 + 718 694 /* mask TSC interrupt */ 719 695 max8925_reg_write(chip->adc, MAX8925_TSC_IRQ_MASK, 0x0f); 720 696 ··· 718 704 return 0; 719 705 } 720 706 chip->tsc_irq = pdata->tsc_irq; 721 - 722 707 ret = request_threaded_irq(chip->tsc_irq, NULL, max8925_tsc_irq, 723 708 flags | IRQF_ONESHOT, "max8925-tsc", chip); 724 709 if (ret) { ··· 859 846 860 847 ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0], 861 848 ARRAY_SIZE(rtc_devs), 862 - &rtc_resources[0], chip->irq_base, NULL); 849 + NULL, chip->irq_base, NULL); 863 850 if (ret < 0) { 864 851 dev_err(chip->dev, "Failed to add rtc subdev\n"); 865 852 goto out; ··· 867 854 868 855 ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0], 869 856 ARRAY_SIZE(onkey_devs), 870 - &onkey_resources[0], 0, NULL); 857 + NULL, chip->irq_base, NULL); 871 858 if (ret < 0) { 872 859 dev_err(chip->dev, "Failed to add onkey subdev\n"); 873 860 goto out_dev; ··· 886 873 goto out_dev; 887 874 } 888 875 889 - if (pdata && pdata->power) { 890 - ret = mfd_add_devices(chip->dev, 0, &power_devs[0], 891 - ARRAY_SIZE(power_devs), 892 - &power_supply_resources[0], 0, NULL); 893 - if (ret < 0) { 894 - dev_err(chip->dev, "Failed to add power supply " 895 - "subdev\n"); 896 - goto out_dev; 897 - } 876 + ret = mfd_add_devices(chip->dev, 0, &power_devs[0], 877 + ARRAY_SIZE(power_devs), 878 + NULL, 0, NULL); 879 + if (ret < 0) { 880 + dev_err(chip->dev, 881 + "Failed to add power supply subdev, err = %d\n", ret); 882 + goto out_dev; 898 883 } 899 884 900 885 if (pdata && pdata->touch) { 901 886 ret = mfd_add_devices(chip->dev, 0, &touch_devs[0], 902 887 ARRAY_SIZE(touch_devs), 903 - &touch_resources[0], 0, NULL); 888 + NULL, chip->tsc_irq, NULL); 904 889 if (ret < 0) { 905 890 dev_err(chip->dev, "Failed to add touch subdev\n"); 906 891 goto out_dev;
+32 -2
drivers/mfd/max8925-i2c.c
··· 135 135 }; 136 136 MODULE_DEVICE_TABLE(i2c, max8925_id_table); 137 137 138 + static int max8925_dt_init(struct device_node *np, struct device *dev, 139 + struct max8925_platform_data *pdata) 140 + { 141 + int ret; 142 + 143 + ret = of_property_read_u32(np, "maxim,tsc-irq", &pdata->tsc_irq); 144 + if (ret) { 145 + dev_err(dev, "Not found maxim,tsc-irq property\n"); 146 + return -EINVAL; 147 + } 148 + return 0; 149 + } 150 + 138 151 static int max8925_probe(struct i2c_client *client, 139 152 const struct i2c_device_id *id) 140 153 { 141 154 struct max8925_platform_data *pdata = client->dev.platform_data; 142 155 static struct max8925_chip *chip; 156 + struct device_node *node = client->dev.of_node; 143 157 144 - if (!pdata) { 158 + if (node && !pdata) { 159 + /* parse DT to get platform data */ 160 + pdata = devm_kzalloc(&client->dev, 161 + sizeof(struct max8925_platform_data), 162 + GFP_KERNEL); 163 + if (!pdata) 164 + return -ENOMEM; 165 + 166 + if (max8925_dt_init(node, &client->dev, pdata)) 167 + return -EINVAL; 168 + } else if (!pdata) { 145 169 pr_info("%s: platform data is missing\n", __func__); 146 170 return -EINVAL; 147 171 } ··· 227 203 228 204 static SIMPLE_DEV_PM_OPS(max8925_pm_ops, max8925_suspend, max8925_resume); 229 205 206 + static const struct of_device_id max8925_dt_ids[] = { 207 + { .compatible = "maxim,max8925", }, 208 + {}, 209 + }; 210 + MODULE_DEVICE_TABLE(of, max8925_dt_ids); 211 + 230 212 static struct i2c_driver max8925_driver = { 231 213 .driver = { 232 214 .name = "max8925", 233 215 .owner = THIS_MODULE, 234 216 .pm = &max8925_pm_ops, 217 + .of_match_table = of_match_ptr(max8925_dt_ids), 235 218 }, 236 219 .probe = max8925_probe, 237 220 .remove = max8925_remove, ··· 248 217 static int __init max8925_i2c_init(void) 249 218 { 250 219 int ret; 251 - 252 220 ret = i2c_add_driver(&max8925_driver); 253 221 if (ret != 0) 254 222 pr_err("Failed to register MAX8925 I2C driver: %d\n", ret);
+332 -226
drivers/mfd/omap-usb-host.c
··· 23 23 #include <linux/delay.h> 24 24 #include <linux/clk.h> 25 25 #include <linux/dma-mapping.h> 26 - #include <linux/spinlock.h> 27 26 #include <linux/gpio.h> 28 27 #include <linux/platform_device.h> 29 28 #include <linux/platform_data/usb-omap.h> ··· 90 91 91 92 92 93 struct usbhs_hcd_omap { 94 + int nports; 95 + struct clk **utmi_clk; 96 + struct clk **hsic60m_clk; 97 + struct clk **hsic480m_clk; 98 + 93 99 struct clk *xclk60mhsp1_ck; 94 100 struct clk *xclk60mhsp2_ck; 95 - struct clk *utmi_p1_fck; 96 - struct clk *usbhost_p1_fck; 97 - struct clk *utmi_p2_fck; 98 - struct clk *usbhost_p2_fck; 101 + struct clk *utmi_p1_gfclk; 102 + struct clk *utmi_p2_gfclk; 99 103 struct clk *init_60m_fclk; 100 104 struct clk *ehci_logic_fck; 101 105 102 106 void __iomem *uhh_base; 103 107 104 - struct usbhs_omap_platform_data platdata; 108 + struct usbhs_omap_platform_data *pdata; 105 109 106 110 u32 usbhs_rev; 107 - spinlock_t lock; 108 111 }; 109 112 /*-------------------------------------------------------------------------*/ 110 113 ··· 185 184 static int omap_usbhs_alloc_children(struct platform_device *pdev) 186 185 { 187 186 struct device *dev = &pdev->dev; 188 - struct usbhs_hcd_omap *omap; 189 - struct ehci_hcd_omap_platform_data *ehci_data; 190 - struct ohci_hcd_omap_platform_data *ohci_data; 187 + struct usbhs_omap_platform_data *pdata = dev->platform_data; 191 188 struct platform_device *ehci; 192 189 struct platform_device *ohci; 193 190 struct resource *res; 194 191 struct resource resources[2]; 195 192 int ret; 196 - 197 - omap = platform_get_drvdata(pdev); 198 - ehci_data = omap->platdata.ehci_data; 199 - ohci_data = omap->platdata.ohci_data; 200 193 201 194 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ehci"); 202 195 if (!res) { ··· 208 213 } 209 214 resources[1] = *res; 210 215 211 - ehci = omap_usbhs_alloc_child(OMAP_EHCI_DEVICE, resources, 2, ehci_data, 212 - sizeof(*ehci_data), dev); 216 + ehci = omap_usbhs_alloc_child(OMAP_EHCI_DEVICE, resources, 2, pdata, 217 + sizeof(*pdata), dev); 213 218 214 219 if (!ehci) { 215 220 dev_err(dev, "omap_usbhs_alloc_child failed\n"); ··· 233 238 } 234 239 resources[1] = *res; 235 240 236 - ohci = omap_usbhs_alloc_child(OMAP_OHCI_DEVICE, resources, 2, ohci_data, 237 - sizeof(*ohci_data), dev); 241 + ohci = omap_usbhs_alloc_child(OMAP_OHCI_DEVICE, resources, 2, pdata, 242 + sizeof(*pdata), dev); 238 243 if (!ohci) { 239 244 dev_err(dev, "omap_usbhs_alloc_child failed\n"); 240 245 ret = -ENOMEM; ··· 273 278 static int usbhs_runtime_resume(struct device *dev) 274 279 { 275 280 struct usbhs_hcd_omap *omap = dev_get_drvdata(dev); 276 - struct usbhs_omap_platform_data *pdata = &omap->platdata; 277 - unsigned long flags; 281 + struct usbhs_omap_platform_data *pdata = omap->pdata; 282 + int i, r; 278 283 279 284 dev_dbg(dev, "usbhs_runtime_resume\n"); 280 285 281 - if (!pdata) { 282 - dev_dbg(dev, "missing platform_data\n"); 283 - return -ENODEV; 284 - } 285 - 286 286 omap_tll_enable(); 287 - spin_lock_irqsave(&omap->lock, flags); 288 287 289 - if (omap->ehci_logic_fck && !IS_ERR(omap->ehci_logic_fck)) 288 + if (!IS_ERR(omap->ehci_logic_fck)) 290 289 clk_enable(omap->ehci_logic_fck); 291 290 292 - if (is_ehci_tll_mode(pdata->port_mode[0])) 293 - clk_enable(omap->usbhost_p1_fck); 294 - if (is_ehci_tll_mode(pdata->port_mode[1])) 295 - clk_enable(omap->usbhost_p2_fck); 291 + for (i = 0; i < omap->nports; i++) { 292 + switch (pdata->port_mode[i]) { 293 + case OMAP_EHCI_PORT_MODE_HSIC: 294 + if (!IS_ERR(omap->hsic60m_clk[i])) { 295 + r = clk_enable(omap->hsic60m_clk[i]); 296 + if (r) { 297 + dev_err(dev, 298 + "Can't enable port %d hsic60m clk:%d\n", 299 + i, r); 300 + } 301 + } 296 302 297 - clk_enable(omap->utmi_p1_fck); 298 - clk_enable(omap->utmi_p2_fck); 303 + if (!IS_ERR(omap->hsic480m_clk[i])) { 304 + r = clk_enable(omap->hsic480m_clk[i]); 305 + if (r) { 306 + dev_err(dev, 307 + "Can't enable port %d hsic480m clk:%d\n", 308 + i, r); 309 + } 310 + } 311 + /* Fall through as HSIC mode needs utmi_clk */ 299 312 300 - spin_unlock_irqrestore(&omap->lock, flags); 313 + case OMAP_EHCI_PORT_MODE_TLL: 314 + if (!IS_ERR(omap->utmi_clk[i])) { 315 + r = clk_enable(omap->utmi_clk[i]); 316 + if (r) { 317 + dev_err(dev, 318 + "Can't enable port %d clk : %d\n", 319 + i, r); 320 + } 321 + } 322 + break; 323 + default: 324 + break; 325 + } 326 + } 301 327 302 328 return 0; 303 329 } ··· 326 310 static int usbhs_runtime_suspend(struct device *dev) 327 311 { 328 312 struct usbhs_hcd_omap *omap = dev_get_drvdata(dev); 329 - struct usbhs_omap_platform_data *pdata = &omap->platdata; 330 - unsigned long flags; 313 + struct usbhs_omap_platform_data *pdata = omap->pdata; 314 + int i; 331 315 332 316 dev_dbg(dev, "usbhs_runtime_suspend\n"); 333 317 334 - if (!pdata) { 335 - dev_dbg(dev, "missing platform_data\n"); 336 - return -ENODEV; 318 + for (i = 0; i < omap->nports; i++) { 319 + switch (pdata->port_mode[i]) { 320 + case OMAP_EHCI_PORT_MODE_HSIC: 321 + if (!IS_ERR(omap->hsic60m_clk[i])) 322 + clk_disable(omap->hsic60m_clk[i]); 323 + 324 + if (!IS_ERR(omap->hsic480m_clk[i])) 325 + clk_disable(omap->hsic480m_clk[i]); 326 + /* Fall through as utmi_clks were used in HSIC mode */ 327 + 328 + case OMAP_EHCI_PORT_MODE_TLL: 329 + if (!IS_ERR(omap->utmi_clk[i])) 330 + clk_disable(omap->utmi_clk[i]); 331 + break; 332 + default: 333 + break; 334 + } 337 335 } 338 336 339 - spin_lock_irqsave(&omap->lock, flags); 340 - 341 - if (is_ehci_tll_mode(pdata->port_mode[0])) 342 - clk_disable(omap->usbhost_p1_fck); 343 - if (is_ehci_tll_mode(pdata->port_mode[1])) 344 - clk_disable(omap->usbhost_p2_fck); 345 - 346 - clk_disable(omap->utmi_p2_fck); 347 - clk_disable(omap->utmi_p1_fck); 348 - 349 - if (omap->ehci_logic_fck && !IS_ERR(omap->ehci_logic_fck)) 337 + if (!IS_ERR(omap->ehci_logic_fck)) 350 338 clk_disable(omap->ehci_logic_fck); 351 339 352 - spin_unlock_irqrestore(&omap->lock, flags); 353 340 omap_tll_disable(); 354 341 355 342 return 0; 356 343 } 357 344 345 + static unsigned omap_usbhs_rev1_hostconfig(struct usbhs_hcd_omap *omap, 346 + unsigned reg) 347 + { 348 + struct usbhs_omap_platform_data *pdata = omap->pdata; 349 + int i; 350 + 351 + for (i = 0; i < omap->nports; i++) { 352 + switch (pdata->port_mode[i]) { 353 + case OMAP_USBHS_PORT_MODE_UNUSED: 354 + reg &= ~(OMAP_UHH_HOSTCONFIG_P1_CONNECT_STATUS << i); 355 + break; 356 + case OMAP_EHCI_PORT_MODE_PHY: 357 + if (pdata->single_ulpi_bypass) 358 + break; 359 + 360 + if (i == 0) 361 + reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS; 362 + else 363 + reg &= ~(OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS 364 + << (i-1)); 365 + break; 366 + default: 367 + if (pdata->single_ulpi_bypass) 368 + break; 369 + 370 + if (i == 0) 371 + reg |= OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS; 372 + else 373 + reg |= OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS 374 + << (i-1); 375 + break; 376 + } 377 + } 378 + 379 + if (pdata->single_ulpi_bypass) { 380 + /* bypass ULPI only if none of the ports use PHY mode */ 381 + reg |= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS; 382 + 383 + for (i = 0; i < omap->nports; i++) { 384 + if (is_ehci_phy_mode(pdata->port_mode[i])) { 385 + reg &= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS; 386 + break; 387 + } 388 + } 389 + } 390 + 391 + return reg; 392 + } 393 + 394 + static unsigned omap_usbhs_rev2_hostconfig(struct usbhs_hcd_omap *omap, 395 + unsigned reg) 396 + { 397 + struct usbhs_omap_platform_data *pdata = omap->pdata; 398 + int i; 399 + 400 + for (i = 0; i < omap->nports; i++) { 401 + /* Clear port mode fields for PHY mode */ 402 + reg &= ~(OMAP4_P1_MODE_CLEAR << 2 * i); 403 + 404 + if (is_ehci_tll_mode(pdata->port_mode[i]) || 405 + (is_ohci_port(pdata->port_mode[i]))) 406 + reg |= OMAP4_P1_MODE_TLL << 2 * i; 407 + else if (is_ehci_hsic_mode(pdata->port_mode[i])) 408 + reg |= OMAP4_P1_MODE_HSIC << 2 * i; 409 + } 410 + 411 + return reg; 412 + } 413 + 358 414 static void omap_usbhs_init(struct device *dev) 359 415 { 360 416 struct usbhs_hcd_omap *omap = dev_get_drvdata(dev); 361 - struct usbhs_omap_platform_data *pdata = &omap->platdata; 362 - unsigned long flags; 417 + struct usbhs_omap_platform_data *pdata = omap->pdata; 363 418 unsigned reg; 364 419 365 420 dev_dbg(dev, "starting TI HSUSB Controller\n"); 366 421 367 - if (pdata->ehci_data->phy_reset) { 368 - if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) 369 - gpio_request_one(pdata->ehci_data->reset_gpio_port[0], 422 + if (pdata->phy_reset) { 423 + if (gpio_is_valid(pdata->reset_gpio_port[0])) 424 + gpio_request_one(pdata->reset_gpio_port[0], 370 425 GPIOF_OUT_INIT_LOW, "USB1 PHY reset"); 371 426 372 - if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) 373 - gpio_request_one(pdata->ehci_data->reset_gpio_port[1], 427 + if (gpio_is_valid(pdata->reset_gpio_port[1])) 428 + gpio_request_one(pdata->reset_gpio_port[1], 374 429 GPIOF_OUT_INIT_LOW, "USB2 PHY reset"); 375 430 376 431 /* Hold the PHY in RESET for enough time till DIR is high */ ··· 449 362 } 450 363 451 364 pm_runtime_get_sync(dev); 452 - spin_lock_irqsave(&omap->lock, flags); 453 - omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION); 454 - dev_dbg(dev, "OMAP UHH_REVISION 0x%x\n", omap->usbhs_rev); 455 365 456 366 reg = usbhs_read(omap->uhh_base, OMAP_UHH_HOSTCONFIG); 457 367 /* setup ULPI bypass and burst configurations */ ··· 458 374 reg |= OMAP4_UHH_HOSTCONFIG_APP_START_CLK; 459 375 reg &= ~OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN; 460 376 461 - if (is_omap_usbhs_rev1(omap)) { 462 - if (pdata->port_mode[0] == OMAP_USBHS_PORT_MODE_UNUSED) 463 - reg &= ~OMAP_UHH_HOSTCONFIG_P1_CONNECT_STATUS; 464 - if (pdata->port_mode[1] == OMAP_USBHS_PORT_MODE_UNUSED) 465 - reg &= ~OMAP_UHH_HOSTCONFIG_P2_CONNECT_STATUS; 466 - if (pdata->port_mode[2] == OMAP_USBHS_PORT_MODE_UNUSED) 467 - reg &= ~OMAP_UHH_HOSTCONFIG_P3_CONNECT_STATUS; 377 + switch (omap->usbhs_rev) { 378 + case OMAP_USBHS_REV1: 379 + omap_usbhs_rev1_hostconfig(omap, reg); 380 + break; 468 381 469 - /* Bypass the TLL module for PHY mode operation */ 470 - if (pdata->single_ulpi_bypass) { 471 - dev_dbg(dev, "OMAP3 ES version <= ES2.1\n"); 472 - if (is_ehci_phy_mode(pdata->port_mode[0]) || 473 - is_ehci_phy_mode(pdata->port_mode[1]) || 474 - is_ehci_phy_mode(pdata->port_mode[2])) 475 - reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_BYPASS; 476 - else 477 - reg |= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS; 478 - } else { 479 - dev_dbg(dev, "OMAP3 ES version > ES2.1\n"); 480 - if (is_ehci_phy_mode(pdata->port_mode[0])) 481 - reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS; 482 - else 483 - reg |= OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS; 484 - if (is_ehci_phy_mode(pdata->port_mode[1])) 485 - reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS; 486 - else 487 - reg |= OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS; 488 - if (is_ehci_phy_mode(pdata->port_mode[2])) 489 - reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P3_BYPASS; 490 - else 491 - reg |= OMAP_UHH_HOSTCONFIG_ULPI_P3_BYPASS; 492 - } 493 - } else if (is_omap_usbhs_rev2(omap)) { 494 - /* Clear port mode fields for PHY mode*/ 495 - reg &= ~OMAP4_P1_MODE_CLEAR; 496 - reg &= ~OMAP4_P2_MODE_CLEAR; 382 + case OMAP_USBHS_REV2: 383 + omap_usbhs_rev2_hostconfig(omap, reg); 384 + break; 497 385 498 - if (is_ehci_tll_mode(pdata->port_mode[0]) || 499 - (is_ohci_port(pdata->port_mode[0]))) 500 - reg |= OMAP4_P1_MODE_TLL; 501 - else if (is_ehci_hsic_mode(pdata->port_mode[0])) 502 - reg |= OMAP4_P1_MODE_HSIC; 503 - 504 - if (is_ehci_tll_mode(pdata->port_mode[1]) || 505 - (is_ohci_port(pdata->port_mode[1]))) 506 - reg |= OMAP4_P2_MODE_TLL; 507 - else if (is_ehci_hsic_mode(pdata->port_mode[1])) 508 - reg |= OMAP4_P2_MODE_HSIC; 386 + default: /* newer revisions */ 387 + omap_usbhs_rev2_hostconfig(omap, reg); 388 + break; 509 389 } 510 390 511 391 usbhs_write(omap->uhh_base, OMAP_UHH_HOSTCONFIG, reg); 512 392 dev_dbg(dev, "UHH setup done, uhh_hostconfig=%x\n", reg); 513 393 514 - spin_unlock_irqrestore(&omap->lock, flags); 515 - 516 394 pm_runtime_put_sync(dev); 517 - if (pdata->ehci_data->phy_reset) { 395 + if (pdata->phy_reset) { 518 396 /* Hold the PHY in RESET for enough time till 519 397 * PHY is settled and ready 520 398 */ 521 399 udelay(10); 522 400 523 - if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) 401 + if (gpio_is_valid(pdata->reset_gpio_port[0])) 524 402 gpio_set_value_cansleep 525 - (pdata->ehci_data->reset_gpio_port[0], 1); 403 + (pdata->reset_gpio_port[0], 1); 526 404 527 - if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) 405 + if (gpio_is_valid(pdata->reset_gpio_port[1])) 528 406 gpio_set_value_cansleep 529 - (pdata->ehci_data->reset_gpio_port[1], 1); 407 + (pdata->reset_gpio_port[1], 1); 530 408 } 531 409 } 532 410 533 411 static void omap_usbhs_deinit(struct device *dev) 534 412 { 535 413 struct usbhs_hcd_omap *omap = dev_get_drvdata(dev); 536 - struct usbhs_omap_platform_data *pdata = &omap->platdata; 414 + struct usbhs_omap_platform_data *pdata = omap->pdata; 537 415 538 - if (pdata->ehci_data->phy_reset) { 539 - if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) 540 - gpio_free(pdata->ehci_data->reset_gpio_port[0]); 416 + if (pdata->phy_reset) { 417 + if (gpio_is_valid(pdata->reset_gpio_port[0])) 418 + gpio_free(pdata->reset_gpio_port[0]); 541 419 542 - if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) 543 - gpio_free(pdata->ehci_data->reset_gpio_port[1]); 420 + if (gpio_is_valid(pdata->reset_gpio_port[1])) 421 + gpio_free(pdata->reset_gpio_port[1]); 544 422 } 545 423 } 546 424 ··· 520 474 struct resource *res; 521 475 int ret = 0; 522 476 int i; 477 + bool need_logic_fck; 523 478 524 479 if (!pdata) { 525 480 dev_err(dev, "Missing platform data\n"); 526 - ret = -ENOMEM; 527 - goto end_probe; 481 + return -ENODEV; 528 482 } 529 483 530 - omap = kzalloc(sizeof(*omap), GFP_KERNEL); 484 + omap = devm_kzalloc(dev, sizeof(*omap), GFP_KERNEL); 531 485 if (!omap) { 532 486 dev_err(dev, "Memory allocation failed\n"); 533 - ret = -ENOMEM; 534 - goto end_probe; 487 + return -ENOMEM; 535 488 } 536 489 537 - spin_lock_init(&omap->lock); 490 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "uhh"); 491 + omap->uhh_base = devm_request_and_ioremap(dev, res); 492 + if (!omap->uhh_base) { 493 + dev_err(dev, "Resource request/ioremap failed\n"); 494 + return -EADDRNOTAVAIL; 495 + } 538 496 539 - for (i = 0; i < OMAP3_HS_USB_PORTS; i++) 540 - omap->platdata.port_mode[i] = pdata->port_mode[i]; 541 - 542 - omap->platdata.ehci_data = pdata->ehci_data; 543 - omap->platdata.ohci_data = pdata->ohci_data; 497 + omap->pdata = pdata; 544 498 545 499 pm_runtime_enable(dev); 546 500 501 + platform_set_drvdata(pdev, omap); 502 + pm_runtime_get_sync(dev); 547 503 548 - for (i = 0; i < OMAP3_HS_USB_PORTS; i++) 549 - if (is_ehci_phy_mode(i) || is_ehci_tll_mode(i) || 550 - is_ehci_hsic_mode(i)) { 551 - omap->ehci_logic_fck = clk_get(dev, "ehci_logic_fck"); 552 - if (IS_ERR(omap->ehci_logic_fck)) { 553 - ret = PTR_ERR(omap->ehci_logic_fck); 554 - dev_warn(dev, "ehci_logic_fck failed:%d\n", 555 - ret); 556 - } 504 + omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION); 505 + 506 + /* we need to call runtime suspend before we update omap->nports 507 + * to prevent unbalanced clk_disable() 508 + */ 509 + pm_runtime_put_sync(dev); 510 + 511 + /* 512 + * If platform data contains nports then use that 513 + * else make out number of ports from USBHS revision 514 + */ 515 + if (pdata->nports) { 516 + omap->nports = pdata->nports; 517 + } else { 518 + switch (omap->usbhs_rev) { 519 + case OMAP_USBHS_REV1: 520 + omap->nports = 3; 521 + break; 522 + case OMAP_USBHS_REV2: 523 + omap->nports = 2; 524 + break; 525 + default: 526 + omap->nports = OMAP3_HS_USB_PORTS; 527 + dev_dbg(dev, 528 + "USB HOST Rev:0x%d not recognized, assuming %d ports\n", 529 + omap->usbhs_rev, omap->nports); 557 530 break; 558 531 } 532 + } 559 533 560 - omap->utmi_p1_fck = clk_get(dev, "utmi_p1_gfclk"); 561 - if (IS_ERR(omap->utmi_p1_fck)) { 562 - ret = PTR_ERR(omap->utmi_p1_fck); 563 - dev_err(dev, "utmi_p1_gfclk failed error:%d\n", ret); 564 - goto err_end; 534 + i = sizeof(struct clk *) * omap->nports; 535 + omap->utmi_clk = devm_kzalloc(dev, i, GFP_KERNEL); 536 + omap->hsic480m_clk = devm_kzalloc(dev, i, GFP_KERNEL); 537 + omap->hsic60m_clk = devm_kzalloc(dev, i, GFP_KERNEL); 538 + 539 + if (!omap->utmi_clk || !omap->hsic480m_clk || !omap->hsic60m_clk) { 540 + dev_err(dev, "Memory allocation failed\n"); 541 + ret = -ENOMEM; 542 + goto err_mem; 543 + } 544 + 545 + need_logic_fck = false; 546 + for (i = 0; i < omap->nports; i++) { 547 + if (is_ehci_phy_mode(i) || is_ehci_tll_mode(i) || 548 + is_ehci_hsic_mode(i)) 549 + need_logic_fck |= true; 550 + } 551 + 552 + omap->ehci_logic_fck = ERR_PTR(-EINVAL); 553 + if (need_logic_fck) { 554 + omap->ehci_logic_fck = clk_get(dev, "ehci_logic_fck"); 555 + if (IS_ERR(omap->ehci_logic_fck)) { 556 + ret = PTR_ERR(omap->ehci_logic_fck); 557 + dev_dbg(dev, "ehci_logic_fck failed:%d\n", ret); 558 + } 559 + } 560 + 561 + omap->utmi_p1_gfclk = clk_get(dev, "utmi_p1_gfclk"); 562 + if (IS_ERR(omap->utmi_p1_gfclk)) { 563 + ret = PTR_ERR(omap->utmi_p1_gfclk); 564 + dev_err(dev, "utmi_p1_gfclk failed error:%d\n", ret); 565 + goto err_p1_gfclk; 566 + } 567 + 568 + omap->utmi_p2_gfclk = clk_get(dev, "utmi_p2_gfclk"); 569 + if (IS_ERR(omap->utmi_p2_gfclk)) { 570 + ret = PTR_ERR(omap->utmi_p2_gfclk); 571 + dev_err(dev, "utmi_p2_gfclk failed error:%d\n", ret); 572 + goto err_p2_gfclk; 565 573 } 566 574 567 575 omap->xclk60mhsp1_ck = clk_get(dev, "xclk60mhsp1_ck"); 568 576 if (IS_ERR(omap->xclk60mhsp1_ck)) { 569 577 ret = PTR_ERR(omap->xclk60mhsp1_ck); 570 578 dev_err(dev, "xclk60mhsp1_ck failed error:%d\n", ret); 571 - goto err_utmi_p1_fck; 572 - } 573 - 574 - omap->utmi_p2_fck = clk_get(dev, "utmi_p2_gfclk"); 575 - if (IS_ERR(omap->utmi_p2_fck)) { 576 - ret = PTR_ERR(omap->utmi_p2_fck); 577 - dev_err(dev, "utmi_p2_gfclk failed error:%d\n", ret); 578 - goto err_xclk60mhsp1_ck; 579 + goto err_xclk60mhsp1; 579 580 } 580 581 581 582 omap->xclk60mhsp2_ck = clk_get(dev, "xclk60mhsp2_ck"); 582 583 if (IS_ERR(omap->xclk60mhsp2_ck)) { 583 584 ret = PTR_ERR(omap->xclk60mhsp2_ck); 584 585 dev_err(dev, "xclk60mhsp2_ck failed error:%d\n", ret); 585 - goto err_utmi_p2_fck; 586 - } 587 - 588 - omap->usbhost_p1_fck = clk_get(dev, "usb_host_hs_utmi_p1_clk"); 589 - if (IS_ERR(omap->usbhost_p1_fck)) { 590 - ret = PTR_ERR(omap->usbhost_p1_fck); 591 - dev_err(dev, "usbhost_p1_fck failed error:%d\n", ret); 592 - goto err_xclk60mhsp2_ck; 593 - } 594 - 595 - omap->usbhost_p2_fck = clk_get(dev, "usb_host_hs_utmi_p2_clk"); 596 - if (IS_ERR(omap->usbhost_p2_fck)) { 597 - ret = PTR_ERR(omap->usbhost_p2_fck); 598 - dev_err(dev, "usbhost_p2_fck failed error:%d\n", ret); 599 - goto err_usbhost_p1_fck; 586 + goto err_xclk60mhsp2; 600 587 } 601 588 602 589 omap->init_60m_fclk = clk_get(dev, "init_60m_fclk"); 603 590 if (IS_ERR(omap->init_60m_fclk)) { 604 591 ret = PTR_ERR(omap->init_60m_fclk); 605 592 dev_err(dev, "init_60m_fclk failed error:%d\n", ret); 606 - goto err_usbhost_p2_fck; 593 + goto err_init60m; 594 + } 595 + 596 + for (i = 0; i < omap->nports; i++) { 597 + char clkname[30]; 598 + 599 + /* clock names are indexed from 1*/ 600 + snprintf(clkname, sizeof(clkname), 601 + "usb_host_hs_utmi_p%d_clk", i + 1); 602 + 603 + /* If a clock is not found we won't bail out as not all 604 + * platforms have all clocks and we can function without 605 + * them 606 + */ 607 + omap->utmi_clk[i] = clk_get(dev, clkname); 608 + if (IS_ERR(omap->utmi_clk[i])) 609 + dev_dbg(dev, "Failed to get clock : %s : %ld\n", 610 + clkname, PTR_ERR(omap->utmi_clk[i])); 611 + 612 + snprintf(clkname, sizeof(clkname), 613 + "usb_host_hs_hsic480m_p%d_clk", i + 1); 614 + omap->hsic480m_clk[i] = clk_get(dev, clkname); 615 + if (IS_ERR(omap->hsic480m_clk[i])) 616 + dev_dbg(dev, "Failed to get clock : %s : %ld\n", 617 + clkname, PTR_ERR(omap->hsic480m_clk[i])); 618 + 619 + snprintf(clkname, sizeof(clkname), 620 + "usb_host_hs_hsic60m_p%d_clk", i + 1); 621 + omap->hsic60m_clk[i] = clk_get(dev, clkname); 622 + if (IS_ERR(omap->hsic60m_clk[i])) 623 + dev_dbg(dev, "Failed to get clock : %s : %ld\n", 624 + clkname, PTR_ERR(omap->hsic60m_clk[i])); 607 625 } 608 626 609 627 if (is_ehci_phy_mode(pdata->port_mode[0])) { 610 - /* for OMAP3 , the clk set paretn fails */ 611 - ret = clk_set_parent(omap->utmi_p1_fck, 628 + /* for OMAP3, clk_set_parent fails */ 629 + ret = clk_set_parent(omap->utmi_p1_gfclk, 612 630 omap->xclk60mhsp1_ck); 613 631 if (ret != 0) 614 - dev_err(dev, "xclk60mhsp1_ck set parent" 615 - "failed error:%d\n", ret); 632 + dev_dbg(dev, "xclk60mhsp1_ck set parent failed: %d\n", 633 + ret); 616 634 } else if (is_ehci_tll_mode(pdata->port_mode[0])) { 617 - ret = clk_set_parent(omap->utmi_p1_fck, 635 + ret = clk_set_parent(omap->utmi_p1_gfclk, 618 636 omap->init_60m_fclk); 619 637 if (ret != 0) 620 - dev_err(dev, "init_60m_fclk set parent" 621 - "failed error:%d\n", ret); 638 + dev_dbg(dev, "P0 init_60m_fclk set parent failed: %d\n", 639 + ret); 622 640 } 623 641 624 642 if (is_ehci_phy_mode(pdata->port_mode[1])) { 625 - ret = clk_set_parent(omap->utmi_p2_fck, 643 + ret = clk_set_parent(omap->utmi_p2_gfclk, 626 644 omap->xclk60mhsp2_ck); 627 645 if (ret != 0) 628 - dev_err(dev, "xclk60mhsp2_ck set parent" 629 - "failed error:%d\n", ret); 646 + dev_dbg(dev, "xclk60mhsp2_ck set parent failed: %d\n", 647 + ret); 630 648 } else if (is_ehci_tll_mode(pdata->port_mode[1])) { 631 - ret = clk_set_parent(omap->utmi_p2_fck, 649 + ret = clk_set_parent(omap->utmi_p2_gfclk, 632 650 omap->init_60m_fclk); 633 651 if (ret != 0) 634 - dev_err(dev, "init_60m_fclk set parent" 635 - "failed error:%d\n", ret); 652 + dev_dbg(dev, "P1 init_60m_fclk set parent failed: %d\n", 653 + ret); 636 654 } 637 - 638 - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "uhh"); 639 - if (!res) { 640 - dev_err(dev, "UHH EHCI get resource failed\n"); 641 - ret = -ENODEV; 642 - goto err_init_60m_fclk; 643 - } 644 - 645 - omap->uhh_base = ioremap(res->start, resource_size(res)); 646 - if (!omap->uhh_base) { 647 - dev_err(dev, "UHH ioremap failed\n"); 648 - ret = -ENOMEM; 649 - goto err_init_60m_fclk; 650 - } 651 - 652 - platform_set_drvdata(pdev, omap); 653 655 654 656 omap_usbhs_init(dev); 655 657 ret = omap_usbhs_alloc_children(pdev); ··· 706 612 goto err_alloc; 707 613 } 708 614 709 - goto end_probe; 615 + return 0; 710 616 711 617 err_alloc: 712 618 omap_usbhs_deinit(&pdev->dev); 713 - iounmap(omap->uhh_base); 714 619 715 - err_init_60m_fclk: 620 + for (i = 0; i < omap->nports; i++) { 621 + if (!IS_ERR(omap->utmi_clk[i])) 622 + clk_put(omap->utmi_clk[i]); 623 + if (!IS_ERR(omap->hsic60m_clk[i])) 624 + clk_put(omap->hsic60m_clk[i]); 625 + if (!IS_ERR(omap->hsic480m_clk[i])) 626 + clk_put(omap->hsic480m_clk[i]); 627 + } 628 + 716 629 clk_put(omap->init_60m_fclk); 717 630 718 - err_usbhost_p2_fck: 719 - clk_put(omap->usbhost_p2_fck); 720 - 721 - err_usbhost_p1_fck: 722 - clk_put(omap->usbhost_p1_fck); 723 - 724 - err_xclk60mhsp2_ck: 631 + err_init60m: 725 632 clk_put(omap->xclk60mhsp2_ck); 726 633 727 - err_utmi_p2_fck: 728 - clk_put(omap->utmi_p2_fck); 729 - 730 - err_xclk60mhsp1_ck: 634 + err_xclk60mhsp2: 731 635 clk_put(omap->xclk60mhsp1_ck); 732 636 733 - err_utmi_p1_fck: 734 - clk_put(omap->utmi_p1_fck); 637 + err_xclk60mhsp1: 638 + clk_put(omap->utmi_p2_gfclk); 735 639 736 - err_end: 737 - clk_put(omap->ehci_logic_fck); 640 + err_p2_gfclk: 641 + clk_put(omap->utmi_p1_gfclk); 642 + 643 + err_p1_gfclk: 644 + if (!IS_ERR(omap->ehci_logic_fck)) 645 + clk_put(omap->ehci_logic_fck); 646 + 647 + err_mem: 738 648 pm_runtime_disable(dev); 739 - kfree(omap); 740 649 741 - end_probe: 742 650 return ret; 743 651 } 744 652 ··· 753 657 static int usbhs_omap_remove(struct platform_device *pdev) 754 658 { 755 659 struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev); 660 + int i; 756 661 757 662 omap_usbhs_deinit(&pdev->dev); 758 - iounmap(omap->uhh_base); 663 + 664 + for (i = 0; i < omap->nports; i++) { 665 + if (!IS_ERR(omap->utmi_clk[i])) 666 + clk_put(omap->utmi_clk[i]); 667 + if (!IS_ERR(omap->hsic60m_clk[i])) 668 + clk_put(omap->hsic60m_clk[i]); 669 + if (!IS_ERR(omap->hsic480m_clk[i])) 670 + clk_put(omap->hsic480m_clk[i]); 671 + } 672 + 759 673 clk_put(omap->init_60m_fclk); 760 - clk_put(omap->usbhost_p2_fck); 761 - clk_put(omap->usbhost_p1_fck); 674 + clk_put(omap->utmi_p1_gfclk); 675 + clk_put(omap->utmi_p2_gfclk); 762 676 clk_put(omap->xclk60mhsp2_ck); 763 - clk_put(omap->utmi_p2_fck); 764 677 clk_put(omap->xclk60mhsp1_ck); 765 - clk_put(omap->utmi_p1_fck); 766 - clk_put(omap->ehci_logic_fck); 678 + 679 + if (!IS_ERR(omap->ehci_logic_fck)) 680 + clk_put(omap->ehci_logic_fck); 681 + 767 682 pm_runtime_disable(&pdev->dev); 768 - kfree(omap); 769 683 770 684 return 0; 771 685 } ··· 791 685 .owner = THIS_MODULE, 792 686 .pm = &usbhsomap_dev_pm_ops, 793 687 }, 794 - .remove = __exit_p(usbhs_omap_remove), 688 + .remove = usbhs_omap_remove, 795 689 }; 796 690 797 691 MODULE_AUTHOR("Keshava Munegowda <keshava_mgowda@ti.com>");
+136 -111
drivers/mfd/omap-usb-tll.c
··· 54 54 55 55 #define OMAP_TLL_CHANNEL_CONF(num) (0x040 + 0x004 * num) 56 56 #define OMAP_TLL_CHANNEL_CONF_FSLSMODE_SHIFT 24 57 + #define OMAP_TLL_CHANNEL_CONF_DRVVBUS (1 << 16) 58 + #define OMAP_TLL_CHANNEL_CONF_CHRGVBUS (1 << 15) 57 59 #define OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF (1 << 11) 58 60 #define OMAP_TLL_CHANNEL_CONF_ULPI_ULPIAUTOIDLE (1 << 10) 59 61 #define OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE (1 << 9) 60 62 #define OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE (1 << 8) 63 + #define OMAP_TLL_CHANNEL_CONF_MODE_TRANSPARENT_UTMI (2 << 1) 61 64 #define OMAP_TLL_CHANNEL_CONF_CHANMODE_FSLS (1 << 1) 62 65 #define OMAP_TLL_CHANNEL_CONF_CHANEN (1 << 0) 63 66 ··· 95 92 #define OMAP_USBTLL_REV1 0x00000015 /* OMAP3 */ 96 93 #define OMAP_USBTLL_REV2 0x00000018 /* OMAP 3630 */ 97 94 #define OMAP_USBTLL_REV3 0x00000004 /* OMAP4 */ 95 + #define OMAP_USBTLL_REV4 0x00000006 /* OMAP5 */ 98 96 99 97 #define is_ehci_tll_mode(x) (x == OMAP_EHCI_PORT_MODE_TLL) 100 98 99 + /* only PHY and UNUSED modes don't need TLL */ 100 + #define omap_usb_mode_needs_tll(x) ((x) != OMAP_USBHS_PORT_MODE_UNUSED &&\ 101 + (x) != OMAP_EHCI_PORT_MODE_PHY) 102 + 101 103 struct usbtll_omap { 102 - struct clk *usbtll_p1_fck; 103 - struct clk *usbtll_p2_fck; 104 - struct usbtll_omap_platform_data platdata; 105 - /* secure the register updates */ 106 - spinlock_t lock; 104 + int nch; /* num. of channels */ 105 + struct usbhs_omap_platform_data *pdata; 106 + struct clk **ch_clk; 107 107 }; 108 108 109 109 /*-------------------------------------------------------------------------*/ 110 110 111 - const char usbtll_driver_name[] = USBTLL_DRIVER_NAME; 112 - struct platform_device *tll_pdev; 111 + static const char usbtll_driver_name[] = USBTLL_DRIVER_NAME; 112 + static struct device *tll_dev; 113 + static DEFINE_SPINLOCK(tll_lock); /* serialize access to tll_dev */ 113 114 114 115 /*-------------------------------------------------------------------------*/ 115 116 ··· 210 203 static int usbtll_omap_probe(struct platform_device *pdev) 211 204 { 212 205 struct device *dev = &pdev->dev; 213 - struct usbtll_omap_platform_data *pdata = dev->platform_data; 206 + struct usbhs_omap_platform_data *pdata = dev->platform_data; 214 207 void __iomem *base; 215 208 struct resource *res; 216 209 struct usbtll_omap *tll; 217 210 unsigned reg; 218 - unsigned long flags; 219 211 int ret = 0; 220 - int i, ver, count; 212 + int i, ver; 213 + bool needs_tll; 221 214 222 215 dev_dbg(dev, "starting TI HSUSB TLL Controller\n"); 223 216 224 - tll = kzalloc(sizeof(struct usbtll_omap), GFP_KERNEL); 217 + tll = devm_kzalloc(dev, sizeof(struct usbtll_omap), GFP_KERNEL); 225 218 if (!tll) { 226 219 dev_err(dev, "Memory allocation failed\n"); 227 - ret = -ENOMEM; 228 - goto end; 220 + return -ENOMEM; 229 221 } 230 222 231 - spin_lock_init(&tll->lock); 232 - 233 - for (i = 0; i < OMAP3_HS_USB_PORTS; i++) 234 - tll->platdata.port_mode[i] = pdata->port_mode[i]; 235 - 236 - tll->usbtll_p1_fck = clk_get(dev, "usb_tll_hs_usb_ch0_clk"); 237 - if (IS_ERR(tll->usbtll_p1_fck)) { 238 - ret = PTR_ERR(tll->usbtll_p1_fck); 239 - dev_err(dev, "usbtll_p1_fck failed error:%d\n", ret); 240 - goto err_tll; 223 + if (!pdata) { 224 + dev_err(dev, "Platform data missing\n"); 225 + return -ENODEV; 241 226 } 242 227 243 - tll->usbtll_p2_fck = clk_get(dev, "usb_tll_hs_usb_ch1_clk"); 244 - if (IS_ERR(tll->usbtll_p2_fck)) { 245 - ret = PTR_ERR(tll->usbtll_p2_fck); 246 - dev_err(dev, "usbtll_p2_fck failed error:%d\n", ret); 247 - goto err_usbtll_p1_fck; 248 - } 228 + tll->pdata = pdata; 249 229 250 230 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 251 - if (!res) { 252 - dev_err(dev, "usb tll get resource failed\n"); 253 - ret = -ENODEV; 254 - goto err_usbtll_p2_fck; 255 - } 256 - 257 - base = ioremap(res->start, resource_size(res)); 231 + base = devm_request_and_ioremap(dev, res); 258 232 if (!base) { 259 - dev_err(dev, "TLL ioremap failed\n"); 260 - ret = -ENOMEM; 261 - goto err_usbtll_p2_fck; 233 + ret = -EADDRNOTAVAIL; 234 + dev_err(dev, "Resource request/ioremap failed:%d\n", ret); 235 + return ret; 262 236 } 263 237 264 238 platform_set_drvdata(pdev, tll); 265 239 pm_runtime_enable(dev); 266 240 pm_runtime_get_sync(dev); 267 241 268 - spin_lock_irqsave(&tll->lock, flags); 269 - 270 242 ver = usbtll_read(base, OMAP_USBTLL_REVISION); 271 243 switch (ver) { 272 244 case OMAP_USBTLL_REV1: 273 - case OMAP_USBTLL_REV2: 274 - count = OMAP_TLL_CHANNEL_COUNT; 245 + case OMAP_USBTLL_REV4: 246 + tll->nch = OMAP_TLL_CHANNEL_COUNT; 275 247 break; 248 + case OMAP_USBTLL_REV2: 276 249 case OMAP_USBTLL_REV3: 277 - count = OMAP_REV2_TLL_CHANNEL_COUNT; 250 + tll->nch = OMAP_REV2_TLL_CHANNEL_COUNT; 278 251 break; 279 252 default: 280 - dev_err(dev, "TLL version failed\n"); 281 - ret = -ENODEV; 282 - goto err_ioremap; 253 + tll->nch = OMAP_TLL_CHANNEL_COUNT; 254 + dev_dbg(dev, 255 + "USB TLL Rev : 0x%x not recognized, assuming %d channels\n", 256 + ver, tll->nch); 257 + break; 283 258 } 284 259 285 - if (is_ehci_tll_mode(pdata->port_mode[0]) || 286 - is_ehci_tll_mode(pdata->port_mode[1]) || 287 - is_ehci_tll_mode(pdata->port_mode[2]) || 288 - is_ohci_port(pdata->port_mode[0]) || 289 - is_ohci_port(pdata->port_mode[1]) || 290 - is_ohci_port(pdata->port_mode[2])) { 260 + tll->ch_clk = devm_kzalloc(dev, sizeof(struct clk * [tll->nch]), 261 + GFP_KERNEL); 262 + if (!tll->ch_clk) { 263 + ret = -ENOMEM; 264 + dev_err(dev, "Couldn't allocate memory for channel clocks\n"); 265 + goto err_clk_alloc; 266 + } 267 + 268 + for (i = 0; i < tll->nch; i++) { 269 + char clkname[] = "usb_tll_hs_usb_chx_clk"; 270 + 271 + snprintf(clkname, sizeof(clkname), 272 + "usb_tll_hs_usb_ch%d_clk", i); 273 + tll->ch_clk[i] = clk_get(dev, clkname); 274 + 275 + if (IS_ERR(tll->ch_clk[i])) 276 + dev_dbg(dev, "can't get clock : %s\n", clkname); 277 + } 278 + 279 + needs_tll = false; 280 + for (i = 0; i < tll->nch; i++) 281 + needs_tll |= omap_usb_mode_needs_tll(pdata->port_mode[i]); 282 + 283 + if (needs_tll) { 291 284 292 285 /* Program Common TLL register */ 293 286 reg = usbtll_read(base, OMAP_TLL_SHARED_CONF); ··· 299 292 usbtll_write(base, OMAP_TLL_SHARED_CONF, reg); 300 293 301 294 /* Enable channels now */ 302 - for (i = 0; i < count; i++) { 295 + for (i = 0; i < tll->nch; i++) { 303 296 reg = usbtll_read(base, OMAP_TLL_CHANNEL_CONF(i)); 304 297 305 298 if (is_ohci_port(pdata->port_mode[i])) { ··· 315 308 reg &= ~(OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE 316 309 | OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF 317 310 | OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE); 311 + } else if (pdata->port_mode[i] == 312 + OMAP_EHCI_PORT_MODE_HSIC) { 313 + /* 314 + * HSIC Mode requires UTMI port configurations 315 + */ 316 + reg |= OMAP_TLL_CHANNEL_CONF_DRVVBUS 317 + | OMAP_TLL_CHANNEL_CONF_CHRGVBUS 318 + | OMAP_TLL_CHANNEL_CONF_MODE_TRANSPARENT_UTMI 319 + | OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF; 318 320 } else { 319 321 continue; 320 322 } ··· 336 320 } 337 321 } 338 322 339 - err_ioremap: 340 - spin_unlock_irqrestore(&tll->lock, flags); 341 - iounmap(base); 342 323 pm_runtime_put_sync(dev); 343 - tll_pdev = pdev; 344 - if (!ret) 345 - goto end; 324 + /* only after this can omap_tll_enable/disable work */ 325 + spin_lock(&tll_lock); 326 + tll_dev = dev; 327 + spin_unlock(&tll_lock); 328 + 329 + return 0; 330 + 331 + err_clk_alloc: 332 + pm_runtime_put_sync(dev); 346 333 pm_runtime_disable(dev); 347 334 348 - err_usbtll_p2_fck: 349 - clk_put(tll->usbtll_p2_fck); 350 - 351 - err_usbtll_p1_fck: 352 - clk_put(tll->usbtll_p1_fck); 353 - 354 - err_tll: 355 - kfree(tll); 356 - 357 - end: 358 335 return ret; 359 336 } 360 337 ··· 360 351 static int usbtll_omap_remove(struct platform_device *pdev) 361 352 { 362 353 struct usbtll_omap *tll = platform_get_drvdata(pdev); 354 + int i; 363 355 364 - clk_put(tll->usbtll_p2_fck); 365 - clk_put(tll->usbtll_p1_fck); 356 + spin_lock(&tll_lock); 357 + tll_dev = NULL; 358 + spin_unlock(&tll_lock); 359 + 360 + for (i = 0; i < tll->nch; i++) 361 + if (!IS_ERR(tll->ch_clk[i])) 362 + clk_put(tll->ch_clk[i]); 363 + 366 364 pm_runtime_disable(&pdev->dev); 367 - kfree(tll); 368 365 return 0; 369 366 } 370 367 371 368 static int usbtll_runtime_resume(struct device *dev) 372 369 { 373 370 struct usbtll_omap *tll = dev_get_drvdata(dev); 374 - struct usbtll_omap_platform_data *pdata = &tll->platdata; 375 - unsigned long flags; 371 + struct usbhs_omap_platform_data *pdata = tll->pdata; 372 + int i; 376 373 377 374 dev_dbg(dev, "usbtll_runtime_resume\n"); 378 375 379 - if (!pdata) { 380 - dev_dbg(dev, "missing platform_data\n"); 381 - return -ENODEV; 376 + for (i = 0; i < tll->nch; i++) { 377 + if (omap_usb_mode_needs_tll(pdata->port_mode[i])) { 378 + int r; 379 + 380 + if (IS_ERR(tll->ch_clk[i])) 381 + continue; 382 + 383 + r = clk_enable(tll->ch_clk[i]); 384 + if (r) { 385 + dev_err(dev, 386 + "Error enabling ch %d clock: %d\n", i, r); 387 + } 388 + } 382 389 } 383 - 384 - spin_lock_irqsave(&tll->lock, flags); 385 - 386 - if (is_ehci_tll_mode(pdata->port_mode[0])) 387 - clk_enable(tll->usbtll_p1_fck); 388 - 389 - if (is_ehci_tll_mode(pdata->port_mode[1])) 390 - clk_enable(tll->usbtll_p2_fck); 391 - 392 - spin_unlock_irqrestore(&tll->lock, flags); 393 390 394 391 return 0; 395 392 } ··· 403 388 static int usbtll_runtime_suspend(struct device *dev) 404 389 { 405 390 struct usbtll_omap *tll = dev_get_drvdata(dev); 406 - struct usbtll_omap_platform_data *pdata = &tll->platdata; 407 - unsigned long flags; 391 + struct usbhs_omap_platform_data *pdata = tll->pdata; 392 + int i; 408 393 409 394 dev_dbg(dev, "usbtll_runtime_suspend\n"); 410 395 411 - if (!pdata) { 412 - dev_dbg(dev, "missing platform_data\n"); 413 - return -ENODEV; 396 + for (i = 0; i < tll->nch; i++) { 397 + if (omap_usb_mode_needs_tll(pdata->port_mode[i])) { 398 + if (!IS_ERR(tll->ch_clk[i])) 399 + clk_disable(tll->ch_clk[i]); 400 + } 414 401 } 415 - 416 - spin_lock_irqsave(&tll->lock, flags); 417 - 418 - if (is_ehci_tll_mode(pdata->port_mode[0])) 419 - clk_disable(tll->usbtll_p1_fck); 420 - 421 - if (is_ehci_tll_mode(pdata->port_mode[1])) 422 - clk_disable(tll->usbtll_p2_fck); 423 - 424 - spin_unlock_irqrestore(&tll->lock, flags); 425 402 426 403 return 0; 427 404 } ··· 436 429 437 430 int omap_tll_enable(void) 438 431 { 439 - if (!tll_pdev) { 440 - pr_err("missing omap usbhs tll platform_data\n"); 441 - return -ENODEV; 432 + int ret; 433 + 434 + spin_lock(&tll_lock); 435 + 436 + if (!tll_dev) { 437 + pr_err("%s: OMAP USB TLL not initialized\n", __func__); 438 + ret = -ENODEV; 439 + } else { 440 + ret = pm_runtime_get_sync(tll_dev); 442 441 } 443 - return pm_runtime_get_sync(&tll_pdev->dev); 442 + 443 + spin_unlock(&tll_lock); 444 + 445 + return ret; 444 446 } 445 447 EXPORT_SYMBOL_GPL(omap_tll_enable); 446 448 447 449 int omap_tll_disable(void) 448 450 { 449 - if (!tll_pdev) { 450 - pr_err("missing omap usbhs tll platform_data\n"); 451 - return -ENODEV; 451 + int ret; 452 + 453 + spin_lock(&tll_lock); 454 + 455 + if (!tll_dev) { 456 + pr_err("%s: OMAP USB TLL not initialized\n", __func__); 457 + ret = -ENODEV; 458 + } else { 459 + ret = pm_runtime_put_sync(tll_dev); 452 460 } 453 - return pm_runtime_put_sync(&tll_pdev->dev); 461 + 462 + spin_unlock(&tll_lock); 463 + 464 + return ret; 454 465 } 455 466 EXPORT_SYMBOL_GPL(omap_tll_disable); 456 467
+12 -2
drivers/mfd/palmas.c
··· 39 39 PALMAS_USB_ID, 40 40 }; 41 41 42 + static struct resource palmas_rtc_resources[] = { 43 + { 44 + .start = PALMAS_RTC_ALARM_IRQ, 45 + .end = PALMAS_RTC_ALARM_IRQ, 46 + .flags = IORESOURCE_IRQ, 47 + }, 48 + }; 49 + 42 50 static const struct mfd_cell palmas_children[] = { 43 51 { 44 52 .name = "palmas-pmic", ··· 67 59 { 68 60 .name = "palmas-rtc", 69 61 .id = PALMAS_RTC_ID, 62 + .resources = &palmas_rtc_resources[0], 63 + .num_resources = ARRAY_SIZE(palmas_rtc_resources), 70 64 }, 71 65 { 72 66 .name = "palmas-pwrbutton", ··· 466 456 467 457 ret = mfd_add_devices(palmas->dev, -1, 468 458 children, ARRAY_SIZE(palmas_children), 469 - NULL, regmap_irq_chip_get_base(palmas->irq_data), 470 - NULL); 459 + NULL, 0, 460 + regmap_irq_get_domain(palmas->irq_data)); 471 461 kfree(children); 472 462 473 463 if (ret < 0)
+13 -3
drivers/mfd/rtl8411.c
··· 115 115 static int rtl8411_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) 116 116 { 117 117 u8 mask, val; 118 + int err; 118 119 119 120 mask = (BPP_REG_TUNED18 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_MASK; 120 - if (voltage == OUTPUT_3V3) 121 + if (voltage == OUTPUT_3V3) { 122 + err = rtsx_pci_write_register(pcr, 123 + SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_D); 124 + if (err < 0) 125 + return err; 121 126 val = (BPP_ASIC_3V3 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_3V3; 122 - else if (voltage == OUTPUT_1V8) 127 + } else if (voltage == OUTPUT_1V8) { 128 + err = rtsx_pci_write_register(pcr, 129 + SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B); 130 + if (err < 0) 131 + return err; 123 132 val = (BPP_ASIC_1V8 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_1V8; 124 - else 133 + } else { 125 134 return -EINVAL; 135 + } 126 136 127 137 return rtsx_pci_write_register(pcr, LDO_CTL, mask, val); 128 138 }
+8
drivers/mfd/rts5209.c
··· 149 149 int err; 150 150 151 151 if (voltage == OUTPUT_3V3) { 152 + err = rtsx_pci_write_register(pcr, 153 + SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_D); 154 + if (err < 0) 155 + return err; 152 156 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24); 153 157 if (err < 0) 154 158 return err; 155 159 } else if (voltage == OUTPUT_1V8) { 160 + err = rtsx_pci_write_register(pcr, 161 + SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B); 162 + if (err < 0) 163 + return err; 156 164 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24); 157 165 if (err < 0) 158 166 return err;
+234
drivers/mfd/rts5227.c
··· 1 + /* Driver for Realtek PCI-Express card reader 2 + * 3 + * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms of the GNU General Public License as published by the 7 + * Free Software Foundation; either version 2, or (at your option) any 8 + * later version. 9 + * 10 + * This program is distributed in the hope that it will be useful, but 11 + * WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 + * General Public License for more details. 14 + * 15 + * You should have received a copy of the GNU General Public License along 16 + * with this program; if not, see <http://www.gnu.org/licenses/>. 17 + * 18 + * Author: 19 + * Wei WANG <wei_wang@realsil.com.cn> 20 + * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China 21 + * 22 + * Roger Tseng <rogerable@realtek.com> 23 + * No. 2, Innovation Road II, Hsinchu Science Park, Hsinchu 300, Taiwan 24 + */ 25 + 26 + #include <linux/module.h> 27 + #include <linux/delay.h> 28 + #include <linux/mfd/rtsx_pci.h> 29 + 30 + #include "rtsx_pcr.h" 31 + 32 + static int rts5227_extra_init_hw(struct rtsx_pcr *pcr) 33 + { 34 + u16 cap; 35 + 36 + rtsx_pci_init_cmd(pcr); 37 + 38 + /* Configure GPIO as output */ 39 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02); 40 + /* Switch LDO3318 source from DV33 to card_3v3 */ 41 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x00); 42 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01); 43 + /* LED shine disabled, set initial shine cycle period */ 44 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OLT_LED_CTL, 0x0F, 0x02); 45 + /* Configure LTR */ 46 + pcie_capability_read_word(pcr->pci, PCI_EXP_DEVCTL2, &cap); 47 + if (cap & PCI_EXP_LTR_EN) 48 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LTR_CTL, 0xFF, 0xA3); 49 + /* Configure OBFF */ 50 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OBFF_CFG, 0x03, 0x03); 51 + /* Configure force_clock_req 52 + * Maybe We should define 0xFF03 as some name 53 + */ 54 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, 0xFF03, 0x08, 0x08); 55 + /* Correct driving */ 56 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, 57 + SD30_CLK_DRIVE_SEL, 0xFF, 0x96); 58 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, 59 + SD30_CMD_DRIVE_SEL, 0xFF, 0x96); 60 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, 61 + SD30_DAT_DRIVE_SEL, 0xFF, 0x96); 62 + 63 + return rtsx_pci_send_cmd(pcr, 100); 64 + } 65 + 66 + static int rts5227_optimize_phy(struct rtsx_pcr *pcr) 67 + { 68 + /* Optimize RX sensitivity */ 69 + return rtsx_pci_write_phy_register(pcr, 0x00, 0xBA42); 70 + } 71 + 72 + static int rts5227_turn_on_led(struct rtsx_pcr *pcr) 73 + { 74 + return rtsx_pci_write_register(pcr, GPIO_CTL, 0x02, 0x02); 75 + } 76 + 77 + static int rts5227_turn_off_led(struct rtsx_pcr *pcr) 78 + { 79 + return rtsx_pci_write_register(pcr, GPIO_CTL, 0x02, 0x00); 80 + } 81 + 82 + static int rts5227_enable_auto_blink(struct rtsx_pcr *pcr) 83 + { 84 + return rtsx_pci_write_register(pcr, OLT_LED_CTL, 0x08, 0x08); 85 + } 86 + 87 + static int rts5227_disable_auto_blink(struct rtsx_pcr *pcr) 88 + { 89 + return rtsx_pci_write_register(pcr, OLT_LED_CTL, 0x08, 0x00); 90 + } 91 + 92 + static int rts5227_card_power_on(struct rtsx_pcr *pcr, int card) 93 + { 94 + int err; 95 + 96 + rtsx_pci_init_cmd(pcr); 97 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_PWR_CTL, 98 + SD_POWER_MASK, SD_PARTIAL_POWER_ON); 99 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL, 100 + LDO3318_PWR_MASK, 0x02); 101 + err = rtsx_pci_send_cmd(pcr, 100); 102 + if (err < 0) 103 + return err; 104 + 105 + /* To avoid too large in-rush current */ 106 + udelay(150); 107 + 108 + rtsx_pci_init_cmd(pcr); 109 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_PWR_CTL, 110 + SD_POWER_MASK, SD_POWER_ON); 111 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL, 112 + LDO3318_PWR_MASK, 0x06); 113 + err = rtsx_pci_send_cmd(pcr, 100); 114 + if (err < 0) 115 + return err; 116 + 117 + return 0; 118 + } 119 + 120 + static int rts5227_card_power_off(struct rtsx_pcr *pcr, int card) 121 + { 122 + rtsx_pci_init_cmd(pcr); 123 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_PWR_CTL, 124 + SD_POWER_MASK | PMOS_STRG_MASK, 125 + SD_POWER_OFF | PMOS_STRG_400mA); 126 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL, 127 + LDO3318_PWR_MASK, 0X00); 128 + return rtsx_pci_send_cmd(pcr, 100); 129 + } 130 + 131 + static int rts5227_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) 132 + { 133 + int err; 134 + u8 drive_sel; 135 + 136 + if (voltage == OUTPUT_3V3) { 137 + err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24); 138 + if (err < 0) 139 + return err; 140 + drive_sel = 0x96; 141 + } else if (voltage == OUTPUT_1V8) { 142 + err = rtsx_pci_write_phy_register(pcr, 0x11, 0x3C02); 143 + if (err < 0) 144 + return err; 145 + err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C80 | 0x24); 146 + if (err < 0) 147 + return err; 148 + drive_sel = 0xB3; 149 + } else { 150 + return -EINVAL; 151 + } 152 + 153 + /* set pad drive */ 154 + rtsx_pci_init_cmd(pcr); 155 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CLK_DRIVE_SEL, 156 + 0xFF, drive_sel); 157 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CMD_DRIVE_SEL, 158 + 0xFF, drive_sel); 159 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DAT_DRIVE_SEL, 160 + 0xFF, drive_sel); 161 + return rtsx_pci_send_cmd(pcr, 100); 162 + } 163 + 164 + static const struct pcr_ops rts5227_pcr_ops = { 165 + .extra_init_hw = rts5227_extra_init_hw, 166 + .optimize_phy = rts5227_optimize_phy, 167 + .turn_on_led = rts5227_turn_on_led, 168 + .turn_off_led = rts5227_turn_off_led, 169 + .enable_auto_blink = rts5227_enable_auto_blink, 170 + .disable_auto_blink = rts5227_disable_auto_blink, 171 + .card_power_on = rts5227_card_power_on, 172 + .card_power_off = rts5227_card_power_off, 173 + .switch_output_voltage = rts5227_switch_output_voltage, 174 + .cd_deglitch = NULL, 175 + .conv_clk_and_div_n = NULL, 176 + }; 177 + 178 + /* SD Pull Control Enable: 179 + * SD_DAT[3:0] ==> pull up 180 + * SD_CD ==> pull up 181 + * SD_WP ==> pull up 182 + * SD_CMD ==> pull up 183 + * SD_CLK ==> pull down 184 + */ 185 + static const u32 rts5227_sd_pull_ctl_enable_tbl[] = { 186 + RTSX_REG_PAIR(CARD_PULL_CTL2, 0xAA), 187 + RTSX_REG_PAIR(CARD_PULL_CTL3, 0xE9), 188 + 0, 189 + }; 190 + 191 + /* SD Pull Control Disable: 192 + * SD_DAT[3:0] ==> pull down 193 + * SD_CD ==> pull up 194 + * SD_WP ==> pull down 195 + * SD_CMD ==> pull down 196 + * SD_CLK ==> pull down 197 + */ 198 + static const u32 rts5227_sd_pull_ctl_disable_tbl[] = { 199 + RTSX_REG_PAIR(CARD_PULL_CTL2, 0x55), 200 + RTSX_REG_PAIR(CARD_PULL_CTL3, 0xD5), 201 + 0, 202 + }; 203 + 204 + /* MS Pull Control Enable: 205 + * MS CD ==> pull up 206 + * others ==> pull down 207 + */ 208 + static const u32 rts5227_ms_pull_ctl_enable_tbl[] = { 209 + RTSX_REG_PAIR(CARD_PULL_CTL5, 0x55), 210 + RTSX_REG_PAIR(CARD_PULL_CTL6, 0x15), 211 + 0, 212 + }; 213 + 214 + /* MS Pull Control Disable: 215 + * MS CD ==> pull up 216 + * others ==> pull down 217 + */ 218 + static const u32 rts5227_ms_pull_ctl_disable_tbl[] = { 219 + RTSX_REG_PAIR(CARD_PULL_CTL5, 0x55), 220 + RTSX_REG_PAIR(CARD_PULL_CTL6, 0x15), 221 + 0, 222 + }; 223 + 224 + void rts5227_init_params(struct rtsx_pcr *pcr) 225 + { 226 + pcr->extra_caps = EXTRA_CAPS_SD_SDR50 | EXTRA_CAPS_SD_SDR104; 227 + pcr->num_slots = 2; 228 + pcr->ops = &rts5227_pcr_ops; 229 + 230 + pcr->sd_pull_ctl_enable_tbl = rts5227_sd_pull_ctl_enable_tbl; 231 + pcr->sd_pull_ctl_disable_tbl = rts5227_sd_pull_ctl_disable_tbl; 232 + pcr->ms_pull_ctl_enable_tbl = rts5227_ms_pull_ctl_enable_tbl; 233 + pcr->ms_pull_ctl_disable_tbl = rts5227_ms_pull_ctl_disable_tbl; 234 + }
+8
drivers/mfd/rts5229.c
··· 119 119 int err; 120 120 121 121 if (voltage == OUTPUT_3V3) { 122 + err = rtsx_pci_write_register(pcr, 123 + SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_D); 124 + if (err < 0) 125 + return err; 122 126 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24); 123 127 if (err < 0) 124 128 return err; 125 129 } else if (voltage == OUTPUT_1V8) { 130 + err = rtsx_pci_write_register(pcr, 131 + SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B); 132 + if (err < 0) 133 + return err; 126 134 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24); 127 135 if (err < 0) 128 136 return err;
+74 -34
drivers/mfd/rtsx_pcr.c
··· 55 55 { PCI_DEVICE(0x10EC, 0x5209), PCI_CLASS_OTHERS << 16, 0xFF0000 }, 56 56 { PCI_DEVICE(0x10EC, 0x5229), PCI_CLASS_OTHERS << 16, 0xFF0000 }, 57 57 { PCI_DEVICE(0x10EC, 0x5289), PCI_CLASS_OTHERS << 16, 0xFF0000 }, 58 + { PCI_DEVICE(0x10EC, 0x5227), PCI_CLASS_OTHERS << 16, 0xFF0000 }, 58 59 { 0, } 59 60 }; 60 61 ··· 326 325 val = ((u64)addr << 32) | ((u64)len << 12) | option; 327 326 328 327 put_unaligned_le64(val, ptr); 329 - ptr++; 330 328 pcr->sgi++; 331 329 } 332 330 ··· 591 591 u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk) 592 592 { 593 593 int err, clk; 594 - u8 N, min_N, max_N, clk_divider; 595 - u8 mcu_cnt, div, max_div; 594 + u8 n, clk_divider, mcu_cnt, div; 596 595 u8 depth[] = { 597 596 [RTSX_SSC_DEPTH_4M] = SSC_DEPTH_4M, 598 597 [RTSX_SSC_DEPTH_2M] = SSC_DEPTH_2M, ··· 615 616 card_clock /= 1000000; 616 617 dev_dbg(&(pcr->pci->dev), "Switch card clock to %dMHz\n", card_clock); 617 618 618 - min_N = 80; 619 - max_N = 208; 620 - max_div = CLK_DIV_8; 621 - 622 619 clk = card_clock; 623 620 if (!initial_mode && double_clk) 624 621 clk = card_clock * 2; ··· 626 631 return 0; 627 632 628 633 if (pcr->ops->conv_clk_and_div_n) 629 - N = (u8)pcr->ops->conv_clk_and_div_n(clk, CLK_TO_DIV_N); 634 + n = (u8)pcr->ops->conv_clk_and_div_n(clk, CLK_TO_DIV_N); 630 635 else 631 - N = (u8)(clk - 2); 632 - if ((clk <= 2) || (N > max_N)) 636 + n = (u8)(clk - 2); 637 + if ((clk <= 2) || (n > MAX_DIV_N_PCR)) 633 638 return -EINVAL; 634 639 635 640 mcu_cnt = (u8)(125/clk + 3); 636 641 if (mcu_cnt > 15) 637 642 mcu_cnt = 15; 638 643 639 - /* Make sure that the SSC clock div_n is equal or greater than min_N */ 644 + /* Make sure that the SSC clock div_n is not less than MIN_DIV_N_PCR */ 640 645 div = CLK_DIV_1; 641 - while ((N < min_N) && (div < max_div)) { 646 + while ((n < MIN_DIV_N_PCR) && (div < CLK_DIV_8)) { 642 647 if (pcr->ops->conv_clk_and_div_n) { 643 - int dbl_clk = pcr->ops->conv_clk_and_div_n(N, 648 + int dbl_clk = pcr->ops->conv_clk_and_div_n(n, 644 649 DIV_N_TO_CLK) * 2; 645 - N = (u8)pcr->ops->conv_clk_and_div_n(dbl_clk, 650 + n = (u8)pcr->ops->conv_clk_and_div_n(dbl_clk, 646 651 CLK_TO_DIV_N); 647 652 } else { 648 - N = (N + 2) * 2 - 2; 653 + n = (n + 2) * 2 - 2; 649 654 } 650 655 div++; 651 656 } 652 - dev_dbg(&(pcr->pci->dev), "N = %d, div = %d\n", N, div); 657 + dev_dbg(&(pcr->pci->dev), "n = %d, div = %d\n", n, div); 653 658 654 659 ssc_depth = depth[ssc_depth]; 655 660 if (double_clk) ··· 666 671 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_CTL1, SSC_RSTB, 0); 667 672 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_CTL2, 668 673 SSC_DEPTH_MASK, ssc_depth); 669 - rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_DIV_N_0, 0xFF, N); 674 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_DIV_N_0, 0xFF, n); 670 675 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_CTL1, SSC_RSTB, SSC_RSTB); 671 676 if (vpclk) { 672 677 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_VPCLK0_CTL, ··· 707 712 return 0; 708 713 } 709 714 EXPORT_SYMBOL_GPL(rtsx_pci_card_power_off); 715 + 716 + int rtsx_pci_card_exclusive_check(struct rtsx_pcr *pcr, int card) 717 + { 718 + unsigned int cd_mask[] = { 719 + [RTSX_SD_CARD] = SD_EXIST, 720 + [RTSX_MS_CARD] = MS_EXIST 721 + }; 722 + 723 + if (!pcr->ms_pmos) { 724 + /* When using single PMOS, accessing card is not permitted 725 + * if the existing card is not the designated one. 726 + */ 727 + if (pcr->card_exist & (~cd_mask[card])) 728 + return -EIO; 729 + } 730 + 731 + return 0; 732 + } 733 + EXPORT_SYMBOL_GPL(rtsx_pci_card_exclusive_check); 710 734 711 735 int rtsx_pci_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) 712 736 { ··· 772 758 struct delayed_work *dwork; 773 759 struct rtsx_pcr *pcr; 774 760 unsigned long flags; 775 - unsigned int card_detect = 0; 761 + unsigned int card_detect = 0, card_inserted, card_removed; 776 762 u32 irq_status; 777 763 778 764 dwork = to_delayed_work(work); ··· 780 766 781 767 dev_dbg(&(pcr->pci->dev), "--> %s\n", __func__); 782 768 769 + mutex_lock(&pcr->pcr_mutex); 783 770 spin_lock_irqsave(&pcr->lock, flags); 784 771 785 772 irq_status = rtsx_pci_readl(pcr, RTSX_BIPR); 786 773 dev_dbg(&(pcr->pci->dev), "irq_status: 0x%08x\n", irq_status); 787 774 788 - if (pcr->card_inserted || pcr->card_removed) { 789 - dev_dbg(&(pcr->pci->dev), 790 - "card_inserted: 0x%x, card_removed: 0x%x\n", 791 - pcr->card_inserted, pcr->card_removed); 792 - 793 - if (pcr->ops->cd_deglitch) 794 - pcr->card_inserted = pcr->ops->cd_deglitch(pcr); 795 - 796 - card_detect = pcr->card_inserted | pcr->card_removed; 797 - pcr->card_inserted = 0; 798 - pcr->card_removed = 0; 799 - } 775 + irq_status &= CARD_EXIST; 776 + card_inserted = pcr->card_inserted & irq_status; 777 + card_removed = pcr->card_removed; 778 + pcr->card_inserted = 0; 779 + pcr->card_removed = 0; 800 780 801 781 spin_unlock_irqrestore(&pcr->lock, flags); 782 + 783 + if (card_inserted || card_removed) { 784 + dev_dbg(&(pcr->pci->dev), 785 + "card_inserted: 0x%x, card_removed: 0x%x\n", 786 + card_inserted, card_removed); 787 + 788 + if (pcr->ops->cd_deglitch) 789 + card_inserted = pcr->ops->cd_deglitch(pcr); 790 + 791 + card_detect = card_inserted | card_removed; 792 + 793 + pcr->card_exist |= card_inserted; 794 + pcr->card_exist &= ~card_removed; 795 + } 796 + 797 + mutex_unlock(&pcr->pcr_mutex); 802 798 803 799 if ((card_detect & SD_EXIST) && pcr->slots[RTSX_SD_CARD].card_event) 804 800 pcr->slots[RTSX_SD_CARD].card_event( ··· 860 836 } 861 837 } 862 838 863 - if (pcr->card_inserted || pcr->card_removed) 864 - schedule_delayed_work(&pcr->carddet_work, 865 - msecs_to_jiffies(200)); 866 - 867 839 if (int_reg & (NEED_COMPLETE_INT | DELINK_INT)) { 868 840 if (int_reg & (TRANS_FAIL_INT | DELINK_INT)) { 869 841 pcr->trans_result = TRANS_RESULT_FAIL; ··· 871 851 complete(pcr->done); 872 852 } 873 853 } 854 + 855 + if (pcr->card_inserted || pcr->card_removed) 856 + schedule_delayed_work(&pcr->carddet_work, 857 + msecs_to_jiffies(200)); 874 858 875 859 spin_unlock(&pcr->lock); 876 860 return IRQ_HANDLED; ··· 998 974 return err; 999 975 } 1000 976 977 + /* No CD interrupt if probing driver with card inserted. 978 + * So we need to initialize pcr->card_exist here. 979 + */ 980 + if (pcr->ops->cd_deglitch) 981 + pcr->card_exist = pcr->ops->cd_deglitch(pcr); 982 + else 983 + pcr->card_exist = rtsx_pci_readl(pcr, RTSX_BIPR) & CARD_EXIST; 984 + 1001 985 return 0; 1002 986 } 1003 987 ··· 1028 996 1029 997 case 0x5289: 1030 998 rtl8411_init_params(pcr); 999 + break; 1000 + 1001 + case 0x5227: 1002 + rts5227_init_params(pcr); 1031 1003 break; 1032 1004 } 1033 1005 ··· 1065 1029 ": Realtek PCI-E Card Reader found at %s [%04x:%04x] (rev %x)\n", 1066 1030 pci_name(pcidev), (int)pcidev->vendor, (int)pcidev->device, 1067 1031 (int)pcidev->revision); 1032 + 1033 + ret = pci_set_dma_mask(pcidev, DMA_BIT_MASK(32)); 1034 + if (ret < 0) 1035 + return ret; 1068 1036 1069 1037 ret = pci_enable_device(pcidev); 1070 1038 if (ret)
+4
drivers/mfd/rtsx_pcr.h
··· 25 25 26 26 #include <linux/mfd/rtsx_pci.h> 27 27 28 + #define MIN_DIV_N_PCR 80 29 + #define MAX_DIV_N_PCR 208 30 + 28 31 void rts5209_init_params(struct rtsx_pcr *pcr); 29 32 void rts5229_init_params(struct rtsx_pcr *pcr); 30 33 void rtl8411_init_params(struct rtsx_pcr *pcr); 34 + void rts5227_init_params(struct rtsx_pcr *pcr); 31 35 32 36 #endif
+1
drivers/mfd/syscon.c
··· 20 20 #include <linux/of_platform.h> 21 21 #include <linux/platform_device.h> 22 22 #include <linux/regmap.h> 23 + #include <linux/mfd/syscon.h> 23 24 24 25 static struct platform_driver syscon_driver; 25 26
+9
drivers/mfd/tps6507x.c
··· 19 19 #include <linux/init.h> 20 20 #include <linux/slab.h> 21 21 #include <linux/i2c.h> 22 + #include <linux/of_device.h> 22 23 #include <linux/mfd/core.h> 23 24 #include <linux/mfd/tps6507x.h> 24 25 ··· 117 116 }; 118 117 MODULE_DEVICE_TABLE(i2c, tps6507x_i2c_id); 119 118 119 + #ifdef CONFIG_OF 120 + static struct of_device_id tps6507x_of_match[] = { 121 + {.compatible = "ti,tps6507x", }, 122 + {}, 123 + }; 124 + MODULE_DEVICE_TABLE(of, tps6507x_of_match); 125 + #endif 120 126 121 127 static struct i2c_driver tps6507x_i2c_driver = { 122 128 .driver = { 123 129 .name = "tps6507x", 124 130 .owner = THIS_MODULE, 131 + .of_match_table = of_match_ptr(tps6507x_of_match), 125 132 }, 126 133 .probe = tps6507x_i2c_probe, 127 134 .remove = tps6507x_i2c_remove,
+20 -27
drivers/mfd/tps65090.c
··· 25 25 #include <linux/i2c.h> 26 26 #include <linux/mfd/core.h> 27 27 #include <linux/mfd/tps65090.h> 28 + #include <linux/of.h> 29 + #include <linux/of_device.h> 28 30 #include <linux/err.h> 29 31 30 32 #define NUM_INT_REG 2 ··· 150 148 .volatile_reg = is_volatile_reg, 151 149 }; 152 150 151 + #ifdef CONFIG_OF 152 + static const struct of_device_id tps65090_of_match[] = { 153 + { .compatible = "ti,tps65090",}, 154 + {}, 155 + }; 156 + MODULE_DEVICE_TABLE(of, tps65090_of_match); 157 + #endif 158 + 153 159 static int tps65090_i2c_probe(struct i2c_client *client, 154 160 const struct i2c_device_id *id) 155 161 { 156 162 struct tps65090_platform_data *pdata = client->dev.platform_data; 163 + int irq_base = 0; 157 164 struct tps65090 *tps65090; 158 165 int ret; 159 166 160 - if (!pdata) { 161 - dev_err(&client->dev, "tps65090 requires platform data\n"); 167 + if (!pdata && !client->dev.of_node) { 168 + dev_err(&client->dev, 169 + "tps65090 requires platform data or of_node\n"); 162 170 return -EINVAL; 163 171 } 172 + 173 + if (pdata) 174 + irq_base = pdata->irq_base; 164 175 165 176 tps65090 = devm_kzalloc(&client->dev, sizeof(*tps65090), GFP_KERNEL); 166 177 if (!tps65090) { ··· 193 178 194 179 if (client->irq) { 195 180 ret = regmap_add_irq_chip(tps65090->rmap, client->irq, 196 - IRQF_ONESHOT | IRQF_TRIGGER_LOW, pdata->irq_base, 181 + IRQF_ONESHOT | IRQF_TRIGGER_LOW, irq_base, 197 182 &tps65090_irq_chip, &tps65090->irq_data); 198 183 if (ret) { 199 184 dev_err(&client->dev, ··· 204 189 205 190 ret = mfd_add_devices(tps65090->dev, -1, tps65090s, 206 191 ARRAY_SIZE(tps65090s), NULL, 207 - regmap_irq_chip_get_base(tps65090->irq_data), NULL); 192 + 0, regmap_irq_get_domain(tps65090->irq_data)); 208 193 if (ret) { 209 194 dev_err(&client->dev, "add mfd devices failed with err: %d\n", 210 195 ret); ··· 230 215 return 0; 231 216 } 232 217 233 - #ifdef CONFIG_PM_SLEEP 234 - static int tps65090_suspend(struct device *dev) 235 - { 236 - struct i2c_client *client = to_i2c_client(dev); 237 - if (client->irq) 238 - disable_irq(client->irq); 239 - return 0; 240 - } 241 - 242 - static int tps65090_resume(struct device *dev) 243 - { 244 - struct i2c_client *client = to_i2c_client(dev); 245 - if (client->irq) 246 - enable_irq(client->irq); 247 - return 0; 248 - } 249 - #endif 250 - 251 - static const struct dev_pm_ops tps65090_pm_ops = { 252 - SET_SYSTEM_SLEEP_PM_OPS(tps65090_suspend, tps65090_resume) 253 - }; 254 - 255 218 static const struct i2c_device_id tps65090_id_table[] = { 256 219 { "tps65090", 0 }, 257 220 { }, ··· 240 247 .driver = { 241 248 .name = "tps65090", 242 249 .owner = THIS_MODULE, 243 - .pm = &tps65090_pm_ops, 250 + .of_match_table = of_match_ptr(tps65090_of_match), 244 251 }, 245 252 .probe = tps65090_i2c_probe, 246 253 .remove = tps65090_i2c_remove,
+161 -203
drivers/mfd/twl-core.c
··· 66 66 67 67 /* Triton Core internal information (BEGIN) */ 68 68 69 - #define TWL_NUM_SLAVES 4 70 - 71 - #define SUB_CHIP_ID0 0 72 - #define SUB_CHIP_ID1 1 73 - #define SUB_CHIP_ID2 2 74 - #define SUB_CHIP_ID3 3 75 - #define SUB_CHIP_ID_INVAL 0xff 76 - 77 - #define TWL_MODULE_LAST TWL4030_MODULE_LAST 78 - 79 69 /* Base Address defns for twl4030_map[] */ 80 70 81 71 /* subchip/slave 0 - USB ID */ ··· 84 94 #define TWL4030_BASEADD_MADC 0x0000 85 95 #define TWL4030_BASEADD_MAIN_CHARGE 0x0074 86 96 #define TWL4030_BASEADD_PRECHARGE 0x00AA 87 - #define TWL4030_BASEADD_PWM0 0x00F8 88 - #define TWL4030_BASEADD_PWM1 0x00FB 89 - #define TWL4030_BASEADD_PWMA 0x00EF 90 - #define TWL4030_BASEADD_PWMB 0x00F1 97 + #define TWL4030_BASEADD_PWM 0x00F8 91 98 #define TWL4030_BASEADD_KEYPAD 0x00D2 92 99 93 100 #define TWL5031_BASEADD_ACCESSORY 0x0074 /* Replaces Main Charge */ ··· 104 117 105 118 /* subchip/slave 0 0x48 - POWER */ 106 119 #define TWL6030_BASEADD_RTC 0x0000 107 - #define TWL6030_BASEADD_MEM 0x0017 120 + #define TWL6030_BASEADD_SECURED_REG 0x0017 108 121 #define TWL6030_BASEADD_PM_MASTER 0x001F 109 122 #define TWL6030_BASEADD_PM_SLAVE_MISC 0x0030 /* PM_RECEIVER */ 110 123 #define TWL6030_BASEADD_PM_MISC 0x00E2 ··· 119 132 #define TWL6030_BASEADD_PIH 0x00D0 120 133 #define TWL6030_BASEADD_CHARGER 0x00E0 121 134 #define TWL6025_BASEADD_CHARGER 0x00DA 135 + #define TWL6030_BASEADD_LED 0x00F4 122 136 123 137 /* subchip/slave 2 0x4A - DFT */ 124 138 #define TWL6030_BASEADD_DIEID 0x00C0 ··· 141 153 142 154 /*----------------------------------------------------------------------*/ 143 155 144 - /* is driver active, bound to a chip? */ 145 - static bool inuse; 146 - 147 - /* TWL IDCODE Register value */ 148 - static u32 twl_idcode; 149 - 150 - static unsigned int twl_id; 151 - unsigned int twl_rev(void) 152 - { 153 - return twl_id; 154 - } 155 - EXPORT_SYMBOL(twl_rev); 156 - 157 156 /* Structure for each TWL4030/TWL6030 Slave */ 158 157 struct twl_client { 159 158 struct i2c_client *client; 160 159 struct regmap *regmap; 161 160 }; 162 161 163 - static struct twl_client twl_modules[TWL_NUM_SLAVES]; 164 - 165 162 /* mapping the module id to slave id and base address */ 166 163 struct twl_mapping { 167 164 unsigned char sid; /* Slave ID */ 168 165 unsigned char base; /* base address */ 169 166 }; 170 - static struct twl_mapping *twl_map; 167 + 168 + struct twl_private { 169 + bool ready; /* The core driver is ready to be used */ 170 + u32 twl_idcode; /* TWL IDCODE Register value */ 171 + unsigned int twl_id; 172 + 173 + struct twl_mapping *twl_map; 174 + struct twl_client *twl_modules; 175 + }; 176 + 177 + static struct twl_private *twl_priv; 171 178 172 179 static struct twl_mapping twl4030_map[] = { 173 180 /* ··· 171 188 * so they continue to match the order in this table. 172 189 */ 173 190 191 + /* Common IPs */ 174 192 { 0, TWL4030_BASEADD_USB }, 193 + { 1, TWL4030_BASEADD_PIH }, 194 + { 2, TWL4030_BASEADD_MAIN_CHARGE }, 195 + { 3, TWL4030_BASEADD_PM_MASTER }, 196 + { 3, TWL4030_BASEADD_PM_RECEIVER }, 197 + 198 + { 3, TWL4030_BASEADD_RTC }, 199 + { 2, TWL4030_BASEADD_PWM }, 200 + { 2, TWL4030_BASEADD_LED }, 201 + { 3, TWL4030_BASEADD_SECURED_REG }, 202 + 203 + /* TWL4030 specific IPs */ 175 204 { 1, TWL4030_BASEADD_AUDIO_VOICE }, 176 205 { 1, TWL4030_BASEADD_GPIO }, 177 206 { 1, TWL4030_BASEADD_INTBR }, 178 - { 1, TWL4030_BASEADD_PIH }, 179 - 180 207 { 1, TWL4030_BASEADD_TEST }, 181 208 { 2, TWL4030_BASEADD_KEYPAD }, 209 + 182 210 { 2, TWL4030_BASEADD_MADC }, 183 211 { 2, TWL4030_BASEADD_INTERRUPTS }, 184 - { 2, TWL4030_BASEADD_LED }, 185 - 186 - { 2, TWL4030_BASEADD_MAIN_CHARGE }, 187 212 { 2, TWL4030_BASEADD_PRECHARGE }, 188 - { 2, TWL4030_BASEADD_PWM0 }, 189 - { 2, TWL4030_BASEADD_PWM1 }, 190 - { 2, TWL4030_BASEADD_PWMA }, 191 - 192 - { 2, TWL4030_BASEADD_PWMB }, 193 - { 2, TWL5031_BASEADD_ACCESSORY }, 194 - { 2, TWL5031_BASEADD_INTERRUPTS }, 195 213 { 3, TWL4030_BASEADD_BACKUP }, 196 214 { 3, TWL4030_BASEADD_INT }, 197 215 198 - { 3, TWL4030_BASEADD_PM_MASTER }, 199 - { 3, TWL4030_BASEADD_PM_RECEIVER }, 200 - { 3, TWL4030_BASEADD_RTC }, 201 - { 3, TWL4030_BASEADD_SECURED_REG }, 216 + { 2, TWL5031_BASEADD_ACCESSORY }, 217 + { 2, TWL5031_BASEADD_INTERRUPTS }, 202 218 }; 203 219 204 220 static struct regmap_config twl4030_regmap_config[4] = { ··· 233 251 * <linux/i2c/twl.h> defines for TWL4030_MODULE_* 234 252 * so they continue to match the order in this table. 235 253 */ 236 - { SUB_CHIP_ID1, TWL6030_BASEADD_USB }, 237 - { SUB_CHIP_ID_INVAL, TWL6030_BASEADD_AUDIO }, 238 - { SUB_CHIP_ID2, TWL6030_BASEADD_DIEID }, 239 - { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 240 - { SUB_CHIP_ID1, TWL6030_BASEADD_PIH }, 241 254 242 - { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 243 - { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 244 - { SUB_CHIP_ID1, TWL6030_BASEADD_GPADC_CTRL }, 245 - { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 246 - { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 255 + /* Common IPs */ 256 + { 1, TWL6030_BASEADD_USB }, 257 + { 1, TWL6030_BASEADD_PIH }, 258 + { 1, TWL6030_BASEADD_CHARGER }, 259 + { 0, TWL6030_BASEADD_PM_MASTER }, 260 + { 0, TWL6030_BASEADD_PM_SLAVE_MISC }, 247 261 248 - { SUB_CHIP_ID1, TWL6030_BASEADD_CHARGER }, 249 - { SUB_CHIP_ID1, TWL6030_BASEADD_GASGAUGE }, 250 - { SUB_CHIP_ID1, TWL6030_BASEADD_PWM }, 251 - { SUB_CHIP_ID0, TWL6030_BASEADD_ZERO }, 252 - { SUB_CHIP_ID1, TWL6030_BASEADD_ZERO }, 262 + { 0, TWL6030_BASEADD_RTC }, 263 + { 1, TWL6030_BASEADD_PWM }, 264 + { 1, TWL6030_BASEADD_LED }, 265 + { 0, TWL6030_BASEADD_SECURED_REG }, 253 266 254 - { SUB_CHIP_ID2, TWL6030_BASEADD_ZERO }, 255 - { SUB_CHIP_ID2, TWL6030_BASEADD_ZERO }, 256 - { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 257 - { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 258 - { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 259 - 260 - { SUB_CHIP_ID0, TWL6030_BASEADD_PM_MASTER }, 261 - { SUB_CHIP_ID0, TWL6030_BASEADD_PM_SLAVE_MISC }, 262 - { SUB_CHIP_ID0, TWL6030_BASEADD_RTC }, 263 - { SUB_CHIP_ID0, TWL6030_BASEADD_MEM }, 264 - { SUB_CHIP_ID1, TWL6025_BASEADD_CHARGER }, 267 + /* TWL6030 specific IPs */ 268 + { 0, TWL6030_BASEADD_ZERO }, 269 + { 1, TWL6030_BASEADD_ZERO }, 270 + { 2, TWL6030_BASEADD_ZERO }, 271 + { 1, TWL6030_BASEADD_GPADC_CTRL }, 272 + { 1, TWL6030_BASEADD_GASGAUGE }, 265 273 }; 266 274 267 275 static struct regmap_config twl6030_regmap_config[3] = { ··· 277 305 278 306 /*----------------------------------------------------------------------*/ 279 307 308 + static inline int twl_get_num_slaves(void) 309 + { 310 + if (twl_class_is_4030()) 311 + return 4; /* TWL4030 class have four slave address */ 312 + else 313 + return 3; /* TWL6030 class have three slave address */ 314 + } 315 + 316 + static inline int twl_get_last_module(void) 317 + { 318 + if (twl_class_is_4030()) 319 + return TWL4030_MODULE_LAST; 320 + else 321 + return TWL6030_MODULE_LAST; 322 + } 323 + 280 324 /* Exported Functions */ 325 + 326 + unsigned int twl_rev(void) 327 + { 328 + return twl_priv ? twl_priv->twl_id : 0; 329 + } 330 + EXPORT_SYMBOL(twl_rev); 281 331 282 332 /** 283 333 * twl_i2c_write - Writes a n bit register in TWL4030/TWL5030/TWL60X0 ··· 307 313 * @value: an array of num_bytes+1 containing data to write 308 314 * @reg: register address (just offset will do) 309 315 * @num_bytes: number of bytes to transfer 310 - * 311 - * IMPORTANT: for 'value' parameter: Allocate value num_bytes+1 and 312 - * valid data starts at Offset 1. 313 316 * 314 317 * Returns the result of operation - 0 is success 315 318 */ ··· 316 325 int sid; 317 326 struct twl_client *twl; 318 327 319 - if (unlikely(mod_no >= TWL_MODULE_LAST)) { 320 - pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 321 - return -EPERM; 322 - } 323 - if (unlikely(!inuse)) { 328 + if (unlikely(!twl_priv || !twl_priv->ready)) { 324 329 pr_err("%s: not initialized\n", DRIVER_NAME); 325 330 return -EPERM; 326 331 } 327 - sid = twl_map[mod_no].sid; 328 - if (unlikely(sid == SUB_CHIP_ID_INVAL)) { 329 - pr_err("%s: module %d is not part of the pmic\n", 330 - DRIVER_NAME, mod_no); 331 - return -EINVAL; 332 + if (unlikely(mod_no >= twl_get_last_module())) { 333 + pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 334 + return -EPERM; 332 335 } 333 - twl = &twl_modules[sid]; 334 336 335 - ret = regmap_bulk_write(twl->regmap, twl_map[mod_no].base + reg, 336 - value, num_bytes); 337 + sid = twl_priv->twl_map[mod_no].sid; 338 + twl = &twl_priv->twl_modules[sid]; 339 + 340 + ret = regmap_bulk_write(twl->regmap, 341 + twl_priv->twl_map[mod_no].base + reg, value, 342 + num_bytes); 337 343 338 344 if (ret) 339 345 pr_err("%s: Write failed (mod %d, reg 0x%02x count %d)\n", ··· 355 367 int sid; 356 368 struct twl_client *twl; 357 369 358 - if (unlikely(mod_no >= TWL_MODULE_LAST)) { 359 - pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 360 - return -EPERM; 361 - } 362 - if (unlikely(!inuse)) { 370 + if (unlikely(!twl_priv || !twl_priv->ready)) { 363 371 pr_err("%s: not initialized\n", DRIVER_NAME); 364 372 return -EPERM; 365 373 } 366 - sid = twl_map[mod_no].sid; 367 - if (unlikely(sid == SUB_CHIP_ID_INVAL)) { 368 - pr_err("%s: module %d is not part of the pmic\n", 369 - DRIVER_NAME, mod_no); 370 - return -EINVAL; 374 + if (unlikely(mod_no >= twl_get_last_module())) { 375 + pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 376 + return -EPERM; 371 377 } 372 - twl = &twl_modules[sid]; 373 378 374 - ret = regmap_bulk_read(twl->regmap, twl_map[mod_no].base + reg, 375 - value, num_bytes); 379 + sid = twl_priv->twl_map[mod_no].sid; 380 + twl = &twl_priv->twl_modules[sid]; 381 + 382 + ret = regmap_bulk_read(twl->regmap, 383 + twl_priv->twl_map[mod_no].base + reg, value, 384 + num_bytes); 376 385 377 386 if (ret) 378 387 pr_err("%s: Read failed (mod %d, reg 0x%02x count %d)\n", ··· 378 393 return ret; 379 394 } 380 395 EXPORT_SYMBOL(twl_i2c_read); 381 - 382 - /** 383 - * twl_i2c_write_u8 - Writes a 8 bit register in TWL4030/TWL5030/TWL60X0 384 - * @mod_no: module number 385 - * @value: the value to be written 8 bit 386 - * @reg: register address (just offset will do) 387 - * 388 - * Returns result of operation - 0 is success 389 - */ 390 - int twl_i2c_write_u8(u8 mod_no, u8 value, u8 reg) 391 - { 392 - return twl_i2c_write(mod_no, &value, reg, 1); 393 - } 394 - EXPORT_SYMBOL(twl_i2c_write_u8); 395 - 396 - /** 397 - * twl_i2c_read_u8 - Reads a 8 bit register from TWL4030/TWL5030/TWL60X0 398 - * @mod_no: module number 399 - * @value: the value read 8 bit 400 - * @reg: register address (just offset will do) 401 - * 402 - * Returns result of operation - 0 is success 403 - */ 404 - int twl_i2c_read_u8(u8 mod_no, u8 *value, u8 reg) 405 - { 406 - return twl_i2c_read(mod_no, value, reg, 1); 407 - } 408 - EXPORT_SYMBOL(twl_i2c_read_u8); 409 396 410 397 /*----------------------------------------------------------------------*/ 411 398 ··· 397 440 goto fail; 398 441 } 399 442 400 - err = twl_i2c_read(TWL4030_MODULE_INTBR, (u8 *)(&twl_idcode), 443 + err = twl_i2c_read(TWL4030_MODULE_INTBR, (u8 *)(&twl_priv->twl_idcode), 401 444 REG_IDCODE_7_0, 4); 402 445 if (err) { 403 446 pr_err("TWL4030: unable to read IDCODE -%d\n", err); ··· 418 461 */ 419 462 int twl_get_type(void) 420 463 { 421 - return TWL_SIL_TYPE(twl_idcode); 464 + return TWL_SIL_TYPE(twl_priv->twl_idcode); 422 465 } 423 466 EXPORT_SYMBOL_GPL(twl_get_type); 424 467 ··· 429 472 */ 430 473 int twl_get_version(void) 431 474 { 432 - return TWL_SIL_REV(twl_idcode); 475 + return TWL_SIL_REV(twl_priv->twl_idcode); 433 476 } 434 477 EXPORT_SYMBOL_GPL(twl_get_version); 435 478 ··· 466 509 EXPORT_SYMBOL_GPL(twl_get_hfclk_rate); 467 510 468 511 static struct device * 469 - add_numbered_child(unsigned chip, const char *name, int num, 512 + add_numbered_child(unsigned mod_no, const char *name, int num, 470 513 void *pdata, unsigned pdata_len, 471 514 bool can_wakeup, int irq0, int irq1) 472 515 { 473 516 struct platform_device *pdev; 474 - struct twl_client *twl = &twl_modules[chip]; 475 - int status; 517 + struct twl_client *twl; 518 + int status, sid; 519 + 520 + if (unlikely(mod_no >= twl_get_last_module())) { 521 + pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 522 + return ERR_PTR(-EPERM); 523 + } 524 + sid = twl_priv->twl_map[mod_no].sid; 525 + twl = &twl_priv->twl_modules[sid]; 476 526 477 527 pdev = platform_device_alloc(name, num); 478 528 if (!pdev) { ··· 524 560 return &pdev->dev; 525 561 } 526 562 527 - static inline struct device *add_child(unsigned chip, const char *name, 563 + static inline struct device *add_child(unsigned mod_no, const char *name, 528 564 void *pdata, unsigned pdata_len, 529 565 bool can_wakeup, int irq0, int irq1) 530 566 { 531 - return add_numbered_child(chip, name, -1, pdata, pdata_len, 567 + return add_numbered_child(mod_no, name, -1, pdata, pdata_len, 532 568 can_wakeup, irq0, irq1); 533 569 } 534 570 ··· 537 573 struct regulator_consumer_supply *consumers, 538 574 unsigned num_consumers, unsigned long features) 539 575 { 540 - unsigned sub_chip_id; 541 576 struct twl_regulator_driver_data drv_data; 542 577 543 578 /* regulator framework demands init_data ... */ ··· 563 600 } 564 601 565 602 /* NOTE: we currently ignore regulator IRQs, e.g. for short circuits */ 566 - sub_chip_id = twl_map[TWL_MODULE_PM_MASTER].sid; 567 - return add_numbered_child(sub_chip_id, "twl_reg", num, 603 + return add_numbered_child(TWL_MODULE_PM_MASTER, "twl_reg", num, 568 604 pdata, sizeof(*pdata), false, 0, 0); 569 605 } 570 606 ··· 585 623 unsigned long features) 586 624 { 587 625 struct device *child; 588 - unsigned sub_chip_id; 589 626 590 627 if (IS_ENABLED(CONFIG_GPIO_TWL4030) && pdata->gpio) { 591 - child = add_child(SUB_CHIP_ID1, "twl4030_gpio", 628 + child = add_child(TWL4030_MODULE_GPIO, "twl4030_gpio", 592 629 pdata->gpio, sizeof(*pdata->gpio), 593 630 false, irq_base + GPIO_INTR_OFFSET, 0); 594 631 if (IS_ERR(child)) ··· 595 634 } 596 635 597 636 if (IS_ENABLED(CONFIG_KEYBOARD_TWL4030) && pdata->keypad) { 598 - child = add_child(SUB_CHIP_ID2, "twl4030_keypad", 637 + child = add_child(TWL4030_MODULE_KEYPAD, "twl4030_keypad", 599 638 pdata->keypad, sizeof(*pdata->keypad), 600 639 true, irq_base + KEYPAD_INTR_OFFSET, 0); 601 640 if (IS_ERR(child)) ··· 604 643 605 644 if (IS_ENABLED(CONFIG_TWL4030_MADC) && pdata->madc && 606 645 twl_class_is_4030()) { 607 - child = add_child(SUB_CHIP_ID2, "twl4030_madc", 646 + child = add_child(TWL4030_MODULE_MADC, "twl4030_madc", 608 647 pdata->madc, sizeof(*pdata->madc), 609 648 true, irq_base + MADC_INTR_OFFSET, 0); 610 649 if (IS_ERR(child)) ··· 619 658 * Eventually, Linux might become more aware of such 620 659 * HW security concerns, and "least privilege". 621 660 */ 622 - sub_chip_id = twl_map[TWL_MODULE_RTC].sid; 623 - child = add_child(sub_chip_id, "twl_rtc", NULL, 0, 661 + child = add_child(TWL_MODULE_RTC, "twl_rtc", NULL, 0, 624 662 true, irq_base + RTC_INTR_OFFSET, 0); 625 663 if (IS_ERR(child)) 626 664 return PTR_ERR(child); 627 665 } 628 666 629 667 if (IS_ENABLED(CONFIG_PWM_TWL)) { 630 - child = add_child(SUB_CHIP_ID1, "twl-pwm", NULL, 0, 668 + child = add_child(TWL_MODULE_PWM, "twl-pwm", NULL, 0, 631 669 false, 0, 0); 632 670 if (IS_ERR(child)) 633 671 return PTR_ERR(child); 634 672 } 635 673 636 674 if (IS_ENABLED(CONFIG_PWM_TWL_LED)) { 637 - child = add_child(SUB_CHIP_ID1, "twl-pwmled", NULL, 0, 675 + child = add_child(TWL_MODULE_LED, "twl-pwmled", NULL, 0, 638 676 false, 0, 0); 639 677 if (IS_ERR(child)) 640 678 return PTR_ERR(child); ··· 685 725 686 726 } 687 727 688 - child = add_child(SUB_CHIP_ID0, "twl4030_usb", 728 + child = add_child(TWL_MODULE_USB, "twl4030_usb", 689 729 pdata->usb, sizeof(*pdata->usb), true, 690 730 /* irq0 = USB_PRES, irq1 = USB */ 691 731 irq_base + USB_PRES_INTR_OFFSET, ··· 734 774 735 775 pdata->usb->features = features; 736 776 737 - child = add_child(SUB_CHIP_ID0, "twl6030_usb", 777 + child = add_child(TWL_MODULE_USB, "twl6030_usb", 738 778 pdata->usb, sizeof(*pdata->usb), true, 739 779 /* irq1 = VBUS_PRES, irq0 = USB ID */ 740 780 irq_base + USBOTG_INTR_OFFSET, ··· 759 799 } 760 800 761 801 if (IS_ENABLED(CONFIG_TWL4030_WATCHDOG) && twl_class_is_4030()) { 762 - child = add_child(SUB_CHIP_ID3, "twl4030_wdt", NULL, 0, 763 - false, 0, 0); 802 + child = add_child(TWL_MODULE_PM_RECEIVER, "twl4030_wdt", NULL, 803 + 0, false, 0, 0); 764 804 if (IS_ERR(child)) 765 805 return PTR_ERR(child); 766 806 } 767 807 768 808 if (IS_ENABLED(CONFIG_INPUT_TWL4030_PWRBUTTON) && twl_class_is_4030()) { 769 - child = add_child(SUB_CHIP_ID3, "twl4030_pwrbutton", NULL, 0, 770 - true, irq_base + 8 + 0, 0); 809 + child = add_child(TWL_MODULE_PM_MASTER, "twl4030_pwrbutton", 810 + NULL, 0, true, irq_base + 8 + 0, 0); 771 811 if (IS_ERR(child)) 772 812 return PTR_ERR(child); 773 813 } 774 814 775 815 if (IS_ENABLED(CONFIG_MFD_TWL4030_AUDIO) && pdata->audio && 776 816 twl_class_is_4030()) { 777 - child = add_child(SUB_CHIP_ID1, "twl4030-audio", 817 + child = add_child(TWL4030_MODULE_AUDIO_VOICE, "twl4030-audio", 778 818 pdata->audio, sizeof(*pdata->audio), 779 819 false, 0, 0); 780 820 if (IS_ERR(child)) ··· 1014 1054 1015 1055 if (IS_ENABLED(CONFIG_CHARGER_TWL4030) && pdata->bci && 1016 1056 !(features & (TPS_SUBSET | TWL5031))) { 1017 - child = add_child(SUB_CHIP_ID3, "twl4030_bci", 1057 + child = add_child(TWL_MODULE_MAIN_CHARGE, "twl4030_bci", 1018 1058 pdata->bci, sizeof(*pdata->bci), false, 1019 1059 /* irq0 = CHG_PRES, irq1 = BCI */ 1020 1060 irq_base + BCI_PRES_INTR_OFFSET, ··· 1105 1145 unsigned i, num_slaves; 1106 1146 int status; 1107 1147 1108 - if (twl_class_is_4030()) { 1148 + if (twl_class_is_4030()) 1109 1149 status = twl4030_exit_irq(); 1110 - num_slaves = TWL_NUM_SLAVES; 1111 - } else { 1150 + else 1112 1151 status = twl6030_exit_irq(); 1113 - num_slaves = TWL_NUM_SLAVES - 1; 1114 - } 1115 1152 1116 1153 if (status < 0) 1117 1154 return status; 1118 1155 1156 + num_slaves = twl_get_num_slaves(); 1119 1157 for (i = 0; i < num_slaves; i++) { 1120 - struct twl_client *twl = &twl_modules[i]; 1158 + struct twl_client *twl = &twl_priv->twl_modules[i]; 1121 1159 1122 1160 if (twl->client && twl->client != client) 1123 1161 i2c_unregister_device(twl->client); 1124 - twl_modules[i].client = NULL; 1162 + twl->client = NULL; 1125 1163 } 1126 - inuse = false; 1164 + twl_priv->ready = false; 1127 1165 return 0; 1128 1166 } 1129 1167 ··· 1137 1179 int status; 1138 1180 unsigned i, num_slaves; 1139 1181 1182 + if (!node && !pdata) { 1183 + dev_err(&client->dev, "no platform data\n"); 1184 + return -EINVAL; 1185 + } 1186 + 1187 + if (twl_priv) { 1188 + dev_dbg(&client->dev, "only one instance of %s allowed\n", 1189 + DRIVER_NAME); 1190 + return -EBUSY; 1191 + } 1192 + 1140 1193 pdev = platform_device_alloc(DRIVER_NAME, -1); 1141 1194 if (!pdev) { 1142 1195 dev_err(&client->dev, "can't alloc pdev\n"); ··· 1160 1191 return status; 1161 1192 } 1162 1193 1163 - if (node && !pdata) { 1164 - /* 1165 - * XXX: Temporary pdata until the information is correctly 1166 - * retrieved by every TWL modules from DT. 1167 - */ 1168 - pdata = devm_kzalloc(&client->dev, 1169 - sizeof(struct twl4030_platform_data), 1170 - GFP_KERNEL); 1171 - if (!pdata) { 1172 - status = -ENOMEM; 1173 - goto free; 1174 - } 1175 - } 1176 - 1177 - if (!pdata) { 1178 - dev_dbg(&client->dev, "no platform data?\n"); 1179 - status = -EINVAL; 1180 - goto free; 1181 - } 1182 - 1183 - platform_set_drvdata(pdev, pdata); 1184 - 1185 1194 if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) { 1186 1195 dev_dbg(&client->dev, "can't talk I2C?\n"); 1187 1196 status = -EIO; 1188 1197 goto free; 1189 1198 } 1190 1199 1191 - if (inuse) { 1192 - dev_dbg(&client->dev, "driver is already in use\n"); 1193 - status = -EBUSY; 1200 + twl_priv = devm_kzalloc(&client->dev, sizeof(struct twl_private), 1201 + GFP_KERNEL); 1202 + if (!twl_priv) { 1203 + status = -ENOMEM; 1194 1204 goto free; 1195 1205 } 1196 1206 1197 1207 if ((id->driver_data) & TWL6030_CLASS) { 1198 - twl_id = TWL6030_CLASS_ID; 1199 - twl_map = &twl6030_map[0]; 1208 + twl_priv->twl_id = TWL6030_CLASS_ID; 1209 + twl_priv->twl_map = &twl6030_map[0]; 1210 + /* The charger base address is different in twl6025 */ 1211 + if ((id->driver_data) & TWL6025_SUBCLASS) 1212 + twl_priv->twl_map[TWL_MODULE_MAIN_CHARGE].base = 1213 + TWL6025_BASEADD_CHARGER; 1200 1214 twl_regmap_config = twl6030_regmap_config; 1201 - num_slaves = TWL_NUM_SLAVES - 1; 1202 1215 } else { 1203 - twl_id = TWL4030_CLASS_ID; 1204 - twl_map = &twl4030_map[0]; 1216 + twl_priv->twl_id = TWL4030_CLASS_ID; 1217 + twl_priv->twl_map = &twl4030_map[0]; 1205 1218 twl_regmap_config = twl4030_regmap_config; 1206 - num_slaves = TWL_NUM_SLAVES; 1219 + } 1220 + 1221 + num_slaves = twl_get_num_slaves(); 1222 + twl_priv->twl_modules = devm_kzalloc(&client->dev, 1223 + sizeof(struct twl_client) * num_slaves, 1224 + GFP_KERNEL); 1225 + if (!twl_priv->twl_modules) { 1226 + status = -ENOMEM; 1227 + goto free; 1207 1228 } 1208 1229 1209 1230 for (i = 0; i < num_slaves; i++) { 1210 - struct twl_client *twl = &twl_modules[i]; 1231 + struct twl_client *twl = &twl_priv->twl_modules[i]; 1211 1232 1212 1233 if (i == 0) { 1213 1234 twl->client = client; ··· 1223 1264 } 1224 1265 } 1225 1266 1226 - inuse = true; 1267 + twl_priv->ready = true; 1227 1268 1228 1269 /* setup clock framework */ 1229 - clocks_init(&pdev->dev, pdata->clock); 1270 + clocks_init(&pdev->dev, pdata ? pdata->clock : NULL); 1230 1271 1231 1272 /* read TWL IDCODE Register */ 1232 - if (twl_id == TWL4030_CLASS_ID) { 1273 + if (twl_class_is_4030()) { 1233 1274 status = twl_read_idcode_register(); 1234 1275 WARN(status < 0, "Error: reading twl_idcode register value\n"); 1235 1276 } 1236 1277 1237 1278 /* load power event scripts */ 1238 - if (IS_ENABLED(CONFIG_TWL4030_POWER) && pdata->power) 1279 + if (IS_ENABLED(CONFIG_TWL4030_POWER) && pdata && pdata->power) 1239 1280 twl4030_power_init(pdata->power); 1240 1281 1241 1282 /* Maybe init the T2 Interrupt subsystem */ ··· 1267 1308 twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1); 1268 1309 } 1269 1310 1270 - status = -ENODEV; 1271 1311 if (node) 1272 1312 status = of_platform_populate(node, NULL, NULL, &client->dev); 1273 - if (status) 1313 + else 1274 1314 status = add_children(pdata, irq_base, id->driver_data); 1275 1315 1276 1316 fail:
+61 -22
drivers/mfd/vexpress-sysreg.c
··· 49 49 #define SYS_ID_HBI_SHIFT 16 50 50 #define SYS_PROCIDx_HBI_SHIFT 0 51 51 52 + #define SYS_LED_LED(n) (1 << (n)) 53 + 52 54 #define SYS_MCI_CARDIN (1 << 0) 53 55 #define SYS_MCI_WPROT (1 << 1) 54 56 ··· 338 336 339 337 void __init vexpress_sysreg_of_early_init(void) 340 338 { 341 - struct device_node *node = of_find_compatible_node(NULL, NULL, 342 - "arm,vexpress-sysreg"); 339 + struct device_node *node; 343 340 341 + if (vexpress_sysreg_base) 342 + return; 343 + 344 + node = of_find_compatible_node(NULL, NULL, "arm,vexpress-sysreg"); 344 345 if (node) { 345 346 vexpress_sysreg_base = of_iomap(node, 0); 346 347 vexpress_sysreg_setup(node); 347 - } else { 348 - pr_info("vexpress-sysreg: No Device Tree node found."); 349 348 } 350 349 } 351 350 351 + 352 + #define VEXPRESS_SYSREG_GPIO(_name, _reg, _value) \ 353 + [VEXPRESS_GPIO_##_name] = { \ 354 + .reg = _reg, \ 355 + .value = _reg##_##_value, \ 356 + } 352 357 353 358 static struct vexpress_sysreg_gpio { 354 359 unsigned long reg; 355 360 u32 value; 356 361 } vexpress_sysreg_gpios[] = { 357 - [VEXPRESS_GPIO_MMC_CARDIN] = { 358 - .reg = SYS_MCI, 359 - .value = SYS_MCI_CARDIN, 360 - }, 361 - [VEXPRESS_GPIO_MMC_WPROT] = { 362 - .reg = SYS_MCI, 363 - .value = SYS_MCI_WPROT, 364 - }, 365 - [VEXPRESS_GPIO_FLASH_WPn] = { 366 - .reg = SYS_FLASH, 367 - .value = SYS_FLASH_WPn, 368 - }, 362 + VEXPRESS_SYSREG_GPIO(MMC_CARDIN, SYS_MCI, CARDIN), 363 + VEXPRESS_SYSREG_GPIO(MMC_WPROT, SYS_MCI, WPROT), 364 + VEXPRESS_SYSREG_GPIO(FLASH_WPn, SYS_FLASH, WPn), 365 + VEXPRESS_SYSREG_GPIO(LED0, SYS_LED, LED(0)), 366 + VEXPRESS_SYSREG_GPIO(LED1, SYS_LED, LED(1)), 367 + VEXPRESS_SYSREG_GPIO(LED2, SYS_LED, LED(2)), 368 + VEXPRESS_SYSREG_GPIO(LED3, SYS_LED, LED(3)), 369 + VEXPRESS_SYSREG_GPIO(LED4, SYS_LED, LED(4)), 370 + VEXPRESS_SYSREG_GPIO(LED5, SYS_LED, LED(5)), 371 + VEXPRESS_SYSREG_GPIO(LED6, SYS_LED, LED(6)), 372 + VEXPRESS_SYSREG_GPIO(LED7, SYS_LED, LED(7)), 369 373 }; 370 374 371 375 static int vexpress_sysreg_gpio_direction_input(struct gpio_chip *chip, 372 376 unsigned offset) 373 - { 374 - return 0; 375 - } 376 - 377 - static int vexpress_sysreg_gpio_direction_output(struct gpio_chip *chip, 378 - unsigned offset, int value) 379 377 { 380 378 return 0; 381 379 } ··· 403 401 writel(reg_value, vexpress_sysreg_base + gpio->reg); 404 402 } 405 403 404 + static int vexpress_sysreg_gpio_direction_output(struct gpio_chip *chip, 405 + unsigned offset, int value) 406 + { 407 + vexpress_sysreg_gpio_set(chip, offset, value); 408 + 409 + return 0; 410 + } 411 + 406 412 static struct gpio_chip vexpress_sysreg_gpio_chip = { 407 413 .label = "vexpress-sysreg", 408 414 .direction_input = vexpress_sysreg_gpio_direction_input, ··· 419 409 .set = vexpress_sysreg_gpio_set, 420 410 .ngpio = ARRAY_SIZE(vexpress_sysreg_gpios), 421 411 .base = 0, 412 + }; 413 + 414 + 415 + #define VEXPRESS_SYSREG_GREEN_LED(_name, _default_trigger, _gpio) \ 416 + { \ 417 + .name = "v2m:green:"_name, \ 418 + .default_trigger = _default_trigger, \ 419 + .gpio = VEXPRESS_GPIO_##_gpio, \ 420 + } 421 + 422 + struct gpio_led vexpress_sysreg_leds[] = { 423 + VEXPRESS_SYSREG_GREEN_LED("user1", "heartbeat", LED0), 424 + VEXPRESS_SYSREG_GREEN_LED("user2", "mmc0", LED1), 425 + VEXPRESS_SYSREG_GREEN_LED("user3", "cpu0", LED2), 426 + VEXPRESS_SYSREG_GREEN_LED("user4", "cpu1", LED3), 427 + VEXPRESS_SYSREG_GREEN_LED("user5", "cpu2", LED4), 428 + VEXPRESS_SYSREG_GREEN_LED("user6", "cpu3", LED5), 429 + VEXPRESS_SYSREG_GREEN_LED("user7", "cpu4", LED6), 430 + VEXPRESS_SYSREG_GREEN_LED("user8", "cpu5", LED7), 431 + }; 432 + 433 + struct gpio_led_platform_data vexpress_sysreg_leds_pdata = { 434 + .num_leds = ARRAY_SIZE(vexpress_sysreg_leds), 435 + .leds = vexpress_sysreg_leds, 422 436 }; 423 437 424 438 ··· 490 456 return err; 491 457 } 492 458 459 + platform_device_register_data(vexpress_sysreg_dev, "leds-gpio", 460 + PLATFORM_DEVID_AUTO, &vexpress_sysreg_leds_pdata, 461 + sizeof(vexpress_sysreg_leds_pdata)); 462 + 493 463 vexpress_sysreg_dev = &pdev->dev; 494 464 495 465 device_create_file(vexpress_sysreg_dev, &dev_attr_sys_id); ··· 516 478 517 479 static int __init vexpress_sysreg_init(void) 518 480 { 481 + vexpress_sysreg_of_early_init(); 519 482 return platform_driver_register(&vexpress_sysreg_driver); 520 483 } 521 484 core_initcall(vexpress_sysreg_init);
+59 -71
drivers/mfd/wm5102-tables.c
··· 59 59 static const struct reg_default wm5102_revb_patch[] = { 60 60 { 0x80, 0x0003 }, 61 61 { 0x081, 0xE022 }, 62 - { 0x410, 0x6080 }, 63 - { 0x418, 0x6080 }, 64 - { 0x420, 0x6080 }, 62 + { 0x410, 0x4080 }, 63 + { 0x418, 0x4080 }, 64 + { 0x420, 0x4080 }, 65 65 { 0x428, 0xC000 }, 66 - { 0x441, 0x8014 }, 66 + { 0x4B0, 0x0066 }, 67 67 { 0x458, 0x000b }, 68 + { 0x212, 0x0000 }, 68 69 { 0x80, 0x0000 }, 69 70 }; 70 71 ··· 232 231 static const struct reg_default wm5102_reg_default[] = { 233 232 { 0x00000008, 0x0019 }, /* R8 - Ctrl IF SPI CFG 1 */ 234 233 { 0x00000009, 0x0001 }, /* R9 - Ctrl IF I2C1 CFG 1 */ 235 - { 0x0000000D, 0x0000 }, /* R13 - Ctrl IF Status 1 */ 236 234 { 0x00000016, 0x0000 }, /* R22 - Write Sequencer Ctrl 0 */ 237 235 { 0x00000017, 0x0000 }, /* R23 - Write Sequencer Ctrl 1 */ 238 236 { 0x00000018, 0x0000 }, /* R24 - Write Sequencer Ctrl 2 */ 239 - { 0x0000001A, 0x0000 }, /* R26 - Write Sequencer PROM */ 240 237 { 0x00000020, 0x0000 }, /* R32 - Tone Generator 1 */ 241 238 { 0x00000021, 0x1000 }, /* R33 - Tone Generator 2 */ 242 239 { 0x00000022, 0x0000 }, /* R34 - Tone Generator 3 */ ··· 249 250 { 0x00000062, 0x01FF }, /* R98 - Sample Rate Sequence Select 2 */ 250 251 { 0x00000063, 0x01FF }, /* R99 - Sample Rate Sequence Select 3 */ 251 252 { 0x00000064, 0x01FF }, /* R100 - Sample Rate Sequence Select 4 */ 252 - { 0x00000068, 0x01FF }, /* R104 - Always On Triggers Sequence Select 1 */ 253 - { 0x00000069, 0x01FF }, /* R105 - Always On Triggers Sequence Select 2 */ 254 - { 0x0000006A, 0x01FF }, /* R106 - Always On Triggers Sequence Select 3 */ 255 - { 0x0000006B, 0x01FF }, /* R107 - Always On Triggers Sequence Select 4 */ 256 - { 0x0000006C, 0x01FF }, /* R108 - Always On Triggers Sequence Select 5 */ 257 - { 0x0000006D, 0x01FF }, /* R109 - Always On Triggers Sequence Select 6 */ 253 + { 0x00000066, 0x01FF }, /* R102 - Always On Triggers Sequence Select 1 */ 254 + { 0x00000067, 0x01FF }, /* R103 - Always On Triggers Sequence Select 2 */ 255 + { 0x00000068, 0x01FF }, /* R104 - Always On Triggers Sequence Select 3 */ 256 + { 0x00000069, 0x01FF }, /* R105 - Always On Triggers Sequence Select 4 */ 257 + { 0x0000006A, 0x01FF }, /* R106 - Always On Triggers Sequence Select 5 */ 258 + { 0x0000006B, 0x01FF }, /* R107 - Always On Triggers Sequence Select 6 */ 259 + { 0x0000006E, 0x01FF }, /* R110 - Trigger Sequence Select 32 */ 260 + { 0x0000006F, 0x01FF }, /* R111 - Trigger Sequence Select 33 */ 258 261 { 0x00000070, 0x0000 }, /* R112 - Comfort Noise Generator */ 259 262 { 0x00000090, 0x0000 }, /* R144 - Haptics Control 1 */ 260 263 { 0x00000091, 0x7FFF }, /* R145 - Haptics Control 2 */ ··· 266 265 { 0x00000095, 0x0000 }, /* R149 - Haptics phase 2 duration */ 267 266 { 0x00000096, 0x0000 }, /* R150 - Haptics phase 3 intensity */ 268 267 { 0x00000097, 0x0000 }, /* R151 - Haptics phase 3 duration */ 269 - { 0x00000100, 0x0001 }, /* R256 - Clock 32k 1 */ 268 + { 0x00000100, 0x0002 }, /* R256 - Clock 32k 1 */ 270 269 { 0x00000101, 0x0304 }, /* R257 - System Clock 1 */ 271 270 { 0x00000102, 0x0011 }, /* R258 - Sample rate 1 */ 272 271 { 0x00000103, 0x0011 }, /* R259 - Sample rate 2 */ 273 272 { 0x00000104, 0x0011 }, /* R260 - Sample rate 3 */ 274 273 { 0x00000112, 0x0305 }, /* R274 - Async clock 1 */ 275 274 { 0x00000113, 0x0011 }, /* R275 - Async sample rate 1 */ 275 + { 0x00000114, 0x0011 }, /* R276 - Async sample rate 2 */ 276 276 { 0x00000149, 0x0000 }, /* R329 - Output system clock */ 277 277 { 0x0000014A, 0x0000 }, /* R330 - Output async clock */ 278 278 { 0x00000152, 0x0000 }, /* R338 - Rate Estimator 1 */ ··· 282 280 { 0x00000155, 0x0000 }, /* R341 - Rate Estimator 4 */ 283 281 { 0x00000156, 0x0000 }, /* R342 - Rate Estimator 5 */ 284 282 { 0x00000161, 0x0000 }, /* R353 - Dynamic Frequency Scaling 1 */ 285 - { 0x00000171, 0x0000 }, /* R369 - FLL1 Control 1 */ 283 + { 0x00000171, 0x0002 }, /* R369 - FLL1 Control 1 */ 286 284 { 0x00000172, 0x0008 }, /* R370 - FLL1 Control 2 */ 287 285 { 0x00000173, 0x0018 }, /* R371 - FLL1 Control 3 */ 288 286 { 0x00000174, 0x007D }, /* R372 - FLL1 Control 4 */ 289 287 { 0x00000175, 0x0004 }, /* R373 - FLL1 Control 5 */ 290 288 { 0x00000176, 0x0000 }, /* R374 - FLL1 Control 6 */ 291 289 { 0x00000177, 0x0181 }, /* R375 - FLL1 Loop Filter Test 1 */ 290 + { 0x00000178, 0x0000 }, /* R376 - FLL1 NCO Test 0 */ 292 291 { 0x00000181, 0x0000 }, /* R385 - FLL1 Synchroniser 1 */ 293 292 { 0x00000182, 0x0000 }, /* R386 - FLL1 Synchroniser 2 */ 294 293 { 0x00000183, 0x0000 }, /* R387 - FLL1 Synchroniser 3 */ ··· 305 302 { 0x00000195, 0x0004 }, /* R405 - FLL2 Control 5 */ 306 303 { 0x00000196, 0x0000 }, /* R406 - FLL2 Control 6 */ 307 304 { 0x00000197, 0x0000 }, /* R407 - FLL2 Loop Filter Test 1 */ 305 + { 0x00000198, 0x0000 }, /* R408 - FLL2 NCO Test 0 */ 308 306 { 0x000001A1, 0x0000 }, /* R417 - FLL2 Synchroniser 1 */ 309 307 { 0x000001A2, 0x0000 }, /* R418 - FLL2 Synchroniser 2 */ 310 308 { 0x000001A3, 0x0000 }, /* R419 - FLL2 Synchroniser 3 */ ··· 321 317 { 0x00000218, 0x01A6 }, /* R536 - Mic Bias Ctrl 1 */ 322 318 { 0x00000219, 0x01A6 }, /* R537 - Mic Bias Ctrl 2 */ 323 319 { 0x0000021A, 0x01A6 }, /* R538 - Mic Bias Ctrl 3 */ 320 + { 0x00000225, 0x0400 }, /* R549 - HP Ctrl 1L */ 321 + { 0x00000226, 0x0400 }, /* R550 - HP Ctrl 1R */ 324 322 { 0x00000293, 0x0000 }, /* R659 - Accessory Detect Mode 1 */ 325 323 { 0x0000029B, 0x0020 }, /* R667 - Headphone Detect 1 */ 324 + { 0x0000029C, 0x0000 }, /* R668 - Headphone Detect 2 */ 325 + { 0x0000029F, 0x0000 }, /* R671 - Headphone Detect Test */ 326 326 { 0x000002A2, 0x0000 }, /* R674 - Micd clamp control */ 327 327 { 0x000002A3, 0x1102 }, /* R675 - Mic Detect 1 */ 328 328 { 0x000002A4, 0x009F }, /* R676 - Mic Detect 2 */ ··· 358 350 { 0x00000400, 0x0000 }, /* R1024 - Output Enables 1 */ 359 351 { 0x00000408, 0x0000 }, /* R1032 - Output Rate 1 */ 360 352 { 0x00000409, 0x0022 }, /* R1033 - Output Volume Ramp */ 361 - { 0x00000410, 0x0080 }, /* R1040 - Output Path Config 1L */ 353 + { 0x00000410, 0x4080 }, /* R1040 - Output Path Config 1L */ 362 354 { 0x00000411, 0x0180 }, /* R1041 - DAC Digital Volume 1L */ 363 - { 0x00000412, 0x0080 }, /* R1042 - DAC Volume Limit 1L */ 355 + { 0x00000412, 0x0081 }, /* R1042 - DAC Volume Limit 1L */ 364 356 { 0x00000413, 0x0001 }, /* R1043 - Noise Gate Select 1L */ 365 357 { 0x00000414, 0x0080 }, /* R1044 - Output Path Config 1R */ 366 358 { 0x00000415, 0x0180 }, /* R1045 - DAC Digital Volume 1R */ 367 - { 0x00000416, 0x0080 }, /* R1046 - DAC Volume Limit 1R */ 359 + { 0x00000416, 0x0081 }, /* R1046 - DAC Volume Limit 1R */ 368 360 { 0x00000417, 0x0002 }, /* R1047 - Noise Gate Select 1R */ 369 - { 0x00000418, 0x0080 }, /* R1048 - Output Path Config 2L */ 361 + { 0x00000418, 0x4080 }, /* R1048 - Output Path Config 2L */ 370 362 { 0x00000419, 0x0180 }, /* R1049 - DAC Digital Volume 2L */ 371 - { 0x0000041A, 0x0080 }, /* R1050 - DAC Volume Limit 2L */ 363 + { 0x0000041A, 0x0081 }, /* R1050 - DAC Volume Limit 2L */ 372 364 { 0x0000041B, 0x0004 }, /* R1051 - Noise Gate Select 2L */ 373 365 { 0x0000041C, 0x0080 }, /* R1052 - Output Path Config 2R */ 374 366 { 0x0000041D, 0x0180 }, /* R1053 - DAC Digital Volume 2R */ 375 - { 0x0000041E, 0x0080 }, /* R1054 - DAC Volume Limit 2R */ 367 + { 0x0000041E, 0x0081 }, /* R1054 - DAC Volume Limit 2R */ 376 368 { 0x0000041F, 0x0008 }, /* R1055 - Noise Gate Select 2R */ 377 - { 0x00000420, 0x0080 }, /* R1056 - Output Path Config 3L */ 369 + { 0x00000420, 0x4080 }, /* R1056 - Output Path Config 3L */ 378 370 { 0x00000421, 0x0180 }, /* R1057 - DAC Digital Volume 3L */ 379 - { 0x00000422, 0x0080 }, /* R1058 - DAC Volume Limit 3L */ 371 + { 0x00000422, 0x0081 }, /* R1058 - DAC Volume Limit 3L */ 380 372 { 0x00000423, 0x0010 }, /* R1059 - Noise Gate Select 3L */ 381 - { 0x00000424, 0x0080 }, /* R1060 - Output Path Config 3R */ 382 - { 0x00000425, 0x0180 }, /* R1061 - DAC Digital Volume 3R */ 383 - { 0x00000426, 0x0080 }, /* R1062 - DAC Volume Limit 3R */ 384 - { 0x00000428, 0x0000 }, /* R1064 - Output Path Config 4L */ 373 + { 0x00000428, 0xC000 }, /* R1064 - Output Path Config 4L */ 385 374 { 0x00000429, 0x0180 }, /* R1065 - DAC Digital Volume 4L */ 386 - { 0x0000042A, 0x0080 }, /* R1066 - Out Volume 4L */ 375 + { 0x0000042A, 0x0081 }, /* R1066 - Out Volume 4L */ 387 376 { 0x0000042B, 0x0040 }, /* R1067 - Noise Gate Select 4L */ 388 - { 0x0000042C, 0x0000 }, /* R1068 - Output Path Config 4R */ 389 377 { 0x0000042D, 0x0180 }, /* R1069 - DAC Digital Volume 4R */ 390 - { 0x0000042E, 0x0080 }, /* R1070 - Out Volume 4R */ 378 + { 0x0000042E, 0x0081 }, /* R1070 - Out Volume 4R */ 391 379 { 0x0000042F, 0x0080 }, /* R1071 - Noise Gate Select 4R */ 392 380 { 0x00000430, 0x0000 }, /* R1072 - Output Path Config 5L */ 393 381 { 0x00000431, 0x0180 }, /* R1073 - DAC Digital Volume 5L */ 394 - { 0x00000432, 0x0080 }, /* R1074 - DAC Volume Limit 5L */ 382 + { 0x00000432, 0x0081 }, /* R1074 - DAC Volume Limit 5L */ 395 383 { 0x00000433, 0x0100 }, /* R1075 - Noise Gate Select 5L */ 396 - { 0x00000434, 0x0000 }, /* R1076 - Output Path Config 5R */ 397 384 { 0x00000435, 0x0180 }, /* R1077 - DAC Digital Volume 5R */ 398 - { 0x00000436, 0x0080 }, /* R1078 - DAC Volume Limit 5R */ 399 - { 0x00000437, 0x0200 }, /* R1079 - Noise Gate Select 5R */ 385 + { 0x00000436, 0x0081 }, /* R1078 - DAC Volume Limit 5R */ 386 + { 0x00000437, 0x0200 }, /* R1079 - Noise Gate Select 5R */ 400 387 { 0x00000450, 0x0000 }, /* R1104 - DAC AEC Control 1 */ 401 388 { 0x00000458, 0x0001 }, /* R1112 - Noise Gate Control */ 402 389 { 0x00000490, 0x0069 }, /* R1168 - PDM SPK1 CTRL 1 */ 403 390 { 0x00000491, 0x0000 }, /* R1169 - PDM SPK1 CTRL 2 */ 404 - { 0x000004DC, 0x0000 }, /* R1244 - DAC comp 1 */ 405 - { 0x000004DD, 0x0000 }, /* R1245 - DAC comp 2 */ 406 - { 0x000004DE, 0x0000 }, /* R1246 - DAC comp 3 */ 407 - { 0x000004DF, 0x0000 }, /* R1247 - DAC comp 4 */ 408 391 { 0x00000500, 0x000C }, /* R1280 - AIF1 BCLK Ctrl */ 409 392 { 0x00000501, 0x0008 }, /* R1281 - AIF1 Tx Pin Ctrl */ 410 393 { 0x00000502, 0x0000 }, /* R1282 - AIF1 Rx Pin Ctrl */ ··· 423 424 { 0x00000518, 0x0007 }, /* R1304 - AIF1 Frame Ctrl 18 */ 424 425 { 0x00000519, 0x0000 }, /* R1305 - AIF1 Tx Enables */ 425 426 { 0x0000051A, 0x0000 }, /* R1306 - AIF1 Rx Enables */ 426 - { 0x0000051B, 0x0000 }, /* R1307 - AIF1 Force Write */ 427 427 { 0x00000540, 0x000C }, /* R1344 - AIF2 BCLK Ctrl */ 428 428 { 0x00000541, 0x0008 }, /* R1345 - AIF2 Tx Pin Ctrl */ 429 429 { 0x00000542, 0x0000 }, /* R1346 - AIF2 Rx Pin Ctrl */ ··· 438 440 { 0x00000552, 0x0001 }, /* R1362 - AIF2 Frame Ctrl 12 */ 439 441 { 0x00000559, 0x0000 }, /* R1369 - AIF2 Tx Enables */ 440 442 { 0x0000055A, 0x0000 }, /* R1370 - AIF2 Rx Enables */ 441 - { 0x0000055B, 0x0000 }, /* R1371 - AIF2 Force Write */ 442 443 { 0x00000580, 0x000C }, /* R1408 - AIF3 BCLK Ctrl */ 443 444 { 0x00000581, 0x0008 }, /* R1409 - AIF3 Tx Pin Ctrl */ 444 445 { 0x00000582, 0x0000 }, /* R1410 - AIF3 Rx Pin Ctrl */ ··· 453 456 { 0x00000592, 0x0001 }, /* R1426 - AIF3 Frame Ctrl 12 */ 454 457 { 0x00000599, 0x0000 }, /* R1433 - AIF3 Tx Enables */ 455 458 { 0x0000059A, 0x0000 }, /* R1434 - AIF3 Rx Enables */ 456 - { 0x0000059B, 0x0000 }, /* R1435 - AIF3 Force Write */ 457 459 { 0x000005E3, 0x0004 }, /* R1507 - SLIMbus Framer Ref Gear */ 458 460 { 0x000005E5, 0x0000 }, /* R1509 - SLIMbus Rates 1 */ 459 461 { 0x000005E6, 0x0000 }, /* R1510 - SLIMbus Rates 2 */ ··· 776 780 { 0x000008CD, 0x0080 }, /* R2253 - DRC1RMIX Input 3 Volume */ 777 781 { 0x000008CE, 0x0000 }, /* R2254 - DRC1RMIX Input 4 Source */ 778 782 { 0x000008CF, 0x0080 }, /* R2255 - DRC1RMIX Input 4 Volume */ 779 - { 0x000008D0, 0x0000 }, /* R2256 - DRC2LMIX Input 1 Source */ 780 - { 0x000008D1, 0x0080 }, /* R2257 - DRC2LMIX Input 1 Volume */ 781 - { 0x000008D2, 0x0000 }, /* R2258 - DRC2LMIX Input 2 Source */ 782 - { 0x000008D3, 0x0080 }, /* R2259 - DRC2LMIX Input 2 Volume */ 783 - { 0x000008D4, 0x0000 }, /* R2260 - DRC2LMIX Input 3 Source */ 784 - { 0x000008D5, 0x0080 }, /* R2261 - DRC2LMIX Input 3 Volume */ 785 - { 0x000008D6, 0x0000 }, /* R2262 - DRC2LMIX Input 4 Source */ 786 - { 0x000008D7, 0x0080 }, /* R2263 - DRC2LMIX Input 4 Volume */ 787 - { 0x000008D8, 0x0000 }, /* R2264 - DRC2RMIX Input 1 Source */ 788 - { 0x000008D9, 0x0080 }, /* R2265 - DRC2RMIX Input 1 Volume */ 789 - { 0x000008DA, 0x0000 }, /* R2266 - DRC2RMIX Input 2 Source */ 790 - { 0x000008DB, 0x0080 }, /* R2267 - DRC2RMIX Input 2 Volume */ 791 - { 0x000008DC, 0x0000 }, /* R2268 - DRC2RMIX Input 3 Source */ 792 - { 0x000008DD, 0x0080 }, /* R2269 - DRC2RMIX Input 3 Volume */ 793 - { 0x000008DE, 0x0000 }, /* R2270 - DRC2RMIX Input 4 Source */ 794 - { 0x000008DF, 0x0080 }, /* R2271 - DRC2RMIX Input 4 Volume */ 795 783 { 0x00000900, 0x0000 }, /* R2304 - HPLP1MIX Input 1 Source */ 796 784 { 0x00000901, 0x0080 }, /* R2305 - HPLP1MIX Input 1 Volume */ 797 785 { 0x00000902, 0x0000 }, /* R2306 - HPLP1MIX Input 2 Source */ ··· 867 887 { 0x00000D1B, 0xFFFF }, /* R3355 - IRQ2 Status 4 Mask */ 868 888 { 0x00000D1C, 0xFFFF }, /* R3356 - IRQ2 Status 5 Mask */ 869 889 { 0x00000D1F, 0x0000 }, /* R3359 - IRQ2 Control */ 870 - { 0x00000D41, 0x0000 }, /* R3393 - ADSP2 IRQ0 */ 890 + { 0x00000D50, 0x0000 }, /* R3408 - AOD wkup and trig */ 871 891 { 0x00000D53, 0xFFFF }, /* R3411 - AOD IRQ Mask IRQ1 */ 872 892 { 0x00000D54, 0xFFFF }, /* R3412 - AOD IRQ Mask IRQ2 */ 873 893 { 0x00000D56, 0x0000 }, /* R3414 - Jack detect debounce */ ··· 962 982 { 0x00000E82, 0x0018 }, /* R3714 - DRC1 ctrl3 */ 963 983 { 0x00000E83, 0x0000 }, /* R3715 - DRC1 ctrl4 */ 964 984 { 0x00000E84, 0x0000 }, /* R3716 - DRC1 ctrl5 */ 965 - { 0x00000E89, 0x0018 }, /* R3721 - DRC2 ctrl1 */ 966 - { 0x00000E8A, 0x0933 }, /* R3722 - DRC2 ctrl2 */ 967 - { 0x00000E8B, 0x0018 }, /* R3723 - DRC2 ctrl3 */ 968 - { 0x00000E8C, 0x0000 }, /* R3724 - DRC2 ctrl4 */ 969 - { 0x00000E8D, 0x0000 }, /* R3725 - DRC2 ctrl5 */ 970 985 { 0x00000EC0, 0x0000 }, /* R3776 - HPLPF1_1 */ 971 986 { 0x00000EC1, 0x0000 }, /* R3777 - HPLPF1_2 */ 972 987 { 0x00000EC4, 0x0000 }, /* R3780 - HPLPF2_1 */ ··· 972 997 { 0x00000ECD, 0x0000 }, /* R3789 - HPLPF4_2 */ 973 998 { 0x00000EE0, 0x0000 }, /* R3808 - ASRC_ENABLE */ 974 999 { 0x00000EE2, 0x0000 }, /* R3810 - ASRC_RATE1 */ 975 - { 0x00000EE3, 0x4000 }, /* R3811 - ASRC_RATE2 */ 976 1000 { 0x00000EF0, 0x0000 }, /* R3824 - ISRC 1 CTRL 1 */ 977 1001 { 0x00000EF1, 0x0000 }, /* R3825 - ISRC 1 CTRL 2 */ 978 1002 { 0x00000EF2, 0x0000 }, /* R3826 - ISRC 1 CTRL 3 */ 979 1003 { 0x00000EF3, 0x0000 }, /* R3827 - ISRC 2 CTRL 1 */ 980 1004 { 0x00000EF4, 0x0000 }, /* R3828 - ISRC 2 CTRL 2 */ 981 1005 { 0x00000EF5, 0x0000 }, /* R3829 - ISRC 2 CTRL 3 */ 982 - { 0x00000EF6, 0x0000 }, /* R3830 - ISRC 3 CTRL 1 */ 983 - { 0x00000EF7, 0x0000 }, /* R3831 - ISRC 3 CTRL 2 */ 984 - { 0x00000EF8, 0x0000 }, /* R3832 - ISRC 3 CTRL 3 */ 985 1006 { 0x00001100, 0x0010 }, /* R4352 - DSP1 Control 1 */ 986 1007 { 0x00001101, 0x0000 }, /* R4353 - DSP1 Clocking 1 */ 987 1008 }; ··· 1804 1833 case ARIZONA_DSP1_STATUS_1: 1805 1834 case ARIZONA_DSP1_STATUS_2: 1806 1835 case ARIZONA_DSP1_STATUS_3: 1836 + case ARIZONA_DSP1_SCRATCH_0: 1837 + case ARIZONA_DSP1_SCRATCH_1: 1838 + case ARIZONA_DSP1_SCRATCH_2: 1839 + case ARIZONA_DSP1_SCRATCH_3: 1807 1840 return true; 1808 1841 default: 1809 - return false; 1842 + if ((reg >= 0x100000 && reg < 0x106000) || 1843 + (reg >= 0x180000 && reg < 0x180800) || 1844 + (reg >= 0x190000 && reg < 0x194800) || 1845 + (reg >= 0x1a8000 && reg < 0x1a9800)) 1846 + return true; 1847 + else 1848 + return false; 1810 1849 } 1811 1850 } 1812 1851 1813 1852 static bool wm5102_volatile_register(struct device *dev, unsigned int reg) 1814 1853 { 1815 - if (reg > 0xffff) 1816 - return true; 1817 - 1818 1854 switch (reg) { 1819 1855 case ARIZONA_SOFTWARE_RESET: 1820 1856 case ARIZONA_DEVICE_REVISION: ··· 1862 1884 case ARIZONA_DSP1_STATUS_1: 1863 1885 case ARIZONA_DSP1_STATUS_2: 1864 1886 case ARIZONA_DSP1_STATUS_3: 1887 + case ARIZONA_DSP1_SCRATCH_0: 1888 + case ARIZONA_DSP1_SCRATCH_1: 1889 + case ARIZONA_DSP1_SCRATCH_2: 1890 + case ARIZONA_DSP1_SCRATCH_3: 1865 1891 case ARIZONA_HEADPHONE_DETECT_2: 1866 1892 case ARIZONA_HP_DACVAL: 1867 1893 case ARIZONA_MIC_DETECT_3: 1868 1894 return true; 1869 1895 default: 1870 - return false; 1896 + if ((reg >= 0x100000 && reg < 0x106000) || 1897 + (reg >= 0x180000 && reg < 0x180800) || 1898 + (reg >= 0x190000 && reg < 0x194800) || 1899 + (reg >= 0x1a8000 && reg < 0x1a9800)) 1900 + return true; 1901 + else 1902 + return false; 1871 1903 } 1872 1904 } 1873 1905
+2 -5
drivers/mfd/wm8994-core.c
··· 467 467 goto err; 468 468 } 469 469 470 - ret = regulator_bulk_get(wm8994->dev, wm8994->num_supplies, 470 + ret = devm_regulator_bulk_get(wm8994->dev, wm8994->num_supplies, 471 471 wm8994->supplies); 472 472 if (ret != 0) { 473 473 dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret); ··· 478 478 wm8994->supplies); 479 479 if (ret != 0) { 480 480 dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret); 481 - goto err_get; 481 + goto err; 482 482 } 483 483 484 484 ret = wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET); ··· 658 658 err_enable: 659 659 regulator_bulk_disable(wm8994->num_supplies, 660 660 wm8994->supplies); 661 - err_get: 662 - regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); 663 661 err: 664 662 mfd_remove_devices(wm8994->dev); 665 663 return ret; ··· 670 672 wm8994_irq_exit(wm8994); 671 673 regulator_bulk_disable(wm8994->num_supplies, 672 674 wm8994->supplies); 673 - regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); 674 675 } 675 676 676 677 static const struct of_device_id wm8994_of_match[] = {
+18
drivers/mmc/host/rtsx_pci_sdmmc.c
··· 678 678 struct mmc_command *cmd = mrq->cmd; 679 679 struct mmc_data *data = mrq->data; 680 680 unsigned int data_size = 0; 681 + int err; 681 682 682 683 if (host->eject) { 683 684 cmd->error = -ENOMEDIUM; 685 + goto finish; 686 + } 687 + 688 + err = rtsx_pci_card_exclusive_check(host->pcr, RTSX_SD_CARD); 689 + if (err) { 690 + cmd->error = err; 684 691 goto finish; 685 692 } 686 693 ··· 908 901 if (host->eject) 909 902 return; 910 903 904 + if (rtsx_pci_card_exclusive_check(host->pcr, RTSX_SD_CARD)) 905 + return; 906 + 911 907 mutex_lock(&pcr->pcr_mutex); 912 908 913 909 rtsx_pci_start_run(pcr); ··· 1083 1073 if (host->eject) 1084 1074 return -ENOMEDIUM; 1085 1075 1076 + err = rtsx_pci_card_exclusive_check(host->pcr, RTSX_SD_CARD); 1077 + if (err) 1078 + return err; 1079 + 1086 1080 mutex_lock(&pcr->pcr_mutex); 1087 1081 1088 1082 rtsx_pci_start_run(pcr); ··· 1135 1121 1136 1122 if (host->eject) 1137 1123 return -ENOMEDIUM; 1124 + 1125 + err = rtsx_pci_card_exclusive_check(host->pcr, RTSX_SD_CARD); 1126 + if (err) 1127 + return err; 1138 1128 1139 1129 mutex_lock(&pcr->pcr_mutex); 1140 1130
+10
drivers/rtc/Kconfig
··· 305 305 This driver can also be built as a module. If so, the module 306 306 will be called rtc-x1205. 307 307 308 + config RTC_DRV_PALMAS 309 + tristate "TI Palmas RTC driver" 310 + depends on MFD_PALMAS 311 + help 312 + If you say yes here you get support for the RTC of TI PALMA series PMIC 313 + chips. 314 + 315 + This driver can also be built as a module. If so, the module 316 + will be called rtc-palma. 317 + 308 318 config RTC_DRV_PCF8523 309 319 tristate "NXP PCF8523" 310 320 help
+1
drivers/rtc/Makefile
··· 81 81 obj-$(CONFIG_RTC_DRV_MV) += rtc-mv.o 82 82 obj-$(CONFIG_RTC_DRV_NUC900) += rtc-nuc900.o 83 83 obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o 84 + obj-$(CONFIG_RTC_DRV_PALMAS) += rtc-palmas.o 84 85 obj-$(CONFIG_RTC_DRV_PCAP) += rtc-pcap.o 85 86 obj-$(CONFIG_RTC_DRV_PCF8523) += rtc-pcf8523.o 86 87 obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o
+339
drivers/rtc/rtc-palmas.c
··· 1 + /* 2 + * rtc-palmas.c -- Palmas Real Time Clock driver. 3 + 4 + * RTC driver for TI Palma series devices like TPS65913, 5 + * TPS65914 power management IC. 6 + * 7 + * Copyright (c) 2012, NVIDIA Corporation. 8 + * 9 + * Author: Laxman Dewangan <ldewangan@nvidia.com> 10 + * 11 + * This program is free software; you can redistribute it and/or 12 + * modify it under the terms of the GNU General Public License as 13 + * published by the Free Software Foundation version 2. 14 + * 15 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind, 16 + * whether express or implied; without even the implied warranty of 17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 + * General Public License for more details. 19 + * 20 + * You should have received a copy of the GNU General Public License 21 + * along with this program; if not, write to the Free Software 22 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 23 + * 02111-1307, USA 24 + */ 25 + 26 + #include <linux/bcd.h> 27 + #include <linux/errno.h> 28 + #include <linux/init.h> 29 + #include <linux/interrupt.h> 30 + #include <linux/kernel.h> 31 + #include <linux/mfd/palmas.h> 32 + #include <linux/module.h> 33 + #include <linux/rtc.h> 34 + #include <linux/types.h> 35 + #include <linux/platform_device.h> 36 + #include <linux/pm.h> 37 + 38 + struct palmas_rtc { 39 + struct rtc_device *rtc; 40 + struct device *dev; 41 + unsigned int irq; 42 + }; 43 + 44 + /* Total number of RTC registers needed to set time*/ 45 + #define PALMAS_NUM_TIME_REGS (PALMAS_YEARS_REG - PALMAS_SECONDS_REG + 1) 46 + 47 + static int palmas_rtc_read_time(struct device *dev, struct rtc_time *tm) 48 + { 49 + unsigned char rtc_data[PALMAS_NUM_TIME_REGS]; 50 + struct palmas *palmas = dev_get_drvdata(dev->parent); 51 + int ret; 52 + 53 + /* Copy RTC counting registers to static registers or latches */ 54 + ret = palmas_update_bits(palmas, PALMAS_RTC_BASE, PALMAS_RTC_CTRL_REG, 55 + PALMAS_RTC_CTRL_REG_GET_TIME, PALMAS_RTC_CTRL_REG_GET_TIME); 56 + if (ret < 0) { 57 + dev_err(dev, "RTC CTRL reg update failed, err: %d\n", ret); 58 + return ret; 59 + } 60 + 61 + ret = palmas_bulk_read(palmas, PALMAS_RTC_BASE, PALMAS_SECONDS_REG, 62 + rtc_data, PALMAS_NUM_TIME_REGS); 63 + if (ret < 0) { 64 + dev_err(dev, "RTC_SECONDS reg read failed, err = %d\n", ret); 65 + return ret; 66 + } 67 + 68 + tm->tm_sec = bcd2bin(rtc_data[0]); 69 + tm->tm_min = bcd2bin(rtc_data[1]); 70 + tm->tm_hour = bcd2bin(rtc_data[2]); 71 + tm->tm_mday = bcd2bin(rtc_data[3]); 72 + tm->tm_mon = bcd2bin(rtc_data[4]) - 1; 73 + tm->tm_year = bcd2bin(rtc_data[5]) + 100; 74 + 75 + return ret; 76 + } 77 + 78 + static int palmas_rtc_set_time(struct device *dev, struct rtc_time *tm) 79 + { 80 + unsigned char rtc_data[PALMAS_NUM_TIME_REGS]; 81 + struct palmas *palmas = dev_get_drvdata(dev->parent); 82 + int ret; 83 + 84 + rtc_data[0] = bin2bcd(tm->tm_sec); 85 + rtc_data[1] = bin2bcd(tm->tm_min); 86 + rtc_data[2] = bin2bcd(tm->tm_hour); 87 + rtc_data[3] = bin2bcd(tm->tm_mday); 88 + rtc_data[4] = bin2bcd(tm->tm_mon + 1); 89 + rtc_data[5] = bin2bcd(tm->tm_year - 100); 90 + 91 + /* Stop RTC while updating the RTC time registers */ 92 + ret = palmas_update_bits(palmas, PALMAS_RTC_BASE, PALMAS_RTC_CTRL_REG, 93 + PALMAS_RTC_CTRL_REG_STOP_RTC, 0); 94 + if (ret < 0) { 95 + dev_err(dev, "RTC stop failed, err = %d\n", ret); 96 + return ret; 97 + } 98 + 99 + ret = palmas_bulk_write(palmas, PALMAS_RTC_BASE, PALMAS_SECONDS_REG, 100 + rtc_data, PALMAS_NUM_TIME_REGS); 101 + if (ret < 0) { 102 + dev_err(dev, "RTC_SECONDS reg write failed, err = %d\n", ret); 103 + return ret; 104 + } 105 + 106 + /* Start back RTC */ 107 + ret = palmas_update_bits(palmas, PALMAS_RTC_BASE, PALMAS_RTC_CTRL_REG, 108 + PALMAS_RTC_CTRL_REG_STOP_RTC, PALMAS_RTC_CTRL_REG_STOP_RTC); 109 + if (ret < 0) 110 + dev_err(dev, "RTC start failed, err = %d\n", ret); 111 + return ret; 112 + } 113 + 114 + static int palmas_rtc_alarm_irq_enable(struct device *dev, unsigned enabled) 115 + { 116 + struct palmas *palmas = dev_get_drvdata(dev->parent); 117 + u8 val; 118 + 119 + val = enabled ? PALMAS_RTC_INTERRUPTS_REG_IT_ALARM : 0; 120 + return palmas_write(palmas, PALMAS_RTC_BASE, 121 + PALMAS_RTC_INTERRUPTS_REG, val); 122 + } 123 + 124 + static int palmas_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) 125 + { 126 + unsigned char alarm_data[PALMAS_NUM_TIME_REGS]; 127 + u32 int_val; 128 + struct palmas *palmas = dev_get_drvdata(dev->parent); 129 + int ret; 130 + 131 + ret = palmas_bulk_read(palmas, PALMAS_RTC_BASE, 132 + PALMAS_ALARM_SECONDS_REG, 133 + alarm_data, PALMAS_NUM_TIME_REGS); 134 + if (ret < 0) { 135 + dev_err(dev, "RTC_ALARM_SECONDS read failed, err = %d\n", ret); 136 + return ret; 137 + } 138 + 139 + alm->time.tm_sec = bcd2bin(alarm_data[0]); 140 + alm->time.tm_min = bcd2bin(alarm_data[1]); 141 + alm->time.tm_hour = bcd2bin(alarm_data[2]); 142 + alm->time.tm_mday = bcd2bin(alarm_data[3]); 143 + alm->time.tm_mon = bcd2bin(alarm_data[4]) - 1; 144 + alm->time.tm_year = bcd2bin(alarm_data[5]) + 100; 145 + 146 + ret = palmas_read(palmas, PALMAS_RTC_BASE, PALMAS_RTC_INTERRUPTS_REG, 147 + &int_val); 148 + if (ret < 0) { 149 + dev_err(dev, "RTC_INTERRUPTS reg read failed, err = %d\n", ret); 150 + return ret; 151 + } 152 + 153 + if (int_val & PALMAS_RTC_INTERRUPTS_REG_IT_ALARM) 154 + alm->enabled = 1; 155 + return ret; 156 + } 157 + 158 + static int palmas_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) 159 + { 160 + unsigned char alarm_data[PALMAS_NUM_TIME_REGS]; 161 + struct palmas *palmas = dev_get_drvdata(dev->parent); 162 + int ret; 163 + 164 + ret = palmas_rtc_alarm_irq_enable(dev, 0); 165 + if (ret < 0) { 166 + dev_err(dev, "Disable RTC alarm failed\n"); 167 + return ret; 168 + } 169 + 170 + alarm_data[0] = bin2bcd(alm->time.tm_sec); 171 + alarm_data[1] = bin2bcd(alm->time.tm_min); 172 + alarm_data[2] = bin2bcd(alm->time.tm_hour); 173 + alarm_data[3] = bin2bcd(alm->time.tm_mday); 174 + alarm_data[4] = bin2bcd(alm->time.tm_mon + 1); 175 + alarm_data[5] = bin2bcd(alm->time.tm_year - 100); 176 + 177 + ret = palmas_bulk_write(palmas, PALMAS_RTC_BASE, 178 + PALMAS_ALARM_SECONDS_REG, alarm_data, PALMAS_NUM_TIME_REGS); 179 + if (ret < 0) { 180 + dev_err(dev, "ALARM_SECONDS_REG write failed, err = %d\n", ret); 181 + return ret; 182 + } 183 + 184 + if (alm->enabled) 185 + ret = palmas_rtc_alarm_irq_enable(dev, 1); 186 + return ret; 187 + } 188 + 189 + static int palmas_clear_interrupts(struct device *dev) 190 + { 191 + struct palmas *palmas = dev_get_drvdata(dev->parent); 192 + unsigned int rtc_reg; 193 + int ret; 194 + 195 + ret = palmas_read(palmas, PALMAS_RTC_BASE, PALMAS_RTC_STATUS_REG, 196 + &rtc_reg); 197 + if (ret < 0) { 198 + dev_err(dev, "RTC_STATUS read failed, err = %d\n", ret); 199 + return ret; 200 + } 201 + 202 + ret = palmas_write(palmas, PALMAS_RTC_BASE, PALMAS_RTC_STATUS_REG, 203 + rtc_reg); 204 + if (ret < 0) { 205 + dev_err(dev, "RTC_STATUS write failed, err = %d\n", ret); 206 + return ret; 207 + } 208 + return 0; 209 + } 210 + 211 + static irqreturn_t palmas_rtc_interrupt(int irq, void *context) 212 + { 213 + struct palmas_rtc *palmas_rtc = context; 214 + struct device *dev = palmas_rtc->dev; 215 + int ret; 216 + 217 + ret = palmas_clear_interrupts(dev); 218 + if (ret < 0) { 219 + dev_err(dev, "RTC interrupt clear failed, err = %d\n", ret); 220 + return IRQ_NONE; 221 + } 222 + 223 + rtc_update_irq(palmas_rtc->rtc, 1, RTC_IRQF | RTC_AF); 224 + return IRQ_HANDLED; 225 + } 226 + 227 + static struct rtc_class_ops palmas_rtc_ops = { 228 + .read_time = palmas_rtc_read_time, 229 + .set_time = palmas_rtc_set_time, 230 + .read_alarm = palmas_rtc_read_alarm, 231 + .set_alarm = palmas_rtc_set_alarm, 232 + .alarm_irq_enable = palmas_rtc_alarm_irq_enable, 233 + }; 234 + 235 + static int palmas_rtc_probe(struct platform_device *pdev) 236 + { 237 + struct palmas *palmas = dev_get_drvdata(pdev->dev.parent); 238 + struct palmas_rtc *palmas_rtc = NULL; 239 + int ret; 240 + 241 + palmas_rtc = devm_kzalloc(&pdev->dev, sizeof(struct palmas_rtc), 242 + GFP_KERNEL); 243 + if (!palmas_rtc) 244 + return -ENOMEM; 245 + 246 + /* Clear pending interrupts */ 247 + ret = palmas_clear_interrupts(&pdev->dev); 248 + if (ret < 0) { 249 + dev_err(&pdev->dev, "clear RTC int failed, err = %d\n", ret); 250 + return ret; 251 + } 252 + 253 + palmas_rtc->dev = &pdev->dev; 254 + platform_set_drvdata(pdev, palmas_rtc); 255 + 256 + /* Start RTC */ 257 + ret = palmas_update_bits(palmas, PALMAS_RTC_BASE, PALMAS_RTC_CTRL_REG, 258 + PALMAS_RTC_CTRL_REG_STOP_RTC, 259 + PALMAS_RTC_CTRL_REG_STOP_RTC); 260 + if (ret < 0) { 261 + dev_err(&pdev->dev, "RTC_CTRL write failed, err = %d\n", ret); 262 + return ret; 263 + } 264 + 265 + palmas_rtc->irq = platform_get_irq(pdev, 0); 266 + 267 + palmas_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, 268 + &palmas_rtc_ops, THIS_MODULE); 269 + if (IS_ERR(palmas_rtc->rtc)) { 270 + ret = PTR_ERR(palmas_rtc->rtc); 271 + dev_err(&pdev->dev, "RTC register failed, err = %d\n", ret); 272 + return ret; 273 + } 274 + 275 + ret = request_threaded_irq(palmas_rtc->irq, NULL, 276 + palmas_rtc_interrupt, 277 + IRQF_TRIGGER_LOW | IRQF_ONESHOT | 278 + IRQF_EARLY_RESUME, 279 + dev_name(&pdev->dev), palmas_rtc); 280 + if (ret < 0) { 281 + dev_err(&pdev->dev, "IRQ request failed, err = %d\n", ret); 282 + rtc_device_unregister(palmas_rtc->rtc); 283 + return ret; 284 + } 285 + 286 + device_set_wakeup_capable(&pdev->dev, 1); 287 + return 0; 288 + } 289 + 290 + static int palmas_rtc_remove(struct platform_device *pdev) 291 + { 292 + struct palmas_rtc *palmas_rtc = platform_get_drvdata(pdev); 293 + 294 + palmas_rtc_alarm_irq_enable(&pdev->dev, 0); 295 + free_irq(palmas_rtc->irq, palmas_rtc); 296 + rtc_device_unregister(palmas_rtc->rtc); 297 + return 0; 298 + } 299 + 300 + #ifdef CONFIG_PM_SLEEP 301 + static int palmas_rtc_suspend(struct device *dev) 302 + { 303 + struct palmas_rtc *palmas_rtc = dev_get_drvdata(dev); 304 + 305 + if (device_may_wakeup(dev)) 306 + enable_irq_wake(palmas_rtc->irq); 307 + return 0; 308 + } 309 + 310 + static int palmas_rtc_resume(struct device *dev) 311 + { 312 + struct palmas_rtc *palmas_rtc = dev_get_drvdata(dev); 313 + 314 + if (device_may_wakeup(dev)) 315 + disable_irq_wake(palmas_rtc->irq); 316 + return 0; 317 + } 318 + #endif 319 + 320 + static const struct dev_pm_ops palmas_rtc_pm_ops = { 321 + SET_SYSTEM_SLEEP_PM_OPS(palmas_rtc_suspend, palmas_rtc_resume) 322 + }; 323 + 324 + static struct platform_driver palmas_rtc_driver = { 325 + .probe = palmas_rtc_probe, 326 + .remove = palmas_rtc_remove, 327 + .driver = { 328 + .owner = THIS_MODULE, 329 + .name = "palmas-rtc", 330 + .pm = &palmas_rtc_pm_ops, 331 + }, 332 + }; 333 + 334 + module_platform_driver(palmas_rtc_driver); 335 + 336 + MODULE_ALIAS("platform:palmas_rtc"); 337 + MODULE_DESCRIPTION("TI PALMAS series RTC driver"); 338 + MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>"); 339 + MODULE_LICENSE("GPL v2");
+3 -3
drivers/usb/host/ehci-omap.c
··· 107 107 { 108 108 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 109 109 int rc; 110 - struct ehci_hcd_omap_platform_data *pdata; 110 + struct usbhs_omap_platform_data *pdata; 111 111 112 112 pdata = hcd->self.controller->platform_data; 113 113 ··· 151 151 } 152 152 153 153 static void disable_put_regulator( 154 - struct ehci_hcd_omap_platform_data *pdata) 154 + struct usbhs_omap_platform_data *pdata) 155 155 { 156 156 int i; 157 157 ··· 176 176 static int ehci_hcd_omap_probe(struct platform_device *pdev) 177 177 { 178 178 struct device *dev = &pdev->dev; 179 - struct ehci_hcd_omap_platform_data *pdata = dev->platform_data; 179 + struct usbhs_omap_platform_data *pdata = dev->platform_data; 180 180 struct resource *res; 181 181 struct usb_hcd *hcd; 182 182 void __iomem *regs;
+30 -1
drivers/video/backlight/max8925_bl.c
··· 101 101 .get_brightness = max8925_backlight_get_brightness, 102 102 }; 103 103 104 + #ifdef CONFIG_OF 105 + static int max8925_backlight_dt_init(struct platform_device *pdev, 106 + struct max8925_backlight_pdata *pdata) 107 + { 108 + struct device_node *nproot = pdev->dev.parent->of_node, *np; 109 + int dual_string; 110 + 111 + if (!nproot) 112 + return -ENODEV; 113 + np = of_find_node_by_name(nproot, "backlight"); 114 + if (!np) { 115 + dev_err(&pdev->dev, "failed to find backlight node\n"); 116 + return -ENODEV; 117 + } 118 + 119 + of_property_read_u32(np, "maxim,max8925-dual-string", &dual_string); 120 + pdata->dual_string = dual_string; 121 + return 0; 122 + } 123 + #else 124 + #define max8925_backlight_dt_init(x, y) (-1) 125 + #endif 126 + 104 127 static int max8925_backlight_probe(struct platform_device *pdev) 105 128 { 106 129 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); ··· 170 147 platform_set_drvdata(pdev, bl); 171 148 172 149 value = 0; 150 + if (pdev->dev.parent->of_node && !pdata) { 151 + pdata = devm_kzalloc(&pdev->dev, 152 + sizeof(struct max8925_backlight_pdata), 153 + GFP_KERNEL); 154 + max8925_backlight_dt_init(pdev, pdata); 155 + } 156 + 173 157 if (pdata) { 174 158 if (pdata->lxw_scl) 175 159 value |= (1 << 7); ··· 188 158 ret = max8925_set_bits(chip->i2c, data->reg_mode_cntl, 0xfe, value); 189 159 if (ret < 0) 190 160 goto out_brt; 191 - 192 161 backlight_update_status(bl); 193 162 return 0; 194 163 out_brt:
+12
drivers/watchdog/Kconfig
··· 364 364 To compile this driver as a module, choose M here: the 365 365 module will be called imx2_wdt. 366 366 367 + config UX500_WATCHDOG 368 + tristate "ST-Ericsson Ux500 watchdog" 369 + depends on MFD_DB8500_PRCMU 370 + select WATCHDOG_CORE 371 + default y 372 + help 373 + Say Y here to include Watchdog timer support for the watchdog 374 + existing in the prcmu of ST-Ericsson Ux500 series platforms. 375 + 376 + To compile this driver as a module, choose M here: the 377 + module will be called ux500_wdt. 378 + 367 379 # AVR32 Architecture 368 380 369 381 config AT32AP700X_WDT
+1
drivers/watchdog/Makefile
··· 52 52 obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o 53 53 obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o 54 54 obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o 55 + obj-$(CONFIG_UX500_WATCHDOG) += ux500_wdt.o 55 56 56 57 # AVR32 Architecture 57 58 obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
+171
drivers/watchdog/ux500_wdt.c
··· 1 + /* 2 + * Copyright (C) ST-Ericsson SA 2011-2013 3 + * 4 + * License Terms: GNU General Public License v2 5 + * 6 + * Author: Mathieu Poirier <mathieu.poirier@linaro.org> for ST-Ericsson 7 + * Author: Jonas Aaberg <jonas.aberg@stericsson.com> for ST-Ericsson 8 + */ 9 + 10 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 11 + 12 + #include <linux/module.h> 13 + #include <linux/kernel.h> 14 + #include <linux/moduleparam.h> 15 + #include <linux/miscdevice.h> 16 + #include <linux/err.h> 17 + #include <linux/uaccess.h> 18 + #include <linux/watchdog.h> 19 + #include <linux/platform_device.h> 20 + #include <linux/platform_data/ux500_wdt.h> 21 + 22 + #include <linux/mfd/dbx500-prcmu.h> 23 + 24 + #define WATCHDOG_TIMEOUT 600 /* 10 minutes */ 25 + 26 + #define WATCHDOG_MIN 0 27 + #define WATCHDOG_MAX28 268435 /* 28 bit resolution in ms == 268435.455 s */ 28 + #define WATCHDOG_MAX32 4294967 /* 32 bit resolution in ms == 4294967.295 s */ 29 + 30 + static unsigned int timeout = WATCHDOG_TIMEOUT; 31 + module_param(timeout, uint, 0); 32 + MODULE_PARM_DESC(timeout, 33 + "Watchdog timeout in seconds. default=" 34 + __MODULE_STRING(WATCHDOG_TIMEOUT) "."); 35 + 36 + static bool nowayout = WATCHDOG_NOWAYOUT; 37 + module_param(nowayout, bool, 0); 38 + MODULE_PARM_DESC(nowayout, 39 + "Watchdog cannot be stopped once started (default=" 40 + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 41 + 42 + static int ux500_wdt_start(struct watchdog_device *wdd) 43 + { 44 + return prcmu_enable_a9wdog(PRCMU_WDOG_ALL); 45 + } 46 + 47 + static int ux500_wdt_stop(struct watchdog_device *wdd) 48 + { 49 + return prcmu_disable_a9wdog(PRCMU_WDOG_ALL); 50 + } 51 + 52 + static int ux500_wdt_keepalive(struct watchdog_device *wdd) 53 + { 54 + return prcmu_kick_a9wdog(PRCMU_WDOG_ALL); 55 + } 56 + 57 + static int ux500_wdt_set_timeout(struct watchdog_device *wdd, 58 + unsigned int timeout) 59 + { 60 + ux500_wdt_stop(wdd); 61 + prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); 62 + ux500_wdt_start(wdd); 63 + 64 + return 0; 65 + } 66 + 67 + static const struct watchdog_info ux500_wdt_info = { 68 + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, 69 + .identity = "Ux500 WDT", 70 + .firmware_version = 1, 71 + }; 72 + 73 + static const struct watchdog_ops ux500_wdt_ops = { 74 + .owner = THIS_MODULE, 75 + .start = ux500_wdt_start, 76 + .stop = ux500_wdt_stop, 77 + .ping = ux500_wdt_keepalive, 78 + .set_timeout = ux500_wdt_set_timeout, 79 + }; 80 + 81 + static struct watchdog_device ux500_wdt = { 82 + .info = &ux500_wdt_info, 83 + .ops = &ux500_wdt_ops, 84 + .min_timeout = WATCHDOG_MIN, 85 + .max_timeout = WATCHDOG_MAX32, 86 + }; 87 + 88 + static int ux500_wdt_probe(struct platform_device *pdev) 89 + { 90 + int ret; 91 + struct ux500_wdt_data *pdata = pdev->dev.platform_data; 92 + 93 + if (pdata) { 94 + if (pdata->timeout > 0) 95 + timeout = pdata->timeout; 96 + if (pdata->has_28_bits_resolution) 97 + ux500_wdt.max_timeout = WATCHDOG_MAX28; 98 + } 99 + 100 + watchdog_set_nowayout(&ux500_wdt, nowayout); 101 + 102 + /* disable auto off on sleep */ 103 + prcmu_config_a9wdog(PRCMU_WDOG_CPU1, false); 104 + 105 + /* set HW initial value */ 106 + prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); 107 + 108 + ret = watchdog_register_device(&ux500_wdt); 109 + if (ret) 110 + return ret; 111 + 112 + dev_info(&pdev->dev, "initialized\n"); 113 + 114 + return 0; 115 + } 116 + 117 + static int ux500_wdt_remove(struct platform_device *dev) 118 + { 119 + watchdog_unregister_device(&ux500_wdt); 120 + 121 + return 0; 122 + } 123 + 124 + #ifdef CONFIG_PM 125 + static int ux500_wdt_suspend(struct platform_device *pdev, 126 + pm_message_t state) 127 + { 128 + if (watchdog_active(&ux500_wdt)) { 129 + ux500_wdt_stop(&ux500_wdt); 130 + prcmu_config_a9wdog(PRCMU_WDOG_CPU1, true); 131 + 132 + prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); 133 + ux500_wdt_start(&ux500_wdt); 134 + } 135 + return 0; 136 + } 137 + 138 + static int ux500_wdt_resume(struct platform_device *pdev) 139 + { 140 + if (watchdog_active(&ux500_wdt)) { 141 + ux500_wdt_stop(&ux500_wdt); 142 + prcmu_config_a9wdog(PRCMU_WDOG_CPU1, false); 143 + 144 + prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); 145 + ux500_wdt_start(&ux500_wdt); 146 + } 147 + return 0; 148 + } 149 + #else 150 + #define ux500_wdt_suspend NULL 151 + #define ux500_wdt_resume NULL 152 + #endif 153 + 154 + static struct platform_driver ux500_wdt_driver = { 155 + .probe = ux500_wdt_probe, 156 + .remove = ux500_wdt_remove, 157 + .suspend = ux500_wdt_suspend, 158 + .resume = ux500_wdt_resume, 159 + .driver = { 160 + .owner = THIS_MODULE, 161 + .name = "ux500_wdt", 162 + }, 163 + }; 164 + 165 + module_platform_driver(ux500_wdt_driver); 166 + 167 + MODULE_AUTHOR("Jonas Aaberg <jonas.aberg@stericsson.com>"); 168 + MODULE_DESCRIPTION("Ux500 Watchdog Driver"); 169 + MODULE_LICENSE("GPL"); 170 + MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 171 + MODULE_ALIAS("platform:ux500_wdt");
+47 -41
include/linux/i2c/twl.h
··· 39 39 * address each module uses within a given i2c slave. 40 40 */ 41 41 42 + /* Module IDs for similar functionalities found in twl4030/twl6030 */ 43 + enum twl_module_ids { 44 + TWL_MODULE_USB, 45 + TWL_MODULE_PIH, 46 + TWL_MODULE_MAIN_CHARGE, 47 + TWL_MODULE_PM_MASTER, 48 + TWL_MODULE_PM_RECEIVER, 49 + 50 + TWL_MODULE_RTC, 51 + TWL_MODULE_PWM, 52 + TWL_MODULE_LED, 53 + TWL_MODULE_SECURED_REG, 54 + 55 + TWL_MODULE_LAST, 56 + }; 57 + 58 + /* Modules only available in twl4030 series */ 42 59 enum twl4030_module_ids { 43 - TWL4030_MODULE_USB = 0, /* Slave 0 (i2c address 0x48) */ 44 - TWL4030_MODULE_AUDIO_VOICE, /* Slave 1 (i2c address 0x49) */ 60 + TWL4030_MODULE_AUDIO_VOICE = TWL_MODULE_LAST, 45 61 TWL4030_MODULE_GPIO, 46 62 TWL4030_MODULE_INTBR, 47 - TWL4030_MODULE_PIH, 48 - 49 63 TWL4030_MODULE_TEST, 50 - TWL4030_MODULE_KEYPAD, /* Slave 2 (i2c address 0x4a) */ 64 + TWL4030_MODULE_KEYPAD, 65 + 51 66 TWL4030_MODULE_MADC, 52 67 TWL4030_MODULE_INTERRUPTS, 53 - TWL4030_MODULE_LED, 54 - 55 - TWL4030_MODULE_MAIN_CHARGE, 56 68 TWL4030_MODULE_PRECHARGE, 57 - TWL4030_MODULE_PWM0, 58 - TWL4030_MODULE_PWM1, 59 - TWL4030_MODULE_PWMA, 60 - 61 - TWL4030_MODULE_PWMB, 62 - TWL5031_MODULE_ACCESSORY, 63 - TWL5031_MODULE_INTERRUPTS, 64 - TWL4030_MODULE_BACKUP, /* Slave 3 (i2c address 0x4b) */ 69 + TWL4030_MODULE_BACKUP, 65 70 TWL4030_MODULE_INT, 66 71 67 - TWL4030_MODULE_PM_MASTER, 68 - TWL4030_MODULE_PM_RECEIVER, 69 - TWL4030_MODULE_RTC, 70 - TWL4030_MODULE_SECURED_REG, 72 + TWL5031_MODULE_ACCESSORY, 73 + TWL5031_MODULE_INTERRUPTS, 74 + 71 75 TWL4030_MODULE_LAST, 72 76 }; 73 77 74 - /* Similar functionalities implemented in TWL4030/6030 */ 75 - #define TWL_MODULE_USB TWL4030_MODULE_USB 76 - #define TWL_MODULE_PIH TWL4030_MODULE_PIH 77 - #define TWL_MODULE_MAIN_CHARGE TWL4030_MODULE_MAIN_CHARGE 78 - #define TWL_MODULE_PM_MASTER TWL4030_MODULE_PM_MASTER 79 - #define TWL_MODULE_PM_RECEIVER TWL4030_MODULE_PM_RECEIVER 80 - #define TWL_MODULE_RTC TWL4030_MODULE_RTC 81 - #define TWL_MODULE_PWM TWL4030_MODULE_PWM0 82 - #define TWL_MODULE_LED TWL4030_MODULE_LED 78 + /* Modules only available in twl6030 series */ 79 + enum twl6030_module_ids { 80 + TWL6030_MODULE_ID0 = TWL_MODULE_LAST, 81 + TWL6030_MODULE_ID1, 82 + TWL6030_MODULE_ID2, 83 + TWL6030_MODULE_GPADC, 84 + TWL6030_MODULE_GASGAUGE, 83 85 84 - #define TWL6030_MODULE_ID0 13 85 - #define TWL6030_MODULE_ID1 14 86 - #define TWL6030_MODULE_ID2 15 86 + TWL6030_MODULE_LAST, 87 + }; 88 + 89 + /* Until the clients has been converted to use TWL_MODULE_LED */ 90 + #define TWL4030_MODULE_LED TWL_MODULE_LED 87 91 88 92 #define GPIO_INTR_OFFSET 0 89 93 #define KEYPAD_INTR_OFFSET 1 ··· 175 171 TWL_CLASS_IS(6030, TWL6030_CLASS_ID) 176 172 177 173 /* 178 - * Read and write single 8-bit registers 179 - */ 180 - int twl_i2c_write_u8(u8 mod_no, u8 val, u8 reg); 181 - int twl_i2c_read_u8(u8 mod_no, u8 *val, u8 reg); 182 - 183 - /* 184 174 * Read and write several 8-bit registers at once. 185 - * 186 - * IMPORTANT: For twl_i2c_write(), allocate num_bytes + 1 187 - * for the value, and populate your data starting at offset 1. 188 175 */ 189 176 int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes); 190 177 int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes); 178 + 179 + /* 180 + * Read and write single 8-bit registers 181 + */ 182 + static inline int twl_i2c_write_u8(u8 mod_no, u8 val, u8 reg) { 183 + return twl_i2c_write(mod_no, &val, reg, 1); 184 + } 185 + 186 + static inline int twl_i2c_read_u8(u8 mod_no, u8 *val, u8 reg) { 187 + return twl_i2c_read(mod_no, val, reg, 1); 188 + } 191 189 192 190 int twl_get_type(void); 193 191 int twl_get_version(void);
+1 -1
include/linux/mfd/88pm80x.h
··· 365 365 366 366 extern int pm80x_init(struct i2c_client *client, 367 367 const struct i2c_device_id *id); 368 - extern int pm80x_deinit(struct i2c_client *client); 368 + extern int pm80x_deinit(void); 369 369 #endif /* __LINUX_MFD_88PM80X_H */
+2
include/linux/mfd/abx500.h
··· 311 311 int abx500_get_chip_id(struct device *dev); 312 312 int abx500_event_registers_startup_state_get(struct device *dev, u8 *event); 313 313 int abx500_startup_irq_enabled(struct device *dev, unsigned int irq); 314 + void abx500_dump_all_banks(void); 314 315 315 316 struct abx500_ops { 316 317 int (*get_chip_id) (struct device *); ··· 322 321 int (*mask_and_set_register) (struct device *, u8, u8, u8, u8); 323 322 int (*event_registers_startup_state_get) (struct device *, u8 *); 324 323 int (*startup_irq_enabled) (struct device *, unsigned int); 324 + void (*dump_all_banks) (struct device *); 325 325 }; 326 326 327 327 int abx500_register_ops(struct device *core_dev, struct abx500_ops *ops);
+5
include/linux/mfd/abx500/ab8500-sysctrl.h
··· 37 37 return ab8500_sysctrl_write(reg, bits, 0); 38 38 } 39 39 40 + /* Configuration data for SysClkReq1RfClkBuf - SysClkReq8RfClkBuf */ 41 + struct ab8500_sysctrl_platform_data { 42 + u8 initial_req_buf_config[8]; 43 + }; 44 + 40 45 /* Registers */ 41 46 #define AB8500_TURNONSTATUS 0x100 42 47 #define AB8500_RESETSTATUS 0x101
+12
include/linux/mfd/abx500/ab8500.h
··· 368 368 struct regulator_init_data; 369 369 struct ab8500_gpio_platform_data; 370 370 struct ab8500_codec_platform_data; 371 + struct ab8500_sysctrl_platform_data; 371 372 372 373 /** 373 374 * struct ab8500_platform_data - AB8500 platform data 374 375 * @irq_base: start of AB8500 IRQs, AB8500_NR_IRQS will be used 376 + * @pm_power_off: Should machine pm power off hook be registered or not 375 377 * @init: board-specific initialization after detection of ab8500 376 378 * @num_regulator_reg_init: number of regulator init registers 377 379 * @regulator_reg_init: regulator init registers ··· 382 380 */ 383 381 struct ab8500_platform_data { 384 382 int irq_base; 383 + bool pm_power_off; 385 384 void (*init) (struct ab8500 *); 386 385 int num_regulator_reg_init; 387 386 struct ab8500_regulator_reg_init *regulator_reg_init; ··· 390 387 struct regulator_init_data *regulator; 391 388 struct abx500_gpio_platform_data *gpio; 392 389 struct ab8500_codec_platform_data *codec; 390 + struct ab8500_sysctrl_platform_data *sysctrl; 393 391 }; 394 392 395 393 extern int ab8500_init(struct ab8500 *ab8500, ··· 511 507 { 512 508 return (is_ab9540(ab) && (ab->chip_id < AB8500_CUT2P0)); 513 509 } 510 + 511 + #ifdef CONFIG_AB8500_DEBUG 512 + void ab8500_dump_all_banks(struct device *dev); 513 + void ab8500_debug_register_interrupt(int line); 514 + #else 515 + static inline void ab8500_dump_all_banks(struct device *dev) {} 516 + static inline void ab8500_debug_register_interrupt(int line) {} 517 + #endif 514 518 515 519 #endif /* MFD_AB8500_H */
+12
include/linux/mfd/arizona/pdata.h
··· 56 56 #define ARIZONA_DMIC_MICBIAS2 2 57 57 #define ARIZONA_DMIC_MICBIAS3 3 58 58 59 + #define ARIZONA_MAX_MICBIAS 3 60 + 59 61 #define ARIZONA_INMODE_DIFF 0 60 62 #define ARIZONA_INMODE_SE 1 61 63 #define ARIZONA_INMODE_DMIC 2 ··· 72 70 #define ARIZONA_MAX_PDM_SPK 2 73 71 74 72 struct regulator_init_data; 73 + 74 + struct arizona_micbias { 75 + int mV; /** Regulated voltage */ 76 + unsigned int ext_cap:1; /** External capacitor fitted */ 77 + unsigned int discharge:1; /** Actively discharge */ 78 + unsigned int fast_start:1; /** Enable aggressive startup ramp rate */ 79 + }; 75 80 76 81 struct arizona_micd_config { 77 82 unsigned int src; ··· 144 135 145 136 /** Reference voltage for DMIC inputs */ 146 137 int dmic_ref[ARIZONA_MAX_INPUT]; 138 + 139 + /** MICBIAS configurations */ 140 + struct arizona_micbias micbias[ARIZONA_MAX_MICBIAS]; 147 141 148 142 /** Mode of input structures */ 149 143 int inmode[ARIZONA_MAX_INPUT];
+16
include/linux/mfd/arizona/registers.h
··· 984 984 #define ARIZONA_DSP1_STATUS_1 0x1104 985 985 #define ARIZONA_DSP1_STATUS_2 0x1105 986 986 #define ARIZONA_DSP1_STATUS_3 0x1106 987 + #define ARIZONA_DSP1_SCRATCH_0 0x1140 988 + #define ARIZONA_DSP1_SCRATCH_1 0x1141 989 + #define ARIZONA_DSP1_SCRATCH_2 0x1142 990 + #define ARIZONA_DSP1_SCRATCH_3 0x1143 987 991 #define ARIZONA_DSP2_CONTROL_1 0x1200 988 992 #define ARIZONA_DSP2_CLOCKING_1 0x1201 989 993 #define ARIZONA_DSP2_STATUS_1 0x1204 990 994 #define ARIZONA_DSP2_STATUS_2 0x1205 995 + #define ARIZONA_DSP2_SCRATCH_0 0x1240 996 + #define ARIZONA_DSP2_SCRATCH_1 0x1241 997 + #define ARIZONA_DSP2_SCRATCH_2 0x1242 998 + #define ARIZONA_DSP2_SCRATCH_3 0x1243 991 999 #define ARIZONA_DSP3_CONTROL_1 0x1300 992 1000 #define ARIZONA_DSP3_CLOCKING_1 0x1301 993 1001 #define ARIZONA_DSP3_STATUS_1 0x1304 994 1002 #define ARIZONA_DSP3_STATUS_2 0x1305 1003 + #define ARIZONA_DSP3_SCRATCH_0 0x1340 1004 + #define ARIZONA_DSP3_SCRATCH_1 0x1341 1005 + #define ARIZONA_DSP3_SCRATCH_2 0x1342 1006 + #define ARIZONA_DSP3_SCRATCH_3 0x1343 995 1007 #define ARIZONA_DSP4_CONTROL_1 0x1400 996 1008 #define ARIZONA_DSP4_CLOCKING_1 0x1401 997 1009 #define ARIZONA_DSP4_STATUS_1 0x1404 998 1010 #define ARIZONA_DSP4_STATUS_2 0x1405 1011 + #define ARIZONA_DSP4_SCRATCH_0 0x1440 1012 + #define ARIZONA_DSP4_SCRATCH_1 0x1441 1013 + #define ARIZONA_DSP4_SCRATCH_2 0x1442 1014 + #define ARIZONA_DSP4_SCRATCH_3 0x1443 999 1015 1000 1016 /* 1001 1017 * Field Definitions.
+12
include/linux/mfd/dbx500-prcmu.h
··· 151 151 }; 152 152 153 153 /** 154 + * enum prcmu_wdog_id - PRCMU watchdog IDs 155 + * @PRCMU_WDOG_ALL: use all timers 156 + * @PRCMU_WDOG_CPU1: use first CPU timer only 157 + * @PRCMU_WDOG_CPU2: use second CPU timer conly 158 + */ 159 + enum prcmu_wdog_id { 160 + PRCMU_WDOG_ALL = 0x00, 161 + PRCMU_WDOG_CPU1 = 0x01, 162 + PRCMU_WDOG_CPU2 = 0x02, 163 + }; 164 + 165 + /** 154 166 * enum ape_opp - APE OPP states definition 155 167 * @APE_OPP_INIT: 156 168 * @APE_NO_CHANGE: The APE operating point is unchanged
+2 -1
include/linux/mfd/max8925.h
··· 190 190 MAX8925_NR_IRQS, 191 191 }; 192 192 193 + 194 + 193 195 struct max8925_chip { 194 196 struct device *dev; 195 197 struct i2c_client *i2c; ··· 203 201 int irq_base; 204 202 int core_irq; 205 203 int tsc_irq; 206 - 207 204 unsigned int wakeup_flag; 208 205 }; 209 206
+52
include/linux/mfd/palmas.h
··· 2789 2789 #define PALMAS_GPADC_TRIM15 0xE 2790 2790 #define PALMAS_GPADC_TRIM16 0xF 2791 2791 2792 + static inline int palmas_read(struct palmas *palmas, unsigned int base, 2793 + unsigned int reg, unsigned int *val) 2794 + { 2795 + unsigned int addr = PALMAS_BASE_TO_REG(base, reg); 2796 + int slave_id = PALMAS_BASE_TO_SLAVE(base); 2797 + 2798 + return regmap_read(palmas->regmap[slave_id], addr, val); 2799 + } 2800 + 2801 + static inline int palmas_write(struct palmas *palmas, unsigned int base, 2802 + unsigned int reg, unsigned int value) 2803 + { 2804 + unsigned int addr = PALMAS_BASE_TO_REG(base, reg); 2805 + int slave_id = PALMAS_BASE_TO_SLAVE(base); 2806 + 2807 + return regmap_write(palmas->regmap[slave_id], addr, value); 2808 + } 2809 + 2810 + static inline int palmas_bulk_write(struct palmas *palmas, unsigned int base, 2811 + unsigned int reg, const void *val, size_t val_count) 2812 + { 2813 + unsigned int addr = PALMAS_BASE_TO_REG(base, reg); 2814 + int slave_id = PALMAS_BASE_TO_SLAVE(base); 2815 + 2816 + return regmap_bulk_write(palmas->regmap[slave_id], addr, 2817 + val, val_count); 2818 + } 2819 + 2820 + static inline int palmas_bulk_read(struct palmas *palmas, unsigned int base, 2821 + unsigned int reg, void *val, size_t val_count) 2822 + { 2823 + unsigned int addr = PALMAS_BASE_TO_REG(base, reg); 2824 + int slave_id = PALMAS_BASE_TO_SLAVE(base); 2825 + 2826 + return regmap_bulk_read(palmas->regmap[slave_id], addr, 2827 + val, val_count); 2828 + } 2829 + 2830 + static inline int palmas_update_bits(struct palmas *palmas, unsigned int base, 2831 + unsigned int reg, unsigned int mask, unsigned int val) 2832 + { 2833 + unsigned int addr = PALMAS_BASE_TO_REG(base, reg); 2834 + int slave_id = PALMAS_BASE_TO_SLAVE(base); 2835 + 2836 + return regmap_update_bits(palmas->regmap[slave_id], addr, mask, val); 2837 + } 2838 + 2839 + static inline int palmas_irq_get_virq(struct palmas *palmas, int irq) 2840 + { 2841 + return regmap_irq_get_virq(palmas->irq_data, irq); 2842 + } 2843 + 2792 2844 #endif /* __LINUX_MFD_PALMAS_H */
+8 -1
include/linux/mfd/rtsx_pci.h
··· 465 465 #define SD_RSP_TYPE_R6 0x01 466 466 #define SD_RSP_TYPE_R7 0x01 467 467 468 - /* SD_CONFIURE3 */ 468 + /* SD_CONFIGURE3 */ 469 469 #define SD_RSP_80CLK_TIMEOUT_EN 0x01 470 470 471 471 /* Card Transfer Reset Register */ ··· 581 581 #define CARD_GPIO_DIR 0xFD57 582 582 #define CARD_GPIO 0xFD58 583 583 #define CARD_DATA_SOURCE 0xFD5B 584 + #define SD30_CLK_DRIVE_SEL 0xFD5A 584 585 #define CARD_SELECT 0xFD5C 585 586 #define SD30_DRIVE_SEL 0xFD5E 587 + #define SD30_CMD_DRIVE_SEL 0xFD5E 588 + #define SD30_DAT_DRIVE_SEL 0xFD5F 586 589 #define CARD_CLK_EN 0xFD69 587 590 #define SDIO_CTRL 0xFD6B 588 591 #define CD_PAD_CTL 0xFD73 ··· 658 655 #define MSGTXDATA3 0xFE47 659 656 #define MSGTXCTL 0xFE48 660 657 #define PETXCFG 0xFE49 658 + #define LTR_CTL 0xFE4A 659 + #define OBFF_CFG 0xFE4C 661 660 662 661 #define CDRESUMECTL 0xFE52 663 662 #define WAKE_SEL_CTL 0xFE54 ··· 740 735 741 736 unsigned int card_inserted; 742 737 unsigned int card_removed; 738 + unsigned int card_exist; 743 739 744 740 struct delayed_work carddet_work; 745 741 struct delayed_work idle_work; ··· 805 799 u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk); 806 800 int rtsx_pci_card_power_on(struct rtsx_pcr *pcr, int card); 807 801 int rtsx_pci_card_power_off(struct rtsx_pcr *pcr, int card); 802 + int rtsx_pci_card_exclusive_check(struct rtsx_pcr *pcr, int card); 808 803 int rtsx_pci_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage); 809 804 unsigned int rtsx_pci_card_exist(struct rtsx_pcr *pcr); 810 805 void rtsx_pci_complete_unfinished_transfer(struct rtsx_pcr *pcr);
+1
include/linux/platform_data/usb-omap.h
··· 55 55 }; 56 56 57 57 struct usbhs_omap_platform_data { 58 + int nports; 58 59 enum usbhs_omap_port_mode port_mode[OMAP3_HS_USB_PORTS]; 59 60 int reset_gpio_port[OMAP3_HS_USB_PORTS]; 60 61 struct regulator *regulator[OMAP3_HS_USB_PORTS];
+19
include/linux/platform_data/ux500_wdt.h
··· 1 + /* 2 + * Copyright (C) ST Ericsson SA 2011 3 + * 4 + * License Terms: GNU General Public License v2 5 + * 6 + * STE Ux500 Watchdog platform data 7 + */ 8 + #ifndef __UX500_WDT_H 9 + #define __UX500_WDT_H 10 + 11 + /** 12 + * struct ux500_wdt_data 13 + */ 14 + struct ux500_wdt_data { 15 + unsigned int timeout; 16 + bool has_28_bits_resolution; 17 + }; 18 + 19 + #endif /* __UX500_WDT_H */
+8
include/linux/vexpress.h
··· 27 27 #define VEXPRESS_GPIO_MMC_CARDIN 0 28 28 #define VEXPRESS_GPIO_MMC_WPROT 1 29 29 #define VEXPRESS_GPIO_FLASH_WPn 2 30 + #define VEXPRESS_GPIO_LED0 3 31 + #define VEXPRESS_GPIO_LED1 4 32 + #define VEXPRESS_GPIO_LED2 5 33 + #define VEXPRESS_GPIO_LED3 6 34 + #define VEXPRESS_GPIO_LED4 7 35 + #define VEXPRESS_GPIO_LED5 8 36 + #define VEXPRESS_GPIO_LED6 9 37 + #define VEXPRESS_GPIO_LED7 10 30 38 31 39 #define VEXPRESS_RES_FUNC(_site, _func) \ 32 40 { \