From 6faa4ed74df2d83cbb959ba799032da4249893b6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 29 Jul 2017 11:34:53 -0600 Subject: dm: blk: Add a function to find an interface-type name Add a function to find the name of an interface type (e.g. "sata", "scsi") from the interface type enum. This is useful for generic code (not specific to SATA or SCSI, for example) that wants to display the type of interface it is dealing with. Signed-off-by: Simon Glass --- include/blk.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/blk.h b/include/blk.h index 61b56281b31..8672e32fe1d 100644 --- a/include/blk.h +++ b/include/blk.h @@ -624,4 +624,12 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start, */ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart); +/** + * blk_get_if_type_name() - Get the name of an interface type + * + * @if_type: Interface type to check + * @return name of interface, or NULL if none + */ +const char *blk_get_if_type_name(enum if_type if_type); + #endif -- cgit v1.2.3 From 4395f6673901196b58821e2e9e37fb8e93b25528 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 29 Jul 2017 11:34:54 -0600 Subject: dm: blk: Add a generic function for block device commands Most block devices provide a command (e.g. 'sata', 'scsi', 'ide') and these commands generally do the same thing. This makes it harder to maintain this code and keep it consistent. We now have a block device interface which is either implemented by driver model (when CONFIG_BLK is enabled) or with a legacy interface. Therefore it is possible to handle most of what these commands do with generic code. Add a new generic function to process block-device commands using the interface type and the current device number for that type. Signed-off-by: Simon Glass --- include/blk.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/blk.h b/include/blk.h index 8672e32fe1d..a106f9ca0e5 100644 --- a/include/blk.h +++ b/include/blk.h @@ -632,4 +632,16 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart); */ const char *blk_get_if_type_name(enum if_type if_type); +/** + * blk_common_cmd() - handle common commands with block devices + * + * @args: Number of arguments to the command (argv[0] is the command itself) + * @argv: Command arguments + * @if_type: Interface type + * @cur_devnump: Current device number for this interface type + * @return 0 if OK, CMD_RET_ERROR on error + */ +int blk_common_cmd(int argc, char * const argv[], enum if_type if_type, + int *cur_devnump); + #endif -- cgit v1.2.3 From e88afccc44562912a681ce14e348408277d942cb Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 29 Jul 2017 11:35:00 -0600 Subject: dm: core: Add a comment about the device_remove() flags We should explain which flags are used for this function. Update the comment to indicate this. Signed-off-by: Simon Glass --- include/dm/device-internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index 81ab893b600..eaeadd48d2a 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -98,7 +98,7 @@ int device_probe(struct udevice *dev); * children are deactivated first. * * @dev: Pointer to device to remove - * @flags: Flags for selective device removal + * @flags: Flags for selective device removal (DM_REMOVE_...) * @return 0 if OK, -ve on error (an error here is normally a very bad thing) */ #if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE) -- cgit v1.2.3 From f19f1ecb6025f0e2afb237a59b24462c5340787a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 29 Jul 2017 11:35:13 -0600 Subject: dm: sata: Support driver model with the 'sata' command Update this command to support driver model. This has a different way of starting and stopping SATA. Signed-off-by: Simon Glass --- include/sata.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/sata.h b/include/sata.h index d18cc9aa875..d89f7a8a298 100644 --- a/include/sata.h +++ b/include/sata.h @@ -2,7 +2,7 @@ #define __SATA_H__ #include -#if !defined(CONFIG_DM_SCSI) +#if !defined(CONFIG_DM_SCSI) && !defined(CONFIG_AHCI) int init_sata(int dev); int reset_sata(int dev); int scan_sata(int dev); @@ -18,4 +18,7 @@ int sata_port_status(int dev, int port); extern struct blk_desc sata_dev_desc[]; #endif +int sata_probe(int devnum); +int sata_remove(int devnum); + #endif -- cgit v1.2.3 From b8341f1c39df8708ee783038d8abb2b50dd83fac Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 29 Jul 2017 11:35:15 -0600 Subject: dm: sata: Update the AHCI uclass to support operations At present the AHCI uclass is just a shell and we still use the global functions to access SATA. Fix this by adding operations to the uclass. Signed-off-by: Simon Glass --- include/ahci.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'include') diff --git a/include/ahci.h b/include/ahci.h index 29f4ba1d13d..33171b7ffd6 100644 --- a/include/ahci.h +++ b/include/ahci.h @@ -176,6 +176,60 @@ struct ahci_uc_priv { u32 link_port_map; /*linkup port map*/ }; +struct ahci_ops { + /** + * reset() - reset the controller + * + * @dev: Controller to reset + * @return 0 if OK, -ve on error + */ + int (*reset)(struct udevice *dev); + + /** + * port_status() - get the status of a SATA port + * + * @dev: Controller to reset + * @port: Port number to check (0 for first) + * @return 0 if detected, -ENXIO if nothing on port, other -ve on error + */ + int (*port_status)(struct udevice *dev, int port); + + /** + * scan() - scan SATA ports + * + * @dev: Controller to scan + * @return 0 if OK, -ve on error + */ + int (*scan)(struct udevice *dev); +}; + +#define ahci_get_ops(dev) ((struct ahci_ops *)(dev)->driver->ops) + +/** + * sata_reset() - reset the controller + * + * @dev: Controller to reset + * @return 0 if OK, -ve on error + */ +int sata_reset(struct udevice *dev); + +/** + * sata_port_status() - get the status of a SATA port + * + * @dev: Controller to reset + * @port: Port number to check (0 for first) + * @return 0 if detected, -ENXIO if nothin on port, other -ve on error + */ +int sata_dm_port_status(struct udevice *dev, int port); + +/** + * sata_scan() - scan SATA ports + * + * @dev: Controller to scan + * @return 0 if OK, -ve on error + */ +int sata_scan(struct udevice *dev); + int ahci_init(void __iomem *base); int ahci_reset(void __iomem *base); -- cgit v1.2.3 From c893f1e6e5cd6ccd4c7aaaf760f27fa6779e351c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 29 Jul 2017 11:35:16 -0600 Subject: dm: sata: dwc_ahsata: Add support for driver model Update this driver to support driver model. This involves implementing the AHCI operations and reusing existing common code. Signed-off-by: Simon Glass --- include/dwc_ahsata.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 include/dwc_ahsata.h (limited to 'include') diff --git a/include/dwc_ahsata.h b/include/dwc_ahsata.h new file mode 100644 index 00000000000..cae275fe75a --- /dev/null +++ b/include/dwc_ahsata.h @@ -0,0 +1,16 @@ +/* + * Copyright 2017 Google, Inc + * Written by Simon Glass + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __DWC_AHSATA_H__ +#define __DWC_AHSATA_H__ + +int dwc_ahsata_bus_reset(struct udevice *dev); +int dwc_ahsata_probe(struct udevice *dev); +int dwc_ahsata_scan(struct udevice *dev); +int dwc_ahsata_port_status(struct udevice *dev, int port); + +#endif -- cgit v1.2.3 From e7881d85a94b2e35b12a163c3af671057e9ca5e8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 29 Jul 2017 11:35:31 -0600 Subject: dm: mmc: Drop CONFIG_DM_MMC_OPS All boards which use DM_MMC have now been converted to use DM_MMC_OPS. Drop the option and good riddance. Signed-off-by: Simon Glass --- include/configs/am335x_evm.h | 1 - include/configs/am335x_shc.h | 1 - include/configs/chiliboard.h | 1 - include/configs/omap3_logic.h | 1 - include/dwmmc.h | 2 +- include/mmc.h | 6 +++--- include/sdhci.h | 2 +- 7 files changed, 5 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index c9420b2d739..973f63f891b 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -282,7 +282,6 @@ */ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC -#undef CONFIG_DM_MMC_OPS #undef CONFIG_TIMER #undef CONFIG_DM_USB #endif diff --git a/include/configs/am335x_shc.h b/include/configs/am335x_shc.h index 62ab2d7227e..3fdbfdcdc67 100644 --- a/include/configs/am335x_shc.h +++ b/include/configs/am335x_shc.h @@ -256,7 +256,6 @@ */ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC -#undef CONFIG_DM_MMC_OPS #undef CONFIG_TIMER #endif diff --git a/include/configs/chiliboard.h b/include/configs/chiliboard.h index fb3e67466ee..20075915fd5 100644 --- a/include/configs/chiliboard.h +++ b/include/configs/chiliboard.h @@ -183,7 +183,6 @@ */ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC -#undef CONFIG_DM_MMC_OPS #undef CONFIG_TIMER #undef CONFIG_DM_USB #endif diff --git a/include/configs/omap3_logic.h b/include/configs/omap3_logic.h index 5490fc945a1..b4311ab13b6 100644 --- a/include/configs/omap3_logic.h +++ b/include/configs/omap3_logic.h @@ -23,7 +23,6 @@ * DM support in SPL */ #undef CONFIG_DM_MMC -#undef CONFIG_DM_MMC_OPS #undef OMAP_HSMMC_USE_GPIO /* select serial console configuration for SPL */ diff --git a/include/dwmmc.h b/include/dwmmc.h index 4dda0091cef..a9058824e0d 100644 --- a/include/dwmmc.h +++ b/include/dwmmc.h @@ -291,7 +291,7 @@ int dwmci_bind(struct udevice *dev, struct mmc *mmc, struct mmc_config *cfg); int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk); #endif /* !CONFIG_BLK */ -#ifdef CONFIG_DM_MMC_OPS +#ifdef CONFIG_DM_MMC /* Export the operations to drivers */ int dwmci_probe(struct udevice *dev); extern const struct dm_mmc_ops dm_dwmci_ops; diff --git a/include/mmc.h b/include/mmc.h index cb8bf6a971c..16a5c20a288 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -321,7 +321,7 @@ struct mmc_data { /* forward decl. */ struct mmc; -#if CONFIG_IS_ENABLED(DM_MMC_OPS) +#if CONFIG_IS_ENABLED(DM_MMC) struct dm_mmc_ops { /** * send_cmd() - Send a command to the MMC device @@ -385,7 +385,7 @@ struct mmc_ops { struct mmc_config { const char *name; -#if !CONFIG_IS_ENABLED(DM_MMC_OPS) +#if !CONFIG_IS_ENABLED(DM_MMC) const struct mmc_ops *ops; #endif uint host_caps; @@ -519,7 +519,7 @@ int mmc_switch_part(struct mmc *mmc, unsigned int part_num); int mmc_hwpart_config(struct mmc *mmc, const struct mmc_hwpart_conf *conf, enum mmc_hwpart_conf_mode mode); -#if !CONFIG_IS_ENABLED(DM_MMC_OPS) +#if !CONFIG_IS_ENABLED(DM_MMC) int mmc_getcd(struct mmc *mmc); int board_mmc_getcd(struct mmc *mmc); int mmc_getwp(struct mmc *mmc); diff --git a/include/sdhci.h b/include/sdhci.h index 6a43271e963..7e84012f60e 100644 --- a/include/sdhci.h +++ b/include/sdhci.h @@ -410,7 +410,7 @@ int sdhci_bind(struct udevice *dev, struct mmc *mmc, struct mmc_config *cfg); int add_sdhci(struct sdhci_host *host, u32 f_max, u32 f_min); #endif /* !CONFIG_BLK */ -#ifdef CONFIG_DM_MMC_OPS +#ifdef CONFIG_DM_MMC /* Export the operations to drivers */ int sdhci_probe(struct udevice *dev); extern const struct dm_mmc_ops sdhci_ops; -- cgit v1.2.3 From bdb6099666933491ce393e52132e05604da91b1a Mon Sep 17 00:00:00 2001 From: Angelo Dureghello Date: Tue, 1 Aug 2017 14:27:10 +0200 Subject: cmd: mmc: add mmc partconf read capability This patch allows to show the EXT_CSD[179] partition_config register info, just by specifying the dev param: U-Boot> mmc partconf 0 EXT_CSD[179], PARTITION_CONFIG: BOOT_ACK: 0x0 BOOT_PARTITION_ENABLE: 0x0 PARTITION_ACCESS: 0x0 Signed-off-by: Angelo Dureghello Signed-off-by: Anatolij Gustschin --- include/mmc.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/mmc.h b/include/mmc.h index 16a5c20a288..010ebe048c4 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -221,6 +221,10 @@ #define EXT_CSD_BOOT_PART_NUM(x) (x << 3) #define EXT_CSD_PARTITION_ACCESS(x) (x << 0) +#define EXT_CSD_EXTRACT_BOOT_ACK(x) (((x) >> 6) & 0x1) +#define EXT_CSD_EXTRACT_BOOT_PART(x) (((x) >> 3) & 0x7) +#define EXT_CSD_EXTRACT_PARTITION_ACCESS(x) ((x) & 0x7) + #define EXT_CSD_BOOT_BUS_WIDTH_MODE(x) (x << 3) #define EXT_CSD_BOOT_BUS_WIDTH_RESET(x) (x << 2) #define EXT_CSD_BOOT_BUS_WIDTH_WIDTH(x) (x) -- cgit v1.2.3