blob: 7fd5575a368f95d4208de03fb20b3e9be659dd65 [file] [log] [blame]
Wolfram Sang738ac062019-01-19 13:16:54 +01001/* 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 Torvalds1da177e2005-04-16 15:20:36 -07009
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#ifndef _LINUX_I2C_ALGO_BIT_H
11#define _LINUX_I2C_ALGO_BIT_H
12
Wolfram Sang22928222019-01-19 13:16:53 +010013#include <linux/i2c.h>
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015/* --- Defines for bit-adapters --------------------------------------- */
16/*
David Brownell438d6c22006-12-10 21:21:31 +010017 * This struct contains the hw-dependent functions of bit-style adapters to
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 * manipulate the line states, and to init any hw-specific features. This is
David Brownell438d6c22006-12-10 21:21:31 +010019 * only used if you have more than one hw-type of adapter running.
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 */
21struct 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 Delvare0a9c1472010-03-13 20:56:56 +010027 int (*pre_xfer) (struct i2c_adapter *);
28 void (*post_xfer) (struct i2c_adapter *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
30 /* local settings */
Jean Delvare424ed672007-05-01 23:26:33 +020031 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 Torvalds1da177e2005-04-16 15:20:36 -070035 int timeout; /* in jiffies */
Wolfram Sang8927fbf2019-04-03 14:40:18 +020036 bool can_do_atomic; /* callbacks don't sleep, we can be atomic */
Linus Torvalds1da177e2005-04-16 15:20:36 -070037};
38
Linus Torvalds1da177e2005-04-16 15:20:36 -070039int i2c_bit_add_bus(struct i2c_adapter *);
Jean Delvare0f3b4832007-05-01 23:26:31 +020040int i2c_bit_add_numbered_bus(struct i2c_adapter *);
Daniel Vetterb0209b32012-02-28 00:39:39 +010041extern const struct i2c_algorithm i2c_bit_algo;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43#endif /* _LINUX_I2C_ALGO_BIT_H */