mpc5200: Add RTDM LPBFIFO driver and demo RTDM FPGA driver driver
v3 cover mpc5200: Add RTDM LPBFIFO driver and demo RTDM FPGA driver driver
From: Stefan Roese <[email protected]>
This patch adds support for the RTDM LPB (LocalPlusBus) FIFO driver for the MPC5200. It will be used for DMA support in an RTDM FPGA device driver. This rt-fpga.c driver is a custom device driver, but might be useful for other developers as well. Thats why I included it here too.
The lpb-fifo driver is ported from the Linux kernel lpb-fifo driver:
arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c
With all locking etc changed from Linux call to Xenomai/RTDM calls.
Thanks,
Stefan
Series-changes: 3
- Patch split into 3 separate patches
- Added RTDM_CLASS_CUSTOM
- Fixed usage of CONFIG_ options defined in Kconfig in driver
- Removed Linux v2.4 support (Config.in / Makefiles)
- Removed dbg macro and used existing kernel debug function
- Headers moved to include/rtdm
- Used different structs for the ioctl's
Series-changes: 2
- Moved debug switches from #define in source to Kconfig
- Some minor spelling fixes
Stefan Roese (3):
Add RTDM_CLASS_CUSTOM for custom RTDM device drivers
mpc5200: Add RTDM LPBFIFO driver
mpc5200: Add demo RTDM FPGA DMA based device driver
include/rtdm/rt-fpga.h | 46 ++ include/rtdm/rt_mpc52xx_lpbfifo.h | 13 + include/rtdm/rtdm.h | 1 + ksrc/drivers/Kconfig | 1 + ksrc/drivers/Makefile | 2 +- ksrc/drivers/mpc5200_dma/Kconfig | 53 ++ ksrc/drivers/mpc5200_dma/Makefile | 9 + ksrc/drivers/mpc5200_dma/rt-fpga.c | 711 ++++++++++++++++++++++++++ ksrc/drivers/mpc5200_dma/rt_mpc52xx_lpbfifo.c | 569 +++++++++++++++++++++ scripts/Modules.frag | 3 +- 10 files changed, 1406 insertions(+), 2 deletions(-) create mode 100644 include/rtdm/rt-fpga.h create mode 100644 include/rtdm/rt_mpc52xx_lpbfifo.h create mode 100644 ksrc/drivers/mpc5200_dma/Kconfig create mode 100644 ksrc/drivers/mpc5200_dma/Makefile create mode 100644 ksrc/drivers/mpc5200_dma/rt-fpga.c create mode 100644 ksrc/drivers/mpc5200_dma/rt_mpc52xx_lpbfifo.c
Signature · 1 line
1.8.0
PATCH v3 1/3 Add RTDM_CLASS_CUSTOM for custom RTDM device drivers
From: Stefan Roese <[email protected]>
As suggested by Jan Kriszka, define a new class for custom RTDM device drivers.
--- include/rtdm/rtdm.h | 1 + 1 file changed, 1 insertion(+)
include/rtdm/rtdm.h +1 -0
@@ -121,6 +121,7 @@ typedef int64_t nanosecs_rel_t;#define RTDM_CLASS_RTMAC 5#define RTDM_CLASS_TESTING 6#define RTDM_CLASS_RTIPC 7 +#define RTDM_CLASS_CUSTOM 8/* #define RTDM_CLASS_USB ? #define RTDM_CLASS_FIREWIRE ?
Signature · 1 line
1.8.0
PATCH v3 2/3 mpc5200: Add RTDM LPBFIFO driver
In reply to [email protected]From: Stefan Roese <[email protected]>
This patch adds support for the RTDM LPB (LocalPlusBus) FIFO driver for the MPC5200. It will be used for DMA support in an custom RTDM FPGA device driver.
The RT lpb-fifo driver is ported from the Linux kernel lpb-fifo driver:
arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c
With all locking etc changed from Linux call to Xenomai/RTDM calls.
--- include/rtdm/rt_mpc52xx_lpbfifo.h | 13 + ksrc/drivers/Kconfig | 1 + ksrc/drivers/Makefile | 2 +- ksrc/drivers/mpc5200_dma/Kconfig | 14 + ksrc/drivers/mpc5200_dma/Makefile | 7 + ksrc/drivers/mpc5200_dma/rt_mpc52xx_lpbfifo.c | 569 ++++++++++++++++++++++++++ scripts/Modules.frag | 2 +- 7 files changed, 606 insertions(+), 2 deletions(-) create mode 100644 include/rtdm/rt_mpc52xx_lpbfifo.h create mode 100644 ksrc/drivers/mpc5200_dma/Kconfig create mode 100644 ksrc/drivers/mpc5200_dma/Makefile create mode 100644 ksrc/drivers/mpc5200_dma/rt_mpc52xx_lpbfifo.c
include/rtdm/rt_mpc52xx_lpbfifo.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* RTDM mpc5200 lpbfifo driver +* +* Copyright (C) 2012 Stefan Roese <[email protected]> +*/ + +#ifndef _RT_MPC5200_LPBFIFO_H +#define _RT_MPC5200_LPBFIFO_H + +/* Interface to rt_mpc5200_lpbfifo driver */ +int rt_mpc52xx_lpbfifo_submit (struct mpc52xx_lpbfifo_request *req); + +#endif
ksrc/drivers/Kconfig +1 -0
@@ -7,5 +7,6 @@ source "drivers/xenomai/testing/Kconfig" source "drivers/xenomai/can/Kconfig" source "drivers/xenomai/analogy/Kconfig" source "drivers/xenomai/ipc/Kconfig" +source "drivers/xenomai/mpc5200_dma/Kconfig" endmenu
ksrc/drivers/Makefile +1 -1
@@ -2,7 +2,7 @@ ifneq ($(VERSION).$(PATCHLEVEL),2.4) # Makefile frag for Linux v2.6 and v3.x -obj-$(CONFIG_XENOMAI) += serial/ testing/ can/ analogy/ ipc/ +obj-$(CONFIG_XENOMAI) += serial/ testing/ can/ analogy/ ipc/ mpc5200_dma/ else
ksrc/drivers/mpc5200_dma/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +menu "MPC5200 DMA drivers" + +config XENO_DRIVERS_MPC5200_LPBFIFO + tristate "RTDM MPC5200 LocalPlus bus FIFO driver" + depends on XENO_SKIN_RTDM && PPC_MPC52xx + select PPC_BESTCOMM_GEN_BD + select PPC_MPC5200_LPBFIFO + help + + This RTDM driver implements the LPB-FIFO infrastructure for DMA + based RTDM device drivers using the BestComm DMA controller + on the MPC5200. + +endmenu
ksrc/drivers/mpc5200_dma/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# Makefile frag for Linux v2.6 and v3.x + +EXTRA_CFLAGS += -D__IN_XENOMAI__ -Iinclude/xenomai + +obj-$(CONFIG_XENO_DRIVERS_MPC5200_LPBFIFO) += xeno_rt_mpc52xx_lpbfifo.o + +xeno_rt_mpc52xx_lpbfifo-y := rt_mpc52xx_lpbfifo.o
ksrc/drivers/mpc5200_dma/rt_mpc52xx_lpbfifo.c new file +569 -0
569 lines not on this page · raw message
scripts/Modules.frag +1 -1
@@ -21,4 +21,4 @@ DRIVERS-$(CONFIG_XENO_DRIVERS_CAN_SJA1000_PEAK_PCI) += drivers/xenomai/can/sja10 DRIVERS-$(CONFIG_XENO_DRIVERS_CAN_SJA1000_PEAK_DNG) += drivers/xenomai/can/sja1000/xeno_can_peak_dng.o DRIVERS-$(CONFIG_XENO_DRIVERS_CAN_SJA1000_IXXAT_PCI) += drivers/xenomai/can/sja1000/xeno_can_ixxat_pci.o DRIVERS-$(CONFIG_XENO_DRIVERS_CAN_SJA1000_EMS_PCI) += drivers/xenomai/can/sja1000/xeno_can_ems_pci.o - +DRIVERS-$(CONFIG_XENO_DRIVERS_MPC5200_LPBFIFO) += drivers/xenomai/mpc5200_dma/rt_mpc52xx_lpbfifo.o
Signature · 1 line
1.8.0
PATCH v3 3/3 mpc5200: Add demo RTDM FPGA DMA based device driver
In reply to [email protected]From: Stefan Roese <[email protected]>
This patch adds support for an custom RTDM FPGA DMA based driver driver. This is a driver to demonstrate the usage of the RTDM DMA infrastructure on the MPC5200. It uses the RTDM lpbfifo driver to communicate with the BestComm DMA controller.
As mentioned above, its a special custom driver. But it might be useful for other developers as well. Thats why I included it here too.
--- include/rtdm/rt-fpga.h | 46 +++ ksrc/drivers/mpc5200_dma/Kconfig | 39 ++ ksrc/drivers/mpc5200_dma/Makefile | 2 + ksrc/drivers/mpc5200_dma/rt-fpga.c | 711 +++++++++++++++++++++++++++++++++++++ scripts/Modules.frag | 1 + 5 files changed, 799 insertions(+) create mode 100644 include/rtdm/rt-fpga.h create mode 100644 ksrc/drivers/mpc5200_dma/rt-fpga.c
include/rtdm/rt-fpga.h new file +46 -0
@@ -0,0 +1,46 @@ +/* +* Xenomai RTDM device driver for A3M071 FPGA with interrupt support +* +* Copyright (C) 2012 Stefan Roese <[email protected]> +*/ + +#ifndef _RT_FPGA_H +#define _RT_FPGA_H + +/* +* IOCTL's for this FPGA driver +*/ +#define RTIOC_TYPE_CUSTOM RTDM_CLASS_CUSTOM +#define FPGA_CONFIG \ + _IOW(RTIOC_TYPE_CUSTOM, 0x00, struct fpga_config) +#define FPGA_READ_WORD \ + _IOR(RTIOC_TYPE_CUSTOM, 0x01, struct fpga_rw_word) +#define FPGA_WRITE_WORD \ + _IOW(RTIOC_TYPE_CUSTOM, 0x02, struct fpga_rw_word) +#define FPGA_SET_TIMEOUT \ + _IOW(RTIOC_TYPE_CUSTOM, 0x03, struct fpga_set_timeout) +#define FPGA_GET_CYCLES_MISSED \ + _IOR(RTIOC_TYPE_CUSTOM, 0x04, struct fpga_get_cycles_missed) + +/* Structs for ioctls */ +struct fpga_config { +unsigned int offset; +unsigned int count; +unsigned int write_offset; +unsigned int write_count; +}; + +struct fpga_rw_word { +unsigned int offset; +unsigned short value; +}; + +struct fpga_set_timeout { +unsigned int timeout; +}; + +struct fpga_get_cycles_missed { +int cycles_missed; +}; + +#endif
ksrc/drivers/mpc5200_dma/Kconfig +39 -0
@@ -11,4 +11,43 @@ config XENO_DRIVERS_MPC5200_LPBFIFO based RTDM device drivers using the BestComm DMA controller on the MPC5200. +config XENO_DRIVERS_MPC5200_DMA + depends on XENO_DRIVERS_MPC5200_LPBFIFO + tristate "MPC5200 DMA based driver to receive data from an FPGA" + help + + This is a driver to demonstrate the usage of the RTDM DMA + infrastructure on the MPC5200. + +config XENO_DRIVERS_MPC5200_DMA_DEBUG + depends on XENO_DRIVERS_MPC5200_DMA + bool "Enable debug output" + default n + help + + This option activates debugging checks and enhanced output for the + RTDM FPGA DMA driver. It is a recommended option for getting started + and analysing potential problems. For production purposes, it should + be switched off (for the sake of latency). + +config XENO_DRIVERS_MPC5200_DMA_NO_DMA + depends on XENO_DRIVERS_MPC5200_DMA + bool "Enable non-DMA version of this FPGA driver" + default n + help + + Define to enable memcpy() for blockdata transfer instead of DMA + support. This is available only for test purposes. Should be disabled + in the final/release driver version. + +config XENO_DRIVERS_MPC5200_DMA_PRINT_READ_TIME + depends on XENO_DRIVERS_MPC5200_DMA + bool "Enable read time debug output of this FPGA driver" + default n + help + + Print min and max times consumed by the blockdata transfer, either + per DMA or per memcpy. Should be disabled in the final/release driver + version. + endmenu
ksrc/drivers/mpc5200_dma/Makefile +2 -0
@@ -3,5 +3,7 @@ EXTRA_CFLAGS += -D__IN_XENOMAI__ -Iinclude/xenomai obj-$(CONFIG_XENO_DRIVERS_MPC5200_LPBFIFO) += xeno_rt_mpc52xx_lpbfifo.o +obj-$(CONFIG_XENO_DRIVERS_MPC5200_DMA) += xeno_rt-fpga.o xeno_rt_mpc52xx_lpbfifo-y := rt_mpc52xx_lpbfifo.o +xeno_rt-fpga-y := rt-fpga.o
ksrc/drivers/mpc5200_dma/rt-fpga.c new file +711 -0
711 lines not on this page · raw message
scripts/Modules.frag +1 -0
@@ -22,3 +22,4 @@ DRIVERS-$(CONFIG_XENO_DRIVERS_CAN_SJA1000_PEAK_DNG) += drivers/xenomai/can/sja10 DRIVERS-$(CONFIG_XENO_DRIVERS_CAN_SJA1000_IXXAT_PCI) += drivers/xenomai/can/sja1000/xeno_can_ixxat_pci.o DRIVERS-$(CONFIG_XENO_DRIVERS_CAN_SJA1000_EMS_PCI) += drivers/xenomai/can/sja1000/xeno_can_ems_pci.o DRIVERS-$(CONFIG_XENO_DRIVERS_MPC5200_LPBFIFO) += drivers/xenomai/mpc5200_dma/rt_mpc52xx_lpbfifo.o +DRIVERS-$(CONFIG_XENO_DRIVERS_MPC5200_DMA) += drivers/xenomai/mpc5200_dma/rt-fpga.o
Signature · 1 line
1.8.0
Re: [Xenomai] [PATCH v3 3/3] mpc5200: Add demo RTDM FPGA DMA based device driver
Dear Stefan,
Quoted 1 line · In message <[email protected]> you wrote:
...
Quoted 7 lines
ksrc/drivers/mpc5200_dma/rt-fpga.c new file +7
-0+/* +* CONFIG_XENO_DRIVERS_MPC5200_DMA_DEBUG: +* +* Define to print debug informations. Should be disabled in the +* final driver of course. +*/ +
ksrc/drivers/mpc5200_dma/rt-fpga.c line 71
Quoted 10 lines
ksrc/drivers/mpc5200_dma/rt-fpga.c new file +10
-0+#ifdef CONFIG_XENO_DRIVERS_MPC5200_DMA_DEBUG +#define dbg(format, arg...) \ + printk("%s (%d): " format, __func__, __LINE__, ##arg) +#else +#define dbg(format, arg...) \ +do { \ + if (0) \ + printk("%s (%d): " format, __func__, __LINE__, ##arg); \ +} while (0) +#endif
Your change log said: "Removed dbg macro and used existing kernel debug function".
What about this, then?
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected] Conceptual integrity in turn dictates that the design must proceed from one mind, or from a very small number of agreeing resonant minds. - Frederick Brooks Jr., "The Mythical Man Month"