/* * sja1000.c - Philips SJA1000 network device driver * * Copyright (c) 2003 Matthias Brukner, Trajet Gmbh, Rebenring 33, * 38106 Braunschweig, GERMANY * * Copyright (c) 2002-2007 Volkswagen Group Electronic Research * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of Volkswagen nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * Alternatively, provided that this notice is retained in full, this * software may be distributed under the terms of the GNU General * Public License ("GPL") version 2, in which case the provisions of the * GPL apply INSTEAD OF those given above. * * The provided data structures and external interfaces from this code * are not restricted to be used by modules with a GPL compatible license. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * */ #include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/types.h> #include <linux/fcntl.h> #include <linux/interrupt.h> #include <linux/ptrace.h> #include <linux/string.h> #include <linux/errno.h> #include <linux/ethtool.h> #include <linux/netdevice.h> #include <linux/if_arp.h> #include <linux/if_ether.h> #include <linux/skbuff.h> #include <linux/delay.h> #include <linux/can/dev.h> #include <linux/can/error.h> #include "sja1000.h" #define DRV_NAME … MODULE_AUTHOR(…) …; MODULE_LICENSE(…) …; MODULE_DESCRIPTION(…) …; static const struct can_bittiming_const sja1000_bittiming_const = …; static void sja1000_write_cmdreg(struct sja1000_priv *priv, u8 val) { … } static int sja1000_is_absent(struct sja1000_priv *priv) { … } static int sja1000_probe_chip(struct net_device *dev) { … } static void set_reset_mode(struct net_device *dev) { … } static void set_normal_mode(struct net_device *dev) { … } /* * initialize SJA1000 chip: * - reset chip * - set output mode * - set baudrate * - enable interrupts * - start operating mode */ static void chipset_init(struct net_device *dev) { … } static void sja1000_start(struct net_device *dev) { … } static int sja1000_set_mode(struct net_device *dev, enum can_mode mode) { … } static int sja1000_set_bittiming(struct net_device *dev) { … } static int sja1000_get_berr_counter(const struct net_device *dev, struct can_berr_counter *bec) { … } /* * transmit a CAN message * message layout in the sk_buff should be like this: * xx xx xx xx ff ll 00 11 22 33 44 55 66 77 * [ can-id ] [flags] [len] [can data (up to 8 bytes] */ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb, struct net_device *dev) { … } static void sja1000_rx(struct net_device *dev) { … } static irqreturn_t sja1000_reset_interrupt(int irq, void *dev_id) { … } static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) { … } irqreturn_t sja1000_interrupt(int irq, void *dev_id) { … } EXPORT_SYMBOL_GPL(…); static int sja1000_open(struct net_device *dev) { … } static int sja1000_close(struct net_device *dev) { … } struct net_device *alloc_sja1000dev(int sizeof_priv) { … } EXPORT_SYMBOL_GPL(…); void free_sja1000dev(struct net_device *dev) { … } EXPORT_SYMBOL_GPL(…); static const struct net_device_ops sja1000_netdev_ops = …; static const struct ethtool_ops sja1000_ethtool_ops = …; int register_sja1000dev(struct net_device *dev) { … } EXPORT_SYMBOL_GPL(…); void unregister_sja1000dev(struct net_device *dev) { … } EXPORT_SYMBOL_GPL(…); static __init int sja1000_init(void) { … } module_init(…) …; static __exit void sja1000_exit(void) { … } module_exit(sja1000_exit);