Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2015 Google, Inc |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
Patrick Delaunay | 8131335 | 2021-04-27 11:02:19 +0200 | [diff] [blame] | 7 | #define LOG_CATEGORY UCLASS_PCH |
| 8 | |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 9 | #include <common.h> |
| 10 | #include <dm.h> |
| 11 | #include <pch.h> |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 12 | |
Bin Meng | 06d66af | 2016-02-01 01:40:42 -0800 | [diff] [blame] | 13 | int pch_get_spi_base(struct udevice *dev, ulong *sbasep) |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 14 | { |
| 15 | struct pch_ops *ops = pch_get_ops(dev); |
| 16 | |
| 17 | *sbasep = 0; |
Bin Meng | 06d66af | 2016-02-01 01:40:42 -0800 | [diff] [blame] | 18 | if (!ops->get_spi_base) |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 19 | return -ENOSYS; |
| 20 | |
Bin Meng | 06d66af | 2016-02-01 01:40:42 -0800 | [diff] [blame] | 21 | return ops->get_spi_base(dev, sbasep); |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 22 | } |
| 23 | |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 24 | int pch_set_spi_protect(struct udevice *dev, bool protect) |
| 25 | { |
| 26 | struct pch_ops *ops = pch_get_ops(dev); |
| 27 | |
| 28 | if (!ops->set_spi_protect) |
| 29 | return -ENOSYS; |
| 30 | |
| 31 | return ops->set_spi_protect(dev, protect); |
| 32 | } |
| 33 | |
Bin Meng | 8fec3e1 | 2016-02-01 01:40:43 -0800 | [diff] [blame] | 34 | int pch_get_gpio_base(struct udevice *dev, u32 *gbasep) |
| 35 | { |
| 36 | struct pch_ops *ops = pch_get_ops(dev); |
| 37 | |
| 38 | *gbasep = 0; |
| 39 | if (!ops->get_gpio_base) |
| 40 | return -ENOSYS; |
| 41 | |
| 42 | return ops->get_gpio_base(dev, gbasep); |
| 43 | } |
| 44 | |
Bin Meng | b9c951d | 2016-02-01 01:40:45 -0800 | [diff] [blame] | 45 | int pch_get_io_base(struct udevice *dev, u32 *iobasep) |
| 46 | { |
| 47 | struct pch_ops *ops = pch_get_ops(dev); |
| 48 | |
| 49 | *iobasep = 0; |
| 50 | if (!ops->get_io_base) |
| 51 | return -ENOSYS; |
| 52 | |
| 53 | return ops->get_io_base(dev, iobasep); |
| 54 | } |
| 55 | |
Simon Glass | dbadbb7 | 2019-02-16 20:24:51 -0700 | [diff] [blame] | 56 | int pch_ioctl(struct udevice *dev, ulong req, void *data, int size) |
| 57 | { |
| 58 | struct pch_ops *ops = pch_get_ops(dev); |
| 59 | |
| 60 | if (!ops->ioctl) |
| 61 | return -ENOSYS; |
| 62 | |
| 63 | return ops->ioctl(dev, req, data, size); |
| 64 | } |
| 65 | |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 66 | UCLASS_DRIVER(pch) = { |
| 67 | .id = UCLASS_PCH, |
| 68 | .name = "pch", |
Simon Glass | d164213 | 2019-09-25 08:56:43 -0600 | [diff] [blame] | 69 | #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) |
Simon Glass | 1823034 | 2016-07-05 17:10:10 -0600 | [diff] [blame] | 70 | .post_bind = dm_scan_fdt_dev, |
Simon Glass | d164213 | 2019-09-25 08:56:43 -0600 | [diff] [blame] | 71 | #endif |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 72 | }; |