Compare commits

...

172 Commits

Author SHA1 Message Date
Shaun Ruffell
a951dd5e32 wcte43x: Do not reconfigure framer when span lineconfig is not changed.
If dahdi_span_ops.spanconfig is called multiple times in a row (like when
running dahdi_cfg; dahdi_cfg ) the tx signaling bits would go through a spurious
state that some far side devices would respond to.

Now, if the dahdi_span_ops.spanconfig callback is called, and the configuration
matches the existing configuration, we will not touch the framer.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-07-11 14:14:15 -05:00
Shaun Ruffell
8210fea5b3 wcte13xp: Do not reconfigure framer when span lineconfig is not changed.
If dahdi_span_ops.spanconfig is called multiple times in a row (like when
running dahdi_cfg; dahdi_cfg ) the tx signaling bits would go through a spurious
state that some far side devices would respond to.

Now, if the dahdi_span_ops.spanconfig callback is called, and the configuration
matches the existing configuration, we will not touch the framer.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-07-11 14:14:15 -05:00
Shaun Ruffell
a1ff3cb0c0 dahdi: Stop tones on channel when updating tone zone.
If a channel is currently playing a tone when the tone zone is updated, the
existing tone zone could be freed while the channel keeps a reference to the
current tone (curtone) that points into the freed zone.

If the newly freed tone is then modified, there was a window where it was
possible to  corrupt 'struct dahdi_chan' (by overrunning swritechunk[])
resulting in a "BUG: unable to handle kernel paging request at virtual address"
panic in the context of __dahdi_transmit_chunk().

Reported-and-Tested-by: Matt Behrens <matt@zigg.com>
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-07-07 12:25:36 -05:00
Shaun Ruffell
089b593b56 wct4xxp: Report rx signalling bit changes after spanconfig.
This fixes a long standing issue where, for CAS signaling, the RX bits were
sometimes misreported after span configuration before the first detected state
change.

The logic in the wct4xxp driver now matches that in the wcte43x driver and
wcte13xp drivers. The wcte12xp driver always polls the sigbits due to how
voicebus works and is not affected by this.

Internal-Issue-ID: DAHDI-1081
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-06-27 22:40:28 -05:00
Shaun Ruffell
71867c3de7 wcte43x: Do not get stuck in "Not Open" state when DAHDI_CONFIG_NOTOPEN is set.
This is the same change for the wcte13xp driver but applied to the other
xbus-based digital card.

If dahdi_cfg set the DAHDI_CONFIG_NOTOPEN setting on the span, which it does
when the "yellow" flag is added to the span config line, then it was possible
for the span to get stuck with DAHDI_ALARM_NOTOPEN (NOP).

This is because the driver only updates the alarm state when the framer reports
that the span alarm has changed. Therefore, unless the framer goes through an
alarm transition, the fact that channels are opened was never noticed by alarm
handling routine.

Now check the alarm state directly when the first channel is opened, and the
last channel is closed.

Internal-Issue-ID: DAHDI-1103
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-20 13:01:27 -05:00
Shaun Ruffell
61aeaf13ae wcte43x: Change span flags to atomic bitfield.
This will facilitate adding another flag for open channels on a span without
needing to add a lock on the span, or taking the global lock. Currently the span
flags are protected by the global reglock. This is not longer required.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-20 13:01:27 -05:00
Shaun Ruffell
f35e8aafb0 wcte13xp: Do not get stuck in "Not Open" state when DAHDI_CONFIG_NOTOPEN is set.
If dahdi_cfg set the DAHDI_CONFIG_NOTOPEN setting on the span, which it does
when the "yellow" flag is added to the span config line, then it was possible
for the span to get stuck with DAHDI_ALARM_NOTOPEN (NOP).

This is because the wcte13xp driver only updates the alarm state when the framer
reports that the span alarm has changed. Therefore, unless the framer goes
through an alarm transition, the fact that channels are opened was never noticed
by alarm handling routine.

Now check the alarm state directly when the first channel is opened, and the
last channel is closed.

Internal-Issue-ID: DAHDI-1103
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-20 13:01:27 -05:00
Shaun Ruffell
b3a6b91858 Do not call dahdi_span_ops.open with spinlock held.
This makes the open symmetrical with the close. It is also considered good
practice to not call through callbacks with spinlocks held.

I modified all the drivers where I could not tell whether it was necessary to
hold the chan->lock with interrupts disabled to simply take the lock inside the
callback.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-20 13:01:27 -05:00
Shaun Ruffell
2e33bdc7b5 tor2: Remove unused open/close callbacks.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-20 13:01:27 -05:00
Shaun Ruffell
3755ec9bf2 wct4xxp: Remove unused open/close span_ops callbacks.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-20 13:01:27 -05:00
Doug Bailey
47f0fde0f1 wct4xxp: AMI w/CAS errata applies to octal card as well.
Fixes inability to reliably get CAS (robbed-bits) when using AMI line encoding
on the TE820 card.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-20 13:01:27 -05:00
Shaun Ruffell
180a17a39c wct4xxp: Trivial kmalloc + memset -> kzalloc.
Just a minor cleanup.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-20 13:01:27 -05:00
Shaun Ruffell
d1afa1b101 oct612x: Implement the SerializationObject callbacks.
When originally implemented, the octasic calls where protected by the big kernel
lock. This change now allows the octasic library to control it's synchronization
as originally intended.

It would still be worthwhile to completely make the oct612x library
kernel-compliant.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-20 13:01:27 -05:00
Shaun Ruffell
b4941f35ad wct4xxp: Move bottom half processing from tasklet to workqueue.
I am primarily making this change in order that the oct612x API can use a mutex as
a synchronization primitive. Mutexes can only be aquired in process context and
the wct4xxp driver calls the Oct61000InterruptServiceRoutine (which grabs a
serialization object) when tone detection is enabled.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-20 13:01:27 -05:00
Shaun Ruffell
a3578ca156 dahdi: dahdi_chan.ec_factory can be protected with the mutex.
This is never accessed or modified in interrupt context. This closes a potential
race if the echocan is being changed on a channel while enabling disabling is
hapening on another thread.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-20 13:01:27 -05:00
Shaun Ruffell
761e02da52 dahdi: Protect echocan creation/destruction with mutex.
This closes a reference and memory leak when multiple CPUs are enabling echocan
on a single channel in parallel.

The essential problem is that the call to try_module_get() is not serialized.
Two separate threads can come into ioctl_echocan() on the same channel, they
coordinate via the dahdi_chan.lock to release any current echocan, but then both
create a new echocan state, bump the reference on the module, and the last one
through will actually attach the new state to the channel. The earlier reference
/ memory is leaked.

I tried to conceive of a way to fix this leak without adding a new lock, but the
choices where calling throught the function pointers with dahdi_chan.lock.
Otherwise I needed to change the semantics of echocan_create /free which would
ripple through the hardware echocan modules.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-20 13:01:27 -05:00
Shaun Ruffell
cb50ae1500 wctc4xxp: spin_lock() -> spin_lock_irqsave() in wctc4xxp_watchdog()
Since commit (e10f740 "wctc4xxp: Service tx ring in interrupt handler."), it
was possible to deadlock the system if the interrupt fires while the
watchdog function is running in the context of the system timer.

This was reported by lockdep.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-10 11:33:00 -05:00
Shaun Ruffell
e9ec13dfa0 wctc4xxp: Trivial reduction of indentation level in wctc4xxp_watchdog()
Now use a continue after the check for cmd->timeout. This change is because I
need to make another change but the deep indentation level would make it hard to
stay within the 80 column limit.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-10 11:33:00 -05:00
Shaun Ruffell
dfa8a0ebd3 wctc4xxp: Trivial removal of unused structure members.
These were left over from recent developments and are not used by the driver.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-05 11:35:42 -05:00
Shaun Ruffell
6e10dbdfb6 wctc4xxp: Constrain RTP payload to 500 bytes.
This is a limitation of the DTE firmware that normally would result in dropped
packets on the firmware. If the driver knows it is going to be dropped it should
drop it.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-05 11:35:42 -05:00
Shaun Ruffell
2010bc6433 wctc4xxp: Reload the firmware if a fatal alert was received.
The driver will now automatically reload the firmware when there are no open
channels if the firmware reports a fatal error. If the firmware reports an
error, but it was not fatal, it will leave things running and try to reload when
all channels are shut down. The driver will also halt channel processing and
reload the firmware if a channel ever failed to be created.

The thought is that if the DTE reports a non-fatal error, I cannot be certain
what the state is, and it should be reset when possible without impacting
otherwise functioning card.  If there are problems, presumably all users would
hang up and the driver will then reload the firmware.

If the error is fatal, then all processing is halted to encourage everyone to
hang up. The card is probably not working at this point anyway, so there is no
point in trying to communicate with it.

Also included in this change is a compile-time selectable debug sysfs attribute
that will allow forcing an alert condition for testing the recovery.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-05 11:35:42 -05:00
Shaun Ruffell
624f30bbf6 wctc4xxp: Trivial fix typo that was preventing firmware load.
The interrupt handler was not schedulding the deferred processing routine when
there was packets to process. I did not test the actual master branch after
editing for checkpatch compliance. Sorry.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-06-02 06:08:08 -05:00
Shaun Ruffell
d7c0b0aba1 wctc4xxp: Prevent exhausting memory in firmware.
If the host system sends to many packets to the DTE to process, the on-card
memory can be exhausted which will result in an out of memory alert. In commit
2ac2338247, the driver will halt all communication
with the card and request a reload if any alert is received.

Now the driver will silently drop any "burst" traffic that was sent to the
transcoder as opposed to expecting the firmware to do it. There is currently a
limit of 640 samples (80ms of audio) in flight to the firmware at any one time
allowed.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-30 15:07:20 -05:00
Shaun Ruffell
e10f740476 wctc4xxp: Service tx ring in interrupt handler.
This helps to keep the tx descriptor ring at max capacity when the system is
otherwise loaded. Now ready packets are moved from cmd_list to the transmit
descriptor ring directly in the interrupt handler and not when the deferred
function runs.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-30 15:07:20 -05:00
Shaun Ruffell
dc92bf05cd wctc4xxp: Fix the timestamp calculation for the RTP stream.
I do not have any evidence that this made a difference, but hopefully it will
clear things up for people in the future who might be wondering why the
timestamp does not increase with the number of samples actually sent.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-30 15:07:20 -05:00
Shaun Ruffell
8557bb6786 wctc4xxp: Speed up the rate of polling.
The polling interval was not fast enough to keep the tx ring full on a loaded
card. This fixes a regression introduced in commits
ba05e31c8a and
354d88cd41.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-30 15:07:20 -05:00
Shaun Ruffell
5981b152de wctc4xxp: Handle all known interrupts regardless of mask.
When switching to polling mode it was possible that we would mask off the
receive complete interrupt until the next timer fired. Now go ahead and handle
anything we know how to handle regardless of the current mask.

Also, no need to update the reg local anymore since it isn't used to ack any
interrupts. We now always ack all the interrupts first and inspect them all.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-30 15:07:20 -05:00
Oron Peled
cbe92363ea xpp: re-organize calls so worker_reset()
re-organize calls so worker_reset() isn't called twice
(was called from xbus_disconnect() and worker_destroy())

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-05-27 14:04:48 +03:00
Oron Peled
43a3dbb484 xpp: demote some NOTICE() to DBG()
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-05-27 14:04:48 +03:00
Oron Peled
9a00fc6321 xpp: stability -- better xbus shut down
* Maintain a "shutting_down" flag per-xbus
* Use it to prevent xbus dereferencing (via xbus_get()/xbus_put())
  during an xbus shutdown.
* Also, remove xbus from global array earlier.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-05-27 14:04:48 +03:00
Oron Peled
db07e1b74d xpp: stability -- deadlock in waitfor_xpds()
waitfor_xpds xbus sysfs file should not take an xbus refcount:

* It is called from sysfs which maintain its own device refcount.
* If put_xbus() calls xbus_destroy() than down the call chain it will
  try to release an object that is held by sysfs.
* This will create a deadlock.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-05-27 14:04:48 +03:00
Oron Peled
235d530fee xpp: stability -- better debug information
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-05-27 14:04:48 +03:00
Oron Peled
dfa7304f51 xpp: stability -- cleaner xpp_open/close
* No need to use spinlock.
 * Just correctly use the atomic open_counter.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-05-27 14:04:48 +03:00
Oron Peled
08127e14f7 xpp: stability fixes - xusb mutex
* Replace old semaphore with mutex
 * Use this mutex for BOTH usb probe/disconnect

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-05-27 14:04:48 +03:00
Shaun Ruffell
6e2698f4c1 wctc4xxp: Speed up channel setup / tear-down.
1) Enabling multiple csm_encaps channel commands in a single packet.
2) Sending commands to separate channels in parallel.

This reduces the time waiting for the responses to the commands and brings in
the channel setup from 50ms to under 10ms.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-20 11:36:23 -05:00
Shaun Ruffell
c9481d30bb pciradio: interruptible_sleep_on_timeout() -> msleep_interruptible()
interruptible_sleep_on_timeout() has been deprecated for awhile and was finally
removed in Linux 3.15. Since interruptible_sleep_on_timeout() uses jiffies for
the delay, I assumed that each jiffy equated to 10ms given the age of the
driver.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-20 11:36:23 -05:00
Shaun Ruffell
779d62791c Add #include <linux/slab.h> to all files that call kzalloc|kmalloc|kfree.
Some architectures, like arm, do not automatically pull in the definitions for
kzalloc and friends. This allows DAHDI to build on those platforms.

Originally reported to the asterisk-users mailing list here
http://lists.digium.com/pipermail/asterisk-users/2014-February/282338.html

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-20 11:36:23 -05:00
Shaun Ruffell
8342a3d21b wctc4xxp: Add debug option to print channel stats to kernel log.
This patch does a couple of things. It adds a new DEBUG mode where packet
statistics are printed when channels are closed which can be used to track where
packets might be lost in the transcoding chain.

This patch will also print to the kernel log if the AN983 has detected any
errored received packets. Problems of this type are typically system problems,
like when the card is having trouble DMAing packets.

Internal-Issue-ID: DAHDI-1071
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:58 -05:00
Shaun Ruffell
ba05e31c8a wctc4xxp: Allow the tx and rx descriptor rings to be different sizes
Keeping the transmit descriptor ring shorter reduces the time it takes to send
CSM_ENCAP commands to the transcoding engine when the card is otherwise busy.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:58 -05:00
Shaun Ruffell
b6a8623203 wctc4xxp: channel count does not need to be atomic.
It is only modified under the chanlock anyway.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:58 -05:00
Shaun Ruffell
354d88cd41 wctc4xxp: Use hardware timer for polling and not kernel timer
Simplifies the logic when polling is enabled. No need to worry about any system
factors when scheduling the default kernel timer.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:58 -05:00
Shaun Ruffell
0efce00a09 wctc4xxp: Make sure csm_encaps commands are sent before RTP.
Otherwise, if there are many RTP commands queued on the command list, some of
the CSM_ENCAP packets, like ACKS, weren't being sent to the firmware within the
timeout value.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:58 -05:00
Shaun Ruffell
67e422c1ef wctc4xxp: Reduce the number of locks grabbed when sending commands
Not only does this make it atomic when moving commands from the
waiting_for_response_list to the command_list if the descriptor is full, it will
also make the entire process of submitting a packet the packet transmission
logic atomic.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:58 -05:00
Shaun Ruffell
cbe4825d1a wctc4xxp: Trivial removal of the receiveprep function.
This was more a holdover when the AN983 interface was brought over from the
voicebus driver.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:58 -05:00
Shaun Ruffell
b5ac763f29 wctc4xxp: Cleanup RTP for unopened channels.
When we start the shutdown sequence for a channel, there is no need to submit
any RTP packets that are queued on the command list. Under extreme load with
many backed up RTP packets it was possible to have RTP packets submitted after
the channel shutdown process started.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:58 -05:00
Shaun Ruffell
6341783cc8 wctc4xxp: All the commands do not need to have completions embedded in them.
A small percentage of the total packets sent to the DTE ever wait for
completions. This will save on the need to keep the completion around in all the
packets.

Also, since we can use the presence of the completion as the flag whether we
intend to auto free, we can simplify the flags as well.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:58 -05:00
Shaun Ruffell
ea04099e77 wctc4xxp: Encode the function in the ACK.
While not required by the protocol to the DTE, this does help when debugging the
trace files.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:58 -05:00
Shaun Ruffell
bc274e1b5d wctc4xxp: We always want to ack the responses.
Furthermore, do it as soon as we know we should to prevent the ack from
potentially going out after another CSM_ENCAPS packet on another CPU.

Previously, we would not send ACKS to responses we believed we already responded
to.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:58 -05:00
Shaun Ruffell
44a33126e0 wctc4xxp: Only capture commands once they are on the descriptor ring.
Eliminates some cases where there are duplicated packets in the capture if the
hardware descriptor ring was already full.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:57 -05:00
Shaun Ruffell
3446cdca8f wctc4xxp: Do not allow duplicated sequence numbers to be received for the channels.
Makes the channels themselves behave like the supervisor channel. This only
protects the driver in the case the commands were severly backed up, like when
there was high packet loss.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:57 -05:00
Shaun Ruffell
391ca2b7aa wctc4xxp: Do not need locks on the transcoder buffers.
They are sufficiently protected by the list locks. This also cleans up a case
where the tcp was unlocked after already completing it, which was corrupting the
list.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:57 -05:00
Shaun Ruffell
ec9d162344 wctc4xxp: Check for shutdown after acquiring the mutex lock.
In case we missed an alert, this will allow for rapid shutdown of Asterisk.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:57 -05:00
Shaun Ruffell
7168b87cb5 wctc4xxp: Always ack a response packet.
Even if it is duplicated or we don't have an outbound message waiting, we should
ack it so that the firmware does not keep trying to send it to the host.
Otherwise the firmware could get into situations where it was constantly
retrying to send packets for which it did not receive our previous ACK and
exhaust memory.

I was only seeing this on platforms were packets were going missing in the
stream, increasing the probability that the driver would miss early responses.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:57 -05:00
Shaun Ruffell
f8a6f55e80 wctc4xxp: Enable the fatal bus error interrupt.
The kernel log will now contain reports if there are bus errors.
This is a troubleshooting aide on systems with bus issues.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:57 -05:00
Shaun Ruffell
6c796d0774 wctc4xxp: Replace channel semaphore with channel mutex.
Clarifies that the semaphore was being used as a mutex. Mutexes are also more
efficient and allow better debugging checks.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:57 -05:00
Shaun Ruffell
9c65971863 wctc4xxp: Remove unused debug ioctl interface.
The ioctls for the debug network interface on the tc400b0 has not been used for
a long time. It is now gone.

This will also allow the sempahore set in the ioctl to be changed into a mutex
which provides enhanced debugging checks.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:57 -05:00
Shaun Ruffell
2ac2338247 wctc4xxp: Halt the card when an alert is received.
When an unsolicited alert is received, we'll flag the card as halted so that
commands will not be retried. This is because often times the firmware will no
longer process any commands in this state and the driver will hold processes in
the dstate while waiting to retry the commands.

This is a debugging aide in that it simplies unloading the driver if the card /
driver is currently in a failed state.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:57 -05:00
Shaun Ruffell
3096ffe955 wctc4xxp: Disable read-line and read-line-multiple PCI commands.
The read-line-multiple command was already disabled on the voicebus cards, which
use the same interface, in commit 4de462c3e0. This
does the same thing for the transcoder card and also disables the read line
command.

I've seen this change directly correlated to problems with the AN983 receiving
packets from the onboard DSP on some platforms.

Internal-Issue-ID: DAHDI-1071
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:57 -05:00
Shaun Ruffell
039daca12e wctc4xxp: Make sure we call the pci_enable_mwi() function.
I've not seen this directly tied to any issue, but it's enabled on the voicebus
cards and so brings the wctc4xxp driver in line.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-05-16 12:06:57 -05:00
Tzafrir Cohen
15ff405dc8 xpp: pri: Fix more than a single CAS/R2 call
Fixes regression from bb63d03bba (before
v2.7.0). This failed to set the PCM mask on a CAS span when
DAHDI_AUDIO_NOTIFY was not set.

As the first channel of each xbus would be enabled (for
synchronization), a single call may still have passed.

This patch sets the PCM mask on any CAS channel explicitly.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-04-30 22:44:46 +03:00
Oron Peled
5e24d501c5 xpp: prevent double dahdi un-registration
* It's currently harmless (just re-run the pre/post XPD registrations)
* But it's cleaner this way (as with xbus_register_dahdi_device())

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-04-30 22:44:46 +03:00
Oron Peled
193c9e59a8 xpp: new xbus attribute: dahdi_registration
XPP devices have implicit support for device registration and
unregistration. Even though it is only used for the legacy (non-hotplug)
configuration case, we still prefer to make it explicit.

This attribute would later allow a simpler implementation of the user
space (xpp-specific) tool dahdi_registration.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-04-30 22:44:46 +03:00
Oron Peled
606dd58a47 xpp: fix failed multi-PRI E1<->T1 transition
In an Astribank with >= 2 PRI ports, switching from E1 to T1 at run-time
may fail at the DAHDI_CHANCONFIG ioctl on the first channel in a span,
That is, on first run of dahdi_cfg, it fails on second span, on second:
it fails on third span, etc.

The code clears the D-channel information on the DAHDI_CHANCONFIG call
for the first channel in the span.

However The code tested for the global "channo" rather than the per-span
"chanpos" to check for the first channel in the span. This the test
failed.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-04-30 22:44:46 +03:00
Tzafrir Cohen
adfd0910b7 Don't install firmware to /usr/lib/hotplug/firmware
/usr/lib/hotplug/firmware is an old location not used since the move
from the old hotplug system. We no longer need to support it. No need to
keep two copies of the firmware files.

Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-04-30 13:58:07 -05:00
Shaun Ruffell
a66db43356 wcte43x: Build against 2.6.18 and CentOS 5.5
This is to support users who are unable to update to the lastest CentOS 5.x.
There is no change for most users on the latest releases of their distribution.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-04-30 13:58:07 -05:00
Shaun Ruffell
6649a3a166 wcte43x: Trivial fix of 'source' in comment.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-04-30 13:58:02 -05:00
Shaun Ruffell
8256ba602e wctc4xxp: Trivial. Remove unused timer_list from struct tcb.
The timer_list member of the transcoder buffer has not been used for a long
time. Saves some space in the buffer in addition to removing any future
curiosity about what it is for.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-04-30 13:34:58 -05:00
Shaun Ruffell
c8b0d91972 dahdi: Define pf_fmt() globally in kernel.h
Normally the board drivers should define this, but if they do not we will
provide a suitable default. This allows compilation with vanilla Linux 2.6.18.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-04-30 13:34:29 -05:00
Shaun Ruffell
b6eb7ae6d8 wcte43xp: Close potential unbalanced call to enable_irq().
If the memory allocation for the new channel array fails, it would be possible
to call enable_irq() without the corresponding call to disable_irq().

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-04-01 11:53:00 -05:00
Shaun Ruffell
f6edaf5cea wcte13xp: Remove redundant call to synchronize_irq().
disable_irq() already synchronizes with any running handlers.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-04-01 11:46:46 -05:00
Shaun Ruffell
f2a3c1c963 wcte13xp: Trivial. Remove duplicate pointer to "struct pci_dev".
This pointer was left over during the switch to the wcxb library.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-04-01 10:45:36 -05:00
Tzafrir Cohen
22f034a307 firmware: Honor DESTDIR when installing firmware.
This fixes a regression introduced first in release 2.9.1 with commit
(7ce8498465 "firmware: Refactor by using build_tools/install_firmware.")
which prevents from installing the firmware in a location other than the system
root.

Bug: https://issues.asterisk.org/jira/browse/DAHLIN-337
Reported-by: Anthony Messina <amessina@messinet.com>
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
[edited the commit message]
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-03-31 09:22:10 -05:00
Oron Peled
6593097586 xpp: fix PANIC for old dahdi_registration
* dahdi_registration writes multiple times to:
     /sys/bus/astribanks/devices/*/*/span
* In some race cases this resulted in corruption and eventual kernel
  panic.
* Until migration to "assigned-spans" is complete:
  - Accept and ignore multiple "dahdi registrations" from user-space.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-03-23 17:25:52 +02:00
Shaun Ruffell
e62f0f1835 wcxb: Disable presence detect reporting on upstream port during PCIe hard reset.
When the card goes through a reset the PCIe link will be brought down. Some
slots will report this change upstream to the root port which will believe that
the card has been hotplugged out of the system.

This fixes cases on some systems where, during a firmware update, the card gets
removed from the system's logical PCI tree with messages like the following in
the kernel log:

  pciehp 0000:00:1c.0:pcie04: Card not present on Slot(259)
  pciehp 0000:00:1c.0:pcie04: Card present on Slot(259)

Internal-Issue-ID: DAHDI-1091
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-03-19 15:34:32 -05:00
Shaun Ruffell
e4fce6849a wcte43x: Update firmware for TE435 / TE235 to e0019.
This firmware image is able to handle system conditions that would result in
spans internmittenly going down and recovering.

Internal-Issue-ID: DAHDI-1087
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-03-17 12:02:47 -05:00
Shaun Ruffell
bc0c04fb13 wcaxx: Update firmware for A8B/A4B to 1d0019/b0019.
These firmware images can handle system conditions that would previously result
in transmitted audio being intermittently silenced and then unsilenced.

Internal-Issue-ID: DAHDI-1087
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-03-17 12:02:47 -05:00
Shaun Ruffell
45b4937a35 wcte13xp: Update firmware for TE133/TE131 to 780019
This firmware image is able to handle system conditions that would result in
spans going down and then coming back intermittently.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-03-17 12:02:47 -05:00
Shaun Ruffell
50f2fd15b6 wcxb: Add diagnostic message if DMA retries are increasing when DEBUG is defined.
There are some platforms where the DMA operation to the host does not complete
within the required 50us. When this happens some versions of the firmware will
issue a retry and increment the retry field in the descriptor status word.

Now if this driver is configured in DEBUG mode, the presence of these retries
will be printed to the kernel log as a potential troubleshooting aide.

Internal-Issue-ID: DAHDI-1087
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-03-17 10:33:14 -05:00
Shaun Ruffell
665bf9feb6 wcxb: Reset TDM engine on IO errors.
There are error conditions that the firmware can detect but cannot recover from
without help from the driver. When firmware detects these conditions the
DESC_IO_ERROR bit will be set in the descriptor header to signal that the driver
should reset the TDM engine on the card. Since this is not due to failure of the
host to service the interrupt in time, it does not make sense to increase
latency when these conditions are detected.

Internal-Issue-ID: DAHDI-1087
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-03-17 09:24:30 -05:00
Shaun Ruffell
b817c7625a wcxb: Print running version when recommending power cycle.
Without this change it's hard to see what is actually running on the card when
the firmware in the flash doesn't match the reported version. This is a
debugging aide.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-03-13 01:44:18 -05:00
Shaun Ruffell
6cebc1c1fb build_tools/install_firwmare: Try to extract the .bin file from .tar.gz
This allows a .tar.gz file that is normally downloaded from the server to be
checked directly into a test branch. Now when the firmware is being installed,
it can be extracted from any present .tar.gz.  Again, this is primarily to
simplify testing.

A nice side effect is that when going from a newer version to an older version,
any stale .bin files in the firmware directory will not be installed into
/lib/firmware, but instead the bin file from the *versioned* .tar.gz will always
be installed. This should reduce problems where you have to run "make
dist-clean" when reverting to an older version that has a firmware change.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-03-12 23:45:16 -05:00
Shaun Ruffell
7ce8498465 firmware: Refactor by using build_tools/install_firmware.
This is intended to simplify the Makefile and move a large common part into a
subscript. The behavior is the same as it was before.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-03-12 23:12:40 -05:00
Oron Peled
d4868092bf xpp: PRI stability fixes
* We didn't handle proper E1/T1 transitions after device registration.

* Fix SPAN_REGISTERED(xpd):
  It now checks for DAHDI_FLAGBIT_REGISTERED as well, as this flag is
  set/clear by assign/unassign.

* From set_pri_proto():
  - Always free/allocate channels
  - Always call dahdi_init_span()

* Improve phonedev_cleanup() safety:
  - NULL pointers after free.
  - Zero number of channels at the end.

* Refactor channel allocation out of phonedev_init():
  - Into phonedev_alloc_channels()
  - Also called from xpd_init_span() to prevent duplicated logic.
  - And called from set_pri_proto() to prevent our bug.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-02-05 20:19:08 +02:00
Tzafrir Cohen
06c45b7cd8 dahdi_get_auto_assigned_spans
Commit 74e949c33a exported the module
variable dahdi.auto_assigned_spans. However this is not a good name.

This commit reverts the export and replaces it with a new function to
get the value of the variable.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-02-05 19:25:20 +02:00
Tzafrir Cohen
fdca6f36de sysfs: registration_time: use ktime_get_ts
A fix to 03b3ce1a10: use ktime_get_ts
instead of getnstimeofday to better handle system time changes.
(Shaun Ruffell)

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-28 20:39:21 +02:00
Tzafrir Cohen
02f6b4e7bd README: The sysfs class now includes no channels
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-28 20:24:40 +02:00
Tzafrir Cohen
701ed41adf README: the new registration_time device attribute
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-28 20:17:26 +02:00
Oron Peled
03b3ce1a10 sysfs: new device attribute: registration_time
Add a new sysfs attribute to dahdi_device: registration_time

* Records the time of the device's registration with DAHDI.
* Used by dahdi_auto_assign_compat to assign spans by device
  registration order when backward compatibility needed.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>
2014-01-28 20:04:22 +02:00
Tzafrir Cohen
2c4373972b README: xpp.dahdi_autoreg is deprecated
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-28 19:27:05 +02:00
Oron Peled
2ecf700dd8 xpp: continue xpp.dahdi_autoreg deprecation
* Set it to 0 by default (as we use dahdi.auto_assign_spans now)
* Make it readonly (no runtime changes)
* Warn during startup if it was forced to 1

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-28 19:24:27 +02:00
Oron Peled
74e949c33a xpp: deprecate dahdi_autoreg
Instead, use the inverse of dahdi.auto_assign_spans value.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-28 19:24:15 +02:00
Russ Meyerriecks
3efa9d8cd1 wcte13xp: wcxb: Add delayed reset firmware feature
Allow certain older firmwares to delay the hard reset until a full power cycle.
This way we can "preload" newer firmware images, without requiring the user to
physically power off/on their machine.

Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>
2014-01-24 13:14:14 -06:00
Shaun Ruffell
4cd09feb54 wcte43x, wcte13xp, wcaxx: Bump irqmisses counter when there are DMA underruns.
This makes the behavior of IRQ misses for these drivers behave the same as the
wcte12xp, wctdm24xxp, and wct4xxp drivers.

Previously irqmisses would never increase. The presence of underruns would still
show up in dmesg as latency bumps.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-22 18:04:47 -06:00
Shaun Ruffell
1f024713ed wct4xxp: Trivial drop of unnecessary local variables.
These were left over from when the VPM callbacks depended on the different VPM
installed. On the wcte43x this is unnecessary.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-22 18:04:47 -06:00
Shaun Ruffell
0b499d9566 wcte43x: Trivial drop of unnecessary local variables.
These were left over from when the VPM callbacks depended on the different VPM
installed. On the wcte43x this is unnecessary.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-22 18:04:47 -06:00
Russ Meyerriecks
438b2a36b3 wcte13xp: wcaxx: wcte43x: Remove VPM_SUPPORT compile option.
This was a legacy compile time option that is no longer necessary with the new
series of cards.

Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-22 13:40:27 -06:00
Russ Meyerriecks
be94aa11bb Revert "dahdi: Change auto_assign_spans default from 1 to 0."
This reverts commit c49a56c954.

