Commit ceae608a authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'pwm/for-5.10-rc1' of...

Merge tag 'pwm/for-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm

Pull pwm updates from Thierry Reding:
 "This release cycle's updates are mostly cleanup and some minor fixes"

* tag 'pwm/for-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm:
  dt-bindings: pwm: renesas,pwm-rcar: Add r8a7742 support
  dt-bindings: pwm: renesas,tpu-pwm: Document r8a7742 support
  pwm: Allow store 64-bit duty cycle from sysfs interface
  pwm: img: Fix null pointer access in probe
  pwm: pca9685: Disable unused alternative addresses
  pwm: pca9685: Use BIT() macro instead of shift
  pwm: pca9685: Make comments more consistent
  pwm: sun4i: Simplify with dev_err_probe()
  pwm: sprd: Simplify with dev_err_probe()
  pwm: sifive: Simplify with dev_err_probe()
  pwm: rockchip: Simplify with dev_err_probe()
  pwm: jz4740: Simplify with dev_err_probe()
  pwm: bcm2835: Simplify with dev_err_probe()
  pwm: Convert to use DEFINE_SEQ_ATTRIBUTE macro
  pwm: rockchip: Keep enabled PWMs running while probing
  dt-bindings: pwm: renesas,pwm-rcar: Add r8a774e1 support
