]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge tag 'pwm/for-4.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry...
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 25 May 2016 17:40:15 +0000 (10:40 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 25 May 2016 17:40:15 +0000 (10:40 -0700)
Pull pwm updates from Thierry Reding:
 "This set of changes introduces an atomic API to the PWM subsystem.
  This is influenced by the DRM atomic API that was introduced a while
  back, though it is obviously a lot simpler.  The fundamental idea
  remains the same, though: drivers provide a single callback to
  implement the atomic configuration of a PWM channel.

  As a side-effect the PWM subsystem gains the ability for initial state
  retrieval, so that the logical state mirrors that of the hardware.
  Many use-cases don't care about this, but for others it is essential.

  These new features require changes in all users, which these patches
  take care of.  The core is transitioned to use the atomic callback if
  available and provides a fallback mechanism for other drivers.

  Changes to transition users and drivers to the atomic API are
  postponed to v4.8"

* tag 'pwm/for-4.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: (30 commits)
  pwm: Add information about polarity, duty cycle and period to debugfs
  pwm: Switch to the atomic API
  pwm: Update documentation
  pwm: Add core infrastructure to allow atomic updates
  pwm: Add hardware readout infrastructure
  pwm: Move the enabled/disabled info into pwm_state
  pwm: Introduce the pwm_state concept
  pwm: Keep PWM state in sync with hardware state
  ARM: Explicitly apply PWM config extracted from pwm_args
  drm: i915: Explicitly apply PWM config extracted from pwm_args
  input: misc: pwm-beeper: Explicitly apply PWM config extracted from pwm_args
  input: misc: max8997: Explicitly apply PWM config extracted from pwm_args
  backlight: lm3630a: explicitly apply PWM config extracted from pwm_args
  backlight: lp855x: Explicitly apply PWM config extracted from pwm_args
  backlight: lp8788: Explicitly apply PWM config extracted from pwm_args
  backlight: pwm_bl: Use pwm_get_args() where appropriate
  fbdev: ssd1307fb: Use pwm_get_args() where appropriate
  regulator: pwm: Use pwm_get_args() where appropriate
  leds: pwm: Use pwm_get_args() where appropriate
  input: misc: max77693: Use pwm_get_args() where appropriate
  ...

1  2 
drivers/gpu/drm/i915/intel_panel.c
drivers/input/misc/max8997_haptic.c
drivers/video/fbdev/ssd1307fb.c

index a0788763757b0d650ab25d213aea9d1b5c8c032d,dc3a2e4f74c2bc27b7f0a4debd3a15fbd39d3ea9..8357d571553a56471ff42ab0f048bab7f52f475f
@@@ -504,7 -504,7 +504,7 @@@ static u32 i9xx_get_backlight(struct in
        if (panel->backlight.combination_mode) {
                u8 lbpc;
  
 -              pci_read_config_byte(dev_priv->dev->pdev, PCI_LBPC, &lbpc);
 +              pci_read_config_byte(dev_priv->dev->pdev, LBPC, &lbpc);
                val *= lbpc;
        }
  
@@@ -592,7 -592,7 +592,7 @@@ static void i9xx_set_backlight(struct i
  
                lbpc = level * 0xfe / panel->backlight.max + 1;
                level /= lbpc;
 -              pci_write_config_byte(dev_priv->dev->pdev, PCI_LBPC, lbpc);
 +              pci_write_config_byte(dev_priv->dev->pdev, LBPC, lbpc);
        }
  
        if (IS_GEN4(dev_priv)) {
@@@ -1240,7 -1240,7 +1240,7 @@@ static void intel_backlight_device_unre
   */
  static u32 bxt_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
  {
 -      return KHz(19200) / pwm_freq_hz;
 +      return DIV_ROUND_CLOSEST(KHz(19200), pwm_freq_hz);
  }
  
  /*
  static u32 spt_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
  {
        struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
 -      u32 mul, clock;
 +      u32 mul;
  
        if (I915_READ(SOUTH_CHICKEN1) & SPT_PWM_GRANULARITY)
                mul = 128;
        else
                mul = 16;
  
 -      clock = MHz(24);
 -
 -      return clock / (pwm_freq_hz * mul);
 +      return DIV_ROUND_CLOSEST(MHz(24), pwm_freq_hz * mul);
  }
  
  /*
@@@ -1281,7 -1283,7 +1281,7 @@@ static u32 lpt_hz_to_pwm(struct intel_c
        else
                clock = MHz(24); /* LPT:LP */
  
 -      return clock / (pwm_freq_hz * mul);
 +      return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * mul);
  }
  
  /*
   */
  static u32 pch_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
  {
 -      struct drm_device *dev = connector->base.dev;
 -      int clock = MHz(intel_pch_rawclk(dev));
 +      struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
  
 -      return clock / (pwm_freq_hz * 128);
 +      return DIV_ROUND_CLOSEST(KHz(dev_priv->rawclk_freq), pwm_freq_hz * 128);
  }
  
  /*
   */
  static u32 i9xx_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
  {
 -      struct drm_device *dev = connector->base.dev;
 -      struct drm_i915_private *dev_priv = dev->dev_private;
 +      struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
        int clock;
  
 -      if (IS_PINEVIEW(dev))
 -              clock = MHz(intel_hrawclk(dev));
 +      if (IS_PINEVIEW(dev_priv))
 +              clock = KHz(dev_priv->rawclk_freq);
        else
 -              clock = 1000 * dev_priv->cdclk_freq;
 +              clock = KHz(dev_priv->cdclk_freq);
  
 -      return clock / (pwm_freq_hz * 32);
 +      return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * 32);
  }
  
  /*
@@@ -1328,11 -1332,11 +1328,11 @@@ static u32 i965_hz_to_pwm(struct intel_
        int clock;
  
        if (IS_G4X(dev_priv))
 -              clock = MHz(intel_hrawclk(dev));
 +              clock = KHz(dev_priv->rawclk_freq);
        else
 -              clock = 1000 * dev_priv->cdclk_freq;
 +              clock = KHz(dev_priv->cdclk_freq);
  
 -      return clock / (pwm_freq_hz * 128);
 +      return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * 128);
  }
  
  /*
   */
  static u32 vlv_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
  {
 -      struct drm_device *dev = connector->base.dev;
 -      struct drm_i915_private *dev_priv = dev->dev_private;
 -      int clock;
 +      struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
 +      int mul, clock;
  
        if ((I915_READ(CBR1_VLV) & CBR_PWM_CLOCK_MUX_SELECT) == 0) {
 -              if (IS_CHERRYVIEW(dev))
 -                      return KHz(19200) / (pwm_freq_hz * 16);
 +              if (IS_CHERRYVIEW(dev_priv))
 +                      clock = KHz(19200);
                else
 -                      return MHz(25) / (pwm_freq_hz * 16);
 +                      clock = MHz(25);
 +              mul = 16;
        } else {
 -              clock = intel_hrawclk(dev);
 -              return MHz(clock) / (pwm_freq_hz * 128);
 +              clock = KHz(dev_priv->rawclk_freq);
 +              mul = 128;
        }
 +
 +      return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * mul);
  }
  
  static u32 get_backlight_max_vbt(struct intel_connector *connector)
