diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2009-06-07 13:46:50 +0000 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2009-06-07 13:46:50 +0000 |
commit | 0ffff3434e610cf38c8eb06a3f1b1dece92652fa (patch) | |
tree | cbe26bd96d6f5aaa536987741879ccc4b49cc6d2 /src/mainboard/via/epia-m700 | |
parent | cff071ab0ed60c887ceeaafa2e722b07691fff10 (diff) | |
download | coreboot-0ffff3434e610cf38c8eb06a3f1b1dece92652fa.tar.xz |
First bunch of coding style and consistency cleanups for the
EPIA-M700 target.
Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4349 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src/mainboard/via/epia-m700')
-rw-r--r-- | src/mainboard/via/epia-m700/Config.lb | 99 | ||||
-rw-r--r-- | src/mainboard/via/epia-m700/DrivingClkPhaseData.c | 401 | ||||
-rw-r--r-- | src/mainboard/via/epia-m700/Options.lb | 59 | ||||
-rw-r--r-- | src/mainboard/via/epia-m700/acpi_tables.c | 117 | ||||
-rw-r--r-- | src/mainboard/via/epia-m700/cache_as_ram_auto.c | 1092 | ||||
-rw-r--r-- | src/mainboard/via/epia-m700/dsdt.c | 5 | ||||
-rw-r--r-- | src/mainboard/via/epia-m700/fadt.c | 65 | ||||
-rw-r--r-- | src/mainboard/via/epia-m700/get_dsdt | 18 | ||||
-rw-r--r-- | src/mainboard/via/epia-m700/irq_tables.c | 50 | ||||
-rw-r--r-- | src/mainboard/via/epia-m700/ssdt.c | 5 | ||||
-rw-r--r-- | src/mainboard/via/epia-m700/wakeup.c | 433 | ||||
-rw-r--r-- | src/mainboard/via/epia-m700/wakeup.h | 18 |
12 files changed, 1211 insertions, 1151 deletions
diff --git a/src/mainboard/via/epia-m700/Config.lb b/src/mainboard/via/epia-m700/Config.lb index 2c5b80bb3b..70f669ef62 100644 --- a/src/mainboard/via/epia-m700/Config.lb +++ b/src/mainboard/via/epia-m700/Config.lb @@ -28,19 +28,19 @@ driver wakeup.o if HAVE_PIRQ_TABLE object irq_tables.o end if HAVE_MP_TABLE object mptable.o end if HAVE_ACPI_TABLES - object fadt.o - object dsdt.o -# object ssdt.o - object acpi_tables.o + object fadt.o + object dsdt.o + # object ssdt.o + object acpi_tables.o end -# these lines maybe noused +# These lines maybe noused. makerule ./failover.E - depends "$(MAINBOARD)/../../../arch/i386/lib/failover.c ./romcc" - action "./romcc -E -O --label-prefix=failover -I$(TOP)/src -I. $(CPPFLAGS) $(MAINBOARD)/../../../arch/i386/lib/failover.c -o $@" + depends "$(MAINBOARD)/../../../arch/i386/lib/failover.c ./romcc" + action "./romcc -E -O --label-prefix=failover -I$(TOP)/src -I. $(CPPFLAGS) $(MAINBOARD)/../../../arch/i386/lib/failover.c -o $@" end makerule ./failover.inc - depends "$(MAINBOARD)/../../../arch/i386/lib/failover.c ./romcc" - action "./romcc -O --label-prefix=failover -I$(TOP)/src -I. $(CPPFLAGS) $(MAINBOARD)/../../../arch/i386/lib/failover.c -o $@" + depends "$(MAINBOARD)/../../../arch/i386/lib/failover.c ./romcc" + action "./romcc -O --label-prefix=failover -I$(TOP)/src -I. $(CPPFLAGS) $(MAINBOARD)/../../../arch/i386/lib/failover.c -o $@" end if USE_DCACHE_RAM if CONFIG_USE_INIT @@ -60,22 +60,23 @@ end mainboardinit cpu/via/16bit/entry16.inc ldscript /cpu/via/16bit/entry16.lds -mainboardinit northbridge/via/vx800/romstrap.inc +mainboardinit northbridge/via/vx800/romstrap.inc ldscript /northbridge/via/vx800/romstrap.lds mainboardinit cpu/x86/32bit/entry32.inc ldscript /cpu/x86/32bit/entry32.lds if USE_FALLBACK_IMAGE - mainboardinit cpu/x86/16bit/reset16.inc - ldscript /cpu/x86/16bit/reset16.lds + mainboardinit cpu/x86/16bit/reset16.inc + ldscript /cpu/x86/16bit/reset16.lds else - mainboardinit cpu/x86/32bit/reset32.inc - ldscript /cpu/x86/32bit/reset32.lds + mainboardinit cpu/x86/32bit/reset32.inc + ldscript /cpu/x86/32bit/reset32.lds end -#mainboardinit arch/i386/lib/cpu_reset.inc -#here cpu_reset.inc have label _cpu_reset, which is needed in failover,c, but cpu_reset.inc also has code to jump to __main() which is not included in cache_as_ram_auto_auto.c - +# mainboardinit arch/i386/lib/cpu_reset.inc +# Here cpu_reset.inc have label _cpu_reset, which is needed in failover.c, +# but cpu_reset.inc also has code to jump to __main() which is not included +# in cache_as_ram_auto_auto.c. mainboardinit arch/i386/lib/id.inc ldscript /arch/i386/lib/id.lds @@ -85,13 +86,13 @@ if USE_DCACHE_RAM end if USE_FALLBACK_IMAGE - ldscript /arch/i386/lib/failover.lds -# failover.inc need defination in cpu_reset.inc, but we do not include cpu_reset.inc,so ... -# mainboardinit ./failover.inc + ldscript /arch/i386/lib/failover.lds + # failover.inc need definition in cpu_reset.inc, but we do not include + # cpu_reset.inc,so ... + # mainboardinit ./failover.inc end -#mainboardinit cpu/x86/fpu/enable_fpu.inc -#mainboardinit cpu/x86/mmx/enable_mmx.inc - +# mainboardinit cpu/x86/fpu/enable_fpu.inc +# mainboardinit cpu/x86/mmx/enable_mmx.inc if USE_DCACHE_RAM if CONFIG_USE_INIT @@ -100,35 +101,33 @@ if USE_DCACHE_RAM mainboardinit ./cache_as_ram_auto.inc end end - -#mainboardinit cpu/x86/mmx/disable_mmx.inc + +# mainboardinit cpu/x86/mmx/disable_mmx.inc dir /pc80 config chip.h - chip northbridge/via/vx800 # Northbridge - device pci_domain 0 on - device pci 0.0 on end # AGP Bridge - device pci 0.1 on end # Error Reporting - device pci 0.2 on end # Host Bus Control - device pci 0.3 on end # Memory Controller - device pci 0.4 on end # Power Management - device pci 0.7 on end # V-Link Controller - device pci 1.0 on end # PCI Bridge - #device pci f.0 on end # IDE/SATA - #device pci f.1 on end # IDE - #device pci 10.0 on end # USB 1.1 - #device pci 10.1 on end # USB 1.1 - #device pci 10.2 on end # USB 1.1 - #device pci 10.4 on end # USB 2.0 - #device pci 11.0 on # Southbridge LPC - #end # pci 11.0 - - end # pci domain 0 - device apic_cluster 0 on # APIC cluster - chip cpu/via/model_c7 # VIA C7 - device apic 0 on end # APIC - end - end -end # vx800 + device pci_domain 0 on + device pci 0.0 on end # AGP Bridge + device pci 0.1 on end # Error Reporting + device pci 0.2 on end # Host Bus Control + device pci 0.3 on end # Memory Controller + device pci 0.4 on end # Power Management + device pci 0.7 on end # V-Link Controller + device pci 1.0 on end # PCI Bridge + # device pci f.0 on end # IDE/SATA + # device pci f.1 on end # IDE + # device pci 10.0 on end # USB 1.1 + # device pci 10.1 on end # USB 1.1 + # device pci 10.2 on end # USB 1.1 + # device pci 10.4 on end # USB 2.0 + # device pci 11.0 on # Southbridge LPC + # end + end + device apic_cluster 0 on # APIC cluster + chip cpu/via/model_c7 # VIA C7 + device apic 0 on end # APIC + end + end +end diff --git a/src/mainboard/via/epia-m700/DrivingClkPhaseData.c b/src/mainboard/via/epia-m700/DrivingClkPhaseData.c index 06f1a8eaaa..8132772efa 100644 --- a/src/mainboard/via/epia-m700/DrivingClkPhaseData.c +++ b/src/mainboard/via/epia-m700/DrivingClkPhaseData.c @@ -17,230 +17,221 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - + #include "northbridge/via/vx800/DrivingClkPhaseData.h" -// DQS Driving -//Reg0xE0, 0xE1 +// DQS Driving +// Reg0xE0, 0xE1 // According to #Bank to set DRAM DQS Driving -// #Bank 1 2 3 4 5 6 7 8 -static const u8 DDR2_DQSA_Driving_Table[4] = { 0xEE, 0xEE, 0xEE, 0xEE}; -static const u8 DDR2_DQSB_Driving_Table[2] = { 0xEE, 0xEE}; +// #Bank 1 2 3 4 5 6 7 8 +static const u8 DDR2_DQSA_Driving_Table[4] = { 0xEE, 0xEE, 0xEE, 0xEE }; +static const u8 DDR2_DQSB_Driving_Table[2] = { 0xEE, 0xEE }; // DQ Driving -//Reg0xE2, 0xE3 -// For DDR2: According to bank to set DRAM DQ Driving -static const u8 DDR2_DQA_Driving_Table[4] = { 0xAC, 0xAC, 0xAC, 0xAC }; -static const u8 DDR2_DQB_Driving_Table[2] = { 0xCA, 0xCA }; - +// Reg0xE2, 0xE3 +// For DDR2: According to bank to set DRAM DQ Driving +static const u8 DDR2_DQA_Driving_Table[4] = { 0xAC, 0xAC, 0xAC, 0xAC }; +static const u8 DDR2_DQB_Driving_Table[2] = { 0xCA, 0xCA }; -// CS Driving -//Reg0xE4, 0xE5 +// CS Driving +// Reg0xE4, 0xE5 // According to #Bank to set DRAM CS Driving -// DDR1 #Bank 1 2 3 4 5 6 7 8 -static const u8 DDR2_CSA_Driving_Table_x8[4] = { 0x44, 0x44, 0x44, 0x44 }; -static const u8 DDR2_CSB_Driving_Table_x8[2] = { 0x44, 0x44}; -static const u8 DDR2_CSA_Driving_Table_x16[4]= { 0x44, 0x44, 0x44, 0x44}; -static const u8 DDR2_CSB_Driving_Table_x16[2]= { 0x44, 0x44}; -// MAA Driving -//Reg0xE8, Reg0xE9 -static const u8 DDR2_MAA_Driving_Table[MA_Table][5] = - { - //Chip number, 400, 533, 667 800 ;(SRAS, SCAS, SWE)RxE8 - { 6, 0x86, 0x86, 0x86, 0x86}, // total MAA chips = 00 ~ 06 - { 18, 0x86, 0x86, 0x86, 0x86}, // total MAA chips = 06 ~ 18 - {255, 0xDB, 0xDB, 0xDB, 0xDB} // total MAA chips = 18 ~ - }; - -static const u8 DDR2_MAB_Driving_Table[MA_Table][2] = - { - // Chip number, Value ;(SRAS, SCAS, SWE)RxE9 - { 6, 0x86 }, // total MAB chips = 00 ~ 06 - { 18, 0x86 }, // total MAB chips = 06 ~ 18 - {255, 0xDB } // total MAB chips = 18 ~ - }; +// DDR1 #Bank 1 2 3 4 5 6 7 8 +static const u8 DDR2_CSA_Driving_Table_x8[4] = { 0x44, 0x44, 0x44, 0x44 }; +static const u8 DDR2_CSB_Driving_Table_x8[2] = { 0x44, 0x44 }; +static const u8 DDR2_CSA_Driving_Table_x16[4] = { 0x44, 0x44, 0x44, 0x44 }; +static const u8 DDR2_CSB_Driving_Table_x16[2] = { 0x44, 0x44 }; + +// MAA Driving +// Reg0xE8, Reg0xE9 +static const u8 DDR2_MAA_Driving_Table[MA_Table][5] = { + // Chip number, 400, 533, 667 800 ;(SRAS, SCAS, SWE)RxE8 + {6, 0x86, 0x86, 0x86, 0x86}, // total MAA chips = 00 ~ 06 + {18, 0x86, 0x86, 0x86, 0x86}, // total MAA chips = 06 ~ 18 + {255, 0xDB, 0xDB, 0xDB, 0xDB}, // total MAA chips = 18 ~ +}; + +static const u8 DDR2_MAB_Driving_Table[MA_Table][2] = { + // Chip number, Value ;(SRAS, SCAS, SWE)RxE9 + {6, 0x86}, // total MAB chips = 00 ~ 06 + {18, 0x86}, // total MAB chips = 06 ~ 18 + {255, 0xDB}, // total MAB chips = 18 ~ +}; // DCLK Driving -//Reg0xE6, 0xE7 +// Reg0xE6, 0xE7 // For DDR2: According to #Freq to set DRAM DCLK Driving -// freq 400M, 533M, 667M, 800M - -static const u8 DDR2_DCLKA_Driving_Table[4] = { 0xFF, 0xFF, 0xFF, 0xFF }; -static const u8 DDR2_DCLKB_Driving_Table[4] = { 0xFF, 0xFF, 0xFF, 0xFF }; +// freq 400M, 533M, 667M, 800M +static const u8 DDR2_DCLKA_Driving_Table[4] = { 0xFF, 0xFF, 0xFF, 0xFF }; +static const u8 DDR2_DCLKB_Driving_Table[4] = { 0xFF, 0xFF, 0xFF, 0xFF }; /* -Duty cycle -Duty cycle Control for DQ/DQS/DDRCKG in ChA & ChB -D0F3RxEC/D0F3RxED/D0F3RxEE/D0F3RxEF -According to DRAM frequency to control Duty Cycle -*/ -static const u8 ChA_Duty_Control_DDR2[DUTY_CYCLE_REG_NUM][DUTY_CYCLE_FREQ_NUM] = - { - // (And NOT) DDR800 DDR667 DDR533 DDR400 - //Reg Mask Value Value Value Value - {0xEC, 0x00, 0x30, 0x30, 0x30, 0x30 }, // 1Rank - {0xEE, 0x0F, 0x40, 0x40, 0x00, 0x00 }, - {0xEF, 0xCF, 0x00, 0x30, 0x30, 0x30} - }; - -static const u8 ChB_Duty_Control_DDR2[DUTY_CYCLE_REG_NUM][DUTY_CYCLE_FREQ_NUM] = - { - // (And NOT) DDR800 DDR667 DDR533 DDR400 - //Reg Mask Value Value Value Value - {0xED, 0x00, 0x88, 0x88, 0x84, 0x88 }, // 1Rank - {0xEE, 0xF0, 0x00, 0x00, 0x00, 0x00 }, - {0xEF, 0xFC, 0x00, 0x00, 0x00, 0x00 } - }; + * Duty cycle + * Duty cycle Control for DQ/DQS/DDRCKG in ChA & ChB + * D0F3RxEC/D0F3RxED/D0F3RxEE/D0F3RxEF + * According to DRAM frequency to control Duty Cycle + */ +static const u8 ChA_Duty_Control_DDR2[DUTY_CYCLE_REG_NUM][DUTY_CYCLE_FREQ_NUM] = { + // (And NOT) DDR800 DDR667 DDR533 DDR400 + //Reg Mask Value Value Value Value + {0xEC, 0x00, 0x30, 0x30, 0x30, 0x30}, // 1Rank + {0xEE, 0x0F, 0x40, 0x40, 0x00, 0x00}, + {0xEF, 0xCF, 0x00, 0x30, 0x30, 0x30}, +}; +static const u8 ChB_Duty_Control_DDR2[DUTY_CYCLE_REG_NUM][DUTY_CYCLE_FREQ_NUM] = { + // (And NOT) DDR800 DDR667 DDR533 DDR400 + //Reg Mask Value Value Value Value + {0xED, 0x00, 0x88, 0x88, 0x84, 0x88}, // 1Rank + {0xEE, 0xF0, 0x00, 0x00, 0x00, 0x00}, + {0xEF, 0xFC, 0x00, 0x00, 0x00, 0x00}, +}; /* -DRAM Clock Phase Control for FeedBack Mode -Modify NB Reg: Rx90[7]/Rx91/Rx92/Rx93/Rx94 -Processing: - 1.Program VIA_NB3DRAM_REG90[7]=0b for FeedBack mode - 2.Program clock phase value with ChA/B DCLK enable, VIA_NB3DRAM_REG91[7:3]=00b - 3.Check ChB rank #, if 0, VIA_NB3DRAM_REG91[7]=1b, to disable ChB DCLKO - ChA DCLKO can not be disable, so always program VIA_NB3DRAM_REG91[3]=0b + * DRAM Clock Phase Control for FeedBack Mode + * Modify NB Reg: Rx90[7]/Rx91/Rx92/Rx93/Rx94 + * Processing: + * 1. Program VIA_NB3DRAM_REG90[7]=0b for FeedBack mode. + * 2. Program clock phase value with ChA/B DCLK enable, + * VIA_NB3DRAM_REG91[7:3]=00b + * 3. Check ChB rank #, if 0, VIA_NB3DRAM_REG91[7]=1b, to disable ChB DCLKO + * ChA DCLKO can't be disabled, so always program VIA_NB3DRAM_REG91[3]=0b. */ -static const u8 DDR2_ChA_Clk_Phase_Table_1R[3][Clk_Phase_Table_DDR2_Width] = - { - // (And NOT) DDR800 DDR667 DDR533 DDR400 - //Reg Mask Value Value Value Value - {0x91, 0xF8, 0x02, 0x01, 0x00, 0x07 }, // 1Rank - {0x92, 0xF8, 0x04, 0x03, 0x03, 0x02 }, - {0x93, 0xF8, 0x06, 0x05, 0x04, 0x03 } - }; - -static const u8 DDR2_ChB_Clk_Phase_Table_1R[3][Clk_Phase_Table_DDR2_Width] = - { - // (And NOT) DDR800 DDR667 DDR533 DDR400 - //Reg Mask Value Value Value Value - {0x91, 0x0F, 0x20, 0x10, 0x00, 0x70 }, // 1Rank - {0x92, 0x0F, 0x40, 0x30, 0x30, 0x20 }, - {0x93, 0x0F, 0x60, 0x50, 0x40, 0x30 } - }; - -//vt6413c -/*static const u8 DDR2_ChA_Clk_Phase_Table_2R[3][Clk_Phase_Table_DDR2_Width] = - { - // (And NOT) DDR800 DDR667 DDR533 DDR400 - //Reg Mask Value Value Value Value - {0x91, 0xF8, 0x04, 0x03, 0x04, 0x01 }, // 1Rank - {0x92, 0xF8, 0x03, 0x06, 0x05, 0x04 }, - {0x93, 0xF8, 0x03, 0x07, 0x06, 0x05 } - };*/ - -//vt6413d -static const u8 DDR2_ChA_Clk_Phase_Table_2R[3][Clk_Phase_Table_DDR2_Width] = - { - // (And NOT) DDR800 DDR667 DDR533 DDR400 - //Reg Mask Value Value Value Value - {0x91, 0xF8, 0x02, 0x01, 0x00, 0x07}, // 1Rank - {0x92, 0xF8, 0x04, 0x03, 0x03, 0x02 }, - {0x93, 0xF8, 0x06, 0x05, 0x04, 0x03 } - }; +static const u8 DDR2_ChA_Clk_Phase_Table_1R[3][Clk_Phase_Table_DDR2_Width] = { + // (And NOT) DDR800 DDR667 DDR533 DDR400 + //Reg Mask Value Value Value Value + {0x91, 0xF8, 0x02, 0x01, 0x00, 0x07}, // 1Rank + {0x92, 0xF8, 0x04, 0x03, 0x03, 0x02}, + {0x93, 0xF8, 0x06, 0x05, 0x04, 0x03}, +}; + +static const u8 DDR2_ChB_Clk_Phase_Table_1R[3][Clk_Phase_Table_DDR2_Width] = { + // (And NOT) DDR800 DDR667 DDR533 DDR400 + //Reg Mask Value Value Value Value + {0x91, 0x0F, 0x20, 0x10, 0x00, 0x70}, // 1Rank + {0x92, 0x0F, 0x40, 0x30, 0x30, 0x20}, + {0x93, 0x0F, 0x60, 0x50, 0x40, 0x30}, +}; + +/* vt6413c */ +#if 0 +static const u8 DDR2_ChA_Clk_Phase_Table_2R[3][Clk_Phase_Table_DDR2_Width] = { + // (And NOT) DDR800 DDR667 DDR533 DDR400 + //Reg Mask Value Value Value Value + {0x91, 0xF8, 0x04, 0x03, 0x04, 0x01 }, // 1Rank + {0x92, 0xF8, 0x03, 0x06, 0x05, 0x04 }, + {0x93, 0xF8, 0x03, 0x07, 0x06, 0x05 }, +}; +#endif + +/* vt6413d */ +static const u8 DDR2_ChA_Clk_Phase_Table_2R[3][Clk_Phase_Table_DDR2_Width] = { + // (And NOT) DDR800 DDR667 DDR533 DDR400 + //Reg Mask Value Value Value Value + {0x91, 0xF8, 0x02, 0x01, 0x00, 0x07}, // 1Rank + {0x92, 0xF8, 0x04, 0x03, 0x03, 0x02}, + {0x93, 0xF8, 0x06, 0x05, 0x04, 0x03}, +}; /* -DRAM Write Data phase control -Modify NB Reg: Rx74/Rx75/Rx76 -*/ -//vt6413c -/*static const u8 DDR2_ChA_WrtData_Phase_Table[WrtData_REG_NUM ][WrtData_FREQ_NUM] = - { - // (And NOT) DDR800 DDR667 DDR533 DDR400 - //Reg Mask Value Value Value Value - {0x74, 0xF8, 0x03, 0x04, 0x05, 0x02 }, // 1Rank - {0x75, 0xF8, 0x03, 0x04, 0x05, 0x02 }, - {0x76, 0x00, 0x10, 0x80, 0x00, 0x07 } - };*/ - -//vt6413D -static const u8 DDR2_ChA_WrtData_Phase_Table[WrtData_REG_NUM ][WrtData_FREQ_NUM] = - { - // (And NOT) DDR800 DDR667 DDR533 DDR400 - //Reg Mask Value Value Value Value - {0x74, 0xF8, 0x01, 0x00, 0x00, 0x07 }, // 1Rank - {0x75, 0xF8, 0x01, 0x00, 0x00, 0x07 }, - {0x76, 0x10, 0x80, 0x87, 0x07, 0x06 }, - {0x8C, 0xFC, 0x03, 0x03, 0x03, 0x03 } - }; - -/*static const u8 DDR2_ChB_WrtData_Phase_Table[WrtData_REG_NUM ][WrtData_FREQ_NUM] = - { - // (And NOT) DDR800 DDR667 DDR533 DDR400 - //Reg Mask Value Value Value Value - {0x74, 0x8F, 0x30, 0x40, 0x30, 0x20 }, // 1Rank - {0x75, 0x8F, 0x30, 0x40, 0x30, 0x20 }, - {0x8A, 0x00, 0x10, 0x80, 0x07, 0x07 } - }; -*/ + * DRAM Write Data phase control + * Modify NB Reg: Rx74/Rx75/Rx76 + */ +/* vt6413c */ +#if 0 +static const u8 DDR2_ChA_WrtData_Phase_Table[WrtData_REG_NUM ][WrtData_FREQ_NUM] = { + // (And NOT) DDR800 DDR667 DDR533 DDR400 + //Reg Mask Value Value Value Value + {0x74, 0xF8, 0x03, 0x04, 0x05, 0x02 }, // 1Rank + {0x75, 0xF8, 0x03, 0x04, 0x05, 0x02 }, + {0x76, 0x00, 0x10, 0x80, 0x00, 0x07 }, +}; +#endif + +/* vt6413D */ +static const u8 DDR2_ChA_WrtData_Phase_Table[WrtData_REG_NUM][WrtData_FREQ_NUM] = { + // (And NOT) DDR800 DDR667 DDR533 DDR400 + //Reg Mask Value Value Value Value + {0x74, 0xF8, 0x01, 0x00, 0x00, 0x07}, // 1Rank + {0x75, 0xF8, 0x01, 0x00, 0x00, 0x07}, + {0x76, 0x10, 0x80, 0x87, 0x07, 0x06}, + {0x8C, 0xFC, 0x03, 0x03, 0x03, 0x03}, +}; + +#if 0 +static const u8 DDR2_ChB_WrtData_Phase_Table[WrtData_REG_NUM ][WrtData_FREQ_NUM] = { + // (And NOT) DDR800 DDR667 DDR533 DDR400 + //Reg Mask Value Value Value Value + {0x74, 0x8F, 0x30, 0x40, 0x30, 0x20 }, // 1Rank + {0x75, 0x8F, 0x30, 0x40, 0x30, 0x20 }, + {0x8A, 0x00, 0x10, 0x80, 0x07, 0x07 }, +}; +#endif + /* -DQ/DQS Output Delay Control -Modify NB D0F3: RxF0/RxF1/RxF2/RxF3 -*/ -static const u8 DDR2_CHA_DQ_DQS_Delay_Table[4][DQ_DQS_Delay_Table_Width] = - { - // RxF0 RxF1 RxF2 RxF3 - { 0x00, 0x00, 0x00, 0x00 },// DDR400 - { 0x00, 0x00, 0x00, 0x00 },// DDR533 - { 0x00, 0x00, 0x00, 0x00 },// DDR667 - { 0x00, 0x00, 0x00, 0x00 }// DDR800 - }; -static const u8 DDR2_CHB_DQ_DQS_Delay_Table[4][DQ_DQS_Delay_Table_Width] = - { - // RxF4 RxF5 RxF6 RxF7 - { 0x00, 0x00, 0x00, 0x00 },// DDR400 - { 0x00, 0x00, 0x00, 0x00 },// DDR533 - { 0x00, 0x00, 0x00, 0x00 },// DDR667 - { 0x00, 0x00, 0x00, 0x00 }// DDR800 - }; + * DQ/DQS Output Delay Control + * Modify NB D0F3: RxF0/RxF1/RxF2/RxF3 + */ +static const u8 DDR2_CHA_DQ_DQS_Delay_Table[4][DQ_DQS_Delay_Table_Width] = { + //RxF0 RxF1 RxF2 RxF3 + {0x00, 0x00, 0x00, 0x00}, /* DDR400 */ + {0x00, 0x00, 0x00, 0x00}, /* DDR533 */ + {0x00, 0x00, 0x00, 0x00}, /* DDR667 */ + {0x00, 0x00, 0x00, 0x00}, /* DDR800 */ +}; + +static const u8 DDR2_CHB_DQ_DQS_Delay_Table[4][DQ_DQS_Delay_Table_Width] = { + //RxF4 RxF5 RxF6 RxF7 + {0x00, 0x00, 0x00, 0x00}, /* DDR400 */ + {0x00, 0x00, 0x00, 0x00}, /* DDR533 */ + {0x00, 0x00, 0x00, 0x00}, /* DDR667 */ + {0x00, 0x00, 0x00, 0x00}, /* DDR800 */ +}; /* -DQ/DQS input Capture Control -modify NB D0F3_Reg:Rx78/Rx79/Rx7A/Rx7B -*/ -//vt6413C -/*static const u8 DDR2_ChA_DQS_Input_Capture_Tbl[DQS_INPUT_CAPTURE_REG_NUM ][DQS_INPUT_CAPTURE_FREQ_NUM] = - { - // (And NOT) DDR800 DDR667 DDR533 DDR400 - //Reg Mask Value Value Value Value - {0x78, 0x00, 0x83, 0x8D, 0x87, 0x83 }, // 1Rank - {0x7A, 0xF0, 0x00, 0x00, 0x00, 0x00 }, - {0x7B, 0x00, 0x10, 0x30, 0x20, 0x10 } - };*/ - -//Vt6413D -static const u8 DDR2_ChA_DQS_Input_Capture_Tbl[DQS_INPUT_CAPTURE_REG_NUM ][DQS_INPUT_CAPTURE_FREQ_NUM] = - { - // (And NOT) DDR800 DDR667 DDR533 DDR400 - //Reg Mask Value Value Value Value - {0x78, 0xC0, 0x0D, 0x07, 0x03, 0x01 }, // 1Rank - {0x7A, 0xF0, 0x00, 0x00, 0x00, 0x00 }, - {0x7B, 0x00, 0x34, 0x34, 0x20, 0x10 } - }; - -static const u8 DDR2_ChB_DQS_Input_Capture_Tbl[DQS_INPUT_CAPTURE_REG_NUM ][DQS_INPUT_CAPTURE_FREQ_NUM] = - { - // (And NOT) DDR800 DDR667 DDR533 DDR400 - //Reg Mask Value Value Value Value - {0x79, 0x00, 0x89, 0x89, 0x87, 0x83 }, // 1Rank - {0x7A, 0x0F, 0x00, 0x00, 0x00, 0x00 }, - {0x8B, 0x00, 0x34, 0x34, 0x20, 0x10 } - }; - -static const u8 Fixed_DQSA_1_2_Rank_Table[4][2] = -{ -// Rx70 Rx71 - { 0x00, 0x05 }, // DDR800 - { 0x00, 0x06 }, // DDR667 - { 0x00, 0x04 }, // DDR533 - { 0x00, 0x05 } // DDR400 -}; -static const u8 Fixed_DQSA_3_4_Rank_Table[4][2] = -{ -// Rx70 Rx71 - {0x00 , 0x04}, // DDR800 - {0x00 , 0x04}, // DDR667 - {0x00 , 0x03}, // DDR533 - {0x00 , 0x04} // DDR400 + * DQ/DQS input Capture Control + * modify NB D0F3_Reg:Rx78/Rx79/Rx7A/Rx7B + */ +/* vt6413C */ +#if 0 +static const u8 DDR2_ChA_DQS_Input_Capture_Tbl[DQS_INPUT_CAPTURE_REG_NUM ][DQS_INPUT_CAPTURE_FREQ_NUM] = { + // (And NOT) DDR800 DDR667 DDR533 DDR400 + //Reg Mask Value Value Value Value + {0x78, 0x00, 0x83, 0x8D, 0x87, 0x83 }, // 1Rank + {0x7A, 0xF0, 0x00, 0x00, 0x00, 0x00 }, + {0x7B, 0x00, 0x10, 0x30, 0x20, 0x10 } +}; +#endif + +/* vt6413D */ +static const u8DDR2_ChA_DQS_Input_Capture_Tbl[DQS_INPUT_CAPTURE_REG_NUM][DQS_INPUT_CAPTURE_FREQ_NUM] = { + // (And NOT) DDR800 DDR667 DDR533 DDR400 + //Reg Mask Value Value Value Value + {0x78, 0xC0, 0x0D, 0x07, 0x03, 0x01}, // 1Rank + {0x7A, 0xF0, 0x00, 0x00, 0x00, 0x00}, + {0x7B, 0x00, 0x34, 0x34, 0x20, 0x10} +}; + +static const u8 DDR2_ChB_DQS_Input_Capture_Tbl[DQS_INPUT_CAPTURE_REG_NUM][DQS_INPUT_CAPTURE_FREQ_NUM] = { + // (And NOT) DDR800 DDR667 DDR533 DDR400 + //Reg Mask Value Value Value Value + {0x79, 0x00, 0x89, 0x89, 0x87, 0x83}, // 1Rank + {0x7A, 0x0F, 0x00, 0x00, 0x00, 0x00}, + {0x8B, 0x00, 0x34, 0x34, 0x20, 0x10} +}; + +static const u8 Fixed_DQSA_1_2_Rank_Table[4][2] = { + //Rx70 Rx71 + {0x00, 0x05}, /* DDR800 */ + {0x00, 0x06}, /* DDR667 */ + {0x00, 0x04}, /* DDR533 */ + {0x00, 0x05}, /* DDR400 */ +}; + +static const u8 Fixed_DQSA_3_4_Rank_Table[4][2] = { + //Rx70 Rx71 + {0x00, 0x04}, /* DDR800 */ + {0x00, 0x04}, /* DDR667 */ + {0x00, 0x03}, /* DDR533 */ + {0x00, 0x04}, /* DDR400 */ }; diff --git a/src/mainboard/via/epia-m700/Options.lb b/src/mainboard/via/epia-m700/Options.lb index a788f29395..240817543f 100644 --- a/src/mainboard/via/epia-m700/Options.lb +++ b/src/mainboard/via/epia-m700/Options.lb @@ -67,11 +67,7 @@ uses TTYS0_BAUD uses CONFIG_VIDEO_MB uses CONFIG_IOAPIC - - -## -## new options -## +## New options uses USE_DCACHE_RAM uses DCACHE_RAM_BASE uses DCACHE_RAM_SIZE @@ -88,33 +84,31 @@ uses VIACONFIG_TOP_SM_SIZE_MB uses VIACONFIG_VGA_PCI_10 uses VIACONFIG_VGA_PCI_14 -## -## new options -## -default USE_DCACHE_RAM=1 -default DCACHE_RAM_BASE=0xffef0000 -#default DCACHE_RAM_BASE=0xffbf0000 -#default DCACHE_RAM_BASE=0xfec00000 //hpet may use this -default DCACHE_RAM_SIZE=0x2000 -default CONFIG_USE_INIT=0 -default MAX_RAM_SLOTS=2 -default USB_ENABLE=1 -default EHCI_ENABLE=1 -default HPET_ENABLE=1 -default USB_PORTNUM=2 +## New options +default USE_DCACHE_RAM = 1 +default DCACHE_RAM_BASE = 0xffef0000 +# default DCACHE_RAM_BASE = 0xffbf0000 +# default DCACHE_RAM_BASE = 0xfec00000 # HPET may use this. +default DCACHE_RAM_SIZE = 8 * 1024 +default CONFIG_USE_INIT = 0 +default MAX_RAM_SLOTS = 2 +default USB_ENABLE = 1 +default EHCI_ENABLE = 1 +default HPET_ENABLE = 1 +default USB_PORTNUM = 2 default FULL_ROM_SIZE = 512 * 1024 -default FULL_ROM_BASE = (0xffffffff - FULL_ROM_SIZE+ 1) -default VIACONFIG_TOP_SM_SIZE_MB=0 -#default VIACONFIG_VGA_PCI_10=0xd0000008 -#default VIACONFIG_VGA_PCI_14=0xfd000000 -default VIACONFIG_VGA_PCI_10=0xf8000008 -default VIACONFIG_VGA_PCI_14=0xfc000000 - +default FULL_ROM_BASE = (0xffffffff - FULL_ROM_SIZE + 1) +default VIACONFIG_TOP_SM_SIZE_MB = 0 +# default VIACONFIG_VGA_PCI_10 = 0xd0000008 +# default VIACONFIG_VGA_PCI_14 = 0xfd000000 +default VIACONFIG_VGA_PCI_10 = 0xf8000008 +default VIACONFIG_VGA_PCI_14 = 0xfc000000 default ROM_SIZE = 512 * 1024 default CONFIG_IOAPIC = 1 -#define framebuffer size of VX800's integrated graphics card. support 32 64 128 256 +# Define framebuffer size of VX800's integrated graphics card. +# Supports: 32, 64, 128, 256. default CONFIG_VIDEO_MB = 64 default CONFIG_CONSOLE_SERIAL8250 = 1 @@ -126,7 +120,7 @@ default CONFIG_UDELAY_TSC = 1 default CONFIG_TSC_X86RDTSC_CALIBRATE_WITH_TIMER2 = 1 default HAVE_HARD_RESET = 0 default HAVE_PIRQ_TABLE = 0 -default IRQ_SLOT_COUNT = 10 +default IRQ_SLOT_COUNT = 10 # FIXME. irq_table.c says 14. default HAVE_ACPI_TABLES = 1 default HAVE_OPTION_TABLE = 1 default ROM_IMAGE_SIZE = 128 * 1024 @@ -134,13 +128,14 @@ default FALLBACK_SIZE = ROM_SIZE default USE_FALLBACK_IMAGE = 1 default STACK_SIZE = 16 * 1024 default HEAP_SIZE = 20 * 1024 -#default USE_OPTION_TABLE = !USE_FALLBACK_IMAGE +# default USE_OPTION_TABLE = !USE_FALLBACK_IMAGE default USE_OPTION_TABLE = 0 default _RAMBASE = 0x00004000 default CONFIG_ROM_PAYLOAD = 1 default CROSS_COMPILE = "" default CC = "$(CROSS_COMPILE)gcc -m32" default HOSTCC = "gcc" +default CONFIG_CBFS = 0 ## ## Set this to the max PCI bus number you would ever use for PCI config I/O. @@ -148,11 +143,5 @@ default HOSTCC = "gcc" ## time when it can't find a device. ## default CONFIG_MAX_PCI_BUSES = 3 -end -# -# CBFS -# -# -default CONFIG_CBFS=0 end diff --git a/src/mainboard/via/epia-m700/acpi_tables.c b/src/mainboard/via/epia-m700/acpi_tables.c index cb85be2805..54480cdff5 100644 --- a/src/mainboard/via/epia-m700/acpi_tables.c +++ b/src/mainboard/via/epia-m700/acpi_tables.c @@ -3,7 +3,7 @@ * * LinuxBIOS ACPI Table support * written by Stefan Reinauer <stepan@openbios.org> - * ACPI FADT, FACS, and DSDT table support added by + * ACPI FADT, FACS, and DSDT table support added by * Nick Barker <nick.barker9@btinternet.com>, and those portions * (C) Copyright 2004 Nick Barker * (C) Copyright 2005 Stefan Reinauer @@ -24,8 +24,8 @@ */ /* - * most parts of this file copied from src\mainboard\asus\a8v-e_se\acpi_tables.c, - * acpi_is_wakeup() is from Rudolf's S3 patch and SSDT was added + * Most parts of this file copied from asus\a8v-e_se\acpi_tables.c, + * acpi_is_wakeup() is from Rudolf's S3 patch and SSDT was added. */ #include <console/console.h> @@ -38,20 +38,24 @@ extern unsigned char AmlCode_dsdt[]; extern unsigned char AmlCode_ssdt[]; +extern u32 wake_vec; +extern u8 acpi_sleep_type; + /* -These four macro copied from #include <arch/smp/mpspec.h>, I have to do this since "default HAVE_MP_TABLE = 0" in option.lb, -and also since mainboard/via/*.* have no Mptable.c(so that I can not set HAVE_MP_TABLE = 1) as many other mainboard. -So I have to copy these four to here. acpi_fill_madt() need this. -*/ + * These four macros are copied from <arch/smp/mpspec.h>, I have to do this + * since the "default HAVE_MP_TABLE = 0" in Options.lb, and also since + * mainboard/via/... have no mptable.c (so that I can not set + * HAVE_MP_TABLE = 1) as many other mainboards. + * So I have to copy these four to here. acpi_fill_madt() needs this. + */ #define MP_IRQ_POLARITY_HIGH 0x1 #define MP_IRQ_POLARITY_LOW 0x3 #define MP_IRQ_TRIGGER_EDGE 0x4 #define MP_IRQ_TRIGGER_LEVEL 0xc - unsigned long acpi_fill_mcfg(unsigned long current) { - /* NO MCFG in VX855, no pci-e*/ + /* NO MCFG in VX855, no PCI-E. */ return current; } @@ -60,34 +64,35 @@ unsigned long acpi_create_madt_lapics(unsigned long current) device_t cpu; int cpu_index = 0; - for(cpu = all_devices; cpu; cpu = cpu->next) { + for (cpu = all_devices; cpu; cpu = cpu->next) { if ((cpu->path.type != DEVICE_PATH_APIC) || - (cpu->bus->dev->path.type != DEVICE_PATH_APIC_CLUSTER)) { + (cpu->bus->dev->path.type != DEVICE_PATH_APIC_CLUSTER)) { continue; } - if (!cpu->enabled) { + if (!cpu->enabled) continue; - } - current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, cpu_index, cpu->path.apic.apic_id); + current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, + cpu_index, cpu->path.apic.apic_id); cpu_index++; } return current; } -unsigned long acpi_create_madt_lapic_nmis(unsigned long current, u16 flags, u8 lint) +unsigned long acpi_create_madt_lapic_nmis(unsigned long current, u16 flags, + u8 lint) { device_t cpu; int cpu_index = 0; - for(cpu = all_devices; cpu; cpu = cpu->next) { + for (cpu = all_devices; cpu; cpu = cpu->next) { if ((cpu->path.type != DEVICE_PATH_APIC) || - (cpu->bus->dev->path.type != DEVICE_PATH_APIC_CLUSTER)) { + (cpu->bus->dev->path.type != DEVICE_PATH_APIC_CLUSTER)) { continue; } - if (!cpu->enabled) { + if (!cpu->enabled) continue; - } - current += acpi_create_madt_lapic_nmi((acpi_madt_lapic_nmi_t *)current, cpu_index, flags, lint); + current += acpi_create_madt_lapic_nmi((acpi_madt_lapic_nmi_t *) + current, cpu_index, flags, lint); cpu_index++; } return current; @@ -102,11 +107,11 @@ unsigned long acpi_fill_madt(unsigned long current) /* Write SB IOAPIC. */ current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *) current, - VX800SB_APIC_ID, VX800SB_APIC_BASE, 0); + VX800SB_APIC_ID, VX800SB_APIC_BASE, 0); /* IRQ0 -> APIC IRQ2. */ current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *) - current, 0, 0, 2, 0x0); + current, 0, 0, 2, 0x0); /* IRQ9 ACPI active low. */ current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *) @@ -114,20 +119,20 @@ unsigned long acpi_fill_madt(unsigned long current) /* Create all subtables for processors. */ current = acpi_create_madt_lapic_nmis(current, - MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, 1); + MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, 1); return current; } -unsigned long acpi_fill_slit(unsigned long current) -{ - // Not implemented - return current; +unsigned long acpi_fill_slit(unsigned long current) +{ + /* Not implemented. */ + return current; } - + unsigned long acpi_fill_srat(unsigned long current) { - /* No NUMA, no SRAT */ + /* No NUMA, no SRAT. */ } #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) @@ -144,30 +149,27 @@ unsigned long write_acpi_tables(unsigned long start) acpi_madt_t *madt; acpi_fadt_t *fadt; acpi_facs_t *facs; - acpi_header_t *dsdt; - acpi_header_t *ssdt; - - /* Align ACPI tables to 16byte */ - start = ( start + 0x0f ) & -0x10; + acpi_header_t *dsdt, *ssdt; + + /* Align ACPI tables to 16 byte. */ + start = (start + 0x0f) & -0x10; current = start; - + printk_info("ACPI: Writing ACPI tables at %lx...\n", start); - /* We need at least an RSDP and an RSDT Table */ + /* We need at least an RSDP and an RSDT table. */ rsdp = (acpi_rsdp_t *) current; current += sizeof(acpi_rsdp_t); rsdt = (acpi_rsdt_t *) current; current += sizeof(acpi_rsdt_t); - /* clear all table memory */ + /* Clear all table memory. */ memset((void *)start, 0, current - start); - + acpi_write_rsdp(rsdp, rsdt); acpi_write_rsdt(rsdt); - - /* - * We explicitly add these tables later on: - */ + + /* We explicitly add these tables later on: */ printk_debug("ACPI: * FACS\n"); current = ALIGN(current, 64); facs = (acpi_facs_t *) current; @@ -176,18 +178,19 @@ unsigned long write_acpi_tables(unsigned long start) printk_debug("ACPI: * DSDT\n"); dsdt = (acpi_header_t *) current; - current += ((acpi_header_t *)AmlCode_dsdt)->length; - memcpy((void *)dsdt,(void *)AmlCode_dsdt, ((acpi_header_t *)AmlCode_dsdt)->length); - dsdt->checksum = 0; /* don't trust intel iasl compiler to get this right. */ + current += ((acpi_header_t *) AmlCode_dsdt)->length; + memcpy((void *)dsdt, (void *)AmlCode_dsdt, + ((acpi_header_t *) AmlCode_dsdt)->length); + dsdt->checksum = 0; /* Don't trust iasl to get this right. */ dsdt->checksum = acpi_checksum(dsdt, dsdt->length); printk_debug("ACPI: * DSDT @ %08x Length %x\n", dsdt, dsdt->length); - + printk_debug("ACPI: * FADT\n"); fadt = (acpi_fadt_t *) current; current += sizeof(acpi_fadt_t); - acpi_create_fadt(fadt,facs,dsdt); - acpi_add_table(rsdt,fadt); + acpi_create_fadt(fadt, facs, dsdt); + acpi_add_table(rsdt, fadt); /* If we want to use HPET timers Linux wants it in MADT. */ printk_debug("ACPI: * MADT\n"); @@ -195,33 +198,31 @@ unsigned long write_acpi_tables(unsigned long start) acpi_create_madt(madt); current += madt->header.length; acpi_add_table(rsdt, madt); - - /* NO MCFG in VX855, no pci-e*/ + + /* NO MCFG in VX855, no PCI-E. */ printk_debug("ACPI: * HPET\n"); hpet = (acpi_mcfg_t *) current; acpi_create_hpet(hpet); current += hpet->header.length; acpi_add_table(rsdt, hpet); -/* + +#if 0 printk_debug("ACPI: * SSDT\n"); ssdt = (acpi_header_t *) current; current += ((acpi_header_t *)AmlCode_ssdt)->length; memcpy((void *)ssdt,(void *)AmlCode_ssdt, ((acpi_header_t *)AmlCode_ssdt)->length); - ssdt->checksum = 0; // don't trust intel iasl compiler to get this right + ssdt->checksum = 0; /* Don't trust iasl to get this right. */ ssdt->checksum = acpi_checksum(ssdt, ssdt->length); acpi_add_table(rsdt, ssdt); printk_debug("ACPI: * SSDT @ %08x Length %x\n", ssdt, ssdt->length); -*/ +#endif printk_info("ACPI: done.\n"); return current; } -extern u32 wake_vec; -extern u8 acpi_sleep_type; - -int acpi_is_wakeup(void) { +int acpi_is_wakeup(void) +{ return (acpi_sleep_type == 3); } - diff --git a/src/mainboard/via/epia-m700/cache_as_ram_auto.c b/src/mainboard/via/epia-m700/cache_as_ram_auto.c index b8076d37e5..8095b81ec8 100644 --- a/src/mainboard/via/epia-m700/cache_as_ram_auto.c +++ b/src/mainboard/via/epia-m700/cache_as_ram_auto.c @@ -18,8 +18,8 @@ */ /* - * part of this file is from cx700 port, part of is from cn700 port, - * and acpi_is_wakeup_early_via_VX800() is part of Rudolf's S3 patch + * Part of this file is from cx700 port, part of is from cn700 port, + * and acpi_is_wakeup_early_via_VX800() is part of Rudolf's S3 patch. */ #define ASSEMBLY 1 @@ -47,7 +47,7 @@ #endif #include "cpu/x86/lapic/boot_cpu.c" -/* this file contains the board-special SI value for raminit.c*/ +/* This file contains the board-special SI value for raminit.c. */ #include "mainboard/via/6413e/DrivingClkPhaseData.c" #include "northbridge/via/vx800/raminit.h" @@ -55,23 +55,26 @@ #include "cpu/x86/car/copy_and_run.c" #include "mainboard/via/6413e/wakeup.h" -/* this acpi_is_wakeup_early_via_VX800 is from Rudolf's patch post in maillist in 2008-9-8, - http://www.coreboot.org/pipermail/coreboot/2008-January/028787.html. -*/ - -void jason_tsc_count_car(void) -{/* +/* + * This acpi_is_wakeup_early_via_VX800 is from Rudolf's patch on the list: + * http://www.coreboot.org/pipermail/coreboot/2008-January/028787.html. + */ +void jason_tsc_count_car(void) +{ +#if 0 unsigned long long start; asm volatile ("rdtsc" : "=A" (start)); start >>= 20; print_emerg("jason_tsc_count_car= "); - print_emerg_hex32((unsigned long) start); - print_emerg("\n");*/ + print_emerg_hex32((unsigned long) start); + print_emerg("\n"); +#endif } -int acpi_is_wakeup_early_via_vx800(void) { +int acpi_is_wakeup_early_via_vx800(void) +{ device_t dev; - u16 tmp,result; + u16 tmp, result; print_debug("In acpi_is_wakeup_early_via_vx800\r\n"); /* Power management controller */ @@ -88,11 +91,11 @@ int acpi_is_wakeup_early_via_vx800(void) { pci_write_config8(dev, 0x81, 0x84); tmp = inw(VX800_ACPI_IO_BASE + 0x04); - result= ((tmp & (7 << 10)) >> 10) == 1 ? 3 : 0; + result = ((tmp & (7 << 10)) >> 10) == 1 ? 3 : 0; print_debug(" boot_mode="); - print_debug_hex16(result); + print_debug_hex16(result); print_debug("\r\n"); - return result ; + return result; } static inline int spd_read_byte(unsigned device, unsigned address) @@ -100,625 +103,710 @@ static inline int spd_read_byte(unsigned device, unsigned address) return smbus_read_byte(device, address); } - -/* all content of this function came from the cx700 port of coreboot. - */ +/* All content of this function came from the cx700 port of coreboot. */ static void enable_mainboard_devices(void) { device_t dev; - uint16_t values; + uint16_t values; -#if 0 // add and close this switch, since some line cause error, some written at elsewhere (stage1 stage2), +#if 0 + /* + * Add and close this switch, since some line cause error, some + * written at elsewhere (stage1 stage2). + */ u8 regdata; - dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, - PCI_DEVICE_ID_VIA_VX855_LPC), 0); + dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, + PCI_DEVICE_ID_VIA_VX855_LPC), 0); - /* Disable GP3 */ + /* Disable GP3. */ pci_write_config8(dev, 0x98, 0x00); - pci_write_config8(dev, 0x50, 0x80);//disable mc97 - //martin disable internal KBC Configuration - pci_write_config8(dev, 0x51, 0x2d); //internal Config is needed to decide which key can be pressed to resume from s3 + pci_write_config8(dev, 0x50, 0x80); /* Disable mc97. */ + + /* + * Martin: Disable internal KBC configuration. + * + * Internal Config is needed to decide which key can be pressed to + * resume from s3. + */ + pci_write_config8(dev, 0x51, 0x2d); - // this cmd cause the irq0 can not be triggerd,since bit 5 was set to 0. - //pci_write_config8(dev, 0x58, 0x42); + /* This causes irq0 can not be triggerd, since bit 5 was set to 0. */ + /* pci_write_config8(dev, 0x58, 0x42); */ - //these writing may - regdata=pci_read_config8(dev, 0x58); - regdata|=0x41; - pci_write_config8(dev, 0x58,regdata); + /* These writing may... TODO */ + regdata = pci_read_config8(dev, 0x58); + regdata |= 0x41; + pci_write_config8(dev, 0x58, regdata); pci_write_config8(dev, 0x59, 0x80); pci_write_config8(dev, 0x5b, 0x01); #endif + print_debug("In enable_mainboard_devices \r\n"); - /*--AUTHOR-NOTE-- - Enable P2P Bridge Header for External PCI BUS. ---AUTHOR-NOTE--*/ + /* Enable P2P Bridge Header for external PCI bus. */ dev = pci_locate_device(PCI_ID(0x1106, 0xa353), 0); - pci_write_config8(dev, 0x4f, 0x41); - - /* "5324" already is the default value of PCI ide device, cancel this pci write*/ - /*[william 20080124]: fix bug that can not boot ubuntu at the begnning time*/ - /* dev = 0; - dev = pci_locate_device(PCI_ID(0x1106, PCI_DEVICE_ID_VIA_VX855_IDE), 0); - values = pci_read_config16(dev, 0xBA); - values &= ~0xffff; - values |= 0x5324; - pci_write_config16(dev, 0xBA, values);*/ + pci_write_config8(dev, 0x4f, 0x41); + + /* + * "5324" already is the default value of the PCI IDE device, cancel + * this PCI write. + * + * [william 20080124]: Fix bug that can not boot Ubuntu at the + * beginning time. + */ +#if 0 + dev = 0; + dev = pci_locate_device(PCI_ID(0x1106, PCI_DEVICE_ID_VIA_VX855_IDE), 0); + values = pci_read_config16(dev, 0xBA); + values &= ~0xffff; + values |= 0x5324; + pci_write_config16(dev, 0xBA, values); +#endif } -/* most content of this function came from the cx700 port of coreboot. - Turn on the shadow of E-seg. - */ +/* + * Most content of this function came from the cx700 port of coreboot. + * Turn on the shadow of E-seg. + */ static void enable_shadow_ram(void) { uint8_t shadowreg; - /*changed the value from 0x2a to 0x3f. "read only" may block "write"? - and maybe in C-seg "write" will be needed?*/ + + /* + * Changed the value from 0x2a to 0x3f. "read only" may block "write"? + * and maybe in C-seg "write" will be needed? + */ pci_write_config8(PCI_DEV(0, 0, 3), 0x80, 0xff); + /* 0xf0000-0xfffff - ACPI tables */ shadowreg = pci_read_config8(PCI_DEV(0, 0, 3), 0x83); shadowreg |= 0x30; pci_write_config8(PCI_DEV(0, 0, 3), 0x83, shadowreg); - /* 0xe0000-0xeffff - elfload? */ - /*in s3 resume process, wakeup.c, I use E-seg to hold the code(which can not locate in the area to be covered) that will copy 0-A-seg and F-seg from TOP-mem back to their normal location.*/ + + /* 0xe0000-0xeffff - elfload? */ + /* + * In s3 resume process, wakeup.c, I use E-seg to hold the code + * (which can not locate in the area to be covered) that will copy + * 0-A-seg and F-seg from TOP-mem back to their normal location. + */ pci_write_config8(PCI_DEV(0, 0, 3), 0x82, 0xff); - + #if 0 - /* Enable shadow ram as normal dram */ + /* Enable shadow RAM as normal DRAM */ /* 0xc0000-0xcffff - VGA BIOS */ pci_write_config8(PCI_DEV(0, 0, 3), 0x80, 0x2a); pci_write_config8(PCI_DEV(0, 0, 7), 0x61, 0x00); /* 0xd0000-0xdffff - ?? */ - //pci_write_config8(PCI_DEV(0, 0, 3), 0x81, 0xff); - //pci_write_config8(PCI_DEV(0, 0, 7), 0x62, 0xff); + /* pci_write_config8(PCI_DEV(0, 0, 3), 0x81, 0xff); */ + /* pci_write_config8(PCI_DEV(0, 0, 7), 0x62, 0xff); */ - /* Do it again for the vlink controller */ + /* Do it again for the vlink controller. */ shadowreg = pci_read_config8(PCI_DEV(0, 0, 7), 0x63); shadowreg |= 0x30; pci_write_config8(PCI_DEV(0, 0, 7), 0x63, shadowreg); #endif } - -/*added this table 2008-11-28, -this table contains the value needed to be set before begin to init dram. -Note: REV_Bx should be checked for changes when porting a new board!!!!! */ -static const struct VIA_PCI_REG_INIT_TABLE mNbStage1InitTbl[]= { - //VT3409 no pcie - 0x00, 0xFF, NB_APIC_REG(0x61), 0xFF, 0x0E, // Set Exxxxxxx as pcie mmio config range - 0x00, 0xFF, NB_APIC_REG(0x60), 0xF4, 0x0B, // Support extended cfg address of pcie - //0x00, 0xFF, NB_APIC_REG(0x42), 0xF9, 0x02, // APIC Interrupt((BT_INTR)) Control - // Set ROMSIP value by software - - /*0x00, 0xFF, NB_HOST_REG(0x70), 0x77, 0x33, // 2x Host Adr Strobe/Pad Pullup Driving = 3 - 0x00, 0xFF, NB_HOST_REG(0x71), 0x77, 0x33, // 2x Host Adr Strobe/Pad Pulldown Driving = 3 - 0x00, 0xFF, NB_HOST_REG(0x72), 0x77, 0x33, // 4x Host Dat Strobe/Pad Pullup Driving = 3 - 0x00, 0xFF, NB_HOST_REG(0x73), 0x77, 0x33, // 4x Host Dat Strobe/Pad Pulldown Driving = 3 - 0x00, 0xFF, NB_HOST_REG(0x74), 0xFF, 0x21, // Memory I/F timing ctrl - 0x00, 0xFF, NB_HOST_REG(0x74), 0xFF, 0xE1, // Memory I/F timing ctrl - 0x00, 0xFF, NB_HOST_REG(0x75), 0xFF, 0x18, // AGTL+ I/O Circuit - 0x00, 0xFF, NB_HOST_REG(0x76), 0xFB, 0x0C, // AGTL+ Compensation Status - 0x00, 0xFF, NB_HOST_REG(0x78), 0xFF, 0x33, // 2X AGTL+ Auto Compensation Offset - 0x00, 0xFF, NB_HOST_REG(0x79), 0xFF, 0x33, // 4X AGTL+ Auto Compensation Offset - 0x00, 0xFF, NB_HOST_REG(0x7A), 0x3F, 0x72, // AGTL Compensation Status - 0x00, 0xFF, NB_HOST_REG(0x7A), 0x3F, 0x77, // AGTL Compensation Status - 0x00, 0xFF, NB_HOST_REG(0x7B), 0xFF, 0x44, // Input Host Address / Host Strobe Delay Control for HA Group - 0x00, 0xFF, NB_HOST_REG(0x7B), 0xFF, 0x22, // Input Host Address / Host Strobe Delay Control for HA Group - 0x00, 0xFF, NB_HOST_REG(0x7C), 0xFF, 0x00, // Output Delay Control of PAD for HA Group - 0x00, 0xFF, NB_HOST_REG(0x7D), 0xFF, 0xAA, // Host Address / Address Clock Output Delay Control (Only for P4 Bus) - 0x00, 0xFF, NB_HOST_REG(0x7E), 0xFF, 0x10, // Host Address CKG Rising / Falling Time Control (Only for P4 Bus) - 0x00, 0xFF, NB_HOST_REG(0x7E), 0xFF, 0x40, // Host Address CKG Rising / Falling Time Control (Only for P4 Bus) - 0x00, 0xFF, NB_HOST_REG(0x7F), 0xFF, 0x10, // Host Address CKG Rising / Falling Time Control (Only for P4 Bus) - 0x00, 0xFF, NB_HOST_REG(0x7F), 0xFF, 0x40, // Host Address CKG Rising / Falling Time Control (Only for P4 Bus) - 0x00, 0xFF, NB_HOST_REG(0x80), 0x3F, 0x44, // Host Data Receiving Strobe Delay Ctrl 1 - 0x00, 0xFF, NB_HOST_REG(0x81), 0xFF, 0x44, // Host Data Receiving Strobe Delay Ctrl 2 - 0x00, 0xFF, NB_HOST_REG(0x82), 0xFF, 0x00, // Output Delay of PAD for HDSTB - 0x00, 0xFF, NB_HOST_REG(0x83), 0xFF, 0x00, // Output Delay of PAD for HD - 0x00, 0xFF, NB_HOST_REG(0x84), 0xFF, 0x44, // Host Data / Strobe CKG Control (Group 0) - 0x00, 0xFF, NB_HOST_REG(0x85), 0xFF, 0x44, // Host Data / Strobe CKG Control (Group 1) - 0x00, 0xFF, NB_HOST_REG(0x86), 0xFF, 0x44, // Host Data / Strobe CKG Control (Group 2) - 0x00, 0xFF, NB_HOST_REG(0x87), 0xFF, 0x44, // Host Data / Strobe CKG Control (Group 3)*/ - - - // CPU Host Bus Control - 0x00, 0xFF, NB_HOST_REG(0x50), 0x1F, 0x08, // Request phase ctrl: Dynamic Defer Snoop Stall Count = 8 - //0x00, 0xFF, NB_HOST_REG(0x51), 0xFF, 0x7F, // CPU I/F Ctrl-1: Disable Fast DRDY and RAW - 0x00, 0xFF, NB_HOST_REG(0x51), 0xFF, 0x7C, // CPU I/F Ctrl-1: Disable Fast DRDY and RAW - 0x00, 0xFF, NB_HOST_REG(0x52), 0xCB, 0xCB, // CPU I/F Ctrl-2: Enable all for performance - //0x00, 0xFF, NB_HOST_REG(0x53), 0xFF, 0x88, // Arbitration: Host/Master Occupancy timer = 8*4 HCLK - 0x00, 0xFF, NB_HOST_REG(0x53), 0xFF, 0x44, // Arbitration: Host/Master Occupancy timer = 4*4 HCLK - 0x00, 0xFF, NB_HOST_REG(0x54), 0x1E, 0x1C, // Misc Ctrl: Enable 8QW burst Mem Access - //0x00, 0xFF, NB_HOST_REG(0x55), 0x06, 0x06, // Miscellaneous Control 2 - 0x00, 0xFF, NB_HOST_REG(0x55), 0x06, 0x04, // Miscellaneous Control 2 - 0x00, 0xFF, NB_HOST_REG(0x56), 0xF7, 0x63, // Write Policy 1 - //0x00, 0xFF, NB_HOST_REG(0x59), 0x3D, 0x01, // CPU Miscellaneous Control 1, enable Lowest-Priority IPL - //0x00, 0xFF, NB_HOST_REG(0x5c), 0xFF, 0x00, // CPU Miscellaneous Control 2 - 0x00, 0xFF, NB_HOST_REG(0x5D), 0xFF, 0xA2, // Write Policy - 0x00, 0xFF, NB_HOST_REG(0x5E), 0xFF, 0x88, // Bandwidth Timer - 0x00, 0xFF, NB_HOST_REG(0x5F), 0x46, 0x46, // CPU Misc Ctrl - // 0x00, 0xFF, NB_HOST_REG(0x90), 0xFF, 0x0B, // CPU Miscellaneous Control 3 - //0x00, 0xFF, NB_HOST_REG(0x96), 0x0B, 0x0B, // CPU Miscellaneous Control 2 - 0x00, 0xFF, NB_HOST_REG(0x96), 0x0B, 0x0A, // CPU Miscellaneous Control 2 - 0x00, 0xFF, NB_HOST_REG(0x98), 0xC1, 0x41, // CPU Miscellaneous Control 3 - 0x00, 0xFF, NB_HOST_REG(0x99), 0x0E, 0x06, // CPU Miscellaneous Control 4 - - - // Set APIC and SMRAM - 0x00, 0xFF, NB_HOST_REG(0x97), 0xFF, 0x00, // APIC Related Control - 0x00, 0xFF, NB_DRAMC_REG(0x86), 0xD6, 0x29, // SMM and APIC Decoding: enable APIC, MSI and SMRAM A-Seg - 0x00, 0xFF, 0x00, 0x00, 0x00,0x00, 0x00, 0x00 // End of the table +/* + * Added this table 2008-11-28. + * This table contains the value needed to be set before begin to init DRAM. + * Note: REV_Bx should be checked for changes when porting a new board! + */ +static const struct VIA_PCI_REG_INIT_TABLE mNbStage1InitTbl[] = { + /* VT3409 no PCI-E */ + 0x00, 0xFF, NB_APIC_REG(0x61), 0xFF, 0x0E, // Set Exxxxxxx as pcie mmio config range + 0x00, 0xFF, NB_APIC_REG(0x60), 0xF4, 0x0B, // Support extended cfg address of pcie + //0x00, 0xFF, NB_APIC_REG(0x42), 0xF9, 0x02, // APIC Interrupt((BT_INTR)) Control + // Set ROMSIP value by software + + /* + 0x00, 0xFF, NB_HOST_REG(0x70), 0x77, 0x33, // 2x Host Adr Strobe/Pad Pullup Driving = 3 + 0x00, 0xFF, NB_HOST_REG(0x71), 0x77, 0x33, // 2x Host Adr Strobe/Pad Pulldown Driving = 3 + 0x00, 0xFF, NB_HOST_REG(0x72), 0x77, 0x33, // 4x Host Dat Strobe/Pad Pullup Driving = 3 + 0x00, 0xFF, NB_HOST_REG(0x73), 0x77, 0x33, // 4x Host Dat Strobe/Pad Pulldown Driving = 3 + 0x00, 0xFF, NB_HOST_REG(0x74), 0xFF, 0x21, // Memory I/F timing ctrl + 0x00, 0xFF, NB_HOST_REG(0x74), 0xFF, 0xE1, // Memory I/F timing ctrl + 0x00, 0xFF, NB_HOST_REG(0x75), 0xFF, 0x18, // AGTL+ I/O Circuit + 0x00, 0xFF, NB_HOST_REG(0x76), 0xFB, 0x0C, // AGTL+ Compensation Status + 0x00, 0xFF, NB_HOST_REG(0x78), 0xFF, 0x33, // 2X AGTL+ Auto Compensation Offset + 0x00, 0xFF, NB_HOST_REG(0x79), 0xFF, 0x33, // 4X AGTL+ Auto Compensation Offset + 0x00, 0xFF, NB_HOST_REG(0x7A), 0x3F, 0x72, // AGTL Compensation Status + 0x00, 0xFF, NB_HOST_REG(0x7A), 0x3F, 0x77, // AGTL Compensation Status + 0x00, 0xFF, NB_HOST_REG(0x7B), 0xFF, 0x44, // Input Host Address / Host Strobe Delay Control for HA Group + 0x00, 0xFF, NB_HOST_REG(0x7B), 0xFF, 0x22, // Input Host Address / Host Strobe Delay Control for HA Group + 0x00, 0xFF, NB_HOST_REG(0x7C), 0xFF, 0x00, // Output Delay Control of PAD for HA Group + 0x00, 0xFF, NB_HOST_REG(0x7D), 0xFF, 0xAA, // Host Address / Address Clock Output Delay Control (Only for P4 Bus) + 0x00, 0xFF, NB_HOST_REG(0x7E), 0xFF, 0x10, // Host Address CKG Rising / Falling Time Control (Only for P4 Bus) + 0x00, 0xFF, NB_HOST_REG(0x7E), 0xFF, 0x40, // Host Address CKG Rising / Falling Time Control (Only for P4 Bus) + 0x00, 0xFF, NB_HOST_REG(0x7F), 0xFF, 0x10, // Host Address CKG Rising / Falling Time Control (Only for P4 Bus) + 0x00, 0xFF, NB_HOST_REG(0x7F), 0xFF, 0x40, // Host Address CKG Rising / Falling Time Control (Only for P4 Bus) + 0x00, 0xFF, NB_HOST_REG(0x80), 0x3F, 0x44, // Host Data Receiving Strobe Delay Ctrl 1 + 0x00, 0xFF, NB_HOST_REG(0x81), 0xFF, 0x44, // Host Data Receiving Strobe Delay Ctrl 2 + 0x00, 0xFF, NB_HOST_REG(0x82), 0xFF, 0x00, // Output Delay of PAD for HDSTB + 0x00, 0xFF, NB_HOST_REG(0x83), 0xFF, 0x00, // Output Delay of PAD for HD + 0x00, 0xFF, NB_HOST_REG(0x84), 0xFF, 0x44, // Host Data / Strobe CKG Control (Group 0) + 0x00, 0xFF, NB_HOST_REG(0x85), 0xFF, 0x44, // Host Data / Strobe CKG Control (Group 1) + 0x00, 0xFF, NB_HOST_REG(0x86), 0xFF, 0x44, // Host Data / Strobe CKG Control (Group 2) + 0x00, 0xFF, NB_HOST_REG(0x87), 0xFF, 0x44, // Host Data / Strobe CKG Control (Group 3) */ + + // CPU Host Bus Control + 0x00, 0xFF, NB_HOST_REG(0x50), 0x1F, 0x08, // Request phase ctrl: Dynamic Defer Snoop Stall Count = 8 + //0x00, 0xFF, NB_HOST_REG(0x51), 0xFF, 0x7F, // CPU I/F Ctrl-1: Disable Fast DRDY and RAW + 0x00, 0xFF, NB_HOST_REG(0x51), 0xFF, 0x7C, // CPU I/F Ctrl-1: Disable Fast DRDY and RAW + 0x00, 0xFF, NB_HOST_REG(0x52), 0xCB, 0xCB, // CPU I/F Ctrl-2: Enable all for performance + //0x00, 0xFF, NB_HOST_REG(0x53), 0xFF, 0x88, // Arbitration: Host/Master Occupancy timer = 8*4 HCLK + 0x00, 0xFF, NB_HOST_REG(0x53), 0xFF, 0x44, // Arbitration: Host/Master Occupancy timer = 4*4 HCLK + 0x00, 0xFF, NB_HOST_REG(0x54), 0x1E, 0x1C, // Misc Ctrl: Enable 8QW burst Mem Access + //0x00, 0xFF, NB_HOST_REG(0x55), 0x06, 0x06, // Miscellaneous Control 2 + 0x00, 0xFF, NB_HOST_REG(0x55), 0x06, 0x04, // Miscellaneous Control 2 + 0x00, 0xFF, NB_HOST_REG(0x56), 0xF7, 0x63, // Write Policy 1 + //0x00, 0xFF, NB_HOST_REG(0x59), 0x3D, 0x01, // CPU Miscellaneous Control 1, enable Lowest-Priority IPL + //0x00, 0xFF, NB_HOST_REG(0x5c), 0xFF, 0x00, // CPU Miscellaneous Control 2 + 0x00, 0xFF, NB_HOST_REG(0x5D), 0xFF, 0xA2, // Write Policy + 0x00, 0xFF, NB_HOST_REG(0x5E), 0xFF, 0x88, // Bandwidth Timer + 0x00, 0xFF, NB_HOST_REG(0x5F), 0x46, 0x46, // CPU Misc Ctrl + // 0x00, 0xFF, NB_HOST_REG(0x90), 0xFF, 0x0B, // CPU Miscellaneous Control 3 + //0x00, 0xFF, NB_HOST_REG(0x96), 0x0B, 0x0B, // CPU Miscellaneous Control 2 + 0x00, 0xFF, NB_HOST_REG(0x96), 0x0B, 0x0A, // CPU Miscellaneous Control 2 + 0x00, 0xFF, NB_HOST_REG(0x98), 0xC1, 0x41, // CPU Miscellaneous Control 3 + 0x00, 0xFF, NB_HOST_REG(0x99), 0x0E, 0x06, // CPU Miscellaneous Control 4 + + // Set APIC and SMRAM + 0x00, 0xFF, NB_HOST_REG(0x97), 0xFF, 0x00, // APIC Related Control + 0x00, 0xFF, NB_DRAMC_REG(0x86), 0xD6, 0x29, // SMM and APIC Decoding: enable APIC, MSI and SMRAM A-Seg + 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // End of the table }; -#define USE_VCP 1//0 means use DVP +#define USE_VCP 1 /* 0 means "use DVP". */ #define USE_COM1 1 #define USE_COM2 0 #define gCom1Base 0x3f8 #define gCom2Base 0x2f8 + void EmbedComInit() { - u8 ByteVal; - u16 ComBase; + u8 ByteVal; + u16 ComBase; - //enable NB multiple function control + /* Enable NB multiple function control. */ ByteVal = pci_read_config8(PCI_DEV(0, 0, 0), 0x4f); - ByteVal = ByteVal |0x01; + ByteVal = ByteVal | 0x01; pci_write_config8(PCI_DEV(0, 0, 0), 0x4f, ByteVal); - //VGA Enable + /* VGA enable. */ ByteVal = pci_read_config8(PCI_DEV(0, 0, 3), 0xA1); - ByteVal = ByteVal |0x80; + ByteVal = ByteVal | 0x80; pci_write_config8(PCI_DEV(0, 0, 3), 0xA1, ByteVal); - + ByteVal = pci_read_config8(PCI_DEV(0, 0, 3), 0xA7); - ByteVal = ByteVal |0x08; + ByteVal = ByteVal | 0x08; pci_write_config8(PCI_DEV(0, 0, 3), 0xA7, ByteVal); - - //Enable p2p IO/mem + + /* Enable P2P IO/mem. */ ByteVal = pci_read_config8(PCI_DEV(0, 1, 0), 0x4); - ByteVal = ByteVal |0x07; + ByteVal = ByteVal | 0x07; pci_write_config8(PCI_DEV(0, 1, 0), 0x4, ByteVal); - //Turn on Graphic chip IO port port access - ByteVal = inb(0x3C3); - ByteVal = ByteVal |0x01; - outb(ByteVal,0x3C3); - - //Turn off Graphic chip Register protection - outb(0x10,0x3C4); - ByteVal = inb(0x3C5); - ByteVal = ByteVal |0x01; - outb(ByteVal,0x3C5); - - //south module pad share enable 0x3C5.78[7] - outb(0x78,0x3C4); - ByteVal = inb(0x3C5); - ByteVal = ByteVal |0x80; - outb(ByteVal,0x3C5); - - //enable UART Function multiplex with DVP or VCP pad D17F0Rx46[7,6] - ByteVal = pci_read_config8(PCI_DEV(0, 17, 0), 0x46); - //multiplex with VCP - if(USE_VCP == 1) - ByteVal = (ByteVal & 0x3F) | 0x40; - //multiplex with DVP - else - ByteVal = (ByteVal & 0x3F) | 0xC0; + /* Turn on graphic chip I/O port port access. */ + ByteVal = inb(0x3C3); + ByteVal = ByteVal | 0x01; + outb(ByteVal, 0x3C3); + + /* Turn off graphic chip register protection. */ + outb(0x10, 0x3C4); + ByteVal = inb(0x3C5); + ByteVal = ByteVal | 0x01; + outb(ByteVal, 0x3C5); + + /* South module pad share enable 0x3C5.78[7]. */ + outb(0x78, 0x3C4); + ByteVal = inb(0x3C5); + ByteVal = ByteVal | 0x80; + outb(ByteVal, 0x3C5); + + /* Enable UART function multiplex with DVP or VCP pad D17F0Rx46[7,6]. */ + ByteVal = pci_read_config8(PCI_DEV(0, 17, 0), 0x46); + if (USE_VCP == 1) + ByteVal = (ByteVal & 0x3F) | 0x40; /* Multiplex with VCP. */ + else + ByteVal = (ByteVal & 0x3F) | 0xC0; /* Multiplex with DVP. */ pci_write_config8(PCI_DEV(0, 17, 0), 0x46, ByteVal); - - - //enable embeded com1 and com2 D17F0RxB0[5,4] - ByteVal = pci_read_config8(PCI_DEV(0, 17, 0), 0xB0); - ByteVal = ByteVal & 0xcf; - //multiplex with VCP - if(USE_COM1==1) - ByteVal = ByteVal | 0x10; - if(USE_COM2==1) - ByteVal = ByteVal | 0x20; + /* Enable embedded COM1 and COM2 D17F0RxB0[5,4]. */ + ByteVal = pci_read_config8(PCI_DEV(0, 17, 0), 0xB0); + ByteVal = ByteVal & 0xcf; + /* Multiplex with VCP. */ + if (USE_COM1 == 1) + ByteVal = ByteVal | 0x10; + if (USE_COM2 == 1) + ByteVal = ByteVal | 0x20; pci_write_config8(PCI_DEV(0, 17, 0), 0xB0, ByteVal); - if(USE_COM1 == 1) - ComBase = gCom1Base; - else - ComBase = gCom2Base; - + if (USE_COM1 == 1) + ComBase = gCom1Base; + else + ComBase = gCom2Base; + //noharddrive - //set embeded com1 IO base = 0x3E8 - //D17F0RB4 - //ByteVal = 0xFD; - if(USE_COM1==1){ - ByteVal = (u8)((gCom1Base >> 3) |0x80); - pci_write_config8(PCI_DEV(0, 17, 0), 0xB4, ByteVal); - ByteVal = pci_read_config8(PCI_DEV(0, 17, 0), 0xb2); - ByteVal = (ByteVal&0xf0)|0x04; - pci_write_config8(PCI_DEV(0, 17, 0), 0xB2, ByteVal); - } - - //set embeded com2 IO base = 0x2E8 - //D17F0RB5 - //ByteVal = 0xDD; - if(USE_COM2==1){ - ByteVal = (u8)((gCom2Base >> 3) |0x80); - pci_write_config8(PCI_DEV(0, 17, 0), 0xB5, ByteVal); - ByteVal = pci_read_config8(PCI_DEV(0, 17, 0), 0xb2); - ByteVal = (ByteVal&0x0f)|0x30; - pci_write_config8(PCI_DEV(0, 17, 0), 0xB2, ByteVal); - } - - //no port 80 biger then 0x10 - - //disable interrupt - ByteVal = inb(ComBase + 3); - outb(ByteVal & 0x7F,ComBase + 3); - outb( 0x00,ComBase + 1); - - //set baudrate - ByteVal = inb(ComBase + 3); - outb( ByteVal | 0x80,ComBase + 3); - outb(0x01,ComBase); - outb(0x00,ComBase + 1 ); - - //set frame fromat - ByteVal = inb(ComBase + 3); - outb( ByteVal & 0x3F,ComBase + 3); - outb(0x03,ComBase + 3 ); - outb(0x00,ComBase + 2); - outb(0x00,ComBase + 4); - - //SOutput("Embeded com output\n"); - //while(1); + /* Set embedded COM1 I/O base = 0x3E8 */ + //D17F0RB4 + //ByteVal = 0xFD; + if (USE_COM1 == 1) { + ByteVal = (u8) ((gCom1Base >> 3) | 0x80); + pci_write_config8(PCI_DEV(0, 17, 0), 0xB4, ByteVal); + ByteVal = pci_read_config8(PCI_DEV(0, 17, 0), 0xb2); + ByteVal = (ByteVal & 0xf0) | 0x04; + pci_write_config8(PCI_DEV(0, 17, 0), 0xB2, ByteVal); + } + + /* Set embedded COM2 I/O base = 0x2E8. */ + //D17F0RB5 + //ByteVal = 0xDD; + if (USE_COM2 == 1) { + ByteVal = (u8) ((gCom2Base >> 3) | 0x80); + pci_write_config8(PCI_DEV(0, 17, 0), 0xB5, ByteVal); + ByteVal = pci_read_config8(PCI_DEV(0, 17, 0), 0xb2); + ByteVal = (ByteVal & 0x0f) | 0x30; + pci_write_config8(PCI_DEV(0, 17, 0), 0xB2, ByteVal); + } + /* No port 80 biger then 0x10. */ + + /* Disable interrupt. */ + ByteVal = inb(ComBase + 3); + outb(ByteVal & 0x7F, ComBase + 3); + outb(0x00, ComBase + 1); + + /* Set BAUD rate. */ + ByteVal = inb(ComBase + 3); + outb(ByteVal | 0x80, ComBase + 3); + outb(0x01, ComBase); + outb(0x00, ComBase + 1); + + /* Set frame format. */ + ByteVal = inb(ComBase + 3); + outb(ByteVal & 0x3F, ComBase + 3); + outb(0x03, ComBase + 3); + outb(0x00, ComBase + 2); + outb(0x00, ComBase + 4); + + /* SOutput("Embedded COM output\n"); */ + /* while(1); */ } -/*cache_as_ram.inc jump to here -*/ +/* cache_as_ram.inc jumps to here. */ void amd64_main(unsigned long bist) -{ unsigned cpu_reset = 0; +{ + unsigned cpu_reset = 0; u16 boot_mode; - u8 rambits; + u8 rambits, Data8, Data; + device_t device; + /* device_t dev; */ - //device_t dev; - /* Enable multifunction for northbridge. These 4 lines(until console_init();) are the same with epia-cn port.*/ + /* + * Enable multifunction for northbridge. These 4 lines (until + * console_init()) are the same with epia-cn port. + */ pci_write_config8(PCI_DEV(0, 0, 0), 0x4f, 0x01); - EmbedComInit(); - //enable_vx800_serial(); - //uart_init(); - - -/* 1. D15F0 - -a) RxBAh = 71h - -b) RxBBh = 05h - -c) RxBEh = 71h - -d) RxBFh = 05h - -2. D17F0 - -a) RxA0h = 06h - -b) RxA1h = 11h - -c) RxA2h = 27h - -d) RxA3h = 32h - -e) Rx79h = 40h - -f) Rx72h = 27h - -g) Rx73h = 32h -*/ - - u8 Data8; - - jason_tsc_count_car(); - pci_write_config16(PCI_DEV(0, 0xf, 0), 0xBA, PCI_DEVICE_ID_VIA_VX855_IDE); - pci_write_config16(PCI_DEV(0, 0xf, 0), 0xBE, PCI_DEVICE_ID_VIA_VX855_IDE); - pci_write_config16(PCI_DEV(0, 0x11, 0), 0xA0, PCI_VENDOR_ID_VIA); - pci_write_config16(PCI_DEV(0, 0x11, 0), 0xA2, PCI_DEVICE_ID_VIA_VX855_LPC); - Data8=pci_read_config8(PCI_DEV(0, 0x11, 0),0x79); - Data8 &= ~0x40; - Data8 |=0x40; - pci_write_config8(PCI_DEV(0, 0x11, 0),0x79,Data8); - pci_write_config16(PCI_DEV(0, 0x11, 0), 0x72, PCI_DEVICE_ID_VIA_VX855_LPC); - - console_init();//there are to function defination of console_init(), while the src/archi386/lib is the right one. + EmbedComInit(); + /* enable_vx800_serial(); */ + /* uart_init(); */ + + /* + * 1. D15F0 + * a) RxBAh = 71h + * b) RxBBh = 05h + * c) RxBEh = 71h + * d) RxBFh = 05h + * + * 2. D17F0 + * a) RxA0h = 06h + * b) RxA1h = 11h + * c) RxA2h = 27h + * d) RxA3h = 32h + * e) Rx79h = 40h + * f) Rx72h = 27h + * g) Rx73h = 32h + */ - /* decide if this is a s3 wakeup or a normal boot*/ - boot_mode=acpi_is_wakeup_early_via_vx800(); - /* 2008-11-27 add this, to transfer "cpu restart" to "cold boot" - When this boot is not a S3 resume, and PCI registers had been written, - then this must be a cpu restart(result of os reboot cmd), so we need a real "cold boot".*/ - jason_tsc_count_car(); - if((boot_mode!=3)&&(pci_read_config8(PCI_DEV(0, 0, 3), 0x80)!=0)) - {outb(6, 0xcf9);} /*x86 cold boot I/O cmd*/ + jason_tsc_count_car(); + + pci_write_config16(PCI_DEV(0, 0xf, 0), 0xBA, + PCI_DEVICE_ID_VIA_VX855_IDE); + pci_write_config16(PCI_DEV(0, 0xf, 0), 0xBE, + PCI_DEVICE_ID_VIA_VX855_IDE); + pci_write_config16(PCI_DEV(0, 0x11, 0), 0xA0, PCI_VENDOR_ID_VIA); + pci_write_config16(PCI_DEV(0, 0x11, 0), 0xA2, + PCI_DEVICE_ID_VIA_VX855_LPC); + Data8 = pci_read_config8(PCI_DEV(0, 0x11, 0), 0x79); + Data8 &= ~0x40; + Data8 |= 0x40; + pci_write_config8(PCI_DEV(0, 0x11, 0), 0x79, Data8); + pci_write_config16(PCI_DEV(0, 0x11, 0), 0x72, + PCI_DEVICE_ID_VIA_VX855_LPC); + + /* + * There are two function definitions of console_init(), while the + * src/arch/i386/lib is the right one. + */ + console_init(); + + /* Decide if this is a s3 wakeup or a normal boot. */ + boot_mode = acpi_is_wakeup_early_via_vx800(); + + /* + * 2008-11-27 Add this, to transfer "cpu restart" to "cold boot". + * When this boot is not a S3 resume, and PCI registers had been + * written, then this must be a CPU restart (result of OS reboot cmd), + * so we need a real "cold boot". + */ + jason_tsc_count_car(); + if ((boot_mode != 3) + && (pci_read_config8(PCI_DEV(0, 0, 3), 0x80) != 0)) { + outb(6, 0xcf9); + } - /* this 2 lines is the same with epia-cn port.*/ + /* x86 cold boot I/O cmd. */ + /* These 2 lines are the same with epia-cn port. */ enable_smbus(); - jason_tsc_count_car(); - //smbus_fixup(&ctrl);// this fix does help vx800!, but vx855 doesn't need this + jason_tsc_count_car(); + + /* This fix does help vx800!, but vx855 doesn't need this. */ + /* smbus_fixup(&ctrl); */ if (bist == 0) { - //CAR need mtrr untill mem is ok, so i disable this early_mtrr_init(); - //print_debug("doing early_mtrr\r\n"); - //early_mtrr_init(); + /* + * CAR needs MTRR until memory is ok, so disable this + * early_mtrr_init() call. + */ +#if 0 + print_debug("doing early_mtrr\r\n"); + early_mtrr_init(); +#endif } /* Halt if there was a built-in self test failure. */ report_bist_failure(bist); - + print_debug("Enabling mainboard devices\r\n"); enable_mainboard_devices(); - u8 Data; - device_t device; - /*2008-11-27 Get NB Chip revision from D0F4RxF6, revision will be used in via_pci_inittable*/ - device=PCI_DEV(0, 0, 4); - Data=pci_read_config8(device,0xf6); + /* + * Get NB chip revision from D0F4RxF6, revision will be used in + * via_pci_inittable. + */ + device = PCI_DEV(0, 0, 4); + Data = pci_read_config8(device, 0xf6); print_debug("NB chip revision ="); - print_debug_hex8(Data); + print_debug_hex8(Data); print_debug("\r\n"); - /*2008-11-27, make NB ready before draminit*/ - via_pci_inittable(Data,mNbStage1InitTbl); - /*2008-11-27 add this. - When resume from s3, draminit is skiped, so need to recovery any PCI register related to draminit. d0f3 didnt lose its Power during whole s3 time, so any register not belonging to d0f3 needs to be recovered .*/ + /* Make NB ready before DRAM init. */ + via_pci_inittable(Data, mNbStage1InitTbl); + + /* + * When resume from s3, DRAM init is skipped, so need to recovery + * any PCI register related to DRAM init. d0f3 didn't lose its power + * during whole s3 time, so any register not belonging to d0f3 needs + * to be recovered. + */ #if 1 - if (boot_mode==3) { + if (boot_mode == 3) { u8 i; - u8 ramregs[] = {0x43, 0x42, 0x41, 0x40}; + u8 ramregs[] = { 0x43, 0x42, 0x41, 0x40 }; DRAM_SYS_ATTR DramAttr; - - print_debug("This is a S3 wakeup\r\n"); - - memset (&DramAttr, 0,sizeof (DRAM_SYS_ATTR)); - /*Step1 DRAM Detection; DDR1 or DDR2; Get SPD Data; Rank Presence;64 or 128bit; Unbuffered or registered; 1T or 2T*/ - DRAMDetect(&DramAttr); - - /*begin to get ram size, 43,42 41 40 contains the end address of last rank in ddr2-slot*/ - device=PCI_DEV(0, 0, 3); - for(rambits = 0, i = 0; i < ARRAY_SIZE(ramregs); i++) { + + print_debug("This is an S3 wakeup\r\n"); + + memset(&DramAttr, 0, sizeof(DRAM_SYS_ATTR)); + /* + * Step 1: DRAM detection; DDR1 or DDR2; Get SPD Data; + * Rank Presence; 64 or 128bit; Unbuffered or registered; + * 1T or 2T. + */ + DRAMDetect(&DramAttr); + + /* + * Begin to get RAM size, 43,42 41 40 contains the end + * address of last rank in DDR2 slot. + */ + device = PCI_DEV(0, 0, 3); + for (rambits = 0, i = 0; i < ARRAY_SIZE(ramregs); i++) { rambits = pci_read_config8(device, ramregs[i]); if (rambits != 0) break; } - DRAMDRDYSetting (&DramAttr); + DRAMDRDYSetting(&DramAttr); - Data = 0x80;//this value is same with DevInit.c - pci_write_config8(PCI_DEV(0,0,4), 0xa3, Data); - pci_write_config8(PCI_DEV(0,17,7), 0x60, rambits<<2); - Data=pci_read_config8(MEMCTRL, 0x88); - pci_write_config8(PCI_DEV(0,17,7), 0xE5, Data); + Data = 0x80; /* This value is same with DevInit.c. */ + pci_write_config8(PCI_DEV(0, 0, 4), 0xa3, Data); + pci_write_config8(PCI_DEV(0, 17, 7), 0x60, rambits << 2); + Data = pci_read_config8(MEMCTRL, 0x88); + pci_write_config8(PCI_DEV(0, 17, 7), 0xE5, Data); - DRAMRegFinalValue(&DramAttr); //Just copy this function from draminit to here! - SetUMARam();//Just copy this function from draminit to here! - print_debug("Resume from S3, RAM init was ignored\r\n"); - } - else{ - ddr2_ram_setup(); - ram_check(0, 640 * 1024); + /* Just copy this function from draminit to here! */ + DRAMRegFinalValue(&DramAttr); + + /* Just copy this function from draminit to here! */ + SetUMARam(); + + print_debug("Resume from S3, RAM init was ignored\r\n"); + } else { + ddr2_ram_setup(); + ram_check(0, 640 * 1024); } #endif - //ddr2_ram_setup(); - /*2008-11-27 this line is the same with cx700 port .*/ - enable_shadow_ram(); - - jason_tsc_count_car(); - /*2008-11-27 - For coreboot most time of S3 resume is the same as normal boot, so some memory area under 1M become dirty, - so before this happen, I need to backup the content of mem to top-mem. - I will reserve the 1M top-men in LBIO table in coreboot_table.c and recovery the content of 1M-mem in wakeup.c - */ -#if PAYLOAD_IS_SEABIOS==1 // - if(boot_mode==3){ - /* An Idea of Libo.Feng at amd.com in http://www.coreboot.org/pipermail/coreboot/2008-December/043111.html - I want move the 1M data, I have to set some MTRRs myself.*/ - /*Setting mtrr before back memoy save s3 resume time about 0.14 seconds*/ - /*!!!!!!!!Since CAR stack uses cache, and we are using cache here, we must be careful, - 1 during these mtrr code, must no function call, (after this mtrr, I think it should be ok to use function) - 2 before stack switch, no use variable that have value set before this - 3 due to 2, take care of "cpu_reset", I directlly set it to ZERO. + + /* ddr2_ram_setup(); */ + /* This line is the same with cx700 port. */ + enable_shadow_ram(); + + jason_tsc_count_car(); + + /* + * For coreboot most time of S3 resume is the same as normal boot, + * so some memory area under 1M become dirty, so before this happen, + * I need to backup the content of mem to top-mem. + * + * I will reserve the 1M top-men in LBIO table in coreboot_table.c + * and recovery the content of 1M-mem in wakeup.c. + */ +#if PAYLOAD_IS_SEABIOS == 1 + if (boot_mode == 3) { + /* An idea of Libo.Feng at amd.com in http://www.coreboot.org/pipermail/coreboot/2008-December/043111.html + * + * I want move the 1M data, I have to set some MTRRs myself. + * Setting MTRR before back memory save s3 resume time about + * 0.14 seconds. + * + * !!! Since CAR stack uses cache, and we are using cache + * here, we must be careful: + * + * 1. during this MTRR code, must no function call (after + * this MTRR, I think it should be OK to use function). + * 2. Before stack switch, no use variable that have value + * set before this. + * 3. Due to 2, take care of "cpu_reset", I directlly set it + * to ZERO. + */ + u32 memtop = *(u32 *) WAKE_MEM_INFO; + u32 memtop1 = *(u32 *) WAKE_MEM_INFO - 0x100000; + u32 memtop2 = *(u32 *) WAKE_MEM_INFO - 0x200000; + u32 memtop3 = *(u32 *) WAKE_MEM_INFO - 64 * 1024 - 0x100000; + u32 memtop4 = + *(u32 *) WAKE_MEM_INFO - 64 * 1024 - 0x100000 + 0xe0000; +#if 0 + __asm__ volatile ( + "movl $0x204, %%ecx\n\t" + "xorl %%edx, %%edx\n\t" + "movl %0,%%eax\n\t" + "orl $(0 | 6), %%eax\n\t" + "wrmsr\n\t" + + "movl $0x205, %%ecx\n\t" + "xorl %%edx, %%edx\n\t" + "movl $0x100000,%%eax\n\t" + "decl %%eax\n\t" + "notl %%eax\n\t" + "orl $(0 | 0x800), %%eax\n\t" + "wrmsr\n\t" + ::"g"(memtop2) + ); + + __asm__ volatile ( + "movl $0x206, %%ecx\n\t" + "xorl %%edx, %%edx\n\t" + "movl %0,%%eax\n\t" + "orl $(0 | 6), %%eax\n\t" + "wrmsr\n\t" + + "movl $0x207, %%ecx\n\t" + "xorl %%edx, %%edx\n\t" + "movl $0x100000,%%eax\n\t" + "decl %%eax\n\t" + "notl %%eax\n\t" + "orl $(0 | 0x800), %%eax\n\t" + "wrmsr\n\t" + ::"g"(memtop1) + ); + + __asm__ volatile ( + "movl $0x208, %ecx\n\t" + "xorl %edx, %edx\n\t" + "movl $0,%eax\n\t" + "orl $(0 | 6), %eax\n\t" + "wrmsr\n\t" + + "movl $0x209, %ecx\n\t" + "xorl %edx, %edx\n\t" + "movl $0x100000,%eax\n\t" + "decl %eax\n\t" + "notl %eax\n\t" + "orl $(0 | 0x800), %eax\n\t" + "wrmsr\n\t" + ); +#endif + + /* + * WAKE_MEM_INFO is inited in get_set_top_available_mem() + * in tables.c these two memcpy() not not be enabled if set + * the MTRR around this two lines. */ - u32 memtop=*(u32*)WAKE_MEM_INFO; - u32 memtop1=*(u32*)WAKE_MEM_INFO-0x100000; - u32 memtop2=*(u32*)WAKE_MEM_INFO-0x200000; - u32 memtop3=*(u32*)WAKE_MEM_INFO- 64*1024-0x100000; - u32 memtop4=*(u32*)WAKE_MEM_INFO- 64*1024-0x100000+0xe0000; - /* __asm__ volatile ( - "movl $0x204, %%ecx\n\t" - "xorl %%edx, %%edx\n\t" - "movl %0,%%eax\n\t" - "orl $(0 | 6), %%eax\n\t" - "wrmsr\n\t" - - "movl $0x205, %%ecx\n\t" - "xorl %%edx, %%edx\n\t" - "movl $0x100000,%%eax\n\t" - "decl %%eax\n\t" - "notl %%eax\n\t" - "orl $(0 | 0x800), %%eax\n\t" - "wrmsr\n\t" - ::"g"(memtop2) +#if 0 + __asm__ volatile ( + "movl $0, %%esi\n\t" + "movl %0, %%edi\n\t" + "movl $0xa0000, %%ecx\n\t" + "shrl $2, %%ecx\n\t" + "rep movsd\n\t" + ::"g"(memtop3) ); - __asm__ volatile ( - "movl $0x206, %%ecx\n\t" - "xorl %%edx, %%edx\n\t" - "movl %0,%%eax\n\t" - "orl $(0 | 6), %%eax\n\t" - "wrmsr\n\t" - - "movl $0x207, %%ecx\n\t" - "xorl %%edx, %%edx\n\t" - "movl $0x100000,%%eax\n\t" - "decl %%eax\n\t" - "notl %%eax\n\t" - "orl $(0 | 0x800), %%eax\n\t" - "wrmsr\n\t" - ::"g"(memtop1) + + __asm__ volatile ( + "movl $0xe0000, %%esi\n\t" + "movl %0, %%edi\n\t" + "movl $0x20000, %%ecx\n\t" + "shrl $2, %%ecx\n\t" + "rep movsd\n\t" + ::"g"(memtop4) ); - __asm__ volatile ( - "movl $0x208, %ecx\n\t" - "xorl %edx, %edx\n\t" - "movl $0,%eax\n\t" - "orl $(0 | 6), %eax\n\t" - "wrmsr\n\t" - - "movl $0x209, %ecx\n\t" - "xorl %edx, %edx\n\t" - "movl $0x100000,%eax\n\t" - "decl %eax\n\t" - "notl %eax\n\t" - "orl $(0 | 0x800), %eax\n\t" - "wrmsr\n\t" +#endif + /* This can have function call, because no variable used before this. */ + print_debug("Copy memory to high memory to protect s3 wakeup vector code \r\n"); + memcpy((unsigned char *)((*(u32 *) WAKE_MEM_INFO) - 64 * 1024 - + 0x100000), (unsigned char *)0, 0xa0000); + memcpy((unsigned char *)((*(u32 *) WAKE_MEM_INFO) - 64 * 1024 - + 0x100000 + 0xe0000), (unsigned char *)0xe0000, 0x20000); + + /* Restore the MTRR previously modified. */ +#if 0 + __asm__ volatile ( + "wbinvd\n\t" + "xorl %edx, %edx\n\t" + "xorl %eax, %eax\n\t" + "movl $0x204, %ecx\n\t" + "wrmsr\n\t" + "movl $0x205, %ecx\n\t" + "wrmsr\n\t" + "movl $0x206, %ecx\n\t" + "wrmsr\n\t" + "movl $0x207, %ecx\n\t" + "wrmsr\n\t" + "movl $0x208, %ecx\n\t" + "wrmsr\n\t" + "movl $0x209, %ecx\n\t" + "wrmsr\n\t" ); - */ - // WAKE_MEM_INFO is inited in get_set_top_available_mem in tables.c - // these two memcpy not not be enabled if set the MTRR around this two lines. - /*__asm__ volatile ( - "movl $0, %%esi\n\t" - "movl %0, %%edi\n\t" - "movl $0xa0000, %%ecx\n\t" - "shrl $2, %%ecx\n\t" - "rep movsd\n\t" - ::"g"(memtop3) - ); - __asm__ volatile ( - "movl $0xe0000, %%esi\n\t" - "movl %0, %%edi\n\t" - "movl $0x20000, %%ecx\n\t" - "shrl $2, %%ecx\n\t" - "rep movsd\n\t" - ::"g"(memtop4) - );*/ - print_debug("copy memory to high memory to protect s3 wakeup vector code \r\n");//this can have function call, because no variable used before this - memcpy((unsigned char *)((*(u32*)WAKE_MEM_INFO) - 64*1024-0x100000),(unsigned char *)0,0xa0000); - memcpy((unsigned char *)((*(u32*)WAKE_MEM_INFO) - 64*1024-0x100000+0xe0000),(unsigned char *)0xe0000,0x20000); - - /* restore the MTRR previously modified. */ -/* __asm__ volatile ( - "wbinvd\n\t" - "xorl %edx, %edx\n\t" - "xorl %eax, %eax\n\t" - "movl $0x204, %ecx\n\t" - "wrmsr\n\t" - "movl $0x205, %ecx\n\t" - "wrmsr\n\t" - "movl $0x206, %ecx\n\t" - "wrmsr\n\t" - "movl $0x207, %ecx\n\t" - "wrmsr\n\t" - "movl $0x208, %ecx\n\t" - "wrmsr\n\t" - "movl $0x209, %ecx\n\t" - "wrmsr\n\t" - );*/ - } - #endif -/*2008-11-27 -the following code is copied from src\mainboard\tyan\s2735\cache_as_ram_auto.c -Only the code around CLEAR_FIRST_1M_RAM is changed. -Removed all the code around CLEAR_FIRST_1M_RAM and #include "cpu/x86/car/cache_as_ram_post.c" -the CLEAR_FIRST_1M_RAM seems to make cpu/x86/car/cache_as_ram_post.c stop at somewhere, -and cpu/x86/car/cache_as_ram_post.c do not cache my $XIP_ROM_BASE+SIZE area. - -Uuse: #include "cpu/via/car/cache_as_ram_post.c". this version post.c have some diff withx86-version -*/ +#endif + } + +#endif + +/* + * The following code is copied from tyan\s2735\cache_as_ram_auto.c. + * Only the code around CLEAR_FIRST_1M_RAM is changed. Removed all the code + * around CLEAR_FIRST_1M_RAM and #include "cpu/x86/car/cache_as_ram_post.c". + * The CLEAR_FIRST_1M_RAM seems to make cpu/x86/car/cache_as_ram_post.c stop + * at somewhere, and cpu/x86/car/cache_as_ram_post.c do not cache my + * $XIP_ROM_BASE+SIZE area. + * + * Use #include "cpu/via/car/cache_as_ram_post.c". This version post.c have + * some diff with x86-version. + */ #if 1 - { - /* Check value of esp to verify if we have enough rom for stack in Cache as RAM */ - unsigned v_esp; - __asm__ volatile ( - "movl %%esp, %0\n\t" - : "=a" (v_esp) - ); + { + /* + * Check value of esp to verify if we have enough ROM for + * stack in Cache as RAM. + */ + unsigned v_esp; + __asm__ volatile ("movl %%esp, %0\n\t":"=a" (v_esp)); #if CONFIG_USE_INIT - printk_debug("v_esp=%08x\r\n", v_esp); + printk_debug("v_esp=%08x\r\n", v_esp); #else - print_debug("v_esp="); print_debug_hex32(v_esp); print_debug("\r\n"); + print_debug("v_esp="); + print_debug_hex32(v_esp); + print_debug("\r\n"); #endif - } - + } #endif -#if 1 +#if 1 cpu_reset_x: -// it seems that cpu_reset is not used before this, so I just reset it, (this is because the s3 resume, setting in mtrr and copy data may destroy -//stack -cpu_reset=0; + + /* It seems that cpu_reset is not used before this, so I just reset + * it, (this is because the s3 resume, setting in MTRR and copy data + * may destroy stack. + */ + cpu_reset = 0; + #if CONFIG_USE_INIT - printk_debug("cpu_reset = %08x\r\n",cpu_reset); + printk_debug("cpu_reset = %08x\r\n", cpu_reset); #else - print_debug("cpu_reset = "); print_debug_hex32(cpu_reset); print_debug("\r\n"); + print_debug("cpu_reset = "); + print_debug_hex32(cpu_reset); + print_debug("\r\n"); #endif - if(cpu_reset == 0) { - print_debug("Clearing initial memory region: "); - } + if (cpu_reset == 0) + print_debug("Clearing initial memory region: "); print_debug("No cache as ram now - "); - /* store cpu_reset to ebx */ - __asm__ volatile ( - "movl %0, %%ebx\n\t" - ::"a" (cpu_reset) - ); - + /* Store cpu_reset to ebx. */ + __asm__ volatile ("movl %0, %%ebx\n\t"::"a" (cpu_reset)); -/* Cancel these lines, CLEAR_FIRST_1M_RAM cause the cpu/x86/car/cache_as_ram_post.c stop at somewhere - - if(cpu_reset==0) { + /* + * Cancel these lines, CLEAR_FIRST_1M_RAM cause the + * cpu/x86/car/cache_as_ram_post.c stop at somewhere. + */ +#if 0 + if (cpu_reset == 0) { #define CLEAR_FIRST_1M_RAM 1 -#include "cpu/via/car/cache_as_ram_post.c" - } - else { +#include "cpu/via/car/cache_as_ram_post.c" + } else { #undef CLEAR_FIRST_1M_RAM #include "cpu/via/car/cache_as_ram_post.c" } -*/ -#include "cpu/via/car/cache_as_ram_post.c" -//#include "cpu/x86/car/cache_as_ram_post.c" +#endif + +#include "cpu/via/car/cache_as_ram_post.c" +/* #include "cpu/x86/car/cache_as_ram_post.c" */ __asm__ volatile ( - /* set new esp */ /* before _RAMBASE */ - "subl %0, %%ebp\n\t" - "subl %0, %%esp\n\t" - ::"a"( (DCACHE_RAM_BASE + DCACHE_RAM_SIZE)- _RAMBASE) + /* Set new esp *//* before _RAMBASE */ + "subl %0, %%ebp\n\t" + "subl %0, %%esp\n\t":: + "a" ((DCACHE_RAM_BASE + DCACHE_RAM_SIZE) - _RAMBASE) ); { unsigned new_cpu_reset; - /* get back cpu_reset from ebx */ - __asm__ volatile ( - "movl %%ebx, %0\n\t" - :"=a" (new_cpu_reset) - ); + /* Get back cpu_reset from ebx. */ + __asm__ volatile ("movl %%ebx, %0\n\t":"=a" (new_cpu_reset)); + + /* We can't go back anymore, we lost old stack data in CAR. */ + if (new_cpu_reset == 0) + print_debug("Use Ram as Stack now - done\r\n"); + else + print_debug("Use Ram as Stack now - \r\n"); - /* We can not go back any more, we lost old stack data in cache as ram*/ - if(new_cpu_reset==0) { - print_debug("Use Ram as Stack now - done\r\n"); - } else - { - print_debug("Use Ram as Stack now - \r\n"); - } #if CONFIG_USE_INIT - printk_debug("new_cpu_reset = %08x\r\n", new_cpu_reset); + printk_debug("new_cpu_reset = %08x\r\n", new_cpu_reset); #else - print_debug("new_cpu_reset = "); print_debug_hex32(new_cpu_reset); print_debug("\r\n"); + print_debug("new_cpu_reset = "); + print_debug_hex32(new_cpu_reset); + print_debug("\r\n"); #endif - jason_tsc_count_car(); - /*copy and execute coreboot_ram */ + + jason_tsc_count_car(); + /* Copy and execute coreboot_ram. */ copy_and_run(new_cpu_reset); - /* We will not return */ + /* We will not return. */ } #endif - print_debug("should not be here -\r\n"); - } diff --git a/src/mainboard/via/epia-m700/dsdt.c b/src/mainboard/via/epia-m700/dsdt.c index 09d7d7c794..953e1f3ee8 100644 --- a/src/mainboard/via/epia-m700/dsdt.c +++ b/src/mainboard/via/epia-m700/dsdt.c @@ -18,8 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -unsigned char AmlCode_dsdt[] = -{ - 0x44,0x53,0x44,0x54,0x0F,0x3C,0x00,0x00, +unsigned char AmlCode_dsdt[] = { + 0x44, 0x53, 0x44, 0x54, 0x0F, 0x3C, 0x00, 0x00, /* Removed for lincense issue. See get_dsdt script. */ }; diff --git a/src/mainboard/via/epia-m700/fadt.c b/src/mainboard/via/epia-m700/fadt.c index 5220f23563..9e29993b37 100644 --- a/src/mainboard/via/epia-m700/fadt.c +++ b/src/mainboard/via/epia-m700/fadt.c @@ -23,8 +23,9 @@ #include <arch/acpi.h> #include <../../../northbridge/via/vx800/vx800.h> -void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs,void *dsdt){ - acpi_header_t *header =& (fadt->header); +void acpi_create_fadt(acpi_fadt_t * fadt, acpi_facs_t * facs, void *dsdt) +{ + acpi_header_t *header = &(fadt->header); memset((void *)fadt, 0, sizeof(acpi_fadt_t)); memcpy(header->signature, "FACP", 4); @@ -40,54 +41,55 @@ void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs,void *dsdt){ fadt->preferred_pm_profile = 0; fadt->sci_int = 0x9; - fadt->smi_cmd = VX800_ACPI_IO_BASE+0x2F; + fadt->smi_cmd = VX800_ACPI_IO_BASE + 0x2F; fadt->acpi_enable = 0xA1; fadt->acpi_disable = 0xA0; - /* value 42F,A1,A0, if we dont want SMI, then set them to zero. - fadt->smi_cmd = 0x0; - fadt->acpi_enable = 0x0; - fadt->acpi_disable = 0x0; - */ - + /* + * Value 42F,A1,A0, if we don't want SMI, then set them to zero. + * fadt->smi_cmd = 0x0; + * fadt->acpi_enable = 0x0; + * fadt->acpi_disable = 0x0; + */ + fadt->s4bios_req = 0x0; fadt->pstate_cnt = 0x0; fadt->pm1a_evt_blk = VX800_ACPI_IO_BASE; fadt->pm1b_evt_blk = 0x0; - fadt->pm1a_cnt_blk = VX800_ACPI_IO_BASE+0x4; + fadt->pm1a_cnt_blk = VX800_ACPI_IO_BASE + 0x4; fadt->pm1b_cnt_blk = 0x0; - fadt->pm2_cnt_blk = 0x22;//to support cpu-c3 -// fadt->pm2_cnt_blk = 0x0; - fadt->pm_tmr_blk = VX800_ACPI_IO_BASE+0x8; - fadt->gpe0_blk = VX800_ACPI_IO_BASE+0x20; - fadt->gpe1_blk = VX800_ACPI_IO_BASE+0x50; + fadt->pm2_cnt_blk = 0x22; /* To support cpu-c3. */ + /* fadt->pm2_cnt_blk = 0x0; */ + fadt->pm_tmr_blk = VX800_ACPI_IO_BASE + 0x8; + fadt->gpe0_blk = VX800_ACPI_IO_BASE + 0x20; + fadt->gpe1_blk = VX800_ACPI_IO_BASE + 0x50; fadt->pm1_evt_len = 4; fadt->pm1_cnt_len = 2; - fadt->pm2_cnt_len = 1;//to support cpu-c3 -// fadt->pm2_cnt_len = 0; + fadt->pm2_cnt_len = 1; /* To support cpu-c3. */ + /* fadt->pm2_cnt_len = 0; */ fadt->pm_tmr_len = 4; fadt->gpe0_blk_len = 4; fadt->gpe1_blk_len = 4; fadt->gpe1_base = 0x10; fadt->cst_cnt = 0; - - fadt->p_lvl2_lat = 0x50; //this is the coreboot source - fadt->p_lvl3_lat = 0x320;// -// fadt->p_lvl2_lat = 0x80; // -// fadt->p_lvl3_lat = 0x800;// -// fadt->p_lvl2_lat = 0x1; // -// fadt->p_lvl3_lat = 0x23; -// fadt->p_lvl2_lat = 0x200; //disable -// fadt->p_lvl3_lat = 0x2000; + fadt->p_lvl2_lat = 0x50; /* This is the coreboot source. */ + fadt->p_lvl3_lat = 0x320; + /* fadt->p_lvl2_lat = 0x80; */ + /* fadt->p_lvl3_lat = 0x800; */ + /* fadt->p_lvl2_lat = 0x1; */ + /* fadt->p_lvl3_lat = 0x23; */ + + /* fadt->p_lvl2_lat = 0x200; */ /* Disable. */ + /* fadt->p_lvl3_lat = 0x2000; */ fadt->flush_size = 0; fadt->flush_stride = 0; fadt->duty_offset = 0; -// fadt->duty_width = 1; + /* fadt->duty_width = 1; */ fadt->duty_width = 4; fadt->day_alrm = 0x7d; fadt->mon_alrm = 0x7e; @@ -126,7 +128,7 @@ void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs,void *dsdt){ fadt->x_pm1a_cnt_blk.bit_width = 2; fadt->x_pm1a_cnt_blk.bit_offset = 0; fadt->x_pm1a_cnt_blk.resv = 0; - fadt->x_pm1a_cnt_blk.addrl = VX800_ACPI_IO_BASE+0x4; + fadt->x_pm1a_cnt_blk.addrl = VX800_ACPI_IO_BASE + 0x4; fadt->x_pm1a_cnt_blk.addrh = 0x0; fadt->x_pm1b_cnt_blk.space_id = 1; @@ -136,8 +138,7 @@ void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs,void *dsdt){ fadt->x_pm1b_cnt_blk.addrl = 0x0; fadt->x_pm1b_cnt_blk.addrh = 0x0; - -// fadt->x_pm2_cnt_blk.space_id = 1; + /* fadt->x_pm2_cnt_blk.space_id = 1; */ fadt->x_pm2_cnt_blk.space_id = 0; fadt->x_pm2_cnt_blk.bit_width = 0; fadt->x_pm2_cnt_blk.bit_offset = 0; @@ -149,14 +150,14 @@ void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs,void *dsdt){ fadt->x_pm_tmr_blk.bit_width = 4; fadt->x_pm_tmr_blk.bit_offset = 0; fadt->x_pm_tmr_blk.resv = 0; - fadt->x_pm_tmr_blk.addrl = VX800_ACPI_IO_BASE+0x8; + fadt->x_pm_tmr_blk.addrl = VX800_ACPI_IO_BASE + 0x8; fadt->x_pm_tmr_blk.addrh = 0x0; fadt->x_gpe0_blk.space_id = 1; fadt->x_gpe0_blk.bit_width = 0; fadt->x_gpe0_blk.bit_offset = 0; fadt->x_gpe0_blk.resv = 0; - fadt->x_gpe0_blk.addrl = VX800_ACPI_IO_BASE+0x20; + fadt->x_gpe0_blk.addrl = VX800_ACPI_IO_BASE + 0x20; fadt->x_gpe0_blk.addrh = 0x0; fadt->x_gpe1_blk.space_id = 1; diff --git a/src/mainboard/via/epia-m700/get_dsdt b/src/mainboard/via/epia-m700/get_dsdt index 95d4a042ca..ae6df9f019 100644 --- a/src/mainboard/via/epia-m700/get_dsdt +++ b/src/mainboard/via/epia-m700/get_dsdt @@ -19,25 +19,25 @@ ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ## -# Simple script to dump the factory ACPI DSDT and convert it to C -# Needs to be run as root on some systems, and always run on the target machine +# Simple script to dump the factory ACPI DSDT and convert it to C. +# Must be run as root on some systems, and always run on the target machine. -if [ ! iasl ] -then echo "Intel ASL Compiler required to recompile DSDT table" +if [ ! iasl ]; then + echo "Intel ASL Compiler required to recompile DSDT table." fi -if [ ! -f /proc/acpi/dsdt ] -then echo "Cannot find DSDT table, check that your kernel supports and uses ACPI" +if [ ! -f /proc/acpi/dsdt ]; then + echo "Cannot find DSDT table, check that your kernel supports and uses ACPI." fi cat /proc/acpi/dsdt > dsdt -if [ ! -f dsdt ] -then echo "Failed copying DSDT, please check your permissions" +if [ ! -f dsdt ]; then + echo "Failed copying DSDT, please check your permissions." fi iasl -d -vr -vs dsdt iasl -tc -vr -vs dsdt.dsl mv dsdt.hex dsdt.c -echo "Done, cleaning up" +echo "Done, cleaning up." rm -f dsdt dsdt.dsl dsdt.aml dsdt.hex exit diff --git a/src/mainboard/via/epia-m700/irq_tables.c b/src/mainboard/via/epia-m700/irq_tables.c index ca481ffd62..4366d65059 100644 --- a/src/mainboard/via/epia-m700/irq_tables.c +++ b/src/mainboard/via/epia-m700/irq_tables.c @@ -18,41 +18,35 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifdef GETPIR -#include "pirq_routing.h" -#else #include <arch/pirq_routing.h> -#endif const struct irq_routing_table intel_irq_routing_table = { - PIRQ_SIGNATURE, /* u32 signature */ - PIRQ_VERSION, /* u16 version */ - 32+16*14, /* There can be total 14 devices on the bus */ - 0x00, /* Where the interrupt router lies (bus) */ - (0x11<<3)|0x0, /* Where the interrupt router lies (dev) */ - 0xc20, /* IRQs devoted exclusively to PCI usage */ - 0x1106, /* Vendor */ - 0x8409, /* Device */ - 0, /* Crap (miniport) */ - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* u8 rfu[11] */ - 0xc6, /* u8 checksum. This has to be set to some - //0xa0?? value that would give 0 after the sum of all - bytes for this structure (including checksum) */ + PIRQ_SIGNATURE, /* u32 signature */ + PIRQ_VERSION, /* u16 version */ + 32 + 16 * 14, /* There can be total 14 devices on the bus */ + 0x00, /* Where the interrupt router lies (bus) */ + (0x11 << 3) | 0x0, /* Where the interrupt router lies (dev) */ + 0xc20, /* IRQs devoted exclusively to PCI usage */ + 0x1106, /* Vendor */ + 0x8409, /* Device */ + 0, /* Miniport */ + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* u8 rfu[11] */ + 0xc6, /* Checksum. 0xa0? */ { - /* bus, dev|fn, {link, bitmap}, {link, bitmap}, {link, bitmap}, {link, bitmap}, slot, rfu */ - {0x00,(0x01<<3)|0x0, {{0x01, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0x0deb8}}, 0x0, 0x0}, - {0x00,(0x08<<3)|0x0, {{0x01, 0xdeb8}, {0x01, 0xdeb8}, {0x01, 0xdeb8}, {0x01, 0x0deb8}}, 0x1, 0x0}, - {0x00,(0x0b<<3)|0x0, {{0x01, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0x0deb8}}, 0x0, 0x0}, - {0x00,(0x0c<<3)|0x0, {{0x01, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0x0deb8}}, 0x0, 0x0}, - {0x00,(0x0d<<3)|0x0, {{0x02, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0x0deb8}}, 0x0, 0x0}, - {0x00,(0x0e<<3)|0x0, {{0x03, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0x0deb8}}, 0x0, 0x0}, - {0x00,(0x0f<<3)|0x0, {{0x02, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0x0deb8}}, 0x0, 0x0}, - {0x00,(0x10<<3)|0x0, {{0x01, 0xdeb8}, {0x02, 0xdeb8}, {0x03, 0xdeb8}, {0x04, 0x0deb8}}, 0x0, 0x0}, - {0x00,(0x14<<3)|0x0, {{0x02, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0x0deb8}}, 0x0, 0x0}, + /* bus, dev | fn, {link, bitmap}, {link, bitmap}, {link, bitmap}, {link, bitmap}, slot, rfu */ + {0x00, (0x01 << 3) | 0x0, {{0x01, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0x0deb8}}, 0x0, 0x0}, + {0x00, (0x08 << 3) | 0x0, {{0x01, 0xdeb8}, {0x01, 0xdeb8}, {0x01, 0xdeb8}, {0x01, 0x0deb8}}, 0x1, 0x0}, + {0x00, (0x0b << 3) | 0x0, {{0x01, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0x0deb8}}, 0x0, 0x0}, + {0x00, (0x0c << 3) | 0x0, {{0x01, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0x0deb8}}, 0x0, 0x0}, + {0x00, (0x0d << 3) | 0x0, {{0x02, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0x0deb8}}, 0x0, 0x0}, + {0x00, (0x0e << 3) | 0x0, {{0x03, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0x0deb8}}, 0x0, 0x0}, + {0x00, (0x0f << 3) | 0x0, {{0x02, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0x0deb8}}, 0x0, 0x0}, + {0x00, (0x10 << 3) | 0x0, {{0x01, 0xdeb8}, {0x02, 0xdeb8}, {0x03, 0xdeb8}, {0x04, 0x0deb8}}, 0x0, 0x0}, + {0x00, (0x14 << 3) | 0x0, {{0x02, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0xdeb8}, {0x00, 0x0deb8}}, 0x0, 0x0}, } }; inline unsigned long write_pirq_routing_table(unsigned long addr) { - return copy_pirq_routing_table(addr); + return copy_pirq_routing_table(addr); } diff --git a/src/mainboard/via/epia-m700/ssdt.c b/src/mainboard/via/epia-m700/ssdt.c index a32167bb1c..7c1e087a3d 100644 --- a/src/mainboard/via/epia-m700/ssdt.c +++ b/src/mainboard/via/epia-m700/ssdt.c @@ -18,8 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -unsigned char AmlCode_ssdt[] = -{ - 0x53,0x53,0x44,0x54,0xA7,0x01,0x00,0x00, /* 00000000 "SSDT...." */ +unsigned char AmlCode_ssdt[] = { + 0x53, 0x53, 0x44, 0x54, 0xA7, 0x01, 0x00, 0x00, /* Removed for licese issue. */ }; diff --git a/src/mainboard/via/epia-m700/wakeup.c b/src/mainboard/via/epia-m700/wakeup.c index 37dec7dab5..a7aa6a38c3 100644 --- a/src/mainboard/via/epia-m700/wakeup.c +++ b/src/mainboard/via/epia-m700/wakeup.c @@ -19,208 +19,206 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - //reboot.c from linux -/*this file mostly copied from Rudolf's S3 patch, some changes in acpi_jump_wake()*/ +/* reboot.c from Linux. */ + +/* + * This file mostly copied from Rudolf's S3 patch, some changes in + * acpi_jump_wake(). + */ + #include <stdint.h> #include <string.h> #include <arch/io.h> #include <console/console.h> #include <delay.h> -#include <part/init_timer.h>//for jaon_tsc_count_end +#include <part/init_timer.h> /* for jason_tsc_count_end */ #include "wakeup.h" - - - int enable_a20(void); -/* The following code and data reboots the machine by switching to real - mode and jumping to the BIOS reset entry point, as if the CPU has - really been reset. The previous version asked the keyboard - controller to pulse the CPU reset line, which is more thorough, but - doesn't work with at least one type of 486 motherboard. It is easy - to stop this code working; hence the copious comments. */ +/* + * The following code and data reboots the machine by switching to real + * mode and jumping to the BIOS reset entry point, as if the CPU has + * really been reset. The previous version asked the keyboard + * controller to pulse the CPU reset line, which is more thorough, but + * doesn't work with at least one type of 486 motherboard. It is easy + * to stop this code working; hence the copious comments. + */ -static unsigned long long -real_mode_gdt_entries [3] = -{ +static unsigned long long real_mode_gdt_entries[3] = { 0x0000000000000000ULL, /* Null descriptor */ 0x00009a000000ffffULL, /* 16-bit real-mode 64k code at 0x00000000 */ 0x000092000100ffffULL /* 16-bit real-mode 64k data at 0x00000100 */ }; struct Xgt_desc_struct { - unsigned short size; - unsigned long address __attribute__((packed)); - unsigned short pad; - } __attribute__ ((packed)); + unsigned short size; + unsigned long address __attribute__ ((packed)); + unsigned short pad; +} __attribute__ ((packed)); static struct Xgt_desc_struct -real_mode_gdt = { sizeof (real_mode_gdt_entries) - 1, (long)real_mode_gdt_entries }, -real_mode_idt = { 0x3ff, 0 }, -no_idt = { 0, 0 }; - - -/* This is 16-bit protected mode code to disable paging and the cache, - switch to real mode and jump to the BIOS reset code. - - The instruction that switches to real mode by writing to CR0 must be - followed immediately by a far jump instruction, which set CS to a - valid value for real mode, and flushes the prefetch queue to avoid - running instructions that have already been decoded in protected - mode. - - Clears all the flags except ET, especially PG (paging), PE - (protected-mode enable) and TS (task switch for coprocessor state - save). Flushes the TLB after paging has been disabled. Sets CD and - NW, to disable the cache on a 486, and invalidates the cache. This - is more like the state of a 486 after reset. I don't know if - something else should be done for other chips. - - More could be done here to set up the registers as if a CPU reset had - occurred; hopefully real BIOSs don't assume much. */ + real_mode_gdt = + { sizeof(real_mode_gdt_entries) - 1, (long)real_mode_gdt_entries }, + real_mode_idt = { +0x3ff, 0}, no_idt = { +0, 0}; +/* + * This is 16-bit protected mode code to disable paging and the cache, + * switch to real mode and jump to the BIOS reset code. + * + * The instruction that switches to real mode by writing to CR0 must be + * followed immediately by a far jump instruction, which set CS to a + * valid value for real mode, and flushes the prefetch queue to avoid + * running instructions that have already been decoded in protected + * mode. + * + * Clears all the flags except ET, especially PG (paging), PE + * (protected-mode enable) and TS (task switch for coprocessor state + * save). Flushes the TLB after paging has been disabled. Sets CD and + * NW, to disable the cache on a 486, and invalidates the cache. This + * is more like the state of a 486 after reset. I don't know if + * something else should be done for other chips. + * + * More could be done here to set up the registers as if a CPU reset had + * occurred; hopefully real BIOSs don't assume much. + */ -// 0x66, 0x0d, 0x00, 0x00, 0x00, 0x60, /* orl $0x60000000,%eax */ +// 0x66, 0x0d, 0x00, 0x00, 0x00, 0x60, /* orl $0x60000000,%eax */ -static unsigned char real_mode_switch [] = -{ - 0x66, 0x0f, 0x20, 0xc0, /* movl %cr0,%eax */ - 0x24, 0xfe, /* andb $0xfe,al */ - 0x66, 0x0f, 0x22, 0xc0 /* movl %eax,%cr0 */ +static unsigned char real_mode_switch[] = { + 0x66, 0x0f, 0x20, 0xc0, /* movl %cr0,%eax */ + 0x24, 0xfe, /* andb $0xfe,al */ + 0x66, 0x0f, 0x22, 0xc0 /* movl %eax,%cr0 */ }; -static unsigned char jump_to_wakeup [] = -{ - 0xea, 0x00, 0x00, 0x00, 0xe0 /* ljmp $0xffff,$0x0000 */ + +static unsigned char jump_to_wakeup[] = { + 0xea, 0x00, 0x00, 0x00, 0xe0 /* ljmp $0xffff, $0x0000 */ }; /* * Switch to real mode and then execute the code * specified by the code and length parameters. * We assume that length will aways be less that 100! - */ -static unsigned char show31 [6] = -{ - 0xb0, 0x31, 0xe6, 0x80, 0xeb ,0xFA /* ljmp $0xffff,$0x0000 */ -}; -static unsigned char show32 [6] = -{ - 0xb0, 0x32, 0xe6, 0x80, 0xeb ,0xFA /* ljmp $0xffff,$0x0000 */ -}; + */ +static unsigned char show31[6] = { + 0xb0, 0x31, 0xe6, 0x80, 0xeb, 0xFA /* ljmp $0xffff,$0x0000 */ +}; + +static unsigned char show32[6] = { + 0xb0, 0x32, 0xe6, 0x80, 0xeb, 0xFA /* ljmp $0xffff,$0x0000 */ +}; + void acpi_jump_wake(u32 vector) { -u32 tmp; -u16 tmpvector; -u32 dwEip; -u8 Data; -struct Xgt_desc_struct * wake_thunk16_Xgt_desc; + u32 tmp; + u16 tmpvector; + u32 dwEip; + u8 Data; + struct Xgt_desc_struct *wake_thunk16_Xgt_desc; printk_debug("IN ACPI JUMP WAKE TO %x\n", vector); if (enable_a20()) die("failed to enable A20\n"); printk_debug("IN ACPI JUMP WAKE TO 3 %x\n", vector); - - * ((u16 *) (jump_to_wakeup+3)) = (u16)(vector>>4); - printk_debug("%x %x %x %x %x\n", jump_to_wakeup[0], jump_to_wakeup[1], jump_to_wakeup[2], jump_to_wakeup[3],jump_to_wakeup[4]); - memcpy ((void *) (WAKE_THUNK16_ADDR - sizeof (real_mode_switch) - 100), - real_mode_switch, sizeof (real_mode_switch)); - memcpy ((void *) (WAKE_THUNK16_ADDR - 100), jump_to_wakeup, sizeof(jump_to_wakeup)); + *((u16 *) (jump_to_wakeup + 3)) = (u16) (vector >> 4); + printk_debug("%x %x %x %x %x\n", jump_to_wakeup[0], jump_to_wakeup[1], + jump_to_wakeup[2], jump_to_wakeup[3], jump_to_wakeup[4]); + + memcpy((void *)(WAKE_THUNK16_ADDR - sizeof(real_mode_switch) - 100), + real_mode_switch, sizeof(real_mode_switch)); + memcpy((void *)(WAKE_THUNK16_ADDR - 100), jump_to_wakeup, + sizeof(jump_to_wakeup)); jason_tsc_count(); - printk_emerg("file '%s', line %d\n\n", __FILE__, __LINE__); + printk_emerg("file '%s', line %d\n\n", __FILE__, __LINE__); jason_tsc_count_end(); - - unsigned long long * real_mode_gdt_entries_at_eseg; - real_mode_gdt_entries_at_eseg=WAKE_THUNK16_GDT; //copy from real_mode_gdt_entries and change limition to 1M and data base to 0; - real_mode_gdt_entries_at_eseg [0] = 0x0000000000000000ULL; /* Null descriptor */ - real_mode_gdt_entries_at_eseg [1] = 0x000f9a000000ffffULL; /* 16-bit real-mode 1M code at 0x00000000 */ - real_mode_gdt_entries_at_eseg [2] = 0x000f93000000ffffULL; /* 16-bit real-mode 1M data at 0x00000000 */ - - wake_thunk16_Xgt_desc=WAKE_THUNK16_XDTR; - wake_thunk16_Xgt_desc[0].size=sizeof (real_mode_gdt_entries) - 1; - wake_thunk16_Xgt_desc[0].address=(long)real_mode_gdt_entries_at_eseg; - wake_thunk16_Xgt_desc[1].size=0x3ff; - wake_thunk16_Xgt_desc[1].address=0; - wake_thunk16_Xgt_desc[2].size=0; - wake_thunk16_Xgt_desc[2].address=0; - - /*added this code to get current value of EIP - */ - __asm__ volatile ( - "calll geip\n\t" - "geip: \n\t" - "popl %0\n\t" - :"=a"(dwEip) - ); + unsigned long long *real_mode_gdt_entries_at_eseg; + real_mode_gdt_entries_at_eseg = WAKE_THUNK16_GDT; //copy from real_mode_gdt_entries and change limition to 1M and data base to 0; + real_mode_gdt_entries_at_eseg[0] = 0x0000000000000000ULL; /* Null descriptor */ + real_mode_gdt_entries_at_eseg[1] = 0x000f9a000000ffffULL; /* 16-bit real-mode 1M code at 0x00000000 */ + real_mode_gdt_entries_at_eseg[2] = 0x000f93000000ffffULL; /* 16-bit real-mode 1M data at 0x00000000 */ + + wake_thunk16_Xgt_desc = WAKE_THUNK16_XDTR; + wake_thunk16_Xgt_desc[0].size = sizeof(real_mode_gdt_entries) - 1; + wake_thunk16_Xgt_desc[0].address = (long)real_mode_gdt_entries_at_eseg; + wake_thunk16_Xgt_desc[1].size = 0x3ff; + wake_thunk16_Xgt_desc[1].address = 0; + wake_thunk16_Xgt_desc[2].size = 0; + wake_thunk16_Xgt_desc[2].address = 0; + + /*added this code to get current value of EIP + */ + __asm__ volatile ("calll geip\n\t" + "geip: \n\t" "popl %0\n\t":"=a" (dwEip) + ); unsigned char *dest; unsigned char *src; - src= (unsigned char *)dwEip; - dest=WAKE_RECOVER1M_CODE; + src = (unsigned char *)dwEip; + dest = WAKE_RECOVER1M_CODE; u32 i; - for (i = 0; i < 0x200; i++) - dest[i] = src[i]; - - __asm__ __volatile__ ("ljmp $0x0010,%0"//08 error - : - : "i" ((void *) (WAKE_RECOVER1M_CODE+0x20))); - - /*added 0x20 "nop" to make sure the ljmp will not jump then halt*/ - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - asm volatile("nop"); - + for (i = 0; i < 0x200; i++) + dest[i] = src[i]; - __asm__ volatile ( - /* set new esp, maybe ebp should not equal to esp?, - due to the variable in acpi_jump_wake?, anyway, this may be not a big problem. - and I didnt clear the area (ef000+-0x200) to zero. - */ - "movl %0, %%ebp\n\t" - "movl %0, %%esp\n\t" - ::"a"(WAKE_THUNK16_STACK) - ); + __asm__ __volatile__("ljmp $0x0010,%0" //08 error + ::"i"((void *)(WAKE_RECOVER1M_CODE + 0x20))); + + /*added 0x20 "nop" to make sure the ljmp will not jump then halt */ + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + __asm__ volatile ( + /* set new esp, maybe ebp should not equal to esp?, + due to the variable in acpi_jump_wake?, anyway, this may be not a big problem. + and I didnt clear the area (ef000+-0x200) to zero. + */ + "movl %0, %%ebp\n\t" + "movl %0, %%esp\n\t"::"a" (WAKE_THUNK16_STACK) + ); /* added this - only "src" and "dest" use the new stack, and the esp maybe also used in resumevector - */ -#if PAYLOAD_IS_SEABIOS==1 + only "src" and "dest" use the new stack, and the esp maybe also used in resumevector + */ +#if PAYLOAD_IS_SEABIOS==1 // WAKE_MEM_INFO inited in get_set_top_available_mem in tables.c - src = (unsigned char *)((* (u32*)WAKE_MEM_INFO)- 64*1024-0x100000); - dest = 0; - for (i = 0; i < 0xa0000; i++)//if recovered 0-e0000, then when resume, before winxp turn on the desktop screen ,there is gray background which last 1sec. + src = + (unsigned char *)((*(u32 *) WAKE_MEM_INFO) - 64 * 1024 - 0x100000); + dest = 0; + for (i = 0; i < 0xa0000; i++) //if recovered 0-e0000, then when resume, before winxp turn on the desktop screen ,there is gray background which last 1sec. dest[i] = src[i]; /*__asm__ volatile ( "movl %0, %%esi\n\t" @@ -230,55 +228,57 @@ struct Xgt_desc_struct * wake_thunk16_Xgt_desc; "rep movsd\n\t" ::"a"(src) );*/ - src = (unsigned char *)((* (u32*)WAKE_MEM_INFO)- 64*1024-0x100000+0xc0000); + src = + (unsigned char *)((*(u32 *) WAKE_MEM_INFO) - 64 * 1024 - 0x100000 + + 0xc0000); //dest = 0xc0000; //for (i = 0; i < 0x20000; i++) - // dest[i] = src[i]; - /* __asm__ volatile ( - "movl %0, %%esi\n\t" - "movl $0xc0000, %%edi\n\t" - "movl $0x20000, %%ecx\n\t" - "shrl $2, %%ecx\n\t" - "rep movsd\n\t" - ::"a"(src) - );*/ - - - src = (unsigned char *)((* (u32*)WAKE_MEM_INFO)- 64*1024-0x100000+0xe0000+WAKE_SPECIAL_SIZE); - //dest = 0xf0000; - //for (i = 0; i < 0x10000; i++) - // dest[i] = src[i]; - __asm__ volatile ( - "movl %0, %%esi\n\t" - "movl %1, %%edi\n\t" - "movl %2, %%ecx\n\t" - "shrl $2, %%ecx\n\t" - "rep movsd\n\t" - ::"r"(src),"r"(0xe0000+WAKE_SPECIAL_SIZE), "r"(0x10000-WAKE_SPECIAL_SIZE) - ); - - src = (unsigned char *)((* (u32*)WAKE_MEM_INFO)- 64*1024-0x100000+0xf0000); - //dest = 0xf0000; - //for (i = 0; i < 0x10000; i++) - // dest[i] = src[i]; - __asm__ volatile ( - "movl %0, %%esi\n\t" - "movl $0xf0000, %%edi\n\t" - "movl $0x10000, %%ecx\n\t" - "shrl $2, %%ecx\n\t" - "rep movsd\n\t" - ::"a"(src) - ); - - asm volatile("wbinvd"); + // dest[i] = src[i]; + /* __asm__ volatile ( + "movl %0, %%esi\n\t" + "movl $0xc0000, %%edi\n\t" + "movl $0x20000, %%ecx\n\t" + "shrl $2, %%ecx\n\t" + "rep movsd\n\t" + ::"a"(src) + ); */ + + src = + (unsigned char *)((*(u32 *) WAKE_MEM_INFO) - 64 * 1024 - 0x100000 + + 0xe0000 + WAKE_SPECIAL_SIZE); + //dest = 0xf0000; + //for (i = 0; i < 0x10000; i++) + // dest[i] = src[i]; + __asm__ volatile ("movl %0, %%esi\n\t" + "movl %1, %%edi\n\t" + "movl %2, %%ecx\n\t" + "shrl $2, %%ecx\n\t" + "rep movsd\n\t"::"r" (src), + "r"(0xe0000 + WAKE_SPECIAL_SIZE), + "r"(0x10000 - WAKE_SPECIAL_SIZE) + ); + + src = + (unsigned char *)((*(u32 *) WAKE_MEM_INFO) - 64 * 1024 - 0x100000 + + 0xf0000); + //dest = 0xf0000; + //for (i = 0; i < 0x10000; i++) + // dest[i] = src[i]; + __asm__ volatile ("movl %0, %%esi\n\t" + "movl $0xf0000, %%edi\n\t" + "movl $0x10000, %%ecx\n\t" + "shrl $2, %%ecx\n\t" "rep movsd\n\t"::"a" (src) + ); + + asm volatile ("wbinvd"); #endif /* Set up the IDT for real mode. */ - asm volatile("lidt %0"::"m" (wake_thunk16_Xgt_desc[1])); - + asm volatile ("lidt %0"::"m" (wake_thunk16_Xgt_desc[1])); + /* Set up a GDT from which we can load segment descriptors for real mode. The GDT is not used in real mode; it is just needed here to prepare the descriptors. */ - asm volatile("lgdt %0"::"m" (wake_thunk16_Xgt_desc[0])); + asm volatile ("lgdt %0"::"m" (wake_thunk16_Xgt_desc[0])); /* Load the data segment registers, and thus the descriptors ready for real mode. The base address of each segment is 0x100, 16 times the @@ -286,22 +286,21 @@ struct Xgt_desc_struct * wake_thunk16_Xgt_desc; registers don't have to be reloaded after switching to real mode: the values are consistent for real mode operation already. */ - __asm__ __volatile__ ("movl $0x0010,%%eax\n" - "\tmovl %%eax,%%ds\n" - "\tmovl %%eax,%%es\n" - "\tmovl %%eax,%%fs\n" - "\tmovl %%eax,%%gs\n" - "\tmovl %%eax,%%ss" : : : "eax"); + __asm__ __volatile__("movl $0x0010,%%eax\n" + "\tmovl %%eax,%%ds\n" + "\tmovl %%eax,%%es\n" + "\tmovl %%eax,%%fs\n" + "\tmovl %%eax,%%gs\n" "\tmovl %%eax,%%ss":::"eax"); /* Jump to the 16-bit code that we copied earlier. It disables paging and the cache, switches to real mode, and jumps to the BIOS reset entry point. */ - - __asm__ __volatile__ ("ljmp $0x0008,%0" - : - : "i" ((void *) (WAKE_THUNK16_ADDR - sizeof (real_mode_switch) - 100))); -} + __asm__ + __volatile__("ljmp $0x0008,%0"::"i" + ((void *)(WAKE_THUNK16_ADDR - + sizeof(real_mode_switch) - 100))); +} /* -*- linux-c -*- ------------------------------------------------------- * * @@ -357,24 +356,24 @@ static int a20_test(int loops) int ok = 0; int saved, ctr; -// set_fs(0x0000); -// set_gs(0xffff); +// set_fs(0x0000); +// set_gs(0xffff); - saved = ctr = *((u32*) A20_TEST_ADDR); + saved = ctr = *((u32 *) A20_TEST_ADDR); while (loops--) { //wrfs32(++ctr, A20_TEST_ADDR); - - *((u32*) A20_TEST_ADDR) = ++ctr; - + + *((u32 *) A20_TEST_ADDR) = ++ctr; + udelay(1); /* Serialize and make delay constant */ - - ok = *((u32 *) A20_TEST_ADDR+0xffff0+0x10) ^ ctr; + + ok = *((u32 *) A20_TEST_ADDR + 0xffff0 + 0x10) ^ ctr; if (ok) break; } - *((u32*) A20_TEST_ADDR) = saved; + *((u32 *) A20_TEST_ADDR) = saved; return ok; } @@ -407,7 +406,7 @@ static void enable_a20_fast(void) u8 port_a; port_a = inb(0x92); /* Configuration port A */ - port_a |= 0x02; /* Enable A20 */ + port_a |= 0x02; /* Enable A20 */ port_a &= ~0x01; /* Do not reset machine */ outb(port_a, 0x92); } @@ -431,7 +430,7 @@ int enable_a20(void) /* Try enabling A20 through the keyboard controller */ empty_8042(); //if (a20_test_short()) -// return 0; /* BIOS worked, but with delayed reaction */ +// return 0; /* BIOS worked, but with delayed reaction */ enable_a20_kbc(); if (a20_test_long()) diff --git a/src/mainboard/via/epia-m700/wakeup.h b/src/mainboard/via/epia-m700/wakeup.h index 703119c590..734bbfa3bd 100644 --- a/src/mainboard/via/epia-m700/wakeup.h +++ b/src/mainboard/via/epia-m700/wakeup.h @@ -21,13 +21,13 @@ #ifndef WAKEUP_H #define WAKEUP_H -#define WAKE_SPECIAL_AREA 0xE0000 -#define WAKE_SPECIAL_SIZE 0x1000 -#define WAKE_THUNK16_ADDR (WAKE_SPECIAL_AREA+0x200) -#define WAKE_THUNK16_GDT (WAKE_SPECIAL_AREA+0x300) -#define WAKE_THUNK16_XDTR (WAKE_SPECIAL_AREA+0x350) -#define WAKE_MEM_INFO (WAKE_SPECIAL_AREA+0x400) -#define WAKE_RECOVER1M_CODE (WAKE_SPECIAL_AREA+0x500) -#define WAKE_THUNK16_STACK (WAKE_SPECIAL_AREA+0xf00) +#define WAKE_SPECIAL_AREA 0xE0000 +#define WAKE_SPECIAL_SIZE 0x1000 +#define WAKE_THUNK16_ADDR (WAKE_SPECIAL_AREA + 0x200) +#define WAKE_THUNK16_GDT (WAKE_SPECIAL_AREA + 0x300) +#define WAKE_THUNK16_XDTR (WAKE_SPECIAL_AREA + 0x350) +#define WAKE_MEM_INFO (WAKE_SPECIAL_AREA + 0x400) +#define WAKE_RECOVER1M_CODE (WAKE_SPECIAL_AREA + 0x500) +#define WAKE_THUNK16_STACK (WAKE_SPECIAL_AREA + 0xf00) -#endif /* WAKEUP_H */ +#endif |