mirror of
https://gitlab.com/etherlab.org/ethercat.git
synced 2026-08-17 16:51:44 +08:00
Native EtherCAT device driver for the Raspberry Pi 5 on-RP1 gigabit MAC (Cadence GEM, "macb"), ported from the genet recipe. Lets the IgH kernel master poll-drive the NIC directly instead of via the generic driver. Derived from the in-tree macb driver at Linux 6.18.33 (drivers/net/ethernet/cadence: macb_main.c, macb.h, macb_ptp.c); the -orig files are verbatim, the -ethercat files add the ecdev hooks (ecdev_offer/open/close/withdraw, ec_poll, gem_rx -> ecdev_receive, a persistent TX skb ring, IRQ/NAPI/PTP gated by get_ecdev()). macb-specific points vs the genet recipe: - ecdev_offer() before macb_init() (macb requests its IRQs there). - phylink (not MDIO adjust_link); phylink_start/stop wrapped in rtnl_lock in EtherCAT mode (ecdev_open runs without the RTNL lock). - MAC PHC / PTP init gated off in EtherCAT mode. - macb_pad_and_fcs(): the master reuses one persistent TX skb and rewrites skb->len each cycle without resetting the tail, so re-sync the tail and append the software FCS in place; a plain skb_put() walked the tail past the buffer end -> skb_over_panic(). Tested on a Raspberry Pi 5 (BCM2712, 6.18.33-rt) against an A6-EC servo drive: binds the RP1 GEM, reaches OP, 0 lost frames at up to 4 kHz. Build: ./configure --enable-macb [--with-macb-kernel=6.18] Known limitations: RX allocates an skb per frame in the poll path (a future revision can reuse the buffer in place); only the GEM RX path carries the hook (RP1 is GEM); PM suspend/resume is not specially handled.