18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2007 Ben Dooks 48c2ecf20Sopenharmony_ci * Copyright (c) 2008 Simtec Electronics 58c2ecf20Sopenharmony_ci * Ben Dooks <ben@simtec.co.uk>, <ben-linux@fluff.org> 68c2ecf20Sopenharmony_ci * Copyright (c) 2013 Tomasz Figa <tomasz.figa@gmail.com> 78c2ecf20Sopenharmony_ci * Copyright (c) 2017 Samsung Electronics Co., Ltd. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * PWM driver for Samsung SoCs 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/bitops.h> 138c2ecf20Sopenharmony_ci#include <linux/clk.h> 148c2ecf20Sopenharmony_ci#include <linux/export.h> 158c2ecf20Sopenharmony_ci#include <linux/err.h> 168c2ecf20Sopenharmony_ci#include <linux/io.h> 178c2ecf20Sopenharmony_ci#include <linux/kernel.h> 188c2ecf20Sopenharmony_ci#include <linux/module.h> 198c2ecf20Sopenharmony_ci#include <linux/of.h> 208c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 218c2ecf20Sopenharmony_ci#include <linux/pwm.h> 228c2ecf20Sopenharmony_ci#include <linux/slab.h> 238c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 248c2ecf20Sopenharmony_ci#include <linux/time.h> 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci/* For struct samsung_timer_variant and samsung_pwm_lock. */ 278c2ecf20Sopenharmony_ci#include <clocksource/samsung_pwm.h> 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define REG_TCFG0 0x00 308c2ecf20Sopenharmony_ci#define REG_TCFG1 0x04 318c2ecf20Sopenharmony_ci#define REG_TCON 0x08 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define REG_TCNTB(chan) (0x0c + ((chan) * 0xc)) 348c2ecf20Sopenharmony_ci#define REG_TCMPB(chan) (0x10 + ((chan) * 0xc)) 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define TCFG0_PRESCALER_MASK 0xff 378c2ecf20Sopenharmony_ci#define TCFG0_PRESCALER1_SHIFT 8 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define TCFG1_MUX_MASK 0xf 408c2ecf20Sopenharmony_ci#define TCFG1_SHIFT(chan) (4 * (chan)) 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci/* 438c2ecf20Sopenharmony_ci * Each channel occupies 4 bits in TCON register, but there is a gap of 4 448c2ecf20Sopenharmony_ci * bits (one channel) after channel 0, so channels have different numbering 458c2ecf20Sopenharmony_ci * when accessing TCON register. See to_tcon_channel() function. 468c2ecf20Sopenharmony_ci * 478c2ecf20Sopenharmony_ci * In addition, the location of autoreload bit for channel 4 (TCON channel 5) 488c2ecf20Sopenharmony_ci * in its set of bits is 2 as opposed to 3 for other channels. 498c2ecf20Sopenharmony_ci */ 508c2ecf20Sopenharmony_ci#define TCON_START(chan) BIT(4 * (chan) + 0) 518c2ecf20Sopenharmony_ci#define TCON_MANUALUPDATE(chan) BIT(4 * (chan) + 1) 528c2ecf20Sopenharmony_ci#define TCON_INVERT(chan) BIT(4 * (chan) + 2) 538c2ecf20Sopenharmony_ci#define _TCON_AUTORELOAD(chan) BIT(4 * (chan) + 3) 548c2ecf20Sopenharmony_ci#define _TCON_AUTORELOAD4(chan) BIT(4 * (chan) + 2) 558c2ecf20Sopenharmony_ci#define TCON_AUTORELOAD(chan) \ 568c2ecf20Sopenharmony_ci ((chan < 5) ? _TCON_AUTORELOAD(chan) : _TCON_AUTORELOAD4(chan)) 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/** 598c2ecf20Sopenharmony_ci * struct samsung_pwm_channel - private data of PWM channel 608c2ecf20Sopenharmony_ci * @period_ns: current period in nanoseconds programmed to the hardware 618c2ecf20Sopenharmony_ci * @duty_ns: current duty time in nanoseconds programmed to the hardware 628c2ecf20Sopenharmony_ci * @tin_ns: time of one timer tick in nanoseconds with current timer rate 638c2ecf20Sopenharmony_ci */ 648c2ecf20Sopenharmony_cistruct samsung_pwm_channel { 658c2ecf20Sopenharmony_ci u32 period_ns; 668c2ecf20Sopenharmony_ci u32 duty_ns; 678c2ecf20Sopenharmony_ci u32 tin_ns; 688c2ecf20Sopenharmony_ci}; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci/** 718c2ecf20Sopenharmony_ci * struct samsung_pwm_chip - private data of PWM chip 728c2ecf20Sopenharmony_ci * @chip: generic PWM chip 738c2ecf20Sopenharmony_ci * @variant: local copy of hardware variant data 748c2ecf20Sopenharmony_ci * @inverter_mask: inverter status for all channels - one bit per channel 758c2ecf20Sopenharmony_ci * @disabled_mask: disabled status for all channels - one bit per channel 768c2ecf20Sopenharmony_ci * @base: base address of mapped PWM registers 778c2ecf20Sopenharmony_ci * @base_clk: base clock used to drive the timers 788c2ecf20Sopenharmony_ci * @tclk0: external clock 0 (can be ERR_PTR if not present) 798c2ecf20Sopenharmony_ci * @tclk1: external clock 1 (can be ERR_PTR if not present) 808c2ecf20Sopenharmony_ci */ 818c2ecf20Sopenharmony_cistruct samsung_pwm_chip { 828c2ecf20Sopenharmony_ci struct pwm_chip chip; 838c2ecf20Sopenharmony_ci struct samsung_pwm_variant variant; 848c2ecf20Sopenharmony_ci u8 inverter_mask; 858c2ecf20Sopenharmony_ci u8 disabled_mask; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci void __iomem *base; 888c2ecf20Sopenharmony_ci struct clk *base_clk; 898c2ecf20Sopenharmony_ci struct clk *tclk0; 908c2ecf20Sopenharmony_ci struct clk *tclk1; 918c2ecf20Sopenharmony_ci}; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci#ifndef CONFIG_CLKSRC_SAMSUNG_PWM 948c2ecf20Sopenharmony_ci/* 958c2ecf20Sopenharmony_ci * PWM block is shared between pwm-samsung and samsung_pwm_timer drivers 968c2ecf20Sopenharmony_ci * and some registers need access synchronization. If both drivers are 978c2ecf20Sopenharmony_ci * compiled in, the spinlock is defined in the clocksource driver, 988c2ecf20Sopenharmony_ci * otherwise following definition is used. 998c2ecf20Sopenharmony_ci * 1008c2ecf20Sopenharmony_ci * Currently we do not need any more complex synchronization method 1018c2ecf20Sopenharmony_ci * because all the supported SoCs contain only one instance of the PWM 1028c2ecf20Sopenharmony_ci * IP. Should this change, both drivers will need to be modified to 1038c2ecf20Sopenharmony_ci * properly synchronize accesses to particular instances. 1048c2ecf20Sopenharmony_ci */ 1058c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(samsung_pwm_lock); 1068c2ecf20Sopenharmony_ci#endif 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_cistatic inline 1098c2ecf20Sopenharmony_cistruct samsung_pwm_chip *to_samsung_pwm_chip(struct pwm_chip *chip) 1108c2ecf20Sopenharmony_ci{ 1118c2ecf20Sopenharmony_ci return container_of(chip, struct samsung_pwm_chip, chip); 1128c2ecf20Sopenharmony_ci} 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_cistatic inline unsigned int to_tcon_channel(unsigned int channel) 1158c2ecf20Sopenharmony_ci{ 1168c2ecf20Sopenharmony_ci /* TCON register has a gap of 4 bits (1 channel) after channel 0 */ 1178c2ecf20Sopenharmony_ci return (channel == 0) ? 0 : (channel + 1); 1188c2ecf20Sopenharmony_ci} 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_cistatic void pwm_samsung_set_divisor(struct samsung_pwm_chip *pwm, 1218c2ecf20Sopenharmony_ci unsigned int channel, u8 divisor) 1228c2ecf20Sopenharmony_ci{ 1238c2ecf20Sopenharmony_ci u8 shift = TCFG1_SHIFT(channel); 1248c2ecf20Sopenharmony_ci unsigned long flags; 1258c2ecf20Sopenharmony_ci u32 reg; 1268c2ecf20Sopenharmony_ci u8 bits; 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci bits = (fls(divisor) - 1) - pwm->variant.div_base; 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci spin_lock_irqsave(&samsung_pwm_lock, flags); 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci reg = readl(pwm->base + REG_TCFG1); 1338c2ecf20Sopenharmony_ci reg &= ~(TCFG1_MUX_MASK << shift); 1348c2ecf20Sopenharmony_ci reg |= bits << shift; 1358c2ecf20Sopenharmony_ci writel(reg, pwm->base + REG_TCFG1); 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&samsung_pwm_lock, flags); 1388c2ecf20Sopenharmony_ci} 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_cistatic int pwm_samsung_is_tdiv(struct samsung_pwm_chip *chip, unsigned int chan) 1418c2ecf20Sopenharmony_ci{ 1428c2ecf20Sopenharmony_ci struct samsung_pwm_variant *variant = &chip->variant; 1438c2ecf20Sopenharmony_ci u32 reg; 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci reg = readl(chip->base + REG_TCFG1); 1468c2ecf20Sopenharmony_ci reg >>= TCFG1_SHIFT(chan); 1478c2ecf20Sopenharmony_ci reg &= TCFG1_MUX_MASK; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci return (BIT(reg) & variant->tclk_mask) == 0; 1508c2ecf20Sopenharmony_ci} 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_cistatic unsigned long pwm_samsung_get_tin_rate(struct samsung_pwm_chip *chip, 1538c2ecf20Sopenharmony_ci unsigned int chan) 1548c2ecf20Sopenharmony_ci{ 1558c2ecf20Sopenharmony_ci unsigned long rate; 1568c2ecf20Sopenharmony_ci u32 reg; 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci rate = clk_get_rate(chip->base_clk); 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci reg = readl(chip->base + REG_TCFG0); 1618c2ecf20Sopenharmony_ci if (chan >= 2) 1628c2ecf20Sopenharmony_ci reg >>= TCFG0_PRESCALER1_SHIFT; 1638c2ecf20Sopenharmony_ci reg &= TCFG0_PRESCALER_MASK; 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci return rate / (reg + 1); 1668c2ecf20Sopenharmony_ci} 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_cistatic unsigned long pwm_samsung_calc_tin(struct samsung_pwm_chip *chip, 1698c2ecf20Sopenharmony_ci unsigned int chan, unsigned long freq) 1708c2ecf20Sopenharmony_ci{ 1718c2ecf20Sopenharmony_ci struct samsung_pwm_variant *variant = &chip->variant; 1728c2ecf20Sopenharmony_ci unsigned long rate; 1738c2ecf20Sopenharmony_ci struct clk *clk; 1748c2ecf20Sopenharmony_ci u8 div; 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci if (!pwm_samsung_is_tdiv(chip, chan)) { 1778c2ecf20Sopenharmony_ci clk = (chan < 2) ? chip->tclk0 : chip->tclk1; 1788c2ecf20Sopenharmony_ci if (!IS_ERR(clk)) { 1798c2ecf20Sopenharmony_ci rate = clk_get_rate(clk); 1808c2ecf20Sopenharmony_ci if (rate) 1818c2ecf20Sopenharmony_ci return rate; 1828c2ecf20Sopenharmony_ci } 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci dev_warn(chip->chip.dev, 1858c2ecf20Sopenharmony_ci "tclk of PWM %d is inoperational, using tdiv\n", chan); 1868c2ecf20Sopenharmony_ci } 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci rate = pwm_samsung_get_tin_rate(chip, chan); 1898c2ecf20Sopenharmony_ci dev_dbg(chip->chip.dev, "tin parent at %lu\n", rate); 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci /* 1928c2ecf20Sopenharmony_ci * Compare minimum PWM frequency that can be achieved with possible 1938c2ecf20Sopenharmony_ci * divider settings and choose the lowest divisor that can generate 1948c2ecf20Sopenharmony_ci * frequencies lower than requested. 1958c2ecf20Sopenharmony_ci */ 1968c2ecf20Sopenharmony_ci if (variant->bits < 32) { 1978c2ecf20Sopenharmony_ci /* Only for s3c24xx */ 1988c2ecf20Sopenharmony_ci for (div = variant->div_base; div < 4; ++div) 1998c2ecf20Sopenharmony_ci if ((rate >> (variant->bits + div)) < freq) 2008c2ecf20Sopenharmony_ci break; 2018c2ecf20Sopenharmony_ci } else { 2028c2ecf20Sopenharmony_ci /* 2038c2ecf20Sopenharmony_ci * Other variants have enough counter bits to generate any 2048c2ecf20Sopenharmony_ci * requested rate, so no need to check higher divisors. 2058c2ecf20Sopenharmony_ci */ 2068c2ecf20Sopenharmony_ci div = variant->div_base; 2078c2ecf20Sopenharmony_ci } 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci pwm_samsung_set_divisor(chip, chan, BIT(div)); 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci return rate >> div; 2128c2ecf20Sopenharmony_ci} 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_cistatic int pwm_samsung_request(struct pwm_chip *chip, struct pwm_device *pwm) 2158c2ecf20Sopenharmony_ci{ 2168c2ecf20Sopenharmony_ci struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip); 2178c2ecf20Sopenharmony_ci struct samsung_pwm_channel *our_chan; 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci if (!(our_chip->variant.output_mask & BIT(pwm->hwpwm))) { 2208c2ecf20Sopenharmony_ci dev_warn(chip->dev, 2218c2ecf20Sopenharmony_ci "tried to request PWM channel %d without output\n", 2228c2ecf20Sopenharmony_ci pwm->hwpwm); 2238c2ecf20Sopenharmony_ci return -EINVAL; 2248c2ecf20Sopenharmony_ci } 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci our_chan = kzalloc(sizeof(*our_chan), GFP_KERNEL); 2278c2ecf20Sopenharmony_ci if (!our_chan) 2288c2ecf20Sopenharmony_ci return -ENOMEM; 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci pwm_set_chip_data(pwm, our_chan); 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci return 0; 2338c2ecf20Sopenharmony_ci} 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_cistatic void pwm_samsung_free(struct pwm_chip *chip, struct pwm_device *pwm) 2368c2ecf20Sopenharmony_ci{ 2378c2ecf20Sopenharmony_ci kfree(pwm_get_chip_data(pwm)); 2388c2ecf20Sopenharmony_ci} 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_cistatic int pwm_samsung_enable(struct pwm_chip *chip, struct pwm_device *pwm) 2418c2ecf20Sopenharmony_ci{ 2428c2ecf20Sopenharmony_ci struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip); 2438c2ecf20Sopenharmony_ci unsigned int tcon_chan = to_tcon_channel(pwm->hwpwm); 2448c2ecf20Sopenharmony_ci unsigned long flags; 2458c2ecf20Sopenharmony_ci u32 tcon; 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci spin_lock_irqsave(&samsung_pwm_lock, flags); 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci tcon = readl(our_chip->base + REG_TCON); 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci tcon &= ~TCON_START(tcon_chan); 2528c2ecf20Sopenharmony_ci tcon |= TCON_MANUALUPDATE(tcon_chan); 2538c2ecf20Sopenharmony_ci writel(tcon, our_chip->base + REG_TCON); 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci tcon &= ~TCON_MANUALUPDATE(tcon_chan); 2568c2ecf20Sopenharmony_ci tcon |= TCON_START(tcon_chan) | TCON_AUTORELOAD(tcon_chan); 2578c2ecf20Sopenharmony_ci writel(tcon, our_chip->base + REG_TCON); 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci our_chip->disabled_mask &= ~BIT(pwm->hwpwm); 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&samsung_pwm_lock, flags); 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci return 0; 2648c2ecf20Sopenharmony_ci} 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_cistatic void pwm_samsung_disable(struct pwm_chip *chip, struct pwm_device *pwm) 2678c2ecf20Sopenharmony_ci{ 2688c2ecf20Sopenharmony_ci struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip); 2698c2ecf20Sopenharmony_ci unsigned int tcon_chan = to_tcon_channel(pwm->hwpwm); 2708c2ecf20Sopenharmony_ci unsigned long flags; 2718c2ecf20Sopenharmony_ci u32 tcon; 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci spin_lock_irqsave(&samsung_pwm_lock, flags); 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci tcon = readl(our_chip->base + REG_TCON); 2768c2ecf20Sopenharmony_ci tcon &= ~TCON_AUTORELOAD(tcon_chan); 2778c2ecf20Sopenharmony_ci writel(tcon, our_chip->base + REG_TCON); 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_ci our_chip->disabled_mask |= BIT(pwm->hwpwm); 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&samsung_pwm_lock, flags); 2828c2ecf20Sopenharmony_ci} 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_cistatic void pwm_samsung_manual_update(struct samsung_pwm_chip *chip, 2858c2ecf20Sopenharmony_ci struct pwm_device *pwm) 2868c2ecf20Sopenharmony_ci{ 2878c2ecf20Sopenharmony_ci unsigned int tcon_chan = to_tcon_channel(pwm->hwpwm); 2888c2ecf20Sopenharmony_ci u32 tcon; 2898c2ecf20Sopenharmony_ci unsigned long flags; 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci spin_lock_irqsave(&samsung_pwm_lock, flags); 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci tcon = readl(chip->base + REG_TCON); 2948c2ecf20Sopenharmony_ci tcon |= TCON_MANUALUPDATE(tcon_chan); 2958c2ecf20Sopenharmony_ci writel(tcon, chip->base + REG_TCON); 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_ci tcon &= ~TCON_MANUALUPDATE(tcon_chan); 2988c2ecf20Sopenharmony_ci writel(tcon, chip->base + REG_TCON); 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&samsung_pwm_lock, flags); 3018c2ecf20Sopenharmony_ci} 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_cistatic int __pwm_samsung_config(struct pwm_chip *chip, struct pwm_device *pwm, 3048c2ecf20Sopenharmony_ci int duty_ns, int period_ns, bool force_period) 3058c2ecf20Sopenharmony_ci{ 3068c2ecf20Sopenharmony_ci struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip); 3078c2ecf20Sopenharmony_ci struct samsung_pwm_channel *chan = pwm_get_chip_data(pwm); 3088c2ecf20Sopenharmony_ci u32 tin_ns = chan->tin_ns, tcnt, tcmp, oldtcmp; 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci /* 3118c2ecf20Sopenharmony_ci * We currently avoid using 64bit arithmetic by using the 3128c2ecf20Sopenharmony_ci * fact that anything faster than 1Hz is easily representable 3138c2ecf20Sopenharmony_ci * by 32bits. 3148c2ecf20Sopenharmony_ci */ 3158c2ecf20Sopenharmony_ci if (period_ns > NSEC_PER_SEC) 3168c2ecf20Sopenharmony_ci return -ERANGE; 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ci tcnt = readl(our_chip->base + REG_TCNTB(pwm->hwpwm)); 3198c2ecf20Sopenharmony_ci oldtcmp = readl(our_chip->base + REG_TCMPB(pwm->hwpwm)); 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_ci /* We need tick count for calculation, not last tick. */ 3228c2ecf20Sopenharmony_ci ++tcnt; 3238c2ecf20Sopenharmony_ci 3248c2ecf20Sopenharmony_ci /* Check to see if we are changing the clock rate of the PWM. */ 3258c2ecf20Sopenharmony_ci if (chan->period_ns != period_ns || force_period) { 3268c2ecf20Sopenharmony_ci unsigned long tin_rate; 3278c2ecf20Sopenharmony_ci u32 period; 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ci period = NSEC_PER_SEC / period_ns; 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci dev_dbg(our_chip->chip.dev, "duty_ns=%d, period_ns=%d (%u)\n", 3328c2ecf20Sopenharmony_ci duty_ns, period_ns, period); 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ci tin_rate = pwm_samsung_calc_tin(our_chip, pwm->hwpwm, period); 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ci dev_dbg(our_chip->chip.dev, "tin_rate=%lu\n", tin_rate); 3378c2ecf20Sopenharmony_ci 3388c2ecf20Sopenharmony_ci tin_ns = NSEC_PER_SEC / tin_rate; 3398c2ecf20Sopenharmony_ci tcnt = period_ns / tin_ns; 3408c2ecf20Sopenharmony_ci } 3418c2ecf20Sopenharmony_ci 3428c2ecf20Sopenharmony_ci /* Period is too short. */ 3438c2ecf20Sopenharmony_ci if (tcnt <= 1) 3448c2ecf20Sopenharmony_ci return -ERANGE; 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci /* Note that counters count down. */ 3478c2ecf20Sopenharmony_ci tcmp = duty_ns / tin_ns; 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ci /* 0% duty is not available */ 3508c2ecf20Sopenharmony_ci if (!tcmp) 3518c2ecf20Sopenharmony_ci ++tcmp; 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ci tcmp = tcnt - tcmp; 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_ci /* Decrement to get tick numbers, instead of tick counts. */ 3568c2ecf20Sopenharmony_ci --tcnt; 3578c2ecf20Sopenharmony_ci /* -1UL will give 100% duty. */ 3588c2ecf20Sopenharmony_ci --tcmp; 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ci dev_dbg(our_chip->chip.dev, 3618c2ecf20Sopenharmony_ci "tin_ns=%u, tcmp=%u/%u\n", tin_ns, tcmp, tcnt); 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_ci /* Update PWM registers. */ 3648c2ecf20Sopenharmony_ci writel(tcnt, our_chip->base + REG_TCNTB(pwm->hwpwm)); 3658c2ecf20Sopenharmony_ci writel(tcmp, our_chip->base + REG_TCMPB(pwm->hwpwm)); 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_ci /* 3688c2ecf20Sopenharmony_ci * In case the PWM is currently at 100% duty cycle, force a manual 3698c2ecf20Sopenharmony_ci * update to prevent the signal staying high if the PWM is disabled 3708c2ecf20Sopenharmony_ci * shortly afer this update (before it autoreloaded the new values). 3718c2ecf20Sopenharmony_ci */ 3728c2ecf20Sopenharmony_ci if (oldtcmp == (u32) -1) { 3738c2ecf20Sopenharmony_ci dev_dbg(our_chip->chip.dev, "Forcing manual update"); 3748c2ecf20Sopenharmony_ci pwm_samsung_manual_update(our_chip, pwm); 3758c2ecf20Sopenharmony_ci } 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ci chan->period_ns = period_ns; 3788c2ecf20Sopenharmony_ci chan->tin_ns = tin_ns; 3798c2ecf20Sopenharmony_ci chan->duty_ns = duty_ns; 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_ci return 0; 3828c2ecf20Sopenharmony_ci} 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_cistatic int pwm_samsung_config(struct pwm_chip *chip, struct pwm_device *pwm, 3858c2ecf20Sopenharmony_ci int duty_ns, int period_ns) 3868c2ecf20Sopenharmony_ci{ 3878c2ecf20Sopenharmony_ci return __pwm_samsung_config(chip, pwm, duty_ns, period_ns, false); 3888c2ecf20Sopenharmony_ci} 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_cistatic void pwm_samsung_set_invert(struct samsung_pwm_chip *chip, 3918c2ecf20Sopenharmony_ci unsigned int channel, bool invert) 3928c2ecf20Sopenharmony_ci{ 3938c2ecf20Sopenharmony_ci unsigned int tcon_chan = to_tcon_channel(channel); 3948c2ecf20Sopenharmony_ci unsigned long flags; 3958c2ecf20Sopenharmony_ci u32 tcon; 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci spin_lock_irqsave(&samsung_pwm_lock, flags); 3988c2ecf20Sopenharmony_ci 3998c2ecf20Sopenharmony_ci tcon = readl(chip->base + REG_TCON); 4008c2ecf20Sopenharmony_ci 4018c2ecf20Sopenharmony_ci if (invert) { 4028c2ecf20Sopenharmony_ci chip->inverter_mask |= BIT(channel); 4038c2ecf20Sopenharmony_ci tcon |= TCON_INVERT(tcon_chan); 4048c2ecf20Sopenharmony_ci } else { 4058c2ecf20Sopenharmony_ci chip->inverter_mask &= ~BIT(channel); 4068c2ecf20Sopenharmony_ci tcon &= ~TCON_INVERT(tcon_chan); 4078c2ecf20Sopenharmony_ci } 4088c2ecf20Sopenharmony_ci 4098c2ecf20Sopenharmony_ci writel(tcon, chip->base + REG_TCON); 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&samsung_pwm_lock, flags); 4128c2ecf20Sopenharmony_ci} 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_cistatic int pwm_samsung_set_polarity(struct pwm_chip *chip, 4158c2ecf20Sopenharmony_ci struct pwm_device *pwm, 4168c2ecf20Sopenharmony_ci enum pwm_polarity polarity) 4178c2ecf20Sopenharmony_ci{ 4188c2ecf20Sopenharmony_ci struct samsung_pwm_chip *our_chip = to_samsung_pwm_chip(chip); 4198c2ecf20Sopenharmony_ci bool invert = (polarity == PWM_POLARITY_NORMAL); 4208c2ecf20Sopenharmony_ci 4218c2ecf20Sopenharmony_ci /* Inverted means normal in the hardware. */ 4228c2ecf20Sopenharmony_ci pwm_samsung_set_invert(our_chip, pwm->hwpwm, invert); 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_ci return 0; 4258c2ecf20Sopenharmony_ci} 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_cistatic const struct pwm_ops pwm_samsung_ops = { 4288c2ecf20Sopenharmony_ci .request = pwm_samsung_request, 4298c2ecf20Sopenharmony_ci .free = pwm_samsung_free, 4308c2ecf20Sopenharmony_ci .enable = pwm_samsung_enable, 4318c2ecf20Sopenharmony_ci .disable = pwm_samsung_disable, 4328c2ecf20Sopenharmony_ci .config = pwm_samsung_config, 4338c2ecf20Sopenharmony_ci .set_polarity = pwm_samsung_set_polarity, 4348c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 4358c2ecf20Sopenharmony_ci}; 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_ci#ifdef CONFIG_OF 4388c2ecf20Sopenharmony_cistatic const struct samsung_pwm_variant s3c24xx_variant = { 4398c2ecf20Sopenharmony_ci .bits = 16, 4408c2ecf20Sopenharmony_ci .div_base = 1, 4418c2ecf20Sopenharmony_ci .has_tint_cstat = false, 4428c2ecf20Sopenharmony_ci .tclk_mask = BIT(4), 4438c2ecf20Sopenharmony_ci}; 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_cistatic const struct samsung_pwm_variant s3c64xx_variant = { 4468c2ecf20Sopenharmony_ci .bits = 32, 4478c2ecf20Sopenharmony_ci .div_base = 0, 4488c2ecf20Sopenharmony_ci .has_tint_cstat = true, 4498c2ecf20Sopenharmony_ci .tclk_mask = BIT(7) | BIT(6) | BIT(5), 4508c2ecf20Sopenharmony_ci}; 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_cistatic const struct samsung_pwm_variant s5p64x0_variant = { 4538c2ecf20Sopenharmony_ci .bits = 32, 4548c2ecf20Sopenharmony_ci .div_base = 0, 4558c2ecf20Sopenharmony_ci .has_tint_cstat = true, 4568c2ecf20Sopenharmony_ci .tclk_mask = 0, 4578c2ecf20Sopenharmony_ci}; 4588c2ecf20Sopenharmony_ci 4598c2ecf20Sopenharmony_cistatic const struct samsung_pwm_variant s5pc100_variant = { 4608c2ecf20Sopenharmony_ci .bits = 32, 4618c2ecf20Sopenharmony_ci .div_base = 0, 4628c2ecf20Sopenharmony_ci .has_tint_cstat = true, 4638c2ecf20Sopenharmony_ci .tclk_mask = BIT(5), 4648c2ecf20Sopenharmony_ci}; 4658c2ecf20Sopenharmony_ci 4668c2ecf20Sopenharmony_cistatic const struct of_device_id samsung_pwm_matches[] = { 4678c2ecf20Sopenharmony_ci { .compatible = "samsung,s3c2410-pwm", .data = &s3c24xx_variant }, 4688c2ecf20Sopenharmony_ci { .compatible = "samsung,s3c6400-pwm", .data = &s3c64xx_variant }, 4698c2ecf20Sopenharmony_ci { .compatible = "samsung,s5p6440-pwm", .data = &s5p64x0_variant }, 4708c2ecf20Sopenharmony_ci { .compatible = "samsung,s5pc100-pwm", .data = &s5pc100_variant }, 4718c2ecf20Sopenharmony_ci { .compatible = "samsung,exynos4210-pwm", .data = &s5p64x0_variant }, 4728c2ecf20Sopenharmony_ci {}, 4738c2ecf20Sopenharmony_ci}; 4748c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, samsung_pwm_matches); 4758c2ecf20Sopenharmony_ci 4768c2ecf20Sopenharmony_cistatic int pwm_samsung_parse_dt(struct samsung_pwm_chip *chip) 4778c2ecf20Sopenharmony_ci{ 4788c2ecf20Sopenharmony_ci struct device_node *np = chip->chip.dev->of_node; 4798c2ecf20Sopenharmony_ci const struct of_device_id *match; 4808c2ecf20Sopenharmony_ci struct property *prop; 4818c2ecf20Sopenharmony_ci const __be32 *cur; 4828c2ecf20Sopenharmony_ci u32 val; 4838c2ecf20Sopenharmony_ci 4848c2ecf20Sopenharmony_ci match = of_match_node(samsung_pwm_matches, np); 4858c2ecf20Sopenharmony_ci if (!match) 4868c2ecf20Sopenharmony_ci return -ENODEV; 4878c2ecf20Sopenharmony_ci 4888c2ecf20Sopenharmony_ci memcpy(&chip->variant, match->data, sizeof(chip->variant)); 4898c2ecf20Sopenharmony_ci 4908c2ecf20Sopenharmony_ci of_property_for_each_u32(np, "samsung,pwm-outputs", prop, cur, val) { 4918c2ecf20Sopenharmony_ci if (val >= SAMSUNG_PWM_NUM) { 4928c2ecf20Sopenharmony_ci dev_err(chip->chip.dev, 4938c2ecf20Sopenharmony_ci "%s: invalid channel index in samsung,pwm-outputs property\n", 4948c2ecf20Sopenharmony_ci __func__); 4958c2ecf20Sopenharmony_ci continue; 4968c2ecf20Sopenharmony_ci } 4978c2ecf20Sopenharmony_ci chip->variant.output_mask |= BIT(val); 4988c2ecf20Sopenharmony_ci } 4998c2ecf20Sopenharmony_ci 5008c2ecf20Sopenharmony_ci return 0; 5018c2ecf20Sopenharmony_ci} 5028c2ecf20Sopenharmony_ci#else 5038c2ecf20Sopenharmony_cistatic int pwm_samsung_parse_dt(struct samsung_pwm_chip *chip) 5048c2ecf20Sopenharmony_ci{ 5058c2ecf20Sopenharmony_ci return -ENODEV; 5068c2ecf20Sopenharmony_ci} 5078c2ecf20Sopenharmony_ci#endif 5088c2ecf20Sopenharmony_ci 5098c2ecf20Sopenharmony_cistatic int pwm_samsung_probe(struct platform_device *pdev) 5108c2ecf20Sopenharmony_ci{ 5118c2ecf20Sopenharmony_ci struct device *dev = &pdev->dev; 5128c2ecf20Sopenharmony_ci struct samsung_pwm_chip *chip; 5138c2ecf20Sopenharmony_ci struct resource *res; 5148c2ecf20Sopenharmony_ci unsigned int chan; 5158c2ecf20Sopenharmony_ci int ret; 5168c2ecf20Sopenharmony_ci 5178c2ecf20Sopenharmony_ci chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL); 5188c2ecf20Sopenharmony_ci if (chip == NULL) 5198c2ecf20Sopenharmony_ci return -ENOMEM; 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_ci chip->chip.dev = &pdev->dev; 5228c2ecf20Sopenharmony_ci chip->chip.ops = &pwm_samsung_ops; 5238c2ecf20Sopenharmony_ci chip->chip.base = -1; 5248c2ecf20Sopenharmony_ci chip->chip.npwm = SAMSUNG_PWM_NUM; 5258c2ecf20Sopenharmony_ci chip->inverter_mask = BIT(SAMSUNG_PWM_NUM) - 1; 5268c2ecf20Sopenharmony_ci 5278c2ecf20Sopenharmony_ci if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) { 5288c2ecf20Sopenharmony_ci ret = pwm_samsung_parse_dt(chip); 5298c2ecf20Sopenharmony_ci if (ret) 5308c2ecf20Sopenharmony_ci return ret; 5318c2ecf20Sopenharmony_ci 5328c2ecf20Sopenharmony_ci chip->chip.of_xlate = of_pwm_xlate_with_flags; 5338c2ecf20Sopenharmony_ci chip->chip.of_pwm_n_cells = 3; 5348c2ecf20Sopenharmony_ci } else { 5358c2ecf20Sopenharmony_ci if (!pdev->dev.platform_data) { 5368c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "no platform data specified\n"); 5378c2ecf20Sopenharmony_ci return -EINVAL; 5388c2ecf20Sopenharmony_ci } 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_ci memcpy(&chip->variant, pdev->dev.platform_data, 5418c2ecf20Sopenharmony_ci sizeof(chip->variant)); 5428c2ecf20Sopenharmony_ci } 5438c2ecf20Sopenharmony_ci 5448c2ecf20Sopenharmony_ci res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 5458c2ecf20Sopenharmony_ci chip->base = devm_ioremap_resource(&pdev->dev, res); 5468c2ecf20Sopenharmony_ci if (IS_ERR(chip->base)) 5478c2ecf20Sopenharmony_ci return PTR_ERR(chip->base); 5488c2ecf20Sopenharmony_ci 5498c2ecf20Sopenharmony_ci chip->base_clk = devm_clk_get(&pdev->dev, "timers"); 5508c2ecf20Sopenharmony_ci if (IS_ERR(chip->base_clk)) { 5518c2ecf20Sopenharmony_ci dev_err(dev, "failed to get timer base clk\n"); 5528c2ecf20Sopenharmony_ci return PTR_ERR(chip->base_clk); 5538c2ecf20Sopenharmony_ci } 5548c2ecf20Sopenharmony_ci 5558c2ecf20Sopenharmony_ci ret = clk_prepare_enable(chip->base_clk); 5568c2ecf20Sopenharmony_ci if (ret < 0) { 5578c2ecf20Sopenharmony_ci dev_err(dev, "failed to enable base clock\n"); 5588c2ecf20Sopenharmony_ci return ret; 5598c2ecf20Sopenharmony_ci } 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_ci for (chan = 0; chan < SAMSUNG_PWM_NUM; ++chan) 5628c2ecf20Sopenharmony_ci if (chip->variant.output_mask & BIT(chan)) 5638c2ecf20Sopenharmony_ci pwm_samsung_set_invert(chip, chan, true); 5648c2ecf20Sopenharmony_ci 5658c2ecf20Sopenharmony_ci /* Following clocks are optional. */ 5668c2ecf20Sopenharmony_ci chip->tclk0 = devm_clk_get(&pdev->dev, "pwm-tclk0"); 5678c2ecf20Sopenharmony_ci chip->tclk1 = devm_clk_get(&pdev->dev, "pwm-tclk1"); 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_ci platform_set_drvdata(pdev, chip); 5708c2ecf20Sopenharmony_ci 5718c2ecf20Sopenharmony_ci ret = pwmchip_add(&chip->chip); 5728c2ecf20Sopenharmony_ci if (ret < 0) { 5738c2ecf20Sopenharmony_ci dev_err(dev, "failed to register PWM chip\n"); 5748c2ecf20Sopenharmony_ci clk_disable_unprepare(chip->base_clk); 5758c2ecf20Sopenharmony_ci return ret; 5768c2ecf20Sopenharmony_ci } 5778c2ecf20Sopenharmony_ci 5788c2ecf20Sopenharmony_ci dev_dbg(dev, "base_clk at %lu, tclk0 at %lu, tclk1 at %lu\n", 5798c2ecf20Sopenharmony_ci clk_get_rate(chip->base_clk), 5808c2ecf20Sopenharmony_ci !IS_ERR(chip->tclk0) ? clk_get_rate(chip->tclk0) : 0, 5818c2ecf20Sopenharmony_ci !IS_ERR(chip->tclk1) ? clk_get_rate(chip->tclk1) : 0); 5828c2ecf20Sopenharmony_ci 5838c2ecf20Sopenharmony_ci return 0; 5848c2ecf20Sopenharmony_ci} 5858c2ecf20Sopenharmony_ci 5868c2ecf20Sopenharmony_cistatic int pwm_samsung_remove(struct platform_device *pdev) 5878c2ecf20Sopenharmony_ci{ 5888c2ecf20Sopenharmony_ci struct samsung_pwm_chip *chip = platform_get_drvdata(pdev); 5898c2ecf20Sopenharmony_ci int ret; 5908c2ecf20Sopenharmony_ci 5918c2ecf20Sopenharmony_ci ret = pwmchip_remove(&chip->chip); 5928c2ecf20Sopenharmony_ci if (ret < 0) 5938c2ecf20Sopenharmony_ci return ret; 5948c2ecf20Sopenharmony_ci 5958c2ecf20Sopenharmony_ci clk_disable_unprepare(chip->base_clk); 5968c2ecf20Sopenharmony_ci 5978c2ecf20Sopenharmony_ci return 0; 5988c2ecf20Sopenharmony_ci} 5998c2ecf20Sopenharmony_ci 6008c2ecf20Sopenharmony_ci#ifdef CONFIG_PM_SLEEP 6018c2ecf20Sopenharmony_cistatic int pwm_samsung_resume(struct device *dev) 6028c2ecf20Sopenharmony_ci{ 6038c2ecf20Sopenharmony_ci struct samsung_pwm_chip *our_chip = dev_get_drvdata(dev); 6048c2ecf20Sopenharmony_ci struct pwm_chip *chip = &our_chip->chip; 6058c2ecf20Sopenharmony_ci unsigned int i; 6068c2ecf20Sopenharmony_ci 6078c2ecf20Sopenharmony_ci for (i = 0; i < SAMSUNG_PWM_NUM; i++) { 6088c2ecf20Sopenharmony_ci struct pwm_device *pwm = &chip->pwms[i]; 6098c2ecf20Sopenharmony_ci struct samsung_pwm_channel *chan = pwm_get_chip_data(pwm); 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_ci if (!chan) 6128c2ecf20Sopenharmony_ci continue; 6138c2ecf20Sopenharmony_ci 6148c2ecf20Sopenharmony_ci if (our_chip->variant.output_mask & BIT(i)) 6158c2ecf20Sopenharmony_ci pwm_samsung_set_invert(our_chip, i, 6168c2ecf20Sopenharmony_ci our_chip->inverter_mask & BIT(i)); 6178c2ecf20Sopenharmony_ci 6188c2ecf20Sopenharmony_ci if (chan->period_ns) { 6198c2ecf20Sopenharmony_ci __pwm_samsung_config(chip, pwm, chan->duty_ns, 6208c2ecf20Sopenharmony_ci chan->period_ns, true); 6218c2ecf20Sopenharmony_ci /* needed to make PWM disable work on Odroid-XU3 */ 6228c2ecf20Sopenharmony_ci pwm_samsung_manual_update(our_chip, pwm); 6238c2ecf20Sopenharmony_ci } 6248c2ecf20Sopenharmony_ci 6258c2ecf20Sopenharmony_ci if (our_chip->disabled_mask & BIT(i)) 6268c2ecf20Sopenharmony_ci pwm_samsung_disable(chip, pwm); 6278c2ecf20Sopenharmony_ci else 6288c2ecf20Sopenharmony_ci pwm_samsung_enable(chip, pwm); 6298c2ecf20Sopenharmony_ci } 6308c2ecf20Sopenharmony_ci 6318c2ecf20Sopenharmony_ci return 0; 6328c2ecf20Sopenharmony_ci} 6338c2ecf20Sopenharmony_ci#endif 6348c2ecf20Sopenharmony_ci 6358c2ecf20Sopenharmony_cistatic SIMPLE_DEV_PM_OPS(pwm_samsung_pm_ops, NULL, pwm_samsung_resume); 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_cistatic struct platform_driver pwm_samsung_driver = { 6388c2ecf20Sopenharmony_ci .driver = { 6398c2ecf20Sopenharmony_ci .name = "samsung-pwm", 6408c2ecf20Sopenharmony_ci .pm = &pwm_samsung_pm_ops, 6418c2ecf20Sopenharmony_ci .of_match_table = of_match_ptr(samsung_pwm_matches), 6428c2ecf20Sopenharmony_ci }, 6438c2ecf20Sopenharmony_ci .probe = pwm_samsung_probe, 6448c2ecf20Sopenharmony_ci .remove = pwm_samsung_remove, 6458c2ecf20Sopenharmony_ci}; 6468c2ecf20Sopenharmony_cimodule_platform_driver(pwm_samsung_driver); 6478c2ecf20Sopenharmony_ci 6488c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 6498c2ecf20Sopenharmony_ciMODULE_AUTHOR("Tomasz Figa <tomasz.figa@gmail.com>"); 6508c2ecf20Sopenharmony_ciMODULE_ALIAS("platform:samsung-pwm"); 651