.. SPDX-License-Identifier: GPL-2.0+

How to port a SPI driver to driver model
========================================

Here is a rough step-by-step guide. It is based around converting the
exynos SPI driver to driver model (DM) and the example code is based
around U-Boot v2014.10-rc2 (commit be9f643). This has been updated for
v2015.04.

It is quite long since it includes actual code examples.

Before driver model, SPI drivers have their own private structure which
contains 'struct spi_slave'. With driver model, 'struct spi_slave' still
exists, but now it is 'per-child data' for the SPI bus. Each child of the
SPI bus is a SPI slave. The information that was stored in the
driver-specific slave structure can now be port in private data for the
SPI bus.

For example, struct tegra_spi_slave looks like this:

.. code-block:: c

	struct tegra_spi_slave {
		struct spi_slave slave;
		struct tegra_spi_ctrl *ctrl;
	};

In this case 'slave' will be in per-child data, and 'ctrl' will be in the
SPI's buses private data.


How long does this take?
------------------------

You should be able to complete this within 2 hours, including testing but
excluding preparing the patches. The API is basically the same as before
with only minor changes:

- methods to set speed and mode are separated out
- cs_info is used to get information on a chip select


Enable driver mode for SPI and SPI flash
----------------------------------------

Add these to your board config:

* CONFIG_DM_SPI
* CONFIG_DM_SPI_FLASH


Add the skeleton
----------------

Put this code at the bottom of your existing driver file:

.. code-block:: c

	struct spi_slave *spi_setup_slave(unsigned int busnum, unsigned int cs,
					  unsigned int max_hz, unsigned int mode)
	{
		return NULL;
	}

	struct spi_slave *spi_setup_slave_fdt(const void *blob, int slave_node,
					      int spi_node)
	{
		return NULL;
	}

	static int exynos_spi_of_to_plat(struct udevice *dev)
	{
		return -ENODEV;
	}

	static int exynos_spi_probe(struct udevice *dev)
	{
		return -ENODEV;
	}

	static int exynos_spi_remove(struct udevice *dev)
	{
		return -ENODEV;
	}

	static int exynos_spi_claim_bus(struct udevice *dev)
	{

		return -ENODEV;
	}

	static int exynos_spi_release_bus(struct udevice *dev)
	{

		return -ENODEV;
	}

	static int exynos_spi_xfer(struct udevice *dev, unsigned int bitlen,
				   const void *dout, void *din, unsigned long flags)
	{

		return -ENODEV;
	}

	static int exynos_spi_set_speed(struct udevice *dev, uint speed)
	{
		return -ENODEV;
	}

	static int exynos_spi_set_mode(struct udevice *dev, uint mode)
	{
		return -ENODEV;
	}

	static int exynos_cs_info(struct udevice *bus, uint cs,
				  struct spi_cs_info *info)
	{
		return -EINVAL;
	}

	static const struct dm_spi_ops exynos_spi_ops = {
		.claim_bus	= exynos_spi_claim_bus,
		.release_bus	= exynos_spi_release_bus,
		.xfer		= exynos_spi_xfer,
		.set_speed	= exynos_spi_set_speed,
		.set_mode	= exynos_spi_set_mode,
		.cs_info	= exynos_cs_info,
	};

	static const struct udevice_id exynos_spi_ids[] = {
		{ .compatible = "samsung,exynos-spi" },
		{ }
	};

	U_BOOT_DRIVER(exynos_spi) = {
		.name	= "exynos_spi",
		.id	= UCLASS_SPI,
		.of_match = exynos_spi_ids,
		.ops	= &exynos_spi_ops,
		.of_to_plat = exynos_spi_of_to_plat,
		.probe	= exynos_spi_probe,
		.remove	= exynos_spi_remove,
	};


Replace 'exynos' in the above code with your driver name
--------------------------------------------------------


#ifdef out all of the code in your driver except for the above
--------------------------------------------------------------

This will allow you to get it building, which means you can work
incrementally. Since all the methods return an error initially, there is
less chance that you will accidentally leave something in.

