mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-30 15:03:18 +00:00
8613c8d897
Use the _ptr suffixed variant instead of casting. Also, convert it to dev_read_addr_ptr(), which is safe to CONFIG_OF_LIVE. One curious part is an error check like follows in drivers/watchdog/omap_wdt.c: priv->regs = (struct wd_timer *)devfdt_get_addr(dev); if (!priv->regs) return -EINVAL; devfdt_get_addr() returns FDT_ADDR_T_NONE (i.e. -1) on error. So, this code does not catch any error in DT parsing. dev_read_addr_ptr() returns NULL on error, so this error check will work. I generated this commit by the following command: $ find . -name .git -prune -o -name '*.[ch]' -type f -print | \ xargs sed -i -e 's/([^*)]*\*)devfdt_get_addr(/dev_read_addr_ptr(/' I manually fixed drivers/usb/host/ehci-mx6.c Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
91 lines
1.8 KiB
C
91 lines
1.8 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright 2019 IBM Corp.
|
|
* Eddie James <eajames@linux.ibm.com>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <clk.h>
|
|
#include <dm.h>
|
|
#include <malloc.h>
|
|
#include <sdhci.h>
|
|
#include <linux/err.h>
|
|
|
|
struct aspeed_sdhci_plat {
|
|
struct mmc_config cfg;
|
|
struct mmc mmc;
|
|
};
|
|
|
|
static int aspeed_sdhci_probe(struct udevice *dev)
|
|
{
|
|
struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
|
|
struct aspeed_sdhci_plat *plat = dev_get_platdata(dev);
|
|
struct sdhci_host *host = dev_get_priv(dev);
|
|
u32 max_clk;
|
|
struct clk clk;
|
|
int ret;
|
|
|
|
ret = clk_get_by_index(dev, 0, &clk);
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = clk_enable(&clk);
|
|
if (ret)
|
|
goto free;
|
|
|
|
host->name = dev->name;
|
|
host->ioaddr = dev_read_addr_ptr(dev);
|
|
|
|
max_clk = clk_get_rate(&clk);
|
|
if (IS_ERR_VALUE(max_clk)) {
|
|
ret = max_clk;
|
|
goto err;
|
|
}
|
|
|
|
host->max_clk = max_clk;
|
|
host->mmc = &plat->mmc;
|
|
host->mmc->dev = dev;
|
|
host->mmc->priv = host;
|
|
upriv->mmc = host->mmc;
|
|
|
|
ret = sdhci_setup_cfg(&plat->cfg, host, 0, 0);
|
|
if (ret)
|
|
goto err;
|
|
|
|
ret = sdhci_probe(dev);
|
|
if (ret)
|
|
goto err;
|
|
|
|
return 0;
|
|
|
|
err:
|
|
clk_disable(&clk);
|
|
free:
|
|
clk_free(&clk);
|
|
return ret;
|
|
}
|
|
|
|
static int aspeed_sdhci_bind(struct udevice *dev)
|
|
{
|
|
struct aspeed_sdhci_plat *plat = dev_get_platdata(dev);
|
|
|
|
return sdhci_bind(dev, &plat->mmc, &plat->cfg);
|
|
}
|
|
|
|
static const struct udevice_id aspeed_sdhci_ids[] = {
|
|
{ .compatible = "aspeed,ast2400-sdhci" },
|
|
{ .compatible = "aspeed,ast2500-sdhci" },
|
|
{ .compatible = "aspeed,ast2600-sdhci" },
|
|
{ }
|
|
};
|
|
|
|
U_BOOT_DRIVER(aspeed_sdhci_drv) = {
|
|
.name = "aspeed_sdhci",
|
|
.id = UCLASS_MMC,
|
|
.of_match = aspeed_sdhci_ids,
|
|
.ops = &sdhci_ops,
|
|
.bind = aspeed_sdhci_bind,
|
|
.probe = aspeed_sdhci_probe,
|
|
.priv_auto_alloc_size = sizeof(struct sdhci_host),
|
|
.platdata_auto_alloc_size = sizeof(struct aspeed_sdhci_plat),
|
|
};
|