162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Freescale eSDHC controller driver generics for OF and pltfm.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (c) 2007 Freescale Semiconductor, Inc.
662306a36Sopenharmony_ci * Copyright (c) 2009 MontaVista Software, Inc.
762306a36Sopenharmony_ci * Copyright (c) 2010 Pengutronix e.K.
862306a36Sopenharmony_ci * Copyright 2020 NXP
962306a36Sopenharmony_ci *   Author: Wolfram Sang <kernel@pengutronix.de>
1062306a36Sopenharmony_ci */
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#ifndef _DRIVERS_MMC_SDHCI_ESDHC_H
1362306a36Sopenharmony_ci#define _DRIVERS_MMC_SDHCI_ESDHC_H
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci/*
1662306a36Sopenharmony_ci * Ops and quirks for the Freescale eSDHC controller.
1762306a36Sopenharmony_ci */
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#define ESDHC_DEFAULT_QUIRKS	(SDHCI_QUIRK_FORCE_BLK_SZ_2048 | \
2062306a36Sopenharmony_ci				SDHCI_QUIRK_32BIT_DMA_ADDR | \
2162306a36Sopenharmony_ci				SDHCI_QUIRK_NO_BUSY_IRQ | \
2262306a36Sopenharmony_ci				SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK | \
2362306a36Sopenharmony_ci				SDHCI_QUIRK_PIO_NEEDS_DELAY | \
2462306a36Sopenharmony_ci				SDHCI_QUIRK_NO_HISPD_BIT)
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci/* pltfm-specific */
2762306a36Sopenharmony_ci#define ESDHC_HOST_CONTROL_LE	0x20
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci/*
3062306a36Sopenharmony_ci * eSDHC register definition
3162306a36Sopenharmony_ci */
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci/* Present State Register */
3462306a36Sopenharmony_ci#define ESDHC_PRSSTAT			0x24
3562306a36Sopenharmony_ci#define ESDHC_CLOCK_GATE_OFF		0x00000080
3662306a36Sopenharmony_ci#define ESDHC_CLOCK_STABLE		0x00000008
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci/* Protocol Control Register */
3962306a36Sopenharmony_ci#define ESDHC_PROCTL			0x28
4062306a36Sopenharmony_ci#define ESDHC_VOLT_SEL			0x00000400
4162306a36Sopenharmony_ci#define ESDHC_CTRL_4BITBUS		(0x1 << 1)
4262306a36Sopenharmony_ci#define ESDHC_CTRL_8BITBUS		(0x2 << 1)
4362306a36Sopenharmony_ci#define ESDHC_CTRL_BUSWIDTH_MASK	(0x3 << 1)
4462306a36Sopenharmony_ci#define ESDHC_HOST_CONTROL_RES		0x01
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci/* System Control Register */
4762306a36Sopenharmony_ci#define ESDHC_SYSTEM_CONTROL		0x2c
4862306a36Sopenharmony_ci#define ESDHC_CLOCK_MASK		0x0000fff0
4962306a36Sopenharmony_ci#define ESDHC_PREDIV_SHIFT		8
5062306a36Sopenharmony_ci#define ESDHC_DIVIDER_SHIFT		4
5162306a36Sopenharmony_ci#define ESDHC_CLOCK_SDCLKEN		0x00000008
5262306a36Sopenharmony_ci#define ESDHC_CLOCK_PEREN		0x00000004
5362306a36Sopenharmony_ci#define ESDHC_CLOCK_HCKEN		0x00000002
5462306a36Sopenharmony_ci#define ESDHC_CLOCK_IPGEN		0x00000001
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/* System Control 2 Register */
5762306a36Sopenharmony_ci#define ESDHC_SYSTEM_CONTROL_2		0x3c
5862306a36Sopenharmony_ci#define ESDHC_SMPCLKSEL			0x00800000
5962306a36Sopenharmony_ci#define ESDHC_EXTN			0x00400000
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci/* Host Controller Capabilities Register 2 */
6262306a36Sopenharmony_ci#define ESDHC_CAPABILITIES_1		0x114
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci/* Tuning Block Control Register */
6562306a36Sopenharmony_ci#define ESDHC_TBCTL			0x120
6662306a36Sopenharmony_ci#define ESDHC_HS400_WNDW_ADJUST		0x00000040
6762306a36Sopenharmony_ci#define ESDHC_HS400_MODE		0x00000010
6862306a36Sopenharmony_ci#define ESDHC_TB_EN			0x00000004
6962306a36Sopenharmony_ci#define ESDHC_TB_MODE_MASK		0x00000003
7062306a36Sopenharmony_ci#define ESDHC_TB_MODE_SW		0x00000003
7162306a36Sopenharmony_ci#define ESDHC_TB_MODE_3			0x00000002
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci#define ESDHC_TBSTAT			0x124
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci#define ESDHC_TBPTR			0x128
7662306a36Sopenharmony_ci#define ESDHC_WNDW_STRT_PTR_SHIFT	8
7762306a36Sopenharmony_ci#define ESDHC_WNDW_STRT_PTR_MASK	(0x7f << 8)
7862306a36Sopenharmony_ci#define ESDHC_WNDW_END_PTR_MASK		0x7f
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci/* SD Clock Control Register */
8162306a36Sopenharmony_ci#define ESDHC_SDCLKCTL			0x144
8262306a36Sopenharmony_ci#define ESDHC_LPBK_CLK_SEL		0x80000000
8362306a36Sopenharmony_ci#define ESDHC_CMD_CLK_CTL		0x00008000
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci/* SD Timing Control Register */
8662306a36Sopenharmony_ci#define ESDHC_SDTIMNGCTL		0x148
8762306a36Sopenharmony_ci#define ESDHC_FLW_CTL_BG		0x00008000
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci/* DLL Config 0 Register */
9062306a36Sopenharmony_ci#define ESDHC_DLLCFG0			0x160
9162306a36Sopenharmony_ci#define ESDHC_DLL_ENABLE		0x80000000
9262306a36Sopenharmony_ci#define ESDHC_DLL_RESET			0x40000000
9362306a36Sopenharmony_ci#define ESDHC_DLL_FREQ_SEL		0x08000000
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci/* DLL Config 1 Register */
9662306a36Sopenharmony_ci#define ESDHC_DLLCFG1			0x164
9762306a36Sopenharmony_ci#define ESDHC_DLL_PD_PULSE_STRETCH_SEL	0x80000000
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci/* DLL Status 0 Register */
10062306a36Sopenharmony_ci#define ESDHC_DLLSTAT0			0x170
10162306a36Sopenharmony_ci#define ESDHC_DLL_STS_SLV_LOCK		0x08000000
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci/* Control Register for DMA transfer */
10462306a36Sopenharmony_ci#define ESDHC_DMA_SYSCTL		0x40c
10562306a36Sopenharmony_ci#define ESDHC_PERIPHERAL_CLK_SEL	0x00080000
10662306a36Sopenharmony_ci#define ESDHC_FLUSH_ASYNC_FIFO		0x00040000
10762306a36Sopenharmony_ci#define ESDHC_DMA_SNOOP			0x00000040
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci#endif /* _DRIVERS_MMC_SDHCI_ESDHC_H */
110