9front - general discussion about 9front
 help / color / mirror / Atom feed
From: kemal <kemalinanc8@gmail.com>
To: 9front@9front.org
Subject: Re: [9front] driver for intel wireless 7260?
Date: Thu, 5 Aug 2021 00:32:16 +0000	[thread overview]
Message-ID: <CABO6shewZynEt0-MbXMHrwBiG0s3evJnp5AGLao_RWvZ+A3SCg@mail.gmail.com> (raw)
In-Reply-To: <CABO6shebP2EbWxcbH9aRGRj3r15e4t_pWt0=6wuAZduoT2YBhw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 353 bytes --]

> just now i cleaned up those patches and now i have a diff that
> should work. it can be applied with `ape/patch -p0 < diff.txt`

fuck forgot one thing... openbsd sends a command for 7k family
after boot, it initializes tx backoffs to minimum. in addition,
obsd does not check for errors for this command, gonna do the
same.

the new diff is attached.

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 2945 bytes --]

--- /sys/src/9/pc/etheriwl.c
+++ /sys/src/9/pc/etheriwl.c
@@ -1,9 +1,10 @@
 /*
  * Intel WiFi Link driver.
  *
- * Written without any documentation but Damien Bergaminis
- * OpenBSD iwn(4) and iwm(4) driver sources. Requires intel
- * firmware to be present in /lib/firmware/iwn-* on attach.
+ * Written without any documentation but Damien Bergamini's
+ * iwn(4) and Stefan Sperling's iwm(4) OpenBSD driver sources.
+ * Requires Intel firmware to be present in /lib/firmware/iw[nm]-*
+ * on attach.
  */
 
 #include "u.h"
@@ -242,6 +243,8 @@
 
 	SbCpu1Status	= 0xa01e30,
 	SbCpu2Status	= 0xa01e34,
+	OscClk		= 0xa04068,
+		OscClkCtrl	= 1<<3,
 	UregChick	= 0xa05c00,
 		UregChickMsiEnable	= 1<<24,
 
@@ -631,6 +634,7 @@
 	Type6005	= 11,	/* also Centrino Advanced-N 6030, 6235 */
 	Type2030	= 12,
 	Type2000	= 16,
+	Type7260	= 30,
 
 	Type8265	= 35,
 };
@@ -686,6 +690,7 @@
 	[Type6005] "iwn-6005", /* see in iwlattach() below */
 	[Type2030] "iwn-2030",
 	[Type2000] "iwn-2000",
+	[Type7260] "iwm-7260-17",
 };
 
 static char *qcmd(Ctlr *ctlr, uint qid, uint code, uchar *data, int size, Block *block);
@@ -1088,6 +1093,22 @@
 		nicunlock(ctlr);
 	}
 
+	/* Enable the oscillator to count wake up time for L1 exit. (weird W/A) */
+	if(ctlr->type == Type7260){
+		if((err = niclock(ctlr)) != nil)
+			return err;
+
+		prphread(ctlr, OscClk);
+		prphread(ctlr, OscClk);
+		delay(20);
+
+		prphwrite(ctlr, OscClk, prphread(ctlr, OscClk) | OscClkCtrl);
+
+		prphread(ctlr, OscClk);
+		prphread(ctlr, OscClk);
+
+		nicunlock(ctlr);
+	}
 	if(ctlr->family < 8000){
 		if((err = niclock(ctlr)) != nil)
 			return err;
@@ -2800,6 +2821,12 @@
 	return cmd(ctlr, 210, c, 11*4);
 }
 
+static void
+tttxbackoff(Ctlr *ctlr, u32int backoff)
+{
+	cmd(ctlr, 126, (uchar*)&backoff, sizeof(backoff));
+}
+
 static char*
 updatedevicepower(Ctlr *ctlr)
 {
@@ -2864,6 +2891,10 @@
 		if((err = sendbtcoexadv(ctlr)) != nil)
 			return err;
 
+		/* Initialize tx backoffs to the minimum. */
+		if(ctlr->family == 7000)
+			tttxbackoff(ctlr, 0);
+
 		if((err = updatedevicepower(ctlr)) != nil){
 			print("can't update device power: %s\n", err);
 			return err;
@@ -3416,6 +3447,12 @@
 		iunlock(ctlr);
 		return "qcmd: broken";
 	}
+	/* wake up the nic (just needed for 7k) */
+	if(ctlr->family == 7000 && q->n == 0)
+		if(niclock(ctlr) != nil){
+			iunlock(ctlr);
+			return "qcmd: busy";
+		}
 	q->n++;
 	q->lastcmd = code;
 
@@ -4242,6 +4279,9 @@
 		if(tx != nil && tx->n > 0){
 			tx->n--;
 			wakeup(tx);
+			/* unlock 7k family nics as all commands are done */
+			if(ctlr->family == 7000 && tx->n == 0)
+				nicunlock(ctlr);
 		}
 	}
 
@@ -4349,6 +4389,11 @@
 		case 0x088e:	/* Centrino Advanced-N 6235 */
 		case 0x088f:	/* Centrino Advanced-N 6235 */
 			family = 0;
+			fwname = nil;
+			break;
+		case 0x08b1:	/* Wireless AC 7260 */
+		case 0x08b2:	/* Wireless AC 7260 */
+			family = 7000;
 			fwname = nil;
 			break;
 		case 0x24f3:	/* Wireless AC 8260 */

  reply	other threads:[~2021-08-05  9:19 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-26 16:30 Skylar Bleed
2021-07-26 19:29 ` cinap_lenrek
2021-07-27  7:21   ` Aw: " Eckard Brauer
2021-08-04 20:50     ` kemal
2021-08-05  0:32       ` kemal [this message]
2021-08-05  7:52         ` cinap_lenrek
2021-08-05 12:41           ` kemal
2021-08-05 21:19             ` Eckard Brauer
2021-08-05 22:33             ` cinap_lenrek
2021-07-27  8:17   ` Aw: " Eckard Brauer
2021-07-30 21:19     ` unobe
2021-08-06  4:43 qwx
2021-08-06  4:57 ` Skylar Bleed
2021-08-06 10:06 ` cinap_lenrek
2021-08-06 17:56   ` Skylar Bleed
2021-08-06 23:48     ` cinap_lenrek
2021-08-07  2:59       ` Skylar Bleed
2021-08-07 11:16         ` cinap_lenrek
2021-08-07 14:39           ` Skylar Bleed
2021-08-07 22:14             ` kemal
2021-08-08 14:35               ` Skylar Bleed
2021-08-09 12:05               ` kemal
2021-08-10 15:11                 ` Skylar Bleed
2021-08-12 21:03                   ` kemal
2021-08-13 19:49                     ` Skylar Bleed
2021-08-14 13:26                       ` kemal
2021-08-13 23:41                     ` kemal
2021-08-14 17:25                       ` cinap_lenrek
2021-08-14 17:50                       ` kemal
2021-08-07 22:27             ` ori
2021-08-07 10:30     ` kemal
2021-08-06 14:07 ` kemal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABO6shewZynEt0-MbXMHrwBiG0s3evJnp5AGLao_RWvZ+A3SCg@mail.gmail.com \
    --to=kemalinanc8@gmail.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).