MTK 9.0平台调试gsensor

MTK 9.0平台调试gsensor ----型号为:stk8baxx

1 查看原理图可以知道stk8baxx重力传感器 使用i2c1通道进行通讯,由于该重力传感器是不使用中断模式的进行触发的,所以不需要配置中断引脚。由此可以配置stk8baxx重力传感器的dts
MTK 9.0平台调试gsensor_第1张图片
dts文件配置如下:
dts文件路径为:\kernel-4.4\arch\arm\boot\dts\aiot8362am3_bsp.dts

&gsensor_mtk{
	status = "okay";
};
&i2c1 {
	clock-div = <2>;
	pinctrl-names = "default";
	pinctrl-0 = <&i2c1_pins_a>;
	status = "okay";
	clock-frequency = <400000>;


	stk8baxx@18{
		compatible = "mediatek,stk8baxx";
		reg = <0x18>;
		i2c_num	= <1>;
		i2c_addr = <0x18 0 0 0>;
		direction = <0>;
		power_id = <0xffff>;
		power_vol = <0>;
		firlen = <0>;
		is_batch_supported = <0>;
		status = "okay";
	};

}

\kernel-4.4\arch\arm\boot\dts\mt8167.dtsi

		gsensor_mtk:gsensor@0 {
			compatible = "mediatek,gsensor";

		};

2 配置aiot8362am3_bsp_defconfig和aiot8362am3_bsp_debug_defconfig文件以及配置相关的Makefile和Kconfig

2.1 配置aiot8362am3_bsp_defconfig和aiot8362am3_bsp_debug_defconfig文件
文件路径为:\kernel-4.4\arch\arm\configs\aiot8362am3_bsp_debug_defconfig和\kernel-4.4\arch\arm\configs\aiot8362am3_bsp_defconfig

#g-sensor
CONFIG_CUSTOM_KERNEL_ACCELEROMETER=y

CONFIG_MTK_STK8BAXX=y

2.2 配置相关的Makefile和Kconfig

\kernel-4.4\drivers\misc\mediatek\sensors-1.0\accelerometer\Kconfig

source "drivers/misc/mediatek/sensors-1.0/accelerometer/stk8baxx/Kconfig"

\kernel-4.4\drivers\misc\mediatek\sensors-1.0\accelerometer\Makefile

obj-$(CONFIG_MTK_STK8BAXX) += stk8baxx/

\kernel-4.4\drivers\misc\mediatek\sensors-1.0\accelerometer\stk8baxx\Kconfig

config MTK_STK8BAXX
	bool "MTK_STK8BAXX for MediaTek package"
	default n
	help
	  The STK8BA50 is a highly integrated,
	  low power internal measurement unit
	  that provides precise acceleration
	  measurement.
	  this config will turn on accelerometer feature.

\kernel-4.4\drivers\misc\mediatek\sensors-1.0\accelerometer\stk8baxx\Makefile

ccflags-y += -I$(srctree)/drivers/misc/mediatek/sensors-1.0/accelerometer/inc
ccflags-y += -I$(srctree)/drivers/misc/mediatek/sensors-1.0/hwmon/include

obj-y	:=  stk8baxx.o

\device\mediateksample\aiot8362am3_bsp\ProjectConfig.mk

CUSTOM_KERNEL_ACCELEROMETER = yes

3 把 stk8baxx.c放进去编译查看log发现 stk8baxx.cstk8baxx重力传感器i2c是能够通讯成功的,同时相关节点也产生了,由此可以验证stk8baxx重力传感器移植成功, log如下:

[    0.402790] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_init 3463  start-----
[    0.408960] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_init 3463  start-----
[    1.326177] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3158 client->addr = 0x18 start-----
[    1.327289] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3167 client->addr = 0x18 start-----
[    1.328381] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3179 client->addr = 0x18 start-----
[    1.329477] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3184 client->addr = 0x18 start-----
[    1.330584] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3196 client->addr = 0x18 start-----
[    1.331809] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3201 client->addr = 0x18 start-----
[    1.333044] <3>.(3)[1:swapper/0]dsy:-------stk_polling_mode_setup 2501 start-----
[    1.333972] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3215 client->addr = 0x18 start no INTERRUPT_MODE -----
[    1.335267] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3220 client->addr = 0x18 start-----
[    1.336365] <3>.(3)[1:swapper/0]dsy:-------stk_reg_init 2539 start-----
[    1.341175] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3226 client->addr = 0x18 start-----
[    1.342303] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3241 client->addr = 0x18 start-----
[    1.343672] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3263 client->addr = 0x18 start-----
[    1.344779] <3>.(3)[1:swapper/0]dsy:-------stk8baxx_i2c_probe 3273 client->addr = 0x18 start-----
[    1.345878] <3>.(3)[1:swapper/0]BOOTPROF:      1345.877694:probe: probe=i2c_device_probe drv=stk8baxx(c0e43b70)    19.696616ms
[   23.837242] <3>.(3)[454:nvram_daemon]dsy:-------stk_factory_set_cali 3052 start-----
[   23.838215] <3>.(3)[454:nvram_daemon]dsy:-------stk_factory_set_cali 3071 start-----
[   23.839177] <3>.(3)[454:nvram_daemon]dsy:-------stk_writeCalibration 2966 start-----
[   23.840146] <3>.(3)[454:nvram_daemon]dsy:-------stk_readCalibration 2942 start-----
[   23.847060] <3>.(3)[454:nvram_daemon]dsy:-------stk_readCalibration 2951 start-----
[   23.848021] <3>.(3)[454:nvram_daemon]dsy:-------stk_writeCalibration 2972 start-----
[   23.848984] <3>.(3)[454:nvram_daemon]dsy:-------stk_writeCalibration 2984 start-----
[   51.778288] <2>.(2)[160:kworker/2:1]dsy:-------stk_read_accel_rawdata 961 start-----
[   51.779761] <2>.(2)[160:kworker/2:1]dsy:-------stk_low_pass_fir 882 start-----
[   51.844305] <2>.(2)[160:kworker/2:1]dsy:-------stk_read_accel_rawdata 961 start-----
[   51.846374] <2>.(2)[160:kworker/2:1]dsy:-------stk_low_pass_fir 882 start-----
[   51.912318] <2>.(2)[160:kworker/2:1]dsy:-------stk_read_accel_rawdata 961 start-----

你可能感兴趣的:(MTK调试笔记)