28 #include <linux/module.h>
39 #define LCD_DATA_REG_OFFSET 0x10
40 #define LCD_XRES_MAX 16
41 #define LCD_YRES_MAX 2
42 #define LCD_CHARS_MAX 32
44 #define LCD_CLEAR 0x01
45 #define LCD_CURSOR_MOVE_HOME 0x02
46 #define LCD_RESET 0x06
48 #define LCD_CURSOR_OFF 0x0c
49 #define LCD_CURSOR_BLINK_OFF 0x0e
50 #define LCD_CURSOR_ON 0x0f
51 #define LCD_ON LCD_CURSOR_ON
52 #define LCD_CURSOR_MOVE_LEFT 0x10
53 #define LCD_CURSOR_MOVE_RIGHT 0x14
54 #define LCD_DISPLAY_LEFT 0x18
55 #define LCD_DISPLAY_RIGHT 0x1c
56 #define LCD_PRERESET 0x3f
59 #define LCD_GRAPHIC_MODE 0x40
60 #define LCD_TEXT_MODE 0x80
61 #define LCD_CUR_POS_MASK 0x7f
63 #define LCD_CUR_POS(x) ((x) & LCD_CUR_POS_MASK)
64 #define LCD_TEXT_POS(x) ((x) | LCD_TEXT_MODE)
66 #ifdef CONFIG_MIPS_COBALT
82 static inline u8 lcd_read_data(
struct fb_info *info)
90 #define CPLD_STATUS 0x10
91 #define CPLD_DATA 0x18
93 static inline void cpld_wait(
struct fb_info *info)
105 static inline u8 lcd_read_control(
struct fb_info *info)
113 static inline void lcd_write_data(
struct fb_info *info,
u8 data)
119 static inline u8 lcd_read_data(
struct fb_info *info)
128 static int lcd_busy_wait(
struct fb_info *info)
134 val = lcd_read_control(info);
151 static void lcd_clear(
struct fb_info *info)
155 for (i = 0; i < 4; i++) {
180 size_t count, loff_t *ppos)
196 for (len = 0; len <
count; len++) {
197 retval = lcd_busy_wait(info);
203 retval = lcd_busy_wait(info);
207 src[len] = lcd_read_data(info);
214 if (retval < 0 && signal_pending(
current))
225 static ssize_t cobalt_lcdfb_write(
struct fb_info *info,
const char __user *buf,
226 size_t count, loff_t *ppos)
245 for (len = 0; len <
count; len++) {
246 retval = lcd_busy_wait(info);
252 retval = lcd_busy_wait(info);
256 lcd_write_data(info, dst[len]);
263 if (retval < 0 && signal_pending(
current))
271 static int cobalt_lcdfb_blank(
int blank_mode,
struct fb_info *info)
275 retval = lcd_busy_wait(info);
279 switch (blank_mode) {
281 lcd_write_control(info,
LCD_ON);
284 lcd_write_control(info,
LCD_OFF);
291 static int cobalt_lcdfb_cursor(
struct fb_info *info,
struct fb_cursor *cursor)
296 switch (cursor->
set) {
298 x = cursor->
image.dx;
299 y = cursor->
image.dy;
303 retval = lcd_busy_wait(info);
307 lcd_write_control(info,
314 retval = lcd_busy_wait(info);
326 static struct fb_ops cobalt_lcd_fbops = {
328 .fb_read = cobalt_lcdfb_read,
329 .fb_write = cobalt_lcdfb_write,
330 .fb_blank = cobalt_lcdfb_blank,
331 .fb_cursor = cobalt_lcdfb_cursor,
353 info->
fbops = &cobalt_lcd_fbops;
354 info->
fix = cobalt_lcdfb_fix;
367 platform_set_drvdata(dev, info);
381 info = platform_get_drvdata(dev);
391 .probe = cobalt_lcdfb_probe,
394 .name =
"cobalt-lcd",
399 static int __init cobalt_lcdfb_init(
void)
404 static void __exit cobalt_lcdfb_exit(
void)