Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 Google, Inc. |
| 3 | * Copyright (C) 2012 Intel, Inc. |
| 4 | * |
| 5 | * This software is licensed under the terms of the GNU General Public |
| 6 | * License version 2, as published by the Free Software Foundation, and |
| 7 | * may be copied, distributed, and modified under those terms. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | */ |
| 15 | |
| 16 | #include <linux/console.h> |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 17 | #include <linux/interrupt.h> |
| 18 | #include <linux/platform_device.h> |
| 19 | #include <linux/tty.h> |
| 20 | #include <linux/tty_flip.h> |
| 21 | #include <linux/slab.h> |
| 22 | #include <linux/io.h> |
| 23 | #include <linux/module.h> |
Alan | e0f682e0 | 2014-05-12 16:57:05 +0100 | [diff] [blame] | 24 | #include <linux/goldfish.h> |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 25 | |
Aleksandar Markovic | 2296eee | 2017-08-29 15:53:18 +0200 | [diff] [blame^] | 26 | /* Goldfish tty register's offsets */ |
| 27 | #define GOLDFISH_TTY_REG_BYTES_READY 0x04 |
| 28 | #define GOLDFISH_TTY_REG_CMD 0x08 |
| 29 | #define GOLDFISH_TTY_REG_DATA_PTR 0x10 |
| 30 | #define GOLDFISH_TTY_REG_DATA_LEN 0x14 |
| 31 | #define GOLDFISH_TTY_REG_DATA_PTR_HIGH 0x18 |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 32 | |
Aleksandar Markovic | 2296eee | 2017-08-29 15:53:18 +0200 | [diff] [blame^] | 33 | /* Goldfish tty commands */ |
| 34 | #define GOLDFISH_TTY_CMD_INT_DISABLE 0 |
| 35 | #define GOLDFISH_TTY_CMD_INT_ENABLE 1 |
| 36 | #define GOLDFISH_TTY_CMD_WRITE_BUFFER 2 |
| 37 | #define GOLDFISH_TTY_CMD_READ_BUFFER 3 |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 38 | |
| 39 | struct goldfish_tty { |
| 40 | struct tty_port port; |
| 41 | spinlock_t lock; |
| 42 | void __iomem *base; |
| 43 | u32 irq; |
| 44 | int opencount; |
| 45 | struct console console; |
| 46 | }; |
| 47 | |
| 48 | static DEFINE_MUTEX(goldfish_tty_lock); |
| 49 | static struct tty_driver *goldfish_tty_driver; |
| 50 | static u32 goldfish_tty_line_count = 8; |
| 51 | static u32 goldfish_tty_current_line_count; |
| 52 | static struct goldfish_tty *goldfish_ttys; |
| 53 | |
| 54 | static void goldfish_tty_do_write(int line, const char *buf, unsigned count) |
| 55 | { |
| 56 | unsigned long irq_flags; |
| 57 | struct goldfish_tty *qtty = &goldfish_ttys[line]; |
| 58 | void __iomem *base = qtty->base; |
| 59 | spin_lock_irqsave(&qtty->lock, irq_flags); |
Aleksandar Markovic | 2296eee | 2017-08-29 15:53:18 +0200 | [diff] [blame^] | 60 | gf_write_ptr(buf, base + GOLDFISH_TTY_REG_DATA_PTR, |
| 61 | base + GOLDFISH_TTY_REG_DATA_PTR_HIGH); |
| 62 | writel(count, base + GOLDFISH_TTY_REG_DATA_LEN); |
| 63 | writel(GOLDFISH_TTY_CMD_WRITE_BUFFER, base + GOLDFISH_TTY_REG_CMD); |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 64 | spin_unlock_irqrestore(&qtty->lock, irq_flags); |
| 65 | } |
| 66 | |
| 67 | static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id) |
| 68 | { |
Greg Hackmann | 465893e | 2016-02-26 19:01:05 +0000 | [diff] [blame] | 69 | struct goldfish_tty *qtty = dev_id; |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 70 | void __iomem *base = qtty->base; |
| 71 | unsigned long irq_flags; |
| 72 | unsigned char *buf; |
| 73 | u32 count; |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 74 | |
Aleksandar Markovic | 2296eee | 2017-08-29 15:53:18 +0200 | [diff] [blame^] | 75 | count = readl(base + GOLDFISH_TTY_REG_BYTES_READY); |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 76 | if (count == 0) |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 77 | return IRQ_NONE; |
| 78 | |
Alan Cox | ebcf098 | 2013-01-25 15:05:30 +0000 | [diff] [blame] | 79 | count = tty_prepare_flip_string(&qtty->port, &buf, count); |
| 80 | spin_lock_irqsave(&qtty->lock, irq_flags); |
Aleksandar Markovic | 2296eee | 2017-08-29 15:53:18 +0200 | [diff] [blame^] | 81 | gf_write_ptr(buf, base + GOLDFISH_TTY_REG_DATA_PTR, |
| 82 | base + GOLDFISH_TTY_REG_DATA_PTR_HIGH); |
| 83 | writel(count, base + GOLDFISH_TTY_REG_DATA_LEN); |
| 84 | writel(GOLDFISH_TTY_CMD_READ_BUFFER, base + GOLDFISH_TTY_REG_CMD); |
Alan Cox | ebcf098 | 2013-01-25 15:05:30 +0000 | [diff] [blame] | 85 | spin_unlock_irqrestore(&qtty->lock, irq_flags); |
| 86 | tty_schedule_flip(&qtty->port); |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 87 | return IRQ_HANDLED; |
| 88 | } |
| 89 | |
| 90 | static int goldfish_tty_activate(struct tty_port *port, struct tty_struct *tty) |
| 91 | { |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 92 | struct goldfish_tty *qtty = container_of(port, struct goldfish_tty, |
| 93 | port); |
Aleksandar Markovic | 2296eee | 2017-08-29 15:53:18 +0200 | [diff] [blame^] | 94 | writel(GOLDFISH_TTY_CMD_INT_ENABLE, qtty->base + GOLDFISH_TTY_REG_CMD); |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | static void goldfish_tty_shutdown(struct tty_port *port) |
| 99 | { |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 100 | struct goldfish_tty *qtty = container_of(port, struct goldfish_tty, |
| 101 | port); |
Aleksandar Markovic | 2296eee | 2017-08-29 15:53:18 +0200 | [diff] [blame^] | 102 | writel(GOLDFISH_TTY_CMD_INT_DISABLE, qtty->base + GOLDFISH_TTY_REG_CMD); |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 103 | } |
| 104 | |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 105 | static int goldfish_tty_open(struct tty_struct *tty, struct file *filp) |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 106 | { |
| 107 | struct goldfish_tty *qtty = &goldfish_ttys[tty->index]; |
| 108 | return tty_port_open(&qtty->port, tty, filp); |
| 109 | } |
| 110 | |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 111 | static void goldfish_tty_close(struct tty_struct *tty, struct file *filp) |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 112 | { |
| 113 | tty_port_close(tty->port, tty, filp); |
| 114 | } |
| 115 | |
| 116 | static void goldfish_tty_hangup(struct tty_struct *tty) |
| 117 | { |
| 118 | tty_port_hangup(tty->port); |
| 119 | } |
| 120 | |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 121 | static int goldfish_tty_write(struct tty_struct *tty, const unsigned char *buf, |
| 122 | int count) |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 123 | { |
| 124 | goldfish_tty_do_write(tty->index, buf, count); |
| 125 | return count; |
| 126 | } |
| 127 | |
| 128 | static int goldfish_tty_write_room(struct tty_struct *tty) |
| 129 | { |
| 130 | return 0x10000; |
| 131 | } |
| 132 | |
| 133 | static int goldfish_tty_chars_in_buffer(struct tty_struct *tty) |
| 134 | { |
| 135 | struct goldfish_tty *qtty = &goldfish_ttys[tty->index]; |
| 136 | void __iomem *base = qtty->base; |
Aleksandar Markovic | 2296eee | 2017-08-29 15:53:18 +0200 | [diff] [blame^] | 137 | return readl(base + GOLDFISH_TTY_REG_BYTES_READY); |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 138 | } |
| 139 | |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 140 | static void goldfish_tty_console_write(struct console *co, const char *b, |
| 141 | unsigned count) |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 142 | { |
| 143 | goldfish_tty_do_write(co->index, b, count); |
| 144 | } |
| 145 | |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 146 | static struct tty_driver *goldfish_tty_console_device(struct console *c, |
| 147 | int *index) |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 148 | { |
| 149 | *index = c->index; |
| 150 | return goldfish_tty_driver; |
| 151 | } |
| 152 | |
| 153 | static int goldfish_tty_console_setup(struct console *co, char *options) |
| 154 | { |
Dan Carpenter | fda2b41 | 2014-10-29 11:43:25 +0300 | [diff] [blame] | 155 | if ((unsigned)co->index >= goldfish_tty_line_count) |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 156 | return -ENODEV; |
Fabian Frederick | a4dc923 | 2014-09-28 20:10:17 +0200 | [diff] [blame] | 157 | if (!goldfish_ttys[co->index].base) |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 158 | return -ENODEV; |
| 159 | return 0; |
| 160 | } |
| 161 | |
Aya Mahfouz | 04b757d | 2015-12-15 01:53:36 +0200 | [diff] [blame] | 162 | static const struct tty_port_operations goldfish_port_ops = { |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 163 | .activate = goldfish_tty_activate, |
| 164 | .shutdown = goldfish_tty_shutdown |
| 165 | }; |
| 166 | |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 167 | static const struct tty_operations goldfish_tty_ops = { |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 168 | .open = goldfish_tty_open, |
| 169 | .close = goldfish_tty_close, |
| 170 | .hangup = goldfish_tty_hangup, |
| 171 | .write = goldfish_tty_write, |
| 172 | .write_room = goldfish_tty_write_room, |
| 173 | .chars_in_buffer = goldfish_tty_chars_in_buffer, |
| 174 | }; |
| 175 | |
| 176 | static int goldfish_tty_create_driver(void) |
| 177 | { |
| 178 | int ret; |
| 179 | struct tty_driver *tty; |
| 180 | |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 181 | goldfish_ttys = kzalloc(sizeof(*goldfish_ttys) * |
| 182 | goldfish_tty_line_count, GFP_KERNEL); |
| 183 | if (goldfish_ttys == NULL) { |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 184 | ret = -ENOMEM; |
| 185 | goto err_alloc_goldfish_ttys_failed; |
| 186 | } |
| 187 | tty = alloc_tty_driver(goldfish_tty_line_count); |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 188 | if (tty == NULL) { |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 189 | ret = -ENOMEM; |
| 190 | goto err_alloc_tty_driver_failed; |
| 191 | } |
| 192 | tty->driver_name = "goldfish"; |
| 193 | tty->name = "ttyGF"; |
| 194 | tty->type = TTY_DRIVER_TYPE_SERIAL; |
| 195 | tty->subtype = SERIAL_TYPE_NORMAL; |
| 196 | tty->init_termios = tty_std_termios; |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 197 | tty->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW | |
| 198 | TTY_DRIVER_DYNAMIC_DEV; |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 199 | tty_set_operations(tty, &goldfish_tty_ops); |
| 200 | ret = tty_register_driver(tty); |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 201 | if (ret) |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 202 | goto err_tty_register_driver_failed; |
| 203 | |
| 204 | goldfish_tty_driver = tty; |
| 205 | return 0; |
| 206 | |
| 207 | err_tty_register_driver_failed: |
| 208 | put_tty_driver(tty); |
| 209 | err_alloc_tty_driver_failed: |
| 210 | kfree(goldfish_ttys); |
| 211 | goldfish_ttys = NULL; |
| 212 | err_alloc_goldfish_ttys_failed: |
| 213 | return ret; |
| 214 | } |
| 215 | |
| 216 | static void goldfish_tty_delete_driver(void) |
| 217 | { |
| 218 | tty_unregister_driver(goldfish_tty_driver); |
| 219 | put_tty_driver(goldfish_tty_driver); |
| 220 | goldfish_tty_driver = NULL; |
| 221 | kfree(goldfish_ttys); |
| 222 | goldfish_ttys = NULL; |
| 223 | } |
| 224 | |
| 225 | static int goldfish_tty_probe(struct platform_device *pdev) |
| 226 | { |
| 227 | struct goldfish_tty *qtty; |
| 228 | int ret = -EINVAL; |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 229 | struct resource *r; |
| 230 | struct device *ttydev; |
| 231 | void __iomem *base; |
| 232 | u32 irq; |
Greg Hackmann | 465893e | 2016-02-26 19:01:05 +0000 | [diff] [blame] | 233 | unsigned int line; |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 234 | |
| 235 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 236 | if (r == NULL) |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 237 | return -EINVAL; |
| 238 | |
| 239 | base = ioremap(r->start, 0x1000); |
| 240 | if (base == NULL) |
| 241 | pr_err("goldfish_tty: unable to remap base\n"); |
| 242 | |
| 243 | r = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 244 | if (r == NULL) |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 245 | goto err_unmap; |
| 246 | |
| 247 | irq = r->start; |
| 248 | |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 249 | mutex_lock(&goldfish_tty_lock); |
Greg Hackmann | 465893e | 2016-02-26 19:01:05 +0000 | [diff] [blame] | 250 | |
| 251 | if (pdev->id == PLATFORM_DEVID_NONE) |
| 252 | line = goldfish_tty_current_line_count; |
| 253 | else |
| 254 | line = pdev->id; |
| 255 | |
| 256 | if (line >= goldfish_tty_line_count) |
| 257 | goto err_create_driver_failed; |
| 258 | |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 259 | if (goldfish_tty_current_line_count == 0) { |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 260 | ret = goldfish_tty_create_driver(); |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 261 | if (ret) |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 262 | goto err_create_driver_failed; |
| 263 | } |
| 264 | goldfish_tty_current_line_count++; |
| 265 | |
Greg Hackmann | 465893e | 2016-02-26 19:01:05 +0000 | [diff] [blame] | 266 | qtty = &goldfish_ttys[line]; |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 267 | spin_lock_init(&qtty->lock); |
| 268 | tty_port_init(&qtty->port); |
| 269 | qtty->port.ops = &goldfish_port_ops; |
| 270 | qtty->base = base; |
| 271 | qtty->irq = irq; |
| 272 | |
Aleksandar Markovic | 2296eee | 2017-08-29 15:53:18 +0200 | [diff] [blame^] | 273 | writel(GOLDFISH_TTY_CMD_INT_DISABLE, base + GOLDFISH_TTY_REG_CMD); |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 274 | |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 275 | ret = request_irq(irq, goldfish_tty_interrupt, IRQF_SHARED, |
Greg Hackmann | 465893e | 2016-02-26 19:01:05 +0000 | [diff] [blame] | 276 | "goldfish_tty", qtty); |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 277 | if (ret) |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 278 | goto err_request_irq_failed; |
| 279 | |
| 280 | |
| 281 | ttydev = tty_port_register_device(&qtty->port, goldfish_tty_driver, |
Greg Hackmann | 465893e | 2016-02-26 19:01:05 +0000 | [diff] [blame] | 282 | line, &pdev->dev); |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 283 | if (IS_ERR(ttydev)) { |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 284 | ret = PTR_ERR(ttydev); |
| 285 | goto err_tty_register_device_failed; |
| 286 | } |
| 287 | |
| 288 | strcpy(qtty->console.name, "ttyGF"); |
| 289 | qtty->console.write = goldfish_tty_console_write; |
| 290 | qtty->console.device = goldfish_tty_console_device; |
| 291 | qtty->console.setup = goldfish_tty_console_setup; |
| 292 | qtty->console.flags = CON_PRINTBUFFER; |
Greg Hackmann | 465893e | 2016-02-26 19:01:05 +0000 | [diff] [blame] | 293 | qtty->console.index = line; |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 294 | register_console(&qtty->console); |
Greg Hackmann | 465893e | 2016-02-26 19:01:05 +0000 | [diff] [blame] | 295 | platform_set_drvdata(pdev, qtty); |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 296 | |
| 297 | mutex_unlock(&goldfish_tty_lock); |
| 298 | return 0; |
| 299 | |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 300 | err_tty_register_device_failed: |
Christophe JAILLET | 1a5c2d1 | 2017-01-09 01:26:37 +0100 | [diff] [blame] | 301 | free_irq(irq, qtty); |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 302 | err_request_irq_failed: |
| 303 | goldfish_tty_current_line_count--; |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 304 | if (goldfish_tty_current_line_count == 0) |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 305 | goldfish_tty_delete_driver(); |
| 306 | err_create_driver_failed: |
| 307 | mutex_unlock(&goldfish_tty_lock); |
| 308 | err_unmap: |
| 309 | iounmap(base); |
| 310 | return ret; |
| 311 | } |
| 312 | |
| 313 | static int goldfish_tty_remove(struct platform_device *pdev) |
| 314 | { |
Greg Hackmann | 465893e | 2016-02-26 19:01:05 +0000 | [diff] [blame] | 315 | struct goldfish_tty *qtty = platform_get_drvdata(pdev); |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 316 | |
| 317 | mutex_lock(&goldfish_tty_lock); |
| 318 | |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 319 | unregister_console(&qtty->console); |
Greg Hackmann | 465893e | 2016-02-26 19:01:05 +0000 | [diff] [blame] | 320 | tty_unregister_device(goldfish_tty_driver, qtty->console.index); |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 321 | iounmap(qtty->base); |
Fabian Frederick | a4dc923 | 2014-09-28 20:10:17 +0200 | [diff] [blame] | 322 | qtty->base = NULL; |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 323 | free_irq(qtty->irq, pdev); |
| 324 | goldfish_tty_current_line_count--; |
Alan | d78055d | 2014-05-12 16:57:14 +0100 | [diff] [blame] | 325 | if (goldfish_tty_current_line_count == 0) |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 326 | goldfish_tty_delete_driver(); |
| 327 | mutex_unlock(&goldfish_tty_lock); |
| 328 | return 0; |
| 329 | } |
| 330 | |
Miodrag Dinic | 9b883ee | 2016-02-26 19:00:44 +0000 | [diff] [blame] | 331 | static const struct of_device_id goldfish_tty_of_match[] = { |
| 332 | { .compatible = "google,goldfish-tty", }, |
| 333 | {}, |
| 334 | }; |
| 335 | |
| 336 | MODULE_DEVICE_TABLE(of, goldfish_tty_of_match); |
| 337 | |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 338 | static struct platform_driver goldfish_tty_platform_driver = { |
| 339 | .probe = goldfish_tty_probe, |
| 340 | .remove = goldfish_tty_remove, |
| 341 | .driver = { |
Miodrag Dinic | 9b883ee | 2016-02-26 19:00:44 +0000 | [diff] [blame] | 342 | .name = "goldfish_tty", |
| 343 | .of_match_table = goldfish_tty_of_match, |
Arve Hjønnevåg | 666b779 | 2013-01-21 23:38:47 +0000 | [diff] [blame] | 344 | } |
| 345 | }; |
| 346 | |
| 347 | module_platform_driver(goldfish_tty_platform_driver); |
| 348 | |
| 349 | MODULE_LICENSE("GPL v2"); |