Merge branch 'i2c/for-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
[linux-2.6-microblaze.git] / include / linux / mfd / smsc.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * SMSC ECE1099
4  *
5  * Copyright 2012 Texas Instruments Inc.
6  *
7  * Author: Sourav Poddar <sourav.poddar@ti.com>
8  */
9
10 #ifndef __LINUX_MFD_SMSC_H
11 #define __LINUX_MFD_SMSC_H
12
13 #include <linux/regmap.h>
14
15 #define SMSC_ID_ECE1099                 1
16 #define SMSC_NUM_CLIENTS                2
17
18 #define SMSC_BASE_ADDR                  0x38
19 #define OMAP_GPIO_SMSC_IRQ              151
20
21 #define SMSC_MAXGPIO         32
22 #define SMSC_BANK(offs)      ((offs) >> 3)
23 #define SMSC_BIT(offs)       (1u << ((offs) & 0x7))
24
25 struct smsc {
26         struct device *dev;
27         struct i2c_client *i2c_clients[SMSC_NUM_CLIENTS];
28         struct regmap *regmap;
29         int clk;
30         /* Stored chip id */
31         int id;
32 };
33
34 struct smsc_gpio;
35 struct smsc_keypad;
36
37 static inline int smsc_read(struct device *child, unsigned int reg,
38         unsigned int *dest)
39 {
40         struct smsc     *smsc = dev_get_drvdata(child->parent);
41
42         return regmap_read(smsc->regmap, reg, dest);
43 }
44
45 static inline int smsc_write(struct device *child, unsigned int reg,
46         unsigned int value)
47 {
48         struct smsc     *smsc = dev_get_drvdata(child->parent);
49
50         return regmap_write(smsc->regmap, reg, value);
51 }
52
53 /* Registers for SMSC */
54 #define SMSC_RESET                                              0xF5
55 #define SMSC_GRP_INT                                            0xF9
56 #define SMSC_CLK_CTRL                                           0xFA
57 #define SMSC_WKUP_CTRL                                          0xFB
58 #define SMSC_DEV_ID                                             0xFC
59 #define SMSC_DEV_REV                                            0xFD
60 #define SMSC_VEN_ID_L                                           0xFE
61 #define SMSC_VEN_ID_H                                           0xFF
62
63 /* CLK VALUE */
64 #define SMSC_CLK_VALUE                                          0x13
65
66 /* Registers for function GPIO INPUT */
67 #define SMSC_GPIO_DATA_IN_START                                 0x00
68
69 /* Registers for function GPIO OUPUT */
70 #define SMSC_GPIO_DATA_OUT_START                                       0x05
71
72 /* Definitions for SMSC GPIO CONFIGURATION REGISTER*/
73 #define SMSC_GPIO_INPUT_LOW                                     0x01
74 #define SMSC_GPIO_INPUT_RISING                                  0x09
75 #define SMSC_GPIO_INPUT_FALLING                                 0x11
76 #define SMSC_GPIO_INPUT_BOTH_EDGE                               0x19
77 #define SMSC_GPIO_OUTPUT_PP                                     0x21
78 #define SMSC_GPIO_OUTPUT_OP                                     0x31
79
80 #define GRP_INT_STAT                                            0xf9
81 #define SMSC_GPI_INT                                            0x0f
82 #define SMSC_CFG_START                                          0x0A
83
84 /* Registers for SMSC GPIO INTERRUPT STATUS REGISTER*/
85 #define SMSC_GPIO_INT_STAT_START                                  0x32
86
87 /* Registers for SMSC GPIO INTERRUPT MASK REGISTER*/
88 #define SMSC_GPIO_INT_MASK_START                               0x37
89
90 /* Registers for SMSC function KEYPAD*/
91 #define SMSC_KP_OUT                                             0x40
92 #define SMSC_KP_IN                                              0x41
93 #define SMSC_KP_INT_STAT                                        0x42
94 #define SMSC_KP_INT_MASK                                        0x43
95
96 /* Definitions for keypad */
97 #define SMSC_KP_KSO           0x70
98 #define SMSC_KP_KSI           0x51
99 #define SMSC_KSO_ALL_LOW        0x20
100 #define SMSC_KP_SET_LOW_PWR        0x0B
101 #define SMSC_KP_SET_HIGH           0xFF
102 #define SMSC_KSO_EVAL           0x00
103
104 #endif /*  __LINUX_MFD_SMSC_H */