rockchip: add gpio_poweroff driver
authorcl <cl@rock-chips.com>
Thu, 16 Oct 2014 02:47:26 +0000 (10:47 +0800)
committercl <cl@rock-chips.com>
Thu, 16 Oct 2014 03:13:34 +0000 (11:13 +0800)
Signed-off-by: cl <cl@rock-chips.com>
arch/arm/boot/dts/rk3126-86v.dts
arch/arm/configs/rockchip_defconfig
drivers/power/rk30_factory_adc_battery.c
kernel/sys.c

index a136b978b7c621e6a9e67d32c34794c06c5114f8..e4d46fe0b7bfe72a443b9108e2d05ef404c9cb67 100644 (file)
                 enable-gpios = <&gpio3 GPIO_C1 GPIO_ACTIVE_HIGH>;
         };
 
+       gpio_poweroff {
+               compatible = "gpio-poweroff";
+               gpios = <&gpio1 GPIO_A2 GPIO_ACTIVE_LOW>;
+       };
 
        usb_control {
                compatible = "rockchip,rk3126-usb-control";
                compatible = "rk30-adc-battery";
                 io-channels = <&adc 0>;
                dc_det_gpio = <&gpio2 GPIO_B1 GPIO_ACTIVE_LOW>;
-               pwr_hold = <&gpio1 GPIO_A2 GPIO_ACTIVE_LOW>;
                //bat_low_gpio = <&gpio0 GPIO_A7 GPIO_ACTIVE_LOW>;
                //chg_ok_gpio = <&gpio0 GPIO_B1 GPIO_ACTIVE_HIGH>;
                bat_table = <0 0 0 0 100 100
 
 &dwc_control_usb {
        usb_uart {
-               status = "disabled";
+               status = "ok";
        };
 };
 
index 7c8d4aa439ab87f08a09d93b769690161c8a7fd2..4c4ebf47c7897acdf5e27def901a36d25b2ef069 100644 (file)
@@ -354,6 +354,8 @@ CONFIG_BATTERY_BQ24296=y
 CONFIG_BATTERY_BQ27320=y
 CONFIG_BATTERY_RK30_ADC_FAC=y
 CONFIG_CW2015_BATTERY=y
+CONFIG_POWER_RESET=y
+CONFIG_POWER_RESET_GPIO=y
 CONFIG_SENSORS_ROCKCHIP_TSADC=y
 CONFIG_THERMAL=y
 CONFIG_MFD_RT5025=y
index b07d98f37393207f586db7e41b86163fa8cbfcfc..5b4d36cdb984f29bf4a3b6d2b5299267877a4859 100755 (executable)
@@ -44,7 +44,6 @@
 #include <linux/iio/driver.h>
 #include <linux/iio/consumer.h>
 
-#include <asm/system_misc.h>
 #ifdef CONFIG_EARLYSUSPEND
 /* kernel/power/earlysuspend.c */
 extern suspend_state_t get_suspend_state(void);
@@ -105,8 +104,6 @@ int    gDoubleVoltageCnt = 6800;
 unsigned long gSecondsCnt = 0;
 char gDischargeFlag[4] = {"on "};
 
-int pwr_hold;
-
 #if 1
 #define BATT_MAX_VOL_VALUE     4250/*Full  charge volatge*/
 #define BATT_ZERO_VOL_VALUE    3500/*power down voltage*/
@@ -246,37 +243,6 @@ static  bool batt_gpio_is_valid(int number)
 {
        return number > 0 && number < 256;
 }
-
-static void v86_pm_power_off(void)
-{
-
-   bool isCharging = false; 
-       if (batt_gpio_is_valid(gBatteryData->pdata->dc_det_pin)){
-               if (gpio_get_value (gBatteryData->pdata->dc_det_pin) == gBatteryData->pdata->dc_det_level){
-                               isCharging = 1;
-                       }else{
-                               isCharging = 0;
-                       }
-       }
-   //gpio_direction_output(pwr_hold, GPIO_LOW);
-   printk("xhh ========= v86_pm_power_off \n"); 
-   gpio_request(pwr_hold, NULL);
-   //mdelay(500);
-      if(isCharging)
-   {
-       printk("xhh ========= isCharging \n");
-      arm_pm_restart('h', "charge");     
-   }
-   else
-   {
-       printk("xhh ========= power off \n");
-       gpio_direction_output(pwr_hold, RK30_GPIO_LOW);
-         gpio_set_value(pwr_hold,RK30_GPIO_LOW);       
-   } 
-   while(1);
-
-}
-
 #ifdef  BATTERY_APK
 //#define BAT_ADC_TABLE_LEN               11
 static ssize_t bat_param_read(struct device *dev,struct device_attribute *attr, char *buf)
@@ -2210,10 +2176,6 @@ rk30_adc_battery_platform_data *data)
        if (batt_gpio_is_valid(data->charge_ok_pin))
                data->charge_ok_level = (flags & OF_GPIO_ACTIVE_LOW)
                ? RK30_GPIO_LOW : RK30_GPIO_HIGH;
-               pwr_hold = of_get_named_gpio_flags(node, "pwr_hold", 0,
-                                                   &flags);
-       if (pwr_hold == -EPROBE_DEFER)
-               printk("%s  pwr_hold error\n",__func__);
 
        ret = of_property_read_u32(node, "is_dc_charge", &value);
        if (ret < 0) {
@@ -2325,12 +2287,7 @@ static int rk30_adc_battery_probe(struct platform_device *pdev)
        memset(data->adc_samples, 0, sizeof(int)*(NUM_VOLTAGE_SAMPLE + 2));
 
         //register adc for battery sample
-
-       if (!pm_power_off) {
-               pm_power_off = v86_pm_power_off;
-       }       
        data->wq = create_singlethread_workqueue("adc_battd");
-           
         //variable init
        /*data->client  = client;*/
        data->adc_val = rk_adc_battery_iio_read(data->pdata);
index ab7fda5fbe188559fcb7924fa5944e8439c8e856..6af60700eede2beecca24e2b7894e304b66c727f 100644 (file)
@@ -64,6 +64,9 @@
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/unistd.h>
+#ifdef CONFIG_ARCH_ROCKCHIP
+#include <asm/system_misc.h>
+#endif
 
 #ifndef SET_UNALIGN_CTL
 # define SET_UNALIGN_CTL(a,b)  (-EINVAL)
@@ -450,6 +453,9 @@ void kernel_power_off(void)
        printk(KERN_EMERG "Power down.\n");
        kmsg_dump(KMSG_DUMP_POWEROFF);
        machine_power_off();
+#ifdef CONFIG_ARCH_ROCKCHIP
+       arm_pm_restart('h', "charge");
+#endif
 }
 EXPORT_SYMBOL_GPL(kernel_power_off);