coreboot/src/mainboard/intel/eagleheights/debug.c
<<
>>
Prefs
   1/*
   2 * This file is part of the coreboot project.
   3 *
   4 * Copyright (C) 2007-2008 coresystems GmbH
   5 * Copyright (C) 2009 Thomas Jourdan <thomas.jourdan@gmail.com>
   6 *
   7 * This program is free software; you can redistribute it and/or
   8 * modify it under the terms of the GNU General Public License as
   9 * published by the Free Software Foundation; version 2 of
  10 * the License.
  11 *
  12 * This program is distributed in the hope that it will be useful,
  13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15 * GNU General Public License for more details.
  16 *
  17 * You should have received a copy of the GNU General Public License
  18 * along with this program; if not, write to the Free Software
  19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
  20 * MA 02110-1301 USA
  21 */
  22
  23#include <spd.h>
  24
  25static void print_reg(unsigned char index)
  26{
  27        unsigned char data;
  28
  29        outb(index, 0x2e);
  30        data = inb(0x2f);
  31        print_debug("0x");
  32        print_debug_hex8(index);
  33        print_debug(": 0x");
  34        print_debug_hex8(data);
  35        print_debug("\n");
  36        return;
  37}
  38
  39static inline void xbus_en(void)
  40{
  41        /* select the XBUS function in the SIO */
  42        outb(0x07, 0x2e);
  43        outb(0x0f, 0x2f);
  44        outb(0x30, 0x2e);
  45        outb(0x01, 0x2f);
  46        return;
  47}
  48
  49static void setup_func(unsigned char func)
  50{
  51        /* select the function in the SIO */
  52        outb(0x07, 0x2e);
  53        outb(func, 0x2f);
  54        /* print out the regs */
  55        print_reg(0x30);
  56        print_reg(0x60);
  57        print_reg(0x61);
  58        print_reg(0x62);
  59        print_reg(0x63);
  60        print_reg(0x70);
  61        print_reg(0x71);
  62        print_reg(0x74);
  63        print_reg(0x75);
  64        return;
  65}
  66
  67static inline void siodump(void)
  68{
  69        int i;
  70        unsigned char data;
  71
  72         print_debug("\n*** SERVER I/O REGISTERS ***\n");
  73        for (i=0x10; i<=0x2d; i++) {
  74                print_reg((unsigned char)i);
  75        }
  76#if 0
  77        print_debug("\n*** XBUS REGISTERS ***\n");
  78        setup_func(0x0f);
  79        for (i=0xf0; i<=0xff; i++) {
  80                print_reg((unsigned char)i);
  81        }
  82
  83        print_debug("\n***  SERIAL 1 CONFIG REGISTERS ***\n");
  84        setup_func(0x03);
  85        print_reg(0xf0);
  86
  87        print_debug("\n***  SERIAL 2 CONFIG REGISTERS ***\n");
  88        setup_func(0x02);
  89        print_reg(0xf0);
  90
  91#endif
  92        print_debug("\n***  GPIO REGISTERS ***\n");
  93        setup_func(0x07);
  94        for (i=0xf0; i<=0xf8; i++) {
  95                print_reg((unsigned char)i);
  96        }
  97        print_debug("\n***  GPIO VALUES ***\n");
  98        data = inb(0x68a);
  99        print_debug("\nGPDO 4: 0x");
 100        print_debug_hex8(data);
 101        data = inb(0x68b);
 102        print_debug("\nGPDI 4: 0x");
 103        print_debug_hex8(data);
 104        print_debug("\n");
 105
 106#if 0
 107
 108        print_debug("\n***  WATCHDOG TIMER REGISTERS ***\n");
 109        setup_func(0x0a);
 110        print_reg(0xf0);
 111
 112        print_debug("\n***  FAN CONTROL REGISTERS ***\n");
 113        setup_func(0x09);
 114        print_reg(0xf0);
 115        print_reg(0xf1);
 116
 117        print_debug("\n***  RTC REGISTERS ***\n");
 118        setup_func(0x10);
 119        print_reg(0xf0);
 120        print_reg(0xf1);
 121        print_reg(0xf3);
 122        print_reg(0xf6);
 123        print_reg(0xf7);
 124        print_reg(0xfe);
 125        print_reg(0xff);
 126
 127        print_debug("\n***  HEALTH MONITORING & CONTROL REGISTERS ***\n");
 128        setup_func(0x14);
 129        print_reg(0xf0);
 130#endif
 131        return;
 132}
 133
 134static void print_debug_pci_dev(unsigned dev)
 135{
 136        print_debug("PCI: ");
 137        print_debug_hex8((dev >> 16) & 0xff);
 138        print_debug_char(':');
 139        print_debug_hex8((dev >> 11) & 0x1f);
 140        print_debug_char('.');
 141        print_debug_hex8((dev >> 8) & 7);
 142}
 143
 144static inline void print_pci_devices(void)
 145{
 146        device_t dev;
 147        for(dev = PCI_DEV(0, 0, 0);
 148                dev <= PCI_DEV(0, 0x1f, 0x7);
 149                dev += PCI_DEV(0,0,1)) {
 150                uint32_t id;
 151                id = pci_read_config32(dev, PCI_VENDOR_ID);
 152                if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
 153                        (((id >> 16) & 0xffff) == 0xffff) ||
 154                        (((id >> 16) & 0xffff) == 0x0000)) {
 155                        continue;
 156                }
 157                print_debug_pci_dev(dev);
 158                print_debug("\n");
 159        }
 160}
 161
 162static inline void dump_pci_device(unsigned dev)
 163{
 164        int i;
 165        print_debug_pci_dev(dev);
 166        print_debug("\n");
 167
 168        for(i = 0; i <= 255; i++) {
 169                unsigned char val;
 170                if ((i & 0x0f) == 0) {
 171                        print_debug_hex8(i);
 172                        print_debug_char(':');
 173                }
 174                val = pci_read_config8(dev, i);
 175                print_debug_char(' ');
 176                print_debug_hex8(val);
 177                if ((i & 0x0f) == 0x0f) {
 178                        print_debug("\n");
 179                }
 180        }
 181}
 182
 183static inline void dump_bar14(unsigned dev)
 184{
 185        int i;
 186        unsigned long bar;
 187
 188        print_debug("BAR 14 Dump\n");
 189
 190        bar = pci_read_config32(dev, 0x14);
 191        for(i = 0; i <= 0x300; i+=4) {
 192#if 0
 193                unsigned char val;
 194                if ((i & 0x0f) == 0) {
 195                        print_debug_hex8(i);
 196                        print_debug_char(':');
 197                }
 198                val = pci_read_config8(dev, i);
 199#endif
 200                if((i%4)==0) {
 201                print_debug("\n");
 202                print_debug_hex16(i);
 203                print_debug_char(' ');
 204                }
 205                print_debug_hex32(read32(bar + i));
 206                print_debug_char(' ');
 207        }
 208        print_debug("\n");
 209}
 210
 211static inline void dump_pci_devices(void)
 212{
 213        device_t dev;
 214        for(dev = PCI_DEV(0, 0, 0);
 215                dev <= PCI_DEV(0, 0x1f, 0x7);
 216                dev += PCI_DEV(0,0,1)) {
 217                uint32_t id;
 218                id = pci_read_config32(dev, PCI_VENDOR_ID);
 219                if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
 220                        (((id >> 16) & 0xffff) == 0xffff) ||
 221                        (((id >> 16) & 0xffff) == 0x0000)) {
 222                        continue;
 223                }
 224                dump_pci_device(dev);
 225        }
 226}
 227
 228static inline void dump_spd_registers(void)
 229{
 230        unsigned device;
 231        device = DIMM0;
 232        while(device <= DIMM7) {
 233                int status = 0;
 234                int i;
 235                print_debug("\n");
 236                print_debug("dimm ");
 237                print_debug_hex8(device);
 238
 239                for(i = 0; (i < 256) ; i++) {
 240                        if ((i % 16) == 0) {
 241                                print_debug("\n");
 242                                print_debug_hex8(i);
 243                                print_debug(": ");
 244                        }
 245                        status = smbus_read_byte(device, i);
 246                        if (status < 0) {
 247                                 print_debug("bad device: ");
 248                                 print_debug_hex8(-status);
 249                                 print_debug("\n");
 250                                 break;
 251                        }
 252                        print_debug_hex8(status);
 253                        print_debug_char(' ');
 254                }
 255                device++;
 256                print_debug("\n");
 257        }
 258}
 259
 260static inline void dump_ipmi_registers(void)
 261{
 262        unsigned device;
 263        device = 0x42;
 264        while(device <= 0x42) {
 265                int status = 0;
 266                int i;
 267                print_debug("\n");
 268                print_debug("ipmi ");
 269                print_debug_hex8(device);
 270
 271                for(i = 0; (i < 8) ; i++) {
 272                        status = smbus_read_byte(device, 2);
 273                        if (status < 0) {
 274                                 print_debug("bad device: ");
 275                                 print_debug_hex8(-status);
 276                                 print_debug("\n");
 277                                 break;
 278                        }
 279                        print_debug_hex8(status);
 280                        print_debug_char(' ');
 281                }
 282                device++;
 283                print_debug("\n");
 284        }
 285}
 286
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.