blob: a1c9624a2225528e860bb1fb268dee2362493018 [file] [log] [blame]
Jaehoon Chung48ad8272021-02-16 10:16:52 +09001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * (C) Copyright 2021 SAMSUNG Electronics
4 * Jaehoon Chung <jh80.chung@samsung.com>
5 */
6
Jaehoon Chung48ad8272021-02-16 10:16:52 +09007#include <dm.h>
8#include <mmc.h>
9#include <pwrseq.h>
10#include <asm/gpio.h>
11#include <linux/delay.h>
12
13int mmc_pwrseq_get_power(struct udevice *dev, struct mmc_config *cfg)
14{
15 /* Enable power if needed */
16 return uclass_get_device_by_phandle(UCLASS_PWRSEQ, dev, "mmc-pwrseq",
17 &cfg->pwr_dev);
18}
19
20static int mmc_pwrseq_set_power(struct udevice *dev, bool enable)
21{
22 struct gpio_desc reset;
23 int ret;
24
25 ret = gpio_request_by_name(dev, "reset-gpios", 0, &reset, GPIOD_IS_OUT);
26 if (ret)
27 return ret;
28 dm_gpio_set_value(&reset, 1);
29 udelay(1);
30 dm_gpio_set_value(&reset, 0);
31 udelay(200);
32
33 return 0;
34}
35
36static const struct pwrseq_ops mmc_pwrseq_ops = {
37 .set_power = mmc_pwrseq_set_power,
38};
39
40static const struct udevice_id mmc_pwrseq_ids[] = {
41 { .compatible = "mmc-pwrseq-emmc" },
42 { }
43};
44
45U_BOOT_DRIVER(mmc_pwrseq_drv) = {
46 .name = "mmc_pwrseq_emmc",
47 .id = UCLASS_PWRSEQ,
48 .of_match = mmc_pwrseq_ids,
49 .ops = &mmc_pwrseq_ops,
50};