@@ -238,6 +238,9 @@ nandc_set_reg(chip, reg, \
238
238
* @bam_ce - the array of BAM command elements
239
239
* @cmd_sgl - sgl for NAND BAM command pipe
240
240
* @data_sgl - sgl for NAND BAM consumer/producer pipe
241
+ * @last_data_desc - last DMA desc in data channel (tx/rx).
242
+ * @last_cmd_desc - last DMA desc in command channel.
243
+ * @txn_done - completion for NAND transfer.
241
244
* @bam_ce_pos - the index in bam_ce which is available for next sgl
242
245
* @bam_ce_start - the index in bam_ce which marks the start position ce
243
246
* for current sgl. It will be used for size calculation
@@ -250,14 +253,14 @@ nandc_set_reg(chip, reg, \
250
253
* @rx_sgl_start - start index in data sgl for rx.
251
254
* @wait_second_completion - wait for second DMA desc completion before making
252
255
* the NAND transfer completion.
253
- * @txn_done - completion for NAND transfer.
254
- * @last_data_desc - last DMA desc in data channel (tx/rx).
255
- * @last_cmd_desc - last DMA desc in command channel.
256
256
*/
257
257
struct bam_transaction {
258
258
struct bam_cmd_element * bam_ce ;
259
259
struct scatterlist * cmd_sgl ;
260
260
struct scatterlist * data_sgl ;
261
+ struct dma_async_tx_descriptor * last_data_desc ;
262
+ struct dma_async_tx_descriptor * last_cmd_desc ;
263
+ struct completion txn_done ;
261
264
u32 bam_ce_pos ;
262
265
u32 bam_ce_start ;
263
266
u32 cmd_sgl_pos ;
@@ -267,33 +270,31 @@ struct bam_transaction {
267
270
u32 rx_sgl_pos ;
268
271
u32 rx_sgl_start ;
269
272
bool wait_second_completion ;
270
- struct completion txn_done ;
271
- struct dma_async_tx_descriptor * last_data_desc ;
272
- struct dma_async_tx_descriptor * last_cmd_desc ;
273
273
};
274
274
275
275
/*
276
276
* This data type corresponds to the nand dma descriptor
277
+ * @dma_desc - low level DMA engine descriptor
277
278
* @list - list for desc_info
278
- * @dir - DMA transfer direction
279
+ *
279
280
* @adm_sgl - sgl which will be used for single sgl dma descriptor. Only used by
280
281
* ADM
281
282
* @bam_sgl - sgl which will be used for dma descriptor. Only used by BAM
282
283
* @sgl_cnt - number of SGL in bam_sgl. Only used by BAM
283
- * @dma_desc - low level DMA engine descriptor
284
+ * @dir - DMA transfer direction
284
285
*/
285
286
struct desc_info {
287
+ struct dma_async_tx_descriptor * dma_desc ;
286
288
struct list_head node ;
287
289
288
- enum dma_data_direction dir ;
289
290
union {
290
291
struct scatterlist adm_sgl ;
291
292
struct {
292
293
struct scatterlist * bam_sgl ;
293
294
int sgl_cnt ;
294
295
};
295
296
};
296
- struct dma_async_tx_descriptor * dma_desc ;
297
+ enum dma_data_direction dir ;
297
298
};
298
299
299
300
/*
@@ -337,52 +338,64 @@ struct nandc_regs {
337
338
/*
338
339
* NAND controller data struct
339
340
*
340
- * @controller: base controller structure
341
- * @host_list: list containing all the chips attached to the
342
- * controller
343
341
* @dev: parent device
342
+ *
344
343
* @base: MMIO base
345
- * @base_phys: physical base address of controller registers
346
- * @base_dma: dma base address of controller registers
344
+ *
347
345
* @core_clk: controller clock
348
346
* @aon_clk: another controller clock
349
347
*
348
+ * @regs: a contiguous chunk of memory for DMA register
349
+ * writes. contains the register values to be
350
+ * written to controller
351
+ *
352
+ * @props: properties of current NAND controller,
353
+ * initialized via DT match data
354
+ *
355
+ * @controller: base controller structure
356
+ * @host_list: list containing all the chips attached to the
357
+ * controller
358
+ *
350
359
* @chan: dma channel
351
360
* @cmd_crci: ADM DMA CRCI for command flow control
352
361
* @data_crci: ADM DMA CRCI for data flow control
362
+ *
353
363
* @desc_list: DMA descriptor list (list of desc_infos)
354
364
*
355
365
* @data_buffer: our local DMA buffer for page read/writes,
356
366
* used when we can't use the buffer provided
357
367
* by upper layers directly
358
- * @buf_size/count/start: markers for chip->legacy.read_buf/write_buf
359
- * functions
360
368
* @reg_read_buf: local buffer for reading back registers via DMA
369
+ *
370
+ * @base_phys: physical base address of controller registers
371
+ * @base_dma: dma base address of controller registers
361
372
* @reg_read_dma: contains dma address for register read buffer
362
- * @reg_read_pos: marker for data read in reg_read_buf
363
373
*
364
- * @regs: a contiguous chunk of memory for DMA register
365
- * writes. contains the register values to be
366
- * written to controller
367
- * @cmd1/vld: some fixed controller register values
368
- * @props: properties of current NAND controller,
369
- * initialized via DT match data
374
+ * @buf_size/count/start: markers for chip->legacy.read_buf/write_buf
375
+ * functions
370
376
* @max_cwperpage: maximum QPIC codewords required. calculated
371
377
* from all connected NAND devices pagesize
378
+ *
379
+ * @reg_read_pos: marker for data read in reg_read_buf
380
+ *
381
+ * @cmd1/vld: some fixed controller register values
372
382
*/
373
383
struct qcom_nand_controller {
374
- struct nand_controller controller ;
375
- struct list_head host_list ;
376
-
377
384
struct device * dev ;
378
385
379
386
void __iomem * base ;
380
- phys_addr_t base_phys ;
381
- dma_addr_t base_dma ;
382
387
383
388
struct clk * core_clk ;
384
389
struct clk * aon_clk ;
385
390
391
+ struct nandc_regs * regs ;
392
+ struct bam_transaction * bam_txn ;
393
+
394
+ const struct qcom_nandc_props * props ;
395
+
396
+ struct nand_controller controller ;
397
+ struct list_head host_list ;
398
+
386
399
union {
387
400
/* will be used only by QPIC for BAM DMA */
388
401
struct {
@@ -400,22 +413,22 @@ struct qcom_nand_controller {
400
413
};
401
414
402
415
struct list_head desc_list ;
403
- struct bam_transaction * bam_txn ;
404
416
405
417
u8 * data_buffer ;
418
+ __le32 * reg_read_buf ;
419
+
420
+ phys_addr_t base_phys ;
421
+ dma_addr_t base_dma ;
422
+ dma_addr_t reg_read_dma ;
423
+
406
424
int buf_size ;
407
425
int buf_count ;
408
426
int buf_start ;
409
427
unsigned int max_cwperpage ;
410
428
411
- __le32 * reg_read_buf ;
412
- dma_addr_t reg_read_dma ;
413
429
int reg_read_pos ;
414
430
415
- struct nandc_regs * regs ;
416
-
417
431
u32 cmd1 , vld ;
418
- const struct qcom_nandc_props * props ;
419
432
};
420
433
421
434
/*
@@ -431,19 +444,21 @@ struct qcom_nand_controller {
431
444
* and reserved bytes
432
445
* @cw_data: the number of bytes within a codeword protected
433
446
* by ECC
434
- * @use_ecc: request the controller to use ECC for the
435
- * upcoming read/write
436
- * @bch_enabled: flag to tell whether BCH ECC mode is used
437
447
* @ecc_bytes_hw: ECC bytes used by controller hardware for this
438
448
* chip
439
- * @status: value to be returned if NAND_CMD_STATUS command
440
- * is executed
449
+ *
441
450
* @last_command: keeps track of last command on this chip. used
442
451
* for reading correct status
443
452
*
444
453
* @cfg0, cfg1, cfg0_raw..: NANDc register configurations needed for
445
454
* ecc/non-ecc mode for the current nand flash
446
455
* device
456
+ *
457
+ * @status: value to be returned if NAND_CMD_STATUS command
458
+ * is executed
459
+ * @use_ecc: request the controller to use ECC for the
460
+ * upcoming read/write
461
+ * @bch_enabled: flag to tell whether BCH ECC mode is used
447
462
*/
448
463
struct qcom_nand_host {
449
464
struct nand_chip chip ;
@@ -452,12 +467,10 @@ struct qcom_nand_host {
452
467
int cs ;
453
468
int cw_size ;
454
469
int cw_data ;
455
- bool use_ecc ;
456
- bool bch_enabled ;
457
470
int ecc_bytes_hw ;
458
471
int spare_bytes ;
459
472
int bbm_size ;
460
- u8 status ;
473
+
461
474
int last_command ;
462
475
463
476
u32 cfg0 , cfg1 ;
@@ -466,23 +479,27 @@ struct qcom_nand_host {
466
479
u32 ecc_bch_cfg ;
467
480
u32 clrflashstatus ;
468
481
u32 clrreadstatus ;
482
+
483
+ u8 status ;
484
+ bool use_ecc ;
485
+ bool bch_enabled ;
469
486
};
470
487
471
488
/*
472
489
* This data type corresponds to the NAND controller properties which varies
473
490
* among different NAND controllers.
474
491
* @ecc_modes - ecc mode for NAND
492
+ * @dev_cmd_reg_start - NAND_DEV_CMD_* registers starting offset
475
493
* @is_bam - whether NAND controller is using BAM
476
494
* @is_qpic - whether NAND CTRL is part of qpic IP
477
495
* @qpic_v2 - flag to indicate QPIC IP version 2
478
- * @dev_cmd_reg_start - NAND_DEV_CMD_* registers starting offset
479
496
*/
480
497
struct qcom_nandc_props {
481
498
u32 ecc_modes ;
499
+ u32 dev_cmd_reg_start ;
482
500
bool is_bam ;
483
501
bool is_qpic ;
484
502
bool qpic_v2 ;
485
- u32 dev_cmd_reg_start ;
486
503
};
487
504
488
505
/* Frees the BAM transaction memory */
0 commit comments