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