Add support Microchip SST25VF016B.
- Fixed imxspi send and receive bugs.
This commit is contained in:
parent
11af610cd2
commit
5a40d81280
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: imxspi.c,v 1.2 2014/03/29 12:00:27 hkenken Exp $ */
|
||||
/* $NetBSD: imxspi.c,v 1.3 2017/08/07 09:24:43 hkenken Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2014 Genetec Corporation. All rights reserved.
|
||||
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: imxspi.c,v 1.2 2014/03/29 12:00:27 hkenken Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: imxspi.c,v 1.3 2017/08/07 09:24:43 hkenken Exp $");
|
||||
|
||||
#include "opt_imx.h"
|
||||
#include "opt_imxspi.h"
|
||||
@ -256,7 +256,7 @@ imxspi_send(struct imxspi_softc *sc)
|
||||
while (chunk->chunk_wresid) {
|
||||
/* transmit fifo full? */
|
||||
if (READ_REG(sc, STATREG) & IMXSPI(STAT_TF))
|
||||
return;
|
||||
goto out;
|
||||
|
||||
if (chunk->chunk_wptr) {
|
||||
data = *chunk->chunk_wptr;
|
||||
@ -271,7 +271,7 @@ imxspi_send(struct imxspi_softc *sc)
|
||||
/* advance to next transfer */
|
||||
sc->sc_wchunk = sc->sc_wchunk->chunk_next;
|
||||
}
|
||||
|
||||
out:
|
||||
if (!(READ_REG(sc, STATREG) & IMXSPI(INTR_TE_EN)))
|
||||
WRITE_REG(sc, CONREG, READ_REG(sc, CONREG) | IMXSPI(CON_XCH));
|
||||
}
|
||||
@ -321,7 +321,7 @@ imxspi_sched(struct imxspi_softc *sc)
|
||||
sc->sc_tag->spi_cs_enable(sc->sc_tag->cookie,
|
||||
st->st_slave);
|
||||
|
||||
/*chip slect*/
|
||||
/* chip slect */
|
||||
chipselect = READ_REG(sc, CONREG);
|
||||
chipselect &= ~IMXSPI(CON_CS);
|
||||
chipselect |= __SHIFTIN(st->st_slave, IMXSPI(CON_CS));
|
||||
@ -382,19 +382,19 @@ imxspi_intr(void *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Transfer Conplete? */
|
||||
if (sr & IMXSPI(INTR_TC_EN)) {
|
||||
/* complete TX */
|
||||
imxspi_send(sc);
|
||||
}
|
||||
|
||||
/* RXFIFO ready */
|
||||
/* RXFIFO ready? */
|
||||
if (sr & IMXSPI(INTR_RR_EN)) {
|
||||
imxspi_recv(sc);
|
||||
if (sc->sc_wchunk == NULL && sc->sc_rchunk == NULL)
|
||||
imxspi_done(sc, err);
|
||||
}
|
||||
|
||||
/* Transfer Conplete? */
|
||||
if (sr & IMXSPI(INTR_TC_EN)) {
|
||||
/* complete TX */
|
||||
imxspi_send(sc);
|
||||
}
|
||||
|
||||
/* status register clear */
|
||||
WRITE_REG(sc, STATREG, sr);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: NETWALKER,v 1.35 2015/12/21 04:26:29 hkenken Exp $
|
||||
# $NetBSD: NETWALKER,v 1.36 2017/08/07 09:24:43 hkenken Exp $
|
||||
#
|
||||
# NETWALKER -- http://www.sharp.co.jp/netwalker/
|
||||
#
|
||||
@ -113,8 +113,8 @@ lidsw0 at gpio3 offset 12 mask 0x01 # intr 236
|
||||
imxpwm0 at axi? addr 0x73FB4000 irq 61
|
||||
|
||||
# SPI NOR-Flash
|
||||
#spiflash0 at spiflashbus?
|
||||
#m25p0 at spi0 slave 1
|
||||
spiflash0 at spiflashbus?
|
||||
m25p0 at spi0 slave 1
|
||||
|
||||
# SD/MMC
|
||||
sdhc0 at axi? addr 0x70004000 irq 1 # eSDHC1
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: m25p.c,v 1.4 2013/10/26 15:18:21 rkujawa Exp $ */
|
||||
/* $NetBSD: m25p.c,v 1.5 2017/08/07 09:24:43 hkenken Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 Urbana-Champaign Independent Media Center.
|
||||
@ -42,7 +42,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.4 2013/10/26 15:18:21 rkujawa Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.5 2017/08/07 09:24:43 hkenken Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -60,6 +60,7 @@ __KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.4 2013/10/26 15:18:21 rkujawa Exp $");
|
||||
|
||||
static int m25p_match(device_t , cfdata_t , void *);
|
||||
static void m25p_attach(device_t , device_t , void *);
|
||||
static void m25p_doattach(device_t);
|
||||
static const char *m25p_getname(void *);
|
||||
static struct spi_handle *m25p_gethandle(void *);
|
||||
static int m25p_getflags(void *);
|
||||
@ -95,7 +96,8 @@ static const struct m25p_info {
|
||||
{ 0x14, 0x20, 0x2015, "STMicro M25P16", 2048, 64 }, /* 16Mbit */
|
||||
{ 0x12, 0x20, 0x2013, "STMicro M25P40", 512, 64 }, /* 4Mbit */
|
||||
{ 0xc0, 0x20, 0x7117, "STMicro M25PX64", 8192, 64 }, /* 64Mbit */
|
||||
{ 0x0, 0x20, 0xBB18, "Numonyx N25Q128", 16384, 64 }, /* 128Mbit */
|
||||
{ 0x00, 0x20, 0xBB18, "Numonyx N25Q128", 16384, 64 }, /* 128Mbit */
|
||||
{ 0x00, 0xBF, 0x2541, "Microchip SST25VF016B", 2048, 64 }, /* 16Mbit */
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
@ -116,20 +118,27 @@ m25p_attach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
struct m25p_softc *sc = device_private(self);
|
||||
struct spi_attach_args *sa = aux;
|
||||
|
||||
sc->sc_sh = sa->sa_handle;
|
||||
|
||||
config_interrupts(self, m25p_doattach);
|
||||
}
|
||||
|
||||
static void
|
||||
m25p_doattach(device_t self)
|
||||
{
|
||||
struct m25p_softc *sc = device_private(self);
|
||||
const struct m25p_info *info;
|
||||
uint8_t buf[4];
|
||||
uint8_t buf[4];
|
||||
uint8_t cmd;
|
||||
uint8_t mfgid;
|
||||
uint8_t sig;
|
||||
uint16_t devid;
|
||||
|
||||
sc->sc_sh = sa->sa_handle;
|
||||
|
||||
/* first we try JEDEC ID read */
|
||||
|
||||
cmd = SPIFLASH_CMD_RDJI;
|
||||
if (spi_send_recv(sa->sa_handle, 1, &cmd, 3, buf)) {
|
||||
aprint_error(": failed to get JEDEC identification\n");
|
||||
if (spi_send_recv(sc->sc_sh, 1, &cmd, 3, buf)) {
|
||||
aprint_error(": failed to get JEDEC identification\n");
|
||||
return;
|
||||
}
|
||||
mfgid = buf[0];
|
||||
@ -137,7 +146,7 @@ m25p_attach(device_t parent, device_t self, void *aux)
|
||||
|
||||
if ((mfgid == 0xff) || (mfgid == 0)) {
|
||||
cmd = SPIFLASH_CMD_RDID;
|
||||
if (spi_send_recv(sa->sa_handle, 1, &cmd, 4, buf)) {
|
||||
if (spi_send_recv(sc->sc_sh, 1, &cmd, 4, buf)) {
|
||||
aprint_error(": failed to get legacy signature\n");
|
||||
return;
|
||||
}
|
||||
@ -150,7 +159,7 @@ m25p_attach(device_t parent, device_t self, void *aux)
|
||||
for (info = m25p_infos; info->name; info++) {
|
||||
if ((info->mfgid == mfgid) && (info->devid == devid))
|
||||
break;
|
||||
if (sig == info->sig)
|
||||
if ((sig != 0) && (sig == info->sig))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -160,7 +169,6 @@ m25p_attach(device_t parent, device_t self, void *aux)
|
||||
}
|
||||
|
||||
sc->sc_name = info->name;
|
||||
sc->sc_sh = sa->sa_handle;
|
||||
sc->sc_sizes[SPIFLASH_SIZE_DEVICE] = info->size * 1024;
|
||||
sc->sc_sizes[SPIFLASH_SIZE_ERASE] = info->sector * 1024;
|
||||
sc->sc_sizes[SPIFLASH_SIZE_WRITE] = 256;
|
||||
@ -168,6 +176,8 @@ m25p_attach(device_t parent, device_t self, void *aux)
|
||||
|
||||
sc->sc_flags = SPIFLASH_FLAG_FAST_READ;
|
||||
|
||||
aprint_normal_dev(self, "JEDEC ID mfgid:0x%02X, devid:0x%04X",
|
||||
mfgid, devid);
|
||||
aprint_normal("\n");
|
||||
|
||||
spiflash_attach_mi(&m25p_hw_if, sc, self);
|
||||
|
Loading…
Reference in New Issue
Block a user