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 ADM1026_DEVICE 0x2d /* Either 0x2c or 0x2d or 0x2e */
12 #define ADM1026_REG_CONFIG1 0x00
13 #define CFG1_MONITOR 0x01
14 #define CFG1_INT_ENABLE 0x02
15 #define CFG1_INT_CLEAR 0x04
16 #define CFG1_AIN8_9 0x08
17 #define CFG1_THERM_HOT 0x10
18 #define CFT1_DAC_AFC 0x20
19 #define CFG1_PWM_AFC 0x40
20 #define CFG1_RESET 0x80
21 #define ADM1026_REG_CONFIG2 0x01
22 #define ADM1026_REG_CONFIG3 0x07
24 static void adm1026_enable_monitoring(device_t dev);
26 static void adm1026_init(device_t dev)
28 if (dev->enabled && dev->path.type == DEVICE_PATH_I2C)
30 if(ops_smbus_bus(get_pbus_smbus(dev))) {
31 if( dev->bus->dev->path.type == DEVICE_PATH_I2C) smbus_set_link(dev); // it is under mux
32 adm1026_enable_monitoring(dev);
38 static void adm1026_enable_monitoring(device_t dev)
41 result = smbus_read_byte(dev, ADM1026_REG_CONFIG1);
43 result = (result | CFG1_MONITOR) & ~(CFG1_INT_CLEAR | CFG1_RESET);
44 result = smbus_write_byte(dev, ADM1026_REG_CONFIG1, result);
46 result = smbus_read_byte(dev, ADM1026_REG_CONFIG1);
47 if (!(result & CFG1_MONITOR)) {
48 printk_debug("ADM1026: monitoring would not enable");
51 static void adm1026_noop(device_t dummy)
55 static struct device_operations adm1026_operations = {
56 .read_resources = adm1026_noop,
57 .set_resources = adm1026_noop,
58 .enable_resources = adm1026_noop,
62 static void enable_dev(struct device *dev)
64 dev->ops = &adm1026_operations;
67 struct chip_operations drivers_i2c_adm1026_ops = {
69 .enable_dev = enable_dev,