Skip to content

Commit

Permalink
Merge tag 'for-3.10-rc1' of git://gitorious.org/linux-pwm/linux-pwm
Browse files Browse the repository at this point in the history
Pull pwm changes from Thierry Reding:
 "Nothing very exciting this time around.  A couple of bug fixes and a
  lot of cleanup across the board.  The DaVinci 8xx family of SoCs now
  use the same driver as the AM33xx family.

  Many thanks to Axel Lin and Jingoo Han who have done a great job
  fixing various bugs and inconsistencies."

* tag 'for-3.10-rc1' of git://gitorious.org/linux-pwm/linux-pwm: (27 commits)
  pwm: lpc32xx: Don't change PWM_ENABLE bit in lpc32xx_pwm_config
  pwm: lpc32xx: Properly set PWM_ENABLE bit in lpc32xx_pwm_[enable|disable]
  pwm: Constify OF match tables
  pwm: pwm-tiehrpwm: Update device-tree binding document
  pwm: pwm-tiecap: Update device-tree binding document
  pwm: puv3: Remove unused enabled filed from struct puv3_pwm_chip
  pwm: pxa: Remove PWM_ID_BASE macro
  pwm: spear: Remove unused *dev from struct spear_pwm_chip
  pwm: mxs: Remove unused *dev from struct mxs_pwm_chip
  pwm: twl: Return proper error if twl6030_pwm_enable() fails
  pwm: pxa: Remove clk_enabled field from struct pxa_pwm_chip
  pwm: imx: Remove enabled field from struct imx_chip
  pwm: twl: Add .owner to struct pwm_ops
  pwm: twl-led: Add .owner to struct pwm_ops
  pwm: atmel-tcb: Add .owner to struct pwm_ops
  pwm: ab8500: Add .owner to struct pwm_ops
  pwm: spear: Fix checking return value of clk_enable() and clk_prepare()
  pwm: tiehrpwm: Staticize non-exported symbols
  pwm: tiecap: Staticize non-exported symbols
  pwm: ab8500: Fix trivial typo in dev_err message
  ...
  • Loading branch information
Linus Torvalds committed May 6, 2013
2 parents 9973798 + affb923 commit f87bb9e
Show file tree
Hide file tree
Showing 20 changed files with 91 additions and 79 deletions.
12 changes: 10 additions & 2 deletions Documentation/devicetree/bindings/pwm/pwm-tiecap.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
TI SOC ECAP based APWM controller

Required properties:
- compatible: Must be "ti,am33xx-ecap"
- compatible: Must be "ti,<soc>-ecap".
for am33xx - compatible = "ti,am33xx-ecap";
for da850 - compatible = "ti,da850-ecap", "ti,am33xx-ecap";
- #pwm-cells: Should be 3. Number of cells being used to specify PWM property.
First cell specifies the per-chip index of the PWM to use, the second
cell is the period in nanoseconds and bit 0 in the third cell is used to
Expand All @@ -15,9 +17,15 @@ Optional properties:

Example:

