Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 May 2015 02:27:41 GMT
From:      pratiksinghal@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r286434 - in soc2015/pratiksinghal/cubie-head/sys/arm: allwinner conf
Message-ID:  <201505310227.t4V2RfCA003975@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pratiksinghal
Date: Sun May 31 02:27:40 2015
New Revision: 286434
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286434

Log:
  Removed the size > 0 panic message.  Mapping still needs to be corrected though

Modified:
  soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c
  soc2015/pratiksinghal/cubie-head/sys/arm/conf/CUBIEBOARD

Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c
==============================================================================
--- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c	Sun May 31 01:02:05 2015	(r286433)
+++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c	Sun May 31 02:27:40 2015	(r286434)
@@ -55,6 +55,7 @@
 #define	A10_MMC_IRQRES		1
 #define	A10_MMC_RESSZ		2
 
+
 struct a10_mmc_softc {
 	bus_space_handle_t	a10_bsh;
 	bus_space_tag_t		a10_bst;
@@ -71,6 +72,14 @@
 	uint32_t		a10_intr;
 	uint32_t		a10_intr_wait;
 	void *			a10_intrhand;
+	bus_dma_tag_t 		a10_mmc_dmat ; 
+	bus_dma_segment_t	a10_mmc_dma_segments ; 
+	bus_dmamap_t		a10_mmc_dmamap ; 
+	bus_size_t			buf_size ; 
+	bus_dma_segment_t	a10_mmc_dmasegs[1] ; 	
+	void * 				a10_mmc_buff ; /* Pointer to the buffer */ 
+	uint32_t			a10_mmc_nseg ; /* No of segments */ 
+	bus_addr_t 			a10_mmc_seg ;  /* Address of the first descriptor */ 
 };
 
 static struct resource_spec a10_mmc_res_spec[] = {
@@ -85,6 +94,8 @@
 static int a10_mmc_reset(struct a10_mmc_softc *);
 static void a10_mmc_intr(void *);
 static int a10_mmc_update_clock(struct a10_mmc_softc *);
+static int a10_mmc_init_dma(struct a10_mmc_softc *, struct mmc_command *) ; /* Not defined yet */
+static void a10_mmc_dma_callback(void *, bus_dma_segment_t *,int , int) ;  
 
 static int a10_mmc_update_ios(device_t, device_t);
 static int a10_mmc_request(device_t, device_t, struct mmc_request *);
@@ -135,8 +146,8 @@
 	sc->a10_bst = rman_get_bustag(sc->a10_res[A10_MMC_MEMRES]);
 	sc->a10_bsh = rman_get_bushandle(sc->a10_res[A10_MMC_MEMRES]);
 	if (bus_setup_intr(dev, sc->a10_res[A10_MMC_IRQRES],
-	    INTR_TYPE_MISC | INTR_MPSAFE, NULL, a10_mmc_intr, sc,
-	    &sc->a10_intrhand)) {
+		INTR_TYPE_MISC | INTR_MPSAFE, NULL, a10_mmc_intr, sc,
+		&sc->a10_intrhand)) {
 		bus_release_resources(dev, a10_mmc_res_spec, sc->a10_res);
 		device_printf(dev, "cannot setup interrupt handler\n");
 		return (ENXIO);
@@ -145,7 +156,7 @@
 	/* Activate the module clock. */
 	if (a10_clk_mmc_activate(sc->a10_id) != 0) {
 		bus_teardown_intr(dev, sc->a10_res[A10_MMC_IRQRES],
-		    sc->a10_intrhand);
+			sc->a10_intrhand);
 		bus_release_resources(dev, a10_mmc_res_spec, sc->a10_res);
 		device_printf(dev, "cannot activate mmc clock\n");
 		return (ENXIO);
@@ -155,9 +166,9 @@
 	ctx = device_get_sysctl_ctx(dev);
 	tree = SYSCTL_CHILDREN(device_get_sysctl_tree(dev));
 	SYSCTL_ADD_INT(ctx, tree, OID_AUTO, "req_timeout", CTLFLAG_RW,
-	    &sc->a10_timeout, 0, "Request timeout in seconds");
+		&sc->a10_timeout, 0, "Request timeout in seconds");
 	mtx_init(&sc->a10_mtx, device_get_nameunit(sc->a10_dev), "a10_mmc",
-	    MTX_DEF);
+		MTX_DEF);
 	callout_init_mtx(&sc->a10_timeoutc, &sc->a10_mtx, 0);
 
 	/* Reset controller. */
