[PATCH 2/2] freebsd/if_cpsw: Port.

Christian Mauderer list at c-mauderer.de
Wed Dec 19 21:53:54 UTC 2018


From: Christian Mauderer <christian.mauderer at embedded-brains.de>

---
 freebsd/sys/arm/ti/cpsw/if_cpsw.c           | 21 +++++++++++++++++++++
 libbsd.py                                   |  3 +++
 rtemsbsd/include/bsp/nexus-devices.h        |  2 ++
 rtemsbsd/include/rtems/bsd/local/opt_cpsw.h |  0
 4 files changed, 26 insertions(+)
 create mode 100644 rtemsbsd/include/rtems/bsd/local/opt_cpsw.h

diff --git a/freebsd/sys/arm/ti/cpsw/if_cpsw.c b/freebsd/sys/arm/ti/cpsw/if_cpsw.c
index bd996f6d..1fbda688 100644
--- a/freebsd/sys/arm/ti/cpsw/if_cpsw.c
+++ b/freebsd/sys/arm/ti/cpsw/if_cpsw.c
@@ -375,6 +375,11 @@ cpsw_debugf(const char *fmt, ...)
 
 #define	cpsw_cpdma_bd_offset(i)	(CPSW_CPPI_RAM_OFFSET + ((i)*16))
 
+#ifdef __rtems__
+/* Missing in the bus.h provided by rtems. */
+#define BUS_SPACE_PHYSADDR(res, offs) \
+	((u_int)(rman_get_start(res)+(offs)))
+#endif /* __rtems__ */
 #define	cpsw_cpdma_bd_paddr(sc, slot)					\
 	BUS_SPACE_PHYSADDR(sc->mem_res, slot->bd_offset)
 #define	cpsw_cpdma_read_bd(sc, slot, val)				\
@@ -1751,7 +1756,9 @@ cpsw_rx_enqueue(struct cpsw_softc *sc)
 			break;
 		}
 
+#ifndef __rtems__
 		bus_dmamap_sync(sc->mbuf_dtag, slot->dmamap, BUS_DMASYNC_PREREAD);
+#endif /* __rtems__ */
 
 		/* Create and submit new rx descriptor. */
 		if ((next = STAILQ_NEXT(slot, next)) != NULL)
@@ -1763,6 +1770,10 @@ cpsw_rx_enqueue(struct cpsw_softc *sc)
 		bd.buflen = MCLBYTES - 1;
 		bd.pktlen = bd.buflen;
 		bd.flags = CPDMA_BD_OWNER;
+#ifdef __rtems__
+		rtems_cache_invalidate_multiple_data_lines(
+		    seg->ds_addr, bd.buflen);
+#endif /* __rtems__ */
 		cpsw_cpdma_write_bd(sc, slot, &bd);
 		++added;
 
@@ -1876,8 +1887,10 @@ cpswp_tx_enqueue(struct cpswp_softc *sc)
 			break;
 		}
 
+#ifndef __rtems__
 		bus_dmamap_sync(sc->swsc->mbuf_dtag, slot->dmamap,
 				BUS_DMASYNC_PREWRITE);
+#endif /* __rtems__ */
 
 		CPSW_DEBUGF(sc->swsc,
 		    ("Queueing TX packet: %d segments + %d pad bytes",
@@ -1910,6 +1923,10 @@ cpswp_tx_enqueue(struct cpswp_softc *sc)
 			bd.flags |= CPDMA_BD_TO_PORT;
 			bd.flags |= ((sc->unit + 1) & CPDMA_BD_PORT_MASK);
 		}
+#ifdef __rtems__
+		rtems_cache_flush_multiple_data_lines((void *)segs[0].ds_addr,
+		    segs[0].ds_len);
+#endif /* __rtems__ */
 		for (seg = 1; seg < nsegs; ++seg) {
 			/* Save the previous buffer (which isn't EOP) */
 			cpsw_cpdma_write_bd(sc->swsc, slot, &bd);
@@ -1928,6 +1945,10 @@ cpswp_tx_enqueue(struct cpswp_softc *sc)
 			bd.buflen = segs[seg].ds_len;
 			bd.pktlen = 0;
 			bd.flags = CPDMA_BD_OWNER;
+#ifdef __rtems__
+			rtems_cache_flush_multiple_data_lines(
+			    (void *)segs[seg].ds_addr, segs[seg].ds_len);
+#endif /* __rtems__ */
 		}
 
 		/* Save the final buffer. */
diff --git a/libbsd.py b/libbsd.py
index ca90f76d..021763cc 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -1335,6 +1335,8 @@ class dev_net(builder.Module):
         mm = self.manager
         self.addKernelSpaceHeaderFiles(
             [
+                'sys/arm/ti/cpsw/if_cpswreg.h',
+                'sys/arm/ti/cpsw/if_cpswvar.h',
                 'sys/arm/xilinx/zy7_slcr.h',
                 'sys/dev/cadence/if_cgem_hw.h',
                 'sys/dev/dwc/if_dwc.h',
@@ -1367,6 +1369,7 @@ class dev_net(builder.Module):
         )
         self.addKernelSpaceSourceFiles(
             [
+                'sys/arm/ti/cpsw/if_cpsw.c',
                 'sys/dev/ffec/if_ffec.c',
                 'sys/dev/mii/mii.c',
                 'sys/dev/mii/mii_bitbang.c',
diff --git a/rtemsbsd/include/bsp/nexus-devices.h b/rtemsbsd/include/bsp/nexus-devices.h
index 034e408a..a916c664 100644
--- a/rtemsbsd/include/bsp/nexus-devices.h
+++ b/rtemsbsd/include/bsp/nexus-devices.h
@@ -59,6 +59,8 @@ SYSINIT_DRIVER_REFERENCE(usbss, simplebus);
 SYSINIT_DRIVER_REFERENCE(musbotg, usbss);
 SYSINIT_DRIVER_REFERENCE(sdhci_ti, simplebus);
 SYSINIT_DRIVER_REFERENCE(mmcsd, mmc);
+SYSINIT_DRIVER_REFERENCE(cpsw, cpswss);
+SYSINIT_DRIVER_REFERENCE(ukphy, miibus);
 #ifdef RTEMS_BSD_MODULE_NET80211
 SYSINIT_DRIVER_REFERENCE(rtwn_usb, uhub);
 SYSINIT_MODULE_REFERENCE(wlan_ratectl_none);
diff --git a/rtemsbsd/include/rtems/bsd/local/opt_cpsw.h b/rtemsbsd/include/rtems/bsd/local/opt_cpsw.h
new file mode 100644
index 00000000..e69de29b
-- 
2.20.1




More information about the devel mailing list