drivers: spi: migrate cf_spi to DM
PATCH 1/1 drivers: spi: migrate cf_spi to DM
This patch adds DM support to cf_spi.c.
To be able to build spi driver with DM support, a new config option has been introdiced (DM_NO_DT) since m68k architecture does not support fdt.
--- arch/Kconfig | 1 + drivers/core/Kconfig | 4 + drivers/spi/cf_spi.c | 408 ++++++++++++++++++++------------ drivers/spi/spi-uclass.c | 12 +- include/dm/platform_data/spi_coldfire.h | 22 ++ 5 files changed, 291 insertions(+), 156 deletions(-) create mode 100644 include/dm/platform_data/spi_coldfire.h
arch/Kconfig +1 -0
@@ -28,6 +28,7 @@ config M68K select HAVE_PRIVATE_LIBGCC select SYS_BOOT_GET_CMDLINE select SYS_BOOT_GET_KBD + select DM_NO_OF config MICROBLAZE bool "MicroBlaze architecture"
drivers/core/Kconfig +4 -0
@@ -244,4 +244,8 @@ config DM_DEV_READ_INLINE bool default y if !OF_LIVE +config DM_NO_OF + bool + default n + endmenu
drivers/spi/cf_spi.c +257 -151
513 lines not on this page · raw message
drivers/spi/spi-uclass.c +7 -5
@@ -107,7 +107,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen,return dm_spi_xfer (slave->dev, bitlen, dout, din, flags); } -#if !CONFIG_IS_ENABLED (OF_PLATDATA ) +#if !CONFIG_IS_ENABLED (OF_PLATDATA ) && !defined(CONFIG_DM_NO_OF )static int spi_child_post_bind (struct udevice *dev) {struct dm_spi_slave_platdata *plat =dev_get_parent_platdata (dev);
@@ -121,7 +121,7 @@ static int spi_child_post_bind(struct udevice *dev)static int spi_post_probe (struct udevice *bus) { -#if !CONFIG_IS_ENABLED (OF_PLATDATA ) +#if !CONFIG_IS_ENABLED (OF_PLATDATA ) && !defined(CONFIG_DM_NO_OF )struct dm_spi_bus *spi =dev_get_uclass_priv (bus); spi->max_hz =dev_read_u32_default (bus,"spi-max-frequency" ,0 );
@@ -274,7 +274,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode,bool created = false;int ret; -#if CONFIG_IS_ENABLED (OF_PLATDATA ) +#if CONFIG_IS_ENABLED (OF_PLATDATA ) || defined(CONFIG_DM_NO_OF ) ret =uclass_first_device_err (UCLASS_SPI , &bus);#else ret =uclass_get_device_by_seq (UCLASS_SPI , busnum, &bus);
@@ -283,6 +283,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode,printf ("Invalid bus %d (err=%d)\n" , busnum, ret);return ret; } + ret =spi_find_chip_select (bus, cs, &dev);/*
@@ -321,6 +322,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode, } plat =dev_get_parent_platdata (dev); +if (!speed) { speed = plat->max_hz; mode = plat->mode;
@@ -427,7 +429,7 @@ UCLASS_DRIVER(spi) = { .id = UCLASS_SPI, .name = "spi", .flags = DM_UC_FLAG_SEQ_ALIAS, -#if !CONFIG_IS_ENABLED(OF_PLATDATA) +#if !CONFIG_IS_ENABLED(OF_PLATDATA) && !defined(CONFIG_DM_NO_OF) .post_bind = dm_scan_fdt_dev, #endif .post_probe = spi_post_probe,
@@ -436,7 +438,7 @@ UCLASS_DRIVER(spi) = { .per_child_auto_alloc_size = sizeof(struct spi_slave), .per_child_platdata_auto_alloc_size = sizeof(struct dm_spi_slave_platdata), -#if !CONFIG_IS_ENABLED (OF_PLATDATA ) +#if !CONFIG_IS_ENABLED (OF_PLATDATA ) && !defined(CONFIG_DM_NO_OF ) .child_post_bind = spi_child_post_bind,#endif };
include/dm/platform_data/spi_coldfire.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright (c) 2015 Angelo Dureghello <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __spi_coldfire_h +#define __spi_coldfire_h + +/* +* struct coldfire_spi_platdata - information about a coldfire spi module +* +* @speed_hz: SPI speed +*/ +struct coldfire_spi_platdata { +uint speed_hz; +uint mode; +uint cs; +}; + +#endif /* __spi_coldfire_h */ +
Signature · 1 line
2.15.1
PATCH 1/1 drivers: spi: migrate cf_spi to DM
Quoted 4 lines · Angelo Dureghello
This patch adds DM support to
cf_spi.c.
To be able to build spi driver with DM support, a new config option has been introdiced (DM_NO_DT) since m68k architecture does not support fdt.
This can be different case, how about using platdata in U-Boot?
Jagan.
Signature · 4 lines
Jagan Teki Free Software Engineer | www.openedev.com U-Boot, Linux | Upstream Maintainer Hyderabad, India.
PATCH 1/1 drivers: spi: migrate cf_spi to DM
Hi Jagan,
Quoted 8 lines · Jagan Teki
Quoted 4 lines · Angelo Dureghello
This patch adds DM support to
cf_spi.c.
To be able to build spi driver with DM support, a new config option has been introdiced (DM_NO_DT) since m68k architecture does not support fdt.This can be different case, how about using platdata in U-Boot?
I used also platdata, as you can see from
+#include <dm/platform_data/spi_coldfire.h>
But it is not enough: spi/spi-uclass.c in any case looks for fdt nodes entries, so i had to add that DM_NO_OF option, this to avoid all the of_xx calls as unresolved externals.
Every suggestion is welcome.
Quoted 2 lines
Jagan.
Regards,
Angelo
Quoted 9 lines
--
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH 1/1 drivers: spi: migrate cf_spi to DM
Quoted 12 lines · Angelo Dureghello
Hi Jagan,
Quoted 8 lines · Jagan Teki
Quoted 4 lines · Angelo Dureghello
This patch adds DM support to
cf_spi.c.
To be able to build spi driver with DM support, a new config option has been introdiced (DM_NO_DT) since m68k architecture does not support fdt.This can be different case, how about using platdata in U-Boot?
Quoted 7 lines
I used also platdata, as you can see from
+#include <
dm/platform_data/spi_coldfire.h>But it is not enough:
spi/spi-uclass.cin any case looks for fdt nodes entries, so i had to add thatDM_NO_OFoption, this to avoid all theof_xxcalls as unresolved externals.
Ok, then create separate patches for DM_NO_OF and spi changes.