blob: 1030aa0e88e36b9e0c7f07bff4340366e4623f96 [file] [log] [blame]
Li-Ta Loa413ecc2006-03-13 22:18:39 +00001/*
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 Loa413ecc2006-03-13 22:18:39 +000011/**
12 * @brief Setup PCI IDSEL for CS5535
13 *
Stefan Reinauer14e22772010-04-27 06:56:47 +000014 *
Li-Ta Loa413ecc2006-03-13 22:18:39 +000015 */
16
17static 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 Reinauer4154c662010-04-14 10:12:23 +000023#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 Loa413ecc2006-03-13 22:18:39 +000028 wrmsr(0x5000201e, msr);
29}
30
31static 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 Lod8d8fff2006-04-13 17:00:38 +000037static 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 Jacobse4740702010-07-26 23:46:25 +000051static void cs5535_setup_iobase(void)
Li-Ta Loa413ecc2006-03-13 22:18:39 +000052{
53 msr_t msr;
Li-Ta Loa413ecc2006-03-13 22:18:39 +000054 /* setup LBAR for SMBus controller */
Nils Jacobse4740702010-07-26 23:46:25 +000055 msr.hi = 0x0000f001;
56 msr.lo = SMBUS_IO_BASE;
57 wrmsr(MDD_LBAR_SMB, msr);
58
Li-Ta Loa413ecc2006-03-13 22:18:39 +000059 /* setup LBAR for GPIO */
Nils Jacobse4740702010-07-26 23:46:25 +000060 msr.hi = 0x0000f001;
61 msr.lo = GPIO_IO_BASE;
62 wrmsr(MDD_LBAR_GPIO, msr);
63
Li-Ta Loa413ecc2006-03-13 22:18:39 +000064 /* setup LBAR for MFGPT */
Nils Jacobse4740702010-07-26 23:46:25 +000065 msr.hi = 0x0000f001;
66 msr.lo = MFGPT_IO_BASE;
67 wrmsr(MDD_LBAR_MFGPT, msr);
68
Li-Ta Loa413ecc2006-03-13 22:18:39 +000069 /* setup LBAR for ACPI */
Nils Jacobse4740702010-07-26 23:46:25 +000070 msr.hi = 0x0000f001;
71 msr.lo = ACPI_IO_BASE;
72 wrmsr(MDD_LBAR_ACPI, msr);
73
Li-Ta Lod8d8fff2006-04-13 17:00:38 +000074 /* setup LBAR for PM Support */
Nils Jacobse4740702010-07-26 23:46:25 +000075 msr.hi = 0x0000f001;
76 msr.lo = PMS_IO_BASE;
77 wrmsr(MDD_LBAR_PMS, msr);
Li-Ta Lod8d8fff2006-04-13 17:00:38 +000078}
79
Li-Ta Loa413ecc2006-03-13 22:18:39 +000080static 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 Jacobse4740702010-07-26 23:46:25 +0000102void cs5535_disable_internal_uart(void)
Li-Ta Lod8d8fff2006-04-13 17:00:38 +0000103{
Li-Ta Lod8d8fff2006-04-13 17:00:38 +0000104}
105
Li-Ta Loa413ecc2006-03-13 22:18:39 +0000106static void cs5535_setup_cis_mode(void)
107{
108 msr_t msr;
109
Nils Jacobs8098e422010-12-30 19:23:29 +0000110 /* Setup CPU serial SouthBridge interface to mode C. */
Nils Jacobse4740702010-07-26 23:46:25 +0000111 msr = rdmsr(GLPCI_SB_CTRL);
Li-Ta Loa413ecc2006-03-13 22:18:39 +0000112 msr.lo &= ~0x18;
113 msr.lo |= 0x10;
Nils Jacobse4740702010-07-26 23:46:25 +0000114 wrmsr(GLPCI_SB_CTRL, msr);
Li-Ta Loa413ecc2006-03-13 22:18:39 +0000115}
116
117static void dummy(void)
118{
119}
120
Nils Jacobse4740702010-07-26 23:46:25 +0000121static void cs5535_early_setup(void)
Li-Ta Loa413ecc2006-03-13 22:18:39 +0000122{
123 msr_t msr;
124
125 cs5535_setup_extmsr();
126
Li-Ta Lo8854d302006-04-03 22:20:05 +0000127 msr = rdmsr(GLCP_SYS_RSTPLL);
Li-Ta Loa413ecc2006-03-13 22:18:39 +0000128 if (msr.lo & (0x3f << 26)) {
129 /* PLL is already set and we are reboot from PLL reset */
Stefan Reinauer5ab52dd2015-01-05 13:01:01 -0800130 printk(BIOS_DEBUG, "reboot from BIOS reset\n");
Li-Ta Loa413ecc2006-03-13 22:18:39 +0000131 return;
132 }
Stefan Reinauer5ab52dd2015-01-05 13:01:01 -0800133 printk(BIOS_DEBUG, "Setup idsel\n");
Li-Ta Loa413ecc2006-03-13 22:18:39 +0000134 cs5535_setup_idsel();
Stefan Reinauer5ab52dd2015-01-05 13:01:01 -0800135 printk(BIOS_DEBUG, "Setup iobase\n");
Li-Ta Lod8d8fff2006-04-13 17:00:38 +0000136 cs5535_usb_swapsif();
Li-Ta Loa413ecc2006-03-13 22:18:39 +0000137 cs5535_setup_iobase();
Stefan Reinauer5ab52dd2015-01-05 13:01:01 -0800138 printk(BIOS_DEBUG, "Setup gpio\n");
Li-Ta Loa413ecc2006-03-13 22:18:39 +0000139 cs5535_setup_gpio();
Stefan Reinauer5ab52dd2015-01-05 13:01:01 -0800140 printk(BIOS_DEBUG, "Setup cis_mode\n");
Li-Ta Loa413ecc2006-03-13 22:18:39 +0000141 cs5535_setup_cis_mode();
Stefan Reinauer5ab52dd2015-01-05 13:01:01 -0800142 printk(BIOS_DEBUG, "Setup smbus\n");
Li-Ta Loa413ecc2006-03-13 22:18:39 +0000143 cs5535_enable_smbus();
Li-Ta Loa413ecc2006-03-13 22:18:39 +0000144 dummy();
145}