Skip to content

Commit

Permalink
os/arch/arm/src/amebasmart: Revise callbacks setup routine
Browse files Browse the repository at this point in the history
- Move callbacks registration to be done at bootup stage, due to the PM is always needed
- Code cleanup
  • Loading branch information
edwakuwaku committed May 21, 2024
1 parent 8aa2f0a commit d4002e9
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 42 deletions.
8 changes: 2 additions & 6 deletions os/arch/arm/src/amebasmart/amebasmart_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1258,15 +1258,9 @@ static void amebasmart_serial_pmnotify(FAR struct pm_callback_s *cb, int domain,
switch (pmstate)
{
case PM_NORMAL:
pmu_unregister_sleep_callback(PMU_LOGUART_DEVICE);
pmu_unregister_sleep_callback(PMU_UART1_DEVICE);
break;
case PM_IDLE:
case PM_STANDBY:
break;
case PM_SLEEP:
pmu_register_sleep_callback(PMU_LOGUART_DEVICE, (PSM_HOOK_FUN)rtk_loguart_suspend, NULL, (PSM_HOOK_FUN)rtk_loguart_resume, NULL);
pmu_register_sleep_callback(PMU_UART1_DEVICE, (PSM_HOOK_FUN)rtk_uart_suspend, NULL, (PSM_HOOK_FUN)rtk_uart_resume, NULL);
break;
default:
break;
Expand Down Expand Up @@ -1399,6 +1393,8 @@ void up_serialinit(void)
#ifdef CONFIG_PM
/* Register to receive power management callbacks */
ret = pm_register(&g_serialpm.pm_cb);
pmu_register_sleep_callback(PMU_LOGUART_DEVICE, (PSM_HOOK_FUN)rtk_loguart_suspend, NULL, (PSM_HOOK_FUN)rtk_loguart_resume, NULL);
pmu_register_sleep_callback(PMU_UART1_DEVICE, (PSM_HOOK_FUN)rtk_uart_suspend, NULL, (PSM_HOOK_FUN)rtk_uart_resume, NULL);
DEBUGASSERT(ret == OK);
UNUSED(ret);
#endif
Expand Down
5 changes: 1 addition & 4 deletions os/arch/arm/src/amebasmart/amebasmart_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,13 +1506,9 @@ static void amebasmart_spi_pmnotify(FAR struct pm_callback_s *cb, int domain,
If using SPI as wakeup interrupt, NP core can only go for CG sleep
*/
case PM_NORMAL:
pmu_unregister_sleep_callback(PMU_SPI_DEVICE);
break;
case PM_IDLE:
case PM_STANDBY:
break;
case PM_SLEEP:
pmu_register_sleep_callback(PMU_SPI_DEVICE, (PSM_HOOK_FUN)rtk_spi_suspend, NULL, (PSM_HOOK_FUN)rtk_spi_resume, NULL);
break;
default:
break;
Expand Down Expand Up @@ -1649,6 +1645,7 @@ void spi_pminitialize(void)
int ret;
/* Register to receive power management callbacks */
ret = pm_register(&g_spipm.pm_cb);
pmu_register_sleep_callback(PMU_SPI_DEVICE, (PSM_HOOK_FUN)rtk_spi_suspend, NULL, (PSM_HOOK_FUN)rtk_spi_resume, NULL);
DEBUGASSERT(ret == OK);
UNUSED(ret);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,14 @@

typedef enum {
PMU_OS = 0,
PMU_WLAN_DEVICE = 1,
PMU_LOGUART_DEVICE = 2,
PMU_KM4_RUN = 3,

PMU_UART0_DEVICE = 4,
PMU_UART1_DEVICE = 5,
PMU_I2C0_DEVICE = 6,
PMU_TOUCH_DEVICE = 7,
PMU_USOC_DEVICE = 8,
PMU_DONGLE_DEVICE = 9,
PMU_RTC_DEVICE = 10,
PMU_CONSOL_DEVICE = 11,
PMU_ADC_DEVICE = 12,
PMU_WAKWLOCK_TIMEOUT = 13,
PMU_AP_RUN = 14,
PMU_PSRAM_DEVICE = 15,
PMU_DEV_USER_BASE = 16, /*number 16 ~ 31 is reserved for customer use*/
PMU_BT_DEVICE = 17,
PMU_VAD_DEVICE = 18,
PMU_SPI_DEVICE = 19,

PMU_MAX = 31
PMU_WLAN_DEVICE = 1,
PMU_LOGUART_DEVICE = 2,
PMU_UART1_DEVICE = 3,
PMU_BT_DEVICE = 4,
PMU_SPI_DEVICE = 5,
PMU_I2C_DEVICE = 6,
PMU_I2S_DEVICE = 7,
PMU_MAX,
} PMU_DEVICE;

enum CPU1_STATE {
Expand Down
2 changes: 0 additions & 2 deletions os/board/rtl8730e/src/rtl8730e_alc1019.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ extern FAR struct i2s_dev_s *amebasmart_i2s_initialize(uint16_t port);

#ifdef CONFIG_AUDIO_ALC1019

extern struct i2s_dev_s *amebad_i2s_initialize(uint16_t port);

/****************************************************************************
* Private Types
****************************************************************************/
Expand Down
7 changes: 7 additions & 0 deletions os/board/rtl8730e/src/rtl8730e_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ void board_i2s_initialize(void)
{
#if defined(CONFIG_AUDIO_I2SCHAR) && defined(CONFIG_AMEBASMART_I2S)
i2schar_devinit();
#ifdef CONFIG_PM
i2s_pminitialize();
#endif
#endif

}

void board_spi_initialize(void)
Expand Down Expand Up @@ -211,6 +215,9 @@ void board_i2c_initialize(void)
}
#endif
#endif
#ifdef CONFIG_PM
i2c_pminitialize();
#endif
#endif
}

Expand Down
19 changes: 12 additions & 7 deletions os/board/rtl8730e/src/rtl8730e_i2schar.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@
* Pre-processor Definitions
****************************************************************************/

#ifndef CONFIG_AMEBASMART_I2SCHAR_MINOR
#define CONFIG_AMEBASMART_I2SCHAR_MINOR 0
#ifndef CONFIG_AMEBASMART_I2SCHAR_MINOR_2
#define CONFIG_AMEBASMART_I2SCHAR_MINOR_2 2
#endif

#ifndef CONFIG_AMEBASMART_I2SCHAR_MINOR_3
#define CONFIG_AMEBASMART_I2SCHAR_MINOR_3 3
#endif
/*****************************************************************************
* Private Functions
Expand Down Expand Up @@ -66,7 +70,8 @@ int i2schar_devinit(void)
int ret;

if (!initialized) {
#ifdef CONFIG_AMEBASMART_I2S2
/* If ALC1019 is enabled, we should reserve I2S 2 for it */
#if defined(CONFIG_AMEBASMART_I2S2) && !defined(CONFIG_AUDIO_ALC1019)
/* Call amebasmart_i2s_initialize() to get an instance of the I2S interface */
/* Initialise I2S2 */
i2s = amebasmart_i2s_initialize(I2S_NUM_2);
Expand All @@ -76,8 +81,8 @@ int i2schar_devinit(void)
return -ENODEV;
}

/* Register the I2S character driver at "/dev/i2schar0" */
ret = i2schar_register(i2s, CONFIG_AMEBASMART_I2SCHAR_MINOR);
/* Register the I2S character driver at "/dev/i2schar2" */
ret = i2schar_register(i2s, CONFIG_AMEBASMART_I2SCHAR_MINOR_2);
if (ret < 0) {
lldbg("ERROR: i2schar_register failed: %d\n", ret);
return ret;
Expand All @@ -93,8 +98,8 @@ int i2schar_devinit(void)
return -ENODEV;
}

/* Register the I2S character driver at "/dev/i2schar0" */
ret = i2schar_register(i2s, CONFIG_AMEBASMART_I2SCHAR_MINOR);
/* Register the I2S character driver at "/dev/i2schar3" */
ret = i2schar_register(i2s, CONFIG_AMEBASMART_I2SCHAR_MINOR_3);
if (ret < 0) {
lldbg("ERROR: i2schar_register failed: %d\n", ret);
return ret;
Expand Down
2 changes: 1 addition & 1 deletion os/drivers/audio/alc1019.c
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ FAR struct audio_lowerhalf_s *alc1019_initialize(FAR struct i2c_dev_s *i2c, FAR
* default state.
*/

/*reconfigure the ALC1019 hardwaqre */
/*reconfigure the ALC1019 hardware */
alc1019_reset_config(priv);
alc1019_exec_i2c_script(priv, codec_init_mute_on_script, sizeof(codec_init_mute_on_script) / sizeof(t_codec_init_script_entry));

Expand Down

0 comments on commit d4002e9

Please sign in to comment.