socsvn commit: r271979 - in soc2014/astarasikov/head/sys/arm: conf goldfish
astarasikov at FreeBSD.org
astarasikov at FreeBSD.org
Wed Aug 6 01:39:26 UTC 2014
Author: astarasikov
Date: Wed Aug 6 01:39:24 2014
New Revision: 271979
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271979
Log:
[goldfish]: config update, mmc/nand stubs
Modified:
soc2014/astarasikov/head/sys/arm/conf/GOLDFISH
soc2014/astarasikov/head/sys/arm/goldfish/files.goldfish
soc2014/astarasikov/head/sys/arm/goldfish/goldfish_mmc.c
soc2014/astarasikov/head/sys/arm/goldfish/goldfish_nand.c
Modified: soc2014/astarasikov/head/sys/arm/conf/GOLDFISH
==============================================================================
--- soc2014/astarasikov/head/sys/arm/conf/GOLDFISH Wed Aug 6 01:38:02 2014 (r271978)
+++ soc2014/astarasikov/head/sys/arm/conf/GOLDFISH Wed Aug 6 01:39:24 2014 (r271979)
@@ -1,4 +1,4 @@
-# GOLDFISH - Configuration for QEMU version of Versatile Platform Board
+#GOLDFISH - Configuration for QEMU version of Versatile Platform Board
#
# For more information on this file, please read the handbook section on
# Kernel Configuration Files:
@@ -10,105 +10,122 @@
# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the
# latest information.
#
-# An exhaustive list of options and more detailed explanations of the
-# device lines is also present in the ../../conf/NOTES and NOTES files.
+# An exhaustive list of options and more detailed explanations of the
+# device lines is also present in the ../../conf/NOTES and NOTES files.
# If you are in doubt as to the purpose or necessity of a line, check first
# in NOTES.
#
# $FreeBSD: release/10.0.0/sys/arm/conf/GOLDFISH 254902 2013-08-26 10:27:15Z andrew $
-ident GOLDFISH
+ident GOLDFISH
-cpu CPU_CORTEXA
-machine arm armv6
-makeoptions ARM_LITTLE_ENDIAN
+cpu CPU_CORTEXA
+machine arm armv6
+makeoptions ARM_LITTLE_ENDIAN
-options QEMU_WORKAROUNDS
+nooptions ARM_CACHE_LOCK_ENABLE # QEMU does not implement this
+options QEMU_WORKAROUNDS
-files "../goldfish/files.goldfish"
-makeoptions MODULES_OVERRIDE=""
+files "../goldfish/files.goldfish"
+makeoptions MODULES_OVERRIDE=""
options KERNVIRTADDR=0xc0100000
-makeoptions KERNVIRTADDR=0xc0100000
+makeoptions KERNVIRTADDR=0xc0100000
options KERNPHYSADDR=0x00100000
-makeoptions KERNPHYSADDR=0x00100000
+makeoptions KERNPHYSADDR=0x00100000
options PHYSADDR=0x00000000
-options FREEBSD_BOOT_LOADER
-options LINUX_BOOT_ABI
+options FREEBSD_BOOT_LOADER
+options LINUX_BOOT_ABI
+options VERBOSE_INIT_ARM
-makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols
+makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols
options HZ=100
options SCHED_4BSD #4BSD scheduler
options INET #InterNETworking
+options TMPFS # Efficient memory filesystem
options FFS #Berkeley Fast Filesystem
options SOFTUPDATES #Enable FFS soft updates support
options UFS_ACL #Support for access control lists
options UFS_DIRHASH #Improve performance on big directories
-device snp
+options GEOM_PART_BSD # BSD partition scheme
+options GEOM_PART_MBR # MBR partition scheme
options PSEUDOFS #Pseudo-filesystem framework
options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!]
-options SCSI_DELAY=5000 #Delay (in ms) before probing SCSI
options KTRACE #ktrace(1) support
options SYSVSHM #SYSV-style shared memory
options SYSVMSG #SYSV-style message queues
options SYSVSEM #SYSV-style semaphores
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
options KBD_INSTALL_CDEV # install a CDEV entry in /dev
-options ROOTDEVNAME=\"ufs:da0s1a\"
options VFP # vfp/neon
+options PLATFORM
options PREEMPTION
-options PLATFORM
-device bpf
-device loop
+device loop
+device snp
+
+# NAND for rootfs
+# device nand
# Ethernet
-device ether
-device mii
-device mii_bitbang
-device smc
-device smcphy
+device ether
+device mii
+device mii_bitbang
+device smc
+device smcphy
# Serial
-device uart
-device pty
+device uart
+device pty
# NOTE: serial console is disabled if syscons enabled
# Comment following lines for headless setup
-device sc
-device kbdmux
-options SC_DFLT_FONT # compile font in
-makeoptions SC_DFLT_FONT=cp437
-
+device sc
+device kbdmux
+options SC_DFLT_FONT # compile font in
+makeoptions SC_DFLT_FONT=cp437
+
+options STACK
+makeoptions WITH_CTF=1
+options DDB_CTF
options KDB
+options KDB_TRACE
options DDB #Enable the kernel debugger
-options VERBOSE_SYSINIT
-options DIAGNOSTIC
-#options INVARIANTS #Enable calls of extra sanity checking
-#options INVARIANT_SUPPORT #Extra sanity checks of internal structures, required by INVARIANTS
+options VERBOSE_SYSINIT
+options DIAGNOSTIC
+options DEBUG
+options INVARIANTS #Enable calls of extra sanity checking
+options INVARIANT_SUPPORT #Extra sanity checks of internal structures, required by INVARIANTS
+options KLD_DEBUG
+
+options MUTEX_NOINLINE
+options RWLOCK_NOINLINE
+options NO_SWAPPING
+#options WITNESS
+#options WITNESS_SKIPSPIN
-device md
-device random # Entropy device
+device md
+device random # Entropy device
# Flattened Device Tree
-options FDT
-options FDT_DTB_STATIC
-makeoptions FDT_DTS_FILE=goldfish.dts
-
-#options MD_ROOT
-#options MD_ROOT_SIZE=5120
-#makeoptions MFS_IMAGE=/root/handhelds/myroot.img
-#options ROOTDEVNAME=\"/dev/md0\"
+options FDT
+options FDT_DTB_STATIC
+makeoptions FDT_DTS_FILE=goldfish.dts
+
+options MD_ROOT
+options MD_ROOT_SIZE=5120
+makeoptions MFS_IMAGE=/root/handhelds/myroot.img
+options ROOTDEVNAME=\"/dev/md0\"
#boot from NFS
-#options NFSCL
-#options NFSCLIENT
-#options NFS_ROOT
-#options BOOTP_COMPAT
-#options BOOTP
-#options BOOTP_NFSV3
-#options BOOTP_WIRED_TO=smc0
-#options ROOTDEVNAME=\"nfs:192.168.1.51:/srv/nfs3/bsd/\"
+#options NFSCL
+#options NFSCLIENT
+#options NFS_ROOT
+#options BOOTP_COMPAT
+#options BOOTP
+#options BOOTP_NFSV3
+#options BOOTP_WIRED_TO=smc0
+#options ROOTDEVNAME=\"nfs:192.168.1.51:/srv/nfs3/bsd/\"
Modified: soc2014/astarasikov/head/sys/arm/goldfish/files.goldfish
==============================================================================
--- soc2014/astarasikov/head/sys/arm/goldfish/files.goldfish Wed Aug 6 01:38:02 2014 (r271978)
+++ soc2014/astarasikov/head/sys/arm/goldfish/files.goldfish Wed Aug 6 01:39:24 2014 (r271979)
@@ -1,16 +1,16 @@
arm/arm/bus_space_asm_generic.S standard
arm/arm/bus_space_generic.c standard
arm/arm/bus_space-v6.c standard
-arm/arm/cpufunc_asm_armv5.S standard
+
arm/arm/cpufunc_asm_arm11.S standard
+arm/arm/cpufunc_asm_armv6.S standard
arm/arm/cpufunc_asm_armv7.S standard
kern/kern_clocksource.c standard
-arm/goldfish/goldfish_fb.c optional sc
+arm/goldfish/goldfish_fb.c optional sc
arm/goldfish/goldfish_machdep.c standard
arm/goldfish/goldfish_mmc.c standard
-arm/goldfish/goldfish_nand.c standard
arm/goldfish/goldfish_pic.c standard
arm/goldfish/goldfish_pdev.c standard
arm/goldfish/goldfish_timer.c standard
Modified: soc2014/astarasikov/head/sys/arm/goldfish/goldfish_mmc.c
==============================================================================
--- soc2014/astarasikov/head/sys/arm/goldfish/goldfish_mmc.c Wed Aug 6 01:38:02 2014 (r271978)
+++ soc2014/astarasikov/head/sys/arm/goldfish/goldfish_mmc.c Wed Aug 6 01:39:24 2014 (r271979)
@@ -67,7 +67,7 @@
goldfish_mmc_probe(device_t dev)
{
- if (!ofw_bus_is_compatible(dev, "arm,goldfish-mmc"))
+ if (1 || !ofw_bus_is_compatible(dev, "arm,goldfish-mmc"))
return (ENXIO);
device_set_desc(dev, "Goldfish MMC");
Modified: soc2014/astarasikov/head/sys/arm/goldfish/goldfish_nand.c
==============================================================================
--- soc2014/astarasikov/head/sys/arm/goldfish/goldfish_nand.c Wed Aug 6 01:38:02 2014 (r271978)
+++ soc2014/astarasikov/head/sys/arm/goldfish/goldfish_nand.c Wed Aug 6 01:39:24 2014 (r271979)
@@ -45,90 +45,199 @@
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
+#include <dev/nand/nand.h>
+#include <dev/nand/nandbus.h>
+#include "nfc_if.h"
+
+enum goldfish_nand_cmd {
+ GOLGDFISH_NAND_CMD_GET_DEV_NAME = 0,
+ GOLGDFISH_NAND_CMD_READ = 1,
+ GOLGDFISH_NAND_CMD_WRITE = 2,
+ GOLGDFISH_NAND_CMD_ERASE = 3,
+ GOLGDFISH_NAND_CMD_BLOCK_IS_BAD = 4,
+ GOLGDFISH_NAND_CMD_BLOCK_MARK_BAD = 5,
+};
+
+enum goldfish_nand_reg {
+ GOLGDFISH_NAND_VERSION = 0x00,
+ GOLGDFISH_NAND_NUM_DEV = 0x04,
+ GOLGDFISH_NAND_DEV = 0x08,
+
+ GOLGDFISH_NAND_DEV_FLAGS = 0x10,
+ GOLGDFISH_NAND_DEV_NAME_LEN = 0x14,
+ GOLGDFISH_NAND_DEV_PAGE_SIZE = 0x18,
+ GOLGDFISH_NAND_DEV_EXTRA_SIZE = 0x1c,
+ GOLGDFISH_NAND_DEV_ERASE_SIZE = 0x20,
+ GOLGDFISH_NAND_DEV_SIZE_LOW = 0x28,
+ GOLGDFISH_NAND_DEV_SIZE_HIGH = 0x2c,
+
+ GOLGDFISH_NAND_RESULT = 0x40,
+ GOLGDFISH_NAND_COMMAND = 0x44,
+ GOLGDFISH_NAND_DATA = 0x48,
+ GOLGDFISH_NAND_TRANSFER_SIZE = 0x4c,
+ GOLGDFISH_NAND_ADDR_LOW = 0x50,
+ GOLGDFISH_NAND_ADDR_HIGH = 0x54,
+};
+
+enum goldfish_nand_constants {
+ GOLGDFISH_NAND_DEV_FLAG_RO = 0x1,
+ GOLGDFISH_NAND_VERSION_CURRENT = 0x1,
+};
+
struct goldfish_nand_softc {
- struct resource * li_res;
- bus_space_tag_t li_bst;
- bus_space_handle_t li_bsh;
- struct resource* irq_res;
- void* intr_hl;
-};
-
-static int goldfish_nand_probe(device_t);
-static int goldfish_nand_attach(device_t);
-
-static struct goldfish_nand_softc *nand_softc = NULL;
-
-#define nand_read_4(reg) \
- bus_space_read_4(nand_softc->li_bst, nand_softc->li_bsh, reg)
-#define nand_write_4(reg, val) \
- bus_space_write_4(nand_softc->li_bst, nand_softc->li_bsh, reg, val)
+ struct nand_softc nand_dev;
+ bus_space_handle_t sc_handle;
+ bus_space_tag_t sc_tag;
+ struct resource *res;
+ int rid;
+};
+
+#define intc_read_4(reg) \
+ bus_space_read_4(intc_softc->li_bst, intc_softc->li_bsh, reg)
+#define intc_write_4(reg, val) \
+ bus_space_write_4(intc_softc->li_bst, intc_softc->li_bsh, reg, val)
+
+static int goldfish_nand_attach(device_t);
+static int goldfish_nand_probe(device_t);
+static int goldfish_nand_send_command(device_t, uint8_t);
+static int goldfish_nand_send_address(device_t, uint8_t);
+static uint8_t goldfish_nand_read_byte(device_t);
+static void goldfish_nand_read_buf(device_t, void *, uint32_t);
+static void goldfish_nand_write_buf(device_t, void *, uint32_t);
+static int goldfish_nand_select_cs(device_t, uint8_t);
+static int goldfish_nand_read_rnb(device_t);
+
+static device_method_t goldfish_nand_methods[] = {
+ DEVMETHOD(device_probe, goldfish_nand_probe),
+ DEVMETHOD(device_attach, goldfish_nand_attach),
+
+ DEVMETHOD(nfc_send_command, goldfish_nand_send_command),
+ DEVMETHOD(nfc_send_address, goldfish_nand_send_address),
+ DEVMETHOD(nfc_read_byte, goldfish_nand_read_byte),
+ DEVMETHOD(nfc_read_buf, goldfish_nand_read_buf),
+ DEVMETHOD(nfc_write_buf, goldfish_nand_write_buf),
+ DEVMETHOD(nfc_select_cs, goldfish_nand_select_cs),
+ DEVMETHOD(nfc_read_rnb, goldfish_nand_read_rnb),
+
+ { 0, 0 },
+};
+
+static driver_t goldfish_nand_driver = {
+ "nand",
+ goldfish_nand_methods,
+ sizeof(struct goldfish_nand_softc),
+};
+
+static devclass_t goldfish_nand_devclass;
+DRIVER_MODULE(goldfish_nand, localbus, goldfish_nand_driver, goldfish_nand_devclass, 0, 0);
+
+static uint32_t
+goldfish_nand_mmio_cmd(device_t dev, enum goldfish_nand_cmd cmd,
+ uint64_t addr, uint32_t length, void *data)
+{
+ struct goldfish_nand_softc *sc;
+ uint32_t ret;
+ sc = device_get_softc(dev);
+
+ //XXX: lock
+
+ bus_space_write_4(sc->sc_tag, sc->sc_handle, GOLGDFISH_NAND_DEV, 0); //FIXME: multiple devices?
+ bus_space_write_4(sc->sc_tag, sc->sc_handle, GOLGDFISH_NAND_ADDR_HIGH,
+ (uint32_t)(addr >> 32));
+ bus_space_write_4(sc->sc_tag, sc->sc_handle, GOLGDFISH_NAND_ADDR_LOW,
+ (uint32_t)addr);
+ bus_space_write_4(sc->sc_tag, sc->sc_handle, GOLGDFISH_NAND_TRANSFER_SIZE, length);
+ bus_space_write_4(sc->sc_tag, sc->sc_handle, GOLGDFISH_NAND_DATA, (uint32_t)data);
+ bus_space_write_4(sc->sc_tag, sc->sc_handle, GOLGDFISH_NAND_COMMAND, (uint32_t)cmd);
+ ret = bus_space_read_4(sc->sc_tag, sc->sc_handle, GOLGDFISH_NAND_RESULT);
+
+ //XXX: unlock
+ return ret;
+}
static int
goldfish_nand_probe(device_t dev)
{
-
- if (!ofw_bus_is_compatible(dev, "arm,goldfish-nand"))
+ //if (!ofw_bus_is_compatible(dev, "arm,goldfish-nand"))
return (ENXIO);
- device_set_desc(dev, "Goldfish NAND");
+ device_set_desc(dev, "Goldfish NAND controller");
return (BUS_PROBE_DEFAULT);
}
static int
-goldfish_nand_intr(void *arg)
+goldfish_nand_attach(device_t dev)
{
- printf("%s: irq\n", __func__);
- return (FILTER_HANDLED);
+ struct goldfish_nand_softc *sc;
+ int err;
+ uint32_t num_dev = 0;
+ uint32_t version = 0;
+
+ sc = device_get_softc(dev);
+ sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->rid,
+ RF_ACTIVE);
+ if (sc->res == NULL) {
+ device_printf(dev, "could not allocate resources!\n");
+ return (ENXIO);
+ }
+
+ sc->sc_tag = rman_get_bustag(sc->res);
+ sc->sc_handle = rman_get_bushandle(sc->res);
+
+ version = bus_space_read_4(sc->sc_tag, sc->sc_handle, GOLGDFISH_NAND_VERSION);
+ num_dev = bus_space_read_4(sc->sc_tag, sc->sc_handle, GOLGDFISH_NAND_NUM_DEV);
+
+ device_printf(dev, "version %d num_devices=%d\n", version, num_dev);
+
+ nand_init(&sc->nand_dev, dev, NAND_ECC_SOFT, 0, 0, NULL, NULL);
+
+ err = nandbus_create(dev);
+
+ return (err);
}
static int
-goldfish_nand_attach(device_t dev)
+goldfish_nand_send_command(device_t dev, uint8_t command)
{
- struct goldfish_nand_softc *sc = device_get_softc(dev);
- int li_rid = 0, irq_rid = 0;
-
- if (nand_softc)
- return (ENXIO);
-
- sc->li_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &li_rid, RF_ACTIVE);
- if (!sc->li_res)
- goto fail;
-
- sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &irq_rid, RF_ACTIVE);
- if (!sc->irq_res)
- goto fail;
-
- if (bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC,
- goldfish_nand_intr, NULL, sc, &sc->intr_hl) != 0)
- goto fail;
-
- sc->li_bst = rman_get_bustag(sc->li_res);
- sc->li_bsh = rman_get_bushandle(sc->li_res);
- nand_softc = sc;
+ return (0);
+}
+static int
+goldfish_nand_send_address(device_t dev, uint8_t addr)
+{
return (0);
+}
-fail:
- if (sc->irq_res)
- bus_release_resource(dev, SYS_RES_IRQ, irq_rid, sc->irq_res);
+static uint8_t
+goldfish_nand_read_byte(device_t dev)
+{
+ return (0);
+}
- if (sc->li_res)
- bus_release_resource(dev, SYS_RES_MEMORY, li_rid, sc->li_res);
+static void
+goldfish_nand_read_buf(device_t dev, void* buf, uint32_t len)
+{
+}
- return (ENXIO);
+static void
+goldfish_nand_write_buf(device_t dev, void* buf, uint32_t len)
+{
}
-static device_method_t goldfish_nand_methods[] = {
- DEVMETHOD(device_probe, goldfish_nand_probe),
- DEVMETHOD(device_attach, goldfish_nand_attach),
- { 0, 0 }
-};
+static int
+goldfish_nand_select_cs(device_t dev, uint8_t cs)
+{
-static driver_t goldfish_nand_driver = {
- "nand",
- goldfish_nand_methods,
- sizeof(struct goldfish_nand_softc),
-};
+ if (cs > 0)
+ return (ENODEV);
-static devclass_t goldfish_nand_devclass;
-DRIVER_MODULE(nand, simplebus, goldfish_nand_driver, goldfish_nand_devclass, 0, 0);
+ return (0);
+}
+
+static int
+goldfish_nand_read_rnb(device_t dev)
+{
+
+ /* no-op */
+ return (0); /* ready */
+}
More information about the svn-soc-all
mailing list