From patchwork Thu Dec 14 16:29:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13493237 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="lvVKyWMf" 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 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) Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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?q?E4mNwW5lPbt6u9QQjdL4TrWYOGjO?= =?utf-8?q?Q7dxGcM7Pn+n8ZRXAap5ar3ruT/8k31+ROU/qrblyPuGigs/J9YfxubdfDzB4r5v5?= =?utf-8?q?qgra/fevLEemmADCy0p/EcAYgfBmr0+u/7NJPCE7VzfPiql5eAl00cB5gIB0lPZhl?= =?utf-8?q?W/exJutulvhI+kZTNa4IVWHE0OiBilyCKmYOMB32W9kZtR8W7oMHyi3wH+//ldEfr?= =?utf-8?q?K3uJa5CmOYkbDRe7wwruddBDTQEd/xbpovN8w65jR+7dpjPhcA7+9Lo/VGVXyQzOY?= =?utf-8?q?60CCSZ/GJRIdnEDbN9Hb8/nwLwws0TzI7y/nSpePFu2cwkM2ZfxzjRDDWzWYvwKYd?= =?utf-8?q?+WELMpAvU1KZ71D4qKKgM/HtAZDQhlRy6p/lzXOHTwCyScjqnZu8bGlvzEI3KUzTd?= =?utf-8?q?c1Y9zXJ4fuici0EDjti35ZIAEsBxzLtKjAP1yH8ZJ7yS+J4jWYe+fJ5pbRvq37dYq?= =?utf-8?q?TTQj2NgCEDsG1+Iug+COaJIHZD6kn2KB6mGoZkFNi1XlWrzkUlgtFtM25Rs8RRANU?= =?utf-8?q?XGsEEklZ4lccFQh+APnXDcdJe7RWaqc/AGigt76gjr6PoGoRyBKHcZZfl49roT5Sz?= =?utf-8?q?I5cD7pLlVGxTnW7QuJzQEbBfDX9mEaMFn4TIyy1txRluGvtSQNSjjhaE3FAUElfJc?= =?utf-8?q?bHuobUfEN+JqwlOqbHjTjdo/6nebBVLgoSqBZcRA2MTBrrGKjn2qq2mw0Nijupijk?= =?utf-8?q?E/mw3ds8LtObjmF4PQ9u7bH0vEKqmkVQ9vFSUJ65iQ9g+5E+VSe32pHrArLGtZK/T?= =?utf-8?q?8Inb2L94fQAeikKDug3f8xmrH+ASc4CkmkLDYYnFwj9MsI7kbVsAtX5BJc2Nj1AGI?= =?utf-8?q?b3ZdV+bg+VMzwy1iiQWk+GPKQ/JHIeBi+Y3K1JXaPmq53w3MIqQ1TsGBVimTvMH34?= =?utf-8?q?wVC+DfXO11S8e1eHQoKjxKnDKde4sOR/5rqHlMpryd3M1/ZGSwg/P1+Mb4R6+4kKb?= =?utf-8?q?j3ANClF48PTIFlGw/ciGhW3O+vRHe3i6bMij4K5NdtonOBsXGNKIiG33L9Bz+PFZg?= =?utf-8?q?pkdFFvUmRFkDgjdB494LpgBVStwXSfsVgaJj4XEs7PjOF7G+m3tAQXvEE6gNY1rBQ?= =?utf-8?q?N6c84uavwFkZAT/UUedQ+FGtfx2jiy9/d2IT8lx31W59eCqK/VOiukXPlUzHzibYO?= =?utf-8?q?o67Fc6dALwkyY4fuux+SeaFbg6BYvPiEGBRXsDdCmgRZezp+ylxB9MpozkTQ7guVY?= =?utf-8?q?Q9jnT56OX/Z/yizn3LyZT12Dds9Xtdwasqn0HMByHqXvxnoA0usNzffDTwPu/1i/8?= =?utf-8?q?r94H9kUscwp54ozMdg0xkGXjqHInwuF9nGx78ZneVfqmHlkVoDxPIPc8PtVJFUjgh?= =?utf-8?q?JrXQwo9cfEHog0W+w/JMYK33MhMpI7UMyevM+k8RUq2jaf8pFBc5ev90Vk26ZTsnI?= =?utf-8?q?I54WDG/vlTuRaqIq/YrSaA4k9mb5pF/9AGXko4EBhSa4OULD2g4kJzYuC50u/6q0M?= =?utf-8?q?8XZ2uB3f16h8BmXRAkd7XeGfODJbPQaXeFMbh8O6U+G1oHfVsJfcmTGMeIEGv5GrF?= =?utf-8?q?XlSkZSvbueX/l7BGdW7KfZWD6vUXkmKu7gs27LaxHvIjvA0TQcZCqBE=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 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 Reviewed-by: Heikki Krogerus --- 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[] = { From patchwork Thu Dec 14 16:29:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13493239 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="VcEM6raC" 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 3D794125; Thu, 14 Dec 2023 08:29:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LC/GedQ0M8c3vvDrPd8WNx+gHBZq8WX8WUwlEimV0Yb2ZxGoz4sByLa0RY8HYBIz7LeRLBdTpAe25wEj6OCjpykbXo0lb7qjR9G/Lh6TUX0NYO7XXu4yYKWx2bIJjYEFJq1swnbl1HiXK3GqF0elx9bLJcvF32Fs/wfZiK0As/dnWtSYbFkCkOJ7s/AmZC4k9bRiI2Mn1RB7VOBSt+ax4evkAN482dwKYew9iHH2GAKpT1koz4Zz5Y/nqPKBHZ0k5n7a4DlQVxOyfHEt4FG2cKTSR7vvSz2/NKsWjbBfkxduZscM8q/EkFcoYCsEM1DrVkNiZdKLZbFkRc5MYmdfXA== 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=Alf3X77o95+4npf2Xmg3XH0mq/gq3JSYWbS2tW+Hm+4=; b=Rp8AfizAK/cFmUUaKp42wjlhfB/H2egD2pxtbmIUhsE0NH1sg8PzD229ESj5xVXaMSQMi72a0VTpC+v55m3kF/YmOgA6fv+/x+shFEVpOOQ+t3SKODPjqzbocg85Mx86y1N1U475VZBJRLUcBg7VXfqkXhQW5Wkt9kv4Pj+EZVKezp6UEvX6dSmOrSw248qnVUhbuMVtJCFvlbQpmDwt5JgWR1lfoBxVYfM7kVE33kkbHH0540EG5x4T8tefF+mYAMKnyDNlEgNR889azxTTo+MwgP+B524ityEpnLb6bGJTSvwCJv7+meYe/6DgDHWhsPgJA2F7zMSGTS535orZPA== 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=Alf3X77o95+4npf2Xmg3XH0mq/gq3JSYWbS2tW+Hm+4=; b=VcEM6raCuel7OKb81UHkq4EOYCdHt8dFlr7wCkX2UGqx6A+H/5QIZiP+BDt1EXocTHrPefDIPnlIUIjgD/R1cutyTffRmmLMZuqcGlo/vABJNtQ4UvqINqWEfRjaXD5kAXU2KvV43KRfBl6OQAKAX5xKV6OO1CH/l+j/mfLTSMg= 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:16 +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:16 +0000 From: Javier Carrasco Date: Thu, 14 Dec 2023 17:29:10 +0100 Subject: [PATCH v2 2/4] usb: typec: tipd: add function to request firmware Message-Id: <20231207-tps6598x_update-v2-2-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=1726; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=lu6STSMTUjxa+BhbXAPxJC7PhXobLmfFr1D/or+2rAI=; b=RSHvW9zwcGH7+aW/7UCIa4jd5kXjoEA2JuQNqkLNVXbd/4ps3mZSCh5/3he3xYYHGrzHA6FC+ O6qDgge+zLlDIhZ1O+DVsFsyx13IJIPJWke1FWYMnodeLUtSy+pvvEz 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) Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|DU0PR08MB8302:EE_ X-MS-Office365-Filtering-Correlation-Id: 48531cf0-c2f1-4d82-9c25-08dbfcc1d08d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mHBgiFvIdmh6ojZbOwIHJY/TuvJxE6JG+gYPXV6tPIJ23oDoBug1XGPSZtmZh1i6WZWKJAyM7gY/rzM+gMPhKggMarTtNciM3H0iD+JlfOmYnTCYzEjLvQOzQjkSPniHI7unFseOGE9IrAQZCZNQM0c1joZcmqPyPFDr48TKOxXLPHCHX7QX9BV5u2NcQD1MOtE9vVwuxC7J5xf0VvQ7yj4hBigCZ3Ec4cHHSipCd17zDw9YQ2gvZhjPb5dEkvPflPmxWyE83zxTOCNk0ZazB88m2KOAQjzMXI3W5P0IY9WBRJFVj9Buf1mccmU3e+c11eAGhArnMAOds9fvq7K3L8G3AwUn5P8Y30RoDj72f68aJxq/dtSeu4Gxse9hf92gpjnEcGiPz9IvIr8b549+Gj780itg5+60NSb9Jcucmu3RcCof83bOcrNpUzD5aDTLzPP/KdkrnzaOZXp9/33SYfGL/2AQmDFp5K7+915s/66Vs73bllSK/2Jb8UVa0JinWDnQ/TidYnVcoa2uILPGc4J7cUv/DrxKtHYk88BoKlNkEOYubZTHENF2f6XEqb9LW3Ohzu+mIeRzEvbsPSZf3glGkivog+vCIpTxH92jTQ5NYoUds7OjH5LVRIujf3Kr 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);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?wdVxc1nWqRQVvTzBjIVQZ9H3cF4T?= =?utf-8?q?zfvY2cvtWY1sUqXO/U3bIIed99o5jQhuUqD4VREkGKwc91l+rzf9Ar5gjxOuyxL9F?= =?utf-8?q?6bhPv6YLTPGY5bCwj3TKtHQXQi/w8QypaLvrjbBcwNgFZMiS0uFW3ZncenpR1TJ9l?= =?utf-8?q?GatuLrFGCpQiPqkwTJfnacHSeAe5MGHz22hPnJKQZVLprlxmQP20ASavnie7uIYMz?= =?utf-8?q?MAdNgh9HiEl9JMhex31XRVH+RZplsIhvk+RJPnJKqNt1aIfusznlzpJDro2RAIpCt?= =?utf-8?q?tkG30FGfKa2eGnGPNaf152WQlfDSWrp1GnaC4IcQuLXG54NQMeLULf9QyfyBXrcPm?= =?utf-8?q?1V1+lWAT6kY8YTkdyVq9gIeTiZ65/qviBB+KJbNWXVCZFLhDDW5tczuDSzMS1FbpY?= =?utf-8?q?91FFsY1RT2VtkngEbcXEQ8nH4E52itsbrswDRxMRQRPxlqGkn2T9PrNYApZABaYb5?= =?utf-8?q?IAU5u3+cykPvijRzmznG3+66gz+j6rBYSEfToPyxc3xXrQOatBAr6i4jjj4YZyywO?= =?utf-8?q?n5YMFSX5S8smPvnCx4bLIFlW35PW1ZmOZKOf6I3HK2fhIBSZI7xy/1oavrSZZDTPu?= =?utf-8?q?ClEYPKb56sP3afMULnx8/ImVujaShKtvP6qub7YzR9Nf2plJE+Bf53Guzthtww+q2?= =?utf-8?q?1DitOt/BMKaAxjTjKFvcyueEI6Ne5qPolaVyKzZufT6mVCAVG3j3U6UB9IYRdwQ3t?= =?utf-8?q?4jb7KZfLMIVaxBNUikfcc+fvnbbLZy9PZdqjAARdbe6MNdH8VH8XnDfjQ7YGCZFzi?= =?utf-8?q?EcU8N7iz/w60CvjcOK/pcU7XUeuhL4ETt20fyXKAhiWtn2ZnjYnvCStTaxICJ9Gee?= =?utf-8?q?rTD5xHLLrbi0f3G853Ba8byi7UDd1/7/Vmy0DqyiboS5SEKbv60072Rce/pdhmp4h?= =?utf-8?q?pQPoQUf37yoZSLvXcC2SsAG8xQyFqLLD8HcoaoJEStbd8V2ta05+0bJJVnWaEXGxt?= =?utf-8?q?Rlijmx0x3CH0WTH88gLg5EurhDMTnjsNNFVbRI6fFBKBFXc6tXW9fThT80BoLDWhc?= =?utf-8?q?OqXMRCGHcchxX9bC6UwJUp3cf8aQLLykHvKOGVID/D+utVZlxVTiRkHF9sxNcqT3Z?= =?utf-8?q?3185t9EXUd1qfWvUNrq8ScpN14ZRlp3XG6KaxSiwO3i1qft8iVYv2smWE6eoU0QeR?= =?utf-8?q?gramSBpgFwzScnqc/pSQC9nY5dqgMcXQseMFemhdwylbX4GTYQpFzERZ9QnAMUEmS?= =?utf-8?q?Ur+mZ3HcOO56a6Kfx4Trq9ytUHcqCQw11/KvRWgIvMdauTNwi6ypCylO8RFeAbh1z?= =?utf-8?q?xL9jQZ2McW0jGKMBF+sW7dpyh2X2iXvPZ62mKqliMJXLcdpo/9MNHQgkKu75csliH?= =?utf-8?q?FcpBmGm7THe0kzEUUNIpEUmh8QsyyDI130y48KmZpaB9Qc2ACexCFz5KJKf1NbvIi?= =?utf-8?q?HEIZqG7QBmCqGWztrwkE54qvRtT1esCuls++SI5wunpWQ2GpnuuPRzVW757I17gg3?= =?utf-8?q?YZ+T+hQ35bkY+GJrzKnPXpLervW8Ge0bzIcTYD8BLSPvBDh1NeHIxSCkm6PDxFm+H?= =?utf-8?q?VCOnH28nTKZGk/o+XF+kmNpKibMlSGjZkW0pCi6AiDJiUfadRBG0LTs=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 48531cf0-c2f1-4d82-9c25-08dbfcc1d08d 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:16.2077 (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: P6aWcS4NVFV9qzCNh6ULaQtrwrBgBZDIXjQ8nTTnsEpZTCIsfGaGjCMChrpCQjiXLeE3F+OexB+k1eDss9BT14SUw9zIBLxhWFOZg3BTAKY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8302 The firmware request process is device agnostic and can be used for other parts. Signed-off-by: Javier Carrasco Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tipd/core.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index f0c4cd571a37..83e5eeecdf5c 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -873,6 +873,30 @@ tps6598x_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) return 0; } +static int tps_request_firmware(struct tps6598x *tps, const struct firmware **fw) +{ + const char *firmware_name; + int ret; + + ret = device_property_read_string(tps->dev, "firmware-name", + &firmware_name); + if (ret) + return ret; + + ret = request_firmware(fw, firmware_name, tps->dev); + if (ret) { + dev_err(tps->dev, "failed to retrieve \"%s\"\n", firmware_name); + return ret; + } + + if ((*fw)->size == 0) { + release_firmware(*fw); + ret = -EINVAL; + } + + return ret; +} + static int tps25750_write_firmware(struct tps6598x *tps, u8 bpms_addr, const u8 *data, size_t len) @@ -961,16 +985,9 @@ static int tps25750_start_patch_burst_mode(struct tps6598x *tps) if (ret) return ret; - ret = request_firmware(&fw, firmware_name, tps->dev); - if (ret) { - dev_err(tps->dev, "failed to retrieve \"%s\"\n", firmware_name); + ret = tps_request_firmware(tps, &fw); + if (ret) return ret; - } - - if (fw->size == 0) { - ret = -EINVAL; - goto release_fw; - } ret = of_property_match_string(np, "reg-names", "patch-address"); if (ret < 0) { From patchwork Thu Dec 14 16:29:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13493238 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="JnHWoiou" 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 A238711B; Thu, 14 Dec 2023 08:29:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IBxfwrf2kSaIMs1tDY5FPf7vKoF+hStGGxJKfSJuQ+jfvS9DrzRYoiI1Ejsv6lzcT0r50WxTZ7BNGvEDLTSIXPj7fGZgxHnmSQSfnRi5LLonz0neZwnEWr4xe2ZnTf3fFDrOnWab1BTs5+1xtqAxzrbXaecmzKZS9RCcV91WO3TzRhJG1KrgCAUEcFKpBWTsmixvKB9kW9ynQpJRHFkGtAKmjCv+MKIm6yHKabsoAgiDGRJr0HgTwwxbTZjTYp0biBruI1QgVeULGRn5xjn75ak1Nr8zg9bHExcnorR8QXnrayvnKuNpdKl+fE9xSGTyxX4z19O4Y9FHenCVk89ZXQ== 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=9Nbp7KXbUxxTU41IvOZEP4Y+wSOIC/dVuJsy2ah9s2E=; b=mh55u7loVLpSV3fwpXguWeANLhyTQqh4kEmBq4/D1hC2gPEQGYXkwJm2Wq17ccFOTeChE5xWz6OpU5EN+BVbuMsCAoKyDWtlmiZiGadDCriP1nt61MGP1Pl0W/FzjOK8gE7nhZe667270HGA9/dKEs6DwGidD/QpJabXeN46NyRltawUrv7mliPJidJUV3iv9I6Ymaa29dbut3jb99TmDvm+vjQSYrJIBmbGRcUrHDSl/8QZILHIqsNiqfXcal36CSd5kWGkfs8u5mljRzl3OjESmFBe18pfRVaJ7rygIfB0r3Yh2W0GwgW8Ffkq5oqd6Kl3p5e+78JYbrwNbW5uPA== 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=9Nbp7KXbUxxTU41IvOZEP4Y+wSOIC/dVuJsy2ah9s2E=; b=JnHWoiou5Mz1J3nn7mkUlKYX4JzWE2NFfbZtSxUBExTeJq34cjwtDj9EH85FnNv9ezPzEZsuc3WPiLF2175Ndm2us7ZNOSNi2XxVyhSdW7lLNRzEQRGEESMYjpSX9hGGOs6ErgMyWllpsQvU7l6DDGGFEHVm4D9ehY4fL5FzfmU= 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:16 +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:16 +0000 From: Javier Carrasco Date: Thu, 14 Dec 2023 17:29:11 +0100 Subject: [PATCH v2 3/4] usb: typec: tipd: declare in_data in as const in exec_cmd functions Message-Id: <20231207-tps6598x_update-v2-3-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=1739; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=G8jD1YMhqm/GwQuFi+8ybk99Xtsx5Enpb51VaGZhocc=; b=ks125/rMHj9MP/oDOQ4RVolGqp+bBk2Gkt+jrvOZVYLyCbSkJHD7Gb3/E0eKr0pn0JiU7q74K v/jlWNtyGo+AR8PYew9gYCxv+K9zuJwMguB2WJ0bHhHoI1TgCZKEQQE 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) Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|DU0PR08MB8302:EE_ X-MS-Office365-Filtering-Correlation-Id: d396dd6f-1995-445e-708a-08dbfcc1d0e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YOkrW8J1in8njbgWfVLXutUWGWql1LPL4gF7a7fcDGDUWOYvuz0Sfjwm2sKG6GwqNQzp98WAbFZ0rT5xr+8uBtc8eGwzKgWBGdYDazhjFJXj4AOaTRS3okZ7V5O4EerYy1t/Vmk96Ef4SE+OrED9W5rjtsZofXXVriYAmjPhoRy+QDeNA+mgkqZEYVFnbVqPoAejc3qrNJ8H6fBg5fRatf9XAunLD2iaGNTjgqbeVDbPHpAei7WcaJIiKlkCnVsjcjMlpEfTFvPhrKi9Mx2RMjk3T00B2Y83DvUyi0g0DuXobTLMrkT0s3KvFooPxBYciscjTHQAJGMR1lLugnK/msLYKI4fJhENJPYin9KGQEDZgSmgGc9o1anoUuOltJq5lntgYHCc1Zf9D3Ax/cmWR0T/O+x//cgX2L9f6iiRFzna7+1qbkBnkrsk1J3mXpFZusi7+N63n4ma72WrJ1kqsetvt+ztl4kzeWYT6ZDjpxqscozIg0S64qfWNJYMNnkefvrgJ/747hPbyHNT3pgG2hTRmQiwjgIEVxK0GSxVvMLKrTezGqR5QZ7/gjWEzhEVwRgf82Q6IDP+UcZmt3fUOsw9uhVJ+16S9aS6XjcZNNVkC6vCzpxdZTMGZE6Ev2UF 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);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?RNjJTsxJR+POr/6/0ME+0vNGBUU+?= =?utf-8?q?qrJlnYsFX3ieM3r6Q7CTtB11eSLdzEWskPK7QFePtzk3O0GXb5XoU7XOIF04PXA7U?= =?utf-8?q?36qPIA2muPbpFxfhYqwl8N18wR/T8aJOBm/PqO6+vZn+z7Z2qIO3KICuBx6yZ0464?= =?utf-8?q?KQcyOkne4YIbFftbdxbYWfBZ9k+L2KZprDb/+VU8ZMnR8hB4YbwKXb8ZF7+G97vnf?= =?utf-8?q?ZThlnRGOChYP0hAgK/M9A6uVkz6ok6NnkjR7bQFAbh2X6KbYW4ooXmIOGSIRlaosR?= =?utf-8?q?aaGkbPRsEOZxmyVxO2nH39kTj9zyYD+TMxPyoFESWBHDHRPd9AUaJ3H6i9zyPtUj8?= =?utf-8?q?ns4JPTgZbSO2gQldCaZI3XlsyNXK3Cce7SWCNsYgwXQGSHLFDtxYSs92De1Abljoj?= =?utf-8?q?5K6fdSWKu/4+YqgtGWqL+YHnxy3xZBa4EFXZNFNoHRBbxY7j6ZNcLCB5t26if0JfE?= =?utf-8?q?6szsOQFFzkltCZPXZ1lExkc56wt69MpLwbzePdXPte7y/b5JX+jZGR8f0XYWoWlPr?= =?utf-8?q?MClm+pq16+W4LOlBO5LMZl7aUWNs7lFeDx+mR5Wb/zA4bpvJiClRx6p6dPLc9fUs+?= =?utf-8?q?ULRk4YwqRnRYX6fWpnHfsLyu4GDOq5pnc+kSFSyFvBX6wI8UVxnSE6LnqiIvCB/rV?= =?utf-8?q?nkm7gw9/CzIVqdpjsPFPpH/YwLTBrXx659kTWRlI5tu/GqFZYd5XxM22imfi7wBMD?= =?utf-8?q?qgYD4lkK3M4lgXV0irMpJiRMat1a6zm6V4HdW4/fTCzhoSDHmbrPROuWl3ywP5ow/?= =?utf-8?q?te8qkneCLYXTwghahIZ70KCOE2KoXxlJfldyzqVwBAeJlvIUjoISsMJew+1AnruVP?= =?utf-8?q?MuqTj8YaT7tVmU+htM4oT2L/UZ0VWVvsm69D7IhlfBBTQyEL/DCe3CoBaPYQGOrux?= =?utf-8?q?Qqc76stPuLxrzbXpJ2oxPb6QWtpJbceFL1mQPav1NM0N6Swmfl+BEjXpz3GoYjKpy?= =?utf-8?q?aHmQ3avrgP5Uz2J6E+1KM7LrhPYv8roMmG6XYMY5RFNHkZAJLRg7hwFgryINrK8Il?= =?utf-8?q?w6Ya7gVZnNClfJtqBknHHLxLM0pabaruG1htZnvTdHnUr6vuHfmpu7vJ998/ScCa+?= =?utf-8?q?zxgvpjT1SH8DelD+FxgEsVRaOksiGRuZpcVc5pbRstwJcIgeDU3wzdn6QwLnOVg7M?= =?utf-8?q?8V6Pwfs4g6ut0usOfwv+FCZpy7hD0AnGIaIs4Zjkel7SpHwV++nY+dCVp09p4hhPm?= =?utf-8?q?MQe1/C5GpNaNSQWRj8bvpDSn2FzsjaYaKns5GS4z/G6V2MHb7ZJx8H9qrR6DnVPvL?= =?utf-8?q?MTiDz99vmF70VgOvF31RKf2wmBwaDjwldm47ZZxkfe8v21XD0wLHB2Df56RipeSO9?= =?utf-8?q?WoVK0+FCGQ36cNVFTnvt17EpeEOcpW4AC+XBn/OzSOmgAMiBlrF+BVTXzGc47j0g1?= =?utf-8?q?sYr6JNo7iSZjZCDRqrSuweEi2htMnANlO7PSn54KK6CMJCuz4QGAVnRNgWF6a47HN?= =?utf-8?q?z3SOWhUp0k/zQ3JfizXcmwS/R4Us+RUs4L6aBqfZD/lbmUGw9naTRA6vZXLxoips0?= =?utf-8?q?wFADzcizdZKh1NapRXMPcY9KEtazBLshhjeJpHXGrjIXEHCZPAGasBo=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: d396dd6f-1995-445e-708a-08dbfcc1d0e3 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:16.7878 (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: 8gAqaoFCD69lPL89BonTnrsUDM8zLav8QsjB347qJzPG9N8iqnnyZfbF4u+A5y3wW1I9EOMrxufWmj/0QdYF+UwJW6x5Rr5d8yErbvi6dcc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8302 The input data passed to execute commands with tps6598x_exec_cmd() is not supposed to be modified by the function. Moreover, this data is passed to tps6598x_exec_cmd_tmo() and finally to tps6598x_block_write(), which expects a const pointer. The current implementation does not produce any bugs, but it discards const qualifiers from the pointers passed as arguments. This leads to compile issues if 'discarded-qualifiers' is active and a const pointer is passed to the function, which is the case if data from a firmware structure is passed to execute update commands. Adding the const modifier to in_data prevents such issues and provides code consistency. Signed-off-by: Javier Carrasco Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tipd/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 83e5eeecdf5c..7f4bbc0629b0 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -330,7 +330,7 @@ static void tps6598x_disconnect(struct tps6598x *tps, u32 status) } static int tps6598x_exec_cmd_tmo(struct tps6598x *tps, const char *cmd, - size_t in_len, u8 *in_data, + size_t in_len, const u8 *in_data, size_t out_len, u8 *out_data, u32 cmd_timeout_ms, u32 res_delay_ms) { @@ -396,7 +396,7 @@ static int tps6598x_exec_cmd_tmo(struct tps6598x *tps, const char *cmd, } static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, - size_t in_len, u8 *in_data, + size_t in_len, const u8 *in_data, size_t out_len, u8 *out_data) { return tps6598x_exec_cmd_tmo(tps, cmd, in_len, in_data, From patchwork Thu Dec 14 16:29:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13493240 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="F+05H9Mc" 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 3F247112; Thu, 14 Dec 2023 08:29:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BaYnODPS5xUWoXI1a4DTIUpf7Z2rK28FYHWfBbt9bKbJzNsvdaJB4+/Zh0SSD0pgPN7wUsw/qT+NBN7evLGtu0qNc1eCyG/xh1L+53ClXKGQdnEP45omkCnn9xH1faKv8+lHMMrLg7caXkiNZ4NGfllXzYNyet33vB3rE0LH2ypBfdNN/Gl/Gu5ijwmWH8Kz2v7Ur2IEE0tqU7d2DfhjtW02XuDmlcm3zLkqa1XDY5ZOWhY0XyFhcKVCVBE63Uq36a46KsOxC00UNJbVHwAQqnk/LRW+TO6lZ/NLpCDHIA5z+ORKRlrNPOb/rUSJhHi6ZJYksplQ4ZN6X6lavVJNQw== 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=Cfnz/JgogGoqHnZ/PtMvlHqKqWdKHhhucVx4GLaQzVM=; b=KmXg1p+ysLO05n4NLaV/ntJ9gr0PMT5Y3VKGnvOx+4PqlGK2XfBkk9OZ8hqFRE103lol6m+HzNTZgNZXRRDi+YhbROFUuoTAwlqf1VQlhmJ+Gfv2murwzqnVky3qtkE7IfkJkhJ1+2sH80tbk0GjrM7jUANCz3Od3LyHRPlgUSqrAjockKu0pyEky0kiRk72B/sQ6fQqp56ZXqBmujvlJztdooOwzdxK+Xfm6E+srVqKf85LuQdkH0OfsTF+iZ/M6wZmhYyqNidO5cGU/GojQJQQgt8wShdyENvfySd5yjaRLOdLp2/Mra2Lt3x9pJu5dY+RqyFZQKLzD1i/I/HmCw== 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=Cfnz/JgogGoqHnZ/PtMvlHqKqWdKHhhucVx4GLaQzVM=; b=F+05H9McRvg64JGhNPjCDAihi7HjgxnelLBcFRnz1R+pqc9KyWss5zzHhsN1WxAAnL0oJl+plAemeRYLJGNRJ0eZ5zz3ooY959/D9LsGf7C2frYV52qq/yfT/ThVeeqdDG8o9m+KmGbmIp5mc+goLTRMk3DSxDcSYhpfXLDPa0s= 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:17 +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:17 +0000 From: Javier Carrasco Date: Thu, 14 Dec 2023 17:29:12 +0100 Subject: [PATCH v2 4/4] usb: typec: tipd: add patch update support for tps6598x Message-Id: <20231207-tps6598x_update-v2-4-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=4936; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=TVl+/n3421/aHLjJqCJvBtCJNcSNOeLZsG/G74/AoQA=; b=7PymAq/KTkfqBgqFa8DkBWDzirlTkCbae0Q0Pq2IZTw2G3DphN8F4xqr6zh9JgtkkBAAR7ktD fOBF/tDKrJmCkNyhpoQqYJASIrjK+htau5MxosQvpfUlQNB4Nf2jQWb 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) Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|DU0PR08MB8302:EE_ X-MS-Office365-Filtering-Correlation-Id: 575e72e1-30ab-4b76-803c-08dbfcc1d134 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8QzJs+JqFTiaS3UQDE2Lf5T9MQqFbVOxq2djIVUuqVIi9GVYM1NmcB4CBoZDuH1i4DKp/80kciqbTssOeHjJTpsOMJs5LZ07Ayzji7EBJRZVFi5BWjafOnAbexMfRa+lXFxSM5Ol7duomlzvlXfNK3qD5KYayYnT02hWev9ZUkn81Mgwgvu4qJk04zY2XcWgWKyU1WSnjfPdt6gvanx/FLWIQ/zhugQym4YYSInQM7rHpNhSS3dfBbqV4rD7FkR55/x3+/El8UwmnQtRuIe1BKlfhrbKevIXS0wtRP1hE9XuvjJEqYiL94dtjN3bHzuc18jJ6ipCoSl3tlFiv/hxGnQQsIvO8Bb1ZOWHEqrWimKJq7dx+sJaR9+oE4u7ikc5AFBuo260n0sm3kuZ5S5WltVq1neTr4AFOYXS/LrOdPsd4vZVWP1GjLZh/vWPs0+3GUq0uFjKyHU4SY6T3HzSApip9mI8hvmjRRfZqkrxYjZDammGlKhSjCe2r0ZG6zeir4s2uHk+mkO9LLcZReDZnzLHA/sG/8Z3bIWB6HPzFvwnRg2gefcqRHKeDCgIt6Vyhfm+yZc24HVOCoxDY0DZrETEySwt1zqk9nFWBJbKiGInumzSRkrKoNeSqu+7IhwT2kH+h0hMOcpFfbqCCL0rWQ== 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)(230173577357003)(230922051799003)(230273577357003)(1800799012)(451199024)(64100799003)(186009)(52116002)(107886003)(2616005)(26005)(6666004)(6512007)(6506007)(66556008)(83380400001)(15650500001)(44832011)(2906002)(5660300002)(41300700001)(6486002)(478600001)(966005)(66946007)(8936002)(4326008)(66476007)(316002)(110136005)(8676002)(38350700005)(86362001)(38100700002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?MR2J0+4sidVfFybsMGMXRcvGA/Do?= =?utf-8?q?GjtqpgYxGTSkI9x7Kf4lXoHVUWUb7fYSLaC1Nim/qtGNuHyv/Y+xZMXpB+QxIW5dx?= =?utf-8?q?rJ2N7Tn4q1ufWBRy+Dh8+ZXDtB1ch+88liOUCAZMLG91cAAa6mxdCWmYfhL6z+cAn?= =?utf-8?q?DSL8InBgksUkXPDMRjwzgwnzkFWjPwE7v2N83lp8DZ1qW6fWqPtYeV3cNWCfcPbzB?= =?utf-8?q?9/vJyKHvaMwwfMe80lW1a+lbm4r0cb2FFBQVe4wCTQwgt50eYaZSbmw1qsFZTYk8e?= =?utf-8?q?pJHZnaRoPLnRX69ELKjQmMF9V0DB1IXn6uLg9GvJ0WE0m5DUeNl/n2K3g3z1Pw0iB?= =?utf-8?q?3oomr8L2+x5dWZ5dh4sIICfyFUQVBqxCH1MWZBDrQXdVoTX7QpDL2RvpC6WA4wZmh?= =?utf-8?q?oUbHA/p97ww+OFOEEZqk/KcoqZwlfUHDs+plAOefejk7kYo6WCCMztAoLjBrCsG0K?= =?utf-8?q?TpWY9BDpqmrln4ub9La0YOaLfb3jAr99dFLrfqddx/Ghtuqh0eD3Bdim0NMGHCDiG?= =?utf-8?q?AQC1W7vjCKEqREEcKvUe/WmI+b2+wFdRtTgtZ3n355T1XZeqsosAgtU3+mdo8Eo1M?= =?utf-8?q?ZHOi1smQV7IN1KAKnx+6YjK+KCMXdixztIrxIgrCkz2QRl7/utWyFSEPwG1EYRaSr?= =?utf-8?q?0H0zwks9qJq74PFGOKsu2JXNc+iOBu+MoWXpk1HX8P+4S5n87NN+MDKCOlUOjgc5k?= =?utf-8?q?ucM3x72rIsIlAbtp8fwDWafQhL/gZmAoleN6THFldBtCq7NOIUock87rvUjW6Jyh3?= =?utf-8?q?oJw5uiPJV3P6PfPYGTkhvqb+eXY18QfB2m00LlrDjKYffhM65m2P87kohDGnrnHvt?= =?utf-8?q?YzsaNMzhkfJjzTK7zPHoQUJ3dZyDVclluixy1ODBt8qWni2f05b+wW6hZ22aS0vgX?= =?utf-8?q?znGr4/QKsDKCmHiO6G8R9Ifc/eGn+SZhjp9fnxyOrFXUVJCqsqkfyQin6IIqG4281?= =?utf-8?q?9ZSCg4VmTzlptQQ1M4jcR7kYnVTZm4n7fG88BDMCINMAfY6Ygy3xk+gm6lFtwnG6u?= =?utf-8?q?z63c0xOI4MamF0Ldm1M92CTFwPAlBYooi7fYrhTfR7uIy+kFO8QANDeoSkTw9i+ud?= =?utf-8?q?58xaMe2HsE6T5iRL67mRErzLVIAPpF9AgC75x4GKUu0Tx6Ra5Z7f0TjwW8AYdj+Rj?= =?utf-8?q?8cIAXQbZrk+IxWN+hsm3wRrlsGH4GfmhzFawtFbwU8zNNg0qZp0jbIwQO1ycW0c4w?= =?utf-8?q?1hV7k62OaoWux78ufTD58xJa0JEiqjs21xd/tD8LAsXAvMX0nuzUJSQ/dRwjop+2K?= =?utf-8?q?R4MOjOqBl4qkns6JIZ8xrjnGhGpFlIfFxDA6FI5zZnB3y0LcHkc/pPbwKjA/yz+y6?= =?utf-8?q?W5eAwPYQz1Fp/pb4xfN+I0sgLqB+jFrgw2wUT32nCdgh4F1mATFBJ6cHTu2q/2APl?= =?utf-8?q?be1elbJ2vJUwlL0yTMsaUJq29WAzWwByz4ZdhrH0lLCY8tDAcdSXbzaJN9Pf4jyH9?= =?utf-8?q?vhqg7r06nSq+SS0KgPTwamFynvF9gAPFmTJxewPnkICi/v9clL5aT4QSpfyVoWeTJ?= =?utf-8?q?w1QlbUAqTf5xHKNfBaShtIKthrcB3XDQIVhTWHLWmcS/Qlpb3AIK/04=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 575e72e1-30ab-4b76-803c-08dbfcc1d134 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:17.2890 (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: SRJ8HHRJx/+UAhYN9w/LsaFE+QI7qJeb4U4E6qMnEg0DUW5hWYQDLvUsUkXPOoZwncH1YnIVmd7b02bbhCdpxC1JbPofY+WqzuDBCtgRnfk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8302 The TPS6598x PD controller supports firmware updates that can be loaded either from an external flash memory or a host using the device's I2C host interface. This patch implements the second approach, which is especially relevant if no flash memory is available. In order to make patch bundle updates, a series of tasks (special commands) must be sent to the device as it is documented in the TPS65987DDH and TPS65988DH Host Interface Technical Reference Manual[1], section 4.11 (Patch Bundle Update Tasks). The update sequence is as follows: 1. PTCs - Start Patch Load Sequence: the proposed approach includes device and application configuration data. 2. PTCd - Patch Download: 64-byte data chunks must be sent until the end of the firmware file is reached (the last chunk may be shorter). 3. PTCc - Patch Data Transfer Complete: ends the patch loading sequence. After this sequence and if no errors occurred, the device will change its mode to 'APP' after SETUP_MS milliseconds, and then it will be ready for normal operation. [1] https://www.ti.com/lit/ug/slvubh2b/slvubh2b.pdf?ts=1697623299919&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FTPS65987D Signed-off-by: Javier Carrasco Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tipd/core.c | 68 ++++++++++++++++++++++++++++++++++++++- drivers/usb/typec/tipd/tps6598x.h | 18 +++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 7f4bbc0629b0..a956eb976906 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -1125,6 +1125,71 @@ static int tps25750_apply_patch(struct tps6598x *tps) return 0; }; +static int tps6598x_apply_patch(struct tps6598x *tps) +{ + u8 in = TPS_PTCS_CONTENT_DEV | TPS_PTCS_CONTENT_APP; + u8 out[TPS_MAX_LEN] = {0}; + size_t in_len = sizeof(in); + size_t copied_bytes = 0; + size_t bytes_left; + const struct firmware *fw; + const char *firmware_name; + int ret; + + ret = device_property_read_string(tps->dev, "firmware-name", + &firmware_name); + if (ret) + return ret; + + ret = tps_request_firmware(tps, &fw); + if (ret) + return ret; + + ret = tps6598x_exec_cmd(tps, "PTCs", in_len, &in, + TPS_PTCS_OUT_BYTES, out); + if (ret || out[TPS_PTCS_STATUS] == TPS_PTCS_STATUS_FAIL) { + if (!ret) + ret = -EBUSY; + dev_err(tps->dev, "Update start failed (%d)\n", ret); + goto release_fw; + } + + bytes_left = fw->size; + while (bytes_left) { + if (bytes_left < TPS_MAX_LEN) + in_len = bytes_left; + else + in_len = TPS_MAX_LEN; + ret = tps6598x_exec_cmd(tps, "PTCd", in_len, + fw->data + copied_bytes, + TPS_PTCD_OUT_BYTES, out); + if (ret || out[TPS_PTCD_TRANSFER_STATUS] || + out[TPS_PTCD_LOADING_STATE] == TPS_PTCD_LOAD_ERR) { + if (!ret) + ret = -EBUSY; + dev_err(tps->dev, "Patch download failed (%d)\n", ret); + goto release_fw; + } + copied_bytes += in_len; + bytes_left -= in_len; + } + + ret = tps6598x_exec_cmd(tps, "PTCc", 0, NULL, TPS_PTCC_OUT_BYTES, out); + if (ret || out[TPS_PTCC_DEV] || out[TPS_PTCC_APP]) { + if (!ret) + ret = -EBUSY; + dev_err(tps->dev, "Update completion failed (%d)\n", ret); + goto release_fw; + } + msleep(TPS_SETUP_MS); + dev_info(tps->dev, "Firmware update succeeded\n"); + +release_fw: + release_firmware(fw); + + return ret; +}; + static int cd321x_init(struct tps6598x *tps) { return 0; @@ -1150,7 +1215,7 @@ static int tps25750_init(struct tps6598x *tps) static int tps6598x_init(struct tps6598x *tps) { - return 0; + return tps->data->apply_patch(tps); } static int cd321x_reset(struct tps6598x *tps) @@ -1468,6 +1533,7 @@ static const struct tipd_data tps6598x_data = { .register_port = tps6598x_register_port, .trace_power_status = trace_tps6598x_power_status, .trace_status = trace_tps6598x_status, + .apply_patch = tps6598x_apply_patch, .init = tps6598x_init, .reset = tps6598x_reset, }; diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index 01609bf509e4..89b24519463a 100644 --- a/drivers/usb/typec/tipd/tps6598x.h +++ b/drivers/usb/typec/tipd/tps6598x.h @@ -235,4 +235,22 @@ /* SLEEP CONF REG */ #define TPS_SLEEP_CONF_SLEEP_MODE_ALLOWED BIT(0) +/* Start Patch Download Sequence */ +#define TPS_PTCS_CONTENT_APP BIT(0) +#define TPS_PTCS_CONTENT_DEV BIT(1) +#define TPS_PTCS_OUT_BYTES 4 +#define TPS_PTCS_STATUS 1 + +#define TPS_PTCS_STATUS_FAIL 0x80 +/* Patch Download */ +#define TPS_PTCD_OUT_BYTES 10 +#define TPS_PTCD_TRANSFER_STATUS 1 +#define TPS_PTCD_LOADING_STATE 2 + +#define TPS_PTCD_LOAD_ERR 0x09 +/* Patch Download Complete */ +#define TPS_PTCC_OUT_BYTES 4 +#define TPS_PTCC_DEV 2 +#define TPS_PTCC_APP 3 + #endif /* __TPS6598X_H__ */