Skip to contentSkip to conversation

barebox PCI support

RFC Superseded Antony Pavlov 3 participants 11 messages Jun 25, 2014 – Jul 1, 2014

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover barebox PCI support

This patchseries introduce simple PCI bus support for barebox.

Previous (RFC v2) version can be found here:

http://lists.infradead.org/pipermail/barebox/2012-March/006327.html

TODOs for RFC v3:

* no PCI bridges support;
* introduce dma_alloc_coherent();
* introduce pci_resource_start();
* introduce pci_iomap();
* introduce pci_set_master() & pci_clear_master();
* clean '#if 0'.

This patchseries can be found on github:

https://github.com/frantony/barebox/tree/pci.20140626

Antony Pavlov (5):
PCI: initial commit
commands: add 'lspci' command
net: add RealTek RTL-8139 PCI Ethernet driver
MIPS: add PCI support for GT64120-based Malta board
MIPS: qemu-malta_defconfig: enable PCI & network stuff

 arch/mips/Kconfig                                |  22 +
 arch/mips/configs/qemu-malta_defconfig           |   4 +
 arch/mips/include/asm/gt64120.h                  |  53 ++
 arch/mips/mach-malta/Makefile                    |   1 +
 arch/mips/mach-malta/include/mach/mach-gt64120.h |   2 +
 arch/mips/mach-malta/pci.c                       | 246 +++++++++
 commands/Kconfig                                 |   8 +
 commands/Makefile                                |   1 +
 commands/lspci.c                                 |  49 ++
 drivers/Makefile                                 |   1 +
 drivers/net/Kconfig                              |   8 +
 drivers/net/Makefile                             |   1 +
 drivers/net/rtl8139.c                            | 621 +++++++++++++++++++++++
 drivers/pci/Kconfig                              |  12 +
 drivers/pci/Makefile                             |   8 +
 drivers/pci/bus.c                                | 110 ++++
 drivers/pci/pci.c                                | 282 ++++++++++
 include/linux/mod_devicetable.h                  |  20 +
 include/linux/pci.h                              | 241 +++++++++
 include/linux/pci_ids.h                          | 141 +++++
 include/linux/pci_regs.h                         | 118 +++++
 21 files changed, 1949 insertions(+)
 create mode 100644 arch/mips/mach-malta/pci.c
 create mode 100644 commands/lspci.c
 create mode 100644 drivers/net/rtl8139.c
 create mode 100644 drivers/pci/Kconfig
 create mode 100644 drivers/pci/Makefile
 create mode 100644 drivers/pci/bus.c
 create mode 100644 drivers/pci/pci.c
 create mode 100644 include/linux/mod_devicetable.h
 create mode 100644 include/linux/pci.h
 create mode 100644 include/linux/pci_ids.h
 create mode 100644 include/linux/pci_regs.h
Signature · 7 lines
1.9.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

RFC v3 1/5 PCI: initial commit

used shorten version of linux-2.6.39 pci_ids.h

---
 drivers/Makefile                |   1 +
 drivers/pci/Kconfig             |  12 ++
 drivers/pci/Makefile            |   8 ++
 drivers/pci/bus.c               | 110 ++++++++++++++++
 drivers/pci/pci.c               | 282 ++++++++++++++++++++++++++++++++++++++++
 include/linux/mod_devicetable.h |  20 +++
 include/linux/pci.h             | 241 ++++++++++++++++++++++++++++++++++
 include/linux/pci_ids.h         | 136 +++++++++++++++++++
 include/linux/pci_regs.h        | 118 +++++++++++++++++
 9 files changed, 928 insertions(+)
 create mode 100644 drivers/pci/Kconfig
 create mode 100644 drivers/pci/Makefile
 create mode 100644 drivers/pci/bus.c
 create mode 100644 drivers/pci/pci.c
 create mode 100644 include/linux/mod_devicetable.h
 create mode 100644 include/linux/pci.h
 create mode 100644 include/linux/pci_ids.h
 create mode 100644 include/linux/pci_regs.h
