blob: e61e92d4d5424da40e63a77e2842264b7db52e5d [file] [log] [blame]
Prafulla Wadaskare5f495d2010-12-07 15:23:39 +05301/*
2 * (C) Copyright 2010
3 * Marvell Semiconductor <www.marvell.com>
4 * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
5 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Prafulla Wadaskare5f495d2010-12-07 15:23:39 +05307 */
8
9#ifndef __MVMFP_H
10#define __MVMFP_H
11
12/*
13 * Header file for MultiFunctionPin (MFP) Configururation framework
14 *
15 * Processors Supported:
16 * 1. Marvell ARMADA100 Processors
17 *
18 * processor to be supported should be added here
19 */
20
21/*
22 * MFP configuration is represented by a 32-bit unsigned integer
23 */
Xiang Wangee4303c2015-03-23 17:56:58 -050024#ifdef CONFIG_MVMFP_V2
25#define MFP(_off, _pull, _drv, _slp, _edge, _sleep, _afn) ( \
26 /* bits 31..16 - MFP Register Offset */ (((_off) & 0xffff) << 16) | \
27 /* bits 15..13 - Run Mode Pull State */ (((_pull) & 0x7) << 13) | \
28 /* bit 12..11 - Driver Strength */ (((_drv) & 0x3) << 11) | \
29 /* bits 10 - pad driver */ (((_slp) & 0x1) << 10) | \
30 /* bit 09..07 - sleep mode */ (((_sleep) & 0xe) << 6) | \
31 /* bits 06..04 - Edge Detection */ (((_edge) & 0x7) << 4) | \
32 /* bits 03 - sleep mode */ (((_sleep) & 0x1) << 3) | \
33 /* bits 02..00 - Alt-fun select */ ((_afn) & 0x7))
34#else
35#define MFP(_off, _pull, _drv, _slp, _edge, _sleep, _afn) ( \
Prafulla Wadaskare5f495d2010-12-07 15:23:39 +053036 /* bits 31..16 - MFP Register Offset */ (((_off) & 0xffff) << 16) | \
37 /* bits 15..13 - Run Mode Pull State */ (((_pull) & 0x7) << 13) | \
38 /* bit 12 - Unused */ \
39 /* bits 11..10 - Driver Strength */ (((_drv) & 0x3) << 10) | \
Xiang Wangee4303c2015-03-23 17:56:58 -050040 /* bit 09..07 - sleep mode */ (((_sleep) & 0xe) << 6) | \
Prafulla Wadaskare5f495d2010-12-07 15:23:39 +053041 /* bits 06..04 - Edge Detection */ (((_edge) & 0x7) << 4) | \
Xiang Wangee4303c2015-03-23 17:56:58 -050042 /* bits 03 - sleep mode */ (((_sleep) & 0x1) << 3) | \
43 /* bits 02..00 - Alt-fun select */ ((_afn) & 0x7))
44#endif
Prafulla Wadaskare5f495d2010-12-07 15:23:39 +053045
46/*
47 * to facilitate the definition, the following macros are provided
48 *
49 * offset, pull,pF, drv,dF, edge,eF ,afn,aF
50 */
Xiang Wangee4303c2015-03-23 17:56:58 -050051#define MFP_OFFSET_MASK MFP(0xffff, 0, 0, 0, 0, 0, 0)
52#define MFP_REG(x) MFP(x, 0, 0, 0, 0, 0, 0)
Prafulla Wadaskare5f495d2010-12-07 15:23:39 +053053#define MFP_REG_GET_OFFSET(x) ((x & MFP_OFFSET_MASK) >> 16)
54
Xiang Wangee4303c2015-03-23 17:56:58 -050055#define MFP_AF0 MFP(0x0000, 0, 0, 0, 0, 0, 0)
56#define MFP_AF1 MFP(0x0000, 0, 0, 0, 0, 0, 1)
57#define MFP_AF2 MFP(0x0000, 0, 0, 0, 0, 0, 2)
58#define MFP_AF3 MFP(0x0000, 0, 0, 0, 0, 0, 3)
59#define MFP_AF4 MFP(0x0000, 0, 0, 0, 0, 0, 4)
60#define MFP_AF5 MFP(0x0000, 0, 0, 0, 0, 0, 5)
61#define MFP_AF6 MFP(0x0000, 0, 0, 0, 0, 0, 6)
62#define MFP_AF7 MFP(0x0000, 0, 0, 0, 0, 0, 7)
63#define MFP_AF_MASK MFP(0x0000, 0, 0, 0, 0, 0, 7)
Prafulla Wadaskare5f495d2010-12-07 15:23:39 +053064
Xiang Wangee4303c2015-03-23 17:56:58 -050065#define MFP_SLEEP_CTRL2 MFP(0x0000, 0, 0, 0, 0, 1, 0)
66#define MFP_SLEEP_DIR MFP(0x0000, 0, 0, 0, 0, 2, 0)
67#define MFP_SLEEP_DATA MFP(0x0000, 0, 0, 0, 0, 4, 0)
68#define MFP_SLEEP_CTRL MFP(0x0000, 0, 0, 0, 0, 8, 0)
69#define MFP_SLEEP_MASK MFP(0x0000, 0, 0, 0, 0, 0xf, 0)
Prafulla Wadaskare5f495d2010-12-07 15:23:39 +053070
Xiang Wangee4303c2015-03-23 17:56:58 -050071#define MFP_LPM_EDGE_NONE MFP(0x0000, 0, 0, 0, 4, 0, 0)
72#define MFP_LPM_EDGE_RISE MFP(0x0000, 0, 0, 0, 1, 0, 0)
73#define MFP_LPM_EDGE_FALL MFP(0x0000, 0, 0, 0, 2, 0, 0)
74#define MFP_LPM_EDGE_BOTH MFP(0x0000, 0, 0, 0, 3, 0, 0)
75#define MFP_LPM_EDGE_MASK MFP(0x0000, 0, 0, 0, 7, 0, 0)
Prafulla Wadaskare5f495d2010-12-07 15:23:39 +053076
Xiang Wangee4303c2015-03-23 17:56:58 -050077#define MFP_SLP_DI MFP(0x0000, 0, 0, 1, 0, 0, 0)
Prafulla Wadaskare5f495d2010-12-07 15:23:39 +053078
Xiang Wangee4303c2015-03-23 17:56:58 -050079#define MFP_DRIVE_VERY_SLOW MFP(0x0000, 0, 0, 0, 0, 0, 0)
80#define MFP_DRIVE_SLOW MFP(0x0000, 0, 1, 0, 0, 0, 0)
81#define MFP_DRIVE_MEDIUM MFP(0x0000, 0, 2, 0, 0, 0, 0)
82#define MFP_DRIVE_FAST MFP(0x0000, 0, 3, 0, 0, 0, 0)
83#define MFP_DRIVE_MASK MFP(0x0000, 0, 3, 0, 0, 0, 0)
Prafulla Wadaskare5f495d2010-12-07 15:23:39 +053084
Xiang Wangee4303c2015-03-23 17:56:58 -050085#define MFP_PULL_NONE MFP(0x0000, 0, 0, 0, 0, 0, 0)
86#define MFP_PULL_LOW MFP(0x0000, 5, 0, 0, 0, 0, 0)
87#define MFP_PULL_HIGH MFP(0x0000, 6, 0, 0, 0, 0, 0)
88#define MFP_PULL_BOTH MFP(0x0000, 7, 0, 0, 0, 0, 0)
89#define MFP_PULL_FLOAT MFP(0x0000, 4, 0, 0, 0, 0, 0)
90#define MFP_PULL_MASK MFP(0x0000, 7, 0, 0, 0, 0, 0)
91
92#define MFP_VALUE_MASK (MFP_PULL_MASK | MFP_DRIVE_MASK | MFP_SLP_DI \
93 | MFP_LPM_EDGE_MASK | MFP_SLEEP_MASK \
94 | MFP_AF_MASK)
Prafulla Wadaskare5f495d2010-12-07 15:23:39 +053095#define MFP_EOC 0xffffffff /* indicates end-of-conf */
96
97/* Functions */
98void mfp_config(u32 *mfp_cfgs);
99
100#endif /* __MVMFP_H */