diff options
-rw-r--r-- | drivers/mfd/lm3533-ctrlbank.c | 43 | ||||
-rw-r--r-- | include/linux/mfd/lm3533.h | 7 |
2 files changed, 33 insertions, 17 deletions
diff --git a/drivers/mfd/lm3533-ctrlbank.c b/drivers/mfd/lm3533-ctrlbank.c index adf4c1a542a9..a4cb7a5220a7 100644 --- a/drivers/mfd/lm3533-ctrlbank.c +++ b/drivers/mfd/lm3533-ctrlbank.c | |||
@@ -17,8 +17,11 @@ | |||
17 | #include <linux/mfd/lm3533.h> | 17 | #include <linux/mfd/lm3533.h> |
18 | 18 | ||
19 | 19 | ||
20 | #define LM3533_MAX_CURRENT_MIN 5000 | ||
21 | #define LM3533_MAX_CURRENT_MAX 29800 | ||
22 | #define LM3533_MAX_CURRENT_STEP 800 | ||
23 | |||
20 | #define LM3533_BRIGHTNESS_MAX 255 | 24 | #define LM3533_BRIGHTNESS_MAX 255 |
21 | #define LM3533_MAX_CURRENT_MAX 31 | ||
22 | #define LM3533_PWM_MAX 0x3f | 25 | #define LM3533_PWM_MAX 0x3f |
23 | 26 | ||
24 | #define LM3533_REG_PWM_BASE 0x14 | 27 | #define LM3533_REG_PWM_BASE 0x14 |
@@ -65,6 +68,31 @@ int lm3533_ctrlbank_disable(struct lm3533_ctrlbank *cb) | |||
65 | } | 68 | } |
66 | EXPORT_SYMBOL_GPL(lm3533_ctrlbank_disable); | 69 | EXPORT_SYMBOL_GPL(lm3533_ctrlbank_disable); |
67 | 70 | ||
71 | /* | ||
72 | * Full-scale current. | ||
73 | * | ||
74 | * imax 5000 - 29800 uA (800 uA step) | ||
75 | */ | ||
76 | int lm3533_ctrlbank_set_max_current(struct lm3533_ctrlbank *cb, u16 imax) | ||
77 | { | ||
78 | u8 reg; | ||
79 | u8 val; | ||
80 | int ret; | ||
81 | |||
82 | if (imax < LM3533_MAX_CURRENT_MIN || imax > LM3533_MAX_CURRENT_MAX) | ||
83 | return -EINVAL; | ||
84 | |||
85 | val = (imax - LM3533_MAX_CURRENT_MIN) / LM3533_MAX_CURRENT_STEP; | ||
86 | |||
87 | reg = lm3533_ctrlbank_get_reg(cb, LM3533_REG_MAX_CURRENT_BASE); | ||
88 | ret = lm3533_write(cb->lm3533, reg, val); | ||
89 | if (ret) | ||
90 | dev_err(cb->dev, "failed to set max current\n"); | ||
91 | |||
92 | return ret; | ||
93 | } | ||
94 | EXPORT_SYMBOL_GPL(lm3533_ctrlbank_set_max_current); | ||
95 | |||
68 | #define lm3533_ctrlbank_set(_name, _NAME) \ | 96 | #define lm3533_ctrlbank_set(_name, _NAME) \ |
69 | int lm3533_ctrlbank_set_##_name(struct lm3533_ctrlbank *cb, u8 val) \ | 97 | int lm3533_ctrlbank_set_##_name(struct lm3533_ctrlbank *cb, u8 val) \ |
70 | { \ | 98 | { \ |
@@ -102,19 +130,6 @@ lm3533_ctrlbank_set(brightness, BRIGHTNESS); | |||
102 | lm3533_ctrlbank_get(brightness, BRIGHTNESS); | 130 | lm3533_ctrlbank_get(brightness, BRIGHTNESS); |
103 | 131 | ||
104 | /* | 132 | /* |
105 | * Full scale current. | ||
106 | * | ||
107 | * Imax = 5 + val * 0.8 mA, e.g.: | ||
108 | * | ||
109 | * 0 - 5 mA | ||
110 | * ... | ||
111 | * 19 - 20.2 mA (default) | ||
112 | * ... | ||
113 | * 31 - 29.8 mA | ||
114 | */ | ||
115 | lm3533_ctrlbank_set(max_current, MAX_CURRENT); | ||
116 | |||
117 | /* | ||
118 | * PWM-input control mask: | 133 | * PWM-input control mask: |
119 | * | 134 | * |
120 | * bit 5 - PWM-input enabled in Zone 4 | 135 | * bit 5 - PWM-input enabled in Zone 4 |
diff --git a/include/linux/mfd/lm3533.h b/include/linux/mfd/lm3533.h index 7cfef9e4f41b..9660febe93c2 100644 --- a/include/linux/mfd/lm3533.h +++ b/include/linux/mfd/lm3533.h | |||
@@ -47,15 +47,15 @@ struct lm3533_als_platform_data { | |||
47 | 47 | ||
48 | struct lm3533_bl_platform_data { | 48 | struct lm3533_bl_platform_data { |
49 | char *name; | 49 | char *name; |
50 | u16 max_current; /* 5000 - 29800 uA (800 uA step) */ | ||
50 | u8 default_brightness; /* 0 - 255 */ | 51 | u8 default_brightness; /* 0 - 255 */ |
51 | u8 max_current; /* 0 - 31 */ | ||
52 | u8 pwm; /* 0 - 0x3f */ | 52 | u8 pwm; /* 0 - 0x3f */ |
53 | }; | 53 | }; |
54 | 54 | ||
55 | struct lm3533_led_platform_data { | 55 | struct lm3533_led_platform_data { |
56 | char *name; | 56 | char *name; |
57 | const char *default_trigger; | 57 | const char *default_trigger; |
58 | u8 max_current; /* 0 - 31 */ | 58 | u16 max_current; /* 5000 - 29800 uA (800 uA step) */ |
59 | u8 pwm; /* 0 - 0x3f */ | 59 | u8 pwm; /* 0 - 0x3f */ |
60 | }; | 60 | }; |
61 | 61 | ||
@@ -91,7 +91,8 @@ extern int lm3533_ctrlbank_disable(struct lm3533_ctrlbank *cb); | |||
91 | 91 | ||
92 | extern int lm3533_ctrlbank_set_brightness(struct lm3533_ctrlbank *cb, u8 val); | 92 | extern int lm3533_ctrlbank_set_brightness(struct lm3533_ctrlbank *cb, u8 val); |
93 | extern int lm3533_ctrlbank_get_brightness(struct lm3533_ctrlbank *cb, u8 *val); | 93 | extern int lm3533_ctrlbank_get_brightness(struct lm3533_ctrlbank *cb, u8 *val); |
94 | extern int lm3533_ctrlbank_set_max_current(struct lm3533_ctrlbank *cb, u8 val); | 94 | extern int lm3533_ctrlbank_set_max_current(struct lm3533_ctrlbank *cb, |
95 | u16 imax); | ||
95 | extern int lm3533_ctrlbank_set_pwm(struct lm3533_ctrlbank *cb, u8 val); | 96 | extern int lm3533_ctrlbank_set_pwm(struct lm3533_ctrlbank *cb, u8 val); |
96 | extern int lm3533_ctrlbank_get_pwm(struct lm3533_ctrlbank *cb, u8 *val); | 97 | extern int lm3533_ctrlbank_get_pwm(struct lm3533_ctrlbank *cb, u8 *val); |
97 | 98 | ||