1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright (c) 2023 Rockchip Electronics Co., Ltd 4 * 5 * Authors: 6 * Dingqiang Lin <jon.lin@rock-chips.com> 7 */ 8 9 #ifndef __UBOOT__ 10 #include <linux/device.h> 11 #include <linux/kernel.h> 12 #endif 13 #include <linux/mtd/spinand.h> 14 15 #define SPINAND_MFR_GSTO 0x52 16 17 static SPINAND_OP_VARIANTS(read_cache_variants, 18 SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0), 19 SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0), 20 SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0), 21 SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0), 22 SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0), 23 SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0)); 24 25 static SPINAND_OP_VARIANTS(write_cache_variants, 26 SPINAND_PROG_LOAD_X4(true, 0, NULL, 0), 27 SPINAND_PROG_LOAD(true, 0, NULL, 0)); 28 29 static SPINAND_OP_VARIANTS(update_cache_variants, 30 SPINAND_PROG_LOAD_X4(false, 0, NULL, 0), 31 SPINAND_PROG_LOAD(false, 0, NULL, 0)); 32 33 static int gss0xgsak1_ooblayout_ecc(struct mtd_info *mtd, int section, 34 struct mtd_oob_region *region) 35 { 36 if (section) 37 return -ERANGE; 38 39 region->offset = 32; 40 region->length = 32; 41 42 return 0; 43 } 44 45 static int gss0xgsak1_ooblayout_free(struct mtd_info *mtd, int section, 46 struct mtd_oob_region *region) 47 { 48 if (section) 49 return -ERANGE; 50 51 region->offset = 2; 52 region->length = 30; 53 54 return 0; 55 } 56 57 static const struct mtd_ooblayout_ops gss0xgsak1_ooblayout = { 58 .ecc = gss0xgsak1_ooblayout_ecc, 59 .rfree = gss0xgsak1_ooblayout_free, 60 }; 61 62 static int gss0xgsax1_ooblayout_ecc(struct mtd_info *mtd, int section, 63 struct mtd_oob_region *region) 64 { 65 if (section) 66 return -ERANGE; 67 68 region->offset = 64; 69 region->length = 64; 70 71 return 0; 72 } 73 74 static int gss0xgsax1_ooblayout_free(struct mtd_info *mtd, int section, 75 struct mtd_oob_region *region) 76 { 77 if (section) 78 return -ERANGE; 79 80 region->offset = 2; 81 region->length = 62; 82 83 return 0; 84 } 85 86 static const struct mtd_ooblayout_ops gss0xgsax1_ooblayout = { 87 .ecc = gss0xgsax1_ooblayout_ecc, 88 .rfree = gss0xgsax1_ooblayout_free, 89 }; 90 91 static const struct spinand_info gsto_spinand_table[] = { 92 SPINAND_INFO("GSS01GSAK1", 93 SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xBA, 0x13), 94 NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 1), 95 NAND_ECCREQ(4, 512), 96 SPINAND_INFO_OP_VARIANTS(&read_cache_variants, 97 &write_cache_variants, 98 &update_cache_variants), 99 0, 100 SPINAND_ECCINFO(&gss0xgsak1_ooblayout, NULL)), 101 SPINAND_INFO("GSS02GSAK1", 102 SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xBA, 0x23), 103 NAND_MEMORG(1, 2048, 64, 64, 2048, 1, 1, 1), 104 NAND_ECCREQ(4, 512), 105 SPINAND_INFO_OP_VARIANTS(&read_cache_variants, 106 &write_cache_variants, 107 &update_cache_variants), 108 0, 109 SPINAND_ECCINFO(&gss0xgsax1_ooblayout, NULL)), 110 SPINAND_INFO("GSS02GSAX1", 111 SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xCA, 0x23), 112 NAND_MEMORG(1, 2048, 128, 64, 2048, 1, 1, 1), 113 NAND_ECCREQ(8, 512), 114 SPINAND_INFO_OP_VARIANTS(&read_cache_variants, 115 &write_cache_variants, 116 &update_cache_variants), 117 0, 118 SPINAND_ECCINFO(&gss0xgsax1_ooblayout, NULL)), 119 SPINAND_INFO("GSS01GSAX1", 120 SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xCA, 0x13), 121 NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), 122 NAND_ECCREQ(8, 512), 123 SPINAND_INFO_OP_VARIANTS(&read_cache_variants, 124 &write_cache_variants, 125 &update_cache_variants), 126 0, 127 SPINAND_ECCINFO(&gss0xgsax1_ooblayout, NULL)), 128 SPINAND_INFO("GSS01GSBX1", 129 SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xCB, 0x13), 130 NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1), 131 NAND_ECCREQ(8, 512), 132 SPINAND_INFO_OP_VARIANTS(&read_cache_variants, 133 &write_cache_variants, 134 &update_cache_variants), 135 0, 136 SPINAND_ECCINFO(&gss0xgsax1_ooblayout, NULL)), 137 }; 138 139 static const struct spinand_manufacturer_ops gsto_spinand_manuf_ops = { 140 }; 141 142 const struct spinand_manufacturer gsto_spinand_manufacturer = { 143 .id = SPINAND_MFR_GSTO, 144 .name = "GSTO", 145 .chips = gsto_spinand_table, 146 .nchips = ARRAY_SIZE(gsto_spinand_table), 147 .ops = &gsto_spinand_manuf_ops, 148 }; 149