mbox series

[00/10] spi: Add driver to support AMD eSPI controller

Message ID 20250313183440.261872-1-Raju.Rangoju@amd.com
Headers show
Series spi: Add driver to support AMD eSPI controller | expand

Message

Rangoju, Raju March 13, 2025, 6:34 p.m. UTC
The eSPI protocol serves as a communication interface between the main
processor and peripheral devices in computer systems. It offers several
advantages over the traditional LPC bus, including higher data transfer
rates, increased scalability and improved system management capabilities.
The eSPI protocol supports multiple channels, each serving a specific
purpose in the communication process.

AMD SOCs feature multiple SPI controllers, including a dedicated eSPI
controller. This controller is responsible for managing the communication
between the main processor and peripheral devices using the eSPI protocol.
It provides support for various channels, including Peripheral channel(PC),
Virtual Wire(VW), Out-Of-Band(OOB) message, and Flash access channels.

This patch series implements new AMD eSPI driver aims to comprehensive
support for the eSPI protocol, including initialization of eSPI controller
and slave devices. It also adds functionality for channel-independent eSPI
commands and support for I/O and MMIO read/write operations on PC
channels.

Raju Rangoju (10):
  spi: espi_amd: Add AMD eSPI controller driver support
  spi: espi_amd: Add eSPI set config IOCTL command
  spi: espi_amd: Add eSPI get config IOCTL command
  spi: espi_amd: Add eSPI inband-reset IOCTL command
  spi: espi_amd: Add eSPI set IO mode IOCTL command
  spi: espi_amd: Add eSPI set channel IOCTL command
  spi: espi_amd: Add eSPI set frequency IOCTL command
  spi: espi_amd: Add support for IO/MMIO configuration
  spi: espi_amd: Add eSPI PC channel IO read/write IOCTL commands
  spi: espi_amd: Add eSPI PC channel MMIO read/write IOCTL commands

 MAINTAINERS                  |    6 +
 drivers/spi/Kconfig          |   10 +
 drivers/spi/Makefile         |    2 +
 drivers/spi/espi-amd-core.c  | 1215 ++++++++++++++++++++++++++++++++++
 drivers/spi/espi-amd-dev.c   |  584 ++++++++++++++++
 drivers/spi/espi-amd-err.h   |   50 ++
 drivers/spi/espi-amd-slave.h |  109 +++
 drivers/spi/espi-amd.h       |  416 ++++++++++++
 8 files changed, 2392 insertions(+)
 create mode 100644 drivers/spi/espi-amd-core.c
 create mode 100644 drivers/spi/espi-amd-dev.c
 create mode 100644 drivers/spi/espi-amd-err.h
 create mode 100644 drivers/spi/espi-amd-slave.h
 create mode 100644 drivers/spi/espi-amd.h

Comments

Mark Brown March 17, 2025, 2:14 p.m. UTC | #1
On Fri, Mar 14, 2025 at 12:04:30AM +0530, Raju Rangoju wrote:
> The eSPI protocol serves as a communication interface between the main
> processor and peripheral devices in computer systems. It offers several
> advantages over the traditional LPC bus, including higher data transfer
> rates, increased scalability and improved system management capabilities.
> The eSPI protocol supports multiple channels, each serving a specific
> purpose in the communication process.

I see nothing in this series that registers a SPI controller with the
SPI core.  You need to use the standard frameworks the kernel offers to
provide standard functionality.
Rangoju, Raju March 26, 2025, 9:55 a.m. UTC | #2
On 3/17/2025 7:44 PM, Mark Brown wrote:

Hi Mark,

Thanks for reviewing the patch and apologies for delayed response.

> On Fri, Mar 14, 2025 at 12:04:30AM +0530, Raju Rangoju wrote:
>> The eSPI protocol serves as a communication interface between the main
>> processor and peripheral devices in computer systems. It offers several
>> advantages over the traditional LPC bus, including higher data transfer
>> rates, increased scalability and improved system management capabilities.
>> The eSPI protocol supports multiple channels, each serving a specific
>> purpose in the communication process.
> 
> I see nothing in this series that registers a SPI controller with the
> SPI core.  You need to use the standard frameworks the kernel offers to
> provide standard functionality.

The AMD SPI controller hardware has only the chip select line enabled, 
which is connected to the EC slave in AMD EMB platforms. Currently, 
there is no support from the slave device to register as an SPI slave 
device with the SPI framework and provide SPI communication.

For this reason, the AMD eSPI driver is designed to handle device 
initialization itself and provide a character device file as an 
interface with user space for dynamic interaction and configurations.
Mark Brown March 26, 2025, 11:05 a.m. UTC | #3
On Wed, Mar 26, 2025 at 03:25:21PM +0530, Rangoju, Raju wrote:
> On 3/17/2025 7:44 PM, Mark Brown wrote:

> > I see nothing in this series that registers a SPI controller with the
> > SPI core.  You need to use the standard frameworks the kernel offers to
> > provide standard functionality.

> The AMD SPI controller hardware has only the chip select line enabled, which
> is connected to the EC slave in AMD EMB platforms. Currently, there is no
> support from the slave device to register as an SPI slave device with the
> SPI framework and provide SPI communication.

> For this reason, the AMD eSPI driver is designed to handle device
> initialization itself and provide a character device file as an interface
> with user space for dynamic interaction and configurations.

If you want to ignore the SPI subsystem and just write a driver for your
embedded controller then you should put the driver in the subsystem or
subsystems for that embedded controller (possibly MFD if it does a bunch
of things), not SPI.  Even if there is no flexibility you may still want
to have the controller side in the SPI subsystem in order to help with
reuse with different controller/EC combinations but if you're going that
way you need to use the SPI subsystem.
Rangoju, Raju April 2, 2025, 11:43 a.m. UTC | #4
On 3/26/2025 4:35 PM, Mark Brown wrote:
> On Wed, Mar 26, 2025 at 03:25:21PM +0530, Rangoju, Raju wrote:
>> On 3/17/2025 7:44 PM, Mark Brown wrote:
> 
>>> I see nothing in this series that registers a SPI controller with the
>>> SPI core.  You need to use the standard frameworks the kernel offers to
>>> provide standard functionality.
> 
>> The AMD SPI controller hardware has only the chip select line enabled, which
>> is connected to the EC slave in AMD EMB platforms. Currently, there is no
>> support from the slave device to register as an SPI slave device with the
>> SPI framework and provide SPI communication.
> 
>> For this reason, the AMD eSPI driver is designed to handle device
>> initialization itself and provide a character device file as an interface
>> with user space for dynamic interaction and configurations.
> 
> If you want to ignore the SPI subsystem and just write a driver for your
> embedded controller then you should put the driver in the subsystem or
> subsystems for that embedded controller (possibly MFD if it does a bunch
> of things), not SPI.  Even if there is no flexibility you may still want
> to have the controller side in the SPI subsystem in order to help with
> reuse with different controller/EC combinations but if you're going that
> way you need to use the SPI subsystem.

Thanks for the suggestions Mark. We will rework on this.