drivers/Makefile +1 -0
index ef3604f..1990e86 100644
@@ -26,3 +26,4 @@ obj-y += pinctrl/
 obj-y += bus/
 obj-$(CONFIG_REGULATOR) += regulator/
 obj-$(CONFIG_RESET_CONTROLLER) += reset/
+obj-$(CONFIG_PCI) += pci/
drivers/pci/Kconfig new file +12 -0
new file mode 100644
index 0000000..88b8dfb
@@ -0,0 +1,12 @@
+#
+# PCI configuration
+#
+config PCI_DEBUG
+	bool "PCI Debugging"
+	depends on PCI
+	help
+	  Say Y here if you want the PCI core to produce a bunch of debug
+	  messages to the system log.  Select this if you are having a
+	  problem with PCI support and want to see more of what is going on.
+
+	  When in doubt, say N.
drivers/pci/Makefile new file +8 -0
new file mode 100644
index 0000000..c7d43c3
@@ -0,0 +1,8 @@
+#
+# Makefile for the PCI bus specific drivers.
+#
+obj-y		+= pci.o bus.o
+
+ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG
+
+CPPFLAGS += $(ccflags-y)
drivers/pci/bus.c new file +110 -0

110 lines not on this page · raw message

drivers/pci/pci.c new file +282 -0

282 lines not on this page · raw message

include/linux/mod_devicetable.h new file +20 -0
new file mode 100644
index 0000000..c822075
@@ -0,0 +1,20 @@
+/*
+ * Device tables which are exported to userspace via
+ * scripts/mod/file2alias.c.  You must keep that file in sync with this
+ * header.
+ */
+
+#ifndef LINUX_MOD_DEVICETABLE_H
+#define LINUX_MOD_DEVICETABLE_H
+
+#include <linux/types.h>
+
+#define PCI_ANY_ID (~0)
+
+struct pci_device_id {
+	__u32 vendor, device;		/* Vendor and device ID or PCI_ANY_ID*/
+	__u32 subvendor, subdevice;	/* Subsystem ID's or PCI_ANY_ID */
+	__u32 class, class_mask;	/* (class,subclass,prog-if) triplet */
+};
+
+#endif /* LINUX_MOD_DEVICETABLE_H */
include/linux/pci.h new file +241 -0

241 lines not on this page · raw message

include/linux/pci_ids.h new file +136 -0

136 lines not on this page · raw message

include/linux/pci_regs.h new file +118 -0

118 lines not on this page · raw message

Signature · 7 lines
1.9.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

RFC v3 2/5 commands: add 'lspci' command

In reply to Antony Pavlov
---
 commands/Kconfig  |  8 ++++++++
 commands/Makefile |  1 +
 commands/lspci.c  | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+)
 create mode 100644 commands/lspci.c
commands/Kconfig +8 -0
index eed6fbd..c98dbc5 100644
@@ -207,6 +207,14 @@ config CMD_REGULATOR
 	  the regulator command lists the currently registered regulators and
 	  their current state.
 
+config CMD_LSPCI
+	bool
+	depends on PCI
+	prompt "lspci command"
+	default y
+	help
+	  The lspci command allows to list all PCI devices.
+
 config CMD_VERSION
 	tristate
 	default y
commands/Makefile +1 -0
index a84d333..d42aca5 100644
@@ -99,3 +99,4 @@ obj-$(CONFIG_CMD_READF)		+= readf.o
 obj-$(CONFIG_CMD_MENUTREE)	+= menutree.o
 obj-$(CONFIG_CMD_2048)		+= 2048.o
 obj-$(CONFIG_CMD_REGULATOR)	+= regulator.o
+obj-$(CONFIG_CMD_LSPCI)		+= lspci.o
commands/lspci.c new file +49 -0

49 lines not on this page · raw message

