Lines Matching +full:10 +full:base +full:- +full:te

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2000-2008 Krzysztof Halasa <khc@pm.waw.pl>
10 * Hitachi HD64572 SCA-II User's Manual
44 #define MAX_TX_BUFFERS 10
57 /* PLX PCI9050-1 local configuration and shared runtime registers.
61 u32 loc_addr_range[4]; /* 00-0Ch : Local Address Ranges */
62 u32 loc_rom_range; /* 10h : Local ROM Range */
63 u32 loc_addr_base[4]; /* 14-20h : Local Address Base Addrs */
64 u32 loc_rom_base; /* 24h : Local ROM Base */
65 u32 loc_bus_descr[4]; /* 28-34h : Local Bus Descriptors */
67 u32 cs_base[4]; /* 3C-48h : Chip Select Base Addrs */
86 u8 chan; /* physical port # - 0 or 1 */
92 u8 __iomem *rambase; /* buffer memory base (virtual) */
93 u8 __iomem *scabase; /* SCA memory base (virtual) */
94 plx9050 __iomem *plxbase; /* PLX registers memory base (virtual) */
95 u32 init_ctrl_value; /* Saved value - 9050 bug workaround */
104 #define get_port(card, port) ((port) < (card)->n_ports ? \
105 (&(card)->ports[port]) : (NULL))
111 card_t *card = port->card; in pc300_set_iface()
112 u32 __iomem *init_ctrl = &card->plxbase->init_ctrl; in pc300_set_iface()
114 u8 rxs = port->rxs & CLK_BRG_MASK; in pc300_set_iface()
115 u8 txs = port->txs & CLK_BRG_MASK; in pc300_set_iface()
117 sca_out(EXS_TES1, (port->chan ? MSCI1_OFFSET : MSCI0_OFFSET) + EXS, in pc300_set_iface()
118 port->card); in pc300_set_iface()
119 switch (port->settings.clock_type) { in pc300_set_iface()
141 port->rxs = rxs; in pc300_set_iface()
142 port->txs = txs; in pc300_set_iface()
147 if (port->card->type == PC300_RSV) { in pc300_set_iface()
148 if (port->iface == IF_IFACE_V35) in pc300_set_iface()
149 writel(card->init_ctrl_value | in pc300_set_iface()
150 PC300_CHMEDIA_MASK(port->chan), init_ctrl); in pc300_set_iface()
152 writel(card->init_ctrl_value & in pc300_set_iface()
153 ~PC300_CHMEDIA_MASK(port->chan), init_ctrl); in pc300_set_iface()
186 return -EOPNOTSUPP; in pc300_siocdevprivate()
193 sync_serial_settings __user *line = ifs->ifs_ifsu.sync; in pc300_ioctl()
197 if (ifs->type == IF_GET_IFACE) { in pc300_ioctl()
198 ifs->type = port->iface; in pc300_ioctl()
199 if (ifs->size < size) { in pc300_ioctl()
200 ifs->size = size; /* data size wanted */ in pc300_ioctl()
201 return -ENOBUFS; in pc300_ioctl()
203 if (copy_to_user(line, &port->settings, size)) in pc300_ioctl()
204 return -EFAULT; in pc300_ioctl()
208 if (port->card->type == PC300_X21 && in pc300_ioctl()
209 (ifs->type == IF_IFACE_SYNC_SERIAL || in pc300_ioctl()
210 ifs->type == IF_IFACE_X21)) in pc300_ioctl()
213 else if (port->card->type == PC300_RSV && in pc300_ioctl()
214 (ifs->type == IF_IFACE_SYNC_SERIAL || in pc300_ioctl()
215 ifs->type == IF_IFACE_V35)) in pc300_ioctl()
218 else if (port->card->type == PC300_RSV && in pc300_ioctl()
219 ifs->type == IF_IFACE_V24) in pc300_ioctl()
226 return -EPERM; in pc300_ioctl()
229 return -EFAULT; in pc300_ioctl()
235 return -EINVAL; /* No such clock setting */ in pc300_ioctl()
238 return -EINVAL; in pc300_ioctl()
240 memcpy(&port->settings, &new_line, size); /* Update settings */ in pc300_ioctl()
241 port->iface = new_type; in pc300_ioctl()
252 if (card->ports[i].card) in pc300_pci_remove_one()
253 unregister_hdlc_device(card->ports[i].netdev); in pc300_pci_remove_one()
255 if (card->irq) in pc300_pci_remove_one()
256 free_irq(card->irq, card); in pc300_pci_remove_one()
258 if (card->rambase) in pc300_pci_remove_one()
259 iounmap(card->rambase); in pc300_pci_remove_one()
260 if (card->scabase) in pc300_pci_remove_one()
261 iounmap(card->scabase); in pc300_pci_remove_one()
262 if (card->plxbase) in pc300_pci_remove_one()
263 iounmap(card->plxbase); in pc300_pci_remove_one()
267 if (card->ports[0].netdev) in pc300_pci_remove_one()
268 free_netdev(card->ports[0].netdev); in pc300_pci_remove_one()
269 if (card->ports[1].netdev) in pc300_pci_remove_one()
270 free_netdev(card->ports[1].netdev); in pc300_pci_remove_one()
289 u32 ramphys; /* buffer memory base */ in pc300_pci_init_one()
290 u32 scaphys; /* SCA memory base */ in pc300_pci_init_one()
291 u32 plxphys; /* PLX registers memory base */ in pc300_pci_init_one()
307 return -ENOBUFS; in pc300_pci_init_one()
316 return -EFAULT; in pc300_pci_init_one()
320 card->plxbase = ioremap(plxphys, PC300_PLX_SIZE); in pc300_pci_init_one()
323 card->scabase = ioremap(scaphys, PC300_SCA_SIZE); in pc300_pci_init_one()
326 card->rambase = pci_ioremap_bar(pdev, 3); in pc300_pci_init_one()
328 if (!card->plxbase || !card->scabase || !card->rambase) { in pc300_pci_init_one()
331 return -ENOMEM; in pc300_pci_init_one()
336 card->init_ctrl_value = readl(&((plx9050 __iomem *)card->scabase)->init_ctrl); in pc300_pci_init_one()
339 if (pdev->device == PCI_DEVICE_ID_PC300_TE_1 || in pc300_pci_init_one()
340 pdev->device == PCI_DEVICE_ID_PC300_TE_2) in pc300_pci_init_one()
341 card->type = PC300_TE; /* not fully supported */ in pc300_pci_init_one()
342 else if (card->init_ctrl_value & PC300_CTYPE_MASK) in pc300_pci_init_one()
343 card->type = PC300_X21; in pc300_pci_init_one()
345 card->type = PC300_RSV; in pc300_pci_init_one()
347 if (pdev->device == PCI_DEVICE_ID_PC300_RX_1 || in pc300_pci_init_one()
348 pdev->device == PCI_DEVICE_ID_PC300_TE_1) in pc300_pci_init_one()
349 card->n_ports = 1; in pc300_pci_init_one()
351 card->n_ports = 2; in pc300_pci_init_one()
353 for (i = 0; i < card->n_ports; i++) { in pc300_pci_init_one()
354 card->ports[i].netdev = alloc_hdlcdev(&card->ports[i]); in pc300_pci_init_one()
355 if (!card->ports[i].netdev) { in pc300_pci_init_one()
358 return -ENOMEM; in pc300_pci_init_one()
363 p = &card->plxbase->init_ctrl; in pc300_pci_init_one()
364 writel(card->init_ctrl_value | 0x40000000, p); in pc300_pci_init_one()
365 readl(p); /* Flush the write - do not use sca_flush */ in pc300_pci_init_one()
368 writel(card->init_ctrl_value, p); in pc300_pci_init_one()
369 readl(p); /* Flush the write - do not use sca_flush */ in pc300_pci_init_one()
373 writel(card->init_ctrl_value | 0x20000000, p); in pc300_pci_init_one()
374 readl(p); /* Flush the write - do not use sca_flush */ in pc300_pci_init_one()
377 writel(card->init_ctrl_value, p); in pc300_pci_init_one()
378 readl(p); /* Flush the write - do not use sca_flush */ in pc300_pci_init_one()
381 ramsize = sca_detect_ram(card, card->rambase, in pc300_pci_init_one()
385 card->init_ctrl_value &= ~PC300_CLKSEL_MASK; in pc300_pci_init_one()
387 card->init_ctrl_value |= PC300_CLKSEL_MASK; in pc300_pci_init_one()
389 writel(card->init_ctrl_value, &card->plxbase->init_ctrl); in pc300_pci_init_one()
391 i = ramsize / (card->n_ports * (sizeof(pkt_desc) + HDLC_MAX_MRU)); in pc300_pci_init_one()
392 card->tx_ring_buffers = min(i / 2, MAX_TX_BUFFERS); in pc300_pci_init_one()
393 card->rx_ring_buffers = i - card->tx_ring_buffers; in pc300_pci_init_one()
395 card->buff_offset = card->n_ports * sizeof(pkt_desc) * in pc300_pci_init_one()
396 (card->tx_ring_buffers + card->rx_ring_buffers); in pc300_pci_init_one()
399 card->type == PC300_X21 ? "X21" : in pc300_pci_init_one()
400 card->type == PC300_TE ? "TE" : "RSV", in pc300_pci_init_one()
401 ramsize / 1024, ramphys, pdev->irq, in pc300_pci_init_one()
402 card->tx_ring_buffers, card->rx_ring_buffers); in pc300_pci_init_one()
404 if (card->tx_ring_buffers < 1) { in pc300_pci_init_one()
407 return -EFAULT; in pc300_pci_init_one()
411 writew(0x0041, &card->plxbase->intr_ctrl_stat); in pc300_pci_init_one()
414 if (request_irq(pdev->irq, sca_intr, IRQF_SHARED, "pc300", card)) { in pc300_pci_init_one()
415 pr_warn("could not allocate IRQ%d\n", pdev->irq); in pc300_pci_init_one()
417 return -EBUSY; in pc300_pci_init_one()
419 card->irq = pdev->irq; in pc300_pci_init_one()
423 // COTE not set - allows better TX DMA settings in pc300_pci_init_one()
428 for (i = 0; i < card->n_ports; i++) { in pc300_pci_init_one()
429 port_t *port = &card->ports[i]; in pc300_pci_init_one()
430 struct net_device *dev = port->netdev; in pc300_pci_init_one()
433 port->chan = i; in pc300_pci_init_one()
435 spin_lock_init(&port->lock); in pc300_pci_init_one()
436 dev->irq = card->irq; in pc300_pci_init_one()
437 dev->mem_start = ramphys; in pc300_pci_init_one()
438 dev->mem_end = ramphys + ramsize - 1; in pc300_pci_init_one()
439 dev->tx_queue_len = 50; in pc300_pci_init_one()
440 dev->netdev_ops = &pc300_ops; in pc300_pci_init_one()
441 hdlc->attach = sca_attach; in pc300_pci_init_one()
442 hdlc->xmit = sca_xmit; in pc300_pci_init_one()
443 port->settings.clock_type = CLOCK_EXT; in pc300_pci_init_one()
444 port->card = card; in pc300_pci_init_one()
445 if (card->type == PC300_X21) in pc300_pci_init_one()
446 port->iface = IF_IFACE_X21; in pc300_pci_init_one()
448 port->iface = IF_IFACE_V35; in pc300_pci_init_one()
453 port->card = NULL; in pc300_pci_init_one()
455 return -ENOBUFS; in pc300_pci_init_one()
458 netdev_info(dev, "PC300 channel %d\n", port->chan); in pc300_pci_init_one()
486 return -EINVAL; in pc300_init_module()
490 return -EINVAL; in pc300_init_module()