s5p: adc: move to s5p-common
authorMinkyu Kang <mk7.kang@samsung.com>
Thu, 20 Jan 2011 01:08:18 +0000 (10:08 +0900)
committerMinkyu Kang <mk7.kang@samsung.com>
Thu, 20 Jan 2011 01:08:18 +0000 (10:08 +0900)
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
arch/arm/cpu/armv7/s5p-common/Makefile
arch/arm/cpu/armv7/s5p-common/adc.c [new file with mode: 0644]
arch/arm/include/asm/arch-s5pc1xx/adc.h
arch/arm/include/asm/arch-s5pc1xx/cpu.h
arch/arm/include/asm/arch-s5pc2xx/adc.h
board/samsung/slp7_c210/slp7.c
board/samsung/universal_c110/universal.c
board/samsung/universal_c210/universal.c

index 42f66bd..23a1794 100644 (file)
@@ -25,6 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB    = $(obj)libs5p-common.o
 
+COBJS-y                += adc.o
 COBJS-y                += cpu_info.o
 COBJS-y                += timer.o
 COBJS-$(CONFIG_CMD_USBDOWN)    += usb_downloader.o
diff --git a/arch/arm/cpu/armv7/s5p-common/adc.c b/arch/arm/cpu/armv7/s5p-common/adc.c
new file mode 100644 (file)
index 0000000..3f2d631
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ *  Copyright (C) 2011 Samsung Electronics
+ *  MyungJoo Ham <myungjoo.ham@samsung.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/adc.h>
+
+unsigned short get_adc_value(int channel)
+{
+       struct s5p_adc *adc = (struct s5p_adc *)samsung_get_base_adc();
+       unsigned short ret = 0;
+       unsigned int reg;
+       unsigned int loop = 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;
+
+       return ret;
+}
index 0999df7..c5b5444 100644 (file)
@@ -35,6 +35,8 @@ struct s5p_adc {
        unsigned int adcmux;
        unsigned int adcclrintpndnup;
 };
+
+unsigned short get_adc_value(int channel);
 #endif
 
 #endif /* __ASM_ARM_ARCH_ADC_H_ */
index 6c77a51..98cfe6b 100644 (file)
@@ -43,6 +43,7 @@
 #define S5PC100_MODEM_BASE     0xED500000
 #define S5PC100_MMC_BASE       0xED800000
 #define S5PC100_FIMD_BASE      0xEE000000
+#define S5PC100_ADC_BASE       0xF3000000
 
 /* S5PC110 */
 #define S5PC110_PRO_ID         0xE0000000
@@ -97,6 +98,7 @@ static inline unsigned int samsung_get_base_##device(void)    \
                return 0;                                       \
 }
 
+SAMSUNG_BASE(adc, ADC_BASE)
 SAMSUNG_BASE(clock, CLOCK_BASE)
 SAMSUNG_BASE(fimd, FIMD_BASE)
 SAMSUNG_BASE(gpio, GPIO_BASE)
index 2c96674..30a98f9 100644 (file)
@@ -35,6 +35,8 @@ struct s5p_adc {
        unsigned int adcmux;
        unsigned int adcclrintpndnup;
 };
+
+unsigned short get_adc_value(int channel);
 #endif
 
 #endif /* __ASM_ARM_ARCH_ADC_H_ */
index 5c6ca4d..84a68a3 100644 (file)
@@ -570,7 +570,6 @@ static int adc_to_temperature_centigrade(unsigned short adc)
        return approximation;
 }
 
-static unsigned short get_adc_value(int channel);
 static int adc_get_average_ambient_temperature(void)
 {
        unsigned short min = USHRT_MAX;
@@ -824,31 +823,6 @@ void init_panel_info(vidinfo_t *vid)
 }
 #endif
 
-static unsigned short get_adc_value(int channel)
-{
-       struct s5p_adc *adc = (struct s5p_adc *)samsung_get_base_adc();
-       unsigned short ret = 0;
-       unsigned int reg;
-       unsigned int loop = 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;
-
-       return ret;
-}
-
 static unsigned int get_hw_revision(void)
 {
        int hwrev = 0;
index 08c4d6b..27929b2 100644 (file)
@@ -1244,55 +1244,6 @@ static int adc_to_temperature_centigrade(unsigned short adc)
        return approximation;
 }
 
-static unsigned short get_adc_value(int channel)
-{
-       struct s5p_adc *adc = (struct s5p_adc *)S5PC110_ADC_BASE;
-       unsigned short ret = 0;
-       unsigned int reg;
-       int ldonum = 8;
-       char buf[64];
-       unsigned int loop = 0;
-
-       if (mach_is_goni())
-               ldonum = 4;
-       else if (mach_is_geminus())
-               ldonum = 4;
-       else if (mach_is_wmg160())
-               ldonum = 4;
-       else if (mach_is_cypress())
-               ldonum = 8;
-       else if (mach_is_tickertape())
-               ldonum = 8;
-       else if (mach_is_aquila())
-               ldonum = 8;
-       /*
-       else if (mach_is_p1p2())
-               ldonum = 4;
-       */
-
-       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;
-}
-
 static int adc_get_average_ambient_temperature(void)
 {
        if (mach_is_goni()) {
@@ -1302,6 +1253,8 @@ static int adc_get_average_ambient_temperature(void)
                unsigned int measured = 0;
                int i;
 
+               run_command("pmic ldo 4 on", 0);
+
                for (i = 0; i < 7; i++) {
                        unsigned short measurement = get_adc_value(6);
                        sum += measurement;
@@ -1311,6 +1264,9 @@ static int adc_get_average_ambient_temperature(void)
                        if (max < measurement)
                                max = measurement;
                }
+
+               run_command("pmic ldo 4 off", 0);
+
                if (measured >= 3) {
                        measured -= 2;
                        sum -= min;
index c6c37f0..0dacb53 100644 (file)
@@ -777,7 +777,6 @@ static int adc_to_temperature_centigrade(unsigned short adc)
        return approximation;
 }
 
-static unsigned short get_adc_value(int channel);
 static int adc_get_average_ambient_temperature(void)
 {
        unsigned short min = USHRT_MAX;
@@ -1088,31 +1087,6 @@ void init_panel_info(vidinfo_t *vid)
 }
 #endif
 
-static unsigned short get_adc_value(int channel)
-{
-       struct s5p_adc *adc = (struct s5p_adc *)samsung_get_base_adc();
-       unsigned short ret = 0;
-       unsigned int reg;
-       unsigned int loop = 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;
-
-       return ret;
-}
-
 static unsigned int get_hw_revision(void)
 {
        int hwrev, mode0, mode1;