linux/include/linux/mtd/doc2000.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Linux driver for Disk-On-Chip devices
 *
 * Copyright © 1999 Machine Vision Holdings, Inc.
 * Copyright © 1999-2010 David Woodhouse <[email protected]>
 * Copyright © 2002-2003 Greg Ungerer <[email protected]>
 * Copyright © 2002-2003 SnapGear Inc
 */

#ifndef __MTD_DOC2000_H__
#define __MTD_DOC2000_H__

#include <linux/mtd/mtd.h>
#include <linux/mutex.h>

#define DoC_Sig1
#define DoC_Sig2

#define DoC_ChipID
#define DoC_DOCStatus
#define DoC_DOCControl
#define DoC_FloorSelect
#define DoC_CDSNControl
#define DoC_CDSNDeviceSelect
#define DoC_ECCConf
#define DoC_2k_ECCStatus

#define DoC_CDSNSlowIO
#define DoC_ECCSyndrome0
#define DoC_ECCSyndrome1
#define DoC_ECCSyndrome2
#define DoC_ECCSyndrome3
#define DoC_ECCSyndrome4
#define DoC_ECCSyndrome5
#define DoC_AliasResolution
#define DoC_ConfigInput
#define DoC_ReadPipeInit
#define DoC_WritePipeTerm
#define DoC_LastDataRead
#define DoC_NOP

#define DoC_Mil_CDSN_IO
#define DoC_2k_CDSN_IO

#define DoC_Mplus_NOP
#define DoC_Mplus_AliasResolution
#define DoC_Mplus_DOCControl
#define DoC_Mplus_AccessStatus
#define DoC_Mplus_DeviceSelect
#define DoC_Mplus_Configuration
#define DoC_Mplus_OutputControl
#define DoC_Mplus_FlashControl
#define DoC_Mplus_FlashSelect
#define DoC_Mplus_FlashCmd
#define DoC_Mplus_FlashAddress
#define DoC_Mplus_FlashData0
#define DoC_Mplus_FlashData1
#define DoC_Mplus_ReadPipeInit
#define DoC_Mplus_LastDataRead
#define DoC_Mplus_LastDataRead1
#define DoC_Mplus_WritePipeTerm
#define DoC_Mplus_ECCSyndrome0
#define DoC_Mplus_ECCSyndrome1
#define DoC_Mplus_ECCSyndrome2
#define DoC_Mplus_ECCSyndrome3
#define DoC_Mplus_ECCSyndrome4
#define DoC_Mplus_ECCSyndrome5
#define DoC_Mplus_ECCConf
#define DoC_Mplus_Toggle
#define DoC_Mplus_DownloadStatus
#define DoC_Mplus_CtrlConfirm
#define DoC_Mplus_Power

/* How to access the device?
 * On ARM, it'll be mmap'd directly with 32-bit wide accesses.
 * On PPC, it's mmap'd and 16-bit wide.
 * Others use readb/writeb
 */
#if defined(__arm__)
static inline u8 ReadDOC_(u32 __iomem *addr, unsigned long reg)
{
	return __raw_readl(addr + reg);
}
static inline void WriteDOC_(u8 data, u32 __iomem *addr, unsigned long reg)
{
	__raw_writel(data, addr + reg);
	wmb();
}
#define DOC_IOREMAP_LEN
#elif defined(__ppc__)
static inline u8 ReadDOC_(u16 __iomem *addr, unsigned long reg)
{
	return __raw_readw(addr + reg);
}
static inline void WriteDOC_(u8 data, u16 __iomem *addr, unsigned long reg)
{
	__raw_writew(data, addr + reg);
	wmb();
}
#define DOC_IOREMAP_LEN
#else
#define ReadDOC_(adr, reg)
#define WriteDOC_(d, adr, reg)
#define DOC_IOREMAP_LEN

#endif

#if defined(__i386__) || defined(__x86_64__)
#define USE_MEMCPY
#endif

/* These are provided to directly use the DoC_xxx defines */
#define ReadDOC(adr, reg)
#define WriteDOC(d, adr, reg)

#define DOC_MODE_RESET
#define DOC_MODE_NORMAL
#define DOC_MODE_RESERVED1
#define DOC_MODE_RESERVED2

#define DOC_MODE_CLR_ERR
#define DOC_MODE_RST_LAT
#define DOC_MODE_BDECT
#define DOC_MODE_MDWREN

#define DOC_ChipID_Doc2k
#define DOC_ChipID_Doc2kTSOP
#define DOC_ChipID_DocMil
#define DOC_ChipID_DocMilPlus32
#define DOC_ChipID_DocMilPlus16

#define CDSN_CTRL_FR_B
#define CDSN_CTRL_FR_B0
#define CDSN_CTRL_FR_B1

#define CDSN_CTRL_ECC_IO
#define CDSN_CTRL_FLASH_IO
#define CDSN_CTRL_WP
#define CDSN_CTRL_ALE
#define CDSN_CTRL_CLE
#define CDSN_CTRL_CE

#define DOC_ECC_RESET
#define DOC_ECC_ERROR
#define DOC_ECC_RW
#define DOC_ECC__EN
#define DOC_TOGGLE_BIT
#define DOC_ECC_RESV
#define DOC_ECC_IGNORE

#define DOC_FLASH_CE
#define DOC_FLASH_WP
#define DOC_FLASH_BANK

/* We have to also set the reserved bit 1 for enable */
#define DOC_ECC_EN
#define DOC_ECC_DIS

struct Nand {};

#define MAX_FLOORS
#define MAX_CHIPS

#define MAX_FLOORS_MIL
#define MAX_CHIPS_MIL

#define MAX_FLOORS_MPLUS
#define MAX_CHIPS_MPLUS

#define ADDR_COLUMN
#define ADDR_PAGE
#define ADDR_COLUMN_PAGE

struct DiskOnChip {};

int doc_decode_ecc(unsigned char sector[512], unsigned char ecc1[6]);

#endif /* __MTD_DOC2000_H__ */