sciphone_g2: Vibrator functionality

This patch adds vibrator functionality.
It implements vibrator driver and introduces new U-Boot command: vibrate

Signed-off-by: Marcin Mielczarczyk <marcin.mielczarczyk@tieto.com>
This commit is contained in:
Marcin Mielczarczyk 2011-02-16 14:51:16 +01:00
parent 3d64b95e4b
commit cef09789e6
8 changed files with 170 additions and 2 deletions

View File

@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).o 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-$(CONFIG_MTK_LCD) += lcd_backlight.o
COBJS := $(COBJS-y) COBJS := $(COBJS-y)

View File

@ -0,0 +1,56 @@
/*
* (C) 2010 by Tieto <www.tieto.com>
* Krzysztof Antonowicz <krzysztof.antonowicz@tieto.com>
*
* 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 <common.h>
#include <asm/io.h>
#include <asm/arch-mtk/mt6235.h>
#include <asm/arch-mtk/system.h>
#include <asm/arch-mtk/pwm.h>
#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);
}

View File

@ -192,4 +192,39 @@
#define PLL_PDN_CON_PLL (1 << 13) #define PLL_PDN_CON_PLL (1 << 13)
#define PLL_PDN_CON_DSP_DIV2 (1 << 15) #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 #endif

View File

@ -0,0 +1,30 @@
/*
* (C) 2010 by Tieto <www.tieto.com>
* Krzysztof Antonowicz <krzysztof.antonowicz@tieto.com>
*
* 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 */

View File

@ -143,6 +143,7 @@ COBJS-$(CONFIG_CMD_TSI148) += cmd_tsi148.o
COBJS-$(CONFIG_CMD_UBI) += cmd_ubi.o COBJS-$(CONFIG_CMD_UBI) += cmd_ubi.o
COBJS-$(CONFIG_CMD_UBIFS) += cmd_ubifs.o COBJS-$(CONFIG_CMD_UBIFS) += cmd_ubifs.o
COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o
COBJS-$(CONFIG_CMD_VIBRATE) += cmd_vibrate.o
ifdef CONFIG_CMD_USB ifdef CONFIG_CMD_USB
COBJS-y += cmd_usb.o COBJS-y += cmd_usb.o
COBJS-y += usb.o COBJS-y += usb.o

45
common/cmd_vibrate.c Normal file
View File

@ -0,0 +1,45 @@
/*
* (C) 2010 by Tieto <www.tieto.com>
* Marcin Mielczarczyk <marcin.mielczarczyk@tieto.com>
*
* 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 <common.h>
#include <command.h>
#include <asm/arch-mtk/vibra.h>
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"
);

View File

@ -533,7 +533,7 @@ void lcd_disable(void)
DEBUG_LINE(); DEBUG_LINE();
/* Stop control of LCD frame transfer. */ /* 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. */ /* Turn off the LCD block in MTK. */
writew(PDN_CON1_LCD, MTK_CONFG_PDN_SET1); writew(PDN_CON1_LCD, MTK_CONFG_PDN_SET1);

View File

@ -79,6 +79,7 @@
#define CONFIG_CMD_RUN #define CONFIG_CMD_RUN
#define CONFIG_CMD_SAVEENV #define CONFIG_CMD_SAVEENV
#define CONFIG_CMD_MTDPARTS #define CONFIG_CMD_MTDPARTS
#define CONFIG_CMD_VIBRATE
#define CONFIG_CMDLINE_TAG #define CONFIG_CMDLINE_TAG
/* Timing configuration */ /* Timing configuration */