summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorGrzegorz Sygieda <grzegorz.sygieda@tieto.com>2010-07-16 15:01:08 +0200
committerMichael BRANDT <michael.brandt@stericsson.com>2010-07-19 15:05:39 +0200
commitb1078a80d3830ec0ee56091d48e1830abe48d1dd (patch)
treedad6c617fd198331f1c0e6547387a6e2b7896a60 /board
parentf68fc58b4fec93041c49771d45f6708653a29e73 (diff)
Applies vibrator support for U-boot.
This implements vibrator feature using AB8500 chip and I2C i/f. The vibrator driver provides shell command "vibrate". Checked with HREFP boards: 1.1_V21, 1.1_V31, 1.1_V33 ST-Ericsson ID: AP266348 Change-Id: Ifd0d780b41c4285038b8de659cdeac2086b8e873 Signed-off-by: Grzegorz Sygieda <grzegorz.sygieda@tieto.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/2937 Reviewed-by: Marcus COOPER <marcus.xm.cooper@stericsson.com> Reviewed-by: Michael BRANDT <michael.brandt@stericsson.com> Tested-by: Michael BRANDT <michael.brandt@stericsson.com>
Diffstat (limited to 'board')
-rw-r--r--board/st/u8500/Makefile2
-rw-r--r--board/st/u8500/ab8500vibra.c86
2 files changed, 87 insertions, 1 deletions
diff --git a/board/st/u8500/Makefile b/board/st/u8500/Makefile
index 254da4eae..ccaae6aa5 100644
--- a/board/st/u8500/Makefile
+++ b/board/st/u8500/Makefile
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
CFLAGS += -D__RELEASE -D__STN_8500
LIB = $(obj)lib$(BOARD).a
-COBJS := u8500.o flash.o gpio.o u8500_i2c.o mmc.o mmc_utils.o init_mmc.o emmc.o clock.o prcmu.o mcde_display.o mcde_hw.o
+COBJS := u8500.o flash.o gpio.o u8500_i2c.o mmc.o mmc_utils.o init_mmc.o emmc.o clock.o prcmu.o mcde_display.o mcde_hw.o ab8500vibra.o
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(COBJS))
diff --git a/board/st/u8500/ab8500vibra.c b/board/st/u8500/ab8500vibra.c
new file mode 100644
index 000000000..da08a8e64
--- /dev/null
+++ b/board/st/u8500/ab8500vibra.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2010
+ * Author: Grzegorz Sygieda <grzegorz.sygieda@tieto.com> for ST-Ericsson.
+ *
+ * License terms: GNU General Public License (GPL), version 2.
+ */
+
+#include <common.h>
+#include <command.h>
+#include <asm/arch/ab8500.h>
+
+/* Control vibrator */
+int do_vibrate(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ int time_ms = 100; /* 100 ms */
+ int intensity = 50; /* 50 % */
+ int reg;
+
+ /*
+ * We use the last specified parameters, unless new ones are
+ * entered.
+ */
+ if (!(flag & CMD_FLAG_REPEAT)) {
+ /* Parse vibration time if given */
+ if (argc >= 2)
+ time_ms = simple_strtoul(argv[1], NULL, 10);
+
+ /* Parse vibration intensity if given */
+ if (argc >= 3)
+ intensity = simple_strtoul(argv[2], NULL, 10);
+ }
+
+ /* disable audio registers reset */
+ reg = ab8500_read(AB8500_SYS_CTRL2_BLOCK, AB8500_CTRL3_REG);
+ ab8500_write(AB8500_SYS_CTRL2_BLOCK, AB8500_CTRL3_REG, reg | 0x02);
+ /* audio clock enable */
+ reg = ab8500_read(AB8500_SYS_CTRL2_BLOCK, AB8500_SYSULPCLK_CTRL1_REG);
+ ab8500_write(AB8500_SYS_CTRL2_BLOCK,
+ AB8500_SYSULPCLK_CTRL1_REG, reg | 0x10);
+ /* enable audio supply */
+ ab8500_write(AB8500_REGU_CTRL1, AB8500_REGU_VAUDIO_SUPPLY_REG, 0x02);
+
+ /*
+ * Audio related registers - Vibrator is controled using PWM
+ */
+ /* power up audio feature */
+ ab8500_write(AB8500_AUDIO, AB8500_AUDIO_POWER_UP, 0x88);
+ /* enable vibra class-D */
+ ab8500_write(AB8500_AUDIO, AB8500_AUDIO_ANA_CONF4, 0x03);
+ /* general vibra control */
+ ab8500_write(AB8500_AUDIO, AB8500_AUDIO_PWM_GEN_CONF1, 0xFF);
+
+ /*
+ * control register ... Set PWM intensity 0..100%
+ */
+ ab8500_write(AB8500_AUDIO, AB8500_AUDIO_PWM_GEN_CONF2, 0);
+ ab8500_write(AB8500_AUDIO, AB8500_AUDIO_PWM_GEN_CONF3, intensity);
+ ab8500_write(AB8500_AUDIO, AB8500_AUDIO_PWM_GEN_CONF4, 0);
+ ab8500_write(AB8500_AUDIO, AB8500_AUDIO_PWM_GEN_CONF5, intensity);
+
+ /* Sleep for time specified */
+ udelay(1000 * time_ms);
+
+ /* Set PWM RMS power to zero */
+ ab8500_write(AB8500_AUDIO, AB8500_AUDIO_PWM_GEN_CONF3, 0);
+ ab8500_write(AB8500_AUDIO, AB8500_AUDIO_PWM_GEN_CONF5, 0);
+
+ /* audio clock disable */
+ reg = ab8500_read(AB8500_SYS_CTRL2_BLOCK, AB8500_SYSULPCLK_CTRL1_REG);
+ ab8500_write(AB8500_SYS_CTRL2_BLOCK,
+ AB8500_SYSULPCLK_CTRL1_REG, reg & ~0x10);
+ /* power down audio feature */
+ ab8500_write(AB8500_AUDIO, AB8500_AUDIO_POWER_UP, 0);
+ /* disable audio supply */
+ ab8500_write(AB8500_REGU_CTRL1, AB8500_REGU_VAUDIO_SUPPLY_REG, 0);
+
+ return 0;
+}
+
+U_BOOT_CMD(
+ vibrate, 3, 1, do_vibrate,
+ "vibrator control utility\n",
+ "<time> <intensity> - vibrate for time, intensity specified\n"
+ "<time> - vibration time (default 100 ms)\n"
+ "<intensity> - vibration intensity (default 50 %)\n"
+);