/* Default Value for NAND_DEV_CMD_VLD */ #define NAND_DEV_CMD_VLD_VAL (READ_START_VLD | WRITE_START_VLD | \
ERASE_START_VLD | SEQ_READ_START_VLD)
/* NAND_CTRL bits */ #define BAM_MODE_EN BIT(0)
/* * the NAND controller performs reads/writes with ECC in 516 byte chunks. * the driver calls the chunks 'step' or 'codeword' interchangeably
*/ #define NANDC_STEP_SIZE 512
/* * the largest page size we support is 8K, this will have 16 steps/codewords * of 512 bytes each
*/ #define MAX_NUM_STEPS (SZ_8K / NANDC_STEP_SIZE)
/* we read at most 3 registers per codeword scan */ #define MAX_REG_RD (3 * MAX_NUM_STEPS)
/* ECC modes supported by the controller */ #define ECC_NONE BIT(0) #define ECC_RS_4BIT BIT(1) #define ECC_BCH_4BIT BIT(2) #define ECC_BCH_8BIT BIT(3)
/* * Returns the actual register address for all NAND_DEV_ registers * (i.e. NAND_DEV_CMD0, NAND_DEV_CMD1, NAND_DEV_CMD2 and NAND_DEV_CMD_VLD)
*/ #define dev_cmd_reg_addr(nandc, reg) ((nandc)->props->dev_cmd_reg_start + (reg))
/* * Flags used in DMA descriptor preparation helper functions * (i.e. qcom_read_reg_dma/qcom_write_reg_dma/qcom_read_data_dma/qcom_write_data_dma)
*/ /* Don't set the EOT in current tx BAM sgl */ #define NAND_BAM_NO_EOT BIT(0) /* Set the NWD flag in current BAM sgl */ #define NAND_BAM_NWD BIT(1) /* Finish writing in the current BAM sgl and start writing in another BAM sgl */ #define NAND_BAM_NEXT_SGL BIT(2) /* * Erased codeword status is being used two times in single transfer so this * flag will determine the current value of erased codeword status register
*/ #define NAND_ERASED_CW_SET BIT(4)
#define MAX_ADDRESS_CYCLE 5
/* * This data type corresponds to the BAM transaction which will be used for all * NAND transfers. * @bam_ce - the array of BAM command elements * @cmd_sgl - sgl for NAND BAM command pipe * @data_sgl - sgl for NAND BAM consumer/producer pipe * @last_data_desc - last DMA desc in data channel (tx/rx). * @last_cmd_desc - last DMA desc in command channel. * @txn_done - completion for NAND transfer. * @bam_ce_nitems - the number of elements in the @bam_ce array * @cmd_sgl_nitems - the number of elements in the @cmd_sgl array * @data_sgl_nitems - the number of elements in the @data_sgl array * @bam_ce_pos - the index in bam_ce which is available for next sgl * @bam_ce_start - the index in bam_ce which marks the start position ce * for current sgl. It will be used for size calculation * for current sgl * @cmd_sgl_pos - current index in command sgl. * @cmd_sgl_start - start index in command sgl. * @tx_sgl_pos - current index in data sgl for tx. * @tx_sgl_start - start index in data sgl for tx. * @rx_sgl_pos - current index in data sgl for rx. * @rx_sgl_start - start index in data sgl for rx.
*/ struct bam_transaction { struct bam_cmd_element *bam_ce; struct scatterlist *cmd_sgl; struct scatterlist *data_sgl; struct dma_async_tx_descriptor *last_data_desc; struct dma_async_tx_descriptor *last_cmd_desc; struct completion txn_done;
/* * This data type corresponds to the nand dma descriptor * @dma_desc - low level DMA engine descriptor * @list - list for desc_info * * @adm_sgl - sgl which will be used for single sgl dma descriptor. Only used by * ADM * @bam_sgl - sgl which will be used for dma descriptor. Only used by BAM * @sgl_cnt - number of SGL in bam_sgl. Only used by BAM * @dir - DMA transfer direction
*/ struct desc_info { struct dma_async_tx_descriptor *dma_desc; struct list_head node;
union { struct scatterlist adm_sgl; struct { struct scatterlist *bam_sgl; int sgl_cnt;
};
}; enum dma_data_direction dir;
};
/* * holds the current register values that we want to write. acts as a contiguous * chunk of memory which we use to write the controller registers through DMA.
*/ struct nandc_regs {
__le32 cmd;
__le32 addr0;
__le32 addr1;
__le32 chip_sel;
__le32 exec;
/* * NAND controller data struct * * @dev: parent device * * @base: MMIO base * * @core_clk: controller clock * @aon_clk: another controller clock * @iomacro_clk: io macro clock * * @regs: a contiguous chunk of memory for DMA register * writes. contains the register values to be * written to controller * * @props: properties of current NAND controller, * initialized via DT match data * * @controller: base controller structure * @qspi: qpic spi structure * @host_list: list containing all the chips attached to the * controller * * @chan: dma channel * @cmd_crci: ADM DMA CRCI for command flow control * @data_crci: ADM DMA CRCI for data flow control * * @desc_list: DMA descriptor list (list of desc_infos) * * @data_buffer: our local DMA buffer for page read/writes, * used when we can't use the buffer provided * by upper layers directly * @reg_read_buf: local buffer for reading back registers via DMA * * @base_phys: physical base address of controller registers * @base_dma: dma base address of controller registers * @reg_read_dma: contains dma address for register read buffer * * @buf_size/count/start: markers for chip->legacy.read_buf/write_buf * functions * @max_cwperpage: maximum QPIC codewords required. calculated * from all connected NAND devices pagesize * * @reg_read_pos: marker for data read in reg_read_buf * * @cmd1/vld: some fixed controller register values * * @exec_opwrite: flag to select correct number of code word * while reading status
*/ struct qcom_nand_controller { struct device *dev;
int buf_size; int buf_count; int buf_start; unsignedint max_cwperpage;
int reg_read_pos;
u32 cmd1, vld; bool exec_opwrite;
};
/* * This data type corresponds to the NAND controller properties which varies * among different NAND controllers. * @ecc_modes - ecc mode for NAND * @dev_cmd_reg_start - NAND_DEV_CMD_* registers starting offset * @supports_bam - whether NAND controller is using 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
*/ struct qcom_nandc_props {
u32 ecc_modes;
u32 dev_cmd_reg_start;
u32 bam_offset; bool supports_bam; bool nandc_part_of_qpic; bool qpic_version2; bool use_codeword_fixup;
};
void qcom_free_bam_transaction(struct qcom_nand_controller *nandc); struct bam_transaction *qcom_alloc_bam_transaction(struct qcom_nand_controller *nandc); void qcom_clear_bam_transaction(struct qcom_nand_controller *nandc); void qcom_qpic_bam_dma_done(void *data); void qcom_nandc_dev_to_mem(struct qcom_nand_controller *nandc, bool is_cpu); int qcom_prepare_bam_async_desc(struct qcom_nand_controller *nandc, struct dma_chan *chan, unsignedlong flags); int qcom_prep_bam_dma_desc_cmd(struct qcom_nand_controller *nandc, bool read, int reg_off, constvoid *vaddr, int size, unsignedint flags); int qcom_prep_bam_dma_desc_data(struct qcom_nand_controller *nandc, bool read, constvoid *vaddr, int size, unsignedint flags); int qcom_prep_adm_dma_desc(struct qcom_nand_controller *nandc, bool read, int reg_off, constvoid *vaddr, int size, bool flow_control); int qcom_read_reg_dma(struct qcom_nand_controller *nandc, int first, int num_regs, unsignedint flags); int qcom_write_reg_dma(struct qcom_nand_controller *nandc, __le32 *vaddr, int first, int num_regs, unsignedint flags); int qcom_read_data_dma(struct qcom_nand_controller *nandc, int reg_off, const u8 *vaddr, int size, unsignedint flags); int qcom_write_data_dma(struct qcom_nand_controller *nandc, int reg_off, const u8 *vaddr, int size, unsignedint flags); int qcom_submit_descs(struct qcom_nand_controller *nandc); void qcom_clear_read_regs(struct qcom_nand_controller *nandc); void qcom_nandc_unalloc(struct qcom_nand_controller *nandc); int qcom_nandc_alloc(struct qcom_nand_controller *nandc); #endif
Messung V0.5
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.