Lines Matching +full:port +full:- +full:2

2  * IEEE 1284.3 Parallel port daisy chain and multiplexor code
9 * 2 of the License, or (at your option) any later version.
11 * ??-12-1998: Initial implementation.
12 * 31-01-1999: Make port-cloning transparent.
13 * 13-02-1999: Move DeviceID technique from parport_probe.
14 * 13-03-1999: Get DeviceID from non-IEEE 1284.3 devices too.
15 * 22-02-2000: Count devices that are actually detected.
35 struct parport *port; member
44 /* Forward-declaration of lower-level functions. */
45 static int mux_present(struct parport *port);
46 static int num_mux_ports(struct parport *port);
47 static int select_port(struct parport *port);
48 static int assign_addrs(struct parport *port);
51 static void add_dev(int devnum, struct parport *port, int daisy) in add_dev() argument
56 newdev->port = port; in add_dev()
57 newdev->daisy = daisy; in add_dev()
58 newdev->devnum = devnum; in add_dev()
60 for (p = &topology; *p && (*p)->devnum<devnum; p = &(*p)->next) in add_dev()
62 newdev->next = *p; in add_dev()
71 struct parport *extra = parport_register_port(real->base, in clone_parport()
72 real->irq, in clone_parport()
73 real->dma, in clone_parport()
74 real->ops); in clone_parport()
76 extra->portnum = real->portnum; in clone_parport()
77 extra->physport = real; in clone_parport()
78 extra->muxport = muxport; in clone_parport()
79 real->slaves[muxport-1] = extra; in clone_parport()
87 struct device_driver *drv = par_dev->dev.driver; in daisy_drv_probe()
89 if (strcmp(drv->name, "daisy_drv")) in daisy_drv_probe()
90 return -ENODEV; in daisy_drv_probe()
91 if (strcmp(par_dev->name, daisy_dev_name)) in daisy_drv_probe()
92 return -ENODEV; in daisy_drv_probe()
102 /* Discover the IEEE1284.3 topology on a port -- muxes and daisy chains.
104 int parport_daisy_init(struct parport *port) in parport_daisy_init() argument
134 /* If mux present on normal port, need to create new in parport_daisy_init()
135 * parports for each extra port. */ in parport_daisy_init()
136 if (port->muxport < 0 && mux_present(port) && in parport_daisy_init()
137 /* don't be fooled: a mux must have 2 or 4 ports. */ in parport_daisy_init()
138 ((num_ports = num_mux_ports(port)) == 2 || num_ports == 4)) { in parport_daisy_init()
139 /* Leave original as port zero. */ in parport_daisy_init()
140 port->muxport = 0; in parport_daisy_init()
141 pr_info("%s: 1st (default) port of %d-way multiplexor\n", in parport_daisy_init()
142 port->name, num_ports); in parport_daisy_init()
144 /* Clone the port. */ in parport_daisy_init()
145 struct parport *extra = clone_parport(port, i); in parport_daisy_init()
154 pr_info("%s: %d%s port of %d-way multiplexor on %s\n", in parport_daisy_init()
155 extra->name, i + 1, th[i + 1], num_ports, in parport_daisy_init()
156 port->name); in parport_daisy_init()
158 /* Analyse that port too. We won't recurse in parport_daisy_init()
159 forever because of the 'port->muxport < 0' in parport_daisy_init()
165 if (port->muxport >= 0) in parport_daisy_init()
166 select_port(port); in parport_daisy_init()
168 parport_daisy_deselect_all(port); in parport_daisy_init()
169 detected += assign_addrs(port); in parport_daisy_init()
172 add_dev(numdevs++, port, -1); in parport_daisy_init()
177 if (parport_device_id(numdevs - 1, deviceid, 1024) > 2) in parport_daisy_init()
187 parport_daisy_fini(port); in parport_daisy_init()
188 parport_write_control(port, PARPORT_CONTROL_SELECT); in parport_daisy_init()
190 parport_write_control(port, in parport_daisy_init()
201 /* Forget about devices on a physical port. */
202 void parport_daisy_fini(struct parport *port) in parport_daisy_fini() argument
210 if (dev->port != port) { in parport_daisy_fini()
211 p = &dev->next; in parport_daisy_fini()
214 *p = dev->next; in parport_daisy_fini()
227 * parport_open - find a device by canonical device number
232 * that it locates a device by its number rather than by the port
244 struct parport *port; in parport_open() local
250 while (p && p->devnum != devnum) in parport_open()
251 p = p->next; in parport_open()
258 daisy = p->daisy; in parport_open()
259 port = parport_get_port(p->port); in parport_open()
262 dev = parport_register_dev_model(port, name, &par_cb, devnum); in parport_open()
263 parport_put_port(port); in parport_open()
267 dev->daisy = daisy; in parport_open()
273 selected = port->daisy; in parport_open()
287 * parport_close - close a device opened with parport_open()
299 /* Send a daisy-chain-style CPP command packet. */
300 static int cpp_daisy(struct parport *port, int cmd) in cpp_daisy() argument
304 parport_data_forward(port); in cpp_daisy()
305 parport_write_data(port, 0xaa); udelay(2); in cpp_daisy()
306 parport_write_data(port, 0x55); udelay(2); in cpp_daisy()
307 parport_write_data(port, 0x00); udelay(2); in cpp_daisy()
308 parport_write_data(port, 0xff); udelay(2); in cpp_daisy()
309 s = parport_read_status(port) & (PARPORT_STATUS_BUSY in cpp_daisy()
317 pr_debug("%s: cpp_daisy: aa5500ff(%02x)\n", port->name, s); in cpp_daisy()
318 return -ENXIO; in cpp_daisy()
321 parport_write_data(port, 0x87); udelay(2); in cpp_daisy()
322 s = parport_read_status(port) & (PARPORT_STATUS_BUSY in cpp_daisy()
327 pr_debug("%s: cpp_daisy: aa5500ff87(%02x)\n", port->name, s); in cpp_daisy()
328 return -ENXIO; in cpp_daisy()
331 parport_write_data(port, 0x78); udelay(2); in cpp_daisy()
332 parport_write_data(port, cmd); udelay(2); in cpp_daisy()
333 parport_frob_control(port, in cpp_daisy()
337 s = parport_read_status(port); in cpp_daisy()
338 parport_frob_control(port, PARPORT_CONTROL_STROBE, 0); in cpp_daisy()
340 parport_write_data(port, 0xff); udelay(2); in cpp_daisy()
345 /* Send a mux-style CPP command packet. */
346 static int cpp_mux(struct parport *port, int cmd) in cpp_mux() argument
351 parport_data_forward(port); in cpp_mux()
352 parport_write_data(port, 0xaa); udelay(2); in cpp_mux()
353 parport_write_data(port, 0x55); udelay(2); in cpp_mux()
354 parport_write_data(port, 0xf0); udelay(2); in cpp_mux()
355 parport_write_data(port, 0x0f); udelay(2); in cpp_mux()
356 parport_write_data(port, 0x52); udelay(2); in cpp_mux()
357 parport_write_data(port, 0xad); udelay(2); in cpp_mux()
358 parport_write_data(port, cmd); udelay(2); in cpp_mux()
360 s = parport_read_status(port); in cpp_mux()
363 port->name, cmd, s); in cpp_mux()
364 return -EIO; in cpp_mux()
369 ((s & PARPORT_STATUS_BUSY ? 0 : 1) << 2) | in cpp_mux()
375 void parport_daisy_deselect_all(struct parport *port) in parport_daisy_deselect_all() argument
377 cpp_daisy(port, 0x30); in parport_daisy_deselect_all()
380 int parport_daisy_select(struct parport *port, int daisy, int mode) in parport_daisy_select() argument
388 return !(cpp_daisy(port, 0x20 + daisy) & in parport_daisy_select()
395 return !(cpp_daisy(port, 0xd0 + daisy) & in parport_daisy_select()
406 return !(cpp_daisy(port, 0xe0 + daisy) & in parport_daisy_select()
411 static int mux_present(struct parport *port) in mux_present() argument
413 return cpp_mux(port, 0x51) == 3; in mux_present()
416 static int num_mux_ports(struct parport *port) in num_mux_ports() argument
418 return cpp_mux(port, 0x58); in num_mux_ports()
421 static int select_port(struct parport *port) in select_port() argument
423 int muxport = port->muxport; in select_port()
424 return cpp_mux(port, 0x60 + muxport) == muxport; in select_port()
427 static int assign_addrs(struct parport *port) in assign_addrs() argument
435 parport_data_forward(port); in assign_addrs()
436 parport_write_data(port, 0xaa); udelay(2); in assign_addrs()
437 parport_write_data(port, 0x55); udelay(2); in assign_addrs()
438 parport_write_data(port, 0x00); udelay(2); in assign_addrs()
439 parport_write_data(port, 0xff); udelay(2); in assign_addrs()
440 s = parport_read_status(port) & (PARPORT_STATUS_BUSY in assign_addrs()
448 pr_debug("%s: assign_addrs: aa5500ff(%02x)\n", port->name, s); in assign_addrs()
452 parport_write_data(port, 0x87); udelay(2); in assign_addrs()
453 s = parport_read_status(port) & (PARPORT_STATUS_BUSY in assign_addrs()
458 pr_debug("%s: assign_addrs: aa5500ff87(%02x)\n", port->name, s); in assign_addrs()
462 parport_write_data(port, 0x78); udelay(2); in assign_addrs()
463 s = parport_read_status(port); in assign_addrs()
470 parport_write_data(port, daisy); in assign_addrs()
471 udelay(2); in assign_addrs()
472 parport_frob_control(port, in assign_addrs()
476 parport_frob_control(port, PARPORT_CONTROL_STROBE, 0); in assign_addrs()
479 add_dev(numdevs++, port, daisy); in assign_addrs()
488 work status lines from some non-daisy chain in assign_addrs()
490 s = parport_read_status(port); in assign_addrs()
493 parport_write_data(port, 0xff); udelay(2); in assign_addrs()
494 detected = numdevs - thisdev; in assign_addrs()
495 pr_debug("%s: Found %d daisy-chained devices\n", port->name, detected); in assign_addrs()