2019-04-05 09:41:50 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
|
|
|
/*
|
|
|
|
* Copyright (C) STMicroelectronics 2019
|
|
|
|
* Author: Christophe Kerello <christophe.kerello@st.com>
|
|
|
|
*/
|
|
|
|
|
2020-11-06 18:01:54 +00:00
|
|
|
#define LOG_CATEGORY UCLASS_MTD
|
|
|
|
|
2019-04-05 09:41:50 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <clk.h>
|
|
|
|
#include <dm.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2019-04-05 09:41:50 +00:00
|
|
|
#include <nand.h>
|
|
|
|
#include <reset.h>
|
2020-11-06 18:01:54 +00:00
|
|
|
#include <dm/device_compat.h>
|
2020-07-31 07:53:38 +00:00
|
|
|
#include <linux/bitfield.h>
|
2020-05-10 17:40:13 +00:00
|
|
|
#include <linux/bitops.h>
|
2020-05-10 17:40:11 +00:00
|
|
|
#include <linux/delay.h>
|
2020-02-03 14:36:15 +00:00
|
|
|
#include <linux/err.h>
|
2019-04-05 09:41:50 +00:00
|
|
|
#include <linux/iopoll.h>
|
|
|
|
#include <linux/ioport.h>
|
2021-09-22 18:50:35 +00:00
|
|
|
#include <linux/mtd/rawnand.h>
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/* Bad block marker length */
|
|
|
|
#define FMC2_BBM_LEN 2
|
|
|
|
|
|
|
|
/* ECC step size */
|
|
|
|
#define FMC2_ECC_STEP_SIZE 512
|
|
|
|
|
|
|
|
/* Command delay */
|
|
|
|
#define FMC2_RB_DELAY_US 30
|
|
|
|
|
|
|
|
/* Max chip enable */
|
|
|
|
#define FMC2_MAX_CE 2
|
|
|
|
|
|
|
|
/* Timings */
|
|
|
|
#define FMC2_THIZ 1
|
|
|
|
#define FMC2_TIO 8000
|
|
|
|
#define FMC2_TSYNC 3000
|
|
|
|
#define FMC2_PCR_TIMING_MASK 0xf
|
|
|
|
#define FMC2_PMEM_PATT_TIMING_MASK 0xff
|
|
|
|
|
|
|
|
/* FMC2 Controller Registers */
|
|
|
|
#define FMC2_BCR1 0x0
|
|
|
|
#define FMC2_PCR 0x80
|
|
|
|
#define FMC2_SR 0x84
|
|
|
|
#define FMC2_PMEM 0x88
|
|
|
|
#define FMC2_PATT 0x8c
|
|
|
|
#define FMC2_HECCR 0x94
|
|
|
|
#define FMC2_BCHISR 0x254
|
|
|
|
#define FMC2_BCHICR 0x258
|
|
|
|
#define FMC2_BCHPBR1 0x260
|
|
|
|
#define FMC2_BCHPBR2 0x264
|
|
|
|
#define FMC2_BCHPBR3 0x268
|
|
|
|
#define FMC2_BCHPBR4 0x26c
|
|
|
|
#define FMC2_BCHDSR0 0x27c
|
|
|
|
#define FMC2_BCHDSR1 0x280
|
|
|
|
#define FMC2_BCHDSR2 0x284
|
|
|
|
#define FMC2_BCHDSR3 0x288
|
|
|
|
#define FMC2_BCHDSR4 0x28c
|
|
|
|
|
|
|
|
/* Register: FMC2_BCR1 */
|
|
|
|
#define FMC2_BCR1_FMC2EN BIT(31)
|
|
|
|
|
|
|
|
/* Register: FMC2_PCR */
|
|
|
|
#define FMC2_PCR_PWAITEN BIT(1)
|
|
|
|
#define FMC2_PCR_PBKEN BIT(2)
|
2020-07-31 07:53:38 +00:00
|
|
|
#define FMC2_PCR_PWID GENMASK(5, 4)
|
2019-04-05 09:41:50 +00:00
|
|
|
#define FMC2_PCR_PWID_BUSWIDTH_8 0
|
|
|
|
#define FMC2_PCR_PWID_BUSWIDTH_16 1
|
|
|
|
#define FMC2_PCR_ECCEN BIT(6)
|
|
|
|
#define FMC2_PCR_ECCALG BIT(8)
|
2020-07-31 07:53:38 +00:00
|
|
|
#define FMC2_PCR_TCLR GENMASK(12, 9)
|
2019-04-05 09:41:50 +00:00
|
|
|
#define FMC2_PCR_TCLR_DEFAULT 0xf
|
2020-07-31 07:53:38 +00:00
|
|
|
#define FMC2_PCR_TAR GENMASK(16, 13)
|
2019-04-05 09:41:50 +00:00
|
|
|
#define FMC2_PCR_TAR_DEFAULT 0xf
|
2020-07-31 07:53:38 +00:00
|
|
|
#define FMC2_PCR_ECCSS GENMASK(19, 17)
|
2019-04-05 09:41:50 +00:00
|
|
|
#define FMC2_PCR_ECCSS_512 1
|
|
|
|
#define FMC2_PCR_ECCSS_2048 3
|
|
|
|
#define FMC2_PCR_BCHECC BIT(24)
|
|
|
|
#define FMC2_PCR_WEN BIT(25)
|
|
|
|
|
|
|
|
/* Register: FMC2_SR */
|
|
|
|
#define FMC2_SR_NWRF BIT(6)
|
|
|
|
|
|
|
|
/* Register: FMC2_PMEM */
|
2020-07-31 07:53:38 +00:00
|
|
|
#define FMC2_PMEM_MEMSET GENMASK(7, 0)
|
|
|
|
#define FMC2_PMEM_MEMWAIT GENMASK(15, 8)
|
|
|
|
#define FMC2_PMEM_MEMHOLD GENMASK(23, 16)
|
|
|
|
#define FMC2_PMEM_MEMHIZ GENMASK(31, 24)
|
2019-04-05 09:41:50 +00:00
|
|
|
#define FMC2_PMEM_DEFAULT 0x0a0a0a0a
|
|
|
|
|
|
|
|
/* Register: FMC2_PATT */
|
2020-07-31 07:53:38 +00:00
|
|
|
#define FMC2_PATT_ATTSET GENMASK(7, 0)
|
|
|
|
#define FMC2_PATT_ATTWAIT GENMASK(15, 8)
|
|
|
|
#define FMC2_PATT_ATTHOLD GENMASK(23, 16)
|
|
|
|
#define FMC2_PATT_ATTHIZ GENMASK(31, 24)
|
2019-04-05 09:41:50 +00:00
|
|
|
#define FMC2_PATT_DEFAULT 0x0a0a0a0a
|
|
|
|
|
|
|
|
/* Register: FMC2_BCHISR */
|
|
|
|
#define FMC2_BCHISR_DERF BIT(1)
|
|
|
|
#define FMC2_BCHISR_EPBRF BIT(4)
|
|
|
|
|
|
|
|
/* Register: FMC2_BCHICR */
|
|
|
|
#define FMC2_BCHICR_CLEAR_IRQ GENMASK(4, 0)
|
|
|
|
|
|
|
|
/* Register: FMC2_BCHDSR0 */
|
|
|
|
#define FMC2_BCHDSR0_DUE BIT(0)
|
|
|
|
#define FMC2_BCHDSR0_DEF BIT(1)
|
2020-07-31 07:53:38 +00:00
|
|
|
#define FMC2_BCHDSR0_DEN GENMASK(7, 4)
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/* Register: FMC2_BCHDSR1 */
|
2020-07-31 07:53:38 +00:00
|
|
|
#define FMC2_BCHDSR1_EBP1 GENMASK(12, 0)
|
|
|
|
#define FMC2_BCHDSR1_EBP2 GENMASK(28, 16)
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/* Register: FMC2_BCHDSR2 */
|
2020-07-31 07:53:38 +00:00
|
|
|
#define FMC2_BCHDSR2_EBP3 GENMASK(12, 0)
|
|
|
|
#define FMC2_BCHDSR2_EBP4 GENMASK(28, 16)
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/* Register: FMC2_BCHDSR3 */
|
2020-07-31 07:53:38 +00:00
|
|
|
#define FMC2_BCHDSR3_EBP5 GENMASK(12, 0)
|
|
|
|
#define FMC2_BCHDSR3_EBP6 GENMASK(28, 16)
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/* Register: FMC2_BCHDSR4 */
|
2020-07-31 07:53:38 +00:00
|
|
|
#define FMC2_BCHDSR4_EBP7 GENMASK(12, 0)
|
|
|
|
#define FMC2_BCHDSR4_EBP8 GENMASK(28, 16)
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
#define FMC2_NSEC_PER_SEC 1000000000L
|
|
|
|
|
2020-07-31 07:53:36 +00:00
|
|
|
#define FMC2_TIMEOUT_5S 5000000
|
|
|
|
|
2019-04-05 09:41:50 +00:00
|
|
|
enum stm32_fmc2_ecc {
|
|
|
|
FMC2_ECC_HAM = 1,
|
|
|
|
FMC2_ECC_BCH4 = 4,
|
|
|
|
FMC2_ECC_BCH8 = 8
|
|
|
|
};
|
|
|
|
|
|
|
|
struct stm32_fmc2_timings {
|
|
|
|
u8 tclr;
|
|
|
|
u8 tar;
|
|
|
|
u8 thiz;
|
|
|
|
u8 twait;
|
|
|
|
u8 thold_mem;
|
|
|
|
u8 tset_mem;
|
|
|
|
u8 thold_att;
|
|
|
|
u8 tset_att;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct stm32_fmc2_nand {
|
|
|
|
struct nand_chip chip;
|
|
|
|
struct stm32_fmc2_timings timings;
|
|
|
|
int ncs;
|
|
|
|
int cs_used[FMC2_MAX_CE];
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct stm32_fmc2_nand *to_fmc2_nand(struct nand_chip *chip)
|
|
|
|
{
|
|
|
|
return container_of(chip, struct stm32_fmc2_nand, chip);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct stm32_fmc2_nfc {
|
|
|
|
struct nand_hw_control base;
|
|
|
|
struct stm32_fmc2_nand nand;
|
|
|
|
struct nand_ecclayout ecclayout;
|
2020-07-31 07:53:41 +00:00
|
|
|
fdt_addr_t io_base;
|
|
|
|
fdt_addr_t data_base[FMC2_MAX_CE];
|
|
|
|
fdt_addr_t cmd_base[FMC2_MAX_CE];
|
|
|
|
fdt_addr_t addr_base[FMC2_MAX_CE];
|
2019-04-05 09:41:50 +00:00
|
|
|
struct clk clk;
|
|
|
|
|
|
|
|
u8 cs_assigned;
|
|
|
|
int cs_sel;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct stm32_fmc2_nfc *to_stm32_nfc(struct nand_hw_control *base)
|
|
|
|
{
|
|
|
|
return container_of(base, struct stm32_fmc2_nfc, base);
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static void stm32_fmc2_nfc_timings_init(struct nand_chip *chip)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
2020-07-31 07:53:37 +00:00
|
|
|
struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller);
|
2019-04-05 09:41:50 +00:00
|
|
|
struct stm32_fmc2_nand *nand = to_fmc2_nand(chip);
|
|
|
|
struct stm32_fmc2_timings *timings = &nand->timings;
|
|
|
|
u32 pmem, patt;
|
|
|
|
|
|
|
|
/* Set tclr/tar timings */
|
2020-07-31 07:53:39 +00:00
|
|
|
clrsetbits_le32(nfc->io_base + FMC2_PCR,
|
|
|
|
FMC2_PCR_TCLR | FMC2_PCR_TAR,
|
|
|
|
FIELD_PREP(FMC2_PCR_TCLR, timings->tclr) |
|
|
|
|
FIELD_PREP(FMC2_PCR_TAR, timings->tar));
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/* Set tset/twait/thold/thiz timings in common bank */
|
2020-07-31 07:53:38 +00:00
|
|
|
pmem = FIELD_PREP(FMC2_PMEM_MEMSET, timings->tset_mem);
|
|
|
|
pmem |= FIELD_PREP(FMC2_PMEM_MEMWAIT, timings->twait);
|
|
|
|
pmem |= FIELD_PREP(FMC2_PMEM_MEMHOLD, timings->thold_mem);
|
|
|
|
pmem |= FIELD_PREP(FMC2_PMEM_MEMHIZ, timings->thiz);
|
2020-07-31 07:53:39 +00:00
|
|
|
writel(pmem, nfc->io_base + FMC2_PMEM);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/* Set tset/twait/thold/thiz timings in attribut bank */
|
2020-07-31 07:53:38 +00:00
|
|
|
patt = FIELD_PREP(FMC2_PATT_ATTSET, timings->tset_att);
|
|
|
|
patt |= FIELD_PREP(FMC2_PATT_ATTWAIT, timings->twait);
|
|
|
|
patt |= FIELD_PREP(FMC2_PATT_ATTHOLD, timings->thold_att);
|
|
|
|
patt |= FIELD_PREP(FMC2_PATT_ATTHIZ, timings->thiz);
|
2020-07-31 07:53:37 +00:00
|
|
|
writel(patt, nfc->io_base + FMC2_PATT);
|
2019-04-05 09:41:50 +00:00
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static void stm32_fmc2_nfc_setup(struct nand_chip *chip)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
2020-07-31 07:53:37 +00:00
|
|
|
struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller);
|
2020-07-31 07:53:39 +00:00
|
|
|
u32 pcr = 0, pcr_mask;
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/* Configure ECC algorithm (default configuration is Hamming) */
|
2020-07-31 07:53:39 +00:00
|
|
|
pcr_mask = FMC2_PCR_ECCALG;
|
|
|
|
pcr_mask |= FMC2_PCR_BCHECC;
|
2019-04-05 09:41:50 +00:00
|
|
|
if (chip->ecc.strength == FMC2_ECC_BCH8) {
|
|
|
|
pcr |= FMC2_PCR_ECCALG;
|
|
|
|
pcr |= FMC2_PCR_BCHECC;
|
|
|
|
} else if (chip->ecc.strength == FMC2_ECC_BCH4) {
|
|
|
|
pcr |= FMC2_PCR_ECCALG;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set buswidth */
|
2020-07-31 07:53:39 +00:00
|
|
|
pcr_mask |= FMC2_PCR_PWID;
|
2019-04-05 09:41:50 +00:00
|
|
|
if (chip->options & NAND_BUSWIDTH_16)
|
2020-07-31 07:53:38 +00:00
|
|
|
pcr |= FIELD_PREP(FMC2_PCR_PWID, FMC2_PCR_PWID_BUSWIDTH_16);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/* Set ECC sector size */
|
2020-07-31 07:53:39 +00:00
|
|
|
pcr_mask |= FMC2_PCR_ECCSS;
|
2020-07-31 07:53:38 +00:00
|
|
|
pcr |= FIELD_PREP(FMC2_PCR_ECCSS, FMC2_PCR_ECCSS_512);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
2020-07-31 07:53:39 +00:00
|
|
|
clrsetbits_le32(nfc->io_base + FMC2_PCR, pcr_mask, pcr);
|
2019-04-05 09:41:50 +00:00
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static void stm32_fmc2_nfc_select_chip(struct mtd_info *mtd, int chipnr)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
|
|
|
struct nand_chip *chip = mtd_to_nand(mtd);
|
2020-07-31 07:53:37 +00:00
|
|
|
struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller);
|
2019-04-05 09:41:50 +00:00
|
|
|
struct stm32_fmc2_nand *nand = to_fmc2_nand(chip);
|
|
|
|
|
|
|
|
if (chipnr < 0 || chipnr >= nand->ncs)
|
|
|
|
return;
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
if (nand->cs_used[chipnr] == nfc->cs_sel)
|
2019-04-05 09:41:50 +00:00
|
|
|
return;
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
nfc->cs_sel = nand->cs_used[chipnr];
|
2020-07-31 07:53:41 +00:00
|
|
|
chip->IO_ADDR_R = (void __iomem *)nfc->data_base[nfc->cs_sel];
|
|
|
|
chip->IO_ADDR_W = (void __iomem *)nfc->data_base[nfc->cs_sel];
|
2019-04-05 09:41:50 +00:00
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
stm32_fmc2_nfc_setup(chip);
|
|
|
|
stm32_fmc2_nfc_timings_init(chip);
|
2019-04-05 09:41:50 +00:00
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static void stm32_fmc2_nfc_set_buswidth_16(struct stm32_fmc2_nfc *nfc,
|
|
|
|
bool set)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
2020-07-31 07:53:39 +00:00
|
|
|
u32 pcr;
|
2019-04-05 09:41:50 +00:00
|
|
|
|
2020-07-31 07:53:39 +00:00
|
|
|
pcr = set ? FIELD_PREP(FMC2_PCR_PWID, FMC2_PCR_PWID_BUSWIDTH_16) :
|
|
|
|
FIELD_PREP(FMC2_PCR_PWID, FMC2_PCR_PWID_BUSWIDTH_8);
|
|
|
|
|
|
|
|
clrsetbits_le32(nfc->io_base + FMC2_PCR, FMC2_PCR_PWID, pcr);
|
2019-04-05 09:41:50 +00:00
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static void stm32_fmc2_nfc_set_ecc(struct stm32_fmc2_nfc *nfc, bool enable)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
2020-07-31 07:53:39 +00:00
|
|
|
clrsetbits_le32(nfc->io_base + FMC2_PCR, FMC2_PCR_ECCEN,
|
|
|
|
enable ? FMC2_PCR_ECCEN : 0);
|
2019-04-05 09:41:50 +00:00
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static void stm32_fmc2_nfc_clear_bch_irq(struct stm32_fmc2_nfc *nfc)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
2020-07-31 07:53:37 +00:00
|
|
|
writel(FMC2_BCHICR_CLEAR_IRQ, nfc->io_base + FMC2_BCHICR);
|
2019-04-05 09:41:50 +00:00
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static void stm32_fmc2_nfc_cmd_ctrl(struct mtd_info *mtd, int cmd,
|
|
|
|
unsigned int ctrl)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
|
|
|
struct nand_chip *chip = mtd_to_nand(mtd);
|
2020-07-31 07:53:37 +00:00
|
|
|
struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
if (cmd == NAND_CMD_NONE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ctrl & NAND_CLE) {
|
2020-07-31 07:53:37 +00:00
|
|
|
writeb(cmd, nfc->cmd_base[nfc->cs_sel]);
|
2019-04-05 09:41:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
writeb(cmd, nfc->addr_base[nfc->cs_sel]);
|
2019-04-05 09:41:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable ECC logic and reset syndrome/parity bits previously calculated
|
|
|
|
* Syndrome/parity bits is cleared by setting the ECCEN bit to 0
|
|
|
|
*/
|
2020-07-31 07:53:37 +00:00
|
|
|
static void stm32_fmc2_nfc_hwctl(struct mtd_info *mtd, int mode)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
|
|
|
struct nand_chip *chip = mtd_to_nand(mtd);
|
2020-07-31 07:53:37 +00:00
|
|
|
struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
stm32_fmc2_nfc_set_ecc(nfc, false);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
if (chip->ecc.strength != FMC2_ECC_HAM) {
|
2020-07-31 07:53:39 +00:00
|
|
|
clrsetbits_le32(nfc->io_base + FMC2_PCR, FMC2_PCR_WEN,
|
|
|
|
mode == NAND_ECC_WRITE ? FMC2_PCR_WEN : 0);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
stm32_fmc2_nfc_clear_bch_irq(nfc);
|
2019-04-05 09:41:50 +00:00
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
stm32_fmc2_nfc_set_ecc(nfc, true);
|
2019-04-05 09:41:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ECC Hamming calculation
|
|
|
|
* ECC is 3 bytes for 512 bytes of data (supports error correction up to
|
|
|
|
* max of 1-bit)
|
|
|
|
*/
|
2020-07-31 07:53:37 +00:00
|
|
|
static int stm32_fmc2_nfc_ham_calculate(struct mtd_info *mtd, const u8 *data,
|
|
|
|
u8 *ecc)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
|
|
|
struct nand_chip *chip = mtd_to_nand(mtd);
|
2020-07-31 07:53:37 +00:00
|
|
|
struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller);
|
2019-04-05 09:41:50 +00:00
|
|
|
u32 heccr, sr;
|
|
|
|
int ret;
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
ret = readl_poll_timeout(nfc->io_base + FMC2_SR, sr,
|
2020-07-31 07:53:36 +00:00
|
|
|
sr & FMC2_SR_NWRF, FMC2_TIMEOUT_5S);
|
2019-04-05 09:41:50 +00:00
|
|
|
if (ret < 0) {
|
2020-11-06 18:01:54 +00:00
|
|
|
log_err("Ham timeout\n");
|
2019-04-05 09:41:50 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
heccr = readl(nfc->io_base + FMC2_HECCR);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
ecc[0] = heccr;
|
|
|
|
ecc[1] = heccr >> 8;
|
|
|
|
ecc[2] = heccr >> 16;
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
stm32_fmc2_nfc_set_ecc(nfc, false);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static int stm32_fmc2_nfc_ham_correct(struct mtd_info *mtd, u8 *dat,
|
|
|
|
u8 *read_ecc, u8 *calc_ecc)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
|
|
|
u8 bit_position = 0, b0, b1, b2;
|
|
|
|
u32 byte_addr = 0, b;
|
|
|
|
u32 i, shifting = 1;
|
|
|
|
|
|
|
|
/* Indicate which bit and byte is faulty (if any) */
|
|
|
|
b0 = read_ecc[0] ^ calc_ecc[0];
|
|
|
|
b1 = read_ecc[1] ^ calc_ecc[1];
|
|
|
|
b2 = read_ecc[2] ^ calc_ecc[2];
|
|
|
|
b = b0 | (b1 << 8) | (b2 << 16);
|
|
|
|
|
|
|
|
/* No errors */
|
|
|
|
if (likely(!b))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Calculate bit position */
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
switch (b % 4) {
|
|
|
|
case 2:
|
|
|
|
bit_position += shifting;
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EBADMSG;
|
|
|
|
}
|
|
|
|
shifting <<= 1;
|
|
|
|
b >>= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate byte position */
|
|
|
|
shifting = 1;
|
|
|
|
for (i = 0; i < 9; i++) {
|
|
|
|
switch (b % 4) {
|
|
|
|
case 2:
|
|
|
|
byte_addr += shifting;
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EBADMSG;
|
|
|
|
}
|
|
|
|
shifting <<= 1;
|
|
|
|
b >>= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Flip the bit */
|
|
|
|
dat[byte_addr] ^= (1 << bit_position);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ECC BCH calculation and correction
|
|
|
|
* ECC is 7/13 bytes for 512 bytes of data (supports error correction up to
|
|
|
|
* max of 4-bit/8-bit)
|
|
|
|
*/
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static int stm32_fmc2_nfc_bch_calculate(struct mtd_info *mtd, const u8 *data,
|
|
|
|
u8 *ecc)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
|
|
|
struct nand_chip *chip = mtd_to_nand(mtd);
|
2020-07-31 07:53:37 +00:00
|
|
|
struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller);
|
2019-04-05 09:41:50 +00:00
|
|
|
u32 bchpbr, bchisr;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Wait until the BCH code is ready */
|
2020-07-31 07:53:37 +00:00
|
|
|
ret = readl_poll_timeout(nfc->io_base + FMC2_BCHISR, bchisr,
|
2020-07-31 07:53:36 +00:00
|
|
|
bchisr & FMC2_BCHISR_EPBRF, FMC2_TIMEOUT_5S);
|
2019-04-05 09:41:50 +00:00
|
|
|
if (ret < 0) {
|
2020-11-06 18:01:54 +00:00
|
|
|
log_err("Bch timeout\n");
|
2019-04-05 09:41:50 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read parity bits */
|
2020-07-31 07:53:37 +00:00
|
|
|
bchpbr = readl(nfc->io_base + FMC2_BCHPBR1);
|
2019-04-05 09:41:50 +00:00
|
|
|
ecc[0] = bchpbr;
|
|
|
|
ecc[1] = bchpbr >> 8;
|
|
|
|
ecc[2] = bchpbr >> 16;
|
|
|
|
ecc[3] = bchpbr >> 24;
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
bchpbr = readl(nfc->io_base + FMC2_BCHPBR2);
|
2019-04-05 09:41:50 +00:00
|
|
|
ecc[4] = bchpbr;
|
|
|
|
ecc[5] = bchpbr >> 8;
|
|
|
|
ecc[6] = bchpbr >> 16;
|
|
|
|
|
|
|
|
if (chip->ecc.strength == FMC2_ECC_BCH8) {
|
|
|
|
ecc[7] = bchpbr >> 24;
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
bchpbr = readl(nfc->io_base + FMC2_BCHPBR3);
|
2019-04-05 09:41:50 +00:00
|
|
|
ecc[8] = bchpbr;
|
|
|
|
ecc[9] = bchpbr >> 8;
|
|
|
|
ecc[10] = bchpbr >> 16;
|
|
|
|
ecc[11] = bchpbr >> 24;
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
bchpbr = readl(nfc->io_base + FMC2_BCHPBR4);
|
2019-04-05 09:41:50 +00:00
|
|
|
ecc[12] = bchpbr;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
stm32_fmc2_nfc_set_ecc(nfc, false);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static int stm32_fmc2_nfc_bch_correct(struct mtd_info *mtd, u8 *dat,
|
|
|
|
u8 *read_ecc, u8 *calc_ecc)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
|
|
|
struct nand_chip *chip = mtd_to_nand(mtd);
|
2020-07-31 07:53:37 +00:00
|
|
|
struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller);
|
2019-04-05 09:41:50 +00:00
|
|
|
u32 bchdsr0, bchdsr1, bchdsr2, bchdsr3, bchdsr4, bchisr;
|
|
|
|
u16 pos[8];
|
|
|
|
int i, ret, den, eccsize = chip->ecc.size;
|
|
|
|
unsigned int nb_errs = 0;
|
|
|
|
|
|
|
|
/* Wait until the decoding error is ready */
|
2020-07-31 07:53:37 +00:00
|
|
|
ret = readl_poll_timeout(nfc->io_base + FMC2_BCHISR, bchisr,
|
2020-07-31 07:53:36 +00:00
|
|
|
bchisr & FMC2_BCHISR_DERF, FMC2_TIMEOUT_5S);
|
2019-04-05 09:41:50 +00:00
|
|
|
if (ret < 0) {
|
2020-11-06 18:01:54 +00:00
|
|
|
log_err("Bch timeout\n");
|
2019-04-05 09:41:50 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
bchdsr0 = readl(nfc->io_base + FMC2_BCHDSR0);
|
|
|
|
bchdsr1 = readl(nfc->io_base + FMC2_BCHDSR1);
|
|
|
|
bchdsr2 = readl(nfc->io_base + FMC2_BCHDSR2);
|
|
|
|
bchdsr3 = readl(nfc->io_base + FMC2_BCHDSR3);
|
|
|
|
bchdsr4 = readl(nfc->io_base + FMC2_BCHDSR4);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
stm32_fmc2_nfc_set_ecc(nfc, false);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/* No errors found */
|
|
|
|
if (likely(!(bchdsr0 & FMC2_BCHDSR0_DEF)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Too many errors detected */
|
|
|
|
if (unlikely(bchdsr0 & FMC2_BCHDSR0_DUE))
|
|
|
|
return -EBADMSG;
|
|
|
|
|
2020-07-31 07:53:38 +00:00
|
|
|
pos[0] = FIELD_GET(FMC2_BCHDSR1_EBP1, bchdsr1);
|
|
|
|
pos[1] = FIELD_GET(FMC2_BCHDSR1_EBP2, bchdsr1);
|
|
|
|
pos[2] = FIELD_GET(FMC2_BCHDSR2_EBP3, bchdsr2);
|
|
|
|
pos[3] = FIELD_GET(FMC2_BCHDSR2_EBP4, bchdsr2);
|
|
|
|
pos[4] = FIELD_GET(FMC2_BCHDSR3_EBP5, bchdsr3);
|
|
|
|
pos[5] = FIELD_GET(FMC2_BCHDSR3_EBP6, bchdsr3);
|
|
|
|
pos[6] = FIELD_GET(FMC2_BCHDSR4_EBP7, bchdsr4);
|
|
|
|
pos[7] = FIELD_GET(FMC2_BCHDSR4_EBP8, bchdsr4);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
2020-07-31 07:53:38 +00:00
|
|
|
den = FIELD_GET(FMC2_BCHDSR0_DEN, bchdsr0);
|
2019-04-05 09:41:50 +00:00
|
|
|
for (i = 0; i < den; i++) {
|
|
|
|
if (pos[i] < eccsize * 8) {
|
|
|
|
__change_bit(pos[i], (unsigned long *)dat);
|
|
|
|
nb_errs++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nb_errs;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static int stm32_fmc2_nfc_read_page(struct mtd_info *mtd,
|
|
|
|
struct nand_chip *chip, u8 *buf,
|
|
|
|
int oob_required, int page)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
|
|
|
int i, s, stat, eccsize = chip->ecc.size;
|
|
|
|
int eccbytes = chip->ecc.bytes;
|
|
|
|
int eccsteps = chip->ecc.steps;
|
|
|
|
int eccstrength = chip->ecc.strength;
|
|
|
|
u8 *p = buf;
|
|
|
|
u8 *ecc_calc = chip->buffers->ecccalc;
|
|
|
|
u8 *ecc_code = chip->buffers->ecccode;
|
|
|
|
unsigned int max_bitflips = 0;
|
|
|
|
|
|
|
|
for (i = mtd->writesize + FMC2_BBM_LEN, s = 0; s < eccsteps;
|
|
|
|
s++, i += eccbytes, p += eccsize) {
|
|
|
|
chip->ecc.hwctl(mtd, NAND_ECC_READ);
|
|
|
|
|
|
|
|
/* Read the nand page sector (512 bytes) */
|
|
|
|
chip->cmdfunc(mtd, NAND_CMD_RNDOUT, s * eccsize, -1);
|
|
|
|
chip->read_buf(mtd, p, eccsize);
|
|
|
|
|
|
|
|
/* Read the corresponding ECC bytes */
|
|
|
|
chip->cmdfunc(mtd, NAND_CMD_RNDOUT, i, -1);
|
|
|
|
chip->read_buf(mtd, ecc_code, eccbytes);
|
|
|
|
|
|
|
|
/* Correct the data */
|
|
|
|
stat = chip->ecc.correct(mtd, p, ecc_code, ecc_calc);
|
|
|
|
if (stat == -EBADMSG)
|
|
|
|
/* Check for empty pages with bitflips */
|
|
|
|
stat = nand_check_erased_ecc_chunk(p, eccsize,
|
|
|
|
ecc_code, eccbytes,
|
|
|
|
NULL, 0,
|
|
|
|
eccstrength);
|
|
|
|
|
|
|
|
if (stat < 0) {
|
|
|
|
mtd->ecc_stats.failed++;
|
|
|
|
} else {
|
|
|
|
mtd->ecc_stats.corrected += stat;
|
|
|
|
max_bitflips = max_t(unsigned int, max_bitflips, stat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read oob */
|
|
|
|
if (oob_required) {
|
|
|
|
chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1);
|
|
|
|
chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
|
|
|
|
}
|
|
|
|
|
|
|
|
return max_bitflips;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:41 +00:00
|
|
|
static void stm32_fmc2_nfc_init(struct stm32_fmc2_nfc *nfc, bool has_parent)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
2020-07-31 07:53:37 +00:00
|
|
|
u32 pcr = readl(nfc->io_base + FMC2_PCR);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/* Set CS used to undefined */
|
2020-07-31 07:53:37 +00:00
|
|
|
nfc->cs_sel = -1;
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/* Enable wait feature and nand flash memory bank */
|
|
|
|
pcr |= FMC2_PCR_PWAITEN;
|
|
|
|
pcr |= FMC2_PCR_PBKEN;
|
|
|
|
|
|
|
|
/* Set buswidth to 8 bits mode for identification */
|
2020-07-31 07:53:38 +00:00
|
|
|
pcr &= ~FMC2_PCR_PWID;
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/* ECC logic is disabled */
|
|
|
|
pcr &= ~FMC2_PCR_ECCEN;
|
|
|
|
|
|
|
|
/* Default mode */
|
|
|
|
pcr &= ~FMC2_PCR_ECCALG;
|
|
|
|
pcr &= ~FMC2_PCR_BCHECC;
|
|
|
|
pcr &= ~FMC2_PCR_WEN;
|
|
|
|
|
|
|
|
/* Set default ECC sector size */
|
2020-07-31 07:53:38 +00:00
|
|
|
pcr &= ~FMC2_PCR_ECCSS;
|
|
|
|
pcr |= FIELD_PREP(FMC2_PCR_ECCSS, FMC2_PCR_ECCSS_2048);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/* Set default tclr/tar timings */
|
2020-07-31 07:53:38 +00:00
|
|
|
pcr &= ~FMC2_PCR_TCLR;
|
|
|
|
pcr |= FIELD_PREP(FMC2_PCR_TCLR, FMC2_PCR_TCLR_DEFAULT);
|
|
|
|
pcr &= ~FMC2_PCR_TAR;
|
|
|
|
pcr |= FIELD_PREP(FMC2_PCR_TAR, FMC2_PCR_TAR_DEFAULT);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/* Enable FMC2 controller */
|
2020-07-31 07:53:41 +00:00
|
|
|
if (!has_parent)
|
|
|
|
setbits_le32(nfc->io_base + FMC2_BCR1, FMC2_BCR1_FMC2EN);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
writel(pcr, nfc->io_base + FMC2_PCR);
|
|
|
|
writel(FMC2_PMEM_DEFAULT, nfc->io_base + FMC2_PMEM);
|
|
|
|
writel(FMC2_PATT_DEFAULT, nfc->io_base + FMC2_PATT);
|
2019-04-05 09:41:50 +00:00
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static void stm32_fmc2_nfc_calc_timings(struct nand_chip *chip,
|
|
|
|
const struct nand_sdr_timings *sdrt)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
2020-07-31 07:53:37 +00:00
|
|
|
struct stm32_fmc2_nfc *nfc = to_stm32_nfc(chip->controller);
|
2019-04-05 09:41:50 +00:00
|
|
|
struct stm32_fmc2_nand *nand = to_fmc2_nand(chip);
|
|
|
|
struct stm32_fmc2_timings *tims = &nand->timings;
|
2020-07-31 07:53:37 +00:00
|
|
|
unsigned long hclk = clk_get_rate(&nfc->clk);
|
2019-04-05 09:41:50 +00:00
|
|
|
unsigned long hclkp = FMC2_NSEC_PER_SEC / (hclk / 1000);
|
2019-06-21 13:26:54 +00:00
|
|
|
unsigned long timing, tar, tclr, thiz, twait;
|
|
|
|
unsigned long tset_mem, tset_att, thold_mem, thold_att;
|
|
|
|
|
|
|
|
tar = max_t(unsigned long, hclkp, sdrt->tAR_min);
|
|
|
|
timing = DIV_ROUND_UP(tar, hclkp) - 1;
|
|
|
|
tims->tar = min_t(unsigned long, timing, FMC2_PCR_TIMING_MASK);
|
|
|
|
|
|
|
|
tclr = max_t(unsigned long, hclkp, sdrt->tCLR_min);
|
|
|
|
timing = DIV_ROUND_UP(tclr, hclkp) - 1;
|
|
|
|
tims->tclr = min_t(unsigned long, timing, FMC2_PCR_TIMING_MASK);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
tims->thiz = FMC2_THIZ;
|
|
|
|
thiz = (tims->thiz + 1) * hclkp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* tWAIT > tRP
|
|
|
|
* tWAIT > tWP
|
|
|
|
* tWAIT > tREA + tIO
|
|
|
|
*/
|
2019-06-21 13:26:54 +00:00
|
|
|
twait = max_t(unsigned long, hclkp, sdrt->tRP_min);
|
|
|
|
twait = max_t(unsigned long, twait, sdrt->tWP_min);
|
|
|
|
twait = max_t(unsigned long, twait, sdrt->tREA_max + FMC2_TIO);
|
|
|
|
timing = DIV_ROUND_UP(twait, hclkp);
|
|
|
|
tims->twait = clamp_val(timing, 1, FMC2_PMEM_PATT_TIMING_MASK);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* tSETUP_MEM > tCS - tWAIT
|
|
|
|
* tSETUP_MEM > tALS - tWAIT
|
|
|
|
* tSETUP_MEM > tDS - (tWAIT - tHIZ)
|
|
|
|
*/
|
|
|
|
tset_mem = hclkp;
|
|
|
|
if (sdrt->tCS_min > twait && (tset_mem < sdrt->tCS_min - twait))
|
|
|
|
tset_mem = sdrt->tCS_min - twait;
|
|
|
|
if (sdrt->tALS_min > twait && (tset_mem < sdrt->tALS_min - twait))
|
|
|
|
tset_mem = sdrt->tALS_min - twait;
|
|
|
|
if (twait > thiz && (sdrt->tDS_min > twait - thiz) &&
|
|
|
|
(tset_mem < sdrt->tDS_min - (twait - thiz)))
|
|
|
|
tset_mem = sdrt->tDS_min - (twait - thiz);
|
2019-06-21 13:26:54 +00:00
|
|
|
timing = DIV_ROUND_UP(tset_mem, hclkp);
|
|
|
|
tims->tset_mem = clamp_val(timing, 1, FMC2_PMEM_PATT_TIMING_MASK);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* tHOLD_MEM > tCH
|
|
|
|
* tHOLD_MEM > tREH - tSETUP_MEM
|
|
|
|
* tHOLD_MEM > max(tRC, tWC) - (tSETUP_MEM + tWAIT)
|
|
|
|
*/
|
2019-06-21 13:26:54 +00:00
|
|
|
thold_mem = max_t(unsigned long, hclkp, sdrt->tCH_min);
|
2019-04-05 09:41:50 +00:00
|
|
|
if (sdrt->tREH_min > tset_mem &&
|
|
|
|
(thold_mem < sdrt->tREH_min - tset_mem))
|
|
|
|
thold_mem = sdrt->tREH_min - tset_mem;
|
|
|
|
if ((sdrt->tRC_min > tset_mem + twait) &&
|
|
|
|
(thold_mem < sdrt->tRC_min - (tset_mem + twait)))
|
|
|
|
thold_mem = sdrt->tRC_min - (tset_mem + twait);
|
|
|
|
if ((sdrt->tWC_min > tset_mem + twait) &&
|
|
|
|
(thold_mem < sdrt->tWC_min - (tset_mem + twait)))
|
|
|
|
thold_mem = sdrt->tWC_min - (tset_mem + twait);
|
2019-06-21 13:26:54 +00:00
|
|
|
timing = DIV_ROUND_UP(thold_mem, hclkp);
|
|
|
|
tims->thold_mem = clamp_val(timing, 1, FMC2_PMEM_PATT_TIMING_MASK);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* tSETUP_ATT > tCS - tWAIT
|
|
|
|
* tSETUP_ATT > tCLS - tWAIT
|
|
|
|
* tSETUP_ATT > tALS - tWAIT
|
|
|
|
* tSETUP_ATT > tRHW - tHOLD_MEM
|
|
|
|
* tSETUP_ATT > tDS - (tWAIT - tHIZ)
|
|
|
|
*/
|
|
|
|
tset_att = hclkp;
|
|
|
|
if (sdrt->tCS_min > twait && (tset_att < sdrt->tCS_min - twait))
|
|
|
|
tset_att = sdrt->tCS_min - twait;
|
|
|
|
if (sdrt->tCLS_min > twait && (tset_att < sdrt->tCLS_min - twait))
|
|
|
|
tset_att = sdrt->tCLS_min - twait;
|
|
|
|
if (sdrt->tALS_min > twait && (tset_att < sdrt->tALS_min - twait))
|
|
|
|
tset_att = sdrt->tALS_min - twait;
|
|
|
|
if (sdrt->tRHW_min > thold_mem &&
|
|
|
|
(tset_att < sdrt->tRHW_min - thold_mem))
|
|
|
|
tset_att = sdrt->tRHW_min - thold_mem;
|
|
|
|
if (twait > thiz && (sdrt->tDS_min > twait - thiz) &&
|
|
|
|
(tset_att < sdrt->tDS_min - (twait - thiz)))
|
|
|
|
tset_att = sdrt->tDS_min - (twait - thiz);
|
2019-06-21 13:26:54 +00:00
|
|
|
timing = DIV_ROUND_UP(tset_att, hclkp);
|
|
|
|
tims->tset_att = clamp_val(timing, 1, FMC2_PMEM_PATT_TIMING_MASK);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* tHOLD_ATT > tALH
|
|
|
|
* tHOLD_ATT > tCH
|
|
|
|
* tHOLD_ATT > tCLH
|
|
|
|
* tHOLD_ATT > tCOH
|
|
|
|
* tHOLD_ATT > tDH
|
|
|
|
* tHOLD_ATT > tWB + tIO + tSYNC - tSETUP_MEM
|
|
|
|
* tHOLD_ATT > tADL - tSETUP_MEM
|
|
|
|
* tHOLD_ATT > tWH - tSETUP_MEM
|
|
|
|
* tHOLD_ATT > tWHR - tSETUP_MEM
|
|
|
|
* tHOLD_ATT > tRC - (tSETUP_ATT + tWAIT)
|
|
|
|
* tHOLD_ATT > tWC - (tSETUP_ATT + tWAIT)
|
|
|
|
*/
|
2019-06-21 13:26:54 +00:00
|
|
|
thold_att = max_t(unsigned long, hclkp, sdrt->tALH_min);
|
|
|
|
thold_att = max_t(unsigned long, thold_att, sdrt->tCH_min);
|
|
|
|
thold_att = max_t(unsigned long, thold_att, sdrt->tCLH_min);
|
|
|
|
thold_att = max_t(unsigned long, thold_att, sdrt->tCOH_min);
|
|
|
|
thold_att = max_t(unsigned long, thold_att, sdrt->tDH_min);
|
2019-04-05 09:41:50 +00:00
|
|
|
if ((sdrt->tWB_max + FMC2_TIO + FMC2_TSYNC > tset_mem) &&
|
|
|
|
(thold_att < sdrt->tWB_max + FMC2_TIO + FMC2_TSYNC - tset_mem))
|
|
|
|
thold_att = sdrt->tWB_max + FMC2_TIO + FMC2_TSYNC - tset_mem;
|
|
|
|
if (sdrt->tADL_min > tset_mem &&
|
|
|
|
(thold_att < sdrt->tADL_min - tset_mem))
|
|
|
|
thold_att = sdrt->tADL_min - tset_mem;
|
|
|
|
if (sdrt->tWH_min > tset_mem &&
|
|
|
|
(thold_att < sdrt->tWH_min - tset_mem))
|
|
|
|
thold_att = sdrt->tWH_min - tset_mem;
|
|
|
|
if (sdrt->tWHR_min > tset_mem &&
|
|
|
|
(thold_att < sdrt->tWHR_min - tset_mem))
|
|
|
|
thold_att = sdrt->tWHR_min - tset_mem;
|
|
|
|
if ((sdrt->tRC_min > tset_att + twait) &&
|
|
|
|
(thold_att < sdrt->tRC_min - (tset_att + twait)))
|
|
|
|
thold_att = sdrt->tRC_min - (tset_att + twait);
|
|
|
|
if ((sdrt->tWC_min > tset_att + twait) &&
|
|
|
|
(thold_att < sdrt->tWC_min - (tset_att + twait)))
|
|
|
|
thold_att = sdrt->tWC_min - (tset_att + twait);
|
2019-06-21 13:26:54 +00:00
|
|
|
timing = DIV_ROUND_UP(thold_att, hclkp);
|
|
|
|
tims->thold_att = clamp_val(timing, 1, FMC2_PMEM_PATT_TIMING_MASK);
|
2019-04-05 09:41:50 +00:00
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static int stm32_fmc2_nfc_setup_interface(struct mtd_info *mtd, int chipnr,
|
|
|
|
const struct nand_data_interface *cf)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
|
|
|
struct nand_chip *chip = mtd_to_nand(mtd);
|
|
|
|
const struct nand_sdr_timings *sdrt;
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
sdrt = nand_get_sdr_timings(cf);
|
2019-04-05 09:41:50 +00:00
|
|
|
if (IS_ERR(sdrt))
|
|
|
|
return PTR_ERR(sdrt);
|
|
|
|
|
|
|
|
if (chipnr == NAND_DATA_IFACE_CHECK_ONLY)
|
|
|
|
return 0;
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
stm32_fmc2_nfc_calc_timings(chip, sdrt);
|
|
|
|
stm32_fmc2_nfc_timings_init(chip);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static void stm32_fmc2_nfc_nand_callbacks_setup(struct nand_chip *chip)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
2020-07-31 07:53:37 +00:00
|
|
|
chip->ecc.hwctl = stm32_fmc2_nfc_hwctl;
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Specific callbacks to read/write a page depending on
|
|
|
|
* the algo used (Hamming, BCH).
|
|
|
|
*/
|
|
|
|
if (chip->ecc.strength == FMC2_ECC_HAM) {
|
|
|
|
/* Hamming is used */
|
2020-07-31 07:53:37 +00:00
|
|
|
chip->ecc.calculate = stm32_fmc2_nfc_ham_calculate;
|
|
|
|
chip->ecc.correct = stm32_fmc2_nfc_ham_correct;
|
2019-04-05 09:41:50 +00:00
|
|
|
chip->ecc.bytes = chip->options & NAND_BUSWIDTH_16 ? 4 : 3;
|
|
|
|
chip->ecc.options |= NAND_ECC_GENERIC_ERASED_CHECK;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* BCH is used */
|
2020-07-31 07:53:37 +00:00
|
|
|
chip->ecc.read_page = stm32_fmc2_nfc_read_page;
|
|
|
|
chip->ecc.calculate = stm32_fmc2_nfc_bch_calculate;
|
|
|
|
chip->ecc.correct = stm32_fmc2_nfc_bch_correct;
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
if (chip->ecc.strength == FMC2_ECC_BCH8)
|
|
|
|
chip->ecc.bytes = chip->options & NAND_BUSWIDTH_16 ? 14 : 13;
|
|
|
|
else
|
|
|
|
chip->ecc.bytes = chip->options & NAND_BUSWIDTH_16 ? 8 : 7;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static int stm32_fmc2_nfc_calc_ecc_bytes(int step_size, int strength)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
|
|
|
/* Hamming */
|
|
|
|
if (strength == FMC2_ECC_HAM)
|
|
|
|
return 4;
|
|
|
|
|
|
|
|
/* BCH8 */
|
|
|
|
if (strength == FMC2_ECC_BCH8)
|
|
|
|
return 14;
|
|
|
|
|
|
|
|
/* BCH4 */
|
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
NAND_ECC_CAPS_SINGLE(stm32_fmc2_nfc_ecc_caps, stm32_fmc2_nfc_calc_ecc_bytes,
|
2019-04-05 09:41:50 +00:00
|
|
|
FMC2_ECC_STEP_SIZE,
|
|
|
|
FMC2_ECC_HAM, FMC2_ECC_BCH4, FMC2_ECC_BCH8);
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static int stm32_fmc2_nfc_parse_child(struct stm32_fmc2_nfc *nfc, ofnode node)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
2020-07-31 07:53:37 +00:00
|
|
|
struct stm32_fmc2_nand *nand = &nfc->nand;
|
2019-04-05 09:41:50 +00:00
|
|
|
u32 cs[FMC2_MAX_CE];
|
|
|
|
int ret, i;
|
|
|
|
|
|
|
|
if (!ofnode_get_property(node, "reg", &nand->ncs))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
nand->ncs /= sizeof(u32);
|
|
|
|
if (!nand->ncs) {
|
2020-11-06 18:01:54 +00:00
|
|
|
log_err("Invalid reg property size\n");
|
2019-04-05 09:41:50 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ofnode_read_u32_array(node, "reg", cs, nand->ncs);
|
|
|
|
if (ret < 0) {
|
2020-11-06 18:01:54 +00:00
|
|
|
log_err("Could not retrieve reg property\n");
|
2019-04-05 09:41:50 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < nand->ncs; i++) {
|
2020-07-31 07:53:34 +00:00
|
|
|
if (cs[i] >= FMC2_MAX_CE) {
|
2020-11-06 18:01:54 +00:00
|
|
|
log_err("Invalid reg value: %d\n", nand->cs_used[i]);
|
2019-04-05 09:41:50 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
if (nfc->cs_assigned & BIT(cs[i])) {
|
2020-11-06 18:01:54 +00:00
|
|
|
log_err("Cs already assigned: %d\n", nand->cs_used[i]);
|
2019-04-05 09:41:50 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
nfc->cs_assigned |= BIT(cs[i]);
|
2019-04-05 09:41:50 +00:00
|
|
|
nand->cs_used[i] = cs[i];
|
|
|
|
}
|
|
|
|
|
2021-09-13 14:25:53 +00:00
|
|
|
nand->chip.flash_node = node;
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static int stm32_fmc2_nfc_parse_dt(struct udevice *dev,
|
|
|
|
struct stm32_fmc2_nfc *nfc)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
|
|
|
ofnode child;
|
|
|
|
int ret, nchips = 0;
|
|
|
|
|
|
|
|
dev_for_each_subnode(child, dev)
|
|
|
|
nchips++;
|
|
|
|
|
|
|
|
if (!nchips) {
|
2020-11-06 18:01:54 +00:00
|
|
|
log_err("NAND chip not defined\n");
|
2019-04-05 09:41:50 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nchips > 1) {
|
2020-11-06 18:01:54 +00:00
|
|
|
log_err("Too many NAND chips defined\n");
|
2019-04-05 09:41:50 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev_for_each_subnode(child, dev) {
|
2020-07-31 07:53:37 +00:00
|
|
|
ret = stm32_fmc2_nfc_parse_child(nfc, child);
|
2019-04-05 09:41:50 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:41 +00:00
|
|
|
static struct udevice *stm32_fmc2_nfc_get_cdev(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct udevice *pdev = dev_get_parent(dev);
|
|
|
|
struct udevice *cdev = NULL;
|
|
|
|
bool ebi_found = false;
|
|
|
|
|
|
|
|
if (pdev && ofnode_device_is_compatible(dev_ofnode(pdev),
|
|
|
|
"st,stm32mp1-fmc2-ebi"))
|
|
|
|
ebi_found = true;
|
|
|
|
|
|
|
|
if (ofnode_device_is_compatible(dev_ofnode(dev),
|
|
|
|
"st,stm32mp1-fmc2-nfc")) {
|
|
|
|
if (ebi_found)
|
|
|
|
cdev = pdev;
|
|
|
|
|
|
|
|
return cdev;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ebi_found)
|
|
|
|
cdev = dev;
|
|
|
|
|
|
|
|
return cdev;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static int stm32_fmc2_nfc_probe(struct udevice *dev)
|
2019-04-05 09:41:50 +00:00
|
|
|
{
|
2020-07-31 07:53:37 +00:00
|
|
|
struct stm32_fmc2_nfc *nfc = dev_get_priv(dev);
|
|
|
|
struct stm32_fmc2_nand *nand = &nfc->nand;
|
2019-04-05 09:41:50 +00:00
|
|
|
struct nand_chip *chip = &nand->chip;
|
|
|
|
struct mtd_info *mtd = &chip->mtd;
|
|
|
|
struct nand_ecclayout *ecclayout;
|
2020-07-31 07:53:41 +00:00
|
|
|
struct udevice *cdev;
|
2019-04-05 09:41:50 +00:00
|
|
|
struct reset_ctl reset;
|
2019-06-21 13:26:54 +00:00
|
|
|
int oob_index, chip_cs, mem_region, ret;
|
|
|
|
unsigned int i;
|
2020-07-31 07:53:41 +00:00
|
|
|
int start_region = 0;
|
|
|
|
fdt_addr_t addr;
|
2019-04-05 09:41:50 +00:00
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
spin_lock_init(&nfc->controller.lock);
|
|
|
|
init_waitqueue_head(&nfc->controller.wq);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
2020-07-31 07:53:41 +00:00
|
|
|
cdev = stm32_fmc2_nfc_get_cdev(dev);
|
|
|
|
if (!cdev)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
ret = stm32_fmc2_nfc_parse_dt(dev, nfc);
|
2019-04-05 09:41:50 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2020-07-31 07:53:41 +00:00
|
|
|
nfc->io_base = dev_read_addr(cdev);
|
|
|
|
if (nfc->io_base == FDT_ADDR_T_NONE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (dev == cdev)
|
|
|
|
start_region = 1;
|
2019-04-05 09:41:50 +00:00
|
|
|
|
2020-07-31 07:53:41 +00:00
|
|
|
for (chip_cs = 0, mem_region = start_region; chip_cs < FMC2_MAX_CE;
|
2019-04-05 09:41:50 +00:00
|
|
|
chip_cs++, mem_region += 3) {
|
2020-07-31 07:53:37 +00:00
|
|
|
if (!(nfc->cs_assigned & BIT(chip_cs)))
|
2019-04-05 09:41:50 +00:00
|
|
|
continue;
|
|
|
|
|
2020-07-31 07:53:41 +00:00
|
|
|
addr = dev_read_addr_index(dev, mem_region);
|
|
|
|
if (addr == FDT_ADDR_T_NONE) {
|
2020-11-06 18:01:54 +00:00
|
|
|
dev_err(dev, "Resource data_base not found for cs%d", chip_cs);
|
2019-04-05 09:41:50 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2020-07-31 07:53:41 +00:00
|
|
|
nfc->data_base[chip_cs] = addr;
|
2019-04-05 09:41:50 +00:00
|
|
|
|
2020-07-31 07:53:41 +00:00
|
|
|
addr = dev_read_addr_index(dev, mem_region + 1);
|
|
|
|
if (addr == FDT_ADDR_T_NONE) {
|
2020-11-06 18:01:54 +00:00
|
|
|
dev_err(dev, "Resource cmd_base not found for cs%d", chip_cs);
|
2019-04-05 09:41:50 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2020-07-31 07:53:41 +00:00
|
|
|
nfc->cmd_base[chip_cs] = addr;
|
2019-04-05 09:41:50 +00:00
|
|
|
|
2020-07-31 07:53:41 +00:00
|
|
|
addr = dev_read_addr_index(dev, mem_region + 2);
|
|
|
|
if (addr == FDT_ADDR_T_NONE) {
|
2020-11-06 18:01:54 +00:00
|
|
|
dev_err(dev, "Resource addr_base not found for cs%d", chip_cs);
|
2019-04-05 09:41:50 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2020-07-31 07:53:41 +00:00
|
|
|
nfc->addr_base[chip_cs] = addr;
|
2019-04-05 09:41:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable the clock */
|
2020-07-31 07:53:41 +00:00
|
|
|
ret = clk_get_by_index(cdev, 0, &nfc->clk);
|
2019-04-05 09:41:50 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
ret = clk_enable(&nfc->clk);
|
2019-04-05 09:41:50 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* Reset */
|
|
|
|
ret = reset_get_by_index(dev, 0, &reset);
|
|
|
|
if (!ret) {
|
|
|
|
reset_assert(&reset);
|
|
|
|
udelay(2);
|
|
|
|
reset_deassert(&reset);
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:41 +00:00
|
|
|
stm32_fmc2_nfc_init(nfc, dev != cdev);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
chip->controller = &nfc->base;
|
|
|
|
chip->select_chip = stm32_fmc2_nfc_select_chip;
|
|
|
|
chip->setup_data_interface = stm32_fmc2_nfc_setup_interface;
|
|
|
|
chip->cmd_ctrl = stm32_fmc2_nfc_cmd_ctrl;
|
2019-04-05 09:41:50 +00:00
|
|
|
chip->chip_delay = FMC2_RB_DELAY_US;
|
|
|
|
chip->options |= NAND_BUSWIDTH_AUTO | NAND_NO_SUBPAGE_WRITE |
|
|
|
|
NAND_USE_BOUNCE_BUFFER;
|
|
|
|
|
|
|
|
/* Default ECC settings */
|
|
|
|
chip->ecc.mode = NAND_ECC_HW;
|
|
|
|
chip->ecc.size = FMC2_ECC_STEP_SIZE;
|
|
|
|
chip->ecc.strength = FMC2_ECC_BCH8;
|
|
|
|
|
|
|
|
ret = nand_scan_ident(mtd, nand->ncs, NULL);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only NAND_ECC_HW mode is actually supported
|
|
|
|
* Hamming => ecc.strength = 1
|
|
|
|
* BCH4 => ecc.strength = 4
|
|
|
|
* BCH8 => ecc.strength = 8
|
|
|
|
* ECC sector size = 512
|
|
|
|
*/
|
|
|
|
if (chip->ecc.mode != NAND_ECC_HW) {
|
2020-11-06 18:01:54 +00:00
|
|
|
dev_err(dev, "Nand_ecc_mode is not well defined in the DT\n");
|
2019-04-05 09:41:50 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
ret = nand_check_ecc_caps(chip, &stm32_fmc2_nfc_ecc_caps,
|
2019-04-05 09:41:50 +00:00
|
|
|
mtd->oobsize - FMC2_BBM_LEN);
|
|
|
|
if (ret) {
|
2020-11-06 18:01:54 +00:00
|
|
|
dev_err(dev, "No valid ECC settings set\n");
|
2019-04-05 09:41:50 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (chip->bbt_options & NAND_BBT_USE_FLASH)
|
|
|
|
chip->bbt_options |= NAND_BBT_NO_OOB;
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
stm32_fmc2_nfc_nand_callbacks_setup(chip);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
/* Define ECC layout */
|
2020-07-31 07:53:37 +00:00
|
|
|
ecclayout = &nfc->ecclayout;
|
2019-04-05 09:41:50 +00:00
|
|
|
ecclayout->eccbytes = chip->ecc.bytes *
|
|
|
|
(mtd->writesize / chip->ecc.size);
|
|
|
|
oob_index = FMC2_BBM_LEN;
|
|
|
|
for (i = 0; i < ecclayout->eccbytes; i++, oob_index++)
|
|
|
|
ecclayout->eccpos[i] = oob_index;
|
|
|
|
ecclayout->oobfree->offset = oob_index;
|
|
|
|
ecclayout->oobfree->length = mtd->oobsize - ecclayout->oobfree->offset;
|
|
|
|
chip->ecc.layout = ecclayout;
|
|
|
|
|
|
|
|
if (chip->options & NAND_BUSWIDTH_16)
|
2020-07-31 07:53:37 +00:00
|
|
|
stm32_fmc2_nfc_set_buswidth_16(nfc, true);
|
2019-04-05 09:41:50 +00:00
|
|
|
|
|
|
|
ret = nand_scan_tail(mtd);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return nand_register(0, mtd);
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
static const struct udevice_id stm32_fmc2_nfc_match[] = {
|
2019-04-05 09:41:50 +00:00
|
|
|
{ .compatible = "st,stm32mp15-fmc2" },
|
2020-07-31 07:53:41 +00:00
|
|
|
{ .compatible = "st,stm32mp1-fmc2-nfc" },
|
2019-04-05 09:41:50 +00:00
|
|
|
{ /* Sentinel */ }
|
|
|
|
};
|
|
|
|
|
2020-07-31 07:53:37 +00:00
|
|
|
U_BOOT_DRIVER(stm32_fmc2_nfc) = {
|
|
|
|
.name = "stm32_fmc2_nfc",
|
2019-04-05 09:41:50 +00:00
|
|
|
.id = UCLASS_MTD,
|
2020-07-31 07:53:37 +00:00
|
|
|
.of_match = stm32_fmc2_nfc_match,
|
|
|
|
.probe = stm32_fmc2_nfc_probe,
|
2020-12-03 23:55:17 +00:00
|
|
|
.priv_auto = sizeof(struct stm32_fmc2_nfc),
|
2019-04-05 09:41:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void board_nand_init(void)
|
|
|
|
{
|
|
|
|
struct udevice *dev;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = uclass_get_device_by_driver(UCLASS_MTD,
|
2020-12-29 03:34:56 +00:00
|
|
|
DM_DRIVER_GET(stm32_fmc2_nfc),
|
2019-04-05 09:41:50 +00:00
|
|
|
&dev);
|
|
|
|
if (ret && ret != -ENODEV)
|
2020-11-06 18:01:54 +00:00
|
|
|
log_err("Failed to initialize STM32 FMC2 NFC controller. (error %d)\n",
|
|
|
|
ret);
|
2019-04-05 09:41:50 +00:00
|
|
|
}
|