Attached patch fixes the LPC decode ranges of SB600/SB800. We enable early only Seria...
authorRudolf Marek <r.marek@assembler.cz>
Sat, 12 Feb 2011 16:24:48 +0000 (16:24 +0000)
committerRudolf Marek <r.marek@assembler.cz>
Sat, 12 Feb 2011 16:24:48 +0000 (16:24 +0000)
Everything else needs to be done by lpc.c Problem was that early settings survived, because the lpc.c is doing ORs only...
Hence we decode quite a lot and even strange ranges like IO port 0x4600 etc...

Also, if some port which does not fit to predefined set is requested, like 0x290 for Hardware monitor, the wide port is done, but in our case it has range 512 bytes which means we decode in fact 0x290 - 0x490. And if we hit GPU in the 0x3bx range I receive MCE exception if I do isadump -f 0x300 which is bad.
Therefore If I detect that the requested range is small (16 bytes) I additionally set the small wide io region so only 16 bytes is decoded.

While at it, I fix spelling typos and I init the regs so we don't write random garbage to regs even if we don't enable them later.

Signed-off-by: Rudolf Marek <r.marek@assembler.cz>
Acked-by: Marc Jones <marcj303@gmail.com>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@6343 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

src/southbridge/amd/sb600/early_setup.c
src/southbridge/amd/sb600/lpc.c
src/southbridge/amd/sb800/early_setup.c
src/southbridge/amd/sb800/lpc.c

index 45b29c1d58204f2871d25b624cbb4e9838befa82..838ea319f6d046d904c465419e14a63e1bfef5df 100644 (file)
@@ -364,26 +364,8 @@ static void sb600_devices_por_init(void)
        dev = pci_locate_device(PCI_ID(0x1002, 0x438D), 0);
        /* DMA enable */
        pci_write_config8(dev, 0x40, 0x04);
-
-       /* IO Port Decode Enable */
-       pci_write_config8(dev, 0x44, 0xFF);
-       pci_write_config8(dev, 0x45, 0xFF);
-       pci_write_config8(dev, 0x46, 0xC3);
-       pci_write_config8(dev, 0x47, 0xFF);
-
-       // TODO: This has already been done(?)
-       /* IO/Mem Port Decode Enable, I don't know why CIM disable some ports.
-        *  Disable LPC TimeOut counter, enable SuperIO Configuration Port (2e/2f),
-        * Alternate SuperIO Configuration Port (4e/4f), Wide Generic IO Port (64/65). */
-       byte = pci_read_config8(dev, 0x48);
-       byte |= (1 << 1) | (1 << 0);    /* enable Super IO config port 2e-2h, 4e-4f */
-       byte |= 1 << 6;         /* enable for RTC I/O range */
-       pci_write_config8(dev, 0x48, byte);
+       /* LPC Sync Timeout */
        pci_write_config8(dev, 0x49, 0xFF);
-       /* Enable 0x480-0x4bf, 0x4700-0x470B */
-       byte = pci_read_config8(dev, 0x4A);
-       byte |= ((1 << 1) + (1 << 6));  /*0x42, save the configuraion for port 0x80. */
-       pci_write_config8(dev, 0x4A, byte);
 
        /* Enable Tpm12_en and Tpm_legacy. I don't know what is its usage and copied from CIM. */
        pci_write_config8(dev, 0x7C, 0x05);
index 6a17f72318cef9d38987aef94440498e75e5a8f5..6f16ea81c70b9625ff24a802dfb8e6883271a8bd 100644 (file)
@@ -103,7 +103,8 @@ static void sb600_lpc_enable_childrens_resources(device_t dev)
        struct bus *link;
        u32 reg, reg_x;
        int var_num = 0;
-       u16 reg_var[3];
+       u16 reg_var[3] = {0x0, 0x0, 0x0};
+       u8 wiosize = pci_read_config8(dev, 0x74);
 
        reg = pci_read_config32(dev, 0x44);
        reg_x = pci_read_config32(dev, 0x48);
@@ -134,13 +135,14 @@ static void sb600_lpc_enable_childrens_resources(device_t dev)
                                        case 0x2f8:     /*  COM2 */
                                                reg |= (1 << 7);
                                                break;
-                                       case 0x378:     /*  Parallal 1 */
+                                       case 0x378:     /*  Parallel 1 */
                                                reg |= (1 << 0);
+                                               reg |= (1 << 1); /* + 0x778 for ECP */
                                                break;
                                        case 0x3f0:     /*  FD0 */
                                                reg |= (1 << 26);
                                                break;
-                                       case 0x220:     /*  Aduio 0 */
+                                       case 0x220:     /*  Audio 0 */
                                                reg |= (1 << 8);
                                                break;
                                        case 0x300:     /*  Midi 0 */
@@ -170,12 +172,19 @@ static void sb600_lpc_enable_childrens_resources(device_t dev)
                                                switch (var_num) {
                                                case 0:
                                                        reg_x |= (1 << 2);
+                                                       if ((end - base) < 16)
+                                                               wiosize |= (1 << 0);
                                                        break;
                                                case 1:
                                                        reg_x |= (1 << 24);
+                                                       if ((end - base) < 16)
+                                                               wiosize |= (1 << 2);
                                                        break;
                                                case 2:
                                                        reg_x |= (1 << 25);
+                                                       reg_x |= (1 << 24);
+                                                       if ((end - base) < 16)
+                                                               wiosize |= (1 << 3);
                                                        break;
                                                }
                                                reg_var[var_num++] =
