Squashed backup commit (no shallow-clone history issues) of xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2 branch, upstream commit 9eece662e) plus all fixes applied to get everpal_defconfig building clean against a modern (GCC 15.2.0) toolchain -- see the previous commit message on the lineage-23.2 branch (also in this repo history is not available here since this is a squashed snapshot; full incremental history lives in the local DL380 checkout and the upstream GitHub remote). Upstream: https://github.com/xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2)
92 lines
1.9 KiB
C
92 lines
1.9 KiB
C
/*
|
|
* Copyright (C) 2017 MediaTek Inc.
|
|
* Licensed under either
|
|
* BSD Licence, (see NOTICE for more details)
|
|
* GNU General Public License, version 2.0, (see NOTICE for more details)
|
|
*/
|
|
#include <linux/mtd/mtd.h>
|
|
#include "nandx_ops.h"
|
|
#include "nandx_core.h"
|
|
|
|
int nand_write(struct mtd_info *mtd, loff_t to, size_t len,
|
|
size_t *retlen, const uint8_t *buf)
|
|
{
|
|
int ret;
|
|
struct nandx_core *ncore;
|
|
|
|
ncore = (struct nandx_core *)mtd->priv;
|
|
ret = nandx_ops_write(ncore, to, len, (u8 *)buf, DO_SINGLE_PLANE_OPS);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
*retlen = len;
|
|
return 0;
|
|
}
|
|
|
|
int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
|
|
size_t *retlen, uint8_t *buf)
|
|
{
|
|
int ret;
|
|
struct nandx_core *ncore;
|
|
|
|
ncore = (struct nandx_core *)mtd->priv;
|
|
ret = nandx_ops_read(ncore, from, len, buf, DO_SINGLE_PLANE_OPS);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
*retlen = len;
|
|
return 0;
|
|
}
|
|
|
|
int nand_erase(struct mtd_info *mtd, struct erase_info *instr)
|
|
{
|
|
struct nandx_core *ncore;
|
|
int ret;
|
|
|
|
ncore = (struct nandx_core *)mtd->priv;
|
|
|
|
instr->state = MTD_ERASING;
|
|
ret = nandx_ops_erase(ncore, instr->addr, 0, instr->len);
|
|
instr->state = ret < 0 ? MTD_ERASE_FAILED : MTD_ERASE_DONE;
|
|
ret = ret < 0 ? -EIO : 0;
|
|
if (!ret)
|
|
mtd_erase_callback(instr);
|
|
|
|
return ret;
|
|
}
|
|
|
|
int nand_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
|
|
{
|
|
struct nandx_core *ncore;
|
|
|
|
ncore = (struct nandx_core *)mtd->priv;
|
|
return nandx_ops_read_oob(ncore, from, ops->oobbuf);
|
|
}
|
|
|
|
int nand_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops)
|
|
{
|
|
struct nandx_core *ncore;
|
|
|
|
ncore = (struct nandx_core *)mtd->priv;
|
|
return nandx_ops_read_oob(ncore, to, ops->oobbuf);
|
|
}
|
|
|
|
#ifdef CONFIG_MTK_TLC_NAND_SUPPORT
|
|
int nand_mark_bad(struct mtd_info *mtd, loff_t ofs, const uint8_t *buf)
|
|
#else
|
|
int nand_mark_bad(struct mtd_info *mtd, loff_t ofs)
|
|
#endif
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int nand_is_bad(struct mtd_info *mtd, loff_t ofs)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
void nand_sync(struct mtd_info *mtd)
|
|
{
|
|
|
|
}
|