Exemple #1
0
static void nxp_spifi_write(struct spi_nor *nor, loff_t to, size_t len,
                            size_t *retlen, const u_char *buf)
{
    struct nxp_spifi *spifi = nor->priv;
    u32 cmd;
    int ret;

    ret = nxp_spifi_set_memory_mode_off(spifi);
    if (ret)
        return;

    writel(to, spifi->io_base + SPIFI_ADDR);
    *retlen += len;

    cmd = SPIFI_CMD_DOUT |
          SPIFI_CMD_DATALEN(len) |
          SPIFI_CMD_FIELDFORM_ALL_SERIAL |
          SPIFI_CMD_OPCODE(nor->program_opcode) |
          SPIFI_CMD_FRAMEFORM(spifi->nor.addr_width + 1);
    writel(cmd, spifi->io_base + SPIFI_CMD);

    while (len--)
        writeb(*buf++, spifi->io_base + SPIFI_DATA);

    nxp_spifi_wait_for_cmd(spifi);
}
Exemple #2
0
void SPIFI_SetCommand(SPIFI_Type *base, spifi_command_t *cmd)
{
    /* Wait for the CMD and MCINT flag all be 0 */
    while (SPIFI_GetStatusFlag(base) & (SPIFI_STAT_MCINIT_MASK | SPIFI_STAT_CMD_MASK))
    {
    }
    base->CMD = SPIFI_CMD_DATALEN(cmd->dataLen) | SPIFI_CMD_POLL(cmd->isPollMode) | SPIFI_CMD_DOUT(cmd->direction) |
                SPIFI_CMD_INTLEN(cmd->intermediateBytes) | SPIFI_CMD_FIELDFORM(cmd->format) |
                SPIFI_CMD_FRAMEFORM(cmd->type) | SPIFI_CMD_OPCODE(cmd->opcode);

    /* Wait for the command written */
    while ((base->STAT & SPIFI_STAT_CMD_MASK) == 0U)
    {
    }
}
Exemple #3
0
static int nxp_spifi_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len)
{
    struct nxp_spifi *spifi = nor->priv;
    u32 cmd;
    int ret;

    ret = nxp_spifi_set_memory_mode_off(spifi);
    if (ret)
        return ret;

    cmd = SPIFI_CMD_DATALEN(len) |
          SPIFI_CMD_OPCODE(opcode) |
          SPIFI_CMD_FIELDFORM_ALL_SERIAL |
          SPIFI_CMD_FRAMEFORM_OPCODE_ONLY;
    writel(cmd, spifi->io_base + SPIFI_CMD);

    while (len--)
        *buf++ = readb(spifi->io_base + SPIFI_DATA);

    return nxp_spifi_wait_for_cmd(spifi);
}