Message ID | 20240113-pmi632-typec-v2-9-182d9aa0a5b3@linaro.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | usb: typec: qcom-pmic-typec: enable support for PMI632 PMIC | expand |
On 1/13/24 21:55, Dmitry Baryshkov wrote: > The PMI632 PMIC support Type-C port handling, but lacks USB > PowerDelivery support. The TCPM requires all callbacks to be provided > by the implementation. Implement a special, 'stub' Qcom PD PHY > implementation to enable the PMI632 support. > > Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > --- Still not a fan of stubby stubs :/ Konrad
On Tue, 16 Jan 2024 at 14:32, Konrad Dybcio <konrad.dybcio@linaro.org> wrote: > > > > On 1/13/24 21:55, Dmitry Baryshkov wrote: > > The PMI632 PMIC support Type-C port handling, but lacks USB > > PowerDelivery support. The TCPM requires all callbacks to be provided > > by the implementation. Implement a special, 'stub' Qcom PD PHY > > implementation to enable the PMI632 support. > > > > Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > > --- > > Still not a fan of stubby stubs :/ Me too. If there are better suggestions, I'll be pleased to implement them. Greg, Heikki?
On Tue, Jan 16, 2024 at 02:56:11PM +0200, Dmitry Baryshkov wrote: > On Tue, 16 Jan 2024 at 14:32, Konrad Dybcio <konrad.dybcio@linaro.org> wrote: > > On 1/13/24 21:55, Dmitry Baryshkov wrote: > > > The PMI632 PMIC support Type-C port handling, but lacks USB > > > PowerDelivery support. The TCPM requires all callbacks to be provided > > > by the implementation. Implement a special, 'stub' Qcom PD PHY > > > implementation to enable the PMI632 support. > > > > > > Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > > > --- > > > > Still not a fan of stubby stubs :/ > > Me too. If there are better suggestions, I'll be pleased to implement > them. Greg, Heikki? Guenter, do you have time to look at this? thanks,
On Tue, 16 Jan 2024 at 16:23, Heikki Krogerus <heikki.krogerus@linux.intel.com> wrote: > > On Tue, Jan 16, 2024 at 02:56:11PM +0200, Dmitry Baryshkov wrote: > > On Tue, 16 Jan 2024 at 14:32, Konrad Dybcio <konrad.dybcio@linaro.org> wrote: > > > On 1/13/24 21:55, Dmitry Baryshkov wrote: > > > > The PMI632 PMIC support Type-C port handling, but lacks USB > > > > PowerDelivery support. The TCPM requires all callbacks to be provided > > > > by the implementation. Implement a special, 'stub' Qcom PD PHY > > > > implementation to enable the PMI632 support. > > > > > > > > Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> > > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > > > > --- > > > > > > Still not a fan of stubby stubs :/ > > > > Me too. If there are better suggestions, I'll be pleased to implement > > them. Greg, Heikki? > > Guenter, do you have time to look at this? Heikki, Guenter, just a gracious ping for your opinion. Probably another option is to read pd_supported (or all caps) before checking the callbacks and then instrument all calls to PD with pd_supported checks.
On Thu, Jan 25, 2024 at 02:07:59AM +0200, Dmitry Baryshkov wrote: > On Tue, 16 Jan 2024 at 16:23, Heikki Krogerus > <heikki.krogerus@linux.intel.com> wrote: > > > > On Tue, Jan 16, 2024 at 02:56:11PM +0200, Dmitry Baryshkov wrote: > > > On Tue, 16 Jan 2024 at 14:32, Konrad Dybcio <konrad.dybcio@linaro.org> wrote: > > > > On 1/13/24 21:55, Dmitry Baryshkov wrote: > > > > > The PMI632 PMIC support Type-C port handling, but lacks USB > > > > > PowerDelivery support. The TCPM requires all callbacks to be provided > > > > > by the implementation. Implement a special, 'stub' Qcom PD PHY > > > > > implementation to enable the PMI632 support. > > > > > > > > > > Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> > > > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > > > > > --- > > > > > > > > Still not a fan of stubby stubs :/ > > > > > > Me too. If there are better suggestions, I'll be pleased to implement > > > them. Greg, Heikki? > > > > Guenter, do you have time to look at this? > > Heikki, Guenter, just a gracious ping for your opinion. > Probably another option is to read pd_supported (or all caps) before > checking the callbacks and then instrument all calls to PD with > pd_supported checks. I don't have anything to suggest here, but Guenter should really comment this one. In any case, FWIW: Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
diff --git a/drivers/usb/typec/tcpm/qcom/Makefile b/drivers/usb/typec/tcpm/qcom/Makefile index dc1e8832e197..cc23042b9487 100644 --- a/drivers/usb/typec/tcpm/qcom/Makefile +++ b/drivers/usb/typec/tcpm/qcom/Makefile @@ -3,4 +3,5 @@ obj-$(CONFIG_TYPEC_QCOM_PMIC) += qcom_pmic_tcpm.o qcom_pmic_tcpm-y += qcom_pmic_typec.o \ qcom_pmic_typec_port.o \ - qcom_pmic_typec_pdphy.o + qcom_pmic_typec_pdphy.o \ + qcom_pmic_typec_pdphy_stub.o \ diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c index 82e3f59ea471..e48412cdcb0f 100644 --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c @@ -42,7 +42,7 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev) const struct pmic_typec_resources *res; struct regmap *regmap; struct device *bridge_dev; - u32 base[2]; + u32 base; int ret; res = of_device_get_match_data(dev); @@ -62,19 +62,29 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev) return -ENODEV; } - ret = of_property_read_u32_array(np, "reg", base, 2); + ret = of_property_read_u32_index(np, "reg", 0, &base); if (ret) return ret; ret = qcom_pmic_typec_port_probe(pdev, tcpm, - res->port_res, regmap, base[0]); + res->port_res, regmap, base); if (ret) return ret; - ret = qcom_pmic_typec_pdphy_probe(pdev, tcpm, - res->pdphy_res, regmap, base[1]); - if (ret) - return ret; + if (res->pdphy_res) { + ret = of_property_read_u32_index(np, "reg", 1, &base); + if (ret) + return ret; + + ret = qcom_pmic_typec_pdphy_probe(pdev, tcpm, + res->pdphy_res, regmap, base); + if (ret) + return ret; + } else { + ret = qcom_pmic_typec_pdphy_stub_probe(pdev, tcpm); + if (ret) + return ret; + } platform_set_drvdata(pdev, tcpm); @@ -123,8 +133,14 @@ static const struct pmic_typec_resources pm8150b_typec_res = { .port_res = &pm8150b_port_res, }; +static const struct pmic_typec_resources pmi632_typec_res = { + /* PD PHY not present */ + .port_res = &pm8150b_port_res, +}; + static const struct of_device_id qcom_pmic_typec_table[] = { { .compatible = "qcom,pm8150b-typec", .data = &pm8150b_typec_res }, + { .compatible = "qcom,pmi632-typec", .data = &pmi632_typec_res }, { } }; MODULE_DEVICE_TABLE(of, qcom_pmic_typec_table); diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.h b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.h index 5f428e67ccfe..04dee20293cf 100644 --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.h +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.h @@ -31,5 +31,7 @@ int qcom_pmic_typec_pdphy_probe(struct platform_device *pdev, const struct pmic_typec_pdphy_resources *res, struct regmap *regmap, u32 base); +int qcom_pmic_typec_pdphy_stub_probe(struct platform_device *pdev, + struct pmic_typec *tcpm); #endif /* __QCOM_PMIC_TYPEC_PDPHY_H__ */ diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy_stub.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy_stub.c new file mode 100644 index 000000000000..df79059cda67 --- /dev/null +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy_stub.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2024, Linaro Ltd. All rights reserved. + */ + +#include <linux/err.h> +#include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> +#include <linux/regulator/consumer.h> +#include <linux/slab.h> +#include <linux/usb/pd.h> +#include <linux/usb/tcpm.h> +#include "qcom_pmic_typec.h" +#include "qcom_pmic_typec_pdphy.h" + +static int qcom_pmic_typec_pdphy_stub_pd_transmit(struct tcpc_dev *tcpc, + enum tcpm_transmit_type type, + const struct pd_message *msg, + unsigned int negotiated_rev) +{ + struct pmic_typec *tcpm = tcpc_to_tcpm(tcpc); + struct device *dev = tcpm->dev; + + dev_dbg(dev, "pdphy_transmit: type=%d\n", type); + + tcpm_pd_transmit_complete(tcpm->tcpm_port, + TCPC_TX_SUCCESS); + + return 0; +} + +static int qcom_pmic_typec_pdphy_stub_set_pd_rx(struct tcpc_dev *tcpc, bool on) +{ + struct pmic_typec *tcpm = tcpc_to_tcpm(tcpc); + struct device *dev = tcpm->dev; + + dev_dbg(dev, "set_pd_rx: %s\n", on ? "on" : "off"); + + return 0; +} + +static int qcom_pmic_typec_pdphy_stub_set_roles(struct tcpc_dev *tcpc, bool attached, + enum typec_role power_role, + enum typec_data_role data_role) +{ + struct pmic_typec *tcpm = tcpc_to_tcpm(tcpc); + struct device *dev = tcpm->dev; + + dev_dbg(dev, "pdphy_set_roles: data_role_host=%d power_role_src=%d\n", + data_role, power_role); + + return 0; +} + +static int qcom_pmic_typec_pdphy_stub_start(struct pmic_typec *tcpm, + struct tcpm_port *tcpm_port) +{ + return 0; +} + +static void qcom_pmic_typec_pdphy_stub_stop(struct pmic_typec *tcpm) +{ +} + +int qcom_pmic_typec_pdphy_stub_probe(struct platform_device *pdev, + struct pmic_typec *tcpm) +{ + tcpm->tcpc.set_pd_rx = qcom_pmic_typec_pdphy_stub_set_pd_rx; + tcpm->tcpc.set_roles = qcom_pmic_typec_pdphy_stub_set_roles; + tcpm->tcpc.pd_transmit = qcom_pmic_typec_pdphy_stub_pd_transmit; + + tcpm->pdphy_start = qcom_pmic_typec_pdphy_stub_start; + tcpm->pdphy_stop = qcom_pmic_typec_pdphy_stub_stop; + + return 0; +}