linux/include/uapi/mtd/mtd-abi.h

/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
/*
 * Copyright © 1999-2010 David Woodhouse <[email protected]> et al.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

#ifndef __MTD_ABI_H__
#define __MTD_ABI_H__

#include <linux/types.h>

struct erase_info_user {};

struct erase_info_user64 {};

struct mtd_oob_buf {};

struct mtd_oob_buf64 {};

/**
 * MTD operation modes
 *
 * @MTD_OPS_PLACE_OOB:	OOB data are placed at the given offset (default)
 * @MTD_OPS_AUTO_OOB:	OOB data are automatically placed at the free areas
 *			which are defined by the internal ecclayout
 * @MTD_OPS_RAW:	data are transferred as-is, with no error correction;
 *			this mode implies %MTD_OPS_PLACE_OOB
 *
 * These modes can be passed to ioctl(MEMWRITE) and ioctl(MEMREAD); they are
 * also used internally. See notes on "MTD file modes" for discussion on
 * %MTD_OPS_RAW vs. %MTD_FILE_MODE_RAW.
 */
enum {};

/**
 * struct mtd_write_req - data structure for requesting a write operation
 *
 * @start:	start address
 * @len:	length of data buffer (only lower 32 bits are used)
 * @ooblen:	length of OOB buffer (only lower 32 bits are used)
 * @usr_data:	user-provided data buffer
 * @usr_oob:	user-provided OOB buffer
 * @mode:	MTD mode (see "MTD operation modes")
 * @padding:	reserved, must be set to 0
 *
 * This structure supports ioctl(MEMWRITE) operations, allowing data and/or OOB
 * writes in various modes. To write to OOB-only, set @usr_data == NULL, and to
 * write data-only, set @usr_oob == NULL. However, setting both @usr_data and
 * @usr_oob to NULL is not allowed.
 */
struct mtd_write_req {};

/**
 * struct mtd_read_req_ecc_stats - ECC statistics for a read operation
 *
 * @uncorrectable_errors: the number of uncorrectable errors that happened
 *			  during the read operation
 * @corrected_bitflips: the number of bitflips corrected during the read
 *			operation
 * @max_bitflips: the maximum number of bitflips detected in any single ECC
 *		  step for the data read during the operation; this information
 *		  can be used to decide whether the data stored in a specific
 *		  region of the MTD device should be moved somewhere else to
 *		  avoid data loss.
 */
struct mtd_read_req_ecc_stats {};

/**
 * struct mtd_read_req - data structure for requesting a read operation
 *
 * @start:	start address
 * @len:	length of data buffer (only lower 32 bits are used)
 * @ooblen:	length of OOB buffer (only lower 32 bits are used)
 * @usr_data:	user-provided data buffer
 * @usr_oob:	user-provided OOB buffer
 * @mode:	MTD mode (see "MTD operation modes")
 * @padding:	reserved, must be set to 0
 * @ecc_stats:	ECC statistics for the read operation
 *
 * This structure supports ioctl(MEMREAD) operations, allowing data and/or OOB
 * reads in various modes. To read from OOB-only, set @usr_data == NULL, and to
 * read data-only, set @usr_oob == NULL. However, setting both @usr_data and
 * @usr_oob to NULL is not allowed.
 */
struct mtd_read_req {};

#define MTD_ABSENT
#define MTD_RAM
#define MTD_ROM
#define MTD_NORFLASH
#define MTD_NANDFLASH
#define MTD_DATAFLASH
#define MTD_UBIVOLUME
#define MTD_MLCNANDFLASH

#define MTD_WRITEABLE
#define MTD_BIT_WRITEABLE
#define MTD_NO_ERASE
#define MTD_POWERUP_LOCK
#define MTD_SLC_ON_MLC_EMULATION

/* Some common devices / combinations of capabilities */
#define MTD_CAP_ROM
#define MTD_CAP_RAM
#define MTD_CAP_NORFLASH
#define MTD_CAP_NANDFLASH
#define MTD_CAP_NVRAM

/* Obsolete ECC byte placement modes (used with obsolete MEMGETOOBSEL) */
#define MTD_NANDECC_OFF
#define MTD_NANDECC_PLACE
#define MTD_NANDECC_AUTOPLACE
#define MTD_NANDECC_PLACEONLY
#define MTD_NANDECC_AUTOPL_USR

/* OTP mode selection */
#define MTD_OTP_OFF
#define MTD_OTP_FACTORY
#define MTD_OTP_USER

struct mtd_info_user {};

struct region_info_user {};

struct otp_info {};

/*
 * Note, the following ioctl existed in the past and was removed:
 * #define MEMSETOOBSEL           _IOW('M', 9, struct nand_oobinfo)
 * Try to avoid adding a new ioctl with the same ioctl number.
 */

