From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0A7BC07E95 for ; Tue, 13 Jul 2021 20:11:59 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 28B7B6128E for ; Tue, 13 Jul 2021 20:11:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 28B7B6128E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 105C582C0B; Tue, 13 Jul 2021 22:11:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="MnblGVti"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 319B782C3C; Tue, 13 Jul 2021 22:11:55 +0200 (CEST) Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) (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 14E5882C09 for ; Tue, 13 Jul 2021 22:11:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ej1-x62f.google.com with SMTP id gn32so43765162ejc.2 for ; Tue, 13 Jul 2021 13:11:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=YC5Rbb4gCnPG3nyEjPAJa9O1jc0/KRWTaEvScmYTlK8=; b=MnblGVtiZ6kubrlypU4tx0g/hC7AzpyvcT4jkDxv2hG/esleyxWXKNNugkZ0Cojlxd JQeFUNezZkj3n/OVPdvFv0dhVhzPb+ihhJyr5c5EJ8slURwt+xBiALHv+WggDHdjqo51 raKo8iO7nW32LyZFvHRGBQ6ChX2FsFy7i5dL0NM/bSDV4KkGfARVnu86aKYbYPWsLSVn QCNpIwqZqESoRFful0gZ2iUeW+vr5MCifFr95eFIVoGI4UAh57ryUmNLL13JR8RrbV6R K1s2AWXc+yTQ9qYl0TXjw60Hp3mu5VhiOULR7lpIMWnjkwc6uG0gHSQ9C3hHLBLm/8sI ahKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=YC5Rbb4gCnPG3nyEjPAJa9O1jc0/KRWTaEvScmYTlK8=; b=fttsiB4D3qo9DyAeTanpoDhxATpwvG5cJKxvl7OQwwDEQPdieAqVq2AOC0jaZQAx+T i2o7Qzv96dgpp39Hv9nooL6d1AUTBxRmteSq4Vfhh0JWolsIrH/Gg6oC0wtCHzoDWKov EQYtBBopk9fTwYfEa97y9V2dQWt15EPsHbLqK+b7OtIbvfEnpTP75GPC/KDy+4joEMEJ Xevk1DS+iMzdAywZpUg9J36med390c2HJOxXv71XMUYzhp88aamS7AocK0Xa7q28RDhy 4G/1uvsDa3WFg8/G+Yjb8veyQtswCOUUhXKWPvHygsoxn15nNVp/bDOeAxcpQUlPWnDC ByHw== X-Gm-Message-State: AOAM530DFTbXGQRGhVoAsm5X3Hm5dJFQywMVj82cEZk2J9HcUa7+TOfi O71Ps1z1JM9Mnxo40AfeJj6Q1w== X-Google-Smtp-Source: ABdhPJyC/MSbmyB1xqmfLgxiRRLTC9lbKX/VdDV9/kYOcW6E2znBOasXfgCAXAwpLbhWaWrmpkU3Ng== X-Received: by 2002:a17:906:288d:: with SMTP id o13mr7658197ejd.120.1626207111557; Tue, 13 Jul 2021 13:11:51 -0700 (PDT) Received: from enceladus (athedsl-417902.home.otenet.gr. [79.131.184.108]) by smtp.gmail.com with ESMTPSA id w2sm13829edx.58.2021.07.13.13.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 13:11:51 -0700 (PDT) Date: Tue, 13 Jul 2021 23:11:48 +0300 From: Ilias Apalodimas To: Simon Glass Cc: Heinrich Schuchardt , Johannes Holland , Masahisa Kojima , Dhananjay Phadke , U-Boot Mailing List Subject: Re: [PATCH 2/2] tpm2: Add a TPMv2 MMIO TIS driver Message-ID: References: <20210707162604.84196-1-ilias.apalodimas@linaro.org> <20210707162604.84196-2-ilias.apalodimas@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.103.2 at phobos.denx.de X-Virus-Status: Clean [...] > > > Should be a uclass interface. > > > > > > > Why? A uclass is supposed to describe and abstract hardware. This is just > > a specific implementation of a TPM, not all TPMs are TIS compliant. We already > > have a uclass for those. > > Who told you that a uclass is supposed to describe and abstract hardware? :-) > That's what I've mostly seen it used for, maybe i got the idea wrong. > The uclass is how driver model does APIs, so normally a uclass would > be used for any API. There are exceptions, but this one actually looks > like a useful interface we should have. > the point is we already have a uclass for tpm devices. So why should the we add another one that just describes the TIS interface? > > > > > > + .read_bytes = mmio_read_bytes, > > > > + .write_bytes = mmio_write_bytes, > > > > + .read16 = mmio_read16, > > > > + .read32 = mmio_read32, > > > > + .write32 = mmio_write32, > > > > +}; > > > > + > > > > +static int tpm_tis_probe(struct udevice *udev) > > > > +{ > > > > + struct tpm_tis_chip_data *drv_data = (void *)dev_get_driver_data(udev); > > > > + struct tpm_chip_priv *priv = dev_get_uclass_priv(udev); > > > > + int ret = 0; > > > > + fdt_addr_t ioaddr; > > > > + u64 sz; > > > > + > > > > + ioaddr = dev_read_addr(udev); > > > > + if (ioaddr == FDT_ADDR_T_NONE) > > > > + return -EINVAL; > > > > > > consider this for easier debugging: > > > > > > return log_msg_ret("ioaddr", -EINVAL); > > > > > > > Sure > > > > > > + > > > > + ret = dev_read_u64(udev, "reg", &sz); > > > > + if (ret) > > > > + return -EINVAL; > > > > + > > > > + drv_data->iobase = ioremap(ioaddr, sz); > > > > + log_info("Remapped TPM2 base: 0x%llx size: 0x%llx\n", ioaddr, sz); > > > > > > log_debug() I think? > > > > > Yea, that's a leftover of my initial code, were I needed to make sure the > > ioremap worked. > > > > > > + tpm_tis_ops_register(udev, &phy_ops); > > > > + ret = tpm_tis_init(udev); > > > > + if (ret) > > > > + goto iounmap; > > > > + > > > > + priv->pcr_count = drv_data->pcr_count; > > > > + priv->pcr_select_min = drv_data->pcr_select_min; > > > > + /* > > > > + * Although the driver probably works with a TPMv1 our Kconfig > > > > + * limits the driver to TPMv2 only > > > > + */ > > > > + priv->version = TPM_V2; > > > > + > > > > + return ret; > > > > +iounmap: > > > > + iounmap(drv_data->iobase); > > > > + return -EINVAL; > > > > +} > > > > + > > > > +static int tpm_tis_remove(struct udevice *udev) > > > > +{ > > > > + struct tpm_tis_chip_data *drv_data = (void *)dev_get_driver_data(udev); > > > > + > > > > + iounmap(drv_data->iobase); > > > > + return tpm_tis_cleanup(udev); > > > > +} > > > > + > > > > +static const struct tpm_ops tpm_tis_ops = { > > > > + .open = tpm_tis_open, > > > > + .close = tpm_tis_close, > > > > + .get_desc = tpm_tis_get_desc, > > > > + .send = tpm_tis_send, > > > > + .recv = tpm_tis_recv, > > > > + .cleanup = tpm_tis_cleanup, > > > > +}; > > > > + > > > > +static const struct tpm_tis_chip_data tpm_tis_std_chip_data = { > > > > + .pcr_count = 24, > > > > + .pcr_select_min = 3, > > > > +}; > > > > + > > > > +static const struct udevice_id tpm_tis_ids[] = { > > > > + { > > > > + .compatible = "tcg,tpm-tis-mmio", > > > > + .data = (ulong)&tpm_tis_std_chip_data, > > > > + }, > > > > + { } > > > > +}; > > > > + > > > > +U_BOOT_DRIVER(tpm_tis_mmio) = { > > > > + .name = "tpm_tis_mmio", > > > > + .id = UCLASS_TPM, > > > > + .of_match = tpm_tis_ids, > > > > + .ops = &tpm_tis_ops, > > > > + .probe = tpm_tis_probe, > > > > + .remove = tpm_tis_remove, > > > > + .priv_auto = sizeof(struct tpm_chip), > > > > +}; > > > > -- > > > > 2.32.0.rc0 > > > > > > > > > > Regards, > > > Simon > > > > Thanks for looking at this > > /Ilias > > Likewise. > > Regards, > Simon