From patchwork Fri Apr 13 05:55:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 10339555 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 1AC266039A for ; Fri, 13 Apr 2018 06:11:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF74D286B5 for ; Fri, 13 Apr 2018 06:11:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D41B9286BC; Fri, 13 Apr 2018 06:11:28 +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 63137286B5 for ; Fri, 13 Apr 2018 06:11:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751160AbeDMGL1 (ORCPT ); Fri, 13 Apr 2018 02:11:27 -0400 Received: from mail-ve1eur01on0080.outbound.protection.outlook.com ([104.47.1.80]:14896 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751047AbeDMGL0 (ORCPT ); Fri, 13 Apr 2018 02:11:26 -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=NyzFqhJVfi7l7XGaIH4BIS14/kR55FDSZNXksB7QQ+w=; b=g/SOWhtyO8s8rTwwIVni6DKb7Mom1Jac53lcgNp5/DNvVPpBsW2DPwB/cW4Kjb98xZjDkO38Zq3M2u34dXmGaBwmWne89Vu9jUg9zNGe7V9HQQuYn04av3XgEwvzELgvN28Lp9L58ipgmp1fyo2vGhUhmDJGUD9cfn4pzl3nLfE= 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 AM0PR0402MB3906.eurprd04.prod.outlook.com (2603:10a6:208:f::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.675.10; Fri, 13 Apr 2018 06:11:20 +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 v3 2/5] usb: typec: fusb302: remove max_snk_* for sink config Date: Fri, 13 Apr 2018 13:55:10 +0800 Message-Id: <1523598913-11507-3-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523598913-11507-1-git-send-email-jun.li@nxp.com> References: <1523598913-11507-1-git-send-email-jun.li@nxp.com> MIME-Version: 1.0 X-Originating-IP: [92.121.68.129] X-ClientProxiedBy: KL1PR0302CA0007.apcprd03.prod.outlook.com (2603:1096:802::17) To AM0PR0402MB3906.eurprd04.prod.outlook.com (2603:10a6:208:f::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603328)(7153060)(7193020); SRVR:AM0PR0402MB3906; X-Microsoft-Exchange-Diagnostics: 1; AM0PR0402MB3906; 3:wst/T+mafVaN6Kz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fF1PfJXGflJeOG/vdd2qZO62KPgwGPM7B2KBG9l2voWDRKdJjzFtaoAvMAU/KCc2PDSEKV/dxP088TJGsZurR4fMjVTYyJsTt2hNlUI3o/l5kaEqqCa26H/scJZQn5/sFbfN5MvFg3OAXg+Wmroag3uq+oen82+YKcyELxtLKi5wwNSAXDT1s/13lvl5Tla88w6+Pr/J4CHBgzECCGYS1F7D4TgyDPQszADDMqndX+M/09vDJ8QK7Q4HOgsgR/uVflN23UWhlnfSrAh9wB/aZzMnOrswAE2qRPCTZ5cJPaS6P1sqoWSrqhPhdKtjjI10CmkTGoY8Cyh+V; 4:FVyixQq+H+niGAJNnrPZEN+N6WJZ2iQsDsyUEuanbMM5M2yCQ7dmU6DuPPQmbdq4uM+qbkVzBzG914VNeYnXRBlojLHz5aZ0UkgMpQaA4dKITTnuy/QwNIc4dsKvNvdS31NuUog6I3NGiQ9S1vMcbB1/0sV2j0W7wIw3Vt89onYCQGYkRsw5ZrhaKI6mTtD1NQQpQbUDQ4Dylm4pS2uvz61kuLUz+F6j65aKCbub8hkvtvwgbRJaCExtW3Q9DNWastrIb3MS4oVTINeQnrhewtS4pzgUhGgPYjkQDzbJEXnPKyZtIUgTmOHTSRn5ptht 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)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123564045)(20161123562045)(6072148)(201708071742011); SRVR:AM0PR0402MB3906; BCL:0; PCL:0; RULEID:; SRVR:AM0PR0402MB3906; X-Forefront-PRVS: 0641678E68 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(39380400002)(396003)(376002)(366004)(39860400002)(189003)(199004)(478600001)(8676002)(6666003)(4326008)(68736007)(5660300001)(8936002)(50226002)(6486002)(81156014)(81166006)(26005)(36756003)(53936002)(6506007)(386003)(59450400001)(105586002)(3846002)(47776003)(51416003)(6512007)(97736004)(86362001)(25786009)(48376002)(76176011)(52116002)(66066001)(16526019)(50466002)(6116002)(305945005)(2906002)(956004)(2616005)(106356001)(486006)(316002)(16586007)(11346002)(186003)(476003)(446003)(7736002)(39060400002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0402MB3906; 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; AM0PR0402MB3906; 23:Khs8D5LuQy3O/vpAtHDg/i9twh90X6uSIVb0Ylb?= =?us-ascii?Q?K8lpLqTHmS2Fy7MY9N7vhaA8oNskw+Tzp/st0VIJthB/XJUIqXtp0K/hhuOw?= =?us-ascii?Q?l2RRI4HMM9IskVO4RhXPUZ5DQASjB7ujj8yHsbfIWIlwffDL0QFUYo2GWZjy?= =?us-ascii?Q?1mP7JQWra4qEtxfLw94BDT9hT67M46E7tYLKRTyXtin9CG6sZls0ibVIiWoj?= =?us-ascii?Q?w+I7bvw+qmPwWE1PKQuFyeDaqOg+XdDr4etmnkkj7EAlHN6Y62rSbLBZ42Gu?= =?us-ascii?Q?Xpkh03P2ZFsaSn0hDb93CADi5XBN5vFUXtonlwuh1Wh2Lb7POIH8fZBTgcGP?= =?us-ascii?Q?nrwEK+6BZG0ayqLakbHTYspS5wDwSDY+idefG13WwekX7RN25biDwYQXMp06?= =?us-ascii?Q?qs2ljkkfGw8Lt/hG+zZeOBeUpOZitAGwDGMhvQECM/LJIzmVfzGI/xNPPd/W?= =?us-ascii?Q?eNV+6+4govxj23JDYLuKN7rjrbD+t/XxeHMR4X+biINubZVtIWEVpIypM+yz?= =?us-ascii?Q?bgygiclj6/z4rY4TmLNR5y8IIvRy8iQKyYQjESDyl1JQLDffCI8s7oG3pCTJ?= =?us-ascii?Q?SnmCJYgZ85sRbDMU9s/jSfeawYS0inuxci8HH7KKv4tEuJAjpK4JRMoZ4uDr?= =?us-ascii?Q?f7s6s3aYAr7CPJsBqsoV2keItozgA3wwlWG5SaBQceH1XyB3EVfStOCRtyf6?= =?us-ascii?Q?gKccfORSrmj1exJoON+OaoOtIgZqhYttsaJmK5uJ+TPMOzzgvFImA9l9FO4d?= =?us-ascii?Q?/D2bDKJms2xo5a6VbCv0rzD1oP0ee0jEgsrh9ZZTWM4mUR3vy3S1DrZ8DKgK?= =?us-ascii?Q?SnGk9PAebjCoZWSSo6KiZ7eAeBlZ7JRCuDXrR3cfmuoqpa+GA4bQJ0XMbadH?= =?us-ascii?Q?3XPRv7idzD0e7Fw7XnqEk4NSwC0VVSv4GsqodQjigb7WI/5Tum9inKMSYsjz?= =?us-ascii?Q?d/LLqbW06ml987Vs/wYDuTc9AskNLso+QxCGmj69t6ZP1Wf6ERWfDl4NYA8Z?= =?us-ascii?Q?SsVWwlnWIImnIRuh1zY0/21vhauTt0pBpl8lpMyC44phwokcctm9XZ0+Iokq?= =?us-ascii?Q?Q0aLmL46bFi4pupBRIxcxtS5G/vF+HND5LAxRuJrloz9AigxhQCtGCGGMTRv?= =?us-ascii?Q?gup4BimB/mV1aUuEn957aqi/fWgsnYaYbcf/9LTdNkRvOCKtjthgaJIe4szJ?= =?us-ascii?Q?HfZFr5C+jkeN/tQa7chl7kXXtQo8wt0QdKCIV?= X-Microsoft-Antispam-Message-Info: 2y80xPssao/kGfmcXtF6jYXI7vRcuD7SxVilXe+NjJyNgOSMrlaWJGkSP1noJ6WM19AQYs4DOd9zlA19SzEAGUAv69GaCT+ACe9BePtS7CcQWtnYAQP6WI+rDt41TiW9b+AD8p342NkwVZML6yxmkkuHS3b9cuOfr+rcYG54HE8ZYGWvUpB3HDwxAzRT+5Am X-Microsoft-Exchange-Diagnostics: 1; AM0PR0402MB3906; 6:lkdjm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gu X-MS-Office365-Filtering-Correlation-Id: 172f4a8a-96de-4e6e-b904-08d5a1056209 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2018 06:11:20.4974 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 172f4a8a-96de-4e6e-b904-08d5a1056209 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3906 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. 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.