~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to arch/x86/kernel/amd_nb.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 
13
13
static u32 *flush_words;
14
14
 
15
 
struct pci_device_id amd_nb_misc_ids[] = {
 
15
const struct pci_device_id amd_nb_misc_ids[] = {
16
16
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) },
17
17
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) },
18
 
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_MISC) },
 
18
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F3) },
19
19
        {}
20
20
};
21
21
EXPORT_SYMBOL(amd_nb_misc_ids);
22
22
 
 
23
static struct pci_device_id amd_nb_link_ids[] = {
 
24
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) },
 
25
        {}
 
26
};
 
27
 
23
28
const struct amd_nb_bus_dev_range amd_nb_bus_dev_ranges[] __initconst = {
24
29
        { 0x00, 0x18, 0x20 },
25
30
        { 0xff, 0x00, 0x20 },
31
36
EXPORT_SYMBOL(amd_northbridges);
32
37
 
33
38
static struct pci_dev *next_northbridge(struct pci_dev *dev,
34
 
                                        struct pci_device_id *ids)
 
39
                                        const struct pci_device_id *ids)
35
40
{
36
41
        do {
37
42
                dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev);
43
48
 
44
49
int amd_cache_northbridges(void)
45
50
{
46
 
        int i = 0;
 
51
        u16 i = 0;
47
52
        struct amd_northbridge *nb;
48
 
        struct pci_dev *misc;
 
53
        struct pci_dev *misc, *link;
49
54
 
50
55
        if (amd_nb_num())
51
56
                return 0;
64
69
        amd_northbridges.nb = nb;
65
70
        amd_northbridges.num = i;
66
71
 
67
 
        misc = NULL;
 
72
        link = misc = NULL;
68
73
        for (i = 0; i != amd_nb_num(); i++) {
69
74
                node_to_amd_nb(i)->misc = misc =
70
75
                        next_northbridge(misc, amd_nb_misc_ids);
 
76
                node_to_amd_nb(i)->link = link =
 
77
                        next_northbridge(link, amd_nb_link_ids);
71
78
        }
72
79
 
73
80
        /* some CPU families (e.g. family 0x11) do not support GART */
85
92
             boot_cpu_data.x86_mask >= 0x1))
86
93
                amd_northbridges.flags |= AMD_NB_L3_INDEX_DISABLE;
87
94
 
 
95
        if (boot_cpu_data.x86 == 0x15)
 
96
                amd_northbridges.flags |= AMD_NB_L3_INDEX_DISABLE;
 
97
 
 
98
        /* L3 cache partitioning is supported on family 0x15 */
 
99
        if (boot_cpu_data.x86 == 0x15)
 
100
                amd_northbridges.flags |= AMD_NB_L3_PARTITIONING;
 
101
 
88
102
        return 0;
89
103
}
90
104
EXPORT_SYMBOL_GPL(amd_cache_northbridges);
91
105
 
92
 
/* Ignores subdevice/subvendor but as far as I can figure out
93
 
   they're useless anyways */
94
 
int __init early_is_amd_nb(u32 device)
 
106
/*
 
107
 * Ignores subdevice/subvendor but as far as I can figure out
 
108
 * they're useless anyways
 
109
 */
 
110
bool __init early_is_amd_nb(u32 device)
95
111
{
96
 
        struct pci_device_id *id;
 
112
        const struct pci_device_id *id;
97
113
        u32 vendor = device & 0xffff;
 
114
 
98
115
        device >>= 16;
99
116
        for (id = amd_nb_misc_ids; id->vendor; id++)
100
117
                if (vendor == id->vendor && device == id->device)
101
 
                        return 1;
 
118
                        return true;
 
119
        return false;
 
120
}
 
121
 
 
122
int amd_get_subcaches(int cpu)
 
123
{
 
124
        struct pci_dev *link = node_to_amd_nb(amd_get_nb_id(cpu))->link;
 
125
        unsigned int mask;
 
126
        int cuid = 0;
 
127
 
 
128
        if (!amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
 
129
                return 0;
 
130
 
 
131
        pci_read_config_dword(link, 0x1d4, &mask);
 
132
 
 
133
#ifdef CONFIG_SMP
 
134
        cuid = cpu_data(cpu).compute_unit_id;
 
135
#endif
 
136
        return (mask >> (4 * cuid)) & 0xf;
 
137
}
 
138
 
 
139
int amd_set_subcaches(int cpu, int mask)
 
140
{
 
141
        static unsigned int reset, ban;
 
142
        struct amd_northbridge *nb = node_to_amd_nb(amd_get_nb_id(cpu));
 
143
        unsigned int reg;
 
144
        int cuid = 0;
 
145
 
 
146
        if (!amd_nb_has_feature(AMD_NB_L3_PARTITIONING) || mask > 0xf)
 
147
                return -EINVAL;
 
148
 
 
149
        /* if necessary, collect reset state of L3 partitioning and BAN mode */
 
150
        if (reset == 0) {
 
151
                pci_read_config_dword(nb->link, 0x1d4, &reset);
 
152
                pci_read_config_dword(nb->misc, 0x1b8, &ban);
 
153
                ban &= 0x180000;
 
154
        }
 
155
 
 
156
        /* deactivate BAN mode if any subcaches are to be disabled */
 
157
        if (mask != 0xf) {
 
158
                pci_read_config_dword(nb->misc, 0x1b8, &reg);
 
159
                pci_write_config_dword(nb->misc, 0x1b8, reg & ~0x180000);
 
160
        }
 
161
 
 
162
#ifdef CONFIG_SMP
 
163
        cuid = cpu_data(cpu).compute_unit_id;
 
164
#endif
 
165
        mask <<= 4 * cuid;
 
166
        mask |= (0xf ^ (1 << cuid)) << 26;
 
167
 
 
168
        pci_write_config_dword(nb->link, 0x1d4, mask);
 
169
 
 
170
        /* reset BAN mode if L3 partitioning returned to reset state */
 
171
        pci_read_config_dword(nb->link, 0x1d4, &reg);
 
172
        if (reg == reset) {
 
173
                pci_read_config_dword(nb->misc, 0x1b8, &reg);
 
174
                reg &= ~0x180000;
 
175
                pci_write_config_dword(nb->misc, 0x1b8, reg | ban);
 
176
        }
 
177
 
102
178
        return 0;
103
179
}
104
180
 
105
 
int amd_cache_gart(void)
 
181
static int amd_cache_gart(void)
106
182
{
107
 
       int i;
 
183
        u16 i;
108
184
 
109
185
       if (!amd_nb_has_feature(AMD_NB_GART))
110
186
               return 0;