target/linux: extend r23881 for 2.6.37 too.
[openwrt.git] / target / linux / ubicom32 / files / drivers / video / ubicom32fb.c
1 /*
2 * drivers/video/ubicom32fb.c
3 * Ubicom32 frame buffer driver
4 *
5 * (C) Copyright 2009, Ubicom, Inc.
6 *
7 * This file is part of the Ubicom32 Linux Kernel Port.
8 *
9 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
10 * it and/or modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation, either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
15 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with the Ubicom32 Linux Kernel Port. If not,
21 * see <http://www.gnu.org/licenses/>.
22 *
23 * Ubicom32 implementation derived from (with many thanks):
24 * arch/m68knommu
25 * arch/blackfin
26 * arch/parisc
27 */
28
29 /*
30 * This driver was based on skeletonfb.c, Skeleton for a frame buffer device by
31 * Geert Uytterhoeven.
32 */
33
34 #include <linux/device.h>
35 #include <linux/module.h>
36 #include <linux/kernel.h>
37 #include <linux/version.h>
38 #include <linux/errno.h>
39 #include <linux/string.h>
40 #include <linux/mm.h>
41 #include <linux/fb.h>
42 #include <linux/init.h>
43 #include <linux/dma-mapping.h>
44 #include <linux/platform_device.h>
45 #include <linux/device.h>
46 #include <linux/uaccess.h>
47 #include <linux/interrupt.h>
48
49 #include <asm/io.h>
50 #include <asm/ip5000.h>
51 #include <asm/vdc_tio.h>
52 #include <asm/ubicom32fb.h>
53
54 #define DRIVER_NAME "ubicom32fb"
55 #define DRIVER_DESCRIPTION "Ubicom32 frame buffer driver"
56
57 #define PALETTE_ENTRIES_NO 16
58
59 /*
60 * Option variables
61 *
62 * vram_size: VRAM size in kilobytes, subject to alignment
63 */
64 static int vram_size = 0;
65 module_param(vram_size, int, 0);
66 MODULE_PARM_DESC(vram, "VRAM size, in kilobytes to allocate, should be at least the size of one screen, subject to alignment");
67 static int init_value = 0;
68 module_param(init_value, int, 0);
69 MODULE_PARM_DESC(init, "Initial value of the framebuffer (16-bit number).");
70
71 /*
72 * fb_fix_screeninfo defines the non-changeable properties of the VDC, depending on what mode it is in.
73 */
74 static struct fb_fix_screeninfo ubicom32fb_fix = {
75 .id = "Ubicom32",
76 .type = FB_TYPE_PACKED_PIXELS,
77 .visual = FB_VISUAL_TRUECOLOR,
78 .accel = FB_ACCEL_UBICOM32,
79 };
80
81 /*
82 * Filled in at probe time when we find out what the hardware supports
83 */
84 static struct fb_var_screeninfo ubicom32fb_var;
85
86 /*
87 * Private data structure
88 */
89 struct ubicom32fb_drvdata {
90 struct fb_info *fbinfo;
91 bool cmap_alloc;
92
93 /*
94 * The address of the framebuffer in memory
95 */
96 void *fb;
97 void *fb_aligned;
98
99 /*
100 * Total size of vram including alignment allowance
101 */
102 u32 total_vram_size;
103
104 /*
105 * Interrupt to set when changing registers
106 */
107 u32 vp_int;
108
109 /*
110 * Optional: Interrupt used by TIO to signal us
111 */
112 u32 rx_int;
113
114 /*
115 * Base address of the regs for VDC_TIO
116 */
117 volatile struct vdc_tio_vp_regs *regs;
118
119 /*
120 * non-zero if we are in yuv mode
121 */
122 u8_t is_yuv;
123
124 /*
125 * Fake palette of 16 colors
126 */
127 u32 pseudo_palette[PALETTE_ENTRIES_NO];
128
129 /*
130 * Wait queue and lock used to block when we need to wait
131 * for something to happen.
132 */
133 wait_queue_head_t waitq;
134 struct mutex lock;
135
136 };
137
138 /*
139 * ubicom32fb_set_next_frame
140 * Sets the next frame buffer to display
141 *
142 * if sync is TRUE then this function will block until the hardware
143 * acknowledges the change
144 */
145 static inline void ubicom32fb_set_next_frame(struct ubicom32fb_drvdata *ud, void *fb, u8_t sync)
146 {
147 ud->regs->next_frame_flags = ud->is_yuv ? VDCTIO_NEXT_FRAME_FLAG_YUV : 0;
148 ud->regs->next_frame = (void *)((u32_t)fb | 1);
149
150 /*
151 * If we have interrupts, then we can wait on it
152 */
153 if (ud->rx_int != -1) {
154 DEFINE_WAIT(wait);
155 unsigned long flags;
156
157 spin_lock_irqsave(&ud->lock, flags);
158 prepare_to_wait(&ud->waitq, &wait, TASK_INTERRUPTIBLE);
159 spin_unlock_irqrestore(&ud->lock, flags);
160 schedule();
161 finish_wait(&ud->waitq, &wait);
162 return;
163 }
164
165 /*
166 * No interrupt, we will just spin here
167 */
168 while (sync && ((u32_t)ud->regs->next_frame & 1));
169 }
170
171 /*
172 * ubicom32fb_send_command
173 * Sends a command/data pair to the VDC
174 */
175 static inline void ubicom32fb_send_command(struct ubicom32fb_drvdata *ud, u16 command, u8_t block)
176 {
177 ud->regs->command = command;
178 ubicom32_set_interrupt(ud->vp_int);
179 while (block && ud->regs->command);
180 }
181
182 /*
183 * ubicom32fb_ioctl
184 * Handles any ioctls sent to us
185 */
186 static int ubicom32fb_ioctl(struct fb_info *fbi, unsigned int cmd,
187 unsigned long arg)
188 {
189 struct ubicom32fb_drvdata *ud = (struct ubicom32fb_drvdata *)fbi->par;
190 void __user *argp = (void __user *)arg;
191 int retval = -EFAULT;
192
193 switch (cmd) {
194 case UBICOM32FB_IOCTL_SET_NEXT_FRAME_SYNC:
195 // check alignment, return -EINVAL if necessary
196 ubicom32fb_set_next_frame(ud, argp, 1);
197 retval = 0;
198 break;
199
200 case UBICOM32FB_IOCTL_SET_NEXT_FRAME:
201 // check alignment, return -EINVAL if necessary
202 ubicom32fb_set_next_frame(ud, argp, 0);
203 retval = 0;
204 break;
205
206 case UBICOM32FB_IOCTL_SET_MODE:
207 if (!(ud->regs->caps & VDCTIO_CAPS_SUPPORTS_SCALING)) {
208 break;
209 } else {
210 struct ubicom32fb_mode mode;
211 volatile struct vdc_tio_vp_regs *regs = ud->regs;
212 u32_t flags = 0;
213
214 if (copy_from_user(&mode, argp, sizeof(mode))) {
215 break;
216 }
217
218 regs->x_in = mode.width;
219 regs->y_in = mode.height;
220 regs->x_out = regs->xres;
221 regs->y_out = regs->yres;
222 if (mode.flags & UBICOM32FB_IOCTL_SET_MODE_FLAG_YUV_SCAN_ORDER) {
223 flags |= VDCTIO_SCALE_FLAG_YUV_SCAN_ORDER;
224 }
225 if (mode.flags & UBICOM32FB_IOCTL_SET_MODE_FLAG_YUV_BLOCK_ORDER) {
226 flags |= VDCTIO_SCALE_FLAG_YUV_BLOCK_ORDER;
227 }
228 ud->is_yuv = mode.flags & UBICOM32FB_IOCTL_SET_MODE_FLAG_YUV;
229 if (ud->is_yuv) {
230 flags |= VDCTIO_SCALE_FLAG_YUV;
231 }
232 if (mode.flags & UBICOM32FB_IOCTL_SET_MODE_FLAG_VRANGE_16_255) {
233 flags |= VDCTIO_SCALE_FLAG_VRANGE_16_255;
234 }
235 if (mode.flags & UBICOM32FB_IOCTL_SET_MODE_FLAG_VRANGE_0_255) {
236 flags |= VDCTIO_SCALE_FLAG_VRANGE_0_255;
237 }
238 if (mode.flags & UBICOM32FB_IOCTL_SET_MODE_FLAG_VSUB) {
239 flags |= VDCTIO_SCALE_FLAG_VSUB;
240 }
241 if (mode.flags & UBICOM32FB_IOCTL_SET_MODE_FLAG_HSUB_2_1) {
242 flags |= VDCTIO_SCALE_FLAG_HSUB_2_1;
243 }
244 if (mode.flags & UBICOM32FB_IOCTL_SET_MODE_FLAG_HSUB_1_1) {
245 flags |= VDCTIO_SCALE_FLAG_HSUB_1_1;
246 }
247 if (mode.flags & UBICOM32FB_IOCTL_SET_MODE_FLAG_SCALE_ENABLE) {
248 flags |= VDCTIO_SCALE_FLAG_ENABLE;
249 }
250 if (mode.next_frame) {
251 flags |= VDCTIO_SCALE_FLAG_SET_FRAME_BUFFER;
252 regs->next_frame = mode.next_frame;
253 }
254
255 regs->scale_flags = flags;
256 ubicom32fb_send_command(ud, VDCTIO_COMMAND_SET_SCALE_MODE, 1);
257 retval = 0;
258 break;
259 }
260
261 default:
262 retval = -ENOIOCTLCMD;
263 break;
264 }
265
266 return retval;
267 }
268
269 /*
270 * ubicom32fb_interrupt
271 * Called by the OS when the TIO has set the rx_int
272 */
273 static irqreturn_t ubicom32fb_interrupt(int vec, void *appdata)
274 {
275 struct ubicom32fb_drvdata *ud = (struct ubicom32fb_drvdata *)appdata;
276
277 spin_lock(&ud->lock);
278 if (waitqueue_active(&ud->waitq)) {
279 wake_up(&ud->waitq);
280 }
281 spin_unlock(&ud->lock);
282
283 return IRQ_HANDLED;
284 }
285
286 /*
287 * ubicom32fb_pan_display
288 * Pans the display to a given location. Supports only y direction panning.
289 */
290 static int ubicom32fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *fbi)
291 {
292 struct ubicom32fb_drvdata *ud = (struct ubicom32fb_drvdata *)fbi->par;
293 void *new_addr;
294
295 /*
296 * Get the last y line that would be displayed. Since we don't support YWRAP,
297 * it must be less than our virtual y size.
298 */
299 u32 lasty = var->yoffset + var->yres;
300 if (lasty > fbi->var.yres_virtual) {
301 /*
302 * We would fall off the end of our frame buffer if we panned here.
303 */
304 return -EINVAL;
305 }
306
307 if (var->xoffset) {
308 /*
309 * We don't support panning in the x direction
310 */
311 return -EINVAL;
312 }
313
314 /*
315 * Everything looks sane, go ahead and pan
316 *
317 * We have to calculate a new address for the VDC to look at
318 */
319 new_addr = ud->fb_aligned + (var->yoffset * fbi->fix.line_length);
320
321 /*
322 * Send down the command. The buffer will switch at the next vertical blank
323 */
324 ubicom32fb_set_next_frame(ud, (void *)new_addr, 0);
325
326 return 0;
327 }
328
329 /*
330 * ubicom32fb_setcolreg
331 * Sets a color in our virtual palette
332 */
333 static int ubicom32fb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *fbi)
334 {
335 u32 *palette = fbi->pseudo_palette;
336
337 if (regno >= PALETTE_ENTRIES_NO) {
338 return -EINVAL;
339 }
340
341 /*
342 * We only use 8 bits from each color
343 */
344 red >>= 8;
345 green >>= 8;
346 blue >>= 8;
347
348 /*
349 * Convert any grayscale values
350 */
351 if (fbi->var.grayscale) {
352 u16 gray = red + green + blue;
353 gray += (gray >> 2) + (gray >> 3) - (gray >> 7);
354 gray >>= 2;
355 if (gray > 255) {
356 gray = 255;
357 }
358 red = gray;
359 blue = gray;
360 green = gray;
361 }
362
363 palette[regno] = (red << fbi->var.red.offset) | (green << fbi->var.green.offset) |
364 (blue << fbi->var.blue.offset);
365
366 return 0;
367 }
368
369 /*
370 * ubicom32fb_mmap
371 */
372 static int ubicom32fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
373 {
374 struct ubicom32fb_drvdata *drvdata = (struct ubicom32fb_drvdata *)info->par;
375
376 vma->vm_start = (unsigned long)(drvdata->fb_aligned);
377
378 vma->vm_end = vma->vm_start + info->fix.smem_len;
379
380 /* For those who don't understand how mmap works, go read
381 * Documentation/nommu-mmap.txt.
382 * For those that do, you will know that the VM_MAYSHARE flag
383 * must be set in the vma->vm_flags structure on noMMU
384 * Other flags can be set, and are documented in
385 * include/linux/mm.h
386 */
387
388 vma->vm_flags |= VM_MAYSHARE | VM_SHARED;
389
390 return 0;
391 }
392
393 /*
394 * ubicom32fb_blank
395 */
396 static int ubicom32fb_blank(int blank_mode, struct fb_info *fbi)
397 {
398 return 0;
399 #if 0
400 struct ubicom32fb_drvdata *drvdata = to_ubicom32fb_drvdata(fbi);
401
402 switch (blank_mode) {
403 case FB_BLANK_UNBLANK:
404 /* turn on panel */
405 ubicom32fb_out_be32(drvdata, REG_CTRL, drvdata->reg_ctrl_default);
406 break;
407
408 case FB_BLANK_NORMAL:
409 case FB_BLANK_VSYNC_SUSPEND:
410 case FB_BLANK_HSYNC_SUSPEND:
411 case FB_BLANK_POWERDOWN:
412 /* turn off panel */
413 ubicom32fb_out_be32(drvdata, REG_CTRL, 0);
414 default:
415 break;
416
417 }
418 return 0; /* success */
419 #endif
420 }
421
422 static struct fb_ops ubicom32fb_ops =
423 {
424 .owner = THIS_MODULE,
425 .fb_pan_display = ubicom32fb_pan_display,
426 .fb_setcolreg = ubicom32fb_setcolreg,
427 .fb_blank = ubicom32fb_blank,
428 .fb_mmap = ubicom32fb_mmap,
429 .fb_ioctl = ubicom32fb_ioctl,
430 .fb_fillrect = cfb_fillrect,
431 .fb_copyarea = cfb_copyarea,
432 .fb_imageblit = cfb_imageblit,
433 };
434
435 /*
436 * ubicom32fb_release
437 */
438 static int ubicom32fb_release(struct device *dev)
439 {
440 struct ubicom32fb_drvdata *ud = dev_get_drvdata(dev);
441
442 #if !defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_LOGO)
443 //ubicom32fb_blank(VESA_POWERDOWN, &drvdata->info);
444 #endif
445
446 unregister_framebuffer(ud->fbinfo);
447
448 if (ud->cmap_alloc) {
449 fb_dealloc_cmap(&ud->fbinfo->cmap);
450 }
451
452 if (ud->fb) {
453 kfree(ud->fb);
454 }
455
456 if (ud->rx_int != -1) {
457 free_irq(ud->rx_int, ud);
458 }
459
460 /*
461 * Turn off the display
462 */
463 //ubicom32fb_out_be32(drvdata, REG_CTRL, 0);
464 //iounmap(drvdata->regs);
465
466 framebuffer_release(ud->fbinfo);
467 dev_set_drvdata(dev, NULL);
468
469 return 0;
470 }
471
472 /*
473 * ubicom32fb_platform_probe
474 */
475 static int __init ubicom32fb_platform_probe(struct platform_device *pdev)
476 {
477 struct ubicom32fb_drvdata *ud;
478 struct resource *irq_resource_rx;
479 struct resource *irq_resource_tx;
480 struct resource *mem_resource;
481 struct fb_info *fbinfo;
482 int rc;
483 size_t fbsize;
484 struct device *dev = &pdev->dev;
485 int offset;
486 struct vdc_tio_vp_regs *regs;
487
488 /*
489 * Get our resources
490 */
491 irq_resource_tx = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
492 if (!irq_resource_tx) {
493 dev_err(dev, "No tx IRQ resource assigned\n");
494 return -ENODEV;
495 }
496
497 irq_resource_rx = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
498 if (!irq_resource_rx) {
499 dev_err(dev, "No rx IRQ resource assigned\n");
500 return -ENODEV;
501 }
502
503 mem_resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
504 if (!mem_resource || !mem_resource->start) {
505 dev_err(dev, "No mem resource assigned\n");
506 return -ENODEV;
507 }
508 regs = (struct vdc_tio_vp_regs *)mem_resource->start;
509 if (regs->version != VDCTIO_VP_VERSION) {
510 dev_err(dev, "VDCTIO is not compatible with this driver tio:%x drv:%x\n",
511 regs->version, VDCTIO_VP_VERSION);
512 return -ENODEV;
513 }
514
515 /*
516 * This is the minimum VRAM size
517 */
518 fbsize = regs->xres * regs->yres * (regs->bpp / 8);
519 if (!vram_size) {
520 vram_size = (fbsize + 1023) / 1024;
521 } else {
522 if (fbsize > (vram_size * 1024)) {
523 dev_err(dev, "Not enough VRAM for display, need >= %u bytes\n", fbsize);
524 return -ENOMEM; // should be ebadparam?
525 }
526 }
527
528 /*
529 * Allocate the framebuffer instance + our private data
530 */
531 fbinfo = framebuffer_alloc(sizeof(struct ubicom32fb_drvdata), &pdev->dev);
532 if (!fbinfo) {
533 dev_err(dev, "Not enough memory to allocate instance.\n");
534 return -ENOMEM;
535 }
536
537 /*
538 * Fill in our private data.
539 */
540 ud = (struct ubicom32fb_drvdata *)fbinfo->par;
541 ud->fbinfo = fbinfo;
542 ud->regs = (struct vdc_tio_vp_regs *)(mem_resource->start);
543 dev_set_drvdata(dev, ud);
544
545 ud->vp_int = irq_resource_tx->start;
546
547 /*
548 * If we were provided an rx_irq then we need to init the appropriate
549 * queues, locks, and functions.
550 */
551 ud->rx_int = -1;
552 if (irq_resource_rx->start != DEVTREE_IRQ_NONE) {
553 init_waitqueue_head(&ud->waitq);
554 mutex_init(&ud->lock);
555 if (request_irq(ud->rx_int, ubicom32fb_interrupt, IRQF_SHARED, "ubicom32fb_rx", ud)) {
556 dev_err(dev, "Couldn't request rx IRQ\n");
557 rc = -ENOMEM;
558 goto fail;
559 }
560 ud->rx_int = irq_resource_rx->start;
561 }
562
563 /*
564 * Allocate and align the requested amount of VRAM
565 */
566 ud->total_vram_size = (vram_size * 1024) + regs->fb_align;
567 ud->fb = kmalloc(ud->total_vram_size, GFP_KERNEL);
568 if (ud->fb == NULL) {
569 dev_err(dev, "Couldn't allocate VRAM\n");
570 rc = -ENOMEM;
571 goto fail;
572 }
573
574 offset = (u32_t)ud->fb & (regs->fb_align - 1);
575 if (!offset) {
576 ud->fb_aligned = ud->fb;
577 } else {
578 offset = regs->fb_align - offset;
579 ud->fb_aligned = ud->fb + offset;
580 }
581
582 /*
583 * Clear the entire frame buffer
584 */
585 if (!init_value) {
586 memset(ud->fb_aligned, 0, vram_size * 1024);
587 } else {
588 unsigned short *p = ud->fb_aligned;
589 int i;
590 for (i = 0; i < ((vram_size * 1024) / sizeof(u16_t)); i++) {
591 *p++ = init_value;
592 }
593 }
594
595 /*
596 * Fill in the fb_var_screeninfo structure
597 */
598 memset(&ubicom32fb_var, 0, sizeof(ubicom32fb_var));
599 ubicom32fb_var.bits_per_pixel = regs->bpp;
600 ubicom32fb_var.red.offset = regs->rshift;
601 ubicom32fb_var.green.offset = regs->gshift;
602 ubicom32fb_var.blue.offset = regs->bshift;
603 ubicom32fb_var.red.length = regs->rbits;
604 ubicom32fb_var.green.length = regs->gbits;
605 ubicom32fb_var.blue.length = regs->bbits;
606 ubicom32fb_var.activate = FB_ACTIVATE_NOW;
607
608 #if 0
609 /*
610 * Turn on the display
611 */
612 ud->reg_ctrl_default = REG_CTRL_ENABLE;
613 if (regs->rotate_screen)
614 ud->reg_ctrl_default |= REG_CTRL_ROTATE;
615 ubicom32fb_out_be32(ud, REG_CTRL, ud->reg_ctrl_default);
616 #endif
617
618 /*
619 * Fill in the fb_info structure
620 */
621 ud->fbinfo->device = dev;
622 ud->fbinfo->screen_base = (void *)ud->fb_aligned;
623 ud->fbinfo->fbops = &ubicom32fb_ops;
624 ud->fbinfo->fix = ubicom32fb_fix;
625 ud->fbinfo->fix.smem_start = (u32)ud->fb_aligned;
626 ud->fbinfo->fix.smem_len = vram_size * 1024;
627 ud->fbinfo->fix.line_length = regs->xres * (regs->bpp / 8);
628 ud->fbinfo->fix.mmio_start = (u32)regs;
629 ud->fbinfo->fix.mmio_len = sizeof(struct vdc_tio_vp_regs);
630
631 /*
632 * We support panning in the y direction only
633 */
634 ud->fbinfo->fix.xpanstep = 0;
635 ud->fbinfo->fix.ypanstep = 1;
636
637 ud->fbinfo->pseudo_palette = ud->pseudo_palette;
638 ud->fbinfo->flags = FBINFO_DEFAULT;
639 ud->fbinfo->var = ubicom32fb_var;
640 ud->fbinfo->var.xres = regs->xres;
641 ud->fbinfo->var.yres = regs->yres;
642
643 /*
644 * We cannot pan in the X direction, so xres_virtual is regs->xres
645 * We can pan in the Y direction, so yres_virtual is vram_size / ud->fbinfo->fix.line_length
646 */
647 ud->fbinfo->var.xres_virtual = regs->xres;
648 ud->fbinfo->var.yres_virtual = (vram_size * 1024) / ud->fbinfo->fix.line_length;
649
650 //ud->fbinfo->var.height = regs->height_mm;
651 //ud->fbinfo->var.width = regs->width_mm;
652
653 /*
654 * Allocate a color map
655 */
656 rc = fb_alloc_cmap(&ud->fbinfo->cmap, PALETTE_ENTRIES_NO, 0);
657 if (rc) {
658 dev_err(dev, "Fail to allocate colormap (%d entries)\n",
659 PALETTE_ENTRIES_NO);
660 goto fail;
661 }
662 ud->cmap_alloc = true;
663
664 /*
665 * Register new frame buffer
666 */
667 rc = register_framebuffer(ud->fbinfo);
668 if (rc) {
669 dev_err(dev, "Could not register frame buffer\n");
670 goto fail;
671 }
672
673 /*
674 * Start up the VDC
675 */
676 ud->regs->next_frame = ud->fb;
677 ubicom32fb_send_command(ud, VDCTIO_COMMAND_START, 0);
678
679 /*
680 * Tell the log we are here
681 */
682 dev_info(dev, "fbaddr=%p align=%p, size=%uKB screen(%ux%u) virt(%ux%u), regs=%p irqtx=%u irqrx=%u\n",
683 ud->fb, ud->fb_aligned, vram_size, ud->fbinfo->var.xres, ud->fbinfo->var.yres,
684 ud->fbinfo->var.xres_virtual, ud->fbinfo->var.yres_virtual, ud->regs,
685 irq_resource_tx->start, irq_resource_rx->start);
686
687 /*
688 * Success
689 */
690 return 0;
691
692 fail:
693 ubicom32fb_release(dev);
694 return rc;
695 }
696
697 /*
698 * ubicom32fb_platform_remove
699 */
700 static int ubicom32fb_platform_remove(struct platform_device *pdev)
701 {
702 dev_info(&(pdev->dev), "Ubicom32 FB Driver Remove\n");
703 return ubicom32fb_release(&pdev->dev);
704 }
705
706 static struct platform_driver ubicom32fb_platform_driver = {
707 .probe = ubicom32fb_platform_probe,
708 .remove = ubicom32fb_platform_remove,
709 .driver = {
710 .name = DRIVER_NAME,
711 .owner = THIS_MODULE,
712 },
713 };
714
715 #ifndef MODULE
716 /*
717 * ubicom32fb_setup
718 * Process kernel boot options
719 */
720 static int __init ubicom32fb_setup(char *options)
721 {
722 char *this_opt;
723
724 if (!options || !*options) {
725 return 0;
726 }
727
728 while ((this_opt = strsep(&options, ",")) != NULL) {
729 if (!*this_opt) {
730 continue;
731 }
732
733 if (!strncmp(this_opt, "init_value=", 10)) {
734 init_value = simple_strtoul(this_opt + 11, NULL, 0);
735 continue;
736 }
737
738 if (!strncmp(this_opt, "vram_size=", 10)) {
739 vram_size = simple_strtoul(this_opt + 10, NULL, 0);
740 continue;
741 }
742 }
743 return 0;
744 }
745 #endif /* MODULE */
746
747 /*
748 * ubicom32fb_init
749 */
750 static int __devinit ubicom32fb_init(void)
751 {
752 #ifndef MODULE
753 /*
754 * Get kernel boot options (in 'video=ubicom32fb:<options>')
755 */
756 char *option = NULL;
757
758 if (fb_get_options(DRIVER_NAME, &option)) {
759 return -ENODEV;
760 }
761 ubicom32fb_setup(option);
762 #endif /* MODULE */
763
764 return platform_driver_register(&ubicom32fb_platform_driver);
765 }
766 module_init(ubicom32fb_init);
767
768 /*
769 * ubicom32fb_exit
770 */
771 static void __exit ubicom32fb_exit(void)
772 {
773 platform_driver_unregister(&ubicom32fb_platform_driver);
774 }
775 module_exit(ubicom32fb_exit);
776
777 MODULE_LICENSE("GPL");
778 MODULE_AUTHOR("Patrick Tjin <@ubicom.com>");
779 MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
This page took 0.094788 seconds and 5 git commands to generate.