Skip to content

Commit

Permalink
platxr871: move more code into .xip section
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron-Ye committed Feb 24, 2018
1 parent f941ec6 commit bfaa938
Show file tree
Hide file tree
Showing 23 changed files with 311 additions and 16 deletions.
3 changes: 3 additions & 0 deletions platform/mcu/xr871/include/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
#define __asm asm
#define __weak __attribute__((weak))

#define __xip_text __attribute__((section (".xip.text")))
#define __xip_rodata __attribute__((section (".xip.rodata")))

#else
#error "Compiler not supported."
#endif
Expand Down
8 changes: 6 additions & 2 deletions platform/mcu/xr871/project/common/board/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,15 @@ __weak HAL_Status board_spi_deinit(SPI_Port spi)

/* sound card0 */
#if PRJCONF_SOUNDCARD0_EN
__xip_text
__weak HAL_Status board_soundcard0_init(void)
{
static const I2C_InitParam i2c_param = {
static const I2C_InitParam i2c_param __xip_rodata = {
.addrMode = BOARD_SOUNDCARD0_I2C_ADDR_MODE,
.clockFreq = BOARD_SOUNDCARD0_I2C_CLK
};

static const CODEC_Param acodec_param = {
static const CODEC_Param acodec_param __xip_rodata = {
.name = (uint8_t *)BOARD_SOUNDCARD0_CODEC_NAME,
.write = BOARD_SOUNDCARD0_CODEC_WRITE,
.read = BOARD_SOUNDCARD0_CODEC_READ,
Expand Down Expand Up @@ -121,6 +122,7 @@ __weak HAL_Status board_soundcard0_init(void)
return ret;
}

__xip_text
__weak HAL_Status board_soundcard0_deinit(void)
{
HAL_CODEC_DeInit();
Expand All @@ -131,6 +133,7 @@ __weak HAL_Status board_soundcard0_deinit(void)

/* sound card1 */
#if PRJCONF_SOUNDCARD1_EN
__xip_text
__weak HAL_Status board_soundcard1_init(void)
{
DMIC_Param dmic_param;
Expand All @@ -139,6 +142,7 @@ __weak HAL_Status board_soundcard1_init(void)
return HAL_DMIC_Init(&dmic_param);
}

__xip_text
__weak HAL_Status board_soundcard1_deinit(void)
{
HAL_DMIC_DeInit();
Expand Down
2 changes: 2 additions & 0 deletions platform/mcu/xr871/project/common/framework/platform_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ __weak void platform_init_level0(void)
}

/* init standard platform hardware and services */
__xip_text
__weak void platform_init_level1(void)
{
#if PRJCONF_UART_EN
Expand Down Expand Up @@ -220,6 +221,7 @@ __weak void platform_init_level1(void)
}

/* init extern platform hardware and services */
__xip_text
__weak void platform_init_level2(void)
{
#if PRJCONF_SPI_EN
Expand Down
38 changes: 29 additions & 9 deletions platform/mcu/xr871/src/driver/chip/codec/hal_ac101.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ typedef struct {
* Note : pll code from original tdm/i2s driver.
* freq_out = freq_in * N/(m*(2k+1)) , k=1,N=N_i+N_f,N_f=factor*0.2;
*/
static const PLL_Div codec_pll_div[] = {
static const PLL_Div codec_pll_div[] __xip_rodata = {
{128000, 22579200, 1, 529, 1},
{192000, 22579200, 1, 352, 4},
{256000, 22579200, 1, 264, 3},
Expand All @@ -92,7 +92,7 @@ static const PLL_Div codec_pll_div[] = {
{19200000, 24576000, 25, 88, 1},
};

static const AIF1_Fs codec_aif1_fs[] = {
static const AIF1_Fs codec_aif1_fs[] __xip_rodata = {
{44100, 4, 7},
{48000, 4, 8},
{8000, 9, 0},
Expand All @@ -106,22 +106,22 @@ static const AIF1_Fs codec_aif1_fs[] = {
{192000, 1, 10},
};

static const AIF1_Lrck codec_aif1_lrck[] = {
static const AIF1_Lrck codec_aif1_lrck[] __xip_rodata = {
{16, 0},
{32, 1},
{64, 2},
{128, 3},
{256, 4},
};

static const AIF1_WordSize codec_aif1_wsize[] = {
static const AIF1_WordSize codec_aif1_wsize[] __xip_rodata = {
{8, 0},
{16, 1},
{20, 2},
{24, 3},
};

static Volume spk_vol[] = {
static const Volume spk_vol[] __xip_rodata = {
{VOLUME_LEVEL0, 0},
{VOLUME_LEVEL1, 1},
{VOLUME_LEVEL2, 2},
Expand Down Expand Up @@ -156,7 +156,7 @@ static Volume spk_vol[] = {
{VOLUME_LEVEL31, 31},
};

static Volume phone_vol[] = {
static const Volume phone_vol[] __xip_rodata = {
{VOLUME_LEVEL0, 0},
{VOLUME_LEVEL1, 2},
{VOLUME_LEVEL2, 4},
Expand Down Expand Up @@ -193,6 +193,7 @@ static Volume phone_vol[] = {

static uint8_t speaker_double_used = 0;

__xip_text
static void agc_config()
{
snd_soc_update_bits(0xb4, (0x3<<6), (0x3<<6));
Expand All @@ -207,6 +208,7 @@ static void agc_config()
snd_soc_write(0x94, 0xabb3);
}

__xip_text
static void drc_config()
{
snd_soc_update_bits(0xa3, (0x7ff<<0),(1<<0));
Expand All @@ -226,6 +228,7 @@ static void drc_config()
snd_soc_write(0x16, 0x9f9f);
}

__xip_text
static void agc_enable(bool on)
{
if (on) {
Expand All @@ -243,6 +246,7 @@ static void agc_enable(bool on)
}
}

__xip_text
static void drc_enable(bool on)
{
if (on) {
Expand All @@ -261,6 +265,7 @@ static void drc_enable(bool on)
/*
* Set clock split ratio according to the pcm parameter.
*/
__xip_text
static int32_t AC101_SetClkdiv(DAI_FmtParam *fmtParam,uint32_t sampleRate)
{
uint32_t i = 0;
Expand Down Expand Up @@ -298,6 +303,7 @@ static int32_t AC101_SetClkdiv(DAI_FmtParam *fmtParam,uint32_t sampleRate)
/*
* Set the codec FLL.
*/
__xip_text
static int32_t AC101_SetPll(DAI_FmtParam *fmtParam)
{
uint32_t i = 0;
Expand Down Expand Up @@ -365,6 +371,7 @@ static int32_t AC101_SetPll(DAI_FmtParam *fmtParam)
/*
* Set codec DAI configuration.
*/
__xip_text
static int32_t AC101_SetFotmat(DAI_FmtParam *fmtParam)
{
int32_t reg_val;
Expand Down Expand Up @@ -435,6 +442,7 @@ static int32_t AC101_SetFotmat(DAI_FmtParam *fmtParam)
/*
* Set headphone as the current output device.
*/
__xip_text
static void AC101_SetHeadphone()
{
AC101_DEBUG("Route(PLAY): Headphone..\n");
Expand Down Expand Up @@ -465,6 +473,7 @@ static void AC101_SetHeadphone()
/*
* Set speaker as the current output device.
*/
__xip_text
static void AC101_SetSpeaker()
{
AC101_DEBUG("Route(PLAY): speaker..\n");
Expand Down Expand Up @@ -504,6 +513,7 @@ static void AC101_SetSpeaker()
/*
* Set main mic as the current input device.
*/
__xip_text
static void AC101_SetMainMic()
{
AC101_DEBUG("Route(cap): main mic..\n");
Expand Down Expand Up @@ -563,6 +573,7 @@ static void AC101_SetMainMic()
/*
* Set headset mic as the current input device.
*/
__xip_text
static void AC101_SetHeadphoneMic()
{
AC101_DEBUG("Route(cap): Headset mic..\n");
Expand Down Expand Up @@ -622,6 +633,7 @@ static void AC101_SetHeadphoneMic()
/*
* Set codec initialization parameter.
*/
__xip_text
HAL_Status AC101_Setcfg(CODEC_InitParam *param)
{
if (!param)
Expand Down Expand Up @@ -661,6 +673,7 @@ HAL_Status AC101_Setcfg(CODEC_InitParam *param)
/*
* Set audio output/input device.
*/
__xip_text
static int32_t AC101_SetRoute(AUDIO_Device device)
{
switch(device) {
Expand All @@ -685,6 +698,7 @@ static int32_t AC101_SetRoute(AUDIO_Device device)
/*
* Set audio output device volume gain.
*/
__xip_text
static int32_t AC101_SetVolume( AUDIO_Device dev,uint32_t volume)
{
AC101_DEBUG("[set volume] dev(%d) volume(%d)..\n", (int)dev, (int)volume);
Expand All @@ -710,6 +724,7 @@ static int32_t AC101_SetVolume( AUDIO_Device dev,uint32_t volume)
/*
* Trigger output device avoid pops.
*/
__xip_text
static int32_t AC101_SetTrigger( AUDIO_Device dev,uint32_t on)
{
if (AUDIO_DEVICE_HEADPHONE != dev)
Expand All @@ -726,6 +741,7 @@ static int32_t AC101_SetTrigger( AUDIO_Device dev,uint32_t on)
/*
* Deinit codec hardware when audio stream stop.
*/
__xip_text
static int32_t AC101_ShutDown(bool playOn, bool recordOn)
{
if (playOn == 0 && recordOn == 0) {
Expand Down Expand Up @@ -820,6 +836,7 @@ static int32_t AC101_ShutDown(bool playOn, bool recordOn)
/*
* Set/reset power for the codec.
*/
__xip_text
static int32_t AC101_SetPower(CODEC_Req req, void *arg)
{
if (req == HAL_CODEC_INIT) {
Expand All @@ -833,6 +850,7 @@ static int32_t AC101_SetPower(CODEC_Req req, void *arg)
/*
* Set/reset sysclk for the codec.
*/
__xip_text
static int32_t AC101_SetSysClk(CODEC_Req req, void *arg)
{
if (req == HAL_CODEC_INIT) {
Expand All @@ -846,6 +864,7 @@ static int32_t AC101_SetSysClk(CODEC_Req req, void *arg)
/*
* Set/reset the necessary initialization value for the codec.
*/
__xip_text
static int32_t AC101_SetInitParam(CODEC_Req req, void *arg)
{
if (req == HAL_CODEC_INIT) {
Expand Down Expand Up @@ -873,6 +892,7 @@ static int32_t AC101_SetInitParam(CODEC_Req req, void *arg)
/*
* Init/deinit jack detection.
*/
__xip_text
static int32_t AC101_JackDetect(CODEC_Req req, void *arg)
{
if (req == HAL_CODEC_INIT) {
Expand All @@ -883,20 +903,20 @@ static int32_t AC101_JackDetect(CODEC_Req req, void *arg)
return HAL_OK;
}

const struct codec_ctl_ops ac101_ctl_ops = {
const struct codec_ctl_ops ac101_ctl_ops __xip_rodata = {
.setRoute = AC101_SetRoute,
.setVolume = AC101_SetVolume,
.setTrigger = AC101_SetTrigger,
};

const struct codec_dai_ops ac101_dai_ops = {
const struct codec_dai_ops ac101_dai_ops __xip_rodata = {
.setPll = AC101_SetPll,
.setClkdiv = AC101_SetClkdiv,
.setFormat = AC101_SetFotmat,
.shutDown = AC101_ShutDown,
};

const struct codec_ops ac101_ops = {
const struct codec_ops ac101_ops __xip_rodata = {
.setPower = AC101_SetPower,
.setSysClk = AC101_SetSysClk,
.setInitParam = AC101_SetInitParam,
Expand Down
Loading

0 comments on commit bfaa938

Please sign in to comment.