linux/include/linux/mtd/cfi.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright © 2000-2010 David Woodhouse <[email protected]> et al.
 */

#ifndef __MTD_CFI_H__
#define __MTD_CFI_H__

#include <linux/delay.h>
#include <linux/types.h>
#include <linux/bug.h>
#include <linux/interrupt.h>
#include <linux/mtd/flashchip.h>
#include <linux/mtd/map.h>
#include <linux/mtd/cfi_endian.h>
#include <linux/mtd/xip.h>

#ifdef CONFIG_MTD_CFI_I1
#define cfi_interleave(cfi)
#define cfi_interleave_is_1(cfi)
#else
#define cfi_interleave_is_1
#endif

#ifdef CONFIG_MTD_CFI_I2
# ifdef cfi_interleave
#  undef cfi_interleave
#define cfi_interleave(cfi)
# else
#define cfi_interleave
# endif
#define cfi_interleave_is_2(cfi)
#else
#define cfi_interleave_is_2
#endif

#ifdef CONFIG_MTD_CFI_I4
# ifdef cfi_interleave
#  undef cfi_interleave
#define cfi_interleave(cfi)
# else
#define cfi_interleave
# endif
#define cfi_interleave_is_4(cfi)
#else
#define cfi_interleave_is_4
#endif

#ifdef CONFIG_MTD_CFI_I8
# ifdef cfi_interleave
#  undef cfi_interleave
#define cfi_interleave(cfi)
# else
#define cfi_interleave
# endif
#define cfi_interleave_is_8(cfi)
#else
#define cfi_interleave_is_8
#endif

#ifndef cfi_interleave
#warning No CONFIG_MTD_CFI_Ix selected. No NOR chip support can work.
static inline int cfi_interleave(void *cfi)
{
	BUG();
	return 0;
}
#endif

static inline int cfi_interleave_supported(int i)
{}


/* NB: these values must represents the number of bytes needed to meet the
 *     device type (x8, x16, x32).  Eg. a 32 bit device is 4 x 8 bytes.
 *     These numbers are used in calculations.
 */
#define CFI_DEVICETYPE_X8
#define CFI_DEVICETYPE_X16
#define CFI_DEVICETYPE_X32
#define CFI_DEVICETYPE_X64


/* Device Interface Code Assignments from the "Common Flash Memory Interface
 * Publication 100" dated December 1, 2001.
 */
#define CFI_INTERFACE_X8_ASYNC
#define CFI_INTERFACE_X16_ASYNC
#define CFI_INTERFACE_X8_BY_X16_ASYNC
#define CFI_INTERFACE_X32_ASYNC
#define CFI_INTERFACE_X16_BY_X32_ASYNC
#define CFI_INTERFACE_NOT_ALLOWED


/* NB: We keep these structures in memory in HOST byteorder, except
 * where individually noted.
 */

/* Basic Query Structure */
struct cfi_ident {} __packed;

/* Extended Query Structure for both PRI and ALT */

struct cfi_extquery {} __packed;

/* Vendor-Specific PRI for Intel/Sharp Extended Command Set (0x0001) */

struct cfi_pri_intelext {} __packed;

struct cfi_intelext_otpinfo {} __packed;

struct cfi_intelext_blockinfo {} __packed;

struct cfi_intelext_regioninfo {} __packed;

struct cfi_intelext_programming_regioninfo {} __packed;

/* Vendor-Specific PRI for AMD/Fujitsu Extended Command Set (0x0002) */

struct cfi_pri_amdstd {} __packed;

/* Vendor-Specific PRI for Atmel chips (command set 0x0002) */

struct cfi_pri_atmel {} __packed;

struct cfi_pri_query {} __packed;

struct cfi_bri_query {} __packed;

#define P_ID_NONE
#define P_ID_INTEL_EXT
#define P_ID_AMD_STD
#define P_ID_INTEL_STD
#define P_ID_AMD_EXT
#define P_ID_WINBOND
#define P_ID_ST_ADV
#define P_ID_MITSUBISHI_STD
#define P_ID_MITSUBISHI_EXT
#define P_ID_SST_PAGE
#define P_ID_SST_OLD
#define P_ID_INTEL_PERFORMANCE
#define P_ID_INTEL_DATA
#define P_ID_RESERVED


#define CFI_MODE_CFI
#define CFI_MODE_JEDEC

struct cfi_private {};

uint32_t cfi_build_cmd_addr(uint32_t cmd_ofs,
				struct map_info *map, struct cfi_private *cfi);

map_word cfi_build_cmd(u_long cmd, struct map_info *map, struct cfi_private *cfi);
#define CMD(x)

unsigned long cfi_merge_status(map_word val, struct map_info *map,
					   struct cfi_private *cfi);
#define MERGESTATUS(x)

uint32_t cfi_send_gen_cmd(u_char cmd, uint32_t cmd_addr, uint32_t base,
				struct map_info *map, struct cfi_private *cfi,
				int type, map_word *prev_val);

static inline uint8_t cfi_read_query(struct map_info *map, uint32_t addr)
{}

static inline uint16_t cfi_read_query16(struct map_info *map, uint32_t addr)
{}

void cfi_udelay(int us);

int __xipram cfi_qry_present(struct map_info *map, __u32 base,
			     struct cfi_private *cfi);
int __xipram cfi_qry_mode_on(uint32_t base, struct map_info *map,
			     struct cfi_private *cfi);
void __xipram cfi_qry_mode_off(uint32_t base, struct map_info *map,
			       struct cfi_private *cfi);

struct cfi_extquery *cfi_read_pri(struct map_info *map, uint16_t adr, uint16_t size,
			     const char* name);
struct cfi_fixup {};

#define CFI_MFR_ANY
#define CFI_ID_ANY
#define CFI_MFR_CONTINUATION

#define CFI_MFR_AMD
#define CFI_MFR_AMIC
#define CFI_MFR_ATMEL
#define CFI_MFR_EON
#define CFI_MFR_FUJITSU
#define CFI_MFR_HYUNDAI
#define CFI_MFR_INTEL
#define CFI_MFR_MACRONIX
#define CFI_MFR_NEC
#define CFI_MFR_PMC
#define CFI_MFR_SAMSUNG
#define CFI_MFR_SHARP
#define CFI_MFR_SST
#define CFI_MFR_ST
#define CFI_MFR_MICRON
#define CFI_MFR_TOSHIBA
#define CFI_MFR_WINBOND

void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups);

varsize_frob_t;

int cfi_varsize_frob(struct mtd_info *mtd, varsize_frob_t frob,
	loff_t ofs, size_t len, void *thunk);


#endif /* __MTD_CFI_H__ */