<div><div>diff -ruN ./rtems-libbsd/freebsd/sys/arm/ti/cpsw/if_cpsw.c ./am335x_bsp/rtems-libbsd/freebsd/sys/arm/ti/cpsw/if_cpsw.c</div><div>--- ./rtems-libbsd/freebsd/sys/arm/ti/cpsw/if_cpsw.c<span class="Apple-tab-span" style="white-space:pre">  </span>1970-01-01 08:00:00.000000000 +0800</div><div>+++ ./am335x_bsp/rtems-libbsd/freebsd/sys/arm/ti/cpsw/if_cpsw.c<span class="Apple-tab-span" style="white-space:pre">   </span>2016-07-05 09:22:41.794327800 +0800</div><div>@@ -0,0 +1,2772 @@</div><div>+#include <machine/rtems-bsd-kernel-space.h></div><div>+/*-</div><div>+ * Copyright (c) 2012 Damjan Marion <dmarion@Freebsd.org></div><div>+ * Copyright (c) 2016 Rubicon Communications, LLC (Netgate)</div><div>+ * All rights reserved.</div><div>+ *</div><div>+ * Redistribution and use in source and binary forms, with or without</div><div>+ * modification, are permitted provided that the following conditions</div><div>+ * are met:</div><div>+ * 1. Redistributions of source code must retain the above copyright</div><div>+ *    notice, this list of conditions and the following disclaimer.</div><div>+ * 2. Redistributions in binary form must reproduce the above copyright</div><div>+ *    notice, this list of conditions and the following disclaimer in the</div><div>+ *    documentation and/or other materials provided with the distribution.</div><div>+ *</div><div>+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND</div><div>+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE</div><div>+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</div><div>+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE</div><div>+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</div><div>+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS</div><div>+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)</div><div>+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT</div><div>+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY</div><div>+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</div><div>+ * SUCH DAMAGE.</div><div>+ */</div><div>+</div><div>+/*</div><div>+ * TI Common Platform Ethernet Switch (CPSW) Driver</div><div>+ * Found in TI8148 "DaVinci" and AM335x "Sitara" SoCs.</div><div>+ *</div><div>+ * This controller is documented in the AM335x Technical Reference</div><div>+ * Manual, in the TMS320DM814x DaVinci Digital Video Processors TRM</div><div>+ * and in the TMS320C6452 3 Port Switch Ethernet Subsystem TRM.</div><div>+ *</div><div>+ * It is basically a single Ethernet port (port 0) wired internally to</div><div>+ * a 3-port store-and-forward switch connected to two independent</div><div>+ * "sliver" controllers (port 1 and port 2).  You can operate the</div><div>+ * controller in a variety of different ways by suitably configuring</div><div>+ * the slivers and the Address Lookup Engine (ALE) that routes packets</div><div>+ * between the ports.</div><div>+ *</div><div>+ * This code was developed and tested on a BeagleBone with</div><div>+ * an AM335x SoC.</div><div>+ */</div><div>+</div><div>+#include <sys/cdefs.h></div><div>+__FBSDID("$FreeBSD$");</div><div>+</div><div>+#include <rtems/bsd/sys/param.h></div><div>+#include <sys/systm.h></div><div>+#include <sys/endian.h></div><div>+#include <sys/mbuf.h></div><div>+#ifndef __rtems__</div><div>+#include <sys/lock.h></div><div>+#else</div><div>+#include <rtems/bsd/sys/lock.h></div><div>+#endif</div><div>+#include <sys/mutex.h></div><div>+#include <sys/kernel.h></div><div>+#include <sys/module.h></div><div>+#include <sys/socket.h></div><div>+#include <sys/sysctl.h></div><div>+</div><div>+#include <net/ethernet.h></div><div>+#include <net/bpf.h></div><div>+#include <net/if.h></div><div>+#include <net/if_arp.h></div><div>+#include <net/if_dl.h></div><div>+#include <net/if_media.h></div><div>+#include <net/if_types.h></div><div>+#include <net/if_var.h></div><div>+#include <net/if_vlan_var.h></div><div>+</div><div>+#include <netinet/in_systm.h></div><div>+#include <netinet/in.h></div><div>+#include <netinet/ip.h></div><div>+</div><div>+#include <sys/sockio.h></div><div>+#include <sys/bus.h></div><div>+#include <machine/bus.h></div><div>+#include <sys/rman.h></div><div>+#include <machine/resource.h></div><div>+</div><div>+#include <dev/mii/mii.h></div><div>+#include <dev/mii/miivar.h></div><div>+#ifndef __rtems__</div><div>+#include <dev/fdt/fdt_common.h></div><div>+#include <dev/ofw/ofw_bus.h></div><div>+#include <dev/ofw/ofw_bus_subr.h></div><div>+#endif</div><div>+#include "if_cpswreg.h"</div><div>+#include "if_cpswvar.h"</div><div>+#ifndef __rtems__ </div><div>+#include <arm/ti/ti_scm.h></div><div>+#endif</div><div>+#include <rtems/bsd/local/miibus_if.h></div><div>+#include <sys/malloc.h></div><div>+</div><div>+/* Device probe/attach/detach. */</div><div>+static int cpsw_probe(device_t);</div><div>+static void cpsw_init_slots(struct cpsw_softc *);</div><div>+static int cpsw_attach(device_t);</div><div>+static void cpsw_free_slot(struct cpsw_softc *, struct cpsw_slot *);</div><div>+static int cpsw_detach(device_t);</div><div>+</div><div>+/* Device probe/attach/detach. */</div><div>+static int cpswp_probe(device_t);</div><div>+static int cpswp_attach(device_t);</div><div>+static int cpswp_detach(device_t);</div><div>+#ifndef __rtems__ </div><div>+static phandle_t cpsw_get_node(device_t, device_t);</div><div>+#endif</div><div>+/* Device Init/shutdown. */</div><div>+static int cpsw_shutdown(device_t);</div><div>+static void cpswp_init(void *);</div><div>+static void cpswp_init_locked(void *);</div><div>+static void cpswp_stop_locked(struct cpswp_softc *);</div><div>+</div><div>+/* Device Suspend/Resume. */</div><div>+static int cpsw_suspend(device_t);</div><div>+static int cpsw_resume(device_t);</div><div>+</div><div>+/* Ioctl. */</div><div>+static int cpswp_ioctl(struct ifnet *, u_long command, caddr_t data);</div><div>+</div><div>+static int cpswp_miibus_readreg(device_t, int phy, int reg);</div><div>+static int cpswp_miibus_writereg(device_t, int phy, int reg, int value);</div><div>+static void cpswp_miibus_statchg(device_t);</div><div>+</div><div>+/* Send/Receive packets. */</div><div>+static void cpsw_intr_rx(void *arg);</div><div>+static struct mbuf *cpsw_rx_dequeue(struct cpsw_softc *);</div><div>+static void cpsw_rx_enqueue(struct cpsw_softc *);</div><div>+static void cpswp_start(struct ifnet *);</div><div>+static void cpswp_tx_enqueue(struct cpswp_softc *);</div><div>+static int cpsw_tx_dequeue(struct cpsw_softc *);</div><div>+</div><div>+/* Misc interrupts and watchdog. */</div><div>+static void cpsw_intr_rx_thresh(void *);</div><div>+static void cpsw_intr_misc(void *);</div><div>+static void cpswp_tick(void *);</div><div>+static void cpswp_ifmedia_sts(struct ifnet *, struct ifmediareq *);</div><div>+static int cpswp_ifmedia_upd(struct ifnet *);</div><div>+static void cpsw_tx_watchdog(void *);</div><div>+</div><div>+/* ALE support */</div><div>+static void cpsw_ale_read_entry(struct cpsw_softc *, uint16_t, uint32_t *);</div><div>+static void cpsw_ale_write_entry(struct cpsw_softc *, uint16_t, uint32_t *);</div><div>+static int cpsw_ale_mc_entry_set(struct cpsw_softc *, uint8_t, int, uint8_t *);</div><div>+static void cpsw_ale_dump_table(struct cpsw_softc *);</div><div>+static int cpsw_ale_update_vlan_table(struct cpsw_softc *, int, int, int);</div><div>+static int cpswp_ale_update_addresses(struct cpswp_softc *, int);</div><div>+</div><div>+/* Statistics and sysctls. */</div><div>+#ifndef __rtems__</div><div>+static void cpsw_add_sysctls(struct cpsw_softc *);</div><div>+static void cpsw_stats_collect(struct cpsw_softc *);</div><div>+static int cpsw_stats_sysctl(SYSCTL_HANDLER_ARGS);</div><div>+#endif</div><div>+</div><div>+/*</div><div>+ * Arbitrary limit on number of segments in an mbuf to be transmitted.</div><div>+ * Packets with more segments than this will be defragmented before</div><div>+ * they are queued.</div><div>+ */</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_TXFRAGS<span class="Apple-tab-span" style="white-space:pre">                </span>8</div><div>+</div><div>+/* Shared resources. */</div><div>+static device_method_t cpsw_methods[] = {</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>/* Device interface */</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>DEVMETHOD(device_probe,<span class="Apple-tab-span" style="white-space:pre">             </span>cpsw_probe),</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>DEVMETHOD(device_attach,<span class="Apple-tab-span" style="white-space:pre">    </span>cpsw_attach),</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>DEVMETHOD(device_detach,<span class="Apple-tab-span" style="white-space:pre">    </span>cpsw_detach),</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>DEVMETHOD(device_shutdown,<span class="Apple-tab-span" style="white-space:pre">  </span>cpsw_shutdown),</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>DEVMETHOD(device_suspend,<span class="Apple-tab-span" style="white-space:pre">   </span>cpsw_suspend),</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>DEVMETHOD(device_resume,<span class="Apple-tab-span" style="white-space:pre">    </span>cpsw_resume),</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>/* OFW methods */</div><div>+#ifndef __rtems__</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>DEVMETHOD(ofw_bus_get_node,<span class="Apple-tab-span" style="white-space:pre"> </span>cpsw_get_node),</div><div>+#endif<span class="Apple-tab-span" style="white-space:pre">       </span></div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>DEVMETHOD_END</div><div>+};</div><div>+</div><div>+static driver_t cpsw_driver = {</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>"cpsw",</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>cpsw_methods,</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>sizeof(struct cpsw_softc),</div><div>+};</div><div>+</div><div>+static devclass_t cpsw_devclass;</div><div>+</div><div>+#ifndef __rtems__</div><div>+DRIVER_MODULE(cpsw, simplebus, cpsw_driver, cpsw_devclass, 0, 0);</div><div>+#else</div><div>+DRIVER_MODULE(cpsw, nexus, cpsw_driver, cpsw_devclass, 0, 0);</div><div>+#endif</div><div>+/* Port/Slave resources. */</div><div>+static device_method_t cpswp_methods[] = {</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>/* Device interface */</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>DEVMETHOD(device_probe,<span class="Apple-tab-span" style="white-space:pre">             </span>cpswp_probe),</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>DEVMETHOD(device_attach,<span class="Apple-tab-span" style="white-space:pre">    </span>cpswp_attach),</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>DEVMETHOD(device_detach,<span class="Apple-tab-span" style="white-space:pre">    </span>cpswp_detach),</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>/* MII interface */</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>DEVMETHOD(miibus_readreg,<span class="Apple-tab-span" style="white-space:pre">   </span>cpswp_miibus_readreg),</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>DEVMETHOD(miibus_writereg,<span class="Apple-tab-span" style="white-space:pre">  </span>cpswp_miibus_writereg),</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>DEVMETHOD(miibus_statchg,<span class="Apple-tab-span" style="white-space:pre">   </span>cpswp_miibus_statchg),</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>DEVMETHOD_END</div><div>+};</div><div>+</div><div>+static driver_t cpswp_driver = {</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>"cpswp",</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>cpswp_methods,</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>sizeof(struct cpswp_softc),</div><div>+};</div><div>+</div><div>+static devclass_t cpswp_devclass;</div><div>+</div><div>+DRIVER_MODULE(cpswp, cpsw, cpswp_driver, cpswp_devclass, 0, 0);</div><div>+DRIVER_MODULE(miibus, cpswp, miibus_driver, miibus_devclass, 0, 0);</div><div>+MODULE_DEPEND(cpsw, ether, 1, 1, 1);</div><div>+MODULE_DEPEND(cpswp, miibus, 1, 1, 1);</div><div>+</div><div>+static uint32_t slave_mdio_addr[] = { 0x4a100200, 0x4a100300 };</div><div>+</div><div>+static struct resource_spec irq_res_spec[] = {</div><div>+#ifdef __rtems__</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>{ SYS_RES_MEMORY, 0, RF_ACTIVE },</div><div>+#endif</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>{ SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE },</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>{ SYS_RES_IRQ, 1, RF_ACTIVE | RF_SHAREABLE },</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>{ SYS_RES_IRQ, 2, RF_ACTIVE | RF_SHAREABLE },</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>{ SYS_RES_IRQ, 3, RF_ACTIVE | RF_SHAREABLE },</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>{ -1, 0 }</div><div>+};</div><div>+</div><div>+/* Number of entries here must match size of stats</div><div>+ * array in struct cpswp_softc. */</div><div>+static struct cpsw_stat {</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>int<span class="Apple-tab-span" style="white-space:pre"> </span>reg;</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>char *oid;</div><div>+} cpsw_stat_sysctls[CPSW_SYSCTL_COUNT] = {</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>{0x00, "GoodRxFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>{0x04, "BroadcastRxFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>{0x08, "MulticastRxFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>{0x0C, "PauseRxFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>{0x10, "RxCrcErrors"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>{0x14, "RxAlignErrors"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>{0x18, "OversizeRxFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>{0x1c, "RxJabbers"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>{0x20, "ShortRxFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>{0x24, "RxFragments"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>{0x30, "RxOctets"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>{0x34, "GoodTxFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>{0x38, "BroadcastTxFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>{0x3c, "MulticastTxFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>{0x40, "PauseTxFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>{0x44, "DeferredTxFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>{0x48, "CollisionsTxFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>{0x4c, "SingleCollisionTxFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>{0x50, "MultipleCollisionTxFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>{0x54, "ExcessiveCollisions"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>{0x58, "LateCollisions"},</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>{0x5c, "TxUnderrun"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>{0x60, "CarrierSenseErrors"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>{0x64, "TxOctets"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>{0x68, "RxTx64OctetFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>{0x6c, "RxTx65to127OctetFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>{0x70, "RxTx128to255OctetFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>{0x74, "RxTx256to511OctetFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>{0x78, "RxTx512to1024OctetFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>{0x7c, "RxTx1024upOctetFrames"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>{0x80, "NetOctets"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>{0x84, "RxStartOfFrameOverruns"},</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>{0x88, "RxMiddleOfFrameOverruns"},</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>{0x8c, "RxDmaOverruns"}</div><div>+};</div><div>+</div><div>+/*</div><div>+ * Basic debug support.</div><div>+ */</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span>IF_DEBUG(_sc)<span class="Apple-tab-span" style="white-space:pre">               </span>if ((_sc)->if_flags & IFF_DEBUG)</div><div>+</div><div>+static void</div><div>+cpsw_debugf_head(const char *funcname)</div><div>+{</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>int t = (int)(time_second % (24 * 60 * 60));</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>printf("%02d:%02d:%02d %s ", t / (60 * 60), (t / 60) % 60, t % 60, funcname);</div><div>+}</div><div>+</div><div>+#include <machine/stdarg.h></div><div>+static void</div><div>+cpsw_debugf(const char *fmt, ...)</div><div>+{</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>va_list ap;</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>va_start(ap, fmt);</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>vprintf(fmt, ap);</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>va_end(ap);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>printf("\n");</div><div>+</div><div>+}</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">     </span>CPSW_DEBUGF(_sc, a) do {<span class="Apple-tab-span" style="white-space:pre">                                    </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>if (sc->debug) {<span class="Apple-tab-span" style="white-space:pre">                                         </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>cpsw_debugf_head(__func__);<span class="Apple-tab-span" style="white-space:pre">                         </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>cpsw_debugf a;<span class="Apple-tab-span" style="white-space:pre">                                              </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>}<span class="Apple-tab-span" style="white-space:pre">                                                           </span>\</div><div>+} while (0)</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>CPSWP_DEBUGF(_sc, a) do {<span class="Apple-tab-span" style="white-space:pre">                                   </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>IF_DEBUG((_sc)) {<span class="Apple-tab-span" style="white-space:pre">                                           </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>cpsw_debugf_head(__func__);<span class="Apple-tab-span" style="white-space:pre">                         </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>cpsw_debugf a;<span class="Apple-tab-span" style="white-space:pre">                                              </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>}<span class="Apple-tab-span" style="white-space:pre">                                                           </span>\</div><div>+} while (0)</div><div>+</div><div>+</div><div>+/*</div><div>+ * Locking macros</div><div>+ */</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_TX_LOCK(sc) do {<span class="Apple-tab-span" style="white-space:pre">                                               </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>mtx_assert(&(sc)->rx.lock, MA_NOTOWNED);<span class="Apple-tab-span" style="white-space:pre">             </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>mtx_lock(&(sc)->tx.lock);<span class="Apple-tab-span" style="white-space:pre">                            </span>\</div><div>+} while (0)</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_TX_UNLOCK(sc)<span class="Apple-tab-span" style="white-space:pre">  </span>mtx_unlock(&(sc)->tx.lock)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">    </span>CPSW_TX_LOCK_ASSERT(sc)<span class="Apple-tab-span" style="white-space:pre">     </span>mtx_assert(&(sc)->tx.lock, MA_OWNED)</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">  </span>CPSW_RX_LOCK(sc) do {<span class="Apple-tab-span" style="white-space:pre">                                               </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>mtx_assert(&(sc)->tx.lock, MA_NOTOWNED);<span class="Apple-tab-span" style="white-space:pre">             </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>mtx_lock(&(sc)->rx.lock);<span class="Apple-tab-span" style="white-space:pre">                            </span>\</div><div>+} while (0)</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_RX_UNLOCK(sc)<span class="Apple-tab-span" style="white-space:pre">          </span>mtx_unlock(&(sc)->rx.lock)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">    </span>CPSW_RX_LOCK_ASSERT(sc)<span class="Apple-tab-span" style="white-space:pre">     </span>mtx_assert(&(sc)->rx.lock, MA_OWNED)</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">  </span>CPSW_GLOBAL_LOCK(sc) do {<span class="Apple-tab-span" style="white-space:pre">                                   </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>if ((mtx_owned(&(sc)->tx.lock) ? 1 : 0) !=<span class="Apple-tab-span" style="white-space:pre">           </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>    (mtx_owned(&(sc)->rx.lock) ? 1 : 0)) {<span class="Apple-tab-span" style="white-space:pre">         </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">                   </span>panic("cpsw deadlock possibility detection!");<span class="Apple-tab-span" style="white-space:pre">    </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>}<span class="Apple-tab-span" style="white-space:pre">                                                   </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>mtx_lock(&(sc)->tx.lock);<span class="Apple-tab-span" style="white-space:pre">                            </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>mtx_lock(&(sc)->rx.lock);<span class="Apple-tab-span" style="white-space:pre">                            </span>\</div><div>+} while (0)</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_GLOBAL_UNLOCK(sc) do {<span class="Apple-tab-span" style="white-space:pre">                                 </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>CPSW_RX_UNLOCK(sc);<span class="Apple-tab-span" style="white-space:pre">                                 </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>CPSW_TX_UNLOCK(sc);<span class="Apple-tab-span" style="white-space:pre">                                 </span>\</div><div>+} while (0)</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_GLOBAL_LOCK_ASSERT(sc) do {<span class="Apple-tab-span" style="white-space:pre">                            </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>CPSW_TX_LOCK_ASSERT(sc);<span class="Apple-tab-span" style="white-space:pre">                            </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>CPSW_RX_LOCK_ASSERT(sc);<span class="Apple-tab-span" style="white-space:pre">                            </span>\</div><div>+} while (0)</div><div>+</div><div>+#define CPSW_PORT_LOCK(_sc) do {<span class="Apple-tab-span" style="white-space:pre">                                        </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>mtx_assert(&(_sc)->lock, MA_NOTOWNED);<span class="Apple-tab-span" style="white-space:pre">                       </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>mtx_lock(&(_sc)->lock);<span class="Apple-tab-span" style="white-space:pre">                                      </span>\</div><div>+} while (0)</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_PORT_UNLOCK(_sc)<span class="Apple-tab-span" style="white-space:pre">       </span>mtx_unlock(&(_sc)->lock)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span>CPSW_PORT_LOCK_ASSERT(_sc)<span class="Apple-tab-span" style="white-space:pre">  </span>mtx_assert(&(_sc)->lock, MA_OWNED)</div><div>+</div><div>+/*</div><div>+ * Read/Write macros</div><div>+ */</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>cpsw_read_4(_sc, _reg)<span class="Apple-tab-span" style="white-space:pre">              </span>bus_read_4((_sc)->irq_res[0], (_reg))</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">     </span>cpsw_write_4(_sc, _reg, _val)<span class="Apple-tab-span" style="white-space:pre">                                       </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>bus_write_4((_sc)->irq_res[0], (_reg), (_val))</div><div>+</div><div>+#define BUS_SPACE_PHYSADDR(res, offs) \</div><div>+        ((u_int)(rman_get_start(res)+(offs)))</div><div>+#define CONTROL_MOD_BASE 0x44E10000</div><div>+#define CPSW_GMII_SEL<span class="Apple-tab-span" style="white-space:pre">                   </span>         (0x0650)</div><div>+/* GMII_SEL Register Field */</div><div>+#define GMIISEL_RMII2_IO_CLK_EN<span class="Apple-tab-span" style="white-space:pre">   </span>             (1UL<<(7))</div><div>+#define GMIISEL_RMII1_IO_CLK_EN<span class="Apple-tab-span" style="white-space:pre">  </span>             (1UL<<(6))</div><div>+#define GMIISEL_RGMII2_IDMODE<span class="Apple-tab-span" style="white-space:pre">    </span>             (1UL<<(5))</div><div>+#define GMIISEL_RGMII1_IDMODE<span class="Apple-tab-span" style="white-space:pre">    </span>             (1UL<<(4))</div><div>+#define GMIISEL_GMII2_SEL(val)<span class="Apple-tab-span" style="white-space:pre">   </span>             ((0x3 & (val)) << 2)</div><div>+#define GMIISEL_GMII1_SEL(val)<span class="Apple-tab-span" style="white-space:pre">     </span>             ((0x3 & (val)) << 0)</div><div>+#define GMII_MODE<span class="Apple-tab-span" style="white-space:pre">  </span>                              0</div><div>+#define RMII_MODE<span class="Apple-tab-span" style="white-space:pre"> </span>                              1</div><div>+#define RGMII_MODE<span class="Apple-tab-span" style="white-space:pre">        </span>                          2</div><div>+</div><div>+</div><div>+#define cm_read(a)    (*(volatile uint32_t *)(a))</div><div>+#define cm_write(a,v) (*(volatile uint32_t *)(a) = (v))</div><div>+</div><div>+</div><div>+</div><div>+</div><div>+</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>cpsw_cpdma_bd_offset(i)<span class="Apple-tab-span" style="white-space:pre">     </span>(CPSW_CPPI_RAM_OFFSET + ((i)*16))</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">    </span>cpsw_cpdma_bd_paddr(sc, slot)<span class="Apple-tab-span" style="white-space:pre">                                       </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>BUS_SPACE_PHYSADDR(sc->irq_res[0], slot->bd_offset)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">    </span>cpsw_cpdma_read_bd(sc, slot, val)<span class="Apple-tab-span" style="white-space:pre">                           </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>bus_read_region_4(sc->irq_res[0], slot->bd_offset, (uint32_t *) val, 4)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">        </span>cpsw_cpdma_write_bd(sc, slot, val)<span class="Apple-tab-span" style="white-space:pre">                          </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>bus_write_region_4(sc->irq_res[0], slot->bd_offset, (uint32_t *) val, 4)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>cpsw_cpdma_write_bd_next(sc, slot, next_slot)<span class="Apple-tab-span" style="white-space:pre">                       </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>cpsw_write_4(sc, slot->bd_offset, cpsw_cpdma_bd_paddr(sc, next_slot))</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">     </span>cpsw_cpdma_read_bd_flags(sc, slot)<span class="Apple-tab-span" style="white-space:pre">                          </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>bus_read_2(sc->irq_res[0], slot->bd_offset + 14)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>cpsw_write_hdp_slot(sc, queue, slot)<span class="Apple-tab-span" style="white-space:pre">                                </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>cpsw_write_4(sc, (queue)->hdp_offset, cpsw_cpdma_bd_paddr(sc, slot))</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span>CP_OFFSET (CPSW_CPDMA_TX_CP(0) - CPSW_CPDMA_TX_HDP(0))</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>cpsw_read_cp(sc, queue)<span class="Apple-tab-span" style="white-space:pre">                                             </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>cpsw_read_4(sc, (queue)->hdp_offset + CP_OFFSET) </div><div>+#define<span class="Apple-tab-span" style="white-space:pre">    </span>cpsw_write_cp(sc, queue, val)<span class="Apple-tab-span" style="white-space:pre">                                       </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>cpsw_write_4(sc, (queue)->hdp_offset + CP_OFFSET, (val))</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">  </span>cpsw_write_cp_slot(sc, queue, slot)<span class="Apple-tab-span" style="white-space:pre">                         </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>cpsw_write_cp(sc, queue, cpsw_cpdma_bd_paddr(sc, slot))</div><div>+</div><div>+#if 0</div><div>+/* XXX temporary function versions for debugging. */</div><div>+static void</div><div>+cpsw_write_hdp_slotX(struct cpsw_softc *sc, struct cpsw_queue *queue, struct cpsw_slot *slot)</div><div>+{</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>uint32_t reg = queue->hdp_offset;</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>uint32_t v = cpsw_cpdma_bd_paddr(sc, slot);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_DEBUGF(("HDP <=== 0x%08x (was 0x%08x)", v, cpsw_read_4(sc, reg)));</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>cpsw_write_4(sc, reg, v);</div><div>+}</div><div>+static void</div><div>+cpsw_write_cp_slotX(struct cpsw_softc *sc, struct cpsw_queue *queue, struct cpsw_slot *slot)</div><div>+{</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>uint32_t v = cpsw_cpdma_bd_paddr(sc, slot);</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_DEBUGF(("CP <=== 0x%08x (expecting 0x%08x)", v, cpsw_read_cp(sc, queue)));</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>cpsw_write_cp(sc, queue, v);</div><div>+}</div><div>+#endif</div><div>+</div><div>+/*</div><div>+ * Expanded dump routines for verbose debugging.</div><div>+ */</div><div>+static void</div><div>+cpsw_dump_slot(struct cpsw_softc *sc, struct cpsw_slot *slot)</div><div>+{</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>static const char *flags[] = {"SOP", "EOP", "Owner", "EOQ",</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>    "TDownCmplt", "PassCRC", "Long", "Short", "MacCtl", "Overrun",</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>    "PktErr1", "PortEn/PktErr0", "RxVlanEncap", "Port2", "Port1",</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>    "Port0"};</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>struct cpsw_cpdma_bd bd;</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>const char *sep;</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>int i;</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>cpsw_cpdma_read_bd(sc, slot, &bd);</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>printf("BD Addr: 0x%08x   Next: 0x%08x\n", cpsw_cpdma_bd_paddr(sc, slot), bd.next);</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>printf("  BufPtr: 0x%08x   BufLen: 0x%08x\n", bd.bufptr, bd.buflen);</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>printf("  BufOff: 0x%08x   PktLen: 0x%08x\n", bd.bufoff, bd.pktlen);</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>printf("  Flags: ");</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>sep = "";</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>for (i = 0; i < 16; ++i) {</div><div>+<span class="Apple-tab-span" style="white-space:pre">               </span>if (bd.flags & (1 << (15 - i))) {</div><div>+<span class="Apple-tab-span" style="white-space:pre">                 </span>printf("%s%s", sep, flags[i]);</div><div>+<span class="Apple-tab-span" style="white-space:pre">                    </span>sep = ",";</div><div>+<span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>}</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>printf("\n");</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>if (slot->mbuf) {</div><div>+<span class="Apple-tab-span" style="white-space:pre">                </span>printf("  Ether:  %14D\n",</div><div>+<span class="Apple-tab-span" style="white-space:pre">              </span>    (char *)(slot->mbuf->m_data), " ");</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>printf("  Packet: %16D\n",</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>    (char *)(slot->mbuf->m_data) + 14, " ");</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>}</div><div>+}</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_DUMP_SLOT(cs, slot) do {<span class="Apple-tab-span" style="white-space:pre">                               </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>IF_DEBUG(sc) {<span class="Apple-tab-span" style="white-space:pre">                                              </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>cpsw_dump_slot(sc, slot);<span class="Apple-tab-span" style="white-space:pre">                   </span>\</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>}<span class="Apple-tab-span" style="white-space:pre">                                                   </span>\</div><div>+} while (0)</div><div>+</div><div>+static void</div><div>+cpsw_dump_queue(struct cpsw_softc *sc, struct cpsw_slots *q)</div><div>+{</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>struct cpsw_slot *slot;</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>int i = 0;</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>int others = 0;</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>STAILQ_FOREACH(slot, q, next) {</div><div>+<span class="Apple-tab-span" style="white-space:pre">             </span>if (i > 4)</div><div>+<span class="Apple-tab-span" style="white-space:pre">                       </span>++others;</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>else</div><div>+<span class="Apple-tab-span" style="white-space:pre">                        </span>cpsw_dump_slot(sc, slot);</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>++i;</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>if (others)</div><div>+<span class="Apple-tab-span" style="white-space:pre">         </span>printf(" ... and %d more.\n", others);</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>printf("\n");</div><div>+}</div></div><div><div><br></div><div><br></div><div style="font-size: 12px;font-family: Arial Narrow;padding:2px 0 2px 0;">------------------ Original ------------------</div><div style="font-size: 12px;background:#efefef;padding:8px;"><div><b>From: </b> "yao0718";<29171383@qq.com>;</div><div><b>Date: </b> Tue, Jul 5, 2016 03:15 PM</div><div><b>To: </b> "devel"<devel@rtems.org>; <wbr></div><div></div><div><b>Subject: </b> Re: [2/6] add ti cpsw head file</div></div><div><br></div><div><div>diff -ruN ./rtems-libbsd/freebsd/sys/arm/ti/cpsw/if_cpswreg.h ./am335x_bsp/rtems-libbsd/freebsd/sys/arm/ti/cpsw/if_cpswreg.h</div><div>--- ./rtems-libbsd/freebsd/sys/arm/ti/cpsw/if_cpswreg.h<span class="Apple-tab-span" style="white-space:pre">    </span>1970-01-01 08:00:00.000000000 +0800</div><div>+++ ./am335x_bsp/rtems-libbsd/freebsd/sys/arm/ti/cpsw/if_cpswreg.h<span class="Apple-tab-span" style="white-space:pre">        </span>2016-03-18 11:38:45.324075400 +0800</div><div>@@ -0,0 +1,178 @@</div><div>+/*-</div><div>+ * Copyright (c) 2012 Damjan Marion <dmarion@Freebsd.org></div><div>+ * All rights reserved.</div><div>+ *</div><div>+ * Redistribution and use in source and binary forms, with or without</div><div>+ * modification, are permitted provided that the following conditions</div><div>+ * are met:</div><div>+ * 1. Redistributions of source code must retain the above copyright</div><div>+ *    notice, this list of conditions and the following disclaimer.</div><div>+ * 2. Redistributions in binary form must reproduce the above copyright</div><div>+ *    notice, this list of conditions and the following disclaimer in the</div><div>+ *    documentation and/or other materials provided with the distribution.</div><div>+ *</div><div>+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND</div><div>+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE</div><div>+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</div><div>+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE</div><div>+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</div><div>+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS</div><div>+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)</div><div>+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT</div><div>+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY</div><div>+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</div><div>+ * SUCH DAMAGE.</div><div>+ *</div><div>+ * $FreeBSD$</div><div>+ */</div><div>+</div><div>+#ifndef<span class="Apple-tab-span" style="white-space:pre">   </span>_IF_CPSWREG_H</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">        </span>_IF_CPSWREG_H</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">        </span>CPSW_SS_OFFSET<span class="Apple-tab-span" style="white-space:pre">                      </span>0x0000</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_SS_IDVER<span class="Apple-tab-span" style="white-space:pre">                       </span>(CPSW_SS_OFFSET + 0x00)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span>CPSW_SS_SOFT_RESET<span class="Apple-tab-span" style="white-space:pre">          </span>(CPSW_SS_OFFSET + 0x08)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span>CPSW_SS_STAT_PORT_EN<span class="Apple-tab-span" style="white-space:pre">                </span>(CPSW_SS_OFFSET + 0x0C)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span>CPSW_SS_PTYPE<span class="Apple-tab-span" style="white-space:pre">                       </span>(CPSW_SS_OFFSET + 0x10)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span>CPSW_SS_FLOW_CONTROL<span class="Apple-tab-span" style="white-space:pre">                </span>(CPSW_SS_OFFSET + 0x24)</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span>CPSW_PORT_OFFSET<span class="Apple-tab-span" style="white-space:pre">            </span>0x0100</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_PORT_P_MAX_BLKS(p)<span class="Apple-tab-span" style="white-space:pre">             </span>(CPSW_PORT_OFFSET + 0x08 + ((p) * 0x100))</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">    </span>CPSW_PORT_P_BLK_CNT(p)<span class="Apple-tab-span" style="white-space:pre">              </span>(CPSW_PORT_OFFSET + 0x0C + ((p) * 0x100))</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">    </span>CPSW_PORT_P_VLAN(p)<span class="Apple-tab-span" style="white-space:pre">         </span>(CPSW_PORT_OFFSET + 0x14 + ((p) * 0x100))</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">    </span>CPSW_PORT_P_TX_PRI_MAP(p)<span class="Apple-tab-span" style="white-space:pre">   </span>(CPSW_PORT_OFFSET + 0x118 + ((p-1) * 0x100))</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_PORT_P0_CPDMA_TX_PRI_MAP<span class="Apple-tab-span" style="white-space:pre">       </span>(CPSW_PORT_OFFSET + 0x01C)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_PORT_P0_CPDMA_RX_CH_MAP<span class="Apple-tab-span" style="white-space:pre">        </span>(CPSW_PORT_OFFSET + 0x020)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_PORT_P_SA_LO(p)<span class="Apple-tab-span" style="white-space:pre">                </span>(CPSW_PORT_OFFSET + 0x120 + ((p-1) * 0x100))</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_PORT_P_SA_HI(p)<span class="Apple-tab-span" style="white-space:pre">                </span>(CPSW_PORT_OFFSET + 0x124 + ((p-1) * 0x100))</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_CPDMA_OFFSET<span class="Apple-tab-span" style="white-space:pre">           </span>0x0800</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_CPDMA_TX_CONTROL<span class="Apple-tab-span" style="white-space:pre">               </span>(CPSW_CPDMA_OFFSET + 0x04)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_TX_TEARDOWN<span class="Apple-tab-span" style="white-space:pre">              </span>(CPSW_CPDMA_OFFSET + 0x08)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_RX_CONTROL<span class="Apple-tab-span" style="white-space:pre">               </span>(CPSW_CPDMA_OFFSET + 0x14)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_RX_TEARDOWN<span class="Apple-tab-span" style="white-space:pre">              </span>(CPSW_CPDMA_OFFSET + 0x18)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_SOFT_RESET<span class="Apple-tab-span" style="white-space:pre">               </span>(CPSW_CPDMA_OFFSET + 0x1c)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_DMACONTROL<span class="Apple-tab-span" style="white-space:pre">               </span>(CPSW_CPDMA_OFFSET + 0x20)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_DMASTATUS<span class="Apple-tab-span" style="white-space:pre">                </span>(CPSW_CPDMA_OFFSET + 0x24)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_RX_BUFFER_OFFSET<span class="Apple-tab-span" style="white-space:pre"> </span>(CPSW_CPDMA_OFFSET + 0x28)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_TX_INTSTAT_RAW<span class="Apple-tab-span" style="white-space:pre">   </span>(CPSW_CPDMA_OFFSET + 0x80)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_TX_INTSTAT_MASKED<span class="Apple-tab-span" style="white-space:pre">        </span>(CPSW_CPDMA_OFFSET + 0x84)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_TX_INTMASK_SET<span class="Apple-tab-span" style="white-space:pre">   </span>(CPSW_CPDMA_OFFSET + 0x88)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_TX_INTMASK_CLEAR<span class="Apple-tab-span" style="white-space:pre"> </span>(CPSW_CPDMA_OFFSET + 0x8C)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_CPDMA_EOI_VECTOR<span class="Apple-tab-span" style="white-space:pre"> </span>(CPSW_CPDMA_OFFSET + 0x94)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_RX_INTSTAT_RAW<span class="Apple-tab-span" style="white-space:pre">   </span>(CPSW_CPDMA_OFFSET + 0xA0)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_RX_INTSTAT_MASKED<span class="Apple-tab-span" style="white-space:pre">        </span>(CPSW_CPDMA_OFFSET + 0xA4)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_RX_INTMASK_SET<span class="Apple-tab-span" style="white-space:pre">   </span>(CPSW_CPDMA_OFFSET + 0xA8)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_RX_INTMASK_CLEAR<span class="Apple-tab-span" style="white-space:pre"> </span>(CPSW_CPDMA_OFFSET + 0xAc)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_DMA_INTSTAT_RAW<span class="Apple-tab-span" style="white-space:pre">  </span>(CPSW_CPDMA_OFFSET + 0xB0)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_DMA_INTSTAT_MASKED<span class="Apple-tab-span" style="white-space:pre">       </span>(CPSW_CPDMA_OFFSET + 0xB4)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_DMA_INTMASK_SET<span class="Apple-tab-span" style="white-space:pre">  </span>(CPSW_CPDMA_OFFSET + 0xB8)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_DMA_INTMASK_CLEAR<span class="Apple-tab-span" style="white-space:pre">        </span>(CPSW_CPDMA_OFFSET + 0xBC)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_CPDMA_RX_FREEBUFFER(p)<span class="Apple-tab-span" style="white-space:pre"> </span>(CPSW_CPDMA_OFFSET + 0x0e0 + ((p) * 0x04))</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_STATS_OFFSET<span class="Apple-tab-span" style="white-space:pre">           </span>0x0900</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_STATERAM_OFFSET<span class="Apple-tab-span" style="white-space:pre">                </span>0x0A00</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_CPDMA_TX_HDP(p)<span class="Apple-tab-span" style="white-space:pre">                </span>(CPSW_STATERAM_OFFSET + 0x00 + ((p) * 0x04))</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_CPDMA_RX_HDP(p)<span class="Apple-tab-span" style="white-space:pre">                </span>(CPSW_STATERAM_OFFSET + 0x20 + ((p) * 0x04))</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_CPDMA_TX_CP(p)<span class="Apple-tab-span" style="white-space:pre">         </span>(CPSW_STATERAM_OFFSET + 0x40 + ((p) * 0x04))</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_CPDMA_RX_CP(p)<span class="Apple-tab-span" style="white-space:pre">         </span>(CPSW_STATERAM_OFFSET + 0x60 + ((p) * 0x04))</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_CPTS_OFFSET<span class="Apple-tab-span" style="white-space:pre">            </span>0x0C00</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_ALE_OFFSET<span class="Apple-tab-span" style="white-space:pre">                     </span>0x0D00</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_ALE_CONTROL<span class="Apple-tab-span" style="white-space:pre">            </span>(CPSW_ALE_OFFSET + 0x08)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">     </span> CPSW_ALE_CTL_ENABLE<span class="Apple-tab-span" style="white-space:pre">                </span>(1U << 31)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">     </span> CPSW_ALE_CTL_CLEAR_TBL<span class="Apple-tab-span" style="white-space:pre">             </span>(1 << 30)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span> CPSW_ALE_CTL_BYPASS<span class="Apple-tab-span" style="white-space:pre">                </span>(1 << 4)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span> CPSW_ALE_CTL_VLAN_AWARE<span class="Apple-tab-span" style="white-space:pre">    </span>(1 << 2)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_ALE_TBLCTL<span class="Apple-tab-span" style="white-space:pre">                     </span>(CPSW_ALE_OFFSET + 0x20)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">     </span>CPSW_ALE_TBLW2<span class="Apple-tab-span" style="white-space:pre">                      </span>(CPSW_ALE_OFFSET + 0x34)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">     </span>CPSW_ALE_TBLW1<span class="Apple-tab-span" style="white-space:pre">                      </span>(CPSW_ALE_OFFSET + 0x38)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">     </span>CPSW_ALE_TBLW0<span class="Apple-tab-span" style="white-space:pre">                      </span>(CPSW_ALE_OFFSET + 0x3C)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">     </span> ALE_MCAST(_a)<span class="Apple-tab-span" style="white-space:pre">                      </span>((_a[1] >> 8) & 1)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span> ALE_MCAST_FWD<span class="Apple-tab-span" style="white-space:pre">                      </span>(3 << 30)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span> ALE_PORTS(_a)<span class="Apple-tab-span" style="white-space:pre">                      </span>((_a[2] >> 2) & 7)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span> ALE_TYPE(_a)<span class="Apple-tab-span" style="white-space:pre">                       </span>((_a[1] >> 28) & 3)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">        </span> ALE_TYPE_ADDR<span class="Apple-tab-span" style="white-space:pre">                      </span>1</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">    </span> ALE_TYPE_VLAN<span class="Apple-tab-span" style="white-space:pre">                      </span>2</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">    </span> ALE_TYPE_VLAN_ADDR<span class="Apple-tab-span" style="white-space:pre">         </span>3</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">    </span> ALE_VLAN(_a)<span class="Apple-tab-span" style="white-space:pre">                       </span>((_a[1] >> 16) & 0xfff)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">    </span> ALE_VLAN_REGFLOOD(_a)<span class="Apple-tab-span" style="white-space:pre">              </span>((_a[0] >> 8) & 7)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span> ALE_VLAN_UNREGFLOOD(_a)<span class="Apple-tab-span" style="white-space:pre">    </span>((_a[0] >> 16) & 7)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">        </span> ALE_VLAN_UNTAG(_a)<span class="Apple-tab-span" style="white-space:pre">         </span>((_a[0] >> 24) & 7)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">        </span> ALE_VLAN_MEMBERS(_a)<span class="Apple-tab-span" style="white-space:pre">               </span>(_a[0] & 7)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span>CPSW_ALE_PORTCTL(p)<span class="Apple-tab-span" style="white-space:pre">         </span>(CPSW_ALE_OFFSET + 0x40 + ((p) * 0x04))</div><div>+</div><div>+/* SL1 is at 0x0D80, SL2 is at 0x0DC0 */</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span>CPSW_SL_OFFSET<span class="Apple-tab-span" style="white-space:pre">                      </span>0x0D80</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_SL_MACCONTROL(p)<span class="Apple-tab-span" style="white-space:pre">               </span>(CPSW_SL_OFFSET + (0x40 * (p)) + 0x04)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span> CPSW_SL_MACTL_IFCTL_B<span class="Apple-tab-span" style="white-space:pre">              </span>(1 << 16)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span> CPSW_SL_MACTL_IFCTL_A<span class="Apple-tab-span" style="white-space:pre">              </span>(1 << 15)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span> CPSW_SL_MACTL_GIG<span class="Apple-tab-span" style="white-space:pre">          </span>(1 << 7)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span> CPSW_SL_MACTL_GMII_ENABLE<span class="Apple-tab-span" style="white-space:pre">  </span>(1 << 5)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span> CPSW_SL_MACTL_FULLDUPLEX<span class="Apple-tab-span" style="white-space:pre">   </span>(1 << 0)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_SL_MACSTATUS(p)<span class="Apple-tab-span" style="white-space:pre">                </span>(CPSW_SL_OFFSET + (0x40 * (p)) + 0x08)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_SL_SOFT_RESET(p)<span class="Apple-tab-span" style="white-space:pre">               </span>(CPSW_SL_OFFSET + (0x40 * (p)) + 0x0C)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_SL_RX_MAXLEN(p)<span class="Apple-tab-span" style="white-space:pre">                </span>(CPSW_SL_OFFSET + (0x40 * (p)) + 0x10)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_SL_RX_PAUSE(p)<span class="Apple-tab-span" style="white-space:pre">         </span>(CPSW_SL_OFFSET + (0x40 * (p)) + 0x18)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_SL_TX_PAUSE(p)<span class="Apple-tab-span" style="white-space:pre">         </span>(CPSW_SL_OFFSET + (0x40 * (p)) + 0x1C)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_SL_RX_PRI_MAP(p)<span class="Apple-tab-span" style="white-space:pre">               </span>(CPSW_SL_OFFSET + (0x40 * (p)) + 0x24)</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>MDIO_OFFSET<span class="Apple-tab-span" style="white-space:pre">                 </span>0x1000</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>MDIOCONTROL<span class="Apple-tab-span" style="white-space:pre">                 </span>(MDIO_OFFSET + 0x04)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span> MDIOCTL_ENABLE<span class="Apple-tab-span" style="white-space:pre">                     </span>(1 << 30)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span> MDIOCTL_FAULTENB<span class="Apple-tab-span" style="white-space:pre">           </span>(1 << 18)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span>MDIOLINKINTRAW<span class="Apple-tab-span" style="white-space:pre">                      </span>(MDIO_OFFSET + 0x10)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>MDIOLINKINTMASKED<span class="Apple-tab-span" style="white-space:pre">           </span>(MDIO_OFFSET + 0x14)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>MDIOUSERACCESS0<span class="Apple-tab-span" style="white-space:pre">                     </span>(MDIO_OFFSET + 0x80)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>MDIOUSERPHYSEL0<span class="Apple-tab-span" style="white-space:pre">                     </span>(MDIO_OFFSET + 0x84)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>MDIOUSERACCESS1<span class="Apple-tab-span" style="white-space:pre">                     </span>(MDIO_OFFSET + 0x88)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>MDIOUSERPHYSEL1<span class="Apple-tab-span" style="white-space:pre">                     </span>(MDIO_OFFSET + 0x8C)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span> MDIO_PHYSEL_LINKINTENB<span class="Apple-tab-span" style="white-space:pre">             </span>(1 << 6)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span> MDIO_PHYACCESS_GO<span class="Apple-tab-span" style="white-space:pre">          </span>(1U << 31)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">     </span> MDIO_PHYACCESS_WRITE<span class="Apple-tab-span" style="white-space:pre">               </span>(1 << 30)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span> MDIO_PHYACCESS_ACK<span class="Apple-tab-span" style="white-space:pre">         </span>(1 << 29)</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span>CPSW_WR_OFFSET<span class="Apple-tab-span" style="white-space:pre">                      </span>0x1200</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_WR_SOFT_RESET<span class="Apple-tab-span" style="white-space:pre">          </span>(CPSW_WR_OFFSET + 0x04)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span>CPSW_WR_CONTROL<span class="Apple-tab-span" style="white-space:pre">                     </span>(CPSW_WR_OFFSET + 0x08)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span>CPSW_WR_INT_CONTROL<span class="Apple-tab-span" style="white-space:pre">         </span>(CPSW_WR_OFFSET + 0x0c)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span>CPSW_WR_C_RX_THRESH_EN(p)<span class="Apple-tab-span" style="white-space:pre">   </span>(CPSW_WR_OFFSET + (0x10 * (p)) + 0x10)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_WR_C_RX_EN(p)<span class="Apple-tab-span" style="white-space:pre">          </span>(CPSW_WR_OFFSET + (0x10 * (p)) + 0x14)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_WR_C_TX_EN(p)<span class="Apple-tab-span" style="white-space:pre">          </span>(CPSW_WR_OFFSET + (0x10 * (p)) + 0x18)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_WR_C_MISC_EN(p)<span class="Apple-tab-span" style="white-space:pre">                </span>(CPSW_WR_OFFSET + (0x10 * (p)) + 0x1C)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_WR_C_RX_THRESH_STAT(p)<span class="Apple-tab-span" style="white-space:pre"> </span>(CPSW_WR_OFFSET + (0x10 * (p)) + 0x40)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_WR_C_RX_STAT(p)<span class="Apple-tab-span" style="white-space:pre">                </span>(CPSW_WR_OFFSET + (0x10 * (p)) + 0x44)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_WR_C_TX_STAT(p)<span class="Apple-tab-span" style="white-space:pre">                </span>(CPSW_WR_OFFSET + (0x10 * (p)) + 0x48)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_WR_C_MISC_STAT(p)<span class="Apple-tab-span" style="white-space:pre">              </span>(CPSW_WR_OFFSET + (0x10 * (p)) + 0x4C)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span> CPSW_WR_C_MISC_EVNT_PEND<span class="Apple-tab-span" style="white-space:pre">   </span>(1 << 4)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span> CPSW_WR_C_MISC_STAT_PEND<span class="Apple-tab-span" style="white-space:pre">   </span>(1 << 3)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span> CPSW_WR_C_MISC_HOST_PEND<span class="Apple-tab-span" style="white-space:pre">   </span>(1 << 2)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span> CPSW_WR_C_MISC_MDIOLINK<span class="Apple-tab-span" style="white-space:pre">    </span>(1 << 1)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span> CPSW_WR_C_MISC_MDIOUSER<span class="Apple-tab-span" style="white-space:pre">    </span>(1 << 0)</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_CPPI_RAM_OFFSET<span class="Apple-tab-span" style="white-space:pre">                </span>0x2000</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_CPPI_RAM_SIZE<span class="Apple-tab-span" style="white-space:pre">          </span>0x2000</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span>CPSW_MEMWINDOW_SIZE<span class="Apple-tab-span" style="white-space:pre">         </span>0x4000</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span> CPDMA_BD_SOP<span class="Apple-tab-span" style="white-space:pre">                       </span>(1 << 15)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span> CPDMA_BD_EOP<span class="Apple-tab-span" style="white-space:pre">                       </span>(1 << 14)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span> CPDMA_BD_OWNER<span class="Apple-tab-span" style="white-space:pre">                     </span>(1 << 13)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span> CPDMA_BD_EOQ<span class="Apple-tab-span" style="white-space:pre">                       </span>(1 << 12)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span> CPDMA_BD_TDOWNCMPLT<span class="Apple-tab-span" style="white-space:pre">                </span>(1 << 11)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">      </span> CPDMA_BD_PKT_ERR_MASK<span class="Apple-tab-span" style="white-space:pre">              </span>(3 << 4)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span> CPDMA_BD_TO_PORT<span class="Apple-tab-span" style="white-space:pre">           </span>(1 << 4)</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">       </span> CPDMA_BD_PORT_MASK<span class="Apple-tab-span" style="white-space:pre">         </span>3</div><div>+</div><div>+struct cpsw_cpdma_bd {</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>volatile uint32_t next;</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>volatile uint32_t bufptr;</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>volatile uint16_t buflen;</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>volatile uint16_t bufoff;</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>volatile uint16_t pktlen;</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>volatile uint16_t flags;</div><div>+};</div><div>+</div><div>+#endif /*_IF_CPSWREG_H */</div><div><br></div><div>diff -ruN ./rtems-libbsd/freebsd/sys/arm/ti/cpsw/if_cpswvar.h ./am335x_bsp/rtems-libbsd/freebsd/sys/arm/ti/cpsw/if_cpswvar.h</div><div>--- ./rtems-libbsd/freebsd/sys/arm/ti/cpsw/if_cpswvar.h<span class="Apple-tab-span" style="white-space:pre">       </span>1970-01-01 08:00:00.000000000 +0800</div><div>+++ ./am335x_bsp/rtems-libbsd/freebsd/sys/arm/ti/cpsw/if_cpswvar.h<span class="Apple-tab-span" style="white-space:pre">        </span>2016-07-02 21:43:26.205209800 +0800</div><div>@@ -0,0 +1,147 @@</div><div>+/*-</div><div>+ * Copyright (c) 2012 Damjan Marion <dmarion@Freebsd.org></div><div>+ * All rights reserved.</div><div>+ *</div><div>+ * Redistribution and use in source and binary forms, with or without</div><div>+ * modification, are permitted provided that the following conditions</div><div>+ * are met:</div><div>+ * 1. Redistributions of source code must retain the above copyright</div><div>+ *    notice, this list of conditions and the following disclaimer.</div><div>+ * 2. Redistributions in binary form must reproduce the above copyright</div><div>+ *    notice, this list of conditions and the following disclaimer in the</div><div>+ *    documentation and/or other materials provided with the distribution.</div><div>+ *</div><div>+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND</div><div>+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE</div><div>+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</div><div>+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE</div><div>+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</div><div>+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS</div><div>+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)</div><div>+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT</div><div>+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY</div><div>+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</div><div>+ * SUCH DAMAGE.</div><div>+ *</div><div>+ * $FreeBSD$</div><div>+ */</div><div>+</div><div>+#ifndef<span class="Apple-tab-span" style="white-space:pre">   </span>_IF_CPSWVAR_H</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">        </span>_IF_CPSWVAR_H</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">        </span>CPSW_PORTS<span class="Apple-tab-span" style="white-space:pre">          </span>2</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">    </span>CPSW_INTR_COUNT<span class="Apple-tab-span" style="white-space:pre">             </span>4</div><div>+</div><div>+/* MII BUS  */</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_MIIBUS_RETRIES<span class="Apple-tab-span" style="white-space:pre"> </span>10</div><div>+#define<span class="Apple-tab-span" style="white-space:pre">   </span>CPSW_MIIBUS_DELAY<span class="Apple-tab-span" style="white-space:pre">   </span>2000</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_MAX_ALE_ENTRIES<span class="Apple-tab-span" style="white-space:pre">        </span>1024</div><div>+</div><div>+#define<span class="Apple-tab-span" style="white-space:pre"> </span>CPSW_SYSCTL_COUNT<span class="Apple-tab-span" style="white-space:pre">   </span>34</div><div>+</div><div>+#define CPSW_RESEMBLE_BUFFER_LEN  2048</div><div>+#define CPSW_RESEMBLE_BUFFER_ALIGN 4</div><div>+struct cpsw_slot {</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>uint32_t bd_offset;  /* Offset of corresponding BD within CPPI RAM. */</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>bus_dmamap_t dmamap;</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>struct mbuf *mbuf;</div><div>+/* yao0718 add  why cppi dma can not send when address misalign 32 bits*/</div><div>+    uint8_t  *resemble;</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>uint8_t  *align_res;</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>STAILQ_ENTRY(cpsw_slot) next;</div><div>+};</div><div>+STAILQ_HEAD(cpsw_slots, cpsw_slot);</div><div>+</div><div>+struct cpsw_queue {</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>struct mtx<span class="Apple-tab-span" style="white-space:pre">  </span>lock;</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>running;</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>struct cpsw_slots active;</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>struct cpsw_slots avail;</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>uint32_t<span class="Apple-tab-span" style="white-space:pre">    </span>queue_adds; /* total bufs added */</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>uint32_t<span class="Apple-tab-span" style="white-space:pre">    </span>queue_removes; /* total bufs removed */</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>uint32_t<span class="Apple-tab-span" style="white-space:pre">    </span>queue_removes_at_last_tick; /* Used by watchdog */</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>queue_slots;</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>active_queue_len;</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>max_active_queue_len;</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>avail_queue_len;</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>max_avail_queue_len;</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>longest_chain; /* Largest # segments in a single packet. */</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>hdp_offset;</div><div>+};</div><div>+</div><div>+struct cpsw_port {</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>device_t<span class="Apple-tab-span" style="white-space:pre">    </span>dev;</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>phy;</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>vlan;</div><div>+};</div><div>+</div><div>+struct cpsw_softc {</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>device_t<span class="Apple-tab-span" style="white-space:pre">    </span>dev;</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>active_slave;</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>debug;</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>dualemac;</div><div>+#ifndef __rtems__</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>phandle_t<span class="Apple-tab-span" style="white-space:pre">   </span>node;</div><div>+#endif</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>struct bintime<span class="Apple-tab-span" style="white-space:pre">      </span>attach_uptime; /* system uptime when attach happened. */</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>struct cpsw_port port[2];</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>/* RX and TX buffer tracking */</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>struct cpsw_queue rx, tx;</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>/* We expect 1 memory resource and 4 interrupts from the device tree. */</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>void<span class="Apple-tab-span" style="white-space:pre">                </span>*ih_cookie[CPSW_INTR_COUNT];</div><div>+#ifndef __rtems__</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>mem_rid;</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>struct resource<span class="Apple-tab-span" style="white-space:pre">     </span>*mem_res;</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>struct resource<span class="Apple-tab-span" style="white-space:pre">     </span>*irq_res[CPSW_INTR_COUNT];</div><div>+#else</div><div>+    struct resource<span class="Apple-tab-span" style="white-space:pre">        </span>*irq_res[1+CPSW_INTR_COUNT];</div><div>+#endif</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>/* An mbuf full of nulls for TX padding. */</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>bus_dmamap_t null_mbuf_dmamap;</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>struct mbuf *null_mbuf;</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>bus_addr_t null_mbuf_paddr;</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>bus_dma_tag_t<span class="Apple-tab-span" style="white-space:pre">       </span>mbuf_dtag;</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>struct {</div><div>+<span class="Apple-tab-span" style="white-space:pre">            </span>int resets;</div><div>+<span class="Apple-tab-span" style="white-space:pre">         </span>int timer;</div><div>+<span class="Apple-tab-span" style="white-space:pre">          </span>struct callout  callout;</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>} watchdog;</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>/* 64-bit versions of 32-bit hardware statistics counters */</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>uint64_t shadow_stats[CPSW_SYSCTL_COUNT];</div><div>+</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>/* CPPI STATERAM has 512 slots for building TX/RX queues. */</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>/* TODO: Size here supposedly varies with different versions</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>   of the controller.  Check DaVinci specs and find a good</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>   way to adjust this.  One option is to have a separate</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>   Device Tree parameter for number slots; another option</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>   is to calculate it from the memory size in the device tree. */</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>struct cpsw_slot _slots[CPSW_CPPI_RAM_SIZE / sizeof(struct cpsw_cpdma_bd)];</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>struct cpsw_slots avail;</div><div>+};</div><div>+</div><div>+struct cpswp_softc {</div><div>+<span class="Apple-tab-span" style="white-space:pre">      </span>device_t<span class="Apple-tab-span" style="white-space:pre">    </span>dev;</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>device_t<span class="Apple-tab-span" style="white-space:pre">    </span>miibus;</div><div>+<span class="Apple-tab-span" style="white-space:pre">     </span>device_t<span class="Apple-tab-span" style="white-space:pre">    </span>pdev;</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>media_status;</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>unit;</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>int<span class="Apple-tab-span" style="white-space:pre">         </span>vlan;</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>struct bintime<span class="Apple-tab-span" style="white-space:pre">      </span>init_uptime; /* system uptime when init happened. */</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>struct callout<span class="Apple-tab-span" style="white-space:pre">      </span>mii_callout;</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>struct cpsw_softc *swsc;</div><div>+<span class="Apple-tab-span" style="white-space:pre">    </span>struct ifnet<span class="Apple-tab-span" style="white-space:pre">        </span>*ifp;</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>struct mii_data<span class="Apple-tab-span" style="white-space:pre">     </span>*mii;</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>struct mtx<span class="Apple-tab-span" style="white-space:pre">  </span>lock;</div><div>+<span class="Apple-tab-span" style="white-space:pre">       </span>uint32_t<span class="Apple-tab-span" style="white-space:pre">    </span>if_flags;</div><div>+<span class="Apple-tab-span" style="white-space:pre">   </span>uint32_t<span class="Apple-tab-span" style="white-space:pre">    </span>phy;</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>uint32_t<span class="Apple-tab-span" style="white-space:pre">    </span>phyaccess;</div><div>+<span class="Apple-tab-span" style="white-space:pre">  </span>uint32_t<span class="Apple-tab-span" style="white-space:pre">    </span>physel;</div><div>+};</div><div>+</div><div>+#endif /*_IF_CPSWVAR_H */</div></div><div><div><br></div><div><br></div><div style="font-size: 12px;font-family: Arial Narrow;padding:2px 0 2px 0;">------------------ Original ------------------</div><div style="font-size: 12px;background:#efefef;padding:8px;"><div><b>From: </b> "yao0718";<29171383@qq.com>;</div><div><b>Date: </b> Tue, Jul 5, 2016 03:11 PM</div><div><b>To: </b> "devel"<devel@rtems.org>; <wbr></div><div></div><div><b>Subject: </b> [0/6] ti cpsw driver port from freebsd for am335x </div></div><div><br></div><div><span style="font-family: 'lucida Grande', Verdana, 'Microsoft YaHei'; line-height: 23.8px;">I add cpsw driver from freebsd and modify some code for my board, my board is not beagleblack, so i am not sure it can work fine in BB board,to reduce phy find process, I  set phy address 4 and 6 for which phy address on my board,my board has two eth port ,I set dualmac when attach;</span></div><div><span style="font-family: 'lucida Grande', Verdana, 'Microsoft YaHei'; line-height: 23.8px;">can somebody test it on beaglebone and merge to beaglebone  bsp?</span></div><div><span style="font-family: 'lucida Grande', Verdana, 'Microsoft YaHei'; line-height: 23.8px;"><br></span></div></div></div>