diff --git a/arch/arm/cpu/arm926ejs/mtk/Makefile b/arch/arm/cpu/arm926ejs/mtk/Makefile index f97d8a11c..cf74bf8a3 100644 --- a/arch/arm/cpu/arm926ejs/mtk/Makefile +++ b/arch/arm/cpu/arm926ejs/mtk/Makefile @@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(SOC).o -COBJS-y = timer.o reset.o +COBJS-y = timer.o reset.o vibra.o COBJS-$(CONFIG_MTK_LCD) += lcd_backlight.o COBJS := $(COBJS-y) diff --git a/arch/arm/cpu/arm926ejs/mtk/vibra.c b/arch/arm/cpu/arm926ejs/mtk/vibra.c new file mode 100644 index 000000000..b035792dc --- /dev/null +++ b/arch/arm/cpu/arm926ejs/mtk/vibra.c @@ -0,0 +1,56 @@ +/* + * (C) 2010 by Tieto + * Krzysztof Antonowicz + * + * All Rights Reserved + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include +#include +#include +#include + +#define PWM2_TRESH_VALUE 16 +#define PWM2_DATA_WIDTH_VALUE 16 +#define PWM2_GDURATION_VALUE 0 + +void vibra_on(void) +{ + /* Power up PWM2 */ + writew(PDN_CON1_PWM2, MTK_CONFG_PDN_CLR1); + + /* Enable VIBRA in PMIC. */ + writew(readw(MTK_PMIC_CON5) | PMIC_CON5_VIBR_EN, MTK_PMIC_CON5); + + /* Configure PWM2 output in old mode and with 32kHz. */ + writew(PWM_CON_OLD_PWM_MODE | PWM_CON_CLKSEL, PWM_PWM2_CON); + + writew(PWM2_TRESH_VALUE, PWM_PWM2_THRESH); + writew(PWM2_DATA_WIDTH_VALUE, PWM_PWM2_DATA_WIDTH); + writew(PWM2_GDURATION_VALUE, PWM_PWM2_GDURATION); + + /* Start vibrating. */ + writew(readw(PWM_ENABLE) | PWM_ENABLE_PWM2_EN, PWM_ENABLE); +} + +void vibra_off(void) +{ + writew(readw(PWM_ENABLE) & (~PWM_ENABLE_PWM2_EN), PWM_ENABLE); + //writew(PDN_CON1_PWM2, MTK_CONFG_PDN_SET1); +} diff --git a/arch/arm/include/asm/arch-mtk/system.h b/arch/arm/include/asm/arch-mtk/system.h index 454302917..9ceb90576 100644 --- a/arch/arm/include/asm/arch-mtk/system.h +++ b/arch/arm/include/asm/arch-mtk/system.h @@ -192,4 +192,39 @@ #define PLL_PDN_CON_PLL (1 << 13) #define PLL_PDN_CON_DSP_DIV2 (1 << 15) +/* PMIC registry. */ +#define MTK_PMIC_CON0 0x83010800 +#define MTK_PMIC_CON1 0x83010804 +#define MTK_PMIC_CON2 0x83010808 +#define MTK_PMIC_CON3 0x8301080C +#define MTK_PMIC_CON4 0x83010810 +#define MTK_PMIC_CON5 0x83010814 +#define MTK_PMIC_CON6 0x83010818 +#define MTK_PMIC_CON7 0x8301081C +#define MTK_PMIC_CON8 0x83010820 +#define MTK_PMIC_CON9 0x83010824 +#define MTK_PMIC_CONA 0x83010828 +#define MTK_PMIC_CONB 0x8301082C +#define MTK_PMIC_CONC 0x83010830 +#define MTK_PMIC_COND 0x83010834 +#define MTK_PMIC_CONE 0x83010838 +#define MTK_PMIC_CONF 0x8301083C +#define MTK_PMIC_CONG 0x83010840 + +/* MTK_PMIC_CON5 bit field definitions. */ +#define PMIC_CON5_VIBR_EN (1 << 0) +#define PMIC_CON5_KPLED_EN (1 << 1) +#define PMIC_CON5_RLED_EN (1 << 2) +#define PMIC_CON5_GLED_EN (1 << 3) +#define PMIC_CON5_BLED_EN (1 << 4) +#define PMIC_CON5_INT_NODE_MUX (1 << 5) +#define PMIC_CON5_VSIM_EN (1 << 8) +#define PMIC_CON5_VSIM_SEL (1 << 9) +#define PMIC_CON5_OVP (1 << 10) +#define PMIC_CON5_CHRDET (1 << 11) +#define PMIC_CON5_BAT_ON (1 << 12) +#define PMIC_CON5_AC_DET (1 << 13) +#define PMIC_CON5_CV (1 << 14) +#define PMIC_CON5_CHRG_DIS (1 << 15) + #endif diff --git a/arch/arm/include/asm/arch-mtk/vibra.h b/arch/arm/include/asm/arch-mtk/vibra.h new file mode 100644 index 000000000..f9e0b50cd --- /dev/null +++ b/arch/arm/include/asm/arch-mtk/vibra.h @@ -0,0 +1,30 @@ +/* + * (C) 2010 by Tieto + * Krzysztof Antonowicz + * + * All Rights Reserved + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef __VIBRA_H +#define __VIBRA_H + +void vibra_on(void); + +void vibra_off(void); + +#endif /* __VIBRA_H */ diff --git a/common/Makefile b/common/Makefile index 048df0cbc..83e3735ac 100644 --- a/common/Makefile +++ b/common/Makefile @@ -143,6 +143,7 @@ COBJS-$(CONFIG_CMD_TSI148) += cmd_tsi148.o COBJS-$(CONFIG_CMD_UBI) += cmd_ubi.o COBJS-$(CONFIG_CMD_UBIFS) += cmd_ubifs.o COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o +COBJS-$(CONFIG_CMD_VIBRATE) += cmd_vibrate.o ifdef CONFIG_CMD_USB COBJS-y += cmd_usb.o COBJS-y += usb.o diff --git a/common/cmd_vibrate.c b/common/cmd_vibrate.c new file mode 100644 index 000000000..753dd74d9 --- /dev/null +++ b/common/cmd_vibrate.c @@ -0,0 +1,45 @@ +/* + * (C) 2010 by Tieto + * Marcin Mielczarczyk + * + * All Rights Reserved + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include +#include + +int do_vibrate(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + if (2 != argc) + goto usage; + + vibra_on(); + udelay(1000 * simple_strtoul(argv[1], NULL, 10)); + vibra_off(); + + return 0; +usage: + return cmd_usage(cmdtp); +} + +U_BOOT_CMD( + vibrate, 2, 1, do_vibrate, + "vibrator control", + "time_in_ms - starts vibrator for given time" +); diff --git a/drivers/video/mtk_lcd.c b/drivers/video/mtk_lcd.c index 90337dd4a..3eff995bf 100644 --- a/drivers/video/mtk_lcd.c +++ b/drivers/video/mtk_lcd.c @@ -533,7 +533,7 @@ void lcd_disable(void) DEBUG_LINE(); /* Stop control of LCD frame transfer. */ - writew(LCD_START_START, (~LCD_START)); + writew((unsigned short)~LCD_START_START, LCD_START); /* Turn off the LCD block in MTK. */ writew(PDN_CON1_LCD, MTK_CONFG_PDN_SET1); diff --git a/include/configs/sciphone_g2.h b/include/configs/sciphone_g2.h index dc065bf60..9292f42ff 100644 --- a/include/configs/sciphone_g2.h +++ b/include/configs/sciphone_g2.h @@ -79,6 +79,7 @@ #define CONFIG_CMD_RUN #define CONFIG_CMD_SAVEENV #define CONFIG_CMD_MTDPARTS +#define CONFIG_CMD_VIBRATE #define CONFIG_CMDLINE_TAG /* Timing configuration */