Skip to content

Commit 41c618d

Browse files
mniestrojcarlescufi
authored andcommitted
modem: simcom-sim7080: use 'gpio_dt_spec' instead of 'modem_pin'
Move away from 'modem_pin' abstraction as it has not obvious value compared to generic 'gpio_dt_spec'. Signed-off-by: Marcin Niestroj <[email protected]>
1 parent 9353b6e commit 41c618d

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

drivers/modem/simcom-sim7080.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ static K_KERNEL_STACK_DEFINE(modem_rx_stack, CONFIG_MODEM_SIMCOM_SIM7080_RX_STAC
3030
static K_KERNEL_STACK_DEFINE(modem_workq_stack, CONFIG_MODEM_SIMCOM_SIM7080_RX_WORKQ_STACK_SIZE);
3131
NET_BUF_POOL_DEFINE(mdm_recv_pool, MDM_RECV_MAX_BUF, MDM_RECV_BUF_SIZE, 0, NULL);
3232

33+
/* pin settings */
34+
static const struct gpio_dt_spec power_gpio = GPIO_DT_SPEC_INST_GET(0, mdm_power_gpios);
35+
3336
static void socket_close(struct modem_socket *sock);
3437
const struct socket_dns_offload offload_dns_ops;
3538

@@ -1225,9 +1228,9 @@ static int modem_pdp_activate(void)
12251228
static void modem_pwrkey(void)
12261229
{
12271230
/* Power pin should be high for 1.5 seconds. */
1228-
modem_pin_write(&mctx, 0, 1);
1231+
gpio_pin_set_dt(&power_gpio, 1);
12291232
k_sleep(K_MSEC(1500));
1230-
modem_pin_write(&mctx, 0, 0);
1233+
gpio_pin_set_dt(&power_gpio, 0);
12311234
k_sleep(K_SECONDS(5));
12321235
}
12331236

@@ -2371,8 +2374,12 @@ static int modem_init(const struct device *dev)
23712374
#endif /* #if defined(CONFIG_MODEM_SIM_NUMBERS) */
23722375
mctx.data_rssi = &mdata.mdm_rssi;
23732376

2374-
mctx.pins = modem_pins;
2375-
mctx.pins_len = ARRAY_SIZE(modem_pins);
2377+
ret = gpio_pin_configure_dt(&power_gpio, GPIO_OUTPUT_LOW);
2378+
if (ret < 0) {
2379+
LOG_ERR("Failed to configure %s pin", "power");
2380+
goto error;
2381+
}
2382+
23762383
mctx.driver_data = &mdata;
23772384

23782385
memset(&gnss_data, 0, sizeof(gnss_data));

drivers/modem/simcom-sim7080.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,6 @@ struct sim7080_data {
167167
struct k_sem sem_ftp;
168168
};
169169

170-
/*
171-
* Pin definitions
172-
*/
173-
static struct modem_pin modem_pins[] = { MODEM_PIN(
174-
DT_INST_GPIO_LABEL(0, mdm_power_gpios), DT_INST_GPIO_PIN(0, mdm_power_gpios),
175-
DT_INST_GPIO_FLAGS(0, mdm_power_gpios) | GPIO_OUTPUT_LOW) };
176-
177170
/*
178171
* Socket read callback data.
179172
*/

tests/drivers/build_all/modem/modem_simcom_sim7080.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
CONFIG_TEST=y
22
CONFIG_TEST_RANDOM_GENERATOR=y
33
CONFIG_SERIAL=y
4+
CONFIG_GPIO=y
45
CONFIG_NETWORKING=y
56
CONFIG_NET_SOCKETS=y
67
CONFIG_MODEM=y

0 commit comments

Comments
 (0)