From patchwork Sat Dec 7 04:42:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1205408 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=85.214.62.61; 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.b="PGwxXQr3"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 47VHM73PHbz9sPL for ; Sat, 7 Dec 2019 16:00:03 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4A9D5817AB; Sat, 7 Dec 2019 05:51:33 +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="PGwxXQr3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DA5BB817A2; Sat, 7 Dec 2019 05:51:28 +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 E80F28179C for ; Sat, 7 Dec 2019 05:51:25 +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 z23so9434672iog.11 for ; Fri, 06 Dec 2019 20:51:25 -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=gd07ohFjsLFGqwYOLP0UpwRT0atO9sCRM60B5302Cj8=; b=PGwxXQr3RuO6gmNokzPWYBtXB30PqyY2r/5MH1saQFXnQHLS9J6LPp7w2DrHDJ6RMQ spTJOW0JIjjMUVsdS7pgTSMHjmgLL5SbNIZjgCQzEUUfNr02dcQ2HW+T/T2w8ccUOdLY cQelGp6ELowTja0SW5gYpaUGqNfxQV3VuDEy4= 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=gd07ohFjsLFGqwYOLP0UpwRT0atO9sCRM60B5302Cj8=; b=bmKMo/E7Hx0c8k7NYt+LGGTg5dsdXvuCkhDymvCjDeZKSnNOqDX1t8uV+tsUa+evXt 2QM0rVHqNnLPIEyy9goUn1k75K8RVmKHnfxSiYDKM4noC2Y3VIeM0bYvxOFobXT51CbN L8mxwgliPXhSZryfkN5rBU41WM1pr4Daah63R8iIL8WImXv9iMcJi/t5QylPYoLJuzjC d+SvkK+F63CivflGBVzS6QNCyUrMQqUW0Db24CIJGKU9ddXtenGA3HxDNIgcOqbguq5W MLEYV/i+YqSP57pbtJT+C6+GgOBCadbwrK5+fO1MUyyaoxwvgV5FKm6Tnhqu4PMz5tqC DCWQ== X-Gm-Message-State: APjAAAXleVxxFho76b4VxDk6sYhfnfyuCaeBw8f4IB0B9avNz5hWrula Oo5MLmJ/EOwdkpiY2rKzblGB3BWX438= X-Google-Smtp-Source: APXvYqy4fAAz9gOGYe2wSVC89c/f/ohR+Q8K1qmDsnMlN1KKraJXpWi4mVz91Y+sTPEbO+9mCc6qqA== X-Received: by 2002:a02:a610:: with SMTP id c16mr10506860jam.13.1575694284749; Fri, 06 Dec 2019 20:51:24 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id o7sm4549410ilo.58.2019.12.06.20.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 20:51:24 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH v6 074/102] spi: ich: Add support for get_mmap() method Date: Fri, 6 Dec 2019 21:42:47 -0700 Message-Id: <20191206213936.v6.74.Iafaf6313798e822d6d2dec647f43334322196760@changeid> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog In-Reply-To: <20191207044315.51770-1-sjg@chromium.org> References: <20191207044315.51770-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: , Cc: Jagannadha Sutradharudu Teki 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 Add this method so that the memory-mapped location of the SPI flash can be queried. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- Changes in v6: None Changes in v5: None Changes in v4: - Use the new pci_ofplat_get_devfn() function Changes in v3: None Changes in v2: None drivers/spi/ich.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c index db895a396d..160ec370fd 100644 --- a/drivers/spi/ich.c +++ b/drivers/spi/ich.c @@ -611,6 +611,37 @@ static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op) return ret; } +static int ich_get_mmap_bus(struct udevice *bus, ulong *map_basep, + uint *map_sizep, uint *offsetp) +{ + pci_dev_t spi_bdf; + +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + struct pci_child_platdata *pplat = dev_get_parent_platdata(bus); + + spi_bdf = pplat->devfn; +#else + struct ich_spi_platdata *plat = dev_get_platdata(bus); + + /* + * We cannot rely on plat->bdf being set up yet since this method can + * be called before the device is probed. Use the of-platdata directly + * instead. + */ + spi_bdf = pci_ofplat_get_devfn(plat->dtplat.reg[0]); +#endif + + return fast_spi_get_bios_mmap(spi_bdf, map_basep, map_sizep, offsetp); +} + +static int ich_get_mmap(struct udevice *dev, ulong *map_basep, uint *map_sizep, + uint *offsetp) +{ + struct udevice *bus = dev_get_parent(dev); + + return ich_get_mmap_bus(bus, map_basep, map_sizep, offsetp); +} + static int ich_spi_adjust_size(struct spi_slave *slave, struct spi_mem_op *op) { unsigned int page_offset; @@ -835,6 +866,7 @@ static const struct dm_spi_ops ich_spi_ops = { .set_speed = ich_spi_set_speed, .set_mode = ich_spi_set_mode, .mem_ops = &ich_controller_mem_ops, + .get_mmap = ich_get_mmap, /* * cs_info is not needed, since we require all chip selects to be * in the device tree explicitly