cmd: date: Change to use CONFIG_DM_RTC instead of CONFIG_DM_I2C
PATCH v2 2/15 cmd: date: Change to use CONFIG_DM_RTC instead of CONFIG_DM_I2C
In reply to a message not in the archiveCurrently CONFIG_DM_I2C is used in cmd_date.c for driver model, but it should be actually CONFIG_DM_RTC.
---
Changes in v2:
- New patch to change to use CONFIG_DM_RTC instead of CONFIG_DM_I2C
common/cmd_date.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
common/cmd_date.c +6 -6
@@ -37,7 +37,7 @@ static int do_date(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])int old_bus__maybe_unused ;/* switch to correct I2C bus */ -#ifdef CONFIG_DM_I2C +#ifdef CONFIG_DM_RTC struct udevice *dev; rcode =uclass_get_device (UCLASS_RTC ,0 , &dev);
@@ -57,7 +57,7 @@ static int do_date(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])case 2 :/* set date & time */ if (strcmp (argv[1 ],"reset" ) ==0 ) {puts ("Reset RTC...\n" ); -#ifdef CONFIG_DM_I2C +#ifdef CONFIG_DM_RTC rcode =dm_rtc_reset (dev);if (!rcode) rcode =dm_rtc_set (dev, &default_tm);
@@ -69,7 +69,7 @@ static int do_date(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])puts ("## Failed to set date after RTC reset\n" ); }else {/* initialize tm with current time */ -#ifdef CONFIG_DM_I2C +#ifdef CONFIG_DM_RTC rcode =dm_rtc_get (dev, &tm);#else rcode =rtc_get (&tm);
@@ -81,7 +81,7 @@ static int do_date(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])break ; }/* and write to RTC */ -#ifdef CONFIG_DM_I2C +#ifdef CONFIG_DM_RTC rcode =dm_rtc_set (dev, &tm);#else rcode =rtc_set (&tm);
@@ -96,7 +96,7 @@ static int do_date(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) }/* FALL TROUGH */ case 1 :/* get date & time */ -#ifdef CONFIG_DM_I2C +#ifdef CONFIG_DM_RTC rcode =dm_rtc_get (dev, &tm);#else rcode =rtc_get (&tm);
@@ -120,7 +120,7 @@ static int do_date(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])/* switch back to original I2C bus */ #ifdef CONFIG_SYS_I2C i2c_set_bus_num (old_bus); -#elif !defined(CONFIG_DM_I2C ) +#elif !defined(CONFIG_DM_RTC )I2C_SET_BUS (old_bus);#endif
Signature · 1 line
1.8.2.1
PATCH v2 3/15 x86: crownbay: Enable DM RTC support
In reply to a message not in the archiveAdd a RTC node in the device tree to enable DM RTC support.
---
Changes in v2:
- New patch to enable DM RTC support for Crown Bay
arch/x86/dts/crownbay.dts | 1 + arch/x86/dts/rtc.dtsi | 6 ++++++ configs/crownbay_defconfig | 1 + 3 files changed, 8 insertions(+) create mode 100644 arch/x86/dts/rtc.dtsi
arch/x86/dts/crownbay.dts +1 -0
@@ -10,6 +10,7 @@ /include/ "skeleton.dtsi" /include/ "serial.dtsi" +/include/ "rtc.dtsi" / { model = "Intel Crown Bay";
arch/x86/dts/rtc.dtsi new file +6 -0
@@ -0,0 +1,6 @@ +/ { + rtc { + compatible = "motorola,mc146818"; + reg = <0x70 2>; + }; +};
configs/crownbay_defconfig +1 -0
@@ -9,3 +9,4 @@ CONFIG_CMD_CPU=y CONFIG_CMD_NET=y CONFIG_OF_CONTROL=y CONFIG_CPU=y +CONFIG_DM_RTC=y
Signature · 1 line
1.8.2.1
PATCH v2 4/15 x86: queensbay: Correct Topcliff device irqs
In reply to a message not in the archiveThere are 4 usb ports on the Intel Crown Bay board, 2 of which are connected to Topcliff usb host 0 and the other 2 connected to usb host 1. USB devices inserted in the ports connected to usb host 1 cannot get detected due to wrong IRQ assigned to the controller. Actually we need apply the PCI interrupt pin swizzling logic to all devices on the Topcliff chipset when configuring the PIRQ routing.
This was observed on usb ports, but device 6 and 10 irqs are also wrong. Correct them all together.
---
Changes in v2: None
arch/x86/dts/crownbay.dts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
arch/x86/dts/crownbay.dts +12 -12
@@ -180,29 +180,29 @@ * Note on the Crown Bay board, Topcliff chipset * is connected to TunnelCreek PCIe port 0, so * its bus number is 1 for its PCIe port and 2 - * for its PCI devices per U-Boot currnet PCI + * for its PCI devices per U-Boot current PCI * bus enumeration algorithm. */ PCI_BDF(1, 0, 0) INTA PIRQA PCI_BDF(2, 0, 1) INTA PIRQA PCI_BDF(2, 0, 2) INTA PIRQA - PCI_BDF(2, 2, 0) INTB PIRQB - PCI_BDF(2, 2, 1) INTB PIRQB - PCI_BDF(2, 2, 2) INTB PIRQB - PCI_BDF(2, 2, 3) INTB PIRQB - PCI_BDF(2, 2, 4) INTB PIRQB + PCI_BDF(2, 2, 0) INTB PIRQD + PCI_BDF(2, 2, 1) INTB PIRQD + PCI_BDF(2, 2, 2) INTB PIRQD + PCI_BDF(2, 2, 3) INTB PIRQD + PCI_BDF(2, 2, 4) INTB PIRQD PCI_BDF(2, 4, 0) INTC PIRQC PCI_BDF(2, 4, 1) INTC PIRQC - PCI_BDF(2, 6, 0) INTD PIRQD + PCI_BDF(2, 6, 0) INTD PIRQB PCI_BDF(2, 8, 0) INTA PIRQA PCI_BDF(2, 8, 1) INTA PIRQA PCI_BDF(2, 8, 2) INTA PIRQA PCI_BDF(2, 8, 3) INTA PIRQA - PCI_BDF(2, 10, 0) INTB PIRQB - PCI_BDF(2, 10, 1) INTB PIRQB - PCI_BDF(2, 10, 2) INTB PIRQB - PCI_BDF(2, 10, 3) INTB PIRQB - PCI_BDF(2, 10, 4) INTB PIRQB + PCI_BDF(2, 10, 0) INTB PIRQD + PCI_BDF(2, 10, 1) INTB PIRQD + PCI_BDF(2, 10, 2) INTB PIRQD + PCI_BDF(2, 10, 3) INTB PIRQD + PCI_BDF(2, 10, 4) INTB PIRQD PCI_BDF(2, 12, 0) INTC PIRQC PCI_BDF(2, 12, 1) INTC PIRQC PCI_BDF(2, 12, 2) INTC PIRQC
Signature · 1 line
1.8.2.1
PATCH v2 5/15 x86: Write correct bus number for the irq router
In reply to a message not in the archiveWe should write correct bus number to the PIRQ routing table for the irq router from device tree, instead of hard-coded zero.
---
Changes in v2: None
arch/x86/cpu/irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/cpu/irq.c +1 -1
@@ -161,7 +161,7 @@ static int create_pirq_routing_table(void)/* Populate the PIRQ table fields */ rt->signature =PIRQ_SIGNATURE ; rt->version =PIRQ_VERSION ; - rt->rtr_bus =0 ; + rt->rtr_bus =PCI_BUS (irq_router.bdf); rt->rtr_devfn = (PCI_DEV (irq_router.bdf) <<3 ) |PCI_FUNC (irq_router.bdf); rt->rtr_vendor =PCI_VENDOR_ID_INTEL ;
Signature · 1 line
1.8.2.1
PATCH v2 6/15 x86: Ignore function number when writing PIRQ routing table
In reply to a message not in the archiveIn fill_irq_info() pci device's function number is written into the table, however this is not really necessary. The function number can be anything as OS doesn't care about this field, neither does the PIRQ routing specification. Change to always writing 0 as the function number.
---
Changes in v2: None
arch/x86/cpu/irq.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
arch/x86/cpu/irq.c +3 -4
@@ -59,12 +59,12 @@ void pirq_assign_irq(int link, u8 irq) }static inline void fill_irq_info (struct irq_info **slotp,int *entries,u8 bus, -u8 device,u8 func,u8 pin,u8 pirq) +u8 device,u8 pin,u8 pirq) {struct irq_info *slot = *slotp; slot->bus = bus; - slot->devfn = (device <<3 ) | func; + slot->devfn = (device <<3 ) |0 ; slot->irq[pin -1 ].link =LINK_N2V (pirq, irq_router.link_base); slot->irq[pin -1 ].bitmap = irq_router.irq_mask; (*entries)++;
@@ -182,8 +182,7 @@ static int create_pirq_routing_table(void)PCI_FUNC (pr.bdf),'A' + pr.pin -1 , 'A' + pr.pirq);fill_irq_info (&slot, &irq_entries,PCI_BUS (pr.bdf), -PCI_DEV (pr.bdf),PCI_FUNC (pr.bdf), - pr.pin, pr.pirq); +PCI_DEV (pr.bdf), pr.pin, pr.pirq); cell +=sizeof (struct pirq_routing ) /sizeof (u32); }
Signature · 1 line
1.8.2.1
PATCH v2 7/15 x86: Reduce PIRQ routing table size
In reply to a message not in the archiveThere is no need to populate multiple irq info entries with the same bus number and device number, but with different interrupt pin. We can use the same entry to store all the 4 interrupt pin (INT A/B/C/D) routing information to reduce the whole PIRQ routing table size.
---
Changes in v2:
- Avoid using u16 and u8 in parameters
arch/x86/cpu/irq.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 9 deletions(-)
arch/x86/cpu/irq.c +56 -9
@@ -58,17 +58,28 @@ void pirq_assign_irq(int link, u8 irq)writeb (irq, irq_router.ibase +LINK_N2V (link, base)); } -static inline void fill_irq_info (struct irq_info **slotp,int *entries,u8 bus, -u8 device,u8 pin,u8 pirq) +static struct irq_info *check_dup_entry (struct irq_info *slot_base, +int entry_num,int bus,int device) { -struct irq_info *slot = *slotp; +struct irq_info *slot = slot_base; +int i; + +for (i =0 ; i < entry_num; i++) { +if (slot->bus == bus && slot->devfn == (device <<3 )) +break ; + slot++; + } +return (i == entry_num) ?NULL : slot; +} + +static inline void fill_irq_info (struct irq_info *slot,int bus,int device, +int pin,int pirq) +{ slot->bus = bus; slot->devfn = (device <<3 ) |0 ; slot->irq[pin -1 ].link =LINK_N2V (pirq, irq_router.link_base); slot->irq[pin -1 ].bitmap = irq_router.irq_mask; - (*entries)++; - (*slotp)++; }__weak void cpu_irq_init (void )
@@ -84,7 +95,7 @@ static int create_pirq_routing_table(void)int len, count;const u32 *cell;struct irq_routing_table *rt; -struct irq_info *slot; +struct irq_info *slot, *slot_base;int irq_entries =0 ;int i;int ret;
@@ -167,7 +178,7 @@ static int create_pirq_routing_table(void) rt->rtr_vendor =PCI_VENDOR_ID_INTEL ; rt->rtr_device =PCI_DEVICE_ID_INTEL_ICH7_31 ; - slot = rt->slots; + slot_base = rt->slots;/* Now fill in the irq_info entries in the PIRQ table */ for (i =0 ; i < count; i++) {
@@ -181,8 +192,44 @@ static int create_pirq_routing_table(void) i,PCI_BUS (pr.bdf),PCI_DEV (pr.bdf),PCI_FUNC (pr.bdf),'A' + pr.pin -1 , 'A' + pr.pirq); -fill_irq_info (&slot, &irq_entries,PCI_BUS (pr.bdf), -PCI_DEV (pr.bdf), pr.pin, pr.pirq); + + slot =check_dup_entry (slot_base, irq_entries, +PCI_BUS (pr.bdf),PCI_DEV (pr.bdf)); +if (slot) { +debug ("found entry for bus %d device %d, " , +PCI_BUS (pr.bdf),PCI_DEV (pr.bdf)); + +if (slot->irq[pr.pin -1 ].link) { +debug ("skipping\n" ); + +/* +* Sanity test on the routed PIRQ pin +* +* If they don't match, show a warning to tell +* there might be something wrong with the PIRQ +* routing information in the device tree. +*/ +if (slot->irq[pr.pin -1 ].link != +LINK_N2V (pr.pirq, irq_router.link_base)) +debug ("WARNING: Inconsistent PIRQ routing information\n" ); + + cell +=sizeof (struct pirq_routing ) / +sizeof (u32); +continue ; + }else { +debug ("writing INT%c\n" ,'A' + pr.pin -1 ); +fill_irq_info (slot,PCI_BUS (pr.bdf), +PCI_DEV (pr.bdf), pr.pin, pr.pirq); + cell +=sizeof (struct pirq_routing ) / +sizeof (u32); +continue ; + } + } + + slot = slot_base + irq_entries; +fill_irq_info (slot,PCI_BUS (pr.bdf),PCI_DEV (pr.bdf), + pr.pin, pr.pirq); + irq_entries++; cell +=sizeof (struct pirq_routing ) /sizeof (u32); }
Signature · 1 line
1.8.2.1
PATCH v2 8/15 x86: Clean up ioapic header file
In reply to a message not in the archiveRemove all the dead/unused macros from asm/ioapic.h.
---
Changes in v2: None
arch/x86/include/asm/ioapic.h | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-)
arch/x86/include/asm/ioapic.h +3 -23
@@ -10,29 +10,9 @@#define __ASM_IOAPIC_H#define IO_APIC_ADDR 0xfec00000 -#define IO_APIC_INDEX IO_APIC_ADDR -#define IO_APIC_DATA (IO_APIC_ADDR + 0x10) -#define IO_APIC_INTERRUPTS 24 - -#define ALL (0xff << 24) -#define NONE 0 -#define DISABLED (1 << 16) -#define ENABLED (0 << 16) -#define TRIGGER_EDGE (0 << 15) -#define TRIGGER_LEVEL (1 << 15) -#define POLARITY_HIGH (0 << 13) -#define POLARITY_LOW (1 << 13) -#define PHYSICAL_DEST (0 << 11) -#define LOGICAL_DEST (1 << 11) -#define ExtINT (7 << 8) -#define NMI (4 << 8) -#define SMI (2 << 8) -#define INT (1 << 8) -u32 io_apic_read (u32 ioapic_base,u32 reg); -void io_apic_write (u32 ioapic_base,u32 reg,u32 value); -void set_ioapic_id (u32 ioapic_base,u8 ioapic_id); -void setup_ioapic (u32 ioapic_base,u8 ioapic_id); -void clear_ioapic (u32 ioapic_base); +/* Direct addressed register */ +#define IO_APIC_INDEX (IO_APIC_ADDR + 0x00) +#define IO_APIC_DATA (IO_APIC_ADDR + 0x10)#endif
Signature · 1 line
1.8.2.1
PATCH v2 9/15 x86: Add I/O APIC register access routines
In reply to a message not in the archiveI/O APIC registers are addressed indirectly. Add io_apic_read() and io_apic_write() routines to help register access. Two macros for I/O APIC ID and version register offset are also added.
---
Changes in v2:
- Do not use inline for register access
arch/x86/cpu/Makefile | 2 +- arch/x86/cpu/ioapic.c | 21 +++++++++++++++++++++ arch/x86/include/asm/ioapic.h | 24 ++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 arch/x86/cpu/ioapic.c
arch/x86/cpu/Makefile +1 -1
@@ -19,7 +19,7 @@ obj-$(CONFIG_NORTHBRIDGE_INTEL_SANDYBRIDGE) += ivybridge/ obj-$(CONFIG_NORTHBRIDGE_INTEL_IVYBRIDGE) += ivybridge/ obj-$(CONFIG_INTEL_QUARK) += quark/ obj-$(CONFIG_INTEL_QUEENSBAY) += queensbay/ -obj-y += irq.o lapic.o +obj-y += irq.o lapic.o ioapic.o obj-$(CONFIG_SMP) += mp_init.o obj-y += mtrr.o obj-$(CONFIG_PCI) += pci.o
arch/x86/cpu/ioapic.c new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Copyright (C) 2015, Bin Meng <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <asm/io.h> +#include <asm/ioapic.h> + +u32 io_apic_read (u32 reg) +{ +writel (reg,IO_APIC_INDEX ); +return readl (IO_APIC_DATA ); +} + +void io_apic_write (u32 reg,u32 val) +{ +writel (reg,IO_APIC_INDEX ); +writel (val,IO_APIC_DATA ); +}
arch/x86/include/asm/ioapic.h +24 -0
@@ -15,4 +15,28 @@#define IO_APIC_INDEX (IO_APIC_ADDR + 0x00)#define IO_APIC_DATA (IO_APIC_ADDR + 0x10) +/* Indirect addressed register offset */ +#define IO_APIC_ID 0x00 +#define IO_APIC_VER 0x01 + +/** +* io_apic_read() - Read I/O APIC register +* +* This routine reads I/O APIC indirect addressed register. +* +* @reg: address of indirect addressed register +* @return: register value to read +*/ +u32 io_apic_read (u32 reg); + +/** +* io_apic_write() - Write I/O APIC register +* +* This routine writes I/O APIC indirect addressed register. +* +* @reg: address of indirect addressed register +* @val: register value to write +*/ +void io_apic_write (u32 reg,u32 val); +#endif
Signature · 1 line
1.8.2.1
PATCH v2 10/15 x86: Remove inline for lapic access routines
In reply to a message not in the archiveRemove inline for lapic access routines and expose lapic_read() & lapic_write() as APIs to read/write lapic registers. Also move stop_this_cpu() to mp_init.c as it has nothing to do with lapic.
---
Changes in v2:
- New patch to remove inline for lapic access routines
arch/x86/cpu/lapic.c | 143 +++++++++++++++++++++++++++++++++++++------ arch/x86/cpu/mp_init.c | 27 +++++--- arch/x86/include/asm/lapic.h | 134 +++------------------------------------- 3 files changed, 153 insertions(+), 151 deletions(-)
arch/x86/cpu/lapic.c +125 -18
@@ -8,9 +8,116 @@*/ #include <common.h> +#include <asm/io.h> #include <asm/lapic.h> +#include <asm/msr.h> +#include <asm/msr-index.h> #include <asm/post.h> +unsigned long lapic_read (unsigned long reg) +{ +return readl (LAPIC_DEFAULT_BASE + reg); +} + +#define xchg (ptr, v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v), (ptr), \ + sizeof(*(ptr)))) + +struct __xchg_dummy {unsigned long a[100 ]; }; +#define __xg (x) ((struct __xchg_dummy *)(x)) + +/* +* Note: no "lock" prefix even on SMP. xchg always implies lock anyway. +* +* Note 2: xchg has side effect, so that attribute volatile is necessary, +* but generally the primitive is invalid, *ptr is output argument. +*/ +static inline unsigned long __xchg (unsigned long x,volatile void *ptr, +int size) +{ +switch (size) { +case 1 : + __asm__ __volatile__("xchgb %b0,%1" + :"=q" (x) + :"m" (*__xg (ptr)),"0" (x) + :"memory" ); +break ; +case 2 : + __asm__ __volatile__("xchgw %w0,%1" + :"=r" (x) + :"m" (*__xg (ptr)),"0" (x) + :"memory" ); +break ; +case 4 : + __asm__ __volatile__("xchgl %0,%1" + :"=r" (x) + :"m" (*__xg (ptr)),"0" (x) + :"memory" ); +break ; + } + +return x; +} + +void lapic_write (unsigned long reg,unsigned long v) +{ + (void )xchg ((volatile unsigned long *)(LAPIC_DEFAULT_BASE + reg), v); +} + +void enable_lapic (void ) +{ +msr_t msr; + + msr =msr_read (MSR_IA32_APICBASE ); + msr.hi &=0xffffff00 ; + msr.lo |=MSR_IA32_APICBASE_ENABLE ; + msr.lo &= ~MSR_IA32_APICBASE_BASE ; + msr.lo |=LAPIC_DEFAULT_BASE ; +msr_write (MSR_IA32_APICBASE , msr); +} + +void disable_lapic (void ) +{ +msr_t msr; + + msr =msr_read (MSR_IA32_APICBASE ); + msr.lo &= ~MSR_IA32_APICBASE_ENABLE ; +msr_write (MSR_IA32_APICBASE , msr); +} + +unsigned long lapicid (void ) +{ +return lapic_read (LAPIC_ID ) >>24 ; +} + +static void lapic_wait_icr_idle (void ) +{ +do { }while (lapic_read (LAPIC_ICR ) &LAPIC_ICR_BUSY ); +} + +int lapic_remote_read (int apicid,int reg,unsigned long *pvalue) +{ +int timeout; +unsigned long status; +int result; + +lapic_wait_icr_idle (); +lapic_write (LAPIC_ICR2 ,SET_LAPIC_DEST_FIELD (apicid)); +lapic_write (LAPIC_ICR ,LAPIC_DM_REMRD | (reg >>4 )); + + timeout =0 ; +do { + status =lapic_read (LAPIC_ICR ) &LAPIC_ICR_RR_MASK ; + }while (status ==LAPIC_ICR_RR_INPROG && timeout++ <1000 ); + + result =-1 ; +if (status ==LAPIC_ICR_RR_VALID ) { + *pvalue =lapic_read (LAPIC_RRR ); + result =0 ; + } + +return result; +} +void lapic_setup (void ) {#ifdef CONFIG_SMP
@@ -21,26 +128,26 @@ void lapic_setup(void)enable_lapic ();/* Set Task Priority to 'accept all' */ -lapic_write_around (LAPIC_TASKPRI , -lapic_read_around (LAPIC_TASKPRI ) & ~LAPIC_TPRI_MASK ); +lapic_write (LAPIC_TASKPRI , +lapic_read (LAPIC_TASKPRI ) & ~LAPIC_TPRI_MASK );/* Put the local apic in virtual wire mode */ -lapic_write_around (LAPIC_SPIV , (lapic_read_around (LAPIC_SPIV ) & - ~(LAPIC_VECTOR_MASK )) |LAPIC_SPIV_ENABLE ); -lapic_write_around (LAPIC_LVT0 , (lapic_read_around (LAPIC_LVT0 ) & - ~(LAPIC_LVT_MASKED |LAPIC_LVT_LEVEL_TRIGGER | -LAPIC_LVT_REMOTE_IRR |LAPIC_INPUT_POLARITY | -LAPIC_SEND_PENDING |LAPIC_LVT_RESERVED_1 | -LAPIC_DELIVERY_MODE_MASK )) | - (LAPIC_LVT_REMOTE_IRR |LAPIC_SEND_PENDING | -LAPIC_DELIVERY_MODE_EXTINT )); -lapic_write_around (LAPIC_LVT1 , (lapic_read_around (LAPIC_LVT1 ) & - ~(LAPIC_LVT_MASKED |LAPIC_LVT_LEVEL_TRIGGER | -LAPIC_LVT_REMOTE_IRR |LAPIC_INPUT_POLARITY | -LAPIC_SEND_PENDING |LAPIC_LVT_RESERVED_1 | -LAPIC_DELIVERY_MODE_MASK )) | - (LAPIC_LVT_REMOTE_IRR |LAPIC_SEND_PENDING | -LAPIC_DELIVERY_MODE_NMI )); +lapic_write (LAPIC_SPIV , (lapic_read (LAPIC_SPIV ) & + ~(LAPIC_VECTOR_MASK )) |LAPIC_SPIV_ENABLE ); +lapic_write (LAPIC_LVT0 , (lapic_read (LAPIC_LVT0 ) & + ~(LAPIC_LVT_MASKED |LAPIC_LVT_LEVEL_TRIGGER | +LAPIC_LVT_REMOTE_IRR |LAPIC_INPUT_POLARITY | +LAPIC_SEND_PENDING |LAPIC_LVT_RESERVED_1 | +LAPIC_DELIVERY_MODE_MASK )) | + (LAPIC_LVT_REMOTE_IRR |LAPIC_SEND_PENDING | +LAPIC_DELIVERY_MODE_EXTINT )); +lapic_write (LAPIC_LVT1 , (lapic_read (LAPIC_LVT1 ) & + ~(LAPIC_LVT_MASKED |LAPIC_LVT_LEVEL_TRIGGER | +LAPIC_LVT_REMOTE_IRR |LAPIC_INPUT_POLARITY | +LAPIC_SEND_PENDING |LAPIC_LVT_RESERVED_1 | +LAPIC_DELIVERY_MODE_MASK )) | + (LAPIC_LVT_REMOTE_IRR |LAPIC_SEND_PENDING | +LAPIC_DELIVERY_MODE_NMI ));debug ("apic_id: 0x%02lx, " ,lapicid ());#else /* !CONFIG_SMP */
arch/x86/cpu/mp_init.c +18 -9
@@ -16,7 +16,9 @@#include <asm/interrupt.h> #include <asm/lapic.h> #include <asm/mp.h> +#include <asm/msr.h> #include <asm/mtrr.h> +#include <asm/processor.h> #include <asm/sipi.h> #include <dm/device-internal.h> #include <dm/uclass-internal.h>
@@ -59,6 +61,13 @@ static inline void release_barrier(atomic_t *b)atomic_set (b,1 ); } +static inline void stop_this_cpu (void ) +{ +/* Called by an AP when it is ready to halt and wait for a new task */ +for (;;) +cpu_hlt (); +} +/* Returns 1 if timeout waiting for APs. 0 if target APs found */ static int wait_for_aps (atomic_t *val,int target,int total_delay,int delay_step)
@@ -317,9 +326,9 @@ static int start_aps(int ap_count, atomic_t *num_aps) }/* Send INIT IPI to all but self */ -lapic_write_around (LAPIC_ICR2 ,SET_LAPIC_DEST_FIELD (0 )); -lapic_write_around (LAPIC_ICR ,LAPIC_DEST_ALLBUT |LAPIC_INT_ASSERT | -LAPIC_DM_INIT ); +lapic_write (LAPIC_ICR2 ,SET_LAPIC_DEST_FIELD (0 )); +lapic_write (LAPIC_ICR ,LAPIC_DEST_ALLBUT |LAPIC_INT_ASSERT | +LAPIC_DM_INIT );debug ("Waiting for 10ms after sending INIT.\n" );mdelay (10 );
@@ -334,9 +343,9 @@ static int start_aps(int ap_count, atomic_t *num_aps) } } -lapic_write_around (LAPIC_ICR2 ,SET_LAPIC_DEST_FIELD (0 )); -lapic_write_around (LAPIC_ICR ,LAPIC_DEST_ALLBUT |LAPIC_INT_ASSERT | -LAPIC_DM_STARTUP | sipi_vector); +lapic_write (LAPIC_ICR2 ,SET_LAPIC_DEST_FIELD (0 )); +lapic_write (LAPIC_ICR ,LAPIC_DEST_ALLBUT |LAPIC_INT_ASSERT | +LAPIC_DM_STARTUP | sipi_vector);debug ("Waiting for 1st SIPI to complete..." );if (apic_wait_timeout (10000 ,50 )) {debug ("timed out.\n" );
@@ -359,9 +368,9 @@ static int start_aps(int ap_count, atomic_t *num_aps) } } -lapic_write_around (LAPIC_ICR2 ,SET_LAPIC_DEST_FIELD (0 )); -lapic_write_around (LAPIC_ICR ,LAPIC_DEST_ALLBUT |LAPIC_INT_ASSERT | -LAPIC_DM_STARTUP | sipi_vector); +lapic_write (LAPIC_ICR2 ,SET_LAPIC_DEST_FIELD (0 )); +lapic_write (LAPIC_ICR ,LAPIC_DEST_ALLBUT |LAPIC_INT_ASSERT | +LAPIC_DM_STARTUP | sipi_vector);debug ("Waiting for 2nd SIPI to complete..." );if (apic_wait_timeout (10000 ,50 )) {debug ("timed out.\n" );
arch/x86/include/asm/lapic.h +10 -124
147 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH v2 11/15 x86: Add MultiProcessor (MP) table APIs
In reply to a message not in the archiveThe MP table provides a way for the operating system to support for symmetric multiprocessing as well as symmetric I/O interrupt handling with the local APIC and I/O APIC. We provide a bunch of APIs for U-Boot to write the floating table, configuration table header as well as base and extended table entries.
---
Changes in v2:
- Avoid using u16 and u8 in parameters
- Create a helper routine of strncpy that pads with spaces
arch/x86/include/asm/mpspec.h | 434 ++++++++++++++++++++++++++++++++++++++++++ arch/x86/include/asm/tables.h | 14 ++ arch/x86/lib/Makefile | 1 + arch/x86/lib/mpspec.c | 225 ++++++++++++++++++++++ arch/x86/lib/tables.c | 14 ++ 5 files changed, 688 insertions(+) create mode 100644 arch/x86/include/asm/mpspec.h create mode 100644 arch/x86/lib/mpspec.c
arch/x86/include/asm/mpspec.h new file +434 -0
@@ -0,0 +1,434 @@ +/* +* Copyright (C) 2015, Bin Meng <[email protected]> +* +* Adapted from coreboot src/arch/x86/include/arch/smp/mpspec.h +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __ASM_MPSPEC_H +#define __ASM_MPSPEC_H + +/* +* Structure definitions for SMP machines following the +* Intel MultiProcessor Specification 1.4 +*/ + +#define MPSPEC_V14 4 + +#define MPF_SIGNATURE "_MP_" + +struct mp_floating_table { +char mpf_signature[4 ];/* "_MP_" */ +u32 mpf_physptr;/* Configuration table address */ +u8 mpf_length;/* Our length (paragraphs) */ +u8 mpf_spec;/* Specification version */ +u8 mpf_checksum;/* Checksum (makes sum 0) */ +u8 mpf_feature1;/* Predefined or Unique configuration? */ +u8 mpf_feature2;/* Bit7 set for IMCR/PIC */ +u8 mpf_feature3;/* Unused (0) */ +u8 mpf_feature4;/* Unused (0) */ +u8 mpf_feature5;/* Unused (0) */ +}; + +#define MPC_SIGNATURE "PCMP" + +struct mp_config_table { +char mpc_signature[4 ];/* "PCMP" */ +u16 mpc_length;/* Size of table */ +u8 mpc_spec;/* Specification version */ +u8 mpc_checksum;/* Checksum (makes sum 0) */ +char mpc_oem[8 ];/* OEM ID */ +char mpc_product[12 ];/* Product ID */ +u32 mpc_oemptr;/* OEM table address */ +u16 mpc_oemsize;/* OEM table size */ +u16 mpc_entry_count;/* Number of entries in the table */ +u32 mpc_lapic;/* Local APIC address */ +u16 mpe_length;/* Extended table size */ +u8 mpe_checksum;/* Extended table checksum */ +u8 reserved; +}; + +/* Base MP configuration table entry types */ + +enum mp_base_config_entry_type { +MP_PROCESSOR , +MP_BUS , +MP_IOAPIC , +MP_INTSRC , +MP_LINTSRC +}; + +#define MPC_CPU_EN (1 << 0) +#define MPC_CPU_BP (1 << 1) + +struct mpc_config_processor { +u8 mpc_type; +u8 mpc_apicid; +u8 mpc_apicver; +u8 mpc_cpuflag; +u32 mpc_cpusignature; +u32 mpc_cpufeature; +u32 mpc_reserved[2 ]; +}; + +#define BUSTYPE_CBUS "CBUS " +#define BUSTYPE_CBUSII "CBUSII" +#define BUSTYPE_EISA "EISA " +#define BUSTYPE_FUTURE "FUTURE" +#define BUSTYPE_INTERN "INTERN" +#define BUSTYPE_ISA "ISA " +#define BUSTYPE_MBI "MBI " +#define BUSTYPE_MBII "MBII " +#define BUSTYPE_MCA "MCA " +#define BUSTYPE_MPI "MPI " +#define BUSTYPE_MPSA "MPSA " +#define BUSTYPE_NUBUS "NUBUS " +#define BUSTYPE_PCI "PCI " +#define BUSTYPE_PCMCIA "PCMCIA" +#define BUSTYPE_TC "TC " +#define BUSTYPE_VL "VL " +#define BUSTYPE_VME "VME " +#define BUSTYPE_XPRESS "XPRESS" + +struct mpc_config_bus { +u8 mpc_type; +u8 mpc_busid; +u8 mpc_bustype[6 ]; +}; + +#define MPC_APIC_USABLE (1 << 0) + +struct mpc_config_ioapic { +u8 mpc_type; +u8 mpc_apicid; +u8 mpc_apicver; +u8 mpc_flags; +u32 mpc_apicaddr; +}; + +enum mp_irq_source_types { +MP_INT , +MP_NMI , +MP_SMI , +MP_EXTINT +}; + +#define MP_IRQ_POLARITY_DEFAULT 0x0 +#define MP_IRQ_POLARITY_HIGH 0x1 +#define MP_IRQ_POLARITY_LOW 0x3 +#define MP_IRQ_POLARITY_MASK 0x3 +#define MP_IRQ_TRIGGER_DEFAULT 0x0 +#define MP_IRQ_TRIGGER_EDGE 0x4 +#define MP_IRQ_TRIGGER_LEVEL 0xc +#define MP_IRQ_TRIGGER_MASK 0xc + +#define MP_APIC_ALL 0xff + +struct mpc_config_intsrc { +u8 mpc_type; +u8 mpc_irqtype; +u16 mpc_irqflag; +u8 mpc_srcbus; +u8 mpc_srcbusirq; +u8 mpc_dstapic; +u8 mpc_dstirq; +}; + +struct mpc_config_lintsrc { +u8 mpc_type; +u8 mpc_irqtype; +u16 mpc_irqflag; +u8 mpc_srcbusid; +u8 mpc_srcbusirq; +u8 mpc_destapic; +u8 mpc_destlint; +}; + +/* Extended MP configuration table entry types */ + +enum mp_ext_config_entry_type { +MPE_SYSTEM_ADDRESS_SPACE =128 , +MPE_BUS_HIERARCHY , +MPE_COMPAT_ADDRESS_SPACE +}; + +struct mp_ext_config { +u8 mpe_type; +u8 mpe_length; +}; + +#define ADDRESS_TYPE_IO 0 +#define ADDRESS_TYPE_MEM 1 +#define ADDRESS_TYPE_PREFETCH 2 + +struct mp_ext_system_address_space { +u8 mpe_type; +u8 mpe_length; +u8 mpe_busid; +u8 mpe_addr_type; +u32 mpe_addr_base_low; +u32 mpe_addr_base_high; +u32 mpe_addr_length_low; +u32 mpe_addr_length_high; +}; + +#define BUS_SUBTRACTIVE_DECODE (1 << 0) + +struct mp_ext_bus_hierarchy { +u8 mpe_type; +u8 mpe_length; +u8 mpe_busid; +u8 mpe_bus_info; +u8 mpe_parent_busid; +u8 reserved[3 ]; +}; + +#define ADDRESS_RANGE_ADD 0 +#define ADDRESS_RANGE_SUBTRACT 1 + +/* +* X100 - X3FF +* X500 - X7FF +* X900 - XBFF +* XD00 - XFFF +*/ +#define RANGE_LIST_IO_ISA 0 +/* +* X3B0 - X3BB +* X3C0 - X3DF +* X7B0 - X7BB +* X7C0 - X7DF +* XBB0 - XBBB +* XBC0 - XBDF +* XFB0 - XFBB +* XFC0 - XCDF +*/ +#define RANGE_LIST_IO_VGA 1 + +struct mp_ext_compat_address_space { +u8 mpe_type; +u8 mpe_length; +u8 mpe_busid; +u8 mpe_addr_modifier; +u32 mpe_range_list; +}; + +/** +* mp_next_mpc_entry() - Compute MP configuration table end to be used as +* next base table entry start address +* +* This computes the end address of current MP configuration table, without +* counting any extended configuration table entry. +* +* @mc: configuration table header address +* @return: configuration table end address +*/ +static inline u32 mp_next_mpc_entry (struct mp_config_table *mc) +{ +return (u32 )mc + mc->mpc_length; +} + +/** +* mp_add_mpc_entry() - Add a base MP configuration table entry +* +* This adds the base MP configuration table entry size with +* added base table entry length and increases entry count by 1. +* +* @mc: configuration table header address +* @length: length of the added table entry +*/ +static inline void mp_add_mpc_entry (struct mp_config_table *mc,uint length) +{ + mc->mpc_length += length; + mc->mpc_entry_count++; +} + +/** +* mp_next_mpe_entry() - Compute MP configuration table end to be used as +* next extended table entry start address +* +* This computes the end address of current MP configuration table, +* including any extended configuration table entry. +* +* @mc: configuration table header address +* @return: configuration table end address +*/ +static inline u32 mp_next_mpe_entry (struct mp_config_table *mc) +{ +return (u32 )mc + mc->mpc_length + mc->mpe_length; +} + +/** +* mp_add_mpe_entry() - Add an extended MP configuration table entry +* +* This adds the extended MP configuration table entry size with +* added extended table entry length. +* +* @mc: configuration table header address +* @mpe: extended table entry base address +*/ +static inline void mp_add_mpe_entry (struct mp_config_table *mc, +struct mp_ext_config *mpe) +{ + mc->mpe_length += mpe->mpe_length; +} + +/** +* mp_write_floating_table() - Write the MP floating table +* +* This writes the MP floating table, and points MP configuration table +* to its end address so that MP configuration table follows immediately +* after the floating table. +* +* @mf: MP floating table base address +* @return: MP configuration table header address +*/ +struct mp_config_table *mp_write_floating_table (struct mp_floating_table *mf); + +/** +* mp_config_table_init() - Initialize the MP configuration table header +* +* This populates the MP configuration table header with valid bits. +* +* @mc: MP configuration table header address +*/ +void mp_config_table_init (struct mp_config_table *mc); + +/** +* mp_write_processor() - Write a processor entry +* +* This writes a processor entry to the configuration table. +* +* @mc: MP configuration table header address +*/ +void mp_write_processor (struct mp_config_table *mc); + +/** +* mp_write_bus() - Write a bus entry +* +* This writes a bus entry to the configuration table. +* +* @mc: MP configuration table header address +* @id: bus id +* @bustype: bus type name +*/ +void mp_write_bus (struct mp_config_table *mc,int id,const char *bustype); + +/** +* mp_write_ioapic() - Write an I/O APIC entry +* +* This writes an I/O APIC entry to the configuration table. +* +* @mc: MP configuration table header address +* @id: I/O APIC id +* @ver: I/O APIC version +* @apicaddr: I/O APIC address +*/ +void mp_write_ioapic (struct mp_config_table *mc,int id,int ver,u32 apicaddr); + +/** +* mp_write_intsrc() - Write an I/O interrupt assignment entry +* +* This writes an I/O interrupt assignment entry to the configuration table. +* +* @mc: MP configuration table header address +* @irqtype: IRQ type (INT/NMI/SMI/ExtINT) +* @irqflag: IRQ flag (level/trigger) +* @srcbus: source bus id where the interrupt comes from +* @srcbusirq: IRQ number mapped on the source bus +* @dstapic: destination I/O APIC id where the interrupt goes to +* @dstirq: destination I/O APIC pin where the interrupt goes to +*/ +void mp_write_intsrc (struct mp_config_table *mc,int irqtype,int irqflag, +int srcbus,int srcbusirq,int dstapic,int dstirq); + +/** +* mp_write_pci_intsrc() - Write a PCI interrupt assignment entry +* +* This writes a PCI interrupt assignment entry to the configuration table. +* +* @mc: MP configuration table header address +* @irqtype: IRQ type (INT/NMI/SMI/ExtINT) +* @srcbus: PCI bus number where the interrupt comes from +* @dev: device number on the PCI bus +* @pin: PCI interrupt pin (INT A/B/C/D) +* @dstapic: destination I/O APIC id where the interrupt goes to +* @dstirq: destination I/O APIC pin where the interrupt goes to +*/ +void mp_write_pci_intsrc (struct mp_config_table *mc,int irqtype, +int srcbus,int dev,int pin,int dstapic,int dstirq); + +/** +* mp_write_lintsrc() - Write a local interrupt assignment entry +* +* This writes a local interrupt assignment entry to the configuration table. +* +* @mc: MP configuration table header address +* @irqtype: IRQ type (INT/NMI/SMI/ExtINT) +* @irqflag: IRQ flag (level/trigger) +* @srcbus: PCI bus number where the interrupt comes from +* @srcbusirq: IRQ number mapped on the source bus +* @dstapic: destination local APIC id where the interrupt goes to +* @destlint: destination local APIC pin where the interrupt goes to +*/ +void mp_write_lintsrc (struct mp_config_table *mc,int irqtype,int irqflag, +int srcbus,int srcbusirq,int destapic,int destlint); + + +/** +* mp_write_address_space() - Write a system address space entry +* +* This writes a system address space entry to the configuration table. +* +* @mc: MP configuration table header address +* @busid: bus id for the bus where system address space is mapped +* @addr_type: system address type +* @addr_base_low: starting address low +* @addr_base_high: starting address high +* @addr_length_low: address length low +* @addr_length_high: address length high +*/ +void mp_write_address_space (struct mp_config_table *mc, +int busid,int addr_type, +u32 addr_base_low,u32 addr_base_high, +u32 addr_length_low,u32 addr_length_high); + +/** +* mp_write_bus_hierarchy() - Write a bus hierarchy descriptor entry +* +* This writes a bus hierarchy descriptor entry to the configuration table. +* +* @mc: MP configuration table header address +* @busid: bus id +* @bus_info: bit0 indicates if the bus is a subtractive decode bus +* @parent_busid: parent bus id +*/ +void mp_write_bus_hierarchy (struct mp_config_table *mc, +int busid,int bus_info,int parent_busid); + +/** +* mp_write_compat_address_space() - Write a compat bus address space entry +* +* This writes a compatibility bus address space modifier entry to the +* configuration table. +* +* @mc: MP configuration table header address +* @busid: bus id +* @addr_modifier: add or subtract to predefined address range list +* @range_list: list of predefined address space ranges +*/ +void mp_write_compat_address_space (struct mp_config_table *mc,int busid, +int addr_modifier,u32 range_list); + +/** +* mptable_finalize() - Finalize the MP table +* +* This finalizes the MP table by calculating required checksums. +* +* @mc: MP configuration table header address +* @return: MP table end address +*/ +u32 mptable_finalize (struct mp_config_table *mc); + +#endif /* __ASM_MPSPEC_H */
arch/x86/include/asm/tables.h +14 -0
@@ -28,6 +28,20 @@u8 table_compute_checksum (void *v,int len);/** +* table_fill_string() - Fill a string with pad in the configuration table +* +* This fills a string in the configuration table. It copies number of bytes +* from the source string, and if source string length is shorter than the +* required size to copy, pad the table string with the given pad character. +* +* @dest: where to fill a string +* @src: where to copy from +* @n: number of bytes to copy +* @pad: character to pad the remaining bytes +*/ +void table_fill_string (char *dest,const char *src,size_t n,char pad); + +/** * write_tables() - Write x86 configuration tables * * This writes x86 configuration tables, including PIRQ routing table,
arch/x86/lib/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-y += gcc.o obj-y += init_helpers.o obj-y += interrupts.o obj-y += lpc-uclass.o +obj-y += mpspec.o obj-y += cmd_mtrr.o obj-$(CONFIG_SYS_PCAT_INTERRUPTS) += pcat_interrupts.o obj-$(CONFIG_SYS_PCAT_TIMER) += pcat_timer.o
arch/x86/lib/mpspec.c new file +225 -0
225 lines not on this page · raw message
arch/x86/lib/tables.c +14 -0
@@ -20,6 +20,20 @@ u8 table_compute_checksum(void *v, int len)return checksum; } +void table_fill_string (char *dest,const char *src,size_t n,char pad) +{ +int start, len; +int i; + +strncpy (dest, src, n); + +/* Fill the remaining bytes with pad */ + len =strlen (src); + start = len < n ? len : n; +for (i = start; i < n; i++) + dest[i] = pad; +} +void write_tables (void ) {u32 __maybe_unused rom_table_end =ROM_TABLE_ADDR ;
Signature · 1 line
1.8.2.1
PATCH v2 12/15 x86: Generate a valid MultiProcessor (MP) table
In reply to a message not in the archiveImplement write_mp_table() to create a minimal working MP table. This includes an MP floating table, a configuration table header and all of the 5 base configuration table entries. The I/O interrupt assignment table entry is created based on the same information used in the creation of PIRQ routing table from device tree. A check duplicated entry logic is applied to prevent writing multiple I/O interrupt entries with the same information.
Use a Kconfig option GENERATE_MP_TABLE to tell U-Boot whether we need actually write the MP table at the F seg, just like we did for PIRQ routing and SFI tables. With MP table existence, linux kernel will switch to I/O APIC and local APIC to process all the peripheral interrupts instead of 8259 PICs. This takes full advantage of the multicore hardware and the SMP kernel.
---
Changes in v2:
- Avoid using u16 and u8 in parameters
- Add a comment block for check_dup_entry()
- Return and check error codes of mptable_add_intsrc()
- Remove __weak for write_mp_table()
arch/x86/Kconfig | 9 +++ arch/x86/include/asm/mpspec.h | 10 +++ arch/x86/lib/mpspec.c | 157 ++++++++++++++++++++++++++++++++++++++++++ arch/x86/lib/tables.c | 5 ++ 4 files changed, 181 insertions(+)
arch/x86/Kconfig +9 -0
@@ -319,6 +319,15 @@ config GENERATE_SFI_TABLE For more information, see http://simplefirmware.org +config GENERATE_MP_TABLE + bool "Generate an MP (Multi-Processor) table" + default n + help + Generate an MP (Multi-Processor) table for this board. The MP table + provides a way for the operating system to support for symmetric + multiprocessing as well as symmetric I/O interrupt handling with + the local APIC and I/O APIC. + endmenu config MAX_PIRQ_LINKS
arch/x86/include/asm/mpspec.h +10 -0
@@ -431,4 +431,14 @@ void mp_write_compat_address_space(struct mp_config_table *mc, int busid,*/ u32 mptable_finalize (struct mp_config_table *mc); +/** +* write_mp_table() - Write MP table +* +* This writes MP table at a given address. +* +* @addr: start address to write MP table +* @return: end address of MP table +*/ +u32 write_mp_table (u32 addr); +#endif /* __ASM_MPSPEC_H */
arch/x86/lib/mpspec.c +157 -0
173 lines not on this page · raw message
arch/x86/lib/tables.c +5 -0
@@ -6,6 +6,7 @@#include <common.h> #include <asm/sfi.h> +#include <asm/mpspec.h> #include <asm/tables.h> u8 table_compute_checksum (void *v,int len)
@@ -46,4 +47,8 @@ void write_tables(void) rom_table_end =write_sfi_table (rom_table_end); rom_table_end =ALIGN (rom_table_end,1024 );#endif +#ifdef CONFIG_GENERATE_MP_TABLE + rom_table_end =write_mp_table (rom_table_end); + rom_table_end =ALIGN (rom_table_end,1024 ); +#endif }
Signature · 1 line
1.8.2.1
PATCH v2 13/15 x86: Update README.x86 for SMP support
In reply to a message not in the archiveDocument U-Boot multi-processor support as well as configuration tables like SFI and MP tables for SMP OS kernel.
---
Changes in v2:
- New patch to update README.x86 for SMP support
doc/README.x86 | 13 +++++++++++++ 1 file changed, 13 insertions(+)
doc/README.x86 +13 -0
@@ -258,6 +258,17 @@ Modern CPUs usually require a special bit stream called microcode [6] to be loaded on the processor after power up in order to function properly. U-Boot has already integrated these as hex dumps in the source tree. +SMP Support +----------- +On a multicore system, U-Boot is executed on the bootstrap processor (BSP). +Additional application processors (AP) can be brought up by U-Boot. In order to +have an SMP kernel to discover all of the available processors, U-Boot needs to +prepare configuration tables which contain the multi-CPUs information before +loading the OS kernel. Currently U-Boot supports generating two types of tables +for SMP, called Simple Firmware Interface (SFI) [7] and Multi-Processor (MP) [8] +tables. The writing of these two tables are controlled by two Kconfig options +GENERATE_SFI_TABLE and GENERATE_MP_TABLE. + Driver Model ------------ x86 has been converted to use driver model for serial and GPIO.
@@ -362,3 +373,5 @@ References [4] http://www.intel.com/content/www/us/en/embedded/design-tools/evaluation-platforms/atom-e660-eg20t-development-kit.html [5] http://www.intel.com/fsp [6] http://en.wikipedia.org/wiki/Microcode +[7] http://simplefirmware.org +[8] http://www.intel.com/design/archives/processors/pro/docs/242016.htm
Signature · 1 line
1.8.2.1
PATCH v2 14/15 x86: crownbay: Enable writing MP table
In reply to a message not in the archiveEnable writing MP table for Intel Crown Bay board.
---
Changes in v2: None
configs/crownbay_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/crownbay_defconfig +1 -0
@@ -5,6 +5,7 @@ CONFIG_TARGET_CROWNBAY=y CONFIG_SMP=y CONFIG_MAX_CPUS=2 CONFIG_GENERATE_PIRQ_TABLE=y +CONFIG_GENERATE_MP_TABLE=y CONFIG_CMD_CPU=y CONFIG_CMD_NET=y CONFIG_OF_CONTROL=y
Signature · 1 line
1.8.2.1
PATCH v2 15/15 x86: queensbay: Change PCIe root ports' interrupt routing
In reply to a message not in the archiveSo far interrupt routing works pretty well for any on-chip devices on Intel Crown Bay. When inserting any PCIe card to any PCIe slot, Linux kernel is smart enough to do interrupt swizzling and figure out device's irq using its parent bridge's interrupt routing info all the way up to its root port. In U-Boot all PCIe root ports' interrupts were routed to PIRQ E/F/G/H before, while actually all PCIe downstream ports received INTx are routed to PIRQ A/B/C/D directly and not configurable. Now we change this mapping so that any external PCIe device can work correctly.
---
Changes in v2:
- New patch to change PCIe root ports' interrupt routing for queensbay
arch/x86/cpu/queensbay/tnc.c | 13 +++++++------ arch/x86/dts/crownbay.dts | 20 ++++++++++++++++---- 2 files changed, 23 insertions(+), 10 deletions(-)
arch/x86/cpu/queensbay/tnc.c +7 -6
@@ -69,17 +69,18 @@ void cpu_irq_init(void)* Route TunnelCreek PCI device interrupt pin to PIRQ * * Since PCIe downstream ports received INTx are routed to PIRQ -* A/B/C/D directly and not configurable, we route internal PCI -* device's INTx to PIRQ E/F/G/H. +* A/B/C/D directly and not configurable, we have to route PCIe +* root ports' INTx to PIRQ A/B/C/D as well. For other devices +* on TunneCreek, route them to PIRQ E/F/G/H. */ writew (PIRQE , &rcba->d02ir);writew (PIRQF , &rcba->d03ir);writew (PIRQG , &rcba->d27ir);writew (PIRQH , &rcba->d31ir); -writew (PIRQE , &rcba->d23ir); -writew (PIRQF , &rcba->d24ir); -writew (PIRQG , &rcba->d25ir); -writew (PIRQH , &rcba->d26ir); +writew (PIRQA , &rcba->d23ir); +writew (PIRQB , &rcba->d24ir); +writew (PIRQC , &rcba->d25ir); +writew (PIRQD , &rcba->d26ir); }int arch_misc_init (void )
arch/x86/dts/crownbay.dts +16 -4
@@ -169,10 +169,22 @@ /* TunnelCreek PCI devices */ PCI_BDF(0, 2, 0) INTA PIRQE PCI_BDF(0, 3, 0) INTA PIRQF - PCI_BDF(0, 23, 0) INTA PIRQE - PCI_BDF(0, 24, 0) INTA PIRQF - PCI_BDF(0, 25, 0) INTA PIRQG - PCI_BDF(0, 26, 0) INTA PIRQH + PCI_BDF(0, 23, 0) INTA PIRQA + PCI_BDF(0, 23, 0) INTB PIRQB + PCI_BDF(0, 23, 0) INTC PIRQC + PCI_BDF(0, 23, 0) INTD PIRQD + PCI_BDF(0, 24, 0) INTA PIRQB + PCI_BDF(0, 24, 0) INTB PIRQC + PCI_BDF(0, 24, 0) INTC PIRQD + PCI_BDF(0, 24, 0) INTD PIRQA + PCI_BDF(0, 25, 0) INTA PIRQC + PCI_BDF(0, 25, 0) INTB PIRQD + PCI_BDF(0, 25, 0) INTC PIRQA + PCI_BDF(0, 25, 0) INTD PIRQB + PCI_BDF(0, 26, 0) INTA PIRQD + PCI_BDF(0, 26, 0) INTB PIRQA + PCI_BDF(0, 26, 0) INTC PIRQB + PCI_BDF(0, 26, 0) INTD PIRQC PCI_BDF(0, 27, 0) INTA PIRQG /* * Topcliff PCI devices
Signature · 1 line
1.8.2.1
PATCH v2 12/15 x86: Generate a valid MultiProcessor (MP) table
In reply to Bin MengQuoted 25 lines · Bin Meng
Implement
write_mp_table()to create a minimal working MP table. This includes an MP floating table, a configuration table header and all of the 5 base configuration table entries. The I/O interrupt assignment table entry is created based on the same information used in the creation of PIRQ routing table from device tree. A check duplicated entry logic is applied to prevent writing multiple I/O interrupt entries with the same information.Use a
KconfigoptionGENERATE_MP_TABLEto tell U-Boot whether we need actually write the MP table at the F seg, just like we did for PIRQ routing and SFI tables. With MP table existence, linux kernel will switch to I/O APIC and local APIC to process all the peripheral interrupts instead of 8259 PICs. This takes full advantage of the multicore hardware and the SMP kernel.Signed-off-by Bin Meng <[email protected]>---
Changes in v2:
- Avoid using u16 and u8 in parameters
- Add a comment block forcheck_dup_entry()
- Return and check error codes ofmptable_add_intsrc()
- Remove__weakforwrite_mp_table()
[snip]
Quoted 21 lines
arch/x86/lib/mpspec.c +21
-0+u32 write_mp_table (u32 addr) +{ +struct mp_config_table *mc; +int ioapic_id, ioapic_ver; +int bus_isa =0xff ; +int ret; +u32 end; + +/* 16 byte align the table address */ + addr =ALIGN (addr,16 ); + +/* Write floating table */ + mc =mp_write_floating_table ((struct mp_floating_table *)addr); + +/* Write configuration table header */ +mp_config_table_init (mc); + +/* Write processor entry */ +mp_write_processor (mc); + +/* Write bus entry */
arch/x86/lib/mpspec.c u32 mptable_finalize(struct mp_config_table *mc) · line 372
Quoted 10 lines
arch/x86/lib/mpspec.c +10
-0+mp_write_bus (mc, bus_isa,BUSTYPE_ISA ); + +/* Write I/O APIC entry */ + ioapic_id =io_apic_read (IO_APIC_ID ) >>24 ; + ioapic_ver =io_apic_read (IO_APIC_VER ) &0xff ; +mp_write_ioapic (mc, ioapic_id, ioapic_ver,IO_APIC_ADDR ); + +/* Write I/O interrupt assignment entry */ + ret =mptable_add_intsrc (mc, bus_isa, ioapic_id); +if (!ret)
Sorry, the logic is wrong here. Should be if (ret)
arch/x86/lib/mpspec.c u32 mptable_finalize(struct mp_config_table *mc) · line 382
Quoted 10 lines
arch/x86/lib/mpspec.c +10
-0+debug ("Failed to write I/O interrupt assignment table\n" ); + +/* Write local interrupt assignment entry */ +mptable_add_lintsrc (mc, bus_isa); + +/* Finalize the MP table */ + end =mptable_finalize (mc); + +return end; +}
[snip]
Regards,
Bin
PATCH v2 12/15 x86: Generate a valid MultiProcessor (MP) table
Hi Simon,
Quoted 54 lines · Bin Meng
Quoted 25 lines · Bin Meng
Implement
write_mp_table()to create a minimal working MP table. This includes an MP floating table, a configuration table header and all of the 5 base configuration table entries. The I/O interrupt assignment table entry is created based on the same information used in the creation of PIRQ routing table from device tree. A check duplicated entry logic is applied to prevent writing multiple I/O interrupt entries with the same information.Use a
KconfigoptionGENERATE_MP_TABLEto tell U-Boot whether we need actually write the MP table at the F seg, just like we did for PIRQ routing and SFI tables. With MP table existence, linux kernel will switch to I/O APIC and local APIC to process all the peripheral interrupts instead of 8259 PICs. This takes full advantage of the multicore hardware and the SMP kernel.Signed-off-by Bin Meng <[email protected]>---
Changes in v2:
- Avoid using u16 and u8 in parameters
- Add a comment block forcheck_dup_entry()
- Return and check error codes ofmptable_add_intsrc()
- Remove__weakforwrite_mp_table()[snip]
Quoted 25 lines
arch/x86/lib/mpspec.c +25
-0+u32 write_mp_table (u32 addr) +{ +struct mp_config_table *mc; +int ioapic_id, ioapic_ver; +int bus_isa =0xff ; +int ret; +u32 end; + +/* 16 byte align the table address */ + addr =ALIGN (addr,16 ); + +/* Write floating table */ + mc =mp_write_floating_table ((struct mp_floating_table *)addr); + +/* Write configuration table header */ +mp_config_table_init (mc); + +/* Write processor entry */ +mp_write_processor (mc); + +/* Write bus entry */ +mp_write_bus (mc, bus_isa,BUSTYPE_ISA ); + +/* Write I/O APIC entry */ + ioapic_id =io_apic_read (IO_APIC_ID ) >>24 ;
Quoted 9 lines
arch/x86/lib/mpspec.c u32 mptable_finalize(struct mp_config_table *mc) · line 372
Quoted 6 lines
arch/x86/lib/mpspec.c +6
-0+ ioapic_ver =io_apic_read (IO_APIC_VER ) &0xff ; +mp_write_ioapic (mc, ioapic_id, ioapic_ver,IO_APIC_ADDR ); + +/* Write I/O interrupt assignment entry */ + ret =mptable_add_intsrc (mc, bus_isa, ioapic_id); +if (!ret)Sorry, the logic is wrong here. Should be if (ret)
I sent a respin patch series which just fixed the "if (!ret)" logic. Please have a look.
http://patchwork.ozlabs.org/patch/487491/
[snip]
Regards,
Bin