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)
27 result = smbus_read_byte(dev, ADM1027_REG_CONFIG1);
29 if (!(result & CFG1_RDY)) {
30 printk_debug("ADM1027: monitoring not ready\r\n");
33 result = (result | CFG1_STRT);
34 result = smbus_write_byte(dev, ADM1027_REG_CONFIG1, result);
36 result = smbus_read_byte(dev, ADM1027_REG_CONFIG1);
37 if (!(result & CFG1_STRT)) {
38 printk_debug("ADM1027: monitoring would not enable\r\n");
40 printk_debug("ADM1027: monitoring enabled\r\n");
43 static void adm1027_init(device_t dev)
45 if (dev->enabled && dev->path.type == DEVICE_PATH_I2C) {
46 if (ops_smbus_bus(get_pbus_smbus(dev))) {
47 if (dev->bus->dev->path.type == DEVICE_PATH_I2C)
48 smbus_set_link(dev); // it is under mux
49 adm1027_enable_monitoring(dev);
55 static void adm1027_noop(device_t dummy)
59 static struct device_operations adm1027_operations = {
60 .read_resources = adm1027_noop,
61 .set_resources = adm1027_noop,
62 .enable_resources = adm1027_noop,
66 static void enable_dev(struct device *dev)
68 dev->ops = &adm1027_operations;
71 struct chip_operations drivers_i2c_adm1027_ops = {
73 .enable_dev = enable_dev,