From patchwork Mon Sep 9 19:38:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13797500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2051.outbound.protection.outlook.com [40.107.22.51]) (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 7D49F166F07 for ; Mon, 9 Sep 2024 19:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725910760; cv=fail; b=YbYSm+IVd2wpar4/V7XVhJ42cXh+u7ZfKInM039K93Dfu7Hb662r2SPrdzDpKPmbwyD1luiw958YmBQmC4Am9aL9jBbsv68olnyoLO9A3BMbgPtoF0RjZzsZrSJn2aU232TFigZe35zg7kXQYh8sWd/NMFXa99WBf2NKnoNz5oM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725910760; c=relaxed/simple; bh=T7KhXOnsnIIPa+2JhFaYwg9cTmeugUkC5FVAAlQ8UBw=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=oYLESeXm8HRTwd4eXuFL2IhjA2Ah37OeiFiM700kxoKbTlfICuMBo9fryOoCpbuK3kjRd16WfZ2qzXnoxIYIgw/Qn5hWEJsDM/9Aqlbjm7vyjsAomRq3q+JFZePamHgKvscCb6oiemZwdWvH62ASzfk2COcprSBzmxfu2f6aTCY= 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=IODStxZe; arc=fail smtp.client-ip=40.107.22.51 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="IODStxZe" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Zx7WihHtITJKF+ZFUxLwDXZRdFh+H9DJuAnUQ5VlxgpgIDRuWrXh3BKepxZd2cRbVFxWFYy0bClDFdX+nLiuyGQS4nlYgdM1En01Z9SR3rHoCeKG6dnVw/szaXI1ZfQzX6S9jS+XiVw8lfRqyj1iXtZ/chrg85nCB+m/K33KGzilhmOFtNkfprNgh+ITmMmfasjhx4pxomCj7d88bCGYmV+znqAVswBnJ/QQub2v/ersJD2cgjUT0CRrmFDGDz6Sy4IGczmTF1nYKdM9kINut9ktlytbMnXAdzb9iFeIoK2tk0JDRuIhlVQetvXL938e0Z9u0TNzqpbXq325zWI62A== 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=xpzX3vOA3Sby+Lgs9FL3tcTpRtSOpfwbLu0BG+gKV3Y=; b=S2FnLafKkhPbVHkPm3XEMlDStobriRVGuZ02CzSOifTRouil9dOGuw0377BOMfqhV6P1jxD+CaFgKSeP2lDAPG2ZSCOLrNryVqp+HFDcb7PKnfuKsA2CheW72ahao9C96p9yHOFyf7L6MCqnMh2rlHWhK3J+xL7mb3STrqhX/PuyWzg0e+AiktgQPTA3drq601aQh9WOBVk99GxB2fp8qa8VaOd9N8xW9oXKZF9LVx84EUZrJQIClY4RjSNXZiHAJOgBkGoDI9Bi8FY+Nog67OuNgv9Wuif4g559KzPwkgRK9ox4vIYZdI/eobAnIvWIcW6p6Q6xVazvKAx04vdY2w== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xpzX3vOA3Sby+Lgs9FL3tcTpRtSOpfwbLu0BG+gKV3Y=; b=IODStxZekceuOth90FTu5JoCmweyT7BRcUrd8RHkmikXIs9WAhhQ+B3uCL2XGv6wZ5XtOtRaSTI7ontSBgLsOKmNeTtZErc0eLwpO3NKZibeNYYaJsje61JRUjoCyuWmSHxvVOMSbSzGBXZoXKYtWeB6PsTcQ3z+nPnh8FZOxq6OoqGoIl4/05SzfvOCcN+TTLJ7tA649i9tInpDuI+efRkr7B0FzXhLEI2HbIn1zqsilLoQvB9oaZxtNH8Las15SFcjmioGvzesrA8vdLQnpyHqqF3u1M3pQFUNnxV6pfM+lbJR3KbMneOdo02uMZsH2j3zHsKvQ57c8UQ325twaw== 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 AM9PR04MB7716.eurprd04.prod.outlook.com (2603:10a6:20b:280::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.23; Mon, 9 Sep 2024 19:39:14 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7939.022; Mon, 9 Sep 2024 19:39:13 +0000 From: Frank Li To: marex@denx.de Cc: Frank.li@nxp.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, francesco@dolcini.it, imx@lists.linux.dev, jun.li@nxp.com, kernel@pengutronix.de, krzk+dt@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, p.zabel@pengutronix.de, pratikmanvar09@gmail.com, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org, ukleinek@kernel.org, xiaoning.wang@nxp.com Subject: [PATCH v4 1/1] pwm: imx27: workaround of the pwm output bug when decrease the duty cycle Date: Mon, 9 Sep 2024 15:38:55 -0400 Message-Id: <20240909193855.2394830-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SJ0PR03CA0136.namprd03.prod.outlook.com (2603:10b6:a03:33c::21) 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_|AM9PR04MB7716:EE_ X-MS-Office365-Filtering-Correlation-Id: 108a1fbc-4e0a-4ffa-27cc-08dcd1071588 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|366016|7416014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?SpowErwa0/BkToeTh+hx16fqyVtpFU0?= =?utf-8?q?Wr+5X/jLpyJu3HV6BOK3xJZe5quou/fxXW8wlLpMK02ovZUCy6XioGYYeq0zxCamI?= =?utf-8?q?SJ4fJwnYeXc3RqyzlvHgu1R8vgDTByRIDPpXmIBzhttx++MJdxvhY9ADlUpT6EtPg?= =?utf-8?q?1mqEj38HZP1QMtDVwx3t7buLajEaKV5/ub/fxs0yVZrXGPP/oB9CmUUh1AMOsLzDm?= =?utf-8?q?2jdAPZhAIdj6WSEgFAUyVeXmS05v2uFWORLKHb6B6uPXk4Qq98BUToM9QMHLTgCNu?= =?utf-8?q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LaQcI7f7mxRv6nDLrzMMCy45rQSlEayLEAUotoiuPRoDZ+qx7QTmTPK51?= =?utf-8?q?8QJiEnlkoXGdFJhSy3VuQ77FVelM11mZcClkDA5NVOrOHqQzVf5P2dxzbaO35eZO+?= =?utf-8?q?FMrCWI8/cCkOEYPT7uj2n5S7MUPklUocjS8srWs0kAnKlhgrrXEqzx5bNkTNAZ5Dv?= =?utf-8?q?LrK3V5Z6p+FUXcgv7WZPI3epi1Q0Ann6wQ=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)(376014)(52116014)(366016)(7416014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?vPUT/7Xwo9PkxmWdFsVWG34XwLPq?= =?utf-8?q?6SxeihM4qydmTiAT5NJnrkTyt2bjQUm2l736krO6J5Eeys3aVJXGNdcxGicw3eCZT?= =?utf-8?q?gFns4aZ02csoFFlzqVa3CJ1ROsNinxOOoa8pvSC6Lmnimyg53d/no1KmKgEF0GGyD?= =?utf-8?q?0wJ4yxBGnOR5gQNhZuEPv8pJkefJURLz1rRHSKvH/7VbdU+3QI9KyYRY1chKGjJP3?= =?utf-8?q?P21zDsCU5KsL+qbmFWDGCcKakBIW8Ei7K+P3POYOr3FsUXmvkbO+FRg5/mi6ihEdZ?= =?utf-8?q?pTnPEEUBbvknM2ouFCqRqytfk+6zVWcMt3FWpo9Q3b3HBUsNEH2M3DeURHCj/O+e3?= =?utf-8?q?xZVcBJSpsGBrU9i/Pabo4gw156MpDpNOU7jfwTAcey+880+AcDPDBEIhyeKA1c0JT?= =?utf-8?q?0RJkav1+YI8E1C7LNZ7XvG34fu99aCI/DCaafnEuVkIpzUaO/WIXR3w1YPHArFAYl?= =?ut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gEsaPamb7FQVR/hBDpBjYsVAWHbBMs3jeZjRueZ7d7Dm/qaUrxmkpg2Y2+J8FE?= =?utf-8?q?N0T7tyyR+MaEsBFuJYnM9QpHsVSFw5iEumtHVRh166VX8WWO6Ybu8gVaHjtzdL7WB?= =?utf-8?q?jiAfnZUT3/hXMXfJ5VHudVlFx6oaw0zNda/eYfO/bmOTVqV/seCfOc0s=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 108a1fbc-4e0a-4ffa-27cc-08dcd1071588 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2024 19:39:13.8469 (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: BDq5wbk4rPP+GU5ZxPIspiWXYF9d1ysiL+3gvQo/3sutQw1rgm30jJhH0l6wOVbk/4gBe7j+wWkiAU6HbciYWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7716 From: Clark Wang Implement workaround for ERR051198 (https://www.nxp.com/docs/en/errata/IMX8MN_0N14Y.pdf) PWM output may not function correctly if the FIFO is empty when a new SAR value is programmed Description: When the PWM FIFO is empty, a new value programmed to the PWM Sample register (PWM_PWMSAR) will be directly applied even if the current timer period has not expired. If the new SAMPLE value programmed in the PWM_PWMSAR register is less than the previous value, and the PWM counter register (PWM_PWMCNR) that contains the current COUNT value is greater than the new programmed SAMPLE value, the current period will not flip the level. This may result in an output pulse with a duty cycle of 100%. Workaround: Program the current SAMPLE value in the PWM_PWMSAR register before updating the new duty cycle to the SAMPLE value in the PWM_PWMSAR register. This will ensure that the new SAMPLE value is modified during a non-empty FIFO, and can be successfully updated after the period expires. Write the old SAR value before updating the new duty cycle to SAR. This avoids writing the new value into an empty FIFO. This only resolves the issue when the PWM period is longer than 2us (or <500KHz) because write register is not quick enough when PWM period is very short. Reproduce steps: cd /sys/class/pwm/pwmchip1/pwm0 echo 2000000000 > period # It is easy to observe by using long period echo 1000000000 > duty_cycle echo 1 > enable echo 800000000 > duty_cycle # One full high plus will be seen by scope Fixes: 166091b1894d ("[ARM] MXC: add pwm driver for i.MX SoCs") Reviewed-by: Jun Li Signed-off-by: Clark Wang Signed-off-by: Frank Li --- Change from v2 to v3 - simple workaround implement. - add reproduce steps. Change from v1 to v2 - address comments in https://lore.kernel.org/linux-pwm/20211221095053.uz4qbnhdqziftymw@pengutronix.de/ About disable/enable pwm instead of disable/enable irq: Some pmw periphal may sensitive to period. Disable/enable pwm will increase period, althouhg it is okay for most case, such as LED backlight or FAN speed. But some device such servo may require strict period. - address comments in https://lore.kernel.org/linux-pwm/d72d1ae5-0378-4bac-8b77-0bb69f55accd@gmx.net/ Using official errata number fix typo 'filp' add {} for else I supposed fixed all previous issues, let me know if I missed one. --- drivers/pwm/pwm-imx27.c | 68 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-imx27.c b/drivers/pwm/pwm-imx27.c index 253afe94c4776..06840742017ed 100644 --- a/drivers/pwm/pwm-imx27.c +++ b/drivers/pwm/pwm-imx27.c @@ -27,6 +27,7 @@ #define MX3_PWMSR 0x04 /* PWM Status Register */ #define MX3_PWMSAR 0x0C /* PWM Sample Register */ #define MX3_PWMPR 0x10 /* PWM Period Register */ +#define MX3_PWMCNR 0x14 /* PWM Counter Register */ #define MX3_PWMCR_FWM GENMASK(27, 26) #define MX3_PWMCR_STOPEN BIT(25) @@ -232,8 +233,11 @@ static int pwm_imx27_apply(struct pwm_chip *chip, struct pwm_device *pwm, { unsigned long period_cycles, duty_cycles, prescale; struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip); + void __iomem *reg_sar = imx->mmio_base + MX3_PWMSAR; unsigned long long c; unsigned long long clkrate; + unsigned long flags; + int val; int ret; u32 cr; @@ -274,7 +278,69 @@ static int pwm_imx27_apply(struct pwm_chip *chip, struct pwm_device *pwm, pwm_imx27_sw_reset(chip); } - writel(duty_cycles, imx->mmio_base + MX3_PWMSAR); + /* + * This is a limited workaround. When the SAR FIFO is empty, the new + * write value will be directly applied to SAR even the current period + * is not over. + * + * ─────────────────────┐ + * PWM OUTPUT │ + * └───────────────────────── + * + * ┌──────────────────────────────────────────────┐ + * Counter │ XXXXXXXXXXXXXX │ + * └──────────────────────────────────────────────┘ + * ▲ ▲ + * │ │ + * New SAR Old SAR + * + * XXXX Errata happen window + * + * If the new SAR value is less than the old one, and the counter is + * greater than the new SAR value (see above diagram XXXX), the current + * period will not filp the level. This will result in a pulse with a + * duty cycle of 100%. + * + * Check new sar less than old sar and current counter is in errata + * windows, write extra old sar into FIFO and new sar will effect at + * next period. + * + * Sometime period is quite long, such as over 1 second. If add old sar + * into FIFO unconditional, new sar have to wait for next period. It + * may be too long. + * + * Turn off the interrupt to ensure that not irq and schedule happen + * during above operations. If any irq and schedule happen, counter + * in PMW will be out of data and take wrong action. + * + * Add a safety margin 1.5us because it needs some time to complete + * IO write. + * + * Use __raw_writel() to minimize the interval between two writes to + * the SAR register to increase the fastest pwm frequency supported. + * + * When the PWM period is longer than 2us(or <500KHz), this workaround + * can solve this problem. No software workaround is available If PMW + * period is shorter than IO write. + */ + c = clkrate * 1500; + do_div(c, NSEC_PER_SEC); + + local_irq_save(flags); + val = FIELD_GET(MX3_PWMSR_FIFOAV, readl_relaxed(imx->mmio_base + MX3_PWMSR)); + if (duty_cycles < imx->duty_cycle && val < MX3_PWMSR_FIFOAV_2WORDS) { + val = readl_relaxed(imx->mmio_base + MX3_PWMCNR); + if ((val + c >= duty_cycles && val < imx->duty_cycle) || + /* + * If counter is close to period, controller may roll over + * when next IO write. + */ + val + c >= period_cycles) + writel_relaxed(imx->duty_cycle, reg_sar); + } + writel_relaxed(duty_cycles, reg_sar); + local_irq_restore(flags); + writel(period_cycles, imx->mmio_base + MX3_PWMPR); /*