Skip to content

Commit 1fe4c00

Browse files
Ke LiuDivya Sharma
authored andcommitted
regulator: onsemi-ncp6335d: add support for tlmm spare register control
Certain Qualcomm chips mux the output of some GPIOs using the TLMM_SPARE register. Add support for a device tree property which can be used to specify a mask and value to write into this register so that the VSEL GPIO can be toggled successfully on affected devices. When the appropriate bits in the TLMM_SPARE register are written, the physical output of the GPIO can be controlled normally via GPIO control registers. Change-Id: Ic8a0886886a44687931ab5cb8150383cd84db2f6 Signed-off-by: Ke Liu <[email protected]> Signed-off-by: Divya Sharma <[email protected]>
1 parent 4dc88f2 commit 1fe4c00

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

Documentation/devicetree/bindings/regulator/onsemi-ncp6335d.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ Optional Properties:
3939
pins are low.
4040
Not Present: Low quiescent current mode when EN and VSEL
4141
pins are low.
42+
- onnn,tlmm-config: Array of 2 elements to indicate the mask value and the value
43+
to write in the masked bits.
44+
This property is used to allow the VSEL GPIO to toggle on certain
45+
Qualcomm processors. If it is not specified, then no register write is required.
46+
The 2 elements with index[0..1] are:
47+
[0] => the mask value;
48+
[1] => the value to write into the masked bits.
4249

4350

4451
Example:

drivers/regulator/onsemi-ncp6335d.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/of_gpio.h>
2525
#include <linux/regmap.h>
2626
#include <linux/regulator/onsemi-ncp6335d.h>
27+
#include <mach/gpiomux.h>
2728

2829
/* registers */
2930
#define REG_NCP6335D_PID 0x03
@@ -310,6 +311,31 @@ static int ncp6335d_parse_gpio(struct device_node *node,
310311

311312
return ret;
312313
}
314+
315+
static int ncp6335d_parse_tlmm(struct device_node *node,
316+
struct ncp6335d_info *dd)
317+
{
318+
int val, ret = 0;
319+
u32 tmp[2];
320+
321+
if (!of_find_property(node, "onnn,tlmm-config", NULL))
322+
return ret;
323+
324+
ret = of_property_read_u32_array(node, "onnn,tlmm-config", tmp, 2);
325+
if (ret) {
326+
dev_err(dd->dev, "onnn,tlmm-config is misconfigured, ret = %d",
327+
ret);
328+
return ret;
329+
}
330+
331+
val = msm_tlmm_misc_reg_read(TLMM_SPARE_REG);
332+
val &= ~tmp[0];
333+
val |= tmp[1] & tmp[0];
334+
msm_tlmm_misc_reg_write(TLMM_SPARE_REG, val);
335+
336+
return ret;
337+
}
338+
313339
static int __devinit ncp6335d_init(struct i2c_client *client,
314340
struct ncp6335d_info *dd,
315341
const struct ncp6335d_platform_data *pdata)
@@ -343,6 +369,10 @@ static int __devinit ncp6335d_init(struct i2c_client *client,
343369
if (rc)
344370
return rc;
345371

372+
rc = ncp6335d_parse_tlmm(client->dev.of_node, dd);
373+
if (rc)
374+
return rc;
375+
346376
/* get the current programmed voltage */
347377
rc = regmap_read(dd->regmap, dd->vsel_reg, &val);
348378
if (rc) {

0 commit comments

Comments
 (0)