blob: 4d1241acb9d9a77ca848417b40c5d05632fc4e72 [file] [log] [blame]
Yinghai Luafd34e62006-02-16 17:22:19 +00001#include <device/device.h>
2#include <device/smbus.h>
Yinghai Luafd34e62006-02-16 17:22:19 +00003
Edward O'Callaghan2c9d2cf2014-10-27 23:29:29 +11004static void i2cmux2_set_link(struct device *dev, unsigned int link)
Yinghai Luafd34e62006-02-16 17:22:19 +00005{
Vikram Narayanan0786bc62011-12-26 22:52:01 +05306 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 Luafd34e62006-02-16 17:22:19 +00009 }
Yinghai Luafd34e62006-02-16 17:22:19 +000010 }
Yinghai Luafd34e62006-02-16 17:22:19 +000011}
Vikram Narayanan0786bc62011-12-26 22:52:01 +053012
Yinghai Luafd34e62006-02-16 17:22:19 +000013static struct device_operations i2cmux2_operations = {
Edward O'Callaghan524625d2014-10-31 07:55:45 +110014 .read_resources = DEVICE_NOOP,
15 .set_resources = DEVICE_NOOP,
16 .enable_resources = DEVICE_NOOP,
17 .init = DEVICE_NOOP,
Kyösti Mälkkid0e212c2015-02-26 20:47:47 +020018 .scan_bus = scan_smbus,
Vikram Narayanan0786bc62011-12-26 22:52:01 +053019 .set_link = i2cmux2_set_link,
Yinghai Luafd34e62006-02-16 17:22:19 +000020};
21
22static void enable_dev(struct device *dev)
23{
Vikram Narayanan0786bc62011-12-26 22:52:01 +053024 if (dev->link_list != NULL)
Yinghai Luafd34e62006-02-16 17:22:19 +000025 dev->ops = &i2cmux2_operations;
26}
27
28struct chip_operations drivers_i2c_i2cmux2_ops = {
29 CHIP_NAME("i2cmux2")
Stefan Reinauer14e22772010-04-27 06:56:47 +000030 .enable_dev = enable_dev,
Yinghai Luafd34e62006-02-16 17:22:19 +000031};