barebox PCI support
Subsystems (3)
PATCH v5 1/7 linux/ioport.h: include missed <linux/list.h>
In reply to Antony Pavlov--- include/linux/ioport.h | 1 + 1 file changed, 1 insertion(+)
include/linux/ioport.h +1 -0
@@ -9,6 +9,7 @@#define _LINUX_IOPORT_H#ifndef __ASSEMBLY__ +#include <linux/list.h> #include <linux/compiler.h> #include <linux/types.h> /*
Signature · 7 lines
2.0.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v5 2/7 MIPS: add dma_alloc_coherent()
In reply to Antony Pavlov--- arch/mips/include/asm/dma-mapping.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
arch/mips/include/asm/dma-mapping.h new file +25 -0
@@ -0,0 +1,25 @@ +#ifndef _ASM_DMA_MAPPING_H +#define _ASM_DMA_MAPPING_H + +#include <xfuncs.h> +#include <asm/addrspace.h> +#include <asm/types.h> +#include <malloc.h> + +static inline void *dma_alloc_coherent (size_t size,dma_addr_t *dma_handle) +{ +void *ret; + + ret =xmemalign (PAGE_SIZE , size); + + *dma_handle =CPHYSADDR (ret); + +return (void *)CKSEG1ADDR (ret); +} + +static inline void dma_free_coherent (void *vaddr) +{ +free (vaddr); +} + +#endif /* _ASM_DMA_MAPPING_H */
Signature · 7 lines
2.0.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
v5 cover barebox PCI support
This patchseries introduce simple PCI bus support for barebox.
This patchseries can be found on github:
https://github.com/frantony/barebox/tree/pci.20140704
Changes since RFC v4:
* introduce pci_iomap();
* rtl8139: use dev_err instead of printk;
* rtl8139: clean '#if 0';
* struct pci_bus: drop unused fields.
Changes since RFC v3:
* rebase over latest 'next';
* use list for pci_root_buses;
* move common PCI Kconfig stuff from arch/mips to drivers/pci;
* make pci_*_write_config_* PCIe-friendly (use 'int' type for
config register address);
* drop some unused stuff;
* change lspci "no pci" error message to "No PCI bus detected";
* rtl8139: use dma_alloc_coherent();
* rtl8139: use pci_set_master() & pci_clear_master().
Antony Pavlov (7):
linux/ioport.h: include missed <linux/list.h>
MIPS: add dma_alloc_coherent()
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 | 1 + arch/mips/configs/qemu-malta_defconfig | 4 + arch/mips/include/asm/dma-mapping.h | 25 + 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 | 236 +++++++++ commands/Kconfig | 8 + commands/Makefile | 1 + commands/lspci.c | 52 ++ drivers/Kconfig | 1 + drivers/Makefile | 1 + drivers/net/Kconfig | 8 + drivers/net/Makefile | 1 + drivers/net/rtl8139.c | 605 +++++++++++++++++++++++ drivers/pci/Kconfig | 29 ++ drivers/pci/Makefile | 8 + drivers/pci/bus.c | 110 +++++ drivers/pci/pci.c | 292 +++++++++++ drivers/pci/pci_iomap.c | 29 ++ include/linux/ioport.h | 1 + include/linux/mod_devicetable.h | 20 + include/linux/pci.h | 297 +++++++++++ include/linux/pci_ids.h | 141 ++++++ include/linux/pci_regs.h | 110 +++++ 25 files changed, 2036 insertions(+) create mode 100644 arch/mips/include/asm/dma-mapping.h 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 drivers/pci/pci_iomap.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
2.0.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v5 4/7 commands: add 'lspci' command
--- commands/Kconfig | 8 ++++++++ commands/Makefile | 1 + commands/lspci.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+)
commands/Kconfig +8 -0
@@ -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
@@ -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 +52 -0
52 lines not on this page · raw message
Signature · 7 lines
2.0.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v5 3/7 PCI: initial commit
In reply to Antony Pavlovused shorten version of linux-2.6.39 pci_ids.h
--- drivers/Kconfig | 1 + drivers/Makefile | 1 + drivers/pci/Kconfig | 29 ++++ drivers/pci/Makefile | 8 ++ drivers/pci/bus.c | 110 +++++++++++++++ drivers/pci/pci.c | 292 +++++++++++++++++++++++++++++++++++++++ drivers/pci/pci_iomap.c | 29 ++++ include/linux/mod_devicetable.h | 20 +++ include/linux/pci.h | 297 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci_ids.h | 136 ++++++++++++++++++ include/linux/pci_regs.h | 110 +++++++++++++++ 11 files changed, 1033 insertions(+)
drivers/Kconfig +1 -0
@@ -27,5 +27,6 @@ source "drivers/pinctrl/Kconfig" source "drivers/bus/Kconfig" source "drivers/regulator/Kconfig" source "drivers/reset/Kconfig" +source "drivers/pci/Kconfig" endmenu
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/
drivers/pci/Kconfig new file +29 -0
@@ -0,0 +1,29 @@ +config HW_HAS_PCI + bool + +if HW_HAS_PCI + +menu "PCI bus options" + +config PCI + bool "Support for PCI controller" + depends on HW_HAS_PCI + 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_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. + +endmenu + +endif
drivers/pci/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# Makefile for the PCI bus specific drivers. +# +obj-y += pci.o bus.o pci_iomap.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 +292 -0
292 lines not on this page · raw message
drivers/pci/pci_iomap.c new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Implement the default iomap interfaces +* +* (C) Copyright 2004 Linus Torvalds +*/ +#include <linux/pci.h> +#include <io.h> + +#include <module.h> + +/** +* pci_iomap - create a virtual mapping cookie for a PCI BAR +* @dev: PCI device that owns the BAR +* @bar: BAR number +* +* Using this function you will get a __iomem address to your device BAR. +* You can access it using ioread*() and iowrite*(). These functions hide +* the details if this is a MMIO or PIO address space and will just do what +* you expect from them in the correct way. +* +*/ +void __iomem *pci_iomap (struct pci_dev *dev,int bar) +{ +struct pci_bus *bus = dev->bus; +resource_size_t start =pci_resource_start (dev, bar); + +return (void *)bus->ops->res_start (bus, start); +} +EXPORT_SYMBOL (pci_iomap);
include/linux/mod_devicetable.h new file +20 -0
@@ -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 +297 -0
297 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 +110 -0
110 lines not on this page · raw message
Signature · 7 lines
2.0.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v5 6/7 MIPS: add PCI support for GT64120-based Malta board
In reply to Antony Pavlov--- arch/mips/Kconfig | 1 + 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 | 236 +++++++++++++++++++++++ 5 files changed, 293 insertions(+)
arch/mips/Kconfig +1 -0
@@ -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"
arch/mips/include/asm/gt64120.h +53 -0
63 lines not on this page · raw message
arch/mips/mach-malta/Makefile +1 -0
@@ -1 +1,2 @@ obj-y += reset.o +obj-$(CONFIG_PCI) += pci.o
arch/mips/mach-malta/include/mach/mach-gt64120.h +2 -0
@@ -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 +236 -0
236 lines not on this page · raw message
Signature · 7 lines
2.0.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v5 5/7 net: add RealTek RTL-8139 PCI Ethernet driver
In reply to Antony PavlovThis driver is based on Linux 2.6.39 8139too driver.
--- drivers/net/Kconfig | 8 + drivers/net/Makefile | 1 + drivers/net/rtl8139.c | 605 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/pci_ids.h | 5 + 4 files changed, 619 insertions(+)
drivers/net/Kconfig +8 -0
@@ -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
@@ -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 +605 -0
605 lines not on this page · raw message
include/linux/pci_ids.h +5 -0
@@ -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
2.0.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v5 7/7 MIPS: qemu-malta_defconfig: enable PCI & network stuff
In reply to Antony Pavlovqemu 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
@@ -32,6 +32,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 +57,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
@@ -66,6 +68,8 @@ CONFIG_DRIVER_CFI=y # CONFIG_DRIVER_CFI_BANK_WIDTH_2 is not set CONFIG_CFI_BUFFER_WRITE=y CONFIG_GPIO_MALTA_FPGA_I2C=y +CONFIG_PCI=y +CONFIG_PCI_DEBUG=y CONFIG_FS_CRAMFS=y CONFIG_FS_TFTP=y CONFIG_FS_FAT=y
Signature · 7 lines
2.0.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 5 lines · Antony Pavlov
This patchseries introduce simple PCI bus support for barebox.
This patchseries can be found on github:
Applied, thanks
Sascha
Quoted 78 lines
Changes since RFC v4:
* introduce
pci_iomap();
* rtl8139: usedev_errinstead of printk;
* rtl8139: clean '#if 0';
* structpci_bus: drop unused fields.Changes since RFC v3:
* rebase over latest 'next';
* use list forpci_root_buses;
* move common PCIKconfigstuff fromarch/mipstodrivers/pci;
* make pci_*_write_config_* PCIe-friendly (use 'int' type forconfig register address);* drop some unused stuff;
* change lspci "no pci" error message to "No PCI bus detected";
* rtl8139: usedma_alloc_coherent();
* rtl8139: usepci_set_master()&pci_clear_master().Antony Pavlov (7):
linux/ioport.h: include missed <linux/list.h>
MIPS: adddma_alloc_coherent()
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 stuffarch/mips/Kconfig | 1 + arch/mips/configs/qemu-malta_defconfig | 4 + arch/mips/include/asm/dma-mapping.h | 25 + 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 | 236 +++++++++ commands/Kconfig | 8 + commands/Makefile | 1 + commands/lspci.c | 52 ++ drivers/Kconfig | 1 + drivers/Makefile | 1 + drivers/net/Kconfig | 8 + drivers/net/Makefile | 1 + drivers/net/rtl8139.c | 605 +++++++++++++++++++++++ drivers/pci/Kconfig | 29 ++ drivers/pci/Makefile | 8 + drivers/pci/bus.c | 110 +++++ drivers/pci/pci.c | 292 +++++++++++ drivers/pci/pci_iomap.c | 29 ++ include/linux/ioport.h | 1 + include/linux/mod_devicetable.h | 20 + include/linux/pci.h | 297 +++++++++++ include/linux/pci_ids.h | 141 ++++++ include/linux/pci_regs.h | 110 +++++ 25 files changed, 2036 insertions(+) create mode 100644 arch/mips/include/asm/dma-mapping.h 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 drivers/pci/pci_iomap.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.hSignature · 7 lines
2.0.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v5 3/7] PCI: initial commit
In reply to Antony Pavlovdrivers/pci/bus.c
Quoted 93 lines · Antony Pavlov
used shorten version of linux-2.6.39
pci_ids.hSigned-off-by Antony Pavlov <[email protected]>Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- drivers/Kconfig | 1 + drivers/Makefile | 1 + drivers/pci/Kconfig | 29 ++++ drivers/pci/Makefile | 8 ++ drivers/pci/bus.c | 110 +++++++++++++++ drivers/pci/pci.c | 292 +++++++++++++++++++++++++++++++++++++++ drivers/pci/pci_iomap.c | 29 ++++ include/linux/mod_devicetable.h | 20 +++ include/linux/pci.h | 297 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci_ids.h | 136 ++++++++++++++++++ include/linux/pci_regs.h | 110 +++++++++++++++ 11 files changed, 1033 insertions(+)drivers/Kconfig +1
-0@@ -27,5 +27,6 @@ source "drivers/pinctrl/Kconfig" source "drivers/bus/Kconfig" source "drivers/regulator/Kconfig" source "drivers/reset/Kconfig" +source "drivers/pci/Kconfig" endmenudrivers/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/drivers/pci/Kconfig new file +29
-0@@ -0,0 +1,29 @@ +config HW_HAS_PCI + bool + +if HW_HAS_PCI + +menu "PCI bus options" + +config PCI + bool "Support for PCI controller" + depends on HW_HAS_PCI + 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_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. + +endmenu + +endifdrivers/pci/Makefile new file +8
-0@@ -0,0 +1,8 @@ +# +# Makefile for the PCI bus specific drivers. +# +obj-y += pci.o bus.o pci_iomap.o + +ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG + +CPPFLAGS += $(ccflags-y)drivers/pci/bus.c new file +0
-0
missing copyright and licence
I do not remember who wrote it you, me or both
drivers/pci/pci.c
Quoted 116 lines
drivers/pci/bus.c new file +110
-0@@ -0,0 +1,110 @@ +#include <common.h> +#include <init.h> +#include <driver.h> +#include <linux/pci.h> + +/** +* pci_match_one_device - Tell if a PCI device structure has a matching +* PCI device id structure +* @id: single PCI device id structure to match +* @dev: the PCI device structure to match against +* +* Returns the matching pci_device_id structure or %NULL if there is no match. +*/ +static inline const struct pci_device_id * +pci_match_one_device (const struct pci_device_id *id,const struct pci_dev *dev) +{ +if ((id->vendor ==PCI_ANY_ID || id->vendor == dev->vendor) && + (id->device ==PCI_ANY_ID || id->device == dev->device) && + (id->subvendor ==PCI_ANY_ID || id->subvendor == dev->subsystem_vendor) && + (id->subdevice ==PCI_ANY_ID || id->subdevice == dev->subsystem_device) && + !((id->class ^ dev->class) & id->class_mask)) +return id; +return NULL ; +} + +static int pci_match (struct device_d *dev,struct driver_d *drv) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct pci_driver *pdrv =to_pci_driver (drv); +struct pci_device_id *id; + +for (id = (struct pci_device_id *)pdrv->id_table; id->vendor; id++) +if (pci_match_one_device (id, pdev)) { + dev->priv = id; +return 0 ; + } + +return -1 ; +} + +static int pci_probe (struct device_d *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct pci_driver *pdrv =to_pci_driver (dev->driver); + +return pdrv->probe (pdev, dev->priv); +} + +static void pci_remove (struct device_d *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct pci_driver *pdrv =to_pci_driver (dev->driver); + + pdrv->remove (pdev); +} + +struct bus_type pci_bus = { + .name ="pci" , + .match = pci_match, + .probe = pci_probe, + .remove = pci_remove, +}; + +static int pci_bus_init (void ) +{ +return bus_register (&pci_bus); +} +pure_initcall (pci_bus_init); + +int pci_register_driver (struct pci_driver *pdrv) +{ +struct driver_d *drv = &pdrv->driver; + +if (!pdrv->id_table) +return -EIO ; + + drv->name = pdrv->name; + drv->bus = &pci_bus; + +return register_driver (drv); +} + +int pci_register_device (struct pci_dev *pdev) +{ +char str[6 ]; +struct device_d *dev = &pdev->dev; +int ret; + +strcpy (dev->name,"pci" ); + dev->bus = &pci_bus; + dev->id =DEVICE_ID_DYNAMIC ; + + ret =register_device (dev); + +if (ret) +return ret; + +sprintf (str,"%02x" , pdev->devfn); +dev_add_param_fixed (dev,"devfn" , str); +sprintf (str,"%04x" , (pdev->class >>8 ) &0xffff ); +dev_add_param_fixed (dev,"class" , str); +sprintf (str,"%04x" , pdev->vendor); +dev_add_param_fixed (dev,"vendor" , str); +sprintf (str,"%04x" , pdev->device); +dev_add_param_fixed (dev,"device" , str); +sprintf (str,"%04x" , pdev->revision); +dev_add_param_fixed (dev,"revision" , str); + +return 0 ; +}drivers/pci/pci.c new file +0
-0
same here
drivers/pci/pci.c line 8
Quoted 9 lines
drivers/pci/pci.c new file +8
-0@@ -0,0 +1,292 @@ +#include <common.h> +#include <linux/pci.h> + +#ifdef DEBUG +#define DBG(x...) printk(x) +#else +#define DBG(x...) +#endif
we need to use pr_debug or better dev_dbg
drivers/pci/pci.c line 19
Quoted 11 lines
drivers/pci/pci.c new file +11
-0+ +static struct pci_controller *hose_head, **hose_tail = &hose_head; + +LIST_HEAD (pci_root_buses); +EXPORT_SYMBOL (pci_root_buses); + +static struct pci_bus *pci_alloc_bus (void ) +{ +struct pci_bus *b; + + b =kzalloc (sizeof (*b),GFP_KERNEL );
if (!b) return b;
so no {}
Quoted 79 lines
drivers/pci/pci.c new file +79
-0+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); + +list_add_tail (&bus->node, &pci_root_buses); + +return ; +} + +/* +* Wrappers for all PCI configuration access functions. They just check +* alignment, do locking and call the low-level functions pointed to +* by pci_dev->ops. +*/ + +#define PCI_byte_BAD 0 +#define PCI_word_BAD (pos & 1) +#define PCI_dword_BAD (pos & 3) + +#define PCI_OP_READ (size,type,len) \ +int pci_bus_read_config_##size \ + (struct pci_bus *bus, unsigned int devfn, int pos, type *value) \ +{ \ + int res; \ + u32 data = 0; \ + if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ + res = bus->ops->read(bus, devfn, pos, len, &data); \ + *value = (type)data; \ + return res; \ +} + +#define PCI_OP_WRITE (size,type,len) \ +int pci_bus_write_config_##size \ + (struct pci_bus *bus, unsigned int devfn, int pos, type value) \ +{ \ + int res; \ + if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ + res = bus->ops->write(bus, devfn, pos, len, value); \ + return res; \ +} + +PCI_OP_READ(byte, u8, 1) +PCI_OP_READ(word, u16, 2) +PCI_OP_READ(dword, u32, 4) +PCI_OP_WRITE(byte, u8, 1) +PCI_OP_WRITE(word, u16, 2) +PCI_OP_WRITE(dword, u32, 4) + +EXPORT_SYMBOL (pci_bus_read_config_byte); +EXPORT_SYMBOL (pci_bus_read_config_word); +EXPORT_SYMBOL (pci_bus_read_config_dword); +EXPORT_SYMBOL (pci_bus_write_config_byte); +EXPORT_SYMBOL (pci_bus_write_config_word); +EXPORT_SYMBOL (pci_bus_write_config_dword); + +static struct pci_dev *alloc_pci_dev (void ) +{ +struct pci_dev *dev;
drivers/pci/pci.c line 108
Quoted 10 lines
drivers/pci/pci.c new file +10
-0+ + dev =kzalloc (sizeof (struct pci_dev ),GFP_KERNEL ); +if (!dev) +return NULL ; + +INIT_LIST_HEAD (&dev->bus_list); + +return dev; +} +
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v5 3/7] PCI: initial commit
Quoted 96 lines · On Mon, 7 Jul 2014 20:22:10 +0200 Jean-Christophe PLAGNIOL-VILLARD…
drivers/pci/bus.c
Quoted 93 lines · Antony Pavlov
used shorten version of linux-2.6.39
pci_ids.hSigned-off-by Antony Pavlov <[email protected]>Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- drivers/Kconfig | 1 + drivers/Makefile | 1 + drivers/pci/Kconfig | 29 ++++ drivers/pci/Makefile | 8 ++ drivers/pci/bus.c | 110 +++++++++++++++ drivers/pci/pci.c | 292 +++++++++++++++++++++++++++++++++++++++ drivers/pci/pci_iomap.c | 29 ++++ include/linux/mod_devicetable.h | 20 +++ include/linux/pci.h | 297 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci_ids.h | 136 ++++++++++++++++++ include/linux/pci_regs.h | 110 +++++++++++++++ 11 files changed, 1033 insertions(+)drivers/Kconfig +1
-0@@ -27,5 +27,6 @@ source "drivers/pinctrl/Kconfig" source "drivers/bus/Kconfig" source "drivers/regulator/Kconfig" source "drivers/reset/Kconfig" +source "drivers/pci/Kconfig" endmenudrivers/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/drivers/pci/Kconfig new file +29
-0@@ -0,0 +1,29 @@ +config HW_HAS_PCI + bool + +if HW_HAS_PCI + +menu "PCI bus options" + +config PCI + bool "Support for PCI controller" + depends on HW_HAS_PCI + 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_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. + +endmenu + +endifdrivers/pci/Makefile new file +8
-0@@ -0,0 +1,8 @@ +# +# Makefile for the PCI bus specific drivers. +# +obj-y += pci.o bus.o pci_iomap.o + +ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG + +CPPFLAGS += $(ccflags-y)drivers/pci/bus.c new file +0
-0missing copyright and licence
Quoted 1 line
I do not remember who wrote it you, me or both
both
Quoted 117 lines
drivers/pci/pci.c
Quoted 116 lines
drivers/pci/bus.c new file +110
-0@@ -0,0 +1,110 @@ +#include <common.h> +#include <init.h> +#include <driver.h> +#include <linux/pci.h> + +/** +* pci_match_one_device - Tell if a PCI device structure has a matching +* PCI device id structure +* @id: single PCI device id structure to match +* @dev: the PCI device structure to match against +* +* Returns the matching pci_device_id structure or %NULL if there is no match. +*/ +static inline const struct pci_device_id * +pci_match_one_device (const struct pci_device_id *id,const struct pci_dev *dev) +{ +if ((id->vendor ==PCI_ANY_ID || id->vendor == dev->vendor) && + (id->device ==PCI_ANY_ID || id->device == dev->device) && + (id->subvendor ==PCI_ANY_ID || id->subvendor == dev->subsystem_vendor) && + (id->subdevice ==PCI_ANY_ID || id->subdevice == dev->subsystem_device) && + !((id->class ^ dev->class) & id->class_mask)) +return id; +return NULL ; +} + +static int pci_match (struct device_d *dev,struct driver_d *drv) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct pci_driver *pdrv =to_pci_driver (drv); +struct pci_device_id *id; + +for (id = (struct pci_device_id *)pdrv->id_table; id->vendor; id++) +if (pci_match_one_device (id, pdev)) { + dev->priv = id; +return 0 ; + } + +return -1 ; +} + +static int pci_probe (struct device_d *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct pci_driver *pdrv =to_pci_driver (dev->driver); + +return pdrv->probe (pdev, dev->priv); +} + +static void pci_remove (struct device_d *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct pci_driver *pdrv =to_pci_driver (dev->driver); + + pdrv->remove (pdev); +} + +struct bus_type pci_bus = { + .name ="pci" , + .match = pci_match, + .probe = pci_probe, + .remove = pci_remove, +}; + +static int pci_bus_init (void ) +{ +return bus_register (&pci_bus); +} +pure_initcall (pci_bus_init); + +int pci_register_driver (struct pci_driver *pdrv) +{ +struct driver_d *drv = &pdrv->driver; + +if (!pdrv->id_table) +return -EIO ; + + drv->name = pdrv->name; + drv->bus = &pci_bus; + +return register_driver (drv); +} + +int pci_register_device (struct pci_dev *pdev) +{ +char str[6 ]; +struct device_d *dev = &pdev->dev; +int ret; + +strcpy (dev->name,"pci" ); + dev->bus = &pci_bus; + dev->id =DEVICE_ID_DYNAMIC ; + + ret =register_device (dev); + +if (ret) +return ret; + +sprintf (str,"%02x" , pdev->devfn); +dev_add_param_fixed (dev,"devfn" , str); +sprintf (str,"%04x" , (pdev->class >>8 ) &0xffff ); +dev_add_param_fixed (dev,"class" , str); +sprintf (str,"%04x" , pdev->vendor); +dev_add_param_fixed (dev,"vendor" , str); +sprintf (str,"%04x" , pdev->device); +dev_add_param_fixed (dev,"device" , str); +sprintf (str,"%04x" , pdev->revision); +dev_add_param_fixed (dev,"revision" , str); + +return 0 ; +}drivers/pci/pci.c new file +0
-0same here
Quoted 10 lines
drivers/pci/pci.c line 8
Quoted 9 lines
drivers/pci/pci.c new file +8
-0@@ -0,0 +1,292 @@ +#include <common.h> +#include <linux/pci.h> + +#ifdef DEBUG +#define DBG(x...) printk(x) +#else +#define DBG(x...) +#endif we need to use
pr_debugor betterdev_dbg
but currently there is no device instance to pass to dev_* family calls.
so pr_* is better.
Quoted 6 lines
Quoted 6 lines
drivers/pci/pci.c new file +6
-0+ +static struct pci_controller *hose_head, **hose_tail = &hose_head; + +LIST_HEAD (pci_root_buses); +EXPORT_SYMBOL (pci_root_buses); +
Quoted 8 lines
drivers/pci/pci.c line 19
Quoted 5 lines
drivers/pci/pci.c new file +5
-0+static struct pci_bus *pci_alloc_bus (void ) +{ +struct pci_bus *b; + + b =kzalloc (sizeof (*b),GFP_KERNEL );if (!b) return b;
kzalloc() eventually calls xmalloc().xmalloc() calls panic() if malloc fails, so there is no need to check b at all.
Quoted 92 lines
so no {}
Quoted 89 lines
drivers/pci/pci.c new file +89
-0+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); + +list_add_tail (&bus->node, &pci_root_buses); + +return ; +} + +/* +* Wrappers for all PCI configuration access functions. They just check +* alignment, do locking and call the low-level functions pointed to +* by pci_dev->ops. +*/ + +#define PCI_byte_BAD 0 +#define PCI_word_BAD (pos & 1) +#define PCI_dword_BAD (pos & 3) + +#define PCI_OP_READ (size,type,len) \ +int pci_bus_read_config_##size \ + (struct pci_bus *bus, unsigned int devfn, int pos, type *value) \ +{ \ + int res; \ + u32 data = 0; \ + if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ + res = bus->ops->read(bus, devfn, pos, len, &data); \ + *value = (type)data; \ + return res; \ +} + +#define PCI_OP_WRITE (size,type,len) \ +int pci_bus_write_config_##size \ + (struct pci_bus *bus, unsigned int devfn, int pos, type value) \ +{ \ + int res; \ + if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ + res = bus->ops->write(bus, devfn, pos, len, value); \ + return res; \ +} + +PCI_OP_READ(byte, u8, 1) +PCI_OP_READ(word, u16, 2) +PCI_OP_READ(dword, u32, 4) +PCI_OP_WRITE(byte, u8, 1) +PCI_OP_WRITE(word, u16, 2) +PCI_OP_WRITE(dword, u32, 4) + +EXPORT_SYMBOL (pci_bus_read_config_byte); +EXPORT_SYMBOL (pci_bus_read_config_word); +EXPORT_SYMBOL (pci_bus_read_config_dword); +EXPORT_SYMBOL (pci_bus_write_config_byte); +EXPORT_SYMBOL (pci_bus_write_config_word); +EXPORT_SYMBOL (pci_bus_write_config_dword); + +static struct pci_dev *alloc_pci_dev (void ) +{ +struct pci_dev *dev; + + dev =kzalloc (sizeof (struct pci_dev ),GFP_KERNEL ); +if (!dev) +return NULL ; + +INIT_LIST_HEAD (&dev->bus_list); + +return dev; +} +
Signature · 8 lines
-- Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v5 3/7] PCI: initial commit
Quoted 12 lines · Antony Pavlov
Quoted 8 lines · On Mon, 7 Jul 2014 20:22:10 +0200 Jean-Christophe PLAGNIOL-VILLARD…
drivers/pci/pci.c line 19
Quoted 5 lines
drivers/pci/pci.c new file +5
-0+static struct pci_bus *pci_alloc_bus (void ) +{ +struct pci_bus *b; + + b =kzalloc (sizeof (*b),GFP_KERNEL );if (!b) return b;
Quoted 2 lines
kzalloc()eventually callsxmalloc().xmalloc()callspanic()if malloc fails, so there is no need to check b at all.
Then let's use xzalloc directly here. I think only the x functions should panic on failure. kzalloc should be implemented with malloc or calloc.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v5 3/7] PCI: initial commit
Quoted 13 lines · On Tue, 8 Jul 2014 08:29:34 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 12 lines · Antony Pavlov
Quoted 8 lines · On Mon, 7 Jul 2014 20:22:10 +0200 Jean-Christophe PLAGNIOL-VILLARD…
drivers/pci/pci.c line 19
Quoted 5 lines
drivers/pci/pci.c new file +5
-0+static struct pci_bus *pci_alloc_bus (void ) +{ +struct pci_bus *b; + + b =kzalloc (sizeof (*b),GFP_KERNEL );if (!b) return b;
Quoted 6 lines
Quoted 2 lines
kzalloc()eventually callsxmalloc().xmalloc()callspanic()if malloc fails, so there is no need to check b at all.Then let's use xzalloc directly here. I think only the x functions should panic on failure. kzalloc should be implemented with malloc or calloc.
The PCI series consist much code from original August 2011 patchseries (e.g. see http://lists.infradead.org/pipermail/barebox/2011-August/004349.html).
Some things have changed since 2011.
I'll prepare fix patches.
Can we ammend them into the PCI patch series (already in the 'next' but not in the 'master'?)
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v5 3/7] PCI: initial commit
In reply to Jean-Christophe PLAGNIOL-VILLARDQuoted 96 lines · On Mon, 7 Jul 2014 20:22:10 +0200 Jean-Christophe PLAGNIOL-VILLARD…
drivers/pci/bus.c
Quoted 93 lines · Antony Pavlov
used shorten version of linux-2.6.39
pci_ids.hSigned-off-by Antony Pavlov <[email protected]>Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- drivers/Kconfig | 1 + drivers/Makefile | 1 + drivers/pci/Kconfig | 29 ++++ drivers/pci/Makefile | 8 ++ drivers/pci/bus.c | 110 +++++++++++++++ drivers/pci/pci.c | 292 +++++++++++++++++++++++++++++++++++++++ drivers/pci/pci_iomap.c | 29 ++++ include/linux/mod_devicetable.h | 20 +++ include/linux/pci.h | 297 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci_ids.h | 136 ++++++++++++++++++ include/linux/pci_regs.h | 110 +++++++++++++++ 11 files changed, 1033 insertions(+)drivers/Kconfig +1
-0@@ -27,5 +27,6 @@ source "drivers/pinctrl/Kconfig" source "drivers/bus/Kconfig" source "drivers/regulator/Kconfig" source "drivers/reset/Kconfig" +source "drivers/pci/Kconfig" endmenudrivers/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/drivers/pci/Kconfig new file +29
-0@@ -0,0 +1,29 @@ +config HW_HAS_PCI + bool + +if HW_HAS_PCI + +menu "PCI bus options" + +config PCI + bool "Support for PCI controller" + depends on HW_HAS_PCI + 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_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. + +endmenu + +endifdrivers/pci/Makefile new file +8
-0@@ -0,0 +1,8 @@ +# +# Makefile for the PCI bus specific drivers. +# +obj-y += pci.o bus.o pci_iomap.o + +ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG + +CPPFLAGS += $(ccflags-y)drivers/pci/bus.c new file +0
-0missing copyright and licence
Quoted 1 line
I do not remember who wrote it you, me or both
Should I use GPLv2-only or GPLv2-or-later license?
Quoted 234 lines
drivers/pci/pci.c
Quoted 116 lines
drivers/pci/bus.c new file +110
-0@@ -0,0 +1,110 @@ +#include <common.h> +#include <init.h> +#include <driver.h> +#include <linux/pci.h> + +/** +* pci_match_one_device - Tell if a PCI device structure has a matching +* PCI device id structure +* @id: single PCI device id structure to match +* @dev: the PCI device structure to match against +* +* Returns the matching pci_device_id structure or %NULL if there is no match. +*/ +static inline const struct pci_device_id * +pci_match_one_device (const struct pci_device_id *id,const struct pci_dev *dev) +{ +if ((id->vendor ==PCI_ANY_ID || id->vendor == dev->vendor) && + (id->device ==PCI_ANY_ID || id->device == dev->device) && + (id->subvendor ==PCI_ANY_ID || id->subvendor == dev->subsystem_vendor) && + (id->subdevice ==PCI_ANY_ID || id->subdevice == dev->subsystem_device) && + !((id->class ^ dev->class) & id->class_mask)) +return id; +return NULL ; +} + +static int pci_match (struct device_d *dev,struct driver_d *drv) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct pci_driver *pdrv =to_pci_driver (drv); +struct pci_device_id *id; + +for (id = (struct pci_device_id *)pdrv->id_table; id->vendor; id++) +if (pci_match_one_device (id, pdev)) { + dev->priv = id; +return 0 ; + } + +return -1 ; +} + +static int pci_probe (struct device_d *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct pci_driver *pdrv =to_pci_driver (dev->driver); + +return pdrv->probe (pdev, dev->priv); +} + +static void pci_remove (struct device_d *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct pci_driver *pdrv =to_pci_driver (dev->driver); + + pdrv->remove (pdev); +} + +struct bus_type pci_bus = { + .name ="pci" , + .match = pci_match, + .probe = pci_probe, + .remove = pci_remove, +}; + +static int pci_bus_init (void ) +{ +return bus_register (&pci_bus); +} +pure_initcall (pci_bus_init); + +int pci_register_driver (struct pci_driver *pdrv) +{ +struct driver_d *drv = &pdrv->driver; + +if (!pdrv->id_table) +return -EIO ; + + drv->name = pdrv->name; + drv->bus = &pci_bus; + +return register_driver (drv); +} + +int pci_register_device (struct pci_dev *pdev) +{ +char str[6 ]; +struct device_d *dev = &pdev->dev; +int ret; + +strcpy (dev->name,"pci" ); + dev->bus = &pci_bus; + dev->id =DEVICE_ID_DYNAMIC ; + + ret =register_device (dev); + +if (ret) +return ret; + +sprintf (str,"%02x" , pdev->devfn); +dev_add_param_fixed (dev,"devfn" , str); +sprintf (str,"%04x" , (pdev->class >>8 ) &0xffff ); +dev_add_param_fixed (dev,"class" , str); +sprintf (str,"%04x" , pdev->vendor); +dev_add_param_fixed (dev,"vendor" , str); +sprintf (str,"%04x" , pdev->device); +dev_add_param_fixed (dev,"device" , str); +sprintf (str,"%04x" , pdev->revision); +dev_add_param_fixed (dev,"revision" , str); + +return 0 ; +}drivers/pci/pci.c new file +0
-0same here
drivers/pci/pci.c line 8
Quoted 9 lines
drivers/pci/pci.c new file +8
-0@@ -0,0 +1,292 @@ +#include <common.h> +#include <linux/pci.h> + +#ifdef DEBUG +#define DBG(x...) printk(x) +#else +#define DBG(x...) +#endif we need to use
pr_debugor betterdev_dbgdrivers/pci/pci.c line 19
Quoted 11 lines
drivers/pci/pci.c new file +11
-0+ +static struct pci_controller *hose_head, **hose_tail = &hose_head; + +LIST_HEAD (pci_root_buses); +EXPORT_SYMBOL (pci_root_buses); + +static struct pci_bus *pci_alloc_bus (void ) +{ +struct pci_bus *b; + + b =kzalloc (sizeof (*b),GFP_KERNEL );if (!b) return b;so no {}
Quoted 89 lines
drivers/pci/pci.c new file +89
-0+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); + +list_add_tail (&bus->node, &pci_root_buses); + +return ; +} + +/* +* Wrappers for all PCI configuration access functions. They just check +* alignment, do locking and call the low-level functions pointed to +* by pci_dev->ops. +*/ + +#define PCI_byte_BAD 0 +#define PCI_word_BAD (pos & 1) +#define PCI_dword_BAD (pos & 3) + +#define PCI_OP_READ (size,type,len) \ +int pci_bus_read_config_##size \ + (struct pci_bus *bus, unsigned int devfn, int pos, type *value) \ +{ \ + int res; \ + u32 data = 0; \ + if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ + res = bus->ops->read(bus, devfn, pos, len, &data); \ + *value = (type)data; \ + return res; \ +} + +#define PCI_OP_WRITE (size,type,len) \ +int pci_bus_write_config_##size \ + (struct pci_bus *bus, unsigned int devfn, int pos, type value) \ +{ \ + int res; \ + if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ + res = bus->ops->write(bus, devfn, pos, len, value); \ + return res; \ +} + +PCI_OP_READ(byte, u8, 1) +PCI_OP_READ(word, u16, 2) +PCI_OP_READ(dword, u32, 4) +PCI_OP_WRITE(byte, u8, 1) +PCI_OP_WRITE(word, u16, 2) +PCI_OP_WRITE(dword, u32, 4) + +EXPORT_SYMBOL (pci_bus_read_config_byte); +EXPORT_SYMBOL (pci_bus_read_config_word); +EXPORT_SYMBOL (pci_bus_read_config_dword); +EXPORT_SYMBOL (pci_bus_write_config_byte); +EXPORT_SYMBOL (pci_bus_write_config_word); +EXPORT_SYMBOL (pci_bus_write_config_dword); + +static struct pci_dev *alloc_pci_dev (void ) +{ +struct pci_dev *dev; + + dev =kzalloc (sizeof (struct pci_dev ),GFP_KERNEL ); +if (!dev) +return NULL ; + +INIT_LIST_HEAD (&dev->bus_list); + +return dev; +} +
Signature · 8 lines
-- Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v5 3/7] PCI: initial commit
In reply to Antony PavlovQuoted 23 lines · Antony Pavlov
Quoted 13 lines · On Tue, 8 Jul 2014 08:29:34 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 12 lines · Antony Pavlov
Quoted 8 lines · On Mon, 7 Jul 2014 20:22:10 +0200 Jean-Christophe PLAGNIOL-VILLARD…
drivers/pci/pci.c line 19
Quoted 5 lines
drivers/pci/pci.c new file +5
-0+static struct pci_bus *pci_alloc_bus (void ) +{ +struct pci_bus *b; + + b =kzalloc (sizeof (*b),GFP_KERNEL );if (!b) return b;Quoted 6 lines
Quoted 2 lines
kzalloc()eventually callsxmalloc().xmalloc()callspanic()if malloc fails, so there is no need to check b at all.Then let's use xzalloc directly here. I think only the x functions should panic on failure. kzalloc should be implemented with malloc or calloc.
Quoted 7 lines
The PCI series consist much code from original August 2011 patchseries (e.g. see http://lists.infradead.org/pipermail/barebox/2011-August/004349.html).
Some things have changed since 2011.
I'll prepare fix patches.
Can we ammend them into the PCI patch series (already in the 'next' but not in the 'master'?)
The PCI support is in master, no chance to fixup.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v5 3/7] PCI: initial commit
In reply to Antony PavlovQuoted 100 lines · Antony Pavlov
Quoted 96 lines · On Mon, 7 Jul 2014 20:22:10 +0200 Jean-Christophe PLAGNIOL-VILLARD…
drivers/pci/bus.c
Quoted 93 lines · Antony Pavlov
used shorten version of linux-2.6.39
pci_ids.hSigned-off-by Antony Pavlov <[email protected]>Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>---
drivers/Kconfig | 1 + drivers/Makefile | 1 + drivers/pci/Kconfig | 29 ++++ drivers/pci/Makefile | 8 ++ drivers/pci/bus.c | 110 +++++++++++++++ drivers/pci/pci.c | 292 +++++++++++++++++++++++++++++++++++++++ drivers/pci/pci_iomap.c | 29 ++++ include/linux/mod_devicetable.h | 20 +++ include/linux/pci.h | 297 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci_ids.h | 136 ++++++++++++++++++ include/linux/pci_regs.h | 110 +++++++++++++++ 11 files changed, 1033 insertions(+)drivers/Kconfig +0
-0@@ -27,5 +27,6 @@ source "drivers/pinctrl/Kconfig"source "
drivers/bus/Kconfig"
source "drivers/regulator/Kconfig"
source "drivers/reset/Kconfig"
+source "drivers/pci/Kconfig"endmenu
drivers/Makefile +0
-0@@ -26,3 +26,4 @@ obj-y += pinctrl/obj-y += bus/
obj-$(CONFIG_REGULATOR) += regulator/
obj-$(CONFIG_RESET_CONTROLLER) += reset/drivers/Makefile +1
-0+obj-$(CONFIG_PCI) += pci/drivers/pci/Kconfig new file +29
-0@@ -0,0 +1,29 @@ +config HW_HAS_PCI + bool + +if HW_HAS_PCI + +menu "PCI bus options" + +config PCI + bool "Support for PCI controller" + depends on HW_HAS_PCI + 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_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. + +endmenu + +endifdrivers/pci/Makefile new file +8
-0@@ -0,0 +1,8 @@ +# +# Makefile for the PCI bus specific drivers. +# +obj-y += pci.o bus.o pci_iomap.o + +ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG + +CPPFLAGS += $(ccflags-y)drivers/pci/bus.c new file +0
-0missing copyright and licence
Quoted 4 lines
Quoted 1 line
I do not remember who wrote it you, me or both
Should I use GPLv2-only or GPLv2-or-later license?
I only wrote GPLv2-only
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox