[flash] Teach mx25l SPI flash driver to interact with fdt_slicer and geom_flashmap

This teaches the mx25l driver (sys/dev/flash/mx25l.c) to interact with
sys/dev/fdt/fdt_slicer.c and sys/geom/geom_flashmap.c.

This allows systems with SPI flash to benefit from the possibility to define
flash 'slices' via FDT, just the same way that it's currently possible for
CFI and NAND flashes.

Tested:

* Carambola 2, AR9331 + SPI NOR flash

PR:		kern/206227
Submitted by:	Stanislav Galabov <sgalabov@gmail.com>
This commit is contained in:
adrian 2016-01-22 03:15:53 +00:00
parent 010e5362b8
commit 078702fc47

View File

@ -93,6 +93,7 @@ static int mx25l_open(struct disk *dp);
static int mx25l_close(struct disk *dp);
static int mx25l_ioctl(struct disk *, u_long, void *, int, struct thread *);
static void mx25l_strategy(struct bio *bp);
static int mx25l_getattr(struct bio *bp);
static void mx25l_task(void *arg);
struct mx25l_flash_ident flash_devices[] = {
@ -383,6 +384,7 @@ mx25l_attach(device_t dev)
sc->sc_disk->d_open = mx25l_open;
sc->sc_disk->d_close = mx25l_close;
sc->sc_disk->d_strategy = mx25l_strategy;
sc->sc_disk->d_getattr = mx25l_getattr;
sc->sc_disk->d_ioctl = mx25l_ioctl;
sc->sc_disk->d_name = "flash/spi";
sc->sc_disk->d_drv1 = sc;
@ -448,6 +450,27 @@ mx25l_strategy(struct bio *bp)
M25PXX_UNLOCK(sc);
}
static int
mx25l_getattr(struct bio *bp)
{
struct mx25l_softc *sc;
device_t dev;
if (bp->bio_disk == NULL || bp->bio_disk->d_drv1 == NULL)
return (ENXIO);
sc = bp->bio_disk->d_drv1;
dev = sc->sc_dev;
if (strcmp(bp->bio_attribute, "SPI::device") == 0) {
if (bp->bio_length != sizeof(dev))
return (EFAULT);
bcopy(&dev, bp->bio_data, sizeof(dev));
} else
return (-1);
return (0);
}
static void
mx25l_task(void *arg)
{