1 #include <linux/module.h>
2 #include <linux/kernel.h>
3 #include <linux/errno.h>
4 #include <linux/string.h>
6 #include <linux/slab.h>
7 #include <linux/delay.h>
9 #include <linux/ioport.h>
10 #include <linux/init.h>
11 #include <linux/pci.h>
12 #include <linux/vmalloc.h>
13 #include <linux/pagemap.h>
14 #include <linux/console.h>
15 #include <linux/platform_device.h>
16 #include <linux/screen_info.h>
19 #include "sm750_help.h"
20 #include "sm750_cursor.h"
23 #define PEEK32(addr) \
24 readl(cursor->mmio + (addr))
26 #define POKE32(addr, data) \
27 writel((data), cursor->mmio + (addr))
29 /* cursor control for voyager and 718/750*/
30 #define HWC_ADDRESS 0x0
31 #define HWC_ADDRESS_ENABLE 31:31
32 #define HWC_ADDRESS_ENABLE_DISABLE 0
33 #define HWC_ADDRESS_ENABLE_ENABLE 1
34 #define HWC_ADDRESS_EXT 27:27
35 #define HWC_ADDRESS_EXT_LOCAL 0
36 #define HWC_ADDRESS_EXT_EXTERNAL 1
37 #define HWC_ADDRESS_CS 26:26
38 #define HWC_ADDRESS_CS_0 0
39 #define HWC_ADDRESS_CS_1 1
40 #define HWC_ADDRESS_ADDRESS 25:0
42 #define HWC_LOCATION 0x4
43 #define HWC_LOCATION_TOP 27:27
44 #define HWC_LOCATION_TOP_INSIDE 0
45 #define HWC_LOCATION_TOP_OUTSIDE 1
46 #define HWC_LOCATION_Y 26:16
47 #define HWC_LOCATION_LEFT 11:11
48 #define HWC_LOCATION_LEFT_INSIDE 0
49 #define HWC_LOCATION_LEFT_OUTSIDE 1
50 #define HWC_LOCATION_X 10:0
52 #define HWC_COLOR_12 0x8
53 #define HWC_COLOR_12_2_RGB565 31:16
54 #define HWC_COLOR_12_1_RGB565 15:0
56 #define HWC_COLOR_3 0xC
57 #define HWC_COLOR_3_RGB565 15:0
60 /* hw_cursor_xxx works for voyager,718 and 750 */
61 void hw_cursor_enable(struct lynx_cursor *cursor)
65 reg = FIELD_VALUE(0, HWC_ADDRESS, ADDRESS, cursor->offset)|
66 FIELD_SET(0, HWC_ADDRESS, EXT, LOCAL)|
67 FIELD_SET(0, HWC_ADDRESS, ENABLE, ENABLE);
68 POKE32(HWC_ADDRESS, reg);
70 void hw_cursor_disable(struct lynx_cursor *cursor)
72 POKE32(HWC_ADDRESS, 0);
75 void hw_cursor_setSize(struct lynx_cursor *cursor,
81 void hw_cursor_setPos(struct lynx_cursor *cursor,
86 reg = FIELD_VALUE(0, HWC_LOCATION, Y, y)|
87 FIELD_VALUE(0, HWC_LOCATION, X, x);
88 POKE32(HWC_LOCATION, reg);
90 void hw_cursor_setColor(struct lynx_cursor *cursor,
93 POKE32(HWC_COLOR_12, (fg<<16)|(bg&0xffff));
94 POKE32(HWC_COLOR_3, 0xffe0);
97 void hw_cursor_setData(struct lynx_cursor *cursor,
98 u16 rop, const u8 *pcol, const u8 *pmsk)
100 int i, j, count, pitch, offset;
103 void __iomem *pbuffer, *pstart;
106 pitch = cursor->w >> 3;
109 count = pitch * cursor->h;
112 offset = cursor->maxW * 2 / 8;
115 pstart = cursor->vstart;
120 hw_cursor_setData2(cursor,rop,pcol,pmsk);
127 for (i = 0; i < count; i++) {
132 for (j = 0; j < 8; j++) {
133 if (mask & (0x80>>j)) {
139 /* 2 stands for forecolor and 1 for backcolor */
140 data |= ((opr & (0x80>>j))?2:1)<<(j*2);
143 iowrite16(data, pbuffer);
145 /* assume pitch is 1,2,4,8,...*/
146 if ((i+1) % pitch == 0)
152 pbuffer += sizeof(u16);
161 void hw_cursor_setData2(struct lynx_cursor *cursor,
162 u16 rop, const u8 *pcol, const u8 *pmsk)
164 int i, j, count, pitch, offset;
167 void __iomem *pbuffer, *pstart;
170 pitch = cursor->w >> 3;
173 count = pitch * cursor->h;
176 offset = cursor->maxW * 2 / 8;
179 pstart = cursor->vstart;
182 for (i = 0; i < count; i++) {
187 for (j = 0; j < 8; j++) {
189 data |= ((color & (1<<j))?1:2)<<(j*2);
191 iowrite16(data, pbuffer);
193 /* assume pitch is 1,2,4,8,...*/
194 if (!(i&(pitch-1))) {
199 pbuffer += sizeof(u16);