#include <linux/module.h>
#include <linux/leds.h>
#include <linux/mfd/core.h>
#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/mfd/lm3533.h>
#define LM3533_LVCTRLBANK_MIN …
#define LM3533_LVCTRLBANK_MAX …
#define LM3533_LVCTRLBANK_COUNT …
#define LM3533_RISEFALLTIME_MAX …
#define LM3533_ALS_CHANNEL_LV_MIN …
#define LM3533_ALS_CHANNEL_LV_MAX …
#define LM3533_REG_CTRLBANK_BCONF_BASE …
#define LM3533_REG_PATTERN_ENABLE …
#define LM3533_REG_PATTERN_LOW_TIME_BASE …
#define LM3533_REG_PATTERN_HIGH_TIME_BASE …
#define LM3533_REG_PATTERN_RISETIME_BASE …
#define LM3533_REG_PATTERN_FALLTIME_BASE …
#define LM3533_REG_PATTERN_STEP …
#define LM3533_REG_CTRLBANK_BCONF_MAPPING_MASK …
#define LM3533_REG_CTRLBANK_BCONF_ALS_EN_MASK …
#define LM3533_REG_CTRLBANK_BCONF_ALS_CHANNEL_MASK …
#define LM3533_LED_FLAG_PATTERN_ENABLE …
struct lm3533_led { … };
static inline struct lm3533_led *to_lm3533_led(struct led_classdev *cdev)
{ … }
static inline int lm3533_led_get_ctrlbank_id(struct lm3533_led *led)
{ … }
static inline u8 lm3533_led_get_lv_reg(struct lm3533_led *led, u8 base)
{ … }
static inline u8 lm3533_led_get_pattern(struct lm3533_led *led)
{ … }
static inline u8 lm3533_led_get_pattern_reg(struct lm3533_led *led,
u8 base)
{ … }
static int lm3533_led_pattern_enable(struct lm3533_led *led, int enable)
{ … }
static int lm3533_led_set(struct led_classdev *cdev,
enum led_brightness value)
{ … }
static enum led_brightness lm3533_led_get(struct led_classdev *cdev)
{ … }
#define LM3533_LED_DELAY1_VMIN …
#define LM3533_LED_DELAY2_VMIN …
#define LM3533_LED_DELAY3_VMIN …
#define LM3533_LED_DELAY1_VMAX …
#define LM3533_LED_DELAY2_VMAX …
#define LM3533_LED_DELAY3_VMAX …
#define LM3533_LED_DELAY1_TMIN …
#define LM3533_LED_DELAY2_TMIN …
#define LM3533_LED_DELAY3_TMIN …
#define LM3533_LED_DELAY1_TMAX …
#define LM3533_LED_DELAY2_TMAX …
#define LM3533_LED_DELAY3_TMAX …
#define LM3533_LED_DELAY1_TSTEP …
#define LM3533_LED_DELAY2_TSTEP …
#define LM3533_LED_DELAY3_TSTEP …
#define LM3533_LED_DELAY_ON_MAX …
#define LM3533_LED_DELAY_OFF_MAX …
static u8 time_to_val(unsigned *t, unsigned t_min, unsigned t_step,
u8 v_min, u8 v_max)
{ … }
static u8 lm3533_led_get_hw_delay(unsigned *delay)
{ … }
static u8 lm3533_led_delay_set(struct lm3533_led *led, u8 base,
unsigned long *delay)
{ … }
static int lm3533_led_delay_on_set(struct lm3533_led *led, unsigned long *t)
{ … }
static int lm3533_led_delay_off_set(struct lm3533_led *led, unsigned long *t)
{ … }
static int lm3533_led_blink_set(struct led_classdev *cdev,
unsigned long *delay_on,
unsigned long *delay_off)
{ … }
static ssize_t show_id(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t show_risefalltime(struct device *dev,
struct device_attribute *attr,
char *buf, u8 base)
{ … }
static ssize_t show_risetime(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t show_falltime(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t store_risefalltime(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len, u8 base)
{ … }
static ssize_t store_risetime(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static ssize_t store_falltime(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static ssize_t show_als_channel(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t store_als_channel(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static ssize_t show_als_en(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t store_als_en(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static ssize_t show_linear(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t store_linear(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static ssize_t show_pwm(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t store_pwm(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static LM3533_ATTR_RW(als_channel);
static LM3533_ATTR_RW(als_en);
static LM3533_ATTR_RW(falltime);
static LM3533_ATTR_RO(id);
static LM3533_ATTR_RW(linear);
static LM3533_ATTR_RW(pwm);
static LM3533_ATTR_RW(risetime);
static struct attribute *lm3533_led_attributes[] = …;
static umode_t lm3533_led_attr_is_visible(struct kobject *kobj,
struct attribute *attr, int n)
{
struct device *dev = kobj_to_dev(kobj);
struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct lm3533_led *led = to_lm3533_led(led_cdev);
umode_t mode = attr->mode;
if (attr == &dev_attr_als_channel.attr ||
attr == &dev_attr_als_en.attr) {
if (!led->lm3533->have_als)
mode = 0;
}
return mode;
};
static const struct attribute_group lm3533_led_attribute_group = …;
static const struct attribute_group *lm3533_led_attribute_groups[] = …;
static int lm3533_led_setup(struct lm3533_led *led,
struct lm3533_led_platform_data *pdata)
{ … }
static int lm3533_led_probe(struct platform_device *pdev)
{ … }
static void lm3533_led_remove(struct platform_device *pdev)
{ … }
static void lm3533_led_shutdown(struct platform_device *pdev)
{ … }
static struct platform_driver lm3533_led_driver = …;
module_platform_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_ALIAS(…) …;