183d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */ 2ca831f49SSimon Glass /* 3ca831f49SSimon Glass * Copyright (c) 2015 Google, Inc 4ca831f49SSimon Glass * Written by Simon Glass <sjg@chromium.org> 5ca831f49SSimon Glass */ 6ca831f49SSimon Glass 7ca831f49SSimon Glass #ifndef __pch_h 8ca831f49SSimon Glass #define __pch_h 9ca831f49SSimon Glass 101ff4f321SSimon Glass #define PCH_RCBA 0xf0 111ff4f321SSimon Glass 121ff4f321SSimon Glass #define BIOS_CTRL_BIOSWE BIT(0) 131ff4f321SSimon Glass 141260f8c0SSimon Glass /* All the supported PCH ioctls */ 151260f8c0SSimon Glass enum pch_req_t { 16*67b0cda7SSimon Glass /* Returns HDA config info if Azalia V1CTL enabled, -ENOENT if not */ 17*67b0cda7SSimon Glass PCH_REQ_HDA_CONFIG, 18*67b0cda7SSimon Glass 191260f8c0SSimon Glass PCH_REQ_TEST1, /* Test requests for sandbox driver */ 201260f8c0SSimon Glass PCH_REQ_TEST2, 211260f8c0SSimon Glass PCH_REQ_TEST3, 221260f8c0SSimon Glass 231260f8c0SSimon Glass PCH_REQ_COUNT, /* Number of ioctrls supported */ 241260f8c0SSimon Glass }; 251260f8c0SSimon Glass 261260f8c0SSimon Glass /** 271260f8c0SSimon Glass * struct pch_ops - Operations for the Platform Controller Hub 281260f8c0SSimon Glass * 291260f8c0SSimon Glass * Consider using ioctl() to add rarely used or driver-specific operations. 301260f8c0SSimon Glass */ 31ca831f49SSimon Glass struct pch_ops { 32ca831f49SSimon Glass /** 333e389d8bSBin Meng * get_spi_base() - get the address of SPI base 34ca831f49SSimon Glass * 35ca831f49SSimon Glass * @dev: PCH device to check 36ca831f49SSimon Glass * @sbasep: Returns address of SPI base if available, else 0 37ca831f49SSimon Glass * @return 0 if OK, -ve on error (e.g. there is no SPI base) 38ca831f49SSimon Glass */ 393e389d8bSBin Meng int (*get_spi_base)(struct udevice *dev, ulong *sbasep); 40ca831f49SSimon Glass 41ca831f49SSimon Glass /** 42ca831f49SSimon Glass * set_spi_protect() - set whether SPI flash is protected or not 43ca831f49SSimon Glass * 44ca831f49SSimon Glass * @dev: PCH device to adjust 45ca831f49SSimon Glass * @protect: true to protect, false to unprotect 46ca831f49SSimon Glass * 47ca831f49SSimon Glass * @return 0 on success, -ENOSYS if not implemented 48ca831f49SSimon Glass */ 49ca831f49SSimon Glass int (*set_spi_protect)(struct udevice *dev, bool protect); 50384980c6SBin Meng 51384980c6SBin Meng /** 52384980c6SBin Meng * get_gpio_base() - get the address of GPIO base 53384980c6SBin Meng * 54384980c6SBin Meng * @dev: PCH device to check 55384980c6SBin Meng * @gbasep: Returns address of GPIO base if available, else 0 56384980c6SBin Meng * @return 0 if OK, -ve on error (e.g. there is no GPIO base) 57384980c6SBin Meng */ 58384980c6SBin Meng int (*get_gpio_base)(struct udevice *dev, u32 *gbasep); 5979d4eb62SBin Meng 6079d4eb62SBin Meng /** 6179d4eb62SBin Meng * get_io_base() - get the address of IO base 6279d4eb62SBin Meng * 6379d4eb62SBin Meng * @dev: PCH device to check 6479d4eb62SBin Meng * @iobasep: Returns address of IO base if available, else 0 6579d4eb62SBin Meng * @return 0 if OK, -ve on error (e.g. there is no IO base) 6679d4eb62SBin Meng */ 6779d4eb62SBin Meng int (*get_io_base)(struct udevice *dev, u32 *iobasep); 681260f8c0SSimon Glass 691260f8c0SSimon Glass /** 701260f8c0SSimon Glass * ioctl() - perform misc read/write operations 711260f8c0SSimon Glass * 721260f8c0SSimon Glass * This is a catch-all operation intended to avoid adding lots of 731260f8c0SSimon Glass * methods to this uclass, of which few are commonly used. Uncommon 741260f8c0SSimon Glass * operations that pertain only to a few devices in this uclass should 751260f8c0SSimon Glass * use this method instead of adding new methods. 761260f8c0SSimon Glass * 771260f8c0SSimon Glass * @dev: PCH device to check 781260f8c0SSimon Glass * @req: PCH request ID 791260f8c0SSimon Glass * @data: Input/output data 801260f8c0SSimon Glass * @size: Size of input data (and maximum size of output data) 811260f8c0SSimon Glass * @return size of output data on sucesss, -ve on error 821260f8c0SSimon Glass */ 831260f8c0SSimon Glass int (*ioctl)(struct udevice *dev, enum pch_req_t req, void *data, 841260f8c0SSimon Glass int size); 85ca831f49SSimon Glass }; 86ca831f49SSimon Glass 87ca831f49SSimon Glass #define pch_get_ops(dev) ((struct pch_ops *)(dev)->driver->ops) 88ca831f49SSimon Glass 89ca831f49SSimon Glass /** 903e389d8bSBin Meng * pch_get_spi_base() - get the address of SPI base 91ca831f49SSimon Glass * 92ca831f49SSimon Glass * @dev: PCH device to check 93ca831f49SSimon Glass * @sbasep: Returns address of SPI base if available, else 0 94ca831f49SSimon Glass * @return 0 if OK, -ve on error (e.g. there is no SPI base) 95ca831f49SSimon Glass */ 963e389d8bSBin Meng int pch_get_spi_base(struct udevice *dev, ulong *sbasep); 97ca831f49SSimon Glass 98ca831f49SSimon Glass /** 99ca831f49SSimon Glass * set_spi_protect() - set whether SPI flash is protected or not 100ca831f49SSimon Glass * 101ca831f49SSimon Glass * @dev: PCH device to adjust 102ca831f49SSimon Glass * @protect: true to protect, false to unprotect 103ca831f49SSimon Glass * 104ca831f49SSimon Glass * @return 0 on success, -ENOSYS if not implemented 105ca831f49SSimon Glass */ 106ca831f49SSimon Glass int pch_set_spi_protect(struct udevice *dev, bool protect); 107ca831f49SSimon Glass 108384980c6SBin Meng /** 109384980c6SBin Meng * pch_get_gpio_base() - get the address of GPIO base 110384980c6SBin Meng * 111384980c6SBin Meng * @dev: PCH device to check 112384980c6SBin Meng * @gbasep: Returns address of GPIO base if available, else 0 113384980c6SBin Meng * @return 0 if OK, -ve on error (e.g. there is no GPIO base) 114384980c6SBin Meng */ 115384980c6SBin Meng int pch_get_gpio_base(struct udevice *dev, u32 *gbasep); 116384980c6SBin Meng 11779d4eb62SBin Meng /** 11879d4eb62SBin Meng * pch_get_io_base() - get the address of IO base 11979d4eb62SBin Meng * 12079d4eb62SBin Meng * @dev: PCH device to check 12179d4eb62SBin Meng * @iobasep: Returns address of IO base if available, else 0 12279d4eb62SBin Meng * @return 0 if OK, -ve on error (e.g. there is no IO base) 12379d4eb62SBin Meng */ 12479d4eb62SBin Meng int pch_get_io_base(struct udevice *dev, u32 *iobasep); 12579d4eb62SBin Meng 1261260f8c0SSimon Glass /** 1271260f8c0SSimon Glass * pch_ioctl() - perform misc read/write operations 1281260f8c0SSimon Glass * 1291260f8c0SSimon Glass * This is a catch-all operation intended to avoid adding lots of 1301260f8c0SSimon Glass * methods to this uclass, of which few are commonly used. Uncommon 1311260f8c0SSimon Glass * operations that pertain only to a few devices in this uclass should 1321260f8c0SSimon Glass * use this method instead of adding new methods. 1331260f8c0SSimon Glass * 1341260f8c0SSimon Glass * @dev: PCH device to check 1351260f8c0SSimon Glass * @req: PCH request ID 1361260f8c0SSimon Glass * @data: Input/output data 1371260f8c0SSimon Glass * @size: Size of input data (and maximum size of output data) 1381260f8c0SSimon Glass * @return size of output data on sucesss, -ve on error 1391260f8c0SSimon Glass */ 1401260f8c0SSimon Glass int pch_ioctl(struct udevice *dev, ulong req, void *data, int size); 1411260f8c0SSimon Glass 142ca831f49SSimon Glass #endif 143