From patchwork Thu Aug 27 11:18:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ChiYuan Huang X-Patchwork-Id: 11740559 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 0D23314F6 for ; Thu, 27 Aug 2020 11:19:41 +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 C720F22B40 for ; Thu, 27 Aug 2020 11:19:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fLlns7dq"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="njwip9Ot" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C720F22B40 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-arm-kernel-bounces+patchwork-linux-arm=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=BNK8Ud6+L1aUD3EPtjXAs6CDGrALO9HpgPp4UZJ60Q4=; b=fLlns7dqp80+9jRO656k5FYZoW dCuVAopdJqUonA9Gkfu4Rrh20lGF3QfdW6Xo1HATwAMfBVkEP2aQVq7Kfr+xAeZEDXtttg5faAKkS VHJw0yRbQMjYRANPfLFP6zRTD8sQLggdCRF29gasd21qHyK6Ipimp/6Rz6Mts+cpaNAPtdAnH5i/z hNDyypOPijy/IoaNJi0a1Qd3Pt0s3JW2cezWDCF51vQomcf6LHFrMoaFIpfvY+7zb+B0q/4+FptV9 XIkyBOxAPh9Ua/8hn8my2V3De41Gaga1BTjs0L+uznw+1S50bsFAeQqD0R1E10gVpvE3/k8GnNGLB eedUHdSw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBFw9-0004nI-9V; Thu, 27 Aug 2020 11:19:21 +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 1kBFw6-0004mm-Mq; Thu, 27 Aug 2020 11:19:19 +0000 Received: by mail-pg1-x542.google.com with SMTP id l191so3126952pgd.5; Thu, 27 Aug 2020 04:19:16 -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=ezC+r3YwpKVy+03QFUWjpev8y2+TmsNBfqy2y9Sv7nA=; b=njwip9OteVbnU53kYGdWeEMhJ/hlw2I6O8fXTEhcJRokjrdqzvTUnJLfbUvZ6wTpQs SdO+UI2tbRBZqAoIuGTl8tVrYtWFoEqDBOdUOxcmY+wScfxstyXVXiX9mn3YMEyHC0te eeY1gp9Et/wd27x2VTOfC3qJHrfKtBUYMBCsykzOgGoOGC71lkJZYM2JAa2Mq0UnhF9c r5OFttSiWMrC2J1cTo1qbntPShmRwzdt8hcTzlliJe5yTdu/s1kUgkfjdfBPyy9WhW6k pqRZUEEby8XKlMBqbdWFgtIEBrO6JL522uJ0suI26ZMJBjD12j2qxPXJrfrMiVrbPf/s TK+g== 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=ezC+r3YwpKVy+03QFUWjpev8y2+TmsNBfqy2y9Sv7nA=; b=MNI7hNPgIWIKknuyVP7CU7QU6kq68voUecg/2DVgWhOEsDAjsKND26lGeOKzgp55E9 mTNe9HochmuYVOcwtOETH0iy3yYsOkpLTymj7QTuZwLHGhjwG0+tPjgoQd8AM1WSGShQ FWD5Cy/7xpkmiaKeHfbGbbbDECy3yZLpCR4N7bVoNIxfzBPYTd/S551dr8FhEkC/vcvl R8ZegbFEiemKxoS3UswMy/RP0zs9FAUYnSqVhgFBVkKtoC14GMpE/Eq3PY4+KM0NeZFV fdgMgC8aEldJ50fFdcYYl0Ga+ZjwsRqYkqhyakKGVc181K8HSvqVbVdhhi5xttbhdcp8 SZsQ== X-Gm-Message-State: AOAM533H0KSoJZHMkZv1mfCadykXQjh3Tzh+l8uOuHmy3Zni4eR47NZ2 7/iCttcD6oMPR1iBFHNW//U= X-Google-Smtp-Source: ABdhPJz1riIoixopfph84TM+/NFmzd1shmOghN8yKei0D1odJDN1b2CsleH5KGm9ES2tc5eTvw+2Lw== X-Received: by 2002:aa7:9219:: with SMTP id 25mr16247625pfo.4.1598527154547; Thu, 27 Aug 2020 04:19:14 -0700 (PDT) Received: from localhost.localdomain ([2402:7500:46b:c678:1129:dc1b:b8d8:6430]) by smtp.gmail.com with ESMTPSA id h64sm2411609pfe.201.2020.08.27.04.19.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Aug 2020 04:19:13 -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 v3 1/3] usb typec: mt6360: Add support for mt6360 Type-C driver Date: Thu, 27 Aug 2020 19:18:55 +0800 Message-Id: <1598527137-6915-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-20200827_071918_784499_7C20AA01 X-CRM114-Status: GOOD ( 24.86 ) 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.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [u0084500[at]gmail.com] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=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. v1 to v2 1. Add fix to Prevent the race condition from interrupt and tcpci port unregister during module remove. v2 to v3 1. Change comment style for the head of source code. 2. No need to print error for platform_get_irq_byname. 3. Fix tcpci_register_port check from IS_ERR_OR_NULL to IS_ERR. 4. Rename driver/Kconfig/Makefile form mt6360 to mt636x. 5. Rename DT binding documents from mt6360 to mt636x. 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..f1bd9e0 --- /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) + return mti->irq; + + mti->tdata.init = mt6360_tcpc_init; + mti->tcpci = tcpci_register_port(&pdev->dev, &mti->tdata); + if (IS_ERR(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); + + disable_irq(mti->irq); + 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 11:18:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ChiYuan Huang X-Patchwork-Id: 11740561 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 41B38913 for ; Thu, 27 Aug 2020 11:19:41 +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 0DC4F22CF7 for ; Thu, 27 Aug 2020 11:19:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sWFZebSl"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iP5GfH4B" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0DC4F22CF7 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-arm-kernel-bounces+patchwork-linux-arm=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=72u8CGiGk2pBvgfGi3MTdIB0rRXSTqVa5aCtz96pH+0=; b=sWFZebSlIOKLOH35gqMYf4whE8 SxwNajRo37B2OA6QeDJMogdyvjQQgOX/92TEmVgxKNP6rm6/6RJYxMOwgpraxSmBqyQq7KnxPthRa jZN3QlwqQFCaMa2WfDWSmMXQt5fiY7LfPTYcLFAiWyG6OPT5jRthkoEsM/cwSgJpPPdCk2tgPx7Ea ldv66M+grgs/jUKuTsiB48R1oSouhYWwMaedgSsR2QfNwv55+yu4C/SCacGazbAhk6N54ccdvMj86 0ou3UCiKJJxCgGDHe9yttSSMGpiOa4nE23ODqGF7Zo5YnEpX0telRYrgap1qh9cLVFeWAp0NiVi9L tZfYPA9Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBFwF-0004oa-8j; Thu, 27 Aug 2020 11:19:27 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBFwB-0004nW-6c; Thu, 27 Aug 2020 11:19:24 +0000 Received: by mail-pg1-x544.google.com with SMTP id g29so2108034pgl.2; Thu, 27 Aug 2020 04:19:22 -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=4AB77AAFgWkjOgI8rZNbI2/uf+Pa/WR+XiSoAO41hDU=; b=iP5GfH4BYcFn1X7+ZaLSUUP8OFJgPiJ0YXqtbyak2fY+O+dRk8aIeqwW2sg2YIRtbl 4561u6EklbPcqjXB73lkcd2pQPLAD3CpN/1lcFAegHNijNA6O8hmgc/99UPk/y3c3AZU W1qTMcQELkRJHqmgWPBYeW1a6UTbLXPCoDAyZ91PMUaDIX9WvdYuKDixpDbwlIoN/dBS baEwyQUGHCgraS23lIENCgkLA0/MJId5x4FySBjmpZJ+7iPPADXbOMdygwgwFStGaHQV 5FzIhc84ICzEuV8M8zoBBZDl7GOE9sJIupMYO8i7/Uotr1/3YJHWYIGGjRqpRCE20hUO dU5Q== 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=4AB77AAFgWkjOgI8rZNbI2/uf+Pa/WR+XiSoAO41hDU=; b=qWaixE+ZER0rVCJWHfODQrWZw/33m7NlBvNzx8QvkSAT3OOYydzBdKdQk4Scs0Dodd cohsBiSC9/u/9l8YXLzNrQg0Z4f6bgYl5RdowQilIXFpmaF8IZAX3IsdXgHkwiK0gJ24 pF/cVdGW5tYwIk0dJ5TtmxVwnIOtxuYHoPUltEd/kv1becq7+ONckGvr13l90EW4mgU8 pWHN7P+X7BKBJtL6KeTLCJb9LvTEi5jvPMe1udGMkr4CDuG3FlKo6VlEatYsM1KYhq2i 5CannXlLLlhwnint1rFKm1I4MK/fxSTigRL2xsnF0Jji1NGUfDm4OsnD1u1h6eVNyiZs qiOQ== X-Gm-Message-State: AOAM532OBnIeKlH059XpEz4OcLNBbahe/I6oN4zrdpdAYzHCcfXneyeM RxuDxsJDJWhDbHtbIIupqSw5MCSOmyQPIg== X-Google-Smtp-Source: ABdhPJyS8KU9UqgkcpP9lUUeYiVT5tWm/4YdrdCIIWqlJ0PCb4r7qs1JbjY/8l3wZGSH7qp0kRqejw== X-Received: by 2002:a17:902:7045:: with SMTP id h5mr5664144plt.4.1598527160923; Thu, 27 Aug 2020 04:19:20 -0700 (PDT) Received: from localhost.localdomain ([2402:7500:46b:c678:1129:dc1b:b8d8:6430]) by smtp.gmail.com with ESMTPSA id h64sm2411609pfe.201.2020.08.27.04.19.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Aug 2020 04:19:20 -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 v3 2/3] usb typec: mt6360: Rename driver/Kconfig/Makefile from mt6360 to mt636x Date: Thu, 27 Aug 2020 19:18:56 +0800 Message-Id: <1598527137-6915-2-git-send-email-u0084500@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598527137-6915-1-git-send-email-u0084500@gmail.com> References: <1598527137-6915-1-git-send-email-u0084500@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200827_071923_332711_5550400C X-CRM114-Status: GOOD ( 26.62 ) 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:544 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [u0084500[at]gmail.com] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: ChiYuan Huang 1. Rename file form tcpci_mt6360.c to tcpci_mt636x.c 2. Rename internal function from mt6360 to mt636x, except the register definition. 3. Change Kconfig/Makefile from MT6360 to MT636X. Signed-off-by: ChiYuan Huang --- drivers/usb/typec/tcpm/Kconfig | 6 +- drivers/usb/typec/tcpm/Makefile | 2 +- drivers/usb/typec/tcpm/tcpci_mt6360.c | 212 ---------------------------------- drivers/usb/typec/tcpm/tcpci_mt636x.c | 212 ++++++++++++++++++++++++++++++++++ 4 files changed, 216 insertions(+), 216 deletions(-) delete mode 100644 drivers/usb/typec/tcpm/tcpci_mt6360.c create mode 100644 drivers/usb/typec/tcpm/tcpci_mt636x.c diff --git a/drivers/usb/typec/tcpm/Kconfig b/drivers/usb/typec/tcpm/Kconfig index 58a64e1..c96141f 100644 --- a/drivers/usb/typec/tcpm/Kconfig +++ b/drivers/usb/typec/tcpm/Kconfig @@ -27,11 +27,11 @@ 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" +config TYPEC_MT636X + tristate "Mediatek MT636x Type-C driver" depends on MFD_MT6360 help - Mediatek MT6360 is a multi-functional IC that includes + Mediatek MT636x 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. diff --git a/drivers/usb/typec/tcpm/Makefile b/drivers/usb/typec/tcpm/Makefile index 7592ccb..ccd7923 100644 --- a/drivers/usb/typec/tcpm/Makefile +++ b/drivers/usb/typec/tcpm/Makefile @@ -5,4 +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 +obj-$(CONFIG_TYPEC_MT636X) += tcpci_mt636x.o diff --git a/drivers/usb/typec/tcpm/tcpci_mt6360.c b/drivers/usb/typec/tcpm/tcpci_mt6360.c deleted file mode 100644 index f1bd9e0..00000000 --- a/drivers/usb/typec/tcpm/tcpci_mt6360.c +++ /dev/null @@ -1,212 +0,0 @@ -// 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) - return mti->irq; - - mti->tdata.init = mt6360_tcpc_init; - mti->tcpci = tcpci_register_port(&pdev->dev, &mti->tdata); - if (IS_ERR(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); - - disable_irq(mti->irq); - 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"); diff --git a/drivers/usb/typec/tcpm/tcpci_mt636x.c b/drivers/usb/typec/tcpm/tcpci_mt636x.c new file mode 100644 index 00000000..ca0f743 --- /dev/null +++ b/drivers/usb/typec/tcpm/tcpci_mt636x.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 mt636x_tcpc_info { + struct tcpci_data tdata; + struct tcpci *tcpci; + struct device *dev; + int irq; +}; + +static inline int mt636x_tcpc_read16(struct regmap *regmap, + unsigned int reg, u16 *val) +{ + return regmap_raw_read(regmap, reg, val, sizeof(u16)); +} + +static inline int mt636x_tcpc_write16(struct regmap *regmap, + unsigned int reg, u16 val) +{ + return regmap_raw_write(regmap, reg, &val, sizeof(u16)); +} + +static int mt636x_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 = mt636x_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 = mt636x_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 mt636x_irq(int irq, void *dev_id) +{ + struct mt636x_tcpc_info *mti = dev_id; + + return tcpci_irq(mti->tcpci); +} + +static int mt636x_tcpc_probe(struct platform_device *pdev) +{ + struct mt636x_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) + return mti->irq; + + mti->tdata.init = mt636x_tcpc_init; + mti->tcpci = tcpci_register_port(&pdev->dev, &mti->tdata); + if (IS_ERR(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, mt636x_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 mt636x_tcpc_remove(struct platform_device *pdev) +{ + struct mt636x_tcpc_info *mti = platform_get_drvdata(pdev); + + disable_irq(mti->irq); + tcpci_unregister_port(mti->tcpci); + return 0; +} + +static int __maybe_unused mt636x_tcpc_suspend(struct device *dev) +{ + struct mt636x_tcpc_info *mti = dev_get_drvdata(dev); + + if (device_may_wakeup(dev)) + enable_irq_wake(mti->irq); + + return 0; +} + +static int __maybe_unused mt636x_tcpc_resume(struct device *dev) +{ + struct mt636x_tcpc_info *mti = dev_get_drvdata(dev); + + if (device_may_wakeup(dev)) + disable_irq_wake(mti->irq); + + return 0; +} + +static SIMPLE_DEV_PM_OPS(mt636x_tcpc_pm_ops, mt636x_tcpc_suspend, mt636x_tcpc_resume); + +static const struct of_device_id __maybe_unused mt636x_tcpc_of_id[] = { + { .compatible = "mediatek,mt6360-tcpc", }, + {}, +}; +MODULE_DEVICE_TABLE(of, mt636x_tcpc_of_id); + +static struct platform_driver mt636x_tcpc_driver = { + .driver = { + .name = "mt636x-tcpc", + .pm = &mt636x_tcpc_pm_ops, + .of_match_table = mt636x_tcpc_of_id, + }, + .probe = mt636x_tcpc_probe, + .remove = mt636x_tcpc_remove, +}; +module_platform_driver(mt636x_tcpc_driver); + +MODULE_AUTHOR("ChiYuan Huang "); +MODULE_DESCRIPTION("MT636x USB Type-C Port Controller Interface Driver"); +MODULE_LICENSE("GPL v2"); From patchwork Thu Aug 27 11:18:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ChiYuan Huang X-Patchwork-Id: 11740563 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 D7DF614F6 for ; Thu, 27 Aug 2020 11:19:44 +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 AD99522B40 for ; Thu, 27 Aug 2020 11:19:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="FKA/iYbR"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AGJQu3Tb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD99522B40 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-arm-kernel-bounces+patchwork-linux-arm=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=iA51cCcyOUPzZBvoQl3SPoVgg6NvBPAqyX8366jV0X4=; b=FKA/iYbRyXMQVtb+9zY3+QBQaR 8sYgHuFlEYUUVUpLHJ/BkuT/5Kk2v8a/YPWEtRCbB2lWohI6bSseWp0TO0I2SJMYAjh2kWxFdSC2H AnlPljm7MGtbxO3Pzu6hcx5lgl9j7nBpiQFhBSobDcUq+ynVPoOkYxxel3vPPDAWLlg/dDOZIcYO6 lHPT7kMpT43bnWDYO4sJ/po+7UPzGVewXvzFO0NlNcOKMhW6hv0DeaNuhX93dLoHpfheypz59Ipq8 6XygB3K8QPtt66mSRCAXsI/cjd71EScPXuCXeG5Hb/oHYIgqMtZ25SLyGXQt44KCOaJAlvrnRujL8 3g4eR+qQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBFwM-0004qa-0i; Thu, 27 Aug 2020 11:19:34 +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 1kBFwH-0004oQ-4X; Thu, 27 Aug 2020 11:19:30 +0000 Received: by mail-pf1-x443.google.com with SMTP id m8so3245562pfh.3; Thu, 27 Aug 2020 04:19:26 -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=A0zpPcYJ1vUHmpV3rQXkBSiNDDj5ItcpLqLQV/ENULo=; b=AGJQu3TbjrCnuhhqkqS7j1YaiFtASNUFy2jKDkkrMPsbG74tH+k2AvHvE3Wq3SFUFK il9cHaz+IFKfK0oQnZqC7GVn9uztwPz7XrF09MilOdo1c4uyLjnkPy7qHUZ328ce7Qim 4+rSz1G2nwDriX1NppIqikjH7CHPGsbDohBmB1EO+6vyFcyKtRI5zxP26bovtvOdIqPX vIbFygjdpZzEU/AUet9U27Ekk3eAOZKLaGdUCGl5qGiHktb/Tv1pflAza1wFPATgaMxC +HSEfAU4sPHHQqf4uqxRE8zCDQYE7VMtWATO6g7O3Mi2I6D18seH689L3mOrHGyERk9l t47w== 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=A0zpPcYJ1vUHmpV3rQXkBSiNDDj5ItcpLqLQV/ENULo=; b=Gh36RA2P8zGSeqS6LYWfS/6inB69h6JLU6XhXgH7L0xO+IYgL8/8rxlsR8gdiVljfd DRMO2Vy7dcEM5puHnPOiwIcNa65U6LwFPqV6xaCiXsOcLK1/iLm+64A1XHhNswjOdJVd YKyogP8wNFOm5p3kCrNictbOepg7/ORUGmdCMfrrA/OyTi5h+3MdpjC15v+K4SUEUVd4 m5ov3ucB8HBUorRH186ks/e/yh17ruWXumid7KZIa5HJj8pH12mVN7enPKuNMQuCOWW8 keXaTbMLQ01OKRqi/T2Di/HDFHj8R1WqWd68DJOr1GSAkOxuZZtY/Q+gEIBkXJJp2qfD k1XA== X-Gm-Message-State: AOAM530PjwDpWO6RkZagUomdCAp/S2H0eUNo+VOTLzppjomZhDL16gCA nBI58ppW7vg5NkVAuzGhylg= X-Google-Smtp-Source: ABdhPJx9BG4IH8NlwPLL49IRWs8UoqHlTHOcA3OYqMJkPAu5ZaZsoK54zswbbH4CKT3oBYuVYRl8QQ== X-Received: by 2002:a63:2d83:: with SMTP id t125mr13734429pgt.441.1598527165079; Thu, 27 Aug 2020 04:19:25 -0700 (PDT) Received: from localhost.localdomain ([2402:7500:46b:c678:1129:dc1b:b8d8:6430]) by smtp.gmail.com with ESMTPSA id h64sm2411609pfe.201.2020.08.27.04.19.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Aug 2020 04:19:24 -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 v3 3/3] usb typec: mt6360: Add MT6360 Type-C DT binding documentation Date: Thu, 27 Aug 2020 19:18:57 +0800 Message-Id: <1598527137-6915-3-git-send-email-u0084500@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598527137-6915-1-git-send-email-u0084500@gmail.com> References: <1598527137-6915-1-git-send-email-u0084500@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200827_071929_255506_080A4547 X-CRM114-Status: GOOD ( 16.19 ) 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.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [u0084500[at]gmail.com] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: ChiYuan Huang Add a devicetree binding documentation for the MT6360 Type-C driver. usb typec: mt6360: Rename DT binding doument from mt6360 to mt636x Change binding document file name from mt6360 to mt636xfor the future compatible. Also change internal description from mt6360 to mt636x. Signed-off-by: ChiYuan Huang --- .../bindings/usb/mediatek,mt636x-tcpc.yaml | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/mediatek,mt636x-tcpc.yaml diff --git a/Documentation/devicetree/bindings/usb/mediatek,mt636x-tcpc.yaml b/Documentation/devicetree/bindings/usb/mediatek,mt636x-tcpc.yaml new file mode 100644 index 00000000..e6d2b3d --- /dev/null +++ b/Documentation/devicetree/bindings/usb/mediatek,mt636x-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,mt636x-tcpc.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Mediatek MT636x Type-C Port Switch and Power Delivery controller DT bindings + +maintainers: + - ChiYuan Huang + +description: | + Mediatek MT636x 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 MT636x 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>; + }; + }; + }; + }; +...