Eric Biederman | 9b4336c | 2003-07-19 04:28:22 +0000 | [diff] [blame] | 1 | #include <stdint.h> |
Eric Biederman | 297b06e | 2004-10-14 21:55:53 +0000 | [diff] [blame] | 2 | #include <cpu/x86/lapic.h> |
Eric Biederman | 9b4336c | 2003-07-19 04:28:22 +0000 | [diff] [blame] | 3 | #define NODE_ID 0x60 |
| 4 | #define HT_INIT_CONTROL 0x6c |
| 5 | |
| 6 | #define HTIC_ColdR_Detect (1<<4) |
| 7 | #define HTIC_BIOSR_Detect (1<<5) |
| 8 | #define HTIC_INIT_Detect (1<<6) |
| 9 | |
Stefan Reinauer | f8b1923 | 2010-04-07 00:38:09 +0000 | [diff] [blame] | 10 | static inline int cpu_init_detected(unsigned nodeid) |
Eric Biederman | 9b4336c | 2003-07-19 04:28:22 +0000 | [diff] [blame] | 11 | { |
Stefan Reinauer | f8b1923 | 2010-04-07 00:38:09 +0000 | [diff] [blame] | 12 | u32 htic; |
Edward O'Callaghan | 3ec9c95 | 2014-10-26 10:36:02 +1100 | [diff] [blame] | 13 | pci_devfn_t dev; |
Eric Biederman | 5cd8173 | 2004-03-11 15:01:31 +0000 | [diff] [blame] | 14 | |
Yinghai Lu | 23202a9 | 2005-01-05 20:29:05 +0000 | [diff] [blame] | 15 | dev = PCI_DEV(0, 0x18 + nodeid, 0); |
Eric Biederman | 5cd8173 | 2004-03-11 15:01:31 +0000 | [diff] [blame] | 16 | htic = pci_read_config32(dev, HT_INIT_CONTROL); |
Eric Biederman | 9b4336c | 2003-07-19 04:28:22 +0000 | [diff] [blame] | 17 | |
Eric Biederman | 0ac6b41 | 2003-09-02 17:16:48 +0000 | [diff] [blame] | 18 | return !!(htic & HTIC_INIT_Detect); |
| 19 | } |
| 20 | |
Stefan Reinauer | f8b1923 | 2010-04-07 00:38:09 +0000 | [diff] [blame] | 21 | static inline int bios_reset_detected(void) |
Eric Biederman | 0ac6b41 | 2003-09-02 17:16:48 +0000 | [diff] [blame] | 22 | { |
Stefan Reinauer | f8b1923 | 2010-04-07 00:38:09 +0000 | [diff] [blame] | 23 | u32 htic; |
Eric Biederman | 0ac6b41 | 2003-09-02 17:16:48 +0000 | [diff] [blame] | 24 | htic = pci_read_config32(PCI_DEV(0, 0x18, 0), HT_INIT_CONTROL); |
| 25 | |
| 26 | return (htic & HTIC_ColdR_Detect) && !(htic & HTIC_BIOSR_Detect); |
| 27 | } |
| 28 | |
Stefan Reinauer | f8b1923 | 2010-04-07 00:38:09 +0000 | [diff] [blame] | 29 | static inline int cold_reset_detected(void) |
Eric Biederman | 0ac6b41 | 2003-09-02 17:16:48 +0000 | [diff] [blame] | 30 | { |
Stefan Reinauer | f8b1923 | 2010-04-07 00:38:09 +0000 | [diff] [blame] | 31 | u32 htic; |
Eric Biederman | 0ac6b41 | 2003-09-02 17:16:48 +0000 | [diff] [blame] | 32 | htic = pci_read_config32(PCI_DEV(0, 0x18, 0), HT_INIT_CONTROL); |
| 33 | |
| 34 | return !(htic & HTIC_ColdR_Detect); |
Eric Biederman | 9b4336c | 2003-07-19 04:28:22 +0000 | [diff] [blame] | 35 | } |
| 36 | |
Stefan Reinauer | f8b1923 | 2010-04-07 00:38:09 +0000 | [diff] [blame] | 37 | static inline void distinguish_cpu_resets(unsigned nodeid) |
Eric Biederman | 9b4336c | 2003-07-19 04:28:22 +0000 | [diff] [blame] | 38 | { |
Stefan Reinauer | f8b1923 | 2010-04-07 00:38:09 +0000 | [diff] [blame] | 39 | u32 htic; |
Edward O'Callaghan | 3ec9c95 | 2014-10-26 10:36:02 +1100 | [diff] [blame] | 40 | pci_devfn_t device; |
Yinghai Lu | 23202a9 | 2005-01-05 20:29:05 +0000 | [diff] [blame] | 41 | device = PCI_DEV(0, 0x18 + nodeid, 0); |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 42 | htic = pci_read_config32(device, HT_INIT_CONTROL); |
Eric Biederman | 9b4336c | 2003-07-19 04:28:22 +0000 | [diff] [blame] | 43 | htic |= HTIC_ColdR_Detect | HTIC_BIOSR_Detect | HTIC_INIT_Detect; |
Eric Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 44 | pci_write_config32(device, HT_INIT_CONTROL, htic); |
Eric Biederman | 9b4336c | 2003-07-19 04:28:22 +0000 | [diff] [blame] | 45 | } |
Eric Biederman | 0ac6b41 | 2003-09-02 17:16:48 +0000 | [diff] [blame] | 46 | |
Vladimir Serbinenko | bf8722a | 2014-11-09 13:17:39 +0100 | [diff] [blame] | 47 | void set_bios_reset(void); |
| 48 | void set_bios_reset(void) |
Eric Biederman | 0ac6b41 | 2003-09-02 17:16:48 +0000 | [diff] [blame] | 49 | { |
Stefan Reinauer | f8b1923 | 2010-04-07 00:38:09 +0000 | [diff] [blame] | 50 | u32 htic; |
Eric Biederman | 0ac6b41 | 2003-09-02 17:16:48 +0000 | [diff] [blame] | 51 | htic = pci_read_config32(PCI_DEV(0, 0x18, 0), HT_INIT_CONTROL); |
| 52 | htic &= ~HTIC_BIOSR_Detect; |
| 53 | pci_write_config32(PCI_DEV(0, 0x18, 0), HT_INIT_CONTROL, htic); |
| 54 | } |
Yinghai Lu | 9a791df | 2006-04-03 20:38:34 +0000 | [diff] [blame] | 55 | |
| 56 | static unsigned node_link_to_bus(unsigned node, unsigned link) |
| 57 | { |
Stefan Reinauer | f8b1923 | 2010-04-07 00:38:09 +0000 | [diff] [blame] | 58 | u8 reg; |
Yinghai Lu | 9a791df | 2006-04-03 20:38:34 +0000 | [diff] [blame] | 59 | |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 60 | for(reg = 0xE0; reg < 0xF0; reg += 0x04) { |
Stefan Reinauer | f8b1923 | 2010-04-07 00:38:09 +0000 | [diff] [blame] | 61 | u32 config_map; |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 62 | config_map = pci_read_config32(PCI_DEV(0, 0x18, 1), reg); |
| 63 | if ((config_map & 3) != 3) { |
| 64 | continue; |
| 65 | } |
| 66 | if ((((config_map >> 4) & 7) == node) && |
| 67 | (((config_map >> 8) & 3) == link)) |
| 68 | { |
| 69 | return (config_map >> 16) & 0xff; |
| 70 | } |
| 71 | } |
| 72 | return 0; |
Yinghai Lu | 9a791df | 2006-04-03 20:38:34 +0000 | [diff] [blame] | 73 | } |
| 74 | |
Stefan Reinauer | f8b1923 | 2010-04-07 00:38:09 +0000 | [diff] [blame] | 75 | static inline unsigned get_sblk(void) |
Yinghai Lu | 9a791df | 2006-04-03 20:38:34 +0000 | [diff] [blame] | 76 | { |
Stefan Reinauer | f8b1923 | 2010-04-07 00:38:09 +0000 | [diff] [blame] | 77 | u32 reg; |
Myles Watson | d61ada6 | 2008-10-02 19:20:22 +0000 | [diff] [blame] | 78 | /* read PCI_DEV(0,0x18,0) 0x64 bit [8:9] to find out SbLink m */ |
| 79 | reg = pci_read_config32(PCI_DEV(0, 0x18, 0), 0x64); |
| 80 | return ((reg>>8) & 3) ; |
Yinghai Lu | 9a791df | 2006-04-03 20:38:34 +0000 | [diff] [blame] | 81 | } |
| 82 | |
Stefan Reinauer | f8b1923 | 2010-04-07 00:38:09 +0000 | [diff] [blame] | 83 | static inline unsigned get_sbbusn(unsigned sblk) |
Yinghai Lu | 9a791df | 2006-04-03 20:38:34 +0000 | [diff] [blame] | 84 | { |
| 85 | return node_link_to_bus(0, sblk); |
| 86 | } |