Module Name: src Committed By: uebayasi Date: Sun Feb 28 04:36:27 UTC 2010
Modified Files: src/sys/dev [uebayasi-xip]: flash.c Log Message: Implement mmap() entry using bus_space_mmap(9). Put a common init code. To generate a diff of this commit: cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/dev/flash.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/flash.c diff -u src/sys/dev/flash.c:1.1.2.2 src/sys/dev/flash.c:1.1.2.3 --- src/sys/dev/flash.c:1.1.2.2 Wed Feb 24 01:19:37 2010 +++ src/sys/dev/flash.c Sun Feb 28 04:36:27 2010 @@ -1,4 +1,4 @@ -/* $Id: flash.c,v 1.1.2.2 2010/02/24 01:19:37 uebayasi Exp $ */ +/* $Id: flash.c,v 1.1.2.3 2010/02/28 04:36:27 uebayasi Exp $ */ /*- * Copyright (c) 2010 Tsubai Masanari. All rights reserved. @@ -122,6 +122,21 @@ return error; } +paddr_t +flash_mmap(dev_t dev, off_t off, int prot) +{ + struct flash_softc *sc = device_lookup_private(&flash_cd, minor(dev)); + + if (sc == NULL) + return -1; + + if ((u_int64_t)off >= sc->sc_size) + return -1; + + return bus_space_mmap(sc->sc_iot, sc->sc_addr, off, prot, + BUS_SPACE_MAP_LINEAR); +} + int flash_map(struct flash_softc *sc, u_long addr) { @@ -194,3 +209,33 @@ return sc->sc_size >> DEV_BSHIFT; } + +void +flash_init(struct flash_softc *sc) +{ + +#ifdef notyet + if (bus_space_map(sc->sc_iot, sc->sc_addr, 0x1000, 0, &sc->sc_baseioh)) { + printf(": failed to map registers\n"); + return; + } + + if (intelflash_probe(sc) == 0) + goto found; + if (amdflash_probe(sc) == 0) + goto found; + printf(": unknown chip\n"); + return; + +found: + + sc->sc_program = amdflash_program_word; + sc->sc_eraseblk = amdflash_erase_block; + sc->sc_size = sc->sc_product->size; + printf(": %s (%dKB, %d bit/word)\n", sc->sc_product->name, + sc->sc_size / 1024, sc->sc_wordsize * 8); +#endif + + disk_init(&sc->sc_dkdev, device_xname(&sc->sc_dev), NULL); + disk_attach(&sc->sc_dkdev); +}