Merge tag 'for-3.8-rc1' of git://gitorious.org/linux-pwm/linux-pwm
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 19 Dec 2012 16:19:07 +0000 (08:19 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 19 Dec 2012 16:19:07 +0000 (08:19 -0800)
Pull pwm changes from Thierry Reding:
 "A new driver has been added for the SPEAr platform and the
  TWL4030/6030 driver has been replaced by two drivers that control the
  regular PWMs and the PWM driven LEDs provided by the chips.

  The vt8500, tiecap, tiehrpwm, i.MX, LPC32xx and Samsung drivers have
  all been improved and the device tree bindings now support the PWM
  signal polarity."

Fix up trivial conflicts due to __devinit/exit removal.

* tag 'for-3.8-rc1' of git://gitorious.org/linux-pwm/linux-pwm: (21 commits)
  pwm: samsung: add missing s3c->pwm_id assignment
  pwm: lpc32xx: Set the chip base for dynamic allocation
  pwm: lpc32xx: Properly disable the clock on device removal
  pwm: lpc32xx: Fix the PWM polarity
  pwm: i.MX: eliminate build warning
  pwm: Export of_pwm_xlate_with_flags()
  pwm: Remove pwm-twl6030 driver
  pwm: New driver to support PWM driven LEDs on TWL4030/6030 series of PMICs
  pwm: New driver to support PWMs on TWL4030/6030 series of PMICs
  pwm: pwm-tiehrpwm: pinctrl support
  pwm: tiehrpwm: Add device-tree binding
  pwm: pwm-tiehrpwm: Adding TBCLK gating support.
  pwm: pwm-tiecap: pinctrl support
  pwm: tiecap: Add device-tree binding
  pwm: Add TI PWM subsystem driver
  pwm: Device tree support for PWM polarity
  pwm: vt8500: Ensure PWM clock is enabled during pwm_config
  pwm: vt8500: Fix build error
  pwm: spear: Staticize spear_pwm_config()
  pwm: Add SPEAr PWM chip driver support
  ...

1  2 
drivers/pwm/pwm-imx.c
drivers/pwm/pwm-lpc32xx.c
drivers/pwm/pwm-samsung.c
drivers/pwm/pwm-tiecap.c
drivers/pwm/pwm-tiehrpwm.c

diff --combined drivers/pwm/pwm-imx.c
index 8f26e9fcea976e259443dedfcd9997d67009f7f3,fe3fbdbc86aaeb2333722a3c88e55e42f78c3c71..65a86bdeabedbdfdf35ff66f976cda00114a09a9
@@@ -231,11 -231,11 +231,11 @@@ static const struct of_device_id imx_pw
  };
  MODULE_DEVICE_TABLE(of, imx_pwm_dt_ids);
  
 -static int __devinit imx_pwm_probe(struct platform_device *pdev)
 +static int imx_pwm_probe(struct platform_device *pdev)
  {
        const struct of_device_id *of_id =
                        of_match_device(imx_pwm_dt_ids, &pdev->dev);
-       struct imx_pwm_data *data;
+       const struct imx_pwm_data *data;
        struct imx_chip *imx;
        struct resource *r;
        int ret = 0;
        return 0;
  }
  
 -static int __devexit imx_pwm_remove(struct platform_device *pdev)
 +static int imx_pwm_remove(struct platform_device *pdev)
  {
        struct imx_chip *imx;
  
@@@ -307,7 -307,7 +307,7 @@@ static struct platform_driver imx_pwm_d
                .of_match_table = of_match_ptr(imx_pwm_dt_ids),
        },
        .probe          = imx_pwm_probe,
 -      .remove         = __devexit_p(imx_pwm_remove),
 +      .remove         = imx_pwm_remove,
  };
  
  module_platform_driver(imx_pwm_driver);
