11 #ifndef _ASM_X86_UV_UV_HUB_H
12 #define _ASM_X86_UV_UV_HUB_H
19 #include <asm/types.h>
20 #include <asm/percpu.h>
21 #include <asm/uv/uv_mmrs.h>
22 #include <asm/irq_vectors.h>
117 #define UV_MAX_NUMALINK_BLADES 16384
123 #define UV_MAX_SSI_BLADES 256
128 #define UV_MAX_NASID_VALUE (UV_MAX_NUMALINK_BLADES * 2)
134 unsigned long idle_on;
135 unsigned long idle_off;
148 unsigned int gnode_extra;
149 unsigned char hub_revision;
150 unsigned char apic_pnode_shift;
151 unsigned char m_shift;
152 unsigned char n_lshift;
156 unsigned short pnode;
163 struct uv_scir_s scir;
167 #define uv_hub_info (&__get_cpu_var(__uv_hub_info))
168 #define uv_cpu_hub_info(cpu) (&per_cpu(__uv_hub_info, cpu))
176 #define UV1_HUB_REVISION_BASE 1
177 #define UV2_HUB_REVISION_BASE 3
179 static inline int is_uv1_hub(
void)
181 return uv_hub_info->hub_revision < UV2_HUB_REVISION_BASE;
184 static inline int is_uv2_hub(
void)
186 return uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE;
189 static inline int is_uv2_1_hub(
void)
191 return uv_hub_info->hub_revision == UV2_HUB_REVISION_BASE;
194 static inline int is_uv2_2_hub(
void)
196 return uv_hub_info->hub_revision == UV2_HUB_REVISION_BASE + 1;
201 struct uvh_apicid_s {
202 unsigned long local_apic_mask : 24;
203 unsigned long local_apic_shift : 5;
205 unsigned long pnode_mask : 24;
206 unsigned long pnode_shift : 5;
219 #define UV_NASID_TO_PNODE(n) (((n) >> 1) & uv_hub_info->pnode_mask)
220 #define UV_PNODE_TO_GNODE(p) ((p) |uv_hub_info->gnode_extra)
221 #define UV_PNODE_TO_NASID(p) (UV_PNODE_TO_GNODE(p) << 1)
223 #define UV1_LOCAL_MMR_BASE 0xf4000000UL
224 #define UV1_GLOBAL_MMR32_BASE 0xf8000000UL
225 #define UV1_LOCAL_MMR_SIZE (64UL * 1024 * 1024)
226 #define UV1_GLOBAL_MMR32_SIZE (64UL * 1024 * 1024)
228 #define UV2_LOCAL_MMR_BASE 0xfa000000UL
229 #define UV2_GLOBAL_MMR32_BASE 0xfc000000UL
230 #define UV2_LOCAL_MMR_SIZE (32UL * 1024 * 1024)
231 #define UV2_GLOBAL_MMR32_SIZE (32UL * 1024 * 1024)
233 #define UV_LOCAL_MMR_BASE (is_uv1_hub() ? UV1_LOCAL_MMR_BASE \
234 : UV2_LOCAL_MMR_BASE)
235 #define UV_GLOBAL_MMR32_BASE (is_uv1_hub() ? UV1_GLOBAL_MMR32_BASE \
236 : UV2_GLOBAL_MMR32_BASE)
237 #define UV_LOCAL_MMR_SIZE (is_uv1_hub() ? UV1_LOCAL_MMR_SIZE : \
239 #define UV_GLOBAL_MMR32_SIZE (is_uv1_hub() ? UV1_GLOBAL_MMR32_SIZE :\
240 UV2_GLOBAL_MMR32_SIZE)
241 #define UV_GLOBAL_MMR64_BASE (uv_hub_info->global_mmr_base)
243 #define UV_GLOBAL_GRU_MMR_BASE 0x4000000
245 #define UV_GLOBAL_MMR32_PNODE_SHIFT 15
246 #define UV_GLOBAL_MMR64_PNODE_SHIFT 26
248 #define UV_GLOBAL_MMR32_PNODE_BITS(p) ((p) << (UV_GLOBAL_MMR32_PNODE_SHIFT))
250 #define UV_GLOBAL_MMR64_PNODE_BITS(p) \
251 (((unsigned long)(p)) << UV_GLOBAL_MMR64_PNODE_SHIFT)
253 #define UVH_APICID 0x002D0E00L
254 #define UV_APIC_PNODE_SHIFT 6
256 #define UV_APICID_HIBIT_MASK 0xffff0000
259 #define LOCAL_BUS_BASE 0x1c00000
260 #define LOCAL_BUS_SIZE (4 * 1024 * 1024)
273 #define SCIR_WINDOW_COUNT 64
274 #define SCIR_LOCAL_MMR_BASE (LOCAL_BUS_BASE + \
278 #define SCIR_CPU_HEARTBEAT 0x01
279 #define SCIR_CPU_ACTIVITY 0x02
280 #define SCIR_CPU_HB_INTERVAL (HZ)
283 #define for_each_possible_blade(bid) \
284 for ((bid) = 0; (bid) < uv_num_possible_blades(); (bid)++)
294 static inline unsigned long uv_soc_phys_ram_to_gpa(
unsigned long paddr)
296 if (paddr < uv_hub_info->lowmem_remap_top)
306 static inline unsigned long uv_gpa(
void *
v)
308 return uv_soc_phys_ram_to_gpa(
__pa(v));
313 uv_gpa_in_mmr_space(
unsigned long gpa)
315 return (gpa >> 62) == 0x3
UL;
319 static inline unsigned long uv_gpa_to_soc_phys_ram(
unsigned long gpa)
322 unsigned long remap_base =
uv_hub_info->lowmem_remap_base;
323 unsigned long remap_top =
uv_hub_info->lowmem_remap_top;
328 if (paddr >= remap_base && paddr < remap_base + remap_top)
335 static inline unsigned long uv_gpa_to_gnode(
unsigned long gpa)
341 static inline int uv_gpa_to_pnode(
unsigned long gpa)
345 return uv_gpa_to_gnode(gpa) & n_mask;
349 static inline unsigned long uv_gpa_to_offset(
unsigned long gpa)
355 static inline void *uv_pnode_offset_to_vaddr(
int pnode,
unsigned long offset)
364 static inline int uv_apicid_to_pnode(
int apicid)
372 static inline int uv_apicid_to_socket(
int apicid)
375 return (apicid >> (
uv_hub_info->apic_pnode_shift - 1)) & 1;
384 static inline unsigned long *uv_global_mmr32_address(
int pnode,
unsigned long offset)
390 static inline void uv_write_global_mmr32(
int pnode,
unsigned long offset,
unsigned long val)
392 writeq(val, uv_global_mmr32_address(pnode, offset));
395 static inline unsigned long uv_read_global_mmr32(
int pnode,
unsigned long offset)
397 return readq(uv_global_mmr32_address(pnode, offset));
404 static inline volatile void __iomem *uv_global_mmr64_address(
int pnode,
unsigned long offset)
410 static inline void uv_write_global_mmr64(
int pnode,
unsigned long offset,
unsigned long val)
412 writeq(val, uv_global_mmr64_address(pnode, offset));
415 static inline unsigned long uv_read_global_mmr64(
int pnode,
unsigned long offset)
417 return readq(uv_global_mmr64_address(pnode, offset));
424 static inline unsigned long uv_global_gru_mmr_address(
int pnode,
unsigned long offset)
426 return UV_GLOBAL_GRU_MMR_BASE | offset |
430 static inline void uv_write_global_mmr8(
int pnode,
unsigned long offset,
unsigned char val)
432 writeb(val, uv_global_mmr64_address(pnode, offset));
435 static inline unsigned char uv_read_global_mmr8(
int pnode,
unsigned long offset)
437 return readb(uv_global_mmr64_address(pnode, offset));
444 static inline unsigned long *uv_local_mmr_address(
unsigned long offset)
449 static inline unsigned long uv_read_local_mmr(
unsigned long offset)
451 return readq(uv_local_mmr_address(offset));
454 static inline void uv_write_local_mmr(
unsigned long offset,
unsigned long val)
456 writeq(val, uv_local_mmr_address(offset));
459 static inline unsigned char uv_read_local_mmr8(
unsigned long offset)
461 return readb(uv_local_mmr_address(offset));
464 static inline void uv_write_local_mmr8(
unsigned long offset,
unsigned char val)
466 writeb(val, uv_local_mmr_address(offset));
474 unsigned short nr_possible_cpus;
475 unsigned short nr_online_cpus;
476 unsigned short pnode;
487 static inline int uv_blade_processor_id(
void)
493 static inline int uv_numa_blade_id(
void)
499 static inline int uv_cpu_to_blade_id(
int cpu)
501 return uv_cpu_to_blade[
cpu];
505 static inline int uv_node_to_blade_id(
int nid)
507 return uv_node_to_blade[nid];
511 static inline int uv_blade_to_pnode(
int bid)
513 return uv_blade_info[
bid].pnode;
517 static inline int uv_blade_to_memory_nid(
int bid)
519 return uv_blade_info[
bid].memory_nid;
523 static inline int uv_blade_nr_possible_cpus(
int bid)
525 return uv_blade_info[
bid].nr_possible_cpus;
529 static inline int uv_blade_nr_online_cpus(
int bid)
531 return uv_blade_info[
bid].nr_online_cpus;
535 static inline int uv_cpu_to_pnode(
int cpu)
537 return uv_blade_info[uv_cpu_to_blade_id(cpu)].pnode;
541 static inline int uv_node_to_pnode(
int nid)
543 return uv_blade_info[uv_node_to_blade_id(nid)].pnode;
547 static inline int uv_num_possible_blades(
void)
553 static inline void uv_set_scir_bits(
unsigned char value)
557 uv_write_local_mmr8(
uv_hub_info->scir.offset, value);
561 static inline unsigned long uv_scir_offset(
int apicid)
563 return SCIR_LOCAL_MMR_BASE | (apicid & 0x3f);
566 static inline void uv_set_cpu_scir_bits(
int cpu,
unsigned char value)
569 uv_write_global_mmr8(uv_cpu_to_pnode(cpu),
576 static unsigned long uv_hub_ipi_value(
int apicid,
int vector,
int mode)
585 static inline void uv_hub_send_ipi(
int pnode,
int apicid,
int vector)
593 val = uv_hub_ipi_value(apicid, vector, dmode);
603 static inline int uv_get_min_hub_revision_id(
void)