#include <asm/arch/mmc.h>
#include <asm/arch/power.h>
#include <asm/arch/mem.h>
+#include <asm/errno.h>
#include <fbutils.h>
#include <lcd.h>
static unsigned int board_rev;
static unsigned int battery_soc;
+static struct s5pc110_gpio *s5pc110_gpio;
enum {
I2C_2,
int board_init(void)
{
+ /* Set Initial global variables */
+ s5pc110_gpio = (struct s5pc110_gpio *) S5PC110_GPIO_BASE;
+
gd->bd->bi_arch_number = MACH_TYPE;
gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
#endif
#ifdef CONFIG_CMD_DEVICE_POWER
+
enum {
POWER_NONE,
+ POWER_TOUCH,
POWER_3_TOUCHKEY,
+ POWER_LCD,
+ POWER_HAPTIC,
};
-static void power_3_touchkey(int on)
+static void power_display_devices(void)
{
- struct s5pc110_gpio *gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
+ printf("devices:\n");
+ printf("\t%d - touch\n", POWER_TOUCH);
+ printf("\t%d - 3 touchkey\n", POWER_3_TOUCHKEY);
+ printf("\t%d - LCD\n", POWER_LCD);
+ printf("\t%d - Haptic\n", POWER_HAPTIC);
+}
+
+static int power_haptic(int on)
+{
+ /* HAPTIC_ON: GPJ1[1] */
+ gpio_direction_output(&s5pc110_gpio->gpio_j1, 1, on);
+ return 0;
+}
+
+static int power_lcd(int on)
+{
+ /* MLCD_ON: GPJ1[3] */
+ gpio_direction_output(&s5pc110_gpio->gpio_j1, 3, on);
+ return 0;
+}
- /* TOUCH_EN - GPIO_J3(0) : (J1B2) */
- /* TOUCH_EN - GPIO_J3(5) : (not J1B2) */
+static int power_touch(int on)
+{
+ /* TOUCH_EN: GPG3[6] */
+ gpio_direction_output(&s5pc110_gpio->gpio_g3, 6, on);
+ return 0;
+}
+
+static int power_3_touchkey(int on)
+{
+ /* 3_TOUCH_EN - GPJ3[0] : (J1B2) */
+ /* 3_TOUCH_EN - GPJ3[5] : (not J1B2) */
if (board_rev & J1_B2_BOARD)
- gpio_direction_output(&gpio->gpio_j3, 0, on);
+ gpio_direction_output(&s5pc110_gpio->gpio_j3, 0, on);
else
- gpio_direction_output(&gpio->gpio_j3, 5, on);
+ gpio_direction_output(&s5pc110_gpio->gpio_j3, 5, on);
- /* TOUCH_CE - GPIO_J2(6) */
- gpio_direction_output(&gpio->gpio_j2, 6, on); /* TOUCH_CE */
+ /* 3_TOUCH_CE - GPJ2[6] */
+ gpio_direction_output(&s5pc110_gpio->gpio_j2, 6, on); /* TOUCH_CE */
if (on) {
unsigned int reg;
unsigned char val[2];
unsigned char addr = 0x20; /* mcs5000 3-touchkey */
- if (!machine_is_aquila())
- return;
-
/* Require 100ms */
udelay(80 * 1000);
if (i2c_probe(addr)) {
if (i2c_probe(addr)) {
printf("Can't found 3 touchkey\n");
- return;
+ return -ENODEV;
}
}
i2c_read(addr, reg, 1, val, 1);
printf("F/W 0x%x\n", val[0]);
}
+ return 0;
}
static int power_control(int device, int on)
{
switch (device) {
+ case POWER_TOUCH:
+ return power_touch(on);
case POWER_3_TOUCHKEY:
- power_3_touchkey(on);
- break;
+ return power_3_touchkey(on);
+ case POWER_LCD:
+ return power_lcd(on);
+ case POWER_HAPTIC:
+ return power_haptic(on);
default:
printf("I don't know device %d\n", device);
break;
{
int device, on;
+ if (!machine_is_aquila())
+ goto out;
+
switch (argc) {
case 2:
break;
default:
break;
}
-
+out:
cmd_usage(cmdtp);
+ power_display_devices();
return 1;
}
power, CONFIG_SYS_MAXARGS, 1, do_power,
"Device Power Management control",
"device on/off - Turn on/off the device\n"
- "devices:\n"
- " 1 - 3 touchkey\n"
);
#endif