Delaying this feature until after v2.9 release.
2014-01-21 16:36:44 -06:00
Russ Meyerriecks
1add33efe7 wcte13xp: Add support for te131 and te132 products
These are similar to te133 and te134 but without integrated echo cancel.

Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-17 15:43:06 -06:00
Russ Meyerriecks
094e30483d wcte13xp: Update firmware to 0x780017
This firmware adds support for the te131 and te132 products.

Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-17 15:33:25 -06:00
Russ Meyerriecks
e4ea886ee0 wcte13xp: wcaxx: Fix broken devicetype attributes
struct dahdi_device.devicetype was set incorrectly in both drivers. This caused
the vpm module to not show up after the device name when reading this field
from a spanstat.

Reported-by: Charles Moye <cmoye@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-17 15:30:38 -06:00
Shaun Ruffell
860eb4ab48 dahdi: Do not access invalid memory if invalid local span number is passed to spantype attribute.
This fixes potential kernel panic due to accessing invalid memory if passing
invalid local span number to 'spantype' attribute via sysfs.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-01-14 16:03:18 -06:00
Shaun Ruffell
47dcc9377c wcte43x, wcte13xp: Use MSI interrupts if possible.
It was an oversight to prevent the wcte43x and wcte13xp drivers from using
Message Signaled interrupts during the switch to the wcxb library.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-08 12:21:10 -06:00
Shaun Ruffell
f10eb3f547 wcte13xp: Export max_latency module parameter.
wcte13xp now has a max_latency module parameter like the wcaxx and wcte43x
drivers.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-08 12:21:10 -06:00
Shaun Ruffell
99de304d84 wcaxx, wcte13xp, wcte43x: Honor max_latency module parameter.
The wcxb library did not do actually use the max_latency member to limit the
maximum latency of the DMA engine.

Now it does.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-08 12:21:10 -06:00
Shaun Ruffell
c49a56c954 dahdi: Change auto_assign_spans default from 1 to 0.
The infrastructure has been put in place in 2.8.0 for fully dynamic device and
span configuration. This will be the default mode in DAHDI-Linux 2.9.0.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
Acked-by: Oron Peled <oron.peled@xorcom.com>
2014-01-06 13:24:28 -06:00
Shaun Ruffell
e6b16eace1 dahdi: Move clearing of DAHDI_ALARM_NOTOPEN to __dahdi_assign_span().
Previously this was in __dahdi_init_span(). The problem was that
__dahdi_init_span() was only called when a spans' line mode was being changed.
Therefore it was possible to unassign and resassign an analog span and leave it
stuck in the 'NOP' alarm state.

It also make the setting / clearing of DAHDI_ALARM_NOTOPEN symetrical about span
unassignment / assignment in addition to updating the alarm states on all the
channels on the span via the dahdi_alarm_notify() function.

This is a better version of commit 496f817773.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-12-26 17:04:29 -06:00
Shaun Ruffell
3933ffd350 wctdm24xxp: Reset module specific type information on probe.
This fixes an issue that affects TDM410 modules when there is not a module
installed in the first port, but there is an FXO module installed in the third
port.

When scaning for QRV modules in the first port, the 3rd port will have the
'hook' struct.qrv set to 0xff. When a QRV module is  not detected, that value
will be left, which then maps to an invalid state for both fxo.ring_state and
fxo.battery_state.

The result would be that FXO ports would fail to run the ring detector state
machine since it did not know what the current state was.

Now we'll just reset all the values in struct fxo or struct fxs to the expected
init state.

Internal-Issue-ID: DAHLIN-332
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-12-20 14:15:26 -06:00
Russ Meyerriecks
05bf6ac601 wcte13xp: Fix bug preventing recover timing from ever being set
A bug introduced in v2.8.0 prevented the recover timing configuration from
being set properly on the hardware. This caused the card to never go into
recovered timing mode.

Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-12-18 18:15:21 -06:00
Shaun Ruffell
d536c3e203 build_tools/dkms-helper: Helper script for DKMS integration.
DKMS (Dynamic Kernel Module Support) [1] provides a mechanism where kernel
modules can be automatically updated when a new kernel is booted.  This is a
simple helper script to automate the process of adding dahdi-linux to the local
DKMS system.

[1] http://linux.dell.com/dkms/

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-12-12 16:08:43 -06:00
Shaun Ruffell
2e7acd212e xpp: Replace drv_attrs with drv_groups on kernels > 3.12
drv_attrs was fully removed from the bus structure in upstream commit
e18945b159a1cdbc031f1d3b0b7e515a33bdcbf7 which was merged into 3.13.

This is necessary to compile against linux kernel version 3.13.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-12-06 15:42:46 -06:00
Shaun Ruffell
71c003ba49 dahdi: Fix previous CentOS 6.5 commit.
The previous commit from earlier today to fix the backport of PDE_DATA was
wrong in that it would not then process the other defines for older kernels if
it detected it was running on a redhat release.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-12-02 16:51:06 -06:00
Shaun Ruffell
3707ee713e Revert "wcaxx: Use startup/shutdown callbacks to protect access to channel registers."
This reverts commit 1cf7d9b08c.

It turns out this change was not necessary.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-12-02 16:23:58 -06:00
Shaun Ruffell
f5d3b35d7b dahdi: Replace drv_attr with drv_groups on kernels > 3.12.
drv_attrs was fully removed from the bus structure in upstream commit
e18945b159a1cdbc031f1d3b0b7e515a33bdcbf7 which was merged into 3.13.

This is necessary to compile dahdi against linux version 3.13.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-12-02 15:47:56 -06:00
Shaun Ruffell
6bcc70a421 wcte43x: Update firmware to version e0017.
This resolves issues where, when using internal timing, the first channel of
span 3 has occassional corrupted data in transmit stream.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-12-02 15:46:39 -06:00
Shaun Ruffell
d389f9f743 wcaxx: Add extra dummy read when checking for single fxs modules.
This extra read eliminates some problems with detecting certain S100M modules.
It is unclear at this time why it is necessary.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-12-02 15:46:39 -06:00
Shaun Ruffell
0faac26dde wcxb: Do not access cur_transfer/cur_msg outside of lock.
The spi master cur_transfer and cur_msg should only be changed under the
spin_lock for the master. The result is that if running user space tools, like
fxstest, that check registers on the modules, it's possible to have a message
that was not yet complete flagged as completed which would result in a bad read.

This does not affect "normal" operation of the wcaxx driver since interrupts are
not enabled during module detection, and during normal operation all access to
the resgisters is done in the context of the interrupt handler. This would only
be an issue if the interrupt handler was running and register accesses are tried
in user space context on an SMP system.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-12-02 15:46:39 -06:00
Oron Peled
d803fad133 Makefile: new 'make-dist' target
Creates a tar.gz:
* Identical results to the existing distributed tarballs
* Named "dahdi-linux-<version>.tar.gz"
* Only from committed files (uses git-archive)
* Adds a .version file

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-12-02 22:59:00 +02:00
Shaun Ruffell
acfec5dfbb wcxb: is_pcie -> pci_is_pcie()
is_pcie attribute was finally dropped from struct pci_dev in
upstream commit 115e3bc5e23e7ec3c85a2014bfa96c0ddd036083.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-12-01 22:44:09 -06:00
Shaun Ruffell
5ec9d756aa dahdi: CentOS 6.5 backported PDE_DATA definition.
This will fix the "error: redefinition of 'PDE_DATA'" error when compiling.

Internal-Issue-ID: DAHLIN-330
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-12-01 19:57:44 -06:00
Shaun Ruffell
4bfdd8bea5 dahdi: Remove "ddev" symlink before unregistering the span device.
This makes the order of operations for device removal symmetrical with those for
device addition. This change also eliminates the following warning when
unloading dahdi after dynamic spans have been created:

  ------------[ cut here ]------------
  WARNING: at /build/buildd/linux-3.2.0/fs/sysfs/inode.c:324 sysfs_hash_and_remove+0x92/0xa0()
  Hardware name: VirtualBox
  sysfs: can not remove 'ddev', no directory
  Modules linked in: dahdi_dynamic_loc(O-) dahdi_dynamic(O) dahdi(O) crc_ccitt
     hdlc_cisco hdlc vboxvideo(O) drm vboxsf(O) vesafb ppdev psmouse parport_pc
     serio_raw mac_hid vboxguest(O) nfsd nfs i2c_piix4 lockd fscache auth_rpcgss
     nfs_acl sunrpc ext2 lp parport e1000 [last unloaded: dahdi]
  Pid: 3533, comm: rmmod Tainted: G        W  O 3.2.0-56-generic-pae #86-Ubuntu
  Call Trace:
   [<c105ab42>] warn_slowpath_common+0x72/0xa0
   [<c11a7992>] ? sysfs_hash_and_remove+0x92/0xa0
   [<c11a7992>] ? sysfs_hash_and_remove+0x92/0xa0
   [<c105ac13>] warn_slowpath_fmt+0x33/0x40
   [<c11a7992>] sysfs_hash_and_remove+0x92/0xa0
   [<c1385427>] ? device_del+0x127/0x150
   [<c11a9bd0>] sysfs_remove_link+0x20/0x30
   [<d8a03fa3>] span_sysfs_remove+0xa3/0x170 [dahdi]
   [<c1036a88>] ? default_spin_lock_flags+0x8/0x10
   [<d89f7e5e>] _dahdi_unassign_span+0xae/0x210 [dahdi]
   [<c1053f6b>] ? __cond_resched+0x1b/0x30
   [<c15a9859>] ? _cond_resched+0x29/0x30
   [<d89f80a3>] dahdi_unregister_device+0xe3/0x190 [dahdi]
   [<d8936464>] dahdi_dynamic_unregister_driver+0x84/0x130 [dahdi_dynamic]
   [<d89284ed>] dahdi_dynamic_local_exit+0xd/0xb20 [dahdi_dynamic_loc]
   [<c1095995>] sys_delete_module+0x135/0x230
   [<c1110063>] ? pagetypeinfo_show.part.8+0x33/0x100
   [<c15b295f>] sysenter_do_call+0x12/0x28
  ---[ end trace b818e326720c8385 ]---

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-29 15:42:07 -06:00
Shaun Ruffell
c0d52a04cb wctdm24xxp: Remove assigned callback.
For the spans exported by the wctdm24xxp, the channels are not going to change
after they are already registered.

This eliminates a problem when analog spans are unassigned/reassigned and the
not_ready goes negative, thereby causing many warnings in the kernel.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-26 10:49:58 -06:00
Shaun Ruffell
1cf7d9b08c wcaxx: Use startup/shutdown callbacks to protect access to channel registers.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-25 16:19:28 -06:00
Shaun Ruffell
3a0905b1ec dahdi_dynamic: Create a span type for dynamic spans.
Fixes the following warning when loading the driver:

  dahdi: Warning: Span DYN/eth/eth1/00:50:c2:97:92:1d/1 didn't specify a spantype. Please fix driver!

The spantype is intended to be used by the auto configuration tools
(dahdi_genconf, pinned spans, etc..) but dynamic spans, since they are created
directly by dahdi_cfg, never take part in the pre-registration auto
configuration, therefore the span type was never used.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-24 10:09:33 -06:00
Shaun Ruffell
4a75f58156 oct612x: Make dependent on dahdi.ko
This change will ensure that the oct612x module is unloaded automatically when
/etc/init.d/dahdi stop is run.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-24 10:09:33 -06:00
Tzafrir Cohen
2b20289cb7 Ignore some more firmware files
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-11-24 17:22:39 +02:00
Oron Peled
dd944f3362 sysfs: new driver attribute: master_span
* This changeset adds master_span as an attribute of the span's driver:
  /sys/bus/dahdi_spans/drivers/generic_lowlevel/master_span
* This is mainly used for debugging.
* Reading from it the master span number (or 0 if there is no master
  span).
* Writing a number to it, force specified span to be master
* Existing Alternatives:
  - grep "MASTER" from /proc/dahdi/*
  - cat /sys/bus/dahdi_spans/devices/span-*/is_sync_master

(Note: commit d8fe2af23d is also Acked-By
Tzafrir Cohen <tzafrir.cohen@xorcom.com>)

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 17:20:04 +02:00
Oron Peled
d8fe2af23d xpp: automatic dahdi_registration by default
* Now with pinned-spans, we can assure reliable ordering
2013-11-24 15:34:57 +02:00
Oron Peled
35e9924b3c Rename "pinned spans" to "assigned spans"
Rename as terminology has changed. No change in kernel interface.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 15:03:35 +02:00
Oron Peled
a9c85de700 .gitignore: *.ko.unsigned
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 14:55:49 +02:00
Oron Peled
7a822db82c dahdi: Rename span 'master' as 'master_span'
* No functional changes.
* Rename the span 'master' to 'master_span' to avoid ambiguity with the
  'master' channel.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 14:54:27 +02:00
Oron Peled
007ff90025 sysfs: create symlink "ddev" to device of span
Create a "ddev" symlink from span's sysfs node to the one of its dahdi
device.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 14:54:03 +02:00
Oron Peled
be25fdb6fa remove udev rules: moved to dahdi-tools
* Removed xpp.rules
* Removed generation of dahdi.rules

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 14:53:20 +02:00
Oron Peled
06daf6c270 live_dahdi: load "dahdi" with tools_rootdir=$DESTDIR
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 14:52:35 +02:00
Oron Peled
1672e07deb Also send DAHDI_TOOLS_ROOTDIR with device events
Send the new DAHDI_TOOLS_ROOTDIR and existing DAHDI_INIT_DIR with udev
device events as well.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 14:51:24 +02:00
Oron Peled
7b578b83b9 dahdi: add "tools_rootdir" module parameter
* Passed to udev as DAHDI_TOOLS_ROOTDIR environment variable
* Default is "/"
* Deprecates the parameter initdir:
  - Defaults to $DAHDI_TOOLS_ROOTDIR/usr/share/dahdi
  - If specified: taken relative to $DAHDI_TOOLS_ROOTDIR
  - Setting both parameters explicitly is prohibited.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 14:51:14 +02:00
Shaun Ruffell
1ab5723b85 wcte43x: Remove 'dcxo' debug attribute.
Removes another bit of debugging instrumentation that I let slip through.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-20 09:39:12 -06:00
Shaun Ruffell
cbad5a7ae1 wcte43x: Do not grab reglock in handle_transmit/handle_receive.
If the driver is loaded with vpmsupport=0, then it was possible to create a
deadlock situation since the call into __dahdi_ec_chunk might then try to grab
the channel lock while already holding the reglock.

The purpose of grabbing reglock in the DMA routines was to protect the channel
array, which can be changed when linemode is changing. So instead, we'll
completely mask off that interrupt line from all CPUs when potentially changing
the channel array.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-20 09:33:07 -06:00
Shaun RuffellL
b3c6320374 wcaxx: Remove some left over debugging trace statements.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-17 02:36:29 -06:00
Shaun Ruffell
69a716af1a wcxb: Update the firmware meta block during flash update.
The meta block contains specific version and checksum information and allows the
test tools to validate the image in the flash.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-16 16:03:19 -06:00
Shaun Ruffell
eed2e4e00b wcaxx: Update A4B firmware to version 0b0017
Resolves some sporadic issues with invalid underruns.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-16 16:02:00 -06:00
Wendell Thompson
466acea7e0 wcte43x: Add driver for TE435/TE235 digital cards.
From: Wendell Thompson <wthompson@digium.com>

These new cards are based on a common architecture with the TE133/TE134 as well
as the new analog cards, A4A/A4B/A8A/A8B.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 14:39:19 -06:00
Russ Meyerriecks
3134b36d7e wcte13xp: Improve maintenance functions and error counters
From: Rus Meyerriecks <rmeyerriecks@digium.com>

* Removed work queue for maint interface as it is not needed in this driver
* Error counters are now accessible through the maint interface
* Consolidated and revised the big maint switch case
* Added loopup/loopdown code transmit logic to E1
* Now supports error/defect insersion

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 14:39:19 -06:00
Russ Meyerriecks
4707e19654 wcte13xp: Hold framer in reset to stop xmit on modprobe -r
From: Russ Meyerriecks <rmeyerriecks@digium.com>

The framer appears to continue transmitting a signal after modprobe -r. This
patch will leave the physical framer reset pin asserted to force the chip to
stop transmitting a signal when there is no driver attached.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 14:39:19 -06:00
Russ Meyerriecks
e42548f2c5 wcte13xp: Migrate to wcxb library
From: Russ Meyerriecks <rmeyerriecks@digium.com>

Removed all the custom logic and replaced with the common platform wcxb stuff.

There are also changes in here to standardize the function prefix in this
driver to t13x_.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 14:39:19 -06:00
Wendell Thompson
abe35059bc wcte13xp: Use interrupts for Falc alarms and signaling
From: Wendell Thompson <wthompson@digium.com>

Now uses framer interrupt vector polling (in the FPGA interrupt) for
alarm, loopcode, and signaling events eliminating continuous polling.
Now uses timer function for alarm and loopcode debouce, which only
executes during exception conditions.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 14:39:19 -06:00
Shaun Ruffell
348f6ab030 wcaxx: New driver for A4A/A4B/A8A/A8B analog cards.
This is a driver for the new line of analog cards that shares a common interface
with the TE133/TE134 and the TE435.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 14:39:19 -06:00
Shaun Ruffell
26efcf6902 wct4xxp, wcte13xp: Move the octasic DSP code into separate module.
The octasic library is relatively large and is currently separately linked into
both the wcte13xp and wct4xxp libraries. This change moves it out into a
separate loadable module.

The bigest change from the drivers perspectives is that they must provide a
table of callbacks instead of using statically linked Oct6100UserXxxxx functions
to allow the library to communicate with actual parts on the cards.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 14:39:19 -06:00
Shaun Ruffell
a648cef0f6 wct4xxp: If linemode changed via sysfs, reset the complete part.
This works around some issues with older versions of the firmware not
working properly after the linemode is changed via sysfs. Basically the
intent is to simulate redoing a complete driver reload with a new
linemode.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 14:39:19 -06:00
Shaun Ruffell
a5a52dbe94 wct4xxp: VPM companding switch print is now debug only.
This print happened when the linemode was changed via sysfs, but it didn't
really add much extra information that a user could act on.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 14:39:19 -06:00
Shaun Ruffell
43ad3eeb65 wct4xxp: Fix bipolar error insertion test mode.
This change wouldn't affect most people since it's only used by the error
injection code.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 14:39:19 -06:00
Shaun Ruffell
706dc43483 wct4xxp: Print warning in dmesg if span priority is not set correctly.
dahdi_genconf currently does not take into account the number of spans
configured for a particular board. Therefore if you have two dual span cards
installed in the system, it could be possible to have something like this in
/etc/dahdi/system.conf:

  spans=1,1,...
  spans=2,2,...
  spans=3,3,...
  spans=4,4,...

When what you really want is something like this:

  spans=1,1,...
  spans=2,2,...
  spans=3,1,...
  spans=4,2,...

Otherwise, spans 3 and 4 will be configured to not recover the clock from the
span which is most likely NOT what you want.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 14:39:19 -06:00
Shaun Ruffell
92f1e46b8f dahdi: Backport try_wait_for_completion() and list_first_entry()
This allows drivers to use the newer interface but build against older
kernels.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 14:39:19 -06:00
Shaun Ruffell
abb09a012d dahdi: Work around missing KBUILD_MODNAME
Some older versions of Kbuild will not pass KBUILD_MODNAME to a
compilation unit that is linked to multiple drivers. This change works
around this issue by globally modifing dev_dbg in this case.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 14:39:19 -06:00
Shaun Ruffell
7405dd6038 dahdi: Fix placement of '/' in output of /proc/dahdi/x
Fixes strings that look like:
  Span 1: TE2/0/1 "T2XXP (PCI) Card 0 Span 1" CCSHDB3//CRC4 RED

To look like:
  Span 1: TE2/0/1 "T2XXP (PCI) Card 0 Span 1" CCS/HDB3/CRC4 RED

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 14:39:18 -06:00
Shaun Ruffell
496f817773 dahdi: Clear DAHDI_ALARM_NOTOPEN when spans are re-initialized.
This eliminates the need for board drivers to always re-report their alarm
states when spans are unassigned and then reassigned.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 14:39:18 -06:00
Shaun Ruffell
4a6ecbbdeb dahdi_config: Remove unused NO_DCDC definition.
There are not any drivers in the tree that make reference to this definition
anymore, so it can be removed.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 14:39:18 -06:00
Tzafrir Cohen
bd0366287e xpp: Fail loading if no module on first slot
The driver assumes that the first slot is not empty. If this is not the
case, synchronization will not work.

Fail loading if this assertion does not hold.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-11-10 16:39:36 +02:00
Tzafrir Cohen
f287c0af7f xpp: mark an AB as failed if it gives bad desc
If we fail at handling the device descriptor from the Astribank, mark it
as in state "failed".

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-11-10 16:39:36 +02:00
Tzafrir Cohen
7adc74512e xpp: USB_FW.202.hex: provide as a symlink
Provide USB_FW.202.hex as a (install-time) symlink to USB_FW.201.hex.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-11-07 17:08:45 +02:00
Tzafrir Cohen
b993d25c5a xpp: Firmware for Astribanks 2.02: Makefile
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-11-06 16:57:48 +02:00
Tzafrir Cohen
41ae90a8a3 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>
2013-10-21 16:51:30 +03:00
Oron Peled
d4c8eb47ac 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>
2013-10-01 23:42:21 +03:00
Oron Peled
2bd36a3307 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>
2013-10-01 15:25:42 +03:00
Oron Peled
600dd03e30 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>
2013-10-01 15:23:56 +03:00
Oron Peled
3d1d87e526 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>
2013-10-01 15:22:32 +03:00
Oron Peled
745118acb9 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>
2013-09-29 19:13:26 +03:00
Russ Meyerriecks
ce3f1f2650 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>
2013-08-16 15:28:24 -05:00
Oron Peled
2ad4dc555f 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>
2013-07-30 15:04:00 +03:00
Shaun Ruffell
0469efb733 build_tools/make_version: Fix typo in build_tools/make_version.
The make_version script would test for a .version file in the proper location,
but then would not properly read it. Since make_version is always reading the
.version script correctly now, the Makefile can be slightly simpilfied and
always defer to it.

This has no user impact since build_tools/make_version was never used to read
the .version file previously but will allow external scripts to use the
make_version script.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-06-26 14:32:15 -05:00
Oron Peled
8ea23535dc sysfs: bugfix: shorten too long file names
* In old kernels (e.g: 2.6.18) sysfs file names must be shorter
  then KOBJ_NAME_LEN.

* Longer names are truncated and this leads to duplicate names
  which fails device_register()
  Examples: "dahdi!channels!10!10" is truncated to "dahdi!channels!10!1"

* The fix shorten the names and make them fixed length. Example:
            "dahdi!chan!010!010"

* It seems no current userspace tools rely on that name or on
  /dev/dahdi/channels .

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-06-23 22:12:33 +03:00
Russ Meyerriecks
431571b5fc wcte13xp: Start the span in unconfigured, instead of red state
This was causing inconsistancies with dahdi_scan showing an "UNCONFIGURED" span
in the "RED" state.

Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-06-14 14:55:37 -05:00
Shaun Ruffell
ab927f796b dahdi: Do not set rxbufpolicy when opening dahdi net device.
This fixes a regression introduced in 2.7.0 in commit
(da8b96d725 "dahdi: Remove unused 'rxbufpolicy'
and 'rxdisable' from dahdi_chan.") when CONFIG_DAHDI_NET is defined in
include/dahdi/dahdi_config.h.

rxbufpolicy was always hardcoded to immediate policy and was removed from the
channel structure. There is no longer any need to set it in dahdi_net_open.

Reported-by: Dave Fullerton <dfullertasterisk@shorelinecontainer.com>
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-06-11 10:25:10 -05:00
67 changed files with 34645 additions and 2746 deletions

9
.gitignore vendored
View File

@@ -5,6 +5,7 @@
*.mod
*.mod.[oc]
*.ko
*.ko.unsigned
*.cmd
*.order
*.tar.gz
@@ -38,4 +39,12 @@ drivers/dahdi/firmware/dahdi-fw-oct6114-256.bin
drivers/dahdi/firmware/dahdi-fw-tc400m.bin
drivers/dahdi/firmware/dahdi-fw-te820.bin
drivers/dahdi/firmware/dahdi-fw-vpmoct032.bin
drivers/dahdi/firmware/dahdi-fw-a4a.bin
drivers/dahdi/firmware/dahdi-fw-a4b.bin
drivers/dahdi/firmware/dahdi-fw-a8a.bin
drivers/dahdi/firmware/dahdi-fw-a8b.bin
drivers/dahdi/firmware/dahdi-fw-oct6114-032.bin
drivers/dahdi/firmware/dahdi-fw-te133.bin
drivers/dahdi/firmware/dahdi-fw-te134.bin
drivers/dahdi/firmware/dahdi-fw-te435.bin
drivers/dahdi/firmware/make_firmware_object

View File

@@ -47,8 +47,6 @@ ifeq (yes,$(HAS_KSRC))
HOTPLUG_FIRMWARE:=$(shell if grep -q '^CONFIG_FW_LOADER=[ym]' $(KCONFIG); then echo "yes"; else echo "no"; fi)
endif
UDEV_DIR:=/etc/udev/rules.d
MODULE_ALIASES:=wcfxs wctdm8xxp wct2xxp
INST_HEADERS:=kernel.h user.h fasthdlc.h wctdm_user.h dahdi_config.h
@@ -64,11 +62,7 @@ ASCIIDOC_CMD:=$(ASCIIDOC) -n -a toc -a toclevels=4
GENERATED_DOCS:=README.html
ifneq ($(wildcard .version),)
DAHDIVERSION:=$(shell cat .version)
else
DAHDIVERSION:=$(shell build_tools/make_version . dahdi/linux)
endif
DAHDIVERSION:=$(shell build_tools/make_version . dahdi/linux)
all: modules
@@ -86,12 +80,12 @@ include/dahdi/version.h: FORCE
fi
@rm -f $@.tmp
prereq: include/dahdi/version.h firmware-loaders oct612x-lib
prereq: include/dahdi/version.h firmware-loaders
stackcheck: $(CHECKSTACK) modules
objdump -d drivers/dahdi/*.ko drivers/dahdi/*/*.ko | $(CHECKSTACK)
install: all install-modules install-devices install-include install-firmware install-xpp-firm
install: all install-modules install-include install-firmware install-xpp-firm
@echo "###################################################"
@echo "###"
@echo "### DAHDI installed successfully."
@@ -100,7 +94,7 @@ install: all install-modules install-devices install-include install-firmware in
@echo "###"
@echo "###################################################"
uninstall: uninstall-modules uninstall-devices uninstall-include uninstall-firmware
uninstall: uninstall-modules uninstall-include uninstall-firmware
install-modconf:
build_tools/genmodconf $(BUILDVER) "$(ROOT_PREFIX)" "$(filter-out dahdi dahdi_dummy xpp dahdi_transcode dahdi_dynamic,$(BUILD_MODULES)) $(MODULE_ALIASES)"
@@ -122,13 +116,6 @@ uninstall-firmware:
firmware-loaders:
$(MAKE) -C drivers/dahdi/firmware firmware-loaders
oct612x-lib:
ifeq (no,$(HAS_KSRC))
@echo "You do not appear to have the sources for the $(KVERS) kernel installed."
@exit 1
endif
$(MAKE) -C $(KSRC) M='$(PWD)/drivers/dahdi/oct612x'
install-include:
for hdr in $(INST_HEADERS); do \
install -D -m 644 include/dahdi/$$hdr $(DESTDIR)/usr/include/dahdi/$$hdr; \
@@ -141,14 +128,6 @@ uninstall-include:
done
-rmdir $(DESTDIR)/usr/include/dahdi
install-devices:
install -d $(DESTDIR)$(UDEV_DIR)
build_tools/genudevrules > $(DESTDIR)$(UDEV_DIR)/dahdi.rules
install -m 644 drivers/dahdi/xpp/xpp.rules $(DESTDIR)$(UDEV_DIR)/
uninstall-devices:
rm -f $(DESTDIR)$(UDEV_DIR)/dahdi.rules
install-modules: modules
ifndef DESTDIR
@if modinfo zaptel > /dev/null 2>&1; then \
@@ -190,6 +169,9 @@ update:
echo "Not under version control"; \
fi
dist:
@./build_tools/make_dist "dahdi-linux" "$(DAHDIVERSION)"
clean:
ifneq (no,$(HAS_KSRC))
$(KMAKE) clean
@@ -219,6 +201,6 @@ README.html: README
dahdi-api.html: drivers/dahdi/dahdi-base.c
build_tools/kernel-doc --kernel $(KSRC) $^ >$@
.PHONY: distclean dist-clean clean all install devices modules stackcheck install-udev update install-modules install-include uninstall-modules firmware-download install-xpp-firm firmware-loaders
.PHONY: distclean dist-clean clean all install devices modules stackcheck install-udev update install-modules install-include uninstall-modules firmware-download install-xpp-firm firmware-loaders dist
FORCE:

49
README
View File

@@ -528,16 +528,26 @@ XPP (Astribank) module parameters
==== dahdi_autoreg
(xpp)
Register spans automatically (1) or not (0). Default: 0.
Setting it simplifies operations with a single Astribank and no other
DAHDI hardware. However if you have such systems, automatic
registration can cause the order of spans to be unpredictable.
The standard startup scripts use 'dahdi_registration on' instead of this.
Deprecated. See dahdi.<<_auto_assign_spans,auto_assign_spans>> above.
Originally had a somewhat similar (but xpp-specific and more limited)
role to auto_assign_spans. For backward compatibility this variable is
still kept, but its value is unused. Astribanks will auto-register
with dahdi if auto_assign_spans is not set.
==== tools_rootdir
(xpp)
Defaults to /. Passed (as the variable DAHDI_TOOLS_ROOTDIR) to generated
events (which can be used in udev hooks). Also serves as the base of
the variable DAHDI_INIT_DIR (by default: $DAHDI_TOOLS_DIR/usr/share/dahdi).
==== initdir
(xpp)
This is the directory containing the initialization scripts.
Deprecated. Setting both initdir and tools_rootdir will generate an error.
A directory under tools_rootdir containing the initialization scripts.
The default is /usr/share/dahdi .
Setting this value could be useful if that location is inconvenient for you.
@@ -646,8 +656,10 @@ or dynamically through the udev system.
* /dev/dahdi/ctl (196:0) - a general device file for various information and
control operations on the DAHDI channels.
* /dev/dahdi/channels/N/M - A device file for channel M in span N
(M is chanpos - numbering relative to the current span).
* /dev/dahdi/chan/N/M - A device file for channel M in span N
- Both N and M are zero padded 3 digit numbers
- Both N and M start at 001
- M is chanpos - numbering relative to the current span.
* /dev/dahdi/NNN (196:NNN) - for NNN in the range 1-249. A device file for
DAHDI channel NNN. It can be used to read data from the channel
and write data to the channel. It is not generated by default but may
@@ -885,11 +897,12 @@ to other nodes.
Class DAHDI
^^^^^^^^^^^
under /sys/class/dadhi there exists a node for each DAHDI device file
under /dev/dahdi. The name is 'dahdi!foo' for the file '/dev/dahdi/foo'
(udev translates exclamation marks to slashes). Those nodes are not, for
the most part, proper SysFS nodes, and don't include any interesting
properties.
Under /sys/class/dadhi there exists a node for the non-channel DAHDI
device file under /dev/dahdi. The name is 'dahdi!foo' for the file
'/dev/dahdi/foo' (udev translates exclamation marks to slashes). Those
nodes are not, for the most part, proper SysFS nodes, and don't include
any interesting properties. The files in this class `ctl`, `timer`,
`channel`, `pseudo` and (if exists) `transcode`.
Devices Bus
@@ -914,6 +927,10 @@ A unique hardware-level identifier (e.g. serial number), if available.
===== /sys/bus/dahdi_devices/devices/DEVICE/manufacturer
The name of the manufacturer. Freeform-string.
===== /sys/bus/dahdi_devices/devices/DEVICE/registration_time
The time at which the device registered with the DAHDI core. Example
value: "0005634136.941901429".
===== /sys/bus/dahdi_devices/devices/DEVICE/spantype
A line for each available span: <num>:<type>. This has to be provided
here as in the case of manual assignment, userspace may need to know
@@ -978,6 +995,12 @@ A very short type string.
===== /sys/bus/dahdi_spans/devices/span-N/syncsrc
Current sync source.
==== sys/bus/dahdi_spans/drivers/generic_lowlevel/master_span
All spans in the bus are handled by a single driver. The driver has one
non-standard attribute: master_span. printing it shows the current DAHDI
master span writing a number to it forces setting this span as the master
span.
Channels Bus
^^^^^^^^^^^^

123
build_tools/dkms-helper Executable file
View File

@@ -0,0 +1,123 @@
#!/bin/sh
set -e
DKMS=$(which dkms)
usage() {
echo "$(basename $0): Helper functions for DKMS (Dynamic Kernel Module Support)"
echo "Usage: $0 [add|remove|generate_conf]"
echo "Options:"
echo " remove -a : Remove all versions of DAHDI for all kernels."
echo ""
echo "Examples:"
echo ""
echo " build_tools/dkms-helper add"
echo " Installs the current version of DAHDI into the DKMS system."
echo ""
echo " build_tools/dkms-helper remove"
echo " Removes the current version of DAHDI from all kernels."
echo ""
echo " build_tools/dkms-helper generate_conf > dkms.conf"
echo " Create a dkms.conf based on the currently compiled kernel"
echo " modules. This is also done as part of add and is not"
echo " normally needed as a separate step."
echo ""
echo "NOTE: Because firmware files could be different between different"
echo "versions of DAHDI, and the firmware files are installed into the common"
echo "/lib/firmware directory, you should remove a given version of DAHDI from all"
echo "kernels before installing a new version of DAHDI to avoid potential"
echo "conflicts."
echo ""
}
generate_configuration() {
echo 'PACKAGE_NAME="dahdi-linux"'
echo "PACKAGE_VERSION=\"$(build_tools/make_version .)\""
echo 'MAKE="make KSRC=/lib/modules/${kernelver}/build"'
echo 'CLEAN="make clean"'
echo 'AUTOINSTALL="yes"'
let "module_number=0" || true
for file in $(find ./ -type f -name "*.ko"); do
MODULE_LOCATION=$(dirname $file | cut -d\/ -f 2-)
echo "BUILT_MODULE_NAME[$module_number]=\"$(basename $file .ko)\""
echo "BUILT_MODULE_LOCATION[$module_number]=\"$MODULE_LOCATION\""
echo "DEST_MODULE_LOCATION[$module_number]=\"/kernel/dahdi/$(echo $MODULE_LOCATION | cut -d\/ -f 3-)\""
let "module_number=${module_number}+1" || true
done
if [ $module_number -eq 0 ]; then
echo "WARNING: You should build the modules before generating a config." >&2
exit 1
fi
}
add() {
GIT=$(which git)
VERSION="$(build_tools/make_version .)"
if [ $(id -u) != "0" ]; then
echo "You must run $0 as root."
exit 1
fi
echo "Building for version ${VERSION}"
make > /dev/null
echo "Copying to /usr/src/dahdi-linux-${VERSION}"
if [ ! -d /usr/src/dahdi-linux-${VERSION} ]; then
if [ -d .git ]; then
${GIT} checkout-index -a --prefix=/usr/src/dahdi-linux-${VERSION}/
else
cp -f -r * /usr/src/dahdi-linux-${VERSION}/
fi
fi
make -C /usr/src/dahdi-linux-${VERSION} install-firmware firmware-loaders
build_tools/dkms-helper generate_conf > /usr/src/dahdi-linux-${VERSION}/dkms.conf
echo $VERSION > /usr/src/dahdi-linux-${VERSION}/.version
${DKMS} add -m dahdi-linux -v ${VERSION}
${DKMS} build -m dahdi-linux -v ${VERSION}
${DKMS} install --force -m dahdi-linux -v ${VERSION}
}
remove() {
if [ $(id -u) != "0" ]; then
echo "You must run $0 as root."
exit 1
fi
REMOVE_ALL=false
shift
while getopts "a" opt; do
case $opt in
a) REMOVE_ALL=true ;;
*) echo "Unknown option to remove" ; exit 1;;
esac
done
if [ $REMOVE_ALL == true ]; then
# Remove all installed dahdi versions for all kernels.
for version in $(${DKMS} status -m dahdi-linux | cut -d, -f 2 | sed -e "s/^\s\+//"); do
echo "Removing version ${version}"
${DKMS} remove -m dahdi-linux -v ${version} --all
rm -f -r /usr/src/dahdi-linux-${version}
done
else
# Just remove the version for the current tree.
GIT=$(which git)
VERSION="$(build_tools/make_version .)"
${DKMS} remove -m dahdi-linux -v ${VERSION} --all
if [ -e /usr/src/dahdi-linux-${VERSION}/dkms.conf ]; then
rm -f -r /usr/src/dahdi-linux-${VERSION}
else
echo "/usr/src/dahdi-linux-${VERSION} not a dkms dir?"
exit 1
fi
fi
}
# Run the command...
shift $(($OPTIND-1))
COMMAND=$1
case $COMMAND in
add) add $*; exit $? ;;
remove) remove $* ; exit $? ;;
generate_conf) generate_configuration; exit $? ;;
*) echo "unknown command $0" ; usage; exit 1;;
esac
exit 0

