Hi, On 5 March 2015 at 12:25, Simon Glass <s...@chromium.org> wrote: > > This series is a collection of changes in core DM, sandbox, x86 and PCI code > to implement a PCI uclass and associated operations. Some basic tests are > provided as well. > > As is becoming common with DM conversions, the existing structure (here > struct pci_controller) becomes per-bus uclass data. This allows the concept > of a 'hose' (generally a PCI host controller and a bus) to continue to exist > in the interim, even if it should not be needed in the end. This makes it > much easier to convert over existing code. > > PCI buses are not scanned in the bind() method but only later when probe() > is called. This will be automatic if you access a bus, but it does mean that > if PCI is not used it will not be touched, in keeping with U-Boot's lazy- > init philosophy. > > The existing 'pciauto' bus configuration code is still used, although it now > uses DM underneath. It works exclusively by reading and writing PCI config > and does not refer to DM data structures. The one change is to drop use of > the hose->current_busno field which is no longer required. The fact that > file works largely as before is an indication that a good level of > compatibility is achieved between DM and legacy PCI. > > In order to support testing of PCI I/O and memory space, support has been > added to sandbox to allow mapping of these. This allows commands like 'md' > and 'iod' to display data from mapped PCI devices. Similarly, it is possible > to make changes to this space. This support relies on the existing > map_sysmem() and unmap_sysmem() calls which are now fairly widespread in > U-Boot. > > Apart from the driver model tests (run with ./test/dm/test-dm.sh) you can > try out these commands which use the new 'swap_case' test device: > > ../u-boot -d b/sandbox/u-boot.dtb > .... > => iow.b 20000000 2 > => iod.b 20000000 > 0000: 02 > => mw.l 10000000 64436241 > => md.l 10000000 1 > 10000000: 44634261 aBcD > => > > This shows an I/O access to 20000000, setting the value 2 which means to > swap the case. Then 'AbCd' is written to the memory space at 10000000 and > 'aBcD' is read back. > > The 'pci' command can be used as before. > > Most existing PCI functions (in pci.h) still work, but route through driver > model. The file drivers/pci/pci.c is replaced when driver model is enabled > so not everything is present. A new pci_common.c file holds functions common > to driver model and the old system, and pci_compat.c contains functions I > would like to eventually deprecate. > > Two x86 boards (coreboot and chromebook_link) are converted over to use > driver model for PCI. > > Core driver model changes include: > - Addition of a new pre_probe() method for the uclass to set up devices just > before the device's probe() method is called > - A change in the ordering of when a device is marked as probed > - A dev_get_uclass_priv() accessor > - A tweak to the 'dm uclass' command to improve sequence number display > > Notably missing from this series are functions to access PCI devices using > a 'struct udevice *'. Where there is no device tree entry for a bus device, > a generic PCI device is created in driver model to mirror the device, as > with I2C and SPI. Future work could add more real devices to x86 and create > a demand for these sorts of functions. Also we might store things like the > PCI base address registers (BARs) in data structures if there is a need. > These things are probably best developed as a need arises to avoid creating > infrastructure and overhead that may not be used. > > This series is available at u-boot-dm.git branch pci-working. > > Changes in v2: > - Update root node #size=cells to 1 in this patch > - Add a new patch with a CPU init function which can use driver model > - Use the new arch_cpu_init_dm() function instead of something x86-specific > - Add -ve sign before ENXIO
I'm going to go ahead and apply this to u-boot-dm/next along with the x86 panther series (which it depends on). > > Simon Glass (22): > sandbox: Update device tree 'reg' properties for I2C and SPI > fdt: Export fdtdec_get_number() for general use > x86: Add a x86_ prefix to the x86-specific PCI functions > dm: Add a new CPU init function which can use driver model > x86: Split up arch_cpu_init() > Correct map_sysmem() logic in do_mem_mw() > fdt: Tighten up error handling in fdtdec_get_pci_addr() > dm: core: Add dev_get_uclass_priv() to access uclass private data > dm: core: Mark device as active before calling its probe() method > dm: core: Add a uclass pre_probe() method for devices > dm: Show both allocated and requested seq numbers in 'dm uclass' > dm: pci: Move common PCI functions into their own file > dm: pci: Add a uclass for PCI > dm: sandbox: pci: Add PCI support for sandbox > dm: sandbox: Add a simple PCI driver > dm: sandbox: pci: Add a PCI emulation uclass > dm: sandbox: Add a emulated PCI device as an example > dm: sandbox: pci: Enable PCI for sandbox > dm: x86: pci: Add a PCI driver for driver model > dm: x86: pci: Convert coreboot to use driver model for pci > dm: x86: pci: Convert chromebook_link to use driver model for pci > dm: pci: Add driver model tests for PCI > > arch/sandbox/Kconfig | 7 + > arch/sandbox/cpu/cpu.c | 37 +- > arch/sandbox/dts/sandbox.dts | 26 +- > arch/sandbox/include/asm/io.h | 16 +- > arch/sandbox/include/asm/processor.h | 12 + > arch/sandbox/include/asm/test.h | 7 +- > arch/sandbox/include/asm/u-boot-sandbox.h | 48 ++ > arch/sandbox/lib/Makefile | 2 +- > arch/sandbox/lib/pci_io.c | 138 ++++++ > arch/x86/cpu/baytrail/early_uart.c | 5 +- > arch/x86/cpu/coreboot/pci.c | 63 +-- > arch/x86/cpu/ivybridge/bd82x6x.c | 56 ++- > arch/x86/cpu/ivybridge/cpu.c | 62 +-- > arch/x86/cpu/ivybridge/early_init.c | 58 +-- > arch/x86/cpu/ivybridge/early_me.c | 12 +- > arch/x86/cpu/ivybridge/gma.c | 4 +- > arch/x86/cpu/ivybridge/lpc.c | 75 +-- > arch/x86/cpu/ivybridge/northbridge.c | 6 +- > arch/x86/cpu/ivybridge/pch.c | 4 +- > arch/x86/cpu/ivybridge/pci.c | 85 ++-- > arch/x86/cpu/ivybridge/report_platform.c | 4 +- > arch/x86/cpu/ivybridge/sata.c | 61 +-- > arch/x86/cpu/ivybridge/sdram.c | 20 +- > arch/x86/cpu/ivybridge/usb_ehci.c | 4 +- > arch/x86/cpu/ivybridge/usb_xhci.c | 8 +- > arch/x86/cpu/pci.c | 52 ++- > arch/x86/cpu/quark/quark.c | 4 +- > arch/x86/cpu/queensbay/tnc.c | 4 +- > arch/x86/dts/chromebook_link.dts | 10 +- > arch/x86/include/asm/arch-ivybridge/bd82x6x.h | 1 - > arch/x86/include/asm/pci.h | 20 +- > arch/x86/lib/Makefile | 2 + > arch/x86/lib/bios_interrupts.c | 12 +- > board/google/chromebook_link/link.c | 9 + > common/board_f.c | 6 + > common/board_r.c | 2 + > common/cmd_mem.c | 7 +- > common/cmd_pci.c | 14 +- > common/cmd_sf.c | 2 +- > common/cros_ec.c | 2 +- > configs/chromebook_link_defconfig | 1 + > configs/chromebox_panther_defconfig | 1 + > configs/coreboot-x86_defconfig | 1 + > configs/sandbox_defconfig | 3 + > doc/driver-model/pci-info.txt | 70 +++ > drivers/core/device.c | 19 +- > drivers/core/uclass.c | 10 +- > drivers/gpio/at91_gpio.c | 2 +- > drivers/gpio/bcm2835_gpio.c | 2 +- > drivers/gpio/gpio-uclass.c | 22 +- > drivers/gpio/intel_ich6_gpio.c | 18 +- > drivers/gpio/mxc_gpio.c | 2 +- > drivers/gpio/omap_gpio.c | 2 +- > drivers/gpio/s5p_gpio.c | 2 +- > drivers/gpio/sandbox.c | 6 +- > drivers/gpio/sunxi_gpio.c | 2 +- > drivers/gpio/tegra_gpio.c | 2 +- > drivers/i2c/i2c-uclass.c | 6 +- > drivers/i2c/sandbox_i2c.c | 2 +- > drivers/misc/Makefile | 1 + > drivers/misc/cros_ec.c | 6 +- > drivers/misc/cros_ec_i2c.c | 2 +- > drivers/misc/cros_ec_sandbox.c | 2 +- > drivers/misc/cros_ec_spi.c | 4 +- > drivers/misc/swap_case.c | 285 ++++++++++++ > drivers/mtd/spi/sf-uclass.c | 2 +- > drivers/mtd/spi/sf_probe.c | 8 +- > drivers/pci/Kconfig | 22 + > drivers/pci/Makefile | 11 +- > drivers/pci/pci-emul-uclass.c | 67 +++ > drivers/pci/pci-uclass.c | 639 > ++++++++++++++++++++++++++ > drivers/pci/pci.c | 281 +---------- > drivers/pci/pci_auto.c | 16 +- > drivers/pci/pci_common.c | 292 ++++++++++++ > drivers/pci/pci_compat.c | 43 ++ > drivers/pci/pci_sandbox.c | 79 ++++ > drivers/pci/pci_x86.c | 24 + > drivers/serial/serial-uclass.c | 4 +- > drivers/spi/spi-uclass.c | 4 +- > include/common.h | 11 + > include/configs/sandbox.h | 4 + > include/dm/device.h | 10 + > include/dm/test.h | 1 + > include/dm/uclass-id.h | 4 + > include/dm/uclass-internal.h | 7 +- > include/dm/uclass.h | 2 + > include/fdtdec.h | 15 +- > include/i2c.h | 8 +- > include/pci.h | 411 ++++++++++++++++- > lib/fdtdec.c | 8 +- > test/dm/Makefile | 1 + > test/dm/cmd_dm.c | 4 +- > test/dm/core.c | 9 +- > test/dm/pci.c | 59 +++ > test/dm/test-uclass.c | 16 +- > test/dm/test.dts | 17 + > 96 files changed, 2842 insertions(+), 677 deletions(-) > create mode 100644 arch/sandbox/include/asm/processor.h > create mode 100644 arch/sandbox/lib/pci_io.c > create mode 100644 doc/driver-model/pci-info.txt > create mode 100644 drivers/misc/swap_case.c > create mode 100644 drivers/pci/pci-emul-uclass.c > create mode 100644 drivers/pci/pci-uclass.c > create mode 100644 drivers/pci/pci_common.c > create mode 100644 drivers/pci/pci_compat.c > create mode 100644 drivers/pci/pci_sandbox.c > create mode 100644 drivers/pci/pci_x86.c > create mode 100644 test/dm/pci.c > > -- > 2.2.0.rc0.207.ga3a616c > Regards, Simon _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot