From patchwork Tue Feb 20 14:05:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13564062 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2138.outbound.protection.outlook.com [40.107.22.138]) (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 58B6F73195; Tue, 20 Feb 2024 14:06:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.138 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708437969; cv=fail; b=a3SNKNC9k/YmWWAsyR8EGNtQcDPUGbJQcAht/8rD08DIfXCYXghEziiFklvAyX29XCLS2HHgxgHrH2Nyzy1J5/e+dzTrbJEKXjUzHgyQYFQRNzw9BRKKyuGhR6s/1awCRHvvLNd+5aJDd8TcZS4N+aPOSzzaBLjB+/DSMhdMgV0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708437969; c=relaxed/simple; bh=wUGrYbPnydwzo+RtLKmi7eQ2m/EJeSbfPolFtQ6kIRQ=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Z5sD0q/+rGvkytApF5NBIl+xlAuHe+lVNJDsvtjsfiyaS3+V1rDO45vKuk9I407IgubBp7cNJ79ecEJMgFrCzhMRXW6MrkZ1rOF913zwLCpdNEQMmmn+08K++ctYQ9QvSzRiq4n5e5MTcdS+sEYxY5/VwOcunArOeUg2eHoDiRo= 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=W6Lj2AA9; arc=fail smtp.client-ip=40.107.22.138 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="W6Lj2AA9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AVK6aJE7kKo3hI60sLrybf1C1YZ3JcusTr5AonWD4vUVa3pM9WZVKoG7zMwEtkcFemlutEdLartI48rv2omKNbzpS+lgefMkUbbYaE1pO/oWfJtb7ZBgE7kYXtyAT7jU7nMhXozQAQ6e10vTXKy54+FJ79m9PXXRUEBry/+IjkwYI3lArA8uksnn7ed1IRU0ABMLEjw+Ahe91td3kb5lnUqH6Mb1nmvYjLoHEYDglQgX0nShGk7sQeUD3xs5t13j9tbXyfwGQSvoym+q8yWwLw5wLC3AUwSAtjleYeHZ34a2O1SRje5VMlj0PWxkIH6BQdxcfKiJ2uVGczHCd3rl9Q== 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=wu9zGPKHKH/j0L4z2++XlAq79sCFrmoumx8z7gnJzZw=; b=kTz0GHrSe0SrKxOMDaGlLgDPS782n0vJld9Tpl1f6uCbMQLi7VGkf+pyWvHFR9cEqywwrrsoENVEMDlgzTs26spwfbBS6k75ISatpv07M9N62noXGVS5mTAMPuKD8fHaq6BRNUpbYY/Rbf+hUc57ZUXHvdKGe2Wy4JR+dU5NPyfD/aU3rbaQ4TvVWtacuHt1Y8zmY8147miOKlHh9yIGFZul7Mx1/n7dRApAXhVuvGnwuYDaQ6c9CNg0zZP+kcFgboFxNnXx8fThZEyW1Rqa0M3oJgbkhUllWfg4gvzsujpB17y1UCt26YdzzCDFjXzch3JHpJjF3h2lYLRYc4tFTg== 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=wu9zGPKHKH/j0L4z2++XlAq79sCFrmoumx8z7gnJzZw=; b=W6Lj2AA93+7z8LVUklES/JRsU2IjXEa7sT7roGrBpzBw5lREe0QnPxDhQ5nKL7N/tZMlNfBLbrxBo+gYgKsFGvW5mexuZbKsgr7luSiHhDNZtv6dDveQeTTilOBCiUpoK43K73M5Cz0dsexxiTjtU7HbjCKbGhjoKLLBrWCVVhU= 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 PR3PR08MB5577.eurprd08.prod.outlook.com (2603:10a6:102:81::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.39; Tue, 20 Feb 2024 14:05:58 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::9527:ec9f:ec4b:ec99]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::9527:ec9f:ec4b:ec99%6]) with mapi id 15.20.7292.033; Tue, 20 Feb 2024 14:05:58 +0000 From: Javier Carrasco Date: Tue, 20 Feb 2024 15:05:50 +0100 Subject: [PATCH v4 6/8] usb: misc: onboard_dev: use device supply names Message-Id: <20240220-onboard_xvf3500-v4-6-dc1617cc5dd4@wolfvision.net> References: <20240220-onboard_xvf3500-v4-0-dc1617cc5dd4@wolfvision.net> In-Reply-To: <20240220-onboard_xvf3500-v4-0-dc1617cc5dd4@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-8b532 X-Developer-Signature: v=1; a=ed25519-sha256; t=1708437949; l=5600; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=wUGrYbPnydwzo+RtLKmi7eQ2m/EJeSbfPolFtQ6kIRQ=; b=NfsAaQep/oh9gZ7YytYUoAWOR9xVUzlZ+mL1lYrfCleQj8N/AfsRRjGKWmSfsfwTPYc/J8TST vaCWzcRyNeXASuhwRNuiHcPD+T5ig7T12/N8poLEk0XpX9M1ongpQz8 X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR0102CA0010.eurprd01.prod.exchangelabs.com (2603:10a6:802::23) 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_|PR3PR08MB5577:EE_ X-MS-Office365-Filtering-Correlation-Id: f982dc5e-9aa4-4235-5be2-08dc321d0fcc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Jhw4rUTMtfAI24+OMIL7yLgt8Hx86ztx6+C89sjABEu8KpNsVOmHjvKdmpK6NiD96oEUrwdxYaBzKJrn7eQBIBdilH4Zl3IpeHfUl93f2AVtZB9dcaoPZqjQCEhFuo/iqfZEqGvKJlJcuaQ+SdDO7ncvHcqV2WR2mjUdtHbL5R5T/o3DXnKsoMwGozg1jyuNN6qyRZjdXdYzTEkDi5wzrZiSSlci2bUNT2pCFV/yDtflz4bzWIv0Sj5s6lSYdzXd3T8GrEsaZqCGtTlLTZPelrJl+HOxeqcP82tASNfAQos8eIL7Cn2C5K1NHPwEI/2HTXIjddY27kHISJ6Ehd1z41bBC7FnkYMai5hvXzLj9DgI5eAvJKayICJ1Bh7Gv0uCDzCbI1uVgrEzF2DGG9ieYKmf3OptuGem58jcASEVCB/L3gUMuKCzTcR5w3KaQfbVyASnHMdaLxZ4cM30Hw7YkIDfHpWsqwTXTn/4DBFsdNn7+FuYi7GTS7COuqY8oS1cQoRJvOadOFIsRkJC6UBcd+SLc1p/hFLsDVGh50G3OJ8UZXrCdU1G/n/KBJAw7PEhVHmne2biam1iKDSB7YP8Iaeu3tzi6bQP6KVyiqP1UDAbr8UJ6It+iZLcsl8v7Kn8LZCMBbgCgAmhBKbaCH3yCw== 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?a+3dk8aMnQZwPaK//f6cQclOBhEn?= =?utf-8?q?xW5SJJnbC1xcnFWFC4Ryi4LvSuPxJuGUaXg4Y4sReMMVAgEaH16ok0kfvsrjrPrAa?= =?utf-8?q?n+V9nm1lzoX/d9H/Oolt3PBCv3QCixhhfwtOR4H/Q7lW5CjRSavZrlRpStn1bHI2A?= =?utf-8?q?qhRSpzb2VmyY89SevsiZwftfhNESM8qPoHOMJHd5tEC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RzNbxRJV9?= =?utf-8?q?HxQqwHsY2Qv0VqjOYZ/LiB1E2gKK/qO0noVcTDjBRevQPt3b44uM4I9OsLTnAPfAl?= =?utf-8?q?hfaK/6/x/SUADek+W/OeWXtM4bzH9wOdKrW5D2yNlFJgnjF7RPNMR4GWFaWDoxmjh?= =?utf-8?q?McZynP33bFnixgYoAERsOzgAkeYQW/o/QPTwxms+bwh6Uqe9MhyY2E4H694b1tFNt?= =?utf-8?q?NjQaiYirLOJY6d9qarO5roS15jtiamMuxkcDFWmF6v/ZOPyJ/6MhsoDA+sKPFQG+Q?= =?utf-8?q?nzu8vLi1Gtnos8ab8ScXqgO41oy0/lxdB6YAa8DMoeDXpYuLXLhUtcHAyO6wSiKnb?= =?utf-8?q?VXgicvAoWp2YKf8v5rW46eDreFRkTJjWyXE9dKt+nHVRYYGUw9hmUah0Ow1e4F70j?= =?utf-8?q?9aiprM8xsAYOJ6XvZWDwlBkWymtyCROTN9hiQWAwlHBI+3UBKV4755CY1OyUZgnZH?= =?utf-8?q?0mw2srUgzWS3zZDwJyBet+7lQ5NK87p/1uEYD/P/Ac79nUqkPsTQ7qI=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: f982dc5e-9aa4-4235-5be2-08dc321d0fcc X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2024 14:05:58.1078 (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: idsM3Y2m+uzunysAbGu2pwHWpxtGuKgHHD7smbdN9nGRPjV8WbL6U9g6szk5DgcoNyZHN4IsOKIrjReGHbgHrIxeBRN8KkhyyOCqxhol2zE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5577 The current mechanism 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 as a fallback mechanism for backward compatibility. Signed-off-by: Javier Carrasco --- drivers/usb/misc/onboard_usb_dev.c | 54 ++++++++++++++++++++------------------ drivers/usb/misc/onboard_usb_dev.h | 23 ++++++++++++++++ 2 files changed, 52 insertions(+), 25 deletions(-) diff --git a/drivers/usb/misc/onboard_usb_dev.c b/drivers/usb/misc/onboard_usb_dev.c index f43130a6786f..e66fcac93006 100644 --- a/drivers/usb/misc/onboard_usb_dev.c +++ b/drivers/usb/misc/onboard_usb_dev.c @@ -29,18 +29,6 @@ #include "onboard_usb_dev.h" -/* - * Use generic names, as the actual names might differ between devices. If a new - * device 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_dev_attach_usb_driver(struct work_struct *work); static struct usb_device_driver onboard_dev_usbdev_driver; @@ -66,6 +54,33 @@ struct onboard_dev { struct clk *clk; }; +static int onboard_dev_get_regulator_bulk(struct device *dev, + struct onboard_dev *onboard_dev) +{ + unsigned int i; + int err; + + const char * const *supply_names = onboard_dev->pdata->supply_names; + + if (onboard_dev->pdata->num_supplies > MAX_SUPPLIES) + return dev_err_probe(dev, -EINVAL, "max %zu supplies supported!\n", + MAX_SUPPLIES); + + if (!supply_names[0]) + supply_names = generic_supply_names; + + for (i = 0; i < onboard_dev->pdata->num_supplies; i++) + onboard_dev->supplies[i].supply = supply_names[i]; + + err = devm_regulator_bulk_get(dev, onboard_dev->pdata->num_supplies, + onboard_dev->supplies); + if (err) + dev_err(dev, "Failed to get regulator supplies: %pe\n", + ERR_PTR(err)); + + return err; +} + static int onboard_dev_power_on(struct onboard_dev *onboard_dev) { int err; @@ -266,7 +281,6 @@ static int onboard_dev_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct onboard_dev *onboard_dev; - unsigned int i; int err; onboard_dev = devm_kzalloc(dev, sizeof(*onboard_dev), GFP_KERNEL); @@ -277,19 +291,9 @@ static int onboard_dev_probe(struct platform_device *pdev) if (!onboard_dev->pdata) return -EINVAL; - if (onboard_dev->pdata->num_supplies > MAX_SUPPLIES) - return dev_err_probe(dev, -EINVAL, "max %zu supplies supported!\n", - MAX_SUPPLIES); - - for (i = 0; i < onboard_dev->pdata->num_supplies; i++) - onboard_dev->supplies[i].supply = supply_names[i]; - - err = devm_regulator_bulk_get(dev, onboard_dev->pdata->num_supplies, - onboard_dev->supplies); - if (err) { - dev_err(dev, "Failed to get regulator supplies: %pe\n", ERR_PTR(err)); + err = onboard_dev_get_regulator_bulk(dev, onboard_dev); + if (err) return err; - } onboard_dev->clk = devm_clk_get_optional(dev, NULL); if (IS_ERR(onboard_dev->clk)) diff --git a/drivers/usb/misc/onboard_usb_dev.h b/drivers/usb/misc/onboard_usb_dev.h index ebe83e19d818..59dced6bd339 100644 --- a/drivers/usb/misc/onboard_usb_dev.h +++ b/drivers/usb/misc/onboard_usb_dev.h @@ -6,63 +6,86 @@ #ifndef _USB_MISC_ONBOARD_USB_DEV_H #define _USB_MISC_ONBOARD_USB_DEV_H +/* + * Fallback supply names for backwards compatibility. If the device requires + * more than the currently supported supplies, add a new one here, and if + * possible, the real name supplies to the device-specific data. + */ +static const char * const generic_supply_names[] = { + "vdd", + "vdd2", +}; + +#define MAX_SUPPLIES ARRAY_SIZE(generic_supply_names) + struct onboard_dev_pdata { unsigned long reset_us; /* reset pulse width in us */ unsigned int num_supplies; /* number of supplies */ bool is_hub; + const char * const supply_names[MAX_SUPPLIES]; + }; static const struct onboard_dev_pdata microchip_usb424_data = { .reset_us = 1, .num_supplies = 1, + .supply_names = { NULL }, .is_hub = true, }; static const struct onboard_dev_pdata microchip_usb5744_data = { .reset_us = 0, .num_supplies = 2, + .supply_names = { NULL }, .is_hub = true, }; static const struct onboard_dev_pdata realtek_rts5411_data = { .reset_us = 0, .num_supplies = 1, + .supply_names = { NULL }, .is_hub = true, }; static const struct onboard_dev_pdata ti_tusb8041_data = { .reset_us = 3000, .num_supplies = 1, + .supply_names = { NULL }, .is_hub = true, }; static const struct onboard_dev_pdata cypress_hx3_data = { .reset_us = 10000, .num_supplies = 2, + .supply_names = { NULL }, .is_hub = true, }; static const struct onboard_dev_pdata cypress_hx2vl_data = { .reset_us = 1, .num_supplies = 1, + .supply_names = { NULL }, .is_hub = true, }; static const struct onboard_dev_pdata genesys_gl850g_data = { .reset_us = 3, .num_supplies = 1, + .supply_names = { NULL }, .is_hub = true, }; static const struct onboard_dev_pdata genesys_gl852g_data = { .reset_us = 50, .num_supplies = 1, + .supply_names = { NULL }, .is_hub = true, }; static const struct onboard_dev_pdata vialab_vl817_data = { .reset_us = 10, .num_supplies = 1, + .supply_names = { NULL }, .is_hub = true, };