From patchwork Sun Sep 1 12:08:38 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: 13786409 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2082.outbound.protection.outlook.com [40.107.220.82]) (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 0F5F0166F28; Sun, 1 Sep 2024 12:08:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725192538; cv=fail; b=jcQG+dXRdd5jhL3YFahmPN/xJ6xPzIVAu+5R4SAFDB2cc5r1/PRdRc90zZOkH5UgadYTM37gR67WT7duMDFyTB00KOBERxy83zSbGsK4wUfT2seUZ0ByEMmvjN5heTbp3PRToECwMoj2lds5zbO1lz0HPUmeqWL7gpmQMAifUvg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725192538; c=relaxed/simple; bh=i1nehX9q69wSImAI7/tKFoX0G0zLrylKtfARjmcsWjY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HjgVP0mp/LrL/I4aYA1+3M0tfSCPmrgi7SdwghANeZNyQtpmrUagVsIEs6mOT30grLpqBoDrm7Zod+TUp+E22rTDZKDuDaa13wg8kXiDpRvVZcxKcAOm9RDKgmWfgPbK4jozSmaeUaBPqxlhNqOxPQrbzI1Rn5VZRkGqT/3JgL8= 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=hNlr8lsf; arc=fail smtp.client-ip=40.107.220.82 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="hNlr8lsf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=q4/isCeFH6j44hUqV2LXCexPVchbBjDdJsz7yMdc6dk5GvN3sDkCOvPnV65c3tV59x3yzLzVFsAvT0YFF/12wBajLQ+sZRYYPHUuTf4/lRToIe1zUgwNUGHwLroTFQJcAsZ/xwAOAIHCh/0WveOmf4isP5KNzCgUn+omxtAQCkU06d5v07/G09TGAlfrZ85ASX2yfwHnupFfJcoJtPg3w65MXHfv6qjEQZ5v0PeKrsi1mxO8nItxStJg7X3j1atDM4FhZyhNu5hEpxHb4RcvFL+Q1dIRtHPYAWt3lkbWSMtQsNGpliePlkHhi4SPS/A1t74vTvkmWYQB249EY3bpRQ== 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=etp56CxO7r95eVfAg0QeXfFKGla9mkaROWXj0ODbOkI=; b=qi/6UXue0teeVM/YZ22tjzDDqhbey4ZgjGO0TSrzI85snhH95eX7J8pwn+scddFULVcV1/OUtKXg9c4eZqHJ7NRMXVkLFdt/bccWlO+wM0+NBNr5bCquuLP2ciL+uXfUkVITUs0ffc+X/qkJCQOnevysYfxlajMTqfwZNJJ0cre+V8Dqwg3nVyiLfNxRASJp0sperSOGxVqNPZTLEIZJgs5qqR8+7SnEl+Zeaj8JlLvoP8vZKF05Y+oiLeHl4k7TccIBBOYy0CoyADsNrCHEMKoXHxbK/xp5sedmv9dUDBCyLEhReLAPWo88TRhLiMTKeghUxLOe80EPkYXr8FuO6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.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=etp56CxO7r95eVfAg0QeXfFKGla9mkaROWXj0ODbOkI=; b=hNlr8lsffMZrT50p6tDP4DMtmnbYSkqtkVC/U1UsMHRdxJ/oS+EhMMplwIYKRu221pyKisgXOtxQSfCybT0GDLWrpjY8HGTNvgxhGIE9iYxMedzebN55dU5sbVzQQJTrB6yyUMArNn5/BvRJw3j8LHfQMyLAWYXcdgLSgnfBhMM= Received: from BL6PEPF00016412.NAMP222.PROD.OUTLOOK.COM (2603:10b6:22e:400:0:1004:0:a) by PH8PR12MB6724.namprd12.prod.outlook.com (2603:10b6:510:1cf::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Sun, 1 Sep 2024 12:08:53 +0000 Received: from BL02EPF00021F6C.namprd02.prod.outlook.com (2a01:111:f403:f901::8) by BL6PEPF00016412.outlook.office365.com (2603:1036:903:4::a) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.24 via Frontend Transport; Sun, 1 Sep 2024 12:08:52 +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 BL02EPF00021F6C.mail.protection.outlook.com (10.167.249.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Sun, 1 Sep 2024 12:08:52 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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; Sun, 1 Sep 2024 07:08:51 -0500 Received: from xhdradheys41.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Sun, 1 Sep 2024 07:08:47 -0500 From: Radhey Shyam Pandey To: , , , , , , , , , CC: , , , Radhey Shyam Pandey Subject: [PATCH v4 1/2] usb: misc: onboard_dev: extend platform data to add power on delay field Date: Sun, 1 Sep 2024 17:38:38 +0530 Message-ID: <1725192519-3867920-2-git-send-email-radhey.shyam.pandey@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1725192519-3867920-1-git-send-email-radhey.shyam.pandey@amd.com> References: <1725192519-3867920-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: BL02EPF00021F6C:EE_|PH8PR12MB6724:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b19993d-f40b-4dad-b2f1-08dcca7ed895 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|1800799024|36860700013|921020; X-Microsoft-Antispam-Message-Info: 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UJAt9B17D0Mvjr69d515yKXdbqIYLS4EEIMt+RHpPf3LvqcQfCeNYciFi1OpUp+vNSYTws6g1gm6mqjpz/q9ua/BE2mtpHGZx5UlbheU+Ykf27NS+7JVJpIMPo/zN0VPKtVElHSFJ659HXV5SfZmhaZxGNRNmEoy4LRnM60rPTvCFr0DnzHKMYF1/8cJO7DL5ijU/Z//2tysFYEisz0gJ/28yPDA5cY1ChyyQ0QhU2rhPUci7qFmIXAw0NDS0Qcw9nLSL8Xj7y2wcPR6i97ZVi4kDreVSuIcjDanuC7en8JG4FoMRZitnka4RcTKHF84tG5vC/FBN/JmHPsLH2DE5qhZadPrELg7POEtQSz9XgRy+XXbH1fYjrzawhheJ7b1nkTR8NdXH5GLUvW68KQFicsdvcg== 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)(7416014)(376014)(82310400026)(1800799024)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 12:08:52.5803 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5b19993d-f40b-4dad-b2f1-08dcca7ed895 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: BL02EPF00021F6C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6724 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 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 Sun Sep 1 12:08:39 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: 13786410 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2048.outbound.protection.outlook.com [40.107.223.48]) (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 2EDDA166F28; Sun, 1 Sep 2024 12:09:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725192546; cv=fail; b=BnUaqahPxP/KZ8hSV6Bo2ThSYOWxHqG21fQJNXi5QmHPJ1L5+wsIXun3l/9NoJsBzT2WW9MleBligOACLWX6KsNL3mu9LsH1uPDPUHSwJ+aRGwch5Aml3MCn1YtJskmU14heRIK2cwCmihTrK4OjIaipwiDshvuS1NPM53Gl3lI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725192546; c=relaxed/simple; bh=rTf5h/JBKa28eI3xi2c56nyXYUlttdfsfNSuQnlTBm4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GeqmRbPAHs8In6JI/ZL9D9KAHy5jALDDzUr6J/5yFIjR6QNshWZ99BJSu5YAD8hxcaCmwPTmANw5F2QRl1X3TtP3agIJjBugIr0xoutafSO9+H+rR8BUKkzBq+VoxDYfVi/iAOO0Wmp060/PiibXEpy4sC++ohPY4mV389siNGM= 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=ltSd1k29; arc=fail smtp.client-ip=40.107.223.48 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="ltSd1k29" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=u/J/Uv9Pr2BZGNS0WeGes6IPAY1xeADnmr//LRzHKzxRnCXqp03r4uQQVIKltCOO5o2iTxHAMHgCtPXFdYpmv43DtSJB3Drn3rkqM5BeXgXBlKxJwLuDRzL60U/XWTB4xJPsZsWy2/tOmEKBFElPT6OPsTKEY25hJC6FmNNSAYJKTniscXHumntRW0hlScvtAAjDxmpquWpJOmFZeZr3CMloZ86cRPAXxf4QF2EHgtN9IfwMxV2ho/v5xeQCJyxizKfHLj4ZDWlU/EdXhEcbUUvsnsFAuxELvgxXPntpwyuhfV7iGnjdbsUMZ8wnsXfT+Mut1ylZvB3u4pZwNwyrUg== 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=OVnUAY4XHoBPZe3Wgn9Hp7aaHS3rl2xGyvH3ftQB2jU=; b=KOMZMjWeXwDl7Y3uSazAHXjCKSd1QBRzuPAoVZGIvWruhLGqgE+96d27ETrT6DuS1LSpsnK5ec/pN0LkAxevyawJ+5pvIXyn0/HMyaXWBseRtb7o5rqutGtQ44aUDuCUWNpktHfY9Jk6m9uoFewOZEmYuy6//Ty4dLacCLZn+1angalYonT0luz6zsvYV0xCd1fKpwfmIoksBKsDQRhWBH8mjoTVE0fvwbtThXbLGxhfL/WtImhS345+Mlqk1bs8MXx9aUG6cDb/wbzo+LlqtrRAbvZTygBINlTE9ctiS2tm+EuzCjr8hPZfHkC65W1wMDHYe+M/LE25H8itx4LdGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.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=OVnUAY4XHoBPZe3Wgn9Hp7aaHS3rl2xGyvH3ftQB2jU=; b=ltSd1k29zLPg29WEIsc1JidlZpKWBVu/oqvNLCI3bfiFFdzT7pdRkJIaEnznWyj7hWYs6z0bKkwwjJW9YjT7bxGpqjHC6dynx5nuLG8IR1PjwAFvh8ti5Yqv1olD1LCytCjjXUjChosk2JSYALNVM7RReXqwfdcgAlc2HEV96tc= Received: from BN9PR03CA0650.namprd03.prod.outlook.com (2603:10b6:408:13b::25) by LV2PR12MB5773.namprd12.prod.outlook.com (2603:10b6:408:17b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Sun, 1 Sep 2024 12:08:56 +0000 Received: from BL02EPF00021F6D.namprd02.prod.outlook.com (2603:10b6:408:13b:cafe::75) by BN9PR03CA0650.outlook.office365.com (2603:10b6:408:13b::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23 via Frontend Transport; Sun, 1 Sep 2024 12:08:56 +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 BL02EPF00021F6D.mail.protection.outlook.com (10.167.249.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Sun, 1 Sep 2024 12:08:56 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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; Sun, 1 Sep 2024 07:08:55 -0500 Received: from xhdradheys41.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Sun, 1 Sep 2024 07:08:51 -0500 From: Radhey Shyam Pandey To: , , , , , , , , , CC: , , , Radhey Shyam Pandey Subject: [PATCH v4 2/2] usb: misc: onboard_usb_dev: add Microchip usb5744 SMBus programming support Date: Sun, 1 Sep 2024 17:38:39 +0530 Message-ID: <1725192519-3867920-3-git-send-email-radhey.shyam.pandey@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1725192519-3867920-1-git-send-email-radhey.shyam.pandey@amd.com> References: <1725192519-3867920-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: BL02EPF00021F6D:EE_|LV2PR12MB5773:EE_ X-MS-Office365-Filtering-Correlation-Id: d22e308a-3bdd-48a5-d5ae-08dcca7edade X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|376014|82310400026|921020; X-Microsoft-Antispam-Message-Info: 8N11+BTuQ7L4nXQvC+ihwuk8smfyOPuAwJphIVWOzsQUCadWwnBVijAltLd+s3iWp2V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ZXeBlLLb2W7lfcHfVFiFCw3TF/qQGTilz/1hpsg71rouCioGNDR8Nx19JM2TO8WwJ4AG7J3vrIz7wmnpElE8wxi85XpYIE/4V8VtfuUHWB5L3uUK6WBcKaM9fE0C7r9BfjVzBoOgWLXH5qSSL73gwvxkD9MrM+wkyl8mqyy43r3uT70eFAq82CA/x9cjzFhEZSrlKDOvef4MWl24QQ5r9nnrVSuUR0OG4nl2vzQH7vehY3VgVGfmOUqx9pGeIOKHXwviy7Xt8B2KPIpSAvL2ZQr6W7hvNxhOG9JRB4ZqqD2zwRbnqHjN8x3vH7XD3pL0Q8mtaHYxQ== 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)(1800799024)(36860700013)(7416014)(376014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2024 12:08:56.4463 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d22e308a-3bdd-48a5-d5ae-08dcca7edade 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: BL02EPF00021F6D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5773 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 Signed-off-by: Radhey Shyam Pandey --- 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/Kconfig | 2 +- drivers/usb/misc/onboard_usb_dev.c | 73 ++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index 50b86d531701..cb5e47d439ab 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig @@ -318,7 +318,7 @@ config BRCM_USB_PINMAP config USB_ONBOARD_DEV tristate "Onboard USB device support" - depends on OF + depends on OF && I2C help Say Y here if you want to support discrete onboard USB devices that don't require an additional control bus for initialization, diff --git a/drivers/usb/misc/onboard_usb_dev.c b/drivers/usb/misc/onboard_usb_dev.c index da27c48fc11d..247600015bca 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,46 @@ 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) +{ + 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; +} + 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 +388,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 +420,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)