Lines Matching +full:mem +full:- +full:base
1 // SPDX-License-Identifier: GPL-2.0-only
24 MODULE_DESCRIPTION("Socket-CAN driver for SJA1000 on the ISA bus");
32 static unsigned long mem[MAXDEV]; variable
35 static unsigned char cdr[MAXDEV] = {[0 ... (MAXDEV - 1)] = 0xff};
36 static unsigned char ocr[MAXDEV] = {[0 ... (MAXDEV - 1)] = 0xff};
37 static int indirect[MAXDEV] = {[0 ... (MAXDEV - 1)] = -1};
43 module_param_hw_array(mem, ulong, iomem, NULL, 0444);
44 MODULE_PARM_DESC(mem, "I/O memory address");
71 return readb(priv->reg_base + reg); in sja1000_isa_mem_read_reg()
77 writeb(val, priv->reg_base + reg); in sja1000_isa_mem_write_reg()
82 return inb((unsigned long)priv->reg_base + reg); in sja1000_isa_port_read_reg()
88 outb(val, (unsigned long)priv->reg_base + reg); in sja1000_isa_port_write_reg()
94 unsigned long flags, base = (unsigned long)priv->reg_base; in sja1000_isa_port_read_reg_indirect() local
97 spin_lock_irqsave(&indirect_lock[priv->dev->dev_id], flags); in sja1000_isa_port_read_reg_indirect()
98 outb(reg, base); in sja1000_isa_port_read_reg_indirect()
99 readval = inb(base + 1); in sja1000_isa_port_read_reg_indirect()
100 spin_unlock_irqrestore(&indirect_lock[priv->dev->dev_id], flags); in sja1000_isa_port_read_reg_indirect()
108 unsigned long flags, base = (unsigned long)priv->reg_base; in sja1000_isa_port_write_reg_indirect() local
110 spin_lock_irqsave(&indirect_lock[priv->dev->dev_id], flags); in sja1000_isa_port_write_reg_indirect()
111 outb(reg, base); in sja1000_isa_port_write_reg_indirect()
112 outb(val, base + 1); in sja1000_isa_port_write_reg_indirect()
113 spin_unlock_irqrestore(&indirect_lock[priv->dev->dev_id], flags); in sja1000_isa_port_write_reg_indirect()
120 void __iomem *base = NULL; in sja1000_isa_probe() local
122 int idx = pdev->id; in sja1000_isa_probe()
125 dev_dbg(&pdev->dev, "probing idx=%d: port=%#lx, mem=%#lx, irq=%d\n", in sja1000_isa_probe()
126 idx, port[idx], mem[idx], irq[idx]); in sja1000_isa_probe()
128 if (mem[idx]) { in sja1000_isa_probe()
129 if (!request_mem_region(mem[idx], iosize, DRV_NAME)) { in sja1000_isa_probe()
130 err = -EBUSY; in sja1000_isa_probe()
133 base = ioremap(mem[idx], iosize); in sja1000_isa_probe()
134 if (!base) { in sja1000_isa_probe()
135 err = -ENOMEM; in sja1000_isa_probe()
140 (indirect[idx] == -1 && indirect[0] > 0)) in sja1000_isa_probe()
143 err = -EBUSY; in sja1000_isa_probe()
150 err = -ENOMEM; in sja1000_isa_probe()
155 dev->irq = irq[idx]; in sja1000_isa_probe()
156 priv->irq_flags = IRQF_SHARED; in sja1000_isa_probe()
157 if (mem[idx]) { in sja1000_isa_probe()
158 priv->reg_base = base; in sja1000_isa_probe()
159 dev->base_addr = mem[idx]; in sja1000_isa_probe()
160 priv->read_reg = sja1000_isa_mem_read_reg; in sja1000_isa_probe()
161 priv->write_reg = sja1000_isa_mem_write_reg; in sja1000_isa_probe()
163 priv->reg_base = (void __iomem *)port[idx]; in sja1000_isa_probe()
164 dev->base_addr = port[idx]; in sja1000_isa_probe()
167 priv->read_reg = sja1000_isa_port_read_reg_indirect; in sja1000_isa_probe()
168 priv->write_reg = sja1000_isa_port_write_reg_indirect; in sja1000_isa_probe()
171 priv->read_reg = sja1000_isa_port_read_reg; in sja1000_isa_probe()
172 priv->write_reg = sja1000_isa_port_write_reg; in sja1000_isa_probe()
177 priv->can.clock.freq = clk[idx] / 2; in sja1000_isa_probe()
179 priv->can.clock.freq = clk[0] / 2; in sja1000_isa_probe()
181 priv->can.clock.freq = CLK_DEFAULT / 2; in sja1000_isa_probe()
184 priv->ocr = ocr[idx]; in sja1000_isa_probe()
186 priv->ocr = ocr[0]; in sja1000_isa_probe()
188 priv->ocr = OCR_DEFAULT; in sja1000_isa_probe()
191 priv->cdr = cdr[idx]; in sja1000_isa_probe()
193 priv->cdr = cdr[0]; in sja1000_isa_probe()
195 priv->cdr = CDR_DEFAULT; in sja1000_isa_probe()
198 SET_NETDEV_DEV(dev, &pdev->dev); in sja1000_isa_probe()
199 dev->dev_id = idx; in sja1000_isa_probe()
203 dev_err(&pdev->dev, "registering %s failed (err=%d)\n", in sja1000_isa_probe()
208 dev_info(&pdev->dev, "%s device registered (reg_base=0x%p, irq=%d)\n", in sja1000_isa_probe()
209 DRV_NAME, priv->reg_base, dev->irq); in sja1000_isa_probe()
215 if (mem[idx]) in sja1000_isa_probe()
216 iounmap(base); in sja1000_isa_probe()
218 if (mem[idx]) in sja1000_isa_probe()
219 release_mem_region(mem[idx], iosize); in sja1000_isa_probe()
230 int idx = pdev->id; in sja1000_isa_remove()
234 if (mem[idx]) { in sja1000_isa_remove()
235 iounmap(priv->reg_base); in sja1000_isa_remove()
236 release_mem_region(mem[idx], SJA1000_IOSIZE); in sja1000_isa_remove()
238 if (priv->read_reg == sja1000_isa_port_read_reg_indirect) in sja1000_isa_remove()
259 if ((port[idx] || mem[idx]) && irq[idx]) { in sja1000_isa_init()
263 err = -ENOMEM; in sja1000_isa_init()
271 pr_debug("%s: platform device %d: port=%#lx, mem=%#lx, " in sja1000_isa_init()
273 DRV_NAME, idx, port[idx], mem[idx], irq[idx]); in sja1000_isa_init()
274 } else if (idx == 0 || port[idx] || mem[idx]) { in sja1000_isa_init()
277 err = -EINVAL; in sja1000_isa_init()
292 while (--idx >= 0) { in sja1000_isa_init()