/* Get basic MTD characteristics info (better to use sysfs) */
#define MEMGETINFO
/* Erase segment of MTD */
#define MEMERASE
/* Write out-of-band data from MTD */
#define MEMWRITEOOB
/* Read out-of-band data from MTD */
#define MEMREADOOB
/* Lock a chip (for MTD that supports it) */
#define MEMLOCK
/* Unlock a chip (for MTD that supports it) */
#define MEMUNLOCK
/* Get the number of different erase regions */
#define MEMGETREGIONCOUNT
/* Get information about the erase region for a specific index */
#define MEMGETREGIONINFO
/* Get info about OOB modes (e.g., RAW, PLACE, AUTO) - legacy interface */
#define MEMGETOOBSEL
/* Check if an eraseblock is bad */
#define MEMGETBADBLOCK
/* Mark an eraseblock as bad */
#define MEMSETBADBLOCK
/* Set OTP (One-Time Programmable) mode (factory vs. user) */
#define OTPSELECT
/* Get number of OTP (One-Time Programmable) regions */
#define OTPGETREGIONCOUNT
/* Get all OTP (One-Time Programmable) info about MTD */
#define OTPGETREGIONINFO
/* Lock a given range of user data (must be in mode %MTD_FILE_MODE_OTP_USER) */
#define OTPLOCK
/* Get ECC layout (deprecated) */
#define ECCGETLAYOUT
/* Get statistics about corrected/uncorrected errors */
#define ECCGETSTATS
/* Set MTD mode on a per-file-descriptor basis (see "MTD file modes") */
#define MTDFILEMODE
/* Erase segment of MTD (supports 64-bit address) */
#define MEMERASE64
/* Write data to OOB (64-bit version) */
#define MEMWRITEOOB64
/* Read data from OOB (64-bit version) */
#define MEMREADOOB64
/* Check if chip is locked (for MTD that supports it) */
#define MEMISLOCKED
/*
 * Most generic write interface; can write in-band and/or out-of-band in various
 * modes (see "struct mtd_write_req"). This ioctl is not supported for flashes
 * without OOB, e.g., NOR flash.
 */
#define MEMWRITE
/* Erase a given range of user data (must be in mode %MTD_FILE_MODE_OTP_USER) */
#define OTPERASE
/*
 * Most generic read interface; can read in-band and/or out-of-band in various
 * modes (see "struct mtd_read_req"). This ioctl is not supported for flashes
 * without OOB, e.g., NOR flash.
 */
#define MEMREAD

/*
 * Obsolete legacy interface. Keep it in order not to break userspace
 * interfaces
 */
struct nand_oobinfo {};

struct nand_oobfree {};

#define MTD_MAX_OOBFREE_ENTRIES
#define MTD_MAX_ECCPOS_ENTRIES
/*
 * OBSOLETE: ECC layout control structure. Exported to user-space via ioctl
 * ECCGETLAYOUT for backwards compatbility and should not be mistaken as a
 * complete set of ECC information. The ioctl truncates the larger internal
 * structure to retain binary compatibility with the static declaration of the
 * ioctl. Note that the "MTD_MAX_..._ENTRIES" macros represent the max size of
 * the user struct, not the MAX size of the internal OOB layout representation.
 */
struct nand_ecclayout_user {};

/**
 * struct mtd_ecc_stats - error correction stats
 *
 * @corrected:	number of corrected bits
 * @failed:	number of uncorrectable errors
 * @badblocks:	number of bad blocks in this partition
 * @bbtblocks:	number of blocks reserved for bad block tables
 */
struct mtd_ecc_stats {};

/*
 * MTD file modes - for read/write access to MTD
 *
 * @MTD_FILE_MODE_NORMAL:	OTP disabled, ECC enabled
 * @MTD_FILE_MODE_OTP_FACTORY:	OTP enabled in factory mode
 * @MTD_FILE_MODE_OTP_USER:	OTP enabled in user mode
 * @MTD_FILE_MODE_RAW:		OTP disabled, ECC disabled
 *
 * These modes can be set via ioctl(MTDFILEMODE). The mode will be retained
 * separately for each open file descriptor.
 *
 * Note: %MTD_FILE_MODE_RAW provides the same functionality as %MTD_OPS_RAW -
 * raw access to the flash, without error correction or autoplacement schemes.
 * Wherever possible, the MTD_OPS_* mode will override the MTD_FILE_MODE_* mode
 * (e.g., when using ioctl(MEMWRITE) or ioctl(MEMREAD)), but in some cases, the
 * MTD_FILE_MODE is used out of necessity (e.g., `write()',
 * ioctl(MEMWRITEOOB64)).
 */
enum mtd_file_modes {};

static inline int mtd_type_is_nand_user(const struct mtd_info_user *mtd)
{}

#endif /* __MTD_ABI_H__ */