2 * Xylon logiCVC frame buffer driver pixel clock generation
5 * e-mail: davor.joja@logicbricks.com
7 * 2012 (c) Xylon d.o.o.
9 * This file is licensed under the terms of the GNU General Public License
10 * version 2. This program is licensed "as is" without any warranty of any
11 * kind, whether express or implied.
16 * This file implements HW dependent functionality for controlling pixel clock
17 * generation on various HW platforms.
24 #define HW_PIXEL_CLOCK_CHANGE_SUPPORTED 1
27 #if defined(CONFIG_FB_XYLON_TEST)
29 #define HW_PIXEL_CLOCK_CHANGE_SUPPORTED 0
30 int pixclk_set(struct fb_info
*fbi
)
33 "Changing of pixel clock for %s on platform TEST not supported\n",
39 #elif defined(CONFIG_FB_XYLON_ZYNQ_PS_PIXCLK)
41 int pixclk_set(struct fb_info
*fbi
)
43 unsigned long pllclk
, sysclk
, pixclk
;
44 unsigned long div
, delta
, delta_dec
, delta_inc
;
45 void *slcr_regs
, *clk_regs
, *rst_reg
;
47 /* all clock values are in kHz */
50 pixclk
= PICOS2KHZ(fbi
->var
.pixclock
);
52 slcr_regs
= ioremap_nocache(0xF8000004, 8);
55 "Error mapping SLCR\n");
58 clk_regs
= ioremap_nocache(0xF8000170, 32);
61 "Error setting xylonfb pixelclock\n");
65 rst_reg
= ioremap_nocache(0xF8000240, 4);
68 "Error setting xylonfb pixelclock\n");
74 /* unlock register access */
75 writel(0xDF0D, (slcr_regs
+4));
76 // /* calculate system clock divisor */
77 // div = pllclk / sysclk;
78 // /* prepare for register writting */
79 // div = (div + 0x1000) << 8;
80 // /* set system clock */
81 // writel(div, clk_regs);
82 /* calculate video clock divisor */
83 div
= pllclk
/ pixclk
;
84 delta
= (pllclk
/ div
) - pixclk
;
86 delta_inc
= pixclk
- (pllclk
/ (div
+1));
87 delta_dec
= (pllclk
/ (div
-1)) - pixclk
;
88 if (delta
< delta_inc
) {
89 if (delta
> delta_dec
)
94 if (delta
> delta_dec
) {
95 if (delta_inc
> delta_dec
)
104 /* prepare for register writting */
105 div
= (div
+ 0x1000) << 8;
106 /* set video clock */
107 writel(div
, (clk_regs
+0x10));
109 // writel(0, rst_reg);
110 // writel(0x1, rst_reg);
111 // writel(0, rst_reg);
112 /* lock register access */
113 writel(0x767B, slcr_regs
);
122 #elif defined(CONFIG_FB_XYLON_ZC702_PIXCLK)
124 #include <linux/i2c/si570.h>
126 int pixclk_set(struct fb_info
*fbi
)
128 struct i2c_client
*si570_client
;
129 unsigned long pixclk
;
131 pixclk
= PICOS2KHZ(fbi
->var
.pixclock
) * 1000;
133 si570_client
= get_i2c_client_si570();
135 return set_frequency_si570(&si570_client
->dev
, pixclk
);
142 #if defined (HW_PIXEL_CLOCK_CHANGE_SUPPORTED)
143 #undef HW_PIXEL_CLOCK_CHANGE_SUPPORTED
145 #define HW_PIXEL_CLOCK_CHANGE_SUPPORTED 0
146 int pixclk_set(struct fb_info
*fbi
)
148 printk(KERN_INFO
"Changing of pixel clock for %s not supported\n",
157 inline int pixclk_change(struct fb_info
*fbi
)
159 #if HW_PIXEL_CLOCK_CHANGE_SUPPORTED == 0
161 #elif HW_PIXEL_CLOCK_CHANGE_SUPPORTED == 1