mirror_ubuntu-kernels/include/linux/platform_data
Jonathan Yong 9745fb0747 platform/x86/intel: Add Primary to Sideband (P2SB) bridge support
SoC features such as GPIO are accessed via a reserved MMIO area,
we don't know its address but can obtain it from the BAR of
the P2SB device, that device is normally hidden so we have to
temporarily unhide it, read address and hide it back.

There are already a few users and at least one more is coming which
require an access to Primary to Sideband (P2SB) bridge in order
to get IO or MMIO BAR hidden by BIOS.

Create a library to access P2SB for x86 devices in a unified way.

Background information
======================
Note, the term "bridge" is used in the documentation and it has nothing
to do with a PCI (host) bridge as per the PCI specifications.

The P2SB is an interesting device by its nature and hardware design.
First of all, it has several devices in the hardware behind it. These
devices may or may not be represented as ACPI devices by a firmware.

It also has a hardwired (to 0s) the least significant bits of the
base address register which is represented by the only 64-bit BAR0.
It means that OS mustn't reallocate the BAR.

On top of that in some cases P2SB is represented by function 0 on PCI
slot (in terms of B:D.F) and according to the PCI specification any
other function can't be seen until function 0 is present and visible.

In the PCI configuration space of P2SB device the full 32-bit register
is allocated for the only purpose of hiding the entire P2SB device. As
per [3]:

  3.1.39 P2SB Control (P2SBC)—Offset E0h

  Hide Device (HIDE): When this bit is set, the P2SB will return 1s on
  any PCI Configuration Read on IOSF-P. All other transactions including
  PCI Configuration Writes on IOSF-P are unaffected by this. This does
  not affect reads performed on the IOSF-SB interface.

This doesn't prevent MMIO accesses, although preventing the OS from
assigning these addresses. The firmware on the affected platforms marks
the region as unusable (by cutting it off from the PCI host bridge
resources) as depicted in the Apollo Lake example below:

  PCI host bridge to bus 0000:00
  pci_bus 0000:00: root bus resource [io  0x0070-0x0077]
  pci_bus 0000:00: root bus resource [io  0x0000-0x006f window]
  pci_bus 0000:00: root bus resource [io  0x0078-0x0cf7 window]
  pci_bus 0000:00: root bus resource [io  0x0d00-0xffff window]
  pci_bus 0000:00: root bus resource [mem 0x7c000001-0x7fffffff window]
  pci_bus 0000:00: root bus resource [mem 0x7b800001-0x7bffffff window]
  pci_bus 0000:00: root bus resource [mem 0x80000000-0xcfffffff window]
  pci_bus 0000:00: root bus resource [mem 0xe0000000-0xefffffff window]
  pci_bus 0000:00: root bus resource [bus 00-ff]

The P2SB 16MB BAR is located at 0xd0000000-0xd0ffffff memory window.

The generic solution
====================
The generic solution for all cases when we need to access to the information
behind P2SB device is a library code where users ask for necessary resources
by demand and hence those users take care of not being run on the systems
where this access is not required.

The library provides the p2sb_bar() API to retrieve the MMIO of the BAR0 of
the device from P2SB device slot.

