lp5521_wait_opmode_done();
}
- static void lp5521_stop_engine(struct lp55xx_chip *chip)
+ static void lp5521_stop_all_engines(struct lp55xx_chip *chip)
{
lp55xx_write(chip, LP5521_REG_OP_MODE, 0);
lp5521_wait_opmode_done();
}
+ static void lp5521_stop_engine(struct lp55xx_chip *chip)
+ {
+ enum lp55xx_engine_index idx = chip->engine_idx;
+ u8 mask[] = {
+ [LP55XX_ENGINE_1] = LP5521_MODE_R_M,
+ [LP55XX_ENGINE_2] = LP5521_MODE_G_M,
+ [LP55XX_ENGINE_3] = LP5521_MODE_B_M,
+ };
+
+ lp55xx_update_bits(chip, LP5521_REG_OP_MODE, mask[idx], 0);
+
+ lp5521_wait_opmode_done();
+ }
+
static void lp5521_run_engine(struct lp55xx_chip *chip, bool start)
{
int ret;
if (i % 2)
goto err;
- mutex_lock(&chip->lock);
-
for (i = 0; i < LP5521_PROGRAM_LENGTH; i++) {
ret = lp55xx_write(chip, addr[idx] + i, pattern[i]);
- if (ret) {
- mutex_unlock(&chip->lock);
+ if (ret)
return -EINVAL;
- }
}
- mutex_unlock(&chip->lock);
-
return size;
err:
{
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
struct lp55xx_chip *chip = led->chip;
+ int ret;
mutex_lock(&chip->lock);
chip->engine_idx = nr;
lp5521_load_engine(chip);
+ ret = lp5521_update_program_memory(chip, buf, len);
mutex_unlock(&chip->lock);
- return lp5521_update_program_memory(chip, buf, len);
+ return ret;
}
store_load(1)
store_load(2)
struct lp55xx_led *led = i2c_get_clientdata(client);
struct lp55xx_chip *chip = led->chip;
- lp5521_stop_engine(chip);
+ lp5521_stop_all_engines(chip);
lp55xx_unregister_sysfs(chip);
lp55xx_unregister_leds(led, chip);
lp55xx_deinit_device(chip);
#include "leds-lp55xx-common.h"
-#define LP5523_PROGRAM_LENGTH 32
+#define LP5523_PROGRAM_LENGTH 32 /* bytes */
+/* Memory is used like this:
+ 0x00 engine 1 program
+ 0x10 engine 2 program
+ 0x20 engine 3 program
+ 0x30 engine 1 muxing info
+ 0x40 engine 2 muxing info
+ 0x50 engine 3 muxing info
+*/
#define LP5523_MAX_LEDS 9
/* Registers */
lp55xx_write(chip, LP5523_REG_PROG_PAGE_SEL, page_sel[idx]);
}
- static void lp5523_stop_engine(struct lp55xx_chip *chip)
+ static void lp5523_stop_all_engines(struct lp55xx_chip *chip)
{
lp55xx_write(chip, LP5523_REG_OP_MODE, 0);
lp5523_wait_opmode_done();
}
+ static void lp5523_stop_engine(struct lp55xx_chip *chip)
+ {
+ enum lp55xx_engine_index idx = chip->engine_idx;
+ u8 mask[] = {
+ [LP55XX_ENGINE_1] = LP5523_MODE_ENG1_M,
+ [LP55XX_ENGINE_2] = LP5523_MODE_ENG2_M,
+ [LP55XX_ENGINE_3] = LP5523_MODE_ENG3_M,
+ };
+
+ lp55xx_update_bits(chip, LP5523_REG_OP_MODE, mask[idx], 0);
+
+ lp5523_wait_opmode_done();
+ }
+
static void lp5523_turn_off_channels(struct lp55xx_chip *chip)
{
int i;
}
out:
- lp5523_stop_engine(chip);
+ lp5523_stop_all_engines(chip);
return ret;
}
if (i % 2)
goto err;
- mutex_lock(&chip->lock);
-
for (i = 0; i < LP5523_PROGRAM_LENGTH; i++) {
ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + i, pattern[i]);
- if (ret) {
- mutex_unlock(&chip->lock);
+ if (ret)
return -EINVAL;
- }
}
- mutex_unlock(&chip->lock);
-
return size;
err:
{
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
struct lp55xx_chip *chip = led->chip;
+ int ret;
mutex_lock(&chip->lock);
chip->engine_idx = nr;
lp5523_load_engine_and_select_page(chip);
+ ret = lp5523_update_program_memory(chip, buf, len);
mutex_unlock(&chip->lock);
- return lp5523_update_program_memory(chip, buf, len);
+ return ret;
}
store_load(1)
store_load(2)
struct lp55xx_led *led = i2c_get_clientdata(client);
struct lp55xx_chip *chip = led->chip;
- lp5523_stop_engine(chip);
+ lp5523_stop_all_engines(chip);
lp55xx_unregister_sysfs(chip);
lp55xx_unregister_leds(led, chip);
lp55xx_deinit_device(chip);
#include <linux/gpio.h>
#include <linux/slab.h>
#include <linux/module.h>
+ #include <linux/platform_data/leds-s3c24xx.h>
- #include <mach/hardware.h>
#include <mach/regs-gpio.h>
- #include <linux/platform_data/leds-s3c24xx.h>
+#include <plat/gpio-cfg.h>
/* our context */
int mc13xxx_reg_rmw(struct mc13xxx *mc13xxx, unsigned int offset,
u32 mask, u32 val);
-int mc13xxx_get_flags(struct mc13xxx *mc13xxx);
-
int mc13xxx_irq_request(struct mc13xxx *mc13xxx, int irq,
irq_handler_t handler, const char *name, void *dev);
int mc13xxx_irq_request_nounmask(struct mc13xxx *mc13xxx, int irq,
int id;
const char *name;
const char *default_trigger;
-
- /* Three or two bits current selection depending on the led */
- char max_current;
};
#define MAX_LED_CONTROL_REGS 6
struct mc13xxx_led_platform_data *led;
int num_leds;
- /* LED Control 0 */
+ /* MC13783 LED Control 0 */
#define MC13783_LED_C0_ENABLE (1 << 0)
#define MC13783_LED_C0_TRIODE_MD (1 << 7)
#define MC13783_LED_C0_TRIODE_AD (1 << 8)
#define MC13783_LED_C0_BOOST (1 << 10)
#define MC13783_LED_C0_ABMODE(x) (((x) & 0x7) << 11)
#define MC13783_LED_C0_ABREF(x) (((x) & 0x3) << 14)
- /* LED Control 1 */
+ /* MC13783 LED Control 1 */
#define MC13783_LED_C1_TC1HALF (1 << 18)
#define MC13783_LED_C1_SLEWLIM (1 << 23)
- /* LED Control 2 */
+ /* MC13783 LED Control 2 */
+ #define MC13783_LED_C2_CURRENT_MD(x) (((x) & 0x7) << 0)
+ #define MC13783_LED_C2_CURRENT_AD(x) (((x) & 0x7) << 3)
+ #define MC13783_LED_C2_CURRENT_KP(x) (((x) & 0x7) << 6)
#define MC13783_LED_C2_PERIOD(x) (((x) & 0x3) << 21)
#define MC13783_LED_C2_SLEWLIM (1 << 23)
- /* LED Control 3 */
+ /* MC13783 LED Control 3 */
+ #define MC13783_LED_C3_CURRENT_R1(x) (((x) & 0x3) << 0)
+ #define MC13783_LED_C3_CURRENT_G1(x) (((x) & 0x3) << 2)
+ #define MC13783_LED_C3_CURRENT_B1(x) (((x) & 0x3) << 4)
#define MC13783_LED_C3_PERIOD(x) (((x) & 0x3) << 21)
#define MC13783_LED_C3_TRIODE_TC1 (1 << 23)
- /* LED Control 4 */
+ /* MC13783 LED Control 4 */
+ #define MC13783_LED_C4_CURRENT_R2(x) (((x) & 0x3) << 0)
+ #define MC13783_LED_C4_CURRENT_G2(x) (((x) & 0x3) << 2)
+ #define MC13783_LED_C4_CURRENT_B2(x) (((x) & 0x3) << 4)
#define MC13783_LED_C4_PERIOD(x) (((x) & 0x3) << 21)
#define MC13783_LED_C4_TRIODE_TC2 (1 << 23)
- /* LED Control 5 */
+ /* MC13783 LED Control 5 */
+ #define MC13783_LED_C5_CURRENT_R3(x) (((x) & 0x3) << 0)
+ #define MC13783_LED_C5_CURRENT_G3(x) (((x) & 0x3) << 2)
+ #define MC13783_LED_C5_CURRENT_B3(x) (((x) & 0x3) << 4)
#define MC13783_LED_C5_PERIOD(x) (((x) & 0x3) << 21)
#define MC13783_LED_C5_TRIODE_TC3 (1 << 23)
+ /* MC13892 LED Control 0 */
+ #define MC13892_LED_C0_CURRENT_MD(x) (((x) & 0x7) << 9)
+ #define MC13892_LED_C0_CURRENT_AD(x) (((x) & 0x7) << 21)
+ /* MC13892 LED Control 1 */
+ #define MC13892_LED_C1_CURRENT_KP(x) (((x) & 0x7) << 9)
+ /* MC13892 LED Control 2 */
+ #define MC13892_LED_C2_CURRENT_R(x) (((x) & 0x7) << 9)
+ #define MC13892_LED_C2_CURRENT_G(x) (((x) & 0x7) << 21)
+ /* MC13892 LED Control 3 */
+ #define MC13892_LED_C3_CURRENT_B(x) (((x) & 0x7) << 9)
u32 led_control[MAX_LED_CONTROL_REGS];
};