#include <linux/acpi.h>
#include <linux/gpio/driver.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/pwm.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/pm_runtime.h>
#include <linux/bitmap.h>
#define PCA9685_MODE1 …
#define PCA9685_MODE2 …
#define PCA9685_SUBADDR1 …
#define PCA9685_SUBADDR2 …
#define PCA9685_SUBADDR3 …
#define PCA9685_ALLCALLADDR …
#define PCA9685_LEDX_ON_L …
#define PCA9685_LEDX_ON_H …
#define PCA9685_LEDX_OFF_L …
#define PCA9685_LEDX_OFF_H …
#define PCA9685_ALL_LED_ON_L …
#define PCA9685_ALL_LED_ON_H …
#define PCA9685_ALL_LED_OFF_L …
#define PCA9685_ALL_LED_OFF_H …
#define PCA9685_PRESCALE …
#define PCA9685_PRESCALE_MIN …
#define PCA9685_PRESCALE_MAX …
#define PCA9685_COUNTER_RANGE …
#define PCA9685_OSC_CLOCK_MHZ …
#define PCA9685_NUMREGS …
#define PCA9685_MAXCHAN …
#define LED_FULL …
#define MODE1_ALLCALL …
#define MODE1_SUB3 …
#define MODE1_SUB2 …
#define MODE1_SUB1 …
#define MODE1_SLEEP …
#define MODE2_INVRT …
#define MODE2_OUTDRV …
#define LED_N_ON_H(N) …
#define LED_N_ON_L(N) …
#define LED_N_OFF_H(N) …
#define LED_N_OFF_L(N) …
#define REG_ON_H(C) …
#define REG_ON_L(C) …
#define REG_OFF_H(C) …
#define REG_OFF_L(C) …
struct pca9685 { … };
static inline struct pca9685 *to_pca(struct pwm_chip *chip)
{ … }
static bool pca9685_prescaler_can_change(struct pca9685 *pca, int channel)
{ … }
static int pca9685_read_reg(struct pwm_chip *chip, unsigned int reg, unsigned int *val)
{ … }
static int pca9685_write_reg(struct pwm_chip *chip, unsigned int reg, unsigned int val)
{ … }
static void pca9685_pwm_set_duty(struct pwm_chip *chip, int channel, unsigned int duty)
{ … }
static unsigned int pca9685_pwm_get_duty(struct pwm_chip *chip, int channel)
{ … }
#if IS_ENABLED(CONFIG_GPIOLIB)
static bool pca9685_pwm_test_and_set_inuse(struct pca9685 *pca, int pwm_idx)
{ … }
static void pca9685_pwm_clear_inuse(struct pca9685 *pca, int pwm_idx)
{ … }
static int pca9685_pwm_gpio_request(struct gpio_chip *gpio, unsigned int offset)
{ … }
static int pca9685_pwm_gpio_get(struct gpio_chip *gpio, unsigned int offset)
{ … }
static void pca9685_pwm_gpio_set(struct gpio_chip *gpio, unsigned int offset,
int value)
{ … }
static void pca9685_pwm_gpio_free(struct gpio_chip *gpio, unsigned int offset)
{ … }
static int pca9685_pwm_gpio_get_direction(struct gpio_chip *chip,
unsigned int offset)
{ … }
static int pca9685_pwm_gpio_direction_input(struct gpio_chip *gpio,
unsigned int offset)
{ … }
static int pca9685_pwm_gpio_direction_output(struct gpio_chip *gpio,
unsigned int offset, int value)
{ … }
static int pca9685_pwm_gpio_probe(struct pwm_chip *chip)
{ … }
#else
static inline bool pca9685_pwm_test_and_set_inuse(struct pca9685 *pca,
int pwm_idx)
{
return false;
}
static inline void
pca9685_pwm_clear_inuse(struct pca9685 *pca, int pwm_idx)
{
}
static inline int pca9685_pwm_gpio_probe(struct pwm_chip *chip)
{
return 0;
}
#endif
static void pca9685_set_sleep_mode(struct pwm_chip *chip, bool enable)
{ … }
static int __pca9685_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
const struct pwm_state *state)
{ … }
static int pca9685_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
const struct pwm_state *state)
{ … }
static int pca9685_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
struct pwm_state *state)
{ … }
static int pca9685_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
{ … }
static void pca9685_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
{ … }
static const struct pwm_ops pca9685_pwm_ops = …;
static const struct regmap_config pca9685_regmap_i2c_config = …;
static int pca9685_pwm_probe(struct i2c_client *client)
{ … }
static void pca9685_pwm_remove(struct i2c_client *client)
{ … }
static int __maybe_unused pca9685_pwm_runtime_suspend(struct device *dev)
{ … }
static int __maybe_unused pca9685_pwm_runtime_resume(struct device *dev)
{ … }
static const struct i2c_device_id pca9685_id[] = …;
MODULE_DEVICE_TABLE(i2c, pca9685_id);
#ifdef CONFIG_ACPI
static const struct acpi_device_id pca9685_acpi_ids[] = …;
MODULE_DEVICE_TABLE(acpi, pca9685_acpi_ids);
#endif
#ifdef CONFIG_OF
static const struct of_device_id pca9685_dt_ids[] = …;
MODULE_DEVICE_TABLE(of, pca9685_dt_ids);
#endif
static const struct dev_pm_ops pca9685_pwm_pm = …;
static struct i2c_driver pca9685_i2c_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;