dm: x86: Add a driver for Intel PCH9
[oweals/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 #include <dm/root.h>
12
13 DECLARE_GLOBAL_DATA_PTR;
14
15 int pch_get_sbase(struct udevice *dev, ulong *sbasep)
16 {
17         struct pch_ops *ops = pch_get_ops(dev);
18
19         *sbasep = 0;
20         if (!ops->get_sbase)
21                 return -ENOSYS;
22
23         return ops->get_sbase(dev, sbasep);
24 }
25
26 enum pch_version pch_get_version(struct udevice *dev)
27 {
28         struct pch_ops *ops = pch_get_ops(dev);
29
30         if (!ops->get_version)
31                 return -ENOSYS;
32
33         return ops->get_version(dev);
34 }
35
36 int pch_set_spi_protect(struct udevice *dev, bool protect)
37 {
38         struct pch_ops *ops = pch_get_ops(dev);
39
40         if (!ops->set_spi_protect)
41                 return -ENOSYS;
42
43         return ops->set_spi_protect(dev, protect);
44 }
45
46 static int pch_uclass_post_bind(struct udevice *bus)
47 {
48         /*
49          * Scan the device tree for devices
50          *
51          * Before relocation, only bind devices marked for pre-relocation
52          * use.
53          */
54         return dm_scan_fdt_node(bus, gd->fdt_blob, bus->of_offset,
55                                 gd->flags & GD_FLG_RELOC ? false : true);
56 }
57
58 UCLASS_DRIVER(pch) = {
59         .id             = UCLASS_PCH,
60         .name           = "pch",
61         .post_bind      = pch_uclass_post_bind,
62 };