diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-01-28 13:01:05 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-01-29 08:16:45 -0500 |
commit | 2e096df8edefad78155bb406a5a86c182b17786e (patch) | |
tree | 3df8d35e23303644cb42950e6991de2d8dbede81 /arch/x86 | |
parent | 83d7aeabe4cf20e59b5d7fd56a75cfd0e0b6b880 (diff) |
x86, ES7000: Consolidate code
Move all ES7000 code into arch/x86/kernel/es7000_32.c.
With this it ceases to rely on any build-time subarch features.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/es7000_32.c | 428 | ||||
-rw-r--r-- | arch/x86/mach-generic/Makefile | 1 | ||||
-rw-r--r-- | arch/x86/mach-generic/es7000.c | 427 |
3 files changed, 428 insertions, 428 deletions
diff --git a/arch/x86/kernel/es7000_32.c b/arch/x86/kernel/es7000_32.c index 8faea13c8fac..078364ccfa07 100644 --- a/arch/x86/kernel/es7000_32.c +++ b/arch/x86/kernel/es7000_32.c | |||
@@ -372,3 +372,431 @@ void __init es7000_enable_apic_mode(void) | |||
372 | mip_status); | 372 | mip_status); |
373 | } | 373 | } |
374 | } | 374 | } |
375 | |||
376 | /* | ||
377 | * APIC driver for the Unisys ES7000 chipset. | ||
378 | */ | ||
379 | #define APIC_DEFINITION 1 | ||
380 | #include <linux/threads.h> | ||
381 | #include <linux/cpumask.h> | ||
382 | #include <asm/mpspec.h> | ||
383 | #include <asm/genapic.h> | ||
384 | #include <asm/fixmap.h> | ||
385 | #include <asm/apicdef.h> | ||
386 | #include <linux/kernel.h> | ||
387 | #include <linux/string.h> | ||
388 | #include <linux/init.h> | ||
389 | #include <linux/acpi.h> | ||
390 | #include <linux/smp.h> | ||
391 | #include <asm/ipi.h> | ||
392 | |||
393 | #define APIC_DFR_VALUE_CLUSTER (APIC_DFR_CLUSTER) | ||
394 | #define INT_DELIVERY_MODE_CLUSTER (dest_LowestPrio) | ||
395 | #define INT_DEST_MODE_CLUSTER (1) /* logical delivery broadcast to all procs */ | ||
396 | |||
397 | #define APIC_DFR_VALUE (APIC_DFR_FLAT) | ||
398 | |||
399 | extern void es7000_enable_apic_mode(void); | ||
400 | extern int apic_version [MAX_APICS]; | ||
401 | extern u8 cpu_2_logical_apicid[]; | ||
402 | extern unsigned int boot_cpu_physical_apicid; | ||
403 | |||
404 | extern int parse_unisys_oem (char *oemptr); | ||
405 | extern int find_unisys_acpi_oem_table(unsigned long *oem_addr); | ||
406 | extern void unmap_unisys_acpi_oem_table(unsigned long oem_addr); | ||
407 | extern void setup_unisys(void); | ||
408 | |||
409 | #define apicid_cluster(apicid) (apicid & 0xF0) | ||
410 | #define xapic_phys_to_log_apicid(cpu) per_cpu(x86_bios_cpu_apicid, cpu) | ||
411 | |||
412 | static void es7000_vector_allocation_domain(int cpu, cpumask_t *retmask) | ||
413 | { | ||
414 | /* Careful. Some cpus do not strictly honor the set of cpus | ||
415 | * specified in the interrupt destination when using lowest | ||
416 | * priority interrupt delivery mode. | ||
417 | * | ||
418 | * In particular there was a hyperthreading cpu observed to | ||
419 | * deliver interrupts to the wrong hyperthread when only one | ||
420 | * hyperthread was specified in the interrupt desitination. | ||
421 | */ | ||
422 | *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } }; | ||
423 | } | ||
424 | |||
425 | |||
426 | static void es7000_wait_for_init_deassert(atomic_t *deassert) | ||
427 | { | ||
428 | #ifndef CONFIG_ES7000_CLUSTERED_APIC | ||
429 | while (!atomic_read(deassert)) | ||
430 | cpu_relax(); | ||
431 | #endif | ||
432 | return; | ||
433 | } | ||
434 | |||
435 | static unsigned int es7000_get_apic_id(unsigned long x) | ||
436 | { | ||
437 | return (x >> 24) & 0xFF; | ||
438 | } | ||
439 | |||
440 | #ifdef CONFIG_ACPI | ||
441 | static int es7000_check_dsdt(void) | ||
442 | { | ||
443 | struct acpi_table_header header; | ||
444 | |||
445 | if (ACPI_SUCCESS(acpi_get_table_header(ACPI_SIG_DSDT, 0, &header)) && | ||
446 | !strncmp(header.oem_id, "UNISYS", 6)) | ||
447 | return 1; | ||
448 | return 0; | ||
449 | } | ||
450 | #endif | ||
451 | |||
452 | static void es7000_send_IPI_mask(const struct cpumask *mask, int vector) | ||
453 | { | ||
454 | default_send_IPI_mask_sequence(mask, vector); | ||
455 | } | ||
456 | |||
457 | static void es7000_send_IPI_allbutself(int vector) | ||
458 | { | ||
459 | default_send_IPI_mask_allbutself(cpu_online_mask, vector); | ||
460 | } | ||
461 | |||
462 | static void es7000_send_IPI_all(int vector) | ||
463 | { | ||
464 | es7000_send_IPI_mask(cpu_online_mask, vector); | ||
465 | } | ||
466 | |||
467 | static int es7000_apic_id_registered(void) | ||
468 | { | ||
469 | return 1; | ||
470 | } | ||
471 | |||
472 | static const cpumask_t *target_cpus_cluster(void) | ||
473 | { | ||
474 | return &CPU_MASK_ALL; | ||
475 | } | ||
476 | |||
477 | static const cpumask_t *es7000_target_cpus(void) | ||
478 | { | ||
479 | return &cpumask_of_cpu(smp_processor_id()); | ||
480 | } | ||
481 | |||
482 | static unsigned long | ||
483 | es7000_check_apicid_used(physid_mask_t bitmap, int apicid) | ||
484 | { | ||
485 | return 0; | ||
486 | } | ||
487 | static unsigned long es7000_check_apicid_present(int bit) | ||
488 | { | ||
489 | return physid_isset(bit, phys_cpu_present_map); | ||
490 | } | ||
491 | |||
492 | static unsigned long calculate_ldr(int cpu) | ||
493 | { | ||
494 | unsigned long id = xapic_phys_to_log_apicid(cpu); | ||
495 | |||
496 | return (SET_APIC_LOGICAL_ID(id)); | ||
497 | } | ||
498 | |||
499 | /* | ||
500 | * Set up the logical destination ID. | ||
501 | * | ||
502 | * Intel recommends to set DFR, LdR and TPR before enabling | ||
503 | * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel | ||
504 | * document number 292116). So here it goes... | ||
505 | */ | ||
506 | static void es7000_init_apic_ldr_cluster(void) | ||
507 | { | ||
508 | unsigned long val; | ||
509 | int cpu = smp_processor_id(); | ||
510 | |||
511 | apic_write(APIC_DFR, APIC_DFR_VALUE_CLUSTER); | ||
512 | val = calculate_ldr(cpu); | ||
513 | apic_write(APIC_LDR, val); | ||
514 | } | ||
515 | |||
516 | static void es7000_init_apic_ldr(void) | ||
517 | { | ||
518 | unsigned long val; | ||
519 | int cpu = smp_processor_id(); | ||
520 | |||
521 | apic_write(APIC_DFR, APIC_DFR_VALUE); | ||
522 | val = calculate_ldr(cpu); | ||
523 | apic_write(APIC_LDR, val); | ||
524 | } | ||
525 | |||
526 | static void es7000_setup_apic_routing(void) | ||
527 | { | ||
528 | int apic = per_cpu(x86_bios_cpu_apicid, smp_processor_id()); | ||
529 | printk("Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n", | ||
530 | (apic_version[apic] == 0x14) ? | ||
531 | "Physical Cluster" : "Logical Cluster", | ||
532 | nr_ioapics, cpus_addr(*es7000_target_cpus())[0]); | ||
533 | } | ||
534 | |||
535 | static int es7000_apicid_to_node(int logical_apicid) | ||
536 | { | ||
537 | return 0; | ||
538 | } | ||
539 | |||
540 | |||
541 | static int es7000_cpu_present_to_apicid(int mps_cpu) | ||
542 | { | ||
543 | if (!mps_cpu) | ||
544 | return boot_cpu_physical_apicid; | ||
545 | else if (mps_cpu < nr_cpu_ids) | ||
546 | return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu); | ||
547 | else | ||
548 | return BAD_APICID; | ||
549 | } | ||
550 | |||
551 | static physid_mask_t es7000_apicid_to_cpu_present(int phys_apicid) | ||
552 | { | ||
553 | static int id = 0; | ||
554 | physid_mask_t mask; | ||
555 | |||
556 | mask = physid_mask_of_physid(id); | ||
557 | ++id; | ||
558 | |||
559 | return mask; | ||
560 | } | ||
561 | |||
562 | /* Mapping from cpu number to logical apicid */ | ||
563 | static int es7000_cpu_to_logical_apicid(int cpu) | ||
564 | { | ||
565 | #ifdef CONFIG_SMP | ||
566 | if (cpu >= nr_cpu_ids) | ||
567 | return BAD_APICID; | ||
568 | return (int)cpu_2_logical_apicid[cpu]; | ||
569 | #else | ||
570 | return logical_smp_processor_id(); | ||
571 | #endif | ||
572 | } | ||
573 | |||
574 | static physid_mask_t es7000_ioapic_phys_id_map(physid_mask_t phys_map) | ||
575 | { | ||
576 | /* For clustered we don't have a good way to do this yet - hack */ | ||
577 | return physids_promote(0xff); | ||
578 | } | ||
579 | |||
580 | static int es7000_check_phys_apicid_present(int cpu_physical_apicid) | ||
581 | { | ||
582 | boot_cpu_physical_apicid = read_apic_id(); | ||
583 | return (1); | ||
584 | } | ||
585 | |||
586 | static unsigned int | ||
587 | es7000_cpu_mask_to_apicid_cluster(const struct cpumask *cpumask) | ||
588 | { | ||
589 | int cpus_found = 0; | ||
590 | int num_bits_set; | ||
591 | int apicid; | ||
592 | int cpu; | ||
593 | |||
594 | num_bits_set = cpumask_weight(cpumask); | ||
595 | /* Return id to all */ | ||
596 | if (num_bits_set == nr_cpu_ids) | ||
597 | return 0xFF; | ||
598 | /* | ||
599 | * The cpus in the mask must all be on the apic cluster. If are not | ||
600 | * on the same apicid cluster return default value of target_cpus(): | ||
601 | */ | ||
602 | cpu = cpumask_first(cpumask); | ||
603 | apicid = es7000_cpu_to_logical_apicid(cpu); | ||
604 | |||
605 | while (cpus_found < num_bits_set) { | ||
606 | if (cpumask_test_cpu(cpu, cpumask)) { | ||
607 | int new_apicid = es7000_cpu_to_logical_apicid(cpu); | ||
608 | |||
609 | if (apicid_cluster(apicid) != | ||
610 | apicid_cluster(new_apicid)) { | ||
611 | printk ("%s: Not a valid mask!\n", __func__); | ||
612 | |||
613 | return 0xFF; | ||
614 | } | ||
615 | apicid = new_apicid; | ||
616 | cpus_found++; | ||
617 | } | ||
618 | cpu++; | ||
619 | } | ||
620 | return apicid; | ||
621 | } | ||
622 | |||
623 | static unsigned int es7000_cpu_mask_to_apicid(const cpumask_t *cpumask) | ||
624 | { | ||
625 | int cpus_found = 0; | ||
626 | int num_bits_set; | ||
627 | int apicid; | ||
628 | int cpu; | ||
629 | |||
630 | num_bits_set = cpus_weight(*cpumask); | ||
631 | /* Return id to all */ | ||
632 | if (num_bits_set == nr_cpu_ids) | ||
633 | return es7000_cpu_to_logical_apicid(0); | ||
634 | /* | ||
635 | * The cpus in the mask must all be on the apic cluster. If are not | ||
636 | * on the same apicid cluster return default value of target_cpus(): | ||
637 | */ | ||
638 | cpu = first_cpu(*cpumask); | ||
639 | apicid = es7000_cpu_to_logical_apicid(cpu); | ||
640 | while (cpus_found < num_bits_set) { | ||
641 | if (cpu_isset(cpu, *cpumask)) { | ||
642 | int new_apicid = es7000_cpu_to_logical_apicid(cpu); | ||
643 | |||
644 | if (apicid_cluster(apicid) != | ||
645 | apicid_cluster(new_apicid)) { | ||
646 | printk ("%s: Not a valid mask!\n", __func__); | ||
647 | |||
648 | return es7000_cpu_to_logical_apicid(0); | ||
649 | } | ||
650 | apicid = new_apicid; | ||
651 | cpus_found++; | ||
652 | } | ||
653 | cpu++; | ||
654 | } | ||
655 | return apicid; | ||
656 | } | ||
657 | |||
658 | static unsigned int | ||
659 | es7000_cpu_mask_to_apicid_and(const struct cpumask *inmask, | ||
660 | const struct cpumask *andmask) | ||
661 | { | ||
662 | int apicid = es7000_cpu_to_logical_apicid(0); | ||
663 | cpumask_var_t cpumask; | ||
664 | |||
665 | if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC)) | ||
666 | return apicid; | ||
667 | |||
668 | cpumask_and(cpumask, inmask, andmask); | ||
669 | cpumask_and(cpumask, cpumask, cpu_online_mask); | ||
670 | apicid = es7000_cpu_mask_to_apicid(cpumask); | ||
671 | |||
672 | free_cpumask_var(cpumask); | ||
673 | |||
674 | return apicid; | ||
675 | } | ||
676 | |||
677 | static int es7000_phys_pkg_id(int cpuid_apic, int index_msb) | ||
678 | { | ||
679 | return cpuid_apic >> index_msb; | ||
680 | } | ||
681 | |||
682 | void __init es7000_update_genapic_to_cluster(void) | ||
683 | { | ||
684 | apic->target_cpus = target_cpus_cluster; | ||
685 | apic->irq_delivery_mode = INT_DELIVERY_MODE_CLUSTER; | ||
686 | apic->irq_dest_mode = INT_DEST_MODE_CLUSTER; | ||
687 | |||
688 | apic->init_apic_ldr = es7000_init_apic_ldr_cluster; | ||
689 | |||
690 | apic->cpu_mask_to_apicid = es7000_cpu_mask_to_apicid_cluster; | ||
691 | } | ||
692 | |||
693 | static int probe_es7000(void) | ||
694 | { | ||
695 | /* probed later in mptable/ACPI hooks */ | ||
696 | return 0; | ||
697 | } | ||
698 | |||
699 | static __init int | ||
700 | es7000_mps_oem_check(struct mpc_table *mpc, char *oem, char *productid) | ||
701 | { | ||
702 | if (mpc->oemptr) { | ||
703 | struct mpc_oemtable *oem_table = | ||
704 | (struct mpc_oemtable *)mpc->oemptr; | ||
705 | |||
706 | if (!strncmp(oem, "UNISYS", 6)) | ||
707 | return parse_unisys_oem((char *)oem_table); | ||
708 | } | ||
709 | return 0; | ||
710 | } | ||
711 | |||
712 | #ifdef CONFIG_ACPI | ||
713 | /* Hook from generic ACPI tables.c */ | ||
714 | static int __init es7000_acpi_madt_oem_check(char *oem_id, char *oem_table_id) | ||
715 | { | ||
716 | unsigned long oem_addr = 0; | ||
717 | int check_dsdt; | ||
718 | int ret = 0; | ||
719 | |||
720 | /* check dsdt at first to avoid clear fix_map for oem_addr */ | ||
721 | check_dsdt = es7000_check_dsdt(); | ||
722 | |||
723 | if (!find_unisys_acpi_oem_table(&oem_addr)) { | ||
724 | if (check_dsdt) | ||
725 | ret = parse_unisys_oem((char *)oem_addr); | ||
726 | else { | ||
727 | setup_unisys(); | ||
728 | ret = 1; | ||
729 | } | ||
730 | /* | ||
731 | * we need to unmap it | ||
732 | */ | ||
733 | unmap_unisys_acpi_oem_table(oem_addr); | ||
734 | } | ||
735 | return ret; | ||
736 | } | ||
737 | #else | ||
738 | static int __init es7000_acpi_madt_oem_check(char *oem_id, char *oem_table_id) | ||
739 | { | ||
740 | return 0; | ||
741 | } | ||
742 | #endif | ||
743 | |||
744 | |||
745 | struct genapic apic_es7000 = { | ||
746 | |||
747 | .name = "es7000", | ||
748 | .probe = probe_es7000, | ||
749 | .acpi_madt_oem_check = es7000_acpi_madt_oem_check, | ||
750 | .apic_id_registered = es7000_apic_id_registered, | ||
751 | |||
752 | .irq_delivery_mode = dest_Fixed, | ||
753 | /* phys delivery to target CPUs: */ | ||
754 | .irq_dest_mode = 0, | ||
755 | |||
756 | .target_cpus = es7000_target_cpus, | ||
757 | .disable_esr = 1, | ||
758 | .dest_logical = 0, | ||
759 | .check_apicid_used = es7000_check_apicid_used, | ||
760 | .check_apicid_present = es7000_check_apicid_present, | ||
761 | |||
762 | .vector_allocation_domain = es7000_vector_allocation_domain, | ||
763 | .init_apic_ldr = es7000_init_apic_ldr, | ||
764 | |||
765 | .ioapic_phys_id_map = es7000_ioapic_phys_id_map, | ||
766 | .setup_apic_routing = es7000_setup_apic_routing, | ||
767 | .multi_timer_check = NULL, | ||
768 | .apicid_to_node = es7000_apicid_to_node, | ||
769 | .cpu_to_logical_apicid = es7000_cpu_to_logical_apicid, | ||
770 | .cpu_present_to_apicid = es7000_cpu_present_to_apicid, | ||
771 | .apicid_to_cpu_present = es7000_apicid_to_cpu_present, | ||
772 | .setup_portio_remap = NULL, | ||
773 | .check_phys_apicid_present = es7000_check_phys_apicid_present, | ||
774 | .enable_apic_mode = es7000_enable_apic_mode, | ||
775 | .phys_pkg_id = es7000_phys_pkg_id, | ||
776 | .mps_oem_check = es7000_mps_oem_check, | ||
777 | |||
778 | .get_apic_id = es7000_get_apic_id, | ||
779 | .set_apic_id = NULL, | ||
780 | .apic_id_mask = 0xFF << 24, | ||
781 | |||
782 | .cpu_mask_to_apicid = es7000_cpu_mask_to_apicid, | ||
783 | .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and, | ||
784 | |||
785 | .send_IPI_mask = es7000_send_IPI_mask, | ||
786 | .send_IPI_mask_allbutself = NULL, | ||
787 | .send_IPI_allbutself = es7000_send_IPI_allbutself, | ||
788 | .send_IPI_all = es7000_send_IPI_all, | ||
789 | .send_IPI_self = NULL, | ||
790 | |||
791 | .wakeup_cpu = NULL, | ||
792 | |||
793 | .trampoline_phys_low = 0x467, | ||
794 | .trampoline_phys_high = 0x469, | ||
795 | |||
796 | .wait_for_init_deassert = es7000_wait_for_init_deassert, | ||
797 | |||
798 | /* Nothing to do for most platforms, since cleared by the INIT cycle: */ | ||
799 | .smp_callin_clear_local_apic = NULL, | ||
800 | .store_NMI_vector = NULL, | ||
801 | .inquire_remote_apic = default_inquire_remote_apic, | ||
802 | }; | ||
diff --git a/arch/x86/mach-generic/Makefile b/arch/x86/mach-generic/Makefile index 78ab5735cb80..05e47acfd666 100644 --- a/arch/x86/mach-generic/Makefile +++ b/arch/x86/mach-generic/Makefile | |||
@@ -7,4 +7,3 @@ EXTRA_CFLAGS := -Iarch/x86/kernel | |||
7 | obj-y := probe.o default.o | 7 | obj-y := probe.o default.o |
8 | obj-$(CONFIG_X86_NUMAQ) += numaq.o | 8 | obj-$(CONFIG_X86_NUMAQ) += numaq.o |
9 | obj-$(CONFIG_X86_BIGSMP) += bigsmp.o | 9 | obj-$(CONFIG_X86_BIGSMP) += bigsmp.o |
10 | obj-$(CONFIG_X86_ES7000) += es7000.o | ||
diff --git a/arch/x86/mach-generic/es7000.c b/arch/x86/mach-generic/es7000.c deleted file mode 100644 index bb11166b7c3c..000000000000 --- a/arch/x86/mach-generic/es7000.c +++ /dev/null | |||
@@ -1,427 +0,0 @@ | |||
1 | /* | ||
2 | * APIC driver for the Unisys ES7000 chipset. | ||
3 | */ | ||
4 | #define APIC_DEFINITION 1 | ||
5 | #include <linux/threads.h> | ||
6 | #include <linux/cpumask.h> | ||
7 | #include <asm/mpspec.h> | ||
8 | #include <asm/genapic.h> | ||
9 | #include <asm/fixmap.h> | ||
10 | #include <asm/apicdef.h> | ||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/string.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/acpi.h> | ||
15 | #include <linux/smp.h> | ||
16 | #include <asm/ipi.h> | ||
17 | |||
18 | #define APIC_DFR_VALUE_CLUSTER (APIC_DFR_CLUSTER) | ||
19 | #define INT_DELIVERY_MODE_CLUSTER (dest_LowestPrio) | ||
20 | #define INT_DEST_MODE_CLUSTER (1) /* logical delivery broadcast to all procs */ | ||
21 | |||
22 | #define APIC_DFR_VALUE (APIC_DFR_FLAT) | ||
23 | |||
24 | extern void es7000_enable_apic_mode(void); | ||
25 | extern int apic_version [MAX_APICS]; | ||
26 | extern u8 cpu_2_logical_apicid[]; | ||
27 | extern unsigned int boot_cpu_physical_apicid; | ||
28 | |||
29 | extern int parse_unisys_oem (char *oemptr); | ||
30 | extern int find_unisys_acpi_oem_table(unsigned long *oem_addr); | ||
31 | extern void unmap_unisys_acpi_oem_table(unsigned long oem_addr); | ||
32 | extern void setup_unisys(void); | ||
33 | |||
34 | #define apicid_cluster(apicid) (apicid & 0xF0) | ||
35 | #define xapic_phys_to_log_apicid(cpu) per_cpu(x86_bios_cpu_apicid, cpu) | ||
36 | |||
37 | static void es7000_vector_allocation_domain(int cpu, cpumask_t *retmask) | ||
38 | { | ||
39 | /* Careful. Some cpus do not strictly honor the set of cpus | ||
40 | * specified in the interrupt destination when using lowest | ||
41 | * priority interrupt delivery mode. | ||
42 | * | ||
43 | * In particular there was a hyperthreading cpu observed to | ||
44 | * deliver interrupts to the wrong hyperthread when only one | ||
45 | * hyperthread was specified in the interrupt desitination. | ||
46 | */ | ||
47 | *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } }; | ||
48 | } | ||
49 | |||
50 | |||
51 | static void es7000_wait_for_init_deassert(atomic_t *deassert) | ||
52 | { | ||
53 | #ifndef CONFIG_ES7000_CLUSTERED_APIC | ||
54 | while (!atomic_read(deassert)) | ||
55 | cpu_relax(); | ||
56 | #endif | ||
57 | return; | ||
58 | } | ||
59 | |||
60 | static unsigned int es7000_get_apic_id(unsigned long x) | ||
61 | { | ||
62 | return (x >> 24) & 0xFF; | ||
63 | } | ||
64 | |||
65 | #ifdef CONFIG_ACPI | ||
66 | static int es7000_check_dsdt(void) | ||
67 | { | ||
68 | struct acpi_table_header header; | ||
69 | |||
70 | if (ACPI_SUCCESS(acpi_get_table_header(ACPI_SIG_DSDT, 0, &header)) && | ||
71 | !strncmp(header.oem_id, "UNISYS", 6)) | ||
72 | return 1; | ||
73 | return 0; | ||
74 | } | ||
75 | #endif | ||
76 | |||
77 | static void es7000_send_IPI_mask(const struct cpumask *mask, int vector) | ||
78 | { | ||
79 | default_send_IPI_mask_sequence(mask, vector); | ||
80 | } | ||
81 | |||
82 | static void es7000_send_IPI_allbutself(int vector) | ||
83 | { | ||
84 | default_send_IPI_mask_allbutself(cpu_online_mask, vector); | ||
85 | } | ||
86 | |||
87 | static void es7000_send_IPI_all(int vector) | ||
88 | { | ||
89 | es7000_send_IPI_mask(cpu_online_mask, vector); | ||
90 | } | ||
91 | |||
92 | static int es7000_apic_id_registered(void) | ||
93 | { | ||
94 | return 1; | ||
95 | } | ||
96 | |||
97 | static const cpumask_t *target_cpus_cluster(void) | ||
98 | { | ||
99 | return &CPU_MASK_ALL; | ||
100 | } | ||
101 | |||
102 | static const cpumask_t *es7000_target_cpus(void) | ||
103 | { | ||
104 | return &cpumask_of_cpu(smp_processor_id()); | ||
105 | } | ||
106 | |||
107 | static unsigned long | ||
108 | es7000_check_apicid_used(physid_mask_t bitmap, int apicid) | ||
109 | { | ||
110 | return 0; | ||
111 | } | ||
112 | static unsigned long es7000_check_apicid_present(int bit) | ||
113 | { | ||
114 | return physid_isset(bit, phys_cpu_present_map); | ||
115 | } | ||
116 | |||
117 | static unsigned long calculate_ldr(int cpu) | ||
118 | { | ||
119 | unsigned long id = xapic_phys_to_log_apicid(cpu); | ||
120 | |||
121 | return (SET_APIC_LOGICAL_ID(id)); | ||
122 | } | ||
123 | |||
124 | /* | ||
125 | * Set up the logical destination ID. | ||
126 | * | ||
127 | * Intel recommends to set DFR, LdR and TPR before enabling | ||
128 | * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel | ||
129 | * document number 292116). So here it goes... | ||
130 | */ | ||
131 | static void es7000_init_apic_ldr_cluster(void) | ||
132 | { | ||
133 | unsigned long val; | ||
134 | int cpu = smp_processor_id(); | ||
135 | |||
136 | apic_write(APIC_DFR, APIC_DFR_VALUE_CLUSTER); | ||
137 | val = calculate_ldr(cpu); | ||
138 | apic_write(APIC_LDR, val); | ||
139 | } | ||
140 | |||
141 | static void es7000_init_apic_ldr(void) | ||
142 | { | ||
143 | unsigned long val; | ||
144 | int cpu = smp_processor_id(); | ||
145 | |||
146 | apic_write(APIC_DFR, APIC_DFR_VALUE); | ||
147 | val = calculate_ldr(cpu); | ||
148 | apic_write(APIC_LDR, val); | ||
149 | } | ||
150 | |||
151 | static void es7000_setup_apic_routing(void) | ||
152 | { | ||
153 | int apic = per_cpu(x86_bios_cpu_apicid, smp_processor_id()); | ||
154 | printk("Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n", | ||
155 | (apic_version[apic] == 0x14) ? | ||
156 | "Physical Cluster" : "Logical Cluster", | ||
157 | nr_ioapics, cpus_addr(*es7000_target_cpus())[0]); | ||
158 | } | ||
159 | |||
160 | static int es7000_apicid_to_node(int logical_apicid) | ||
161 | { | ||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | |||
166 | static int es7000_cpu_present_to_apicid(int mps_cpu) | ||
167 | { | ||
168 | if (!mps_cpu) | ||
169 | return boot_cpu_physical_apicid; | ||
170 | else if (mps_cpu < nr_cpu_ids) | ||
171 | return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu); | ||
172 | else | ||
173 | return BAD_APICID; | ||
174 | } | ||
175 | |||
176 | static physid_mask_t es7000_apicid_to_cpu_present(int phys_apicid) | ||
177 | { | ||
178 | static int id = 0; | ||
179 | physid_mask_t mask; | ||
180 | |||
181 | mask = physid_mask_of_physid(id); | ||
182 | ++id; | ||
183 | |||
184 | return mask; | ||
185 | } | ||
186 | |||
187 | /* Mapping from cpu number to logical apicid */ | ||
188 | static int es7000_cpu_to_logical_apicid(int cpu) | ||
189 | { | ||
190 | #ifdef CONFIG_SMP | ||
191 | if (cpu >= nr_cpu_ids) | ||
192 | return BAD_APICID; | ||
193 | return (int)cpu_2_logical_apicid[cpu]; | ||
194 | #else | ||
195 | return logical_smp_processor_id(); | ||
196 | #endif | ||
197 | } | ||
198 | |||
199 | static physid_mask_t es7000_ioapic_phys_id_map(physid_mask_t phys_map) | ||
200 | { | ||
201 | /* For clustered we don't have a good way to do this yet - hack */ | ||
202 | return physids_promote(0xff); | ||
203 | } | ||
204 | |||
205 | static int es7000_check_phys_apicid_present(int cpu_physical_apicid) | ||
206 | { | ||
207 | boot_cpu_physical_apicid = read_apic_id(); | ||
208 | return (1); | ||
209 | } | ||
210 | |||
211 | static unsigned int | ||
212 | es7000_cpu_mask_to_apicid_cluster(const struct cpumask *cpumask) | ||
213 | { | ||
214 | int cpus_found = 0; | ||
215 | int num_bits_set; | ||
216 | int apicid; | ||
217 | int cpu; | ||
218 | |||
219 | num_bits_set = cpumask_weight(cpumask); | ||
220 | /* Return id to all */ | ||
221 | if (num_bits_set == nr_cpu_ids) | ||
222 | return 0xFF; | ||
223 | /* | ||
224 | * The cpus in the mask must all be on the apic cluster. If are not | ||
225 | * on the same apicid cluster return default value of target_cpus(): | ||
226 | */ | ||
227 | cpu = cpumask_first(cpumask); | ||
228 | apicid = es7000_cpu_to_logical_apicid(cpu); | ||
229 | |||
230 | while (cpus_found < num_bits_set) { | ||
231 | if (cpumask_test_cpu(cpu, cpumask)) { | ||
232 | int new_apicid = es7000_cpu_to_logical_apicid(cpu); | ||
233 | |||
234 | if (apicid_cluster(apicid) != | ||
235 | apicid_cluster(new_apicid)) { | ||
236 | printk ("%s: Not a valid mask!\n", __func__); | ||
237 | |||
238 | return 0xFF; | ||
239 | } | ||
240 | apicid = new_apicid; | ||
241 | cpus_found++; | ||
242 | } | ||
243 | cpu++; | ||
244 | } | ||
245 | return apicid; | ||
246 | } | ||
247 | |||
248 | static unsigned int es7000_cpu_mask_to_apicid(const cpumask_t *cpumask) | ||
249 | { | ||
250 | int cpus_found = 0; | ||
251 | int num_bits_set; | ||
252 | int apicid; | ||
253 | int cpu; | ||
254 | |||
255 | num_bits_set = cpus_weight(*cpumask); | ||
256 | /* Return id to all */ | ||
257 | if (num_bits_set == nr_cpu_ids) | ||
258 | return es7000_cpu_to_logical_apicid(0); | ||
259 | /* | ||
260 | * The cpus in the mask must all be on the apic cluster. If are not | ||
261 | * on the same apicid cluster return default value of target_cpus(): | ||
262 | */ | ||
263 | cpu = first_cpu(*cpumask); | ||
264 | apicid = es7000_cpu_to_logical_apicid(cpu); | ||
265 | while (cpus_found < num_bits_set) { | ||
266 | if (cpu_isset(cpu, *cpumask)) { | ||
267 | int new_apicid = es7000_cpu_to_logical_apicid(cpu); | ||
268 | |||
269 | if (apicid_cluster(apicid) != | ||
270 | apicid_cluster(new_apicid)) { | ||
271 | printk ("%s: Not a valid mask!\n", __func__); | ||
272 | |||
273 | return es7000_cpu_to_logical_apicid(0); | ||
274 | } | ||
275 | apicid = new_apicid; | ||
276 | cpus_found++; | ||
277 | } | ||
278 | cpu++; | ||
279 | } | ||
280 | return apicid; | ||
281 | } | ||
282 | |||
283 | static unsigned int | ||
284 | es7000_cpu_mask_to_apicid_and(const struct cpumask *inmask, | ||
285 | const struct cpumask *andmask) | ||
286 | { | ||
287 | int apicid = es7000_cpu_to_logical_apicid(0); | ||
288 | cpumask_var_t cpumask; | ||
289 | |||
290 | if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC)) | ||
291 | return apicid; | ||
292 | |||
293 | cpumask_and(cpumask, inmask, andmask); | ||
294 | cpumask_and(cpumask, cpumask, cpu_online_mask); | ||
295 | apicid = es7000_cpu_mask_to_apicid(cpumask); | ||
296 | |||
297 | free_cpumask_var(cpumask); | ||
298 | |||
299 | return apicid; | ||
300 | } | ||
301 | |||
302 | static int es7000_phys_pkg_id(int cpuid_apic, int index_msb) | ||
303 | { | ||
304 | return cpuid_apic >> index_msb; | ||
305 | } | ||
306 | |||
307 | void __init es7000_update_genapic_to_cluster(void) | ||
308 | { | ||
309 | apic->target_cpus = target_cpus_cluster; | ||
310 | apic->irq_delivery_mode = INT_DELIVERY_MODE_CLUSTER; | ||
311 | apic->irq_dest_mode = INT_DEST_MODE_CLUSTER; | ||
312 | |||
313 | apic->init_apic_ldr = es7000_init_apic_ldr_cluster; | ||
314 | |||
315 | apic->cpu_mask_to_apicid = es7000_cpu_mask_to_apicid_cluster; | ||
316 | } | ||
317 | |||
318 | static int probe_es7000(void) | ||
319 | { | ||
320 | /* probed later in mptable/ACPI hooks */ | ||
321 | return 0; | ||
322 | } | ||
323 | |||
324 | static __init int | ||
325 | es7000_mps_oem_check(struct mpc_table *mpc, char *oem, char *productid) | ||
326 | { | ||
327 | if (mpc->oemptr) { | ||
328 | struct mpc_oemtable *oem_table = | ||
329 | (struct mpc_oemtable *)mpc->oemptr; | ||
330 | |||
331 | if (!strncmp(oem, "UNISYS", 6)) | ||
332 | return parse_unisys_oem((char *)oem_table); | ||
333 | } | ||
334 | return 0; | ||
335 | } | ||
336 | |||
337 | #ifdef CONFIG_ACPI | ||
338 | /* Hook from generic ACPI tables.c */ | ||
339 | static int __init es7000_acpi_madt_oem_check(char *oem_id, char *oem_table_id) | ||
340 | { | ||
341 | unsigned long oem_addr = 0; | ||
342 | int check_dsdt; | ||
343 | int ret = 0; | ||
344 | |||
345 | /* check dsdt at first to avoid clear fix_map for oem_addr */ | ||
346 | check_dsdt = es7000_check_dsdt(); | ||
347 | |||
348 | if (!find_unisys_acpi_oem_table(&oem_addr)) { | ||
349 | if (check_dsdt) | ||
350 | ret = parse_unisys_oem((char *)oem_addr); | ||
351 | else { | ||
352 | setup_unisys(); | ||
353 | ret = 1; | ||
354 | } | ||
355 | /* | ||
356 | * we need to unmap it | ||
357 | */ | ||
358 | unmap_unisys_acpi_oem_table(oem_addr); | ||
359 | } | ||
360 | return ret; | ||
361 | } | ||
362 | #else | ||
363 | static int __init es7000_acpi_madt_oem_check(char *oem_id, char *oem_table_id) | ||
364 | { | ||
365 | return 0; | ||
366 | } | ||
367 | #endif | ||
368 | |||
369 | |||
370 | struct genapic apic_es7000 = { | ||
371 | |||
372 | .name = "es7000", | ||
373 | .probe = probe_es7000, | ||
374 | .acpi_madt_oem_check = es7000_acpi_madt_oem_check, | ||
375 | .apic_id_registered = es7000_apic_id_registered, | ||
376 | |||
377 | .irq_delivery_mode = dest_Fixed, | ||
378 | /* phys delivery to target CPUs: */ | ||
379 | .irq_dest_mode = 0, | ||
380 | |||
381 | .target_cpus = es7000_target_cpus, | ||
382 | .disable_esr = 1, | ||
383 | .dest_logical = 0, | ||
384 | .check_apicid_used = es7000_check_apicid_used, | ||
385 | .check_apicid_present = es7000_check_apicid_present, | ||
386 | |||
387 | .vector_allocation_domain = es7000_vector_allocation_domain, | ||
388 | .init_apic_ldr = es7000_init_apic_ldr, | ||
389 | |||
390 | .ioapic_phys_id_map = es7000_ioapic_phys_id_map, | ||
391 | .setup_apic_routing = es7000_setup_apic_routing, | ||
392 | .multi_timer_check = NULL, | ||
393 | .apicid_to_node = es7000_apicid_to_node, | ||
394 | .cpu_to_logical_apicid = es7000_cpu_to_logical_apicid, | ||
395 | .cpu_present_to_apicid = es7000_cpu_present_to_apicid, | ||
396 | .apicid_to_cpu_present = es7000_apicid_to_cpu_present, | ||
397 | .setup_portio_remap = NULL, | ||
398 | .check_phys_apicid_present = es7000_check_phys_apicid_present, | ||
399 | .enable_apic_mode = es7000_enable_apic_mode, | ||
400 | .phys_pkg_id = es7000_phys_pkg_id, | ||
401 | .mps_oem_check = es7000_mps_oem_check, | ||
402 | |||
403 | .get_apic_id = es7000_get_apic_id, | ||
404 | .set_apic_id = NULL, | ||
405 | .apic_id_mask = 0xFF << 24, | ||
406 | |||
407 | .cpu_mask_to_apicid = es7000_cpu_mask_to_apicid, | ||
408 | .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and, | ||
409 | |||
410 | .send_IPI_mask = es7000_send_IPI_mask, | ||
411 | .send_IPI_mask_allbutself = NULL, | ||
412 | .send_IPI_allbutself = es7000_send_IPI_allbutself, | ||
413 | .send_IPI_all = es7000_send_IPI_all, | ||
414 | .send_IPI_self = NULL, | ||
415 | |||
416 | .wakeup_cpu = NULL, | ||
417 | |||
418 | .trampoline_phys_low = 0x467, | ||
419 | .trampoline_phys_high = 0x469, | ||
420 | |||
421 | .wait_for_init_deassert = es7000_wait_for_init_deassert, | ||
422 | |||
423 | /* Nothing to do for most platforms, since cleared by the INIT cycle: */ | ||
424 | .smp_callin_clear_local_apic = NULL, | ||
425 | .store_NMI_vector = NULL, | ||
426 | .inquire_remote_apic = default_inquire_remote_apic, | ||
427 | }; | ||