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>master
parent
3d64b95e4b
commit
cef09789e6
@ -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);
|
||||
} |
@ -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 */ |
@ -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" |
||||
); |
Loading…
Reference in new issue