From: Simon Glass Date: Mon, 21 Jan 2019 18:12:55 -0700 Subject: [U-Boot] [PATCH 18/33] x86: ivybridge: Add a way to get the HDA config setting In-Reply-To: <20190122011310.186491-1-sjg@chromium.org> References: <20190122011310.186491-1-sjg@chromium.org> Message-ID: <20190122011310.186491-19-sjg@chromium.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Add a way check to whether HD audio is enabled. Use ioctl() to avoid adding too many unusual operations to PCH. Signed-off-by: Simon Glass --- arch/x86/cpu/ivybridge/bd82x6x.c | 19 +++++++++++++++++++ include/pch.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/arch/x86/cpu/ivybridge/bd82x6x.c b/arch/x86/cpu/ivybridge/bd82x6x.c index a78bb02544..7d16294a5e 100644 --- a/arch/x86/cpu/ivybridge/bd82x6x.c +++ b/arch/x86/cpu/ivybridge/bd82x6x.c @@ -212,10 +212,29 @@ static int bd82x6x_get_gpio_base(struct udevice *dev, u32 *gbasep) return 0; } +static int bd82x6x_ioctl(struct udevice *dev, enum pch_req_t req, void *data, + int size) +{ + u32 rcba, val; + + switch (req) { + case PCH_REQ_HDA_CONFIG: + dm_pci_read_config32(dev, PCH_RCBA, &rcba); + val = readl(rcba + 0x2030); + if (!(val & (1U << 31))) + return -ENOENT; + + return val & 0xfe; + default: + return -ENOSYS; + } +} + static const struct pch_ops bd82x6x_pch_ops = { .get_spi_base = bd82x6x_pch_get_spi_base, .set_spi_protect = bd82x6x_set_spi_protect, .get_gpio_base = bd82x6x_get_gpio_base, + .ioctl = bd82x6x_ioctl, }; static const struct udevice_id bd82x6x_ids[] = { diff --git a/include/pch.h b/include/pch.h index c9995702c1..d1a8131794 100644 --- a/include/pch.h +++ b/include/pch.h @@ -13,6 +13,9 @@ /* All the supported PCH ioctls */ enum pch_req_t { + /* Returns HDA config info if Azalia V1CTL enabled, -ENOENT if not */ + PCH_REQ_HDA_CONFIG, + PCH_REQ_TEST1, /* Test requests for sandbox driver */ PCH_REQ_TEST2, PCH_REQ_TEST3, -- 2.20.1.321.g9e740568ce-goog