1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2020-2021 Rockchip Electronics Co., Ltd.
4 *
5 * Author: Dingqiang Lin <jon.lin@rock-chips.com>
6 */
7
8 #include <linux/device.h>
9 #include <linux/kernel.h>
10 #include <linux/mtd/spinand.h>
11
12 #define SPINAND_MFR_FMSH 0xA1
13
14 static SPINAND_OP_VARIANTS(read_cache_variants,
15 SPINAND_PAGE_READ_FROM_CACHE_1S_4S_4S_OP(0, 2, NULL, 0, 0),
16 SPINAND_PAGE_READ_FROM_CACHE_1S_1S_4S_OP(0, 1, NULL, 0, 0),
17 SPINAND_PAGE_READ_FROM_CACHE_1S_2S_2S_OP(0, 1, NULL, 0, 0),
18 SPINAND_PAGE_READ_FROM_CACHE_1S_1S_2S_OP(0, 1, NULL, 0, 0),
19 SPINAND_PAGE_READ_FROM_CACHE_FAST_1S_1S_1S_OP(0, 1, NULL, 0, 0),
20 SPINAND_PAGE_READ_FROM_CACHE_1S_1S_1S_OP(0, 1, NULL, 0, 0));
21
22 static SPINAND_OP_VARIANTS(write_cache_variants,
23 SPINAND_PROG_LOAD_1S_1S_4S_OP(true, 0, NULL, 0),
24 SPINAND_PROG_LOAD_1S_1S_1S_OP(true, 0, NULL, 0));
25
26 static SPINAND_OP_VARIANTS(update_cache_variants,
27 SPINAND_PROG_LOAD_1S_1S_4S_OP(false, 0, NULL, 0),
28 SPINAND_PROG_LOAD_1S_1S_1S_OP(false, 0, NULL, 0));
29
fm25s01a_ooblayout_ecc(struct mtd_info * mtd,int section,struct mtd_oob_region * region)30 static int fm25s01a_ooblayout_ecc(struct mtd_info *mtd, int section,
31 struct mtd_oob_region *region)
32 {
33 return -ERANGE;
34 }
35
fm25s01a_ooblayout_free(struct mtd_info * mtd,int section,struct mtd_oob_region * region)36 static int fm25s01a_ooblayout_free(struct mtd_info *mtd, int section,
37 struct mtd_oob_region *region)
38 {
39 if (section)
40 return -ERANGE;
41
42 region->offset = 2;
43 region->length = 62;
44
45 return 0;
46 }
47
48 static const struct mtd_ooblayout_ops fm25s01a_ooblayout = {
49 .ecc = fm25s01a_ooblayout_ecc,
50 .free = fm25s01a_ooblayout_free,
51 };
52
53 static const struct spinand_info fmsh_spinand_table[] = {
54 SPINAND_INFO("FM25S01A",
55 SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xE4),
56 NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
57 NAND_ECCREQ(1, 512),
58 SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
59 &write_cache_variants,
60 &update_cache_variants),
61 0,
62 SPINAND_ECCINFO(&fm25s01a_ooblayout, NULL)),
63 };
64
65 static const struct spinand_manufacturer_ops fmsh_spinand_manuf_ops = {
66 };
67
68 const struct spinand_manufacturer fmsh_spinand_manufacturer = {
69 .id = SPINAND_MFR_FMSH,
70 .name = "Fudan Micro",
71 .chips = fmsh_spinand_table,
72 .nchips = ARRAY_SIZE(fmsh_spinand_table),
73 .ops = &fmsh_spinand_manuf_ops,
74 };
75