View File

@@ -1,40 +0,0 @@
#!/bin/sh
ver=`udevinfo -V | cut -f3 -d" "`
if [ -z "${ver}" ]; then
# Not found - try udevadm
ver=`udevadm info -V | cut -f3 -d" "`
if [ -z "${ver}" ]; then
# nobody has that old version, anyway.
ver=54
fi
fi
# udev versions prior to 055 use a single '=' for matching key values
# udev versions 055 and later support '==' for that purpose, and versions
# beyond 092 will probably make it mandatory
#
# very old versions of udev required naming rules and permissions rules to be
# in separate files, but it's not clear at what version number that changed
if [ ${ver} -gt 54 ]; then
match="=="
else
match="="
fi
cat <<EOF
# udev rules to generate the /dev/dahdi device files (if not yet provided
# by your distribution):
KERNEL${match}"dahdictl", NAME="dahdi/ctl"
KERNEL${match}"dahditranscode", NAME="dahdi/transcode"
KERNEL${match}"dahditimer", NAME="dahdi/timer"
KERNEL${match}"dahdichannel", NAME="dahdi/channel"
KERNEL${match}"dahdipseudo", NAME="dahdi/pseudo"
KERNEL${match}"dahdi[0-9]*", NAME="dahdi/%n"
# DAHDI devices with ownership/permissions for running as non-root
SUBSYSTEM${match}"dahdi", OWNER="asterisk", GROUP="asterisk", MODE="0660"
EOF

21
build_tools/install_firmware Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/sh
# This is a helper script intended to be called from
# drivers/dahdi/firmware/Makefile to install the different firmware version.
FIRMWARE_PATTERN=$1
FIRMWARE_VERSION=$2
DESTDIR=$3
target="$DESTDIR/lib/firmware"
if ! test -f $target/.${FIRMWARE_PATTERN}-${FIRMWARE_VERSION}; then
echo "Installing ${FIRMWARE_PATTERN}.bin to $target"
tar --no-same-owner -xf ${FIRMWARE_PATTERN}-${FIRMWARE_VERSION}.tar.gz || exit 1
install -m 644 ${FIRMWARE_PATTERN}.bin $target || exit 1
rm -rf $target/.${FIRMWARE_PATTERN}-*
touch $target/.${FIRMWARE_PATTERN}-${FIRMWARE_VERSION}
# Remove the .bin file so that if the version is reverted, it will not
# be installed with a non-matching ${FIRMARE_VERSION} file.
rm ${FIRMWARE_PATTERN}.bin
else
echo "Firmware ${FIRMWARE_PATTERN}.bin is already installed with required version ${FIRMWARE_VERSION}"
fi

View File

@@ -61,7 +61,7 @@ export ASTRIBANK_HEXLOAD
# make sure Astribank initialization scripts are from our tree.
xpp_ARGS="$xpp_ARGS initdir=$FIRMWARE_DIR"
#dahdi_ARGS="$dahdi_ARGS initdir=$FIRMWARE_DIR"
dahdi_ARGS="$dahdi_ARGS tools_rootdir=$DESTDIR"
if [ "$DYNAMIC_LOC" = 'yes' ]; then
MODULES_LOAD="$MODULES_LOAD dahdi_dynamic dahdi_dynamic_loc"

26
build_tools/make_dist Executable file
View File

@@ -0,0 +1,26 @@
#! /bin/sh
if [ "$#" -ne 2 ]; then
echo >&2 "Usage: $0 <package> <version>"
exit 1
fi
package="$1"
version="$2"
tarball_prefix="$package-$version"
echo "I: Making dist tarball for $tarball_prefix"
tarball_name="$tarball_prefix.tar.gz"
tmp_work_dir=".tmp"
tmp_version_dir="$tmp_work_dir/$tarball_prefix"
if [ "$DESTDIR" != '' ]; then
destdir="$DESTDIR/"
fi
output="$destdir$tarball_name"
mkdir -p "$tmp_version_dir"
git archive --format tar HEAD | tar xf - -C "$tmp_version_dir"
echo "$version" > "$tmp_version_dir/.version"
tar czf "$output" -C "$tmp_work_dir" "$tarball_prefix"
rm -rf "$tmp_work_dir"
echo "I: tarball is ready: '$output'"

View File

@@ -1,7 +1,7 @@
#!/bin/sh
if [ -f ${1}/.version ]; then
cat ${1}.version
cat ${1}/.version
elif [ -f ${1}/.svnrevision ]; then
echo SVN-`cat ${1}/.svnbranch`-r`cat ${1}/.svnrevision`
elif [ -d ${1}/.svn ]; then

View File

@@ -7,18 +7,35 @@ obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_DYNAMIC_ETHMF) += dahdi_dynamic_ethmf.o
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_TRANSCODE) += dahdi_transcode.o
ifdef CONFIG_PCI
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_OCT612X) += oct612x/
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCT4XXP) += wct4xxp/
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCTC4XXP) += wctc4xxp/
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCTDM24XXP) += wctdm24xxp/
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCTE12XP) += wcte12xp/
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCTE13XP) += wcte13xp.o
wcte13xp-objs := wcte13xp-base.o oct612x/lib.a
CFLAGS_wcte13xp-base.o += -I$(src)/oct612x/include -I$(src)/oct612x/octdeviceapi -I$(src)/oct612x/octdeviceapi/oct6100api
wcte13xp-objs := wcte13xp-base.o wcxb_spi.o wcxb.o wcxb_flash.o
CFLAGS_wcte13xp-base.o += -I$(src)/oct612x -I$(src)/oct612x/include -I$(src)/oct612x/octdeviceapi -I$(src)/oct612x/octdeviceapi/oct6100api
ifeq ($(HOTPLUG_FIRMWARE),yes)
CFLAGS_wcte13xp-base.o += -DHOTPLUG_FIRMWARE
endif
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCTE43X) += wcte43x.o
wcte43x-objs := wcte43x-base.o wcxb_spi.o wcxb.o wcxb_flash.o
CFLAGS_wcte43x-base.o += -I$(src)/oct612x -I$(src)/oct612x/include -I$(src)/oct612x/octdeviceapi -I$(src)/oct612x/octdeviceapi/oct6100api
ifeq ($(HOTPLUG_FIRMWARE),yes)
CFLAGS_wcte43x-base.o += -DHOTPLUG_FIRMWARE
endif
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCAXX) += wcaxx.o
wcaxx-objs := wcaxx-base.o wcxb_spi.o wcxb.o wcxb_flash.o
CFLAGS_wcaxx-base.o += -I$(src)/oct612x/ -I$(src)/oct612x/include -I$(src)/oct612x/octdeviceapi -I$(src)/oct612x/octdeviceapi/oct6100api
ifeq ($(HOTPLUG_FIRMWARE),yes)
CFLAGS_wcaxx-base.o += -DHOTPLUG_FIRMWARE
endif
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCTDM) += wctdm.o
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_VOICEBUS) += voicebus/
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCB4XXP) += wcb4xxp/

View File

