Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * cs5535_early_setup.c: Early chipset initialization for CS5535 companion device |
| 4 | * |
| 5 | * |
| 6 | * This file implements the initialization sequence documented in section 4.2 of |
| 7 | * AMD Geode GX Processor CS5535 Companion Device GoedeROM Porting Guide. |
| 8 | * |
| 9 | */ |
| 10 | |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 11 | /** |
| 12 | * @brief Setup PCI IDSEL for CS5535 |
| 13 | * |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 14 | * |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | static void cs5535_setup_extmsr(void) |
| 18 | { |
| 19 | msr_t msr; |
| 20 | |
| 21 | /* forward MSR access to CS5535_GLINK_PORT_NUM to CS5535_DEV_NUM */ |
| 22 | msr.hi = msr.lo = 0x00000000; |
Stefan Reinauer | 4154c66 | 2010-04-14 10:12:23 +0000 | [diff] [blame] | 23 | #if CS5535_GLINK_PORT_NUM <= 4 |
| 24 | msr.lo = CS5535_DEV_NUM << ((CS5535_GLINK_PORT_NUM - 1) * 8); |
| 25 | #else |
| 26 | msr.hi = CS5535_DEV_NUM << ((CS5535_GLINK_PORT_NUM - 5) * 8); |
| 27 | #endif |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 28 | wrmsr(0x5000201e, msr); |
| 29 | } |
| 30 | |
| 31 | static void cs5535_setup_idsel(void) |
| 32 | { |
| 33 | /* write IDSEL to the write once register at address 0x0000 */ |
| 34 | outl(0x1 << (CS5535_DEV_NUM + 10), 0); |
| 35 | } |
| 36 | |
Li-Ta Lo | d8d8fff | 2006-04-13 17:00:38 +0000 | [diff] [blame] | 37 | static void cs5535_usb_swapsif(void) |
| 38 | { |
| 39 | msr_t msr; |
| 40 | |
| 41 | msr = rdmsr(0x51600005); |
| 42 | //USB Serial short detect bit. |
| 43 | if (msr.hi & 0x10) { |
| 44 | /* We need to preserve bits 32,33,35 and not clear any BIST error, but clear the |
| 45 | * SERSHRT error bit */ |
| 46 | msr.hi &= 0xFFFFFFFB; |
| 47 | wrmsr(0x51600005, msr); |
| 48 | } |
| 49 | } |
| 50 | |
Nils Jacobs | e474070 | 2010-07-26 23:46:25 +0000 | [diff] [blame] | 51 | static void cs5535_setup_iobase(void) |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 52 | { |
| 53 | msr_t msr; |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 54 | /* setup LBAR for SMBus controller */ |
Nils Jacobs | e474070 | 2010-07-26 23:46:25 +0000 | [diff] [blame] | 55 | msr.hi = 0x0000f001; |
| 56 | msr.lo = SMBUS_IO_BASE; |
| 57 | wrmsr(MDD_LBAR_SMB, msr); |
| 58 | |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 59 | /* setup LBAR for GPIO */ |
Nils Jacobs | e474070 | 2010-07-26 23:46:25 +0000 | [diff] [blame] | 60 | msr.hi = 0x0000f001; |
| 61 | msr.lo = GPIO_IO_BASE; |
| 62 | wrmsr(MDD_LBAR_GPIO, msr); |
| 63 | |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 64 | /* setup LBAR for MFGPT */ |
Nils Jacobs | e474070 | 2010-07-26 23:46:25 +0000 | [diff] [blame] | 65 | msr.hi = 0x0000f001; |
| 66 | msr.lo = MFGPT_IO_BASE; |
| 67 | wrmsr(MDD_LBAR_MFGPT, msr); |
| 68 | |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 69 | /* setup LBAR for ACPI */ |
Nils Jacobs | e474070 | 2010-07-26 23:46:25 +0000 | [diff] [blame] | 70 | msr.hi = 0x0000f001; |
| 71 | msr.lo = ACPI_IO_BASE; |
| 72 | wrmsr(MDD_LBAR_ACPI, msr); |
| 73 | |
Li-Ta Lo | d8d8fff | 2006-04-13 17:00:38 +0000 | [diff] [blame] | 74 | /* setup LBAR for PM Support */ |
Nils Jacobs | e474070 | 2010-07-26 23:46:25 +0000 | [diff] [blame] | 75 | msr.hi = 0x0000f001; |
| 76 | msr.lo = PMS_IO_BASE; |
| 77 | wrmsr(MDD_LBAR_PMS, msr); |
Li-Ta Lo | d8d8fff | 2006-04-13 17:00:38 +0000 | [diff] [blame] | 78 | } |
| 79 | |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 80 | static void cs5535_setup_gpio(void) |
| 81 | { |
| 82 | uint32_t val; |
| 83 | |
| 84 | /* setup GPIO pins 14/15 for SDA/SCL */ |
| 85 | val = (1<<14 | 1<<15); |
| 86 | /* Output Enable */ |
| 87 | outl(0x3fffc000, 0x6100 + 0x04); |
| 88 | //outl(val, 0x6100 + 0x04); |
| 89 | /* Output AUX1 */ |
| 90 | outl(0x3fffc000, 0x6100 + 0x10); |
| 91 | //outl(val, 0x6100 + 0x10); |
| 92 | /* Input Enable */ |
| 93 | //outl(0x0f5af0a5, 0x6100 + 0x20); |
| 94 | outl(0x3fffc000, 0x6100 + 0x20); |
| 95 | //outl(val, 0x6100 + 0x20); |
| 96 | /* Input AUX1 */ |
| 97 | //outl(0x3ffbc004, 0x6100 + 0x34); |
| 98 | outl(0x3fffc000, 0x6100 + 0x34); |
| 99 | //outl(val, 0x6100 + 0x34); |
| 100 | } |
| 101 | |
Nils Jacobs | e474070 | 2010-07-26 23:46:25 +0000 | [diff] [blame] | 102 | void cs5535_disable_internal_uart(void) |
Li-Ta Lo | d8d8fff | 2006-04-13 17:00:38 +0000 | [diff] [blame] | 103 | { |
Li-Ta Lo | d8d8fff | 2006-04-13 17:00:38 +0000 | [diff] [blame] | 104 | } |
| 105 | |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 106 | static void cs5535_setup_cis_mode(void) |
| 107 | { |
| 108 | msr_t msr; |
| 109 | |
Nils Jacobs | 8098e42 | 2010-12-30 19:23:29 +0000 | [diff] [blame] | 110 | /* Setup CPU serial SouthBridge interface to mode C. */ |
Nils Jacobs | e474070 | 2010-07-26 23:46:25 +0000 | [diff] [blame] | 111 | msr = rdmsr(GLPCI_SB_CTRL); |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 112 | msr.lo &= ~0x18; |
| 113 | msr.lo |= 0x10; |
Nils Jacobs | e474070 | 2010-07-26 23:46:25 +0000 | [diff] [blame] | 114 | wrmsr(GLPCI_SB_CTRL, msr); |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | static void dummy(void) |
| 118 | { |
| 119 | } |
| 120 | |
Nils Jacobs | e474070 | 2010-07-26 23:46:25 +0000 | [diff] [blame] | 121 | static void cs5535_early_setup(void) |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 122 | { |
| 123 | msr_t msr; |
| 124 | |
| 125 | cs5535_setup_extmsr(); |
| 126 | |
Li-Ta Lo | 8854d30 | 2006-04-03 22:20:05 +0000 | [diff] [blame] | 127 | msr = rdmsr(GLCP_SYS_RSTPLL); |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 128 | if (msr.lo & (0x3f << 26)) { |
| 129 | /* PLL is already set and we are reboot from PLL reset */ |
Stefan Reinauer | 5ab52dd | 2015-01-05 13:01:01 -0800 | [diff] [blame] | 130 | printk(BIOS_DEBUG, "reboot from BIOS reset\n"); |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 131 | return; |
| 132 | } |
Stefan Reinauer | 5ab52dd | 2015-01-05 13:01:01 -0800 | [diff] [blame] | 133 | printk(BIOS_DEBUG, "Setup idsel\n"); |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 134 | cs5535_setup_idsel(); |
Stefan Reinauer | 5ab52dd | 2015-01-05 13:01:01 -0800 | [diff] [blame] | 135 | printk(BIOS_DEBUG, "Setup iobase\n"); |
Li-Ta Lo | d8d8fff | 2006-04-13 17:00:38 +0000 | [diff] [blame] | 136 | cs5535_usb_swapsif(); |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 137 | cs5535_setup_iobase(); |
Stefan Reinauer | 5ab52dd | 2015-01-05 13:01:01 -0800 | [diff] [blame] | 138 | printk(BIOS_DEBUG, "Setup gpio\n"); |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 139 | cs5535_setup_gpio(); |
Stefan Reinauer | 5ab52dd | 2015-01-05 13:01:01 -0800 | [diff] [blame] | 140 | printk(BIOS_DEBUG, "Setup cis_mode\n"); |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 141 | cs5535_setup_cis_mode(); |
Stefan Reinauer | 5ab52dd | 2015-01-05 13:01:01 -0800 | [diff] [blame] | 142 | printk(BIOS_DEBUG, "Setup smbus\n"); |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 143 | cs5535_enable_smbus(); |
Li-Ta Lo | a413ecc | 2006-03-13 22:18:39 +0000 | [diff] [blame] | 144 | dummy(); |
| 145 | } |