Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 May 2017 21:25:49 +0000 (UTC)
From:      Oleksandr Tymoshenko <gonzo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r318118 - stable/11/sys/arm/freescale/imx
Message-ID:  <201705092125.v49LPnuL062609@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gonzo
Date: Tue May  9 21:25:49 2017
New Revision: 318118
URL: https://svnweb.freebsd.org/changeset/base/318118

Log:
  MFC r310343-r310344
  
  r310343:
  [iMX6] Fix build for SSI driver and add dependency for SDMA driver
  
  - Pass correct pointer to OF_getencprop
  - Check the size of "dmas" property
  - Add dependency on sdma driver
  
  Reviewed by:	br
  Differential Revision:	https://reviews.freebsd.org/D8873
  
  r310344:
  [iMX6] Fix SDMA driver build
  
  - Place const modifiers where required
  - Make sure sdma device is attahched before consumers like SSI
  
  Reviewed by:	br
  Differential Revision:	https://reviews.freebsd.org/D8874

Modified:
  stable/11/sys/arm/freescale/imx/imx6_sdma.c
  stable/11/sys/arm/freescale/imx/imx6_sdma.h
  stable/11/sys/arm/freescale/imx/imx6_ssi.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/arm/freescale/imx/imx6_sdma.c
==============================================================================
--- stable/11/sys/arm/freescale/imx/imx6_sdma.c	Tue May  9 20:47:16 2017	(r318117)
+++ stable/11/sys/arm/freescale/imx/imx6_sdma.c	Tue May  9 21:25:49 2017	(r318118)
@@ -352,7 +352,7 @@ sdma_configure(int chn, struct sdma_conf
 static int
 load_firmware(struct sdma_softc *sc)
 {
-	struct sdma_firmware_header *header;
+	const struct sdma_firmware_header *header;
 	const struct firmware *fp;
 
 	fp = firmware_get("sdma_fw");
@@ -361,14 +361,14 @@ load_firmware(struct sdma_softc *sc)
 		return (-1);
 	}
 
-	header = (struct sdma_firmware_header *)fp->data;
+	header = fp->data;
 	if (header->magic != FW_HEADER_MAGIC) {
 		device_printf(sc->dev, "Can't use firmware.\n");
 		return (-1);
 	}
 
 	sc->fw_header = header;
-	sc->fw_scripts = (void *)((char *)header +
+	sc->fw_scripts = (const void *)((const char *)header +
 				header->script_addrs_start);
 
 	return (0);
@@ -378,14 +378,14 @@ static int
 boot_firmware(struct sdma_softc *sc)
 {
 	struct sdma_buffer_descriptor *bd0;
-	uint32_t *ram_code;
+	const uint32_t *ram_code;
 	int timeout;
 	int ret;
 	int chn;
 	int sz;
 	int i;
 
-	ram_code = (void *)((char *)sc->fw_header +
+	ram_code = (const void *)((const char *)sc->fw_header +
 			sc->fw_header->ram_code_start);
 
 	/* Make sure SDMA has not started yet */
@@ -515,4 +515,5 @@ static driver_t sdma_driver = {
 
 static devclass_t sdma_devclass;
 
-DRIVER_MODULE(sdma, simplebus, sdma_driver, sdma_devclass, 0, 0);
+EARLY_DRIVER_MODULE(sdma, simplebus, sdma_driver, sdma_devclass, 0, 0,
+    BUS_PASS_RESOURCE);

Modified: stable/11/sys/arm/freescale/imx/imx6_sdma.h
==============================================================================
--- stable/11/sys/arm/freescale/imx/imx6_sdma.h	Tue May  9 20:47:16 2017	(r318117)
+++ stable/11/sys/arm/freescale/imx/imx6_sdma.h	Tue May  9 21:25:49 2017	(r318118)
@@ -221,8 +221,8 @@ struct sdma_softc {
 	uint32_t			num_bd;
 	uint32_t			ccb_phys;
 	uint32_t			context_phys;
-	struct sdma_firmware_header	*fw_header;
-	struct sdma_script_start_addrs	*fw_scripts;
+	const struct sdma_firmware_header	*fw_header;
+	const struct sdma_script_start_addrs	*fw_scripts;
 };
 
 struct sdma_conf {

Modified: stable/11/sys/arm/freescale/imx/imx6_ssi.c
==============================================================================
--- stable/11/sys/arm/freescale/imx/imx6_ssi.c	Tue May  9 20:47:16 2017	(r318117)
+++ stable/11/sys/arm/freescale/imx/imx6_ssi.c	Tue May  9 21:25:49 2017	(r318118)
@@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$");
 	bus_space_write_4(_sc->bst, _sc->bsh, _reg, _val)
 
 #define	SSI_NCHANNELS	1
+#define	DMAS_TOTAL	8
 
 /* i.MX6 SSI registers */
 
@@ -188,8 +189,8 @@ struct sc_info {
 	struct sdma_conf	*conf;
 	struct ssi_rate		*sr;
 	struct sdma_softc	*sdma_sc;
-	int			sdma_ev_rx;
-	int			sdma_ev_tx;
+	uint32_t		sdma_ev_rx;
+	uint32_t		sdma_ev_tx;
 	int			sdma_channel;
 };
 
@@ -438,7 +439,7 @@ find_sdma_controller(struct sc_info *sc)
 	struct sdma_softc *sdma_sc;
 	phandle_t node, sdma_node;
 	device_t sdma_dev;
-	int dts_value[8];
+	pcell_t dts_value[DMAS_TOTAL];
 	int len;
 
 	if ((node = ofw_bus_get_node(sc->dev)) == -1)
@@ -447,7 +448,14 @@ find_sdma_controller(struct sc_info *sc)
 	if ((len = OF_getproplen(node, "dmas")) <= 0)
 		return (ENXIO);
 
-	OF_getencprop(node, "dmas", &dts_value, len);
+	if (len != sizeof(dts_value)) {
+		device_printf(sc->dev,
+		    "\"dmas\" property length is invalid: %d (expected %d)",
+		    len, sizeof(dts_value));
+		return (ENXIO);
+	}
+
+	OF_getencprop(node, "dmas", dts_value, sizeof(dts_value));
 
 	sc->sdma_ev_rx = dts_value[1];
 	sc->sdma_ev_tx = dts_value[5];
@@ -851,4 +859,5 @@ static driver_t ssi_pcm_driver = {
 
 DRIVER_MODULE(ssi, simplebus, ssi_pcm_driver, pcm_devclass, 0, 0);
 MODULE_DEPEND(ssi, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER);
+MODULE_DEPEND(ssi, sdma, 0, 0, 0);
 MODULE_VERSION(ssi, 1);



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