From patchwork Mon Apr 16 06:54:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 10342301 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 934D860365 for ; Mon, 16 Apr 2018 07:10:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8220A2859F for ; Mon, 16 Apr 2018 07:10:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80A112858F; Mon, 16 Apr 2018 07:10:40 +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 A70FB285B0 for ; Mon, 16 Apr 2018 07:10:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752359AbeDPHKZ (ORCPT ); Mon, 16 Apr 2018 03:10:25 -0400 Received: from mail-eopbgr10082.outbound.protection.outlook.com ([40.107.1.82]:52036 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750716AbeDPHKY (ORCPT ); Mon, 16 Apr 2018 03:10:24 -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=89s1e9vyf3vnkr5SwPewlbcO8UhAEvbXASu9a3uAfaU=; b=xWUrQ1mSvbvA2HQgL0YCcBLqCXpUGudCPPYzVpwyYfv8fxprpYeQCR28js/tzuOpEOkZUns/fFvq6iXvJv3IJSdaFhD833FVb0PqFYXntWFArMjg30wW8WhlNiZjUPJOIW6BxCRGkZy4FQ74kEWZtUKzThkUeQs5dHcFBoF8vIc= 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 AM0PR0402MB3907.eurprd04.prod.outlook.com (2603:10a6:208:f::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.675.9; Mon, 16 Apr 2018 07:10:17 +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 v5 2/5] usb: typec: fusb302: remove max_snk_* for sink config Date: Mon, 16 Apr 2018 14:54:34 +0800 Message-Id: <1523861677-16893-3-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523861677-16893-1-git-send-email-jun.li@nxp.com> References: <1523861677-16893-1-git-send-email-jun.li@nxp.com> MIME-Version: 1.0 X-Originating-IP: [92.121.68.129] X-ClientProxiedBy: HK2P15301CA0001.APCP153.PROD.OUTLOOK.COM (2603:1096:202:1::11) To AM0PR0402MB3907.eurprd04.prod.outlook.com (2603:10a6:208:f::27) 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:AM0PR0402MB3907; X-Microsoft-Exchange-Diagnostics: 1; AM0PR0402MB3907; 3:xk3tcYT+LY5bdOV75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758ahYIMfQI4Wdsd40M/NG5wOAkUqvcDAPx88P+7rQVZl7kxStOn8fpW8IQDOWdlFhc7ba0wn72BiVoksehDnC/yGsEBUCtov0/RxQm3BZcFn4pJsKqM0QCdFql/1/23V8eW+TOEK83vAvucPyuj87Gsod5YNu5nNiv2ViCBGuGFF3fz1eoWApRAvfxPMyWBmIJsVLBahYy+RbjuYTXfTB3aGIyV13/paL2QMwxgE+2BXTq5K1c8fWJH8EQMHNg2gAxgjdemIZw/COWAxb+AaQ46FQp+r0CWC77s9jLyxGgtZNasBIzUc+uuW1NME0gXi9OVWULqR3Qi3ZllpvrH; 4:FDE6UFTVOoq+M1PxBB3C6bnk7lhXrlC6zk3xyCswt+vNA+fuB+MIBIkExt4NmsROr7ba8gN22OkT8psjO4tYnO7yRCyEpVMNv0W1uwIfHHGmJS7glhIFCTNlMdLoKBqNyREKgJaqOP458YlV1+7dWx7JYbtrFUeF9egk2mCsMxc7vX0ioBaalWM2s9uOb4qSQQ0697oonS3dJY/SoY4rmWJAOolJEog+5sHa2urvM7e5pXmerbVBrzDECmlQS/cewd5tmAOwbDKlptTL6RXhsJ++BQuddyxC9TTmJC67Pmtf5kg5Crd3QJ8XCR8MU7X6 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)(5005006)(8121501046)(3231232)(944501327)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(6072148)(201708071742011); SRVR:AM0PR0402MB3907; BCL:0; PCL:0; RULEID:; SRVR:AM0PR0402MB3907; X-Forefront-PRVS: 0644578634 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(346002)(39380400002)(366004)(396003)(199004)(189003)(52116002)(7736002)(11346002)(51416003)(316002)(305945005)(2906002)(478600001)(16586007)(26005)(76176011)(6666003)(86362001)(59450400001)(105586002)(6506007)(106356001)(25786009)(386003)(6486002)(97736004)(66066001)(47776003)(486006)(6116002)(16526019)(3846002)(6512007)(186003)(53936002)(5660300001)(36756003)(476003)(2616005)(50226002)(68736007)(48376002)(50466002)(446003)(4326008)(8936002)(81156014)(956004)(8676002)(81166006)(39060400002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0402MB3907; H:b47624-OptiPlex-7040.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM0PR0402MB3907; 23:yO+JCMt0SBvnHqI7yjExLCXISvowp8yTdeH6fSG?= =?us-ascii?Q?QWZqoctNlFJU2r93W5MbVL6J2BO4tAfdwshNrDVKs0fOCUzCPByYJPHdVuS2?= =?us-ascii?Q?PUzB6fENYdqVg8w+gPtjtklGRExSEZiU9GJ3qIEmHWJKQv6Z+z/Es9I7L5AL?= =?us-ascii?Q?y53ZuGGoIg2anxK0+VdX6kR9k0XQ8W8jlxiAV1q/hEXUdvSpQeKH5nyhC1sZ?= =?us-ascii?Q?FCMDyEehHeBN8K25rvj3RtAl21PmIAILxJjRQ4kkJT4JGW0JqJzkq/yr2obF?= =?us-ascii?Q?vhrDdmJ1A+r8TAp5iYSSyGzE8H7BqpdsPpUjzIqDdf1/y6QuBKO4PYhI304c?= =?us-ascii?Q?cr7zp9AxZ3BEsxhhRZKLFsVHXOT5lrWfrnQlT6ZSqSwDdn9PN5ytn4pXUdbB?= =?us-ascii?Q?EzUeHMjxk/+Tvgh0XdBYuzRmmt6toSttELqfmE+cTYgEtYstvip4Rz/bkqWv?= =?us-ascii?Q?aWGiIKvk6gUDvN4ArWIqC5w+p47DfadRgBmoS2/kWjx8hbFpSEGyt82E3LK7?= =?us-ascii?Q?b54G5FVx4S77a/KPEQ685OMDtc+GKUlDR7XAbE55/yCkfrRWQ1TzlYWRWIXm?= =?us-ascii?Q?P/CRwIuy/V22z0uHjcLKmOWr6SnQull9/LMGlB1+yUciUTTeE1a1lnlplvdw?= =?us-ascii?Q?mGALvx3ZSAEJyorxjxlhv7ETxmASjv6S2HbFf6qGP0Ye0GjMcvIp40P40LLW?= =?us-ascii?Q?pAEvGtsxrbekMdOlJMEUceYIELndIrFmQ1CR8BY5GLNNQZHB+XKUEIfxz9PX?= =?us-ascii?Q?AvDM4zWPAK0cP5d/rw1gJH8yY0l4qWZVL0EdDGsxZ0qQaTiMY5i3fy+BlFHc?= =?us-ascii?Q?gCz4VRRQRKT7LDurRdUSDBmAm9bQXx34o7uZjuGPgFoawA50urRXtOajJ9wP?= =?us-ascii?Q?X1X1dYENsZm9aUmPSbMNwbVKti3cbDp8jl2BxTvPMcDKffbZTa6rg5KLCX/A?= =?us-ascii?Q?V3Ms1/UH0l5gW5p/ZtiNJGaO2rzF4pw+4dqwpYV0mOGY+WBev58g4RESamzo?= =?us-ascii?Q?Plxaja632M0tNmkdOg0tBmq9TYN2fVgi0LQIZ5LovLpRu1ArVGzpvgpekk+q?= =?us-ascii?Q?AXBz9qfOW9NhEisw6lHvLLGg3Jtbbbh8vzAn2EDufmJBL7dAZo/r4yeaKqxL?= =?us-ascii?Q?OtiXEeGmrOn5e/Ch7Egla7nOV/6oVDFhvLye4lzQCku17gDErpQ2jkLONSOJ?= =?us-ascii?Q?qPvowlki00RhCN5YMu23Ssbc6zoLDQVG7NDt5?= X-Microsoft-Antispam-Message-Info: hwkHeU8inpwRbgKWb4+LhCwWov/QAEc2jwO+agkh0uO3Uh2jkn+//xWcPDsQFPJlZyE1vKPm6zALXAmi5Wsodz9uzowm7493OPdnJyu7AXcrqr+arKefTS++mRAEdjovF5SRC+RG0DTncO9vmj376dl2Ft6ELLejL+5tPezpK8UF9NS+u+Agdu/zWv8P9OdK X-Microsoft-Exchange-Diagnostics: 1; AM0PR0402MB3907; 6:Q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7I07kE0k4IJpkl X-MS-Office365-Filtering-Correlation-Id: b329f3f9-df9d-46e9-ad23-08d5a3691e02 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2018 07:10:17.6146 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b329f3f9-df9d-46e9-ad23-08d5a3691e02 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3907 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 Acked-by: Heikki Krogerus --- drivers/usb/typec/fusb302/fusb302.c | 42 ++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c index 7036171..664463d 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,29 @@ 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); + + /* + * As max_snk_ma/mv/mw is not needed for tcpc_config, + * those settings should be passed in via sink PDO, so + * "fcs, max-sink-*" properties will be deprecated, to + * perserve compatibility with existing users of them, + * we read those properties to convert them to be a var + * PDO. + */ + 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 +1803,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.