From patchwork Mon Jan 27 05:06:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229595 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=fr+Eapj/; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 485dWr31Fzz9sR1 for ; Mon, 27 Jan 2020 16:26:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5F9218193E; Mon, 27 Jan 2020 06:13:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="fr+Eapj/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5A762817EC; Mon, 27 Jan 2020 06:10:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E4451817EE for ; Mon, 27 Jan 2020 06:09:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd43.google.com with SMTP id d15so8579310iog.3 for ; Sun, 26 Jan 2020 21:09:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Fnz37EwQeZYOETbUtfr9KU6n+7mt/VxCcek/Lyj0Mkw=; b=fr+Eapj/pne21jE5CpDxvyx4p1vo7GFHuTRRWSiUuZRaIk9jJWI3KhmQ2BrmdYQMkv ouxOgnf/HIcWcgZ2LDh8WT+gA0Dc9Y7P2Cyzr1Eps/eEqZDS6xlhRXJCdPFPPsUJvANL /psK/qIAClMp8eFdD0CHQhFiXsoqjlNQ1TdWo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fnz37EwQeZYOETbUtfr9KU6n+7mt/VxCcek/Lyj0Mkw=; b=YEij/3ccwrQ8+VkKxxNeuL/Xm3CHNQLNSwHNijFWj+YVaUtrSvw8nqypg6tM0pz0B7 yVuyWz3VftkhPzt2P6esG7es28sRzPrWADckIvHiOeBIXu6Ofttw2GDBTYqCEvg0LCfR N4DMl3KqdfJuOKHAYQAoPW2cnl4uOxTSTn1aMhB8Q02ZbVOwYIGfxoQqIEYjHOdw5FWs Cns68DWW/bbJuN2f1VNf13Yv6d+hG0Gt4yDDp1zV6YEJ+5vGOAw0Wqt6DT6YBNpha3Ab XQYsCF0XOQaXVfsI4E+sEV1SGB0P9ddB9reax96rBWHlmadTZWwTpoG2aFakuG3koVn2 sMbw== X-Gm-Message-State: APjAAAWVvIZuK2AblRhqGf4gekRCTxLnjcfDUz2lZFR6c9cSUiCn3zw3 jCPJaS3P+C+WrywRax2+Zt8eU+ubnmhFAg== X-Google-Smtp-Source: APXvYqz0gya5fHrnpFRJwX7s3phb03ls9+UFN5Oe8W/FIC505O6R1HfNt2NACRiTXs7RHf9rXaKvUQ== X-Received: by 2002:a5e:df47:: with SMTP id g7mr11308851ioq.31.1580101780710; Sun, 26 Jan 2020 21:09:40 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id h23sm4313195ilf.57.2020.01.26.21.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:40 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 096/108] tpm: cr50: Add ACPI support Date: Sun, 26 Jan 2020 22:06:43 -0700 Message-Id: <20200126220508.96.I1a9174fd9af26d0891e4ccfac247c7359b28b23e@changeid> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200127050655.170614-1-sjg@chromium.org> References: <20200127050655.170614-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean Generate ACPI information for this device so that Linux can use it correctly. Signed-off-by: Simon Glass --- drivers/tpm/cr50_i2c.c | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/drivers/tpm/cr50_i2c.c b/drivers/tpm/cr50_i2c.c index d68534e7a9..5a3db87125 100644 --- a/drivers/tpm/cr50_i2c.c +++ b/drivers/tpm/cr50_i2c.c @@ -8,6 +8,8 @@ #define LOG_CATEGORY UCLASS_TPM #include +#include +#include #include #include #include @@ -17,6 +19,7 @@ #include #include #include +#include enum { TIMEOUT_INIT_MS = 30000, /* Very long timeout for TPM init */ @@ -580,6 +583,53 @@ static int cr50_i2c_cleanup(struct udevice *dev) return 0; } +static int cr50_acpi_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx) +{ + char scope[ACPI_PATH_MAX]; + char name[ACPI_NAME_MAX]; + const char *hid; + int ret; + + ret = acpi_device_scope(dev, scope, sizeof(scope)); + if (ret) + return log_msg_ret("scope", ret); + ret = acpi_device_name(dev, name); + if (ret) + return log_msg_ret("name", ret); + + hid = dev_read_string(dev, "acpi,hid"); + if (!hid) + return log_msg_ret("hid", ret); + + /* Device */ + acpigen_write_scope(ctx, scope); + acpigen_write_device(ctx, name); + acpigen_write_name_string(ctx, "_HID", hid); + acpigen_write_name_integer(ctx, "_UID", + dev_read_u32_default(dev, "acpi,uid", 0)); + acpigen_write_name_string(ctx, "_DDN", + dev_read_string(dev, "acpi,desc")); + acpigen_write_sta(ctx, acpi_device_status(dev)); + + /* Resources */ + acpigen_write_name(ctx, "_CRS"); + acpigen_write_resourcetemplate_header(ctx); + ret = acpi_device_write_i2c_dev(ctx, dev); + if (ret) + return log_msg_ret("i2c", ret); + ret = acpi_device_write_interrupt_or_gpio(ctx, (struct udevice *)dev, + "ready-gpios"); + if (ret) + return log_msg_ret("irq_gpio", ret); + + acpigen_write_resourcetemplate_footer(ctx); + + acpigen_pop_len(ctx); /* Device */ + acpigen_pop_len(ctx); /* Scope */ + + return 0; +} + enum { TPM_TIMEOUT_MS = 5, SHORT_TIMEOUT_MS = 750, @@ -652,6 +702,10 @@ static int cr50_i2c_probe(struct udevice *dev) return 0; } +struct acpi_ops cr50_acpi_ops = { + .fill_ssdt = cr50_acpi_fill_ssdt, +}; + static const struct tpm_ops cr50_i2c_ops = { .open = cr50_i2c_open, .get_desc = cr50_i2c_get_desc, @@ -674,5 +728,6 @@ U_BOOT_DRIVER(cr50_i2c) = { .probe = cr50_i2c_probe, .remove = cr50_i2c_cleanup, .priv_auto_alloc_size = sizeof(struct cr50_priv), + acpi_ops_ptr(&cr50_acpi_ops) .flags = DM_FLAG_OS_PREPARE, };