* [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup @ 2019-10-18 5:24 Bjorn Andersson 2019-10-18 5:24 ` [PATCH 1/4] Bluetooth: hci_qca: Update regulator_set_load() usage Bjorn Andersson ` (5 more replies) 0 siblings, 6 replies; 17+ messages in thread From: Bjorn Andersson @ 2019-10-18 5:24 UTC (permalink / raw) To: Marcel Holtmann, Johan Hedberg Cc: linux-bluetooth, linux-kernel, Jeffrey Hugo, linux-arm-msm Clean up the regulator usage in hci_qca and in particular don't regulator_set_voltage() for fixed voltages. It cleans up the driver, but more important it makes bluetooth work on my Lenovo Yoga C630, where the regulator for vddch0 is defined with a voltage range that doesn't overlap the values in the driver. Bjorn Andersson (4): Bluetooth: hci_qca: Update regulator_set_load() usage Bluetooth: hci_qca: Don't vote for specific voltage Bluetooth: hci_qca: Use regulator bulk enable/disable Bluetooth: hci_qca: Split qca_power_setup() drivers/bluetooth/hci_qca.c | 135 +++++++++++++++--------------------- 1 file changed, 55 insertions(+), 80 deletions(-) -- 2.23.0 ^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 1/4] Bluetooth: hci_qca: Update regulator_set_load() usage 2019-10-18 5:24 [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup Bjorn Andersson @ 2019-10-18 5:24 ` Bjorn Andersson 2019-10-18 11:18 ` Harish Bandi 2019-10-18 5:24 ` [PATCH 2/4] Bluetooth: hci_qca: Don't vote for specific voltage Bjorn Andersson ` (4 subsequent siblings) 5 siblings, 1 reply; 17+ messages in thread From: Bjorn Andersson @ 2019-10-18 5:24 UTC (permalink / raw) To: Marcel Holtmann, Johan Hedberg Cc: linux-bluetooth, linux-kernel, Jeffrey Hugo, linux-arm-msm Since the introduction of '5451781dadf8 ("regulator: core: Only count load for enabled consumers")' in v5.0, the requested load of a regulator consumer is only accounted for when said consumer is voted enabled. So there's no need to vote for load ever time the regulator is enabled or disabled. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> --- drivers/bluetooth/hci_qca.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index e3164c200eac..c07c529b0d81 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -1393,13 +1393,6 @@ static int qca_enable_regulator(struct qca_vreg vregs, if (ret) return ret; - if (vregs.load_uA) - ret = regulator_set_load(regulator, - vregs.load_uA); - - if (ret) - return ret; - return regulator_enable(regulator); } @@ -1409,8 +1402,6 @@ static void qca_disable_regulator(struct qca_vreg vregs, { regulator_disable(regulator); regulator_set_voltage(regulator, 0, vregs.max_uV); - if (vregs.load_uA) - regulator_set_load(regulator, 0); } @@ -1462,18 +1453,30 @@ static int qca_power_setup(struct hci_uart *hu, bool on) static int qca_init_regulators(struct qca_power *qca, const struct qca_vreg *vregs, size_t num_vregs) { + struct regulator_bulk_data *bulk; + int ret; int i; - qca->vreg_bulk = devm_kcalloc(qca->dev, num_vregs, - sizeof(struct regulator_bulk_data), - GFP_KERNEL); - if (!qca->vreg_bulk) + bulk = devm_kcalloc(qca->dev, num_vregs, sizeof(*bulk), GFP_KERNEL); + if (!bulk) return -ENOMEM; for (i = 0; i < num_vregs; i++) - qca->vreg_bulk[i].supply = vregs[i].name; + bulk[i].supply = vregs[i].name; + + ret = devm_regulator_bulk_get(qca->dev, num_vregs, bulk); + if (ret < 0) + return ret; - return devm_regulator_bulk_get(qca->dev, num_vregs, qca->vreg_bulk); + for (i = 0; i < num_vregs; i++) { + ret = regulator_set_load(bulk[i].consumer, vregs[i].load_uA); + if (ret) + return ret; + } + + qca->vreg_bulk = bulk; + + return 0; } static int qca_serdev_probe(struct serdev_device *serdev) -- 2.23.0 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 1/4] Bluetooth: hci_qca: Update regulator_set_load() usage 2019-10-18 5:24 ` [PATCH 1/4] Bluetooth: hci_qca: Update regulator_set_load() usage Bjorn Andersson @ 2019-10-18 11:18 ` Harish Bandi 0 siblings, 0 replies; 17+ messages in thread From: Harish Bandi @ 2019-10-18 11:18 UTC (permalink / raw) To: Bjorn Andersson, Balakrishna Godavarthi Cc: Marcel Holtmann, Johan Hedberg, linux-bluetooth, linux-kernel, Jeffrey Hugo, linux-arm-msm, linux-bluetooth-owner On 2019-10-18 10:54, Bjorn Andersson wrote: > Since the introduction of '5451781dadf8 ("regulator: core: Only count > load for enabled consumers")' in v5.0, the requested load of a > regulator > consumer is only accounted for when said consumer is voted enabled. > > So there's no need to vote for load ever time the regulator is > enabled or disabled. > > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> > --- > drivers/bluetooth/hci_qca.c | 33 ++++++++++++++++++--------------- > 1 file changed, 18 insertions(+), 15 deletions(-) > > diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c > index e3164c200eac..c07c529b0d81 100644 > --- a/drivers/bluetooth/hci_qca.c > +++ b/drivers/bluetooth/hci_qca.c > @@ -1393,13 +1393,6 @@ static int qca_enable_regulator(struct qca_vreg > vregs, > if (ret) > return ret; > > - if (vregs.load_uA) > - ret = regulator_set_load(regulator, > - vregs.load_uA); > - > - if (ret) > - return ret; > - > return regulator_enable(regulator); > > } > @@ -1409,8 +1402,6 @@ static void qca_disable_regulator(struct qca_vreg > vregs, > { > regulator_disable(regulator); > regulator_set_voltage(regulator, 0, vregs.max_uV); > - if (vregs.load_uA) > - regulator_set_load(regulator, 0); > > } > > @@ -1462,18 +1453,30 @@ static int qca_power_setup(struct hci_uart *hu, > bool on) > static int qca_init_regulators(struct qca_power *qca, > const struct qca_vreg *vregs, size_t num_vregs) > { > + struct regulator_bulk_data *bulk; > + int ret; > int i; > > - qca->vreg_bulk = devm_kcalloc(qca->dev, num_vregs, > - sizeof(struct regulator_bulk_data), > - GFP_KERNEL); > - if (!qca->vreg_bulk) > + bulk = devm_kcalloc(qca->dev, num_vregs, sizeof(*bulk), GFP_KERNEL); > + if (!bulk) > return -ENOMEM; > > for (i = 0; i < num_vregs; i++) > - qca->vreg_bulk[i].supply = vregs[i].name; > + bulk[i].supply = vregs[i].name; > + > + ret = devm_regulator_bulk_get(qca->dev, num_vregs, bulk); > + if (ret < 0) > + return ret; > > - return devm_regulator_bulk_get(qca->dev, num_vregs, qca->vreg_bulk); > + for (i = 0; i < num_vregs; i++) { > + ret = regulator_set_load(bulk[i].consumer, vregs[i].load_uA); > + if (ret) > + return ret; > + } > + > + qca->vreg_bulk = bulk; > + > + return 0; > } > > static int qca_serdev_probe(struct serdev_device *serdev) ^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 2/4] Bluetooth: hci_qca: Don't vote for specific voltage 2019-10-18 5:24 [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup Bjorn Andersson 2019-10-18 5:24 ` [PATCH 1/4] Bluetooth: hci_qca: Update regulator_set_load() usage Bjorn Andersson @ 2019-10-18 5:24 ` Bjorn Andersson 2019-10-18 11:18 ` Harish Bandi 2019-10-18 18:22 ` Matthias Kaehlcke 2019-10-18 5:24 ` [PATCH 3/4] Bluetooth: hci_qca: Use regulator bulk enable/disable Bjorn Andersson ` (3 subsequent siblings) 5 siblings, 2 replies; 17+ messages in thread From: Bjorn Andersson @ 2019-10-18 5:24 UTC (permalink / raw) To: Marcel Holtmann, Johan Hedberg Cc: linux-bluetooth, linux-kernel, Jeffrey Hugo, linux-arm-msm Devices with specific voltage requirements should not request voltage from the driver, but instead rely on the system configuration to define appropriate voltages for each rail. This ensures that PMIC and board variations are accounted for, something that the 0.1V range in the hci_qca driver currently tries to address. But on the Lenovo Yoga C630 (with wcn3990) vddch0 is 3.1V, which means the driver will fail to set the voltage. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> --- drivers/bluetooth/hci_qca.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index c07c529b0d81..54aafcc69d06 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -130,8 +130,6 @@ enum qca_speed_type { */ struct qca_vreg { const char *name; - unsigned int min_uV; - unsigned int max_uV; unsigned int load_uA; }; @@ -1332,10 +1330,10 @@ static const struct hci_uart_proto qca_proto = { static const struct qca_vreg_data qca_soc_data_wcn3990 = { .soc_type = QCA_WCN3990, .vregs = (struct qca_vreg []) { - { "vddio", 1800000, 1900000, 15000 }, - { "vddxo", 1800000, 1900000, 80000 }, - { "vddrf", 1300000, 1350000, 300000 }, - { "vddch0", 3300000, 3400000, 450000 }, + { "vddio", 15000 }, + { "vddxo", 80000 }, + { "vddrf", 300000 }, + { "vddch0", 450000 }, }, .num_vregs = 4, }; @@ -1343,10 +1341,10 @@ static const struct qca_vreg_data qca_soc_data_wcn3990 = { static const struct qca_vreg_data qca_soc_data_wcn3998 = { .soc_type = QCA_WCN3998, .vregs = (struct qca_vreg []) { - { "vddio", 1800000, 1900000, 10000 }, - { "vddxo", 1800000, 1900000, 80000 }, - { "vddrf", 1300000, 1352000, 300000 }, - { "vddch0", 3300000, 3300000, 450000 }, + { "vddio", 10000 }, + { "vddxo", 80000 }, + { "vddrf", 300000 }, + { "vddch0", 450000 }, }, .num_vregs = 4, }; @@ -1386,13 +1384,6 @@ static int qca_power_off(struct hci_dev *hdev) static int qca_enable_regulator(struct qca_vreg vregs, struct regulator *regulator) { - int ret; - - ret = regulator_set_voltage(regulator, vregs.min_uV, - vregs.max_uV); - if (ret) - return ret; - return regulator_enable(regulator); } @@ -1401,7 +1392,6 @@ static void qca_disable_regulator(struct qca_vreg vregs, struct regulator *regulator) { regulator_disable(regulator); - regulator_set_voltage(regulator, 0, vregs.max_uV); } -- 2.23.0 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 2/4] Bluetooth: hci_qca: Don't vote for specific voltage 2019-10-18 5:24 ` [PATCH 2/4] Bluetooth: hci_qca: Don't vote for specific voltage Bjorn Andersson @ 2019-10-18 11:18 ` Harish Bandi 2019-10-18 18:22 ` Matthias Kaehlcke 1 sibling, 0 replies; 17+ messages in thread From: Harish Bandi @ 2019-10-18 11:18 UTC (permalink / raw) To: Bjorn Andersson, Balakrishna Godavarthi Cc: Marcel Holtmann, Johan Hedberg, linux-bluetooth, linux-kernel, Jeffrey Hugo, linux-arm-msm, linux-bluetooth-owner On 2019-10-18 10:54, Bjorn Andersson wrote: > Devices with specific voltage requirements should not request voltage > from the driver, but instead rely on the system configuration to define > appropriate voltages for each rail. > > This ensures that PMIC and board variations are accounted for, > something > that the 0.1V range in the hci_qca driver currently tries to address. > But on the Lenovo Yoga C630 (with wcn3990) vddch0 is 3.1V, which means > the driver will fail to set the voltage. > > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> > --- > drivers/bluetooth/hci_qca.c | 26 ++++++++------------------ > 1 file changed, 8 insertions(+), 18 deletions(-) > > diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c > index c07c529b0d81..54aafcc69d06 100644 > --- a/drivers/bluetooth/hci_qca.c > +++ b/drivers/bluetooth/hci_qca.c > @@ -130,8 +130,6 @@ enum qca_speed_type { > */ > struct qca_vreg { > const char *name; > - unsigned int min_uV; > - unsigned int max_uV; > unsigned int load_uA; > }; > > @@ -1332,10 +1330,10 @@ static const struct hci_uart_proto qca_proto = > { > static const struct qca_vreg_data qca_soc_data_wcn3990 = { > .soc_type = QCA_WCN3990, > .vregs = (struct qca_vreg []) { > - { "vddio", 1800000, 1900000, 15000 }, > - { "vddxo", 1800000, 1900000, 80000 }, > - { "vddrf", 1300000, 1350000, 300000 }, > - { "vddch0", 3300000, 3400000, 450000 }, > + { "vddio", 15000 }, > + { "vddxo", 80000 }, > + { "vddrf", 300000 }, > + { "vddch0", 450000 }, > }, > .num_vregs = 4, > }; > @@ -1343,10 +1341,10 @@ static const struct qca_vreg_data > qca_soc_data_wcn3990 = { > static const struct qca_vreg_data qca_soc_data_wcn3998 = { > .soc_type = QCA_WCN3998, > .vregs = (struct qca_vreg []) { > - { "vddio", 1800000, 1900000, 10000 }, > - { "vddxo", 1800000, 1900000, 80000 }, > - { "vddrf", 1300000, 1352000, 300000 }, > - { "vddch0", 3300000, 3300000, 450000 }, > + { "vddio", 10000 }, > + { "vddxo", 80000 }, > + { "vddrf", 300000 }, > + { "vddch0", 450000 }, > }, > .num_vregs = 4, > }; > @@ -1386,13 +1384,6 @@ static int qca_power_off(struct hci_dev *hdev) > static int qca_enable_regulator(struct qca_vreg vregs, > struct regulator *regulator) > { > - int ret; > - > - ret = regulator_set_voltage(regulator, vregs.min_uV, > - vregs.max_uV); > - if (ret) > - return ret; > - > return regulator_enable(regulator); > > } > @@ -1401,7 +1392,6 @@ static void qca_disable_regulator(struct qca_vreg > vregs, > struct regulator *regulator) > { > regulator_disable(regulator); > - regulator_set_voltage(regulator, 0, vregs.max_uV); > > } ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 2/4] Bluetooth: hci_qca: Don't vote for specific voltage 2019-10-18 5:24 ` [PATCH 2/4] Bluetooth: hci_qca: Don't vote for specific voltage Bjorn Andersson 2019-10-18 11:18 ` Harish Bandi @ 2019-10-18 18:22 ` Matthias Kaehlcke 2019-10-21 6:37 ` Harish Bandi 1 sibling, 1 reply; 17+ messages in thread From: Matthias Kaehlcke @ 2019-10-18 18:22 UTC (permalink / raw) To: Bjorn Andersson Cc: Marcel Holtmann, Johan Hedberg, linux-bluetooth, linux-kernel, Jeffrey Hugo, linux-arm-msm On Thu, Oct 17, 2019 at 10:24:02PM -0700, Bjorn Andersson wrote: > Devices with specific voltage requirements should not request voltage > from the driver, but instead rely on the system configuration to define > appropriate voltages for each rail. > > This ensures that PMIC and board variations are accounted for, something > that the 0.1V range in the hci_qca driver currently tries to address. > But on the Lenovo Yoga C630 (with wcn3990) vddch0 is 3.1V, which means > the driver will fail to set the voltage. > > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> > --- > drivers/bluetooth/hci_qca.c | 26 ++++++++------------------ > 1 file changed, 8 insertions(+), 18 deletions(-) > > diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c > index c07c529b0d81..54aafcc69d06 100644 > --- a/drivers/bluetooth/hci_qca.c > +++ b/drivers/bluetooth/hci_qca.c > @@ -130,8 +130,6 @@ enum qca_speed_type { > */ > struct qca_vreg { > const char *name; > - unsigned int min_uV; > - unsigned int max_uV; > unsigned int load_uA; > }; > > @@ -1332,10 +1330,10 @@ static const struct hci_uart_proto qca_proto = { > static const struct qca_vreg_data qca_soc_data_wcn3990 = { > .soc_type = QCA_WCN3990, > .vregs = (struct qca_vreg []) { > - { "vddio", 1800000, 1900000, 15000 }, > - { "vddxo", 1800000, 1900000, 80000 }, > - { "vddrf", 1300000, 1350000, 300000 }, > - { "vddch0", 3300000, 3400000, 450000 }, > + { "vddio", 15000 }, > + { "vddxo", 80000 }, > + { "vddrf", 300000 }, > + { "vddch0", 450000 }, > }, > .num_vregs = 4, > }; > @@ -1343,10 +1341,10 @@ static const struct qca_vreg_data qca_soc_data_wcn3990 = { > static const struct qca_vreg_data qca_soc_data_wcn3998 = { > .soc_type = QCA_WCN3998, > .vregs = (struct qca_vreg []) { > - { "vddio", 1800000, 1900000, 10000 }, > - { "vddxo", 1800000, 1900000, 80000 }, > - { "vddrf", 1300000, 1352000, 300000 }, > - { "vddch0", 3300000, 3300000, 450000 }, > + { "vddio", 10000 }, > + { "vddxo", 80000 }, > + { "vddrf", 300000 }, > + { "vddch0", 450000 }, > }, > .num_vregs = 4, > }; > @@ -1386,13 +1384,6 @@ static int qca_power_off(struct hci_dev *hdev) > static int qca_enable_regulator(struct qca_vreg vregs, > struct regulator *regulator) > { > - int ret; > - > - ret = regulator_set_voltage(regulator, vregs.min_uV, > - vregs.max_uV); > - if (ret) > - return ret; > - > return regulator_enable(regulator); > > } > @@ -1401,7 +1392,6 @@ static void qca_disable_regulator(struct qca_vreg vregs, > struct regulator *regulator) > { > regulator_disable(regulator); > - regulator_set_voltage(regulator, 0, vregs.max_uV); > > } This was brought up multiple times during the initial review, but wasn't addressed. Reviewed-by: Matthias Kaehlcke <mka@chromium.org> ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 2/4] Bluetooth: hci_qca: Don't vote for specific voltage 2019-10-18 18:22 ` Matthias Kaehlcke @ 2019-10-21 6:37 ` Harish Bandi 2019-10-22 6:05 ` Balakrishna Godavarthi 0 siblings, 1 reply; 17+ messages in thread From: Harish Bandi @ 2019-10-21 6:37 UTC (permalink / raw) To: Matthias Kaehlcke, Balakrishna Godavarthi Cc: Bjorn Andersson, Marcel Holtmann, Johan Hedberg, linux-bluetooth, linux-kernel, Jeffrey Hugo, linux-arm-msm, linux-bluetooth-owner + Bala On 2019-10-18 23:52, Matthias Kaehlcke wrote: > On Thu, Oct 17, 2019 at 10:24:02PM -0700, Bjorn Andersson wrote: >> Devices with specific voltage requirements should not request voltage >> from the driver, but instead rely on the system configuration to >> define >> appropriate voltages for each rail. >> >> This ensures that PMIC and board variations are accounted for, >> something >> that the 0.1V range in the hci_qca driver currently tries to address. >> But on the Lenovo Yoga C630 (with wcn3990) vddch0 is 3.1V, which means >> the driver will fail to set the voltage. >> >> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> >> --- >> drivers/bluetooth/hci_qca.c | 26 ++++++++------------------ >> 1 file changed, 8 insertions(+), 18 deletions(-) >> >> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c >> index c07c529b0d81..54aafcc69d06 100644 >> --- a/drivers/bluetooth/hci_qca.c >> +++ b/drivers/bluetooth/hci_qca.c >> @@ -130,8 +130,6 @@ enum qca_speed_type { >> */ >> struct qca_vreg { >> const char *name; >> - unsigned int min_uV; >> - unsigned int max_uV; >> unsigned int load_uA; >> }; >> >> @@ -1332,10 +1330,10 @@ static const struct hci_uart_proto qca_proto = >> { >> static const struct qca_vreg_data qca_soc_data_wcn3990 = { >> .soc_type = QCA_WCN3990, >> .vregs = (struct qca_vreg []) { >> - { "vddio", 1800000, 1900000, 15000 }, >> - { "vddxo", 1800000, 1900000, 80000 }, >> - { "vddrf", 1300000, 1350000, 300000 }, >> - { "vddch0", 3300000, 3400000, 450000 }, >> + { "vddio", 15000 }, >> + { "vddxo", 80000 }, >> + { "vddrf", 300000 }, >> + { "vddch0", 450000 }, >> }, >> .num_vregs = 4, >> }; >> @@ -1343,10 +1341,10 @@ static const struct qca_vreg_data >> qca_soc_data_wcn3990 = { >> static const struct qca_vreg_data qca_soc_data_wcn3998 = { >> .soc_type = QCA_WCN3998, >> .vregs = (struct qca_vreg []) { >> - { "vddio", 1800000, 1900000, 10000 }, >> - { "vddxo", 1800000, 1900000, 80000 }, >> - { "vddrf", 1300000, 1352000, 300000 }, >> - { "vddch0", 3300000, 3300000, 450000 }, >> + { "vddio", 10000 }, >> + { "vddxo", 80000 }, >> + { "vddrf", 300000 }, >> + { "vddch0", 450000 }, >> }, >> .num_vregs = 4, >> }; >> @@ -1386,13 +1384,6 @@ static int qca_power_off(struct hci_dev *hdev) >> static int qca_enable_regulator(struct qca_vreg vregs, >> struct regulator *regulator) >> { >> - int ret; >> - >> - ret = regulator_set_voltage(regulator, vregs.min_uV, >> - vregs.max_uV); >> - if (ret) >> - return ret; >> - >> return regulator_enable(regulator); >> >> } >> @@ -1401,7 +1392,6 @@ static void qca_disable_regulator(struct >> qca_vreg vregs, >> struct regulator *regulator) >> { >> regulator_disable(regulator); >> - regulator_set_voltage(regulator, 0, vregs.max_uV); >> >> } > > This was brought up multiple times during the initial review, but > wasn't addressed. > > Reviewed-by: Matthias Kaehlcke <mka@chromium.org> ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 2/4] Bluetooth: hci_qca: Don't vote for specific voltage 2019-10-21 6:37 ` Harish Bandi @ 2019-10-22 6:05 ` Balakrishna Godavarthi 2019-10-22 17:15 ` Matthias Kaehlcke 0 siblings, 1 reply; 17+ messages in thread From: Balakrishna Godavarthi @ 2019-10-22 6:05 UTC (permalink / raw) To: Matthias Kaehlcke, Bjorn Andersson Cc: Marcel Holtmann, Johan Hedberg, linux-bluetooth, linux-kernel, Jeffrey Hugo, linux-arm-msm, linux-bluetooth-owner, hemantg, Harish Bandi Hi Matthias, Bjorn andresson, On 2019-10-21 12:07, Harish Bandi wrote: > + Bala > > On 2019-10-18 23:52, Matthias Kaehlcke wrote: >> On Thu, Oct 17, 2019 at 10:24:02PM -0700, Bjorn Andersson wrote: >>> Devices with specific voltage requirements should not request voltage >>> from the driver, but instead rely on the system configuration to >>> define >>> appropriate voltages for each rail. >>> >>> This ensures that PMIC and board variations are accounted for, >>> something >>> that the 0.1V range in the hci_qca driver currently tries to address. >>> But on the Lenovo Yoga C630 (with wcn3990) vddch0 is 3.1V, which >>> means >>> the driver will fail to set the voltage. >>> >>> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> >>> --- >>> drivers/bluetooth/hci_qca.c | 26 ++++++++------------------ >>> 1 file changed, 8 insertions(+), 18 deletions(-) >>> >>> diff --git a/drivers/bluetooth/hci_qca.c >>> b/drivers/bluetooth/hci_qca.c >>> index c07c529b0d81..54aafcc69d06 100644 >>> --- a/drivers/bluetooth/hci_qca.c >>> +++ b/drivers/bluetooth/hci_qca.c >>> @@ -130,8 +130,6 @@ enum qca_speed_type { >>> */ >>> struct qca_vreg { >>> const char *name; >>> - unsigned int min_uV; >>> - unsigned int max_uV; >>> unsigned int load_uA; >>> }; >>> >>> @@ -1332,10 +1330,10 @@ static const struct hci_uart_proto qca_proto >>> = { >>> static const struct qca_vreg_data qca_soc_data_wcn3990 = { >>> .soc_type = QCA_WCN3990, >>> .vregs = (struct qca_vreg []) { >>> - { "vddio", 1800000, 1900000, 15000 }, >>> - { "vddxo", 1800000, 1900000, 80000 }, >>> - { "vddrf", 1300000, 1350000, 300000 }, >>> - { "vddch0", 3300000, 3400000, 450000 }, >>> + { "vddio", 15000 }, >>> + { "vddxo", 80000 }, >>> + { "vddrf", 300000 }, >>> + { "vddch0", 450000 }, >>> }, >>> .num_vregs = 4, >>> }; >>> @@ -1343,10 +1341,10 @@ static const struct qca_vreg_data >>> qca_soc_data_wcn3990 = { >>> static const struct qca_vreg_data qca_soc_data_wcn3998 = { >>> .soc_type = QCA_WCN3998, >>> .vregs = (struct qca_vreg []) { >>> - { "vddio", 1800000, 1900000, 10000 }, >>> - { "vddxo", 1800000, 1900000, 80000 }, >>> - { "vddrf", 1300000, 1352000, 300000 }, >>> - { "vddch0", 3300000, 3300000, 450000 }, >>> + { "vddio", 10000 }, >>> + { "vddxo", 80000 }, >>> + { "vddrf", 300000 }, >>> + { "vddch0", 450000 }, >>> }, >>> .num_vregs = 4, >>> }; >>> @@ -1386,13 +1384,6 @@ static int qca_power_off(struct hci_dev *hdev) >>> static int qca_enable_regulator(struct qca_vreg vregs, >>> struct regulator *regulator) >>> { >>> - int ret; >>> - >>> - ret = regulator_set_voltage(regulator, vregs.min_uV, >>> - vregs.max_uV); >>> - if (ret) >>> - return ret; >>> - >>> return regulator_enable(regulator); >>> >>> } >>> @@ -1401,7 +1392,6 @@ static void qca_disable_regulator(struct >>> qca_vreg vregs, >>> struct regulator *regulator) >>> { >>> regulator_disable(regulator); >>> - regulator_set_voltage(regulator, 0, vregs.max_uV); >>> >>> } >> >> This was brought up multiple times during the initial review, but >> wasn't addressed. >> >> Reviewed-by: Matthias Kaehlcke <mka@chromium.org> yes true PMIC dts regulator should do this. But we have some real time issues observed. Issue 1: In PMIC dts node, ASAIK we have three levels of voltages. 1. Default voltage. 2. Minimum voltage. (mandatory entry) 3. Maximum voltage. (mandatory entry) Let us assume that the if PMIC regulator dts node supports defaults voltage to 3.2 Volts and Min as 3.1 V and max as 3.3V So default operating voltage is 3.1V when we turn on BT (but according to spec SoC requires min of 3.3V to operate, Might have some functionality failures on end to end testing Issue 2: WCN3990 RF is shared with WiFi, so it also try to turn on the regulators. Wifi driver uses the same approach of restricting to min and max voltages in driver. Let us assume we turned ON BT and CH0 is set to 3.1v (as in your case), Wifi is tuned on now, as its request the CH0 to operate at 3.3 Volts, regulator will fail to set this voltage as BT is operating at CH0 3.1v (assuming max voltage is 3.2v) https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/drivers/net/wireless/ath/ath10k/snoc.c#n39 Issue 3: By mistake PMIC has low min or default voltage and high max voltages, that is harm for WNC3990. I would suggest to restrict the min and max voltages in driver, instead of relaying on PMIC to do this. BTW pmic will do this and doing it in our driver is safer. Let me know your views on this. -- Regards Balakrishna. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 2/4] Bluetooth: hci_qca: Don't vote for specific voltage 2019-10-22 6:05 ` Balakrishna Godavarthi @ 2019-10-22 17:15 ` Matthias Kaehlcke 2019-10-30 6:18 ` Balakrishna Godavarthi 0 siblings, 1 reply; 17+ messages in thread From: Matthias Kaehlcke @ 2019-10-22 17:15 UTC (permalink / raw) To: Balakrishna Godavarthi Cc: Bjorn Andersson, Marcel Holtmann, Johan Hedberg, linux-bluetooth, linux-kernel, Jeffrey Hugo, linux-arm-msm, linux-bluetooth-owner, hemantg, Harish Bandi, Stephen Boyd On Tue, Oct 22, 2019 at 11:35:43AM +0530, Balakrishna Godavarthi wrote: > Hi Matthias, Bjorn andresson, > > On 2019-10-21 12:07, Harish Bandi wrote: > > + Bala > > > > On 2019-10-18 23:52, Matthias Kaehlcke wrote: > > > On Thu, Oct 17, 2019 at 10:24:02PM -0700, Bjorn Andersson wrote: > > > > Devices with specific voltage requirements should not request voltage > > > > from the driver, but instead rely on the system configuration to > > > > define > > > > appropriate voltages for each rail. > > > > > > > > This ensures that PMIC and board variations are accounted for, > > > > something > > > > that the 0.1V range in the hci_qca driver currently tries to address. > > > > But on the Lenovo Yoga C630 (with wcn3990) vddch0 is 3.1V, which > > > > means > > > > the driver will fail to set the voltage. > > > > > > > > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> > > > > --- > > > > drivers/bluetooth/hci_qca.c | 26 ++++++++------------------ > > > > 1 file changed, 8 insertions(+), 18 deletions(-) > > > > > > > > diff --git a/drivers/bluetooth/hci_qca.c > > > > b/drivers/bluetooth/hci_qca.c > > > > index c07c529b0d81..54aafcc69d06 100644 > > > > --- a/drivers/bluetooth/hci_qca.c > > > > +++ b/drivers/bluetooth/hci_qca.c > > > > @@ -130,8 +130,6 @@ enum qca_speed_type { > > > > */ > > > > struct qca_vreg { > > > > const char *name; > > > > - unsigned int min_uV; > > > > - unsigned int max_uV; > > > > unsigned int load_uA; > > > > }; > > > > > > > > @@ -1332,10 +1330,10 @@ static const struct hci_uart_proto > > > > qca_proto = { > > > > static const struct qca_vreg_data qca_soc_data_wcn3990 = { > > > > .soc_type = QCA_WCN3990, > > > > .vregs = (struct qca_vreg []) { > > > > - { "vddio", 1800000, 1900000, 15000 }, > > > > - { "vddxo", 1800000, 1900000, 80000 }, > > > > - { "vddrf", 1300000, 1350000, 300000 }, > > > > - { "vddch0", 3300000, 3400000, 450000 }, > > > > + { "vddio", 15000 }, > > > > + { "vddxo", 80000 }, > > > > + { "vddrf", 300000 }, > > > > + { "vddch0", 450000 }, > > > > }, > > > > .num_vregs = 4, > > > > }; > > > > @@ -1343,10 +1341,10 @@ static const struct qca_vreg_data > > > > qca_soc_data_wcn3990 = { > > > > static const struct qca_vreg_data qca_soc_data_wcn3998 = { > > > > .soc_type = QCA_WCN3998, > > > > .vregs = (struct qca_vreg []) { > > > > - { "vddio", 1800000, 1900000, 10000 }, > > > > - { "vddxo", 1800000, 1900000, 80000 }, > > > > - { "vddrf", 1300000, 1352000, 300000 }, > > > > - { "vddch0", 3300000, 3300000, 450000 }, > > > > + { "vddio", 10000 }, > > > > + { "vddxo", 80000 }, > > > > + { "vddrf", 300000 }, > > > > + { "vddch0", 450000 }, > > > > }, > > > > .num_vregs = 4, > > > > }; > > > > @@ -1386,13 +1384,6 @@ static int qca_power_off(struct hci_dev *hdev) > > > > static int qca_enable_regulator(struct qca_vreg vregs, > > > > struct regulator *regulator) > > > > { > > > > - int ret; > > > > - > > > > - ret = regulator_set_voltage(regulator, vregs.min_uV, > > > > - vregs.max_uV); > > > > - if (ret) > > > > - return ret; > > > > - > > > > return regulator_enable(regulator); > > > > > > > > } > > > > @@ -1401,7 +1392,6 @@ static void qca_disable_regulator(struct > > > > qca_vreg vregs, > > > > struct regulator *regulator) > > > > { > > > > regulator_disable(regulator); > > > > - regulator_set_voltage(regulator, 0, vregs.max_uV); > > > > > > > > } > > > > > > This was brought up multiple times during the initial review, but > > > wasn't addressed. > > > > > > Reviewed-by: Matthias Kaehlcke <mka@chromium.org> > > > yes true PMIC dts regulator should do this. > But we have some real time issues observed. > > Issue 1: > > In PMIC dts node, ASAIK we have three levels of voltages. > > 1. Default voltage. > 2. Minimum voltage. (mandatory entry) > 3. Maximum voltage. (mandatory entry) > > Let us assume that the if PMIC regulator dts node supports defaults voltage > to 3.2 Volts and Min as 3.1 V and max as 3.3V > So default operating voltage is 3.1V when we turn on BT (but according to > spec SoC requires min of 3.3V to operate, > Might have some functionality failures on end to end testing The PMIC regulator shouldn't be configured with the entire range of voltages it can generate, but with a range of voltages that is suitable for all its consumers. In other words if BT requires a minimum voltage of 3.3V the minimum voltage of the regulator should be at least 3.3V. > Issue 2: > > WCN3990 RF is shared with WiFi, so it also try to turn on the regulators. > Wifi driver uses the same approach of restricting to min and max voltages in > driver. > Let us assume we turned ON BT and CH0 is set to 3.1v (as in your case), Wifi > is tuned on now, as its request the CH0 to operate at 3.3 Volts, regulator > will fail to set this voltage as BT is operating > at CH0 3.1v (assuming max voltage is 3.2v) > https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/drivers/net/wireless/ath/ath10k/snoc.c#n39 see above > Issue 3: > > By mistake PMIC has low min or default voltage and high max voltages, that > is harm for WNC3990. > > I would suggest to restrict the min and max voltages in driver, instead of > relaying on PMIC to do this. > BTW pmic will do this and doing it in our driver is safer. What if another device switches the regulator on before BT? Again, what you describe is a misconfiguration of the regulator and should be fixed at its root, instead of implementing unreliable 'safeguards' in each and every driver using regulators. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 2/4] Bluetooth: hci_qca: Don't vote for specific voltage 2019-10-22 17:15 ` Matthias Kaehlcke @ 2019-10-30 6:18 ` Balakrishna Godavarthi 0 siblings, 0 replies; 17+ messages in thread From: Balakrishna Godavarthi @ 2019-10-30 6:18 UTC (permalink / raw) To: Matthias Kaehlcke Cc: Bjorn Andersson, Marcel Holtmann, Johan Hedberg, linux-bluetooth, linux-kernel, Jeffrey Hugo, linux-arm-msm, linux-bluetooth-owner, hemantg, Harish Bandi, Stephen Boyd Hi Matthias, On 2019-10-22 22:45, Matthias Kaehlcke wrote: > On Tue, Oct 22, 2019 at 11:35:43AM +0530, Balakrishna Godavarthi wrote: >> Hi Matthias, Bjorn andresson, >> >> On 2019-10-21 12:07, Harish Bandi wrote: >> > + Bala >> > >> > On 2019-10-18 23:52, Matthias Kaehlcke wrote: >> > > On Thu, Oct 17, 2019 at 10:24:02PM -0700, Bjorn Andersson wrote: >> > > > Devices with specific voltage requirements should not request voltage >> > > > from the driver, but instead rely on the system configuration to >> > > > define >> > > > appropriate voltages for each rail. >> > > > >> > > > This ensures that PMIC and board variations are accounted for, >> > > > something >> > > > that the 0.1V range in the hci_qca driver currently tries to address. >> > > > But on the Lenovo Yoga C630 (with wcn3990) vddch0 is 3.1V, which >> > > > means >> > > > the driver will fail to set the voltage. >> > > > >> > > > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> >> > > > --- >> > > > drivers/bluetooth/hci_qca.c | 26 ++++++++------------------ >> > > > 1 file changed, 8 insertions(+), 18 deletions(-) >> > > > >> > > > diff --git a/drivers/bluetooth/hci_qca.c >> > > > b/drivers/bluetooth/hci_qca.c >> > > > index c07c529b0d81..54aafcc69d06 100644 >> > > > --- a/drivers/bluetooth/hci_qca.c >> > > > +++ b/drivers/bluetooth/hci_qca.c >> > > > @@ -130,8 +130,6 @@ enum qca_speed_type { >> > > > */ >> > > > struct qca_vreg { >> > > > const char *name; >> > > > - unsigned int min_uV; >> > > > - unsigned int max_uV; >> > > > unsigned int load_uA; >> > > > }; >> > > > >> > > > @@ -1332,10 +1330,10 @@ static const struct hci_uart_proto >> > > > qca_proto = { >> > > > static const struct qca_vreg_data qca_soc_data_wcn3990 = { >> > > > .soc_type = QCA_WCN3990, >> > > > .vregs = (struct qca_vreg []) { >> > > > - { "vddio", 1800000, 1900000, 15000 }, >> > > > - { "vddxo", 1800000, 1900000, 80000 }, >> > > > - { "vddrf", 1300000, 1350000, 300000 }, >> > > > - { "vddch0", 3300000, 3400000, 450000 }, >> > > > + { "vddio", 15000 }, >> > > > + { "vddxo", 80000 }, >> > > > + { "vddrf", 300000 }, >> > > > + { "vddch0", 450000 }, >> > > > }, >> > > > .num_vregs = 4, >> > > > }; >> > > > @@ -1343,10 +1341,10 @@ static const struct qca_vreg_data >> > > > qca_soc_data_wcn3990 = { >> > > > static const struct qca_vreg_data qca_soc_data_wcn3998 = { >> > > > .soc_type = QCA_WCN3998, >> > > > .vregs = (struct qca_vreg []) { >> > > > - { "vddio", 1800000, 1900000, 10000 }, >> > > > - { "vddxo", 1800000, 1900000, 80000 }, >> > > > - { "vddrf", 1300000, 1352000, 300000 }, >> > > > - { "vddch0", 3300000, 3300000, 450000 }, >> > > > + { "vddio", 10000 }, >> > > > + { "vddxo", 80000 }, >> > > > + { "vddrf", 300000 }, >> > > > + { "vddch0", 450000 }, >> > > > }, >> > > > .num_vregs = 4, >> > > > }; >> > > > @@ -1386,13 +1384,6 @@ static int qca_power_off(struct hci_dev *hdev) >> > > > static int qca_enable_regulator(struct qca_vreg vregs, >> > > > struct regulator *regulator) >> > > > { >> > > > - int ret; >> > > > - >> > > > - ret = regulator_set_voltage(regulator, vregs.min_uV, >> > > > - vregs.max_uV); >> > > > - if (ret) >> > > > - return ret; >> > > > - >> > > > return regulator_enable(regulator); >> > > > >> > > > } >> > > > @@ -1401,7 +1392,6 @@ static void qca_disable_regulator(struct >> > > > qca_vreg vregs, >> > > > struct regulator *regulator) >> > > > { >> > > > regulator_disable(regulator); >> > > > - regulator_set_voltage(regulator, 0, vregs.max_uV); >> > > > >> > > > } >> > > >> > > This was brought up multiple times during the initial review, but >> > > wasn't addressed. >> > > >> > > Reviewed-by: Matthias Kaehlcke <mka@chromium.org> >> >> >> yes true PMIC dts regulator should do this. >> But we have some real time issues observed. >> >> Issue 1: >> >> In PMIC dts node, ASAIK we have three levels of voltages. >> >> 1. Default voltage. >> 2. Minimum voltage. (mandatory entry) >> 3. Maximum voltage. (mandatory entry) >> >> Let us assume that the if PMIC regulator dts node supports defaults >> voltage >> to 3.2 Volts and Min as 3.1 V and max as 3.3V >> So default operating voltage is 3.1V when we turn on BT (but >> according to >> spec SoC requires min of 3.3V to operate, >> Might have some functionality failures on end to end testing > > The PMIC regulator shouldn't be configured with the entire range of > voltages > it can generate, but with a range of voltages that is suitable for all > its > consumers. > > In other words if BT requires a minimum voltage of 3.3V the minimum > voltage > of the regulator should be at least 3.3V. > >> Issue 2: >> >> WCN3990 RF is shared with WiFi, so it also try to turn on the >> regulators. >> Wifi driver uses the same approach of restricting to min and max >> voltages in >> driver. >> Let us assume we turned ON BT and CH0 is set to 3.1v (as in your >> case), Wifi >> is tuned on now, as its request the CH0 to operate at 3.3 Volts, >> regulator >> will fail to set this voltage as BT is operating >> at CH0 3.1v (assuming max voltage is 3.2v) >> https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/drivers/net/wireless/ath/ath10k/snoc.c#n39 > > see above > >> Issue 3: >> >> By mistake PMIC has low min or default voltage and high max voltages, >> that >> is harm for WNC3990. >> >> I would suggest to restrict the min and max voltages in driver, >> instead of >> relaying on PMIC to do this. >> BTW pmic will do this and doing it in our driver is safer. > > What if another device switches the regulator on before BT? > > Again, what you describe is a misconfiguration of the regulator and > should > be fixed at its root, instead of implementing unreliable 'safeguards' > in each > and every driver using regulators. Thanks for detail analysis :) -- Regards Balakrishna. ^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 3/4] Bluetooth: hci_qca: Use regulator bulk enable/disable 2019-10-18 5:24 [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup Bjorn Andersson 2019-10-18 5:24 ` [PATCH 1/4] Bluetooth: hci_qca: Update regulator_set_load() usage Bjorn Andersson 2019-10-18 5:24 ` [PATCH 2/4] Bluetooth: hci_qca: Don't vote for specific voltage Bjorn Andersson @ 2019-10-18 5:24 ` Bjorn Andersson 2019-10-18 11:18 ` Harish Bandi 2019-10-18 5:24 ` [PATCH 4/4] Bluetooth: hci_qca: Split qca_power_setup() Bjorn Andersson ` (2 subsequent siblings) 5 siblings, 1 reply; 17+ messages in thread From: Bjorn Andersson @ 2019-10-18 5:24 UTC (permalink / raw) To: Marcel Holtmann, Johan Hedberg Cc: linux-bluetooth, linux-kernel, Jeffrey Hugo, linux-arm-msm With the regulator_set_load() and regulator_set_voltage() out of the enable/disable code paths the code can now use the standard regulator bulk enable/disable API. By cloning num_vregs into struct qca_power there's no need to lug around a reference to the struct qca_vreg_data, which further simplifies qca_power_setup(). Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> --- drivers/bluetooth/hci_qca.c | 55 +++++++++---------------------------- 1 file changed, 13 insertions(+), 42 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 54aafcc69d06..01f941e9adf3 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -144,8 +144,8 @@ struct qca_vreg_data { */ struct qca_power { struct device *dev; - const struct qca_vreg_data *vreg_data; struct regulator_bulk_data *vreg_bulk; + int num_vregs; bool vregs_on; }; @@ -1381,63 +1381,34 @@ static int qca_power_off(struct hci_dev *hdev) return 0; } -static int qca_enable_regulator(struct qca_vreg vregs, - struct regulator *regulator) -{ - return regulator_enable(regulator); - -} - -static void qca_disable_regulator(struct qca_vreg vregs, - struct regulator *regulator) -{ - regulator_disable(regulator); - -} - static int qca_power_setup(struct hci_uart *hu, bool on) { - struct qca_vreg *vregs; struct regulator_bulk_data *vreg_bulk; struct qca_serdev *qcadev; - int i, num_vregs, ret = 0; + int num_vregs; + int ret = 0; qcadev = serdev_device_get_drvdata(hu->serdev); - if (!qcadev || !qcadev->bt_power || !qcadev->bt_power->vreg_data || - !qcadev->bt_power->vreg_bulk) + if (!qcadev || !qcadev->bt_power || !qcadev->bt_power->vreg_bulk) return -EINVAL; - vregs = qcadev->bt_power->vreg_data->vregs; vreg_bulk = qcadev->bt_power->vreg_bulk; - num_vregs = qcadev->bt_power->vreg_data->num_vregs; - BT_DBG("on: %d", on); + num_vregs = qcadev->bt_power->num_vregs; + BT_DBG("on: %d (%d regulators)", on, num_vregs); if (on && !qcadev->bt_power->vregs_on) { - for (i = 0; i < num_vregs; i++) { - ret = qca_enable_regulator(vregs[i], - vreg_bulk[i].consumer); - if (ret) - break; - } + ret = regulator_bulk_enable(num_vregs, vreg_bulk); + if (ret) + return ret; - if (ret) { - BT_ERR("failed to enable regulator:%s", vregs[i].name); - /* turn off regulators which are enabled */ - for (i = i - 1; i >= 0; i--) - qca_disable_regulator(vregs[i], - vreg_bulk[i].consumer); - } else { - qcadev->bt_power->vregs_on = true; - } + qcadev->bt_power->vregs_on = true; } else if (!on && qcadev->bt_power->vregs_on) { /* turn off regulator in reverse order */ - i = qcadev->bt_power->vreg_data->num_vregs - 1; - for ( ; i >= 0; i--) - qca_disable_regulator(vregs[i], vreg_bulk[i].consumer); + regulator_bulk_disable(num_vregs, vreg_bulk); qcadev->bt_power->vregs_on = false; } - return ret; + return 0; } static int qca_init_regulators(struct qca_power *qca, @@ -1465,6 +1436,7 @@ static int qca_init_regulators(struct qca_power *qca, } qca->vreg_bulk = bulk; + qca->num_vregs = num_vregs; return 0; } @@ -1493,7 +1465,6 @@ static int qca_serdev_probe(struct serdev_device *serdev) return -ENOMEM; qcadev->bt_power->dev = &serdev->dev; - qcadev->bt_power->vreg_data = data; err = qca_init_regulators(qcadev->bt_power, data->vregs, data->num_vregs); if (err) { -- 2.23.0 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 3/4] Bluetooth: hci_qca: Use regulator bulk enable/disable 2019-10-18 5:24 ` [PATCH 3/4] Bluetooth: hci_qca: Use regulator bulk enable/disable Bjorn Andersson @ 2019-10-18 11:18 ` Harish Bandi 0 siblings, 0 replies; 17+ messages in thread From: Harish Bandi @ 2019-10-18 11:18 UTC (permalink / raw) To: Bjorn Andersson, Balakrishna Godavarthi Cc: Marcel Holtmann, Johan Hedberg, linux-bluetooth, linux-kernel, Jeffrey Hugo, linux-arm-msm, linux-bluetooth-owner On 2019-10-18 10:54, Bjorn Andersson wrote: > With the regulator_set_load() and regulator_set_voltage() out of the > enable/disable code paths the code can now use the standard > regulator bulk enable/disable API. > > By cloning num_vregs into struct qca_power there's no need to lug > around > a reference to the struct qca_vreg_data, which further simplifies > qca_power_setup(). > > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> > --- > drivers/bluetooth/hci_qca.c | 55 +++++++++---------------------------- > 1 file changed, 13 insertions(+), 42 deletions(-) > > diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c > index 54aafcc69d06..01f941e9adf3 100644 > --- a/drivers/bluetooth/hci_qca.c > +++ b/drivers/bluetooth/hci_qca.c > @@ -144,8 +144,8 @@ struct qca_vreg_data { > */ > struct qca_power { > struct device *dev; > - const struct qca_vreg_data *vreg_data; > struct regulator_bulk_data *vreg_bulk; > + int num_vregs; > bool vregs_on; > }; > > @@ -1381,63 +1381,34 @@ static int qca_power_off(struct hci_dev *hdev) > return 0; > } > > -static int qca_enable_regulator(struct qca_vreg vregs, > - struct regulator *regulator) > -{ > - return regulator_enable(regulator); > - > -} > - > -static void qca_disable_regulator(struct qca_vreg vregs, > - struct regulator *regulator) > -{ > - regulator_disable(regulator); > - > -} > - > static int qca_power_setup(struct hci_uart *hu, bool on) > { > - struct qca_vreg *vregs; > struct regulator_bulk_data *vreg_bulk; > struct qca_serdev *qcadev; > - int i, num_vregs, ret = 0; > + int num_vregs; > + int ret = 0; > > qcadev = serdev_device_get_drvdata(hu->serdev); > - if (!qcadev || !qcadev->bt_power || !qcadev->bt_power->vreg_data || > - !qcadev->bt_power->vreg_bulk) > + if (!qcadev || !qcadev->bt_power || !qcadev->bt_power->vreg_bulk) > return -EINVAL; > > - vregs = qcadev->bt_power->vreg_data->vregs; > vreg_bulk = qcadev->bt_power->vreg_bulk; > - num_vregs = qcadev->bt_power->vreg_data->num_vregs; > - BT_DBG("on: %d", on); > + num_vregs = qcadev->bt_power->num_vregs; > + BT_DBG("on: %d (%d regulators)", on, num_vregs); > if (on && !qcadev->bt_power->vregs_on) { > - for (i = 0; i < num_vregs; i++) { > - ret = qca_enable_regulator(vregs[i], > - vreg_bulk[i].consumer); > - if (ret) > - break; > - } > + ret = regulator_bulk_enable(num_vregs, vreg_bulk); > + if (ret) > + return ret; > > - if (ret) { > - BT_ERR("failed to enable regulator:%s", vregs[i].name); > - /* turn off regulators which are enabled */ > - for (i = i - 1; i >= 0; i--) > - qca_disable_regulator(vregs[i], > - vreg_bulk[i].consumer); > - } else { > - qcadev->bt_power->vregs_on = true; > - } > + qcadev->bt_power->vregs_on = true; > } else if (!on && qcadev->bt_power->vregs_on) { > /* turn off regulator in reverse order */ > - i = qcadev->bt_power->vreg_data->num_vregs - 1; > - for ( ; i >= 0; i--) > - qca_disable_regulator(vregs[i], vreg_bulk[i].consumer); > + regulator_bulk_disable(num_vregs, vreg_bulk); > > qcadev->bt_power->vregs_on = false; > } > > - return ret; > + return 0; > } > > static int qca_init_regulators(struct qca_power *qca, > @@ -1465,6 +1436,7 @@ static int qca_init_regulators(struct qca_power > *qca, > } > > qca->vreg_bulk = bulk; > + qca->num_vregs = num_vregs; > > return 0; > } > @@ -1493,7 +1465,6 @@ static int qca_serdev_probe(struct serdev_device > *serdev) > return -ENOMEM; > > qcadev->bt_power->dev = &serdev->dev; > - qcadev->bt_power->vreg_data = data; > err = qca_init_regulators(qcadev->bt_power, data->vregs, > data->num_vregs); > if (err) { ^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 4/4] Bluetooth: hci_qca: Split qca_power_setup() 2019-10-18 5:24 [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup Bjorn Andersson ` (2 preceding siblings ...) 2019-10-18 5:24 ` [PATCH 3/4] Bluetooth: hci_qca: Use regulator bulk enable/disable Bjorn Andersson @ 2019-10-18 5:24 ` Bjorn Andersson 2019-10-18 11:19 ` Harish Bandi 2019-10-18 7:59 ` [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup Marcel Holtmann 2019-10-18 11:17 ` Harish Bandi 5 siblings, 1 reply; 17+ messages in thread From: Bjorn Andersson @ 2019-10-18 5:24 UTC (permalink / raw) To: Marcel Holtmann, Johan Hedberg Cc: linux-bluetooth, linux-kernel, Jeffrey Hugo, linux-arm-msm Split and rename qca_power_setup() in order to simplify each code path and to clarify that it is unrelated to qca_power_off() and qca_power_setup(). Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> --- drivers/bluetooth/hci_qca.c | 61 ++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 01f941e9adf3..c591a8ba9d93 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -160,7 +160,8 @@ struct qca_serdev { const char *firmware_name; }; -static int qca_power_setup(struct hci_uart *hu, bool on); +static int qca_regulator_enable(struct qca_serdev *qcadev); +static void qca_regulator_disable(struct qca_serdev *qcadev); static void qca_power_shutdown(struct hci_uart *hu); static int qca_power_off(struct hci_dev *hdev); @@ -516,7 +517,7 @@ static int qca_open(struct hci_uart *hu) } else { hu->init_speed = qcadev->init_speed; hu->oper_speed = qcadev->oper_speed; - ret = qca_power_setup(hu, true); + ret = qca_regulator_enable(qcadev); if (ret) { destroy_workqueue(qca->workqueue); kfree_skb(qca->rx_skb); @@ -1186,7 +1187,7 @@ static int qca_wcn3990_init(struct hci_uart *hu) qcadev = serdev_device_get_drvdata(hu->serdev); if (!qcadev->bt_power->vregs_on) { serdev_device_close(hu->serdev); - ret = qca_power_setup(hu, true); + ret = qca_regulator_enable(qcadev); if (ret) return ret; @@ -1351,9 +1352,12 @@ static const struct qca_vreg_data qca_soc_data_wcn3998 = { static void qca_power_shutdown(struct hci_uart *hu) { + struct qca_serdev *qcadev; struct qca_data *qca = hu->priv; unsigned long flags; + qcadev = serdev_device_get_drvdata(hu->serdev); + /* From this point we go into power off state. But serial port is * still open, stop queueing the IBS data and flush all the buffered * data in skb's. @@ -1365,7 +1369,7 @@ static void qca_power_shutdown(struct hci_uart *hu) host_set_baudrate(hu, 2400); qca_send_power_pulse(hu, false); - qca_power_setup(hu, false); + qca_regulator_disable(qcadev); } static int qca_power_off(struct hci_dev *hdev) @@ -1381,36 +1385,43 @@ static int qca_power_off(struct hci_dev *hdev) return 0; } -static int qca_power_setup(struct hci_uart *hu, bool on) +static int qca_regulator_enable(struct qca_serdev *qcadev) { - struct regulator_bulk_data *vreg_bulk; - struct qca_serdev *qcadev; - int num_vregs; - int ret = 0; + struct qca_power *power = qcadev->bt_power; + int ret; - qcadev = serdev_device_get_drvdata(hu->serdev); - if (!qcadev || !qcadev->bt_power || !qcadev->bt_power->vreg_bulk) - return -EINVAL; + /* Already enabled */ + if (power->vregs_on) + return 0; - vreg_bulk = qcadev->bt_power->vreg_bulk; - num_vregs = qcadev->bt_power->num_vregs; - BT_DBG("on: %d (%d regulators)", on, num_vregs); - if (on && !qcadev->bt_power->vregs_on) { - ret = regulator_bulk_enable(num_vregs, vreg_bulk); - if (ret) - return ret; + BT_DBG("enabling %d regulators)", power->num_vregs); - qcadev->bt_power->vregs_on = true; - } else if (!on && qcadev->bt_power->vregs_on) { - /* turn off regulator in reverse order */ - regulator_bulk_disable(num_vregs, vreg_bulk); + ret = regulator_bulk_enable(power->num_vregs, power->vreg_bulk); + if (ret) + return ret; - qcadev->bt_power->vregs_on = false; - } + power->vregs_on = true; return 0; } +static void qca_regulator_disable(struct qca_serdev *qcadev) +{ + struct qca_power *power; + + if (!qcadev) + return; + + power = qcadev->bt_power; + + /* Already disabled? */ + if (!power->vregs_on) + return; + + regulator_bulk_disable(power->num_vregs, power->vreg_bulk); + power->vregs_on = false; +} + static int qca_init_regulators(struct qca_power *qca, const struct qca_vreg *vregs, size_t num_vregs) { -- 2.23.0 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 4/4] Bluetooth: hci_qca: Split qca_power_setup() 2019-10-18 5:24 ` [PATCH 4/4] Bluetooth: hci_qca: Split qca_power_setup() Bjorn Andersson @ 2019-10-18 11:19 ` Harish Bandi 0 siblings, 0 replies; 17+ messages in thread From: Harish Bandi @ 2019-10-18 11:19 UTC (permalink / raw) To: Bjorn Andersson, Balakrishna Godavarthi Cc: Marcel Holtmann, Johan Hedberg, linux-bluetooth, linux-kernel, Jeffrey Hugo, linux-arm-msm, linux-bluetooth-owner On 2019-10-18 10:54, Bjorn Andersson wrote: > Split and rename qca_power_setup() in order to simplify each code path > and to clarify that it is unrelated to qca_power_off() and > qca_power_setup(). > > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> > --- > drivers/bluetooth/hci_qca.c | 61 ++++++++++++++++++++++--------------- > 1 file changed, 36 insertions(+), 25 deletions(-) > > diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c > index 01f941e9adf3..c591a8ba9d93 100644 > --- a/drivers/bluetooth/hci_qca.c > +++ b/drivers/bluetooth/hci_qca.c > @@ -160,7 +160,8 @@ struct qca_serdev { > const char *firmware_name; > }; > > -static int qca_power_setup(struct hci_uart *hu, bool on); > +static int qca_regulator_enable(struct qca_serdev *qcadev); > +static void qca_regulator_disable(struct qca_serdev *qcadev); > static void qca_power_shutdown(struct hci_uart *hu); > static int qca_power_off(struct hci_dev *hdev); > > @@ -516,7 +517,7 @@ static int qca_open(struct hci_uart *hu) > } else { > hu->init_speed = qcadev->init_speed; > hu->oper_speed = qcadev->oper_speed; > - ret = qca_power_setup(hu, true); > + ret = qca_regulator_enable(qcadev); > if (ret) { > destroy_workqueue(qca->workqueue); > kfree_skb(qca->rx_skb); > @@ -1186,7 +1187,7 @@ static int qca_wcn3990_init(struct hci_uart *hu) > qcadev = serdev_device_get_drvdata(hu->serdev); > if (!qcadev->bt_power->vregs_on) { > serdev_device_close(hu->serdev); > - ret = qca_power_setup(hu, true); > + ret = qca_regulator_enable(qcadev); > if (ret) > return ret; > > @@ -1351,9 +1352,12 @@ static const struct qca_vreg_data > qca_soc_data_wcn3998 = { > > static void qca_power_shutdown(struct hci_uart *hu) > { > + struct qca_serdev *qcadev; > struct qca_data *qca = hu->priv; > unsigned long flags; > > + qcadev = serdev_device_get_drvdata(hu->serdev); > + > /* From this point we go into power off state. But serial port is > * still open, stop queueing the IBS data and flush all the buffered > * data in skb's. > @@ -1365,7 +1369,7 @@ static void qca_power_shutdown(struct hci_uart > *hu) > > host_set_baudrate(hu, 2400); > qca_send_power_pulse(hu, false); > - qca_power_setup(hu, false); > + qca_regulator_disable(qcadev); > } > > static int qca_power_off(struct hci_dev *hdev) > @@ -1381,36 +1385,43 @@ static int qca_power_off(struct hci_dev *hdev) > return 0; > } > > -static int qca_power_setup(struct hci_uart *hu, bool on) > +static int qca_regulator_enable(struct qca_serdev *qcadev) > { > - struct regulator_bulk_data *vreg_bulk; > - struct qca_serdev *qcadev; > - int num_vregs; > - int ret = 0; > + struct qca_power *power = qcadev->bt_power; > + int ret; > > - qcadev = serdev_device_get_drvdata(hu->serdev); > - if (!qcadev || !qcadev->bt_power || !qcadev->bt_power->vreg_bulk) > - return -EINVAL; > + /* Already enabled */ > + if (power->vregs_on) > + return 0; > > - vreg_bulk = qcadev->bt_power->vreg_bulk; > - num_vregs = qcadev->bt_power->num_vregs; > - BT_DBG("on: %d (%d regulators)", on, num_vregs); > - if (on && !qcadev->bt_power->vregs_on) { > - ret = regulator_bulk_enable(num_vregs, vreg_bulk); > - if (ret) > - return ret; > + BT_DBG("enabling %d regulators)", power->num_vregs); > > - qcadev->bt_power->vregs_on = true; > - } else if (!on && qcadev->bt_power->vregs_on) { > - /* turn off regulator in reverse order */ > - regulator_bulk_disable(num_vregs, vreg_bulk); > + ret = regulator_bulk_enable(power->num_vregs, power->vreg_bulk); > + if (ret) > + return ret; > > - qcadev->bt_power->vregs_on = false; > - } > + power->vregs_on = true; > > return 0; > } > > +static void qca_regulator_disable(struct qca_serdev *qcadev) > +{ > + struct qca_power *power; > + > + if (!qcadev) > + return; > + > + power = qcadev->bt_power; > + > + /* Already disabled? */ > + if (!power->vregs_on) > + return; > + > + regulator_bulk_disable(power->num_vregs, power->vreg_bulk); > + power->vregs_on = false; > +} > + > static int qca_init_regulators(struct qca_power *qca, > const struct qca_vreg *vregs, size_t num_vregs) > { ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup 2019-10-18 5:24 [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup Bjorn Andersson ` (3 preceding siblings ...) 2019-10-18 5:24 ` [PATCH 4/4] Bluetooth: hci_qca: Split qca_power_setup() Bjorn Andersson @ 2019-10-18 7:59 ` Marcel Holtmann 2019-10-18 14:52 ` Jeffrey Hugo 2019-10-18 11:17 ` Harish Bandi 5 siblings, 1 reply; 17+ messages in thread From: Marcel Holtmann @ 2019-10-18 7:59 UTC (permalink / raw) To: Bjorn Andersson Cc: Johan Hedberg, linux-bluetooth, linux-kernel, Jeffrey Hugo, linux-arm-msm Hi Bjorn, > Clean up the regulator usage in hci_qca and in particular don't > regulator_set_voltage() for fixed voltages. It cleans up the driver, but more > important it makes bluetooth work on my Lenovo Yoga C630, where the regulator > for vddch0 is defined with a voltage range that doesn't overlap the values in > the driver. > > Bjorn Andersson (4): > Bluetooth: hci_qca: Update regulator_set_load() usage > Bluetooth: hci_qca: Don't vote for specific voltage > Bluetooth: hci_qca: Use regulator bulk enable/disable > Bluetooth: hci_qca: Split qca_power_setup() > > drivers/bluetooth/hci_qca.c | 135 +++++++++++++++--------------------- > 1 file changed, 55 insertions(+), 80 deletions(-) all 4 patches have been applied to bluetooth-next tree. Regards Marcel ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup 2019-10-18 7:59 ` [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup Marcel Holtmann @ 2019-10-18 14:52 ` Jeffrey Hugo 0 siblings, 0 replies; 17+ messages in thread From: Jeffrey Hugo @ 2019-10-18 14:52 UTC (permalink / raw) To: Marcel Holtmann Cc: Bjorn Andersson, Johan Hedberg, linux-bluetooth, lkml, MSM On Fri, Oct 18, 2019 at 1:59 AM Marcel Holtmann <marcel@holtmann.org> wrote: > > Hi Bjorn, > > > Clean up the regulator usage in hci_qca and in particular don't > > regulator_set_voltage() for fixed voltages. It cleans up the driver, but more > > important it makes bluetooth work on my Lenovo Yoga C630, where the regulator > > for vddch0 is defined with a voltage range that doesn't overlap the values in > > the driver. > > > > Bjorn Andersson (4): > > Bluetooth: hci_qca: Update regulator_set_load() usage > > Bluetooth: hci_qca: Don't vote for specific voltage > > Bluetooth: hci_qca: Use regulator bulk enable/disable > > Bluetooth: hci_qca: Split qca_power_setup() > > > > drivers/bluetooth/hci_qca.c | 135 +++++++++++++++--------------------- > > 1 file changed, 55 insertions(+), 80 deletions(-) > > all 4 patches have been applied to bluetooth-next tree. I know this is already applied, but I just wanted to follow up and indicate: Tested-by: Jeffrey Hugo <jeffrey.l.hugo@gmail.com> Reviewed-by: Jeffrey Hugo <jeffrey.l.hugo@gmail.com> Thanks for the cleanups Bjorn. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup 2019-10-18 5:24 [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup Bjorn Andersson ` (4 preceding siblings ...) 2019-10-18 7:59 ` [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup Marcel Holtmann @ 2019-10-18 11:17 ` Harish Bandi 5 siblings, 0 replies; 17+ messages in thread From: Harish Bandi @ 2019-10-18 11:17 UTC (permalink / raw) To: Bjorn Andersson, Balakrishna Godavarthi Cc: Marcel Holtmann, Johan Hedberg, linux-bluetooth, linux-kernel, Jeffrey Hugo, linux-arm-msm, linux-bluetooth-owner On 2019-10-18 10:54, Bjorn Andersson wrote: > Clean up the regulator usage in hci_qca and in particular don't > regulator_set_voltage() for fixed voltages. It cleans up the driver, > but more > important it makes bluetooth work on my Lenovo Yoga C630, where the > regulator > for vddch0 is defined with a voltage range that doesn't overlap the > values in > the driver. > > Bjorn Andersson (4): > Bluetooth: hci_qca: Update regulator_set_load() usage > Bluetooth: hci_qca: Don't vote for specific voltage > Bluetooth: hci_qca: Use regulator bulk enable/disable > Bluetooth: hci_qca: Split qca_power_setup() > > drivers/bluetooth/hci_qca.c | 135 +++++++++++++++--------------------- > 1 file changed, 55 insertions(+), 80 deletions(-) ^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2019-10-30 6:18 UTC | newest] Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-10-18 5:24 [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup Bjorn Andersson 2019-10-18 5:24 ` [PATCH 1/4] Bluetooth: hci_qca: Update regulator_set_load() usage Bjorn Andersson 2019-10-18 11:18 ` Harish Bandi 2019-10-18 5:24 ` [PATCH 2/4] Bluetooth: hci_qca: Don't vote for specific voltage Bjorn Andersson 2019-10-18 11:18 ` Harish Bandi 2019-10-18 18:22 ` Matthias Kaehlcke 2019-10-21 6:37 ` Harish Bandi 2019-10-22 6:05 ` Balakrishna Godavarthi 2019-10-22 17:15 ` Matthias Kaehlcke 2019-10-30 6:18 ` Balakrishna Godavarthi 2019-10-18 5:24 ` [PATCH 3/4] Bluetooth: hci_qca: Use regulator bulk enable/disable Bjorn Andersson 2019-10-18 11:18 ` Harish Bandi 2019-10-18 5:24 ` [PATCH 4/4] Bluetooth: hci_qca: Split qca_power_setup() Bjorn Andersson 2019-10-18 11:19 ` Harish Bandi 2019-10-18 7:59 ` [PATCH 0/4] Bluetooth: hci_qca: Regulator usage cleanup Marcel Holtmann 2019-10-18 14:52 ` Jeffrey Hugo 2019-10-18 11:17 ` Harish Bandi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).