modem: remove 'modem_pin' abstraction
All drivers using 'modem_pin' abstraction were converted already, so remove its implementation now. Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
This commit is contained in:
parent
41c618dbf7
commit
ec6026ccdd
4 changed files with 2 additions and 111 deletions
|
@ -5,10 +5,7 @@ zephyr_library()
|
||||||
zephyr_library_sources_ifdef(CONFIG_MODEM_RECEIVER modem_receiver.c)
|
zephyr_library_sources_ifdef(CONFIG_MODEM_RECEIVER modem_receiver.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_MODEM_SHELL modem_shell.c)
|
zephyr_library_sources_ifdef(CONFIG_MODEM_SHELL modem_shell.c)
|
||||||
|
|
||||||
zephyr_library_sources_ifdef(CONFIG_MODEM_CONTEXT
|
zephyr_library_sources_ifdef(CONFIG_MODEM_CONTEXT modem_context.c)
|
||||||
modem_context.c
|
|
||||||
modem_pin.c
|
|
||||||
)
|
|
||||||
|
|
||||||
zephyr_library_sources_ifdef(CONFIG_MODEM_IFACE_UART_INTERRUPT modem_iface_uart_interrupt.c)
|
zephyr_library_sources_ifdef(CONFIG_MODEM_IFACE_UART_INTERRUPT modem_iface_uart_interrupt.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_MODEM_IFACE_UART_ASYNC modem_iface_uart_async.c)
|
zephyr_library_sources_ifdef(CONFIG_MODEM_IFACE_UART_ASYNC modem_iface_uart_async.c)
|
||||||
|
|
|
@ -128,22 +128,9 @@ struct modem_context *modem_context_from_id(int id)
|
||||||
|
|
||||||
int modem_context_register(struct modem_context *ctx)
|
int modem_context_register(struct modem_context *ctx)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = modem_context_get(ctx);
|
return modem_context_get(ctx);
|
||||||
if (ret < 0) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = modem_pin_init(ctx);
|
|
||||||
if (ret < 0) {
|
|
||||||
LOG_ERR("modem pin init error: %d", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MODEM_PIN(name_, pin_, flags_) { \
|
|
||||||
.dev_name = name_, \
|
|
||||||
.pin = pin_, \
|
|
||||||
.init_flags = flags_ \
|
|
||||||
}
|
|
||||||
|
|
||||||
struct modem_iface {
|
struct modem_iface {
|
||||||
const struct device *dev;
|
const struct device *dev;
|
||||||
|
|
||||||
|
@ -49,13 +43,6 @@ struct modem_cmd_handler {
|
||||||
void *cmd_handler_data;
|
void *cmd_handler_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct modem_pin {
|
|
||||||
const struct device *gpio_port_dev;
|
|
||||||
char *dev_name;
|
|
||||||
gpio_pin_t pin;
|
|
||||||
gpio_flags_t init_flags;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct modem_context {
|
struct modem_context {
|
||||||
/* modem data */
|
/* modem data */
|
||||||
char *data_manufacturer;
|
char *data_manufacturer;
|
||||||
|
@ -73,9 +60,6 @@ struct modem_context {
|
||||||
#endif
|
#endif
|
||||||
int *data_rssi;
|
int *data_rssi;
|
||||||
bool is_automatic_oper;
|
bool is_automatic_oper;
|
||||||
/* pin config */
|
|
||||||
struct modem_pin *pins;
|
|
||||||
size_t pins_len;
|
|
||||||
|
|
||||||
/* interface config */
|
/* interface config */
|
||||||
struct modem_iface iface;
|
struct modem_iface iface;
|
||||||
|
@ -137,12 +121,6 @@ struct modem_context *modem_context_from_iface_dev(const struct device *dev);
|
||||||
*/
|
*/
|
||||||
int modem_context_register(struct modem_context *ctx);
|
int modem_context_register(struct modem_context *ctx);
|
||||||
|
|
||||||
/* pin config functions */
|
|
||||||
int modem_pin_read(struct modem_context *ctx, uint32_t pin);
|
|
||||||
int modem_pin_write(struct modem_context *ctx, uint32_t pin, uint32_t value);
|
|
||||||
int modem_pin_config(struct modem_context *ctx, uint32_t pin, bool enable);
|
|
||||||
int modem_pin_init(struct modem_context *ctx);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
/** @file
|
|
||||||
* @brief Modem pin setup for modem context driver
|
|
||||||
*
|
|
||||||
* GPIO-based pin handling for the modem context driver
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 Foundries.io
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <zephyr/types.h>
|
|
||||||
#include <zephyr/device.h>
|
|
||||||
#include <zephyr/drivers/gpio.h>
|
|
||||||
|
|
||||||
#include "modem_context.h"
|
|
||||||
|
|
||||||
int modem_pin_read(struct modem_context *ctx, uint32_t pin)
|
|
||||||
{
|
|
||||||
if (pin >= ctx->pins_len) {
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
return gpio_pin_get(ctx->pins[pin].gpio_port_dev,
|
|
||||||
ctx->pins[pin].pin);
|
|
||||||
}
|
|
||||||
|
|
||||||
int modem_pin_write(struct modem_context *ctx, uint32_t pin, uint32_t value)
|
|
||||||
{
|
|
||||||
if (pin >= ctx->pins_len) {
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
return gpio_pin_set(ctx->pins[pin].gpio_port_dev,
|
|
||||||
ctx->pins[pin].pin, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
int modem_pin_config(struct modem_context *ctx, uint32_t pin, bool enable)
|
|
||||||
{
|
|
||||||
if (pin >= ctx->pins_len) {
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
return gpio_pin_configure(ctx->pins[pin].gpio_port_dev,
|
|
||||||
ctx->pins[pin].pin,
|
|
||||||
enable ? ctx->pins[pin].init_flags :
|
|
||||||
GPIO_INPUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
int modem_pin_init(struct modem_context *ctx)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
/* setup port devices and pin directions */
|
|
||||||
for (i = 0; i < ctx->pins_len; i++) {
|
|
||||||
ctx->pins[i].gpio_port_dev =
|
|
||||||
device_get_binding(ctx->pins[i].dev_name);
|
|
||||||
if (!ctx->pins[i].gpio_port_dev) {
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = modem_pin_config(ctx, i, true);
|
|
||||||
if (ret < 0) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue