18 #include <linux/kernel.h>
19 #include <linux/module.h>
22 #include <linux/netdevice.h>
31 #define DRV_NAME "sja1000_isa"
39 #define CLK_DEFAULT 16000000
40 #define CDR_DEFAULT (CDR_CBP | CDR_CLK_OFF)
41 #define OCR_DEFAULT OCR_TX0_PUSHPULL
65 "(default=16000000 [16 MHz])");
69 "(default=0x48 [CDR_CBP | CDR_CLK_OFF])");
73 "(default=0x18 [OCR_TX0_PUSHPULL])");
75 #define SJA1000_IOSIZE 0x20
76 #define SJA1000_IOSIZE_INDIRECT 0x02
96 static void sja1000_isa_port_write_reg(
const struct sja1000_priv *priv,
102 static u8 sja1000_isa_port_read_reg_indirect(
const struct sja1000_priv *priv,
108 return inb(base + 1);
111 static void sja1000_isa_port_write_reg_indirect(
const struct sja1000_priv *priv,
129 dev_dbg(&pdev->
dev,
"probing idx=%d: port=%#lx, mem=%#lx, irq=%d\n",
130 idx,
port[idx],
mem[idx], irq[idx]);
143 if (indirect[idx] > 0 ||
144 (indirect[idx] == -1 && indirect[0] > 0))
157 priv = netdev_priv(dev);
164 priv->
read_reg = sja1000_isa_mem_read_reg;
165 priv->
write_reg = sja1000_isa_mem_write_reg;
171 priv->
read_reg = sja1000_isa_port_read_reg_indirect;
172 priv->
write_reg = sja1000_isa_port_write_reg_indirect;
174 priv->
read_reg = sja1000_isa_port_read_reg;
175 priv->
write_reg = sja1000_isa_port_write_reg;
182 priv->
can.clock.freq =
clk[0] / 2;
186 if (ocr[idx] != 0xff)
188 else if (ocr[0] != 0xff)
193 if (
cdr[idx] != 0xff)
195 else if (
cdr[0] != 0xff)
205 dev_err(&pdev->
dev,
"registering %s failed (err=%d)\n",
210 dev_info(&pdev->
dev,
"%s device registered (reg_base=0x%p, irq=%d)\n",
239 if (priv->
read_reg == sja1000_isa_port_read_reg_indirect)
250 .probe = sja1000_isa_probe,
258 static int __init sja1000_isa_init(
void)
262 for (idx = 0; idx <
MAXDEV; idx++) {
263 if ((
port[idx] ||
mem[idx]) && irq[idx]) {
264 sja1000_isa_devs[
idx] =
266 if (!sja1000_isa_devs[idx]) {
268 goto exit_free_devices;
273 goto exit_free_devices;
275 pr_debug(
"%s: platform device %d: port=%#lx, mem=%#lx, "
278 }
else if (idx == 0 ||
port[idx] ||
mem[idx]) {
279 pr_err(
"%s: insufficient parameters supplied\n",
282 goto exit_free_devices;
288 goto exit_free_devices;
290 pr_info(
"Legacy %s driver for max. %d devices registered\n",
297 if (sja1000_isa_devs[idx])
304 static void __exit sja1000_isa_exit(
void)
309 for (idx = 0; idx <
MAXDEV; idx++) {
310 if (sja1000_isa_devs[idx])