xref: /rk3399_rockchip-uboot/include/pch.h (revision 79d4eb627cffbc3ab7cefdd623fa39fefaaedbe7)
1ca831f49SSimon Glass /*
2ca831f49SSimon Glass  * Copyright (c) 2015 Google, Inc
3ca831f49SSimon Glass  * Written by Simon Glass <sjg@chromium.org>
4ca831f49SSimon Glass  *
5ca831f49SSimon Glass  * SPDX-License-Identifier:	GPL-2.0+
6ca831f49SSimon Glass  */
7ca831f49SSimon Glass 
8ca831f49SSimon Glass #ifndef __pch_h
9ca831f49SSimon Glass #define __pch_h
10ca831f49SSimon Glass 
111ff4f321SSimon Glass #define PCH_RCBA		0xf0
121ff4f321SSimon Glass 
131ff4f321SSimon Glass #define BIOS_CTRL_BIOSWE	BIT(0)
141ff4f321SSimon Glass 
15ca831f49SSimon Glass /* Operations for the Platform Controller Hub */
16ca831f49SSimon Glass struct pch_ops {
17ca831f49SSimon Glass 	/**
183e389d8bSBin Meng 	 * get_spi_base() - get the address of SPI base
19ca831f49SSimon Glass 	 *
20ca831f49SSimon Glass 	 * @dev:	PCH device to check
21ca831f49SSimon Glass 	 * @sbasep:	Returns address of SPI base if available, else 0
22ca831f49SSimon Glass 	 * @return 0 if OK, -ve on error (e.g. there is no SPI base)
23ca831f49SSimon Glass 	 */
243e389d8bSBin Meng 	int (*get_spi_base)(struct udevice *dev, ulong *sbasep);
25ca831f49SSimon Glass 
26ca831f49SSimon Glass 	/**
27ca831f49SSimon Glass 	 * set_spi_protect() - set whether SPI flash is protected or not
28ca831f49SSimon Glass 	 *
29ca831f49SSimon Glass 	 * @dev:	PCH device to adjust
30ca831f49SSimon Glass 	 * @protect:	true to protect, false to unprotect
31ca831f49SSimon Glass 	 *
32ca831f49SSimon Glass 	 * @return 0 on success, -ENOSYS if not implemented
33ca831f49SSimon Glass 	 */
34ca831f49SSimon Glass 	int (*set_spi_protect)(struct udevice *dev, bool protect);
35384980c6SBin Meng 
36384980c6SBin Meng 	/**
37384980c6SBin Meng 	 * get_gpio_base() - get the address of GPIO base
38384980c6SBin Meng 	 *
39384980c6SBin Meng 	 * @dev:	PCH device to check
40384980c6SBin Meng 	 * @gbasep:	Returns address of GPIO base if available, else 0
41384980c6SBin Meng 	 * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
42384980c6SBin Meng 	 */
43384980c6SBin Meng 	int (*get_gpio_base)(struct udevice *dev, u32 *gbasep);
44*79d4eb62SBin Meng 
45*79d4eb62SBin Meng 	/**
46*79d4eb62SBin Meng 	 * get_io_base() - get the address of IO base
47*79d4eb62SBin Meng 	 *
48*79d4eb62SBin Meng 	 * @dev:	PCH device to check
49*79d4eb62SBin Meng 	 * @iobasep:	Returns address of IO base if available, else 0
50*79d4eb62SBin Meng 	 * @return 0 if OK, -ve on error (e.g. there is no IO base)
51*79d4eb62SBin Meng 	 */
52*79d4eb62SBin Meng 	int (*get_io_base)(struct udevice *dev, u32 *iobasep);
53ca831f49SSimon Glass };
54ca831f49SSimon Glass 
55ca831f49SSimon Glass #define pch_get_ops(dev)        ((struct pch_ops *)(dev)->driver->ops)
56ca831f49SSimon Glass 
57ca831f49SSimon Glass /**
583e389d8bSBin Meng  * pch_get_spi_base() - get the address of SPI base
59ca831f49SSimon Glass  *
60ca831f49SSimon Glass  * @dev:	PCH device to check
61ca831f49SSimon Glass  * @sbasep:	Returns address of SPI base if available, else 0
62ca831f49SSimon Glass  * @return 0 if OK, -ve on error (e.g. there is no SPI base)
63ca831f49SSimon Glass  */
643e389d8bSBin Meng int pch_get_spi_base(struct udevice *dev, ulong *sbasep);
65ca831f49SSimon Glass 
66ca831f49SSimon Glass /**
67ca831f49SSimon Glass  * set_spi_protect() - set whether SPI flash is protected or not
68ca831f49SSimon Glass  *
69ca831f49SSimon Glass  * @dev:	PCH device to adjust
70ca831f49SSimon Glass  * @protect:	true to protect, false to unprotect
71ca831f49SSimon Glass  *
72ca831f49SSimon Glass  * @return 0 on success, -ENOSYS if not implemented
73ca831f49SSimon Glass  */
74ca831f49SSimon Glass int pch_set_spi_protect(struct udevice *dev, bool protect);
75ca831f49SSimon Glass 
76384980c6SBin Meng /**
77384980c6SBin Meng  * pch_get_gpio_base() - get the address of GPIO base
78384980c6SBin Meng  *
79384980c6SBin Meng  * @dev:	PCH device to check
80384980c6SBin Meng  * @gbasep:	Returns address of GPIO base if available, else 0
81384980c6SBin Meng  * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
82384980c6SBin Meng  */
83384980c6SBin Meng int pch_get_gpio_base(struct udevice *dev, u32 *gbasep);
84384980c6SBin Meng 
85*79d4eb62SBin Meng /**
86*79d4eb62SBin Meng  * pch_get_io_base() - get the address of IO base
87*79d4eb62SBin Meng  *
88*79d4eb62SBin Meng  * @dev:	PCH device to check
89*79d4eb62SBin Meng  * @iobasep:	Returns address of IO base if available, else 0
90*79d4eb62SBin Meng  * @return 0 if OK, -ve on error (e.g. there is no IO base)
91*79d4eb62SBin Meng  */
92*79d4eb62SBin Meng int pch_get_io_base(struct udevice *dev, u32 *iobasep);
93*79d4eb62SBin Meng 
94ca831f49SSimon Glass #endif
95