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 /* Operations for the Platform Controller Hub */ 18 struct pch_ops { 19 /** 20 * get_sbase() - get the address of SPI base 21 * 22 * @dev: PCH device to check 23 * @sbasep: Returns address of SPI base if available, else 0 24 * @return 0 if OK, -ve on error (e.g. there is no SPI base) 25 */ 26 int (*get_sbase)(struct udevice *dev, ulong *sbasep); 27 28 /** 29 * get_version() - get the PCH version 30 * 31 * @return version, or -ENOSYS if unknown 32 */ 33 enum pch_version (*get_version)(struct udevice *dev); 34 35 /** 36 * set_spi_protect() - set whether SPI flash is protected or not 37 * 38 * @dev: PCH device to adjust 39 * @protect: true to protect, false to unprotect 40 * 41 * @return 0 on success, -ENOSYS if not implemented 42 */ 43 int (*set_spi_protect)(struct udevice *dev, bool protect); 44 }; 45 46 #define pch_get_ops(dev) ((struct pch_ops *)(dev)->driver->ops) 47 48 /** 49 * pch_get_sbase() - get the address of SPI base 50 * 51 * @dev: PCH device to check 52 * @sbasep: Returns address of SPI base if available, else 0 53 * @return 0 if OK, -ve on error (e.g. there is no SPI base) 54 */ 55 int pch_get_sbase(struct udevice *dev, ulong *sbasep); 56 57 /** 58 * pch_get_version() - get the PCH version 59 * 60 * @return version, or -ENOSYS if unknown 61 */ 62 enum pch_version pch_get_version(struct udevice *dev); 63 64 /** 65 * set_spi_protect() - set whether SPI flash is protected or not 66 * 67 * @dev: PCH device to adjust 68 * @protect: true to protect, false to unprotect 69 * 70 * @return 0 on success, -ENOSYS if not implemented 71 */ 72 int pch_set_spi_protect(struct udevice *dev, bool protect); 73 74 #endif 75