Source
static void jz4740_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
/*
* Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
* JZ4740 platform PWM support
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
struct jz4740_pwm_chip {
struct pwm_chip chip;
struct clk *clk;
};
static inline struct jz4740_pwm_chip *to_jz4740(struct pwm_chip *chip)
{
return container_of(chip, struct jz4740_pwm_chip, chip);
}
static int jz4740_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
{
/*
* Timers 0 and 1 are used for system tasks, so they are unavailable
* for use as PWMs.
*/
if (pwm->hwpwm < 2)
return -EBUSY;
jz4740_timer_start(pwm->hwpwm);
return 0;
}
static void jz4740_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
{
jz4740_timer_set_ctrl(pwm->hwpwm, 0);
jz4740_timer_stop(pwm->hwpwm);
}
static int jz4740_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
{
uint32_t ctrl = jz4740_timer_get_ctrl(pwm->pwm);