From patchwork Fri Apr 13 14:18:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 10340231 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 517BD604D4 for ; Fri, 13 Apr 2018 14:34:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C8A6201BD for ; Fri, 13 Apr 2018 14:34:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EC72288B6; Fri, 13 Apr 2018 14:34:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9325201BD for ; Fri, 13 Apr 2018 14:34:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753101AbeDMOeg (ORCPT ); Fri, 13 Apr 2018 10:34:36 -0400 Received: from mail-eopbgr30063.outbound.protection.outlook.com ([40.107.3.63]:25973 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753080AbeDMOef (ORCPT ); Fri, 13 Apr 2018 10:34:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=vHPdfQP7lmguWatHcQrYPAadNtYM5rESn80n8jMOXRM=; b=Cx0dcICbr4Cp6+eYCjmNVXz8gtW1cuJDRNu65f475IDgyJ7EcV+tvbi14gMoFXtS/sVvhIlO4R2YbUD3EHMZeH08mZbZQ7eXxAqTgutIwxYNqYI1TU5lDA0hESFVhZwj0kS1jS9NA9tyoy9SPhMl6ehiVwnAZ0uTpoEvRDTT6pc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jun.li@nxp.com; Received: from b47624-OptiPlex-7040.ap.freescale.net (92.121.68.129) by VI1PR0402MB3920.eurprd04.prod.outlook.com (2603:10a6:803:23::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.653.12; Fri, 13 Apr 2018 14:34:27 +0000 From: Li Jun To: gregkh@linuxfoundation.org, robh+dt@kernel.org, heikki.krogerus@linux.intel.com, hdegoede@redhat.com Cc: linux@roeck-us.net, rmfrfs@gmail.com, yueyao.zhu@gmail.com, linux-usb@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH v4 2/5] usb: typec: fusb302: remove max_snk_* for sink config Date: Fri, 13 Apr 2018 22:18:42 +0800 Message-Id: <1523629125-16332-3-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523629125-16332-1-git-send-email-jun.li@nxp.com> References: <1523629125-16332-1-git-send-email-jun.li@nxp.com> MIME-Version: 1.0 X-Originating-IP: [92.121.68.129] X-ClientProxiedBy: HK2PR02CA0139.apcprd02.prod.outlook.com (2603:1096:202:16::23) To VI1PR0402MB3920.eurprd04.prod.outlook.com (2603:10a6:803:23::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(2017052603328)(7153060)(7193020); SRVR:VI1PR0402MB3920; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0402MB3920; 3:Kso99bMj0QImAVLhleND3hH87qz91FLwfwayt8W9H4cWSLzuts6q8ZTf5GWqPKpDRcsuSZsq355qObhxYPpK6nzZr/CwWnzELiUHBaWX1bc/A6PRPx60Rqe6XJRuoKJiFjI75xAu1LGEsj9ze+OY5GadbWJrlaLE/td8Hga2Wc/DTY5dtkpGIDIuQGKC159DioQaih8B866Hs5HuSifdmUe5slMnivPu5aGLQk+PUK3N0z4neWM9oWjrqkZO+5SQ; 25:oGUsAF3LyuG1uQp7imibSrEoLcqC/Bhpal1CXivVbQaiuJdLgjjKaLGrFoSS0vtXVedSwY1DBvIEw42TpSXifB3zuv/wF5J/fj+zVh2F2D7VXe+jLLR5rl9cA64OBWVj7sx9XP5x2CqA892yIEytU9FkN7BKppHVFYrCl15byXkgl33yAXSXU5Ig8UL87KySw66WFWPUQA2a2bFYE63aov8jhG5i3arQ85XWi4RqnFLNsajBi1hrM7EN9MP0RGdEgysOBJCu1PlD+J98VpCzoFetE1GXcpYbvZ+T3Y/9NWdQD27gEZauIjBAUHw6QRWYpFv9jWmjlqO6eQR/eZs0LA==; 31:aLYEJ3amsqYS+FWe1J4z50EztESCDo/0YooURWOCwsHmVa2MvQvEazhwnslhjwJSzurG0VpgQYJ3ZSBeAHqbE8uqyby46wz2co51VvtID7S2Wo1toDAxFqdB+mkhzqfZtiGT1v6DpLvEr9+GwdjkEMpwCZhpBw76vATN6+1D4mpFKbYztFuZT298cAnpw8GUS6wAfsbwUoxB9+aHJ3DepYQ9+tR2Goaz20peTWYQBY0= X-MS-TrafficTypeDiagnostic: VI1PR0402MB3920: X-Microsoft-Exchange-Diagnostics: 1; VI1PR0402MB3920; 20:tIabLzSo9LFJKTInTwrGZG72zeqb2W1SA4yJVv13OYi82ackUm3Mlv8bb3wr1nZ1lHWIvYjSYdgVdCgl0liRs+O4oycTqsi38OTZpFUJ5FBKRabsPlxswTERcT+WSSeMFaXM6Vqnl90x9tLlwRnwv0zqg5r/lCswtFDYppXscLBRb2zFa6R/uLsMmmRMLeNEUCSbrb/q3OP1HjMS/AkASfDR6UN05ngnm5zco0Su9KbEiRa9DA27hb5CVmV1txxYKtVDodhv0mKfi8fBlhzU3F0eQo2aihsZ9jQTmH4fWS1PLxEFtgrVEtOguqS8F79+dU6FmsZKCQyna4p8/8aZ57Y8gRK1eFQdW2Fy8KhoYlXP+2R7fw4EEk11KagYsw+8I9T0TevHuOw1YH8UHXuPLIHCBStQUC2KD4I+iRZl+W313VVjmHntBY8R1yDIDw1Hw5Mo4nfTaWGn2Zru2aNL4ETq88XVR1A6cA2gEplfXiKkyts5uDOyjBQXKhHgRhqO; 4:SYWpO2zMjkuTwTSyypuoaBEeubkbsC1gE6ANYG7mA3oXhVFuXoRT78dFenSjXP7eVl6sXXjZ9BhVsOHbviWD012k3gHC7HlEHlOI5GzdwVEeeL7poJSynfGwFThMzBSG4AH2CS+y+wKc/b7bbZeF48/VM6W2SM8P/QdRTDhKtTtH2vwn7Bs/YbdiihYP3cl4tjTInylZMcdnW/x9BOU8mA77c8IykVDt2H679Av3tq7it/N9q5WyplZI4G9tOfF7/J53WeEGCIF4eAu9jtyBEpNxzCvr3zsyTsBlNOXXZx7L+1Nns3kiIZEqWt9zkPiu X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231232)(944501327)(52105095)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041310)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:VI1PR0402MB3920; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0402MB3920; X-Forefront-PRVS: 0641678E68 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(346002)(39380400002)(366004)(396003)(376002)(189003)(199004)(305945005)(16526019)(3846002)(6506007)(6512007)(7736002)(446003)(476003)(47776003)(50466002)(48376002)(66066001)(486006)(81156014)(81166006)(956004)(2616005)(8936002)(11346002)(6486002)(2906002)(39060400002)(105586002)(6116002)(16586007)(53936002)(26005)(316002)(8676002)(36756003)(186003)(6666003)(478600001)(25786009)(50226002)(97736004)(52116002)(86362001)(59450400001)(76176011)(68736007)(106356001)(4326008)(51416003)(386003)(5660300001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB3920; H:b47624-OptiPlex-7040.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0402MB3920; 23:hAD0rlZevQND3c/AClt+HHM9YyliKL+PvXIAuVm?= =?us-ascii?Q?CKQp3IIzQPbfVbynDWVA5q1Tld7gQq2iRP5+iVygKAi812YqYYD+RSOk8YjI?= =?us-ascii?Q?tu9MK7TTmfrPSmhGY1JYt8MZYyCs3Vfpp+mJVqOmbdZq7VbYeW+ZHQbmC3Wi?= =?us-ascii?Q?ArsR5JvpShDRiz/I4fheAqz7imfJB6KQ5DkCYDkblLr5fDOj8q2UhxuTyYk5?= =?us-ascii?Q?C7feGLim71s5mxfGCBZ74Um/5bLebGyX0/9LdJBSe1NobLjcAhznRR/x5otL?= =?us-ascii?Q?mKweFOPAtKEOm/CjGwVStLNjzar/AbiSve7c0eU0VwXEizzLXhpXsOvOxiAW?= =?us-ascii?Q?JtSkKNWLvSu9VIXTtiVBLP/2eWEaIfbtLFEqXvh3vKDHxD1L/ZMx5w48NUeL?= =?us-ascii?Q?YFuru42fq/ap6hZ/qofdexHWvfyVVITg+HFYCMOKFnNYSedSRQHiJmGNXUST?= =?us-ascii?Q?UrUmtTBeYgOTcIEeo8qDmhWwXK0Y8bXPjCSB8FEtw3bTZr97piLa8HhkyQYp?= =?us-ascii?Q?stLNKjmxzyi+OTw14vzohLGAQkJio0H5wOQxEuGZIXRq9hCxgGeM+KYuswIa?= =?us-ascii?Q?j/I+6p5YoXFLnTEiot8HAx91PzDTr8inLIkS46DyuGMKqVjDbDMf40pvohgl?= =?us-ascii?Q?LgYpY5yW/btIssNq7fw39jZwA4idcABo8kbOOXJEeCXgcHyK+oaMpl+Jpwcz?= =?us-ascii?Q?tgmVZrmiMSriqLbvtxwxGXGS8/wlQ8Xuc+nCV4TDP5gL/oq0oSBwR1z2+flq?= =?us-ascii?Q?WIMjhrIOps3Hy/1g7D4YPffgQurJp32EjnKm23LkoSXOOHFQzVIGFAoD2DCw?= =?us-ascii?Q?m5hXvJRaL/fneSoWrv9dSPfzm0vU9kMx4aCI9A68sdgTGrammf5Hntbp90VH?= =?us-ascii?Q?HJOj3T8MEPJlCAaZrEipmA1KNaZgQZ7WLaGrh6TQrCaAhnCKgZpNnDZaxNwB?= =?us-ascii?Q?kiUxMQUSbpycGH93SHJ7+6bGj5DhmMnAmr13yEMLnT0yj6yhiO4fTnLIuh3E?= =?us-ascii?Q?pJXzXYku8DVP4VM9NKT5L2nRLgBFkaTtqmSUaan8BMGQFzZj2yuf9VAG26+X?= =?us-ascii?Q?D6f10AxU4KySTfYmhiI3u6tmPV1mMexTXiJEV3xgKDX1Q8iSgdY+cQ798Q/Q?= =?us-ascii?Q?WBlfRAoOCRUvqcHKM8ttZtFjIyR/Qg+SfSvEyflOOJ34hZrYtTJUW+hhrJsw?= =?us-ascii?Q?LgnSRosxKakCDZHHKDMD1F+WTAol9SUJK8umF?= X-Microsoft-Antispam-Message-Info: ZWwlSORTOZ8YasA97LkqB+LV9IWWbwNxABIaFXUnWvtPRaWTiCzJbSEyceIV+l6wJO7CPr3vGKZ5LN6VPaIBLkibIh7kDEuFR92QI1j7r7FFwBGU8bFnvXkV7IvvA9aOVnIwAwB5eLZ+f2PzD1rd6rr66dr8cXxdyysSoCJn9eLeQyDe008gtTLgYIaKcs4d X-Microsoft-Exchange-Diagnostics: 1; VI1PR0402MB3920; 6:Ze62cMhW0WmS0nV3DsSRwtSuLa2Oqj59wiyv+LmMz5qo7ejFuhItf4M+VGByVT++2IBlYJz4DlhP3racGL2ylJBHD+IOAFf8LBnEJGhltLu8SQRp/WQO9LARUdLPWpj4Qn8hpAQiI1zkEWMpr6+WNnVhkXJ084eqZZeInZR7QrfFGAZbmmStIIk+I8DPzkPFM+cNHovC3v7rm/Nhvthax9nG10HTfu/RLTfRCN/RAupyFrAEN/jXSoUqn/mo9UV/41u24m6Vf/c2qD2cLXry4godpmDTolwzW9/7szhRP/PNI8QojGZuKdEI/UbZ0SMJ1HUrIMVv3YVrBRIbxku72/Ba+sZaCYFKqK8pglquYBRyRbFRJKljFqOxU2M4h2pn+5da4DLgur2RMKbwZ6AU6UUp9/Bnfk0uMRmjL5PhYwXPKuEKpnoEe7sdtRAm4c2wqhotRRXpKSaaTJYoePdZAw==; 5:YMAK0QVdwuJRqfEeMk/a05IKYZUhZFKvmrnQ3kJOtBJfuwcWWMrk9jvW5c+VIFSPCe3iYvJYIFZyJWAHAo47FgNyKs8oi2AD2Jneq7S9JKycWZ/u9bAO6bOXrx2INIgEP2WrnCI7kLvS3dqTllHX22CKsM3qCt23QjyxfAy5wBg=; 24:mT38I8McYcSLhPEViIauVReZVHdARwmAbQaVSFm+TvdqrqHLfTKmkiRuZBKfezPmgudhT+rSinsfxcnnledvtLCdaL1RpGL67hIHTSiGDFM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0402MB3920; 7:f3py08T2XxxfxzqtK2Bd/Of3vrdOZW+ujmAbnm3aChCZkFJpWaQyF0mG86fv0ot5DHMt93e+5NPY5drIiAK3YwtIZGFpGKfW5eTSqWS+T568H/EG3LXa9wFulXqEHxwuPhwgYElHVflmuBrcrJmbi9dk0SJp14AcJJvdoGZjhNLIqAkf4wrJGo6kRz40zw9Dl0tcs6prq4o9v3N+bVF5U1alZ8qhJJr3XJUq4ebLvy/oa60UIgoZu7Pa1sYhYBie X-MS-Office365-Filtering-Correlation-Id: 42fb8a2c-014f-46a2-fa68-08d5a14bab31 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2018 14:34:27.3341 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 42fb8a2c-014f-46a2-fa68-08d5a14bab31 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3920 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since max_snk_* is to be deprecated, so remove max_snk_* by adding a variable PDO for sink config. Reviewed-by: Hans de Goede Signed-off-by: Li Jun --- drivers/usb/typec/fusb302/fusb302.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c index 7036171..893f9e5 100644 --- a/drivers/usb/typec/fusb302/fusb302.c +++ b/drivers/usb/typec/fusb302/fusb302.c @@ -120,6 +120,7 @@ struct fusb302_chip { enum typec_cc_polarity cc_polarity; enum typec_cc_status cc1; enum typec_cc_status cc2; + u32 snk_pdo[PDO_MAX_OBJECTS]; #ifdef CONFIG_DEBUG_FS struct dentry *dentry; @@ -1212,11 +1213,6 @@ static const u32 snk_pdo[] = { static const struct tcpc_config fusb302_tcpc_config = { .src_pdo = src_pdo, .nr_src_pdo = ARRAY_SIZE(src_pdo), - .snk_pdo = snk_pdo, - .nr_snk_pdo = ARRAY_SIZE(snk_pdo), - .max_snk_mv = 5000, - .max_snk_ma = 3000, - .max_snk_mw = 15000, .operating_snk_mw = 2500, .type = TYPEC_PORT_DRP, .data = TYPEC_PORT_DRD, @@ -1756,6 +1752,21 @@ static int init_gpio(struct fusb302_chip *chip) return 0; } +static int fusb302_composite_snk_pdo_array(struct fusb302_chip *chip) +{ + struct device *dev = chip->dev; + u32 max_uv, max_ua; + + chip->snk_pdo[0] = PDO_FIXED(5000, 400, PDO_FIXED_FLAGS); + + if (device_property_read_u32(dev, "fcs,max-sink-microvolt", &max_uv) || + device_property_read_u32(dev, "fcs,max-sink-microamp", &max_ua)) + return 1; + + chip->snk_pdo[1] = PDO_VAR(5000, max_uv / 1000, max_ua / 1000); + return 2; +} + static int fusb302_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1784,18 +1795,13 @@ static int fusb302_probe(struct i2c_client *client, chip->tcpc_dev.config = &chip->tcpc_config; mutex_init(&chip->lock); - if (!device_property_read_u32(dev, "fcs,max-sink-microvolt", &v)) - chip->tcpc_config.max_snk_mv = v / 1000; - - if (!device_property_read_u32(dev, "fcs,max-sink-microamp", &v)) - chip->tcpc_config.max_snk_ma = v / 1000; - - if (!device_property_read_u32(dev, "fcs,max-sink-microwatt", &v)) - chip->tcpc_config.max_snk_mw = v / 1000; - if (!device_property_read_u32(dev, "fcs,operating-sink-microwatt", &v)) chip->tcpc_config.operating_snk_mw = v / 1000; + /* Composite sink PDO */ + chip->tcpc_config.nr_snk_pdo = fusb302_composite_snk_pdo_array(chip); + chip->tcpc_config.snk_pdo = chip->snk_pdo; + /* * Devicetree platforms should get extcon via phandle (not yet * supported). On ACPI platforms, we get the name from a device prop.