From patchwork Fri Jan 15 14:13:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: cy_huang X-Patchwork-Id: 364831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84FF4C433E0 for ; Fri, 15 Jan 2021 14:14:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 47C5523772 for ; Fri, 15 Jan 2021 14:14:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732039AbhAOOOR (ORCPT ); Fri, 15 Jan 2021 09:14:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731745AbhAOOOQ (ORCPT ); Fri, 15 Jan 2021 09:14:16 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98172C061757; Fri, 15 Jan 2021 06:13:36 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id e9so603114plh.3; Fri, 15 Jan 2021 06:13:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=CbZNeMTYUi7Mg7VyMn/xUQXZnoLVOk+YmqoECElgO5I=; b=QUTm2d97niOvJWqofhkNL9W7lxALHkiFYLbsnmHT0j6+l2dfDaVQyUZVkUTC1l0mdl EICM5zti7BnGQNrwu4DiXRWqFvaBLTaXJp/19o0TYCNYaDP2Snwoj15htcJAHpvMwipe NSqam4a9wE5z+mxPyB7GAYPZNLg+w0K4Eal2jElAfNitB8PrVW0VEIN2iAm2FetBHQLN W3WhorgQ03TvG6kvqY2qIEI3tH8uYI2+a2xEGi3Jw3GKnrmGg4lsIyr4GXpqFdlkTxQe lncTy92kOlFjxnnKl0b7d31JCFUFAgEfJgjr5DMfVuhvkOEkoO5xcdJIOahzNQUrx8b2 EApg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=CbZNeMTYUi7Mg7VyMn/xUQXZnoLVOk+YmqoECElgO5I=; b=XwFawtYvV5QlbxxTMkHlvzkkKzA2h3kooPLAIsskyGnezCwpCT5SXET05bUoKE6gad DHxZpztMx7N4RomIvQ+xsiXqqTyzAOjKvG/A8JMNs0WRI6xVolucu3zWIt9dpI6Be8qO C8wlbtpKhd01UOVLq0kUPpJKn+E9ncSrYSgRnJ+RSA12ThWUe14mtHBntuKX9ewBjWWE zmLl9bffBjsFli0HIO1TklZGjWyQpV0SmBH17eniGWlsLt651P/4aI62b6V7RNYDL5E8 h16NBK4eW4heYutMDT2IAEFevIanm6yt2qZ0dT4M2oKUaaYmWzbDx5ahUWZJWIRlsWBK 0yEw== X-Gm-Message-State: AOAM532SCis/6kwWrrSqch+JFg20x6O+LOwke/wrjdqZSjLDWfdcpw3a pGRQIZ5qQ1riqQuIBZh2VdGMO1XLNms= X-Google-Smtp-Source: ABdhPJyGv8T8Tw0nXwlkPBk1os5KvQGNW2rZCV/3HHX43JkUZJkmNwkV4CuqIo7ieQn+gWYnNXksow== X-Received: by 2002:a17:90a:b395:: with SMTP id e21mr10781383pjr.197.1610720015990; Fri, 15 Jan 2021 06:13:35 -0800 (PST) Received: from localhost.localdomain (1-171-15-80.dynamic-ip.hinet.net. [1.171.15.80]) by smtp.gmail.com with ESMTPSA id h5sm8898408pgl.86.2021.01.15.06.13.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jan 2021 06:13:34 -0800 (PST) From: cy_huang To: linux@roeck-us.net, heikki.krogerus@linux.intel.com, matthias.bgg@gmail.com, robh+dt@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, cy_huang@richtek.com, gene_chen@richtek.com, devicetree@vger.kernel.org Subject: [PATCH 1/2] usb typec: tcpci: mt6360: Add vsafe0v support and external vbus supply control Date: Fri, 15 Jan 2021 22:13:20 +0800 Message-Id: <1610720001-15300-1-git-send-email-u0084500@gmail.com> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: ChiYuan Huang MT6360 not support for TCPC command to control source and sink. Uses external 5V vbus regulator as the vbus source control. Also adds the capability to report vsafe0v. Signed-off-by: ChiYuan Huang --- drivers/usb/typec/tcpm/tcpci_mt6360.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/usb/typec/tcpm/tcpci_mt6360.c b/drivers/usb/typec/tcpm/tcpci_mt6360.c index f1bd9e0..0edf4b6 100644 --- a/drivers/usb/typec/tcpm/tcpci_mt6360.c +++ b/drivers/usb/typec/tcpm/tcpci_mt6360.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "tcpci.h" @@ -36,6 +37,7 @@ struct mt6360_tcpc_info { struct tcpci_data tdata; struct tcpci *tcpci; struct device *dev; + struct regulator *vbus; int irq; }; @@ -51,6 +53,27 @@ static inline int mt6360_tcpc_write16(struct regmap *regmap, return regmap_raw_write(regmap, reg, &val, sizeof(u16)); } +static int mt6360_tcpc_set_vbus(struct tcpci *tcpci, struct tcpci_data *data, bool src, bool snk) +{ + struct mt6360_tcpc_info *mti = container_of(data, struct mt6360_tcpc_info, tdata); + int ret; + + /* To correctly handle the already enabled vbus and disable its supply first */ + if (regulator_is_enabled(mti->vbus)) { + ret = regulator_disable(mti->vbus); + if (ret) + return ret; + } + + if (src) { + ret = regulator_enable(mti->vbus); + if (ret) + return ret; + } + + return 0; +} + static int mt6360_tcpc_init(struct tcpci *tcpci, struct tcpci_data *tdata) { struct regmap *regmap = tdata->regmap; @@ -138,7 +161,13 @@ static int mt6360_tcpc_probe(struct platform_device *pdev) if (mti->irq < 0) return mti->irq; + mti->vbus = devm_regulator_get(&pdev->dev, "vbus"); + if (IS_ERR(mti->vbus)) + return PTR_ERR(mti->vbus); + mti->tdata.init = mt6360_tcpc_init; + mti->tdata.set_vbus = mt6360_tcpc_set_vbus; + mti->tdata.vbus_vsafe0v = 1; mti->tcpci = tcpci_register_port(&pdev->dev, &mti->tdata); if (IS_ERR(mti->tcpci)) { dev_err(&pdev->dev, "Failed to register tcpci port\n"); From patchwork Fri Jan 15 14:13:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: cy_huang X-Patchwork-Id: 363991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2AF7C433E6 for ; Fri, 15 Jan 2021 14:14:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9E23E224F9 for ; Fri, 15 Jan 2021 14:14:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732969AbhAOOOW (ORCPT ); Fri, 15 Jan 2021 09:14:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731745AbhAOOOW (ORCPT ); Fri, 15 Jan 2021 09:14:22 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 766ADC0613C1; Fri, 15 Jan 2021 06:13:40 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id b8so4777955plx.0; Fri, 15 Jan 2021 06:13:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pEukWvtuwh82TDEPEZ3woLLJLq853GtFGRDGVW376W0=; b=d56nTDt327VgF/XuYROfVX7Ku4gbnv881jVJBzfwSdhMsqCb8W3xDas4Ii4WP+3rym y1jbl0OHSy2yL2Qfm6Xatbk4PvpjuiIjVbeLpGibFMYI2unQT2LA3qpK4ZrfXMTdSeo7 d9WQ8asbVfBdxxwbrSVMxgt+VI4r3jLDbyYjFsxx6bzqZ4j/cUnSHlklmYfQOGE2BwF/ cugv4B7yy40HyQWJFkunnBqNZL9l40c0l3U+YEtmducQgtcrKQpgMh/4dhD/Ipf6pxgj vJTdIrhLFXNTYs1G13vxi7AOZEB6fG7h1X1n9cCowKokdjfDRXDuERCE5kO1o0CFLHW3 6YCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pEukWvtuwh82TDEPEZ3woLLJLq853GtFGRDGVW376W0=; b=MueGgKYIYLwk7x3IMaGjlWUSu/9yXphEfMWCOWSAX8WDGYFXgLsgmt4BvmQus6ew1c CARothZtyouE2xqYRlvSRqDUnniHxZpODIMBFHhiXIyQvycmBq42zFXdSau8u/fK09ap 49DmXYSvm+vnzxl4aTa4zC5SkttprKXa/OpJeoMat6rcmF2MteAs5yqNE+9Jg7OZbzcT ZdoUqXU5JN5J6ImWllB6339AS84YR2l7Dz85CrWSd/VuZcyAtXcRnIQ5WzfXkXe5KWz5 17/m0xFggOFey5riEAYpHHu2fUqrSYn2Za81DF9UMlz4DGEOdMvjG6dN+ZW/aUym3170 pplw== X-Gm-Message-State: AOAM5319o5Of077gG989vWsB5AdBr4ZZhyWPX7uCI9dRmUw0by6DwHMq UNc5JRje02YErjsDZp/6f2k= X-Google-Smtp-Source: ABdhPJwLvlOK7S6tSYllr+OMNyZgyloJTKWhIZLiNjcdhjGKjeEWhTc0QmEW8fZcY9NCzKk9a2u6Jg== X-Received: by 2002:a17:902:9896:b029:dc:3306:8aa7 with SMTP id s22-20020a1709029896b02900dc33068aa7mr12972171plp.6.1610720019995; Fri, 15 Jan 2021 06:13:39 -0800 (PST) Received: from localhost.localdomain (1-171-15-80.dynamic-ip.hinet.net. [1.171.15.80]) by smtp.gmail.com with ESMTPSA id h5sm8898408pgl.86.2021.01.15.06.13.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jan 2021 06:13:39 -0800 (PST) From: cy_huang To: linux@roeck-us.net, heikki.krogerus@linux.intel.com, matthias.bgg@gmail.com, robh+dt@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, cy_huang@richtek.com, gene_chen@richtek.com, devicetree@vger.kernel.org Subject: [PATCH 2/2] usb typec: tcpci: mt6360: Add vbus supply into dt-binding description Date: Fri, 15 Jan 2021 22:13:21 +0800 Message-Id: <1610720001-15300-2-git-send-email-u0084500@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1610720001-15300-1-git-send-email-u0084500@gmail.com> References: <1610720001-15300-1-git-send-email-u0084500@gmail.com> Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: ChiYuan Huang Add external vbus source into dt-binding description. Signed-off-by: ChiYuan Huang --- Documentation/devicetree/bindings/usb/mediatek,mt6360-tcpc.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/mediatek,mt6360-tcpc.yaml b/Documentation/devicetree/bindings/usb/mediatek,mt6360-tcpc.yaml index 1e8e1c2..b8d842b 100644 --- a/Documentation/devicetree/bindings/usb/mediatek,mt6360-tcpc.yaml +++ b/Documentation/devicetree/bindings/usb/mediatek,mt6360-tcpc.yaml @@ -26,6 +26,11 @@ properties: items: - const: PD_IRQB + vbus-supply: + description: + Vbus source supply regulator. + maxItems: 1 + connector: type: object $ref: ../connector/usb-connector.yaml# @@ -38,6 +43,7 @@ required: - compatible - interrupts - interrupt-names + - vbus-supply examples: - | @@ -54,6 +60,7 @@ examples: compatible = "mediatek,mt6360-tcpc"; interrupts-extended = <&gpio26 3 IRQ_TYPE_LEVEL_LOW>; interrupt-names = "PD_IRQB"; + vbus-supply = <&otg_vbus>; connector { compatible = "usb-c-connector";