// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 /* * Mellanox i2c mux driver * * Copyright (C) 2016-2020 Mellanox Technologies */ #include <linux/device.h> #include <linux/i2c.h> #include <linux/i2c-mux.h> #include <linux/io.h> #include <linux/init.h> #include <linux/module.h> #include <linux/platform_data/mlxcpld.h> #include <linux/platform_device.h> #include <linux/slab.h> /* mlxcpld_mux - mux control structure: * @last_val - last selected register value or -1 if mux deselected * @client - I2C device client * @pdata: platform data */ struct mlxcpld_mux { … }; /* MUX logic description. * Driver can support different mux control logic, according to CPLD * implementation. * * Connectivity schema. * * i2c-mlxcpld Digital Analog * driver * *--------* * -> mux1 (virt bus2) -> mux -> | * | I2CLPC | i2c physical * -> mux2 (virt bus3) -> mux -> | * | bridge | bus 1 *---------* | * | logic |---------------------> * mux reg * | * | in CPLD| *---------* | * *--------* i2c-mux-mlxpcld ^ * -> muxn (virt busn) -> mux -> | * | driver | | * | *---------------* | Devices * | * CPLD (i2c bus)* select | * | * registers for *--------* * | * mux selection * deselect * | *---------------* * | | * <--------> <-----------> * i2c cntrl Board cntrl reg * reg space space (mux select, * IO, LED, WD, info) * */ /* Write to mux register. Don't use i2c_transfer() and i2c_smbus_xfer() * for this as they will try to lock adapter a second time. */ static int mlxcpld_mux_reg_write(struct i2c_adapter *adap, struct mlxcpld_mux *mux, u32 val) { … } static int mlxcpld_mux_select_chan(struct i2c_mux_core *muxc, u32 chan) { … } static int mlxcpld_mux_deselect(struct i2c_mux_core *muxc, u32 chan) { … } /* Probe/reomove functions */ static int mlxcpld_mux_probe(struct platform_device *pdev) { … } static void mlxcpld_mux_remove(struct platform_device *pdev) { … } static struct platform_driver mlxcpld_mux_driver = …; module_platform_driver(…) …; MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …; MODULE_ALIAS(…) …;