@@ -50,6 +50,8 @@
#include <linux/list.h>
#include <linux/delay.h>
#include <linux/mutex.h>
#include <linux/ktime.h>
#include <linux/slab.h>
#if defined(HAVE_UNLOCKED_IOCTL) && defined(CONFIG_BKL)
#include <linux/smp_lock.h>
@@ -173,7 +175,7 @@ static sumtype *conf_sums_next;
static sumtype *conf_sums;
static sumtype *conf_sums_prev;
static struct dahdi_span *master;
static struct dahdi_span *master_span;
struct file_operations *dahdi_transcode_fops = NULL;
@@ -611,7 +613,7 @@ void dahdi_unregister_echocan_factory(const struct dahdi_echocan_factory *ec)
/* Is this span our syncronization master? */
int dahdi_is_sync_master(const struct dahdi_span *span)
{
return span == master;
return span == master_span;
}
static inline void rotate_sums(void)
@@ -732,6 +734,8 @@ enum spantypes dahdi_str2spantype(const char *name)
return SPANTYPE_DIGITAL_BRI_TE;
else if (strcasecmp("BRI_SOFT", name) == 0)
return SPANTYPE_DIGITAL_BRI_SOFT;
else if (strcasecmp("DYNAMIC", name) == 0)
return SPANTYPE_DIGITAL_DYNAMIC;
else
return SPANTYPE_INVALID;
}
@@ -749,6 +753,7 @@ const char *dahdi_spantype2str(enum spantypes st)
case SPANTYPE_DIGITAL_BRI_NT: return "BRI_NT";
case SPANTYPE_DIGITAL_BRI_TE: return "BRI_TE";
case SPANTYPE_DIGITAL_BRI_SOFT: return "BRI_SOFT";
case SPANTYPE_DIGITAL_DYNAMIC: return "DYNAMIC";
default:
case SPANTYPE_INVALID: return "INVALID";
};
@@ -787,6 +792,7 @@ ssize_t lineconfig_str(int lineconfig, char buf[], size_t size)
int crc4_bit = 0;
int len = 0;
int bit;
bool written = false;
for (bit = 4; bit <= 12; bit++) {
int mask = (1 << bit);
@@ -798,8 +804,10 @@ ssize_t lineconfig_str(int lineconfig, char buf[], size_t size)
case DAHDI_CONFIG_AMI:
case DAHDI_CONFIG_HDB3:
framing_bit = bit;
len += snprintf(buf + len, size, "%s/",
len += snprintf(buf + len, size, "%s%s",
(written) ? "/" : "",
dahdi_lineconfig_bit_name(bit));
written = true;
}
}
if (!coding_bit) {
@@ -808,14 +816,18 @@ ssize_t lineconfig_str(int lineconfig, char buf[], size_t size)
case DAHDI_CONFIG_D4:
case DAHDI_CONFIG_CCS:
coding_bit = bit;
len += snprintf(buf + len, size, "%s",
len += snprintf(buf + len, size, "%s%s",
(written) ? "/" : "",
dahdi_lineconfig_bit_name(bit));
written = true;
}
}
if (!crc4_bit && mask == DAHDI_CONFIG_CRC4) {
crc4_bit = bit;
len += snprintf(buf + len, size, "/%s",
len += snprintf(buf + len, size, "%s%s",
(written) ? "/" : "",
dahdi_lineconfig_bit_name(bit));
written = true;
}
}
return len;
@@ -979,10 +991,13 @@ static int dahdi_seq_show(struct seq_file *sfile, void *data)
seq_fill_alarm_string(sfile, chan->chan_alarms);
if (chan->ec_factory)
mutex_lock(&chan->mutex);
if (chan->ec_factory) {
seq_printf(sfile, "(EC: %s - %s) ",
chan->ec_factory->get_name(chan),
chan->ec_state ? "ACTIVE" : "INACTIVE");
}
mutex_unlock(&chan->mutex);
seq_printf(sfile, "\n");
}
@@ -1477,14 +1492,13 @@ static const struct dahdi_echocan_factory hwec_factory = {
static int dahdi_enable_hw_preechocan(struct dahdi_chan *chan)
{
int res;
unsigned long flags;
spin_lock_irqsave(&chan->lock, flags);
mutex_lock(&chan->mutex);
if (chan->ec_factory != &hwec_factory)
res = -ENODEV;
else
res = 0;
spin_unlock_irqrestore(&chan->lock, flags);
mutex_unlock(&chan->mutex);
if (-ENODEV == res)
return 0;
@@ -1797,6 +1811,17 @@ static int start_tone(struct dahdi_chan *chan, int tone)
return res;
}
/**
* stop_tone - Stops any tones on a channel.
*
* Must be called with chan->lock held.
*
*/
static inline int stop_tone(struct dahdi_chan *chan)
{
return start_tone(chan, -1);
}
static int set_tone_zone(struct dahdi_chan *chan, int zone)
{
int res = 0;
@@ -1824,6 +1849,9 @@ static int set_tone_zone(struct dahdi_chan *chan, int zone)
return -ENODATA;
spin_lock_irqsave(&chan->lock, flags);
stop_tone(chan);
if (chan->curzone) {
struct dahdi_zone *zone = chan->curzone;
chan->curzone = NULL;
@@ -1872,6 +1900,7 @@ static void __dahdi_init_chan(struct dahdi_chan *chan)
might_sleep();
spin_lock_init(&chan->lock);
mutex_init(&chan->mutex);
init_waitqueue_head(&chan->waitq);
if (!chan->master)
chan->master = chan;
@@ -1964,7 +1993,6 @@ static int dahdi_net_open(struct net_device *dev)
return -EINVAL;
}
ms->txbufpolicy = DAHDI_POLICY_IMMEDIATE;
ms->rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
res = dahdi_reallocbufs(ms, DAHDI_DEFAULT_MTU_MRU, DAHDI_DEFAULT_NUM_BUFS);
if (res)
@@ -2291,10 +2319,10 @@ static void dahdi_chan_unreg(struct dahdi_chan *chan)
*/
}
spin_lock_irqsave(&chan->lock, flags);
mutex_lock(&chan->mutex);
release_echocan(chan->ec_factory);
chan->ec_factory = NULL;
spin_unlock_irqrestore(&chan->lock, flags);
mutex_unlock(&chan->mutex);
#ifdef CONFIG_DAHDI_NET
if (dahdi_have_netdev(chan)) {
@@ -3043,57 +3071,64 @@ static const struct file_operations dahdi_chan_fops;
static int dahdi_specchan_open(struct file *file)
{
int res = 0;
int res = -ENXIO;
struct dahdi_chan *const chan = chan_from_file(file);
if (chan && chan->sig) {
/* Make sure we're not already open, a net device, or a slave device */
if (dahdi_have_netdev(chan))
res = -EBUSY;
else if (chan->master != chan)
res = -EBUSY;
else if ((chan->sig & __DAHDI_SIG_DACS) == __DAHDI_SIG_DACS)
res = -EBUSY;
else if (!test_and_set_bit(DAHDI_FLAGBIT_OPEN, &chan->flags)) {
unsigned long flags;
res = initialize_channel(chan);
if (res) {
/* Reallocbufs must have failed */
clear_bit(DAHDI_FLAGBIT_OPEN, &chan->flags);
return res;
}
spin_lock_irqsave(&chan->lock, flags);
if (is_pseudo_chan(chan))
chan->flags |= DAHDI_FLAG_AUDIO;
if (chan->span) {
const struct dahdi_span_ops *const ops =
chan->span->ops;
if (!try_module_get(ops->owner)) {
res = -ENXIO;
} else if (ops->open) {
res = ops->open(chan);
if (res)
module_put(ops->owner);
}
}
if (!res) {
chan->file = file;
file->private_data = chan;
/* Since we know we're a channel now, we can
* update the f_op pointer and bypass a few of
* the checks on the minor number. */
file->f_op = &dahdi_chan_fops;
spin_unlock_irqrestore(&chan->lock, flags);
} else {
spin_unlock_irqrestore(&chan->lock, flags);
close_channel(chan);
clear_bit(DAHDI_FLAGBIT_OPEN, &chan->flags);
}
} else {
res = -EBUSY;
if (!chan || !chan->sig)
return -ENXIO;
/* Make sure we're not already open, a net device, or a slave
* device */
if (dahdi_have_netdev(chan))
res = -EBUSY;
else if (chan->master != chan)
res = -EBUSY;
else if ((chan->sig & __DAHDI_SIG_DACS) == __DAHDI_SIG_DACS)
res = -EBUSY;
else if (!test_and_set_bit(DAHDI_FLAGBIT_OPEN, &chan->flags)) {
unsigned long flags;
const struct dahdi_span_ops *const ops =
(!is_pseudo_chan(chan)) ? chan->span->ops : NULL;
if (ops && !try_module_get(ops->owner)) {
clear_bit(DAHDI_FLAGBIT_OPEN, &chan->flags);
return -ENXIO;
}
} else
res = -ENXIO;
res = initialize_channel(chan);
if (res) {
/* Reallocbufs must have failed */
clear_bit(DAHDI_FLAGBIT_OPEN, &chan->flags);
return res;
}
spin_lock_irqsave(&chan->lock, flags);
if (is_pseudo_chan(chan))
chan->flags |= DAHDI_FLAG_AUDIO;
chan->file = file;
file->private_data = chan;
/* Since we know we're a channel now, we can
* update the f_op pointer and bypass a few of
* the checks on the minor number. */
file->f_op = &dahdi_chan_fops;
spin_unlock_irqrestore(&chan->lock, flags);
if (ops && ops->open) {
res = ops->open(chan);
if (res) {
spin_lock_irqsave(&chan->lock, flags);
chan->file = NULL;
file->private_data = NULL;
spin_unlock_irqrestore(&chan->lock, flags);
module_put(ops->owner);
close_channel(chan);
clear_bit(DAHDI_FLAGBIT_OPEN,
&chan->flags);
}
}
} else {
res = -EBUSY;
}
return res;
}
@@ -3834,6 +3869,31 @@ void dahdi_alarm_channel(struct dahdi_chan *chan, int alarms)
spin_unlock_irqrestore(&chan->lock, flags);
}
struct dahdi_span *get_master_span(void)
{
return master_span;
}
void set_master_span(int spanno)
{
struct dahdi_span *s;
unsigned long flags;
struct dahdi_span *old_master;
spin_lock_irqsave(&chan_lock, flags);
old_master = master_span;
list_for_each_entry(s, &span_list, spans_node) {
if (spanno == s->spanno) {
master_span = s;
break;
}
}
spin_unlock_irqrestore(&chan_lock, flags);
if ((debug & DEBUG_MAIN) && (old_master != master_span))
module_printk(KERN_NOTICE, "Master span is set to %d (%s)\n",
master_span->spanno, master_span->name);
}
static void __dahdi_find_master_span(void)
{
struct dahdi_span *s;
@@ -3841,7 +3901,7 @@ static void __dahdi_find_master_span(void)
struct dahdi_span *old_master;
spin_lock_irqsave(&chan_lock, flags);
old_master = master;
old_master = master_span;
list_for_each_entry(s, &span_list, spans_node) {
if (s->alarms && old_master)
continue;
@@ -3851,15 +3911,15 @@ static void __dahdi_find_master_span(void)
continue;
if (!can_provide_timing(s))
continue;
if (master == s)
if (master_span == s)
continue;
master = s;
master_span = s;
break;
}
spin_unlock_irqrestore(&chan_lock, flags);
if ((debug & DEBUG_MAIN) && (old_master != master))
if ((debug & DEBUG_MAIN) && (old_master != master_span))
module_printk(KERN_NOTICE, "Master changed to %s\n", s->name);
}
@@ -3900,7 +3960,7 @@ void dahdi_alarm_notify(struct dahdi_span *span)
dahdi_alarm_channel(span->chans[x], span->alarms);
/* If we're going into or out of alarm we should try to find a
* new master that may be a better fit. */
* new master_span that may be a better fit. */
dahdi_find_master_span();
/* Report more detailed alarms */
@@ -5130,7 +5190,7 @@ static int dahdi_ioctl_startup(struct file *file, unsigned long data)
}
/* Now that this span is running, it might be selected as the
* master span */
* master_span */
__dahdi_find_master_span();
}
put_span(s);
@@ -5190,7 +5250,6 @@ static bool dahdi_is_hwec_available(const struct dahdi_chan *chan)
static int dahdi_ioctl_attach_echocan(unsigned long data)
{
unsigned long flags;
struct dahdi_chan *chan;
struct dahdi_attach_echocan ae;
const struct dahdi_echocan_factory *new = NULL, *old;
@@ -5232,10 +5291,10 @@ static int dahdi_ioctl_attach_echocan(unsigned long data)
}
}
spin_lock_irqsave(&chan->lock, flags);
mutex_lock(&chan->mutex);
old = chan->ec_factory;
chan->ec_factory = new;
spin_unlock_irqrestore(&chan->lock, flags);
mutex_unlock(&chan->mutex);
if (old)
release_echocan(old);
@@ -6295,6 +6354,7 @@ ioctl_echocancel(struct dahdi_chan *chan, struct dahdi_echocanparams *ecp,
if (ecp->tap_length == 0) {
/* disable mode, don't need to inspect params */
mutex_lock(&chan->mutex);
spin_lock_irqsave(&chan->lock, flags);
ec_state = chan->ec_state;
chan->ec_state = NULL;
@@ -6305,7 +6365,7 @@ ioctl_echocancel(struct dahdi_chan *chan, struct dahdi_echocanparams *ecp,
ec_state->ops->echocan_free(chan, ec_state);
release_echocan(ec_current);
}
mutex_unlock(&chan->mutex);
return 0;
}
@@ -6322,6 +6382,7 @@ ioctl_echocancel(struct dahdi_chan *chan, struct dahdi_echocanparams *ecp,
goto exit_with_free;
}
mutex_lock(&chan->mutex);
/* free any echocan that may be on the channel already */
spin_lock_irqsave(&chan->lock, flags);
ec_state = chan->ec_state;
@@ -6392,6 +6453,7 @@ ioctl_echocancel(struct dahdi_chan *chan, struct dahdi_echocanparams *ecp,
}
exit_with_free:
mutex_unlock(&chan->mutex);
kfree(params);
return ret;
@@ -7195,7 +7257,7 @@ EXPORT_SYMBOL(dahdi_init_span);
* @spanno: The span number we would like assigned. If 0, the first
* available spanno/basechan will be used.
* @basechan: The base channel number we would like. Ignored if spanno is 0.
* @prefmaster: will the new span be preferred as a master?
* @prefmaster: will the new span be preferred as a master_span?
*
* Assigns a span for usage with DAHDI. All the channel numbers in it will
* have their numbering started at basechan.
@@ -7214,6 +7276,7 @@ static int _dahdi_assign_span(struct dahdi_span *span, unsigned int spanno,
{
int res = 0;
unsigned int x;
unsigned long flags;
if (!span || !span->ops || !span->ops->owner)
return -EFAULT;
@@ -7225,6 +7288,16 @@ static int _dahdi_assign_span(struct dahdi_span *span, unsigned int spanno,
return -EINVAL;
}
/* DAHDI_ALARM_NOTOPEN can be set when a span is disabled, i.e. via
* sysfs, so when the span is being reassigned we should make sure it's
* cleared. This eliminates the need for board drivers to re-report
* their alarm states on span reassignment. */
spin_lock_irqsave(&span->lock, flags);
span->alarms &= ~DAHDI_ALARM_NOTOPEN;
dahdi_alarm_notify(span);
spin_unlock_irqrestore(&span->lock, flags);
if (span->ops->enable_hw_preechocan ||
span->ops->disable_hw_preechocan) {
if ((NULL == span->ops->enable_hw_preechocan) ||
@@ -7331,6 +7404,15 @@ int dahdi_assign_device_spans(struct dahdi_device *ddev)
static int auto_assign_spans = 1;
static const char *UNKNOWN = "";
/**
* dahdi_auto_assign_spans - is the parameter auto_assign_spans set?
*/
int dahdi_get_auto_assign_spans(void)
{
return auto_assign_spans;
}
EXPORT_SYMBOL(dahdi_get_auto_assign_spans);
/**
* _dahdi_register_device - Registers a DAHDI device and assign its spans.
* @ddev: the DAHDI device
@@ -7358,6 +7440,7 @@ static int _dahdi_register_device(struct dahdi_device *ddev,
__dahdi_init_span(s);
}
ktime_get_ts(&ddev->registration_time);
ret = dahdi_sysfs_add_device(ddev, parent);
if (ret)
return ret;
@@ -7473,8 +7556,8 @@ static int _dahdi_unassign_span(struct dahdi_span *span)
for (x=0;x<span->channels;x++)
dahdi_chan_unreg(span->chans[x]);
new_master = master; /* FIXME: locking */
if (master == span)
new_master = master_span; /* FIXME: locking */
if (master_span == span)
new_master = NULL;
spin_lock_irqsave(&chan_lock, flags);
@@ -7485,13 +7568,13 @@ static int _dahdi_unassign_span(struct dahdi_span *span)
break;
}
spin_unlock_irqrestore(&chan_lock, flags);
if (master != new_master) {
if (master_span != new_master) {
if (debug & DEBUG_MAIN) {
module_printk(KERN_NOTICE, "%s: Span ('%s') is new master\n", __FUNCTION__,
(new_master)? new_master->name: "no master");
}
}
master = new_master;
master_span = new_master;
return 0;
}

View File

@@ -247,7 +247,7 @@ int chan_sysfs_create(struct dahdi_chan *chan)
/*
* FIXME: the name cannot be longer than KOBJ_NAME_LEN
*/
dev_set_name(dev, "dahdi!channels!%d!%d", span->spanno, chan->chanpos);
dev_set_name(dev, "dahdi!chan!%03d!%03d", span->spanno, chan->chanpos);
dev_set_drvdata(dev, chan);
dev->release = chan_release;
res = device_register(dev);

View File

@@ -32,8 +32,15 @@
#include "dahdi-sysfs.h"
static char *initdir = "/usr/share/dahdi";
module_param(initdir, charp, 0644);
static char *initdir;
module_param(initdir, charp, 0444);
MODULE_PARM_DESC(initdir,
"deprecated, should use <tools_rootdir>/usr/share/dahdi");
static char *tools_rootdir;
module_param(tools_rootdir, charp, 0444);
MODULE_PARM_DESC(tools_rootdir,
"root directory of all tools paths (default /)");
static int span_match(struct device *dev, struct device_driver *driver)
{
@@ -47,7 +54,9 @@ static inline struct dahdi_span *dev_to_span(struct device *dev)
#define SPAN_VAR_BLOCK \
do { \
DAHDI_ADD_UEVENT_VAR("DAHDI_INIT_DIR=%s", initdir); \
DAHDI_ADD_UEVENT_VAR("DAHDI_TOOLS_ROOTDIR=%s", tools_rootdir); \
DAHDI_ADD_UEVENT_VAR("DAHDI_INIT_DIR=%s/%s", tools_rootdir, \
initdir); \
DAHDI_ADD_UEVENT_VAR("SPAN_NUM=%d", span->spanno); \
DAHDI_ADD_UEVENT_VAR("SPAN_NAME=%s", span->name); \
} while (0)
@@ -222,16 +231,51 @@ static struct device_attribute span_dev_attrs[] = {
__ATTR_NULL,
};
static ssize_t master_span_show(struct device_driver *driver, char *buf)
{
struct dahdi_span *s = get_master_span();
return snprintf(buf, PAGE_SIZE, "%d\n", (s) ? s->spanno : 0);
}
static ssize_t master_span_store(struct device_driver *driver, const char *buf,
size_t count)
{
int spanno;
if (sscanf(buf, "%d", &spanno) != 1) {
module_printk(KERN_ERR, "non-numeric input '%s'\n", buf);
return -EINVAL;
}
set_master_span(spanno);
return count;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
static struct driver_attribute dahdi_attrs[] = {
__ATTR(master_span, S_IRUGO | S_IWUSR, master_span_show,
master_span_store),
__ATTR_NULL,
};
#else
static DRIVER_ATTR_RW(master_span);
static struct attribute *dahdi_attrs[] = {
&driver_attr_master_span.attr,
NULL,
};
ATTRIBUTE_GROUPS(dahdi);
#endif
static struct bus_type spans_bus_type = {
.name = "dahdi_spans",
.match = span_match,
.uevent = span_uevent,
.dev_attrs = span_dev_attrs,
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
.drv_attrs = dahdi_attrs,
#else
.drv_groups = dahdi_groups,
#endif
};
static int span_probe(struct device *dev)
@@ -296,6 +340,7 @@ void span_sysfs_remove(struct dahdi_span *span)
get_device(span_device);
span_uevent_send(span, KOBJ_OFFLINE);
sysfs_remove_link(&span_device->kobj, "ddev");
device_unregister(span->span_device);
dev_set_drvdata(span_device, NULL);
span_device->parent = NULL;
@@ -336,6 +381,15 @@ int span_sysfs_create(struct dahdi_span *span)
span->span_device = NULL;
goto cleanup;
}
res = sysfs_create_link(&span_device->kobj, &span_device->parent->kobj,
"ddev");
if (res) {
span_err(span, "%s: sysfs_create_link failed: %d\n", __func__,
res);
kfree(span->span_device);
span->span_device = NULL;
goto cleanup;
}
for (x = 0; x < span->channels; x++) {
res = chan_sysfs_create(span->chans[x]);
@@ -362,6 +416,71 @@ static inline struct dahdi_device *to_ddev(struct device *dev)
return container_of(dev, struct dahdi_device, dev);
}
#define DEVICE_VAR_BLOCK \
do { \
DAHDI_ADD_UEVENT_VAR("DAHDI_TOOLS_ROOTDIR=%s", tools_rootdir); \
DAHDI_ADD_UEVENT_VAR("DAHDI_INIT_DIR=%s/%s", tools_rootdir, \
initdir); \
DAHDI_ADD_UEVENT_VAR("DAHDI_DEVICE_HWID=%s", \
ddev->hardware_id); \
DAHDI_ADD_UEVENT_VAR("DAHDI_DEVICE_LOCATION=%s", \
ddev->location); \
} while (0)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
#define DAHDI_ADD_UEVENT_VAR(fmt, val...) \
do { \
int err = add_uevent_var(envp, num_envp, &i, \
buffer, buffer_size, &len, \
fmt, val); \
if (err) \
return err; \
} while (0)
static int device_uevent(struct device *dev, char **envp, int num_envp,
char *buffer, int buffer_size)
{
struct dahdi_device *ddev;
int i = 0;
int len = 0;
if (!dev)
return -ENODEV;
ddev = to_ddev(dev);
if (!ddev)
return -ENODEV;
dahdi_dbg(GENERAL, "SYFS dev_name=%s\n", dev_name(dev));
DEVICE_VAR_BLOCK;
envp[i] = NULL;
return 0;
}
#else
#define DAHDI_ADD_UEVENT_VAR(fmt, val...) \
do { \
int err = add_uevent_var(kenv, fmt, val); \
if (err) \
return err; \
} while (0)
static int device_uevent(struct device *dev, struct kobj_uevent_env *kenv)
{
struct dahdi_device *ddev;
if (!dev)
return -ENODEV;
ddev = to_ddev(dev);
if (!ddev)
return -ENODEV;
dahdi_dbg(GENERAL, "SYFS dev_name=%s\n", dev_name(dev));
DEVICE_VAR_BLOCK;
return 0;
}
#endif
static ssize_t
dahdi_device_manufacturer_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -402,6 +521,16 @@ dahdi_device_hardware_id_show(struct device *dev,
(ddev->hardware_id) ? ddev->hardware_id : "");
}
static ssize_t
dahdi_device_location_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct dahdi_device *ddev = to_ddev(dev);
return sprintf(buf, "%s\n",
(ddev->location) ? ddev->location : "");
}
static ssize_t
dahdi_device_auto_assign(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
@@ -500,7 +629,8 @@ dahdi_spantype_store(struct device *dev, struct device_attribute *attr,
{
struct dahdi_device *const ddev = to_ddev(dev);
int ret;
struct dahdi_span *span;
struct dahdi_span *span = NULL;
struct dahdi_span *cur;
unsigned int local_span_number;
char spantype_name[80];
enum spantypes spantype;
@@ -516,9 +646,18 @@ dahdi_spantype_store(struct device *dev, struct device_attribute *attr,
return -EINVAL;
}
list_for_each_entry(span, &ddev->spans, device_node) {
if (local_spanno(span) == local_span_number)
list_for_each_entry(cur, &ddev->spans, device_node) {
if (local_spanno(cur) == local_span_number) {
span = cur;
break;
}
}
if (!span || (local_spanno(span) != local_span_number)) {
module_printk(KERN_WARNING,
"%d is not a valid local span number "
"for this device.\n", local_span_number);
return -EINVAL;
}
if (test_bit(DAHDI_FLAGBIT_REGISTERED, &span->flags)) {
@@ -527,12 +666,6 @@ dahdi_spantype_store(struct device *dev, struct device_attribute *attr,
return -EINVAL;
}
if (local_spanno(span) != local_span_number) {
module_printk(KERN_WARNING,
"%d is not a valid local span number "
"for this device.\n", local_span_number);
return -EINVAL;
}
if (!span->ops->set_spantype) {
module_printk(KERN_WARNING, "Span %s does not support "
@@ -544,21 +677,37 @@ dahdi_spantype_store(struct device *dev, struct device_attribute *attr,
return (ret < 0) ? ret : count;
}
static ssize_t
dahdi_registration_time_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct dahdi_device *ddev = to_ddev(dev);
int count = 0;
count += sprintf(buf, "%010ld.%09ld\n",
ddev->registration_time.tv_sec,
ddev->registration_time.tv_nsec);
return count;
}
static struct device_attribute dahdi_device_attrs[] = {
__ATTR(manufacturer, S_IRUGO, dahdi_device_manufacturer_show, NULL),
__ATTR(type, S_IRUGO, dahdi_device_type_show, NULL),
__ATTR(span_count, S_IRUGO, dahdi_device_span_count_show, NULL),
__ATTR(hardware_id, S_IRUGO, dahdi_device_hardware_id_show, NULL),
__ATTR(location, S_IRUGO, dahdi_device_location_show, NULL),
__ATTR(auto_assign, S_IWUSR, NULL, dahdi_device_auto_assign),
__ATTR(assign_span, S_IWUSR, NULL, dahdi_device_assign_span),
__ATTR(unassign_span, S_IWUSR, NULL, dahdi_device_unassign_span),
__ATTR(spantype, S_IWUSR | S_IRUGO, dahdi_spantype_show,
dahdi_spantype_store),
__ATTR(registration_time, S_IRUGO, dahdi_registration_time_show, NULL),
__ATTR_NULL,
};
static struct bus_type dahdi_device_bus = {
.name = "dahdi_devices",
.uevent = device_uevent,
.dev_attrs = dahdi_device_attrs,
};
@@ -639,6 +788,19 @@ int __init dahdi_sysfs_init(const struct file_operations *dahdi_fops)
int res = 0;
dahdi_dbg(DEVICES, "Registering DAHDI device bus\n");
/* Handle dahdi-tools paths (for udev environment) */
if (tools_rootdir && initdir) {
dahdi_err("Cannot use tools-rootdir and initdir parameters simultaneously\n");
return -EINVAL;
}
if (initdir)
pr_notice("dahdi: initdir is depracated -- prefer using \"tools_rootdir\" parameter\n");
else
initdir = "/usr/share/dahdi";
if (!tools_rootdir)
tools_rootdir = "";
res = bus_register(&dahdi_device_bus);
if (res)
return res;

View File

@@ -630,6 +630,10 @@ static int _create_dynamic(struct dahdi_dynamic_span *dds)
d->span.deflaw = DAHDI_LAW_MULAW;
d->span.flags |= DAHDI_FLAG_RBS;
d->span.chans = d->chans;
d->span.spantype = SPANTYPE_DIGITAL_DYNAMIC;
d->span.linecompat = DAHDI_CONFIG_D4 | DAHDI_CONFIG_ESF |
DAHDI_CONFIG_AMI | DAHDI_CONFIG_B8ZS | DAHDI_CONFIG_CCS |
DAHDI_CONFIG_HDB3 | DAHDI_CONFIG_CRC4 | DAHDI_CONFIG_NOTOPEN;
d->span.ops = &dynamic_ops;
for (x = 0; x < d->span.channels; x++) {
sprintf(d->chans[x]->name, "DYN/%s/%s/%d",

View File

@@ -168,8 +168,9 @@ static void dtc_release(struct dahdi_transcoder_channel *chan)
BUG_ON(!chan);
if (chan->parent && chan->parent->release) {
chan->parent->release(chan);
} else {
dahdi_tc_clear_busy(chan);
}
dahdi_tc_clear_busy(chan);
}
static int dahdi_tc_release(struct inode *inode, struct file *file)

View File

@@ -51,6 +51,7 @@
#include <linux/pkt_sched.h>
#include <linux/spinlock.h>
#include <linux/rcupdate.h>
#include <linux/slab.h>
#include <net/syncppp.h>

View File

@@ -3,7 +3,7 @@
#
# Makefile for firmware downloading/installation
#
# Copyright (C) 2007-2010, Digium, Inc.
# Copyright (C) 2007-2013, Digium, Inc.
#
# Joshua Colp <jcolp@digium.com>
#
@@ -31,12 +31,19 @@ VPMADT032_VERSION:=1.25.0
HX8_VERSION:=2.06
VPMOCT032_VERSION:=1.12.0
WCT820_VERSION:=1.76
TE133_VERSION:=6f0017
TE134_VERSION:=6f0017
TE133_VERSION:=780019
TE134_VERSION:=780017
TE435_VERSION:=e0019
A8A_VERSION:=1d0017
A8B_VERSION:=1d0019
A4A_VERSION:=a0017
A4B_VERSION:=b0019
FIRMWARE_URL:=http://downloads.digium.com/pub/telephony/firmware/releases
ALL_FIRMWARE=FIRMWARE-OCT6114-032 FIRMWARE-OCT6114-064 FIRMWARE-OCT6114-128 FIRMWARE-OCT6114-256 FIRMWARE-TC400M FIRMWARE-HX8 FIRMWARE-VPMOCT032 FIRMWARE-TE820 FIRMWARE-TE133 FIRMWARE-TE134
ALL_FIRMWARE=FIRMWARE-OCT6114-032 FIRMWARE-OCT6114-064 FIRMWARE-OCT6114-128 FIRMWARE-OCT6114-256
ALL_FIRMWARE+=FIRMWARE-TC400M FIRMWARE-HX8 FIRMWARE-VPMOCT032 FIRMWARE-TE820 FIRMWARE-TE133 FIRMWARE-TE134
ALL_FIRMWARE+=FIRMWARE-A8A FIRMWARE-A8B FIRMWARE-A4A FIRMWARE-A4B FIRMWARE-TE435
# Firmware files should use the naming convention: dahdi-fw-<base name>-<sub name>-<version> or dahdi-fw-<base name>-<version>
# First example: dahdi-fw-oct6114-064-1.05.01
@@ -55,6 +62,11 @@ FIRMWARE:=$(FIRMWARE:FIRMWARE-VPMOCT032=dahdi-fw-vpmoct032-$(VPMOCT032_VERSION).
FIRMWARE:=$(FIRMWARE:FIRMWARE-TE820=dahdi-fw-te820-$(WCT820_VERSION).tar.gz)
FIRMWARE:=$(FIRMWARE:FIRMWARE-TE133=dahdi-fw-te133-$(TE133_VERSION).tar.gz)
FIRMWARE:=$(FIRMWARE:FIRMWARE-TE134=dahdi-fw-te134-$(TE134_VERSION).tar.gz)
FIRMWARE:=$(FIRMWARE:FIRMWARE-TE435=dahdi-fw-te435-$(TE435_VERSION).tar.gz)
FIRMWARE:=$(FIRMWARE:FIRMWARE-A8A=dahdi-fw-a8b-$(A8B_VERSION).tar.gz)
FIRMWARE:=$(FIRMWARE:FIRMWARE-A8B=dahdi-fw-a8a-$(A8A_VERSION).tar.gz)
FIRMWARE:=$(FIRMWARE:FIRMWARE-A4A=dahdi-fw-a4b-$(A4B_VERSION).tar.gz)
FIRMWARE:=$(FIRMWARE:FIRMWARE-A4B=dahdi-fw-a4a-$(A4A_VERSION).tar.gz)
FWLOADERS:=dahdi-fwload-vpmadt032-$(VPMADT032_VERSION).tar.gz
@@ -70,6 +82,8 @@ OBJECT_FILES:=$(OBJECT_FILES:FIRMWARE-VPMOCT032=dahdi-fw-vpmoct032.o)
# Force usage of wget, for now
DOWNLOAD=wget
WGET=wget
INSTALL_FIRMWARE=../../../build_tools/install_firmware
RUN_INST=$(INSTALL_FIRMWARE) $(1) $(2) $(DESTDIR)
# If "fetch" is used, --continue is not a valid option.
ifeq ($(WGET),wget)
@@ -95,7 +109,6 @@ dahdi-fw-%.tar.gz:
echo "Attempting to download $@"; \
if test ! -f $@; then $(DOWNLOAD) $(WGET_ARGS) $(FIRMWARE_URL)/$@; fi; \
if test ! -f $@; then exit 1; fi; \
(cat $@ | gzip -d | tar --no-same-owner -xf -) \
fi
firmware-loaders: $(FWLOADERS)
@@ -114,117 +127,21 @@ $(DESTDIR)/usr/lib/hotplug/firmware $(DESTDIR)/lib/firmware:
# Install all downloaded firmware images for hotplug usage
hotplug-install: $(DESTDIR)/usr/lib/hotplug/firmware $(DESTDIR)/lib/firmware $(FIRMWARE)
ifeq ($(shell if ( [ -f $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-oct6114-032-$(OCT6114_032_VERSION) ] ) && ( [ -f $(DESTDIR)/lib/firmware/.dahdi-fw-oct6114-032-$(OCT6114_032_VERSION) ] ); then echo "no"; else echo "yes"; fi),yes)
@echo "Installing dahdi-fw-oct6114-032.bin to hotplug firmware directories"
@install -m 644 dahdi-fw-oct6114-032.bin $(DESTDIR)/usr/lib/hotplug/firmware
@rm -rf $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-oct6114-032-*
@touch $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-oct6114-032-$(OCT6114_032_VERSION)
@install -m 644 dahdi-fw-oct6114-032.bin $(DESTDIR)/lib/firmware
@rm -rf $(DESTDIR)/lib/firmware/.dahdi-fw-oct6114-032-*
@touch $(DESTDIR)/lib/firmware/.dahdi-fw-oct6114-032-$(OCT6114_032_VERSION)
else
@echo "Firmware dahdi-fw-oct6114-032.bin is already installed with required version $(OCT6114_032_VERSION)"
endif
ifeq ($(shell if ( [ -f $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-oct6114-064-$(OCT6114_064_VERSION) ] ) && ( [ -f $(DESTDIR)/lib/firmware/.dahdi-fw-oct6114-064-$(OCT6114_064_VERSION) ] ); then echo "no"; else echo "yes"; fi),yes)
@echo "Installing dahdi-fw-oct6114-064.bin to hotplug firmware directories"
@install -m 644 dahdi-fw-oct6114-064.bin $(DESTDIR)/usr/lib/hotplug/firmware
@rm -rf $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-oct6114-064-*
@touch $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-oct6114-064-$(OCT6114_064_VERSION)
@install -m 644 dahdi-fw-oct6114-064.bin $(DESTDIR)/lib/firmware
@rm -rf $(DESTDIR)/lib/firmware/.dahdi-fw-oct6114-064-*
@touch $(DESTDIR)/lib/firmware/.dahdi-fw-oct6114-064-$(OCT6114_064_VERSION)
else
@echo "Firmware dahdi-fw-oct6114-064.bin is already installed with required version $(OCT6114_064_VERSION)"
endif
ifeq ($(shell if ( [ -f $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-oct6114-128-$(OCT6114_128_VERSION) ] ) && ( [ -f $(DESTDIR)/lib/firmware/.dahdi-fw-oct6114-128-$(OCT6114_128_VERSION) ] ); then echo "no"; else echo "yes"; fi),yes)
@echo "Installing dahdi-fw-oct6114-128.bin to hotplug firmware directories"
@install -m 644 dahdi-fw-oct6114-128.bin $(DESTDIR)/usr/lib/hotplug/firmware
@rm -rf $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-oct6114-128-*
@touch $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-oct6114-128-$(OCT6114_128_VERSION)
@install -m 644 dahdi-fw-oct6114-128.bin $(DESTDIR)/lib/firmware
@rm -rf $(DESTDIR)/lib/firmware/.dahdi-fw-oct6114-128-*
@touch $(DESTDIR)/lib/firmware/.dahdi-fw-oct6114-128-$(OCT6114_128_VERSION)
else
@echo "Firmware dahdi-fw-oct6114-128.bin is already installed with required version $(OCT6114_128_VERSION)"
endif
ifeq ($(shell if ( [ -f $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-oct6114-256-$(OCT6114_256_VERSION) ] ) && ( [ -f $(DESTDIR)/lib/firmware/.dahdi-fw-oct6114-256-$(OCT6114_256_VERSION) ] ); then echo "no"; else echo "yes"; fi),yes)
@echo "Installing dahdi-fw-oct6114-256.bin to hotplug firmware directories"
@install -m 644 dahdi-fw-oct6114-256.bin $(DESTDIR)/usr/lib/hotplug/firmware
@rm -rf $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-oct6114-256-*
@touch $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-oct6114-256-$(OCT6114_256_VERSION)
@install -m 644 dahdi-fw-oct6114-256.bin $(DESTDIR)/lib/firmware
@rm -rf $(DESTDIR)/lib/firmware/.dahdi-fw-oct6114-256-*
@touch $(DESTDIR)/lib/firmware/.dahdi-fw-oct6114-256-$(OCT6114_256_VERSION)
else
@echo "Firmware dahdi-fw-oct6114-256.bin is already installed with required version $(OCT6114_256_VERSION)"
endif
ifeq ($(shell if ( [ -f $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-tc400m-$(TC400M_VERSION) ] ) && ( [ -f $(DESTDIR)/lib/firmware/.dahdi-fw-tc400m-$(TC400M_VERSION) ] ); then echo "no"; else echo "yes"; fi),yes)
@echo "Installing dahdi-fw-tc400m.bin to hotplug firmware directories"
@install -m 644 dahdi-fw-tc400m.bin $(DESTDIR)/usr/lib/hotplug/firmware
@rm -rf $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-tc400m-*
@touch $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-tc400m-$(TC400M_VERSION)
@install -m 644 dahdi-fw-tc400m.bin $(DESTDIR)/lib/firmware
@rm -rf $(DESTDIR)/lib/firmware/.dahdi-fw-tc400m-*
@touch $(DESTDIR)/lib/firmware/.dahdi-fw-tc400m-$(TC400M_VERSION)
else
@echo "Firmware dahdi-fw-tc400m.bin is already installed with required version $(TC400M_VERSION)"
endif
ifeq ($(shell if ( [ -f $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-hx8-$(HX8_VERSION) ] ) && ( [ -f $(DESTDIR)/lib/firmware/.dahdi-fw-hx8-$(HX8_VERSION) ] ); then echo "no"; else echo "yes"; fi),yes)
@echo "Installing dahdi-fw-hx8.bin to hotplug firmware directories"
@install -m 644 dahdi-fw-hx8.bin $(DESTDIR)/usr/lib/hotplug/firmware
@rm -rf $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-hx8-*
@touch $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-hx8-$(HX8_VERSION)
@install -m 644 dahdi-fw-hx8.bin $(DESTDIR)/lib/firmware
@rm -rf $(DESTDIR)/lib/firmware/.dahdi-fw-hx8-*
@touch $(DESTDIR)/lib/firmware/.dahdi-fw-hx8-$(HX8_VERSION)
else
@echo "Firmware dahdi-fw-hx8.bin is already installed with required version $(HX8_VERSION)"
endif
ifeq ($(shell if ( [ -f $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-vpmoct032-$(VPMOCT032_VERSION) ] ) && ( [ -f $(DESTDIR)/lib/firmware/.dahdi-fw-vpmoct032-$(VPMOCT032_VERSION) ] ); then echo "no"; else echo "yes"; fi),yes)
@echo "Installing dahdi-fw-vpmoct032.bin to hotplug firmware directories"
@install -m 644 dahdi-fw-vpmoct032.bin $(DESTDIR)/usr/lib/hotplug/firmware
@rm -rf $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-vpmoct032-*
@touch $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-vpmoct032-$(VPMOCT032_VERSION)
@install -m 644 dahdi-fw-vpmoct032.bin $(DESTDIR)/lib/firmware
@rm -rf $(DESTDIR)/lib/firmware/.dahdi-fw-vpmoct032-*
@touch $(DESTDIR)/lib/firmware/.dahdi-fw-vpmoct032-$(VPMOCT032_VERSION)
else
@echo "Firmware dahdi-fw-vpmoct032.bin is already installed with required version $(VPMOCT032_VERSION)"
endif
ifeq ($(shell if ( [ -f $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-te820-$(WCT820_VERSION) ] ) && ( [ -f $(DESTDIR)/lib/firmware/.dahdi-fw-te820-$(WCT820_VERSION) ] ); then echo "no"; else echo "yes"; fi),yes)
@echo "Installing dahdi-fw-te820.bin to hotplug firmware directories"
@install -m 644 dahdi-fw-te820.bin $(DESTDIR)/usr/lib/hotplug/firmware
@rm -rf $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-te820-*
@touch $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-te820-$(WCT820_VERSION)
@install -m 644 dahdi-fw-te820.bin $(DESTDIR)/lib/firmware
@rm -rf $(DESTDIR)/lib/firmware/.dahdi-fw-te820-*
@touch $(DESTDIR)/lib/firmware/.dahdi-fw-te820-$(WCT820_VERSION)
else
@echo "Firmware dahdi-fw-te820.bin is already installed with required version $(WCT820_VERSION)"
endif
ifeq ($(shell if ( [ -f $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-te133-$(TE133_VERSION) ] ) && ( [ -f $(DESTDIR)/lib/firmware/.dahdi-fw-te133-$(TE133_VERSION) ] ); then echo "no"; else echo "yes"; fi),yes)
@echo "Installing dahdi-fw-te133.bin to hotplug firmware directories"
@install -m 644 dahdi-fw-te133.bin $(DESTDIR)/usr/lib/hotplug/firmware
@rm -rf $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-te133-*
@touch $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-te133-$(TE133_VERSION)
@install -m 644 dahdi-fw-te133.bin $(DESTDIR)/lib/firmware
@rm -rf $(DESTDIR)/lib/firmware/.dahdi-fw-te133-*
@touch $(DESTDIR)/lib/firmware/.dahdi-fw-te133-$(TE133_VERSION)
else
@echo "Firmware dahdi-fw-te133.bin is already installed with required version $(TE133_VERSION)"
endif
ifeq ($(shell if ( [ -f $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-te134-$(TE134_VERSION) ] ) && ( [ -f $(DESTDIR)/lib/firmware/.dahdi-fw-te134-$(TE134_VERSION) ] ); then echo "no"; else echo "yes"; fi),yes)
@echo "Installing dahdi-fw-te134.bin to hotplug firmware directories"
@install -m 644 dahdi-fw-te134.bin $(DESTDIR)/usr/lib/hotplug/firmware
@rm -rf $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-te134-*
@touch $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw-te134-$(TE134_VERSION)
@install -m 644 dahdi-fw-te134.bin $(DESTDIR)/lib/firmware
@rm -rf $(DESTDIR)/lib/firmware/.dahdi-fw-te134-*
@touch $(DESTDIR)/lib/firmware/.dahdi-fw-te134-$(TE134_VERSION)
else
@echo "Firmware dahdi-fw-te134.bin is already installed with required version $(TE134_VERSION)"
endif
@$(call RUN_INST,dahdi-fw-oct6114-032,$(OCT6114_032_VERSION))
@$(call RUN_INST,dahdi-fw-oct6114-064,$(OCT6114_064_VERSION))
@$(call RUN_INST,dahdi-fw-oct6114-128,$(OCT6114_128_VERSION))
@$(call RUN_INST,dahdi-fw-oct6114-256,$(OCT6114_256_VERSION))
@$(call RUN_INST,dahdi-fw-tc400m,$(TC400M_VERSION))
@$(call RUN_INST,dahdi-fw-hx8,$(HX8_VERSION))
@$(call RUN_INST,dahdi-fw-vpmoct032,$(VPMOCT032_VERSION))
@$(call RUN_INST,dahdi-fw-te820,$(WCT820_VERSION))
@$(call RUN_INST,dahdi-fw-te133,$(TE133_VERSION))
@$(call RUN_INST,dahdi-fw-te134,$(TE134_VERSION))
@$(call RUN_INST,dahdi-fw-te435,$(TE435_VERSION))
@$(call RUN_INST,dahdi-fw-a8a,$(A8A_VERSION))
@$(call RUN_INST,dahdi-fw-a8b,$(A8B_VERSION))
@$(call RUN_INST,dahdi-fw-a4a,$(A4A_VERSION))
@$(call RUN_INST,dahdi-fw-a4b,$(A4B_VERSION))
# Uninstall any installed dahdi firmware images from hotplug firmware directories
hotplug-uninstall:

View File

@@ -0,0 +1,32 @@
#
# Produces the oct612x library
#
octapi_files = octdeviceapi/oct6100api/oct6100_api/oct6100_adpcm_chan.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_channel.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_chip_open.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_chip_stats.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_conf_bridge.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_debug.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_events.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_interrupts.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_memory.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_miscellaneous.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_mixer.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_phasing_tsst.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_playout_buf.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_remote_debug.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_tlv.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_tone_detection.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_tsi_cnct.o \
octdeviceapi/oct6100api/oct6100_api/oct6100_tsst.o \
apilib/bt/octapi_bt0.o \
apilib/largmath/octapi_largmath.o \
apilib/llman/octapi_llman.o \
oct612x-user.o
# TODO: ccflags was added in 2.6.24 in commit f77bf01425b11947eeb3b5b54. This
# should be changed to a conditional compilation based on the Kernel Version.
# ccflags-y := -I$(src)/.. -Wno-undef -I$(src)/include -I$(src)/octdeviceapi -I$(src)/octdeviceapi/oct6100api
EXTRA_CFLAGS = -I$(src)/.. -Wno-undef -I$(src)/include -I$(src)/octdeviceapi -I$(src)/octdeviceapi/oct6100api
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_OCT612X) := oct612x.o
oct612x-objs := $(octapi_files)

View File

@@ -129,7 +129,7 @@ $Octasic_Revision: 16 $
/***************************** TYPES ***************************************/
/*Change this type if your platform uses 64bits semaphores/locks */
typedef UINT32 tOCT6100_USER_SERIAL_OBJECT;
typedef void* tOCT6100_USER_SERIAL_OBJECT;
typedef struct _OCT6100_GET_TIME_
{

View File

@@ -0,0 +1,209 @@
/*
* Octasic OCT6100 Interface
*
* Copyright (C) 2013 Digium, Inc.
*
* All rights reserved.
*
*/
/*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2 as published by the
* Free Software Foundation. See the LICENSE file included with
* this program for more details.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <dahdi/kernel.h>
#include "oct612x.h"
UINT32 Oct6100UserGetTime(tPOCT6100_GET_TIME f_pTime)
{
/* Why couldn't they just take a timeval like everyone else? */
struct timeval tv;
unsigned long long total_usecs;
unsigned int mask = ~0;
do_gettimeofday(&tv);
total_usecs = (((unsigned long long)(tv.tv_sec)) * 1000000) +
(((unsigned long long)(tv.tv_usec)));
f_pTime->aulWallTimeUs[0] = (total_usecs & mask);
f_pTime->aulWallTimeUs[1] = (total_usecs >> 32);
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserMemSet(PVOID f_pAddress, UINT32 f_ulPattern,
UINT32 f_ulLength)
{
memset(f_pAddress, f_ulPattern, f_ulLength);
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserMemCopy(PVOID f_pDestination, const void *f_pSource,
UINT32 f_ulLength)
{
memcpy(f_pDestination, f_pSource, f_ulLength);
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserCreateSerializeObject(
tPOCT6100_CREATE_SERIALIZE_OBJECT f_pCreate)
{
struct oct612x_context *context = f_pCreate->pProcessContext;
struct mutex *lock = kzalloc(sizeof(*lock), GFP_KERNEL);
if (!lock) {
dev_err(context->dev, "Out of memory in %s.\n", __func__);
return cOCT6100_ERR_BASE;
}
mutex_init(lock);
f_pCreate->ulSerialObjHndl = lock;
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserDestroySerializeObject(
tPOCT6100_DESTROY_SERIALIZE_OBJECT f_pDestroy)
{
struct mutex *lock = f_pDestroy->ulSerialObjHndl;
kfree(lock);
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserSeizeSerializeObject(
tPOCT6100_SEIZE_SERIALIZE_OBJECT f_pSeize)
{
struct mutex *lock = f_pSeize->ulSerialObjHndl;
mutex_lock(lock);
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserReleaseSerializeObject(
tPOCT6100_RELEASE_SERIALIZE_OBJECT f_pRelease)
{
struct mutex *lock = f_pRelease->ulSerialObjHndl;
mutex_unlock(lock);
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserDriverWriteApi(tPOCT6100_WRITE_PARAMS f_pWriteParams)
{
struct oct612x_context *context = f_pWriteParams->pProcessContext;
#ifdef OCTASIC_DEBUG
if (!context || !context->ops || !context->ops->write) {
pr_debug("Invalid call to %s\n", __func__);
return cOCT6100_ERR_BASE;
}
#endif
context->ops->write(context, f_pWriteParams->ulWriteAddress,
f_pWriteParams->usWriteData);
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserDriverWriteSmearApi(tPOCT6100_WRITE_SMEAR_PARAMS f_pSmearParams)
{
struct oct612x_context *context = f_pSmearParams->pProcessContext;
#ifdef OCTASIC_DEBUG
if (!context || !context->ops || !context->ops->write_smear) {
pr_debug("Invalid call to %s\n", __func__);
return cOCT6100_ERR_BASE;
}
#endif
context->ops->write_smear(context, f_pSmearParams->ulWriteAddress,
f_pSmearParams->usWriteData,
f_pSmearParams->ulWriteLength);
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserDriverWriteBurstApi(
tPOCT6100_WRITE_BURST_PARAMS f_pBurstParams)
{
struct oct612x_context *context = f_pBurstParams->pProcessContext;
#ifdef OCTASIC_DEBUG
if (!context || !context->ops || !context->ops->write_burst) {
pr_debug("Invalid call to %s\n", __func__);
return cOCT6100_ERR_BASE;
}
#endif
context->ops->write_burst(context, f_pBurstParams->ulWriteAddress,
f_pBurstParams->pusWriteData,
f_pBurstParams->ulWriteLength);
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserDriverReadApi(tPOCT6100_READ_PARAMS f_pReadParams)
{
struct oct612x_context *context = f_pReadParams->pProcessContext;
#ifdef OCTASIC_DEBUG
if (!context || !context->ops || !context->ops->read) {
pr_debug("Invalid call to %s\n", __func__);
return cOCT6100_ERR_BASE;
}
#endif
context->ops->read(context, f_pReadParams->ulReadAddress,
f_pReadParams->pusReadData);
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserDriverReadBurstApi(tPOCT6100_READ_BURST_PARAMS f_pBurstParams)
{
struct oct612x_context *context = f_pBurstParams->pProcessContext;
#ifdef OCTASIC_DEBUG
if (!context || !context->ops || !context->ops->read_burst) {
pr_debug("Invalid call to %s\n", __func__);
return cOCT6100_ERR_BASE;
}
#endif
context->ops->read_burst(context, f_pBurstParams->ulReadAddress,
f_pBurstParams->pusReadData,
f_pBurstParams->ulReadLength);
return cOCT6100_ERR_OK;
}
EXPORT_SYMBOL(Oct6100ChipOpen);
EXPORT_SYMBOL(Oct6100ChipClose);
EXPORT_SYMBOL(Oct6100ChipCloseDef);
EXPORT_SYMBOL(Oct6100GetInstanceSize);
EXPORT_SYMBOL(Oct6100GetInstanceSizeDef);
EXPORT_SYMBOL(Oct6100ChipOpenDef);
EXPORT_SYMBOL(Oct6100ChannelModify);
EXPORT_SYMBOL(Oct6100ToneDetectionEnableDef);
EXPORT_SYMBOL(Oct6100InterruptServiceRoutine);
EXPORT_SYMBOL(Oct6100InterruptServiceRoutineDef);
EXPORT_SYMBOL(Oct6100ApiGetCapacityPins);
EXPORT_SYMBOL(Oct6100ToneDetectionEnable);
EXPORT_SYMBOL(Oct6100EventGetToneDef);
EXPORT_SYMBOL(Oct6100EventGetTone);
EXPORT_SYMBOL(Oct6100ApiGetCapacityPinsDef);
EXPORT_SYMBOL(Oct6100ChannelOpen);
EXPORT_SYMBOL(Oct6100ChannelOpenDef);
EXPORT_SYMBOL(Oct6100ChannelModifyDef);
static int __init oct612x_module_init(void)
{
/* This registration with dahdi.ko will fail since the span is not
* defined, but it will make sure that this module is a dependency of
* dahdi.ko, so that when it is being unloded, this module will be
* unloaded as well. */
dahdi_register_device(NULL, NULL);
return 0;
}
module_init(oct612x_module_init);
static void __exit oct612x_module_cleanup(void)
{
/* Nothing to do */;
}
module_exit(oct612x_module_cleanup);
MODULE_AUTHOR("Digium Incorporated <support@digium.com>");
MODULE_DESCRIPTION("Octasic OCT6100 Hardware Echocan Library");
MODULE_LICENSE("GPL v2");

View File

@@ -0,0 +1,49 @@
/*
* Octasic OCT6100 Interface
*
* Copyright (C) 2013 Digium, Inc.
*
* All rights reserved.
*
*/
/*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2 as published by the
* Free Software Foundation. See the LICENSE file included with
* this program for more details.
*/
#ifndef __OCT612X_H__
#define __OCT612X_H__
#include <oct6100api/oct6100_api.h>
struct oct612x_context;
/**
* struct oct612x_ops - Callbacks used by oct612x library to talk to part.
*
*/
struct oct612x_ops {
int (*write)(struct oct612x_context *context, u32 address, u16 value);
int (*read)(struct oct612x_context *context, u32 address, u16 *value);
int (*write_smear)(struct oct612x_context *context, u32 address,
u16 value, size_t count);
int (*write_burst)(struct oct612x_context *context, u32 address,
const u16 *value, size_t count);
int (*read_burst)(struct oct612x_context *context, u32 address,
u16 *value, size_t count);
};
struct oct612x_context {
const struct oct612x_ops *ops;
struct device *dev;
};
#endif /* __OCT612X_H__ */

View File

@@ -51,6 +51,8 @@ With driver: 303826 (1.5 %)
#include <linux/interrupt.h>
#include <linux/moduleparam.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <asm/io.h>
#include <asm/delay.h>
@@ -480,8 +482,6 @@ static void rbi_out(struct pciradio *rad, int n, unsigned char *rbicmd)
{
unsigned long flags;
int x;
DECLARE_WAIT_QUEUE_HEAD(mywait);
for(;;)
{
@@ -489,7 +489,8 @@ DECLARE_WAIT_QUEUE_HEAD(mywait);
x = rad->remote_locked || (__pciradio_getcreg(rad,0xc) & 2);
if (!x) rad->remote_locked = 1;
spin_unlock_irqrestore(&rad->lock,flags);
if (x) interruptible_sleep_on_timeout(&mywait,2);
if (x)
msleep_interruptible(20);
else break;
}
spin_lock_irqsave(&rad->lock,flags);
@@ -526,7 +527,6 @@ static void mx828_command(struct pciradio *rad,int channel, unsigned char comman
static void mx828_command_wait(struct pciradio *rad,int channel, unsigned char command, unsigned char *byte1, unsigned char *byte2)
{
DECLARE_WAIT_QUEUE_HEAD(mywait);
unsigned long flags;
@@ -534,7 +534,7 @@ unsigned long flags;
while(rad->encdec.state)
{
spin_unlock_irqrestore(&rad->lock,flags);
interruptible_sleep_on_timeout(&mywait,2);
msleep_interruptible(20);
spin_lock_irqsave(&rad->lock,flags);
}
rad->encdec.lastcmd = jiffies + 1000;
@@ -966,7 +966,6 @@ static int pciradio_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned lo
} stack;
struct pciradio *rad = chan->pvt;
DECLARE_WAIT_QUEUE_HEAD(mywait);
switch (cmd) {
case DAHDI_RADIO_GETPARAM:
@@ -1254,7 +1253,7 @@ static int pciradio_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned lo
__pciradio_setcreg(rad,8,byte2);
spin_unlock_irqrestore(&rad->lock,flags);
if (i || (jiffies < rad->lastremcmd + 10))
interruptible_sleep_on_timeout(&mywait,10);
msleep_interruptible(100);
rad->lastremcmd = jiffies;
rbi_out(rad,chan->chanpos - 1,(unsigned char *)&stack.p.data);
spin_lock_irqsave(&rad->lock,flags);
@@ -1269,7 +1268,8 @@ static int pciradio_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned lo
x = rad->remote_locked || (__pciradio_getcreg(rad,0xc) & 2);
if (!x) rad->remote_locked = 1;
spin_unlock_irqrestore(&rad->lock,flags);
if (x) interruptible_sleep_on_timeout(&mywait,2);
if (x)
msleep_interruptible(20);
else break;
}
spin_lock_irqsave(&rad->lock,flags);
@@ -1286,14 +1286,14 @@ static int pciradio_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned lo
__pciradio_setcreg(rad,8,byte2);
spin_unlock_irqrestore(&rad->lock,flags);
if (byte1 != byte2)
interruptible_sleep_on_timeout(&mywait,3);
msleep_interruptible(30);
while (jiffies < rad->lastremcmd + 10)
interruptible_sleep_on_timeout(&mywait,10);
msleep_interruptible(100);
rad->lastremcmd = jiffies;
for(;;)
{
if (!(__pciradio_getcreg(rad,0xc) & 2)) break;
interruptible_sleep_on_timeout(&mywait,2);
msleep_interruptible(20);
}
spin_lock_irqsave(&rad->lock,flags);
/* enable and address async serializer */
@@ -1315,7 +1315,7 @@ static int pciradio_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned lo
(!strchr((char *)rad->rxbuf,'\r'))))
{
spin_unlock_irqrestore(&rad->lock,flags);
interruptible_sleep_on_timeout(&mywait,2);
msleep_interruptible(20);
spin_lock_irqsave(&rad->lock,flags);
continue;
}
@@ -1335,7 +1335,7 @@ static int pciradio_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned lo
while(rad->txlen && (rad->txindex < rad->txlen))
{
spin_unlock_irqrestore(&rad->lock,flags);
interruptible_sleep_on_timeout(&mywait,2);
msleep_interruptible(20);
spin_lock_irqsave(&rad->lock,flags);
}
/* disable and un-address async serializer */
@@ -1344,7 +1344,7 @@ static int pciradio_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned lo
rad->remote_locked = 0;
spin_unlock_irqrestore(&rad->lock,flags);
if (rad->remmode[chan->chanpos - 1] == DAHDI_RADPAR_REM_SERIAL_ASCII)
interruptible_sleep_on_timeout(&mywait,100);
msleep_interruptible(1000);
if (copy_to_user((__user void *) data, &stack.p, sizeof(stack.p))) return -EFAULT;
return 0;
default:

View File

@@ -31,6 +31,7 @@
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/moduleparam.h>
#include <linux/slab.h>
#include <dahdi/kernel.h>
#define NEED_PCI_IDS
@@ -253,16 +254,6 @@ static int tor2_chanconfig(struct file *file,
return 0;
}
static int tor2_open(struct dahdi_chan *chan)
{
return 0;
}
static int tor2_close(struct dahdi_chan *chan)
{
return 0;
}
static const struct dahdi_span_ops tor2_span_ops = {
.owner = THIS_MODULE,
.spanconfig = tor2_spanconfig,
@@ -271,8 +262,6 @@ static const struct dahdi_span_ops tor2_span_ops = {
.shutdown = tor2_shutdown,
.rbsbits = tor2_rbsbits,
.maint = tor2_maint,
.open = tor2_open,
.close = tor2_close,
.ioctl = tor2_ioctl,
};

View File

@@ -38,6 +38,7 @@
#else
#include <asm/semaphore.h>
#endif
#include <linux/slab.h>
#include <dahdi/kernel.h>
#include <dahdi/user.h>

View File

@@ -27,6 +27,7 @@
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <dahdi/kernel.h>

View File

@@ -26,6 +26,7 @@
#include <linux/delay.h>
#include <linux/sched.h>
#include <linux/crc32.h>
#include <linux/slab.h>
#include "voicebus/vpmoct.h"
#include "linux/firmware.h"

View File

@@ -23,6 +23,7 @@
#include <linux/ctype.h>
#include <linux/moduleparam.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <dahdi/kernel.h>

4544
drivers/dahdi/wcaxx-base.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -40,6 +40,7 @@
#include <linux/timer.h> /* timer_struct */
#include <linux/moduleparam.h>
#include <linux/proc_fs.h>
#include <linux/slab.h>
#include <dahdi/kernel.h>
@@ -2429,7 +2430,7 @@ b4xxp_chanconfig(struct file *file, struct dahdi_chan *chan, int sigtype)
return 0;
}
static int b4xxp_open(struct dahdi_chan *chan)
static int _b4xxp_open(struct dahdi_chan *chan)
{
struct b4xxp *b4 = chan->pvt;
struct b4xxp_span *bspan = &b4->spans[chan->span->offset];
@@ -2443,6 +2444,15 @@ static int b4xxp_open(struct dahdi_chan *chan)
return 0;
}
static int b4xxp_open(struct dahdi_chan *chan)
{
unsigned long flags;
int res;
spin_lock_irqsave(&chan->lock, flags);
res = _b4xxp_open(chan);
spin_unlock_irqrestore(&chan->lock, flags);
return res;
}
static int b4xxp_close(struct dahdi_chan *chan)
{

View File

@@ -31,6 +31,7 @@
#include <linux/pci.h>
#include <asm/io.h>
#include <linux/moduleparam.h>
#include <linux/slab.h>
#include <dahdi/kernel.h>
@@ -569,7 +570,7 @@ static inline struct wcfxo *wcfxo_from_span(struct dahdi_span *span)
return container_of(span, struct wcfxo, span);
}
static int wcfxo_open(struct dahdi_chan *chan)
static int _wcfxo_open(struct dahdi_chan *chan)
{
struct wcfxo *wc = chan->pvt;
if (wc->dead)
@@ -578,6 +579,16 @@ static int wcfxo_open(struct dahdi_chan *chan)
return 0;
}
static int wcfxo_open(struct dahdi_chan *chan)
{
int res;
unsigned long flags;
spin_lock_irqsave(&chan->lock, flags);
res = _wcfxo_open(chan);
spin_unlock_irqrestore(&chan->lock, flags);
return res;
}
static int wcfxo_watchdog(struct dahdi_span *span, int event)
{
printk(KERN_INFO "FXO: Restarting DMA\n");

View File

@@ -32,6 +32,7 @@
#include <linux/pci.h>
#include <linux/spinlock.h>
#include <linux/moduleparam.h>
#include <linux/slab.h>
#include <dahdi/kernel.h>

View File

@@ -2,7 +2,7 @@ obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCT4XXP) += wct4xxp.o
FIRM_DIR := ../firmware
EXTRA_CFLAGS += -I$(src)/.. $(shell $(src)/../oct612x/octasic-helper cflags $(src)/../oct612x) -Wno-undef
EXTRA_CFLAGS += -I$(src)/.. -I$(src)/../oct612x/ $(shell $(src)/../oct612x/octasic-helper cflags $(src)/../oct612x) -Wno-undef
# The OCT612X source files are from a vendor drop and we do not want to edit
# them to make this warning go away. Therefore, turn off the
@@ -14,7 +14,7 @@ ifeq ($(HOTPLUG_FIRMWARE),yes)
EXTRA_CFLAGS+=-DHOTPLUG_FIRMWARE
endif
wct4xxp-objs := base.o vpm450m.o ../oct612x/lib.a
wct4xxp-objs := base.o vpm450m.o
ifneq ($(HOTPLUG_FIRMWARE),yes)
wct4xxp-objs += $(FIRM_DIR)/dahdi-fw-oct6114-064.o $(FIRM_DIR)/dahdi-fw-oct6114-128.o $(FIRM_DIR)/dahdi-fw-oct6114-256.o

View File

@@ -40,6 +40,7 @@
#include <linux/delay.h>
#include <linux/moduleparam.h>
#include <linux/crc32.h>
#include <linux/slab.h>
#include <stdbool.h>
#include <dahdi/kernel.h>
@@ -183,7 +184,7 @@ static inline int t4_queue_work(struct workqueue_struct *wq, struct work_struct
"CONFIG_NOEXTENDED_RESET."
#endif
static int debug=0;
int debug = 0;
static int timingcable = 0;
static int t1e1override = -1; /* deprecated */
static char *default_linemode = "auto";
@@ -299,6 +300,7 @@ struct t4_span {
unsigned long alarmcheck_time;
int spanflags;
int syncpos;
#ifdef SUPPORT_GEN1
int e1check; /* E1 check */
#endif
@@ -345,6 +347,7 @@ struct t4 {
int irq; /* IRQ used by device */
int order; /* Order */
const struct devtype *devtype;
unsigned int reset_required:1; /* If reset needed in serial_setup */
unsigned int falc31:1; /* are we falc v3.1 (atomic not necessary) */
unsigned int t1e1:8; /* T1 / E1 select pins */
int ledreg; /* LED Register */
@@ -368,9 +371,14 @@ struct t4 {
dma_addr_t writedma;
void __iomem *membase; /* Base address of card */
/* Flags for our bottom half */
#define T4_CHECK_VPM 0
#define T4_LOADING_FW 1
#define T4_STOP_DMA 2
#define T4_CHECK_TIMING 3
#define T4_CHANGE_LATENCY 4
#define T4_IGNORE_LATENCY 5
unsigned long checkflag;
struct tasklet_struct t4_tlet;
struct work_struct bh_work;
/* Latency related additions */
unsigned char rxident;
unsigned char lastindex;
@@ -505,7 +513,7 @@ static void t4_check_sigbits(struct t4 *wc, int span);
#define FMR5_EIBR (1 << 6) /* Internal Bit Robbing Access */
#define DEC_T 0x60 /* Diable Error Counter */
#define IERR_T 0x1B /* Single Bit Defect Insertion Register */
#define IBV 0 /* Bipolar violation */
#define IBV (1 << 0) /* Bipolar violation */
#define IPE (1 << 1) /* PRBS defect */
#define ICASE (1 << 2) /* CAS defect */
#define ICRCE (1 << 3) /* CRC defect */
@@ -546,8 +554,6 @@ static void t4_check_sigbits(struct t4 *wc, int span);
#define MAX_T4_CARDS 64
static void t4_isr_bh(unsigned long data);
static struct t4 *cards[MAX_T4_CARDS];
struct t8_firm_header {
@@ -1119,16 +1125,11 @@ static int t4_echocan_create(struct dahdi_chan *chan,
struct t4 *wc = chan->pvt;
struct t4_span *tspan = container_of(chan->span, struct t4_span, span);
int channel;
const struct dahdi_echocan_ops *ops;
const struct dahdi_echocan_features *features;
const bool alaw = (chan->span->deflaw == 2);
if (!vpmsupport || !wc->vpm)
return -ENODEV;
ops = &vpm_ec_ops;
features = &vpm_ec_features;
if (ecp->param_count > 0) {
dev_warn(&wc->dev->dev, "%s echo canceller does not support "
"parameters; failing request\n",
@@ -1137,8 +1138,8 @@ static int t4_echocan_create(struct dahdi_chan *chan,
}
*ec = tspan->ec[chan->chanpos - 1];
(*ec)->ops = ops;
(*ec)->features = *features;
(*ec)->ops = &vpm_ec_ops;
(*ec)->features = vpm_ec_features;
channel = has_e1_span(wc) ? chan->chanpos : chan->chanpos + 4;
@@ -1712,8 +1713,11 @@ _t4_spanconfig(struct file *file, struct dahdi_span *span,
if (lc->sync < 0)
lc->sync = 0;
if (lc->sync > wc->numspans)
if (lc->sync > wc->numspans) {
dev_warn(&wc->dev->dev, "WARNING: Cannot set priority on span %d to %d. Please set to a number between 1 and %d\n",
span->spanno, lc->sync, wc->numspans);
lc->sync = 0;
}
/* remove this span number from the current sync sources, if there */
for(i = 0; i < wc->numspans; i++) {
@@ -1828,16 +1832,6 @@ t4_chanconfig(struct file *file, struct dahdi_chan *chan, int sigtype)
return 0;
}
static int t4_open(struct dahdi_chan *chan)
{
return 0;
}
static int t4_close(struct dahdi_chan *chan)
{
return 0;
}
static int set_span_devicetype(struct t4 *wc)
{
#ifdef VPM_SUPPORT
@@ -1890,6 +1884,33 @@ static void setup_chunks(struct t4 *wc, int which)
}
}
static int __t4_hardware_init_1(struct t4 *wc, unsigned int cardflags,
bool first_time);
static int __t4_hardware_init_2(struct t4 *wc, bool first_time);
static int t4_hardware_stop(struct t4 *wc);
static void t4_framer_reset(struct t4 *wc)
{
const bool first_time = false;
bool have_vpm = wc->vpm != NULL;
if (have_vpm) {
release_vpm450m(wc->vpm);
wc->vpm = NULL;
}
t4_hardware_stop(wc);
__t4_set_sclk_src(wc, WC_SELF, 0, 0);
__t4_hardware_init_1(wc, wc->devtype->flags, first_time);
__t4_hardware_init_2(wc, first_time);
if (have_vpm) {
t4_vpm_init(wc);
wc->dmactrl |= (wc->vpm) ? T4_VPM_PRESENT : 0;
t4_pci_out(wc, WC_DMACTRL, wc->dmactrl);
}
setup_chunks(wc, 0);
wc->lastindex = 0;
}
/**
* t4_serial_setup - Setup serial parameters and system interface.
* @wc: The card to configure.
@@ -1899,6 +1920,7 @@ static void t4_serial_setup(struct t4 *wc)
{
unsigned long flags;
unsigned int unit;
bool reset_required = false;
if (debug) {
dev_info(&wc->dev->dev,
@@ -1906,6 +1928,14 @@ static void t4_serial_setup(struct t4 *wc)
wc->numspans);
}
spin_lock_irqsave(&wc->reglock, flags);
reset_required = wc->reset_required > 0;
wc->reset_required = 0;
spin_unlock_irqrestore(&wc->reglock, flags);
if (reset_required)
t4_framer_reset(wc);
spin_lock_irqsave(&wc->reglock, flags);
/* GPC1: Multiplex mode enabled, FSC is output, active low, RCLK from
* channel 0 */
@@ -2056,6 +2086,7 @@ static void t4_span_assigned(struct dahdi_span *span)
struct t4 *wc = tspan->owner;
struct dahdi_span *pos;
unsigned int unassigned_spans = 0;
unsigned long flags;
/* We use this to make sure all the spans are assigned before
* running the serial setup. */
@@ -2064,14 +2095,22 @@ static void t4_span_assigned(struct dahdi_span *span)
++unassigned_spans;
}
if (0 == unassigned_spans)
if (0 == unassigned_spans) {
t4_serial_setup(wc);
set_bit(T4_CHECK_TIMING, &wc->checkflag);
spin_lock_irqsave(&wc->reglock, flags);
__t4_set_sclk_src(wc, WC_SELF, 0, 0);
spin_unlock_irqrestore(&wc->reglock, flags);
}
}
static void free_wc(struct t4 *wc)
{
unsigned int x, y;
flush_scheduled_work();
for (x = 0; x < ARRAY_SIZE(wc->tspans); x++) {
if (!wc->tspans[x])
continue;
@@ -2227,6 +2266,7 @@ static int t4_set_linemode(struct dahdi_span *span, enum spantypes linemode)
enum linemode mode;
const char *old_name;
static DEFINE_MUTEX(linemode_lock);
unsigned long flags;
dev_dbg(&wc->dev->dev, "Setting '%s' to '%s'\n", span->name,
dahdi_spantype2str(linemode));
@@ -2234,6 +2274,10 @@ static int t4_set_linemode(struct dahdi_span *span, enum spantypes linemode)
if (span->spantype == linemode)
return 0;
spin_lock_irqsave(&wc->reglock, flags);
wc->reset_required = 1;
spin_unlock_irqrestore(&wc->reglock, flags);
/* Do not allow the t1e1 member to be changed by multiple threads. */
mutex_lock(&linemode_lock);
old_name = dahdi_spantype2str(span->spantype);
@@ -2280,8 +2324,6 @@ static const struct dahdi_span_ops t4_gen1_span_ops = {
.shutdown = t4_shutdown,
.rbsbits = t4_rbsbits,
.maint = t4_maint,
.open = t4_open,
.close = t4_close,
.ioctl = t4_ioctl,
.hdlc_hard_xmit = t4_hdlc_hard_xmit,
.assigned = t4_span_assigned,
@@ -2296,8 +2338,6 @@ static const struct dahdi_span_ops t4_gen2_span_ops = {
.shutdown = t4_shutdown,
.rbsbits = t4_rbsbits,
.maint = t4_maint,
.open = t4_open,
.close = t4_close,
.ioctl = t4_ioctl,
.hdlc_hard_xmit = t4_hdlc_hard_xmit,
.dacs = t4_dacs,
@@ -2670,7 +2710,7 @@ static void __t4_configure_t1(struct t4 *wc, int unit, int lineconfig, int txlev
if (lineconfig & DAHDI_CONFIG_AMI) {
line = "AMI";
/* workaround for errata #2 in ES v3 09-10-16 */
fmr0 = (wc->falc31) ? 0xb0 : 0xa0;
fmr0 = (is_octal(wc) || wc->falc31) ? 0xb0 : 0xa0;
} else {
line = "B8ZS";
fmr0 = 0xf0;
@@ -2769,7 +2809,7 @@ static void __t4_configure_e1(struct t4 *wc, int unit, int lineconfig)
if (lineconfig & DAHDI_CONFIG_AMI) {
line = "AMI";
/* workaround for errata #2 in ES v3 09-10-16 */
fmr0 = (wc->falc31) ? 0xb0 : 0xa0;
fmr0 = (is_octal(wc) || wc->falc31) ? 0xb0 : 0xa0;
} else {
line = "HDB3";
fmr0 = 0xf0;
@@ -2830,6 +2870,10 @@ static void __t4_configure_e1(struct t4 *wc, int unit, int lineconfig)
__t4_framer_out(wc, unit, 0x17, 0x04 | imr3extra); /* IMR3: AIS */
__t4_framer_out(wc, unit, 0x18, 0x3f); /* IMR4: We care about slips on transmit */
__t4_framer_out(wc, unit, 0x2f, 0x00);
__t4_framer_out(wc, unit, 0x30, 0x00);
__t4_framer_out(wc, unit, 0x31, 0x00);
dev_info(&wc->dev->dev, "TE%dXXP: Span %d configured for %s/%s%s\n",
wc->numspans, unit + 1, framing, line, crc4);
}
@@ -3252,8 +3296,6 @@ static void t4_check_sigbits(struct t4 *wc, int span)
dev_notice(&wc->dev->dev, "Checking sigbits on span %d\n",
span + 1);
if (!(ts->span.flags & DAHDI_FLAG_RUNNING))
return;
if (E1 == ts->linemode) {
for (i = 0; i < 15; i++) {
a = t4_framer_in(wc, span, 0x71 + i);
@@ -3643,6 +3685,7 @@ static inline void t4_framer_interrupt(struct t4 *wc, int span)
struct t4_span *ts = wc->tspans[span];
struct dahdi_chan *sigchan;
unsigned long flags;
bool recheck_sigbits = false;
/* 1st gen cards isn't used interrupts */
@@ -3668,6 +3711,8 @@ static inline void t4_framer_interrupt(struct t4 *wc, int span)
ts->span.count.ebit += __t4_framer_in(wc, span, EBCL_T);
ts->span.count.be += __t4_framer_in(wc, span, BECL_T);
ts->span.count.prbs = __t4_framer_in(wc, span, FRS1_T);
if (DAHDI_RXSIG_INITIAL == ts->span.chans[0]->rxhooksig)
recheck_sigbits = true;
}
spin_unlock_irqrestore(&wc->reglock, flags);
@@ -3676,7 +3721,7 @@ static inline void t4_framer_interrupt(struct t4 *wc, int span)
ts->span.count.errsec += 1;
}
if (isr0)
if (isr0 & 0x08 || recheck_sigbits)
t4_check_sigbits(wc, span);
if (E1 == ts->linemode) {
@@ -4003,9 +4048,15 @@ static void t4_increase_latency(struct t4 *wc, int newlatency)
}
static void t4_isr_bh(unsigned long data)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void t4_work_func(void *data)
{
struct t4 *wc = (struct t4 *)data;
struct t4 *wc = data;
#else
static void t4_work_func(struct work_struct *work)
{
struct t4 *wc = container_of(work, struct t4, bh_work);
#endif
if (test_bit(T4_CHANGE_LATENCY, &wc->checkflag)) {
if (wc->needed_latency != wc->numbufs) {
@@ -4212,7 +4263,7 @@ static irqreturn_t _t4_interrupt_gen2(int irq, void *dev_id)
out:
if (unlikely(test_bit(T4_CHANGE_LATENCY, &wc->checkflag) || test_bit(T4_CHECK_VPM, &wc->checkflag)))
tasklet_schedule(&wc->t4_tlet);
schedule_work(&wc->bh_work);
#ifndef ENABLE_WORKQUEUES
__t4_pci_out(wc, WC_INTR, 0);
@@ -4306,7 +4357,7 @@ static void t4_vpm_init(struct t4 *wc)
laws[x] = 1;
}
vpm_capacity = get_vpm450m_capacity(wc);
vpm_capacity = get_vpm450m_capacity(&wc->dev->dev);
if (vpm_capacity != wc->numspans * 32) {
dev_info(&wc->dev->dev, "Disabling VPMOCT%03d. TE%dXXP"\
" requires a VPMOCT%03d", vpm_capacity,
@@ -4378,7 +4429,8 @@ static void t4_vpm_init(struct t4 *wc)
return;
}
if (!(wc->vpm = init_vpm450m(wc, laws, wc->numspans, firmware))) {
wc->vpm = init_vpm450m(&wc->dev->dev, laws, wc->numspans, firmware);
if (!wc->vpm) {
dev_notice(&wc->dev->dev, "VPM450: Failed to initialize\n");
if (firmware != &embedded_firmware)
release_firmware(firmware);
@@ -4865,17 +4917,18 @@ cleanup:
return res;
}
static int t4_hardware_init_1(struct t4 *wc, unsigned int cardflags)
static int
__t4_hardware_init_1(struct t4 *wc, unsigned int cardflags, bool first_time)
{
unsigned int version;
int res;
version = t4_pci_in(wc, WC_VERSION);
if (is_octal(wc)) {
if (is_octal(wc) && first_time) {
dev_info(&wc->dev->dev, "Firmware Version: %01x.%02x\n",
(version & 0xf00) >> 8,
version & 0xff);
} else {
} else if (first_time) {
dev_info(&wc->dev->dev, "Firmware Version: %08x\n", version);
}
if (debug) {
@@ -4923,30 +4976,33 @@ static int t4_hardware_init_1(struct t4 *wc, unsigned int cardflags)
t4_pci_out(wc, WC_INTR, 0x00000000);
/* Read T1/E1 status */
if (!strcasecmp("auto", default_linemode)) {
if (-1 == t1e1override) {
wc->t1e1 = (((t4_pci_in(wc, WC_LEDS)) & 0x0f00) >> 8);
wc->t1e1 &= 0xf;
if (is_octal(wc)) {
wc->t1e1 |= ((t4_pci_in(wc, WC_LEDS2)) &
0x0f00) >> 4;
if (first_time) {
if (!strcasecmp("auto", default_linemode)) {
if (-1 == t1e1override) {
wc->t1e1 = (((t4_pci_in(wc, WC_LEDS)) &
0x0f00) >> 8);
wc->t1e1 &= 0xf;
if (is_octal(wc)) {
wc->t1e1 |= ((t4_pci_in(wc, WC_LEDS2)) &
0x0f00) >> 4;
}
} else {
dev_warn(&wc->dev->dev,
"'t1e1override' is deprecated. Please use 'default_linemode'.\n");
wc->t1e1 = t1e1override & 0xf;
}
} else if (!strcasecmp("t1", default_linemode)) {
wc->t1e1 = 0;
} else if (!strcasecmp("e1", default_linemode)) {
wc->t1e1 = 0xff;
} else if (!strcasecmp("j1", default_linemode)) {
wc->t1e1 = 0;
j1mode = 1;
} else {
dev_warn(&wc->dev->dev, "'t1e1override' is deprecated. "
"Please use 'default_linemode'.\n");
wc->t1e1 = t1e1override & 0xf;
dev_err(&wc->dev->dev, "'%s' is an unknown linemode.\n",
default_linemode);
wc->t1e1 = 0;
}
} else if (!strcasecmp("t1", default_linemode)) {
wc->t1e1 = 0;
} else if (!strcasecmp("e1", default_linemode)) {
wc->t1e1 = 0xff;
} else if (!strcasecmp("j1", default_linemode)) {
wc->t1e1 = 0;
j1mode = 1;
} else {
dev_err(&wc->dev->dev, "'%s' is an unknown linemode.\n",
default_linemode);
wc->t1e1 = 0;
}
wc->order = ((t4_pci_in(wc, WC_LEDS)) & 0xf0000000) >> 28;
@@ -4975,7 +5031,12 @@ static int t4_hardware_init_1(struct t4 *wc, unsigned int cardflags)
return 0;
}
static int t4_hardware_init_2(struct t4 *wc)
static int t4_hardware_init_1(struct t4 *wc, unsigned int cardflags)
{
return __t4_hardware_init_1(wc, cardflags, true);
}
static int __t4_hardware_init_2(struct t4 *wc, bool first_time)
{
int x;
unsigned int regval;
@@ -5007,13 +5068,14 @@ static int t4_hardware_init_2(struct t4 *wc)
if (!is_octal(wc)) {
regval = t4_framer_in(wc, 0, 0x4a);
if (regval == 0x05) {
if (first_time && regval == 0x05) {
dev_info(&wc->dev->dev, "FALC Framer Version: 2.1 or "
"earlier\n");
} else if (regval == 0x20) {
dev_info(&wc->dev->dev, "FALC Framer Version: 3.1\n");
if (first_time)
dev_info(&wc->dev->dev, "FALC Framer Version: 3.1\n");
wc->falc31 = 1;
} else {
} else if (first_time) {
dev_info(&wc->dev->dev, "FALC Framer Version: Unknown "
"(VSTR = 0x%02x)\n", regval);
}
@@ -5033,14 +5095,24 @@ static int t4_hardware_init_2(struct t4 *wc)
t4_pci_in(wc, x));
}
}
wc->gpio = 0x00000000;
t4_pci_out(wc, WC_GPIO, wc->gpio);
t4_gpio_setdir(wc, (1 << 17), (1 << 17));
t4_gpio_setdir(wc, (0xff), (0xff));
return 0;
}
static int t4_hardware_init_2(struct t4 *wc)
{
return __t4_hardware_init_2(wc, true);
}
static int __devinit t4_launch(struct t4 *wc)
{
int x;
int res;
unsigned long flags;
if (test_bit(DAHDI_FLAGBIT_REGISTERED, &wc->tspans[0]->span.flags))
return 0;
@@ -5072,17 +5144,18 @@ static int __devinit t4_launch(struct t4 *wc)
&wc->ddev->spans);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
INIT_WORK(&wc->bh_work, t4_work_func, wc);
#else
INIT_WORK(&wc->bh_work, t4_work_func);
#endif
res = dahdi_register_device(wc->ddev, &wc->dev->dev);
if (res) {
dev_err(&wc->dev->dev, "Failed to register with DAHDI.\n");
return res;
}
set_bit(T4_CHECK_TIMING, &wc->checkflag);
spin_lock_irqsave(&wc->reglock, flags);
__t4_set_sclk_src(wc, WC_SELF, 0, 0);
spin_unlock_irqrestore(&wc->reglock, flags);
tasklet_init(&wc->t4_tlet, t4_isr_bh, (unsigned long)wc);
return 0;
}
@@ -5296,10 +5369,6 @@ t4_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
dev_info(&wc->dev->dev,
"Found a Wildcard: %s\n", wc->devtype->desc);
}
wc->gpio = 0x00000000;
t4_pci_out(wc, WC_GPIO, wc->gpio);
t4_gpio_setdir(wc, (1 << 17), (1 << 17));
t4_gpio_setdir(wc, (0xff), (0xff));
#ifdef VPM_SUPPORT
if (!wc->vpm) {

View File

@@ -31,99 +31,62 @@
#include <stdbool.h>
#include "vpm450m.h"
#include "oct6100api/oct6100_api.h"
#include <oct612x.h>
/* API for Octasic access */
UINT32 Oct6100UserGetTime(tPOCT6100_GET_TIME f_pTime)
static int wct4xxp_oct612x_write(struct oct612x_context *context,
u32 address, u16 value)
{
/* Why couldn't they just take a timeval like everyone else? */
struct timeval tv;
unsigned long long total_usecs;
unsigned int mask = ~0;
do_gettimeofday(&tv);
total_usecs = (((unsigned long long)(tv.tv_sec)) * 1000000) +
(((unsigned long long)(tv.tv_usec)));
f_pTime->aulWallTimeUs[0] = (total_usecs & mask);
f_pTime->aulWallTimeUs[1] = (total_usecs >> 32);
return cOCT6100_ERR_OK;
struct t4 *wc = dev_get_drvdata(context->dev);
oct_set_reg(wc, address, value);
return 0;
}
UINT32 Oct6100UserMemSet(PVOID f_pAddress, UINT32 f_ulPattern, UINT32 f_ulLength)
static int wct4xxp_oct612x_read(struct oct612x_context *context, u32 address,
u16 *value)
{
memset(f_pAddress, f_ulPattern, f_ulLength);
return cOCT6100_ERR_OK;
struct t4 *wc = dev_get_drvdata(context->dev);
*value = (u16)oct_get_reg(wc, address);
return 0;
}
UINT32 Oct6100UserMemCopy(PVOID f_pDestination, const void *f_pSource, UINT32 f_ulLength)
static int wct4xxp_oct612x_write_smear(struct oct612x_context *context,
u32 address, u16 value, size_t count)
{
memcpy(f_pDestination, f_pSource, f_ulLength);
return cOCT6100_ERR_OK;
struct t4 *wc = dev_get_drvdata(context->dev);
int i;
for (i = 0; i < count; ++i)
oct_set_reg(wc, address + (i << 1), value);
return 0;
}
UINT32 Oct6100UserCreateSerializeObject(tPOCT6100_CREATE_SERIALIZE_OBJECT f_pCreate)
static int wct4xxp_oct612x_write_burst(struct oct612x_context *context,
u32 address, const u16 *buffer,
size_t count)
{
return cOCT6100_ERR_OK;
struct t4 *wc = dev_get_drvdata(context->dev);
int i;
for (i = 0; i < count; ++i)
oct_set_reg(wc, address + (i << 1), buffer[i]);
return 0;
}
UINT32 Oct6100UserDestroySerializeObject(tPOCT6100_DESTROY_SERIALIZE_OBJECT f_pDestroy)
static int wct4xxp_oct612x_read_burst(struct oct612x_context *context,
u32 address, u16 *buffer, size_t count)
{
#ifdef OCTASIC_DEBUG
printk(KERN_DEBUG "I should never be called! (destroy serialize object)\n");
#endif
return cOCT6100_ERR_OK;
struct t4 *wc = dev_get_drvdata(context->dev);
int i;
for (i = 0; i < count; ++i)
buffer[i] = oct_get_reg(wc, address + (i << 1));
return 0;
}
UINT32 Oct6100UserSeizeSerializeObject(tPOCT6100_SEIZE_SERIALIZE_OBJECT f_pSeize)
{
/* Not needed */
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserReleaseSerializeObject(tPOCT6100_RELEASE_SERIALIZE_OBJECT f_pRelease)
{
/* Not needed */
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserDriverWriteApi(tPOCT6100_WRITE_PARAMS f_pWriteParams)
{
oct_set_reg(f_pWriteParams->pProcessContext, f_pWriteParams->ulWriteAddress, f_pWriteParams->usWriteData);
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserDriverWriteSmearApi(tPOCT6100_WRITE_SMEAR_PARAMS f_pSmearParams)
{
unsigned int x;
for (x=0;x<f_pSmearParams->ulWriteLength;x++) {
oct_set_reg(f_pSmearParams->pProcessContext, f_pSmearParams->ulWriteAddress + (x << 1), f_pSmearParams->usWriteData);
}
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserDriverWriteBurstApi(tPOCT6100_WRITE_BURST_PARAMS f_pBurstParams)
{
unsigned int x;
for (x=0;x<f_pBurstParams->ulWriteLength;x++) {
oct_set_reg(f_pBurstParams->pProcessContext, f_pBurstParams->ulWriteAddress + (x << 1), f_pBurstParams->pusWriteData[x]);
}
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserDriverReadApi(tPOCT6100_READ_PARAMS f_pReadParams)
{
*(f_pReadParams->pusReadData) = oct_get_reg(f_pReadParams->pProcessContext, f_pReadParams->ulReadAddress);
return cOCT6100_ERR_OK;
}
UINT32 Oct6100UserDriverReadBurstApi(tPOCT6100_READ_BURST_PARAMS f_pBurstParams)
{
unsigned int x;
for (x=0;x<f_pBurstParams->ulReadLength;x++) {
f_pBurstParams->pusReadData[x] = oct_get_reg(f_pBurstParams->pProcessContext, f_pBurstParams->ulReadAddress + (x << 1));
}
return cOCT6100_ERR_OK;
}
static const struct oct612x_ops wct4xxp_oct612x_ops = {
.write = wct4xxp_oct612x_write,
.read = wct4xxp_oct612x_read,
.write_smear = wct4xxp_oct612x_write_smear,
.write_burst = wct4xxp_oct612x_write_burst,
.read_burst = wct4xxp_oct612x_read_burst,
};
#define SOUT_G168_1100GB_ON 0x40000004
#define SOUT_DTMF_1 0x40000011
@@ -173,6 +136,7 @@ UINT32 Oct6100UserDriverReadBurstApi(tPOCT6100_READ_BURST_PARAMS f_pBurstParams)
struct vpm450m {
tPOCT6100_INSTANCE_API pApiInstance;
struct oct612x_context context;
UINT32 aulEchoChanHndl[256];
int chanflags[256];
int ecmode[256];
@@ -256,8 +220,10 @@ void vpm450m_set_alaw_companding(struct vpm450m *vpm450m, int channel,
pr_notice("Failed to apply echo can changes on channel %d %d %08x!\n",
vpm450m->aulEchoChanHndl[channel], channel, ulResult);
} else {
pr_info("Changed companding on channel %d to %s.\n", channel,
(alaw) ? "alaw" : "ulaw");
if (debug) {
pr_info("Changed companding on channel %d to %s.\n",
channel, (alaw) ? "alaw" : "ulaw");
}
if (alaw)
vpm450m->chanflags[channel] |= FLAG_ALAW;
else
@@ -273,7 +239,7 @@ static void vpm450m_setecmode(struct vpm450m *vpm450m, int channel, int mode)
if (vpm450m->ecmode[channel] == mode)
return;
modify = kmalloc(sizeof(tOCT6100_CHANNEL_MODIFY), GFP_ATOMIC);
modify = kzalloc(sizeof(*modify), GFP_ATOMIC);
if (!modify) {
printk(KERN_NOTICE "wct4xxp: Unable to allocate memory for setec!\n");
return;
@@ -303,7 +269,7 @@ void vpm450m_setdtmf(struct vpm450m *vpm450m, int channel, int detect, int mute)
return;
}
modify = kmalloc(sizeof(tOCT6100_CHANNEL_MODIFY), GFP_KERNEL);
modify = kzalloc(sizeof(*modify), GFP_KERNEL);
if (!modify) {
printk(KERN_NOTICE "wct4xxp: Unable to allocate memory for setdtmf!\n");
return;
@@ -451,14 +417,18 @@ int vpm450m_getdtmf(struct vpm450m *vpm450m, int *channel, int *tone, int *start
return 0;
}
unsigned int get_vpm450m_capacity(void *wc)
unsigned int get_vpm450m_capacity(struct device *device)
{
struct oct612x_context context;
UINT32 ulResult;
tOCT6100_API_GET_CAPACITY_PINS CapacityPins;
context.dev = device;
context.ops = &wct4xxp_oct612x_ops;
Oct6100ApiGetCapacityPinsDef(&CapacityPins);
CapacityPins.pProcessContext = wc;
CapacityPins.pProcessContext = &context;
CapacityPins.ulMemoryType = cOCT6100_MEM_TYPE_DDR;
CapacityPins.fEnableMemClkOut = TRUE;
CapacityPins.ulMemClkFreq = cOCT6100_MCLK_FREQ_133_MHZ;
@@ -472,7 +442,8 @@ unsigned int get_vpm450m_capacity(void *wc)
return CapacityPins.ulCapacityValue;
}
struct vpm450m *init_vpm450m(void *wc, int *isalaw, int numspans, const struct firmware *firmware)
struct vpm450m *init_vpm450m(struct device *device, int *isalaw,
int numspans, const struct firmware *firmware)
{
tOCT6100_CHIP_OPEN *ChipOpen;
tOCT6100_GET_INSTANCE_SIZE InstanceSize;
@@ -483,26 +454,27 @@ struct vpm450m *init_vpm450m(void *wc, int *isalaw, int numspans, const struct f
struct vpm450m *vpm450m;
int x,y,law;
if (!(vpm450m = kmalloc(sizeof(struct vpm450m), GFP_KERNEL)))
vpm450m = kzalloc(sizeof(*vpm450m), GFP_KERNEL);
if (!vpm450m)
return NULL;
memset(vpm450m, 0, sizeof(struct vpm450m));
vpm450m->context.dev = device;
vpm450m->context.ops = &wct4xxp_oct612x_ops;
if (!(ChipOpen = kmalloc(sizeof(tOCT6100_CHIP_OPEN), GFP_KERNEL))) {
ChipOpen = kzalloc(sizeof(*ChipOpen), GFP_KERNEL);
if (!ChipOpen) {
kfree(vpm450m);
kfree(vpm450m);
return NULL;
}
memset(ChipOpen, 0, sizeof(tOCT6100_CHIP_OPEN));
if (!(ChannelOpen = kmalloc(sizeof(tOCT6100_CHANNEL_OPEN), GFP_KERNEL))) {
ChannelOpen = kzalloc(sizeof(*ChannelOpen), GFP_KERNEL);
if (!ChannelOpen) {
kfree(vpm450m);
kfree(ChipOpen);
return NULL;
}
memset(ChannelOpen, 0, sizeof(tOCT6100_CHANNEL_OPEN));
for (x = 0; x < ARRAY_SIZE(vpm450m->ecmode); x++)
vpm450m->ecmode[x] = -1;
@@ -515,7 +487,7 @@ struct vpm450m *init_vpm450m(void *wc, int *isalaw, int numspans, const struct f
ChipOpen->ulUpclkFreq = cOCT6100_UPCLK_FREQ_33_33_MHZ;
Oct6100GetInstanceSizeDef(&InstanceSize);
ChipOpen->pProcessContext = wc;
ChipOpen->pProcessContext = &vpm450m->context;
ChipOpen->pbyImageFile = firmware->data;
ChipOpen->ulImageSize = firmware->size;

View File

@@ -25,6 +25,7 @@
#include <linux/firmware.h>
struct t4;
struct vpm450m;
/* From driver */
@@ -32,8 +33,9 @@ unsigned int oct_get_reg(void *data, unsigned int reg);
void oct_set_reg(void *data, unsigned int reg, unsigned int val);
/* From vpm450m */
struct vpm450m *init_vpm450m(void *wc, int *isalaw, int numspans, const struct firmware *firmware);
unsigned int get_vpm450m_capacity(void *wc);
struct vpm450m *init_vpm450m(struct device *device, int *isalaw,
int numspans, const struct firmware *firmware);
unsigned int get_vpm450m_capacity(struct device *device);
void vpm450m_setec(struct vpm450m *instance, int channel, int eclen);
void vpm450m_setdtmf(struct vpm450m *instance, int channel, int dtmfdetect, int dtmfmute);
int vpm450m_checkirq(struct vpm450m *vpm450m);
@@ -42,4 +44,6 @@ void release_vpm450m(struct vpm450m *instance);
void vpm450m_set_alaw_companding(struct vpm450m *vpm450m,
int channel, bool alaw);
extern int debug;
#endif

View File

@@ -131,13 +131,6 @@ struct t4_reg {
unsigned int val;
};
#define T4_CHECK_VPM 0
#define T4_LOADING_FW 1
#define T4_STOP_DMA 2
#define T4_CHECK_TIMING 3
#define T4_CHANGE_LATENCY 4
#define T4_IGNORE_LATENCY 5
#define WCT4_GET_REGS _IOW(DAHDI_CODE, 60, struct t4_regs)
#define WCT4_GET_REG _IOW(DAHDI_CODE, 61, struct t4_reg)
#define WCT4_SET_REG _IOW(DAHDI_CODE, 62, struct t4_reg)

File diff suppressed because it is too large Load Diff

View File

@@ -31,6 +31,7 @@
#include <linux/interrupt.h>
#include <linux/moduleparam.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <asm/io.h>
#include "proslic.h"
@@ -2143,7 +2144,7 @@ static int wctdm_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long
}
static int wctdm_open(struct dahdi_chan *chan)
static int _wctdm_open(struct dahdi_chan *chan)
{
struct wctdm *wc = chan->pvt;
if (!(wc->cardflag & (1 << (chan->chanpos - 1))))
@@ -2154,6 +2155,16 @@ static int wctdm_open(struct dahdi_chan *chan)
return 0;
}
static int wctdm_open(struct dahdi_chan *chan)
{
unsigned long flags;
int res;
spin_lock_irqsave(&chan->lock, flags);
res = _wctdm_open(chan);
spin_unlock_irqrestore(&chan->lock, flags);
return res;
}
static inline struct wctdm *wctdm_from_span(struct dahdi_span *span)
{
return container_of(span, struct wctdm, span);

View File

@@ -55,6 +55,7 @@ Tx Gain - W/Pre-Emphasis: -23.99 to 0.00 db
#include <asm/semaphore.h>
#endif
#include <linux/crc32.h>
#include <linux/slab.h>
#include <stdbool.h>
@@ -3100,6 +3101,8 @@ wctdm_init_voicedaa(struct wctdm *wc, struct wctdm_module *mod,
spin_unlock_irqrestore(&wc->reglock, flags);
msleep(20);
memset(&mod->mod.fxo, 0, sizeof(mod->mod.fxo));
if (!sane && wctdm_voicedaa_insane(wc, mod))
return -2;
@@ -3244,8 +3247,7 @@ wctdm_init_proslic(struct wctdm *wc, struct wctdm_module *const mod,
return -2;
/* Initialize VMWI settings */
memset(&(fxs->vmwisetting), 0, sizeof(fxs->vmwisetting));
fxs->vmwi_linereverse = 0;
memset(fxs, 0, sizeof(*fxs));
/* By default, don't send on hook */
if (!reversepolarity != !fxs->reversepolarity)
@@ -4384,32 +4386,6 @@ wctdm_chanconfig(struct file *file, struct dahdi_chan *chan, int sigtype)
return wctdm_wait_for_ready(wc);
}
/*
* wctdm24xxp_assigned - Called when span is assigned.
* @span: The span that is now assigned.
*
* This function is called by the core of DAHDI after the span number and
* channel numbers have been assigned.
*
*/
static void wctdm24xxp_assigned(struct dahdi_span *span)
{
struct dahdi_span *s;
struct dahdi_device *ddev = span->parent;
struct wctdm *wc = NULL;
list_for_each_entry(s, &ddev->spans, device_node) {
wc = (container_of(s, struct wctdm_span, span))->wc;
if (!test_bit(DAHDI_FLAGBIT_REGISTERED, &s->flags))
return;
}
if (wc) {
WARN_ON(0 == wc->not_ready);
--wc->not_ready;
}
}
static const struct dahdi_span_ops wctdm24xxp_analog_span_ops = {
.owner = THIS_MODULE,
.hooksig = wctdm_hooksig,
@@ -4419,7 +4395,6 @@ static const struct dahdi_span_ops wctdm24xxp_analog_span_ops = {
.watchdog = wctdm_watchdog,
.chanconfig = wctdm_chanconfig,
.dacs = wctdm_dacs,
.assigned = wctdm24xxp_assigned,
#ifdef VPM_SUPPORT
.enable_hw_preechocan = wctdm_enable_hw_preechocan,
.disable_hw_preechocan = wctdm_disable_hw_preechocan,
@@ -4438,7 +4413,6 @@ static const struct dahdi_span_ops wctdm24xxp_digital_span_ops = {
.spanconfig = b400m_spanconfig,
.chanconfig = b400m_chanconfig,
.dacs = wctdm_dacs,
.assigned = wctdm24xxp_assigned,
#ifdef VPM_SUPPORT
.enable_hw_preechocan = wctdm_enable_hw_preechocan,
.disable_hw_preechocan = wctdm_disable_hw_preechocan,
@@ -5951,6 +5925,9 @@ __wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
return -1;
}
WARN_ON(wc->not_ready <= 0);
--wc->not_ready;
dev_info(&wc->vb.pdev->dev,
"Found a %s: %s (%d BRI spans, %d analog %s)\n",
(is_hx8(wc)) ? "Hybrid card" : "Wildcard TDM",

View File

@@ -25,6 +25,7 @@
#include <linux/ppp_defs.h>
#include <linux/delay.h>
#include <linux/sched.h>
#include <linux/slab.h>
#define FAST_HDLC_NEED_TABLES
#include <dahdi/kernel.h>

View File

@@ -31,6 +31,7 @@
#include <linux/pci.h>
#include <linux/spinlock.h>
#include <linux/moduleparam.h>
#include <linux/slab.h>
#include <dahdi/kernel.h>
@@ -224,7 +225,7 @@ static inline void __select_control(struct t1 *wc)
}
}
static int t1xxp_open(struct dahdi_chan *chan)
static int _t1xxp_open(struct dahdi_chan *chan)
{
struct t1 *wc = chan->pvt;
if (wc->dead)
@@ -234,6 +235,16 @@ static int t1xxp_open(struct dahdi_chan *chan)
return 0;
}
static int t1xxp_open(struct dahdi_chan *chan)
{
unsigned long flags;
int res;
spin_lock_irqsave(&chan->lock, flags);
res = _t1xxp_open(chan);
spin_unlock_irqrestore(&chan->lock, flags);
return res;
}
static int __control_set_reg(struct t1 *wc, int reg, unsigned char val)
{
__select_control(wc);

View File

@@ -40,6 +40,7 @@
#include <linux/workqueue.h>
#include <linux/delay.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <stdbool.h>
#include <dahdi/kernel.h>

File diff suppressed because it is too large Load Diff

3674
drivers/dahdi/wcte43x-base.c Normal file

File diff suppressed because it is too large Load Diff

1077
drivers/dahdi/wcxb.c Normal file

File diff suppressed because it is too large Load Diff

201
drivers/dahdi/wcxb.h Normal file
View File

@@ -0,0 +1,201 @@
/*
* wcxb SPI library
*
* Copyright (C) 2013 Digium, Inc.
*
* All rights reserved.
*
*/
/*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2 as published by the
* Free Software Foundation. See the LICENSE file included with
* this program for more details.
*/
#ifndef __WCXB_H__
#define __WCXB_H__
#define WCXB_DEFAULT_LATENCY 3U
#define WCXB_DEFAULT_MAXLATENCY 20U
#define WCXB_DMA_CHAN_SIZE 128
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
/* The is_pcie member was backported but I'm not sure in which version. */
# ifndef RHEL_RELEASE_VERSION
#define WCXB_PCI_DEV_DOES_NOT_HAVE_IS_PCIE
# endif
#else
#endif
struct wcxb;
struct wcxb_operations {
void (*handle_receive)(struct wcxb *xb, void *frame);
void (*handle_transmit)(struct wcxb *xb, void *frame);
void (*handle_error)(struct wcxb *xb);
void (*handle_interrupt)(struct wcxb *xb, u32 pending);
};
struct wcxb_meta_desc;
struct wcxb_hw_desc;
/**
* struct wcxb - Interface to wcxb firmware.
* @last_retry_count: Running count of times firmware had to retry host DMA
* transaction. Debugging aide.
*/
struct wcxb {
struct pci_dev *pdev;
spinlock_t lock;
const struct wcxb_operations *ops;
unsigned int *debug;
unsigned int max_latency;
unsigned int latency;
struct {
u32 have_msi:1;
u32 latency_locked:1;
u32 drive_timing_cable:1;
#ifdef WCXB_PCI_DEV_DOES_NOT_HAVE_IS_PCIE
u32 is_pcie:1;
#endif
u32 io_error:1;
} flags;
void __iomem *membase;
struct wcxb_meta_desc *meta_dring;
struct wcxb_hw_desc *hw_dring;
unsigned int dma_head;
unsigned int dma_tail;
dma_addr_t hw_dring_phys;
struct dma_pool *pool;
unsigned long framecount;
#ifdef DEBUG
u8 last_retry_count;
#endif
};
extern int wcxb_init(struct wcxb *xb, const char *board_name, u32 int_mode);
extern void wcxb_release(struct wcxb *xb);
extern int wcxb_start(struct wcxb *xb);
extern void wcxb_stop(struct wcxb *xb);
extern int wcxb_wait_for_stop(struct wcxb *xb, unsigned long timeout_ms);
extern bool wcxb_is_stopped(struct wcxb *xb);
enum wcxb_clock_sources {
WCXB_CLOCK_SELF, /* Use the internal oscillator for timing. */
WCXB_CLOCK_RECOVER, /* Recover the clock from a framer. */
#ifdef RPC_RCLK
WCXB_CLOCK_RECOVER_ALT, /* Recover the clock from a framer. */
#endif
WCXB_CLOCK_SLAVE /* Recover clock from any timing header. */
};
extern enum wcxb_clock_sources wcxb_get_clksrc(struct wcxb *xb);
extern void wcxb_set_clksrc(struct wcxb *xb, enum wcxb_clock_sources clksrc);
static inline void wcxb_enable_timing_header_driver(struct wcxb *xb)
{
xb->flags.drive_timing_cable = 1;
}
static inline bool wcxb_is_timing_header_driver_enabled(struct wcxb *xb)
{
return 1 == xb->flags.drive_timing_cable;
}
static inline void wcxb_disable_timing_header_driver(struct wcxb *xb)
{
xb->flags.drive_timing_cable = 0;
}
enum wcxb_reset_option {
WCXB_RESET_NOW,
WCXB_RESET_LATER
};
extern u32 wcxb_get_firmware_version(struct wcxb *xb);
extern int wcxb_check_firmware(struct wcxb *xb, const u32 expected_version,
const char *firmware_filename,
bool force_firmware,
enum wcxb_reset_option reset);
extern void wcxb_stop_dma(struct wcxb *xb);
extern void wcxb_disable_interrupts(struct wcxb *xb);
static inline void wcxb_gpio_set(struct wcxb *xb, u32 bits)
{
u32 reg;
unsigned long flags;
spin_lock_irqsave(&xb->lock, flags);
reg = ioread32be(xb->membase);
iowrite32be(reg | bits, xb->membase);
spin_unlock_irqrestore(&xb->lock, flags);
}
static inline void wcxb_gpio_clear(struct wcxb *xb, u32 bits)
{
u32 reg;
unsigned long flags;
spin_lock_irqsave(&xb->lock, flags);
reg = ioread32be(xb->membase);
iowrite32be(reg & (~bits), xb->membase);
spin_unlock_irqrestore(&xb->lock, flags);
}
static inline void
wcxb_set_maxlatency(struct wcxb *xb, unsigned int max_latency)
{
unsigned long flags;
spin_lock_irqsave(&xb->lock, flags);
xb->max_latency = clamp(max_latency,
xb->latency,
WCXB_DEFAULT_MAXLATENCY);
spin_unlock_irqrestore(&xb->lock, flags);
}
static inline void
wcxb_set_minlatency(struct wcxb *xb, unsigned int min_latency)
{
unsigned long flags;
spin_lock_irqsave(&xb->lock, flags);
xb->latency = clamp(min_latency, WCXB_DEFAULT_LATENCY,
WCXB_DEFAULT_MAXLATENCY);
spin_unlock_irqrestore(&xb->lock, flags);
}
static inline void
wcxb_lock_latency(struct wcxb *xb)
{
unsigned long flags;
spin_lock_irqsave(&xb->lock, flags);
xb->flags.latency_locked = 1;
spin_unlock_irqrestore(&xb->lock, flags);
return;
}
static inline void
wcxb_unlock_latency(struct wcxb *xb)
{
unsigned long flags;
spin_lock_irqsave(&xb->lock, flags);
xb->flags.latency_locked = 0;
spin_unlock_irqrestore(&xb->lock, flags);
return;
}
/* Interface for the echocan block */
extern void wcxb_enable_echocan(struct wcxb *xb);
extern void wcxb_disable_echocan(struct wcxb *xb);
extern void wcxb_reset_echocan(struct wcxb *xb);
extern void wcxb_enable_echocan_dram(struct wcxb *xb);
extern bool wcxb_is_echocan_present(struct wcxb *xb);
extern u16 wcxb_get_echocan_reg(struct wcxb *xb, u32 address);
extern void wcxb_set_echocan_reg(struct wcxb *xb, u32 address, u16 val);
#endif

170
drivers/dahdi/wcxb_flash.c Normal file
View File

@@ -0,0 +1,170 @@
/*
* wcxb SPI library
*
* Copyright (C) 2013 Digium, Inc.
*
* All rights reserved.
*
*/
/*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2 as published by the
* Free Software Foundation. See the LICENSE file included with
* this program for more details.
*/
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/device.h>
#include <linux/sched.h>
#include "wcxb_spi.h"
#include "wcxb_flash.h"
#define FLASH_PAGE_PROGRAM 0x02
#define FLASH_READ 0x03
#define FLASH_READ_STATUS 0x05
#define FLASH_WRITE_ENABLE 0x06
#define FLASH_SECTOR_ERASE 0xd8
static int wcxb_flash_read_status_register(struct wcxb_spi_device *spi,
u8 *status)
{
u8 command[] = {
FLASH_READ_STATUS,
};
struct wcxb_spi_transfer t_cmd = {
.tx_buf = command,
.len = sizeof(command),
};
struct wcxb_spi_transfer t_serial = {
.rx_buf = status,
.len = 1,
};
struct wcxb_spi_message m;
wcxb_spi_message_init(&m);
wcxb_spi_message_add_tail(&t_cmd, &m);
wcxb_spi_message_add_tail(&t_serial, &m);
return wcxb_spi_sync(spi, &m);
}
int wcxb_flash_read(struct wcxb_spi_device *spi, unsigned int address,
void *data, size_t len)
{
u8 command[] = {
FLASH_READ,
(address & 0xff0000) >> 16,
(address & 0xff00) >> 8,
(address & 0xff)
};
struct wcxb_spi_transfer t_cmd = {
.tx_buf = command,
.len = sizeof(command),
};
struct wcxb_spi_transfer t_serial = {
.rx_buf = data,
.len = len,
};
struct wcxb_spi_message m;
wcxb_spi_message_init(&m);
wcxb_spi_message_add_tail(&t_cmd, &m);
wcxb_spi_message_add_tail(&t_serial, &m);
return wcxb_spi_sync(spi, &m);
}
static int wcxb_flash_wait_until_not_busy(struct wcxb_spi_device *spi)
{
int res;
u8 status;
unsigned long stop = jiffies + 5*HZ;
do {
res = wcxb_flash_read_status_register(spi, &status);
} while (!res && (status & 0x1) && time_before(jiffies, stop));
if (!res)
return res;
if (time_after_eq(jiffies, stop))
return -EIO;
return 0;
}
static int wcxb_flash_write_enable(struct wcxb_spi_device *spi)
{
u8 command = FLASH_WRITE_ENABLE;
return wcxb_spi_write(spi, &command, 1);
}
int wcxb_flash_sector_erase(struct wcxb_spi_device *spi,
unsigned int address)
{
int res;
u8 command[] = {FLASH_SECTOR_ERASE, (address >> 16)&0xff, 0x00, 0x00};
/* Sector must be on 64KB boundary. */
if (address & 0xffff)
return -EINVAL;
/* Start the erase. */
res = wcxb_flash_write_enable(spi);
if (res)
return res;
res = wcxb_spi_write(spi, &command, sizeof(command));
if (res)
return res;
return wcxb_flash_wait_until_not_busy(spi);
}
int wcxb_flash_write(struct wcxb_spi_device *spi, unsigned int address,
const void *data, size_t len)
{
int res;
const size_t FLASH_PAGE_SIZE = 256;
u8 command[] = {
FLASH_PAGE_PROGRAM,
(address & 0xff0000) >> 16,
(address & 0xff00) >> 8,
0x00,
};
struct wcxb_spi_transfer t_cmd = {
.tx_buf = command,
.len = sizeof(command),
};
struct wcxb_spi_transfer t_data = {
.tx_buf = data,
.len = len,
};
struct wcxb_spi_message m;
/* We need to write on page size boundaries */
WARN_ON(address & 0xff);
wcxb_spi_message_init(&m);
wcxb_spi_message_add_tail(&t_cmd, &m);
wcxb_spi_message_add_tail(&t_data, &m);
while (len) {
res = wcxb_flash_write_enable(spi);
if (res)
return res;
command[1] = (address >> 16) & 0xff;
command[2] = (address >> 8) & 0xff;
t_data.tx_buf = data;
t_data.len = min(len, FLASH_PAGE_SIZE);
res = wcxb_spi_sync(spi, &m);
WARN_ON(res);
if (res)
return res;
res = wcxb_flash_wait_until_not_busy(spi);
WARN_ON(res);
if (res)
return res;
len -= t_data.len;
address += t_data.len;
data += t_data.len;
}
return 0;
}

View File

@@ -0,0 +1,34 @@
/*
* wcxb SPI library
*
* Copyright (C) 2013 Digium, Inc.
*
* All rights reserved.
*
*/
/*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2 as published by the
* Free Software Foundation. See the LICENSE file included with
* this program for more details.
*/
#ifndef __WCXB_FLASH_H__
#define __WCXB_FLASH_H__
extern int wcxb_flash_read(struct wcxb_spi_device *spi, unsigned int address,
void *data, size_t len);
extern int wcxb_flash_sector_erase(struct wcxb_spi_device *spi, unsigned int
address);
extern int wcxb_flash_write(struct wcxb_spi_device *spi, unsigned int address,
const void *data, size_t len);
#endif

387
drivers/dahdi/wcxb_spi.c Normal file
View File

@@ -0,0 +1,387 @@
/*
* wcxb SPI library
*
* Copyright (C) 2013 Digium, Inc.
*
* All rights reserved.
*
*/
/*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2 as published by the
* Free Software Foundation. See the LICENSE file included with
* this program for more details.
*/
#define DEBUG
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/device.h>
#include <linux/completion.h>
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/io.h>
#include <dahdi/kernel.h>
#include "wcxb_spi.h"
#define BBIT(n) (1UL << (31UL - (n)))
#define SPISRR 0x40
#define SPISRR_RESET 0x0000000a /* Resets Device */
#define SPICR 0x60
#define SPICR_LSB_FIRST BBIT(22) /* LSB First. 0=MSB first transfer */
#define SPICR_MASTER_INHIBIT BBIT(23) /* Master Transaction Inhibit */
#define SPICR_SLAVE_SELECT BBIT(24) /* Manual Slave Select Assert Enable */
#define SPICR_RX_FIFO_RESET BBIT(25) /* Receive FIFO Reset */
#define SPICR_TX_FIFO_RESET BBIT(26) /* Transmit FIFO Reset */
#define SPICR_CPHA BBIT(27) /* Clock Phase */
#define SPICR_CPOL BBIT(28) /* Clock Polarity 0=Active High */
#define SPICR_MASTER BBIT(29) /* Master Enable */
#define SPICR_SPE BBIT(30) /* SPI System Enable */
#define SPICR_LOOP BBIT(31) /* Local Loopback Mode */
#define SPICR_START_TRANSFER (SPICR_CPHA | SPICR_CPOL | \
SPICR_MASTER | SPICR_SPE)
#define SPICR_READY_TRANSFER (SPICR_MASTER_INHIBIT | SPICR_START_TRANSFER)
#define SPISR 0x64 /* SPI Status Register */
#define SPISR_SLAVE_MODE_SEL BBIT(26) /* Slave Mode Select Flag */
#define SPISR_MODF BBIT(27) /* Mode-Fault Error Flag */
#define SPISR_TX_FULL BBIT(28) /* Transmit FIFO Full */
#define SPISR_TX_EMPTY BBIT(29) /* Transmit FIFO Empty */
#define SPISR_RX_FULL BBIT(30) /* Receive FIFO Full */
#define SPISR_RX_EMPTY BBIT(31) /* Receive FIFO Empty */
#define SPIDTR 0x68 /* SPI Data Transmit Register */
#define SPIDRR 0x6c /* SPI Data Receive Register */
#define SPISSR 0x70 /* SPI Slave Select Register */
#undef SUCCESS
#define SUCCESS 0
struct wcxb_spi_master {
struct device *parent;
struct list_head message_queue;
spinlock_t lock;
void __iomem *base;
struct wcxb_spi_message *cur_msg;
struct wcxb_spi_transfer *cur_transfer;
u16 bytes_left;
u16 bytes_in_fifo;
const u8 *cur_tx_byte;
u8 *cur_rx_byte;
u16 auto_cs:1;
};
static inline void _wcxb_assert_chip_select(struct wcxb_spi_master *master,
unsigned int cs)
{
const int cs_mask = ~(1UL << cs);
iowrite32be(cs_mask, master->base + SPISSR);
ioread32be(master->base + SPISSR);
}
static inline void _wcxb_clear_chip_select(struct wcxb_spi_master *master)
{
iowrite32be(~(0), master->base + SPISSR);
ioread32(master->base + SPISSR);
}
static inline void wcxb_spi_reset_controller(struct wcxb_spi_master *master)
{
u32 spicr = SPICR_READY_TRANSFER;
spicr |= (master->auto_cs) ? 0 : SPICR_SLAVE_SELECT;
iowrite32be(SPISRR_RESET, master->base + SPISRR);
iowrite32be(spicr, master->base + SPICR);
iowrite32be(0xffffffff, master->base + SPISSR);
}
struct wcxb_spi_master *wcxb_spi_master_create(struct device *parent,
void __iomem *membase,
bool auto_cs)
{
struct wcxb_spi_master *master = NULL;
master = kzalloc(sizeof(struct wcxb_spi_master), GFP_KERNEL);
if (!master)
goto error_exit;
spin_lock_init(&master->lock);
INIT_LIST_HEAD(&master->message_queue);
master->base = membase;
master->parent = parent;
master->auto_cs = (auto_cs) ? 1 : 0;
wcxb_spi_reset_controller(master);
return master;
error_exit:
kfree(master);
return NULL;
}
void wcxb_spi_master_destroy(struct wcxb_spi_master *master)
{
struct wcxb_spi_message *m;
if (!master)
return;
while (!list_empty(&master->message_queue)) {
m = list_first_entry(&master->message_queue,
struct wcxb_spi_message, node);
list_del(&m->node);
if (m->complete)
m->complete(m->arg);
}
kfree(master);
return;
}
static inline bool is_txfifo_empty(const struct wcxb_spi_master *master)
{
return ((ioread32(master->base + SPISR) &
cpu_to_be32(SPISR_TX_EMPTY)) > 0);
}
static const u8 DUMMY_TX = 0xff;
static u8 DUMMY_RX;
static void _wcxb_spi_transfer_to_fifo(struct wcxb_spi_master *master)
{
const unsigned int FIFO_SIZE = 16;
u32 spicr;
while (master->bytes_left && master->bytes_in_fifo < FIFO_SIZE) {
iowrite32be(*master->cur_tx_byte, master->base + SPIDTR);
master->bytes_in_fifo++;
master->bytes_left--;
if (&DUMMY_TX != master->cur_tx_byte)
master->cur_tx_byte++;
}
spicr = (master->auto_cs) ? SPICR_START_TRANSFER :
SPICR_START_TRANSFER | SPICR_SLAVE_SELECT;
iowrite32be(spicr, master->base + SPICR);
}
static void _wcxb_spi_transfer_from_fifo(struct wcxb_spi_master *master)
{
u32 spicr;
while (master->bytes_in_fifo) {
*master->cur_rx_byte = ioread32be(master->base + SPIDRR);
if (&DUMMY_RX != master->cur_rx_byte)
master->cur_rx_byte++;
--master->bytes_in_fifo;
}
spicr = SPICR_START_TRANSFER;
spicr |= (master->auto_cs) ? 0 : SPICR_SLAVE_SELECT;
iowrite32be(spicr | SPICR_MASTER_INHIBIT, master->base + SPICR);
}
static void _wcxb_spi_start_transfer(struct wcxb_spi_master *master,
struct wcxb_spi_transfer *t)
{
#ifdef DEBUG
if (!t || !master || (!t->tx_buf && !t->rx_buf) ||
master->cur_transfer) {
WARN_ON(1);
return;
}
#endif
master->cur_transfer = t;
master->bytes_left = t->len;
master->cur_tx_byte = (t->tx_buf) ?: &DUMMY_TX;
master->cur_rx_byte = (t->rx_buf) ?: &DUMMY_RX;
_wcxb_spi_transfer_to_fifo(master);
}
/**
* _wcxb_spi_start_message - Start a new message transferring.
*
* Must be called with master->lock held.
*
*/
static int _wcxb_spi_start_message(struct wcxb_spi_master *master,
struct wcxb_spi_message *message)
{
struct wcxb_spi_transfer *t;
if (master->cur_msg) {
/* There is already a message in progress. Queue for later. */
list_add_tail(&message->node, &master->message_queue);
return 0;
}
if (!message->spi) {
dev_dbg(master->parent,
"Queueing message without SPI device specified?\n");
return -EINVAL;
};
master->cur_msg = message;
_wcxb_assert_chip_select(master, message->spi->chip_select);
t = list_first_entry(&message->transfers,
struct wcxb_spi_transfer, node);
_wcxb_spi_start_transfer(master, t);
return 0;
}
/**
* wcxb_spi_complete_message - Complete the current message.
*
* Called after all transfers in current message have been completed. This will
* complete the current message and start the next queued message if there are
* any.
*
* Must be called with the master->lock held.
*
*/
static void _wcxb_spi_complete_cur_msg(struct wcxb_spi_master *master)
{
struct wcxb_spi_message *message;
if (!master->cur_msg)
return;
message = master->cur_msg;
message->status = SUCCESS;
_wcxb_clear_chip_select(master);
master->cur_msg = NULL;
if (!list_empty(&master->message_queue)) {
message = list_first_entry(&master->message_queue,
struct wcxb_spi_message, node);
list_del(&message->node);
_wcxb_spi_start_message(master, message);
}
return;
}
static inline bool
_wcxb_spi_is_last_transfer(const struct wcxb_spi_transfer *t,
const struct wcxb_spi_message *message)
{
return t->node.next == &message->transfers;
}
static inline struct wcxb_spi_transfer *
_wcxb_spi_next_transfer(struct wcxb_spi_transfer *t)
{
return list_entry(t->node.next, struct wcxb_spi_transfer, node);
}
/**
* wcxb_spi_handle_interrupt - Drives the transfers forward.
*
* Doesn't necessarily need to be called in the context of a real interrupt, but
* should be called with interrupts disabled on the local CPU.
*
*/
void wcxb_spi_handle_interrupt(struct wcxb_spi_master *master)
{
struct wcxb_spi_message *msg;
struct wcxb_spi_transfer *t;
void (*complete)(void *arg) = NULL;
unsigned long flags;
/* Check if we're not in the middle of a transfer, or not finished with
* a part of one. */
spin_lock_irqsave(&master->lock, flags);
t = master->cur_transfer;
msg = master->cur_msg;
if (!msg || !is_txfifo_empty(master))
goto done;
#ifdef DEBUG
if (!t) {
dev_dbg(master->parent,
"No current transfer in %s\n", __func__);
goto done;
}
#endif
/* First read any data out of the receive FIFO into the current
* transfer. */
_wcxb_spi_transfer_from_fifo(master);
if (master->bytes_left) {
/* The current transfer isn't finished. */
_wcxb_spi_transfer_to_fifo(master);
goto done;
}
/* The current transfer is finished. Check for another transfer in this
* message or complete it and look for another message to start. */
master->cur_transfer = NULL;
if (_wcxb_spi_is_last_transfer(t, msg)) {
complete = msg->complete;
_wcxb_spi_complete_cur_msg(master);
} else {
t = _wcxb_spi_next_transfer(t);
_wcxb_spi_start_transfer(master, t);
}
done:
spin_unlock_irqrestore(&master->lock, flags);
/* Do not call the complete call back under the bus lock. */
if (complete)
complete(msg->arg);
return;
}
int wcxb_spi_async(struct wcxb_spi_device *spi,
struct wcxb_spi_message *message)
{
int res;
unsigned long flags;
WARN_ON(!spi || !message || !spi->master);
if (list_empty(&message->transfers)) {
/* No transfers in this message? */
if (message->complete)
message->complete(message->arg);
message->status = -EINVAL;
return 0;
}
message->status = -EINPROGRESS;
message->spi = spi;
spin_lock_irqsave(&spi->master->lock, flags);
res = _wcxb_spi_start_message(spi->master, message);
spin_unlock_irqrestore(&spi->master->lock, flags);
return res;
}
static void wcxb_spi_complete_message(void *arg)
{
complete((struct completion *)arg);
}
int wcxb_spi_sync(struct wcxb_spi_device *spi, struct wcxb_spi_message *message)
{
DECLARE_COMPLETION_ONSTACK(done);
WARN_ON(!spi || !spi->master);
message->complete = wcxb_spi_complete_message;
message->arg = &done;
wcxb_spi_async(spi, message);
/* TODO: There has got to be a better way to do this. */
while (!try_wait_for_completion(&done)) {
wcxb_spi_handle_interrupt(spi->master);
cpu_relax();
}
return message->status;
}

116
drivers/dahdi/wcxb_spi.h Normal file
View File

@@ -0,0 +1,116 @@
/*
* wcxb SPI library
*
* Copyright (C) 2013 Digium, Inc.
*
* All rights reserved.
*
*/
/*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2 as published by the
* Free Software Foundation. See the LICENSE file included with
* this program for more details.
*/
#ifndef __WCXB_SPI_H
#define __WCXB_SPI_H
#include <linux/spi/spi.h>
#include <stdbool.h>
struct wcxb_spi_transfer {
const void *tx_buf;
void *rx_buf;
u32 len:16;
u16 delay_usecs;
struct list_head node;
};
struct wcxb_spi_message {
struct list_head transfers;
struct list_head node;
struct wcxb_spi_device *spi;
void (*complete)(void *arg);
void *arg;
int status;
};
struct wcxb_spi_master;
struct wcxb_spi_device {
struct wcxb_spi_master *master;
u16 chip_select;
};
extern struct wcxb_spi_master *wcxb_spi_master_create(struct device *parent,
void __iomem *base, bool auto_cs);
extern void wcxb_spi_master_destroy(struct wcxb_spi_master *master);
extern int wcxb_spi_sync(struct wcxb_spi_device *spi,
struct wcxb_spi_message *message);
extern int wcxb_spi_async(struct wcxb_spi_device *spi,
struct wcxb_spi_message *message);
extern void wcxb_spi_handle_interrupt(struct wcxb_spi_master *master);
static inline struct wcxb_spi_device *
wcxb_spi_device_create(struct wcxb_spi_master *master, u16 chip_select)
{
struct wcxb_spi_device *spi = kzalloc(sizeof(*spi), GFP_KERNEL);
if (!spi)
return NULL;
spi->master = master;
spi->chip_select = chip_select;
return spi;
}
static inline void wcxb_spi_device_destroy(struct wcxb_spi_device *spi)
{
kfree(spi);
}
static inline void wcxb_spi_message_init(struct wcxb_spi_message *m)
{
memset(m, 0, sizeof(*m));
INIT_LIST_HEAD(&m->transfers);
}
static inline void wcxb_spi_message_add_tail(struct wcxb_spi_transfer *t,
struct wcxb_spi_message *m)
{
list_add_tail(&t->node, &m->transfers);
}
static inline int
wcxb_spi_write(struct wcxb_spi_device *spi, const void *buffer, size_t len)
{
struct wcxb_spi_transfer t = {
.tx_buf = buffer,
.len = len,
};
struct wcxb_spi_message m;
wcxb_spi_message_init(&m);
wcxb_spi_message_add_tail(&t, &m);
return wcxb_spi_sync(spi, &m);
}
static inline int
wcxb_spi_read(struct wcxb_spi_device *spi, void *buffer, size_t len)
{
struct wcxb_spi_transfer t = {
.rx_buf = buffer,
.len = len,
};
struct wcxb_spi_message m;
wcxb_spi_message_init(&m);
wcxb_spi_message_add_tail(&t, &m);
return wcxb_spi_sync(spi, &m);
}
#endif

View File

@@ -654,6 +654,95 @@ static void __do_mute_dtmf(xpd_t *xpd, int pos, bool muteit)
CALL_PHONE_METHOD(card_pcm_recompute, xpd, priv->search_fsk_pattern);
}
struct ring_reg_param {
int is_indirect;
int regno;
uint8_t h_val;
uint8_t l_val;
};
enum ring_types {
RING_TYPE_NEON = 0,
RING_TYPE_TRAPEZ,
RING_TYPE_NORMAL,
};
struct byte_pair {
uint8_t h_val;
uint8_t l_val;
};
struct ring_reg_params {
const int is_indirect;
const int regno;
struct byte_pair values[1 + RING_TYPE_NORMAL - RING_TYPE_NEON];
};
#define REG_ENTRY(di, reg, vh1, vl1, vh2, vl2, vh3, vl3) \
{ (di), (reg), .values = { \
[RING_TYPE_NEON] = { .h_val = (vh1), .l_val = (vl1) }, \
[RING_TYPE_TRAPEZ] = { .h_val = (vh2), .l_val = (vl2) }, \
[RING_TYPE_NORMAL] = { .h_val = (vh3), .l_val = (vl3) }, \
}, \
}
static struct ring_reg_params ring_parameters[] = {
/* INDIR REG NEON TRAPEZ NORMAL */
REG_ENTRY(1, 0x16, 0xE8, 0x03, 0xC8, 0x00, 0x00, 0x00),
REG_ENTRY(1, 0x15, 0xEF, 0x7B, 0xAB, 0x5E, 0x77, 0x01),
REG_ENTRY(1, 0x14, 0x9F, 0x00, 0x8C, 0x01, 0xFD, 0x7E),
REG_ENTRY(0, 0x22, 0x00, 0x19, 0x00, 0x01, 0x00, 0x00),
REG_ENTRY(0, 0x30, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00),
REG_ENTRY(0, 0x31, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00),
REG_ENTRY(0, 0x32, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00),
REG_ENTRY(0, 0x33, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00),
REG_ENTRY(1, 0x1D, 0x00, 0x46, 0x00, 0x36, 0x00, 0x36),
};
static int send_ring_parameters(xbus_t *xbus, xpd_t *xpd, int pos,
enum ring_types rtype)
{
const struct ring_reg_params *p;
const struct byte_pair *v;
int ret = 0;
int i;
if (rtype < RING_TYPE_NEON || rtype > RING_TYPE_NORMAL)
return -EINVAL;
for (i = 0; i < ARRAY_SIZE(ring_parameters); i++) {
p = &ring_parameters[i];
v = &(p->values[rtype]);
if (p->is_indirect) {
LINE_DBG(REGS, xpd, pos,
"[%d] 0x%02X: I 0x%02X 0x%02X\n",
i, p->regno, v->h_val, v->l_val);
ret = SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE,
p->regno, v->h_val, v->l_val);
if (ret < 0) {
LINE_ERR(xpd, pos,
"Failed: 0x%02X: I 0x%02X, 0x%02X\n",
p->regno, v->h_val, v->l_val);
break;
}
} else {
LINE_DBG(REGS, xpd, pos, "[%d] 0x%02X: D 0x%02X\n",
i, p->regno, v->l_val);
ret = SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE,
p->regno, v->l_val);
if (ret < 0) {
LINE_ERR(xpd, pos,
"Failed: 0x%02X: D 0x%02X\n",
p->regno, v->l_val);
break;
}
}
}
return ret;
}
static int set_vm_led_mode(xbus_t *xbus, xpd_t *xpd, int pos,
unsigned int msg_waiting)
{
@@ -667,81 +756,15 @@ static int set_vm_led_mode(xbus_t *xbus, xpd_t *xpd, int pos,
/* A write to register 0x40 will now turn on/off the VM led */
LINE_DBG(SIGNAL, xpd, pos, "NEON\n");
BIT_SET(priv->neon_blinking, pos);
ret +=
SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x16,
0xE8, 0x03);
ret +=
SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x15,
0xEF, 0x7B);
ret +=
SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x14,
0x9F, 0x00);
ret +=
SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x22, 0x19);
ret +=
SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x30, 0xE0);
ret +=
SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x31, 0x01);
ret +=
SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x32, 0xF0);
ret +=
SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x33, 0x05);
ret +=
SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x1D,
0x00, 0x46);
ret = send_ring_parameters(xbus, xpd, pos, RING_TYPE_NEON);
} else if (ring_trapez) {
LINE_DBG(SIGNAL, xpd, pos, "RINGER: Trapez ring\n");
ret +=
SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x16,
0xC8, 0x00);
ret +=
SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x15,
0xAB, 0x5E);
ret +=
SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x14,
0x8C, 0x01);
ret +=
SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x22, 0x01);
ret +=
SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x4A, 0x34);
ret +=
SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x30, 0x00);
ret +=
SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x31, 0x00);
ret +=
SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x32, 0x00);
ret +=
SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x33, 0x00);
ret +=
SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x1D,
0x00, 0x36);
ret = send_ring_parameters(xbus, xpd, pos, RING_TYPE_TRAPEZ);
} else {
/* A write to register 0x40 will now turn on/off the ringer */
LINE_DBG(SIGNAL, xpd, pos, "RINGER\n");
BIT_CLR(priv->neon_blinking, pos);
ret += SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE,
0x16, 0x00, 0x00);
ret += SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE,
0x15, 0x77, 0x01);
ret += SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE,
0x14, 0xFD, 0x7E);
ret += SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE,
0x22, 0x00);
ret += SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE,
0x30, 0x00);
ret += SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE,
0x31, 0x00);
ret += SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE,
0x32, 0x00);
ret += SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE,
0x33, 0x00);
/* High Vbat~ -82V[Dc] */
ret += SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE,
0x4A, 0x34);
ret += SLIC_INDIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE,
0x1D, 0x00, 0x36);
ret = send_ring_parameters(xbus, xpd, pos, RING_TYPE_NORMAL);
}
return (ret ? -EPROTO : 0);
}
@@ -1838,9 +1861,134 @@ static const struct file_operations proc_xpd_metering_ops = {
#endif
#endif
static DEVICE_ATTR_READER(fxs_ring_registers_show, dev, buf)
{
xpd_t *xpd;
struct FXS_priv_data *priv;
unsigned long flags;
const struct ring_reg_params *p;
const struct byte_pair *v;
enum ring_types rtype;
int len = 0;
int i;
BUG_ON(!dev);
xpd = dev_to_xpd(dev);
if (!xpd)
return -ENODEV;
priv = xpd->priv;
BUG_ON(!priv);
spin_lock_irqsave(&xpd->lock, flags);
len += sprintf(buf + len, "# Reg#: D/I\tNEON \tTRAPEZ \tNORMAL \n");
for (i = 0; i < ARRAY_SIZE(ring_parameters); i++) {
p = &ring_parameters[i];
len += sprintf(buf + len, "[%d] 0x%02X: %c",
i, p->regno, (p->is_indirect) ? 'I' : 'D');
for (rtype = RING_TYPE_NEON; rtype <= RING_TYPE_NORMAL; rtype++) {
v = &(p->values[rtype]);
if (p->is_indirect)
len += sprintf(buf + len, "\t0x%02X 0x%02X",
v->h_val, v->l_val);
else
len += sprintf(buf + len, "\t0x%02X ----",
v->l_val);
}
len += sprintf(buf + len, "\n");
}
spin_unlock_irqrestore(&xpd->lock, flags);
return len;
}
static DEVICE_ATTR_WRITER(fxs_ring_registers_store, dev, buf, count)
{
xpd_t *xpd;
struct FXS_priv_data *priv;
unsigned long flags;
char rtype_name[MAX_PROC_WRITE];
enum ring_types rtype;
struct ring_reg_params *params;
struct byte_pair *v;
int regno;
int h_val;
int l_val;
int ret;
int i;
BUG_ON(!dev);
xpd = dev_to_xpd(dev);
if (!xpd)
return -ENODEV;
priv = xpd->priv;
BUG_ON(!priv);
ret = sscanf(buf, "%10s %X %X %X\n",
rtype_name, &regno, &h_val, &l_val);
if (ret < 3 || ret > 4) {
XPD_ERR(xpd, "Bad input: '%s'\n", buf);
XPD_ERR(xpd, "# Correct input\n");
XPD_ERR(xpd, "{NEON|TRAPEZ|NORMAL} <regno> <byte> [<byte>]\n");
goto invalid_input;
}
if (strcasecmp("NEON", rtype_name) == 0)
rtype = RING_TYPE_NEON;
else if (strcasecmp("TRAPEZ", rtype_name) == 0)
rtype = RING_TYPE_TRAPEZ;
else if (strcasecmp("NORMAL", rtype_name) == 0)
rtype = RING_TYPE_NORMAL;
else {
XPD_ERR(xpd, "Unknown ring type '%s' (NEON/TRAPEZ/NORMAL)\n",
rtype_name);
goto invalid_input;
}
params = NULL;
for (i = 0; i < ARRAY_SIZE(ring_parameters); i++) {
if (ring_parameters[i].regno == regno) {
params = &ring_parameters[i];
break;
}
}
if (!params) {
XPD_ERR(xpd, "Bad register 0x%X\n", regno);
goto invalid_input;
}
if (params->is_indirect) {
if (ret != 4) {
XPD_ERR(xpd,
"Missing low-byte (0x%X is indirect register)\n",
regno);
goto invalid_input;
}
XPD_DBG(SIGNAL, xpd, "%s Indirect 0x%X <=== 0x%X 0x%X\n",
rtype_name, regno, h_val, l_val);
} else {
if (ret != 3) {
XPD_ERR(xpd,
"Should give exactly one value (0x%X is direct register)\n",
regno);
goto invalid_input;
}
l_val = h_val;
h_val = 0;
XPD_DBG(SIGNAL, xpd, "%s Direct 0x%X <=== 0x%X\n",
rtype_name, regno, h_val);
}
spin_lock_irqsave(&xpd->lock, flags);
v = &(params->values[rtype]);
v->h_val = h_val;
v->l_val = l_val;
spin_unlock_irqrestore(&xpd->lock, flags);
return count;
invalid_input:
return -EINVAL;
}
static DEVICE_ATTR(fxs_ring_registers, S_IRUGO | S_IWUSR,
fxs_ring_registers_show,
fxs_ring_registers_store);
static int fxs_xpd_probe(struct device *dev)
{
xpd_t *xpd;
int ret;
xpd = dev_to_xpd(dev);
/* Is it our device? */
@@ -1850,7 +1998,15 @@ static int fxs_xpd_probe(struct device *dev)
return -EINVAL;
}
XPD_DBG(DEVICES, xpd, "SYSFS\n");
ret = device_create_file(dev, &dev_attr_fxs_ring_registers);
if (ret) {
XPD_ERR(xpd, "%s: device_create_file(fxs_ring_registers) failed: %d\n",
__func__, ret);
goto fail_fxs_ring_registers;
}
return 0;
fail_fxs_ring_registers:
return ret;
}
static int fxs_xpd_remove(struct device *dev)
@@ -1859,6 +2015,7 @@ static int fxs_xpd_remove(struct device *dev)
xpd = dev_to_xpd(dev);
XPD_DBG(DEVICES, xpd, "SYSFS\n");
device_remove_file(dev, &dev_attr_fxs_ring_registers);
return 0;
}

View File

@@ -511,6 +511,11 @@ HANDLER_DEF(GLOBAL, AB_DESCRIPTION)
ret = -EPROTO;
goto proto_err;
}
if (units[0].addr.unit != 0 || units[0].addr.subunit != 0) {
XBUS_NOTICE(xbus, "No first module. Astribank unusable.\n");
ret = -EPROTO;
goto proto_err;
}
if (!xbus_setstate(xbus, XBUS_STATE_RECVD_DESC)) {
ret = -EPROTO;
goto proto_err;
@@ -568,6 +573,7 @@ HANDLER_DEF(GLOBAL, AB_DESCRIPTION)
}
goto out;
proto_err:
xbus_setstate(xbus, XBUS_STATE_FAIL);
dump_packet("AB_DESCRIPTION", pack, DBG_ANY);
out:
return ret;

View File

@@ -524,9 +524,12 @@ static void PRI_card_pcm_recompute(xpd_t *xpd, xpp_line_t pcm_mask)
//XPD_DBG(SIGNAL, xpd, "pcm_mask=0x%X\n", pcm_mask);
/* Add/remove all the trivial cases */
pcm_mask |= PHONEDEV(xpd).offhook_state;
if (priv->is_cas)
pcm_mask |= BITMASK(PHONEDEV(xpd).channels);
for_each_line(xpd, i)
if (IS_SET(pcm_mask, i))
line_count++;
else
if (priv->is_cas) {
if (priv->pri_protocol == PRI_PROTO_E1) {
/* CAS: Don't send PCM to D-Channel */
@@ -611,7 +614,7 @@ static int set_pri_proto(xpd_t *xpd, enum pri_protocol set_proto)
}
priv->pri_protocol = set_proto;
priv->is_cas = -1;
phonedev->channels = pri_num_channels(set_proto);
phonedev_alloc_channels(xpd, pri_num_channels(set_proto));
phonedev->offhook_state = BITMASK(phonedev->channels);
CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
priv->deflaw = deflaw;
@@ -1082,6 +1085,7 @@ static int pri_set_spantype(struct dahdi_span *span, enum spantypes spantype)
struct phonedev *phonedev = container_of(span, struct phonedev, span);
xpd_t *xpd = container_of(phonedev, struct xpd, phonedev);
enum pri_protocol set_proto = PRI_PROTO_0;
int ret;
XPD_INFO(xpd, "%s: %s\n", __func__, dahdi_spantype2str(spantype));
switch (spantype) {
@@ -1099,7 +1103,13 @@ static int pri_set_spantype(struct dahdi_span *span, enum spantypes spantype)
__func__, dahdi_spantype2str(spantype));
return -EINVAL;
}
return set_pri_proto(xpd, set_proto);
ret = set_pri_proto(xpd, set_proto);
if (ret < 0) {
XPD_ERR(xpd, "%s: set_pri_proto failed\n", __func__);
return ret;
}
dahdi_init_span(span);
return 0;
}
static int PRI_card_open(xpd_t *xpd, lineno_t pos)
@@ -1224,7 +1234,7 @@ static int pri_chanconfig(struct file *file, struct dahdi_chan *chan,
if (priv->pri_protocol != PRI_PROTO_E1 && priv->is_cas != 0)
set_mode_cas(xpd, 0);
} else {
if (chan->channo == 1) {
if (chan->chanpos == 1) {
XPD_DBG(GENERAL, xpd,
"channel %d (%s) marked a not DChan\n",
chan->channo, chan->name);
@@ -1929,7 +1939,8 @@ static void PRI_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack)
dchan_state(xpd, 0);
}
if (IS_SET(physical_mask, i)) {
r = XPD_CHAN(xpd, logical_chan)->readchunk;
struct dahdi_chan *chan = XPD_CHAN(xpd, logical_chan);
r = chan->readchunk;
// memset((u_char *)r, 0x5A, DAHDI_CHUNKSIZE); // DEBUG
memcpy((u_char *)r, pcm, DAHDI_CHUNKSIZE);
pcm += DAHDI_CHUNKSIZE;

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
USB_FW = USB_FW.hex USB_FW.201.hex USB_RECOV.hex
FPGA_FW = FPGA_FXS.hex FPGA_1141.hex FPGA_1151.hex FPGA_1161.hex \
FPGA_1161.201.hex
FPGA_1161.201.hex FPGA_1161.202.hex
PIC_FW = PIC_TYPE_1.hex PIC_TYPE_2.hex PIC_TYPE_3.hex PIC_TYPE_4.hex
OCT_FW = $(wildcard OCT6104E-256D.ima)
FIRMWARES = $(USB_FW) $(FPGA_FW) $(PIC_FW) $(OCT_FW)
@@ -20,4 +20,7 @@ install:
mkdir -p $(TARGET)
install $(SCRIPTS) $(TARGET)/
install -m 644 ../XppConfig.pm $(FIRMWARES) $(TARGET)/
if [ ! -r $(TARGET)/USB_FW.202.hex ]; then \
ln -s USB_FW.201.hex $(TARGET)/USB_FW.202.hex;\
fi

View File

@@ -0,0 +1 @@
USB_FW.201.hex

View File

@@ -59,6 +59,7 @@ my %settings;
$settings{debug} = 0;
$settings{fxs_skip_calib} = 0;
my $chipregs;
my $ring_registers;
sub logit {
print STDERR "$unit_id: @_\n";
@@ -104,6 +105,10 @@ if (-t STDERR) {
logit "OLD DRIVER: does not use /sys chipregs. Falling back to /proc"
if -f $chipregs;
}
$ring_registers = sprintf "/sys/bus/xpds/devices/%02d:%1d:0/fxs_ring_registers",
$ENV{XBUS_NUMBER}, $ENV{UNIT_NUMBER};
logit "OLD DRIVER: missing '$ring_registers' -- fallback to hard-coded defaults"
unless -f $ring_registers;
}
sub set_output() {
@@ -147,6 +152,16 @@ sub write_to_slic_file($) {
}
sub write_to_ring_register($) {
my $write_str = shift;
open(SLICS,">$ring_registers") or
die("Failed writing to ring_registers file $ring_registers");
print SLICS $write_str;
close(SLICS) or die "Failed writing '$write_str' to '$ring_registers': $!";
main::mysleep(0.001);
}
sub read_reg($$$) {
my $read_slic = shift;
my $read_reg = shift;
@@ -298,7 +313,7 @@ sub init_early_direct_regs() {
return write_to_slic_file("#
* WD 08 00 # Audio Path Loopback Control
* WD 6C 01
* WD 4A 3F # High Battery Voltage
* WD 4A 34 # High Battery Voltage
* WD 4B $lbv # Low Battery Voltage
* WD 49 $vcm # Common Mode Voltage (VCM)
* WD 40 00 # Line Feed Control
@@ -442,6 +457,10 @@ sub check_slics() {
return @slics;
}
sub overwrite_ring_registers() {
write_to_ring_register("NEON 0x33 0x12");
}
package main;
main::debug "Starting '$0'";
@@ -470,6 +489,7 @@ while(<DATA>) {
print "$_\n";
}
close REG;
FXS::overwrite_ring_registers();
main::debug "Ending '$0'";
close STDERR;

View File

@@ -4,6 +4,7 @@
#include <linux/proc_fs.h>
#include <linux/interrupt.h>
#include <linux/firmware.h>
#include <linux/slab.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/blackfin.h>

View File

@@ -24,8 +24,10 @@
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/mutex.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#ifdef PROTOCOL_DEBUG
#include <linux/ctype.h>
#endif
@@ -59,8 +61,8 @@ static DEF_PARM(uint, command_queue_length, 1500, 0444,
static DEF_PARM(uint, poll_timeout, 1000, 0644,
"Timeout (in jiffies) waiting for units to reply");
static DEF_PARM_BOOL(rx_tasklet, 0, 0644, "Use receive tasklets");
static DEF_PARM_BOOL(dahdi_autoreg, 0, 0644,
"Register devices automatically (1) or not (0)");
static DEF_PARM_BOOL(dahdi_autoreg, 0, 0444,
"Register devices automatically (1) or not (0). UNUSED.");
#ifdef CONFIG_PROC_FS
static const struct file_operations xbus_read_proc_ops;
@@ -78,8 +80,14 @@ static struct proc_dir_entry *proc_xbuses;
static struct xbus_desc {
xbus_t *xbus;
int shutting_down;
} xbuses_array[MAX_BUSES];
static int xbus_is_shutting_down(int num)
{
return xbuses_array[num].shutting_down;
}
static xbus_t *xbus_byhwid(const char *hwid)
{
int i;
@@ -147,6 +155,8 @@ static void init_xbus(uint num, xbus_t *xbus)
BUG_ON(num >= ARRAY_SIZE(xbuses_array));
desc = &xbuses_array[num];
desc->xbus = xbus;
if (xbus)
desc->shutting_down = 0;
}
xbus_t *xbus_num(uint num)
@@ -186,9 +196,12 @@ static void finalize_xbuses_array(void)
static void xbus_destroy(struct kref *kref)
{
xbus_t *xbus;
int num;
xbus = kref_to_xbus(kref);
XBUS_NOTICE(xbus, "%s\n", __func__);
XBUS_DBG(DEVICES, xbus, "%s\n", __func__);
num = xbus->num;
xbuses_array[num].shutting_down = 1;
xbus_sysfs_remove(xbus);
}
@@ -197,6 +210,11 @@ xbus_t *get_xbus(const char *msg, uint num)
unsigned long flags;
xbus_t *xbus;
if (xbus_is_shutting_down(num)) {
DBG(DEVICES, "%s(%s): XBUS-%d: shutting down\n", __func__,
msg, num);
return NULL;
}
spin_lock_irqsave(&xbuses_lock, flags);
xbus = xbus_num(num);
if (xbus != NULL) {
@@ -210,6 +228,13 @@ xbus_t *get_xbus(const char *msg, uint num)
void put_xbus(const char *msg, xbus_t *xbus)
{
if (xbus_is_shutting_down(xbus->num)) {
if (!refcount_xbus(xbus)) {
DBG(DEVICES, "%s(%s): XBUS-%d: shutting down\n",
__func__, msg, xbus->num);
return;
}
}
XBUS_DBG(DEVICES, xbus, "%s: refcount_xbus=%d\n", msg,
refcount_xbus(xbus));
kref_put(&xbus->kref, xbus_destroy);
@@ -559,6 +584,14 @@ static void receive_tasklet_func(unsigned long data)
void xbus_receive_xframe(xbus_t *xbus, xframe_t *xframe)
{
BUG_ON(!xbus);
if (xbus_is_shutting_down(xbus->num)) {
static int rate_limit;
if ((rate_limit++ % 1000) == 0)
XBUS_NOTICE(xbus, "%s: during shutdown (%d)\n",
__func__, rate_limit);
return;
}
if (rx_tasklet) {
xframe_enqueue_recv(xbus, xframe);
} else {
@@ -937,6 +970,8 @@ static void xbus_free_ddev(xbus_t *xbus)
xbus->ddev = NULL;
}
static DEFINE_MUTEX(dahdi_registration_mutex);
int xbus_register_dahdi_device(xbus_t *xbus)
{
int i;
@@ -944,12 +979,21 @@ int xbus_register_dahdi_device(xbus_t *xbus)
int ret;
XBUS_DBG(DEVICES, xbus, "Entering %s\n", __func__);
if (xbus_is_registered(xbus)) {
XBUS_ERR(xbus, "Already registered to DAHDI\n");
WARN_ON(1);
ret = -EINVAL;
ret = mutex_lock_interruptible(&dahdi_registration_mutex);
if (ret < 0) {
XBUS_ERR(xbus, "dahdi_registration_mutex already taken\n");
goto err;
}
if (xbus_is_registered(xbus)) {
/*
* Ignore duplicate registrations (from dahdi_registration)
* Until we completely migrate to dahdi_autoreg=1 and
* hotplug-based span-assignments
*/
XBUS_DBG(DEVICES, xbus, "Already registered to DAHDI\n");
ret = 0;
goto out;
}
xbus->ddev = dahdi_create_device();
if (!xbus->ddev) {
ret = -ENOMEM;
@@ -1008,31 +1052,49 @@ int xbus_register_dahdi_device(xbus_t *xbus)
xpd_dahdi_postregister(xpd);
}
}
return 0;
ret = 0;
out:
mutex_unlock(&dahdi_registration_mutex);
return ret;
err:
xbus_free_ddev(xbus);
return ret;
goto out;
}
void xbus_unregister_dahdi_device(xbus_t *xbus)
{
int i;
int ret;
XBUS_NOTICE(xbus, "%s\n", __func__);
XBUS_DBG(DEVICES, xbus, "%s\n", __func__);
ret = mutex_lock_interruptible(&dahdi_registration_mutex);
if (ret < 0) {
XBUS_ERR(xbus, "dahdi_registration_mutex already taken\n");
return;
}
if (!xbus_is_registered(xbus)) {
/*
* Ignore duplicate unregistrations
*/
XBUS_DBG(DEVICES, xbus, "Already unregistered to DAHDI\n");
goto err;
}
for (i = 0; i < MAX_XPDS; i++) {
xpd_t *xpd = xpd_of(xbus, i);
xpd_dahdi_preunregister(xpd);
}
if (xbus->ddev) {
dahdi_unregister_device(xbus->ddev);
XBUS_NOTICE(xbus, "%s: finished dahdi_unregister_device()\n",
__func__);
XBUS_DBG(DEVICES, xbus,
"%s: finished dahdi_unregister_device()\n", __func__);
xbus_free_ddev(xbus);
}
for (i = 0; i < MAX_XPDS; i++) {
xpd_t *xpd = xpd_of(xbus, i);
xpd_dahdi_postunregister(xpd);
}
err:
mutex_unlock(&dahdi_registration_mutex);
}
/*
@@ -1100,7 +1162,7 @@ void xbus_populate(void *data)
*/
xbus_request_sync(xbus, SYNC_MODE_PLL);
elect_syncer("xbus_populate(end)"); /* FIXME: try to do it later */
if (dahdi_autoreg)
if (!dahdi_get_auto_assign_spans())
xbus_register_dahdi_device(xbus);
out:
XBUS_DBG(DEVICES, xbus, "Leaving\n");
@@ -1158,8 +1220,7 @@ static void worker_reset(xbus_t *xbus)
name = (xbus) ? xbus->busname : "detached";
DBG(DEVICES, "%s\n", name);
if (!worker->xpds_init_done) {
NOTICE("%s: worker(%s)->xpds_init_done=%d\n", __func__, name,
worker->xpds_init_done);
XBUS_NOTICE(xbus, "XPDS initialization was not finished\n");
}
spin_lock_irqsave(&worker->worker_lock, flags);
list_for_each_safe(card, next_card, &worker->card_list) {
@@ -1177,13 +1238,15 @@ static void worker_reset(xbus_t *xbus)
spin_unlock_irqrestore(&worker->worker_lock, flags);
}
/*
* Called only after worker_reset(xbus)
*/
static void worker_destroy(xbus_t *xbus)
{
struct xbus_workqueue *worker;
BUG_ON(!xbus);
worker = &xbus->worker;
worker_reset(xbus);
XBUS_DBG(DEVICES, xbus, "Waiting for worker to finish...\n");
down(&worker->running_initialization);
XBUS_DBG(DEVICES, xbus, "Waiting for worker to finish -- done\n");
@@ -1236,6 +1299,7 @@ static int worker_run(xbus_t *xbus)
}
return 1;
err:
worker_reset(xbus);
worker_destroy(xbus);
return 0;
}
@@ -1403,6 +1467,7 @@ void xbus_disconnect(xbus_t *xbus)
del_timer_sync(&xbus->command_timer);
transportops_put(xbus);
transport_destroy(xbus);
/* worker_reset(xbus) was called in xbus_deactivate(xbus) */
worker_destroy(xbus);
XBUS_DBG(DEVICES, xbus, "Deactivated refcount_xbus=%d\n",
refcount_xbus(xbus));
@@ -1452,6 +1517,7 @@ void xbus_free(xbus_t *xbus)
num = xbus->num;
BUG_ON(!xbuses_array[num].xbus);
BUG_ON(xbus != xbuses_array[num].xbus);
init_xbus(num, NULL);
spin_unlock_irqrestore(&xbuses_lock, flags);
#ifdef CONFIG_PROC_FS
if (xbus->proc_xbus_dir) {
@@ -1478,7 +1544,6 @@ void xbus_free(xbus_t *xbus)
#endif
spin_lock_irqsave(&xbuses_lock, flags);
XBUS_DBG(DEVICES, xbus, "Going to free...\n");
init_xbus(num, NULL);
spin_unlock_irqrestore(&xbuses_lock, flags);
KZFREE(xbus);
}
@@ -1592,8 +1657,6 @@ static bool xpds_done(xbus_t *xbus)
{
if (XBUS_IS(xbus, FAIL))
return 1; /* Nothing to wait for */
if (!XBUS_IS(xbus, RECVD_DESC))
return 1; /* We are not in the initialization phase */
if (xbus->worker.xpds_init_done)
return 1; /* All good */
/* Keep waiting */
@@ -1611,10 +1674,6 @@ int waitfor_xpds(xbus_t *xbus, char *buf)
* FIXME: worker is created before ?????
* So by now it exists and initialized.
*/
/* until end of waitfor_xpds_show(): */
xbus = get_xbus(__func__, xbus->num);
if (!xbus)
return -ENODEV;
worker = &xbus->worker;
BUG_ON(!worker);
if (!worker->wq) {
@@ -1622,14 +1681,9 @@ int waitfor_xpds(xbus_t *xbus, char *buf)
len = -ENODEV;
goto out;
}
if (worker->num_units == 0) {
XBUS_ERR(xbus, "No cards. Skipping.\n");
goto out;
}
XBUS_DBG(DEVICES, xbus,
"Waiting for card init of %d XPD's max %d seconds (%p)\n",
worker->num_units, INITIALIZATION_TIMEOUT / HZ,
&worker->wait_for_xpd_initialization);
"Waiting for card init of XPDs max %d seconds\n",
INITIALIZATION_TIMEOUT / HZ);
ret =
wait_event_interruptible_timeout(worker->
wait_for_xpd_initialization,
@@ -1658,7 +1712,6 @@ int waitfor_xpds(xbus_t *xbus, char *buf)
spin_unlock_irqrestore(&xbus->lock, flags);
}
out:
put_xbus(__func__, xbus); /* from start of waitfor_xpds_show() */
return len;
}
@@ -1966,6 +2019,10 @@ int __init xbus_core_init(void)
{
int ret = 0;
if (dahdi_autoreg == 1) {
NOTICE("WARNING: The dahdi_autoreg parameter is deprecated " \
"-- just set dahdi.auto_assign_spans=0\n");
}
initialize_xbuses_array();
#ifdef PROTOCOL_DEBUG
INFO("FEATURE: with PROTOCOL_DEBUG\n");

View File

@@ -30,6 +30,7 @@
#include <linux/workqueue.h>
#include <linux/device.h>
#include <linux/delay.h> /* for msleep() to debug */
#include <linux/sched.h>
#include "xpd.h"
#include "xpp_dahdi.h"
#include "xbus-core.h"
@@ -54,10 +55,19 @@ static ssize_t sync_store(struct device_driver *driver, const char *buf,
return exec_sync_command(buf, count);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
static struct driver_attribute xpp_attrs[] = {
__ATTR(sync, S_IRUGO | S_IWUSR, sync_show, sync_store),
__ATTR_NULL,
};
#else
static DRIVER_ATTR_RW(sync);
static struct attribute *xpp_attrs[] = {
&driver_attr_sync.attr,
NULL,
};
ATTRIBUTE_GROUPS(xpp);
#endif
/*--------- Sysfs Bus handling ----*/
static DEVICE_ATTR_READER(xbus_state_show, dev, buf)
@@ -293,6 +303,42 @@ field##_show(struct device *dev, struct device_attribute *attr, char *buf) \
xbus_attr(connector, "%s\n");
xbus_attr(label, "%s\n");
static DEVICE_ATTR_WRITER(dahdi_registration_store, dev, buf, count)
{
xbus_t *xbus;
int dahdi_reg;
int ret;
xbus = dev_to_xbus(dev);
if (!xbus)
return -ENODEV;
ret = sscanf(buf, "%d", &dahdi_reg);
if (ret != 1)
return -EINVAL;
if (dahdi_reg) {
ret = xbus_register_dahdi_device(xbus);
if (ret < 0) {
XBUS_ERR(xbus,
"xbus_register_dahdi_device() failed (ret = %d)\n",
ret);
return ret;
}
} else {
xbus_unregister_dahdi_device(xbus);
}
return count;
}
static DEVICE_ATTR_READER(dahdi_registration_show, dev, buf)
{
xbus_t *xbus;
int len;
xbus = dev_to_xbus(dev);
len = sprintf(buf, "%d\n", xbus_is_registered(xbus));
return len;
}
static struct device_attribute xbus_dev_attrs[] = {
__ATTR_RO(connector),
__ATTR_RO(label),
@@ -307,6 +353,9 @@ static struct device_attribute xbus_dev_attrs[] = {
#ifdef SAMPLE_TICKS
__ATTR(samples, S_IWUSR | S_IRUGO, samples_show, samples_store),
#endif
__ATTR(dahdi_registration, S_IRUGO | S_IWUSR,
dahdi_registration_show,
dahdi_registration_store),
__ATTR_NULL,
};
@@ -409,7 +458,11 @@ static struct bus_type toplevel_bus_type = {
.match = astribank_match,
.uevent = astribank_uevent,
.dev_attrs = xbus_dev_attrs,
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
.drv_attrs = xpp_attrs,
#else
.drv_groups = xpp_groups,
#endif
};
static int astribank_probe(struct device *dev)
@@ -601,25 +654,12 @@ static DEVICE_ATTR_WRITER(span_store, dev, buf, count)
return -EINVAL;
if (!XBUS_IS(xpd->xbus, READY))
return -ENODEV;
XPD_DBG(DEVICES, xpd, "%s -- deprecated (should use pinned-spans)\n",
XPD_DBG(DEVICES, xpd, "%s -- deprecated (should use assigned-spans)\n",
(dahdi_reg) ? "register" : "unregister");
if (xbus_is_registered(xpd->xbus)) {
if (dahdi_reg) {
XPD_DBG(DEVICES, xpd,
"already registered %s. Ignored.\n",
xpd->xbus->busname);
} else {
xbus_unregister_dahdi_device(xpd->xbus);
}
} else {
if (!dahdi_reg) {
XPD_DBG(DEVICES, xpd,
"already unregistered %s. Ignored.\n",
xpd->xbus->busname);
} else {
xbus_register_dahdi_device(xpd->xbus);
}
}
if (dahdi_reg)
xbus_register_dahdi_device(xpd->xbus);
else
xbus_unregister_dahdi_device(xpd->xbus);
return count;
}
@@ -928,10 +968,13 @@ void xbus_sysfs_remove(xbus_t *xbus)
struct device *astribank;
BUG_ON(!xbus);
XBUS_DBG(DEVICES, xbus, "\n");
astribank = &xbus->astribank;
if (!dev_get_drvdata(astribank))
if (!dev_get_drvdata(astribank)) {
XBUS_NOTICE(xbus, "%s: already removed\n", __func__);
return;
}
XBUS_DBG(DEVICES, xbus, "going to unregister: refcount=%d\n",
atomic_read(&astribank->kobj.kref.refcount));
BUG_ON(dev_get_drvdata(astribank) != xbus);
device_unregister(astribank);
dev_set_drvdata(astribank, NULL);

View File

@@ -31,6 +31,7 @@
#include <linux/device.h>
#include <linux/version.h>
#include <asm/atomic.h>
#include <linux/slab.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
#include <linux/semaphore.h>
#else

View File

@@ -1,11 +0,0 @@
# Load firmware into the Xorcom Astribank device:
SUBSYSTEM=="usb", ACTION=="add", \
ENV{PRODUCT}=="e4e4/11[3456][013]/*", ENV{DEVTYPE}!="usb_interface", \
RUN+="/usr/share/dahdi/xpp_fxloader udev $env{PRODUCT}"
# Hotplug hook for Astribank up/down
# If you need this functionality, copy the astribank_hook.sample
# to $XPP_INIT_DIR/astribank_hook
#
# By default XPP_INIT_DIR="/usr/share/dahdi"
KERNEL=="xbus*", RUN+="%E{XPP_INIT_DIR}/astribank_hook udev $kernel $sysfs{status} $sysfs{connector}"

View File

@@ -458,29 +458,28 @@ static void phonedev_cleanup(xpd_t *xpd)
unsigned int x;
for (x = 0; x < phonedev->channels; x++) {
if (phonedev->chans[x])
if (phonedev->chans[x]) {
KZFREE(phonedev->chans[x]);
if (phonedev->ec[x])
phonedev->chans[x] = NULL;
}
if (phonedev->ec[x]) {
KZFREE(phonedev->ec[x]);
phonedev->ec[x] = NULL;
}
}
phonedev->channels = 0;
}
__must_check static int phonedev_init(xpd_t *xpd,
const xproto_table_t *proto_table,
int channels, xpp_line_t no_pcm)
int phonedev_alloc_channels(xpd_t *xpd, int channels)
{
struct phonedev *phonedev = &PHONEDEV(xpd);
int old_channels = phonedev->channels;
unsigned int x;
spin_lock_init(&phonedev->lock_recompute_pcm);
XPD_DBG(DEVICES, xpd, "Reallocating channels: %d -> %d\n",
old_channels, channels);
phonedev_cleanup(xpd);
phonedev->channels = channels;
phonedev->no_pcm = no_pcm;
phonedev->offhook_state = 0x0; /* ONHOOK */
phonedev->phoneops = proto_table->phoneops;
phonedev->digital_outputs = 0;
phonedev->digital_inputs = 0;
atomic_set(&phonedev->dahdi_registered, 0);
atomic_set(&phonedev->open_counter, 0);
for (x = 0; x < phonedev->channels; x++) {
if (!
(phonedev->chans[x] =
@@ -501,6 +500,29 @@ err:
phonedev_cleanup(xpd);
return -ENOMEM;
}
EXPORT_SYMBOL(phonedev_alloc_channels);
__must_check static int phonedev_init(xpd_t *xpd,
const xproto_table_t *proto_table,
int channels, xpp_line_t no_pcm)
{
struct phonedev *phonedev = &PHONEDEV(xpd);
spin_lock_init(&phonedev->lock_recompute_pcm);
phonedev->no_pcm = no_pcm;
phonedev->offhook_state = 0x0; /* ONHOOK */
phonedev->phoneops = proto_table->phoneops;
phonedev->digital_outputs = 0;
phonedev->digital_inputs = 0;
atomic_set(&phonedev->dahdi_registered, 0);
atomic_set(&phonedev->open_counter, 0);
if (phonedev_alloc_channels(xpd, channels) < 0)
goto err;
return 0;
err:
return -ENOMEM;
}
/*
* xpd_alloc - Allocator for new XPD's
@@ -692,15 +714,15 @@ EXPORT_SYMBOL(hookstate_changed);
/*------------------------- Dahdi Interfaces -----------------------*/
/*
* Called from dahdi with spinlock held on chan. Must not call back
* Called with spinlock held on chan. Must not call back
* dahdi functions.
*/
int xpp_open(struct dahdi_chan *chan)
static int _xpp_open(struct dahdi_chan *chan)
{
xpd_t *xpd;
xbus_t *xbus;
int pos;
unsigned long flags;
int open_counter;
if (!chan) {
NOTICE("open called on a null chan\n");
@@ -721,31 +743,37 @@ int xpp_open(struct dahdi_chan *chan)
LINE_NOTICE(xpd, pos, "Cannot open -- device not ready\n");
return -ENODEV;
}
spin_lock_irqsave(&xbus->lock, flags);
atomic_inc(&PHONEDEV(xpd).open_counter);
open_counter = atomic_inc_return(&PHONEDEV(xpd).open_counter);
LINE_DBG(DEVICES, xpd, pos, "%s[%d]: open_counter=%d\n", current->comm,
current->pid, atomic_read(&PHONEDEV(xpd).open_counter));
spin_unlock_irqrestore(&xbus->lock, flags);
current->pid, open_counter);
if (PHONE_METHOD(card_open, xpd))
CALL_PHONE_METHOD(card_open, xpd, pos);
return 0;
}
int xpp_open(struct dahdi_chan *chan)
{
unsigned long flags;
int res;
spin_lock_irqsave(&chan->lock, flags);
res = _xpp_open(chan);
spin_unlock_irqrestore(&chan->lock, flags);
return res;
}
EXPORT_SYMBOL(xpp_open);
int xpp_close(struct dahdi_chan *chan)
{
xpd_t *xpd = chan->pvt;
xbus_t *xbus = xpd->xbus;
int pos = chan->chanpos - 1;
unsigned long flags;
int open_counter;
spin_lock_irqsave(&xbus->lock, flags);
spin_unlock_irqrestore(&xbus->lock, flags);
if (PHONE_METHOD(card_close, xpd))
CALL_PHONE_METHOD(card_close, xpd, pos);
/* from xpp_open(): */
open_counter = atomic_dec_return(&PHONEDEV(xpd).open_counter);
LINE_DBG(DEVICES, xpd, pos, "%s[%d]: open_counter=%d\n", current->comm,
current->pid, atomic_read(&PHONEDEV(xpd).open_counter));
atomic_dec(&PHONEDEV(xpd).open_counter); /* from xpp_open() */
current->pid, open_counter);
return 0;
}
EXPORT_SYMBOL(xpp_close);
@@ -1025,12 +1053,9 @@ EXPORT_SYMBOL(xpd_set_spanname);
static void xpd_init_span(xpd_t *xpd, unsigned offset, int cn)
{
struct dahdi_span *span;
int i;
memset(&PHONEDEV(xpd).span, 0, sizeof(struct dahdi_span));
for (i = 0; i < cn; i++)
memset(XPD_CHAN(xpd, i), 0, sizeof(struct dahdi_chan));
phonedev_alloc_channels(xpd, cn);
span = &PHONEDEV(xpd).span;
span->deflaw = DAHDI_LAW_MULAW; /* card_* drivers may override */
span->channels = cn;

View File

@@ -38,6 +38,7 @@ xpd_t *xpd_alloc(xbus_t *xbus, int unit, int subunit, int subtype, int subunits,
int channels);
void xpd_free(xpd_t *xpd);
void xpd_remove(xpd_t *xpd);
int phonedev_alloc_channels(xpd_t *xpd, int channels);
void update_xpd_status(xpd_t *xpd, int alarm_flag);
const char *xpp_echocan_name(const struct dahdi_chan *chan);
int xpp_echocan_create(struct dahdi_chan *chan, struct dahdi_echocanparams *ecp,
@@ -64,6 +65,7 @@ void notify_rxsig(xpd_t *xpd, int pos, enum dahdi_rxsig rxsig);
extern struct proc_dir_entry *xpp_proc_toplevel;
#endif
#define SPAN_REGISTERED(xpd) atomic_read(&PHONEDEV(xpd).dahdi_registered)
#define SPAN_REGISTERED(xpd) (atomic_read(&PHONEDEV(xpd).dahdi_registered) && \
test_bit(DAHDI_FLAGBIT_REGISTERED, &PHONEDEV(xpd).span.flags))
#endif /* XPP_DAHDI_H */

View File

@@ -211,7 +211,7 @@ static xusb_t *xusb_array[MAX_BUSES] = { };
static unsigned bus_count;
/* prevent races between open() and disconnect() */
static DEFINE_SEMAPHORE(disconnect_sem);
static DEFINE_MUTEX(protect_xusb_devices);
/*
* AsteriskNow kernel has backported the "lean" callback from 2.6.20
@@ -652,6 +652,7 @@ static int xusb_probe(struct usb_interface *interface,
iface_desc->desc.bInterfaceNumber, model_info->iface_num);
return -ENODEV;
}
mutex_lock(&protect_xusb_devices);
if ((retval = usb_reset_device(udev)) < 0) {
ERR("usb_reset_device failed: %d\n", retval);
goto probe_failed;
@@ -759,6 +760,7 @@ static int xusb_probe(struct usb_interface *interface,
for (i = 0; i < 10; i++)
xusb_listen(xusb);
xbus_connect(xbus);
mutex_unlock(&protect_xusb_devices);
return retval;
probe_failed:
ERR("Failed to initialize xpp usb bus: %d\n", retval);
@@ -785,6 +787,7 @@ probe_failed:
ERR("Calling xbus_disconnect()\n");
xbus_disconnect(xbus); // Blocking until fully deactivated!
}
mutex_unlock(&protect_xusb_devices);
return retval;
}
@@ -810,7 +813,7 @@ static void xusb_disconnect(struct usb_interface *interface)
DBG(DEVICES, "CALLED on interface #%d\n",
iface_desc->desc.bInterfaceNumber);
/* prevent races with open() */
down(&disconnect_sem);
mutex_lock(&protect_xusb_devices);
xusb = usb_get_intfdata(interface);
usb_set_intfdata(interface, NULL);
@@ -844,7 +847,7 @@ static void xusb_disconnect(struct usb_interface *interface)
XUSB_INFO(xusb, "now disconnected\n");
KZFREE(xusb);
up(&disconnect_sem);
mutex_unlock(&protect_xusb_devices);
}
static void xpp_send_callback(USB_PASS_CB(urb))

View File

@@ -40,11 +40,10 @@
/* #define SHORT_FLASH_TIME */
/*
* Uncomment to disable calibration and/or DC/DC converter tests
* Uncomment to disable calibration tests
* (not generally recommended)
*/
/* #define NO_CALIBRATION */
/* #define NO_DCDC */
/*
* Boost ring voltage (Higher ring voltage, takes more power)

View File

@@ -425,6 +425,7 @@ struct dahdi_chan {
int lastnumbufs;
#endif
spinlock_t lock;
struct mutex mutex;
char name[40];
/* Specified by DAHDI */
/*! \brief DAHDI channel number */
@@ -811,6 +812,7 @@ enum spantypes {
SPANTYPE_DIGITAL_BRI_NT,
SPANTYPE_DIGITAL_BRI_TE,
SPANTYPE_DIGITAL_BRI_SOFT,
SPANTYPE_DIGITAL_DYNAMIC,
};
const char *dahdi_spantype2str(enum spantypes st);
enum spantypes dahdi_str2spantype(const char *name);
@@ -909,7 +911,7 @@ struct dahdi_span_ops {
/*! Opt: Provide the name of the echo canceller on a channel */
const char *(*echocan_name)(const struct dahdi_chan *chan);
/*! When using "pinned_spans", this function is called back when this
/*! When using "assigned spans", this function is called back when this
* span has been assigned with the system. */
void (*assigned)(struct dahdi_span *span);
@@ -940,6 +942,7 @@ struct dahdi_device {
const char *devicetype;
struct device dev;
unsigned int irqmisses;
struct timespec registration_time;
};
struct dahdi_span {
@@ -1003,6 +1006,8 @@ struct dahdi_transcoder_channel {
};
int dahdi_is_sync_master(const struct dahdi_span *span);
struct dahdi_span *get_master_span(void);
void set_master_span(int spanno);
static inline int
dahdi_tc_is_built(struct dahdi_transcoder_channel *dtc) {
@@ -1277,6 +1282,8 @@ static inline void dahdi_ec_span(struct dahdi_span *span)
extern struct file_operations *dahdi_transcode_fops;
int dahdi_get_auto_assign_spans(void);
/* Don't use these directly -- they're not guaranteed to
be there. */
extern short __dahdi_mulaw[256];
@@ -1402,6 +1409,8 @@ static inline short dahdi_txtone_nextsample(struct dahdi_chan *ss)
#define DAHDI_FORMAT_AUDIO_MASK ((1 << 16) - 1)
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)
#ifdef RHEL_RELEASE_VERSION
#if RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(6, 5)
#ifdef CONFIG_PROC_FS
#include <linux/proc_fs.h>
static inline void *PDE_DATA(const struct inode *inode)
@@ -1409,8 +1418,37 @@ static inline void *PDE_DATA(const struct inode *inode)
return PDE(inode)->data;
}
#endif
#endif
#else
#ifdef CONFIG_PROC_FS
#include <linux/proc_fs.h>
static inline void *PDE_DATA(const struct inode *inode)
{
return PDE(inode)->data;
}
#endif
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
#define KERN_CONT ""
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
# ifndef RHEL_RELEASE_VERSION
/* I'm not sure which 5.x release this was backported into. */
static inline int try_wait_for_completion(struct completion *x)
{
unsigned long flags;
int ret = 1;
spin_lock_irqsave(&x->wait.lock, flags);
if (!x->done)
ret = 0;
else
x->done--;
spin_unlock_irqrestore(&x->wait.lock, flags);
return ret;
}
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
#ifdef CONFIG_PROC_FS
#include <linux/proc_fs.h>
@@ -1450,8 +1488,11 @@ void dahdi_pci_disable_link_state(struct pci_dev *pdev, int state);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
#ifndef __packed
#define __packed __attribute__((packed))
#define list_first_entry(ptr, type, member) \
list_entry((ptr)->next, type, member)
#ifndef __packed
#define __packed __attribute__((packed))
#endif
#include <linux/ctype.h>
@@ -1479,6 +1520,7 @@ static inline int strcasecmp(const char *s1, const char *s2)
#endif /* 2.6.22 */
#endif /* 2.6.25 */
#endif /* 2.6.26 */
#endif /* 2.6.27 */
#endif /* 2.6.31 */
#endif /* 3.10.0 */
@@ -1551,6 +1593,10 @@ struct mutex {
#define chan_err(chan, fmt, ...) chan_printk(ERR, "", chan, fmt, \
## __VA_ARGS__)
#ifndef pr_fmt
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#endif
#ifndef pr_err
#define pr_err(fmt, ...) \
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
@@ -1571,6 +1617,17 @@ struct mutex {
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
#endif
/* If KBUILD_MODNAME is not defined in a compilation unit, then the dev_dbg
* macro will not work properly. */
#ifndef KBUILD_MODNAME
#undef dev_dbg
#ifdef DEBUG
#define dev_dbg dev_info
#else
#define dev_dbg(...) do { } while (0)
#endif
#endif
/* The dbg_* ones use a magical variable 'debug' and the user should be
* aware of that.
*/