[RK3288][Android6.0] 调试笔记 --- 伪电池驱动添加

Platform: ROCKCHIP
OS: Android 6.0
Kernel: 3.10.92

由于电池部分是用户空间Service从另外一颗MCU获取,而Android需要显示电量,
所以按照电池驱动框架做了一个伪电池驱动, 主要是使用它的充电状态和电池电量
这两个property, 代码如下:

/* drivers/power/rk3288_battery.c
 *
 * Power supply driver for the rk3288
 *
 * Copyright (C) 2008 Google, Inc.
 * Author: kris.fei<kris_fei@126.com>
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * 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.
 *
 */

#include <linux/module.h>
#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
#include <linux/types.h>
#include <linux/pci.h>
#include <linux/interrupt.h>
#include <asm/io.h>
#include <linux/timer.h>
#include <linux/slab.h>
#include <linux/of_irq.h>
#include <linux/of_gpio.h>
#include <linux/of.h>
#include <linux/of_device.h>

//#define DEBUG

struct rk3288_battery_data {
    int status;
    int health;
    int present;
    int capacity;

    struct power_supply battery;
  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值