diff options
author | Harald Welte <laforge@gnumonks.org> | 2017-02-03 22:21:32 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-02-03 22:22:20 +0100 |
commit | 31f817c3ac270b1bae83f18ed63e3adf043e96bc (patch) | |
tree | b97e319cb8c19c5d36f4732345b656256345f913 | |
parent | 83207e0cadfea41246ac6e62afaa5d03ead6e83c (diff) |
Add support for controlling PERST of WWAN modems (on qmod)
-rw-r--r-- | firmware/Makefile | 2 | ||||
-rw-r--r-- | firmware/include_board/qmod/board.h | 5 | ||||
-rw-r--r-- | firmware/src_simtrace/wwan_perst.c | 57 | ||||
-rw-r--r-- | firmware/src_simtrace/wwan_perst.h | 4 |
4 files changed, 67 insertions, 1 deletions
diff --git a/firmware/Makefile b/firmware/Makefile index d7a5586..493193d 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -147,7 +147,7 @@ C_CMSIS = core_cm3.o C_LOWLEVEL = board_cstartup_gnu.o board_lowlevel.o syscalls.o exceptions.o C_LIBLEVEL = spi.o pio.o pmc.o usart.o pio_it.o pio_capture.o uart_console.o iso7816_4.o wdt.o led.o tc.o unique_id.o C_CCID = cciddriver.o USBD.o USBDDriver.o USBD_HAL.o USBRequests.o USBDCallbacks.o USBDescriptors.o USBDDriverCallbacks.o -C_SIMTRACE = simtrace_iso7816.o usb.o ccid.o sniffer.o mitm.o ringbuffer.o host_communication.o iso7816_fidi.o tc_etu.o req_ctx.o card_emu.o mode_cardemu.o i2c.o wwan_led.o +C_SIMTRACE = simtrace_iso7816.o usb.o ccid.o sniffer.o mitm.o ringbuffer.o host_communication.o iso7816_fidi.o tc_etu.o req_ctx.o card_emu.o mode_cardemu.o i2c.o wwan_led.o wwan_perst.o C_APPLEVEL = main.o C_OBJECTS = $(C_CMSIS) $(C_LOWLEVEL) $(C_LIBLEVEL) $(C_APPLEVEL) $(C_CCID) $(C_SIMTRACE) diff --git a/firmware/include_board/qmod/board.h b/firmware/include_board/qmod/board.h index 5b5c751..e970447 100644 --- a/firmware/include_board/qmod/board.h +++ b/firmware/include_board/qmod/board.h @@ -48,6 +48,11 @@ #define PIN_WWAN2 {PIO_PA16, PIOA, ID_PIOA, PIO_INPUT, PIO_PULLUP | PIO_DEGLITCH | PIO_IT_EDGE} #define PINS_WWAN_IN { PIN_WWAN1, PIN_WWAN2 } +/* outputs controlling RESET input of modems */ +#define PIN_PERST1 {PIO_PA25, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_PULLUP} +#define PIN_PERST2 {PIO_PA26, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_PULLUP} +#define PINS_PERST { PIN_PERST1, PIN_PERST2 } + #define SIMTRACE_VENDOR_ID 0x1d50 #define SIMTRACE_PRODUCT_ID 0x60e3 /* FIXME */ #define USB_VENDOR_ID SIMTRACE_VENDOR_ID diff --git a/firmware/src_simtrace/wwan_perst.c b/firmware/src_simtrace/wwan_perst.c new file mode 100644 index 0000000..adb1ef3 --- /dev/null +++ b/firmware/src_simtrace/wwan_perst.c @@ -0,0 +1,57 @@ +/* Code to control the PERST lines of attached modems + * + * Depending on the board this is running on, it might be possible + * for the controller to set the status of the PERST input line of + * the cellular modem. If the board supports this, it sets the + * PIN_PERST1 and/or PIN_PERST2 defines in its board.h file. + */ + +#include "board.h" +#include "wwan_perst.h" + +#ifdef PIN_PERST1 +static const Pin pin_perst1 = PIN_PERST1; +#endif + +#ifdef PIN_PERST2 +static const Pin pin_perst2 = PIN_PERST2; +#endif + +int wwan_perst_do_reset(int modem_nr) +{ + static const Pin *pin; + + switch (modem_nr) { +#ifdef PIN_PERST1 + case 1: + pin = &pin_perst1; + break; +#endif +#ifdef PIN_PERST2 + case 2: + pin = &pin_perst2; + break; +#endif + default: + return -1; + } + PIO_Clear(pin); + mdelay(1); + PIO_Set(pin); + return 0; +} + +int wwan_perst_init(void) +{ + int num_perst = 0; +#ifdef PIN_PERST1 + PIO_Configure(&pin_perst1, 1); + num_perst++; +#endif + +#ifdef PIN_PERST2 + PIO_Configure(&pin_perst2, 1); + num_perst++; +#endif + return num_perst; +} diff --git a/firmware/src_simtrace/wwan_perst.h b/firmware/src_simtrace/wwan_perst.h new file mode 100644 index 0000000..8997a52 --- /dev/null +++ b/firmware/src_simtrace/wwan_perst.h @@ -0,0 +1,4 @@ +#pragma once + +int wwan_perst_do_reset(int modem_nr); +int wwan_perst_init(void); |