[Xenomai-git] Wolfgang Grandegger : rtcan: ems_pci driver update to support more devices

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 6c03c92c496e3f719e8322c4180f865e29daa452
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6c03c92c496e3f719e8322c4180f865e29daa452

Author: Wolfgang Grandegger 
Date:   Fri Oct 28 09:25:00 2016 +0200

rtcan: ems_pci driver update to support more devices

Hi Philippe

Am 06.10.2016 um 21:40 schrieb Philippe Gerum:
> >
> > Hi Wolfgang,
> >
> > On 10/04/2016 08:25 AM, Wolfgang Grandegger wrote:
>> >> The driver follows now more closely the corresponding Linux driver
>> >> to simplify updates in the future.
>> >>
> >
> > Any chance to have this forward ported to 3.x? Xenomai 2.6 has reached EOL.

Below is the patch for Xenomai-3. It's untested for the moment but the
changes compared with 2.6 seem not the be critical.

Wolfgang

>From 0fc42b023eb9f6f58ce3b2381a55cab74757c2a1 Mon Sep 17 00:00:00 2001
From: Wolfgang Grandegger 
Date: Fri, 28 Oct 2016 09:21:24 +0200
Subject: [PATCH] [PATCH] rtcan: ems_pci driver update to support more devices

The driver now also follows more closely the corresponding Linux
driver to simplify updates in the future.

Signed-off-by: Wolfgang Grandegger 

---

 kernel/drivers/can/sja1000/rtcan_ems_pci.c  |  487 +--
 kernel/drivers/can/sja1000/rtcan_sja1000_regs.h |1 +
 2 files changed, 281 insertions(+), 207 deletions(-)

diff --git a/kernel/drivers/can/sja1000/rtcan_ems_pci.c 
b/kernel/drivers/can/sja1000/rtcan_ems_pci.c
index be4b704..e3c178f 100644
--- a/kernel/drivers/can/sja1000/rtcan_ems_pci.c
+++ b/kernel/drivers/can/sja1000/rtcan_ems_pci.c
@@ -1,28 +1,28 @@
 /*
- * Copyright (C) 2007 Wolfgang Grandegger 
+ * Copyright (C) 2007, 2016 Wolfgang Grandegger 
+ * Copyright (C) 2008 Markus Plessing 
+ * Copyright (C) 2008 Sebastian Haas 
  *
- * Register definitions and descriptions are taken from LinCAN 0.3.3.
+ * Derived from Linux CAN SJA1000 PCI driver "ems_pci".
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the version 2 of the GNU General Public License
+ * as published by the Free Software Foundation
  *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with this program; if not, see .
  */
 
+#include 
 #include 
-#include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 
@@ -40,23 +40,30 @@
 static char *ems_pci_board_name = "EMS-CPC-PCI";
 
 MODULE_AUTHOR("Wolfgang Grandegger ");
