mirror of
https://github.com/armbian/linux-cix.git
synced 2026-01-06 12:30:45 -08:00
Merge tag 'pwm/for-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm
Pull pwm updates from Thierry Reding: "Various changes across the board, mostly improvements and cleanups" * tag 'pwm/for-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: (42 commits) pwm: pca9685: Convert to i2c's .probe_new() pwm: sun4i: Propagate errors in .get_state() to the caller pwm: Handle .get_state() failures pwm: sprd: Propagate errors in .get_state() to the caller pwm: rockchip: Propagate errors in .get_state() to the caller pwm: mtk-disp: Propagate errors in .get_state() to the caller pwm: imx27: Propagate errors in .get_state() to the caller pwm: cros-ec: Propagate errors in .get_state() to the caller pwm: crc: Propagate errors in .get_state() to the caller leds: qcom-lpg: Propagate errors in .get_state() to the caller drm/bridge: ti-sn65dsi86: Propagate errors in .get_state() to the caller pwm/tracing: Also record trace events for failed API calls pwm: Make .get_state() callback return an error code pwm: pxa: Enable for MMP platform pwm: pxa: Add reference manual link and limitations pwm: pxa: Use abrupt shutdown mode pwm: pxa: Remove clk enable/disable from pxa_pwm_config pwm: pxa: Set duty cycle to 0 when disabling PWM pwm: pxa: Remove pxa_pwm_enable/disable pwm: mediatek: Add support for MT7986 ...
This commit is contained in:
@@ -35,6 +35,7 @@ properties:
|
||||
- renesas,pwm-r8a77980 # R-Car V3H
|
||||
- renesas,pwm-r8a77990 # R-Car E3
|
||||
- renesas,pwm-r8a77995 # R-Car D3
|
||||
- renesas,pwm-r8a779g0 # R-Car V4H
|
||||
- const: renesas,pwm-rcar
|
||||
|
||||
reg:
|
||||
|
||||
@@ -40,6 +40,7 @@ properties:
|
||||
- renesas,tpu-r8a77970 # R-Car V3M
|
||||
- renesas,tpu-r8a77980 # R-Car V3H
|
||||
- renesas,tpu-r8a779a0 # R-Car V3U
|
||||
- renesas,tpu-r8a779g0 # R-Car V4H
|
||||
- const: renesas,tpu
|
||||
|
||||
reg:
|
||||
|
||||
@@ -657,9 +657,10 @@ static void mvebu_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
|
||||
spin_unlock_irqrestore(&mvpwm->lock, flags);
|
||||
}
|
||||
|
||||
static void mvebu_pwm_get_state(struct pwm_chip *chip,
|
||||
struct pwm_device *pwm,
|
||||
struct pwm_state *state) {
|
||||
static int mvebu_pwm_get_state(struct pwm_chip *chip,
|
||||
struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
{
|
||||
|
||||
struct mvebu_pwm *mvpwm = to_mvebu_pwm(chip);
|
||||
struct mvebu_gpio_chip *mvchip = mvpwm->mvchip;
|
||||
@@ -693,6 +694,8 @@ static void mvebu_pwm_get_state(struct pwm_chip *chip,
|
||||
state->enabled = false;
|
||||
|
||||
spin_unlock_irqrestore(&mvpwm->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mvebu_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
|
||||
@@ -1500,8 +1500,8 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void ti_sn_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
static int ti_sn_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
{
|
||||
struct ti_sn65dsi86 *pdata = pwm_chip_to_ti_sn_bridge(chip);
|
||||
unsigned int pwm_en_inv;
|
||||
@@ -1512,19 +1512,19 @@ static void ti_sn_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
|
||||
ret = regmap_read(pdata->regmap, SN_PWM_EN_INV_REG, &pwm_en_inv);
|
||||
if (ret)
|
||||
return;
|
||||
return ret;
|
||||
|
||||
ret = ti_sn65dsi86_read_u16(pdata, SN_BACKLIGHT_SCALE_REG, &scale);
|
||||
if (ret)
|
||||
return;
|
||||
return ret;
|
||||
|
||||
ret = ti_sn65dsi86_read_u16(pdata, SN_BACKLIGHT_REG, &backlight);
|
||||
if (ret)
|
||||
return;
|
||||
return ret;
|
||||
|
||||
ret = regmap_read(pdata->regmap, SN_PWM_PRE_DIV_REG, &pre_div);
|
||||
if (ret)
|
||||
return;
|
||||
return ret;
|
||||
|
||||
state->enabled = FIELD_GET(SN_PWM_EN_MASK, pwm_en_inv);
|
||||
if (FIELD_GET(SN_PWM_INV_MASK, pwm_en_inv))
|
||||
@@ -1539,6 +1539,8 @@ static void ti_sn_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
|
||||
if (state->duty_cycle > state->period)
|
||||
state->duty_cycle = state->period;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct pwm_ops ti_sn_pwm_ops = {
|
||||
|
||||
@@ -972,8 +972,8 @@ out_unlock:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
static int lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
{
|
||||
struct lpg *lpg = container_of(chip, struct lpg, pwm);
|
||||
struct lpg_channel *chan = &lpg->channels[pwm->hwpwm];
|
||||
@@ -986,20 +986,20 @@ static void lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
|
||||
ret = regmap_read(lpg->map, chan->base + LPG_SIZE_CLK_REG, &val);
|
||||
if (ret)
|
||||
return;
|
||||
return ret;
|
||||
|
||||
refclk = lpg_clk_rates[val & PWM_CLK_SELECT_MASK];
|
||||
if (refclk) {
|
||||
ret = regmap_read(lpg->map, chan->base + LPG_PREDIV_CLK_REG, &val);
|
||||
if (ret)
|
||||
return;
|
||||
return ret;
|
||||
|
||||
pre_div = lpg_pre_divs[FIELD_GET(PWM_FREQ_PRE_DIV_MASK, val)];
|
||||
m = FIELD_GET(PWM_FREQ_EXP_MASK, val);
|
||||
|
||||
ret = regmap_bulk_read(lpg->map, chan->base + PWM_VALUE_REG, &pwm_value, sizeof(pwm_value));
|
||||
if (ret)
|
||||
return;
|
||||
return ret;
|
||||
|
||||
state->period = DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC * LPG_RESOLUTION * pre_div * (1 << m), refclk);
|
||||
state->duty_cycle = DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC * pwm_value * pre_div * (1 << m), refclk);
|
||||
@@ -1010,13 +1010,15 @@ static void lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
|
||||
ret = regmap_read(lpg->map, chan->base + PWM_ENABLE_CONTROL_REG, &val);
|
||||
if (ret)
|
||||
return;
|
||||
return ret;
|
||||
|
||||
state->enabled = FIELD_GET(LPG_ENABLE_CONTROL_OUTPUT, val);
|
||||
state->polarity = PWM_POLARITY_NORMAL;
|
||||
|
||||
if (state->duty_cycle > state->period)
|
||||
state->duty_cycle = state->period;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct pwm_ops lpg_pwm_ops = {
|
||||
|
||||
@@ -282,8 +282,8 @@ config PWM_IQS620A
|
||||
|
||||
config PWM_JZ4740
|
||||
tristate "Ingenic JZ47xx PWM support"
|
||||
depends on MIPS || COMPILE_TEST
|
||||
depends on COMMON_CLK
|
||||
depends on MACH_INGENIC || COMPILE_TEST
|
||||
depends on COMMON_CLK && OF
|
||||
select MFD_SYSCON
|
||||
help
|
||||
Generic PWM framework driver for Ingenic JZ47xx based
|
||||
@@ -434,7 +434,7 @@ config PWM_PCA9685
|
||||
|
||||
config PWM_PXA
|
||||
tristate "PXA PWM support"
|
||||
depends on ARCH_PXA || COMPILE_TEST
|
||||
depends on ARCH_PXA || ARCH_MMP || COMPILE_TEST
|
||||
depends on HAS_IOMEM
|
||||
help
|
||||
Generic PWM framework driver for PXA.
|
||||
|
||||
@@ -27,7 +27,10 @@
|
||||
|
||||
static DEFINE_MUTEX(pwm_lookup_lock);
|
||||
static LIST_HEAD(pwm_lookup_list);
|
||||
|
||||
/* protects access to pwm_chips, allocated_pwms, and pwm_tree */
|
||||
static DEFINE_MUTEX(pwm_lock);
|
||||
|
||||
static LIST_HEAD(pwm_chips);
|
||||
static DECLARE_BITMAP(allocated_pwms, MAX_PWMS);
|
||||
static RADIX_TREE(pwm_tree, GFP_KERNEL);
|
||||
@@ -37,6 +40,7 @@ static struct pwm_device *pwm_to_device(unsigned int pwm)
|
||||
return radix_tree_lookup(&pwm_tree, pwm);
|
||||
}
|
||||
|
||||
/* Called with pwm_lock held */
|
||||
static int alloc_pwms(unsigned int count)
|
||||
{
|
||||
unsigned int start;
|
||||
@@ -47,9 +51,12 @@ static int alloc_pwms(unsigned int count)
|
||||
if (start + count > MAX_PWMS)
|
||||
return -ENOSPC;
|
||||
|
||||
bitmap_set(allocated_pwms, start, count);
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
/* Called with pwm_lock held */
|
||||
static void free_pwms(struct pwm_chip *chip)
|
||||
{
|
||||
unsigned int i;
|
||||
@@ -108,8 +115,13 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label)
|
||||
}
|
||||
|
||||
if (pwm->chip->ops->get_state) {
|
||||
pwm->chip->ops->get_state(pwm->chip, pwm, &pwm->state);
|
||||
trace_pwm_get(pwm, &pwm->state);
|
||||
struct pwm_state state;
|
||||
|
||||
err = pwm->chip->ops->get_state(pwm->chip, pwm, &state);
|
||||
trace_pwm_get(pwm, &state, err);
|
||||
|
||||
if (!err)
|
||||
pwm->state = state;
|
||||
|
||||
if (IS_ENABLED(CONFIG_PWM_DEBUG))
|
||||
pwm->last = pwm->state;
|
||||
@@ -267,20 +279,21 @@ int pwmchip_add(struct pwm_chip *chip)
|
||||
if (!pwm_ops_check(chip))
|
||||
return -EINVAL;
|
||||
|
||||
chip->pwms = kcalloc(chip->npwm, sizeof(*pwm), GFP_KERNEL);
|
||||
if (!chip->pwms)
|
||||
return -ENOMEM;
|
||||
|
||||
mutex_lock(&pwm_lock);
|
||||
|
||||
ret = alloc_pwms(chip->npwm);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
if (ret < 0) {
|
||||
mutex_unlock(&pwm_lock);
|
||||
kfree(chip->pwms);
|
||||
return ret;
|
||||
}
|
||||
|
||||
chip->base = ret;
|
||||
|
||||
chip->pwms = kcalloc(chip->npwm, sizeof(*pwm), GFP_KERNEL);
|
||||
if (!chip->pwms) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (i = 0; i < chip->npwm; i++) {
|
||||
pwm = &chip->pwms[i];
|
||||
|
||||
@@ -291,23 +304,16 @@ int pwmchip_add(struct pwm_chip *chip)
|
||||
radix_tree_insert(&pwm_tree, pwm->pwm, pwm);
|
||||
}
|
||||
|
||||
bitmap_set(allocated_pwms, chip->base, chip->npwm);
|
||||
|
||||
INIT_LIST_HEAD(&chip->list);
|
||||
list_add(&chip->list, &pwm_chips);
|
||||
|
||||
ret = 0;
|
||||
mutex_unlock(&pwm_lock);
|
||||
|
||||
if (IS_ENABLED(CONFIG_OF))
|
||||
of_pwmchip_add(chip);
|
||||
|
||||
out:
|
||||
mutex_unlock(&pwm_lock);
|
||||
pwmchip_sysfs_export(chip);
|
||||
|
||||
if (!ret)
|
||||
pwmchip_sysfs_export(chip);
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pwmchip_add);
|
||||
|
||||
@@ -457,8 +463,11 @@ static void pwm_apply_state_debug(struct pwm_device *pwm,
|
||||
* checks.
|
||||
*/
|
||||
|
||||
chip->ops->get_state(chip, pwm, &s1);
|
||||
trace_pwm_get(pwm, &s1);
|
||||
err = chip->ops->get_state(chip, pwm, &s1);
|
||||
trace_pwm_get(pwm, &s1, err);
|
||||
if (err)
|
||||
/* If that failed there isn't much to debug */
|
||||
return;
|
||||
|
||||
/*
|
||||
* The lowlevel driver either ignored .polarity (which is a bug) or as
|
||||
@@ -514,16 +523,17 @@ static void pwm_apply_state_debug(struct pwm_device *pwm,
|
||||
|
||||
/* reapply the state that the driver reported being configured. */
|
||||
err = chip->ops->apply(chip, pwm, &s1);
|
||||
trace_pwm_apply(pwm, &s1, err);
|
||||
if (err) {
|
||||
*last = s1;
|
||||
dev_err(chip->dev, "failed to reapply current setting\n");
|
||||
return;
|
||||
}
|
||||
|
||||
trace_pwm_apply(pwm, &s1);
|
||||
|
||||
chip->ops->get_state(chip, pwm, last);
|
||||
trace_pwm_get(pwm, last);
|
||||
err = chip->ops->get_state(chip, pwm, last);
|
||||
trace_pwm_get(pwm, last, err);
|
||||
if (err)
|
||||
return;
|
||||
|
||||
/* reapplication of the current state should give an exact match */
|
||||
if (s1.enabled != last->enabled ||
|
||||
@@ -571,11 +581,10 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state)
|
||||
return 0;
|
||||
|
||||
err = chip->ops->apply(chip, pwm, state);
|
||||
trace_pwm_apply(pwm, state, err);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
trace_pwm_apply(pwm, state);
|
||||
|
||||
pwm->state = *state;
|
||||
|
||||
/*
|
||||
@@ -1179,8 +1188,7 @@ DEFINE_SEQ_ATTRIBUTE(pwm_debugfs);
|
||||
|
||||
static int __init pwm_debugfs_init(void)
|
||||
{
|
||||
debugfs_create_file("pwm", S_IFREG | 0444, NULL, NULL,
|
||||
&pwm_debugfs_fops);
|
||||
debugfs_create_file("pwm", 0444, NULL, NULL, &pwm_debugfs_fops);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -356,8 +356,8 @@ static int atmel_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void atmel_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
static int atmel_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
{
|
||||
struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip);
|
||||
u32 sr, cmr;
|
||||
@@ -396,6 +396,8 @@ static void atmel_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
state->polarity = PWM_POLARITY_INVERSED;
|
||||
else
|
||||
state->polarity = PWM_POLARITY_NORMAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct pwm_ops atmel_pwm_ops = {
|
||||
|
||||
@@ -68,8 +68,8 @@ static void iproc_pwmc_disable(struct iproc_pwmc *ip, unsigned int channel)
|
||||
ndelay(400);
|
||||
}
|
||||
|
||||
static void iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
static int iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
{
|
||||
struct iproc_pwmc *ip = to_iproc_pwmc(chip);
|
||||
u64 tmp, multi, rate;
|
||||
@@ -91,7 +91,7 @@ static void iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
if (rate == 0) {
|
||||
state->period = 0;
|
||||
state->duty_cycle = 0;
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
value = readl(ip->base + IPROC_PWM_PRESCALE_OFFSET);
|
||||
@@ -107,6 +107,8 @@ static void iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
value = readl(ip->base + IPROC_PWM_DUTY_CYCLE_OFFSET(pwm->hwpwm));
|
||||
tmp = (value & IPROC_PWM_PERIOD_MAX) * multi;
|
||||
state->duty_cycle = div64_u64(tmp, rate);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iproc_pwmc_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
|
||||
@@ -121,8 +121,8 @@ static int crc_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void crc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
static int crc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
{
|
||||
struct crystalcove_pwm *crc_pwm = to_crc_pwm(chip);
|
||||
struct device *dev = crc_pwm->chip.dev;
|
||||
@@ -132,13 +132,13 @@ static void crc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
error = regmap_read(crc_pwm->regmap, PWM0_CLK_DIV, &clk_div_reg);
|
||||
if (error) {
|
||||
dev_err(dev, "Error reading PWM0_CLK_DIV %d\n", error);
|
||||
return;
|
||||
return error;
|
||||
}
|
||||
|
||||
error = regmap_read(crc_pwm->regmap, PWM0_DUTY_CYCLE, &duty_cycle_reg);
|
||||
if (error) {
|
||||
dev_err(dev, "Error reading PWM0_DUTY_CYCLE %d\n", error);
|
||||
return;
|
||||
return error;
|
||||
}
|
||||
|
||||
clk_div = (clk_div_reg & ~PWM_OUTPUT_ENABLE) + 1;
|
||||
@@ -149,6 +149,8 @@ static void crc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
DIV_ROUND_UP_ULL(duty_cycle_reg * state->period, PWM_MAX_LEVEL);
|
||||
state->polarity = PWM_POLARITY_NORMAL;
|
||||
state->enabled = !!(clk_div_reg & PWM_OUTPUT_ENABLE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct pwm_ops crc_pwm_ops = {
|
||||
|
||||
@@ -183,8 +183,8 @@ static int cros_ec_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
static int cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
{
|
||||
struct cros_ec_pwm_device *ec_pwm = pwm_to_cros_ec_pwm(chip);
|
||||
struct cros_ec_pwm *channel = pwm_get_chip_data(pwm);
|
||||
@@ -193,7 +193,7 @@ static void cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
ret = cros_ec_pwm_get_duty(ec_pwm, pwm->hwpwm);
|
||||
if (ret < 0) {
|
||||
dev_err(chip->dev, "error getting initial duty: %d\n", ret);
|
||||
return;
|
||||
return ret;
|
||||
}
|
||||
|
||||
state->enabled = (ret > 0);
|
||||
@@ -212,6 +212,8 @@ static void cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
state->duty_cycle = channel->duty_cycle;
|
||||
else
|
||||
state->duty_cycle = ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct pwm_device *
|
||||
|
||||
@@ -163,8 +163,8 @@ static int dwc_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dwc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
static int dwc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
{
|
||||
struct dwc_pwm *dwc = to_dwc_pwm(chip);
|
||||
u64 duty, period;
|
||||
@@ -188,6 +188,8 @@ static void dwc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
state->polarity = PWM_POLARITY_INVERSED;
|
||||
|
||||
pm_runtime_put_sync(chip->dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct pwm_ops dwc_pwm_ops = {
|
||||
|
||||
@@ -65,13 +65,12 @@ static void ftm_clear_write_protection(struct fsl_pwm_chip *fpc)
|
||||
|
||||
regmap_read(fpc->regmap, FTM_FMS, &val);
|
||||
if (val & FTM_FMS_WPEN)
|
||||
regmap_update_bits(fpc->regmap, FTM_MODE, FTM_MODE_WPDIS,
|
||||
FTM_MODE_WPDIS);
|
||||
regmap_set_bits(fpc->regmap, FTM_MODE, FTM_MODE_WPDIS);
|
||||
}
|
||||
|
||||
static void ftm_set_write_protection(struct fsl_pwm_chip *fpc)
|
||||
{
|
||||
regmap_update_bits(fpc->regmap, FTM_FMS, FTM_FMS_WPEN, FTM_FMS_WPEN);
|
||||
regmap_set_bits(fpc->regmap, FTM_FMS, FTM_FMS_WPEN);
|
||||
}
|
||||
|
||||
static bool fsl_pwm_periodcfg_are_equal(const struct fsl_pwm_periodcfg *a,
|
||||
@@ -94,8 +93,7 @@ static int fsl_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
|
||||
ret = clk_prepare_enable(fpc->ipg_clk);
|
||||
if (!ret && fpc->soc->has_enable_bits) {
|
||||
mutex_lock(&fpc->lock);
|
||||
regmap_update_bits(fpc->regmap, FTM_SC, BIT(pwm->hwpwm + 16),
|
||||
BIT(pwm->hwpwm + 16));
|
||||
regmap_set_bits(fpc->regmap, FTM_SC, BIT(pwm->hwpwm + 16));
|
||||
mutex_unlock(&fpc->lock);
|
||||
}
|
||||
|
||||
@@ -108,8 +106,7 @@ static void fsl_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
|
||||
|
||||
if (fpc->soc->has_enable_bits) {
|
||||
mutex_lock(&fpc->lock);
|
||||
regmap_update_bits(fpc->regmap, FTM_SC, BIT(pwm->hwpwm + 16),
|
||||
0);
|
||||
regmap_clear_bits(fpc->regmap, FTM_SC, BIT(pwm->hwpwm + 16));
|
||||
mutex_unlock(&fpc->lock);
|
||||
}
|
||||
|
||||
@@ -317,8 +314,8 @@ static int fsl_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
|
||||
if (!newstate->enabled) {
|
||||
if (oldstate->enabled) {
|
||||
regmap_update_bits(fpc->regmap, FTM_OUTMASK,
|
||||
BIT(pwm->hwpwm), BIT(pwm->hwpwm));
|
||||
regmap_set_bits(fpc->regmap, FTM_OUTMASK,
|
||||
BIT(pwm->hwpwm));
|
||||
clk_disable_unprepare(fpc->clk[FSL_PWM_CLK_CNTEN]);
|
||||
clk_disable_unprepare(fpc->clk[fpc->period.clk_select]);
|
||||
}
|
||||
@@ -342,8 +339,7 @@ static int fsl_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
goto end_mutex;
|
||||
}
|
||||
|
||||
regmap_update_bits(fpc->regmap, FTM_OUTMASK, BIT(pwm->hwpwm),
|
||||
0);
|
||||
regmap_clear_bits(fpc->regmap, FTM_OUTMASK, BIT(pwm->hwpwm));
|
||||
}
|
||||
|
||||
end_mutex:
|
||||
|
||||
@@ -128,8 +128,8 @@ static void hibvt_pwm_set_polarity(struct pwm_chip *chip,
|
||||
PWM_POLARITY_MASK, (0x0 << PWM_POLARITY_SHIFT));
|
||||
}
|
||||
|
||||
static void hibvt_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
static int hibvt_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
{
|
||||
struct hibvt_pwm_chip *hi_pwm_chip = to_hibvt_pwm_chip(chip);
|
||||
void __iomem *base;
|
||||
@@ -146,6 +146,8 @@ static void hibvt_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
|
||||
value = readl(base + PWM_CTRL_ADDR(pwm->hwpwm));
|
||||
state->enabled = (PWM_ENABLE_MASK & value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hibvt_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
|
||||
@@ -161,9 +161,9 @@ static int img_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
|
||||
val |= BIT(pwm->hwpwm);
|
||||
img_pwm_writel(imgchip, PWM_CTRL_CFG, val);
|
||||
|
||||
regmap_update_bits(imgchip->periph_regs, PERIP_PWM_PDM_CONTROL,
|
||||
PERIP_PWM_PDM_CONTROL_CH_MASK <<
|
||||
PERIP_PWM_PDM_CONTROL_CH_SHIFT(pwm->hwpwm), 0);
|
||||
regmap_clear_bits(imgchip->periph_regs, PERIP_PWM_PDM_CONTROL,
|
||||
PERIP_PWM_PDM_CONTROL_CH_MASK <<
|
||||
PERIP_PWM_PDM_CONTROL_CH_SHIFT(pwm->hwpwm));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -397,11 +397,10 @@ static int img_pwm_resume(struct device *dev)
|
||||
|
||||
for (i = 0; i < imgchip->chip.npwm; i++)
|
||||
if (imgchip->suspend_ctrl_cfg & BIT(i))
|
||||
regmap_update_bits(imgchip->periph_regs,
|
||||
PERIP_PWM_PDM_CONTROL,
|
||||
PERIP_PWM_PDM_CONTROL_CH_MASK <<
|
||||
PERIP_PWM_PDM_CONTROL_CH_SHIFT(i),
|
||||
0);
|
||||
regmap_clear_bits(imgchip->periph_regs,
|
||||
PERIP_PWM_PDM_CONTROL,
|
||||
PERIP_PWM_PDM_CONTROL_CH_MASK <<
|
||||
PERIP_PWM_PDM_CONTROL_CH_SHIFT(i));
|
||||
|
||||
if (pm_runtime_status_suspended(dev))
|
||||
img_pwm_runtime_suspend(dev);
|
||||
|
||||
@@ -132,9 +132,9 @@ static int pwm_imx_tpm_round_state(struct pwm_chip *chip,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pwm_imx_tpm_get_state(struct pwm_chip *chip,
|
||||
struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
static int pwm_imx_tpm_get_state(struct pwm_chip *chip,
|
||||
struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
{
|
||||
struct imx_tpm_pwm_chip *tpm = to_imx_tpm_pwm_chip(chip);
|
||||
u32 rate, val, prescale;
|
||||
@@ -164,6 +164,8 @@ static void pwm_imx_tpm_get_state(struct pwm_chip *chip,
|
||||
|
||||
/* get channel status */
|
||||
state->enabled = FIELD_GET(PWM_IMX_TPM_CnSC_ELS, val) ? true : false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* this function is supposed to be called with mutex hold */
|
||||
|
||||
@@ -118,8 +118,8 @@ static void pwm_imx27_clk_disable_unprepare(struct pwm_imx27_chip *imx)
|
||||
clk_disable_unprepare(imx->clk_ipg);
|
||||
}
|
||||
|
||||
static void pwm_imx27_get_state(struct pwm_chip *chip,
|
||||
struct pwm_device *pwm, struct pwm_state *state)
|
||||
static int pwm_imx27_get_state(struct pwm_chip *chip,
|
||||
struct pwm_device *pwm, struct pwm_state *state)
|
||||
{
|
||||
struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip);
|
||||
u32 period, prescaler, pwm_clk, val;
|
||||
@@ -128,7 +128,7 @@ static void pwm_imx27_get_state(struct pwm_chip *chip,
|
||||
|
||||
ret = pwm_imx27_clk_prepare_enable(imx);
|
||||
if (ret < 0)
|
||||
return;
|
||||
return ret;
|
||||
|
||||
val = readl(imx->mmio_base + MX3_PWMCR);
|
||||
|
||||
@@ -170,6 +170,8 @@ static void pwm_imx27_get_state(struct pwm_chip *chip,
|
||||
state->duty_cycle = DIV_ROUND_UP_ULL(tmp, pwm_clk);
|
||||
|
||||
pwm_imx27_clk_disable_unprepare(imx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pwm_imx27_sw_reset(struct pwm_chip *chip)
|
||||
|
||||
@@ -86,8 +86,8 @@ static int lgm_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
return lgm_pwm_enable(chip, 1);
|
||||
}
|
||||
|
||||
static void lgm_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
static int lgm_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
{
|
||||
struct lgm_pwm_chip *pc = to_lgm_pwm_chip(chip);
|
||||
u32 duty, val;
|
||||
@@ -100,6 +100,8 @@ static void lgm_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
regmap_read(pc->regmap, LGM_PWM_FAN_CON0, &val);
|
||||
duty = FIELD_GET(LGM_PWM_FAN_DC_MSK, val);
|
||||
state->duty_cycle = DIV_ROUND_UP(duty * pc->period, LGM_PWM_MAX_DUTY_CYCLE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct pwm_ops lgm_pwm_ops = {
|
||||
|
||||
@@ -47,8 +47,8 @@ static int iqs620_pwm_init(struct iqs620_pwm_private *iqs620_pwm,
|
||||
int ret;
|
||||
|
||||
if (!duty_scale)
|
||||
return regmap_update_bits(iqs62x->regmap, IQS620_PWR_SETTINGS,
|
||||
IQS620_PWR_SETTINGS_PWM_OUT, 0);
|
||||
return regmap_clear_bits(iqs62x->regmap, IQS620_PWR_SETTINGS,
|
||||
IQS620_PWR_SETTINGS_PWM_OUT);
|
||||
|
||||
ret = regmap_write(iqs62x->regmap, IQS620_PWM_DUTY_CYCLE,
|
||||
duty_scale - 1);
|
||||
@@ -104,8 +104,8 @@ static int iqs620_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void iqs620_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
static int iqs620_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
{
|
||||
struct iqs620_pwm_private *iqs620_pwm;
|
||||
|
||||
@@ -126,6 +126,8 @@ static void iqs620_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
mutex_unlock(&iqs620_pwm->lock);
|
||||
|
||||
state->period = IQS620_PWM_PERIOD_NS;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iqs620_pwm_notifier(struct notifier_block *notifier,
|
||||
|
||||
@@ -88,8 +88,7 @@ static int jz4740_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
|
||||
struct jz4740_pwm_chip *jz = to_jz4740(chip);
|
||||
|
||||
/* Enable PWM output */
|
||||
regmap_update_bits(jz->map, TCU_REG_TCSRc(pwm->hwpwm),
|
||||
TCU_TCSR_PWM_EN, TCU_TCSR_PWM_EN);
|
||||
regmap_set_bits(jz->map, TCU_REG_TCSRc(pwm->hwpwm), TCU_TCSR_PWM_EN);
|
||||
|
||||
/* Start counter */
|
||||
regmap_write(jz->map, TCU_REG_TESR, BIT(pwm->hwpwm));
|
||||
@@ -113,8 +112,7 @@ static void jz4740_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
|
||||
* In TCU2 mode (channel 1/2 on JZ4750+), this must be done before the
|
||||
* counter is stopped, while in TCU1 mode the order does not matter.
|
||||
*/
|
||||
regmap_update_bits(jz->map, TCU_REG_TCSRc(pwm->hwpwm),
|
||||
TCU_TCSR_PWM_EN, 0);
|
||||
regmap_clear_bits(jz->map, TCU_REG_TCSRc(pwm->hwpwm), TCU_TCSR_PWM_EN);
|
||||
|
||||
/* Stop counter */
|
||||
regmap_write(jz->map, TCU_REG_TECR, BIT(pwm->hwpwm));
|
||||
@@ -184,8 +182,8 @@ static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
regmap_write(jz4740->map, TCU_REG_TDFRc(pwm->hwpwm), period);
|
||||
|
||||
/* Set abrupt shutdown */
|
||||
regmap_update_bits(jz4740->map, TCU_REG_TCSRc(pwm->hwpwm),
|
||||
TCU_TCSR_PWM_SD, TCU_TCSR_PWM_SD);
|
||||
regmap_set_bits(jz4740->map, TCU_REG_TCSRc(pwm->hwpwm),
|
||||
TCU_TCSR_PWM_SD);
|
||||
|
||||
/*
|
||||
* Set polarity.
|
||||
@@ -248,19 +246,18 @@ static int jz4740_pwm_probe(struct platform_device *pdev)
|
||||
return devm_pwmchip_add(dev, &jz4740->chip);
|
||||
}
|
||||
|
||||
static const struct soc_info __maybe_unused jz4740_soc_info = {
|
||||
static const struct soc_info jz4740_soc_info = {
|
||||
.num_pwms = 8,
|
||||
};
|
||||
|
||||
static const struct soc_info __maybe_unused jz4725b_soc_info = {
|
||||
static const struct soc_info jz4725b_soc_info = {
|
||||
.num_pwms = 6,
|
||||
};
|
||||
|
||||
static const struct soc_info __maybe_unused x1000_soc_info = {
|
||||
static const struct soc_info x1000_soc_info = {
|
||||
.num_pwms = 5,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static const struct of_device_id jz4740_pwm_dt_ids[] = {
|
||||
{ .compatible = "ingenic,jz4740-pwm", .data = &jz4740_soc_info },
|
||||
{ .compatible = "ingenic,jz4725b-pwm", .data = &jz4725b_soc_info },
|
||||
@@ -268,12 +265,11 @@ static const struct of_device_id jz4740_pwm_dt_ids[] = {
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, jz4740_pwm_dt_ids);
|
||||
#endif
|
||||
|
||||
static struct platform_driver jz4740_pwm_driver = {
|
||||
.driver = {
|
||||
.name = "jz4740-pwm",
|
||||
.of_match_table = of_match_ptr(jz4740_pwm_dt_ids),
|
||||
.of_match_table = jz4740_pwm_dt_ids,
|
||||
},
|
||||
.probe = jz4740_pwm_probe,
|
||||
};
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user