Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6107989rdb; Thu, 14 Dec 2023 08:29:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGc3blcoT/nz47hygZB3I5RO0YWOfvQ4zBMZ5DulUHA2qI+V0CsbRnlkQivijrOrhtEmO7X X-Received: by 2002:a05:6a20:918f:b0:191:511:a989 with SMTP id v15-20020a056a20918f00b001910511a989mr9855012pzd.39.1702571372260; Thu, 14 Dec 2023 08:29:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702571372; cv=pass; d=google.com; s=arc-20160816; b=rUN+hptL6xIObEbGcwhZjRc3ZD8wc/c18Y6IkBsRwb8uQquHVrCOciBqChDdx8ur7x 0apt2lRELFvvM1QtvE2Gtk81FfWW3kuOxm1HfaeGtN2JY+l4rAqAJzbDs0FsZ0dOcnl/ Qqcjl3vN7HCGgW9ptOl5Ivvzf1Ik0FamgVsTS3NgeTl+WaQjwZ4A/YOTDy7XAmA88lXA Ele8OEbcpq5v6fnkbKqKBWeXkrvDESwHAxY2/JZ9XT+DTAlqqnHH6/S6f8NUnp7JZlqs KwGYQSdgM/ZYSWcIMY1s2KLh8He3/k3paRdniu+0nEZeGX7WNkKuSyFmsJwNfapL7ckj 2y8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:cc:to:in-reply-to:references :message-id:content-transfer-encoding:subject:date:from :dkim-signature; bh=dFinOaArdwIYeAM3WtAo6SpWlNlZf6708hGd1TSt4Uo=; fh=skg4aWcIne/NkBvGBSxiPFt6u1LkY77F5jj9Umi9ZmE=; b=B99KQ0QPVpestlZKuH3pAqL3uUIZ73RBrbWZCMZBPgw+Z299SEyVcYD6nG3OhA3QC5 N+bFvaCiORfCluGlmITXyMpxFpXhGhvlsdfePU4bl+Nr60mV+ZQ0+6hvMja0DKj5vhoO bPZ8qaMkWqWZyP2HlzjKiaj69DtuRWEbwWURwp2SV0IOsGL1X3GKjx/y+LuojOvxFLW4 DWwnxGh0kZO9y6yrm5SeBhd5iPrU2zdmShxx96RfrOr7eJ00YIsyeSbAVl75MMMWJS39 FqDHljefY6Ee6xCtRXJl2RAi6GEXeQwuXq6/M7ADPG1q8+FXaV2Uo/Nd42wBHpC8p2mW LsZw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=lvVKyWMf; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id s16-20020a656910000000b005c6e820b5e6si10935413pgq.771.2023.12.14.08.29.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 08:29:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=lvVKyWMf; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 97C0883328EF; Thu, 14 Dec 2023 08:29:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229880AbjLNQ3P (ORCPT + 99 others); Thu, 14 Dec 2023 11:29:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbjLNQ3N (ORCPT ); Thu, 14 Dec 2023 11:29:13 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2082.outbound.protection.outlook.com [40.107.8.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B27F123; Thu, 14 Dec 2023 08:29:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PgCLsG0ilMOnZfgNQSOl2SzVOGunh4WPo7SudUoPLMlUY6NHnkl70XL5gTfAU5EB94ncYNvs8FEf/Ab9DLFh2pOHXQ0dNnqPm9aK2uaCnatyxe0YsNywgQsH7D5GuASRrgq27Ut0VrQnsYKFDJW11D+K6YWxgbEN0zBKKJsVCSV+KMF+2++9Zg2/yUy37HVjGiI2fRiubUA+AfCbPtuRfYhW8l/p8al7TKNEaCXvL5QLW9zLvSiDjJT8t1IFtME+4M59dWEefVCvceFZjus2GBhv8+SjmrranZ5NCEBdmDNkgl83naiG4YIZe6zoKdZa3J0Eyv/kLftg+ep4vR9tyQ== 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=dFinOaArdwIYeAM3WtAo6SpWlNlZf6708hGd1TSt4Uo=; b=kRm2pvyjJenONpAUQyG2Dh/GJQcEC6Ae87K5Q0nkFMAUZHgQZIzoEPRhtDcMJ4SuWp5q7yU0llainXzyXXR3Yp3GmNm9iRPo+3RGTVl4/+3NMpBE+EkcdmRYbSHBykttGibR+HpGx33vTH+6OwE8O60wpB+l6bK1ZMmZOvc9Wt77oyhFgfKG8lheZSwPahPVXrJIbIWWGjmuqXjfObR+BifEymAYYBpA6y2kd5LnDFN5//yGMRBs+MXmvZ/9c5Ww9fNFIgaloAFIzJ4PcFzAfiBx0c1W46h2JdExvmDiQJBmDhLZzEt65qhsL/RCQfjTf0twHh4YVV9cAqGx+Wx0DQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dFinOaArdwIYeAM3WtAo6SpWlNlZf6708hGd1TSt4Uo=; b=lvVKyWMfuLfEWXjsHXrDeJAguP5AFAOlv8e2KRUQN8yCWptkrcVxHOlmLHUNBlBt6ECDFH4tuyv1yxVA12aTsZJUguR5r/CmcqeW5jciDoPDMLF+cIla6FtjSXdr1OiyZ1fpiWKCBeYAOPZSPYaHap/1KZke7C5ziAAgpsEBVQE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) by DU0PR08MB8302.eurprd08.prod.outlook.com (2603:10a6:10:40e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.28; Thu, 14 Dec 2023 16:29:15 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6b40:1e6f:7c94:71dc]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6b40:1e6f:7c94:71dc%4]) with mapi id 15.20.7091.028; Thu, 14 Dec 2023 16:29:15 +0000 From: Javier Carrasco Date: Thu, 14 Dec 2023 17:29:09 +0100 Subject: [PATCH v2 1/4] usb: typec: tipd: add init and reset functions to tipd_data Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231207-tps6598x_update-v2-1-f3cfcde6d890@wolfvision.net> References: <20231207-tps6598x_update-v2-0-f3cfcde6d890@wolfvision.net> In-Reply-To: <20231207-tps6598x_update-v2-0-f3cfcde6d890@wolfvision.net> To: Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1702571354; l=4687; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=uuzBZoVgbfJRVw/uB3TAQ/14SQq/Je6fi5f+9uL7q9I=; b=ocXu4DT6SCja/JA6ebL7vPH4NHLCOvm1GnfeiAs9eqIDCcHl3Z7lZrjcmfVlKoJGUjZqtIexI NOTjSYf15UTAzCOQvzR5N0FLhwrp2S/C9/UhfWRVsi1Fvykzxlk88uF X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1P191CA0011.EURP191.PROD.OUTLOOK.COM (2603:10a6:800:1ba::19) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|DU0PR08MB8302:EE_ X-MS-Office365-Filtering-Correlation-Id: bfa5834c-e689-410b-7838-08dbfcc1d048 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fBylX6rcG6z046O1Gtdjb+vCcd8wpns6DgGBJpck3JyoGGo5M98PmVppMMqBploIbBD6wr+kJ5M5Zc/1GQ2rNyBlJKpvrLTEFufqRUlh2YarRAovaQetBHf0e1pKSQuM7ITcKBCbzXnfajbaWWrI4H83I1NvUNmnthuCLBdqesRrBE39ptAIp6YJrkBGn6d6EE+lB54d6hMuqt3pN5e/qXzRWDmty05SKG4hJowfJCNgGDP/yykUTd9x1/AUv0/HeAITSibzn6WT04F+QJYxvFb/jKiSfIdMdpnJsAo116wfMCSacEmg10KnZFx/WEFmNefPwDtkfkVnLE9W/P23r3ECva/b362EpR0tmnei7JVs41MNxaAmYr0QnbVlP2E0SUWEQUzeV1kTHd/0tXuya9MPJeYCPtIOXJol6WDCGYDURG+SGIDYlHIfRJ01vvf65SLY3dzP7CjW9v8+j16GTSaHyA/L1JckmllK2IPHcNBbsfRR7B1VPHGMhCHEZ708TDPQ270cU1xKuAUhqtP4Wp59cKWPNULDEZhYF/nFbhr6vaZnolMn8eDLWMrndUs2EIOo/YI3CNzYEuPWPHVbw+SDy2nvXO2bLxMEcRhSYEVRRjq93iZzDQVLp072rnyc X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR08MB4974.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(396003)(39850400004)(376002)(366004)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(52116002)(107886003)(2616005)(26005)(6666004)(6512007)(6506007)(66556008)(83380400001)(44832011)(2906002)(5660300002)(41300700001)(6486002)(478600001)(66946007)(8936002)(4326008)(66476007)(316002)(110136005)(8676002)(38350700005)(86362001)(38100700002)(36756003)(66899024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RTRtTndXNWxQYnQ2dTlRUWpkTDRUcldZT0dqT1E3ZHhHY003UG4rbjhaUlhB?= =?utf-8?B?YXA1YXIzcnVULzhrMzErUk9VL3FyYmx5UHVHaWdzL0o5WWZ4dWJkZkR6QjRy?= =?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UszM01oTXBJN1VNeWV2TStrOFJVcTJqYWY4?= =?utf-8?B?cEZCYzVldjkwVmsyNlpUc25JSTU0V0RHL3ZsVHVSYXFJcS9ZclNhQTRrOW1i?= =?utf-8?B?NXBGLzlBR1hrbzRFQmhTYTRPVUxEMmc0a0p6WXVDNTB1LzZxME04WFoydUIz?= =?utf-8?B?ZjE2aDhCbVhSQWtkN1hlR2ZPREpiUFFhWGVGTWJoOE82VStHMW9IZlZzSmZj?= =?utf-8?B?bVRHTWVJRUd2NUdyRlhsU2taU3ZidWVYL2w3QkdkVzdLZlpXRDZ2VVhrbUt1?= =?utf-8?Q?7gs27LaxHvIjvA0TQcZCqBE=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: bfa5834c-e689-410b-7838-08dbfcc1d048 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2023 16:29:15.7403 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: H9g/5nHYkN/h/rxbw/NSEBhHK3P2f6FXLrxeZJP0IqQzl6KTest4bEvr2vIjmcSj1jb2gIbIiCGMHFZDBmebb/1HMXEiK04DQLsz+s0AoHA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8302 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 14 Dec 2023 08:29:29 -0800 (PST) The current implementation includes a number of special cases for the tps25750. Nevertheless, init and reset functions can be generalized by adding function pointers to the tipd_data structure in order to offer that functionality to other parts without additional conditional clauses. Some functionality like the cold reset request (GAID) is shared by the tps25750 and the tps6598x, so they can use the same reset function. Signed-off-by: Javier Carrasco --- drivers/usb/typec/tipd/core.c | 45 +++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 806ef68273ca..f0c4cd571a37 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -115,6 +115,8 @@ struct tipd_data { void (*trace_power_status)(u16 status); void (*trace_status)(u32 status); int (*apply_patch)(struct tps6598x *tps); + int (*init)(struct tps6598x *tps); + int (*reset)(struct tps6598x *tps); }; struct tps6598x { @@ -1106,6 +1108,11 @@ static int tps25750_apply_patch(struct tps6598x *tps) return 0; }; +static int cd321x_init(struct tps6598x *tps) +{ + return 0; +} + static int tps25750_init(struct tps6598x *tps) { int ret; @@ -1124,6 +1131,21 @@ static int tps25750_init(struct tps6598x *tps) return 0; } +static int tps6598x_init(struct tps6598x *tps) +{ + return 0; +} + +static int cd321x_reset(struct tps6598x *tps) +{ + return 0; +} + +static int tps6598x_reset(struct tps6598x *tps) +{ + return tps6598x_exec_cmd_tmo(tps, "GAID", 0, NULL, 0, NULL, 2000, 0); +} + static int tps25750_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) { @@ -1187,7 +1209,6 @@ static int tps6598x_probe(struct i2c_client *client) u32 vid; int ret; u64 mask1; - bool is_tps25750; tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); if (!tps) @@ -1207,8 +1228,7 @@ static int tps6598x_probe(struct i2c_client *client) if (IS_ERR(tps->regmap)) return PTR_ERR(tps->regmap); - is_tps25750 = device_is_compatible(tps->dev, "ti,tps25750"); - if (!is_tps25750) { + if (!device_is_compatible(tps->dev, "ti,tps25750")) { ret = tps6598x_read32(tps, TPS_REG_VID, &vid); if (ret < 0 || !vid) return -ENODEV; @@ -1251,8 +1271,8 @@ static int tps6598x_probe(struct i2c_client *client) if (ret < 0) return ret; - if (is_tps25750 && ret == TPS_MODE_PTCH) { - ret = tps25750_init(tps); + if (ret == TPS_MODE_PTCH) { + ret = tps->data->init(tps); if (ret) return ret; } @@ -1340,8 +1360,8 @@ static int tps6598x_probe(struct i2c_client *client) tps6598x_write64(tps, TPS_REG_INT_MASK1, 0); err_reset_controller: /* Reset PD controller to remove any applied patch */ - if (is_tps25750) - tps6598x_exec_cmd_tmo(tps, "GAID", 0, NULL, 0, NULL, 2000, 0); + tps->data->reset(tps); + return ret; } @@ -1358,8 +1378,7 @@ static void tps6598x_remove(struct i2c_client *client) usb_role_switch_put(tps->role_sw); /* Reset PD controller to remove any applied patch */ - if (device_is_compatible(tps->dev, "ti,tps25750")) - tps6598x_exec_cmd_tmo(tps, "GAID", 0, NULL, 0, NULL, 2000, 0); + tps->data->reset(tps); if (tps->reset) gpiod_set_value_cansleep(tps->reset, 1); @@ -1393,7 +1412,7 @@ static int __maybe_unused tps6598x_resume(struct device *dev) if (ret < 0) return ret; - if (device_is_compatible(tps->dev, "ti,tps25750") && ret == TPS_MODE_PTCH) { + if (ret == TPS_MODE_PTCH) { ret = tps25750_init(tps); if (ret) return ret; @@ -1423,6 +1442,8 @@ static const struct tipd_data cd321x_data = { .register_port = tps6598x_register_port, .trace_power_status = trace_tps6598x_power_status, .trace_status = trace_tps6598x_status, + .init = cd321x_init, + .reset = cd321x_reset, }; static const struct tipd_data tps6598x_data = { @@ -1430,6 +1451,8 @@ static const struct tipd_data tps6598x_data = { .register_port = tps6598x_register_port, .trace_power_status = trace_tps6598x_power_status, .trace_status = trace_tps6598x_status, + .init = tps6598x_init, + .reset = tps6598x_reset, }; static const struct tipd_data tps25750_data = { @@ -1438,6 +1461,8 @@ static const struct tipd_data tps25750_data = { .trace_power_status = trace_tps25750_power_status, .trace_status = trace_tps25750_status, .apply_patch = tps25750_apply_patch, + .init = tps25750_init, + .reset = tps6598x_reset, }; static const struct of_device_id tps6598x_of_match[] = { -- 2.39.2