mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 17:42:41 +00:00
ipq807x: update qca-thermald
Let qca thermald support IPQ50xx platform and has cooling function to limit the duty cycle of tx queues Signed-off-by: wingate5678 <wingate.chi@cybertan.com.tw>
This commit is contained in:
committed by
John Crispin
parent
42f0c520da
commit
18100e0b4e
@@ -35,6 +35,8 @@ define Package/qca-thermald-10.4/install
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/install/etc/thermal/ipq-thermald-8064.conf $(1)/etc/thermal
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/install/etc/thermal/ipq-thermald-8066.conf $(1)/etc/thermal
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/install/etc/thermal/ipq-thermald-8069.conf $(1)/etc/thermal
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/install/etc/thermal/ipq-thermald-cybertan-eww631-a1.conf $(1)/etc/thermal
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/install/etc/thermal/ipq-thermald-cybertan-eww631-b1.conf $(1)/etc/thermal
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/thermal.init $(1)/etc/init.d/thermal
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
|
||||
@@ -5,6 +5,8 @@ START=98
|
||||
SERVICE_WRITE_PID=1
|
||||
SERVICE_DAEMONIZE=1
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
start() {
|
||||
. /lib/functions.sh
|
||||
|
||||
@@ -14,10 +16,19 @@ start() {
|
||||
config_get_bool enabled config 'Enabled' '0'
|
||||
|
||||
[ "$enabled" -gt 0 ] || return 1
|
||||
|
||||
service_start /usr/sbin/thermald
|
||||
case "$board" in
|
||||
cybertan,eww631-a1)
|
||||
service_start /usr/sbin/thermald -c /etc/thermal/ipq-thermald-cybertan-eww631-a1.conf
|
||||
;;
|
||||
cybertan,eww631-b1)
|
||||
service_start /usr/sbin/thermald -c /etc/thermal/ipq-thermald-cybertan-eww631-b1.conf
|
||||
;;
|
||||
*)
|
||||
service_start /usr/sbin/thermald
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
stop() {
|
||||
service_stop /usr/sbin/thermald
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,9 @@ endif
|
||||
|
||||
export CC = $(CROSS)gcc
|
||||
export CFLAGS += -O2 -Wall -DIPQ_806x -c
|
||||
ifeq ($(SoC),$(filter $(SoC),ipq50xx ipq50xx_64))
|
||||
export CFLAGS += -DIPQ_5000
|
||||
endif
|
||||
export STRIP = $(CROSS)strip
|
||||
export SOURCES= \
|
||||
thermal.c \
|
||||
@@ -63,6 +66,7 @@ install: local
|
||||
cp -a -f $(ALL) $(INSTALL_ROOT)/usr/sbin/
|
||||
mkdir -p $(INSTALL_ROOT)/etc/thermal
|
||||
cp -a -f ipq-thermald-806?.conf $(INSTALL_ROOT)/etc/thermal/
|
||||
cp -a -f ipq-thermald-cybertan-eww631-*.conf $(INSTALL_ROOT)/etc/thermal/
|
||||
@echo Installed outputs from `pwd`
|
||||
|
||||
# Remove all generated files
|
||||
|
||||
15
feeds/ipq807x/qca-thermald-10.4/src/ipq-thermald-cybertan-eww631-a1.conf
Executable file
15
feeds/ipq807x/qca-thermald-10.4/src/ipq-thermald-cybertan-eww631-a1.conf
Executable file
@@ -0,0 +1,15 @@
|
||||
sampling 5000
|
||||
|
||||
[tsens_tz_sensor1]
|
||||
sampling 5000
|
||||
thresholds 105 110 115 119 120
|
||||
thresholds_clr 0 100 105 110 115
|
||||
actions cooling cooling cooling cooling shutdown
|
||||
action_info 35 35 50 70 800000
|
||||
|
||||
[tsens_tz_sensor4]
|
||||
sampling 5000
|
||||
thresholds 105 107 112 119 120
|
||||
thresholds_clr 0 100 105 110 115
|
||||
actions cooling cooling cooling cooling shutdown
|
||||
action_info 0 20 30 50 800000
|
||||
15
feeds/ipq807x/qca-thermald-10.4/src/ipq-thermald-cybertan-eww631-b1.conf
Executable file
15
feeds/ipq807x/qca-thermald-10.4/src/ipq-thermald-cybertan-eww631-b1.conf
Executable file
@@ -0,0 +1,15 @@
|
||||
sampling 5000
|
||||
|
||||
[tsens_tz_sensor1]
|
||||
sampling 5000
|
||||
thresholds 70 80 90 105 115 120
|
||||
thresholds_clr 0 75 85 100 110 113
|
||||
actions cooling cooling cooling cooling cooling shutdown
|
||||
action_info 0 25 45 65 90 800000
|
||||
|
||||
[tsens_tz_sensor4]
|
||||
sampling 5000
|
||||
thresholds 70 80 90 105 115 120
|
||||
thresholds_clr 0 75 85 100 110 113
|
||||
actions cooling cooling cooling cooling cooling shutdown
|
||||
action_info 0 15 25 45 60 800000
|
||||
@@ -138,7 +138,14 @@ enum therm_msm_id {
|
||||
THERM_IPQ_6018,
|
||||
THERM_IPQ_6028,
|
||||
THERM_IPQ_6000,
|
||||
THERM_IPQ_6010
|
||||
THERM_IPQ_6010,
|
||||
THERM_IPQ_6005,
|
||||
THERM_IPQ_5010,
|
||||
THERM_IPQ_5018,
|
||||
THERM_IPQ_5028,
|
||||
THERM_IPQ_5000,
|
||||
THERM_IPQ_0509,
|
||||
THERM_IPQ_0518
|
||||
};
|
||||
|
||||
enum therm_msm_id therm_get_msm_id(void);
|
||||
@@ -158,6 +165,9 @@ enum {
|
||||
#ifdef IPQ_806x
|
||||
POWERSAVE,
|
||||
NSS_FREQ,
|
||||
#ifdef IPQ_5000
|
||||
COOLING,
|
||||
#endif
|
||||
#else
|
||||
REPORT,
|
||||
LCD,
|
||||
@@ -311,6 +321,9 @@ int cpufreq_request(int cpu, int requester, int temperature, int frequency);
|
||||
int powersave_request( int enable );
|
||||
int nssfreq_request( int frequency );
|
||||
int powerctl_restart(int reset_max);
|
||||
#ifdef IPQ_5000
|
||||
int cooling_request( int requester, int temperature, int percentage );
|
||||
#endif
|
||||
#else
|
||||
int report_action(int requester, int temperature, int level, int is_trigger);
|
||||
int lcd_brightness_request(int requester, int temperature, int value);
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#define NUM_US_IN_MS (1000)
|
||||
#define CPU_BUF_MAX (50)
|
||||
#define HOTPLUG_BUF_MAX (1024)
|
||||
|
||||
#define SHUTDOWN_BUF_MAX (100)
|
||||
enum {
|
||||
MITIGATION_ENABLE = 0,
|
||||
MITIGATION_DISABLE = 1
|
||||
@@ -116,6 +116,8 @@ int shutdown_action(int requester, int temperature, int delay)
|
||||
{
|
||||
static int shutdown_requested = 0;
|
||||
int ret = 0;
|
||||
int fd;
|
||||
char buf[SHUTDOWN_BUF_MAX] = {0};
|
||||
|
||||
if (requester < 0 ||
|
||||
requester >= SENSOR_IDX_MAX) {
|
||||
@@ -134,6 +136,15 @@ int shutdown_action(int requester, int temperature, int delay)
|
||||
"with %d millisecond delay\n",
|
||||
SENSOR(requester), temperature, delay);
|
||||
|
||||
fd = open("/dev/console", O_RDWR, 0);
|
||||
if (fd >= 0)
|
||||
{
|
||||
snprintf(buf, SHUTDOWN_BUF_MAX, "THERMAL SHUTDOWN: "
|
||||
"%s reached temperature %d with %d mSec Delay \n",
|
||||
SENSOR(requester), temperature, delay);
|
||||
write(fd,buf,SHUTDOWN_BUF_MAX);
|
||||
close(fd);
|
||||
}
|
||||
usleep(delay * NUM_US_IN_MS);
|
||||
|
||||
/* commit buffers to disk and shutdown */
|
||||
@@ -403,7 +414,7 @@ int cpufreq_init()
|
||||
return -1;
|
||||
}
|
||||
info("Number of cpus :%d\n", num_cpus);
|
||||
memset(online, 0, MAX_CPUS);
|
||||
memset(online, 0, MAX_CPUS * sizeof(int));
|
||||
|
||||
for (cpu = 0; cpu < num_cpus; cpu++) {
|
||||
snprintf(finfo_buf, MAX_PATH, CPU_SYSFS(FMAX_INFO_NODE), cpu);
|
||||
@@ -1384,6 +1395,99 @@ int nssfreq_request(int frequency)
|
||||
pthread_mutex_unlock(&nssfreq_set_mtx);
|
||||
return ret;
|
||||
}
|
||||
#ifdef IPQ_5000
|
||||
/*===========================================================================
|
||||
FUNCTION cooling_request
|
||||
|
||||
Action function to request wlan throttling action
|
||||
|
||||
ARGUMENTS
|
||||
percentage => duty cycle of tx queues suspending
|
||||
|
||||
RETURN VALUE
|
||||
0 on success, -1 on failure.
|
||||
===========================================================================*/
|
||||
static int cooling_req[2];
|
||||
#define COOLING_24G_MITIGATION_SYSFS "/sys/class/thermal/cooling_device0/cur_state"
|
||||
#define COOLING_5G_MITIGATION_SYSFS "/sys/class/thermal/cooling_device1/cur_state"
|
||||
#define MAX_COOLING_MITIGATION_PERCENTAGE (90)
|
||||
|
||||
static pthread_mutex_t cooling_mtx = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
int cooling_request(int requester, int temperature, int percentage )
|
||||
{
|
||||
int ret = -1;
|
||||
char buf[UINT_BUF_MAX] = {0};
|
||||
static int current_24g_percentage, current_5g_percentage;
|
||||
char * end_ptr;
|
||||
|
||||
if ((NULL == COOLING_24G_MITIGATION_SYSFS) || (NULL == COOLING_5G_MITIGATION_SYSFS)) {
|
||||
msg("%s: Unsupported action on current target", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
temperature = RCONV(temperature);
|
||||
|
||||
if (percentage < 0)
|
||||
percentage = 0;
|
||||
|
||||
if (percentage > MAX_COOLING_MITIGATION_PERCENTAGE)
|
||||
percentage = MAX_COOLING_MITIGATION_PERCENTAGE;
|
||||
|
||||
pthread_mutex_lock(&cooling_mtx);
|
||||
|
||||
if (requester == 1) {
|
||||
/* get current cooling percentage */
|
||||
if (read_line_from_file(COOLING_24G_MITIGATION_SYSFS, buf, UINT_BUF_MAX) > 0) {
|
||||
current_24g_percentage = strtol(buf, &end_ptr, 10);
|
||||
dbgmsg("current 2g cooling percentage(%d)\n", current_24g_percentage);
|
||||
}
|
||||
|
||||
/* Aggregate cooling throttling percentage for 24g */
|
||||
cooling_req[requester] = percentage;
|
||||
|
||||
if (percentage != current_24g_percentage) {
|
||||
snprintf(buf, UINT_BUF_MAX, "%d", percentage);
|
||||
if (write_to_file(COOLING_24G_MITIGATION_SYSFS, buf, strlen(buf)) > 0) {
|
||||
info("ACTION: COOLING - "
|
||||
"Setting 24G COOLING mitigation to %d\n", percentage);
|
||||
ret = 0;
|
||||
} else {
|
||||
msg("Unable to set COOLING mitigation to %d\n", percentage);
|
||||
}
|
||||
} else {
|
||||
dbgmsg("COOLING mitigation already at %d percentage\n", percentage);
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
else if (requester == 4) {
|
||||
/* get current 5g cooling percentage */
|
||||
if (read_line_from_file(COOLING_5G_MITIGATION_SYSFS, buf, UINT_BUF_MAX) > 0) {
|
||||
current_5g_percentage = strtol(buf, &end_ptr, 10);
|
||||
dbgmsg("current 5g cooling percentage(%d)\n", current_5g_percentage);
|
||||
}
|
||||
|
||||
/* Aggregate cooling throttling percentage for 5g */
|
||||
cooling_req[requester] = percentage;
|
||||
|
||||
if (percentage != current_5g_percentage) {
|
||||
snprintf(buf, UINT_BUF_MAX, "%d", percentage);
|
||||
if (write_to_file(COOLING_5G_MITIGATION_SYSFS, buf, strlen(buf)) > 0) {
|
||||
info("ACTION: COOLING - "
|
||||
"Setting 5G COOLING mitigation to %d\n", percentage);
|
||||
ret = 0;
|
||||
} else {
|
||||
msg("Unable to set COOLING mitigation to %d\n", percentage);
|
||||
}
|
||||
} else {
|
||||
dbgmsg("COOLING mitigation already at %d percentage\n", percentage);
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&cooling_mtx);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*===========================================================================
|
||||
FUNCTION set_mitigation_level
|
||||
|
||||
@@ -43,6 +43,9 @@ static char *action_names[] = {
|
||||
#ifdef IPQ_806x
|
||||
"powersave",
|
||||
"nss",
|
||||
#ifdef IPQ_5000
|
||||
"cooling"
|
||||
#endif
|
||||
#else
|
||||
"report",
|
||||
"lcd",
|
||||
@@ -337,6 +340,41 @@ def_sensor_setting_t def_cp_setting = {
|
||||
.sensors = def_sensor_cp
|
||||
};
|
||||
|
||||
/* TODO: Fix desc, id, lvl_trig, lvl_clr */
|
||||
sensor_setting_t def_sensor_mp[] = {
|
||||
{
|
||||
.desc = "tsens_tz_sensor4",
|
||||
.id = 4,
|
||||
.disabled = 0, /* Sensor enabled */
|
||||
.sampling_period_us = 1000,
|
||||
.num_thresholds = 1, /* No. of threshold levels */
|
||||
|
||||
.t = {
|
||||
{
|
||||
.lvl_trig = 120,
|
||||
.num_actions = 1,
|
||||
.actions = {
|
||||
{
|
||||
.action = SHUTDOWN,
|
||||
.info = 1000
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/* Internal variables initialized with threshold count */
|
||||
._n_thresholds = 1,
|
||||
._n_to_clear = 1,
|
||||
._n_actions = 1,
|
||||
._n_action_info = 1
|
||||
},
|
||||
};
|
||||
|
||||
def_sensor_setting_t def_mp_setting = {
|
||||
.sensor_count = 1,
|
||||
.sensors = def_sensor_mp
|
||||
};
|
||||
|
||||
/* IPQ806x */
|
||||
sensor_setting_t def_ipq8064[] = {
|
||||
{
|
||||
@@ -638,9 +676,19 @@ void update_def_sensor_settings(thermal_setting_t *settings)
|
||||
case THERM_IPQ_6028:
|
||||
case THERM_IPQ_6000:
|
||||
case THERM_IPQ_6010:
|
||||
case THERM_IPQ_6005:
|
||||
msg("==== IPQ60xx ====\n");
|
||||
def_sensor_setting = &def_cp_setting;
|
||||
break;
|
||||
case THERM_IPQ_5010:
|
||||
case THERM_IPQ_5018:
|
||||
case THERM_IPQ_5028:
|
||||
case THERM_IPQ_5000:
|
||||
case THERM_IPQ_0509:
|
||||
case THERM_IPQ_0518:
|
||||
msg("==== IPQ50xx ====\n");
|
||||
def_sensor_setting = &def_mp_setting;
|
||||
break;
|
||||
default:
|
||||
msg("==== DEFAULT ===\n");
|
||||
def_sensor_setting = &def_hk_setting;
|
||||
@@ -851,6 +899,13 @@ int parse_config(thermal_setting_t *settings, int fd)
|
||||
|| settings->soc_id == THERM_IPQ_6000
|
||||
|| settings->soc_id == THERM_IPQ_6010)
|
||||
i = TSENS_TZ_SENSOR4;
|
||||
else if ( settings->soc_id == THERM_IPQ_5010
|
||||
|| settings->soc_id == THERM_IPQ_5018
|
||||
|| settings->soc_id == THERM_IPQ_5028
|
||||
|| settings->soc_id == THERM_IPQ_5000
|
||||
|| settings->soc_id == THERM_IPQ_0509
|
||||
|| settings->soc_id == THERM_IPQ_0518)
|
||||
i = TSENS_TZ_SENSOR1;
|
||||
else
|
||||
i = TSENS_TZ_SENSOR0;
|
||||
|
||||
|
||||
@@ -73,6 +73,11 @@ static void clear_all_alarms(sensor_setting_t *sensor, int sensor_temp)
|
||||
case NSS_FREQ:
|
||||
nssfreq_request(-1);
|
||||
break;
|
||||
#ifdef IPQ_5000
|
||||
case COOLING:
|
||||
cooling_request(sensor->id, sensor_temp, 0);
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -186,6 +191,11 @@ void *sensor_monitor(void *vsensor)
|
||||
case NSS_FREQ:
|
||||
nssfreq_request(sensor->t[i].actions[j].info);
|
||||
break;
|
||||
#ifdef IPQ_5000
|
||||
case COOLING:
|
||||
cooling_request(sensor->id, sensor_temp, sensor->t[i].actions[j].info);
|
||||
break;
|
||||
#endif
|
||||
#else
|
||||
case REPORT:
|
||||
if (alarm_raised)
|
||||
|
||||
@@ -93,6 +93,14 @@ static therm_msm_soc_type msm_soc_table[] = {
|
||||
{THERM_IPQ_6028, 403},
|
||||
{THERM_IPQ_6000, 421},
|
||||
{THERM_IPQ_6010, 422},
|
||||
{THERM_IPQ_6005, 453},
|
||||
/* MP variants */
|
||||
{THERM_IPQ_5010, 446},
|
||||
{THERM_IPQ_5018, 447},
|
||||
{THERM_IPQ_5028, 448},
|
||||
{THERM_IPQ_5000, 503},
|
||||
{THERM_IPQ_0509, 504},
|
||||
{THERM_IPQ_0518, 505},
|
||||
};
|
||||
|
||||
int read_id_from_binary_file(char *path, size_t size) {
|
||||
|
||||
Reference in New Issue
Block a user