Skip to content

Commit

Permalink
Thermal/int340x/processor_thermal: Enable auxiliary DTS for Braswell
Browse files Browse the repository at this point in the history
Support two auxiliary DTS present on Braswell platform using side band
IOSF interface. This supports two read write trips, which can be used
to get notification on trip violation.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
  • Loading branch information
Srinivas Pandruvada authored and Zhang Rui committed May 1, 2015
1 parent 3a2419f commit 4d0dd6c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
1 change: 1 addition & 0 deletions drivers/thermal/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ config INT340X_THERMAL
select THERMAL_GOV_USER_SPACE
select ACPI_THERMAL_REL
select ACPI_FAN
select INTEL_SOC_DTS_IOSF_CORE
help
Newer laptops and tablets that use ACPI may have thermal sensors and
other devices with thermal control capabilities outside the core
Expand Down
55 changes: 54 additions & 1 deletion drivers/thermal/int340x_thermal/processor_thermal_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/acpi.h>
#include <linux/thermal.h>
#include "int340x_thermal_zone.h"
#include "../intel_soc_dts_iosf.h"

/* Broadwell-U/HSB thermal reporting device */
#define PCI_DEVICE_ID_PROC_BDW_THERMAL 0x1603
Expand All @@ -42,6 +44,7 @@ struct proc_thermal_device {
struct acpi_device *adev;
struct power_config power_limits[2];
struct int34x_thermal_zone *int340x_zone;
struct intel_soc_dts_sensors *soc_dts;
};

enum proc_thermal_emum_mode_type {
Expand Down Expand Up @@ -308,6 +311,18 @@ static int int3401_remove(struct platform_device *pdev)
return 0;
}

static irqreturn_t proc_thermal_pci_msi_irq(int irq, void *devid)
{
struct proc_thermal_device *proc_priv;
struct pci_dev *pdev = devid;

proc_priv = pci_get_drvdata(pdev);

intel_soc_dts_iosf_interrupt_handler(proc_priv->soc_dts);

return IRQ_HANDLED;
}

static int proc_thermal_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *unused)
{
Expand All @@ -334,12 +349,50 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev,
pci_set_drvdata(pdev, proc_priv);
proc_thermal_emum_mode = PROC_THERMAL_PCI;

if (pdev->device == PCI_DEVICE_ID_PROC_BSW_THERMAL) {
/*
* Enumerate additional DTS sensors available via IOSF.
* But we are not treating as a failure condition, if
* there are no aux DTSs enabled or fails. This driver
* already exposes sensors, which can be accessed via
* ACPI/MSR. So we don't want to fail for auxiliary DTSs.
*/
proc_priv->soc_dts = intel_soc_dts_iosf_init(
INTEL_SOC_DTS_INTERRUPT_MSI, 2, 0);

if (proc_priv->soc_dts && pdev->irq) {
ret = pci_enable_msi(pdev);
if (!ret) {
ret = request_threaded_irq(pdev->irq, NULL,
proc_thermal_pci_msi_irq,
IRQF_ONESHOT, "proc_thermal",
pdev);
if (ret) {
intel_soc_dts_iosf_exit(
proc_priv->soc_dts);
pci_disable_msi(pdev);
proc_priv->soc_dts = NULL;
}
}
} else
dev_err(&pdev->dev, "No auxiliary DTSs enabled\n");
}

return 0;
}

static void proc_thermal_pci_remove(struct pci_dev *pdev)
{
proc_thermal_remove(pci_get_drvdata(pdev));
struct proc_thermal_device *proc_priv = pci_get_drvdata(pdev);

if (proc_priv->soc_dts) {
intel_soc_dts_iosf_exit(proc_priv->soc_dts);
if (pdev->irq) {
free_irq(pdev->irq, pdev);
pci_disable_msi(pdev);
}
}
proc_thermal_remove(proc_priv);
pci_disable_device(pdev);
}

Expand Down

0 comments on commit 4d0dd6c

Please sign in to comment.