Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1682913pxb; Wed, 9 Feb 2022 02:05:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwA5yFSAz5egtDfKaeTtiMMKcbix+IYvfa1W89YOVbqP0ouh2EkUavTFWfWRqn558Vniv+J X-Received: by 2002:a17:90a:df13:: with SMTP id gp19mr1689237pjb.170.1644401118911; Wed, 09 Feb 2022 02:05:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1644401118; cv=pass; d=google.com; s=arc-20160816; b=W9DtU4/HUz7/qOomwuzxHgzQPHQrrl4tvvKCW/VBKELnJscSEPrMsx6PI8g1Xe7dH6 5+fjJV3QwCBufwTkJfuksmt9zPnWVFsuG9jLa8ITV6b0FZF0O54vML1wfE7JdGIEDaoX zp/yG6yY0pvpU/oZFZE+Pie3Rriwn8U7SPM4SXtkTqjihEmm61sT5Fs42UNvLNFVsUnn aM55choJa3kqgC2ANKtdfKLNzQmVIKCyyWbnlMnD4IjW4ktzs8mjxNrBSyOwZe8x5Qzd m7omKF5tJoY53BUK7sIaKZKmwTslvvDbpLCpGTDAlT5TYpFWB19BTSiR11QQWU3sLI3S 7/8g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=kgkJPhZdxaN4k8YfU7okIPfT6UEZXl2XOC5ZCMGyn84=; b=y6AVjsotZ0j0l/m6AtvjjI9ixd8ykDrzan3rtrLpUKfWuuVFZzE3iKNLO7Qndninbg a9QemwdhzAAt76dRSJDA8NWaqtb1rVJRim7kiAV6BHu/hRJPYRxl7C4LvJPCCilSlDr3 VNKWP+sLUoYcEz87vC8aRTZCzLVqxKTKiuIgNE90xdjJz4l9MWzVvsdZYxBvzccbqhWQ jDp1/5ajh0qpu2errLq8ZRkU0f8j4m+0BzwREHx1g1D11OnzpAKx3UU79YvT36t+fPl8 dm4B4Fn/bFrt5FnhHb5ea9SefdK+Dc2s791fbN0H+iZlt+K4ZxTTg10TpZP6BZH7ditc 1UUg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quantacorp.onmicrosoft.com header.s=selector2-quantacorp-onmicrosoft-com header.b=kRQ5PCab; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bm10si18704096pgb.326.2022.02.09.02.05.04; Wed, 09 Feb 2022 02:05:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@quantacorp.onmicrosoft.com header.s=selector2-quantacorp-onmicrosoft-com header.b=kRQ5PCab; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358776AbiBHLgi (ORCPT + 99 others); Tue, 8 Feb 2022 06:36:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240375AbiBHLWt (ORCPT ); Tue, 8 Feb 2022 06:22:49 -0500 Received: from APC01-HK2-obe.outbound.protection.outlook.com (mail-eopbgr1300094.outbound.protection.outlook.com [40.107.130.94]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02C13C03FEC0; Tue, 8 Feb 2022 03:22:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jYEfZhs2INsqVuhmNJK/pL5iC0fj1PrnOqiak2qpRd1ZYw7L0PRqB9vQ4Yb0Wndk2III659F05JUVgLrDJSz+jOzLdQ8UMkYv5qp6751MIUjZPMIHDKsfSPT9Awr4oBxXfFhVCsq4SYAHkU3bJr9DgxTeh7XOiv9cZ1uAdUFOGgNo+epXbnl9MhJeeuEDGZigRKp+ZwmAZiaEMKyibSdFLXukkUXL+mhd9YJiR318HmwxNprb2U4NJdcaDnu1H6cu7soascHZL8cxpiWi9n4XkWt3UvtVfZT/QYyDex2th6HMB/xZ7PUjeL+zGyQ3A/BInaT9vSOqTjtxTi7aIl4jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kgkJPhZdxaN4k8YfU7okIPfT6UEZXl2XOC5ZCMGyn84=; b=YzetKVzSEQSZP3gFpPIocojhFkWcVMBCB0ElHhWsKbxEGBVB0ijoT4QoMYLRx2iJozgj+OmiNWg/en5KKmFwAfiPO7yHBMl2Cz/79QYUEEkhgAFGL1yQPaAydFNDokq9Xbe2heoekFeHv6ermNcwFM3wnsJcfK5FLmW1XLnbUlS7+7uWE/+hy6XSa2ERt/s5LwCK++zcQltjytIfH9KDA/ZhuY3bHp0wPOFxgRQZ0iFGJEZV1OysJVyoEkR9zSDlepcmqfl5tGaiYOuxztq88JsqJDaXbztY3ImAplLZYkPpm6VIv+4Luk3gIerocVCRKiDbIwnLlw3GksV2y7z/nA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantacorp.onmicrosoft.com; s=selector2-quantacorp-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kgkJPhZdxaN4k8YfU7okIPfT6UEZXl2XOC5ZCMGyn84=; b=kRQ5PCabRjZQTGyDnL+Zj5Co9As5k2hj1mkcBnacqDEaN+V5WXXJOMUN+bH8mYXUBnsAV3gmx8jDLjzZK/Ai8HJfK51riJ8mlu/wo2s5KxU8YUSU5tgkhabQ5KkZzVfXSwAzEK6p6hJkkpSmPkJLW+wQ2GADu5giEndbSAwN4+4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=quantatw.com; Received: from HK0PR04MB3282.apcprd04.prod.outlook.com (2603:1096:203:89::17) by TY2PR04MB3805.apcprd04.prod.outlook.com (2603:1096:404:f7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.14; Tue, 8 Feb 2022 11:22:43 +0000 Received: from HK0PR04MB3282.apcprd04.prod.outlook.com ([fe80::8160:1a0:97e1:9e53]) by HK0PR04MB3282.apcprd04.prod.outlook.com ([fe80::8160:1a0:97e1:9e53%3]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 11:22:42 +0000 From: Potin Lai To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Patrick Williams , Potin Lai Subject: [PATCH v2 2/2] usb: typec: fusb302: add support of supported_pd_rev Date: Tue, 8 Feb 2022 19:22:26 +0800 Message-Id: <20220208112226.9108-3-potin.lai@quantatw.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220208112226.9108-1-potin.lai@quantatw.com> References: <20220208082026.4855-1-potin.lai@quantatw.com> <20220208112226.9108-1-potin.lai@quantatw.com> Content-Type: text/plain X-ClientProxiedBy: HK2PR02CA0143.apcprd02.prod.outlook.com (2603:1096:202:16::27) To HK0PR04MB3282.apcprd04.prod.outlook.com (2603:1096:203:89::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1c5831e7-589a-4a3d-4a91-08d9eaf5525b X-MS-TrafficTypeDiagnostic: TY2PR04MB3805:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 241EjccOd12q0/+gVlYuphEIGGOXzu6qmECMVarDmxlyt3CfieqNjVno4ncxwVVNz43Sc3JeLDF6gQxKrE7QBbTOLu6gF+3qlmEkM9w7K75TmroM7cQNkeHBey00hjbBvnvl6SIOmYl5XRLXaNJDuo6DVqZmLg46RwdyIxbB45o/G4X3Uzd089cTc2pFtaoArpWo66JK2yjnD/0WDHsbwwWoV/5XmO9IHdYE8F7RfXLEZPN16S8PPew5MYUX28QXJoYz0XGXu3BPoDXR+kvRDf7OYjy4uvCNBHRDF1X7m0KMZAQi6hoj4bqV6wVXxZYTCzDCXsQiahGpk73XP6zNq80jXKvbSLmH4RHurD/OkQ84T7eFEDiztcOEkk/Qmlo7bJrWAzZ0kUaIXvzBsx0vhthiyTpYwDDInyuFA1LbxZMsf2O9CynC2AF966ZGmOeGuDujoWYjyyeuNi2sItCSozGA0ADa0nk0Q2jO7naXeM/kAA/4mPSuH9UuHN+tQqMRK6vxlNG5hiNw4bQk6renYjhxugQGHzxm3J2lI4CPLy9TjjTICpawcGx+UR4AXl5GkCGkmK8zZzwjS2DFVGrWJQrDKur3B2Tg82xLpMtJIvlsYzhIuZMO/pFBthMu4yQG842eHua9sxGixkKz8rjrZ7swDzk0fkdr/MCNhK1P4rdKboL1gB9NalVK4aMKCDC4s27hNjsL0Rb2EtGuY5DHkQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HK0PR04MB3282.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(26005)(1076003)(6486002)(38350700002)(38100700002)(2906002)(186003)(44832011)(107886003)(86362001)(2616005)(36756003)(8676002)(8936002)(52116002)(5660300002)(66476007)(66556008)(66946007)(54906003)(110136005)(6506007)(6512007)(6666004)(4326008)(508600001)(316002)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ChB2UqIjI5Stlq8LtDQKYbToKXgfFs8MudiehoKi5OoOH3aGS2h3CPdc3LxH?= =?us-ascii?Q?7doDwUqmEgWuQfowkMgAB5qn+L5oJsC6uQDnbEU2DMQgRPImZdha/hwmrvSP?= =?us-ascii?Q?REZXi1TBky7AEcjitK3SNPze8dd6I5f5aF17MQ2LXYddMFQVC40sRC5qqi7E?= =?us-ascii?Q?Wpp+RDuBh85jIoMI9Xs8Zl8qC+6IsvdVpQ74JvZyysKkbA3FkIhTkaxtz+tv?= =?us-ascii?Q?EdgxmnuDkaLvkAl8YmKj1PrafmUItEECzSZZBTsWtgM7dBSe/Iy5LHdRC7c/?= =?us-ascii?Q?Hh8bg0KW3DBcq4td/SdMPj1ZgzeZ7GFhd5W8C3KvJE94zg1MTG5YRt0vPu0G?= =?us-ascii?Q?U7nZ6+t7BwaGHDlLmKtrdNb0i4XP9P3tqPbiyU9Fnda4N0Ri4ymeEZNUkdb/?= =?us-ascii?Q?oxO/5J3XIm8uLUlDkXs6wvzhzbqW1q/A30VM7HXb8fjaLGroApAb4KccAjUF?= =?us-ascii?Q?feRyWAb+bsfdmxs8bXl8JlwzRokxtg8JXwl2N2UJzyjMsE0fB0yJz9J1mYGA?= =?us-ascii?Q?vI6Z3NrHgJRgpitiO1EkfmyK5u4w5ZlKeVjJunA61UU6h6XY1v9hlO/OV9qp?= =?us-ascii?Q?qOP80wraa7IXx3I4ETuKA3O4CYFL3I/bDiD6rTm01zenhu25E5Ynf1PpcBlY?= =?us-ascii?Q?UGVmNLdW4K0R/GpFoaOhQHJJQDibZogcekaD+FYEI2h2MzObUXec5TEjlKRp?= =?us-ascii?Q?O3DdOiPsUoKLVLZAzXkkTefoHXISt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x2N6dgAvGNBJYvuoBxoC8=3D?= X-OriginatorOrg: quantatw.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c5831e7-589a-4a3d-4a91-08d9eaf5525b X-MS-Exchange-CrossTenant-AuthSource: HK0PR04MB3282.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 11:22:42.1893 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 179b0327-07fc-4973-ac73-8de7313561b2 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: C66qSUlGvPWrkEWJqAd8wH+JUMb0eSVjjhdkbewDPdsdscFFGcofUfJ+QijW0w1JhT2u4/lt0182tl6bqDVJeQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY2PR04MB3805 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for passing supported PD rev to TCPM. If "supported-pd-rev" property exist, then return supported_pd_rev as defined value in DTS, otherwise return PD_MAX_REV Example of DTS: fusb302: typec-portc@22 { compatible = "fcs,fusb302"; reg = <0x22>; ... supported-pd-rev=<1>; // PD_REV20 ... }; Signed-off-by: Potin Lai --- drivers/usb/typec/tcpm/fusb302.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c index 72f9001b0792..8cff92d58b96 100644 --- a/drivers/usb/typec/tcpm/fusb302.c +++ b/drivers/usb/typec/tcpm/fusb302.c @@ -109,6 +109,9 @@ struct fusb302_chip { enum typec_cc_status cc2; u32 snk_pdo[PDO_MAX_OBJECTS]; + /* supported pd rev */ + u32 supported_pd_rev; + #ifdef CONFIG_DEBUG_FS struct dentry *dentry; /* lock for log buffer access */ @@ -1056,6 +1059,13 @@ static int tcpm_pd_transmit(struct tcpc_dev *dev, enum tcpm_transmit_type type, return ret; } +static u32 tcpm_supported_pd_rev(struct tcpc_dev *dev) +{ + struct fusb302_chip *chip = container_of(dev, struct fusb302_chip, + tcpc_dev); + return chip->supported_pd_rev; +} + static enum typec_cc_status fusb302_bc_lvl_to_cc(u8 bc_lvl) { if (bc_lvl == FUSB_REG_STATUS0_BC_LVL_1230_MAX) @@ -1129,6 +1139,7 @@ static void init_tcpc_dev(struct tcpc_dev *fusb302_tcpc_dev) fusb302_tcpc_dev->set_roles = tcpm_set_roles; fusb302_tcpc_dev->start_toggling = tcpm_start_toggling; fusb302_tcpc_dev->pd_transmit = tcpm_pd_transmit; + fusb302_tcpc_dev->supported_pd_rev = tcpm_supported_pd_rev; } static const char * const cc_polarity_name[] = { @@ -1683,6 +1694,7 @@ static int fusb302_probe(struct i2c_client *client, struct fusb302_chip *chip; struct i2c_adapter *adapter = client->adapter; struct device *dev = &client->dev; + struct device_node *np = dev->of_node; const char *name; int ret = 0; @@ -1756,6 +1768,14 @@ static int fusb302_probe(struct i2c_client *client, dev_err(dev, "cannot request IRQ for GPIO Int_N, ret=%d", ret); goto tcpm_unregister_port; } + + if (of_property_read_u32(np, "supported-pd-rev", + &chip->supported_pd_rev) < 0) { + chip->supported_pd_rev = PD_MAX_REV; + } else if (chip->supported_pd_rev > PD_MAX_REV) { + chip->supported_pd_rev = PD_MAX_REV; + } + enable_irq_wake(chip->gpio_int_n_irq); i2c_set_clientdata(client, chip); -- 2.17.1