1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (C) 2015 Linaro
4  * Peter Griffin <peter.griffin@linaro.org>
5  */
6 
7 #ifndef __ASM_ARM_ARCH_PINMUX_H
8 #define __ASM_ARM_ARCH_PINMUX_H
9 
10 #include "periph.h"
11 
12 /* iomg bit definition */
13 #define MUX_M0          0
14 #define MUX_M1          1
15 #define MUX_M2          2
16 #define MUX_M3          3
17 #define MUX_M4          4
18 #define MUX_M5          5
19 #define MUX_M6          6
20 #define MUX_M7          7
21 
22 /* iocg bit definition */
23 #define PULL_MASK       (3)
24 #define PULL_DIS        (0)
25 #define PULL_UP         (1 << 0)
26 #define PULL_DOWN       (1 << 1)
27 
28 /* drive strength definition */
29 #define DRIVE_MASK      (7 << 4)
30 #define DRIVE1_02MA     (0 << 4)
31 #define DRIVE1_04MA     (1 << 4)
32 #define DRIVE1_08MA     (2 << 4)
33 #define DRIVE1_10MA     (3 << 4)
34 #define DRIVE2_02MA     (0 << 4)
35 #define DRIVE2_04MA     (1 << 4)
36 #define DRIVE2_08MA     (2 << 4)
37 #define DRIVE2_10MA     (3 << 4)
38 #define DRIVE3_04MA     (0 << 4)
39 #define DRIVE3_08MA     (1 << 4)
40 #define DRIVE3_12MA     (2 << 4)
41 #define DRIVE3_16MA     (3 << 4)
42 #define DRIVE3_20MA     (4 << 4)
43 #define DRIVE3_24MA     (5 << 4)
44 #define DRIVE3_32MA     (6 << 4)
45 #define DRIVE3_40MA     (7 << 4)
46 #define DRIVE4_02MA     (0 << 4)
47 #define DRIVE4_04MA     (2 << 4)
48 #define DRIVE4_08MA     (4 << 4)
49 #define DRIVE4_10MA     (6 << 4)
50 
51 #define HI6220_PINMUX0_BASE 0xf7010000
52 #define HI6220_PINMUX1_BASE 0xf7010800
53 
54 #ifndef	__ASSEMBLY__
55 
56 /* maybe more registers, but highest used is 123 */
57 #define REG_NUM 123
58 
59 struct hi6220_pinmux0_regs {
60 	uint32_t	iomg[REG_NUM];
61 };
62 
63 struct hi6220_pinmux1_regs {
64 	uint32_t	iocfg[REG_NUM];
65 };
66 
67 #endif
68 
69 /**
70  * Configures the pinmux for a particular peripheral.
71  *
72  * This function will configure the peripheral pinmux along with
73  * pull-up/down and drive strength.
74  *
75  * @param peripheral	peripheral to be configured
76  * Return: 0 if ok, -1 on error (e.g. unsupported peripheral)
77  */
78 int hi6220_pinmux_config(int peripheral);
79 
80 #endif
81