1 /*
2  * Copyright (c) 2019,  NXP
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #include <zephyr/init.h>
7 #include <zephyr/devicetree.h>
8 #include <fsl_common.h>
9 #include <soc.h>
10 
lpcxpresso_55s69_board_init(void)11 static int lpcxpresso_55s69_board_init(void)
12 {
13 
14 #if (DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm6), nxp_lpc_i2s, okay)) && \
15 		(DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm7), nxp_lpc_i2s, okay)) && \
16 		CONFIG_I2S
17 	/*
18 	 * Flexcomm 6 and 7 are connected to codec on board, and shared signal
19 	 * sets are used to enable one I2S device to handle RX and one to handle
20 	 * TX
21 	 */
22 	CLOCK_EnableClock(kCLOCK_Sysctl);
23 	/* Set shared signal set 0 SCK, WS from Transmit I2S - Flexcomm 7 */
24 	SYSCTL->SHAREDCTRLSET[0] = SYSCTL_SHAREDCTRLSET_SHAREDSCKSEL(7) |
25 				SYSCTL_SHAREDCTRLSET_SHAREDWSSEL(7);
26 
27 #ifdef CONFIG_I2S_TEST_SEPARATE_DEVICES
28 	/* Select Data in from Transmit I2S - Flexcomm 7 */
29 	SYSCTL->SHAREDCTRLSET[0] |= SYSCTL_SHAREDCTRLSET_SHAREDDATASEL(7);
30 	/* Enable Transmit I2S - Flexcomm 7 for Shared Data Out */
31 	SYSCTL->SHAREDCTRLSET[0] |= SYSCTL_SHAREDCTRLSET_FC7DATAOUTEN(1);
32 #endif
33 
34 	/* Set Receive I2S - Flexcomm 6 SCK, WS from shared signal set 0 */
35 	SYSCTL->FCCTRLSEL[6] = SYSCTL_FCCTRLSEL_SCKINSEL(1) |
36 				SYSCTL_FCCTRLSEL_WSINSEL(1);
37 
38 	/* Set Transmit I2S - Flexcomm 7 SCK, WS from shared signal set 0 */
39 	SYSCTL->FCCTRLSEL[7] = SYSCTL_FCCTRLSEL_SCKINSEL(1) |
40 				SYSCTL_FCCTRLSEL_WSINSEL(1);
41 
42 #ifdef CONFIG_I2S_TEST_SEPARATE_DEVICES
43 	/* Select Receive I2S - Flexcomm 6 Data in from shared signal set 0 */
44 	SYSCTL->FCCTRLSEL[6] |= SYSCTL_FCCTRLSEL_DATAINSEL(1);
45 	/* Select Transmit I2S - Flexcomm 7 Data out to shared signal set 0 */
46 	SYSCTL->FCCTRLSEL[7] |= SYSCTL_FCCTRLSEL_DATAOUTSEL(1);
47 #endif
48 
49 #endif
50 
51 	return 0;
52 }
53 
54 SYS_INIT(lpcxpresso_55s69_board_init,  PRE_KERNEL_1, 0);
55