socsvn commit: r272383 - in soc2014/astarasikov/head/sys: arm/conf arm/goldfish boot/fdt/dts/arm

astarasikov at FreeBSD.org astarasikov at FreeBSD.org
Thu Aug 14 04:18:40 UTC 2014


Author: astarasikov
Date: Thu Aug 14 04:18:38 2014
New Revision: 272383
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=272383

Log:
  Goldfish: implement the (almost-working) MMC driver.
  
  	The driver correctly writes/reads MMC command data,
  	but seems stuck after sending CMD13. I'm currently debugging it.
  

Modified:
  soc2014/astarasikov/head/sys/arm/conf/GOLDFISH
  soc2014/astarasikov/head/sys/arm/goldfish/files.goldfish
  soc2014/astarasikov/head/sys/arm/goldfish/goldfish_nand.c
  soc2014/astarasikov/head/sys/boot/fdt/dts/arm/goldfish.dts

Modified: soc2014/astarasikov/head/sys/arm/conf/GOLDFISH
==============================================================================
--- soc2014/astarasikov/head/sys/arm/conf/GOLDFISH	Thu Aug 14 04:13:25 2014	(r272382)
+++ soc2014/astarasikov/head/sys/arm/conf/GOLDFISH	Thu Aug 14 04:18:38 2014	(r272383)
@@ -41,6 +41,7 @@
 makeoptions 	DEBUG=-g		#Build kernel with gdb(1) debug symbols
 options 	HZ=100
 
+options 	SCSI_DELAY=5000		# Delay (in ms) before probing SCSI
 options 	SCHED_4BSD		#4BSD scheduler
 options 	INET			#InterNETworking
 options 	TMPFS			# Efficient memory filesystem
@@ -68,7 +69,8 @@
 device 	snp
 
 # NAND for rootfs
-# device 	nand
+device 	nand
+options 	NANDFS			# NAND file system
 
 # Ethernet
 device 	ether
@@ -83,10 +85,10 @@
 
 # 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
@@ -110,15 +112,19 @@
 device 	md
 device 	random		# Entropy device
 
+device mmc
+device mmcsd
+options ROOTDEVNAME=\"ufs:/dev/mmcsd0s1a\"
+
 # 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 	MD_ROOT
+#options 	MD_ROOT_SIZE=5120
+#makeoptions 	MFS_IMAGE=/root/handhelds/myroot.img
+#options 	ROOTDEVNAME=\"/dev/md0\"
 
 #boot from NFS
 #options 	NFSCL

Modified: soc2014/astarasikov/head/sys/arm/goldfish/files.goldfish
==============================================================================
--- soc2014/astarasikov/head/sys/arm/goldfish/files.goldfish	Thu Aug 14 04:13:25 2014	(r272382)
+++ soc2014/astarasikov/head/sys/arm/goldfish/files.goldfish	Thu Aug 14 04:18:38 2014	(r272383)
@@ -10,7 +10,8 @@
 
 arm/goldfish/goldfish_fb.c			optional sc
 arm/goldfish/goldfish_machdep.c		standard
-arm/goldfish/goldfish_mmc.c			standard
+arm/goldfish/goldfish_mmc.c			optional mmc
+#arm/goldfish/goldfish_nand.c		optional nand
 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_nand.c
==============================================================================
--- soc2014/astarasikov/head/sys/arm/goldfish/goldfish_nand.c	Thu Aug 14 04:13:25 2014	(r272382)
+++ soc2014/astarasikov/head/sys/arm/goldfish/goldfish_nand.c	Thu Aug 14 04:18:38 2014	(r272383)
@@ -84,6 +84,9 @@
 	GOLGDFISH_NAND_VERSION_CURRENT = 0x1,
 };
 
+struct goldfish_nand_state {
+};
+
 struct goldfish_nand_softc {
 	struct nand_softc 	nand_dev;
 	bus_space_handle_t 	sc_handle;
@@ -99,25 +102,28 @@
 
 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_read_rnb(device_t);
+static int	goldfish_nand_select_cs(device_t, uint8_t);
 static int	goldfish_nand_send_address(device_t, uint8_t);
+static int	goldfish_nand_send_command(device_t, uint8_t);
+static int	goldfish_nand_start_command(device_t dev);
 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_byte,	goldfish_nand_read_byte),
 	DEVMETHOD(nfc_read_rnb,		goldfish_nand_read_rnb),
+	DEVMETHOD(nfc_select_cs,	goldfish_nand_select_cs),
+	DEVMETHOD(nfc_send_address,	goldfish_nand_send_address),
+	DEVMETHOD(nfc_send_command,	goldfish_nand_send_command),
+	DEVMETHOD(nfc_start_command, goldfish_nand_start_command),
+	DEVMETHOD(nfc_write_buf,	goldfish_nand_write_buf),
 
 	{ 0, 0 },
 };
@@ -129,7 +135,7 @@
 };
 
 static devclass_t goldfish_nand_devclass;