P2SB unconditional unhiding awareness
=====================================
Technically it's possible to unhide the P2SB device and devices on
the same PCI slot and access them at any time as needed. But there are
several potential issues with that:

 - the systems were never tested against such configuration and hence
   nobody knows what kind of bugs it may bring, especially when we talk
   about SPI NOR case which contains Intel FirmWare Image (IFWI) code
   (including BIOS) and already known to be problematic in the past for
   end users

 - the PCI by its nature is a hotpluggable bus and in case somebody
   attaches a driver to the functions of a P2SB slot device(s) the
   end user experience and system behaviour can be unpredictable

 - the kernel code would need some ugly hacks (or code looking as an
   ugly hack) under arch/x86/pci in order to enable these devices on
   only selected platforms (which may include CPU ID table followed by
   a potentially growing number of DMI strings

The future improvements
=======================
The future improvements with this code may go in order to gain some kind
of cache, if it's possible at all, to prevent unhiding and hiding many
times to take static information that may be saved once per boot.

Links
=====
[1]: https://lab.whitequark.org/notes/2017-11-08/accessing-intel-ich-pch-gpios/
[2]: https://cdrdv2.intel.com/v1/dl/getContent/332690?wapkw=332690
[3]: https://cdrdv2.intel.com/v1/dl/getContent/332691?wapkw=332691
[4]: https://medium.com/@jacksonchen_43335/bios-gpio-p2sb-70e9b829b403

Signed-off-by: Jonathan Yong <jonathan.yong@intel.com>
Co-developed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Henning Schild <henning.schild@siemens.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee@kernel.org>
2022-07-14 10:48:27 +01:00
..
gpio platform/x86: pcengines-apuv2: Fix typo on define of AMD_FCH_GPIO_REG_GPIO55_DEVSLP0 2020-09-24 14:04:53 +03:00
media media: camera-mx3: Remove unused header file 2021-03-22 11:58:22 +01:00
txx9
x86 platform/x86/intel: Add Primary to Sideband (P2SB) bridge support 2022-07-14 10:48:27 +01:00
ad5449.h
ad5761.h mailmap: change email for Ricardo Ribalda 2020-05-25 18:59:59 -06:00
ad7266.h iio: ad7266: Convert to use GPIO descriptors 2019-12-15 11:42:16 +00:00
ad7791.h
ad7793.h platform_data: ad7793.h: drop a duplicated word 2020-08-22 10:53:23 +01:00
ad7887.h iio: adc: ad7887: invert/rework external ref logic 2020-10-10 17:38:36 +01:00
adau17x1.h
adp5588.h
adp8860.h
adp8870.h
ads7828.h
ams-delta-fiq.h
apds990x.h
arm-ux500-pm.h
asoc-imx-ssi.h
asoc-kirkwood.h
asoc-palm27x.h
asoc-poodle.h ARM: pxa: poodle: use platform data for poodle asoc driver 2022-05-07 22:55:47 +02:00
asoc-pxa.h ARM: pxa: move mach/sound.h to linux/platform_data/ 2022-04-19 16:28:41 +02:00
asoc-s3c24xx_simtec.h
asoc-s3c.h
asoc-ti-mcbsp.h
asoc-ux500-msp.h
ata-pxa.h
ata-samsung_cf.h
atmel.h pcmcia: at91_cf: move definitions locally 2020-11-27 22:25:07 +01:00
b53.h net: dsa: b53: Platform data shan't include kernel.h 2020-02-05 14:00:05 +01:00
bcm7038_wdt.h watchdog: bcm7038_wdt: Support platform data configuration 2021-12-28 13:59:07 +01:00
bcmgenet.h
bd6107.h backlight: bd6107: Convert to use GPIO descriptor 2019-12-16 10:32:27 +00:00
bh1770glc.h
brcmfmac.h treewide: Replace zero-length arrays with flexible-array members 2022-02-17 07:00:39 -06:00
brcmnand.h mtd: rawnand: brcmnand: Add platform data structure for BCMA 2022-01-23 16:37:18 +01:00
clk-da8xx-cfgchip.h
clk-davinci-pll.h
clk-fch.h ACPI: APD: Add a fmw property clk-name 2022-01-06 17:57:52 -08:00
clk-s3c2410.h ARM: s3c24xx: pass pointer to clk driver via platform data 2020-08-19 20:58:10 +02:00
cpuidle-exynos.h
cros_ec_chardev.h platform/chrome: cros_ec_chardev: Add a poll handler to receive MKBP events 2019-09-12 16:20:54 +02:00
cros_ec_commands.h platform/chrome: cros_ec_lpcs: reserve the MEC LPC I/O ports first 2022-05-03 13:43:21 +08:00
cros_ec_proto.h platform/chrome: Re-introduce cros_ec_cmd_xfer and use it for ioctls 2022-04-19 11:27:20 +08:00
cros_ec_sensorhub.h platform/chrome: cros_ec_sensorhub: Allocate sensorhub resource before claiming sensors 2020-04-29 23:17:45 +02:00
cros_usbpd_notify.h platform: chrome: Add cros-usbpd-notify driver 2020-02-10 10:14:19 -08:00
crypto-ux500.h
cyttsp4.h
davinci_asp.h ASoC: ti: davinci-mcasp: Add support for the OMAP4 version of McASP 2021-07-11 23:46:39 +01:00
davinci-cpufreq.h include/: replace HTTP links with HTTPS ones 2020-08-12 10:57:59 -07:00
dma-dw.h dmaengine: dw: Convert members to u32 in platform data 2021-08-06 19:18:35 +05:30
dma-ep93xx.h
dma-hsu.h
dma-iop32x.h dma: iop-adma: allow building without platform headers 2019-08-14 15:36:22 +02:00
dma-mcf-edma.h
dma-mmp_tdma.h
dma-mv_xor.h
dma-s3c24xx.h
dma-ste-dma40.h
dmtimer-omap.h clocksource/drivers/timer-ti-dm: Enable autoreload in set_pwm 2020-03-16 12:40:51 +01:00
ds620.h
dsa.h
edma.h
elm.h include/: replace HTTP links with HTTPS ones 2020-08-12 10:57:59 -07:00
emif_plat.h
eth-ep93xx.h
fb-s3c2410.h fbdev: s3c2410fb: remove mach header dependency 2020-08-20 17:48:12 +02:00
g762.h
gpio_backlight.h backlight: gpio: Remove unused fields from platform data 2019-11-11 11:34:01 +00:00
gpio-ath79.h
gpio-davinci.h include/: replace HTTP links with HTTPS ones 2020-08-12 10:57:59 -07:00
gpio-htc-egpio.h gpio: htc-egpio: Remove unused exported htc_egpio_get_wakeup_irq() 2019-09-12 10:07:44 +01:00
gpio-omap.h gpio: omap: Save and restore sysconfig 2021-04-21 16:43:51 +02:00
gpmc-omap.h include/: replace HTTP links with HTTPS ones 2020-08-12 10:57:59 -07:00
gsc_hwmon.h hwmon: (gsc-hwmon) add fan sensor 2020-09-23 09:42:41 -07:00
hirschmann-hellcreek.h net: dsa: hellcreek: Report switch name and ID 2021-03-22 18:02:10 -07:00
hsmmc-omap.h mmc: host: omap-hsmmc: remove init_card pdata callback from pdata 2019-11-15 09:59:19 +01:00
hwmon-s3c.h
i2c-davinci.h
i2c-gpio.h
i2c-imx.h
i2c-mux-gpio.h
i2c-mux-reg.h
i2c-ocores.h
i2c-omap.h
i2c-pca-platform.h
i2c-pxa.h i2c: pxa: move private definitions to i2c-pxa.c 2020-05-05 14:50:41 +02:00
i2c-s3c2410.h
i2c-xiic.h
ina2xx.h
intel-mid_wdt.h
invensense_mpu6050.h iio:imu:mpu6050: Modify matricies to matrices 2021-03-29 11:06:01 +01:00
iommu-omap.h iommu/omap: add pdata ops for omap_device_enable/idle 2019-08-09 17:37:09 +02:00
irda-pxaficp.h
irda-sa11x0.h
isl9305.h
itco_wdt.h platform/x86: intel_pmc_ipc: Convert to MFD 2020-04-24 11:18:44 +01:00
keyboard-pxa930_rotary.h
keyboard-spear.h
keypad-ep93xx.h
keypad-nomadik-ske.h
keypad-omap.h
keypad-pxa27x.h
keyscan-davinci.h
lcd-mipid.h
leds-lm355x.h
leds-lm3642.h
leds-lp55xx.h leds: lp55xx: Add multicolor framework support to lp55xx 2020-07-22 14:42:06 +02:00
leds-omap.h
leds-s3c24xx.h ARM: s3c24xx: leds: Convert to use GPIO descriptors 2020-07-09 09:56:14 +02:00
lm3630a_bl.h
lm3639_bl.h
lm8323.h
lp855x.h
lp8727.h
lp8755.h
ltc4245.h
lv5207lp.h
max197.h
max732x.h gpio: max732x: Drop unused support for irq and setup code via platform data 2022-05-05 14:37:17 +02:00
max3421-hcd.h
max6639.h
max6697.h
mcs.h
mdio-bcm-unimac.h
mdio-gpio.h
mfd-mcp-sa11x0.h
microchip-ksz.h net: dsa: microchip: Platform data shan't include kernel.h 2020-02-05 14:00:05 +01:00
mlxcpld.h i2c: mux: mlxcpld: Add callback to notify mux creation completion 2021-02-09 11:35:44 +01:00
mlxreg.h platform_data/mlxreg: Add field for notification callback 2022-05-11 16:32:30 +02:00
mmc-davinci.h
mmc-esdhc-mcf.h m68k: mcf5441x: add support for esdhc mmc controller 2020-05-28 11:22:15 +02:00
mmc-mxcmmc.h
mmc-omap.h mmc: omap: remove unused struct component card_detect_irq 2021-02-01 11:54:44 +01:00
mmc-pxamci.h
mmc-s3cmci.h ARM: s3c24xx: move s3cmci pinctrl handling into board files 2020-08-20 17:42:21 +02:00
mmc-sdhci-s3c.h
mmp_audio.h
mmp_dma.h
mouse-pxa930_trkball.h
mtd-davinci-aemif.h include/: replace HTTP links with HTTPS ones 2020-08-12 10:57:59 -07:00
mtd-davinci.h mtd: rawnand: Use the new ECC engine type enumeration 2020-09-28 15:59:42 +02:00
mtd-nand-omap2.h Memory controller drivers for v5.17 - OMAP GPMC 2021-12-31 12:45:57 +01:00
mtd-nand-pxa3xx.h
mtd-nand-s3c2410.h mtd: rawnand: Use the new ECC engine type enumeration 2020-09-28 15:59:42 +02:00
mtd-orion_nand.h
mv88e6xxx.h
mv_usb.h USB: EHCI: ehci-mv: drop pxa_ehci_type and some device IDs 2019-12-30 20:11:29 +01:00
net-cw1200.h
nfcmrvl.h
omap1_bl.h
omap-twl4030.h include/: replace HTTP links with HTTPS ones 2020-08-12 10:57:59 -07:00
omap-wd-timer.h
omapdss.h
pca953x.h
pcf857x.h gpio: pcf857x: Make teardown callback return void 2022-04-25 20:55:39 +02:00
phy-da8xx-usb.h
pinctrl-single.h
pm33xx.h soc: ti: pm33xx: Simplify RTC usage to prepare to drop platform data 2020-08-24 08:38:32 +03:00
pxa2xx_udc.h
pxa_sdhci.h
regulator-haptic.h
rtc-ds2404.h
rtc-v3020.h
s3c-hsotg.h
s3c-hsudc.h usb: gadget: s3c-hsudc: remove platform header dependency 2020-08-19 20:58:27 +02:00
sa11x0-serial.h
sc18is602.h
sdhci-pic32.h
serial-omap.h
serial-sccnxp.h
sgi-w1.h w1: add 1-wire master driver for IP block found in SGI ASICs 2019-09-04 14:34:31 +02:00
sh_mmcif.h mmc: sh_mmcif: move platform_data header to proper location 2022-04-26 14:05:21 +02:00
shmob_drm.h drm: shmobile: Reduce include dependencies 2020-10-13 17:15:43 +03:00
sht3x.h
shtc1.h
si5351.h
simplefb.h video: fbdev: simplefb: Add "r5g5b5a1" mode 2021-01-20 12:12:22 +01:00
spi-davinci.h
spi-ep93xx.h
spi-mt65xx.h spi: mediatek: add tick_delay support 2021-07-14 13:30:43 +01:00
spi-omap2-mcspi.h spi: spi-omap2-mcspi: Handle DMA size restriction on AM65x 2020-02-06 15:53:40 +00:00
spi-s3c64xx.h spi: s3c64xx: Convert to use GPIO descriptors 2022-01-24 13:37:33 +00:00
ssm2518.h
st33zp24.h
st_sensors_pdata.h iio: magnetometer: st_magn: Provide default platform data 2021-05-17 13:54:22 +01:00
syscon.h
tda9950.h
ti-aemif.h
ti-prm.h soc: ti: omap-prm: add support for denying idle for reset clockdomain 2019-10-09 08:55:38 -07:00
ti-sysc.h bus: ti-sysc: Handle otg force idle quirk 2021-09-21 12:56:14 +03:00
touchscreen-s3c2410.h
tps68470.h platform_data: Add linux/platform_data/tps68470.h file 2021-12-13 11:44:48 +01:00
tsc2007.h
tsl2563.h
tsl2772.h
uio_dmem_genirq.h
uio_pruss.h include/: replace HTTP links with HTTPS ones 2020-08-12 10:57:59 -07:00
usb3503.h usb: usb3503: Convert to use GPIO descriptors 2019-12-30 20:40:19 +01:00
usb-davinci.h
usb-ehci-orion.h
usb-musb-ux500.h
usb-ohci-pxa27x.h
usb-ohci-s3c2410.h
usb-omap1.h ARM: omap1: innovator: move ohci phy power handling to board file 2022-04-21 15:01:44 +02:00
usb-omap.h include/: replace HTTP links with HTTPS ones 2020-08-12 10:57:59 -07:00
usb-pxa3xx-ulpi.h
usb-s3c2410_udc.h
video_s3c.h
video-ep93xx.h
video-imxfb.h
video-mx3fb.h
video-pxafb.h ARM: pxa: move regs-lcd.h into driver 2022-04-19 16:29:03 +02:00
voltage-omap.h
wilco-ec.h platform_data: wilco-ec.h: Replace zero-length array with flexible-array member 2020-04-18 15:44:55 -05:00
wiznet.h
wkup_m3.h
xilinx-ll-temac.h
xtalk-bridge.h
zforce_ts.h