From patchwork Wed Feb 28 13:51:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13575478 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 6DF271586D4; Wed, 28 Feb 2024 13:51:50 +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=1709128312; cv=fail; b=A+auUpRA2Gyj0/reGEEzw37VpQokhHDHr6SKU+s3DrTHI3rgBVv9VmpSNjnCjVWWm+hDeHmxazhUwHt4CR5lnlNJwkXML92imVn35r+kPBGZ7lRSM2ZOmEDLXeOr2GJV1sY88NLEtsMXQ/pf7fc06kDNXEIhwx16hGoj4KgcVdg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709128312; c=relaxed/simple; bh=moj7dNPzywLu5KBQuWEF56AL6ondXwteo2SwhW8gJKY=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=hps2UtGMRIRNechaxkGyikMLgwl7cLxwUYanrUKqE/r5A+qZWbHK7caG6YS8OJ3NBVh2hgGYdwnV+ta8gEAzexZP1RZggzdEHdrk4BRsNKlHn8xsbAwSNFR9Z48434FJwA8luNv4nJxaV2XwYM5ZTX3pCkpARdw4OElty9RMgRM= 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=nksWASWU; 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="nksWASWU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LeF8qy+uiXA3HI55U4qIV18yxDbiapz0WM9BRdotXj1eCelM8xUHNt2mDfgqKzkDSiOtlIWCAxHd3LFFV8G5dw0zLob3GQX7cJzq2nMuAA0AZWEYvKfCz6meZ4Qmy1SOue0DN99LEuk8CHTDGdo5fO2ogUffpzDHMNFdDuGR89b5LHtIVKMlj1xH7UBGhackZ63M9pD6fSSryhrWOt8jVR3k/8iPOMG+scMZXT7jpeHL51PVF8m11AkOc7t3XyOedsQgyAEWFH/4qr33ZQKtgn+xJeKYurQrveZiXDxDV72sL9sgNoHGZiWyJ6Qj/hCbtfdpOyBYRvASmDq/1T7Pig== 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=k5SXUlle2NVEXwDFcWjTn+XnAibneyXcGO3oVO7aYIU=; b=aNf+S8+AJ1vPzeYD3D3/jOQ/O5MRsNoPJOAbVSbQ/OjWRw019/ObxBVCJTj9QJZn5VskBzBC3VLasBhsSzZAG2tZW24r/vAXLAkJcrHmzRnciWxV9p+f2IAGeaIS2KYXgdvmvL8086k7D41tH6+yP0+VzW2JNK7wIW3jNJXNFpsjA8nCL0cJbdiiCqux9QI80STRijB8NuRalCy209Wzlyq9VK8D1HMI/tG+LOPUAKSwrN5OGyiB5E2/oEUje0tgrTWVoDux+t90LyMrPhG0VWic/m2oFyB0W8/Fg6VTNep10SBVWwrlx0zel+bPkXVod0XMlSbwT7JjnkO2hWpj/A== 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=k5SXUlle2NVEXwDFcWjTn+XnAibneyXcGO3oVO7aYIU=; b=nksWASWUJtTZfr4ZUl9jF1YGQ0L5j+W9xizP5TWqGdErX3biKgwUJoiMbdVJb1mvRIE+iM1dyCONuE3Fcpvkp+bZygV9qjf1Wy8sPxYVsk9SxMM8cF40NREVBecVJHKoqZHWougYUNL18qpPs63I6UrX6250Kjw1+mDuCId0c1Y= 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:43 +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:43 +0000 From: Javier Carrasco Date: Wed, 28 Feb 2024 14:51:33 +0100 Subject: [PATCH v5 6/8] usb: misc: onboard_dev: add support for non-hub devices Message-Id: <20240228-onboard_xvf3500-v5-6-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=4013; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=moj7dNPzywLu5KBQuWEF56AL6ondXwteo2SwhW8gJKY=; b=QRj/qc1Eh7opso6M3JwpKRV4SYDiDZ+bYYZa0ss103gWaRUSBk97Zg/2pfEyJ0JJP5DvFa+c0 n4qoet/jCZnB82ocwcpygGVBJn7ddafJJWuTAAlzBMKhXULBtiJYw/O 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: 07085d1b-f809-472b-bcb0-08dc3864656f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l+xdbm7iEuH4vU3B6xmAgcnVSZ+BzLEQ4BYVFlwDGJAGFIIMm1iJy1L/6xMVj1npe0U97GNlG4XeuAueUxypNcX95OolgWapvgGyJPMtMaCuDy+olOCyB3TDLLNeDwnN8zOsOCBSq7kvS7IsbwkXG5DRJCcQzKMvvuVIFMKvMsHcBa0jf3wZLdGT1GAGUDTbDRpbqMLx3koYr+jXvFkLry2VL5XykmsqbY5UE7Eg56vLv/lP8hSs2q/5PBOJXWzMYF3fIkMSBF3i+5jv0KXSWM3RhGeeX5P04xd7Tv0/cIO5qtm4fi5B7dPorH/8v3mXQvW5Wh3A3kHyYrYEFoepCKWwy2+rSUUTT9A6Z+A/jCqeqjFA4MLjWfxeFwzttZF8k2brCmlmWhuaACsc5N+9LOalAJMwqyZMRzq4FnMgbPriWLYB9Trj8uHAHLQ6VKqCEkWjTYoIPFi7PEQ6xF65mxfk61UBdZyI4fpvwpypnPg3nT2LFwzAD7K24eEciUGIIrDuqHFQ4XXEmPbwKDdWCq+sNVcnNMdlhzGN/6XBSBpKAELS2YOOCaXHfbt/gludCKyTatp0hwQeYSBJs0dbLpqRL1uFDnobsFfHvgh/K5oWEouJKMasm2PXwNB3TwVYyPs049slGWN6Iadojh04Kagf0E44oBmZskgvHcG0IDkflKJ4qj5ma6tt4L01raRXSrjKKeY5wlfzevtCjf/D9SE5qRII7D3t0pTWBv9cl0E= 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?GqWNqurMkfRfFhGizlH0qgs7P74B?= =?utf-8?q?k9cQC79rGMIOg0HJ0R/6a7tqDKtcZCDQ1N3WQJdyFpaVh7o3TciPSGXRYWr18nmLg?= =?utf-8?q?skkdi2wJSlYLvVyO6SrfVh3OFVqNwfA5nR/c3LJhiSSS7RD5MAF28PwO2ziddLxOf?= =?utf-8?q?c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mULAlbk6TYLZBzyirnWmhIIl3YRzjHsmT30fe8oLLZMZG5O5PH7JSq8JEZdOP?= =?utf-8?q?/jc0C0xI+4NGaSJmx9eQ4UwO+VC20o2RHfMoWGtQBt0oWZrqRipJ6A3k0SH0Xr/h+?= =?utf-8?q?iNGOQBYmllDQYho8G/VfuW7hE1Bjn+y6VGVB2z8OCIa/T/4YMWWMRiBArePG3kcHE?= =?utf-8?q?HYlVzd1gyyScqUci3IVsg3OXQGw6C2DoN1ZkSqc2ZZmusqFocxHiEYkJ/mmO4qZBG?= =?utf-8?q?TkMd+Ib2/+AY2ce8q9gIfQbCJ0jmQSuv4sTdUSCAFHUb2beiZT4MOxgfxKwVljOwV?= =?utf-8?q?Iy2aob33SriakPG8eIMk4fLR9JnS8zcZNdRPKoQJDtk0txj33Ov5V3uFQj+ZuvdhG?= =?utf-8?q?GCgCmf3Gk1xE6nYAHY551QM6xWp5qC3B8jVkPvDXaWyucNImaXLuMjye41CAeGLt0?= =?utf-8?q?W3Ki60rLuVk8VDDHi94EuuoQAnIdd4N3+wTQbdvn6kMr9bG2o77JnBckVnE5ITIlH?= =?utf-8?q?c9i4nqBVBm/FeYwBUNUExikS8XEd+URY09o2AR/1T8RL3SplJ/aKkOo=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 07085d1b-f809-472b-bcb0-08dc3864656f 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:43.1062 (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: oOxr4soj1bARsuWJ1vmKOO8S3DxJoXtun0O1lD77L6D5cTE32NIcZF57V6NBM1NVemtI1jJTqnaI9Bia8ftJntYiG5Bd7x/18hFLGj2IWiU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB10523 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 --- drivers/usb/misc/onboard_usb_dev.c | 25 +++++++++++++++++++++++-- drivers/usb/misc/onboard_usb_dev.h | 10 ++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/usb/misc/onboard_usb_dev.c b/drivers/usb/misc/onboard_usb_dev.c index e1779bd2d126..df0ed172c7ec 100644 --- a/drivers/usb/misc/onboard_usb_dev.c +++ b/drivers/usb/misc/onboard_usb_dev.c @@ -132,7 +132,8 @@ static int __maybe_unused onboard_dev_suspend(struct device *dev) struct usbdev_node *node; bool power_off = true; - if (onboard_dev->always_powered_in_suspend) + if (onboard_dev->always_powered_in_suspend && + !onboard_dev->pdata->is_hub) return 0; mutex_lock(&onboard_dev->lock); @@ -262,7 +263,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) { diff --git a/drivers/usb/misc/onboard_usb_dev.h b/drivers/usb/misc/onboard_usb_dev.h index 470736483cdf..106480ce72b5 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]; /* use the real names */ + 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[] = {