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
--- /dev/null
+/*
+ * 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;
+}
unsigned int adcmux;
unsigned int adcclrintpndnup;
};
+
+unsigned short get_adc_value(int channel);
#endif
#endif /* __ASM_ARM_ARCH_ADC_H_ */
#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
return 0; \
}
+SAMSUNG_BASE(adc, ADC_BASE)
SAMSUNG_BASE(clock, CLOCK_BASE)
SAMSUNG_BASE(fimd, FIMD_BASE)
SAMSUNG_BASE(gpio, GPIO_BASE)
unsigned int adcmux;
unsigned int adcclrintpndnup;
};
+
+unsigned short get_adc_value(int channel);
#endif
#endif /* __ASM_ARM_ARCH_ADC_H_ */
return approximation;
}
-static unsigned short get_adc_value(int channel);
static int adc_get_average_ambient_temperature(void)
{
unsigned short min = USHRT_MAX;
}
#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;
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()) {
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;
if (max < measurement)
max = measurement;
}
+
+ run_command("pmic ldo 4 off", 0);
+
if (measured >= 3) {
measured -= 2;
sum -= min;
return approximation;
}
-static unsigned short get_adc_value(int channel);
static int adc_get_average_ambient_temperature(void)
{
unsigned short min = USHRT_MAX;
}
#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;