Lines Matching +full:modem +full:- +full:control +full:- +full:line +full:- +full:ports
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 1998-2003 Krzysztof Halasa <khc@pm.waw.pl>
55 static char *hw; /* pointer to hw=xxx command line string */
59 /* PC Control Register */
62 #define PCR_VPM 2 /* Enable VPM - needed if using RAM above 1 MB */
64 #define PCR_BUS16 8 /* 16-bit bus */
78 /* Modem Control Reg */
102 u8 phy_node; /* physical port # - 0 or 1 */
114 u8 irq; /* IRQ (3-15) */
116 port_t ports[2]; member
123 #define sca_reg(reg, card) (0x8000 | (card)->io | \
130 #define port_to_card(port) ((port)->card)
131 #define log_node(port) ((port)->log_node)
132 #define phy_node(port) ((port)->phy_node)
134 #define winbase(card) ((card)->winbase)
135 #define get_port(card, port) ((card)->ports[port].valid ? \
136 &(card)->ports[port] : NULL)
140 return inb(card->io + N2_PSR) & PSR_PAGEBITS; in sca_get_page()
145 u8 psr = inb(card->io + N2_PSR); in openwin()
147 outb((psr & ~PSR_PAGEBITS) | page, card->io + N2_PSR); in openwin()
154 card_t *card = port->card; in n2_set_iface()
155 int io = card->io; in n2_set_iface()
158 u8 rxs = port->rxs & CLK_BRG_MASK; in n2_set_iface()
159 u8 txs = port->txs & CLK_BRG_MASK; in n2_set_iface()
161 switch (port->settings.clock_type) { in n2_set_iface()
163 mcr |= port->phy_node ? CLOCK_OUT_PORT1 : CLOCK_OUT_PORT0; in n2_set_iface()
169 mcr |= port->phy_node ? CLOCK_OUT_PORT1 : CLOCK_OUT_PORT0; in n2_set_iface()
175 mcr |= port->phy_node ? CLOCK_OUT_PORT1 : CLOCK_OUT_PORT0; in n2_set_iface()
181 mcr &= port->phy_node ? ~CLOCK_OUT_PORT1 : ~CLOCK_OUT_PORT0; in n2_set_iface()
187 port->rxs = rxs; in n2_set_iface()
188 port->txs = txs; in n2_set_iface()
197 int io = port->card->io; in n2_open()
199 (port->phy_node ? TX422_PORT1 : TX422_PORT0); in n2_open()
206 mcr &= port->phy_node ? ~DTR_PORT1 : ~DTR_PORT0; /* set DTR ON */ in n2_open()
219 int io = port->card->io; in n2_close()
221 (port->phy_node ? TX422_PORT1 : TX422_PORT0); in n2_close()
224 mcr |= port->phy_node ? DTR_PORT1 : DTR_PORT0; /* set DTR OFF */ in n2_close()
239 return -EOPNOTSUPP; in n2_siocdevprivate()
246 sync_serial_settings __user *line = ifs->ifs_ifsu.sync; in n2_ioctl() local
249 switch (ifs->type) { in n2_ioctl()
251 ifs->type = IF_IFACE_SYNC_SERIAL; in n2_ioctl()
252 if (ifs->size < size) { in n2_ioctl()
253 ifs->size = size; /* data size wanted */ in n2_ioctl()
254 return -ENOBUFS; in n2_ioctl()
256 if (copy_to_user(line, &port->settings, size)) in n2_ioctl()
257 return -EFAULT; in n2_ioctl()
262 return -EPERM; in n2_ioctl()
264 if (copy_from_user(&new_line, line, size)) in n2_ioctl()
265 return -EFAULT; in n2_ioctl()
271 return -EINVAL; /* No such clock setting */ in n2_ioctl()
274 return -EINVAL; in n2_ioctl()
276 memcpy(&port->settings, &new_line, size); /* Update settings */ in n2_ioctl()
290 if (card->ports[cnt].card) { in n2_destroy_card()
291 struct net_device *dev = port_to_dev(&card->ports[cnt]); in n2_destroy_card()
296 if (card->irq) in n2_destroy_card()
297 free_irq(card->irq, card); in n2_destroy_card()
299 if (card->winbase) { in n2_destroy_card()
300 iounmap(card->winbase); in n2_destroy_card()
301 release_mem_region(card->phy_winbase, USE_WINDOWSIZE); in n2_destroy_card()
304 if (card->io) in n2_destroy_card()
305 release_region(card->io, N2_IOPORTS); in n2_destroy_card()
306 if (card->ports[0].dev) in n2_destroy_card()
307 free_netdev(card->ports[0].dev); in n2_destroy_card()
308 if (card->ports[1].dev) in n2_destroy_card()
309 free_netdev(card->ports[1].dev); in n2_destroy_card()
330 return -ENODEV; in n2_run()
335 return -ENODEV; in n2_run()
340 return -ENODEV; in n2_run()
345 return -ENOBUFS; in n2_run()
347 card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); in n2_run()
348 card->ports[1].dev = alloc_hdlcdev(&card->ports[1]); in n2_run()
349 if (!card->ports[0].dev || !card->ports[1].dev) { in n2_run()
352 return -ENOMEM; in n2_run()
358 return -EBUSY; in n2_run()
360 card->io = io; in n2_run()
365 return -EBUSY; in n2_run()
367 card->irq = irq; in n2_run()
372 return -EBUSY; in n2_run()
374 card->phy_winbase = winbase; in n2_run()
375 card->winbase = ioremap(winbase, USE_WINDOWSIZE); in n2_run()
376 if (!card->winbase) { in n2_run()
379 return -EFAULT; in n2_run()
401 return -ENODEV; in n2_run()
407 card->ram_size = sca_detect_ram(card, card->winbase, MAX_RAM_SIZE); in n2_run()
410 i = card->ram_size / ((valid0 + valid1) * (sizeof(pkt_desc) + in n2_run()
413 card->tx_ring_buffers = min(i / 2, MAX_TX_BUFFERS); in n2_run()
414 card->rx_ring_buffers = i - card->tx_ring_buffers; in n2_run()
416 card->buff_offset = (valid0 + valid1) * sizeof(pkt_desc) * in n2_run()
417 (card->tx_ring_buffers + card->rx_ring_buffers); in n2_run()
420 card->ram_size / 1024, card->irq, in n2_run()
421 card->tx_ring_buffers, card->rx_ring_buffers); in n2_run()
423 if (card->tx_ring_buffers < 1) { in n2_run()
426 return -EIO; in n2_run()
435 port_t *port = &card->ports[cnt]; in n2_run()
442 port->phy_node = cnt; in n2_run()
443 port->valid = 1; in n2_run()
446 port->log_node = 1; in n2_run()
448 spin_lock_init(&port->lock); in n2_run()
449 dev->irq = irq; in n2_run()
450 dev->mem_start = winbase; in n2_run()
451 dev->mem_end = winbase + USE_WINDOWSIZE - 1; in n2_run()
452 dev->tx_queue_len = 50; in n2_run()
453 dev->netdev_ops = &n2_ops; in n2_run()
454 hdlc->attach = sca_attach; in n2_run()
455 hdlc->xmit = sca_xmit; in n2_run()
456 port->settings.clock_type = CLOCK_EXT; in n2_run()
457 port->card = card; in n2_run()
461 port->card = NULL; in n2_run()
463 return -ENOBUFS; in n2_run()
467 netdev_info(dev, "RISCom/N2 node %d\n", port->phy_node); in n2_run()
471 new_card = &card->next_card; in n2_run()
482 return -EINVAL; /* no parameters specified, abort */ in n2_init()
489 long valid[2] = { 0, 0 }; /* Default = both ports disabled */ in n2_init()
520 return first_card ? 0 : -EINVAL; in n2_init()
524 return first_card ? 0 : -EINVAL; in n2_init()
534 card = card->next_card; in n2_cleanup()
546 MODULE_PARM_DESC(hw, "io,irq,ram,ports:io,irq,...");