drivers: modem: clean up pin configuration
After startup ublox-sara-r4 code sets the MDM_POWER signal to input using a deprecated configuration macro. This was the only use of the modem context API to configure a pin. Refactor the API to not take the flags as an input but instead select between the flags to be used when the pin is active and a disconnected state. Use this API instead of a separate direct configure call when initializing the modem pins. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
a8a2b48317
commit
97106bf95e
3 changed files with 8 additions and 9 deletions
|
@ -51,8 +51,8 @@ struct modem_cmd_handler {
|
|||
struct modem_pin {
|
||||
struct device *gpio_port_dev;
|
||||
char *dev_name;
|
||||
u32_t pin;
|
||||
int init_flags;
|
||||
gpio_pin_t pin;
|
||||
gpio_flags_t init_flags;
|
||||
};
|
||||
|
||||
struct modem_context {
|
||||
|
@ -128,7 +128,7 @@ int modem_context_register(struct modem_context *ctx);
|
|||
/* pin config functions */
|
||||
int modem_pin_read(struct modem_context *ctx, u32_t pin);
|
||||
int modem_pin_write(struct modem_context *ctx, u32_t pin, u32_t value);
|
||||
int modem_pin_config(struct modem_context *ctx, u32_t pin, int flags);
|
||||
int modem_pin_config(struct modem_context *ctx, u32_t pin, bool enable);
|
||||
int modem_pin_init(struct modem_context *ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -36,14 +36,15 @@ int modem_pin_write(struct modem_context *ctx, u32_t pin, u32_t value)
|
|||
ctx->pins[pin].pin, value);
|
||||
}
|
||||
|
||||
int modem_pin_config(struct modem_context *ctx, u32_t pin, int flags)
|
||||
int modem_pin_config(struct modem_context *ctx, u32_t pin, bool enable)
|
||||
{
|
||||
if (pin < 0 || pin >= ctx->pins_len) {
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
return gpio_pin_configure(ctx->pins[pin].gpio_port_dev,
|
||||
ctx->pins[pin].pin, flags);
|
||||
ctx->pins[pin].pin,
|
||||
enable ? cts->pins[pin].flags : GPIO_INPUT);
|
||||
}
|
||||
|
||||
int modem_pin_init(struct modem_context *ctx)
|
||||
|
@ -58,9 +59,7 @@ int modem_pin_init(struct modem_context *ctx)
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = gpio_pin_configure(ctx->pins[i].gpio_port_dev,
|
||||
ctx->pins[i].pin,
|
||||
ctx->pins[i].init_flags);
|
||||
ret = modem_pin_config(ctx, i, true);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -679,7 +679,7 @@ static int pin_init(void)
|
|||
k_sleep(K_SECONDS(10));
|
||||
#endif
|
||||
|
||||
modem_pin_config(&mctx, MDM_POWER, GPIO_DIR_IN);
|
||||
modem_pin_config(&mctx, MDM_POWER, false);
|
||||
|
||||
LOG_INF("... Done!");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue