All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7 0/2] pwm: add support for NXPs high-side switch MC33XS2410
@ 2024-11-09 17:41 Dimitri Fedrau
  2024-11-09 17:41 ` [PATCH v7 1/2] dt-bindings: pwm: add support for MC33XS2410 Dimitri Fedrau
  2024-11-09 17:41 ` [PATCH v7 2/2] pwm: add support for NXPs high-side switch MC33XS2410 Dimitri Fedrau
  0 siblings, 2 replies; 7+ messages in thread
From: Dimitri Fedrau @ 2024-11-09 17:41 UTC (permalink / raw)
  Cc: Dimitri Fedrau, Uwe Kleine-König, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, linux-pwm, devicetree,
	linux-kernel

The MC33XS2410 is a four channel high-side switch. Featuring advanced
monitoring and control function, the device is operational from 3.0 V to
60 V. The device is controlled by SPI port for configuration.

Changes in V2:
  - fix title in devicetree binding
  - fix commit message in devicetree binding patch
  - remove external clock from pwms and create clocks property
  - switch to unevaluatedProperties: false
  - add missing properties for complete example:
    - pwm-names
    - pwms
    - interrupts
    - clocks

Changes in V3:
  - Add description of the general behaviour of the device (limitations)
  - Drop unused defines
  - Add ranges comments for defines with parameters
  - Drop MC33XS2410_PERIOD_MAX, MC33XS2410_PERIOD_MIN defines
  - Drop mc33xs2410_period variable
  - Round down when calculating period and duty cycle
  - Use switch instead of loop when calculating frequency
  - Removed ret variable in mc33xs2410_pwm_get_freq
  - Handle all accesses in a single call to spi_sync_transfer
  - Fix comments in function mc33xs2410_pwm_get_period
  - Fix call pwm_set_relative_duty_cycle(state, ret, 255), instead
    pwm_set_relative_duty_cycle(state, val[1] + 1, 256);
  - Use devm_pwmchip_alloc
  - Fix typo s/Transitition/Transition/
  - Drop driver_data
  - Removed patch for direct inputs from series
  - Tested with PWM_DEBUG enabled, didn't before !

Changes in V4:
  - removed include of math.h, already included in math64.h
  - removed include of mutex.h, no mutexes are used
  - added include of bitfield.h(FIELD_GET, FIELD_PREP), fixes errors
    discovered by kernel test robot
  - cast parameters in DIV_ROUND_UP to u32, fixes errors discovered by
    kernel test robot

Changes in V5:
  - Fix comment in mc33xs2410_pwm_get_freq, selecting steps instead of
    period
  - Add comment in mc33xs2410_pwm_get_relative_duty_cycle that duty_cycle
    cannot overflow and and period is not zero, guaranteed by the caller
  - Hardware emits a low level when disabled, disable if duty_cycle = 0 is
    requested.
  - Fix complaints when PWM_DEBUG enabled, round-down division in
    mc33xs2410_pwm_apply and round-up in mc33xs2410_pwm_get_state.
  - Add comment for disabling watchdog in probe

Changes in V6:
  - Add link to manual
  - Redefine MC33XS2410_GLB_CTRL_MODE_MASK as MC33XS2410_GLB_CTRL_MODE and
    MC33XS2410_GLB_CTRL_NORMAL_MODE as MC33XS2410_GLB_CTRL_MODE_NORMAL
  - Remove define MC33XS2410_MIN_PERIOD_STEP(x) as there is no need for
    parameters and use instead MC33XS2410_MIN_PERIOD
  - Rename function to_pwm_mc33xs2410_chip to mc33xs2410_from_chip
  - Add comment in mc33xs2410_pwm_get_freq why count should be rounded up
  - Fix incorrect comment in mc33xs2410_pwm_get_period
  - Rename steps variable to doubled_steps in function
    mc33xs2410_pwm_get_freq
  - remove cast in mc33xs2410_pwm_set_relative_duty_cycle
  - remove duty_cycle from if in mc33xs2410_pwm_set_relative_duty_cycle

