[AS7326-56X] Fix led drv bug (#8541)

CPLD offset in led drv is incorrect. 

#### How to verify it

echo 1  > brightness, show green on in DIAG led
echo 3  > brightness, show red on in DIAG led
echo 4  > brightness, show blue on in DIAG led
echo 5  > brightness, show green blinking in DIAG led

Signed-off-by: Jostar Yang <jostar_yang@accton.com.tw>
This commit is contained in:
jostar-yang 2021-08-22 09:13:51 +08:00 committed by GitHub
parent 51fce2ae99
commit 753ea80d23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,7 +44,7 @@ struct accton_as7326_56x_led_data {
struct mutex update_lock; struct mutex update_lock;
char valid; /* != 0 if registers are valid */ char valid; /* != 0 if registers are valid */
unsigned long last_updated; /* In jiffies */ unsigned long last_updated; /* In jiffies */
u8 reg_val[1]; /* only 1 register*/ u8 reg_val[2];
}; };
static struct accton_as7326_56x_led_data *ledctl = NULL; static struct accton_as7326_56x_led_data *ledctl = NULL;
@ -54,16 +54,24 @@ static struct accton_as7326_56x_led_data *ledctl = NULL;
#define LED_CNTRLER_I2C_ADDRESS (0x60) #define LED_CNTRLER_I2C_ADDRESS (0x60)
#define LED_TYPE_DIAG_REG_MASK (0x3) #define LED_TYPE_DIAG_REG_MASK (0x3f)
#define LED_MODE_DIAG_GREEN_VALUE (0x02) #define LED_MODE_DIAG_GREEN_VALUE (0x05)
#define LED_MODE_DIAG_RED_VALUE (0x01) #define LED_MODE_DIAG_RED_VALUE (0x06)
#define LED_MODE_DIAG_AMBER_VALUE (0x00) /*It's yellow actually. Green+Red=Yellow*/ #define LED_MODE_DIAG_BLUE_VALUE (0x03)
#define LED_MODE_DIAG_OFF_VALUE (0x03) #define LED_MODE_DIAG_GREEN_BLINK_VALUE (0x17)
#define LED_MODE_DIAG_RED_BLINK_VALUE (0x0d)
#define LED_MODE_DIAG_BLUE_BLINK_VALUE (0x27)
#define LED_MODE_DIAG_OFF_VALUE (0x07)
#define LED_TYPE_LOC_REG_MASK (0x80) #define LED_TYPE_LOC_REG_MASK (0x3f)
#define LED_MODE_LOC_ON_VALUE (0) #define LED_MODE_LOC_GREEN_VALUE (0x05)
#define LED_MODE_LOC_OFF_VALUE (0x80) #define LED_MODE_LOC_RED_VALUE (0x06)
#define LED_MODE_LOC_BLUE_VALUE (0x03)
#define LED_MODE_LOC_GREEN_BLINK_VALUE (0x17)
#define LED_MODE_LOC_RED_BLINK_VALUE (0x0d)
#define LED_MODE_LOC_BLUE_BLINK_VALUE (0x27)
#define LED_MODE_LOC_OFF_VALUE (0x07)
enum led_type { enum led_type {
LED_TYPE_DIAG, LED_TYPE_DIAG,
@ -79,7 +87,8 @@ struct led_reg {
}; };
static const struct led_reg led_reg_map[] = { static const struct led_reg led_reg_map[] = {
{(1<<LED_TYPE_LOC) | (1<<LED_TYPE_DIAG), 0x41}, {LED_TYPE_DIAG, 0x24},
{LED_TYPE_LOC, 0x25}
}; };
@ -105,12 +114,22 @@ struct led_type_mode {
}; };
static struct led_type_mode led_type_mode_data[] = { static struct led_type_mode led_type_mode_data[] = {
{LED_TYPE_LOC, LED_MODE_OFF, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_OFF_VALUE}, {LED_TYPE_LOC, LED_MODE_OFF, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_OFF_VALUE},
{LED_TYPE_LOC, LED_MODE_AMBER, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_ON_VALUE}, {LED_TYPE_LOC, LED_MODE_GREEN, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_GREEN_VALUE},
{LED_TYPE_LOC, LED_MODE_RED, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_RED_VALUE},
{LED_TYPE_LOC, LED_MODE_BLUE, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_BLUE_VALUE},
{LED_TYPE_LOC, LED_MODE_GREEN_BLINK, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_GREEN_BLINK_VALUE},
{LED_TYPE_LOC, LED_MODE_RED_BLINK, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_RED_BLINK_VALUE},
{LED_TYPE_LOC, LED_MODE_BLUE_BLINK, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_BLUE_BLINK_VALUE},
{LED_TYPE_DIAG, LED_MODE_OFF, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_OFF_VALUE}, {LED_TYPE_DIAG, LED_MODE_OFF, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_OFF_VALUE},
{LED_TYPE_DIAG, LED_MODE_GREEN, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_GREEN_VALUE}, {LED_TYPE_DIAG, LED_MODE_GREEN, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_GREEN_VALUE},
{LED_TYPE_DIAG, LED_MODE_RED, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_RED_VALUE}, {LED_TYPE_DIAG, LED_MODE_RED, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_RED_VALUE},
{LED_TYPE_DIAG, LED_MODE_AMBER, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_AMBER_VALUE}, {LED_TYPE_DIAG, LED_MODE_BLUE, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_BLUE_VALUE},
{LED_TYPE_DIAG, LED_MODE_GREEN_BLINK, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_GREEN_BLINK_VALUE},
{LED_TYPE_DIAG, LED_MODE_RED_BLINK, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_RED_BLINK_VALUE},
{LED_TYPE_DIAG, LED_MODE_BLUE_BLINK, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_BLUE_BLINK_VALUE},
}; };
@ -125,8 +144,9 @@ static void accton_as7326_56x_led_set(struct led_classdev *led_cdev,
static int accton_getLedReg(enum led_type type, u8 *reg) static int accton_getLedReg(enum led_type type, u8 *reg)
{ {
int i; int i;
for (i = 0; i < ARRAY_SIZE(led_reg_map); i++) { for (i = 0; i < ARRAY_SIZE(led_reg_map); i++) {
if(led_reg_map[i].types & (type<<1)) { if(led_reg_map[i].types ==type)) {
*reg = led_reg_map[i].reg_addr; *reg = led_reg_map[i].reg_addr;
return 0; return 0;
} }
@ -267,7 +287,7 @@ static void accton_as7326_56x_led_loc_set(struct led_classdev *led_cdev,
static enum led_brightness accton_as7326_56x_led_loc_get(struct led_classdev *cdev) static enum led_brightness accton_as7326_56x_led_loc_get(struct led_classdev *cdev)
{ {
accton_as7326_56x_led_update(); accton_as7326_56x_led_update();
return led_reg_val_to_light_mode(LED_TYPE_LOC, ledctl->reg_val[0]); return led_reg_val_to_light_mode(LED_TYPE_LOC, ledctl->reg_val[1]);
} }
static void accton_as7326_56x_led_auto_set(struct led_classdev *led_cdev, static void accton_as7326_56x_led_auto_set(struct led_classdev *led_cdev,
@ -287,7 +307,7 @@ static struct led_classdev accton_as7326_56x_leds[] = {
.brightness_set = accton_as7326_56x_led_diag_set, .brightness_set = accton_as7326_56x_led_diag_set,
.brightness_get = accton_as7326_56x_led_diag_get, .brightness_get = accton_as7326_56x_led_diag_get,
.flags = LED_CORE_SUSPENDRESUME, .flags = LED_CORE_SUSPENDRESUME,
.max_brightness = LED_MODE_RED, .max_brightness = LED_MODE_BLUE_BLINK,
}, },
[LED_TYPE_LOC] = { [LED_TYPE_LOC] = {
.name = "accton_as7326_56x_led::loc", .name = "accton_as7326_56x_led::loc",
@ -295,7 +315,7 @@ static struct led_classdev accton_as7326_56x_leds[] = {
.brightness_set = accton_as7326_56x_led_loc_set, .brightness_set = accton_as7326_56x_led_loc_set,
.brightness_get = accton_as7326_56x_led_loc_get, .brightness_get = accton_as7326_56x_led_loc_get,
.flags = LED_CORE_SUSPENDRESUME, .flags = LED_CORE_SUSPENDRESUME,
.max_brightness = LED_MODE_BLUE, .max_brightness = LED_MODE_BLUE_BLINK,
}, },
[LED_TYPE_FAN] = { [LED_TYPE_FAN] = {
.name = "accton_as7326_56x_led::fan", .name = "accton_as7326_56x_led::fan",