1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
12 #define BIOS_CTRL_BIOSWE BIT(0)
14 /* All the supported PCH ioctls */
16 /* Returns HDA config info if Azalia V1CTL enabled, -ENOENT if not */
19 /* Fills out a struct pch_pmbase_info if available */
22 PCH_REQ_TEST1, /* Test requests for sandbox driver */
26 PCH_REQ_COUNT, /* Number of ioctrls supported */
30 * struct pch_pmbase_info - Information filled in by PCH_REQ_PMBASE_INFO
32 * @pmbase: IO address of power-management controller
33 * @gpio0_en_ofs: Offset of GPIO0 enable register
34 * @pm1_sts_ofs: Offset of status register
35 * @pm1_cnt_ofs: Offset of control register
37 struct pch_pmbase_info {
45 * struct pch_ops - Operations for the Platform Controller Hub
47 * Consider using ioctl() to add rarely used or driver-specific operations.
51 * get_spi_base() - get the address of SPI base
53 * @dev: PCH device to check
54 * @sbasep: Returns address of SPI base if available, else 0
55 * @return 0 if OK, -ve on error (e.g. there is no SPI base)
57 int (*get_spi_base)(struct udevice *dev, ulong *sbasep);
60 * set_spi_protect() - set whether SPI flash is protected or not
62 * @dev: PCH device to adjust
63 * @protect: true to protect, false to unprotect
65 * @return 0 on success, -ENOSYS if not implemented
67 int (*set_spi_protect)(struct udevice *dev, bool protect);
70 * get_gpio_base() - get the address of GPIO base
72 * @dev: PCH device to check
73 * @gbasep: Returns address of GPIO base if available, else 0
74 * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
76 int (*get_gpio_base)(struct udevice *dev, u32 *gbasep);
79 * get_io_base() - get the address of IO base
81 * @dev: PCH device to check
82 * @iobasep: Returns address of IO base if available, else 0
83 * @return 0 if OK, -ve on error (e.g. there is no IO base)
85 int (*get_io_base)(struct udevice *dev, u32 *iobasep);
88 * ioctl() - perform misc read/write operations
90 * This is a catch-all operation intended to avoid adding lots of
91 * methods to this uclass, of which few are commonly used. Uncommon
92 * operations that pertain only to a few devices in this uclass should
93 * use this method instead of adding new methods.
95 * @dev: PCH device to check
96 * @req: PCH request ID
97 * @data: Input/output data
98 * @size: Size of input data (and maximum size of output data)
99 * @return size of output data on sucesss, -ve on error
101 int (*ioctl)(struct udevice *dev, enum pch_req_t req, void *data,
105 #define pch_get_ops(dev) ((struct pch_ops *)(dev)->driver->ops)
108 * pch_get_spi_base() - get the address of SPI base
110 * @dev: PCH device to check
111 * @sbasep: Returns address of SPI base if available, else 0
112 * @return 0 if OK, -ve on error (e.g. there is no SPI base)
114 int pch_get_spi_base(struct udevice *dev, ulong *sbasep);
117 * set_spi_protect() - set whether SPI flash is protected or not
119 * @dev: PCH device to adjust
120 * @protect: true to protect, false to unprotect
122 * @return 0 on success, -ENOSYS if not implemented
124 int pch_set_spi_protect(struct udevice *dev, bool protect);
127 * pch_get_gpio_base() - get the address of GPIO base
129 * @dev: PCH device to check
130 * @gbasep: Returns address of GPIO base if available, else 0
131 * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
133 int pch_get_gpio_base(struct udevice *dev, u32 *gbasep);
136 * pch_get_io_base() - get the address of IO base
138 * @dev: PCH device to check
139 * @iobasep: Returns address of IO base if available, else 0
140 * @return 0 if OK, -ve on error (e.g. there is no IO base)
142 int pch_get_io_base(struct udevice *dev, u32 *iobasep);
145 * pch_ioctl() - perform misc read/write operations
147 * This is a catch-all operation intended to avoid adding lots of
148 * methods to this uclass, of which few are commonly used. Uncommon
149 * operations that pertain only to a few devices in this uclass should
150 * use this method instead of adding new methods.
152 * @dev: PCH device to check
153 * @req: PCH request ID
154 * @data: Input/output data
155 * @size: Size of input data (and maximum size of output data)
156 * @return size of output data on sucesss, -ve on error
158 int pch_ioctl(struct udevice *dev, ulong req, void *data, int size);