1
2
3
4
5
6#ifndef POWERPC_ASM_MPC85XX_GPIO_H_
7#define POWERPC_ASM_MPC85XX_GPIO_H_
8
9#ifndef CONFIG_DM_GPIO
10# include <asm/immap_85xx.h>
11
12
13
14
15
16
17
18
19
20static inline void mpc85xx_gpio_set(unsigned int mask,
21 unsigned int dir, unsigned int val)
22{
23 ccsr_gpio_t *gpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
24
25
26 dir &= mask;
27 val &= mask;
28
29
30 dir |= (in_be32(&gpio->gpdir) & ~mask);
31 val |= (in_be32(&gpio->gpdat) & ~mask);
32
33
34
35
36
37
38 out_be32(&gpio->gpdat, val);
39 out_be32(&gpio->gpdir, dir);
40}
41
42static inline void mpc85xx_gpio_set_in(unsigned int gpios)
43{
44 mpc85xx_gpio_set(gpios, 0x00000000, 0x00000000);
45}
46
47static inline void mpc85xx_gpio_set_low(unsigned int gpios)
48{
49 mpc85xx_gpio_set(gpios, 0xFFFFFFFF, 0x00000000);
50}
51
52static inline void mpc85xx_gpio_set_high(unsigned int gpios)
53{
54 mpc85xx_gpio_set(gpios, 0xFFFFFFFF, 0xFFFFFFFF);
55}
56
57static inline unsigned int mpc85xx_gpio_get(unsigned int mask)
58{
59 ccsr_gpio_t *gpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
60
61
62 return in_be32(&gpio->gpdat) & mask;
63}
64
65
66
67
68
69static inline int gpio_request(unsigned gpio, const char *label)
70{
71
72 return 0;
73}
74
75static inline int gpio_free(unsigned gpio)
76{
77
78 return 0;
79}
80
81static inline int gpio_direction_input(unsigned gpio)
82{
83 mpc85xx_gpio_set_in(1U << gpio);
84 return 0;
85}
86
87static inline int gpio_direction_output(unsigned gpio, int value)
88{
89 if (value)
90 mpc85xx_gpio_set_high(1U << gpio);
91 else
92 mpc85xx_gpio_set_low(1U << gpio);
93 return 0;
94}
95
96static inline int gpio_get_value(unsigned gpio)
97{
98 return !!mpc85xx_gpio_get(1U << gpio);
99}
100
101static inline int gpio_set_value(unsigned gpio, int value)
102{
103 if (value)
104 mpc85xx_gpio_set_high(1U << gpio);
105 else
106 mpc85xx_gpio_set_low(1U << gpio);
107 return 0;
108}
109
110static inline int gpio_is_valid(int gpio)
111{
112 return (gpio >= 0) && (gpio < 32);
113}
114#endif
115#endif
116