@@ -197,6 +206,7 @@ static void sb600_lpc_enable_childrens_resources(device_t dev)
                pci_write_config16(dev, 0x64, reg_var[0]);
                break;
        }
+       pci_write_config8(dev, 0x74, wiosize);
 }
 
 static void sb600_lpc_enable_resources(device_t dev)
index 6a7ea6c9eb9c391d47f958428bbb018a8c87b5f6..50f4ff70cda0f5b41746ea227adef8c41a246997 100644 (file)
@@ -450,26 +450,8 @@ static void sb800_devices_por_init(void)
        /* DMA enable */
        pci_write_config8(dev, 0x40, 0x04);
 
-       /* IO Port Decode Enable */
-       pci_write_config8(dev, 0x44, 0xFF);
-       pci_write_config8(dev, 0x45, 0xFF);
-       pci_write_config8(dev, 0x46, 0xC3);
-       pci_write_config8(dev, 0x47, 0xFF);
-
-       /* IO/Mem Port Decode Enable, I don't know why CIM disable some ports.
-        *  Disable LPC TimeOut counter, enable SuperIO Configuration Port (2e/2f),
-        * Alternate SuperIO Configuration Port (4e/4f), Wide Generic IO Port (64/65).
-        * Enable bits for LPC ROM memory address range 1&2 for 1M ROM setting.*/
-       byte = pci_read_config8(dev, 0x48);
-       byte |= (1 << 1) | (1 << 0);    /* enable Super IO config port 2e-2h, 4e-4f */
-       byte |= (1 << 3) | (1 << 4);    /* enable for LPC ROM address range1&2, Enable 512KB rom access at 0xFFF80000 - 0xFFFFFFFF */
-       byte |= 1 << 6;         /* enable for RTC I/O range */
-       pci_write_config8(dev, 0x48, byte);
+       /* LPC Sync Timeout */
        pci_write_config8(dev, 0x49, 0xFF);
-       /* Enable 0x480-0x4bf, 0x4700-0x470B */
-       byte = pci_read_config8(dev, 0x4A);
-       byte |= ((1 << 1) + (1 << 6));  /*0x42, save the configuraion for port 0x80. */
-       pci_write_config8(dev, 0x4A, byte);
 
        /* Set LPC ROM size, it has been done in sb800_lpc_init().
         * enable LPC ROM range, 0xfff8: 512KB, 0xfff0: 1MB;
index 50ff4d4cec5fb8597df98952d168270e277e18de..6b72a6232795aa452e75b5ff3eb9c2b14ebb1bc9 100644 (file)
@@ -122,7 +122,8 @@ static void sb800_lpc_enable_childrens_resources(device_t dev)
        struct bus *link;
        u32 reg, reg_x;
        int var_num = 0;
-       u16 reg_var[3];
+       u16 reg_var[3] = {0x0, 0x0, 0x0};
+       u8 wiosize = pci_read_config8(dev, 0x74);
 
        reg = pci_read_config32(dev, 0x44);
        reg_x = pci_read_config32(dev, 0x48);
@@ -153,13 +154,14 @@ static void sb800_lpc_enable_childrens_resources(device_t dev)
                                        case 0x2f8:     /*  COM2 */
                                                reg |= (1 << 7);
                                                break;
-                                       case 0x378:     /*  Parallal 1 */
+                                       case 0x378:     /*  Parallel 1 */
                                                reg |= (1 << 0);
+                                               reg |= (1 << 1); /* + 0x778 for ECP */
                                                break;
                                        case 0x3f0:     /*  FD0 */
                                                reg |= (1 << 26);
                                                break;
-                                       case 0x220:     /*  Aduio 0 */
+                                       case 0x220:     /*  Audio 0 */
                                                reg |= (1 << 8);
                                                break;
                                        case 0x300:     /*  Midi 0 */
@@ -189,12 +191,19 @@ static void sb800_lpc_enable_childrens_resources(device_t dev)
                                                switch (var_num) {
                                                case 0:
                                                        reg_x |= (1 << 2);
+                                                       if ((end - base) < 16)
+                                                               wiosize |= (1 << 0);
                                                        break;
                                                case 1:
                                                        reg_x |= (1 << 24);
+                                                       if ((end - base) < 16)
+                                                               wiosize |= (1 << 2);
                                                        break;
                                                case 2:
                                                        reg_x |= (1 << 25);
+                                                       reg_x |= (1 << 24);
+                                                       if ((end - base) < 16)
+                                                               wiosize |= (1 << 3);
                                                        break;
                                                }
                                                reg_var[var_num++] =
@@ -216,6 +225,7 @@ static void sb800_lpc_enable_childrens_resources(device_t dev)
                pci_write_config16(dev, 0x64, reg_var[0]);
                break;
        }
+       pci_write_config8(dev, 0x74, wiosize);
 }
 
 static void sb800_lpc_enable_resources(device_t dev)