mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
i2c: Add generic I2C multiplexer using GPIO API
Add an i2c mux driver providing access to i2c bus segments using a hardware MUX sitting on a master bus and controlled through gpio pins. E.G. something like: ---------- ---------- Bus segment 1 - - - - - | | SCL/SDA | |-------------- | | | |------------| | | | | | Bus segment 2 | | | Linux | GPIO 1..N | MUX |--------------- Devices | |------------| | | | | | | | Bus segment M | | | |---------------| | ---------- ---------- - - - - - SCL/SDA of the master I2C bus is multiplexed to bus segment 1..M according to the settings of the GPIO pins 1..N. Signed-off-by: Peter Korsgaard <peter.korsgaard@barco.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
This commit is contained in:
parent
b18a5c80eb
commit
92ed1a76ca
6 changed files with 308 additions and 0 deletions
38
include/linux/gpio-i2cmux.h
Normal file
38
include/linux/gpio-i2cmux.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* gpio-i2cmux interface to platform code
|
||||
*
|
||||
* Peter Korsgaard <peter.korsgaard@barco.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_GPIO_I2CMUX_H
|
||||
#define _LINUX_GPIO_I2CMUX_H
|
||||
|
||||
/* MUX has no specific idle mode */
|
||||
#define GPIO_I2CMUX_NO_IDLE ((unsigned)-1)
|
||||
|
||||
/**
|
||||
* struct gpio_i2cmux_platform_data - Platform-dependent data for gpio-i2cmux
|
||||
* @parent: Parent I2C bus adapter number
|
||||
* @base_nr: Base I2C bus number to number adapters from or zero for dynamic
|
||||
* @values: Array of bitmasks of GPIO settings (low/high) for each
|
||||
* position
|
||||
* @n_values: Number of multiplexer positions (busses to instantiate)
|
||||
* @gpios: Array of GPIO numbers used to control MUX
|
||||
* @n_gpios: Number of GPIOs used to control MUX
|
||||
* @idle: Bitmask to write to MUX when idle or GPIO_I2CMUX_NO_IDLE if not used
|
||||
*/
|
||||
struct gpio_i2cmux_platform_data {
|
||||
int parent;
|
||||
int base_nr;
|
||||
const unsigned *values;
|
||||
int n_values;
|
||||
const unsigned *gpios;
|
||||
int n_gpios;
|
||||
unsigned idle;
|
||||
};
|
||||
|
||||
#endif /* _LINUX_GPIO_I2CMUX_H */
|
Loading…
Add table
Add a link
Reference in a new issue