2019-05-27 06:55:14 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2006-06-05 19:25:20 +00:00
|
|
|
* (C) 2004-2006 Sebastian Witt <se.witt@gmx.net>
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Based upon reverse engineered information
|
|
|
|
*
|
|
|
|
* BIG FAT DISCLAIMER: Work in progress code. Possibly *dangerous*
|
|
|
|
*/
|
|
|
|
|
2016-04-05 20:28:25 +00:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/cpufreq.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
|
|
|
|
#define NFORCE2_XTAL 25
|
|
|
|
#define NFORCE2_BOOTFSB 0x48
|
|
|
|
#define NFORCE2_PLLENABLE 0xa8
|
|
|
|
#define NFORCE2_PLLREG 0xa4
|
|
|
|
#define NFORCE2_PLLADR 0xa0
|
|
|
|
#define NFORCE2_PLL(mul, div) (0x100000 | (mul << 8) | div)
|
|
|
|
|
|
|
|
#define NFORCE2_MIN_FSB 50
|
|
|
|
#define NFORCE2_SAFE_DISTANCE 50
|
|
|
|
|
|
|
|
/* Delay in ms between FSB changes */
|
2008-06-14 19:11:39 +00:00
|
|
|
/* #define NFORCE2_DELAY 10 */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-06-14 19:11:39 +00:00
|
|
|
/*
|
|
|
|
* nforce2_chipset:
|
2005-04-16 22:20:36 +00:00
|
|
|
* FSB is changed using the chipset
|
|
|
|
*/
|
2009-01-18 03:39:47 +00:00
|
|
|
static struct pci_dev *nforce2_dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* fid:
|
|
|
|
* multiplier * 10
|
|
|
|
*/
|
2008-06-14 19:11:39 +00:00
|
|
|
static int fid;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* min_fsb, max_fsb:
|
2006-02-28 05:43:23 +00:00
|
|
|
* minimum and maximum FSB (= FSB at boot time)
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2008-06-14 19:11:39 +00:00
|
|
|
static int min_fsb;
|
|
|
|
static int max_fsb;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Sebastian Witt <se.witt@gmx.net>");
|
|
|
|
MODULE_DESCRIPTION("nForce2 FSB changing cpufreq driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
module_param(fid, int, 0444);
|
|
|
|
module_param(min_fsb, int, 0444);
|
|
|
|
|
|
|
|
MODULE_PARM_DESC(fid, "CPU multiplier to use (11.5 = 115)");
|
|
|
|
MODULE_PARM_DESC(min_fsb,
|
2008-06-14 19:11:39 +00:00
|
|
|
"Minimum FSB to use, if not defined: current FSB - 50");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-02-28 05:43:23 +00:00
|
|
|
/**
|
2005-04-16 22:20:36 +00:00
|
|
|
* nforce2_calc_fsb - calculate FSB
|
|
|
|
* @pll: PLL value
|
2006-02-28 05:43:23 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* Calculates FSB from PLL value
|
|
|
|
*/
|
|
|
|
static int nforce2_calc_fsb(int pll)
|
|
|
|
{
|
|
|
|
unsigned char mul, div;
|
|
|
|
|
|
|
|
mul = (pll >> 8) & 0xff;
|
|
|
|
div = pll & 0xff;
|
|
|
|
|
|
|
|
if (div > 0)
|
|
|
|
return NFORCE2_XTAL * mul / div;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-02-28 05:43:23 +00:00
|
|
|
/**
|
2005-04-16 22:20:36 +00:00
|
|
|
* nforce2_calc_pll - calculate PLL value
|
|
|
|
* @fsb: FSB
|
2006-02-28 05:43:23 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* Calculate PLL value for given FSB
|
|
|
|
*/
|
|
|
|
static int nforce2_calc_pll(unsigned int fsb)
|
|
|
|
{
|
|
|
|
unsigned char xmul, xdiv;
|
|
|
|
unsigned char mul = 0, div = 0;
|
|
|
|
int tried = 0;
|
|
|
|
|
|
|
|
/* Try to calculate multiplier and divider up to 4 times */
|
|
|
|
while (((mul == 0) || (div == 0)) && (tried <= 3)) {
|
2006-06-05 19:25:20 +00:00
|
|
|
for (xdiv = 2; xdiv <= 0x80; xdiv++)
|
2005-04-16 22:20:36 +00:00
|
|
|
for (xmul = 1; xmul <= 0xfe; xmul++)
|
|
|
|
if (nforce2_calc_fsb(NFORCE2_PLL(xmul, xdiv)) ==
|
|
|
|
fsb + tried) {
|
|
|
|
mul = xmul;
|
|
|
|
div = xdiv;
|
|
|
|
}
|
|
|
|
tried++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((mul == 0) || (div == 0))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return NFORCE2_PLL(mul, div);
|
|
|
|
}
|
|
|
|
|
2006-02-28 05:43:23 +00:00
|
|
|
/**
|
2005-04-16 22:20:36 +00:00
|
|
|
* nforce2_write_pll - write PLL value to chipset
|
|
|
|
* @pll: PLL value
|
2006-02-28 05:43:23 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* Writes new FSB PLL value to chipset
|
|
|
|
*/
|
|
|
|
static void nforce2_write_pll(int pll)
|
|
|
|
{
|
|
|
|
int temp;
|
|
|
|
|
|
|
|
/* Set the pll addr. to 0x00 */
|
2009-01-18 03:39:47 +00:00
|
|
|
pci_write_config_dword(nforce2_dev, NFORCE2_PLLADR, 0);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Now write the value in all 64 registers */
|
2006-02-28 05:43:23 +00:00
|
|
|
for (temp = 0; temp <= 0x3f; temp++)
|
2009-01-18 03:39:47 +00:00
|
|
|
pci_write_config_dword(nforce2_dev, NFORCE2_PLLREG, pll);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-02-28 05:43:23 +00:00
|
|
|
/**
|
2005-04-16 22:20:36 +00:00
|
|
|
* nforce2_fsb_read - Read FSB
|
|
|
|
*
|
|
|
|
* Read FSB from chipset
|
|
|
|
* If bootfsb != 0, return FSB at boot-time
|
|
|
|
*/
|
|
|
|
static unsigned int nforce2_fsb_read(int bootfsb)
|
|
|
|
{
|
|
|
|
struct pci_dev *nforce2_sub5;
|
|
|
|
u32 fsb, temp = 0;
|
|
|
|
|
|
|
|
/* Get chipset boot FSB from subdevice 5 (FSB at boot-time) */
|
2009-01-18 03:39:47 +00:00
|
|
|
nforce2_sub5 = pci_get_subsys(PCI_VENDOR_ID_NVIDIA, 0x01EF,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID, NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!nforce2_sub5)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
pci_read_config_dword(nforce2_sub5, NFORCE2_BOOTFSB, &fsb);
|
|
|
|
fsb /= 1000000;
|
2006-02-28 05:43:23 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Check if PLL register is already set */
|
2009-01-18 03:39:47 +00:00
|
|
|
pci_read_config_byte(nforce2_dev, NFORCE2_PLLENABLE, (u8 *)&temp);
|
2006-02-28 05:43:23 +00:00
|
|
|
|
2008-06-14 19:11:39 +00:00
|
|
|
if (bootfsb || !temp)
|
2005-04-16 22:20:36 +00:00
|
|
|
return fsb;
|
2008-06-14 19:11:39 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Use PLL register FSB value */
|
2009-01-18 03:39:47 +00:00
|
|
|
pci_read_config_dword(nforce2_dev, NFORCE2_PLLREG, &temp);
|
2005-04-16 22:20:36 +00:00
|
|
|
fsb = nforce2_calc_fsb(temp);
|
|
|
|
|
|
|
|
return fsb;
|
|
|
|
}
|
|
|
|
|
2006-02-28 05:43:23 +00:00
|
|
|
/**
|
2005-04-16 22:20:36 +00:00
|
|
|
* nforce2_set_fsb - set new FSB
|
|
|
|
* @fsb: New FSB
|
2006-02-28 05:43:23 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* Sets new FSB
|
|
|
|
*/
|
|
|
|
static int nforce2_set_fsb(unsigned int fsb)
|
|
|
|
{
|
2005-12-01 09:09:22 +00:00
|
|
|
u32 temp = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned int tfsb;
|
|
|
|
int diff;
|
2005-12-01 09:09:22 +00:00
|
|
|
int pll = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if ((fsb > max_fsb) || (fsb < NFORCE2_MIN_FSB)) {
|
2016-04-05 20:28:25 +00:00
|
|
|
pr_err("FSB %d is out of range!\n", fsb);
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2006-02-28 05:43:23 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
tfsb = nforce2_fsb_read(0);
|
|
|
|
if (!tfsb) {
|
2016-04-05 20:28:25 +00:00
|
|
|
pr_err("Error while reading the FSB\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* First write? Then set actual value */
|
2009-01-18 03:39:47 +00:00
|
|
|
pci_read_config_byte(nforce2_dev, NFORCE2_PLLENABLE, (u8 *)&temp);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!temp) {
|
|
|
|
pll = nforce2_calc_pll(tfsb);
|
|
|
|
|
|
|
|
if (pll < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
nforce2_write_pll(pll);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable write access */
|
|
|
|
temp = 0x01;
|
2009-01-18 03:39:47 +00:00
|
|
|
pci_write_config_byte(nforce2_dev, NFORCE2_PLLENABLE, (u8)temp);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
diff = tfsb - fsb;
|
|
|
|
|
|
|
|
if (!diff)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
while ((tfsb != fsb) && (tfsb <= max_fsb) && (tfsb >= min_fsb)) {
|
|
|
|
if (diff < 0)
|
|
|
|
tfsb++;
|
|
|
|
else
|
|
|
|
tfsb--;
|
|
|
|
|
|
|
|
/* Calculate the PLL reg. value */
|
2008-06-14 19:11:39 +00:00
|
|
|
pll = nforce2_calc_pll(tfsb);
|
|
|
|
if (pll == -1)
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EINVAL;
|
2006-02-28 05:43:23 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
nforce2_write_pll(pll);
|
|
|
|
#ifdef NFORCE2_DELAY
|
|
|
|
mdelay(NFORCE2_DELAY);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
temp = 0x40;
|
2009-01-18 03:39:47 +00:00
|
|
|
pci_write_config_byte(nforce2_dev, NFORCE2_PLLADR, (u8)temp);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nforce2_get - get the CPU frequency
|
|
|
|
* @cpu: CPU number
|
2006-02-28 05:43:23 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* Returns the CPU frequency
|
|
|
|
*/
|
|
|
|
static unsigned int nforce2_get(unsigned int cpu)
|
|
|
|
{
|
|
|
|
if (cpu)
|
|
|
|
return 0;
|
|
|
|
return nforce2_fsb_read(0) * fid * 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nforce2_target - set a new CPUFreq policy
|
|
|
|
* @policy: new policy
|
|
|
|
* @target_freq: the target frequency
|
2009-01-18 03:39:47 +00:00
|
|
|
* @relation: how that frequency relates to achieved frequency
|
|
|
|
* (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Sets a new CPUFreq policy.
|
|
|
|
*/
|
|
|
|
static int nforce2_target(struct cpufreq_policy *policy,
|
|
|
|
unsigned int target_freq, unsigned int relation)
|
|
|
|
{
|
2008-06-14 19:11:39 +00:00
|
|
|
/* unsigned long flags; */
|
2005-04-16 22:20:36 +00:00
|
|
|
struct cpufreq_freqs freqs;
|
|
|
|
unsigned int target_fsb;
|
|
|
|
|
|
|
|
if ((target_freq > policy->max) || (target_freq < policy->min))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
target_fsb = target_freq / (fid * 100);
|
|
|
|
|
|
|
|
freqs.old = nforce2_get(policy->cpu);
|
|
|
|
freqs.new = target_fsb * fid * 100;
|
|
|
|
|
|
|
|
if (freqs.old == freqs.new)
|
|
|
|
return 0;
|
|
|
|
|
2011-03-27 13:04:46 +00:00
|
|
|
pr_debug("Old CPU frequency %d kHz, new %d kHz\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
freqs.old, freqs.new);
|
|
|
|
|
2014-03-24 08:05:45 +00:00
|
|
|
cpufreq_freq_transition_begin(policy, &freqs);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Disable IRQs */
|
2008-06-14 19:11:39 +00:00
|
|
|
/* local_irq_save(flags); */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (nforce2_set_fsb(target_fsb) < 0)
|
2016-04-05 20:28:25 +00:00
|
|
|
pr_err("Changing FSB to %d failed\n", target_fsb);
|
2005-04-16 22:20:36 +00:00
|
|
|
else
|
2011-03-27 13:04:46 +00:00
|
|
|
pr_debug("Changed FSB successfully to %d\n",
|
2008-06-14 19:11:39 +00:00
|
|
|
target_fsb);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Enable IRQs */
|
2008-06-14 19:11:39 +00:00
|
|
|
/* local_irq_restore(flags); */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2014-03-24 08:05:45 +00:00
|
|
|
cpufreq_freq_transition_end(policy, &freqs, 0);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nforce2_verify - verifies a new CPUFreq policy
|
|
|
|
* @policy: new policy
|
|
|
|
*/
|
cpufreq: Avoid creating excessively large stack frames
In the process of modifying a cpufreq policy, the cpufreq core makes
a copy of it including all of the internals which is stored on the
CPU stack. Because struct cpufreq_policy is relatively large, this
may cause the size of the stack frame to exceed the 2 KB limit and
so the GCC complains when -Wframe-larger-than= is used.
In fact, it is not necessary to copy the entire policy structure
in order to modify it, however.
First, because cpufreq_set_policy() obtains the min and max policy
limits from frequency QoS now, it is not necessary to pass the limits
to it from the callers. The only things that need to be passed to it
from there are the new governor pointer or (if there is a built-in
governor in the driver) the "policy" value representing the governor
choice. They both can be passed as individual arguments, though, so
make cpufreq_set_policy() take them this way and rework its callers
accordingly. This avoids making copies of cpufreq policies in the
callers of cpufreq_set_policy().
Second, cpufreq_set_policy() still needs to pass the new policy
data to the ->verify() callback of the cpufreq driver whose task
is to sanitize the min and max policy limits. It still does not
need to make a full copy of struct cpufreq_policy for this purpose,
but it needs to pass a few items from it to the driver in case they
are needed (different drivers have different needs in that respect
and all of them have to be covered). For this reason, introduce
struct cpufreq_policy_data to hold copies of the members of
struct cpufreq_policy used by the existing ->verify() driver
callbacks and pass a pointer to a temporary structure of that
type to ->verify() (instead of passing a pointer to full struct
cpufreq_policy to it).
While at it, notice that intel_pstate and longrun don't really need
to verify the "policy" value in struct cpufreq_policy, so drop those
check from them to avoid copying "policy" into struct
cpufreq_policy_data (which allows it to be slightly smaller).
Also while at it fix up white space in a couple of places and make
cpufreq_set_policy() static (as it can be so).
Fixes: 3000ce3c52f8 ("cpufreq: Use per-policy frequency QoS")
Link: https://lore.kernel.org/linux-pm/CAMuHMdX6-jb1W8uC2_237m8ctCpsnGp=JCxqt8pCWVqNXHmkVg@mail.gmail.com
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: 5.4+ <stable@vger.kernel.org> # 5.4+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
2020-01-26 22:40:11 +00:00
|
|
|
static int nforce2_verify(struct cpufreq_policy_data *policy)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
unsigned int fsb_pol_max;
|
|
|
|
|
|
|
|
fsb_pol_max = policy->max / (fid * 100);
|
|
|
|
|
|
|
|
if (policy->min < (fsb_pol_max * fid * 100))
|
|
|
|
policy->max = (fsb_pol_max + 1) * fid * 100;
|
|
|
|
|
2013-10-02 08:43:19 +00:00
|
|
|
cpufreq_verify_within_cpu_limits(policy);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nforce2_cpu_init(struct cpufreq_policy *policy)
|
|
|
|
{
|
|
|
|
unsigned int fsb;
|
|
|
|
unsigned int rfid;
|
|
|
|
|
|
|
|
/* capability check */
|
|
|
|
if (policy->cpu != 0)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/* Get current FSB */
|
|
|
|
fsb = nforce2_fsb_read(0);
|
|
|
|
|
|
|
|
if (!fsb)
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
/* FIX: Get FID from CPU */
|
|
|
|
if (!fid) {
|
|
|
|
if (!cpu_khz) {
|
2016-04-05 20:28:25 +00:00
|
|
|
pr_warn("cpu_khz not set, can't calculate multiplier!\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
fid = cpu_khz / (fsb * 100);
|
|
|
|
rfid = fid % 5;
|
|
|
|
|
|
|
|
if (rfid) {
|
|
|
|
if (rfid > 2)
|
|
|
|
fid += 5 - rfid;
|
|
|
|
else
|
|
|
|
fid -= rfid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-05 20:28:25 +00:00
|
|
|
pr_info("FSB currently at %i MHz, FID %d.%d\n",
|
2016-04-05 20:28:24 +00:00
|
|
|
fsb, fid / 10, fid % 10);
|
2006-02-28 05:43:23 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Set maximum FSB to FSB at boot time */
|
|
|
|
max_fsb = nforce2_fsb_read(1);
|
2006-02-28 05:43:23 +00:00
|
|
|
|
2008-06-14 19:11:39 +00:00
|
|
|
if (!max_fsb)
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
if (!min_fsb)
|
|
|
|
min_fsb = max_fsb - NFORCE2_SAFE_DISTANCE;
|
|
|
|
|
|
|
|
if (min_fsb < NFORCE2_MIN_FSB)
|
|
|
|
min_fsb = NFORCE2_MIN_FSB;
|
|
|
|
|
|
|
|
/* cpuinfo and default policy values */
|
2013-04-01 12:57:48 +00:00
|
|
|
policy->min = policy->cpuinfo.min_freq = min_fsb * fid * 100;
|
|
|
|
policy->max = policy->cpuinfo.max_freq = max_fsb * fid * 100;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-02-26 22:55:48 +00:00
|
|
|
static struct cpufreq_driver nforce2_driver = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.name = "nforce2",
|
2017-07-19 10:12:48 +00:00
|
|
|
.flags = CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING,
|
2005-04-16 22:20:36 +00:00
|
|
|
.verify = nforce2_verify,
|
|
|
|
.target = nforce2_target,
|
|
|
|
.get = nforce2_get,
|
|
|
|
.init = nforce2_cpu_init,
|
|
|
|
};
|
|
|
|
|
2012-01-25 23:09:12 +00:00
|
|
|
#ifdef MODULE
|
2014-05-09 06:08:29 +00:00
|
|
|
static const struct pci_device_id nforce2_ids[] = {
|
2012-01-25 23:09:12 +00:00
|
|
|
{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2 },
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pci, nforce2_ids);
|
|
|
|
#endif
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/**
|
|
|
|
* nforce2_detect_chipset - detect the Southbridge which contains FSB PLL logic
|
|
|
|
*
|
|
|
|
* Detects nForce2 A2 and C1 stepping
|
2006-02-28 05:43:23 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2010-09-05 19:00:20 +00:00
|
|
|
static int nforce2_detect_chipset(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-01-18 03:39:47 +00:00
|
|
|
nforce2_dev = pci_get_subsys(PCI_VENDOR_ID_NVIDIA,
|
2006-02-28 05:43:23 +00:00
|
|
|
PCI_DEVICE_ID_NVIDIA_NFORCE2,
|
|
|
|
PCI_ANY_ID, PCI_ANY_ID, NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-01-18 03:39:47 +00:00
|
|
|
if (nforce2_dev == NULL)
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENODEV;
|
|
|
|
|
2016-04-05 20:28:25 +00:00
|
|
|
pr_info("Detected nForce2 chipset revision %X\n",
|
2016-04-05 20:28:24 +00:00
|
|
|
nforce2_dev->revision);
|
2016-04-05 20:28:25 +00:00
|
|
|
pr_info("FSB changing is maybe unstable and can lead to crashes and data loss\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nforce2_init - initializes the nForce2 CPUFreq driver
|
|
|
|
*
|
|
|
|
* Initializes the nForce2 FSB support. Returns -ENODEV on unsupported
|
2015-05-23 05:06:18 +00:00
|
|
|
* devices, -EINVAL on problems during initialization, and zero on
|
2005-04-16 22:20:36 +00:00
|
|
|
* success.
|
|
|
|
*/
|
|
|
|
static int __init nforce2_init(void)
|
|
|
|
{
|
|
|
|
/* TODO: do we need to detect the processor? */
|
|
|
|
|
|
|
|
/* detect chipset */
|
|
|
|
if (nforce2_detect_chipset()) {
|
2016-04-05 20:28:25 +00:00
|
|
|
pr_info("No nForce2 chipset\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cpufreq_register_driver(&nforce2_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nforce2_exit - unregisters cpufreq module
|
|
|
|
*
|
|
|
|
* Unregisters nForce2 FSB change support.
|
|
|
|
*/
|
|
|
|
static void __exit nforce2_exit(void)
|
|
|
|
{
|
|
|
|
cpufreq_unregister_driver(&nforce2_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(nforce2_init);
|
|
|
|
module_exit(nforce2_exit);
|