File: mmc-pwrseq.c

package info (click to toggle)
u-boot 2023.01%2Bdfsg-2%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 167,504 kB
  • sloc: ansic: 2,036,483; python: 39,879; asm: 21,501; makefile: 11,365; perl: 11,111; sh: 3,657; cpp: 1,868; yacc: 1,100; lex: 747; awk: 57; tcl: 28; sed: 24
file content (51 lines) | stat: -rw-r--r-- 1,088 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// SPDX-License-Identifier: GPL-2.0+
/*
 * (C) Copyright 2021 SAMSUNG Electronics
 * Jaehoon Chung <jh80.chung@samsung.com>
 */

#include <common.h>
#include <dm.h>
#include <mmc.h>
#include <pwrseq.h>
#include <asm/gpio.h>
#include <linux/delay.h>

int mmc_pwrseq_get_power(struct udevice *dev, struct mmc_config *cfg)
{
	/* Enable power if needed */
	return uclass_get_device_by_phandle(UCLASS_PWRSEQ, dev, "mmc-pwrseq",
					   &cfg->pwr_dev);
}

static int mmc_pwrseq_set_power(struct udevice *dev, bool enable)
{
	struct gpio_desc reset;
	int ret;

	ret = gpio_request_by_name(dev, "reset-gpios", 0, &reset, GPIOD_IS_OUT);
	if (ret)
		return ret;
	dm_gpio_set_value(&reset, 1);
	udelay(1);
	dm_gpio_set_value(&reset, 0);
	udelay(200);

	return 0;
}

static const struct pwrseq_ops mmc_pwrseq_ops = {
	.set_power	= mmc_pwrseq_set_power,
};

static const struct udevice_id mmc_pwrseq_ids[] = {
	{ .compatible = "mmc-pwrseq-emmc" },
	{ }
};

U_BOOT_DRIVER(mmc_pwrseq_drv) = {
	.name		= "mmc_pwrseq_emmc",
	.id		= UCLASS_PWRSEQ,
	.of_match	= mmc_pwrseq_ids,
	.ops		= &mmc_pwrseq_ops,
};