From 079d95b7c67be611a732decdea72995c1b2ba039 Mon Sep 17 00:00:00 2001 From: Choi Jaehyoung Date: Tue, 25 Jul 2017 20:17:40 +0900 Subject: [PATCH] [COMMON] pwm: pwm-samsung: Initialize PWM Divider, Prescaler. The reason for initializing PWM Divider and Prescaler is as follows. - In the past, init function in clk-exynos-pwm.c initialized Divider and Prescaler, but no longer uses the clk-exynos-pwm.c file. Therefore, they must be initialized at the time of kernel probe. - The current bootloader sets the Divider and Prescaler values to use PWM. After the bootloader finishes, they must be initizlized in kernel. Change-Id: I9bd0f8e869209380153582bb28a759892ff06ca2 Signed-off-by: Choi Jaehyoung --- drivers/pwm/pwm-samsung.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c index d7e15c23c754..e27b1b285b5c 100755 --- a/drivers/pwm/pwm-samsung.c +++ b/drivers/pwm/pwm-samsung.c @@ -573,7 +573,7 @@ static const struct samsung_pwm_variant s3c24xx_variant = { static const struct samsung_pwm_variant s3c64xx_variant = { .bits = 16, - .div_base = 1, + .div_base = 0, .has_tint_cstat = true, .tclk_mask = BIT(7) | BIT(6) | BIT(5), }; @@ -640,7 +640,7 @@ static int pwm_samsung_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct samsung_pwm_chip *chip; struct resource *res; - unsigned int chan; + unsigned int chan, reg_tcfg0; int ret; chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL); @@ -694,6 +694,15 @@ static int pwm_samsung_probe(struct platform_device *pdev) return ret; } + /* Initialize Prescaler */ + reg_tcfg0 = readl(chip->base + REG_TCFG0); + reg_tcfg0 &= ~(TCFG0_PRESCALER_MASK | + (TCFG0_PRESCALER_MASK << TCFG0_PRESCALER1_SHIFT)); + writel(reg_tcfg0, chip->base + REG_TCFG0); + + /* Initialize Divider MUX */ + writel(0, chip->base + REG_TCFG1); + for (chan = 0; chan < SAMSUNG_PWM_NUM; ++chan) if (chip->variant.output_mask & BIT(chan)) pwm_samsung_set_invert(chip, chan, true); -- 2.20.1