Lines Matching defs:ps2port
134 static void gscps2_flush(struct gscps2port *ps2port)
136 while (gscps2_readb_status(ps2port->addr) & GSC_STAT_RBNE)
137 gscps2_readb_input(ps2port->addr);
138 ps2port->act = ps2port->append = 0;
147 static inline int gscps2_writeb_output(struct gscps2port *ps2port, u8 data)
150 char *addr = ps2port->addr;
157 while (gscps2_readb_status(ps2port->addr) & GSC_STAT_RBNE)
160 spin_lock_irqsave(&ps2port->lock, flags);
162 spin_unlock_irqrestore(&ps2port->lock, flags);
179 static void gscps2_enable(struct gscps2port *ps2port, int enable)
185 spin_lock_irqsave(&ps2port->lock, flags);
186 gscps2_flush(ps2port);
187 data = gscps2_readb_control(ps2port->addr);
192 gscps2_writeb_control(data, ps2port->addr);
193 spin_unlock_irqrestore(&ps2port->lock, flags);
194 wait_TBE(ps2port->addr);
195 gscps2_flush(ps2port);
202 static void gscps2_reset(struct gscps2port *ps2port)
204 char *addr = ps2port->addr;
208 spin_lock_irqsave(&ps2port->lock, flags);
209 gscps2_flush(ps2port);
211 gscps2_flush(ps2port);
212 spin_unlock_irqrestore(&ps2port->lock, flags);
231 struct gscps2port *ps2port;
233 list_for_each_entry(ps2port, &ps2port_list, node) {
236 spin_lock_irqsave(&ps2port->lock, flags);
238 while ( (ps2port->buffer[ps2port->append].str =
239 gscps2_readb_status(ps2port->addr)) & GSC_STAT_RBNE ) {
240 ps2port->buffer[ps2port->append].data =
241 gscps2_readb_input(ps2port->addr);
242 ps2port->append = ((ps2port->append+1) & BUFFER_SIZE);
245 spin_unlock_irqrestore(&ps2port->lock, flags);
251 list_for_each_entry(ps2port, &ps2port_list, node) {
253 while (ps2port->act != ps2port->append) {
260 if (gscps2_readb_status(ps2port->addr) & GSC_STAT_CMPINTR)
263 status = ps2port->buffer[ps2port->act].str;
264 data = ps2port->buffer[ps2port->act].data;
266 ps2port->act = ((ps2port->act+1) & BUFFER_SIZE);
270 serio_interrupt(ps2port->port, data, rxflags);
286 struct gscps2port *ps2port = port->port_data;
288 if (!gscps2_writeb_output(ps2port, data)) {
302 struct gscps2port *ps2port = port->port_data;
304 gscps2_reset(ps2port);
307 gscps2_enable(ps2port, ENABLE);
320 struct gscps2port *ps2port = port->port_data;
321 gscps2_enable(ps2port, DISABLE);
331 struct gscps2port *ps2port;
343 ps2port = kmalloc(sizeof(struct gscps2port), GFP_KERNEL);
345 if (!ps2port || !serio) {
350 dev_set_drvdata(&dev->dev, ps2port);
352 memset(ps2port, 0, sizeof(struct gscps2port));
354 ps2port->port = serio;
355 ps2port->padev = dev;
356 ps2port->addr = ioremap_nocache(hpa, GSC_STATUS + 4);
357 spin_lock_init(&ps2port->lock);
359 gscps2_reset(ps2port);
360 ps2port->id = readb(ps2port->addr + GSC_ID) & 0x0f;
363 (ps2port->id == GSC_ID_KEYBOARD) ? "keyboard" : "mouse");
369 serio->port_data = ps2port;
373 if (request_irq(dev->irq, gscps2_interrupt, IRQF_SHARED, ps2port->port->name, ps2port))
376 if (ps2port->id != GSC_ID_KEYBOARD && ps2port->id != GSC_ID_MOUSE) {
378 hpa, ps2port->id);
385 ps2port->port->name,
386 ps2port->addr,
387 ps2port->padev->irq,
388 ps2port->port->phys);
390 serio_register_port(ps2port->port);
392 list_add_tail(&ps2port->node, &ps2port_list);
397 free_irq(dev->irq, ps2port);
400 iounmap(ps2port->addr);
404 kfree(ps2port);
416 struct gscps2port *ps2port = dev_get_drvdata(&dev->dev);
418 serio_unregister_port(ps2port->port);
419 free_irq(dev->irq, ps2port);
420 gscps2_flush(ps2port);
421 list_del(&ps2port->node);
422 iounmap(ps2port->addr);
424 kfree(ps2port);