From patchwork Thu Feb 29 08:34: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: 13576833 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2115.outbound.protection.outlook.com [40.107.22.115]) (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 E381A54F88; Thu, 29 Feb 2024 08:35:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.115 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709195712; cv=fail; b=kJR+l4i4JlVSRao3iXRuQvDnGaYZStLIx5x/f6LgcjCekJxoy8afWdqSN8DPv1RKCJLoIleaqmDl+bYzR0b7txNsfX5u1f3cT+L3BIC/PqzCuV/lgh5/EiQv6oLY+Xk7hIuZfY/gZvQi3o7afI/GOHZUWuBSp25aqCb+E5TIcns= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709195712; c=relaxed/simple; bh=vfQGF7yQinSaT9UNhA3JHy0/iTESK+//H4eVSAxy678=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Ca9NKrl5a4Wgv1gfdOLXQiVzE0u4IoG2ULY1HkSCrLqQj2qp4f86yrY9mJIvmR9iCkcolOqr4TboHL+SGuca7qwlk0CFDHP3rgO/0S9mj46XIRpvLEpL8ZrMSR38PP6m9HJrdbjTa6GXrHSn4qmxUfjMQwuO1akmVLGJ8wajCAU= 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=1Ba6YloI; arc=fail smtp.client-ip=40.107.22.115 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="1Ba6YloI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SdRz0sSq2JKST5OPBMhTb42Wf6b6irP3+pkTWopvQCVPJRGC9LhkgZyMn3Vgzug5JO59uu7f+ie2amb8ADpdPm/omIkOT0zk0kuRJw9+OHBealfmU2m7Jk3e2dYxqMYU6oJpoD4Ea34XdtAAs7brdzMTjWPbFDJPO1RaHSf3C5WcqBuAyW75YFgQHd9GkBdR/NZchYVANFgwo+AfItVXWiNkEU49VIUFKFzDVu2TyjbMmfPZTDpSQUG33bbZNaIYR/suHmDe7zQ6CekpITzMQmaLKDBwSG14Vq/06eVi/ot6rPKLHWsdZPoHT1ck3iqoXXO8C7usva/tXghAyaUNMA== 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=Ds6itwYkR9TL4kKD6AgurAEc7kv/3VVG8//qRHS0lNI=; b=mMAPVqcpjbmfeigAO3MJlqW95gIEzZjtO9DM24UTKOaa5ihi4HksoZ1Mi9yvwh1A56jykgfHSntw3bElr5SSK8ETI6guQge7YOBpTcVRMjymcOqXaw8PHG71xTF53XnnIBWgfa/CxMR8kxPJ06A82kgBiGIcuuinydkvTCNwo+pExyUtlkR7tFUiD1QI8FzBSLyjb2vFeFgmZNXJ18jghHEbCX0SniHV6+Pib4nxckIKK+wxdcCg9JCqKq1u5W35nkSblKaO8OVp21dEn70YegL0ZNAeIZ7eErRpS/bMiFRsc1wsFwq9IN/mcapuqTi1P5tpcrjxAmW7enzSZRg3zQ== 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=Ds6itwYkR9TL4kKD6AgurAEc7kv/3VVG8//qRHS0lNI=; b=1Ba6YloI6C/qkw+p/9zwIwoiztMQ629o/jBg+9XB+2xgF6rij+TgU89exEVB6D0CztCCnWzgwtuPO28o7kIClzMkqGFkOarQ6sYq90UZimI1ZWchHtuPgpUWLVYfEgbLqHD0XtbyWy3axDCJv9GZxZKGHcUFTeVnYvoMgWva3xY= 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:35:01 +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:35:01 +0000 From: Javier Carrasco Date: Thu, 29 Feb 2024 09:34:50 +0100 Subject: [PATCH v6 7/9] usb: misc: onboard_dev: add support for non-hub devices Message-Id: <20240229-onboard_xvf3500-v6-7-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=3959; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=vfQGF7yQinSaT9UNhA3JHy0/iTESK+//H4eVSAxy678=; b=GK3bolSX/KFdmigmvWTPqHOLsYen6j6QYuOuV/sku7/6iJPSUwEh7scxNJEaBJapt/BpD0Cbc lYPOX368xBvDYOPnHiEASNSmsjn/2ifwDDOnVTxutOo0RNFrCiU7sKy 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: f0e524da-2d7c-42cc-ce79-08dc390151e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1M6CKcGB/2soMq6pkVS+haxkMOxp8lrYlDhfARj0zG56YGyUAERZvE+eW4Rizt8vlAfQ8/e5ikQHLjh+ss/GK+ngmATSJQoP+Ims0++CFFkbNl4eLMqegbN1IhO7vvAMyr7THPNq2Ne51bwcCNB1CRjZrb6K3azWoc0hk0VvpGaawN1CVoPvsFcHdIO1SMv9pyhZnK9NGdBDFrz/VKooDAuSS1ahkZwGvHNVeQOzle6QZqUF0wmSvdFNPrSyrUd/DacF+l3Xy1DK8U0bDcSFGvV/ttmMSr2Ayn4I0r13D0RKE/9R08su4PFaUlqs1GFkaD4WPdFXlzN+0JsIgEK2G8upNILvUOnz5Qm9jSi2vGAPvmNIIfKnnsXuMHTQaHeBAMrUwSJd4LOB7VA/O2pl0kI+BuNiAFt058nE4Q5gVwlRQngaAizMxzfj5KYcT245zpRdazwhK3QlIzjGy+UEFdOKWisv2rfOBAV1Q7UK5/EK05XRYIuq3euGlrbTPiRKArvVrm4QbBYcjKmbMc9d2JS0csNnxBpbyutsPgS2IXzGJ6QDSiVXXKsWjZnk+KFxKoIx0r/W3y6ifBCvLKjwOx1g7d/CK5dsZcF1YObJpl0N+vj7/Aax9QRQXAc5vf9qBXor62Mf/RzX4wYAQzMKw5BK4RYsX5vrH5vrukPZysWeUx3d02PjdKhHP+pkwl4yiryl39C0MEU73DwS0Nn/K2z+FE0lPW2e3f48kLhwuj4= 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?z0bUXt8Jj5m6GvPyaWj36Vj2igrG?= =?utf-8?q?1JItVW4OAN/gnBcIE5YCbUkwkniFY2jIcoi081HUOTFawei7l0GAyhywRNJw0SQmJ?= =?utf-8?q?Y4MSwdfZsdOkgelxOde88nbSD/8zGbb/2ib386Cyjh2YUa/pV8tNh4HuZehiS5DX4?= =?utf-8?q?5sRPz8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mUueAqixnIZDAIR4uf4Lin/F4v2I+XOkaiQPm9r6FOhsK/AXgJnOfcnC9StlRX?= =?utf-8?q?gvywtkwUboXVL6Nll1XQdsQQPgY5MBvzH61VRJNiQATwm+pCDrSqgSX7qpBuqPUob?= =?utf-8?q?EE0Ac74/vPfMIN4H2kpJmq2Urui/A+1aXzwYl/deGGGQd962cUrL0E0btZ/hG8tdb?= =?utf-8?q?8LEAGYei56Ds8DU8Z99IN41OJkM+g5bL52Gp7CXe/+1WpamXNWUUrhvQB5S4CbYuk?= =?utf-8?q?yWXkVkkr1o452RTaQshCYzgoG4nrqnCYkoMDc3Ta59H+lx/LaKGCBNzWmFNac7iY6?= =?utf-8?q?QpsE0yfOwhO8HdyrcHW1h/76JuFOrcphTF0ynAYPioj8myuBjZuNo9AsFBr+iNYlk?= =?utf-8?q?qfJuL8tUH5oI7V+3w0P1ASzxkVSjVwcA9eTFqUUrpaSlVzCVWCDkU2zh4iPDpwfcO?= =?utf-8?q?1aL8/oTrdnlKDJ5C/LRh2EAnMQ6arP9WwfXjOH8eeTPm2pKQqAG2wMyItMm1OeQxA?= =?utf-8?q?BWDFqyr4cxw/yLIBcGeFqFacQ51MV/KIHCFEOWE4Cvqhdj1Ie/3jSRA=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: f0e524da-2d7c-42cc-ce79-08dc390151e7 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:35:01.2528 (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: 9R7edYZdzUiVWj61qlLlKdUD0z8QsY4ESr2Y9E9JT2po0VPiOzpaRtjFZOjtrcL0ovOwArnk5mLqJwH2Ib0Y1/iD2JVKW6sDkAaJnJpVyqM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9727 Most of the functionality this driver provides can be used by non-hub devices as well. To account for the hub-specific code, add a flag to the device data structure and check its value for hub-specific code. The 'always_powered_in_supend' attribute is only available for hub devices, keeping the driver's default behavior for non-hub devices (keep on in suspend). Signed-off-by: Javier Carrasco Acked-by: Matthias Kaehlcke --- drivers/usb/misc/onboard_usb_dev.c | 25 ++++++++++++++++++++++++- drivers/usb/misc/onboard_usb_dev.h | 10 ++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/usb/misc/onboard_usb_dev.c b/drivers/usb/misc/onboard_usb_dev.c index 4ae580445408..f1b174503c44 100644 --- a/drivers/usb/misc/onboard_usb_dev.c +++ b/drivers/usb/misc/onboard_usb_dev.c @@ -261,7 +261,27 @@ static struct attribute *onboard_dev_attrs[] = { &dev_attr_always_powered_in_suspend.attr, NULL, }; -ATTRIBUTE_GROUPS(onboard_dev); + +static umode_t onboard_dev_attrs_are_visible(struct kobject *kobj, + struct attribute *attr, + int n) +{ + struct device *dev = kobj_to_dev(kobj); + struct onboard_dev *onboard_dev = dev_get_drvdata(dev); + + if (attr == &dev_attr_always_powered_in_suspend.attr && + !onboard_dev->pdata->is_hub) + return 0; + + return attr->mode; +} + +static const struct attribute_group onboard_dev_group = { + .is_visible = onboard_dev_attrs_are_visible, + .attrs = onboard_dev_attrs, +}; +__ATTRIBUTE_GROUPS(onboard_dev); + static void onboard_dev_attach_usb_driver(struct work_struct *work) { @@ -286,6 +306,9 @@ static int onboard_dev_probe(struct platform_device *pdev) if (!onboard_dev->pdata) return -EINVAL; + if (!onboard_dev->pdata->is_hub) + onboard_dev->always_powered_in_suspend = true; + onboard_dev->dev = dev; err = onboard_dev_get_regulators(onboard_dev); diff --git a/drivers/usb/misc/onboard_usb_dev.h b/drivers/usb/misc/onboard_usb_dev.h index 4da9f3b7f9e9..58cf8c81b2cf 100644 --- a/drivers/usb/misc/onboard_usb_dev.h +++ b/drivers/usb/misc/onboard_usb_dev.h @@ -12,60 +12,70 @@ struct onboard_dev_pdata { unsigned long reset_us; /* reset pulse width in us */ unsigned int num_supplies; /* number of supplies */ const char * const supply_names[MAX_SUPPLIES]; + bool is_hub; /* true if the device is a HUB */ }; static const struct onboard_dev_pdata microchip_usb424_data = { .reset_us = 1, .num_supplies = 1, .supply_names = { "vdd" }, + .is_hub = true, }; static const struct onboard_dev_pdata microchip_usb5744_data = { .reset_us = 0, .num_supplies = 2, .supply_names = { "vdd", "vdd2" }, + .is_hub = true, }; static const struct onboard_dev_pdata realtek_rts5411_data = { .reset_us = 0, .num_supplies = 1, .supply_names = { "vdd" }, + .is_hub = true, }; static const struct onboard_dev_pdata ti_tusb8041_data = { .reset_us = 3000, .num_supplies = 1, .supply_names = { "vdd" }, + .is_hub = true, }; static const struct onboard_dev_pdata cypress_hx3_data = { .reset_us = 10000, .num_supplies = 2, .supply_names = { "vdd", "vdd2" }, + .is_hub = true, }; static const struct onboard_dev_pdata cypress_hx2vl_data = { .reset_us = 1, .num_supplies = 1, .supply_names = { "vdd" }, + .is_hub = true, }; static const struct onboard_dev_pdata genesys_gl850g_data = { .reset_us = 3, .num_supplies = 1, .supply_names = { "vdd" }, + .is_hub = true, }; static const struct onboard_dev_pdata genesys_gl852g_data = { .reset_us = 50, .num_supplies = 1, .supply_names = { "vdd" }, + .is_hub = true, }; static const struct onboard_dev_pdata vialab_vl817_data = { .reset_us = 10, .num_supplies = 1, .supply_names = { "vdd" }, + .is_hub = true, }; static const struct of_device_id onboard_dev_match[] = {