2 * linux/arch/arm/mach-w90x900/clksel.c
4 * Copyright (c) 2008 Nuvoton technology corporation
6 * Wan ZongShun <mcuos.com@gmail.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation;version 2 of the License.
13 #include <linux/module.h>
14 #include <linux/kernel.h>
15 #include <linux/device.h>
16 #include <linux/list.h>
17 #include <linux/errno.h>
18 #include <linux/err.h>
19 #include <linux/string.h>
20 #include <linux/clk.h>
21 #include <linux/mutex.h>
24 #include <mach/hardware.h>
25 #include <mach/regs-clock.h>
32 #define ATAOFFSET 0x0a
33 #define LCDOFFSET 0x06
34 #define AUDOFFSET 0x04
35 #define CPUOFFSET 0x00
37 static DEFINE_MUTEX(clksel_sem
);
39 static void clock_source_select(const char *dev_id
, unsigned int clkval
)
41 unsigned int clksel
, offset
;
43 clksel
= __raw_readl(REG_CLKSEL
);
45 if (strcmp(dev_id
, "nuc900-ms") == 0)
47 else if (strcmp(dev_id
, "nuc900-atapi") == 0)
49 else if (strcmp(dev_id
, "nuc900-lcd") == 0)
51 else if (strcmp(dev_id
, "nuc900-audio") == 0)
56 clksel
&= ~(0x03 << offset
);
57 clksel
|= (clkval
<< offset
);
59 __raw_writel(clksel
, REG_CLKSEL
);
62 void nuc900_clock_source(struct device
*dev
, unsigned char *src
)
70 mutex_lock(&clksel_sem
);
73 dev_id
= dev_name(dev
);
77 if (strcmp(src
, "pll0") == 0)
79 else if (strcmp(src
, "pll1") == 0)
81 else if (strcmp(src
, "ext") == 0)
83 else if (strcmp(src
, "oth") == 0)
86 clock_source_select(dev_id
, clkval
);
88 mutex_unlock(&clksel_sem
);
90 EXPORT_SYMBOL(nuc900_clock_source
);