blob: a3db7b88c0fd03dc31a242a60df1ce10dcf345cc [file] [log] [blame]
Richard Smithcb8eab42006-07-24 04:25:47 +00001#include "i440bx_smbus.h"
2
3#define SMBUS_IO_BASE 0x0f00
4
5static 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");
14 pci_write_config32(dev, 0x90, SMBUS_IO_BASE );
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 */
24 outb(0x1e, SMBUS_IO_BASE + SMBGSTATUS);
25}
26
27static int smbus_recv_byte(unsigned device)
28{
29 return do_smbus_recv_byte(SMBUS_IO_BASE, device);
30}
31
32static int smbus_send_byte(unsigned device, unsigned char val)
33{
34 return do_smbus_send_byte(SMBUS_IO_BASE, device, val);
35}
36
37static int smbus_read_byte(unsigned device, unsigned address)
38{
39 return do_smbus_read_byte(SMBUS_IO_BASE, device, address);
40}
41
42static int smbus_write_byte(unsigned device, unsigned address, unsigned char val)
43{
44 return do_smbus_write_byte(SMBUS_IO_BASE, device, address, val);
45}