#include <linux/module.h>
#include <linux/platform_device.h>
static inline struct clps711x_chip *to_clps711x_chip(struct pwm_chip *chip)
return container_of(chip, struct clps711x_chip, chip);
static void clps711x_pwm_update_val(struct clps711x_chip *priv, u32 n, u32 v)
spin_lock_irqsave(&priv->lock, flags);
tmp = readl(priv->pmpcon);
writel(tmp, priv->pmpcon);
spin_unlock_irqrestore(&priv->lock, flags);
static unsigned int clps711x_get_duty(struct pwm_device *pwm, unsigned int v)
return DIV_ROUND_CLOSEST(v * 0xf, pwm->args.period);
static int clps711x_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
struct clps711x_chip *priv = to_clps711x_chip(chip);
unsigned int freq = clk_get_rate(priv->clk);
pwm->args.period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, freq);
static int clps711x_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,