// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright 2019 IBM Corp.
 * Eddie James <eajames@linux.ibm.com>
 */

#include <clk.h>
#include <dm.h>
#include <malloc.h>
#include <sdhci.h>
#include <linux/err.h>
#include <dm/lists.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_plat(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) {
		debug("%s: clock get failed %d\n", __func__, ret);
		return ret;
	}

	ret = clk_enable(&clk);
	if (ret) {
		debug("%s: clock enable failed %d\n", __func__, ret);
		return ret;
	}

	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;
		debug("%s: clock rate get failed %d\n", __func__, ret);
		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);
	return ret;
}

static int aspeed_sdhci_bind(struct udevice *dev)
{
	struct aspeed_sdhci_plat *plat = dev_get_plat(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	= sizeof(struct sdhci_host),
	.plat_auto	= sizeof(struct aspeed_sdhci_plat),
};

static int aspeed_sdc_probe(struct udevice *parent)
{
	struct clk clk;
	int ret;

	ret = clk_get_by_index(parent, 0, &clk);
	if (ret) {
		debug("%s: clock get failed %d\n", __func__, ret);
		return ret;
	}

	ret = clk_enable(&clk);
	if (ret) {
		debug("%s: clock enable failed %d\n", __func__, ret);
		return ret;
	}

	return 0;
}

static const struct udevice_id aspeed_sdc_ids[] = {
	{ .compatible = "aspeed,ast2400-sd-controller" },
	{ .compatible = "aspeed,ast2500-sd-controller" },
	{ .compatible = "aspeed,ast2600-sd-controller" },
	{ }
};

U_BOOT_DRIVER(aspeed_sdc_drv) = {
	.name		= "aspeed_sdc",
	.id		= UCLASS_MISC,
	.of_match	= aspeed_sdc_ids,
	.probe		= aspeed_sdc_probe,
};
