From patchwork Fri Dec 9 17:18:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13070041 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 722BDC4332F for ; Fri, 9 Dec 2022 17:19:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230132AbiLIRTR (ORCPT ); Fri, 9 Dec 2022 12:19:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230214AbiLIRSz (ORCPT ); Fri, 9 Dec 2022 12:18:55 -0500 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8BDFB26ABE; Fri, 9 Dec 2022 09:18:45 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.96,230,1665414000"; d="scan'208";a="142849593" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 10 Dec 2022 02:18:45 +0900 Received: from localhost.localdomain (unknown [10.226.92.39]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 99EA04035BC0; Sat, 10 Dec 2022 02:18:42 +0900 (JST) From: Biju Das To: Rob Herring , Krzysztof Kozlowski Cc: Biju Das , Greg Kroah-Hartman , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, Geert Uytterhoeven , Fabrizio Castro , linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 1/2] dt-bindings: usb: ti,hd3ss3220: Update interrupt property as optional Date: Fri, 9 Dec 2022 17:18:35 +0000 Message-Id: <20221209171836.71610-2-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209171836.71610-1-biju.das.jz@bp.renesas.com> References: <20221209171836.71610-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org On some platforms(for eg: RZ/V2M EVK), interrupt is not populated. Update the binding to make interrupt property as optional. Signed-off-by: Biju Das Acked-by: Rob Herring Reviewed-by: Geert Uytterhoeven --- v1->v2: * updated the typo in commit description. --- Documentation/devicetree/bindings/usb/ti,hd3ss3220.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/Documentation/devicetree/bindings/usb/ti,hd3ss3220.yaml b/Documentation/devicetree/bindings/usb/ti,hd3ss3220.yaml index b86bf6bc9cd6..a1cffb70c621 100644 --- a/Documentation/devicetree/bindings/usb/ti,hd3ss3220.yaml +++ b/Documentation/devicetree/bindings/usb/ti,hd3ss3220.yaml @@ -46,7 +46,6 @@ properties: required: - compatible - reg - - interrupts additionalProperties: false From patchwork Fri Dec 9 17:18:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13070042 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 028FDC4332F for ; Fri, 9 Dec 2022 17:19:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230030AbiLIRTX (ORCPT ); Fri, 9 Dec 2022 12:19:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230072AbiLIRS6 (ORCPT ); Fri, 9 Dec 2022 12:18:58 -0500 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B85C313E8D; Fri, 9 Dec 2022 09:18:48 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.96,230,1665414000"; d="scan'208";a="145653356" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 10 Dec 2022 02:18:48 +0900 Received: from localhost.localdomain (unknown [10.226.92.39]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id E066E4035BC1; Sat, 10 Dec 2022 02:18:45 +0900 (JST) From: Biju Das To: Heikki Krogerus Cc: Biju Das , Greg Kroah-Hartman , linux-usb@vger.kernel.org, Geert Uytterhoeven , Fabrizio Castro , linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 2/2] usb: typec: hd3ss3220: Add polling support Date: Fri, 9 Dec 2022 17:18:36 +0000 Message-Id: <20221209171836.71610-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209171836.71610-1-biju.das.jz@bp.renesas.com> References: <20221209171836.71610-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Some platforms(for eg: RZ/V2M EVK) does not have interrupt pin connected to HD3SS3220. Add polling support for role detection. Signed-off-by: Biju Das Reviewed-by: Heikki Krogerus --- v1->v2: * Dropped patch#3 for soring header files. --- drivers/usb/typec/hd3ss3220.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/usb/typec/hd3ss3220.c b/drivers/usb/typec/hd3ss3220.c index c24bbccd14f9..a445c1bd0627 100644 --- a/drivers/usb/typec/hd3ss3220.c +++ b/drivers/usb/typec/hd3ss3220.c @@ -14,6 +14,7 @@ #include #include #include +#include #define HD3SS3220_REG_CN_STAT_CTRL 0x09 #define HD3SS3220_REG_GEN_CTRL 0x0A @@ -37,6 +38,9 @@ struct hd3ss3220 { struct regmap *regmap; struct usb_role_switch *role_sw; struct typec_port *port; + struct delayed_work output_poll_work; + enum usb_role role_state; + bool poll; }; static int hd3ss3220_set_source_pref(struct hd3ss3220 *hd3ss3220, int src_pref) @@ -118,6 +122,22 @@ static void hd3ss3220_set_role(struct hd3ss3220 *hd3ss3220) default: break; } + + hd3ss3220->role_state = role_state; +} + +static void output_poll_execute(struct work_struct *work) +{ + struct delayed_work *delayed_work = to_delayed_work(work); + struct hd3ss3220 *hd3ss3220 = container_of(delayed_work, + struct hd3ss3220, + output_poll_work); + enum usb_role role_state = hd3ss3220_get_attached_state(hd3ss3220); + + if (hd3ss3220->role_state != role_state) + hd3ss3220_set_role(hd3ss3220); + + schedule_delayed_work(&hd3ss3220->output_poll_work, HZ); } static irqreturn_t hd3ss3220_irq(struct hd3ss3220 *hd3ss3220) @@ -227,6 +247,9 @@ static int hd3ss3220_probe(struct i2c_client *client, "hd3ss3220", &client->dev); if (ret) goto err_unreg_port; + } else { + INIT_DELAYED_WORK(&hd3ss3220->output_poll_work, output_poll_execute); + hd3ss3220->poll = true; } ret = i2c_smbus_read_byte_data(client, HD3SS3220_REG_DEV_REV); @@ -235,6 +258,9 @@ static int hd3ss3220_probe(struct i2c_client *client, fwnode_handle_put(connector); + if (hd3ss3220->poll) + schedule_delayed_work(&hd3ss3220->output_poll_work, HZ); + dev_info(&client->dev, "probed revision=0x%x\n", ret); return 0; @@ -252,6 +278,9 @@ static void hd3ss3220_remove(struct i2c_client *client) { struct hd3ss3220 *hd3ss3220 = i2c_get_clientdata(client); + if (hd3ss3220->poll) + cancel_delayed_work_sync(&hd3ss3220->output_poll_work); + typec_unregister_port(hd3ss3220->port); usb_role_switch_put(hd3ss3220->role_sw); }