1 #include <console/console.h>
2 #include <device/device.h>
3 #include <device/smbus.h>
4 #include <device/pci.h>
5 #include <device/pci_ids.h>
6 #include <device/pci_ops.h>
7 #include <part/hard_reset.h>
8 #include <cpu/x86/msr.h>
11 #define ADM1027_REG_CONFIG1 0x40
12 #define CFG1_STRT 0x01
13 #define CFG1_LOCK 0x02
15 #define CFG1_FSPD 0x08
17 #define CFT1_FSPDIS 0x20
18 #define CFG1_TODIS 0x40
20 #define ADM1027_REG_CONFIG2 0x73
21 #define ADM1027_REG_CONFIG3 0x78
23 static void adm1027_enable_monitoring(device_t dev)
26 result = smbus_read_byte(dev, ADM1027_REG_CONFIG1);
28 if(!(result & CFG1_RDY) ) {
29 printk_debug("ADM1027: monitoring not ready\r\n");
32 result = (result | CFG1_STRT);
33 result = smbus_write_byte(dev, ADM1027_REG_CONFIG1, result);
35 result = smbus_read_byte(dev, ADM1027_REG_CONFIG1);
36 if (!(result & CFG1_STRT)) {
37 printk_debug("ADM1027: monitoring would not enable\r\n");
41 static void adm1027_init(device_t dev)
43 if (dev->enabled && dev->path.type == DEVICE_PATH_I2C)
45 if(ops_smbus_bus(get_pbus_smbus(dev))) {
46 if( dev->bus->dev->path.type == DEVICE_PATH_I2C) smbus_set_link(dev); // it is under mux
47 adm1027_enable_monitoring(dev);
53 static void adm1027_noop(device_t dummy)
57 static struct device_operations adm1027_operations = {
58 .read_resources = adm1027_noop,
59 .set_resources = adm1027_noop,
60 .enable_resources = adm1027_noop,
64 static void enable_dev(struct device *dev)
66 dev->ops = &adm1027_operations;
69 struct chip_operations drivers_i2c_adm1027_ops = {
71 .enable_dev = enable_dev,