Lines Matching +full:layer +full:- +full:buffer +full:- +full:offset

4  * Copyright (c) 2004-2006 Helge Deller <[email protected]>
6 * Copyright (c) 2002 Thibaut Varene <varenet@parisc-linux.org>
8 * Pieces of code based on linux-2.4's hp_mouse.c & hp_keyb.c
10 * Copyright (c) 1999-2000 Philipp Rumpf <[email protected]>
12 * Copyright (c) 2000-2001 Thomas Marteau <[email protected]>
21 * - Dino testing (did HP ever shipped a machine on which this port
37 #include <asm/parisc-device.h>
39 MODULE_AUTHOR("Laurent Canet <[email protected]>, Thibaut Varene <varenet@parisc-linux.org>, Helge De…
53 #define GSC_DINO_OFFSET 0x0800 /* offset for DINO controller versus LASI one */
56 #define GSC_ID 0x00 /* device ID offset (see: GSC_ID_XXX) */
57 #define GSC_RESET 0x00 /* reset port offset */
58 #define GSC_RCVDATA 0x04 /* receive port offset */
59 #define GSC_XMTDATA 0x04 /* transmit port offset */
71 #define GSC_STAT_RBNE 0x01 /* Receive Buffer Not Empty */
72 #define GSC_STAT_TBNE 0x02 /* Transmit Buffer Not Empty */
95 u8 act, append; /* position in buffer[] */
99 } buffer[BUFFER_SIZE+1]; member
114 * wait_TBE() - wait for Transmit Buffer Empty
121 if (!--timeout) in wait_TBE()
130 * gscps2_flush() - flush the receive buffer
135 while (gscps2_readb_status(ps2port->addr) & GSC_STAT_RBNE) in gscps2_flush()
136 gscps2_readb_input(ps2port->addr); in gscps2_flush()
137 ps2port->act = ps2port->append = 0; in gscps2_flush()
141 * gscps2_writeb_output() - write a byte to the port
148 char __iomem *addr = ps2port->addr; in gscps2_writeb_output()
151 printk(KERN_DEBUG PFX "timeout - could not write byte %#x\n", data); in gscps2_writeb_output()
158 scoped_guard(spinlock_irqsave, &ps2port->lock) in gscps2_writeb_output()
173 * gscps2_enable() - enables or disables the port
181 scoped_guard(spinlock_irqsave, &ps2port->lock) { in gscps2_enable()
183 data = gscps2_readb_control(ps2port->addr); in gscps2_enable()
188 gscps2_writeb_control(data, ps2port->addr); in gscps2_enable()
191 wait_TBE(ps2port->addr); in gscps2_enable()
196 * gscps2_reset() - resets the PS/2 port
202 guard(spinlock_irqsave)(&ps2port->lock); in gscps2_reset()
204 writeb(0xff, ps2port->addr + GSC_RESET); in gscps2_reset()
215 status = gscps2_readb_status(ps2port->addr); in gscps2_read_data()
219 ps2port->buffer[ps2port->append].str = status; in gscps2_read_data()
220 ps2port->buffer[ps2port->append].data = in gscps2_read_data()
221 gscps2_readb_input(ps2port->addr); in gscps2_read_data()
230 while (ps2port->act != ps2port->append) { in gscps2_report_data()
236 if (gscps2_readb_status(ps2port->addr) & GSC_STAT_CMPINTR) in gscps2_report_data()
239 status = ps2port->buffer[ps2port->act].str; in gscps2_report_data()
240 data = ps2port->buffer[ps2port->act].data; in gscps2_report_data()
242 ps2port->act = (ps2port->act + 1) & BUFFER_SIZE; in gscps2_report_data()
246 serio_interrupt(ps2port->port, data, rxflags); in gscps2_report_data()
253 * gscps2_interrupt() - Interruption service routine
260 * the data as fast as possible and handle the reporting to the upper layer
269 guard(spinlock_irqsave)(&ps2port->lock); in gscps2_interrupt()
274 /* all data was read from the ports - now report the data to upper layer */ in gscps2_interrupt()
277 /* More data ready - break early to restart interrupt */ in gscps2_interrupt()
287 * gscps2_write() - send a byte out through the aux interface.
292 struct gscps2port *ps2port = port->port_data; in gscps2_write()
296 return -1; in gscps2_write()
302 * gscps2_open() is called when a port is opened by the higher layer.
308 struct gscps2port *ps2port = port->port_data; in gscps2_open()
326 struct gscps2port *ps2port = port->port_data; in gscps2_close()
331 * gscps2_probe() - Probes PS2 devices
339 unsigned long hpa = dev->hpa.start; in gscps2_probe()
342 if (!dev->irq) in gscps2_probe()
343 return -ENODEV; in gscps2_probe()
345 /* Offset for DINO PS/2. Works with LASI even */ in gscps2_probe()
346 if (dev->id.sversion == 0x96) in gscps2_probe()
352 ret = -ENOMEM; in gscps2_probe()
356 dev_set_drvdata(&dev->dev, ps2port); in gscps2_probe()
358 ps2port->port = serio; in gscps2_probe()
359 ps2port->padev = dev; in gscps2_probe()
360 ps2port->addr = ioremap(hpa, GSC_STATUS + 4); in gscps2_probe()
361 if (!ps2port->addr) { in gscps2_probe()
362 ret = -ENOMEM; in gscps2_probe()
365 spin_lock_init(&ps2port->lock); in gscps2_probe()
368 ps2port->id = readb(ps2port->addr + GSC_ID) & 0x0f; in gscps2_probe()
370 snprintf(serio->name, sizeof(serio->name), "gsc-ps2-%s", in gscps2_probe()
371 (ps2port->id == GSC_ID_KEYBOARD) ? "keyboard" : "mouse"); in gscps2_probe()
372 strscpy(serio->phys, dev_name(&dev->dev), sizeof(serio->phys)); in gscps2_probe()
373 serio->id.type = SERIO_8042; in gscps2_probe()
374 serio->write = gscps2_write; in gscps2_probe()
375 serio->open = gscps2_open; in gscps2_probe()
376 serio->close = gscps2_close; in gscps2_probe()
377 serio->port_data = ps2port; in gscps2_probe()
378 serio->dev.parent = &dev->dev; in gscps2_probe()
380 ret = -EBUSY; in gscps2_probe()
381 if (request_irq(dev->irq, gscps2_interrupt, IRQF_SHARED, ps2port->port->name, ps2port)) in gscps2_probe()
384 if (ps2port->id != GSC_ID_KEYBOARD && ps2port->id != GSC_ID_MOUSE) { in gscps2_probe()
386 hpa, ps2port->id); in gscps2_probe()
387 ret = -ENODEV; in gscps2_probe()
392 if (!request_mem_region(hpa, GSC_STATUS + 4, ps2port->port.name)) in gscps2_probe()
397 ps2port->port->name, in gscps2_probe()
399 ps2port->padev->irq, in gscps2_probe()
400 ps2port->port->phys); in gscps2_probe()
402 serio_register_port(ps2port->port); in gscps2_probe()
404 list_add_tail(&ps2port->node, &ps2port_list); in gscps2_probe()
409 free_irq(dev->irq, ps2port); in gscps2_probe()
412 iounmap(ps2port->addr); in gscps2_probe()
413 release_mem_region(dev->hpa.start, GSC_STATUS + 4); in gscps2_probe()
422 * gscps2_remove() - Removes PS2 devices
428 struct gscps2port *ps2port = dev_get_drvdata(&dev->dev); in gscps2_remove()
430 serio_unregister_port(ps2port->port); in gscps2_remove()
431 free_irq(dev->irq, ps2port); in gscps2_remove()
433 list_del(&ps2port->node); in gscps2_remove()
434 iounmap(ps2port->addr); in gscps2_remove()
436 release_mem_region(dev->hpa, GSC_STATUS + 4); in gscps2_remove()
438 dev_set_drvdata(&dev->dev, NULL); in gscps2_remove()