xref: /OK3568_Linux_fs/u-boot/include/tca642x.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright 2013 Texas Instruments, Inc.
3*4882a593Smuzhiyun  * Author: Dan Murphy <dmurphy@ti.com>
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Derived work from the pca953x.c driver
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * This program is free software; you can redistribute it and/or
8*4882a593Smuzhiyun  * modify it under the terms of the GNU General Public License as
9*4882a593Smuzhiyun  * published by the Free Software Foundation; either version 2 of
10*4882a593Smuzhiyun  * the License, or (at your option) any later version.
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  * This program is distributed in the hope that it will be useful,
13*4882a593Smuzhiyun  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14*4882a593Smuzhiyun  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15*4882a593Smuzhiyun  * GNU General Public License for more details.
16*4882a593Smuzhiyun  *
17*4882a593Smuzhiyun  * You should have received a copy of the GNU General Public License
18*4882a593Smuzhiyun  * along with this program; if not, write to the Free Software
19*4882a593Smuzhiyun  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20*4882a593Smuzhiyun  * MA 02111-1307 USA
21*4882a593Smuzhiyun  */
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun #ifndef __TCA642X_H_
24*4882a593Smuzhiyun #define __TCA642X_H_
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun #ifdef CONFIG_CMD_TCA642X
27*4882a593Smuzhiyun enum {
28*4882a593Smuzhiyun 	TCA642X_CMD_INFO,
29*4882a593Smuzhiyun 	TCA642X_CMD_DEVICE,
30*4882a593Smuzhiyun 	TCA642X_CMD_OUTPUT,
31*4882a593Smuzhiyun 	TCA642X_CMD_INPUT,
32*4882a593Smuzhiyun 	TCA642X_CMD_INVERT,
33*4882a593Smuzhiyun };
34*4882a593Smuzhiyun #endif
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun #define TCA642X_OUT_LOW		0
37*4882a593Smuzhiyun #define TCA642X_OUT_HIGH	1
38*4882a593Smuzhiyun #define TCA642X_POL_NORMAL	0
39*4882a593Smuzhiyun #define TCA642X_POL_INVERT	1
40*4882a593Smuzhiyun #define TCA642X_DIR_OUT		0
41*4882a593Smuzhiyun #define TCA642X_DIR_IN		1
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun /* Default to an address that hopefully won't corrupt other i2c devices */
44*4882a593Smuzhiyun #ifndef CONFIG_SYS_I2C_TCA642X_ADDR
45*4882a593Smuzhiyun #define CONFIG_SYS_I2C_TCA642X_ADDR	(~0)
46*4882a593Smuzhiyun #endif
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun /* Default to an address that hopefully won't corrupt other i2c devices */
49*4882a593Smuzhiyun #ifndef CONFIG_SYS_I2C_TCA642X_BUS_NUM
50*4882a593Smuzhiyun #define CONFIG_SYS_I2C_TCA642X_BUS_NUM	(0)
51*4882a593Smuzhiyun #endif
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun struct tca642x_bank_info {
54*4882a593Smuzhiyun 	uint8_t input_reg;
55*4882a593Smuzhiyun 	uint8_t output_reg;
56*4882a593Smuzhiyun 	uint8_t polarity_reg;
57*4882a593Smuzhiyun 	uint8_t configuration_reg;
58*4882a593Smuzhiyun };
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun int tca642x_set_val(uchar chip, uint8_t gpio_bank,
61*4882a593Smuzhiyun 			uint8_t reg_bit, uint8_t data);
62*4882a593Smuzhiyun int tca642x_set_pol(uchar chip, uint8_t gpio_bank,
63*4882a593Smuzhiyun 			uint8_t reg_bit, uint8_t data);
64*4882a593Smuzhiyun int tca642x_set_dir(uchar chip, uint8_t gpio_bank,
65*4882a593Smuzhiyun 			uint8_t reg_bit, uint8_t data);
66*4882a593Smuzhiyun int tca642x_get_val(uchar chip, uint8_t gpio_bank);
67*4882a593Smuzhiyun int tca642x_set_inital_state(uchar chip, struct tca642x_bank_info init_data[]);
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun #endif /* __TCA642X_H_ */
70