mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krishna Kurapati PSSNV <krishna.kurapati@oss.qualcomm.com>
To: Biju Das <biju.das.jz@bp.renesas.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Subject: Re: [PATCH v3 2/2] usb: typec: hd3ss3220: Enable VBUS based on ID pin state
Date: Sat, 25 Oct 2025 13:46:01 +0530	[thread overview]
Message-ID: <828cbef4-6b4b-413e-9f76-d61d35771192@oss.qualcomm.com> (raw)
In-Reply-To: <TY3PR01MB113464EA259DDA069E7453DF986FEA@TY3PR01MB11346.jpnprd01.prod.outlook.com>



On 10/25/2025 12:31 PM, Biju Das wrote:
> 
> 
>> -----Original Message-----
>> From: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
>> Sent: 24 October 2025 19:19
>> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>; Rob Herring <robh@kernel.org>; Krzysztof
>> Kozlowski <krzk+dt@kernel.org>; Conor Dooley <conor+dt@kernel.org>; Heikki Krogerus
>> <heikki.krogerus@linux.intel.com>; Biju Das <biju.das.jz@bp.renesas.com>; Dmitry Baryshkov
>> <dmitry.baryshkov@oss.qualcomm.com>
>> Cc: linux-usb@vger.kernel.org; devicetree@vger.kernel.org; linux-kernel@vger.kernel.org; Krishna
>> Kurapati <krishna.kurapati@oss.qualcomm.com>
>> Subject: [PATCH v3 2/2] usb: typec: hd3ss3220: Enable VBUS based on ID pin state
>>
>> There is a ID pin present on HD3SS3220 controller that can be routed to SoC. As per the datasheet:
>>
>> "Upon detecting a UFP device, HD3SS3220 will keep ID pin high if VBUS is not at VSafe0V. Once VBUS is
>> at VSafe0V, the HD3SS3220 will assert ID pin low. This is done to enforce Type-C requirement that VBUS
>> must be at VSafe0V before re-enabling VBUS"
>>
>> Add support to read the ID pin state and enable VBUS accordingly.
>>
>> Signed-off-by: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
>> ---
>>   drivers/usb/typec/hd3ss3220.c | 101 ++++++++++++++++++++++++++++++++++
>>   1 file changed, 101 insertions(+)
>>

[...]

>> +static int hd3ss3220_get_vbus_supply(struct hd3ss3220 *hd3ss3220) {
>> +	struct device_node *hd3ss3220_node = hd3ss3220->dev->of_node;
>> +	const char *compat_string;
>> +	struct device_node *np;
>> +	int num_ports = 0;
>> +	int ret = 0;
>> +	int i = 0;
>> +
>> +	num_ports = of_graph_get_port_count(hd3ss3220_node);
>> +
>> +	for (i = 0; i < num_ports; i++) {
>> +		np = of_graph_get_remote_node(hd3ss3220_node, i, 0);
>> +		if (!np) {
>> +			dev_err(hd3ss3220->dev, "failed to get device node");
>> +			ret = -ENODEV;
>> +			goto done;
>> +		}
>> +
>> +		ret = of_property_read_string(np, "compatible", &compat_string);
>> +		if (ret) {
>> +			of_node_put(np);
>> +			dev_err(hd3ss3220->dev, "failed to get compatible string");
>> +			ret = -ENODEV;
>> +			goto done;
>> +		}
>> +
>> +		if (strcmp(compat_string, "usb-c-connector") == 0) {
>> +			hd3ss3220->vbus = of_regulator_get(hd3ss3220->dev, np, "vbus");
>> +			if (PTR_ERR(hd3ss3220->vbus) == -ENODEV)
>> +				hd3ss3220->vbus = NULL;
>> +
>> +			if (IS_ERR(hd3ss3220->vbus))
>> +				ret = -ENODEV;
>> +		}
>> +
>> +		of_node_put(np);
>> +	}
>> +
>> +done:
>> +	return ret;
>> +}
>> +
>>   static int hd3ss3220_probe(struct i2c_client *client)  {
>>   	struct typec_capability typec_cap = { }; @@ -354,6 +427,34 @@ static int hd3ss3220_probe(struct
>> i2c_client *client)
>>   		hd3ss3220->role_sw = usb_role_switch_get(hd3ss3220->dev);
>>   	}
>>
>> +	hd3ss3220->id_gpiod = devm_gpiod_get_optional(hd3ss3220->dev, "id", GPIOD_IN);
>> +	if (IS_ERR(hd3ss3220->id_gpiod))
>> +		return PTR_ERR(hd3ss3220->id_gpiod);
>> +
>> +	if (hd3ss3220->id_gpiod) {
>> +		hd3ss3220->id_irq = gpiod_to_irq(hd3ss3220->id_gpiod);
>> +		if (hd3ss3220->id_irq < 0) {
>> +			dev_err(hd3ss3220->dev, "failed to get ID IRQ\n");
>> +			return hd3ss3220->id_irq;
>> +		}
>> +
>> +		ret = devm_request_threaded_irq(hd3ss3220->dev,
>> +						hd3ss3220->id_irq, NULL,
>> +						hd3ss3220_id_isr,
>> +						IRQF_TRIGGER_RISING |
>> +						IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
>> +						dev_name(hd3ss3220->dev), hd3ss3220);
>> +		if (ret < 0) {
>> +			dev_err(hd3ss3220->dev, "failed to get id irq\n");
>> +			return ret;
>> +		}
>> +	}
>> +
>> +	ret = hd3ss3220_get_vbus_supply(hd3ss3220);
>> +	if (ret)
>> +		return dev_err_probe(hd3ss3220->dev,
>> +				     PTR_ERR(hd3ss3220->vbus), "failed to get vbus\n");
> 
> Does this code backward compatible? There is no vbus definition here [1]
> 
> [1]
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/arch/arm64/boot/dts/renesas/r8a774c0-cat874.dts?h=next-20251024#n208
> 

Hi Biju,

  Yes. If there is no vbus supply in the usb-c-connector node, we just 
mark it as NULL. The ret value would be zero if there is no vbus.

Regards,
Krishna,

      reply	other threads:[~2025-10-25  8:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-24 18:18 [PATCH v3 0/2] Implement vbus support for HD3SS3220 port controller Krishna Kurapati
2025-10-24 18:18 ` [PATCH v3 1/2] dt-bindings: usb: ti,hd3ss3220: Add support for VBUS based on ID state Krishna Kurapati
2025-10-24 18:18 ` [PATCH v3 2/2] usb: typec: hd3ss3220: Enable VBUS based on ID pin state Krishna Kurapati
2025-10-24 23:37   ` Dmitry Baryshkov
2025-10-25  7:01   ` Biju Das
2025-10-25  8:16     ` Krishna Kurapati PSSNV [this message]

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=828cbef4-6b4b-413e-9f76-d61d35771192@oss.qualcomm.com \
    --to=krishna.kurapati@oss.qualcomm.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=robh@kernel.org \
    /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

all inboxes | Powered by JetHome®