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