diff options
41 files changed, 1911 insertions, 94 deletions
diff --git a/Documentation/devicetree/bindings/mfd/max77693.txt b/Documentation/devicetree/bindings/mfd/max77693.txt new file mode 100644 index 000000000000..11921cc417bf --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/max77693.txt | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | Maxim MAX77693 multi-function device | ||
| 2 | |||
| 3 | MAX77693 is a Multifunction device with the following submodules: | ||
| 4 | - PMIC, | ||
| 5 | - CHARGER, | ||
| 6 | - LED, | ||
| 7 | - MUIC, | ||
| 8 | - HAPTIC | ||
| 9 | |||
| 10 | It is interfaced to host controller using i2c. | ||
| 11 | This document describes the bindings for the mfd device. | ||
| 12 | |||
| 13 | Required properties: | ||
| 14 | - compatible : Must be "maxim,max77693". | ||
| 15 | - reg : Specifies the i2c slave address of PMIC block. | ||
| 16 | - interrupts : This i2c device has an IRQ line connected to the main SoC. | ||
| 17 | - interrupt-parent : The parent interrupt controller. | ||
| 18 | |||
| 19 | Optional properties: | ||
| 20 | - regulators : The regulators of max77693 have to be instantiated under subnod | ||
| 21 | named "regulators" using the following format. | ||
| 22 | |||
| 23 | regulators { | ||
| 24 | regualtor-compatible = ESAFEOUT1/ESAFEOUT2/CHARGER | ||
| 25 | standard regulator constratints[*]. | ||
| 26 | }; | ||
| 27 | |||
| 28 | [*] refer Documentation/devicetree/bindings/regulator/regulator.txt | ||
| 29 | |||
| 30 | Example: | ||
| 31 | max77693@66 { | ||
| 32 | compatible = "maxim,max77693"; | ||
| 33 | reg = <0x66>; | ||
| 34 | interrupt-parent = <&gpx1>; | ||
| 35 | interrupts = <5 2>; | ||
| 36 | |||
| 37 | regulators { | ||
| 38 | esafeout@1 { | ||
| 39 | regulator-compatible = "ESAFEOUT1"; | ||
| 40 | regulator-name = "ESAFEOUT1"; | ||
| 41 | regulator-boot-on; | ||
| 42 | }; | ||
| 43 | esafeout@2 { | ||
| 44 | regulator-compatible = "ESAFEOUT2"; | ||
| 45 | regulator-name = "ESAFEOUT2"; | ||
| 46 | }; | ||
| 47 | charger@0 { | ||
| 48 | regulator-compatible = "CHARGER"; | ||
| 49 | regulator-name = "CHARGER"; | ||
| 50 | regulator-min-microamp = <60000>; | ||
| 51 | regulator-max-microamp = <2580000>; | ||
| 52 | regulator-boot-on; | ||
| 53 | }; | ||
| 54 | }; | ||
| 55 | }; | ||
diff --git a/Documentation/devicetree/bindings/regulator/lp872x.txt b/Documentation/devicetree/bindings/regulator/lp872x.txt new file mode 100644 index 000000000000..78183182dad9 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/lp872x.txt | |||
| @@ -0,0 +1,160 @@ | |||
| 1 | Binding for TI/National Semiconductor LP872x Driver | ||
| 2 | |||
| 3 | Required properties: | ||
| 4 | - compatible: "ti,lp8720" or "ti,lp8725" | ||
| 5 | - reg: I2C slave address. 0x7d = LP8720, 0x7a = LP8725 | ||
| 6 | |||
| 7 | Optional properties: | ||
| 8 | - ti,general-config: the value of LP872X_GENERAL_CFG register (u8) | ||
| 9 | (LP8720) | ||
| 10 | bit[2]: BUCK output voltage control by external DVS pin or register | ||
| 11 | 1 = external pin, 0 = bit7 of register 08h | ||
| 12 | bit[1]: sleep control by external DVS pin or register | ||
| 13 | 1 = external pin, 0 = bit6 of register 08h | ||
| 14 | bit[0]: time step unit(usec). 1 = 25, 0 = 50 | ||
| 15 | |||
| 16 | (LP8725) | ||
| 17 | bit[7:6]: time step unit(usec). 00 = 32, 01 = 64, 10 = 128, 11 = 256 | ||
| 18 | bit[4]: BUCK2 enable control. 1 = enable, 0 = disable | ||
| 19 | bit[3]: BUCK2 output voltage register address. 1 = 0Ah, 0 = 0Bh | ||
| 20 | bit[2]: BUCK1 output voltage control by external DVS pin or register | ||
| 21 | 1 = register 08h, 0 = DVS | ||
| 22 | bit[1]: LDO sleep control. 1 = sleep mode, 0 = normal | ||
| 23 | bit[0]: BUCK1 enable control, 1 = enable, 0 = disable | ||
| 24 | |||
| 25 | For more details, please see the datasheet. | ||
| 26 | |||
| 27 | - ti,update-config: define it when LP872X_GENERAL_CFG register should be set | ||
| 28 | - ti,dvs-gpio: GPIO specifier for external DVS pin control of LP872x devices. | ||
| 29 | - ti,dvs-vsel: DVS selector. 0 = SEL_V1, 1 = SEL_V2. | ||
| 30 | - ti,dvs-state: initial DVS pin state. 0 = DVS_LOW, 1 = DVS_HIGH. | ||
| 31 | |||
| 32 | Sub nodes for regulator_init_data | ||
| 33 | LP8720 has maximum 6 nodes. (child name: ldo1 ~ 5 and buck) | ||
| 34 | LP8725 has maximum 9 nodes. (child name: ldo1 ~ 5, lilo1,2 and buck1,2) | ||
| 35 | For more details, please see the following binding document. | ||
| 36 | (Documentation/devicetree/bindings/regulator/regulator.txt) | ||
| 37 | |||
| 38 | Datasheet | ||
| 39 | - LP8720: http://www.ti.com/lit/ds/symlink/lp8720.pdf | ||
| 40 | - LP8725: http://www.ti.com/lit/ds/symlink/lp8725.pdf | ||
| 41 | |||
| 42 | Example 1) LP8720 | ||
| 43 | |||
| 44 | lp8720@7d { | ||
| 45 | compatible = "ti,lp8720"; | ||
| 46 | reg = <0x7d>; | ||
| 47 | |||
| 48 | /* external DVS pin used, timestep is 25usec */ | ||
| 49 | ti,general-config = /bits/ 8 <0x03>; | ||
| 50 | ti,update-config; | ||
| 51 | |||
| 52 | /* | ||
| 53 | * The dvs-gpio depends on the processor environment. | ||
| 54 | * For example, following GPIO specifier means GPIO134 in OMAP4. | ||
| 55 | */ | ||
| 56 | ti,dvs-gpio = <&gpio5 6 0>; | ||
| 57 | ti,dvs-vsel = /bits/ 8 <1>; /* SEL_V2 */ | ||
| 58 | ti,dvs-state = /bits/ 8 <1>; /* DVS_HIGH */ | ||
| 59 | |||
| 60 | vaf: ldo1 { | ||
| 61 | regulator-min-microvolt = <1200000>; | ||
| 62 | regulator-max-microvolt = <3300000>; | ||
| 63 | }; | ||
| 64 | |||
| 65 | vmmc: ldo2 { | ||
| 66 | regulator-min-microvolt = <1200000>; | ||
| 67 | regulator-max-microvolt = <3300000>; | ||
| 68 | }; | ||
| 69 | |||
| 70 | vcam_io: ldo3 { | ||
| 71 | regulator-min-microvolt = <1200000>; | ||
| 72 | regulator-max-microvolt = <3300000>; | ||
| 73 | regulator-boot-on; | ||
| 74 | }; | ||
| 75 | |||
| 76 | vcam_core: ldo4 { | ||
| 77 | regulator-min-microvolt = <800000>; | ||
| 78 | regulator-max-microvolt = <2850000>; | ||
| 79 | regulator-boot-on; | ||
| 80 | }; | ||
| 81 | |||
| 82 | vcam: ldo5 { | ||
| 83 | regulator-min-microvolt = <1200000>; | ||
| 84 | regulator-max-microvolt = <3300000>; | ||
| 85 | }; | ||
| 86 | |||
| 87 | vcc: buck { | ||
| 88 | regulator-name = "VBUCK"; | ||
| 89 | regulator-min-microvolt = <800000>; | ||
| 90 | regulator-max-microvolt = <2300000>; | ||
| 91 | }; | ||
| 92 | }; | ||
| 93 | |||
| 94 | Example 2) LP8725 | ||
| 95 | |||
| 96 | lp8725@7a { | ||
| 97 | compatible = "ti,lp8725"; | ||
| 98 | reg = <0x7a>; | ||
| 99 | |||
| 100 | /* Enable BUCK1,2, no DVS, normal LDO mode, timestep is 256usec */ | ||
| 101 | ti,general-config = /bits/ 8 <0xdd>; | ||
| 102 | ti,update-config; | ||
| 103 | |||
| 104 | vcam_io: ldo1 { | ||
| 105 | regulator-min-microvolt = <1200000>; | ||
| 106 | regulator-max-microvolt = <3300000>; | ||
| 107 | }; | ||
| 108 | |||
| 109 | vcam_core: ldo2 { | ||
| 110 | regulator-min-microvolt = <1200000>; | ||
| 111 | regulator-max-microvolt = <3300000>; | ||
| 112 | }; | ||
| 113 | |||
| 114 | vcam: ldo3 { | ||
| 115 | regulator-min-microvolt = <1200000>; | ||
| 116 | regulator-max-microvolt = <3300000>; | ||
| 117 | }; | ||
| 118 | |||
| 119 | vcmmb_io: ldo4 { | ||
| 120 | regulator-min-microvolt = <1200000>; | ||
| 121 | regulator-max-microvolt = <3300000>; | ||
| 122 | regulator-boot-on; | ||
| 123 | }; | ||
| 124 | |||
| 125 | vcmmb_core: ldo5 { | ||
| 126 | regulator-min-microvolt = <1200000>; | ||
| 127 | regulator-max-microvolt = <3300000>; | ||
| 128 | regulator-boot-on; | ||
| 129 | }; | ||
| 130 | |||
| 131 | vaux1: lilo1 { | ||
| 132 | regulator-name = "VAUX1"; | ||
| 133 | regulator-min-microvolt = <800000>; | ||
| 134 | regulator-max-microvolt = <3300000>; | ||
| 135 | }; | ||
| 136 | |||
| 137 | vaux2: lilo2 { | ||
| 138 | regulator-name = "VAUX2"; | ||
| 139 | regulator-min-microvolt = <800000>; | ||
| 140 | regulator-max-microvolt = <3300000>; | ||
| 141 | }; | ||
| 142 | |||
| 143 | vcc1: buck1 { | ||
| 144 | regulator-name = "VBUCK1"; | ||
| 145 | regulator-min-microvolt = <800000>; | ||
| 146 | regulator-max-microvolt = <3000000>; | ||
| 147 | regulator-min-microamp = <460000>; | ||
| 148 | regulator-max-microamp = <1370000>; | ||
| 149 | regulator-boot-on; | ||
| 150 | }; | ||
| 151 | |||
| 152 | vcc2: buck2 { | ||
| 153 | regulator-name = "VBUCK2"; | ||
| 154 | regulator-min-microvolt = <800000>; | ||
| 155 | regulator-max-microvolt = <3000000>; | ||
| 156 | regulator-min-microamp = <460000>; | ||
| 157 | regulator-max-microamp = <1370000>; | ||
| 158 | regulator-boot-on; | ||
| 159 | }; | ||
| 160 | }; | ||
diff --git a/Documentation/devicetree/bindings/regulator/max8973-regulator.txt b/Documentation/devicetree/bindings/regulator/max8973-regulator.txt new file mode 100644 index 000000000000..4f15d8a1bfd0 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/max8973-regulator.txt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | * Maxim MAX8973 Voltage Regulator | ||
| 2 | |||
| 3 | Required properties: | ||
| 4 | |||
| 5 | - compatible: must be "maxim,max8973" | ||
| 6 | - reg: the i2c slave address of the regulator. It should be 0x1b. | ||
| 7 | |||
| 8 | Any standard regulator properties can be used to configure the single max8973 | ||
| 9 | DCDC. | ||
| 10 | |||
| 11 | Example: | ||
| 12 | |||
| 13 | max8973@1b { | ||
| 14 | compatible = "maxim,max8973"; | ||
| 15 | reg = <0x1b>; | ||
| 16 | |||
| 17 | regulator-min-microvolt = <935000>; | ||
| 18 | regulator-max-microvolt = <1200000>; | ||
| 19 | regulator-boot-on; | ||
| 20 | regulator-always-on; | ||
| 21 | }; | ||
diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt index ecfc6ccd67ef..48a3b8e5d6bd 100644 --- a/Documentation/devicetree/bindings/regulator/regulator.txt +++ b/Documentation/devicetree/bindings/regulator/regulator.txt | |||
| @@ -9,6 +9,7 @@ Optional properties: | |||
| 9 | - regulator-max-microamp: largest current consumers may set | 9 | - regulator-max-microamp: largest current consumers may set |
| 10 | - regulator-always-on: boolean, regulator should never be disabled | 10 | - regulator-always-on: boolean, regulator should never be disabled |
| 11 | - regulator-boot-on: bootloader/firmware enabled regulator | 11 | - regulator-boot-on: bootloader/firmware enabled regulator |
| 12 | - regulator-allow-bypass: allow the regulator to go into bypass mode | ||
| 12 | - <name>-supply: phandle to the parent supply/regulator node | 13 | - <name>-supply: phandle to the parent supply/regulator node |
| 13 | - regulator-ramp-delay: ramp delay for regulator(in uV/uS) | 14 | - regulator-ramp-delay: ramp delay for regulator(in uV/uS) |
| 14 | 15 | ||
diff --git a/Documentation/devicetree/bindings/regulator/ti-abb-regulator.txt b/Documentation/devicetree/bindings/regulator/ti-abb-regulator.txt new file mode 100644 index 000000000000..2e57a33e9029 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/ti-abb-regulator.txt | |||
| @@ -0,0 +1,128 @@ | |||
| 1 | Adaptive Body Bias(ABB) SoC internal LDO regulator for Texas Instruments SoCs | ||
| 2 | |||
| 3 | Required Properties: | ||
| 4 | - compatible: Should be one of: | ||
| 5 | - "ti,abb-v1" for older SoCs like OMAP3 | ||
| 6 | - "ti,abb-v2" for newer SoCs like OMAP4, OMAP5 | ||
| 7 | - reg: Address and length of the register set for the device. It contains | ||
| 8 | the information of registers in the same order as described by reg-names | ||
| 9 | - reg-names: Should contain the reg names | ||
| 10 | - "base-address" - contains base address of ABB module | ||
| 11 | - "int-address" - contains address of interrupt register for ABB module | ||
| 12 | (also see Optional properties) | ||
| 13 | - #address-cell: should be 0 | ||
| 14 | - #size-cell: should be 0 | ||
| 15 | - clocks: should point to the clock node used by ABB module | ||
| 16 | - ti,settling-time: Settling time in uSecs from SoC documentation for ABB module | ||
| 17 | to settle down(target time for SR2_WTCNT_VALUE). | ||
| 18 | - ti,clock-cycles: SoC specific data about count of system ti,clock-cycles used for | ||
| 19 | computing settling time from SoC Documentation for ABB module(clock | ||
| 20 | cycles for SR2_WTCNT_VALUE). | ||
| 21 | - ti,tranxdone-status-mask: Mask to the int-register to write-to-clear mask | ||
| 22 | indicating LDO tranxdone (operation complete). | ||
| 23 | - ti,abb_info: An array of 6-tuples u32 items providing information about ABB | ||
| 24 | configuration needed per operational voltage of the device. | ||
| 25 | Each item consists of the following in the same order: | ||
| 26 | volt: voltage in uV - Only used to index ABB information. | ||
| 27 | ABB mode: one of the following: | ||
| 28 | 0-bypass | ||
| 29 | 1-Forward Body Bias(FBB) | ||
| 30 | 3-Reverse Body Bias(RBB) | ||
| 31 | efuse: (see Optional properties) | ||
| 32 | RBB enable efuse Mask: (See Optional properties) | ||
| 33 | FBB enable efuse Mask: (See Optional properties) | ||
| 34 | Vset value efuse Mask: (See Optional properties) | ||
| 35 | |||
| 36 | NOTE: If more than 1 entry is present, then regulator is setup to change | ||
| 37 | voltage, allowing for various modes to be selected indexed off | ||
| 38 | the regulator. Further, ABB LDOs are considered always-on by | ||
| 39 | default. | ||
| 40 | |||
| 41 | Optional Properties: | ||
| 42 | - reg-names: In addition to the required properties, the following are optional | ||
| 43 | - "efuse-address" - Contains efuse base address used to pick up ABB info. | ||
| 44 | - "ldo-address" - Contains address of ABB LDO overide register address. | ||
| 45 | "efuse-address" is required for this. | ||
| 46 | - ti,ldovbb-vset-mask - Required if ldo-address is set, mask for LDO override | ||
| 47 | register to provide override vset value. | ||
| 48 | - ti,ldovbb-override-mask - Required if ldo-address is set, mask for LDO | ||
| 49 | override register to enable override vset value. | ||
| 50 | - ti,abb_opp_sel: Addendum to the description in required properties | ||
| 51 | efuse: Mandatory if 'efuse-address' register is defined. Provides offset | ||
| 52 | from efuse-address to pick up ABB characteristics. Set to 0 if | ||
| 53 | 'efuse-address' is not defined. | ||
| 54 | RBB enable efuse Mask: Optional if 'efuse-address' register is defined. | ||
| 55 | 'ABB mode' is force set to RBB mode if value at "efuse-address" | ||
| 56 | + efuse maps to RBB mask. Set to 0 to ignore this. | ||
| 57 | FBB enable efuse Mask: Optional if 'efuse-address' register is defined. | ||
| 58 | 'ABB mode' is force set to FBB mode if value at "efuse-address" | ||
| 59 | + efuse maps to FBB mask (valid only if RBB mask does not match) | ||
| 60 | Set to 0 to ignore this. | ||
| 61 | Vset value efuse Mask: Mandatory if ldo-address is set. Picks up from | ||
| 62 | efuse the value to set in 'ti,ldovbb-vset-mask' at ldo-address. | ||
| 63 | |||
| 64 | Example #1: Simplest configuration (no efuse data, hard coded ABB table): | ||
| 65 | abb_x: regulator-abb-x { | ||
| 66 | compatible = "ti,abb-v1"; | ||
| 67 | regulator-name = "abb_x"; | ||
| 68 | #address-cell = <0>; | ||
| 69 | #size-cells = <0>; | ||
| 70 | reg = <0x483072f0 0x8>, <0x48306818 0x4>; | ||
| 71 | reg-names = "base-address", "int-address"; | ||
| 72 | ti,tranxdone-status-mask = <0x4000000>; | ||
| 73 | clocks = <&sysclk>; | ||
| 74 | ti,settling-time = <30>; | ||
| 75 | ti,clock-cycles = <8>; | ||
| 76 | ti,abb_info = < | ||
| 77 | /* uV ABB efuse rbb_m fbb_m vset_m */ | ||
| 78 | 1012500 0 0 0 0 0 /* Bypass */ | ||
| 79 | 1200000 3 0 0 0 0 /* RBB mandatory */ | ||
| 80 | 1320000 1 0 0 0 0 /* FBB mandatory */ | ||
| 81 | >; | ||
| 82 | }; | ||
| 83 | |||
| 84 | Example #2: Efuse bits contain ABB mode setting (no LDO override capability) | ||
| 85 | abb_y: regulator-abb-y { | ||
| 86 | compatible = "ti,abb-v2"; | ||
| 87 | regulator-name = "abb_y"; | ||
| 88 | #address-cell = <0>; | ||
| 89 | #size-cells = <0>; | ||
| 90 | reg = <0x4a307bd0 0x8>, <0x4a306014 0x4>, <0x4A002268 0x8>; | ||
| 91 | reg-names = "base-address", "int-address", "efuse-address"; | ||
| 92 | ti,tranxdone-status-mask = <0x4000000>; | ||
| 93 | clocks = <&sysclk>; | ||
| 94 | ti,settling-time = <50>; | ||
| 95 | ti,clock-cycles = <16>; | ||
| 96 | ti,abb_info = < | ||
| 97 | /* uV ABB efuse rbb_m fbb_m vset_m */ | ||
| 98 | 975000 0 0 0 0 0 /* Bypass */ | ||
| 99 | 1012500 0 0 0x40000 0 0 /* RBB optional */ | ||
| 100 | 1200000 0 0x4 0 0x40000 0 /* FBB optional */ | ||
| 101 | 1320000 1 0 0 0 0 /* FBB mandatory */ | ||
| 102 | >; | ||
| 103 | }; | ||
| 104 | |||
| 105 | Example #3: Efuse bits contain ABB mode setting and LDO override capability | ||
| 106 | abb_z: regulator-abb-z { | ||
| 107 | compatible = "ti,abb-v2"; | ||
| 108 | regulator-name = "abb_z"; | ||
| 109 | #address-cell = <0>; | ||
| 110 | #size-cells = <0>; | ||
| 111 | reg = <0x4ae07ce4 0x8>, <0x4ae06010 0x4>, | ||
| 112 | <0x4a002194 0x8>, <0x4ae0C314 0x4>; | ||
| 113 | reg-names = "base-address", "int-address", | ||
| 114 | "efuse-address", "ldo-address"; | ||
| 115 | ti,tranxdone-status-mask = <0x8000000>; | ||
| 116 | /* LDOVBBMM_MUX_CTRL */ | ||
| 117 | ti,ldovbb-override-mask = <0x400>; | ||
| 118 | /* LDOVBBMM_VSET_OUT */ | ||
| 119 | ti,ldovbb-vset-mask = <0x1F>; | ||
| 120 | clocks = <&sysclk>; | ||
| 121 | ti,settling-time = <50>; | ||
| 122 | ti,clock-cycles = <16>; | ||
| 123 | ti,abb_info = < | ||
| 124 | /* uV ABB efuse rbb_m fbb_m vset_m */ | ||
| 125 | 975000 0 0 0 0 0 /* Bypass */ | ||
| 126 | 1200000 0 0x4 0 0x40000 0x1f00 /* FBB optional, vset */ | ||
| 127 | >; | ||
| 128 | }; | ||
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c index 493948a38fca..8a7cb1f43046 100644 --- a/drivers/regulator/88pm8607.c +++ b/drivers/regulator/88pm8607.c | |||
| @@ -406,7 +406,6 @@ static int pm8607_regulator_remove(struct platform_device *pdev) | |||
| 406 | { | 406 | { |
| 407 | struct pm8607_regulator_info *info = platform_get_drvdata(pdev); | 407 | struct pm8607_regulator_info *info = platform_get_drvdata(pdev); |
| 408 | 408 | ||
| 409 | platform_set_drvdata(pdev, NULL); | ||
| 410 | regulator_unregister(info->regulator); | 409 | regulator_unregister(info->regulator); |
| 411 | return 0; | 410 | return 0; |
| 412 | } | 411 | } |
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 8bb26446037e..f1e6ad98eeba 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig | |||
| @@ -250,6 +250,15 @@ config REGULATOR_MAX77686 | |||
| 250 | via I2C bus. The provided regulator is suitable for | 250 | via I2C bus. The provided regulator is suitable for |
| 251 | Exynos-4 chips to control VARM and VINT voltages. | 251 | Exynos-4 chips to control VARM and VINT voltages. |
| 252 | 252 | ||
| 253 | config REGULATOR_MAX77693 | ||
| 254 | tristate "Maxim MAX77693 regulator" | ||
| 255 | depends on MFD_MAX77693 | ||
| 256 | help | ||
| 257 | This driver controls a Maxim 77693 regulator via I2C bus. | ||
| 258 | The regulators include two LDOs, 'SAFEOUT1', 'SAFEOUT2' | ||
| 259 | and one current regulator 'CHARGER'. This is suitable for | ||
| 260 | Exynos-4x12 chips. | ||
| 261 | |||
| 253 | config REGULATOR_PCAP | 262 | config REGULATOR_PCAP |
| 254 | tristate "Motorola PCAP2 regulator driver" | 263 | tristate "Motorola PCAP2 regulator driver" |
| 255 | depends on EZX_PCAP | 264 | depends on EZX_PCAP |
| @@ -472,6 +481,16 @@ config REGULATOR_TWL4030 | |||
| 472 | This driver supports the voltage regulators provided by | 481 | This driver supports the voltage regulators provided by |
| 473 | this family of companion chips. | 482 | this family of companion chips. |
| 474 | 483 | ||
| 484 | config REGULATOR_TI_ABB | ||
| 485 | bool "TI Adaptive Body Bias on-chip LDO" | ||
| 486 | depends on ARCH_OMAP | ||
| 487 | help | ||
| 488 | Select this option to support Texas Instruments' on-chip Adaptive Body | ||
| 489 | Bias (ABB) LDO regulators. It is recommended that this option be | ||
| 490 | enabled on required TI SoC. Certain Operating Performance Points | ||
| 491 | on TI SoCs may be unstable without enabling this as it provides | ||
| 492 | device specific optimized bias to allow/optimize functionality. | ||
| 493 | |||
| 475 | config REGULATOR_VEXPRESS | 494 | config REGULATOR_VEXPRESS |
| 476 | tristate "Versatile Express regulators" | 495 | tristate "Versatile Express regulators" |
| 477 | depends on VEXPRESS_CONFIG | 496 | depends on VEXPRESS_CONFIG |
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 47a34ff88f98..ba4a3cf3afec 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile | |||
| @@ -12,7 +12,7 @@ obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o | |||
| 12 | obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o | 12 | obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o |
| 13 | obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o | 13 | obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o |
| 14 | obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o | 14 | obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o |
| 15 | obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o ab8500-ext.o | 15 | obj-$(CONFIG_REGULATOR_AB8500) += ab8500-ext.o ab8500.o |
| 16 | obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o | 16 | obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o |
| 17 | obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o | 17 | obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o |
| 18 | obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o | 18 | obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o |
| @@ -41,6 +41,7 @@ obj-$(CONFIG_REGULATOR_MAX8973) += max8973-regulator.o | |||
| 41 | obj-$(CONFIG_REGULATOR_MAX8997) += max8997.o | 41 | obj-$(CONFIG_REGULATOR_MAX8997) += max8997.o |
| 42 | obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o | 42 | obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o |
| 43 | obj-$(CONFIG_REGULATOR_MAX77686) += max77686.o | 43 | obj-$(CONFIG_REGULATOR_MAX77686) += max77686.o |
| 44 | obj-$(CONFIG_REGULATOR_MAX77693) += max77693.o | ||
| 44 | obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o | 45 | obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o |
| 45 | obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o | 46 | obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o |
| 46 | obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o | 47 | obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o |
| @@ -63,6 +64,7 @@ obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o | |||
| 63 | obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o | 64 | obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o |
| 64 | obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o | 65 | obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o |
| 65 | obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o | 66 | obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o |
| 67 | obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o | ||
| 66 | obj-$(CONFIG_REGULATOR_VEXPRESS) += vexpress.o | 68 | obj-$(CONFIG_REGULATOR_VEXPRESS) += vexpress.o |
| 67 | obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o | 69 | obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o |
| 68 | obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o | 70 | obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o |
diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c index b4d45472aae6..02ff691cdb8b 100644 --- a/drivers/regulator/ab8500-ext.c +++ b/drivers/regulator/ab8500-ext.c | |||
| @@ -16,9 +16,11 @@ | |||
| 16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
| 17 | #include <linux/err.h> | 17 | #include <linux/err.h> |
| 18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
| 19 | #include <linux/of.h> | ||
| 19 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
| 20 | #include <linux/regulator/driver.h> | 21 | #include <linux/regulator/driver.h> |
| 21 | #include <linux/regulator/machine.h> | 22 | #include <linux/regulator/machine.h> |
| 23 | #include <linux/regulator/of_regulator.h> | ||
| 22 | #include <linux/mfd/abx500.h> | 24 | #include <linux/mfd/abx500.h> |
| 23 | #include <linux/mfd/abx500/ab8500.h> | 25 | #include <linux/mfd/abx500/ab8500.h> |
| 24 | #include <linux/regulator/ab8500.h> | 26 | #include <linux/regulator/ab8500.h> |
| @@ -229,6 +231,28 @@ static unsigned int ab8500_ext_regulator_get_mode(struct regulator_dev *rdev) | |||
| 229 | return ret; | 231 | return ret; |
| 230 | } | 232 | } |
| 231 | 233 | ||
| 234 | static int ab8500_ext_set_voltage(struct regulator_dev *rdev, int min_uV, | ||
| 235 | int max_uV, unsigned *selector) | ||
| 236 | { | ||
| 237 | struct regulation_constraints *regu_constraints = rdev->constraints; | ||
| 238 | |||
| 239 | if (!regu_constraints) { | ||
| 240 | dev_err(rdev_get_dev(rdev), "No regulator constraints\n"); | ||
| 241 | return -EINVAL; | ||
| 242 | } | ||
| 243 | |||
| 244 | if (regu_constraints->min_uV == min_uV && | ||
| 245 | regu_constraints->max_uV == max_uV) | ||
| 246 | return 0; | ||
| 247 | |||
| 248 | dev_err(rdev_get_dev(rdev), | ||
| 249 | "Requested min %duV max %duV != constrained min %duV max %duV\n", | ||
| 250 | min_uV, max_uV, | ||
| 251 | regu_constraints->min_uV, regu_constraints->max_uV); | ||
| 252 | |||
| 253 | return -EINVAL; | ||
| 254 | } | ||
| 255 | |||
| 232 | static int ab8500_ext_list_voltage(struct regulator_dev *rdev, | 256 | static int ab8500_ext_list_voltage(struct regulator_dev *rdev, |
| 233 | unsigned selector) | 257 | unsigned selector) |
| 234 | { | 258 | { |
| @@ -252,6 +276,7 @@ static struct regulator_ops ab8500_ext_regulator_ops = { | |||
| 252 | .is_enabled = ab8500_ext_regulator_is_enabled, | 276 | .is_enabled = ab8500_ext_regulator_is_enabled, |
| 253 | .set_mode = ab8500_ext_regulator_set_mode, | 277 | .set_mode = ab8500_ext_regulator_set_mode, |
| 254 | .get_mode = ab8500_ext_regulator_get_mode, | 278 | .get_mode = ab8500_ext_regulator_get_mode, |
| 279 | .set_voltage = ab8500_ext_set_voltage, | ||
| 255 | .list_voltage = ab8500_ext_list_voltage, | 280 | .list_voltage = ab8500_ext_list_voltage, |
| 256 | }; | 281 | }; |
| 257 | 282 | ||
| @@ -310,18 +335,37 @@ static struct ab8500_ext_regulator_info | |||
| 310 | }, | 335 | }, |
| 311 | }; | 336 | }; |
| 312 | 337 | ||
| 313 | int ab8500_ext_regulator_init(struct platform_device *pdev) | 338 | static struct of_regulator_match ab8500_ext_regulator_match[] = { |
| 339 | { .name = "ab8500_ext1", .driver_data = (void *) AB8500_EXT_SUPPLY1, }, | ||
| 340 | { .name = "ab8500_ext2", .driver_data = (void *) AB8500_EXT_SUPPLY2, }, | ||
| 341 | { .name = "ab8500_ext3", .driver_data = (void *) AB8500_EXT_SUPPLY3, }, | ||
| 342 | }; | ||
| 343 | |||
| 344 | static int ab8500_ext_regulator_probe(struct platform_device *pdev) | ||
| 314 | { | 345 | { |
| 315 | struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); | 346 | struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); |
| 316 | struct ab8500_platform_data *ppdata; | 347 | struct ab8500_platform_data *ppdata; |
| 317 | struct ab8500_regulator_platform_data *pdata; | 348 | struct ab8500_regulator_platform_data *pdata; |
| 349 | struct device_node *np = pdev->dev.of_node; | ||
| 318 | struct regulator_config config = { }; | 350 | struct regulator_config config = { }; |
| 319 | int i, err; | 351 | int i, err; |
| 320 | 352 | ||
| 353 | if (np) { | ||
| 354 | err = of_regulator_match(&pdev->dev, np, | ||
| 355 | ab8500_ext_regulator_match, | ||
| 356 | ARRAY_SIZE(ab8500_ext_regulator_match)); | ||
| 357 | if (err < 0) { | ||
| 358 | dev_err(&pdev->dev, | ||
| 359 | "Error parsing regulator init data: %d\n", err); | ||
| 360 | return err; | ||
| 361 | } | ||
| 362 | } | ||
| 363 | |||
| 321 | if (!ab8500) { | 364 | if (!ab8500) { |
| 322 | dev_err(&pdev->dev, "null mfd parent\n"); | 365 | dev_err(&pdev->dev, "null mfd parent\n"); |
| 323 | return -EINVAL; | 366 | return -EINVAL; |
| 324 | } | 367 | } |
| 368 | |||
| 325 | ppdata = dev_get_platdata(ab8500->dev); | 369 | ppdata = dev_get_platdata(ab8500->dev); |
| 326 | if (!ppdata) { | 370 | if (!ppdata) { |
| 327 | dev_err(&pdev->dev, "null parent pdata\n"); | 371 | dev_err(&pdev->dev, "null parent pdata\n"); |
| @@ -362,8 +406,11 @@ int ab8500_ext_regulator_init(struct platform_device *pdev) | |||
| 362 | pdata->ext_regulator[i].driver_data; | 406 | pdata->ext_regulator[i].driver_data; |
| 363 | 407 | ||
| 364 | config.dev = &pdev->dev; | 408 | config.dev = &pdev->dev; |
| 365 | config.init_data = &pdata->ext_regulator[i]; | ||
| 366 | config.driver_data = info; | 409 | config.driver_data = info; |
| 410 | config.of_node = ab8500_ext_regulator_match[i].of_node; | ||
| 411 | config.init_data = (np) ? | ||
| 412 | ab8500_ext_regulator_match[i].init_data : | ||
| 413 | &pdata->ext_regulator[i]; | ||
| 367 | 414 | ||
| 368 | /* register regulator with framework */ | 415 | /* register regulator with framework */ |
| 369 | info->rdev = regulator_register(&info->desc, &config); | 416 | info->rdev = regulator_register(&info->desc, &config); |
| @@ -386,7 +433,7 @@ int ab8500_ext_regulator_init(struct platform_device *pdev) | |||
| 386 | return 0; | 433 | return 0; |
| 387 | } | 434 | } |
| 388 | 435 | ||
| 389 | void ab8500_ext_regulator_exit(struct platform_device *pdev) | 436 | static int ab8500_ext_regulator_remove(struct platform_device *pdev) |
| 390 | { | 437 | { |
| 391 | int i; | 438 | int i; |
| 392 | 439 | ||
| @@ -399,7 +446,36 @@ void ab8500_ext_regulator_exit(struct platform_device *pdev) | |||
| 399 | 446 | ||
| 400 | regulator_unregister(info->rdev); | 447 | regulator_unregister(info->rdev); |
| 401 | } | 448 | } |
| 449 | |||
| 450 | return 0; | ||
| 451 | } | ||
| 452 | |||
| 453 | static struct platform_driver ab8500_ext_regulator_driver = { | ||
| 454 | .probe = ab8500_ext_regulator_probe, | ||
| 455 | .remove = ab8500_ext_regulator_remove, | ||
| 456 | .driver = { | ||
| 457 | .name = "ab8500-ext-regulator", | ||
| 458 | .owner = THIS_MODULE, | ||
| 459 | }, | ||
| 460 | }; | ||
| 461 | |||
| 462 | static int __init ab8500_ext_regulator_init(void) | ||
| 463 | { | ||
| 464 | int ret; | ||
| 465 | |||
| 466 | ret = platform_driver_register(&ab8500_ext_regulator_driver); | ||
| 467 | if (ret) | ||
| 468 | pr_err("Failed to register ab8500 ext regulator: %d\n", ret); | ||
| 469 | |||
| 470 | return ret; | ||
| 471 | } | ||
| 472 | subsys_initcall(ab8500_ext_regulator_init); | ||
| 473 | |||
| 474 | static void __exit ab8500_ext_regulator_exit(void) | ||
| 475 | { | ||
| 476 | platform_driver_unregister(&ab8500_ext_regulator_driver); | ||
| 402 | } | 477 | } |
| 478 | module_exit(ab8500_ext_regulator_exit); | ||
| 403 | 479 | ||
| 404 | MODULE_LICENSE("GPL v2"); | 480 | MODULE_LICENSE("GPL v2"); |
| 405 | MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>"); | 481 | MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>"); |
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index a19045ee0ec4..603f192e84f1 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c | |||
| @@ -719,6 +719,7 @@ static struct ab8500_regulator_info | |||
| 719 | .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), | 719 | .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), |
| 720 | .volt_table = ldo_vauxn_voltages, | 720 | .volt_table = ldo_vauxn_voltages, |
| 721 | .enable_time = 200, | 721 | .enable_time = 200, |
| 722 | .supply_name = "vin", | ||
| 722 | }, | 723 | }, |
| 723 | .load_lp_uA = 5000, | 724 | .load_lp_uA = 5000, |
| 724 | .update_bank = 0x04, | 725 | .update_bank = 0x04, |
| @@ -741,6 +742,7 @@ static struct ab8500_regulator_info | |||
| 741 | .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), | 742 | .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), |
| 742 | .volt_table = ldo_vauxn_voltages, | 743 | .volt_table = ldo_vauxn_voltages, |
| 743 | .enable_time = 200, | 744 | .enable_time = 200, |
| 745 | .supply_name = "vin", | ||
| 744 | }, | 746 | }, |
| 745 | .load_lp_uA = 5000, | 747 | .load_lp_uA = 5000, |
| 746 | .update_bank = 0x04, | 748 | .update_bank = 0x04, |
| @@ -763,6 +765,7 @@ static struct ab8500_regulator_info | |||
| 763 | .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages), | 765 | .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages), |
| 764 | .volt_table = ldo_vaux3_voltages, | 766 | .volt_table = ldo_vaux3_voltages, |
| 765 | .enable_time = 450, | 767 | .enable_time = 450, |
| 768 | .supply_name = "vin", | ||
| 766 | }, | 769 | }, |
| 767 | .load_lp_uA = 5000, | 770 | .load_lp_uA = 5000, |
| 768 | .update_bank = 0x04, | 771 | .update_bank = 0x04, |
| @@ -3156,22 +3159,12 @@ static int ab8500_regulator_probe(struct platform_device *pdev) | |||
| 3156 | return err; | 3159 | return err; |
| 3157 | } | 3160 | } |
| 3158 | 3161 | ||
| 3159 | if (!is_ab8505(ab8500)) { | ||
| 3160 | /* register external regulators (before Vaux1, 2 and 3) */ | ||
| 3161 | err = ab8500_ext_regulator_init(pdev); | ||
| 3162 | if (err) | ||
| 3163 | return err; | ||
| 3164 | } | ||
| 3165 | |||
| 3166 | /* register all regulators */ | 3162 | /* register all regulators */ |
| 3167 | for (i = 0; i < abx500_regulator.info_size; i++) { | 3163 | for (i = 0; i < abx500_regulator.info_size; i++) { |
| 3168 | err = ab8500_regulator_register(pdev, &pdata->regulator[i], | 3164 | err = ab8500_regulator_register(pdev, &pdata->regulator[i], |
| 3169 | i, NULL); | 3165 | i, NULL); |
| 3170 | if (err < 0) { | 3166 | if (err < 0) |
| 3171 | if (!is_ab8505(ab8500)) | ||
| 3172 | ab8500_ext_regulator_exit(pdev); | ||
| 3173 | return err; | 3167 | return err; |
| 3174 | } | ||
| 3175 | } | 3168 | } |
| 3176 | 3169 | ||
| 3177 | return 0; | 3170 | return 0; |
| @@ -3180,7 +3173,6 @@ static int ab8500_regulator_probe(struct platform_device *pdev) | |||
| 3180 | static int ab8500_regulator_remove(struct platform_device *pdev) | 3173 | static int ab8500_regulator_remove(struct platform_device *pdev) |
| 3181 | { | 3174 | { |
| 3182 | int i, err; | 3175 | int i, err; |
| 3183 | struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); | ||
| 3184 | 3176 | ||
| 3185 | for (i = 0; i < abx500_regulator.info_size; i++) { | 3177 | for (i = 0; i < abx500_regulator.info_size; i++) { |
| 3186 | struct ab8500_regulator_info *info = NULL; | 3178 | struct ab8500_regulator_info *info = NULL; |
| @@ -3192,10 +3184,6 @@ static int ab8500_regulator_remove(struct platform_device *pdev) | |||
| 3192 | regulator_unregister(info->regulator); | 3184 | regulator_unregister(info->regulator); |
| 3193 | } | 3185 | } |
| 3194 | 3186 | ||
| 3195 | /* remove external regulators (after Vaux1, 2 and 3) */ | ||
| 3196 | if (!is_ab8505(ab8500)) | ||
| 3197 | ab8500_ext_regulator_exit(pdev); | ||
| 3198 | |||
| 3199 | /* remove regulator debug */ | 3187 | /* remove regulator debug */ |
| 3200 | err = ab8500_regulator_debug_exit(pdev); | 3188 | err = ab8500_regulator_debug_exit(pdev); |
| 3201 | if (err) | 3189 | if (err) |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 815d6df8bd5f..288c75abc190 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
| @@ -2138,6 +2138,21 @@ int regulator_list_voltage(struct regulator *regulator, unsigned selector) | |||
| 2138 | EXPORT_SYMBOL_GPL(regulator_list_voltage); | 2138 | EXPORT_SYMBOL_GPL(regulator_list_voltage); |
| 2139 | 2139 | ||
| 2140 | /** | 2140 | /** |
| 2141 | * regulator_get_linear_step - return the voltage step size between VSEL values | ||
| 2142 | * @regulator: regulator source | ||
| 2143 | * | ||
| 2144 | * Returns the voltage step size between VSEL values for linear | ||
| 2145 | * regulators, or return 0 if the regulator isn't a linear regulator. | ||
| 2146 | */ | ||
| 2147 | unsigned int regulator_get_linear_step(struct regulator *regulator) | ||
| 2148 | { | ||
| 2149 | struct regulator_dev *rdev = regulator->rdev; | ||
| 2150 | |||
| 2151 | return rdev->desc->uV_step; | ||
| 2152 | } | ||
| 2153 | EXPORT_SYMBOL_GPL(regulator_get_linear_step); | ||
| 2154 | |||
| 2155 | /** | ||
| 2141 | * regulator_is_supported_voltage - check if a voltage range can be supported | 2156 | * regulator_is_supported_voltage - check if a voltage range can be supported |
| 2142 | * | 2157 | * |
| 2143 | * @regulator: Regulator to check. | 2158 | * @regulator: Regulator to check. |
diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c index d1e5bee2a26b..b99c49b9aff0 100644 --- a/drivers/regulator/isl6271a-regulator.c +++ b/drivers/regulator/isl6271a-regulator.c | |||
| @@ -130,7 +130,7 @@ static int isl6271a_probe(struct i2c_client *i2c, | |||
| 130 | if (i == 0) | 130 | if (i == 0) |
| 131 | config.init_data = init_data; | 131 | config.init_data = init_data; |
| 132 | else | 132 | else |
| 133 | config.init_data = 0; | 133 | config.init_data = NULL; |
| 134 | config.driver_data = pmic; | 134 | config.driver_data = pmic; |
| 135 | 135 | ||
| 136 | pmic->rdev[i] = regulator_register(&isl_rd[i], &config); | 136 | pmic->rdev[i] = regulator_register(&isl_rd[i], &config); |
diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c index d8af9e773310..3809b4381606 100644 --- a/drivers/regulator/lp3971.c +++ b/drivers/regulator/lp3971.c | |||
| @@ -434,7 +434,7 @@ static int lp3971_i2c_probe(struct i2c_client *i2c, | |||
| 434 | return -ENODEV; | 434 | return -ENODEV; |
| 435 | } | 435 | } |
| 436 | 436 | ||
| 437 | lp3971 = kzalloc(sizeof(struct lp3971), GFP_KERNEL); | 437 | lp3971 = devm_kzalloc(&i2c->dev, sizeof(struct lp3971), GFP_KERNEL); |
| 438 | if (lp3971 == NULL) | 438 | if (lp3971 == NULL) |
| 439 | return -ENOMEM; | 439 | return -ENOMEM; |
| 440 | 440 | ||
| @@ -449,19 +449,15 @@ static int lp3971_i2c_probe(struct i2c_client *i2c, | |||
| 449 | ret = -ENODEV; | 449 | ret = -ENODEV; |
| 450 | if (ret < 0) { | 450 | if (ret < 0) { |
| 451 | dev_err(&i2c->dev, "failed to detect device\n"); | 451 | dev_err(&i2c->dev, "failed to detect device\n"); |
| 452 | goto err_detect; | 452 | return ret; |
| 453 | } | 453 | } |
| 454 | 454 | ||
| 455 | ret = setup_regulators(lp3971, pdata); | 455 | ret = setup_regulators(lp3971, pdata); |
| 456 | if (ret < 0) | 456 | if (ret < 0) |
| 457 | goto err_detect; | 457 | return ret; |
| 458 | 458 | ||
| 459 | i2c_set_clientdata(i2c, lp3971); | 459 | i2c_set_clientdata(i2c, lp3971); |
| 460 | return 0; | 460 | return 0; |
| 461 | |||
| 462 | err_detect: | ||
| 463 | kfree(lp3971); | ||
| 464 | return ret; | ||
| 465 | } | 461 | } |
| 466 | 462 | ||
| 467 | static int lp3971_i2c_remove(struct i2c_client *i2c) | 463 | static int lp3971_i2c_remove(struct i2c_client *i2c) |
| @@ -473,7 +469,6 @@ static int lp3971_i2c_remove(struct i2c_client *i2c) | |||
| 473 | regulator_unregister(lp3971->rdev[i]); | 469 | regulator_unregister(lp3971->rdev[i]); |
| 474 | 470 | ||
| 475 | kfree(lp3971->rdev); | 471 | kfree(lp3971->rdev); |
| 476 | kfree(lp3971); | ||
| 477 | 472 | ||
| 478 | return 0; | 473 | return 0; |
| 479 | } | 474 | } |
diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c index 61e4cf9edf6e..573024039ca0 100644 --- a/drivers/regulator/lp3972.c +++ b/drivers/regulator/lp3972.c | |||
| @@ -528,7 +528,7 @@ static int lp3972_i2c_probe(struct i2c_client *i2c, | |||
| 528 | return -ENODEV; | 528 | return -ENODEV; |
| 529 | } | 529 | } |
| 530 | 530 | ||
| 531 | lp3972 = kzalloc(sizeof(struct lp3972), GFP_KERNEL); | 531 | lp3972 = devm_kzalloc(&i2c->dev, sizeof(struct lp3972), GFP_KERNEL); |
| 532 | if (!lp3972) | 532 | if (!lp3972) |
| 533 | return -ENOMEM; | 533 | return -ENOMEM; |
| 534 | 534 | ||
| @@ -546,19 +546,15 @@ static int lp3972_i2c_probe(struct i2c_client *i2c, | |||
| 546 | } | 546 | } |
| 547 | if (ret < 0) { | 547 | if (ret < 0) { |
| 548 | dev_err(&i2c->dev, "failed to detect device. ret = %d\n", ret); | 548 | dev_err(&i2c->dev, "failed to detect device. ret = %d\n", ret); |
| 549 | goto err_detect; | 549 | return ret; |
| 550 | } | 550 | } |
| 551 | 551 | ||
| 552 | ret = setup_regulators(lp3972, pdata); | 552 | ret = setup_regulators(lp3972, pdata); |
| 553 | if (ret < 0) | 553 | if (ret < 0) |
| 554 | goto err_detect; | 554 | return ret; |
| 555 | 555 | ||
| 556 | i2c_set_clientdata(i2c, lp3972); | 556 | i2c_set_clientdata(i2c, lp3972); |
| 557 | return 0; | 557 | return 0; |
| 558 | |||
| 559 | err_detect: | ||
| 560 | kfree(lp3972); | ||
| 561 | return ret; | ||
| 562 | } | 558 | } |
| 563 | 559 | ||
| 564 | static int lp3972_i2c_remove(struct i2c_client *i2c) | 560 | static int lp3972_i2c_remove(struct i2c_client *i2c) |
| @@ -569,7 +565,6 @@ static int lp3972_i2c_remove(struct i2c_client *i2c) | |||
| 569 | for (i = 0; i < lp3972->num_regulators; i++) | 565 | for (i = 0; i < lp3972->num_regulators; i++) |
| 570 | regulator_unregister(lp3972->rdev[i]); | 566 | regulator_unregister(lp3972->rdev[i]); |
| 571 | kfree(lp3972->rdev); | 567 | kfree(lp3972->rdev); |
| 572 | kfree(lp3972); | ||
| 573 | 568 | ||
| 574 | return 0; | 569 | return 0; |
| 575 | } | 570 | } |
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c index f5fc4a142cdf..b16336bcd4d4 100644 --- a/drivers/regulator/lp872x.c +++ b/drivers/regulator/lp872x.c | |||
| @@ -18,6 +18,9 @@ | |||
| 18 | #include <linux/regulator/lp872x.h> | 18 | #include <linux/regulator/lp872x.h> |
| 19 | #include <linux/regulator/driver.h> | 19 | #include <linux/regulator/driver.h> |
| 20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
| 21 | #include <linux/of.h> | ||
| 22 | #include <linux/of_gpio.h> | ||
| 23 | #include <linux/regulator/of_regulator.h> | ||
| 21 | 24 | ||
| 22 | /* Registers : LP8720/8725 shared */ | 25 | /* Registers : LP8720/8725 shared */ |
| 23 | #define LP872X_GENERAL_CFG 0x00 | 26 | #define LP872X_GENERAL_CFG 0x00 |
| @@ -723,8 +726,8 @@ static int lp872x_init_dvs(struct lp872x *lp) | |||
| 723 | 726 | ||
| 724 | gpio = dvs->gpio; | 727 | gpio = dvs->gpio; |
| 725 | if (!gpio_is_valid(gpio)) { | 728 | if (!gpio_is_valid(gpio)) { |
| 726 | dev_err(lp->dev, "invalid gpio: %d\n", gpio); | 729 | dev_warn(lp->dev, "invalid gpio: %d\n", gpio); |
| 727 | return -EINVAL; | 730 | goto set_default_dvs_mode; |
| 728 | } | 731 | } |
| 729 | 732 | ||
| 730 | pinstate = dvs->init_state; | 733 | pinstate = dvs->init_state; |
| @@ -829,6 +832,103 @@ static const struct regmap_config lp872x_regmap_config = { | |||
| 829 | .max_register = MAX_REGISTERS, | 832 | .max_register = MAX_REGISTERS, |
| 830 | }; | 833 | }; |
| 831 | 834 | ||
| 835 | #ifdef CONFIG_OF | ||
| 836 | |||
| 837 | #define LP872X_VALID_OPMODE (REGULATOR_MODE_FAST | REGULATOR_MODE_NORMAL) | ||
| 838 | |||
| 839 | static struct of_regulator_match lp8720_matches[] = { | ||
| 840 | { .name = "ldo1", .driver_data = (void *)LP8720_ID_LDO1, }, | ||
| 841 | { .name = "ldo2", .driver_data = (void *)LP8720_ID_LDO2, }, | ||
| 842 | { .name = "ldo3", .driver_data = (void *)LP8720_ID_LDO3, }, | ||
| 843 | { .name = "ldo4", .driver_data = (void *)LP8720_ID_LDO4, }, | ||
| 844 | { .name = "ldo5", .driver_data = (void *)LP8720_ID_LDO5, }, | ||
| 845 | { .name = "buck", .driver_data = (void *)LP8720_ID_BUCK, }, | ||
| 846 | }; | ||
| 847 | |||
| 848 | static struct of_regulator_match lp8725_matches[] = { | ||
| 849 | { .name = "ldo1", .driver_data = (void *)LP8725_ID_LDO1, }, | ||
| 850 | { .name = "ldo2", .driver_data = (void *)LP8725_ID_LDO2, }, | ||
| 851 | { .name = "ldo3", .driver_data = (void *)LP8725_ID_LDO3, }, | ||
| 852 | { .name = "ldo4", .driver_data = (void *)LP8725_ID_LDO4, }, | ||
| 853 | { .name = "ldo5", .driver_data = (void *)LP8725_ID_LDO5, }, | ||
| 854 | { .name = "lilo1", .driver_data = (void *)LP8725_ID_LILO1, }, | ||
| 855 | { .name = "lilo2", .driver_data = (void *)LP8725_ID_LILO2, }, | ||
| 856 | { .name = "buck1", .driver_data = (void *)LP8725_ID_BUCK1, }, | ||
| 857 | { .name = "buck2", .driver_data = (void *)LP8725_ID_BUCK2, }, | ||
| 858 | }; | ||
| 859 | |||
| 860 | static struct lp872x_platform_data | ||
| 861 | *lp872x_populate_pdata_from_dt(struct device *dev, enum lp872x_id which) | ||
| 862 | { | ||
| 863 | struct device_node *np = dev->of_node; | ||
| 864 | struct lp872x_platform_data *pdata; | ||
| 865 | struct of_regulator_match *match; | ||
| 866 | struct regulator_init_data *d; | ||
| 867 | int num_matches; | ||
| 868 | int count; | ||
| 869 | int i; | ||
| 870 | u8 dvs_state; | ||
| 871 | |||
| 872 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | ||
| 873 | if (!pdata) | ||
| 874 | goto out; | ||
| 875 | |||
| 876 | of_property_read_u8(np, "ti,general-config", &pdata->general_config); | ||
| 877 | if (of_find_property(np, "ti,update-config", NULL)) | ||
| 878 | pdata->update_config = true; | ||
| 879 | |||
| 880 | pdata->dvs = devm_kzalloc(dev, sizeof(struct lp872x_dvs), GFP_KERNEL); | ||
| 881 | if (!pdata->dvs) | ||
| 882 | goto out; | ||
| 883 | |||
| 884 | pdata->dvs->gpio = of_get_named_gpio(np, "ti,dvs-gpio", 0); | ||
| 885 | of_property_read_u8(np, "ti,dvs-vsel", (u8 *)&pdata->dvs->vsel); | ||
| 886 | of_property_read_u8(np, "ti,dvs-state", &dvs_state); | ||
| 887 | pdata->dvs->init_state = dvs_state ? DVS_HIGH : DVS_LOW; | ||
| 888 | |||
| 889 | if (of_get_child_count(np) == 0) | ||
| 890 | goto out; | ||
| 891 | |||
| 892 | switch (which) { | ||
| 893 | case LP8720: | ||
| 894 | match = lp8720_matches; | ||
| 895 | num_matches = ARRAY_SIZE(lp8720_matches); | ||
| 896 | break; | ||
| 897 | case LP8725: | ||
| 898 | match = lp8725_matches; | ||
| 899 | num_matches = ARRAY_SIZE(lp8725_matches); | ||
| 900 | break; | ||
| 901 | default: | ||
| 902 | goto out; | ||
| 903 | } | ||
| 904 | |||
| 905 | count = of_regulator_match(dev, np, match, num_matches); | ||
| 906 | if (count <= 0) | ||
| 907 | goto out; | ||
| 908 | |||
| 909 | for (i = 0; i < num_matches; i++) { | ||
| 910 | pdata->regulator_data[i].id = (int)match[i].driver_data; | ||
| 911 | pdata->regulator_data[i].init_data = match[i].init_data; | ||
| 912 | |||
| 913 | /* Operation mode configuration for buck/buck1/buck2 */ | ||
| 914 | if (strncmp(match[i].name, "buck", 4)) | ||
| 915 | continue; | ||
| 916 | |||
| 917 | d = pdata->regulator_data[i].init_data; | ||
| 918 | d->constraints.valid_modes_mask |= LP872X_VALID_OPMODE; | ||
| 919 | d->constraints.valid_ops_mask |= REGULATOR_CHANGE_MODE; | ||
| 920 | } | ||
| 921 | out: | ||
| 922 | return pdata; | ||
| 923 | } | ||
| 924 | #else | ||
| 925 | static struct lp872x_platform_data | ||
| 926 | *lp872x_populate_pdata_from_dt(struct device *dev, enum lp872x_id which) | ||
| 927 | { | ||
| 928 | return NULL; | ||
| 929 | } | ||
| 930 | #endif | ||
| 931 | |||
| 832 | static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id) | 932 | static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id) |
| 833 | { | 933 | { |
| 834 | struct lp872x *lp; | 934 | struct lp872x *lp; |
| @@ -838,6 +938,10 @@ static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id) | |||
| 838 | [LP8725] = LP8725_NUM_REGULATORS, | 938 | [LP8725] = LP8725_NUM_REGULATORS, |
| 839 | }; | 939 | }; |
| 840 | 940 | ||
| 941 | if (cl->dev.of_node) | ||
| 942 | cl->dev.platform_data = lp872x_populate_pdata_from_dt(&cl->dev, | ||
| 943 | (enum lp872x_id)id->driver_data); | ||
| 944 | |||
| 841 | lp = devm_kzalloc(&cl->dev, sizeof(struct lp872x), GFP_KERNEL); | 945 | lp = devm_kzalloc(&cl->dev, sizeof(struct lp872x), GFP_KERNEL); |
| 842 | if (!lp) | 946 | if (!lp) |
| 843 | goto err_mem; | 947 | goto err_mem; |
| @@ -882,6 +986,13 @@ static int lp872x_remove(struct i2c_client *cl) | |||
| 882 | return 0; | 986 | return 0; |
| 883 | } | 987 | } |
| 884 | 988 | ||
| 989 | static const struct of_device_id lp872x_dt_ids[] = { | ||
| 990 | { .compatible = "ti,lp8720", }, | ||
| 991 | { .compatible = "ti,lp8725", }, | ||
| 992 | { } | ||
| 993 | }; | ||
| 994 | MODULE_DEVICE_TABLE(of, lp872x_dt_ids); | ||
| 995 | |||
| 885 | static const struct i2c_device_id lp872x_ids[] = { | 996 | static const struct i2c_device_id lp872x_ids[] = { |
| 886 | {"lp8720", LP8720}, | 997 | {"lp8720", LP8720}, |
| 887 | {"lp8725", LP8725}, | 998 | {"lp8725", LP8725}, |
| @@ -893,6 +1004,7 @@ static struct i2c_driver lp872x_driver = { | |||
| 893 | .driver = { | 1004 | .driver = { |
| 894 | .name = "lp872x", | 1005 | .name = "lp872x", |
| 895 | .owner = THIS_MODULE, | 1006 | .owner = THIS_MODULE, |
| 1007 | .of_match_table = of_match_ptr(lp872x_dt_ids), | ||
| 896 | }, | 1008 | }, |
| 897 | .probe = lp872x_probe, | 1009 | .probe = lp872x_probe, |
| 898 | .remove = lp872x_remove, | 1010 | .remove = lp872x_remove, |
diff --git a/drivers/regulator/lp8755.c b/drivers/regulator/lp8755.c index f0f6ea05065b..d9e38b4c2adc 100644 --- a/drivers/regulator/lp8755.c +++ b/drivers/regulator/lp8755.c | |||
| @@ -19,7 +19,6 @@ | |||
| 19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
| 20 | #include <linux/gpio.h> | 20 | #include <linux/gpio.h> |
| 21 | #include <linux/regmap.h> | 21 | #include <linux/regmap.h> |
| 22 | #include <linux/delay.h> | ||
| 23 | #include <linux/uaccess.h> | 22 | #include <linux/uaccess.h> |
| 24 | #include <linux/regulator/driver.h> | 23 | #include <linux/regulator/driver.h> |
| 25 | #include <linux/regulator/machine.h> | 24 | #include <linux/regulator/machine.h> |
diff --git a/drivers/regulator/lp8788-buck.c b/drivers/regulator/lp8788-buck.c index eb1e1e88ae51..0b015f2a7fd9 100644 --- a/drivers/regulator/lp8788-buck.c +++ b/drivers/regulator/lp8788-buck.c | |||
| @@ -533,7 +533,6 @@ static int lp8788_buck_remove(struct platform_device *pdev) | |||
| 533 | { | 533 | { |
| 534 | struct lp8788_buck *buck = platform_get_drvdata(pdev); | 534 | struct lp8788_buck *buck = platform_get_drvdata(pdev); |
| 535 | 535 | ||
| 536 | platform_set_drvdata(pdev, NULL); | ||
| 537 | regulator_unregister(buck->regulator); | 536 | regulator_unregister(buck->regulator); |
| 538 | 537 | ||
| 539 | return 0; | 538 | return 0; |
diff --git a/drivers/regulator/lp8788-ldo.c b/drivers/regulator/lp8788-ldo.c index 0ce2c4c194b3..0527d87c6dd5 100644 --- a/drivers/regulator/lp8788-ldo.c +++ b/drivers/regulator/lp8788-ldo.c | |||
| @@ -561,7 +561,6 @@ static int lp8788_dldo_remove(struct platform_device *pdev) | |||
| 561 | { | 561 | { |
| 562 | struct lp8788_ldo *ldo = platform_get_drvdata(pdev); | 562 | struct lp8788_ldo *ldo = platform_get_drvdata(pdev); |
| 563 | 563 | ||
| 564 | platform_set_drvdata(pdev, NULL); | ||
| 565 | regulator_unregister(ldo->regulator); | 564 | regulator_unregister(ldo->regulator); |
| 566 | 565 | ||
| 567 | return 0; | 566 | return 0; |
| @@ -622,7 +621,6 @@ static int lp8788_aldo_remove(struct platform_device *pdev) | |||
| 622 | { | 621 | { |
| 623 | struct lp8788_ldo *ldo = platform_get_drvdata(pdev); | 622 | struct lp8788_ldo *ldo = platform_get_drvdata(pdev); |
| 624 | 623 | ||
| 625 | platform_set_drvdata(pdev, NULL); | ||
| 626 | regulator_unregister(ldo->regulator); | 624 | regulator_unregister(ldo->regulator); |
| 627 | 625 | ||
| 628 | return 0; | 626 | return 0; |
diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index 20935b1a6ed4..f563057e5690 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c | |||
| @@ -24,7 +24,6 @@ | |||
| 24 | 24 | ||
| 25 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
| 26 | #include <linux/bug.h> | 26 | #include <linux/bug.h> |
| 27 | #include <linux/delay.h> | ||
| 28 | #include <linux/err.h> | 27 | #include <linux/err.h> |
| 29 | #include <linux/gpio.h> | 28 | #include <linux/gpio.h> |
| 30 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
diff --git a/drivers/regulator/max77693.c b/drivers/regulator/max77693.c new file mode 100644 index 000000000000..ce4b96c15eba --- /dev/null +++ b/drivers/regulator/max77693.c | |||
| @@ -0,0 +1,322 @@ | |||
| 1 | /* | ||
| 2 | * max77693.c - Regulator driver for the Maxim 77693 | ||
| 3 | * | ||
| 4 | * Copyright (C) 2013 Samsung Electronics | ||
| 5 | * Jonghwa Lee <jonghwa3.lee@samsung.com> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2 of the License, or | ||
| 10 | * (at your option) any later version. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 20 | * | ||
| 21 | * This driver is based on max77686.c | ||
| 22 | */ | ||
| 23 | |||
| 24 | #include <linux/err.h> | ||
| 25 | #include <linux/slab.h> | ||
| 26 | #include <linux/platform_device.h> | ||
| 27 | #include <linux/module.h> | ||
| 28 | #include <linux/export.h> | ||
| 29 | #include <linux/regulator/driver.h> | ||
| 30 | #include <linux/regulator/machine.h> | ||
| 31 | #include <linux/mfd/max77693.h> | ||
| 32 | #include <linux/mfd/max77693-private.h> | ||
| 33 | #include <linux/regulator/of_regulator.h> | ||
| 34 | |||
| 35 | #define CHGIN_ILIM_STEP_20mA 20000 | ||
| 36 | |||
| 37 | struct max77693_pmic_dev { | ||
| 38 | struct device *dev; | ||
| 39 | struct max77693_dev *iodev; | ||
| 40 | int num_regulators; | ||
| 41 | struct regulator_dev **rdev; | ||
| 42 | }; | ||
| 43 | |||
| 44 | /* CHARGER regulator ops */ | ||
| 45 | /* CHARGER regulator uses two bits for enabling */ | ||
| 46 | static int max77693_chg_is_enabled(struct regulator_dev *rdev) | ||
| 47 | { | ||
| 48 | int ret; | ||
| 49 | u8 val; | ||
| 50 | |||
| 51 | ret = max77693_read_reg(rdev->regmap, rdev->desc->enable_reg, &val); | ||
| 52 | if (ret) | ||
| 53 | return ret; | ||
| 54 | |||
| 55 | return (val & rdev->desc->enable_mask) == rdev->desc->enable_mask; | ||
| 56 | } | ||
| 57 | |||
| 58 | /* | ||
| 59 | * CHARGER regulator - Min : 20mA, Max : 2580mA, step : 20mA | ||
| 60 | * 0x00, 0x01, 0x2, 0x03 = 60 mA | ||
| 61 | * 0x04 ~ 0x7E = (60 + (X - 3) * 20) mA | ||
| 62 | */ | ||
| 63 | static int max77693_chg_get_current_limit(struct regulator_dev *rdev) | ||
| 64 | { | ||
| 65 | unsigned int chg_min_uA = rdev->constraints->min_uA; | ||
| 66 | unsigned int chg_max_uA = rdev->constraints->max_uA; | ||
| 67 | u8 reg, sel; | ||
| 68 | unsigned int val; | ||
| 69 | int ret; | ||
| 70 | |||
| 71 | ret = max77693_read_reg(rdev->regmap, | ||
| 72 | MAX77693_CHG_REG_CHG_CNFG_09, ®); | ||
| 73 | if (ret < 0) | ||
| 74 | return ret; | ||
| 75 | |||
| 76 | sel = reg & CHG_CNFG_09_CHGIN_ILIM_MASK; | ||
| 77 | |||
| 78 | /* the first four codes for charger current are all 60mA */ | ||
| 79 | if (sel <= 3) | ||
| 80 | sel = 0; | ||
| 81 | else | ||
| 82 | sel -= 3; | ||
| 83 | |||
| 84 | val = chg_min_uA + CHGIN_ILIM_STEP_20mA * sel; | ||
| 85 | if (val > chg_max_uA) | ||
| 86 | return -EINVAL; | ||
| 87 | |||
| 88 | return val; | ||
| 89 | } | ||
| 90 | |||
| 91 | static int max77693_chg_set_current_limit(struct regulator_dev *rdev, | ||
| 92 | int min_uA, int max_uA) | ||
| 93 | { | ||
| 94 | unsigned int chg_min_uA = rdev->constraints->min_uA; | ||
| 95 | int sel = 0; | ||
| 96 | |||
| 97 | while (chg_min_uA + CHGIN_ILIM_STEP_20mA * sel < min_uA) | ||
| 98 | sel++; | ||
| 99 | |||
| 100 | if (chg_min_uA + CHGIN_ILIM_STEP_20mA * sel > max_uA) | ||
| 101 | return -EINVAL; | ||
| 102 | |||
| 103 | /* the first four codes for charger current are all 60mA */ | ||
| 104 | sel += 3; | ||
| 105 | |||
| 106 | return max77693_write_reg(rdev->regmap, | ||
| 107 | MAX77693_CHG_REG_CHG_CNFG_09, sel); | ||
| 108 | } | ||
| 109 | /* end of CHARGER regulator ops */ | ||
| 110 | |||
| 111 | static const unsigned int max77693_safeout_table[] = { | ||
| 112 | 4850000, | ||
| 113 | 4900000, | ||
| 114 | 4950000, | ||
| 115 | 3300000, | ||
| 116 | }; | ||
| 117 | |||
| 118 | static struct regulator_ops max77693_safeout_ops = { | ||
| 119 | .list_voltage = regulator_list_voltage_table, | ||
| 120 | .is_enabled = regulator_is_enabled_regmap, | ||
| 121 | .enable = regulator_enable_regmap, | ||
| 122 | .disable = regulator_disable_regmap, | ||
| 123 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
| 124 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
| 125 | }; | ||
| 126 | |||
| 127 | static struct regulator_ops max77693_charger_ops = { | ||
| 128 | .is_enabled = max77693_chg_is_enabled, | ||
| 129 | .enable = regulator_enable_regmap, | ||
| 130 | .disable = regulator_disable_regmap, | ||
| 131 | .get_current_limit = max77693_chg_get_current_limit, | ||
| 132 | .set_current_limit = max77693_chg_set_current_limit, | ||
| 133 | }; | ||
| 134 | |||
| 135 | #define regulator_desc_esafeout(_num) { \ | ||
| 136 | .name = "ESAFEOUT"#_num, \ | ||
| 137 | .id = MAX77693_ESAFEOUT##_num, \ | ||
| 138 | .n_voltages = 4, \ | ||
| 139 | .ops = &max77693_safeout_ops, \ | ||
| 140 | .type = REGULATOR_VOLTAGE, \ | ||
| 141 | .volt_table = max77693_safeout_table, \ | ||
| 142 | .vsel_reg = MAX77693_CHG_REG_SAFEOUT_CTRL, \ | ||
| 143 | .vsel_mask = SAFEOUT_CTRL_SAFEOUT##_num##_MASK, \ | ||
| 144 | .enable_reg = MAX77693_CHG_REG_SAFEOUT_CTRL, \ | ||
| 145 | .enable_mask = SAFEOUT_CTRL_ENSAFEOUT##_num##_MASK , \ | ||
| 146 | } | ||
| 147 | |||
| 148 | static struct regulator_desc regulators[] = { | ||
| 149 | regulator_desc_esafeout(1), | ||
| 150 | regulator_desc_esafeout(2), | ||
| 151 | { | ||
| 152 | .name = "CHARGER", | ||
| 153 | .id = MAX77693_CHARGER, | ||
| 154 | .ops = &max77693_charger_ops, | ||
| 155 | .type = REGULATOR_CURRENT, | ||
| 156 | .owner = THIS_MODULE, | ||
| 157 | .enable_reg = MAX77693_CHG_REG_CHG_CNFG_00, | ||
| 158 | .enable_mask = CHG_CNFG_00_CHG_MASK | | ||
| 159 | CHG_CNFG_00_BUCK_MASK, | ||
| 160 | }, | ||
| 161 | }; | ||
| 162 | |||
| 163 | #ifdef CONFIG_OF | ||
| 164 | static int max77693_pmic_dt_parse_rdata(struct device *dev, | ||
| 165 | struct max77693_regulator_data **rdata) | ||
| 166 | { | ||
| 167 | struct device_node *np; | ||
| 168 | struct of_regulator_match *rmatch; | ||
| 169 | struct max77693_regulator_data *tmp; | ||
| 170 | int i, matched = 0; | ||
| 171 | |||
| 172 | np = of_find_node_by_name(dev->parent->of_node, "regulators"); | ||
| 173 | if (!np) | ||
| 174 | return -EINVAL; | ||
| 175 | |||
| 176 | rmatch = devm_kzalloc(dev, | ||
| 177 | sizeof(*rmatch) * ARRAY_SIZE(regulators), GFP_KERNEL); | ||
| 178 | if (!rmatch) | ||
| 179 | return -ENOMEM; | ||
| 180 | |||
| 181 | for (i = 0; i < ARRAY_SIZE(regulators); i++) | ||
| 182 | rmatch[i].name = regulators[i].name; | ||
| 183 | |||
| 184 | matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(regulators)); | ||
| 185 | if (matched <= 0) | ||
| 186 | return matched; | ||
| 187 | *rdata = devm_kzalloc(dev, sizeof(**rdata) * matched, GFP_KERNEL); | ||
| 188 | if (!(*rdata)) | ||
| 189 | return -ENOMEM; | ||
| 190 | |||
| 191 | tmp = *rdata; | ||
| 192 | |||
| 193 | for (i = 0; i < matched; i++) { | ||
| 194 | tmp->initdata = rmatch[i].init_data; | ||
| 195 | tmp->of_node = rmatch[i].of_node; | ||
| 196 | tmp->id = regulators[i].id; | ||
| 197 | tmp++; | ||
| 198 | } | ||
| 199 | |||
| 200 | return matched; | ||
| 201 | } | ||
| 202 | #else | ||
| 203 | static int max77693_pmic_dt_parse_rdata(struct device *dev, | ||
| 204 | struct max77693_regulator_data **rdata) | ||
| 205 | { | ||
| 206 | return 0; | ||
| 207 | } | ||
| 208 | #endif /* CONFIG_OF */ | ||
| 209 | |||
| 210 | static int max77693_pmic_init_rdata(struct device *dev, | ||
| 211 | struct max77693_regulator_data **rdata) | ||
| 212 | { | ||
| 213 | struct max77693_platform_data *pdata; | ||
| 214 | int num_regulators = 0; | ||
| 215 | |||
| 216 | pdata = dev_get_platdata(dev->parent); | ||
| 217 | if (pdata) { | ||
| 218 | *rdata = pdata->regulators; | ||
| 219 | num_regulators = pdata->num_regulators; | ||
| 220 | } | ||
| 221 | |||
| 222 | if (!(*rdata) && dev->parent->of_node) | ||
| 223 | num_regulators = max77693_pmic_dt_parse_rdata(dev, rdata); | ||
| 224 | |||
| 225 | return num_regulators; | ||
| 226 | } | ||
| 227 | |||
| 228 | static int max77693_pmic_probe(struct platform_device *pdev) | ||
| 229 | { | ||
| 230 | struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent); | ||
| 231 | struct max77693_pmic_dev *max77693_pmic; | ||
| 232 | struct max77693_regulator_data *rdata = NULL; | ||
| 233 | int num_rdata, i, ret; | ||
| 234 | struct regulator_config config; | ||
| 235 | |||
| 236 | num_rdata = max77693_pmic_init_rdata(&pdev->dev, &rdata); | ||
| 237 | if (!rdata || num_rdata <= 0) { | ||
| 238 | dev_err(&pdev->dev, "No init data supplied.\n"); | ||
| 239 | return -ENODEV; | ||
| 240 | } | ||
| 241 | |||
| 242 | max77693_pmic = devm_kzalloc(&pdev->dev, | ||
| 243 | sizeof(struct max77693_pmic_dev), | ||
| 244 | GFP_KERNEL); | ||
| 245 | if (!max77693_pmic) | ||
| 246 | return -ENOMEM; | ||
| 247 | |||
| 248 | max77693_pmic->rdev = devm_kzalloc(&pdev->dev, | ||
| 249 | sizeof(struct regulator_dev *) * num_rdata, | ||
| 250 | GFP_KERNEL); | ||
| 251 | if (!max77693_pmic->rdev) | ||
| 252 | return -ENOMEM; | ||
| 253 | |||
| 254 | max77693_pmic->dev = &pdev->dev; | ||
| 255 | max77693_pmic->iodev = iodev; | ||
| 256 | max77693_pmic->num_regulators = num_rdata; | ||
| 257 | |||
| 258 | config.dev = &pdev->dev; | ||
| 259 | config.regmap = iodev->regmap; | ||
| 260 | config.driver_data = max77693_pmic; | ||
| 261 | platform_set_drvdata(pdev, max77693_pmic); | ||
| 262 | |||
| 263 | for (i = 0; i < max77693_pmic->num_regulators; i++) { | ||
| 264 | int id = rdata[i].id; | ||
| 265 | |||
| 266 | config.init_data = rdata[i].initdata; | ||
| 267 | config.of_node = rdata[i].of_node; | ||
| 268 | |||
| 269 | max77693_pmic->rdev[i] = regulator_register(®ulators[id], | ||
| 270 | &config); | ||
| 271 | if (IS_ERR(max77693_pmic->rdev[i])) { | ||
| 272 | ret = PTR_ERR(max77693_pmic->rdev[i]); | ||
| 273 | dev_err(max77693_pmic->dev, | ||
| 274 | "Failed to initialize regulator-%d\n", id); | ||
| 275 | max77693_pmic->rdev[i] = NULL; | ||
| 276 | goto err; | ||
| 277 | } | ||
| 278 | } | ||
| 279 | |||
| 280 | return 0; | ||
| 281 | err: | ||
| 282 | while (--i >= 0) | ||
| 283 | regulator_unregister(max77693_pmic->rdev[i]); | ||
| 284 | |||
| 285 | return ret; | ||
| 286 | } | ||
| 287 | |||
| 288 | static int max77693_pmic_remove(struct platform_device *pdev) | ||
| 289 | { | ||
| 290 | struct max77693_pmic_dev *max77693_pmic = platform_get_drvdata(pdev); | ||
| 291 | struct regulator_dev **rdev = max77693_pmic->rdev; | ||
| 292 | int i; | ||
| 293 | |||
| 294 | for (i = 0; i < max77693_pmic->num_regulators; i++) | ||
| 295 | if (rdev[i]) | ||
| 296 | regulator_unregister(rdev[i]); | ||
| 297 | |||
| 298 | return 0; | ||
| 299 | } | ||
| 300 | |||
| 301 | static const struct platform_device_id max77693_pmic_id[] = { | ||
| 302 | {"max77693-pmic", 0}, | ||
| 303 | {}, | ||
| 304 | }; | ||
| 305 | |||
| 306 | MODULE_DEVICE_TABLE(platform, max77693_pmic_id); | ||
| 307 | |||
| 308 | static struct platform_driver max77693_pmic_driver = { | ||
| 309 | .driver = { | ||
| 310 | .name = "max77693-pmic", | ||
| 311 | .owner = THIS_MODULE, | ||
| 312 | }, | ||
| 313 | .probe = max77693_pmic_probe, | ||
| 314 | .remove = max77693_pmic_remove, | ||
| 315 | .id_table = max77693_pmic_id, | ||
| 316 | }; | ||
| 317 | |||
| 318 | module_platform_driver(max77693_pmic_driver); | ||
| 319 | |||
| 320 | MODULE_DESCRIPTION("MAXIM MAX77693 regulator driver"); | ||
| 321 | MODULE_AUTHOR("Jonghwa Lee <jonghwa3.lee@samsung.com>"); | ||
| 322 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c index 3597da8f0dca..e6d54a546d36 100644 --- a/drivers/regulator/max8925-regulator.c +++ b/drivers/regulator/max8925-regulator.c | |||
| @@ -327,7 +327,6 @@ static int max8925_regulator_remove(struct platform_device *pdev) | |||
| 327 | { | 327 | { |
| 328 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | 328 | struct regulator_dev *rdev = platform_get_drvdata(pdev); |
| 329 | 329 | ||
| 330 | platform_set_drvdata(pdev, NULL); | ||
| 331 | regulator_unregister(rdev); | 330 | regulator_unregister(rdev); |
| 332 | 331 | ||
| 333 | return 0; | 332 | return 0; |
diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index adb1414e5e37..0c5195a842e2 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c | |||
| @@ -26,10 +26,12 @@ | |||
| 26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
| 27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
| 28 | #include <linux/err.h> | 28 | #include <linux/err.h> |
| 29 | #include <linux/of.h> | ||
| 29 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
| 30 | #include <linux/regulator/driver.h> | 31 | #include <linux/regulator/driver.h> |
| 31 | #include <linux/regulator/machine.h> | 32 | #include <linux/regulator/machine.h> |
| 32 | #include <linux/regulator/max8973-regulator.h> | 33 | #include <linux/regulator/max8973-regulator.h> |
| 34 | #include <linux/regulator/of_regulator.h> | ||
| 33 | #include <linux/gpio.h> | 35 | #include <linux/gpio.h> |
| 34 | #include <linux/i2c.h> | 36 | #include <linux/i2c.h> |
| 35 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
| @@ -100,6 +102,7 @@ struct max8973_chip { | |||
| 100 | int curr_vout_reg; | 102 | int curr_vout_reg; |
| 101 | int curr_gpio_val; | 103 | int curr_gpio_val; |
| 102 | bool valid_dvs_gpio; | 104 | bool valid_dvs_gpio; |
| 105 | struct regulator_ops ops; | ||
| 103 | }; | 106 | }; |
| 104 | 107 | ||
| 105 | /* | 108 | /* |
| @@ -240,7 +243,7 @@ static unsigned int max8973_dcdc_get_mode(struct regulator_dev *rdev) | |||
| 240 | REGULATOR_MODE_FAST : REGULATOR_MODE_NORMAL; | 243 | REGULATOR_MODE_FAST : REGULATOR_MODE_NORMAL; |
| 241 | } | 244 | } |
| 242 | 245 | ||
| 243 | static struct regulator_ops max8973_dcdc_ops = { | 246 | static const struct regulator_ops max8973_dcdc_ops = { |
| 244 | .get_voltage_sel = max8973_dcdc_get_voltage_sel, | 247 | .get_voltage_sel = max8973_dcdc_get_voltage_sel, |
| 245 | .set_voltage_sel = max8973_dcdc_set_voltage_sel, | 248 | .set_voltage_sel = max8973_dcdc_set_voltage_sel, |
| 246 | .list_voltage = regulator_list_voltage_linear, | 249 | .list_voltage = regulator_list_voltage_linear, |
| @@ -369,7 +372,8 @@ static int max8973_probe(struct i2c_client *client, | |||
| 369 | int ret; | 372 | int ret; |
| 370 | 373 | ||
| 371 | pdata = client->dev.platform_data; | 374 | pdata = client->dev.platform_data; |
| 372 | if (!pdata) { | 375 | |
| 376 | if (!pdata && !client->dev.of_node) { | ||
| 373 | dev_err(&client->dev, "No Platform data"); | 377 | dev_err(&client->dev, "No Platform data"); |
| 374 | return -EIO; | 378 | return -EIO; |
| 375 | } | 379 | } |
| @@ -388,30 +392,36 @@ static int max8973_probe(struct i2c_client *client, | |||
| 388 | } | 392 | } |
| 389 | 393 | ||
| 390 | i2c_set_clientdata(client, max); | 394 | i2c_set_clientdata(client, max); |
| 395 | max->ops = max8973_dcdc_ops; | ||
| 391 | max->dev = &client->dev; | 396 | max->dev = &client->dev; |
| 392 | max->desc.name = id->name; | 397 | max->desc.name = id->name; |
| 393 | max->desc.id = 0; | 398 | max->desc.id = 0; |
| 394 | max->desc.ops = &max8973_dcdc_ops; | 399 | max->desc.ops = &max->ops; |
| 395 | max->desc.type = REGULATOR_VOLTAGE; | 400 | max->desc.type = REGULATOR_VOLTAGE; |
| 396 | max->desc.owner = THIS_MODULE; | 401 | max->desc.owner = THIS_MODULE; |
| 397 | max->desc.min_uV = MAX8973_MIN_VOLATGE; | 402 | max->desc.min_uV = MAX8973_MIN_VOLATGE; |
| 398 | max->desc.uV_step = MAX8973_VOLATGE_STEP; | 403 | max->desc.uV_step = MAX8973_VOLATGE_STEP; |
| 399 | max->desc.n_voltages = MAX8973_BUCK_N_VOLTAGE; | 404 | max->desc.n_voltages = MAX8973_BUCK_N_VOLTAGE; |
| 400 | 405 | ||
| 401 | if (!pdata->enable_ext_control) { | 406 | if (!pdata || !pdata->enable_ext_control) { |
| 402 | max->desc.enable_reg = MAX8973_VOUT; | 407 | max->desc.enable_reg = MAX8973_VOUT; |
| 403 | max->desc.enable_mask = MAX8973_VOUT_ENABLE; | 408 | max->desc.enable_mask = MAX8973_VOUT_ENABLE; |
| 404 | max8973_dcdc_ops.enable = regulator_enable_regmap; | 409 | max->ops.enable = regulator_enable_regmap; |
| 405 | max8973_dcdc_ops.disable = regulator_disable_regmap; | 410 | max->ops.disable = regulator_disable_regmap; |
| 406 | max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap; | 411 | max->ops.is_enabled = regulator_is_enabled_regmap; |
| 412 | } | ||
| 413 | |||
| 414 | if (pdata) { | ||
| 415 | max->dvs_gpio = pdata->dvs_gpio; | ||
| 416 | max->enable_external_control = pdata->enable_ext_control; | ||
| 417 | max->curr_gpio_val = pdata->dvs_def_state; | ||
| 418 | max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state; | ||
| 419 | } else { | ||
| 420 | max->dvs_gpio = -EINVAL; | ||
| 421 | max->curr_vout_reg = MAX8973_VOUT; | ||
| 407 | } | 422 | } |
| 408 | 423 | ||
| 409 | max->enable_external_control = pdata->enable_ext_control; | ||
| 410 | max->dvs_gpio = pdata->dvs_gpio; | ||
| 411 | max->curr_gpio_val = pdata->dvs_def_state; | ||
| 412 | max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state; | ||
| 413 | max->lru_index[0] = max->curr_vout_reg; | 424 | max->lru_index[0] = max->curr_vout_reg; |
| 414 | max->valid_dvs_gpio = false; | ||
| 415 | 425 | ||
| 416 | if (gpio_is_valid(max->dvs_gpio)) { | 426 | if (gpio_is_valid(max->dvs_gpio)) { |
| 417 | int gpio_flags; | 427 | int gpio_flags; |
| @@ -437,16 +447,21 @@ static int max8973_probe(struct i2c_client *client, | |||
| 437 | max->lru_index[i] = i; | 447 | max->lru_index[i] = i; |
| 438 | max->lru_index[0] = max->curr_vout_reg; | 448 | max->lru_index[0] = max->curr_vout_reg; |
| 439 | max->lru_index[max->curr_vout_reg] = 0; | 449 | max->lru_index[max->curr_vout_reg] = 0; |
| 450 | } else { | ||
| 451 | max->valid_dvs_gpio = false; | ||
| 440 | } | 452 | } |
| 441 | 453 | ||
| 442 | ret = max8973_init_dcdc(max, pdata); | 454 | if (pdata) { |
| 443 | if (ret < 0) { | 455 | ret = max8973_init_dcdc(max, pdata); |
| 444 | dev_err(max->dev, "Max8973 Init failed, err = %d\n", ret); | 456 | if (ret < 0) { |
| 445 | return ret; | 457 | dev_err(max->dev, "Max8973 Init failed, err = %d\n", ret); |
| 458 | return ret; | ||
| 459 | } | ||
| 446 | } | 460 | } |
| 447 | 461 | ||
| 448 | config.dev = &client->dev; | 462 | config.dev = &client->dev; |
| 449 | config.init_data = pdata->reg_init_data; | 463 | config.init_data = pdata ? pdata->reg_init_data : |
| 464 | of_get_regulator_init_data(&client->dev, client->dev.of_node); | ||
| 450 | config.driver_data = max; | 465 | config.driver_data = max; |
| 451 | config.of_node = client->dev.of_node; | 466 | config.of_node = client->dev.of_node; |
| 452 | config.regmap = max->regmap; | 467 | config.regmap = max->regmap; |
diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c index fdf7f0a09090..5ff99d2703db 100644 --- a/drivers/regulator/mc13783-regulator.c +++ b/drivers/regulator/mc13783-regulator.c | |||
| @@ -466,8 +466,6 @@ static int mc13783_regulator_remove(struct platform_device *pdev) | |||
| 466 | struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); | 466 | struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); |
| 467 | int i; | 467 | int i; |
| 468 | 468 | ||
| 469 | platform_set_drvdata(pdev, NULL); | ||
| 470 | |||
| 471 | for (i = 0; i < priv->num_regulators; i++) | 469 | for (i = 0; i < priv->num_regulators; i++) |
| 472 | regulator_unregister(priv->regulators[i]); | 470 | regulator_unregister(priv->regulators[i]); |
| 473 | 471 | ||
diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c index b716283a8760..1037e07937cf 100644 --- a/drivers/regulator/mc13892-regulator.c +++ b/drivers/regulator/mc13892-regulator.c | |||
| @@ -636,8 +636,6 @@ static int mc13892_regulator_remove(struct platform_device *pdev) | |||
| 636 | struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); | 636 | struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); |
| 637 | int i; | 637 | int i; |
| 638 | 638 | ||
| 639 | platform_set_drvdata(pdev, NULL); | ||
| 640 | |||
| 641 | for (i = 0; i < priv->num_regulators; i++) | 639 | for (i = 0; i < priv->num_regulators; i++) |
| 642 | regulator_unregister(priv->regulators[i]); | 640 | regulator_unregister(priv->regulators[i]); |
| 643 | 641 | ||
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 66ca769287ab..f3c8f8f9dc39 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c | |||
| @@ -61,6 +61,9 @@ static void of_get_regulation_constraints(struct device_node *np, | |||
| 61 | else /* status change should be possible if not always on. */ | 61 | else /* status change should be possible if not always on. */ |
| 62 | constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS; | 62 | constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS; |
| 63 | 63 | ||
| 64 | if (of_property_read_bool(np, "regulator-allow-bypass")) | ||
| 65 | constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS; | ||
| 66 | |||
| 64 | ramp_delay = of_get_property(np, "regulator-ramp-delay", NULL); | 67 | ramp_delay = of_get_property(np, "regulator-ramp-delay", NULL); |
| 65 | if (ramp_delay) | 68 | if (ramp_delay) |
| 66 | constraints->ramp_delay = be32_to_cpu(*ramp_delay); | 69 | constraints->ramp_delay = be32_to_cpu(*ramp_delay); |
diff --git a/drivers/regulator/pcap-regulator.c b/drivers/regulator/pcap-regulator.c index 4899342f1fc1..1a73a297fe73 100644 --- a/drivers/regulator/pcap-regulator.c +++ b/drivers/regulator/pcap-regulator.c | |||
| @@ -260,7 +260,6 @@ static int pcap_regulator_remove(struct platform_device *pdev) | |||
| 260 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | 260 | struct regulator_dev *rdev = platform_get_drvdata(pdev); |
| 261 | 261 | ||
| 262 | regulator_unregister(rdev); | 262 | regulator_unregister(rdev); |
| 263 | platform_set_drvdata(pdev, NULL); | ||
| 264 | 263 | ||
| 265 | return 0; | 264 | return 0; |
| 266 | } | 265 | } |
diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c index 534075e13d6d..54df9f7cb504 100644 --- a/drivers/regulator/pcf50633-regulator.c +++ b/drivers/regulator/pcf50633-regulator.c | |||
| @@ -106,7 +106,6 @@ static int pcf50633_regulator_remove(struct platform_device *pdev) | |||
| 106 | { | 106 | { |
| 107 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | 107 | struct regulator_dev *rdev = platform_get_drvdata(pdev); |
| 108 | 108 | ||
| 109 | platform_set_drvdata(pdev, NULL); | ||
| 110 | regulator_unregister(rdev); | 109 | regulator_unregister(rdev); |
| 111 | 110 | ||
| 112 | return 0; | 111 | return 0; |
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index cd9ea2ea1826..c9f16e17920f 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | */ | 12 | */ |
| 13 | 13 | ||
| 14 | #include <linux/bug.h> | 14 | #include <linux/bug.h> |
| 15 | #include <linux/delay.h> | ||
| 16 | #include <linux/err.h> | 15 | #include <linux/err.h> |
| 17 | #include <linux/gpio.h> | 16 | #include <linux/gpio.h> |
| 18 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
diff --git a/drivers/regulator/ti-abb-regulator.c b/drivers/regulator/ti-abb-regulator.c new file mode 100644 index 000000000000..3753ed05e719 --- /dev/null +++ b/drivers/regulator/ti-abb-regulator.c | |||
| @@ -0,0 +1,910 @@ | |||
| 1 | /* | ||
| 2 | * Texas Instruments SoC Adaptive Body Bias(ABB) Regulator | ||
| 3 | * | ||
| 4 | * Copyright (C) 2011 Texas Instruments, Inc. | ||
| 5 | * Mike Turquette <mturquette@ti.com> | ||
| 6 | * | ||
| 7 | * Copyright (C) 2012-2013 Texas Instruments, Inc. | ||
| 8 | * Andrii Tseglytskyi <andrii.tseglytskyi@ti.com> | ||
| 9 | * Nishanth Menon <nm@ti.com> | ||
| 10 | * | ||
| 11 | * This program is free software; you can redistribute it and/or modify | ||
| 12 | * it under the terms of the GNU General Public License version 2 as | ||
| 13 | * published by the Free Software Foundation. | ||
| 14 | * | ||
| 15 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
| 16 | * kind, whether express or implied; without even the implied warranty | ||
| 17 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | * GNU General Public License for more details. | ||
| 19 | */ | ||
| 20 | #include <linux/clk.h> | ||
| 21 | #include <linux/delay.h> | ||
| 22 | #include <linux/err.h> | ||
| 23 | #include <linux/io.h> | ||
| 24 | #include <linux/module.h> | ||
| 25 | #include <linux/of_device.h> | ||
| 26 | #include <linux/of.h> | ||
| 27 | #include <linux/platform_device.h> | ||
| 28 | #include <linux/regulator/driver.h> | ||
| 29 | #include <linux/regulator/machine.h> | ||
| 30 | #include <linux/regulator/of_regulator.h> | ||
| 31 | |||
| 32 | /* | ||
| 33 | * ABB LDO operating states: | ||
| 34 | * NOMINAL_OPP: bypasses the ABB LDO | ||
| 35 | * FAST_OPP: sets ABB LDO to Forward Body-Bias | ||
| 36 | * SLOW_OPP: sets ABB LDO to Reverse Body-Bias | ||
| 37 | */ | ||
| 38 | #define TI_ABB_NOMINAL_OPP 0 | ||
| 39 | #define TI_ABB_FAST_OPP 1 | ||
| 40 | #define TI_ABB_SLOW_OPP 3 | ||
| 41 | |||
| 42 | /** | ||
| 43 | * struct ti_abb_info - ABB information per voltage setting | ||
| 44 | * @opp_sel: one of TI_ABB macro | ||
| 45 | * @vset: (optional) vset value that LDOVBB needs to be overriden with. | ||
| 46 | * | ||
| 47 | * Array of per voltage entries organized in the same order as regulator_desc's | ||
| 48 | * volt_table list. (selector is used to index from this array) | ||
| 49 | */ | ||
| 50 | struct ti_abb_info { | ||
| 51 | u32 opp_sel; | ||
| 52 | u32 vset; | ||
| 53 | }; | ||
| 54 | |||
| 55 | /** | ||
| 56 | * struct ti_abb_reg - Register description for ABB block | ||
| 57 | * @setup_reg: setup register offset from base | ||
| 58 | * @control_reg: control register offset from base | ||
| 59 | * @sr2_wtcnt_value_mask: setup register- sr2_wtcnt_value mask | ||
| 60 | * @fbb_sel_mask: setup register- FBB sel mask | ||
| 61 | * @rbb_sel_mask: setup register- RBB sel mask | ||
| 62 | * @sr2_en_mask: setup register- enable mask | ||
| 63 | * @opp_change_mask: control register - mask to trigger LDOVBB change | ||
| 64 | * @opp_sel_mask: control register - mask for mode to operate | ||
| 65 | */ | ||
| 66 | struct ti_abb_reg { | ||
| 67 | u32 setup_reg; | ||
| 68 | u32 control_reg; | ||
| 69 | |||
| 70 | /* Setup register fields */ | ||
| 71 | u32 sr2_wtcnt_value_mask; | ||
| 72 | u32 fbb_sel_mask; | ||
| 73 | u32 rbb_sel_mask; | ||
| 74 | u32 sr2_en_mask; | ||
| 75 | |||
| 76 | /* Control register fields */ | ||
| 77 | u32 opp_change_mask; | ||
| 78 | u32 opp_sel_mask; | ||
| 79 | }; | ||
| 80 | |||
| 81 | /** | ||
| 82 | * struct ti_abb - ABB instance data | ||
| 83 | * @rdesc: regulator descriptor | ||
| 84 | * @clk: clock(usually sysclk) supplying ABB block | ||
| 85 | * @base: base address of ABB block | ||
| 86 | * @int_base: interrupt register base address | ||
| 87 | * @efuse_base: (optional) efuse base address for ABB modes | ||
| 88 | * @ldo_base: (optional) LDOVBB vset override base address | ||
| 89 | * @regs: pointer to struct ti_abb_reg for ABB block | ||
| 90 | * @txdone_mask: mask on int_base for tranxdone interrupt | ||
| 91 | * @ldovbb_override_mask: mask to ldo_base for overriding default LDO VBB | ||
| 92 | * vset with value from efuse | ||
| 93 | * @ldovbb_vset_mask: mask to ldo_base for providing the VSET override | ||
| 94 | * @info: array to per voltage ABB configuration | ||
| 95 | * @current_info_idx: current index to info | ||
| 96 | * @settling_time: SoC specific settling time for LDO VBB | ||
| 97 | */ | ||
| 98 | struct ti_abb { | ||
| 99 | struct regulator_desc rdesc; | ||
| 100 | struct clk *clk; | ||
| 101 | void __iomem *base; | ||
| 102 | void __iomem *int_base; | ||
| 103 | void __iomem *efuse_base; | ||
| 104 | void __iomem *ldo_base; | ||
| 105 | |||
| 106 | const struct ti_abb_reg *regs; | ||
| 107 | u32 txdone_mask; | ||
| 108 | u32 ldovbb_override_mask; | ||
| 109 | u32 ldovbb_vset_mask; | ||
| 110 | |||
| 111 | struct ti_abb_info *info; | ||
| 112 | int current_info_idx; | ||
| 113 | |||
| 114 | u32 settling_time; | ||
| 115 | }; | ||
| 116 | |||
| 117 | /** | ||
| 118 | * ti_abb_rmw() - handy wrapper to set specific register bits | ||
| 119 | * @mask: mask for register field | ||
| 120 | * @value: value shifted to mask location and written | ||
| 121 | * @offset: offset of register | ||
| 122 | * @base: base address | ||
| 123 | * | ||
| 124 | * Return: final register value (may be unused) | ||
| 125 | */ | ||
| 126 | static inline u32 ti_abb_rmw(u32 mask, u32 value, u32 offset, | ||
| 127 | void __iomem *base) | ||
| 128 | { | ||
| 129 | u32 val; | ||
| 130 | |||
| 131 | val = readl(base + offset); | ||
| 132 | val &= ~mask; | ||
| 133 | val |= (value << __ffs(mask)) & mask; | ||
| 134 | writel(val, base + offset); | ||
| 135 | |||
| 136 | return val; | ||
| 137 | } | ||
| 138 | |||
| 139 | /** | ||
| 140 | * ti_abb_check_txdone() - handy wrapper to check ABB tranxdone status | ||
| 141 | * @abb: pointer to the abb instance | ||
| 142 | * | ||
| 143 | * Return: true or false | ||
| 144 | */ | ||
| 145 | static inline bool ti_abb_check_txdone(const struct ti_abb *abb) | ||
| 146 | { | ||
| 147 | return !!(readl(abb->int_base) & abb->txdone_mask); | ||
| 148 | } | ||
| 149 | |||
| 150 | /** | ||
| 151 | * ti_abb_clear_txdone() - handy wrapper to clear ABB tranxdone status | ||
| 152 | * @abb: pointer to the abb instance | ||
| 153 | */ | ||
| 154 | static inline void ti_abb_clear_txdone(const struct ti_abb *abb) | ||
| 155 | { | ||
| 156 | writel(abb->txdone_mask, abb->int_base); | ||
| 157 | }; | ||
| 158 | |||
| 159 | /** | ||
| 160 | * ti_abb_wait_tranx() - waits for ABB tranxdone event | ||
| 161 | * @dev: device | ||
| 162 | * @abb: pointer to the abb instance | ||
| 163 | * | ||
| 164 | * Return: 0 on success or -ETIMEDOUT if the event is not cleared on time. | ||
| 165 | */ | ||
| 166 | static int ti_abb_wait_txdone(struct device *dev, struct ti_abb *abb) | ||
| 167 | { | ||
| 168 | int timeout = 0; | ||
| 169 | bool status; | ||
| 170 | |||
| 171 | while (timeout++ <= abb->settling_time) { | ||
| 172 | status = ti_abb_check_txdone(abb); | ||
| 173 | if (status) | ||
| 174 | break; | ||
| 175 | |||
| 176 | udelay(1); | ||
| 177 | } | ||
| 178 | |||
| 179 | if (timeout > abb->settling_time) { | ||
| 180 | dev_warn_ratelimited(dev, | ||
| 181 | "%s:TRANXDONE timeout(%duS) int=0x%08x\n", | ||
| 182 | __func__, timeout, readl(abb->int_base)); | ||
| 183 | return -ETIMEDOUT; | ||
| 184 | } | ||
| 185 | |||
| 186 | return 0; | ||
| 187 | } | ||
| 188 | |||
| 189 | /** | ||
| 190 | * ti_abb_clear_all_txdone() - clears ABB tranxdone event | ||
| 191 | * @dev: device | ||
| 192 | * @abb: pointer to the abb instance | ||
| 193 | * | ||
| 194 | * Return: 0 on success or -ETIMEDOUT if the event is not cleared on time. | ||
| 195 | */ | ||
| 196 | static int ti_abb_clear_all_txdone(struct device *dev, const struct ti_abb *abb) | ||
| 197 | { | ||
| 198 | int timeout = 0; | ||
| 199 | bool status; | ||
| 200 | |||
| 201 | while (timeout++ <= abb->settling_time) { | ||
| 202 | ti_abb_clear_txdone(abb); | ||
| 203 | |||
| 204 | status = ti_abb_check_txdone(abb); | ||
| 205 | if (!status) | ||
| 206 | break; | ||
| 207 | |||
| 208 | udelay(1); | ||
| 209 | } | ||
| 210 | |||
| 211 | if (timeout > abb->settling_time) { | ||
| 212 | dev_warn_ratelimited(dev, | ||
| 213 | "%s:TRANXDONE timeout(%duS) int=0x%08x\n", | ||
| 214 | __func__, timeout, readl(abb->int_base)); | ||
| 215 | return -ETIMEDOUT; | ||
| 216 | } | ||
| 217 | |||
| 218 | return 0; | ||
| 219 | } | ||
| 220 | |||
| 221 | /** | ||
| 222 | * ti_abb_program_ldovbb() - program LDOVBB register for override value | ||
| 223 | * @dev: device | ||
| 224 | * @abb: pointer to the abb instance | ||
| 225 | * @info: ABB info to program | ||
| 226 | */ | ||
| 227 | static void ti_abb_program_ldovbb(struct device *dev, const struct ti_abb *abb, | ||
| 228 | struct ti_abb_info *info) | ||
| 229 | { | ||
| 230 | u32 val; | ||
| 231 | |||
| 232 | val = readl(abb->ldo_base); | ||
| 233 | /* clear up previous values */ | ||
| 234 | val &= ~(abb->ldovbb_override_mask | abb->ldovbb_vset_mask); | ||
| 235 | |||
| 236 | switch (info->opp_sel) { | ||
| 237 | case TI_ABB_SLOW_OPP: | ||
| 238 | case TI_ABB_FAST_OPP: | ||
| 239 | val |= abb->ldovbb_override_mask; | ||
| 240 | val |= info->vset << __ffs(abb->ldovbb_vset_mask); | ||
| 241 | break; | ||
| 242 | } | ||
| 243 | |||
| 244 | writel(val, abb->ldo_base); | ||
| 245 | } | ||
| 246 | |||
| 247 | /** | ||
| 248 | * ti_abb_set_opp() - Setup ABB and LDO VBB for required bias | ||
| 249 | * @rdev: regulator device | ||
| 250 | * @abb: pointer to the abb instance | ||
| 251 | * @info: ABB info to program | ||
| 252 | * | ||
| 253 | * Return: 0 on success or appropriate error value when fails | ||
| 254 | */ | ||
| 255 | static int ti_abb_set_opp(struct regulator_dev *rdev, struct ti_abb *abb, | ||
| 256 | struct ti_abb_info *info) | ||
| 257 | { | ||
| 258 | const struct ti_abb_reg *regs = abb->regs; | ||
| 259 | struct device *dev = &rdev->dev; | ||
| 260 | int ret; | ||
| 261 | |||
| 262 | ret = ti_abb_clear_all_txdone(dev, abb); | ||
| 263 | if (ret) | ||
| 264 | goto out; | ||
| 265 | |||
| 266 | ti_abb_rmw(regs->fbb_sel_mask | regs->rbb_sel_mask, 0, regs->setup_reg, | ||
| 267 | abb->base); | ||
| 268 | |||
| 269 | switch (info->opp_sel) { | ||
| 270 | case TI_ABB_SLOW_OPP: | ||
| 271 | ti_abb_rmw(regs->rbb_sel_mask, 1, regs->setup_reg, abb->base); | ||
| 272 | break; | ||
| 273 | case TI_ABB_FAST_OPP: | ||
| 274 | ti_abb_rmw(regs->fbb_sel_mask, 1, regs->setup_reg, abb->base); | ||
| 275 | break; | ||
| 276 | } | ||
| 277 | |||
| 278 | /* program next state of ABB ldo */ | ||
| 279 | ti_abb_rmw(regs->opp_sel_mask, info->opp_sel, regs->control_reg, | ||
| 280 | abb->base); | ||
| 281 | |||
| 282 | /* program LDO VBB vset override if needed */ | ||
| 283 | if (abb->ldo_base) | ||
| 284 | ti_abb_program_ldovbb(dev, abb, info); | ||
| 285 | |||
| 286 | /* Initiate ABB ldo change */ | ||
| 287 | ti_abb_rmw(regs->opp_change_mask, 1, regs->control_reg, abb->base); | ||
| 288 | |||
| 289 | /* Wait for ABB LDO to complete transition to new Bias setting */ | ||
| 290 | ret = ti_abb_wait_txdone(dev, abb); | ||
| 291 | if (ret) | ||
| 292 | goto out; | ||
| 293 | |||
| 294 | ret = ti_abb_clear_all_txdone(dev, abb); | ||
| 295 | if (ret) | ||
| 296 | goto out; | ||
| 297 | |||
| 298 | out: | ||
| 299 | return ret; | ||
| 300 | } | ||
| 301 | |||
| 302 | /** | ||
| 303 | * ti_abb_set_voltage_sel() - regulator accessor function to set ABB LDO | ||
| 304 | * @rdev: regulator device | ||
| 305 | * @sel: selector to index into required ABB LDO settings (maps to | ||
| 306 | * regulator descriptor's volt_table) | ||
| 307 | * | ||
| 308 | * Return: 0 on success or appropriate error value when fails | ||
| 309 | */ | ||
| 310 | static int ti_abb_set_voltage_sel(struct regulator_dev *rdev, unsigned sel) | ||
| 311 | { | ||
| 312 | const struct regulator_desc *desc = rdev->desc; | ||
| 313 | struct ti_abb *abb = rdev_get_drvdata(rdev); | ||
| 314 | struct device *dev = &rdev->dev; | ||
| 315 | struct ti_abb_info *info, *oinfo; | ||
| 316 | int ret = 0; | ||
| 317 | |||
| 318 | if (!abb) { | ||
| 319 | dev_err_ratelimited(dev, "%s: No regulator drvdata\n", | ||
| 320 | __func__); | ||
| 321 | return -ENODEV; | ||
| 322 | } | ||
| 323 | |||
| 324 | if (!desc->n_voltages || !abb->info) { | ||
| 325 | dev_err_ratelimited(dev, | ||
| 326 | "%s: No valid voltage table entries?\n", | ||
| 327 | __func__); | ||
| 328 | return -EINVAL; | ||
| 329 | } | ||
| 330 | |||
| 331 | if (sel >= desc->n_voltages) { | ||
| 332 | dev_err(dev, "%s: sel idx(%d) >= n_voltages(%d)\n", __func__, | ||
| 333 | sel, desc->n_voltages); | ||
| 334 | return -EINVAL; | ||
| 335 | } | ||
| 336 | |||
| 337 | /* If we are in the same index as we were, nothing to do here! */ | ||
| 338 | if (sel == abb->current_info_idx) { | ||
| 339 | dev_dbg(dev, "%s: Already at sel=%d\n", __func__, sel); | ||
| 340 | return ret; | ||
| 341 | } | ||
| 342 | |||
| 343 | /* If data is exactly the same, then just update index, no change */ | ||
| 344 | info = &abb->info[sel]; | ||
| 345 | oinfo = &abb->info[abb->current_info_idx]; | ||
| 346 | if (!memcmp(info, oinfo, sizeof(*info))) { | ||
| 347 | dev_dbg(dev, "%s: Same data new idx=%d, old idx=%d\n", __func__, | ||
| 348 | sel, abb->current_info_idx); | ||
| 349 | goto out; | ||
| 350 | } | ||
| 351 | |||
| 352 | ret = ti_abb_set_opp(rdev, abb, info); | ||
| 353 | |||
| 354 | out: | ||
| 355 | if (!ret) | ||
| 356 | abb->current_info_idx = sel; | ||
| 357 | else | ||
| 358 | dev_err_ratelimited(dev, | ||
| 359 | "%s: Volt[%d] idx[%d] mode[%d] Fail(%d)\n", | ||
| 360 | __func__, desc->volt_table[sel], sel, | ||
| 361 | info->opp_sel, ret); | ||
| 362 | return ret; | ||
| 363 | } | ||
| 364 | |||
| 365 | /** | ||
| 366 | * ti_abb_get_voltage_sel() - Regulator accessor to get current ABB LDO setting | ||
| 367 | * @rdev: regulator device | ||
| 368 | * | ||
| 369 | * Return: 0 on success or appropriate error value when fails | ||
| 370 | */ | ||
| 371 | static int ti_abb_get_voltage_sel(struct regulator_dev *rdev) | ||
| 372 | { | ||
| 373 | const struct regulator_desc *desc = rdev->desc; | ||
| 374 | struct ti_abb *abb = rdev_get_drvdata(rdev); | ||
| 375 | struct device *dev = &rdev->dev; | ||
| 376 | |||
| 377 | if (!abb) { | ||
| 378 | dev_err_ratelimited(dev, "%s: No regulator drvdata\n", | ||
| 379 | __func__); | ||
| 380 | return -ENODEV; | ||
| 381 | } | ||
| 382 | |||
| 383 | if (!desc->n_voltages || !abb->info) { | ||
| 384 | dev_err_ratelimited(dev, | ||
| 385 | "%s: No valid voltage table entries?\n", | ||
| 386 | __func__); | ||
| 387 | return -EINVAL; | ||
| 388 | } | ||
| 389 | |||
| 390 | if (abb->current_info_idx >= (int)desc->n_voltages) { | ||
| 391 | dev_err(dev, "%s: Corrupted data? idx(%d) >= n_voltages(%d)\n", | ||
| 392 | __func__, abb->current_info_idx, desc->n_voltages); | ||
| 393 | return -EINVAL; | ||
| 394 | } | ||
| 395 | |||
| 396 | return abb->current_info_idx; | ||
| 397 | } | ||
| 398 | |||
| 399 | /** | ||
| 400 | * ti_abb_init_timings() - setup ABB clock timing for the current platform | ||
| 401 | * @dev: device | ||
| 402 | * @abb: pointer to the abb instance | ||
| 403 | * | ||
| 404 | * Return: 0 if timing is updated, else returns error result. | ||
| 405 | */ | ||
| 406 | static int ti_abb_init_timings(struct device *dev, struct ti_abb *abb) | ||
| 407 | { | ||
| 408 | u32 clock_cycles; | ||
| 409 | u32 clk_rate, sr2_wt_cnt_val, cycle_rate; | ||
| 410 | const struct ti_abb_reg *regs = abb->regs; | ||
| 411 | int ret; | ||
| 412 | char *pname = "ti,settling-time"; | ||
| 413 | |||
| 414 | /* read device tree properties */ | ||
| 415 | ret = of_property_read_u32(dev->of_node, pname, &abb->settling_time); | ||
| 416 | if (ret) { | ||
| 417 | dev_err(dev, "Unable to get property '%s'(%d)\n", pname, ret); | ||
| 418 | return ret; | ||
| 419 | } | ||
| 420 | |||
| 421 | /* ABB LDO cannot be settle in 0 time */ | ||
| 422 | if (!abb->settling_time) { | ||
| 423 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); | ||
| 424 | return -EINVAL; | ||
| 425 | } | ||
| 426 | |||
| 427 | pname = "ti,clock-cycles"; | ||
| 428 | ret = of_property_read_u32(dev->of_node, pname, &clock_cycles); | ||
| 429 | if (ret) { | ||
| 430 | dev_err(dev, "Unable to get property '%s'(%d)\n", pname, ret); | ||
| 431 | return ret; | ||
| 432 | } | ||
| 433 | /* ABB LDO cannot be settle in 0 clock cycles */ | ||
| 434 | if (!clock_cycles) { | ||
| 435 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); | ||
| 436 | return -EINVAL; | ||
| 437 | } | ||
| 438 | |||
| 439 | abb->clk = devm_clk_get(dev, NULL); | ||
| 440 | if (IS_ERR(abb->clk)) { | ||
| 441 | ret = PTR_ERR(abb->clk); | ||
| 442 | dev_err(dev, "%s: Unable to get clk(%d)\n", __func__, ret); | ||
| 443 | return ret; | ||
| 444 | } | ||
| 445 | |||
| 446 | /* | ||
| 447 | * SR2_WTCNT_VALUE is the settling time for the ABB ldo after a | ||
| 448 | * transition and must be programmed with the correct time at boot. | ||
| 449 | * The value programmed into the register is the number of SYS_CLK | ||
| 450 | * clock cycles that match a given wall time profiled for the ldo. | ||
| 451 | * This value depends on: | ||
| 452 | * settling time of ldo in micro-seconds (varies per OMAP family) | ||
| 453 | * # of clock cycles per SYS_CLK period (varies per OMAP family) | ||
| 454 | * the SYS_CLK frequency in MHz (varies per board) | ||
| 455 | * The formula is: | ||
| 456 | * | ||
| 457 | * ldo settling time (in micro-seconds) | ||
| 458 | * SR2_WTCNT_VALUE = ------------------------------------------ | ||
| 459 | * (# system clock cycles) * (sys_clk period) | ||
| 460 | * | ||
| 461 | * Put another way: | ||
| 462 | * | ||
| 463 | * SR2_WTCNT_VALUE = settling time / (# SYS_CLK cycles / SYS_CLK rate)) | ||
| 464 | * | ||
| 465 | * To avoid dividing by zero multiply both "# clock cycles" and | ||
| 466 | * "settling time" by 10 such that the final result is the one we want. | ||
| 467 | */ | ||
| 468 | |||
| 469 | /* Convert SYS_CLK rate to MHz & prevent divide by zero */ | ||
| 470 | clk_rate = DIV_ROUND_CLOSEST(clk_get_rate(abb->clk), 1000000); | ||
| 471 | |||
| 472 | /* Calculate cycle rate */ | ||
| 473 | cycle_rate = DIV_ROUND_CLOSEST(clock_cycles * 10, clk_rate); | ||
| 474 | |||
| 475 | /* Calulate SR2_WTCNT_VALUE */ | ||
| 476 | sr2_wt_cnt_val = DIV_ROUND_CLOSEST(abb->settling_time * 10, cycle_rate); | ||
| 477 | |||
| 478 | dev_dbg(dev, "%s: Clk_rate=%ld, sr2_cnt=0x%08x\n", __func__, | ||
| 479 | clk_get_rate(abb->clk), sr2_wt_cnt_val); | ||
| 480 | |||
| 481 | ti_abb_rmw(regs->sr2_wtcnt_value_mask, sr2_wt_cnt_val, regs->setup_reg, | ||
| 482 | abb->base); | ||
| 483 | |||
| 484 | return 0; | ||
| 485 | } | ||
| 486 | |||
| 487 | /** | ||
| 488 | * ti_abb_init_table() - Initialize ABB table from device tree | ||
| 489 | * @dev: device | ||
| 490 | * @abb: pointer to the abb instance | ||
| 491 | * @rinit_data: regulator initdata | ||
| 492 | * | ||
| 493 | * Return: 0 on success or appropriate error value when fails | ||
| 494 | */ | ||
| 495 | static int ti_abb_init_table(struct device *dev, struct ti_abb *abb, | ||
| 496 | struct regulator_init_data *rinit_data) | ||
| 497 | { | ||
| 498 | struct ti_abb_info *info; | ||
| 499 | const struct property *prop; | ||
| 500 | const __be32 *abb_info; | ||
| 501 | const u32 num_values = 6; | ||
| 502 | char *pname = "ti,abb_info"; | ||
| 503 | u32 num_entries, i; | ||
| 504 | unsigned int *volt_table; | ||
| 505 | int min_uV = INT_MAX, max_uV = 0; | ||
| 506 | struct regulation_constraints *c = &rinit_data->constraints; | ||
| 507 | |||
| 508 | prop = of_find_property(dev->of_node, pname, NULL); | ||
| 509 | if (!prop) { | ||
| 510 | dev_err(dev, "No '%s' property?\n", pname); | ||
| 511 | return -ENODEV; | ||
| 512 | } | ||
| 513 | |||
| 514 | if (!prop->value) { | ||
| 515 | dev_err(dev, "Empty '%s' property?\n", pname); | ||
| 516 | return -ENODATA; | ||
| 517 | } | ||
| 518 | |||
| 519 | /* | ||
| 520 | * Each abb_info is a set of n-tuple, where n is num_values, consisting | ||
| 521 | * of voltage and a set of detection logic for ABB information for that | ||
| 522 | * voltage to apply. | ||
| 523 | */ | ||
| 524 | num_entries = prop->length / sizeof(u32); | ||
| 525 | if (!num_entries || (num_entries % num_values)) { | ||
| 526 | dev_err(dev, "All '%s' list entries need %d vals\n", pname, | ||
| 527 | num_values); | ||
| 528 | return -EINVAL; | ||
| 529 | } | ||
| 530 | num_entries /= num_values; | ||
| 531 | |||
| 532 | info = devm_kzalloc(dev, sizeof(*info) * num_entries, GFP_KERNEL); | ||
| 533 | if (!info) { | ||
| 534 | dev_err(dev, "Can't allocate info table for '%s' property\n", | ||
| 535 | pname); | ||
| 536 | return -ENOMEM; | ||
| 537 | } | ||
| 538 | abb->info = info; | ||
| 539 | |||
| 540 | volt_table = devm_kzalloc(dev, sizeof(unsigned int) * num_entries, | ||
| 541 | GFP_KERNEL); | ||
| 542 | if (!volt_table) { | ||
| 543 | dev_err(dev, "Can't allocate voltage table for '%s' property\n", | ||
| 544 | pname); | ||
| 545 | return -ENOMEM; | ||
| 546 | } | ||
| 547 | |||
| 548 | abb->rdesc.n_voltages = num_entries; | ||
| 549 | abb->rdesc.volt_table = volt_table; | ||
| 550 | /* We do not know where the OPP voltage is at the moment */ | ||
| 551 | abb->current_info_idx = -EINVAL; | ||
| 552 | |||
| 553 | abb_info = prop->value; | ||
| 554 | for (i = 0; i < num_entries; i++, info++, volt_table++) { | ||
| 555 | u32 efuse_offset, rbb_mask, fbb_mask, vset_mask; | ||
| 556 | u32 efuse_val; | ||
| 557 | |||
| 558 | /* NOTE: num_values should equal to entries picked up here */ | ||
| 559 | *volt_table = be32_to_cpup(abb_info++); | ||
| 560 | info->opp_sel = be32_to_cpup(abb_info++); | ||
| 561 | efuse_offset = be32_to_cpup(abb_info++); | ||
| 562 | rbb_mask = be32_to_cpup(abb_info++); | ||
| 563 | fbb_mask = be32_to_cpup(abb_info++); | ||
| 564 | vset_mask = be32_to_cpup(abb_info++); | ||
| 565 | |||
| 566 | dev_dbg(dev, | ||
| 567 | "[%d]v=%d ABB=%d ef=0x%x rbb=0x%x fbb=0x%x vset=0x%x\n", | ||
| 568 | i, *volt_table, info->opp_sel, efuse_offset, rbb_mask, | ||
| 569 | fbb_mask, vset_mask); | ||
| 570 | |||
| 571 | /* Find min/max for voltage set */ | ||
| 572 | if (min_uV > *volt_table) | ||
| 573 | min_uV = *volt_table; | ||
| 574 | if (max_uV < *volt_table) | ||
| 575 | max_uV = *volt_table; | ||
| 576 | |||
| 577 | if (!abb->efuse_base) { | ||
| 578 | /* Ignore invalid data, but warn to help cleanup */ | ||
| 579 | if (efuse_offset || rbb_mask || fbb_mask || vset_mask) | ||
| 580 | dev_err(dev, "prop '%s': v=%d,bad efuse/mask\n", | ||
| 581 | pname, *volt_table); | ||
| 582 | goto check_abb; | ||
| 583 | } | ||
| 584 | |||
| 585 | efuse_val = readl(abb->efuse_base + efuse_offset); | ||
| 586 | |||
| 587 | /* Use ABB recommendation from Efuse */ | ||
| 588 | if (efuse_val & rbb_mask) | ||
| 589 | info->opp_sel = TI_ABB_SLOW_OPP; | ||
| 590 | else if (efuse_val & fbb_mask) | ||
| 591 | info->opp_sel = TI_ABB_FAST_OPP; | ||
| 592 | else if (rbb_mask || fbb_mask) | ||
| 593 | info->opp_sel = TI_ABB_NOMINAL_OPP; | ||
| 594 | |||
| 595 | dev_dbg(dev, | ||
| 596 | "[%d]v=%d efusev=0x%x final ABB=%d\n", | ||
| 597 | i, *volt_table, efuse_val, info->opp_sel); | ||
| 598 | |||
| 599 | /* Use recommended Vset bits from Efuse */ | ||
| 600 | if (!abb->ldo_base) { | ||
| 601 | if (vset_mask) | ||
| 602 | dev_err(dev, "prop'%s':v=%d vst=%x LDO base?\n", | ||
| 603 | pname, *volt_table, vset_mask); | ||
| 604 | continue; | ||
| 605 | } | ||
| 606 | info->vset = efuse_val & vset_mask >> __ffs(vset_mask); | ||
| 607 | dev_dbg(dev, "[%d]v=%d vset=%x\n", i, *volt_table, info->vset); | ||
| 608 | check_abb: | ||
| 609 | switch (info->opp_sel) { | ||
| 610 | case TI_ABB_NOMINAL_OPP: | ||
| 611 | case TI_ABB_FAST_OPP: | ||
| 612 | case TI_ABB_SLOW_OPP: | ||
| 613 | /* Valid values */ | ||
| 614 | break; | ||
| 615 | default: | ||
| 616 | dev_err(dev, "%s:[%d]v=%d, ABB=%d is invalid! Abort!\n", | ||
| 617 | __func__, i, *volt_table, info->opp_sel); | ||
| 618 | return -EINVAL; | ||
| 619 | } | ||
| 620 | } | ||
| 621 | |||
| 622 | /* Setup the min/max voltage constraints from the supported list */ | ||
| 623 | c->min_uV = min_uV; | ||
| 624 | c->max_uV = max_uV; | ||
| 625 | |||
| 626 | return 0; | ||
| 627 | } | ||
| 628 | |||
| 629 | static struct regulator_ops ti_abb_reg_ops = { | ||
| 630 | .list_voltage = regulator_list_voltage_table, | ||
| 631 | |||
| 632 | .set_voltage_sel = ti_abb_set_voltage_sel, | ||
| 633 | .get_voltage_sel = ti_abb_get_voltage_sel, | ||
| 634 | }; | ||
| 635 | |||
| 636 | /* Default ABB block offsets, IF this changes in future, create new one */ | ||
| 637 | static const struct ti_abb_reg abb_regs_v1 = { | ||
| 638 | /* WARNING: registers are wrongly documented in TRM */ | ||
| 639 | .setup_reg = 0x04, | ||
| 640 | .control_reg = 0x00, | ||
| 641 | |||
| 642 | .sr2_wtcnt_value_mask = (0xff << 8), | ||
| 643 | .fbb_sel_mask = (0x01 << 2), | ||
| 644 | .rbb_sel_mask = (0x01 << 1), | ||
| 645 | .sr2_en_mask = (0x01 << 0), | ||
| 646 | |||
| 647 | .opp_change_mask = (0x01 << 2), | ||
| 648 | .opp_sel_mask = (0x03 << 0), | ||
| 649 | }; | ||
| 650 | |||
| 651 | static const struct ti_abb_reg abb_regs_v2 = { | ||
| 652 | .setup_reg = 0x00, | ||
| 653 | .control_reg = 0x04, | ||
| 654 | |||
| 655 | .sr2_wtcnt_value_mask = (0xff << 8), | ||
| 656 | .fbb_sel_mask = (0x01 << 2), | ||
| 657 | .rbb_sel_mask = (0x01 << 1), | ||
| 658 | .sr2_en_mask = (0x01 << 0), | ||
| 659 | |||
| 660 | .opp_change_mask = (0x01 << 2), | ||
| 661 | .opp_sel_mask = (0x03 << 0), | ||
| 662 | }; | ||
| 663 | |||
| 664 | static const struct of_device_id ti_abb_of_match[] = { | ||
| 665 | {.compatible = "ti,abb-v1", .data = &abb_regs_v1}, | ||
| 666 | {.compatible = "ti,abb-v2", .data = &abb_regs_v2}, | ||
| 667 | { }, | ||
| 668 | }; | ||
| 669 | |||
| 670 | MODULE_DEVICE_TABLE(of, ti_abb_of_match); | ||
| 671 | |||
| 672 | /** | ||
| 673 | * ti_abb_probe() - Initialize an ABB ldo instance | ||
| 674 | * @pdev: ABB platform device | ||
| 675 | * | ||
| 676 | * Initializes an individual ABB LDO for required Body-Bias. ABB is used to | ||
| 677 | * addional bias supply to SoC modules for power savings or mandatory stability | ||
| 678 | * configuration at certain Operating Performance Points(OPPs). | ||
| 679 | * | ||
| 680 | * Return: 0 on success or appropriate error value when fails | ||
| 681 | */ | ||
| 682 | static int ti_abb_probe(struct platform_device *pdev) | ||
| 683 | { | ||
| 684 | struct device *dev = &pdev->dev; | ||
| 685 | const struct of_device_id *match; | ||
| 686 | struct resource *res; | ||
| 687 | struct ti_abb *abb; | ||
| 688 | struct regulator_init_data *initdata = NULL; | ||
| 689 | struct regulator_dev *rdev = NULL; | ||
| 690 | struct regulator_desc *desc; | ||
| 691 | struct regulation_constraints *c; | ||
| 692 | struct regulator_config config = { }; | ||
| 693 | char *pname; | ||
| 694 | int ret = 0; | ||
| 695 | |||
| 696 | match = of_match_device(ti_abb_of_match, dev); | ||
| 697 | if (!match) { | ||
| 698 | /* We do not expect this to happen */ | ||
| 699 | ret = -ENODEV; | ||
| 700 | dev_err(dev, "%s: Unable to match device\n", __func__); | ||
| 701 | goto err; | ||
| 702 | } | ||
| 703 | if (!match->data) { | ||
| 704 | ret = -EINVAL; | ||
| 705 | dev_err(dev, "%s: Bad data in match\n", __func__); | ||
| 706 | goto err; | ||
| 707 | } | ||
| 708 | |||
| 709 | abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL); | ||
| 710 | if (!abb) { | ||
| 711 | dev_err(dev, "%s: Unable to allocate ABB struct\n", __func__); | ||
| 712 | ret = -ENOMEM; | ||
| 713 | goto err; | ||
| 714 | } | ||
| 715 | abb->regs = match->data; | ||
| 716 | |||
| 717 | /* Map ABB resources */ | ||
| 718 | pname = "base-address"; | ||
| 719 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); | ||
| 720 | if (!res) { | ||
| 721 | dev_err(dev, "Missing '%s' IO resource\n", pname); | ||
| 722 | ret = -ENODEV; | ||
| 723 | goto err; | ||
| 724 | } | ||
| 725 | abb->base = devm_ioremap_resource(dev, res); | ||
| 726 | if (IS_ERR(abb->base)) { | ||
| 727 | ret = PTR_ERR(abb->base); | ||
| 728 | goto err; | ||
| 729 | } | ||
| 730 | |||
| 731 | pname = "int-address"; | ||
| 732 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); | ||
| 733 | if (!res) { | ||
| 734 | dev_err(dev, "Missing '%s' IO resource\n", pname); | ||
| 735 | ret = -ENODEV; | ||
| 736 | goto err; | ||
| 737 | } | ||
| 738 | /* | ||
| 739 | * We may have shared interrupt register offsets which are | ||
| 740 | * write-1-to-clear between domains ensuring exclusivity. | ||
| 741 | */ | ||
| 742 | abb->int_base = devm_ioremap_nocache(dev, res->start, | ||
| 743 | resource_size(res)); | ||
| 744 | if (!abb->int_base) { | ||
| 745 | dev_err(dev, "Unable to map '%s'\n", pname); | ||
| 746 | ret = -ENOMEM; | ||
| 747 | goto err; | ||
| 748 | } | ||
| 749 | |||
| 750 | /* Map Optional resources */ | ||
| 751 | pname = "efuse-address"; | ||
| 752 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); | ||
| 753 | if (!res) { | ||
| 754 | dev_dbg(dev, "Missing '%s' IO resource\n", pname); | ||
| 755 | ret = -ENODEV; | ||
| 756 | goto skip_opt; | ||
| 757 | } | ||
| 758 | |||
| 759 | /* | ||
| 760 | * We may have shared efuse register offsets which are read-only | ||
| 761 | * between domains | ||
| 762 | */ | ||
| 763 | abb->efuse_base = devm_ioremap_nocache(dev, res->start, | ||
| 764 | resource_size(res)); | ||
| 765 | if (!abb->efuse_base) { | ||
| 766 | dev_err(dev, "Unable to map '%s'\n", pname); | ||
| 767 | ret = -ENOMEM; | ||
| 768 | goto err; | ||
| 769 | } | ||
| 770 | |||
| 771 | pname = "ldo-address"; | ||
| 772 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); | ||
| 773 | if (!res) { | ||
| 774 | dev_dbg(dev, "Missing '%s' IO resource\n", pname); | ||
| 775 | ret = -ENODEV; | ||
| 776 | goto skip_opt; | ||
| 777 | } | ||
| 778 | abb->ldo_base = devm_ioremap_resource(dev, res); | ||
| 779 | if (IS_ERR(abb->ldo_base)) { | ||
| 780 | ret = PTR_ERR(abb->ldo_base); | ||
| 781 | goto err; | ||
| 782 | } | ||
| 783 | |||
| 784 | /* IF ldo_base is set, the following are mandatory */ | ||
| 785 | pname = "ti,ldovbb-override-mask"; | ||
| 786 | ret = | ||
| 787 | of_property_read_u32(pdev->dev.of_node, pname, | ||
| 788 | &abb->ldovbb_override_mask); | ||
| 789 | if (ret) { | ||
| 790 | dev_err(dev, "Missing '%s' (%d)\n", pname, ret); | ||
| 791 | goto err; | ||
| 792 | } | ||
| 793 | if (!abb->ldovbb_override_mask) { | ||
| 794 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); | ||
| 795 | ret = -EINVAL; | ||
| 796 | goto err; | ||
| 797 | } | ||
| 798 | |||
| 799 | pname = "ti,ldovbb-vset-mask"; | ||
| 800 | ret = | ||
| 801 | of_property_read_u32(pdev->dev.of_node, pname, | ||
| 802 | &abb->ldovbb_vset_mask); | ||
| 803 | if (ret) { | ||
| 804 | dev_err(dev, "Missing '%s' (%d)\n", pname, ret); | ||
| 805 | goto err; | ||
| 806 | } | ||
| 807 | if (!abb->ldovbb_vset_mask) { | ||
| 808 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); | ||
| 809 | ret = -EINVAL; | ||
| 810 | goto err; | ||
| 811 | } | ||
| 812 | |||
| 813 | skip_opt: | ||
| 814 | pname = "ti,tranxdone-status-mask"; | ||
| 815 | ret = | ||
| 816 | of_property_read_u32(pdev->dev.of_node, pname, | ||
| 817 | &abb->txdone_mask); | ||
| 818 | if (ret) { | ||
| 819 | dev_err(dev, "Missing '%s' (%d)\n", pname, ret); | ||
| 820 | goto err; | ||
| 821 | } | ||
| 822 | if (!abb->txdone_mask) { | ||
| 823 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); | ||
| 824 | ret = -EINVAL; | ||
| 825 | goto err; | ||
| 826 | } | ||
| 827 | |||
| 828 | initdata = of_get_regulator_init_data(dev, pdev->dev.of_node); | ||
| 829 | if (!initdata) { | ||
| 830 | ret = -ENOMEM; | ||
| 831 | dev_err(dev, "%s: Unable to alloc regulator init data\n", | ||
| 832 | __func__); | ||
| 833 | goto err; | ||
| 834 | } | ||
| 835 | |||
| 836 | /* init ABB opp_sel table */ | ||
| 837 | ret = ti_abb_init_table(dev, abb, initdata); | ||
| 838 | if (ret) | ||
| 839 | goto err; | ||
| 840 | |||
| 841 | /* init ABB timing */ | ||
| 842 | ret = ti_abb_init_timings(dev, abb); | ||
| 843 | if (ret) | ||
| 844 | goto err; | ||
| 845 | |||
| 846 | desc = &abb->rdesc; | ||
| 847 | desc->name = dev_name(dev); | ||
| 848 | desc->owner = THIS_MODULE; | ||
| 849 | desc->type = REGULATOR_VOLTAGE; | ||
| 850 | desc->ops = &ti_abb_reg_ops; | ||
| 851 | |||
| 852 | c = &initdata->constraints; | ||
| 853 | if (desc->n_voltages > 1) | ||
| 854 | c->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE; | ||
| 855 | c->always_on = true; | ||
| 856 | |||
| 857 | config.dev = dev; | ||
| 858 | config.init_data = initdata; | ||
| 859 | config.driver_data = abb; | ||
| 860 | config.of_node = pdev->dev.of_node; | ||
| 861 | |||
| 862 | rdev = regulator_register(desc, &config); | ||
| 863 | if (IS_ERR(rdev)) { | ||
| 864 | ret = PTR_ERR(rdev); | ||
| 865 | dev_err(dev, "%s: failed to register regulator(%d)\n", | ||
| 866 | __func__, ret); | ||
| 867 | goto err; | ||
| 868 | } | ||
| 869 | platform_set_drvdata(pdev, rdev); | ||
| 870 | |||
| 871 | /* Enable the ldo if not already done by bootloader */ | ||
| 872 | ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->regs->setup_reg, abb->base); | ||
| 873 | |||
| 874 | return 0; | ||
| 875 | |||
| 876 | err: | ||
| 877 | dev_err(dev, "%s: Failed to initialize(%d)\n", __func__, ret); | ||
| 878 | return ret; | ||
| 879 | } | ||
| 880 | |||
| 881 | /** | ||
| 882 | * ti_abb_remove() - cleanups | ||
| 883 | * @pdev: ABB platform device | ||
| 884 | * | ||
| 885 | * Return: 0 | ||
| 886 | */ | ||
| 887 | static int ti_abb_remove(struct platform_device *pdev) | ||
| 888 | { | ||
| 889 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | ||
| 890 | |||
| 891 | regulator_unregister(rdev); | ||
| 892 | return 0; | ||
| 893 | } | ||
| 894 | |||
| 895 | MODULE_ALIAS("platform:ti_abb"); | ||
| 896 | |||
| 897 | static struct platform_driver ti_abb_driver = { | ||
| 898 | .probe = ti_abb_probe, | ||
| 899 | .remove = ti_abb_remove, | ||
| 900 | .driver = { | ||
| 901 | .name = "ti_abb", | ||
| 902 | .owner = THIS_MODULE, | ||
| 903 | .of_match_table = of_match_ptr(ti_abb_of_match), | ||
| 904 | }, | ||
| 905 | }; | ||
| 906 | module_platform_driver(ti_abb_driver); | ||
| 907 | |||
| 908 | MODULE_DESCRIPTION("Texas Instruments ABB LDO regulator driver"); | ||
| 909 | MODULE_AUTHOR("Texas Instruments Inc."); | ||
| 910 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index 612919c3081c..a490d5b749b2 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c | |||
| @@ -351,7 +351,6 @@ static int tps62360_probe(struct i2c_client *client, | |||
| 351 | int chip_id; | 351 | int chip_id; |
| 352 | 352 | ||
| 353 | pdata = client->dev.platform_data; | 353 | pdata = client->dev.platform_data; |
| 354 | chip_id = id->driver_data; | ||
| 355 | 354 | ||
| 356 | if (client->dev.of_node) { | 355 | if (client->dev.of_node) { |
| 357 | const struct of_device_id *match; | 356 | const struct of_device_id *match; |
| @@ -364,6 +363,11 @@ static int tps62360_probe(struct i2c_client *client, | |||
| 364 | chip_id = (int)match->data; | 363 | chip_id = (int)match->data; |
| 365 | if (!pdata) | 364 | if (!pdata) |
| 366 | pdata = of_get_tps62360_platform_data(&client->dev); | 365 | pdata = of_get_tps62360_platform_data(&client->dev); |
| 366 | } else if (id) { | ||
| 367 | chip_id = id->driver_data; | ||
| 368 | } else { | ||
| 369 | dev_err(&client->dev, "No device tree match or id table match found\n"); | ||
| 370 | return -ENODEV; | ||
| 367 | } | 371 | } |
| 368 | 372 | ||
| 369 | if (!pdata) { | 373 | if (!pdata) { |
| @@ -402,7 +406,7 @@ static int tps62360_probe(struct i2c_client *client, | |||
| 402 | return -ENODEV; | 406 | return -ENODEV; |
| 403 | } | 407 | } |
| 404 | 408 | ||
| 405 | tps->desc.name = id->name; | 409 | tps->desc.name = client->name; |
| 406 | tps->desc.id = 0; | 410 | tps->desc.id = 0; |
| 407 | tps->desc.ops = &tps62360_dcdc_ops; | 411 | tps->desc.ops = &tps62360_dcdc_ops; |
| 408 | tps->desc.type = REGULATOR_VOLTAGE; | 412 | tps->desc.type = REGULATOR_VOLTAGE; |
diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c index df395187c063..2df4616621f5 100644 --- a/drivers/regulator/tps65217-regulator.c +++ b/drivers/regulator/tps65217-regulator.c | |||
| @@ -405,8 +405,6 @@ static int tps65217_regulator_remove(struct platform_device *pdev) | |||
| 405 | for (i = 0; i < TPS65217_NUM_REGULATOR; i++) | 405 | for (i = 0; i < TPS65217_NUM_REGULATOR; i++) |
| 406 | regulator_unregister(tps->rdev[i]); | 406 | regulator_unregister(tps->rdev[i]); |
| 407 | 407 | ||
| 408 | platform_set_drvdata(pdev, NULL); | ||
| 409 | |||
| 410 | return 0; | 408 | return 0; |
| 411 | } | 409 | } |
| 412 | 410 | ||
diff --git a/drivers/regulator/virtual.c b/drivers/regulator/virtual.c index 01c66e9712a4..a9d4284ea007 100644 --- a/drivers/regulator/virtual.c +++ b/drivers/regulator/virtual.c | |||
| @@ -330,8 +330,6 @@ static int regulator_virtual_remove(struct platform_device *pdev) | |||
| 330 | if (drvdata->enabled) | 330 | if (drvdata->enabled) |
| 331 | regulator_disable(drvdata->regulator); | 331 | regulator_disable(drvdata->regulator); |
| 332 | 332 | ||
| 333 | platform_set_drvdata(pdev, NULL); | ||
| 334 | |||
| 335 | return 0; | 333 | return 0; |
| 336 | } | 334 | } |
| 337 | 335 | ||
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c index 0af6898bcd79..46938cf162ad 100644 --- a/drivers/regulator/wm831x-dcdc.c +++ b/drivers/regulator/wm831x-dcdc.c | |||
| @@ -567,8 +567,6 @@ static int wm831x_buckv_remove(struct platform_device *pdev) | |||
| 567 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); | 567 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); |
| 568 | struct wm831x *wm831x = dcdc->wm831x; | 568 | struct wm831x *wm831x = dcdc->wm831x; |
| 569 | 569 | ||
| 570 | platform_set_drvdata(pdev, NULL); | ||
| 571 | |||
| 572 | free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "HC")), | 570 | free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "HC")), |
| 573 | dcdc); | 571 | dcdc); |
| 574 | free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")), | 572 | free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")), |
| @@ -714,8 +712,6 @@ static int wm831x_buckp_remove(struct platform_device *pdev) | |||
| 714 | { | 712 | { |
| 715 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); | 713 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); |
| 716 | 714 | ||
| 717 | platform_set_drvdata(pdev, NULL); | ||
| 718 | |||
| 719 | free_irq(wm831x_irq(dcdc->wm831x, platform_get_irq_byname(pdev, "UV")), | 715 | free_irq(wm831x_irq(dcdc->wm831x, platform_get_irq_byname(pdev, "UV")), |
| 720 | dcdc); | 716 | dcdc); |
| 721 | regulator_unregister(dcdc->regulator); | 717 | regulator_unregister(dcdc->regulator); |
| @@ -849,8 +845,6 @@ static int wm831x_boostp_remove(struct platform_device *pdev) | |||
| 849 | { | 845 | { |
| 850 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); | 846 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); |
| 851 | 847 | ||
| 852 | platform_set_drvdata(pdev, NULL); | ||
| 853 | |||
| 854 | free_irq(wm831x_irq(dcdc->wm831x, platform_get_irq_byname(pdev, "UV")), | 848 | free_irq(wm831x_irq(dcdc->wm831x, platform_get_irq_byname(pdev, "UV")), |
| 855 | dcdc); | 849 | dcdc); |
| 856 | regulator_unregister(dcdc->regulator); | 850 | regulator_unregister(dcdc->regulator); |
| @@ -940,7 +934,6 @@ static int wm831x_epe_remove(struct platform_device *pdev) | |||
| 940 | { | 934 | { |
| 941 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); | 935 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); |
| 942 | 936 | ||
| 943 | platform_set_drvdata(pdev, NULL); | ||
| 944 | regulator_unregister(dcdc->regulator); | 937 | regulator_unregister(dcdc->regulator); |
| 945 | 938 | ||
| 946 | return 0; | 939 | return 0; |
diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c index 68586ee3e1cb..16ebdf94d0a0 100644 --- a/drivers/regulator/wm831x-isink.c +++ b/drivers/regulator/wm831x-isink.c | |||
| @@ -225,8 +225,6 @@ static int wm831x_isink_remove(struct platform_device *pdev) | |||
| 225 | { | 225 | { |
| 226 | struct wm831x_isink *isink = platform_get_drvdata(pdev); | 226 | struct wm831x_isink *isink = platform_get_drvdata(pdev); |
| 227 | 227 | ||
| 228 | platform_set_drvdata(pdev, NULL); | ||
| 229 | |||
| 230 | free_irq(wm831x_irq(isink->wm831x, platform_get_irq(pdev, 0)), isink); | 228 | free_irq(wm831x_irq(isink->wm831x, platform_get_irq(pdev, 0)), isink); |
| 231 | 229 | ||
| 232 | regulator_unregister(isink->regulator); | 230 | regulator_unregister(isink->regulator); |
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c index 1ec379a9a95c..9ff883f80878 100644 --- a/drivers/regulator/wm831x-ldo.c +++ b/drivers/regulator/wm831x-ldo.c | |||
| @@ -338,8 +338,6 @@ static int wm831x_gp_ldo_remove(struct platform_device *pdev) | |||
| 338 | { | 338 | { |
| 339 | struct wm831x_ldo *ldo = platform_get_drvdata(pdev); | 339 | struct wm831x_ldo *ldo = platform_get_drvdata(pdev); |
| 340 | 340 | ||
| 341 | platform_set_drvdata(pdev, NULL); | ||
| 342 | |||
| 343 | free_irq(wm831x_irq(ldo->wm831x, | 341 | free_irq(wm831x_irq(ldo->wm831x, |
| 344 | platform_get_irq_byname(pdev, "UV")), ldo); | 342 | platform_get_irq_byname(pdev, "UV")), ldo); |
| 345 | regulator_unregister(ldo->regulator); | 343 | regulator_unregister(ldo->regulator); |
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c index c6a32ea80b9d..a09f03ee5506 100644 --- a/drivers/regulator/wm8400-regulator.c +++ b/drivers/regulator/wm8400-regulator.c | |||
| @@ -250,7 +250,6 @@ static int wm8400_regulator_remove(struct platform_device *pdev) | |||
| 250 | { | 250 | { |
| 251 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | 251 | struct regulator_dev *rdev = platform_get_drvdata(pdev); |
| 252 | 252 | ||
| 253 | platform_set_drvdata(pdev, NULL); | ||
| 254 | regulator_unregister(rdev); | 253 | regulator_unregister(rdev); |
| 255 | 254 | ||
| 256 | return 0; | 255 | return 0; |
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c index a612c356a697..8f2a8a7a3f99 100644 --- a/drivers/regulator/wm8994-regulator.c +++ b/drivers/regulator/wm8994-regulator.c | |||
| @@ -185,8 +185,6 @@ static int wm8994_ldo_remove(struct platform_device *pdev) | |||
| 185 | { | 185 | { |
| 186 | struct wm8994_ldo *ldo = platform_get_drvdata(pdev); | 186 | struct wm8994_ldo *ldo = platform_get_drvdata(pdev); |
| 187 | 187 | ||
| 188 | platform_set_drvdata(pdev, NULL); | ||
| 189 | |||
| 190 | regulator_unregister(ldo->regulator); | 188 | regulator_unregister(ldo->regulator); |
| 191 | 189 | ||
| 192 | return 0; | 190 | return 0; |
diff --git a/include/linux/mfd/max77693-private.h b/include/linux/mfd/max77693-private.h index 1aa4f13cdfa6..244fb0d51589 100644 --- a/include/linux/mfd/max77693-private.h +++ b/include/linux/mfd/max77693-private.h | |||
| @@ -85,6 +85,19 @@ enum max77693_pmic_reg { | |||
| 85 | MAX77693_PMIC_REG_END, | 85 | MAX77693_PMIC_REG_END, |
| 86 | }; | 86 | }; |
| 87 | 87 | ||
| 88 | /* MAX77693 CHG_CNFG_00 register */ | ||
| 89 | #define CHG_CNFG_00_CHG_MASK 0x1 | ||
| 90 | #define CHG_CNFG_00_BUCK_MASK 0x4 | ||
| 91 | |||
| 92 | /* MAX77693 CHG_CNFG_09 Register */ | ||
| 93 | #define CHG_CNFG_09_CHGIN_ILIM_MASK 0x7F | ||
| 94 | |||
| 95 | /* MAX77693 CHG_CTRL Register */ | ||
| 96 | #define SAFEOUT_CTRL_SAFEOUT1_MASK 0x3 | ||
| 97 | #define SAFEOUT_CTRL_SAFEOUT2_MASK 0xC | ||
| 98 | #define SAFEOUT_CTRL_ENSAFEOUT1_MASK 0x40 | ||
| 99 | #define SAFEOUT_CTRL_ENSAFEOUT2_MASK 0x80 | ||
| 100 | |||
| 88 | /* Slave addr = 0x4A: MUIC */ | 101 | /* Slave addr = 0x4A: MUIC */ |
| 89 | enum max77693_muic_reg { | 102 | enum max77693_muic_reg { |
| 90 | MAX77693_MUIC_REG_ID = 0x00, | 103 | MAX77693_MUIC_REG_ID = 0x00, |
diff --git a/include/linux/mfd/max77693.h b/include/linux/mfd/max77693.h index 3109a6c5c948..676f0f388992 100644 --- a/include/linux/mfd/max77693.h +++ b/include/linux/mfd/max77693.h | |||
| @@ -30,6 +30,20 @@ | |||
| 30 | #ifndef __LINUX_MFD_MAX77693_H | 30 | #ifndef __LINUX_MFD_MAX77693_H |
| 31 | #define __LINUX_MFD_MAX77693_H | 31 | #define __LINUX_MFD_MAX77693_H |
| 32 | 32 | ||
| 33 | /* MAX77686 regulator IDs */ | ||
| 34 | enum max77693_regulators { | ||
| 35 | MAX77693_ESAFEOUT1 = 0, | ||
| 36 | MAX77693_ESAFEOUT2, | ||
| 37 | MAX77693_CHARGER, | ||
| 38 | MAX77693_REG_MAX, | ||
| 39 | }; | ||
| 40 | |||
| 41 | struct max77693_regulator_data { | ||
| 42 | int id; | ||
| 43 | struct regulator_init_data *initdata; | ||
| 44 | struct device_node *of_node; | ||
| 45 | }; | ||
| 46 | |||
| 33 | struct max77693_reg_data { | 47 | struct max77693_reg_data { |
| 34 | u8 addr; | 48 | u8 addr; |
| 35 | u8 data; | 49 | u8 data; |
| @@ -52,6 +66,10 @@ struct max77693_muic_platform_data { | |||
| 52 | struct max77693_platform_data { | 66 | struct max77693_platform_data { |
| 53 | int wakeup; | 67 | int wakeup; |
| 54 | 68 | ||
| 69 | /* regulator data */ | ||
| 70 | struct max77693_regulator_data *regulators; | ||
| 71 | int num_regulators; | ||
| 72 | |||
| 55 | /* muic data */ | 73 | /* muic data */ |
| 56 | struct max77693_muic_platform_data *muic_data; | 74 | struct max77693_muic_platform_data *muic_data; |
| 57 | }; | 75 | }; |
diff --git a/include/linux/regulator/ab8500.h b/include/linux/regulator/ab8500.h index 7c5ff0c55773..75307447cef9 100644 --- a/include/linux/regulator/ab8500.h +++ b/include/linux/regulator/ab8500.h | |||
| @@ -336,8 +336,4 @@ static inline int ab8500_regulator_debug_exit(struct platform_device *pdev) | |||
| 336 | } | 336 | } |
| 337 | #endif | 337 | #endif |
| 338 | 338 | ||
| 339 | /* AB8500 external regulator functions. */ | ||
| 340 | int ab8500_ext_regulator_init(struct platform_device *pdev); | ||
| 341 | void ab8500_ext_regulator_exit(struct platform_device *pdev); | ||
| 342 | |||
| 343 | #endif | 339 | #endif |
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index 145022a83085..3a76389c6aaa 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h | |||
| @@ -165,6 +165,7 @@ int regulator_count_voltages(struct regulator *regulator); | |||
| 165 | int regulator_list_voltage(struct regulator *regulator, unsigned selector); | 165 | int regulator_list_voltage(struct regulator *regulator, unsigned selector); |
| 166 | int regulator_is_supported_voltage(struct regulator *regulator, | 166 | int regulator_is_supported_voltage(struct regulator *regulator, |
| 167 | int min_uV, int max_uV); | 167 | int min_uV, int max_uV); |
| 168 | unsigned int regulator_get_linear_step(struct regulator *regulator); | ||
| 168 | int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV); | 169 | int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV); |
| 169 | int regulator_set_voltage_time(struct regulator *regulator, | 170 | int regulator_set_voltage_time(struct regulator *regulator, |
| 170 | int old_uV, int new_uV); | 171 | int old_uV, int new_uV); |
