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