CH9434在SSD202D平台调试不通

硬件原理图如下:



1728719951107745.png

1728719951185415.png

CH9434的INT接SSD202D的TTL26,CS,CLK,MOSI,MISO,分别接SSD202D的GPIO8,GPIO9,GPIO10,GPIO11 。

参考SPI使用参考 - SigmaStarDocs (comake.online),修改DTS,

修改arch\arm\boot\dts\infinity2m-ssc011a-s01a-padmux.dtsi

,

,

,

,

把相关管脚复用成SPI,编译kernel烧进板子后,会有/dev/spidev0.0节点。

参考恒沁官网驱动,修改ch9434驱动,

1:屏蔽DTS,增加spi_info

sw1.png

sw2.png

2:增加spi_register_board_info

sw3.png把驱动编译进内核后,跑起来后ch943x_scr_test一直不过。

[    1.837296] [ss_gpi_intc_domain_alloc] hw:30 -> v:62

[    1.839409] gpio_to_irq:62, spi->irq:60

[    1.843310] change to SPI MODE 3!

[    1.846561] [Padmux]reset Pad_45(reg 0x101e0d; mask0xf00) to GPIO(org: TTL_MODE_1)

[    1.854279] ch943x_port_write - reg:0x81, val:0x 0

[    1.858940] ch943x_port_write - reg:0x84, val:0x 0

[    1.863760] ch943x_port_read - reg:0x 6, val:0xc7

[    1.868389] ******Uart 0 SPR Test Start******

[    1.872791] ch943x_port_write - reg:0x87, val:0x55

[    1.877567] ch943x_port_read - reg:0x 7, val:0xc7

[    1.882253] UART 0 SPR Test Failed.

[    1.885725] ch943x_spi spi0.1: ch943x_probe error

[    1.890431] ch943x_spi: probe of spi0.1 failed with error -1

spi_board_info中的irq以及其controller_data不知道如何取值。不清楚这样修改是否正确?还请大神给与解答。

帮顶


1、驱动能执行到ch943x_spi_probe,说明驱动已经成功移植到系统,SPI总线-设备-驱动已正常匹配;

2、ch943x_scr_test不过表示外围硬件上存在问题,SPI主机和芯片通信失败,建议用逻辑分析仪抓SPI硬件时序查看,可将原理图和时序发至邮箱yz@wch.cn


hi,

我也遇到通信问题,ch943x_scr_test不过 ,量了cpu端的spi通信(回环测试)是正常的,量了ch9434的vdd vcc vcore 晶振都是正常的,就是目前量cpu到ch9434的波形时,clk有变化,mosi和clk一起变化,但是cs的电平一直为高,想请教下这个cs信号要怎么设置呢?



image.png


1:管脚复用需要修改DTS:

dts1.png2:还需要修改公版DTS中的dma(默认是1,需要屏蔽或者修改成0,原因未知)

dts2.png3:修改驱动中ch943x_spi_probe函数,把函数刚开始的dev_dbg换成printk,否则ch943x_scr_test也过不了。

probe.png

修改上面几处之后,可以正常加载ko。结果如下:

root@SmartGateway:/tmp# insmod ch9434.ko

[   16.582673] ch9434: SPI serial driver for ch9434.

[   16.584531] ch9434: V1.1 On 2023.04

[   16.588236] [ss_gpi_intc_domain_alloc] hw:30 -> v:65

[   16.593443] gpio_to_irq:65, spi->irq:64

[   16.596829] ch943x_spi spi0.1: change to SPI MODE 3!

[   16.602195] ch943x_spi spi0.1: ch943x_port_write - reg:0x81, val:0x 0

[   16.608234] ch943x_spi spi0.1: ch943x_port_write - reg:0x84, val:0x 0

[   16.615005] ch943x_spi spi0.1: ch943x_port_read - reg:0x 6, val:0x11

[   16.621830] ch943x_spi spi0.1: ******Uart 0 SPR Test Start******

[   16.627086] ch943x_spi spi0.1: ch943x_port_write - reg:0x87, val:0x55

[   16.633914] ch943x_spi spi0.1: ch943x_port_read - reg:0x 7, val:0x55

[   16.639849] ch943x_spi spi0.1: ch943x_port_write - reg:0x87, val:0xaa

[   16.646590] ch943x_spi spi0.1: ch943x_port_read - reg:0x 7, val:0xaa

[   16.652758] ch943x_spi spi0.1: ******Uart 0 SPR Test End******