@@ -183,6 +194,30 @@
 		goto fail;
 	}
 
+	/* Create the tag. */ 
+	uint32_t err = bus_dma_tag_create(bus_get_dma_tag(dev), 4096,
+		0,BUS_SPACE_MAXADDR,BUS_SPACE_MAXADDR,
+		NULL,NULL,sizeof(struct a10_mmc_dma_desc)*2,
+		1,PAGE_SIZE,0,
+		NULL,NULL,&sc->a10_mmc_dmat) ;
+
+	if(err) {	 
+		device_printf(dev, "Could not create dma tag.\n"); 
+		goto fail ; 
+	}
+	/* Allocate buffer */
+	bus_dmamem_alloc(sc->a10_mmc_dmat, &sc->a10_mmc_buff,BUS_DMA_WAITOK|BUS_DMA_ZERO|BUS_DMA_COHERENT, &sc->a10_mmc_dmamap) ; 
+
+	err = bus_dmamap_load(sc->a10_mmc_dmat, sc->a10_mmc_dmamap, sc->a10_mmc_buff, sizeof(struct a10_mmc_dma_desc)*2, a10_mmc_dma_callback,
+							&sc->a10_mmc_seg, BUS_DMA_NOWAIT) ; 
+
+	if(err)
+	{
+		device_printf(sc->a10_dev, "Error while loading dma map! code = %d\n", err) ; 
+		goto fail ; 
+	}
+
+	device_printf(sc->a10_dev, "dma_map loaded succesfully!\n") ; 
 	return (0);
 
 fail:
@@ -207,7 +242,7 @@
 	int timeout;
 
 	A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,
-	    A10_MMC_READ_4(sc, A10_MMC_GCTRL) | A10_MMC_RESET);
+		A10_MMC_READ_4(sc, A10_MMC_GCTRL) | A10_MMC_RESET);
 	timeout = 1000;
 	while (--timeout > 0) {
 		if ((A10_MMC_READ_4(sc, A10_MMC_GCTRL) & A10_MMC_RESET) == 0)
@@ -224,13 +259,13 @@
 	A10_MMC_WRITE_4(sc, A10_MMC_RINTR, 0xffffffff);
 	/* Unmask interrupts. */
 	A10_MMC_WRITE_4(sc, A10_MMC_IMASK,
-	    A10_MMC_CMD_DONE | A10_MMC_INT_ERR_BIT |
-	    A10_MMC_DATA_OVER | A10_MMC_AUTOCMD_DONE |
-	    A10_MMC_RX_DATA_REQ | A10_MMC_TX_DATA_REQ);
+		A10_MMC_CMD_DONE | A10_MMC_INT_ERR_BIT |
+		A10_MMC_DATA_OVER | A10_MMC_AUTOCMD_DONE |
+		A10_MMC_RX_DATA_REQ | A10_MMC_TX_DATA_REQ);
 	/* Enable interrupts and AHB access. */
 	A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,
-	    A10_MMC_READ_4(sc, A10_MMC_GCTRL) |
-	    A10_MMC_INT_ENABLE | A10_MMC_ACCESS_BY_AHB);
+		A10_MMC_READ_4(sc, A10_MMC_GCTRL) |
+		A10_MMC_INT_ENABLE | A10_MMC_ACCESS_BY_AHB);
 
 	return (0);
 }
@@ -249,7 +284,7 @@
 	}
 	/* Reset the FIFO. */
 	A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,
-	    A10_MMC_READ_4(sc, A10_MMC_GCTRL) | A10_MMC_FIFO_RESET);
+		A10_MMC_READ_4(sc, A10_MMC_GCTRL) | A10_MMC_FIFO_RESET);
 
 	req = sc->a10_req;
 	callout_stop(&sc->a10_timeoutc);
@@ -307,7 +342,7 @@
 		a10_mmc_req_done(sc);
 	} else
 		device_printf(sc->a10_dev,
-		    "Spurious timeout - no active request\n");
+			"Spurious timeout - no active request\n");
 }
 
 static int
@@ -352,8 +387,8 @@
 #endif
 	if (sc->a10_req == NULL) {
 		device_printf(sc->a10_dev,
-		    "Spurious interrupt - no active request, rint: 0x%08X\n",
-		    rint);
+			"Spurious interrupt - no active request, rint: 0x%08X\n",
+			rint);
 		A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint);
 		A10_MMC_UNLOCK(sc);
 		return;