ecap0: ecap@0 {
ecap0: ecap@0 { /* ECAP on am33xx */
compatible = "ti,am33xx-ecap";
#pwm-cells = <3>;
reg = <0x48300100 0x80>;
ti,hwmods = "ecap0";
};

ecap0: ecap@0 { /* ECAP on da850 */
compatible = "ti,da850-ecap", "ti,am33xx-ecap";
#pwm-cells = <3>;
reg = <0x306000 0x80>;
};
12 changes: 10 additions & 2 deletions Documentation/devicetree/bindings/pwm/pwm-tiehrpwm.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
TI SOC EHRPWM based PWM controller

Required properties:
- compatible : Must be "ti,am33xx-ehrpwm"
- compatible: Must be "ti,<soc>-ehrpwm".
for am33xx - compatible = "ti,am33xx-ehrpwm";
for da850 - compatible = "ti,da850-ehrpwm", "ti,am33xx-ehrpwm";
- #pwm-cells: Should be 3. Number of cells being used to specify PWM property.
First cell specifies the per-chip index of the PWM to use, the second
cell is the period in nanoseconds and bit 0 in the third cell is used to
Expand All @@ -15,9 +17,15 @@ Optional properties:

Example:

ehrpwm0: ehrpwm@0 {
ehrpwm0: ehrpwm@0 { /* EHRPWM on am33xx */
compatible = "ti,am33xx-ehrpwm";
#pwm-cells = <3>;
reg = <0x48300200 0x100>;
ti,hwmods = "ehrpwm0";
};

ehrpwm0: ehrpwm@0 { /* EHRPWM on da850 */
compatible = "ti,da850-ehrpwm", "ti,am33xx-ehrpwm";
#pwm-cells = <3>;
reg = <0x300000 0x2000>;
};
8 changes: 3 additions & 5 deletions drivers/pwm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ config PWM_TEGRA

config PWM_TIECAP
tristate "ECAP PWM support"
depends on SOC_AM33XX
select PWM_TIPWMSS
depends on SOC_AM33XX || ARCH_DAVINCI_DA8XX
help
PWM driver support for the ECAP APWM controller found on AM33XX
TI SOC
Expand All @@ -158,8 +157,7 @@ config PWM_TIECAP

config PWM_TIEHRPWM
tristate "EHRPWM PWM support"
depends on SOC_AM33XX
select PWM_TIPWMSS
depends on SOC_AM33XX || ARCH_DAVINCI_DA8XX
help
PWM driver support for the EHRPWM controller found on AM33XX
TI SOC
Expand All @@ -169,7 +167,7 @@ config PWM_TIEHRPWM

config PWM_TIPWMSS
bool
depends on SOC_AM33XX && (PWM_TIEHRPWM || PWM_TIECAP)
default y if SOC_AM33XX && (PWM_TIECAP || PWM_TIEHRPWM)
help
PWM Subsystem driver support for AM33xx SOC.

Expand Down
10 changes: 4 additions & 6 deletions drivers/pwm/pwm-ab8500.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static int ab8500_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
AB8500_MISC, AB8500_PWM_OUT_CTRL7_REG,
1 << (chip->base - 1), ENABLE_PWM);
if (ret < 0)
dev_err(chip->dev, "%s: Failed to disable PWM, Error %d\n",
dev_err(chip->dev, "%s: Failed to enable PWM, Error %d\n",
pwm->label, ret);
return ret;
}
Expand All @@ -88,6 +88,7 @@ static const struct pwm_ops ab8500_pwm_ops = {
.config = ab8500_pwm_config,
.enable = ab8500_pwm_enable,
.disable = ab8500_pwm_disable,
.owner = THIS_MODULE,
};

static int ab8500_pwm_probe(struct platform_device *pdev)
Expand All @@ -99,7 +100,7 @@ static int ab8500_pwm_probe(struct platform_device *pdev)
* Nothing to be done in probe, this is required to get the
* device which is required for ab8500 read and write
*/
ab8500 = kzalloc(sizeof(*ab8500), GFP_KERNEL);
ab8500 = devm_kzalloc(&pdev->dev, sizeof(*ab8500), GFP_KERNEL);
if (ab8500 == NULL) {
dev_err(&pdev->dev, "failed to allocate memory\n");
return -ENOMEM;
Expand All @@ -111,10 +112,8 @@ static int ab8500_pwm_probe(struct platform_device *pdev)
ab8500->chip.npwm = 1;

err = pwmchip_add(&ab8500->chip);
if (err < 0) {
kfree(ab8500);
if (err < 0)
return err;
}

dev_dbg(&pdev->dev, "pwm probe successful\n");
platform_set_drvdata(pdev, ab8500);
Expand All @@ -132,7 +131,6 @@ static int ab8500_pwm_remove(struct platform_device *pdev)
return err;

dev_dbg(&pdev->dev, "pwm driver removed\n");
kfree(ab8500);

return 0;
}
Expand Down
1 change: 1 addition & 0 deletions drivers/pwm/pwm-atmel-tcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ static const struct pwm_ops atmel_tcb_pwm_ops = {
.set_polarity = atmel_tcb_pwm_set_polarity,
.enable = atmel_tcb_pwm_enable,
.disable = atmel_tcb_pwm_disable,
.owner = THIS_MODULE,
};

static int atmel_tcb_pwm_probe(struct platform_device *pdev)
Expand Down
6 changes: 1 addition & 5 deletions drivers/pwm/pwm-imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ struct imx_chip {
struct clk *clk_per;
struct clk *clk_ipg;

int enabled;
void __iomem *mmio_base;

struct pwm_chip chip;
Expand Down Expand Up @@ -135,7 +134,7 @@ static int imx_pwm_config_v2(struct pwm_chip *chip,
MX3_PWMCR_DOZEEN | MX3_PWMCR_WAITEN |
MX3_PWMCR_DBGEN | MX3_PWMCR_CLKSRC_IPG_HIGH;

if (imx->enabled)
if (test_bit(PWMF_ENABLED, &pwm->flags))
cr |= MX3_PWMCR_EN;

writel(cr, imx->mmio_base + MX3_PWMCR);
Expand Down Expand Up @@ -186,8 +185,6 @@ static int imx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)

imx->set_enable(chip, true);

imx->enabled = 1;

return 0;
}

Expand All @@ -198,7 +195,6 @@ static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
imx->set_enable(chip, false);

clk_disable_unprepare(imx->clk_per);
imx->enabled = 0;
}

