How to add new ch9434.c(SPI to UART) on Orin nx

I want to add ch934.c to source code /driver/tty/serial,and I add the followed txt into the kernel file:$kernel_src\drivers\tty\serial\Konfig
config SERIAL_CH9434
tristate “SERIAL_CH9434 serial support”
depends on SPI
This selects support for ch9434 serial ports.
Add the follow define into the $kernel_src\drivers\tty\serial\Makefile for compile the driver.
obj-$(CONFIG_SERIAL_CH943X) += ch9434.o

I also run the make menuconfig and select the ch9434 serial support at the driver/tty/serial and save the config. But when I make -j5 Image and make -j5 modules,I don’t get ch9434.ko。Did I do something wrong? What can I do to get ch9434.ko。

Hi sjz_shaohua,

It seems a custom driver, do you get the porting guide from your vendor?

Is CONFIG_SERIAL_CH943X included in .config?

I modified it according to the supplier’s guidance. And,I also added CONFIG_SERIAL_CH943X=y in kernel_src/kernel/kernel-5.10/arch/arm64/configs/tegra_defconfig. Also, sudo make tegra_defconfig in kernel_src/kernel/kernel-5.10

Is it included in .config?
Or you could just define as the following:

obj-y+= ch9434.o

Please check if there’s any object built for ch9434 after your run make command

Now CH934.ko is loaded to the system, but when I restart the device after updating the Image, the system fails to boot and this error message appears in the log message.

And,What is the reason for this? Thanks!

Please share the log file instead of screenshot for us to check.

It seems your ch943x probe failed during boot up.
You have to add debug message in your driver to check how error -22 comes from.

I would suggest you could build the driver as kernel module with the following definition.

obj-m+= ch9434.o

and load your module after boot up with the following command to debug the issue.

$ sudo modprobe ch9434
$ sudo insmod ch9434.ko

When I loaded CH934.KO, the error message in the figure appeared through dmesg, I used GPIO06(PCC.03) as the interrupt, is the error message because of GPIO06(PCC.03)? Thank you

I’m clear about what you added in ch934 driver to debug
It seems the probe failed.

Are you using PCC.03 for ch934?

It seems this pin is used for CAM_I2C_MUX by default and pulled low in the following line.

gpio@c2f0000 {
	gpio-init-names = "default";
	gpio-init-0 = <&gpio_aon_default>;

	gpio_aon_default: default {
		gpio-input = <
		gpio-output-low = <
		gpio-output-high = <
				TEGRA234_AON_GPIO(CC, 1)
				TEGRA234_AON_GPIO(AA, 5)
				TEGRA234_AON_GPIO(BB, 3)

You could remove TEGRA234_AON_GPIO(CC, 3) line if you want to use this pin for your CH934 driver.

I have modified the GPIO interrupt and can also use it. Now I have encountered a new problem, and there is an error in the process of data transmission from spi to CH9434. I want to know if /drivers/spi/ spi-tegra114. c needs to be modified, and how should it be modified? And, SPI0.0 is not found under /dev. Thank you.
ch9434.c.txt (43.1 KB)

log.txt (136.8 KB)

By adding print information to source/drivers/spi/spi.c, it is found that __spi_validate_bits_per_word() appears on line 3593 in function __spi_validate(). -EINVAL(-22), bits_per_word(239) > 32. This error occurs when I execute echo “123” > ttyWCH0.

It is expected since you use ch943x_spi driver instead.

It seems you could probe the ch9434 driver successfully since you get the new /dev/ttyWCH* node.
Sorry that I’m not familiar with how this driver works.
I would suggest you asking the help from your vendor.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.