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 | #ifndef __pch_h |
| 8 | #define __pch_h |
| 9 | |
Simon Glass | 567696b | 2016-01-18 20:19:18 -0700 | [diff] [blame] | 10 | #define PCH_RCBA 0xf0 |
| 11 | |
| 12 | #define BIOS_CTRL_BIOSWE BIT(0) |
| 13 | |
Simon Glass | dbadbb7 | 2019-02-16 20:24:51 -0700 | [diff] [blame^] | 14 | /* All the supported PCH ioctls */ |
| 15 | enum pch_req_t { |
| 16 | PCH_REQ_TEST1, /* Test requests for sandbox driver */ |
| 17 | PCH_REQ_TEST2, |
| 18 | PCH_REQ_TEST3, |
| 19 | |
| 20 | PCH_REQ_COUNT, /* Number of ioctrls supported */ |
| 21 | }; |
| 22 | |
| 23 | /** |
| 24 | * struct pch_ops - Operations for the Platform Controller Hub |
| 25 | * |
| 26 | * Consider using ioctl() to add rarely used or driver-specific operations. |
| 27 | */ |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 28 | struct pch_ops { |
| 29 | /** |
Bin Meng | 06d66af | 2016-02-01 01:40:42 -0800 | [diff] [blame] | 30 | * get_spi_base() - get the address of SPI base |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 31 | * |
| 32 | * @dev: PCH device to check |
| 33 | * @sbasep: Returns address of SPI base if available, else 0 |
| 34 | * @return 0 if OK, -ve on error (e.g. there is no SPI base) |
| 35 | */ |
Bin Meng | 06d66af | 2016-02-01 01:40:42 -0800 | [diff] [blame] | 36 | int (*get_spi_base)(struct udevice *dev, ulong *sbasep); |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 37 | |
| 38 | /** |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 39 | * set_spi_protect() - set whether SPI flash is protected or not |
| 40 | * |
| 41 | * @dev: PCH device to adjust |
| 42 | * @protect: true to protect, false to unprotect |
| 43 | * |
| 44 | * @return 0 on success, -ENOSYS if not implemented |
| 45 | */ |
| 46 | int (*set_spi_protect)(struct udevice *dev, bool protect); |
Bin Meng | 8fec3e1 | 2016-02-01 01:40:43 -0800 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * get_gpio_base() - get the address of GPIO base |
| 50 | * |
| 51 | * @dev: PCH device to check |
| 52 | * @gbasep: Returns address of GPIO base if available, else 0 |
| 53 | * @return 0 if OK, -ve on error (e.g. there is no GPIO base) |
| 54 | */ |
| 55 | int (*get_gpio_base)(struct udevice *dev, u32 *gbasep); |
Bin Meng | b9c951d | 2016-02-01 01:40:45 -0800 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * get_io_base() - get the address of IO base |
| 59 | * |
| 60 | * @dev: PCH device to check |
| 61 | * @iobasep: Returns address of IO base if available, else 0 |
| 62 | * @return 0 if OK, -ve on error (e.g. there is no IO base) |
| 63 | */ |
| 64 | int (*get_io_base)(struct udevice *dev, u32 *iobasep); |
Simon Glass | dbadbb7 | 2019-02-16 20:24:51 -0700 | [diff] [blame^] | 65 | |
| 66 | /** |
| 67 | * ioctl() - perform misc read/write operations |
| 68 | * |
| 69 | * This is a catch-all operation intended to avoid adding lots of |
| 70 | * methods to this uclass, of which few are commonly used. Uncommon |
| 71 | * operations that pertain only to a few devices in this uclass should |
| 72 | * use this method instead of adding new methods. |
| 73 | * |
| 74 | * @dev: PCH device to check |
| 75 | * @req: PCH request ID |
| 76 | * @data: Input/output data |
| 77 | * @size: Size of input data (and maximum size of output data) |
| 78 | * @return size of output data on sucesss, -ve on error |
| 79 | */ |
| 80 | int (*ioctl)(struct udevice *dev, enum pch_req_t req, void *data, |
| 81 | int size); |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | #define pch_get_ops(dev) ((struct pch_ops *)(dev)->driver->ops) |
| 85 | |
| 86 | /** |
Bin Meng | 06d66af | 2016-02-01 01:40:42 -0800 | [diff] [blame] | 87 | * pch_get_spi_base() - get the address of SPI base |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 88 | * |
| 89 | * @dev: PCH device to check |
| 90 | * @sbasep: Returns address of SPI base if available, else 0 |
| 91 | * @return 0 if OK, -ve on error (e.g. there is no SPI base) |
| 92 | */ |
Bin Meng | 06d66af | 2016-02-01 01:40:42 -0800 | [diff] [blame] | 93 | int pch_get_spi_base(struct udevice *dev, ulong *sbasep); |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 94 | |
| 95 | /** |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 96 | * set_spi_protect() - set whether SPI flash is protected or not |
| 97 | * |
| 98 | * @dev: PCH device to adjust |
| 99 | * @protect: true to protect, false to unprotect |
| 100 | * |
| 101 | * @return 0 on success, -ENOSYS if not implemented |
| 102 | */ |
| 103 | int pch_set_spi_protect(struct udevice *dev, bool protect); |
| 104 | |
Bin Meng | 8fec3e1 | 2016-02-01 01:40:43 -0800 | [diff] [blame] | 105 | /** |
| 106 | * pch_get_gpio_base() - get the address of GPIO base |
| 107 | * |
| 108 | * @dev: PCH device to check |
| 109 | * @gbasep: Returns address of GPIO base if available, else 0 |
| 110 | * @return 0 if OK, -ve on error (e.g. there is no GPIO base) |
| 111 | */ |
| 112 | int pch_get_gpio_base(struct udevice *dev, u32 *gbasep); |
| 113 | |
Bin Meng | b9c951d | 2016-02-01 01:40:45 -0800 | [diff] [blame] | 114 | /** |
| 115 | * pch_get_io_base() - get the address of IO base |
| 116 | * |
| 117 | * @dev: PCH device to check |
| 118 | * @iobasep: Returns address of IO base if available, else 0 |
| 119 | * @return 0 if OK, -ve on error (e.g. there is no IO base) |
| 120 | */ |
| 121 | int pch_get_io_base(struct udevice *dev, u32 *iobasep); |
| 122 | |
Simon Glass | dbadbb7 | 2019-02-16 20:24:51 -0700 | [diff] [blame^] | 123 | /** |
| 124 | * pch_ioctl() - perform misc read/write operations |
| 125 | * |
| 126 | * This is a catch-all operation intended to avoid adding lots of |
| 127 | * methods to this uclass, of which few are commonly used. Uncommon |
| 128 | * operations that pertain only to a few devices in this uclass should |
| 129 | * use this method instead of adding new methods. |
| 130 | * |
| 131 | * @dev: PCH device to check |
| 132 | * @req: PCH request ID |
| 133 | * @data: Input/output data |
| 134 | * @size: Size of input data (and maximum size of output data) |
| 135 | * @return size of output data on sucesss, -ve on error |
| 136 | */ |
| 137 | int pch_ioctl(struct udevice *dev, ulong req, void *data, int size); |
| 138 | |
Simon Glass | 68a2423 | 2016-01-18 20:19:17 -0700 | [diff] [blame] | 139 | #endif |