1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
10 #include <linux/bitops.h>
13 #define BIOS_CTRL_BIOSWE BIT(0)
15 /* All the supported PCH ioctls */
17 /* Returns HDA config info if Azalia V1CTL enabled, -ENOENT if not */
20 /* Fills out a struct pch_pmbase_info if available */
23 PCH_REQ_TEST1, /* Test requests for sandbox driver */
27 PCH_REQ_COUNT, /* Number of ioctrls supported */
31 * struct pch_pmbase_info - Information filled in by PCH_REQ_PMBASE_INFO
33 * @pmbase: IO address of power-management controller
34 * @gpio0_en_ofs: Offset of GPIO0 enable register
35 * @pm1_sts_ofs: Offset of status register
36 * @pm1_cnt_ofs: Offset of control register
38 struct pch_pmbase_info {
46 * struct pch_ops - Operations for the Platform Controller Hub
48 * Consider using ioctl() to add rarely used or driver-specific operations.
52 * get_spi_base() - get the address of SPI base
54 * @dev: PCH device to check
55 * @sbasep: Returns address of SPI base if available, else 0
56 * @return 0 if OK, -ve on error (e.g. there is no SPI base)
58 int (*get_spi_base)(struct udevice *dev, ulong *sbasep);
61 * set_spi_protect() - set whether SPI flash is protected or not
63 * @dev: PCH device to adjust
64 * @protect: true to protect, false to unprotect
66 * @return 0 on success, -ENOSYS if not implemented
68 int (*set_spi_protect)(struct udevice *dev, bool protect);
71 * get_gpio_base() - get the address of GPIO base
73 * @dev: PCH device to check
74 * @gbasep: Returns address of GPIO base if available, else 0
75 * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
77 int (*get_gpio_base)(struct udevice *dev, u32 *gbasep);
80 * get_io_base() - get the address of IO base
82 * @dev: PCH device to check
83 * @iobasep: Returns address of IO base if available, else 0
84 * @return 0 if OK, -ve on error (e.g. there is no IO base)
86 int (*get_io_base)(struct udevice *dev, u32 *iobasep);
89 * ioctl() - perform misc read/write operations
91 * This is a catch-all operation intended to avoid adding lots of
92 * methods to this uclass, of which few are commonly used. Uncommon
93 * operations that pertain only to a few devices in this uclass should
94 * use this method instead of adding new methods.
96 * @dev: PCH device to check
97 * @req: PCH request ID
98 * @data: Input/output data
99 * @size: Size of input data (and maximum size of output data)
100 * @return size of output data on sucesss, -ve on error
102 int (*ioctl)(struct udevice *dev, enum pch_req_t req, void *data,
106 #define pch_get_ops(dev) ((struct pch_ops *)(dev)->driver->ops)
109 * pch_get_spi_base() - get the address of SPI base
111 * @dev: PCH device to check
112 * @sbasep: Returns address of SPI base if available, else 0
113 * Return: 0 if OK, -ve on error (e.g. there is no SPI base)
115 int pch_get_spi_base(struct udevice *dev, ulong *sbasep);
118 * set_spi_protect() - set whether SPI flash is protected or not
120 * @dev: PCH device to adjust
121 * @protect: true to protect, false to unprotect
123 * Return: 0 on success, -ENOSYS if not implemented
125 int pch_set_spi_protect(struct udevice *dev, bool protect);
128 * pch_get_gpio_base() - get the address of GPIO base
130 * @dev: PCH device to check
131 * @gbasep: Returns address of GPIO base if available, else 0
132 * Return: 0 if OK, -ve on error (e.g. there is no GPIO base)
134 int pch_get_gpio_base(struct udevice *dev, u32 *gbasep);
137 * pch_get_io_base() - get the address of IO base
139 * @dev: PCH device to check
140 * @iobasep: Returns address of IO base if available, else 0
141 * Return: 0 if OK, -ve on error (e.g. there is no IO base)
143 int pch_get_io_base(struct udevice *dev, u32 *iobasep);
146 * pch_ioctl() - perform misc read/write operations
148 * This is a catch-all operation intended to avoid adding lots of
149 * methods to this uclass, of which few are commonly used. Uncommon
150 * operations that pertain only to a few devices in this uclass should
151 * use this method instead of adding new methods.
153 * @dev: PCH device to check
154 * @req: PCH request ID
155 * @data: Input/output data
156 * @size: Size of input data (and maximum size of output data)
157 * Return: size of output data on sucesss, -ve on error
159 int pch_ioctl(struct udevice *dev, ulong req, void *data, int size);