blob: dfb5ad43506a86a7cfc96eef7479096a7ef2ebb0 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Vitaly Andrianov60990112015-09-19 16:26:44 +05302/*
3 * K2G: Pinmux configuration
4 *
5 * (C) Copyright 2015
6 * Texas Instruments Incorporated, <www.ti.com>
Vitaly Andrianov60990112015-09-19 16:26:44 +05307 */
8
9#ifndef __ASM_ARCH_MUX_K2G_H
10#define __ASM_ARCH_MUX_K2G_H
11
Vitaly Andrianov60990112015-09-19 16:26:44 +053012#include <asm/io.h>
13
14#define K2G_PADCFG_REG (KS2_DEVICE_STATE_CTRL_BASE + 0x1000)
15
16/*
17 * 20:19 - buffer class RW fixed
18 * 18 - rxactive (Input enabled for the pad ) 0 - Di; 1 - En;
19 * 17 - pulltypesel (0 - PULLDOWN; 1 - PULLUP);
20 * 16 - pulluden (0 - PULLUP/DOWN EN; 1 - DI);
21 * 3:0 - muxmode (available modes 0:5)
22 */
23
24#define PIN_IEN (1 << 18) /* pin input enabled */
25#define PIN_PDIS (1 << 16) /* pull up/down disabled */
26#define PIN_PTU (1 << 17) /* pull up */
27#define PIN_PTD (0 << 17) /* pull down */
28
Murali Karicheria9c7a192019-02-21 12:02:01 -050029#define BUFFER_CLASS_B (0 << 19)
30#define BUFFER_CLASS_C (1 << 19)
31#define BUFFER_CLASS_D (2 << 19)
32#define BUFFER_CLASS_E (3 << 19)
33
Vitaly Andrianov60990112015-09-19 16:26:44 +053034#define MODE(m) ((m) & 0x7)
35#define MAX_PIN_N 260
36
37#define MUX_CFG(value, index) \
38 __raw_writel(\
39 (value) | \
40 (__raw_readl(K2G_PADCFG_REG + (index << 2)) & \
41 (0x3 << 19)),\
42 (K2G_PADCFG_REG + (index << 2))\
43 );
44
45struct pin_cfg {
46 int reg_inx;
47 u32 val;
48};
49
50static inline void configure_pin_mux(struct pin_cfg *pin_mux)
51{
52 if (!pin_mux)
53 return;
54
55 while ((pin_mux->reg_inx >= 0) && (pin_mux->reg_inx < MAX_PIN_N)) {
56 MUX_CFG(pin_mux->val, pin_mux->reg_inx);
57 pin_mux++;
58 }
59}
60
61#endif /* __ASM_ARCH_MUX_K2G_H */