Changes in V7:
  - Add empty lines for defines with parameter
  - Hardcode into:
    - MC33XS2410_PWM_DC1 -> MC33XS2410_PWM_DC
    - MC33XS2410_PWM_FREQ1 -> MC33XS2410_PWM_FREQ
    - MC33XS2410_MAX_PERIOD_STEP0 -> MC33XS2410_MAX_PERIOD_STEP
  - Rename:
    - MC33XS2410_MIN_PERIOD -> MC33XS2410_PWM_MIN_PERIOD
    - MC33XS2410_MAX_PERIOD_STEP -> MC33XS2410_PWM_MAX_PERIOD
    - MC33XS2410_WR -> MC33XS2410_FRAME_IN_ADDR_WR
    - MC33XS2410_RD_CTRL -> MC33XS2410_FRAME_IN_DATA_RD
    - MC33XS2410_RD_DATA_MASK -> MC33XS2410_FRAME_OUT_DATA
  - Change range for MC33XS2410_PWM_CTRL1_POL_INV
  - Drop mask suffixes
  - Switch to unsigned int len in mc33xs2410_write_regs and
    mc33xs2410_read_regs
  - Remove define MC33XS2410_WORD_LEN
  - Use a single spi transfer in mc33xs2410_write_regs and
    mc33xs2410_read_regs by using SPI_CS_WORD and 16 bits per word
  - Break the line in the argument list instead of having a static in its
    own for mc33xs2410_read_reg definition
  - Remove u32 cast mc33xs2410_pwm_get_period
  - Unroll mc33xs2410_pwm_get_relative_duty_cycle
  - Unroll mc33xs2410_pwm_set_relative_duty_cycle and remove check for
    state->enabled
  - Remove ctrl[x] and use instead a u8 flag which indicates from which
    registers to read

Dimitri Fedrau (2):
  dt-bindings: pwm: add support for MC33XS2410
  pwm: add support for NXPs high-side switch MC33XS2410

 .../bindings/pwm/nxp,mc33xs2410.yaml          | 118 ++++++
 drivers/pwm/Kconfig                           |  12 +
 drivers/pwm/Makefile                          |   1 +
 drivers/pwm/pwm-mc33xs2410.c                  | 388 ++++++++++++++++++
 4 files changed, 519 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pwm/nxp,mc33xs2410.yaml
 create mode 100644 drivers/pwm/pwm-mc33xs2410.c

-- 
2.39.5


^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [PATCH v7 2/2] pwm: add support for NXPs high-side switch MC33XS2410
@ 2024-11-12 15:02 kernel test robot
  0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2024-11-12 15:02 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20241109174135.26292-3-dima.fedrau@gmail.com>
References: <20241109174135.26292-3-dima.fedrau@gmail.com>
TO: Dimitri Fedrau <dima.fedrau@gmail.com>
CC: Dimitri Fedrau <dima.fedrau@gmail.com>
CC: "Uwe Kleine-König" <ukleinek@kernel.org>
CC: Rob Herring <robh+dt@kernel.org>
CC: Krzysztof Kozlowski <krzk@kernel.org>
CC: Conor Dooley <conor+dt@kernel.org>
CC: linux-pwm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org

Hi Dimitri,

kernel test robot noticed the following build warnings:

