From patchwork Wed Jul 31 15:42:27 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: 13748940 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2048.outbound.protection.outlook.com [40.107.96.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 AD2FF1BC065; Wed, 31 Jul 2024 15:42:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722440564; cv=fail; b=AFftRwi14dz9wlUfCwzVTTZKXLUQnTzxew6pMwlS2cEK/EXeDqt/HhKxvk2WjVcZKmQknWJ7XGGnR5cxBWyvUh+Y3MYOg+bJjPxuJo+vg0zS/VmoLZnogQMsQPAT975a8nbkpt+8aQgJQFykyFsrwIYK37zqfDNfsWDHf/Fmpzw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722440564; c=relaxed/simple; bh=5ay0Gt0hva7MVhckA/jSt8XQTSk8oi0Bn/H/Y3Mpq7Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ftnTBNX5XbzF+iggmJcpcLxw9TomUqWx+GGCF1pnymRDpfEnoGB4x4m9z2tBMPkVfLOUMDFG+Fr3IX49QYMl40+BmxiwcVzW7/8azOWHrAc6DgV2kfJnAioeXmzTlSea2f+Ze8ACn5s8Wy5mOw7FhHApLl9FCV3TieR57oMymFE= 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=JvJmmcop; arc=fail smtp.client-ip=40.107.96.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="JvJmmcop" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EftrP48gDV3Z6lmoIG4r2FfWXzoGWp3AoMdmiEMAsMiIbqRp8Vjdl0zk9aJ/D7odNUILyUrVCni3pcgkNvpQhjL+/LmSPP5HfDKwqU+Q7iOaV4a9BuTDysZiRokbVAl+DeUCnUPkJFgCbNZmR8DItu4BFxzDPO9Ys9WBmMv/2/jLGr1GWaWlRmd58ImuvHShAV09ccaIfKRQ6o5jgbFC5JHuKNstne7HJ3xvSAyp4zVzIy/jn/sbJdbQvrdkBNq6gGYRNWJcRuUsmwRLuAoYsyPrB60tuhvWwVREr9amxOiYVyajYm8bZLHLHKdhGoFVjQh959XGpiSNYMA8MGS4JQ== 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=e5utttJCw9otr4OYG/wtifAYsp6L77djCWab126RLfo=; b=KYistJbl98G1+VMGPj++jhg73I4vNcTQWpD2msP2NERi7eRzVhcw7CLJNUjjq8L0Op7coWOrdWyZDrVXoTJh0zHzFPTqyn8LfHU+kwzxk34Gj3qa5prSSG+DjEb+qzND2Cj371spxtIaf6lbntcFON/PnIzOnfJlWV2eDHTVsoUCD6jnmg5kuvWYrxGWqKilYSgin+Q7qDOAm8wbynhlEMXPPj2wVHNjg94VXgXmAuVU/Qbc5/arLK9uluRLQew8S5J16yt7laRb2fqyRSABwO2XaYej54PPi29RWf9C5NYrfxGeapV1cKgqUI9IdBwY0jKlEj3lKsGT7XO6Js8BrA== 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=e5utttJCw9otr4OYG/wtifAYsp6L77djCWab126RLfo=; b=JvJmmcopdkZxPs+64/5p45AJjIhXZKqs3FVtoGxyuRvUeBt/1fSMd4TkeWsEJBpPcTLBLbLa6pfampBvynjGzsAuaTHZ43g7F6m/VpfRBN+dViwoqS3mV4L56RNlHYeKKfAZe4UAWVPggx20ML34VJs5/o+q04x0TYPqaCONy4s= Received: from CH2PR18CA0029.namprd18.prod.outlook.com (2603:10b6:610:4f::39) by CY5PR12MB6346.namprd12.prod.outlook.com (2603:10b6:930:21::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.21; Wed, 31 Jul 2024 15:42:39 +0000 Received: from DS3PEPF000099DB.namprd04.prod.outlook.com (2603:10b6:610:4f:cafe::30) by CH2PR18CA0029.outlook.office365.com (2603:10b6:610:4f::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22 via Frontend Transport; Wed, 31 Jul 2024 15:42:39 +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 DS3PEPF000099DB.mail.protection.outlook.com (10.167.17.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Wed, 31 Jul 2024 15:42:39 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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; Wed, 31 Jul 2024 10:42:37 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 31 Jul 2024 10:42:37 -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; Wed, 31 Jul 2024 10:42:34 -0500 From: Radhey Shyam Pandey To: , , , , , CC: , , , Radhey Shyam Pandey Subject: [PATCH v3 1/2] usb: misc: onboard_dev: extend platform data to add power on delay field Date: Wed, 31 Jul 2024 21:12:27 +0530 Message-ID: <1722440548-107682-2-git-send-email-radhey.shyam.pandey@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1722440548-107682-1-git-send-email-radhey.shyam.pandey@amd.com> References: <1722440548-107682-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 (SATLEXMB05.amd.com: radhey.shyam.pandey@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DB:EE_|CY5PR12MB6346:EE_ X-MS-Office365-Filtering-Correlation-Id: b2a4e99e-8331-4808-c215-08dcb177688a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: R6umQHLRDZljcSF9McdJrin6oqpjrrgOKFRK5mIkv9zhzomFKLAiWcJqqRmutnVgoJxNQFslGZiBSo7eO+cVrcaf5IXcrJ49faXvXmVZ8DhZkT8PLo5fRFSq5nWuTNVHBb5Ev77by9ttQCZkkIFbyWRca42pRCrqK91hevHtoGIOtAjgy+Xl4H45x0Qadd7bgaL81xqtEBIfi8oQ3sLl+SgRzQi2CtlJn4PPZBNmQimxB8y+c6IlfkS1qVT6gHsEBi926MQtO6HPtayam49S8HAemwnHBXQU+pqhK5f9YGnjY5b+p/xPMNvhSHevsRNZ7DjgKXAoZaol56Ec0Tk1e5u8KA7NpmxWCSQhYKmWrL6TGoYvx8etRVuE/knbtTVKIgaLLbVVVZB8MbmTz2+oumirFBtXkNGnwbJWbt4KnBgimptolx07OleBgMRv4QhShBF5Oiyqj7SZlx/w5ZZ0h8czg9TgHRoFmkDtwvb0FS9nj0ylTkNP+wM4YMjXilFCnogJPbaj+L78ghQQWI1/h7wZgW1SG229dZ+Ke9teb7XCbQTT10aprffjzAWw+b6sZ7xZJ2a5lfqgKB+iXiDYQT8crnEBzzyLFjkd9JnEUm7Kjrg9DOS0x/yEpSDMNTw07g5svAXEomS11b7Jd8dx72dwp27xzCMKqwI1feRUQBrO3g4xxYb3GqY5Lepkfm46IIoT7FeI36WdJArrCkfYk8ozHtxOUX4//dAO6NZlm/CA4Q2DjY5X2It8obRRIkbqX0CIa3TsB5+3ZhfnK5joA7is2Smtlh22rpdemil/uXoQMCfdIcV+kLO4sv8VnBsW9s1VxYzPWezxCjlwp2euR2on94NeuEYyKs0ezvUiPY9LGVz8u0YoHSS9pOZZad1kErvZASneJzFxm+yYIbSKS51Ud05XrTN8vqwUAKxqr7kZnq8WeeuWe9vzdWtpWR8zCgwfVkrcQrzvFzGnpPbIuBC1NzO+ogWpsuDxALZ0/K8OTnuMHXRbz/jTnwELcvWWNp8jlQvgeAwhKWcEyM1yjhD3XK14SETI3DI1F6psg+I8ITyMeLI/p4HnckWFFMnqHBQ2WafS8CQgZA6NcHYjMhFV650Ybwae3jSjR0ozWA+ROWLeS/JCOJskYTaIAbisk5pMzu2ExvURDBk2qk2r+9luGhooT3LOCTyN9DnJ+5KKsEA6vV11A1qCJQ5Ns+GGh1IPfVwXLNnvKL16AI4t6ZH5jMNbh08LljFcnY/+F6pyOmQtqew013h5uv221KmT/nrEQUiQ5yLLZ7sf57Rfs2NE8aWxiXXxT5qeb9sMU5v43a2edDVJHJGL6903753dXb9BiII/sKZMjApSbQaxwFx9jKYvIsMCVFbXCSU8FYx9mtKfwgNT/ROUgo7wNAce4kVlVcDA+loLw34gj4KEGebwwCk1XE8NXxyppWBOgdWgweomYtDEWHYx36YVEG1u 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)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2024 15:42:39.1666 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2a4e99e-8331-4808-c215-08dcb177688a 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: DS3PEPF000099DB.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6346 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 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 Wed Jul 31 15:42:28 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: 13748941 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2056.outbound.protection.outlook.com [40.107.223.56]) (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 7EDB01BD002; Wed, 31 Jul 2024 15:42:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722440568; cv=fail; b=iUAykoAdqk5r5KlnSQsfh1Qjiv16/jShS0b/KgbXLzJsBZBuYfJtO4WpaQXxyoZ6Im/1eUhjkHXiXmj+hW6p0alOVoTIbd18tk6ZxdSg374HBm8j0i8KhHNDzAgu6r6q2dOCTYrhDbGow0RWYOVFiHyh3XEftexzVSC0+Wu9fKg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722440568; c=relaxed/simple; bh=5amGSm0P+IV+nCfKwiNwhDK8V6xhvw+nyeFHN2zH3sA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l/5ESEQhomsfo8X5DevLexJMHG62cErfG8X/7BPehmowxYmjBMvlNT19DurSeBT1cdN6lcuJIx6dhq22F9EvHxfMFqwWdajCAhKzrrPAIMFSF1k37e0ohmQ9zcazBCoTXLrerQQpvVroZfglK5N+R4n+y+7fgAlZfnBeSoRqwcU= 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=zAuT00pc; arc=fail smtp.client-ip=40.107.223.56 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="zAuT00pc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Rp2JVeZKsp1U/0Mpw7s15iv9eqzTKhNFKwHZgnGzUSZHUIkHdIdpwH2jSkJbz3o2zBTEUPrN3XHhGvv4mwiiw/qd64JGUpQoK3VTJnEkyhtYD5jlc5rY9lDwfRjCZ2S1CCnzuqzDidwB/yd4H3ePmLMlr8EMOzPVzBmhKwy4jngWdiKG2ggxwiKKTMcBlAuxrw1YyqUYYlqxkuQ0tNI18MColrnehtUAXpaCXQHnToa2ysDVBgVg5lZ7JIYULyX7hicJWQ94k4TaG+4i5WIdeAShlDNs2iEXBtl30BYVGnyzb+gRAIXkigjJrQDHtFLIqWD/AqMbZYaXGZeEBB3Uww== 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=gQA1ljYmHTKiXu0J18FhMdsiGiWgL829U2IHwXIHUy0=; b=PtbO8RJBOuVMpAGiuTcg+XVoUfm4Rfwuqsyx5KRnTn6JY9VOQAtraz8zf16Np5r5kD4quP1ml8HDQ5l7Qp61tOcZ/uBsqv5lXsZKxgPAdN9B7JReBDkHeCw1UzbGC3wfz1VO293wDV2hDyO3Wi93ky2t1T1bFo+kI/4kySIEYXYPC98suNtiMj/9Cu917tJU0iFd/fvMyl5ojeebhj3d5e2ygjrK4/fvCdU++iA7/mj1g2XMe7CZOSsRd9bmYz5LZgUgPtqmHKzy9m5S0zkMQbVTu0HMwSqxfNVU70H5QIPzvHrpT2CFbvI02Ue6n7onMbBCAcip6pWyleNYryNEaw== 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=gQA1ljYmHTKiXu0J18FhMdsiGiWgL829U2IHwXIHUy0=; b=zAuT00pcUnQNj9b50Mr+w9NZ+EczwJ7LDe6LnrhPbctfKRpbp/TWR3sssPxiqyNoS6TwCWEUzbyzbyCYmSjRQLScfpeLjUoFT77S9OCer3vzdPgLSxmSe1CcAs+K1mMuhan6T8CKQvEXqYc88FzTBcvTw1nDc0n0uJ8WbF0m5KM= Received: from PH0PR07CA0021.namprd07.prod.outlook.com (2603:10b6:510:5::26) by SN7PR12MB7155.namprd12.prod.outlook.com (2603:10b6:806:2a6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7807.27; Wed, 31 Jul 2024 15:42:41 +0000 Received: from SN1PEPF00036F41.namprd05.prod.outlook.com (2603:10b6:510:5:cafe::14) by PH0PR07CA0021.outlook.office365.com (2603:10b6:510:5::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.35 via Frontend Transport; Wed, 31 Jul 2024 15:42:41 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF00036F41.mail.protection.outlook.com (10.167.248.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Wed, 31 Jul 2024 15:42:41 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 31 Jul 2024 10:42:40 -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; Wed, 31 Jul 2024 10:42:37 -0500 From: Radhey Shyam Pandey To: , , , , , CC: , , , Radhey Shyam Pandey Subject: [PATCH v3 2/2] usb: misc: onboard_usb_dev: add Microchip usb5744 SMBus programming support Date: Wed, 31 Jul 2024 21:12:28 +0530 Message-ID: <1722440548-107682-3-git-send-email-radhey.shyam.pandey@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1722440548-107682-1-git-send-email-radhey.shyam.pandey@amd.com> References: <1722440548-107682-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 (SATLEXMB03.amd.com: radhey.shyam.pandey@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00036F41:EE_|SN7PR12MB7155:EE_ X-MS-Office365-Filtering-Correlation-Id: 71d10d39-dbdc-44ff-26c8-08dcb17769d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: jkvX/aLq+/+CC6LzFctSc4CSrAzuEXbdjKa3XU+ItG57uxXqYux9H7IofszEq0Y+RUTT1halxE62Y1G8ruuAHE+4gL0/GPjpKrOuadkBDjCZ+HVK8ouFG/bLjSIgHZaR57qM8eoyxMh6LIMChMLm2fTtWmRe+n4oJ8eg1gxZtF3pCTaJQM1y9W0n39FH17NkiE4EUkCgMsHNgXGIcUYy77XZB5L2DJAcm8BsMzrGUTUZX2MZ8111NNz35mI7sYKhRoc7kh6+y5LOtsEyQhtll0UCYW3OsqXDm9KVJXo3CArxSnsOveuB+SRUWN3sz8TZpHJpiy7LOmIlSBTb+H68lyxrCZ8PWPd26C4xRs1FNCHJHQmZH6sYU39mfbxNUTgFzSu0gP5F4bYyFBgsHwJBgrBeRhzdqxpvHfUpDTcQUzfGehepw5eN4LTdlxQjUvUlAgQ4DKHCk5mZWihav7nBtBQMHpa99iH+EDjRiVYTF3fv28yzC6R67WqpN/FL+LhK3dgolDHHm+57VbShlD4a3CLyUOY3pmKi+BpcH8xCQwmFMmPYKH8AW2KMfrg/EAonMLSjGGehJOa0xGPYJRDxKSNxNMXc4qZLMbXdDNeSJtBcnGfWMswE1NAHcL/LY8U2mzeZsjkdpXk0pkkNBki3mt4eDcXrziaSjqasR/6kjrt0RsWI6e3Lbf1aXms0iro6vRXaug3iojcoOFvHH+tidLUX1vhikEFv6vCPIDA2Y6fWRyun/1KHIeB3vHBM4hTjIdrk1oDmrGt5yYtrBZRo/mvdyHTGpq8c7Yi+X/Q3xRWfqe4a85ev62rHLPnCaOwRQAMBE+7wckVoiNDhxUZrBUQ7q7J0FT1+UpNdq4D/VqqzMGM+ubgp7QbewL1oCoYYj2eywEi3QU4nOkHo6e/3G4tzNLmn7W5S3pfoHMy2mFHTunxu2+qO+2MGBpaFyh0drjYeBOk+DniQ6i05pVKIR3A4T5AEvZDfX/uTfArk+PGibgo7S8YnYMZfLw9XOWml5ffqnYsLYnyLeUlBwtWGp9CNlrLo8xINraQTBpC+CZGVsikPcijjEwW6NGERO80fWAY1Wz9aVKOIRCqk4IXLpg9IGO3C6xpdh5hHVB6/881AYDyLKVh9Km5CLSbDqxAhxuMLEe0I5E9J5dQYtLE6TfS52cXDAXDKTGke8LkosZMj9dxKHZSYJd3XYHt/mol28UAZ0P+ny1mj2PJIs95EiPF6o68moKw1ZoxRAmOsQp7heR/x1/sELr0Y9b4Ht6gNPXDArpjM1JZqsqX/ZfEdKYQn5Nehbd8IoYN7mfsBY6Rn9pNdbhM/6NM6Va0mD9D7m7GZIduPyXGgB4J+/XN9Gx+HhWNSW+LlauEe2S2EqushQ539d5AW+HwLeTPlns+RXRNjPfLhqChfKy2912kQSYoWEwVaVBsJLHtXUghS9xR6UHOpmbearP5tIL8MmRNN X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2024 15:42:41.3787 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 71d10d39-dbdc-44ff-26c8-08dcb17769d5 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00036F41.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7155 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 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 | 73 ++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) 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)