xref: /openbmc/u-boot/drivers/pch/sandbox_pch.c (revision b45c833c)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright 2018 Google LLC
4  */
5 
6 #include <common.h>
7 #include <dm.h>
8 #include <pch.h>
9 
10 struct sandbox_pch_priv {
11 	bool protect;
12 };
13 
14 int sandbox_get_pch_spi_protect(struct udevice *dev)
15 {
16 	struct sandbox_pch_priv *priv = dev_get_priv(dev);
17 
18 	return priv->protect;
19 }
20 
21 static int sandbox_pch_get_spi_base(struct udevice *dev, ulong *sbasep)
22 {
23 	*sbasep = 0x10;
24 
25 	return 0;
26 }
27 
28 static int sandbox_pch_set_spi_protect(struct udevice *dev, bool protect)
29 {
30 	struct sandbox_pch_priv *priv = dev_get_priv(dev);
31 
32 	priv->protect = protect;
33 
34 	return 0;
35 }
36 
37 static int sandbox_pch_get_gpio_base(struct udevice *dev, u32 *gbasep)
38 {
39 	*gbasep = 0x20;
40 
41 	return 0;
42 }
43 
44 static int sandbox_pch_get_io_base(struct udevice *dev, u32 *iobasep)
45 {
46 	*iobasep = 0x30;
47 
48 	return 0;
49 }
50 
51 static const struct pch_ops sandbox_pch_ops = {
52 	.get_spi_base	= sandbox_pch_get_spi_base,
53 	.set_spi_protect = sandbox_pch_set_spi_protect,
54 	.get_gpio_base	= sandbox_pch_get_gpio_base,
55 	.get_io_base = sandbox_pch_get_io_base,
56 };
57 
58 static const struct udevice_id sandbox_pch_ids[] = {
59 	{ .compatible = "sandbox,pch" },
60 	{ }
61 };
62 
63 U_BOOT_DRIVER(sandbox_pch_drv) = {
64 	.name		= "sandbox-pch",
65 	.id		= UCLASS_PCH,
66 	.of_match	= sandbox_pch_ids,
67 	.ops		= &sandbox_pch_ops,
68 	.priv_auto_alloc_size	= sizeof(struct sandbox_pch_priv),
69 };
70