From patchwork Mon Mar 25 09:15:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13601724 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2097.outbound.protection.outlook.com [40.107.7.97]) (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 1063916D9B6; Mon, 25 Mar 2024 09:15:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.7.97 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711358131; cv=fail; b=S1Qkcs3MPmbghWhpneUARJUQgdI0aGRTN2lJOURIX7BPhL8jgvVCPSYnGy1LRRGs+h8OO9bg6xrUwSJEXgLZBF30129ZIdqebuhBh21lefpgcb+XdbZAdcX2UvxFIszr/R4vxiiWBObUIhTnGVnx3zk1BoFRdNccSz0xrca8ECY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711358131; c=relaxed/simple; bh=TZQhiTzzMHNkCwR9rUpRWSA2CA31wBBLiqLduAbUesY=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=YEUlciSriT9ymHBtnttMesXutHJd4kWbdCytp90pKtfRMuSzbN2MuvrD9rft01I6EwOt0N8GybJ9fMcCDNELF15xmlENWSpaJLW5I0NbVC3Rpxi3iaBh8bt/XgMphBz+vktnFp28vuku0Hsjdlqta41vWz0gSQll/1lYdMgF/9Y= 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=Ud6g/Hiz; arc=fail smtp.client-ip=40.107.7.97 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="Ud6g/Hiz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IoZmCoul5BI7Yz71/azGOqs6gjrtDJ88afjB7N3/jqLnhQlkDR6R1ANOaVU0yGAYsZN9M4ap8nHJMiQzRxITDM6NnAgg2PN1uCUJZ+Ci+gkaaUEXXLoR58JfnG4uW205f8dBWG/VrUdSrimP9PifzdaY9BTaDXVfQVBTPnRa7kq1zIdHms5hL7uyXzN9iixK4zdb60rHt5Cw1+qItS3YPQV/fFiUdtwHDX9y7GZuM3eTzjxWWwh3IUVWMKPolYE+uGF02cVqCBT309jvJIpsCpuEbxsStIFrWH7vXymclahBgvkq48iQA5dFDuxV1C2K2UGexGzjzTvrbqT0vO9qFQ== 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=S0i+W8GryJ5fTxOdddYdgKCq4aMHZ5qqCN6E+23nstI=; b=DarYYOCVTuoUdIFHmwqn6+T9kMsKHDNlbfHdaiPcK4RYYeKToKihLPrjcnnUoxIZ0uvOUfrOUXZoanE44P2k7nnLUp5anDTA4TGGKzbr3EcCRzQ7kOXbxL2Q/SpTFxNcGVO86Zsfs5SjW3kEGltWNMqrJ7fwANBKHcmmA8rkSiIAy2xXt2HsWBsNh4PzDW6pPEadx3H1x6ETfDP7GO/2ckI3Ip9c68dXqlVfgRrasKrgTYP20LeAg/YniS10wcyLE6KXA0VyZGQXSAiHl7rQCacnM9EhcgwxLWoWdqvmDFCfLwOk58UcHR06lNFJTph1w0DBLcrHIj7SJVEkMDJRCQ== 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=S0i+W8GryJ5fTxOdddYdgKCq4aMHZ5qqCN6E+23nstI=; b=Ud6g/HizAsfXDm5mSLuJAv3Q5JzikLq9bm+Rvxi5GxG7cyA0d0TmiSXJoVBKNCU2i1ocLu+KdYQBTF06svKUV5a4nlEdtDrLX1ncur0b3FokgriekdJMQM1GHSTz1KvHuCvLaYQ80WmzlaQCx/out1ytiumL8DIwUrE3ZlYLlgM= 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 AS2PR08MB8951.eurprd08.prod.outlook.com (2603:10a6:20b:5fa::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 09:15:19 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::9e35:6de9:e4fc:843f]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::9e35:6de9:e4fc:843f%7]) with mapi id 15.20.7409.028; Mon, 25 Mar 2024 09:15:19 +0000 From: Javier Carrasco Date: Mon, 25 Mar 2024 10:15:16 +0100 Subject: [PATCH v8 6/8] usb: misc: onboard_dev: add support for non-hub devices Message-Id: <20240325-onboard_xvf3500-v8-6-29e3f9222922@wolfvision.net> References: <20240325-onboard_xvf3500-v8-0-29e3f9222922@wolfvision.net> In-Reply-To: <20240325-onboard_xvf3500-v8-0-29e3f9222922@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=1711358115; l=4134; i=javier.carrasco@wolfvision.net; s=20240320; h=from:subject:message-id; bh=TZQhiTzzMHNkCwR9rUpRWSA2CA31wBBLiqLduAbUesY=; b=z0OodHFpcDutdzh6kgspB8J/l5t0Eft3WNWWdk7b3MsvI83K7+57eQJE7s7ouge+aix99+X3Y nF+YZvLHgyNBw3cj2KzGODqYd5VUJ0kPDAOjHl2yE2CtvjCbC+pABsK X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=Vxk2/0sGIxM8rsKnceszFuSuHVfQwa1Yo8+is7BX2nY= X-ClientProxiedBy: VI1PR08CA0223.eurprd08.prod.outlook.com (2603:10a6:802:15::32) 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_|AS2PR08MB8951:EE_ X-MS-Office365-Filtering-Correlation-Id: 81f5d71b-7dd0-41fa-bee2-08dc4cac1792 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xi5qVsQUAxCK3LVnGYIXlqZ3ojDGOd8PxdkrV6+uZuRIx0BokqyISSimY1QqVdWHjFYOqqp4iZ1NMjxhdKYkZAT+GjxiSrj6U8n39U/eMtQOJdjIQb6UQICFx0Ye1ey0M8aQ0F5Qiqnh1VaDYL7UePULV9cc4WSK2nYRT8SJ+B2g3G6lWa8nXLBed0YOX5kNaOSmlu62WwpkKQpncZF/nXPuZuoH4Y09nZkW9xWkeJTGhIjfA1t7WvErQLY8EwoTuzeb+0Gv3XzirCtWD6LxB/CFFDbyVMLhfAlI++MVYMEmLKJgoaBCBqZlOOWL0DOgDsMIH2SGy5tv5kmbp769lbo8FoKPSpexNBTVZSJhMxrklLIO2UBBVXxK1SP7o3cLq7OetmP5b/EsIC3a3Zbvuvk3tNUzO8uYMkVNcBWWIIm3Ei6UAv5GpKeGbOOUdHK2UkpMsm2V6/y6KUgcydjr2nbjnQDGiVb9J697GBRmqWqEWABFbNs2oMdBM/V0yijwO4Cd88K/DryWDrWzUQpYiJaI5+W8YKyBxCtEOswjkWXa7jpJIIUH0XZea52o7816RSnpCEKQKOQEDdpNnP1dJ+WKsLVLXfDSJCUTuIHkFgGOWk5jObjt3Z4KOJug31ME7DI8yLOWlOHFlCkkTw95rLSd9TrLsBL1A1KsZqy3I0+T15WEUTe3PQ+3CDx1T1VnjWQOgYxeoSAsVX7fEDWxwcEDsWUIePbYTZgdANAtjq4= 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)(52116005)(7416005)(1800799015)(376005)(366007)(921011)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?b3FIU35yv+gAMJF7fGilvItjiXSM?= =?utf-8?q?WDMfSnUg3FAAvuYeFBYb4jCc136tA+FZGU3ziW9yCvQ7h9Y3NDdjU6EIymKxHFEQy?= =?utf-8?q?BU3jYI2lgBN/IB0q/IY8nY5ZTA465ojN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U+U6LjJSxSTuFCrsAp/AfK5cedoFHYM+H?= =?utf-8?q?xWh+iIEgQnkIu5SZ8KJoJ/7R8fEmtOHI0NiRklTy4KA49iZ1giUemNizy1gCr0Djx?= =?utf-8?q?M5ZPPHAZJM80UYR1/wv7cgTp4/bXCeD4ySsJ39HawESd67xVI0aGfEP8iH8BM1Nlk?= =?utf-8?q?O7Pi0ffV9FKBHnjPKyQ0BpkpgWzeHbLHDjS/sUJHyPukX1Opa2M9VH/xfV7KMw9ac?= =?utf-8?q?5wW/TOPa5Hq/5ZhJVrn+g8nOw8Ur5zD24QzxVrqTk8pkGWI7z/5UYSA1+BAzgWY7f?= =?utf-8?q?mpIOu/DpgMgKSEUtPT9F8PXEj7a2uFpdFzNh1X3BnZ3w8rQXSGbbJYxY5TXHOrAKB?= =?utf-8?q?n+k0GpQTdpvDk23HBf22fAX6jwrbYHlBsiDWjTWX2O5GMkFRgSVznflsp9c5j1YdC?= =?utf-8?q?ApIrhzapgjMegh8PvEzOShqsQywDqR9/rcAnuUuDgRveBBYTvvP4AQ535n3Xq3nMV?= =?utf-8?q?uTcjWHJCwleFyFFggPGtvgYrCnleTanZ6Q0k7fYD2BfjI8bquRp0/7nP2gZzznNA3?= =?utf-8?q?fisiNscvqgr/Oa48pBz19I+qeL660DJc37BvnpVw4bmYbV4dfzkulKg=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 81f5d71b-7dd0-41fa-bee2-08dc4cac1792 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 09:15:19.4638 (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: S2RzPfEvjW7jOk5qREGFHpPMTmM12PnHzctN2R1FaRc/Pg1QW+ODiFcJZ1OhHL+U6y0FgTw6oJSCf43rH9Tt3WkL5nREjxFMbmaQa1zuRpQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB8951 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). Acked-by: Matthias Kaehlcke Signed-off-by: Javier Carrasco --- drivers/usb/misc/onboard_usb_dev.c | 25 ++++++++++++++++++++++++- drivers/usb/misc/onboard_usb_dev.h | 11 +++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/usb/misc/onboard_usb_dev.c b/drivers/usb/misc/onboard_usb_dev.c index 6aee43896216..f72f47edd87e 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 debab2895a53..b6fd73f960bc 100644 --- a/drivers/usb/misc/onboard_usb_dev.h +++ b/drivers/usb/misc/onboard_usb_dev.h @@ -12,66 +12,77 @@ 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; }; 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_tusb8020b_data = { .reset_us = 3000, .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[] = {