This is to announce that I have started working on DM driver support for mxs spi driver that adds basic skeleton of DM driver functionality along with legacy driver support.
This is compilation tested only. Signed-off-by: Akash Gajjar <gajjar04ak...@gmail.com> --- drivers/spi/mxs_spi.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c index 790db78..94e9ab3 100644 --- a/drivers/spi/mxs_spi.c +++ b/drivers/spi/mxs_spi.c @@ -20,6 +20,9 @@ #include <asm/arch/imx-regs.h> #include <asm/arch/sys_proto.h> #include <asm/mach-imx/dma.h> +#ifdef CONFIG_DM_SPI +#include <dm.h> +#endif #define MXS_SPI_MAX_TIMEOUT 1000000 #define MXS_SPI_PORT_OFFSET 0x2000 @@ -361,3 +364,74 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, return mxs_spi_xfer_dma(mxs_slave, data, len, write, flags); } } + +#ifdef CONFIG_DM_SPI +struct mxs_spi_priv { + struct spi_slave slave; + struct mxs_ssp_regs *regs; + u32 max_khz; + u32 mode; +}; + +struct mxs_spi_platdata { + struct spi_slave slave; + struct mxs_ssp_regs *regs; + u32 bus; +}; + +static int mxs_spi_claim_bus(struct udevice *dev) +{ + struct udevice *bus = dev->parent; + struct mxs_spi_platdata *plat = dev_get_platdata(bus); + struct mxs_ssp_regs *ssp_regs = plat->regs; + u32 reg = 0; + + writel((slave->cs << MXS_SSP_CHIPSELECT_SHIFT) | + SSP_CTRL0_BUS_WIDTH_ONE_BIT, + &ssp_regs->hw_ssp_ctrl0); + + return 0; +} + +static int mxs_spi_release_bus(struct udevice *dev) +{ + return 0; +} + +static int mxs_spi_xfer(struct udevice *dev, unsigned int bitlen, + const void *dout, void *din, unsigned long flags) +{ + return 0; +} + +static int mxs_spi_set_speed(struct udevice *bus, uint speed) +{ + return 0; +} + +static int mxs_spi_set_mode(struct udevice *bus, uint mode) +{ + return 0; +} + +static int mxs_spi_probe(struct udevice *dev) +{ + return 0; +} + +static const struct dm_spi_ops mxs_spi_ops = { + .claim_bus = mxs_spi_claim_bus, + .release_bus = mxs_spi_release_bus, + .xfer = mxs_spi_xfer, + .set_speed = mxs_spi_set_speed, + .set_mode = mxs_spi_set_mode, +}; + +U_BOOT_DRIVER(mxs_spi) = { + .name = "mxs_spi", + .id = UCLASS_SPI, + .ops = &mxs_spi_ops, + .priv_auto_alloc_size = sizeof(struct mxs_spi_priv), + .probe = mxs_spi_probe, +}; +#endif -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot