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 | |
| 7 | #include <common.h> |
| 8 | #include <dm.h> |
| 9 | #include <pch.h> |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 10 | |
Bin Meng | 06d66af | 2016-02-01 01:40:42 -0800 | [diff] [blame] | 11 | int pch_get_spi_base(struct udevice *dev, ulong *sbasep) |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 12 | { |
| 13 | struct pch_ops *ops = pch_get_ops(dev); |
| 14 | |
| 15 | *sbasep = 0; |
Bin Meng | 06d66af | 2016-02-01 01:40:42 -0800 | [diff] [blame] | 16 | if (!ops->get_spi_base) |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 17 | return -ENOSYS; |
| 18 | |
Bin Meng | 06d66af | 2016-02-01 01:40:42 -0800 | [diff] [blame] | 19 | return ops->get_spi_base(dev, sbasep); |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 20 | } |
| 21 | |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 22 | int 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 Meng | 8fec3e1 | 2016-02-01 01:40:43 -0800 | [diff] [blame] | 32 | int 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 Meng | b9c951d | 2016-02-01 01:40:45 -0800 | [diff] [blame] | 43 | int 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 Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 54 | UCLASS_DRIVER(pch) = { |
| 55 | .id = UCLASS_PCH, |
| 56 | .name = "pch", |
Simon Glass | 1823034 | 2016-07-05 17:10:10 -0600 | [diff] [blame] | 57 | .post_bind = dm_scan_fdt_dev, |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 58 | }; |