[   16.658459] ch943x_spi spi0.1: ch943x_port_write - reg:0x91, val:0x 0

[   16.665145] ch943x_spi spi0.1: ch943x_port_write - reg:0x94, val:0x 0

[   16.671490] ch943x_spi spi0.1: ch943x_port_read - reg:0x16, val:0x 0

[   16.678463] ch943x_spi spi0.1: ******Uart 1 SPR Test Start******

[   16.683796] ch943x_spi spi0.1: ch943x_port_write - reg:0x97, val:0x55

[   16.690191] ch943x_spi spi0.1: ch943x_port_read - reg:0x17, val:0x55

[   16.696953] ch943x_spi spi0.1: ch943x_port_write - reg:0x97, val:0xaa

[   16.703100] ch943x_spi spi0.1: ch943x_port_read - reg:0x17, val:0xaa

[   16.709251] ch943x_spi spi0.1: ******Uart 1 SPR Test End******

[   16.715359] ch943x_spi spi0.1: ch943x_port_write - reg:0xa1, val:0x 0

[   16.721722] ch943x_spi spi0.1: ch943x_port_write - reg:0xa4, val:0x 0

[   16.727996] ch943x_spi spi0.1: ch943x_port_read - reg:0x26, val:0x11

[   16.735225] ch943x_spi spi0.1: ******Uart 2 SPR Test Start******

[   16.740407] ch943x_spi spi0.1: ch943x_port_write - reg:0xa7, val:0x55

[   16.747252] ch943x_spi spi0.1: ch943x_port_read - reg:0x27, val:0x55

[   16.753397] ch943x_spi spi0.1: ch943x_port_write - reg:0xa7, val:0xaa

[   16.759592] ch943x_spi spi0.1: ch943x_port_read - reg:0x27, val:0xaa

[   16.766171] ch943x_spi spi0.1: ******Uart 2 SPR Test End******

[   16.771926] ch943x_spi spi0.1: ch943x_port_write - reg:0xb1, val:0x 0

[   16.778368] ch943x_spi spi0.1: ch943x_port_write - reg:0xb4, val:0x 0

[   16.784687] ch943x_spi spi0.1: ch943x_port_read - reg:0x36, val:0x 0

[   16.791864] ch943x_spi spi0.1: ******Uart 3 SPR Test Start******

[   16.797068] ch943x_spi spi0.1: ch943x_port_write - reg:0xb7, val:0x55

[   16.803919] ch943x_spi spi0.1: ch943x_port_read - reg:0x37, val:0x55

[   16.809833] ch943x_spi spi0.1: ch943x_port_write - reg:0xb7, val:0xaa

[   16.816577] ch943x_spi spi0.1: ch943x_port_read - reg:0x37, val:0xaa

[   16.822732] ch943x_spi spi0.1: ******Uart 3 SPR Test End******

[   16.828449] ch943x_spi spi0.1: ch943x_probe - firmware version: V1.0

[   16.835037] ch943x_spi spi0.1: ch943x_port_write - reg:0xc8, val:0xcd

[   17.041482] ch943x_spi spi0.1: ch943x_probe - devm_request_threaded_irq =64 result:0

[   17.046405] ch943x_spi spi0.1: sysfs_create_group() succeeded!!

root@SmartGateway:/tmp#  [  372.147407] random: crng init done

root@SmartGateway:/tmp# ls /dev/ttyWCH*

/dev/ttyWCH0  /dev/ttyWCH1  /dev/ttyWCH2  /dev/ttyWCH3

root@SmartGateway:/tmp#  



还有一个修改点:终端的触发方式得有默认的IRQF_TRIGGER_LOW改为IRQF_TRIGGER_RISING;

a.png根据irq-gpi.c中代码,只支持IRQ_TYPE_EDGE_FALLING和IRQ_TYPE_EDGE_RISING,实测只有IRQ_TYPE_EDGE_RISING才能正常。

irq.png


您好,因芯片的硬件中断信号是低电平有效,通常在驱动程序的配置上,可配置成:IRQF_TRIGGER_LOW 或 IRQF_TRIGGER_FALLING。其他中断配置方式即使中断可用也存在丢中断导致业务异常的可能。

此外,建议可以用其他通用GPIO口模拟中断给INT引脚,实测下中断的触发是否和设置匹配。


icon_rar.gifch9434.zip

附件是根据建议修改好的驱动文件。串口收发自测正常。

success.png


只有登录才能回复,可以选择微信账号登录