Yinghai Lu | 7213d0f | 2004-12-03 03:39:04 +0000 | [diff] [blame] | 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 <cpu/x86/msr.h> |
Yinghai Lu | 7213d0f | 2004-12-03 03:39:04 +0000 | [diff] [blame] | 8 | |
Edward O'Callaghan | 2c9d2cf | 2014-10-27 23:29:29 +1100 | [diff] [blame] | 9 | static void lm63_init(struct device *dev) |
Yinghai Lu | 7213d0f | 2004-12-03 03:39:04 +0000 | [diff] [blame] | 10 | { |
| 11 | int result; |
Vikram Narayanan | 0786bc6 | 2011-12-26 22:52:01 +0530 | [diff] [blame] | 12 | if (dev->enabled && dev->path.type == DEVICE_PATH_I2C) { |
| 13 | if (ops_smbus_bus(get_pbus_smbus(dev))) { |
| 14 | if (dev->bus->dev->path.type == DEVICE_PATH_I2C) |
| 15 | smbus_set_link(dev); // it is under mux |
Yinghai Lu | 7213d0f | 2004-12-03 03:39:04 +0000 | [diff] [blame] | 16 | result = smbus_read_byte(dev, 0x03); |
Vikram Narayanan | 0786bc6 | 2011-12-26 22:52:01 +0530 | [diff] [blame] | 17 | // result &= ~0x04; |
Yinghai Lu | 7213d0f | 2004-12-03 03:39:04 +0000 | [diff] [blame] | 18 | result |= 0x04; |
Vikram Narayanan | 0786bc6 | 2011-12-26 22:52:01 +0530 | [diff] [blame] | 19 | smbus_write_byte(dev, 0x03, result & 0xff); // config lm63 |
Yinghai Lu | 7213d0f | 2004-12-03 03:39:04 +0000 | [diff] [blame] | 20 | } |
Yinghai Lu | 7213d0f | 2004-12-03 03:39:04 +0000 | [diff] [blame] | 21 | } |
Yinghai Lu | 7213d0f | 2004-12-03 03:39:04 +0000 | [diff] [blame] | 22 | } |
Vikram Narayanan | 0786bc6 | 2011-12-26 22:52:01 +0530 | [diff] [blame] | 23 | |
Yinghai Lu | 7213d0f | 2004-12-03 03:39:04 +0000 | [diff] [blame] | 24 | static struct device_operations lm63_operations = { |
Edward O'Callaghan | 524625d | 2014-10-31 07:55:45 +1100 | [diff] [blame] | 25 | .read_resources = DEVICE_NOOP, |
| 26 | .set_resources = DEVICE_NOOP, |
| 27 | .enable_resources = DEVICE_NOOP, |
Vikram Narayanan | 0786bc6 | 2011-12-26 22:52:01 +0530 | [diff] [blame] | 28 | .init = lm63_init, |
Yinghai Lu | 7213d0f | 2004-12-03 03:39:04 +0000 | [diff] [blame] | 29 | }; |
| 30 | |
| 31 | static void enable_dev(struct device *dev) |
| 32 | { |
| 33 | dev->ops = &lm63_operations; |
| 34 | } |
| 35 | |
| 36 | struct chip_operations drivers_i2c_lm63_ops = { |
Uwe Hermann | a7aa29b | 2006-11-05 18:50:49 +0000 | [diff] [blame] | 37 | CHIP_NAME("National Semiconductor LM63") |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 38 | .enable_dev = enable_dev, |
Yinghai Lu | 7213d0f | 2004-12-03 03:39:04 +0000 | [diff] [blame] | 39 | }; |