Simon Glass | ca831f4 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 1 | /* |
| 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> |
Simon Glass | ca831f4 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 11 | |
| 12 | DECLARE_GLOBAL_DATA_PTR; |
| 13 | |
Bin Meng | 3e389d8 | 2016-02-01 01:40:42 -0800 | [diff] [blame] | 14 | int pch_get_spi_base(struct udevice *dev, ulong *sbasep) |
Simon Glass | ca831f4 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 15 | { |
| 16 | struct pch_ops *ops = pch_get_ops(dev); |
| 17 | |
| 18 | *sbasep = 0; |
Bin Meng | 3e389d8 | 2016-02-01 01:40:42 -0800 | [diff] [blame] | 19 | if (!ops->get_spi_base) |
Simon Glass | ca831f4 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 20 | return -ENOSYS; |
| 21 | |
Bin Meng | 3e389d8 | 2016-02-01 01:40:42 -0800 | [diff] [blame] | 22 | return ops->get_spi_base(dev, sbasep); |
Simon Glass | ca831f4 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 23 | } |
| 24 | |
Simon Glass | ca831f4 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 25 | int pch_set_spi_protect(struct udevice *dev, bool protect) |
| 26 | { |
| 27 | struct pch_ops *ops = pch_get_ops(dev); |
| 28 | |
| 29 | if (!ops->set_spi_protect) |
| 30 | return -ENOSYS; |
| 31 | |
| 32 | return ops->set_spi_protect(dev, protect); |
| 33 | } |
| 34 | |
Bin Meng | 384980c | 2016-02-01 01:40:43 -0800 | [diff] [blame] | 35 | int pch_get_gpio_base(struct udevice *dev, u32 *gbasep) |
| 36 | { |
| 37 | struct pch_ops *ops = pch_get_ops(dev); |
| 38 | |
| 39 | *gbasep = 0; |
| 40 | if (!ops->get_gpio_base) |
| 41 | return -ENOSYS; |
| 42 | |
| 43 | return ops->get_gpio_base(dev, gbasep); |
| 44 | } |
| 45 | |
Bin Meng | 79d4eb6 | 2016-02-01 01:40:45 -0800 | [diff] [blame] | 46 | int pch_get_io_base(struct udevice *dev, u32 *iobasep) |
| 47 | { |
| 48 | struct pch_ops *ops = pch_get_ops(dev); |
| 49 | |
| 50 | *iobasep = 0; |
| 51 | if (!ops->get_io_base) |
| 52 | return -ENOSYS; |
| 53 | |
| 54 | return ops->get_io_base(dev, iobasep); |
| 55 | } |
| 56 | |
Simon Glass | ca831f4 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 57 | UCLASS_DRIVER(pch) = { |
| 58 | .id = UCLASS_PCH, |
| 59 | .name = "pch", |
Simon Glass | 9119548 | 2016-07-05 17:10:10 -0600 | [diff] [blame] | 60 | .post_bind = dm_scan_fdt_dev, |
Simon Glass | ca831f4 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 61 | }; |