From: Wolfgang Grandegger <wg@grandegger.com>
To: Michael Pellegrini <mikep86@gmail.com>
Cc: linux-can@vger.kernel.org
Subject: Re: pch_can: Data transmission stops after dropped packet
Date: Sun, 18 Nov 2012 23:22:57 +0100 [thread overview]
Message-ID: <50A95FC1.3050907@grandegger.com> (raw)
In-Reply-To: <loom.20121115T222748-977@post.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 4889 bytes --]
On 11/15/2012 10:34 PM, Michael Pellegrini wrote:
> Wolfgang Grandegger <wg <at> grandegger.com> writes:
>
>> I need to check first if this driver can be supported with little effort.
>
> Thank you for your consideration.
For simple out-of-tree build I have now extracted the most recent
version of c_can and c_can_pci driver files, backported it to v3.2 and
added the PCH related code.
You should be able to build these drivers on your system as shown below:
$ tar xf c-can-pci-v1.tar.bz2
$ cd c-can-pci-v1
$ CONFIG_CAN_C_CAN_PCI=m \
make -C /usr/src/linux-headers-`uname -r` SUBDIRS=`pwd` modules
This requires that you have the kernel header, gcc and fiends installed
on your system.
Then you can load the modules as shown below, after unloading the
original C_CAN modules:
$ sudo modprobe can_dev
$ rmmod c_can
$ rmmod c_can_pci
$ sudo insmod c_can.ko
$ sudo insmod c_can_pci.ko
Hope it works as expected.
Below is the patch I used for this driver:
From 562bbd0840e710d45ee211a0f99e5a5288dff4ba Mon Sep 17 00:00:00 2001
From: Wolfgang Grandegger <wg@grandegger.com>
Date: Sun, 18 Nov 2012 23:14:04 +0100
Subject: [PATCH] c_can_pci: first hack to get out-of-tree C_CAN_PCI driver to
work
---
c_can.c | 3 +++
c_can.h | 1 +
c_can_pci.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/c_can.c b/c_can.c
index e5180df..23fbcd3 100644
--- a/c_can.c
+++ b/c_can.c
@@ -1106,6 +1106,9 @@ static int c_can_open(struct net_device *dev)
goto exit_irq_fail;
}
+ if (priv->reset)
+ priv->reset(priv);
+
napi_enable(&priv->napi);
/* start the c_can controller */
diff --git a/c_can.h b/c_can.h
index e5ed41d..4bad1d4 100644
--- a/c_can.h
+++ b/c_can.h
@@ -161,6 +161,7 @@ struct c_can_priv {
int last_status;
u16 (*read_reg) (struct c_can_priv *priv, enum reg index);
void (*write_reg) (struct c_can_priv *priv, enum reg index, u16 val);
+ void (*reset) (struct c_can_priv *priv);
void __iomem *base;
const u16 *regs;
unsigned long irq_flags; /* for request_irq() */
diff --git a/c_can_pci.c b/c_can_pci.c
index f8bcd73..017d008 100644
--- a/c_can_pci.c
+++ b/c_can_pci.c
@@ -21,12 +21,17 @@
#include "c_can.h"
#ifndef PCI_DEVICE_ID_STMICRO_CAN
-#define PCI_DEVICE_ID_STMICRO_CAN 0xCC11
+#define PCI_DEVICE_ID_STMICRO_CAN 0xCC11
#endif
+#ifndef PCI_DEVICE_ID_PCH_CAN
+#define PCI_DEVICE_ID_PCH_CAN 0x8818
+#endif
+#define PCH_PCI_SOFT_RESET 0x01fc
enum c_can_pci_reg_align {
C_CAN_REG_ALIGN_16,
C_CAN_REG_ALIGN_32,
+ C_CAN_REG_32,
};
struct c_can_pci_data {
@@ -36,6 +41,8 @@ struct c_can_pci_data {
enum c_can_pci_reg_align reg_align;
/* Set the frequency */
unsigned int freq;
+ /* CAN reset callback */
+ void (*reset) (struct c_can_priv *priv);
};
/*
@@ -68,6 +75,27 @@ static void c_can_pci_write_reg_aligned_to_32bit(struct c_can_priv *priv,
writew(val, priv->base + 2 * priv->regs[index]);
}
+static u16 c_can_pci_read_reg_32bit(struct c_can_priv *priv,
+ enum reg index)
+{
+ return ioread32(priv->base + 4 * priv->regs[index]);
+}
+
+static void c_can_pci_write_reg_32bit(struct c_can_priv *priv,
+ enum reg index, u16 val)
+{
+ iowrite32(val, priv->base + 4 * priv->regs[index]);
+}
+
+static void c_can_pci_reset_pch(struct c_can_priv *priv)
+{
+ u32 __iomem *addr = (u32 __iomem *)(priv->regs + PCH_PCI_SOFT_RESET);
+
+ /* write to sw reset register */
+ iowrite32(1, addr);
+ iowrite32(0, addr);
+}
+
static int __devinit c_can_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
@@ -147,11 +175,17 @@ static int __devinit c_can_pci_probe(struct pci_dev *pdev,
priv->read_reg = c_can_pci_read_reg_aligned_to_16bit;
priv->write_reg = c_can_pci_write_reg_aligned_to_16bit;
break;
+ case C_CAN_REG_32:
+ priv->read_reg = c_can_pci_read_reg_32bit;
+ priv->write_reg = c_can_pci_write_reg_32bit;
+ break;
default:
ret = -EINVAL;
goto out_free_c_can;
}
+ priv->reset = c_can_pci_data->reset;
+
ret = register_c_can_dev(dev);
if (ret) {
dev_err(&pdev->dev, "registering %s failed (err=%d)\n",
@@ -202,6 +236,13 @@ static struct c_can_pci_data c_can_sta2x11= {
.freq = 52000000, /* 52 Mhz */
};
+static struct c_can_pci_data c_can_pch = {
+ .type = BOSCH_C_CAN,
+ .reg_align = C_CAN_REG_32,
+ .freq = 50000000, /* 50 MHz */
+ .reset = c_can_pci_reset_pch,
+};
+
#define C_CAN_ID(_vend, _dev, _driverdata) { \
PCI_DEVICE(_vend, _dev), \
.driver_data = (unsigned long)&_driverdata, \
@@ -209,6 +250,8 @@ static struct c_can_pci_data c_can_sta2x11= {
static DEFINE_PCI_DEVICE_TABLE(c_can_pci_tbl) = {
C_CAN_ID(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_CAN,
c_can_sta2x11),
+ C_CAN_ID(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PCH_CAN,
+ c_can_pch),
{},
};
static struct pci_driver c_can_pci_driver = {
--
1.7.9.5
Wolfgang.
[-- Attachment #2: c-can-pci-v1.tar.bz2 --]
[-- Type: application/x-bzip, Size: 10840 bytes --]
next prev parent reply other threads:[~2012-11-18 22:23 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-14 15:39 pch_can: Data transmission stops after dropped packet Michael Pellegrini
2012-11-14 21:40 ` Michael Pellegrini
2012-11-15 7:18 ` Oliver Hartkopp
2012-11-15 13:13 ` Wolfgang Grandegger
2012-11-15 16:23 ` Michael Pellegrini
2012-11-15 21:19 ` Wolfgang Grandegger
2012-11-15 21:34 ` Michael Pellegrini
2012-11-15 21:51 ` Wolfgang Grandegger
2012-11-18 22:22 ` Wolfgang Grandegger [this message]
2012-11-19 15:10 ` Michael Pellegrini
2012-11-19 15:26 ` Wolfgang Grandegger
2012-11-19 16:20 ` Michael Pellegrini
2012-11-19 16:31 ` Wolfgang Grandegger
2012-11-19 17:39 ` Michael Pellegrini
2012-11-19 19:22 ` Wolfgang Grandegger
2012-11-19 20:19 ` Michael Pellegrini
2012-11-19 21:46 ` Wolfgang Grandegger
2012-11-20 14:25 ` Michael Pellegrini
2012-11-20 16:12 ` Wolfgang Grandegger
2012-11-20 19:12 ` Michael Pellegrini
2012-11-20 21:05 ` Wolfgang Grandegger
2012-11-21 10:24 ` Wolfgang Grandegger
[not found] ` <loom.20121121T160744-278@post.gmane.or g>
2012-11-21 15:15 ` Michael Pellegrini
[not found] ` <loom.20121121T160744-278@post.gmane.or g>
2012-11-21 15:25 ` Michael Pellegrini
2012-11-21 15:32 ` Marc Kleine-Budde
2012-11-21 16:11 ` Michael Pellegrini
2012-11-21 15:41 ` Michael Pellegrini
2012-11-21 15:56 ` Wolfgang Grandegger
2012-11-21 16:09 ` Michael Pellegrini
2012-11-21 16:41 ` Wolfgang Grandegger
2012-11-21 16:58 ` Casper Mogensen
2012-11-21 19:48 ` Wolfgang Grandegger
2012-11-21 17:43 ` Michael Pellegrini
2012-11-21 19:55 ` Wolfgang Grandegger
2012-11-21 21:00 ` Michael Pellegrini
2012-11-23 14:27 ` Michael Pellegrini
2012-11-23 14:45 ` Wolfgang Grandegger
2012-11-23 14:47 ` Wolfgang Grandegger
2012-11-23 15:14 ` Michael Pellegrini
2012-11-23 15:04 ` Michael Pellegrini
2012-11-23 17:00 ` Wolfgang Grandegger
2012-11-23 17:18 ` Wolfgang Grandegger
2012-11-23 17:52 ` Michael Pellegrini
2012-11-25 16:17 ` Wolfgang Grandegger
2012-11-26 14:54 ` Michael Pellegrini
2012-11-26 15:30 ` Wolfgang Grandegger
2012-11-26 17:30 ` Michael Pellegrini
2012-11-26 18:13 ` Wolfgang Grandegger
2012-11-29 12:15 ` Wolfgang Grandegger
2012-11-29 14:15 ` Michael Pellegrini
2012-12-06 14:20 ` Michael Pellegrini
2012-12-06 14:23 ` Marc Kleine-Budde
2012-12-06 14:41 ` Wolfgang Grandegger
2012-12-06 14:42 ` Marc Kleine-Budde
2012-12-06 14:42 ` Michael Pellegrini
2012-12-06 14:49 ` Wolfgang Grandegger
2012-12-06 17:05 ` Alexander Stein
2012-12-06 22:02 ` Wolfgang Grandegger
2012-12-06 23:24 ` Marc Kleine-Budde
2012-12-10 8:21 ` Alexander Stein
2012-12-11 20:24 ` Wolfgang Grandegger
2012-12-13 14:04 ` Alexander Stein
2012-12-11 14:46 ` Michael Pellegrini
2012-12-11 20:21 ` Wolfgang Grandegger
2012-12-12 13:35 ` Alexander Stein
2012-12-06 22:11 ` Michael Pellegrini
2012-12-06 23:23 ` Michael Pellegrini
2012-11-24 7:16 ` Wolfgang Grandegger
2012-11-26 3:33 ` Bhupesh SHARMA
2012-11-21 14:52 ` Michael Pellegrini
2012-11-21 15:02 ` Wolfgang Grandegger
2012-11-15 16:32 ` Casper Mogensen
2012-11-15 21:16 ` Wolfgang Grandegger
2012-11-16 19:39 ` Wolfgang Grandegger
2012-11-15 16:12 ` Michael Pellegrini
2012-11-20 18:59 ` Wolfgang Grandegger
2012-11-15 12:35 ` Steffen Rose
2012-11-15 18:26 ` Michael Pellegrini
2012-11-16 8:24 ` Steffen Rose
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50A95FC1.3050907@grandegger.com \
--to=wg@grandegger.com \
--cc=linux-can@vger.kernel.org \
--cc=mikep86@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).