162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2016 Marvell, All Rights Reserved. 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Author: Hu Ziji <huziji@marvell.com> 662306a36Sopenharmony_ci * Date: 2016-8-24 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci#ifndef SDHCI_XENON_H_ 962306a36Sopenharmony_ci#define SDHCI_XENON_H_ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci/* Register Offset of Xenon SDHC self-defined register */ 1262306a36Sopenharmony_ci#define XENON_SYS_CFG_INFO 0x0104 1362306a36Sopenharmony_ci#define XENON_SLOT_TYPE_SDIO_SHIFT 24 1462306a36Sopenharmony_ci#define XENON_NR_SUPPORTED_SLOT_MASK 0x7 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci#define XENON_SYS_OP_CTRL 0x0108 1762306a36Sopenharmony_ci#define XENON_AUTO_CLKGATE_DISABLE_MASK BIT(20) 1862306a36Sopenharmony_ci#define XENON_SDCLK_IDLEOFF_ENABLE_SHIFT 8 1962306a36Sopenharmony_ci#define XENON_SLOT_ENABLE_SHIFT 0 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#define XENON_SYS_EXT_OP_CTRL 0x010C 2262306a36Sopenharmony_ci#define XENON_MASK_CMD_CONFLICT_ERR BIT(8) 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci#define XENON_SLOT_OP_STATUS_CTRL 0x0128 2562306a36Sopenharmony_ci#define XENON_TUN_CONSECUTIVE_TIMES_SHIFT 16 2662306a36Sopenharmony_ci#define XENON_TUN_CONSECUTIVE_TIMES_MASK 0x7 2762306a36Sopenharmony_ci#define XENON_TUN_CONSECUTIVE_TIMES 0x4 2862306a36Sopenharmony_ci#define XENON_TUNING_STEP_SHIFT 12 2962306a36Sopenharmony_ci#define XENON_TUNING_STEP_MASK 0xF 3062306a36Sopenharmony_ci#define XENON_TUNING_STEP_DIVIDER BIT(6) 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci#define XENON_SLOT_EMMC_CTRL 0x0130 3362306a36Sopenharmony_ci#define XENON_ENABLE_RESP_STROBE BIT(25) 3462306a36Sopenharmony_ci#define XENON_ENABLE_DATA_STROBE BIT(24) 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci#define XENON_SLOT_RETUNING_REQ_CTRL 0x0144 3762306a36Sopenharmony_ci/* retuning compatible */ 3862306a36Sopenharmony_ci#define XENON_RETUNING_COMPATIBLE 0x1 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci#define XENON_SLOT_EXT_PRESENT_STATE 0x014C 4162306a36Sopenharmony_ci#define XENON_DLL_LOCK_STATE 0x1 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci#define XENON_SLOT_DLL_CUR_DLY_VAL 0x0150 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci/* Tuning Parameter */ 4662306a36Sopenharmony_ci#define XENON_TMR_RETUN_NO_PRESENT 0xF 4762306a36Sopenharmony_ci#define XENON_DEF_TUNING_COUNT 0x9 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci#define XENON_DEFAULT_SDCLK_FREQ 400000 5062306a36Sopenharmony_ci#define XENON_LOWEST_SDCLK_FREQ 100000 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci/* Xenon specific Mode Select value */ 5362306a36Sopenharmony_ci#define XENON_CTRL_HS200 0x5 5462306a36Sopenharmony_ci#define XENON_CTRL_HS400 0x6 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_cienum xenon_variant { 5762306a36Sopenharmony_ci XENON_A3700, 5862306a36Sopenharmony_ci XENON_AP806, 5962306a36Sopenharmony_ci XENON_AP807, 6062306a36Sopenharmony_ci XENON_CP110 6162306a36Sopenharmony_ci}; 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_cistruct xenon_priv { 6462306a36Sopenharmony_ci unsigned char tuning_count; 6562306a36Sopenharmony_ci /* idx of SDHC */ 6662306a36Sopenharmony_ci u8 sdhc_id; 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci /* 6962306a36Sopenharmony_ci * eMMC/SD/SDIO require different register settings. 7062306a36Sopenharmony_ci * Xenon driver has to recognize card type 7162306a36Sopenharmony_ci * before mmc_host->card is not available. 7262306a36Sopenharmony_ci * This field records the card type during init. 7362306a36Sopenharmony_ci * It is updated in xenon_init_card(). 7462306a36Sopenharmony_ci * 7562306a36Sopenharmony_ci * It is only valid during initialization after it is updated. 7662306a36Sopenharmony_ci * Do not access this variable in normal transfers after 7762306a36Sopenharmony_ci * initialization completes. 7862306a36Sopenharmony_ci */ 7962306a36Sopenharmony_ci unsigned int init_card_type; 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci /* 8262306a36Sopenharmony_ci * The bus_width, timing, and clock fields in below 8362306a36Sopenharmony_ci * record the current ios setting of Xenon SDHC. 8462306a36Sopenharmony_ci * Driver will adjust PHY setting if any change to 8562306a36Sopenharmony_ci * ios affects PHY timing. 8662306a36Sopenharmony_ci */ 8762306a36Sopenharmony_ci unsigned char bus_width; 8862306a36Sopenharmony_ci unsigned char timing; 8962306a36Sopenharmony_ci unsigned int clock; 9062306a36Sopenharmony_ci struct clk *axi_clk; 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci int phy_type; 9362306a36Sopenharmony_ci /* 9462306a36Sopenharmony_ci * Contains board-specific PHY parameters 9562306a36Sopenharmony_ci * passed from device tree. 9662306a36Sopenharmony_ci */ 9762306a36Sopenharmony_ci void *phy_params; 9862306a36Sopenharmony_ci struct xenon_emmc_phy_regs *emmc_phy_regs; 9962306a36Sopenharmony_ci bool restore_needed; 10062306a36Sopenharmony_ci enum xenon_variant hw_version; 10162306a36Sopenharmony_ci}; 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ciint xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios); 10462306a36Sopenharmony_ciint xenon_phy_parse_params(struct device *dev, 10562306a36Sopenharmony_ci struct sdhci_host *host); 10662306a36Sopenharmony_civoid xenon_soc_pad_ctrl(struct sdhci_host *host, 10762306a36Sopenharmony_ci unsigned char signal_voltage); 10862306a36Sopenharmony_ci#endif 109