2 * Picvue PVC160206 display driver
4 * Brian Murphy <brian@murphy.dk>
7 #include <linux/kernel.h>
8 #include <linux/delay.h>
9 #include <asm/bootinfo.h>
10 #include <asm/lasat/lasat.h>
11 #include <linux/module.h>
12 #include <linux/errno.h>
13 #include <linux/string.h>
19 #define PVC_DISPMEM 80
20 #define PVC_LINELEN PVC_DISPMEM / PVC_NLINES
22 struct pvc_defs *picvue;
24 static void pvc_reg_write(u32 val)
29 static u32 pvc_reg_read(void)
31 u32 tmp = *picvue->reg;
35 static void pvc_write_byte(u32 data, u8 byte)
39 data &= ~picvue->data_mask;
40 data |= byte << picvue->data_shift;
43 pvc_reg_write(data & ~picvue->e);
47 static u8 pvc_read_byte(u32 data)
54 byte = (pvc_reg_read() & picvue->data_mask) >> picvue->data_shift;
61 static u8 pvc_read_data(void)
63 u32 data = pvc_reg_read();
69 byte = pvc_read_byte(data);
76 static int pvc_wait(void)
81 while ((pvc_read_data() & PVC_BUSY) && i)
91 static void pvc_write(u8 byte, int mode)
93 u32 data = pvc_reg_read();
95 if (mode == MODE_DATA)
101 pvc_write_byte(data, byte);
102 if (mode == MODE_DATA)
110 void pvc_write_string(const unsigned char *str, u8 addr, int line)
114 if (line > 0 && (PVC_NLINES > 1))
116 pvc_write(0x80 | addr, MODE_INST);
118 while (*str != 0 && i < PVC_LINELEN) {
119 pvc_write(*str++, MODE_DATA);
124 void pvc_write_string_centered(const unsigned char *str, int line)
126 int len = strlen(str);
129 if (len > PVC_VISIBLE_CHARS)
132 addr = (PVC_VISIBLE_CHARS - strlen(str))/2;
134 pvc_write_string(str, addr, line);
137 void pvc_dump_string(const unsigned char *str)
139 int len = strlen(str);
141 pvc_write_string(str, 0, 0);
142 if (len > PVC_VISIBLE_CHARS)
143 pvc_write_string(&str[PVC_VISIBLE_CHARS], 0, 1);
147 #define MAX_PROGRAMMABLE_CHARS 8
148 int pvc_program_cg(int charnum, u8 bitmap[BM_SIZE])
153 if (charnum > MAX_PROGRAMMABLE_CHARS)
157 pvc_write(0x40 | addr, MODE_INST);
159 for (i = 0; i < BM_SIZE; i++)
160 pvc_write(bitmap[i], MODE_DATA);
164 #define FUNC_SET_CMD 0x20
165 #define EIGHT_BYTE (1 << 4)
167 #define TWO_LINES (1 << 3)
169 #define LARGE_FONT (1 << 2)
172 static void pvc_funcset(u8 cmd)
174 pvc_write(FUNC_SET_CMD | (cmd & (EIGHT_BYTE|TWO_LINES|LARGE_FONT)),
178 #define ENTRYMODE_CMD 0x4
179 #define AUTO_INC (1 << 1)
181 #define CURSOR_FOLLOWS_DISP (1 << 0)
183 static void pvc_entrymode(u8 cmd)
185 pvc_write(ENTRYMODE_CMD | (cmd & (AUTO_INC|CURSOR_FOLLOWS_DISP)),
189 #define DISP_CNT_CMD 0x08
191 #define DISP_ON (1 << 2)
192 #define CUR_ON (1 << 1)
193 #define CUR_BLINK (1 << 0)
194 void pvc_dispcnt(u8 cmd)
196 pvc_write(DISP_CNT_CMD | (cmd & (DISP_ON|CUR_ON|CUR_BLINK)), MODE_INST);
199 #define MOVE_CMD 0x10
200 #define DISPLAY (1 << 3)
202 #define RIGHT (1 << 2)
204 void pvc_move(u8 cmd)
206 pvc_write(MOVE_CMD | (cmd & (DISPLAY|RIGHT)), MODE_INST);
209 #define CLEAR_CMD 0x1
212 pvc_write(CLEAR_CMD, MODE_INST);
218 pvc_write(HOME_CMD, MODE_INST);
226 cmd |= (SMALL_FONT|TWO_LINES);
228 cmd |= (LARGE_FONT|ONE_LINE);
230 pvc_dispcnt(DISP_ON);
231 pvc_entrymode(AUTO_INC);
234 pvc_write_string_centered("Display", 0);
235 pvc_write_string_centered("Initialized", 1);
240 module_init(pvc_init);
241 MODULE_LICENSE("GPL");