mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
drivers/modem/alt1250: Update alt1250 driver
Updated alt1250 driver with regarding to the following changes. - Add LTE hibernation feature - Split source code per module - Some refactoring - Some bug fixes
This commit is contained in:
@@ -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"
|
||||
@@ -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);
|
||||
@@ -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,
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -56,7 +56,7 @@ extern "C"
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_alt1250_initialize(const char *devpath);
|
||||
int board_alt1250_initialize(FAR const char *devpath);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_alt1250_uninitialize
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -65,14 +65,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);
|
||||
cxd56_gpio_write(ALT1250_SHUTDOWN, true);
|
||||
|
||||
board_power_control(POWER_LTE, true);
|
||||
}
|
||||
|
||||
@@ -86,12 +78,40 @@ void board_alt1250_poweron(void)
|
||||
|
||||
void board_alt1250_poweroff(void)
|
||||
{
|
||||
/* Power off Altair modem device */
|
||||
|
||||
board_power_control(POWER_LTE, false);
|
||||
}
|
||||
|
||||
cxd56_gpio_write(ALT1250_SHUTDOWN, false);
|
||||
cxd56_gpio_write(ALT1250_LTE_POWER_BUTTON, false);
|
||||
/****************************************************************************
|
||||
* Name: board_alt1250_powerstatus
|
||||
*
|
||||
* Description:
|
||||
* Get the power status for the Altair modem device on the board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -124,7 +144,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 */
|
||||
|
||||
@@ -135,7 +155,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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user