@@@ -1638,6 -1640,12 +1638,12 @@@ static int pwm_setup_backlight(struct i
                return -ENODEV;
        }
  
+       /*
+        * FIXME: pwm_apply_args() should be removed when switching to
+        * the atomic PWM API.
+        */
+       pwm_apply_args(panel->backlight.pwm);
        retval = pwm_config(panel->backlight.pwm, CRC_PMIC_PWM_PERIOD_NS,
                            CRC_PMIC_PWM_PERIOD_NS);
        if (retval < 0) {
@@@ -1743,7 -1751,7 +1749,7 @@@ intel_panel_init_backlight_funcs(struc
                panel->backlight.get = pch_get_backlight;
                panel->backlight.hz_to_pwm = pch_hz_to_pwm;
        } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
 -              if (dev_priv->vbt.has_mipi) {
 +              if (connector->base.connector_type == DRM_MODE_CONNECTOR_DSI) {
                        panel->backlight.setup = pwm_setup_backlight;
                        panel->backlight.enable = pwm_enable_backlight;
                        panel->backlight.disable = pwm_disable_backlight;
index 8d6326d7e7beaf1875bb95af385dff1285f10b0e,bf17f654ed8886d746b8f6dcb5b839b6cc2f1fb0..99bc762881d5d40bc0c0788a59698f227da8737d
@@@ -255,14 -255,12 +255,14 @@@ static int max8997_haptic_probe(struct 
        struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
        const struct max8997_platform_data *pdata =
                                        dev_get_platdata(iodev->dev);
 -      const struct max8997_haptic_platform_data *haptic_pdata =
 -                                      pdata->haptic_pdata;
 +      const struct max8997_haptic_platform_data *haptic_pdata = NULL;
        struct max8997_haptic *chip;
        struct input_dev *input_dev;
        int error;
  
 +      if (pdata)
 +              haptic_pdata = pdata->haptic_pdata;
 +
        if (!haptic_pdata) {
                dev_err(&pdev->dev, "no haptic platform data\n");
                return -EINVAL;
                                error);
                        goto err_free_mem;
                }
+               /*
+                * FIXME: pwm_apply_args() should be removed when switching to
+                * the atomic PWM API.
+                */
+               pwm_apply_args(chip->pwm);
                break;
  
        default:
index 21dafe53ca492421fd6fe747e32ab3f7aa643dbd,652f68880d608c109e49a0c8b6ef23bfe90de013..a9c45c89b15eaca20f6a62957ff92dd20775a6de
@@@ -286,6 -286,7 +286,7 @@@ static int ssd1307fb_init(struct ssd130
  {
        int ret;
        u32 precharge, dclk, com_invdir, compins;
+       struct pwm_args pargs;
  
        if (par->device_info->need_pwm) {
                par->pwm = pwm_get(&par->client->dev, NULL);
                        return PTR_ERR(par->pwm);
                }
  
-               par->pwm_period = pwm_get_period(par->pwm);
+               /*
+                * FIXME: pwm_apply_args() should be removed when switching to
+                * the atomic PWM API.
+                */
+               pwm_apply_args(par->pwm);
+               pwm_get_args(par->pwm, &pargs);
+               par->pwm_period = pargs.period;
                /* Enable the PWM */
                pwm_config(par->pwm, par->pwm_period / 2, par->pwm_period);
                pwm_enable(par->pwm);
                return ret;
  
        ret = ssd1307fb_write_cmd(par->client,
 -              (par->device_info->need_chargepump & 0x1 << 2) & 0x14);
 +              BIT(4) | (par->device_info->need_chargepump ? BIT(2) : 0));
        if (ret < 0)
                return ret;