From patchwork Tue Mar 5 05:55:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13581686 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 08AA0C54E41 for ; Tue, 5 Mar 2024 05:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=A8HGQ6GdgEeE5ElxKNQncn3H26qTg7wsGYmd5TH9syU=; b=vmvveSrUXmQ4LBxbTew3iWQPrh UsuF6fARnWRep3Xor/Dp52PtCgp5Nh9aTRtdngPFlYDSe5Pxf1qcHpalsqEbOqBpe0c08Ewy96/1B R9JUnhAlrprB7lLGELaZ/uauMMqhN8801JQV43zvi9Jemvz+t19734FfUW07o2r7aStkReVw/oX3b kYVrHojOIZThYtXDDvBubKIIsRLGbNWUZPq+z7wEgBTLmOns8H5/z+sPbODEOoXk71sAiadWaxBZp Xz8MTdGp7Dgr+QWU27IQNoYz3RvSRE9Y7MtcbeWiUDdcdvsWtPt8tbsnynaGhkZs/iDfKuge5ahhA SqjeY0rw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhNmf-0000000C3c0-1SJT; Tue, 05 Mar 2024 05:56:13 +0000 Received: from mail-am0eur02on20701.outbound.protection.outlook.com ([2a01:111:f403:2606::701] helo=EUR02-AM0-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhNmA-0000000C33X-386a for linux-arm-kernel@lists.infradead.org; Tue, 05 Mar 2024 05:55:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U4wBhiPtO+eUtXUzdiMEMC8X3rKCdQUWQfIp2278zk5Dud7nIpdB7SKIPmOB4d732REFYe3zX++xapckfbDtncuih5PNPweLXHdtAoB6GT/K4SvSObmAHmr298Axge+yTrqROKAhTqQkUjIg0uB7JXN5nvMa2rhammCqaAN1gu4ugblzuAgCYVim9CAXBa0BeenYWObmo6OUCqsbNQcWm8fITMOG7V4TkCqN9p/MU2t6aaRlas3h4sOe53l884Zx4czfyP3xjxekqT7cofNAdlbGrnDc0AH/ruk6AzY4NDJ1KvfRm4+vQtIfgcxjRVA0R3VdiJ0f9k5xpExt0M4euQ== 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=U1CdGpA9y443e3RqRh+YFYO9AtKfAMW080qGmyfpPo4=; b=RrvURRx5QXpaSLMeppACCxiueKYs49prbebtMmm5E7rSD9GY4ClnhN8L6Dds2F/jRxS8C1UqtPcNhu0Nm2EpdvgGoAyGjUcAaH7KzgJ3ujwCVQVolqdKdQmWqMikp7b6mU0MH7QlVOnW4XC6tcSbMz9sJSij+UbMKOPTRoG2YXF3zappD48NyH44Xfi99J/K/drVLEP6+i5oBb3pbbJF4qfx3I14q5kCDbRxhkf62mdw/j/3TghquNGw5eyUIAmg6N/Z48zPDMm6RYt/usHiqDW4Jd0AR1G2xZhsTA4og191UBm+2bUxErB5tj/vCBE7JqHfAFZ9aLCAiZVvqCyaOg== 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=U1CdGpA9y443e3RqRh+YFYO9AtKfAMW080qGmyfpPo4=; b=W5csrf+aCOrROERv+DLxg8I9wj30SOZtaYk7Z1VXzpSVyuKROgmsdRGa/5l++OL6inmNSrvO0O9kwEuo/ucf5x+2obLA1g1GOKVLcQdvG5+7usdLqruU3JAJkbXqpNDUCb9Hjbvb9gg2A3NwvzQ9ntfRhlgXo4dDK1XCVjEMDKA= 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 DB9PR08MB8385.eurprd08.prod.outlook.com (2603:10a6:10:3da::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Tue, 5 Mar 2024 05:55:18 +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.7339.035; Tue, 5 Mar 2024 05:55:18 +0000 From: Javier Carrasco Date: Tue, 05 Mar 2024 06:55:07 +0100 Subject: [PATCH v7 7/9] usb: misc: onboard_dev: add support for non-hub devices Message-Id: <20240305-onboard_xvf3500-v7-7-ad3fb50e593b@wolfvision.net> References: <20240305-onboard_xvf3500-v7-0-ad3fb50e593b@wolfvision.net> In-Reply-To: <20240305-onboard_xvf3500-v7-0-ad3fb50e593b@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=1709618108; l=3971; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=wHEtQy1snznHud7XugAlCGlHC2ytRi60iRhCiOKvhRQ=; b=wRJDUqanRxqeT9+JJ1vwwr6UBao07gzhCDfnXIVTwjfONNszgk29KaNHFtj53SlxXtOrQORJW HXwSXiHb0b7CaAaaY84qCC32z/BeGhx8qkDKoK1LrKaVbXT/RtmmCik X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: FR4P281CA0110.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:bb::18) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|DB9PR08MB8385:EE_ X-MS-Office365-Filtering-Correlation-Id: 071e3fd1-3324-4eea-fd39-08dc3cd8d620 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j+b7KErJzEd2IgNME0u7NMKcEykvZtY3vz+aiki9NWkl3BEr1SRCLa1fuvMyiFplzqYMGFZ0uXyWtXmKSMoJKVzSWfdH3nQF2eMbpl9nGWiKEQ6rBFJfthO0UF8RwDYV1K6Be3wBGhk2YYiKZ5dfvbKjpuD7Zln4iZ0KLkcFf7F6Jlmr4d2HyPuKjaQ7iqA9ZHGBCB65V6+qEaEfVS9OFiynt8PAL4a1G9igXtR944vwCY6UYxqXG7HDzChOTUEldE9QY4MBeN3Kc4ErOwFdTl//KtdkhoHAjKH9ddKZ2+ofP6z9UmsOxKC4k59wfsGiztZi4moIie+qnzKsMEYcJ4so644iU/X/XmiR8dI18RYKZbdvN4b6hSRKR2YIfbeNKNzRXmd3zNg0bpMpkdf0yZrbxoA2+1IUx6i+t62QnS1+tiSO5dWzHAazjd2XX5lg76DZkPHV1u4AyhBffk+iJ9PuBGlnvRfbwMOnRunR/2v6idh/E0aguxyT/dfy4FdB9jxCb0r9Kj10qyPAPkHWpAI1gqcmU6qLKeS3qJFJKMNUvi7rEjP7xOGQdyFIMeD6hUQBYfQdfEJ7Yi6D/cOyoCkg9ONaHuzBMCxpl5de5+ofGcdJpiulQpwOJrMQj3OFpq9qpa2zpvagR4IbkD7j3hkVNf5J7ryKtJhuN4zuBMYR23BXTMp8MAVbsZ10hrTpIu+2KdyeTUxM4gXiS6eZqibo3AhYW4Cram8XUT7a2lI= 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)(376005)(38350700005)(921011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?X+GfOidc2o4dVOfYurGth9sxG7iz?= =?utf-8?q?MeBo2BzvSldxEM01XbZkHb+djSFTZXvtRfO//Zdsfy1VakGJQVuXgE03e9AVnXbZ7?= =?utf-8?q?v4YuUNT3Lac9YljzkrGvNcPBHap0B3tkJN6m7n3My12TGinoCZvGUO7JrThFgdEN/?= =?utf-8?q?ctvYjfUr216Y1T3Z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d6SQgb6tlJ36uavZo0KVfznBuYzHEdfjiydqni3G7//0q?= =?utf-8?q?B+wxJuVz+rtRt+doFqqxl0bxClm6IAjTfGi1QqNxUFa5RXmkT+i0BZ+Uv9D3hpOlP?= =?utf-8?q?IgZBqfacxX6+cla7w4cTcU/ruHd4boXwBrdAa0I88xGz62t3bJ8Om4SPR76FkOslm?= =?utf-8?q?q1jAzCf+O/TetIlsfk4TNUe+m2+X0bvMaI+RmKDw0URnvWlNP3Ldbok6na7UcKKzF?= =?utf-8?q?SHj6tKnKVJt8Q1znqFtRWfSuzLaxh8S82dz3XMeWxVGQhZsOeqBAo9Wfw1zsTBbTc?= =?utf-8?q?33zPtcCodwFKgvFwsFJYQ+J9i4Geiv9eKG5BE0/vgm150eIypRCl/cOkK/l5STwvY?= =?utf-8?q?yn8nHP/86Gey44BWFNl/x1j3tX54HvPNCOPZcH7EZyqX4Do4HQboouobsP06v8y2E?= =?utf-8?q?l3aQuc8X+prMnq4muCtHqdEogKkkOENedVcY/oLyhttLK+6IcemVTzX2Z+rXK8FX8?= =?utf-8?q?v+AAJgqGf/oNCtzlwFLHGgqiBRoWI8rTlg=3D=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 071e3fd1-3324-4eea-fd39-08dc3cd8d620 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2024 05:55:18.3743 (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: acPjnPC28pdT8m+3AXsKpkFMatMbBGpP/iC2+kkOKSK5w6ybtcnnFFVZGs0CJgTCpSo4T1kdusKj1jTajyCaBDFazXgq/GHCuMCvNLqSwco= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB8385 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240304_215543_081202_14BAF4FB X-CRM114-Status: GOOD ( 19.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 | 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..ecdce06ea0f9 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; }; 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[] = {