blob: 0b44b66df9f1aaa259f9f06c6d3f5905e421d415 [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 Glassb69b6032019-04-25 21:59:01 -060019 /* Fills out a struct pch_pmbase_info if available */
20 PCH_REQ_PMBASE_INFO,
21
Simon Glass1260f8c2019-02-16 20:24:51 -070022 PCH_REQ_TEST1, /* Test requests for sandbox driver */
23 PCH_REQ_TEST2,
24 PCH_REQ_TEST3,
25
26 PCH_REQ_COUNT, /* Number of ioctrls supported */
27};
28
29/**
Simon Glassb69b6032019-04-25 21:59:01 -060030 * struct pch_pmbase_info - Information filled in by PCH_REQ_PMBASE_INFO
31 *
32 * @pmbase: IO address of power-management controller
33 * @gpio0_en_ofs: Offset of GPIO0 enable register
34 * @pm1_sts_ofs: Offset of status register
35 * @pm1_cnt_ofs: Offset of control register
36 */
37struct pch_pmbase_info {
38 u16 base;
39 u8 gpio0_en_ofs;
40 u8 pm1_sts_ofs;
41 u8 pm1_cnt_ofs;
42};
43
44/**
Simon Glass1260f8c2019-02-16 20:24:51 -070045 * struct pch_ops - Operations for the Platform Controller Hub
46 *
47 * Consider using ioctl() to add rarely used or driver-specific operations.
48 */
Simon Glassca831f42016-01-18 20:19:17 -070049struct pch_ops {
50 /**
Bin Meng3e389d82016-02-01 01:40:42 -080051 * get_spi_base() - get the address of SPI base
Simon Glassca831f42016-01-18 20:19:17 -070052 *
53 * @dev: PCH device to check
54 * @sbasep: Returns address of SPI base if available, else 0
55 * @return 0 if OK, -ve on error (e.g. there is no SPI base)
56 */
Bin Meng3e389d82016-02-01 01:40:42 -080057 int (*get_spi_base)(struct udevice *dev, ulong *sbasep);
Simon Glassca831f42016-01-18 20:19:17 -070058
59 /**
Simon Glassca831f42016-01-18 20:19:17 -070060 * set_spi_protect() - set whether SPI flash is protected or not
61 *
62 * @dev: PCH device to adjust
63 * @protect: true to protect, false to unprotect
64 *
65 * @return 0 on success, -ENOSYS if not implemented
66 */
67 int (*set_spi_protect)(struct udevice *dev, bool protect);
Bin Meng384980c2016-02-01 01:40:43 -080068
69 /**
70 * get_gpio_base() - get the address of GPIO base
71 *
72 * @dev: PCH device to check
73 * @gbasep: Returns address of GPIO base if available, else 0
74 * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
75 */
76 int (*get_gpio_base)(struct udevice *dev, u32 *gbasep);
Bin Meng79d4eb62016-02-01 01:40:45 -080077
78 /**
79 * get_io_base() - get the address of IO base
80 *
81 * @dev: PCH device to check
82 * @iobasep: Returns address of IO base if available, else 0
83 * @return 0 if OK, -ve on error (e.g. there is no IO base)
84 */
85 int (*get_io_base)(struct udevice *dev, u32 *iobasep);
Simon Glass1260f8c2019-02-16 20:24:51 -070086
87 /**
88 * ioctl() - perform misc read/write operations
89 *
90 * This is a catch-all operation intended to avoid adding lots of
91 * methods to this uclass, of which few are commonly used. Uncommon
92 * operations that pertain only to a few devices in this uclass should
93 * use this method instead of adding new methods.
94 *
95 * @dev: PCH device to check
96 * @req: PCH request ID
97 * @data: Input/output data
98 * @size: Size of input data (and maximum size of output data)
99 * @return size of output data on sucesss, -ve on error
100 */
101 int (*ioctl)(struct udevice *dev, enum pch_req_t req, void *data,
102 int size);
Simon Glassca831f42016-01-18 20:19:17 -0700103};
104
105#define pch_get_ops(dev) ((struct pch_ops *)(dev)->driver->ops)
106
107/**
Bin Meng3e389d82016-02-01 01:40:42 -0800108 * pch_get_spi_base() - get the address of SPI base
Simon Glassca831f42016-01-18 20:19:17 -0700109 *
110 * @dev: PCH device to check
111 * @sbasep: Returns address of SPI base if available, else 0
112 * @return 0 if OK, -ve on error (e.g. there is no SPI base)
113 */
Bin Meng3e389d82016-02-01 01:40:42 -0800114int pch_get_spi_base(struct udevice *dev, ulong *sbasep);
Simon Glassca831f42016-01-18 20:19:17 -0700115
116/**
Simon Glassca831f42016-01-18 20:19:17 -0700117 * set_spi_protect() - set whether SPI flash is protected or not
118 *
119 * @dev: PCH device to adjust
120 * @protect: true to protect, false to unprotect
121 *
122 * @return 0 on success, -ENOSYS if not implemented
123 */
124int pch_set_spi_protect(struct udevice *dev, bool protect);
125
Bin Meng384980c2016-02-01 01:40:43 -0800126/**
127 * pch_get_gpio_base() - get the address of GPIO base
128 *
129 * @dev: PCH device to check
130 * @gbasep: Returns address of GPIO base if available, else 0
131 * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
132 */
133int pch_get_gpio_base(struct udevice *dev, u32 *gbasep);
134
Bin Meng79d4eb62016-02-01 01:40:45 -0800135/**
136 * pch_get_io_base() - get the address of IO base
137 *
138 * @dev: PCH device to check
139 * @iobasep: Returns address of IO base if available, else 0
140 * @return 0 if OK, -ve on error (e.g. there is no IO base)
141 */
142int pch_get_io_base(struct udevice *dev, u32 *iobasep);
143
Simon Glass1260f8c2019-02-16 20:24:51 -0700144/**
145 * pch_ioctl() - perform misc read/write operations
146 *
147 * This is a catch-all operation intended to avoid adding lots of
148 * methods to this uclass, of which few are commonly used. Uncommon
149 * operations that pertain only to a few devices in this uclass should
150 * use this method instead of adding new methods.
151 *
152 * @dev: PCH device to check
153 * @req: PCH request ID
154 * @data: Input/output data
155 * @size: Size of input data (and maximum size of output data)
156 * @return size of output data on sucesss, -ve on error
157 */
158int pch_ioctl(struct udevice *dev, ulong req, void *data, int size);
159
Simon Glassca831f42016-01-18 20:19:17 -0700160#endif