linux-stable/drivers/pwm
Hans de Goede 79e0899275 pwm: crc: Fix period / duty_cycle times being off by a factor of 256
While looking into adding atomic-pwm support to the pwm-crc driver I
noticed something odd, there is a PWM_BASE_CLK define of 6 MHz and
there is a clock-divider which divides this with a value between 1-128,
and there are 256 duty-cycle steps.

The pwm-crc code before this commit assumed that a clock-divider
setting of 1 means that the PWM output is running at 6 MHZ, if that
is true, where do these 256 duty-cycle steps come from?

This would require an internal frequency of 256 * 6 MHz = 1.5 GHz, that
seems unlikely for a PMIC which is using a silicon process optimized for
power-switching transistors. It is way more likely that there is an 8
bit counter for the duty cycle which acts as an extra fixed divider
wrt the PWM output frequency.

The main user of the pwm-crc driver is the i915 GPU driver which uses it
for backlight control. Lets compare the PWM register values set by the
video-BIOS (the GOP), assuming the extra fixed divider is present versus
the PWM frequency specified in the Video-BIOS-Tables:

Device:		PWM Hz set by BIOS	PWM Hz specified in VBT
Asus T100TA 	200			200
Asus T100HA 	200			200
Lenovo Miix 2 8	23437			20000
Toshiba WT8-A	23437			20000

So as we can see if we assume the extra division by 256 then the register
values set by the GOP are an exact match for the VBT values, where as
otherwise the values would be of by a factor of 256.

