Skip to contentSkip to conversation

can: CAN network device driver interface and drivers

PATCH Applied Wolfgang Grandegger 2 participants 10 messages May 16, 2009 – May 20, 2009

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v3 cover can: CAN network device driver interface and drivers

Hello,

here comes v3 of this patch series.

The PF_CAN protocol family for the Controller Area Network is available in the kernel since version 2.6.25 but drivers for real CAN devices are still missing. This patch series adds a generic CAN network device driver interface and, as a start, a few drivers. It is the result of the on-going discussion and development of the Socket-CAN project hosted at the BerliOS web-server (http://developer.berlios.de/projects/socketcan).
The patch series consists of the following patches:

1/7) can: Documentation for the CAN device driver interface 2/7) can: Update MAINTAINERS and CREDITS file 3/7) can: CAN Network device driver and Netlink interface 4/7) can: Driver for the SJA1000 CAN controller 5/7) can: SJA1000 generic platform bus driver 6/7) can: SJA1000 driver for EMS PCI cards
7/7) can: SJA1000 driver for Kvaser PCI cards

Changes since v2:
(see http://marc.info/?l=linux-netdev&m=124212048701347&w=4)

- Fix dead-lock with netif_tx_lock used in can_restart_now() pointed out by Andrew Morton. A restart via netlink interface is now only allowed in case of bus-off conditions, which does not require taking the netif_tx_lock. Actually no extra locking is required as the device is "quiet" and the restart delay can not longer be changed while the device is running.

- can_restart_now() now uses "goto out" to handle error conditions properly as suggested by Jonathan Corbet.

- Add member "irq_flags" to "struct sja1000_priv" which will then be used by the request_irq() as suggested by Sascha Hauer. The driver must set it appropriately, including IRQF_SHARED. This also fixes the problem, that drivers used it unnecessarily.

- Fixes for drives/net/can/sja1000.c suggested by Jonathan Corbet:
- call close_candev() to cleanup if the open function fails.
- use negative return code if set_reset/normal_mode() fails.
- call udelay() before the status is checked.

- Fixes for drives/net/can/sja1000_platform.c suggested by Jonathan Corbet and Sascha Hauer:
- use resource_size() where appropriate.
- call iounmap() before release_mem_region() in the exit path.

- Fixes for drives/net/can/kvasar_pci.c suggested by Jonathan Corbet:
- dont use the name "tmp" to avoid reviewers getting grumpy.
- remove udelay(10) in the loop scanning the device on the card.
- there is no need to check the return value of netdev_priv().
- correct procedure of enabling and disabling PCI interrupts.
- use proper exit label if pci_iomap() fails.
- fix cleanup code under label failure_iounmap.

- More documentation of the "struct sja1000_priv" as suggested by Jonathan Corbet.

- Registration of the netlink interface and netdev devices corrected to fix an oops when unloading the driver.

Changes since v1:
(see http://marc.info/?l=linux-netdev&m=123507025810612&w=4.)

- The SysFS interface has been replaced by the Netlink interface. See chapter 6.5 of "Documentation/networking/can.txt" and have a look to "include/linux/can/netdev.h" for further information. The patch for the "ip" program of the iproute2 utility suite will be provided separately.

- The restart function is now properly protected by "dev->tx_lock" using the "netif_tx_[lock|unlock]" functions.

- For the restart, the device driver must now handle CAN_MODE_STOP as well, apart from CAN_MODE_START to avoid race conditions.

- The "irq_lock" member of "struct can_priv" has been removed. The CAN controller driver may should provide its own synchronization if necessary.

- The restart function is now protected by "dev->tx_lock" using the "netif_tx_lock/unlock" functions.

- Cleanup timer usage for the restart function.

- The unused do_set/get_ctrlmode member of "struct can_priv" have been removed.

- "const" has been added to "struct net_device" for some functions not allowed to touch that structure.

- The library functions "can_set_bittiming" and "can_close_cleanup" have been renamed to the more general names "open_candev" and "close_candev", respectively.

- Use "del_timer_sync" instead of "del_timer" for the re-start timer.

- The macro "ND2D()" has been replaced by "dev->dev.parent" as it does not make the code more readable.

- Fix improper BTR setting for triple-sampling for the SJA1000 as pointed out by Oliver.

- Dont use __u8 but __u32 as before for some members of "struct can_bittiming[_const]" to avoid alignment trouble.

- Definitions shared with user-space applications have been moved to "include/linux/can/netlink.h".

- Various other minor correction suggested on the netdev ML.

- The MSCAN driver for the MPC5200 has been removed. It needs to be presented on the Linuxppc-dev and Devicetree-discuss ML as well, which will be done by a sub-sequent patch.

- Add more source code documentation, especially for the structures and functions related to bit-timing.

Please consider these patches for inclusion.

Thanks,

Wolfgang.

#1 lore raw

PATCH v3 1/8 can: Documentation for the CAN device driver interface

This patch documents the CAN netowrk device drivers interface, removes obsolete documentation and adds some useful links to CAN resources.

---
 Documentation/networking/can.txt |  239 ++++++++++++++++++++++++++++++++-------
 1 file changed, 199 insertions(+), 40 deletions(-)
Documentation/networking/can.txt +199 -40
Index: net-next-2.6/Documentation/networking/can.txt
===================================================================
@@ -36,10 +36,15 @@
     6.2 local loopback of sent frames
     6.3 CAN controller hardware filters
     6.4 The virtual CAN driver (vcan)
-    6.5 currently supported CAN hardware
-    6.6 todo
+    6.5 The CAN network device driver interface
+      6.5.1 Netlink interface to set/get devices properties
+      6.5.2 Setting the CAN bit-timing
+      6.5.3 Starting and stopping the CAN network device
+    6.6 supported CAN hardware
 
-  7 Credits
+  7 Socket CAN resources
+
+  8 Credits
 
 ============================================================================
 
@@ -234,6 +239,8 @@
   the user application using the common CAN filter mechanisms. Inside
   this filter definition the (interested) type of errors may be
   selected. The reception of error frames is disabled by default.
+  The format of the CAN error frame is briefly decribed in the Linux
+  header file "include/linux/can/error.h".
 
 4. How to use Socket CAN
 ------------------------
@@ -605,61 +612,213 @@
   removal of vcan network devices can be managed with the ip(8) tool:
 
   - Create a virtual CAN network interface:
-       ip link add type vcan
+       $ ip link add type vcan
 
   - Create a virtual CAN network interface with a specific name 'vcan42':
-       ip link add dev vcan42 type vcan
+       $ ip link add dev vcan42 type vcan
 
   - Remove a (virtual CAN) network interface 'vcan42':
-       ip link del vcan42
-
-  The tool 'vcan' from the SocketCAN SVN repository on BerliOS is obsolete.
-
-  Virtual CAN network device creation in older Kernels:
-  In Linux Kernel versions < 2.6.24 the vcan driver creates 4 vcan
-  netdevices at module load time by default. This value can be changed
-  with the module parameter 'numdev'. E.g. 'modprobe vcan numdev=8'
-
-  6.5 currently supported CAN hardware
-
-  On the project website http://developer.berlios.de/projects/socketcan
-  there are different drivers available:
-
-    vcan:    Virtual CAN interface driver (if no real hardware is available)
-    sja1000: Philips SJA1000 CAN controller (recommended)
-    i82527:  Intel i82527 CAN controller
-    mscan:   Motorola/Freescale CAN controller (e.g. inside SOC MPC5200)
-    ccan:    CCAN controller core (e.g. inside SOC h7202)
-    slcan:   For a bunch of CAN adaptors that are attached via a
-             serial line ASCII protocol (for serial / USB adaptors)
+       $ ip link del vcan42
 
-  Additionally the different CAN adaptors (ISA/PCI/PCMCIA/USB/Parport)
-  from PEAK Systemtechnik support the CAN netdevice driver model
-  since Linux driver v6.0: http://www.peak-system.com/linux/index.htm
+  6.5 The CAN network device driver interface
 
-  Please check the Mailing Lists on the berlios OSS project website.
+  The CAN network device driver interface provides a generic interface
+  to setup, configure and monitor CAN network devices. The user can then
+  configure the CAN device, like setting the bit-timing parameters, via
+  the netlink interface using the program "ip" from the "IPROUTE2"
+  utility suite. The following chapter describes briefly how to use it.
+  Furthermore, the interface uses a common data structure and exports a
+  set of common functions, which all real CAN network device drivers
+  should use. Please have a look to the SJA1000 or MSCAN driver to
+  understand how to use them. The name of the module is can-dev.ko.
+
+  6.5.1 Netlink interface to set/get devices properties
+
+  The CAN device must be configured via netlink interface. The supported
+  netlink message types are defined and briefly described in
+  "include/linux/can/netlink.h". CAN link support for the program "ip"
+  of the IPROUTE2 utility suite is avaiable and it can be used as shown
+  below:
+
+  - Setting CAN device properties:
+
+    $ ip link set can0 type can help
+    Usage: ip link set DEVICE type can
+    	[ bitrate BITRATE [ sample-point SAMPLE-POINT] ] |
+    	[ tq TQ prop-seg PROP_SEG phase-seg1 PHASE-SEG1
+     	  phase-seg2 PHASE-SEG2 [ sjw SJW ] ]
+
+    	[ loopback { on | off } ]
+    	[ listen-only { on | off } ]
+    	[ triple-sampling { on | off } ]
+
+    	[ restart-ms TIME-MS ]
+    	[ restart ]
+
+    	Where: BITRATE       := { 1..1000000 }
+    	       SAMPLE-POINT  := { 0.000..0.999 }
+    	       TQ            := { NUMBER }
+    	       PROP-SEG      := { 1..8 }
+    	       PHASE-SEG1    := { 1..8 }
+    	       PHASE-SEG2    := { 1..8 }
+    	       SJW           := { 1..4 }
+    	       RESTART-MS    := { 0 | NUMBER }
+
+  - Display CAN device details and statistics:
+
+    $ ip -details -statistics link show can0
+    2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP qlen 10
+      link/can
+      can <TRIPLE-SAMPLING> state ERROR-ACTIVE restart-ms 100
+      bitrate 125000 sample_point 0.875
+      tq 125 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
+      sja1000: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
+      clock 8000000
+      re-started bus-errors arbit-lost error-warn error-pass bus-off
+      41         17457      0          41         42         41
+      RX: bytes  packets  errors  dropped overrun mcast
+      140859     17608    17457   0       0       0
+      TX: bytes  packets  errors  dropped carrier collsns
+      861        112      0       41      0       0
+
+  More info to the above output:
+
+    "<TRIPLE-SAMPLING>"
+	Shows the list of selected CAN controller modes: LOOPBACK,
+	LISTEN-ONLY, or TRIPLE-SAMPLING.
+
+    "state ERROR-ACTIVE"
+	The current state of the CAN controller: "ERROR-ACTIVE",
+	"ERROR-WARNING", "ERROR-PASSIVE", "BUS-OFF" or "STOPPED"
+
+    "restart-ms 100"
+	Automatic restart delay time. If set to a non-zero value, a
+	restart of the CAN controller will be triggered automatically
+	in case of a bus-off condition after the specified delay time
+	in milliseconds. By default it's off.
+
+    "bitrate 125000 sample_point 0.875"
+	Shows the real bit-rate in bits/sec and the sample-point in the
+	range 0.000..0.999. If the calculation of bit-timing parameters
+	is enabled in the kernel (CONFIG_CAN_CALC_BITTIMING=y), the
+	bit-timing can be defined by setting the "bitrate" argument.
+	Optionally the "sample-point" can be specified. By default it's
+	0.000 assuming CIA-recommended sample-points.
+
+    "tq 125 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1"
+	Shows the time quanta in ns, propagation segment, phase buffer
+	segment 1 and 2 and the synchronisation jump width in units of
+	tq. They allow to define the CAN bit-timing in a hardware
+	independent format as proposed by the Bosch CAN 2.0 spec (see
+	chapter 8 of http://www.semiconductors.bosch.de/pdf/can2spec.pdf).
+
+    "sja1000: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
+     clock 8000000"
+	Shows the bit-timing constants of the CAN controller, here the
+	"sja1000". The minimum and maximum values of the time segment 1
+	and 2, the synchronisation jump width in units of tq, the
+	bitrate pre-scaler and the CAN system clock frequency in Hz.
+	These constants could be used for user-defined (non-standard)
+	bit-timing calculation algorithms in user-space.
+
+    "re-started bus-errors arbit-lost error-warn error-pass bus-off"
+	Shows the number of restarts, bus and arbitration lost errors,
+	and the state changes to the error-warning, error-passive and
+	bus-off state. RX overrun errors are listed in the "overrun"
+	field of the standard network statistics.
+
+  6.5.2 Setting the CAN bit-timing
+
+  The CAN bit-timing parameters can always be defined in a hardware
+  independent format as proposed in the Bosch CAN 2.0 specification
+  specifying the arguments "tq", "prop_seg", "phase_seg1", "phase_seg2"
+  and "sjw":
+
+    $ ip link set canX type can tq 125 prop-seg 6 \
+				phase-seg1 7 phase-seg2 2 sjw 1
+
+  If the kernel option CONFIG_CAN_CALC_BITTIMING is enabled, CIA
+  recommended CAN bit-timing parameters will be calculated if the bit-
+  rate is specified with the argument "bitrate":
+
+    $ ip link set canX type can bitrate 125000
+
+  Note that this works fine for the most common CAN controllers with
+  standard bit-rates but may *fail* for exotic bit-rates or CAN system
+  clock frequencies. Disabling CONFIG_CAN_CALC_BITTIMING saves some
+  space and allows user-space tools to solely determine and set the
+  bit-timing parameters. The CAN controller specific bit-timing
+  constants can be used for that purpose. They are listed by the
+  following command:
+
+    $ ip -details link show can0
+    ...
+      sja1000: clock 8000000 tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
+
+  6.5.3 Starting and stopping the CAN network device
+
+  A CAN network device is started or stopped as usual with the command
+  "ifconfig canX up/down" or "ip link set canX up/down". Be aware that
+  you *must* define proper bit-timing parameters for real CAN devices
+  before you can start it to avoid error-prone default settings:
+
+    $ ip link set canX up type can bitrate 125000
+
+  A device may enter the "bus-off" state if too much errors occurred on
+  the CAN bus. Then no more messages are received or sent. An automatic
+  bus-off recovery can be enabled by setting the "restart-ms" to a
+  non-zero value, e.g.:
+
+    $ ip link set canX type can restart-ms 100
+
+  Alternatively, the application may realize the "bus-off" condition
+  by monitoring CAN error frames and do a restart when appropriate with
+  the command:
+
+    $ ip link set canX type can restart
+
+  Note that a restart will also create a CAN error frame (see also
+  chapter 3.4).
+
+  6.6 Supported CAN hardware
+
+  Please check the "Kconfig" file in "drivers/net/can" to get an actual
+  list of the support CAN hardware. On the Socket CAN project website
+  (see chapter 7) there might be further drivers available, also for
+  older kernel versions.
+
+7. Socket CAN resources
+-----------------------
+
+  You can find further resources for Socket CAN like user space tools,
+  support for old kernel versions, more drivers, mailing lists, etc.
+  at the BerliOS OSS project website for Socket CAN:
 
-  6.6 todo
+    http://developer.berlios.de/projects/socketcan
 
-  The configuration interface for CAN network drivers is still an open
-  issue that has not been finalized in the socketcan project. Also the
-  idea of having a library module (candev.ko) that holds functions
-  that are needed by all CAN netdevices is not ready to ship.
-  Your contribution is welcome.
+  If you have questions, bug fixes, etc., don't hesitate to post them to
+  the Socketcan-Users mailing list. But please search the archives first.
 
-7. Credits
+8. Credits
 ----------
 
-  Oliver Hartkopp (PF_CAN core, filters, drivers, bcm)
+  Oliver Hartkopp (PF_CAN core, filters, drivers, bcm, SJA1000 driver)
   Urs Thuermann (PF_CAN core, kernel integration, socket interfaces, raw, vcan)
   Jan Kizka (RT-SocketCAN core, Socket-API reconciliation)
-  Wolfgang Grandegger (RT-SocketCAN core & drivers, Raw Socket-API reviews)
+  Wolfgang Grandegger (RT-SocketCAN core & drivers, Raw Socket-API reviews,
+                       CAN device driver interface, MSCAN driver)
   Robert Schwebel (design reviews, PTXdist integration)
   Marc Kleine-Budde (design reviews, Kernel 2.6 cleanups, drivers)
   Benedikt Spranger (reviews)
   Thomas Gleixner (LKML reviews, coding style, posting hints)
-  Andrey Volkov (kernel subtree structure, ioctls, mscan driver)
+  Andrey Volkov (kernel subtree structure, ioctls, MSCAN driver)
   Matthias Brukner (first SJA1000 CAN netdevice implementation Q2/2003)
   Klaus Hitschler (PEAK driver integration)
   Uwe Koppe (CAN netdevices with PF_PACKET approach)
   Michael Schulze (driver layer loopback requirement, RT CAN drivers review)
+  Pavel Pisa (Bit-timing calculation)
+  Sascha Hauer (SJA1000 platform driver)
+  Sebastian Haas (SJA1000 EMS PCI driver)
+  Markus Plessing (SJA1000 EMS PCI driver)
+  Per Dalen (SJA1000 Kvaser PCI driver)
+  Sam Ravnborg (reviews, coding style, kbuild help)
#2 lore raw

PATCH v3 2/8 can: Update MAINTAINERS and CREDITS file

In reply to Wolfgang Grandegger
---
 CREDITS     |    4 ++++
 MAINTAINERS |    7 +++++++
 2 files changed, 11 insertions(+)
CREDITS +4 -0
Index: net-next-2.6/CREDITS
===================================================================
@@ -1253,6 +1253,10 @@
 S: Sterling Heights, Michigan 48313
 S: USA
 
+N: Wolfgang Grandegger
+E: [email protected]
+D: Controller Area Network (device drivers)
+
 N: William Greathouse
 E: [email protected]
 E: [email protected]
MAINTAINERS +7 -0
Index: net-next-2.6/MAINTAINERS
===================================================================
@@ -1278,6 +1278,13 @@
 F:	include/linux/can/
 F:	include/linux/can.h
 
+CAN NETWORK DRIVERS
+P:	Wolfgang Grandegger
+M:	[email protected]
+L:	[email protected] (subscribers-only)
+W:	http://developer.berlios.de/projects/socketcan/
+S:	Maintained
+
 CELL BROADBAND ENGINE ARCHITECTURE
 P:	Arnd Bergmann
 M:	[email protected]
#3 lore raw

PATCH v3 3/8 can: CAN Network device driver and Netlink interface

In reply to Wolfgang Grandegger

The CAN network device driver interface provides a generic interface to setup, configure and monitor CAN network devices. It exports a set of common data structures and functions, which all real CAN network device drivers should use. Please have a look to the SJA1000 or MSCAN driver to understand how to use them. The name of the module is can-dev.ko.

Furthermore, it adds a Netlink interface allowing to configure the CAN device using the program "ip" from the iproute2 utility suite.

For further information please check "Documentation/networking/can.txt"

---
 drivers/net/can/Kconfig     |   23 +
 drivers/net/can/Makefile    |    5 
 drivers/net/can/dev.c       |  657 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/can/Kbuild    |    1 
 include/linux/can/dev.h     |   70 ++++
 include/linux/can/netlink.h |  113 +++++++
 6 files changed, 869 insertions(+)
 create mode 100644 drivers/net/can/dev.c
 create mode 100644 drivers/net/can/sysfs.c
 create mode 100644 drivers/net/can/sysfs.h
 create mode 100644 include/linux/can/dev.h
drivers/net/can/Kconfig +23 -0
Index: net-next-2.6/drivers/net/can/Kconfig
===================================================================
@@ -12,6 +12,29 @@
 	  This driver can also be built as a module.  If so, the module
 	  will be called vcan.
 
+config CAN_DEV
+	tristate "Platform CAN drivers with Netlink support"
+	depends on CAN
+	default Y
+	---help---
+	  Enables the common framework for platform CAN drivers with Netlink
+	  support. This is the standard library for CAN drivers.
+	  If unsure, say Y.
+
+config CAN_CALC_BITTIMING
+	bool "CAN bit-timing calculation"
+	depends on CAN_DEV
+	default Y
+	---help---
+	  If enabled, CAN bit-timing parameters will be calculated for the
+	  bit-rate specified via Netlink argument "bitrate" when the device
+	  get started. This works fine for the most common CAN controllers
+	  with standard bit-rates but may fail for exotic bit-rates or CAN
+	  source clock frequencies. Disabling saves some space, but then the
+	  bit-timing parameters must be specified directly using the Netlink
+	  arguments "tq", "prop_seg", "phase_seg1", "phase_seg2" and "sjw".
+	  If unsure, say Y.
+
 config CAN_DEBUG_DEVICES
 	bool "CAN devices debugging messages"
 	depends on CAN
drivers/net/can/Makefile +5 -0
Index: net-next-2.6/drivers/net/can/Makefile
===================================================================
@@ -3,3 +3,8 @@
 #
 
 obj-$(CONFIG_CAN_VCAN)		+= vcan.o
+
+obj-$(CONFIG_CAN_DEV)		+= can-dev.o
+can-dev-y			:= dev.o
+
+ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
drivers/net/can/dev.c new file +657 -0

657 lines not on this page · raw message

include/linux/can/dev.h new file +70 -0

70 lines not on this page · raw message

include/linux/can/netlink.h new file +113 -0

113 lines not on this page · raw message

include/linux/can/Kbuild +1 -0
Index: net-next-2.6/include/linux/can/Kbuild
===================================================================
@@ -1,3 +1,4 @@
 header-y += raw.h
 header-y += bcm.h
 header-y += error.h
+header-y += netlink.h
#4 lore raw

PATCH v3 4/8 can: Driver for the SJA1000 CAN controller

In reply to Wolfgang Grandegger

This patch adds the generic Socket-CAN driver for the Philips SJA1000 full CAN controller.

---
 drivers/net/can/Kconfig           |    6 
 drivers/net/can/Makefile          |    2 
 drivers/net/can/sja1000/Makefile  |    7 
 drivers/net/can/sja1000/sja1000.c |  637 ++++++++++++++++++++++++++++++++++++++
 drivers/net/can/sja1000/sja1000.h |  180 ++++++++++
 5 files changed, 832 insertions(+)
 create mode 100644 drivers/net/can/sja1000/Makefile
 create mode 100644 drivers/net/can/sja1000/sja1000.c
 create mode 100644 drivers/net/can/sja1000/sja1000.h
drivers/net/can/Kconfig +6 -0
Index: net-next-2.6/drivers/net/can/Kconfig
===================================================================
@@ -35,6 +35,12 @@
 	  arguments "tq", "prop_seg", "phase_seg1", "phase_seg2" and "sjw".
 	  If unsure, say Y.
 
+config CAN_SJA1000
+	depends on CAN_DEV
+	tristate "Philips SJA1000"
+	---help---
+	  Driver for the SJA1000 CAN controllers from Philips or NXP
+
 config CAN_DEBUG_DEVICES
 	bool "CAN devices debugging messages"
 	depends on CAN
drivers/net/can/Makefile +2 -0
Index: net-next-2.6/drivers/net/can/Makefile
===================================================================
@@ -7,4 +7,6 @@
 obj-$(CONFIG_CAN_DEV)		+= can-dev.o
 can-dev-y			:= dev.o
 
+obj-$(CONFIG_CAN_SJA1000)	+= sja1000/
+
 ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
drivers/net/can/sja1000/Makefile new file +7 -0
Index: net-next-2.6/drivers/net/can/sja1000/Makefile
===================================================================
@@ -0,0 +1,7 @@
+#
+#  Makefile for the SJA1000 CAN controller drivers.
+#
+
+obj-$(CONFIG_CAN_SJA1000) += sja1000.o
+
+ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
drivers/net/can/sja1000/sja1000.c new file +637 -0

637 lines not on this page · raw message

drivers/net/can/sja1000/sja1000.h new file +180 -0

180 lines not on this page · raw message

#5 lore raw

PATCH v3 5/8 can: SJA1000 generic platform bus driver

In reply to Wolfgang Grandegger

This driver adds support for the SJA1000 chips connected to the "platform bus", which can be found on various embedded systems.

---
 drivers/net/can/Kconfig                    |   10 +
 drivers/net/can/sja1000/Makefile           |    1 
 drivers/net/can/sja1000/sja1000_platform.c |  164 +++++++++++++++++++++++++++++
 include/linux/can/platform/sja1000.h       |   32 +++++
 4 files changed, 207 insertions(+)
 create mode 100644 drivers/net/can/sja1000/sja1000_platform.c
 create mode 100644 include/linux/can/platform/sja1000.h
drivers/net/can/Kconfig +10 -0
Index: net-next-2.6/drivers/net/can/Kconfig
===================================================================
@@ -41,6 +41,16 @@
 	---help---
 	  Driver for the SJA1000 CAN controllers from Philips or NXP
 
+config CAN_SJA1000_PLATFORM
+	depends on CAN_SJA1000
+	tristate "Generic Platform Bus based SJA1000 driver"
+	---help---
+	  This driver adds support for the SJA1000 chips connected to
+	  the "platform bus" (Linux abstraction for directly to the
+	  processor attached devices).  Which can be found on various
+	  boards from Phytec (http://www.phytec.de) like the PCM027,
+	  PCM038.
+
 config CAN_DEBUG_DEVICES
 	bool "CAN devices debugging messages"
 	depends on CAN
drivers/net/can/sja1000/Makefile +1 -0
Index: net-next-2.6/drivers/net/can/sja1000/Makefile
===================================================================
@@ -3,5 +3,6 @@
 #
 
 obj-$(CONFIG_CAN_SJA1000) += sja1000.o
+obj-$(CONFIG_CAN_SJA1000_PLATFORM) += sja1000_platform.o
 
 ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
drivers/net/can/sja1000/sja1000_platform.c new file +164 -0

164 lines not on this page · raw message

include/linux/can/platform/sja1000.h new file +32 -0
Index: net-next-2.6/include/linux/can/platform/sja1000.h
===================================================================
@@ -0,0 +1,32 @@
+#ifndef _CAN_PLATFORM_SJA1000_H_
+#define _CAN_PLATFORM_SJA1000_H_
+
+/* clock divider register */
+#define CDR_CLKOUT_MASK 0x07
+#define CDR_CLK_OFF	0x08 /* Clock off (CLKOUT pin) */
+#define CDR_RXINPEN	0x20 /* TX1 output is RX irq output */
+#define CDR_CBP		0x40 /* CAN input comparator bypass */
+#define CDR_PELICAN	0x80 /* PeliCAN mode */
+
+/* output control register */
+#define OCR_MODE_BIPHASE  0x00
+#define OCR_MODE_TEST     0x01
+#define OCR_MODE_NORMAL   0x02
+#define OCR_MODE_CLOCK    0x03
+#define OCR_TX0_INVERT    0x04
+#define OCR_TX0_PULLDOWN  0x08
+#define OCR_TX0_PULLUP    0x10
+#define OCR_TX0_PUSHPULL  0x18
+#define OCR_TX1_INVERT    0x20
+#define OCR_TX1_PULLDOWN  0x40
+#define OCR_TX1_PULLUP    0x80
+#define OCR_TX1_PUSHPULL  0xc0
+
+struct sja1000_platform_data {
+	u32 clock;	/* CAN bus oscillator frequency in Hz */
+
+	u8 ocr;		/* output control register */
+	u8 cdr;		/* clock divider register */
+};
+
+#endif	/* !_CAN_PLATFORM_SJA1000_H_ */
#6 lore raw

PATCH v3 6/8 can: SJA1000 driver for EMS PCI cards

In reply to Wolfgang Grandegger

The patch adds support for the one or two channel CPC-PCI and CPC-PCIe cards from EMS Dr. Thomas Wuensche (http://www.ems-wuensche.de).

---
 drivers/net/can/Kconfig           |    7 
 drivers/net/can/sja1000/Makefile  |    1 
 drivers/net/can/sja1000/ems_pci.c |  329 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 337 insertions(+)
 create mode 100644 drivers/net/can/sja1000/ems_pci.c
drivers/net/can/Kconfig +7 -0
Index: net-next-2.6/drivers/net/can/Kconfig
===================================================================
@@ -51,6 +51,13 @@
 	  boards from Phytec (http://www.phytec.de) like the PCM027,
 	  PCM038.
 
+config CAN_EMS_PCI
+	tristate "EMS CPC-PCI and CPC-PCIe Card"
+	depends on PCI && CAN_SJA1000
+	---help---
+	  This driver is for the one or two channel CPC-PCI and CPC-PCIe
+	  cards from EMS Dr. Thomas Wuensche (http://www.ems-wuensche.de).
+
 config CAN_DEBUG_DEVICES
 	bool "CAN devices debugging messages"
 	depends on CAN
drivers/net/can/sja1000/Makefile +1 -0
Index: net-next-2.6/drivers/net/can/sja1000/Makefile
===================================================================
@@ -4,5 +4,6 @@
 
 obj-$(CONFIG_CAN_SJA1000) += sja1000.o
 obj-$(CONFIG_CAN_SJA1000_PLATFORM) += sja1000_platform.o
+obj-$(CONFIG_CAN_EMS_PCI) += ems_pci.o
 
 ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
drivers/net/can/sja1000/ems_pci.c new file +329 -0

329 lines not on this page · raw message

#7 lore raw

PATCH v3 7/7 The patch adds support for the PCI cards: PCIcan and PCIcanx (1, 2 or 4 channel) from Kvaser (http://www.kvaser.com).

In reply to Wolfgang Grandegger
---
 drivers/net/can/Kconfig              |    7 
 drivers/net/can/sja1000/Makefile     |    1 
 drivers/net/can/sja1000/kvaser_pci.c |  411 +++++++++++++++++++++++++++++++++++
 3 files changed, 419 insertions(+)
 create mode 100644 drivers/net/can/sja1000/kvaser_pci.c
drivers/net/can/Kconfig +7 -0
Index: net-next-2.6/drivers/net/can/Kconfig
===================================================================
@@ -58,6 +58,13 @@
 	  This driver is for the one or two channel CPC-PCI and CPC-PCIe
 	  cards from EMS Dr. Thomas Wuensche (http://www.ems-wuensche.de).
 
+config CAN_KVASER_PCI
+	tristate "Kvaser PCIcanx and Kvaser PCIcan PCI Cards"
+	depends on PCI && CAN_SJA1000
+	---help---
+	  This driver is for the the PCIcanx and PCIcan cards (1, 2 or
+	  4 channel) from Kvaser (http://www.kvaser.com).
+
 config CAN_DEBUG_DEVICES
 	bool "CAN devices debugging messages"
 	depends on CAN
drivers/net/can/sja1000/Makefile +1 -0
Index: net-next-2.6/drivers/net/can/sja1000/Makefile
===================================================================
@@ -5,5 +5,6 @@
 obj-$(CONFIG_CAN_SJA1000) += sja1000.o
 obj-$(CONFIG_CAN_SJA1000_PLATFORM) += sja1000_platform.o
 obj-$(CONFIG_CAN_EMS_PCI) += ems_pci.o
+obj-$(CONFIG_CAN_KVASER_PCI) += kvaser_pci.o
 
 ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
drivers/net/can/sja1000/kvaser_pci.c new file +411 -0

411 lines not on this page · raw message

#9 lore raw
Quoted 6 lines · David Miller

From: Wolfgang Grandegger <[email protected]>
Date: Sat, 16 May 2009 11:39:26 +0200

Quoted 1 line

here comes v3 of this patch series.

I've applied these to net-next-2.6, thanks.

Great, we have more patches for various CAN controllers in the pipeline and I actually intend to ask for an account on kernel.org and a GIT repository "can-2.6" to simplify maintenance.

Thanks,

Wolfgang.