Skip to content

Commit

Permalink
modem/alt1250: Add implements for PM notify() function
Browse files Browse the repository at this point in the history
Add detail implementation for PM notify() callback function.
This function adds processing to put ALT1250 into hibernation mode.
  • Loading branch information
SPRESENSE committed Jan 26, 2023
1 parent 53f9cfa commit 0d5ea8d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 15 deletions.
33 changes: 32 additions & 1 deletion drivers/modem/alt1250/alt1250.c
Expand Up @@ -649,6 +649,7 @@ static int alt1250_power_control(FAR struct alt1250_dev_s *dev,

#ifdef CONFIG_PM
case LTE_CMDID_STOPAPI:
case LTE_CMDID_SUSPEND:
alt1250_receive_daemon_response(req);
break;
#endif
Expand Down Expand Up @@ -1406,7 +1407,37 @@ static int alt1250_pm_prepare(struct pm_callback_s *cb, int domain,
static void alt1250_pm_notify(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate)
{
/* TODO: Implement Notify process */
bool power;

/* ALT1250's power management only supports BOARD_PM_APPS */

if ((domain == BOARD_PM_APPS) && (pmstate == PM_SLEEP))
{
power = altmdm_get_powersupply(g_alt1250_dev->lower);

if (power)
{
/* Set retry mode for SPI driver */

altmdm_set_pm_event(EVENT_RETRYREQ, true);

/* Send suspend request to daemon */

alt1250_send_daemon_request(ALT1250_EVTBIT_SUSPEND);

/* Set suspend mode for SPI driver */

altmdm_set_pm_event(EVENT_SUSPEND, true);

/* Waiting for entering sleep state */

nxsem_wait_uninterruptible(&g_alt1250_dev->rxthread_sem);

/* Enable LTE hibernation mode for wakeup from LTE */

g_alt1250_dev->lower->hiber_mode(true);
}
}
}
#endif

Expand Down
12 changes: 0 additions & 12 deletions drivers/modem/alt1250/altmdm.c
Expand Up @@ -45,18 +45,6 @@
* Pre-processor Definitions
****************************************************************************/

#define EVENT_POWERON (1 << 0)
#define EVENT_POWEROFF (1 << 1)
#define EVENT_RESET (1 << 2)
#define EVENT_WLOCK (1 << 3)
#define EVENT_TXREQ (1 << 4)
#define EVENT_RXREQ (1 << 5)
#define EVENT_TXSUSTO (1 << 6)
#define EVENT_DESTROY (1 << 7)
#define EVENT_SUSPEND (1 << 8)
#define EVENT_RESUME (1 << 9)
#define EVENT_RETRYREQ (1 << 10)

#define TX_DONE (1 << 0)
#define TX_CANCEL (1 << 1)

Expand Down
12 changes: 12 additions & 0 deletions drivers/modem/alt1250/altmdm.h
Expand Up @@ -33,6 +33,18 @@
* Pre-processor Definitions
****************************************************************************/

#define EVENT_POWERON (1 << 0)
#define EVENT_POWEROFF (1 << 1)
#define EVENT_RESET (1 << 2)
#define EVENT_WLOCK (1 << 3)
#define EVENT_TXREQ (1 << 4)
#define EVENT_RXREQ (1 << 5)
#define EVENT_TXSUSTO (1 << 6)
#define EVENT_DESTROY (1 << 7)
#define EVENT_SUSPEND (1 << 8)
#define EVENT_RESUME (1 << 9)
#define EVENT_RETRYREQ (1 << 10)

#define ALTMDM_RETURN_RESET_V1 (-1)
#define ALTMDM_RETURN_NOTREADY (-2)
#define ALTMDM_RETURN_CANCELED (-3)
Expand Down
5 changes: 3 additions & 2 deletions include/nuttx/modem/alt1250.h
Expand Up @@ -57,9 +57,10 @@
#define ALT1250_IOC_SETEVTBUFF _MODEMIOC(3)
#define ALT1250_IOC_EXCHGCONTAINER _MODEMIOC(4)

#define ALT1250_EVTBIT_RESET (1ULL << 63)
#define ALT1250_EVTBIT_REPLY (1ULL << 62)
#define ALT1250_EVTBIT_RESET (1ULL << 63)
#define ALT1250_EVTBIT_REPLY (1ULL << 62)
#define ALT1250_EVTBIT_STOPAPI (1ULL << 61)
#define ALT1250_EVTBIT_SUSPEND (1ULL << 60)

/* Number of sockets */

Expand Down
1 change: 1 addition & 0 deletions include/nuttx/wireless/lte/lte_ioctl.h
Expand Up @@ -152,6 +152,7 @@
#define LTE_CMDID_LOGLSEEK _CMDGRP_NORMAL(0x39)
#define LTE_CMDID_LOGREMOVE _CMDGRP_NORMAL(0x3a)
#define LTE_CMDID_STOPAPI _CMDGRP_NORMAL(0x3b)
#define LTE_CMDID_SUSPEND _CMDGRP_NORMAL(0x3c)

#define LTE_CMDID_ACCEPT _CMDGRP_NORMAL(0x50)
#define LTE_CMDID_BIND _CMDGRP_NORMAL(0x51)
Expand Down

0 comments on commit 0d5ea8d

Please sign in to comment.