-MODULE_DESCRIPTION("RTCAN board driver for EMS CPC-PCI cards");
-MODULE_SUPPORTED_DEVICE("EMS CPC-PCI card CAN controller");
-MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("RTCAN board driver for EMS CPC-PCI/PCIe/104P CAN cards");
+MODULE_SUPPORTED_DEVICE("EMS CPC-PCI/PCIe/104P CAN card");
+MODULE_LICENSE("GPL v2");
+
+#define EMS_PCI_V1_MAX_CHAN 2
+#define EMS_PCI_V2_MAX_CHAN 4
+#define EMS_PCI_MAX_CHANEMS_PCI_V2_MAX_CHAN
+
+struct ems_pci_card {
+   int version;
+   int channels;
 
-struct rtcan_ems_pci
-{
struct pci_dev *pci_dev;
-   struct rtcan_device *slave_dev;
-   int channel;
-   volatile void __iomem *base_addr;
-   volatile void __iomem *conf_addr;
+   struct rtcan_device *rtcan_dev[EMS_PCI_MAX_CHAN];
+
+   void __iomem *conf_addr;
+   void __iomem *base_addr;
 };
 
-#define EMS_PCI_MASTER 1 /* multi channel device, this device is master */
-#define EMS_PCI_SLAVE  2 /* multi channel device, this is slave */
+#define EMS_PCI_CAN_CLOCK (1600 / 2)
 
 /*
+ * Register definitions and descriptions are from LinCAN 0.3.3.
+ *
  * PSB4610 PITA-2 bridge control registers
  */
 #define PITA2_ICR   0x00   /* Interrupt Control Register */
@@ -64,7 +71,17 @@ struct rtcan_ems_pci
 #define PITA2_ICR_INT0_EN   0x0002 /* [RW] Enable INT0 */
 
 #define PITA2_MISC  0x1c   /* Miscellaneous Register */
-#define PITA2_MISC_CONFIG   0x0400 /* Multiplexed Parallel_interface_model 
*/
+#define PITA2_MISC_CONFIG   0x0400 /* Multiplexed parallel interface */
+
+/*
+ * Register definitions for the PLX 9030
+ */
+#define PLX_ICSR0x4

[Xenomai-git] Wolfgang Grandegger : rtcan: ems_pci driver update to support more devices

2016-11-21 Thread git repository hosting
Module: xenomai-3
Branch: wip/drivers
Commit: 6c03c92c496e3f719e8322c4180f865e29daa452
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6c03c92c496e3f719e8322c4180f865e29daa452

Author: Wolfgang Grandegger 
Date:   Fri Oct 28 09:25:00 2016 +0200

rtcan: ems_pci driver update to support more devices

Hi Philippe

Am 06.10.2016 um 21:40 schrieb Philippe Gerum:
> >
> > Hi Wolfgang,
> >
> > On 10/04/2016 08:25 AM, Wolfgang Grandegger wrote:
>> >> The driver follows now more closely the corresponding Linux driver
>> >> to simplify updates in the future.
>> >>
> >
> > Any chance to have this forward ported to 3.x? Xenomai 2.6 has reached EOL.

Below is the patch for Xenomai-3. It's untested for the moment but the
changes compared with 2.6 seem not the be critical.

Wolfgang

>From 0fc42b023eb9f6f58ce3b2381a55cab74757c2a1 Mon Sep 17 00:00:00 2001
From: Wolfgang Grandegger 
Date: Fri, 28 Oct 2016 09:21:24 +0200
Subject: [PATCH] [PATCH] rtcan: ems_pci driver update to support more devices

The driver now also follows more closely the corresponding Linux
driver to simplify updates in the future.

Signed-off-by: Wolfgang Grandegger 

---

 kernel/drivers/can/sja1000/rtcan_ems_pci.c  |  487 +--
 kernel/drivers/can/sja1000/rtcan_sja1000_regs.h |1 +
 2 files changed, 281 insertions(+), 207 deletions(-)

diff --git a/kernel/drivers/can/sja1000/rtcan_ems_pci.c 
b/kernel/drivers/can/sja1000/rtcan_ems_pci.c
index be4b704..e3c178f 100644
--- a/kernel/drivers/can/sja1000/rtcan_ems_pci.c
+++ b/kernel/drivers/can/sja1000/rtcan_ems_pci.c
@@ -1,28 +1,28 @@
 /*
- * Copyright (C) 2007 Wolfgang Grandegger 
+ * Copyright (C) 2007, 2016 Wolfgang Grandegger 
+ * Copyright (C) 2008 Markus Plessing 
+ * Copyright (C) 2008 Sebastian Haas 
  *
- * Register definitions and descriptions are taken from LinCAN 0.3.3.
+ * Derived from Linux CAN SJA1000 PCI driver "ems_pci".
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the version 2 of the GNU General Public License
+ * as published by the Free Software Foundation
  *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with this program; if not, see .
  */
 
+#include 
 #include 
-#include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 
@@ -40,23 +40,30 @@
 static char *ems_pci_board_name = "EMS-CPC-PCI";
 
 MODULE_AUTHOR("Wolfgang Grandegger ");
-MODULE_DESCRIPTION("RTCAN board driver for EMS CPC-PCI cards");
-MODULE_SUPPORTED_DEVICE("EMS CPC-PCI card CAN controller");
-MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("RTCAN board driver for EMS CPC-PCI/PCIe/104P CAN cards");
+MODULE_SUPPORTED_DEVICE("EMS CPC-PCI/PCIe/104P CAN card");
+MODULE_LICENSE("GPL v2");
+
+#define EMS_PCI_V1_MAX_CHAN 2
+#define EMS_PCI_V2_MAX_CHAN 4
+#define EMS_PCI_MAX_CHANEMS_PCI_V2_MAX_CHAN
+
+struct ems_pci_card {
+   int version;
+   int channels;
 
-struct rtcan_ems_pci
-{
struct pci_dev *pci_dev;
-   struct rtcan_device *slave_dev;
-   int channel;
-   volatile void __iomem *base_addr;
-   volatile void __iomem *conf_addr;
+   struct rtcan_device *rtcan_dev[EMS_PCI_MAX_CHAN];
+
+   void __iomem *conf_addr;
+   void __iomem *base_addr;
 };
 
-#define EMS_PCI_MASTER 1 /* multi channel device, this device is master */
-#define EMS_PCI_SLAVE  2 /* multi channel device, this is slave */
+#define EMS_PCI_CAN_CLOCK (1600 / 2)
 
 /*
+ * Register definitions and descriptions are from LinCAN 0.3.3.
+ *
  * PSB4610 PITA-2 bridge control registers
  */
 #define PITA2_ICR   0x00   /* Interrupt Control Register */
@@ -64,7 +71,17 @@ struct rtcan_ems_pci
 #define PITA2_ICR_INT0_EN   0x0002 /* [RW] Enable INT0 */
 
 #define PITA2_MISC  0x1c   /* Miscellaneous Register */
-#define PITA2_MISC_CONFIG   0x0400 /* Multiplexed Parallel_interface_model 
*/
+#define PITA2_MISC_CONFIG   0x0400 /* Multiplexed parallel interface */
+
+/*
+ * Register definitions for the PLX 9030
+ */
+#define PLX_ICSR  

[Xenomai-git] Wolfgang Grandegger : rtcan: ems_pci driver update to support more devices

2016-11-15 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 6c03c92c496e3f719e8322c4180f865e29daa452
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6c03c92c496e3f719e8322c4180f865e29daa452

Author: Wolfgang Grandegger 
Date:   Fri Oct 28 09:25:00 2016 +0200

rtcan: ems_pci driver update to support more devices

Hi Philippe

Am 06.10.2016 um 21:40 schrieb Philippe Gerum:
> >
> > Hi Wolfgang,
> >
> > On 10/04/2016 08:25 AM, Wolfgang Grandegger wrote:
>> >> The driver follows now more closely the corresponding Linux driver
>> >> to simplify updates in the future.
>> >>
> >
> > Any chance to have this forward ported to 3.x? Xenomai 2.6 has reached EOL.

Below is the patch for Xenomai-3. It's untested for the moment but the
changes compared with 2.6 seem not the be critical.

Wolfgang

>From 0fc42b023eb9f6f58ce3b2381a55cab74757c2a1 Mon Sep 17 00:00:00 2001
From: Wolfgang Grandegger 
Date: Fri, 28 Oct 2016 09:21:24 +0200
Subject: [PATCH] [PATCH] rtcan: ems_pci driver update to support more devices

The driver now also follows more closely the corresponding Linux
driver to simplify updates in the future.

Signed-off-by: Wolfgang Grandegger 

---

 kernel/drivers/can/sja1000/rtcan_ems_pci.c  |  487 +--
 kernel/drivers/can/sja1000/rtcan_sja1000_regs.h |1 +
 2 files changed, 281 insertions(+), 207 deletions(-)

diff --git a/kernel/drivers/can/sja1000/rtcan_ems_pci.c 
b/kernel/drivers/can/sja1000/rtcan_ems_pci.c
index be4b704..e3c178f 100644
--- a/kernel/drivers/can/sja1000/rtcan_ems_pci.c
+++ b/kernel/drivers/can/sja1000/rtcan_ems_pci.c
@@ -1,28 +1,28 @@
 /*
- * Copyright (C) 2007 Wolfgang Grandegger 
+ * Copyright (C) 2007, 2016 Wolfgang Grandegger 
+ * Copyright (C) 2008 Markus Plessing 
+ * Copyright (C) 2008 Sebastian Haas 
  *
- * Register definitions and descriptions are taken from LinCAN 0.3.3.
+ * Derived from Linux CAN SJA1000 PCI driver "ems_pci".
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the version 2 of the GNU General Public License
+ * as published by the Free Software Foundation
  *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with this program; if not, see .
  */
 
+#include 
 #include 
-#include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 
@@ -40,23 +40,30 @@
 static char *ems_pci_board_name = "EMS-CPC-PCI";
 
 MODULE_AUTHOR("Wolfgang Grandegger ");
-MODULE_DESCRIPTION("RTCAN board driver for EMS CPC-PCI cards");
-MODULE_SUPPORTED_DEVICE("EMS CPC-PCI card CAN controller");
-MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("RTCAN board driver for EMS CPC-PCI/PCIe/104P CAN cards");
+MODULE_SUPPORTED_DEVICE("EMS CPC-PCI/PCIe/104P CAN card");
+MODULE_LICENSE("GPL v2");
+
+#define EMS_PCI_V1_MAX_CHAN 2
+#define EMS_PCI_V2_MAX_CHAN 4
+#define EMS_PCI_MAX_CHANEMS_PCI_V2_MAX_CHAN
+
+struct ems_pci_card {
+   int version;
+   int channels;
 
-struct rtcan_ems_pci
-{
struct pci_dev *pci_dev;
-   struct rtcan_device *slave_dev;
-   int channel;
-   volatile void __iomem *base_addr;
-   volatile void __iomem *conf_addr;
+   struct rtcan_device *rtcan_dev[EMS_PCI_MAX_CHAN];
+
+   void __iomem *conf_addr;
+   void __iomem *base_addr;
 };
 
-#define EMS_PCI_MASTER 1 /* multi channel device, this device is master */
-#define EMS_PCI_SLAVE  2 /* multi channel device, this is slave */
+#define EMS_PCI_CAN_CLOCK (1600 / 2)
 
 /*
+ * Register definitions and descriptions are from LinCAN 0.3.3.
+ *
  * PSB4610 PITA-2 bridge control registers
  */
 #define PITA2_ICR   0x00   /* Interrupt Control Register */
@@ -64,7 +71,17 @@ struct rtcan_ems_pci
 #define PITA2_ICR_INT0_EN   0x0002 /* [RW] Enable INT0 */
 
 #define PITA2_MISC  0x1c   /* Miscellaneous Register */
-#define PITA2_MISC_CONFIG   0x0400 /* Multiplexed Parallel_interface_model 
*/
+#define PITA2_MISC_CONFIG   0x0400 /* Multiplexed parallel interface */
+
+/*
+ * Register definitions for the PLX 9030
+ */
+#define PLX_ICSR0x4c 

[Xenomai-git] Wolfgang Grandegger : rtcan: ems_pci driver update to support more devices

2016-10-30 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 641827d0c029e3c2cf42cb02fdaa845da98b0619
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=641827d0c029e3c2cf42cb02fdaa845da98b0619

Author: Wolfgang Grandegger 
Date:   Fri Oct 28 09:25:00 2016 +0200

rtcan: ems_pci driver update to support more devices

Hi Philippe

Am 06.10.2016 um 21:40 schrieb Philippe Gerum:
> >
> > Hi Wolfgang,
> >
> > On 10/04/2016 08:25 AM, Wolfgang Grandegger wrote:
>> >> The driver follows now more closely the corresponding Linux driver
>> >> to simplify updates in the future.
>> >>
> >
> > Any chance to have this forward ported to 3.x? Xenomai 2.6 has reached EOL.

Below is the patch for Xenomai-3. It's untested for the moment but the
changes compared with 2.6 seem not the be critical.

Wolfgang

>From 0fc42b023eb9f6f58ce3b2381a55cab74757c2a1 Mon Sep 17 00:00:00 2001
From: Wolfgang Grandegger 
Date: Fri, 28 Oct 2016 09:21:24 +0200
Subject: [PATCH] [PATCH] rtcan: ems_pci driver update to support more devices

The driver now also follows more closely the corresponding Linux
driver to simplify updates in the future.

Signed-off-by: Wolfgang Grandegger 

---

 kernel/drivers/can/sja1000/rtcan_ems_pci.c  |  487 +--
 kernel/drivers/can/sja1000/rtcan_sja1000_regs.h |1 +
 2 files changed, 281 insertions(+), 207 deletions(-)

diff --git a/kernel/drivers/can/sja1000/rtcan_ems_pci.c 
b/kernel/drivers/can/sja1000/rtcan_ems_pci.c
index be4b704..e3c178f 100644
--- a/kernel/drivers/can/sja1000/rtcan_ems_pci.c
+++ b/kernel/drivers/can/sja1000/rtcan_ems_pci.c
@@ -1,28 +1,28 @@
 /*
- * Copyright (C) 2007 Wolfgang Grandegger 
+ * Copyright (C) 2007, 2016 Wolfgang Grandegger 
+ * Copyright (C) 2008 Markus Plessing 
+ * Copyright (C) 2008 Sebastian Haas 
  *
- * Register definitions and descriptions are taken from LinCAN 0.3.3.
+ * Derived from Linux CAN SJA1000 PCI driver "ems_pci".
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the version 2 of the GNU General Public License
+ * as published by the Free Software Foundation
  *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with this program; if not, see .
  */
 
+#include 
 #include 
-#include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 
@@ -40,23 +40,30 @@
 static char *ems_pci_board_name = "EMS-CPC-PCI";
 
 MODULE_AUTHOR("Wolfgang Grandegger ");
-MODULE_DESCRIPTION("RTCAN board driver for EMS CPC-PCI cards");
-MODULE_SUPPORTED_DEVICE("EMS CPC-PCI card CAN controller");
-MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("RTCAN board driver for EMS CPC-PCI/PCIe/104P CAN cards");
+MODULE_SUPPORTED_DEVICE("EMS CPC-PCI/PCIe/104P CAN card");
+MODULE_LICENSE("GPL v2");
+
+#define EMS_PCI_V1_MAX_CHAN 2
+#define EMS_PCI_V2_MAX_CHAN 4
+#define EMS_PCI_MAX_CHANEMS_PCI_V2_MAX_CHAN
+
+struct ems_pci_card {
+   int version;
+   int channels;
 
-struct rtcan_ems_pci
-{
struct pci_dev *pci_dev;
-   struct rtcan_device *slave_dev;
-   int channel;
-   volatile void __iomem *base_addr;
-   volatile void __iomem *conf_addr;
+   struct rtcan_device *rtcan_dev[EMS_PCI_MAX_CHAN];
+
+   void __iomem *conf_addr;
+   void __iomem *base_addr;
 };
 
-#define EMS_PCI_MASTER 1 /* multi channel device, this device is master */
-#define EMS_PCI_SLAVE  2 /* multi channel device, this is slave */
+#define EMS_PCI_CAN_CLOCK (1600 / 2)
 
 /*
+ * Register definitions and descriptions are from LinCAN 0.3.3.
+ *
  * PSB4610 PITA-2 bridge control registers
  */
 #define PITA2_ICR   0x00   /* Interrupt Control Register */
@@ -64,7 +71,17 @@ struct rtcan_ems_pci
 #define PITA2_ICR_INT0_EN   0x0002 /* [RW] Enable INT0 */
 
 #define PITA2_MISC  0x1c   /* Miscellaneous Register */
-#define PITA2_MISC_CONFIG   0x0400 /* Multiplexed Parallel_interface_model 
*/
+#define PITA2_MISC_CONFIG   0x0400 /* Multiplexed parallel interface */
+
+/*
+ * Register definitions for the PLX 9030
+ */
+#define PLX_ICSR0x4c 

[Xenomai-git] Wolfgang Grandegger : rtcan: ems_pci driver update to support more devices

2016-10-30 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: 6c03c92c496e3f719e8322c4180f865e29daa452
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6c03c92c496e3f719e8322c4180f865e29daa452

Author: Wolfgang Grandegger 
Date:   Fri Oct 28 09:25:00 2016 +0200

rtcan: ems_pci driver update to support more devices

Hi Philippe

Am 06.10.2016 um 21:40 schrieb Philippe Gerum:
> >
> > Hi Wolfgang,
> >
> > On 10/04/2016 08:25 AM, Wolfgang Grandegger wrote:
>> >> The driver follows now more closely the corresponding Linux driver
>> >> to simplify updates in the future.
>> >>
> >
> > Any chance to have this forward ported to 3.x? Xenomai 2.6 has reached EOL.

Below is the patch for Xenomai-3. It's untested for the moment but the
changes compared with 2.6 seem not the be critical.

Wolfgang

>From 0fc42b023eb9f6f58ce3b2381a55cab74757c2a1 Mon Sep 17 00:00:00 2001
From: Wolfgang Grandegger 
Date: Fri, 28 Oct 2016 09:21:24 +0200
Subject: [PATCH] [PATCH] rtcan: ems_pci driver update to support more devices

The driver now also follows more closely the corresponding Linux
driver to simplify updates in the future.

Signed-off-by: Wolfgang Grandegger 

---

 kernel/drivers/can/sja1000/rtcan_ems_pci.c  |  487 +--
 kernel/drivers/can/sja1000/rtcan_sja1000_regs.h |1 +
 2 files changed, 281 insertions(+), 207 deletions(-)

diff --git a/kernel/drivers/can/sja1000/rtcan_ems_pci.c 
b/kernel/drivers/can/sja1000/rtcan_ems_pci.c
index be4b704..e3c178f 100644
--- a/kernel/drivers/can/sja1000/rtcan_ems_pci.c
+++ b/kernel/drivers/can/sja1000/rtcan_ems_pci.c
@@ -1,28 +1,28 @@
 /*
- * Copyright (C) 2007 Wolfgang Grandegger 
+ * Copyright (C) 2007, 2016 Wolfgang Grandegger 
+ * Copyright (C) 2008 Markus Plessing 
+ * Copyright (C) 2008 Sebastian Haas 
  *
- * Register definitions and descriptions are taken from LinCAN 0.3.3.
+ * Derived from Linux CAN SJA1000 PCI driver "ems_pci".
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the version 2 of the GNU General Public License
+ * as published by the Free Software Foundation
  *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with this program; if not, see .
  */
 
+#include 
 #include 
-#include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 
@@ -40,23 +40,30 @@
 static char *ems_pci_board_name = "EMS-CPC-PCI";
 
 MODULE_AUTHOR("Wolfgang Grandegger ");
-MODULE_DESCRIPTION("RTCAN board driver for EMS CPC-PCI cards");
-MODULE_SUPPORTED_DEVICE("EMS CPC-PCI card CAN controller");
-MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("RTCAN board driver for EMS CPC-PCI/PCIe/104P CAN cards");
+MODULE_SUPPORTED_DEVICE("EMS CPC-PCI/PCIe/104P CAN card");
+MODULE_LICENSE("GPL v2");
+
+#define EMS_PCI_V1_MAX_CHAN 2
+#define EMS_PCI_V2_MAX_CHAN 4
+#define EMS_PCI_MAX_CHANEMS_PCI_V2_MAX_CHAN
+
+struct ems_pci_card {
+   int version;
+   int channels;
 
-struct rtcan_ems_pci
-{
struct pci_dev *pci_dev;
-   struct rtcan_device *slave_dev;
-   int channel;
-   volatile void __iomem *base_addr;
-   volatile void __iomem *conf_addr;
+   struct rtcan_device *rtcan_dev[EMS_PCI_MAX_CHAN];
+
+   void __iomem *conf_addr;
+   void __iomem *base_addr;
 };
 
-#define EMS_PCI_MASTER 1 /* multi channel device, this device is master */
-#define EMS_PCI_SLAVE  2 /* multi channel device, this is slave */
+#define EMS_PCI_CAN_CLOCK (1600 / 2)
 
 /*
+ * Register definitions and descriptions are from LinCAN 0.3.3.
+ *
  * PSB4610 PITA-2 bridge control registers
  */
 #define PITA2_ICR   0x00   /* Interrupt Control Register */
@@ -64,7 +71,17 @@ struct rtcan_ems_pci
 #define PITA2_ICR_INT0_EN   0x0002 /* [RW] Enable INT0 */
 
 #define PITA2_MISC  0x1c   /* Miscellaneous Register */
-#define PITA2_MISC_CONFIG   0x0400 /* Multiplexed Parallel_interface_model 
*/
+#define PITA2_MISC_CONFIG   0x0400 /* Multiplexed parallel interface */
+
+/*
+ * Register definitions for the PLX 9030
+ */
+#define PLX_ICSR 

[Xenomai-git] Wolfgang Grandegger : rtcan: ems_pci driver update to support more devices

2016-10-06 Thread git repository hosting
Module: xenomai-2.6
Branch: master
Commit: 252847ee575fb3ead970dd6d746875785dfa5c36
URL:
http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=252847ee575fb3ead970dd6d746875785dfa5c36

Author: Wolfgang Grandegger 
Date:   Tue Oct  4 08:25:00 2016 +0200

rtcan: ems_pci driver update to support more devices

The driver follows now more closely the corresponding Linux driver
to simplify updates in the future.

Signed-off-by: Wolfgang Grandegger 

---

 ksrc/drivers/can/sja1000/rtcan_ems_pci.c  |  487 ++---
 ksrc/drivers/can/sja1000/rtcan_sja1000_regs.h |1 +
 2 files changed, 281 insertions(+), 207 deletions(-)

diff --git a/ksrc/drivers/can/sja1000/rtcan_ems_pci.c 
b/ksrc/drivers/can/sja1000/rtcan_ems_pci.c
index 4a88ca6..868d236 100644
--- a/ksrc/drivers/can/sja1000/rtcan_ems_pci.c
+++ b/ksrc/drivers/can/sja1000/rtcan_ems_pci.c
@@ -1,28 +1,28 @@
 /*
- * Copyright (C) 2007 Wolfgang Grandegger 
+ * Copyright (C) 2007, 2016 Wolfgang Grandegger 
+ * Copyright (C) 2008 Markus Plessing 
+ * Copyright (C) 2008 Sebastian Haas 
  *
- * Register definitions and descriptions are taken from LinCAN 0.3.3.
+ * Derived from Linux CAN SJA1000 PCI driver "ems_pci".
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the version 2 of the GNU General Public License
+ * as published by the Free Software Foundation
  *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with this program; if not, see .
  */
 
+#include 
 #include 
-#include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 
@@ -40,23 +40,30 @@
 static char *ems_pci_board_name = "EMS-CPC-PCI";
 
 MODULE_AUTHOR("Wolfgang Grandegger ");
-MODULE_DESCRIPTION("RTCAN board driver for EMS CPC-PCI cards");
-MODULE_SUPPORTED_DEVICE("EMS CPC-PCI card CAN controller");
-MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("RTCAN board driver for EMS CPC-PCI/PCIe/104P CAN cards");
+MODULE_SUPPORTED_DEVICE("EMS CPC-PCI/PCIe/104P CAN card");
+MODULE_LICENSE("GPL v2");
+
+#define EMS_PCI_V1_MAX_CHAN 2
+#define EMS_PCI_V2_MAX_CHAN 4
+#define EMS_PCI_MAX_CHANEMS_PCI_V2_MAX_CHAN
+
+struct ems_pci_card {
+   int version;
+   int channels;
 
-struct rtcan_ems_pci
-{
struct pci_dev *pci_dev;
-   struct rtcan_device *slave_dev;
-   int channel;
-   volatile void __iomem *base_addr;
-   volatile void __iomem *conf_addr;
+   struct rtcan_device *rtcan_dev[EMS_PCI_MAX_CHAN];
+
+   void __iomem *conf_addr;
+   void __iomem *base_addr;
 };
 
-#define EMS_PCI_MASTER 1 /* multi channel device, this device is master */
-#define EMS_PCI_SLAVE  2 /* multi channel device, this is slave */
+#define EMS_PCI_CAN_CLOCK (1600 / 2)
 
 /*
+ * Register definitions and descriptions are from LinCAN 0.3.3.
+ *
  * PSB4610 PITA-2 bridge control registers
  */
 #define PITA2_ICR   0x00   /* Interrupt Control Register */
@@ -64,7 +71,17 @@ struct rtcan_ems_pci
 #define PITA2_ICR_INT0_EN   0x0002 /* [RW] Enable INT0 */
 
 #define PITA2_MISC  0x1c   /* Miscellaneous Register */
-#define PITA2_MISC_CONFIG   0x0400 /* Multiplexed Parallel_interface_model 
*/
+#define PITA2_MISC_CONFIG   0x0400 /* Multiplexed parallel interface */
+
+/*
+ * Register definitions for the PLX 9030
+ */
+#define PLX_ICSR0x4c   /* Interrupt Control/Status register */
+#define PLX_ICSR_LINTI1_ENA 0x0001 /* LINTi1 Enable */
+#define PLX_ICSR_PCIINT_ENA 0x0040 /* PCI Interrupt Enable */
+#define PLX_ICSR_LINTI1_CLR 0x0400 /* Local Edge Triggerable Interrupt Clear */
+#define PLX_ICSR_ENA_CLR(PLX_ICSR_LINTI1_ENA | PLX_ICSR_PCIINT_ENA | \
+PLX_ICSR_LINTI1_CLR)
 
 /*
  * The board configuration is probably following:
@@ -72,9 +89,9 @@ struct rtcan_ems_pci
  * TX1 is not connected.
  * CLKO is not connected.
  * Setting the OCR register to 0xDA is a good idea.
- * This means  normal output mode , push-pull and the correct polarity.
+ * This means normal output mode, push-pull and the correct