Blame view

include/linux/i2c-mux.h 1.63 KB
162163332   Thomas Gleixner   treewide: Replace...
1
  /* SPDX-License-Identifier: GPL-2.0-or-later */
0826374bf   Michael Lawnick   i2c: Multiplexed ...
2
3
4
5
6
7
8
  /*
   *
   * i2c-mux.h - functions for the i2c-bus mux support
   *
   * Copyright (c) 2008-2009 Rodolfo Giometti <giometti@linux.it>
   * Copyright (c) 2008-2009 Eurotech S.p.A. <info@eurotech.it>
   * Michael Lawnick <michael.lawnick.ext@nsn.com>
0826374bf   Michael Lawnick   i2c: Multiplexed ...
9
10
11
12
13
14
   */
  
  #ifndef _LINUX_I2C_MUX_H
  #define _LINUX_I2C_MUX_H
  
  #ifdef __KERNEL__
6ef91fcca   Peter Rosin   i2c: mux: relax l...
15
  #include <linux/bitops.h>
a7ab72390   Peter Rosin   i2c: mux: add com...
16
17
18
  struct i2c_mux_core {
  	struct i2c_adapter *parent;
  	struct device *dev;
b2d57b560   Peter Rosin   i2c: mux: add sup...
19
20
21
  	unsigned int mux_locked:1;
  	unsigned int arbitrator:1;
  	unsigned int gate:1;
a7ab72390   Peter Rosin   i2c: mux: add com...
22
23
24
25
26
27
28
29
  
  	void *priv;
  
  	int (*select)(struct i2c_mux_core *, u32 chan_id);
  	int (*deselect)(struct i2c_mux_core *, u32 chan_id);
  
  	int num_adapters;
  	int max_adapters;
8695e0b1b   Gustavo A. R. Silva   i2c: mux: Replace...
30
  	struct i2c_adapter *adapter[];
a7ab72390   Peter Rosin   i2c: mux: add com...
31
32
33
34
35
36
37
  };
  
  struct i2c_mux_core *i2c_mux_alloc(struct i2c_adapter *parent,
  				   struct device *dev, int max_adapters,
  				   int sizeof_priv, u32 flags,
  				   int (*select)(struct i2c_mux_core *, u32),
  				   int (*deselect)(struct i2c_mux_core *, u32));
6ef91fcca   Peter Rosin   i2c: mux: relax l...
38
  /* flags for i2c_mux_alloc */
b2d57b560   Peter Rosin   i2c: mux: add sup...
39
40
41
  #define I2C_MUX_LOCKED     BIT(0)
  #define I2C_MUX_ARBITRATOR BIT(1)
  #define I2C_MUX_GATE       BIT(2)
6ef91fcca   Peter Rosin   i2c: mux: relax l...
42

a7ab72390   Peter Rosin   i2c: mux: add com...
43
44
45
46
  static inline void *i2c_mux_priv(struct i2c_mux_core *muxc)
  {
  	return muxc->priv;
  }
6ef91fcca   Peter Rosin   i2c: mux: relax l...
47
  struct i2c_adapter *i2c_root_adapter(struct device *dev);
0826374bf   Michael Lawnick   i2c: Multiplexed ...
48
  /*
a7ab72390   Peter Rosin   i2c: mux: add com...
49
50
51
52
53
54
55
   * Called to create an i2c bus on a multiplexed bus segment.
   * The chan_id parameter is passed to the select and deselect
   * callback functions to perform hardware-specific mux control.
   */
  int i2c_mux_add_adapter(struct i2c_mux_core *muxc,
  			u32 force_nr, u32 chan_id,
  			unsigned int class);
0826374bf   Michael Lawnick   i2c: Multiplexed ...
56

a7ab72390   Peter Rosin   i2c: mux: add com...
57
  void i2c_mux_del_adapters(struct i2c_mux_core *muxc);
0826374bf   Michael Lawnick   i2c: Multiplexed ...
58
59
60
61
  
  #endif /* __KERNEL__ */
  
  #endif /* _LINUX_I2C_MUX_H */