mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-26 06:33:19 -04:00
pwm: Changes for v4.3-rc1
This set of changes introduces the beginnings of a new API that's based around the concept of states that can be atomically applied. Drivers go to various lengths to implement something similar, which indicates that the core should really be providing the necessary framework. On top of that, there is a bit of cleanup as well as improved kerneldoc and integration into the device-drivers DocBook. Regarding drivers there is a new one for the NXP LPC18xx family of SoCs and a couple of fixes for existing drivers (pca9685, Broadcom Kona and Atmel HLCDC). -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJV8DLwAAoJEN0jrNd/PrOhSf4P/RYwdDGB/xvI0ifXS5p9znNA hr6+MUH87+f9NY1jcDye0RrxIkRsckQ3x3fe/nTmODjCSM/cyrWrVAEKbkqE5bZH LTRT6M6jolSAUGXFTBDuHktYdMU9yaD0PJvm0RgBEC7z2BeBmCgCXTFc4paxw2GA NvikouXZX9XDlXp598pHPFoL92vTLevQQMBHYW9myY8cjAOG0X8Dn05xQaC2kRvJ 5q+OD1D/kIEMJxONrpef7bwzPgCkuGTHqqIIm6gLVoPBPGWz43kaZ5+x/j2E98E9 fkfcP+21GvZ/tdAUEkrRnpy5Jnn+Nk0m+yzPtRkvj4TLwPd93EjumiPg5sb53pys ZfoHgnOAArVxEnTYLQk4IyBWcHyyzIxZBKZZpXkMXjY4QVq6wZLAP+vyCAzcm4tV vHqUN5BYAkwYPUNU58fgFWGHg6rFlb2QSN1bIj5opgygWmRbPgmwVj3trvS2Dkoe NOv47pp0OyWvTvx+wLql8BUt1zK1M6QldfPF6pR4FB18SLyKYH89ZbjHTyGdsuCv SiaWrqNB4eRmEKW1MA20Kc4wlF5c2peXVp2EHeddh/oHPES8IVWBPMPwSkJZrpQb bIUMStKlJ/Y1GPo6Dd7njK/kA3GwwsbYXYHmyPm0IRuAeZKrzGzVSIIljbfpL6Vf LBuKRMQHY4iWtF8A5SmY =ymH8 -----END PGP SIGNATURE----- Merge tag 'pwm/for-4.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm Pull pwm updates from Thierry Reding: "This set of changes introduces the beginnings of a new API that's based around the concept of states that can be atomically applied. Drivers go to various lengths to implement something similar, which indicates that the core should really be providing the necessary framework. On top of that, there is a bit of cleanup as well as improved kerneldoc and integration into the device-drivers DocBook. Regarding drivers there is a new one for the NXP LPC18xx family of SoCs and a couple of fixes for existing drivers (pca9685, Broadcom Kona and Atmel HLCDC)" * tag 'pwm/for-4.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: ARM: at91: pwm: atmel-hlcdc: Add at91sam9n12 errata pwm: Add NXP LPC18xx PWM/SCT DT binding documentation pwm: NXP LPC18xx PWM/SCT driver pwm-pca9685: Support changing the output frequency pwm-pca9685: Fix several driver bugs pwm: kona: Modify settings application sequence pwm: pca9685: Drop owner assignment pwm: Add to device-drivers documentation pwm: Clean up kerneldoc pwm: Remove useless whitespace pwm: sysfs: Remove unnecessary padding pwm: sysfs: Properly convert from enum to string pwm: Make use of pwm_get_xxx() helpers where appropriate pwm: Add pwm_get_polarity() helper function pwm: Constify PWM device where possible pwm: Add the pwm_is_enabled() helper
This commit is contained in:
commit
82278fc079
21 changed files with 802 additions and 96 deletions
|
|
@ -79,26 +79,43 @@ enum {
|
|||
PWMF_EXPORTED = 1 << 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct pwm_device - PWM channel object
|
||||
* @label: name of the PWM device
|
||||
* @flags: flags associated with the PWM device
|
||||
* @hwpwm: per-chip relative index of the PWM device
|
||||
* @pwm: global index of the PWM device
|
||||
* @chip: PWM chip providing this PWM device
|
||||
* @chip_data: chip-private data associated with the PWM device
|
||||
* @period: period of the PWM signal (in nanoseconds)
|
||||
* @duty_cycle: duty cycle of the PWM signal (in nanoseconds)
|
||||
* @polarity: polarity of the PWM signal
|
||||
*/
|
||||
struct pwm_device {
|
||||
const char *label;
|
||||
unsigned long flags;
|
||||
unsigned int hwpwm;
|
||||
unsigned int pwm;
|
||||
struct pwm_chip *chip;
|
||||
void *chip_data;
|
||||
const char *label;
|
||||
unsigned long flags;
|
||||
unsigned int hwpwm;
|
||||
unsigned int pwm;
|
||||
struct pwm_chip *chip;
|
||||
void *chip_data;
|
||||
|
||||
unsigned int period; /* in nanoseconds */
|
||||
unsigned int duty_cycle; /* in nanoseconds */
|
||||
enum pwm_polarity polarity;
|
||||
unsigned int period;
|
||||
unsigned int duty_cycle;
|
||||
enum pwm_polarity polarity;
|
||||
};
|
||||
|
||||
static inline bool pwm_is_enabled(const struct pwm_device *pwm)
|
||||
{
|
||||
return test_bit(PWMF_ENABLED, &pwm->flags);
|
||||
}
|
||||
|
||||
static inline void pwm_set_period(struct pwm_device *pwm, unsigned int period)
|
||||
{
|
||||
if (pwm)
|
||||
pwm->period = period;
|
||||
}
|
||||
|
||||
static inline unsigned int pwm_get_period(struct pwm_device *pwm)
|
||||
static inline unsigned int pwm_get_period(const struct pwm_device *pwm)
|
||||
{
|
||||
return pwm ? pwm->period : 0;
|
||||
}
|
||||
|
|
@ -109,7 +126,7 @@ static inline void pwm_set_duty_cycle(struct pwm_device *pwm, unsigned int duty)
|
|||
pwm->duty_cycle = duty;
|
||||
}
|
||||
|
||||
static inline unsigned int pwm_get_duty_cycle(struct pwm_device *pwm)
|
||||
static inline unsigned int pwm_get_duty_cycle(const struct pwm_device *pwm)
|
||||
{
|
||||
return pwm ? pwm->duty_cycle : 0;
|
||||
}
|
||||
|
|
@ -119,6 +136,11 @@ static inline unsigned int pwm_get_duty_cycle(struct pwm_device *pwm)
|
|||
*/
|
||||
int pwm_set_polarity(struct pwm_device *pwm, enum pwm_polarity polarity);
|
||||
|
||||
static inline enum pwm_polarity pwm_get_polarity(const struct pwm_device *pwm)
|
||||
{
|
||||
return pwm ? pwm->polarity : PWM_POLARITY_NORMAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* struct pwm_ops - PWM controller operations
|
||||
* @request: optional hook for requesting a PWM
|
||||
|
|
@ -131,25 +153,18 @@ int pwm_set_polarity(struct pwm_device *pwm, enum pwm_polarity polarity);
|
|||
* @owner: helps prevent removal of modules exporting active PWMs
|
||||
*/
|
||||
struct pwm_ops {
|
||||
int (*request)(struct pwm_chip *chip,
|
||||
struct pwm_device *pwm);
|
||||
void (*free)(struct pwm_chip *chip,
|
||||
struct pwm_device *pwm);
|
||||
int (*config)(struct pwm_chip *chip,
|
||||
struct pwm_device *pwm,
|
||||
int duty_ns, int period_ns);
|
||||
int (*set_polarity)(struct pwm_chip *chip,
|
||||
struct pwm_device *pwm,
|
||||
enum pwm_polarity polarity);
|
||||
int (*enable)(struct pwm_chip *chip,
|
||||
struct pwm_device *pwm);
|
||||
void (*disable)(struct pwm_chip *chip,
|
||||
struct pwm_device *pwm);
|
||||
int (*request)(struct pwm_chip *chip, struct pwm_device *pwm);
|
||||
void (*free)(struct pwm_chip *chip, struct pwm_device *pwm);
|
||||
int (*config)(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
int duty_ns, int period_ns);
|
||||
int (*set_polarity)(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
enum pwm_polarity polarity);
|
||||
int (*enable)(struct pwm_chip *chip, struct pwm_device *pwm);
|
||||
void (*disable)(struct pwm_chip *chip, struct pwm_device *pwm);
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
void (*dbg_show)(struct pwm_chip *chip,
|
||||
struct seq_file *s);
|
||||
void (*dbg_show)(struct pwm_chip *chip, struct seq_file *s);
|
||||
#endif
|
||||
struct module *owner;
|
||||
struct module *owner;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -160,22 +175,24 @@ struct pwm_ops {
|
|||
* @base: number of first PWM controlled by this chip
|
||||
* @npwm: number of PWMs controlled by this chip
|
||||
* @pwms: array of PWM devices allocated by the framework
|
||||
* @of_xlate: request a PWM device given a device tree PWM specifier
|
||||
* @of_pwm_n_cells: number of cells expected in the device tree PWM specifier
|
||||
* @can_sleep: must be true if the .config(), .enable() or .disable()
|
||||
* operations may sleep
|
||||
*/
|
||||
struct pwm_chip {
|
||||
struct device *dev;
|
||||
struct list_head list;
|
||||
const struct pwm_ops *ops;
|
||||
int base;
|
||||
unsigned int npwm;
|
||||
struct device *dev;
|
||||
struct list_head list;
|
||||
const struct pwm_ops *ops;
|
||||
int base;
|
||||
unsigned int npwm;
|
||||
|
||||
struct pwm_device *pwms;
|
||||
struct pwm_device *pwms;
|
||||
|
||||
struct pwm_device * (*of_xlate)(struct pwm_chip *pc,
|
||||
const struct of_phandle_args *args);
|
||||
unsigned int of_pwm_n_cells;
|
||||
bool can_sleep;
|
||||
struct pwm_device * (*of_xlate)(struct pwm_chip *pc,
|
||||
const struct of_phandle_args *args);
|
||||
unsigned int of_pwm_n_cells;
|
||||
bool can_sleep;
|
||||
};
|
||||
|
||||
#if IS_ENABLED(CONFIG_PWM)
|
||||
|
|
|
|||
Loading…
Reference in a new issue