mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-08-22 00:42:01 +02:00

-----BEGIN PGP SIGNATURE----- iQJIBAABCgAyFiEEgMe7l+5h9hnxdsnuWYigwDrT+vwFAmbseugUHGJoZWxnYWFz QGdvb2dsZS5jb20ACgkQWYigwDrT+vxdwxAAvdvDyTuiPo2R8pQtvKg4YL2IUnK5 UR28mBxZDK5DFhLtD/QzmVVG/eaLY6bJHthHgJgTApzekkqU0h9dcRI0eegXrvcz I3HRsZK2yatUky9l8O148OLzF897r7vXL3QtGe6qjKU+9D83IEeooLKgBca+GoBC bRLvG/fYRzdjOe8UHFqCoeMIg3IOY7CNifvFOihAGpJpxfZQktj6hSKu6q7BL1Rx NRgYlxh0eLcb7vAJqz6RZpQ8PRCwhAjlDuu0BOkES8/6EwisD1xUh3qdDxfVgNA6 FpcAb/53yr46cs4tM9ZTwluka86AskuXj3jwSKf7nE3zqr4nM9OD3sGOSYzK8UdE EDBKj+9iEpYRC6rJMk5gNH2AZkR1OEpNUisR6+kEn81A9yNNoTmkHdHUOWo8TuxD btc0sTM+eWApvTiZwgL4VjMZulQllV51K8tcfvODRhlMkbOPNWGWdmpWqEbUS2HU i7+zzQC3DC5iPlAKgRSeYB0aad6la6brqPW16sGhGovNhgwbzakDLCUJJGn/LNuO wd0UNpJTnHlfChbvNh2bBxiMOo0cab1tJ5Jp97STQYhLg2nW93s/dAfdpSAsYO4S 5YzjSADWeyeuDsHE1RdUdDvYAPMb1VZBUd2OSHis5zw7kmh25c9KYXEkDJ25q/ju sVXK4oMNW/Gnd5M= =L3s9 -----END PGP SIGNATURE----- Merge tag 'pci-v6.12-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci Pull pci updates from Bjorn Helgaas: "Enumeration: - Wait for device readiness after reset by polling Vendor ID and looking for Configuration RRS instead of polling the Command register and looking for non-error completions, to avoid hardware retries done for RRS on non-Vendor ID reads (Bjorn Helgaas) - Rename CRS Completion Status to RRS ('Request Retry Status') to match PCIe r6.0 spec usage (Bjorn Helgaas) - Clear LBMS bit after a manual link retrain so we don't try to retrain a link when there's no downstream device anymore (Maciej W. Rozycki) - Revert to the original link speed after retraining fails instead of leaving it restricted to 2.5GT/s, so a future device has a chance to use higher speeds (Maciej W. Rozycki) - Wait for each level of downstream bus, not just the first, to become accessible before restoring devices on that bus (Ilpo Järvinen) - Add ARCH_PCI_DEV_GROUPS so s390 can add its own attribute_groups without having to stomp on the core's pdev->dev.groups (Lukas Wunner) Driver binding: - Export pcim_request_region(), a managed counterpart of pci_request_region(), for use by drivers (Philipp Stanner) - Export pcim_iomap_region() and deprecate pcim_iomap_regions() (Philipp Stanner) - Request the PCI BAR used by xboxvideo (Philipp Stanner) - Request and map drm/ast BARs with pcim_iomap_region() (Philipp Stanner) MSI: - Add MSI_FLAG_NO_AFFINITY flag for devices that mux MSIs onto a single IRQ line and cannot set the affinity of each MSI to a specific CPU core (Marek Vasut) - Use MSI_FLAG_NO_AFFINITY and remove unnecessary .irq_set_affinity() implementations in aardvark, altera, brcmstb, dwc, mediatek-gen3, mediatek, mobiveil, plda, rcar, tegra, vmd, xilinx-nwl, xilinx-xdma, and xilinx drivers to avoid 'IRQ: set affinity failed' warnings (Marek Vasut) Power management: - Add pwrctl support for ATH11K inside the WCN6855 package (Konrad Dybcio) PCI device hotplug: - Remove unnecessary hpc_ops struct from shpchp (ngn) - Check for PCI_POSSIBLE_ERROR(), not 0xffffffff, in cpqphp (weiyufeng) Virtualization: - Mark Creative Labs EMU20k2 INTx masking as broken (Alex Williamson) - Add an ACS quirk for Qualcomm SA8775P, which doesn't advertise ACS but does provide ACS-like features (Subramanian Ananthanarayanan) IOMMU: - Add function 0 DMA alias quirk for Glenfly Arise audio function, which uses the function 0 Requester ID (WangYuli) NPEM: - Add Native PCIe Enclosure Management (NPEM) support for sysfs control of NVMe RAID storage indicators (ok/fail/locate/ rebuild/etc) (Mariusz Tkaczyk) - Add support for the ACPI _DSM PCIe SSD status LED management, which is functionally similar to NPEM but mediated by platform firmware (Mariusz Tkaczyk) Device trees: - Drop minItems and maxItems from ranges in PCI generic host binding since host bridges may have several MMIO and I/O port apertures (Frank Li) - Add kirin, rcar-gen2, uniphier DT binding top-level constraints for clocks (Krzysztof Kozlowski) Altera PCIe controller driver: - Convert altera DT bindings from text to YAML (Matthew Gerlach) - Replace TLP_REQ_ID() with macro PCI_DEVID(), which does the same thing and is what other drivers use (Jinjie Ruan) Broadcom STB PCIe controller driver: - Add DT binding maxItems for reset controllers (Jim Quinlan) - Use the 'bridge' reset method if described in the DT (Jim Quinlan) - Use the 'swinit' reset method if described in the DT (Jim Quinlan) - Add 'has_phy' so the existence of a 'rescal' reset controller doesn't imply software control of it (Jim Quinlan) - Add support for many inbound DMA windows (Jim Quinlan) - Rename SoC 'type' to 'soc_base' express the fact that SoCs come in families of multiple similar devices (Jim Quinlan) - Add Broadcom 7712 DT description and driver support (Jim Quinlan) - Sort enums, pcie_offsets[], pcie_cfg_data, .compatible strings for maintainability (Bjorn Helgaas) Freescale i.MX6 PCIe controller driver: - Add imx6q-pcie 'dbi2' and 'atu' reg-names for i.MX8M Endpoints (Richard Zhu) - Fix a code restructuring error that caused i.MX8MM and i.MX8MP Endpoints to fail to establish link (Richard Zhu) - Fix i.MX8MP Endpoint occasional failure to trigger MSI by enforcing outbound alignment requirement (Richard Zhu) - Call phy_power_off() in the .probe() error path (Frank Li) - Rename internal names from imx6_* to imx_* since i.MX7/8/9 are also supported (Frank Li) - Manage Refclk by using SoC-specific callbacks instead of switch statements (Frank Li) - Manage core reset by using SoC-specific callbacks instead of switch statements (Frank Li) - Expand comments for erratum ERR010728 workaround (Frank Li) - Use generic PHY APIs to configure mode, speed, and submode, which is harmless for devices that implement their own internal PHY management and don't set the generic imx_pcie->phy (Frank Li) - Add i.MX8Q (i.MX8QM, i.MX8QXP, and i.MX8DXL) DT binding and driver Root Complex support (Richard Zhu) Freescale Layerscape PCIe controller driver: - Replace layerscape-pcie DT binding compatible fsl,lx2160a-pcie with fsl,lx2160ar2-pcie (Frank Li) - Add layerscape-pcie DT binding deprecated 'num-viewport' property to address a DT checker warning (Frank Li) - Change layerscape-pcie DT binding 'fsl,pcie-scfg' to phandle-array (Frank Li) Loongson PCIe controller driver: - Increase max PCI hosts to 8 for Loongson-3C6000 and newer chipsets (Huacai Chen) Marvell Aardvark PCIe controller driver: - Fix issue with emulating Configuration RRS for two-byte reads of Vendor ID; previously it only worked for four-byte reads (Bjorn Helgaas) MediaTek PCIe Gen3 controller driver: - Add per-SoC struct mtk_gen3_pcie_pdata to support multiple SoC types (Lorenzo Bianconi) - Use reset_bulk APIs to manage PHY reset lines (Lorenzo Bianconi) - Add DT and driver support for Airoha EN7581 PCIe controller (Lorenzo Bianconi) Qualcomm PCIe controller driver: - Update qcom,pcie-sc7280 DT binding with eight interrupts (Rayyan Ansari) - Add back DT 'vddpe-3v3-supply', which was incorrectly removed earlier (Johan Hovold) - Drop endpoint redundant masking of global IRQ events (Manivannan Sadhasivam) - Clarify unknown global IRQ message and only log it once to avoid a flood (Manivannan Sadhasivam) - Add 'linux,pci-domain' property to endpoint DT binding (Manivannan Sadhasivam) - Assign PCI domain number for endpoint controllers (Manivannan Sadhasivam) - Add 'qcom_pcie_ep' and the PCI domain number to IRQ names for endpoint controller (Manivannan Sadhasivam) - Add global SPI interrupt for PCIe link events to DT binding (Manivannan Sadhasivam) - Add global RC interrupt handler to handle 'Link up' events and automatically enumerate hot-added devices (Manivannan Sadhasivam) - Avoid mirroring of DBI and iATU register space so it doesn't overlap BAR MMIO space (Prudhvi Yarlagadda) - Enable controller resources like PHY only after PERST# is deasserted to partially avoid the problem that the endpoint SoC crashes when accessing things when Refclk is absent (Manivannan Sadhasivam) - Add 16.0 GT/s equalization and RX lane margining settings (Shashank Babu Chinta Venkata) - Pass domain number to pci_bus_release_domain_nr() explicitly to avoid a NULL pointer dereference (Manivannan Sadhasivam) Renesas R-Car PCIe controller driver: - Make the read-only const array 'check_addr' static (Colin Ian King) - Add R-Car V4M (R8A779H0) PCIe host and endpoint to DT binding (Yoshihiro Shimoda) TI DRA7xx PCIe controller driver: - Request IRQF_ONESHOT for 'dra7xx-pcie-main' IRQ since the primary handler is NULL (Siddharth Vadapalli) - Handle IRQ request errors during root port and endpoint probe (Siddharth Vadapalli) TI J721E PCIe driver: - Add DT 'ti,syscon-acspcie-proxy-ctrl' and driver support to enable the ACSPCIE module to drive Refclk for the Endpoint (Siddharth Vadapalli) - Extract the cadence link setup from cdns_pcie_host_setup() so link setup can be done separately during resume (Thomas Richard) - Add T_PERST_CLK_US definition for the mandatory delay between Refclk becoming stable and PERST# being deasserted (Thomas Richard) - Add j721e suspend and resume support (Théo Lebrun) TI Keystone PCIe controller driver: - Fix NULL pointer checking when applying MRRS limitation quirk for AM65x SR 1.0 Errata #i2037 (Dan Carpenter) Xilinx NWL PCIe controller driver: - Fix off-by-one error in INTx IRQ handler that caused INTx interrupts to be lost or delivered as the wrong interrupt (Sean Anderson) - Rate-limit misc interrupt messages (Sean Anderson) - Turn off the clock on probe failure and device removal (Sean Anderson) - Add DT binding and driver support for enabling/disabling PHYs (Sean Anderson) - Add PCIe phy bindings for the ZCU102 (Sean Anderson) Xilinx XDMA PCIe controller driver: - Add support for Xilinx QDMA Soft IP PCIe Root Port Bridge to DT binding and xilinx-dma-pl driver (Thippeswamy Havalige) Miscellaneous: - Fix buffer overflow in kirin_pcie_parse_port() (Alexandra Diupina) - Fix minor kerneldoc issues and typos (Bjorn Helgaas) - Use PCI_DEVID() macro in aer_inject() instead of open-coding it (Jinjie Ruan) - Check pcie_find_root_port() return in x86 fixups to avoid NULL pointer dereferences (Samasth Norway Ananda) - Make pci_bus_type constant (Kunwu Chan) - Remove unused declarations of __pci_pme_wakeup() and pci_vpd_release() (Yue Haibing) - Remove any leftover .*.cmd files with make clean (zhang jiao) - Remove unused BILLION macro (zhang jiao)" * tag 'pci-v6.12-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci: (132 commits) PCI: Fix typos dt-bindings: PCI: qcom: Allow 'vddpe-3v3-supply' again tools: PCI: Remove unused BILLION macro tools: PCI: Remove .*.cmd files with make clean PCI: Pass domain number to pci_bus_release_domain_nr() explicitly PCI: dra7xx: Fix error handling when IRQ request fails in probe PCI: dra7xx: Fix threaded IRQ request for "dra7xx-pcie-main" IRQ PCI: qcom: Add RX lane margining settings for 16.0 GT/s PCI: qcom: Add equalization settings for 16.0 GT/s PCI: dwc: Always cache the maximum link speed value in dw_pcie::max_link_speed PCI: dwc: Rename 'dw_pcie::link_gen' to 'dw_pcie::max_link_speed' PCI: qcom-ep: Enable controller resources like PHY only after refclk is available PCI: Mark Creative Labs EMU20k2 INTx masking as broken dt-bindings: PCI: imx6q-pcie: Add reg-name "dbi2" and "atu" for i.MX8M PCIe Endpoint dt-bindings: PCI: altera: msi: Convert to YAML PCI: imx6: Add i.MX8Q PCIe Root Complex (RC) support PCI: Rename CRS Completion Status to RRS PCI: aardvark: Correct Configuration RRS checking PCI: Wait for device readiness with Configuration RRS PCI: brcmstb: Sort enums, pcie_offsets[], pcie_cfg_data, .compatible strings ...
479 lines
11 KiB
C
479 lines
11 KiB
C
/*
|
|
* Copyright 2012 Red Hat Inc.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the
|
|
* "Software"), to deal in the Software without restriction, including
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
* distribute, sub license, and/or sell copies of the Software, and to
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
* the following conditions:
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
|
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
|
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*
|
|
* The above copyright notice and this permission notice (including the
|
|
* next paragraph) shall be included in all copies or substantial portions
|
|
* of the Software.
|
|
*
|
|
*/
|
|
/*
|
|
* Authors: Dave Airlie <airlied@redhat.com>
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/of.h>
|
|
#include <linux/pci.h>
|
|
|
|
#include <drm/drm_aperture.h>
|
|
#include <drm/drm_atomic_helper.h>
|
|
#include <drm/drm_drv.h>
|
|
#include <drm/drm_fbdev_shmem.h>
|
|
#include <drm/drm_gem_shmem_helper.h>
|
|
#include <drm/drm_module.h>
|
|
#include <drm/drm_probe_helper.h>
|
|
|
|
#include "ast_drv.h"
|
|
|
|
static int ast_modeset = -1;
|
|
|
|
MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
|
|
module_param_named(modeset, ast_modeset, int, 0400);
|
|
|
|
/*
|
|
* DRM driver
|
|
*/
|
|
|
|
DEFINE_DRM_GEM_FOPS(ast_fops);
|
|
|
|
static const struct drm_driver ast_driver = {
|
|
.driver_features = DRIVER_ATOMIC |
|
|
DRIVER_GEM |
|
|
DRIVER_MODESET,
|
|
|
|
.fops = &ast_fops,
|
|
.name = DRIVER_NAME,
|
|
.desc = DRIVER_DESC,
|
|
.date = DRIVER_DATE,
|
|
.major = DRIVER_MAJOR,
|
|
.minor = DRIVER_MINOR,
|
|
.patchlevel = DRIVER_PATCHLEVEL,
|
|
|
|
DRM_GEM_SHMEM_DRIVER_OPS
|
|
};
|
|
|
|
/*
|
|
* PCI driver
|
|
*/
|
|
|
|
#define PCI_VENDOR_ASPEED 0x1a03
|
|
|
|
#define AST_VGA_DEVICE(id, info) { \
|
|
.class = PCI_BASE_CLASS_DISPLAY << 16, \
|
|
.class_mask = 0xff0000, \
|
|
.vendor = PCI_VENDOR_ASPEED, \
|
|
.device = id, \
|
|
.subvendor = PCI_ANY_ID, \
|
|
.subdevice = PCI_ANY_ID, \
|
|
.driver_data = (unsigned long) info }
|
|
|
|
static const struct pci_device_id ast_pciidlist[] = {
|
|
AST_VGA_DEVICE(PCI_CHIP_AST2000, NULL),
|
|
AST_VGA_DEVICE(PCI_CHIP_AST2100, NULL),
|
|
{0, 0, 0},
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pci, ast_pciidlist);
|
|
|
|
static bool ast_is_vga_enabled(void __iomem *ioregs)
|
|
{
|
|
u8 vgaer = __ast_read8(ioregs, AST_IO_VGAER);
|
|
|
|
return vgaer & AST_IO_VGAER_VGA_ENABLE;
|
|
}
|
|
|
|
static void ast_enable_vga(void __iomem *ioregs)
|
|
{
|
|
__ast_write8(ioregs, AST_IO_VGAER, AST_IO_VGAER_VGA_ENABLE);
|
|
__ast_write8(ioregs, AST_IO_VGAMR_W, AST_IO_VGAMR_IOSEL);
|
|
}
|
|
|
|
/*
|
|
* Run this function as part of the HW device cleanup; not
|
|
* when the DRM device gets released.
|
|
*/
|
|
static void ast_enable_mmio_release(void *data)
|
|
{
|
|
void __iomem *ioregs = (void __force __iomem *)data;
|
|
|
|
/* enable standard VGA decode */
|
|
__ast_write8_i(ioregs, AST_IO_VGACRI, 0xa1, AST_IO_VGACRA1_MMIO_ENABLED);
|
|
}
|
|
|
|
static int ast_enable_mmio(struct device *dev, void __iomem *ioregs)
|
|
{
|
|
void *data = (void __force *)ioregs;
|
|
|
|
__ast_write8_i(ioregs, AST_IO_VGACRI, 0xa1,
|
|
AST_IO_VGACRA1_MMIO_ENABLED |
|
|
AST_IO_VGACRA1_VGAIO_DISABLED);
|
|
|
|
return devm_add_action_or_reset(dev, ast_enable_mmio_release, data);
|
|
}
|
|
|
|
static void ast_open_key(void __iomem *ioregs)
|
|
{
|
|
__ast_write8_i(ioregs, AST_IO_VGACRI, 0x80, AST_IO_VGACR80_PASSWORD);
|
|
}
|
|
|
|
static int ast_detect_chip(struct pci_dev *pdev,
|
|
void __iomem *regs, void __iomem *ioregs,
|
|
enum ast_chip *chip_out,
|
|
enum ast_config_mode *config_mode_out)
|
|
{
|
|
struct device *dev = &pdev->dev;
|
|
struct device_node *np = dev->of_node;
|
|
enum ast_config_mode config_mode = ast_use_defaults;
|
|
uint32_t scu_rev = 0xffffffff;
|
|
enum ast_chip chip;
|
|
u32 data;
|
|
u8 vgacrd0, vgacrd1;
|
|
|
|
/*
|
|
* Find configuration mode and read SCU revision
|
|
*/
|
|
|
|
/* Check if we have device-tree properties */
|
|
if (np && !of_property_read_u32(np, "aspeed,scu-revision-id", &data)) {
|
|
/* We do, disable P2A access */
|
|
config_mode = ast_use_dt;
|
|
scu_rev = data;
|
|
} else if (pdev->device == PCI_CHIP_AST2000) { // Not all families have a P2A bridge
|
|
/*
|
|
* The BMC will set SCU 0x40 D[12] to 1 if the P2 bridge
|
|
* is disabled. We force using P2A if VGA only mode bit
|
|
* is set D[7]
|
|
*/
|
|
vgacrd0 = __ast_read8_i(ioregs, AST_IO_VGACRI, 0xd0);
|
|
vgacrd1 = __ast_read8_i(ioregs, AST_IO_VGACRI, 0xd1);
|
|
if (!(vgacrd0 & 0x80) || !(vgacrd1 & 0x10)) {
|
|
|
|
/*
|
|
* We have a P2A bridge and it is enabled.
|
|
*/
|
|
|
|
/* Patch AST2500/AST2510 */
|
|
if ((pdev->revision & 0xf0) == 0x40) {
|
|
if (!(vgacrd0 & AST_VRAM_INIT_STATUS_MASK))
|
|
ast_patch_ahb_2500(regs);
|
|
}
|
|
|
|
/* Double check that it's actually working */
|
|
data = __ast_read32(regs, 0xf004);
|
|
if ((data != 0xffffffff) && (data != 0x00)) {
|
|
config_mode = ast_use_p2a;
|
|
|
|
/* Read SCU7c (silicon revision register) */
|
|
__ast_write32(regs, 0xf004, 0x1e6e0000);
|
|
__ast_write32(regs, 0xf000, 0x1);
|
|
scu_rev = __ast_read32(regs, 0x1207c);
|
|
}
|
|
}
|
|
}
|
|
|
|
switch (config_mode) {
|
|
case ast_use_defaults:
|
|
dev_info(dev, "Using default configuration\n");
|
|
break;
|
|
case ast_use_dt:
|
|
dev_info(dev, "Using device-tree for configuration\n");
|
|
break;
|
|
case ast_use_p2a:
|
|
dev_info(dev, "Using P2A bridge for configuration\n");
|
|
break;
|
|
}
|
|
|
|
/*
|
|
* Identify chipset
|
|
*/
|
|
|
|
if (pdev->revision >= 0x50) {
|
|
chip = AST2600;
|
|
dev_info(dev, "AST 2600 detected\n");
|
|
} else if (pdev->revision >= 0x40) {
|
|
switch (scu_rev & 0x300) {
|
|
case 0x0100:
|
|
chip = AST2510;
|
|
dev_info(dev, "AST 2510 detected\n");
|
|
break;
|
|
default:
|
|
chip = AST2500;
|
|
dev_info(dev, "AST 2500 detected\n");
|
|
break;
|
|
}
|
|
} else if (pdev->revision >= 0x30) {
|
|
switch (scu_rev & 0x300) {
|
|
case 0x0100:
|
|
chip = AST1400;
|
|
dev_info(dev, "AST 1400 detected\n");
|
|
break;
|
|
default:
|
|
chip = AST2400;
|
|
dev_info(dev, "AST 2400 detected\n");
|
|
break;
|
|
}
|
|
} else if (pdev->revision >= 0x20) {
|
|
switch (scu_rev & 0x300) {
|
|
case 0x0000:
|
|
chip = AST1300;
|
|
dev_info(dev, "AST 1300 detected\n");
|
|
break;
|
|
default:
|
|
chip = AST2300;
|
|
dev_info(dev, "AST 2300 detected\n");
|
|
break;
|
|
}
|
|
} else if (pdev->revision >= 0x10) {
|
|
switch (scu_rev & 0x0300) {
|
|
case 0x0200:
|
|
chip = AST1100;
|
|
dev_info(dev, "AST 1100 detected\n");
|
|
break;
|
|
case 0x0100:
|
|
chip = AST2200;
|
|
dev_info(dev, "AST 2200 detected\n");
|
|
break;
|
|
case 0x0000:
|
|
chip = AST2150;
|
|
dev_info(dev, "AST 2150 detected\n");
|
|
break;
|
|
default:
|
|
chip = AST2100;
|
|
dev_info(dev, "AST 2100 detected\n");
|
|
break;
|
|
}
|
|
} else {
|
|
chip = AST2000;
|
|
dev_info(dev, "AST 2000 detected\n");
|
|
}
|
|
|
|
*chip_out = chip;
|
|
*config_mode_out = config_mode;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|
{
|
|
struct device *dev = &pdev->dev;
|
|
int ret;
|
|
void __iomem *regs;
|
|
void __iomem *ioregs;
|
|
enum ast_config_mode config_mode;
|
|
enum ast_chip chip;
|
|
struct drm_device *drm;
|
|
bool need_post = false;
|
|
|
|
ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &ast_driver);
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = pcim_enable_device(pdev);
|
|
if (ret)
|
|
return ret;
|
|
|
|
regs = pcim_iomap_region(pdev, 1, "ast");
|
|
if (IS_ERR(regs))
|
|
return PTR_ERR(regs);
|
|
|
|
if (pdev->revision >= 0x40) {
|
|
/*
|
|
* On AST2500 and later models, MMIO is enabled by
|
|
* default. Adopt it to be compatible with ARM.
|
|
*/
|
|
resource_size_t len = pci_resource_len(pdev, 1);
|
|
|
|
if (len < AST_IO_MM_OFFSET)
|
|
return -EIO;
|
|
if ((len - AST_IO_MM_OFFSET) < AST_IO_MM_LENGTH)
|
|
return -EIO;
|
|
ioregs = regs + AST_IO_MM_OFFSET;
|
|
} else if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) {
|
|
/*
|
|
* Map I/O registers if we have a PCI BAR for I/O.
|
|
*/
|
|
resource_size_t len = pci_resource_len(pdev, 2);
|
|
|
|
if (len < AST_IO_MM_LENGTH)
|
|
return -EIO;
|
|
ioregs = pcim_iomap_region(pdev, 2, "ast");
|
|
if (IS_ERR(ioregs))
|
|
return PTR_ERR(ioregs);
|
|
} else {
|
|
/*
|
|
* Anything else is best effort.
|
|
*/
|
|
resource_size_t len = pci_resource_len(pdev, 1);
|
|
|
|
if (len < AST_IO_MM_OFFSET)
|
|
return -EIO;
|
|
if ((len - AST_IO_MM_OFFSET) < AST_IO_MM_LENGTH)
|
|
return -EIO;
|
|
ioregs = regs + AST_IO_MM_OFFSET;
|
|
|
|
dev_info(dev, "Platform has no I/O space, using MMIO\n");
|
|
}
|
|
|
|
if (!ast_is_vga_enabled(ioregs)) {
|
|
dev_info(dev, "VGA not enabled on entry, requesting chip POST\n");
|
|
need_post = true;
|
|
}
|
|
|
|
/*
|
|
* If VGA isn't enabled, we need to enable now or subsequent
|
|
* access to the scratch registers will fail.
|
|
*/
|
|
if (need_post)
|
|
ast_enable_vga(ioregs);
|
|
/* Enable extended register access */
|
|
ast_open_key(ioregs);
|
|
|
|
ret = ast_enable_mmio(dev, ioregs);
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = ast_detect_chip(pdev, regs, ioregs, &chip, &config_mode);
|
|
if (ret)
|
|
return ret;
|
|
|
|
drm = ast_device_create(pdev, &ast_driver, chip, config_mode, regs, ioregs, need_post);
|
|
if (IS_ERR(drm))
|
|
return PTR_ERR(drm);
|
|
pci_set_drvdata(pdev, drm);
|
|
|
|
ret = drm_dev_register(drm, ent->driver_data);
|
|
if (ret)
|
|
return ret;
|
|
|
|
drm_fbdev_shmem_setup(drm, 32);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void ast_pci_remove(struct pci_dev *pdev)
|
|
{
|
|
struct drm_device *dev = pci_get_drvdata(pdev);
|
|
|
|
drm_dev_unregister(dev);
|
|
drm_atomic_helper_shutdown(dev);
|
|
}
|
|
|
|
static void ast_pci_shutdown(struct pci_dev *pdev)
|
|
{
|
|
drm_atomic_helper_shutdown(pci_get_drvdata(pdev));
|
|
}
|
|
|
|
static int ast_drm_freeze(struct drm_device *dev)
|
|
{
|
|
int error;
|
|
|
|
error = drm_mode_config_helper_suspend(dev);
|
|
if (error)
|
|
return error;
|
|
pci_save_state(to_pci_dev(dev->dev));
|
|
return 0;
|
|
}
|
|
|
|
static int ast_drm_thaw(struct drm_device *dev)
|
|
{
|
|
struct ast_device *ast = to_ast_device(dev);
|
|
|
|
ast_enable_vga(ast->ioregs);
|
|
ast_open_key(ast->ioregs);
|
|
ast_enable_mmio(dev->dev, ast->ioregs);
|
|
ast_post_gpu(dev);
|
|
|
|
return drm_mode_config_helper_resume(dev);
|
|
}
|
|
|
|
static int ast_drm_resume(struct drm_device *dev)
|
|
{
|
|
if (pci_enable_device(to_pci_dev(dev->dev)))
|
|
return -EIO;
|
|
|
|
return ast_drm_thaw(dev);
|
|
}
|
|
|
|
static int ast_pm_suspend(struct device *dev)
|
|
{
|
|
struct pci_dev *pdev = to_pci_dev(dev);
|
|
struct drm_device *ddev = pci_get_drvdata(pdev);
|
|
int error;
|
|
|
|
error = ast_drm_freeze(ddev);
|
|
if (error)
|
|
return error;
|
|
|
|
pci_disable_device(pdev);
|
|
pci_set_power_state(pdev, PCI_D3hot);
|
|
return 0;
|
|
}
|
|
|
|
static int ast_pm_resume(struct device *dev)
|
|
{
|
|
struct pci_dev *pdev = to_pci_dev(dev);
|
|
struct drm_device *ddev = pci_get_drvdata(pdev);
|
|
return ast_drm_resume(ddev);
|
|
}
|
|
|
|
static int ast_pm_freeze(struct device *dev)
|
|
{
|
|
struct pci_dev *pdev = to_pci_dev(dev);
|
|
struct drm_device *ddev = pci_get_drvdata(pdev);
|
|
return ast_drm_freeze(ddev);
|
|
}
|
|
|
|
static int ast_pm_thaw(struct device *dev)
|
|
{
|
|
struct pci_dev *pdev = to_pci_dev(dev);
|
|
struct drm_device *ddev = pci_get_drvdata(pdev);
|
|
return ast_drm_thaw(ddev);
|
|
}
|
|
|
|
static int ast_pm_poweroff(struct device *dev)
|
|
{
|
|
struct pci_dev *pdev = to_pci_dev(dev);
|
|
struct drm_device *ddev = pci_get_drvdata(pdev);
|
|
|
|
return ast_drm_freeze(ddev);
|
|
}
|
|
|
|
static const struct dev_pm_ops ast_pm_ops = {
|
|
.suspend = ast_pm_suspend,
|
|
.resume = ast_pm_resume,
|
|
.freeze = ast_pm_freeze,
|
|
.thaw = ast_pm_thaw,
|
|
.poweroff = ast_pm_poweroff,
|
|
.restore = ast_pm_resume,
|
|
};
|
|
|
|
static struct pci_driver ast_pci_driver = {
|
|
.name = DRIVER_NAME,
|
|
.id_table = ast_pciidlist,
|
|
.probe = ast_pci_probe,
|
|
.remove = ast_pci_remove,
|
|
.shutdown = ast_pci_shutdown,
|
|
.driver.pm = &ast_pm_ops,
|
|
};
|
|
|
|
drm_module_pci_driver_if_modeset(ast_pci_driver, ast_modeset);
|
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
MODULE_LICENSE("GPL and additional rights");
|