Signature · 7 lines
1.9.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#8 lore raw

RFC v3 3/5 net: add RealTek RTL-8139 PCI Ethernet driver

In reply to Antony Pavlov

This driver is based on Linux 2.6.39 8139too driver.

---
 drivers/net/Kconfig     |   8 +
 drivers/net/Makefile    |   1 +
 drivers/net/rtl8139.c   | 621 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/pci_ids.h |   5 +
 4 files changed, 635 insertions(+)
 create mode 100644 drivers/net/rtl8139.c
drivers/net/Kconfig +8 -0
index 7a0d5e1..975c927 100644
@@ -130,6 +130,14 @@ config DRIVER_NET_ORION
 	select PHYLIB
 	select MDIO_MVEBU
 
+config DRIVER_NET_RTL8139
+	bool "RealTek RTL-8139 PCI Ethernet driver"
+	depends on PCI
+	select PHYLIB
+	help
+	  This is a driver for the Fast Ethernet PCI network cards based on
+	  the RTL 8139 chips.
+
 config DRIVER_NET_SMC911X
 	bool "smc911x ethernet driver"
 	select PHYLIB
drivers/net/Makefile +1 -0
index 65f0d8b..d907061 100644
@@ -20,6 +20,7 @@ obj-$(CONFIG_DRIVER_NET_MICREL)		+= ksz8864rmn.o
 obj-$(CONFIG_DRIVER_NET_MPC5200)	+= fec_mpc5200.o
 obj-$(CONFIG_DRIVER_NET_NETX)		+= netx_eth.o
 obj-$(CONFIG_DRIVER_NET_ORION)		+= orion-gbe.o
+obj-$(CONFIG_DRIVER_NET_RTL8139)	+= rtl8139.o
 obj-$(CONFIG_DRIVER_NET_SMC911X)	+= smc911x.o
 obj-$(CONFIG_DRIVER_NET_SMC91111)	+= smc91111.o
 obj-$(CONFIG_DRIVER_NET_TAP)		+= tap.o
drivers/net/rtl8139.c new file +621 -0

621 lines not on this page · raw message

include/linux/pci_ids.h +5 -0
index 49e2954..17ac7fd 100644
@@ -134,3 +134,8 @@
 #define PCI_CLASS_SP_OTHER		0x1180
 
 #define PCI_CLASS_OTHERS		0xff
+
+/* Vendors and devices.  Sort key: vendor first, device next. */
+
+#define PCI_VENDOR_ID_REALTEK		0x10ec
+#define PCI_DEVICE_ID_REALTEK_8139	0x8139
Signature · 7 lines
1.9.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#9 lore raw

RFC v3 4/5 MIPS: add PCI support for GT64120-based Malta board

In reply to Antony Pavlov
---
 arch/mips/Kconfig                                |  22 ++
 arch/mips/include/asm/gt64120.h                  |  53 +++++
 arch/mips/mach-malta/Makefile                    |   1 +
 arch/mips/mach-malta/include/mach/mach-gt64120.h |   2 +
 arch/mips/mach-malta/pci.c                       | 246 +++++++++++++++++++++++
 5 files changed, 324 insertions(+)
 create mode 100644 arch/mips/mach-malta/pci.c
arch/mips/Kconfig +22 -0
index f6b9765..603ce6e 100644
@@ -45,6 +45,7 @@ config MACH_MIPS_MALTA
 	select SYS_SUPPORTS_BIG_ENDIAN
 	select HAS_DEBUG_LL
 	select GPIOLIB
+	select HW_HAS_PCI
 
 config MACH_MIPS_AR231X
 	bool "Atheros ar231x-based boards"
@@ -330,6 +331,27 @@ config NMON_HELP
 
 endmenu
 