@@ -373,7 +408,7 @@
 	sc->a10_intr |= rint;
 	data = sc->a10_req->cmd->data;
 	if (data != NULL && (rint & (A10_MMC_DATA_OVER |
-	    A10_MMC_RX_DATA_REQ | A10_MMC_TX_DATA_REQ)) != 0)
+		A10_MMC_RX_DATA_REQ | A10_MMC_TX_DATA_REQ)) != 0)
 		a10_mmc_pio_transfer(sc, data);
 	if ((sc->a10_intr & sc->a10_intr_wait) == sc->a10_intr_wait)
 		a10_mmc_req_ok(sc);
@@ -429,7 +464,7 @@
 	A10_MMC_WRITE_4(sc, A10_MMC_CARG, cmd->arg);
 	A10_MMC_WRITE_4(sc, A10_MMC_CMDR, cmdreg | cmd->opcode);
 	callout_reset(&sc->a10_timeoutc, sc->a10_timeout * hz,
-	    a10_mmc_timeout, sc);
+		a10_mmc_timeout, sc);
 	A10_MMC_UNLOCK(sc);
 
 	return (0);
@@ -437,7 +472,7 @@
 
 static int
 a10_mmc_read_ivar(device_t bus, device_t child, int which, 
-    uintptr_t *result)
+	uintptr_t *result)
 {
 	struct a10_mmc_softc *sc;
 
@@ -491,7 +526,7 @@
 
 static int
 a10_mmc_write_ivar(device_t bus, device_t child, int which,
-    uintptr_t value)
+	uintptr_t value)
 {
 	struct a10_mmc_softc *sc;
 
@@ -542,7 +577,7 @@
 	int retry;
 
 	cmdreg = A10_MMC_START | A10_MMC_UPCLK_ONLY |
-	    A10_MMC_WAIT_PREOVER;
+		A10_MMC_WAIT_PREOVER;
 	A10_MMC_WRITE_4(sc, A10_MMC_CMDR, cmdreg);
 	retry = 0xfffff;
 	while (--retry > 0) {
@@ -558,6 +593,24 @@
 	return (ETIMEDOUT);
 }
 
+/* This function will map the buffer into a device visible address space and will be called before the actual transfer of data takes place.
+*/ 
+
+static int 
+a10_mmc_init_dma(struct a10_mmc_softc* sc, struct mmc_command* cmd)
+{
+	return (0) ; 
+}
+
+static void 
+a10_mmc_dma_callback(void* arg, bus_dma_segment_t* segs, int nsegs, int error)
+{
+	if(error) {
+		printf("a10_mmc : Error in the callback function code = %d\n", error) ; 
+		return ; 
+	}
+	*(bus_addr_t*)arg = segs[0].ds_addr ; 
+}
 static int
 a10_mmc_update_ios(device_t bus, device_t child)
 {

Modified: soc2015/pratiksinghal/cubie-head/sys/arm/conf/CUBIEBOARD
==============================================================================
--- soc2015/pratiksinghal/cubie-head/sys/arm/conf/CUBIEBOARD	Sun May 31 01:02:05 2015	(r286433)
+++ soc2015/pratiksinghal/cubie-head/sys/arm/conf/CUBIEBOARD	Sun May 31 02:27:40 2015	(r286434)
@@ -50,7 +50,7 @@
 #options 	BOOTP_WIRED_TO=cpsw0
 
 # Boot device is 2nd slice on MMC/SD card
-options 	ROOTDEVNAME=\"ufs:/dev/da0s2\"
+options 	ROOTDEVNAME=\"ufs:/dev/da0\"
 
 # MMC/SD/SDIO Card slot support
 device		mmc			# mmc/sd bus
@@ -101,7 +101,7 @@
 device		emac
 
 #DMA controller
-device		dma
+#device		dma
 
 # USB ethernet support, requires miibus
 device		miibus
@@ -111,3 +111,5 @@
 options 	FDT_DTB_STATIC
 makeoptions	FDT_DTS_FILE=cubieboard.dts
 makeoptions	MODULES_EXTRA=dtb/allwinner
+
+options ARM_NEW_PMAP



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505310227.t4V2RfCA003975>