From patchwork Thu Feb 29 08:34:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13576832 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2110.outbound.protection.outlook.com [40.107.7.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3D7454747; Thu, 29 Feb 2024 08:35:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.7.110 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709195711; cv=fail; b=nQSf8cHo5SkebzfDmCJoriOVke6xjiHt357V57dI3f5BGXQnv82T8eDQFGOGyOQYF6cY31FzoTczWHqKBAAclyhlQ29KXIFfd/J5c0pQ61KKT6TDkRLdF3PPDIPH3LUvQrgjaWDUlMJDSoAz3etuvHsmaTSZqlltlhE7t1DEWG0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709195711; c=relaxed/simple; bh=1jRF6eUBRouA1Hvx0Z6eIEmXQvVE/AoBOk4doyc8rhY=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=ZjtAdyzYg4s5c5lQUgCYNmBNc9yIU0bacD++XZRmpmvhBPHlNPMEIhcmuND2duuA7zUxqy6HWGbL9N13hnnGxz8BUhC0XPuy4XLl4cc+cQfIRig2lqlLV5ZWcLRatvEvAjEb+uDPbZcX7uUT+tjAxfkm6VlevtrZI787C6T8UFc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wolfvision.net; spf=pass smtp.mailfrom=wolfvision.net; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b=eYunF7HP; arc=fail smtp.client-ip=40.107.7.110 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wolfvision.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wolfvision.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="eYunF7HP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gCJHlCxbdZ4fua7R7wySD9hFmt2rSLuAHCywF9MPkFjdcapvsdT8yZeP1HMZIySN+ETZeYz/X7LM/zio/ik0wjhVBqZ3N90ggB2i2+npwvqLImoiZ5xhV4G+AgNJceQ/fxxhMvNVS3S+c8hwfPht6FwXpJEzAhB481T4Nhb8N998FS7nIZGi4/a1GzgAO5idgbX87B0VvWGnk4szQcN8Mj9K1T9unoqThB2KBTb4p2LcARv1Q/YKNpqPvHWZZEeE83eIrwcTIQRCUBcvRig48yHzVC/qP90U7oBawtA3TTkC/h688UzoiLb6Mo+pJLAScxy6qVa6pu9nXPLaAHgDUw== 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=WgoMgCPBKwzfWbeF8lgH5NAIRhQpmLQTYXnUHWavB58=; b=CeLCYThLJO0w5Z0keYJWKpD4UG0hre+YsTfe92HAgJcyaX3bW4gnWu8o2kksU7aZGW6NsVPAhOdt4L3CBFrmWPxDPU6oY7N3pousfGi0m/6s7YJ4giCTqzm1zqQghjsh3KvaRIc/tJruN9sQlL37R7QIsXMGnIAKrru+QylOeNYvSu/hrofrimQAyldI6dGldTplfJdfUSH+/vL7xR+2quLCK6ZmojQBZM6AP5JyjE7qpLB7thnf5Z/yAyW4rzbia/pzxqkJvHDukDdb7WczyXgNlOZN3E+Eps8Cg67qpVBB6flD6wxh8BU6rq7PAmbd3BtSrMgQG1EDGQM/Ps+Zxg== 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=WgoMgCPBKwzfWbeF8lgH5NAIRhQpmLQTYXnUHWavB58=; b=eYunF7HPZN04HKRxnpNCkk/tW4zv1RbamVP8OaNbVpM1Aqe+V7E7YWFM5V/Rr0HhlxYxrbmsFlZS1EKs5+pcvEM7WHBKb1vA2MdAkG0HjLm1w7G7BvM6jKYYc7CRTvMaXeE/tck9EuDBbYO4irzZdJX/KeTNQX+cvBFAPTpb/0w= 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 DU0PR08MB9727.eurprd08.prod.outlook.com (2603:10a6:10:445::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.41; Thu, 29 Feb 2024 08:34:55 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::9e35:6de9:e4fc:843f]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::9e35:6de9:e4fc:843f%6]) with mapi id 15.20.7316.035; Thu, 29 Feb 2024 08:34:55 +0000 From: Javier Carrasco Date: Thu, 29 Feb 2024 09:34:45 +0100 Subject: [PATCH v6 2/9] usb: misc: onboard_hub: use device supply names Message-Id: <20240229-onboard_xvf3500-v6-2-a0aff2947040@wolfvision.net> References: <20240229-onboard_xvf3500-v6-0-a0aff2947040@wolfvision.net> In-Reply-To: <20240229-onboard_xvf3500-v6-0-a0aff2947040@wolfvision.net> To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Kaehlcke , Greg Kroah-Hartman , Helen Koike , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Catalin Marinas , Will Deacon , Russell King Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1709195691; l=5198; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=1jRF6eUBRouA1Hvx0Z6eIEmXQvVE/AoBOk4doyc8rhY=; b=0EeVN4pBM1GJ9v8jgWBoPsqcxuLrDqh5pThK7jfBO1qPZgPT6o5U2gcNEtaO/KRuYYvlOI2pj t6kFYQ8+QDPADIDB21Zb/fIbl31J6cRxdVmogSOG35Y2J0//l1HPH1L X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: FR3P281CA0020.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::21) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|DU0PR08MB9727:EE_ X-MS-Office365-Filtering-Correlation-Id: d4cf20a4-a127-4692-a1de-08dc39014e2e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2EOLCjIUHaLs8zMcT6XTh7ECtoFv0EY8cD5oOdEHK1qkUasVWy3KQliyLKlTu/Jqgs//8RRb7KUiaEkjQ04erG4cR5iiMQqMRf4BJh/yMDUht6W9v9BJofVSjAGo/ngNUsmPyIa2m2W/rLwBl0AKr4pZqX6Ry9QFtjNHlWBE4S7m/s8SUPRhDiTU1938B/tdBwIkgqYbQOIstruZUpnLxraWxYVted5RJM3yPHmGAiMSuadNUXkstWqMZPX/JVyFXYTe+8XiauvuxasyC6S8347k5Cr67Etsg7PmtDqzfhKp2J2qU5VskiIDrWr+clsiGiKvVPLsONk39rGmEtTY61RQivph8ojNcqg2S/mgkK/+5/KZGiP9fkL208GD4O8mA7zvfjKHCyv3BrcY2neQ+f51Lh0fv+2OiKw9M4HaaM9LawZKOpDurpcZNVTc7Aerm7as1t30MwkvuEcDxRwktb2VNtRP6J/QFlZhZoObb3JRSgq8TozhB9FymbAV2QXTM0NovwfznAVG5fS62rvTHs08dhzFGVHmW43zcRACAu21waRl4BAc5ilF34H/e6pRVwRU/Vh6+7xJR/pUjuFzDaR5lGdMbxw6sbtpgRJFfiHoycK4AyWCNOgR7AUt4fsz2CZShWspm8ju8apO0sX2oA2jFaPmlMwPPIlgRreR1Foo5vY6GFmi1jxnEfyvcP67j0WvnF/49Mja1k3Hy2FgqHIF+fWRE3v344HaFxTaPEI= 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)(921011)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?MU8BiyLVxTVaaxUFEqeEz0g/WEpM?= =?utf-8?q?JZgUZQcSAH1+uGzqxey5W8BLh1Ol+bRUz2Ag9U+0xpBa6BxMpf5Z0iJyIzmN/PbPv?= =?utf-8?q?UsjQPAMyaRG4YQN/LdaKtc8F25yNgKceKUthpHokEMJR1h70eqlpHgix9Pl9fI+I/?= =?utf-8?q?53Dn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HHGzPAjU4BJGbpYKMrWtKZ0ZXleRki2CdmHzuWUhXupgFW9JEqf?= =?utf-8?q?bCSOlT5eA92kUyvdnrSrvo4bOqLz/7mOCLzR07byWccZGtvQ8hmcVxeJAN1cS8Vzk?= =?utf-8?q?VVXJ1t/WUZcy2k5I2Jcpc0bIIMk6jSvrl4ddrV5Vgz0Dt7Ceq/om2+7E/cI1iwJP2?= =?utf-8?q?zM/7rR9qZrktK+JpkG8qvMfMTl/4zqi7WMbeyESs5ji6OHYkHPLVre5+DS42urSGR?= =?utf-8?q?foKJgwQPxKV1yjSSzguWyH5i1vepDUblUD5VkMwCbAT53QgLuhVkpWRoJGfYwjijl?= =?utf-8?q?ta19/Z1wG/b5n6G7l40sCzO/EoIb3Qbd5QQigLqvLOhoKO0hoZsfjiLF0aPvpqwcQ?= =?utf-8?q?2A2uK06jikfF7Fq7MHkZ9m7p3VX1PVndSLLusO+hOnbnTdZy/2lfsnIEE8UN7VHWk?= =?utf-8?q?UAykpSsm34aAGIy4IAiXUCQromO3odQljq6vvlPbFyxHQPYjvafhlpeGbmSxjIIDn?= =?utf-8?q?/BtcmEuAUaMFD+DO8HzMluWV8Bdkicazo1XtquE24MqVjvn9siQYhws=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: d4cf20a4-a127-4692-a1de-08dc39014e2e X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Feb 2024 08:34:55.0314 (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: KrMMn+2Y/1LpU+InzY4tHzBv5fHPf8E9eNdy8KRdtdR3ARNQMsLnTHSB/th9XW5xuJKwoTLkB4w4N2fLh6aAPnaL4Ukj3F7qI4xuwExPSEs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9727 The current implementation uses generic names for the power supplies, which conflicts with proper name definitions in the device bindings. Add a per-device property to include real supply names and keep generic names for existing devices to keep backward compatibility. Signed-off-by: Javier Carrasco Acked-by: Matthias Kaehlcke --- drivers/usb/misc/onboard_usb_hub.c | 49 ++++++++++++++++++++------------------ drivers/usb/misc/onboard_usb_hub.h | 12 ++++++++++ 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/drivers/usb/misc/onboard_usb_hub.c b/drivers/usb/misc/onboard_usb_hub.c index 81c001fd38c1..1f3e0094957d 100644 --- a/drivers/usb/misc/onboard_usb_hub.c +++ b/drivers/usb/misc/onboard_usb_hub.c @@ -29,17 +29,6 @@ #include "onboard_usb_hub.h" -/* - * Use generic names, as the actual names might differ between hubs. If a new - * hub requires more than the currently supported supplies, add a new one here. - */ -static const char * const supply_names[] = { - "vdd", - "vdd2", -}; - -#define MAX_SUPPLIES ARRAY_SIZE(supply_names) - static void onboard_hub_attach_usb_driver(struct work_struct *work); static struct usb_device_driver onboard_hub_usbdev_driver; @@ -65,6 +54,29 @@ struct onboard_hub { struct clk *clk; }; +static int onboard_hub_get_regulators(struct onboard_hub *hub) +{ + const char * const *supply_names = hub->pdata->supply_names; + unsigned int num_supplies = hub->pdata->num_supplies; + struct device *dev = hub->dev; + unsigned int i; + int err; + + if (num_supplies > MAX_SUPPLIES) + return dev_err_probe(dev, -EINVAL, "max %d supplies supported!\n", + MAX_SUPPLIES); + + for (i = 0; i < num_supplies; i++) + hub->supplies[i].supply = supply_names[i]; + + err = devm_regulator_bulk_get(dev, num_supplies, hub->supplies); + if (err) + dev_err(dev, "Failed to get regulator supplies: %pe\n", + ERR_PTR(err)); + + return err; +} + static int onboard_hub_power_on(struct onboard_hub *hub) { int err; @@ -253,7 +265,6 @@ static int onboard_hub_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct onboard_hub *hub; - unsigned int i; int err; hub = devm_kzalloc(dev, sizeof(*hub), GFP_KERNEL); @@ -264,18 +275,11 @@ static int onboard_hub_probe(struct platform_device *pdev) if (!hub->pdata) return -EINVAL; - if (hub->pdata->num_supplies > MAX_SUPPLIES) - return dev_err_probe(dev, -EINVAL, "max %zu supplies supported!\n", - MAX_SUPPLIES); - - for (i = 0; i < hub->pdata->num_supplies; i++) - hub->supplies[i].supply = supply_names[i]; + hub->dev = dev; - err = devm_regulator_bulk_get(dev, hub->pdata->num_supplies, hub->supplies); - if (err) { - dev_err(dev, "Failed to get regulator supplies: %pe\n", ERR_PTR(err)); + err = onboard_hub_get_regulators(hub); + if (err) return err; - } hub->clk = devm_clk_get_optional(dev, NULL); if (IS_ERR(hub->clk)) @@ -286,7 +290,6 @@ static int onboard_hub_probe(struct platform_device *pdev) if (IS_ERR(hub->reset_gpio)) return dev_err_probe(dev, PTR_ERR(hub->reset_gpio), "failed to get reset GPIO\n"); - hub->dev = dev; mutex_init(&hub->lock); INIT_LIST_HEAD(&hub->udev_list); diff --git a/drivers/usb/misc/onboard_usb_hub.h b/drivers/usb/misc/onboard_usb_hub.h index f360d5cf8d8a..0ee515e7feae 100644 --- a/drivers/usb/misc/onboard_usb_hub.h +++ b/drivers/usb/misc/onboard_usb_hub.h @@ -6,54 +6,66 @@ #ifndef _USB_MISC_ONBOARD_USB_HUB_H #define _USB_MISC_ONBOARD_USB_HUB_H +#define MAX_SUPPLIES 2 + struct onboard_hub_pdata { unsigned long reset_us; /* reset pulse width in us */ unsigned int num_supplies; /* number of supplies */ + const char * const supply_names[MAX_SUPPLIES]; }; static const struct onboard_hub_pdata microchip_usb424_data = { .reset_us = 1, .num_supplies = 1, + .supply_names = { "vdd" }, }; static const struct onboard_hub_pdata microchip_usb5744_data = { .reset_us = 0, .num_supplies = 2, + .supply_names = { "vdd", "vdd2" }, }; static const struct onboard_hub_pdata realtek_rts5411_data = { .reset_us = 0, .num_supplies = 1, + .supply_names = { "vdd" }, }; static const struct onboard_hub_pdata ti_tusb8041_data = { .reset_us = 3000, .num_supplies = 1, + .supply_names = { "vdd" }, }; static const struct onboard_hub_pdata cypress_hx3_data = { .reset_us = 10000, .num_supplies = 2, + .supply_names = { "vdd", "vdd2" }, }; static const struct onboard_hub_pdata cypress_hx2vl_data = { .reset_us = 1, .num_supplies = 1, + .supply_names = { "vdd" }, }; static const struct onboard_hub_pdata genesys_gl850g_data = { .reset_us = 3, .num_supplies = 1, + .supply_names = { "vdd" }, }; static const struct onboard_hub_pdata genesys_gl852g_data = { .reset_us = 50, .num_supplies = 1, + .supply_names = { "vdd" }, }; static const struct onboard_hub_pdata vialab_vl817_data = { .reset_us = 10, .num_supplies = 1, + .supply_names = { "vdd" }, }; static const struct of_device_id onboard_hub_match[] = {