From e27802af54c2ff2d4d58e4bc217644b75c04ac4c Mon Sep 17 00:00:00 2001 From: "angelo@sysam.it" Date: Wed, 27 Apr 2016 21:51:13 +0200 Subject: m68k: add DM model serial driver Boards can now use DM serial driver, or still legacy mcf uart driver version. Signed-off-by: Angelo Dureghello Acked-by: Simon Glass --- include/dm/platform_data/serial_coldfire.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 include/dm/platform_data/serial_coldfire.h (limited to 'include') diff --git a/include/dm/platform_data/serial_coldfire.h b/include/dm/platform_data/serial_coldfire.h new file mode 100644 index 0000000000..5d86456f1e --- /dev/null +++ b/include/dm/platform_data/serial_coldfire.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2015 Angelo Dureghello + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __serial_coldfire_h +#define __serial_coldfire_h + +/* + * struct coldfire_serial_platdata - information about a coldfire port + * + * @base: Uart port base register address + * @port: Uart port index, for cpu with pinmux for uart / gpio + * baudrtatre: Uart port baudrate + */ +struct coldfire_serial_platdata { + unsigned long base; + int port; + int baudrate; +}; + +#endif /* __serial_coldfire_h */ -- cgit v1.2.1 From 7a3eff4ce962de50bd9a1d83a9fce178c04999d3 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Tue, 3 May 2016 10:02:22 +0800 Subject: dm: spi: introduce dm api Introduce dm_spi_claim_bus, dm_spi_release_bus and dm_spi_xfer Convert spi_claim_bus, spi_release_bus and spi_xfer to use the new API. Signed-off-by: Peng Fan Cc: Simon Glass Cc: Jagan Teki Acked-by: Simon Glass --- include/spi.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'include') diff --git a/include/spi.h b/include/spi.h index 4b88d3986e..ca96fa4b31 100644 --- a/include/spi.h +++ b/include/spi.h @@ -612,6 +612,58 @@ int sandbox_spi_get_emul(struct sandbox_state *state, struct udevice *bus, struct udevice *slave, struct udevice **emulp); +/** + * Claim the bus and prepare it for communication with a given slave. + * + * This must be called before doing any transfers with a SPI slave. It + * will enable and initialize any SPI hardware as necessary, and make + * sure that the SCK line is in the correct idle state. It is not + * allowed to claim the same bus for several slaves without releasing + * the bus in between. + * + * @dev: The SPI slave device + * + * Returns: 0 if the bus was claimed successfully, or a negative value + * if it wasn't. + */ +int dm_spi_claim_bus(struct udevice *dev); + +/** + * Release the SPI bus + * + * This must be called once for every call to dm_spi_claim_bus() after + * all transfers have finished. It may disable any SPI hardware as + * appropriate. + * + * @slave: The SPI slave device + */ +void dm_spi_release_bus(struct udevice *dev); + +/** + * SPI transfer + * + * This writes "bitlen" bits out the SPI MOSI port and simultaneously clocks + * "bitlen" bits in the SPI MISO port. That's just the way SPI works. + * + * The source of the outgoing bits is the "dout" parameter and the + * destination of the input bits is the "din" parameter. Note that "dout" + * and "din" can point to the same memory location, in which case the + * input data overwrites the output data (since both are buffered by + * temporary variables, this is OK). + * + * dm_spi_xfer() interface: + * @dev: The SPI slave device which will be sending/receiving the data. + * @bitlen: How many bits to write and read. + * @dout: Pointer to a string of bits to send out. The bits are + * held in a byte array and are sent MSB first. + * @din: Pointer to a string of bits that will be filled in. + * @flags: A bitwise combination of SPI_XFER_* flags. + * + * Returns: 0 on success, not 0 on failure + */ +int dm_spi_xfer(struct udevice *dev, unsigned int bitlen, + const void *dout, void *din, unsigned long flags); + /* Access the operations for a SPI device */ #define spi_get_ops(dev) ((struct dm_spi_ops *)(dev)->driver->ops) #define spi_emul_get_ops(dev) ((struct dm_spi_emul_ops *)(dev)->driver->ops) -- cgit v1.2.1 From c0c62d923344d5a68f43259282e68a827318db01 Mon Sep 17 00:00:00 2001 From: Mugunthan V N Date: Tue, 12 Apr 2016 16:01:19 +0530 Subject: drivers: usb: common: add common code for usb drivers to use Add common usb code which usb drivers makes use of it. Signed-off-by: Mugunthan V N Reviewed-by: Simon Glass --- include/linux/usb/otg.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index 7ec5550f4b..8f8ac6aeef 100644 --- a/include/linux/usb/otg.h +++ b/include/linux/usb/otg.h @@ -17,4 +17,13 @@ enum usb_dr_mode { USB_DR_MODE_OTG, }; +/** + * usb_get_dr_mode() - Get dual role mode for given device + * @node: Node offset to the given device + * + * The function gets phy interface string from property 'dr_mode', + * and returns the correspondig enum usb_dr_mode + */ +enum usb_dr_mode usb_get_dr_mode(int node); + #endif /* __LINUX_USB_OTG_H */ -- cgit v1.2.1 From 6c880b7719d73dc4bf4bf828b6341e086e6f5eb6 Mon Sep 17 00:00:00 2001 From: Eric Nelson Date: Sun, 24 Apr 2016 16:32:40 -0700 Subject: dm: gpio: add a default gpio xlate routine Many drivers use a common form of offset + flags for device tree nodes. e.g.: <&gpio1 2 GPIO_ACTIVE_LOW> This patch adds a common implementation of this type of parsing and calls it when a gpio driver doesn't supply its' own xlate routine. This will allow removal of the driver-specific versions in a handful of drivers and simplify the addition of new drivers. Signed-off-by: Eric Nelson Reviewed-by: Stephen Warren Acked-by: Simon Glass --- include/asm-generic/gpio.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index 68b5f0b3c2..2500c10450 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -206,6 +206,16 @@ int gpio_requestf(unsigned gpio, const char *fmt, ...) struct fdtdec_phandle_args; +/** + * gpio_xlate_offs_flags() - implementation for common use of dm_gpio_ops.xlate + * + * This routine sets the offset field to args[0] and the flags field to + * GPIOD_ACTIVE_LOW if the GPIO_ACTIVE_LOW flag is present in args[1]. + * + */ +int gpio_xlate_offs_flags(struct udevice *dev, struct gpio_desc *desc, + struct fdtdec_phandle_args *args); + /** * struct struct dm_gpio_ops - Driver model GPIO operations * @@ -258,12 +268,11 @@ struct dm_gpio_ops { * * @desc->dev to @dev * @desc->flags to 0 - * @desc->offset to the value of the first argument in args, if any, - * otherwise -1 (which is invalid) + * @desc->offset to 0 * - * This method is optional so if the above defaults suit it can be - * omitted. Typical behaviour is to set up the GPIOD_ACTIVE_LOW flag - * in desc->flags. + * This method is optional and defaults to gpio_xlate_offs_flags, + * which will parse offset and the GPIO_ACTIVE_LOW flag in the first + * two arguments. * * Note that @dev is passed in as a parameter to follow driver model * uclass conventions, even though it is already available as -- cgit v1.2.1 From cf63084492377108698619f6d33967af2119e584 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:35:51 -0600 Subject: pci: Drop CONFIG_SYS_SCSI_SCAN_BUS_REVERSE This option is not used by any board. Drop it. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- include/configs/MPC8641HPCN.h | 2 -- include/configs/sbc8641d.h | 2 -- 2 files changed, 4 deletions(-) (limited to 'include') diff --git a/include/configs/MPC8641HPCN.h b/include/configs/MPC8641HPCN.h index 2f94c8214e..5e23007d8d 100644 --- a/include/configs/MPC8641HPCN.h +++ b/include/configs/MPC8641HPCN.h @@ -354,8 +354,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy); #define CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ -#undef CONFIG_SYS_SCSI_SCAN_BUS_REVERSE - #define CONFIG_PCI_PNP /* do pci plug-and-play */ #undef CONFIG_EEPRO100 diff --git a/include/configs/sbc8641d.h b/include/configs/sbc8641d.h index a7c7aef71a..c9970f1f3e 100644 --- a/include/configs/sbc8641d.h +++ b/include/configs/sbc8641d.h @@ -297,8 +297,6 @@ #define CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ -#undef CONFIG_SYS_SCSI_SCAN_BUS_REVERSE - #define CONFIG_PCI_PNP /* do pci plug-and-play */ #undef CONFIG_EEPRO100 -- cgit v1.2.1 From a219639d4216e59a0c55f0b7d2c8a21f9cb0bb06 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:35:52 -0600 Subject: dm: Rename disk uclass to ahci This started as 'ahci' and was renamed to 'disk' during code review. But it seems that this is too generic. Now that we have a 'blk' uclass, we can use that as the generic piece, and revert to ahci for this. Signed-off-by: Simon Glass --- include/dm/uclass-id.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index cbf9b2ca23..a5cf6e201c 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -26,11 +26,11 @@ enum uclass_id { /* U-Boot uclasses start here - in alphabetical order */ UCLASS_ADC, /* Analog-to-digital converter */ + UCLASS_AHCI, /* SATA disk controller */ UCLASS_BLK, /* Block device */ UCLASS_CLK, /* Clock source, e.g. used by peripherals */ UCLASS_CPU, /* CPU, typically part of an SoC */ UCLASS_CROS_EC, /* Chrome OS EC */ - UCLASS_DISK, /* Disk controller, e.g. SATA */ UCLASS_DISPLAY, /* Display (e.g. DisplayPort, HDMI) */ UCLASS_DMA, /* Direct Memory Access */ UCLASS_RAM, /* RAM controller */ -- cgit v1.2.1 From 709e98b7b2461c2535d4ac2bb0311c3b3f53dbbb Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:35:53 -0600 Subject: Allow iotrace byte access to use an address of any size If an address is used with readb() and writeb() which is smaller than the expected size (e.g. 32-bit value on a machine with 64-bit addresses), a warning results. Fix this by adding a cast. Signed-off-by: Simon Glass --- include/iotrace.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/iotrace.h b/include/iotrace.h index 9bd1f167ab..e4ceb61805 100644 --- a/include/iotrace.h +++ b/include/iotrace.h @@ -31,10 +31,11 @@ #define writew(val, addr) iotrace_writew(val, (const void *)(addr)) #undef readb -#define readb(addr) iotrace_readb((const void *)(addr)) +#define readb(addr) iotrace_readb((const void *)(uintptr_t)addr) #undef writeb -#define writeb(val, addr) iotrace_writeb(val, (const void *)(addr)) +#define writeb(val, addr) \ + iotrace_writeb(val, (const void *)(uintptr_t)addr) #endif -- cgit v1.2.1 From c649e3c91cdc96a86ca2665fcfafaca5c4b384b1 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:02 -0600 Subject: dm: scsi: Rename CONFIG_CMD_SCSI to CONFIG_SCSI This option currently enables both the command and the SCSI functionality. Rename the existing option to CONFIG_SCSI since most of the code relates to the feature. Signed-off-by: Simon Glass --- include/config_cmd_all.h | 2 +- include/config_distro_bootcmd.h | 6 +++--- include/config_fallbacks.h | 2 +- include/configs/MPC8544DS.h | 2 +- include/configs/MPC8572DS.h | 2 +- include/configs/MPC8610HPCD.h | 2 +- include/configs/MPC8641HPCN.h | 2 +- include/configs/PIP405.h | 2 +- include/configs/am57xx_evm.h | 2 +- include/configs/cm_t54.h | 2 +- include/configs/db-88f6820-gp.h | 2 +- include/configs/dra7xx_evm.h | 2 +- include/configs/efi-x86.h | 2 +- include/configs/galileo.h | 2 +- include/configs/highbank.h | 2 +- include/configs/ls1043aqds.h | 2 +- include/configs/ls2080aqds.h | 2 +- include/configs/ls2080ardb.h | 2 +- include/configs/omap5_uevm.h | 2 +- include/configs/qemu-x86.h | 2 +- include/configs/sunxi-common.h | 2 +- include/configs/x86-common.h | 2 +- include/configs/xilinx_zynqmp.h | 2 +- 23 files changed, 25 insertions(+), 25 deletions(-) (limited to 'include') diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h index ed502a191f..b5fd6c68e8 100644 --- a/include/config_cmd_all.h +++ b/include/config_cmd_all.h @@ -45,7 +45,7 @@ #define CONFIG_CMD_READ /* Read data from partition */ #define CONFIG_CMD_SANDBOX /* sb command to access sandbox features */ #define CONFIG_CMD_SAVES /* save S record dump */ -#define CONFIG_CMD_SCSI /* SCSI Support */ +#define CONFIG_SCSI /* SCSI Support */ #define CONFIG_CMD_SDRAM /* SDRAM DIMM SPD info printout */ #define CONFIG_CMD_TERMINAL /* built-in Serial Terminal */ #define CONFIG_CMD_UBI /* UBI Support */ diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index 7f673448c9..5a8d7f2708 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -165,7 +165,7 @@ BOOT_TARGET_DEVICES_references_SATA_without_CONFIG_CMD_SATA #endif -#ifdef CONFIG_CMD_SCSI +#ifdef CONFIG_SCSI #define BOOTENV_RUN_SCSI_INIT "run scsi_init; " #define BOOTENV_SET_SCSI_NEED_INIT "setenv scsi_need_init; " #define BOOTENV_SHARED_SCSI \ @@ -185,9 +185,9 @@ #define BOOTENV_SET_SCSI_NEED_INIT #define BOOTENV_SHARED_SCSI #define BOOTENV_DEV_SCSI \ - BOOT_TARGET_DEVICES_references_SCSI_without_CONFIG_CMD_SCSI + BOOT_TARGET_DEVICES_references_SCSI_without_CONFIG_SCSI #define BOOTENV_DEV_NAME_SCSI \ - BOOT_TARGET_DEVICES_references_SCSI_without_CONFIG_CMD_SCSI + BOOT_TARGET_DEVICES_references_SCSI_without_CONFIG_SCSI #endif #ifdef CONFIG_CMD_IDE diff --git a/include/config_fallbacks.h b/include/config_fallbacks.h index 2666191866..2ad54b7bf6 100644 --- a/include/config_fallbacks.h +++ b/include/config_fallbacks.h @@ -45,7 +45,7 @@ /* Rather than repeat this expression each time, add a define for it */ #if defined(CONFIG_CMD_IDE) || \ defined(CONFIG_CMD_SATA) || \ - defined(CONFIG_CMD_SCSI) || \ + defined(CONFIG_SCSI) || \ defined(CONFIG_CMD_USB) || \ defined(CONFIG_CMD_PART) || \ defined(CONFIG_CMD_GPT) || \ diff --git a/include/configs/MPC8544DS.h b/include/configs/MPC8544DS.h index 26d92daff1..f3036c1dc2 100644 --- a/include/configs/MPC8544DS.h +++ b/include/configs/MPC8544DS.h @@ -373,7 +373,7 @@ extern unsigned long get_board_sys_clk(unsigned long dummy); #if defined(CONFIG_PCI) #define CONFIG_CMD_PCI - #define CONFIG_CMD_SCSI + #define CONFIG_SCSI #endif /* diff --git a/include/configs/MPC8572DS.h b/include/configs/MPC8572DS.h index 8c4e5e21ca..bb7f38e34a 100644 --- a/include/configs/MPC8572DS.h +++ b/include/configs/MPC8572DS.h @@ -576,7 +576,7 @@ #if defined(CONFIG_PCI) #define CONFIG_CMD_PCI -#define CONFIG_CMD_SCSI +#define CONFIG_SCSI #endif /* diff --git a/include/configs/MPC8610HPCD.h b/include/configs/MPC8610HPCD.h index e7f01d00d1..f6d45a9e40 100644 --- a/include/configs/MPC8610HPCD.h +++ b/include/configs/MPC8610HPCD.h @@ -449,7 +449,7 @@ #if defined(CONFIG_PCI) #define CONFIG_CMD_PCI -#define CONFIG_CMD_SCSI +#define CONFIG_SCSI #endif #define CONFIG_WATCHDOG /* watchdog enabled */ diff --git a/include/configs/MPC8641HPCN.h b/include/configs/MPC8641HPCN.h index 5e23007d8d..9b2623c726 100644 --- a/include/configs/MPC8641HPCN.h +++ b/include/configs/MPC8641HPCN.h @@ -610,7 +610,7 @@ extern unsigned long get_board_sys_clk(unsigned long dummy); #if defined(CONFIG_PCI) #define CONFIG_CMD_PCI - #define CONFIG_CMD_SCSI + #define CONFIG_SCSI #endif #undef CONFIG_WATCHDOG /* watchdog disabled */ diff --git a/include/configs/PIP405.h b/include/configs/PIP405.h index 4bd06a45bf..4506d86eee 100644 --- a/include/configs/PIP405.h +++ b/include/configs/PIP405.h @@ -43,7 +43,7 @@ #define CONFIG_CMD_EEPROM #define CONFIG_CMD_REGINFO #define CONFIG_CMD_FDC -#define CONFIG_CMD_SCSI +#define CONFIG_SCSI #define CONFIG_CMD_DATE #define CONFIG_CMD_SDRAM #define CONFIG_CMD_SAVES diff --git a/include/configs/am57xx_evm.h b/include/configs/am57xx_evm.h index 32d7d4d0bd..d53b0fdd89 100644 --- a/include/configs/am57xx_evm.h +++ b/include/configs/am57xx_evm.h @@ -75,7 +75,7 @@ /* SATA */ #define CONFIG_BOARD_LATE_INIT -#define CONFIG_CMD_SCSI +#define CONFIG_SCSI #define CONFIG_LIBATA #define CONFIG_SCSI_AHCI #define CONFIG_SCSI_AHCI_PLAT diff --git a/include/configs/cm_t54.h b/include/configs/cm_t54.h index 9b13aa6b5a..ac6103c066 100644 --- a/include/configs/cm_t54.h +++ b/include/configs/cm_t54.h @@ -60,7 +60,7 @@ #define CONFIG_SPL_SATA_BOOT_DEVICE 0 #define CONFIG_SYS_SATA_FAT_BOOT_PARTITION 1 -#define CONFIG_CMD_SCSI +#define CONFIG_SCSI #define CONFIG_LIBATA #define CONFIG_SCSI_AHCI #define CONFIG_SCSI_AHCI_PLAT diff --git a/include/configs/db-88f6820-gp.h b/include/configs/db-88f6820-gp.h index d84dde39c1..3539a62790 100644 --- a/include/configs/db-88f6820-gp.h +++ b/include/configs/db-88f6820-gp.h @@ -27,7 +27,7 @@ #define CONFIG_SYS_NO_FLASH /* Declare no flash (NOR/SPI) */ #define CONFIG_CMD_ENV #define CONFIG_CMD_PCI -#define CONFIG_CMD_SCSI +#define CONFIG_SCSI /* I2C */ #define CONFIG_SYS_I2C diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h index 79b6c09951..8a0cd66cd0 100644 --- a/include/configs/dra7xx_evm.h +++ b/include/configs/dra7xx_evm.h @@ -230,7 +230,7 @@ /* SATA */ #define CONFIG_BOARD_LATE_INIT -#define CONFIG_CMD_SCSI +#define CONFIG_SCSI #define CONFIG_LIBATA #define CONFIG_SCSI_AHCI #define CONFIG_SCSI_AHCI_PLAT diff --git a/include/configs/efi-x86.h b/include/configs/efi-x86.h index 6dd0b32dae..95e46c558d 100644 --- a/include/configs/efi-x86.h +++ b/include/configs/efi-x86.h @@ -18,7 +18,7 @@ #undef CONFIG_VIDEO #undef CONFIG_CFB_CONSOLE #undef CONFIG_SCSI_AHCI -#undef CONFIG_CMD_SCSI +#undef CONFIG_SCSI #undef CONFIG_INTEL_ICH6_GPIO #undef CONFIG_USB_EHCI_PCI diff --git a/include/configs/galileo.h b/include/configs/galileo.h index 2f1f6d4455..40f7fba833 100644 --- a/include/configs/galileo.h +++ b/include/configs/galileo.h @@ -29,7 +29,7 @@ /* SATA is not supported in Quark SoC */ #undef CONFIG_SCSI_AHCI -#undef CONFIG_CMD_SCSI +#undef CONFIG_SCSI /* Video is not supported in Quark SoC */ #undef CONFIG_VIDEO diff --git a/include/configs/highbank.h b/include/configs/highbank.h index 3bce12bbb8..5cefddc2e0 100644 --- a/include/configs/highbank.h +++ b/include/configs/highbank.h @@ -51,7 +51,7 @@ /* * Command line configuration. */ -#define CONFIG_CMD_SCSI +#define CONFIG_SCSI #define CONFIG_BOOT_RETRY_TIME -1 #define CONFIG_RESET_TO_RETRY diff --git a/include/configs/ls1043aqds.h b/include/configs/ls1043aqds.h index d71a229c61..af1f73dbaa 100644 --- a/include/configs/ls1043aqds.h +++ b/include/configs/ls1043aqds.h @@ -108,7 +108,7 @@ unsigned long get_board_ddr_clk(void); #define CONFIG_LIBATA #define CONFIG_SCSI_AHCI #define CONFIG_SCSI_AHCI_PLAT -#define CONFIG_CMD_SCSI +#define CONFIG_SCSI #define CONFIG_DOS_PARTITION #define CONFIG_BOARD_LATE_INIT diff --git a/include/configs/ls2080aqds.h b/include/configs/ls2080aqds.h index 2d7567f394..f8c9e51ae7 100644 --- a/include/configs/ls2080aqds.h +++ b/include/configs/ls2080aqds.h @@ -44,7 +44,7 @@ unsigned long get_board_ddr_clk(void); #define CONFIG_LIBATA #define CONFIG_SCSI_AHCI #define CONFIG_SCSI_AHCI_PLAT -#define CONFIG_CMD_SCSI +#define CONFIG_SCSI #define CONFIG_DOS_PARTITION #define CONFIG_BOARD_LATE_INIT diff --git a/include/configs/ls2080ardb.h b/include/configs/ls2080ardb.h index 5bec5099af..4577919ca1 100644 --- a/include/configs/ls2080ardb.h +++ b/include/configs/ls2080ardb.h @@ -62,7 +62,7 @@ unsigned long get_board_sys_clk(void); #define CONFIG_LIBATA #define CONFIG_SCSI_AHCI #define CONFIG_SCSI_AHCI_PLAT -#define CONFIG_CMD_SCSI +#define CONFIG_SCSI #define CONFIG_DOS_PARTITION #define CONFIG_BOARD_LATE_INIT diff --git a/include/configs/omap5_uevm.h b/include/configs/omap5_uevm.h index 86cefa3b8f..4ddc492112 100644 --- a/include/configs/omap5_uevm.h +++ b/include/configs/omap5_uevm.h @@ -115,7 +115,7 @@ /* Max time to hold reset on this board, see doc/README.omap-reset-time */ #define CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC 16296 -#define CONFIG_CMD_SCSI +#define CONFIG_SCSI #define CONFIG_LIBATA #define CONFIG_SCSI_AHCI #define CONFIG_SCSI_AHCI_PLAT diff --git a/include/configs/qemu-x86.h b/include/configs/qemu-x86.h index b0d2ffe5b4..476d37d4bc 100644 --- a/include/configs/qemu-x86.h +++ b/include/configs/qemu-x86.h @@ -43,7 +43,7 @@ #define CONFIG_ATAPI #undef CONFIG_SCSI_AHCI -#undef CONFIG_CMD_SCSI +#undef CONFIG_SCSI #else #define CONFIG_SCSI_DEV_LIST \ {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_AHCI} diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index 2406115e3e..ac2d93114b 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -125,7 +125,7 @@ #define CONFIG_SYS_SCSI_MAX_LUN 1 #define CONFIG_SYS_SCSI_MAX_DEVICE (CONFIG_SYS_SCSI_MAX_SCSI_ID * \ CONFIG_SYS_SCSI_MAX_LUN) -#define CONFIG_CMD_SCSI +#define CONFIG_SCSI #endif #define CONFIG_SETUP_MEMORY_TAGS diff --git a/include/configs/x86-common.h b/include/configs/x86-common.h index a2822e0114..b79f47baf3 100644 --- a/include/configs/x86-common.h +++ b/include/configs/x86-common.h @@ -100,7 +100,7 @@ #define CONFIG_CMD_IRQ #define CONFIG_CMD_PCI #define CONFIG_CMD_GETTIME -#define CONFIG_CMD_SCSI +#define CONFIG_SCSI #define CONFIG_CMD_ZBOOT diff --git a/include/configs/xilinx_zynqmp.h b/include/configs/xilinx_zynqmp.h index 060bca985e..6b8e3ea865 100644 --- a/include/configs/xilinx_zynqmp.h +++ b/include/configs/xilinx_zynqmp.h @@ -201,7 +201,7 @@ #define CONFIG_SYS_SCSI_MAX_LUN 1 #define CONFIG_SYS_SCSI_MAX_DEVICE (CONFIG_SYS_SCSI_MAX_SCSI_ID * \ CONFIG_SYS_SCSI_MAX_LUN) -#define CONFIG_CMD_SCSI +#define CONFIG_SCSI #endif #define CONFIG_SYS_BOOTM_LEN (60 * 1024 * 1024) -- cgit v1.2.1 From 6eef6eac1fc137c97bf1993304ed83b8e483c80a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:03 -0600 Subject: dm: blk: Add a legacy block interface There is quite a bit of duplicated common code related to block devices in the IDE and SCSI implementations. Create some helper functions that can be used to reduce the duplication. These rely on a linker list of interface-type drivers Signed-off-by: Simon Glass --- include/blk.h | 195 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) (limited to 'include') diff --git a/include/blk.h b/include/blk.h index f62467105a..a562c10a29 100644 --- a/include/blk.h +++ b/include/blk.h @@ -340,6 +340,201 @@ static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start, blkcache_invalidate(block_dev->if_type, block_dev->devnum); return block_dev->block_erase(block_dev, start, blkcnt); } + +/** + * struct blk_driver - Driver for block interface types + * + * This provides access to the block devices for each interface type. One + * driver should be provided using U_BOOT_LEGACY_BLK() for each interface + * type that is to be supported. + * + * @if_typename: Interface type name + * @if_type: Interface type + * @max_devs: Maximum number of devices supported + * @desc: Pointer to list of devices for this interface type, + * or NULL to use @get_dev() instead + */ +struct blk_driver { + const char *if_typename; + enum if_type if_type; + int max_devs; + struct blk_desc *desc; + /** + * get_dev() - get a pointer to a block device given its number + * + * Each interface allocates its own devices and typically + * struct blk_desc is contained with the interface's data structure. + * There is no global numbering for block devices. This method allows + * the device for an interface type to be obtained when @desc is NULL. + * + * @devnum: Device number (0 for first device on that interface, + * 1 for second, etc. + * @descp: Returns pointer to the block device on success + * @return 0 if OK, -ve on error + */ + int (*get_dev)(int devnum, struct blk_desc **descp); + + /** + * select_hwpart() - Select a hardware partition + * + * Some devices (e.g. MMC) can support partitioning at the hardware + * level. This is quite separate from the normal idea of + * software-based partitions. MMC hardware partitions must be + * explicitly selected. Once selected only the region of the device + * covered by that partition is accessible. + * + * The MMC standard provides for two boot partitions (numbered 1 and 2), + * rpmb (3), and up to 4 addition general-purpose partitions (4-7). + * Partition 0 is the main user-data partition. + * + * @desc: Block device descriptor + * @hwpart: Hardware partition number to select. 0 means the main + * user-data partition, 1 is the first partition, 2 is + * the second, etc. + * @return 0 if OK, other value for an error + */ + int (*select_hwpart)(struct blk_desc *desc, int hwpart); +}; + +/* + * Declare a new U-Boot legacy block driver. New drivers should use driver + * model (UCLASS_BLK). + */ +#define U_BOOT_LEGACY_BLK(__name) \ + ll_entry_declare(struct blk_driver, __name, blk_driver) + +struct blk_driver *blk_driver_lookup_type(int if_type); + #endif /* !CONFIG_BLK */ +/** + * blk_get_devnum_by_typename() - Get a block device by type and number + * + * This looks through the available block devices of the given type, returning + * the one with the given @devnum. + * + * @if_type: Block device type + * @devnum: Device number + * @return point to block device descriptor, or NULL if not found + */ +struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum); + +/** + * blk_get_devnum_by_type() - Get a block device by type name, and number + * + * This looks up the block device type based on @if_typename, then calls + * blk_get_devnum_by_type(). + * + * @if_typename: Block device type name + * @devnum: Device number + * @return point to block device descriptor, or NULL if not found + */ +struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, + int devnum); + +/** + * blk_dselect_hwpart() - select a hardware partition + * + * This selects a hardware partition (such as is supported by MMC). The block + * device size may change as this effectively points the block device to a + * partition at the hardware level. See the select_hwpart() method above. + * + * @desc: Block device descriptor for the device to select + * @hwpart: Partition number to select + * @return 0 if OK, -ve on error + */ +int blk_dselect_hwpart(struct blk_desc *desc, int hwpart); + +/** + * blk_list_part() - list the partitions for block devices of a given type + * + * This looks up the partition type for each block device of type @if_type, + * then displays a list of partitions. + * + * @if_type: Block device type + * @return 0 if OK, -ENODEV if there is none of that type + */ +int blk_list_part(enum if_type if_type); + +/** + * blk_list_devices() - list the block devices of a given type + * + * This lists each block device of the type @if_type, showing the capacity + * as well as type-specific information. + * + * @if_type: Block device type + */ +void blk_list_devices(enum if_type if_type); + +/** + * blk_show_device() - show information about a given block device + * + * This shows the block device capacity as well as type-specific information. + * + * @if_type: Block device type + * @devnum: Device number + * @return 0 if OK, -ENODEV for invalid device number + */ +int blk_show_device(enum if_type if_type, int devnum); + +/** + * blk_print_device_num() - show information about a given block device + * + * This is similar to blk_show_device() but returns an error if the block + * device type is unknown. + * + * @if_type: Block device type + * @devnum: Device number + * @return 0 if OK, -ENODEV for invalid device number, -ENOENT if the block + * device is not connected + */ +int blk_print_device_num(enum if_type if_type, int devnum); + +/** + * blk_print_part_devnum() - print the partition information for a device + * + * @if_type: Block device type + * @devnum: Device number + * @return 0 if OK, -ENOENT if the block device is not connected, -ENOSYS if + * the interface type is not supported, other -ve on other error + */ +int blk_print_part_devnum(enum if_type if_type, int devnum); + +/** + * blk_read_devnum() - read blocks from a device + * + * @if_type: Block device type + * @devnum: Device number + * @blkcnt: Number of blocks to read + * @buffer: Address to write data to + * @return number of blocks read, or -ve error number on error + */ +ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start, + lbaint_t blkcnt, void *buffer); + +/** + * blk_write_devnum() - write blocks to a device + * + * @if_type: Block device type + * @devnum: Device number + * @blkcnt: Number of blocks to write + * @buffer: Address to read data from + * @return number of blocks written, or -ve error number on error + */ +ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start, + lbaint_t blkcnt, const void *buffer); + +/** + * blk_select_hwpart_devnum() - select a hardware partition + * + * This is similar to blk_dselect_hwpart() but it looks up the interface and + * device number. + * + * @if_type: Block device type + * @devnum: Device number + * @hwpart: Partition number to select + * @return 0 if OK, -ve on error + */ +int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart); + #endif -- cgit v1.2.1 From 3ef85e377201c1ebe84e74bfb785c95ccbc37b13 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:04 -0600 Subject: dm: systemace: Add a legacy block interface Add a legacy block interface for systemace. Signed-off-by: Simon Glass --- include/blk.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/blk.h b/include/blk.h index a562c10a29..2caac9c96b 100644 --- a/include/blk.h +++ b/include/blk.h @@ -30,6 +30,7 @@ enum if_type { IF_TYPE_SD, IF_TYPE_SATA, IF_TYPE_HOST, + IF_TYPE_SYSTEMACE, IF_TYPE_COUNT, /* Number of interface types */ }; -- cgit v1.2.1 From 57ebf67bad82da0b3ade1728fb39a64d1c29822f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:13 -0600 Subject: dm: usb: Drop the get_dev() function This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass --- include/part.h | 2 -- include/usb.h | 1 - 2 files changed, 3 deletions(-) (limited to 'include') diff --git a/include/part.h b/include/part.h index e3811c68de..f206910970 100644 --- a/include/part.h +++ b/include/part.h @@ -76,7 +76,6 @@ struct blk_desc *blk_get_dev(const char *ifname, int dev); struct blk_desc *ide_get_dev(int dev); struct blk_desc *sata_get_dev(int dev); struct blk_desc *scsi_get_dev(int dev); -struct blk_desc *usb_stor_get_dev(int dev); struct blk_desc *mmc_get_dev(int dev); /** @@ -178,7 +177,6 @@ static inline struct blk_desc *blk_get_dev(const char *ifname, int dev) static inline struct blk_desc *ide_get_dev(int dev) { return NULL; } static inline struct blk_desc *sata_get_dev(int dev) { return NULL; } static inline struct blk_desc *scsi_get_dev(int dev) { return NULL; } -static inline struct blk_desc *usb_stor_get_dev(int dev) { return NULL; } static inline struct blk_desc *mmc_get_dev(int dev) { return NULL; } static inline int mmc_select_hwpart(int dev_num, int hwpart) { return -1; } static inline struct blk_desc *systemace_get_dev(int dev) { return NULL; } diff --git a/include/usb.h b/include/usb.h index 5adad36838..02a0ccdd77 100644 --- a/include/usb.h +++ b/include/usb.h @@ -228,7 +228,6 @@ int board_usb_cleanup(int index, enum usb_init_type init); #ifdef CONFIG_USB_STORAGE #define USB_MAX_STOR_DEV 7 -struct blk_desc *usb_stor_get_dev(int index); int usb_stor_scan(int mode); int usb_stor_info(void); -- cgit v1.2.1 From 74001a2570ccbc120366e66dd40e8c66e3a6820c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:14 -0600 Subject: dm: ide: Drop the get_dev() function This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass --- include/part.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/part.h b/include/part.h index f206910970..f09b794d61 100644 --- a/include/part.h +++ b/include/part.h @@ -73,7 +73,6 @@ typedef struct disk_partition { * error occurred. */ struct blk_desc *blk_get_dev(const char *ifname, int dev); -struct blk_desc *ide_get_dev(int dev); struct blk_desc *sata_get_dev(int dev); struct blk_desc *scsi_get_dev(int dev); struct blk_desc *mmc_get_dev(int dev); @@ -174,7 +173,6 @@ extern const struct block_drvr block_drvr[]; #else static inline struct blk_desc *blk_get_dev(const char *ifname, int dev) { return NULL; } -static inline struct blk_desc *ide_get_dev(int dev) { return NULL; } static inline struct blk_desc *sata_get_dev(int dev) { return NULL; } static inline struct blk_desc *scsi_get_dev(int dev) { return NULL; } static inline struct blk_desc *mmc_get_dev(int dev) { return NULL; } -- cgit v1.2.1 From 3c457f4d2e47cc91385abe15d3c825d0ce1a2b6f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:15 -0600 Subject: dm: mmc: Drop the get_dev() function This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass --- include/part.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/part.h b/include/part.h index f09b794d61..1535930b90 100644 --- a/include/part.h +++ b/include/part.h @@ -75,7 +75,6 @@ typedef struct disk_partition { struct blk_desc *blk_get_dev(const char *ifname, int dev); struct blk_desc *sata_get_dev(int dev); struct blk_desc *scsi_get_dev(int dev); -struct blk_desc *mmc_get_dev(int dev); /** * mmc_select_hwpart() - Select the MMC hardware partiion on an MMC device @@ -175,7 +174,6 @@ static inline struct blk_desc *blk_get_dev(const char *ifname, int dev) { return NULL; } static inline struct blk_desc *sata_get_dev(int dev) { return NULL; } static inline struct blk_desc *scsi_get_dev(int dev) { return NULL; } -static inline struct blk_desc *mmc_get_dev(int dev) { return NULL; } static inline int mmc_select_hwpart(int dev_num, int hwpart) { return -1; } static inline struct blk_desc *systemace_get_dev(int dev) { return NULL; } static inline struct blk_desc *mg_disk_get_dev(int dev) { return NULL; } -- cgit v1.2.1 From edd82ab3547e27b4c1ab1ee7e620f982db9126ad Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:16 -0600 Subject: dm: scsi: Drop the get_dev() function This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass --- include/part.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/part.h b/include/part.h index 1535930b90..ecb049f9a8 100644 --- a/include/part.h +++ b/include/part.h @@ -74,7 +74,6 @@ typedef struct disk_partition { */ struct blk_desc *blk_get_dev(const char *ifname, int dev); struct blk_desc *sata_get_dev(int dev); -struct blk_desc *scsi_get_dev(int dev); /** * mmc_select_hwpart() - Select the MMC hardware partiion on an MMC device @@ -173,7 +172,6 @@ extern const struct block_drvr block_drvr[]; static inline struct blk_desc *blk_get_dev(const char *ifname, int dev) { return NULL; } static inline struct blk_desc *sata_get_dev(int dev) { return NULL; } -static inline struct blk_desc *scsi_get_dev(int dev) { return NULL; } static inline int mmc_select_hwpart(int dev_num, int hwpart) { return -1; } static inline struct blk_desc *systemace_get_dev(int dev) { return NULL; } static inline struct blk_desc *mg_disk_get_dev(int dev) { return NULL; } -- cgit v1.2.1 From 4e7189d4d8c2ab46c4c580ae300c14d1a9c20b11 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:17 -0600 Subject: dm: sata: Drop the get_dev() function This function is implemented by the legacy block functions now. Drop it. We cannot yet make sata_dev_desc[] private to common/sata.c as it is used by the SATA drivers. This will require the SATA interface to be reworked. Signed-off-by: Simon Glass --- include/part.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/part.h b/include/part.h index ecb049f9a8..74bb5d6f96 100644 --- a/include/part.h +++ b/include/part.h @@ -73,7 +73,6 @@ typedef struct disk_partition { * error occurred. */ struct blk_desc *blk_get_dev(const char *ifname, int dev); -struct blk_desc *sata_get_dev(int dev); /** * mmc_select_hwpart() - Select the MMC hardware partiion on an MMC device @@ -171,7 +170,6 @@ extern const struct block_drvr block_drvr[]; #else static inline struct blk_desc *blk_get_dev(const char *ifname, int dev) { return NULL; } -static inline struct blk_desc *sata_get_dev(int dev) { return NULL; } static inline int mmc_select_hwpart(int dev_num, int hwpart) { return -1; } static inline struct blk_desc *systemace_get_dev(int dev) { return NULL; } static inline struct blk_desc *mg_disk_get_dev(int dev) { return NULL; } -- cgit v1.2.1 From f6d000edbeaddfe8e5b5e3be9fd3f6c76fdff6d2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:18 -0600 Subject: dm: systemace: Drop the get_dev() function This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass --- include/part.h | 2 -- include/systemace.h | 7 ------- 2 files changed, 9 deletions(-) (limited to 'include') diff --git a/include/part.h b/include/part.h index 74bb5d6f96..3b59139f14 100644 --- a/include/part.h +++ b/include/part.h @@ -91,7 +91,6 @@ struct blk_desc *blk_get_dev(const char *ifname, int dev); * @return 0 if OK, other value for an error */ int mmc_select_hwpart(int dev_num, int hwpart); -struct blk_desc *systemace_get_dev(int dev); struct blk_desc *mg_disk_get_dev(int dev); struct blk_desc *host_get_dev(int dev); int host_get_dev_err(int dev, struct blk_desc **blk_devp); @@ -171,7 +170,6 @@ extern const struct block_drvr block_drvr[]; static inline struct blk_desc *blk_get_dev(const char *ifname, int dev) { return NULL; } static inline int mmc_select_hwpart(int dev_num, int hwpart) { return -1; } -static inline struct blk_desc *systemace_get_dev(int dev) { return NULL; } static inline struct blk_desc *mg_disk_get_dev(int dev) { return NULL; } static inline struct blk_desc *host_get_dev(int dev) { return NULL; } diff --git a/include/systemace.h b/include/systemace.h index 3b6ec7da4b..bccb2a2ddf 100644 --- a/include/systemace.h +++ b/include/systemace.h @@ -7,11 +7,4 @@ * SPDX-License-Identifier: GPL-2.0+ */ -#ifdef CONFIG_SYSTEMACE - -# include - -struct blk_desc *systemace_get_dev(int dev); - -#endif /* CONFIG_SYSTEMACE */ #endif /* __SYSTEMACE_H */ -- cgit v1.2.1 From ae9ffccdac12b21ad55401d8554b5d835c9c8f22 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:19 -0600 Subject: dm: blk: Drop the systemace.h header This has nothing of consequence. Remove it and its only inclusion site. Signed-off-by: Simon Glass --- include/systemace.h | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 include/systemace.h (limited to 'include') diff --git a/include/systemace.h b/include/systemace.h deleted file mode 100644 index bccb2a2ddf..0000000000 --- a/include/systemace.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __SYSTEMACE_H -#define __SYSTEMACE_H -/* - * Copyright (c) 2004 Picture Elements, Inc. - * Stephen Williams (steve@picturel.com) - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#endif /* __SYSTEMACE_H */ -- cgit v1.2.1 From f1d86fd3b15c2af53964d948c72c9a0a63511927 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:20 -0600 Subject: dm: sandbox: Drop the host_get_dev() function This function is implemented by the legacy block functions now. Drop it. Signed-off-by: Simon Glass --- include/part.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/part.h b/include/part.h index 3b59139f14..47f5bafd63 100644 --- a/include/part.h +++ b/include/part.h @@ -92,7 +92,6 @@ struct blk_desc *blk_get_dev(const char *ifname, int dev); */ int mmc_select_hwpart(int dev_num, int hwpart); struct blk_desc *mg_disk_get_dev(int dev); -struct blk_desc *host_get_dev(int dev); int host_get_dev_err(int dev, struct blk_desc **blk_devp); /* disk/part.c */ @@ -171,7 +170,6 @@ static inline struct blk_desc *blk_get_dev(const char *ifname, int dev) { return NULL; } static inline int mmc_select_hwpart(int dev_num, int hwpart) { return -1; } static inline struct blk_desc *mg_disk_get_dev(int dev) { return NULL; } -static inline struct blk_desc *host_get_dev(int dev) { return NULL; } static inline int part_get_info(struct blk_desc *dev_desc, int part, disk_partition_t *info) { return -1; } -- cgit v1.2.1 From 38bd29beaaf51f92d986ef63e5539f0bd0d371d8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:21 -0600 Subject: dm: part: Drop the get_dev() method This is now handled by the legacy block driver. The get_dev() method is no-longer used. Drop it. Signed-off-by: Simon Glass --- include/part.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/part.h b/include/part.h index 47f5bafd63..bc9dc64912 100644 --- a/include/part.h +++ b/include/part.h @@ -12,7 +12,6 @@ struct block_drvr { char *name; - struct blk_desc* (*get_dev)(int dev); int (*select_hwpart)(int dev_num, int hwpart); }; -- cgit v1.2.1 From 145df842b443a2f2323a11f6e61223e3767dc55c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:22 -0600 Subject: dm: ide: Add support for driver-model block devices Add driver-model block-device support to the IDE implementation. Signed-off-by: Simon Glass --- include/ide.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/ide.h b/include/ide.h index a4e65cf2a9..9b0a4a96fa 100644 --- a/include/ide.h +++ b/include/ide.h @@ -34,10 +34,18 @@ void ide_led(uchar led, uchar status); void ide_init(void); struct blk_desc; +struct udevice; +#ifdef CONFIG_BLK +ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, + void *buffer); +ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, + const void *buffer); +#else ulong ide_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer); ulong ide_write(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer); +#endif #ifdef CONFIG_IDE_PREINIT int ide_preinit(void); -- cgit v1.2.1 From 74c6dc14447e8386dd0799611d316eae5aad1e10 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:23 -0600 Subject: dm: sandbox: Enable IDE Enable building the IDE code for sandbox. This is for build coverage only. It does not currently work. Signed-off-by: Simon Glass --- include/configs/sandbox.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 9790a14b02..a2926fd733 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -192,4 +192,14 @@ #define CONFIG_CMD_LZMADEC #define CONFIG_CMD_DATE +#define CONFIG_CMD_IDE +#define CONFIG_SYS_IDE_MAXBUS 1 +#define CONFIG_SYS_ATA_IDE0_OFFSET 0 +#define CONFIG_SYS_IDE_MAXDEVICE 2 +#define CONFIG_SYS_ATA_BASE_ADDR 0x100 +#define CONFIG_SYS_ATA_DATA_OFFSET 0 +#define CONFIG_SYS_ATA_REG_OFFSET 1 +#define CONFIG_SYS_ATA_ALT_OFFSET 2 +#define CONFIG_SYS_ATA_STRIDE 4 + #endif -- cgit v1.2.1 From e8c0a2509c6ec62a5c58a39c338cc1127bc83e1a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:25 -0600 Subject: dm: sandbox: Enable SCSI Enable building the SCSI code for sandbox. This increases build coverage for sandbox. Signed-off-by: Simon Glass --- include/configs/sandbox.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index a2926fd733..affc9cc390 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -202,4 +202,10 @@ #define CONFIG_SYS_ATA_ALT_OFFSET 2 #define CONFIG_SYS_ATA_STRIDE 4 +#define CONFIG_SCSI +#define CONFIG_SCSI_AHCI_PLAT +#define CONFIG_SYS_SCSI_MAX_DEVICE 2 +#define CONFIG_SYS_SCSI_MAX_SCSI_ID 8 +#define CONFIG_SYS_SCSI_MAX_LUN 4 + #endif -- cgit v1.2.1 From 199a1201ab901413a80c64a9eee72f82977ba8d3 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:27 -0600 Subject: dm: sandbox: Enable SATA Enable building the SATA code for sandbox. This increases build coverage for sandbox. Signed-off-by: Simon Glass --- include/configs/sandbox.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index affc9cc390..71276119e4 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -208,4 +208,7 @@ #define CONFIG_SYS_SCSI_MAX_SCSI_ID 8 #define CONFIG_SYS_SCSI_MAX_LUN 4 +#define CONFIG_CMD_SATA +#define CONFIG_SYS_SATA_MAX_DEVICE 2 + #endif -- cgit v1.2.1 From 52138fd4072b64448855eac4c2c9815b46f5b43c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:28 -0600 Subject: dm: blk: Allow blk_create_device() to allocate the device number Allow a devnum parameter of -1 to indicate that the device number should be alocated automatically. The next highest available device number for that interface type is used. Signed-off-by: Simon Glass --- include/blk.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/blk.h b/include/blk.h index 2caac9c96b..547c3b48dc 100644 --- a/include/blk.h +++ b/include/blk.h @@ -270,7 +270,8 @@ int blk_next_device(struct udevice **devp); * @drv_name: Driver name to use for the block device * @name: Name for the device * @if_type: Interface type (enum if_type_t) - * @devnum: Device number, specific to the interface type + * @devnum: Device number, specific to the interface type, or -1 to + * allocate the next available number * @blksz: Block size of the device in bytes (typically 512) * @size: Total size of the device in bytes * @devp: the new device (which has not been probed) @@ -299,6 +300,18 @@ int blk_prepare_device(struct udevice *dev); */ int blk_unbind_all(int if_type); +/** + * blk_find_max_devnum() - find the maximum device number for an interface type + * + * Finds the last allocated device number for an interface type @if_type. The + * next number is safe to use for a newly allocated device. + * + * @if_type: Interface type to scan + * @return maximum device number found, or -ENODEV if none, or other -ve on + * error + */ +int blk_find_max_devnum(enum if_type if_type); + #else #include /* -- cgit v1.2.1 From 9107c973d32c72a6f7ac909fc4a6884a42e4e607 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:29 -0600 Subject: dm: blk: Add a easier way to create a named block device Add a function that automatically builds the device name given the parent and a supplied string. Most callers will want to do this, so putting this functionality in one place makes more sense. Signed-off-by: Simon Glass --- include/blk.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include') diff --git a/include/blk.h b/include/blk.h index 547c3b48dc..82b2c1a706 100644 --- a/include/blk.h +++ b/include/blk.h @@ -280,6 +280,23 @@ int blk_create_device(struct udevice *parent, const char *drv_name, const char *name, int if_type, int devnum, int blksz, lbaint_t size, struct udevice **devp); +/** + * blk_create_devicef() - Create a new named block device + * + * @parent: Parent of the new device + * @drv_name: Driver name to use for the block device + * @name: Name for the device (parent name is prepended) + * @if_type: Interface type (enum if_type_t) + * @devnum: Device number, specific to the interface type, or -1 to + * allocate the next available number + * @blksz: Block size of the device in bytes (typically 512) + * @size: Total size of the device in bytes + * @devp: the new device (which has not been probed) + */ +int blk_create_devicef(struct udevice *parent, const char *drv_name, + const char *name, int if_type, int devnum, int blksz, + lbaint_t size, struct udevice **devp); + /** * blk_prepare_device() - Prepare a block device for use * -- cgit v1.2.1 From cd995a8aa0127128132bb50f485c53bfb9593312 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:32 -0600 Subject: dm: sandbox: Enable systemace Enable building the systemace code for sandbox. This increases build coverage for sandbox. Signed-off-by: Simon Glass --- include/configs/sandbox.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 71276119e4..c51d4cd737 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -211,4 +211,8 @@ #define CONFIG_CMD_SATA #define CONFIG_SYS_SATA_MAX_DEVICE 2 +#define CONFIG_SYSTEMACE +#define CONFIG_SYS_SYSTEMACE_WIDTH 16 +#define CONFIG_SYS_SYSTEMACE_BASE 0 + #endif -- cgit v1.2.1 From a2040facd23b88082b9b40f0aa9bcfd495eab88e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 13:52:23 -0600 Subject: dm: core: Allow device names to be freed automatically Some devices have a name that is stored in allocated memory. At present there is no mechanism to free this memory when the device is unbound. Add a device flag to track whether a name is allocated and a function to add the flag. Free the memory when the device is unbound. Signed-off-by: Simon Glass --- include/dm/device.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 8970fc015c..e9a8ec72c9 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -41,6 +41,9 @@ struct driver_info; /* Device is bound */ #define DM_FLAG_BOUND (1 << 6) +/* Device name is allocated and should be freed on unbind() */ +#define DM_NAME_ALLOCED (1 << 7) + /** * struct udevice - An instance of a driver * @@ -523,6 +526,9 @@ bool device_is_last_sibling(struct udevice *dev); * this is unnecessary but for probed devices which don't get a useful name * this function can be helpful. * + * The name is allocated and will be freed automatically when the device is + * unbound. + * * @dev: Device to update * @name: New name (this string is allocated new memory and attached to * the device) @@ -531,6 +537,16 @@ bool device_is_last_sibling(struct udevice *dev); */ int device_set_name(struct udevice *dev, const char *name); +/** + * device_set_name_alloced() - note that a device name is allocated + * + * This sets the DM_NAME_ALLOCED flag for the device, so that when it is + * unbound the name will be freed. This avoids memory leaks. + * + * @dev: Device to update + */ +void device_set_name_alloced(struct udevice *dev); + /** * device_is_on_pci_bus - Test if a device is on a PCI bus * -- cgit v1.2.1 From cb5ec33d9096f1f57c5ccc97d44ca0fb771729f5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 13:52:27 -0600 Subject: dm: mmc: Add a function to obtain the block device The MMC block device is contained within struct mmc. But with driver model this will not be the case. Add a function to obtain the block device. We can later implement this for CONFIG_BLK. Signed-off-by: Simon Glass --- include/mmc.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/mmc.h b/include/mmc.h index cdb56e7ac1..36449c34ea 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -498,4 +498,12 @@ int pci_mmc_init(const char *name, struct pci_device_id *mmc_supported); #define CONFIG_SYS_MMC_MAX_BLK_COUNT 65535 #endif +/** + * mmc_get_blk_desc() - Get the block descriptor for an MMC device + * + * @mmc: MMC device + * @return block device if found, else NULL + */ +struct blk_desc *mmc_get_blk_desc(struct mmc *mmc); + #endif /* _MMC_H_ */ -- cgit v1.2.1 From 69f45cd53b8ad8bc3afef2cf2410baf58fe75a6f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 13:52:29 -0600 Subject: dm: mmc: Use the new select_hwpart() API Avoid calling directly into the MMC code - use the new API call instead. Signed-off-by: Simon Glass --- include/mmc.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/mmc.h b/include/mmc.h index 36449c34ea..f01674d9fc 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -415,7 +415,6 @@ struct mmc *find_mmc_device(int dev_num); int mmc_set_dev(int dev_num); void print_mmc_devices(char separator); int get_mmc_num(void); -int mmc_switch_part(int dev_num, unsigned int part_num); int mmc_hwpart_config(struct mmc *mmc, const struct mmc_hwpart_conf *conf, enum mmc_hwpart_conf_mode mode); int mmc_getcd(struct mmc *mmc); -- cgit v1.2.1 From cd0fb55b640b2991c1d29122d252a360037ed903 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 13:52:30 -0600 Subject: dm: blk: Add functions to select a hardware partition The block device uclass does not currently support selecting a particular hardware partition but this is needed for MMC. Add it so that the blk API can support MMC properly. Signed-off-by: Simon Glass --- include/blk.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'include') diff --git a/include/blk.h b/include/blk.h index 82b2c1a706..3fa373e208 100644 --- a/include/blk.h +++ b/include/blk.h @@ -211,6 +211,25 @@ struct blk_ops { */ unsigned long (*erase)(struct udevice *dev, lbaint_t start, lbaint_t blkcnt); + + /** + * select_hwpart() - select a particular hardware partition + * + * Some devices (e.g. MMC) can support partitioning at the hardware + * level. This is quite separate from the normal idea of + * software-based partitions. MMC hardware partitions must be + * explicitly selected. Once selected only the region of the device + * covered by that partition is accessible. + * + * The MMC standard provides for two boot partitions (numbered 1 and 2), + * rpmb (3), and up to 4 addition general-purpose partitions (4-7). + * + * @desc: Block device to update + * @hwpart: Hardware partition number to select. 0 means the raw + * device, 1 is the first partition, 2 is the second, etc. + * @return 0 if OK, -ve on error + */ + int (*select_hwpart)(struct udevice *dev, int hwpart); }; #define blk_get_ops(dev) ((struct blk_ops *)(dev)->driver->ops) @@ -329,6 +348,17 @@ int blk_unbind_all(int if_type); */ int blk_find_max_devnum(enum if_type if_type); +/** + * blk_select_hwpart() - select a hardware partition + * + * Select a hardware partition if the device supports it (typically MMC does) + * + * @dev: Device to update + * @hwpart: Partition number to select + * @return 0 if OK, -ve on error + */ +int blk_select_hwpart(struct udevice *dev, int hwpart); + #else #include /* -- cgit v1.2.1 From b6694a33c45530e4c260c7fd6c77cc8472c9412f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 13:52:33 -0600 Subject: dm: blk: Add a comment as to why the bdev member is needed This member should be explained, since it is not obvious why it is needed. Add a comment. Signed-off-by: Simon Glass --- include/blk.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/blk.h b/include/blk.h index 3fa373e208..66a1c55cc8 100644 --- a/include/blk.h +++ b/include/blk.h @@ -63,6 +63,11 @@ struct blk_desc { char product[20+1]; /* IDE Serial no, SCSI product */ char revision[8+1]; /* firmware revision */ #ifdef CONFIG_BLK + /* + * For now we have a few functions which take struct blk_desc as a + * parameter. This field allows them to look up the associated + * device. Once these functions are removed we can drop this field. + */ struct udevice *bdev; #else unsigned long (*block_read)(struct blk_desc *block_dev, -- cgit v1.2.1 From cffe5d86cfe853ae9271d37522f8bc5795cc4c69 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 13:52:34 -0600 Subject: dm: mmc: Set up the device pointer when using the MMC uclass Update the existing drivers to set up this new pointer. This will be required by the MMC uclass. Signed-off-by: Simon Glass --- include/mmc.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/mmc.h b/include/mmc.h index f01674d9fc..6d1f05c328 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -381,6 +381,9 @@ struct mmc { char init_in_progress; /* 1 if we have done mmc_start_init() */ char preinit; /* start init as early as possible */ int ddr_mode; +#ifdef CONFIG_DM_MMC + struct udevice *dev; /* Device for this MMC controller */ +#endif }; struct mmc_hwpart_conf { -- cgit v1.2.1 From ad27dd5e13436b554f0f3cb9cd3e79634494072d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 13:52:40 -0600 Subject: dm: mmc: Add a way to bind MMC devices with driver model Binding an MMC device when CONFIG_BLK is enabled requires that a block device be bound as a child of the MMC device. Add a function to do this. The mmc_create() method will be used only when DM_BLK is disabled. Add an unbind method also. Signed-off-by: Simon Glass --- include/mmc.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'include') diff --git a/include/mmc.h b/include/mmc.h index 6d1f05c328..fb8d9b2f55 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -409,7 +409,29 @@ enum mmc_hwpart_conf_mode { int mmc_register(struct mmc *mmc); struct mmc *mmc_create(const struct mmc_config *cfg, void *priv); + +/** + * mmc_bind() - Set up a new MMC device ready for probing + * + * A child block device is bound with the IF_TYPE_MMC interface type. This + * allows the device to be used with CONFIG_BLK + * + * @dev: MMC device to set up + * @mmc: MMC struct + * @cfg: MMC configuration + * @return 0 if OK, -ve on error + */ +int mmc_bind(struct udevice *dev, struct mmc *mmc, + const struct mmc_config *cfg); void mmc_destroy(struct mmc *mmc); + +/** + * mmc_unbind() - Unbind a MMC device's child block device + * + * @dev: MMC device + * @return 0 if OK, -ve on error + */ +int mmc_unbind(struct udevice *dev); int mmc_initialize(bd_t *bis); int mmc_init(struct mmc *mmc); int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size); -- cgit v1.2.1 From 33fb211dd2706e666db4008801dc0d5903fd82f6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 13:52:41 -0600 Subject: dm: mmc: Add support for driver-model block devices Add support for enabling CONFIG_BLK with MMC. This involves changing a few functions to use struct udevice and adding a MMC block device driver. Signed-off-by: Simon Glass --- include/mmc.h | 4 ++++ include/part.h | 18 ------------------ 2 files changed, 4 insertions(+), 18 deletions(-) (limited to 'include') diff --git a/include/mmc.h b/include/mmc.h index fb8d9b2f55..a5c6573ddd 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -344,7 +344,9 @@ struct mmc_config { /* TODO struct mmc should be in mmc_private but it's hard to fix right now */ struct mmc { +#ifndef CONFIG_BLK struct list_head link; +#endif const struct mmc_config *cfg; /* provided configuration */ uint version; void *priv; @@ -376,7 +378,9 @@ struct mmc { u64 capacity_gp[4]; u64 enh_user_start; u64 enh_user_size; +#ifndef CONFIG_BLK struct blk_desc block_dev; +#endif char op_cond_pending; /* 1 if we are waiting on an op_cond command */ char init_in_progress; /* 1 if we have done mmc_start_init() */ char preinit; /* start init as early as possible */ diff --git a/include/part.h b/include/part.h index bc9dc64912..226b5be9df 100644 --- a/include/part.h +++ b/include/part.h @@ -73,23 +73,6 @@ typedef struct disk_partition { */ struct blk_desc *blk_get_dev(const char *ifname, int dev); -/** - * mmc_select_hwpart() - Select the MMC hardware partiion on an MMC device - * - * MMC devices can support partitioning at the hardware level. This is quite - * separate from the normal idea of software-based partitions. MMC hardware - * partitions must be explicitly selected. Once selected only the region of - * the device covered by that partition is accessible. - * - * The MMC standard provides for two boot partitions (numbered 1 and 2), - * rpmb (3), and up to 4 addition general-purpose partitions (4-7). - * - * @dev_num: Block device number (struct blk_desc->dev value) - * @hwpart: Hardware partition number to select. 0 means the raw device, - * 1 is the first partition, 2 is the second, etc. - * @return 0 if OK, other value for an error - */ -int mmc_select_hwpart(int dev_num, int hwpart); struct blk_desc *mg_disk_get_dev(int dev); int host_get_dev_err(int dev, struct blk_desc **blk_devp); @@ -167,7 +150,6 @@ extern const struct block_drvr block_drvr[]; #else static inline struct blk_desc *blk_get_dev(const char *ifname, int dev) { return NULL; } -static inline int mmc_select_hwpart(int dev_num, int hwpart) { return -1; } static inline struct blk_desc *mg_disk_get_dev(int dev) { return NULL; } static inline int part_get_info(struct blk_desc *dev_desc, int part, -- cgit v1.2.1 From afa2c3122db1ef5243e717b84d698353da412d92 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 13:52:43 -0600 Subject: dm: sandbox: mmc: Enable building MMC code for sandbox Enable building the MMC code for sandbox. This increases build coverage for sandbox. Signed-off-by: Simon Glass --- include/configs/sandbox.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index c51d4cd737..23a0c40ca5 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -215,4 +215,6 @@ #define CONFIG_SYS_SYSTEMACE_WIDTH 16 #define CONFIG_SYS_SYSTEMACE_BASE 0 +#define CONFIG_GENERIC_MMC + #endif -- cgit v1.2.1