[PATCH v6]pwm: add BCM2835 PWM driver

Stephen Warren swarren at wwwdotorg.org
Tue Oct 7 08:35:51 PDT 2014


On 10/07/2014 07:04 AM, Bart Tanghe wrote:
> Add pwm driver for Broadcom BCM2835 processor (Raspberry Pi)

Just a few nits below,

> diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c

> +#define PWM_CONTROL_MASK	0xff
> +#define PWM_MODE		0x80		/* set timer in pwm mode */
> +#define DEFAULT		0xff		/* set timer in default mode */

BTW, it'd be nice to say default *what*. Perhaps DEFAULT_PWM_MODE?

> +static int bcm2835_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
> +{
> +	struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
> +	u32 value;
> +
> +	value = readl(pc->base);
> +	value &= ~(PWM_CONTROL_MASK << PWM_CONTROL_STRIDE * pwm->hwpwm);
> +	value |= (PWM_MODE << (PWM_CONTROL_STRIDE * pwm->hwpwm));

Presence/absence of brackets around the STRIDE*pwm calculation is still
inconsistent here, and in other places.

> +static void bcm2835_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
> +{
> +	struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
> +	u32 value;
> +
> +	value = readl(pc->base);
> +	value &= (~DEFAULT << (PWM_CONTROL_STRIDE * pwm->hwpwm));

Why clear the "DEFAULT" bits here; why not use PWM_CONTROL_MASK?



More information about the linux-rpi-kernel mailing list