aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2016-03-14 19:21:44 -0400
committerTom Rini <trini@konsulko.com>2016-03-14 19:21:44 -0400
commit88033d737d9f46e7eebda6a8f9770957eb9aae9c (patch)
tree0b7c3bc6caa5ab4b7f8e88f05ce51ace87f25890 /drivers
parent9f0f432c0aea1e70959a0c06938459d3175a36b0 (diff)
parent608e399fdef82e983db44c5cb8f5e772bba870e2 (diff)
downloadu-boot-88033d737d9f46e7eebda6a8f9770957eb9aae9c.zip
u-boot-88033d737d9f46e7eebda6a8f9770957eb9aae9c.tar.gz
u-boot-88033d737d9f46e7eebda6a8f9770957eb9aae9c.tar.bz2
Merge git://git.denx.de/u-boot-dm
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/Kconfig11
-rw-r--r--drivers/block/Makefile2
-rw-r--r--drivers/block/blk-uclass.c175
-rw-r--r--drivers/block/dwc_ahsata.c4
-rw-r--r--drivers/block/pata_bfin.c2
-rw-r--r--drivers/block/sandbox.c166
-rw-r--r--drivers/block/systemace.c12
-rw-r--r--drivers/core/simple-bus.c1
-rw-r--r--drivers/core/uclass.c13
-rw-r--r--drivers/dfu/dfu_mmc.c4
-rw-r--r--drivers/gpio/rk_gpio.c4
-rw-r--r--drivers/misc/altera_sysid.c4
-rw-r--r--drivers/mmc/arm_pl180_mmci.c2
-rw-r--r--drivers/mmc/mmc.c14
-rw-r--r--drivers/mmc/mmc_private.h8
-rw-r--r--drivers/mmc/mmc_write.c8
-rw-r--r--drivers/mmc/mxsmmc.c24
-rw-r--r--drivers/mmc/omap_hsmmc.c4
-rw-r--r--drivers/mmc/sdhci.c2
-rw-r--r--drivers/pci/pci-uclass.c4
-rw-r--r--drivers/pci/pci_auto_common.c51
-rw-r--r--drivers/power/regulator/regulator-uclass.c2
-rw-r--r--drivers/serial/serial-uclass.c5
-rw-r--r--drivers/serial/serial_arc.c3
-rw-r--r--drivers/serial/serial_lpuart.c6
-rw-r--r--drivers/serial/serial_mxc.c8
-rw-r--r--drivers/serial/serial_pxa.c8
-rw-r--r--drivers/serial/serial_s3c24x0.c8
-rw-r--r--drivers/serial/usbtty.c7
-rw-r--r--drivers/timer/timer-uclass.c4
-rw-r--r--drivers/video/vidconsole-uclass.c6
31 files changed, 427 insertions, 145 deletions
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 990f768..f35c4d4 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -1,3 +1,14 @@
+config BLK
+ bool "Support block devices"
+ depends on DM
+ help
+ Enable support for block devices, such as SCSI, MMC and USB
+ flash sticks. These provide a block-level interface which permits
+ reading, writing and (in some cases) erasing blocks. Block
+ devices often have a partition table which allows the device to
+ be partitioned into several areas, called 'partitions' in U-Boot.
+ A filesystem can be placed in each partition.
+
config DISK
bool "Support disk controllers with driver model"
depends on DM
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 5eb87e0..b5c7ae1 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -5,6 +5,8 @@
# SPDX-License-Identifier: GPL-2.0+
#
+obj-$(CONFIG_BLK) += blk-uclass.o
+
obj-$(CONFIG_DISK) += disk-uclass.o
obj-$(CONFIG_SCSI_AHCI) += ahci.o
obj-$(CONFIG_DWC_AHSATA) += dwc_ahsata.o
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
new file mode 100644
index 0000000..49df2a6
--- /dev/null
+++ b/drivers/block/blk-uclass.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2016 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <blk.h>
+#include <dm.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+
+int blk_first_device(int if_type, struct udevice **devp)
+{
+ struct blk_desc *desc;
+ int ret;
+
+ ret = uclass_first_device(UCLASS_BLK, devp);
+ if (ret)
+ return ret;
+ if (!*devp)
+ return -ENODEV;
+ do {
+ desc = dev_get_uclass_platdata(*devp);
+ if (desc->if_type == if_type)
+ return 0;
+ ret = uclass_next_device(devp);
+ if (ret)
+ return ret;
+ } while (*devp);
+
+ return -ENODEV;
+}
+
+int blk_next_device(struct udevice **devp)
+{
+ struct blk_desc *desc;
+ int ret, if_type;
+
+ desc = dev_get_uclass_platdata(*devp);
+ if_type = desc->if_type;
+ do {
+ ret = uclass_next_device(devp);
+ if (ret)
+ return ret;
+ if (!*devp)
+ return -ENODEV;
+ desc = dev_get_uclass_platdata(*devp);
+ if (desc->if_type == if_type)
+ return 0;
+ } while (1);
+}
+
+int blk_get_device(int if_type, int devnum, struct udevice **devp)
+{
+ struct uclass *uc;
+ struct udevice *dev;
+ int ret;
+
+ ret = uclass_get(UCLASS_BLK, &uc);
+ if (ret)
+ return ret;
+ uclass_foreach_dev(dev, uc) {
+ struct blk_desc *desc = dev_get_uclass_platdata(dev);
+
+ debug("%s: if_type=%d, devnum=%d: %s, %d, %d\n", __func__,
+ if_type, devnum, dev->name, desc->if_type, desc->devnum);
+ if (desc->if_type == if_type && desc->devnum == devnum) {
+ *devp = dev;
+ return device_probe(dev);
+ }
+ }
+
+ return -ENODEV;
+}
+
+unsigned long blk_dread(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt, void *buffer)
+{
+ struct udevice *dev = block_dev->bdev;
+ const struct blk_ops *ops = blk_get_ops(dev);
+
+ if (!ops->read)
+ return -ENOSYS;
+
+ return ops->read(dev, start, blkcnt, buffer);
+}
+
+unsigned long blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt, const void *buffer)
+{
+ struct udevice *dev = block_dev->bdev;
+ const struct blk_ops *ops = blk_get_ops(dev);
+
+ if (!ops->write)
+ return -ENOSYS;
+
+ return ops->write(dev, start, blkcnt, buffer);
+}
+
+unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt)
+{
+ struct udevice *dev = block_dev->bdev;
+ const struct blk_ops *ops = blk_get_ops(dev);
+
+ if (!ops->erase)
+ return -ENOSYS;
+
+ return ops->erase(dev, start, blkcnt);
+}
+
+int blk_prepare_device(struct udevice *dev)
+{
+ struct blk_desc *desc = dev_get_uclass_platdata(dev);
+
+ part_init(desc);
+
+ return 0;
+}
+
+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)
+{
+ struct blk_desc *desc;
+ struct udevice *dev;
+ int ret;
+
+ ret = device_bind_driver(parent, drv_name, name, &dev);
+ if (ret)
+ return ret;
+ desc = dev_get_uclass_platdata(dev);
+ desc->if_type = if_type;
+ desc->blksz = blksz;
+ desc->lba = size / blksz;
+ desc->part_type = PART_TYPE_UNKNOWN;
+ desc->bdev = dev;
+ desc->devnum = devnum;
+ *devp = dev;
+
+ return 0;
+}
+
+int blk_unbind_all(int if_type)
+{
+ struct uclass *uc;
+ struct udevice *dev, *next;
+ int ret;
+
+ ret = uclass_get(UCLASS_BLK, &uc);
+ if (ret)
+ return ret;
+ uclass_foreach_dev_safe(dev, next, uc) {
+ struct blk_desc *desc = dev_get_uclass_platdata(dev);
+
+ if (desc->if_type == if_type) {
+ ret = device_remove(dev);
+ if (ret)
+ return ret;
+ ret = device_unbind(dev);
+ if (ret)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+UCLASS_DRIVER(blk) = {
+ .id = UCLASS_BLK,
+ .name = "blk",
+ .per_device_platdata_auto_alloc_size = sizeof(struct blk_desc),
+};
diff --git a/drivers/block/dwc_ahsata.c b/drivers/block/dwc_ahsata.c
index bc072f3..6ec52a9 100644
--- a/drivers/block/dwc_ahsata.c
+++ b/drivers/block/dwc_ahsata.c
@@ -620,7 +620,7 @@ int reset_sata(int dev)
static void dwc_ahsata_print_info(int dev)
{
- block_dev_desc_t *pdev = &(sata_dev_desc[dev]);
+ struct blk_desc *pdev = &(sata_dev_desc[dev]);
printf("SATA Device Info:\n\r");
#ifdef CONFIG_SYS_64BIT_LBA
@@ -956,7 +956,7 @@ int scan_sata(int dev)
struct ahci_probe_ent *probe_ent =
(struct ahci_probe_ent *)sata_dev_desc[dev].priv;
u8 port = probe_ent->hard_port_no;
- block_dev_desc_t *pdev = &(sata_dev_desc[dev]);
+ struct blk_desc *pdev = &(sata_dev_desc[dev]);
id = (u16 *)memalign(ARCH_DMA_MINALIGN,
roundup(ARCH_DMA_MINALIGN,
diff --git a/drivers/block/pata_bfin.c b/drivers/block/pata_bfin.c
index c2673bd..26569d7 100644
--- a/drivers/block/pata_bfin.c
+++ b/drivers/block/pata_bfin.c
@@ -965,7 +965,7 @@ int scan_sata(int dev)
/* Probe device and set xfer mode */
bfin_ata_identify(ap, dev%PATA_DEV_NUM_PER_PORT);
bfin_ata_set_Feature_cmd(ap, dev%PATA_DEV_NUM_PER_PORT);
- init_part(&sata_dev_desc[dev]);
+ part_init(&sata_dev_desc[dev]);
return 0;
}
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index 170f0fa..6d41508 100644
--- a/drivers/block/sandbox.c
+++ b/drivers/block/sandbox.c
@@ -4,14 +4,20 @@
* SPDX-License-Identifier: GPL-2.0+
*/
-#include <config.h>
#include <common.h>
+#include <blk.h>
+#include <dm.h>
+#include <fdtdec.h>
#include <part.h>
#include <os.h>
#include <malloc.h>
#include <sandboxblockdev.h>
#include <asm/errno.h>
+#include <dm/device-internal.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifndef CONFIG_BLK
static struct host_block_dev host_devices[CONFIG_HOST_MAX_DEVICES];
static struct host_block_dev *find_host_device(int dev)
@@ -21,48 +27,130 @@ static struct host_block_dev *find_host_device(int dev)
return NULL;
}
+#endif
-static unsigned long host_block_read(block_dev_desc_t *block_dev,
+#ifdef CONFIG_BLK
+static unsigned long host_block_read(struct udevice *dev,
unsigned long start, lbaint_t blkcnt,
void *buffer)
{
- int dev = block_dev->dev;
+ struct host_block_dev *host_dev = dev_get_priv(dev);
+ struct blk_desc *block_dev = dev_get_uclass_platdata(dev);
+
+#else
+static unsigned long host_block_read(struct blk_desc *block_dev,
+ unsigned long start, lbaint_t blkcnt,
+ void *buffer)
+{
+ int dev = block_dev->devnum;
struct host_block_dev *host_dev = find_host_device(dev);
if (!host_dev)
return -1;
- if (os_lseek(host_dev->fd,
- start * host_dev->blk_dev.blksz,
- OS_SEEK_SET) == -1) {
- printf("ERROR: Invalid position\n");
+#endif
+
+ if (os_lseek(host_dev->fd, start * block_dev->blksz, OS_SEEK_SET) ==
+ -1) {
+ printf("ERROR: Invalid block %lx\n", start);
return -1;
}
- ssize_t len = os_read(host_dev->fd, buffer,
- blkcnt * host_dev->blk_dev.blksz);
+ ssize_t len = os_read(host_dev->fd, buffer, blkcnt * block_dev->blksz);
if (len >= 0)
- return len / host_dev->blk_dev.blksz;
+ return len / block_dev->blksz;
return -1;
}
-static unsigned long host_block_write(block_dev_desc_t *block_dev,
+#ifdef CONFIG_BLK
+static unsigned long host_block_write(struct udevice *dev,
unsigned long start, lbaint_t blkcnt,
const void *buffer)
{
- int dev = block_dev->dev;
+ struct host_block_dev *host_dev = dev_get_priv(dev);
+ struct blk_desc *block_dev = dev_get_uclass_platdata(dev);
+#else
+static unsigned long host_block_write(struct blk_desc *block_dev,
+ unsigned long start, lbaint_t blkcnt,
+ const void *buffer)
+{
+ int dev = block_dev->devnum;
struct host_block_dev *host_dev = find_host_device(dev);
- if (os_lseek(host_dev->fd,
- start * host_dev->blk_dev.blksz,
- OS_SEEK_SET) == -1) {
- printf("ERROR: Invalid position\n");
+#endif
+
+ if (os_lseek(host_dev->fd, start * block_dev->blksz, OS_SEEK_SET) ==
+ -1) {
+ printf("ERROR: Invalid block %lx\n", start);
return -1;
}
- ssize_t len = os_write(host_dev->fd, buffer, blkcnt *
- host_dev->blk_dev.blksz);
+ ssize_t len = os_write(host_dev->fd, buffer, blkcnt * block_dev->blksz);
if (len >= 0)
- return len / host_dev->blk_dev.blksz;
+ return len / block_dev->blksz;
return -1;
}
+#ifdef CONFIG_BLK
+int host_dev_bind(int devnum, char *filename)
+{
+ struct host_block_dev *host_dev;
+ struct udevice *dev;
+ char dev_name[20], *str, *fname;
+ int ret, fd;
+
+ /* Remove and unbind the old device, if any */
+ ret = blk_get_device(IF_TYPE_HOST, devnum, &dev);
+ if (ret == 0) {
+ ret = device_remove(dev);
+ if (ret)
+ return ret;
+ ret = device_unbind(dev);
+ if (ret)
+ return ret;
+ } else if (ret != -ENODEV) {
+ return ret;
+ }
+
+ if (!filename)
+ return 0;
+
+ snprintf(dev_name, sizeof(dev_name), "host%d", devnum);
+ str = strdup(dev_name);
+ if (!str)
+ return -ENOMEM;
+ fname = strdup(filename);
+ if (!fname) {
+ free(str);
+ return -ENOMEM;
+ }
+
+ fd = os_open(filename, OS_O_RDWR);
+ if (fd == -1) {
+ printf("Failed to access host backing file '%s'\n", filename);
+ ret = -ENOENT;
+ goto err;
+ }
+ ret = blk_create_device(gd->dm_root, "sandbox_host_blk", str,
+ IF_TYPE_HOST, devnum, 512,
+ os_lseek(fd, 0, OS_SEEK_END), &dev);
+ if (ret)
+ goto err_file;
+ ret = device_probe(dev);
+ if (ret) {
+ device_unbind(dev);
+ goto err_file;
+ }
+
+ host_dev = dev_get_priv(dev);
+ host_dev->fd = fd;
+ host_dev->filename = fname;
+
+ return blk_prepare_device(dev);
+err_file:
+ os_close(fd);
+err:
+ free(fname);
+ free(str);
+ return ret;
+}
+#else
int host_dev_bind(int dev, char *filename)
{
struct host_block_dev *host_dev = find_host_device(dev);
@@ -89,23 +177,33 @@ int host_dev_bind(int dev, char *filename)
return 1;
}
- block_dev_desc_t *blk_dev = &host_dev->blk_dev;
+ struct blk_desc *blk_dev = &host_dev->blk_dev;
blk_dev->if_type = IF_TYPE_HOST;
blk_dev->priv = host_dev;
blk_dev->blksz = 512;
blk_dev->lba = os_lseek(host_dev->fd, 0, OS_SEEK_END) / blk_dev->blksz;
blk_dev->block_read = host_block_read;
blk_dev->block_write = host_block_write;
- blk_dev->dev = dev;
+ blk_dev->devnum = dev;
blk_dev->part_type = PART_TYPE_UNKNOWN;
- init_part(blk_dev);
+ part_init(blk_dev);
return 0;
}
+#endif
-int host_get_dev_err(int dev, block_dev_desc_t **blk_devp)
+int host_get_dev_err(int devnum, struct blk_desc **blk_devp)
{
- struct host_block_dev *host_dev = find_host_device(dev);
+#ifdef CONFIG_BLK
+ struct udevice *dev;
+ int ret;
+
+ ret = blk_get_device(IF_TYPE_HOST, devnum, &dev);
+ if (ret)
+ return ret;
+ *blk_devp = dev_get_uclass_platdata(dev);
+#else
+ struct host_block_dev *host_dev = find_host_device(devnum);
if (!host_dev)
return -ENODEV;
@@ -114,15 +212,31 @@ int host_get_dev_err(int dev, block_dev_desc_t **blk_devp)
return -ENOENT;
*blk_devp = &host_dev->blk_dev;
+#endif
+
return 0;
}
-block_dev_desc_t *host_get_dev(int dev)
+struct blk_desc *host_get_dev(int dev)
{
- block_dev_desc_t *blk_dev;
+ struct blk_desc *blk_dev;
if (host_get_dev_err(dev, &blk_dev))
return NULL;
return blk_dev;
}
+
+#ifdef CONFIG_BLK
+static const struct blk_ops sandbox_host_blk_ops = {
+ .read = host_block_read,
+ .write = host_block_write,
+};
+
+U_BOOT_DRIVER(sandbox_host_blk) = {
+ .name = "sandbox_host_blk",
+ .id = UCLASS_BLK,
+ .ops = &sandbox_host_blk_ops,
+ .priv_auto_alloc_size = sizeof(struct host_block_dev),
+};
+#endif
diff --git a/drivers/block/systemace.c b/drivers/block/systemace.c
index b974e80..09fe834 100644
--- a/drivers/block/systemace.c
+++ b/drivers/block/systemace.c
@@ -69,11 +69,11 @@ static u16 ace_readw(unsigned off)
return in16(base + off);
}
-static unsigned long systemace_read(block_dev_desc_t *block_dev,
+static unsigned long systemace_read(struct blk_desc *block_dev,
unsigned long start, lbaint_t blkcnt,
void *buffer);
-static block_dev_desc_t systemace_dev = { 0 };
+static struct blk_desc systemace_dev = { 0 };
static int get_cf_lock(void)
{
@@ -105,13 +105,13 @@ static void release_cf_lock(void)
}
#ifdef CONFIG_PARTITIONS
-block_dev_desc_t *systemace_get_dev(int dev)
+struct blk_desc *systemace_get_dev(int dev)
{
/* The first time through this, the systemace_dev object is
not yet initialized. In that case, fill it in. */
if (systemace_dev.blksz == 0) {
systemace_dev.if_type = IF_TYPE_UNKNOWN;
- systemace_dev.dev = 0;
+ systemace_dev.devnum = 0;
systemace_dev.part_type = PART_TYPE_UNKNOWN;
systemace_dev.type = DEV_TYPE_HARDDISK;
systemace_dev.blksz = 512;
@@ -124,7 +124,7 @@ block_dev_desc_t *systemace_get_dev(int dev)
*/
ace_writew(width == 8 ? 0 : 0x0001, 0);
- init_part(&systemace_dev);
+ part_init(&systemace_dev);
}
@@ -137,7 +137,7 @@ block_dev_desc_t *systemace_get_dev(int dev)
* the dev_desc) to read blocks of data. The return value is the
* number of blocks read. A zero return indicates an error.
*/
-static unsigned long systemace_read(block_dev_desc_t *block_dev,
+static unsigned long systemace_read(struct blk_desc *block_dev,
unsigned long start, lbaint_t blkcnt,
void *buffer)
{
diff --git a/drivers/core/simple-bus.c b/drivers/core/simple-bus.c
index 913c3cc..1a9c864 100644
--- a/drivers/core/simple-bus.c
+++ b/drivers/core/simple-bus.c
@@ -53,6 +53,7 @@ UCLASS_DRIVER(simple_bus) = {
static const struct udevice_id generic_simple_bus_ids[] = {
{ .compatible = "simple-bus" },
+ { .compatible = "simple-mfd" },
{ }
};
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 12095e7..1141ce1 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -401,6 +401,19 @@ int uclass_first_device(enum uclass_id id, struct udevice **devp)
return uclass_get_device_tail(dev, ret, devp);
}
+int uclass_first_device_err(enum uclass_id id, struct udevice **devp)
+{
+ int ret;
+
+ ret = uclass_first_device(id, devp);
+ if (ret)
+ return ret;
+ else if (!*devp)
+ return -ENODEV;
+
+ return 0;
+}
+
int uclass_next_device(struct udevice **devp)
{
struct udevice *dev = *devp;
diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index 395d472..faece88 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -351,11 +351,11 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
} else if (!strcmp(entity_type, "part")) {
disk_partition_t partinfo;
- block_dev_desc_t *blk_dev = &mmc->block_dev;
+ struct blk_desc *blk_dev = &mmc->block_dev;
int mmcdev = second_arg;
int mmcpart = third_arg;
- if (get_partition_info(blk_dev, mmcpart, &partinfo) != 0) {
+ if (part_get_info(blk_dev, mmcpart, &partinfo) != 0) {
error("Couldn't find part #%d on mmc device #%d\n",
mmcpart, mmcdev);
return -ENODEV;
diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c
index c62f025..40e87bd 100644
--- a/drivers/gpio/rk_gpio.c
+++ b/drivers/gpio/rk_gpio.c
@@ -116,11 +116,9 @@ static int rockchip_gpio_probe(struct udevice *dev)
/* This only supports RK3288 at present */
priv->regs = (struct rockchip_gpio_regs *)dev_get_addr(dev);
- ret = uclass_first_device(UCLASS_PINCTRL, &priv->pinctrl);
+ ret = uclass_first_device_err(UCLASS_PINCTRL, &priv->pinctrl);
if (ret)
return ret;
- if (!priv->pinctrl)
- return -ENODEV;
uc_priv->gpio_count = ROCKCHIP_GPIOS_PER_BANK;
end = strrchr(dev->name, '@');
diff --git a/drivers/misc/altera_sysid.c b/drivers/misc/altera_sysid.c
index 2d0fa2a..ed6d462 100644
--- a/drivers/misc/altera_sysid.c
+++ b/drivers/misc/altera_sysid.c
@@ -32,11 +32,9 @@ void display_sysid(void)
int ret;
/* the first misc device will be used */
- ret = uclass_first_device(UCLASS_MISC, &dev);
+ ret = uclass_first_device_err(UCLASS_MISC, &dev);
if (ret)
return;
- if (!dev)
- return;
ret = misc_read(dev, 0, &sysid, sizeof(sysid));
if (ret)
return;
diff --git a/drivers/mmc/arm_pl180_mmci.c b/drivers/mmc/arm_pl180_mmci.c
index 5ef7ff7..8f2694f 100644
--- a/drivers/mmc/arm_pl180_mmci.c
+++ b/drivers/mmc/arm_pl180_mmci.c
@@ -375,7 +375,7 @@ int arm_pl180_mmci_init(struct pl180_mmc_host *host)
if (mmc == NULL)
return -1;
- debug("registered mmc interface number is:%d\n", mmc->block_dev.dev);
+ debug("registered mmc interface number is:%d\n", mmc->block_dev.devnum);
return 0;
}
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index ede5d6e..8b2e606 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -182,7 +182,7 @@ struct mmc *find_mmc_device(int dev_num)
list_for_each(entry, &mmc_devices) {
m = list_entry(entry, struct mmc, link);
- if (m->block_dev.dev == dev_num)
+ if (m->block_dev.devnum == dev_num)
return m;
}
@@ -234,10 +234,10 @@ static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,
return blkcnt;
}
-static ulong mmc_bread(block_dev_desc_t *block_dev, lbaint_t start,
+static ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start,
lbaint_t blkcnt, void *dst)
{
- int dev_num = block_dev->dev;
+ int dev_num = block_dev->devnum;
int err;
lbaint_t cur, blocks_todo = blkcnt;
@@ -1495,7 +1495,7 @@ static int mmc_startup(struct mmc *mmc)
mmc->block_dev.revision[0] = 0;
#endif
#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)
- init_part(&mmc->block_dev);
+ part_init(&mmc->block_dev);
#endif
return 0;
@@ -1556,7 +1556,7 @@ struct mmc *mmc_create(const struct mmc_config *cfg, void *priv)
mmc->dsr = 0xffffffff;
/* Setup the universal parts of the block interface just once */
mmc->block_dev.if_type = IF_TYPE_MMC;
- mmc->block_dev.dev = cur_dev_num++;
+ mmc->block_dev.devnum = cur_dev_num++;
mmc->block_dev.removable = 1;
mmc->block_dev.block_read = mmc_bread;
mmc->block_dev.block_write = mmc_bwrite;
@@ -1579,7 +1579,7 @@ void mmc_destroy(struct mmc *mmc)
}
#ifdef CONFIG_PARTITIONS
-block_dev_desc_t *mmc_get_dev(int dev)
+struct blk_desc *mmc_get_dev(int dev)
{
struct mmc *mmc = find_mmc_device(dev);
if (!mmc || mmc_init(mmc))
@@ -1728,7 +1728,7 @@ void print_mmc_devices(char separator)
else
mmc_type = NULL;
- printf("%s: %d", m->cfg->name, m->block_dev.dev);
+ printf("%s: %d", m->cfg->name, m->block_dev.devnum);
if (mmc_type)
printf(" (%s)", mmc_type);
diff --git a/drivers/mmc/mmc_private.h b/drivers/mmc/mmc_private.h
index 6a70639..d3f6bfe 100644
--- a/drivers/mmc/mmc_private.h
+++ b/drivers/mmc/mmc_private.h
@@ -22,23 +22,23 @@ void mmc_adapter_card_type_ident(void);
#ifndef CONFIG_SPL_BUILD
-unsigned long mmc_berase(block_dev_desc_t *block_dev, lbaint_t start,
+unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start,
lbaint_t blkcnt);
-unsigned long mmc_bwrite(block_dev_desc_t *block_dev, lbaint_t start,
+unsigned long mmc_bwrite(struct blk_desc *block_dev, lbaint_t start,
lbaint_t blkcnt, const void *src);
#else /* CONFIG_SPL_BUILD */
/* SPL will never write or erase, declare dummies to reduce code size. */
-static inline unsigned long mmc_berase(block_dev_desc_t *block_dev,
+static inline unsigned long mmc_berase(struct blk_desc *block_dev,
lbaint_t start, lbaint_t blkcnt)
{
return 0;
}
-static inline ulong mmc_bwrite(block_dev_desc_t *block_dev, lbaint_t start,
+static inline ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start,
lbaint_t blkcnt, const void *src)
{
return 0;
diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c
index 79b8c4d..7b186f8 100644
--- a/drivers/mmc/mmc_write.c
+++ b/drivers/mmc/mmc_write.c
@@ -65,10 +65,10 @@ err_out:
return err;
}
-unsigned long mmc_berase(block_dev_desc_t *block_dev, lbaint_t start,
+unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start,
lbaint_t blkcnt)
{
- int dev_num = block_dev->dev;
+ int dev_num = block_dev->devnum;
int err = 0;
u32 start_rem, blkcnt_rem;
struct mmc *mmc = find_mmc_device(dev_num);
@@ -171,10 +171,10 @@ static ulong mmc_write_blocks(struct mmc *mmc, lbaint_t start,
return blkcnt;
}
-ulong mmc_bwrite(block_dev_desc_t *block_dev, lbaint_t start, lbaint_t blkcnt,
+ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
const void *src)
{
- int dev_num = block_dev->dev;
+ int dev_num = block_dev->devnum;
lbaint_t cur, blocks_todo = blkcnt;
int err;
diff --git a/drivers/mmc/mxsmmc.c b/drivers/mmc/mxsmmc.c
index 31fb3ab..9fa87d5 100644
--- a/drivers/mmc/mxsmmc.c
+++ b/drivers/mmc/mxsmmc.c
@@ -142,7 +142,7 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
uint32_t ctrl0;
int ret;
- debug("MMC%d: CMD%d\n", mmc->block_dev.dev, cmd->cmdidx);
+ debug("MMC%d: CMD%d\n", mmc->block_dev.devnum, cmd->cmdidx);
/* Check bus busy */
timeout = MXSMMC_MAX_TIMEOUT;
@@ -157,13 +157,13 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
}
if (!timeout) {
- printf("MMC%d: Bus busy timeout!\n", mmc->block_dev.dev);
+ printf("MMC%d: Bus busy timeout!\n", mmc->block_dev.devnum);
return TIMEOUT;
}
/* See if card is present */
if (!mxsmmc_cd(priv)) {
- printf("MMC%d: No card detected!\n", mmc->block_dev.dev);
+ printf("MMC%d: No card detected!\n", mmc->block_dev.devnum);
return NO_CARD_ERR;
}
@@ -200,9 +200,9 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
if (data->flags & MMC_DATA_READ) {
ctrl0 |= SSP_CTRL0_READ;
} else if (priv->mmc_is_wp &&
- priv->mmc_is_wp(mmc->block_dev.dev)) {
+ priv->mmc_is_wp(mmc->block_dev.devnum)) {
printf("MMC%d: Can not write a locked card!\n",
- mmc->block_dev.dev);
+ mmc->block_dev.devnum);
return UNUSABLE_ERR;
}
@@ -243,21 +243,21 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
if (!timeout) {
printf("MMC%d: Command %d busy\n",
- mmc->block_dev.dev, cmd->cmdidx);
+ mmc->block_dev.devnum, cmd->cmdidx);
return TIMEOUT;
}
/* Check command timeout */
if (reg & SSP_STATUS_RESP_TIMEOUT) {
printf("MMC%d: Command %d timeout (status 0x%08x)\n",
- mmc->block_dev.dev, cmd->cmdidx, reg);
+ mmc->block_dev.devnum, cmd->cmdidx, reg);
return TIMEOUT;
}
/* Check command errors */
if (reg & (SSP_STATUS_RESP_CRC_ERR | SSP_STATUS_RESP_ERR)) {
printf("MMC%d: Command %d error (status 0x%08x)!\n",
- mmc->block_dev.dev, cmd->cmdidx, reg);
+ mmc->block_dev.devnum, cmd->cmdidx, reg);
return COMM_ERR;
}
@@ -279,14 +279,14 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
if (ret) {
printf("MMC%d: Data timeout with command %d "
"(status 0x%08x)!\n",
- mmc->block_dev.dev, cmd->cmdidx, reg);
+ mmc->block_dev.devnum, cmd->cmdidx, reg);
return ret;
}
} else {
ret = mxsmmc_send_cmd_dma(priv, data);
if (ret) {
printf("MMC%d: DMA transfer failed\n",
- mmc->block_dev.dev);
+ mmc->block_dev.devnum);
return ret;
}
}
@@ -297,7 +297,7 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
(SSP_STATUS_TIMEOUT | SSP_STATUS_DATA_CRC_ERR |
SSP_STATUS_FIFO_OVRFLW | SSP_STATUS_FIFO_UNDRFLW)) {
printf("MMC%d: Data error with command %d (status 0x%08x)!\n",
- mmc->block_dev.dev, cmd->cmdidx, reg);
+ mmc->block_dev.devnum, cmd->cmdidx, reg);
return COMM_ERR;
}
@@ -330,7 +330,7 @@ static void mxsmmc_set_ios(struct mmc *mmc)
SSP_CTRL0_BUS_WIDTH_MASK, priv->buswidth);
debug("MMC%d: Set %d bits bus width\n",
- mmc->block_dev.dev, mmc->bus_width);
+ mmc->block_dev.devnum, mmc->bus_width);
}
static int mxsmmc_init(struct mmc *mmc)
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index 5038a9f..5f2db3b 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -177,11 +177,11 @@ static unsigned char mmc_board_init(struct mmc *mmc)
#if defined(CONFIG_OMAP44XX) && defined(CONFIG_TWL6030_POWER)
/* PBIAS config needed for MMC1 only */
- if (mmc->block_dev.dev == 0)
+ if (mmc->block_dev.devnum == 0)
omap4_vmmc_pbias_config(mmc);
#endif
#if defined(CONFIG_OMAP54XX) && defined(CONFIG_PALMAS_POWER)
- if (mmc->block_dev.dev == 0)
+ if (mmc->block_dev.devnum == 0)
omap5_pbias_config(mmc);
#endif
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 8586d89..ef7e615 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -137,7 +137,7 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
int trans_bytes = 0, is_aligned = 1;
u32 mask, flags, mode;
unsigned int time = 0, start_addr = 0;
- int mmc_dev = mmc->block_dev.dev;
+ int mmc_dev = mmc->block_dev.devnum;
unsigned start = get_timer(0);
/* Timeout unit - ms */
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index d01bfc1..519052e 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -30,11 +30,9 @@ int pci_get_bus(int busnum, struct udevice **busp)
/* Since buses may not be numbered yet try a little harder with bus 0 */
if (ret == -ENODEV) {
- ret = uclass_first_device(UCLASS_PCI, busp);
+ ret = uclass_first_device_err(UCLASS_PCI, busp);
if (ret)
return ret;
- else if (!*busp)
- return -ENODEV;
ret = uclass_get_device_by_seq(UCLASS_PCI, busnum, busp);
}
diff --git a/drivers/pci/pci_auto_common.c b/drivers/pci/pci_auto_common.c
index 85c419e..677f094 100644
--- a/drivers/pci/pci_auto_common.c
+++ b/drivers/pci/pci_auto_common.c
@@ -62,6 +62,17 @@ int pciauto_region_allocate(struct pci_region *res, pci_size_t size,
return -1;
}
+static void pciauto_show_region(const char *name, struct pci_region *region)
+{
+ pciauto_region_init(region);
+ debug("PCI Autoconfig: Bus %s region: [%llx-%llx],\n"
+ "\t\tPhysical Memory [%llx-%llxx]\n", name,
+ (unsigned long long)region->bus_start,
+ (unsigned long long)(region->bus_start + region->size - 1),
+ (unsigned long long)region->phys_start,
+ (unsigned long long)(region->phys_start + region->size - 1));
+}
+
void pciauto_config_init(struct pci_controller *hose)
{
int i;
@@ -91,38 +102,10 @@ void pciauto_config_init(struct pci_controller *hose)
}
- if (hose->pci_mem) {
- pciauto_region_init(hose->pci_mem);
-
- debug("PCI Autoconfig: Bus Memory region: [0x%llx-0x%llx],\n"
- "\t\tPhysical Memory [%llx-%llxx]\n",
- (u64)hose->pci_mem->bus_start,
- (u64)(hose->pci_mem->bus_start + hose->pci_mem->size - 1),
- (u64)hose->pci_mem->phys_start,
- (u64)(hose->pci_mem->phys_start + hose->pci_mem->size - 1));
- }
-
- if (hose->pci_prefetch) {
- pciauto_region_init(hose->pci_prefetch);
-
- debug("PCI Autoconfig: Bus Prefetchable Mem: [0x%llx-0x%llx],\n"
- "\t\tPhysical Memory [%llx-%llx]\n",
- (u64)hose->pci_prefetch->bus_start,
- (u64)(hose->pci_prefetch->bus_start +
- hose->pci_prefetch->size - 1),
- (u64)hose->pci_prefetch->phys_start,
- (u64)(hose->pci_prefetch->phys_start +
- hose->pci_prefetch->size - 1));
- }
-
- if (hose->pci_io) {
- pciauto_region_init(hose->pci_io);
-
- debug("PCI Autoconfig: Bus I/O region: [0x%llx-0x%llx],\n"
- "\t\tPhysical Memory: [%llx-%llx]\n",
- (u64)hose->pci_io->bus_start,
- (u64)(hose->pci_io->bus_start + hose->pci_io->size - 1),
- (u64)hose->pci_io->phys_start,
- (u64)(hose->pci_io->phys_start + hose->pci_io->size - 1));
- }
+ if (hose->pci_mem)
+ pciauto_show_region("Memory", hose->pci_mem);
+ if (hose->pci_prefetch)
+ pciauto_show_region("Prefetchable Mem", hose->pci_prefetch);
+ if (hose->pci_io)
+ pciauto_show_region("I/O", hose->pci_io);
}
diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
index 9fe07f2..4434e36 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -325,7 +325,7 @@ int regulators_enable_boot_on(bool verbose)
if (ret)
return ret;
for (uclass_first_device(UCLASS_REGULATOR, &dev);
- dev && !ret;
+ dev;
uclass_next_device(&dev)) {
ret = regulator_autoset(dev);
if (ret == -EMEDIUMTYPE) {
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 1c447ff..f154eb1 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -123,11 +123,12 @@ static void _serial_putc(struct udevice *dev, char ch)
struct dm_serial_ops *ops = serial_get_ops(dev);
int err;
+ if (ch == '\n')
+ _serial_putc(dev, '\r');
+
do {
err = ops->putc(dev, ch);
} while (err == -EAGAIN);
- if (ch == '\n')
- _serial_putc(dev, '\r');
}
static void _serial_puts(struct udevice *dev, const char *str)
diff --git a/drivers/serial/serial_arc.c b/drivers/serial/serial_arc.c
index 7dbb49f..6292eb1 100644
--- a/drivers/serial/serial_arc.c
+++ b/drivers/serial/serial_arc.c
@@ -68,9 +68,6 @@ static int arc_serial_putc(struct udevice *dev, const char c)
struct arc_serial_platdata *plat = dev->platdata;
struct arc_serial_regs *const regs = plat->reg;
- if (c == '\n')
- arc_serial_putc(dev, '\r');
-
while (!(readb(&regs->status) & UART_TXEMPTY))
;
diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c
index fc3321f..042e9a2 100644
--- a/drivers/serial/serial_lpuart.c
+++ b/drivers/serial/serial_lpuart.c
@@ -77,9 +77,6 @@ static int _lpuart_serial_getc(struct lpuart_fsl *base)
static void _lpuart_serial_putc(struct lpuart_fsl *base, const char c)
{
- if (c == '\n')
- _lpuart_serial_putc(base, '\r');
-
while (!(__raw_readb(&base->us1) & US1_TDRE))
WATCHDOG_RESET();
@@ -198,9 +195,6 @@ static int _lpuart32_serial_getc(struct lpuart_fsl *base)
static void _lpuart32_serial_putc(struct lpuart_fsl *base, const char c)
{
- if (c == '\n')
- _lpuart32_serial_putc(base, '\r');
-
while (!(in_be32(&base->stat) & STAT_TDRE))
WATCHDOG_RESET();
diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
index 51485c0..1563bb3 100644
--- a/drivers/serial/serial_mxc.c
+++ b/drivers/serial/serial_mxc.c
@@ -164,15 +164,15 @@ static int mxc_serial_getc(void)
static void mxc_serial_putc(const char c)
{
+ /* If \n, also do \r */
+ if (c == '\n')
+ serial_putc('\r');
+
__REG(UART_PHYS + UTXD) = c;
/* wait for transmitter to be ready */
while (!(__REG(UART_PHYS + UTS) & UTS_TXEMPTY))
WATCHDOG_RESET();
-
- /* If \n, also do \r */
- if (c == '\n')
- serial_putc ('\r');
}
/*
diff --git a/drivers/serial/serial_pxa.c b/drivers/serial/serial_pxa.c
index 8fbcc10..1eb19ec 100644
--- a/drivers/serial/serial_pxa.c
+++ b/drivers/serial/serial_pxa.c
@@ -156,6 +156,10 @@ void pxa_putc_dev(unsigned int uart_index, const char c)
{
struct pxa_uart_regs *uart_regs;
+ /* If \n, also do \r */
+ if (c == '\n')
+ pxa_putc_dev(uart_index, '\r');
+
uart_regs = pxa_uart_index_to_regs(uart_index);
if (!uart_regs)
hang();
@@ -163,10 +167,6 @@ void pxa_putc_dev(unsigned int uart_index, const char c)
while (!(readl(&uart_regs->lsr) & LSR_TEMT))
WATCHDOG_RESET();
writel(c, &uart_regs->thr);
-
- /* If \n, also do \r */
- if (c == '\n')
- pxa_putc_dev (uart_index,'\r');
}
/*
diff --git a/drivers/serial/serial_s3c24x0.c b/drivers/serial/serial_s3c24x0.c
index d4e7df2..0f0878a 100644
--- a/drivers/serial/serial_s3c24x0.c
+++ b/drivers/serial/serial_s3c24x0.c
@@ -135,14 +135,14 @@ static void _serial_putc(const char c, const int dev_index)
{
struct s3c24x0_uart *uart = s3c24x0_get_base_uart(dev_index);
+ /* If \n, also do \r */
+ if (c == '\n')
+ serial_putc('\r');
+
while (!(readl(&uart->utrstat) & 0x2))
/* wait for room in the tx FIFO */ ;
writeb(c, &uart->utxh);
-
- /* If \n, also do \r */
- if (c == '\n')
- serial_putc('\r');
}
static inline void serial_putc_dev(unsigned int dev_index, const char c)
diff --git a/drivers/serial/usbtty.c b/drivers/serial/usbtty.c
index 75f0ec3..2e19813 100644
--- a/drivers/serial/usbtty.c
+++ b/drivers/serial/usbtty.c
@@ -434,11 +434,12 @@ void usbtty_putc(struct stdio_dev *dev, const char c)
if (!usbtty_configured ())
return;
- buf_push (&usbtty_output, &c, 1);
/* If \n, also do \r */
if (c == '\n')
buf_push (&usbtty_output, "\r", 1);
+ buf_push(&usbtty_output, &c, 1);
+
/* Poll at end to handle new data... */
if ((usbtty_output.size + 2) >= usbtty_output.totalsize) {
usbtty_poll ();
@@ -498,8 +499,8 @@ void usbtty_puts(struct stdio_dev *dev, const char *str)
n = next_nl_pos (str);
if (str[n] == '\n') {
- __usbtty_puts (str, n + 1);
- __usbtty_puts ("\r", 1);
+ __usbtty_puts("\r", 1);
+ __usbtty_puts(str, n + 1);
str += (n + 1);
len -= (n + 1);
} else {
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index 382c0f2..f8ddf93 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -82,11 +82,9 @@ int notrace dm_timer_init(void)
node = fdtdec_get_chosen_node(blob, "tick-timer");
if (node < 0) {
/* No chosen timer, trying first available timer */
- ret = uclass_first_device(UCLASS_TIMER, &dev);
+ ret = uclass_first_device_err(UCLASS_TIMER, &dev);
if (ret)
return ret;
- if (!dev)
- return -ENODEV;
} else {
if (uclass_get_device_by_of_offset(UCLASS_TIMER, node, &dev)) {
/*
diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index 832e90a..c8cc05e 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -240,8 +240,7 @@ static int do_video_setcursor(cmd_tbl_t *cmdtp, int flag, int argc,
if (argc != 3)
return CMD_RET_USAGE;
- uclass_first_device(UCLASS_VIDEO_CONSOLE, &dev);
- if (!dev)
+ if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
return CMD_RET_FAILURE;
col = simple_strtoul(argv[1], NULL, 10);
row = simple_strtoul(argv[2], NULL, 10);
@@ -259,8 +258,7 @@ static int do_video_puts(cmd_tbl_t *cmdtp, int flag, int argc,
if (argc != 2)
return CMD_RET_USAGE;
- uclass_first_device(UCLASS_VIDEO_CONSOLE, &dev);
- if (!dev)
+ if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
return CMD_RET_FAILURE;
for (s = argv[1]; *s; s++)
vidconsole_put_char(dev, *s);