This commit fixes the period / duty_cycle calculations to take the
extra division by 256 into account.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200903112337.4113-9-hdegoede@redhat.com
2020-09-06 15:38:02 +02:00
..
core.c pwm: Add missing "CONFIG_" prefix 2020-06-04 19:09:28 +02:00
Kconfig pwm: jz4740: Drop dependency on MACH_INGENIC 2020-06-02 14:23:42 +02:00
Makefile pwm: Add support for Azoteq IQS620A PWM generator 2020-04-14 16:02:28 +02:00
pwm-ab8500.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 194 2019-05-30 11:29:22 -07:00
pwm-atmel-hlcdc.c pwm: Ensure pwm_apply_state() doesn't modify the state argument 2019-09-21 03:25:10 +02:00
pwm-atmel-tcb.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 194 2019-05-30 11:29:22 -07:00
pwm-atmel.c pwm: atmel: Implement .get_state() 2020-01-08 13:47:46 +01:00
pwm-bcm-iproc.c pwm: bcm-iproc: Prevent unloading the driver module while in use 2019-11-08 18:38:06 +01:00
pwm-bcm-kona.c pwm: bcm-kona: Update macros to remove braces around numbers 2019-03-04 12:52:49 +01:00
pwm-bcm2835.c pwm: bcm2835: Dynamically allocate base 2020-03-30 16:55:25 +02:00
pwm-berlin.c pwm: Clear chip_data in pwm_put() 2019-05-09 17:09:54 +02:00
pwm-brcmstb.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
pwm-clps711x.c pwm: clps711x: Switch to SPDX identifier 2018-12-24 12:06:56 +01:00
pwm-crc.c pwm: crc: Fix period / duty_cycle times being off by a factor of 256 2020-09-06 15:38:02 +02:00
pwm-cros-ec.c pwm: cros-ec: Cache duty cycle value 2019-12-09 10:05:42 +01:00
pwm-ep93xx.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
pwm-fsl-ftm.c pwm: Ensure pwm_apply_state() doesn't modify the state argument 2019-09-21 03:25:10 +02:00
pwm-hibvt.c pwm: Ensure pwm_apply_state() doesn't modify the state argument 2019-09-21 03:25:10 +02:00
pwm-img.c pwm: img: Call pm_runtime_put() in pm_runtime_get_sync() failed case 2020-06-02 15:50:51 +02:00
pwm-imx-tpm.c pwm: imx-tpm: Remove unused includes 2020-03-30 16:55:26 +02:00
pwm-imx1.c pwm: imx: Split into two drivers 2019-01-16 08:45:33 +01:00
pwm-imx27.c pwm: imx27: Fix rounding behavior 2020-06-02 15:50:52 +02:00
pwm-iqs620a.c pwm: Add support for Azoteq IQS620A PWM generator 2020-04-14 16:02:28 +02:00
pwm-jz4740.c pwm: jz4740: Add support for the JZ4725B 2020-06-02 14:24:57 +02:00
pwm-lp3943.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 372 2019-06-05 17:37:10 +02:00
pwm-lpc18xx-sct.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 178 2019-05-30 11:29:19 -07:00
pwm-lpc32xx.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 372 2019-06-05 17:37:10 +02:00
pwm-lpss-pci.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
pwm-lpss-platform.c pwm: lpss: Remove suspend/resume handlers 2020-09-06 15:38:01 +02:00
pwm-lpss.c pwm: lpss: Remove suspend/resume handlers 2020-09-06 15:38:01 +02:00
pwm-lpss.h pwm: lpss: Remove suspend/resume handlers 2020-09-06 15:38:01 +02:00
pwm-mediatek.c pwm: mediatek: Add MT7629 compatible string 2019-09-26 13:27:50 +02:00
pwm-meson.c pwm: meson: Remove redundant assignment to variable fin_freq 2020-04-03 21:40:56 +02:00
pwm-mtk-disp.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174 2019-05-30 11:26:41 -07:00
pwm-mxs.c pwm: mxs: Remove unused include of of_address.h 2020-03-30 16:55:27 +02:00
pwm-omap-dmtimer.c pwm: omap-dmtimer: Implement .apply callback 2020-03-30 18:03:08 +02:00
pwm-pca9685.c pwm: pca9685: Fix PWM/GPIO inter-operation 2020-04-03 21:41:42 +02:00
pwm-puv3.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
pwm-pxa.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
pwm-rcar.c pwm: rcar: Fix late Runtime PM enablement 2020-03-30 18:03:05 +02:00
pwm-renesas-tpu.c pwm: renesas-tpu: Drop confusing registered message 2020-03-30 18:03:06 +02:00
pwm-rockchip.c pwm: rockchip: Simplify rockchip_pwm_get_state() 2020-06-02 15:50:52 +02:00
pwm-samsung.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 178 2019-05-30 11:29:19 -07:00
pwm-sifive.c pwm: Ensure pwm_apply_state() doesn't modify the state argument 2019-09-21 03:25:10 +02:00
pwm-spear.c pwm: drop owner assignment from platform_drivers 2014-10-20 16:21:28 +02:00
pwm-sprd.c pwm: Ensure pwm_apply_state() doesn't modify the state argument 2019-09-21 03:25:10 +02:00
pwm-sti.c pwm: Remove dev_err() usage after platform_get_irq() 2019-09-21 00:58:35 +02:00
pwm-stm32-lp.c pwm: stm32-lp: Add check in case requested period cannot be achieved 2019-09-21 03:25:10 +02:00
pwm-stm32.c pwm: stm32: Remove automatic output enable 2020-01-20 13:47:36 +01:00
pwm-stmpe.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
pwm-sun4i.c pwm: sun4i: Support direct clock output on Allwinner A64 2020-06-02 14:20:11 +02:00
pwm-tegra.c pwm: tegra: Support dynamic clock frequency configuration 2020-06-02 14:25:37 +02:00
pwm-tiecap.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00
pwm-tiehrpwm.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00
pwm-twl-led.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
pwm-twl.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
pwm-vt8500.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
pwm-zx.c pwm: Ensure pwm_apply_state() doesn't modify the state argument 2019-09-21 03:25:10 +02:00
sysfs.c pwm: Changes for v5.3-rc1 2019-07-09 08:57:45 -07:00