From: Donggeun Kim Date: Fri, 20 Aug 2010 10:05:01 +0000 (+0900) Subject: s5pc210: universal: support ADC read X-Git-Tag: JH03_20100826~36 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4a7851e2bae7b2ac50e141f59171f2dd103f94fc;p=kernel%2Fu-boot.git s5pc210: universal: support ADC read Signed-off-by: Donggeun Kim --- diff --git a/arch/arm/include/asm/arch-s5pc2xx/adc.h b/arch/arm/include/asm/arch-s5pc2xx/adc.h new file mode 100644 index 0000000..0a4642b --- /dev/null +++ b/arch/arm/include/asm/arch-s5pc2xx/adc.h @@ -0,0 +1,40 @@ +/* + * (C) Copyright 2009 + * Samsung Electronics, + * MyungJoo Ham + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + */ + +#ifndef __ASM_ARM_ARCH_ADC_H_ +#define __ASM_ARM_ARCH_ADC_H_ + +#ifndef __ASSEMBLY__ +struct s5pc210_adc { + unsigned int adccon; /* starts at 0x13910000 */ + unsigned int adctsc; + unsigned int adcdly; + unsigned int adcdat0; + unsigned int adcdat1; /* 0x13910010 */ + unsigned int adcupdn; + unsigned int adcclrint; + unsigned int adcmux; + unsigned int adcclrintpndnup; +}; +#endif + +#endif /* __ASM_ARM_ARCH_ADC_H_ */ diff --git a/arch/arm/include/asm/arch-s5pc2xx/cpu.h b/arch/arm/include/asm/arch-s5pc2xx/cpu.h index a76b626..4a27071 100644 --- a/arch/arm/include/asm/arch-s5pc2xx/cpu.h +++ b/arch/arm/include/asm/arch-s5pc2xx/cpu.h @@ -40,6 +40,7 @@ #define S5PC210_SROMC_BASE 0x12570000 #define S5PC210_USBPHY_BASE 0x125B0000 #define S5PC210_UART_BASE 0x13800000 +#define S5PC210_ADC_BASE 0x13910000 #define S5PC210_PWMTIMER_BASE 0x139D0000 #ifndef __ASSEMBLY__ diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c index 6572112..ee0e2f2 100644 --- a/board/samsung/universal_c210/universal.c +++ b/board/samsung/universal_c210/universal.c @@ -25,6 +25,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -328,6 +329,38 @@ static void init_pmic_max8952(void) /* RAMP: As Fast As Possible: Default: Do Nothing */ } +static unsigned short get_adc_value(int channel) +{ + struct s5pc210_adc *adc = (struct s5pc210_adc *) S5PC210_ADC_BASE; + unsigned short ret = 0; + unsigned int reg; + int ldonum = 4; + char buf[64]; + unsigned int loop = 0; + + sprintf(buf, "pmic ldo %d on", ldonum); + run_command(buf, 0); + + writel(channel & 0xF, &adc->adcmux); + writel((1 << 14) | (49 << 6), &adc->adccon); + writel(1000 & 0xffff, &adc->adcdly); + writel(readl(&adc->adccon) | (1 << 16), &adc->adccon); /* 12 bit */ + udelay(10); + writel(readl(&adc->adccon) | (1 << 0), &adc->adccon); /* Enable */ + udelay(10); + + do { + udelay(1); + reg = readl(&adc->adccon); + } while (!(reg & (1 << 15)) && (loop++ < 1000)); + + ret = readl(&adc->adcdat0) & 0xFFF; + sprintf(buf, "pmic ldo %d off", ldonum); + run_command(buf, 0); + + return ret; +} + #ifdef CONFIG_MISC_INIT_R int misc_init_r(void) { @@ -545,3 +578,4 @@ U_BOOT_CMD( "pmic safeout num on/off - Turn on/off the SAFEOUT\n" ); #endif +