drivers: gpio: add combined drive strength flags and mask
Introduce combined GPIO drive strength flags for GPIO controllers only supporting either default or alternative drive strength regardless if the pin is driven to a high or a low level. Fixes: #30329 Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
671ab46e2b
commit
2e8cc9f9b0
9 changed files with 26 additions and 13 deletions
|
@ -328,7 +328,7 @@ static int gpio_b91_pin_configure(const struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Strengths not implemented */
|
/* Strengths not implemented */
|
||||||
if ((flags & (GPIO_DS_ALT_LOW | GPIO_DS_ALT_HIGH)) != 0) {
|
if ((flags & GPIO_DS_ALT) != 0) {
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ static int cy8c95xx_config(const struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Strengths not implemented */
|
/* Strengths not implemented */
|
||||||
if ((flags & (GPIO_DS_ALT_LOW | GPIO_DS_ALT_HIGH)) != 0) {
|
if ((flags & GPIO_DS_ALT) != 0) {
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,11 +140,11 @@ static int gpio_esp32_config(const struct device *dev,
|
||||||
* to either low or high states. Alternative drive strength is weak-only,
|
* to either low or high states. Alternative drive strength is weak-only,
|
||||||
* while any other intermediary combination is considered invalid.
|
* while any other intermediary combination is considered invalid.
|
||||||
*/
|
*/
|
||||||
switch (flags & (GPIO_DS_LOW_MASK | GPIO_DS_HIGH_MASK)) {
|
switch (flags & GPIO_DS_MASK) {
|
||||||
case GPIO_DS_DFLT_LOW | GPIO_DS_DFLT_HIGH:
|
case GPIO_DS_DFLT:
|
||||||
gpio_ll_set_drive_capability(cfg->gpio_base, io_pin, GPIO_DRIVE_CAP_3);
|
gpio_ll_set_drive_capability(cfg->gpio_base, io_pin, GPIO_DRIVE_CAP_3);
|
||||||
break;
|
break;
|
||||||
case GPIO_DS_ALT_LOW | GPIO_DS_ALT_HIGH:
|
case GPIO_DS_ALT:
|
||||||
gpio_ll_set_drive_capability(cfg->gpio_base, io_pin, GPIO_DRIVE_CAP_0);
|
gpio_ll_set_drive_capability(cfg->gpio_base, io_pin, GPIO_DRIVE_CAP_0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -98,12 +98,12 @@ static int gpio_mcux_configure(const struct device *dev,
|
||||||
|
|
||||||
#if defined(FSL_FEATURE_PORT_HAS_DRIVE_STRENGTH) && FSL_FEATURE_PORT_HAS_DRIVE_STRENGTH
|
#if defined(FSL_FEATURE_PORT_HAS_DRIVE_STRENGTH) && FSL_FEATURE_PORT_HAS_DRIVE_STRENGTH
|
||||||
/* Determine the drive strength */
|
/* Determine the drive strength */
|
||||||
switch (flags & (GPIO_DS_LOW_MASK | GPIO_DS_HIGH_MASK)) {
|
switch (flags & GPIO_DS_MASK) {
|
||||||
case GPIO_DS_DFLT_LOW | GPIO_DS_DFLT_HIGH:
|
case GPIO_DS_DFLT:
|
||||||
/* Default is low drive strength */
|
/* Default is low drive strength */
|
||||||
mask |= PORT_PCR_DSE_MASK;
|
mask |= PORT_PCR_DSE_MASK;
|
||||||
break;
|
break;
|
||||||
case GPIO_DS_ALT_LOW | GPIO_DS_ALT_HIGH:
|
case GPIO_DS_ALT:
|
||||||
/* Alternate is high drive strength */
|
/* Alternate is high drive strength */
|
||||||
pcr |= PORT_PCR_DSE_MASK;
|
pcr |= PORT_PCR_DSE_MASK;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -164,7 +164,7 @@ static int gpio_nrfx_config(const struct device *port,
|
||||||
|
|
||||||
switch (flags & (GPIO_DS_LOW_MASK | GPIO_DS_HIGH_MASK |
|
switch (flags & (GPIO_DS_LOW_MASK | GPIO_DS_HIGH_MASK |
|
||||||
GPIO_OPEN_DRAIN)) {
|
GPIO_OPEN_DRAIN)) {
|
||||||
case GPIO_DS_DFLT_LOW | GPIO_DS_DFLT_HIGH:
|
case GPIO_DS_DFLT:
|
||||||
drive = NRF_GPIO_PIN_S0S1;
|
drive = NRF_GPIO_PIN_S0S1;
|
||||||
break;
|
break;
|
||||||
case GPIO_DS_DFLT_LOW | GPIO_DS_ALT_HIGH:
|
case GPIO_DS_DFLT_LOW | GPIO_DS_ALT_HIGH:
|
||||||
|
@ -177,7 +177,7 @@ static int gpio_nrfx_config(const struct device *port,
|
||||||
case GPIO_DS_ALT_LOW | GPIO_DS_DFLT_HIGH:
|
case GPIO_DS_ALT_LOW | GPIO_DS_DFLT_HIGH:
|
||||||
drive = NRF_GPIO_PIN_H0S1;
|
drive = NRF_GPIO_PIN_H0S1;
|
||||||
break;
|
break;
|
||||||
case GPIO_DS_ALT_LOW | GPIO_DS_ALT_HIGH:
|
case GPIO_DS_ALT:
|
||||||
drive = NRF_GPIO_PIN_H0H1;
|
drive = NRF_GPIO_PIN_H0H1;
|
||||||
break;
|
break;
|
||||||
case GPIO_DS_ALT_LOW | GPIO_OPEN_DRAIN:
|
case GPIO_DS_ALT_LOW | GPIO_OPEN_DRAIN:
|
||||||
|
|
|
@ -203,7 +203,7 @@ static int gpio_pca953x_config(const struct device *dev, gpio_pin_t pin,
|
||||||
* Until something more general is available reject any
|
* Until something more general is available reject any
|
||||||
* attempt to set a non-default drive strength.
|
* attempt to set a non-default drive strength.
|
||||||
*/
|
*/
|
||||||
if ((flags & (GPIO_DS_ALT_LOW | GPIO_DS_ALT_HIGH)) != 0) {
|
if ((flags & GPIO_DS_ALT) != 0) {
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ static int pcal6408a_pin_configure(const struct device *dev,
|
||||||
/* Drive strength configuration in this device is incompatible with
|
/* Drive strength configuration in this device is incompatible with
|
||||||
* the currently available GPIO API flags, hence it is not supported.
|
* the currently available GPIO API flags, hence it is not supported.
|
||||||
*/
|
*/
|
||||||
if ((flags & (GPIO_DS_ALT_LOW | GPIO_DS_ALT_HIGH)) != 0) {
|
if ((flags & GPIO_DS_ALT) != 0) {
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -313,7 +313,7 @@ static int sx1509b_config(const struct device *dev,
|
||||||
* Until something more general is available reject any
|
* Until something more general is available reject any
|
||||||
* attempt to set a non-default drive strength.
|
* attempt to set a non-default drive strength.
|
||||||
*/
|
*/
|
||||||
if ((flags & (GPIO_DS_ALT_LOW | GPIO_DS_ALT_HIGH)) != 0) {
|
if ((flags & GPIO_DS_ALT) != 0) {
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -259,6 +259,19 @@ extern "C" {
|
||||||
* use the default drive strength.
|
* use the default drive strength.
|
||||||
*/
|
*/
|
||||||
#define GPIO_DS_ALT_HIGH (0x1U << GPIO_DS_HIGH_POS)
|
#define GPIO_DS_ALT_HIGH (0x1U << GPIO_DS_HIGH_POS)
|
||||||
|
|
||||||
|
/** Combined default drive strength.
|
||||||
|
*/
|
||||||
|
#define GPIO_DS_DFLT (GPIO_DS_DFLT_LOW | GPIO_DS_DFLT_HIGH)
|
||||||
|
|
||||||
|
/** Combined alternative drive strength.
|
||||||
|
*/
|
||||||
|
#define GPIO_DS_ALT (GPIO_DS_ALT_LOW | GPIO_DS_ALT_HIGH)
|
||||||
|
|
||||||
|
/** @cond INTERNAL_HIDDEN */
|
||||||
|
#define GPIO_DS_MASK (GPIO_DS_LOW_MASK | GPIO_DS_HIGH_MASK)
|
||||||
|
/** @endcond */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/** @cond INTERNAL_HIDDEN */
|
/** @cond INTERNAL_HIDDEN */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue