1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
4 *
5 */
6
7 #include <common.h>
8 #include <errno.h>
9 #include <asm/io.h>
10 #include <asm/arch/handoff_s10.h>
11
sysmgr_pinmux_handoff_read(void * handoff_address,const u32 ** table,unsigned int * table_len)12 static void sysmgr_pinmux_handoff_read(void *handoff_address,
13 const u32 **table,
14 unsigned int *table_len)
15 {
16 unsigned int handoff_entry = (swab32(readl(handoff_address +
17 S10_HANDOFF_OFFSET_LENGTH)) -
18 S10_HANDOFF_OFFSET_DATA) /
19 sizeof(unsigned int);
20 unsigned int handoff_chunk[handoff_entry], temp, i;
21
22 if (swab32(readl(S10_HANDOFF_MUX)) == S10_HANDOFF_MAGIC_MUX) {
23 /* using handoff from Quartus tools if exists */
24 for (i = 0; i < handoff_entry; i++) {
25 temp = readl(handoff_address +
26 S10_HANDOFF_OFFSET_DATA + (i * 4));
27 handoff_chunk[i] = swab32(temp);
28 }
29 *table = handoff_chunk;
30 *table_len = ARRAY_SIZE(handoff_chunk);
31 }
32 }
33
sysmgr_pinmux_table_sel(const u32 ** table,unsigned int * table_len)34 void sysmgr_pinmux_table_sel(const u32 **table, unsigned int *table_len)
35 {
36 sysmgr_pinmux_handoff_read((void *)S10_HANDOFF_MUX, table,
37 table_len);
38 }
39
sysmgr_pinmux_table_ctrl(const u32 ** table,unsigned int * table_len)40 void sysmgr_pinmux_table_ctrl(const u32 **table, unsigned int *table_len)
41 {
42 sysmgr_pinmux_handoff_read((void *)S10_HANDOFF_IOCTL, table,
43 table_len);
44 }
45
sysmgr_pinmux_table_fpga(const u32 ** table,unsigned int * table_len)46 void sysmgr_pinmux_table_fpga(const u32 **table, unsigned int *table_len)
47 {
48 sysmgr_pinmux_handoff_read((void *)S10_HANDOFF_FPGA, table,
49 table_len);
50 }
51
sysmgr_pinmux_table_delay(const u32 ** table,unsigned int * table_len)52 void sysmgr_pinmux_table_delay(const u32 **table, unsigned int *table_len)
53 {
54 sysmgr_pinmux_handoff_read((void *)S10_HANODFF_DELAY, table,
55 table_len);
56 }
57