From patchwork Sat Sep 7 18:03:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Radhey Shyam Pandey X-Patchwork-Id: 826894 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2047.outbound.protection.outlook.com [40.107.93.47]) (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 C7DF8165F0C; Sat, 7 Sep 2024 18:03:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725732214; cv=fail; b=tTJYveO0PZf2tN52JYYa2VoS+iNUfhGBAHXlnVrXXSVlIa+96BjpKtti2gQVQeSpTxg7jRMF45022MJPlPJbxVFME+LuCfm40KLl8c5OPgqXTBM9adZmUk46GncX2OJfE646Eqf6BJn2WmVpLUXsHC01I8PXJaFBRyzMsvfwKh8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725732214; c=relaxed/simple; bh=JRjtY37yqIswM6oG3LZucS1mrXl3R04wDbJGRJcQZAE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FuhSS8Kq4xkr9NIqKVsjdwsypItNL9oeru6kP2CVRMFAiHbl15N+1y7jbdwN661sL4KiuWachT4N1YXcEqZawGuIpw0uBkeciu2ni5t805lOUx5EnUWCd2Sg/f3AMBW5uWZq9+t5xWW+a7Wpvxd5dvczzzSLs7XdIxTJmaAKFnQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=e8GcO85b; arc=fail smtp.client-ip=40.107.93.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="e8GcO85b" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AjszbKdP1aG3ImN2P/WGCiPtIHhg0/jvqLEjqJMiPG26piLrbHaGNV/KrNePz+Po15YMxTw2JssOcavx+BxkkGRkUlbkqUXZtmyQMtaZ9CFUBETF6sDxpVHN/kpY4ZcvIhUss0SGwlDwzjVyExBhvvjHIJeYBrwYSB3ZGJzJkx2n6VkexuaSrYstDdcqVkkdmeDc2sF2LMg5NLLBxydZbTWiYRvakGB7p7kIMP9nBHftD3Uk5jTufAlmwdhJP9QO303X0HQ8JVzVUITWn1Tkj1WDBlMc4a8mudzDk/SK6M6nWJXD//RJLXGdpj7a2x0ar9Jwju0rNjLMYl9fm+mUkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=rt1H5c2T7g7kBtmeffaAKpa2DolgGlcvqKhKHKRayVo=; b=DwzJxGwWMHNOxmYxRlLUNXPLVTBl/vI/nYUtdt7UmM41gkbo/v+9U17JGW3jvX37niznVSsJ37HA3GBxRLJ25kRaKLMOxk9cPv8WYU9v2QgXqLHgstipExv9ObD5NbRdFVO4mz6w7bhmUvvTycQIufIFG+8FoIbtPA1pTSXIqSUyDSDYTVUY3BGz9rkUbqnmRAHxM1jkuCNVmeauFfV0/wxclqoT/SMXZbd2TGxeZ4QtvZkNyC1zNxqNRpJQaq6QlKOSOxbbaXrdjt493cyXe8LOCs4lquvGbVde0iFYIjn8fmeNDZOTB8mIg+u6n1rBxSQjxQDSQOgWl2Lf0ybDiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=chromium.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rt1H5c2T7g7kBtmeffaAKpa2DolgGlcvqKhKHKRayVo=; b=e8GcO85bTKjhQsq0z3pLCrpsSmm7GQovTEXJrDJ4/pb4/jTvBTGm7H0D6/TPY5EtVK2ToJtjgrxAwLj0mj2Kxe0gOxNZVvdwdPJOOOfZ5k9HH/sDFfiuzC/zKIxTFpc7c29mF6/cpEFQdz7bYwHKtYRskKEaHsJmnRZKuCe8+qw= Received: from DS7PR05CA0044.namprd05.prod.outlook.com (2603:10b6:8:2f::10) by BY1PR12MB8445.namprd12.prod.outlook.com (2603:10b6:a03:523::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24; Sat, 7 Sep 2024 18:03:27 +0000 Received: from DS2PEPF0000343C.namprd02.prod.outlook.com (2603:10b6:8:2f:cafe::1c) by DS7PR05CA0044.outlook.office365.com (2603:10b6:8:2f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.20 via Frontend Transport; Sat, 7 Sep 2024 18:03:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343C.mail.protection.outlook.com (10.167.18.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Sat, 7 Sep 2024 18:03:27 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 7 Sep 2024 13:03:26 -0500 Received: from xhdradheys41.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Sat, 7 Sep 2024 13:03:23 -0500 From: Radhey Shyam Pandey To: , , , , , , CC: , , , Radhey Shyam Pandey Subject: [PATCH v6 1/2] usb: misc: onboard_dev: extend platform data to add power on delay field Date: Sat, 7 Sep 2024 23:33:15 +0530 Message-ID: <1725732196-70975-2-git-send-email-radhey.shyam.pandey@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1725732196-70975-1-git-send-email-radhey.shyam.pandey@amd.com> References: <1725732196-70975-1-git-send-email-radhey.shyam.pandey@amd.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: radhey.shyam.pandey@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343C:EE_|BY1PR12MB8445:EE_ X-MS-Office365-Filtering-Correlation-Id: ad7dfc54-332c-4822-2b27-08dccf675f99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: mE6Vhx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UWat99gzfQGiAHXHSkSWocjIfNtbDUxql3jB/zj3KZP92gGEQbQnJ4pHHxXOOgHgI8ANRUM9xpInAKG1bx8kvSHpVlZa+h974+7Vl15FLBt9QsqxoZt7rvPF3Y9boqUDlHiNXBJjJyuAtCFIsjk6lUbCr+wxoCXK99XqmA4IgubepSuOVjot/vnUroTchqll/Vna/ldrDfzGPg5t/uchEDwSgGkbjoP11F45tGEfroawoeYHyK4Ld67xpxuxQwJCqdlOJC8ouyKAuJ7xvN1P7HqInst+XfDfv5TGxaIVvLFCTQjJ+NQauI9WLSY/Qt4KqJXMJK1QcbtHwvPi/SkCrnWSStA1+nsQ7H8UeqpFCOJqxbw/GnD3eCXneGUZeu+9 X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2024 18:03:27.1128 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad7dfc54-332c-4822-2b27-08dccf675f99 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR12MB8445 Introduce dedicated field 'power_on_delay_us' in onboard platform data and update its delay for USB5744 configuration. Hub itself requires some delay after reset to get to state where configuration data is going to be accepted. Without delay upcoming support for configuration via SMBUS is reporting a failure on the first SMBus write. i2c 2-002d: error -ENXIO: BYPASS_UDC_SUSPEND bit configuration failed Similar delay is likely also required for default configuration but because there is enough time (code execution) between reset and usage of the hub any issue is not visible but it doesn't mean delay shouldn't be reflected. Signed-off-by: Radhey Shyam Pandey Suggested-by: Matthias Kaehlcke --- Changes for v6: - None Changes for v5: - None Changes for v4: - None Changes for v3: - Modified power_on_delay_us comment. Changes for v2: - New patch --- drivers/usb/misc/onboard_usb_dev.c | 1 + drivers/usb/misc/onboard_usb_dev.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/drivers/usb/misc/onboard_usb_dev.c b/drivers/usb/misc/onboard_usb_dev.c index 56710e6b1653..da27c48fc11d 100644 --- a/drivers/usb/misc/onboard_usb_dev.c +++ b/drivers/usb/misc/onboard_usb_dev.c @@ -98,6 +98,7 @@ static int onboard_dev_power_on(struct onboard_dev *onboard_dev) fsleep(onboard_dev->pdata->reset_us); gpiod_set_value_cansleep(onboard_dev->reset_gpio, 0); + fsleep(onboard_dev->pdata->power_on_delay_us); onboard_dev->is_powered_on = true; diff --git a/drivers/usb/misc/onboard_usb_dev.h b/drivers/usb/misc/onboard_usb_dev.h index fbba549c0f47..317b3eb99c02 100644 --- a/drivers/usb/misc/onboard_usb_dev.h +++ b/drivers/usb/misc/onboard_usb_dev.h @@ -10,6 +10,7 @@ struct onboard_dev_pdata { unsigned long reset_us; /* reset pulse width in us */ + unsigned long power_on_delay_us; /* power on delay in us */ unsigned int num_supplies; /* number of supplies */ const char * const supply_names[MAX_SUPPLIES]; bool is_hub; @@ -24,6 +25,7 @@ static const struct onboard_dev_pdata microchip_usb424_data = { static const struct onboard_dev_pdata microchip_usb5744_data = { .reset_us = 0, + .power_on_delay_us = 10000, .num_supplies = 2, .supply_names = { "vdd", "vdd2" }, .is_hub = true, From patchwork Sat Sep 7 18:03:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Radhey Shyam Pandey X-Patchwork-Id: 826427 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2042.outbound.protection.outlook.com [40.107.93.42]) (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 533A915E5BA; Sat, 7 Sep 2024 18:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725732220; cv=fail; b=NcFIgpUf/NTqCIBUFYrbXskniMNaYdIzoFRKKMKYtDMR8JfPXu+458zHmlWKz4RJmmHW/VJo1wFIhiIX5aFgXULOhnC6PZAk7/HsbZDEZ8lEjRIzw1e//o6ID2peSDSU4fEz2BBxWCr+aKWisPlez1HpD6gzwYompwrqZGNnrak= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725732220; c=relaxed/simple; bh=8gvurG0pk0PLhtOwuk/P8FNSiBORvNrB+qIASBM4QBU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TuMDhfxhPB0BXTubfFZMC0l5Zty0Xn12T9oky0B0QUn+3WA4Ebu+jo0ilH0ZfaD5pH1fd+yeWOSqxsy2jLReqmLloZ+KfF2gV2rpap2qxi1p2YOIzlvmqgPqWJxItWK8WG1+S+7qlIgV/FxfaXp9sTWO5lPZ4v9VWqhEXOUTUE8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=PDI9MqEg; arc=fail smtp.client-ip=40.107.93.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="PDI9MqEg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xErTvWsiArxa8ymyBqug5Or+7qAZ+YXAT5xzBoLg79TywlgDI+gaN+rfNN7fTh6BS0UXs4A8/Ktb0lLMfXI+M2HwxvjDRP3qkJ+uZNMHIoExwpVe/SLgahY2WsxxBPWbIHaLAmhiCLpiq6KWx8xAm4y2NjYF/1X/uQDbDulEicFv843Pfh3l2Tvt/3FDbPoxYybWHdyxwidklWA6/Xc8qT9hxJ4nw3/Oa2vHrBk99HnkNMvMY4VmZqM2G4h0lO1AVyqL4KASnnTLibsL6u6RanzpiQtuPbjdN93ooTXJAA1s83LuYyuZirRwhgzOleMBb3niocqvlHn5L22KXsB8CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Xq9nHp7JM/c1RuzM1VpRsh34OZ9zK5qM4c6E5tjiVKY=; b=YOS5yk1OpZcQBn/H4CmMOhHNDemUwiqk78ZnLU4AgCJLbVceKjvwwhIMeDBJcH4hOdnf+gwVSs/pcl3h7AIwAC5ShDAIbG0cAbbVJ1lS0eYsCWYBCgTqGOOwZFu8R+klZwbQta4PSPqBLhsSbV9c3rLkofgLGEVqNfbjZC18l4sm2VHtSyMUzz6PfxV5gjCqQuaSN0LTPtamdziR78wr5fisMzkJWpUf2ouTSB2hLc7G/sqELfUs7rhWD6ujbrHZWqP66sTldP+tNNeYF8FS+u769JBH4DATZnnvLZAadEqIJq7shmSVOKCFJQRT3RuTTA8ncC5Ap5wogaJ1if2zlA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=chromium.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xq9nHp7JM/c1RuzM1VpRsh34OZ9zK5qM4c6E5tjiVKY=; b=PDI9MqEgBVtMoo7cI6WFRpfHrb61M++cBUsede7l99CNqYocL77GSg2K14r7dRx65KwOYJWazdSEVIMV7dbNHkOuB/2TlomZxDeoEjbBGrecfOA02y/NnVe3KnYPAb3lUFQsveWzbYell651gzj8kj1JjNUanMHLLdHdmmVTox4= Received: from DM6PR07CA0113.namprd07.prod.outlook.com (2603:10b6:5:330::16) by PH7PR12MB5975.namprd12.prod.outlook.com (2603:10b6:510:1da::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Sat, 7 Sep 2024 18:03:31 +0000 Received: from DS2PEPF00003439.namprd02.prod.outlook.com (2603:10b6:5:330:cafe::59) by DM6PR07CA0113.outlook.office365.com (2603:10b6:5:330::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.16 via Frontend Transport; Sat, 7 Sep 2024 18:03:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF00003439.mail.protection.outlook.com (10.167.18.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Sat, 7 Sep 2024 18:03:30 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 7 Sep 2024 13:03:29 -0500 Received: from xhdradheys41.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Sat, 7 Sep 2024 13:03:26 -0500 From: Radhey Shyam Pandey To: , , , , , , CC: , , , Radhey Shyam Pandey Subject: [PATCH v6 2/2] usb: misc: onboard_usb_dev: add Microchip usb5744 SMBus programming support Date: Sat, 7 Sep 2024 23:33:16 +0530 Message-ID: <1725732196-70975-3-git-send-email-radhey.shyam.pandey@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1725732196-70975-1-git-send-email-radhey.shyam.pandey@amd.com> References: <1725732196-70975-1-git-send-email-radhey.shyam.pandey@amd.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: radhey.shyam.pandey@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003439:EE_|PH7PR12MB5975:EE_ X-MS-Office365-Filtering-Correlation-Id: d123a800-b887-4016-f78b-08dccf6761a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: MbU9QtabZtXpUQOwNQ4obLnhgIvxEUkhGUOrmNNm7boAzQi7TUd2wNuMCco/+lQFwIyMys6zojg1V4pCmYicunPlmJUm0tQpmOAJWw7XvZpDCi1F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R/gwN1Q3+kC84v9D8f+/6kkS5HegrxjnKZcHNZPDo1MwrCqHqiDJR+F3eVvzPrmnPrbNqpOD3D6XIzvTXc5zIQW2bPkUNccAnnyMjr0lmKuCKCxQGqDI81usd5j9nOW/xO9GE0yr77QK6zU2aZGtlIhEU6xnQcpegBYNNtGC8nDHgboyMOlTT/4gESpNTvWXG1SaylAUOX+U+XO5CxUTcB6djAddoB0RbGBmMUSEe6V/YzXmIL+p7rhJKTrURiZ3I/W83GJ3GCXfFR2FqYIxaFRSSvn/R8RcUeouWnZh62 X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2024 18:03:30.5325 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d123a800-b887-4016-f78b-08dccf6761a2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003439.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5975 usb5744 supports SMBus Configuration and it may be configured via the SMBus slave interface during the hub start-up configuration stage. To program it driver uses i2c-bus phandle (added in commit '02be19e914b8 dt-bindings: usb: Add support for Microchip usb5744 hub controller') to get i2c client device and then based on usb5744 compatible check calls usb5744 i2c default initialization sequence. Apart from the USB command attach, prevent the hub from suspend. when the USB Attach with SMBus (0xAA56) command is issued to the hub, the hub is getting enumerated and then it puts in a suspend mode. This causes the hub to NAK any SMBus access made by the SMBus Master during this period and not able to see the hub's slave address while running the "i2c probe" command. Prevent the MCU from putting the HUB in suspend mode through register write. The BYPASS_UDC_SUSPEND bit (Bit 3) of the RuntimeFlags2 register at address 0x411D controls this aspect of the hub. The BYPASS_UDC_SUSPEND bit in register 0x411Dh must be set to ensure that the MCU is always enabled and ready to respond to SMBus runtime commands. This register needs to be written before the USB attach command is issued. The byte sequence is as follows: Slave addr: 0x2d 00 00 05 00 01 41 1D 08 Slave addr: 0x2d 99 37 00 Slave addr: 0x2d AA 56 00 Also since usb5744 i2c initialization routine uses i2c SMBus APIs invoke these APIs only when i2c driver is enabled in the kernel configuration. Signed-off-by: Radhey Shyam Pandey --- Changes for v6: - Return -ENODEV in _i2c_init() if I2C_CONFIG is not defined. Changes for v5: - Drop Kconfig I2C_CONFIG dependency and instead put the _i2c_init() implementation inside IS_ENABLED(CONFIG_I2C) check. Also a note that check for get i2c-bus phandle and find i2c device is not guarded by CONFIG_I2C check as we want to return error when i2c-bus phandle is present and CONFIG_I2C is not enabled in kernel configuration. Changes for v4: - Fix error: implicit declaration of function 'i2c_smbus_*' APIs by introducing a dependency on I2C_CONFIG. This error is reported by kernel test on v3 series and usb:usb-testing 20/25 branch. https://lore.kernel.org/all/2024082503-uncoated-chaperone-7f70@gregkh Changes for v3: - Add comment for UDC suspend sequence. - Drop USB5744_CREG_MEM_NBYTES and USB5744_CREG_NBYTES and replace it with literal + comment. - Move microchip defines to source file. Changes for v2: - Move power on reset delay to separate patch. - Switch to compatible based check for calling usb5755 onboard_dev_5744_i2c_init(). This is done to make onboard_dev_5744_i2c_init() as static. - Fix subsystem "usb: misc: onboard_usb_dev:..." - Use #define for different register bits instead of magic values. - Use err_power_off label name. - Modified commit description to be in sync with v2 changes. --- drivers/usb/misc/onboard_usb_dev.c | 77 ++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/drivers/usb/misc/onboard_usb_dev.c b/drivers/usb/misc/onboard_usb_dev.c index da27c48fc11d..560591e02d6a 100644 --- a/drivers/usb/misc/onboard_usb_dev.c +++ b/drivers/usb/misc/onboard_usb_dev.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,17 @@ #include "onboard_usb_dev.h" +/* USB5744 register offset and mask */ +#define USB5744_CMD_ATTACH 0xAA +#define USB5744_CMD_ATTACH_LSB 0x56 +#define USB5744_CMD_CREG_ACCESS 0x99 +#define USB5744_CMD_CREG_ACCESS_LSB 0x37 +#define USB5744_CREG_MEM_ADDR 0x00 +#define USB5744_CREG_WRITE 0x00 +#define USB5744_CREG_RUNTIMEFLAGS2 0x41 +#define USB5744_CREG_RUNTIMEFLAGS2_LSB 0x1D +#define USB5744_CREG_BYPASS_UDC_SUSPEND BIT(3) + static void onboard_dev_attach_usb_driver(struct work_struct *work); static struct usb_device_driver onboard_dev_usbdev_driver; @@ -297,10 +309,50 @@ static void onboard_dev_attach_usb_driver(struct work_struct *work) pr_err("Failed to attach USB driver: %pe\n", ERR_PTR(err)); } +static int onboard_dev_5744_i2c_init(struct i2c_client *client) +{ +#if IS_ENABLED(CONFIG_I2C) + struct device *dev = &client->dev; + int ret; + + /* + * Set BYPASS_UDC_SUSPEND bit to ensure MCU is always enabled + * and ready to respond to SMBus runtime commands. + * The command writes 5 bytes to memory and single data byte in + * configuration register. + */ + char wr_buf[7] = {USB5744_CREG_MEM_ADDR, 5, + USB5744_CREG_WRITE, 1, + USB5744_CREG_RUNTIMEFLAGS2, + USB5744_CREG_RUNTIMEFLAGS2_LSB, + USB5744_CREG_BYPASS_UDC_SUSPEND}; + + ret = i2c_smbus_write_block_data(client, 0, sizeof(wr_buf), wr_buf); + if (ret) + return dev_err_probe(dev, ret, "BYPASS_UDC_SUSPEND bit configuration failed\n"); + + ret = i2c_smbus_write_word_data(client, USB5744_CMD_CREG_ACCESS, + USB5744_CMD_CREG_ACCESS_LSB); + if (ret) + return dev_err_probe(dev, ret, "Configuration Register Access Command failed\n"); + + /* Send SMBus command to boot hub. */ + ret = i2c_smbus_write_word_data(client, USB5744_CMD_ATTACH, + USB5744_CMD_ATTACH_LSB); + if (ret < 0) + return dev_err_probe(dev, ret, "USB Attach with SMBus command failed\n"); + + return ret; +#else + return -ENODEV; +#endif +} + static int onboard_dev_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct onboard_dev *onboard_dev; + struct device_node *i2c_node; int err; onboard_dev = devm_kzalloc(dev, sizeof(*onboard_dev), GFP_KERNEL); @@ -340,6 +392,27 @@ static int onboard_dev_probe(struct platform_device *pdev) if (err) return err; + i2c_node = of_parse_phandle(pdev->dev.of_node, "i2c-bus", 0); + if (i2c_node) { + struct i2c_client *client; + + client = of_find_i2c_device_by_node(i2c_node); + of_node_put(i2c_node); + + if (!client) { + err = -EPROBE_DEFER; + goto err_power_off; + } + + if (of_device_is_compatible(pdev->dev.of_node, "usb424,2744") || + of_device_is_compatible(pdev->dev.of_node, "usb424,5744")) + err = onboard_dev_5744_i2c_init(client); + + put_device(&client->dev); + if (err < 0) + goto err_power_off; + } + /* * The USB driver might have been detached from the USB devices by * onboard_dev_remove() (e.g. through an 'unbind' by userspace), @@ -351,6 +424,10 @@ static int onboard_dev_probe(struct platform_device *pdev) schedule_work(&attach_usb_driver_work); return 0; + +err_power_off: + onboard_dev_power_off(onboard_dev); + return err; } static void onboard_dev_remove(struct platform_device *pdev)