1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * linux/drivers/video/w100fb.c
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Frame Buffer Device for ATI Imageon w100 (Wallaby)
6*4882a593Smuzhiyun *
7*4882a593Smuzhiyun * Copyright (C) 2002, ATI Corp.
8*4882a593Smuzhiyun * Copyright (C) 2004-2006 Richard Purdie
9*4882a593Smuzhiyun * Copyright (c) 2005 Ian Molton
10*4882a593Smuzhiyun * Copyright (c) 2006 Alberto Mardegan
11*4882a593Smuzhiyun *
12*4882a593Smuzhiyun * Rewritten for 2.6 by Richard Purdie <rpurdie@rpsys.net>
13*4882a593Smuzhiyun *
14*4882a593Smuzhiyun * Generic platform support by Ian Molton <spyro@f2s.com>
15*4882a593Smuzhiyun * and Richard Purdie <rpurdie@rpsys.net>
16*4882a593Smuzhiyun *
17*4882a593Smuzhiyun * w32xx support by Ian Molton
18*4882a593Smuzhiyun *
19*4882a593Smuzhiyun * Hardware acceleration support by Alberto Mardegan
20*4882a593Smuzhiyun * <mardy@users.sourceforge.net>
21*4882a593Smuzhiyun */
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun #include <linux/delay.h>
24*4882a593Smuzhiyun #include <linux/fb.h>
25*4882a593Smuzhiyun #include <linux/init.h>
26*4882a593Smuzhiyun #include <linux/kernel.h>
27*4882a593Smuzhiyun #include <linux/mm.h>
28*4882a593Smuzhiyun #include <linux/platform_device.h>
29*4882a593Smuzhiyun #include <linux/slab.h>
30*4882a593Smuzhiyun #include <linux/string.h>
31*4882a593Smuzhiyun #include <linux/vmalloc.h>
32*4882a593Smuzhiyun #include <linux/module.h>
33*4882a593Smuzhiyun #include <asm/io.h>
34*4882a593Smuzhiyun #include <linux/uaccess.h>
35*4882a593Smuzhiyun #include <video/w100fb.h>
36*4882a593Smuzhiyun #include "w100fb.h"
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun /*
39*4882a593Smuzhiyun * Prototypes
40*4882a593Smuzhiyun */
41*4882a593Smuzhiyun static void w100_suspend(u32 mode);
42*4882a593Smuzhiyun static void w100_vsync(void);
43*4882a593Smuzhiyun static void w100_hw_init(struct w100fb_par*);
44*4882a593Smuzhiyun static void w100_pwm_setup(struct w100fb_par*);
45*4882a593Smuzhiyun static void w100_init_clocks(struct w100fb_par*);
46*4882a593Smuzhiyun static void w100_setup_memory(struct w100fb_par*);
47*4882a593Smuzhiyun static void w100_init_lcd(struct w100fb_par*);
48*4882a593Smuzhiyun static void w100_set_dispregs(struct w100fb_par*);
49*4882a593Smuzhiyun static void w100_update_enable(void);
50*4882a593Smuzhiyun static void w100_update_disable(void);
51*4882a593Smuzhiyun static void calc_hsync(struct w100fb_par *par);
52*4882a593Smuzhiyun static void w100_init_graphic_engine(struct w100fb_par *par);
53*4882a593Smuzhiyun struct w100_pll_info *w100_get_xtal_table(unsigned int freq);
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun /* Pseudo palette size */
56*4882a593Smuzhiyun #define MAX_PALETTES 16
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun #define W100_SUSPEND_EXTMEM 0
59*4882a593Smuzhiyun #define W100_SUSPEND_ALL 1
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun #define BITS_PER_PIXEL 16
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun /* Remapped addresses for base cfg, memmapped regs and the frame buffer itself */
64*4882a593Smuzhiyun static void __iomem *remapped_base;
65*4882a593Smuzhiyun static void __iomem *remapped_regs;
66*4882a593Smuzhiyun static void __iomem *remapped_fbuf;
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun #define REMAPPED_FB_LEN 0x15ffff
69*4882a593Smuzhiyun
70*4882a593Smuzhiyun /* This is the offset in the w100's address space we map the current
71*4882a593Smuzhiyun framebuffer memory to. We use the position of external memory as
72*4882a593Smuzhiyun we can remap internal memory to there if external isn't present. */
73*4882a593Smuzhiyun #define W100_FB_BASE MEM_EXT_BASE_VALUE
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun
76*4882a593Smuzhiyun /*
77*4882a593Smuzhiyun * Sysfs functions
78*4882a593Smuzhiyun */
flip_show(struct device * dev,struct device_attribute * attr,char * buf)79*4882a593Smuzhiyun static ssize_t flip_show(struct device *dev, struct device_attribute *attr, char *buf)
80*4882a593Smuzhiyun {
81*4882a593Smuzhiyun struct fb_info *info = dev_get_drvdata(dev);
82*4882a593Smuzhiyun struct w100fb_par *par=info->par;
83*4882a593Smuzhiyun
84*4882a593Smuzhiyun return sprintf(buf, "%d\n",par->flip);
85*4882a593Smuzhiyun }
86*4882a593Smuzhiyun
flip_store(struct device * dev,struct device_attribute * attr,const char * buf,size_t count)87*4882a593Smuzhiyun static ssize_t flip_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
88*4882a593Smuzhiyun {
89*4882a593Smuzhiyun unsigned int flip;
90*4882a593Smuzhiyun struct fb_info *info = dev_get_drvdata(dev);
91*4882a593Smuzhiyun struct w100fb_par *par=info->par;
92*4882a593Smuzhiyun
93*4882a593Smuzhiyun flip = simple_strtoul(buf, NULL, 10);
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun if (flip > 0)
96*4882a593Smuzhiyun par->flip = 1;
97*4882a593Smuzhiyun else
98*4882a593Smuzhiyun par->flip = 0;
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun w100_update_disable();
101*4882a593Smuzhiyun w100_set_dispregs(par);
102*4882a593Smuzhiyun w100_update_enable();
103*4882a593Smuzhiyun
104*4882a593Smuzhiyun calc_hsync(par);
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun return count;
107*4882a593Smuzhiyun }
108*4882a593Smuzhiyun
109*4882a593Smuzhiyun static DEVICE_ATTR_RW(flip);
110*4882a593Smuzhiyun
w100fb_reg_read(struct device * dev,struct device_attribute * attr,const char * buf,size_t count)111*4882a593Smuzhiyun static ssize_t w100fb_reg_read(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
112*4882a593Smuzhiyun {
113*4882a593Smuzhiyun unsigned long regs, param;
114*4882a593Smuzhiyun regs = simple_strtoul(buf, NULL, 16);
115*4882a593Smuzhiyun param = readl(remapped_regs + regs);
116*4882a593Smuzhiyun printk("Read Register 0x%08lX: 0x%08lX\n", regs, param);
117*4882a593Smuzhiyun return count;
118*4882a593Smuzhiyun }
119*4882a593Smuzhiyun
120*4882a593Smuzhiyun static DEVICE_ATTR(reg_read, 0200, NULL, w100fb_reg_read);
121*4882a593Smuzhiyun
w100fb_reg_write(struct device * dev,struct device_attribute * attr,const char * buf,size_t count)122*4882a593Smuzhiyun static ssize_t w100fb_reg_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
123*4882a593Smuzhiyun {
124*4882a593Smuzhiyun unsigned long regs, param;
125*4882a593Smuzhiyun sscanf(buf, "%lx %lx", ®s, ¶m);
126*4882a593Smuzhiyun
127*4882a593Smuzhiyun if (regs <= 0x2000) {
128*4882a593Smuzhiyun printk("Write Register 0x%08lX: 0x%08lX\n", regs, param);
129*4882a593Smuzhiyun writel(param, remapped_regs + regs);
130*4882a593Smuzhiyun }
131*4882a593Smuzhiyun
132*4882a593Smuzhiyun return count;
133*4882a593Smuzhiyun }
134*4882a593Smuzhiyun
135*4882a593Smuzhiyun static DEVICE_ATTR(reg_write, 0200, NULL, w100fb_reg_write);
136*4882a593Smuzhiyun
137*4882a593Smuzhiyun
fastpllclk_show(struct device * dev,struct device_attribute * attr,char * buf)138*4882a593Smuzhiyun static ssize_t fastpllclk_show(struct device *dev, struct device_attribute *attr, char *buf)
139*4882a593Smuzhiyun {
140*4882a593Smuzhiyun struct fb_info *info = dev_get_drvdata(dev);
141*4882a593Smuzhiyun struct w100fb_par *par=info->par;
142*4882a593Smuzhiyun
143*4882a593Smuzhiyun return sprintf(buf, "%d\n",par->fastpll_mode);
144*4882a593Smuzhiyun }
145*4882a593Smuzhiyun
fastpllclk_store(struct device * dev,struct device_attribute * attr,const char * buf,size_t count)146*4882a593Smuzhiyun static ssize_t fastpllclk_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
147*4882a593Smuzhiyun {
148*4882a593Smuzhiyun struct fb_info *info = dev_get_drvdata(dev);
149*4882a593Smuzhiyun struct w100fb_par *par=info->par;
150*4882a593Smuzhiyun
151*4882a593Smuzhiyun if (simple_strtoul(buf, NULL, 10) > 0) {
152*4882a593Smuzhiyun par->fastpll_mode=1;
153*4882a593Smuzhiyun printk("w100fb: Using fast system clock (if possible)\n");
154*4882a593Smuzhiyun } else {
155*4882a593Smuzhiyun par->fastpll_mode=0;
156*4882a593Smuzhiyun printk("w100fb: Using normal system clock\n");
157*4882a593Smuzhiyun }
158*4882a593Smuzhiyun
159*4882a593Smuzhiyun w100_init_clocks(par);
160*4882a593Smuzhiyun calc_hsync(par);
161*4882a593Smuzhiyun
162*4882a593Smuzhiyun return count;
163*4882a593Smuzhiyun }
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun static DEVICE_ATTR_RW(fastpllclk);
166*4882a593Smuzhiyun
167*4882a593Smuzhiyun static struct attribute *w100fb_attrs[] = {
168*4882a593Smuzhiyun &dev_attr_fastpllclk.attr,
169*4882a593Smuzhiyun &dev_attr_reg_read.attr,
170*4882a593Smuzhiyun &dev_attr_reg_write.attr,
171*4882a593Smuzhiyun &dev_attr_flip.attr,
172*4882a593Smuzhiyun NULL,
173*4882a593Smuzhiyun };
174*4882a593Smuzhiyun ATTRIBUTE_GROUPS(w100fb);
175*4882a593Smuzhiyun
176*4882a593Smuzhiyun /*
177*4882a593Smuzhiyun * Some touchscreens need hsync information from the video driver to
178*4882a593Smuzhiyun * function correctly. We export it here.
179*4882a593Smuzhiyun */
w100fb_get_hsynclen(struct device * dev)180*4882a593Smuzhiyun unsigned long w100fb_get_hsynclen(struct device *dev)
181*4882a593Smuzhiyun {
182*4882a593Smuzhiyun struct fb_info *info = dev_get_drvdata(dev);
183*4882a593Smuzhiyun struct w100fb_par *par=info->par;
184*4882a593Smuzhiyun
185*4882a593Smuzhiyun /* If display is blanked/suspended, hsync isn't active */
186*4882a593Smuzhiyun if (par->blanked)
187*4882a593Smuzhiyun return 0;
188*4882a593Smuzhiyun else
189*4882a593Smuzhiyun return par->hsync_len;
190*4882a593Smuzhiyun }
191*4882a593Smuzhiyun EXPORT_SYMBOL(w100fb_get_hsynclen);
192*4882a593Smuzhiyun
w100fb_clear_screen(struct w100fb_par * par)193*4882a593Smuzhiyun static void w100fb_clear_screen(struct w100fb_par *par)
194*4882a593Smuzhiyun {
195*4882a593Smuzhiyun memset_io(remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), 0, (par->xres * par->yres * BITS_PER_PIXEL/8));
196*4882a593Smuzhiyun }
197*4882a593Smuzhiyun
198*4882a593Smuzhiyun
199*4882a593Smuzhiyun /*
200*4882a593Smuzhiyun * Set a palette value from rgb components
201*4882a593Smuzhiyun */
w100fb_setcolreg(u_int regno,u_int red,u_int green,u_int blue,u_int trans,struct fb_info * info)202*4882a593Smuzhiyun static int w100fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
203*4882a593Smuzhiyun u_int trans, struct fb_info *info)
204*4882a593Smuzhiyun {
205*4882a593Smuzhiyun unsigned int val;
206*4882a593Smuzhiyun int ret = 1;
207*4882a593Smuzhiyun
208*4882a593Smuzhiyun /*
209*4882a593Smuzhiyun * If greyscale is true, then we convert the RGB value
210*4882a593Smuzhiyun * to greyscale no matter what visual we are using.
211*4882a593Smuzhiyun */
212*4882a593Smuzhiyun if (info->var.grayscale)
213*4882a593Smuzhiyun red = green = blue = (19595 * red + 38470 * green + 7471 * blue) >> 16;
214*4882a593Smuzhiyun
215*4882a593Smuzhiyun /*
216*4882a593Smuzhiyun * 16-bit True Colour. We encode the RGB value
217*4882a593Smuzhiyun * according to the RGB bitfield information.
218*4882a593Smuzhiyun */
219*4882a593Smuzhiyun if (regno < MAX_PALETTES) {
220*4882a593Smuzhiyun u32 *pal = info->pseudo_palette;
221*4882a593Smuzhiyun
222*4882a593Smuzhiyun val = (red & 0xf800) | ((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11);
223*4882a593Smuzhiyun pal[regno] = val;
224*4882a593Smuzhiyun ret = 0;
225*4882a593Smuzhiyun }
226*4882a593Smuzhiyun return ret;
227*4882a593Smuzhiyun }
228*4882a593Smuzhiyun
229*4882a593Smuzhiyun
230*4882a593Smuzhiyun /*
231*4882a593Smuzhiyun * Blank the display based on value in blank_mode
232*4882a593Smuzhiyun */
w100fb_blank(int blank_mode,struct fb_info * info)233*4882a593Smuzhiyun static int w100fb_blank(int blank_mode, struct fb_info *info)
234*4882a593Smuzhiyun {
235*4882a593Smuzhiyun struct w100fb_par *par = info->par;
236*4882a593Smuzhiyun struct w100_tg_info *tg = par->mach->tg;
237*4882a593Smuzhiyun
238*4882a593Smuzhiyun switch(blank_mode) {
239*4882a593Smuzhiyun
240*4882a593Smuzhiyun case FB_BLANK_NORMAL: /* Normal blanking */
241*4882a593Smuzhiyun case FB_BLANK_VSYNC_SUSPEND: /* VESA blank (vsync off) */
242*4882a593Smuzhiyun case FB_BLANK_HSYNC_SUSPEND: /* VESA blank (hsync off) */
243*4882a593Smuzhiyun case FB_BLANK_POWERDOWN: /* Poweroff */
244*4882a593Smuzhiyun if (par->blanked == 0) {
245*4882a593Smuzhiyun if(tg && tg->suspend)
246*4882a593Smuzhiyun tg->suspend(par);
247*4882a593Smuzhiyun par->blanked = 1;
248*4882a593Smuzhiyun }
249*4882a593Smuzhiyun break;
250*4882a593Smuzhiyun
251*4882a593Smuzhiyun case FB_BLANK_UNBLANK: /* Unblanking */
252*4882a593Smuzhiyun if (par->blanked != 0) {
253*4882a593Smuzhiyun if(tg && tg->resume)
254*4882a593Smuzhiyun tg->resume(par);
255*4882a593Smuzhiyun par->blanked = 0;
256*4882a593Smuzhiyun }
257*4882a593Smuzhiyun break;
258*4882a593Smuzhiyun }
259*4882a593Smuzhiyun return 0;
260*4882a593Smuzhiyun }
261*4882a593Smuzhiyun
262*4882a593Smuzhiyun
w100_fifo_wait(int entries)263*4882a593Smuzhiyun static void w100_fifo_wait(int entries)
264*4882a593Smuzhiyun {
265*4882a593Smuzhiyun union rbbm_status_u status;
266*4882a593Smuzhiyun int i;
267*4882a593Smuzhiyun
268*4882a593Smuzhiyun for (i = 0; i < 2000000; i++) {
269*4882a593Smuzhiyun status.val = readl(remapped_regs + mmRBBM_STATUS);
270*4882a593Smuzhiyun if (status.f.cmdfifo_avail >= entries)
271*4882a593Smuzhiyun return;
272*4882a593Smuzhiyun udelay(1);
273*4882a593Smuzhiyun }
274*4882a593Smuzhiyun printk(KERN_ERR "w100fb: FIFO Timeout!\n");
275*4882a593Smuzhiyun }
276*4882a593Smuzhiyun
277*4882a593Smuzhiyun
w100fb_sync(struct fb_info * info)278*4882a593Smuzhiyun static int w100fb_sync(struct fb_info *info)
279*4882a593Smuzhiyun {
280*4882a593Smuzhiyun union rbbm_status_u status;
281*4882a593Smuzhiyun int i;
282*4882a593Smuzhiyun
283*4882a593Smuzhiyun for (i = 0; i < 2000000; i++) {
284*4882a593Smuzhiyun status.val = readl(remapped_regs + mmRBBM_STATUS);
285*4882a593Smuzhiyun if (!status.f.gui_active)
286*4882a593Smuzhiyun return 0;
287*4882a593Smuzhiyun udelay(1);
288*4882a593Smuzhiyun }
289*4882a593Smuzhiyun printk(KERN_ERR "w100fb: Graphic engine timeout!\n");
290*4882a593Smuzhiyun return -EBUSY;
291*4882a593Smuzhiyun }
292*4882a593Smuzhiyun
293*4882a593Smuzhiyun
w100_init_graphic_engine(struct w100fb_par * par)294*4882a593Smuzhiyun static void w100_init_graphic_engine(struct w100fb_par *par)
295*4882a593Smuzhiyun {
296*4882a593Smuzhiyun union dp_gui_master_cntl_u gmc;
297*4882a593Smuzhiyun union dp_mix_u dp_mix;
298*4882a593Smuzhiyun union dp_datatype_u dp_datatype;
299*4882a593Smuzhiyun union dp_cntl_u dp_cntl;
300*4882a593Smuzhiyun
301*4882a593Smuzhiyun w100_fifo_wait(4);
302*4882a593Smuzhiyun writel(W100_FB_BASE, remapped_regs + mmDST_OFFSET);
303*4882a593Smuzhiyun writel(par->xres, remapped_regs + mmDST_PITCH);
304*4882a593Smuzhiyun writel(W100_FB_BASE, remapped_regs + mmSRC_OFFSET);
305*4882a593Smuzhiyun writel(par->xres, remapped_regs + mmSRC_PITCH);
306*4882a593Smuzhiyun
307*4882a593Smuzhiyun w100_fifo_wait(3);
308*4882a593Smuzhiyun writel(0, remapped_regs + mmSC_TOP_LEFT);
309*4882a593Smuzhiyun writel((par->yres << 16) | par->xres, remapped_regs + mmSC_BOTTOM_RIGHT);
310*4882a593Smuzhiyun writel(0x1fff1fff, remapped_regs + mmSRC_SC_BOTTOM_RIGHT);
311*4882a593Smuzhiyun
312*4882a593Smuzhiyun w100_fifo_wait(4);
313*4882a593Smuzhiyun dp_cntl.val = 0;
314*4882a593Smuzhiyun dp_cntl.f.dst_x_dir = 1;
315*4882a593Smuzhiyun dp_cntl.f.dst_y_dir = 1;
316*4882a593Smuzhiyun dp_cntl.f.src_x_dir = 1;
317*4882a593Smuzhiyun dp_cntl.f.src_y_dir = 1;
318*4882a593Smuzhiyun dp_cntl.f.dst_major_x = 1;
319*4882a593Smuzhiyun dp_cntl.f.src_major_x = 1;
320*4882a593Smuzhiyun writel(dp_cntl.val, remapped_regs + mmDP_CNTL);
321*4882a593Smuzhiyun
322*4882a593Smuzhiyun gmc.val = 0;
323*4882a593Smuzhiyun gmc.f.gmc_src_pitch_offset_cntl = 1;
324*4882a593Smuzhiyun gmc.f.gmc_dst_pitch_offset_cntl = 1;
325*4882a593Smuzhiyun gmc.f.gmc_src_clipping = 1;
326*4882a593Smuzhiyun gmc.f.gmc_dst_clipping = 1;
327*4882a593Smuzhiyun gmc.f.gmc_brush_datatype = GMC_BRUSH_NONE;
328*4882a593Smuzhiyun gmc.f.gmc_dst_datatype = 3; /* from DstType_16Bpp_444 */
329*4882a593Smuzhiyun gmc.f.gmc_src_datatype = SRC_DATATYPE_EQU_DST;
330*4882a593Smuzhiyun gmc.f.gmc_byte_pix_order = 1;
331*4882a593Smuzhiyun gmc.f.gmc_default_sel = 0;
332*4882a593Smuzhiyun gmc.f.gmc_rop3 = ROP3_SRCCOPY;
333*4882a593Smuzhiyun gmc.f.gmc_dp_src_source = DP_SRC_MEM_RECTANGULAR;
334*4882a593Smuzhiyun gmc.f.gmc_clr_cmp_fcn_dis = 1;
335*4882a593Smuzhiyun gmc.f.gmc_wr_msk_dis = 1;
336*4882a593Smuzhiyun gmc.f.gmc_dp_op = DP_OP_ROP;
337*4882a593Smuzhiyun writel(gmc.val, remapped_regs + mmDP_GUI_MASTER_CNTL);
338*4882a593Smuzhiyun
339*4882a593Smuzhiyun dp_datatype.val = dp_mix.val = 0;
340*4882a593Smuzhiyun dp_datatype.f.dp_dst_datatype = gmc.f.gmc_dst_datatype;
341*4882a593Smuzhiyun dp_datatype.f.dp_brush_datatype = gmc.f.gmc_brush_datatype;
342*4882a593Smuzhiyun dp_datatype.f.dp_src2_type = 0;
343*4882a593Smuzhiyun dp_datatype.f.dp_src2_datatype = gmc.f.gmc_src_datatype;
344*4882a593Smuzhiyun dp_datatype.f.dp_src_datatype = gmc.f.gmc_src_datatype;
345*4882a593Smuzhiyun dp_datatype.f.dp_byte_pix_order = gmc.f.gmc_byte_pix_order;
346*4882a593Smuzhiyun writel(dp_datatype.val, remapped_regs + mmDP_DATATYPE);
347*4882a593Smuzhiyun
348*4882a593Smuzhiyun dp_mix.f.dp_src_source = gmc.f.gmc_dp_src_source;
349*4882a593Smuzhiyun dp_mix.f.dp_src2_source = 1;
350*4882a593Smuzhiyun dp_mix.f.dp_rop3 = gmc.f.gmc_rop3;
351*4882a593Smuzhiyun dp_mix.f.dp_op = gmc.f.gmc_dp_op;
352*4882a593Smuzhiyun writel(dp_mix.val, remapped_regs + mmDP_MIX);
353*4882a593Smuzhiyun }
354*4882a593Smuzhiyun
355*4882a593Smuzhiyun
w100fb_fillrect(struct fb_info * info,const struct fb_fillrect * rect)356*4882a593Smuzhiyun static void w100fb_fillrect(struct fb_info *info,
357*4882a593Smuzhiyun const struct fb_fillrect *rect)
358*4882a593Smuzhiyun {
359*4882a593Smuzhiyun union dp_gui_master_cntl_u gmc;
360*4882a593Smuzhiyun
361*4882a593Smuzhiyun if (info->state != FBINFO_STATE_RUNNING)
362*4882a593Smuzhiyun return;
363*4882a593Smuzhiyun if (info->flags & FBINFO_HWACCEL_DISABLED) {
364*4882a593Smuzhiyun cfb_fillrect(info, rect);
365*4882a593Smuzhiyun return;
366*4882a593Smuzhiyun }
367*4882a593Smuzhiyun
368*4882a593Smuzhiyun gmc.val = readl(remapped_regs + mmDP_GUI_MASTER_CNTL);
369*4882a593Smuzhiyun gmc.f.gmc_rop3 = ROP3_PATCOPY;
370*4882a593Smuzhiyun gmc.f.gmc_brush_datatype = GMC_BRUSH_SOLID_COLOR;
371*4882a593Smuzhiyun w100_fifo_wait(2);
372*4882a593Smuzhiyun writel(gmc.val, remapped_regs + mmDP_GUI_MASTER_CNTL);
373*4882a593Smuzhiyun writel(rect->color, remapped_regs + mmDP_BRUSH_FRGD_CLR);
374*4882a593Smuzhiyun
375*4882a593Smuzhiyun w100_fifo_wait(2);
376*4882a593Smuzhiyun writel((rect->dy << 16) | (rect->dx & 0xffff), remapped_regs + mmDST_Y_X);
377*4882a593Smuzhiyun writel((rect->width << 16) | (rect->height & 0xffff),
378*4882a593Smuzhiyun remapped_regs + mmDST_WIDTH_HEIGHT);
379*4882a593Smuzhiyun }
380*4882a593Smuzhiyun
381*4882a593Smuzhiyun
w100fb_copyarea(struct fb_info * info,const struct fb_copyarea * area)382*4882a593Smuzhiyun static void w100fb_copyarea(struct fb_info *info,
383*4882a593Smuzhiyun const struct fb_copyarea *area)
384*4882a593Smuzhiyun {
385*4882a593Smuzhiyun u32 dx = area->dx, dy = area->dy, sx = area->sx, sy = area->sy;
386*4882a593Smuzhiyun u32 h = area->height, w = area->width;
387*4882a593Smuzhiyun union dp_gui_master_cntl_u gmc;
388*4882a593Smuzhiyun
389*4882a593Smuzhiyun if (info->state != FBINFO_STATE_RUNNING)
390*4882a593Smuzhiyun return;
391*4882a593Smuzhiyun if (info->flags & FBINFO_HWACCEL_DISABLED) {
392*4882a593Smuzhiyun cfb_copyarea(info, area);
393*4882a593Smuzhiyun return;
394*4882a593Smuzhiyun }
395*4882a593Smuzhiyun
396*4882a593Smuzhiyun gmc.val = readl(remapped_regs + mmDP_GUI_MASTER_CNTL);
397*4882a593Smuzhiyun gmc.f.gmc_rop3 = ROP3_SRCCOPY;
398*4882a593Smuzhiyun gmc.f.gmc_brush_datatype = GMC_BRUSH_NONE;
399*4882a593Smuzhiyun w100_fifo_wait(1);
400*4882a593Smuzhiyun writel(gmc.val, remapped_regs + mmDP_GUI_MASTER_CNTL);
401*4882a593Smuzhiyun
402*4882a593Smuzhiyun w100_fifo_wait(3);
403*4882a593Smuzhiyun writel((sy << 16) | (sx & 0xffff), remapped_regs + mmSRC_Y_X);
404*4882a593Smuzhiyun writel((dy << 16) | (dx & 0xffff), remapped_regs + mmDST_Y_X);
405*4882a593Smuzhiyun writel((w << 16) | (h & 0xffff), remapped_regs + mmDST_WIDTH_HEIGHT);
406*4882a593Smuzhiyun }
407*4882a593Smuzhiyun
408*4882a593Smuzhiyun
409*4882a593Smuzhiyun /*
410*4882a593Smuzhiyun * Change the resolution by calling the appropriate hardware functions
411*4882a593Smuzhiyun */
w100fb_activate_var(struct w100fb_par * par)412*4882a593Smuzhiyun static void w100fb_activate_var(struct w100fb_par *par)
413*4882a593Smuzhiyun {
414*4882a593Smuzhiyun struct w100_tg_info *tg = par->mach->tg;
415*4882a593Smuzhiyun
416*4882a593Smuzhiyun w100_pwm_setup(par);
417*4882a593Smuzhiyun w100_setup_memory(par);
418*4882a593Smuzhiyun w100_init_clocks(par);
419*4882a593Smuzhiyun w100fb_clear_screen(par);
420*4882a593Smuzhiyun w100_vsync();
421*4882a593Smuzhiyun
422*4882a593Smuzhiyun w100_update_disable();
423*4882a593Smuzhiyun w100_init_lcd(par);
424*4882a593Smuzhiyun w100_set_dispregs(par);
425*4882a593Smuzhiyun w100_update_enable();
426*4882a593Smuzhiyun w100_init_graphic_engine(par);
427*4882a593Smuzhiyun
428*4882a593Smuzhiyun calc_hsync(par);
429*4882a593Smuzhiyun
430*4882a593Smuzhiyun if (!par->blanked && tg && tg->change)
431*4882a593Smuzhiyun tg->change(par);
432*4882a593Smuzhiyun }
433*4882a593Smuzhiyun
434*4882a593Smuzhiyun
435*4882a593Smuzhiyun /* Select the smallest mode that allows the desired resolution to be
436*4882a593Smuzhiyun * displayed. If desired, the x and y parameters can be rounded up to
437*4882a593Smuzhiyun * match the selected mode.
438*4882a593Smuzhiyun */
w100fb_get_mode(struct w100fb_par * par,unsigned int * x,unsigned int * y,int saveval)439*4882a593Smuzhiyun static struct w100_mode *w100fb_get_mode(struct w100fb_par *par, unsigned int *x, unsigned int *y, int saveval)
440*4882a593Smuzhiyun {
441*4882a593Smuzhiyun struct w100_mode *mode = NULL;
442*4882a593Smuzhiyun struct w100_mode *modelist = par->mach->modelist;
443*4882a593Smuzhiyun unsigned int best_x = 0xffffffff, best_y = 0xffffffff;
444*4882a593Smuzhiyun unsigned int i;
445*4882a593Smuzhiyun
446*4882a593Smuzhiyun for (i = 0 ; i < par->mach->num_modes ; i++) {
447*4882a593Smuzhiyun if (modelist[i].xres >= *x && modelist[i].yres >= *y &&
448*4882a593Smuzhiyun modelist[i].xres < best_x && modelist[i].yres < best_y) {
449*4882a593Smuzhiyun best_x = modelist[i].xres;
450*4882a593Smuzhiyun best_y = modelist[i].yres;
451*4882a593Smuzhiyun mode = &modelist[i];
452*4882a593Smuzhiyun } else if(modelist[i].xres >= *y && modelist[i].yres >= *x &&
453*4882a593Smuzhiyun modelist[i].xres < best_y && modelist[i].yres < best_x) {
454*4882a593Smuzhiyun best_x = modelist[i].yres;
455*4882a593Smuzhiyun best_y = modelist[i].xres;
456*4882a593Smuzhiyun mode = &modelist[i];
457*4882a593Smuzhiyun }
458*4882a593Smuzhiyun }
459*4882a593Smuzhiyun
460*4882a593Smuzhiyun if (mode && saveval) {
461*4882a593Smuzhiyun *x = best_x;
462*4882a593Smuzhiyun *y = best_y;
463*4882a593Smuzhiyun }
464*4882a593Smuzhiyun
465*4882a593Smuzhiyun return mode;
466*4882a593Smuzhiyun }
467*4882a593Smuzhiyun
468*4882a593Smuzhiyun
469*4882a593Smuzhiyun /*
470*4882a593Smuzhiyun * w100fb_check_var():
471*4882a593Smuzhiyun * Get the video params out of 'var'. If a value doesn't fit, round it up,
472*4882a593Smuzhiyun * if it's too big, return -EINVAL.
473*4882a593Smuzhiyun */
w100fb_check_var(struct fb_var_screeninfo * var,struct fb_info * info)474*4882a593Smuzhiyun static int w100fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
475*4882a593Smuzhiyun {
476*4882a593Smuzhiyun struct w100fb_par *par=info->par;
477*4882a593Smuzhiyun
478*4882a593Smuzhiyun if(!w100fb_get_mode(par, &var->xres, &var->yres, 1))
479*4882a593Smuzhiyun return -EINVAL;
480*4882a593Smuzhiyun
481*4882a593Smuzhiyun if (par->mach->mem && ((var->xres*var->yres*BITS_PER_PIXEL/8) > (par->mach->mem->size+1)))
482*4882a593Smuzhiyun return -EINVAL;
483*4882a593Smuzhiyun
484*4882a593Smuzhiyun if (!par->mach->mem && ((var->xres*var->yres*BITS_PER_PIXEL/8) > (MEM_INT_SIZE+1)))
485*4882a593Smuzhiyun return -EINVAL;
486*4882a593Smuzhiyun
487*4882a593Smuzhiyun var->xres_virtual = max(var->xres_virtual, var->xres);
488*4882a593Smuzhiyun var->yres_virtual = max(var->yres_virtual, var->yres);
489*4882a593Smuzhiyun
490*4882a593Smuzhiyun if (var->bits_per_pixel > BITS_PER_PIXEL)
491*4882a593Smuzhiyun return -EINVAL;
492*4882a593Smuzhiyun else
493*4882a593Smuzhiyun var->bits_per_pixel = BITS_PER_PIXEL;
494*4882a593Smuzhiyun
495*4882a593Smuzhiyun var->red.offset = 11;
496*4882a593Smuzhiyun var->red.length = 5;
497*4882a593Smuzhiyun var->green.offset = 5;
498*4882a593Smuzhiyun var->green.length = 6;
499*4882a593Smuzhiyun var->blue.offset = 0;
500*4882a593Smuzhiyun var->blue.length = 5;
501*4882a593Smuzhiyun var->transp.offset = var->transp.length = 0;
502*4882a593Smuzhiyun
503*4882a593Smuzhiyun var->nonstd = 0;
504*4882a593Smuzhiyun var->height = -1;
505*4882a593Smuzhiyun var->width = -1;
506*4882a593Smuzhiyun var->vmode = FB_VMODE_NONINTERLACED;
507*4882a593Smuzhiyun var->sync = 0;
508*4882a593Smuzhiyun var->pixclock = 0x04; /* 171521; */
509*4882a593Smuzhiyun
510*4882a593Smuzhiyun return 0;
511*4882a593Smuzhiyun }
512*4882a593Smuzhiyun
513*4882a593Smuzhiyun
514*4882a593Smuzhiyun /*
515*4882a593Smuzhiyun * w100fb_set_par():
516*4882a593Smuzhiyun * Set the user defined part of the display for the specified console
517*4882a593Smuzhiyun * by looking at the values in info.var
518*4882a593Smuzhiyun */
w100fb_set_par(struct fb_info * info)519*4882a593Smuzhiyun static int w100fb_set_par(struct fb_info *info)
520*4882a593Smuzhiyun {
521*4882a593Smuzhiyun struct w100fb_par *par=info->par;
522*4882a593Smuzhiyun
523*4882a593Smuzhiyun if (par->xres != info->var.xres || par->yres != info->var.yres) {
524*4882a593Smuzhiyun par->xres = info->var.xres;
525*4882a593Smuzhiyun par->yres = info->var.yres;
526*4882a593Smuzhiyun par->mode = w100fb_get_mode(par, &par->xres, &par->yres, 0);
527*4882a593Smuzhiyun
528*4882a593Smuzhiyun info->fix.visual = FB_VISUAL_TRUECOLOR;
529*4882a593Smuzhiyun info->fix.ypanstep = 0;
530*4882a593Smuzhiyun info->fix.ywrapstep = 0;
531*4882a593Smuzhiyun info->fix.line_length = par->xres * BITS_PER_PIXEL / 8;
532*4882a593Smuzhiyun
533*4882a593Smuzhiyun mutex_lock(&info->mm_lock);
534*4882a593Smuzhiyun if ((par->xres*par->yres*BITS_PER_PIXEL/8) > (MEM_INT_SIZE+1)) {
535*4882a593Smuzhiyun par->extmem_active = 1;
536*4882a593Smuzhiyun info->fix.smem_len = par->mach->mem->size+1;
537*4882a593Smuzhiyun } else {
538*4882a593Smuzhiyun par->extmem_active = 0;
539*4882a593Smuzhiyun info->fix.smem_len = MEM_INT_SIZE+1;
540*4882a593Smuzhiyun }
541*4882a593Smuzhiyun mutex_unlock(&info->mm_lock);
542*4882a593Smuzhiyun
543*4882a593Smuzhiyun w100fb_activate_var(par);
544*4882a593Smuzhiyun }
545*4882a593Smuzhiyun return 0;
546*4882a593Smuzhiyun }
547*4882a593Smuzhiyun
548*4882a593Smuzhiyun
549*4882a593Smuzhiyun /*
550*4882a593Smuzhiyun * Frame buffer operations
551*4882a593Smuzhiyun */
552*4882a593Smuzhiyun static const struct fb_ops w100fb_ops = {
553*4882a593Smuzhiyun .owner = THIS_MODULE,
554*4882a593Smuzhiyun .fb_check_var = w100fb_check_var,
555*4882a593Smuzhiyun .fb_set_par = w100fb_set_par,
556*4882a593Smuzhiyun .fb_setcolreg = w100fb_setcolreg,
557*4882a593Smuzhiyun .fb_blank = w100fb_blank,
558*4882a593Smuzhiyun .fb_fillrect = w100fb_fillrect,
559*4882a593Smuzhiyun .fb_copyarea = w100fb_copyarea,
560*4882a593Smuzhiyun .fb_imageblit = cfb_imageblit,
561*4882a593Smuzhiyun .fb_sync = w100fb_sync,
562*4882a593Smuzhiyun };
563*4882a593Smuzhiyun
564*4882a593Smuzhiyun #ifdef CONFIG_PM
w100fb_save_vidmem(struct w100fb_par * par)565*4882a593Smuzhiyun static void w100fb_save_vidmem(struct w100fb_par *par)
566*4882a593Smuzhiyun {
567*4882a593Smuzhiyun int memsize;
568*4882a593Smuzhiyun
569*4882a593Smuzhiyun if (par->extmem_active) {
570*4882a593Smuzhiyun memsize=par->mach->mem->size;
571*4882a593Smuzhiyun par->saved_extmem = vmalloc(memsize);
572*4882a593Smuzhiyun if (par->saved_extmem)
573*4882a593Smuzhiyun memcpy_fromio(par->saved_extmem, remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), memsize);
574*4882a593Smuzhiyun }
575*4882a593Smuzhiyun memsize=MEM_INT_SIZE;
576*4882a593Smuzhiyun par->saved_intmem = vmalloc(memsize);
577*4882a593Smuzhiyun if (par->saved_intmem && par->extmem_active)
578*4882a593Smuzhiyun memcpy_fromio(par->saved_intmem, remapped_fbuf + (W100_FB_BASE-MEM_INT_BASE_VALUE), memsize);
579*4882a593Smuzhiyun else if (par->saved_intmem)
580*4882a593Smuzhiyun memcpy_fromio(par->saved_intmem, remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), memsize);
581*4882a593Smuzhiyun }
582*4882a593Smuzhiyun
w100fb_restore_vidmem(struct w100fb_par * par)583*4882a593Smuzhiyun static void w100fb_restore_vidmem(struct w100fb_par *par)
584*4882a593Smuzhiyun {
585*4882a593Smuzhiyun int memsize;
586*4882a593Smuzhiyun
587*4882a593Smuzhiyun if (par->extmem_active && par->saved_extmem) {
588*4882a593Smuzhiyun memsize=par->mach->mem->size;
589*4882a593Smuzhiyun memcpy_toio(remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), par->saved_extmem, memsize);
590*4882a593Smuzhiyun vfree(par->saved_extmem);
591*4882a593Smuzhiyun par->saved_extmem = NULL;
592*4882a593Smuzhiyun }
593*4882a593Smuzhiyun if (par->saved_intmem) {
594*4882a593Smuzhiyun memsize=MEM_INT_SIZE;
595*4882a593Smuzhiyun if (par->extmem_active)
596*4882a593Smuzhiyun memcpy_toio(remapped_fbuf + (W100_FB_BASE-MEM_INT_BASE_VALUE), par->saved_intmem, memsize);
597*4882a593Smuzhiyun else
598*4882a593Smuzhiyun memcpy_toio(remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), par->saved_intmem, memsize);
599*4882a593Smuzhiyun vfree(par->saved_intmem);
600*4882a593Smuzhiyun par->saved_intmem = NULL;
601*4882a593Smuzhiyun }
602*4882a593Smuzhiyun }
603*4882a593Smuzhiyun
w100fb_suspend(struct platform_device * dev,pm_message_t state)604*4882a593Smuzhiyun static int w100fb_suspend(struct platform_device *dev, pm_message_t state)
605*4882a593Smuzhiyun {
606*4882a593Smuzhiyun struct fb_info *info = platform_get_drvdata(dev);
607*4882a593Smuzhiyun struct w100fb_par *par=info->par;
608*4882a593Smuzhiyun struct w100_tg_info *tg = par->mach->tg;
609*4882a593Smuzhiyun
610*4882a593Smuzhiyun w100fb_save_vidmem(par);
611*4882a593Smuzhiyun if(tg && tg->suspend)
612*4882a593Smuzhiyun tg->suspend(par);
613*4882a593Smuzhiyun w100_suspend(W100_SUSPEND_ALL);
614*4882a593Smuzhiyun par->blanked = 1;
615*4882a593Smuzhiyun
616*4882a593Smuzhiyun return 0;
617*4882a593Smuzhiyun }
618*4882a593Smuzhiyun
w100fb_resume(struct platform_device * dev)619*4882a593Smuzhiyun static int w100fb_resume(struct platform_device *dev)
620*4882a593Smuzhiyun {
621*4882a593Smuzhiyun struct fb_info *info = platform_get_drvdata(dev);
622*4882a593Smuzhiyun struct w100fb_par *par=info->par;
623*4882a593Smuzhiyun struct w100_tg_info *tg = par->mach->tg;
624*4882a593Smuzhiyun
625*4882a593Smuzhiyun w100_hw_init(par);
626*4882a593Smuzhiyun w100fb_activate_var(par);
627*4882a593Smuzhiyun w100fb_restore_vidmem(par);
628*4882a593Smuzhiyun if(tg && tg->resume)
629*4882a593Smuzhiyun tg->resume(par);
630*4882a593Smuzhiyun par->blanked = 0;
631*4882a593Smuzhiyun
632*4882a593Smuzhiyun return 0;
633*4882a593Smuzhiyun }
634*4882a593Smuzhiyun #else
635*4882a593Smuzhiyun #define w100fb_suspend NULL
636*4882a593Smuzhiyun #define w100fb_resume NULL
637*4882a593Smuzhiyun #endif
638*4882a593Smuzhiyun
639*4882a593Smuzhiyun
w100fb_probe(struct platform_device * pdev)640*4882a593Smuzhiyun static int w100fb_probe(struct platform_device *pdev)
641*4882a593Smuzhiyun {
642*4882a593Smuzhiyun int err = -EIO;
643*4882a593Smuzhiyun struct w100fb_mach_info *inf;
644*4882a593Smuzhiyun struct fb_info *info = NULL;
645*4882a593Smuzhiyun struct w100fb_par *par;
646*4882a593Smuzhiyun struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
647*4882a593Smuzhiyun unsigned int chip_id;
648*4882a593Smuzhiyun
649*4882a593Smuzhiyun if (!mem)
650*4882a593Smuzhiyun return -EINVAL;
651*4882a593Smuzhiyun
652*4882a593Smuzhiyun /* Remap the chip base address */
653*4882a593Smuzhiyun remapped_base = ioremap(mem->start+W100_CFG_BASE, W100_CFG_LEN);
654*4882a593Smuzhiyun if (remapped_base == NULL)
655*4882a593Smuzhiyun goto out;
656*4882a593Smuzhiyun
657*4882a593Smuzhiyun /* Map the register space */
658*4882a593Smuzhiyun remapped_regs = ioremap(mem->start+W100_REG_BASE, W100_REG_LEN);
659*4882a593Smuzhiyun if (remapped_regs == NULL)
660*4882a593Smuzhiyun goto out;
661*4882a593Smuzhiyun
662*4882a593Smuzhiyun /* Identify the chip */
663*4882a593Smuzhiyun printk("Found ");
664*4882a593Smuzhiyun chip_id = readl(remapped_regs + mmCHIP_ID);
665*4882a593Smuzhiyun switch(chip_id) {
666*4882a593Smuzhiyun case CHIP_ID_W100: printk("w100"); break;
667*4882a593Smuzhiyun case CHIP_ID_W3200: printk("w3200"); break;
668*4882a593Smuzhiyun case CHIP_ID_W3220: printk("w3220"); break;
669*4882a593Smuzhiyun default:
670*4882a593Smuzhiyun printk("Unknown imageon chip ID\n");
671*4882a593Smuzhiyun err = -ENODEV;
672*4882a593Smuzhiyun goto out;
673*4882a593Smuzhiyun }
674*4882a593Smuzhiyun printk(" at 0x%08lx.\n", (unsigned long) mem->start+W100_CFG_BASE);
675*4882a593Smuzhiyun
676*4882a593Smuzhiyun /* Remap the framebuffer */
677*4882a593Smuzhiyun remapped_fbuf = ioremap(mem->start+MEM_WINDOW_BASE, MEM_WINDOW_SIZE);
678*4882a593Smuzhiyun if (remapped_fbuf == NULL)
679*4882a593Smuzhiyun goto out;
680*4882a593Smuzhiyun
681*4882a593Smuzhiyun info=framebuffer_alloc(sizeof(struct w100fb_par), &pdev->dev);
682*4882a593Smuzhiyun if (!info) {
683*4882a593Smuzhiyun err = -ENOMEM;
684*4882a593Smuzhiyun goto out;
685*4882a593Smuzhiyun }
686*4882a593Smuzhiyun
687*4882a593Smuzhiyun par = info->par;
688*4882a593Smuzhiyun platform_set_drvdata(pdev, info);
689*4882a593Smuzhiyun
690*4882a593Smuzhiyun inf = dev_get_platdata(&pdev->dev);
691*4882a593Smuzhiyun par->chip_id = chip_id;
692*4882a593Smuzhiyun par->mach = inf;
693*4882a593Smuzhiyun par->fastpll_mode = 0;
694*4882a593Smuzhiyun par->blanked = 0;
695*4882a593Smuzhiyun
696*4882a593Smuzhiyun par->pll_table=w100_get_xtal_table(inf->xtal_freq);
697*4882a593Smuzhiyun if (!par->pll_table) {
698*4882a593Smuzhiyun printk(KERN_ERR "No matching Xtal definition found\n");
699*4882a593Smuzhiyun err = -EINVAL;
700*4882a593Smuzhiyun goto out;
701*4882a593Smuzhiyun }
702*4882a593Smuzhiyun
703*4882a593Smuzhiyun info->pseudo_palette = kmalloc_array(MAX_PALETTES, sizeof(u32),
704*4882a593Smuzhiyun GFP_KERNEL);
705*4882a593Smuzhiyun if (!info->pseudo_palette) {
706*4882a593Smuzhiyun err = -ENOMEM;
707*4882a593Smuzhiyun goto out;
708*4882a593Smuzhiyun }
709*4882a593Smuzhiyun
710*4882a593Smuzhiyun info->fbops = &w100fb_ops;
711*4882a593Smuzhiyun info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA |
712*4882a593Smuzhiyun FBINFO_HWACCEL_FILLRECT;
713*4882a593Smuzhiyun info->node = -1;
714*4882a593Smuzhiyun info->screen_base = remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE);
715*4882a593Smuzhiyun info->screen_size = REMAPPED_FB_LEN;
716*4882a593Smuzhiyun
717*4882a593Smuzhiyun strcpy(info->fix.id, "w100fb");
718*4882a593Smuzhiyun info->fix.type = FB_TYPE_PACKED_PIXELS;
719*4882a593Smuzhiyun info->fix.type_aux = 0;
720*4882a593Smuzhiyun info->fix.accel = FB_ACCEL_NONE;
721*4882a593Smuzhiyun info->fix.smem_start = mem->start+W100_FB_BASE;
722*4882a593Smuzhiyun info->fix.mmio_start = mem->start+W100_REG_BASE;
723*4882a593Smuzhiyun info->fix.mmio_len = W100_REG_LEN;
724*4882a593Smuzhiyun
725*4882a593Smuzhiyun if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
726*4882a593Smuzhiyun err = -ENOMEM;
727*4882a593Smuzhiyun goto out;
728*4882a593Smuzhiyun }
729*4882a593Smuzhiyun
730*4882a593Smuzhiyun par->mode = &inf->modelist[0];
731*4882a593Smuzhiyun if(inf->init_mode & INIT_MODE_ROTATED) {
732*4882a593Smuzhiyun info->var.xres = par->mode->yres;
733*4882a593Smuzhiyun info->var.yres = par->mode->xres;
734*4882a593Smuzhiyun }
735*4882a593Smuzhiyun else {
736*4882a593Smuzhiyun info->var.xres = par->mode->xres;
737*4882a593Smuzhiyun info->var.yres = par->mode->yres;
738*4882a593Smuzhiyun }
739*4882a593Smuzhiyun
740*4882a593Smuzhiyun if(inf->init_mode &= INIT_MODE_FLIPPED)
741*4882a593Smuzhiyun par->flip = 1;
742*4882a593Smuzhiyun else
743*4882a593Smuzhiyun par->flip = 0;
744*4882a593Smuzhiyun
745*4882a593Smuzhiyun info->var.xres_virtual = info->var.xres;
746*4882a593Smuzhiyun info->var.yres_virtual = info->var.yres;
747*4882a593Smuzhiyun info->var.pixclock = 0x04; /* 171521; */
748*4882a593Smuzhiyun info->var.sync = 0;
749*4882a593Smuzhiyun info->var.grayscale = 0;
750*4882a593Smuzhiyun info->var.xoffset = info->var.yoffset = 0;
751*4882a593Smuzhiyun info->var.accel_flags = 0;
752*4882a593Smuzhiyun info->var.activate = FB_ACTIVATE_NOW;
753*4882a593Smuzhiyun
754*4882a593Smuzhiyun w100_hw_init(par);
755*4882a593Smuzhiyun
756*4882a593Smuzhiyun if (w100fb_check_var(&info->var, info) < 0) {
757*4882a593Smuzhiyun err = -EINVAL;
758*4882a593Smuzhiyun goto out;
759*4882a593Smuzhiyun }
760*4882a593Smuzhiyun
761*4882a593Smuzhiyun if (register_framebuffer(info) < 0) {
762*4882a593Smuzhiyun err = -EINVAL;
763*4882a593Smuzhiyun goto out;
764*4882a593Smuzhiyun }
765*4882a593Smuzhiyun
766*4882a593Smuzhiyun fb_info(info, "%s frame buffer device\n", info->fix.id);
767*4882a593Smuzhiyun return 0;
768*4882a593Smuzhiyun out:
769*4882a593Smuzhiyun if (info) {
770*4882a593Smuzhiyun fb_dealloc_cmap(&info->cmap);
771*4882a593Smuzhiyun kfree(info->pseudo_palette);
772*4882a593Smuzhiyun }
773*4882a593Smuzhiyun if (remapped_fbuf != NULL) {
774*4882a593Smuzhiyun iounmap(remapped_fbuf);
775*4882a593Smuzhiyun remapped_fbuf = NULL;
776*4882a593Smuzhiyun }
777*4882a593Smuzhiyun if (remapped_regs != NULL) {
778*4882a593Smuzhiyun iounmap(remapped_regs);
779*4882a593Smuzhiyun remapped_regs = NULL;
780*4882a593Smuzhiyun }
781*4882a593Smuzhiyun if (remapped_base != NULL) {
782*4882a593Smuzhiyun iounmap(remapped_base);
783*4882a593Smuzhiyun remapped_base = NULL;
784*4882a593Smuzhiyun }
785*4882a593Smuzhiyun if (info)
786*4882a593Smuzhiyun framebuffer_release(info);
787*4882a593Smuzhiyun return err;
788*4882a593Smuzhiyun }
789*4882a593Smuzhiyun
790*4882a593Smuzhiyun
w100fb_remove(struct platform_device * pdev)791*4882a593Smuzhiyun static int w100fb_remove(struct platform_device *pdev)
792*4882a593Smuzhiyun {
793*4882a593Smuzhiyun struct fb_info *info = platform_get_drvdata(pdev);
794*4882a593Smuzhiyun struct w100fb_par *par=info->par;
795*4882a593Smuzhiyun
796*4882a593Smuzhiyun unregister_framebuffer(info);
797*4882a593Smuzhiyun
798*4882a593Smuzhiyun vfree(par->saved_intmem);
799*4882a593Smuzhiyun vfree(par->saved_extmem);
800*4882a593Smuzhiyun kfree(info->pseudo_palette);
801*4882a593Smuzhiyun fb_dealloc_cmap(&info->cmap);
802*4882a593Smuzhiyun
803*4882a593Smuzhiyun iounmap(remapped_base);
804*4882a593Smuzhiyun remapped_base = NULL;
805*4882a593Smuzhiyun iounmap(remapped_regs);
806*4882a593Smuzhiyun remapped_regs = NULL;
807*4882a593Smuzhiyun iounmap(remapped_fbuf);
808*4882a593Smuzhiyun remapped_fbuf = NULL;
809*4882a593Smuzhiyun
810*4882a593Smuzhiyun framebuffer_release(info);
811*4882a593Smuzhiyun
812*4882a593Smuzhiyun return 0;
813*4882a593Smuzhiyun }
814*4882a593Smuzhiyun
815*4882a593Smuzhiyun
816*4882a593Smuzhiyun /* ------------------- chipset specific functions -------------------------- */
817*4882a593Smuzhiyun
818*4882a593Smuzhiyun
w100_soft_reset(void)819*4882a593Smuzhiyun static void w100_soft_reset(void)
820*4882a593Smuzhiyun {
821*4882a593Smuzhiyun u16 val = readw((u16 __iomem *)remapped_base + cfgSTATUS);
822*4882a593Smuzhiyun
823*4882a593Smuzhiyun writew(val | 0x08, (u16 __iomem *)remapped_base + cfgSTATUS);
824*4882a593Smuzhiyun udelay(100);
825*4882a593Smuzhiyun writew(0x00, (u16 __iomem *)remapped_base + cfgSTATUS);
826*4882a593Smuzhiyun udelay(100);
827*4882a593Smuzhiyun }
828*4882a593Smuzhiyun
w100_update_disable(void)829*4882a593Smuzhiyun static void w100_update_disable(void)
830*4882a593Smuzhiyun {
831*4882a593Smuzhiyun union disp_db_buf_cntl_wr_u disp_db_buf_wr_cntl;
832*4882a593Smuzhiyun
833*4882a593Smuzhiyun /* Prevent display updates */
834*4882a593Smuzhiyun disp_db_buf_wr_cntl.f.db_buf_cntl = 0x1e;
835*4882a593Smuzhiyun disp_db_buf_wr_cntl.f.update_db_buf = 0;
836*4882a593Smuzhiyun disp_db_buf_wr_cntl.f.en_db_buf = 0;
837*4882a593Smuzhiyun writel((u32) (disp_db_buf_wr_cntl.val), remapped_regs + mmDISP_DB_BUF_CNTL);
838*4882a593Smuzhiyun }
839*4882a593Smuzhiyun
w100_update_enable(void)840*4882a593Smuzhiyun static void w100_update_enable(void)
841*4882a593Smuzhiyun {
842*4882a593Smuzhiyun union disp_db_buf_cntl_wr_u disp_db_buf_wr_cntl;
843*4882a593Smuzhiyun
844*4882a593Smuzhiyun /* Enable display updates */
845*4882a593Smuzhiyun disp_db_buf_wr_cntl.f.db_buf_cntl = 0x1e;
846*4882a593Smuzhiyun disp_db_buf_wr_cntl.f.update_db_buf = 1;
847*4882a593Smuzhiyun disp_db_buf_wr_cntl.f.en_db_buf = 1;
848*4882a593Smuzhiyun writel((u32) (disp_db_buf_wr_cntl.val), remapped_regs + mmDISP_DB_BUF_CNTL);
849*4882a593Smuzhiyun }
850*4882a593Smuzhiyun
w100fb_gpio_read(int port)851*4882a593Smuzhiyun unsigned long w100fb_gpio_read(int port)
852*4882a593Smuzhiyun {
853*4882a593Smuzhiyun unsigned long value;
854*4882a593Smuzhiyun
855*4882a593Smuzhiyun if (port==W100_GPIO_PORT_A)
856*4882a593Smuzhiyun value = readl(remapped_regs + mmGPIO_DATA);
857*4882a593Smuzhiyun else
858*4882a593Smuzhiyun value = readl(remapped_regs + mmGPIO_DATA2);
859*4882a593Smuzhiyun
860*4882a593Smuzhiyun return value;
861*4882a593Smuzhiyun }
862*4882a593Smuzhiyun
w100fb_gpio_write(int port,unsigned long value)863*4882a593Smuzhiyun void w100fb_gpio_write(int port, unsigned long value)
864*4882a593Smuzhiyun {
865*4882a593Smuzhiyun if (port==W100_GPIO_PORT_A)
866*4882a593Smuzhiyun writel(value, remapped_regs + mmGPIO_DATA);
867*4882a593Smuzhiyun else
868*4882a593Smuzhiyun writel(value, remapped_regs + mmGPIO_DATA2);
869*4882a593Smuzhiyun }
870*4882a593Smuzhiyun EXPORT_SYMBOL(w100fb_gpio_read);
871*4882a593Smuzhiyun EXPORT_SYMBOL(w100fb_gpio_write);
872*4882a593Smuzhiyun
873*4882a593Smuzhiyun /*
874*4882a593Smuzhiyun * Initialization of critical w100 hardware
875*4882a593Smuzhiyun */
w100_hw_init(struct w100fb_par * par)876*4882a593Smuzhiyun static void w100_hw_init(struct w100fb_par *par)
877*4882a593Smuzhiyun {
878*4882a593Smuzhiyun u32 temp32;
879*4882a593Smuzhiyun union cif_cntl_u cif_cntl;
880*4882a593Smuzhiyun union intf_cntl_u intf_cntl;
881*4882a593Smuzhiyun union cfgreg_base_u cfgreg_base;
882*4882a593Smuzhiyun union wrap_top_dir_u wrap_top_dir;
883*4882a593Smuzhiyun union cif_read_dbg_u cif_read_dbg;
884*4882a593Smuzhiyun union cpu_defaults_u cpu_default;
885*4882a593Smuzhiyun union cif_write_dbg_u cif_write_dbg;
886*4882a593Smuzhiyun union wrap_start_dir_u wrap_start_dir;
887*4882a593Smuzhiyun union cif_io_u cif_io;
888*4882a593Smuzhiyun struct w100_gpio_regs *gpio = par->mach->gpio;
889*4882a593Smuzhiyun
890*4882a593Smuzhiyun w100_soft_reset();
891*4882a593Smuzhiyun
892*4882a593Smuzhiyun /* This is what the fpga_init code does on reset. May be wrong
893*4882a593Smuzhiyun but there is little info available */
894*4882a593Smuzhiyun writel(0x31, remapped_regs + mmSCRATCH_UMSK);
895*4882a593Smuzhiyun for (temp32 = 0; temp32 < 10000; temp32++)
896*4882a593Smuzhiyun readl(remapped_regs + mmSCRATCH_UMSK);
897*4882a593Smuzhiyun writel(0x30, remapped_regs + mmSCRATCH_UMSK);
898*4882a593Smuzhiyun
899*4882a593Smuzhiyun /* Set up CIF */
900*4882a593Smuzhiyun cif_io.val = defCIF_IO;
901*4882a593Smuzhiyun writel((u32)(cif_io.val), remapped_regs + mmCIF_IO);
902*4882a593Smuzhiyun
903*4882a593Smuzhiyun cif_write_dbg.val = readl(remapped_regs + mmCIF_WRITE_DBG);
904*4882a593Smuzhiyun cif_write_dbg.f.dis_packer_ful_during_rbbm_timeout = 0;
905*4882a593Smuzhiyun cif_write_dbg.f.en_dword_split_to_rbbm = 1;
906*4882a593Smuzhiyun cif_write_dbg.f.dis_timeout_during_rbbm = 1;
907*4882a593Smuzhiyun writel((u32) (cif_write_dbg.val), remapped_regs + mmCIF_WRITE_DBG);
908*4882a593Smuzhiyun
909*4882a593Smuzhiyun cif_read_dbg.val = readl(remapped_regs + mmCIF_READ_DBG);
910*4882a593Smuzhiyun cif_read_dbg.f.dis_rd_same_byte_to_trig_fetch = 1;
911*4882a593Smuzhiyun writel((u32) (cif_read_dbg.val), remapped_regs + mmCIF_READ_DBG);
912*4882a593Smuzhiyun
913*4882a593Smuzhiyun cif_cntl.val = readl(remapped_regs + mmCIF_CNTL);
914*4882a593Smuzhiyun cif_cntl.f.dis_system_bits = 1;
915*4882a593Smuzhiyun cif_cntl.f.dis_mr = 1;
916*4882a593Smuzhiyun cif_cntl.f.en_wait_to_compensate_dq_prop_dly = 0;
917*4882a593Smuzhiyun cif_cntl.f.intb_oe = 1;
918*4882a593Smuzhiyun cif_cntl.f.interrupt_active_high = 1;
919*4882a593Smuzhiyun writel((u32) (cif_cntl.val), remapped_regs + mmCIF_CNTL);
920*4882a593Smuzhiyun
921*4882a593Smuzhiyun /* Setup cfgINTF_CNTL and cfgCPU defaults */
922*4882a593Smuzhiyun intf_cntl.val = defINTF_CNTL;
923*4882a593Smuzhiyun intf_cntl.f.ad_inc_a = 1;
924*4882a593Smuzhiyun intf_cntl.f.ad_inc_b = 1;
925*4882a593Smuzhiyun intf_cntl.f.rd_data_rdy_a = 0;
926*4882a593Smuzhiyun intf_cntl.f.rd_data_rdy_b = 0;
927*4882a593Smuzhiyun writeb((u8) (intf_cntl.val), remapped_base + cfgINTF_CNTL);
928*4882a593Smuzhiyun
929*4882a593Smuzhiyun cpu_default.val = defCPU_DEFAULTS;
930*4882a593Smuzhiyun cpu_default.f.access_ind_addr_a = 1;
931*4882a593Smuzhiyun cpu_default.f.access_ind_addr_b = 1;
932*4882a593Smuzhiyun cpu_default.f.access_scratch_reg = 1;
933*4882a593Smuzhiyun cpu_default.f.transition_size = 0;
934*4882a593Smuzhiyun writeb((u8) (cpu_default.val), remapped_base + cfgCPU_DEFAULTS);
935*4882a593Smuzhiyun
936*4882a593Smuzhiyun /* set up the apertures */
937*4882a593Smuzhiyun writeb((u8) (W100_REG_BASE >> 16), remapped_base + cfgREG_BASE);
938*4882a593Smuzhiyun
939*4882a593Smuzhiyun cfgreg_base.val = defCFGREG_BASE;
940*4882a593Smuzhiyun cfgreg_base.f.cfgreg_base = W100_CFG_BASE;
941*4882a593Smuzhiyun writel((u32) (cfgreg_base.val), remapped_regs + mmCFGREG_BASE);
942*4882a593Smuzhiyun
943*4882a593Smuzhiyun wrap_start_dir.val = defWRAP_START_DIR;
944*4882a593Smuzhiyun wrap_start_dir.f.start_addr = WRAP_BUF_BASE_VALUE >> 1;
945*4882a593Smuzhiyun writel((u32) (wrap_start_dir.val), remapped_regs + mmWRAP_START_DIR);
946*4882a593Smuzhiyun
947*4882a593Smuzhiyun wrap_top_dir.val = defWRAP_TOP_DIR;
948*4882a593Smuzhiyun wrap_top_dir.f.top_addr = WRAP_BUF_TOP_VALUE >> 1;
949*4882a593Smuzhiyun writel((u32) (wrap_top_dir.val), remapped_regs + mmWRAP_TOP_DIR);
950*4882a593Smuzhiyun
951*4882a593Smuzhiyun writel((u32) 0x2440, remapped_regs + mmRBBM_CNTL);
952*4882a593Smuzhiyun
953*4882a593Smuzhiyun /* Set the hardware to 565 colour */
954*4882a593Smuzhiyun temp32 = readl(remapped_regs + mmDISP_DEBUG2);
955*4882a593Smuzhiyun temp32 &= 0xff7fffff;
956*4882a593Smuzhiyun temp32 |= 0x00800000;
957*4882a593Smuzhiyun writel(temp32, remapped_regs + mmDISP_DEBUG2);
958*4882a593Smuzhiyun
959*4882a593Smuzhiyun /* Initialise the GPIO lines */
960*4882a593Smuzhiyun if (gpio) {
961*4882a593Smuzhiyun writel(gpio->init_data1, remapped_regs + mmGPIO_DATA);
962*4882a593Smuzhiyun writel(gpio->init_data2, remapped_regs + mmGPIO_DATA2);
963*4882a593Smuzhiyun writel(gpio->gpio_dir1, remapped_regs + mmGPIO_CNTL1);
964*4882a593Smuzhiyun writel(gpio->gpio_oe1, remapped_regs + mmGPIO_CNTL2);
965*4882a593Smuzhiyun writel(gpio->gpio_dir2, remapped_regs + mmGPIO_CNTL3);
966*4882a593Smuzhiyun writel(gpio->gpio_oe2, remapped_regs + mmGPIO_CNTL4);
967*4882a593Smuzhiyun }
968*4882a593Smuzhiyun }
969*4882a593Smuzhiyun
970*4882a593Smuzhiyun
971*4882a593Smuzhiyun struct power_state {
972*4882a593Smuzhiyun union clk_pin_cntl_u clk_pin_cntl;
973*4882a593Smuzhiyun union pll_ref_fb_div_u pll_ref_fb_div;
974*4882a593Smuzhiyun union pll_cntl_u pll_cntl;
975*4882a593Smuzhiyun union sclk_cntl_u sclk_cntl;
976*4882a593Smuzhiyun union pclk_cntl_u pclk_cntl;
977*4882a593Smuzhiyun union pwrmgt_cntl_u pwrmgt_cntl;
978*4882a593Smuzhiyun int auto_mode; /* system clock auto changing? */
979*4882a593Smuzhiyun };
980*4882a593Smuzhiyun
981*4882a593Smuzhiyun
982*4882a593Smuzhiyun static struct power_state w100_pwr_state;
983*4882a593Smuzhiyun
984*4882a593Smuzhiyun /* The PLL Fout is determined by (XtalFreq/(M+1)) * ((N_int+1) + (N_fac/8)) */
985*4882a593Smuzhiyun
986*4882a593Smuzhiyun /* 12.5MHz Crystal PLL Table */
987*4882a593Smuzhiyun static struct w100_pll_info xtal_12500000[] = {
988*4882a593Smuzhiyun /*freq M N_int N_fac tfgoal lock_time */
989*4882a593Smuzhiyun { 50, 0, 1, 0, 0xe0, 56}, /* 50.00 MHz */
990*4882a593Smuzhiyun { 75, 0, 5, 0, 0xde, 37}, /* 75.00 MHz */
991*4882a593Smuzhiyun {100, 0, 7, 0, 0xe0, 28}, /* 100.00 MHz */
992*4882a593Smuzhiyun {125, 0, 9, 0, 0xe0, 22}, /* 125.00 MHz */
993*4882a593Smuzhiyun {150, 0, 11, 0, 0xe0, 17}, /* 150.00 MHz */
994*4882a593Smuzhiyun { 0, 0, 0, 0, 0, 0}, /* Terminator */
995*4882a593Smuzhiyun };
996*4882a593Smuzhiyun
997*4882a593Smuzhiyun /* 14.318MHz Crystal PLL Table */
998*4882a593Smuzhiyun static struct w100_pll_info xtal_14318000[] = {
999*4882a593Smuzhiyun /*freq M N_int N_fac tfgoal lock_time */
1000*4882a593Smuzhiyun { 40, 4, 13, 0, 0xe0, 80}, /* tfgoal guessed */
1001*4882a593Smuzhiyun { 50, 1, 6, 0, 0xe0, 64}, /* 50.05 MHz */
1002*4882a593Smuzhiyun { 57, 2, 11, 0, 0xe0, 53}, /* tfgoal guessed */
1003*4882a593Smuzhiyun { 75, 0, 4, 3, 0xe0, 43}, /* 75.08 MHz */
1004*4882a593Smuzhiyun {100, 0, 6, 0, 0xe0, 32}, /* 100.10 MHz */
1005*4882a593Smuzhiyun { 0, 0, 0, 0, 0, 0},
1006*4882a593Smuzhiyun };
1007*4882a593Smuzhiyun
1008*4882a593Smuzhiyun /* 16MHz Crystal PLL Table */
1009*4882a593Smuzhiyun static struct w100_pll_info xtal_16000000[] = {
1010*4882a593Smuzhiyun /*freq M N_int N_fac tfgoal lock_time */
1011*4882a593Smuzhiyun { 72, 1, 8, 0, 0xe0, 48}, /* tfgoal guessed */
1012*4882a593Smuzhiyun { 80, 1, 9, 0, 0xe0, 13}, /* tfgoal guessed */
1013*4882a593Smuzhiyun { 95, 1, 10, 7, 0xe0, 38}, /* tfgoal guessed */
1014*4882a593Smuzhiyun { 96, 1, 11, 0, 0xe0, 36}, /* tfgoal guessed */
1015*4882a593Smuzhiyun { 0, 0, 0, 0, 0, 0},
1016*4882a593Smuzhiyun };
1017*4882a593Smuzhiyun
1018*4882a593Smuzhiyun static struct pll_entries {
1019*4882a593Smuzhiyun int xtal_freq;
1020*4882a593Smuzhiyun struct w100_pll_info *pll_table;
1021*4882a593Smuzhiyun } w100_pll_tables[] = {
1022*4882a593Smuzhiyun { 12500000, &xtal_12500000[0] },
1023*4882a593Smuzhiyun { 14318000, &xtal_14318000[0] },
1024*4882a593Smuzhiyun { 16000000, &xtal_16000000[0] },
1025*4882a593Smuzhiyun { 0 },
1026*4882a593Smuzhiyun };
1027*4882a593Smuzhiyun
w100_get_xtal_table(unsigned int freq)1028*4882a593Smuzhiyun struct w100_pll_info *w100_get_xtal_table(unsigned int freq)
1029*4882a593Smuzhiyun {
1030*4882a593Smuzhiyun struct pll_entries *pll_entry = w100_pll_tables;
1031*4882a593Smuzhiyun
1032*4882a593Smuzhiyun do {
1033*4882a593Smuzhiyun if (freq == pll_entry->xtal_freq)
1034*4882a593Smuzhiyun return pll_entry->pll_table;
1035*4882a593Smuzhiyun pll_entry++;
1036*4882a593Smuzhiyun } while (pll_entry->xtal_freq);
1037*4882a593Smuzhiyun
1038*4882a593Smuzhiyun return NULL;
1039*4882a593Smuzhiyun }
1040*4882a593Smuzhiyun
1041*4882a593Smuzhiyun
w100_get_testcount(unsigned int testclk_sel)1042*4882a593Smuzhiyun static unsigned int w100_get_testcount(unsigned int testclk_sel)
1043*4882a593Smuzhiyun {
1044*4882a593Smuzhiyun union clk_test_cntl_u clk_test_cntl;
1045*4882a593Smuzhiyun
1046*4882a593Smuzhiyun udelay(5);
1047*4882a593Smuzhiyun
1048*4882a593Smuzhiyun /* Select the test clock source and reset */
1049*4882a593Smuzhiyun clk_test_cntl.f.start_check_freq = 0x0;
1050*4882a593Smuzhiyun clk_test_cntl.f.testclk_sel = testclk_sel;
1051*4882a593Smuzhiyun clk_test_cntl.f.tstcount_rst = 0x1; /* set reset */
1052*4882a593Smuzhiyun writel((u32) (clk_test_cntl.val), remapped_regs + mmCLK_TEST_CNTL);
1053*4882a593Smuzhiyun
1054*4882a593Smuzhiyun clk_test_cntl.f.tstcount_rst = 0x0; /* clear reset */
1055*4882a593Smuzhiyun writel((u32) (clk_test_cntl.val), remapped_regs + mmCLK_TEST_CNTL);
1056*4882a593Smuzhiyun
1057*4882a593Smuzhiyun /* Run clock test */
1058*4882a593Smuzhiyun clk_test_cntl.f.start_check_freq = 0x1;
1059*4882a593Smuzhiyun writel((u32) (clk_test_cntl.val), remapped_regs + mmCLK_TEST_CNTL);
1060*4882a593Smuzhiyun
1061*4882a593Smuzhiyun /* Give the test time to complete */
1062*4882a593Smuzhiyun udelay(20);
1063*4882a593Smuzhiyun
1064*4882a593Smuzhiyun /* Return the result */
1065*4882a593Smuzhiyun clk_test_cntl.val = readl(remapped_regs + mmCLK_TEST_CNTL);
1066*4882a593Smuzhiyun clk_test_cntl.f.start_check_freq = 0x0;
1067*4882a593Smuzhiyun writel((u32) (clk_test_cntl.val), remapped_regs + mmCLK_TEST_CNTL);
1068*4882a593Smuzhiyun
1069*4882a593Smuzhiyun return clk_test_cntl.f.test_count;
1070*4882a593Smuzhiyun }
1071*4882a593Smuzhiyun
1072*4882a593Smuzhiyun
w100_pll_adjust(struct w100_pll_info * pll)1073*4882a593Smuzhiyun static int w100_pll_adjust(struct w100_pll_info *pll)
1074*4882a593Smuzhiyun {
1075*4882a593Smuzhiyun unsigned int tf80;
1076*4882a593Smuzhiyun unsigned int tf20;
1077*4882a593Smuzhiyun
1078*4882a593Smuzhiyun /* Initial Settings */
1079*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_pwdn = 0x0; /* power down */
1080*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_reset = 0x0; /* not reset */
1081*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_tcpoff = 0x1; /* Hi-Z */
1082*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_pvg = 0x0; /* VCO gain = 0 */
1083*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_vcofr = 0x0; /* VCO frequency range control = off */
1084*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_ioffset = 0x0; /* current offset inside VCO = 0 */
1085*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_ring_off = 0x0;
1086*4882a593Smuzhiyun
1087*4882a593Smuzhiyun /* Wai Ming 80 percent of VDD 1.3V gives 1.04V, minimum operating voltage is 1.08V
1088*4882a593Smuzhiyun * therefore, commented out the following lines
1089*4882a593Smuzhiyun * tf80 meant tf100
1090*4882a593Smuzhiyun */
1091*4882a593Smuzhiyun do {
1092*4882a593Smuzhiyun /* set VCO input = 0.8 * VDD */
1093*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_dactal = 0xd;
1094*4882a593Smuzhiyun writel((u32) (w100_pwr_state.pll_cntl.val), remapped_regs + mmPLL_CNTL);
1095*4882a593Smuzhiyun
1096*4882a593Smuzhiyun tf80 = w100_get_testcount(TESTCLK_SRC_PLL);
1097*4882a593Smuzhiyun if (tf80 >= (pll->tfgoal)) {
1098*4882a593Smuzhiyun /* set VCO input = 0.2 * VDD */
1099*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_dactal = 0x7;
1100*4882a593Smuzhiyun writel((u32) (w100_pwr_state.pll_cntl.val), remapped_regs + mmPLL_CNTL);
1101*4882a593Smuzhiyun
1102*4882a593Smuzhiyun tf20 = w100_get_testcount(TESTCLK_SRC_PLL);
1103*4882a593Smuzhiyun if (tf20 <= (pll->tfgoal))
1104*4882a593Smuzhiyun return 1; /* Success */
1105*4882a593Smuzhiyun
1106*4882a593Smuzhiyun if ((w100_pwr_state.pll_cntl.f.pll_vcofr == 0x0) &&
1107*4882a593Smuzhiyun ((w100_pwr_state.pll_cntl.f.pll_pvg == 0x7) ||
1108*4882a593Smuzhiyun (w100_pwr_state.pll_cntl.f.pll_ioffset == 0x0))) {
1109*4882a593Smuzhiyun /* slow VCO config */
1110*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_vcofr = 0x1;
1111*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_pvg = 0x0;
1112*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_ioffset = 0x0;
1113*4882a593Smuzhiyun continue;
1114*4882a593Smuzhiyun }
1115*4882a593Smuzhiyun }
1116*4882a593Smuzhiyun if ((w100_pwr_state.pll_cntl.f.pll_ioffset) < 0x3) {
1117*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_ioffset += 0x1;
1118*4882a593Smuzhiyun } else if ((w100_pwr_state.pll_cntl.f.pll_pvg) < 0x7) {
1119*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_ioffset = 0x0;
1120*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_pvg += 0x1;
1121*4882a593Smuzhiyun } else {
1122*4882a593Smuzhiyun return 0; /* Error */
1123*4882a593Smuzhiyun }
1124*4882a593Smuzhiyun } while(1);
1125*4882a593Smuzhiyun }
1126*4882a593Smuzhiyun
1127*4882a593Smuzhiyun
1128*4882a593Smuzhiyun /*
1129*4882a593Smuzhiyun * w100_pll_calibration
1130*4882a593Smuzhiyun */
w100_pll_calibration(struct w100_pll_info * pll)1131*4882a593Smuzhiyun static int w100_pll_calibration(struct w100_pll_info *pll)
1132*4882a593Smuzhiyun {
1133*4882a593Smuzhiyun int status;
1134*4882a593Smuzhiyun
1135*4882a593Smuzhiyun status = w100_pll_adjust(pll);
1136*4882a593Smuzhiyun
1137*4882a593Smuzhiyun /* PLL Reset And Lock */
1138*4882a593Smuzhiyun /* set VCO input = 0.5 * VDD */
1139*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_dactal = 0xa;
1140*4882a593Smuzhiyun writel((u32) (w100_pwr_state.pll_cntl.val), remapped_regs + mmPLL_CNTL);
1141*4882a593Smuzhiyun
1142*4882a593Smuzhiyun udelay(1); /* reset time */
1143*4882a593Smuzhiyun
1144*4882a593Smuzhiyun /* enable charge pump */
1145*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_tcpoff = 0x0; /* normal */
1146*4882a593Smuzhiyun writel((u32) (w100_pwr_state.pll_cntl.val), remapped_regs + mmPLL_CNTL);
1147*4882a593Smuzhiyun
1148*4882a593Smuzhiyun /* set VCO input = Hi-Z, disable DAC */
1149*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_dactal = 0x0;
1150*4882a593Smuzhiyun writel((u32) (w100_pwr_state.pll_cntl.val), remapped_regs + mmPLL_CNTL);
1151*4882a593Smuzhiyun
1152*4882a593Smuzhiyun udelay(400); /* lock time */
1153*4882a593Smuzhiyun
1154*4882a593Smuzhiyun /* PLL locked */
1155*4882a593Smuzhiyun
1156*4882a593Smuzhiyun return status;
1157*4882a593Smuzhiyun }
1158*4882a593Smuzhiyun
1159*4882a593Smuzhiyun
w100_pll_set_clk(struct w100_pll_info * pll)1160*4882a593Smuzhiyun static int w100_pll_set_clk(struct w100_pll_info *pll)
1161*4882a593Smuzhiyun {
1162*4882a593Smuzhiyun int status;
1163*4882a593Smuzhiyun
1164*4882a593Smuzhiyun if (w100_pwr_state.auto_mode == 1) /* auto mode */
1165*4882a593Smuzhiyun {
1166*4882a593Smuzhiyun w100_pwr_state.pwrmgt_cntl.f.pwm_fast_noml_hw_en = 0x0; /* disable fast to normal */
1167*4882a593Smuzhiyun w100_pwr_state.pwrmgt_cntl.f.pwm_noml_fast_hw_en = 0x0; /* disable normal to fast */
1168*4882a593Smuzhiyun writel((u32) (w100_pwr_state.pwrmgt_cntl.val), remapped_regs + mmPWRMGT_CNTL);
1169*4882a593Smuzhiyun }
1170*4882a593Smuzhiyun
1171*4882a593Smuzhiyun /* Set system clock source to XTAL whilst adjusting the PLL! */
1172*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_src_sel = CLK_SRC_XTAL;
1173*4882a593Smuzhiyun writel((u32) (w100_pwr_state.sclk_cntl.val), remapped_regs + mmSCLK_CNTL);
1174*4882a593Smuzhiyun
1175*4882a593Smuzhiyun w100_pwr_state.pll_ref_fb_div.f.pll_ref_div = pll->M;
1176*4882a593Smuzhiyun w100_pwr_state.pll_ref_fb_div.f.pll_fb_div_int = pll->N_int;
1177*4882a593Smuzhiyun w100_pwr_state.pll_ref_fb_div.f.pll_fb_div_frac = pll->N_fac;
1178*4882a593Smuzhiyun w100_pwr_state.pll_ref_fb_div.f.pll_lock_time = pll->lock_time;
1179*4882a593Smuzhiyun writel((u32) (w100_pwr_state.pll_ref_fb_div.val), remapped_regs + mmPLL_REF_FB_DIV);
1180*4882a593Smuzhiyun
1181*4882a593Smuzhiyun w100_pwr_state.pwrmgt_cntl.f.pwm_mode_req = 0;
1182*4882a593Smuzhiyun writel((u32) (w100_pwr_state.pwrmgt_cntl.val), remapped_regs + mmPWRMGT_CNTL);
1183*4882a593Smuzhiyun
1184*4882a593Smuzhiyun status = w100_pll_calibration(pll);
1185*4882a593Smuzhiyun
1186*4882a593Smuzhiyun if (w100_pwr_state.auto_mode == 1) /* auto mode */
1187*4882a593Smuzhiyun {
1188*4882a593Smuzhiyun w100_pwr_state.pwrmgt_cntl.f.pwm_fast_noml_hw_en = 0x1; /* reenable fast to normal */
1189*4882a593Smuzhiyun w100_pwr_state.pwrmgt_cntl.f.pwm_noml_fast_hw_en = 0x1; /* reenable normal to fast */
1190*4882a593Smuzhiyun writel((u32) (w100_pwr_state.pwrmgt_cntl.val), remapped_regs + mmPWRMGT_CNTL);
1191*4882a593Smuzhiyun }
1192*4882a593Smuzhiyun return status;
1193*4882a593Smuzhiyun }
1194*4882a593Smuzhiyun
1195*4882a593Smuzhiyun /* freq = target frequency of the PLL */
w100_set_pll_freq(struct w100fb_par * par,unsigned int freq)1196*4882a593Smuzhiyun static int w100_set_pll_freq(struct w100fb_par *par, unsigned int freq)
1197*4882a593Smuzhiyun {
1198*4882a593Smuzhiyun struct w100_pll_info *pll = par->pll_table;
1199*4882a593Smuzhiyun
1200*4882a593Smuzhiyun do {
1201*4882a593Smuzhiyun if (freq == pll->freq) {
1202*4882a593Smuzhiyun return w100_pll_set_clk(pll);
1203*4882a593Smuzhiyun }
1204*4882a593Smuzhiyun pll++;
1205*4882a593Smuzhiyun } while(pll->freq);
1206*4882a593Smuzhiyun return 0;
1207*4882a593Smuzhiyun }
1208*4882a593Smuzhiyun
1209*4882a593Smuzhiyun /* Set up an initial state. Some values/fields set
1210*4882a593Smuzhiyun here will be overwritten. */
w100_pwm_setup(struct w100fb_par * par)1211*4882a593Smuzhiyun static void w100_pwm_setup(struct w100fb_par *par)
1212*4882a593Smuzhiyun {
1213*4882a593Smuzhiyun w100_pwr_state.clk_pin_cntl.f.osc_en = 0x1;
1214*4882a593Smuzhiyun w100_pwr_state.clk_pin_cntl.f.osc_gain = 0x1f;
1215*4882a593Smuzhiyun w100_pwr_state.clk_pin_cntl.f.dont_use_xtalin = 0x0;
1216*4882a593Smuzhiyun w100_pwr_state.clk_pin_cntl.f.xtalin_pm_en = 0x0;
1217*4882a593Smuzhiyun w100_pwr_state.clk_pin_cntl.f.xtalin_dbl_en = par->mach->xtal_dbl ? 1 : 0;
1218*4882a593Smuzhiyun w100_pwr_state.clk_pin_cntl.f.cg_debug = 0x0;
1219*4882a593Smuzhiyun writel((u32) (w100_pwr_state.clk_pin_cntl.val), remapped_regs + mmCLK_PIN_CNTL);
1220*4882a593Smuzhiyun
1221*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_src_sel = CLK_SRC_XTAL;
1222*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_post_div_fast = 0x0; /* Pfast = 1 */
1223*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_clkon_hys = 0x3;
1224*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_post_div_slow = 0x0; /* Pslow = 1 */
1225*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.disp_cg_ok2switch_en = 0x0;
1226*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_force_reg = 0x0; /* Dynamic */
1227*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_force_disp = 0x0; /* Dynamic */
1228*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_force_mc = 0x0; /* Dynamic */
1229*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_force_extmc = 0x0; /* Dynamic */
1230*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_force_cp = 0x0; /* Dynamic */
1231*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_force_e2 = 0x0; /* Dynamic */
1232*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_force_e3 = 0x0; /* Dynamic */
1233*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_force_idct = 0x0; /* Dynamic */
1234*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_force_bist = 0x0; /* Dynamic */
1235*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.busy_extend_cp = 0x0;
1236*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.busy_extend_e2 = 0x0;
1237*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.busy_extend_e3 = 0x0;
1238*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.busy_extend_idct = 0x0;
1239*4882a593Smuzhiyun writel((u32) (w100_pwr_state.sclk_cntl.val), remapped_regs + mmSCLK_CNTL);
1240*4882a593Smuzhiyun
1241*4882a593Smuzhiyun w100_pwr_state.pclk_cntl.f.pclk_src_sel = CLK_SRC_XTAL;
1242*4882a593Smuzhiyun w100_pwr_state.pclk_cntl.f.pclk_post_div = 0x1; /* P = 2 */
1243*4882a593Smuzhiyun w100_pwr_state.pclk_cntl.f.pclk_force_disp = 0x0; /* Dynamic */
1244*4882a593Smuzhiyun writel((u32) (w100_pwr_state.pclk_cntl.val), remapped_regs + mmPCLK_CNTL);
1245*4882a593Smuzhiyun
1246*4882a593Smuzhiyun w100_pwr_state.pll_ref_fb_div.f.pll_ref_div = 0x0; /* M = 1 */
1247*4882a593Smuzhiyun w100_pwr_state.pll_ref_fb_div.f.pll_fb_div_int = 0x0; /* N = 1.0 */
1248*4882a593Smuzhiyun w100_pwr_state.pll_ref_fb_div.f.pll_fb_div_frac = 0x0;
1249*4882a593Smuzhiyun w100_pwr_state.pll_ref_fb_div.f.pll_reset_time = 0x5;
1250*4882a593Smuzhiyun w100_pwr_state.pll_ref_fb_div.f.pll_lock_time = 0xff;
1251*4882a593Smuzhiyun writel((u32) (w100_pwr_state.pll_ref_fb_div.val), remapped_regs + mmPLL_REF_FB_DIV);
1252*4882a593Smuzhiyun
1253*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_pwdn = 0x1;
1254*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_reset = 0x1;
1255*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_pm_en = 0x0;
1256*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_mode = 0x0; /* uses VCO clock */
1257*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_refclk_sel = 0x0;
1258*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_fbclk_sel = 0x0;
1259*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_tcpoff = 0x0;
1260*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_pcp = 0x4;
1261*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_pvg = 0x0;
1262*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_vcofr = 0x0;
1263*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_ioffset = 0x0;
1264*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_pecc_mode = 0x0;
1265*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_pecc_scon = 0x0;
1266*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_dactal = 0x0; /* Hi-Z */
1267*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_cp_clip = 0x3;
1268*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_conf = 0x2;
1269*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_mbctrl = 0x2;
1270*4882a593Smuzhiyun w100_pwr_state.pll_cntl.f.pll_ring_off = 0x0;
1271*4882a593Smuzhiyun writel((u32) (w100_pwr_state.pll_cntl.val), remapped_regs + mmPLL_CNTL);
1272*4882a593Smuzhiyun
1273*4882a593Smuzhiyun w100_pwr_state.pwrmgt_cntl.f.pwm_enable = 0x0;
1274*4882a593Smuzhiyun w100_pwr_state.pwrmgt_cntl.f.pwm_mode_req = 0x1; /* normal mode (0, 1, 3) */
1275*4882a593Smuzhiyun w100_pwr_state.pwrmgt_cntl.f.pwm_wakeup_cond = 0x0;
1276*4882a593Smuzhiyun w100_pwr_state.pwrmgt_cntl.f.pwm_fast_noml_hw_en = 0x0;
1277*4882a593Smuzhiyun w100_pwr_state.pwrmgt_cntl.f.pwm_noml_fast_hw_en = 0x0;
1278*4882a593Smuzhiyun w100_pwr_state.pwrmgt_cntl.f.pwm_fast_noml_cond = 0x1; /* PM4,ENG */
1279*4882a593Smuzhiyun w100_pwr_state.pwrmgt_cntl.f.pwm_noml_fast_cond = 0x1; /* PM4,ENG */
1280*4882a593Smuzhiyun w100_pwr_state.pwrmgt_cntl.f.pwm_idle_timer = 0xFF;
1281*4882a593Smuzhiyun w100_pwr_state.pwrmgt_cntl.f.pwm_busy_timer = 0xFF;
1282*4882a593Smuzhiyun writel((u32) (w100_pwr_state.pwrmgt_cntl.val), remapped_regs + mmPWRMGT_CNTL);
1283*4882a593Smuzhiyun
1284*4882a593Smuzhiyun w100_pwr_state.auto_mode = 0; /* manual mode */
1285*4882a593Smuzhiyun }
1286*4882a593Smuzhiyun
1287*4882a593Smuzhiyun
1288*4882a593Smuzhiyun /*
1289*4882a593Smuzhiyun * Setup the w100 clocks for the specified mode
1290*4882a593Smuzhiyun */
w100_init_clocks(struct w100fb_par * par)1291*4882a593Smuzhiyun static void w100_init_clocks(struct w100fb_par *par)
1292*4882a593Smuzhiyun {
1293*4882a593Smuzhiyun struct w100_mode *mode = par->mode;
1294*4882a593Smuzhiyun
1295*4882a593Smuzhiyun if (mode->pixclk_src == CLK_SRC_PLL || mode->sysclk_src == CLK_SRC_PLL)
1296*4882a593Smuzhiyun w100_set_pll_freq(par, (par->fastpll_mode && mode->fast_pll_freq) ? mode->fast_pll_freq : mode->pll_freq);
1297*4882a593Smuzhiyun
1298*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_src_sel = mode->sysclk_src;
1299*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_post_div_fast = mode->sysclk_divider;
1300*4882a593Smuzhiyun w100_pwr_state.sclk_cntl.f.sclk_post_div_slow = mode->sysclk_divider;
1301*4882a593Smuzhiyun writel((u32) (w100_pwr_state.sclk_cntl.val), remapped_regs + mmSCLK_CNTL);
1302*4882a593Smuzhiyun }
1303*4882a593Smuzhiyun
w100_init_lcd(struct w100fb_par * par)1304*4882a593Smuzhiyun static void w100_init_lcd(struct w100fb_par *par)
1305*4882a593Smuzhiyun {
1306*4882a593Smuzhiyun u32 temp32;
1307*4882a593Smuzhiyun struct w100_mode *mode = par->mode;
1308*4882a593Smuzhiyun struct w100_gen_regs *regs = par->mach->regs;
1309*4882a593Smuzhiyun union active_h_disp_u active_h_disp;
1310*4882a593Smuzhiyun union active_v_disp_u active_v_disp;
1311*4882a593Smuzhiyun union graphic_h_disp_u graphic_h_disp;
1312*4882a593Smuzhiyun union graphic_v_disp_u graphic_v_disp;
1313*4882a593Smuzhiyun union crtc_total_u crtc_total;
1314*4882a593Smuzhiyun
1315*4882a593Smuzhiyun /* w3200 doesn't like undefined bits being set so zero register values first */
1316*4882a593Smuzhiyun
1317*4882a593Smuzhiyun active_h_disp.val = 0;
1318*4882a593Smuzhiyun active_h_disp.f.active_h_start=mode->left_margin;
1319*4882a593Smuzhiyun active_h_disp.f.active_h_end=mode->left_margin + mode->xres;
1320*4882a593Smuzhiyun writel(active_h_disp.val, remapped_regs + mmACTIVE_H_DISP);
1321*4882a593Smuzhiyun
1322*4882a593Smuzhiyun active_v_disp.val = 0;
1323*4882a593Smuzhiyun active_v_disp.f.active_v_start=mode->upper_margin;
1324*4882a593Smuzhiyun active_v_disp.f.active_v_end=mode->upper_margin + mode->yres;
1325*4882a593Smuzhiyun writel(active_v_disp.val, remapped_regs + mmACTIVE_V_DISP);
1326*4882a593Smuzhiyun
1327*4882a593Smuzhiyun graphic_h_disp.val = 0;
1328*4882a593Smuzhiyun graphic_h_disp.f.graphic_h_start=mode->left_margin;
1329*4882a593Smuzhiyun graphic_h_disp.f.graphic_h_end=mode->left_margin + mode->xres;
1330*4882a593Smuzhiyun writel(graphic_h_disp.val, remapped_regs + mmGRAPHIC_H_DISP);
1331*4882a593Smuzhiyun
1332*4882a593Smuzhiyun graphic_v_disp.val = 0;
1333*4882a593Smuzhiyun graphic_v_disp.f.graphic_v_start=mode->upper_margin;
1334*4882a593Smuzhiyun graphic_v_disp.f.graphic_v_end=mode->upper_margin + mode->yres;
1335*4882a593Smuzhiyun writel(graphic_v_disp.val, remapped_regs + mmGRAPHIC_V_DISP);
1336*4882a593Smuzhiyun
1337*4882a593Smuzhiyun crtc_total.val = 0;
1338*4882a593Smuzhiyun crtc_total.f.crtc_h_total=mode->left_margin + mode->xres + mode->right_margin;
1339*4882a593Smuzhiyun crtc_total.f.crtc_v_total=mode->upper_margin + mode->yres + mode->lower_margin;
1340*4882a593Smuzhiyun writel(crtc_total.val, remapped_regs + mmCRTC_TOTAL);
1341*4882a593Smuzhiyun
1342*4882a593Smuzhiyun writel(mode->crtc_ss, remapped_regs + mmCRTC_SS);
1343*4882a593Smuzhiyun writel(mode->crtc_ls, remapped_regs + mmCRTC_LS);
1344*4882a593Smuzhiyun writel(mode->crtc_gs, remapped_regs + mmCRTC_GS);
1345*4882a593Smuzhiyun writel(mode->crtc_vpos_gs, remapped_regs + mmCRTC_VPOS_GS);
1346*4882a593Smuzhiyun writel(mode->crtc_rev, remapped_regs + mmCRTC_REV);
1347*4882a593Smuzhiyun writel(mode->crtc_dclk, remapped_regs + mmCRTC_DCLK);
1348*4882a593Smuzhiyun writel(mode->crtc_gclk, remapped_regs + mmCRTC_GCLK);
1349*4882a593Smuzhiyun writel(mode->crtc_goe, remapped_regs + mmCRTC_GOE);
1350*4882a593Smuzhiyun writel(mode->crtc_ps1_active, remapped_regs + mmCRTC_PS1_ACTIVE);
1351*4882a593Smuzhiyun
1352*4882a593Smuzhiyun writel(regs->lcd_format, remapped_regs + mmLCD_FORMAT);
1353*4882a593Smuzhiyun writel(regs->lcdd_cntl1, remapped_regs + mmLCDD_CNTL1);
1354*4882a593Smuzhiyun writel(regs->lcdd_cntl2, remapped_regs + mmLCDD_CNTL2);
1355*4882a593Smuzhiyun writel(regs->genlcd_cntl1, remapped_regs + mmGENLCD_CNTL1);
1356*4882a593Smuzhiyun writel(regs->genlcd_cntl2, remapped_regs + mmGENLCD_CNTL2);
1357*4882a593Smuzhiyun writel(regs->genlcd_cntl3, remapped_regs + mmGENLCD_CNTL3);
1358*4882a593Smuzhiyun
1359*4882a593Smuzhiyun writel(0x00000000, remapped_regs + mmCRTC_FRAME);
1360*4882a593Smuzhiyun writel(0x00000000, remapped_regs + mmCRTC_FRAME_VPOS);
1361*4882a593Smuzhiyun writel(0x00000000, remapped_regs + mmCRTC_DEFAULT_COUNT);
1362*4882a593Smuzhiyun writel(0x0000FF00, remapped_regs + mmLCD_BACKGROUND_COLOR);
1363*4882a593Smuzhiyun
1364*4882a593Smuzhiyun /* Hack for overlay in ext memory */
1365*4882a593Smuzhiyun temp32 = readl(remapped_regs + mmDISP_DEBUG2);
1366*4882a593Smuzhiyun temp32 |= 0xc0000000;
1367*4882a593Smuzhiyun writel(temp32, remapped_regs + mmDISP_DEBUG2);
1368*4882a593Smuzhiyun }
1369*4882a593Smuzhiyun
1370*4882a593Smuzhiyun
w100_setup_memory(struct w100fb_par * par)1371*4882a593Smuzhiyun static void w100_setup_memory(struct w100fb_par *par)
1372*4882a593Smuzhiyun {
1373*4882a593Smuzhiyun union mc_ext_mem_location_u extmem_location;
1374*4882a593Smuzhiyun union mc_fb_location_u intmem_location;
1375*4882a593Smuzhiyun struct w100_mem_info *mem = par->mach->mem;
1376*4882a593Smuzhiyun struct w100_bm_mem_info *bm_mem = par->mach->bm_mem;
1377*4882a593Smuzhiyun
1378*4882a593Smuzhiyun if (!par->extmem_active) {
1379*4882a593Smuzhiyun w100_suspend(W100_SUSPEND_EXTMEM);
1380*4882a593Smuzhiyun
1381*4882a593Smuzhiyun /* Map Internal Memory at FB Base */
1382*4882a593Smuzhiyun intmem_location.f.mc_fb_start = W100_FB_BASE >> 8;
1383*4882a593Smuzhiyun intmem_location.f.mc_fb_top = (W100_FB_BASE+MEM_INT_SIZE) >> 8;
1384*4882a593Smuzhiyun writel((u32) (intmem_location.val), remapped_regs + mmMC_FB_LOCATION);
1385*4882a593Smuzhiyun
1386*4882a593Smuzhiyun /* Unmap External Memory - value is *probably* irrelevant but may have meaning
1387*4882a593Smuzhiyun to acceleration libraries */
1388*4882a593Smuzhiyun extmem_location.f.mc_ext_mem_start = MEM_EXT_BASE_VALUE >> 8;
1389*4882a593Smuzhiyun extmem_location.f.mc_ext_mem_top = (MEM_EXT_BASE_VALUE-1) >> 8;
1390*4882a593Smuzhiyun writel((u32) (extmem_location.val), remapped_regs + mmMC_EXT_MEM_LOCATION);
1391*4882a593Smuzhiyun } else {
1392*4882a593Smuzhiyun /* Map Internal Memory to its default location */
1393*4882a593Smuzhiyun intmem_location.f.mc_fb_start = MEM_INT_BASE_VALUE >> 8;
1394*4882a593Smuzhiyun intmem_location.f.mc_fb_top = (MEM_INT_BASE_VALUE+MEM_INT_SIZE) >> 8;
1395*4882a593Smuzhiyun writel((u32) (intmem_location.val), remapped_regs + mmMC_FB_LOCATION);
1396*4882a593Smuzhiyun
1397*4882a593Smuzhiyun /* Map External Memory at FB Base */
1398*4882a593Smuzhiyun extmem_location.f.mc_ext_mem_start = W100_FB_BASE >> 8;
1399*4882a593Smuzhiyun extmem_location.f.mc_ext_mem_top = (W100_FB_BASE+par->mach->mem->size) >> 8;
1400*4882a593Smuzhiyun writel((u32) (extmem_location.val), remapped_regs + mmMC_EXT_MEM_LOCATION);
1401*4882a593Smuzhiyun
1402*4882a593Smuzhiyun writel(0x00007800, remapped_regs + mmMC_BIST_CTRL);
1403*4882a593Smuzhiyun writel(mem->ext_cntl, remapped_regs + mmMEM_EXT_CNTL);
1404*4882a593Smuzhiyun writel(0x00200021, remapped_regs + mmMEM_SDRAM_MODE_REG);
1405*4882a593Smuzhiyun udelay(100);
1406*4882a593Smuzhiyun writel(0x80200021, remapped_regs + mmMEM_SDRAM_MODE_REG);
1407*4882a593Smuzhiyun udelay(100);
1408*4882a593Smuzhiyun writel(mem->sdram_mode_reg, remapped_regs + mmMEM_SDRAM_MODE_REG);
1409*4882a593Smuzhiyun udelay(100);
1410*4882a593Smuzhiyun writel(mem->ext_timing_cntl, remapped_regs + mmMEM_EXT_TIMING_CNTL);
1411*4882a593Smuzhiyun writel(mem->io_cntl, remapped_regs + mmMEM_IO_CNTL);
1412*4882a593Smuzhiyun if (bm_mem) {
1413*4882a593Smuzhiyun writel(bm_mem->ext_mem_bw, remapped_regs + mmBM_EXT_MEM_BANDWIDTH);
1414*4882a593Smuzhiyun writel(bm_mem->offset, remapped_regs + mmBM_OFFSET);
1415*4882a593Smuzhiyun writel(bm_mem->ext_timing_ctl, remapped_regs + mmBM_MEM_EXT_TIMING_CNTL);
1416*4882a593Smuzhiyun writel(bm_mem->ext_cntl, remapped_regs + mmBM_MEM_EXT_CNTL);
1417*4882a593Smuzhiyun writel(bm_mem->mode_reg, remapped_regs + mmBM_MEM_MODE_REG);
1418*4882a593Smuzhiyun writel(bm_mem->io_cntl, remapped_regs + mmBM_MEM_IO_CNTL);
1419*4882a593Smuzhiyun writel(bm_mem->config, remapped_regs + mmBM_CONFIG);
1420*4882a593Smuzhiyun }
1421*4882a593Smuzhiyun }
1422*4882a593Smuzhiyun }
1423*4882a593Smuzhiyun
w100_set_dispregs(struct w100fb_par * par)1424*4882a593Smuzhiyun static void w100_set_dispregs(struct w100fb_par *par)
1425*4882a593Smuzhiyun {
1426*4882a593Smuzhiyun unsigned long rot=0, divider, offset=0;
1427*4882a593Smuzhiyun union graphic_ctrl_u graphic_ctrl;
1428*4882a593Smuzhiyun
1429*4882a593Smuzhiyun /* See if the mode has been rotated */
1430*4882a593Smuzhiyun if (par->xres == par->mode->xres) {
1431*4882a593Smuzhiyun if (par->flip) {
1432*4882a593Smuzhiyun rot=3; /* 180 degree */
1433*4882a593Smuzhiyun offset=(par->xres * par->yres) - 1;
1434*4882a593Smuzhiyun } /* else 0 degree */
1435*4882a593Smuzhiyun divider = par->mode->pixclk_divider;
1436*4882a593Smuzhiyun } else {
1437*4882a593Smuzhiyun if (par->flip) {
1438*4882a593Smuzhiyun rot=2; /* 270 degree */
1439*4882a593Smuzhiyun offset=par->xres - 1;
1440*4882a593Smuzhiyun } else {
1441*4882a593Smuzhiyun rot=1; /* 90 degree */
1442*4882a593Smuzhiyun offset=par->xres * (par->yres - 1);
1443*4882a593Smuzhiyun }
1444*4882a593Smuzhiyun divider = par->mode->pixclk_divider_rotated;
1445*4882a593Smuzhiyun }
1446*4882a593Smuzhiyun
1447*4882a593Smuzhiyun graphic_ctrl.val = 0; /* w32xx doesn't like undefined bits */
1448*4882a593Smuzhiyun switch (par->chip_id) {
1449*4882a593Smuzhiyun case CHIP_ID_W100:
1450*4882a593Smuzhiyun graphic_ctrl.f_w100.color_depth=6;
1451*4882a593Smuzhiyun graphic_ctrl.f_w100.en_crtc=1;
1452*4882a593Smuzhiyun graphic_ctrl.f_w100.en_graphic_req=1;
1453*4882a593Smuzhiyun graphic_ctrl.f_w100.en_graphic_crtc=1;
1454*4882a593Smuzhiyun graphic_ctrl.f_w100.lcd_pclk_on=1;
1455*4882a593Smuzhiyun graphic_ctrl.f_w100.lcd_sclk_on=1;
1456*4882a593Smuzhiyun graphic_ctrl.f_w100.low_power_on=0;
1457*4882a593Smuzhiyun graphic_ctrl.f_w100.req_freq=0;
1458*4882a593Smuzhiyun graphic_ctrl.f_w100.portrait_mode=rot;
1459*4882a593Smuzhiyun
1460*4882a593Smuzhiyun /* Zaurus needs this */
1461*4882a593Smuzhiyun switch(par->xres) {
1462*4882a593Smuzhiyun case 240:
1463*4882a593Smuzhiyun case 320:
1464*4882a593Smuzhiyun default:
1465*4882a593Smuzhiyun graphic_ctrl.f_w100.total_req_graphic=0xa0;
1466*4882a593Smuzhiyun break;
1467*4882a593Smuzhiyun case 480:
1468*4882a593Smuzhiyun case 640:
1469*4882a593Smuzhiyun switch(rot) {
1470*4882a593Smuzhiyun case 0: /* 0 */
1471*4882a593Smuzhiyun case 3: /* 180 */
1472*4882a593Smuzhiyun graphic_ctrl.f_w100.low_power_on=1;
1473*4882a593Smuzhiyun graphic_ctrl.f_w100.req_freq=5;
1474*4882a593Smuzhiyun break;
1475*4882a593Smuzhiyun case 1: /* 90 */
1476*4882a593Smuzhiyun case 2: /* 270 */
1477*4882a593Smuzhiyun graphic_ctrl.f_w100.req_freq=4;
1478*4882a593Smuzhiyun break;
1479*4882a593Smuzhiyun default:
1480*4882a593Smuzhiyun break;
1481*4882a593Smuzhiyun }
1482*4882a593Smuzhiyun graphic_ctrl.f_w100.total_req_graphic=0xf0;
1483*4882a593Smuzhiyun break;
1484*4882a593Smuzhiyun }
1485*4882a593Smuzhiyun break;
1486*4882a593Smuzhiyun case CHIP_ID_W3200:
1487*4882a593Smuzhiyun case CHIP_ID_W3220:
1488*4882a593Smuzhiyun graphic_ctrl.f_w32xx.color_depth=6;
1489*4882a593Smuzhiyun graphic_ctrl.f_w32xx.en_crtc=1;
1490*4882a593Smuzhiyun graphic_ctrl.f_w32xx.en_graphic_req=1;
1491*4882a593Smuzhiyun graphic_ctrl.f_w32xx.en_graphic_crtc=1;
1492*4882a593Smuzhiyun graphic_ctrl.f_w32xx.lcd_pclk_on=1;
1493*4882a593Smuzhiyun graphic_ctrl.f_w32xx.lcd_sclk_on=1;
1494*4882a593Smuzhiyun graphic_ctrl.f_w32xx.low_power_on=0;
1495*4882a593Smuzhiyun graphic_ctrl.f_w32xx.req_freq=0;
1496*4882a593Smuzhiyun graphic_ctrl.f_w32xx.total_req_graphic=par->mode->xres >> 1; /* panel xres, not mode */
1497*4882a593Smuzhiyun graphic_ctrl.f_w32xx.portrait_mode=rot;
1498*4882a593Smuzhiyun break;
1499*4882a593Smuzhiyun }
1500*4882a593Smuzhiyun
1501*4882a593Smuzhiyun /* Set the pixel clock source and divider */
1502*4882a593Smuzhiyun w100_pwr_state.pclk_cntl.f.pclk_src_sel = par->mode->pixclk_src;
1503*4882a593Smuzhiyun w100_pwr_state.pclk_cntl.f.pclk_post_div = divider;
1504*4882a593Smuzhiyun writel((u32) (w100_pwr_state.pclk_cntl.val), remapped_regs + mmPCLK_CNTL);
1505*4882a593Smuzhiyun
1506*4882a593Smuzhiyun writel(graphic_ctrl.val, remapped_regs + mmGRAPHIC_CTRL);
1507*4882a593Smuzhiyun writel(W100_FB_BASE + ((offset * BITS_PER_PIXEL/8)&~0x03UL), remapped_regs + mmGRAPHIC_OFFSET);
1508*4882a593Smuzhiyun writel((par->xres*BITS_PER_PIXEL/8), remapped_regs + mmGRAPHIC_PITCH);
1509*4882a593Smuzhiyun }
1510*4882a593Smuzhiyun
1511*4882a593Smuzhiyun
1512*4882a593Smuzhiyun /*
1513*4882a593Smuzhiyun * Work out how long the sync pulse lasts
1514*4882a593Smuzhiyun * Value is 1/(time in seconds)
1515*4882a593Smuzhiyun */
calc_hsync(struct w100fb_par * par)1516*4882a593Smuzhiyun static void calc_hsync(struct w100fb_par *par)
1517*4882a593Smuzhiyun {
1518*4882a593Smuzhiyun unsigned long hsync;
1519*4882a593Smuzhiyun struct w100_mode *mode = par->mode;
1520*4882a593Smuzhiyun union crtc_ss_u crtc_ss;
1521*4882a593Smuzhiyun
1522*4882a593Smuzhiyun if (mode->pixclk_src == CLK_SRC_XTAL)
1523*4882a593Smuzhiyun hsync=par->mach->xtal_freq;
1524*4882a593Smuzhiyun else
1525*4882a593Smuzhiyun hsync=((par->fastpll_mode && mode->fast_pll_freq) ? mode->fast_pll_freq : mode->pll_freq)*100000;
1526*4882a593Smuzhiyun
1527*4882a593Smuzhiyun hsync /= (w100_pwr_state.pclk_cntl.f.pclk_post_div + 1);
1528*4882a593Smuzhiyun
1529*4882a593Smuzhiyun crtc_ss.val = readl(remapped_regs + mmCRTC_SS);
1530*4882a593Smuzhiyun if (crtc_ss.val)
1531*4882a593Smuzhiyun par->hsync_len = hsync / (crtc_ss.f.ss_end-crtc_ss.f.ss_start);
1532*4882a593Smuzhiyun else
1533*4882a593Smuzhiyun par->hsync_len = 0;
1534*4882a593Smuzhiyun }
1535*4882a593Smuzhiyun
w100_suspend(u32 mode)1536*4882a593Smuzhiyun static void w100_suspend(u32 mode)
1537*4882a593Smuzhiyun {
1538*4882a593Smuzhiyun u32 val;
1539*4882a593Smuzhiyun
1540*4882a593Smuzhiyun writel(0x7FFF8000, remapped_regs + mmMC_EXT_MEM_LOCATION);
1541*4882a593Smuzhiyun writel(0x00FF0000, remapped_regs + mmMC_PERF_MON_CNTL);
1542*4882a593Smuzhiyun
1543*4882a593Smuzhiyun val = readl(remapped_regs + mmMEM_EXT_TIMING_CNTL);
1544*4882a593Smuzhiyun val &= ~(0x00100000); /* bit20=0 */
1545*4882a593Smuzhiyun val |= 0xFF000000; /* bit31:24=0xff */
1546*4882a593Smuzhiyun writel(val, remapped_regs + mmMEM_EXT_TIMING_CNTL);
1547*4882a593Smuzhiyun
1548*4882a593Smuzhiyun val = readl(remapped_regs + mmMEM_EXT_CNTL);
1549*4882a593Smuzhiyun val &= ~(0x00040000); /* bit18=0 */
1550*4882a593Smuzhiyun val |= 0x00080000; /* bit19=1 */
1551*4882a593Smuzhiyun writel(val, remapped_regs + mmMEM_EXT_CNTL);
1552*4882a593Smuzhiyun
1553*4882a593Smuzhiyun udelay(1); /* wait 1us */
1554*4882a593Smuzhiyun
1555*4882a593Smuzhiyun if (mode == W100_SUSPEND_EXTMEM) {
1556*4882a593Smuzhiyun /* CKE: Tri-State */
1557*4882a593Smuzhiyun val = readl(remapped_regs + mmMEM_EXT_CNTL);
1558*4882a593Smuzhiyun val |= 0x40000000; /* bit30=1 */
1559*4882a593Smuzhiyun writel(val, remapped_regs + mmMEM_EXT_CNTL);
1560*4882a593Smuzhiyun
1561*4882a593Smuzhiyun /* CLK: Stop */
1562*4882a593Smuzhiyun val = readl(remapped_regs + mmMEM_EXT_CNTL);
1563*4882a593Smuzhiyun val &= ~(0x00000001); /* bit0=0 */
1564*4882a593Smuzhiyun writel(val, remapped_regs + mmMEM_EXT_CNTL);
1565*4882a593Smuzhiyun } else {
1566*4882a593Smuzhiyun writel(0x00000000, remapped_regs + mmSCLK_CNTL);
1567*4882a593Smuzhiyun writel(0x000000BF, remapped_regs + mmCLK_PIN_CNTL);
1568*4882a593Smuzhiyun writel(0x00000015, remapped_regs + mmPWRMGT_CNTL);
1569*4882a593Smuzhiyun
1570*4882a593Smuzhiyun udelay(5);
1571*4882a593Smuzhiyun
1572*4882a593Smuzhiyun val = readl(remapped_regs + mmPLL_CNTL);
1573*4882a593Smuzhiyun val |= 0x00000004; /* bit2=1 */
1574*4882a593Smuzhiyun writel(val, remapped_regs + mmPLL_CNTL);
1575*4882a593Smuzhiyun
1576*4882a593Smuzhiyun writel(0x00000000, remapped_regs + mmLCDD_CNTL1);
1577*4882a593Smuzhiyun writel(0x00000000, remapped_regs + mmLCDD_CNTL2);
1578*4882a593Smuzhiyun writel(0x00000000, remapped_regs + mmGENLCD_CNTL1);
1579*4882a593Smuzhiyun writel(0x00000000, remapped_regs + mmGENLCD_CNTL2);
1580*4882a593Smuzhiyun writel(0x00000000, remapped_regs + mmGENLCD_CNTL3);
1581*4882a593Smuzhiyun
1582*4882a593Smuzhiyun val = readl(remapped_regs + mmMEM_EXT_CNTL);
1583*4882a593Smuzhiyun val |= 0xF0000000;
1584*4882a593Smuzhiyun val &= ~(0x00000001);
1585*4882a593Smuzhiyun writel(val, remapped_regs + mmMEM_EXT_CNTL);
1586*4882a593Smuzhiyun
1587*4882a593Smuzhiyun writel(0x0000001d, remapped_regs + mmPWRMGT_CNTL);
1588*4882a593Smuzhiyun }
1589*4882a593Smuzhiyun }
1590*4882a593Smuzhiyun
w100_vsync(void)1591*4882a593Smuzhiyun static void w100_vsync(void)
1592*4882a593Smuzhiyun {
1593*4882a593Smuzhiyun u32 tmp;
1594*4882a593Smuzhiyun int timeout = 30000; /* VSync timeout = 30[ms] > 16.8[ms] */
1595*4882a593Smuzhiyun
1596*4882a593Smuzhiyun tmp = readl(remapped_regs + mmACTIVE_V_DISP);
1597*4882a593Smuzhiyun
1598*4882a593Smuzhiyun /* set vline pos */
1599*4882a593Smuzhiyun writel((tmp >> 16) & 0x3ff, remapped_regs + mmDISP_INT_CNTL);
1600*4882a593Smuzhiyun
1601*4882a593Smuzhiyun /* disable vline irq */
1602*4882a593Smuzhiyun tmp = readl(remapped_regs + mmGEN_INT_CNTL);
1603*4882a593Smuzhiyun
1604*4882a593Smuzhiyun tmp &= ~0x00000002;
1605*4882a593Smuzhiyun writel(tmp, remapped_regs + mmGEN_INT_CNTL);
1606*4882a593Smuzhiyun
1607*4882a593Smuzhiyun /* clear vline irq status */
1608*4882a593Smuzhiyun writel(0x00000002, remapped_regs + mmGEN_INT_STATUS);
1609*4882a593Smuzhiyun
1610*4882a593Smuzhiyun /* enable vline irq */
1611*4882a593Smuzhiyun writel((tmp | 0x00000002), remapped_regs + mmGEN_INT_CNTL);
1612*4882a593Smuzhiyun
1613*4882a593Smuzhiyun /* clear vline irq status */
1614*4882a593Smuzhiyun writel(0x00000002, remapped_regs + mmGEN_INT_STATUS);
1615*4882a593Smuzhiyun
1616*4882a593Smuzhiyun while(timeout > 0) {
1617*4882a593Smuzhiyun if (readl(remapped_regs + mmGEN_INT_STATUS) & 0x00000002)
1618*4882a593Smuzhiyun break;
1619*4882a593Smuzhiyun udelay(1);
1620*4882a593Smuzhiyun timeout--;
1621*4882a593Smuzhiyun }
1622*4882a593Smuzhiyun
1623*4882a593Smuzhiyun /* disable vline irq */
1624*4882a593Smuzhiyun writel(tmp, remapped_regs + mmGEN_INT_CNTL);
1625*4882a593Smuzhiyun
1626*4882a593Smuzhiyun /* clear vline irq status */
1627*4882a593Smuzhiyun writel(0x00000002, remapped_regs + mmGEN_INT_STATUS);
1628*4882a593Smuzhiyun }
1629*4882a593Smuzhiyun
1630*4882a593Smuzhiyun static struct platform_driver w100fb_driver = {
1631*4882a593Smuzhiyun .probe = w100fb_probe,
1632*4882a593Smuzhiyun .remove = w100fb_remove,
1633*4882a593Smuzhiyun .suspend = w100fb_suspend,
1634*4882a593Smuzhiyun .resume = w100fb_resume,
1635*4882a593Smuzhiyun .driver = {
1636*4882a593Smuzhiyun .name = "w100fb",
1637*4882a593Smuzhiyun .dev_groups = w100fb_groups,
1638*4882a593Smuzhiyun },
1639*4882a593Smuzhiyun };
1640*4882a593Smuzhiyun
1641*4882a593Smuzhiyun module_platform_driver(w100fb_driver);
1642*4882a593Smuzhiyun
1643*4882a593Smuzhiyun MODULE_DESCRIPTION("ATI Imageon w100 framebuffer driver");
1644*4882a593Smuzhiyun MODULE_LICENSE("GPL");
1645