From patchwork Wed Feb 28 13:51:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13575475 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2105.outbound.protection.outlook.com [40.107.6.105]) (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 35E78151CC5; Wed, 28 Feb 2024 13:51:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.6.105 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709128308; cv=fail; b=P22OqJBt3egwpKd2tsAbdc2VPRRqYzs6SThv2YFWYqB1KI7G9Y2svccHpQ4HhoiEu9Cmo6Jy6/kyyjIiDVcoWHZIhqV29n3wg1puox6+dWW/no9AK/QumkmGKuNv6y3SKxRiDTBRx4KB+iC5V2XoOkzu/jyd4D4vtu/P3w+ndR8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709128308; c=relaxed/simple; bh=BEdcCVmujfc9kG0AJPFzTPxgH1GxZd8gsqn1iUJC8zM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=M3R+dWtKigVbjHMX0lx2u+LPCOcjXUIETOf6KVY+B/xjx8c2Zcqfx3cgFbyA+lPIvWezdEOmAhZ61SaNOiiTGc16r1+UsHTuSzY1+FE2Z6A38OouCvcKLfaWd3l/EbtJc+Q4yO2Qfc0y7XaYjY1VR2WIMJ4gdD042qF5iXimmlI= 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=V9BZ3j9I; arc=fail smtp.client-ip=40.107.6.105 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="V9BZ3j9I" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k6UWpQOQdNCy47XfmccfTZMYluDLoieQfOqSfQwikWfjuaFu9QdXu287ov6TjBMiZ+cSntmmroF9o0EWCCDYgg2hg+cYVepoSbky+HV9UP9CuZ0K48hqDSrguVOpzGFXnkvnHxI77HJKQ1kAIk1X+YgErKFQ6loKG6UeG8xmF4xI+41lj0aTsNk8Hc+yBUajNJ1KrcvnjtF9cydwHmKBZmtH/pcDUpFTBmMX6+LW2h5yqjdf50JEnCHHhi5wZ+MzUqpBVm/tqyigKK9/zNszoM1dCg1IGYWVIZV5TtGIMcVBZWilFdifycJgyAHgfrRUGtw4Q2qDzIe1XKAqeg42hg== 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=OAs6bOrmyQn739mDtnVcwn7FPSu0LOrXuAzpN0t0DBM=; b=KBGdoYO4bnI9uByiT4CnVSNEkzmWZ6hJ/8dBUSTx74ypsRgohNgnmJUx1wUHhnZiF9t+vduyG9VyYjBHgHfqd3vbtXpasGkqjfFxodyGJXPkLWowC0vOJv0Z9iQ2ORHTUJf8N6HTDUQ4kCgG6AOyKWyTwwR/f7NsRI98RUyzhOGcaVtPhRDy74SSxYciVBgCCz2zk+LlHAjw/gXdPZiJKu5IF176goRk+GQrN0QIqhBs5sMUfjiPwU93dzdVEElmJqwIaN/zaP6N7xQadSWbc69AB7idATBjPk65tiyax1Rszvd1buHohWPe+8+PqsunwtUIDXw59k5FsS4P1Lk9hQ== 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=OAs6bOrmyQn739mDtnVcwn7FPSu0LOrXuAzpN0t0DBM=; b=V9BZ3j9IskDtUh+sHNdyRl6TVNf/NfxCJ3onwQ6igi719R1E4qu7ZPqfEQempdHU3p111PLqoaPuumFQTXgCYZOxx5epW8XFPpEe9UUUnjCGxcIblq+fpbWrqAskuuUd2+zachNBORZHCsF0t9sEik/Zyqet6iCwGjsHGVQdVzw= 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 GV1PR08MB10523.eurprd08.prod.outlook.com (2603:10a6:150:16a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.40; Wed, 28 Feb 2024 13:51:36 +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; Wed, 28 Feb 2024 13:51:36 +0000 From: Javier Carrasco Date: Wed, 28 Feb 2024 14:51:28 +0100 Subject: [PATCH v5 1/8] usb: misc: onboard_hub: use device supply names Message-Id: <20240228-onboard_xvf3500-v5-1-76b805fd3fe6@wolfvision.net> References: <20240228-onboard_xvf3500-v5-0-76b805fd3fe6@wolfvision.net> In-Reply-To: <20240228-onboard_xvf3500-v5-0-76b805fd3fe6@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=1709128293; l=4982; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=BEdcCVmujfc9kG0AJPFzTPxgH1GxZd8gsqn1iUJC8zM=; b=CwPy+gqV4LQCZHq3nhBn1Jzd5f9g1Bzgow+X8c08GLar8MpPUZFF8XzceOBi1l4bc3jooNWUp AMRdwlHWBwWCi8gqOaxrbleM5NeuPaygd48pql0miXJyDZ/qnimLVIK X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: FR3P281CA0184.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a4::19) 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_|GV1PR08MB10523:EE_ X-MS-Office365-Filtering-Correlation-Id: cff8a544-b57a-4bc2-8311-08dc38646178 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b2CNTygykATNkMcrizvDdcFjy2PDTLa0/IGt5BkMv0DLvEy7mHu9bkG4JVBy9VCgJ28wqGoCyCZO4eIc5+1VMfceebXK3OSHFMJTLJTdLYpjiRFKDTrvBzv2ao6t7ri5Gtt9oyGi3hXTThcvHkOKp79rP2HV472eA1n10ps6Ss0dziZ9g3kVEeSWDQbqcik/5dA2bHq9FPB4AEF26YmjEpLjBDAdifOOwkYpwOmwa3FZ0uyeJrTqAhmltcUgfGHUla+IjhIhoOR8F1WnBlA2x7jQQ1kr9KRW17f4UZyMIOScUk/6MYVLQRmn4c6uRyDCtjMB+aUiSNX1o9I7BWSK+czI+vSMDRDGW3wFxWGU231NgSOI6k0qOPl6zCO9mxX1Kb54VqUwc9JBeaVi+8xLQUXfV93l+Ojs3CY1VeKynQk20Wq+N5KelrrMPXmTmdc9e4idLFzbP2Kd/NE747bgNVZbyPxv5u0Bt8pcC7CaxTxOuP1RgYMj10MG/yUbFDqR4QLsJ2rg2xAjsWacDG+HSDYXRrghjTmBwKW+ffYKg//f4hERRp8bpfLSQZy0aHn0m8KfKfQDVIrdcMTwtrNGBZYiBbNvY3bQ+ag1stYq3HwDpLWY8VTaT3oqS91MxQwXKDocEQDoNIG6Z2DDlwgChFAMsV/x9RtfWjbZ5P5Ci6jeoKHZFhXxBchIx63GP9HP6db3ScWNKo/WBhpHoYoYEBvHqdHVigZlQ23Zwft8CUs= 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?ARy9M+DOKMEGSLv4c2MW65XxHVlI?= =?utf-8?q?OqYwp49h2Sb/32IryM4xPfzig9Bz96ll8uQXTII5Q5OwMKPVUzMxXaPgjNDgKzOCW?= =?utf-8?q?yeY8qsvXBo+FMFZBpN0xU56eTPGgBcvmkW5uJfcTkT+o0JJubMtj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JDswprvTe6o0uv+PcETM1WM74F?= =?utf-8?q?qGMm0gBZqiSeGge8piQ8Lbwi1eXgkhcXktfqMJLfNmpobBTBIOVkrmlkf5ezLXXOr?= =?utf-8?q?i7TeeL9kxXXjyUPOt03zUoAvkw8UNsbD65Bffp8VSO0b+PFs5KWglEgQhYdMjnITC?= =?utf-8?q?SKwuwk5LhFoCtnPCZoUvj/5zNb7KpvTxCidVmI2dSEBYn44eZ3L193XNjBcbswYQ5?= =?utf-8?q?TwN5a5OXi3dW6QtrYFqAADGU4HPVgYo7fsig3cDt7YKF5uRNTOGJa5dncnyAXs0sf?= =?utf-8?q?lpWJJNpfQ9x26fM79yLv58wqoRNoqDpmBkdLigvjlbZZpH7PFKs58jJ4/KnlSMRLP?= =?utf-8?q?XoQIZUl6Ob01PjfapdLi3t5viuMDDOpkTKLwv30vi2620ovSpai+XJ8D5w7yWaOZj?= =?utf-8?q?ubq6bZUZSFGrT80sBBEcuAP62rqqj2ZI3yWat3HNTUB/1qBWe1VX+1n5/SUd+XYUn?= =?utf-8?q?hEZvZHm9gjeu28DurkXBpCgt5qZC+Qi20Ts3ZvHPpmzYri+bLFuy9+7OD9CWkfnLv?= =?utf-8?q?co99wBGEH3+O0qJsEcMn1alBnftB7o/5X/xDpvPDhFdYQJKRIhjQ0v8=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: cff8a544-b57a-4bc2-8311-08dc38646178 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2024 13:51:36.4080 (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: Khf6bmPkqf/JzXk6F6l83siuLcRnNooGl+MCtAkTxDEvL1GS3jzd7KsW4ftSA8UB7NtFAhBxIPEZKkcGyAs7eZi6gn75ymc968lA+zoObjY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB10523 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 --- 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 0dd2b032c90b..3755f6cc1eda 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,30 @@ struct onboard_hub { struct clk *clk; }; +static int onboard_hub_get_regulator_bulk(struct device *dev, + struct onboard_hub *onboard_hub) +{ + unsigned int i; + int err; + + const char * const *supply_names = onboard_hub->pdata->supply_names; + + if (onboard_hub->pdata->num_supplies > MAX_SUPPLIES) + return dev_err_probe(dev, -EINVAL, "max %d supplies supported!\n", + MAX_SUPPLIES); + + for (i = 0; i < onboard_hub->pdata->num_supplies; i++) + onboard_hub->supplies[i].supply = supply_names[i]; + + err = devm_regulator_bulk_get(dev, onboard_hub->pdata->num_supplies, + onboard_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 +266,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 +276,9 @@ 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]; - - 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_regulator_bulk(dev, onboard_hub); + if (err) return err; - } hub->clk = devm_clk_get_optional(dev, NULL); if (IS_ERR(hub->clk)) diff --git a/drivers/usb/misc/onboard_usb_hub.h b/drivers/usb/misc/onboard_usb_hub.h index f360d5cf8d8a..ea24bd6790f0 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]; /* use the real names */ }; 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[] = {