+menu "Bus options (PCI)"
+
+config HW_HAS_PCI
+	bool
+
+config PCI
+	bool "Support for PCI controller"
+	depends on HW_HAS_PCI
+	select PCI_DOMAINS
+	help
+	  Find out whether you have a PCI motherboard. PCI is the name of a
+	  bus system, i.e. the way the CPU talks to the other stuff inside
+	  your box. If you have PCI, say Y, otherwise N.
+
+config PCI_DOMAINS
+	bool
+
+source "drivers/pci/Kconfig"
+
+endmenu
+
 source common/Kconfig
 source commands/Kconfig
 source net/Kconfig
arch/mips/include/asm/gt64120.h +53 -0

63 lines not on this page · raw message

arch/mips/mach-malta/Makefile +1 -0
index f3cc668..0c5a701 100644
@@ -1 +1,2 @@
 obj-y += reset.o
+obj-$(CONFIG_PCI) += pci.o
arch/mips/mach-malta/include/mach/mach-gt64120.h +2 -0
index ed1e23e..8f20fcf 100644
@@ -10,4 +10,6 @@
 
 #define MIPS_GT_BASE	0x1be00000
 
+#define GT64120_BASE    0xbbe00000
+
 #endif /* _ASM_MACH_MIPS_MACH_GT64120_DEP_H */
arch/mips/mach-malta/pci.c new file +246 -0

246 lines not on this page · raw message

Signature · 7 lines
1.9.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#10 lore raw

RFC v3 5/5 MIPS: qemu-malta_defconfig: enable PCI & network stuff

In reply to Antony Pavlov

qemu usage:

  # ifconfig br0:1 172.20.0.1
  # qemu-system-mips -nodefaults -nographic -M malta -m 256 \
    -serial stdio -monitor null \
    -bios ./barebox-flash-image \
    -net nic,vlan=0,model=rtl8139 \
    -net tap,vlan=0,script=net_br0.sh

...

barebox:/ eth0.ipaddr=172.20.0.2
barebox:/ eth0.serverip=172.20.0.1
barebox:/ ping 172.20.0.1
phy0: Link is up - 100/Full
host 172.20.0.1 is alive
barebox:/

Sample net_br0.sh (for connecting to br0 interface, so you can connect barebox to your real network):

#!/bin/sh

brctl addif br0 $1
ifconfig $1 up

---
 arch/mips/configs/qemu-malta_defconfig | 4 ++++
 1 file changed, 4 insertions(+)
arch/mips/configs/qemu-malta_defconfig +4 -0
index 78f175d..4fee70e 100644
@@ -1,5 +1,7 @@
 CONFIG_BUILTIN_DTB=y
 CONFIG_BUILTIN_DTB_NAME="qemu-malta"
+CONFIG_PCI=y
+CONFIG_PCI_DEBUG=y
 CONFIG_PBL_IMAGE=y
 CONFIG_STACK_SIZE=0x7000
 CONFIG_BROKEN=y
@@ -32,6 +34,7 @@ CONFIG_CMD_UNCOMPRESS=y
 CONFIG_CMD_GETOPT=y
 CONFIG_CMD_SLEEP=y
 CONFIG_CMD_DHCP=y
+CONFIG_CMD_MIITOOL=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_TFTP=y
 CONFIG_CMD_ECHO_E=y
@@ -56,6 +59,7 @@ CONFIG_NET_NETCONSOLE=y
 CONFIG_NET_RESOLV=y
 CONFIG_OFDEVICE=y
 CONFIG_OF_BAREBOX_DRIVERS=y
+CONFIG_DRIVER_NET_RTL8139=y
 # CONFIG_SPI is not set
 CONFIG_I2C=y
 CONFIG_I2C_GPIO=y
Signature · 7 lines
1.9.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

Re: [RFC v3 1/5] PCI: initial commit

In reply to Antony Pavlov

Hi Antony,

nice to see a new revision of this PCI stuff. I've used v2 as a base for my Tegra PCI hacking during our Techweek.

This revision looks really good and I think it removes most of the issues I've stumbled across. Some comments below.

Regards,
Lucas

