aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorRoland Stigge <stigge@antcom.de>2012-02-17 08:58:14 -0500
committerArnd Bergmann <arnd@arndb.de>2012-02-22 09:19:16 -0500
commit678a0222edc9da43a22145d68647500ee85e6c04 (patch)
tree6e0d859cd04ffc1ad723037e13513e2a269fb375 /arch
parentb01543dfe67bb1d191998e90d20534dc354de059 (diff)
ARM: LPC32xx: ADC support for mach-lpc32xx
This patch adds the mach specific support for the LPC32XX ADC driver (the latter being already in staging/iio) Signed-off-by: Roland Stigge <stigge@antcom.de> Acked-by: Jonathan Cameron <jic23@kernel.org> Acked-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-lpc32xx/clock.c36
-rw-r--r--arch/arm/mach-lpc32xx/common.c22
-rw-r--r--arch/arm/mach-lpc32xx/common.h1
-rw-r--r--arch/arm/mach-lpc32xx/phy3250.c1
4 files changed, 60 insertions, 0 deletions
diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
index 1e027514096d..473015ac07bd 100644
--- a/arch/arm/mach-lpc32xx/clock.c
+++ b/arch/arm/mach-lpc32xx/clock.c
@@ -719,6 +719,41 @@ static struct clk clk_tsc = {
719 .get_rate = local_return_parent_rate, 719 .get_rate = local_return_parent_rate,
720}; 720};
721 721
722static int adc_onoff_enable(struct clk *clk, int enable)
723{
724 u32 tmp;
725 u32 divider;
726
727 /* Use PERIPH_CLOCK */
728 tmp = __raw_readl(LPC32XX_CLKPWR_ADC_CLK_CTRL_1);
729 tmp |= LPC32XX_CLKPWR_ADCCTRL1_PCLK_SEL;
730 /*
731 * Set clock divider so that we have equal to or less than
732 * 4.5MHz clock at ADC
733 */
734 divider = clk->get_rate(clk) / 4500000 + 1;
735 tmp |= divider;
736 __raw_writel(tmp, LPC32XX_CLKPWR_ADC_CLK_CTRL_1);
737
738 /* synchronize rate of this clock w/ actual HW setting */
739 clk->rate = clk->get_rate(clk->parent) / divider;
740
741 if (enable == 0)
742 __raw_writel(0, clk->enable_reg);
743 else
744 __raw_writel(clk->enable_mask, clk->enable_reg);
745
746 return 0;
747}
748
749static struct clk clk_adc = {
750 .parent = &clk_pclk,
751 .enable = adc_onoff_enable,
752 .enable_reg = LPC32XX_CLKPWR_ADC_CLK_CTRL,
753 .enable_mask = LPC32XX_CLKPWR_ADC32CLKCTRL_CLK_EN,
754 .get_rate = local_return_parent_rate,
755};
756
722static int mmc_onoff_enable(struct clk *clk, int enable) 757static int mmc_onoff_enable(struct clk *clk, int enable)
723{ 758{
724 u32 tmp; 759 u32 tmp;
@@ -1075,6 +1110,7 @@ static struct clk_lookup lookups[] = {
1075 _REGISTER_CLOCK("dev:ssp1", NULL, clk_ssp1) 1110 _REGISTER_CLOCK("dev:ssp1", NULL, clk_ssp1)
1076 _REGISTER_CLOCK("lpc32xx_keys.0", NULL, clk_kscan) 1111 _REGISTER_CLOCK("lpc32xx_keys.0", NULL, clk_kscan)
1077 _REGISTER_CLOCK("lpc32xx-nand.0", "nand_ck", clk_nand) 1112 _REGISTER_CLOCK("lpc32xx-nand.0", "nand_ck", clk_nand)
1113 _REGISTER_CLOCK("lpc32xx-adc", NULL, clk_adc)
1078 _REGISTER_CLOCK("tbd", "i2s0_ck", clk_i2s0) 1114 _REGISTER_CLOCK("tbd", "i2s0_ck", clk_i2s0)
1079 _REGISTER_CLOCK("tbd", "i2s1_ck", clk_i2s1) 1115 _REGISTER_CLOCK("tbd", "i2s1_ck", clk_i2s1)
1080 _REGISTER_CLOCK("ts-lpc32xx", NULL, clk_tsc) 1116 _REGISTER_CLOCK("ts-lpc32xx", NULL, clk_tsc)
diff --git a/arch/arm/mach-lpc32xx/common.c b/arch/arm/mach-lpc32xx/common.c
index 369b152896cd..6c76bb36559b 100644
--- a/arch/arm/mach-lpc32xx/common.c
+++ b/arch/arm/mach-lpc32xx/common.c
@@ -138,6 +138,28 @@ struct platform_device lpc32xx_rtc_device = {
138}; 138};
139 139
140/* 140/*
141 * ADC support
142 */
143static struct resource adc_resources[] = {
144 {
145 .start = LPC32XX_ADC_BASE,
146 .end = LPC32XX_ADC_BASE + SZ_4K - 1,
147 .flags = IORESOURCE_MEM,
148 }, {
149 .start = IRQ_LPC32XX_TS_IRQ,
150 .end = IRQ_LPC32XX_TS_IRQ,
151 .flags = IORESOURCE_IRQ,
152 },
153};
154
155struct platform_device lpc32xx_adc_device = {
156 .name = "lpc32xx-adc",
157 .id = -1,
158 .num_resources = ARRAY_SIZE(adc_resources),
159 .resource = adc_resources,
160};
161
162/*
141 * Returns the unique ID for the device 163 * Returns the unique ID for the device
142 */ 164 */
143void lpc32xx_get_uid(u32 devid[4]) 165void lpc32xx_get_uid(u32 devid[4])
diff --git a/arch/arm/mach-lpc32xx/common.h b/arch/arm/mach-lpc32xx/common.h
index 4b4e700343c1..04b72739eb9c 100644
--- a/arch/arm/mach-lpc32xx/common.h
+++ b/arch/arm/mach-lpc32xx/common.h
@@ -29,6 +29,7 @@ extern struct platform_device lpc32xx_i2c0_device;
29extern struct platform_device lpc32xx_i2c1_device; 29extern struct platform_device lpc32xx_i2c1_device;
30extern struct platform_device lpc32xx_i2c2_device; 30extern struct platform_device lpc32xx_i2c2_device;
31extern struct platform_device lpc32xx_tsc_device; 31extern struct platform_device lpc32xx_tsc_device;
32extern struct platform_device lpc32xx_adc_device;
32extern struct platform_device lpc32xx_rtc_device; 33extern struct platform_device lpc32xx_rtc_device;
33 34
34/* 35/*
diff --git a/arch/arm/mach-lpc32xx/phy3250.c b/arch/arm/mach-lpc32xx/phy3250.c
index bfee5b455105..a2f0d4e3f773 100644
--- a/arch/arm/mach-lpc32xx/phy3250.c
+++ b/arch/arm/mach-lpc32xx/phy3250.c
@@ -276,6 +276,7 @@ static struct platform_device *phy3250_devs[] __initdata = {
276 &lpc32xx_i2c2_device, 276 &lpc32xx_i2c2_device,
277 &lpc32xx_watchdog_device, 277 &lpc32xx_watchdog_device,
278 &lpc32xx_gpio_led_device, 278 &lpc32xx_gpio_led_device,
279 &lpc32xx_adc_device,
279}; 280};
280 281
281static struct amba_device *amba_devs[] __initdata = { 282static struct amba_device *amba_devs[] __initdata = {