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