blob: 48a3965a7644e6e00e30b4250d7b023d043f8555 [file] [log] [blame]
Simon Glassca831f42016-01-18 20:19:17 -07001/*
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
13DECLARE_GLOBAL_DATA_PTR;
14
Bin Meng3e389d82016-02-01 01:40:42 -080015int pch_get_spi_base(struct udevice *dev, ulong *sbasep)
Simon Glassca831f42016-01-18 20:19:17 -070016{
17 struct pch_ops *ops = pch_get_ops(dev);
18
19 *sbasep = 0;
Bin Meng3e389d82016-02-01 01:40:42 -080020 if (!ops->get_spi_base)
Simon Glassca831f42016-01-18 20:19:17 -070021 return -ENOSYS;
22
Bin Meng3e389d82016-02-01 01:40:42 -080023 return ops->get_spi_base(dev, sbasep);
Simon Glassca831f42016-01-18 20:19:17 -070024}
25
Simon Glassca831f42016-01-18 20:19:17 -070026int pch_set_spi_protect(struct udevice *dev, bool protect)
27{
28 struct pch_ops *ops = pch_get_ops(dev);
29
30 if (!ops->set_spi_protect)
31 return -ENOSYS;
32
33 return ops->set_spi_protect(dev, protect);
34}
35
Bin Meng384980c2016-02-01 01:40:43 -080036int pch_get_gpio_base(struct udevice *dev, u32 *gbasep)
37{
38 struct pch_ops *ops = pch_get_ops(dev);
39
40 *gbasep = 0;
41 if (!ops->get_gpio_base)
42 return -ENOSYS;
43
44 return ops->get_gpio_base(dev, gbasep);
45}
46
Simon Glassca831f42016-01-18 20:19:17 -070047static int pch_uclass_post_bind(struct udevice *bus)
48{
49 /*
50 * Scan the device tree for devices
51 *
52 * Before relocation, only bind devices marked for pre-relocation
53 * use.
54 */
55 return dm_scan_fdt_node(bus, gd->fdt_blob, bus->of_offset,
56 gd->flags & GD_FLG_RELOC ? false : true);
57}
58
59UCLASS_DRIVER(pch) = {
60 .id = UCLASS_PCH,
61 .name = "pch",
62 .post_bind = pch_uclass_post_bind,
63};