static struct pwm_ops imx_pwm_ops = {
Expand Down
27 changes: 22 additions & 5 deletions drivers/pwm/pwm-lpc32xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip);
unsigned long long c;
int period_cycles, duty_cycles;
u32 val;

c = clk_get_rate(lpc32xx->clk) / 256;
c = c * period_ns;
Expand Down Expand Up @@ -68,24 +69,40 @@ static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
c = 255;
duty_cycles = 256 - c;

writel(PWM_ENABLE | PWM_RELOADV(period_cycles) | PWM_DUTY(duty_cycles),
lpc32xx->base + (pwm->hwpwm << 2));
val = readl(lpc32xx->base + (pwm->hwpwm << 2));
val &= ~0xFFFF;
val |= PWM_RELOADV(period_cycles) | PWM_DUTY(duty_cycles);
writel(val, lpc32xx->base + (pwm->hwpwm << 2));

return 0;
}

static int lpc32xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
{
struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip);
u32 val;
int ret;

ret = clk_enable(lpc32xx->clk);
if (ret)
return ret;

return clk_enable(lpc32xx->clk);
val = readl(lpc32xx->base + (pwm->hwpwm << 2));
val |= PWM_ENABLE;
writel(val, lpc32xx->base + (pwm->hwpwm << 2));

return 0;
}

static void lpc32xx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
{
struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip);
u32 val;

val = readl(lpc32xx->base + (pwm->hwpwm << 2));
val &= ~PWM_ENABLE;
writel(val, lpc32xx->base + (pwm->hwpwm << 2));

writel(0, lpc32xx->base + (pwm->hwpwm << 2));
clk_disable(lpc32xx->clk);
}

Expand Down Expand Up @@ -145,7 +162,7 @@ static int lpc32xx_pwm_remove(struct platform_device *pdev)
return pwmchip_remove(&lpc32xx->chip);
}

static struct of_device_id lpc32xx_pwm_dt_ids[] = {
static const struct of_device_id lpc32xx_pwm_dt_ids[] = {
{ .compatible = "nxp,lpc3220-pwm", },
{ /* sentinel */ }
};
Expand Down
4 changes: 1 addition & 3 deletions drivers/pwm/pwm-mxs.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

struct mxs_pwm_chip {
struct pwm_chip chip;
struct device *dev;
struct clk *clk;
void __iomem *base;
};
Expand Down Expand Up @@ -166,7 +165,6 @@ static int mxs_pwm_probe(struct platform_device *pdev)
return ret;
}

mxs->dev = &pdev->dev;
platform_set_drvdata(pdev, mxs);

stmp_reset_block(mxs->base);
Expand All @@ -181,7 +179,7 @@ static int mxs_pwm_remove(struct platform_device *pdev)
return pwmchip_remove(&mxs->chip);
}

