1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/mmio.h>
6 static void gpio_set_spec_pull_pupd(gpio_t gpio
, enum pull_enable enable
,
7 enum pull_select select
)
13 reg1
= gpio_find_reg_addr(gpio
) + gpio
.offset
;
14 reg2
= reg1
+ (gpio
.base
& 0xf0);
16 if (enable
== GPIO_PULL_ENABLE
) {
17 if (select
== GPIO_PULL_DOWN
)
18 setbits32(reg1
, BIT(bit
));
20 clrbits32(reg1
, BIT(bit
));
23 if (enable
== GPIO_PULL_ENABLE
) {
24 setbits32(reg2
, BIT(bit
));
26 clrbits32(reg2
, BIT(bit
));
27 clrbits32(reg2
+ 0x010, BIT(bit
));
31 static void gpio_set_pull_pu_pd(gpio_t gpio
, enum pull_enable enable
,
32 enum pull_select select
)
38 reg1
= gpio_find_reg_addr(gpio
) + gpio
.offset
;
39 reg2
= reg1
- (gpio
.base
& 0xf0);
41 if (enable
== GPIO_PULL_ENABLE
) {
42 if (select
== GPIO_PULL_DOWN
) {
43 clrbits32(reg1
, BIT(bit
));
44 setbits32(reg2
, BIT(bit
));
46 clrbits32(reg2
, BIT(bit
));
47 setbits32(reg1
, BIT(bit
));
50 clrbits32(reg1
, BIT(bit
));
51 clrbits32(reg2
, BIT(bit
));
55 void gpio_set_pull(gpio_t gpio
, enum pull_enable enable
,
56 enum pull_select select
)
59 gpio_set_spec_pull_pupd(gpio
, enable
, select
);
61 gpio_set_pull_pu_pd(gpio
, enable
, select
);