static char tx_data[TX_DATA_LEN] = "MPL";
static char rx_data[RX_DATA_LEN];
+static int downloading;
extern int s5p_receive_done;
extern int s5p_usb_connected;
extern void s5pc_fimd_lcd_off(unsigned int win_id);
extern void s5pc_fimd_window_off(unsigned int win_id);
extern void get_rev_info(char *rev_info);
+extern int check_exit_key(void);
#ifdef CONFIG_GENERIC_MMC
#include <mmc.h>
}
/* start the usb controller */
-static void usb_init(void)
+static int usb_init(void)
{
if (usb_board_init()) {
puts("Failed to usb_board_init\n");
- return;
+ return 0;
}
#ifdef CONFIG_S5PC1XXFB
fb_printf("\n");
#endif
- fb_printf("Ready to USB Connection\n");
+ fb_printf("USB Download Mode\n");
+ fb_printf("Press the POWERKEY to CANCEL the downloading\n");
}
#endif
s5p_udc_int_hndlr();
s5p_usb_clear_irq();
}
+
+ if (check_exit_key())
+ return 0;
}
s5p_usb_clear_dnfile_info();
puts("Connected!!\n");
+ return 1;
+}
+
+static void usb_stop(void)
+{
+#ifdef CONFIG_S5PC1XXFB
+ if (!s5p_no_lcd_support()) {
+ exit_font();
+
+ /* it uses fb3 as default window. */
+ s5pc_fimd_lcd_off(3);
+ s5pc_fimd_window_off(3);
+ }
+#endif
+}
+
+static void down_start(void)
+{
+ downloading = 1;
+
#ifdef CONFIG_S5PC1XXFB
if (!s5p_no_lcd_support()) {
fb_printf("Download Start\n");
- draw_progress(80, 0, FONT_WHITE);
+ draw_progress(95, 0, FONT_WHITE);
}
#endif
}
-static void usb_stop(void)
+static void down_cancel(void)
{
#ifdef CONFIG_S5PC1XXFB
if (!s5p_no_lcd_support()) {
exit_font();
- /* it uses fb3 as default window. */
- s5pc_fimd_lcd_off(3);
- s5pc_fimd_window_off(3);
+ /* clear fb */
+ fb_clear(100);
}
#endif
+ run_command("run ubifsboot", 0);
}
/*
s5p_receive_done = 0;
return otg.dn_filesize;
}
+
+ if (!downloading) {
+ if (check_exit_key())
+ return 0;
+ }
}
}
#ifdef CONFIG_S5PC1XXFB
static void set_progress(int progress)
{
- draw_progress(80, progress, FONT_WHITE);
+ draw_progress(95, progress, FONT_WHITE);
}
#endif
+
/*
* This function is interfaced between
* USB Device Controller and USB Downloader
usbd->tx_len = TX_DATA_LEN;
usbd->rx_len = RX_DATA_LEN;
usbd->ram_addr = CONFIG_SYS_DOWN_ADDR;
+ usbd->down_cancel = down_cancel;
+ usbd->down_start = down_start;
#ifdef CONFIG_S5PC1XXFB
if (!s5p_no_lcd_support())
usbd->set_progress = set_progress;
#ifdef CONFIG_GENERIC_MMC
usbd_set_mmc_dev(usbd);
#endif
+ downloading = 0;
return usbd;
}
gpio_set_pull(&gpio->h3, 4, GPIO_PULL_UP);
}
-static int power_key_check(void)
-{
- unsigned char addr, val[2];
-
- addr = 0xCC >> 1;
- i2c_set_bus_num(I2C_PMIC);
-
- if (i2c_probe(addr)) {
- puts("Can't found max8998\n");
- return 1;
- }
-
- /* power_key check */
- i2c_read(addr, 0x00, 1, val, 1);
- return val[0] & (1 << 7);
-}
-
-#define KBR3 (1 << 3)
-#define KBR2 (1 << 2)
-#define KBR1 (1 << 1)
-#define KBR0 (1 << 0)
-
-static void check_keypad(void)
-{
- unsigned int reg, value;
- unsigned int col_num, row_num;
- unsigned int col_mask;
- unsigned int col_mask_shift;
- unsigned int row_state[4];
- unsigned int i, power_key;
- unsigned int auto_download = 0;
-
- if (mach_is_wmg160())
- return;
-
- if (board_is_limo_real() || board_is_limo_universal()) {
- row_num = 2;
- col_num = 3;
- } else {
- row_num = 4;
- col_num = 4;
- }
-
- for (i = 0; i < row_num; i++) {
- if (board_is_sdk() &&
- (hwrevision(3) || hwrevision(4)) && i == 0)
- continue;
-
- /* Set GPH3[3:0] to KP_ROW[3:0] */
- gpio_cfg_pin(&gpio->h3, i, 0x3);
- gpio_set_pull(&gpio->h3, i, GPIO_PULL_UP);
- }
-
- for (i = 0; i < col_num; i++)
- /* Set GPH2[3:0] to KP_COL[3:0] */
- gpio_cfg_pin(&gpio->h2, i, 0x3);
-
- reg = S5PC110_KEYPAD_BASE;
- col_mask = S5PC110_KEYIFCOLEN_MASK;
- col_mask_shift = 8;
-
- /* KEYIFCOL reg clear */
- writel(0, reg + S5PC1XX_KEYIFCOL_OFFSET);
-
- /* power_key check */
- power_key = power_key_check();
-
- /* key_scan */
- for (i = 0; i < col_num; i++) {
- value = col_mask;
- value &= ~(1 << i) << col_mask_shift;
-
- writel(value, reg + S5PC1XX_KEYIFCOL_OFFSET);
- udelay(1000);
-
- value = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
- row_state[i] = ~value & ((1 << row_num) - 1);
- }
-
- /* KEYIFCOL reg clear */
- writel(0, reg + S5PC1XX_KEYIFCOL_OFFSET);
-
- if (mach_is_aquila() || mach_is_goni()) {
- /* volume down */
- if (row_state[1] & 0x2)
- display_info = 1;
- if (board_is_sdk() && hwrevision(0)) {
- /* home & volume down
- * or hold key & volume down*/
- if ((power_key || (row_state[1] & 0x1))
- && (row_state[1] & 0x2))
- auto_download = 1;
- } else if (board_is_sdk() && hwrevision(2)) {
- /* cam full shot & volume down
- * or hold key & volume down */
- if ((power_key || (row_state[1] & 0x6))
- && (row_state[2] & 0x4))
- auto_download = 1;
- } else if (board_is_sdk() && (hwrevision(3) || hwrevision(4) ||
- hwrevision(6))) {
- /* cam full shot & volume down
- * or hold key & volume down */
- if ((power_key || (row_state[1] & 0x6))
- && (row_state[2] & 0x4))
- auto_download = 1;
- } else {
- /* cam full shot & volume down
- * or hold key & volume down */
- if ((power_key || (row_state[0] & 0x1))
- && (row_state[1] & 0x2))
- auto_download = 1;
- }
- } else if (mach_is_geminus())
- /* volume down & home or hold key & volume down */
- if ((row_state[1] & 0x2) && ((power_key || row_state[2] & 0x1)))
- auto_download = 1;
-
- if (auto_download)
- setenv("bootcmd", "usbdown");
-}
-
static void check_battery(int mode)
{
unsigned char val[2];
i2c_read(addr, 0x03, 1, val, 1);
}
+static int poweron_key_check(void)
+{
+ unsigned char addr, val[2];
+
+ addr = 0xCC >> 1;
+ if (max8998_probe())
+ return 0;
+
+ i2c_read(addr, 0x02, 1, val, 1);
+ return val[0] & 0x1;
+}
+
+int check_exit_key(void)
+{
+ return poweron_key_check();
+}
+
static int max8998_power_key(void)
{
unsigned char addr, val[2];
return 0;
}
+static int power_key_check(void)
+{
+ unsigned char addr, val[2];
+
+ addr = 0xCC >> 1;
+
+ if (max8998_probe())
+ return 0;
+
+ /* power_key check */
+ i2c_read(addr, 0x00, 1, val, 1);
+ return val[0] & (1 << 7);
+}
+
+#define KBR3 (1 << 3)
+#define KBR2 (1 << 2)
+#define KBR1 (1 << 1)
+#define KBR0 (1 << 0)
+
+static void check_keypad(void)
+{
+ unsigned int reg, value;
+ unsigned int col_num, row_num;
+ unsigned int col_mask;
+ unsigned int col_mask_shift;
+ unsigned int row_state[4];
+ unsigned int i, power_key;
+ unsigned int auto_download = 0;
+
+ if (mach_is_wmg160())
+ return;
+
+ if (board_is_limo_real() || board_is_limo_universal()) {
+ row_num = 2;
+ col_num = 3;
+ } else {
+ row_num = 4;
+ col_num = 4;
+ }
+
+ for (i = 0; i < row_num; i++) {
+ if (board_is_sdk() &&
+ (hwrevision(3) || hwrevision(4)) && i == 0)
+ continue;
+
+ /* Set GPH3[3:0] to KP_ROW[3:0] */
+ gpio_cfg_pin(&gpio->h3, i, 0x3);
+ gpio_set_pull(&gpio->h3, i, GPIO_PULL_UP);
+ }
+
+ for (i = 0; i < col_num; i++)
+ /* Set GPH2[3:0] to KP_COL[3:0] */
+ gpio_cfg_pin(&gpio->h2, i, 0x3);
+
+ reg = S5PC110_KEYPAD_BASE;
+ col_mask = S5PC110_KEYIFCOLEN_MASK;
+ col_mask_shift = 8;
+
+ /* KEYIFCOL reg clear */
+ writel(0, reg + S5PC1XX_KEYIFCOL_OFFSET);
+
+ /* power_key check */
+ power_key = power_key_check();
+
+ /* key_scan */
+ for (i = 0; i < col_num; i++) {
+ value = col_mask;
+ value &= ~(1 << i) << col_mask_shift;
+
+ writel(value, reg + S5PC1XX_KEYIFCOL_OFFSET);
+ udelay(1000);
+
+ value = readl(reg + S5PC1XX_KEYIFROW_OFFSET);
+ row_state[i] = ~value & ((1 << row_num) - 1);
+ }
+
+ /* KEYIFCOL reg clear */
+ writel(0, reg + S5PC1XX_KEYIFCOL_OFFSET);
+
+ if (mach_is_aquila() || mach_is_goni()) {
+ /* volume down */
+ if (row_state[1] & 0x2)
+ display_info = 1;
+ if (board_is_sdk() && hwrevision(0)) {
+ /* home & volume down
+ * or hold key & volume down*/
+ if ((power_key || (row_state[1] & 0x1))
+ && (row_state[1] & 0x2))
+ auto_download = 1;
+ } else if (board_is_sdk() && hwrevision(2)) {
+ /* cam full shot & volume down
+ * or hold key & volume down */
+ if ((power_key || (row_state[1] & 0x6))
+ && (row_state[2] & 0x4))
+ auto_download = 1;
+ } else if (board_is_sdk() && (hwrevision(3) || hwrevision(4) ||
+ hwrevision(6))) {
+ /* cam full shot & volume down
+ * or hold key & volume down */
+ if ((power_key || (row_state[1] & 0x6))
+ && (row_state[2] & 0x4))
+ auto_download = 1;
+ } else {
+ /* cam full shot & volume down
+ * or hold key & volume down */
+ if ((power_key || (row_state[0] & 0x1))
+ && (row_state[1] & 0x2))
+ auto_download = 1;
+ }
+ } else if (mach_is_geminus())
+ /* volume down & home or hold key & volume down */
+ if ((row_state[1] & 0x2) && ((power_key || row_state[2] & 0x1)))
+ auto_download = 1;
+
+ if (auto_download)
+ setenv("bootcmd", "usbdown");
+}
+
+
static int max8998_has_ext_power_source(void)
{
unsigned char addr, val[2];
#ifdef CONFIG_CMD_USBDOWN
int usb_board_init(void)
{
+ /* interrupt clear */
+ poweron_key_check();
+
#ifdef CONFIG_CMD_PMIC
run_command("pmic ldo 8 on", 0);
run_command("pmic ldo 3 on", 0);
memset((void *)magic_base, 0, 2);
}
-static int power_key_check(void)
-{
- unsigned char addr, val[2];
-
- addr = 0xCC >> 1;
- i2c_set_bus_num(I2C_5);
-
- if (i2c_probe(addr)) {
- puts("Can't found lp3974\n");
- return 1;
- }
-
- /* power_key check */
- i2c_read(addr, 0x00, 1, val, 1);
- return (~val[0] & (1 << 6)) >> 6;
-}
-
-static void check_keypad(void)
-{
- unsigned int val = 0;
- unsigned int power_key, auto_download = 0;
-
- val = ~(gpio_get_value(&gpio2->x2, 1));
-
- power_key = power_key_check();
-
- if (power_key && (val & 0x1))
- auto_download = 1;
-
- if (auto_download)
- setenv("bootcmd", "usbdown");
-}
-
static void check_battery(int mode)
{
unsigned char val[2];
i2c_write(addr, 0x2, 1, val, 1);
}
+#define LP3974_REG_IRQ1 0x00
+#define LP3974_REG_IRQ2 0x01
+#define LP3974_REG_IRQ3 0x02
#define LP3974_REG_ONOFF1 0x11
#define LP3974_REG_ONOFF2 0x12
#define LP3974_REG_ONOFF3 0x13
#define LP3974_REG_ONOFF4 0x14
-#define LP3974_REG_LDO7 0x21
+#define LP3974_REG_LDO7 0x21
#define LP3974_REG_LDO17 0x29
#define LP3974_REG_UVLO 0xB9
#define LP3974_REG_MODCHG 0xEF
i2c_write(addr, LP3974_REG_MODCHG, 1, val, 1);
}
+static int poweron_key_check(void)
+{
+ unsigned char addr, val[2];
+
+ addr = 0xCC >> 1;
+ if (lp3974_probe())
+ return 0;
+
+ i2c_read_r(addr, LP3974_REG_IRQ3, 1, val, 1);
+ return val[0] & 0x1;
+}
+
+int check_exit_key(void)
+{
+ return poweron_key_check();
+}
+
+static int power_key_check(void)
+{
+ unsigned char addr, val[2];
+
+ addr = 0xCC >> 1;
+ if (lp3974_probe())
+ return -1;
+
+ /* power_key check */
+ i2c_read_r(addr, LP3974_REG_IRQ1, 1, val, 1);
+ return (~val[0] & (1 << 6)) >> 6;
+}
+
+static void check_keypad(void)
+{
+ unsigned int val = 0;
+ unsigned int power_key, auto_download = 0;
+
+ val = ~(gpio_get_value(&gpio2->x2, 1));
+
+ power_key = power_key_check();
+
+ if (power_key && (val & 0x1))
+ auto_download = 1;
+
+ if (auto_download)
+ setenv("bootcmd", "usbdown");
+}
+
/*
* charger_en(): set lp3974 pmic's charger mode
* enable 0: disable charger
#ifdef CONFIG_CMD_USBDOWN
int usb_board_init(void)
{
+ /* interrupt clear */
+ poweron_key_check();
+
#ifdef CONFIG_CMD_PMIC
run_command("pmic ldo 8 on", 0);
run_command("pmic ldo 3 on", 0);