From: Caleb Connolly <caleb.connolly@linaro.org>
To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
linux@roeck-us.net, heikki.krogerus@linux.intel.com,
gregkh@linuxfoundation.org, andersson@kernel.org,
robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org,
luca.weiss@fairphone.com, linux-usb@vger.kernel.org,
linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org
Cc: konrad.dybcio@linaro.org, subbaram@quicinc.com,
jackp@quicinc.com, robertom@qti.qualcomm.com
Subject: Re: [PATCH v6 07/13] usb: typec: qcom: Add Qualcomm PMIC Type-C driver
Date: Mon, 1 May 2023 18:50:37 +0100 [thread overview]
Message-ID: <91cf184b-2466-183d-5800-da0a12a0701c@linaro.org> (raw)
In-Reply-To: <20230501121111.1058190-8-bryan.odonoghue@linaro.org>
On 01/05/2023 13:11, Bryan O'Donoghue wrote:
> This commit adds a QCOM PMIC TCPM driver with an initial pm8150b
> block.
>
> The driver is layered as follows:
>
> qcom_pmic_typec.c : Responsible for registering with TCPM and arbitrates
> access to the Type-C and PDPHY hardware blocks in one
> place. This presents a single TCPM device to device to
> the Linux TCPM layer.
>
> qcom_pmic_typec_pdphy.c: Responsible for interfacing with the PDPHY hardware and
> processing power-delivery related calls from TCPM.
> This hardware binding can be extended to
> facilitate similar hardware in different PMICs.
>
> qcom_pmic_typec_port.c: Responsible for notifying and processing Type-C
> related calls from TCPM. Similar to the pdphy this
> layer can be extended to handle the specifics of
> different Qualcomm PMIC Type-C port managers.
>
> This code provides all of the same functionality as the existing
> qcom typec driver plus power-delivery as well.
>
> As a result commit 6c8cf3695176 ("usb: typec: Add QCOM PMIC typec detection
> driver") can be deleted entirely.
>
> References code from Jonathan Marek, Jack Pham, Wesley Cheng, Hemant Kumar,
> Guru Das Srinagesh and Ashay Jaiswal.
>
> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>
Just a few additional nits:
[...]
> +
> +static struct platform_driver qcom_pmic_typec_platform_driver = {
This could be renamed to qcom_pmic_typec_driver, following the trend of
the other tcpm drivers.
> + .driver = {
> + .name = "qcom,pmic-typec",
> + .of_match_table = qcom_pmic_typec_table,
> + },
> + .probe = qcom_pmic_typec_probe,
> + .remove = qcom_pmic_typec_remove,
> +};
> +
> +static int __init qcom_pmic_typec_module_init(void)
> +{
> + int ret;
> +
> + ret = platform_driver_register(&qcom_pmic_typec_platform_driver);
> + if (ret)
> + return ret;
> +
> + return 0;
> +}
> +module_init(qcom_pmic_typec_module_init);
> +
> +static void __exit qcom_pmic_typec_module_exit(void)
> +{
> + platform_driver_unregister(&qcom_pmic_typec_platform_driver);
> +}
> +module_exit(qcom_pmic_typec_module_exit);
Can't this be simplified to just:
module_platform_driver(qcom_pmic_typec_platform_driver);
[...]
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.h b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.h
> new file mode 100644
> index 0000000000000..ebd33c9ae0606
> --- /dev/null
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.h
> @@ -0,0 +1,115 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
> + * Copyright (c) 2023, Linaro Ltd. All rights reserved.
> + */
> +#ifndef __QCOM_PMIC_PDPHY_H__
> +#define __QCOM_PMIC_PDPHY_H__
Missing a few headers:
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/usb/tcpm.h>
[...]
> +static irqreturn_t pmic_typec_port_isr(int irq, void *dev_id)
> +{
> + struct pmic_typec_port_irq_data *irq_data = dev_id;
> + struct pmic_typec_port *pmic_typec_port = irq_data->pmic_typec_port;
> + u32 misc_stat;
> + bool vbus_change = false;
> + bool cc_change = false;
> + unsigned long flags;
> + int ret;
> +
> + spin_lock_irqsave(&pmic_typec_port->lock, flags);
> +
> + ret = regmap_read(pmic_typec_port->regmap,
> + pmic_typec_port->base + TYPEC_MISC_STATUS_REG,
> + &misc_stat);
> + if (ret)
> + goto done;
> +
> + switch (irq_data->virq) {
> + case PMIC_TYPEC_VBUS_IRQ:
> + /* Incoming vbus assert/de-assert detect */
This comment can probably be dropped
> + vbus_change = true;
> + break;
> + case PMIC_TYPEC_CC_STATE_IRQ:
> + if (!pmic_typec_port->debouncing_cc)
> + cc_change = true;
> + break;
> + case PMIC_TYPEC_ATTACH_DETACH_IRQ:
> + if (!pmic_typec_port->debouncing_cc)
> + cc_change = true;
> + break;
> + }
The middle case can just fall through:
case PMIC_TYPEC_CC_STATE_IRQ:
case PMIC_TYPEC_ATTACH_DETACH_IRQ:
if (!pmic_typec_port->debouncing_cc)
cc_change = true;
break;
}
[...]
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.h b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.h
> new file mode 100644
> index 0000000000000..5a9c47373c614
> --- /dev/null
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.h
> @@ -0,0 +1,194 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
> + * Copyright (c) 2023, Linaro Ltd. All rights reserved.
> + */
> +#ifndef __QCOM_PMIC_TYPEC_H__
> +#define __QCOM_PMIC_TYPEC_H__
> +
Also missing some headers:
#include <linux/platform_device.h>
#include <linux/regmap.h>
> +#include <linux/usb/tcpm.h>
> +
--
Kind Regards,
Caleb (they/them)
next prev parent reply other threads:[~2023-05-01 17:50 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-01 12:10 [PATCH v6 00/13] Add Qualcomm PMIC TPCM support Bryan O'Donoghue
2023-05-01 12:10 ` [PATCH v6 01/13] dt-bindings: regulator: qcom,usb-vbus-regulator: Mark reg as required Bryan O'Donoghue
2023-05-01 12:11 ` [PATCH v6 02/13] dt-bindings: regulator: qcom,usb-vbus-regulator: Mark regulator-*-microamp required Bryan O'Donoghue
2023-05-01 12:11 ` [PATCH v6 03/13] dt-bindings: phy: qcom,sc7180-qmp-usb3-dp-phy: Add orientation-switch as optional Bryan O'Donoghue
2023-05-01 12:11 ` [PATCH v6 04/13] dt-bindings: phy: qcom,sc7180-qmp-usb3-dp-phy: Add input and output ports Bryan O'Donoghue
2023-05-02 10:45 ` Krzysztof Kozlowski
2023-05-02 10:51 ` Krzysztof Kozlowski
2023-05-01 12:11 ` [PATCH v6 05/13] dt-bindings: usb: Add Qualcomm PMIC Type-C Bryan O'Donoghue
2023-05-02 10:56 ` Krzysztof Kozlowski
2023-05-01 12:11 ` [PATCH v6 06/13] dt-bindings: mfd: qcom,spmi-pmic: Add typec to SPMI device types Bryan O'Donoghue
2023-05-01 12:11 ` [PATCH v6 07/13] usb: typec: qcom: Add Qualcomm PMIC Type-C driver Bryan O'Donoghue
2023-05-01 13:31 ` Guenter Roeck
2023-05-01 17:50 ` Caleb Connolly [this message]
2023-05-01 12:11 ` [PATCH v6 08/13] arm64: dts: qcom: sm8250: Define ports for qmpphy orientation-switching Bryan O'Donoghue
2023-05-02 11:01 ` Konrad Dybcio
2023-05-01 12:11 ` [PATCH v6 09/13] arm64: dts: qcom: pm8150b: Add a TCPM description Bryan O'Donoghue
2023-05-01 12:11 ` [PATCH v6 10/13] arm64: dts: qcom: qrb5165-rb5: Switch on Type-C VBUS boost Bryan O'Donoghue
2023-05-02 10:56 ` Konrad Dybcio
2023-05-01 12:11 ` [PATCH v6 11/13] arm64: dts: qcom: qrb5165-rb5: Switch on basic TCPM Bryan O'Donoghue
2023-05-01 15:28 ` Jianhua Lu
2023-05-02 10:57 ` Konrad Dybcio
2023-05-01 12:11 ` [PATCH v6 12/13] arm64: dts: qcom: qrb5165-rb5: Switch on TCPM usb-role-switching for usb_1 Bryan O'Donoghue
2023-05-01 15:21 ` Jianhua Lu
2023-05-01 15:53 ` Bryan O'Donoghue
2023-05-01 16:04 ` Jianhua Lu
2023-05-01 15:30 ` Jianhua Lu
2023-05-02 11:00 ` Konrad Dybcio
2023-05-02 11:03 ` Bryan O'Donoghue
2023-05-02 11:13 ` Konrad Dybcio
2023-05-02 11:16 ` Bryan O'Donoghue
2023-05-02 11:47 ` Konrad Dybcio
2023-05-02 12:10 ` Bryan O'Donoghue
2023-05-07 21:09 ` Bryan O'Donoghue
2023-05-01 12:11 ` [PATCH v6 13/13] arm64: dts: qcom: qrb5165-rb5: Switch on TCPM orientation-switch for usb_1_qmpphy Bryan O'Donoghue
2023-05-01 15:34 ` Jianhua Lu
2023-05-01 16:00 ` Bryan O'Donoghue
2023-05-01 15:37 ` Jianhua Lu
2023-05-01 17:04 ` Bryan O'Donoghue
2023-05-02 11:01 ` Konrad Dybcio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=91cf184b-2466-183d-5800-da0a12a0701c@linaro.org \
--to=caleb.connolly@linaro.org \
--cc=andersson@kernel.org \
--cc=bryan.odonoghue@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=jackp@quicinc.com \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=luca.weiss@fairphone.com \
--cc=robertom@qti.qualcomm.com \
--cc=robh+dt@kernel.org \
--cc=subbaram@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox