zoukankan      html  css  js  c++  java
  • DA9034驱动程序阅读笔记(4)

     转载时请注明出处和作者联系方式
    文章出处:http://www.limodev.cn/blog
    作者联系方式:李先静 <xianjimli at hotmail dot com>

    DA9034是一个集成了电源管理、音频设备、触摸屏控制器和能用A/D|D/A转换的多功能芯片。最近读了一下相关驱动程序,这里记些笔记,不成体系,作为备忘而已。有兴趣的朋友可以一起讨论。

    DA9034的耳机插拔检测和线控开关检测的原理比较简单,因为不同状态电压不一样。插入耳机时,DA9034会上报中断给CPU,驱动程序在中断处理程序中查询相应的状态即可。
    headset-detect

    HEADSET detection carried out by comparing the voltage at the REM_IN node to a reference voltage that is 90% of
    MICBIAS. A high level is detected as no external microphone present, while a low level is detected as a microphone present.

    HOOK-SWITCH detection is carried out by comparing the voltage at the REM_IN node to a reference voltage that is 10% of
    MICBIAS. A high level is detected as non-pressed button, while a low level is detected as a pressed button.

    耳机检测是一个platform device,在littleton.c中定义:

    static struct gpio_switch_platform_data headset = {
    .name = "h2w",
    .data = PMIC_EVENT_HSDETECT,
    };
     
    struct platform_device pxa_device_micco_switch1 = {
    .name       = "switch-micco",
    .id     = 0,
    };
     
    static struct gpio_switch_platform_data hook = {
    .name = "hook",
    .data = PMIC_EVENT_HOOKSWITCH,
    };
     
    struct platform_device pxa_device_micco_switch2 = {
    .name       = "switch-micco",
    .id     = 1,
    };

    驱动程序有三个实现版本:

    其一是:drivers/char/micco_hsdetect.c
    它通过kobject_uevent上报状态给用户空间。

    其二是:drivers/input/keyboard/micco_keys.c
    它通过input_report_switch上报事件给用户空间。

    其三是:drivers/switch/switch_micco.c
    注册了一个switch_dev,这个好像是android平台专用的。

    不管哪种实现方式,都是在收到PMIC_EVENT_HSDETECT/PMIC_EVENT_HOOKSWITCH事件,读取DA9034的寄存器MICCO_STATUS_B,来查询相应状态。

    static void micco_switch_interrupt(unsigned long event)
    {
    struct micco_switch_data *switch_data;
    u8 val;
    int state;
     
    if (event&amp;PMIC_EVENT_HSDETECT) {
    micco_read(MICCO_STATUS_B, &amp;val);
    state = (val &amp; MICCO_STATUS_B_HEADSET)? 1 : 0;
     
    printk("PMIC_EVENT_HSDETECT %s/n", state?"PLUG IN":"REMOVED");
    switch_data = gswitch_data[HEADSET_SWITCH];
    if (switch_data)
    switch_set_state(&amp;(switch_data-&gt;sdev), state);
    }
     
    if (event&amp;PMIC_EVENT_HOOKSWITCH) {
    micco_read(MICCO_STATUS_B, &amp;val);
    state = (val &amp; MICCO_STATUS_B_HOOKSWITCH)? 1 : 0;
     
    printk("PMIC_EVENT_HOOKSWITCH %s/n", state?"PRESSED":"RELEASED");
    switch_data = gswitch_data[HOOK_SWITCH];
    if (switch_data)
    switch_set_state(&amp;(switch_data-&gt;sdev), state);
    }
    }

  • 相关阅读:
    【转】Redis主从复制简介
    Redis配置文件详解
    Redis在Windows环境下搭建
    Redis桌面管理工具 RedisDesktopManager
    Redis服务停止报错解决方案[NOAUTH Authentication required]
    Redis启动警告错误解决
    修改tcp内核参数:somaxconn
    CentOS6.8安装Redis3.2.5
    Github之协同开发
    自定义实现栈的功能
  • 原文地址:https://www.cnblogs.com/zhangyunlin/p/6167463.html
Copyright © 2011-2022 走看看