Re: [PATCH v18] pwm: airoha: Add support for EN7581 SoC
From: Andy Shevchenko
Date: Fri Jun 27 2025 - 04:58:29 EST
On Fri, Jun 27, 2025 at 12:47:53AM +0200, Christian Marangi wrote:
> From: Benjamin Larsson <benjamin.larsson@xxxxxxxxxx>
>
> Introduce driver for PWM module available on EN7581 SoC.
...
> + * Copyright 2025 Markus Gothe <markus.gothe@xxxxxxxxxx>
> + * Christian Marangi <ansuelsmth@xxxxxxxxx>
I'm not sure you can change the copyright line like this. I would rather expect
* Copyright 2012 Markus Gothe <markus.gothe@xxxxxxxxxx>
* Copyright 2025 Christian Marangi <ansuelsmth@xxxxxxxxx>
(Sorry, I forgot the exact original year there, but you got the point)
...
> + /* Global mutex to protect bucket used refcount_t */
> + struct mutex mutex;
This makes a little sense. Either you use refcount_t (which is atomic) or
use mutex + regular variable.
...
> + /*
> + * It is necessary to explicitly shift out all zeros after muxing
> + * to initialize the shift register before enabling PWM
> + * mode because in PWM mode SIPO will not start shifting until
> + * it needs to output a non-zero value (bit 31 of led_data
> + * indicates shifting in progress and it must return to zero
> + * before led_data can be written or PWM mode can be set)
Missing period at the end.
> + */
...
> +static void airoha_pwm_disable(struct airoha_pwm *pc, struct pwm_device *pwm)
> +{
> + /* Disable PWM and release the bucket */
> + airoha_pwm_config_flash_map(pc, pwm->hwpwm, -1);
> + airoha_pwm_release_bucket_config(pc, pwm->hwpwm);
> +
> + clear_bit(pwm->hwpwm, pc->initialized);
> +
> + /* If no SIPO is used, disable the shift register chip */
> + if (find_next_bit(pc->initialized, AIROHA_PWM_MAX_CHANNELS,
> + AIROHA_PWM_NUM_GPIO) >= AIROHA_PWM_NUM_GPIO)
This can be rewritten as
if (!bitmap_read(pc->initialized, AIROHA_PWM_NUM_GPIO, AIROHA_PWM_NUM_SIPO))
(seems to me that the above code is buggy and has to have a check against the
full size of bitmap).
> + regmap_clear_bits(pc->regmap, AIROHA_PWM_REG_SIPO_FLASH_MODE_CFG,
> + AIROHA_PWM_SERIAL_GPIO_FLASH_MODE);
> +}
--
With Best Regards,
Andy Shevchenko