Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 1 | #include <device/device.h> |
| 2 | #include <device/smbus.h> |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 3 | |
Edward O'Callaghan | 2c9d2cf | 2014-10-27 23:29:29 +1100 | [diff] [blame] | 4 | static void i2cmux2_set_link(struct device *dev, unsigned int link) |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 5 | { |
Vikram Narayanan | 0786bc6 | 2011-12-26 22:52:01 +0530 | [diff] [blame] | 6 | if (dev->enabled && dev->path.type == DEVICE_PATH_I2C) { |
| 7 | if (ops_smbus_bus(get_pbus_smbus(dev))) { |
| 8 | smbus_send_byte(dev, link); // output value |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 9 | } |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 10 | } |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 11 | } |
Vikram Narayanan | 0786bc6 | 2011-12-26 22:52:01 +0530 | [diff] [blame] | 12 | |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 13 | static struct device_operations i2cmux2_operations = { |
Edward O'Callaghan | 524625d | 2014-10-31 07:55:45 +1100 | [diff] [blame] | 14 | .read_resources = DEVICE_NOOP, |
| 15 | .set_resources = DEVICE_NOOP, |
| 16 | .enable_resources = DEVICE_NOOP, |
| 17 | .init = DEVICE_NOOP, |
Kyösti Mälkki | d0e212c | 2015-02-26 20:47:47 +0200 | [diff] [blame] | 18 | .scan_bus = scan_smbus, |
Vikram Narayanan | 0786bc6 | 2011-12-26 22:52:01 +0530 | [diff] [blame] | 19 | .set_link = i2cmux2_set_link, |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 20 | }; |
| 21 | |
| 22 | static void enable_dev(struct device *dev) |
| 23 | { |
Vikram Narayanan | 0786bc6 | 2011-12-26 22:52:01 +0530 | [diff] [blame] | 24 | if (dev->link_list != NULL) |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 25 | dev->ops = &i2cmux2_operations; |
| 26 | } |
| 27 | |
| 28 | struct chip_operations drivers_i2c_i2cmux2_ops = { |
| 29 | CHIP_NAME("i2cmux2") |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 30 | .enable_dev = enable_dev, |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 31 | }; |