Re: amd64 support for AR9485

2014-05-12 Thread Stefan Sperling
On Mon, May 12, 2014 at 06:40:22AM -0400, vtamara wrote:
> El 2014-05-09 07:23, Stefan Sperling escribió:
> 
> >Further work is needed.
> >
> >I have diffs which do much more but don't yet work either.
> >I've given up on trying to get this to work for now, and will
> >share my diffs with anyone who wants to take over. If you're
> >an aspiring wifi hacker, then this is for you. If not, just
> >buy a supported card.
> 
> I cannot tell I can take over, but I have the hardware and would like to try
> your diffs, learn (a lot I need) and try to adapt from other implementations
> (not much time now but I would like to see if netbsd or freebsd support it).

FreeBSD supports it (ath driver). Linux does, too (ath9k driver).

I've studied their code and tried to make the necessary changes
to ar9003.c in our tree. In my case, the hardware fails to perform
I/Q calibration. If I disable this calibration it gets further but
ends up sending a storm TX/RX error interrupts.

I don't know if the problem in in our existing ar9003.c code, or
in the changes I made while trying to port AR9485 support over.

I haven't looked at this in a while. Last I looked was at b2k13.

This has gotten too large, and my next step would be to get rid
of parts that aren't absolutely necessary for progress.

I believe that ar9003.c has never been working. We don't use it
for any chipset that already works with athn. It is full of untested
code and the problems are hard for me to spot.

