Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support LTE Hibernation mode #14

Merged
merged 18 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
081be76
drivers/modem/alt1250: Update state machine for hibernation
SPRESENSE Oct 4, 2022
a0f9228
arm/cxd56xx: Fix build error in CONFIG_PM=y
SPRESENSE Oct 11, 2022
adb3fe8
drivers/modem/alt1250: Add PM callbacks
SPRESENSE Oct 11, 2022
c8b5a34
drivers/modem/alt1250: Use receive thread to kthread
SPRESENSE Nov 28, 2022
2b5b354
cxd56_power: Add lowerhalf interface to keep power when cold sleep
SPRESENSE Nov 28, 2022
1b271e9
cxd56_alt1250_power: Don't touch POWER_BUTTON/SHUTDOWN pins
SPRESENSE Nov 28, 2022
d9a4c32
cxd56_alt1250_power: Add board interface to get LTE power status
SPRESENSE Nov 28, 2022
b71e959
cxd56_alt1250_power: Add board interface to keep power when sleeping
SPRESENSE Nov 28, 2022
d859296
modem/alt1250: Add lowerhalf I/F to get LTE power supply status
SPRESENSE Nov 28, 2022
93c5086
modem/alt1250: Add lowerhalf I/F to set power manager
SPRESENSE Nov 28, 2022
0b558f1
modem/alt1250: Supports initialization when ALT1250 power is turned on
SPRESENSE Nov 28, 2022
890a8a0
modem/alt1250: Add interface to send request to alt1250 daemon
SPRESENSE Nov 28, 2022
53f9cfa
modem/alt1250: Add implements for PM prepare() function
SPRESENSE Nov 28, 2022
0d5ea8d
modem/alt1250: Add implements for PM notify() function
SPRESENSE Nov 28, 2022
1aea4d4
modem/alt1250: Add interface to set retry mode disable
SPRESENSE Nov 28, 2022
912ada1
modem/alt1250; Add interface to get LTE power supply status
SPRESENSE Nov 28, 2022
3cd5ef1
wireless/lte: Add interface for LTE hibernation mode
SPRESENSE Nov 28, 2022
7ebf86b
modem/alt1250: Keep alive when suspend event received
SPRESENSE Nov 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions arch/arm/src/cxd56xx/cxd56_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,13 @@ static void up_idlepm(void)
break;

case PM_STANDBY:
cxd56_pmstandby(true);
/* Not supported yet */

break;

case PM_SLEEP:
cxd56_pmsleep();
/* Not supported yet */

break;

default:
Expand Down
4 changes: 4 additions & 0 deletions boards/arm/cxd56xx/common/src/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ ifeq ($(CONFIG_BOARD_USBDEV_SERIALSTR),y)
CSRCS += cxd56_usbdevserialstr.c
endif

ifeq ($(CONFIG_PM),y)
CSRCS += cxd56_pm.c
endif

DEPPATH += --dep-path src
VPATH += :src
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src)
Expand Down
42 changes: 42 additions & 0 deletions boards/arm/cxd56xx/common/src/cxd56_alt1250.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

#include <arch/board/board.h>
#include <arch/board/cxd56_alt1250.h>
#include <arch/chip/pm.h>

#include "cxd56_spi.h"
#include "cxd56_dmac.h"
Expand Down Expand Up @@ -79,6 +80,8 @@

static struct spi_dev_s *alt1250_poweron(void);
static void alt1250_poweroff(void);
static bool alt1250_powerstatus(void);
static int alt1250_hibernation_mode(bool enable);
static void alt1250_reset(void);
static void alt1250_irqattach(xcpt_t handler);
static void alt1250_irqenable(bool enable);
Expand All @@ -95,6 +98,8 @@ static const struct alt1250_lower_s g_alt1250_lower =
{
.poweron = alt1250_poweron,
.poweroff = alt1250_poweroff,
.powerstatus = alt1250_powerstatus,
.hiber_mode = alt1250_hibernation_mode,
.reset = alt1250_reset,
.irqattach = alt1250_irqattach,
.irqenable = alt1250_irqenable,
Expand Down Expand Up @@ -292,6 +297,43 @@ static void alt1250_poweroff(void)
board_alt1250_poweroff();
}

/****************************************************************************
* Name: alt1250_powerstatus
*
* Description:
* Get the power status for the Altair modem device on the board.
*
****************************************************************************/

static bool alt1250_powerstatus(void)
{
return board_alt1250_powerstatus();
}

/****************************************************************************
* Name: alt1250_hibernation_mode
*
* Description:
* Set power manager for entering hibernation mode.
*
****************************************************************************/

static int alt1250_hibernation_mode(bool enable)
{
uint32_t bootmask = 0;

if (enable)
{
/* Set GPIO interrupt for wake-up */

bootmask = up_pm_get_bootmask();
bootmask |= PM_BOOT_COLD_GPIO;
up_pm_set_bootmask(bootmask);
}

return board_alt1250_powerkeep(enable);
}

