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: ChiYuan Huang X-Patchwork-Id: 12022967 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=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,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=ham 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 6E486C433E0 for ; Fri, 15 Jan 2021 14:14:01 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2BABF22248 for ; Fri, 15 Jan 2021 14:14:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2BABF22248 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=tKWUsM8D1CrgfzXDBAJjXplngnE69hstoJFTm7qdiGs=; b=3c6/aCc59jSuXghC7TT0KxuTeE iURkFx/H0Ub6VvhoVelKMRyu1iD2WAQzQfqjei7etT2QqFLFmUL+VtPWaBF/vZ0ewiVctYey/1xxg dBWWLE7PBVLYqUFyEDlopR3mkibi4R7Xs8UTX/kV3SrzhYErVNci8Bxkpleix08CdyOu2huZ5OFfA ejwjaXDIB1uXDQkW37GLSItwLno34Wyr/DgStgilT3SV/4rOLIrCDJAxc0hfyWhLxxogz+GWPyjKh u7M9o6JZd5MLzEmNKZOt52CPVkdebrUssHwcieFunpCeKZMZsOz5clZbw0XD6Kp01+jBrzaLF5WuV KnCgKj0g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0PrE-0005L2-M6; Fri, 15 Jan 2021 14:13:44 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0PrA-0005J1-Am; Fri, 15 Jan 2021 14:13:41 +0000 Received: by mail-pl1-x632.google.com with SMTP id x12so4752765plr.10; Fri, 15 Jan 2021 06:13:37 -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=oZFZI5gqwY14FfArEffmAkcETL5n1BtSThzZo6aIDI35rFS+QCm83TbbVMQeyOGbew J7+dhBVUpbZQLX8p+b+If33SDgH48TE2VNx19iu6OyCnNPT/g7hLxbqgoM+BGmenxkHi rSGNB4+opdQbgrtGwhZDIdGua4gEyqsFT29P2jLrq7FYHRjUnWo9VubejbCiuhaMfNME 5NtzS9YrzSAH0oFjYMu//uKgZCnzaLgEXU5Mz94YAL/UXH6kQ1LmTa9ar8Z9j/7Tkcdj 1kAql8c96UNx/rAdHzuoQalQuGwDr10Vr9FKIs/Hr51hntq3V2+cz8zvPPgbyU7w+7/l 4a5A== X-Gm-Message-State: AOAM533gFFarSb4iMavdTH6gerX4mMDWkZDv3F5G8NL0vN3KVwJPI/eP qDcMmZ13y+6aPztb68HTbAQ= 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210115_091340_388742_E07D7C96 X-CRM114-Status: GOOD ( 17.13 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gene_chen@richtek.com, devicetree@vger.kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, cy_huang@richtek.com, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.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: ChiYuan Huang X-Patchwork-Id: 12022969 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=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,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=ham 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 4ECAAC433DB for ; Fri, 15 Jan 2021 14:14:03 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 04D0123772 for ; Fri, 15 Jan 2021 14:14:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04D0123772 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=B3ckBe2r0lgEF3yf8YkmZzc7F86GNzF8+TMKdUphVzU=; b=OCRZnapAeFnKlKi3vxfSeYRCs+ JdHxukmOsQ1r20oTrGjJqHyrUP+2QqEKupgvni08LC4p/zzpMLezS+UGNmbb8hPcTG/uhnwm5ZrKe Fj44GunCi5vWriRDUEFKrYbvWX+oC5VC1SI6qCFVkwCM+cxiTUrw+1bYpKxLSG9NKbLiAiL3HsLhM VLDqaKsLXiT/Do3xjb+7hWBlLpOEuDImYPUgNkefaGt2LxaPRBOGdvKpv6gtC4maIPAsVE6Qp7Vvj 2ZCMMM0+fDoXPIs6eZCFljafpkpXfSiqe7/5a6p781/Q5LyK2dIkZ2tk2C72cxD5H3LvRhpcbfhH/ LaSRqDpQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0PrJ-0005M6-Og; Fri, 15 Jan 2021 14:13:49 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0PrC-0005Jr-IF; Fri, 15 Jan 2021 14:13:43 +0000 Received: by mail-pl1-x62a.google.com with SMTP id be12so4768227plb.4; Fri, 15 Jan 2021 06:13:41 -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=kUDxgp3AKwb6g+NPIZSFyGLohRMc1fX3WXACuP7s+lv7gJwHf5PyqABI4mQUtmbX2V SPLfjNmcUQcl1HYF+dLx+JFx8j9pfhRN+FkfVKUlyoqnQuIY2IQU1Jcy9gwVcWxKpZVg lY1LQhuvc85P4nNSPyw/AJxAJ9uv+D5aWE1vgrxUUMmCGWU2TQCpwu/wO3/7xixNdsfH 47ArOQ+o2hYHnPJAoaVnm93QjIpzxV2QVw4gJzYta/S69Zs06YDvO2yg97gfMCZedl2w CFOSRJ/cx/wnWHrhsdKn+WgAEVr8AQC1T1vntrYn12K/DqTtP6wbA+ws17Gs+txU6l/M qhvQ== X-Gm-Message-State: AOAM530vcZWUmwY8+1y5gXANEhnAwPkxLWxT23sr5NqXJSI7GOF6e+VT vF08EJpz2Mk5sOsv1TSUw2Q= 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210115_091342_657754_04828476 X-CRM114-Status: GOOD ( 10.64 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gene_chen@richtek.com, devicetree@vger.kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, cy_huang@richtek.com, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.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";