-DRIVER_MODULE(goldfish_nand, localbus, goldfish_nand_driver, goldfish_nand_devclass, 0, 0);
+DRIVER_MODULE(goldfish_nand, simplebus, goldfish_nand_driver, goldfish_nand_devclass, 0, 0);
 
 static uint32_t
 goldfish_nand_mmio_cmd(device_t dev, enum goldfish_nand_cmd cmd,
@@ -158,7 +164,7 @@
 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 controller");
@@ -192,36 +198,89 @@
 	nand_init(&sc->nand_dev, dev, NAND_ECC_SOFT, 0, 0, NULL, NULL);
 
 	err = nandbus_create(dev);
+	printf("%s: nandbus_create=%d\n", __func__, err);
 
 	return (err);
 }
 
+static int	goldfish_nand_start_command(device_t dev)
+{
+	printf("%s\n", __func__);
+	return (0);
+}
+
 static int
 goldfish_nand_send_command(device_t dev, uint8_t command)
 {
+	printf("%s: command=%x\n", __func__, command);
+
+	switch (command) {
+	case NAND_CMD_READ:
+		fcm->code = CMD_READ_PAGE;
+		fcm->addr_type = ADDR_ROWCOL;
+		break;
+	case NAND_CMD_PROG:
+		fcm->code = CMD_PROG_PAGE;
+		fcm->addr_type = ADDR_ROWCOL;
+		break;
+	case NAND_CMD_PROG_END:
+		break;
+	case NAND_CMD_ERASE_END:
+		break;
+	case NAND_CMD_RESET:
+		fcm->code = CMD_RESET;
+		break;
+	case NAND_CMD_READ_ID:
+		fcm->code = CMD_READ_ID;
+		fcm->addr_type = ADDR_ID;
+		break;
+	case NAND_CMD_READ_PARAMETER:
+		fcm->code = CMD_READ_PAGE;
+		fcm->addr_type = ADDR_ID;
+		break;
+	case NAND_CMD_STATUS:
+		fcm->code = CMD_READ_STATUS;
+		break;
+	case NAND_CMD_ERASE:
+		fcm->code = CMD_ERASE;
+		fcm->addr_type = ADDR_ROW;
+		break;
+	case NAND_CMD_READ_END:
+	case NAND_CMD_PROG_END:
+	case NAND_CMD_ERASE_END:
+		break;
+	default:
+			printf("%s: unknown command %d\n", command);
+			return (1);
+	}
+
 	return (0);
 }
 
 static int
 goldfish_nand_send_address(device_t dev, uint8_t addr)
 {
+	printf("%s: addr=%x\n", __func__, addr);
 	return (0);
 }
 
 static uint8_t
 goldfish_nand_read_byte(device_t dev)
 {
+	printf("%s\n", __func__);
 	return (0);
 }
 
 static void
 goldfish_nand_read_buf(device_t dev, void* buf, uint32_t len)
 {
+	printf("%s: buf=%p, len=%x\n", __func__, buf, len);
 }
 
 static void
 goldfish_nand_write_buf(device_t dev, void* buf, uint32_t len)
 {
+	printf("%s: buf=%p, len=%x\n", __func__, buf, len);
 }
 
 static int

Modified: soc2014/astarasikov/head/sys/boot/fdt/dts/arm/goldfish.dts
==============================================================================
--- soc2014/astarasikov/head/sys/boot/fdt/dts/arm/goldfish.dts	Thu Aug 14 04:13:25 2014	(r272382)
+++ soc2014/astarasikov/head/sys/boot/fdt/dts/arm/goldfish.dts	Thu Aug 14 04:18:38 2014	(r272383)
@@ -25,12 +25,14 @@
 			#interrupt-cells = <1>;
 		};
 
+		/*
 		pdev {
-			compatible = "arm,goldfish-xpdev";
+			compatible = "arm,goldfish-pdev";
 			reg = <0xff001000 0x1000>;
 			interrupts = <1>;
 			interrupt-parent = <&pic>;
 		};
+		*/
 
 		uart0: uart0 {
 			compatible = "arm,goldfish-uart";
@@ -48,19 +50,34 @@
 			interrupts = <3>;
 			interrupt-parent = <&pic>;
 		};
-
-		audio {
-			compatible = "arm,goldfish-xaudio";
-			reg = <0xff004000 0x1000>;
+		
+		mmc at xff005000 {
+			compatible = "arm,goldfish-mmc";
+			reg = <0xff005000 0x1000>;
 			interrupts = <15>;
 			interrupt-parent = <&pic>;
+			non-removable;
+			mmchs-device-id = <1>;
+			max-frequency = <24000000>;
 		};
 		
-		mmc {
-			compatible = "arm,goldfish-xmmc";
-			reg = <0xff005000 0x1000>;
-			interrupts = <16>;
-			interrupt-parent = <&pic>;
+		/*
+		nand {
+			compatible = "arm,goldfish-nand";
+			reg = <0xff017000 0x1000>;
+			interrupts = <2>;
+			interrupt-parent = <&pic>;
+
+			slice at 0 {
+				reg = <0x0 0x200000>;
+				label = "uboot";
+				read-only;
+			};
+
+			slice at 200000 {
+				reg = <0x200000 0x100000>;
+				label = "root";
+			};
 		};
 		
 		smc {
@@ -78,6 +95,7 @@
 			interrupts = <14>;
 			interrupt-parent = <&pic>;
 		};
+		*/
 	};
 
 	memory {


More information about the svn-soc-all mailing list