How to use serdev driver in am335x? - linux-kernel

I have one beaglebone black which has am335x processor and uses linux kernel 5.4. I want to just send and receive data on Tx Rx at uart4 using serdev driver(not use /dev/tty layer). so I find one example code which is drivers/iio/chemical/pms7003.c But this example based on slave sensors and it is not work in my case. so anyone helps me how to use uart using serdev driver to Write and read data on the Tx Rx line without a slave device?

Related

How to operate 10Gbit SFP+ module if driver doesn't support SFP+?

Abstract
I'm trying to get a 10GBASE-SR SFP+ module running. The MAC driver doesn't support I²C access to the registers, therefore I want to use PHY-less mode. On the other hand, the "fixed-link" mode supports only up to 1 Gbit. The "in-band-status" mode is said to not work with my setup. Thus I'm running out of options. I ask you if there are further options to get things running.
About the hardware
My company built an access point containing an NXP QorIQ T1023 Soc. This SoC includes a MAC which is connected to an SFP+ cage. We use XFI for the connection between MAC and SFP+. In addition, the SFP+ module is connected to the SoC via I²C to access its registers.
About the software
I am running OpenWRT with a Linux 4.14.137 kernel. There are patches on that kernel (mostly from the OpenWRT project, some by us).
Details about the problem
For the MAC, I use the DPAA driver. This driver uses the kernels phylib (a.k.a. PHY Abstraction Layer) to access its PHY. However, phylib supports only MDIO-connected PHYs, not I²C connected devices. The kernel also provides phylink which can access I²C devices and MDIO devices (according to my understanding), but the DPAA driver does not support phylink. Therefore, the SFP+ Module will not work in a "normal" way with the DPAA driver.
Instead, I try to use PHY-less mode by adding the "fixed-link" keyword to my DTS file. However, I can only configure up to 1 Gbit, but I need 10 Gbit.
There is an "in-band-status" keyword for the DTS file, but I didn't fully understand what it does. An NXP supported told me that this will not work with XFI.
To summarize, I considered the following options:
Operating SFP+ "normally", register access over I²C --> Not supported by MAC driver
PHY-less operation with "fixed-link" --> does not support 10G
PHY-less operation with "in-band-status" --> said to be no option, but I don't understand why
What I tried so far
Checked XFI link: I read the MACs registers, and it says the XFI link is up. I didn't find an equivalent register on the SFP+ side. The Ethernet switch (this is my link partner for the fiber link) says the link is up (LED is on).
Reading SFP+ registers: I can actually read the registers of the SFP+ module. I tried that on the U-boot commandline, just to test the I²C connection.
Hacking the phylib: I tried to add 10G mode to the "fixed-link" mode and had limited success. My MAC can now receive packets but not send. I believe that the MAC still thinks the link were down. I'm currently working in that area.
My questions
Is there a method to operate the SFP+ module which I'm unaware of?
As a side question: Is there a good overview available over the MII connection types? I'm still unaware if XFI and SFI are the same, or how XFI and XGMII are related and so on.
Kind regards, Tanjeff

I2c Master testing on FPGA board

I have implemented i2c master code for reading temperature value from temp sensor(slave).i am testing my code on FPGA evolution board.FPGA is Microsemi nano very basic FPGA.How can I test my master without connecting to the slave device?
I recommend writing a test bench that simulates the behavior of a slave device and checks for the correct sequence of actions from your I2C master and use it in simulation.

I2C Kernel driver binding

Hi I am new to kernel driver developement. I am using the raspberry pi as my hostI am trying to create an I2C driver for a custom board we have. The custom board will act as the slave. I am confused about how do I go about entering the devices slave address. From what I understand
You need to either have a board setup file which I dont since its a custom board.
You can edit the device tree
Or you can do it in the user space application.
I am not sure where exactly to edit the device tree if I go with the second option. More over I would like to somehow register the slave address in the I2C driver itself. That way I donot need to rebuild the kernel. One method i was looking at was to set the i2c client from the driver code but that was advised by commentators I am not sure why. Any help would be appreciated.
Instantiating Drivers
So I have finally a working way in which I can bind the I2C device without needing a kernel rebuild. I create two driver files(.ko files). One for registering and one for the actual driver.
The way I did it is I got the bus number to which the device was connected.
(You can look into i2c user space code. i2cdetect -y (busnumber) will help you detect which bus number it is)
Once I knew that I created a driver file which would register my device by getting access to the adapter and then registering it. My bus number was 1 and slave address 0x10
static struct i2c_board_info board_info[] __initdata =
{
{
I2C_BOARD_INFO("my_device", 0x10),
},
};
And in the init function of the driver I register the device by
i2c_new_device(i2c_get_adapter(1), board_info[0])
Thats it. Now once you build this insmod the ko file before insmoding the actual driver file and everything should work.

How to communicate between micro controller and Digital signal processor?

I am working on some project where I need to communicate between two processors (hardware), ATxMEGA128A1 AVR Controller and Blackfin BF522 Digital Signal Processor. Someone help me.
Here, to communicate between a DSP and a UController you can use asynchronous serial link USART that's called as Inter-Processor Communication(IPC).
You can code for GPIO pins if you know how to write code for USART,that's available on almost any UController.
In-short you need USART channel to communicate between DSP and UController(IPC).That's the one possible way I don't know about others.

Accessing/monitoring battery status through SMBus

I am currenlty trying to monitor my battery status through SMBus.
I have a battery along with a control board that constantly outputs the battery status.
This control board is then connected to my mother board through a I2C-USB module.
I need to write a program to recognize the SMBus connection and transmit the battery status to the user.
I'm a beginner when it comes to dealing with smart batteries and I2C/SMBus, and I'm somewhat lost with how to approach this problem.
Any help of suggestions would be appreciated. Thanks.
Your question is a bit lacking. What kind of I2C-USB module? Or rather does it come with a Linux driver? If it does you probably won't need to write one. An application will do. You can read more about I2C and SMBus here.
Basically what you need is the I2C address of the control board (a single byte). When you have the address you (as the master) issue read commands over the I2C bus to the control board using its address and reads the response. If there's a driver for the I2C-USB module this should be straightforward enough. Plug in the device and open() the device (/dev/[i2c-usb-name] where [i2c-usb-name] is the name of the device). Then follow the driver implementer's guide how to setup and send data over that device (typically using read()/write() or ioctl()). Here are some additional information on working with I2C from user space: http://www.mjmwired.net/kernel/Documentation/i2c (select topics in the menu on the left hand side).
If you must write the driver yourself, the first stop for a Linux device driver beginner is the LDD3. Read it, it's quite a pleasant read.

Resources