Add driver model support for PCI
Subsystems (15)
cover Add driver model support for PCI
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.
Simon Glass (22):
dm: i2c: Add a missing memory allocaton check
sandbox: Correct 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
RFC: 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/include/asm/u-boot-x86.h | 1 + arch/x86/lib/Makefile | 2 + arch/x86/lib/bios_interrupts.c | 12 +- board/google/chromebook_link/link.c | 15 + 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 | 8 +- 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/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 + 95 files changed, 2834 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
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 1/22 dm: i2c: Add a missing memory allocaton check
This strdup() is missing a check. Add it.
---
drivers/i2c/i2c-uclass.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/i2c/i2c-uclass.c +2 -0
@@ -230,6 +230,8 @@ static int i2c_bind_driver(struct udevice *bus, uint chip_addr, uint offset_len,snprintf (name,sizeof (name),"generic_%x" , chip_addr); str =strdup (name); +if (!str) +return -ENOMEM ; ret =device_bind_driver (bus,"i2c_generic_chip_drv" , str, &dev);debug ("%s: device_bind_driver: ret=%d\n" , __func__, ret);if (ret)
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 1/22 dm: i2c: Add a missing memory allocaton check
Hello Simon,
Am 18.02.2015 22:10, schrieb Simon Glass:
Quoted 7 lines
This
strdup()is missing a check. Add it.Signed-off-by Simon Glass <[email protected]>---
drivers/i2c/i2c-uclass.c | 2 ++ 1 file changed, 2 insertions(+)
Good catch, Thanks!
bye,
Heiko
Quoted 15 lines
drivers/i2c/i2c-uclass.c +2
-0@@ -230,6 +230,8 @@ static int i2c_bind_driver(struct udevice *bus, uint chip_addr, uint offset_len,snprintf (name,sizeof (name),"generic_%x" , chip_addr); str =strdup (name); +if (!str) +return -ENOMEM ; ret =device_bind_driver (bus,"i2c_generic_chip_drv" , str, &dev);debug ("%s: device_bind_driver: ret=%d\n" , __func__, ret);if (ret)
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH 1/22 dm: i2c: Add a missing memory allocaton check
Quoted 9 lines · Heiko Schocher
Hello Simon,
Am 18.02.2015 22:10, schrieb Simon Glass:
Quoted 6 lines
This
strdup()is missing a check. Add it.Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 2 lines
drivers/i2c/i2c-uclass.c | 2 ++ 1 file changed, 2 insertions(+)Good catch, Thanks!
Acked-by Heiko Schocher <[email protected]>
Applied to u-boot-dm.
PATCH 2/22 sandbox: Correct device tree 'reg' properties for I2C and SPI
In reply to Simon GlassThese are missing a size value. Add one in each case.
---
arch/sandbox/dts/sandbox.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/sandbox/dts/sandbox.dts +2 -2
@@ -144,7 +144,7 @@ i2c at 0 { #address-cells = <1>; #size-cells = <0>; - reg = <0>; + reg = <0 0>; compatible = "sandbox,i2c"; clock-frequency = <400000>; eeprom at 2c {
@@ -161,7 +161,7 @@ spi at 0 { #address-cells = <1>; #size-cells = <0>; - reg = <0>; + reg = <0 0>; compatible = "sandbox,spi"; cs-gpios = <0>, <&gpio_a 0>; flash at 0 {
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 2/22 sandbox: Correct device tree 'reg' properties for I2C and SPI
Hi Simon,
Quoted 13 lines · Simon Glass
These are missing a size value. Add one in each case.
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/dts/sandbox.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/sandbox/dts/sandbox.dts +0
-0
arch/sandbox/dts/sandbox.dts line 147
Quoted 5 lines
arch/sandbox/dts/sandbox.dts +1
-1@@ -144,7 +144,7 @@ i2c at 0 { #address-cells = <1>; #size-cells = <0>; - reg = <0>; + reg = <0 0>;
Why? Its parent node's #size-cells is 0.
arch/sandbox/dts/sandbox.dts
Quoted 13 lines
arch/sandbox/dts/sandbox.dts +1
-2compatible = "sandbox,i2c"; clock-frequency = <400000>; eeprom at 2c {@@ -161,7 +161,7 @@ spi at 0 { #address-cells = <1>; #size-cells = <0>; - reg = <0>; + reg = <0 0>; compatible = "sandbox,spi"; cs-gpios = <0>, <&gpio_a 0>; flash at 0 { --
Regards,
Bin
PATCH 2/22 sandbox: Correct device tree 'reg' properties for I2C and SPI
Hi Bin,
Quoted 24 lines · Bin Meng
Hi Simon,
Quoted 13 lines · Simon Glass
These are missing a size value. Add one in each case.
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/dts/sandbox.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/sandbox/dts/sandbox.dts +0
-0arch/sandbox/dts/sandbox.dts line 147
Quoted 5 lines
arch/sandbox/dts/sandbox.dts +1
-1@@ -144,7 +144,7 @@ i2c at 0 { #address-cells = <1>; #size-cells = <0>; - reg = <0>; + reg = <0 0>;Why? Its parent node's #size-cells is 0.
Quoted 13 lines
arch/sandbox/dts/sandbox.dts
Quoted 13 lines
arch/sandbox/dts/sandbox.dts +1
-2compatible = "sandbox,i2c"; clock-frequency = <400000>; eeprom at 2c {@@ -161,7 +161,7 @@ spi at 0 { #address-cells = <1>; #size-cells = <0>; - reg = <0>; + reg = <0 0>; compatible = "sandbox,spi"; cs-gpios = <0>, <&gpio_a 0>; flash at 0 { --
It is needed by a later patch which changes the size to 1. I will merge that change in here.
Regards,
Simon
PATCH 3/22 fdt: Export fdtdec_get_number() for general use
In reply to Simon GlassThis function is missing a prototype but is more widey useful. Add it.
---
include/fdtdec.h | 11 +++++++++++ lib/fdtdec.c | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-)
include/fdtdec.h +11 -0
@@ -385,6 +385,17 @@ s32 fdtdec_get_int(const void *blob, int node, const char *prop_name, s32 default_val);/** +* Get a variable-sized number from a property +* +* This reads a number from one or more cells. +* +* @param ptr Pointer to property +* @param cells Number of cells containing the number +* @return the value in the cells +*/ +u64 fdtdec_get_number (const fdt32_t *ptr,unsigned int cells); + +/** * Look up a 64-bit integer property in a node and return it. The property * must have at least 8 bytes of data (2 cells). The first two cells are * concatenated to form a 8 bytes value, where the first cell is top half and
lib/fdtdec.c +1 -1
@@ -917,7 +917,7 @@ int fdtdec_read_fmap_entry(const void *blob, int node, const char *name,return 0 ; } -static u64 fdtdec_get_number (const fdt32_t *ptr,unsigned int cells) +u64 fdtdec_get_number (const fdt32_t *ptr,unsigned int cells) {u64 number =0 ;
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 4/22 x86: Add a x86_ prefix to the x86-specific PCI functions
In reply to Simon GlassThese functions currently use a generic name, but they are for x86 only. This may introduce confusion and prevents U-Boot from using these names more widely.
In fact it should be possible to remove these at some point and use generic functions, but for now, rename them.
---
arch/x86/cpu/baytrail/early_uart.c | 5 ++- arch/x86/cpu/ivybridge/bd82x6x.c | 32 +++++++------- arch/x86/cpu/ivybridge/cpu.c | 38 ++++++++-------- 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 | 74 ++++++++++++++++---------------- arch/x86/cpu/ivybridge/northbridge.c | 6 +-- arch/x86/cpu/ivybridge/pch.c | 4 +- arch/x86/cpu/ivybridge/pci.c | 4 +- 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 | 12 +++--- arch/x86/cpu/quark/quark.c | 4 +- arch/x86/cpu/queensbay/tnc.c | 4 +- arch/x86/include/asm/pci.h | 12 +++--- arch/x86/lib/bios_interrupts.c | 12 +++--- drivers/gpio/intel_ich6_gpio.c | 16 +++---- 21 files changed, 199 insertions(+), 195 deletions(-)
arch/x86/cpu/baytrail/early_uart.c +3 -2
@@ -50,7 +50,7 @@ static void score_select_func(int pad, int func)writel (reg, pconf0_addr); } -static void pci_write_config32 (int dev,unsigned int where,u32 value) +static void x86_pci_write_config32 (int dev,unsigned int where,u32 value) {unsigned long addr;
@@ -62,7 +62,8 @@ static void pci_write_config32(int dev, unsigned int where, u32 value)int setup_early_uart (void ) {/* Enable the legacy UART hardware. */ -pci_write_config32 (PCI_DEV_CONFIG (0 ,LPC_DEV ,LPC_FUNC ),UART_CONT ,1 ); +x86_pci_write_config32 (PCI_DEV_CONFIG (0 ,LPC_DEV ,LPC_FUNC ),UART_CONT , +1 );/* * Set up the pads to the UART function. This allows the signals to
arch/x86/cpu/ivybridge/bd82x6x.c +16 -16
@@ -22,36 +22,36 @@ void bd82x6x_pci_init(pci_dev_t dev)debug ("bd82x6x PCI init.\n" );/* Enable Bus Master */ - reg16 =pci_read_config16 (dev,PCI_COMMAND ); + reg16 =x86_pci_read_config16 (dev,PCI_COMMAND ); reg16 |=PCI_COMMAND_MASTER ; -pci_write_config16 (dev,PCI_COMMAND , reg16); +x86_pci_write_config16 (dev,PCI_COMMAND , reg16);/* This device has no interrupt */ -pci_write_config8 (dev,INTR ,0xff ); +x86_pci_write_config8 (dev,INTR ,0xff );/* disable parity error response and SERR */ - reg16 =pci_read_config16 (dev,BCTRL ); + reg16 =x86_pci_read_config16 (dev,BCTRL ); reg16 &= ~(1 <<0 ); reg16 &= ~(1 <<1 ); -pci_write_config16 (dev,BCTRL , reg16); +x86_pci_write_config16 (dev,BCTRL , reg16);/* Master Latency Count must be set to 0x04! */ - reg8 =pci_read_config8 (dev,SMLT ); + reg8 =x86_pci_read_config8 (dev,SMLT ); reg8 &=0x07 ; reg8 |= (0x04 <<3 ); -pci_write_config8 (dev,SMLT , reg8); +x86_pci_write_config8 (dev,SMLT , reg8);/* Will this improve throughput of bus masters? */ -pci_write_config8 (dev,PCI_MIN_GNT ,0x06 ); +x86_pci_write_config8 (dev,PCI_MIN_GNT ,0x06 );/* Clear errors in status registers */ - reg16 =pci_read_config16 (dev,PSTS ); + reg16 =x86_pci_read_config16 (dev,PSTS );/* reg16 |= 0xf900; */ -pci_write_config16 (dev,PSTS , reg16); +x86_pci_write_config16 (dev,PSTS , reg16); - reg16 =pci_read_config16 (dev,SECSTS ); + reg16 =x86_pci_read_config16 (dev,SECSTS );/* reg16 |= 0xf900; */ -pci_write_config16 (dev,SECSTS , reg16); +x86_pci_write_config16 (dev,SECSTS , reg16); }#define PCI_BRIDGE_UPDATE_COMMAND
@@ -59,7 +59,7 @@ void bd82x6x_pci_dev_enable_resources(pci_dev_t dev) {uint16_t command; - command =pci_read_config16 (dev,PCI_COMMAND ); + command =x86_pci_read_config16 (dev,PCI_COMMAND ); command |=PCI_COMMAND_IO ;#ifdef PCI_BRIDGE_UPDATE_COMMAND /*
@@ -67,7 +67,7 @@ void bd82x6x_pci_dev_enable_resources(pci_dev_t dev)* ROM and APICs to become invisible. */ debug ("%x cmd <- %02x\n" , dev, command); -pci_write_config16 (dev,PCI_COMMAND , command); +x86_pci_write_config16 (dev,PCI_COMMAND , command);#else printf ("%s cmd <- %02x (NOT WRITTEN!)\n" ,dev_path (dev), command);#endif
@@ -77,11 +77,11 @@ void bd82x6x_pci_bus_enable_resources(pci_dev_t dev) {uint16_t ctrl; - ctrl =pci_read_config16 (dev,PCI_BRIDGE_CONTROL ); + ctrl =x86_pci_read_config16 (dev,PCI_BRIDGE_CONTROL ); ctrl |=PCI_COMMAND_IO ; ctrl |=PCI_BRIDGE_CTL_VGA ;debug ("%x bridge ctrl <- %04x\n" , dev, ctrl); -pci_write_config16 (dev,PCI_BRIDGE_CONTROL , ctrl); +x86_pci_write_config16 (dev,PCI_BRIDGE_CONTROL , ctrl);bd82x6x_pci_dev_enable_resources (dev); }
arch/x86/cpu/ivybridge/cpu.c +19 -19
@@ -167,21 +167,21 @@ static int enable_smbus(void) dev =PCI_BDF (0x0 ,0x1f ,0x3 );/* Check to make sure we've got the right device. */ - value =pci_read_config16 (dev,0x0 ); + value =x86_pci_read_config16 (dev,0x0 );if (value !=0x8086 ) {printf ("SMBus controller not found\n" );return -ENOSYS ; }/* Set SMBus I/O base. */ -pci_write_config32 (dev,SMB_BASE , -SMBUS_IO_BASE |PCI_BASE_ADDRESS_SPACE_IO ); +x86_pci_write_config32 (dev,SMB_BASE , +SMBUS_IO_BASE |PCI_BASE_ADDRESS_SPACE_IO );/* Set SMBus enable. */ -pci_write_config8 (dev,HOSTC ,HST_EN ); +x86_pci_write_config8 (dev,HOSTC ,HST_EN );/* Set SMBus I/O space enable. */ -pci_write_config16 (dev,PCI_COMMAND ,PCI_COMMAND_IO ); +x86_pci_write_config16 (dev,PCI_COMMAND ,PCI_COMMAND_IO );/* Disable interrupt generation. */ outb (0 ,SMBUS_IO_BASE +SMBHSTCTL );
@@ -214,25 +214,25 @@ static void enable_usb_bar(void)u32 cmd;/* USB Controller 1 */ -pci_write_config32 (usb0,PCI_BASE_ADDRESS_0 , -PCH_EHCI0_TEMP_BAR0 ); - cmd =pci_read_config32 (usb0,PCI_COMMAND ); +x86_pci_write_config32 (usb0,PCI_BASE_ADDRESS_0 , +PCH_EHCI0_TEMP_BAR0 ); + cmd =x86_pci_read_config32 (usb0,PCI_COMMAND ); cmd |=PCI_COMMAND_MASTER |PCI_COMMAND_MEMORY ; -pci_write_config32 (usb0,PCI_COMMAND , cmd); +x86_pci_write_config32 (usb0,PCI_COMMAND , cmd);/* USB Controller 1 */ -pci_write_config32 (usb1,PCI_BASE_ADDRESS_0 , -PCH_EHCI1_TEMP_BAR0 ); - cmd =pci_read_config32 (usb1,PCI_COMMAND ); +x86_pci_write_config32 (usb1,PCI_BASE_ADDRESS_0 , +PCH_EHCI1_TEMP_BAR0 ); + cmd =x86_pci_read_config32 (usb1,PCI_COMMAND ); cmd |=PCI_COMMAND_MASTER |PCI_COMMAND_MEMORY ; -pci_write_config32 (usb1,PCI_COMMAND , cmd); +x86_pci_write_config32 (usb1,PCI_COMMAND , cmd);/* USB3 Controller */ -pci_write_config32 (usb3,PCI_BASE_ADDRESS_0 , -PCH_XHCI_TEMP_BAR0 ); - cmd =pci_read_config32 (usb3,PCI_COMMAND ); +x86_pci_write_config32 (usb3,PCI_BASE_ADDRESS_0 , +PCH_XHCI_TEMP_BAR0 ); + cmd =x86_pci_read_config32 (usb3,PCI_COMMAND ); cmd |=PCI_COMMAND_MASTER |PCI_COMMAND_MEMORY ; -pci_write_config32 (usb3,PCI_COMMAND , cmd); +x86_pci_write_config32 (usb3,PCI_COMMAND , cmd); }static int report_bist_failure (void )
@@ -320,8 +320,8 @@ int print_cpuinfo(void) gd->arch.pei_boot_mode = boot_mode;/* TODO: Move this to the board or driver */ -pci_write_config32 (PCH_LPC_DEV ,GPIO_BASE ,DEFAULT_GPIOBASE |1 ); -pci_write_config32 (PCH_LPC_DEV ,GPIO_CNTL ,0x10 ); +x86_pci_write_config32 (PCH_LPC_DEV ,GPIO_BASE ,DEFAULT_GPIOBASE |1 ); +x86_pci_write_config32 (PCH_LPC_DEV ,GPIO_CNTL ,0x10 );/* Print processor name */ name =cpu_get_name (processor_name);
arch/x86/cpu/ivybridge/early_init.c +30 -28
114 lines not on this page · raw message
arch/x86/cpu/ivybridge/early_me.c +6 -6
@@ -29,7 +29,7 @@ static inline void pci_read_dword_ptr(void *ptr, int offset) {u32 dword; - dword =pci_read_config32 (PCH_ME_DEV , offset); + dword =x86_pci_read_config32 (PCH_ME_DEV , offset);memcpy (ptr, &dword,sizeof (dword)); }
@@ -37,7 +37,7 @@ static inline void pci_write_dword_ptr(void *ptr, int offset) {u32 dword =0 ;memcpy (&dword, ptr,sizeof (dword)); -pci_write_config32 (PCH_ME_DEV , offset, dword); +x86_pci_write_config32 (PCH_ME_DEV , offset, dword); }void intel_early_me_status (void )
@@ -101,7 +101,7 @@ static inline void set_global_reset(int enable) {u32 etr3; - etr3 =pci_read_config32 (PCH_LPC_DEV ,ETR3 ); + etr3 =x86_pci_read_config32 (PCH_LPC_DEV ,ETR3 );/* Clear CF9 Without Resume Well Reset Enable */ etr3 &= ~ETR3_CWORWRE ;
@@ -112,7 +112,7 @@ static inline void set_global_reset(int enable)else etr3 &= ~ETR3_CF9GR ; -pci_write_config32 (PCH_LPC_DEV ,ETR3 , etr3); +x86_pci_write_config32 (PCH_LPC_DEV ,ETR3 , etr3); }int intel_early_me_init_done (u8 status)
@@ -127,8 +127,8 @@ int intel_early_me_init_done(u8 status) };/* MEBASE from MESEG_BASE[35:20] */ - mebase_l =pci_read_config32 (PCH_DEV ,PCI_CPU_MEBASE_L ); - mebase_h =pci_read_config32 (PCH_DEV ,PCI_CPU_MEBASE_H ); + mebase_l =x86_pci_read_config32 (PCH_DEV ,PCI_CPU_MEBASE_L ); + mebase_h =x86_pci_read_config32 (PCH_DEV ,PCI_CPU_MEBASE_H ); mebase_h &=0xf ; did.uma_base = (mebase_l >>20 ) | (mebase_h <<12 );
arch/x86/cpu/ivybridge/gma.c +2 -2
@@ -741,9 +741,9 @@ int gma_func0_init(pci_dev_t dev, struct pci_controller *hose,int ret;/* IGD needs to be Bus Master */ - reg32 =pci_read_config32 (dev,PCI_COMMAND ); + reg32 =x86_pci_read_config32 (dev,PCI_COMMAND ); reg32 |=PCI_COMMAND_MASTER |PCI_COMMAND_MEMORY |PCI_COMMAND_IO ; -pci_write_config32 (dev,PCI_COMMAND , reg32); +x86_pci_write_config32 (dev,PCI_COMMAND , reg32);/* Use write-combining for the graphics memory, 256MB */ base =pci_read_bar32 (hose, dev,2 );
arch/x86/cpu/ivybridge/lpc.c +37 -37
210 lines not on this page · raw message
arch/x86/cpu/ivybridge/northbridge.c +3 -3
@@ -30,7 +30,7 @@ int bridge_silicon_revision(void) result =cpuid (1 ); stepping = result.eax &0xf ; dev =PCI_BDF (0 ,0 ,0 ); - bridge_id =pci_read_config16 (dev,PCI_DEVICE_ID ) &0xf0 ; + bridge_id =x86_pci_read_config16 (dev,PCI_DEVICE_ID ) &0xf0 ; bridge_revision_id = bridge_id | stepping; }
@@ -55,7 +55,7 @@ static int get_pcie_bar(u32 *base, u32 *len) *base =0 ; *len =0 ; - pciexbar_reg =pci_read_config32 (dev,PCIEXBAR ); + pciexbar_reg =x86_pci_read_config32 (dev,PCIEXBAR );if (!(pciexbar_reg & (1 <<0 )))return 0 ;
@@ -170,7 +170,7 @@ void northbridge_init(pci_dev_t dev)void northbridge_enable (pci_dev_t dev) {#if CONFIG_HAVE_ACPI_RESUME -switch (pci_read_config32 (dev,SKPAD )) { +switch (x86_pci_read_config32 (dev,SKPAD )) {case 0xcafebabe :debug ("Normal boot.\n" );apci_set_slp_type (0 );
arch/x86/cpu/ivybridge/pch.c +2 -2
@@ -21,7 +21,7 @@ int pch_silicon_revision(void) dev =PCH_LPC_DEV ;if (pch_revision_id <0 ) - pch_revision_id =pci_read_config8 (dev,PCI_REVISION_ID ); + pch_revision_id =x86_pci_read_config8 (dev,PCI_REVISION_ID );return pch_revision_id; }
@@ -32,7 +32,7 @@ int pch_silicon_type(void) dev =PCH_LPC_DEV ;if (pch_type <0 ) - pch_type =pci_read_config8 (dev,PCI_DEVICE_ID +1 ); + pch_type =x86_pci_read_config8 (dev,PCI_DEVICE_ID +1 );return pch_type; }
arch/x86/cpu/ivybridge/pci.c +2 -2
@@ -70,9 +70,9 @@ int board_pci_pre_scan(struct pci_controller *hose) reg16 =0xff ; dev =PCH_DEV ; - reg16 =pci_read_config16 (dev,PCI_COMMAND ); + reg16 =x86_pci_read_config16 (dev,PCI_COMMAND ); reg16 |=PCI_COMMAND_SERR |PCI_COMMAND_MASTER |PCI_COMMAND_MEMORY ; -pci_write_config16 (dev,PCI_COMMAND , reg16); +x86_pci_write_config16 (dev,PCI_COMMAND , reg16);/* * Clear non-reserved bits in status register.
arch/x86/cpu/ivybridge/report_platform.c +2 -2
@@ -70,14 +70,14 @@ static void report_pch_info(void)u16 dev_id;uint8_t rev_id; - dev_id =pci_read_config16 (PCH_LPC_DEV ,2 ); + dev_id =x86_pci_read_config16 (PCH_LPC_DEV ,2 );for (i =0 ; i <ARRAY_SIZE (pch_table); i++) {if (pch_table[i].dev_id == dev_id) { pch_type = pch_table[i].dev_name;break ; } } - rev_id =pci_read_config8 (PCH_LPC_DEV ,8 ); + rev_id =x86_pci_read_config8 (PCH_LPC_DEV ,8 );debug ("PCH type: %s, device id: %x, rev id %x\n" , pch_type, dev_id, rev_id); }
arch/x86/cpu/ivybridge/sata.c +31 -30
145 lines not on this page · raw message
arch/x86/cpu/ivybridge/sdram.c +10 -10
@@ -444,7 +444,7 @@ int sdram_initialise(struct pei_data *pei_data)* Send ME init done for SandyBridge here. This is done inside the * SystemAgent binary on IvyBridge */ - done =pci_read_config32 (PCH_DEV ,PCI_DEVICE_ID ); + done =x86_pci_read_config32 (PCH_DEV ,PCI_DEVICE_ID ); done &=BASE_REV_MASK ;if (BASE_REV_SNB == done)intel_early_me_init_done (ME_INIT_STATUS_SUCCESS );
@@ -615,24 +615,24 @@ static int sdram_find(pci_dev_t dev)*/ /* Top of Upper Usable DRAM, including remap */ - touud =pci_read_config32 (dev,TOUUD +4 ); + touud =x86_pci_read_config32 (dev,TOUUD +4 ); touud <<=32 ; - touud |=pci_read_config32 (dev,TOUUD ); + touud |=x86_pci_read_config32 (dev,TOUUD );/* Top of Lower Usable DRAM */ - tolud =pci_read_config32 (dev,TOLUD ); + tolud =x86_pci_read_config32 (dev,TOLUD );/* Top of Memory - does not account for any UMA */ - tom =pci_read_config32 (dev,0xa4 ); + tom =x86_pci_read_config32 (dev,0xa4 ); tom <<=32 ; - tom |=pci_read_config32 (dev,0xa0 ); + tom |=x86_pci_read_config32 (dev,0xa0 );debug ("TOUUD %llx TOLUD %08x TOM %llx\n" , touud, tolud, tom);/* ME UMA needs excluding if total memory <4GB */ - me_base =pci_read_config32 (dev,0x74 ); + me_base =x86_pci_read_config32 (dev,0x74 ); me_base <<=32 ; - me_base |=pci_read_config32 (dev,0x70 ); + me_base |=x86_pci_read_config32 (dev,0x70 );debug ("MEBASE %llx\n" , me_base);
@@ -650,7 +650,7 @@ static int sdram_find(pci_dev_t dev) }/* Graphics memory comes next */ - ggc =pci_read_config16 (dev,GGC ); + ggc =x86_pci_read_config16 (dev,GGC );if (!(ggc &2 )) {debug ("IGD decoded, subtracting " );
@@ -670,7 +670,7 @@ static int sdram_find(pci_dev_t dev) }/* Calculate TSEG size from its base which must be below GTT */ - tseg_base =pci_read_config32 (dev,0xb8 ); + tseg_base =x86_pci_read_config32 (dev,0xb8 ); uma_size = (uma_memory_base - tseg_base) >>10 ; tomk -= uma_size; uma_memory_base = tomk *1024ULL ;
arch/x86/cpu/ivybridge/usb_ehci.c +2 -2
@@ -20,10 +20,10 @@ void bd82x6x_usb_ehci_init(pci_dev_t dev)writel (reg32,RCB_REG (0x35b0 ));debug ("EHCI: Setting up controller.. " ); - reg32 =pci_read_config32 (dev,PCI_COMMAND ); + reg32 =x86_pci_read_config32 (dev,PCI_COMMAND ); reg32 |=PCI_COMMAND_MASTER ;/* reg32 |= PCI_COMMAND_SERR; */ -pci_write_config32 (dev,PCI_COMMAND , reg32); +x86_pci_write_config32 (dev,PCI_COMMAND , reg32);debug ("done.\n" ); }
arch/x86/cpu/ivybridge/usb_xhci.c +4 -4
@@ -16,17 +16,17 @@ void bd82x6x_usb_xhci_init(pci_dev_t dev)debug ("XHCI: Setting up controller.. " );/* lock overcurrent map */ - reg32 =pci_read_config32 (dev,0x44 ); + reg32 =x86_pci_read_config32 (dev,0x44 ); reg32 |=1 ; -pci_write_config32 (dev,0x44 , reg32); +x86_pci_write_config32 (dev,0x44 , reg32);/* Enable clock gating */ - reg32 =pci_read_config32 (dev,0x40 ); + reg32 =x86_pci_read_config32 (dev,0x40 ); reg32 &= ~((1 <<20 ) | (1 <<21 )); reg32 |= (1 <<19 ) | (1 <<18 ) | (1 <<17 ); reg32 |= (1 <<10 ) | (1 <<9 ) | (1 <<8 ); reg32 |= (1 <<31 );/* lock */ -pci_write_config32 (dev,0x40 , reg32); +x86_pci_write_config32 (dev,0x40 , reg32);debug ("done.\n" ); }
arch/x86/cpu/pci.c +6 -6
@@ -70,7 +70,7 @@ static struct pci_controller *get_hose(void)return pci_bus_to_hose (0 ); } -unsigned int pci_read_config8 (pci_dev_t dev,unsigned where) +unsigned int x86_pci_read_config8 (pci_dev_t dev,unsigned where) {uint8_t value;
@@ -79,7 +79,7 @@ unsigned int pci_read_config8(pci_dev_t dev, unsigned where)return value; } -unsigned int pci_read_config16 (pci_dev_t dev,unsigned where) +unsigned int x86_pci_read_config16 (pci_dev_t dev,unsigned where) {uint16_t value;
@@ -88,7 +88,7 @@ unsigned int pci_read_config16(pci_dev_t dev, unsigned where)return value; } -unsigned int pci_read_config32 (pci_dev_t dev,unsigned where) +unsigned int x86_pci_read_config32 (pci_dev_t dev,unsigned where) {uint32_t value;
@@ -97,17 +97,17 @@ unsigned int pci_read_config32(pci_dev_t dev, unsigned where)return value; } -void pci_write_config8 (pci_dev_t dev,unsigned where,unsigned value) +void x86_pci_write_config8 (pci_dev_t dev,unsigned where,unsigned value) {pci_hose_write_config_byte (get_hose (), dev, where, value); } -void pci_write_config16 (pci_dev_t dev,unsigned where,unsigned value) +void x86_pci_write_config16 (pci_dev_t dev,unsigned where,unsigned value) {pci_hose_write_config_word (get_hose (), dev, where, value); } -void pci_write_config32 (pci_dev_t dev,unsigned where,unsigned value) +void x86_pci_write_config32 (pci_dev_t dev,unsigned where,unsigned value) {pci_hose_write_config_dword (get_hose (), dev, where, value); }
arch/x86/cpu/quark/quark.c +2 -2
@@ -28,9 +28,9 @@ static void unprotect_spi_flash(void) {u32 bc; - bc =pci_read_config32 (QUARK_LEGACY_BRIDGE ,0xd8 ); + bc =x86_pci_read_config32 (QUARK_LEGACY_BRIDGE ,0xd8 ); bc |=0x1 ;/* unprotect the flash */ -pci_write_config32 (QUARK_LEGACY_BRIDGE ,0xd8 , bc); +x86_pci_write_config32 (QUARK_LEGACY_BRIDGE ,0xd8 , bc); }static void quark_setup_bars (void )
arch/x86/cpu/queensbay/tnc.c +2 -2
@@ -16,9 +16,9 @@ static void unprotect_spi_flash(void) {u32 bc; - bc =pci_read_config32 (PCH_LPC_DEV ,0xd8 ); + bc =x86_pci_read_config32 (PCH_LPC_DEV ,0xd8 ); bc |=0x1 ;/* unprotect the flash */ -pci_write_config32 (PCH_LPC_DEV ,0xd8 , bc); +x86_pci_write_config32 (PCH_LPC_DEV ,0xd8 , bc); }int arch_cpu_init (void )
arch/x86/include/asm/pci.h +6 -6
@@ -48,13 +48,13 @@ int board_pci_post_scan(struct pci_controller *hose);* Simple PCI access routines - these work from either the early PCI hose * or the 'real' one, created after U-Boot has memory available */ -unsigned int pci_read_config8 (pci_dev_t dev,unsigned where); -unsigned int pci_read_config16 (pci_dev_t dev,unsigned where); -unsigned int pci_read_config32 (pci_dev_t dev,unsigned where); +unsigned int x86_pci_read_config8 (pci_dev_t dev,unsigned where); +unsigned int x86_pci_read_config16 (pci_dev_t dev,unsigned where); +unsigned int x86_pci_read_config32 (pci_dev_t dev,unsigned where); -void pci_write_config8 (pci_dev_t dev,unsigned where,unsigned value); -void pci_write_config16 (pci_dev_t dev,unsigned where,unsigned value); -void pci_write_config32 (pci_dev_t dev,unsigned where,unsigned value); +void x86_pci_write_config8 (pci_dev_t dev,unsigned where,unsigned value); +void x86_pci_write_config16 (pci_dev_t dev,unsigned where,unsigned value); +void x86_pci_write_config32 (pci_dev_t dev,unsigned where,unsigned value);#endif /* __ASSEMBLY__ */
arch/x86/lib/bios_interrupts.c +6 -6
@@ -172,28 +172,28 @@ int int1a_handler(void) }switch (func) {case 0xb108 :/* Read Config Byte */ - byte =pci_read_config8 (dev, reg); + byte =x86_pci_read_config8 (dev, reg);M .x86.R_ECX = byte;break ;case 0xb109 :/* Read Config Word */ - word =pci_read_config16 (dev, reg); + word =x86_pci_read_config16 (dev, reg);M .x86.R_ECX = word;break ;case 0xb10a :/* Read Config Dword */ - dword =pci_read_config32 (dev, reg); + dword =x86_pci_read_config32 (dev, reg);M .x86.R_ECX = dword;break ;case 0xb10b :/* Write Config Byte */ byte =M .x86.R_ECX; -pci_write_config8 (dev, reg, byte); +x86_pci_write_config8 (dev, reg, byte);break ;case 0xb10c :/* Write Config Word */ word =M .x86.R_ECX; -pci_write_config16 (dev, reg, word); +x86_pci_write_config16 (dev, reg, word);break ;case 0xb10d :/* Write Config Dword */ dword =M .x86.R_ECX; -pci_write_config32 (dev, reg, dword); +x86_pci_write_config32 (dev, reg, dword);break ; }
drivers/gpio/intel_ich6_gpio.c +8 -8
@@ -64,13 +64,13 @@ static int gpio_ich6_ofdata_to_platdata(struct udevice *dev) pci_dev =PCI_BDF (0 ,0x1f ,0 );/* Is the device present? */ - tmpword =pci_read_config16 (pci_dev,PCI_VENDOR_ID ); + tmpword =x86_pci_read_config16 (pci_dev,PCI_VENDOR_ID );if (tmpword !=PCI_VENDOR_ID_INTEL ) {debug ("%s: wrong VendorID\n" , __func__);return -ENODEV ; } - tmpword =pci_read_config16 (pci_dev,PCI_DEVICE_ID ); + tmpword =x86_pci_read_config16 (pci_dev,PCI_DEVICE_ID );debug ("Found %04x:%04x\n" ,PCI_VENDOR_ID_INTEL , tmpword);/* * We'd like to validate the Device ID too, but pretty much any
@@ -80,34 +80,34 @@ static int gpio_ich6_ofdata_to_platdata(struct udevice *dev)*/ /* I/O should already be enabled (it's a RO bit). */ - tmpword =pci_read_config16 (pci_dev,PCI_COMMAND ); + tmpword =x86_pci_read_config16 (pci_dev,PCI_COMMAND );if (!(tmpword &PCI_COMMAND_IO )) {debug ("%s: device IO not enabled\n" , __func__);return -ENODEV ; }/* Header Type must be normal (bits 6-0 only; see spec.) */ - tmpbyte =pci_read_config8 (pci_dev,PCI_HEADER_TYPE ); + tmpbyte =x86_pci_read_config8 (pci_dev,PCI_HEADER_TYPE );if ((tmpbyte &0x7f ) !=PCI_HEADER_TYPE_NORMAL ) {debug ("%s: invalid Header type\n" , __func__);return -ENODEV ; }/* Base Class must be a bridge device */ - tmpbyte =pci_read_config8 (pci_dev,PCI_CLASS_CODE ); + tmpbyte =x86_pci_read_config8 (pci_dev,PCI_CLASS_CODE );if (tmpbyte !=PCI_CLASS_CODE_BRIDGE ) {debug ("%s: invalid class\n" , __func__);return -ENODEV ; }/* Sub Class must be ISA */ - tmpbyte =pci_read_config8 (pci_dev,PCI_CLASS_SUB_CODE ); + tmpbyte =x86_pci_read_config8 (pci_dev,PCI_CLASS_SUB_CODE );if (tmpbyte !=PCI_CLASS_SUB_CODE_BRIDGE_ISA ) {debug ("%s: invalid subclass\n" , __func__);return -ENODEV ; }/* Programming Interface must be 0x00 (no others exist) */ - tmpbyte =pci_read_config8 (pci_dev,PCI_CLASS_PROG ); + tmpbyte =x86_pci_read_config8 (pci_dev,PCI_CLASS_PROG );if (tmpbyte !=0x00 ) {debug ("%s: invalid interface type\n" , __func__);return -ENODEV ;
@@ -123,7 +123,7 @@ static int gpio_ich6_ofdata_to_platdata(struct udevice *dev)* while on the Ivybridge the bit0 is used to indicate it is an * I/O space. */ - tmplong =pci_read_config32 (pci_dev,PCI_CFG_GPIOBASE ); + tmplong =x86_pci_read_config32 (pci_dev,PCI_CFG_GPIOBASE );if (tmplong ==0x00000000 || tmplong ==0xffffffff ) {debug ("%s: unexpected GPIOBASE value\n" , __func__);return -ENODEV ;
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 4/22 x86: Add a x86_ prefix to the x86-specific PCI functions
Quoted 1,204 lines · Simon Glass
These functions currently use a generic name, but they are for x86 only. This may introduce confusion and prevents U-Boot from using these names more widely.
In fact it should be possible to remove these at some point and use generic functions, but for now, rename them.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/baytrail/early_uart.c | 5 ++- arch/x86/cpu/ivybridge/bd82x6x.c | 32 +++++++------- arch/x86/cpu/ivybridge/cpu.c | 38 ++++++++-------- 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 | 74 ++++++++++++++++---------------- arch/x86/cpu/ivybridge/northbridge.c | 6 +-- arch/x86/cpu/ivybridge/pch.c | 4 +- arch/x86/cpu/ivybridge/pci.c | 4 +- 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 | 12 +++--- arch/x86/cpu/quark/quark.c | 4 +- arch/x86/cpu/queensbay/tnc.c | 4 +- arch/x86/include/asm/pci.h | 12 +++--- arch/x86/lib/bios_interrupts.c | 12 +++--- drivers/gpio/intel_ich6_gpio.c | 16 +++---- 21 files changed, 199 insertions(+), 195 deletions(-)arch/x86/cpu/baytrail/early_uart.c +3
-2@@ -50,7 +50,7 @@ static void score_select_func(int pad, int func)writel (reg, pconf0_addr); } -static void pci_write_config32 (int dev,unsigned int where,u32 value) +static void x86_pci_write_config32 (int dev,unsigned int where,u32 value) {unsigned long addr;@@ -62,7 +62,8 @@ static void pci_write_config32(int dev, unsigned int where, u32 value)int setup_early_uart (void ) {/* Enable the legacy UART hardware. */ -pci_write_config32 (PCI_DEV_CONFIG (0 ,LPC_DEV ,LPC_FUNC ),UART_CONT ,1 ); +x86_pci_write_config32 (PCI_DEV_CONFIG (0 ,LPC_DEV ,LPC_FUNC ),UART_CONT , +1 );/* * Set up the pads to the UART function. This allows the signals to arch/x86/cpu/ivybridge/bd82x6x.c +16
-16@@ -22,36 +22,36 @@ void bd82x6x_pci_init(pci_dev_t dev)debug ("bd82x6x PCI init.\n" );/* Enable Bus Master */ - reg16 =pci_read_config16 (dev,PCI_COMMAND ); + reg16 =x86_pci_read_config16 (dev,PCI_COMMAND ); reg16 |=PCI_COMMAND_MASTER ; -pci_write_config16 (dev,PCI_COMMAND , reg16); +x86_pci_write_config16 (dev,PCI_COMMAND , reg16);/* This device has no interrupt */ -pci_write_config8 (dev,INTR ,0xff ); +x86_pci_write_config8 (dev,INTR ,0xff );/* disable parity error response and SERR */ - reg16 =pci_read_config16 (dev,BCTRL ); + reg16 =x86_pci_read_config16 (dev,BCTRL ); reg16 &= ~(1 <<0 ); reg16 &= ~(1 <<1 ); -pci_write_config16 (dev,BCTRL , reg16); +x86_pci_write_config16 (dev,BCTRL , reg16);/* Master Latency Count must be set to 0x04! */ - reg8 =pci_read_config8 (dev,SMLT ); + reg8 =x86_pci_read_config8 (dev,SMLT ); reg8 &=0x07 ; reg8 |= (0x04 <<3 ); -pci_write_config8 (dev,SMLT , reg8); +x86_pci_write_config8 (dev,SMLT , reg8);/* Will this improve throughput of bus masters? */ -pci_write_config8 (dev,PCI_MIN_GNT ,0x06 ); +x86_pci_write_config8 (dev,PCI_MIN_GNT ,0x06 );/* Clear errors in status registers */ - reg16 =pci_read_config16 (dev,PSTS ); + reg16 =x86_pci_read_config16 (dev,PSTS );/* reg16 |= 0xf900; */ -pci_write_config16 (dev,PSTS , reg16); +x86_pci_write_config16 (dev,PSTS , reg16); - reg16 =pci_read_config16 (dev,SECSTS ); + reg16 =x86_pci_read_config16 (dev,SECSTS );/* reg16 |= 0xf900; */ -pci_write_config16 (dev,SECSTS , reg16); +x86_pci_write_config16 (dev,SECSTS , reg16); }#define PCI_BRIDGE_UPDATE_COMMAND @@ -59,7 +59,7 @@ void bd82x6x_pci_dev_enable_resources(pci_dev_t dev) {uint16_t command; - command =pci_read_config16 (dev,PCI_COMMAND ); + command =x86_pci_read_config16 (dev,PCI_COMMAND ); command |=PCI_COMMAND_IO ;#ifdef PCI_BRIDGE_UPDATE_COMMAND /* @@ -67,7 +67,7 @@ void bd82x6x_pci_dev_enable_resources(pci_dev_t dev)* ROM and APICs to become invisible. */ debug ("%x cmd <- %02x\n" , dev, command); -pci_write_config16 (dev,PCI_COMMAND , command); +x86_pci_write_config16 (dev,PCI_COMMAND , command);#else printf ("%s cmd <- %02x (NOT WRITTEN!)\n" ,dev_path (dev), command);#endif @@ -77,11 +77,11 @@ void bd82x6x_pci_bus_enable_resources(pci_dev_t dev) {uint16_t ctrl; - ctrl =pci_read_config16 (dev,PCI_BRIDGE_CONTROL ); + ctrl =x86_pci_read_config16 (dev,PCI_BRIDGE_CONTROL ); ctrl |=PCI_COMMAND_IO ; ctrl |=PCI_BRIDGE_CTL_VGA ;debug ("%x bridge ctrl <- %04x\n" , dev, ctrl); -pci_write_config16 (dev,PCI_BRIDGE_CONTROL , ctrl); +x86_pci_write_config16 (dev,PCI_BRIDGE_CONTROL , ctrl);bd82x6x_pci_dev_enable_resources (dev); }arch/x86/cpu/ivybridge/cpu.c +19
-19@@ -167,21 +167,21 @@ static int enable_smbus(void) dev =PCI_BDF (0x0 ,0x1f ,0x3 );/* Check to make sure we've got the right device. */ - value =pci_read_config16 (dev,0x0 ); + value =x86_pci_read_config16 (dev,0x0 );if (value !=0x8086 ) {printf ("SMBus controller not found\n" );return -ENOSYS ; }/* Set SMBus I/O base. */ -pci_write_config32 (dev,SMB_BASE , -SMBUS_IO_BASE |PCI_BASE_ADDRESS_SPACE_IO ); +x86_pci_write_config32 (dev,SMB_BASE , +SMBUS_IO_BASE |PCI_BASE_ADDRESS_SPACE_IO );/* Set SMBus enable. */ -pci_write_config8 (dev,HOSTC ,HST_EN ); +x86_pci_write_config8 (dev,HOSTC ,HST_EN );/* Set SMBus I/O space enable. */ -pci_write_config16 (dev,PCI_COMMAND ,PCI_COMMAND_IO ); +x86_pci_write_config16 (dev,PCI_COMMAND ,PCI_COMMAND_IO );/* Disable interrupt generation. */ outb (0 ,SMBUS_IO_BASE +SMBHSTCTL );@@ -214,25 +214,25 @@ static void enable_usb_bar(void)u32 cmd;/* USB Controller 1 */ -pci_write_config32 (usb0,PCI_BASE_ADDRESS_0 , -PCH_EHCI0_TEMP_BAR0 ); - cmd =pci_read_config32 (usb0,PCI_COMMAND ); +x86_pci_write_config32 (usb0,PCI_BASE_ADDRESS_0 , +PCH_EHCI0_TEMP_BAR0 ); + cmd =x86_pci_read_config32 (usb0,PCI_COMMAND ); cmd |=PCI_COMMAND_MASTER |PCI_COMMAND_MEMORY ; -pci_write_config32 (usb0,PCI_COMMAND , cmd); +x86_pci_write_config32 (usb0,PCI_COMMAND , cmd);/* USB Controller 1 */ -pci_write_config32 (usb1,PCI_BASE_ADDRESS_0 , -PCH_EHCI1_TEMP_BAR0 ); - cmd =pci_read_config32 (usb1,PCI_COMMAND ); +x86_pci_write_config32 (usb1,PCI_BASE_ADDRESS_0 , +PCH_EHCI1_TEMP_BAR0 ); + cmd =x86_pci_read_config32 (usb1,PCI_COMMAND ); cmd |=PCI_COMMAND_MASTER |PCI_COMMAND_MEMORY ; -pci_write_config32 (usb1,PCI_COMMAND , cmd); +x86_pci_write_config32 (usb1,PCI_COMMAND , cmd);/* USB3 Controller */ -pci_write_config32 (usb3,PCI_BASE_ADDRESS_0 , -PCH_XHCI_TEMP_BAR0 ); - cmd =pci_read_config32 (usb3,PCI_COMMAND ); +x86_pci_write_config32 (usb3,PCI_BASE_ADDRESS_0 , +PCH_XHCI_TEMP_BAR0 ); + cmd =x86_pci_read_config32 (usb3,PCI_COMMAND ); cmd |=PCI_COMMAND_MASTER |PCI_COMMAND_MEMORY ; -pci_write_config32 (usb3,PCI_COMMAND , cmd); +x86_pci_write_config32 (usb3,PCI_COMMAND , cmd); }static int report_bist_failure (void )@@ -320,8 +320,8 @@ int print_cpuinfo(void) gd->arch.pei_boot_mode = boot_mode;/* TODO: Move this to the board or driver */ -pci_write_config32 (PCH_LPC_DEV ,GPIO_BASE ,DEFAULT_GPIOBASE |1 ); -pci_write_config32 (PCH_LPC_DEV ,GPIO_CNTL ,0x10 ); +x86_pci_write_config32 (PCH_LPC_DEV ,GPIO_BASE ,DEFAULT_GPIOBASE |1 ); +x86_pci_write_config32 (PCH_LPC_DEV ,GPIO_CNTL ,0x10 );/* Print processor name */ name =cpu_get_name (processor_name);arch/x86/cpu/ivybridge/early_init.c +30
-28@@ -17,10 +17,10 @@ static void sandybridge_setup_bars(pci_dev_t pch_dev, pci_dev_t lpc_dev) {/* Setting up Southbridge. In the northbridge code. */ debug ("Setting up static southbridge registers\n" ); -pci_write_config32 (lpc_dev,PCH_RCBA_BASE ,DEFAULT_RCBA |1 ); +x86_pci_write_config32 (lpc_dev,PCH_RCBA_BASE ,DEFAULT_RCBA |1 ); -pci_write_config32 (lpc_dev,PMBASE ,DEFAULT_PMBASE |1 ); -pci_write_config8 (lpc_dev,ACPI_CNTL ,0x80 );/* Enable ACPI BAR */ +x86_pci_write_config32 (lpc_dev,PMBASE ,DEFAULT_PMBASE |1 ); +x86_pci_write_config8 (lpc_dev,ACPI_CNTL ,0x80 );/* Enable ACPI BAR */ debug ("Disabling watchdog reboot\n" );setbits_le32 (RCB_REG (GCS ),1 >>5 );/* No reset */ @@ -28,25 +28,27 @@ static void sandybridge_setup_bars(pci_dev_t pch_dev, pci_dev_t lpc_dev)/* Set up all hardcoded northbridge BARs */ debug ("Setting up static registers\n" ); -pci_write_config32 (pch_dev,EPBAR ,DEFAULT_EPBAR |1 ); -pci_write_config32 (pch_dev,EPBAR +4 , (0LL +DEFAULT_EPBAR ) >>32 ); -pci_write_config32 (pch_dev,MCHBAR ,DEFAULT_MCHBAR |1 ); -pci_write_config32 (pch_dev,MCHBAR +4 , (0LL +DEFAULT_MCHBAR ) >>32 ); +x86_pci_write_config32 (pch_dev,EPBAR ,DEFAULT_EPBAR |1 ); +x86_pci_write_config32 (pch_dev,EPBAR +4 , (0LL +DEFAULT_EPBAR ) >>32 ); +x86_pci_write_config32 (pch_dev,MCHBAR ,DEFAULT_MCHBAR |1 ); +x86_pci_write_config32 (pch_dev,MCHBAR +4 , + (0LL +DEFAULT_MCHBAR ) >>32 );/* 64MB - busses 0-63 */ -pci_write_config32 (pch_dev,PCIEXBAR ,DEFAULT_PCIEXBAR |5 ); -pci_write_config32 (pch_dev,PCIEXBAR +4 , - (0LL +DEFAULT_PCIEXBAR ) >>32 ); -pci_write_config32 (pch_dev,DMIBAR ,DEFAULT_DMIBAR |1 ); -pci_write_config32 (pch_dev,DMIBAR +4 , (0LL +DEFAULT_DMIBAR ) >>32 ); +x86_pci_write_config32 (pch_dev,PCIEXBAR ,DEFAULT_PCIEXBAR |5 ); +x86_pci_write_config32 (pch_dev,PCIEXBAR +4 , + (0LL +DEFAULT_PCIEXBAR ) >>32 ); +x86_pci_write_config32 (pch_dev,DMIBAR ,DEFAULT_DMIBAR |1 ); +x86_pci_write_config32 (pch_dev,DMIBAR +4 , + (0LL +DEFAULT_DMIBAR ) >>32 );/* Set C0000-FFFFF to access RAM on both reads and writes */ -pci_write_config8 (pch_dev,PAM0 ,0x30 ); -pci_write_config8 (pch_dev,PAM1 ,0x33 ); -pci_write_config8 (pch_dev,PAM2 ,0x33 ); -pci_write_config8 (pch_dev,PAM3 ,0x33 ); -pci_write_config8 (pch_dev,PAM4 ,0x33 ); -pci_write_config8 (pch_dev,PAM5 ,0x33 ); -pci_write_config8 (pch_dev,PAM6 ,0x33 ); +x86_pci_write_config8 (pch_dev,PAM0 ,0x30 ); +x86_pci_write_config8 (pch_dev,PAM1 ,0x33 ); +x86_pci_write_config8 (pch_dev,PAM2 ,0x33 ); +x86_pci_write_config8 (pch_dev,PAM3 ,0x33 ); +x86_pci_write_config8 (pch_dev,PAM4 ,0x33 ); +x86_pci_write_config8 (pch_dev,PAM5 ,0x33 ); +x86_pci_write_config8 (pch_dev,PAM6 ,0x33 ); }static void sandybridge_setup_graphics (pci_dev_t pch_dev,pci_dev_t video_dev)@@ -55,7 +57,7 @@ static void sandybridge_setup_graphics(pci_dev_t pch_dev, pci_dev_t video_dev)u16 reg16;u8 reg8; - reg16 =pci_read_config16 (video_dev,PCI_DEVICE_ID ); + reg16 =x86_pci_read_config16 (video_dev,PCI_DEVICE_ID );switch (reg16) {case 0x0102 :/* GT1 Desktop */ case 0x0106 :/* GT1 Mobile */ @@ -75,7 +77,7 @@ static void sandybridge_setup_graphics(pci_dev_t pch_dev, pci_dev_t video_dev)debug ("Initialising Graphics\n" );/* Setup IGD memory by setting GGC[7:3] = 1 for 32MB */ - reg16 =pci_read_config16 (pch_dev,GGC ); + reg16 =x86_pci_read_config16 (pch_dev,GGC ); reg16 &= ~0x00f8 ; reg16 |=1 <<3 ;/* Program GTT memory by setting GGC[9:8] = 2MB */ @@ -83,13 +85,13 @@ static void sandybridge_setup_graphics(pci_dev_t pch_dev, pci_dev_t video_dev) reg16 |=2 <<8 ;/* Enable VGA decode */ reg16 &= ~0x0002 ; -pci_write_config16 (pch_dev,GGC , reg16); +x86_pci_write_config16 (pch_dev,GGC , reg16);/* Enable 256MB aperture */ - reg8 =pci_read_config8 (video_dev,MSAC ); + reg8 =x86_pci_read_config8 (video_dev,MSAC ); reg8 &= ~0x06 ; reg8 |=0x02 ; -pci_write_config8 (video_dev,MSAC , reg8); +x86_pci_write_config8 (video_dev,MSAC , reg8);/* Erratum workarounds */ reg32 =readl (MCHBAR_REG (0x5f00 ));@@ -124,22 +126,22 @@ void sandybridge_early_init(int chipset_type)u8 reg8;/* Device ID Override Enable should be done very early */ - capid0_a =pci_read_config32 (pch_dev,0xe4 ); + capid0_a =x86_pci_read_config32 (pch_dev,0xe4 );if (capid0_a & (1 <<10 )) { - reg8 =pci_read_config8 (pch_dev,0xf3 ); + reg8 =x86_pci_read_config8 (pch_dev,0xf3 ); reg8 &= ~7 ;/* Clear 2:0 */ if (chipset_type ==SANDYBRIDGE_MOBILE ) reg8 |=1 ;/* Set bit 0 */ -pci_write_config8 (pch_dev,0xf3 , reg8); +x86_pci_write_config8 (pch_dev,0xf3 , reg8); }/* Setup all BARs required for early PCIe and raminit */ sandybridge_setup_bars (pch_dev, lpc_dev);/* Device Enable */ -pci_write_config32 (pch_dev,DEVEN ,DEVEN_HOST |DEVEN_IGD ); +x86_pci_write_config32 (pch_dev,DEVEN ,DEVEN_HOST |DEVEN_IGD );sandybridge_setup_graphics (pch_dev, video_dev); }arch/x86/cpu/ivybridge/early_me.c +6
-6@@ -29,7 +29,7 @@ static inline void pci_read_dword_ptr(void *ptr, int offset) {u32 dword; - dword =pci_read_config32 (PCH_ME_DEV , offset); + dword =x86_pci_read_config32 (PCH_ME_DEV , offset);memcpy (ptr, &dword,sizeof (dword)); }@@ -37,7 +37,7 @@ static inline void pci_write_dword_ptr(void *ptr, int offset) {u32 dword =0 ;memcpy (&dword, ptr,sizeof (dword)); -pci_write_config32 (PCH_ME_DEV , offset, dword); +x86_pci_write_config32 (PCH_ME_DEV , offset, dword); }void intel_early_me_status (void )@@ -101,7 +101,7 @@ static inline void set_global_reset(int enable) {u32 etr3; - etr3 =pci_read_config32 (PCH_LPC_DEV ,ETR3 ); + etr3 =x86_pci_read_config32 (PCH_LPC_DEV ,ETR3 );/* Clear CF9 Without Resume Well Reset Enable */ etr3 &= ~ETR3_CWORWRE ;@@ -112,7 +112,7 @@ static inline void set_global_reset(int enable)else etr3 &= ~ETR3_CF9GR ; -pci_write_config32 (PCH_LPC_DEV ,ETR3 , etr3); +x86_pci_write_config32 (PCH_LPC_DEV ,ETR3 , etr3); }int intel_early_me_init_done (u8 status)@@ -127,8 +127,8 @@ int intel_early_me_init_done(u8 status) };/* MEBASE from MESEG_BASE[35:20] */ - mebase_l =pci_read_config32 (PCH_DEV ,PCI_CPU_MEBASE_L ); - mebase_h =pci_read_config32 (PCH_DEV ,PCI_CPU_MEBASE_H ); + mebase_l =x86_pci_read_config32 (PCH_DEV ,PCI_CPU_MEBASE_L ); + mebase_h =x86_pci_read_config32 (PCH_DEV ,PCI_CPU_MEBASE_H ); mebase_h &=0xf ; did.uma_base = (mebase_l >>20 ) | (mebase_h <<12 );arch/x86/cpu/ivybridge/gma.c +2
-2@@ -741,9 +741,9 @@ int gma_func0_init(pci_dev_t dev, struct pci_controller *hose,int ret;/* IGD needs to be Bus Master */ - reg32 =pci_read_config32 (dev,PCI_COMMAND ); + reg32 =x86_pci_read_config32 (dev,PCI_COMMAND ); reg32 |=PCI_COMMAND_MASTER |PCI_COMMAND_MEMORY |PCI_COMMAND_IO ; -pci_write_config32 (dev,PCI_COMMAND , reg32); +x86_pci_write_config32 (dev,PCI_COMMAND , reg32);/* Use write-combining for the graphics memory, 256MB */ base =pci_read_bar32 (hose, dev,2 );arch/x86/cpu/ivybridge/lpc.c +37
-37@@ -29,7 +29,7 @@ static int pch_enable_apic(pci_dev_t dev)int i;/* Enable ACPI I/O and power management. Set SCI IRQ to IRQ9 */ -pci_write_config8 (dev,ACPI_CNTL ,0x80 ); +x86_pci_write_config8 (dev,ACPI_CNTL ,0x80 );writel (0 ,IO_APIC_INDEX );writel (1 <<25 ,IO_APIC_DATA );@@ -72,9 +72,9 @@ static void pch_enable_serial_irqs(pci_dev_t dev)/* Set packet length and toggle silent mode bit for one frame. */ value = (1 <<7 ) | (1 <<6 ) | ((21 -17 ) <<2 ) | (0 <<0 );#ifdef CONFIG_SERIRQ_CONTINUOUS_MODE -pci_write_config8 (dev,SERIRQ_CNTL , value); +x86_pci_write_config8 (dev,SERIRQ_CNTL , value);#else -pci_write_config8 (dev,SERIRQ_CNTL , value | (1 <<6 )); +x86_pci_write_config8 (dev,SERIRQ_CNTL , value | (1 <<6 ));#endif }@@ -86,15 +86,15 @@ static int pch_pirq_init(const void *blob, int node, pci_dev_t dev) sizeof(route)))return -EINVAL ; ptr = route; -pci_write_config8 (dev,PIRQA_ROUT , *ptr++); -pci_write_config8 (dev,PIRQB_ROUT , *ptr++); -pci_write_config8 (dev,PIRQC_ROUT , *ptr++); -pci_write_config8 (dev,PIRQD_ROUT , *ptr++); +x86_pci_write_config8 (dev,PIRQA_ROUT , *ptr++); +x86_pci_write_config8 (dev,PIRQB_ROUT , *ptr++); +x86_pci_write_config8 (dev,PIRQC_ROUT , *ptr++); +x86_pci_write_config8 (dev,PIRQD_ROUT , *ptr++); -pci_write_config8 (dev,PIRQE_ROUT , *ptr++); -pci_write_config8 (dev,PIRQF_ROUT , *ptr++); -pci_write_config8 (dev,PIRQG_ROUT , *ptr++); -pci_write_config8 (dev,PIRQH_ROUT , *ptr++); +x86_pci_write_config8 (dev,PIRQE_ROUT , *ptr++); +x86_pci_write_config8 (dev,PIRQF_ROUT , *ptr++); +x86_pci_write_config8 (dev,PIRQG_ROUT , *ptr++); +x86_pci_write_config8 (dev,PIRQH_ROUT , *ptr++);/* * TODO(sjg at chromium.org): U-Boot does not set up the interrupts @@ -116,7 +116,7 @@ static int pch_gpi_routing(const void *blob, int node, pci_dev_t dev)for (reg =0 , gpi =0 ; gpi <ARRAY_SIZE (route); gpi++) reg |= route[gpi] << (gpi *2 ); -pci_write_config32 (dev,0xb8 , reg); +x86_pci_write_config32 (dev,0xb8 , reg);return 0 ; }@@ -141,7 +141,7 @@ static int pch_power_options(const void *blob, int node, pci_dev_t dev)*/ pwr_on =MAINBOARD_POWER_ON ; - reg16 =pci_read_config16 (dev,GEN_PMCON_3 ); + reg16 =x86_pci_read_config16 (dev,GEN_PMCON_3 ); reg16 &=0xfffe ;switch (pwr_on) {case MAINBOARD_POWER_OFF :@@ -168,7 +168,7 @@ static int pch_power_options(const void *blob, int node, pci_dev_t dev) reg16 |= (1 <<12 );/* Disable SLP stretch after SUS well */ -pci_write_config16 (dev,GEN_PMCON_3 , reg16); +x86_pci_write_config16 (dev,GEN_PMCON_3 , reg16);debug ("Set power %s after power failure.\n" , state);/* Set up NMI on errors. */ @@ -192,21 +192,21 @@ static int pch_power_options(const void *blob, int node, pci_dev_t dev)outb (reg8,0x70 );/* Enable CPU_SLP# and Intel Speedstep, set SMI# rate down */ - reg16 =pci_read_config16 (dev,GEN_PMCON_1 ); + reg16 =x86_pci_read_config16 (dev,GEN_PMCON_1 ); reg16 &= ~(3 <<0 );/* SMI# rate 1 minute */ reg16 &= ~(1 <<10 );/* Disable BIOS_PCI_EXP_EN for native PME */ #if DEBUG_PERIODIC_SMIS /* Set DEBUG_PERIODIC_SMIS in pch.h to debug using periodic SMIs */ reg16 |= (3 <<0 );/* Periodic SMI every 8s */ #endif -pci_write_config16 (dev,GEN_PMCON_1 , reg16); +x86_pci_write_config16 (dev,GEN_PMCON_1 , reg16);/* Set the board's GPI routing. */ ret =pch_gpi_routing (blob, node, dev);if (ret)return ret; - pmbase =pci_read_config16 (dev,0x40 ) &0xfffe ; + pmbase =x86_pci_read_config16 (dev,0x40 ) &0xfffe ;writel (pmbase +GPE0_EN ,fdtdec_get_int (blob, node,"intel,gpe0-enable" ,0 ));@@ -231,11 +231,11 @@ static void pch_rtc_init(pci_dev_t dev)int rtc_failed;u8 reg8; - reg8 =pci_read_config8 (dev,GEN_PMCON_3 ); + reg8 =x86_pci_read_config8 (dev,GEN_PMCON_3 ); rtc_failed = reg8 &RTC_BATTERY_DEAD ;if (rtc_failed) { reg8 &= ~RTC_BATTERY_DEAD ; -pci_write_config8 (dev,GEN_PMCON_3 , reg8); +x86_pci_write_config8 (dev,GEN_PMCON_3 , reg8); }debug ("rtc_failed = 0x%x\n" , rtc_failed);@@ -258,7 +258,7 @@ static void pch_rtc_init(pci_dev_t dev)static void cpt_pm_init (pci_dev_t dev) {debug ("CougarPoint PM init\n" ); -pci_write_config8 (dev,0xa9 ,0x47 ); +x86_pci_write_config8 (dev,0xa9 ,0x47 );setbits_le32 (RCB_REG (0x2238 ), (1 <<6 ) | (1 <<0 ));setbits_le32 (RCB_REG (0x228c ),1 <<0 );@@ -302,7 +302,7 @@ static void cpt_pm_init(pci_dev_t dev)static void ppt_pm_init (pci_dev_t dev) {debug ("PantherPoint PM init\n" ); -pci_write_config8 (dev,0xa9 ,0x47 ); +x86_pci_write_config8 (dev,0xa9 ,0x47 );setbits_le32 (RCB_REG (0x2238 ),1 <<0 );setbits_le32 (RCB_REG (0x228c ),1 <<0 );setbits_le16 (RCB_REG (0x1100 ), (1 <<13 ) | (1 <<14 ));@@ -356,9 +356,9 @@ static void enable_clock_gating(pci_dev_t dev)setbits_le32 (RCB_REG (0x2234 ),0xf ); - reg16 =pci_read_config16 (dev,GEN_PMCON_1 ); + reg16 =x86_pci_read_config16 (dev,GEN_PMCON_1 ); reg16 |= (1 <<2 ) | (1 <<11 ); -pci_write_config16 (dev,GEN_PMCON_1 , reg16); +x86_pci_write_config16 (dev,GEN_PMCON_1 , reg16);pch_iobp_update (0xEB007F07 , ~0UL , (1 <<31 ));pch_iobp_update (0xEB004000 , ~0UL , (1 <<7 ));@@ -412,15 +412,15 @@ static void pch_lock_smm(pci_dev_t dev)#if TEST_SMM_FLASH_LOCKDOWN /* Now try this: */ debug ("Locking BIOS to RO... " ); - reg8 =pci_read_config8 (dev,0xdc );/* BIOS_CNTL */ + reg8 =x86_pci_read_config8 (dev,0xdc );/* BIOS_CNTL */ debug (" BLE: %s; BWE: %s\n" , (reg8 &2 ) ?"on" :"off" , (reg8 &1 ) ?"rw" :"ro" ); reg8 &= ~(1 <<0 );/* clear BIOSWE */ -pci_write_config8 (dev,0xdc , reg8); +x86_pci_write_config8 (dev,0xdc , reg8); reg8 |= (1 <<1 );/* set BLE */ -pci_write_config8 (dev,0xdc , reg8); +x86_pci_write_config8 (dev,0xdc , reg8);debug ("ok.\n" ); - reg8 =pci_read_config8 (dev,0xdc );/* BIOS_CNTL */ + reg8 =x86_pci_read_config8 (dev,0xdc );/* BIOS_CNTL */ debug (" BLE: %s; BWE: %s\n" , (reg8 &2 ) ?"on" :"off" , (reg8 &1 ) ?"rw" :"ro" );@@ -428,9 +428,9 @@ static void pch_lock_smm(pci_dev_t dev)writeb (0 ,0xfff00000 );debug ("Testing:\n" ); reg8 |= (1 <<0 );/* set BIOSWE */ -pci_write_config8 (dev,0xdc , reg8); +x86_pci_write_config8 (dev,0xdc , reg8); - reg8 =pci_read_config8 (dev,0xdc );/* BIOS_CNTL */ + reg8 =x86_pci_read_config8 (dev,0xdc );/* BIOS_CNTL */ debug (" BLE: %s; BWE: %s\n" , (reg8 &2 ) ?"on" :"off" , (reg8 &1 ) ?"rw" :"ro" );debug ("Done.\n" );@@ -443,9 +443,9 @@ static void pch_disable_smm_only_flashing(pci_dev_t dev)u8 reg8;debug ("Enabling BIOS updates outside of SMM... " ); - reg8 =pci_read_config8 (dev,0xdc );/* BIOS_CNTL */ + reg8 =x86_pci_read_config8 (dev,0xdc );/* BIOS_CNTL */ reg8 &= ~(1 <<5 ); -pci_write_config8 (dev,0xdc , reg8); +x86_pci_write_config8 (dev,0xdc , reg8); }static void pch_fixups (pci_dev_t dev)@@ -453,9 +453,9 @@ static void pch_fixups(pci_dev_t dev)u8 gen_pmcon_2;/* Indicate DRAM init done for MRC S3 to know it can resume */ - gen_pmcon_2 =pci_read_config8 (dev,GEN_PMCON_2 ); + gen_pmcon_2 =x86_pci_read_config8 (dev,GEN_PMCON_2 ); gen_pmcon_2 |= (1 <<7 ); -pci_write_config8 (dev,GEN_PMCON_2 , gen_pmcon_2); +x86_pci_write_config8 (dev,GEN_PMCON_2 , gen_pmcon_2);/* Enable DMI ASPM in the PCH */ clrbits_le32 (RCB_REG (0x2304 ),1 <<10 );@@ -478,10 +478,10 @@ int lpc_early_init(const void *blob, int node, pci_dev_t dev)return -EINVAL ;/* Set COM1/COM2 decode range */ -pci_write_config16 (dev,LPC_IO_DEC ,0x0010 ); +x86_pci_write_config16 (dev,LPC_IO_DEC ,0x0010 );/* Enable PS/2 Keyboard/Mouse, EC areas and COM1 */ -pci_write_config16 (dev,LPC_EN ,KBC_LPC_EN |MC_LPC_EN | +x86_pci_write_config16 (dev,LPC_EN ,KBC_LPC_EN |MC_LPC_EN |GAMEL_LPC_EN |COMA_LPC_EN );/* Write all registers but use 0 if we run out of data */ @@ -491,7 +491,7 @@ int lpc_early_init(const void *blob, int node, pci_dev_t dev)if (i < count) reg = ptr->base |PCI_COMMAND_IO | (ptr->size <<16 ); -pci_write_config32 (dev,LPC_GENX_DEC (i), reg); +x86_pci_write_config32 (dev,LPC_GENX_DEC (i), reg); }return 0 ;@@ -514,7 +514,7 @@ int lpc_init(struct pci_controller *hose, pci_dev_t dev)return -ENOENT ;/* Set the value for PCI command register. */ -pci_write_config16 (dev,PCI_COMMAND ,0x000f ); +x86_pci_write_config16 (dev,PCI_COMMAND ,0x000f );/* IO APIC initialization. */ pch_enable_apic (dev);arch/x86/cpu/ivybridge/northbridge.c +3
-3@@ -30,7 +30,7 @@ int bridge_silicon_revision(void) result =cpuid (1 ); stepping = result.eax &0xf ; dev =PCI_BDF (0 ,0 ,0 ); - bridge_id =pci_read_config16 (dev,PCI_DEVICE_ID ) &0xf0 ; + bridge_id =x86_pci_read_config16 (dev,PCI_DEVICE_ID ) &0xf0 ; bridge_revision_id = bridge_id | stepping; }@@ -55,7 +55,7 @@ static int get_pcie_bar(u32 *base, u32 *len) *base =0 ; *len =0 ; - pciexbar_reg =pci_read_config32 (dev,PCIEXBAR ); + pciexbar_reg =x86_pci_read_config32 (dev,PCIEXBAR );if (!(pciexbar_reg & (1 <<0 )))return 0 ;@@ -170,7 +170,7 @@ void northbridge_init(pci_dev_t dev)void northbridge_enable (pci_dev_t dev) {#if CONFIG_HAVE_ACPI_RESUME -switch (pci_read_config32 (dev,SKPAD )) { +switch (x86_pci_read_config32 (dev,SKPAD )) {case 0xcafebabe :debug ("Normal boot.\n" );apci_set_slp_type (0 );arch/x86/cpu/ivybridge/pch.c +2
-2@@ -21,7 +21,7 @@ int pch_silicon_revision(void) dev =PCH_LPC_DEV ;if (pch_revision_id <0 ) - pch_revision_id =pci_read_config8 (dev,PCI_REVISION_ID ); + pch_revision_id =x86_pci_read_config8 (dev,PCI_REVISION_ID );return pch_revision_id; }@@ -32,7 +32,7 @@ int pch_silicon_type(void) dev =PCH_LPC_DEV ;if (pch_type <0 ) - pch_type =pci_read_config8 (dev,PCI_DEVICE_ID +1 ); + pch_type =x86_pci_read_config8 (dev,PCI_DEVICE_ID +1 );return pch_type; }arch/x86/cpu/ivybridge/pci.c +2
-2@@ -70,9 +70,9 @@ int board_pci_pre_scan(struct pci_controller *hose) reg16 =0xff ; dev =PCH_DEV ; - reg16 =pci_read_config16 (dev,PCI_COMMAND ); + reg16 =x86_pci_read_config16 (dev,PCI_COMMAND ); reg16 |=PCI_COMMAND_SERR |PCI_COMMAND_MASTER |PCI_COMMAND_MEMORY ; -pci_write_config16 (dev,PCI_COMMAND , reg16); +x86_pci_write_config16 (dev,PCI_COMMAND , reg16);/* * Clear non-reserved bits in status register. arch/x86/cpu/ivybridge/report_platform.c +2
-2@@ -70,14 +70,14 @@ static void report_pch_info(void)u16 dev_id;uint8_t rev_id; - dev_id =pci_read_config16 (PCH_LPC_DEV ,2 ); + dev_id =x86_pci_read_config16 (PCH_LPC_DEV ,2 );for (i =0 ; i <ARRAY_SIZE (pch_table); i++) {if (pch_table[i].dev_id == dev_id) { pch_type = pch_table[i].dev_name;break ; } } - rev_id =pci_read_config8 (PCH_LPC_DEV ,8 ); + rev_id =x86_pci_read_config8 (PCH_LPC_DEV ,8 );debug ("PCH type: %s, device id: %x, rev id %x\n" , pch_type, dev_id, rev_id); }arch/x86/cpu/ivybridge/sata.c +31
-30@@ -14,14 +14,14 @@static inline u32 sir_read (pci_dev_t dev,int idx) { -pci_write_config32 (dev,SATA_SIRI , idx); -return pci_read_config32 (dev,SATA_SIRD ); +x86_pci_write_config32 (dev,SATA_SIRI , idx); +return x86_pci_read_config32 (dev,SATA_SIRD ); }static inline void sir_write (pci_dev_t dev,int idx,u32 value) { -pci_write_config32 (dev,SATA_SIRI , idx); -pci_write_config32 (dev,SATA_SIRD , value); +x86_pci_write_config32 (dev,SATA_SIRI , idx); +x86_pci_write_config32 (dev,SATA_SIRD , value); }static void common_sata_init (pci_dev_t dev,unsigned int port_map)@@ -31,17 +31,17 @@ static void common_sata_init(pci_dev_t dev, unsigned int port_map)/* Set IDE I/O Configuration */ reg32 =SIG_MODE_PRI_NORMAL |FAST_PCB1 |FAST_PCB0 |PCB1 |PCB0 ; -pci_write_config32 (dev,IDE_CONFIG , reg32); +x86_pci_write_config32 (dev,IDE_CONFIG , reg32);/* Port enable */ - reg16 =pci_read_config16 (dev,0x92 ); + reg16 =x86_pci_read_config16 (dev,0x92 ); reg16 &= ~0x3f ; reg16 |= port_map; -pci_write_config16 (dev,0x92 , reg16); +x86_pci_write_config16 (dev,0x92 , reg16);/* SATA Initialization register */ port_map &=0xff ; -pci_write_config32 (dev,0x94 , ((port_map ^0x3f ) <<24 ) |0x183 ); +x86_pci_write_config32 (dev,0x94 , ((port_map ^0x3f ) <<24 ) |0x183 ); }void bd82x6x_sata_init (pci_dev_t dev,const void *blob,int node)@@ -60,7 +60,7 @@ void bd82x6x_sata_init(pci_dev_t dev, const void *blob, int node) "sata_interface_speed_support", 0);/* Enable BARs */ -pci_write_config16 (dev,PCI_COMMAND ,0x0007 ); +x86_pci_write_config16 (dev,PCI_COMMAND ,0x0007 ); mode =fdt_getprop (blob, node,"intel,sata-mode" ,NULL );if (!mode || !strcmp (mode,"ahci" )) {@@ -69,18 +69,18 @@ void bd82x6x_sata_init(pci_dev_t dev, const void *blob, int node)debug ("SATA: Controller in AHCI mode\n" );/* Set Interrupt Line, Interrupt Pin is set by D31IP.PIP */ -pci_write_config8 (dev,INTR_LN ,0x0a ); +x86_pci_write_config8 (dev,INTR_LN ,0x0a );/* Set timings */ -pci_write_config16 (dev,IDE_TIM_PRI ,IDE_DECODE_ENABLE | +x86_pci_write_config16 (dev,IDE_TIM_PRI ,IDE_DECODE_ENABLE |IDE_ISP_3_CLOCKS |IDE_RCT_1_CLOCKS |IDE_PPE0 |IDE_IE0 |IDE_TIME0 ); -pci_write_config16 (dev,IDE_TIM_SEC ,IDE_DECODE_ENABLE | +x86_pci_write_config16 (dev,IDE_TIM_SEC ,IDE_DECODE_ENABLE |IDE_ISP_5_CLOCKS |IDE_RCT_4_CLOCKS );/* Sync DMA */ -pci_write_config16 (dev,IDE_SDMA_CNT ,IDE_PSDE0 ); -pci_write_config16 (dev,IDE_SDMA_TIM ,0x0001 ); +x86_pci_write_config16 (dev,IDE_SDMA_CNT ,IDE_PSDE0 ); +x86_pci_write_config16 (dev,IDE_SDMA_TIM ,0x0001 );common_sata_init (dev,0x8000 | port_map);@@ -115,22 +115,22 @@ void bd82x6x_sata_init(pci_dev_t dev, const void *blob, int node)/* No AHCI: clear AHCI base */ pci_write_bar32 (hose, dev,5 ,0x00000000 );/* And without AHCI BAR no memory decoding */ - reg16 =pci_read_config16 (dev,PCI_COMMAND ); + reg16 =x86_pci_read_config16 (dev,PCI_COMMAND ); reg16 &= ~PCI_COMMAND_MEMORY ; -pci_write_config16 (dev,PCI_COMMAND , reg16); +x86_pci_write_config16 (dev,PCI_COMMAND , reg16); -pci_write_config8 (dev,0x09 ,0x80 ); +x86_pci_write_config8 (dev,0x09 ,0x80 );/* Set timings */ -pci_write_config16 (dev,IDE_TIM_PRI ,IDE_DECODE_ENABLE | +x86_pci_write_config16 (dev,IDE_TIM_PRI ,IDE_DECODE_ENABLE |IDE_ISP_5_CLOCKS |IDE_RCT_4_CLOCKS ); -pci_write_config16 (dev,IDE_TIM_SEC ,IDE_DECODE_ENABLE | +x86_pci_write_config16 (dev,IDE_TIM_SEC ,IDE_DECODE_ENABLE |IDE_ISP_3_CLOCKS |IDE_RCT_1_CLOCKS |IDE_PPE0 |IDE_IE0 |IDE_TIME0 );/* Sync DMA */ -pci_write_config16 (dev,IDE_SDMA_CNT ,IDE_SSDE0 ); -pci_write_config16 (dev,IDE_SDMA_TIM ,0x0200 ); +x86_pci_write_config16 (dev,IDE_SDMA_CNT ,IDE_SSDE0 ); +x86_pci_write_config16 (dev,IDE_SDMA_TIM ,0x0200 );common_sata_init (dev, port_map); }else {@@ -140,31 +140,32 @@ void bd82x6x_sata_init(pci_dev_t dev, const void *blob, int node)pci_write_bar32 (hose, dev,5 ,0x00000000 );/* And without AHCI BAR no memory decoding */ - reg16 =pci_read_config16 (dev,PCI_COMMAND ); + reg16 =x86_pci_read_config16 (dev,PCI_COMMAND ); reg16 &= ~PCI_COMMAND_MEMORY ; -pci_write_config16 (dev,PCI_COMMAND , reg16); +x86_pci_write_config16 (dev,PCI_COMMAND , reg16);/* * Native mode capable on both primary and secondary (0xa) * OR'ed with enabled (0x50) = 0xf */ -pci_write_config8 (dev,0x09 ,0x8f ); +x86_pci_write_config8 (dev,0x09 ,0x8f );/* Set Interrupt Line */ /* Interrupt Pin is set by D31IP.PIP */ -pci_write_config8 (dev,INTR_LN ,0xff ); +x86_pci_write_config8 (dev,INTR_LN ,0xff );/* Set timings */ -pci_write_config16 (dev,IDE_TIM_PRI ,IDE_DECODE_ENABLE | +x86_pci_write_config16 (dev,IDE_TIM_PRI ,IDE_DECODE_ENABLE |IDE_ISP_3_CLOCKS |IDE_RCT_1_CLOCKS |IDE_PPE0 |IDE_IE0 |IDE_TIME0 ); -pci_write_config16 (dev,IDE_TIM_SEC ,IDE_DECODE_ENABLE | +x86_pci_write_config16 (dev,IDE_TIM_SEC ,IDE_DECODE_ENABLE |IDE_SITRE |IDE_ISP_3_CLOCKS |IDE_RCT_1_CLOCKS |IDE_IE0 |IDE_TIME0 );/* Sync DMA */ -pci_write_config16 (dev,IDE_SDMA_CNT ,IDE_SSDE0 |IDE_PSDE0 ); -pci_write_config16 (dev,IDE_SDMA_TIM ,0x0201 ); +x86_pci_write_config16 (dev,IDE_SDMA_CNT , +IDE_SSDE0 |IDE_PSDE0 ); +x86_pci_write_config16 (dev,IDE_SDMA_TIM ,0x0201 );common_sata_init (dev, port_map); }@@ -221,5 +222,5 @@ void bd82x6x_sata_enable(pci_dev_t dev, const void *blob, int node) port_map =fdtdec_get_int (blob, node,"intel,sata-port-map" ,0 ); map |= (port_map ^0x3f ) <<8 ; -pci_write_config16 (dev,0x90 , map); +x86_pci_write_config16 (dev,0x90 , map); }arch/x86/cpu/ivybridge/sdram.c +10
-10@@ -444,7 +444,7 @@ int sdram_initialise(struct pei_data *pei_data)* Send ME init done for SandyBridge here. This is done inside the * SystemAgent binary on IvyBridge */ - done =pci_read_config32 (PCH_DEV ,PCI_DEVICE_ID ); + done =x86_pci_read_config32 (PCH_DEV ,PCI_DEVICE_ID ); done &=BASE_REV_MASK ;if (BASE_REV_SNB == done)intel_early_me_init_done (ME_INIT_STATUS_SUCCESS );@@ -615,24 +615,24 @@ static int sdram_find(pci_dev_t dev)*/ /* Top of Upper Usable DRAM, including remap */ - touud =pci_read_config32 (dev,TOUUD +4 ); + touud =x86_pci_read_config32 (dev,TOUUD +4 ); touud <<=32 ; - touud |=pci_read_config32 (dev,TOUUD ); + touud |=x86_pci_read_config32 (dev,TOUUD );/* Top of Lower Usable DRAM */ - tolud =pci_read_config32 (dev,TOLUD ); + tolud =x86_pci_read_config32 (dev,TOLUD );/* Top of Memory - does not account for any UMA */ - tom =pci_read_config32 (dev,0xa4 ); + tom =x86_pci_read_config32 (dev,0xa4 ); tom <<=32 ; - tom |=pci_read_config32 (dev,0xa0 ); + tom |=x86_pci_read_config32 (dev,0xa0 );debug ("TOUUD %llx TOLUD %08x TOM %llx\n" , touud, tolud, tom);/* ME UMA needs excluding if total memory <4GB */ - me_base =pci_read_config32 (dev,0x74 ); + me_base =x86_pci_read_config32 (dev,0x74 ); me_base <<=32 ; - me_base |=pci_read_config32 (dev,0x70 ); + me_base |=x86_pci_read_config32 (dev,0x70 );debug ("MEBASE %llx\n" , me_base);@@ -650,7 +650,7 @@ static int sdram_find(pci_dev_t dev) }/* Graphics memory comes next */ - ggc =pci_read_config16 (dev,GGC ); + ggc =x86_pci_read_config16 (dev,GGC );if (!(ggc &2 )) {debug ("IGD decoded, subtracting " );@@ -670,7 +670,7 @@ static int sdram_find(pci_dev_t dev) }/* Calculate TSEG size from its base which must be below GTT */ - tseg_base =pci_read_config32 (dev,0xb8 ); + tseg_base =x86_pci_read_config32 (dev,0xb8 ); uma_size = (uma_memory_base - tseg_base) >>10 ; tomk -= uma_size; uma_memory_base = tomk *1024ULL ;arch/x86/cpu/ivybridge/usb_ehci.c +2
-2@@ -20,10 +20,10 @@ void bd82x6x_usb_ehci_init(pci_dev_t dev)writel (reg32,RCB_REG (0x35b0 ));debug ("EHCI: Setting up controller.. " ); - reg32 =pci_read_config32 (dev,PCI_COMMAND ); + reg32 =x86_pci_read_config32 (dev,PCI_COMMAND ); reg32 |=PCI_COMMAND_MASTER ;/* reg32 |= PCI_COMMAND_SERR; */ -pci_write_config32 (dev,PCI_COMMAND , reg32); +x86_pci_write_config32 (dev,PCI_COMMAND , reg32);debug ("done.\n" ); }arch/x86/cpu/ivybridge/usb_xhci.c +4
-4@@ -16,17 +16,17 @@ void bd82x6x_usb_xhci_init(pci_dev_t dev)debug ("XHCI: Setting up controller.. " );/* lock overcurrent map */ - reg32 =pci_read_config32 (dev,0x44 ); + reg32 =x86_pci_read_config32 (dev,0x44 ); reg32 |=1 ; -pci_write_config32 (dev,0x44 , reg32); +x86_pci_write_config32 (dev,0x44 , reg32);/* Enable clock gating */ - reg32 =pci_read_config32 (dev,0x40 ); + reg32 =x86_pci_read_config32 (dev,0x40 ); reg32 &= ~((1 <<20 ) | (1 <<21 )); reg32 |= (1 <<19 ) | (1 <<18 ) | (1 <<17 ); reg32 |= (1 <<10 ) | (1 <<9 ) | (1 <<8 ); reg32 |= (1 <<31 );/* lock */ -pci_write_config32 (dev,0x40 , reg32); +x86_pci_write_config32 (dev,0x40 , reg32);debug ("done.\n" ); }arch/x86/cpu/pci.c +6
-6@@ -70,7 +70,7 @@ static struct pci_controller *get_hose(void)return pci_bus_to_hose (0 ); } -unsigned int pci_read_config8 (pci_dev_t dev,unsigned where) +unsigned int x86_pci_read_config8 (pci_dev_t dev,unsigned where) {uint8_t value;@@ -79,7 +79,7 @@ unsigned int pci_read_config8(pci_dev_t dev, unsigned where)return value; } -unsigned int pci_read_config16 (pci_dev_t dev,unsigned where) +unsigned int x86_pci_read_config16 (pci_dev_t dev,unsigned where) {uint16_t value;@@ -88,7 +88,7 @@ unsigned int pci_read_config16(pci_dev_t dev, unsigned where)return value; } -unsigned int pci_read_config32 (pci_dev_t dev,unsigned where) +unsigned int x86_pci_read_config32 (pci_dev_t dev,unsigned where) {uint32_t value;@@ -97,17 +97,17 @@ unsigned int pci_read_config32(pci_dev_t dev, unsigned where)return value; } -void pci_write_config8 (pci_dev_t dev,unsigned where,unsigned value) +void x86_pci_write_config8 (pci_dev_t dev,unsigned where,unsigned value) {pci_hose_write_config_byte (get_hose (), dev, where, value); } -void pci_write_config16 (pci_dev_t dev,unsigned where,unsigned value) +void x86_pci_write_config16 (pci_dev_t dev,unsigned where,unsigned value) {pci_hose_write_config_word (get_hose (), dev, where, value); } -void pci_write_config32 (pci_dev_t dev,unsigned where,unsigned value) +void x86_pci_write_config32 (pci_dev_t dev,unsigned where,unsigned value) {pci_hose_write_config_dword (get_hose (), dev, where, value); }arch/x86/cpu/quark/quark.c +2
-2@@ -28,9 +28,9 @@ static void unprotect_spi_flash(void) {u32 bc; - bc =pci_read_config32 (QUARK_LEGACY_BRIDGE ,0xd8 ); + bc =x86_pci_read_config32 (QUARK_LEGACY_BRIDGE ,0xd8 ); bc |=0x1 ;/* unprotect the flash */ -pci_write_config32 (QUARK_LEGACY_BRIDGE ,0xd8 , bc); +x86_pci_write_config32 (QUARK_LEGACY_BRIDGE ,0xd8 , bc); }static void quark_setup_bars (void )arch/x86/cpu/queensbay/tnc.c +2
-2@@ -16,9 +16,9 @@ static void unprotect_spi_flash(void) {u32 bc; - bc =pci_read_config32 (PCH_LPC_DEV ,0xd8 ); + bc =x86_pci_read_config32 (PCH_LPC_DEV ,0xd8 ); bc |=0x1 ;/* unprotect the flash */ -pci_write_config32 (PCH_LPC_DEV ,0xd8 , bc); +x86_pci_write_config32 (PCH_LPC_DEV ,0xd8 , bc); }int arch_cpu_init (void )arch/x86/include/asm/pci.h +6
-6@@ -48,13 +48,13 @@ int board_pci_post_scan(struct pci_controller *hose);* Simple PCI access routines - these work from either the early PCI hose * or the 'real' one, created after U-Boot has memory available */ -unsigned int pci_read_config8 (pci_dev_t dev,unsigned where); -unsigned int pci_read_config16 (pci_dev_t dev,unsigned where); -unsigned int pci_read_config32 (pci_dev_t dev,unsigned where); +unsigned int x86_pci_read_config8 (pci_dev_t dev,unsigned where); +unsigned int x86_pci_read_config16 (pci_dev_t dev,unsigned where); +unsigned int x86_pci_read_config32 (pci_dev_t dev,unsigned where); -void pci_write_config8 (pci_dev_t dev,unsigned where,unsigned value); -void pci_write_config16 (pci_dev_t dev,unsigned where,unsigned value); -void pci_write_config32 (pci_dev_t dev,unsigned where,unsigned value); +void x86_pci_write_config8 (pci_dev_t dev,unsigned where,unsigned value); +void x86_pci_write_config16 (pci_dev_t dev,unsigned where,unsigned value); +void x86_pci_write_config32 (pci_dev_t dev,unsigned where,unsigned value);#endif /* __ASSEMBLY__ */ arch/x86/lib/bios_interrupts.c +6
-6@@ -172,28 +172,28 @@ int int1a_handler(void) }switch (func) {case 0xb108 :/* Read Config Byte */ - byte =pci_read_config8 (dev, reg); + byte =x86_pci_read_config8 (dev, reg);M .x86.R_ECX = byte;break ;case 0xb109 :/* Read Config Word */ - word =pci_read_config16 (dev, reg); + word =x86_pci_read_config16 (dev, reg);M .x86.R_ECX = word;break ;case 0xb10a :/* Read Config Dword */ - dword =pci_read_config32 (dev, reg); + dword =x86_pci_read_config32 (dev, reg);M .x86.R_ECX = dword;break ;case 0xb10b :/* Write Config Byte */ byte =M .x86.R_ECX; -pci_write_config8 (dev, reg, byte); +x86_pci_write_config8 (dev, reg, byte);break ;case 0xb10c :/* Write Config Word */ word =M .x86.R_ECX; -pci_write_config16 (dev, reg, word); +x86_pci_write_config16 (dev, reg, word);break ;case 0xb10d :/* Write Config Dword */ dword =M .x86.R_ECX; -pci_write_config32 (dev, reg, dword); +x86_pci_write_config32 (dev, reg, dword);break ; }drivers/gpio/intel_ich6_gpio.c +7
-7@@ -64,13 +64,13 @@ static int gpio_ich6_ofdata_to_platdata(struct udevice *dev) pci_dev =PCI_BDF (0 ,0x1f ,0 );/* Is the device present? */ - tmpword =pci_read_config16 (pci_dev,PCI_VENDOR_ID ); + tmpword =x86_pci_read_config16 (pci_dev,PCI_VENDOR_ID );if (tmpword !=PCI_VENDOR_ID_INTEL ) {debug ("%s: wrong VendorID\n" , __func__);return -ENODEV ; } - tmpword =pci_read_config16 (pci_dev,PCI_DEVICE_ID ); + tmpword =x86_pci_read_config16 (pci_dev,PCI_DEVICE_ID );debug ("Found %04x:%04x\n" ,PCI_VENDOR_ID_INTEL , tmpword);/* * We'd like to validate the Device ID too, but pretty much any @@ -80,34 +80,34 @@ static int gpio_ich6_ofdata_to_platdata(struct udevice *dev)*/ /* I/O should already be enabled (it's a RO bit). */ - tmpword =pci_read_config16 (pci_dev,PCI_COMMAND ); + tmpword =x86_pci_read_config16 (pci_dev,PCI_COMMAND );if (!(tmpword &PCI_COMMAND_IO )) {debug ("%s: device IO not enabled\n" , __func__);return -ENODEV ; }/* Header Type must be normal (bits 6-0 only; see spec.) */ - tmpbyte =pci_read_config8 (pci_dev,PCI_HEADER_TYPE ); + tmpbyte =x86_pci_read_config8 (pci_dev,PCI_HEADER_TYPE );if ((tmpbyte &0x7f ) !=PCI_HEADER_TYPE_NORMAL ) {debug ("%s: invalid Header type\n" , __func__);return -ENODEV ; }/* Base Class must be a bridge device */ - tmpbyte =pci_read_config8 (pci_dev,PCI_CLASS_CODE ); + tmpbyte =x86_pci_read_config8 (pci_dev,PCI_CLASS_CODE );if (tmpbyte !=PCI_CLASS_CODE_BRIDGE ) {debug ("%s: invalid class\n" , __func__);return -ENODEV ; }/* Sub Class must be ISA */ - tmpbyte =pci_read_config8 (pci_dev,PCI_CLASS_SUB_CODE ); + tmpbyte =x86_pci_read_config8 (pci_dev,PCI_CLASS_SUB_CODE );if (tmpbyte !=PCI_CLASS_SUB_CODE_BRIDGE_ISA ) {debug ("%s: invalid subclass\n" , __func__);return -ENODEV ; }/* Programming Interface must be 0x00 (no others exist) */ - tmpbyte =pci_read_config8 (pci_dev,PCI_CLASS_PROG ); + tmpbyte =x86_pci_read_config8 (pci_dev,PCI_CLASS_PROG );if (tmpbyte !=0x00 ) {debug ("%s: invalid interface type\n" , __func__);return -ENODEV ;
drivers/gpio/intel_ich6_gpio.c static int gpio_ich6_ofdata_to_platdata(struct udevice *dev)
Quoted 9 lines
drivers/gpio/intel_ich6_gpio.c +1
-2@@ -123,7 +123,7 @@ static int gpio_ich6_ofdata_to_platdata(struct udevice *dev)* while on the Ivybridge the bit0 is used to indicate it is an * I/O space. */ - tmplong =pci_read_config32 (pci_dev,PCI_CFG_GPIOBASE ); + tmplong =x86_pci_read_config32 (pci_dev,PCI_CFG_GPIOBASE );if (tmplong ==0x00000000 || tmplong ==0xffffffff ) {debug ("%s: unexpected GPIOBASE value\n" , __func__);return -ENODEV ; --
PATCH 5/22 RFC: x86: Split up arch_cpu_init()
In reply to Simon GlassAt present we do more in this function than we should. Create a new x86_post_cpu_init() which can be called from the board file when needed (e.g. in board_early_init_f(). This allows us to use driver model for our x86_post_cpu_init() function.
It is likely that some future refactoring will improve this and reduce the number of steps, using driver model's probing features.
Note: this needs more discussion - e.g. I believe it breaks other x86 boards. We may want to plumb this in differently (e.g. promote x86_post_cpu_init() to the board_init_f() boot sequence).
---
arch/x86/cpu/ivybridge/cpu.c | 8 ++++++++ arch/x86/include/asm/u-boot-x86.h | 1 + board/google/chromebook_link/link.c | 6 ++++++ 3 files changed, 15 insertions(+)
arch/x86/cpu/ivybridge/cpu.c +8 -0
@@ -116,6 +116,14 @@ static void set_spi_speed(void)int arch_cpu_init (void ) { +post_code (POST_CPU_INIT ); +timer_set_base (rdtsc ()); + +return x86_cpu_init_f (); +} + +int x86_post_cpu_init (void ) +{const void *blob = gd->fdt_blob;struct pci_controller *hose;int node;
arch/x86/include/asm/u-boot-x86.h +1 -0
@@ -38,6 +38,7 @@ void reset_cpu(ulong addr);ulong board_get_usable_ram_top (ulong total_size);void dram_init_banksize (void );int default_print_cpuinfo (void ); +int x86_post_cpu_init (void );/* Set up a UART which can be used with printch(), printhex8(), etc. */ int setup_early_uart (void );
board/google/chromebook_link/link.c +6 -0
@@ -120,6 +120,12 @@ static const struct pch_gpio_map link_gpio_map = {int board_early_init_f (void ) { +int ret; + + ret =x86_post_cpu_init (); +if (ret) +return ret; +ich_gpio_set_gpio_map (&link_gpio_map);return 0 ;
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 5/22 RFC: x86: Split up arch_cpu_init()
Hi Simon,
Quoted 11 lines · Simon Glass
At present we do more in this function than we should. Create a new
x86_post_cpu_init()which can be called from the board file when needed (e.g. inboard_early_init_f(). This allows us to use driver model for ourx86_post_cpu_init()function.It is likely that some future refactoring will improve this and reduce the number of steps, using driver model's probing features.
Note: this needs more discussion - e.g. I believe it breaks other x86 boards. We may want to plumb this in differently (e.g. promote
x86_post_cpu_init()to theboard_init_f()boot sequence).
Or maybe change the order in board_f.c so that arch_cpu_init() comes after init_dm()?
Quoted 47 lines
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/ivybridge/cpu.c | 8 ++++++++ arch/x86/include/asm/u-boot-x86.h | 1 + board/google/chromebook_link/link.c | 6 ++++++ 3 files changed, 15 insertions(+)arch/x86/cpu/ivybridge/cpu.c +8
-0@@ -116,6 +116,14 @@ static void set_spi_speed(void)int arch_cpu_init (void ) { +post_code (POST_CPU_INIT ); +timer_set_base (rdtsc ()); + +return x86_cpu_init_f (); +} + +int x86_post_cpu_init (void ) +{const void *blob = gd->fdt_blob;struct pci_controller *hose;int node;arch/x86/include/asm/u-boot-x86.h +1
-0@@ -38,6 +38,7 @@ void reset_cpu(ulong addr);ulong board_get_usable_ram_top (ulong total_size);void dram_init_banksize (void );int default_print_cpuinfo (void ); +int x86_post_cpu_init (void );/* Set up a UART which can be used with printch(), printhex8(), etc. */ int setup_early_uart (void );board/google/chromebook_link/link.c +0
-0@@ -120,6 +120,12 @@ static const struct pch_gpio_map link_gpio_map = {int board_early_init_f (void ) {
board/google/chromebook_link/link.c static const struct pch_gpio_map link_gpio_map = {
Quoted 10 lines
board/google/chromebook_link/link.c +6
-1+int ret; + + ret =x86_post_cpu_init (); +if (ret) +return ret; +ich_gpio_set_gpio_map (&link_gpio_map);return 0 ; --
Regards,
Bin
PATCH 5/22 RFC: x86: Split up arch_cpu_init()
Hi Bin,
Quoted 11 lines · Bin Meng
Hi Simon,
Quoted 8 lines · Simon Glass
At present we do more in this function than we should. Create a new
x86_post_cpu_init()which can be called from the board file when needed (e.g. inboard_early_init_f(). This allows us to use driver model for ourx86_post_cpu_init()function.It is likely that some future refactoring will improve this and reduce the number of steps, using driver model's probing features.
Quoted 6 lines
Quoted 3 lines
Note: this needs more discussion - e.g. I believe it breaks other x86 boards. We may want to plumb this in differently (e.g. promote
x86_post_cpu_init()to theboard_init_f()boot sequence).Or maybe change the order in
board_f.cso thatarch_cpu_init()comes afterinit_dm()?
I feel that arch_cpu_init() should be for very early things, the absolute minimum to allow the machine to function and driver model to be set up. Clearly x86 does not conform to that now!
But I think there are a few things that fit in this category so having the separated seems better.
Quoted 56 lines
Quoted 56 lines
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/ivybridge/cpu.c | 8 ++++++++ arch/x86/include/asm/u-boot-x86.h | 1 + board/google/chromebook_link/link.c | 6 ++++++ 3 files changed, 15 insertions(+)arch/x86/cpu/ivybridge/cpu.c +8
-0@@ -116,6 +116,14 @@ static void set_spi_speed(void)int arch_cpu_init (void ) { +post_code (POST_CPU_INIT ); +timer_set_base (rdtsc ()); + +return x86_cpu_init_f (); +} + +int x86_post_cpu_init (void ) +{const void *blob = gd->fdt_blob;struct pci_controller *hose;int node;arch/x86/include/asm/u-boot-x86.h +1
-0@@ -38,6 +38,7 @@ void reset_cpu(ulong addr);ulong board_get_usable_ram_top (ulong total_size);void dram_init_banksize (void );int default_print_cpuinfo (void ); +int x86_post_cpu_init (void );/* Set up a UART which can be used with printch(), printhex8(), etc. */ int setup_early_uart (void );board/google/chromebook_link/link.c +6
-0@@ -120,6 +120,12 @@ static const struct pch_gpio_map link_gpio_map = {int board_early_init_f (void ) { +int ret; + + ret =x86_post_cpu_init (); +if (ret) +return ret; +ich_gpio_set_gpio_map (&link_gpio_map);
Quoted 5 lines
board/google/chromebook_link/link.c static const struct pch_gpio_map link_gpio_map = {
Quoted 2 lines
board/google/chromebook_link/link.c +0
-1return 0 ; --Regards,
Bin
Regards,
Simon
PATCH 5/22 RFC: x86: Split up arch_cpu_init()
Hi Simon,
Quoted 21 lines · Simon Glass
Hi Bin,
Quoted 11 lines · Bin Meng
Hi Simon,
Quoted 8 lines · Simon Glass
At present we do more in this function than we should. Create a new
x86_post_cpu_init()which can be called from the board file when needed (e.g. inboard_early_init_f(). This allows us to use driver model for ourx86_post_cpu_init()function.It is likely that some future refactoring will improve this and reduce the number of steps, using driver model's probing features.
Quoted 6 lines
Quoted 3 lines
Note: this needs more discussion - e.g. I believe it breaks other x86 boards. We may want to plumb this in differently (e.g. promote
x86_post_cpu_init()to theboard_init_f()boot sequence).Or maybe change the order in
board_f.cso thatarch_cpu_init()comes afterinit_dm()?
Quoted 6 lines
I feel that
arch_cpu_init()should be for very early things, the absolute minimum to allow the machine to function and driver model to be set up. Clearly x86 does not conform to that now!But I think there are a few things that fit in this category so having the separated seems better.
OK, I would prefer we explicitly put the post_cpu_init() into board_f.c initialization sequence. This isn't x86-specific. Any architecture which uses DM and generic board (starting from v2015.04 release) will benefit from this.
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/ivybridge/cpu.c | 8 ++++++++ arch/x86/include/asm/u-boot-x86.h | 1 + board/google/chromebook_link/link.c | 6 ++++++ 3 files changed, 15 insertions(+)arch/x86/cpu/ivybridge/cpu.c +8
-0@@ -116,6 +116,14 @@ static void set_spi_speed(void)int arch_cpu_init (void ) { +post_code (POST_CPU_INIT ); +timer_set_base (rdtsc ()); + +return x86_cpu_init_f (); +} + +int x86_post_cpu_init (void ) +{const void *blob = gd->fdt_blob;struct pci_controller *hose;int node;arch/x86/include/asm/u-boot-x86.h +1
-0@@ -38,6 +38,7 @@ void reset_cpu(ulong addr);ulong board_get_usable_ram_top (ulong total_size);void dram_init_banksize (void );int default_print_cpuinfo (void ); +int x86_post_cpu_init (void );/* Set up a UART which can be used with printch(), printhex8(), etc. */ int setup_early_uart (void );board/google/chromebook_link/link.c +6
-0@@ -120,6 +120,12 @@ static const struct pch_gpio_map link_gpio_map = {int board_early_init_f (void ) { +int ret; + + ret =x86_post_cpu_init (); +if (ret) +return ret; +ich_gpio_set_gpio_map (&link_gpio_map);
Quoted 3 lines
Quoted 3 lines
board/google/chromebook_link/link.c static const struct pch_gpio_map link_gpio_map = {
Quoted 2 lines
board/google/chromebook_link/link.c +0
-1return 0 ; --
Regards,
Bin
PATCH 5/22 RFC: x86: Split up arch_cpu_init()
Hi Bin,
Quoted 28 lines · Bin Meng
Hi Simon,
Quoted 25 lines · Simon Glass
Hi Bin,
Quoted 11 lines · Bin Meng
Hi Simon,
Quoted 8 lines · Simon Glass
At present we do more in this function than we should. Create a new
x86_post_cpu_init()which can be called from the board file when needed (e.g. inboard_early_init_f(). This allows us to use driver model for ourx86_post_cpu_init()function.It is likely that some future refactoring will improve this and reduce the number of steps, using driver model's probing features.
Quoted 6 lines
Quoted 3 lines
Note: this needs more discussion - e.g. I believe it breaks other x86 boards. We may want to plumb this in differently (e.g. promote
x86_post_cpu_init()to theboard_init_f()boot sequence).Or maybe change the order in
board_f.cso thatarch_cpu_init()comes afterinit_dm()?I feel that
arch_cpu_init()should be for very early things, the absolute minimum to allow the machine to function and driver model to be set up. Clearly x86 does not conform to that now!
Quoted 7 lines
Quoted 2 lines
But I think there are a few things that fit in this category so having the separated seems better.
OK, I would prefer we explicitly put the
post_cpu_init()intoboard_f.cinitialization sequence. This isn't x86-specific. Any architecture which uses DM and generic board (starting from v2015.04 release) will benefit from this.
Yes I'll do this, sounds like a good idea.
Regards,
Simon
PATCH 6/22 Correct map_sysmem() logic in do_mem_mw()
In reply to Simon GlassThis function does not unmap what it maps. Correct it.
---
common/cmd_mem.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
common/cmd_mem.c +4 -3
@@ -165,7 +165,7 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])#endif ulong addr, count;int size; -void *buf; +void *buf, *start;ulong bytes;if ((argc <3 ) || (argc >4 ))
@@ -197,7 +197,8 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } bytes = size * count; - buf =map_sysmem (addr, bytes); + start =map_sysmem (addr, bytes); + buf = start;while (count-- >0 ) {if (size ==4 ) *((u32 *)buf) = (u32 )writeval;
@@ -211,7 +212,7 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) *((u8 *)buf) = (u8 )writeval; buf += size; } -unmap_sysmem (buf); +unmap_sysmem (start);return 0 ; }
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 7/22 fdt: Tighten up error handling in fdtdec_get_pci_addr()
In reply to Simon GlassThis function returns -ENOENT when the property is missing (which the caller might forgive) and also when the property is present but incorrectly formatted (which many callers would like to report).
Update the error return value to allow these different situations to be distinguished.
---
include/fdtdec.h | 4 +++- lib/fdtdec.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)
include/fdtdec.h +3 -1
@@ -326,7 +326,9 @@ fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,* @param type pci address type (FDT_PCI_SPACE_xxx) * @param prop_name name of property to find * @param addr returns pci address in the form of fdt_pci_addr -* @return 0 if ok, negative on error +* @return 0 if ok, -ENOENT if the property did not exist, -EINVAL if the +* format of the property was invalid, -ENXIO if the requested +* address type was not found */ int fdtdec_get_pci_addr (const void *blob,int node,enum fdt_pci_space type,const char *prop_name,struct fdt_pci_addr *addr);
lib/fdtdec.c +3 -1
@@ -159,8 +159,10 @@ int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type, } } -if (i == num) +if (i == num) { + ret =ENXIO ; goto fail; + }return 0 ; }else {
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 7/22 fdt: Tighten up error handling in fdtdec_get_pci_addr()
Hi Simon,
Quoted 2 lines · Simon Glass
This function returns
-ENOENTwhen the property is missing (which the caller might forgive) and also when the property is present but incorrectly
forgive? forget?
Quoted 32 lines
formatted (which many callers would like to report).
Update the error return value to allow these different situations to be distinguished.
Signed-off-by Simon Glass <[email protected]>---
include/fdtdec.h | 4 +++- lib/fdtdec.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)include/fdtdec.h +3
-1@@ -326,7 +326,9 @@ fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,* @param type pci address type (FDT_PCI_SPACE_xxx) * @param prop_name name of property to find * @param addr returns pci address in the form of fdt_pci_addr -* @return 0 if ok, negative on error +* @return 0 if ok, -ENOENT if the property did not exist, -EINVAL if the +* format of the property was invalid, -ENXIO if the requested +* address type was not found */ int fdtdec_get_pci_addr (const void *blob,int node,enum fdt_pci_space type,const char *prop_name,struct fdt_pci_addr *addr);lib/fdtdec.c +0
-0
lib/fdtdec.c int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type, · line 163
Quoted 6 lines
lib/fdtdec.c +2
-1@@ -159,8 +159,10 @@ int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type, } } -if (i == num) +if (i == num) { + ret =ENXIO ;
ret = -ENXIO;
lib/fdtdec.c int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type,
Quoted 6 lines
lib/fdtdec.c +1
-1goto fail; + }return 0 ; }else { --
Regards,
Bin
PATCH 7/22 fdt: Tighten up error handling in fdtdec_get_pci_addr()
Hi Bin,
Quoted 8 lines · Bin Meng
Hi Simon,
Quoted 2 lines · Simon Glass
This function returns
-ENOENTwhen the property is missing (which the caller might forgive) and also when the property is present but incorrectlyforgive? forget?
In this case I mean forgive. The caller probably doesn't care that the property is missing since it means that no PCI address is provided. This is often OK and should be forgiven. The other case is often an error.
Quoted 35 lines
Quoted 35 lines
formatted (which many callers would like to report).
Update the error return value to allow these different situations to be distinguished.
Signed-off-by Simon Glass <[email protected]>---
include/fdtdec.h | 4 +++- lib/fdtdec.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)include/fdtdec.h +3
-1@@ -326,7 +326,9 @@ fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,* @param type pci address type (FDT_PCI_SPACE_xxx) * @param prop_name name of property to find * @param addr returns pci address in the form of fdt_pci_addr -* @return 0 if ok, negative on error +* @return 0 if ok, -ENOENT if the property did not exist, -EINVAL if the +* format of the property was invalid, -ENXIO if the requested +* address type was not found */ int fdtdec_get_pci_addr (const void *blob,int node,enum fdt_pci_space type,const char *prop_name,struct fdt_pci_addr *addr);lib/fdtdec.c +0
-0@@ -159,8 +159,10 @@ int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type, } }
Quoted 6 lines
lib/fdtdec.c int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type, · line 163
Quoted 3 lines
lib/fdtdec.c +2
-1-if (i == num) +if (i == num) { + ret =ENXIO ;ret =
-ENXIO;
Fixed, thanks.
Quoted 9 lines
lib/fdtdec.c int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type,
Quoted 6 lines
lib/fdtdec.c +1
-1goto fail; + }return 0 ; }else { --Regards,
Bin
Regards,
Simon
PATCH 8/22 dm: core: Add dev_get_uclass_priv() to access uclass private data
In reply to Simon GlassAdd a convenience function to access the private data that a uclass stores for each of its devices. Convert over most existing uses for consistency and to provide an example for others.
---
common/cmd_sf.c | 2 +- common/cros_ec.c | 2 +- drivers/core/device.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 | 2 +- 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/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/mtd/spi/sf-uclass.c | 2 +- drivers/mtd/spi/sf_probe.c | 8 ++++---- drivers/serial/serial-uclass.c | 4 ++-- drivers/spi/spi-uclass.c | 4 ++-- include/dm/device.h | 10 ++++++++++ include/i2c.h | 8 ++++---- test/dm/core.c | 2 +- test/dm/test-uclass.c | 4 ++-- 27 files changed, 71 insertions(+), 51 deletions(-)
common/cmd_sf.c +1 -1
@@ -130,7 +130,7 @@ static int do_spi_flash_probe(int argc, char * const argv[]) return 1; } - flash = new->uclass_priv; + flash =dev_get_uclass_priv (new);#else new =spi_flash_probe (bus, cs, speed, mode);if (!new) {
common/cros_ec.c +1 -1
@@ -35,7 +35,7 @@ struct cros_ec_dev *board_get_cros_ec_dev(void)debug ("%s: Error %d\n" , __func__, ret); return NULL; } -return dev->uclass_priv; +return dev_get_uclass_priv (dev);#else return local.cros_ec_dev;#endif
drivers/core/device.c +10 -0
@@ -305,6 +305,16 @@ void *dev_get_priv(struct udevice *dev)return dev->priv; } +void *dev_get_uclass_priv (struct udevice *dev) +{ +if (!dev) { +dm_warn ("%s: null device\n" , __func__); +return NULL ; + } + +return dev->uclass_priv; +} +void *dev_get_parentdata (struct udevice *dev) {if (!dev) {
drivers/gpio/at91_gpio.c +1 -1
@@ -511,7 +511,7 @@ static int at91_gpio_probe(struct udevice *dev) {struct at91_port_priv *port =dev_get_priv (dev);struct at91_port_platdata *plat =dev_get_platdata (dev); -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev); uc_priv->bank_name = plat->bank_name; uc_priv->gpio_count =GPIO_PER_BANK ;
drivers/gpio/bcm2835_gpio.c +1 -1
@@ -105,7 +105,7 @@ static int bcm2835_gpio_probe(struct udevice *dev) {struct bcm2835_gpios *gpios =dev_get_priv (dev);struct bcm2835_gpio_platdata *plat =dev_get_platdata (dev); -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev); uc_priv->bank_name ="GPIO" ; uc_priv->gpio_count =BCM2835_GPIO_COUNT ;
drivers/gpio/gpio-uclass.c +11 -11
@@ -34,7 +34,7 @@ static int gpio_to_device(unsigned int gpio, struct gpio_desc *desc)for (ret =uclass_first_device (UCLASS_GPIO , &dev); dev; ret =uclass_next_device (&dev)) { - uc_priv = dev->uclass_priv; + uc_priv =dev_get_uclass_priv (dev);if (gpio >= uc_priv->gpio_base && gpio < uc_priv->gpio_base + uc_priv->gpio_count) { desc->dev = dev;
@@ -65,7 +65,7 @@ int gpio_lookup_name(const char *name, struct udevice **devp, ret = uclass_next_device(&dev)) {int len; - uc_priv = dev->uclass_priv; + uc_priv =dev_get_uclass_priv (dev);if (numeric !=-1 ) { offset = numeric - uc_priv->gpio_base;/* Allow GPIOs to be numbered from 0 */
@@ -116,7 +116,7 @@ static int dm_gpio_request(struct gpio_desc *desc, const char *label)char *str;int ret; - uc_priv = dev->uclass_priv; + uc_priv =dev_get_uclass_priv (dev);if (uc_priv->name[desc->offset])return -EBUSY ; str =strdup (label);
@@ -195,7 +195,7 @@ int _dm_gpio_free(struct udevice *dev, uint offset)struct gpio_dev_priv *uc_priv;int ret; - uc_priv = dev->uclass_priv; + uc_priv =dev_get_uclass_priv (dev);if (!uc_priv->name[offset])return -ENXIO ;if (gpio_get_ops (dev)->free) {
@@ -232,7 +232,7 @@ int gpio_free(unsigned gpio)static int check_reserved (struct gpio_desc *desc,const char *func) { -struct gpio_dev_priv *uc_priv = desc->dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (desc->dev);if (!uc_priv->name[desc->offset]) { printf("%s: %s: error: gpio %s%d not reserved\n",
@@ -402,7 +402,7 @@ const char *gpio_get_bank_info(struct udevice *dev, int *bit_count)struct gpio_dev_priv *priv;/* Must be called on an active device */ - priv = dev->uclass_priv; + priv =dev_get_uclass_priv (dev);assert (priv); *bit_count = priv->gpio_count;
@@ -420,7 +420,7 @@ static const char * const gpio_function[GPIOF_COUNT] = {int get_function (struct udevice *dev,int offset,bool skip_unused,const char **namep) { -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);struct dm_gpio_ops *ops =gpio_get_ops (dev);BUILD_BUG_ON (GPIOF_COUNT !=ARRAY_SIZE (gpio_function));
@@ -468,7 +468,7 @@ int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize)BUILD_BUG_ON (GPIOF_COUNT !=ARRAY_SIZE (gpio_function)); *buf =0 ; - priv = dev->uclass_priv; + priv =dev_get_uclass_priv (dev); ret =gpio_get_raw_function (dev, offset,NULL );if (ret <0 )return ret;
@@ -680,7 +680,7 @@ static int gpio_renumber(struct udevice *removed_dev) base =0 ; uclass_foreach_dev(dev, uc) {if (device_active (dev) && dev != removed_dev) { - uc_priv = dev->uclass_priv; + uc_priv =dev_get_uclass_priv (dev); uc_priv->gpio_base = base; base += uc_priv->gpio_count; }
@@ -691,7 +691,7 @@ static int gpio_renumber(struct udevice *removed_dev)static int gpio_post_probe (struct udevice *dev) { -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev); uc_priv->name =calloc (uc_priv->gpio_count,sizeof (char *));if (!uc_priv->name)
@@ -702,7 +702,7 @@ static int gpio_post_probe(struct udevice *dev)static int gpio_pre_remove (struct udevice *dev) { -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);int i;for (i =0 ; i < uc_priv->gpio_count; i++) {
drivers/gpio/intel_ich6_gpio.c +1 -1
@@ -151,7 +151,7 @@ static int gpio_ich6_ofdata_to_platdata(struct udevice *dev)static int ich6_gpio_probe (struct udevice *dev) {struct ich6_bank_platdata *plat =dev_get_platdata (dev); -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);struct ich6_bank_priv *bank =dev_get_priv (dev);if (gd->arch.gpio_map) {
drivers/gpio/mxc_gpio.c +1 -1
@@ -266,7 +266,7 @@ static int mxc_gpio_probe(struct udevice *dev) {struct mxc_bank_info *bank =dev_get_priv (dev);struct mxc_gpio_plat *plat =dev_get_platdata (dev); -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);int banknum;char name[18 ], *str;
drivers/gpio/omap_gpio.c +1 -1
@@ -309,7 +309,7 @@ static int omap_gpio_probe(struct udevice *dev) {struct gpio_bank *bank =dev_get_priv (dev);struct omap_gpio_platdata *plat =dev_get_platdata (dev); -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);char name[18 ], *str;sprintf (name,"GPIO%d_" , plat->bank_index);
drivers/gpio/s5p_gpio.c +1 -1
@@ -296,7 +296,7 @@ static const struct dm_gpio_ops gpio_exynos_ops = {static int gpio_exynos_probe (struct udevice *dev) { -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);struct exynos_bank_info *priv = dev->priv;struct exynos_gpio_platdata *plat = dev->platdata;
drivers/gpio/sandbox.c +3 -3
@@ -24,7 +24,7 @@ struct gpio_state {/* Access routines for GPIO state */ static u8 *get_gpio_flags (struct udevice *dev,unsigned offset) { -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);struct gpio_state *state =dev_get_priv (dev);if (offset >= uc_priv->gpio_count) {
@@ -160,7 +160,7 @@ static const struct dm_gpio_ops gpio_sandbox_ops = {static int sandbox_gpio_ofdata_to_platdata (struct udevice *dev) { -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev); uc_priv->gpio_count =fdtdec_get_int (gd->fdt_blob, dev->of_offset,"num-gpios" ,0 );
@@ -172,7 +172,7 @@ static int sandbox_gpio_ofdata_to_platdata(struct udevice *dev)static int gpio_sandbox_probe (struct udevice *dev) { -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);if (dev->of_offset ==-1 ) {/* Tell the uclass how many GPIOs we have */
drivers/gpio/sunxi_gpio.c +1 -1
@@ -238,7 +238,7 @@ static char *gpio_bank_name(int bank)static int gpio_sunxi_probe (struct udevice *dev) {struct sunxi_gpio_platdata *plat =dev_get_platdata (dev); -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);/* Tell the uclass how many GPIOs we have */ if (plat) {
drivers/gpio/tegra_gpio.c +1 -1
@@ -310,7 +310,7 @@ static const struct udevice_id tegra_gpio_ids[] = {static int gpio_tegra_probe (struct udevice *dev) { -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);struct tegra_port_info *priv = dev->priv;struct tegra_gpio_platdata *plat = dev->platdata;
drivers/i2c/i2c-uclass.c +3 -3
@@ -330,7 +330,7 @@ int dm_i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags,int dm_i2c_set_bus_speed (struct udevice *bus,unsigned int speed) {struct dm_i2c_ops *ops =i2c_get_ops (bus); -struct dm_i2c_bus *i2c = bus->uclass_priv; +struct dm_i2c_bus *i2c =dev_get_uclass_priv (bus);int ret;/*
@@ -351,7 +351,7 @@ int dm_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)int dm_i2c_get_bus_speed (struct udevice *bus) {struct dm_i2c_ops *ops =i2c_get_ops (bus); -struct dm_i2c_bus *i2c = bus->uclass_priv; +struct dm_i2c_bus *i2c =dev_get_uclass_priv (bus);if (!ops->get_bus_speed)return i2c->speed_hz;
@@ -432,7 +432,7 @@ int i2c_chip_ofdata_to_platdata(const void *blob, int node,static int i2c_post_probe (struct udevice *dev) { -struct dm_i2c_bus *i2c = dev->uclass_priv; +struct dm_i2c_bus *i2c =dev_get_uclass_priv (dev); i2c->speed_hz =fdtdec_get_int (gd->fdt_blob, dev->of_offset,"clock-frequency" ,100000 );
drivers/i2c/sandbox_i2c.c +1 -1
@@ -50,7 +50,7 @@ static int get_emul(struct udevice *dev, struct udevice **devp,static int sandbox_i2c_xfer (struct udevice *bus,struct i2c_msg *msg,int nmsgs) { -struct dm_i2c_bus *i2c = bus->uclass_priv; +struct dm_i2c_bus *i2c =dev_get_uclass_priv (bus);struct dm_i2c_ops *ops;struct udevice *emul, *dev;bool is_read;
drivers/misc/cros_ec.c +3 -3
@@ -1087,7 +1087,7 @@ static int cros_ec_decode_fdt(const void *blob, int node,#ifdef CONFIG_DM_CROS_EC int cros_ec_register (struct udevice *dev) { -struct cros_ec_dev *cdev = dev->uclass_priv; +struct cros_ec_dev *cdev =dev_get_uclass_priv (dev);const void *blob = gd->fdt_blob;int node = dev->of_offset;char id[MSG_BYTES ];
@@ -1128,7 +1128,7 @@ int cros_ec_init(const void *blob, struct cros_ec_dev **cros_ecp) ret =uclass_get_device (UCLASS_CROS_EC ,0 , &udev);if (ret)return ret; - dev = udev->uclass_priv; + dev =dev_get_uclass_priv (udev);return 0 ;#else int node =0 ;
@@ -1610,7 +1610,7 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])printf ("Cannot get cros-ec device (err=%d)\n" , ret); return 1; } - dev = udev->uclass_priv; + dev =dev_get_uclass_priv (udev);#else /* Just use the last allocated device; there should be only one */ if (!last_dev) {
drivers/misc/cros_ec_i2c.c +1 -1
@@ -28,7 +28,7 @@ static int cros_ec_i2c_command(struct udevice *udev, uint8_t cmd, int cmd_version, const uint8_t *dout, int dout_len, uint8_t **dinp, int din_len) { - struct cros_ec_dev *dev = udev->uclass_priv; + struct cros_ec_dev *dev = dev_get_uclass_priv(udev);/* version8, cmd8, arglen8, out8[dout_len], csum8 */ int out_bytes = dout_len +4 ;/* response8, arglen8, in8[din_len], checksum8 */
drivers/misc/cros_ec_sandbox.c +1 -1
@@ -470,7 +470,7 @@ static int process_cmd(struct ec_state *ec,#ifdef CONFIG_DM_CROS_EC int cros_ec_sandbox_packet (struct udevice *udev,int out_bytes,int in_bytes) { -struct cros_ec_dev *dev = udev->uclass_priv; +struct cros_ec_dev *dev =dev_get_uclass_priv (udev);struct ec_state *ec =dev_get_priv (dev->dev);#else int cros_ec_sandbox_packet(struct cros_ec_dev *dev, int out_bytes,
drivers/misc/cros_ec_spi.c +2 -2
@@ -23,7 +23,7 @@ DECLARE_GLOBAL_DATA_PTR;int cros_ec_spi_packet (struct udevice *udev,int out_bytes,int in_bytes) { -struct cros_ec_dev *dev = udev->uclass_priv; +struct cros_ec_dev *dev =dev_get_uclass_priv (udev);struct spi_slave *slave =dev_get_parentdata (dev->dev);int rv;
@@ -66,7 +66,7 @@ int cros_ec_spi_command(struct udevice *udev, uint8_t cmd, int cmd_version, const uint8_t *dout, int dout_len, uint8_t **dinp, int din_len) { - struct cros_ec_dev *dev = udev->uclass_priv; + struct cros_ec_dev *dev = dev_get_uclass_priv(udev);struct spi_slave *slave =dev_get_parentdata (dev->dev);int in_bytes = din_len +4 ;/* status, length, checksum, trailer */ uint8_t *out;
drivers/mtd/spi/sf-uclass.c +1 -1
@@ -23,7 +23,7 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,if (spi_flash_probe_bus_cs (bus, cs, max_hz, spi_mode, &dev))return NULL ; -return dev->uclass_priv; +return dev_get_uclass_priv (dev); }void spi_flash_free (struct spi_flash *flash)
drivers/mtd/spi/sf_probe.c +4 -4
@@ -458,7 +458,7 @@ void spi_flash_free(struct spi_flash *flash)static int spi_flash_std_read (struct udevice *dev,u32 offset,size_t len,void *buf) { -struct spi_flash *flash = dev->uclass_priv; +struct spi_flash *flash =dev_get_uclass_priv (dev);return spi_flash_cmd_read_ops (flash, offset, len, buf); }
@@ -466,14 +466,14 @@ static int spi_flash_std_read(struct udevice *dev, u32 offset, size_t len,int spi_flash_std_write (struct udevice *dev,u32 offset,size_t len,const void *buf) { -struct spi_flash *flash = dev->uclass_priv; +struct spi_flash *flash =dev_get_uclass_priv (dev);return spi_flash_cmd_write_ops (flash, offset, len, buf); }int spi_flash_std_erase (struct udevice *dev,u32 offset,size_t len) { -struct spi_flash *flash = dev->uclass_priv; +struct spi_flash *flash =dev_get_uclass_priv (dev);return spi_flash_cmd_erase_ops (flash, offset, len); }
@@ -484,7 +484,7 @@ int spi_flash_std_probe(struct udevice *dev)struct dm_spi_slave_platdata *plat =dev_get_parent_platdata (dev);struct spi_flash *flash; - flash = dev->uclass_priv; + flash =dev_get_uclass_priv (dev); flash->dev = dev;debug ("%s: slave=%p, cs=%d\n" , __func__, slave, plat->cs);return spi_flash_probe_slave (slave, flash);
drivers/serial/serial-uclass.c +2 -2
@@ -253,7 +253,7 @@ static int serial_post_probe(struct udevice *dev) {struct dm_serial_ops *ops =serial_get_ops (dev);#ifdef CONFIG_DM_STDIO -struct serial_dev_priv *upriv = dev->uclass_priv; +struct serial_dev_priv *upriv =dev_get_uclass_priv (dev);struct stdio_dev sdev;#endif int ret;
@@ -301,7 +301,7 @@ static int serial_post_probe(struct udevice *dev)static int serial_pre_remove (struct udevice *dev) {#ifdef CONFIG_SYS_STDIO_DEREGISTER -struct serial_dev_priv *upriv = dev->uclass_priv; +struct serial_dev_priv *upriv =dev_get_uclass_priv (dev);if (stdio_deregister_dev (upriv->sdev,0 ))return -EPERM ;
drivers/spi/spi-uclass.c +2 -2
@@ -50,7 +50,7 @@ int spi_claim_bus(struct spi_slave *slave)struct udevice *dev = slave->dev;struct udevice *bus = dev->parent;struct dm_spi_ops *ops =spi_get_ops (bus); -struct dm_spi_bus *spi = bus->uclass_priv; +struct dm_spi_bus *spi =dev_get_uclass_priv (bus);int speed;int ret;
@@ -110,7 +110,7 @@ int spi_child_post_bind(struct udevice *dev)int spi_post_probe (struct udevice *bus) { -struct dm_spi_bus *spi = bus->uclass_priv; +struct dm_spi_bus *spi =dev_get_uclass_priv (bus); spi->max_hz =fdtdec_get_int (gd->fdt_blob, bus->of_offset,"spi-max-frequency" ,0 );
include/dm/device.h +10 -0
@@ -238,6 +238,16 @@ void *dev_get_priv(struct udevice *dev);struct udevice *dev_get_parent (struct udevice *child);/** +* dev_get_uclass_priv() - Get the private uclass data for a device +* +* This checks that dev is not NULL, but no other checks for now +* +* @dev Device to check +* @return private uclass data for this device, or NULL if none +*/ +void *dev_get_uclass_priv (struct udevice *dev); + +/** * dev_get_of_data() - get the device tree data used to bind a device * * When a device is bound using a device tree node, it matches a
include/i2c.h +4 -4
@@ -64,8 +64,8 @@ struct dm_i2c_chip {* bus can operate at different speeds (measured in Hz, typically 100KHz * or 400KHz). * -* To obtain this structure, use bus->uclass_priv where bus is the I2C -* bus udevice. +* To obtain this structure, use dev_get_uclass_priv(bus) where bus is the +* I2C bus udevice. * * @speed_hz: Bus speed in hertz (typically 100000) */
@@ -340,7 +340,7 @@ struct dm_i2c_ops {* The bus speed value will be updated by the uclass if this function * does not return an error. This method is optional - if it is not * provided then the driver can read the speed from -* bus->uclass_priv->speed_hz +* dev_get_uclass_priv(bus)->speed_hz * * @bus: Bus to adjust * @speed: Requested speed in Hz
@@ -354,7 +354,7 @@ struct dm_i2c_ops {* Normally this can be provided by the uclass, but if you want your * driver to check the bus speed by looking at the hardware, you can * implement that here. This method is optional. This method would -* normally be expected to return bus->uclass_priv->speed_hz. +* normally be expected to return dev_get_uclass_priv(bus)->speed_hz. * * @bus: Bus to check * @return speed of selected I2C bus in Hz, -ve on error
test/dm/core.c +1 -1
@@ -179,7 +179,7 @@ static int dm_test_autoprobe(struct dm_test_state *dms)ut_assertok (uclass_find_device (UCLASS_TEST , i, &dev));ut_assert (dev); - priv = dev->uclass_priv; + priv =dev_get_uclass_priv (dev);ut_assert (priv);ut_asserteq (expected_base_add, priv->base_add);
test/dm/test-uclass.c +2 -2
@@ -47,7 +47,7 @@ static int test_post_probe(struct udevice *dev)struct udevice *prev =list_entry (dev->uclass_node.prev, struct udevice, uclass_node); -struct dm_test_uclass_perdev_priv *priv = dev->uclass_priv; +struct dm_test_uclass_perdev_priv *priv =dev_get_uclass_priv (dev);struct uclass *uc = dev->uclass; dm_testdrv_op_count[DM_TEST_OP_POST_PROBE ]++;
@@ -58,7 +58,7 @@ static int test_post_probe(struct udevice *dev)return 0 ;if (&prev->uclass_node != &uc->dev_head) {struct dm_test_uclass_perdev_priv *prev_uc_priv - = prev->uclass_priv; + =dev_get_uclass_priv (prev);struct dm_test_pdata *pdata = prev->platdata;ut_assert (pdata);
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 8/22 dm: core: Add dev_get_uclass_priv() to access uclass private data
Hi Simon,
Quoted 3 lines · Simon Glass
Add a convenience function to access the private data that a uclass stores for each of its devices. Convert over most existing uses for consistency and to provide an example for others.
What's the benefit of doing this? It (dev_get_uclass_priv) looks verbose to me. And you cannot stop people from doing that (dev->uclass_priv) either.
Quoted 617 lines
Signed-off-by Simon Glass <[email protected]>---
common/cmd_sf.c | 2 +- common/cros_ec.c | 2 +- drivers/core/device.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 | 2 +- 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/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/mtd/spi/sf-uclass.c | 2 +- drivers/mtd/spi/sf_probe.c | 8 ++++---- drivers/serial/serial-uclass.c | 4 ++-- drivers/spi/spi-uclass.c | 4 ++-- include/dm/device.h | 10 ++++++++++ include/i2c.h | 8 ++++---- test/dm/core.c | 2 +- test/dm/test-uclass.c | 4 ++-- 27 files changed, 71 insertions(+), 51 deletions(-)common/cmd_sf.c +1
-1@@ -130,7 +130,7 @@ static int do_spi_flash_probe(int argc, char * const argv[]) return 1; } - flash = new->uclass_priv; + flash =dev_get_uclass_priv (new);#else new =spi_flash_probe (bus, cs, speed, mode);if (!new) {common/cros_ec.c +1
-1@@ -35,7 +35,7 @@ struct cros_ec_dev *board_get_cros_ec_dev(void)debug ("%s: Error %d\n" , __func__, ret); return NULL; } -return dev->uclass_priv; +return dev_get_uclass_priv (dev);#else return local.cros_ec_dev;#endif drivers/core/device.c +10
-0@@ -305,6 +305,16 @@ void *dev_get_priv(struct udevice *dev)return dev->priv; } +void *dev_get_uclass_priv (struct udevice *dev) +{ +if (!dev) { +dm_warn ("%s: null device\n" , __func__); +return NULL ; + } + +return dev->uclass_priv; +} +void *dev_get_parentdata (struct udevice *dev) {if (!dev) {drivers/gpio/at91_gpio.c +1
-1@@ -511,7 +511,7 @@ static int at91_gpio_probe(struct udevice *dev) {struct at91_port_priv *port =dev_get_priv (dev);struct at91_port_platdata *plat =dev_get_platdata (dev); -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev); uc_priv->bank_name = plat->bank_name; uc_priv->gpio_count =GPIO_PER_BANK ;drivers/gpio/bcm2835_gpio.c +1
-1@@ -105,7 +105,7 @@ static int bcm2835_gpio_probe(struct udevice *dev) {struct bcm2835_gpios *gpios =dev_get_priv (dev);struct bcm2835_gpio_platdata *plat =dev_get_platdata (dev); -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev); uc_priv->bank_name ="GPIO" ; uc_priv->gpio_count =BCM2835_GPIO_COUNT ;drivers/gpio/gpio-uclass.c +11
-11@@ -34,7 +34,7 @@ static int gpio_to_device(unsigned int gpio, struct gpio_desc *desc)for (ret =uclass_first_device (UCLASS_GPIO , &dev); dev; ret =uclass_next_device (&dev)) { - uc_priv = dev->uclass_priv; + uc_priv =dev_get_uclass_priv (dev);if (gpio >= uc_priv->gpio_base && gpio < uc_priv->gpio_base + uc_priv->gpio_count) { desc->dev = dev;@@ -65,7 +65,7 @@ int gpio_lookup_name(const char *name, struct udevice **devp, ret = uclass_next_device(&dev)) {int len; - uc_priv = dev->uclass_priv; + uc_priv =dev_get_uclass_priv (dev);if (numeric !=-1 ) { offset = numeric - uc_priv->gpio_base;/* Allow GPIOs to be numbered from 0 */ @@ -116,7 +116,7 @@ static int dm_gpio_request(struct gpio_desc *desc, const char *label)char *str;int ret; - uc_priv = dev->uclass_priv; + uc_priv =dev_get_uclass_priv (dev);if (uc_priv->name[desc->offset])return -EBUSY ; str =strdup (label);@@ -195,7 +195,7 @@ int _dm_gpio_free(struct udevice *dev, uint offset)struct gpio_dev_priv *uc_priv;int ret; - uc_priv = dev->uclass_priv; + uc_priv =dev_get_uclass_priv (dev);if (!uc_priv->name[offset])return -ENXIO ;if (gpio_get_ops (dev)->free) {@@ -232,7 +232,7 @@ int gpio_free(unsigned gpio)static int check_reserved (struct gpio_desc *desc,const char *func) { -struct gpio_dev_priv *uc_priv = desc->dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (desc->dev);if (!uc_priv->name[desc->offset]) { printf("%s: %s: error: gpio %s%d not reserved\n",@@ -402,7 +402,7 @@ const char *gpio_get_bank_info(struct udevice *dev, int *bit_count)struct gpio_dev_priv *priv;/* Must be called on an active device */ - priv = dev->uclass_priv; + priv =dev_get_uclass_priv (dev);assert (priv); *bit_count = priv->gpio_count;@@ -420,7 +420,7 @@ static const char * const gpio_function[GPIOF_COUNT] = {int get_function (struct udevice *dev,int offset,bool skip_unused,const char **namep) { -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);struct dm_gpio_ops *ops =gpio_get_ops (dev);BUILD_BUG_ON (GPIOF_COUNT !=ARRAY_SIZE (gpio_function));@@ -468,7 +468,7 @@ int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize)BUILD_BUG_ON (GPIOF_COUNT !=ARRAY_SIZE (gpio_function)); *buf =0 ; - priv = dev->uclass_priv; + priv =dev_get_uclass_priv (dev); ret =gpio_get_raw_function (dev, offset,NULL );if (ret <0 )return ret;@@ -680,7 +680,7 @@ static int gpio_renumber(struct udevice *removed_dev) base =0 ; uclass_foreach_dev(dev, uc) {if (device_active (dev) && dev != removed_dev) { - uc_priv = dev->uclass_priv; + uc_priv =dev_get_uclass_priv (dev); uc_priv->gpio_base = base; base += uc_priv->gpio_count; }@@ -691,7 +691,7 @@ static int gpio_renumber(struct udevice *removed_dev)static int gpio_post_probe (struct udevice *dev) { -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev); uc_priv->name =calloc (uc_priv->gpio_count,sizeof (char *));if (!uc_priv->name)@@ -702,7 +702,7 @@ static int gpio_post_probe(struct udevice *dev)static int gpio_pre_remove (struct udevice *dev) { -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);int i;for (i =0 ; i < uc_priv->gpio_count; i++) {drivers/gpio/intel_ich6_gpio.c +1
-1@@ -151,7 +151,7 @@ static int gpio_ich6_ofdata_to_platdata(struct udevice *dev)static int ich6_gpio_probe (struct udevice *dev) {struct ich6_bank_platdata *plat =dev_get_platdata (dev); -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);struct ich6_bank_priv *bank =dev_get_priv (dev);if (gd->arch.gpio_map) {drivers/gpio/mxc_gpio.c +1
-1@@ -266,7 +266,7 @@ static int mxc_gpio_probe(struct udevice *dev) {struct mxc_bank_info *bank =dev_get_priv (dev);struct mxc_gpio_plat *plat =dev_get_platdata (dev); -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);int banknum;char name[18 ], *str;drivers/gpio/omap_gpio.c +1
-1@@ -309,7 +309,7 @@ static int omap_gpio_probe(struct udevice *dev) {struct gpio_bank *bank =dev_get_priv (dev);struct omap_gpio_platdata *plat =dev_get_platdata (dev); -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);char name[18 ], *str;sprintf (name,"GPIO%d_" , plat->bank_index);drivers/gpio/s5p_gpio.c +1
-1@@ -296,7 +296,7 @@ static const struct dm_gpio_ops gpio_exynos_ops = {static int gpio_exynos_probe (struct udevice *dev) { -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);struct exynos_bank_info *priv = dev->priv;struct exynos_gpio_platdata *plat = dev->platdata;drivers/gpio/sandbox.c +3
-3@@ -24,7 +24,7 @@ struct gpio_state {/* Access routines for GPIO state */ static u8 *get_gpio_flags (struct udevice *dev,unsigned offset) { -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);struct gpio_state *state =dev_get_priv (dev);if (offset >= uc_priv->gpio_count) {@@ -160,7 +160,7 @@ static const struct dm_gpio_ops gpio_sandbox_ops = {static int sandbox_gpio_ofdata_to_platdata (struct udevice *dev) { -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev); uc_priv->gpio_count =fdtdec_get_int (gd->fdt_blob, dev->of_offset,"num-gpios" ,0 );@@ -172,7 +172,7 @@ static int sandbox_gpio_ofdata_to_platdata(struct udevice *dev)static int gpio_sandbox_probe (struct udevice *dev) { -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);if (dev->of_offset ==-1 ) {/* Tell the uclass how many GPIOs we have */ drivers/gpio/sunxi_gpio.c +1
-1@@ -238,7 +238,7 @@ static char *gpio_bank_name(int bank)static int gpio_sunxi_probe (struct udevice *dev) {struct sunxi_gpio_platdata *plat =dev_get_platdata (dev); -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);/* Tell the uclass how many GPIOs we have */ if (plat) {drivers/gpio/tegra_gpio.c +1
-1@@ -310,7 +310,7 @@ static const struct udevice_id tegra_gpio_ids[] = {static int gpio_tegra_probe (struct udevice *dev) { -struct gpio_dev_priv *uc_priv = dev->uclass_priv; +struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev);struct tegra_port_info *priv = dev->priv;struct tegra_gpio_platdata *plat = dev->platdata;drivers/i2c/i2c-uclass.c +3
-3@@ -330,7 +330,7 @@ int dm_i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags,int dm_i2c_set_bus_speed (struct udevice *bus,unsigned int speed) {struct dm_i2c_ops *ops =i2c_get_ops (bus); -struct dm_i2c_bus *i2c = bus->uclass_priv; +struct dm_i2c_bus *i2c =dev_get_uclass_priv (bus);int ret;/* @@ -351,7 +351,7 @@ int dm_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)int dm_i2c_get_bus_speed (struct udevice *bus) {struct dm_i2c_ops *ops =i2c_get_ops (bus); -struct dm_i2c_bus *i2c = bus->uclass_priv; +struct dm_i2c_bus *i2c =dev_get_uclass_priv (bus);if (!ops->get_bus_speed)return i2c->speed_hz;@@ -432,7 +432,7 @@ int i2c_chip_ofdata_to_platdata(const void *blob, int node,static int i2c_post_probe (struct udevice *dev) { -struct dm_i2c_bus *i2c = dev->uclass_priv; +struct dm_i2c_bus *i2c =dev_get_uclass_priv (dev); i2c->speed_hz =fdtdec_get_int (gd->fdt_blob, dev->of_offset,"clock-frequency" ,100000 );drivers/i2c/sandbox_i2c.c +1
-1@@ -50,7 +50,7 @@ static int get_emul(struct udevice *dev, struct udevice **devp,static int sandbox_i2c_xfer (struct udevice *bus,struct i2c_msg *msg,int nmsgs) { -struct dm_i2c_bus *i2c = bus->uclass_priv; +struct dm_i2c_bus *i2c =dev_get_uclass_priv (bus);struct dm_i2c_ops *ops;struct udevice *emul, *dev;bool is_read;drivers/misc/cros_ec.c +3
-3@@ -1087,7 +1087,7 @@ static int cros_ec_decode_fdt(const void *blob, int node,#ifdef CONFIG_DM_CROS_EC int cros_ec_register (struct udevice *dev) { -struct cros_ec_dev *cdev = dev->uclass_priv; +struct cros_ec_dev *cdev =dev_get_uclass_priv (dev);const void *blob = gd->fdt_blob;int node = dev->of_offset;char id[MSG_BYTES ];@@ -1128,7 +1128,7 @@ int cros_ec_init(const void *blob, struct cros_ec_dev **cros_ecp) ret =uclass_get_device (UCLASS_CROS_EC ,0 , &udev);if (ret)return ret; - dev = udev->uclass_priv; + dev =dev_get_uclass_priv (udev);return 0 ;#else int node =0 ;@@ -1610,7 +1610,7 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])printf ("Cannot get cros-ec device (err=%d)\n" , ret); return 1; } - dev = udev->uclass_priv; + dev =dev_get_uclass_priv (udev);#else /* Just use the last allocated device; there should be only one */ if (!last_dev) {drivers/misc/cros_ec_i2c.c +1
-1@@ -28,7 +28,7 @@ static int cros_ec_i2c_command(struct udevice *udev, uint8_t cmd, int cmd_version, const uint8_t *dout, int dout_len, uint8_t **dinp, int din_len) { - struct cros_ec_dev *dev = udev->uclass_priv; + struct cros_ec_dev *dev = dev_get_uclass_priv(udev);/* version8, cmd8, arglen8, out8[dout_len], csum8 */ int out_bytes = dout_len +4 ;/* response8, arglen8, in8[din_len], checksum8 */ drivers/misc/cros_ec_sandbox.c +1
-1@@ -470,7 +470,7 @@ static int process_cmd(struct ec_state *ec,#ifdef CONFIG_DM_CROS_EC int cros_ec_sandbox_packet (struct udevice *udev,int out_bytes,int in_bytes) { -struct cros_ec_dev *dev = udev->uclass_priv; +struct cros_ec_dev *dev =dev_get_uclass_priv (udev);struct ec_state *ec =dev_get_priv (dev->dev);#else int cros_ec_sandbox_packet(struct cros_ec_dev *dev, int out_bytes,drivers/misc/cros_ec_spi.c +2
-2@@ -23,7 +23,7 @@ DECLARE_GLOBAL_DATA_PTR;int cros_ec_spi_packet (struct udevice *udev,int out_bytes,int in_bytes) { -struct cros_ec_dev *dev = udev->uclass_priv; +struct cros_ec_dev *dev =dev_get_uclass_priv (udev);struct spi_slave *slave =dev_get_parentdata (dev->dev);int rv;@@ -66,7 +66,7 @@ int cros_ec_spi_command(struct udevice *udev, uint8_t cmd, int cmd_version, const uint8_t *dout, int dout_len, uint8_t **dinp, int din_len) { - struct cros_ec_dev *dev = udev->uclass_priv; + struct cros_ec_dev *dev = dev_get_uclass_priv(udev);struct spi_slave *slave =dev_get_parentdata (dev->dev);int in_bytes = din_len +4 ;/* status, length, checksum, trailer */ uint8_t *out;drivers/mtd/spi/sf-uclass.c +1
-1@@ -23,7 +23,7 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,if (spi_flash_probe_bus_cs (bus, cs, max_hz, spi_mode, &dev))return NULL ; -return dev->uclass_priv; +return dev_get_uclass_priv (dev); }void spi_flash_free (struct spi_flash *flash)drivers/mtd/spi/sf_probe.c +4
-4@@ -458,7 +458,7 @@ void spi_flash_free(struct spi_flash *flash)static int spi_flash_std_read (struct udevice *dev,u32 offset,size_t len,void *buf) { -struct spi_flash *flash = dev->uclass_priv; +struct spi_flash *flash =dev_get_uclass_priv (dev);return spi_flash_cmd_read_ops (flash, offset, len, buf); }@@ -466,14 +466,14 @@ static int spi_flash_std_read(struct udevice *dev, u32 offset, size_t len,int spi_flash_std_write (struct udevice *dev,u32 offset,size_t len,const void *buf) { -struct spi_flash *flash = dev->uclass_priv; +struct spi_flash *flash =dev_get_uclass_priv (dev);return spi_flash_cmd_write_ops (flash, offset, len, buf); }int spi_flash_std_erase (struct udevice *dev,u32 offset,size_t len) { -struct spi_flash *flash = dev->uclass_priv; +struct spi_flash *flash =dev_get_uclass_priv (dev);return spi_flash_cmd_erase_ops (flash, offset, len); }@@ -484,7 +484,7 @@ int spi_flash_std_probe(struct udevice *dev)struct dm_spi_slave_platdata *plat =dev_get_parent_platdata (dev);struct spi_flash *flash; - flash = dev->uclass_priv; + flash =dev_get_uclass_priv (dev); flash->dev = dev;debug ("%s: slave=%p, cs=%d\n" , __func__, slave, plat->cs);return spi_flash_probe_slave (slave, flash);drivers/serial/serial-uclass.c +2
-2@@ -253,7 +253,7 @@ static int serial_post_probe(struct udevice *dev) {struct dm_serial_ops *ops =serial_get_ops (dev);#ifdef CONFIG_DM_STDIO -struct serial_dev_priv *upriv = dev->uclass_priv; +struct serial_dev_priv *upriv =dev_get_uclass_priv (dev);struct stdio_dev sdev;#endif int ret;@@ -301,7 +301,7 @@ static int serial_post_probe(struct udevice *dev)static int serial_pre_remove (struct udevice *dev) {#ifdef CONFIG_SYS_STDIO_DEREGISTER -struct serial_dev_priv *upriv = dev->uclass_priv; +struct serial_dev_priv *upriv =dev_get_uclass_priv (dev);if (stdio_deregister_dev (upriv->sdev,0 ))return -EPERM ;drivers/spi/spi-uclass.c +2
-2@@ -50,7 +50,7 @@ int spi_claim_bus(struct spi_slave *slave)struct udevice *dev = slave->dev;struct udevice *bus = dev->parent;struct dm_spi_ops *ops =spi_get_ops (bus); -struct dm_spi_bus *spi = bus->uclass_priv; +struct dm_spi_bus *spi =dev_get_uclass_priv (bus);int speed;int ret;@@ -110,7 +110,7 @@ int spi_child_post_bind(struct udevice *dev)int spi_post_probe (struct udevice *bus) { -struct dm_spi_bus *spi = bus->uclass_priv; +struct dm_spi_bus *spi =dev_get_uclass_priv (bus); spi->max_hz =fdtdec_get_int (gd->fdt_blob, bus->of_offset,"spi-max-frequency" ,0 );include/dm/device.h +10
-0@@ -238,6 +238,16 @@ void *dev_get_priv(struct udevice *dev);struct udevice *dev_get_parent (struct udevice *child);/** +* dev_get_uclass_priv() - Get the private uclass data for a device +* +* This checks that dev is not NULL, but no other checks for now +* +* @dev Device to check +* @return private uclass data for this device, or NULL if none +*/ +void *dev_get_uclass_priv (struct udevice *dev); + +/** * dev_get_of_data() - get the device tree data used to bind a device * * When a device is bound using a device tree node, it matches a include/i2c.h +4
-4@@ -64,8 +64,8 @@ struct dm_i2c_chip {* bus can operate at different speeds (measured in Hz, typically 100KHz * or 400KHz). * -* To obtain this structure, use bus->uclass_priv where bus is the I2C -* bus udevice. +* To obtain this structure, use dev_get_uclass_priv(bus) where bus is the +* I2C bus udevice. * * @speed_hz: Bus speed in hertz (typically 100000) */ @@ -340,7 +340,7 @@ struct dm_i2c_ops {* The bus speed value will be updated by the uclass if this function * does not return an error. This method is optional - if it is not * provided then the driver can read the speed from -* bus->uclass_priv->speed_hz +* dev_get_uclass_priv(bus)->speed_hz * * @bus: Bus to adjust * @speed: Requested speed in Hz @@ -354,7 +354,7 @@ struct dm_i2c_ops {* Normally this can be provided by the uclass, but if you want your * driver to check the bus speed by looking at the hardware, you can * implement that here. This method is optional. This method would -* normally be expected to return bus->uclass_priv->speed_hz. +* normally be expected to return dev_get_uclass_priv(bus)->speed_hz. * * @bus: Bus to check * @return speed of selected I2C bus in Hz, -ve on error test/dm/core.c +1
-1@@ -179,7 +179,7 @@ static int dm_test_autoprobe(struct dm_test_state *dms)ut_assertok (uclass_find_device (UCLASS_TEST , i, &dev));ut_assert (dev); - priv = dev->uclass_priv; + priv =dev_get_uclass_priv (dev);ut_assert (priv);ut_asserteq (expected_base_add, priv->base_add);test/dm/test-uclass.c +1
-1@@ -47,7 +47,7 @@ static int test_post_probe(struct udevice *dev)struct udevice *prev =list_entry (dev->uclass_node.prev, struct udevice, uclass_node); -struct dm_test_uclass_perdev_priv *priv = dev->uclass_priv; +struct dm_test_uclass_perdev_priv *priv =dev_get_uclass_priv (dev);struct uclass *uc = dev->uclass; dm_testdrv_op_count[DM_TEST_OP_POST_PROBE ]++;
test/dm/test-uclass.c static int test_post_probe(struct udevice *dev)
Quoted 9 lines
test/dm/test-uclass.c +1
-2@@ -58,7 +58,7 @@ static int test_post_probe(struct udevice *dev)return 0 ;if (&prev->uclass_node != &uc->dev_head) {struct dm_test_uclass_perdev_priv *prev_uc_priv - = prev->uclass_priv; + =dev_get_uclass_priv (prev);struct dm_test_pdata *pdata = prev->platdata;ut_assert (pdata); --
Regards,
Bin
PATCH 8/22 dm: core: Add dev_get_uclass_priv() to access uclass private data
Hi Bin,
Quoted 11 lines · Bin Meng
Hi Simon,
Quoted 3 lines · Simon Glass
Add a convenience function to access the private data that a uclass stores for each of its devices. Convert over most existing uses for consistency and to provide an example for others.
What's the benefit of doing this? It (
dev_get_uclass_priv) looks verbose to me. And you cannot stop people from doing that (dev->uclass_priv) either.
The idea is that we can check that the device is valid, and it has a valid uclass, that the private data is there, etc. We don't have many checks like this at present but this makes it possible to add them. With all the pointers flying around I would really like to add some checking, perhaps CONFIG_DM_CHECK, which checks these pointers.
Regards,
Simon
PATCH 9/22 dm: core: Mark device as active before calling its probe() method
In reply to Simon GlassAt present the device is not active when the probe() method is called. But some probe() methods want to set up the device and this can involve accessing it through normal methods. For example a PCI bus may wish to set up its PCI parameters using calls to pci_hose_write_config_dword() and similar.
At present this does not work because every such call within the probe() method sees that the device is not active and attempts to probe it.
Already we mark the device as probed before calling the uclass post_probe() method. This is a subtle change but I believe the new approach is better. Since the scope of the change is only the probe() method and all its callees it should still be within the control of the board author.
---
drivers/core/device.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/core/device.c +4 -3
@@ -243,14 +243,15 @@ int device_probe_child(struct udevice *dev, void *parent_priv) goto fail; } + dev->flags |=DM_FLAG_ACTIVATED ;if (drv->probe) { ret = drv->probe (dev); -if (ret) +if (ret) { + dev->flags &= ~DM_FLAG_ACTIVATED ; goto fail; + } } - dev->flags |=DM_FLAG_ACTIVATED ; - ret =uclass_post_probe_device (dev);if (ret) { dev->flags &= ~DM_FLAG_ACTIVATED ;
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 10/22 dm: core: Add a uclass pre_probe() method for devices
In reply to Simon GlassSome uclasses want to set up a device before it is probed. Add a method for this.
An example is with PCI, where a PCI uclass wants to set up its private data for later use. This allows the device's uclass() method to make calls whcih use that data (for example, read PCI memory regions from device tree, set up bus numbers).
---
drivers/core/device.c | 2 +- drivers/core/uclass.c | 10 +++++++++- include/dm/test.h | 1 + include/dm/uclass-internal.h | 7 ++++--- include/dm/uclass.h | 2 ++ test/dm/core.c | 7 ++++++- test/dm/test-uclass.c | 12 ++++++++++++ 7 files changed, 35 insertions(+), 6 deletions(-)
drivers/core/device.c +1 -1
@@ -227,7 +227,7 @@ int device_probe_child(struct udevice *dev, void *parent_priv) } dev->seq = seq; - ret =uclass_pre_probe_child (dev); + ret =uclass_pre_probe_device (dev);if (ret) goto fail;
drivers/core/uclass.c +9 -1
@@ -391,9 +391,17 @@ int uclass_resolve_seq(struct udevice *dev)return seq; } -int uclass_pre_probe_child (struct udevice *dev) +int uclass_pre_probe_device (struct udevice *dev) {struct uclass_driver *uc_drv; +int ret; + + uc_drv = dev->uclass->uc_drv; +if (uc_drv->pre_probe) { + ret = uc_drv->pre_probe (dev); +if (ret) +return ret; + }if (!dev->parent)return 0 ;
include/dm/test.h +1 -0
@@ -44,6 +44,7 @@ enum {/* For uclass */ DM_TEST_OP_POST_BIND ,DM_TEST_OP_PRE_UNBIND , +DM_TEST_OP_PRE_PROBE ,DM_TEST_OP_POST_PROBE ,DM_TEST_OP_PRE_REMOVE , DM_TEST_OP_INIT,
include/dm/uclass-internal.h +4 -3
@@ -44,15 +44,16 @@ int uclass_bind_device(struct udevice *dev);int uclass_unbind_device (struct udevice *dev);/** -* uclass_pre_probe_child() - Deal with a child that is about to be probed +* uclass_pre_probe_device() - Deal with a device that is about to be probed * * Perform any pre-processing that is needed by the uclass before it can be -* probed. +* probed. This includes the uclass' pre-probe() method and the parent +* uclass' child_pre_probe() method. * * @dev: Pointer to the device * #return 0 on success, -ve on error */ -int uclass_pre_probe_child (struct udevice *dev); +int uclass_pre_probe_device (struct udevice *dev);/** * uclass_post_probe_device() - Deal with a device that has just been probed
include/dm/uclass.h +2 -0
@@ -53,6 +53,7 @@ struct udevice;* @id: ID number of this uclass * @post_bind: Called after a new device is bound to this uclass * @pre_unbind: Called before a device is unbound from this uclass +* @pre_probe: Called before a new device is probed * @post_probe: Called after a new device is probed * @pre_remove: Called before a device is removed * @child_post_bind: Called after a child is bound to a device in this uclass
@@ -80,6 +81,7 @@ struct uclass_driver {enum uclass_id id;int (*post_bind)(struct udevice *dev);int (*pre_unbind)(struct udevice *dev); +int (*pre_probe)(struct udevice *dev);int (*post_probe)(struct udevice *dev);int (*pre_remove)(struct udevice *dev);int (*child_post_bind)(struct udevice *dev);
test/dm/core.c +6 -1
@@ -141,6 +141,7 @@ static int dm_test_autoprobe(struct dm_test_state *dms)ut_assert (uc);ut_asserteq (1 , dm_testdrv_op_count[DM_TEST_OP_INIT ]); +ut_asserteq (0 , dm_testdrv_op_count[DM_TEST_OP_PRE_PROBE ]);ut_asserteq (0 , dm_testdrv_op_count[DM_TEST_OP_POST_PROBE ]);/* The root device should not be activated until needed */
@@ -167,8 +168,12 @@ static int dm_test_autoprobe(struct dm_test_state *dms)ut_assert (dms->root->flags &DM_FLAG_ACTIVATED ); } -/* Our 3 dm_test_infox children should be passed to post_probe */ +/* +* Our 3 dm_test_info children should be passed to pre_probe and +* post_probe +*/ ut_asserteq (3 , dm_testdrv_op_count[DM_TEST_OP_POST_PROBE ]); +ut_asserteq (3 , dm_testdrv_op_count[DM_TEST_OP_PRE_PROBE ]);/* Also we can check the per-device data */ expected_base_add =0 ;
test/dm/test-uclass.c +12 -0
@@ -42,6 +42,17 @@ static int test_pre_unbind(struct udevice *dev)return 0 ; } +static int test_pre_probe (struct udevice *dev) +{ +struct dm_test_uclass_perdev_priv *priv =dev_get_uclass_priv (dev); + + dm_testdrv_op_count[DM_TEST_OP_PRE_PROBE ]++; +ut_assert (priv); +ut_assert (!device_active (dev)); + +return 0 ; +} +static int test_post_probe (struct udevice *dev) { struct udevice *prev = list_entry(dev->uclass_node.prev,
@@ -96,6 +107,7 @@ UCLASS_DRIVER(test) = { .id = UCLASS_TEST, .post_bind = test_post_bind, .pre_unbind = test_pre_unbind, + .pre_probe = test_pre_probe, .post_probe = test_post_probe, .pre_remove = test_pre_remove, .init = test_init,
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 11/22 dm: Show both allocated and requested seq numbers in 'dm uclass'
In reply to Simon GlassBoth of these values are useful for understanding what is going on, so show them both.
The requested number comes from a device tree alias. The allocated one is set up when the device is activated, and is unique throughout the uclass.
---
test/dm/cmd_dm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
test/dm/cmd_dm.c +2 -2
@@ -77,8 +77,8 @@ static void dm_display_line(struct udevice *dev)printf ("- %c %s @ %08lx" , dev->flags &DM_FLAG_ACTIVATED ?'*' :' ' , dev->name, (ulong )map_to_sysmem (dev)); -if (dev->req_seq !=-1 ) -printf (", %d" , dev->req_seq); +if (dev->seq !=-1 || dev->req_seq !=-1 ) +printf (", seq-%d, (req=%d)" , dev->seq, dev->req_seq);puts ("\n" ); }
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 12/22 dm: pci: Move common PCI functions into their own file
In reply to Simon GlassDriver model will share many functions with the existing PCI implementation. Move these into their own file to avoid duplication and confusion.
---
drivers/pci/Makefile | 2 +- drivers/pci/pci.c | 281 +-------------------------------------------- drivers/pci/pci_common.c | 292 +++++++++++++++++++++++++++++++++++++++++++++++ include/pci.h | 14 +++ 4 files changed, 313 insertions(+), 276 deletions(-) create mode 100644 drivers/pci/pci_common.c
drivers/pci/Makefile +1 -1
@@ -6,7 +6,7 @@ # obj-$(CONFIG_FSL_PCI_INIT) += fsl_pci_init.o -obj-$(CONFIG_PCI) += pci.o pci_auto.o pci_rom.o +obj-$(CONFIG_PCI) += pci.o pci_common.o pci_auto.o pci_rom.o obj-$(CONFIG_PCI_INDIRECT_BRIDGE) += pci_indirect.o obj-$(CONFIG_PCI_GT64120) += pci_gt64120.o obj-$(CONFIG_PCI_MSC01) += pci_msc01.o
drivers/pci/pci.c +6 -275
315 lines not on this page · raw message
drivers/pci/pci_common.c new file +292 -0
292 lines not on this page · raw message
include/pci.h +14 -0
@@ -705,5 +705,19 @@ u32 pci_read_bar32(struct pci_controller *hose, pci_dev_t dev, int barnum);*/ int pciauto_setup_rom (struct pci_controller *hose,pci_dev_t dev); +/** +* pci_hose_find_devices() - Find devices by vendor/device ID +* +* @hose: PCI hose to search +* @busnum: Bus number to search +* @ids: PCI vendor/device IDs to look for, terminated by 0, 0 record +* @indexp: Pointer to device index to find. To find the first matching +* device, pass 0; to find the second, pass 1, etc. This +* parameter is decremented for each non-matching device so +* can be called repeatedly. +*/ +pci_dev_t pci_hose_find_devices (struct pci_controller *hose,int busnum, +struct pci_device_id *ids,int *indexp); +#endif /* __ASSEMBLY__ */ #endif /* _PCI_H */
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 13/22 dm: pci: Add a uclass for PCI
In reply to Simon GlassAdd a uclass for PCI controllers and a generic one for PCI devices. Adjust the 'pci' command and the existing PCI support to work with this new uclass. Keep most of the compatibility code in a separate file so that it can be removed one day.
TODO: Add more header file comments to the new parts of pci.h
---
common/board_r.c | 2 + common/cmd_pci.c | 14 +- doc/driver-model/pci-info.txt | 70 +++++ drivers/pci/Kconfig | 12 + drivers/pci/Makefile | 8 +- drivers/pci/pci-uclass.c | 639 ++++++++++++++++++++++++++++++++++++++++++ drivers/pci/pci_auto.c | 16 +- drivers/pci/pci_compat.c | 43 +++ include/dm/uclass-id.h | 2 + include/pci.h | 289 ++++++++++++++++++- 10 files changed, 1081 insertions(+), 14 deletions(-) create mode 100644 doc/driver-model/pci-info.txt create mode 100644 drivers/pci/pci-uclass.c create mode 100644 drivers/pci/pci_compat.c
common/board_r.c +2 -0
@@ -224,7 +224,9 @@ static int initr_unlock_ram_in_cache(void)#ifdef CONFIG_PCI static int initr_pci (void ) { +#ifndef CONFIG_DM_PCI pci_init (); +#endif return 0 ; }
common/cmd_pci.c +11 -3
@@ -48,6 +48,7 @@ void pciinfo(int BusNum, int ShortPCIListing)unsigned char HeaderType;unsigned short VendorID;pci_dev_t dev; +int ret;if (!hose)return ;
@@ -74,7 +75,10 @@ void pciinfo(int BusNum, int ShortPCIListing)if (pci_skip_dev (hose, dev))continue ; -pci_read_config_word (dev,PCI_VENDOR_ID , &VendorID); + ret =pci_read_config_word (dev,PCI_VENDOR_ID , + &VendorID); +if (ret) + goto error;if ((VendorID ==0xFFFF ) || (VendorID ==0x0000 ))continue ;
@@ -91,8 +95,12 @@ void pciinfo(int BusNum, int ShortPCIListing) BusNum, Device, Function);pci_header_show (dev); } - } - } + } + } + +return ; +error: +printf ("Cannot read bus configuration: %d\n" , ret); }
doc/driver-model/pci-info.txt new file +70 -0
70 lines not on this page · raw message
drivers/pci/Kconfig +12 -0
@@ -0,0 +1,12 @@ +menu "PCI" + +config DM_PCI + bool "Enable driver mode for PCI" + depends on DM + help + Use driver model for PCI. Driver model is the new method for + orgnising devices in U-Boot. For PCI, driver model keeps track of + available PCI devices, allows scanning of PCI buses and provides + device configuration support. + +endmenu
drivers/pci/Makefile +7 -1
@@ -5,8 +5,14 @@ # SPDX-License-Identifier: GPL-2.0+ # +ifneq ($(CONFIG_DM_PCI),) +obj-$(CONFIG_PCI) += pci-uclass.o pci_compat.o +else +obj-$(CONFIG_PCI) += pci.o +endif +obj-$(CONFIG_PCI) += pci_common.o pci_auto.o pci_rom.o + obj-$(CONFIG_FSL_PCI_INIT) += fsl_pci_init.o -obj-$(CONFIG_PCI) += pci.o pci_common.o pci_auto.o pci_rom.o obj-$(CONFIG_PCI_INDIRECT_BRIDGE) += pci_indirect.o obj-$(CONFIG_PCI_GT64120) += pci_gt64120.o obj-$(CONFIG_PCI_MSC01) += pci_msc01.o
drivers/pci/pci-uclass.c new file +639 -0
639 lines not on this page · raw message
drivers/pci/pci_auto.c +13 -3
@@ -398,13 +398,20 @@ int pciauto_config_device(struct pci_controller *hose, pci_dev_t dev)switch (class) {case PCI_CLASS_BRIDGE_PCI : - hose->current_busno++; +DEBUGF ("PCI Autoconfig: Found P2P bridge, device %d\n" , +PCI_DEV (dev)); +pciauto_setup_device (hose, dev,2 , hose->pci_mem, hose->pci_prefetch, hose->pci_io); -DEBUGF ("PCI Autoconfig: Found P2P bridge, device %d\n" ,PCI_DEV (dev)); - +#ifdef CONFIG_DM_PCI + n =dm_pci_hose_probe_bus (hose, dev); +if (n <0 ) +return n; + sub_bus = (unsigned int )n; +#else /* Passing in current_busno allows for sibling P2P bridges */ + hose->current_busno++;pciauto_prescan_setup_bridge (hose, dev, hose->current_busno);/* * need to figure out if this is a subordinate bridge on the bus
@@ -417,6 +424,7 @@ int pciauto_config_device(struct pci_controller *hose, pci_dev_t dev)pciauto_postscan_setup_bridge (hose, dev, sub_bus); sub_bus = hose->current_busno; +#endif break ;case PCI_CLASS_STORAGE_IDE :
@@ -441,7 +449,9 @@ int pciauto_config_device(struct pci_controller *hose, pci_dev_t dev)DEBUGF ("PCI Autoconfig: Found P2CardBus bridge, device %d\n" ,PCI_DEV (dev)); +#ifndef CONFIG_DM_PCI hose->current_busno++; +#endif break ;#if defined(CONFIG_PCIAUTO_SKIP_HOST_BRIDGE )
drivers/pci/pci_compat.c new file +43 -0
43 lines not on this page · raw message
include/dm/uclass-id.h +2 -0
@@ -34,6 +34,8 @@ enum uclass_id {UCLASS_I2C_GENERIC ,/* Generic I2C device */ UCLASS_I2C_EEPROM ,/* I2C EEPROM device */ UCLASS_MOD_EXP ,/* RSA Mod Exp device */ +UCLASS_PCI ,/* PCI bus */ +UCLASS_PCI_GENERIC ,/* Generic PCI bus device */ UCLASS_COUNT , UCLASS_INVALID = -1,
include/pci.h +282 -7
348 lines not on this page · raw message
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 14/22 dm: sandbox: pci: Add PCI support for sandbox
In reply to Simon GlassAdd the required header information, device tree nodes and I/O accessor functions to support PCI on sandbox. All devices are emulated by drivers which can be added as required for testing or development.
---
arch/sandbox/Kconfig | 7 ++ arch/sandbox/cpu/cpu.c | 37 +++++++- arch/sandbox/dts/sandbox.dts | 22 ++++- 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 ++++++++++++++++++++++++++++++ 9 files changed, 281 insertions(+), 8 deletions(-) create mode 100644 arch/sandbox/include/asm/processor.h create mode 100644 arch/sandbox/lib/pci_io.c
arch/sandbox/Kconfig +7 -0
@@ -34,4 +34,11 @@ config DM_I2C config DM_TEST default y +config PCI + bool "PCI support" + help + Enable support for PCI (Peripheral Interconnect Bus), a type of bus + used on some devices to allow the CPU to communicate with its + peripherals. + endmenu
arch/sandbox/cpu/cpu.c +36 -1
@@ -2,7 +2,7 @@* Copyright (c) 2011 The Chromium OS Authors. * SPDX-License-Identifier: GPL-2.0+ */ - +#define DEBUG #include <common.h> #include <dm/root.h> #include <os.h>
@@ -10,6 +10,13 @@DECLARE_GLOBAL_DATA_PTR ; +/* Enable access to PCI memory with map_sysmem() */ +static bool enable_pci_map; + +/* Last device that was mapped into memory, and length of mapping */ +static struct udevice *map_dev; +unsigned long map_len; +void reset_cpu (ulong ignored) {if (state_uninit ())
@@ -59,9 +66,37 @@ int cleanup_before_linux(void)void *map_physmem (phys_addr_t paddr,unsigned long len,unsigned long flags) { +#ifdef CONFIG_PCI +unsigned long plen = len; +void *ptr; + + map_dev =NULL ; +if (enable_pci_map && !pci_map_physmem (paddr, &len, &map_dev, &ptr)) { +if (plen != len) { +printf ("%s: Warning: partial map at %x, wanted %lx, got %lx\n" , + __func__, paddr, len, plen); + } + map_len = len; +return ptr; + } +#endif +return (void *)(gd->arch.ram_buf + paddr); } +void unmap_physmem (const void *vaddr,unsigned long flags) +{ +if (map_dev) { +pci_unmap_physmem (vaddr, map_len, map_dev); + map_dev =NULL ; + } +} + +void sandbox_set_enable_pci_map (int enable) +{ + enable_pci_map = enable; +} +phys_addr_t map_to_sysmem (const void *ptr) {return (u8 *)ptr - gd->arch.ram_buf;
arch/sandbox/dts/sandbox.dts +21 -1
@@ -2,7 +2,11 @@ / { #address-cells = <1>; - #size-cells = <0>; + #size-cells = <1>; + + aliases { + pci0 = &pci; + }; chosen { stdout-path = "/serial";
@@ -181,4 +185,20 @@ }; }; + pci: pci-controller { + compatible = "sandbox,pci"; + device_type = "pci"; + #address-cells = <3>; + #size-cells = <2>; + ranges = <0x02000000 0 0x10000000 0x10000000 0 0x2000 + 0x01000000 0 0x20000000 0x20000000 0 0x2000>; + pci at 1f,0 { + compatible = "pci-generic"; + reg = <0xf800 0 0 0 0>; + emul at 1f,0 { + compatible = "sandbox,swap-case"; + }; + }; + }; + };
arch/sandbox/include/asm/io.h +12 -4
@@ -22,10 +22,7 @@ void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags);/* * Take down a mapping set up by map_physmem(). */ -static inline void unmap_physmem (void *vaddr,unsigned long flags) -{ - -} +void unmap_physmem (const void *vaddr,unsigned long flags);/* For sandbox, we want addresses to point into our RAM buffer */ static inline void *map_sysmem (phys_addr_t paddr,unsigned long len)
@@ -33,8 +30,10 @@ static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)return map_physmem (paddr, len,MAP_WRBACK ); } +/* Remove a previous mapping */ static inline void unmap_sysmem (const void *vaddr) { +unmap_physmem (vaddr,MAP_WRBACK ); }/* Map from a pointer to our RAM buffer */
@@ -48,6 +47,15 @@ phys_addr_t map_to_sysmem(const void *ptr);#define writew (v, addr)#define writel (v, addr) +/* I/O access functions */ +int inl (unsigned int addr); +int inw (unsigned int addr); +int inb (unsigned int addr); + +void outl (unsigned int value,unsigned int addr); +void outw (unsigned int value,unsigned int addr); +void outb (unsigned int value,unsigned int addr); +#include <iotrace.h> #endif
arch/sandbox/include/asm/processor.h new file +12 -0
@@ -0,0 +1,12 @@ +/* +* Copyright (c) 2014 Google, Inc +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef _ASM_PROCESSOR_H +#define _ASM_PROCESSOR_H + +/* This file is required for PCI */ + +#endif
arch/sandbox/include/asm/test.h +6 -1
@@ -10,7 +10,12 @@#define __ASM_TEST_H/* The sandbox driver always permits an I2C device with this address */ -#define SANDBOX_I2C_TEST_ADDR 0x59 +#define SANDBOX_I2C_TEST_ADDR 0x59 + +#define SANDBOX_PCI_VENDOR_ID 0x1234 +#define SANDBOX_PCI_DEVICE_ID 0x5678 +#define SANDBOX_PCI_CLASS_CODE PCI_CLASS_CODE_COMM +#define SANDBOX_PCI_CLASS_SUB_CODE PCI_CLASS_SUB_CODE_COMM_SERIALenum sandbox_i2c_eeprom_test_mode {SIE_TEST_MODE_NONE ,
arch/sandbox/include/asm/u-boot-sandbox.h +48 -0
52 lines not on this page · raw message
arch/sandbox/lib/Makefile +1 -1
@@ -7,5 +7,5 @@ # SPDX-License-Identifier: GPL-2.0+ # - obj-y += interrupts.o +obj-$(CONFIG_PCI) += pci_io.o
arch/sandbox/lib/pci_io.c new file +138 -0
138 lines not on this page · raw message
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 15/22 dm: sandbox: Add a simple PCI driver
In reply to Simon GlassAdd a driver which can access emulations of devices and make them available in sandbox.
---
drivers/pci/Kconfig | 10 ++++++ drivers/pci/Makefile | 1 + drivers/pci/pci_sandbox.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 drivers/pci/pci_sandbox.c
drivers/pci/Kconfig +10 -0
@@ -9,4 +9,14 @@ config DM_PCI available PCI devices, allows scanning of PCI buses and provides device configuration support. +config PCI_SANDBOX + bool "Sandbox PCI support" + depends on SANDBOX && DM_PCI + help + Support PCI on sandbox, as an emulated bus. This permits testing of + PCI feature such as bus scanning, device configuration and device + access. The available (emulated) devices are defined statically in + the device tree but the normal PCI scan technique is used to find + then. + endmenu
drivers/pci/Makefile +1 -0
@@ -7,6 +7,7 @@ ifneq ($(CONFIG_DM_PCI),) obj-$(CONFIG_PCI) += pci-uclass.o pci_compat.o +obj-$(CONFIG_PCI_SANDBOX) += pci_sandbox.o else obj-$(CONFIG_PCI) += pci.o endif
drivers/pci/pci_sandbox.c new file +79 -0
79 lines not on this page · raw message
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 16/22 dm: sandbox: pci: Add a PCI emulation uclass
In reply to Simon GlassSince sandbox does not have real devices (unless it borrows those from the host) it must use emulations. Provide a uclass which permits PCI operations to be passed through to an emulation device.
---
drivers/pci/Makefile | 1 + drivers/pci/pci-emul-uclass.c | 67 ++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/pci.h | 108 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 177 insertions(+) create mode 100644 drivers/pci/pci-emul-uclass.c
drivers/pci/Makefile +1 -0
@@ -8,6 +8,7 @@ ifneq ($(CONFIG_DM_PCI),) obj-$(CONFIG_PCI) += pci-uclass.o pci_compat.o obj-$(CONFIG_PCI_SANDBOX) += pci_sandbox.o +obj-$(CONFIG_SANDBOX) += pci-emul-uclass.o else obj-$(CONFIG_PCI) += pci.o endif
drivers/pci/pci-emul-uclass.c new file +67 -0
67 lines not on this page · raw message
include/dm/uclass-id.h +1 -0
@@ -20,6 +20,7 @@ enum uclass_id {UCLASS_TEST_BUS ,UCLASS_SPI_EMUL ,/* sandbox SPI device emulator */ UCLASS_I2C_EMUL ,/* sandbox I2C device emulator */ +UCLASS_PCI_EMUL ,/* sandbox PCI device emulator */ UCLASS_SIMPLE_BUS,/* U-Boot uclasses start here */
include/pci.h +108 -0
114 lines not on this page · raw message
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 17/22 dm: sandbox: Add a emulated PCI device as an example
In reply to Simon GlassThis device sits on the sandbox PCI bus and provides a case-swapping service for sandbox. It illustrates the use of both PCI I/O and PCI memory accesses.
---
drivers/misc/Makefile | 1 + drivers/misc/swap_case.c | 285 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 286 insertions(+) create mode 100644 drivers/misc/swap_case.c
drivers/misc/Makefile +1 -0
@@ -26,5 +26,6 @@ obj-$(CONFIG_SANDBOX) += i2c_eeprom_emul.o endif obj-$(CONFIG_SMSC_LPC47M) += smsc_lpc47m.o obj-$(CONFIG_STATUS_LED) += status_led.o +obj-$(CONFIG_SANDBOX) += swap_case.o obj-$(CONFIG_TWL4030_LED) += twl4030_led.o obj-$(CONFIG_FSL_IFC) += fsl_ifc.o
drivers/misc/swap_case.c new file +285 -0
285 lines not on this page · raw message
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 18/22 dm: sandbox: pci: Enable PCI for sandbox
In reply to Simon GlassEnable PCI options so that sandbox can be used for testing this bus with driver model.
---
configs/sandbox_defconfig | 3 +++ include/configs/sandbox.h | 4 ++++ 2 files changed, 7 insertions(+)
configs/sandbox_defconfig +3 -0
@@ -7,3 +7,6 @@ CONFIG_DM=y CONFIG_DEFAULT_DEVICE_TREE="sandbox" CONFIG_SYS_MALLOC_F=y CONFIG_SYS_MALLOC_F_LEN=0x400 +CONFIG_PCI=y +CONFIG_DM_PCI=y +CONFIG_PCI_SANDBOX=y
include/configs/sandbox.h +4 -0
@@ -34,6 +34,10 @@#define CONFIG_CMD_FDT #define CONFIG_ANDROID_BOOT_IMAGE +#define CONFIG_CMD_PCI +#define CONFIG_PCI_PNP +#define CONFIG_CMD_IO +#define CONFIG_FS_FAT #define CONFIG_FAT_WRITE #define CONFIG_FS_EXT4
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 19/22 dm: x86: pci: Add a PCI driver for driver model
In reply to Simon GlassAdd a simple x86 PCI driver which uses standard functions provided by the architecture.
---
arch/x86/cpu/pci.c | 40 ++++++++++++++++++++++++++++++++++++++++ arch/x86/include/asm/pci.h | 8 ++++++++ arch/x86/lib/Makefile | 2 ++ drivers/pci/Makefile | 1 + drivers/pci/pci_x86.c | 24 ++++++++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 drivers/pci/pci_x86.c
arch/x86/cpu/pci.c +40 -0
@@ -10,9 +10,11 @@*/ #include <common.h> +#include <dm.h> #include <errno.h> #include <malloc.h> #include <pci.h> +#include <asm/io.h> #include <asm/pci.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -111,3 +113,41 @@ void x86_pci_write_config32(pci_dev_t dev, unsigned where, unsigned value) {pci_hose_write_config_dword (get_hose (), dev, where, value); } + +int pci_x86_read_config (struct udevice *bus,pci_dev_t bdf,uint offset, +ulong *valuep,enum pci_size_t size) +{ +outl (bdf | (offset &0xfc ) |PCI_CFG_EN ,PCI_REG_ADDR ); +switch (size) { +case PCI_SIZE_8 : + *valuep =inb (PCI_REG_DATA + (offset &3 )); +break ; +case PCI_SIZE_16 : + *valuep =inw (PCI_REG_DATA + (offset &2 )); +break ; +case PCI_SIZE_32 : + *valuep =inl (PCI_REG_DATA ); +break ; + } + +return 0 ; +} + +int pci_x86_write_config (struct udevice *bus,pci_dev_t bdf,uint offset, +ulong value,enum pci_size_t size) +{ +outl (bdf | (offset &0xfc ) |PCI_CFG_EN ,PCI_REG_ADDR ); +switch (size) { +case PCI_SIZE_8 : +outb (value,PCI_REG_DATA + (offset &3 )); +break ; +case PCI_SIZE_16 : +outw (value,PCI_REG_DATA + (offset &2 )); +break ; +case PCI_SIZE_32 : +outl (value,PCI_REG_DATA ); +break ; + } + +return 0 ; +}
arch/x86/include/asm/pci.h +8 -0
@@ -8,6 +8,8 @@#ifndef _PCI_I386_H_#define _PCI_I386_H_ +#include <pci.h> +/* bus mapping constants (used for PCI core initialization) */ #define PCI_REG_ADDR 0xcf8#define PCI_REG_DATA 0xcfc
@@ -56,6 +58,12 @@ void x86_pci_write_config8(pci_dev_t dev, unsigned where, unsigned value);void x86_pci_write_config16 (pci_dev_t dev,unsigned where,unsigned value);void x86_pci_write_config32 (pci_dev_t dev,unsigned where,unsigned value); +int pci_x86_read_config (struct udevice *bus,pci_dev_t bdf,uint offset, +ulong *valuep,enum pci_size_t size); + +int pci_x86_write_config (struct udevice *bus,pci_dev_t bdf,uint offset, +ulong value,enum pci_size_t size); +#endif /* __ASSEMBLY__ */ #endif /* _PCI_I386_H_ */
arch/x86/lib/Makefile +2 -0
@@ -17,7 +17,9 @@ obj-y += interrupts.o obj-y += cmd_mtrr.o obj-$(CONFIG_SYS_PCAT_INTERRUPTS) += pcat_interrupts.o obj-$(CONFIG_SYS_PCAT_TIMER) += pcat_timer.o +ifndef CONFIG_DM_PCI obj-$(CONFIG_PCI) += pci_type1.o +endif obj-y += relocate.o obj-y += physmem.o obj-$(CONFIG_X86_RAMTEST) += ramtest.o
drivers/pci/Makefile +1 -0
@@ -9,6 +9,7 @@ ifneq ($(CONFIG_DM_PCI),) obj-$(CONFIG_PCI) += pci-uclass.o pci_compat.o obj-$(CONFIG_PCI_SANDBOX) += pci_sandbox.o obj-$(CONFIG_SANDBOX) += pci-emul-uclass.o +obj-$(CONFIG_X86) += pci_x86.o else obj-$(CONFIG_PCI) += pci.o endif
drivers/pci/pci_x86.c new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Copyright (c) 2015 Google, Inc +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <dm.h> +#include <pci.h> + +static const struct dm_pci_ops x86_pci_ops = { +}; + +static const struct udevice_id x86_pci_ids[] = { + { .compatible ="x86,pci" }, + { } +}; + +U_BOOT_DRIVER (pci_x86) = { + .name ="pci_x86" , + .id =UCLASS_PCI , + .of_match = x86_pci_ids, + .ops = &x86_pci_ops, +};
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 20/22 dm: x86: pci: Convert coreboot to use driver model for pci
In reply to Simon GlassMove coreboot-x86 over to driver model for PCI.
---
arch/x86/cpu/coreboot/pci.c | 63 ++++++++++--------------------------- arch/x86/dts/chromebook_link.dts | 7 +++++ board/google/chromebook_link/link.c | 9 ++++++ configs/coreboot-x86_defconfig | 1 + include/dm/uclass-id.h | 1 + 5 files changed, 34 insertions(+), 47 deletions(-)
arch/x86/cpu/coreboot/pci.c +16 -47
@@ -10,58 +10,27 @@*/ #include <common.h> +#include <dm.h> +#include <errno.h> #include <pci.h> +#include <asm/io.h> #include <asm/pci.h> DECLARE_GLOBAL_DATA_PTR ; -static void config_pci_bridge (struct pci_controller *hose,pci_dev_t dev, -struct pci_config_table *table) -{ -u8 secondary; - hose->read_byte (hose, dev,PCI_SECONDARY_BUS , &secondary); - hose->last_busno =max (hose->last_busno, (int )secondary); -pci_hose_scan_bus (hose, secondary); -} - -static struct pci_config_table pci_coreboot_config_table[] = { -/* vendor, device, class, bus, dev, func */ - {PCI_ANY_ID ,PCI_ANY_ID ,PCI_CLASS_BRIDGE_PCI , -PCI_ANY_ID ,PCI_ANY_ID ,PCI_ANY_ID , &config_pci_bridge }, - {} +static const struct dm_pci_ops pci_x86_ops = { + .read_config = pci_x86_read_config, + .write_config = pci_x86_write_config, }; -void board_pci_setup_hose (struct pci_controller *hose) -{ - hose->config_table = pci_coreboot_config_table; - hose->first_busno =0 ; - hose->last_busno =0 ; - -/* PCI memory space */ -pci_set_region (hose->regions +0 , -CONFIG_PCI_MEM_BUS , -CONFIG_PCI_MEM_PHYS , -CONFIG_PCI_MEM_SIZE , -PCI_REGION_MEM ); - -/* PCI IO space */ -pci_set_region (hose->regions +1 , -CONFIG_PCI_IO_BUS , -CONFIG_PCI_IO_PHYS , -CONFIG_PCI_IO_SIZE , -PCI_REGION_IO ); - -pci_set_region (hose->regions +2 , -CONFIG_PCI_PREF_BUS , -CONFIG_PCI_PREF_PHYS , -CONFIG_PCI_PREF_SIZE , -PCI_REGION_PREFETCH ); - -pci_set_region (hose->regions +3 , -0 , -0 , - gd->ram_size, -PCI_REGION_MEM |PCI_REGION_SYS_MEMORY ); +static const struct udevice_id pci_x86_ids[] = { + { .compatible ="pci-x86" }, + { } +}; - hose->region_count =4 ; -} +U_BOOT_DRIVER (pci_x86_drv) = { + .name ="pci_x86" , + .id =UCLASS_PCI , + .of_match = pci_x86_ids, + .ops = &pci_x86_ops, +};
arch/x86/dts/chromebook_link.dts +7 -0
@@ -172,6 +172,13 @@ }; pci { + compatible = "intel,pci-ivybridge", "pci-x86"; + #address-cells = <3>; + #size-cells = <2>; + u-boot,dm-pre-reloc; + ranges = <0x02000000 0x0 0xe0000000 0xe0000000 0 0x10000000 + 0x42000000 0x0 0xd0000000 0xd0000000 0 0x10000000 + 0x01000000 0x0 0x1000 0x1000 0 0xefff>; sata { compatible = "intel,pantherpoint-ahci"; intel,sata-mode = "ahci";
board/google/chromebook_link/link.c +9 -0
@@ -6,6 +6,7 @@#include <common.h> #include <cros_ec.h> +#include <dm.h> #include <asm/gpio.h> #include <asm/io.h> #include <asm/pci.h>
@@ -13,6 +14,14 @@int arch_early_init_r (void ) { +struct udevice *dev; +int ret; + +/* Make sure the platform controller hub is up and running */ + ret =uclass_get_device (UCLASS_PCH ,0 , &dev); +if (ret) +return ret; +if (cros_ec_board_init ())return -1 ;
configs/coreboot-x86_defconfig +1 -0
@@ -2,3 +2,4 @@ CONFIG_SYS_EXTRA_OPTIONS="SYS_TEXT_BASE=0x01110000" CONFIG_X86=y CONFIG_TARGET_COREBOOT=y CONFIG_OF_CONTROL=y +CONFIG_DM_PCI=y
include/dm/uclass-id.h +1 -0
@@ -37,6 +37,7 @@ enum uclass_id {UCLASS_MOD_EXP ,/* RSA Mod Exp device */ UCLASS_PCI ,/* PCI bus */ UCLASS_PCI_GENERIC ,/* Generic PCI bus device */ +UCLASS_PCH ,/* x86 platform controller hub */ UCLASS_COUNT , UCLASS_INVALID = -1,
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 21/22 dm: x86: pci: Convert chromebook_link to use driver model for pci
In reply to Simon GlassMove chromebook_link over to driver model for PCI.
This involves:
- adding a uclass for platform controller hub
- removing most of the existing PCI driver
- adjusting how CPU init works to use driver model instead
- rename the lpc compatible string (it will be removed later)
This does not really take advantage of driver model fully, but it does work. Furture work will improve the code structure to remove many of the explicit calls to init the board.
---
arch/x86/cpu/ivybridge/bd82x6x.c | 24 +++++++- arch/x86/cpu/ivybridge/cpu.c | 16 +++--- arch/x86/cpu/ivybridge/lpc.c | 1 + arch/x86/cpu/ivybridge/pci.c | 81 ++++++++------------------- arch/x86/dts/chromebook_link.dts | 3 +- arch/x86/include/asm/arch-ivybridge/bd82x6x.h | 1 - configs/chromebook_link_defconfig | 1 + configs/chromebox_panther_defconfig | 1 + lib/fdtdec.c | 2 +- 9 files changed, 62 insertions(+), 68 deletions(-)
arch/x86/cpu/ivybridge/bd82x6x.c +23 -1
@@ -5,6 +5,7 @@*/ #include <common.h> +#include <dm.h> #include <errno.h> #include <fdtdec.h> #include <malloc.h>
@@ -86,7 +87,7 @@ void bd82x6x_pci_bus_enable_resources(pci_dev_t dev)bd82x6x_pci_dev_enable_resources (dev); } -int bd82x6x_init_pci_devices (void ) +static int bd82x6x_probe (struct udevice *dev) {const void *blob = gd->fdt_blob;struct pci_controller *hose;
@@ -144,3 +145,24 @@ int bd82x6x_init(void)return 0 ; } + +static const struct udevice_id bd82x6x_ids[] = { + { .compatible ="intel,bd82x6x" }, + { } +}; + +U_BOOT_DRIVER (bd82x6x_drv) = { + .name ="bd82x6x" , + .id =UCLASS_PCH , + .of_match = bd82x6x_ids, + .probe = bd82x6x_probe, +}; + +/* +* TODO(sjg at chromium.org): Move this to arch/x86/lib or similar when other +* boards also use a PCH +*/ +UCLASS_DRIVER (pch) = { + .id =UCLASS_PCH , + .name ="pch" , +};
arch/x86/cpu/ivybridge/cpu.c +9 -7
@@ -12,6 +12,7 @@*/ #include <common.h> +#include <dm.h> #include <errno.h> #include <fdtdec.h> #include <asm/cpu.h>
@@ -126,19 +127,20 @@ int x86_post_cpu_init(void) {const void *blob = gd->fdt_blob;struct pci_controller *hose; +struct udevice *bus;int node;int ret; -post_code (POST_CPU_INIT ); -timer_set_base (rdtsc ()); - - ret =x86_cpu_init_f (); +post_code (0x70 ); + ret =uclass_get_device (UCLASS_PCI ,0 , &bus); +post_code (0x71 );if (ret)return ret; +post_code (0x72 ); + hose =dev_get_uclass_priv (bus); - ret =pci_early_init_hose (&hose); -if (ret) -return ret; +/* TODO(sjg at chromium.org): Get rid of gd->hose */ + gd->hose = hose; node =fdtdec_next_compatible (blob,0 ,COMPAT_INTEL_LPC );if (node <0 )
arch/x86/cpu/ivybridge/lpc.c +1 -0
@@ -7,6 +7,7 @@*/ #include <common.h> +#include <dm.h> #include <errno.h> #include <fdtdec.h> #include <rtc.h>
arch/x86/cpu/ivybridge/pci.c +24 -57
106 lines not on this page · raw message
arch/x86/dts/chromebook_link.dts +2 -1
@@ -200,7 +200,8 @@ }; lpc { - compatible = "intel,lpc"; + reg = <0x0000f800 0 0 0 0>; + compatible = "intel,bd82x6x"; #address-cells = <1>; #size-cells = <1>; gen-dec = <0x800 0xfc 0x900 0xfc>;
arch/x86/include/asm/arch-ivybridge/bd82x6x.h +0 -1
@@ -12,7 +12,6 @@ void bd82x6x_sata_enable(pci_dev_t dev, const void *blob, int node);void bd82x6x_pci_init (pci_dev_t dev);void bd82x6x_usb_ehci_init (pci_dev_t dev);void bd82x6x_usb_xhci_init (pci_dev_t dev); -int bd82x6x_init_pci_devices (void );int gma_func0_init (pci_dev_t dev,struct pci_controller *hose,const void *blob,int node);int bd82x6x_init (void );
configs/chromebook_link_defconfig +1 -0
@@ -9,3 +9,4 @@ CONFIG_SMM_TSEG_SIZE=0x800000 CONFIG_VIDEO_VESA=y CONFIG_FRAMEBUFFER_SET_VESA_MODE=y CONFIG_FRAMEBUFFER_VESA_MODE_11A=y +CONFIG_DM_PCI=y
configs/chromebox_panther_defconfig +1 -0
@@ -9,3 +9,4 @@ CONFIG_SMM_TSEG_SIZE=0x800000 CONFIG_VIDEO_VESA=y CONFIG_FRAMEBUFFER_SET_VESA_MODE=y CONFIG_FRAMEBUFFER_VESA_MODE_11A=y +CONFIG_DM_PCI=y
lib/fdtdec.c +1 -1
@@ -67,7 +67,7 @@ static const char * const compat_names[COMPAT_COUNT] = {COMPAT (COMPAT_NXP_PTN3460 ,"nxp,ptn3460" ),COMPAT (SAMSUNG_EXYNOS_SYSMMU ,"samsung,sysmmu-v3.3" ),COMPAT (PARADE_PS8625 ,"parade,ps8625" ), -COMPAT (COMPAT_INTEL_LPC ,"intel,lpc" ), +COMPAT (COMPAT_INTEL_LPC ,"intel,bd82x6x" ),COMPAT (INTEL_MICROCODE ,"intel,microcode" ),COMPAT (MEMORY_SPD ,"memory-spd" ), COMPAT(INTEL_PANTHERPOINT_AHCI, "intel,pantherpoint-ahci"),
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH 22/22 dm: pci: Add driver model tests for PCI
In reply to Simon GlassAdd some basic tests to check that things work as expected with sandbox.
---
test/dm/Makefile | 1 + test/dm/pci.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/dm/test.dts | 17 ++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 test/dm/pci.c
test/dm/Makefile +1 -0
@@ -21,4 +21,5 @@ obj-$(CONFIG_DM_GPIO) += gpio.o obj-$(CONFIG_DM_SPI) += spi.o obj-$(CONFIG_DM_SPI_FLASH) += sf.o obj-$(CONFIG_DM_I2C) += i2c.o +obj-$(CONFIG_DM_PCI) += pci.o endif
test/dm/pci.c new file +59 -0
59 lines not on this page · raw message
test/dm/test.dts +17 -0
@@ -10,6 +10,7 @@ console = &uart0; i2c0 = "/i2c at 0"; spi0 = "/spi at 0"; + pci0 = &pci; testfdt6 = "/e-test"; testbus3 = "/some-bus"; testfdt0 = "/some-bus/c-test at 0";
@@ -135,6 +136,22 @@ }; }; + pci: pci-controller { + compatible = "sandbox,pci"; + device_type = "pci"; + #address-cells = <3>; + #size-cells = <2>; + ranges = <0x02000000 0 0x10000000 0x10000000 0 0x2000 + 0x01000000 0 0x20000000 0x20000000 0 0x2000>; + pci at 1f,0 { + compatible = "pci-generic"; + reg = <0xf800 0 0 0 0>; + emul at 1f,0 { + compatible = "sandbox,swap-case"; + }; + }; + }; + spi at 0 { #address-cells = <1>; #size-cells = <0>;
Signature · 1 line
2.2.0.rc0.207.ga3a616c