2 * iomux.c - multiplex register access CAN hardware abstraction layer
6 * Inspired by the OCAN driver http://ar.linux.it/software/#ocan
8 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of Volkswagen nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * Alternatively, provided that this notice is retained in full, this
24 * software may be distributed under the terms of the GNU General
25 * Public License ("GPL") version 2, in which case the provisions of the
26 * GPL apply INSTEAD OF those given above.
28 * The provided data structures and external interfaces from this code
29 * are not restricted to be used by modules with a GPL compatible license.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
37 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
41 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
44 * Send feedback to <socketcan-users@lists.berlios.de>
48 #include <linux/netdevice.h>
49 #include <linux/ioport.h>
53 /* init the HAL - call at driver module init */
54 int hal_init(void) { return 0; }
56 /* exit the HAL - call at driver module exit */
57 int hal_exit(void) { return 0; }
59 /* get name of this CAN HAL */
60 char *hal_name(void) { return "iomux"; }
62 /* fill arrays base[] and irq[] with HAL specific defaults */
63 void hal_use_defaults(void)
65 extern unsigned long base[];
66 extern unsigned int irq[];
72 /* request controller register access space */
73 int hal_request_region(int dev_num,
74 unsigned int num_regs,
77 extern unsigned long base[];
78 extern unsigned long rbase[];
80 /* set for device base_addr */
81 rbase[dev_num] = base[dev_num];
83 /* ignore num_regs and create the 2 register region: */
84 /* address register = base / data register = base + 1 */
85 return (request_region(base[dev_num], 2, drv_name))? 1 : 0;
88 /* release controller register access space */
89 void hal_release_region(int dev_num,
90 unsigned int num_regs)
92 extern unsigned long base[];
94 /* ignore num_regs and create the 2 register region: */
95 /* address register = base / data register = base + 1 */
96 release_region(base[dev_num], 2);
99 /* enable non controller hardware (e.g. irq routing, etc.) */
100 int hw_attach(int dev_num) { return 0; }
102 /* disable non controller hardware (e.g. irq routing, etc.) */
103 int hw_detach(int dev_num) { return 0; }
105 /* reset controller hardware (with specific non controller hardware) */
106 int hw_reset_dev(int dev_num) { return 0; }
108 /* read from controller register */
109 u8 hw_readreg(unsigned long base, int reg) {
111 outb(reg, base); /* address */
112 return inb(base + 1); /* data */
115 /* write to controller register */
116 void hw_writereg(unsigned long base, int reg, u8 val) {
118 outb(reg, base); /* address */
119 outb(val, base + 1); /* data */
122 /* hardware specific work to do at start of irq handler */
123 void hw_preirq(struct net_device *dev) { return; }
125 /* hardware specific work to do at end of irq handler */
126 void hw_postirq(struct net_device *dev) { return; }