2 * Filename: cfag12864bfb.c
4 * Description: cfag12864b LCD framebuffer driver
8 * Author: Copyright (C) Miguel Ojeda Sandonis
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/init.h>
27 #include <linux/module.h>
28 #include <linux/kernel.h>
29 #include <linux/delay.h>
30 #include <linux/errno.h>
33 #include <linux/platform_device.h>
34 #include <linux/string.h>
35 #include <linux/uaccess.h>
36 #include <linux/cfag12864b.h>
38 #define CFAG12864BFB_NAME "cfag12864bfb"
40 static struct fb_fix_screeninfo cfag12864bfb_fix
= {
42 .type
= FB_TYPE_PACKED_PIXELS
,
43 .visual
= FB_VISUAL_MONO10
,
47 .line_length
= CFAG12864B_WIDTH
/ 8,
48 .accel
= FB_ACCEL_NONE
,
51 static struct fb_var_screeninfo cfag12864bfb_var
= {
52 .xres
= CFAG12864B_WIDTH
,
53 .yres
= CFAG12864B_HEIGHT
,
54 .xres_virtual
= CFAG12864B_WIDTH
,
55 .yres_virtual
= CFAG12864B_HEIGHT
,
64 .vmode
= FB_VMODE_NONINTERLACED
,
67 static int cfag12864bfb_mmap(struct fb_info
*info
, struct vm_area_struct
*vma
)
69 return vm_insert_page(vma
, vma
->vm_start
,
70 virt_to_page(cfag12864b_buffer
));
73 static struct fb_ops cfag12864bfb_ops
= {
75 .fb_read
= fb_sys_read
,
76 .fb_write
= fb_sys_write
,
77 .fb_fillrect
= sys_fillrect
,
78 .fb_copyarea
= sys_copyarea
,
79 .fb_imageblit
= sys_imageblit
,
80 .fb_mmap
= cfag12864bfb_mmap
,
83 static int cfag12864bfb_probe(struct platform_device
*device
)
86 struct fb_info
*info
= framebuffer_alloc(0, &device
->dev
);
91 info
->screen_base
= (char __iomem
*) cfag12864b_buffer
;
92 info
->screen_size
= CFAG12864B_SIZE
;
93 info
->fbops
= &cfag12864bfb_ops
;
94 info
->fix
= cfag12864bfb_fix
;
95 info
->var
= cfag12864bfb_var
;
96 info
->pseudo_palette
= NULL
;
98 info
->flags
= FBINFO_FLAG_DEFAULT
;
100 if (register_framebuffer(info
) < 0)
103 platform_set_drvdata(device
, info
);
105 printk(KERN_INFO
"fb%d: %s frame buffer device\n", info
->node
,
111 framebuffer_release(info
);
117 static int cfag12864bfb_remove(struct platform_device
*device
)
119 struct fb_info
*info
= platform_get_drvdata(device
);
122 unregister_framebuffer(info
);
123 framebuffer_release(info
);
129 static struct platform_driver cfag12864bfb_driver
= {
130 .probe
= cfag12864bfb_probe
,
131 .remove
= cfag12864bfb_remove
,
133 .name
= CFAG12864BFB_NAME
,
137 static struct platform_device
*cfag12864bfb_device
;
139 static int __init
cfag12864bfb_init(void)
143 /* cfag12864b_init() must be called first */
144 if (!cfag12864b_isinited()) {
145 printk(KERN_ERR CFAG12864BFB_NAME
": ERROR: "
146 "cfag12864b is not initialized\n");
150 if (cfag12864b_enable()) {
151 printk(KERN_ERR CFAG12864BFB_NAME
": ERROR: "
152 "can't enable cfag12864b refreshing (being used)\n");
156 ret
= platform_driver_register(&cfag12864bfb_driver
);
159 cfag12864bfb_device
=
160 platform_device_alloc(CFAG12864BFB_NAME
, 0);
162 if (cfag12864bfb_device
)
163 ret
= platform_device_add(cfag12864bfb_device
);
168 platform_device_put(cfag12864bfb_device
);
169 platform_driver_unregister(&cfag12864bfb_driver
);
177 static void __exit
cfag12864bfb_exit(void)
179 platform_device_unregister(cfag12864bfb_device
);
180 platform_driver_unregister(&cfag12864bfb_driver
);
181 cfag12864b_disable();
184 module_init(cfag12864bfb_init
);
185 module_exit(cfag12864bfb_exit
);
187 MODULE_LICENSE("GPL v2");
188 MODULE_AUTHOR("Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>");
189 MODULE_DESCRIPTION("cfag12864b LCD framebuffer driver");