Am Donnerstag, den 26.06.2014, 02:32 +0400 schrieb Antony Pavlov:

Quoted 29 lines

used shorten version of linux-2.6.39 pci_ids.h

---
 drivers/Makefile                |   1 +
 drivers/pci/Kconfig             |  12 ++
 drivers/pci/Makefile            |   8 ++
 drivers/pci/bus.c               | 110 ++++++++++++++++
 drivers/pci/pci.c               | 282 ++++++++++++++++++++++++++++++++++++++++
 include/linux/mod_devicetable.h |  20 +++
 include/linux/pci.h             | 241 ++++++++++++++++++++++++++++++++++
 include/linux/pci_ids.h         | 136 +++++++++++++++++++
 include/linux/pci_regs.h        | 118 +++++++++++++++++
 9 files changed, 928 insertions(+)
 create mode 100644 drivers/pci/Kconfig
 create mode 100644 drivers/pci/Makefile
 create mode 100644 drivers/pci/bus.c
 create mode 100644 drivers/pci/pci.c
 create mode 100644 include/linux/mod_devicetable.h
 create mode 100644 include/linux/pci.h
 create mode 100644 include/linux/pci_ids.h
 create mode 100644 include/linux/pci_regs.h
drivers/Makefile +0 -0
index ef3604f..1990e86 100644

drivers/Makefile obj-y += pinctrl/ · line 29

Quoted 4 lines
drivers/Makefile +1 -0
@@ -26,3 +26,4 @@ obj-y += pinctrl/
 obj-y += bus/
 obj-$(CONFIG_REGULATOR) += regulator/
 obj-$(CONFIG_RESET_CONTROLLER) += reset/
+obj-$(CONFIG_PCI) += pci/

Can we please move the Kconfig options for this into drivers/Kconfig? I know you did it similar to the kernel, but it just does not feel right to have those into the board/arch Kconfig. PCI is just another bus like USB and the symbol HW_HAS_PCI should be enough to decide if we show this options or not.

Quoted 32 lines
drivers/pci/Kconfig new file +12 -0
new file mode 100644
index 0000000..88b8dfb
@@ -0,0 +1,12 @@
+#
+# PCI configuration
+#
+config PCI_DEBUG
+	bool "PCI Debugging"
+	depends on PCI
+	help
+	  Say Y here if you want the PCI core to produce a bunch of debug
+	  messages to the system log.  Select this if you are having a
+	  problem with PCI support and want to see more of what is going on.
+
+	  When in doubt, say N.
drivers/pci/Makefile new file +8 -0
new file mode 100644
index 0000000..c7d43c3
@@ -0,0 +1,8 @@
+#
+# Makefile for the PCI bus specific drivers.
+#
+obj-y		+= pci.o bus.o
+
+ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG
+
+CPPFLAGS += $(ccflags-y)

[...]

Quoted 9 lines
drivers/pci/pci.c new file +3 -0
new file mode 100644
index 0000000..9bee73f
@@ -0,0 +1,282 @@
+#include <common.h>
+#include <linux/pci.h>
+

drivers/pci/pci.c line 13

Quoted 10 lines
drivers/pci/pci.c new file +10 -0
+#ifdef DEBUG
+#define DBG(x...) printk(x)
+#else
+#define DBG(x...)
+#endif
+
+static struct pci_controller *hose_head, **hose_tail = &hose_head;
+
+struct pci_bus *pci_root;
+

This should really be a list, like it is in the kernel now. With the introduction of PCI host controller drivers we have the situation where a system may have more than one PCI root bus.

