Skip to content

Commit

Permalink
cxd56/alt1250: Fix ALT1250 power control for power ON state
Browse files Browse the repository at this point in the history
  • Loading branch information
SPRESENSE authored Jul 4, 2023
2 parents 6c2a24b + 16d3066 commit 0fc2f95
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
40 changes: 28 additions & 12 deletions boards/arm/cxd56xx/common/src/cxd56_alt1250.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,15 @@
# error "Select LTE SPI 4 or 5"
#endif

#define ACTIVE_SHUTDOWN_TIME (100) /* ms */
#define POWER_ON_WAIT_TIME (2) /* ms */
#define ACTIVE_SHUTDOWN_TIME (100) /* ms */
#define TIME_TO_STABLE_VDDIO (10) /* ms */

/****************************************************************************
* Private Function Prototypes
****************************************************************************/

static struct spi_dev_s *alt1250_poweron(void);
static struct spi_dev_s *alt1250_poweron(bool keep_on);
static void alt1250_poweroff(void);
static bool alt1250_powerstatus(void);
static int alt1250_hibernation_mode(bool enable);
Expand Down Expand Up @@ -198,28 +200,46 @@ static void set_spiparam(struct spi_dev_s *spidev)
*
****************************************************************************/

static struct spi_dev_s *alt1250_poweron(void)
static struct spi_dev_s *alt1250_poweron(bool keep_on)
{
struct spi_dev_s *spi;
#if defined(CONFIG_CXD56_LTE_SPI4_DMAC) || defined(CONFIG_CXD56_LTE_SPI5_DMAC)
DMA_HANDLE hdl;
dma_config_t conf;
#endif

/* Drive SHUTDOWN and WAKEUP signal Low before power-on */
/* Hi-Z SHUTDOWN and PowerBTN signals before power-on */

cxd56_gpio_config(ALT1250_SHUTDOWN, false);
cxd56_gpio_write(ALT1250_SHUTDOWN, 0);
cxd56_gpio_write(ALT1250_WAKEUP, false);

/* power on altair modem device */
/* power on alt1250 modem device and wait until the power is distributed */

board_alt1250_poweron();
up_mdelay(POWER_ON_WAIT_TIME);

/* Keep the SHUTDOWN signal low until enough time for the power stable */
/* If keep_on is enabled, skip setting the SHUTDOWN signal to low
* because the ALT1250 is already in the power-on state.
*/

if (!keep_on)
{
/* Drive SHUTDOWN signal low */

cxd56_gpio_write(ALT1250_SHUTDOWN, 0);
}

/* Keep the SHUTDOWN signal low for reset period */

up_mdelay(ACTIVE_SHUTDOWN_TIME);

/* Undrive SHUTDOWN signal to rise up to high by pull-up */

cxd56_gpio_write_hiz(ALT1250_SHUTDOWN);

/* Wait VDDIO on Alt1250 stable */

up_mdelay(TIME_TO_STABLE_VDDIO);

/* Initialize spi deivce */

spi = cxd56_spibus_initialize(SPI_CH);
Expand Down Expand Up @@ -277,10 +297,6 @@ static struct spi_dev_s *alt1250_poweron(void)
spi_pincontrol(SPI_CH, true);
set_spiparam(spi);

/* Undrive SHUTDOWN signal to rise up to high by pull-up */

cxd56_gpio_write_hiz(ALT1250_SHUTDOWN);

return spi;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/modem/alt1250/altmdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ static altmdm_state_t process_state_poweroff(uint32_t event,
altmdm_event_clear(&g_altmdm_dev.event, EVENT_POWERON);
usec2timespec(RESET_INTERVAL, &interval);
nxsig_nanosleep(&interval, NULL);
g_altmdm_dev.spidev = g_altmdm_dev.lower->poweron();
g_altmdm_dev.spidev = g_altmdm_dev.lower->poweron(false);
g_altmdm_dev.lower->set_mready(false);
g_altmdm_dev.lower->set_wakeup(false);
g_altmdm_dev.lower->irqenable(true);
Expand Down Expand Up @@ -1534,7 +1534,7 @@ int altmdm_init(FAR struct spi_dev_s *spidev,

g_altmdm_dev.current_state = ALTMDM_STATE_SLEEP;
g_altmdm_dev.vp = VP_V4;
g_altmdm_dev.spidev = g_altmdm_dev.lower->poweron();
g_altmdm_dev.spidev = g_altmdm_dev.lower->poweron(true);
g_altmdm_dev.lower->set_mready(false);
g_altmdm_dev.lower->set_wakeup(false);
g_altmdm_dev.lower->irqenable(true);
Expand Down
2 changes: 1 addition & 1 deletion include/nuttx/modem/alt1250.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ struct alt_readdata_s

struct alt1250_lower_s
{
FAR struct spi_dev_s * (*poweron)(void);
FAR struct spi_dev_s * (*poweron)(bool keep_on);
void (*poweroff)(void);
bool (*powerstatus)(void);
int (*hiber_mode)(bool);
Expand Down

0 comments on commit 0fc2f95

Please sign in to comment.