From patchwork Thu Dec 7 11:51:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13483191 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="xsJAimzX" Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2064.outbound.protection.outlook.com [40.107.20.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DED0D13D; Thu, 7 Dec 2023 03:51:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D0hgflg5McTaRha/AlwLFK7wa9RXzMQLFnhTlzZtbANQSh/nA0PWmHqdSUsrdbmx4vWbMtGnIc0aw8xxhqb/ZG1+9KfX/Og5GYgjQUWAXmSLD+ML+1BBbKFpNRTiuJfrsKzKslbR8kET6T6Ja35IgowzR3E5Er6nAvva6lZDspAOtNOAwakUNAG/0la7dMda9T/fS6BNorzH8x0lxzqQdFjjwFyzZLufK5fiZPOknL9FBMT615Y7F9OIQ88COxhEL2l1lh6N4dpDIWJ95OkPdr7VfCHoLh4BXwAP7DhyXDA4kJ3dwqxxoMawpxZbI6b+qKIsVRmZeGlL1Wz4tBfm+A== 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=lH4PvKWA0uv8aoPcyIvZmPqHyY7A0XunllI4HhK1q5gmQoA8XpVdXxy7gHAcLH1cYf764DTMserNkcyE9mBMMQS20rh+v9aWtmUupd578PkkWwta1QugabGu9dnfFV8EUnev+4IRF1griYr3VF8w8/mT6d3dTeMuYc5y1QQdd8GTPn4gg2sRB8V2jEtALo060eCe+Qo2oEFOsbMcqbXG9W4kgCYQZVriceFYU+VIZg2+40xtSnPp1ZDQXNsOcapPPDYk1QRxv7cende3UZrvpg5PDAI3w2Fdemdq6fMDNneVLlpYafLnQqDMZRdMIqgaZPuypuRH1FnHEABZDVemaA== 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=xsJAimzXQ55SN8sYh427ZgPRUce97CBahiVF3A0U64f0jCSRRLcL7JbfP65N+z1yXYDQsCAz+I4bm+GtXbEGnf0zgzoesKUoQzORjHnzmZQvIvjIuL5kkKAhRHhW9xEaetAwLu0Gt0TIIgz3qZycxADcZVy9GjY9ZdyvyPm0Yw8= 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 DB4PR08MB8054.eurprd08.prod.outlook.com (2603:10a6:10:389::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Thu, 7 Dec 2023 11:51:13 +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.7068.027; Thu, 7 Dec 2023 11:51:13 +0000 From: Javier Carrasco Date: Thu, 07 Dec 2023 12:51:06 +0100 Subject: [PATCH 1/4] usb: typec: tipd: add init and reset functions to tipd_data Message-Id: <20231207-tps6598x_update-v1-1-dc21b5301d91@wolfvision.net> References: <20231207-tps6598x_update-v1-0-dc21b5301d91@wolfvision.net> In-Reply-To: <20231207-tps6598x_update-v1-0-dc21b5301d91@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=1701949872; l=4687; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=uuzBZoVgbfJRVw/uB3TAQ/14SQq/Je6fi5f+9uL7q9I=; b=Tjnkl8FGz7MALGsw64W3FrE2xGXZgF7q7SP9ZAkBDy2kYAJpHEd0nJA3D3Hg5IHX74lUZTmvO hJb8w+UZAuYA7i41qje4kkhIKYqNra7DcdARxT+N6cV6CT/R34rofB3 X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR08CA0248.eurprd08.prod.outlook.com (2603:10a6:803:dc::21) 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_|DB4PR08MB8054:EE_ X-MS-Office365-Filtering-Correlation-Id: 4a300ac7-1023-4cf6-6901-08dbf71acfe6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: otga8B/eBym2dD76zNAxQrSx1hp1oKTkgqmuRYkEKTXry8g76ccUSL0bIKrwHU6nVluzzXndr8ngcwCdlrF+kZJbAIWQL2W5+JUYRcGi+4Ku/VgWVURW9aZnWHhvD4KVXvblpYI7aaUUwsaAPAM/22jU7eW1jgx+3kP+EAI3BeRh1yoIXtgX6A+9bBBlbd6DQ9ZQjIY+ZarmMAcjKZywu/pvFdC2Ccr9TbZvF0SLm/eWgsF474eWJcRCGpp6MLFymATqO8N01HpipY0lnZbvWtaDyqV9K1bnNd7HGIezqLOqqDAO5UmppGRIqtXpEtRlRbc49wTkSWP7rRYQ+6JnHu3GpNnI/wntj0oC52i0xCKTG+Dw29mPVqgot4ALNMbaDZEqatI5FzLbqFz2DceV80yqBHKa2p3HWaqT7ipp7IqzihUGeBC5B53Hwn3HiKWifxqVeFnbH6pF+rmm6z7Cw+j2VUBzaR5ph0I2c1sdD7cMlDE0uWQLmlgGeAc+dSAjE9LXlLCwUeUUx9yKbZquyz7lJk4nv6jVnHAWK+sZikJL21dBGNKvNrLX0d9IKQ/GzR7roA3WyTovFsdVq5MEo1sr/wCFsPS2RN39WwcOaig6sc+sQoePVnfBfjzZTat4 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)(39840400004)(136003)(396003)(376002)(366004)(346002)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(52116002)(38100700002)(5660300002)(38350700005)(2906002)(2616005)(6512007)(83380400001)(6666004)(6506007)(107886003)(26005)(110136005)(36756003)(6486002)(478600001)(41300700001)(44832011)(66946007)(66556008)(66476007)(86362001)(8936002)(4326008)(66899024)(316002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?EQ3LtIBBHoSXm6IqrPVj5XRu8PfH?= =?utf-8?q?hi0rs8AfcnZ/rBUu6hX9zqtbgx/djqYbdHZKBfrEQk1CCOulUO/E0YQMVEtbFh1B4?= =?utf-8?q?rNXCDTSnDhk6jix2LeBvwonmruN4dT7bp8FQRr8tzcMelhjnYwUfhF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q?iyysm7+I+DpIqMZjoqtMf1SSAEjovRZZWgiFqhh39iiNkihumy5HM9v5+iI/TyGh3?= =?utf-8?q?U8MSr63Qm5JO6eX3JWLMY1mcLdCXXvzgqpGUTh2+RKuItRNJu6+uzkjZ48sk8/yic?= =?utf-8?q?LKCO063gTPp1tKct5eHQAr9qEuQdCL0gEA/flHJbWIW4955Ahi5NB8SXsVyZvvYFB?= =?utf-8?q?T4tLB9ZsDb2Z70hJh6wbx1sj6Kb7WxfywW7fIepyYDbilGPdPvs92+BNvPAghLZij?= =?utf-8?q?Sciu6vc9Pi1U+TQL/ILozG2O8GZX9efvdlXApcSwHMVhhbFi2cpCDNxYoyCrhYQEz?= =?utf-8?q?Llqb2SVXTq4RK1huBs4fOkNzZNGA9x+MjzwXakO7VaOvRpZazswa+HUfpC0+NzP2y?= =?utf-8?q?JJkP5g0L1i9mCV+PM2S8Md+p/xE+/DZtsS2W+f7fin7NcVZ6noV3N5g6ld3urhHNJ?= =?utf-8?q?cQOL6bhvlOJz/c5Z/l8wWt2RSalejfRknHkQ5skHjtDOrhj5s9sCdOXbSTyNSlsKj?= =?utf-8?q?oKpv+XHYQQ8d4bFZK5n1Nrz8YDT/3YoEwozM1ivF+5hOWVbTmv1+O9s=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 4a300ac7-1023-4cf6-6901-08dbf71acfe6 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2023 11:51:13.3313 (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: HgGgmNZ5atsQ2e0wanZcB/6zCkKs9kdxCbu1+xj8vTQab+zDdZgl5lApsG5ma0pjCSMM+rbgFfLeugOuX4CDDizG8TQ+2TCagpkxjpBjPWs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB8054 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[] = { From patchwork Thu Dec 7 11:51:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13483192 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="yT73oPMJ" Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2064.outbound.protection.outlook.com [40.107.20.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51D13D4A; Thu, 7 Dec 2023 03:51:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EVAk7iX9ZdNiXQtln7jLgNqgGtb34MAO7F6OWMqOeG9EffhnmUORAQU073SKcRgCDEjGEuRSxFKnIz0qEc68tpo62XS/RpmfI+R90y/PlJOEjG4RM3sSw92zZuFB0/4N94SWFfLPiQJ1yLJ7P0eMK00CwntxNo86GVeF3b5Uy1Aqs7EWSPstiqRXWuM1c9M7Uupk46JQEnV8fymoHjWlNs9Y7Tul4H2jTJGDbITldIh5ykMKbRxWWzxgCHSOkuOSEHBynI4LDQMfVyogByQBIPF1g4uQDbsaiJ1IYH/tFMzvXGbqiATeCykykY27/YX0FxCeRPXCNRoMAGxss6hbeQ== 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=XOVUwsCdesOAxIwKuBpk7IheoIyYIMKYs3+/KWhnNw8=; b=J0FXJkGwiiq9hsNhDrxkipH/JVLJJDHAANLJAIiJv532WiYbsxFDt7JkyAhOLo6eOtf91Cg5fmHgcHOCNX8t74QnzdgvooHgoC5Q6+/CWzZrNaDdMFqCYv2GyxHLnCSXTg55bUCyEZjWA0s5oD00IBi0G7ztfhj018EJN6yfTb+dRAIKaehF483K2ojBEoyje6ARjYHYsrvtk8HFrc+FriL/LSy7e/L++2ohge1P+IRtefAuyZ6ghSAMFTSbeCXCxLgRIkTTIs3ugrpgIaBziv20ihE+zqNXrl37qISPC9ZE7NvygGqm0mC5atutFyOUrHeSE5gUDXhNi+z7B987Sw== 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=XOVUwsCdesOAxIwKuBpk7IheoIyYIMKYs3+/KWhnNw8=; b=yT73oPMJmwnzrlNd9y97Wo05beUTMeBsbGc9Gh9mgCS4I1vtgrko2uKoLr+skYQy/S0cXJhXA3eYjB4x5D4rsuAQKra0ljqjga2kNKOIBGYxug2y3zyqPTdO2WEZEo/IAHBTK/sZaSO/DN1iyzlZzyPRfh5I4YlwIX7Xpnp0WxI= 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 DB4PR08MB8054.eurprd08.prod.outlook.com (2603:10a6:10:389::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Thu, 7 Dec 2023 11:51: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.7068.027; Thu, 7 Dec 2023 11:51:16 +0000 From: Javier Carrasco Date: Thu, 07 Dec 2023 12:51:07 +0100 Subject: [PATCH 2/4] usb: typec: tipd: add function to request firmware Message-Id: <20231207-tps6598x_update-v1-2-dc21b5301d91@wolfvision.net> References: <20231207-tps6598x_update-v1-0-dc21b5301d91@wolfvision.net> In-Reply-To: <20231207-tps6598x_update-v1-0-dc21b5301d91@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=1701949872; l=2038; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=IiE6db3v4YrX0nZYmhvzOKALUG0QQqEAuGZEbigpqME=; b=TrqZJpl0BlUS3GCONO2c/i7kZj3SUO5wEvD22r/kf6tYVFUoSEiJPOPzy+1Exxc2c/ga9xIVx PP2PCmGyGO9ClSBkFbO9YcDs4YxKGTSzxGDpIFKz8PXTDmpzCpcUX/5 X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR08CA0248.eurprd08.prod.outlook.com (2603:10a6:803:dc::21) 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_|DB4PR08MB8054:EE_ X-MS-Office365-Filtering-Correlation-Id: b890cb81-ad2a-4f87-8d18-08dbf71ad02b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Fw9m00jCwL73MpgX/9RSdUSaTWjpW4xNNUntMDtGmqvL5Hh6mcTRfN08FurIIOOZEUctP5mGApQvClHNVvrHsNAbZCXv57r0eQLgj531jnqqWmLMYRzXcQia8XZqWtlwBRTC2DRSm1jsY2EcgRfoVS+HGcMS89K64s1H+XVMYnW0aCQ7XN+Uz8NzFmIsJYS/jpEGHUVbjoskz1kWGrntg9YKCI4xiW8jfOUO4DBZc0c0o7u4OKrxW23PewrH9AE37z12Pew0xbEK2GIZGyG7peM0rp5WjF0lLjj6sZkqFGd32eaH9AKsIXfT7hhNb7kkKuv1lGasRBKFmEkFEWo/+BNfsh9e4CIAT9ZtJX51h8Vdx2n5ogotlRqe6O4RA6DxeC/mqQzlqESz+KYhM7/F2W5OosdevGIqC+u8SWTtDvYMUQJnW/pAfaOSpVu0D19UT35jk7p0mFT1Ta09r+JF4LY4pB1ciVoKDGhqW4oJ33u7l+7VjI7QYvnFOwxDfHfVm2UmxOXFHF7Ke4RDvjhLYX7j4VkCII7RLkTE3ASL7Ha+mzsM2pemVz96MzAWsth9ck2aEQbSz8dkjz+8NPVAdb8rpp7FQqPgZR/H90YhihIm2z1xjWF/wkqnGtHDfbeo 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)(39840400004)(136003)(396003)(376002)(366004)(346002)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(52116002)(38100700002)(5660300002)(38350700005)(2906002)(2616005)(6512007)(83380400001)(6666004)(6506007)(107886003)(26005)(110136005)(36756003)(6486002)(478600001)(41300700001)(44832011)(66946007)(66556008)(66476007)(86362001)(8936002)(4326008)(316002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?nUYz1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cjF0GIPo41RqlUWFXux/?= =?utf-8?q?4TMGV/PBNfYJ3pGdymJHSlVSi3OOwC/cWEcgmU+m/LkRIF1d9XF5WifYIsNJDYHad?= =?utf-8?q?QjwM95FHFfaR/NVXFl1mvnO7/n1eEPWUNW/I3cYyc14p5XThDDbRqTnvUCwKLJgQx?= =?utf-8?q?UdOeYkVoNlnf5yz19yVXDZqS8Zbf4DAdUed5tlyAO3KKf1KRax2Y5DDTSnUy4xasm?= =?utf-8?q?kQJxd6OwWfoQoBpXIYo5wgwGOSqelXEGvw7+pkW3+wUPwR4y0/mbDWPjdFgAT0d44?= =?utf-8?q?kOEUAhexjsR9iJeDhkyZogrTzcp3ZuVIABA0bPt9ac+bEwUt7bUpZpZGEgecZQse/?= =?utf-8?q?cmQN4V1tn4RTMx4HBkWv30aSKkmdhb/Eo9z9vJ1kOvCer5IMgxy6toHAkCnJtav3S?= =?utf-8?q?nfax10lXgUKrOBKJ9yPTSjdUx4icwpWIPYO9JAfZRgHNY7egSwzUaTpDX5WX5V7xG?= =?utf-8?q?c1Ol2vJjvc1Z5ykvchXK7hyetr4l26aBRz3z9PfAPKcljRebnfyeWbKIIynFjMw3c?= =?utf-8?q?TnhhaZZdjdBq8O5JgZ/Av5F6Fd/KeuH/ko2CJR7fXMJH4usHZZ2xN4xm+HePjx5+R?= =?utf-8?q?LO8nb8jlosUQcmw/2TaxgTar2zdEI19zYWfXFAGM2ux9P+Wrpae62FvMSCE0+tOWB?= =?utf-8?q?XLQUzet9VNhmuAaD4BEQ4Z+phb5O1omeaptzM4pqBtRTEiiWyJX4KQM=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: b890cb81-ad2a-4f87-8d18-08dbf71ad02b X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2023 11:51:13.7891 (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: HTCWi00nD4a625C3drVdZs+QXipLfrXZG8Jqk0hO6sQMiHj2PtMK2eekLddUGwWHSwW3iolWzy1jNv+xPxb0ZtowvgucvxWFrDx6rfJiUmI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB8054 The firmware request process is device agnostic and can be used for other parts. A probe deferring mechanism has been added in order to account for cases where the file system where the firmware resides is still not available when the probe function is triggered and no firmware is found. Signed-off-by: Javier Carrasco --- drivers/usb/typec/tipd/core.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index f0c4cd571a37..165a1391dc72 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -873,6 +873,31 @@ 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); + /* probe deferring in case the file system is not ready */ + return (ret == -ENOENT) ? -EPROBE_DEFER : 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 +986,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 7 11:51:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13483193 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="SWqaKI4A" Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2064.outbound.protection.outlook.com [40.107.20.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 908C019A; Thu, 7 Dec 2023 03:51:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=izb0lvQ/x/16ob626iW1DDuFCJ6gC3jjY20/ziRuXC9JsHszDTbwk8b98SojWFr8yw0DbaoHqC675MeZmGuQ0jc8HZ7IKH0q/iSaGkV9TwW/98twxcFeoSwCdEtJAPdIF1w6Nnha2RcpsbSKrNTUGfjUsXVCw0FszfyMInK4nfYuULz/65FOl0gqe2CmZY6fgTPJK/LK6X5u92PDsuYVcSOHKQG1/gHq+N/79yNdefigaZf2MkZQIB0B8ZcGHUjuewEAB8hQHw9WhBz/i9d9HT3zQxH5C0RQppbJM3SGxIFjgQTAXWUJLYv8I9EOQjcmLuZEMTTXz5Oj3q6/xR7e4g== 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=qmn+xRnKSGtQIicZhyD/lr/8Jjsxgyoot2OSa2cnruQ=; b=gG5riPDyroX9S90X+3MhxuNb64ukEfx8q8GOdFAt2qSGExzFzpDFeHNpnWzrNmouoWXvNxWW2Y2KwVwYF68IUZZRaU1NkbFNeFJkmli9q6Na/pnQ408ZSszN7l7xoKMG6V2o4jQEtq/WgDK2OKGMfnOXZM4B61gpBZKYI7Je0VziDJ1lmtcSL3Zt/pjFMk7bKYZ1lu9VruHTwKCv9ERe+qVE4VGC1OoBd8oWuviyxEynDA41MLAAes+C8dHNaRD68Kausjs4LFAqvvVZh/+vFUvJLGoKPvVFMTvzknbUsXmNYcquyYHVfub5FC0N20OtPpox6HEvMDj8Ws0z4sKq1w== 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=qmn+xRnKSGtQIicZhyD/lr/8Jjsxgyoot2OSa2cnruQ=; b=SWqaKI4APJMe2JmHdK8jhA1IVlljxYbK1HHPQu21RkCTr97ltyd9MWqBin1ooZTRUEvfUqlNgvPBF0/jd0vLRe19iK9tHbexBPJ+vVThN0wSx0JGYGm66OtB+IebLEIv8a/BRwqMFuNuy+ZWEJb0rbVVQNGOo9KxGMPULRhirA0= 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 DB4PR08MB8054.eurprd08.prod.outlook.com (2603:10a6:10:389::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Thu, 7 Dec 2023 11:51: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.7068.027; Thu, 7 Dec 2023 11:51:17 +0000 From: Javier Carrasco Date: Thu, 07 Dec 2023 12:51:08 +0100 Subject: [PATCH 3/4] usb: typec: tipd: declare in_data in as const in exec_cmd functions Message-Id: <20231207-tps6598x_update-v1-3-dc21b5301d91@wolfvision.net> References: <20231207-tps6598x_update-v1-0-dc21b5301d91@wolfvision.net> In-Reply-To: <20231207-tps6598x_update-v1-0-dc21b5301d91@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=1701949872; l=1739; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=EYKG2QkBt3Q9Z4VdE6eA++VrFA30t1cRvwGmQo1q76g=; b=5JVDfkXVegF6CIN4hukYujw0bL4v5DcLfO+MTuIQgMQM8NdRzJgWnpIyTFqr7w2OKq1yhPWNf yCM6XD8543ZB1Z30xxCSKbWvelha1z50OHjHLVftXVxsSobrC2mmpFo X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR08CA0248.eurprd08.prod.outlook.com (2603:10a6:803:dc::21) 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_|DB4PR08MB8054:EE_ X-MS-Office365-Filtering-Correlation-Id: 11f2c7ea-5d21-4527-75fc-08dbf71ad075 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3fPf7PXstu/u5jGuW1bUcprz7uXc11inOwCt6yXMcDsdYqfiP3ERMxJ6fy7LGm9RrcSlhbb9ByWFW8mDLUYElwA2Yo95nNv92kVqB9yfhofQ/sM8wIuhbY/wPcNTdqTyU/EnA+uJsG/d4FPqh1563vVPlHqixfDpZx6jMm96JGPS8u/S7QWMCj47t6BTQ1SuNRALs6tk/NApE6slidZmw84PrM0ye9n7Baz18Qv/YjxzOU78Wyd1no+EHTx0ZVi6tVAmJYGi/JwgNYiCm7YPDgNavjSA5vVMVpx+TQ6CSoGXTChoK5sbC+lG5SLiAolwunxXUdA1afa7Tybf+z9ml3UgneRLzebh8zh6Q4ecMWw5z9ZK7Sm50ICRN+VlcHi9T1822CbTIsleS5e1MBbV9sAFYsByQ7TJK2w/pjlvtvVneQZMfA76V4ZxMLSVWL0IQuHYvYDM3eXOXxXnABL+iXOy3nOOPeuah0QQGlOF4QQCO/ZXkvnGX/V1wmSyPrxHVACw9jHKX+Aue0mJHG5kBvvffFU9SH8neblWsMZn3waMckzQmUMveD/wLUHQPWAu9eYo5QinUg+5u65RUNh7k+6vG4BYGb7AuKfIwEvRpMHpcVptN04eRtO/eAj0+uGb 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)(39840400004)(136003)(396003)(376002)(366004)(346002)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(52116002)(38100700002)(5660300002)(38350700005)(2906002)(2616005)(6512007)(83380400001)(6666004)(6506007)(107886003)(26005)(110136005)(36756003)(6486002)(478600001)(41300700001)(44832011)(66946007)(66556008)(66476007)(86362001)(8936002)(4326008)(316002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?S5xP6W14/h/icyZjDYPTQT98A2K2?= =?utf-8?q?zYCOn1/Mahhz51VNBPhCntPRe9FZ+t8CN9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XKyHsxJR62JFfSVeNn?= =?utf-8?q?INULcEUGCb33ciL8oBX/r/k9wRmE6EOM4LlhG1yVEeoT5+R0D+6JMjfFVVApL9vlZ?= =?utf-8?q?vTANCSzg3gqMNHcO38RPGZZW1vuPT/vBDvMdHWqJz6BrvmDGsEk0Z6KewqUGDMMtM?= =?utf-8?q?NOvDmdo2/ATgSlaUbBhKZDEMJikoBycejobqJdJfWOjKYLSqMecSUXCEDF7hHtjJ5?= =?utf-8?q?49wo2ziwpG97hy8UUsoOc2n7hn6OJ0nHWpxwD8ryCzValFv+7BB0ct4EL5y7WSy7a?= =?utf-8?q?3QL/W+H0mr2+DXIzTdHWEbY6tMVHYDIz6tQuep4IzgbtmtF3QqzmAllHbF10eFQRA?= =?utf-8?q?9ebC2zUX8Rh3KAoxKjAbMYixZDbFBlYGkB+VFl2Eg0CSn1FZ02O6boVjI54xnxOGe?= =?utf-8?q?bzG5YzY7g+52nsUIYk5fAy+qYONEbEpn3d976cjBzXSiSCnbwKseGiLElM6RvhsJK?= =?utf-8?q?PacV9GRCFYx0y0cawvPwdqrdk8yCXjLK5BMg3PElcbdp/TysT1Sf3qIBPZVIM2JxQ?= =?utf-8?q?NDH1QIl3yrtGForLlgtQuWpEKUKOTiw2IxrS3cjlBSNV2OUuQBGaihr/J5nr2yKdX?= =?utf-8?q?CzOCvepPGOmV6Y2Fd+9wsyF4rFLjlAHNSGr01Nvfdu/8ceWMh2l8WQo=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 11f2c7ea-5d21-4527-75fc-08dbf71ad075 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2023 11:51:14.2591 (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: CpetL/K0PjQMRcgRwfRIqXkiRY7NvVzsiee9iNsmikvlenkpzmW/ggJxFVfgMAujR71M+gsomYXMMj19slePBiJpAYNrFR9RYO/ng/5Faug= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB8054 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 --- 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 165a1391dc72..cd5214c9799e 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 7 11:51: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: 13483194 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="PLF9Mv+a" Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2047.outbound.protection.outlook.com [40.107.21.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DF97D7E; Thu, 7 Dec 2023 03:51:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IDd97ELvn/bRO0pbasXmFCyQoaUitjw5Jjv9w5vazop4tijCLG/KGfcKNbZ5JqLCGezF+Op63y2dCQVWq9P9Ddq8iu1xBhcHbZapLOSJVhqwiGo4gSHsNebnGR3Cxq0J9iuEDurHibuu+2VTSwovg74bdSXV5KJ2oAub5H5u+uoN5I9Da62/hvvC47CseX3M4wny6a+/JMkmbAUmWXEE7HBVXAELAMd2dkzNWtfPFsJU2GYKoA7xXXi9vwJCzMXrOZ7gLtHKgT0jE8NwIDM70umJqAVEWG4ercO1zs6tc69QGxG8ddZMYa1J/g4Tinoypz+P/fsHrudZlClyjPNacw== 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=cujQEzVlmkJFha8J9PhqlxbUa/4fk9ZOlxsXZrOBJeI=; b=Qxip92iUPITOJJMplLnw2e90byAeG9v8QGIkzI/xBSbCxIDAhN2BBnrgHgO+jURPe5Uyd17qjyhh/mI5+ITiknVEeiBruvP7fq5yMo1Egxw+CoZId1YEGdQ3y1OjfBQgSy0dxA8ViI6tqL2rHXQ6PWQ2Z27CnxefcOdY9ovhWODXH21kLCuP/zCVe3G+jQvTsHpjEnQ/5+C6xaK/PMvfBdOp1/877zaFi6pnUFI6arR8/ndG+m3OhT1OA+dcq7CJ8JGw27l/G80ygZTe0bkB+G6sdlJqTQne2Ia1iN1Ul42vBA1BeQtjE2GEB4ejJR76RbRDq3OTvk6mWOeZt7ST6A== 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=cujQEzVlmkJFha8J9PhqlxbUa/4fk9ZOlxsXZrOBJeI=; b=PLF9Mv+apyItWHLBikFpY5Nf4a4h2sb4NWYwZxebatFuK6nMDbTIWKTrNCp2tfM5jycrCFfTR/XOp9ZBuIneNrqvK+1Di4MJxqVNPx/C0D6mbXSj2qOAtnnUBkVOCVbh02be9mooIn7FQyqw6whQsAhEUCCWdRS+7Kwaz9j3WVg= 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 AM0PR08MB5300.eurprd08.prod.outlook.com (2603:10a6:208:18e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25; Thu, 7 Dec 2023 11:51: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.7068.027; Thu, 7 Dec 2023 11:51:17 +0000 From: Javier Carrasco Date: Thu, 07 Dec 2023 12:51:09 +0100 Subject: [PATCH 4/4] usb: typec: tipd: add patch update support for tps6598x Message-Id: <20231207-tps6598x_update-v1-4-dc21b5301d91@wolfvision.net> References: <20231207-tps6598x_update-v1-0-dc21b5301d91@wolfvision.net> In-Reply-To: <20231207-tps6598x_update-v1-0-dc21b5301d91@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=1701949872; l=4936; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=8PtfpVXXJlDFboFn5Nrw8L2jU1tK9s2cmm7l3ScqDZc=; b=NK9f4hLXyN/Odj8cay2BgA+lhDxVk7Rld/H/LBDUvq/122FpQ3x6uiohnXpQkpttPO1H9/BtY 7kKfnEiuxP/BKgvLCJc9ggsUHXt0LK3mAVtPjsPnNv3xSKvJcafo2Y/ X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR08CA0248.eurprd08.prod.outlook.com (2603:10a6:803:dc::21) 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_|AM0PR08MB5300:EE_ X-MS-Office365-Filtering-Correlation-Id: 9cf6b13d-2e9e-44a6-9a05-08dbf71ad0ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qhSA5VwMMADqesAzpR5j5PaKRfEZ3IyG10KPdmLE0kF+PCkwNG2Ue6QhCG1WSmILdON/bSz+Q+hUUDHsIYXMoA+QQu5OTEMiNU6LYZ9m+ACvxilOINAXJIaa3EKgJIEqM/6ifBbQkKE5PSQ4QKFCfPPhmY8J1p6W8p137TlzTkf7pzzFu4lFj/Ml5iPBcl8OO+9Va3ZPpUIQOHZ7PplP0jZyT9ai2+fKYb1QxrMQCaFZJ+80jrow3iyiMhUtHzqpsfAbtI/TmpI6uZHx7pTglnuetd8kLEHjj6vEUQq8cUw0e1832iARJ0B13nI2b8tEpDfWtj5FPqRAqPUadSIsV7d+Ox+AlKQ3pk4/GaYI/SjNRBJE7kGq3bFwPt8Idbqc9gvoVngoekKVjtKt9EJtjrWRAy7UMg5DZJHA6WIoPdKSZi1IoQUSif/BZF6brQbZNe1cgM4s0sGKp5ZRtA2nDJpAZ7eFoJbYG/IuETOPSUVaMf8xCgw+KQkYl6T2izz/hR3PK9ZItj+VlSxCknYcmzEjsZH40yxBb5Qx72NsWt71R4MT8I9MNZPzGnflZ2RB+V6F5LHGsuqFX2kynv701W/uiivTvU4AoWI7AKcTU7aZpwNFgi1SsllD2VIPQV6FKOKU0buGzmhkUMR9QnLBYw== 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)(396003)(39850400004)(346002)(136003)(366004)(376002)(230173577357003)(230922051799003)(230273577357003)(451199024)(186009)(1800799012)(64100799003)(41300700001)(36756003)(38350700005)(15650500001)(2906002)(5660300002)(44832011)(6506007)(6512007)(6666004)(52116002)(107886003)(26005)(2616005)(6486002)(966005)(83380400001)(478600001)(38100700002)(8676002)(8936002)(4326008)(86362001)(110136005)(316002)(66946007)(66476007)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?gObzfV4KBX0eLDwA8553DuCsiQw5?= =?utf-8?q?3kUcCye+fzfBZDLUGc20DuuaPeqdBRJ96ZFv9knrYOmft9qSNLYzY4wB4y6b9Rj43?= =?utf-8?q?zzEa0amy+FoaUDqLn/z8SkpjPNcBGHZG2MnoWtrebKnOHqUC6TL8zSsOXJG/keJGo?= =?utf-8?q?ZQ/vOeYq3go0xG1gh9IucsdpfVVVyzxlv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GKuOoLZGSWm3cN1gtgHRmxxbcJt1u3ouOVzAM?= =?utf-8?q?u+7P+x2PXJz3Vn5PCq7w1Hu274/whNhlOTntKI+bNdRKqroQQ3FJtL6aIve7OnbOl?= =?utf-8?q?UbxCCHSZxSgeLEgCB0mf09qBtG1ziyzeWv/5OpwAQumq/GAjrF3H0bQxweVLgVihO?= =?utf-8?q?I4JX8LEXsSqJgcP7qXkcXmH4C72ajs+HvYjtyfavP3xjlzU/xrkmFhdhWp5JV0Wcm?= =?utf-8?q?V7TKunFiIcvAsFmlDWyUQKwUYHP/j5yyECiRremBoiSSeAteOauK0ymokWBzVMXke?= =?utf-8?q?rNbXT5aXsFr9hx966P2sC0GokKy0rxhjRyO4e0Vxr51fuhxdWZCbRSlLvb/WufCb3?= =?utf-8?q?7d3YT26DIQ6+GrC0gTkU3EtFP9g6fjyra7r9JFifK9vKZLvWTOQv+RD0NN5OvQIu3?= =?utf-8?q?MB8/rFMdaK3rRMQ/lyMuX+0aoDp2NEEuqPamFl19d6V9IruqxiW+UZeLULnxrVkqz?= =?utf-8?q?Xriv0Wwgpl5Cjf5M2Fq8qEnM6I7SiaXeUE71IRj/e7WYS+Mj9ZHteR4=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 9cf6b13d-2e9e-44a6-9a05-08dbf71ad0ba X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2023 11:51:14.7491 (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: k2yfNRbvqz1G0seD2Fw7I68G+Q9bgm89W9beT3QPT2sUnz42OJuhzbixntewoMNlHr4r+tVM2sMTdL8qiqNlTHloD7sLmIE7agnXFzzxICQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5300 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 --- 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 cd5214c9799e..a4a50c52253d 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -1126,6 +1126,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; @@ -1151,7 +1216,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) @@ -1469,6 +1534,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__ */