Simon Glass | 68a2423 | 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> |
| 11 | #include <dm/root.h> |
| 12 | |
| 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
Bin Meng | 06d66af | 2016-02-01 01:40:42 -0800 | [diff] [blame] | 15 | int pch_get_spi_base(struct udevice *dev, ulong *sbasep) |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 16 | { |
| 17 | struct pch_ops *ops = pch_get_ops(dev); |
| 18 | |
| 19 | *sbasep = 0; |
Bin Meng | 06d66af | 2016-02-01 01:40:42 -0800 | [diff] [blame] | 20 | if (!ops->get_spi_base) |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 21 | return -ENOSYS; |
| 22 | |
Bin Meng | 06d66af | 2016-02-01 01:40:42 -0800 | [diff] [blame] | 23 | return ops->get_spi_base(dev, sbasep); |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 24 | } |
| 25 | |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 26 | int pch_set_spi_protect(struct udevice *dev, bool protect) |
| 27 | { |
| 28 | struct pch_ops *ops = pch_get_ops(dev); |
| 29 | |
| 30 | if (!ops->set_spi_protect) |
| 31 | return -ENOSYS; |
| 32 | |
| 33 | return ops->set_spi_protect(dev, protect); |
| 34 | } |
| 35 | |
Bin Meng | 8fec3e1 | 2016-02-01 01:40:43 -0800 | [diff] [blame] | 36 | int pch_get_gpio_base(struct udevice *dev, u32 *gbasep) |
| 37 | { |
| 38 | struct pch_ops *ops = pch_get_ops(dev); |
| 39 | |
| 40 | *gbasep = 0; |
| 41 | if (!ops->get_gpio_base) |
| 42 | return -ENOSYS; |
| 43 | |
| 44 | return ops->get_gpio_base(dev, gbasep); |
| 45 | } |
| 46 | |
Bin Meng | b9c951d | 2016-02-01 01:40:45 -0800 | [diff] [blame] | 47 | int pch_get_io_base(struct udevice *dev, u32 *iobasep) |
| 48 | { |
| 49 | struct pch_ops *ops = pch_get_ops(dev); |
| 50 | |
| 51 | *iobasep = 0; |
| 52 | if (!ops->get_io_base) |
| 53 | return -ENOSYS; |
| 54 | |
| 55 | return ops->get_io_base(dev, iobasep); |
| 56 | } |
| 57 | |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 58 | static int pch_uclass_post_bind(struct udevice *bus) |
| 59 | { |
| 60 | /* |
| 61 | * Scan the device tree for devices |
| 62 | * |
| 63 | * Before relocation, only bind devices marked for pre-relocation |
| 64 | * use. |
| 65 | */ |
| 66 | return dm_scan_fdt_node(bus, gd->fdt_blob, bus->of_offset, |
| 67 | gd->flags & GD_FLG_RELOC ? false : true); |
| 68 | } |
| 69 | |
| 70 | UCLASS_DRIVER(pch) = { |
| 71 | .id = UCLASS_PCH, |
| 72 | .name = "pch", |
| 73 | .post_bind = pch_uclass_post_bind, |
| 74 | }; |