drivers/mtd/nand/raw/nand_hynix.c
Source file repositories/reference/linux-study-clean/drivers/mtd/nand/raw/nand_hynix.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/nand/raw/nand_hynix.c- Extension
.c- Size
- 18204 bytes
- Lines
- 748
- Domain
- Driver Families
- Bucket
- drivers/mtd
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/sizes.hlinux/slab.hinternals.h
Detected Declarations
struct hynix_read_retrystruct hynix_nandstruct hynix_read_retry_otpfunction hynix_nand_has_valid_jedecidfunction hynix_nand_cmd_opfunction hynix_nand_reg_write_opfunction hynix_nand_setup_read_retryfunction hynix_get_majorityfunction hynix_read_rr_otpfunction hynix_mlc_1xnm_rr_valuefunction hynix_mlc_1xnm_rr_initfunction hynix_nand_rr_initfunction hynix_nand_extract_oobsizefunction hynix_nand_extract_ecc_requirementsfunction hynix_nand_extract_scrambling_requirementsfunction hynix_nand_decode_idfunction hynix_nand_cleanupfunction h27ucg8t2atrbc_choose_interface_configfunction h27ucg8t2etrbc_initfunction hynix_nand_initfunction hynix_fixup_onfi_param_page
Annotated Snippet
struct hynix_read_retry {
int nregs;
const u8 *regs;
u8 values[];
};
/**
* struct hynix_nand - private Hynix NAND struct
* @read_retry: read-retry information
*/
struct hynix_nand {
const struct hynix_read_retry *read_retry;
};
/**
* struct hynix_read_retry_otp - structure describing how the read-retry OTP
* area
* @nregs: number of hynix private registers to set before reading the reading
* the OTP area
* @regs: registers that should be configured
* @values: values that should be set in regs
* @page: the address to pass to the READ_PAGE command. Depends on the NAND
* chip
* @size: size of the read-retry OTP section
*/
struct hynix_read_retry_otp {
int nregs;
const u8 *regs;
const u8 *values;
int page;
int size;
};
static bool hynix_nand_has_valid_jedecid(struct nand_chip *chip)
{
u8 jedecid[5] = { };
int ret;
ret = nand_readid_op(chip, 0x40, jedecid, sizeof(jedecid));
if (ret)
return false;
return !strncmp("JEDEC", jedecid, sizeof(jedecid));
}
static int hynix_nand_cmd_op(struct nand_chip *chip, u8 cmd)
{
if (nand_has_exec_op(chip)) {
struct nand_op_instr instrs[] = {
NAND_OP_CMD(cmd, 0),
};
struct nand_operation op = NAND_OPERATION(chip->cur_cs, instrs);
return nand_exec_op(chip, &op);
}
chip->legacy.cmdfunc(chip, cmd, -1, -1);
return 0;
}
static int hynix_nand_reg_write_op(struct nand_chip *chip, u8 addr, u8 val)
{
u16 column = ((u16)addr << 8) | addr;
if (nand_has_exec_op(chip)) {
struct nand_op_instr instrs[] = {
NAND_OP_ADDR(1, &addr, 0),
NAND_OP_8BIT_DATA_OUT(1, &val, 0),
};
struct nand_operation op = NAND_OPERATION(chip->cur_cs, instrs);
return nand_exec_op(chip, &op);
}
chip->legacy.cmdfunc(chip, NAND_CMD_NONE, column, -1);
chip->legacy.write_byte(chip, val);
return 0;
}
static int hynix_nand_setup_read_retry(struct nand_chip *chip, int retry_mode)
{
struct hynix_nand *hynix = nand_get_manufacturer_data(chip);
const u8 *values;
int i, ret;
values = hynix->read_retry->values +
(retry_mode * hynix->read_retry->nregs);
Annotation
- Immediate include surface: `linux/sizes.h`, `linux/slab.h`, `internals.h`.
- Detected declarations: `struct hynix_read_retry`, `struct hynix_nand`, `struct hynix_read_retry_otp`, `function hynix_nand_has_valid_jedecid`, `function hynix_nand_cmd_op`, `function hynix_nand_reg_write_op`, `function hynix_nand_setup_read_retry`, `function hynix_get_majority`, `function hynix_read_rr_otp`, `function hynix_mlc_1xnm_rr_value`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.