From patchwork Wed Oct 23 12:33:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Schumacher X-Patchwork-Id: 13847027 Received: from BEUP281CU002.outbound.protection.outlook.com (mail-germanynorthazon11020083.outbound.protection.outlook.com [52.101.169.83]) (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 93F25153BED for ; Wed, 23 Oct 2024 12:33:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.169.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729686838; cv=fail; b=IVJFl1WGeEg+gAmQsXi+zSDt8dRaWe3aBW81HLVqlGKCWsqW7MJcawvIsNhvey8+t195MEgARNnvdN2VT+GapRPd3257PaKicPOzGOXN8oRZ1v730+ci8x+nJsOnYs9fvEarTXIPDKZPpwjUGwHLQ369/pONAKkE8QbiPMrxcsg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729686838; c=relaxed/simple; bh=nRfuZNlLhk+ejQWglmt4jBd6KMoGgizwF8AwN9bp6h8=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=K/TX304FUGEobTeB/YIpwH4/EZ9s/+uoPtQPiyDEFne02PS9ggRacrddNOgbB2c1KTGu2dK+6dAHG0QevDzRBKu7YzaJdzAKS5frM2t+r4iAU3Vb5I7KNKMKnjhhYKFley08XDpODj5uFRJQaJ7Ih1ORt/2VWytJ8vIMZnWKQjg= 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=gCmNGBTd; arc=fail smtp.client-ip=52.101.169.83 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="gCmNGBTd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BxQ5AWMc6DB/xSRugdepYrcARAsQMtFe+iM0zrtKKshZA7kcSqn4CDCyejh1rk8OCOJfq+PZNw5mv6ojSxFF379930Q40im0zGO6y34mtj/7OKTGi7q3C5JvVhBoFBsTnpu8r0oVtCJeGv6RlYqkDx3uo4VybPVyQRlpWLZnfRPHt8D+41dAacYUAHrjllFgsabrifDD7RYslwikqw05cxEkPcce3tEjtLZXOu4Pw2yWtTU54ht4gtojBIvjzhSc8+fIBIGWN4pT/pW142NOZ6UoFZjFUom6hjbVSZdhUtOMC7+HU6gfdXnXRTAIe3SfPF7arGyrYyBDc4CD/hD/ig== 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=nRfuZNlLhk+ejQWglmt4jBd6KMoGgizwF8AwN9bp6h8=; b=EP4WdMJrGYDcarMSintiT/OwT59YOBHToMrxjswqrbmnipHeajOY4R9VxPdM7W1hQ3+GS+/Q5YF1lVqlxNv2aCN+1JlQRfcBQthWOfT441dXLxFPB3nwelnin/srbyFSkiJy+2qfQFkAYuBHPWNIZXmQoI/TFiVPcxgiNa4nFODYNx25kEFlVNOj//mp+yaoiS2HSAAU14FvL6TDcbNOZ9zOy815IvF2Wo48NnV2YO74xi//nX9n3X2EgisUIafA6tQYjDQm6EKX267lT8e8yYTwhc2ApA/LdVyBWVPehmkoVOiszz37rOLrB4V65mgGoc9kjMSSwqinI18IEJs2CA== 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=nRfuZNlLhk+ejQWglmt4jBd6KMoGgizwF8AwN9bp6h8=; b=gCmNGBTdwfkArIunyhgN6rHX4AQ/u8dHK8LZVEfxV8a7gODIfc3SWdyaZWugjC86iNrBSTYPdc2HQVdUL6+aPO/+q5aPVHwziU/CZ+Ue/rWos6q/IB+U+5DGNUnnfaWhMSXXVVsq1c8I00lOBN9Ap7G1RrKQQ6cDULDmPCiCYDRg9QmW5ULdB5h8qGz17QJwRmNF7x5+K6CQTd346OgODpNJD++yoWyyyX7dqS2BgVzntns/usSbSxTjXihz8zb4GLDVTePhhoEQQnLcL3A40ra5FVP0fT4UoBhEOVI//D1M4d6eqasksEkY3NonFIB40juhslrplm4MPXw9IRpC2Q== Received: from FR0P281MB2809.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:23::8) by FRYP281MB3257.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:72::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Wed, 23 Oct 2024 12:33:53 +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; Wed, 23 Oct 2024 12:33:53 +0000 From: Erik Schumacher To: "ukleinek@kernel.org" CC: "kernel@pengutronix.de" , "s.hauer@pengutronix.de" , "festevam@gmail.com" , "linux-kernel@vger.kernel.org" , "shawnguo@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-pwm@vger.kernel.org" , "imx@lists.linux.dev" Subject: [PATCH] pwm: imx-tpm: Use correct MODULO value for EPWM mode Thread-Topic: [PATCH] pwm: imx-tpm: Use correct MODULO value for EPWM mode Thread-Index: AQHbJUfRxNwwaOjAIEiewaTXGCuTjQ== Date: Wed, 23 Oct 2024 12:33:53 +0000 Message-ID: <349a25ddce02d55cf5a321f27133cae1f34f1962.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_|FRYP281MB3257:EE_ x-ms-office365-filtering-correlation-id: 2871d0c9-6c76-489a-3679-08dcf35ef46b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|10070799003|1800799024|7416014|376014|366016|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?ElsLPCSeyPOFuVPjBQ5zxlI86WxJuGP?= =?utf-8?q?6rt07Kd8azpr4mhtHZylge9aO3yIbXwtkvTDTpjGf3BBLYZ35brUwt9/7IV5Piqua?= =?utf-8?q?GyJ0K19c2ViTU3qAC7o0xAGGG8U2YlCDH3SMfpylV1Z9O0oAE30ADf6FVwj6YLvqT?= =?utf-8?q?W0V3HdcdNL/K3vnQGk1b/DyiZNCF+VFeZspZx4kvDnFS7erHO/ypXr9DZ5kPjMuu3?= =?utf-8?q?2vy4n49lwbB6PuKorJwrBLUekLKsHZJ1c1PDf6dio70FA9PQno22DMtD4mS0XPwlL?= =?utf-8?q?giNXcdVKbmYb+/9mVThtJ3mhgEH4QQXzhCdS/+be0hxhHYER4kBMp5NCvgV3Ip8fW?= =?utf-8?q?rVbcGrOOQ21bjPjvEfF4Ndkv1LyFUHo3GlMOZBX1jmbkMecmQKegRgKVMBiY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kHwTyD8Ve?= =?utf-8?q?XlNbjOfPBwQAUJ/lwxTogytNZUoPuLAj7pU6yThJwxc/yh6KRFCZ3pLs=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)(10070799003)(1800799024)(7416014)(376014)(366016)(38070700018);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?QekaZrzpynP5VdCqS0h9GL6o9DF0?= =?utf-8?q?Qapezz2UyO8PqruWsHuSMgk1Qajpy/LW0a4JUsIF7/L5YfncNO0p2SKe+hhvBpr1n?= =?utf-8?q?K5CEfc+FtYM2T1BK6ZB4uXVXP9VjGxP4o5lz/fp0ngTxmqs0bs2jAtOSodRGPPKbU?= =?utf-8?q?jtZb7Mi/3YpQfQxmD1dNwf11mNs4vu2U99LfcMjgYYFdbDzgKknOO1KX7YVA8j/vr?= =?utf-8?q?kP4euiYG+++75ZSoaIJJ1la8Wkv18HFPVHO7L2T4Or1JW8tisC1fivOs4x6XiniQp?= =?utf-8?q?OTFT0eKqGKc7gPUbPwG0m6TSZ3vBDvalr0eTw5rvaz8iqVx5JpQN2xfS6yMVsLx7D?= =?utf-8?q?krXmFwt1GAUGP0d9TAzwEyvVVnIcZ+oi0VNX/r3kMHpGABFwvsgOZRq3O1zfn4PSt?= =?utf-8?q?/prIAhvxfATjXQPQtwHAgktvpKianBMgeIOFjxQ4cvx9L373t398U+8EX/tDWAnlu?= =?utf-8?q?/fMbdd6fP3vVYlnMHk301xxJl7FrHthVUwCR/uthJV+uFUNUAVfCQ8MAMJFTBA6/Y?= =?utf-8?q?6CwqBKt+ALnuQZYla/pPfvoFoYO8EyXdJr06g/zs2DAN28UBO8EHUb7iRzltraks6?= =?utf-8?q?hfnRAw1i/nGv3AtjolEUCXMQVjo4r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9trsdJPSNpCEwSORLcYxqs7NLHFrY?= =?utf-8?q?i9ia8SU208/+pdqvwtzAYB2xnWYg4tGliiZIIVIkaj0dgnAbApvu+FXn6jlkNuO5W?= =?utf-8?q?3jtX4l2qKWc+6m4/Ye3mpRaCX0boh5ru5s8LVzC8afRrIuH7K/yk40=3D?= Content-ID: <35EA6B3C9D7AAC40AA6DFAD3C6221786@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: 2871d0c9-6c76-489a-3679-08dcf35ef46b X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Oct 2024 12:33:53.2403 (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: luvfW7zyX6HuaBwZ6gacuKy4ExZ1WaGHzWthueouq2DeU1+dZeGxcA5RHs24sVyG7ZBUlVFFzu2pKiQpRI4FQV3hy/JcowUYxchD9cc9Sk7SL0FTY8F9NlVbjsIvd5Eh X-MS-Exchange-Transport-CrossTenantHeadersStamped: FRYP281MB3257 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. Signed-off-by: Erik Schumacher --- 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;