Also, even though your conversion is basically a rewrite, it might help
reviewers if you leave functions in the same place in the file,
particularly for large drivers.


Add some includes
-----------------

Add these includes to your driver:

.. code-block:: c

	#include <dm.h>
	#include <errno.h>


Build
-----

At this point you should be able to build U-Boot for your board with the
empty SPI driver. You still have empty methods in your driver, but we will
write these one by one.

Set up your platform data structure
-----------------------------------

This will hold the information your driver to operate, like its hardware
address or maximum frequency.

You may already have a struct like this, or you may need to create one
from some of the #defines or global variables in the driver.

Note that this information is not the run-time information. It should not
include state that changes. It should be fixed throughout the live of
U-Boot. Run-time information comes later.

Here is what was in the exynos spi driver:

.. code-block:: c

	struct spi_bus {
		enum periph_id periph_id;
		s32 frequency;		/* Default clock frequency, -1 for none */
		struct exynos_spi *regs;
		int inited;		/* 1 if this bus is ready for use */
		int node;
		uint deactivate_delay_us;	/* Delay to wait after deactivate */
	};

Of these, inited is handled by DM and node is the device tree node, which
DM tells you. The name is not quite right. So in this case we would use:

.. code-block:: c

	struct exynos_spi_plat {
		enum periph_id periph_id;
		s32 frequency;		/* Default clock frequency, -1 for none */
		struct exynos_spi *regs;
		uint deactivate_delay_us;	/* Delay to wait after deactivate */
	};


Write of_to_plat() [for device tree only]
-------------------------------------------------

This method will convert information in the device tree node into a C
structure in your driver (called platform data). If you are not using
device tree, go to 8b.

DM will automatically allocate the struct for us when we are using device
tree, but we need to tell it the size:

.. code-block:: c

	U_BOOT_DRIVER(spi_exynos) = {
	...
		.plat_auto = sizeof(struct exynos_spi_plat),


Here is a sample function. It gets a pointer to the platform data and
fills in the fields from device tree.

.. code-block:: c

	static int exynos_spi_of_to_plat(struct udevice *bus)
	{
		struct exynos_spi_plat *plat = bus->plat;
		const void *blob = gd->fdt_blob;
		int node = dev_of_offset(bus);

		plat->regs = (struct exynos_spi *)fdtdec_get_addr(blob, node, "reg");
		plat->periph_id = pinmux_decode_periph_id(blob, node);

		if (plat->periph_id == PERIPH_ID_NONE) {
			debug("%s: Invalid peripheral ID %d\n", __func__,
				plat->periph_id);
			return -FDT_ERR_NOTFOUND;
		}

		/* Use 500KHz as a suitable default */
		plat->frequency = fdtdec_get_int(blob, node, "spi-max-frequency",
						500000);
		plat->deactivate_delay_us = fdtdec_get_int(blob, node,
						"spi-deactivate-delay", 0);
		debug("%s: regs=%p, periph_id=%d, max-frequency=%d, deactivate_delay=%d\n",
		      __func__, plat->regs, plat->periph_id, plat->frequency,
		      plat->deactivate_delay_us);

		return 0;
	}


Add the platform data [non-device-tree only]
--------------------------------------------

Specify this data in a U_BOOT_DRVINFO() declaration in your board file:

.. code-block:: c

	struct exynos_spi_plat platdata_spi0 = {
		.periph_id = ...
		.frequency = ...
		.regs = ...
		.deactivate_delay_us = ...
	};

	U_BOOT_DRVINFO(board_spi0) = {
		.name = "exynos_spi",
		.plat = &platdata_spi0,
	};

You will unfortunately need to put the struct definition into a header file
in this case so that your board file can use it.


Add the device private data
---------------------------

Most devices have some private data which they use to keep track of things
while active. This is the run-time information and needs to be stored in
a structure. There is probably a structure in the driver that includes a
'struct spi_slave', so you can use that.

.. code-block:: c

	struct exynos_spi_slave {
		struct spi_slave slave;
		struct exynos_spi *regs;
		unsigned int freq;		/* Default frequency */
		unsigned int mode;
		enum periph_id periph_id;	/* Peripheral ID for this device */
		unsigned int fifo_size;
		int skip_preamble;
		struct spi_bus *bus;		/* Pointer to our SPI bus info */
		ulong last_transaction_us;	/* Time of last transaction end */
	};


We should rename this to make its purpose more obvious, and get rid of
the slave structure, so we have:

.. code-block:: c

	struct exynos_spi_priv {
		struct exynos_spi *regs;
		unsigned int freq;		/* Default frequency */
		unsigned int mode;
		enum periph_id periph_id;	/* Peripheral ID for this device */
		unsigned int fifo_size;
		int skip_preamble;
		ulong last_transaction_us;	/* Time of last transaction end */
	};


DM can auto-allocate this also:

.. code-block:: c

	U_BOOT_DRIVER(spi_exynos) = {
	...
		.priv_auto = sizeof(struct exynos_spi_priv),


Note that this is created before the probe method is called, and destroyed
after the remove method is called. It will be zeroed when the probe
method is called.


Add the probe() and remove() methods
------------------------------------

Note: It's a good idea to build repeatedly as you are working, to avoid a
huge amount of work getting things compiling at the end.

The probe method is supposed to set up the hardware. U-Boot used to use
spi_setup_slave() to do this. So take a look at this function and see
what you can copy out to set things up.

.. code-block:: c

	static int exynos_spi_probe(struct udevice *bus)
	{
		struct exynos_spi_plat *plat = dev_get_plat(bus);
		struct exynos_spi_priv *priv = dev_get_priv(bus);

		priv->regs = plat->regs;
		if (plat->periph_id == PERIPH_ID_SPI1 ||
		    plat->periph_id == PERIPH_ID_SPI2)
			priv->fifo_size = 64;
		else
			priv->fifo_size = 256;

		priv->skip_preamble = 0;
		priv->last_transaction_us = timer_get_us();
		priv->freq = plat->frequency;
		priv->periph_id = plat->periph_id;

		return 0;
	}

This implementation doesn't actually touch the hardware, which is somewhat
unusual for a driver. In this case we will do that when the device is
claimed by something that wants to use the SPI bus.

For remove we could shut down the clocks, but in this case there is
nothing to do. DM frees any memory that it allocated, so we can just
remove exynos_spi_remove() and its reference in U_BOOT_DRIVER.


Implement set_speed()
---------------------

This should set up clocks so that the SPI bus is running at the right
speed. With the old API spi_claim_bus() would normally do this and several
of the following functions, so let's look at that function:

.. code-block:: c

	int spi_claim_bus(struct spi_slave *slave)
	{
		struct exynos_spi_slave *spi_slave = to_exynos_spi(slave);
		struct exynos_spi *regs = spi_slave->regs;
		u32 reg = 0;
		int ret;

		ret = set_spi_clk(spi_slave->periph_id,
						spi_slave->freq);
		if (ret < 0) {
			debug("%s: Failed to setup spi clock\n", __func__);
			return ret;
		}

		exynos_pinmux_config(spi_slave->periph_id, PINMUX_FLAG_NONE);

		spi_flush_fifo(slave);

		reg = readl(&regs->ch_cfg);
		reg &= ~(SPI_CH_CPHA_B | SPI_CH_CPOL_L);

		if (spi_slave->mode & SPI_CPHA)
			reg |= SPI_CH_CPHA_B;

		if (spi_slave->mode & SPI_CPOL)
			reg |= SPI_CH_CPOL_L;

		writel(reg, &regs->ch_cfg);
		writel(SPI_FB_DELAY_180, &regs->fb_clk);

		return 0;
	}


It sets up the speed, mode, pinmux, feedback delay and clears the FIFOs.
With DM these will happen in separate methods.


Here is an example for the speed part:

.. code-block:: c

	static int exynos_spi_set_speed(struct udevice *bus, uint speed)
	{
		struct exynos_spi_plat *plat = bus->plat;
		struct exynos_spi_priv *priv = dev_get_priv(bus);
		int ret;

		if (speed > plat->frequency)
			speed = plat->frequency;
		ret = set_spi_clk(priv->periph_id, speed);
		if (ret)
			return ret;
		priv->freq = speed;
		debug("%s: regs=%p, speed=%d\n", __func__, priv->regs, priv->freq);

		return 0;
	}


Implement set_mode()
--------------------

This should adjust the SPI mode (polarity, etc.). Again this code probably
comes from the old spi_claim_bus(). Here is an example:

.. code-block:: c

	static int exynos_spi_set_mode(struct udevice *bus, uint mode)
	{
		struct exynos_spi_priv *priv = dev_get_priv(bus);
		uint32_t reg;

		reg = readl(&priv->regs->ch_cfg);
		reg &= ~(SPI_CH_CPHA_B | SPI_CH_CPOL_L);

		if (mode & SPI_CPHA)
			reg |= SPI_CH_CPHA_B;

		if (mode & SPI_CPOL)
			reg |= SPI_CH_CPOL_L;

		writel(reg, &priv->regs->ch_cfg);
		priv->mode = mode;
		debug("%s: regs=%p, mode=%d\n", __func__, priv->regs, priv->mode);

		return 0;
	}


Implement claim_bus()
---------------------

This is where a client wants to make use of the bus, so claims it first.
At this point we need to make sure everything is set up ready for data
transfer. Note that this function is wholly internal to the driver - at
present the SPI uclass never calls it.

Here again we look at the old claim function and see some code that is
needed. It is anything unrelated to speed and mode:

.. code-block:: c

	static int exynos_spi_claim_bus(struct udevice *bus)
	{
		struct exynos_spi_priv *priv = dev_get_priv(bus);

		exynos_pinmux_config(priv->periph_id, PINMUX_FLAG_NONE);
		spi_flush_fifo(priv->regs);

		writel(SPI_FB_DELAY_180, &priv->regs->fb_clk);

		return 0;
	}

The spi_flush_fifo() function is in the removed part of the code, so we
need to expose it again (perhaps with an #endif before it and '#if 0'
after it). It only needs access to priv->regs which is why we have
passed that in:

.. code-block:: c

	/**
	 * Flush spi tx, rx fifos and reset the SPI controller
	 *
	 * @param regs	Pointer to SPI registers
	 */
	static void spi_flush_fifo(struct exynos_spi *regs)
	{
		clrsetbits_le32(&regs->ch_cfg, SPI_CH_HS_EN, SPI_CH_RST);
		clrbits_le32(&regs->ch_cfg, SPI_CH_RST);
		setbits_le32(&regs->ch_cfg, SPI_TX_CH_ON | SPI_RX_CH_ON);
	}


Implement release_bus()
-----------------------

This releases the bus - in our example the old code in spi_release_bus()
is a call to spi_flush_fifo, so we add:

.. code-block:: c

	static int exynos_spi_release_bus(struct udevice *bus)
	{
		struct exynos_spi_priv *priv = dev_get_priv(bus);

		spi_flush_fifo(priv->regs);

		return 0;
	}


Implement xfer()
----------------

This is the final method that we need to create, and it is where all the
work happens. The method parameters are the same as the old spi_xfer() with
the addition of a 'struct udevice' so conversion is pretty easy. Start
by copying the contents of spi_xfer() to your new xfer() method and proceed
from there.

If (flags & SPI_XFER_BEGIN) is non-zero then xfer() normally calls an
activate function, something like this:

.. code-block:: c

	void spi_cs_activate(struct spi_slave *slave)
	{
		struct exynos_spi_slave *spi_slave = to_exynos_spi(slave);

		/* If it's too soon to do another transaction, wait */
		if (spi_slave->bus->deactivate_delay_us &&
		    spi_slave->last_transaction_us) {
			ulong delay_us;		/* The delay completed so far */
			delay_us = timer_get_us() - spi_slave->last_transaction_us;
			if (delay_us < spi_slave->bus->deactivate_delay_us)
				udelay(spi_slave->bus->deactivate_delay_us - delay_us);
		}

		clrbits_le32(&spi_slave->regs->cs_reg, SPI_SLAVE_SIG_INACT);
		debug("Activate CS, bus %d\n", spi_slave->slave.bus);
		spi_slave->skip_preamble = spi_slave->mode & SPI_PREAMBLE;
	}

The new version looks like this:

.. code-block:: c

	static void spi_cs_activate(struct udevice *dev)
	{
		struct udevice *bus = dev->parent;
		struct exynos_spi_plat *pdata = dev_get_plat(bus);
		struct exynos_spi_priv *priv = dev_get_priv(bus);

		/* If it's too soon to do another transaction, wait */
		if (pdata->deactivate_delay_us &&
		    priv->last_transaction_us) {
			ulong delay_us;		/* The delay completed so far */
			delay_us = timer_get_us() - priv->last_transaction_us;
			if (delay_us < pdata->deactivate_delay_us)
				udelay(pdata->deactivate_delay_us - delay_us);
		}

		clrbits_le32(&priv->regs->cs_reg, SPI_SLAVE_SIG_INACT);
		debug("Activate CS, bus '%s'\n", bus->name);
		priv->skip_preamble = priv->mode & SPI_PREAMBLE;
	}

All we have really done here is change the pointers and print the device name
instead of the bus number. Other local static functions can be treated in
the same way.


Set up the per-child data and child pre-probe function
------------------------------------------------------

To minimise the pain and complexity of the SPI subsystem while the driver
model change-over is in place, struct spi_slave is used to reference a
SPI bus slave, even though that slave is actually a struct udevice. In fact
struct spi_slave is the device's child data. We need to make sure this space
is available. It is possible to allocate more space that struct spi_slave
needs, but this is the minimum.

.. code-block:: c

	U_BOOT_DRIVER(exynos_spi) = {
	...
		.per_child_auto	= sizeof(struct spi_slave),
	}


Optional: Set up cs_info() if you want it
-----------------------------------------

Sometimes it is useful to know whether a SPI chip select is valid, but this
is not obvious from outside the driver. In this case you can provide a
method for cs_info() to deal with this. If you don't provide it, then the
device tree will be used to determine what chip selects are valid.

Return -EINVAL if the supplied chip select is invalid, or 0 if it is valid.
If you don't provide the cs_info() method, 0 is assumed for all chip selects
that do not appear in the device tree.


Test it
-------

Now that you have the code written and it compiles, try testing it using
the 'sf test' command. You may need to enable CONFIG_CMD_SF_TEST for your
board.


Prepare patches and send them to the mailing lists
--------------------------------------------------

You can use 'tools/patman/patman' to prepare, check and send patches for
your work. See tools/patman/README for details.

A little note about SPI uclass features
---------------------------------------

The SPI uclass keeps some information about each device 'dev' on the bus:

   struct dm_spi_slave_plat:
     This is device_get_parent_plat(dev).
     This is where the chip select number is stored, along with
     the default bus speed and mode. It is automatically read
     from the device tree in spi_child_post_bind(). It must not
     be changed at run-time after being set up because platform
     data is supposed to be immutable at run-time.
   struct spi_slave:
     This is device_get_parentdata(dev).
     Already mentioned above. It holds run-time information about
     the device.

There are also some SPI uclass methods that get called behind the scenes:

   spi_post_bind():
     Called when a new bus is bound.
     This scans the device tree for devices on the bus, and binds
     each one. This in turn causes spi_child_post_bind() to be
     called for each, which reads the device tree information
     into the parent (per-child) platform data.
   spi_child_post_bind():
     Called when a new child is bound.
     As mentioned above this reads the device tree information
     into the per-child platform data
   spi_child_pre_probe():
     Called before a new child is probed.
     This sets up the mode and speed in struct spi_slave by
     copying it from the parent's platform data for this child.
     It also sets the 'dev' pointer, needed to permit passing
     'struct spi_slave' around the place without needing a
     separate 'struct udevice' pointer.

The above housekeeping makes it easier to write your SPI driver.
