From c4c73e415ed1e03d52f4e20903f70efcd628b8c5 Mon Sep 17 00:00:00 2001
From: Juan David Gonzalez Cobas <dcobas@cern.ch>
Date: Thu, 18 Aug 2016 17:53:30 +0200
Subject: [PATCH] keep track of old Julian L866 patch

This was

18021642d3c13a19213647d786c9aa7557e129aa Mon Sep 17 00:00:00 2001
From: Michel Arruat <michel.arruat@cern.ch>
Date: Fri, 22 May 2015 17:47:34 +0200
Subject: [PATCH] ACDipole for L866:         - Driver: Last fixes done by
 Julian to be L866 compliant         - Library: change made
 by Nicolas Magnin

and there is no way to rebase this sensibly on top of current master.
Most modifications are superseded by the current acdx driver, which
should work fine on L866.
---
 acdx/driver/0001-ACDipole-for-L866.patch | 313 +++++++++++++++++++++++
 1 file changed, 313 insertions(+)
 create mode 100644 acdx/driver/0001-ACDipole-for-L866.patch

diff --git a/acdx/driver/0001-ACDipole-for-L866.patch b/acdx/driver/0001-ACDipole-for-L866.patch
new file mode 100644
index 00000000..9eccd824
--- /dev/null
+++ b/acdx/driver/0001-ACDipole-for-L866.patch
@@ -0,0 +1,313 @@
+From 18021642d3c13a19213647d786c9aa7557e129aa Mon Sep 17 00:00:00 2001
+From: Michel Arruat <michel.arruat@cern.ch>
+Date: Fri, 22 May 2015 17:47:34 +0200
+Subject: [PATCH] ACDipole for L866:         - Driver: Last fixes done by
+ Julian to be L866 compliant         - Library: change made
+ by Nicolas Magnin
+
+Signed-off-by: Michel Arruat <michel.arruat@cern.ch>
+---
+ acdx/driver/AcdxModule.c   |  1 +
+ acdx/driver/Kbuild         |  9 +++-----
+ acdx/driver/Makefile       | 33 ++++++++++++++++++---------
+ acdx/driver/ModuleLynxOs.c | 13 -----------
+ acdx/driver/acdxdrvr.c     | 30 +++++++++++--------------
+ acdx/lib/libacdx.c         |  8 +++++--
+ acdx/lib/libacdx.h         | 56 ++++++++++++++++++++++++----------------------
+ 7 files changed, 74 insertions(+), 76 deletions(-)
+
+diff --git a/acdx/driver/AcdxModule.c b/acdx/driver/AcdxModule.c
+index 21b14f7..59fd485 100644
+--- a/acdx/driver/AcdxModule.c
++++ b/acdx/driver/AcdxModule.c
+@@ -10,6 +10,7 @@
+ #include "ModuleLynxOs.c"
+ #include "EmulateLynxOs.c"
+ #include "DrvrSpec.c"
++
+ #include "acdxdrvr.c"
+ 
+ /* ===================================================== */
+diff --git a/acdx/driver/Kbuild b/acdx/driver/Kbuild
+index d97b1d8..8006185 100644
+--- a/acdx/driver/Kbuild
++++ b/acdx/driver/Kbuild
+@@ -1,12 +1,9 @@
+-EXTRA_CFLAGS += \
++ccflags-y = \
+ 	-Wno-strict-prototypes \
+ 	-DCTR_PCI \
+ 	-DEMULATE_LYNXOS_ON_LINUX \
+ 	-DHARD_FLOAT \
+ 	-mhard-float \
+-	-I/acc/src/dsc/drivers/coht/acdx/driver
+-
+-
+-obj-m := acdx.o
+-acdx-objs := acdxdrvr.o DrvrSpec.o EmulateLynxOs.o ModuleLynxOs.o
++	-I$(src)
+ 
++obj-m:=AcdxModule.o	
+diff --git a/acdx/driver/Makefile b/acdx/driver/Makefile
+index e6b11a1..4fa25c9 100644
+--- a/acdx/driver/Makefile
++++ b/acdx/driver/Makefile
+@@ -1,29 +1,40 @@
+-CPU=L865
+-
+-# KVER=2.6.24.7-rt21
+-# KVER=2.6.24.7-rt27
+-# KVER=2.6.29.4-rt15
+-# KVER=2.6.31.6-rt19
+-# KVER=2.6.24.7-rt21
++CPU=L866
+ 
++ifeq ($(CPU),L865)
+ KVER=3.2.43-rt63
++endif
++
++ifeq ($(CPU),L866)
++KVER=3.6.11-rt30.25.el6rt.x86_64
++endif
+ 
+ KERNELSRC=/acc/sys/$(CPU)/usr/src/kernels/$(KVER)
+-OUTPUTDIR=/acc/src/dsc/drivers/coht/acdx/driver/$(CPU)/$(KVER)
++OUTPUTDIR=$(PWD)/$(CPU)/$(KVER)
+ 
+ CFLAGS=-g -Wall
+ 
+-all: driver 
++all: driver
+ driver: modules
+ 
+-modules: 
++modules:
+ 	make -C $(KERNELSRC) M=`pwd` KVER=$(KVER) CPU=$(CPU) modules
+ 	mkdir -p $(OUTPUTDIR)
+ 	mv *.o *.ko $(OUTPUTDIR)
+ clean:
+ 	rm -f *.o *.a *.pyc *.so $(TESTS)
+ 	rm -f *.mod.c
+-	rm -rf L865 L864 ppc 
++	rm -rf $(CPU) L864 ppc
+ 	make -C $(KERNELSRC) M=`pwd` clean
++	rm -f ,* *~ *.bak *.BAK .es1* .B* %*% .ec1 .ek1 .*~ core a.out *JNL *.lst \\\#*\\\# .nfs* *%
++	rm -f a.out out 32 64
++
++install:
++	@echo "please specify one of {install-lab|install-lhc|install-all}"
++
++install-all: install-lab install-lhc
+ 
++install-lab: ./$(CPU)/$(KVER)/acdx.ko 
++	dsc_install ./$(CPU)/$(KVER)/acdx.ko /acc/dsc/lab/$(CPU)/$(KVER)/acdx;
+ 
++install-lhc: ./$(CPU)/$(KVER)/acdx.ko
++	dsc_install ./$(CPU)/$(KVER)/acdx.ko /acc/dsc/oplhc/$(CPU)/$(KVER)/acdx;
+diff --git a/acdx/driver/ModuleLynxOs.c b/acdx/driver/ModuleLynxOs.c
+index c36c4a3..de68f17 100644
+--- a/acdx/driver/ModuleLynxOs.c
++++ b/acdx/driver/ModuleLynxOs.c
+@@ -28,7 +28,6 @@
+ #include <linux/interrupt.h>
+ #include <linux/version.h>
+ #include <linux/mutex.h>
+-#include <linux/module.h>
+ 
+ #include <EmulateLynxOs.h>
+ #include <DrvrSpec.h>
+@@ -89,15 +88,6 @@ int res;
+    return res;
+ }
+ 
+-int LynxIoctl32(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) {
+-int res;
+-
+-   mutex_lock(&acdx_drvr_mutex);
+-   res = LynxOsIoctl(inode, filp, cmd, arg);
+-   mutex_unlock(&acdx_drvr_mutex);
+-   return res;
+-}
+-
+ struct file_operations LynxOs_fops = {
+    read:           LynxOsRead,
+    write:          LynxOsWrite,
+@@ -429,6 +419,3 @@ int i;
+    }
+    return IRQ_NONE;
+ }
+-
+-module_init(LynxOsInstall);
+-module_exit(LynxOsUninstall);
+diff --git a/acdx/driver/acdxdrvr.c b/acdx/driver/acdxdrvr.c
+index a1953d8..c727bdf 100644
+--- a/acdx/driver/acdxdrvr.c
++++ b/acdx/driver/acdxdrvr.c
+@@ -72,10 +72,6 @@ static void CancelTimeout(int *t) {
+ unsigned long ps = 0;
+ int v;
+ 
+-#ifdef EMULATE_LYNXOS_ON_LINUX
+-   ps = 0;
+-#endif
+-
+    disable(ps);
+    {
+       if ((v = *t)) {
+@@ -236,8 +232,8 @@ char                      *iod;
+    } else {
+       disable(ps);
+ 
+-      kkprintf("AcdxDrvr: BUS-ERROR: Module:%d Addr:%x Dir:%s Data:%d\n",
+-	       (int) mcon->ModuleIndex+1,(int) &(mmap[j]),iod,(int) uary[i]);
++      kkprintf("AcdxDrvr: BUS-ERROR: Module:%d Addr:%p Dir:%s Data:%d\n",
++	       (int) mcon->ModuleIndex+1,&(mmap[j]),iod,(int) uary[i]);
+ 
+       pseterr(ENXIO);        /* No such device or address */
+       rval = SYSERR;
+@@ -403,7 +399,7 @@ AcdxDrvrInfoTable * info; {      /* Driver info table */
+ AcdxDrvrWorkingArea *wa;
+ drm_node_handle handle;
+ AcdxDrvrModuleContext *mcon;
+-unsigned long vadr;
++void *vadr;
+ int modix, mid, cc;
+ 
+ int cmd;
+@@ -447,23 +443,23 @@ int cmd;
+       cmd |= 2;
+       drm_device_write(handle, PCI_RESID_REGS, 1, 0, &cmd);
+ 
+-      vadr = (int) NULL;
+-      cc = drm_map_resource(handle,PCI_RESID_BAR0,&vadr);
++      vadr = NULL;
++      cc = drm_map_resource(handle,PCI_RESID_BAR0,(unsigned long *) &vadr);
+       if ((cc) || (!vadr)) {
+ 	 cprintf("AcdxDrvrInstall: Can't map memory (BAR0) for ACDX module: %d\n",modix+1);
+ 	 return((char *) SYSERR);
+       }
+       mcon->Local = (unsigned long *) vadr;
+-      cprintf("AcdxDrvrInstall: BAR0 is mapped to address: 0x%08X\n",(int) vadr);
++      cprintf("AcdxDrvrInstall: BAR0 is mapped to address: %p\n",vadr);
+ 
+-      vadr = (int) NULL;
+-      cc = drm_map_resource(handle,PCI_RESID_BAR1,&vadr);
++      vadr = NULL;
++      cc = drm_map_resource(handle,PCI_RESID_BAR1,(unsigned long *) &vadr);
+       if ((cc) || (!vadr)) {
+ 	 cprintf("AcdxDrvrInstall: Can't map memory (BAR1) for ACDX module: %d\n",modix+1);
+ 	 return((char *) SYSERR);
+       }
+       mcon->Map = (AcdxDrvrMemoryMap *) vadr;
+-      cprintf("AcdxDrvrInstall: BAR1 is mapped to address: 0x%08X\n",(int) vadr);
++      cprintf("AcdxDrvrInstall: BAR1 is mapped to address: %p\n",vadr);
+ 
+       wa->Modules = modix+1;
+ 
+@@ -533,12 +529,12 @@ int rcnt, wcnt;           /* Readable, Writable byte counts at arg address */
+    /* can be read or written to without error. */
+ 
+    if (arg != NULL) {
+-      rcnt = rbounds((int)arg);       /* Number of readable bytes without error */
+-      wcnt = wbounds((int)arg);       /* Number of writable bytes without error */
++      rcnt = rbounds((unsigned long) arg);            /* Number of readable bytes without error */
++      wcnt = wbounds((unsigned long) arg);            /* Number of writable bytes without error */
+       if (rcnt < sizeof(long)) {      /* We at least need to read one long */
+ 	 pid = getpid();
+-	 cprintf("AcdxDrvrIoctl:Illegal arg-pntr:0x%X ReadCnt:%d(%d) Pid:%d Cmd:%d\n",
+-		 (int) arg,rcnt,sizeof(long),pid,(int) cm);
++	 cprintf("AcdxDrvrIoctl:Illegal arg-pntr:%p ReadCnt:%d Pid:%d Cmd:%d\n",
++		 arg,rcnt,pid,(int) cm);
+ 	 pseterr(EINVAL);        /* Invalid argument */
+ 	 return SYSERR;
+       }
+diff --git a/acdx/lib/libacdx.c b/acdx/lib/libacdx.c
+index 3097aa8..f58fe33 100755
+--- a/acdx/lib/libacdx.c
++++ b/acdx/lib/libacdx.c
+@@ -182,8 +182,10 @@ AcdxLibCompletion AcdxLibInit() {
+ 
+ /* ================================================ */
+ 
+-AcdxLibCompletion AcdxLoadFunction(unsigned int f,   /* Frequency in Hertz */
+-				   unsigned int a) { /* Amplitude in Milli-Volts */
++AcdxLibCompletion AcdxLoadFunction(
++					unsigned int f,      /* Frequency in Hertz */
++					unsigned int a,     /* Amplitude in Milli-Volts */
++					unsigned int ft) {  /* ftop in Milli-Seconds */
+ 
+    if (AcdxLibInit() == AcdxLibOK) {
+ 
+@@ -191,6 +193,8 @@ AcdxLibCompletion AcdxLoadFunction(unsigned int f,   /* Frequency in Hertz */
+       else   freq = 3000;
+       if (a) ampl = a;
+       else   ampl = 500;
++      if (ft) ftop = ft * 1000; // ft in ms
++      else   ftop = 200000;
+ 
+       SinWave();
+       if (PutFunc()) return AcdxLibOK;
+diff --git a/acdx/lib/libacdx.h b/acdx/lib/libacdx.h
+index be61304..e2df13d 100755
+--- a/acdx/lib/libacdx.h
++++ b/acdx/lib/libacdx.h
+@@ -1,27 +1,29 @@
+-/* ================================================ */
+-/* Simply library interface to the AC Dipole system */
+-/* Julian Lewis AB/CO/HT Fri 19th Sept 2008         */
+-/* ================================================ */
+-
+-typedef enum {
+-   AcdxLibOK,
+-   AcdxLibFAIL
+- } AcdxLibCompletion;
+-
+-
+-AcdxLibCompletion AcdxLoadFunction(unsigned int freq,         /* Frequency in Hertz */
+-				   unsigned int ampl);        /* Amplitude in Milli-Volts */
+-
+-AcdxLibCompletion AcdxArm();      /* Arm */
+-
+-AcdxLibCompletion AcdxUnArm();    /* Set Arm bit to 0 */
+-
+-int AcdxIsArmed();                /* Returns 1 if ARMED else 0 */
+-
+-int AcdxIsBusy();                 /* Returns 1 if BUSY else 0 */
+-
+-AcdxLibCompletion  AcdxAmpOn();   /* Set AmpOn status bit to ON */
+-
+-AcdxLibCompletion  AcdxAmpOff();  /* Set AmpOn status bit to OFF */
+-
+-int AcdxAmpIsOn();                /* Returns value of AmpOn status bit */
++/* ================================================ */
++/* Simply library interface to the AC Dipole system */
++/* Julian Lewis AB/CO/HT Fri 19th Sept 2008         */
++/* ================================================ */
++
++typedef enum {
++   AcdxLibOK,
++   AcdxLibFAIL
++ } AcdxLibCompletion;
++
++
++AcdxLibCompletion AcdxLoadFunction(
++                  unsigned int freq,         /* Frequency in Hertz */
++                  unsigned int ampl,       /* Amplitude in Milli-Volts */
++                  unsigned int ftop);       /* Flat-Top Width in Milli-Seconds */
++
++AcdxLibCompletion AcdxArm();      /* Arm */
++
++AcdxLibCompletion AcdxUnArm();    /* Set Arm bit to 0 */
++
++int AcdxIsArmed();                /* Returns 1 if ARMED else 0 */
++
++int AcdxIsBusy();                 /* Returns 1 if BUSY else 0 */
++
++AcdxLibCompletion  AcdxAmpOn();   /* Set AmpOn status bit to ON */
++
++AcdxLibCompletion  AcdxAmpOff();  /* Set AmpOn status bit to OFF */
++
++int AcdxAmpIsOn();                /* Returns value of AmpOn status bit */
+-- 
+1.7.11.3
+
-- 
GitLab