Index: ar9003.c
===
RCS file: /cvs/src/sys/dev/ic/ar9003.c,v
retrieving revision 1.27
diff -u -p -r1.27 ar9003.c
--- ar9003.c7 Aug 2013 01:06:28 -   1.27
+++ ar9003.c21 Oct 2013 16:20:04 -
@@ -93,6 +93,7 @@ void  ar9003_rx_intr(struct athn_softc *,
 intar9003_tx_process(struct athn_softc *);
 void   ar9003_tx_intr(struct athn_softc *);
 intar9003_swba_intr(struct athn_softc *);
+void   ar9003_bb_watchdog_intr(struct athn_softc *);
 intar9003_intr(struct athn_softc *);
 intar9003_tx(struct athn_softc *, struct mbuf *, struct ieee80211_node *,
int);
@@ -119,7 +120,7 @@ voidar9003_do_calib(struct athn_softc *
 void   ar9003_next_calib(struct athn_softc *);
 void   ar9003_calib_iq(struct athn_softc *);
 intar9003_get_iq_corr(struct athn_softc *, int32_t[], int32_t[]);
-intar9003_calib_tx_iq(struct athn_softc *);
+intar9003_calib_tx_iq_result(struct athn_softc *);
 void   ar9003_paprd_calib(struct athn_softc *, struct ieee80211_channel *);
 intar9003_get_desired_txgain(struct athn_softc *, int, int);
 void   ar9003_force_txgain(struct athn_softc *, uint32_t);
@@ -147,6 +148,7 @@ voidar9003_disable_ofdm_weak_signal(str
 void   ar9003_set_cck_weak_signal(struct athn_softc *, int);
 void   ar9003_set_firstep_level(struct athn_softc *, int);
 void   ar9003_set_spur_immunity_level(struct athn_softc *, int);
+void   ar9003_init_pll(struct athn_softc *);
 
 /* Extern functions. */
 void   athn_stop(struct ifnet *, int);
@@ -205,6 +207,9 @@ ar9003_attach(struct athn_softc *sc)
sc->obs_off = AR_OBS;
sc->gpio_input_en_off = AR_GPIO_INPUT_EN_VAL;
 
+   sc->workaround = AR_READ(sc, AR_WA) |
+   AR_WA_ASPM_TIMER_BASED_DISABLE | AR_WA_D3_L1_DISABLE;
+
if (!(sc->flags & ATHN_FLAG_PCIE))
athn_config_nonpcie(sc);
else
@@ -563,6 +568,7 @@ ar9003_rfsilent_init(struct athn_softc *
AR_SETBITS(sc, AR_GPIO_INPUT_EN_VAL, AR_GPIO_INPUT_EN_VAL_RFSILENT_BB);
reg = AR_READ(sc, AR_GPIO_INPUT_MUX2);
reg = RW(reg, AR_GPIO_INPUT_MUX2_RFSILENT, 0);
+   reg = RW(reg, AR_GPIO_INPUT_MUX2_RFSILENT, sc->rfsilent_pin);
AR_WRITE(sc, AR_GPIO_INPUT_MUX2, reg);
ar9003_gpio_config_input(sc, sc->rfsilent_pin);
AR_SETBITS(sc, AR_PHY_TEST, AR_PHY_TEST_RFSILENT_BB);
@@ -1310,13 +1316,37 @@ ar9003_swba_intr(struct athn_softc *sc)
 }
 #endif
 
+void
+ar9003_bb_watchdog_intr(struct athn_softc *sc)
+{
+   uint32_t status, reg;
+   static int phy_restart_disabled;
+
+   status = AR_READ(sc, AR_PHY_PANIC_WD_STATUS);
+   AR_WRITE(sc, AR_PHY_PANIC_WD_STATUS,
+   status & ~AR_PHY_PANIC_WD_STATUS_CLR);
+
+   if (!phy_restart_disabled &&
+   MS(status, AR_PHY_PANIC_WD_RX_OFDM) == 0xb) {
+   /* BB received unsupported frame rate and will hang
+* if the PHY is restarted. Disable PHY restart. */
+   reg = AR_READ(sc, AR_PHY_RESTART);
+   reg &= ~AR_PHY_RESTART_ENA;
+   AR_WRITE(sc, AR_PHY_RESTART, reg);
+   phy_restart_disabled = 1;
+   }
+}
+
 int
 ar9003_intr(struct athn_softc *sc)
 {
uint32_t intr, intr2, intr5, sync;
+   static int count;
 
/* Get pending interrupts. */
intr = AR_READ(sc, AR_INTR_ASYNC_CAUSE);
+   if (count < 4)
+   printf("%s: AR_INTR_ASYNC_CAUSE=0x%x\n", __func__, intr);
if (!(intr & AR_INT

Re: amd64 support for AR9485

2014-05-12 Thread vtamara

El 2014-05-09 07:23, Stefan Sperling escribió:


Further work is needed.

I have diffs which do much more but don't yet work either.
I've given up on trying to get this to work for now, and will
share my diffs with anyone who wants to take over. If you're
an aspiring wifi hacker, then this is for you. If not, just
buy a supported card.


I cannot tell I can take over, but I have the hardware and would like 
to try your diffs, learn (a lot I need) and try to adapt from other 
implementations (not much time now but I would like to see if netbsd or 
freebsd support it).





Re: amd64 support for AR9485

2014-05-09 Thread Sébastien Morand
>
> > No guarantees as to whether this is sufficient, or if further
> > work is needed, but it will at least get the device picked up by
> > the athn driver.
>
> Further work is needed.
>
> I have diffs which do much more but don't yet work either.
> I've given up on trying to get this to work for now, and will
> share my diffs with anyone who wants to take over. If you're
> an aspiring wifi hacker, then this is for you. If not, just
> buy a supported card.
>

Thanks for you reply, I'm not ready for this yet, but I keep it in mind and
maybe in a few months. I can easly get a compatible wifi dongle for now.


Re: amd64 support for AR9485

2014-05-09 Thread Stefan Sperling
On Fri, May 09, 2014 at 12:08:21AM +0100, Stuart Henderson wrote:
> You could try adding the ID to the athn driver to get it to match:
> 
> Index: if_athn_pci.c
> ===
> RCS file: /cvs/src/sys/dev/pci/if_athn_pci.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 if_athn_pci.c
> --- if_athn_pci.c 6 Dec 2013 21:03:03 -   1.14
> +++ if_athn_pci.c 8 May 2014 23:07:17 -
> @@ -98,7 +98,8 @@ static const struct pci_matchid athn_pci
>   { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR2427 },
>   { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9227 },
>   { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9287 },
> - { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9300 }
> + { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9300 },
> + { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9485 }
>  };
>  
>  int
> 
> No guarantees as to whether this is sufficient, or if further
> work is needed, but it will at least get the device picked up by
> the athn driver.

Further work is needed.

I have diffs which do much more but don't yet work either.
I've given up on trying to get this to work for now, and will
share my diffs with anyone who wants to take over. If you're
an aspiring wifi hacker, then this is for you. If not, just
buy a supported card.



Re: amd64 support for AR9485

2014-05-08 Thread Stuart Henderson
On 2014/05/08 23:43, Sébastien Morand wrote:
> >
> >
> > You could try adding the ID to the athn driver to get it to match:
> >
> > Index: if_athn_pci.c
> > ===
> > RCS file: /cvs/src/sys/dev/pci/if_athn_pci.c,v
> > retrieving revision 1.14
> > diff -u -p -r1.14 if_athn_pci.c
> > --- if_athn_pci.c   6 Dec 2013 21:03:03 -   1.14
> > +++ if_athn_pci.c   8 May 2014 23:07:17 -
> > @@ -98,7 +98,8 @@ static const struct pci_matchid athn_pci
> > { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR2427 },
> > { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9227 },
> > { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9287 },
> > -   { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9300 }
> > +   { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9300 },
> > +   { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9485 }
> >  };
> >
> >  int
> >
> > No guarantees as to whether this is sufficient, or if further
> > work is needed, but it will at least get the device picked up by
> > the athn driver.
> >
> 
> I did and It's doing what expected: card is detected but ifconfig athn0
> scan does not give me any result and it should since I'm far from one meter
> of the AP.
> 
> Direct configuration give nothing either:
> $ ifconfig athn0 newid LSA wpapsk '***'
> ifconfig: newid: bad value

This should be "nwid", not newid.

I can't speak for athn, but my 6205 iwn is totally broken for scan,
but works fine if I can supply an nwid, so scan is not a requirement
for a useful adapter.

(Of course there may be other issues with the driver for your adapter,
but it's worth trying a bit more yourself).


> $ dmesg|grep athn0
> athn0 at pci2 dev 0 function 0 "Atheros AR9485" rev 0x01: apic 2 int 16
> athn0: AR9485 rev 1 (1T1R), ROM rev 0, address 18:67:b0:8f:d1:58
> athn0: could not initialize calibration
> athn0: could not initialize calibration
> athn0: unable to reset hardware; reset status 60
> athn0 at pci2 dev 0 function 0 "Atheros AR9485" rev 0x01: apic 2 int 16
> athn0: AR9485 rev 1 (1T1R), ROM rev 0, address 18:67:b0:8f:d1:58
> athn0: could not initialize calibration
> 
> So I'm stuck with finding old usb hardware or waiting for a kind developer
> to have time and will to get my card supported ;-)
> 
> Thanks for your help,
> Sébastien



Re: amd64 support for AR9485

2014-05-08 Thread Sébastien Morand
>
>
> You could try adding the ID to the athn driver to get it to match:
>
> Index: if_athn_pci.c
> ===
> RCS file: /cvs/src/sys/dev/pci/if_athn_pci.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 if_athn_pci.c
> --- if_athn_pci.c   6 Dec 2013 21:03:03 -   1.14
> +++ if_athn_pci.c   8 May 2014 23:07:17 -
> @@ -98,7 +98,8 @@ static const struct pci_matchid athn_pci
> { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR2427 },
> { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9227 },
> { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9287 },
> -   { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9300 }
> +   { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9300 },
> +   { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9485 }
>  };
>
>  int
>
> No guarantees as to whether this is sufficient, or if further
> work is needed, but it will at least get the device picked up by
> the athn driver.
>

I did and It's doing what expected: card is detected but ifconfig athn0
scan does not give me any result and it should since I'm far from one meter
of the AP.

Direct configuration give nothing either:
$ ifconfig athn0 newid LSA wpapsk '***'
ifconfig: newid: bad value

$ dmesg|grep athn0
athn0 at pci2 dev 0 function 0 "Atheros AR9485" rev 0x01: apic 2 int 16
athn0: AR9485 rev 1 (1T1R), ROM rev 0, address 18:67:b0:8f:d1:58
athn0: could not initialize calibration
athn0: could not initialize calibration
athn0: unable to reset hardware; reset status 60
athn0 at pci2 dev 0 function 0 "Atheros AR9485" rev 0x01: apic 2 int 16
athn0: AR9485 rev 1 (1T1R), ROM rev 0, address 18:67:b0:8f:d1:58
athn0: could not initialize calibration

So I'm stuck with finding old usb hardware or waiting for a kind developer
to have time and will to get my card supported ;-)

Thanks for your help,
Sébastien


Re: amd64 support for AR9485

2014-05-08 Thread Stuart Henderson
On 2014/05/08 22:57, Sébastien Morand wrote:
> Hi,
> 
> My wireless card AR9485 is not recognized by kernel (5.5). I'm having the
> error following error message:
> "Atheros AR9485" rev 0x01 at pci2 dev 0 function 0 not configured
> 
> As far as I understand it means it's not supported but I can find a 2012
> email on tech list mentionning the ar9485 device in athn driver.
> 
> I find out in athnreg.h:
> #define AR_SREV_VERSION_94850x240
> #define AR_SREV_REVISION_9485_101
> 
> So it looks like it should be supported?
> 
> pcidump -v give me:
>  2:0:0: Atheros AR9485
> 0x: Vendor ID: 168c Product ID: 0032
> 0x0004: Command: 0007 Status: 0010
>  0x0008: Class: 02 Subclass: 80 Interface: 00 Revision: 01
> 0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 10
>  0x0010: BAR mem 64bit addr: 0xf150/0x0008
> 0x0018: BAR empty ()
> 0x001c: BAR empty ()
>  0x0020: BAR empty ()
> 0x0024: BAR empty ()
> 0x0028: Cardbus CIS: 
>  0x002c: Subsystem Vendor ID: 144d Product ID: 4105
> 0x0030: Expansion ROM Base Address: 
> 0x0038: 
>  0x003c: Interrupt Pin: 01 Line: 0b Min Gnt: 00 Max Lat: 00
> 0x0040: Capability 0x01: Power Management
> 0x0050: Capability 0x05: Message Signaled Interrupts (MSI)
>  0x0070: Capability 0x10: PCI Express
> Link Speed: 2.5 / 2.5 GT/s Link Width: x1 / x1
> 
> pcidump -x give me:
>  2:0:0: Atheros AR9485
> 0x: 0032168c 0017 0281 0010
> 0x0010: f154   
>  0x0020:    4105144d
> 0x0030:  0040  010b
> 
> if any body can help me get it works, thanks (actually I try to play a
> little bit with the value in athnreg.h but it's not working :-) I'm not
> really a kernel developer so obviously I miss something.
> 
> Regards,
> Sebastien

You could try adding the ID to the athn driver to get it to match:

Index: if_athn_pci.c
===
RCS file: /cvs/src/sys/dev/pci/if_athn_pci.c,v
retrieving revision 1.14
diff -u -p -r1.14 if_athn_pci.c
--- if_athn_pci.c   6 Dec 2013 21:03:03 -   1.14
+++ if_athn_pci.c   8 May 2014 23:07:17 -
@@ -98,7 +98,8 @@ static const struct pci_matchid athn_pci
{ PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR2427 },
{ PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9227 },
{ PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9287 },
-   { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9300 }
+   { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9300 },
+   { PCI_VENDOR_ATHEROS, PCI_PRODUCT_ATHEROS_AR9485 }
 };
 
 int

No guarantees as to whether this is sufficient, or if further
work is needed, but it will at least get the device picked up by
the athn driver.