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=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 9A32CC4338F for ; Mon, 2 Aug 2021 00:55:09 +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 B39F661050 for ; Mon, 2 Aug 2021 00:55:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B39F661050 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1DD8B831FE; Mon, 2 Aug 2021 02:55:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (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=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="UlrXUmWJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9648983329; Mon, 2 Aug 2021 02:54:59 +0200 (CEST) Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) (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 F0FE1832E2 for ; Mon, 2 Aug 2021 02:54:52 +0200 (CEST) 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-oi1-x22c.google.com with SMTP id u25so22168843oiv.5 for ; Sun, 01 Aug 2021 17:54:52 -0700 (PDT) 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=KYhs6oJfuipClMwlZHrcYnTbf6a+wcvEvK1nVLfgFAU=; b=UlrXUmWJw5sjIXDgsfxLOs3Z5uAWP8AZZUlKcUOiirDaO23C5q89U2Ni2lNPt5ysgZ lm9Tk2PDnFyIhCHy/m8hZj5bV6bFlUJEZWCWCXp4JrNNvQy1/RafhfARjPCym54MInUE BxsCbLtgtEY2w334e2OSWuL5FR5Wzo5pk/oFI= 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=KYhs6oJfuipClMwlZHrcYnTbf6a+wcvEvK1nVLfgFAU=; b=M4NCqvwilHM1mhlt0Mpxx2xvpMj5PpDugXzM/4i9Ifrfhi63UwsTYxT5zqm47IaN10 CvbTWaeyu1bfUv4RsBHmTKSLwH8XpS6AJqtmvQR8OKh0xZS0toVGRAVa+5La/ZXUEVwQ 9ZFdSwWbnT9lK3+u8HhkwJgZuJBzvTZowjRzCVcJzVkjD80PL/6fynejrec+uY3H16kS 6m1HvzqyFoJIW4/cv/LS6N93mQLDPEiIefaw1BLWA9tu0Z7nLxrIyvGgYdBBwcgF1LM6 MGyyBFPmnum6LLuyMYo0KzfSrfFL66Kp2tsAKnVV9ZU0N/ZjPzSVVgjbczEKZaw3dMHg yzxA== X-Gm-Message-State: AOAM5331JKCHsU4llSF/YE9vlDGJQAkAtMPUXNgFwk6VJud7M43kByH/ Wypr7Is1sqs8eVYfaHTtTdJzb8gKbzYi07RS X-Google-Smtp-Source: ABdhPJyypBXaHokPzl4GbBPkiwUGF3q6LeffpFKmyMWA943f1A00LOsp01eUpQNvxcCjypYBABlUAA== X-Received: by 2002:aca:1802:: with SMTP id h2mr8885873oih.146.1627865690137; Sun, 01 Aug 2021 17:54:50 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id s2sm1452616ooc.15.2021.08.01.17.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Aug 2021 17:54:49 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass Subject: [PATCH v2 01/32] pci: Drop old code from pci command Date: Sun, 1 Aug 2021 18:54:14 -0600 Message-Id: <20210802005446.2267075-2-sjg@chromium.org> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210802005446.2267075-1-sjg@chromium.org> References: <20210802005446.2267075-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Drop the pre-driver model code from this file. Signed-off-by: Simon Glass --- (no changes since v1) cmd/pci.c | 212 ------------------------------------------------------ 1 file changed, 212 deletions(-) diff --git a/cmd/pci.c b/cmd/pci.c index e53b7c858c6..8cfa5bbdaa7 100644 --- a/cmd/pci.c +++ b/cmd/pci.c @@ -47,7 +47,6 @@ static int pci_field_width(enum pci_size_t size) return pci_byte_size(size) * 2; } -#ifdef CONFIG_DM_PCI static void pci_show_regs(struct udevice *dev, struct pci_reg_info *regs) { for (; regs->name; regs++) { @@ -59,40 +58,7 @@ static void pci_show_regs(struct udevice *dev, struct pci_reg_info *regs) pci_field_width(regs->size), val); } } -#else -static unsigned long pci_read_config(pci_dev_t dev, int offset, - enum pci_size_t size) -{ - u32 val32; - u16 val16; - u8 val8; - switch (size) { - case PCI_SIZE_8: - pci_read_config_byte(dev, offset, &val8); - return val8; - case PCI_SIZE_16: - pci_read_config_word(dev, offset, &val16); - return val16; - case PCI_SIZE_32: - default: - pci_read_config_dword(dev, offset, &val32); - return val32; - } -} - -static void pci_show_regs(pci_dev_t dev, struct pci_reg_info *regs) -{ - for (; regs->name; regs++) { - printf(" %s =%*s%#.*lx\n", regs->name, - (int)(28 - strlen(regs->name)), "", - pci_field_width(regs->size), - pci_read_config(dev, regs->offset, regs->size)); - } -} -#endif - -#ifdef CONFIG_DM_PCI int pci_bar_show(struct udevice *dev) { u8 header_type; @@ -162,7 +128,6 @@ int pci_bar_show(struct udevice *dev) return 0; } -#endif static struct pci_reg_info regs_start[] = { { "vendor ID", PCI_SIZE_16, PCI_VENDOR_ID }, @@ -258,23 +223,12 @@ static struct pci_reg_info regs_cardbus[] = { * * @dev: Bus+Device+Function number */ -#ifdef CONFIG_DM_PCI void pci_header_show(struct udevice *dev) -#else -void pci_header_show(pci_dev_t dev) -#endif { -#ifdef CONFIG_DM_PCI unsigned long class, header_type; dm_pci_read_config(dev, PCI_CLASS_CODE, &class, PCI_SIZE_8); dm_pci_read_config(dev, PCI_HEADER_TYPE, &header_type, PCI_SIZE_8); -#else - u8 class, header_type; - - pci_read_config_byte(dev, PCI_CLASS_CODE, &class); - pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type); -#endif pci_show_regs(dev, regs_start); printf(" class code = 0x%.2x (%s)\n", (int)class, pci_class_str(class)); @@ -307,7 +261,6 @@ void pciinfo_header(int busnum, bool short_listing) } } -#ifdef CONFIG_DM_PCI /** * pci_header_show_brief() - Show the short-form PCI device header * @@ -355,102 +308,6 @@ static void pciinfo(struct udevice *bus, bool short_listing) } } -#else - -/** - * pci_header_show_brief() - Show the short-form PCI device header - * - * Reads and prints the header of the specified PCI device in short form. - * - * @dev: Bus+Device+Function number - */ -void pci_header_show_brief(pci_dev_t dev) -{ - u16 vendor, device; - u8 class, subclass; - - pci_read_config_word(dev, PCI_VENDOR_ID, &vendor); - pci_read_config_word(dev, PCI_DEVICE_ID, &device); - pci_read_config_byte(dev, PCI_CLASS_CODE, &class); - pci_read_config_byte(dev, PCI_CLASS_SUB_CODE, &subclass); - - printf("0x%.4x 0x%.4x %-23s 0x%.2x\n", - vendor, device, - pci_class_str(class), subclass); -} - -/** - * pciinfo() - Show a list of devices on the PCI bus - * - * Show information about devices on PCI bus. Depending on @short_pci_listing - * the output will be more or less exhaustive. - * - * @bus_num: The number of the bus to be scanned - * @short_pci_listing: true to use short form, showing only a brief header - * for each device - */ -void pciinfo(int bus_num, int short_pci_listing) -{ - struct pci_controller *hose = pci_bus_to_hose(bus_num); - int device; - int function; - unsigned char header_type; - unsigned short vendor_id; - pci_dev_t dev; - int ret; - - if (!hose) - return; - - pciinfo_header(bus_num, short_pci_listing); - - for (device = 0; device < PCI_MAX_PCI_DEVICES; device++) { - header_type = 0; - vendor_id = 0; - for (function = 0; function < PCI_MAX_PCI_FUNCTIONS; - function++) { - /* - * If this is not a multi-function device, we skip - * the rest. - */ - if (function && !(header_type & 0x80)) - break; - - dev = PCI_BDF(bus_num, device, function); - - if (pci_skip_dev(hose, dev)) - continue; - - ret = pci_read_config_word(dev, PCI_VENDOR_ID, - &vendor_id); - if (ret) - goto error; - if ((vendor_id == 0xFFFF) || (vendor_id == 0x0000)) - continue; - - if (!function) { - pci_read_config_byte(dev, PCI_HEADER_TYPE, - &header_type); - } - - if (short_pci_listing) { - printf("%02x.%02x.%02x ", bus_num, device, - function); - pci_header_show_brief(dev); - } else { - printf("\nFound PCI device %02x.%02x.%02x:\n", - bus_num, device, function); - pci_header_show(dev); - } - } - } - - return; -error: - printf("Cannot read bus configuration: %d\n", ret); -} -#endif - /** * get_pci_dev() - Convert the "bus.device.function" identifier into a number * @@ -482,13 +339,8 @@ static pci_dev_t get_pci_dev(char *name) return PCI_BDF(bdfs[0], bdfs[1], bdfs[2]); } -#ifdef CONFIG_DM_PCI static int pci_cfg_display(struct udevice *dev, ulong addr, enum pci_size_t size, ulong length) -#else -static int pci_cfg_display(pci_dev_t bdf, ulong addr, enum pci_size_t size, - ulong length) -#endif { #define DISP_LINE_LEN 16 ulong i, nbytes, linebytes; @@ -509,11 +361,7 @@ static int pci_cfg_display(pci_dev_t bdf, ulong addr, enum pci_size_t size, for (i = 0; i < linebytes; i += byte_size) { unsigned long val; -#ifdef CONFIG_DM_PCI dm_pci_read_config(dev, addr, &val, size); -#else - val = pci_read_config(bdf, addr, size); -#endif printf(" %0*lx", pci_field_width(size), val); addr += byte_size; } @@ -528,31 +376,8 @@ static int pci_cfg_display(pci_dev_t bdf, ulong addr, enum pci_size_t size, return (rc); } -#ifndef CONFIG_DM_PCI -static int pci_cfg_write (pci_dev_t bdf, ulong addr, ulong size, ulong value) -{ - if (size == 4) { - pci_write_config_dword(bdf, addr, value); - } - else if (size == 2) { - ushort val = value & 0xffff; - pci_write_config_word(bdf, addr, val); - } - else { - u_char val = value & 0xff; - pci_write_config_byte(bdf, addr, val); - } - return 0; -} -#endif - -#ifdef CONFIG_DM_PCI static int pci_cfg_modify(struct udevice *dev, ulong addr, ulong size, ulong value, int incrflag) -#else -static int pci_cfg_modify(pci_dev_t bdf, ulong addr, ulong size, ulong value, - int incrflag) -#endif { ulong i; int nbytes; @@ -563,11 +388,7 @@ static int pci_cfg_modify(pci_dev_t bdf, ulong addr, ulong size, ulong value, */ do { printf("%08lx:", addr); -#ifdef CONFIG_DM_PCI dm_pci_read_config(dev, addr, &val, size); -#else - val = pci_read_config(bdf, addr, size); -#endif printf(" %0*lx", pci_field_width(size), val); nbytes = cli_readline(" ? "); @@ -594,11 +415,7 @@ static int pci_cfg_modify(pci_dev_t bdf, ulong addr, ulong size, ulong value, /* good enough to not time out */ bootretry_reset_cmd_timeout(); -#ifdef CONFIG_DM_PCI dm_pci_write_config(dev, addr, i, size); -#else - pci_cfg_write(bdf, addr, size, i); -#endif if (incrflag) addr += size; } @@ -608,7 +425,6 @@ static int pci_cfg_modify(pci_dev_t bdf, ulong addr, ulong size, ulong value, return 0; } -#ifdef CONFIG_DM_PCI static const struct pci_flag_info { uint flag; const char *name; @@ -647,7 +463,6 @@ static void pci_show_regions(struct udevice *bus) printf("\n"); } } -#endif /* PCI Configuration Space access commands * @@ -661,11 +476,7 @@ static int do_pci(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { ulong addr = 0, value = 0, cmd_size = 0; enum pci_size_t size = PCI_SIZE_32; -#ifdef CONFIG_DM_PCI struct udevice *dev, *bus; -#else - pci_dev_t dev; -#endif int busnum = 0; pci_dev_t bdf = 0; char cmd = 's'; @@ -687,19 +498,15 @@ static int do_pci(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (argc > 4) value = simple_strtoul(argv[4], NULL, 16); case 'h': /* header */ -#ifdef CONFIG_DM_PCI case 'b': /* bars */ -#endif if (argc < 3) goto usage; if ((bdf = get_pci_dev(argv[2])) == -1) return 1; break; -#if defined(CONFIG_DM_PCI) case 'e': pci_init(); return 0; -#endif case 'r': /* no break */ default: /* scan bus */ value = 1; /* short listing */ @@ -711,7 +518,6 @@ static int do_pci(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (argc > 1) busnum = simple_strtoul(argv[1], NULL, 16); } -#ifdef CONFIG_DM_PCI ret = uclass_get_device_by_seq(UCLASS_PCI, busnum, &bus); if (ret) { printf("No such bus\n"); @@ -721,21 +527,14 @@ static int do_pci(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) pci_show_regions(bus); else pciinfo(bus, value); -#else - pciinfo(busnum, value); -#endif return 0; } -#ifdef CONFIG_DM_PCI ret = dm_pci_bus_find_bdf(bdf, &dev); if (ret) { printf("No such device\n"); return CMD_RET_FAILURE; } -#else - dev = bdf; -#endif switch (argv[1][0]) { case 'h': /* header */ @@ -756,17 +555,10 @@ static int do_pci(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) case 'w': /* write */ if (argc < 5) goto usage; -#ifdef CONFIG_DM_PCI ret = dm_pci_write_config(dev, addr, value, size); -#else - ret = pci_cfg_write(dev, addr, size, value); -#endif break; -#ifdef CONFIG_DM_PCI - case 'b': /* bars */ return pci_bar_show(dev); -#endif default: ret = CMD_RET_USAGE; break; @@ -783,18 +575,14 @@ static int do_pci(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) static char pci_help_text[] = "[bus] [long]\n" " - short or long list of PCI devices on bus 'bus'\n" -#if defined(CONFIG_DM_PCI) "pci enum\n" " - Enumerate PCI buses\n" -#endif "pci header b.d.f\n" " - show header of PCI device 'bus.device.function'\n" -#ifdef CONFIG_DM_PCI "pci bar b.d.f\n" " - show BARs base and size for device b.d.f'\n" "pci regions\n" " - show PCI regions\n" -#endif "pci display[.b, .w, .l] b.d.f [address] [# of objects]\n" " - display PCI configuration space (CFG)\n" "pci next[.b, .w, .l] b.d.f address\n" -- 2.32.0.554.ge1b32706d8-goog