Quoted 35 lines
drivers/pci/pci.c new file +35 -0
+static struct pci_bus *pci_alloc_bus(void)
+{
+	struct pci_bus *b;
+
+	b = kzalloc(sizeof(*b), GFP_KERNEL);
+	if (b) {
+		INIT_LIST_HEAD(&b->node);
+		INIT_LIST_HEAD(&b->children);
+		INIT_LIST_HEAD(&b->devices);
+		INIT_LIST_HEAD(&b->slots);
+		INIT_LIST_HEAD(&b->resources);
+	}
+	return b;
+}
+
+void register_pci_controller(struct pci_controller *hose)
+{
+	struct pci_bus *bus;
+
+	*hose_tail = hose;
+	hose_tail = &hose->next;
+
+	bus = pci_alloc_bus();
+	hose->bus = bus;
+	bus->ops = hose->pci_ops;
+	bus->resource[0] = hose->mem_resource;
+	bus->resource[1] = hose->io_resource;
+
+	pci_scan_bus(bus);
+
+	pci_root = bus;
+
+	return;
+}
+

[...]

Signature · 8 lines
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

Re: [RFC v3 2/5] commands: add 'lspci' command

In reply to Antony Pavlov

Am Donnerstag, den 26.06.2014, 02:32 +0400 schrieb Antony Pavlov:

Quoted 8 lines
---
 commands/Kconfig  |  8 ++++++++
 commands/Makefile |  1 +
 commands/lspci.c  | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+)
 create mode 100644 commands/lspci.c

[...]

Quoted 24 lines
commands/lspci.c new file +18 -0
new file mode 100644
index 0000000..5e1f6dd
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2011-2014 Antony Pavlov <[email protected]>
+ *
+ * This file is part of barebox.
+ * See file CREDITS for list of people who contributed to this project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>

commands/lspci.c line 28

Quoted 10 lines
commands/lspci.c new file +10 -0
+#include <command.h>
+#include <complete.h>
+#include <linux/pci.h>
+
+static int do_lspci(int argc, char *argv[])
+{
+	struct pci_dev *dev;
+
+	if (!pci_root) {
+		printf("no pci!\n");

Please rephrase this to something like "No PCI root busses found".

Quoted 21 lines
commands/lspci.c new file +21 -0
+		return 1;
+	}
+
+	list_for_each_entry(dev, &pci_root->devices, bus_list) {
+		printf("%02x: %04x: %04x:%04x (rev %02x)\n",
+			      dev->devfn,
+			      (dev->class >> 8) & 0xffff,
+			      dev->vendor,
+			      dev->device,
+			      dev->revision);
+	}
+
+	return 0;
+}
+
+BAREBOX_CMD_START(lspci)
+	.cmd            = do_lspci,
+	BAREBOX_CMD_DESC("Show PCI info")
+	BAREBOX_CMD_GROUP(CMD_GRP_INFO)
+	BAREBOX_CMD_COMPLETE(empty_complete)
+BAREBOX_CMD_END
Signature · 8 lines
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

Re: [RFC v3 2/5] commands: add 'lspci' command

Quoted 40 lines · On Mon, 30 Jun 2014 12:21:50 +0200 Lucas Stach <[email protected]> wrote:

Am Donnerstag, den 26.06.2014, 02:32 +0400 schrieb Antony Pavlov:

Quoted 8 lines
---
 commands/Kconfig  |  8 ++++++++
 commands/Makefile |  1 +
 commands/lspci.c  | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+)
 create mode 100644 commands/lspci.c

[...]

Quoted 28 lines
commands/lspci.c new file +22 -0
new file mode 100644
index 0000000..5e1f6dd
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2011-2014 Antony Pavlov <[email protected]>
+ *
+ * This file is part of barebox.
+ * See file CREDITS for list of people who contributed to this project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <command.h>
+#include <complete.h>
+#include <linux/pci.h>
+
Quoted 8 lines

commands/lspci.c line 28

