2 * linux/include/asm-arm/arch-rpc/acornfb.h
4 * Copyright (C) 1999 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * AcornFB architecture specific code
13 #define acornfb_valid_pixrate(rate) (1)
16 * Try to find the best PLL parameters for the pixel clock.
17 * This algorithm seems to give best predictable results,
18 * and produces the same values as detailed in the VIDC20
22 acornfb_vidc20_find_pll(u_int pixclk)
24 u_int r, best_r = 2, best_v = 2;
25 int best_d = 0x7fffffff;
27 for (r = 2; r <= 32; r++) {
33 v = (rr + pixclk / 2) / pixclk;
55 return best_v << 8 | best_r;
59 acornfb_vidc20_find_rates(struct vidc_timing *vidc,
60 struct fb_var_screeninfo *var)
64 /* Select pixel-clock divisor to keep PLL in range */
65 div = var->pixclock / 9090; /*9921*/
73 /* Encode divisor to VIDC20 setting */
75 case 1: vidc->control |= VIDC20_CTRL_PIX_CK; break;
76 case 2: vidc->control |= VIDC20_CTRL_PIX_CK2; break;
77 case 3: vidc->control |= VIDC20_CTRL_PIX_CK3; break;
78 case 4: vidc->control |= VIDC20_CTRL_PIX_CK4; break;
79 case 5: vidc->control |= VIDC20_CTRL_PIX_CK5; break;
80 case 6: vidc->control |= VIDC20_CTRL_PIX_CK6; break;
81 case 7: vidc->control |= VIDC20_CTRL_PIX_CK7; break;
82 case 8: vidc->control |= VIDC20_CTRL_PIX_CK8; break;
85 /* Calculate bandwidth */
86 bandwidth = var->pixclock * 8 / var->bits_per_pixel;
88 /* Encode bandwidth as VIDC20 setting */
89 if (bandwidth > 33334)
90 vidc->control |= VIDC20_CTRL_FIFO_16; /* < 30.0MB/s */
91 else if (bandwidth > 26666)
92 vidc->control |= VIDC20_CTRL_FIFO_20; /* < 37.5MB/s */
93 else if (bandwidth > 22222)
94 vidc->control |= VIDC20_CTRL_FIFO_24; /* < 45.0MB/s */
96 vidc->control |= VIDC20_CTRL_FIFO_28; /* > 45.0MB/s */
98 /* Find the PLL values */
99 vidc->pll_ctl = acornfb_vidc20_find_pll(var->pixclock / div);
102 #define acornfb_default_control() (VIDC20_CTRL_PIX_VCLK)
103 #define acornfb_default_econtrol() (VIDC20_ECTL_DAC | VIDC20_ECTL_REG(3))