Skip to content

drivers: gpio: designware: add alif pinctrl support#338

Open
timKnodel wants to merge 1 commit intoalifsemi:mainfrom
timKnodel:f/add-gpio-pinmux
Open

drivers: gpio: designware: add alif pinctrl support#338
timKnodel wants to merge 1 commit intoalifsemi:mainfrom
timKnodel:f/add-gpio-pinmux

Conversation

@timKnodel
Copy link
Copy Markdown

To dynamically control gpio pull-up/pull-down through the gpio API the designware driver needs to call the Alif pinctrl if CONFIG_PINCTRL_ALIF is enabled. This moves some of the helper functions from the c file to the header file to simplify the driver.

@arashed-alif
Copy link
Copy Markdown

Hi @RupeshKumar-AlifSemi, can you please review this improvement?

@RupeshKumar-AlifSemi RupeshKumar-AlifSemi requested review from a team and Copilot January 22, 2026 00:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables dynamic GPIO pull-up/pull-down control in the DesignWare GPIO driver by integrating Alif pinctrl support. The changes refactor pinctrl definitions to be shared between drivers.

Changes:

  • Moved pinctrl macros and definitions from pinctrl_alif.c to pinctrl_soc.h header for reusability
  • Added pull-up/pull-down configuration support in the DesignWare GPIO driver when CONFIG_PINCTRL_ALIF is enabled
  • Introduced DSC (Driver State Control) constants for different pull modes

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
soc/alif/common/pinctrl_soc.h Added LPGPIO documentation, DSC constants, and relocated shared pinctrl macros from driver
drivers/pinctrl/pinctrl_alif.c Removed duplicate definitions now in header, added reference to pinctrl_soc.h
drivers/gpio/gpio_dw.c Added conditional pinctrl integration for dynamic pull-up/pull-down configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AnttiKauppila-AlifSemi
Copy link
Copy Markdown
Contributor

CI fails because of:

  • check_patch_output='0001-drivers-gpio-designware-add-alif-pinctrl-support.patch:47: WARNING:LINE_SPACING: Missing a blank line after declarations
    22:47:16 manifest: Updates HAL Alif #47: FILE: drivers/gpio/gpio_dw.c:307:
    22:47:16 + uint32_t *pinctrl_addr;
    22:47:16 + if (LPGPIO_PINCTRL_BASE && (GET_PINMUX_PORT(port_pin_value) == LPGPIO_PORT)) {
    22:47:16
    22:47:16 0001-drivers-gpio-designware-add-alif-pinctrl-support.patch:73: ERROR:C99_COMMENTS: do not use C99 // comments
    22:47:16 Bluetooth: add automatic connection update #73: FILE: drivers/gpio/gpio_dw.c:333:
    22:47:16 +#endif // CONFIG_PINCTRL_ALIF
    22:47:16
    22:47:16 0001-drivers-gpio-designware-add-alif-pinctrl-support.patch:194: WARNING:LONG_LINE: line length of 108 exceeds 100 columns
    22:47:16 Power management updates and B1 A5 support #194: FILE: soc/alif/common/pinctrl_soc.h:77:
    22:47:16 +#define GPIO_PORT_FROM_ADDRESS(x) (x < GPIO_PORT_BASE_ADDRESS ? 15U : (x - GPIO_PORT_BASE_ADDRESS) / 0x1000)

To dynamically control gpio pull-up/pull-down through the
gpio API the designware driver needs to call the alif
pinctrl if CONFIG_PINCTRL_ALIF is enabled.

Signed-off-by: Tim Knodel <tbk@google.com>
@timKnodel
Copy link
Copy Markdown
Author

Formatting issues fixed.

@RupeshKumar-AlifSemi RupeshKumar-AlifSemi requested review from a team February 6, 2026 05:00
* 0x1000 away from the base address in port order.
*/
#define GPIO_PORT_FROM_ADDRESS(x) \
(x < GPIO_PORT_BASE_ADDRESS ? 15U : (x - GPIO_PORT_BASE_ADDRESS) / 0x1000)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would not this fail for GPIO16 (0x4300_A000) and GPIO 17 (0x4300_B000) ?

}

#if CONFIG_PINCTRL_ALIF
uint32_t port_pin_value = (GPIO_PORT_FROM_ADDRESS(context->base_addr) << 3U) | (pin & 0x7U);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uint32_t port_pin_value = (GPIO_PORT_FROM_ADDRESS(context->base_addr) << 3U) | (pin & 0x7U);
uint32_t port_pin_value = ((GPIO_PORT_FROM_ADDRESS(context->base_addr) << 3U) | (pin & 0x7U)) << PIN_FUNC_SHIFT;

uint32_t *pinctrl_addr;

if (LPGPIO_PINCTRL_BASE && (GET_PINMUX_PORT(port_pin_value) == LPGPIO_PORT)) {
pinctrl_addr = (uint32_t *)LPGPIO_PINMUX_ADDR(port_pin_value);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the above suggested change (to shift port_pin_value by PIN_FUNC_SHIFT), we might break this calculation of pinctrl_addr. So this will need to be handled separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants