Skip to content

Commit

Permalink
thermal: int340x: processor_thermal: Add Tiger Lake support
Browse files Browse the repository at this point in the history
Added new PCI id for Tiger Lake processor thermal device along with
MMIO RAPL support.

Signed-off-by: Sumeet Pawnikar <sumeet.r.pawnikar@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/1583489952-29612-1-git-send-email-sumeet.r.pawnikar@intel.com
  • Loading branch information
sumeetpawnikar authored and dlezcano committed Mar 23, 2020
1 parent afa58b4 commit 671aa92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
/* JasperLake thermal reporting device */
#define PCI_DEVICE_ID_PROC_JSL_THERMAL 0x4503

/* TigerLake thermal reporting device */
#define PCI_DEVICE_ID_PROC_TGL_THERMAL 0x9A03

#define DRV_NAME "proc_thermal"

struct power_config {
Expand Down Expand Up @@ -728,6 +731,8 @@ static const struct pci_device_id proc_thermal_pci_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_ICL_THERMAL),
.driver_data = (kernel_ulong_t)&rapl_mmio_hsw, },
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_JSL_THERMAL)},
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_TGL_THERMAL),
.driver_data = (kernel_ulong_t)&rapl_mmio_hsw, },
{ 0, },
};

Expand Down
26 changes: 9 additions & 17 deletions tools/thermal/tmon/tmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static void start_daemon_mode(void);

pthread_t event_tid;
pthread_mutex_t input_lock;
void usage()
void usage(void)
{
printf("Usage: tmon [OPTION...]\n");
printf(" -c, --control cooling device in control\n");
Expand All @@ -62,15 +62,14 @@ void usage()
exit(0);
}

void version()
void version(void)
{
printf("TMON version %s\n", VERSION);
exit(EXIT_SUCCESS);
}

static void tmon_cleanup(void)
{

syslog(LOG_INFO, "TMON exit cleanup\n");
fflush(stdout);
refresh();
Expand All @@ -96,7 +95,6 @@ static void tmon_cleanup(void)
exit(1);
}


static void tmon_sig_handler(int sig)
{
syslog(LOG_INFO, "TMON caught signal %d\n", sig);
Expand All @@ -120,7 +118,6 @@ static void tmon_sig_handler(int sig)
tmon_exit = true;
}


static void start_syslog(void)
{
if (debug_on)
Expand Down Expand Up @@ -167,15 +164,14 @@ static void prepare_logging(void)
return;
}


fprintf(tmon_log, "#----------- THERMAL SYSTEM CONFIG -------------\n");
for (i = 0; i < ptdata.nr_tz_sensor; i++) {
char binding_str[33]; /* size of long + 1 */
int j;

memset(binding_str, 0, sizeof(binding_str));
for (j = 0; j < 32; j++)
binding_str[j] = (ptdata.tzi[i].cdev_binding & 1<<j) ?
binding_str[j] = (ptdata.tzi[i].cdev_binding & (1 << j)) ?
'1' : '0';

fprintf(tmon_log, "#thermal zone %s%02d cdevs binding: %32s\n",
Expand All @@ -187,7 +183,6 @@ static void prepare_logging(void)
trip_type_name[ptdata.tzi[i].tp[j].type],
ptdata.tzi[i].tp[j].temp);
}

}

for (i = 0; i < ptdata.nr_cooling_dev; i++)
Expand Down Expand Up @@ -219,7 +214,6 @@ static struct option opts[] = {
{ 0, 0, NULL, 0 }
};


int main(int argc, char **argv)
{
int err = 0;
Expand Down Expand Up @@ -283,7 +277,7 @@ int main(int argc, char **argv)
if (signal(SIGINT, tmon_sig_handler) == SIG_ERR)
syslog(LOG_DEBUG, "Cannot handle SIGINT\n");
if (signal(SIGTERM, tmon_sig_handler) == SIG_ERR)
syslog(LOG_DEBUG, "Cannot handle SIGINT\n");
syslog(LOG_DEBUG, "Cannot handle SIGTERM\n");

if (probe_thermal_sysfs()) {
pthread_mutex_destroy(&input_lock);
Expand Down Expand Up @@ -328,8 +322,7 @@ int main(int argc, char **argv)
show_cooling_device();
}
time_elapsed += ticktime;
controller_handler(trec[0].temp[target_tz_index] / 1000,
&yk);
controller_handler(trec[0].temp[target_tz_index] / 1000, &yk);
trec[0].pid_out_pct = yk;
if (!dialogue_on)
show_control_w();
Expand All @@ -340,14 +333,15 @@ int main(int argc, char **argv)
return 0;
}

static void start_daemon_mode()
static void start_daemon_mode(void)
{
daemon_mode = 1;
/* fork */
pid_t sid, pid = fork();
if (pid < 0) {

if (pid < 0)
exit(EXIT_FAILURE);
} else if (pid > 0)
else if (pid > 0)
/* kill parent */
exit(EXIT_SUCCESS);

Expand All @@ -366,11 +360,9 @@ static void start_daemon_mode()
if ((chdir("/")) < 0)
exit(EXIT_FAILURE);


sleep(10);

close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);

}

0 comments on commit 671aa92

Please sign in to comment.