1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2022 Aidan MacDonald
5 * Author: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
8 #include <linux/device.h>
9 #include <linux/kernel.h>
10 #include <linux/mtd/spinand.h>
13 #define SPINAND_MFR_ATO 0x9b
16 static SPINAND_OP_VARIANTS(read_cache_variants
,
17 SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL
, 0),
18 SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL
, 0),
19 SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL
, 0));
21 static SPINAND_OP_VARIANTS(write_cache_variants
,
22 SPINAND_PROG_LOAD_X4(true, 0, NULL
, 0),
23 SPINAND_PROG_LOAD(true, 0, NULL
, 0));
25 static SPINAND_OP_VARIANTS(update_cache_variants
,
26 SPINAND_PROG_LOAD_X4(false, 0, NULL
, 0),
27 SPINAND_PROG_LOAD(false, 0, NULL
, 0));
30 static int ato25d1ga_ooblayout_ecc(struct mtd_info
*mtd
, int section
,
31 struct mtd_oob_region
*region
)
36 region
->offset
= (16 * section
) + 8;
41 static int ato25d1ga_ooblayout_free(struct mtd_info
*mtd
, int section
,
42 struct mtd_oob_region
*region
)
48 region
->offset
= (16 * section
);
51 /* first byte of section 0 is reserved for the BBM */
59 static const struct mtd_ooblayout_ops ato25d1ga_ooblayout
= {
60 .ecc
= ato25d1ga_ooblayout_ecc
,
61 .free
= ato25d1ga_ooblayout_free
,
65 static const struct spinand_info ato_spinand_table
[] = {
66 SPINAND_INFO("ATO25D1GA",
67 SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR
, 0x12),
68 NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
70 SPINAND_INFO_OP_VARIANTS(&read_cache_variants
,
71 &write_cache_variants
,
72 &update_cache_variants
),
74 SPINAND_ECCINFO(&ato25d1ga_ooblayout
, NULL
)),
77 static const struct spinand_manufacturer_ops ato_spinand_manuf_ops
= {
80 const struct spinand_manufacturer ato_spinand_manufacturer
= {
81 .id
= SPINAND_MFR_ATO
,
83 .chips
= ato_spinand_table
,
84 .nchips
= ARRAY_SIZE(ato_spinand_table
),
85 .ops
= &ato_spinand_manuf_ops
,