解析如何在android中增加gsensor驅動(MMA7660)

來源:互聯網
上載者:User

系統原來用的是BOSCH_BMA222的gsensor, 現在要求換成使用MMA7660,我們來看一下怎樣增加驅動和調試過程。
1. 修改Makefie
首先,修改放置驅動的目錄裡的Makefile(kernel/driver/misc),添置如下語句: 複製代碼 代碼如下:obj-$(CONFIG_SENSORS_MMA7660) += mma7660.o

2. 增加驅動檔案
把驅動檔案mma7660.c添加到kernel/driver/misc下。
3. 修改.config檔案,把下面兩行注釋掉
複製代碼 代碼如下:# CONFIG_BOSCH_SENSOR=y
# CONFIG_BOSCH_BMA222=y

再增加下面這項
複製代碼 代碼如下:CONFIG_SENSORS_MMA7660=y

編譯,顯示提示:
複製代碼 代碼如下:make uImage -j16
scripts/kconfig/conf -s arch/arm/Kconfig
*
* Restart config...
*
*
* Misc devices
*
Misc devices (MISC_DEVICES) [Y/n/?] y
Analog Devices AD525x Digital Potentiometers (AD525X_DPOT) [N/m/y/?] n
Android pmem allocator (ANDROID_PMEM) [N/y] n
Integrated Circuits ICS932S401 (ICS932S401) [N/m/y/?] n
Enclosure Services (ENCLOSURE_SERVICES) [N/m/y/?] n
Kernel Debugger Core (KERNEL_DEBUGGER_CORE) [N/y/?] n
Intersil ISL29003 ambient light sensor (ISL29003) [N/m/y/?] n
Taos TSL2550 ambient light sensor (SENSORS_TSL2550) [N/m/y/?] n
Dallas DS1682 Total Elapsed Time Recorder with Alarm (DS1682) [N/m/y/?] n
Texas Instruments DAC7512 (TI_DAC7512) [N/m/y/?] n
UID based statistics tracking exported to /proc/uid_stat (UID_STAT) [Y/n] y
Bluetooth power control driver for TI wl127x (WL127X_RFKILL) [N/m/y/?] n
Android kernel panic diagnostics driver (APANIC) [N/y/?] n
6 Axis sensor mpu3050 (SIX_AXIS_SENSOR_MPU3050) [N/y] n
Motion Processing Unit driver version
> 1. MPU version < v3.4.0 (MPU_PRE_V340)
2. MPU version >= v3.4.0 (MPU_NEW)
choice[1-2]: 1
BOSCH BMA222 acceleration sensor (BOSCH_SENSOR) [N/m/y/?] (NEW) N
*
* Miscellaneous I2C Chip support
*
BMA222 acceleration sensor support (BOSCH_BMA222) [N/m/y/?] (NEW) N
#
# configuration written to .config

這時看編譯輸出,系統沒有編譯mma7660.c, 而且編譯後.config的MMA7660的宏也被覆蓋掉了,所以這樣是沒有辦法掛載的。之所以出現這個錯誤的原因,是因為make的時候會檢查各個Kconfig檔案,沒有的選項會自動率掉,所以,我們還需要修改Kconfig檔案。
5. 修改kernel/driver/misc/Kconfig,在menuconfig MISC_DEVICES下添加如下:
複製代碼 代碼如下:config SENSORS_MMA7660
tristate "MEMSIC Accelerometer Sensor MMA7660 Driver Support"
depends on I2C
help
If you say yes here you get support for the MEMSIC accelerometer sensor

6. 由於這裡gsensor是一個i2c的外掛,所以,還必須修改板子的i2c的device資訊,以便系統可以尋找到裝置。修改板子的資源檔(我這裡的特例是./arch/arm/mach-meson3/board-m3-reff24.c),在結構aml_i2c_bus_info_1[]中添加一下資訊:
複製代碼 代碼如下:#ifdef CONFIG_SENSORS_MMA7660
{
I2C_BOARD_INFO("mma7660", 0x4C),
.irq = INT_GPIO_2,
},
#endif

7. 再進行編譯,驅動就被編譯了。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.