index 015a82235620e648e3b5f49f974ea9f2f7c01ad7,81db1bd5e92d0380dba9145c99cf0ebb42839651..14106440294fa94fd468563f4bed1212d6f356fe
@@@ -49,9 -49,24 +49,24 @@@ static int lpc32xx_pwm_config(struct pw
                c = 0; /* 0 set division by 256 */
        period_cycles = c;
  
+       /* The duty-cycle value is as follows:
+        *
+        *  DUTY-CYCLE     HIGH LEVEL
+        *      1            99.9%
+        *      25           90.0%
+        *      128          50.0%
+        *      220          10.0%
+        *      255           0.1%
+        *      0             0.0%
+        *
+        * In other words, the register value is duty-cycle % 256 with
+        * duty-cycle in the range 1-256.
+        */
        c = 256 * duty_ns;
        do_div(c, period_ns);
-       duty_cycles = c;
+       if (c > 255)
+               c = 255;
+       duty_cycles = 256 - c;
  
        writel(PWM_ENABLE | PWM_RELOADV(period_cycles) | PWM_DUTY(duty_cycles),
                lpc32xx->base + (pwm->hwpwm << 2));
@@@ -106,6 -121,7 +121,7 @@@ static int lpc32xx_pwm_probe(struct pla
        lpc32xx->chip.dev = &pdev->dev;
        lpc32xx->chip.ops = &lpc32xx_pwm_ops;
        lpc32xx->chip.npwm = 2;
+       lpc32xx->chip.base = -1;
  
        ret = pwmchip_add(&lpc32xx->chip);
        if (ret < 0) {
        return 0;
  }
  
 -static int __devexit lpc32xx_pwm_remove(struct platform_device *pdev)
 +static int lpc32xx_pwm_remove(struct platform_device *pdev)
  {
        struct lpc32xx_pwm_chip *lpc32xx = platform_get_drvdata(pdev);
+       unsigned int i;
+       for (i = 0; i < lpc32xx->chip.npwm; i++)
+               pwm_disable(&lpc32xx->chip.pwms[i]);
  
-       clk_disable(lpc32xx->clk);
        return pwmchip_remove(&lpc32xx->chip);
  }
  
@@@ -138,7 -157,7 +157,7 @@@ static struct platform_driver lpc32xx_p
                .of_match_table = of_match_ptr(lpc32xx_pwm_dt_ids),
        },
        .probe = lpc32xx_pwm_probe,
 -      .remove = __devexit_p(lpc32xx_pwm_remove),
 +      .remove = lpc32xx_pwm_remove,
  };
  module_platform_driver(lpc32xx_pwm_driver);
  
index e9b15d099c03cb87d668aa500d5752d18e471061,0704a2abd8c67496380456dee7e9d6467609cbc9..5207e6cd8648d0d89a7ecea039b930a6ff5cf6dc
@@@ -222,6 -222,7 +222,7 @@@ static int s3c_pwm_probe(struct platfor
  
        /* calculate base of control bits in TCON */
        s3c->tcon_base = id == 0 ? 0 : (id * 4) + 4;
+       s3c->pwm_id = id;
        s3c->chip.dev = &pdev->dev;
        s3c->chip.ops = &s3c_pwm_ops;
        s3c->chip.base = -1;
        return ret;
  }
  
 -static int __devexit s3c_pwm_remove(struct platform_device *pdev)
 +static int s3c_pwm_remove(struct platform_device *pdev)
  {
        struct s3c_chip *s3c = platform_get_drvdata(pdev);
        int err;
@@@ -327,7 -328,7 +328,7 @@@ static struct platform_driver s3c_pwm_d
                .owner  = THIS_MODULE,
        },
        .probe          = s3c_pwm_probe,
 -      .remove         = __devexit_p(s3c_pwm_remove),
 +      .remove         = s3c_pwm_remove,
        .suspend        = s3c_pwm_suspend,
        .resume         = s3c_pwm_resume,
  };
diff --combined drivers/pwm/pwm-tiecap.c
index 87c091b245cc74a6225504ce4c8d0c0b3e65f2db,b4f9d4756d584da21dda71f0cabd169ca6d05479..5cf016dd982238f4dac9ba5e4da12194d0e614aa
  #include <linux/clk.h>
  #include <linux/pm_runtime.h>
  #include <linux/pwm.h>
+ #include <linux/of_device.h>
+ #include <linux/pinctrl/consumer.h>
+ #include "pwm-tipwmss.h"
  
  /* ECAP registers and bits definitions */
  #define CAP1                  0x08
@@@ -184,12 -188,24 +188,24 @@@ static const struct pwm_ops ecap_pwm_op
        .owner          = THIS_MODULE,
  };
  
 -static int __devinit ecap_pwm_probe(struct platform_device *pdev)
