Skip to content

Commit 07de64e

Browse files
committed
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 <[email protected]>
1 parent fd58043 commit 07de64e

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

drivers/modem/modem_context.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ struct modem_cmd_handler {
5151
struct modem_pin {
5252
struct device *gpio_port_dev;
5353
char *dev_name;
54-
u32_t pin;
55-
int init_flags;
54+
gpio_pin_t pin;
55+
gpio_flags_t init_flags;
5656
};
5757

5858
struct modem_context {
@@ -128,7 +128,7 @@ int modem_context_register(struct modem_context *ctx);
128128
/* pin config functions */
129129
int modem_pin_read(struct modem_context *ctx, u32_t pin);
130130
int modem_pin_write(struct modem_context *ctx, u32_t pin, u32_t value);
131-
int modem_pin_config(struct modem_context *ctx, u32_t pin, int flags);
131+
int modem_pin_config(struct modem_context *ctx, u32_t pin, bool enable);
132132
int modem_pin_init(struct modem_context *ctx);
133133

134134
#ifdef __cplusplus

drivers/modem/modem_pin.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ int modem_pin_write(struct modem_context *ctx, u32_t pin, u32_t value)
3636
ctx->pins[pin].pin, value);
3737
}
3838

39-
int modem_pin_config(struct modem_context *ctx, u32_t pin, int flags)
39+
int modem_pin_config(struct modem_context *ctx, u32_t pin, bool enable)
4040
{
4141
if (pin < 0 || pin >= ctx->pins_len) {
4242
return -ENODEV;
4343
}
4444

4545
return gpio_pin_configure(ctx->pins[pin].gpio_port_dev,
46-
ctx->pins[pin].pin, flags);
46+
ctx->pins[pin].pin,
47+
enable ? cts->pins[pin].flags : GPIO_INPUT);
4748
}
4849

4950
int modem_pin_init(struct modem_context *ctx)
@@ -58,9 +59,7 @@ int modem_pin_init(struct modem_context *ctx)
5859
return -ENODEV;
5960
}
6061

61-
ret = gpio_pin_configure(ctx->pins[i].gpio_port_dev,
62-
ctx->pins[i].pin,
63-
ctx->pins[i].init_flags);
62+
ret = modem_pin_config(ctx, i, true);
6463
if (ret < 0) {
6564
return ret;
6665
}

drivers/modem/ublox-sara-r4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ static int pin_init(void)
679679
k_sleep(K_SECONDS(10));
680680
#endif
681681

682-
modem_pin_config(&mctx, MDM_POWER, GPIO_DIR_IN);
682+
modem_pin_config(&mctx, MDM_POWER, false);
683683

684684
LOG_INF("... Done!");
685685

0 commit comments

Comments
 (0)