Quoted 6 lines
commands/lspci.c new file +6 -0
+static int do_lspci(int argc, char *argv[])
+{
+	struct pci_dev *dev;
+
+	if (!pci_root) {
+		printf("no pci!\n");

Please rephrase this to something like "No PCI root busses found".

Thanks for this remark!

I prefer the "No PCI bus detected" message from linux-2.0.0 :)

Quoted 26 lines
Quoted 21 lines
commands/lspci.c new file +21 -0
+		return 1;
+	}
+
+	list_for_each_entry(dev, &pci_root->devices, bus_list) {
+		printf("%02x: %04x: %04x:%04x (rev %02x)\n",
+			      dev->devfn,
+			      (dev->class >> 8) & 0xffff,
+			      dev->vendor,
+			      dev->device,
+			      dev->revision);
+	}
+
+	return 0;
+}
+
+BAREBOX_CMD_START(lspci)
+	.cmd            = do_lspci,
+	BAREBOX_CMD_DESC("Show PCI info")
+	BAREBOX_CMD_GROUP(CMD_GRP_INFO)
+	BAREBOX_CMD_COMPLETE(empty_complete)
+BAREBOX_CMD_END
Signature · 2 lines
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |
Signature · 8 lines
-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

Re: [RFC v3 1/5] PCI: initial commit

In reply to Lucas Stach
Quoted 26 lines
drivers/pci/pci.c new file +25 -0
+int
+pci_read_config_byte(struct pci_dev *dev, u8 where, u8 *val)
+{
+	return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val);
+}
+
+int
+pci_read_config_word(struct pci_dev *dev, u8 where, u16 *val)
+{
+	return pci_bus_read_config_word(dev->bus, dev->devfn, where, val);
+}
+
+int
+pci_read_config_dword(struct pci_dev *dev, u8 where, u32 *val)
+{
+	return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val);
+}
+
+int
+pci_write_config_byte(struct pci_dev *dev, u8 where, u8 val)
+{
+	return pci_bus_write_config_byte(dev->bus, dev->devfn, where, val);
+}
+
+int

drivers/pci/pci.c line 143

Quoted 10 lines
drivers/pci/pci.c new file +10 -0
+pci_write_config_word(struct pci_dev *dev, u8 where, u16 val)
+{
+	return pci_bus_write_config_word(dev->bus, dev->devfn, where, val);
+}
+
+int
+pci_write_config_dword(struct pci_dev *dev, u8 where, u32 val)
+{
+	return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val);
+}

I would suggest replacing the "u8 where" (in pci_read/write_config and others) by "int where" to allow future access to PCIe extended configuration space (up to offset 0x1000).

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#4 lore raw

Re: [RFC v3 1/5] PCI: initial commit

Quoted 31 lines · On Tue, 01 Jul 2014 09:29:23 +0200 Clément Léger <[email protected]>…
Quoted 31 lines
drivers/pci/pci.c new file +31 -0
+int
+pci_read_config_byte(struct pci_dev *dev, u8 where, u8 *val)
+{
+	return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val);
+}
+
+int
+pci_read_config_word(struct pci_dev *dev, u8 where, u16 *val)
+{
+	return pci_bus_read_config_word(dev->bus, dev->devfn, where, val);
+}
+
+int
+pci_read_config_dword(struct pci_dev *dev, u8 where, u32 *val)
+{
+	return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val);
+}
+
+int
+pci_write_config_byte(struct pci_dev *dev, u8 where, u8 val)
+{
+	return pci_bus_write_config_byte(dev->bus, dev->devfn, where, val);
+}
+
+int
+pci_write_config_word(struct pci_dev *dev, u8 where, u16 val)
+{
+	return pci_bus_write_config_word(dev->bus, dev->devfn, where, val);
+}
+
+int
Quoted 8 lines

drivers/pci/pci.c line 143

Quoted 5 lines
drivers/pci/pci.c new file +4 -0
+pci_write_config_dword(struct pci_dev *dev, u8 where, u32 val)
+{
+	return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val);
+}

I would suggest replacing the "u8 where" (in pci_read/write_config and others) by "int where" to allow future access to PCIe extended configuration space (up to offset 0x1000).

Already done in [RFC v4] patchseries!

--
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox