diff --git a/configs/sama5d3x-ek/Kconfig b/configs/sama5d3x-ek/Kconfig index 6ae3777ea4d..8c7bcb84e5a 100644 --- a/configs/sama5d3x-ek/Kconfig +++ b/configs/sama5d3x-ek/Kconfig @@ -260,5 +260,16 @@ config SAMA5D3xEK_WM8904_I2CFREQUENCY the WM8904. If you have problems communicating with the WM8904, then you might want to try lowering this rate. +choice + prompt "WM8904 MCLK source" + default SAMA5D3xEK_WM8904_SRCMAIN + +config SAMA5D3xEK_WM8904_SRCMAIN + bool "Main Clock (12MHz)" + +config SAMA5D3xEK_WM8904_SRCSCK + bool "Slow XTAL (32.768KHz)" + +endchoice # WM8904 MCLK source endif # AUDIO_WM8904 endif # ARCH_BOARD_SAMA5D3X_EK diff --git a/configs/sama5d3x-ek/src/sam_wm8904.c b/configs/sama5d3x-ek/src/sam_wm8904.c index f1f955afbf1..d44f9523c4c 100644 --- a/configs/sama5d3x-ek/src/sam_wm8904.c +++ b/configs/sama5d3x-ek/src/sam_wm8904.c @@ -120,7 +120,11 @@ static struct sama5d3ek_mwinfo_s g_mxtinfo = { .address = WM8904_I2C_ADDRESS, .frequency = CONFIG_SAMA5D3xEK_WM8904_I2CFREQUENCY, +#ifdef CONFIG_SAMA5D3xEK_WM8904_SRCSCK .mclk = BOARD_SLOWCLK_FREQUENCY, +#else + .mclk = BOARD_MAINCK_FREQUENCY, +#endif .attach = wm8904_attach, .enable = wm8904_enable, @@ -281,8 +285,16 @@ int sam_wm8904_initialize(int minor) * that is connected to the WM8904 MCLK. */ +#ifdef CONFIG_SAMA5D3xEK_WM8904_SRCSCK + /* Drive the DAC with the slow clock (32.768 KHz) */ + sam_sckc_enable(true); (void)sam_pck_configure(PCK0, PCKSRC_SCK, BOARD_SLOWCLK_FREQUENCY); +#else + /* Drive the DAC with the main clock (12 MHz) */ + + (void)sam_pck_configure(PCK0, PCKSRC_MAINCK, BOARD_MAINCK_FREQUENCY); +#endif /* Enable the DAC master clock */ diff --git a/configs/sama5d4-ek/Kconfig b/configs/sama5d4-ek/Kconfig index 6cbb4951226..99d63a79f32 100644 --- a/configs/sama5d4-ek/Kconfig +++ b/configs/sama5d4-ek/Kconfig @@ -280,5 +280,16 @@ config SAMA5D4EK_WM8904_I2CFREQUENCY the WM8904. If you have problems communicating with the WM8904, then you might want to try lowering this rate. +choice + prompt "WM8904 MCLK source" + default SAMA5D4EK_WM8904_SRCMAIN + +config SAMA5D4EK_WM8904_SRCMAIN + bool "Main Clock (12MHz)" + +config SAMA5D4EK_WM8904_SRCSCK + bool "Slow XTAL (32.768KHz)" + +endchoice # WM8904 MCLK source endif # AUDIO_WM8904 endif # ARCH_BOARD_SAMA5D4_EK diff --git a/configs/sama5d4-ek/src/sam_wm8904.c b/configs/sama5d4-ek/src/sam_wm8904.c index 7207c6ecd1f..69f4cd557ca 100644 --- a/configs/sama5d4-ek/src/sam_wm8904.c +++ b/configs/sama5d4-ek/src/sam_wm8904.c @@ -120,7 +120,11 @@ static struct sama5d4ek_mwinfo_s g_mxtinfo = { .address = WM8904_I2C_ADDRESS, .frequency = CONFIG_SAMA5D4EK_WM8904_I2CFREQUENCY, +#ifdef CONFIG_SAMA5D4EK_WM8904_SRCSCK .mclk = BOARD_SLOWCLK_FREQUENCY, +#else + .mclk = BOARD_MAINCK_FREQUENCY, +#endif .attach = wm8904_attach, .enable = wm8904_enable, @@ -281,8 +285,16 @@ int sam_wm8904_initialize(int minor) * that is connected to the WM8904 MCLK. */ +#ifdef CONFIG_SAMA5D4EK_WM8904_SRCSCK + /* Drive the DAC with the slow clock (32.768 KHz) */ + sam_sckc_enable(true); (void)sam_pck_configure(PCK2, PCKSRC_SCK, BOARD_SLOWCLK_FREQUENCY); +#else + /* Drive the DAC with the main clock (12 MHz) */ + + (void)sam_pck_configure(PCK0, PCKSRC_MAINCK, BOARD_MAINCK_FREQUENCY); +#endif /* Enable the DAC master clock */