]> git.ipfire.org Git - people/ms/u-boot.git/blob - drivers/pch/pch-uclass.c
dm: Convert users from dm_scan_fdt_node() to dm_scan_fdt_dev()
[people/ms/u-boot.git] / drivers / pch / pch-uclass.c
1 /*
2 * Copyright (c) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8 #include <common.h>
9 #include <dm.h>
10 #include <pch.h>
11
12 DECLARE_GLOBAL_DATA_PTR;
13
14 int pch_get_spi_base(struct udevice *dev, ulong *sbasep)
15 {
16 struct pch_ops *ops = pch_get_ops(dev);
17
18 *sbasep = 0;
19 if (!ops->get_spi_base)
20 return -ENOSYS;
21
22 return ops->get_spi_base(dev, sbasep);
23 }
24
25 int pch_set_spi_protect(struct udevice *dev, bool protect)
26 {
27 struct pch_ops *ops = pch_get_ops(dev);
28
29 if (!ops->set_spi_protect)
30 return -ENOSYS;
31
32 return ops->set_spi_protect(dev, protect);
33 }
34
35 int pch_get_gpio_base(struct udevice *dev, u32 *gbasep)
36 {
37 struct pch_ops *ops = pch_get_ops(dev);
38
39 *gbasep = 0;
40 if (!ops->get_gpio_base)
41 return -ENOSYS;
42
43 return ops->get_gpio_base(dev, gbasep);
44 }
45
46 int pch_get_io_base(struct udevice *dev, u32 *iobasep)
47 {
48 struct pch_ops *ops = pch_get_ops(dev);
49
50 *iobasep = 0;
51 if (!ops->get_io_base)
52 return -ENOSYS;
53
54 return ops->get_io_base(dev, iobasep);
55 }
56
57 static int pch_uclass_post_bind(struct udevice *bus)
58 {
59 /*
60 * Scan the device tree for devices
61 *
62 * Before relocation, only bind devices marked for pre-relocation
63 * use.
64 */
65 return dm_scan_fdt_dev(bus);
66 }
67
68 UCLASS_DRIVER(pch) = {
69 .id = UCLASS_PCH,
70 .name = "pch",
71 .post_bind = pch_uclass_post_bind,
72 };