blob: adb1ef30ecaa425cff964ee2c711714a452a8911 [file] [log] [blame]
Harald Welte31f817c2017-02-03 22:21:32 +01001/* Code to control the PERST lines of attached modems
2 *
3 * Depending on the board this is running on, it might be possible
4 * for the controller to set the status of the PERST input line of
5 * the cellular modem. If the board supports this, it sets the
6 * PIN_PERST1 and/or PIN_PERST2 defines in its board.h file.
7 */
8
9#include "board.h"
10#include "wwan_perst.h"
11
12#ifdef PIN_PERST1
13static const Pin pin_perst1 = PIN_PERST1;
14#endif
15
16#ifdef PIN_PERST2
17static const Pin pin_perst2 = PIN_PERST2;
18#endif
19
20int wwan_perst_do_reset(int modem_nr)
21{
22 static const Pin *pin;
23
24 switch (modem_nr) {
25#ifdef PIN_PERST1
26 case 1:
27 pin = &pin_perst1;
28 break;
29#endif
30#ifdef PIN_PERST2
31 case 2:
32 pin = &pin_perst2;
33 break;
34#endif
35 default:
36 return -1;
37 }
38 PIO_Clear(pin);
39 mdelay(1);
40 PIO_Set(pin);
41 return 0;
42}
43
44int wwan_perst_init(void)
45{
46 int num_perst = 0;
47#ifdef PIN_PERST1
48 PIO_Configure(&pin_perst1, 1);
49 num_perst++;
50#endif
51
52#ifdef PIN_PERST2
53 PIO_Configure(&pin_perst2, 1);
54 num_perst++;
55#endif
56 return num_perst;
57}