/* The code in this function is based on the code from  */
static int lcd_clk_set_rate(struct clk *clk, unsigned long rate)
/* The code in this function is based on the code from  */
static int lcd_clk_set_rate(struct clk *clk, unsigned long rate)
{
	u32 tmp, prate, div;
	tmp = __raw_readl(LPC178X_LCD_BASE + CLCD_TIM2) | TIM2_BCD;
	prate = lpc178x_clock_get(CLOCK_CCLK);
	if (rate < prate) {
		div = prate / rate;
		if (div >= 2) {
			div -= 2;
			tmp &= ~TIM2_BCD;
		}
		tmp &= ~(0xF800001F);
		tmp |= (div & 0x1F);
		tmp |= (((div >> 5) & 0x1F) << 27);
	}
	__raw_writel(tmp, LPC178X_LCD_BASE + CLCD_TIM2);
	return 0;
}