about summary refs log tree commit diff
path: root/modules/hardware
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2016-10-13 02:19:36 +0200
committeraszlig <aszlig@redmoonstudios.org>2016-10-13 03:33:12 +0200
commit992f5d8d8de2a39ef6a35b69465bec1f0538abdd (patch)
tree4c4caf3afdc32254d0192aa7e7b694fbf2e25019 /modules/hardware
parent1fb2981f660b2155331cdac1b28640ba7c6b4786 (diff)
hardware/t100ha: Fix support for SDIO WiFi card
While I had terse Internet connectivity these days, I haven't checked
T100HA hardware related news/patchs very often.

Meanwhile a small patch by @tagorereddy popped up on hadess/rtl8723bs#80
which works around the SDIO detection.

On some devices the BIOS has an option to map the SDIO controller to PCI
instead of ACPI, but the T100HA doesn't have this option.

IIUC the issue here is that the controller is already being attached via
PCI device ID 80862280, which prevented the platform device from being
attached via ACPI.

The patch circumvents that by removing PCI device ID 80862280 while
probing for ACPI devices in SDHCI (yes, very hacky but works) and forces
the ACPI platform device to be initialized if the HID is 80860F14:02.

I've rebased and tidied up the original patch a bit to prevent warnings
during build.

Other than this patch, we now need to add the right firmware and the
corresponding parameters to hardware.firmware, so that the actual driver
for the WiFi card can be loaded.

The firmware parameters are stored in EFI on the host itself:

/sys/firmware/efi/efivars/nvram-74b00bd9-805a-4d61-b51f-43268123d113

So I added a copy of it to prevent impurities.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'modules/hardware')
-rw-r--r--modules/hardware/t100ha/brcmfmac43340-sdio.txtbin0 -> 3239 bytes
-rw-r--r--modules/hardware/t100ha/default.nix12
-rw-r--r--modules/hardware/t100ha/sdio.patch52
3 files changed, 64 insertions, 0 deletions
diff --git a/modules/hardware/t100ha/brcmfmac43340-sdio.txt b/modules/hardware/t100ha/brcmfmac43340-sdio.txt
new file mode 100644
index 00000000..db22fef6
--- /dev/null
+++ b/modules/hardware/t100ha/brcmfmac43340-sdio.txt
Binary files differdiff --git a/modules/hardware/t100ha/default.nix b/modules/hardware/t100ha/default.nix
index 3a209777..a1fc746d 100644
--- a/modules/hardware/t100ha/default.nix
+++ b/modules/hardware/t100ha/default.nix
@@ -8,6 +8,15 @@ in {
   options.vuizvui.hardware.t100ha.enable = lib.mkEnableOption desc;
 
   config = lib.mkIf cfg.enable {
+    hardware.firmware = lib.singleton (pkgs.runCommand "brcm43340-firmware" {
+      params = ./brcmfmac43340-sdio.txt;
+      fwbase = "lib/firmware/brcm/brcmfmac43340-sdio";
+      install = "install -vD -m 0644";
+    } ''
+      $install "${pkgs.firmwareLinuxNonfree}/$fwbase.bin" "$out/$fwbase.bin"
+      $install "$params" "$out/$fwbase.txt"
+    '');
+
     boot.kernelPackages = let
       nixpkgs = import ../../../nixpkgs-path.nix;
       t100haKernel = pkgs.linux_4_7.override {
@@ -18,6 +27,9 @@ in {
           { name = "meta-keys";
             patch = ./meta-keys.patch;
           }
+          { name = "sdio";
+            patch = ./sdio.patch;
+          }
         ];
 
         # Missing device drivers:
diff --git a/modules/hardware/t100ha/sdio.patch b/modules/hardware/t100ha/sdio.patch
new file mode 100644
index 00000000..3bfef26d
--- /dev/null
+++ b/modules/hardware/t100ha/sdio.patch
@@ -0,0 +1,52 @@
+Patch from https://github.com/hadess/rtl8723bs/issues/80#issuecomment-252259702
+
+diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
+index 159f7f1..2076427 100644
+--- a/drivers/acpi/acpi_platform.c
++++ b/drivers/acpi/acpi_platform.c
+@@ -50,8 +50,10 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
+ 	int count;
+ 
+ 	/* If the ACPI node already has a physical device attached, skip it. */
+-	if (adev->physical_node_count)
+-		return NULL;
++	if (adev->physical_node_count && !(
++	    !strcmp(acpi_device_hid(adev), "80860F14") &&
++	    !strcmp(adev->pnp.unique_id, "2")
++	)) return NULL;
+ 
+ 	if (!acpi_match_device_ids(adev, forbidden_id_list))
+ 		return ERR_PTR(-EINVAL);
+diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
+index 458ffb7..2807f78 100644
+--- a/drivers/mmc/host/sdhci-acpi.c
++++ b/drivers/mmc/host/sdhci-acpi.c
+@@ -47,6 +47,7 @@
+ #endif
+ 
+ #include "sdhci.h"
++#include <linux/pci.h>
+ 
+ enum {
+ 	SDHCI_ACPI_SD_CD		= BIT(0),
+@@ -381,6 +382,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
+ 	struct acpi_device *device, *child;
+ 	struct sdhci_acpi_host *c;
+ 	struct sdhci_host *host;
++	struct pci_dev *pcidev = NULL;
+ 	struct resource *iomem;
+ 	resource_size_t len;
+ 	const char *hid;
+@@ -404,6 +406,12 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
+ 	hid = acpi_device_hid(device);
+ 	uid = device->pnp.unique_id;
+ 
++	/* Workaround for CherryTrail x5-z8xxx: Make sure the SDIO controller
++	 * doesn't get added via PCI. */
++	if (!strcmp(hid, "80860F14") && !strcmp(uid, "1") &&
++	    (pcidev = pci_get_device(0x8086, 0x2280, NULL)) != NULL)
++		pci_stop_and_remove_bus_device(pcidev);
++
+ 	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ 	if (!iomem)
+ 		return -ENOMEM;