2010-09-18 00:03:43 +08:00
|
|
|
#ifndef _ASM_X86_AMD_NB_H
|
|
|
|
#define _ASM_X86_AMD_NB_H
|
2006-06-26 19:56:40 +08:00
|
|
|
|
2012-01-06 05:27:19 +08:00
|
|
|
#include <linux/ioport.h>
|
2006-06-26 19:56:40 +08:00
|
|
|
#include <linux/pci.h>
|
2017-05-19 17:39:13 +08:00
|
|
|
#include <linux/refcount.h>
|
2006-06-26 19:56:40 +08:00
|
|
|
|
2011-01-11 00:20:23 +08:00
|
|
|
struct amd_nb_bus_dev_range {
|
|
|
|
u8 bus;
|
|
|
|
u8 dev_base;
|
|
|
|
u8 dev_limit;
|
|
|
|
};
|
|
|
|
|
2011-02-09 16:26:53 +08:00
|
|
|
extern const struct pci_device_id amd_nb_misc_ids[];
|
2011-01-11 00:20:23 +08:00
|
|
|
extern const struct amd_nb_bus_dev_range amd_nb_bus_dev_ranges[];
|
2006-06-26 19:56:40 +08:00
|
|
|
|
2011-03-03 19:59:32 +08:00
|
|
|
extern bool early_is_amd_nb(u32 value);
|
2012-01-06 05:27:19 +08:00
|
|
|
extern struct resource *amd_get_mmconfig_range(struct resource *res);
|
2010-10-29 23:14:31 +08:00
|
|
|
extern int amd_cache_northbridges(void);
|
2010-10-29 23:14:30 +08:00
|
|
|
extern void amd_flush_garts(void);
|
2011-02-16 19:13:06 +08:00
|
|
|
extern int amd_numa_init(void);
|
2011-02-08 01:10:39 +08:00
|
|
|
extern int amd_get_subcaches(int);
|
2014-01-21 15:22:09 +08:00
|
|
|
extern int amd_set_subcaches(int, unsigned long);
|
2006-06-26 19:56:40 +08:00
|
|
|
|
2016-11-11 05:10:56 +08:00
|
|
|
extern int amd_smn_read(u16 node, u32 address, u32 *value);
|
|
|
|
extern int amd_smn_write(u16 node, u32 address, u32 value);
|
|
|
|
extern int amd_df_indirect_read(u16 node, u8 func, u16 reg, u8 instance_id, u32 *lo);
|
|
|
|
|
2011-07-24 17:46:09 +08:00
|
|
|
struct amd_l3_cache {
|
|
|
|
unsigned indices;
|
|
|
|
u8 subcaches[4];
|
|
|
|
};
|
|
|
|
|
2012-05-02 23:16:59 +08:00
|
|
|
struct threshold_block {
|
2016-03-07 21:02:21 +08:00
|
|
|
unsigned int block; /* Number within bank */
|
|
|
|
unsigned int bank; /* MCA bank the block belongs to */
|
|
|
|
unsigned int cpu; /* CPU which controls MCA bank */
|
|
|
|
u32 address; /* MSR address for the block */
|
|
|
|
u16 interrupt_enable; /* Enable/Disable APIC interrupt */
|
|
|
|
bool interrupt_capable; /* Bank can generate an interrupt. */
|
|
|
|
|
|
|
|
u16 threshold_limit; /*
|
|
|
|
* Value upon which threshold
|
|
|
|
* interrupt is generated.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct kobject kobj; /* sysfs object */
|
|
|
|
struct list_head miscj; /*
|
|
|
|
* List of threshold blocks
|
|
|
|
* within a bank.
|
|
|
|
*/
|
2012-05-02 23:16:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct threshold_bank {
|
|
|
|
struct kobject *kobj;
|
|
|
|
struct threshold_block *blocks;
|
|
|
|
|
|
|
|
/* initialized to the number of CPUs on the node sharing this bank */
|
2017-05-19 17:39:13 +08:00
|
|
|
refcount_t cpus;
|
2012-05-02 23:16:59 +08:00
|
|
|
};
|
|
|
|
|
2010-10-29 23:14:31 +08:00
|
|
|
struct amd_northbridge {
|
2016-11-11 05:10:56 +08:00
|
|
|
struct pci_dev *root;
|
2010-10-29 23:14:31 +08:00
|
|
|
struct pci_dev *misc;
|
2011-01-24 23:05:42 +08:00
|
|
|
struct pci_dev *link;
|
2011-07-24 17:46:09 +08:00
|
|
|
struct amd_l3_cache l3_cache;
|
2012-05-02 23:16:59 +08:00
|
|
|
struct threshold_bank *bank4;
|
2010-10-29 23:14:31 +08:00
|
|
|
};
|
|
|
|
|
2010-10-29 23:14:30 +08:00
|
|
|
struct amd_northbridge_info {
|
2010-09-18 00:02:54 +08:00
|
|
|
u16 num;
|
2010-10-29 23:14:31 +08:00
|
|
|
u64 flags;
|
|
|
|
struct amd_northbridge *nb;
|
2010-09-18 00:02:54 +08:00
|
|
|
};
|
|
|
|
|
2011-03-03 19:59:32 +08:00
|
|
|
#define AMD_NB_GART BIT(0)
|
|
|
|
#define AMD_NB_L3_INDEX_DISABLE BIT(1)
|
|
|
|
#define AMD_NB_L3_PARTITIONING BIT(2)
|
2010-10-29 23:14:31 +08:00
|
|
|
|
2010-09-18 00:03:43 +08:00
|
|
|
#ifdef CONFIG_AMD_NB
|
2010-04-24 15:56:53 +08:00
|
|
|
|
2016-11-11 05:10:53 +08:00
|
|
|
u16 amd_nb_num(void);
|
|
|
|
bool amd_nb_has_feature(unsigned int feature);
|
|
|
|
struct amd_northbridge *node_to_amd_nb(int node);
|
2010-10-29 23:14:31 +08:00
|
|
|
|
2015-10-19 17:17:42 +08:00
|
|
|
static inline u16 amd_pci_dev_to_node_id(struct pci_dev *pdev)
|
2012-11-27 14:32:09 +08:00
|
|
|
{
|
|
|
|
struct pci_dev *misc;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i != amd_nb_num(); i++) {
|
|
|
|
misc = node_to_amd_nb(i)->misc;
|
|
|
|
|
|
|
|
if (pci_domain_nr(misc->bus) == pci_domain_nr(pdev->bus) &&
|
|
|
|
PCI_SLOT(misc->devfn) == PCI_SLOT(pdev->devfn))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN(1, "Unable to find AMD Northbridge id for %s\n", pci_name(pdev));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-04-08 05:46:37 +08:00
|
|
|
static inline bool amd_gart_present(void)
|
|
|
|
{
|
|
|
|
/* GART present only on Fam15h, upto model 0fh */
|
|
|
|
if (boot_cpu_data.x86 == 0xf || boot_cpu_data.x86 == 0x10 ||
|
|
|
|
(boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model < 0x10))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-10-29 23:14:31 +08:00
|
|
|
#else
|
|
|
|
|
|
|
|
#define amd_nb_num(x) 0
|
|
|
|
#define amd_nb_has_feature(x) false
|
|
|
|
#define node_to_amd_nb(x) NULL
|
2015-04-08 05:46:37 +08:00
|
|
|
#define amd_gart_present(x) false
|
2010-10-29 23:14:31 +08:00
|
|
|
|
2009-04-09 21:16:17 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2010-09-18 00:03:43 +08:00
|
|
|
#endif /* _ASM_X86_AMD_NB_H */
|