static int crypto_bam_init(struct crypto_dev *dev) { uint32_t bam_ret; /* BAM Init. */ bam_init(&dev->bam); /* Initialize BAM CRYPTO read pipe */ bam_sys_pipe_init(&dev->bam, CRYPTO_READ_PIPE_INDEX); /* Init read fifo */ bam_ret = bam_pipe_fifo_init(&dev->bam, CRYPTO_READ_PIPE_INDEX); if (bam_ret) { dprintf(CRITICAL, "CRYPTO: BAM Read FIFO init error\n"); bam_ret = CRYPTO_ERR_FAIL; goto crypto_bam_init_err; } /* Initialize BAM CRYPTO write pipe */ bam_sys_pipe_init(&dev->bam, CRYPTO_WRITE_PIPE_INDEX); /* Init write fifo. Use the same fifo as read fifo. */ bam_ret = bam_pipe_fifo_init(&dev->bam, CRYPTO_WRITE_PIPE_INDEX); if (bam_ret) { dprintf(CRITICAL, "CRYPTO: BAM Write FIFO init error\n"); bam_ret = CRYPTO_ERR_FAIL; goto crypto_bam_init_err; } bam_ret = CRYPTO_ERR_NONE; crypto_bam_init_err: return bam_ret; }
static int qpic_bam_init(struct qpic_nand_init_config *config) { uint32_t bam_ret = NANDC_RESULT_SUCCESS; bam.base = config->bam_base; /* Set Read pipe params. */ bam.pipe[DATA_PRODUCER_PIPE_INDEX].pipe_num = config->pipes.read_pipe; /* System consumer */ bam.pipe[DATA_PRODUCER_PIPE_INDEX].trans_type = BAM2SYS; bam.pipe[DATA_PRODUCER_PIPE_INDEX].fifo.size = QPIC_BAM_DATA_FIFO_SIZE; bam.pipe[DATA_PRODUCER_PIPE_INDEX].fifo.head = data_desc_fifo; bam.pipe[DATA_PRODUCER_PIPE_INDEX].lock_grp = config->pipes.read_pipe_grp; /* Set Write pipe params. */ bam.pipe[DATA_CONSUMER_PIPE_INDEX].pipe_num = config->pipes.write_pipe; /* System producer */ bam.pipe[DATA_CONSUMER_PIPE_INDEX].trans_type = SYS2BAM; bam.pipe[DATA_CONSUMER_PIPE_INDEX].fifo.size = QPIC_BAM_DATA_FIFO_SIZE; bam.pipe[DATA_CONSUMER_PIPE_INDEX].fifo.head = data_desc_fifo; bam.pipe[DATA_CONSUMER_PIPE_INDEX].lock_grp = config->pipes.write_pipe_grp; /* Set Cmd pipe params. */ bam.pipe[CMD_PIPE_INDEX].pipe_num = config->pipes.cmd_pipe; /* System consumer */ bam.pipe[CMD_PIPE_INDEX].trans_type = SYS2BAM; bam.pipe[CMD_PIPE_INDEX].fifo.size = QPIC_BAM_CMD_FIFO_SIZE; bam.pipe[CMD_PIPE_INDEX].fifo.head = cmd_desc_fifo; bam.pipe[CMD_PIPE_INDEX].lock_grp = config->pipes.cmd_pipe_grp; /* Programs the threshold for BAM transfer * When this threshold is reached, BAM signals the peripheral via the pipe_bytes_available * interface. * The peripheral is signalled with this notification in the following cases: * a. It has accumulated all the descriptors. * b. It has accumulated more than threshold bytes. * c. It has reached EOT (End Of Transfer). * Note: this value needs to be set by the h/w folks and is specific for each peripheral. */ bam.threshold = 32; /* Set the EE. */ bam.ee = config->ee; /* Set the max desc length for this BAM. */ bam.max_desc_len = config->max_desc_len; /* BAM Init. */ bam_init(&bam); /* Initialize BAM QPIC read pipe */ bam_sys_pipe_init(&bam, DATA_PRODUCER_PIPE_INDEX); /* Init read fifo */ bam_ret = bam_pipe_fifo_init(&bam, bam.pipe[DATA_PRODUCER_PIPE_INDEX].pipe_num); if (bam_ret) { dprintf(CRITICAL, "QPIC:NANDc BAM Read FIFO init error\n"); bam_ret = NANDC_RESULT_FAILURE; goto qpic_nand_bam_init_error; } /* Initialize BAM QPIC write pipe */ bam_sys_pipe_init(&bam, DATA_CONSUMER_PIPE_INDEX); /* Init write fifo. Use the same fifo as read fifo. */ bam_ret = bam_pipe_fifo_init(&bam, bam.pipe[DATA_CONSUMER_PIPE_INDEX].pipe_num); if (bam_ret) { dprintf(CRITICAL, "QPIC: NANDc: BAM Write FIFO init error\n"); bam_ret = NANDC_RESULT_FAILURE; goto qpic_nand_bam_init_error; } /* Initialize BAM QPIC cmd pipe */ bam_sys_pipe_init(&bam, CMD_PIPE_INDEX); /* Init cmd fifo */ bam_ret = bam_pipe_fifo_init(&bam, bam.pipe[CMD_PIPE_INDEX].pipe_num); if (bam_ret) { dprintf(CRITICAL, "QPIC:NANDc BAM CMD FIFO init error\n"); bam_ret = NANDC_RESULT_FAILURE; goto qpic_nand_bam_init_error; } qpic_nand_bam_init_error: return bam_ret; }