/****************************************************************************
* Name: alt1250_reset
*
Expand Down
56 changes: 56 additions & 0 deletions boards/arm/cxd56xx/common/src/cxd56_pm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/****************************************************************************
* boards/arm/cxd56xx/common/src/cxd56_pm.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>
#include <nuttx/power/pm.h>

/****************************************************************************
* Public Functions
****************************************************************************/

/****************************************************************************
* Name: arm_pminitialize
*
* Description:
* This function is called by MCU-specific logic at power-on reset in
* order to provide one-time initialization the power management subsystem.
* This function must be called *very* early in the initialization sequence
* *before* any other device drivers are initialized (since they may
* attempt to register with the power management subsystem).
*
* Input Parameters:
* None.
*
* Returned Value:
* None.
*
****************************************************************************/

void arm_pminitialize(void)
{
/* Then initialize the NuttX power management subsystem proper */

pm_initialize();
}

5 changes: 5 additions & 0 deletions boards/arm/cxd56xx/spresense/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ enum board_power_device
#define BOARD_POWEROFF_DEEP (0)
#define BOARD_POWEROFF_COLD (1)

/* Power domain definitions **********************************************/

#define BOARD_PM_IDLE (0)
#define BOARD_PM_APPS (1)

/* CXD5247 audio control definitions ****************************************/

#define CXD5247_XRST PIN_SPI3_CS2_X
Expand Down
20 changes: 20 additions & 0 deletions boards/arm/cxd56xx/spresense/include/cxd56_alt1250.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,26 @@ void board_alt1250_poweron(void);

void board_alt1250_poweroff(void);

/****************************************************************************
* Name: board_alt1250_powerstatus
*
* Description:
* Get the power status for the Altair modem device on the board.
*
****************************************************************************/

bool board_alt1250_powerstatus(void);

/****************************************************************************
* Name: board_alt1250_powerkeep
*
* Description:
* Set Modem power keep mode when turning off the board.
*
****************************************************************************/

int board_alt1250_powerkeep(bool enable);

/****************************************************************************
* Name: board_alt1250_reset
*
Expand Down
20 changes: 20 additions & 0 deletions boards/arm/cxd56xx/spresense/include/cxd56_power.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,26 @@ bool board_xtal_power_monitor(void);

int board_lna_power_control(bool en);

/****************************************************************************
* Name: board_set_reset_gpo
*
* Description:
* Set gpo to off when power off the board.
*
****************************************************************************/

int board_set_reset_gpo(int target);

/****************************************************************************
* Name: board_unset_reset_gpo
*
* Description:
* Keep gpo status when power off the board.
*
****************************************************************************/

int board_unset_reset_gpo(int target);

#undef EXTERN
#if defined(__cplusplus)
}
Expand Down
58 changes: 34 additions & 24 deletions boards/arm/cxd56xx/spresense/src/cxd56_alt1250_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,6 @@ static sem_t g_wd_wait;

void board_alt1250_poweron(void)
{
/* Power on altair modem device */

cxd56_gpio_config(ALT1250_LTE_POWER_BUTTON, false);
cxd56_gpio_write(ALT1250_LTE_POWER_BUTTON, false);

cxd56_gpio_config(ALT1250_SHUTDOWN, false);

/* Workaround: Shutdown pin set to low before power on */

cxd56_gpio_write(ALT1250_SHUTDOWN, false);
nxsig_usleep(POWERON_DELAY_USEC);

cxd56_gpio_write(ALT1250_SHUTDOWN, true);

/* Workaround: Power button pin set to high before power on */

cxd56_gpio_write(ALT1250_LTE_POWER_BUTTON, true);

board_power_control(POWER_LTE, true);
}

Expand All @@ -98,12 +80,40 @@ void board_alt1250_poweron(void)

void board_alt1250_poweroff(void)
{
/* Power off Altair modem device */

board_power_control(POWER_LTE, false);
}

/****************************************************************************
* Name: board_alt1250_powerstatus
*
* Description:
* Get the power status for the Altair modem device on the board.
*
****************************************************************************/

cxd56_gpio_write(ALT1250_SHUTDOWN, false);
cxd56_gpio_write(ALT1250_LTE_POWER_BUTTON, false);
bool board_alt1250_powerstatus(void)
{
return board_power_monitor(POWER_LTE);
}

/****************************************************************************
* Name: board_alt1250_powerkeep
*
* Description:
* Set Modem power keep mode when turning off the board.
*
****************************************************************************/

int board_alt1250_powerkeep(bool enable)
{
if (enable)
{
return board_unset_reset_gpo(POWER_LTE);
}
else
{
return board_set_reset_gpo(POWER_LTE);
}
}

/****************************************************************************
Expand Down Expand Up @@ -136,7 +146,7 @@ void board_alt1250_reset(void)

/* Reset Altair modem device */

cxd56_gpio_write(ALT1250_SHUTDOWN, false);
board_alt1250_poweroff();

/* ALT1250_SHUTDOWN should be low in the range 101usec to 100msec */

Expand All @@ -147,7 +157,7 @@ void board_alt1250_reset(void)

nxsem_wait_uninterruptible(&g_wd_wait);

cxd56_gpio_write(ALT1250_SHUTDOWN, true);
board_alt1250_poweron();

nxsem_destroy(&g_wd_wait);
}
Expand Down
Loading