blob: b8b62d74acbcef5f2f49903b591191c3fb3f4a26 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass68a24232016-01-18 20:19:17 -07002/*
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
Simon Glass68a24232016-01-18 20:19:17 -07005 */
6
7#ifndef __pch_h
8#define __pch_h
9
Simon Glass567696b2016-01-18 20:19:18 -070010#define PCH_RCBA 0xf0
11
12#define BIOS_CTRL_BIOSWE BIT(0)
13
Simon Glassdbadbb72019-02-16 20:24:51 -070014/* All the supported PCH ioctls */
15enum pch_req_t {
16 PCH_REQ_TEST1, /* Test requests for sandbox driver */
17 PCH_REQ_TEST2,
18 PCH_REQ_TEST3,
19
20 PCH_REQ_COUNT, /* Number of ioctrls supported */
21};
22
23/**
24 * struct pch_ops - Operations for the Platform Controller Hub
25 *
26 * Consider using ioctl() to add rarely used or driver-specific operations.
27 */
Simon Glass68a24232016-01-18 20:19:17 -070028struct pch_ops {
29 /**
Bin Meng06d66af2016-02-01 01:40:42 -080030 * get_spi_base() - get the address of SPI base
Simon Glass68a24232016-01-18 20:19:17 -070031 *
32 * @dev: PCH device to check
33 * @sbasep: Returns address of SPI base if available, else 0
34 * @return 0 if OK, -ve on error (e.g. there is no SPI base)
35 */
Bin Meng06d66af2016-02-01 01:40:42 -080036 int (*get_spi_base)(struct udevice *dev, ulong *sbasep);
Simon Glass68a24232016-01-18 20:19:17 -070037
38 /**
Simon Glass68a24232016-01-18 20:19:17 -070039 * set_spi_protect() - set whether SPI flash is protected or not
40 *
41 * @dev: PCH device to adjust
42 * @protect: true to protect, false to unprotect
43 *
44 * @return 0 on success, -ENOSYS if not implemented
45 */
46 int (*set_spi_protect)(struct udevice *dev, bool protect);
Bin Meng8fec3e12016-02-01 01:40:43 -080047
48 /**
49 * get_gpio_base() - get the address of GPIO base
50 *
51 * @dev: PCH device to check
52 * @gbasep: Returns address of GPIO base if available, else 0
53 * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
54 */
55 int (*get_gpio_base)(struct udevice *dev, u32 *gbasep);
Bin Mengb9c951d2016-02-01 01:40:45 -080056
57 /**
58 * get_io_base() - get the address of IO base
59 *
60 * @dev: PCH device to check
61 * @iobasep: Returns address of IO base if available, else 0
62 * @return 0 if OK, -ve on error (e.g. there is no IO base)
63 */
64 int (*get_io_base)(struct udevice *dev, u32 *iobasep);
Simon Glassdbadbb72019-02-16 20:24:51 -070065
66 /**
67 * ioctl() - perform misc read/write operations
68 *
69 * This is a catch-all operation intended to avoid adding lots of
70 * methods to this uclass, of which few are commonly used. Uncommon
71 * operations that pertain only to a few devices in this uclass should
72 * use this method instead of adding new methods.
73 *
74 * @dev: PCH device to check
75 * @req: PCH request ID
76 * @data: Input/output data
77 * @size: Size of input data (and maximum size of output data)
78 * @return size of output data on sucesss, -ve on error
79 */
80 int (*ioctl)(struct udevice *dev, enum pch_req_t req, void *data,
81 int size);
Simon Glass68a24232016-01-18 20:19:17 -070082};
83
84#define pch_get_ops(dev) ((struct pch_ops *)(dev)->driver->ops)
85
86/**
Bin Meng06d66af2016-02-01 01:40:42 -080087 * pch_get_spi_base() - get the address of SPI base
Simon Glass68a24232016-01-18 20:19:17 -070088 *
89 * @dev: PCH device to check
90 * @sbasep: Returns address of SPI base if available, else 0
91 * @return 0 if OK, -ve on error (e.g. there is no SPI base)
92 */
Bin Meng06d66af2016-02-01 01:40:42 -080093int pch_get_spi_base(struct udevice *dev, ulong *sbasep);
Simon Glass68a24232016-01-18 20:19:17 -070094
95/**
Simon Glass68a24232016-01-18 20:19:17 -070096 * set_spi_protect() - set whether SPI flash is protected or not
97 *
98 * @dev: PCH device to adjust
99 * @protect: true to protect, false to unprotect
100 *
101 * @return 0 on success, -ENOSYS if not implemented
102 */
103int pch_set_spi_protect(struct udevice *dev, bool protect);
104
Bin Meng8fec3e12016-02-01 01:40:43 -0800105/**
106 * pch_get_gpio_base() - get the address of GPIO base
107 *
108 * @dev: PCH device to check
109 * @gbasep: Returns address of GPIO base if available, else 0
110 * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
111 */
112int pch_get_gpio_base(struct udevice *dev, u32 *gbasep);
113
Bin Mengb9c951d2016-02-01 01:40:45 -0800114/**
115 * pch_get_io_base() - get the address of IO base
116 *
117 * @dev: PCH device to check
118 * @iobasep: Returns address of IO base if available, else 0
119 * @return 0 if OK, -ve on error (e.g. there is no IO base)
120 */
121int pch_get_io_base(struct udevice *dev, u32 *iobasep);
122
Simon Glassdbadbb72019-02-16 20:24:51 -0700123/**
124 * pch_ioctl() - perform misc read/write operations
125 *
126 * This is a catch-all operation intended to avoid adding lots of
127 * methods to this uclass, of which few are commonly used. Uncommon
128 * operations that pertain only to a few devices in this uclass should
129 * use this method instead of adding new methods.
130 *
131 * @dev: PCH device to check
132 * @req: PCH request ID
133 * @data: Input/output data
134 * @size: Size of input data (and maximum size of output data)
135 * @return size of output data on sucesss, -ve on error
136 */
137int pch_ioctl(struct udevice *dev, ulong req, void *data, int size);
138
Simon Glass68a24232016-01-18 20:19:17 -0700139#endif