2 * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
4 * SPDX-License-Identifier: GPL-2.0
7 #include <asm/arch/pinmux.h>
12 static int do_pinctr_pin(const void *blob
, int child
, const char *node_name
)
20 base_addr
= fdtdec_get_addr_size(blob
, child
, "reg", &size
);
21 if (base_addr
!= FDT_ADDR_T_NONE
) {
22 cell
= fdt_getprop(blob
, child
, "pinctrl-single,pins", &len
);
23 if (!cell
|| len
<= 0)
26 debug("%p %d\n", cell
, len
);
27 for (; len
> 0; len
-= (2 * sizeof(u32
))) {
28 offset
= fdt32_to_cpu(*cell
++);
29 value
= fdt32_to_cpu(*cell
++);
30 debug("<0x%x 0x%x>\n", offset
, value
);
31 writel(value
, base_addr
+ offset
);
38 static int do_pinctrl_pins(const void *blob
, int node
, const char *child_name
)
41 const char *node_name
;
43 child
= fdt_first_subnode(blob
, node
);
48 node_name
= fdt_get_name(blob
, child
, &len
);
51 if (!strcmp(child_name
, node_name
))
52 return do_pinctr_pin(blob
, child
, node_name
);
54 child
= fdt_next_subnode(blob
, child
);
59 node_name
= fdt_get_name(blob
, child
, &len
);
65 int config_dedicated_pins(const void *blob
)
69 node
= fdtdec_next_compatible(blob
, 0,
70 COMPAT_ALTERA_SOCFPGA_PINCTRL_SINGLE
);
74 if (do_pinctrl_pins(blob
, node
, "dedicated_cfg"))
77 if (do_pinctrl_pins(blob
, node
, "dedicated"))
83 int config_pins(const void *blob
, const char *pin_grp
)
87 node
= fdtdec_next_compatible(blob
, 0,
88 COMPAT_ALTERA_SOCFPGA_PINCTRL_SINGLE
);
92 if (do_pinctrl_pins(blob
, node
, pin_grp
))