xref: /openbmc/u-boot/arch/arm/include/asm/arch-omap5/dra7xx_iodelay.h (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
2eda6fbccSLokesh Vutla /*
3eda6fbccSLokesh Vutla  * (C) Copyright 2015
4eda6fbccSLokesh Vutla  * Texas Instruments Incorporated
5eda6fbccSLokesh Vutla  *
6eda6fbccSLokesh Vutla  * Lokesh Vutla <lokeshvutla@ti.com>
7eda6fbccSLokesh Vutla  */
8eda6fbccSLokesh Vutla 
9eda6fbccSLokesh Vutla #ifndef _DRA7_IODELAY_H_
10eda6fbccSLokesh Vutla #define _DRA7_IODELAY_H_
11eda6fbccSLokesh Vutla 
12eda6fbccSLokesh Vutla #include <common.h>
13eda6fbccSLokesh Vutla #include <asm/arch/sys_proto.h>
14eda6fbccSLokesh Vutla 
15eda6fbccSLokesh Vutla /* CONFIG_REG_0 */
16eda6fbccSLokesh Vutla #define CFG_REG_0_OFFSET		0xC
17eda6fbccSLokesh Vutla #define CFG_REG_ROM_READ_SHIFT		1
18eda6fbccSLokesh Vutla #define CFG_REG_ROM_READ_MASK		(1 << 1)
19eda6fbccSLokesh Vutla #define CFG_REG_CALIB_STRT_SHIFT	0
20eda6fbccSLokesh Vutla #define CFG_REG_CALIB_STRT_MASK		(1 << 0)
21eda6fbccSLokesh Vutla #define CFG_REG_CALIB_STRT		1
22eda6fbccSLokesh Vutla #define CFG_REG_CALIB_END		0
23eda6fbccSLokesh Vutla #define CFG_REG_ROM_READ_START		(1 << 1)
24eda6fbccSLokesh Vutla #define CFG_REG_ROM_READ_END		(0 << 1)
25eda6fbccSLokesh Vutla 
26eda6fbccSLokesh Vutla /* CONFIG_REG_2 */
27eda6fbccSLokesh Vutla #define CFG_REG_2_OFFSET		0x14
28eda6fbccSLokesh Vutla #define CFG_REG_REFCLK_PERIOD_SHIFT	0
29eda6fbccSLokesh Vutla #define CFG_REG_REFCLK_PERIOD_MASK	(0xFFFF << 0)
30eda6fbccSLokesh Vutla #define CFG_REG_REFCLK_PERIOD		0x2EF
31eda6fbccSLokesh Vutla 
32eda6fbccSLokesh Vutla /* CONFIG_REG_8 */
33eda6fbccSLokesh Vutla #define CFG_REG_8_OFFSET		0x2C
34eda6fbccSLokesh Vutla #define CFG_IODELAY_UNLOCK_KEY		0x0000AAAA
35eda6fbccSLokesh Vutla #define CFG_IODELAY_LOCK_KEY		0x0000AAAB
36eda6fbccSLokesh Vutla 
3771bed185SLokesh Vutla /* CONFIG_REG_3/4 */
3871bed185SLokesh Vutla #define CFG_REG_3_OFFSET	0x18
3971bed185SLokesh Vutla #define CFG_REG_4_OFFSET	0x1C
4071bed185SLokesh Vutla #define CFG_REG_DLY_CNT_SHIFT	16
4171bed185SLokesh Vutla #define CFG_REG_DLY_CNT_MASK	(0xFFFF << 16)
4271bed185SLokesh Vutla #define CFG_REG_REF_CNT_SHIFT	0
4371bed185SLokesh Vutla #define CFG_REG_REF_CNT_MASK	(0xFFFF << 0)
4471bed185SLokesh Vutla 
45eda6fbccSLokesh Vutla /* CTRL_CORE_SMA_SW_0 */
46eda6fbccSLokesh Vutla #define CTRL_ISOLATE_SHIFT		2
47eda6fbccSLokesh Vutla #define CTRL_ISOLATE_MASK		(1 << 2)
48eda6fbccSLokesh Vutla #define ISOLATE_IO			1
49eda6fbccSLokesh Vutla #define DEISOLATE_IO			0
50eda6fbccSLokesh Vutla 
5176cff2b1SNishanth Menon /* CTRL_CORE_SMA_SW_1 */
5276cff2b1SNishanth Menon #define RGMII2_ID_MODE_N_MASK		(1 << 26)
5376cff2b1SNishanth Menon #define RGMII1_ID_MODE_N_MASK		(1 << 25)
5476cff2b1SNishanth Menon 
55eda6fbccSLokesh Vutla /* PRM_IO_PMCTRL */
56eda6fbccSLokesh Vutla #define PMCTRL_ISOCLK_OVERRIDE_SHIFT	0
57eda6fbccSLokesh Vutla #define PMCTRL_ISOCLK_OVERRIDE_MASK	(1 << 0)
58eda6fbccSLokesh Vutla #define PMCTRL_ISOCLK_STATUS_SHIFT	1
59eda6fbccSLokesh Vutla #define PMCTRL_ISOCLK_STATUS_MASK	(1 << 1)
60eda6fbccSLokesh Vutla #define PMCTRL_ISOCLK_OVERRIDE_CTRL	1
61eda6fbccSLokesh Vutla #define PMCTRL_ISOCLK_NOT_OVERRIDE_CTRL	0
62eda6fbccSLokesh Vutla 
63eda6fbccSLokesh Vutla #define ERR_CALIBRATE_IODELAY		0x1
64eda6fbccSLokesh Vutla #define ERR_DEISOLATE_IO		0x2
65eda6fbccSLokesh Vutla #define ERR_ISOLATE_IO			0x4
66eda6fbccSLokesh Vutla #define ERR_UPDATE_DELAY		0x8
6771bed185SLokesh Vutla #define ERR_CPDE			0x3
6871bed185SLokesh Vutla #define ERR_FPDE			0x5
69eda6fbccSLokesh Vutla 
7071bed185SLokesh Vutla /* CFG_XXX */
7171bed185SLokesh Vutla #define CFG_X_SIGNATURE_SHIFT		12
7271bed185SLokesh Vutla #define CFG_X_SIGNATURE_MASK		(0x3F << 12)
7371bed185SLokesh Vutla #define CFG_X_LOCK_SHIFT		10
7471bed185SLokesh Vutla #define CFG_X_LOCK_MASK			(0x1 << 10)
7571bed185SLokesh Vutla #define CFG_X_COARSE_DLY_SHIFT		5
7671bed185SLokesh Vutla #define CFG_X_COARSE_DLY_MASK		(0x1F << 5)
7771bed185SLokesh Vutla #define CFG_X_FINE_DLY_SHIFT		0
7871bed185SLokesh Vutla #define CFG_X_FINE_DLY_MASK		(0x1F << 0)
7971bed185SLokesh Vutla #define CFG_X_SIGNATURE			0x29
8071bed185SLokesh Vutla #define CFG_X_LOCK			1
8171bed185SLokesh Vutla 
8271bed185SLokesh Vutla void __recalibrate_iodelay(struct pad_conf_entry const *pad, int npads,
8371bed185SLokesh Vutla 			   struct iodelay_cfg_entry const *iodelay,
8471bed185SLokesh Vutla 			   int niodelays);
856a27333bSKishon Vijay Abraham I void late_recalibrate_iodelay(struct pad_conf_entry const *pad, int npads,
866a27333bSKishon Vijay Abraham I 			      struct iodelay_cfg_entry const *iodelay,
876a27333bSKishon Vijay Abraham I 			      int niodelays);
88ceb7d77dSNishanth Menon int __recalibrate_iodelay_start(void);
89ceb7d77dSNishanth Menon void __recalibrate_iodelay_end(int ret);
9071bed185SLokesh Vutla 
91c755e675SNishanth Menon int do_set_iodelay(u32 base, struct iodelay_cfg_entry const *array,
92c755e675SNishanth Menon 		   int niodelays);
93eda6fbccSLokesh Vutla #endif
94