+ static const struct of_device_id ecap_of_match[] = {
+       { .compatible   = "ti,am33xx-ecap" },
+       {},
+ };
+ MODULE_DEVICE_TABLE(of, ecap_of_match);
 +static int ecap_pwm_probe(struct platform_device *pdev)
  {
        int ret;
        struct resource *r;
        struct clk *clk;
        struct ecap_pwm_chip *pc;
+       u16 status;
+       struct pinctrl *pinctrl;
+       pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
+       if (IS_ERR(pinctrl))
+               dev_warn(&pdev->dev, "unable to select pin group\n");
  
        pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL);
        if (!pc) {
  
        pc->chip.dev = &pdev->dev;
        pc->chip.ops = &ecap_pwm_ops;
+       pc->chip.of_xlate = of_pwm_xlate_with_flags;
+       pc->chip.of_pwm_n_cells = 3;
        pc->chip.base = -1;
        pc->chip.npwm = 1;
  
        }
  
        pm_runtime_enable(&pdev->dev);
+       pm_runtime_get_sync(&pdev->dev);
+       status = pwmss_submodule_state_change(pdev->dev.parent,
+                       PWMSS_ECAPCLK_EN);
+       if (!(status & PWMSS_ECAPCLK_EN_ACK)) {
+               dev_err(&pdev->dev, "PWMSS config space clock enable failed\n");
+               ret = -EINVAL;
+               goto pwmss_clk_failure;
+       }
+       pm_runtime_put_sync(&pdev->dev);
        platform_set_drvdata(pdev, pc);
        return 0;
+ pwmss_clk_failure:
+       pm_runtime_put_sync(&pdev->dev);
+       pm_runtime_disable(&pdev->dev);
+       pwmchip_remove(&pc->chip);
+       return ret;
  }
  
 -static int __devexit ecap_pwm_remove(struct platform_device *pdev)
 +static int ecap_pwm_remove(struct platform_device *pdev)
  {
        struct ecap_pwm_chip *pc = platform_get_drvdata(pdev);
  
+       pm_runtime_get_sync(&pdev->dev);
+       /*
+        * Due to hardware misbehaviour, acknowledge of the stop_req
+        * is missing. Hence checking of the status bit skipped.
+        */
+       pwmss_submodule_state_change(pdev->dev.parent, PWMSS_ECAPCLK_STOP_REQ);
+       pm_runtime_put_sync(&pdev->dev);
        pm_runtime_put_sync(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
        return pwmchip_remove(&pc->chip);
  
  static struct platform_driver ecap_pwm_driver = {
        .driver = {
-               .name = "ecap",
+               .name   = "ecap",
+               .owner  = THIS_MODULE,
+               .of_match_table = ecap_of_match,
        },
        .probe = ecap_pwm_probe,
 -      .remove = __devexit_p(ecap_pwm_remove),
 +      .remove = ecap_pwm_remove,
  };
  
  module_platform_driver(ecap_pwm_driver);
index 9ffd389d0c8b062f651f73be1b46a66dac2fefc3,542d5f38ccf62f295d5e7b9db8dc5f6ac45183f9..72a6dd40c9ec5a566ccdffaffe69d8d4cc13f0af
  #include <linux/err.h>
  #include <linux/clk.h>
  #include <linux/pm_runtime.h>
+ #include <linux/of_device.h>
+ #include <linux/pinctrl/consumer.h>
+ #include "pwm-tipwmss.h"
  
  /* EHRPWM registers and bits definitions */
  
@@@ -115,6 -119,7 +119,7 @@@ struct ehrpwm_pwm_chip 
        void __iomem    *mmio_base;
        unsigned long period_cycles[NUM_PWM_CHANNEL];
        enum pwm_polarity polarity[NUM_PWM_CHANNEL];
+       struct  clk     *tbclk;
  };
  
  static inline struct ehrpwm_pwm_chip *to_ehrpwm_pwm_chip(struct pwm_chip *chip)
@@@ -335,6 -340,9 +340,9 @@@ static int ehrpwm_pwm_enable(struct pwm
        /* Channels polarity can be configured from action qualifier module */
        configure_polarity(pc, pwm->hwpwm);
  
+       /* Enable TBCLK before enabling PWM device */
+       clk_enable(pc->tbclk);
        /* Enable time counter for free_run */
        ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_RUN_MASK, TBCTL_FREE_RUN);
        return 0;
@@@ -363,6 -371,9 +371,9 @@@ static void ehrpwm_pwm_disable(struct p
  
        ehrpwm_modify(pc->mmio_base, AQCSFRC, aqcsfrc_mask, aqcsfrc_val);
  
+       /* Disabling TBCLK on PWM disable */
+       clk_disable(pc->tbclk);
        /* Stop Time base counter */
        ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_RUN_MASK, TBCTL_STOP_NEXT);
  
@@@ -392,12 -403,24 +403,24 @@@ static const struct pwm_ops ehrpwm_pwm_
        .owner          = THIS_MODULE,
  };
  
 -static int __devinit ehrpwm_pwm_probe(struct platform_device *pdev)
