i2c2 핀 [P9]: (19) I2C2_SCL, (20) I2C2_SDA를 사용하여 BeagleBoneBlack에서 i2c 장치 드라이버를 실행하려고 합니다.
사용자 공간에서 i2c2를 성공적으로 사용하여 동일한 atmel 터치스크린 장치를 제어할 수 있지만 장치 드라이버에서 이를 사용하면 검색할 때 오류 -16(리소스 사용 중)이 계속 발생합니다.
장치 드라이버는https://github.com/ssl-maxtouch/linux-device-driver/blob/master/atmel_mxt_ts.c커널에 정적으로 구축했습니다(drivers/input/touchscreen/atmel_mxt_ts.c).
장치 트리 소스 파일에 다음을 추가했습니다.아치/arm/boot/dts/am335x-boneblack.dts:
&i2c2 {
atmel_mxt_ts@4b {
compatible = "atmel,atmel_mxt_ts";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x4b>;
atmel,reset-gpio = <&gpio1 28 0x00>;
atmel,irq-gpio = <&gpio1 16 0x00>;
atmel,suspend-mode = <0x01>;
atmel,input_name = "SSLUK";
};
};
연장되는 것아치/arm/boot/dts/am33xx.dtsi그리고아치/arm/boot/dts/am335x-bone-common.dtsi:
i2c2: i2c@4819c000 {
compatible = "ti,omap4-i2c";
#address-cells = <1>;
#size-cells = <0>;
ti,hwmods = "i2c3";
reg = <0x4819c000 0x1000>;
interrupts = <30>;
status = "disabled";
};
&i2c2 {
pinctrl-names = "default";
pinctrl-0 = <>;
status = "okay";
clock-frequency = <100000>;
장치 드라이버가 버스에 성공적으로 추가된 것으로 보이지만 모든 i2c_transfer가 -16 값으로 실패하므로 프로브가 실패합니다.
커널 로그에서:
[ 0.879536] atmel_mxt_ts 2-004b: mxt_probe i2c-2-004b/input0
[ 0.879546] atmel_mxt_ts 2-004b: mxt_probe mxtdata->fw_name: (null), mxtdata->cfg_name: (null)
[ 0.879581] atmel_mxt_ts 2-004b: mxt_initialize
[ 1.887051] omap_i2c 4819c000.i2c: timeout waiting for bus ready
[ 1.887069] atmel_mxt_ts 2-004b: __mxt_read_reg: i2c_transfer ret_val -16
[ 2.935039] omap_i2c 4819c000.i2c: timeout waiting for bus ready
[ 2.935049] atmel_mxt_ts 2-004b: __mxt_read_reg: i2c_transfer ret_val -16
[ 3.947044] omap_i2c 4819c000.i2c: timeout waiting for bus ready
[ 3.947059] atmel_mxt_ts 2-004b: mxt_bootloader_read: i2c_transfer ret_val -16
[ 3.954340] atmel_mxt_ts 2-004b: mxt_bootloader_read: retry 1
[ 5.007040] omap_i2c 4819c000.i2c: timeout waiting for bus ready
[ 5.007050] atmel_mxt_ts 2-004b: mxt_bootloader_read: i2c_transfer ret_val -16
[ 5.014329] atmel_mxt_ts 2-004b: mxt_probe_bootloader, 907, buf[0] = 68, buf[1] = 2e, buf[2] = c0, error = -16
[ 5.014337] atmel_mxt_ts 2-004b: Trying alternate bootloader address
[ 6.019042] omap_i2c 4819c000.i2c: timeout waiting for bus ready
[ 6.019059] i2c i2c-2: SCL is stuck low, exit recovery
[ 6.024248] atmel_mxt_ts 2-004b: mxt_bootloader_read: i2c_transfer ret_val -16
[ 6.031521] atmel_mxt_ts 2-004b: mxt_bootloader_read: retry 1
[ 7.083040] omap_i2c 4819c000.i2c: timeout waiting for bus ready
[ 7.083050] atmel_mxt_ts 2-004b: mxt_bootloader_read: i2c_transfer ret_val -16
[ 7.090329] atmel_mxt_ts 2-004b: mxt_probe_bootloader, 907, buf[0] = dc, buf[1] = 13, buf[2] = dc, error = -16
[ 7.090630] atmel_mxt_ts 2-004b: mxt_probe error
[ 7.090657] atmel_mxt_ts: probe of 2-004b failed with error -16
커널은 4.14.25입니다.https://elinux.org/BeagleBoardUbuntu
고쳐 쓰다 장치 드라이버를 모듈로 빌드하고 작동하는 사용자 공간에서 insmod를 실행합니다.
sudo insmod atmel_mxt_ts.ko
커널 로그를 사용하면 다음과 같습니다.
[ 150.125216] atmel_mxt_ts 2-004b: mxt_probe i2c-2-004b/input0
[ 150.125235] atmel_mxt_ts 2-004b: mxt_probe mxtdata->fw_name: (null), mxtdata->cfg_name: (null)
[ 150.125295] atmel_mxt_ts 2-004b: mxt_initialize
[ 150.167071] atmel_mxt_ts 2-004b: Family: 164 Variant: 11 Firmware V1.6.01 Objects: 34
[ 150.167092] atmel_mxt_ts 2-004b: mxt_parse_object_table, object_num = 34
...
[ 150.168174] atmel_mxt_ts 2-004b: Enabling RETRIGEN workaround
[ 150.168617] atmel_mxt_ts 2-004b: mxt_acquire_irq mxtdata->irq = 86
[ 150.224908] atmel_mxt_ts 2-004b: mxt_acquire_irq OK
[ 150.224993] atmel_mxt_ts 2-004b: mxt_configure_objects
[ 150.228762] atmel_mxt_ts 2-004b: Touchscreen size X1023Y1023
[ 150.229141] input: SSLUK as /devices/platform/ocp/4819c000.i2c/i2c-2/2-004b/input/input1
[ 150.229170] atmel_mxt_ts 2-004b: mxt_initialize OK
[ 150.229178] atmel_mxt_ts 2-004b: mxt_probe OK