1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2014 Google, Inc
10 #define GPIO_BASE 0x48
12 #define SBASE_ADDR 0x54
14 static int pch9_get_spi_base(struct udevice *dev, ulong *sbasep)
18 dm_pci_read_config32(dev, SBASE_ADDR, &sbase_addr);
19 *sbasep = sbase_addr & 0xfffffe00;
24 static int pch9_get_gpio_base(struct udevice *dev, u32 *gbasep)
29 * GPIO_BASE moved to its current offset with ICH6, but prior to
30 * that it was unused (or undocumented). Check that it looks
31 * okay: not all ones or zeros.
33 * Note we don't need check bit0 here, because the Tunnel Creek
34 * GPIO base address register bit0 is reserved (read returns 0),
35 * while on the Ivybridge the bit0 is used to indicate it is an
38 dm_pci_read_config32(dev, GPIO_BASE, &base);
39 if (base == 0x00000000 || base == 0xffffffff) {
40 debug("%s: unexpected BASE value\n", __func__);
45 * Okay, I guess we're looking at the right device. The actual
46 * GPIO registers are in the PCI device's I/O space, starting
47 * at the offset that we just read. Bit 0 indicates that it's
48 * an I/O address, not a memory address, so mask that off.
50 *gbasep = base & 1 ? base & ~3 : base & ~15;
55 static int pch9_get_io_base(struct udevice *dev, u32 *iobasep)
59 dm_pci_read_config32(dev, IO_BASE, &base);
60 if (base == 0x00000000 || base == 0xffffffff) {
61 debug("%s: unexpected BASE value\n", __func__);
65 *iobasep = base & 1 ? base & ~3 : base & ~15;
70 static const struct pch_ops pch9_ops = {
71 .get_spi_base = pch9_get_spi_base,
72 .get_gpio_base = pch9_get_gpio_base,
73 .get_io_base = pch9_get_io_base,
76 static const struct udevice_id pch9_ids[] = {
77 { .compatible = "intel,pch9" },
81 U_BOOT_DRIVER(pch9_drv) = {