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