From patchwork Thu Aug 27 03:25:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ChiYuan Huang X-Patchwork-Id: 11739869 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B692739 for ; Thu, 27 Aug 2020 03:26:02 +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 1921F2078A for ; Thu, 27 Aug 2020 03:26:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Fvojr3ye"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e8alhXMF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1921F2078A 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+patchwork-linux-mediatek=patchwork.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=r3XgKDL44huHsD6QJLg1xHnoQN7O+aEEmYCaJyJOMZk=; b=Fvojr3yeZD2C/bkwP/SMs1R3pd 1W7gyZQdIPdFTuX+cgAxMoxHEXyntK/6MD4/4zTK6o0b2qYQyDfgScSRbdwS1I7uuZZuTi+37ZKmv u4kFbT+JnDUfgqx5E9eWSwntiZgc068kfVrTb5U4ZVMzXo3VMXvPYCpMSpmhiivuHQIZKi6gPMK7H I5jTdGNMxnLPH6u2Bxc42+axAa5/GIP22hQC0JjY3nqogZI2fZmIVte3JicQ7rKzt+MsC4dKhzd3n rS/9ecsLI8OtT11pgEezm9SFMZs5jSXWUNql7stQoIwEM2KVlXwDFAV8dnD67D6p7xwSgiCC1Sltp d1mMRTEg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kB8Y4-00036W-5d; Thu, 27 Aug 2020 03:26:00 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kB8Xz-00035R-Ck; Thu, 27 Aug 2020 03:25:56 +0000 Received: by mail-pf1-x443.google.com with SMTP id k1so2399849pfu.2; Wed, 26 Aug 2020 20:25:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ulmIBrkE/+2FmnrwC+qCk+BjYqdq5xXkk5I/QcMd7Ug=; b=e8alhXMFs1AKhmDiWkK+eKHfOhDDLRtujV3DqfPsA/S6bAlvAZWjTwulZJI6PopORn 58yNCsFl7rAFiXwJCrAemFSsJK2uYkC++4e/XlLSJCOwrENsOdKjSTUHot51I/h78Uyn rQ0mi9veyBPrSbunDzhzykBS7jZsIzdiYbc84PXcQ8fAsTx4B1aJA6u1XiH8sOMDdYx4 7vIO6xb/AJKWw5dhy+53uB0Jc6Bl85ldMYLKQBPgMIKr+CvlSb5BrFALRg1+5nJS7krd NJKbPbPzfVvl1oV2i9q1URxTXE3xDiY6tbWsSq63M8IKOm6OjzXkgLlk3srEcYLqIQ6A DP6Q== 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=ulmIBrkE/+2FmnrwC+qCk+BjYqdq5xXkk5I/QcMd7Ug=; b=jQdbwm0CaVkI1MA5FNHDhsq06PHOQ7+Hp1KRR37mUKRqzWhAYrPlhl5uEg/J5/VNRE gdHtdhlPTsStcA3ulDnRCYajzTswSRAo2kIrHJIUT5jVt+C5FZutpLzOp7yy6GXjW8Wd UeaCmZzU6fwfo4oa0r9P+gb6hq8+1ir49Md6b1ytP3mAi2W5zGQ/c97UWSX5Y7jC22jP e3+4tqu8w/BpIyeR0x19OyevcG0wikqgE47u6pCr3YQtpCLlO8acrIjplfZPlEMGqLZc X1gAq5o8MnZ3VPqtuynW6MFpD7dPkeg7a4601XXwey8IA+XTL2ThkZMgfbdTHzTcZcsW Jq7w== X-Gm-Message-State: AOAM532KGcCo7NvX83Mx74s7y4JGXSihJKZOydVfZYVRUjyf9rMdLPYc YCMEKS6l5hDmZH5XQtOM+N0= X-Google-Smtp-Source: ABdhPJxrx48ZYbxgaQFe2cr1IrRk8/2K7FCmaKdo+CVROoZK0e9qUPl0JHx4HK4b+6uz/tBnsPYYaw== X-Received: by 2002:a17:902:be0f:: with SMTP id r15mr14693788pls.84.1598498752906; Wed, 26 Aug 2020 20:25:52 -0700 (PDT) Received: from localhost.localdomain ([2402:7500:57b:156e:1129:dc1b:b8d8:6430]) by smtp.gmail.com with ESMTPSA id 70sm676982pfu.107.2020.08.26.20.25.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2020 20:25:52 -0700 (PDT) From: cy_huang To: gregkh@linuxfoundation.org, robh+dt@kernel.org, matthias.bgg@gmail.com, linux@roeck-us.net, heikki.krogerus@linux.intel.com Subject: [PATCH v2 1/3] usb typec: mt6360: Add support for mt6360 Type-C driver Date: Thu, 27 Aug 2020 11:25:30 +0800 Message-Id: <1598498732-25194-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-20200826_232555_462302_162697B2 X-CRM114-Status: GOOD ( 22.84 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:443 listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [u0084500[at]gmail.com] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [u0084500[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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, 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+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org From: ChiYuan Huang Mediatek MT6360 is a multi-functional IC that includes USB Type-C. It works with Type-C Port Controller Manager to provide USB PD and USB Type-C functionalities. Signed-off-by: ChiYuan Huang --- drivers/usb/typec/tcpm/Kconfig | 8 ++ drivers/usb/typec/tcpm/Makefile | 1 + drivers/usb/typec/tcpm/tcpci_mt6360.c | 212 ++++++++++++++++++++++++++++++++++ 3 files changed, 221 insertions(+) create mode 100644 drivers/usb/typec/tcpm/tcpci_mt6360.c diff --git a/drivers/usb/typec/tcpm/Kconfig b/drivers/usb/typec/tcpm/Kconfig index fa3f393..58a64e1 100644 --- a/drivers/usb/typec/tcpm/Kconfig +++ b/drivers/usb/typec/tcpm/Kconfig @@ -27,6 +27,14 @@ config TYPEC_RT1711H Type-C Port Controller Manager to provide USB PD and USB Type-C functionalities. +config TYPEC_MT6360 + tristate "Mediatek MT6360 Type-C driver" + depends on MFD_MT6360 + help + Mediatek MT6360 is a multi-functional IC that includes + USB Type-C. It works with Type-C Port Controller Manager + to provide USB PD and USB Type-C functionalities. + endif # TYPEC_TCPCI config TYPEC_FUSB302 diff --git a/drivers/usb/typec/tcpm/Makefile b/drivers/usb/typec/tcpm/Makefile index a5ff6c8..7592ccb 100644 --- a/drivers/usb/typec/tcpm/Makefile +++ b/drivers/usb/typec/tcpm/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_TYPEC_WCOVE) += typec_wcove.o typec_wcove-y := wcove.o obj-$(CONFIG_TYPEC_TCPCI) += tcpci.o obj-$(CONFIG_TYPEC_RT1711H) += tcpci_rt1711h.o +obj-$(CONFIG_TYPEC_MT6360) += tcpci_mt6360.o diff --git a/drivers/usb/typec/tcpm/tcpci_mt6360.c b/drivers/usb/typec/tcpm/tcpci_mt6360.c new file mode 100644 index 00000000..6a28193 --- /dev/null +++ b/drivers/usb/typec/tcpm/tcpci_mt6360.c @@ -0,0 +1,212 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright (C) 2020 MediaTek Inc. +// +// Author: ChiYuan Huang + +#include +#include +#include +#include +#include +#include +#include + +#include "tcpci.h" + +#define MT6360_REG_VCONNCTRL1 0x8C +#define MT6360_REG_MODECTRL2 0x8F +#define MT6360_REG_SWRESET 0xA0 +#define MT6360_REG_DEBCTRL1 0xA1 +#define MT6360_REG_DRPCTRL1 0xA2 +#define MT6360_REG_DRPCTRL2 0xA3 +#define MT6360_REG_I2CTORST 0xBF +#define MT6360_REG_RXCTRL2 0xCF +#define MT6360_REG_CTDCTRL2 0xEC + +/* MT6360_REG_VCONNCTRL1 */ +#define MT6360_VCONNCL_ENABLE BIT(0) +/* MT6360_REG_RXCTRL2 */ +#define MT6360_OPEN40M_ENABLE BIT(7) +/* MT6360_REG_CTDCTRL2 */ +#define MT6360_RPONESHOT_ENABLE BIT(6) + +struct mt6360_tcpc_info { + struct tcpci_data tdata; + struct tcpci *tcpci; + struct device *dev; + int irq; +}; + +static inline int mt6360_tcpc_read16(struct regmap *regmap, + unsigned int reg, u16 *val) +{ + return regmap_raw_read(regmap, reg, val, sizeof(u16)); +} + +static inline int mt6360_tcpc_write16(struct regmap *regmap, + unsigned int reg, u16 val) +{ + return regmap_raw_write(regmap, reg, &val, sizeof(u16)); +} + +static int mt6360_tcpc_init(struct tcpci *tcpci, struct tcpci_data *tdata) +{ + struct regmap *regmap = tdata->regmap; + int ret; + + ret = regmap_write(regmap, MT6360_REG_SWRESET, 0x01); + if (ret) + return ret; + + /* after reset command, wait 1~2ms to wait IC action */ + usleep_range(1000, 2000); + + /* write all alert to masked */ + ret = mt6360_tcpc_write16(regmap, TCPC_ALERT_MASK, 0); + if (ret) + return ret; + + /* config I2C timeout reset enable , and timeout to 200ms */ + ret = regmap_write(regmap, MT6360_REG_I2CTORST, 0x8F); + if (ret) + return ret; + + /* config CC Detect Debounce : 26.7*val us */ + ret = regmap_write(regmap, MT6360_REG_DEBCTRL1, 0x10); + if (ret) + return ret; + + /* DRP Toggle Cycle : 51.2 + 6.4*val ms */ + ret = regmap_write(regmap, MT6360_REG_DRPCTRL1, 4); + if (ret) + return ret; + + /* DRP Duyt Ctrl : dcSRC: /1024 */ + ret = mt6360_tcpc_write16(regmap, MT6360_REG_DRPCTRL2, 330); + if (ret) + return ret; + + /* Enable VCONN Current Limit function */ + ret = regmap_update_bits(regmap, MT6360_REG_VCONNCTRL1, MT6360_VCONNCL_ENABLE, + MT6360_VCONNCL_ENABLE); + if (ret) + return ret; + + /* Enable cc open 40ms when pmic send vsysuv signal */ + ret = regmap_update_bits(regmap, MT6360_REG_RXCTRL2, MT6360_OPEN40M_ENABLE, + MT6360_OPEN40M_ENABLE); + if (ret) + return ret; + + /* Enable Rpdet oneshot detection */ + ret = regmap_update_bits(regmap, MT6360_REG_CTDCTRL2, MT6360_RPONESHOT_ENABLE, + MT6360_RPONESHOT_ENABLE); + if (ret) + return ret; + + /* Set shipping mode off, AUTOIDLE on */ + return regmap_write(regmap, MT6360_REG_MODECTRL2, 0x7A); +} + +static irqreturn_t mt6360_irq(int irq, void *dev_id) +{ + struct mt6360_tcpc_info *mti = dev_id; + + return tcpci_irq(mti->tcpci); +} + +static int mt6360_tcpc_probe(struct platform_device *pdev) +{ + struct mt6360_tcpc_info *mti; + int ret; + + mti = devm_kzalloc(&pdev->dev, sizeof(*mti), GFP_KERNEL); + if (!mti) + return -ENOMEM; + + mti->dev = &pdev->dev; + + mti->tdata.regmap = dev_get_regmap(pdev->dev.parent, NULL); + if (!mti->tdata.regmap) { + dev_err(&pdev->dev, "Failed to get parent regmap\n"); + return -ENODEV; + } + + mti->irq = platform_get_irq_byname(pdev, "PD_IRQB"); + if (mti->irq < 0) { + dev_err(&pdev->dev, "Failed to get PD_IRQB irq\n"); + return mti->irq; + } + + mti->tdata.init = mt6360_tcpc_init; + mti->tcpci = tcpci_register_port(&pdev->dev, &mti->tdata); + if (IS_ERR_OR_NULL(mti->tcpci)) { + dev_err(&pdev->dev, "Failed to register tcpci port\n"); + return PTR_ERR(mti->tcpci); + } + + ret = devm_request_threaded_irq(mti->dev, mti->irq, NULL, mt6360_irq, IRQF_ONESHOT, + dev_name(&pdev->dev), mti); + if (ret) { + dev_err(mti->dev, "Failed to register irq\n"); + tcpci_unregister_port(mti->tcpci); + return ret; + } + + device_init_wakeup(&pdev->dev, true); + platform_set_drvdata(pdev, mti); + + return 0; +} + +static int mt6360_tcpc_remove(struct platform_device *pdev) +{ + struct mt6360_tcpc_info *mti = platform_get_drvdata(pdev); + + tcpci_unregister_port(mti->tcpci); + return 0; +} + +static int __maybe_unused mt6360_tcpc_suspend(struct device *dev) +{ + struct mt6360_tcpc_info *mti = dev_get_drvdata(dev); + + if (device_may_wakeup(dev)) + enable_irq_wake(mti->irq); + + return 0; +} + +static int __maybe_unused mt6360_tcpc_resume(struct device *dev) +{ + struct mt6360_tcpc_info *mti = dev_get_drvdata(dev); + + if (device_may_wakeup(dev)) + disable_irq_wake(mti->irq); + + return 0; +} + +static SIMPLE_DEV_PM_OPS(mt6360_tcpc_pm_ops, mt6360_tcpc_suspend, mt6360_tcpc_resume); + +static const struct of_device_id __maybe_unused mt6360_tcpc_of_id[] = { + { .compatible = "mediatek,mt6360-tcpc", }, + {}, +}; +MODULE_DEVICE_TABLE(of, mt6360_tcpc_of_id); + +static struct platform_driver mt6360_tcpc_driver = { + .driver = { + .name = "mt6360-tcpc", + .pm = &mt6360_tcpc_pm_ops, + .of_match_table = mt6360_tcpc_of_id, + }, + .probe = mt6360_tcpc_probe, + .remove = mt6360_tcpc_remove, +}; +module_platform_driver(mt6360_tcpc_driver); + +MODULE_AUTHOR("ChiYuan Huang "); +MODULE_DESCRIPTION("MT6360 USB Type-C Port Controller Interface Driver"); +MODULE_LICENSE("GPL v2"); From patchwork Thu Aug 27 03:25:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ChiYuan Huang X-Patchwork-Id: 11739871 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A026739 for ; Thu, 27 Aug 2020 03:26:15 +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 52AFE2078A for ; Thu, 27 Aug 2020 03:26:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kyMnqfFK"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CjjYCWWo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52AFE2078A 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+patchwork-linux-mediatek=patchwork.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=F8j4sC2OyvHBZS87hQV4/YRa/8AYeiM4wlvH/4A6QOc=; b=kyMnqfFKWKRN5kQGCNIvAhZbLM 475NPXGcJQDM+djNOZkA6Ls3FS7Zegmr+JQ5ovZgI6WLkwgKW8TwdZcjqQ4E+5W1kj2Q7rd8pwUCg 2Nq8C5sMh/4J2NLyZn/QFgV85TUkDi7X5N7UDJGCRnviAt4QYG5LLevU+wfEAqPxCxX5Xd7FTnGNy oz+iHvAEwz21oK8IEVJT2g6b/QvgqXQt+VjMHfEIsaRYRvxAyoE25keZXovEKEzMMF8+3nMLCghTi H1fUFhoyTCxg1ONptqB1K3cnVRYQhcDNnGc6x6alqh0Ny1Y90amMXTV/GmFAMSJGCs5hrj3YK06Qa hn3Flm0Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kB8YH-000396-39; Thu, 27 Aug 2020 03:26:13 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kB8YB-00037d-7r; Thu, 27 Aug 2020 03:26:08 +0000 Received: by mail-pg1-x543.google.com with SMTP id m34so2317643pgl.11; Wed, 26 Aug 2020 20:26:06 -0700 (PDT) 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=9BLb5SG/442AGlteVEU+VMTqxtoAM2EGD3L4sUWx4Zo=; b=CjjYCWWooFK0EHgHSecto1ocZEzgllCZ6bs5diPkpf5KyxPD/2P8ma/JoTJrC/I9kg IrZ8+T8EjNNw5L4HIuw8fdnnF7fHtKv7eleB9/ryEWChUMheH7av2zhsM4pVpbOvUzB9 bndcr9i7J6qk72NPvxT5Pj0VuVCc6JwM47s8q06EI5Xl+EMY7qG4QjzCQbDl6CJYyAFN hCueWm2YbBNWGs19NIorW/WjzSeDn44oax4oZ1gBtppkmpCNYSnseFKrirnw7Nu5EnOO WRvdQZP5BAg9jjMrW+LZh8am0Qh/PFgLe+Ba3L50V+L2q5iIkRCJyatZPqi3T5mi5w1D axpw== 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=9BLb5SG/442AGlteVEU+VMTqxtoAM2EGD3L4sUWx4Zo=; b=H0Vgv5QZ8uJaR3a3jEbi1NRkhFXuwM2z9TMuotGo8drcp8gh94qvMPZ4UHRQCdjg2I 4jcKz9uXTw6Ld9f37Tv13wWIG2Kkg/pARvfPwE2QUuglJyNqppzaH2Dsxi3MuShwv5Uc 2NKStbVsLywOXDEoefQVOat2mk9S4sx1YBX0sRd4EYPx0LG6VXag1vRRLrTe0yb6NESU TXxz4SxQqHW0LTShe3cSN6IjwKdAMhGOU6I3ziyvS6R9HqVBc9HDXGkdIsR6xyvEt81O QlQ6p6s301Ii+esElKKKdKNcyb8hbUxLKVptQT48uzdSdR7pjYMvrDdamStyktUFh2dA ZP9g== X-Gm-Message-State: AOAM532ccGSpEU+/Fl8s3PjuinZkbgsKXNeQ8vlUmYnj1LL5JRCwzPMt uEKyh2sF8EckmRxnUO1V33o= X-Google-Smtp-Source: ABdhPJxlJIglwtNYpMjmJH4S3OB5DwjsuyaIuykvQ+ZOQ/mqrYP2KbU2xeXAzeBV0qrWumABBG0xHw== X-Received: by 2002:a63:4955:: with SMTP id y21mr12686551pgk.180.1598498764661; Wed, 26 Aug 2020 20:26:04 -0700 (PDT) Received: from localhost.localdomain ([2402:7500:57b:156e:1129:dc1b:b8d8:6430]) by smtp.gmail.com with ESMTPSA id 70sm676982pfu.107.2020.08.26.20.25.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2020 20:26:03 -0700 (PDT) From: cy_huang To: gregkh@linuxfoundation.org, robh+dt@kernel.org, matthias.bgg@gmail.com, linux@roeck-us.net, heikki.krogerus@linux.intel.com Subject: [PATCH v2 2/3] usb typec: mt6360: Add MT6360 Type-C DT binding documentation Date: Thu, 27 Aug 2020 11:25:31 +0800 Message-Id: <1598498732-25194-2-git-send-email-u0084500@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598498732-25194-1-git-send-email-u0084500@gmail.com> References: <1598498732-25194-1-git-send-email-u0084500@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200826_232607_626068_969DB08C X-CRM114-Status: GOOD ( 15.22 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:543 listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [u0084500[at]gmail.com] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [u0084500[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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, 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+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org From: ChiYuan Huang Add a devicetree binding documentation for the MT6360 Type-C driver. Signed-off-by: ChiYuan Huang --- .../bindings/usb/mediatek,mt6360-tcpc.yaml | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/mediatek,mt6360-tcpc.yaml diff --git a/Documentation/devicetree/bindings/usb/mediatek,mt6360-tcpc.yaml b/Documentation/devicetree/bindings/usb/mediatek,mt6360-tcpc.yaml new file mode 100644 index 00000000..9e8ab0d --- /dev/null +++ b/Documentation/devicetree/bindings/usb/mediatek,mt6360-tcpc.yaml @@ -0,0 +1,73 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/usb/mediatek,mt6360-tcpc.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Mediatek MT6360 Type-C Port Switch and Power Delivery controller DT bindings + +maintainers: + - ChiYuan Huang + +description: | + Mediatek MT6360 is a multi-functional device. It integrates charger, ADC, flash, RGB indicators, + regulators (BUCKs/LDOs), and TypeC Port Switch with Power Delivery controller. + This document only describes MT6360 Type-C Port Switch and Power Delivery controller. + +properties: + compatible: + enum: + - mediatek,mt6360-tcpc + + interrupts-extended: + maxItems: 1 + + interrupt-names: + items: + - const: PD_IRQB + +patternProperties: + "connector": + type: object + $ref: ../connector/usb-connector.yaml# + description: + Properties for usb c connector. + +additionalProperties: false + +required: + - compatible + - interrupts-extended + - interrupt-names + +examples: + - | + #include + #include + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + mt6360@34 { + compatible = "mediatek,mt6360"; + reg = <0x34>; + + tcpc { + compatible = "mediatek,mt6360-tcpc"; + interrupts-extended = <&gpio26 3 IRQ_TYPE_LEVEL_LOW>; + interrupt-names = "PD_IRQB"; + + connector { + compatible = "usb-c-connector"; + label = "USB-C"; + data-role = "dual"; + power-role = "dual"; + try-power-role = "sink"; + source-pdos = ; + sink-pdos = ; + op-sink-microwatt = <10000000>; + }; + }; + }; + }; +... From patchwork Thu Aug 27 03:25:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ChiYuan Huang X-Patchwork-Id: 11739879 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 390B11751 for ; Thu, 27 Aug 2020 03:26:25 +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 12DF52078A for ; Thu, 27 Aug 2020 03:26:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="EyiGTifk"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="juyCGc0D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 12DF52078A 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+patchwork-linux-mediatek=patchwork.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=DfHsQp/s2SWdhfugM6D8oqfyDa0N5CC01N8u3hR+ZJI=; b=EyiGTifkDFRqgkyMCgX0+0RhWd NXvxv3fJ9ulqf6BlafufyJ2axS+mG8bEpaJhAF5gYWLPSpWSsH0uZHt4wmw5+h1CoPg0R6QAGR7B3 ENqw0oUrPBrnjL9ymFi0pAi+4tqrHs5W3MSHYKxZeoHf5MGXFNb4BZvAbItgFRo6y/SVz4vh6jHmz fd/KKooQRhTcvCGFkH+vGDIKMM67QMcI2ObsSrWPnjoKzkpDUtfy+Z8Az8q1ns2dS4sQgdPERaeXO Ln6AFS8P+T3wGgJio6ym8r/zdsmdwngiLC8niBcM7E08kdLmVvgxbq2DlTnqn/Ff9W7XoLIi01usW CYdRXSxw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kB8YQ-0003Cg-W3; Thu, 27 Aug 2020 03:26:23 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kB8YN-0003AR-5v; Thu, 27 Aug 2020 03:26:19 +0000 Received: by mail-pg1-x542.google.com with SMTP id g29so1320260pgl.2; Wed, 26 Aug 2020 20:26:18 -0700 (PDT) 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=rN37qI20ECUBatR6H4A3g3beWRHeq6Mi+Lp9BztZsHQ=; b=juyCGc0DIHQSjOjHsrh+qOzPev0piOd8Bz8V5NomMrKpRtgz1hEkev8rk95Rfosf++ lnk73HOq4CZaRbiG0/oPUOppYKjNDDv+GrKz5yob2Q+JLlv/uQhRgO5ugFKMGUCEMAJO HQoMI3sVkJ+892Dgoc35biNla/wrHNjbvXHmSuHdtOgUlE6ARLsD4FsGP0TfpePwMpoS iinEOqJzEcZh3fQje53unSjcBpdNpYqMREd+jzPdufjB4ixU9P6StstghAsr9tlHzPMi ZDvtBdi9SR1ibwo1pQDX8rWLe4aSnHgcfYebs+L6FpQM1Vj5hvbYYY1mQ9Zx6ayBfHA4 yl+w== 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=rN37qI20ECUBatR6H4A3g3beWRHeq6Mi+Lp9BztZsHQ=; b=INMhgRdtsmG41UfmhxueI5YeEkHzg4tmbUaCdZwgEDAwbMJTG+GXrn7zMsPybkFNi7 M/cYgbEuFN23wH+MYLUiGKcG4aunppU1iLCKpp6KUz97omPCWmOQykw4FFmStU0YfUA8 kiKd+c0PfQEBuxHeJ/9SRX+3J81pe8n9uH7MR3lFGNidm065CVTJnkRwLWbvUZw2Ftum dz4oJCWVxBNxWwJ0GEnfu105J/hcgEmFN6l2gxxzzk5sDveBLk1+OMKE6DzZUAQGeGf8 eu0kFt0Ie5DxIOKKLVmFz2a+QRoLFmmEwdGkfcLRuebLByEd9qv4S84PjSPJp/YtpEDf rbcQ== X-Gm-Message-State: AOAM531qwUw7V4fjYzA/An+S7D+7EluoWge92xcssKDTmRy2q+Zd6u5w n/lkTiCyR5PQvDQv0aOs1LA= X-Google-Smtp-Source: ABdhPJxs3SdM7Lc3+cmlB678u24GpPwR5yvBajty/DF5b6W58gTKmaqbA8z69x1z9NNVbSOoHjIFhQ== X-Received: by 2002:a17:902:b589:: with SMTP id a9mr14117797pls.98.1598498776792; Wed, 26 Aug 2020 20:26:16 -0700 (PDT) Received: from localhost.localdomain ([2402:7500:57b:156e:1129:dc1b:b8d8:6430]) by smtp.gmail.com with ESMTPSA id 70sm676982pfu.107.2020.08.26.20.26.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2020 20:26:16 -0700 (PDT) From: cy_huang To: gregkh@linuxfoundation.org, robh+dt@kernel.org, matthias.bgg@gmail.com, linux@roeck-us.net, heikki.krogerus@linux.intel.com Subject: [PATCH v2 3/3] usb typec: mt6360: Prevent the race condition during module remove Date: Thu, 27 Aug 2020 11:25:32 +0800 Message-Id: <1598498732-25194-3-git-send-email-u0084500@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598498732-25194-1-git-send-email-u0084500@gmail.com> References: <1598498732-25194-1-git-send-email-u0084500@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200826_232619_247019_4D711DCE X-CRM114-Status: GOOD ( 13.21 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:542 listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [u0084500[at]gmail.com] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [u0084500[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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, 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+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org From: ChiYuan Huang Prevent the race condition from interrupt and tcpci port unregister during module remove. Signed-off-by: ChiYuan Huang --- drivers/usb/typec/tcpm/tcpci_mt6360.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/typec/tcpm/tcpci_mt6360.c b/drivers/usb/typec/tcpm/tcpci_mt6360.c index 6a28193..a381b5d 100644 --- a/drivers/usb/typec/tcpm/tcpci_mt6360.c +++ b/drivers/usb/typec/tcpm/tcpci_mt6360.c @@ -164,6 +164,7 @@ static int mt6360_tcpc_remove(struct platform_device *pdev) { struct mt6360_tcpc_info *mti = platform_get_drvdata(pdev); + disable_irq(mti->irq); tcpci_unregister_port(mti->tcpci); return 0; }