Richard Smith | cb8eab4 | 2006-07-24 04:25:47 +0000 | [diff] [blame] | 1 | #include "i440bx_smbus.h" |
| 2 | |
| 3 | #define SMBUS_IO_BASE 0x0f00 |
| 4 | |
| 5 | static void enable_smbus(void) |
| 6 | { |
| 7 | device_t dev; |
| 8 | dev = pci_locate_device(PCI_ID(0x8086, 0x7113), 0); |
| 9 | if (dev == PCI_DEV_INVALID) { |
| 10 | die("SMBUS controller not found\r\n"); |
| 11 | } |
| 12 | uint8_t enable; |
| 13 | print_spew("SMBus controller enabled\r\n"); |
Richard Smith | d7088c4 | 2006-07-30 00:23:20 +0000 | [diff] [blame^] | 14 | pci_write_config32(dev, 0x90, SMBUS_IO_BASE | 1 ); |
Richard Smith | cb8eab4 | 2006-07-24 04:25:47 +0000 | [diff] [blame] | 15 | // Enable and set SMBBus |
| 16 | // 0x01 Interrupt to SMI# |
| 17 | // (0x4<<1)|1 set interrupt to IRQ9 |
| 18 | pci_write_config8(dev, 0xd2, (0x4<<1)|1); |
| 19 | |
| 20 | // Enable the IO space |
| 21 | pci_write_config16(dev, 0x04, 1); |
| 22 | |
| 23 | /* clear any lingering errors, so the transaction will run */ |
Richard Smith | d7088c4 | 2006-07-30 00:23:20 +0000 | [diff] [blame^] | 24 | outb(0x1e, SMBUS_IO_BASE + SMBHST_STATUS); |
| 25 | } |
| 26 | |
| 27 | |
| 28 | |
| 29 | static int smbus_read_byte(unsigned device, unsigned address) |
| 30 | { |
| 31 | return do_smbus_read_byte(SMBUS_IO_BASE, device, address); |
| 32 | } |
| 33 | |
| 34 | |
| 35 | // The following functions are broken. Do no use until you |
| 36 | // have fixed the low level code to do the right thing. |
| 37 | // |
| 38 | #if 0 |
| 39 | static int smbus_write_byte(unsigned device, unsigned address, unsigned char val) |
| 40 | { |
| 41 | return do_smbus_write_byte(SMBUS_IO_BASE, device, address, val); |
Richard Smith | cb8eab4 | 2006-07-24 04:25:47 +0000 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | static int smbus_recv_byte(unsigned device) |
| 45 | { |
| 46 | return do_smbus_recv_byte(SMBUS_IO_BASE, device); |
| 47 | } |
| 48 | |
| 49 | static int smbus_send_byte(unsigned device, unsigned char val) |
| 50 | { |
| 51 | return do_smbus_send_byte(SMBUS_IO_BASE, device, val); |
| 52 | } |
Richard Smith | d7088c4 | 2006-07-30 00:23:20 +0000 | [diff] [blame^] | 53 | #endif |