blob: ad4906aa58b41c55859180d0572866413d53460b [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glassca831f42016-01-18 20:19:17 -07002/*
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
Simon Glassca831f42016-01-18 20:19:17 -07005 */
6
7#include <common.h>
8#include <dm.h>
9#include <pch.h>
Simon Glassca831f42016-01-18 20:19:17 -070010
Bin Meng3e389d82016-02-01 01:40:42 -080011int pch_get_spi_base(struct udevice *dev, ulong *sbasep)
Simon Glassca831f42016-01-18 20:19:17 -070012{
13 struct pch_ops *ops = pch_get_ops(dev);
14
15 *sbasep = 0;
Bin Meng3e389d82016-02-01 01:40:42 -080016 if (!ops->get_spi_base)
Simon Glassca831f42016-01-18 20:19:17 -070017 return -ENOSYS;
18
Bin Meng3e389d82016-02-01 01:40:42 -080019 return ops->get_spi_base(dev, sbasep);
Simon Glassca831f42016-01-18 20:19:17 -070020}
21
Simon Glassca831f42016-01-18 20:19:17 -070022int pch_set_spi_protect(struct udevice *dev, bool protect)
23{
24 struct pch_ops *ops = pch_get_ops(dev);
25
26 if (!ops->set_spi_protect)
27 return -ENOSYS;
28
29 return ops->set_spi_protect(dev, protect);
30}
31
Bin Meng384980c2016-02-01 01:40:43 -080032int pch_get_gpio_base(struct udevice *dev, u32 *gbasep)
33{
34 struct pch_ops *ops = pch_get_ops(dev);
35
36 *gbasep = 0;
37 if (!ops->get_gpio_base)
38 return -ENOSYS;
39
40 return ops->get_gpio_base(dev, gbasep);
41}
42
Bin Meng79d4eb62016-02-01 01:40:45 -080043int pch_get_io_base(struct udevice *dev, u32 *iobasep)
44{
45 struct pch_ops *ops = pch_get_ops(dev);
46
47 *iobasep = 0;
48 if (!ops->get_io_base)
49 return -ENOSYS;
50
51 return ops->get_io_base(dev, iobasep);
52}
53
Simon Glass1260f8c2019-02-16 20:24:51 -070054int pch_ioctl(struct udevice *dev, ulong req, void *data, int size)
55{
56 struct pch_ops *ops = pch_get_ops(dev);
57
58 if (!ops->ioctl)
59 return -ENOSYS;
60
61 return ops->ioctl(dev, req, data, size);
62}
63
Simon Glassca831f42016-01-18 20:19:17 -070064UCLASS_DRIVER(pch) = {
65 .id = UCLASS_PCH,
66 .name = "pch",
Simon Glass12e927b2019-09-25 08:56:43 -060067#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
Simon Glass91195482016-07-05 17:10:10 -060068 .post_bind = dm_scan_fdt_dev,
Simon Glass12e927b2019-09-25 08:56:43 -060069#endif
Simon Glassca831f42016-01-18 20:19:17 -070070};