2020-11-12 12:22:38 -06:00
|
|
|
/*
|
|
|
|
* Copyright 2019 Broadcom.
|
|
|
|
* The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Description
|
|
|
|
* Platform LED related defines and structures
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************
|
|
|
|
* kobj list
|
|
|
|
*****************************************/
|
|
|
|
|
|
|
|
struct kobject *platform_kobj=NULL;
|
|
|
|
struct kobject *led_kobj=NULL;
|
|
|
|
|
|
|
|
struct kobject *state_attr_kobj=NULL;
|
|
|
|
struct kobject *cur_state_kobj=NULL;
|
|
|
|
|
|
|
|
/*****************************************
|
|
|
|
* Static Data provided from user
|
|
|
|
* space JSON data file
|
|
|
|
*****************************************/
|
|
|
|
#define NAME_SIZE 32
|
2023-03-14 19:53:35 -05:00
|
|
|
#define VALUE_SIZE 5
|
2020-11-12 12:22:38 -06:00
|
|
|
typedef enum {
|
2023-05-18 16:06:19 -05:00
|
|
|
STATUS_LED_COLOR_OFF=0,
|
|
|
|
STATUS_LED_COLOR_GREEN=1,
|
|
|
|
STATUS_LED_COLOR_YELLOW=2,
|
|
|
|
STATUS_LED_COLOR_RED=3,
|
|
|
|
STATUS_LED_COLOR_BLUE=4,
|
|
|
|
STATUS_LED_COLOR_GREEN_BLINK=5,
|
|
|
|
STATUS_LED_COLOR_YELLOW_BLINK=6,
|
|
|
|
STATUS_LED_COLOR_RED_BLINK=7,
|
|
|
|
STATUS_LED_COLOR_BLUE_BLINK=8,
|
2020-11-12 12:22:38 -06:00
|
|
|
STATUS_LED_COLOR_AMBER,
|
|
|
|
STATUS_LED_COLOR_AMBER_BLINK,
|
|
|
|
MAX_LED_STATUS
|
|
|
|
}LED_STATUS;
|
|
|
|
|
|
|
|
char* LED_STATUS_STR[] = {
|
2023-05-18 16:06:19 -05:00
|
|
|
"off",
|
2023-03-14 19:53:35 -05:00
|
|
|
"green",
|
2023-05-18 16:06:19 -05:00
|
|
|
"yellow",
|
2023-03-14 19:53:35 -05:00
|
|
|
"red",
|
|
|
|
"blue",
|
2023-05-18 16:06:19 -05:00
|
|
|
"green_blink",
|
2023-03-14 19:53:35 -05:00
|
|
|
"yellow_blink",
|
2023-05-18 16:06:19 -05:00
|
|
|
"red_blink",
|
|
|
|
"blue_blink",
|
|
|
|
"amber",
|
|
|
|
"amber_blink"
|
2020-11-12 12:22:38 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char bits[NAME_SIZE];
|
|
|
|
int pos;
|
|
|
|
int mask_bits;
|
|
|
|
}MASK_BITS;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int swpld_addr;
|
|
|
|
int swpld_addr_offset;
|
|
|
|
MASK_BITS bits;
|
2023-03-14 19:53:35 -05:00
|
|
|
u8 reg_values[VALUE_SIZE];
|
|
|
|
char value[NAME_SIZE];
|
|
|
|
char attr_devtype[NAME_SIZE];
|
|
|
|
char attr_devname[NAME_SIZE];
|
2020-11-12 12:22:38 -06:00
|
|
|
} LED_DATA;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int state;
|
|
|
|
char color[NAME_SIZE];
|
2023-05-18 16:06:19 -05:00
|
|
|
/* S3IP System LED RW sysfs */
|
|
|
|
int sys_led;
|
|
|
|
int bmc_led;
|
|
|
|
int fan_led;
|
|
|
|
int psu_led;
|
|
|
|
int loc_led;
|
|
|
|
/* S3IP Power LED RO sysfs */
|
|
|
|
int psu1_led;
|
|
|
|
int psu2_led;
|
|
|
|
/* S3IP Fantray LED RO sysfs */
|
|
|
|
int fantray1_led;
|
|
|
|
int fantray2_led;
|
|
|
|
int fantray3_led;
|
|
|
|
int fantray4_led;
|
|
|
|
int fantray5_led;
|
|
|
|
int fantray6_led;
|
2020-11-12 12:22:38 -06:00
|
|
|
} CUR_STATE_DATA;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
CUR_STATE_DATA cur_state;
|
|
|
|
char device_name[NAME_SIZE];
|
|
|
|
int index;
|
|
|
|
LED_DATA data[MAX_LED_STATUS];
|
|
|
|
int swpld_addr;
|
|
|
|
int swpld_addr_offset;
|
2023-03-14 19:53:35 -05:00
|
|
|
char attr_devtype[NAME_SIZE];
|
|
|
|
char attr_devname[NAME_SIZE];
|
2020-11-12 12:22:38 -06:00
|
|
|
} LED_OPS_DATA;
|
|
|
|
|
|
|
|
typedef enum{
|
|
|
|
LED_SYS,
|
|
|
|
LED_PSU,
|
|
|
|
LED_FAN,
|
|
|
|
LED_FANTRAY,
|
|
|
|
LED_DIAG,
|
|
|
|
LED_LOC,
|
2023-05-18 16:06:19 -05:00
|
|
|
LED_BMC,
|
2020-11-12 12:22:38 -06:00
|
|
|
LED_TYPE_MAX
|
|
|
|
} LED_TYPE;
|
|
|
|
char* LED_TYPE_STR[LED_TYPE_MAX] =
|
|
|
|
{
|
|
|
|
"LED_SYS",
|
|
|
|
"LED_PSU",
|
|
|
|
"LED_FAN",
|
|
|
|
"LED_FANTRAY",
|
|
|
|
"LED_DIAG",
|
|
|
|
"LED_LOC",
|
2023-05-18 16:06:19 -05:00
|
|
|
"LED_BMC"
|
2020-11-12 12:22:38 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
/*****************************************
|
|
|
|
* Data exported from kernel for
|
|
|
|
* user space plugin to get/set
|
|
|
|
*****************************************/
|
|
|
|
#define PDDF_LED_DATA_ATTR( _prefix, _name, _mode, _show, _store, _type, _len, _addr) \
|
|
|
|
struct pddf_data_attribute pddf_dev_##_prefix##_attr_##_name = { .dev_attr = __ATTR(_name, _mode, _show, _store), \
|
|
|
|
.type = _type , \
|
|
|
|
.len = _len , \
|
|
|
|
.addr = _addr }
|