Lines Matching refs:ps2if

43 struct ps2if {  struct
63 struct ps2if *ps2if = dev_id; in ps2_rxint() local
66 status = readl_relaxed(ps2if->base + PS2STAT); in ps2_rxint()
69 writel_relaxed(PS2STAT_STP, ps2if->base + PS2STAT); in ps2_rxint()
74 scancode = readl_relaxed(ps2if->base + PS2DATA) & 0xff; in ps2_rxint()
79 serio_interrupt(ps2if->io, scancode, flag); in ps2_rxint()
81 status = readl_relaxed(ps2if->base + PS2STAT); in ps2_rxint()
92 struct ps2if *ps2if = dev_id; in ps2_txint() local
95 spin_lock(&ps2if->lock); in ps2_txint()
96 status = readl_relaxed(ps2if->base + PS2STAT); in ps2_txint()
97 if (ps2if->head == ps2if->tail) { in ps2_txint()
101 writel_relaxed(ps2if->buf[ps2if->tail], ps2if->base + PS2DATA); in ps2_txint()
102 ps2if->tail = (ps2if->tail + 1) & (sizeof(ps2if->buf) - 1); in ps2_txint()
104 spin_unlock(&ps2if->lock); in ps2_txint()
115 struct ps2if *ps2if = io->port_data; in ps2_write() local
119 spin_lock_irqsave(&ps2if->lock, flags); in ps2_write()
124 if (readl_relaxed(ps2if->base + PS2STAT) & PS2STAT_TXE) { in ps2_write()
125 writel_relaxed(val, ps2if->base + PS2DATA); in ps2_write()
127 if (ps2if->head == ps2if->tail) in ps2_write()
128 enable_irq(ps2if->tx_irq); in ps2_write()
129 head = (ps2if->head + 1) & (sizeof(ps2if->buf) - 1); in ps2_write()
130 if (head != ps2if->tail) { in ps2_write()
131 ps2if->buf[ps2if->head] = val; in ps2_write()
132 ps2if->head = head; in ps2_write()
136 spin_unlock_irqrestore(&ps2if->lock, flags); in ps2_write()
142 struct ps2if *ps2if = io->port_data; in ps2_open() local
145 ret = sa1111_enable_device(ps2if->dev); in ps2_open()
149 ret = request_irq(ps2if->rx_irq, ps2_rxint, 0, in ps2_open()
150 SA1111_DRIVER_NAME(ps2if->dev), ps2if); in ps2_open()
153 ps2if->rx_irq, ret); in ps2_open()
154 sa1111_disable_device(ps2if->dev); in ps2_open()
158 ret = request_irq(ps2if->tx_irq, ps2_txint, 0, in ps2_open()
159 SA1111_DRIVER_NAME(ps2if->dev), ps2if); in ps2_open()
162 ps2if->tx_irq, ret); in ps2_open()
163 free_irq(ps2if->rx_irq, ps2if); in ps2_open()
164 sa1111_disable_device(ps2if->dev); in ps2_open()
168 ps2if->open = 1; in ps2_open()
170 enable_irq_wake(ps2if->rx_irq); in ps2_open()
172 writel_relaxed(PS2CR_ENA, ps2if->base + PS2CR); in ps2_open()
178 struct ps2if *ps2if = io->port_data; in ps2_close() local
180 writel_relaxed(0, ps2if->base + PS2CR); in ps2_close()
182 disable_irq_wake(ps2if->rx_irq); in ps2_close()
184 ps2if->open = 0; in ps2_close()
186 free_irq(ps2if->tx_irq, ps2if); in ps2_close()
187 free_irq(ps2if->rx_irq, ps2if); in ps2_close()
189 sa1111_disable_device(ps2if->dev); in ps2_close()
195 static void ps2_clear_input(struct ps2if *ps2if) in ps2_clear_input() argument
200 if ((readl_relaxed(ps2if->base + PS2DATA) & 0xff) == 0xff) in ps2_clear_input()
205 static unsigned int ps2_test_one(struct ps2if *ps2if, in ps2_test_one() argument
210 writel_relaxed(PS2CR_ENA | mask, ps2if->base + PS2CR); in ps2_test_one()
214 val = readl_relaxed(ps2if->base + PS2STAT); in ps2_test_one()
222 static int ps2_test(struct ps2if *ps2if) in ps2_test() argument
227 stat = ps2_test_one(ps2if, PS2CR_FKC); in ps2_test()
233 stat = ps2_test_one(ps2if, 0); in ps2_test()
239 stat = ps2_test_one(ps2if, PS2CR_FKD); in ps2_test()
245 writel_relaxed(0, ps2if->base + PS2CR); in ps2_test()
255 struct ps2if *ps2if; in ps2_probe() local
259 ps2if = kzalloc(sizeof(struct ps2if), GFP_KERNEL); in ps2_probe()
261 if (!ps2if || !serio) { in ps2_probe()
272 serio->port_data = ps2if; in ps2_probe()
274 ps2if->io = serio; in ps2_probe()
275 ps2if->dev = dev; in ps2_probe()
276 sa1111_set_drvdata(dev, ps2if); in ps2_probe()
278 spin_lock_init(&ps2if->lock); in ps2_probe()
280 ps2if->rx_irq = sa1111_get_irq(dev, 0); in ps2_probe()
281 if (ps2if->rx_irq <= 0) { in ps2_probe()
282 ret = ps2if->rx_irq ? : -ENXIO; in ps2_probe()
286 ps2if->tx_irq = sa1111_get_irq(dev, 1); in ps2_probe()
287 if (ps2if->tx_irq <= 0) { in ps2_probe()
288 ret = ps2if->tx_irq ? : -ENXIO; in ps2_probe()
305 ps2if->base = dev->mapbase; in ps2_probe()
307 sa1111_enable_device(ps2if->dev); in ps2_probe()
310 writel_relaxed(0, ps2if->base + PS2CLKDIV); in ps2_probe()
311 writel_relaxed(127, ps2if->base + PS2PRECNT); in ps2_probe()
316 ps2_clear_input(ps2if); in ps2_probe()
321 ret = ps2_test(ps2if); in ps2_probe()
328 ps2_clear_input(ps2if); in ps2_probe()
330 sa1111_disable_device(ps2if->dev); in ps2_probe()
331 serio_register_port(ps2if->io); in ps2_probe()
335 sa1111_disable_device(ps2if->dev); in ps2_probe()
339 kfree(ps2if); in ps2_probe()
349 struct ps2if *ps2if = sa1111_get_drvdata(dev); in ps2_remove() local
351 serio_unregister_port(ps2if->io); in ps2_remove()
355 kfree(ps2if); in ps2_remove()