3 * cs5535_early_setup.c: Early chipset initialization for CS5535 companion device
6 * This file implements the initialization sequence documented in section 4.2 of
7 * AMD Geode GX Processor CS5535 Companion Device GoedeROM Porting Guide.
11 #define CS5535_GLINK_PORT_NUM 0x02 /* the geode link port number to the CS5535 */
12 #define CS5535_DEV_NUM 0x0F /* default PCI device number for CS5535 */
15 * @brief Setup PCI IDSEL for CS5535
20 static void cs5535_setup_extmsr(void)
24 /* forward MSR access to CS5535_GLINK_PORT_NUM to CS5535_DEV_NUM */
25 msr.hi = msr.lo = 0x00000000;
26 if (CS5535_GLINK_PORT_NUM <= 4) {
27 msr.lo = CS5535_DEV_NUM << ((CS5535_GLINK_PORT_NUM - 1) * 8);
29 msr.hi = CS5535_DEV_NUM << ((CS5535_GLINK_PORT_NUM - 5) * 8);
31 wrmsr(0x5000201e, msr);
34 static void cs5535_setup_idsel(void)
36 /* write IDSEL to the write once register at address 0x0000 */
37 outl(0x1 << (CS5535_DEV_NUM + 10), 0);
40 static int cs5535_setup_iobase(void)
44 /* setup LBAR for SMBus controller */
45 __builtin_wrmsr(0x5140000b, 0x00006000, 0x0000f001);
46 /* setup LBAR for GPIO */
47 __builtin_wrmsr(0x5140000c, 0x00006100, 0x0000f001);
48 /* setup LBAR for MFGPT */
49 __builtin_wrmsr(0x5140000d, 0x00006200, 0x0000f001);
50 /* setup LBAR for ACPI */
51 __builtin_wrmsr(0x5140000e, 0x00009c00, 0x0000f001);
52 /* setup LBAR for MFGPT */
53 __builtin_wrmsr(0x5140000f, 0x00009d00, 0x0000f001);
56 static void cs5535_setup_gpio(void)
60 /* setup GPIO pins 14/15 for SDA/SCL */
61 val = (1<<14 | 1<<15);
63 outl(0x3fffc000, 0x6100 + 0x04);
64 //outl(val, 0x6100 + 0x04);
66 outl(0x3fffc000, 0x6100 + 0x10);
67 //outl(val, 0x6100 + 0x10);
69 //outl(0x0f5af0a5, 0x6100 + 0x20);
70 outl(0x3fffc000, 0x6100 + 0x20);
71 //outl(val, 0x6100 + 0x20);
73 //outl(0x3ffbc004, 0x6100 + 0x34);
74 outl(0x3fffc000, 0x6100 + 0x34);
75 //outl(val, 0x6100 + 0x34);
78 static void cs5535_setup_cis_mode(void)
82 /* setup CPU interface serial to mode C on both sides */
83 msr = __builtin_rdmsr(0x51000010);
86 __builtin_wrmsr(0x51000010, msr.lo, msr.hi);
87 __builtin_wrmsr(0x54002010, 0x00000002, 0x00000000);
90 static void dummy(void)
94 static int cs5535_early_setup(void)
98 cs5535_setup_extmsr();
100 msr = rdmsr(0x4c000014);
101 if (msr.lo & (0x3f << 26)) {
102 /* PLL is already set and we are reboot from PLL reset */
103 print_debug("reboot from BIOS reset\n\r");
106 print_debug("Setup idsel\r\n");
107 cs5535_setup_idsel();
108 print_debug("Setup iobase\r\n");
109 cs5535_setup_iobase();
110 print_debug("Setup gpio\r\n");
112 print_debug("Setup cis_mode\r\n");
113 cs5535_setup_cis_mode();
114 print_debug("Setup smbus\r\n");
115 cs5535_enable_smbus();