1 /* 2 * Copyright (c) 2015 Google, Inc 3 * Written by Simon Glass <sjg@chromium.org> 4 * 5 * SPDX-License-Identifier: GPL-2.0+ 6 */ 7 8 #ifndef __pch_h 9 #define __pch_h 10 11 enum pch_version { 12 PCHV_UNKNOWN, 13 PCHV_7, 14 PCHV_9, 15 }; 16 17 #define PCH_RCBA 0xf0 18 19 #define BIOS_CTRL_BIOSWE BIT(0) 20 21 /* Operations for the Platform Controller Hub */ 22 struct pch_ops { 23 /** 24 * get_sbase() - get the address of SPI base 25 * 26 * @dev: PCH device to check 27 * @sbasep: Returns address of SPI base if available, else 0 28 * @return 0 if OK, -ve on error (e.g. there is no SPI base) 29 */ 30 int (*get_sbase)(struct udevice *dev, ulong *sbasep); 31 32 /** 33 * get_version() - get the PCH version 34 * 35 * @return version, or -ENOSYS if unknown 36 */ 37 enum pch_version (*get_version)(struct udevice *dev); 38 39 /** 40 * set_spi_protect() - set whether SPI flash is protected or not 41 * 42 * @dev: PCH device to adjust 43 * @protect: true to protect, false to unprotect 44 * 45 * @return 0 on success, -ENOSYS if not implemented 46 */ 47 int (*set_spi_protect)(struct udevice *dev, bool protect); 48 }; 49 50 #define pch_get_ops(dev) ((struct pch_ops *)(dev)->driver->ops) 51 52 /** 53 * pch_get_sbase() - get the address of SPI base 54 * 55 * @dev: PCH device to check 56 * @sbasep: Returns address of SPI base if available, else 0 57 * @return 0 if OK, -ve on error (e.g. there is no SPI base) 58 */ 59 int pch_get_sbase(struct udevice *dev, ulong *sbasep); 60 61 /** 62 * pch_get_version() - get the PCH version 63 * 64 * @return version, or -ENOSYS if unknown 65 */ 66 enum pch_version pch_get_version(struct udevice *dev); 67 68 /** 69 * set_spi_protect() - set whether SPI flash is protected or not 70 * 71 * @dev: PCH device to adjust 72 * @protect: true to protect, false to unprotect 73 * 74 * @return 0 on success, -ENOSYS if not implemented 75 */ 76 int pch_set_spi_protect(struct udevice *dev, bool protect); 77 78 #endif 79