Loading Documentation/devicetree/bindings/gpio/gpio-sx150x.txt +5 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,9 @@ Required properties: - sx150x,reset_gpio: System GPIO number connected to NRESET of SX150x devices. If "sx150x,reset_onprobe" is true, then the reset_gpio is pulled from low to high to reset the SX150x device. (optional) - <supply-name>-supply: phandle to the regulator device Required "supply-name" examples are: "vdd" : 1.8v supply for sx150x (io-expander). Example: Loading @@ -52,6 +55,7 @@ i2c@f9925000 { sx150x,reset_onprobe; sx150x,reset_gpio = <&msmgpio 138 0x00>; label = "ioexp-gpio"; vdd-supply = <&pm8917_l6>; }; }; Loading drivers/gpio/gpio-sx150x.c +39 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <linux/slab.h> #include <linux/workqueue.h> #include <linux/of_gpio.h> #include <linux/regulator/consumer.h> #include <linux/i2c/sx150x.h> #include <linux/of.h> #include <linux/delay.h> Loading Loading @@ -682,6 +683,25 @@ static int sx150x_parse_dt(struct device *dev, pdata->irq_summary = -1; /* Check: pdata->gpio_base = -1; */ pdata->vdd_in = devm_regulator_get(dev, "vdd"); if (IS_ERR(pdata->vdd_in)) { pr_err("Failed to get regulator: %ld\n", PTR_ERR(pdata->vdd_in)); return PTR_ERR(pdata->vdd_in); } rc = of_property_read_u32(np, "qcom,vdd-max-voltage", &temp); if (rc) pr_err("%s: No vdd_max voltage entries in dts %d\n", __func__, rc); pdata->vdd_in_maxv = temp; rc = of_property_read_u32(np, "qcom,vdd-min-voltage", &temp); if (rc) pr_err("%s: No vdd_min voltage entries in dts %d\n", __func__, rc); pdata->vdd_in_minv = temp; return 0; } #else Loading Loading @@ -714,6 +734,25 @@ static int sx150x_probe(struct i2c_client *client, if (!pdata) return -EINVAL; if (pdata->vdd_in) { if (regulator_count_voltages(pdata->vdd_in) > 0) { rc = regulator_set_voltage(pdata->vdd_in, pdata->vdd_in_minv, pdata->vdd_in_maxv); if (rc) { pr_err("unable to set volt for vdd_in\n"); return rc; } rc = regulator_enable(pdata->vdd_in); if (rc) { pr_err("unable to enable vdd_in\n"); regulator_set_voltage(pdata->vdd_in, 0, pdata->vdd_in_maxv); return rc; } } } if (!i2c_check_functionality(client->adapter, i2c_funcs)) return -ENOSYS; Loading include/linux/i2c/sx150x.h +3 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,9 @@ struct sx150x_platform_data { int irq_summary; unsigned irq_base; bool reset_during_probe; struct regulator *vdd_in; int vdd_in_minv; int vdd_in_maxv; }; #endif /* __LINUX_I2C_SX150X_H */ Loading
Documentation/devicetree/bindings/gpio/gpio-sx150x.txt +5 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,9 @@ Required properties: - sx150x,reset_gpio: System GPIO number connected to NRESET of SX150x devices. If "sx150x,reset_onprobe" is true, then the reset_gpio is pulled from low to high to reset the SX150x device. (optional) - <supply-name>-supply: phandle to the regulator device Required "supply-name" examples are: "vdd" : 1.8v supply for sx150x (io-expander). Example: Loading @@ -52,6 +55,7 @@ i2c@f9925000 { sx150x,reset_onprobe; sx150x,reset_gpio = <&msmgpio 138 0x00>; label = "ioexp-gpio"; vdd-supply = <&pm8917_l6>; }; }; Loading
drivers/gpio/gpio-sx150x.c +39 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <linux/slab.h> #include <linux/workqueue.h> #include <linux/of_gpio.h> #include <linux/regulator/consumer.h> #include <linux/i2c/sx150x.h> #include <linux/of.h> #include <linux/delay.h> Loading Loading @@ -682,6 +683,25 @@ static int sx150x_parse_dt(struct device *dev, pdata->irq_summary = -1; /* Check: pdata->gpio_base = -1; */ pdata->vdd_in = devm_regulator_get(dev, "vdd"); if (IS_ERR(pdata->vdd_in)) { pr_err("Failed to get regulator: %ld\n", PTR_ERR(pdata->vdd_in)); return PTR_ERR(pdata->vdd_in); } rc = of_property_read_u32(np, "qcom,vdd-max-voltage", &temp); if (rc) pr_err("%s: No vdd_max voltage entries in dts %d\n", __func__, rc); pdata->vdd_in_maxv = temp; rc = of_property_read_u32(np, "qcom,vdd-min-voltage", &temp); if (rc) pr_err("%s: No vdd_min voltage entries in dts %d\n", __func__, rc); pdata->vdd_in_minv = temp; return 0; } #else Loading Loading @@ -714,6 +734,25 @@ static int sx150x_probe(struct i2c_client *client, if (!pdata) return -EINVAL; if (pdata->vdd_in) { if (regulator_count_voltages(pdata->vdd_in) > 0) { rc = regulator_set_voltage(pdata->vdd_in, pdata->vdd_in_minv, pdata->vdd_in_maxv); if (rc) { pr_err("unable to set volt for vdd_in\n"); return rc; } rc = regulator_enable(pdata->vdd_in); if (rc) { pr_err("unable to enable vdd_in\n"); regulator_set_voltage(pdata->vdd_in, 0, pdata->vdd_in_maxv); return rc; } } } if (!i2c_check_functionality(client->adapter, i2c_funcs)) return -ENOSYS; Loading
include/linux/i2c/sx150x.h +3 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,9 @@ struct sx150x_platform_data { int irq_summary; unsigned irq_base; bool reset_during_probe; struct regulator *vdd_in; int vdd_in_minv; int vdd_in_maxv; }; #endif /* __LINUX_I2C_SX150X_H */