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