driver: dw: Use base_addr variable to set dir.

Change Summary:
Update Base addr to set direction to use Aligned IP base address instead
of Port Base Address. Port Base Address + offset to direction register
will set incorrect value for Port B,C & D. For ex: In cases when more than
1 port is configured on the same IP, the DTS node for port B will start
at offset 0xC. Calculating the port using Port Base will yield offset of
PORTB DIR register which is at offset 0x10 from Aligned Base, and as a
result will result in setting DIR register of PORTC instead.

Signed-off-by: Ravik Hasija <ravikh@fb.com>
This commit is contained in:
Ravik Hasija 2022-09-22 13:03:50 -07:00 committed by Christopher Friedt
parent 7ba1925d97
commit 96da6f2234

View File

@ -196,7 +196,7 @@ static int gpio_dw_pin_interrupt_configure(const struct device *port,
}
/* Interrupt to be enabled but pin is not set to input */
dir_reg = dw_read(port_base_addr, dir_port) & BIT(pin);
dir_reg = dw_read(base_addr, dir_port) & BIT(pin);
if (dir_reg != 0U) {
return -EINVAL;
}
@ -245,7 +245,7 @@ static inline void dw_pin_config(const struct device *port,
/* Set init value then direction */
pin_is_output = (flags & GPIO_OUTPUT) != 0U;
dw_set_bit(port_base_addr, dir_port, pin, pin_is_output);
dw_set_bit(base_addr, dir_port, pin, pin_is_output);
if (pin_is_output) {
if ((flags & GPIO_OUTPUT_INIT_HIGH) != 0U) {