SPI Interface linux - linux

Micro controller is connected to Ethernet controller through SPI interface. Ethernet controller always gets configuration information from EEPROM(128) when board boots up. I have written basic driver to read/write eeprom, used data, control and status register to do read write opperation. This registers are memory mapped to process address space. Selecting eeprom by making chip select through GPIO.
Question: In the above scenario, what is the need SPI driver to read/write EEPROM. This register read operation is using SPI driver internally..?
Thanks

As mentioned by you "Micro controller is connected to Ethernet controller through SPI interface. Ethernet controller always gets configuration information from EEPROM(128) when board boots up."
It means that the ethernet is tied to SPI bus. It cannot read/write data on it's own.It means eeprom is not using SPI but Ethernet controller is using it.Since it is reading/writing from/to EEPROM and hence it might be giving illusion that EEPROM is using SPI.
Note:- I am assuming EEPROM is not tied to SPI.

Related

How existing kernel driver should be initialized as PCI memory-mapped?

Existing kernel drivers such as xilinx have specific way to be registered (as tty device), if they are mapped directly to cpu memory map as done here with device tree:
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842249/Uartlite+Driver
But in other cases, there is a PCIe device (like FPGA which has the xilinx uart IPs) which is connected to and the cpu.
How should we make the uart get registered when using PCIe device ?
The device tree I try to register into PCIe is uartlite driver:
https://github.com/Xilinx/linux-xlnx/blob/master/drivers/tty/serial/uartlite.c
I think that what I probably need to do is:
Write a custom pci driver.
Need to prepare platform_device struct and then call the uart probe routine from pci driver:
ulite_probe(struct platform_device *pdev)
I've seen related question with others using FPGA with multiple device connected, but seems that there is no docuemnt, or tutorial which describes how to do this.
Any comment, example or document is appreciated.
So something like a ARM CPU connected to an Artix FPGA over PCIe right?
Yes, you would need a custom PCIe driver. The PCIe configuration and data spaces would have to be mapped. Have a look at pci_resource_{start, len} and pci_remap_bar functions. You can then use pci_get_device to get a pointer to the struct device and retrieve the virtual address of the PCIe configuration space. The UART driver can then use the struct device pointer and it's register map should be at some offset to the virtual address of the PCIe configuration space as per your design. You can invoke the probe call of UARTlite IP driver in your own driver.
"Existing kernel drivers such as xilinx have specific way to be registered (as tty device), if they are mapped directly to cpu memory map as done here with device tree". Note that this is true if we are only talking of tty devices. A GPIO peripheral IP won't be expose as tty but in /sys/class/gpio.

Interrupt driven SPI or I2C driver

I am working on a user application, which depends on I2C or SPI device connected with the beaglebone board.
My app is running in userspace. Now whenever an interrupt occurs from I2c device, My application should get the data from I2c device.
My question is how to sync all these. Do I need to write a device driver which gets the data from I2c device or trigger another device driver to read the data from I2c and how it can trigger my user app to get the data?
You'll need to know about three things: i2c drivers, spi drivers and input subsystem.
For i2c drivers, search kernel code for struct i2c_driver and module_i2c_driver helper macro for registering and unregistering the driver.
Similarly, struct spi_driver and module_spi_driver for spi.
For input subsystem, search for struct input_dev. Among other things, you'll need to "hook" into interesting events by setting relevant event bits and implement input_event event handler.
UPDATE: Forgot to mention, aim of input subsystem is to help take care of input events coming in from i2c or spi device.

Writing network driver for Raspberry Pi GPIO connected to FS1000A

I want to create a Linux network driver for a FS1000A connected to the RasPI via GPIO. It does not need to support a high bitrate.
The hardware is already working, I've previously managed to emulate a 433 MHz remote control using a FS1000A transmitter connected to a Raspberry PI's GPIO pins. The FS1000A transmitter and receiver use on off keying. If the GPIO pin is set high, the transmitter transmits a carrier. If it's set low it does not transmit.
According to an article about writing virtual interfaces, "A virtual interface has no way to receive interrupts, and thus it cannot receive any network packet." Is it possible to receive an interrupt when a GPIO pin changes state on a Raspberry PI? If not it is possible for a network driver to get a callback to poll the state of a GPIO pin? It does not have to be elegant or efficient, it just needs to work.
Does a network driver's xmit function have to block until all the data is sent? That could take a long time the packet is transmitted 9600 bps.
I read a guide to writing network device drivers for Linux but it is focused on PCI devices. Is there any documentation/tutorials about writing network drivers for Linux?
Any other tips suggestions welcome.

Are DMA transfers supported with the davinci-spi device driver that is configured using devicetree?

I am trying to use DMA to program an FPGA connected to an OMAP-L138's SPI bus, but without success.
Currently, I am using the stock davinci-spi driver (drivers/spi/spi-davinci.c)that comes with linux 3.19. FPGA configuration is successful (without DMA enabled), but it is very slow. I am using a device tree to configure the SPI interface.
I would like to use DMA to improve performance, however from looking at the spi-davinci.c source code and its device tree bindings, the driver does not appear to support DMA when configured with device tree. Is my understanding correct? If so, are there any plans to support DMA transfers using davinci's SPI driver when also using device tree?
Here are a few guidelines to achieve your goal:
First, check if the SPI has it's own DMA engine. If it doesn't, perhaps there's a generic DMA controller on board. You can check this by looking at the SPI datasheet and looking at the board interconnect schematics.
If none of the above are true, then you can't use DMA with the SPI.
If the SPI has its own DMA, you'll need to write a driver for that.
If there's a DMA on board, it's probably utilized by other components, search for dma_dngine driver for that particular device. Then you'll need to create a DMA client for that particular DMA engine.
Please read:
DMA Provider
DMA Client
Good luck

How to access a registered I2C device in the linux kernel from userspace

I want to be able to modify registers in a I2C slave device.
The device has a driver in the kernel, and the driver registers an I2C client with the address of it.
The driver is very basic and does output all the device functionality.
I want to access the registers from user space, but when I try to access it with I2C-dev, I get the error - Device or resource busy.
I don't want to add functionality to the driver, and I prefer to write a user space application to modify the device registers.
How can use I2C-dev to modify the registers in such a case?
So after investigating the I2C-dev I managed to overcome the problem. I noticed the flag I2C_SLAVE_FORCE inside the ioctl function. With the flag set, the function ignores if the I2C address is already registered.

Resources