blob: 046a5fde3abd65c4f17a0fd5843db9e8e51066b4 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glassca831f42016-01-18 20:19:17 -07002/*
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
Simon Glassca831f42016-01-18 20:19:17 -07005 */
6
7#ifndef __pch_h
8#define __pch_h
9
Simon Glass1ff4f322016-01-18 20:19:18 -070010#define PCH_RCBA 0xf0
11
12#define BIOS_CTRL_BIOSWE BIT(0)
13
Simon Glass1260f8c2019-02-16 20:24:51 -070014/* All the supported PCH ioctls */
15enum pch_req_t {
Simon Glass67b0cda2019-02-16 20:24:52 -070016 /* Returns HDA config info if Azalia V1CTL enabled, -ENOENT if not */
17 PCH_REQ_HDA_CONFIG,
18
Simon Glass1260f8c2019-02-16 20:24:51 -070019 PCH_REQ_TEST1, /* Test requests for sandbox driver */
20 PCH_REQ_TEST2,
21 PCH_REQ_TEST3,
22
23 PCH_REQ_COUNT, /* Number of ioctrls supported */
24};
25
26/**
27 * struct pch_ops - Operations for the Platform Controller Hub
28 *
29 * Consider using ioctl() to add rarely used or driver-specific operations.
30 */
Simon Glassca831f42016-01-18 20:19:17 -070031struct pch_ops {
32 /**
Bin Meng3e389d82016-02-01 01:40:42 -080033 * get_spi_base() - get the address of SPI base
Simon Glassca831f42016-01-18 20:19:17 -070034 *
35 * @dev: PCH device to check
36 * @sbasep: Returns address of SPI base if available, else 0
37 * @return 0 if OK, -ve on error (e.g. there is no SPI base)
38 */
Bin Meng3e389d82016-02-01 01:40:42 -080039 int (*get_spi_base)(struct udevice *dev, ulong *sbasep);
Simon Glassca831f42016-01-18 20:19:17 -070040
41 /**
Simon Glassca831f42016-01-18 20:19:17 -070042 * set_spi_protect() - set whether SPI flash is protected or not
43 *
44 * @dev: PCH device to adjust
45 * @protect: true to protect, false to unprotect
46 *
47 * @return 0 on success, -ENOSYS if not implemented
48 */
49 int (*set_spi_protect)(struct udevice *dev, bool protect);
Bin Meng384980c2016-02-01 01:40:43 -080050
51 /**
52 * get_gpio_base() - get the address of GPIO base
53 *
54 * @dev: PCH device to check
55 * @gbasep: Returns address of GPIO base if available, else 0
56 * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
57 */
58 int (*get_gpio_base)(struct udevice *dev, u32 *gbasep);
Bin Meng79d4eb62016-02-01 01:40:45 -080059
60 /**
61 * get_io_base() - get the address of IO base
62 *
63 * @dev: PCH device to check
64 * @iobasep: Returns address of IO base if available, else 0
65 * @return 0 if OK, -ve on error (e.g. there is no IO base)
66 */
67 int (*get_io_base)(struct udevice *dev, u32 *iobasep);
Simon Glass1260f8c2019-02-16 20:24:51 -070068
69 /**
70 * ioctl() - perform misc read/write operations
71 *
72 * This is a catch-all operation intended to avoid adding lots of
73 * methods to this uclass, of which few are commonly used. Uncommon
74 * operations that pertain only to a few devices in this uclass should
75 * use this method instead of adding new methods.
76 *
77 * @dev: PCH device to check
78 * @req: PCH request ID
79 * @data: Input/output data
80 * @size: Size of input data (and maximum size of output data)
81 * @return size of output data on sucesss, -ve on error
82 */
83 int (*ioctl)(struct udevice *dev, enum pch_req_t req, void *data,
84 int size);
Simon Glassca831f42016-01-18 20:19:17 -070085};
86
87#define pch_get_ops(dev) ((struct pch_ops *)(dev)->driver->ops)
88
89/**
Bin Meng3e389d82016-02-01 01:40:42 -080090 * pch_get_spi_base() - get the address of SPI base
Simon Glassca831f42016-01-18 20:19:17 -070091 *
92 * @dev: PCH device to check
93 * @sbasep: Returns address of SPI base if available, else 0
94 * @return 0 if OK, -ve on error (e.g. there is no SPI base)
95 */
Bin Meng3e389d82016-02-01 01:40:42 -080096int pch_get_spi_base(struct udevice *dev, ulong *sbasep);
Simon Glassca831f42016-01-18 20:19:17 -070097
98/**
Simon Glassca831f42016-01-18 20:19:17 -070099 * set_spi_protect() - set whether SPI flash is protected or not
100 *
101 * @dev: PCH device to adjust
102 * @protect: true to protect, false to unprotect
103 *
104 * @return 0 on success, -ENOSYS if not implemented
105 */
106int pch_set_spi_protect(struct udevice *dev, bool protect);
107
Bin Meng384980c2016-02-01 01:40:43 -0800108/**
109 * pch_get_gpio_base() - get the address of GPIO base
110 *
111 * @dev: PCH device to check
112 * @gbasep: Returns address of GPIO base if available, else 0
113 * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
114 */
115int pch_get_gpio_base(struct udevice *dev, u32 *gbasep);
116
Bin Meng79d4eb62016-02-01 01:40:45 -0800117/**
118 * pch_get_io_base() - get the address of IO base
119 *
120 * @dev: PCH device to check
121 * @iobasep: Returns address of IO base if available, else 0
122 * @return 0 if OK, -ve on error (e.g. there is no IO base)
123 */
124int pch_get_io_base(struct udevice *dev, u32 *iobasep);
125
Simon Glass1260f8c2019-02-16 20:24:51 -0700126/**
127 * pch_ioctl() - perform misc read/write operations
128 *
129 * This is a catch-all operation intended to avoid adding lots of
130 * methods to this uclass, of which few are commonly used. Uncommon
131 * operations that pertain only to a few devices in this uclass should
132 * use this method instead of adding new methods.
133 *
134 * @dev: PCH device to check
135 * @req: PCH request ID
136 * @data: Input/output data
137 * @size: Size of input data (and maximum size of output data)
138 * @return size of output data on sucesss, -ve on error
139 */
140int pch_ioctl(struct udevice *dev, ulong req, void *data, int size);
141
Simon Glassca831f42016-01-18 20:19:17 -0700142#endif