[auto build test WARNING on robh/for-next]
[also build test WARNING on linus/master v6.12-rc7 next-20241112]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Dimitri-Fedrau/dt-bindings-pwm-add-support-for-MC33XS2410/20241110-014336
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20241109174135.26292-3-dima.fedrau%40gmail.com
patch subject: [PATCH v7 2/2] pwm: add support for NXPs high-side switch MC33XS2410
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: s390-randconfig-r073-20241112 (https://download.01.org/0day-ci/archive/20241112/202411122253.03yKXFpX-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 14.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202411122253.03yKXFpX-lkp@intel.com/

smatch warnings:
drivers/pwm/pwm-mc33xs2410.c:184 mc33xs2410_pwm_get_freq() error: uninitialized symbol 'step'.

vim +/step +184 drivers/pwm/pwm-mc33xs2410.c

23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  152  
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  153  static u8 mc33xs2410_pwm_get_freq(u64 period)
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  154  {
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  155  	u8 step, count;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  156  
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  157  	/*
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  158  	 * Check which step is appropriate for the given period, starting with
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  159  	 * the highest frequency(lowest period). Higher frequencies are
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  160  	 * represented with better resolution by the device. Therefore favor
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  161  	 * frequency range with the better resolution to minimize error
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  162  	 * introduced by the frequency steps.
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  163  	 */
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  164  
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  165  	switch (period) {
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  166  	case MC33XS2410_PWM_MIN_PERIOD ... MC33XS2410_PWM_MAX_PERIOD(3):
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  167  		step = 3;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  168  		break;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  169  	case MC33XS2410_PWM_MAX_PERIOD(3) + 1 ... MC33XS2410_PWM_MAX_PERIOD(2):
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  170  		step = 2;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  171  		break;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  172  	case MC33XS2410_PWM_MAX_PERIOD(2) + 1 ... MC33XS2410_PWM_MAX_PERIOD(1):
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  173  		step = 1;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  174  		break;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  175  	case MC33XS2410_PWM_MAX_PERIOD(1) + 1 ... MC33XS2410_PWM_MAX_PERIOD(0):
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  176  		step = 0;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  177  		break;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  178  	}
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  179  
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  180  	/*
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  181  	 * Round up here because a higher count results in a higher frequency
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  182  	 * and so a smaller period.
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  183  	 */
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09 @184  	count = DIV_ROUND_UP((u32)MC33XS2410_PWM_MAX_PERIOD(step), (u32)period);
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  185  	return FIELD_PREP(MC33XS2410_PWM_FREQ_STEP, step) |
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  186  	       FIELD_PREP(MC33XS2410_PWM_FREQ_COUNT, count - 1);
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  187  }
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  188  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [PATCH v7 2/2] pwm: add support for NXPs high-side switch MC33XS2410
@ 2024-11-13  8:37 kernel test robot
  0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2024-11-13  8:37 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20241109174135.26292-3-dima.fedrau@gmail.com>
References: <20241109174135.26292-3-dima.fedrau@gmail.com>
TO: Dimitri Fedrau <dima.fedrau@gmail.com>
CC: Dimitri Fedrau <dima.fedrau@gmail.com>
CC: "Uwe Kleine-König" <ukleinek@kernel.org>
CC: Rob Herring <robh+dt@kernel.org>
CC: Krzysztof Kozlowski <krzk@kernel.org>
CC: Conor Dooley <conor+dt@kernel.org>
CC: linux-pwm@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org

Hi Dimitri,

kernel test robot noticed the following build warnings:

[auto build test WARNING on robh/for-next]
[also build test WARNING on linus/master v6.12-rc7 next-20241112]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Dimitri-Fedrau/dt-bindings-pwm-add-support-for-MC33XS2410/20241110-014336
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20241109174135.26292-3-dima.fedrau%40gmail.com
patch subject: [PATCH v7 2/2] pwm: add support for NXPs high-side switch MC33XS2410
:::::: branch date: 4 days ago
:::::: commit date: 4 days ago
config: s390-randconfig-r073-20241112 (https://download.01.org/0day-ci/archive/20241113/202411131646.RTVxOlpg-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 14.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202411131646.RTVxOlpg-lkp@intel.com/

smatch warnings:
drivers/pwm/pwm-mc33xs2410.c:184 mc33xs2410_pwm_get_freq() error: uninitialized symbol 'step'.

vim +/step +184 drivers/pwm/pwm-mc33xs2410.c

23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  152  
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  153  static u8 mc33xs2410_pwm_get_freq(u64 period)
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  154  {
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  155  	u8 step, count;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  156  
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  157  	/*
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  158  	 * Check which step is appropriate for the given period, starting with
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  159  	 * the highest frequency(lowest period). Higher frequencies are
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  160  	 * represented with better resolution by the device. Therefore favor
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  161  	 * frequency range with the better resolution to minimize error
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  162  	 * introduced by the frequency steps.
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  163  	 */
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  164  
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  165  	switch (period) {
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  166  	case MC33XS2410_PWM_MIN_PERIOD ... MC33XS2410_PWM_MAX_PERIOD(3):
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  167  		step = 3;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  168  		break;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  169  	case MC33XS2410_PWM_MAX_PERIOD(3) + 1 ... MC33XS2410_PWM_MAX_PERIOD(2):
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  170  		step = 2;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  171  		break;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  172  	case MC33XS2410_PWM_MAX_PERIOD(2) + 1 ... MC33XS2410_PWM_MAX_PERIOD(1):
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  173  		step = 1;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  174  		break;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  175  	case MC33XS2410_PWM_MAX_PERIOD(1) + 1 ... MC33XS2410_PWM_MAX_PERIOD(0):
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  176  		step = 0;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  177  		break;
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  178  	}
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  179  
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  180  	/*
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  181  	 * Round up here because a higher count results in a higher frequency
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  182  	 * and so a smaller period.
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  183  	 */
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09 @184  	count = DIV_ROUND_UP((u32)MC33XS2410_PWM_MAX_PERIOD(step), (u32)period);
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  185  	return FIELD_PREP(MC33XS2410_PWM_FREQ_STEP, step) |
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  186  	       FIELD_PREP(MC33XS2410_PWM_FREQ_COUNT, count - 1);
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  187  }
23a0a66c9fc5eb0 Dimitri Fedrau 2024-11-09  188  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-01-09 16:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-09 17:41 [PATCH v7 0/2] pwm: add support for NXPs high-side switch MC33XS2410 Dimitri Fedrau
2024-11-09 17:41 ` [PATCH v7 1/2] dt-bindings: pwm: add support for MC33XS2410 Dimitri Fedrau
2024-11-09 17:41 ` [PATCH v7 2/2] pwm: add support for NXPs high-side switch MC33XS2410 Dimitri Fedrau
2025-01-08  8:01   ` Uwe Kleine-König
2025-01-09 16:21     ` Dimitri Fedrau
  -- strict thread matches above, loose matches on Subject: below --
2024-11-12 15:02 kernel test robot
2024-11-13  8:37 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.