/* Setup each ENGINE program start address */
ret = lp55xx_write(chip, LP5569_REG_CH1_PROG_START, LP5569_ENG1_PROG_ADDR); if (ret) return ret;
ret = lp55xx_write(chip, LP5569_REG_CH2_PROG_START, LP5569_ENG2_PROG_ADDR); if (ret) return ret;
ret = lp55xx_write(chip, LP5569_REG_CH3_PROG_START, LP5569_ENG3_PROG_ADDR); if (ret) return ret;
/* Write precompiled pattern for LED MUX address space for each ENGINE */ for (i = LP55XX_ENGINE_1; i <= LP55XX_ENGINE_3; i++) {
chip->engine_idx = i;
lp55xx_load_engine(chip);
for (j = 0; j < LP55xx_BYTES_PER_PAGE; j++) {
ret = lp55xx_write(chip, LP5569_REG_PROG_MEM + j,
pattern[i - 1][j]); if (ret) goto out;
}
}
lp5569_run_engine(chip, true);
/* Let the programs run for couple of ms and check the engine status */
usleep_range(3000, 6000);
lp55xx_read(chip, LP5569_REG_STATUS, &status);
status = FIELD_GET(LP5569_ENG_STATUS_MASK, status);
if (status != LP5569_ENG_STATUS_MASK) {
dev_err(&chip->cl->dev, "could not configure LED engine, status = 0x%.2x\n",
status);
ret = -EINVAL;
}
out:
lp55xx_stop_all_engine(chip); return ret;
}
staticint lp5569_post_init_device(struct lp55xx_chip *chip)
{ int ret;
u8 val;
val = LP5569_DEFAULT_CONFIG;
val |= FIELD_PREP(LP5569_CP_MODE_MASK, chip->pdata->charge_pump_mode);
ret = lp55xx_write(chip, LP5569_REG_MISC, val); if (ret) return ret;
if (chip->pdata->clock_mode == LP55XX_CLOCK_INT) { /* Internal clock MUST be configured before CLK output */
ret = lp55xx_update_bits(chip, LP5569_REG_MISC,
LP5569_INTERNAL_CLK,
LP5569_INTERNAL_CLK); if (ret) return ret;
ret = lp55xx_update_bits(chip, LP5569_REG_IO_CONTROL,
LP5569_CLK_OUTPUT,
LP5569_CLK_OUTPUT); if (ret) return ret;
}
ret = lp55xx_write(chip, LP5569_REG_ENABLE, LP5569_ENABLE); if (ret) return ret;
/* Set in STANDBY state */
ret = lp55xx_write(chip, LP5569_REG_ENABLE, 0); if (ret) gotoexit;
/* Wait 1ms for device to enter STANDBY state */
usleep_range(1000, 2000);
/* Set Charge Pump to 1.5x */
ret = lp55xx_update_bits(chip, LP5569_REG_MISC,
FIELD_PREP(LP5569_CP_MODE_MASK, LP55XX_CP_BOOST),
LP5569_CP_MODE_MASK); if (ret) gotoexit;
/* Enable LED Open Test */
ret = lp55xx_update_bits(chip, LP5569_REG_MISC2, LP5569_LED_OPEN_TEST,
LP5569_LED_OPEN_TEST); if (ret) gotoexit;
/* Put Device in NORMAL state */
ret = lp55xx_write(chip, LP5569_REG_ENABLE, LP5569_ENABLE); if (ret) gotoexit;
/* Wait 500 us for device to enter NORMAL state */
usleep_range(500, 750);
/* Enable LED and set to 100% brightness */ for (i = 0; i < pdata->num_channels; i++) {
ret = lp55xx_write(chip, LP5569_REG_LED_PWM_BASE + led_tmp->chan_nr,
LED_FULL); if (ret) gotoexit;
led_tmp++;
}
/* Wait 500 us for device to fill status regs */
usleep_range(500, 750);
/* Parse status led fault 1 regs */
ret = lp55xx_read(chip, LP5569_REG_LED_FAULT1, &status); if (ret < 0) gotoexit;
for (i = 0; i < 8; i++)
leds_fault[i] = !!((status >> i) & 0x1);
/* Parse status led fault 2 regs */
ret = lp55xx_read(chip, LP5569_REG_LED_FAULT2, &status); if (ret < 0) gotoexit;
for (i = 0; i < 1; i++)
leds_fault[i + 8] = !!((status >> i) & 0x1);
/* Report LED fault */
led_tmp = led; for (i = 0; i < pdata->num_channels; i++) { if (leds_fault[led_tmp->chan_nr])
pos += sysfs_emit_at(buf, pos, "LED %d OPEN FAIL\n",
led_tmp->chan_nr);
led_tmp++;
}
ret = pos;
exit: /* Disable LED Open Test */
lp55xx_update_bits(chip, LP5569_REG_MISC2, LP5569_LED_OPEN_TEST, 0);
led_tmp = led; for (i = 0; i < pdata->num_channels; i++) {
lp55xx_write(chip, LP5569_REG_LED_PWM_BASE + led_tmp->chan_nr, 0);
/* Set in STANDBY state */
ret = lp55xx_write(chip, LP5569_REG_ENABLE, 0); if (ret) gotoexit;
/* Wait 1ms for device to enter STANDBY state */
usleep_range(1000, 2000);
/* Set Charge Pump to 1x */
ret = lp55xx_update_bits(chip, LP5569_REG_MISC,
FIELD_PREP(LP5569_CP_MODE_MASK, LP55XX_CP_BYPASS),
LP5569_CP_MODE_MASK); if (ret) gotoexit;
/* Enable LED and set to 100% brightness and current to 100% (25.5mA) */ for (i = 0; i < pdata->num_channels; i++) {
ret = lp55xx_write(chip, LP5569_REG_LED_PWM_BASE + led_tmp->chan_nr,
LED_FULL); if (ret) gotoexit;
ret = lp55xx_write(chip, LP5569_REG_LED_CURRENT_BASE + led_tmp->chan_nr,
LED_FULL); if (ret) gotoexit;
led_tmp++;
}
/* Put Device in NORMAL state */
ret = lp55xx_write(chip, LP5569_REG_ENABLE, LP5569_ENABLE); if (ret) gotoexit;
/* Wait 500 us for device to enter NORMAL state */
usleep_range(500, 750);
/* Enable LED Shorted Test */
ret = lp55xx_update_bits(chip, LP5569_REG_MISC2, LP5569_LED_OPEN_TEST,
LP5569_LED_SHORT_TEST); if (ret) gotoexit;
/* Wait 500 us for device to fill status regs */
usleep_range(500, 750);
/* Parse status led fault 1 regs */
ret = lp55xx_read(chip, LP5569_REG_LED_FAULT1, &status); if (ret < 0) gotoexit;
for (i = 0; i < 8; i++)
leds_fault[i] = !!LEDn_STATUS_FAULT(i, status);
/* Parse status led fault 2 regs */
ret = lp55xx_read(chip, LP5569_REG_LED_FAULT2, &status); if (ret < 0) gotoexit;
for (i = 0; i < 1; i++)
leds_fault[i + 8] = !!LEDn_STATUS_FAULT(i, status);
/* Report LED fault */
led_tmp = led; for (i = 0; i < pdata->num_channels; i++) { if (leds_fault[led_tmp->chan_nr])
pos += sysfs_emit_at(buf, pos, "LED %d SHORTED FAIL\n",
led_tmp->chan_nr);
led_tmp++;
}
ret = pos;
exit: /* Disable LED Shorted Test */
lp55xx_update_bits(chip, LP5569_REG_MISC2, LP5569_LED_SHORT_TEST, 0);
led_tmp = led; for (i = 0; i < pdata->num_channels; i++) {
lp55xx_write(chip, LP5569_REG_LED_PWM_BASE + led_tmp->chan_nr, 0);
/* Test LED Open */
pos = lp5569_led_open_test(led, buf); if (pos < 0) return sprintf(buf, "FAIL\n");
/* Test LED Shorted */
pos += lp5569_led_short_test(led, buf); if (pos < 0) return sprintf(buf, "FAIL\n");
for (i = 0; i < chip->pdata->num_channels; i++) { /* Restore current */
lp55xx_write(chip, LP5569_REG_LED_CURRENT_BASE + led->chan_nr,
led->led_current);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.