From patchwork Wed Jul 3 23:06:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13723053 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2085.outbound.protection.outlook.com [40.107.20.85]) (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 A4726194C8C for ; Wed, 3 Jul 2024 23:07:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720048041; cv=fail; b=PLCBs49RROjUqDF10PfokfcafEPy0xrgDhyuU+DXnMHCxas7RiAOnJco7SI8vbJOMjI28qwp7s9eAOkUNx1B6zBLA+b4cLZXgTlB33LZBMI+vfjnrdhTYf8tJGTmIJtniYCwogMRuq9f14PSeDitO8idA+2oTnrzakq+pghAbQI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720048041; c=relaxed/simple; bh=OZhH5vHJIz49Z5w7shnQv9wME/LUgQEwzh9BwGAMQns=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=L33ZWM2sohu8/yY1iWq4AhOVRocO/NXpEn0hgId1LaZjN6mXr0Ey+QKHAkJbMAbs6n9o3fowd605mtvUZMnJOkPbaMYLxy+M1PznbE1+qYXMzBIfq6+wJJLgciyaGEhqK4SNGZNY+k8t12RFbu5jmFq2w/BzIzoI6vzZkMkkZX4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=cij+S9sq; arc=fail smtp.client-ip=40.107.20.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="cij+S9sq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TbjO2Fv+cyoYnvGfFmKSrz5l/cwQhDOroqBhRAkKY909EL8QAieIiEUtrtJ8X01bpeaQ0lskx+WBUsKdNO5yG+ThanM93rKoszoj6r9W759ZktdbLe2Ms278D2e3uMpOIlzE+V/GR7nbHWfltB3kNIzWSZBI04dFh+BL+ZNsyesSWXNwMTP9+9d//ayN9Il4rRTI+cf8ak2vtD/iytaRkOCSNNEDaeg+3DXO+/uP3C5cDnhWecJ7Cx1qYN+bH2qP6AMXaVb8hpJqDAqRuVlnMC1FAaC7v68GeWi5aWzIccytdMlJQvT20yYAGxUfE4ISrpATduuGVvZj80WsiRIZ/Q== 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=J/VekO1EEL3W9tfsm6MZEvDygKk+VT7CpmUCoBkZ1fI=; b=J3Xq8Ryq74Rl6Jl309LtbtqQbOsrisuVzUseVqCh8+5cgbcCvGfKV9V1RK0k7VA4tI7c/DRrpZYVcFrsKqbNzn5u5pqEOgwM9NH0R0svsVGcE8kxP1DPYaeuh4JjzQe2EFK4lAK7ohmuYAuB7XziOefB0/SBCgLyLwNAbuTOgQDwfn8QeMum1jAbUQ0g0iJhGypN/ayRLyoyWZQ0bYc0Br5/DtfCt3xiKQHflaWDTMNMDRS3S5NQtCBWqUSLSeC/7w8CXzx4sN5Q7BC5jjj0sdRAWF1gMObgoevnId6wJq2oz+55XA/xTF9k2yrUDnt9D1sA5TdG/Hr8m73Z4aRfuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J/VekO1EEL3W9tfsm6MZEvDygKk+VT7CpmUCoBkZ1fI=; b=cij+S9sqI8yaHUiXEgHNn45TmqTFngjhLiWl4UyxR0ox+cAWdIOCWsf4R+dkr3sjyQ8tSWpd5KbRpiaYSGbNPApLVWD8t4xarXXVrG+Z2LT/iY8+4iWjttARh6QF5hnXSah5m61dgjE5KGCAZFS9kIAQFlXHXMysYedZ65nSbU0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by PR3PR04MB7242.eurprd04.prod.outlook.com (2603:10a6:102:91::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.29; Wed, 3 Jul 2024 23:07:17 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%2]) with mapi id 15.20.7719.029; Wed, 3 Jul 2024 23:07:16 +0000 From: Frank Li Date: Wed, 03 Jul 2024 19:06:55 -0400 Subject: [PATCH 2/2] usb: dwc3: Set cache type to 'snoop' for freescale layerscape chip Message-Id: <20240703-dwc-v1-2-9cbc93d49180@nxp.com> References: <20240703-dwc-v1-0-9cbc93d49180@nxp.com> In-Reply-To: <20240703-dwc-v1-0-9cbc93d49180@nxp.com> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Felipe Balbi , Thinh Nguyen Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li , Ran Wang , Jun Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1720048027; l=3085; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Gipda9mkYcJ/iFuJC+SVswlU2hwFtDUoHjvW/BiuvmM=; b=JNo0CAT5OZoPJ9r9Da6LTltChMsb+W7nbiHC8HjxAejl2Qiqf89VAZ5cEC4QMdx8RIopRMFUh djpfzkxgtpLDC0d/UVkhDIJEqgpRu5GAtgPNqIJmT66VSwfdwpDxBrm X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR03CA0063.namprd03.prod.outlook.com (2603:10b6:a03:331::8) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|PR3PR04MB7242:EE_ X-MS-Office365-Filtering-Correlation-Id: 24a18687-3887-42e8-f2f1-08dc9bb4e20e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?2jKiXv85lj0NVEiWDsFDz8DdKIIRK64?= =?utf-8?q?e4ce4kJ41lG2y+xXA1XU7s/4o/giHhRd9LAbGrCbYLre4queFUxjRhbk5YSYaaSG0?= =?utf-8?q?a6SzbDljbsj0283gcHuwbBMOQCdMHOr8mypJffjWpofxNapsVx/TdN1BMjMsug9eb?= =?utf-8?q?OqHp1h5yKYNzwZdss/W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uDqJ63Tz85J01CY7K2wLHPn8aNlJ5HqaCQMarnL+thJL?= =?utf-8?q?S1Jphw/DSCrcqJc7lckPiFu78pUU4JzHvCKzoT8Tv0gMnS/gEB+OlDmE1a2jvhUoG?= =?utf-8?q?6n9rJoYEthaxE1AcGLH+cOFFUo3CtQj2zTniajPoBtl40HKzHkJixC9yRookly8Ot?= =?utf-8?q?h6ejSnWEi2ARGplycJJxGW2m4mOD6UZeA8MFGRMzqa1uJ4hVz6RCQfAGa5DPpMtsI?= =?utf-8?q?7P+YL6F0lpA7aZ9k7NtSzYom4fyfpCn8mqBG4e2S3EHVPXBXTMLP535vhs/RYkGsZ?= =?utf-8?q?jdBquQU6KG4btEG4oWcTqlx1VtSUa/k6Dw=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?gdtEOKsRnY/rmzCIayOAr5tNmQnO?= =?utf-8?q?VhSOG+Pt+CLNj+rcBwGZFzNTdv59xQcMfKHdHtxfPWAu09cguq2S5OEyf88Xipx6w?= =?utf-8?q?2NeDeuwjrZs3JoG+oY0ORM0l5BjZrBU/Esm7G+UxPSxb+XFXDAdhdgLEKimCtyEN8?= =?utf-8?q?w0QVLejMmoAr8Srbgz1Ux3A7pP+9WmkD9b080C7kIFjUKxGy2KdupZOLzfAUdHxVk?= =?utf-8?q?xFf1SoFvutkbOj/3sxXai+SoPXFXnep3bMLY1GIOAl+Ac02P93u81YATMZRnDHYsf?= =?utf-8?q?agcWwFH0cpb25EpjAddNZ5TP/krN269mb+mF/U3wi30+y0oVGA/Hu3ucyi8mAOj1X?= =?utf-8?q?c5KYR4k9s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OF7I5Is5Rmp3zrzvbAYeOaZ+VuhjjyQ4ZRsJdJRW?= =?utf-8?q?Mvh0SLCfJQpiw0pvXcrcvvieWcFfLGhvEUvFpJxmQsHfTMOZNlemUU1ZS8pbiC0ft?= =?utf-8?q?x7eryc0oeStY2CjI9Op41lg7N/SprJsYQfBA27GztB5g/BixqaX2IY7GSdybirjJc?= =?utf-8?q?FDFtQcLHOsykicHIOPiQA+kQNPkeU5DsS9URxFS5uNc9meUTGFb3mdOoV2ZqsmiBt?= =?utf-8?q?V8ZXoyhqdj0E1+O/W6Ry+RijhNPrNrcFIQV+0VIwsxLiMEmwgsUcW+ISenVPtGlID?= =?utf-8?q?3d0dtPpyPIFm?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24a18687-3887-42e8-f2f1-08dc9bb4e20e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 23:07:16.9628 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: q1+P/XKlmcG+89s0sOwEAFhiK+FXKu7McHzwb7X95qbAsTh/4yBmKybm9ogzm2fZFYB4UUtM48oQXFP8qXA+nA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR04MB7242 From: Ran Wang dwc3 have 4 different transfer types: Data Read, Desc Read, Data Write and Desc write. For each transfer type, controller has a 4-bit register field to enable different cache type. Quoted from DWC3 data book Table 6-5 Cache Type Bit Assignments: ---------------------------------------------------------------- MBUS_TYPE| bit[3] |bit[2] |bit[1] |bit[0] ---------------------------------------------------------------- AHB |Cacheable |Bufferable |Privilegge |Data AXI3 |Write Allocate|Read Allocate|Cacheable |Bufferable AXI4 |Allocate Other|Allocate |Modifiable |Bufferable AXI4 |Other Allocate|Allocate |Modifiable |Bufferable Native |Same as AXI |Same as AXI |Same as AXI|Same as AXI ---------------------------------------------------------------- Note: The AHB, AXI3, AXI4, and PCIe busses use different names for certain signals, which have the same meaning: Bufferable = Posted Cacheable = Modifiable = Snoop (negation of No Snoop) In most cases, driver work well with default value. But USB device detect failure sometime on Layerscape platforms if bit[1] not set and enable dma-coherent. Set bit[1] "Snoop" for Data Read, Desc Read, Data Write and Desc write if compatible string contain fsl,ls-dwc3. Signed-off-by: Ran Wang Reviewed-by: Jun Li Signed-off-by: Frank Li --- drivers/usb/dwc3/core.c | 12 ++++++++++++ drivers/usb/dwc3/core.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index cb82557678ddd..2b474de83b783 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1061,6 +1061,18 @@ static void dwc3_set_incr_burst_type(struct dwc3 *dwc) cfg = dwc3_readl(dwc->regs, DWC3_GSBUSCFG0); + if (of_device_is_compatible(dev->of_node, "fsl,ls-dwc3")) { + + cfg &= ~(DWC3_GSBUSCFG0_DATARD | DWC3_GSBUSCFG0_DESCRD | + DWC3_GSBUSCFG0_DATAWR | DWC3_GSBUSCFG0_DESCWR); + cfg |= FIELD_PREP(DWC3_GSBUSCFG0_DATARD, 2) | + FIELD_PREP(DWC3_GSBUSCFG0_DESCRD, 2) | + FIELD_PREP(DWC3_GSBUSCFG0_DATAWR, 2) | + FIELD_PREP(DWC3_GSBUSCFG0_DESCWR, 2); + + dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, cfg); + } + /* * Handle property "snps,incr-burst-type-adjustment". * Get the number of value from this property: diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 3781c736c1a17..99edfabd89673 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -184,6 +184,10 @@ /* Bit fields */ /* Global SoC Bus Configuration INCRx Register 0 */ +#define DWC3_GSBUSCFG0_DATARD GENMASK(31, 28) +#define DWC3_GSBUSCFG0_DESCRD GENMASK(27, 24) +#define DWC3_GSBUSCFG0_DATAWR GENMASK(23, 20) +#define DWC3_GSBUSCFG0_DESCWR GENMASK(19, 16) #define DWC3_GSBUSCFG0_INCR256BRSTENA (1 << 7) /* INCR256 burst */ #define DWC3_GSBUSCFG0_INCR128BRSTENA (1 << 6) /* INCR128 burst */ #define DWC3_GSBUSCFG0_INCR64BRSTENA (1 << 5) /* INCR64 burst */