linux/drivers/hwmon/k10temp.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * k10temp.c - AMD Family 10h/11h/12h/14h/15h/16h/17h
 *		processor hardware monitoring
 *
 * Copyright (c) 2009 Clemens Ladisch <[email protected]>
 * Copyright (c) 2020 Guenter Roeck <[email protected]>
 *
 * Implementation notes:
 * - CCD register address information as well as the calculation to
 *   convert raw register values is from https://github.com/ocerman/zenpower.
 *   The information is not confirmed from chip datasheets, but experiments
 *   suggest that it provides reasonable temperature values.
 */

#include <linux/bitops.h>
#include <linux/err.h>
#include <linux/hwmon.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/pci_ids.h>
#include <asm/amd_nb.h>
#include <asm/processor.h>

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();

static bool force;
module_param(force, bool, 0444);
MODULE_PARM_DESC();

/* Provide lock for writing to NB_SMU_IND_ADDR */
static DEFINE_MUTEX(nb_smu_ind_mutex);

#ifndef PCI_DEVICE_ID_AMD_15H_M70H_NB_F3
#define PCI_DEVICE_ID_AMD_15H_M70H_NB_F3
#endif

/* CPUID function 0x80000001, ebx */
#define CPUID_PKGTYPE_MASK
#define CPUID_PKGTYPE_F
#define CPUID_PKGTYPE_AM2R2_AM3

/* DRAM controller (PCI function 2) */
#define REG_DCT0_CONFIG_HIGH
#define DDR3_MODE

/* miscellaneous (PCI function 3) */
#define REG_HARDWARE_THERMAL_CONTROL
#define HTC_ENABLE

#define REG_REPORTED_TEMPERATURE

#define REG_NORTHBRIDGE_CAPABILITIES
#define NB_CAP_HTC

/*
 * For F15h M60h and M70h, REG_HARDWARE_THERMAL_CONTROL
 * and REG_REPORTED_TEMPERATURE have been moved to
 * D0F0xBC_xD820_0C64 [Hardware Temperature Control]
 * D0F0xBC_xD820_0CA4 [Reported Temperature Control]
 */
#define F15H_M60H_HARDWARE_TEMP_CTRL_OFFSET
#define F15H_M60H_REPORTED_TEMP_CTRL_OFFSET

/* Common for Zen CPU families (Family 17h and 18h and 19h and 1Ah) */
#define ZEN_REPORTED_TEMP_CTRL_BASE

#define ZEN_CCD_TEMP(offset, x)
#define ZEN_CCD_TEMP_VALID
#define ZEN_CCD_TEMP_MASK

#define ZEN_CUR_TEMP_SHIFT
#define ZEN_CUR_TEMP_RANGE_SEL_MASK
#define ZEN_CUR_TEMP_TJ_SEL_MASK

/*
 * AMD's Industrial processor 3255 supports temperature from -40 deg to 105 deg Celsius.
 * Use the model name to identify 3255 CPUs and set a flag to display negative temperature.
 * Do not round off to zero for negative Tctl or Tdie values if the flag is set
 */
#define AMD_I3255_STR

struct k10temp_data {};

#define TCTL_BIT
#define TDIE_BIT
#define TCCD_BIT(x)

#define HAVE_TEMP(d, channel)

struct tctl_offset {};

static const struct tctl_offset tctl_offset_table[] =;

static void read_htcreg_pci(struct pci_dev *pdev, u32 *regval)
{}

static void read_tempreg_pci(struct pci_dev *pdev, u32 *regval)
{}

static void amd_nb_index_read(struct pci_dev *pdev, unsigned int devfn,
			      unsigned int base, int offset, u32 *val)
{}

static void read_htcreg_nb_f15(struct pci_dev *pdev, u32 *regval)
{}

static void read_tempreg_nb_f15(struct pci_dev *pdev, u32 *regval)
{}

static void read_tempreg_nb_zen(struct pci_dev *pdev, u32 *regval)
{}

static int read_ccd_temp_reg(struct k10temp_data *data, int ccd, u32 *regval)
{}

static long get_raw_temp(struct k10temp_data *data)
{}

static const char *k10temp_temp_label[] =;

static int k10temp_read_labels(struct device *dev,
			       enum hwmon_sensor_types type,
			       u32 attr, int channel, const char **str)
{}

static int k10temp_read_temp(struct device *dev, u32 attr, int channel,
			     long *val)
{}

static int k10temp_read(struct device *dev, enum hwmon_sensor_types type,
			u32 attr, int channel, long *val)
{}

static umode_t k10temp_is_visible(const void *drvdata,
				  enum hwmon_sensor_types type,
				  u32 attr, int channel)
{}

static bool has_erratum_319(struct pci_dev *pdev)
{}

static const struct hwmon_channel_info * const k10temp_info[] =;

static const struct hwmon_ops k10temp_hwmon_ops =;

static const struct hwmon_chip_info k10temp_chip_info =;

static void k10temp_get_ccd_support(struct k10temp_data *data, int limit)
{}

static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{}

static const struct pci_device_id k10temp_id_table[] =;
MODULE_DEVICE_TABLE(pci, k10temp_id_table);

static struct pci_driver k10temp_driver =;

module_pci_driver();