+ static const struct of_device_id ehrpwm_of_match[] = {
+       { .compatible   = "ti,am33xx-ehrpwm" },
+       {},
+ };
+ MODULE_DEVICE_TABLE(of, ehrpwm_of_match);
 +static int ehrpwm_pwm_probe(struct platform_device *pdev)
  {
        int ret;
        struct resource *r;
        struct clk *clk;
        struct ehrpwm_pwm_chip *pc;
+       u16 status;
+       struct pinctrl *pinctrl;
+       pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
+       if (IS_ERR(pinctrl))
+               dev_warn(&pdev->dev, "unable to select pin group\n");
  
        pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL);
        if (!pc) {
  
        pc->chip.dev = &pdev->dev;
        pc->chip.ops = &ehrpwm_pwm_ops;
+       pc->chip.of_xlate = of_pwm_xlate_with_flags;
+       pc->chip.of_pwm_n_cells = 3;
        pc->chip.base = -1;
        pc->chip.npwm = NUM_PWM_CHANNEL;
  
        if (!pc->mmio_base)
                return  -EADDRNOTAVAIL;
  
+       /* Acquire tbclk for Time Base EHRPWM submodule */
+       pc->tbclk = devm_clk_get(&pdev->dev, "tbclk");
+       if (IS_ERR(pc->tbclk)) {
+               dev_err(&pdev->dev, "Failed to get tbclk\n");
+               return PTR_ERR(pc->tbclk);
+       }
        ret = pwmchip_add(&pc->chip);
        if (ret < 0) {
                dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
        }
  
        pm_runtime_enable(&pdev->dev);
+       pm_runtime_get_sync(&pdev->dev);
+       status = pwmss_submodule_state_change(pdev->dev.parent,
+                       PWMSS_EPWMCLK_EN);
+       if (!(status & PWMSS_EPWMCLK_EN_ACK)) {
+               dev_err(&pdev->dev, "PWMSS config space clock enable failed\n");
+               ret = -EINVAL;
+               goto pwmss_clk_failure;
+       }
+       pm_runtime_put_sync(&pdev->dev);
        platform_set_drvdata(pdev, pc);
        return 0;
+ pwmss_clk_failure:
+       pm_runtime_put_sync(&pdev->dev);
+       pm_runtime_disable(&pdev->dev);
+       pwmchip_remove(&pc->chip);
+       return ret;
  }
  
 -static int __devexit ehrpwm_pwm_remove(struct platform_device *pdev)
 +static int ehrpwm_pwm_remove(struct platform_device *pdev)
  {
        struct ehrpwm_pwm_chip *pc = platform_get_drvdata(pdev);
  
+       pm_runtime_get_sync(&pdev->dev);
+       /*
+        * Due to hardware misbehaviour, acknowledge of the stop_req
+        * is missing. Hence checking of the status bit skipped.
+        */
+       pwmss_submodule_state_change(pdev->dev.parent, PWMSS_EPWMCLK_STOP_REQ);
+       pm_runtime_put_sync(&pdev->dev);
        pm_runtime_put_sync(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
        return pwmchip_remove(&pc->chip);
  
  static struct platform_driver ehrpwm_pwm_driver = {
        .driver = {
-               .name = "ehrpwm",
+               .name   = "ehrpwm",
+               .owner  = THIS_MODULE,
+               .of_match_table = ehrpwm_of_match,
        },
        .probe = ehrpwm_pwm_probe,
 -      .remove = __devexit_p(ehrpwm_pwm_remove),
 +      .remove = ehrpwm_pwm_remove,
  };
  
  module_platform_driver(ehrpwm_pwm_driver);