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

mfd: as3711: Add OF support

Add Flat Device Tree support to the AS3711 MFD driver. This patch just
allows to bind the driver to I2C devices, instantiated from the DT.
DT support for AS3711 cell drivers will be added in separate drivers.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
Reviwed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

authored by

Guennadi Liakhovetski and committed by
Samuel Ortiz
64710af3 5a324acf

+96 -4
+73
Documentation/devicetree/bindings/mfd/as3711.txt
··· 1 + AS3711 is an I2C PMIC from Austria MicroSystems with multiple DCDC and LDO power 2 + supplies, a battery charger and an RTC. So far only bindings for the two stepup 3 + DCDC converters are defined. Other DCDC and LDO supplies are configured, using 4 + standard regulator properties, they must belong to a sub-node, called 5 + "regulators" and be called "sd1" to "sd4" and "ldo1" to "ldo8." Stepup converter 6 + configuration should be placed in a subnode, called "backlight." 7 + 8 + Compulsory properties: 9 + - compatible : must be "ams,as3711" 10 + - reg : specifies the I2C address 11 + 12 + To use the SU1 converter as a backlight source the following two properties must 13 + be provided: 14 + - su1-dev : framebuffer phandle 15 + - su1-max-uA : maximum current 16 + 17 + To use the SU2 converter as a backlight source the following two properties must 18 + be provided: 19 + - su2-dev : framebuffer phandle 20 + - su1-max-uA : maximum current 21 + 22 + Additionally one of these properties must be provided to select the type of 23 + feedback used: 24 + - su2-feedback-voltage : voltage feedback is used 25 + - su2-feedback-curr1 : CURR1 input used for current feedback 26 + - su2-feedback-curr2 : CURR2 input used for current feedback 27 + - su2-feedback-curr3 : CURR3 input used for current feedback 28 + - su2-feedback-curr-auto: automatic current feedback selection 29 + 30 + and one of these to select the over-voltage protection pin 31 + - su2-fbprot-lx-sd4 : LX_SD4 is used for over-voltage protection 32 + - su2-fbprot-gpio2 : GPIO2 is used for over-voltage protection 33 + - su2-fbprot-gpio3 : GPIO3 is used for over-voltage protection 34 + - su2-fbprot-gpio4 : GPIO4 is used for over-voltage protection 35 + 36 + If "su2-feedback-curr-auto" is selected, one or more of the following properties 37 + have to be specified: 38 + - su2-auto-curr1 : use CURR1 input for current feedback 39 + - su2-auto-curr2 : use CURR2 input for current feedback 40 + - su2-auto-curr3 : use CURR3 input for current feedback 41 + 42 + Example: 43 + 44 + as3711@40 { 45 + compatible = "ams,as3711"; 46 + reg = <0x40>; 47 + 48 + regulators { 49 + sd4 { 50 + regulator-name = "1.215V"; 51 + regulator-min-microvolt = <1215000>; 52 + regulator-max-microvolt = <1235000>; 53 + }; 54 + ldo2 { 55 + regulator-name = "2.8V CPU"; 56 + regulator-min-microvolt = <2800000>; 57 + regulator-max-microvolt = <2800000>; 58 + regulator-always-on; 59 + regulator-boot-on; 60 + }; 61 + }; 62 + 63 + backlight { 64 + compatible = "ams,as3711-bl"; 65 + su2-dev = <&lcdc>; 66 + su2-max-uA = <36000>; 67 + su2-feedback-curr-auto; 68 + su2-fbprot-gpio4; 69 + su2-auto-curr1; 70 + su2-auto-curr2; 71 + su2-auto-curr3; 72 + }; 73 + };
+23 -4
drivers/mfd/as3711.c
··· 112 112 .cache_type = REGCACHE_RBTREE, 113 113 }; 114 114 115 + #ifdef CONFIG_OF 116 + static struct of_device_id as3711_of_match[] = { 117 + {.compatible = "ams,as3711",}, 118 + {} 119 + }; 120 + MODULE_DEVICE_TABLE(of, as3711_of_match); 121 + #endif 122 + 115 123 static int as3711_i2c_probe(struct i2c_client *client, 116 124 const struct i2c_device_id *id) 117 125 { 118 126 struct as3711 *as3711; 119 - struct as3711_platform_data *pdata = client->dev.platform_data; 127 + struct as3711_platform_data *pdata; 120 128 unsigned int id1, id2; 121 129 int ret; 122 130 123 - if (!pdata) 124 - dev_dbg(&client->dev, "Platform data not found\n"); 131 + if (!client->dev.of_node) { 132 + pdata = client->dev.platform_data; 133 + if (!pdata) 134 + dev_dbg(&client->dev, "Platform data not found\n"); 135 + } else { 136 + pdata = devm_kzalloc(&client->dev, 137 + sizeof(*pdata), GFP_KERNEL); 138 + if (!pdata) { 139 + dev_err(&client->dev, "Failed to allocate pdata\n"); 140 + return -ENOMEM; 141 + } 142 + } 125 143 126 144 as3711 = devm_kzalloc(&client->dev, sizeof(struct as3711), GFP_KERNEL); 127 145 if (!as3711) { ··· 211 193 .driver = { 212 194 .name = "as3711", 213 195 .owner = THIS_MODULE, 214 - }, 196 + .of_match_table = of_match_ptr(as3711_of_match), 197 + }, 215 198 .probe = as3711_i2c_probe, 216 199 .remove = as3711_i2c_remove, 217 200 .id_table = as3711_i2c_id,