Wolfram Sang | 738ac06 | 2019-01-19 13:16:54 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * i2c-algo-bit.h: i2c driver algorithms for bit-shift adapters |
| 4 | * |
| 5 | * Copyright (C) 1995-99 Simon G. Vogl |
| 6 | * With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even |
| 7 | * Frodo Looijaard <frodol@dds.nl> |
| 8 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #ifndef _LINUX_I2C_ALGO_BIT_H |
| 11 | #define _LINUX_I2C_ALGO_BIT_H |
| 12 | |
Wolfram Sang | 2292822 | 2019-01-19 13:16:53 +0100 | [diff] [blame] | 13 | #include <linux/i2c.h> |
| 14 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | /* --- Defines for bit-adapters --------------------------------------- */ |
| 16 | /* |
David Brownell | 438d6c2 | 2006-12-10 21:21:31 +0100 | [diff] [blame] | 17 | * This struct contains the hw-dependent functions of bit-style adapters to |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | * manipulate the line states, and to init any hw-specific features. This is |
David Brownell | 438d6c2 | 2006-12-10 21:21:31 +0100 | [diff] [blame] | 19 | * only used if you have more than one hw-type of adapter running. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | */ |
| 21 | struct i2c_algo_bit_data { |
| 22 | void *data; /* private data for lowlevel routines */ |
| 23 | void (*setsda) (void *data, int state); |
| 24 | void (*setscl) (void *data, int state); |
| 25 | int (*getsda) (void *data); |
| 26 | int (*getscl) (void *data); |
Jean Delvare | 0a9c147 | 2010-03-13 20:56:56 +0100 | [diff] [blame] | 27 | int (*pre_xfer) (struct i2c_adapter *); |
| 28 | void (*post_xfer) (struct i2c_adapter *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
| 30 | /* local settings */ |
Jean Delvare | 424ed67 | 2007-05-01 23:26:33 +0200 | [diff] [blame] | 31 | int udelay; /* half clock cycle time in us, |
| 32 | minimum 2 us for fast-mode I2C, |
| 33 | minimum 5 us for standard-mode I2C and SMBus, |
| 34 | maximum 50 us for SMBus */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | int timeout; /* in jiffies */ |
Wolfram Sang | 8927fbf | 2019-04-03 14:40:18 +0200 | [diff] [blame] | 36 | bool can_do_atomic; /* callbacks don't sleep, we can be atomic */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | }; |
| 38 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | int i2c_bit_add_bus(struct i2c_adapter *); |
Jean Delvare | 0f3b483 | 2007-05-01 23:26:31 +0200 | [diff] [blame] | 40 | int i2c_bit_add_numbered_bus(struct i2c_adapter *); |
Daniel Vetter | b0209b3 | 2012-02-28 00:39:39 +0100 | [diff] [blame] | 41 | extern const struct i2c_algorithm i2c_bit_algo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
| 43 | #endif /* _LINUX_I2C_ALGO_BIT_H */ |