summaryrefslogtreecommitdiffstats
path: root/drivers/firmware/sysfb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firmware/sysfb.c')
-rw-r--r--drivers/firmware/sysfb.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/drivers/firmware/sysfb.c b/drivers/firmware/sysfb.c
index 3c197db42c..880ffcb500 100644
--- a/drivers/firmware/sysfb.c
+++ b/drivers/firmware/sysfb.c
@@ -29,6 +29,7 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/mm.h>
+#include <linux/pci.h>
#include <linux/platform_data/simplefb.h>
#include <linux/platform_device.h>
#include <linux/screen_info.h>
@@ -69,24 +70,72 @@ void sysfb_disable(void)
}
EXPORT_SYMBOL_GPL(sysfb_disable);
+#if defined(CONFIG_PCI)
+static __init bool sysfb_pci_dev_is_enabled(struct pci_dev *pdev)
+{
+ /*
+ * TODO: Try to integrate this code into the PCI subsystem
+ */
+ int ret;
+ u16 command;
+
+ ret = pci_read_config_word(pdev, PCI_COMMAND, &command);
+ if (ret != PCIBIOS_SUCCESSFUL)
+ return false;
+ if (!(command & PCI_COMMAND_MEMORY))
+ return false;
+ return true;
+}
+#else
+static __init bool sysfb_pci_dev_is_enabled(struct pci_dev *pdev)
+{
+ return false;
+}
+#endif
+
+static __init struct device *sysfb_parent_dev(const struct screen_info *si)
+{
+ struct pci_dev *pdev;
+
+ pdev = screen_info_pci_dev(si);
+ if (IS_ERR(pdev)) {
+ return ERR_CAST(pdev);
+ } else if (pdev) {
+ if (!sysfb_pci_dev_is_enabled(pdev))
+ return ERR_PTR(-ENODEV);
+ return &pdev->dev;
+ }
+
+ return NULL;
+}
+
static __init int sysfb_init(void)
{
struct screen_info *si = &screen_info;
+ struct device *parent;
struct simplefb_platform_data mode;
const char *name;
bool compatible;
int ret = 0;
+ screen_info_apply_fixups();
+
mutex_lock(&disable_lock);
if (disabled)
goto unlock_mutex;
sysfb_apply_efi_quirks();
+ parent = sysfb_parent_dev(si);
+ if (IS_ERR(parent)) {
+ ret = PTR_ERR(parent);
+ goto unlock_mutex;
+ }
+
/* try to create a simple-framebuffer device */
compatible = sysfb_parse_mode(si, &mode);
if (compatible) {
- pd = sysfb_create_simplefb(si, &mode);
+ pd = sysfb_create_simplefb(si, &mode, parent);
if (!IS_ERR(pd))
goto unlock_mutex;
}
@@ -109,6 +158,8 @@ static __init int sysfb_init(void)
goto unlock_mutex;
}
+ pd->dev.parent = parent;
+
sysfb_set_efifb_fwnode(pd);
ret = platform_device_add_data(pd, si, sizeof(*si));