blob: 9af2475800426438ee9717825fc64ed81fae9b84 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glass68a24232016-01-18 20:19:17 -07002/*
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
Simon Glass68a24232016-01-18 20:19:17 -07005 */
6
Patrick Delaunay81313352021-04-27 11:02:19 +02007#define LOG_CATEGORY UCLASS_PCH
8
Simon Glass68a24232016-01-18 20:19:17 -07009#include <dm.h>
10#include <pch.h>
Simon Glass68a24232016-01-18 20:19:17 -070011
Bin Meng06d66af2016-02-01 01:40:42 -080012int pch_get_spi_base(struct udevice *dev, ulong *sbasep)
Simon Glass68a24232016-01-18 20:19:17 -070013{
14 struct pch_ops *ops = pch_get_ops(dev);
15
16 *sbasep = 0;
Bin Meng06d66af2016-02-01 01:40:42 -080017 if (!ops->get_spi_base)
Simon Glass68a24232016-01-18 20:19:17 -070018 return -ENOSYS;
19
Bin Meng06d66af2016-02-01 01:40:42 -080020 return ops->get_spi_base(dev, sbasep);
Simon Glass68a24232016-01-18 20:19:17 -070021}
22
Simon Glass68a24232016-01-18 20:19:17 -070023int pch_set_spi_protect(struct udevice *dev, bool protect)
24{
25 struct pch_ops *ops = pch_get_ops(dev);
26
27 if (!ops->set_spi_protect)
28 return -ENOSYS;
29
30 return ops->set_spi_protect(dev, protect);
31}
32
Bin Meng8fec3e12016-02-01 01:40:43 -080033int pch_get_gpio_base(struct udevice *dev, u32 *gbasep)
34{
35 struct pch_ops *ops = pch_get_ops(dev);
36
37 *gbasep = 0;
38 if (!ops->get_gpio_base)
39 return -ENOSYS;
40
41 return ops->get_gpio_base(dev, gbasep);
42}
43
Bin Mengb9c951d2016-02-01 01:40:45 -080044int pch_get_io_base(struct udevice *dev, u32 *iobasep)
45{
46 struct pch_ops *ops = pch_get_ops(dev);
47
48 *iobasep = 0;
49 if (!ops->get_io_base)
50 return -ENOSYS;
51
52 return ops->get_io_base(dev, iobasep);
53}
54
Simon Glassdbadbb72019-02-16 20:24:51 -070055int pch_ioctl(struct udevice *dev, ulong req, void *data, int size)
56{
57 struct pch_ops *ops = pch_get_ops(dev);
58
59 if (!ops->ioctl)
60 return -ENOSYS;
61
62 return ops->ioctl(dev, req, data, size);
63}
64
Simon Glass68a24232016-01-18 20:19:17 -070065UCLASS_DRIVER(pch) = {
66 .id = UCLASS_PCH,
67 .name = "pch",
Simon Glass3580f6d2021-08-07 07:24:03 -060068#if CONFIG_IS_ENABLED(OF_REAL)
Simon Glass18230342016-07-05 17:10:10 -060069 .post_bind = dm_scan_fdt_dev,
Simon Glassd1642132019-09-25 08:56:43 -060070#endif
Simon Glass68a24232016-01-18 20:19:17 -070071};