162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * cb710/cb710-mmc.h 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright by Michał Mirosław, 2008-2009 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci#ifndef LINUX_CB710_MMC_H 862306a36Sopenharmony_ci#define LINUX_CB710_MMC_H 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include <linux/cb710.h> 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci/* per-MMC-reader structure */ 1362306a36Sopenharmony_cistruct cb710_mmc_reader { 1462306a36Sopenharmony_ci struct tasklet_struct finish_req_tasklet; 1562306a36Sopenharmony_ci struct mmc_request *mrq; 1662306a36Sopenharmony_ci spinlock_t irq_lock; 1762306a36Sopenharmony_ci unsigned char last_power_mode; 1862306a36Sopenharmony_ci}; 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci/* some device struct walking */ 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_cistatic inline struct mmc_host *cb710_slot_to_mmc(struct cb710_slot *slot) 2362306a36Sopenharmony_ci{ 2462306a36Sopenharmony_ci return platform_get_drvdata(&slot->pdev); 2562306a36Sopenharmony_ci} 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_cistatic inline struct cb710_slot *cb710_mmc_to_slot(struct mmc_host *mmc) 2862306a36Sopenharmony_ci{ 2962306a36Sopenharmony_ci struct platform_device *pdev = to_platform_device(mmc_dev(mmc)); 3062306a36Sopenharmony_ci return cb710_pdev_to_slot(pdev); 3162306a36Sopenharmony_ci} 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci/* registers (this might be all wrong ;) */ 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#define CB710_MMC_DATA_PORT 0x00 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci#define CB710_MMC_CONFIG_PORT 0x04 3862306a36Sopenharmony_ci#define CB710_MMC_CONFIG0_PORT 0x04 3962306a36Sopenharmony_ci#define CB710_MMC_CONFIG1_PORT 0x05 4062306a36Sopenharmony_ci#define CB710_MMC_C1_4BIT_DATA_BUS 0x40 4162306a36Sopenharmony_ci#define CB710_MMC_CONFIG2_PORT 0x06 4262306a36Sopenharmony_ci#define CB710_MMC_C2_READ_PIO_SIZE_MASK 0x0F /* N-1 */ 4362306a36Sopenharmony_ci#define CB710_MMC_CONFIG3_PORT 0x07 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci#define CB710_MMC_CONFIGB_PORT 0x08 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci#define CB710_MMC_IRQ_ENABLE_PORT 0x0C 4862306a36Sopenharmony_ci#define CB710_MMC_IE_TEST_MASK 0x00BF 4962306a36Sopenharmony_ci#define CB710_MMC_IE_CARD_INSERTION_STATUS 0x1000 5062306a36Sopenharmony_ci#define CB710_MMC_IE_IRQ_ENABLE 0x8000 5162306a36Sopenharmony_ci#define CB710_MMC_IE_CISTATUS_MASK \ 5262306a36Sopenharmony_ci (CB710_MMC_IE_CARD_INSERTION_STATUS|CB710_MMC_IE_IRQ_ENABLE) 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci#define CB710_MMC_STATUS_PORT 0x10 5562306a36Sopenharmony_ci#define CB710_MMC_STATUS_ERROR_EVENTS 0x60FF 5662306a36Sopenharmony_ci#define CB710_MMC_STATUS0_PORT 0x10 5762306a36Sopenharmony_ci#define CB710_MMC_S0_FIFO_UNDERFLOW 0x40 5862306a36Sopenharmony_ci#define CB710_MMC_STATUS1_PORT 0x11 5962306a36Sopenharmony_ci#define CB710_MMC_S1_COMMAND_SENT 0x01 6062306a36Sopenharmony_ci#define CB710_MMC_S1_DATA_TRANSFER_DONE 0x02 6162306a36Sopenharmony_ci#define CB710_MMC_S1_PIO_TRANSFER_DONE 0x04 6262306a36Sopenharmony_ci#define CB710_MMC_S1_CARD_CHANGED 0x10 6362306a36Sopenharmony_ci#define CB710_MMC_S1_RESET 0x20 6462306a36Sopenharmony_ci#define CB710_MMC_STATUS2_PORT 0x12 6562306a36Sopenharmony_ci#define CB710_MMC_S2_FIFO_READY 0x01 6662306a36Sopenharmony_ci#define CB710_MMC_S2_FIFO_EMPTY 0x02 6762306a36Sopenharmony_ci#define CB710_MMC_S2_BUSY_10 0x10 6862306a36Sopenharmony_ci#define CB710_MMC_S2_BUSY_20 0x20 6962306a36Sopenharmony_ci#define CB710_MMC_STATUS3_PORT 0x13 7062306a36Sopenharmony_ci#define CB710_MMC_S3_CARD_DETECTED 0x02 7162306a36Sopenharmony_ci#define CB710_MMC_S3_WRITE_PROTECTED 0x04 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci#define CB710_MMC_CMD_TYPE_PORT 0x14 7462306a36Sopenharmony_ci#define CB710_MMC_RSP_TYPE_MASK 0x0007 7562306a36Sopenharmony_ci#define CB710_MMC_RSP_R1 (0) 7662306a36Sopenharmony_ci#define CB710_MMC_RSP_136 (5) 7762306a36Sopenharmony_ci#define CB710_MMC_RSP_NO_CRC (2) 7862306a36Sopenharmony_ci#define CB710_MMC_RSP_PRESENT_MASK 0x0018 7962306a36Sopenharmony_ci#define CB710_MMC_RSP_NONE (0 << 3) 8062306a36Sopenharmony_ci#define CB710_MMC_RSP_PRESENT (1 << 3) 8162306a36Sopenharmony_ci#define CB710_MMC_RSP_PRESENT_X (2 << 3) 8262306a36Sopenharmony_ci#define CB710_MMC_CMD_TYPE_MASK 0x0060 8362306a36Sopenharmony_ci#define CB710_MMC_CMD_BC (0 << 5) 8462306a36Sopenharmony_ci#define CB710_MMC_CMD_BCR (1 << 5) 8562306a36Sopenharmony_ci#define CB710_MMC_CMD_AC (2 << 5) 8662306a36Sopenharmony_ci#define CB710_MMC_CMD_ADTC (3 << 5) 8762306a36Sopenharmony_ci#define CB710_MMC_DATA_READ 0x0080 8862306a36Sopenharmony_ci#define CB710_MMC_CMD_CODE_MASK 0x3F00 8962306a36Sopenharmony_ci#define CB710_MMC_CMD_CODE_SHIFT 8 9062306a36Sopenharmony_ci#define CB710_MMC_IS_APP_CMD 0x4000 9162306a36Sopenharmony_ci#define CB710_MMC_RSP_BUSY 0x8000 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci#define CB710_MMC_CMD_PARAM_PORT 0x18 9462306a36Sopenharmony_ci#define CB710_MMC_TRANSFER_SIZE_PORT 0x1C 9562306a36Sopenharmony_ci#define CB710_MMC_RESPONSE0_PORT 0x20 9662306a36Sopenharmony_ci#define CB710_MMC_RESPONSE1_PORT 0x24 9762306a36Sopenharmony_ci#define CB710_MMC_RESPONSE2_PORT 0x28 9862306a36Sopenharmony_ci#define CB710_MMC_RESPONSE3_PORT 0x2C 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci#endif /* LINUX_CB710_MMC_H */ 101