Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Common code for AUO-K190X framebuffer drivers |
| 3 | * |
| 4 | * Copyright (C) 2012 Heiko Stuebner <heiko@sntech.de> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/module.h> |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/gpio.h> |
Greg Kroah-Hartman | 16559ae | 2013-02-04 15:35:26 -0800 | [diff] [blame] | 14 | #include <linux/platform_device.h> |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 15 | #include <linux/pm_runtime.h> |
| 16 | #include <linux/fb.h> |
| 17 | #include <linux/delay.h> |
| 18 | #include <linux/uaccess.h> |
| 19 | #include <linux/vmalloc.h> |
| 20 | #include <linux/regulator/consumer.h> |
| 21 | |
| 22 | #include <video/auo_k190xfb.h> |
| 23 | |
| 24 | #include "auo_k190x.h" |
| 25 | |
| 26 | struct panel_info { |
| 27 | int w; |
| 28 | int h; |
| 29 | }; |
| 30 | |
| 31 | /* table of panel specific parameters to be indexed into by the board drivers */ |
| 32 | static struct panel_info panel_table[] = { |
| 33 | /* standard 6" */ |
| 34 | [AUOK190X_RESOLUTION_800_600] = { |
| 35 | .w = 800, |
| 36 | .h = 600, |
| 37 | }, |
| 38 | /* standard 9" */ |
| 39 | [AUOK190X_RESOLUTION_1024_768] = { |
| 40 | .w = 1024, |
| 41 | .h = 768, |
| 42 | }, |
| 43 | }; |
| 44 | |
| 45 | /* |
| 46 | * private I80 interface to the board driver |
| 47 | */ |
| 48 | |
| 49 | static void auok190x_issue_data(struct auok190xfb_par *par, u16 data) |
| 50 | { |
| 51 | par->board->set_ctl(par, AUOK190X_I80_WR, 0); |
| 52 | par->board->set_hdb(par, data); |
| 53 | par->board->set_ctl(par, AUOK190X_I80_WR, 1); |
| 54 | } |
| 55 | |
| 56 | static void auok190x_issue_cmd(struct auok190xfb_par *par, u16 data) |
| 57 | { |
| 58 | par->board->set_ctl(par, AUOK190X_I80_DC, 0); |
| 59 | auok190x_issue_data(par, data); |
| 60 | par->board->set_ctl(par, AUOK190X_I80_DC, 1); |
| 61 | } |
| 62 | |
Heiko Stübner | 76de404b | 2013-03-22 15:15:55 +0100 | [diff] [blame^] | 63 | static int auok190x_issue_pixels_gray8(struct auok190xfb_par *par, int size, |
| 64 | u16 *data) |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 65 | { |
| 66 | struct device *dev = par->info->device; |
| 67 | int i; |
| 68 | u16 tmp; |
| 69 | |
| 70 | if (size & 3) { |
| 71 | dev_err(dev, "issue_pixels: size %d must be a multiple of 4\n", |
| 72 | size); |
| 73 | return -EINVAL; |
| 74 | } |
| 75 | |
| 76 | for (i = 0; i < (size >> 1); i++) { |
| 77 | par->board->set_ctl(par, AUOK190X_I80_WR, 0); |
| 78 | |
| 79 | /* simple reduction of 8bit staticgray to 4bit gray |
| 80 | * combines 4 * 4bit pixel values into a 16bit value |
| 81 | */ |
| 82 | tmp = (data[2*i] & 0xF0) >> 4; |
| 83 | tmp |= (data[2*i] & 0xF000) >> 8; |
| 84 | tmp |= (data[2*i+1] & 0xF0) << 4; |
| 85 | tmp |= (data[2*i+1] & 0xF000); |
| 86 | |
| 87 | par->board->set_hdb(par, tmp); |
| 88 | par->board->set_ctl(par, AUOK190X_I80_WR, 1); |
| 89 | } |
| 90 | |
| 91 | return 0; |
| 92 | } |
| 93 | |
Heiko Stübner | 76de404b | 2013-03-22 15:15:55 +0100 | [diff] [blame^] | 94 | static int auok190x_issue_pixels(struct auok190xfb_par *par, int size, |
| 95 | u16 *data) |
| 96 | { |
| 97 | struct fb_info *info = par->info; |
| 98 | struct device *dev = par->info->device; |
| 99 | |
| 100 | if (info->var.bits_per_pixel == 8 && info->var.grayscale) |
| 101 | auok190x_issue_pixels_gray8(par, size, data); |
| 102 | else |
| 103 | dev_err(dev, "unsupported color mode (bits: %d, gray: %d)\n", |
| 104 | info->var.bits_per_pixel, info->var.grayscale); |
| 105 | |
| 106 | return 0; |
| 107 | } |
| 108 | |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 109 | static u16 auok190x_read_data(struct auok190xfb_par *par) |
| 110 | { |
| 111 | u16 data; |
| 112 | |
| 113 | par->board->set_ctl(par, AUOK190X_I80_OE, 0); |
| 114 | data = par->board->get_hdb(par); |
| 115 | par->board->set_ctl(par, AUOK190X_I80_OE, 1); |
| 116 | |
| 117 | return data; |
| 118 | } |
| 119 | |
| 120 | /* |
| 121 | * Command interface for the controller drivers |
| 122 | */ |
| 123 | |
| 124 | void auok190x_send_command_nowait(struct auok190xfb_par *par, u16 data) |
| 125 | { |
| 126 | par->board->set_ctl(par, AUOK190X_I80_CS, 0); |
| 127 | auok190x_issue_cmd(par, data); |
| 128 | par->board->set_ctl(par, AUOK190X_I80_CS, 1); |
| 129 | } |
| 130 | EXPORT_SYMBOL_GPL(auok190x_send_command_nowait); |
| 131 | |
| 132 | void auok190x_send_cmdargs_nowait(struct auok190xfb_par *par, u16 cmd, |
| 133 | int argc, u16 *argv) |
| 134 | { |
| 135 | int i; |
| 136 | |
| 137 | par->board->set_ctl(par, AUOK190X_I80_CS, 0); |
| 138 | auok190x_issue_cmd(par, cmd); |
| 139 | |
| 140 | for (i = 0; i < argc; i++) |
| 141 | auok190x_issue_data(par, argv[i]); |
| 142 | par->board->set_ctl(par, AUOK190X_I80_CS, 1); |
| 143 | } |
| 144 | EXPORT_SYMBOL_GPL(auok190x_send_cmdargs_nowait); |
| 145 | |
| 146 | int auok190x_send_command(struct auok190xfb_par *par, u16 data) |
| 147 | { |
| 148 | int ret; |
| 149 | |
| 150 | ret = par->board->wait_for_rdy(par); |
| 151 | if (ret) |
| 152 | return ret; |
| 153 | |
| 154 | auok190x_send_command_nowait(par, data); |
| 155 | return 0; |
| 156 | } |
| 157 | EXPORT_SYMBOL_GPL(auok190x_send_command); |
| 158 | |
| 159 | int auok190x_send_cmdargs(struct auok190xfb_par *par, u16 cmd, |
| 160 | int argc, u16 *argv) |
| 161 | { |
| 162 | int ret; |
| 163 | |
| 164 | ret = par->board->wait_for_rdy(par); |
| 165 | if (ret) |
| 166 | return ret; |
| 167 | |
| 168 | auok190x_send_cmdargs_nowait(par, cmd, argc, argv); |
| 169 | return 0; |
| 170 | } |
| 171 | EXPORT_SYMBOL_GPL(auok190x_send_cmdargs); |
| 172 | |
| 173 | int auok190x_read_cmdargs(struct auok190xfb_par *par, u16 cmd, |
| 174 | int argc, u16 *argv) |
| 175 | { |
| 176 | int i, ret; |
| 177 | |
| 178 | ret = par->board->wait_for_rdy(par); |
| 179 | if (ret) |
| 180 | return ret; |
| 181 | |
| 182 | par->board->set_ctl(par, AUOK190X_I80_CS, 0); |
| 183 | auok190x_issue_cmd(par, cmd); |
| 184 | |
| 185 | for (i = 0; i < argc; i++) |
| 186 | argv[i] = auok190x_read_data(par); |
| 187 | par->board->set_ctl(par, AUOK190X_I80_CS, 1); |
| 188 | |
| 189 | return 0; |
| 190 | } |
| 191 | EXPORT_SYMBOL_GPL(auok190x_read_cmdargs); |
| 192 | |
| 193 | void auok190x_send_cmdargs_pixels_nowait(struct auok190xfb_par *par, u16 cmd, |
| 194 | int argc, u16 *argv, int size, u16 *data) |
| 195 | { |
| 196 | int i; |
| 197 | |
| 198 | par->board->set_ctl(par, AUOK190X_I80_CS, 0); |
| 199 | |
| 200 | auok190x_issue_cmd(par, cmd); |
| 201 | |
| 202 | for (i = 0; i < argc; i++) |
| 203 | auok190x_issue_data(par, argv[i]); |
| 204 | |
| 205 | auok190x_issue_pixels(par, size, data); |
| 206 | |
| 207 | par->board->set_ctl(par, AUOK190X_I80_CS, 1); |
| 208 | } |
| 209 | EXPORT_SYMBOL_GPL(auok190x_send_cmdargs_pixels_nowait); |
| 210 | |
| 211 | int auok190x_send_cmdargs_pixels(struct auok190xfb_par *par, u16 cmd, |
| 212 | int argc, u16 *argv, int size, u16 *data) |
| 213 | { |
| 214 | int ret; |
| 215 | |
| 216 | ret = par->board->wait_for_rdy(par); |
| 217 | if (ret) |
| 218 | return ret; |
| 219 | |
| 220 | auok190x_send_cmdargs_pixels_nowait(par, cmd, argc, argv, size, data); |
| 221 | |
| 222 | return 0; |
| 223 | } |
| 224 | EXPORT_SYMBOL_GPL(auok190x_send_cmdargs_pixels); |
| 225 | |
| 226 | /* |
| 227 | * fbdefio callbacks - common on both controllers. |
| 228 | */ |
| 229 | |
| 230 | static void auok190xfb_dpy_first_io(struct fb_info *info) |
| 231 | { |
| 232 | /* tell runtime-pm that we wish to use the device in a short time */ |
| 233 | pm_runtime_get(info->device); |
| 234 | } |
| 235 | |
| 236 | /* this is called back from the deferred io workqueue */ |
| 237 | static void auok190xfb_dpy_deferred_io(struct fb_info *info, |
| 238 | struct list_head *pagelist) |
| 239 | { |
| 240 | struct fb_deferred_io *fbdefio = info->fbdefio; |
| 241 | struct auok190xfb_par *par = info->par; |
Heiko Stübner | a165510 | 2013-03-22 15:13:02 +0100 | [diff] [blame] | 242 | u16 line_length = info->fix.line_length; |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 243 | u16 yres = info->var.yres; |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 244 | u16 y1 = 0, h = 0; |
| 245 | int prev_index = -1; |
| 246 | struct page *cur; |
| 247 | int h_inc; |
| 248 | int threshold; |
| 249 | |
| 250 | if (!list_empty(pagelist)) |
| 251 | /* the device resume should've been requested through first_io, |
| 252 | * if the resume did not finish until now, wait for it. |
| 253 | */ |
| 254 | pm_runtime_barrier(info->device); |
| 255 | else |
| 256 | /* We reached this via the fsync or some other way. |
| 257 | * In either case the first_io function did not run, |
| 258 | * so we runtime_resume the device here synchronously. |
| 259 | */ |
| 260 | pm_runtime_get_sync(info->device); |
| 261 | |
| 262 | /* Do a full screen update every n updates to prevent |
| 263 | * excessive darkening of the Sipix display. |
| 264 | * If we do this, there is no need to walk the pages. |
| 265 | */ |
| 266 | if (par->need_refresh(par)) { |
| 267 | par->update_all(par); |
| 268 | goto out; |
| 269 | } |
| 270 | |
| 271 | /* height increment is fixed per page */ |
Heiko Stübner | a165510 | 2013-03-22 15:13:02 +0100 | [diff] [blame] | 272 | h_inc = DIV_ROUND_UP(PAGE_SIZE , line_length); |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 273 | |
| 274 | /* calculate number of pages from pixel height */ |
| 275 | threshold = par->consecutive_threshold / h_inc; |
| 276 | if (threshold < 1) |
| 277 | threshold = 1; |
| 278 | |
| 279 | /* walk the written page list and swizzle the data */ |
| 280 | list_for_each_entry(cur, &fbdefio->pagelist, lru) { |
| 281 | if (prev_index < 0) { |
| 282 | /* just starting so assign first page */ |
Heiko Stübner | a165510 | 2013-03-22 15:13:02 +0100 | [diff] [blame] | 283 | y1 = (cur->index << PAGE_SHIFT) / line_length; |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 284 | h = h_inc; |
| 285 | } else if ((cur->index - prev_index) <= threshold) { |
| 286 | /* page is within our threshold for single updates */ |
| 287 | h += h_inc * (cur->index - prev_index); |
| 288 | } else { |
| 289 | /* page not consecutive, issue previous update first */ |
| 290 | par->update_partial(par, y1, y1 + h); |
| 291 | |
| 292 | /* start over with our non consecutive page */ |
Heiko Stübner | a165510 | 2013-03-22 15:13:02 +0100 | [diff] [blame] | 293 | y1 = (cur->index << PAGE_SHIFT) / line_length; |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 294 | h = h_inc; |
| 295 | } |
| 296 | prev_index = cur->index; |
| 297 | } |
| 298 | |
| 299 | /* if we still have any pages to update we do so now */ |
| 300 | if (h >= yres) |
| 301 | /* its a full screen update, just do it */ |
| 302 | par->update_all(par); |
| 303 | else |
| 304 | par->update_partial(par, y1, min((u16) (y1 + h), yres)); |
| 305 | |
| 306 | out: |
| 307 | pm_runtime_mark_last_busy(info->device); |
| 308 | pm_runtime_put_autosuspend(info->device); |
| 309 | } |
| 310 | |
| 311 | /* |
| 312 | * framebuffer operations |
| 313 | */ |
| 314 | |
| 315 | /* |
| 316 | * this is the slow path from userspace. they can seek and write to |
| 317 | * the fb. it's inefficient to do anything less than a full screen draw |
| 318 | */ |
| 319 | static ssize_t auok190xfb_write(struct fb_info *info, const char __user *buf, |
| 320 | size_t count, loff_t *ppos) |
| 321 | { |
| 322 | struct auok190xfb_par *par = info->par; |
| 323 | unsigned long p = *ppos; |
| 324 | void *dst; |
| 325 | int err = 0; |
| 326 | unsigned long total_size; |
| 327 | |
| 328 | if (info->state != FBINFO_STATE_RUNNING) |
| 329 | return -EPERM; |
| 330 | |
| 331 | total_size = info->fix.smem_len; |
| 332 | |
| 333 | if (p > total_size) |
| 334 | return -EFBIG; |
| 335 | |
| 336 | if (count > total_size) { |
| 337 | err = -EFBIG; |
| 338 | count = total_size; |
| 339 | } |
| 340 | |
| 341 | if (count + p > total_size) { |
| 342 | if (!err) |
| 343 | err = -ENOSPC; |
| 344 | |
| 345 | count = total_size - p; |
| 346 | } |
| 347 | |
| 348 | dst = (void *)(info->screen_base + p); |
| 349 | |
| 350 | if (copy_from_user(dst, buf, count)) |
| 351 | err = -EFAULT; |
| 352 | |
| 353 | if (!err) |
| 354 | *ppos += count; |
| 355 | |
| 356 | par->update_all(par); |
| 357 | |
| 358 | return (err) ? err : count; |
| 359 | } |
| 360 | |
| 361 | static void auok190xfb_fillrect(struct fb_info *info, |
| 362 | const struct fb_fillrect *rect) |
| 363 | { |
| 364 | struct auok190xfb_par *par = info->par; |
| 365 | |
| 366 | sys_fillrect(info, rect); |
| 367 | |
| 368 | par->update_all(par); |
| 369 | } |
| 370 | |
| 371 | static void auok190xfb_copyarea(struct fb_info *info, |
| 372 | const struct fb_copyarea *area) |
| 373 | { |
| 374 | struct auok190xfb_par *par = info->par; |
| 375 | |
| 376 | sys_copyarea(info, area); |
| 377 | |
| 378 | par->update_all(par); |
| 379 | } |
| 380 | |
| 381 | static void auok190xfb_imageblit(struct fb_info *info, |
| 382 | const struct fb_image *image) |
| 383 | { |
| 384 | struct auok190xfb_par *par = info->par; |
| 385 | |
| 386 | sys_imageblit(info, image); |
| 387 | |
| 388 | par->update_all(par); |
| 389 | } |
| 390 | |
| 391 | static int auok190xfb_check_var(struct fb_var_screeninfo *var, |
| 392 | struct fb_info *info) |
| 393 | { |
Heiko Stübner | 03fc149 | 2013-03-22 15:14:52 +0100 | [diff] [blame] | 394 | struct device *dev = info->device; |
Heiko Stübner | 4ea80d3 | 2013-03-22 15:15:27 +0100 | [diff] [blame] | 395 | struct auok190xfb_par *par = info->par; |
| 396 | struct panel_info *panel = &panel_table[par->resolution]; |
Heiko Stübner | 03fc149 | 2013-03-22 15:14:52 +0100 | [diff] [blame] | 397 | int size; |
| 398 | |
Heiko Stübner | 4ea80d3 | 2013-03-22 15:15:27 +0100 | [diff] [blame] | 399 | /* |
Heiko Stübner | 76de404b | 2013-03-22 15:15:55 +0100 | [diff] [blame^] | 400 | * Color depth |
| 401 | */ |
| 402 | |
| 403 | if (var->bits_per_pixel == 8 && var->grayscale == 1) { |
| 404 | /* |
| 405 | * For 8-bit grayscale, R, G, and B offset are equal. |
| 406 | */ |
| 407 | var->red.length = 8; |
| 408 | var->red.offset = 0; |
| 409 | var->red.msb_right = 0; |
| 410 | |
| 411 | var->green.length = 8; |
| 412 | var->green.offset = 0; |
| 413 | var->green.msb_right = 0; |
| 414 | |
| 415 | var->blue.length = 8; |
| 416 | var->blue.offset = 0; |
| 417 | var->blue.msb_right = 0; |
| 418 | |
| 419 | var->transp.length = 0; |
| 420 | var->transp.offset = 0; |
| 421 | var->transp.msb_right = 0; |
| 422 | } else { |
| 423 | dev_warn(dev, "unsupported color mode (bits: %d, grayscale: %d)\n", |
| 424 | info->var.bits_per_pixel, info->var.grayscale); |
| 425 | return -EINVAL; |
| 426 | } |
| 427 | |
| 428 | /* |
Heiko Stübner | 4ea80d3 | 2013-03-22 15:15:27 +0100 | [diff] [blame] | 429 | * Dimensions |
| 430 | */ |
| 431 | |
| 432 | if (par->rotation & 1) { |
| 433 | var->xres = panel->h; |
| 434 | var->yres = panel->w; |
| 435 | } else { |
| 436 | var->xres = panel->w; |
| 437 | var->yres = panel->h; |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 438 | } |
| 439 | |
Heiko Stübner | 4ea80d3 | 2013-03-22 15:15:27 +0100 | [diff] [blame] | 440 | var->xres_virtual = var->xres; |
| 441 | var->yres_virtual = var->yres; |
| 442 | |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 443 | /* |
| 444 | * Memory limit |
| 445 | */ |
| 446 | |
Heiko Stübner | 03fc149 | 2013-03-22 15:14:52 +0100 | [diff] [blame] | 447 | size = var->xres_virtual * var->yres_virtual * var->bits_per_pixel / 8; |
| 448 | if (size > info->fix.smem_len) { |
| 449 | dev_err(dev, "Memory limit exceeded, requested %dK\n", |
| 450 | size >> 10); |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 451 | return -ENOMEM; |
| 452 | } |
| 453 | |
| 454 | return 0; |
| 455 | } |
| 456 | |
Heiko Stübner | 76de404b | 2013-03-22 15:15:55 +0100 | [diff] [blame^] | 457 | static int auok190xfb_set_fix(struct fb_info *info) |
| 458 | { |
| 459 | struct fb_fix_screeninfo *fix = &info->fix; |
| 460 | struct fb_var_screeninfo *var = &info->var; |
| 461 | |
| 462 | fix->line_length = var->xres_virtual * var->bits_per_pixel / 8; |
| 463 | |
| 464 | fix->type = FB_TYPE_PACKED_PIXELS; |
| 465 | fix->accel = FB_ACCEL_NONE; |
| 466 | fix->visual = (var->grayscale) ? FB_VISUAL_STATIC_PSEUDOCOLOR |
| 467 | : FB_VISUAL_TRUECOLOR; |
| 468 | fix->xpanstep = 0; |
| 469 | fix->ypanstep = 0; |
| 470 | fix->ywrapstep = 0; |
| 471 | |
| 472 | return 0; |
| 473 | } |
| 474 | |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 475 | static struct fb_ops auok190xfb_ops = { |
| 476 | .owner = THIS_MODULE, |
| 477 | .fb_read = fb_sys_read, |
| 478 | .fb_write = auok190xfb_write, |
| 479 | .fb_fillrect = auok190xfb_fillrect, |
| 480 | .fb_copyarea = auok190xfb_copyarea, |
| 481 | .fb_imageblit = auok190xfb_imageblit, |
| 482 | .fb_check_var = auok190xfb_check_var, |
| 483 | }; |
| 484 | |
| 485 | /* |
| 486 | * Controller-functions common to both K1900 and K1901 |
| 487 | */ |
| 488 | |
| 489 | static int auok190x_read_temperature(struct auok190xfb_par *par) |
| 490 | { |
| 491 | struct device *dev = par->info->device; |
| 492 | u16 data[4]; |
| 493 | int temp; |
| 494 | |
| 495 | pm_runtime_get_sync(dev); |
| 496 | |
| 497 | mutex_lock(&(par->io_lock)); |
| 498 | |
| 499 | auok190x_read_cmdargs(par, AUOK190X_CMD_READ_VERSION, 4, data); |
| 500 | |
| 501 | mutex_unlock(&(par->io_lock)); |
| 502 | |
| 503 | pm_runtime_mark_last_busy(dev); |
| 504 | pm_runtime_put_autosuspend(dev); |
| 505 | |
| 506 | /* sanitize and split of half-degrees for now */ |
| 507 | temp = ((data[0] & AUOK190X_VERSION_TEMP_MASK) >> 1); |
| 508 | |
| 509 | /* handle positive and negative temperatures */ |
| 510 | if (temp >= 201) |
| 511 | return (255 - temp + 1) * (-1); |
| 512 | else |
| 513 | return temp; |
| 514 | } |
| 515 | |
| 516 | static void auok190x_identify(struct auok190xfb_par *par) |
| 517 | { |
| 518 | struct device *dev = par->info->device; |
| 519 | u16 data[4]; |
| 520 | |
| 521 | pm_runtime_get_sync(dev); |
| 522 | |
| 523 | mutex_lock(&(par->io_lock)); |
| 524 | |
| 525 | auok190x_read_cmdargs(par, AUOK190X_CMD_READ_VERSION, 4, data); |
| 526 | |
| 527 | mutex_unlock(&(par->io_lock)); |
| 528 | |
| 529 | par->epd_type = data[1] & AUOK190X_VERSION_TEMP_MASK; |
| 530 | |
| 531 | par->panel_size_int = AUOK190X_VERSION_SIZE_INT(data[2]); |
| 532 | par->panel_size_float = AUOK190X_VERSION_SIZE_FLOAT(data[2]); |
| 533 | par->panel_model = AUOK190X_VERSION_MODEL(data[2]); |
| 534 | |
| 535 | par->tcon_version = AUOK190X_VERSION_TCON(data[3]); |
| 536 | par->lut_version = AUOK190X_VERSION_LUT(data[3]); |
| 537 | |
| 538 | dev_dbg(dev, "panel %d.%din, model 0x%x, EPD 0x%x TCON-rev 0x%x, LUT-rev 0x%x", |
| 539 | par->panel_size_int, par->panel_size_float, par->panel_model, |
| 540 | par->epd_type, par->tcon_version, par->lut_version); |
| 541 | |
| 542 | pm_runtime_mark_last_busy(dev); |
| 543 | pm_runtime_put_autosuspend(dev); |
| 544 | } |
| 545 | |
| 546 | /* |
| 547 | * Sysfs functions |
| 548 | */ |
| 549 | |
| 550 | static ssize_t update_mode_show(struct device *dev, |
| 551 | struct device_attribute *attr, char *buf) |
| 552 | { |
| 553 | struct fb_info *info = dev_get_drvdata(dev); |
| 554 | struct auok190xfb_par *par = info->par; |
| 555 | |
| 556 | return sprintf(buf, "%d\n", par->update_mode); |
| 557 | } |
| 558 | |
| 559 | static ssize_t update_mode_store(struct device *dev, |
| 560 | struct device_attribute *attr, |
| 561 | const char *buf, size_t count) |
| 562 | { |
| 563 | struct fb_info *info = dev_get_drvdata(dev); |
| 564 | struct auok190xfb_par *par = info->par; |
| 565 | int mode, ret; |
| 566 | |
| 567 | ret = kstrtoint(buf, 10, &mode); |
| 568 | if (ret) |
| 569 | return ret; |
| 570 | |
| 571 | par->update_mode = mode; |
| 572 | |
| 573 | /* if we enter a better mode, do a full update */ |
| 574 | if (par->last_mode > 1 && mode < par->last_mode) |
| 575 | par->update_all(par); |
| 576 | |
| 577 | return count; |
| 578 | } |
| 579 | |
| 580 | static ssize_t flash_show(struct device *dev, struct device_attribute *attr, |
| 581 | char *buf) |
| 582 | { |
| 583 | struct fb_info *info = dev_get_drvdata(dev); |
| 584 | struct auok190xfb_par *par = info->par; |
| 585 | |
| 586 | return sprintf(buf, "%d\n", par->flash); |
| 587 | } |
| 588 | |
| 589 | static ssize_t flash_store(struct device *dev, struct device_attribute *attr, |
| 590 | const char *buf, size_t count) |
| 591 | { |
| 592 | struct fb_info *info = dev_get_drvdata(dev); |
| 593 | struct auok190xfb_par *par = info->par; |
| 594 | int flash, ret; |
| 595 | |
| 596 | ret = kstrtoint(buf, 10, &flash); |
| 597 | if (ret) |
| 598 | return ret; |
| 599 | |
| 600 | if (flash > 0) |
| 601 | par->flash = 1; |
| 602 | else |
| 603 | par->flash = 0; |
| 604 | |
| 605 | return count; |
| 606 | } |
| 607 | |
| 608 | static ssize_t temp_show(struct device *dev, struct device_attribute *attr, |
| 609 | char *buf) |
| 610 | { |
| 611 | struct fb_info *info = dev_get_drvdata(dev); |
| 612 | struct auok190xfb_par *par = info->par; |
| 613 | int temp; |
| 614 | |
| 615 | temp = auok190x_read_temperature(par); |
| 616 | return sprintf(buf, "%d\n", temp); |
| 617 | } |
| 618 | |
| 619 | static DEVICE_ATTR(update_mode, 0644, update_mode_show, update_mode_store); |
| 620 | static DEVICE_ATTR(flash, 0644, flash_show, flash_store); |
| 621 | static DEVICE_ATTR(temp, 0644, temp_show, NULL); |
| 622 | |
| 623 | static struct attribute *auok190x_attributes[] = { |
| 624 | &dev_attr_update_mode.attr, |
| 625 | &dev_attr_flash.attr, |
| 626 | &dev_attr_temp.attr, |
| 627 | NULL |
| 628 | }; |
| 629 | |
| 630 | static const struct attribute_group auok190x_attr_group = { |
| 631 | .attrs = auok190x_attributes, |
| 632 | }; |
| 633 | |
| 634 | static int auok190x_power(struct auok190xfb_par *par, bool on) |
| 635 | { |
| 636 | struct auok190x_board *board = par->board; |
| 637 | int ret; |
| 638 | |
| 639 | if (on) { |
| 640 | /* We should maintain POWER up for at least 80ms before set |
| 641 | * RST_N and SLP_N to high (TCON spec 20100803_v35 p59) |
| 642 | */ |
| 643 | ret = regulator_enable(par->regulator); |
| 644 | if (ret) |
| 645 | return ret; |
| 646 | |
| 647 | msleep(200); |
| 648 | gpio_set_value(board->gpio_nrst, 1); |
| 649 | gpio_set_value(board->gpio_nsleep, 1); |
| 650 | msleep(200); |
| 651 | } else { |
| 652 | regulator_disable(par->regulator); |
| 653 | gpio_set_value(board->gpio_nrst, 0); |
| 654 | gpio_set_value(board->gpio_nsleep, 0); |
| 655 | } |
| 656 | |
| 657 | return 0; |
| 658 | } |
| 659 | |
| 660 | /* |
| 661 | * Recovery - powercycle the controller |
| 662 | */ |
| 663 | |
| 664 | static void auok190x_recover(struct auok190xfb_par *par) |
| 665 | { |
Heiko Stübner | 4e0ab85 | 2013-03-22 15:14:22 +0100 | [diff] [blame] | 666 | struct device *dev = par->info->device; |
| 667 | |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 668 | auok190x_power(par, 0); |
| 669 | msleep(100); |
| 670 | auok190x_power(par, 1); |
| 671 | |
Heiko Stübner | 4e0ab85 | 2013-03-22 15:14:22 +0100 | [diff] [blame] | 672 | /* after powercycling the device, it's always active */ |
| 673 | pm_runtime_set_active(dev); |
| 674 | par->standby = 0; |
| 675 | |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 676 | par->init(par); |
| 677 | |
| 678 | /* wait for init to complete */ |
| 679 | par->board->wait_for_rdy(par); |
| 680 | } |
| 681 | |
| 682 | /* |
| 683 | * Power-management |
| 684 | */ |
| 685 | |
| 686 | #ifdef CONFIG_PM |
| 687 | static int auok190x_runtime_suspend(struct device *dev) |
| 688 | { |
| 689 | struct platform_device *pdev = to_platform_device(dev); |
| 690 | struct fb_info *info = platform_get_drvdata(pdev); |
| 691 | struct auok190xfb_par *par = info->par; |
| 692 | struct auok190x_board *board = par->board; |
| 693 | u16 standby_param; |
| 694 | |
| 695 | /* take and keep the lock until we are resumed, as the controller |
| 696 | * will never reach the non-busy state when in standby mode |
| 697 | */ |
| 698 | mutex_lock(&(par->io_lock)); |
| 699 | |
| 700 | if (par->standby) { |
| 701 | dev_warn(dev, "already in standby, runtime-pm pairing mismatch\n"); |
| 702 | mutex_unlock(&(par->io_lock)); |
| 703 | return 0; |
| 704 | } |
| 705 | |
| 706 | /* according to runtime_pm.txt runtime_suspend only means, that the |
| 707 | * device will not process data and will not communicate with the CPU |
| 708 | * As we hold the lock, this stays true even without standby |
| 709 | */ |
| 710 | if (board->quirks & AUOK190X_QUIRK_STANDBYBROKEN) { |
| 711 | dev_dbg(dev, "runtime suspend without standby\n"); |
| 712 | goto finish; |
| 713 | } else if (board->quirks & AUOK190X_QUIRK_STANDBYPARAM) { |
| 714 | /* for some TCON versions STANDBY expects a parameter (0) but |
| 715 | * it seems the real tcon version has to be determined yet. |
| 716 | */ |
| 717 | dev_dbg(dev, "runtime suspend with additional empty param\n"); |
| 718 | standby_param = 0; |
| 719 | auok190x_send_cmdargs(par, AUOK190X_CMD_STANDBY, 1, |
| 720 | &standby_param); |
| 721 | } else { |
| 722 | dev_dbg(dev, "runtime suspend without param\n"); |
| 723 | auok190x_send_command(par, AUOK190X_CMD_STANDBY); |
| 724 | } |
| 725 | |
| 726 | msleep(64); |
| 727 | |
| 728 | finish: |
| 729 | par->standby = 1; |
| 730 | |
| 731 | return 0; |
| 732 | } |
| 733 | |
| 734 | static int auok190x_runtime_resume(struct device *dev) |
| 735 | { |
| 736 | struct platform_device *pdev = to_platform_device(dev); |
| 737 | struct fb_info *info = platform_get_drvdata(pdev); |
| 738 | struct auok190xfb_par *par = info->par; |
| 739 | struct auok190x_board *board = par->board; |
| 740 | |
| 741 | if (!par->standby) { |
| 742 | dev_warn(dev, "not in standby, runtime-pm pairing mismatch\n"); |
| 743 | return 0; |
| 744 | } |
| 745 | |
| 746 | if (board->quirks & AUOK190X_QUIRK_STANDBYBROKEN) { |
| 747 | dev_dbg(dev, "runtime resume without standby\n"); |
| 748 | } else { |
| 749 | /* when in standby, controller is always busy |
| 750 | * and only accepts the wakeup command |
| 751 | */ |
| 752 | dev_dbg(dev, "runtime resume from standby\n"); |
| 753 | auok190x_send_command_nowait(par, AUOK190X_CMD_WAKEUP); |
| 754 | |
| 755 | msleep(160); |
| 756 | |
| 757 | /* wait for the controller to be ready and release the lock */ |
| 758 | board->wait_for_rdy(par); |
| 759 | } |
| 760 | |
| 761 | par->standby = 0; |
| 762 | |
| 763 | mutex_unlock(&(par->io_lock)); |
| 764 | |
| 765 | return 0; |
| 766 | } |
| 767 | |
| 768 | static int auok190x_suspend(struct device *dev) |
| 769 | { |
| 770 | struct platform_device *pdev = to_platform_device(dev); |
| 771 | struct fb_info *info = platform_get_drvdata(pdev); |
| 772 | struct auok190xfb_par *par = info->par; |
| 773 | struct auok190x_board *board = par->board; |
| 774 | int ret; |
| 775 | |
| 776 | dev_dbg(dev, "suspend\n"); |
| 777 | if (board->quirks & AUOK190X_QUIRK_STANDBYBROKEN) { |
| 778 | /* suspend via powering off the ic */ |
| 779 | dev_dbg(dev, "suspend with broken standby\n"); |
| 780 | |
| 781 | auok190x_power(par, 0); |
| 782 | } else { |
| 783 | dev_dbg(dev, "suspend using sleep\n"); |
| 784 | |
| 785 | /* the sleep state can only be entered from the standby state. |
| 786 | * pm_runtime_get_noresume gets called before the suspend call. |
| 787 | * So the devices usage count is >0 but it is not necessarily |
| 788 | * active. |
| 789 | */ |
| 790 | if (!pm_runtime_status_suspended(dev)) { |
| 791 | ret = auok190x_runtime_suspend(dev); |
| 792 | if (ret < 0) { |
| 793 | dev_err(dev, "auok190x_runtime_suspend failed with %d\n", |
| 794 | ret); |
| 795 | return ret; |
| 796 | } |
| 797 | par->manual_standby = 1; |
| 798 | } |
| 799 | |
| 800 | gpio_direction_output(board->gpio_nsleep, 0); |
| 801 | } |
| 802 | |
| 803 | msleep(100); |
| 804 | |
| 805 | return 0; |
| 806 | } |
| 807 | |
| 808 | static int auok190x_resume(struct device *dev) |
| 809 | { |
| 810 | struct platform_device *pdev = to_platform_device(dev); |
| 811 | struct fb_info *info = platform_get_drvdata(pdev); |
| 812 | struct auok190xfb_par *par = info->par; |
| 813 | struct auok190x_board *board = par->board; |
| 814 | |
| 815 | dev_dbg(dev, "resume\n"); |
| 816 | if (board->quirks & AUOK190X_QUIRK_STANDBYBROKEN) { |
| 817 | dev_dbg(dev, "resume with broken standby\n"); |
| 818 | |
| 819 | auok190x_power(par, 1); |
| 820 | |
| 821 | par->init(par); |
| 822 | } else { |
| 823 | dev_dbg(dev, "resume from sleep\n"); |
| 824 | |
| 825 | /* device should be in runtime suspend when we were suspended |
| 826 | * and pm_runtime_put_sync gets called after this function. |
| 827 | * So there is no need to touch the standby mode here at all. |
| 828 | */ |
| 829 | gpio_direction_output(board->gpio_nsleep, 1); |
| 830 | msleep(100); |
| 831 | |
| 832 | /* an additional init call seems to be necessary after sleep */ |
| 833 | auok190x_runtime_resume(dev); |
| 834 | par->init(par); |
| 835 | |
| 836 | /* if we were runtime-suspended before, suspend again*/ |
| 837 | if (!par->manual_standby) |
| 838 | auok190x_runtime_suspend(dev); |
| 839 | else |
| 840 | par->manual_standby = 0; |
| 841 | } |
| 842 | |
| 843 | return 0; |
| 844 | } |
| 845 | #endif |
| 846 | |
| 847 | const struct dev_pm_ops auok190x_pm = { |
| 848 | SET_RUNTIME_PM_OPS(auok190x_runtime_suspend, auok190x_runtime_resume, |
| 849 | NULL) |
| 850 | SET_SYSTEM_SLEEP_PM_OPS(auok190x_suspend, auok190x_resume) |
| 851 | }; |
| 852 | EXPORT_SYMBOL_GPL(auok190x_pm); |
| 853 | |
| 854 | /* |
| 855 | * Common probe and remove code |
| 856 | */ |
| 857 | |
Greg Kroah-Hartman | 48c68c4 | 2012-12-21 13:07:39 -0800 | [diff] [blame] | 858 | int auok190x_common_probe(struct platform_device *pdev, |
| 859 | struct auok190x_init_data *init) |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 860 | { |
| 861 | struct auok190x_board *board = init->board; |
| 862 | struct auok190xfb_par *par; |
| 863 | struct fb_info *info; |
| 864 | struct panel_info *panel; |
| 865 | int videomemorysize, ret; |
| 866 | unsigned char *videomemory; |
| 867 | |
| 868 | /* check board contents */ |
| 869 | if (!board->init || !board->cleanup || !board->wait_for_rdy |
| 870 | || !board->set_ctl || !board->set_hdb || !board->get_hdb |
| 871 | || !board->setup_irq) |
| 872 | return -EINVAL; |
| 873 | |
| 874 | info = framebuffer_alloc(sizeof(struct auok190xfb_par), &pdev->dev); |
| 875 | if (!info) |
| 876 | return -ENOMEM; |
| 877 | |
| 878 | par = info->par; |
| 879 | par->info = info; |
| 880 | par->board = board; |
| 881 | par->recover = auok190x_recover; |
| 882 | par->update_partial = init->update_partial; |
| 883 | par->update_all = init->update_all; |
| 884 | par->need_refresh = init->need_refresh; |
| 885 | par->init = init->init; |
| 886 | |
| 887 | /* init update modes */ |
| 888 | par->update_cnt = 0; |
| 889 | par->update_mode = -1; |
| 890 | par->last_mode = -1; |
| 891 | par->flash = 0; |
| 892 | |
| 893 | par->regulator = regulator_get(info->device, "vdd"); |
| 894 | if (IS_ERR(par->regulator)) { |
| 895 | ret = PTR_ERR(par->regulator); |
| 896 | dev_err(info->device, "Failed to get regulator: %d\n", ret); |
| 897 | goto err_reg; |
| 898 | } |
| 899 | |
| 900 | ret = board->init(par); |
| 901 | if (ret) { |
| 902 | dev_err(info->device, "board init failed, %d\n", ret); |
| 903 | goto err_board; |
| 904 | } |
| 905 | |
| 906 | ret = gpio_request(board->gpio_nsleep, "AUOK190x sleep"); |
| 907 | if (ret) { |
| 908 | dev_err(info->device, "could not request sleep gpio, %d\n", |
| 909 | ret); |
| 910 | goto err_gpio1; |
| 911 | } |
| 912 | |
| 913 | ret = gpio_direction_output(board->gpio_nsleep, 0); |
| 914 | if (ret) { |
| 915 | dev_err(info->device, "could not set sleep gpio, %d\n", ret); |
| 916 | goto err_gpio2; |
| 917 | } |
| 918 | |
| 919 | ret = gpio_request(board->gpio_nrst, "AUOK190x reset"); |
| 920 | if (ret) { |
| 921 | dev_err(info->device, "could not request reset gpio, %d\n", |
| 922 | ret); |
| 923 | goto err_gpio2; |
| 924 | } |
| 925 | |
| 926 | ret = gpio_direction_output(board->gpio_nrst, 0); |
| 927 | if (ret) { |
| 928 | dev_err(info->device, "could not set reset gpio, %d\n", ret); |
| 929 | goto err_gpio3; |
| 930 | } |
| 931 | |
| 932 | ret = auok190x_power(par, 1); |
| 933 | if (ret) { |
| 934 | dev_err(info->device, "could not power on the device, %d\n", |
| 935 | ret); |
| 936 | goto err_gpio3; |
| 937 | } |
| 938 | |
| 939 | mutex_init(&par->io_lock); |
| 940 | |
| 941 | init_waitqueue_head(&par->waitq); |
| 942 | |
| 943 | ret = par->board->setup_irq(par->info); |
| 944 | if (ret) { |
| 945 | dev_err(info->device, "could not setup ready-irq, %d\n", ret); |
| 946 | goto err_irq; |
| 947 | } |
| 948 | |
| 949 | /* wait for init to complete */ |
| 950 | par->board->wait_for_rdy(par); |
| 951 | |
| 952 | /* |
| 953 | * From here on the controller can talk to us |
| 954 | */ |
| 955 | |
| 956 | /* initialise fix, var, resolution and rotation */ |
| 957 | |
| 958 | strlcpy(info->fix.id, init->id, 16); |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 959 | info->var.bits_per_pixel = 8; |
| 960 | info->var.grayscale = 1; |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 961 | |
| 962 | panel = &panel_table[board->resolution]; |
| 963 | |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 964 | par->resolution = board->resolution; |
| 965 | par->rotation = board->rotation; |
| 966 | |
| 967 | /* videomemory handling */ |
| 968 | |
Heiko Stübner | a165510 | 2013-03-22 15:13:02 +0100 | [diff] [blame] | 969 | videomemorysize = roundup((panel->w * panel->h) * |
| 970 | info->var.bits_per_pixel / 8, PAGE_SIZE); |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 971 | videomemory = vmalloc(videomemorysize); |
| 972 | if (!videomemory) { |
| 973 | ret = -ENOMEM; |
| 974 | goto err_irq; |
| 975 | } |
| 976 | |
| 977 | memset(videomemory, 0, videomemorysize); |
| 978 | info->screen_base = (char *)videomemory; |
| 979 | info->fix.smem_len = videomemorysize; |
| 980 | |
| 981 | info->flags = FBINFO_FLAG_DEFAULT | FBINFO_VIRTFB; |
| 982 | info->fbops = &auok190xfb_ops; |
| 983 | |
Heiko Stübner | 4ea80d3 | 2013-03-22 15:15:27 +0100 | [diff] [blame] | 984 | ret = auok190xfb_check_var(&info->var, info); |
| 985 | if (ret) |
| 986 | goto err_defio; |
| 987 | |
Heiko Stübner | 76de404b | 2013-03-22 15:15:55 +0100 | [diff] [blame^] | 988 | auok190xfb_set_fix(info); |
Heiko Stübner | 4ea80d3 | 2013-03-22 15:15:27 +0100 | [diff] [blame] | 989 | |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 990 | /* deferred io init */ |
| 991 | |
| 992 | info->fbdefio = devm_kzalloc(info->device, |
| 993 | sizeof(struct fb_deferred_io), |
| 994 | GFP_KERNEL); |
| 995 | if (!info->fbdefio) { |
| 996 | dev_err(info->device, "Failed to allocate memory\n"); |
| 997 | ret = -ENOMEM; |
| 998 | goto err_defio; |
| 999 | } |
| 1000 | |
| 1001 | dev_dbg(info->device, "targetting %d frames per second\n", board->fps); |
| 1002 | info->fbdefio->delay = HZ / board->fps; |
| 1003 | info->fbdefio->first_io = auok190xfb_dpy_first_io, |
| 1004 | info->fbdefio->deferred_io = auok190xfb_dpy_deferred_io, |
| 1005 | fb_deferred_io_init(info); |
| 1006 | |
| 1007 | /* color map */ |
| 1008 | |
| 1009 | ret = fb_alloc_cmap(&info->cmap, 256, 0); |
| 1010 | if (ret < 0) { |
| 1011 | dev_err(info->device, "Failed to allocate colormap\n"); |
| 1012 | goto err_cmap; |
| 1013 | } |
| 1014 | |
| 1015 | /* controller init */ |
| 1016 | |
| 1017 | par->consecutive_threshold = 100; |
| 1018 | par->init(par); |
| 1019 | auok190x_identify(par); |
| 1020 | |
| 1021 | platform_set_drvdata(pdev, info); |
| 1022 | |
| 1023 | ret = register_framebuffer(info); |
| 1024 | if (ret < 0) |
| 1025 | goto err_regfb; |
| 1026 | |
| 1027 | ret = sysfs_create_group(&info->device->kobj, &auok190x_attr_group); |
| 1028 | if (ret) |
| 1029 | goto err_sysfs; |
| 1030 | |
| 1031 | dev_info(info->device, "fb%d: %dx%d using %dK of video memory\n", |
| 1032 | info->node, info->var.xres, info->var.yres, |
| 1033 | videomemorysize >> 10); |
| 1034 | |
| 1035 | /* increase autosuspend_delay when we use alternative methods |
| 1036 | * for runtime_pm |
| 1037 | */ |
| 1038 | par->autosuspend_delay = (board->quirks & AUOK190X_QUIRK_STANDBYBROKEN) |
| 1039 | ? 1000 : 200; |
| 1040 | |
| 1041 | pm_runtime_set_active(info->device); |
| 1042 | pm_runtime_enable(info->device); |
| 1043 | pm_runtime_set_autosuspend_delay(info->device, par->autosuspend_delay); |
| 1044 | pm_runtime_use_autosuspend(info->device); |
| 1045 | |
| 1046 | return 0; |
| 1047 | |
| 1048 | err_sysfs: |
| 1049 | unregister_framebuffer(info); |
| 1050 | err_regfb: |
| 1051 | fb_dealloc_cmap(&info->cmap); |
| 1052 | err_cmap: |
| 1053 | fb_deferred_io_cleanup(info); |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 1054 | err_defio: |
| 1055 | vfree((void *)info->screen_base); |
| 1056 | err_irq: |
| 1057 | auok190x_power(par, 0); |
| 1058 | err_gpio3: |
| 1059 | gpio_free(board->gpio_nrst); |
| 1060 | err_gpio2: |
| 1061 | gpio_free(board->gpio_nsleep); |
| 1062 | err_gpio1: |
| 1063 | board->cleanup(par); |
| 1064 | err_board: |
| 1065 | regulator_put(par->regulator); |
| 1066 | err_reg: |
| 1067 | framebuffer_release(info); |
| 1068 | |
| 1069 | return ret; |
| 1070 | } |
| 1071 | EXPORT_SYMBOL_GPL(auok190x_common_probe); |
| 1072 | |
Greg Kroah-Hartman | 48c68c4 | 2012-12-21 13:07:39 -0800 | [diff] [blame] | 1073 | int auok190x_common_remove(struct platform_device *pdev) |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 1074 | { |
| 1075 | struct fb_info *info = platform_get_drvdata(pdev); |
| 1076 | struct auok190xfb_par *par = info->par; |
| 1077 | struct auok190x_board *board = par->board; |
| 1078 | |
| 1079 | pm_runtime_disable(info->device); |
| 1080 | |
| 1081 | sysfs_remove_group(&info->device->kobj, &auok190x_attr_group); |
| 1082 | |
| 1083 | unregister_framebuffer(info); |
| 1084 | |
| 1085 | fb_dealloc_cmap(&info->cmap); |
| 1086 | |
| 1087 | fb_deferred_io_cleanup(info); |
Heiko Stübner | 2c8304d | 2012-04-28 12:20:00 +0200 | [diff] [blame] | 1088 | |
| 1089 | vfree((void *)info->screen_base); |
| 1090 | |
| 1091 | auok190x_power(par, 0); |
| 1092 | |
| 1093 | gpio_free(board->gpio_nrst); |
| 1094 | gpio_free(board->gpio_nsleep); |
| 1095 | |
| 1096 | board->cleanup(par); |
| 1097 | |
| 1098 | regulator_put(par->regulator); |
| 1099 | |
| 1100 | framebuffer_release(info); |
| 1101 | |
| 1102 | return 0; |
| 1103 | } |
| 1104 | EXPORT_SYMBOL_GPL(auok190x_common_remove); |
| 1105 | |
| 1106 | MODULE_DESCRIPTION("Common code for AUO-K190X controllers"); |
| 1107 | MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>"); |
| 1108 | MODULE_LICENSE("GPL"); |