xpp: fix waitfor_xpds race at startup

* If userspace would run
    modprobe xpp_usb && cat /sys/bus/astribanks/devices/xbus-00/waitfor_xpds
  it would return immediately rather than wait for the Astribank to
  initialize.
* We sometimes managed to read before getting the reply from the
  astribank.
* Now we don't trust unit count at such an early stage.
* Instread we wait for the Astribank to reach a stable state (READY or FAIL)
  before finish waiting for this astribank.

Internal-Issue-ID: Xorcom-1502
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
wcte13xp: Workaround rare nmi on modprobe on select systems

With certain pci controllers that support pci hotplug, during the reset
sequence of the fpga, the host controller can get confused about the state of
the card and throw an nmi.

Known affected systems:
 HP proliant DL160 & DL360p
 Dell poweredge R520
 Super Micro X7SPA-HF

This patch attempts to work around that by removing the fpga reset sequence
from the driver startup, then setting various control registers to known
starting state values.

This patch removes the field upgradeable firmware logic temporarily for the
te133 card to prevent fpga reset.

Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
xpp: Serialize dahdi registration

xpp: Serialize dahdi registration: Cause races under highly-parallel
workloads (with dahdi_autoreg=0).

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
xpp: refactor FXS ring settings

xpp: refactor the FXS module ring settings into separate data structure:

* Update High VBAT initialization in init_card_1_30:
  - Take the value used in set_vm_led_mode() (0x34)
  - Now we don't need to set it over and over again in set_vm_led_mode()
* Create a unified ring_parameters[] array for all ring registers:
  - Columns for 3 ring types (NEON, TRAPEZ, NORMAL)
  - Used by new send_ring_parameters() function
* Now the set_vm_led_mode() simply calls send_ring_parameters()
* This cleanup would allow us to change ring parameters at runtime (by
  updating the values in these tables).

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
xpp: FXS: ring/mwi settings: a sysfs interface

A new SysFS interface for FXS modules (XPDs):
* In /sys/bus/xpds/devices/<ll>:<m>:<n>/fxs_ring_registers
* Reading show current register values for NEON/TRAPEZ/NORMAL
* Modify the table via writing: "<column> <reg> <byte> [<byte>]"
* Example:
	echo "NEON 0x33 0x12" > \
		'/sys/bus/xpds/devices/00:0:0/fxs_ring_registers'

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
xpp: ring/mwi settings: add to FXS init script

init_card_1_30 (FXS modules init script) can now use the new sysfs
interface to set ring settings.

Currently it only overwrite a single register

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
add a 'location' attribute to sysfs (dahdi_device):

* Our user-space previously used the implicit location from the sysfs
  device path of the "dahdi_device".
* However:
  - Sysfs paths are very limited in length.
  - Low-level driver need more control on the location field.
  - For example, it need to be persistant for span_assignments.
* We now export explicitly the 'location' field which is managed by
  low-level drivers.
* We will use this field as the location in span_assignments.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
xpp: Firmware for Astribanks 2.02

Astribank 2.02: a newer model: slight variation of 2.01 (both use E-Main
4). Uses the same USB firmware, has to use a different FPGA firmware as
newer devices cannot be made to work with older 2.01 firmware.

FPGA rev. 11307.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
xpp: Firmware for Astribanks 2.02: Makefile

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>