summaryrefslogtreecommitdiffstats
path: root/drivers/base/platform.c
blob: 7de3d9557ef65043590c8758b715a1e256a98ddd (plain)
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
52
53
54
55
56
// SPDX-License-Identifier: GPL-2.0
/*
 * bus.c - barebox driver model
 *
 * Copyright (c) 2009 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
 */
#include <common.h>
#include <driver.h>
#include <errno.h>
#include <init.h>
#include <of.h>
#include <pm_domain.h>

static int platform_probe(struct device_d *dev)
{
	int ret;

	ret = genpd_dev_pm_attach(dev);
	if (ret < 0)
		return ret;

	return dev->driver->probe(dev);
}

static void platform_remove(struct device_d *dev)
{
	if (dev->driver->remove)
		dev->driver->remove(dev);
}

int platform_driver_register(struct driver_d *drv)
{
	drv->bus = &platform_bus;

	return register_driver(drv);
}

int platform_device_register(struct device_d *new_device)
{
	new_device->bus = &platform_bus;

	return register_device(new_device);
}

struct bus_type platform_bus = {
	.name = "platform",
	.match = device_match,
	.probe = platform_probe,
	.remove = platform_remove,
};

static int platform_init(void)
{
	return bus_register(&platform_bus);
}
pure_initcall(platform_init);