|
|
@@ -1,101 +1,27 @@
|
|
|
-From 1142a905d3450a40ac03cbe1426b16cd9650c5f7 Mon Sep 17 00:00:00 2001
|
|
|
+From 8c52932da5e6756fa66f52f0720da283fba13aa6 Mon Sep 17 00:00:00 2001
|
|
|
From: Md Sadre Alam <[email protected]>
|
|
|
-Date: Thu, 4 Apr 2024 16:19:43 +0530
|
|
|
-Subject: [PATCH v10 2/8] mtd: rawnand: qcom: cleanup qcom_nandc driver
|
|
|
+Date: Wed, 20 Nov 2024 14:45:00 +0530
|
|
|
+Subject: [PATCH 1/4] mtd: rawnand: qcom: cleanup qcom_nandc driver
|
|
|
|
|
|
-cleanup qcom_nandc driver as below
|
|
|
+Perform a global cleanup of the Qualcomm NAND
|
|
|
+controller driver with the following improvements:
|
|
|
|
|
|
-- Remove register value indirection api
|
|
|
+- Remove register value indirection API
|
|
|
|
|
|
-- Remove set_reg() api
|
|
|
+- Remove set_reg() API
|
|
|
|
|
|
-- Convert read_loc_first & read_loc_last macro to function
|
|
|
+- Convert read_loc_first & read_loc_last macro to functions
|
|
|
|
|
|
-- Renamed multiple variables
|
|
|
+- Rename multiple variables
|
|
|
|
|
|
Signed-off-by: Md Sadre Alam <[email protected]>
|
|
|
+Signed-off-by: Miquel Raynal <[email protected]>
|
|
|
---
|
|
|
+ drivers/mtd/nand/raw/qcom_nandc.c | 516 ++++++++++++++----------------
|
|
|
+ 1 file changed, 234 insertions(+), 282 deletions(-)
|
|
|
|
|
|
-Change in [v10]
|
|
|
-
|
|
|
-* No change
|
|
|
-
|
|
|
-Change in [v9]
|
|
|
-
|
|
|
-* Changed type of cmd1, vld to u32 from __le32 in qcom_nand_controller
|
|
|
- structure
|
|
|
-* Changed type of cfg0, cfg1, cfg0_raw, cfg1_raw, clrflashstatus,
|
|
|
- ecc_buf_cfg, ecc_bch_cfg, clrreadstatus to u32 in qcom_nand_host
|
|
|
- structure
|
|
|
-* In nandc_set_read_loc_first() api added cpu_to_le32() macro to fix
|
|
|
- compilation warning reported by kernel test bot
|
|
|
-* In nandc_set_read_loc_last() api added cpu_to_le32() macro to fix
|
|
|
- compilation warning reported by kernel test bot
|
|
|
-* Changed data type of cw_offset, read_size, is_last_read_loc to
|
|
|
- u32 in nandc_set_read_loc() api to fix compilation warning reported
|
|
|
- by kernel test bot
|
|
|
-* In set_address() api added cpu_to_le32() macro to fix compilation
|
|
|
- warning reported by kernel test bot
|
|
|
-* In update_rw_regs() api added cpu_to_le32() macro to fix compilation
|
|
|
- warning reported by kernel test bot
|
|
|
-* In qcom_op_cmd_mapping() api added cpu_to_le32() macro to fix compilation
|
|
|
- warning reported by kernel test bot
|
|
|
-* In qcom_read_status_exec() api added cpu_to_le32() macro to fix compilation
|
|
|
- warning reported by kernel test bot
|
|
|
-* In qcom_read_id_type_exec() api added cpu_to_le32() macro to fix compilation
|
|
|
- warning reported by kernel test bot
|
|
|
-* In qcom_misc_cmd_type_exec() api added cpu_to_le32() macro to fix compilation
|
|
|
- warning reported by kernel test bot
|
|
|
-* In qcom_param_page_type_exec() api added cpu_to_le32() macro to fix
|
|
|
- compilation warning reported by kernel test bot
|
|
|
-
|
|
|
-Change in [v8]
|
|
|
-
|
|
|
-* Fixed compilation warning reported by kernel test robot
|
|
|
-* Added "chip" description in nandc_set_read_loc_first()
|
|
|
-* Added "chip" description in nandc_set_read_loc_last()
|
|
|
-* Changed data type of read_location0, read_location1,
|
|
|
- read_location2, read_location3, read_location_last0,
|
|
|
- read_location_last1, read_location_last2, read_location_last3,
|
|
|
- addr0, addr1, cmd, cfg0, cfg1, ecc_bch_cfg, ecc_buf_cfg,
|
|
|
- clrflashstatus, clrreadstatus, orig_cmd1, orig_vld to
|
|
|
- __le32 to fix compilation warning reported by kernel test robot
|
|
|
-
|
|
|
-Change in [v7]
|
|
|
-
|
|
|
-* No change
|
|
|
-
|
|
|
-Change in [v6]
|
|
|
-
|
|
|
-* No change
|
|
|
-
|
|
|
-Change in [v5]
|
|
|
-
|
|
|
-* Cleand up raw nand driver.
|
|
|
-
|
|
|
-* Removed register value indirection
|
|
|
-
|
|
|
-* Removed set_reg() api.
|
|
|
-
|
|
|
-Change in [v4]
|
|
|
-
|
|
|
-* This patch was not included in [v4]
|
|
|
-
|
|
|
-Change in [v3]
|
|
|
-
|
|
|
-* This patch was not included in [v3]
|
|
|
-
|
|
|
-Change in [v2]
|
|
|
-
|
|
|
-* This patch was not included in [v2]
|
|
|
-
|
|
|
-Change in [v1]
|
|
|
-
|
|
|
-* This patch was not included in [v1]
|
|
|
-
|
|
|
- drivers/mtd/nand/raw/qcom_nandc.c | 506 ++++++++++++++----------------
|
|
|
- 1 file changed, 229 insertions(+), 277 deletions(-)
|
|
|
-
|
|
|
+diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
|
|
|
+index 636bba2528bf..9ae8c9f2ab55 100644
|
|
|
--- a/drivers/mtd/nand/raw/qcom_nandc.c
|
|
|
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
|
|
|
@@ -189,17 +189,6 @@
|
|
|
@@ -153,7 +79,7 @@ Change in [v1]
|
|
|
- * @is_bam - whether NAND controller is using BAM
|
|
|
- * @is_qpic - whether NAND CTRL is part of qpic IP
|
|
|
- * @qpic_v2 - flag to indicate QPIC IP version 2
|
|
|
-+ * @supports_bam - whether NAND controller is using BAM
|
|
|
++ * @supports_bam - whether NAND controller is using Bus Access Manager (BAM)
|
|
|
+ * @nandc_part_of_qpic - whether NAND controller is part of qpic IP
|
|
|
+ * @qpic_version2 - flag to indicate QPIC IP version 2
|
|
|
* @use_codeword_fixup - whether NAND has different layout for boot partitions
|
|
|
@@ -170,7 +96,7 @@ Change in [v1]
|
|
|
bool use_codeword_fixup;
|
|
|
};
|
|
|
|
|
|
-@@ -613,19 +599,18 @@ static void clear_bam_transaction(struct
|
|
|
+@@ -613,19 +599,11 @@ static void clear_bam_transaction(struct qcom_nand_controller *nandc)
|
|
|
{
|
|
|
struct bam_transaction *bam_txn = nandc->bam_txn;
|
|
|
|
|
|
@@ -178,20 +104,21 @@ Change in [v1]
|
|
|
+ if (!nandc->props->supports_bam)
|
|
|
return;
|
|
|
|
|
|
- bam_txn->bam_ce_pos = 0;
|
|
|
- bam_txn->bam_ce_start = 0;
|
|
|
- bam_txn->cmd_sgl_pos = 0;
|
|
|
- bam_txn->cmd_sgl_start = 0;
|
|
|
- bam_txn->tx_sgl_pos = 0;
|
|
|
- bam_txn->tx_sgl_start = 0;
|
|
|
- bam_txn->rx_sgl_pos = 0;
|
|
|
- bam_txn->rx_sgl_start = 0;
|
|
|
+- bam_txn->bam_ce_pos = 0;
|
|
|
+- bam_txn->bam_ce_start = 0;
|
|
|
+- bam_txn->cmd_sgl_pos = 0;
|
|
|
+- bam_txn->cmd_sgl_start = 0;
|
|
|
+- bam_txn->tx_sgl_pos = 0;
|
|
|
+- bam_txn->tx_sgl_start = 0;
|
|
|
+- bam_txn->rx_sgl_pos = 0;
|
|
|
+- bam_txn->rx_sgl_start = 0;
|
|
|
++ memset(&bam_txn->bam_ce_pos, 0, sizeof(u32) * 8);
|
|
|
bam_txn->last_data_desc = NULL;
|
|
|
- bam_txn->wait_second_completion = false;
|
|
|
|
|
|
sg_init_table(bam_txn->cmd_sgl, nandc->max_cwperpage *
|
|
|
QPIC_PER_CW_CMD_SGL);
|
|
|
-@@ -640,17 +618,7 @@ static void qpic_bam_dma_done(void *data
|
|
|
+@@ -640,46 +618,35 @@ static void qpic_bam_dma_done(void *data)
|
|
|
{
|
|
|
struct bam_transaction *bam_txn = data;
|
|
|
|
|
|
@@ -209,21 +136,44 @@ Change in [v1]
|
|
|
+ complete(&bam_txn->txn_done);
|
|
|
}
|
|
|
|
|
|
- static inline struct qcom_nand_host *to_qcom_nand_host(struct nand_chip *chip)
|
|
|
-@@ -676,10 +644,9 @@ static inline void nandc_write(struct qc
|
|
|
+-static inline struct qcom_nand_host *to_qcom_nand_host(struct nand_chip *chip)
|
|
|
++static struct qcom_nand_host *to_qcom_nand_host(struct nand_chip *chip)
|
|
|
+ {
|
|
|
+ return container_of(chip, struct qcom_nand_host, chip);
|
|
|
+ }
|
|
|
+
|
|
|
+-static inline struct qcom_nand_controller *
|
|
|
++static struct qcom_nand_controller *
|
|
|
+ get_qcom_nand_controller(struct nand_chip *chip)
|
|
|
+ {
|
|
|
+ return container_of(chip->controller, struct qcom_nand_controller,
|
|
|
+ controller);
|
|
|
+ }
|
|
|
+
|
|
|
+-static inline u32 nandc_read(struct qcom_nand_controller *nandc, int offset)
|
|
|
++static u32 nandc_read(struct qcom_nand_controller *nandc, int offset)
|
|
|
+ {
|
|
|
+ return ioread32(nandc->base + offset);
|
|
|
+ }
|
|
|
+
|
|
|
+-static inline void nandc_write(struct qcom_nand_controller *nandc, int offset,
|
|
|
+- u32 val)
|
|
|
++static void nandc_write(struct qcom_nand_controller *nandc, int offset,
|
|
|
++ u32 val)
|
|
|
+ {
|
|
|
iowrite32(val, nandc->base + offset);
|
|
|
}
|
|
|
|
|
|
-static inline void nandc_read_buffer_sync(struct qcom_nand_controller *nandc,
|
|
|
- bool is_cpu)
|
|
|
-+static inline void nandc_dev_to_mem(struct qcom_nand_controller *nandc, bool is_cpu)
|
|
|
++static void nandc_dev_to_mem(struct qcom_nand_controller *nandc, bool is_cpu)
|
|
|
{
|
|
|
- if (!nandc->props->is_bam)
|
|
|
+ if (!nandc->props->supports_bam)
|
|
|
return;
|
|
|
|
|
|
if (is_cpu)
|
|
|
-@@ -694,93 +661,90 @@ static inline void nandc_read_buffer_syn
|
|
|
+@@ -694,93 +661,90 @@ static inline void nandc_read_buffer_sync(struct qcom_nand_controller *nandc,
|
|
|
DMA_FROM_DEVICE);
|
|
|
}
|
|
|
|
|
|
@@ -279,27 +229,14 @@ Change in [v1]
|
|
|
- default:
|
|
|
- return NULL;
|
|
|
- }
|
|
|
--}
|
|
|
--
|
|
|
--static void nandc_set_reg(struct nand_chip *chip, int offset,
|
|
|
-- u32 val)
|
|
|
--{
|
|
|
-- struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
|
|
|
-- struct nandc_regs *regs = nandc->regs;
|
|
|
-- __le32 *reg;
|
|
|
--
|
|
|
-- reg = offset_to_nandc_reg(regs, offset);
|
|
|
--
|
|
|
-- if (reg)
|
|
|
-- *reg = cpu_to_le32(val);
|
|
|
--}
|
|
|
--
|
|
|
- /* Helper to check the code word, whether it is last cw or not */
|
|
|
- static bool qcom_nandc_is_last_cw(struct nand_ecc_ctrl *ecc, int cw)
|
|
|
- {
|
|
|
- return cw == (ecc->steps - 1);
|
|
|
++/* Helper to check whether this is the last CW or not */
|
|
|
++static bool qcom_nandc_is_last_cw(struct nand_ecc_ctrl *ecc, int cw)
|
|
|
++{
|
|
|
++ return cw == (ecc->steps - 1);
|
|
|
}
|
|
|
|
|
|
+-static void nandc_set_reg(struct nand_chip *chip, int offset,
|
|
|
+- u32 val)
|
|
|
+/**
|
|
|
+ * nandc_set_read_loc_first() - to set read location first register
|
|
|
+ * @chip: NAND Private Flash Chip Data
|
|
|
@@ -313,8 +250,12 @@ Change in [v1]
|
|
|
+static void nandc_set_read_loc_first(struct nand_chip *chip,
|
|
|
+ int reg_base, u32 cw_offset,
|
|
|
+ u32 read_size, u32 is_last_read_loc)
|
|
|
-+{
|
|
|
-+ struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
|
|
|
+ {
|
|
|
+ struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
|
|
|
+- struct nandc_regs *regs = nandc->regs;
|
|
|
+- __le32 *reg;
|
|
|
+-
|
|
|
+- reg = offset_to_nandc_reg(regs, offset);
|
|
|
+ __le32 locreg_val;
|
|
|
+ u32 val = (((cw_offset) << READ_LOCATION_OFFSET) |
|
|
|
+ ((read_size) << READ_LOCATION_SIZE) |
|
|
|
@@ -351,9 +292,16 @@ Change in [v1]
|
|
|
+ u32 val = (((cw_offset) << READ_LOCATION_OFFSET) |
|
|
|
+ ((read_size) << READ_LOCATION_SIZE) |
|
|
|
+ ((is_last_read_loc) << READ_LOCATION_LAST));
|
|
|
-+
|
|
|
+
|
|
|
+- if (reg)
|
|
|
+- *reg = cpu_to_le32(val);
|
|
|
+-}
|
|
|
+ locreg_val = cpu_to_le32(val);
|
|
|
-+
|
|
|
+
|
|
|
+-/* Helper to check the code word, whether it is last cw or not */
|
|
|
+-static bool qcom_nandc_is_last_cw(struct nand_ecc_ctrl *ecc, int cw)
|
|
|
+-{
|
|
|
+- return cw == (ecc->steps - 1);
|
|
|
+ if (reg_base == NAND_READ_LOCATION_LAST_CW_0)
|
|
|
+ nandc->regs->read_location_last0 = locreg_val;
|
|
|
+ else if (reg_base == NAND_READ_LOCATION_LAST_CW_1)
|
|
|
@@ -362,8 +310,8 @@ Change in [v1]
|
|
|
+ nandc->regs->read_location_last2 = locreg_val;
|
|
|
+ else if (reg_base == NAND_READ_LOCATION_LAST_CW_3)
|
|
|
+ nandc->regs->read_location_last3 = locreg_val;
|
|
|
-+}
|
|
|
-+
|
|
|
+ }
|
|
|
+
|
|
|
/* helper to configure location register values */
|
|
|
static void nandc_set_read_loc(struct nand_chip *chip, int cw, int reg,
|
|
|
- int cw_offset, int read_size, int is_last_read_loc)
|
|
|
@@ -384,7 +332,7 @@ Change in [v1]
|
|
|
return nandc_set_read_loc_last(chip, reg_base, cw_offset,
|
|
|
read_size, is_last_read_loc);
|
|
|
else
|
|
|
-@@ -792,12 +756,13 @@ static void nandc_set_read_loc(struct na
|
|
|
+@@ -792,12 +756,13 @@ static void nandc_set_read_loc(struct nand_chip *chip, int cw, int reg,
|
|
|
static void set_address(struct qcom_nand_host *host, u16 column, int page)
|
|
|
{
|
|
|
struct nand_chip *chip = &host->chip;
|
|
|
@@ -400,7 +348,7 @@ Change in [v1]
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
-@@ -811,41 +776,43 @@ static void set_address(struct qcom_nand
|
|
|
+@@ -811,41 +776,43 @@ static void set_address(struct qcom_nand_host *host, u16 column, int page)
|
|
|
static void update_rw_regs(struct qcom_nand_host *host, int num_cw, bool read, int cw)
|
|
|
{
|
|
|
struct nand_chip *chip = &host->chip;
|
|
|
@@ -465,7 +413,7 @@ Change in [v1]
|
|
|
|
|
|
if (read)
|
|
|
nandc_set_read_loc(chip, cw, 0, 0, host->use_ecc ?
|
|
|
-@@ -1121,7 +1088,7 @@ static int read_reg_dma(struct qcom_nand
|
|
|
+@@ -1121,7 +1088,7 @@ static int read_reg_dma(struct qcom_nand_controller *nandc, int first,
|
|
|
if (first == NAND_DEV_CMD_VLD || first == NAND_DEV_CMD1)
|
|
|
first = dev_cmd_reg_addr(nandc, first);
|
|
|
|
|
|
@@ -474,11 +422,11 @@ Change in [v1]
|
|
|
return prep_bam_dma_desc_cmd(nandc, true, first, vaddr,
|
|
|
num_regs, flags);
|
|
|
|
|
|
-@@ -1136,25 +1103,16 @@ static int read_reg_dma(struct qcom_nand
|
|
|
+@@ -1136,25 +1103,16 @@ static int read_reg_dma(struct qcom_nand_controller *nandc, int first,
|
|
|
* write_reg_dma: prepares a descriptor to write a given number of
|
|
|
* contiguous registers
|
|
|
*
|
|
|
-+ * @vaddr: contnigeous memory from where register value will
|
|
|
++ * @vaddr: contiguous memory from where register value will
|
|
|
+ * be written
|
|
|
* @first: offset of the first register in the contiguous block
|
|
|
* @num_regs: number of registers to write
|
|
|
@@ -504,7 +452,7 @@ Change in [v1]
|
|
|
|
|
|
if (first == NAND_EXEC_CMD)
|
|
|
flags |= NAND_BAM_NWD;
|
|
|
-@@ -1165,7 +1123,7 @@ static int write_reg_dma(struct qcom_nan
|
|
|
+@@ -1165,7 +1123,7 @@ static int write_reg_dma(struct qcom_nand_controller *nandc, int first,
|
|
|
if (first == NAND_DEV_CMD_VLD_RESTORE || first == NAND_DEV_CMD_VLD)
|
|
|
first = dev_cmd_reg_addr(nandc, NAND_DEV_CMD_VLD);
|
|
|
|
|
|
@@ -513,7 +461,7 @@ Change in [v1]
|
|
|
return prep_bam_dma_desc_cmd(nandc, false, first, vaddr,
|
|
|
num_regs, flags);
|
|
|
|
|
|
-@@ -1188,7 +1146,7 @@ static int write_reg_dma(struct qcom_nan
|
|
|
+@@ -1188,7 +1146,7 @@ static int write_reg_dma(struct qcom_nand_controller *nandc, int first,
|
|
|
static int read_data_dma(struct qcom_nand_controller *nandc, int reg_off,
|
|
|
const u8 *vaddr, int size, unsigned int flags)
|
|
|
{
|
|
|
@@ -522,7 +470,7 @@ Change in [v1]
|
|
|
return prep_bam_dma_desc_data(nandc, true, vaddr, size, flags);
|
|
|
|
|
|
return prep_adm_dma_desc(nandc, true, reg_off, vaddr, size, false);
|
|
|
-@@ -1206,7 +1164,7 @@ static int read_data_dma(struct qcom_nan
|
|
|
+@@ -1206,7 +1164,7 @@ static int read_data_dma(struct qcom_nand_controller *nandc, int reg_off,
|
|
|
static int write_data_dma(struct qcom_nand_controller *nandc, int reg_off,
|
|
|
const u8 *vaddr, int size, unsigned int flags)
|
|
|
{
|
|
|
@@ -531,7 +479,7 @@ Change in [v1]
|
|
|
return prep_bam_dma_desc_data(nandc, false, vaddr, size, flags);
|
|
|
|
|
|
return prep_adm_dma_desc(nandc, false, reg_off, vaddr, size, false);
|
|
|
-@@ -1220,13 +1178,14 @@ static void config_nand_page_read(struct
|
|
|
+@@ -1220,13 +1178,14 @@ static void config_nand_page_read(struct nand_chip *chip)
|
|
|
{
|
|
|
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
|
|
|
|
|
|
@@ -553,7 +501,7 @@ Change in [v1]
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
-@@ -1239,16 +1198,16 @@ config_nand_cw_read(struct nand_chip *ch
|
|
|
+@@ -1239,16 +1198,16 @@ config_nand_cw_read(struct nand_chip *chip, bool use_ecc, int cw)
|
|
|
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
|
|
|
struct nand_ecc_ctrl *ecc = &chip->ecc;
|
|
|
|
|
|
@@ -577,7 +525,7 @@ Change in [v1]
|
|
|
|
|
|
if (use_ecc) {
|
|
|
read_reg_dma(nandc, NAND_FLASH_STATUS, 2, 0);
|
|
|
-@@ -1279,10 +1238,10 @@ static void config_nand_page_write(struc
|
|
|
+@@ -1279,10 +1238,10 @@ static void config_nand_page_write(struct nand_chip *chip)
|
|
|
{
|
|
|
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
|
|
|
|
|
|
@@ -592,7 +540,7 @@ Change in [v1]
|
|
|
NAND_BAM_NEXT_SGL);
|
|
|
}
|
|
|
|
|
|
-@@ -1294,13 +1253,13 @@ static void config_nand_cw_write(struct
|
|
|
+@@ -1294,13 +1253,13 @@ static void config_nand_cw_write(struct nand_chip *chip)
|
|
|
{
|
|
|
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
|
|
|
|
|
|
@@ -610,7 +558,7 @@ Change in [v1]
|
|
|
}
|
|
|
|
|
|
/* helpers to submit/free our list of dma descriptors */
|
|
|
-@@ -1311,7 +1270,7 @@ static int submit_descs(struct qcom_nand
|
|
|
+@@ -1311,7 +1270,7 @@ static int submit_descs(struct qcom_nand_controller *nandc)
|
|
|
struct bam_transaction *bam_txn = nandc->bam_txn;
|
|
|
int ret = 0;
|
|
|
|
|
|
@@ -619,7 +567,7 @@ Change in [v1]
|
|
|
if (bam_txn->rx_sgl_pos > bam_txn->rx_sgl_start) {
|
|
|
ret = prepare_bam_async_desc(nandc, nandc->rx_chan, 0);
|
|
|
if (ret)
|
|
|
-@@ -1336,14 +1295,9 @@ static int submit_descs(struct qcom_nand
|
|
|
+@@ -1336,14 +1295,9 @@ static int submit_descs(struct qcom_nand_controller *nandc)
|
|
|
list_for_each_entry(desc, &nandc->desc_list, node)
|
|
|
cookie = dmaengine_submit(desc->dma_desc);
|
|
|
|
|
|
@@ -635,7 +583,7 @@ Change in [v1]
|
|
|
|
|
|
dma_async_issue_pending(nandc->tx_chan);
|
|
|
dma_async_issue_pending(nandc->rx_chan);
|
|
|
-@@ -1365,7 +1319,7 @@ err_unmap_free_desc:
|
|
|
+@@ -1365,7 +1319,7 @@ static int submit_descs(struct qcom_nand_controller *nandc)
|
|
|
list_for_each_entry_safe(desc, n, &nandc->desc_list, node) {
|
|
|
list_del(&desc->node);
|
|
|
|
|
|
@@ -644,7 +592,7 @@ Change in [v1]
|
|
|
dma_unmap_sg(nandc->dev, desc->bam_sgl,
|
|
|
desc->sgl_cnt, desc->dir);
|
|
|
else
|
|
|
-@@ -1382,7 +1336,7 @@ err_unmap_free_desc:
|
|
|
+@@ -1382,7 +1336,7 @@ static int submit_descs(struct qcom_nand_controller *nandc)
|
|
|
static void clear_read_regs(struct qcom_nand_controller *nandc)
|
|
|
{
|
|
|
nandc->reg_read_pos = 0;
|
|
|
@@ -653,7 +601,7 @@ Change in [v1]
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
-@@ -1446,7 +1400,7 @@ static int check_flash_errors(struct qco
|
|
|
+@@ -1446,7 +1400,7 @@ static int check_flash_errors(struct qcom_nand_host *host, int cw_cnt)
|
|
|
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
|
|
|
int i;
|
|
|
|
|
|
@@ -662,7 +610,7 @@ Change in [v1]
|
|
|
|
|
|
for (i = 0; i < cw_cnt; i++) {
|
|
|
u32 flash = le32_to_cpu(nandc->reg_read_buf[i]);
|
|
|
-@@ -1476,7 +1430,7 @@ qcom_nandc_read_cw_raw(struct mtd_info *
|
|
|
+@@ -1476,7 +1430,7 @@ qcom_nandc_read_cw_raw(struct mtd_info *mtd, struct nand_chip *chip,
|
|
|
clear_read_regs(nandc);
|
|
|
host->use_ecc = false;
|
|
|
|
|
|
@@ -671,7 +619,7 @@ Change in [v1]
|
|
|
raw_cw = ecc->steps - 1;
|
|
|
|
|
|
clear_bam_transaction(nandc);
|
|
|
-@@ -1497,7 +1451,7 @@ qcom_nandc_read_cw_raw(struct mtd_info *
|
|
|
+@@ -1497,7 +1451,7 @@ qcom_nandc_read_cw_raw(struct mtd_info *mtd, struct nand_chip *chip,
|
|
|
oob_size2 = host->ecc_bytes_hw + host->spare_bytes;
|
|
|
}
|
|
|
|
|
|
@@ -680,7 +628,7 @@ Change in [v1]
|
|
|
nandc_set_read_loc(chip, cw, 0, read_loc, data_size1, 0);
|
|
|
read_loc += data_size1;
|
|
|
|
|
|
-@@ -1621,7 +1575,7 @@ static int parse_read_errors(struct qcom
|
|
|
+@@ -1621,7 +1575,7 @@ static int parse_read_errors(struct qcom_nand_host *host, u8 *data_buf,
|
|
|
u8 *data_buf_start = data_buf, *oob_buf_start = oob_buf;
|
|
|
|
|
|
buf = (struct read_stats *)nandc->reg_read_buf;
|
|
|
@@ -689,7 +637,7 @@ Change in [v1]
|
|
|
|
|
|
for (i = 0; i < ecc->steps; i++, buf++) {
|
|
|
u32 flash, buffer, erased_cw;
|
|
|
-@@ -1734,7 +1688,7 @@ static int read_page_ecc(struct qcom_nan
|
|
|
+@@ -1734,7 +1688,7 @@ static int read_page_ecc(struct qcom_nand_host *host, u8 *data_buf,
|
|
|
oob_size = host->ecc_bytes_hw + host->spare_bytes;
|
|
|
}
|
|
|
|
|
|
@@ -698,7 +646,7 @@ Change in [v1]
|
|
|
if (data_buf && oob_buf) {
|
|
|
nandc_set_read_loc(chip, i, 0, 0, data_size, 0);
|
|
|
nandc_set_read_loc(chip, i, 1, data_size,
|
|
|
-@@ -2455,14 +2409,14 @@ static int qcom_nand_attach_chip(struct
|
|
|
+@@ -2455,14 +2409,14 @@ static int qcom_nand_attach_chip(struct nand_chip *chip)
|
|
|
|
|
|
mtd_set_ooblayout(mtd, &qcom_nand_ooblayout_ops);
|
|
|
/* Free the initially allocated BAM transaction for reading the ONFI params */
|
|
|
@@ -715,7 +663,7 @@ Change in [v1]
|
|
|
nandc->bam_txn = alloc_bam_transaction(nandc);
|
|
|
if (!nandc->bam_txn) {
|
|
|
dev_err(nandc->dev,
|
|
|
-@@ -2522,7 +2476,7 @@ static int qcom_nand_attach_chip(struct
|
|
|
+@@ -2522,7 +2476,7 @@ static int qcom_nand_attach_chip(struct nand_chip *chip)
|
|
|
| ecc_mode << ECC_MODE
|
|
|
| host->ecc_bytes_hw << ECC_PARITY_SIZE_BYTES_BCH;
|
|
|
|
|
|
@@ -724,7 +672,7 @@ Change in [v1]
|
|
|
host->ecc_buf_cfg = 0x203 << NUM_STEPS;
|
|
|
|
|
|
host->clrflashstatus = FS_READY_BSY_N;
|
|
|
-@@ -2556,7 +2510,7 @@ static int qcom_op_cmd_mapping(struct na
|
|
|
+@@ -2556,7 +2510,7 @@ static int qcom_op_cmd_mapping(struct nand_chip *chip, u8 opcode,
|
|
|
cmd = OP_FETCH_ID;
|
|
|
break;
|
|
|
case NAND_CMD_PARAM:
|
|
|
@@ -733,7 +681,7 @@ Change in [v1]
|
|
|
cmd = OP_PAGE_READ_ONFI_READ;
|
|
|
else
|
|
|
cmd = OP_PAGE_READ;
|
|
|
-@@ -2609,7 +2563,7 @@ static int qcom_parse_instructions(struc
|
|
|
+@@ -2609,7 +2563,7 @@ static int qcom_parse_instructions(struct nand_chip *chip,
|
|
|
if (ret < 0)
|
|
|
return ret;
|
|
|
|
|
|
@@ -742,7 +690,7 @@ Change in [v1]
|
|
|
q_op->rdy_delay_ns = instr->delay_ns;
|
|
|
break;
|
|
|
|
|
|
-@@ -2619,10 +2573,10 @@ static int qcom_parse_instructions(struc
|
|
|
+@@ -2619,10 +2573,10 @@ static int qcom_parse_instructions(struct nand_chip *chip,
|
|
|
addrs = &instr->ctx.addr.addrs[offset];
|
|
|
|
|
|
for (i = 0; i < min_t(unsigned int, 4, naddrs); i++)
|
|
|
@@ -755,7 +703,7 @@ Change in [v1]
|
|
|
|
|
|
q_op->rdy_delay_ns = instr->delay_ns;
|
|
|
break;
|
|
|
-@@ -2663,7 +2617,7 @@ static int qcom_wait_rdy_poll(struct nan
|
|
|
+@@ -2663,7 +2617,7 @@ static int qcom_wait_rdy_poll(struct nand_chip *chip, unsigned int time_ms)
|
|
|
unsigned long start = jiffies + msecs_to_jiffies(time_ms);
|
|
|
u32 flash;
|
|
|
|
|
|
@@ -764,7 +712,7 @@ Change in [v1]
|
|
|
|
|
|
do {
|
|
|
flash = le32_to_cpu(nandc->reg_read_buf[0]);
|
|
|
-@@ -2706,11 +2660,11 @@ static int qcom_read_status_exec(struct
|
|
|
+@@ -2706,11 +2660,11 @@ static int qcom_read_status_exec(struct nand_chip *chip,
|
|
|
clear_read_regs(nandc);
|
|
|
clear_bam_transaction(nandc);
|
|
|
|
|
|
@@ -780,7 +728,7 @@ Change in [v1]
|
|
|
read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL);
|
|
|
|
|
|
ret = submit_descs(nandc);
|
|
|
-@@ -2719,7 +2673,7 @@ static int qcom_read_status_exec(struct
|
|
|
+@@ -2719,7 +2673,7 @@ static int qcom_read_status_exec(struct nand_chip *chip,
|
|
|
goto err_out;
|
|
|
}
|
|
|
|
|
|
@@ -789,7 +737,7 @@ Change in [v1]
|
|
|
|
|
|
for (i = 0; i < num_cw; i++) {
|
|
|
flash_status = le32_to_cpu(nandc->reg_read_buf[i]);
|
|
|
-@@ -2763,16 +2717,14 @@ static int qcom_read_id_type_exec(struct
|
|
|
+@@ -2763,16 +2717,14 @@ static int qcom_read_id_type_exec(struct nand_chip *chip, const struct nand_subo
|
|
|
clear_read_regs(nandc);
|
|
|
clear_bam_transaction(nandc);
|
|
|
|
|
|
@@ -798,14 +746,14 @@ Change in [v1]
|
|
|
- nandc_set_reg(chip, NAND_ADDR1, q_op.addr2_reg);
|
|
|
- nandc_set_reg(chip, NAND_FLASH_CHIP_SELECT,
|
|
|
- nandc->props->is_bam ? 0 : DM_EN);
|
|
|
+-
|
|
|
+- nandc_set_reg(chip, NAND_EXEC_CMD, 1);
|
|
|
+ nandc->regs->cmd = q_op.cmd_reg;
|
|
|
+ nandc->regs->addr0 = q_op.addr1_reg;
|
|
|
+ nandc->regs->addr1 = q_op.addr2_reg;
|
|
|
+ nandc->regs->chip_sel = cpu_to_le32(nandc->props->supports_bam ? 0 : DM_EN);
|
|
|
+ nandc->regs->exec = cpu_to_le32(1);
|
|
|
|
|
|
-- nandc_set_reg(chip, NAND_EXEC_CMD, 1);
|
|
|
--
|
|
|
- write_reg_dma(nandc, NAND_FLASH_CMD, 4, NAND_BAM_NEXT_SGL);
|
|
|
- write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL);
|
|
|
+ write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, 4, NAND_BAM_NEXT_SGL);
|
|
|
@@ -813,7 +761,7 @@ Change in [v1]
|
|
|
|
|
|
read_reg_dma(nandc, NAND_READ_ID, 1, NAND_BAM_NEXT_SGL);
|
|
|
|
|
|
-@@ -2786,7 +2738,7 @@ static int qcom_read_id_type_exec(struct
|
|
|
+@@ -2786,7 +2738,7 @@ static int qcom_read_id_type_exec(struct nand_chip *chip, const struct nand_subo
|
|
|
op_id = q_op.data_instr_idx;
|
|
|
len = nand_subop_get_data_len(subop, op_id);
|
|
|
|
|
|
@@ -822,7 +770,7 @@ Change in [v1]
|
|
|
memcpy(instr->ctx.data.buf.in, nandc->reg_read_buf, len);
|
|
|
|
|
|
err_out:
|
|
|
-@@ -2807,15 +2759,14 @@ static int qcom_misc_cmd_type_exec(struc
|
|
|
+@@ -2807,15 +2759,14 @@ static int qcom_misc_cmd_type_exec(struct nand_chip *chip, const struct nand_sub
|
|
|
|
|
|
if (q_op.flag == OP_PROGRAM_PAGE) {
|
|
|
goto wait_rdy;
|
|
|
@@ -845,7 +793,7 @@ Change in [v1]
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-@@ -2826,14 +2777,14 @@ static int qcom_misc_cmd_type_exec(struc
|
|
|
+@@ -2826,14 +2777,14 @@ static int qcom_misc_cmd_type_exec(struct nand_chip *chip, const struct nand_sub
|
|
|
clear_read_regs(nandc);
|
|
|
clear_bam_transaction(nandc);
|
|
|
|
|
|
@@ -866,7 +814,7 @@ Change in [v1]
|
|
|
read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL);
|
|
|
|
|
|
ret = submit_descs(nandc);
|
|
|
-@@ -2864,7 +2815,7 @@ static int qcom_param_page_type_exec(str
|
|
|
+@@ -2864,7 +2815,7 @@ static int qcom_param_page_type_exec(struct nand_chip *chip, const struct nand_
|
|
|
if (ret)
|
|
|
return ret;
|
|
|
|
|
|
@@ -875,28 +823,12 @@ Change in [v1]
|
|
|
|
|
|
nandc->buf_count = 0;
|
|
|
nandc->buf_start = 0;
|
|
|
-@@ -2872,38 +2823,38 @@ static int qcom_param_page_type_exec(str
|
|
|
+@@ -2872,38 +2823,38 @@ static int qcom_param_page_type_exec(struct nand_chip *chip, const struct nand_
|
|
|
clear_read_regs(nandc);
|
|
|
clear_bam_transaction(nandc);
|
|
|
|
|
|
- nandc_set_reg(chip, NAND_FLASH_CMD, q_op.cmd_reg);
|
|
|
-+ nandc->regs->cmd = q_op.cmd_reg;
|
|
|
-+ nandc->regs->addr0 = 0;
|
|
|
-+ nandc->regs->addr1 = 0;
|
|
|
-+
|
|
|
-+ nandc->regs->cfg0 = cpu_to_le32(0 << CW_PER_PAGE
|
|
|
-+ | 512 << UD_SIZE_BYTES
|
|
|
-+ | 5 << NUM_ADDR_CYCLES
|
|
|
-+ | 0 << SPARE_SIZE_BYTES);
|
|
|
-+
|
|
|
-+ nandc->regs->cfg1 = cpu_to_le32(7 << NAND_RECOVERY_CYCLES
|
|
|
-+ | 0 << CS_ACTIVE_BSY
|
|
|
-+ | 17 << BAD_BLOCK_BYTE_NUM
|
|
|
-+ | 1 << BAD_BLOCK_IN_SPARE_AREA
|
|
|
-+ | 2 << WR_RD_BSY_GAP
|
|
|
-+ | 0 << WIDE_FLASH
|
|
|
-+ | 1 << DEV0_CFG1_ECC_DISABLE);
|
|
|
-
|
|
|
+-
|
|
|
- nandc_set_reg(chip, NAND_ADDR0, 0);
|
|
|
- nandc_set_reg(chip, NAND_ADDR1, 0);
|
|
|
- nandc_set_reg(chip, NAND_DEV0_CFG0, 0 << CW_PER_PAGE
|
|
|
@@ -912,6 +844,23 @@ Change in [v1]
|
|
|
- | 1 << DEV0_CFG1_ECC_DISABLE);
|
|
|
- if (!nandc->props->qpic_v2)
|
|
|
- nandc_set_reg(chip, NAND_EBI2_ECC_BUF_CFG, 1 << ECC_CFG_ECC_DISABLE);
|
|
|
++ nandc->regs->cmd = q_op.cmd_reg;
|
|
|
++ nandc->regs->addr0 = 0;
|
|
|
++ nandc->regs->addr1 = 0;
|
|
|
++
|
|
|
++ nandc->regs->cfg0 = cpu_to_le32(0 << CW_PER_PAGE |
|
|
|
++ 512 << UD_SIZE_BYTES |
|
|
|
++ 5 << NUM_ADDR_CYCLES |
|
|
|
++ 0 << SPARE_SIZE_BYTES);
|
|
|
++
|
|
|
++ nandc->regs->cfg1 = cpu_to_le32(7 << NAND_RECOVERY_CYCLES |
|
|
|
++ 0 << CS_ACTIVE_BSY |
|
|
|
++ 17 << BAD_BLOCK_BYTE_NUM |
|
|
|
++ 1 << BAD_BLOCK_IN_SPARE_AREA |
|
|
|
++ 2 << WR_RD_BSY_GAP |
|
|
|
++ 0 << WIDE_FLASH |
|
|
|
++ 1 << DEV0_CFG1_ECC_DISABLE);
|
|
|
++
|
|
|
+ if (!nandc->props->qpic_version2)
|
|
|
+ nandc->regs->ecc_buf_cfg = cpu_to_le32(1 << ECC_CFG_ECC_DISABLE);
|
|
|
|
|
|
@@ -929,19 +878,18 @@ Change in [v1]
|
|
|
}
|
|
|
|
|
|
- nandc_set_reg(chip, NAND_EXEC_CMD, 1);
|
|
|
--
|
|
|
++ nandc->regs->exec = cpu_to_le32(1);
|
|
|
+
|
|
|
- if (!nandc->props->qpic_v2) {
|
|
|
- nandc_set_reg(chip, NAND_DEV_CMD1_RESTORE, nandc->cmd1);
|
|
|
- nandc_set_reg(chip, NAND_DEV_CMD_VLD_RESTORE, nandc->vld);
|
|
|
-+ nandc->regs->exec = cpu_to_le32(1);
|
|
|
-+
|
|
|
+ if (!nandc->props->qpic_version2) {
|
|
|
+ nandc->regs->orig_cmd1 = cpu_to_le32(nandc->cmd1);
|
|
|
+ nandc->regs->orig_vld = cpu_to_le32(nandc->vld);
|
|
|
}
|
|
|
|
|
|
instr = q_op.data_instr;
|
|
|
-@@ -2912,9 +2863,9 @@ static int qcom_param_page_type_exec(str
|
|
|
+@@ -2912,9 +2863,9 @@ static int qcom_param_page_type_exec(struct nand_chip *chip, const struct nand_
|
|
|
|
|
|
nandc_set_read_loc(chip, 0, 0, 0, len, 1);
|
|
|
|
|
|
@@ -954,7 +902,7 @@ Change in [v1]
|
|
|
}
|
|
|
|
|
|
nandc->buf_count = len;
|
|
|
-@@ -2926,9 +2877,10 @@ static int qcom_param_page_type_exec(str
|
|
|
+@@ -2926,9 +2877,10 @@ static int qcom_param_page_type_exec(struct nand_chip *chip, const struct nand_
|
|
|
nandc->buf_count, 0);
|
|
|
|
|
|
/* restore CMD1 and VLD regs */
|
|
|
@@ -968,7 +916,7 @@ Change in [v1]
|
|
|
}
|
|
|
|
|
|
ret = submit_descs(nandc);
|
|
|
-@@ -3017,7 +2969,7 @@ static const struct nand_controller_ops
|
|
|
+@@ -3017,7 +2969,7 @@ static const struct nand_controller_ops qcom_nandc_ops = {
|
|
|
|
|
|
static void qcom_nandc_unalloc(struct qcom_nand_controller *nandc)
|
|
|
{
|
|
|
@@ -977,7 +925,7 @@ Change in [v1]
|
|
|
if (!dma_mapping_error(nandc->dev, nandc->reg_read_dma))
|
|
|
dma_unmap_single(nandc->dev, nandc->reg_read_dma,
|
|
|
MAX_REG_RD *
|
|
|
-@@ -3070,7 +3022,7 @@ static int qcom_nandc_alloc(struct qcom_
|
|
|
+@@ -3070,7 +3022,7 @@ static int qcom_nandc_alloc(struct qcom_nand_controller *nandc)
|
|
|
if (!nandc->reg_read_buf)
|
|
|
return -ENOMEM;
|
|
|
|
|
|
@@ -986,7 +934,7 @@ Change in [v1]
|
|
|
nandc->reg_read_dma =
|
|
|
dma_map_single(nandc->dev, nandc->reg_read_buf,
|
|
|
MAX_REG_RD *
|
|
|
-@@ -3151,15 +3103,15 @@ static int qcom_nandc_setup(struct qcom_
|
|
|
+@@ -3151,15 +3103,15 @@ static int qcom_nandc_setup(struct qcom_nand_controller *nandc)
|
|
|
u32 nand_ctrl;
|
|
|
|
|
|
/* kill onenand */
|
|
|
@@ -1005,7 +953,7 @@ Change in [v1]
|
|
|
nand_ctrl = nandc_read(nandc, NAND_CTRL);
|
|
|
|
|
|
/*
|
|
|
-@@ -3176,7 +3128,7 @@ static int qcom_nandc_setup(struct qcom_
|
|
|
+@@ -3176,7 +3128,7 @@ static int qcom_nandc_setup(struct qcom_nand_controller *nandc)
|
|
|
}
|
|
|
|
|
|
/* save the original values of these registers */
|
|
|
@@ -1014,7 +962,7 @@ Change in [v1]
|
|
|
nandc->cmd1 = nandc_read(nandc, dev_cmd_reg_addr(nandc, NAND_DEV_CMD1));
|
|
|
nandc->vld = NAND_DEV_CMD_VLD_VAL;
|
|
|
}
|
|
|
-@@ -3349,7 +3301,7 @@ static int qcom_nandc_parse_dt(struct pl
|
|
|
+@@ -3349,7 +3301,7 @@ static int qcom_nandc_parse_dt(struct platform_device *pdev)
|
|
|
struct device_node *np = nandc->dev->of_node;
|
|
|
int ret;
|
|
|
|
|
|
@@ -1023,7 +971,7 @@ Change in [v1]
|
|
|
ret = of_property_read_u32(np, "qcom,cmd-crci",
|
|
|
&nandc->cmd_crci);
|
|
|
if (ret) {
|
|
|
-@@ -3474,30 +3426,30 @@ static void qcom_nandc_remove(struct pla
|
|
|
+@@ -3474,30 +3426,30 @@ static void qcom_nandc_remove(struct platform_device *pdev)
|
|
|
|
|
|
static const struct qcom_nandc_props ipq806x_nandc_props = {
|
|
|
.ecc_modes = (ECC_RS_4BIT | ECC_BCH_8BIT),
|
|
|
@@ -1062,3 +1010,6 @@ Change in [v1]
|
|
|
.dev_cmd_reg_start = 0x7000,
|
|
|
};
|
|
|
|
|
|
+--
|
|
|
+2.47.1
|
|
|
+
|