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

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: qca: use the power sequencer for QCA6390

Use the pwrseq subsystem's consumer API to run the power-up sequence for
the Bluetooth module of the QCA6390 package.

Tested-by: Amit Pundir <amit.pundir@linaro.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD, SM8650-QRD & SM8650-HDK
Tested-by: Caleb Connolly <caleb.connolly@linaro.org> # OnePlus 8T
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Bartosz Golaszewski and committed by
Luiz Augusto von Dentz
9a15ce68 66ef82c6

+59 -15
+59 -15
drivers/bluetooth/hci_qca.c
··· 28 28 #include <linux/of.h> 29 29 #include <linux/acpi.h> 30 30 #include <linux/platform_device.h> 31 + #include <linux/pwrseq/consumer.h> 31 32 #include <linux/regulator/consumer.h> 32 33 #include <linux/serdev.h> 33 34 #include <linux/mutex.h> ··· 215 214 struct regulator_bulk_data *vreg_bulk; 216 215 int num_vregs; 217 216 bool vregs_on; 217 + struct pwrseq_desc *pwrseq; 218 218 }; 219 219 220 220 struct qca_serdev { ··· 1686 1684 return wakeup; 1687 1685 } 1688 1686 1687 + static int qca_port_reopen(struct hci_uart *hu) 1688 + { 1689 + int ret; 1690 + 1691 + /* Now the device is in ready state to communicate with host. 1692 + * To sync host with device we need to reopen port. 1693 + * Without this, we will have RTS and CTS synchronization 1694 + * issues. 1695 + */ 1696 + serdev_device_close(hu->serdev); 1697 + ret = serdev_device_open(hu->serdev); 1698 + if (ret) { 1699 + bt_dev_err(hu->hdev, "failed to open port"); 1700 + return ret; 1701 + } 1702 + 1703 + hci_uart_set_flow_control(hu, false); 1704 + 1705 + return 0; 1706 + } 1707 + 1689 1708 static int qca_regulator_init(struct hci_uart *hu) 1690 1709 { 1691 1710 enum qca_btsoc_type soc_type = qca_soc_type(hu); ··· 1775 1752 break; 1776 1753 } 1777 1754 1778 - /* Now the device is in ready state to communicate with host. 1779 - * To sync host with device we need to reopen port. 1780 - * Without this, we will have RTS and CTS synchronization 1781 - * issues. 1782 - */ 1783 - serdev_device_close(hu->serdev); 1784 - ret = serdev_device_open(hu->serdev); 1785 - if (ret) { 1786 - bt_dev_err(hu->hdev, "failed to open port"); 1787 - return ret; 1788 - } 1789 - 1790 - hci_uart_set_flow_control(hu, false); 1791 - 1792 - return 0; 1755 + return qca_port_reopen(hu); 1793 1756 } 1794 1757 1795 1758 static int qca_power_on(struct hci_dev *hdev) ··· 1801 1792 case QCA_WCN6855: 1802 1793 case QCA_WCN7850: 1803 1794 ret = qca_regulator_init(hu); 1795 + break; 1796 + 1797 + case QCA_QCA6390: 1798 + qcadev = serdev_device_get_drvdata(hu->serdev); 1799 + ret = pwrseq_power_on(qcadev->bt_power->pwrseq); 1800 + if (ret) 1801 + return ret; 1802 + 1803 + ret = qca_port_reopen(hu); 1804 + if (ret) 1805 + return ret; 1804 1806 break; 1805 1807 1806 1808 default: ··· 2188 2168 } 2189 2169 break; 2190 2170 2171 + case QCA_QCA6390: 2172 + pwrseq_power_off(qcadev->bt_power->pwrseq); 2173 + break; 2174 + 2191 2175 default: 2192 2176 gpiod_set_value_cansleep(qcadev->bt_en, 0); 2193 2177 } ··· 2333 2309 case QCA_WCN6750: 2334 2310 case QCA_WCN6855: 2335 2311 case QCA_WCN7850: 2312 + case QCA_QCA6390: 2336 2313 qcadev->bt_power = devm_kzalloc(&serdev->dev, 2337 2314 sizeof(struct qca_power), 2338 2315 GFP_KERNEL); 2339 2316 if (!qcadev->bt_power) 2340 2317 return -ENOMEM; 2318 + break; 2319 + default: 2320 + break; 2321 + } 2341 2322 2323 + switch (qcadev->btsoc_type) { 2324 + case QCA_WCN3988: 2325 + case QCA_WCN3990: 2326 + case QCA_WCN3991: 2327 + case QCA_WCN3998: 2328 + case QCA_WCN6750: 2329 + case QCA_WCN6855: 2330 + case QCA_WCN7850: 2342 2331 qcadev->bt_power->dev = &serdev->dev; 2343 2332 err = qca_init_regulators(qcadev->bt_power, data->vregs, 2344 2333 data->num_vregs); ··· 2396 2359 return err; 2397 2360 } 2398 2361 break; 2362 + 2363 + case QCA_QCA6390: 2364 + qcadev->bt_power->pwrseq = devm_pwrseq_get(&serdev->dev, 2365 + "bluetooth"); 2366 + if (IS_ERR(qcadev->bt_power->pwrseq)) 2367 + return PTR_ERR(qcadev->bt_power->pwrseq); 2368 + fallthrough; 2399 2369 2400 2370 default: 2401 2371 qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable",