summaryrefslogtreecommitdiff
path: root/include/aml_gpio.h (plain)
blob: 1765f47664ca1821a451dc6268fa1eb9177089f6
1#ifndef __AML_GPIO__
2#define __AML_GPIO__
3#include <asm/io.h>
4/**
5 * struct meson_reg_desc - a register descriptor
6 *
7 * @reg: register offset in the regmap
8 * @bit: bit index in register
9 *
10 * The structure describes the information needed to control pull,
11 * pull-enable, direction, etc. for a single pin
12 */
13struct meson_reg_desc {
14 unsigned int reg;
15 unsigned int bit;
16};
17
18/**
19 * enum meson_reg_type - type of registers encoded in @meson_reg_desc
20 */
21enum meson_reg_type {
22 REG_PULLEN,
23 REG_PULL,
24 REG_DIR,
25 REG_OUT,
26 REG_IN,
27 NUM_REG,
28};
29
30
31
32
33struct meson_bank {
34 const char *name;
35 unsigned int first;
36 unsigned int last;
37 struct meson_reg_desc regs[NUM_REG];
38};
39#define GPIO_REG_BIT(reg, bit) ((reg<<5)|bit)
40#define GPIO_REG(value) ((value>>5))
41#define GPIO_BIT(value) ((value&0x1F))
42#define BIT(bit) (1<<bit)
43static inline void regmap_update_bits(unsigned long reg,unsigned mask,unsigned val)
44{
45
46 unsigned int tmp, orig;
47 orig = readl(reg);
48 tmp = orig & ~mask;
49 tmp |= val & mask;
50 writel(tmp,reg);
51 return;
52}
53
54#endif
55