static struct of_device_id mxs_pwm_dt_ids[] = {
static const struct of_device_id mxs_pwm_dt_ids[] = {
{ .compatible = "fsl,imx23-pwm", },
{ /* sentinel */ }
};
Expand Down
1 change: 0 additions & 1 deletion drivers/pwm/pwm-puv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ struct puv3_pwm_chip {
struct pwm_chip chip;
void __iomem *base;
struct clk *clk;
bool enabled;
};

static inline struct puv3_pwm_chip *to_puv3(struct pwm_chip *chip)
Expand Down
23 changes: 5 additions & 18 deletions drivers/pwm/pwm-pxa.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@
#include <asm/div64.h>

#define HAS_SECONDARY_PWM 0x10
#define PWM_ID_BASE(d) ((d) & 0xf)

static const struct platform_device_id pwm_id_table[] = {
/* PWM has_secondary_pwm? */
{ "pxa25x-pwm", 0 },
{ "pxa27x-pwm", 0 | HAS_SECONDARY_PWM },
{ "pxa168-pwm", 1 },
{ "pxa910-pwm", 1 },
{ "pxa27x-pwm", HAS_SECONDARY_PWM },
{ "pxa168-pwm", 0 },
{ "pxa910-pwm", 0 },
{ },
};
MODULE_DEVICE_TABLE(platform, pwm_id_table);
Expand All @@ -48,7 +47,6 @@ struct pxa_pwm_chip {
struct device *dev;

struct clk *clk;
int clk_enabled;
void __iomem *mmio_base;
};

Expand Down Expand Up @@ -108,24 +106,15 @@ static int pxa_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
static int pxa_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
{
struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip);
int rc = 0;

if (!pc->clk_enabled) {
rc = clk_prepare_enable(pc->clk);
if (!rc)
pc->clk_enabled++;
}
return rc;
return clk_prepare_enable(pc->clk);
}

static void pxa_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
{
struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip);

if (pc->clk_enabled) {
clk_disable_unprepare(pc->clk);
pc->clk_enabled--;
}
clk_disable_unprepare(pc->clk);
}

static struct pwm_ops pxa_pwm_ops = {
Expand All @@ -152,8 +141,6 @@ static int pwm_probe(struct platform_device *pdev)
if (IS_ERR(pwm->clk))
return PTR_ERR(pwm->clk);

pwm->clk_enabled = 0;

pwm->chip.dev = &pdev->dev;
pwm->chip.ops = &pxa_pwm_ops;
pwm->chip.base = -1;
Expand Down
20 changes: 9 additions & 11 deletions drivers/pwm/pwm-samsung.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,10 @@ static int s3c_pwm_remove(struct platform_device *pdev)
return 0;
}

#ifdef CONFIG_PM
static int s3c_pwm_suspend(struct platform_device *pdev, pm_message_t state)
#ifdef CONFIG_PM_SLEEP
static int s3c_pwm_suspend(struct device *dev)
{
struct s3c_chip *s3c = platform_get_drvdata(pdev);
struct s3c_chip *s3c = dev_get_drvdata(dev);

/* No one preserve these values during suspend so reset them
* Otherwise driver leaves PWM unconfigured if same values
Expand All @@ -304,9 +304,9 @@ static int s3c_pwm_suspend(struct platform_device *pdev, pm_message_t state)
return 0;
}

static int s3c_pwm_resume(struct platform_device *pdev)
static int s3c_pwm_resume(struct device *dev)
{
struct s3c_chip *s3c = platform_get_drvdata(pdev);
struct s3c_chip *s3c = dev_get_drvdata(dev);
unsigned long tcon;

/* Restore invertion */
Expand All @@ -316,21 +316,19 @@ static int s3c_pwm_resume(struct platform_device *pdev)

return 0;
}

#else
#define s3c_pwm_suspend NULL
#define s3c_pwm_resume NULL
#endif

static SIMPLE_DEV_PM_OPS(s3c_pwm_pm_ops, s3c_pwm_suspend,
s3c_pwm_resume);

static struct platform_driver s3c_pwm_driver = {
.driver = {
.name = "s3c24xx-pwm",
.owner = THIS_MODULE,
.pm = &s3c_pwm_pm_ops,
},
.probe = s3c_pwm_probe,
.remove = s3c_pwm_remove,
.suspend = s3c_pwm_suspend,
.resume = s3c_pwm_resume,
};

static int __init pwm_init(void)
Expand Down
Loading

0 comments on commit f87bb9e

Please sign in to comment.