xref: /openbmc/u-boot/arch/arm/mach-imx/imx8/iomux.c (revision 4c0411eb)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright 2018 NXP
4  */
5 
6 #include <common.h>
7 #include <asm/io.h>
8 #include <asm/arch/iomux.h>
9 #include <asm/arch/sci/sci.h>
10 
11 DECLARE_GLOBAL_DATA_PTR;
12 
13 /*
14  * configures a single pad in the iomuxer
15  */
16 void imx8_iomux_setup_pad(iomux_cfg_t pad)
17 {
18 	sc_pad_t pin_id = pad & PIN_ID_MASK;
19 	int ret;
20 
21 	u32 val = (u32)((pad & MUX_PAD_CTRL_MASK) >> MUX_PAD_CTRL_SHIFT);
22 
23 	val |= PADRING_IFMUX_EN_MASK;
24 	val |= PADRING_GP_EN_MASK;
25 
26 	ret = sc_pad_set(-1, pin_id, val);
27 	if (ret)
28 		printf("sc_pad_set failed!, pin: %u, val: 0x%x\n", pin_id, val);
29 
30 	debug("iomux: pin %d, val = 0x%x\n", pin_id, val);
31 }
32 
33 /* configures a list of pads within declared with IOMUX_PADS macro */
34 void imx8_iomux_setup_multiple_pads(iomux_cfg_t const *pad_list, u32 count)
35 {
36 	iomux_cfg_t const *p = pad_list;
37 	int i;
38 
39 	for (i = 0; i < count; i++) {
40 		imx8_iomux_setup_pad(*p);
41 		p++;
42 	}
43 }
44