Commit f87bb9ee authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-3.10-rc1' of git://gitorious.org/linux-pwm/linux-pwm

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
  ...
parents 99737982 affb923d
TI SOC ECAP based APWM controller TI SOC ECAP based APWM controller
Required properties: 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. - #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 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 cell is the period in nanoseconds and bit 0 in the third cell is used to
...@@ -15,9 +17,15 @@ Optional properties: ...@@ -15,9 +17,15 @@ Optional properties:
Example: Example:
ecap0: ecap@0 { ecap0: ecap@0 { /* ECAP on am33xx */
compatible = "ti,am33xx-ecap"; compatible = "ti,am33xx-ecap";
#pwm-cells = <3>; #pwm-cells = <3>;
reg = <0x48300100 0x80>; reg = <0x48300100 0x80>;
ti,hwmods = "ecap0"; ti,hwmods = "ecap0";
}; };
ecap0: ecap@0 { /* ECAP on da850 */
compatible = "ti,da850-ecap", "ti,am33xx-ecap";
#pwm-cells = <3>;
reg = <0x306000 0x80>;
};
TI SOC EHRPWM based PWM controller TI SOC EHRPWM based PWM controller
Required properties: 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. - #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 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 cell is the period in nanoseconds and bit 0 in the third cell is used to
...@@ -15,9 +17,15 @@ Optional properties: ...@@ -15,9 +17,15 @@ Optional properties:
Example: Example:
ehrpwm0: ehrpwm@0 { ehrpwm0: ehrpwm@0 { /* EHRPWM on am33xx */
compatible = "ti,am33xx-ehrpwm"; compatible = "ti,am33xx-ehrpwm";
#pwm-cells = <3>; #pwm-cells = <3>;
reg = <0x48300200 0x100>; reg = <0x48300200 0x100>;
ti,hwmods = "ehrpwm0"; ti,hwmods = "ehrpwm0";
}; };
ehrpwm0: ehrpwm@0 { /* EHRPWM on da850 */
compatible = "ti,da850-ehrpwm", "ti,am33xx-ehrpwm";
#pwm-cells = <3>;
reg = <0x300000 0x2000>;
};
...@@ -147,8 +147,7 @@ config PWM_TEGRA ...@@ -147,8 +147,7 @@ config PWM_TEGRA
config PWM_TIECAP config PWM_TIECAP
tristate "ECAP PWM support" tristate "ECAP PWM support"
depends on SOC_AM33XX depends on SOC_AM33XX || ARCH_DAVINCI_DA8XX
select PWM_TIPWMSS
help help
PWM driver support for the ECAP APWM controller found on AM33XX PWM driver support for the ECAP APWM controller found on AM33XX
TI SOC TI SOC
...@@ -158,8 +157,7 @@ config PWM_TIECAP ...@@ -158,8 +157,7 @@ config PWM_TIECAP
config PWM_TIEHRPWM config PWM_TIEHRPWM
tristate "EHRPWM PWM support" tristate "EHRPWM PWM support"
depends on SOC_AM33XX depends on SOC_AM33XX || ARCH_DAVINCI_DA8XX
select PWM_TIPWMSS
help help
PWM driver support for the EHRPWM controller found on AM33XX PWM driver support for the EHRPWM controller found on AM33XX
TI SOC TI SOC
...@@ -169,7 +167,7 @@ config PWM_TIEHRPWM ...@@ -169,7 +167,7 @@ config PWM_TIEHRPWM
config PWM_TIPWMSS config PWM_TIPWMSS
bool bool
depends on SOC_AM33XX && (PWM_TIEHRPWM || PWM_TIECAP) default y if SOC_AM33XX && (PWM_TIECAP || PWM_TIEHRPWM)
help help
PWM Subsystem driver support for AM33xx SOC. PWM Subsystem driver support for AM33xx SOC.
......
...@@ -66,7 +66,7 @@ static int ab8500_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) ...@@ -66,7 +66,7 @@ static int ab8500_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
AB8500_MISC, AB8500_PWM_OUT_CTRL7_REG, AB8500_MISC, AB8500_PWM_OUT_CTRL7_REG,
1 << (chip->base - 1), ENABLE_PWM); 1 << (chip->base - 1), ENABLE_PWM);
if (ret < 0) 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); pwm->label, ret);
return ret; return ret;
} }
...@@ -88,6 +88,7 @@ static const struct pwm_ops ab8500_pwm_ops = { ...@@ -88,6 +88,7 @@ static const struct pwm_ops ab8500_pwm_ops = {
.config = ab8500_pwm_config, .config = ab8500_pwm_config,
.enable = ab8500_pwm_enable, .enable = ab8500_pwm_enable,
.disable = ab8500_pwm_disable, .disable = ab8500_pwm_disable,
.owner = THIS_MODULE,
}; };
static int ab8500_pwm_probe(struct platform_device *pdev) static int ab8500_pwm_probe(struct platform_device *pdev)
...@@ -99,7 +100,7 @@ static int ab8500_pwm_probe(struct platform_device *pdev) ...@@ -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 * Nothing to be done in probe, this is required to get the
* device which is required for ab8500 read and write * 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) { if (ab8500 == NULL) {
dev_err(&pdev->dev, "failed to allocate memory\n"); dev_err(&pdev->dev, "failed to allocate memory\n");
return -ENOMEM; return -ENOMEM;
...@@ -111,10 +112,8 @@ static int ab8500_pwm_probe(struct platform_device *pdev) ...@@ -111,10 +112,8 @@ static int ab8500_pwm_probe(struct platform_device *pdev)
ab8500->chip.npwm = 1; ab8500->chip.npwm = 1;
err = pwmchip_add(&ab8500->chip); err = pwmchip_add(&ab8500->chip);
if (err < 0) { if (err < 0)
kfree(ab8500);
return err; return err;
}
dev_dbg(&pdev->dev, "pwm probe successful\n"); dev_dbg(&pdev->dev, "pwm probe successful\n");
platform_set_drvdata(pdev, ab8500); platform_set_drvdata(pdev, ab8500);
...@@ -132,7 +131,6 @@ static int ab8500_pwm_remove(struct platform_device *pdev) ...@@ -132,7 +131,6 @@ static int ab8500_pwm_remove(struct platform_device *pdev)
return err; return err;
dev_dbg(&pdev->dev, "pwm driver removed\n"); dev_dbg(&pdev->dev, "pwm driver removed\n");
kfree(ab8500);
return 0; return 0;
} }
......
...@@ -358,6 +358,7 @@ static const struct pwm_ops atmel_tcb_pwm_ops = { ...@@ -358,6 +358,7 @@ static const struct pwm_ops atmel_tcb_pwm_ops = {
.set_polarity = atmel_tcb_pwm_set_polarity, .set_polarity = atmel_tcb_pwm_set_polarity,
.enable = atmel_tcb_pwm_enable, .enable = atmel_tcb_pwm_enable,
.disable = atmel_tcb_pwm_disable, .disable = atmel_tcb_pwm_disable,
.owner = THIS_MODULE,
}; };
static int atmel_tcb_pwm_probe(struct platform_device *pdev) static int atmel_tcb_pwm_probe(struct platform_device *pdev)
......
...@@ -43,7 +43,6 @@ struct imx_chip { ...@@ -43,7 +43,6 @@ struct imx_chip {
struct clk *clk_per; struct clk *clk_per;
struct clk *clk_ipg; struct clk *clk_ipg;
int enabled;
void __iomem *mmio_base; void __iomem *mmio_base;
struct pwm_chip chip; struct pwm_chip chip;
...@@ -135,7 +134,7 @@ static int imx_pwm_config_v2(struct pwm_chip *chip, ...@@ -135,7 +134,7 @@ static int imx_pwm_config_v2(struct pwm_chip *chip,
MX3_PWMCR_DOZEEN | MX3_PWMCR_WAITEN | MX3_PWMCR_DOZEEN | MX3_PWMCR_WAITEN |
MX3_PWMCR_DBGEN | MX3_PWMCR_CLKSRC_IPG_HIGH; MX3_PWMCR_DBGEN | MX3_PWMCR_CLKSRC_IPG_HIGH;
if (imx->enabled) if (test_bit(PWMF_ENABLED, &pwm->flags))
cr |= MX3_PWMCR_EN; cr |= MX3_PWMCR_EN;
writel(cr, imx->mmio_base + MX3_PWMCR); writel(cr, imx->mmio_base + MX3_PWMCR);
...@@ -186,8 +185,6 @@ static int imx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) ...@@ -186,8 +185,6 @@ static int imx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
imx->set_enable(chip, true); imx->set_enable(chip, true);
imx->enabled = 1;
return 0; return 0;
} }
...@@ -198,7 +195,6 @@ static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) ...@@ -198,7 +195,6 @@ static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
imx->set_enable(chip, false); imx->set_enable(chip, false);
clk_disable_unprepare(imx->clk_per); clk_disable_unprepare(imx->clk_per);
imx->enabled = 0;
} }
static struct pwm_ops imx_pwm_ops = { static struct pwm_ops imx_pwm_ops = {
......
...@@ -37,6 +37,7 @@ static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -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); struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip);
unsigned long long c; unsigned long long c;
int period_cycles, duty_cycles; int period_cycles, duty_cycles;
u32 val;
c = clk_get_rate(lpc32xx->clk) / 256; c = clk_get_rate(lpc32xx->clk) / 256;
c = c * period_ns; c = c * period_ns;
...@@ -68,8 +69,10 @@ static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -68,8 +69,10 @@ static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
c = 255; c = 255;
duty_cycles = 256 - c; duty_cycles = 256 - c;
writel(PWM_ENABLE | PWM_RELOADV(period_cycles) | PWM_DUTY(duty_cycles), val = readl(lpc32xx->base + (pwm->hwpwm << 2));
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; return 0;
} }
...@@ -77,15 +80,29 @@ static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -77,15 +80,29 @@ static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
static int lpc32xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) static int lpc32xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
{ {
struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip); 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) static void lpc32xx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
{ {
struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip); 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); clk_disable(lpc32xx->clk);
} }
...@@ -145,7 +162,7 @@ static int lpc32xx_pwm_remove(struct platform_device *pdev) ...@@ -145,7 +162,7 @@ static int lpc32xx_pwm_remove(struct platform_device *pdev)
return pwmchip_remove(&lpc32xx->chip); 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", }, { .compatible = "nxp,lpc3220-pwm", },
{ /* sentinel */ } { /* sentinel */ }
}; };
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
struct mxs_pwm_chip { struct mxs_pwm_chip {
struct pwm_chip chip; struct pwm_chip chip;
struct device *dev;
struct clk *clk; struct clk *clk;
void __iomem *base; void __iomem *base;
}; };
...@@ -166,7 +165,6 @@ static int mxs_pwm_probe(struct platform_device *pdev) ...@@ -166,7 +165,6 @@ static int mxs_pwm_probe(struct platform_device *pdev)
return ret; return ret;
} }
mxs->dev = &pdev->dev;
platform_set_drvdata(pdev, mxs); platform_set_drvdata(pdev, mxs);
stmp_reset_block(mxs->base); stmp_reset_block(mxs->base);
...@@ -181,7 +179,7 @@ static int mxs_pwm_remove(struct platform_device *pdev) ...@@ -181,7 +179,7 @@ static int mxs_pwm_remove(struct platform_device *pdev)
return pwmchip_remove(&mxs->chip); 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", }, { .compatible = "fsl,imx23-pwm", },
{ /* sentinel */ } { /* sentinel */ }
}; };
......
...@@ -27,7 +27,6 @@ struct puv3_pwm_chip { ...@@ -27,7 +27,6 @@ struct puv3_pwm_chip {
struct pwm_chip chip; struct pwm_chip chip;
void __iomem *base; void __iomem *base;
struct clk *clk; struct clk *clk;
bool enabled;
}; };
static inline struct puv3_pwm_chip *to_puv3(struct pwm_chip *chip) static inline struct puv3_pwm_chip *to_puv3(struct pwm_chip *chip)
......
...@@ -23,14 +23,13 @@ ...@@ -23,14 +23,13 @@
#include <asm/div64.h> #include <asm/div64.h>
#define HAS_SECONDARY_PWM 0x10 #define HAS_SECONDARY_PWM 0x10
#define PWM_ID_BASE(d) ((d) & 0xf)
static const struct platform_device_id pwm_id_table[] = { static const struct platform_device_id pwm_id_table[] = {
/* PWM has_secondary_pwm? */ /* PWM has_secondary_pwm? */
{ "pxa25x-pwm", 0 }, { "pxa25x-pwm", 0 },
{ "pxa27x-pwm", 0 | HAS_SECONDARY_PWM }, { "pxa27x-pwm", HAS_SECONDARY_PWM },
{ "pxa168-pwm", 1 }, { "pxa168-pwm", 0 },
{ "pxa910-pwm", 1 }, { "pxa910-pwm", 0 },
{ }, { },
}; };
MODULE_DEVICE_TABLE(platform, pwm_id_table); MODULE_DEVICE_TABLE(platform, pwm_id_table);
...@@ -48,7 +47,6 @@ struct pxa_pwm_chip { ...@@ -48,7 +47,6 @@ struct pxa_pwm_chip {
struct device *dev; struct device *dev;
struct clk *clk; struct clk *clk;
int clk_enabled;
void __iomem *mmio_base; void __iomem *mmio_base;
}; };
...@@ -108,24 +106,15 @@ static int pxa_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -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) static int pxa_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
{ {
struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip); struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip);
int rc = 0;
if (!pc->clk_enabled) { return clk_prepare_enable(pc->clk);
rc = clk_prepare_enable(pc->clk);
if (!rc)
pc->clk_enabled++;
}
return rc;
} }
static void pxa_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) static void pxa_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
{ {
struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip); struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip);
if (pc->clk_enabled) { clk_disable_unprepare(pc->clk);
clk_disable_unprepare(pc->clk);
pc->clk_enabled--;
}
} }
static struct pwm_ops pxa_pwm_ops = { static struct pwm_ops pxa_pwm_ops = {
...@@ -152,8 +141,6 @@ static int pwm_probe(struct platform_device *pdev) ...@@ -152,8 +141,6 @@ static int pwm_probe(struct platform_device *pdev)
if (IS_ERR(pwm->clk)) if (IS_ERR(pwm->clk))
return PTR_ERR(pwm->clk); return PTR_ERR(pwm->clk);
pwm->clk_enabled = 0;
pwm->chip.dev = &pdev->dev; pwm->chip.dev = &pdev->dev;
pwm->chip.ops = &pxa_pwm_ops; pwm->chip.ops = &pxa_pwm_ops;
pwm->chip.base = -1; pwm->chip.base = -1;
......
...@@ -289,10 +289,10 @@ static int s3c_pwm_remove(struct platform_device *pdev) ...@@ -289,10 +289,10 @@ static int s3c_pwm_remove(struct platform_device *pdev)
return 0; return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM_SLEEP
static int s3c_pwm_suspend(struct platform_device *pdev, pm_message_t state) 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 /* No one preserve these values during suspend so reset them
* Otherwise driver leaves PWM unconfigured if same values * Otherwise driver leaves PWM unconfigured if same values
...@@ -304,9 +304,9 @@ static int s3c_pwm_suspend(struct platform_device *pdev, pm_message_t state) ...@@ -304,9 +304,9 @@ static int s3c_pwm_suspend(struct platform_device *pdev, pm_message_t state)
return 0; 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; unsigned long tcon;
/* Restore invertion */ /* Restore invertion */
...@@ -316,21 +316,19 @@ static int s3c_pwm_resume(struct platform_device *pdev) ...@@ -316,21 +316,19 @@ static int s3c_pwm_resume(struct platform_device *pdev)
return 0; return 0;
} }
#else
#define s3c_pwm_suspend NULL
#define s3c_pwm_resume NULL
#endif #endif
static SIMPLE_DEV_PM_OPS(s3c_pwm_pm_ops, s3c_pwm_suspend,
s3c_pwm_resume);
static struct platform_driver s3c_pwm_driver = { static struct platform_driver s3c_pwm_driver = {
.driver = { .driver = {
.name = "s3c24xx-pwm", .name = "s3c24xx-pwm",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.pm = &s3c_pwm_pm_ops,
}, },
.probe = s3c_pwm_probe, .probe = s3c_pwm_probe,
.remove = s3c_pwm_remove, .remove = s3c_pwm_remove,
.suspend = s3c_pwm_suspend,
.resume = s3c_pwm_resume,
}; };
static int __init pwm_init(void) static int __init pwm_init(void)
......
...@@ -49,13 +49,11 @@ ...@@ -49,13 +49,11 @@
* @mmio_base: base address of pwm chip * @mmio_base: base address of pwm chip
* @clk: pointer to clk structure of pwm chip * @clk: pointer to clk structure of pwm chip
* @chip: linux pwm chip representation * @chip: linux pwm chip representation
* @dev: pointer to device structure of pwm chip
*/ */
struct spear_pwm_chip { struct spear_pwm_chip {
void __iomem *mmio_base; void __iomem *mmio_base;
struct clk *clk; struct clk *clk;
struct pwm_chip chip; struct pwm_chip chip;
struct device *dev;
}; };
static inline struct spear_pwm_chip *to_spear_pwm_chip(struct pwm_chip *chip) static inline struct spear_pwm_chip *to_spear_pwm_chip(struct pwm_chip *chip)
...@@ -143,7 +141,7 @@ static int spear_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) ...@@ -143,7 +141,7 @@ static int spear_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
u32 val; u32 val;
rc = clk_enable(pc->clk); rc = clk_enable(pc->clk);
if (!rc) if (rc)
return rc; return rc;
val = spear_pwm_readl(pc, pwm->hwpwm, PWMCR); val = spear_pwm_readl(pc, pwm->hwpwm, PWMCR);
...@@ -200,7 +198,6 @@ static int spear_pwm_probe(struct platform_device *pdev) ...@@ -200,7 +198,6 @@ static int spear_pwm_probe(struct platform_device *pdev)
if (IS_ERR(pc->clk)) if (IS_ERR(pc->clk))
return PTR_ERR(pc->clk); return PTR_ERR(pc->clk);
pc->dev = &pdev->dev;
platform_set_drvdata(pdev, pc); platform_set_drvdata(pdev, pc);
pc->chip.dev = &pdev->dev; pc->chip.dev = &pdev->dev;
...@@ -209,12 +206,12 @@ static int spear_pwm_probe(struct platform_device *pdev) ...@@ -209,12 +206,12 @@ static int spear_pwm_probe(struct platform_device *pdev)
pc->chip.npwm = NUM_PWM; pc->chip.npwm = NUM_PWM;
ret = clk_prepare(pc->clk); ret = clk_prepare(pc->clk);
if (!ret) if (ret)
return ret; return ret;
if (of_device_is_compatible(np, "st,spear1340-pwm")) { if (of_device_is_compatible(np, "st,spear1340-pwm")) {
ret = clk_enable(pc->clk); ret = clk_enable(pc->clk);
if (!ret) { if (ret) {
clk_unprepare(pc->clk); clk_unprepare(pc->clk);
return ret; return ret;
} }
...@@ -251,7 +248,7 @@ static int spear_pwm_remove(struct platform_device *pdev) ...@@ -251,7 +248,7 @@ static int spear_pwm_remove(struct platform_device *pdev)
return pwmchip_remove(&pc->chip); return pwmchip_remove(&pc->chip);
} }
static struct of_device_id spear_pwm_of_match[] = { static const struct of_device_id spear_pwm_of_match[] = {
{ .compatible = "st,spear320-pwm" }, { .compatible = "st,spear320-pwm" },
{ .compatible = "st,spear1340-pwm" }, { .compatible = "st,spear1340-pwm" },
{ } { }
......
...@@ -233,7 +233,7 @@ static int tegra_pwm_remove(struct platform_device *pdev) ...@@ -233,7 +233,7 @@ static int tegra_pwm_remove(struct platform_device *pdev)
return pwmchip_remove(&pc->chip); return pwmchip_remove(&pc->chip);
} }
static struct of_device_id tegra_pwm_of_match[] = { static const struct of_device_id tegra_pwm_of_match[] = {
{ .compatible = "nvidia,tegra20-pwm" }, { .compatible = "nvidia,tegra20-pwm" },
{ .compatible = "nvidia,tegra30-pwm" }, { .compatible = "nvidia,tegra30-pwm" },
{ } { }
......
...@@ -295,7 +295,7 @@ static int ecap_pwm_remove(struct platform_device *pdev) ...@@ -295,7 +295,7 @@ static int ecap_pwm_remove(struct platform_device *pdev)
return pwmchip_remove(&pc->chip); return pwmchip_remove(&pc->chip);
} }
void ecap_pwm_save_context(struct ecap_pwm_chip *pc) static void ecap_pwm_save_context(struct ecap_pwm_chip *pc)
{ {
pm_runtime_get_sync(pc->chip.dev); pm_runtime_get_sync(pc->chip.dev);
pc->ctx.ecctl2 = readw(pc->mmio_base + ECCTL2); pc->ctx.ecctl2 = readw(pc->mmio_base + ECCTL2);
...@@ -304,13 +304,14 @@ void ecap_pwm_save_context(struct ecap_pwm_chip *pc) ...@@ -304,13 +304,14 @@ void ecap_pwm_save_context(struct ecap_pwm_chip *pc)
pm_runtime_put_sync(pc->chip.dev); pm_runtime_put_sync(pc->chip.dev);
} }
void ecap_pwm_restore_context(struct ecap_pwm_chip *pc) static void ecap_pwm_restore_context(struct ecap_pwm_chip *pc)
{ {
writel(pc->ctx.cap3, pc->mmio_base + CAP3); writel(pc->ctx.cap3, pc->mmio_base + CAP3);
writel(pc->ctx.cap4, pc->mmio_base + CAP4); writel(pc->ctx.cap4, pc->mmio_base + CAP4);
writew(pc->ctx.ecctl2, pc->mmio_base + ECCTL2); writew(pc->ctx.ecctl2, pc->mmio_base + ECCTL2);
} }
#ifdef CONFIG_PM_SLEEP
static int ecap_pwm_suspend(struct device *dev) static int ecap_pwm_suspend(struct device *dev)
{ {
struct ecap_pwm_chip *pc = dev_get_drvdata(dev); struct ecap_pwm_chip *pc = dev_get_drvdata(dev);
...@@ -337,6 +338,7 @@ static int ecap_pwm_resume(struct device *dev) ...@@ -337,6 +338,7 @@ static int ecap_pwm_resume(struct device *dev)
ecap_pwm_restore_context(pc); ecap_pwm_restore_context(pc);
return 0; return 0;
} }
#endif
static SIMPLE_DEV_PM_OPS(ecap_pwm_pm_ops, ecap_pwm_suspend, ecap_pwm_resume); static SIMPLE_DEV_PM_OPS(ecap_pwm_pm_ops, ecap_pwm_suspend, ecap_pwm_resume);
......
...@@ -533,7 +533,7 @@ static int ehrpwm_pwm_remove(struct platform_device *pdev) ...@@ -533,7 +533,7 @@ static int ehrpwm_pwm_remove(struct platform_device *pdev)
return pwmchip_remove(&pc->chip); return pwmchip_remove(&pc->chip);
} }
void ehrpwm_pwm_save_context(struct ehrpwm_pwm_chip *pc) static void ehrpwm_pwm_save_context(struct ehrpwm_pwm_chip *pc)
{ {
pm_runtime_get_sync(pc->chip.dev); pm_runtime_get_sync(pc->chip.dev);
pc->ctx.tbctl = ehrpwm_read(pc->mmio_base, TBCTL); pc->ctx.tbctl = ehrpwm_read(pc->mmio_base, TBCTL);
...@@ -547,7 +547,7 @@ void ehrpwm_pwm_save_context(struct ehrpwm_pwm_chip *pc) ...@@ -547,7 +547,7 @@ void ehrpwm_pwm_save_context(struct ehrpwm_pwm_chip *pc)
pm_runtime_put_sync(pc->chip.dev); pm_runtime_put_sync(pc->chip.dev);
} }
void ehrpwm_pwm_restore_context(struct ehrpwm_pwm_chip *pc) static void ehrpwm_pwm_restore_context(struct ehrpwm_pwm_chip *pc)
{ {
ehrpwm_write(pc->mmio_base, TBPRD, pc->ctx.tbprd); ehrpwm_write(pc->mmio_base, TBPRD, pc->ctx.tbprd);
ehrpwm_write(pc->mmio_base, CMPA, pc->ctx.cmpa); ehrpwm_write(pc->mmio_base, CMPA, pc->ctx.cmpa);
...@@ -559,6 +559,7 @@ void ehrpwm_pwm_restore_context(struct ehrpwm_pwm_chip *pc) ...@@ -559,6 +559,7 @@ void ehrpwm_pwm_restore_context(struct ehrpwm_pwm_chip *pc)
ehrpwm_write(pc->mmio_base, TBCTL, pc->ctx.tbctl); ehrpwm_write(pc->mmio_base, TBCTL, pc->ctx.tbctl);
} }
#ifdef CONFIG_PM_SLEEP
static int ehrpwm_pwm_suspend(struct device *dev) static int ehrpwm_pwm_suspend(struct device *dev)
{ {
struct ehrpwm_pwm_chip *pc = dev_get_drvdata(dev); struct ehrpwm_pwm_chip *pc = dev_get_drvdata(dev);
...@@ -594,6 +595,7 @@ static int ehrpwm_pwm_resume(struct device *dev) ...@@ -594,6 +595,7 @@ static int ehrpwm_pwm_resume(struct device *dev)
ehrpwm_pwm_restore_context(pc); ehrpwm_pwm_restore_context(pc);
return 0; return 0;
} }
#endif
static SIMPLE_DEV_PM_OPS(ehrpwm_pwm_pm_ops, ehrpwm_pwm_suspend, static SIMPLE_DEV_PM_OPS(ehrpwm_pwm_pm_ops, ehrpwm_pwm_suspend,
ehrpwm_pwm_resume); ehrpwm_pwm_resume);
......
...@@ -101,6 +101,7 @@ static int pwmss_remove(struct platform_device *pdev) ...@@ -101,6 +101,7 @@ static int pwmss_remove(struct platform_device *pdev)
return 0; return 0;
} }
#ifdef CONFIG_PM_SLEEP
static int pwmss_suspend(struct device *dev) static int pwmss_suspend(struct device *dev)
{ {
struct pwmss_info *info = dev_get_drvdata(dev); struct pwmss_info *info = dev_get_drvdata(dev);
...@@ -118,6 +119,7 @@ static int pwmss_resume(struct device *dev) ...@@ -118,6 +119,7 @@ static int pwmss_resume(struct device *dev)
writew(info->pwmss_clkconfig, info->mmio_base + PWMSS_CLKCONFIG); writew(info->pwmss_clkconfig, info->mmio_base + PWMSS_CLKCONFIG);
return 0; return 0;
} }
#endif
static SIMPLE_DEV_PM_OPS(pwmss_pm_ops, pwmss_suspend, pwmss_resume); static SIMPLE_DEV_PM_OPS(pwmss_pm_ops, pwmss_suspend, pwmss_resume);
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#ifndef __TIPWMSS_H #ifndef __TIPWMSS_H
#define __TIPWMSS_H #define __TIPWMSS_H
#ifdef CONFIG_PWM_TIPWMSS
/* PWM substem clock gating */ /* PWM substem clock gating */
#define PWMSS_ECAPCLK_EN BIT(0) #define PWMSS_ECAPCLK_EN BIT(0)
#define PWMSS_ECAPCLK_STOP_REQ BIT(1) #define PWMSS_ECAPCLK_STOP_REQ BIT(1)
...@@ -28,6 +27,7 @@ ...@@ -28,6 +27,7 @@
#define PWMSS_ECAPCLK_EN_ACK BIT(0) #define PWMSS_ECAPCLK_EN_ACK BIT(0)
#define PWMSS_EPWMCLK_EN_ACK BIT(8) #define PWMSS_EPWMCLK_EN_ACK BIT(8)
#ifdef CONFIG_PWM_TIPWMSS
extern u16 pwmss_submodule_state_change(struct device *dev, int set); extern u16 pwmss_submodule_state_change(struct device *dev, int set);
#else #else
static inline u16 pwmss_submodule_state_change(struct device *dev, int set) static inline u16 pwmss_submodule_state_change(struct device *dev, int set)
......
...@@ -271,6 +271,7 @@ static const struct pwm_ops twl4030_pwmled_ops = { ...@@ -271,6 +271,7 @@ static const struct pwm_ops twl4030_pwmled_ops = {
.enable = twl4030_pwmled_enable, .enable = twl4030_pwmled_enable,
.disable = twl4030_pwmled_disable, .disable = twl4030_pwmled_disable,
.config = twl4030_pwmled_config, .config = twl4030_pwmled_config,
.owner = THIS_MODULE,
}; };
static const struct pwm_ops twl6030_pwmled_ops = { static const struct pwm_ops twl6030_pwmled_ops = {
...@@ -279,6 +280,7 @@ static const struct pwm_ops twl6030_pwmled_ops = { ...@@ -279,6 +280,7 @@ static const struct pwm_ops twl6030_pwmled_ops = {
.config = twl6030_pwmled_config, .config = twl6030_pwmled_config,
.request = twl6030_pwmled_request, .request = twl6030_pwmled_request,
.free = twl6030_pwmled_free, .free = twl6030_pwmled_free,
.owner = THIS_MODULE,
}; };
static int twl_pwmled_probe(struct platform_device *pdev) static int twl_pwmled_probe(struct platform_device *pdev)
...@@ -321,7 +323,7 @@ static int twl_pwmled_remove(struct platform_device *pdev) ...@@ -321,7 +323,7 @@ static int twl_pwmled_remove(struct platform_device *pdev)
} }
#ifdef CONFIG_OF #ifdef CONFIG_OF
static struct of_device_id twl_pwmled_of_match[] = { static const struct of_device_id twl_pwmled_of_match[] = {
{ .compatible = "ti,twl4030-pwmled" }, { .compatible = "ti,twl4030-pwmled" },
{ .compatible = "ti,twl6030-pwmled" }, { .compatible = "ti,twl6030-pwmled" },
{ }, { },
......
...@@ -248,7 +248,7 @@ static int twl6030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) ...@@ -248,7 +248,7 @@ static int twl6030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
twl->twl6030_toggle3 = val; twl->twl6030_toggle3 = val;
out: out:
mutex_unlock(&twl->mutex); mutex_unlock(&twl->mutex);
return 0; return ret;
} }
static void twl6030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) static void twl6030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
...@@ -287,12 +287,14 @@ static const struct pwm_ops twl4030_pwm_ops = { ...@@ -287,12 +287,14 @@ static const struct pwm_ops twl4030_pwm_ops = {
.disable = twl4030_pwm_disable, .disable = twl4030_pwm_disable,
.request = twl4030_pwm_request, .request = twl4030_pwm_request,
.free = twl4030_pwm_free, .free = twl4030_pwm_free,
.owner = THIS_MODULE,
}; };
static const struct pwm_ops twl6030_pwm_ops = { static const struct pwm_ops twl6030_pwm_ops = {
.config = twl_pwm_config, .config = twl_pwm_config,
.enable = twl6030_pwm_enable, .enable = twl6030_pwm_enable,
.disable = twl6030_pwm_disable, .disable = twl6030_pwm_disable,
.owner = THIS_MODULE,
}; };
static int twl_pwm_probe(struct platform_device *pdev) static int twl_pwm_probe(struct platform_device *pdev)
...@@ -333,7 +335,7 @@ static int twl_pwm_remove(struct platform_device *pdev) ...@@ -333,7 +335,7 @@ static int twl_pwm_remove(struct platform_device *pdev)
} }
#ifdef CONFIG_OF #ifdef CONFIG_OF
static struct of_device_id twl_pwm_of_match[] = { static const struct of_device_id twl_pwm_of_match[] = {
{ .compatible = "ti,twl4030-pwm" }, { .compatible = "ti,twl4030-pwm" },
{ .compatible = "ti,twl6030-pwm" }, { .compatible = "ti,twl6030-pwm" },
{ }, { },
......
...@@ -274,7 +274,7 @@ static int pwm_backlight_remove(struct platform_device *pdev) ...@@ -274,7 +274,7 @@ static int pwm_backlight_remove(struct platform_device *pdev)
return 0; return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM_SLEEP
static int pwm_backlight_suspend(struct device *dev) static int pwm_backlight_suspend(struct device *dev)
{ {
struct backlight_device *bl = dev_get_drvdata(dev); struct backlight_device *bl = dev_get_drvdata(dev);
...@@ -296,19 +296,16 @@ static int pwm_backlight_resume(struct device *dev) ...@@ -296,19 +296,16 @@ static int pwm_backlight_resume(struct device *dev)
backlight_update_status(bl); backlight_update_status(bl);
return 0; return 0;
} }
#endif
static SIMPLE_DEV_PM_OPS(pwm_backlight_pm_ops, pwm_backlight_suspend, static SIMPLE_DEV_PM_OPS(pwm_backlight_pm_ops, pwm_backlight_suspend,
pwm_backlight_resume); pwm_backlight_resume);
#endif
static struct platform_driver pwm_backlight_driver = { static struct platform_driver pwm_backlight_driver = {
.driver = { .driver = {
.name = "pwm-backlight", .name = "pwm-backlight",
.owner = THIS_MODULE, .owner = THIS_MODULE,
#ifdef CONFIG_PM
.pm = &pwm_backlight_pm_ops, .pm = &pwm_backlight_pm_ops,
#endif
.of_match_table = of_match_ptr(pwm_backlight_of_match), .of_match_table = of_match_ptr(pwm_backlight_of_match),
}, },
.probe = pwm_backlight_probe, .probe = pwm_backlight_probe,
......
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