xref: /linux/drivers/staging/sm750fb/ddk750_swi2c.h (revision 976e3645923bdd2fe7893aae33fd7a21098bfb28)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  *         Copyright (c) 2007 by Silicon Motion, Inc. (SMI)
4  *
5  *  swi2c.h --- SM750/SM718 DDK
6  *  This file contains the definitions for i2c using software
7  *  implementation.
8  *
9  */
10 
11 #ifndef _SWI2C_H_
12 #define _SWI2C_H_
13 
14 /* Default i2c CLK and Data GPIO. These are the default i2c pins */
15 #define DEFAULT_I2C_SCL                     30
16 #define DEFAULT_I2C_SDA                     31
17 
18 /*
19  * This function initializes the i2c attributes and bus
20  *
21  * Parameters:
22  *      i2cClkGPIO  - The GPIO pin to be used as i2c SCL
23  *      i2cDataGPIO - The GPIO pin to be used as i2c SDA
24  *
25  * Return Value:
26  *      -1   - Fail to initialize the i2c
27  *       0   - Success
28  */
29 long sm750_sw_i2c_init(unsigned char clk_gpio, unsigned char data_gpio);
30 
31 /*
32  *  This function reads the slave device's register
33  *
34  *  Parameters:
35  *      addr   - i2c Slave device address which register
36  *                        to be read from
37  *      reg    - Slave device's register to be read
38  *
39  *  Return Value:
40  *      Register value
41  */
42 unsigned char sm750_sw_i2c_read_reg(unsigned char addr, unsigned char reg);
43 
44 /*
45  *  This function writes a value to the slave device's register
46  *
47  *  Parameters:
48  *      addr            - i2c Slave device address which register
49  *                        to be written
50  *      reg             - Slave device's register to be written
51  *      data            - Data to be written to the register
52  *
53  *  Result:
54  *          0   - Success
55  *         -1   - Fail
56  */
57 long sm750_sw_i2c_write_reg(unsigned char addr,
58 			    unsigned char reg,
59 			    unsigned char data);
60 
61 #endif  /* _SWI2C_H_ */
62