From patchwork Thu Oct 24 06:41:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Schumacher X-Patchwork-Id: 13848376 Received: from FR6P281CU001.outbound.protection.outlook.com (mail-germanywestcentralazon11020134.outbound.protection.outlook.com [52.101.171.134]) (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 C09D3189BA8 for ; Thu, 24 Oct 2024 06:41:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.171.134 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729752074; cv=fail; b=uDeAIwmDvNQgX7CK7wvi53lnOrQowVkJAIiaYEVLJkZ+0AK8JJalM8Mye7akYHu3ralMq5Stolry/qrBjUt3STQ63wlDkbSuFo5Ogb3mUBB7R74eHlTkHWfFO+LHeAa25dvCdsNJ7LZ1lrkykM2T+hiJB3+jnSKisgn1MVKqec8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729752074; c=relaxed/simple; bh=hRNOL5XpGlVSzOq3QI/vy8MF5IWP9GTtd1XVNTAOl1w=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=pC5twX4F/ZCQlP1M1YQqQkF1ULTyeWQ+EsmQD8VPNVWReNANl/IlLEzRpSD0uhm9tUe75bAlTfwv4hN4y/7QpGt6Fb23xhfp0VnjwFmEebO9GHBS5XorJMD0KJ2T/t4bpDC52zI307Ooinuna3FG3JV6UauSVFPYvDNH/lT5VWY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=iris-sensing.com; spf=pass smtp.mailfrom=iris-sensing.com; dkim=pass (2048-bit key) header.d=iris-sensing.com header.i=@iris-sensing.com header.b=XpOnYsYS; arc=fail smtp.client-ip=52.101.171.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=iris-sensing.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iris-sensing.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=iris-sensing.com header.i=@iris-sensing.com header.b="XpOnYsYS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FHkFj/kc2U91aJZXN+K6cS8cucX2qQm1v9TvU9EgH77IUjk6oeR+SQdXTaLKenzvPzM+nzT2VEkfxvujVInP7CF5wqGBhfkiPok27w/k7fJ2ku1+MK9v98wMSFCZfK/DkfLnuAEBydE5OCckij9Dqvtl03Ao4NBr5SMcMXnG5DX5a7HdgGcQS6rEAfOJjFSa4fgWVDfMB19U/HM9ts6BY9icpDSc95kKARgrxmLh+yatyl2j+M9xSt7rAA+eYwd6P7mVRTtgBjec7YvnqJgX24iHuC30Orc5Hy0eZbbBeyYP6IMx99HWfjF0g6FNAxx+D0c40KGyokdSNRq0+3Peuw== 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=hRNOL5XpGlVSzOq3QI/vy8MF5IWP9GTtd1XVNTAOl1w=; b=iSdUt6ZjMlTKfuhPEYX6Zsxd0ULjScFGSSN2ZlNb4Dp8I5iCWh6ifRYruTz17QeZ5JmqxObl/ygxWQTGS1Wr1HK8M1eRMRAWc/nNYmjMkk4Q6mK+TME6XFSDUdPrOHLee9VsrCp5eKONx2L3lnrzULM1p2IWfJwQKJzETsj8ztHbekC6HqzoMCjl2QZ2cHRJbp1ZXu2o76xclG2O8+Dx/BaK4bR1+45DSgxt5gRRUhgKH6MgRVPjPuuy3xx55jkcdEaDY7EgP23dB5pyEMA92m6J5G7L2JEfSoFdfKvWyp3EGH7zZC3zjPP7s+GCy+OHDvJICSkFXaBr2ol6sioWqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=iris-sensing.com; dmarc=pass action=none header.from=iris-sensing.com; dkim=pass header.d=iris-sensing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iris-sensing.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hRNOL5XpGlVSzOq3QI/vy8MF5IWP9GTtd1XVNTAOl1w=; b=XpOnYsYSAzzgfn+tNLGAMTWyLIRcjrBAGCaIiKA3FAM0RMa7n1psUOeAiMUPyXlBY7JW3qM41C4xv0V3sLcyQahsE/FbU46/1WfuO84xgdyj3+q6pkWMsU8PdlJt8uFaKrZ6oQanrsTaPbcttEafrPHmahYrUAlTjGPw3ud4Rvd3/rIUR3+rMWNBRmjM0oKx/L4BEEoXoyhQD5wX4Z7ZXciBI17FQCJTuT5K3EUbY3unm6om26OAaOr45uUt+fmekWsiEJpvx8WTTvFVqfhf+5jZGpEP0Sx1vndRuKle5amsAOMbFyVfHbJFp9Av5dPLZ/aS2IXL9wZVg6dERPWsFA== Received: from FR0P281MB2809.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:23::8) by BE1PPFAE0A1427F.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b18::68d) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.19; Thu, 24 Oct 2024 06:41:09 +0000 Received: from FR0P281MB2809.DEUP281.PROD.OUTLOOK.COM ([fe80::d685:f312:e114:519e]) by FR0P281MB2809.DEUP281.PROD.OUTLOOK.COM ([fe80::d685:f312:e114:519e%4]) with mapi id 15.20.8093.018; Thu, 24 Oct 2024 06:41:09 +0000 From: Erik Schumacher To: "ukleinek@kernel.org" CC: "anson.huang@nxp.com" , "kernel@pengutronix.de" , "thierry.reding@gmail.com" , "s.hauer@pengutronix.de" , "festevam@gmail.com" , "shawnguo@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "imx@lists.linux.dev" , "linux-pwm@vger.kernel.org" Subject: [PATCH v2] pwm: imx-tpm: Use correct MODULO value for EPWM mode Thread-Topic: [PATCH v2] pwm: imx-tpm: Use correct MODULO value for EPWM mode Thread-Index: AQHbJd+0DCsBjEpWYE6MZa3vNXpdIQ== Date: Thu, 24 Oct 2024 06:41:07 +0000 Message-ID: <91bfd0c1726d2e6d10c96a3f2e141a7315b08467.camel@iris-sensing.com> Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=iris-sensing.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: FR0P281MB2809:EE_|BE1PPFAE0A1427F:EE_ x-ms-office365-filtering-correlation-id: 76c87cdb-900f-4eab-b3b5-08dcf3f6d80e x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|10070799003|366016|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?zul54UNahoaYhNvrO/i/ue2qz/j9XmY?= =?utf-8?q?xMnGXmUiEyNEelHIhSjzTAA5FSnoXZpaInhEsmq/FbArupxaTZWHyqqV6hci1tOHg?= =?utf-8?q?hEKH5bPsvy87FwxyINRwMcuM6Xv1HATVQiSx6LBqr1qDONWYOESYU7Hk86SYoLQ8x?= =?utf-8?q?VLlI16iuxgRV5pIekiZVlKSIFBxf2JlfCQny2WIM61/xou+WMhOSUpPjPngWZdCWQ?= =?utf-8?q?Zj3OD/NmBhVB0O8UOnkkfrHc2ThwOSZ7RyguGVU5OUpoJt0YVOGIIUR9Oj/NbXeDv?= =?utf-8?q?EMIGcs27e9Atn8DmM2Ypr2iQmOUaSpEFXEWGB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JSL7RU3b7yrG5mtJ2Y?= =?utf-8?q?cAmV7wTeXdCCR+XhOqPyprYjt6SSIkbT51TuIYDkVOFoEXFmpLQk7pZXACzBr87MA?= =?utf-8?q?8B6sWxeDFl4NyEoRHousOhHP3OVgcWXlD/+yrniy9sc0BQxt2r//boBg=3D?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:FR0P281MB2809.DEUP281.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(10070799003)(366016)(38070700018);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?VYLbExdAC4tFIZPEXPyVgrrHyFk2?= =?utf-8?q?T2HSCYbMRQRJ5p/VdJFeDXwW63Iqx8tfmK8YXL8sugecKIcVauthsfsMew6vN2BYC?= =?utf-8?q?t+iMZrYvNeW+23qMfD84Hj29mQmdcsVNow5o0IT4zYCAPIuT/vGEzM4BbESvR3uOi?= =?utf-8?q?G8of/SxNyzjYWC0tv6N3dwT9ej8iCwiiAU4TRbIC2OxMNCvnOnJ2EoCHSaW8sDlP4?= =?utf-8?q?zm1d+8D2o32ZpglhOkwAdglH6inY48AsnD6LJoR8iokbAhT7l3FYq/qgB1587Ev/5?= =?utf-8?q?HDxbFNy/Q8QbsIWOWWZelDTT7zrK1ZunSE+9O2I4maRnEsFAQDXGpUk9aJd8u41t9?= =?utf-8?q?z4WZ9VctmcJkacTKQ7atxCG3x0VSLxrzH1IDrYnIvJlmWEERHnbIKrTJPjBQRjfrI?= =?utf-8?q?EdAkzeR6QxYyB7D/nNNXBYBjFmHOeW42Q24rve+F+goRlr4tDtCG6zBQ7WfTAZlCP?= =?utf-8?q?bG3JL0CSdbzEgKZsjeBFQ6jxzyxpQ5tryouxlE8EoTEELFuGzeEYW/XfF7Wz/5JLe?= =?utf-8?q?sVjOijQASuD7Pp/He/VB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zRiqaY9VjKdFJeZbANu3/SsRnMKodkHP6VB3GiK6+H?= =?utf-8?q?iXymbgZ2aXvaIqRPQ9+aCWoVomjwLiXpmUE/jMAc6XAQVyu50Sa+ZryiJb9/YR0Jv?= =?utf-8?q?8RO4moFVB11whVyIxkGtnSwKNeO3J31qfIqpNiSSpfjOlUacSpYZDRx9M74Wk8wNF?= =?utf-8?q?gLvaTYpFO5ElrGbMUzippEtUnzmqkR9qF4rBDqG7hoFisIwmJVE9hM=3D?= Content-ID: <823BAD78B6D4ED45AA53C8796679AC56@DEUP281.PROD.OUTLOOK.COM> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: iris-sensing.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: FR0P281MB2809.DEUP281.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 76c87cdb-900f-4eab-b3b5-08dcf3f6d80e X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Oct 2024 06:41:09.1616 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 963f3913-ffae-43fd-856b-2dfd3f6604e3 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: eUOJBSIrCYGvkB4sCYB5I9j2j72ABeVaQOwEEs8fe88dW3SDrH6arXlb2dNerCsdFlcFqs2HvY/xcK87huBkTLHhkzTdSKUvZGhRcUd5JBXQ0xGbRssKfZsn7GM7ol0L X-MS-Exchange-Transport-CrossTenantHeadersStamped: BE1PPFAE0A1427F The modulo register defines the period of the edge-aligned PWM mode (which is the only mode implemented). The reference manual states: "The EPWM period is determined by (MOD + 0001h) ..." So the value that is written to the MOD register must therefore be one less than the calculated period length. A correct MODULO value is particularly relevant if the PWM has to output a high frequency due to a low period value. Fixes: 738a1cfec2ed ("pwm: Add i.MX TPM PWM driver support") Cc: stable@vger.kernel.org Signed-off-by: Erik Schumacher --- v2: - Add Fixes: and Cc: tags drivers/pwm/pwm-imx-tpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c index 96ea343856f0..a05b66ffe208 100644 --- a/drivers/pwm/pwm-imx-tpm.c +++ b/drivers/pwm/pwm-imx-tpm.c @@ -106,7 +106,7 @@ static int pwm_imx_tpm_round_state(struct pwm_chip *chip, p->prescale = prescale; period_count = (clock_unit + ((1 << prescale) >> 1)) >> prescale; - p->mod = period_count; + p->mod = period_count - 1; /* calculate real period HW can support */ tmp = (u64)period_count << prescale;