1 /******************************************************************************
2 * mt6575_vibrator.c - MT6575 Android Linux Vibrator Device Driver
4 * Copyright 2009-2010 MediaTek Co.,Ltd.
7 * This file provid the other drivers vibrator relative functions
9 ******************************************************************************/
11 #include <linux/init.h>
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/types.h>
15 #include <linux/device.h>
16 #include <mach/mt_typedefs.h>
17 #include <cust_vibrator.h>
18 #include <mach/upmu_common_sw.h>
19 #include <mach/upmu_hw.h>
20 #include <linux/delay.h>
22 #ifdef CONFIG_MTK_PMIC_MT6397
23 static int vibe_mode
= 0;
25 extern S32
pwrap_read( U32 adr
, U32
*rdata
);
26 extern S32
pwrap_write( U32 adr
, U32 wdata
);
28 // pmic wrap read and write func
29 static unsigned int vibr_pmic_pwrap_read(U32 addr
)
33 pwrap_read(addr
, &val
);
38 static void vibr_pmic_pwrap_write(unsigned int addr
, unsigned int wdata
)
41 //unsigned int val =0;
42 pwrap_write(addr
, wdata
);
45 extern void dct_pmic_VIBR_enable(kal_bool dctEnable
);
47 void vibr_Enable_HW(void)
51 printk("[vibrator]vibr_Enable \n");
53 #ifdef CONFIG_MTK_PMIC_MT6397
56 if(hwPowerOn(MT65XX_POWER_LDO_VIBR, VOL_2800, "VIBR")) {
60 //dct_pmic_VIBR_enable(1);
62 upmu_set_rg_vibr_sw_mode(1);// [bit 5]: VIBR_SW_MODE 0=HW, 1=SW
63 upmu_set_rg_vibr_vosel(7); // [bit 11-9]: VIBR_SEL, 101=2.8V, 110=3.0V, 111=3.3V
64 upmu_set_rg_vibr_fr_ori(1); //[bit 4-3]: VIBR_FR_ORI, 00=float, 01=forward, 10=braking, 11=backward
65 //upmu_set_rg_vibr_mst_time(); //[bit 7-6]: VIBR_MST_TIME, 00=1us, 01=2us, 10=4us, 11=8us
67 upmu_set_rg_vibr_en(1); //[bit 15]: VIBR_EN, 1=enable
68 upmu_set_rg_vibr_pwdb(1); //[bit 6]: VIBR_PWDB, 1=enable
71 dct_pmic_VIBR_enable(1);
78 void vibr_Disable_HW(void)
80 printk("[vibrator]vibr_Disable \n");
82 #ifdef CONFIG_MTK_PMIC_MT6397
85 if(hwPowerDown(MT65XX_POWER_LDO_VIBR, "VIBR")) {
89 //dct_pmic_VIBR_enable(0);
93 upmu_set_rg_vibr_fr_ori(2); //[bit 4-3]: VIBR_FR_ORI, 00=float, 01=forward, 10=braking, 11=backward
94 upmu_set_rg_vibr_fr_ori(3); //[bit 4-3]: VIBR_FR_ORI, 00=float, 01=forward, 10=braking, 11=backward
96 msleep(30); //delay 30ms
97 upmu_set_rg_vibr_fr_ori(2); //[bit 4-3]: VIBR_FR_ORI, 00=float, 01=forward, 10=braking, 11=backward
98 upmu_set_rg_vibr_en(0); //[bit 15]: VIBR_EN, 1=enable
99 upmu_set_rg_vibr_pwdb(0); //[bit 6]: VIBR_PWDB, 1=enable
102 upmu_set_rg_vibr_en(0); //[bit 15]: VIBR_EN, 1=enable
103 upmu_set_rg_vibr_pwdb(0); //[bit 6]: VIBR_PWDB, 1=enable
108 dct_pmic_VIBR_enable(0);
114 void vibr_power_set(void)
117 struct vibrator_hw
* hw
= get_cust_vibrator_hw();
118 printk("[vibrator]vibr_init: vibrator set voltage = %d\n", hw
->vib_vol
);
119 upmu_set_rg_vibr_vosel(hw
->vib_vol
);
123 struct vibrator_hw
* mt_get_cust_vibrator_hw(void)
125 return get_cust_vibrator_hw();