parents 00937f36 3b1954cd
...@@ -13,6 +13,7 @@ properties: ...@@ -13,6 +13,7 @@ properties:
compatible: compatible:
items: items:
- enum: - enum:
- renesas,pwm-r8a7742 # RZ/G1H
- renesas,pwm-r8a7743 # RZ/G1M - renesas,pwm-r8a7743 # RZ/G1M
- renesas,pwm-r8a7744 # RZ/G1N - renesas,pwm-r8a7744 # RZ/G1N
- renesas,pwm-r8a7745 # RZ/G1E - renesas,pwm-r8a7745 # RZ/G1E
...@@ -20,6 +21,7 @@ properties: ...@@ -20,6 +21,7 @@ properties:
- renesas,pwm-r8a774a1 # RZ/G2M - renesas,pwm-r8a774a1 # RZ/G2M
- renesas,pwm-r8a774b1 # RZ/G2N - renesas,pwm-r8a774b1 # RZ/G2N
- renesas,pwm-r8a774c0 # RZ/G2E - renesas,pwm-r8a774c0 # RZ/G2E
- renesas,pwm-r8a774e1 # RZ/G2H
- renesas,pwm-r8a7778 # R-Car M1A - renesas,pwm-r8a7778 # R-Car M1A
- renesas,pwm-r8a7779 # R-Car H1 - renesas,pwm-r8a7779 # R-Car H1
- renesas,pwm-r8a7790 # R-Car H2 - renesas,pwm-r8a7790 # R-Car H2
......
...@@ -15,6 +15,7 @@ properties: ...@@ -15,6 +15,7 @@ properties:
- enum: - enum:
- renesas,tpu-r8a73a4 # R-Mobile APE6 - renesas,tpu-r8a73a4 # R-Mobile APE6
- renesas,tpu-r8a7740 # R-Mobile A1 - renesas,tpu-r8a7740 # R-Mobile A1
- renesas,tpu-r8a7742 # RZ/G1H
- renesas,tpu-r8a7743 # RZ/G1M - renesas,tpu-r8a7743 # RZ/G1M
- renesas,tpu-r8a7744 # RZ/G1N - renesas,tpu-r8a7744 # RZ/G1N
- renesas,tpu-r8a7745 # RZ/G1E - renesas,tpu-r8a7745 # RZ/G1E
......
...@@ -1327,30 +1327,19 @@ static int pwm_seq_show(struct seq_file *s, void *v) ...@@ -1327,30 +1327,19 @@ static int pwm_seq_show(struct seq_file *s, void *v)
return 0; return 0;
} }
static const struct seq_operations pwm_seq_ops = { static const struct seq_operations pwm_debugfs_sops = {
.start = pwm_seq_start, .start = pwm_seq_start,
.next = pwm_seq_next, .next = pwm_seq_next,
.stop = pwm_seq_stop, .stop = pwm_seq_stop,
.show = pwm_seq_show, .show = pwm_seq_show,
}; };
static int pwm_seq_open(struct inode *inode, struct file *file) DEFINE_SEQ_ATTRIBUTE(pwm_debugfs);
{
return seq_open(file, &pwm_seq_ops);
}
static const struct file_operations pwm_debugfs_ops = {
.owner = THIS_MODULE,
.open = pwm_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
static int __init pwm_debugfs_init(void) static int __init pwm_debugfs_init(void)
{ {
debugfs_create_file("pwm", S_IFREG | S_IRUGO, NULL, NULL, debugfs_create_file("pwm", S_IFREG | S_IRUGO, NULL, NULL,
&pwm_debugfs_ops); &pwm_debugfs_fops);
return 0; return 0;
} }
......
...@@ -152,13 +152,9 @@ static int bcm2835_pwm_probe(struct platform_device *pdev) ...@@ -152,13 +152,9 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)
return PTR_ERR(pc->base); return PTR_ERR(pc->base);
pc->clk = devm_clk_get(&pdev->dev, NULL); pc->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(pc->clk)) { if (IS_ERR(pc->clk))
ret = PTR_ERR(pc->clk); return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk),
if (ret != -EPROBE_DEFER) "clock not found\n");
dev_err(&pdev->dev, "clock not found: %d\n", ret);
return ret;
}
ret = clk_prepare_enable(pc->clk); ret = clk_prepare_enable(pc->clk);
if (ret) if (ret)
......
...@@ -277,6 +277,8 @@ static int img_pwm_probe(struct platform_device *pdev) ...@@ -277,6 +277,8 @@ static int img_pwm_probe(struct platform_device *pdev)
return PTR_ERR(pwm->pwm_clk); return PTR_ERR(pwm->pwm_clk);
} }
platform_set_drvdata(pdev, pwm);
pm_runtime_set_autosuspend_delay(&pdev->dev, IMG_PWM_PM_TIMEOUT); pm_runtime_set_autosuspend_delay(&pdev->dev, IMG_PWM_PM_TIMEOUT);
pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
...@@ -313,7 +315,6 @@ static int img_pwm_probe(struct platform_device *pdev) ...@@ -313,7 +315,6 @@ static int img_pwm_probe(struct platform_device *pdev)
goto err_suspend; goto err_suspend;
} }
platform_set_drvdata(pdev, pwm);
return 0; return 0;
err_suspend: err_suspend:
......
...@@ -60,12 +60,9 @@ static int jz4740_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) ...@@ -60,12 +60,9 @@ static int jz4740_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
snprintf(name, sizeof(name), "timer%u", pwm->hwpwm); snprintf(name, sizeof(name), "timer%u", pwm->hwpwm);
clk = clk_get(chip->dev, name); clk = clk_get(chip->dev, name);
if (IS_ERR(clk)) { if (IS_ERR(clk))
if (PTR_ERR(clk) != -EPROBE_DEFER) return dev_err_probe(chip->dev, PTR_ERR(clk),
dev_err(chip->dev, "Failed to get clock: %pe", clk); "Failed to get clock\n");
return PTR_ERR(clk);
}
err = clk_prepare_enable(clk); err = clk_prepare_enable(clk);
if (err < 0) { if (err < 0) {
......
...@@ -57,10 +57,14 @@ ...@@ -57,10 +57,14 @@
#define PCA9685_NUMREGS 0xFF #define PCA9685_NUMREGS 0xFF
#define PCA9685_MAXCHAN 0x10 #define PCA9685_MAXCHAN 0x10
#define LED_FULL (1 << 4) #define LED_FULL BIT(4)
#define MODE1_SLEEP (1 << 4) #define MODE1_ALLCALL BIT(0)
#define MODE2_INVRT (1 << 4) #define MODE1_SUB3 BIT(1)
#define MODE2_OUTDRV (1 << 2) #define MODE1_SUB2 BIT(2)
#define MODE1_SUB1 BIT(3)
#define MODE1_SLEEP BIT(4)
#define MODE2_INVRT BIT(4)
#define MODE2_OUTDRV BIT(2)
#define LED_N_ON_H(N) (PCA9685_LEDX_ON_H + (4 * (N))) #define LED_N_ON_H(N) (PCA9685_LEDX_ON_H + (4 * (N)))
#define LED_N_ON_L(N) (PCA9685_LEDX_ON_L + (4 * (N))) #define LED_N_ON_L(N) (PCA9685_LEDX_ON_L + (4 * (N)))
...@@ -91,7 +95,7 @@ static bool pca9685_pwm_test_and_set_inuse(struct pca9685 *pca, int pwm_idx) ...@@ -91,7 +95,7 @@ static bool pca9685_pwm_test_and_set_inuse(struct pca9685 *pca, int pwm_idx)
mutex_lock(&pca->lock); mutex_lock(&pca->lock);
if (pwm_idx >= PCA9685_MAXCHAN) { if (pwm_idx >= PCA9685_MAXCHAN) {
/* /*
* "all LEDs" channel: * "All LEDs" channel:
* pretend already in use if any of the PWMs are requested * pretend already in use if any of the PWMs are requested
*/ */
if (!bitmap_empty(pca->pwms_inuse, PCA9685_MAXCHAN)) { if (!bitmap_empty(pca->pwms_inuse, PCA9685_MAXCHAN)) {
...@@ -100,7 +104,7 @@ static bool pca9685_pwm_test_and_set_inuse(struct pca9685 *pca, int pwm_idx) ...@@ -100,7 +104,7 @@ static bool pca9685_pwm_test_and_set_inuse(struct pca9685 *pca, int pwm_idx)
} }
} else { } else {
/* /*
* regular channel: * Regular channel:
* pretend already in use if the "all LEDs" channel is requested * pretend already in use if the "all LEDs" channel is requested
*/ */
if (test_bit(PCA9685_MAXCHAN, pca->pwms_inuse)) { if (test_bit(PCA9685_MAXCHAN, pca->pwms_inuse)) {
...@@ -257,7 +261,7 @@ static int pca9685_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -257,7 +261,7 @@ static int pca9685_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
if (prescale >= PCA9685_PRESCALE_MIN && if (prescale >= PCA9685_PRESCALE_MIN &&
prescale <= PCA9685_PRESCALE_MAX) { prescale <= PCA9685_PRESCALE_MAX) {
/* /*
* putting the chip briefly into SLEEP mode * Putting the chip briefly into SLEEP mode
* at this point won't interfere with the * at this point won't interfere with the
* pm_runtime framework, because the pm_runtime * pm_runtime framework, because the pm_runtime
* state is guaranteed active here. * state is guaranteed active here.
...@@ -443,8 +447,8 @@ static int pca9685_pwm_probe(struct i2c_client *client, ...@@ -443,8 +447,8 @@ static int pca9685_pwm_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct pca9685 *pca; struct pca9685 *pca;
unsigned int reg;
int ret; int ret;
int mode2;
pca = devm_kzalloc(&client->dev, sizeof(*pca), GFP_KERNEL); pca = devm_kzalloc(&client->dev, sizeof(*pca), GFP_KERNEL);
if (!pca) if (!pca)
...@@ -461,26 +465,31 @@ static int pca9685_pwm_probe(struct i2c_client *client, ...@@ -461,26 +465,31 @@ static int pca9685_pwm_probe(struct i2c_client *client,
i2c_set_clientdata(client, pca); i2c_set_clientdata(client, pca);
regmap_read(pca->regmap, PCA9685_MODE2, &mode2); regmap_read(pca->regmap, PCA9685_MODE2, &reg);
if (device_property_read_bool(&client->dev, "invert")) if (device_property_read_bool(&client->dev, "invert"))
mode2 |= MODE2_INVRT; reg |= MODE2_INVRT;
else else
mode2 &= ~MODE2_INVRT; reg &= ~MODE2_INVRT;
if (device_property_read_bool(&client->dev, "open-drain")) if (device_property_read_bool(&client->dev, "open-drain"))
mode2 &= ~MODE2_OUTDRV; reg &= ~MODE2_OUTDRV;
else else
mode2 |= MODE2_OUTDRV; reg |= MODE2_OUTDRV;
regmap_write(pca->regmap, PCA9685_MODE2, reg);
regmap_write(pca->regmap, PCA9685_MODE2, mode2); /* Disable all LED ALLCALL and SUBx addresses to avoid bus collisions */
regmap_read(pca->regmap, PCA9685_MODE1, &reg);
reg &= ~(MODE1_ALLCALL | MODE1_SUB1 | MODE1_SUB2 | MODE1_SUB3);
regmap_write(pca->regmap, PCA9685_MODE1, reg);
/* clear all "full off" bits */ /* Clear all "full off" bits */
regmap_write(pca->regmap, PCA9685_ALL_LED_OFF_L, 0); regmap_write(pca->regmap, PCA9685_ALL_LED_OFF_L, 0);
regmap_write(pca->regmap, PCA9685_ALL_LED_OFF_H, 0); regmap_write(pca->regmap, PCA9685_ALL_LED_OFF_H, 0);
pca->chip.ops = &pca9685_pwm_ops; pca->chip.ops = &pca9685_pwm_ops;
/* add an extra channel for ALL_LED */ /* Add an extra channel for ALL_LED */
pca->chip.npwm = PCA9685_MAXCHAN + 1; pca->chip.npwm = PCA9685_MAXCHAN + 1;
pca->chip.dev = &client->dev; pca->chip.dev = &client->dev;
...@@ -496,10 +505,10 @@ static int pca9685_pwm_probe(struct i2c_client *client, ...@@ -496,10 +505,10 @@ static int pca9685_pwm_probe(struct i2c_client *client,
return ret; return ret;
} }
/* the chip comes out of power-up in the active state */ /* The chip comes out of power-up in the active state */
pm_runtime_set_active(&client->dev); pm_runtime_set_active(&client->dev);
/* /*
* enable will put the chip into suspend, which is what we * Enable will put the chip into suspend, which is what we
* want as all outputs are disabled at this point * want as all outputs are disabled at this point
*/ */
pm_runtime_enable(&client->dev); pm_runtime_enable(&client->dev);
......
...@@ -288,6 +288,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev) ...@@ -288,6 +288,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
const struct of_device_id *id; const struct of_device_id *id;
struct rockchip_pwm_chip *pc; struct rockchip_pwm_chip *pc;
struct resource *r; struct resource *r;
u32 enable_conf, ctrl;
int ret, count; int ret, count;
id = of_match_device(rockchip_pwm_dt_ids, &pdev->dev); id = of_match_device(rockchip_pwm_dt_ids, &pdev->dev);
...@@ -306,13 +307,9 @@ static int rockchip_pwm_probe(struct platform_device *pdev) ...@@ -306,13 +307,9 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
pc->clk = devm_clk_get(&pdev->dev, "pwm"); pc->clk = devm_clk_get(&pdev->dev, "pwm");
if (IS_ERR(pc->clk)) { if (IS_ERR(pc->clk)) {
pc->clk = devm_clk_get(&pdev->dev, NULL); pc->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(pc->clk)) { if (IS_ERR(pc->clk))
ret = PTR_ERR(pc->clk); return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk),
if (ret != -EPROBE_DEFER) "Can't get bus clk\n");
dev_err(&pdev->dev, "Can't get bus clk: %d\n",
ret);
return ret;
}
} }
count = of_count_phandle_with_args(pdev->dev.of_node, count = of_count_phandle_with_args(pdev->dev.of_node,
...@@ -362,7 +359,9 @@ static int rockchip_pwm_probe(struct platform_device *pdev) ...@@ -362,7 +359,9 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
} }
/* Keep the PWM clk enabled if the PWM appears to be up and running. */ /* Keep the PWM clk enabled if the PWM appears to be up and running. */
if (!pwm_is_enabled(pc->chip.pwms)) enable_conf = pc->data->enable_conf;
ctrl = readl_relaxed(pc->base + pc->data->regs.ctrl);
if ((ctrl & enable_conf) != enable_conf)
clk_disable(pc->clk); clk_disable(pc->clk);
return 0; return 0;
......
...@@ -254,11 +254,9 @@ static int pwm_sifive_probe(struct platform_device *pdev) ...@@ -254,11 +254,9 @@ static int pwm_sifive_probe(struct platform_device *pdev)
return PTR_ERR(ddata->regs); return PTR_ERR(ddata->regs);
ddata->clk = devm_clk_get(dev, NULL); ddata->clk = devm_clk_get(dev, NULL);
if (IS_ERR(ddata->clk)) { if (IS_ERR(ddata->clk))
if (PTR_ERR(ddata->clk) != -EPROBE_DEFER) return dev_err_probe(dev, PTR_ERR(ddata->clk),
dev_err(dev, "Unable to find controller clock\n"); "Unable to find controller clock\n");
return PTR_ERR(ddata->clk);
}
ret = clk_prepare_enable(ddata->clk); ret = clk_prepare_enable(ddata->clk);
if (ret) { if (ret) {
......
...@@ -228,11 +228,8 @@ static int sprd_pwm_clk_init(struct sprd_pwm_chip *spc) ...@@ -228,11 +228,8 @@ static int sprd_pwm_clk_init(struct sprd_pwm_chip *spc)
if (ret == -ENOENT) if (ret == -ENOENT)
break; break;
if (ret != -EPROBE_DEFER) return dev_err_probe(spc->dev, ret,
dev_err(spc->dev, "failed to get channel clocks\n");
"failed to get channel clocks\n");
return ret;
} }
clk_pwm = chn->clks[SPRD_PWM_CHN_OUTPUT_CLK].clk; clk_pwm = chn->clks[SPRD_PWM_CHN_OUTPUT_CLK].clk;
......
...@@ -423,38 +423,26 @@ static int sun4i_pwm_probe(struct platform_device *pdev) ...@@ -423,38 +423,26 @@ static int sun4i_pwm_probe(struct platform_device *pdev)
* back to the first clock of the PWM. * back to the first clock of the PWM.
*/ */
pwm->clk = devm_clk_get_optional(&pdev->dev, "mod"); pwm->clk = devm_clk_get_optional(&pdev->dev, "mod");
if (IS_ERR(pwm->clk)) { if (IS_ERR(pwm->clk))
if (PTR_ERR(pwm->clk) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(pwm->clk),
dev_err(&pdev->dev, "get mod clock failed %pe\n", "get mod clock failed\n");
pwm->clk);
return PTR_ERR(pwm->clk);
}
if (!pwm->clk) { if (!pwm->clk) {
pwm->clk = devm_clk_get(&pdev->dev, NULL); pwm->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(pwm->clk)) { if (IS_ERR(pwm->clk))
if (PTR_ERR(pwm->clk) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(pwm->clk),
dev_err(&pdev->dev, "get unnamed clock failed %pe\n", "get unnamed clock failed\n");
pwm->clk);
return PTR_ERR(pwm->clk);
}
} }
pwm->bus_clk = devm_clk_get_optional(&pdev->dev, "bus"); pwm->bus_clk = devm_clk_get_optional(&pdev->dev, "bus");
if (IS_ERR(pwm->bus_clk)) { if (IS_ERR(pwm->bus_clk))
if (PTR_ERR(pwm->bus_clk) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(pwm->bus_clk),
dev_err(&pdev->dev, "get bus clock failed %pe\n", "get bus clock failed\n");
pwm->bus_clk);
return PTR_ERR(pwm->bus_clk);
}
pwm->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL); pwm->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL);
if (IS_ERR(pwm->rst)) { if (IS_ERR(pwm->rst))
if (PTR_ERR(pwm->rst) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(pwm->rst),
dev_err(&pdev->dev, "get reset failed %pe\n", "get reset failed\n");
pwm->rst);
return PTR_ERR(pwm->rst);
}
/* Deassert reset */ /* Deassert reset */
ret = reset_control_deassert(pwm->rst); ret = reset_control_deassert(pwm->rst);
......
...@@ -87,10 +87,10 @@ static ssize_t duty_cycle_store(struct device *child, ...@@ -87,10 +87,10 @@ static ssize_t duty_cycle_store(struct device *child,
struct pwm_export *export = child_to_pwm_export(child); struct pwm_export *export = child_to_pwm_export(child);
struct pwm_device *pwm = export->pwm; struct pwm_device *pwm = export->pwm;
struct pwm_state state; struct pwm_state state;
unsigned int val; u64 val;
int ret; int ret;
ret = kstrtouint(buf, 0, &val); ret = kstrtou64(buf, 0, &val);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment