1 diff -urN linux.old/drivers/atm/Config.in linux.dev/drivers/atm/Config.in
2 --- linux.old/drivers/atm/Config.in 2004-08-08 01:26:04.000000000 +0200
3 +++ linux.dev/drivers/atm/Config.in 2005-07-10 08:02:01.417115464 +0200
5 bool 'Use S/UNI PHY driver' CONFIG_ATM_HE_USE_SUNI
9 +# Texas Instruments SANGAM ADSL/ATM support
11 +if [ "$CONFIG_AR7" = "y" ]; then
12 + tristate 'Texas Instruments SANGAM ATM/ADSL support' CONFIG_MIPS_SANGAM_ATM
15 diff -urN linux.old/drivers/atm/Makefile linux.dev/drivers/atm/Makefile
16 --- linux.old/drivers/atm/Makefile 2005-01-19 15:09:40.000000000 +0100
17 +++ linux.dev/drivers/atm/Makefile 2005-07-10 08:02:01.417115464 +0200
19 obj-$(CONFIG_ATM_NICSTAR) += nicstar.o
20 obj-$(CONFIG_ATM_IDT77252) += idt77252.o
22 +ifeq ($(CONFIG_AR7),y)
24 +subdir-$(CONFIG_MIPS_SANGAM_ATM) += sangam_atm
26 +EXTRA_CFLAGS += -DEL -I$(TOPDIR)/drivers/atm/sangam_atm -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
27 +#EXTRA_CFLAGS += -DEL -I$(TOPDIR)/drivers/atm/sangam_atm -DPOST_SILICON -DCOMMON_NSP
30 +EXTRA_CFLAGS += -DANNEX_B -DB
33 +EXTRA_CFLAGS += -DANNEX_C -DC
35 +EXTRA_CFLAGS += -DANNEX_A -DP
39 +list-multi := tiatm.o
40 +tiatm-objs := sangam_atm/tn7atm.o sangam_atm/tn7dsl.o sangam_atm/tn7sar.o \
41 + sangam_atm/dsl_hal_api.o sangam_atm/dsl_hal_support.o sangam_atm/cpsar.o \
42 + sangam_atm/aal5sar.o
44 +obj-$(CONFIG_MIPS_SANGAM_ATM) += sangam_atm/tiatm.o
48 ifeq ($(CONFIG_ATM_NICSTAR_USE_SUNI),y)
49 obj-$(CONFIG_ATM_NICSTAR) += suni.o
51 diff -urN linux.old/drivers/atm/sangam_atm/aal5sar.c linux.dev/drivers/atm/sangam_atm/aal5sar.c
52 --- linux.old/drivers/atm/sangam_atm/aal5sar.c 1970-01-01 01:00:00.000000000 +0100
53 +++ linux.dev/drivers/atm/sangam_atm/aal5sar.c 2005-07-10 08:02:01.420115008 +0200
60 + * TNETDxxxx Software Support\n
61 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
64 + * 28Feb02 Greg 1.00 Original Version created.\n
65 + * 06Mar02 Greg 1.01 Documentation (Doxygen-style) enhanced
66 + * 06May02 Greg 1.02 AAL2 added
67 + * 06Jun02 Greg 1.03 Multiple API and bug fixes from emulation
68 + * 12Jul02 Greg 1.04 API Update
72 +@defgroup CPHAL_Functions CPHAL Functions
74 +These are the CPHAL Functions.
78 +@page CPHAL_Implementation_Details
80 +@section cphal_intro Introduction
82 +The CPHAL API described above is generally applicable to all modules. Any
83 +implementation differences will be described in the following module-specific
86 +Included for your reference is a diagram showing the internal architecture
89 +@image html SangamSoftware.jpg "HAL Architecture"
90 +@image latex SangamSoftware.jpg "HAL Architecture" height=2.8in
95 +@defgroup AAL5_Functions Additional Functions for AAL5 Implementation
97 +These functions are used only by the AAL5 module.
101 +@defgroup CPMAC_Functions Additional Functions for CPMAC Implementation
103 +No additional functions currently defined.
107 +@page VDMA_Implementation_Details
109 +@section vdma_intro Introduction
111 +The VDMA-VT module facilitates efficient transfer of data (especially voice)
112 +between two devices, as shown in the figure below.
114 +@image html vdma.jpg "VDMA System Block Diagram"
115 +@image latex vdma.jpg "VDMA System Block Diagram" height=1in
117 +The VDMA-VT module supports two modes of operation: mirror mode and credit mode.
118 +Mirror mode is intended for systems in which the remote device does not have a
119 +VDMA-based module. Credit mode is intended for highest performance when VDMA-based
120 +modules exist on both ends of an interface.
122 +For more detailed information on the operation of the VDMA module, please
123 +reference the VDMA Module Guide.
125 +@section vdma_channels VDMA Channels
127 +The VDMA-VT module is a single channel, single transmit queue device. Therefore,
128 +when using the CHANNEL_INFO structure, the correct value for @c Ch is always 0.
129 +Correspondingly, the correct value for the @c Ch parameter in @c ChannelTeardown() is
130 +always 0. Further, when calling @c Send(), the driver should always supply the value
131 +of 0 for both the @c Ch and @c Queue parameters.
133 +For the VDMA-VT, configuring the channel requires the configuration of either 2 FIFO
134 +elements (in credit mode) or 4 FIFO elements (in mirror mode). For credit mode, the
135 +driver must configure just the local Tx and Rx FIFOs. For mirror mode, the driver must
136 +configure the Tx and Rx FIFOs for both the remote and local ends of the interface.
138 +This channel configuration is accomplished through multiple calls to @c ChannelSetup().
139 +Each call configures a single FIFO, according to the parameters in the CHANNEL_INFO
140 +structure. The members of VDMA-VT's CHANNEL_INFO structure are defined below.
143 +- int RemFifoAddr; Address of remote FIFO (mirror mode only). Set to 0 for credit mode.
144 +- int FifoAddr; Address of the local FIFO. If 0, the CPHAL will allocate the FIFO.
145 +- int FifoSize; Size of the FIFO.
146 +- int PollInt; Polling interval for the FIFO.
147 +- int Endianness; Endianness of the FIFO. If 1, big endian. If 0, little endian.
148 +- int RemAddr; Used only in credit mode. This is the base address of the remote
149 + remote VDMA-based device (VDMA-VT or AAL2)
150 +- int RemDevID; Used only in credit mode. Identifies the type of remote VDMA-based device.
151 + 0=VDMAVT, 1=AAL2 Ch0, 2=AAL2 Ch1, 3=AAL2 Ch2, 4= AAL2 Ch3.
153 +For the VDMA-VT module, the driver must make all calls to @c ChannelSetup() prior to calling
154 +@c Open(). This is because several of the channel specific parameters may not be changed
155 +while the VDMA-VT module is operational.
157 +@section vdma_params VDMA Parameters
159 +Defined here are the set of parameters for the VDMA-VT module. Default settings for
160 +each parameter should be represented in the device configuration file (options.conf).
161 +During @c Init(), the CPHAL will reference the device configuration file and load all
162 +default settings. The @c Control() interface gives the driver an opportunity to
163 +modify any default settings before the module becomes operational during the @c Open()
166 +@param NoTxIndication If 1, the CPHAL will not call @c SendComplete(). 0 is default.
167 +@param NoRxIndication If 1, the CPHAL will not call @c Receive(). 0 is default.
168 +@param RemoteCPU If 1, the CPHAL will not directly manipulate data in FIFO's, leaving
169 + that task for a remote CPU. 0 is default.
170 +@param RxIntEn If 1, enables Rx interrupts. 0 is default.
171 +@param TxIntEn If 1, enables Tx interrupts. 0 is default.
172 +@param Mirror If 1, enables mirror mode. 0 selects credit mode (default).
173 +@param RxIntCtl Valid only in mirror mode. If 1, interrupts will occur when the Rx FIFO
174 + RdIndex is updated. If 0, interrupts occur when the Rx FIFO WrIndex
176 +@param TxIntCtl Valid only in mirror mode. If 1, interrupts will occur when the Rx FIFO
177 + RdIndex is updated. If 0, interrupts occur when the Rx FIFO WrIndex
179 +@param RBigEn Remote big endian mode. If 1, remote is big endian.
180 +@param LBigEn Local big endian mode. If 1, local is big endian.
182 +@section vdma_polling Using VDMA-VT without interrupts
184 +If your system configuration does not utilize VDMA interrupts, the ability to process the
185 +Tx and Rx FIFOs is supported. To process the Tx FIFO, call @c CheckTx(). If the CPHAL is
186 +able to process any complete data transmissions, it will call @c SendComplete() as usual.
187 +To process the Rx FIFO, call @c CheckRx(). If the CPHAL has received any data, it will
188 +call @c Receive() to pass the driver the data. Please reference @ref VDMA_Functions for more
189 +information on these interfaces.
191 +@section vdma_details VDMA Implementation Details
193 +The following functions are not defined for use with VDMA: @c Status(), @c Tick(), @c StatsGet(),
194 +and @c StatsClear().
199 +@page AAL5_Implementation_Details
201 +@section aal5_ver Version
203 +@copydoc AAL5_Version
205 +@section aal5_intro Introduction
207 +The AAL5 implementation will support 16 channels for transmit and 16 channels for
208 +receive. Each of the transmit channels may have up to two transmit queues
209 +associated with it. If two queues are used, Queue 0 is the high priority queue,
210 +and Queue 1 is the low priority queue.
212 +@section aal5_params AAL5 Configuration Parameters
214 +AAL5 requires two device entries to be available in the configuration repository, named
215 +@p "aal5" and @p "sar". The @p aal5 device entry must contain @p base (base address)
216 +and @p int_line (interrupt number). The @p sar device entry must have both @p base
217 +(base address) and @p reset_bit (reset bit).
219 +@par Device Level Configuration Parameters
221 +The following parameters are device-level parameters, which apply across all
222 +channels. The value for these parameters may be modified by changing the value in the
223 +configuration repository.
226 +AAL5 network setting. 0 = UNI (default), 1 = NNI.
228 +@par Channel Configuration Parameters
230 +All AAL5 channel parameters may also be configured through the @c ChannelSetup() interface.
231 +Following is the list of @p CHANNEL_INFO members that may be modified by the driver when
232 +calling @c ChannelSetup(). The driver may provide a value of 0xFFFFFFFF for any channel
233 +parameter to select a default value for the parameter. The driver should at a minimum
234 +configure @p Vci and @p Vpi. The usage of all parameters beginning with TxVc_,
235 +TxVp_, RxVc_, RxVp_ is described in greater detail in the SAR Firmware Spec.
236 +These parameters are mainly associated with QoS and OAM functionality.
239 +The number of Rx buffer descriptors to allocate for Ch.
241 +Size (in bytes) for each Rx buffer.
243 +Number of bytes to offset rx data from start of buffer (must be less than buffer size).
245 +Maximum number of packets to service at one time.
247 +The number of Tx buffer descriptors to allocate for Ch.
249 +Number of Tx queues for this channel (1-2). Choosing 2 enables a low priority SAR queue.
251 +Maximum number of packets to service at one time.
253 +The 2-byte CPCS UU and CPI information.
255 +Generic Flow Control. Used in ATM header of Tx packets.
257 +Cell Loss Priority. Used in ATM header of Tx packets.
259 +Payload Type Indication. Used in ATM header of Tx packets.
261 +Specifies whether credit issuance is paused when Tx data not available.
263 +Priority bin this channel will be scheduled within.
265 +0=AAL5,1=Null AAL,2=OAM,3=Transparent,4=AAL2.
267 +Virtual Channel Identifier.
269 +Virtual Path Identifier.
271 +In firmware OAM mode, this
272 +is the ATM header to be appended to front of firmware generated VC OAM cells for
273 +this channel. Note: To generate host OAM cells, call @c Send() with
274 +the appropriate mode.
276 +Tx rate, set as clock ticks between transmissions (SCR for VBR, CBR for CBR).
278 +0=CBR,1=VBR,2=UBR,3=UBRmcr.
280 +Min Burst Size in cells.
282 +Peak Cell Rate for VBR in clock ticks between transmissions.
284 +TC Path to transmit OAM cells for TX connections (0,1).
286 +Offset to the OAM VP state table for TX connections. Channels with the same
287 +VPI must have the same VpOffset value. Channels with different VPIs
288 +must have unique VpOffset values.
290 +Channel to which to terminate received OAM cells to be forwarded to the Host
291 +for either Host OAM mode, or when RxVc_OamToHost is enabled during Firmware
294 +Indicates whether to pass received unmatched OAM loopback cells to the host;
295 +0=do not pass, 1=pass.
297 +ATM Header placed on firmware gen'd OAM cells for this channel on a Rx
298 +connection (must be big endian with 0 PTI).
300 +TC Path to transmit OAM cells for RX connections (0,1).
302 +Offset to the OAM VP state table for RX connections. Channels with the same
303 +VPI must have the same VpOffset value. Channels with different VPIs
304 +must have unique VpOffset values.
306 +TC Path to transmit OAM cells for TX VP connections (0,1).
308 +ATM Header placed on firmware gen'd VP OAM cells for this channel on a Tx VP
309 +connection (must be big endian with 0 VCI).
311 +Channel to which to terminate received OAM cells to be forwarded to the Host
312 +for either Host OAM mode, or when RxVc_OamToHost is enabled during Firmware
315 +Indicates whether to pass received unmatched OAM loopback cells to the host;
316 +0=do not pass, 1=pass.
318 +In firmware OAM mode, this
319 +is the ATM header to be appended to front of firmware generated VP OAM cells for
320 +this channel. Note: To generate host OAM cells, call @c Send() with
321 +the appropriate mode.
323 +TC Path to transmit OAM cells for RX VP connections (0,1).
325 +This 32-bit field is one-hot encoded to indicate all the VC channels that are
326 +associated with this VP channel. A value of 21 will indicate that VC
327 +channels 0, 2, and 4 are associated with this VP channel.
329 +Indicates whether or not to forward unknown VCI/VPI cells to the host. This
330 +parameter only takes effect if the channel's PktType is Transparent(3).
331 +1=forwarding enabled, 0=forwarding disabled.
333 +@section aal5_details API Implementation Details
335 +ATTENTION: Documentation given here supplements the documentation given in the general
336 +CPHAL API section. The following details are crucial to correct usage of the
340 +The least significant byte of @p Mode contains the channel number. Bit 31
341 +indicates whether or not the ATM header is present in the first fragment of
342 +the packet. If bit 31 is set, the 4 byte ATM header (minus HEC) will be provided
343 +in the first fragment, with the payload beginning in the second fragment. Currently,
344 +this is the default behavior for host OAM and transparent mode packets.
345 +Bits 17-16 indicate the packet type that is being received.
346 +Mode Parameter Breakdown: <BR>
347 +- 31 ATM Header In First Fragment (1=true, 0=false) <BR>
348 +- 30-18 Unused. <BR>
349 +- 17-16 Pkt Type. <BR>
351 + - 1=PTI Based Null AAL <BR>
353 + - 3=Transparent <BR>
354 +- 15-08 Unused. <BR>
355 +- 07-00 Channel Number.
358 +The most significant 16 bits of the first fragment 'len' is used as the Offset
359 +to be added to the packet. @c Send() will reserve this many bytes at the
360 +beginning of the transmit buffer prior to the first byte of valid data.
361 +For the @p Mode parameter, Bit 31 must be set if the user has sent a packet with
362 +the ATM Header (minus HEC) embedded in the first 4 bytes of the first fragment data buffer.
363 +The OS has the option of using a 4 byte first fragment containing only ATM header,
364 +or concatenating the ATM Header in front of the data payload.
365 +If Bit 31 is set, the ATM Header in the buffer is preserved and sent with
366 +each cell of the packet. Otherwise, Send() will build the ATM header based on the
367 +values of the Pti, Gfc, Clp, Vpi, and Vci parameters for the given channel.
368 +Bits 17-16 are defined as the packet type. Bits 15-08 may be used to specify the
369 +transmit queue to send the packet on. Only values 0 (high priority) and 1 (low
370 +priority) are accepted. Bits 07-00 should be used to indicate the channel number
371 +for the @c Send() operation. Valid channel numbers are 0-15.
372 +Mode Parameter Breakdown: <BR>
373 +- 31 ATM Header In Packet (1=true, 0=false) <BR>
374 +- 30-18 Unused. <BR>
375 +- 17-16 Pkt Type. <BR>
377 + - 1=PTI Based Null AAL <BR>
379 + - 3=Transparent <BR>
380 +- 15-08 Transmit Queue. <BR>
381 +- 07-00 Channel Number.
384 +The AAL5 @c ChannelSetup() always configures both the Tx and Rx side of the channel
385 +connection in the same call.
387 +@par ChannelTeardown()
388 +Regardless of the channel teardown direction selected, the AAL5 CPHAL will always
389 +teardown both the Tx and Rx side of the channel connection.
391 +@par TeardownComplete()
392 +The value for the @p Direction parameter should be ignored for the AAL5 implementation,
393 +since both directions (Tx and Rx) are always torndown in response to a @c ChannelTeardown()
396 +@par Control() (HAL version)
397 +Defined keys and actions. Unless otherwise stated, the data type
398 +for Value is pointer to unsigned integer. The list is broken into
399 +three groups, one group which can be used anytime, one group that should
400 +be used before halOpen(), and one group which can only be used after
401 +halOpen() (but before halClose()). For channelized parameters, replace
402 +'Ch' with the integer number of a channel (ex. "Gfc.4" can be used to set
405 +MAY USE ANYTIME AFTER INIT (after halInit() is called):
407 +- "Gfc.Ch". The OS may "Set" this value. Changing this value causes
408 +the Gfc in each Tx ATM header for this channel to take on the new Gfc value.
410 +- "Clp.Ch". The OS may "Set" this value. Changing this value causes
411 +the Clp in each Tx ATM header for this channel to take on the new Clp value.
413 +- "Pti.Ch". The OS may "Set" this value. Changing this value causes
414 +the Pti in each Tx ATM header for this channel to take on the new Pti value.
416 +- "CpcsUU.Ch". The OS may "Set" this value. Changing this value causes
417 +the CpcsUU in each Tx ATM header for this channel to take on the new CpcsUU value.
419 +- "OamMode". Specifies if host or firmware is performing OAM functions; 0 = Host OAM,
420 +1 = Firmware OAM. When set, all SAR channels will be configured for
421 +the selection, including AAL2 channels.
423 +- "OamLbTimeout". Specifies the firmware OAM loopback timeout, in milliseconds.
425 +- "DeviceCPID". The OS may "Set" this value. This is the OAM connection
426 +point identifier. The OS should provide a pointer to an array of 4 32-bit
427 +integers. Each word must be configured in big endian format.
429 +- "FwdUnkVc.Ch". Indicates whether or not to forward unknown VCI/VPI cells to the host.
430 +This parameter only takes effect if the channel's PktType is Transparent(3).
431 +1=forwarding enabled, 0=forwarding disabled.
433 +MAY USE ONLY BEFORE HAL IS OPEN (before halOpen() call):
434 +- "StrictPriority". The OS may "Set" this value. Setting to 1 causes
435 +a different interrupt processing routine to be used, which gives strict
436 +priority to channels with lower numbers (channel 0 has highest priority).
437 +The default handler gives equal priority to all channels.
439 +- "MaxFrags". The OS may "Set" or "Get" this value. This defines the maximum
440 +number of fragments that can be received by the AAL5 Rx port. The default
441 +value for AAL5 is 46. This provides enough space to receive a maximum
442 +length AAL5 packet (65,568 bytes) with the default buffer size of 1518 bytes, and
443 +any amount of RxBufferOffset. If the buffer size is configured to be smaller,
444 +the OS *MUST* modify this parameter according to the following formula:
445 +((System Max AAL5 packet length)/(RxBufSize)) + 2. (The extra two fragments in
446 +the formula allow for RxBufferOffset and one fragment for the ATM Header, used
447 +when receiving host OAM or transparent mode packets)
449 +MAY USE ONLY AFTER HAL IS 'OPEN' (after halOpen() call):
450 +- "Stats;Level;Ch;Queue". The OS may "Get" Stats groups with this key, where
451 +'Level' is an integer from 0-4, Ch is an integer from 0-15, and Queue is
452 +an integer from 0-1. Note that Ch is not required for Level 4 stats, and Queue
453 +is not required for Level 0, 3, and 4. The statistics functionality and return
454 +value is described in the appendix entitled "Configuration and Control".
456 +- "TxVc_CellRate.Ch". The OS may "Set" this value. Can be used to modify
457 +CellRate for a channel on the fly.
459 +- "TxVc_Mbs.Ch". The OS may "Set" this value. Can be used to modify
460 +Mbs for a channel on the fly.
462 +- "TxVc_Pcr.Ch". The OS may "Set" this value. Can be used to modify
463 +Pcr for a channel on the fly.
465 +- "PdspEnable". The OS may "Set" this value. Value 0 disables the PDSP.
466 +Value 1 enables to PDSP.
468 +- "DeviceCPID". The OS may "Set" this value. The Value should be an array
469 +of 4 32-bit integers that comprise the CPID.
471 +- "RxVc_RDICount.Ch". The OS may "Get" or "Set" this value. Get returns
472 +the current RDI count for the VC channel. Set clears the counter, and the Value
475 +- "RxVp_RDICount.Ch". The OS may "Get" or "Set" this value. Get returns
476 +the current RDI count for the VP channel. Set clears the counter, and the Value
479 +- "RxVc_AISseg.Ch". The OS may "Get" this value. This is an indication of
480 +AIS segment error for the VC channel.
482 +- "RxVp_AISseg.Ch". The OS may "Get" this value. This is an indication of
483 +AIS segment error for the VP channel.
485 +- "RxVc_AISetoe.Ch". The OS may "Get" this value. This is an indication of
486 +AIS end-to-end error for the VC channel.
488 +- "RxVp_AISetoe.Ch". The OS may "Get" this value. This is an indication of
489 +AIS end-to-end error for the VP channel.
491 +- "RxVc_OamCh.Ch". The OS may "Set" this value. Channel to which to terminate
492 +received OAM cells to be forwarded to the Host for either Host OAM mode, or when
493 +RxVc_OamToHost is enabled during Firmware OAM mode.
495 +- "RxVp_OamCh.Ch". The OS may "Set" this value. Channel to which to terminate
496 +received OAM cells to be forwarded to the Host for either Host OAM mode, or when
497 +RxVp_OamToHost is enabled during Firmware OAM mode.
499 +- "F4_LB_Counter". The OS may "Get" this value. This is a count of the number
500 + of near-end F4 loopbacks performed by the PDSP in firmware OAM mode.
502 +- "F5_LB_Counter". The OS may "Get" this value. This is a count of the number
503 + of near-end F5 loopbacks performed by the PDSP in firmware OAM mode.
505 +- "TxVc_AtmHeader.Ch". The OS may "Set" this value. In firmware OAM mode, this
506 +is the ATM header to be appended to front of firmware generated VC OAM cells for
507 +this channel. In host OAM mode, this is used as the ATM header to be appended
508 +to front of host generated VC OAM cells for this channel. It must be configured
509 +as big endian with PTI=0. Note: To generate host OAM cells, call @c Send() with
510 +the appropriate mode.
512 +- "TxVp_AtmHeader.Ch". The OS may "Set" this value. In firmware OAM mode, this
513 +is the ATM header to be appended to front of firmware generated VP OAM cells for
514 +this channel. In host OAM mode, this is used as the ATM header to be appended
515 +to front of host generated VP OAM cells for this channel. It must be configured
516 +as big endian with VCI=0. Note: To generate host OAM cells, call @c Send() with
517 +the appropriate mode.
519 +- "PdspEnable". The OS may "Set" this value. Controls whether or not the PDSP is
520 +allowed to fetch new instructions. The PDSP is enabled by the CPHAL during Open(),
521 +and disabled during Close(). 0 = disabled, 1 = enabled.
523 +@par Control() (OS version)
524 +Defined keys and actions:
526 +- "Firmware". The CPHAL will perform a "Get" action for the key "Firmware". A pointer
527 +to a pointer is passed in @p Value. The OS must modify the referenced pointer to point
530 +- "FirmwareSize". The CPHAL will perform a "Get" action for the key "FirmwareSize".
531 +The OS must place the firmware size in the memory pointed at by @p Value.
533 +- "OamLbResult". When a channel that is in firmware OAM mode is commanded to perform
534 +a loopback function, the result of the loopback generates an interrupt that is handled
535 +by the OS like any other interrupt. The CPHAL, upon servicing the interrupt, will call
536 +osControl with this key, and an action of "Set". The @p Value parameter will be a
537 +pointer to the integer result. 1 = pass, 0 = fail.
539 +- "SarFreq". The CPHAL will perform a "Get" action for this key. The OS should place
540 +the SAR frequency (in Hz) in the memory pointed at by @p Value.
542 +@section aal5_stats AAL5 Specific Statistics
544 +Statistics level '0' contains all AAL5 specific statistics. The following values will
545 +be obtained when requesting stats level 0:
547 +- "Crc Errors". Number of CRC errors reported by SAR hardware. Incremented for received
548 +packets that contain CRC errors.
550 +- "Len Errors". Number of length errors reported by SAR hardware. Incremented for received
551 +packets that are in excess of 1366 cells.
553 +- "Abort Errors". Number of abort errors reported by SAR hardware.
555 +- "Starv Errors". Number of buffer starvation errors reported by SAR hardware. Incremented
556 +when a part or all of a buffer cannot be received due to lack of RX buffer resources. The SAR
557 +drops all cells associated with the packet for each buffer starvation error that occurs.
561 +/* register files */
562 +#include "cp_sar_reg.h"
566 +#define _CPPI_TEST /** @todo remove for release */
567 +#define __CPHAL_CPPI_OFFSET /* support use of offset */
569 +/* OS Data Structure definitions */
571 +typedef void OS_PRIVATE;
572 +typedef void OS_DEVICE;
573 +typedef void OS_SENDINFO;
574 +typedef void OS_RECEIVEINFO;
575 +typedef void OS_SETUP;
577 +/* CPHAL Data Structure definitions */
579 +typedef struct hal_device HAL_DEVICE;
580 +typedef struct hal_private HAL_PRIVATE;
581 +typedef struct hal_private HAL_RECEIVEINFO;
583 +/* include CPHAL header files here */
584 +#include "cpcommon_cpaal5.h"
585 +#include "cpswhal_cpaal5.h"
586 +#include "aal5sar.h"
587 +#include "cpcommon_cpaal5.c"
589 +#define CR_SERVICE (170-1)
590 +#define UTOPIA_PAUSE_REG (*(volatile bit32u *)0xa4000000)
593 +these masks are for the mode parameter used in halSend/OsReceive
594 +(may move these elsewhere)
596 +#define CH_MASK 0xff
597 +#define PRI_MASK 0x10000
599 +/* Rcb/Tcb Constants */
600 +#define CB_SOF_BIT (1<<31)
601 +#define CB_EOF_BIT (1<<30)
602 +#define CB_SOF_AND_EOF_BIT (CB_SOF_BIT|CB_EOF_BIT)
603 +#define CB_OWNERSHIP_BIT (1<<29)
604 +#define CB_EOQ_BIT (1<<28)
605 +#define CB_SIZE_MASK 0x0000ffff
606 +#define CB_OFFSET_MASK 0xffff0000
607 +#define RCB_ERRORS_MASK 0x03fe0000
608 +#define RX_ERROR_MASK 0x000f0000
609 +#define CRC_ERROR_MASK 0x00010000
610 +#define LENGTH_ERROR_MASK 0x00020000
611 +#define ABORT_ERROR_MASK 0x00040000
612 +#define STARV_ERROR_MASK 0x00080000
613 +#define TEARDOWN_VAL 0xfffffffc
615 +/* interrupt vector masks */
616 +#define TXH_PEND 0x01000000
617 +#define TXL_PEND 0x02000000
618 +#define RX_PEND 0x04000000
619 +#define STS_PEND 0x08000000
620 +#define AAL2_PEND 0x10000000
621 +#define INT_PENDING (TXH_PEND | TXL_PEND | RX_PEND | STS_PEND | AAL2_PEND)
622 +#define STS_PEND_INVEC 0x0001F000
623 +#define RX_PEND_INVEC 0x00000F00
624 +#define TXL_PEND_INVEC 0x000000F0
625 +#define TXH_PEND_INVEC 0x0000000F
626 +#define AIS_SEG_MASK 0x1 /* +01.02.00 */
627 +#define AIS_SEG_SHIFT 0 /* +01.02.00 */
628 +#define AIS_ETOE_MASK 0x20000 /* +01.02.00 */
629 +#define AIS_ETOE_SHIFT 17 /* +01.02.00 */
630 +#define RDI_CNT_MASK 0xffff0000 /* +01.02.00 */
631 +#define RDI_CNT_SHIFT 16 /* +01.02.00 */
634 + * This function takes a vpi/vci pair and computes the 4 byte atm header
637 + * @param vpi Virtual Path Identifier.
638 + * @param vci Virtual Channel Identifier.
640 + * @return A properly formatted ATM header, without the HEC.
642 +static int atmheader(int gfc, int vpi, int vci, int pti, int clp)
648 + /* UNI Mode uses the GFC field */
649 + itmp |= ((gfc & 0xF) << 28);
650 + itmp |= ((vpi & 0xFF) << 20);
652 + /* if NNI Mode, no gfc and larger VPI */
653 + /*itmp |= ((vpi & 0xFFF) << 20);*/
655 + itmp|=((vci & 0xFFFF) << 4);
656 + itmp|=((pti & 0x7) << 1);
661 +#include "cppi_cpaal5.c"
664 + * Re-entrancy Issues
665 + * In order to ensure successful re-entrancy certain sections of the
666 + * CPHAL code will be bracketed as Critical.
667 + * The OS will provide the function Os.CriticalSection(BOOL), which
668 + * will be passed a TRUE to enter the Critical Section and FALSE to exit.
672 + * @ingroup CPHAL_Functions
673 + * Clears the statistics information.
675 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
677 + * @return 0 OK, Non-zero not OK
679 +static int StatsClear(HAL_DEVICE *HalDev)
683 +#ifdef __CPHAL_DEBUG
686 + dbgPrintf("[aal5]StatsClear(HalDev:%08x)\n", (bit32u)HalDev);
692 + for (i=0; i<NUM_AAL5_CHAN; i++)
694 + HalDev->Stats.CrcErrors[i]=0;
695 + HalDev->Stats.LenErrors[i]=0;
696 + HalDev->Stats.DmaLenErrors[i]=0;
697 + HalDev->Stats.AbortErrors[i]=0;
698 + HalDev->Stats.StarvErrors[i]=0;
699 + HalDev->Stats.TxMisQCnt[i][0]=0;
700 + HalDev->Stats.TxMisQCnt[i][1]=0;
701 + HalDev->Stats.RxMisQCnt[i]=0;
702 + HalDev->Stats.RxEOQCnt[i]=0;
703 + HalDev->Stats.TxEOQCnt[i][0]=0;
704 + HalDev->Stats.TxEOQCnt[i][1]=0;
705 + HalDev->Stats.RxPacketsServiced[i]=0;
706 + HalDev->Stats.TxPacketsServiced[i][0]=0;
707 + HalDev->Stats.TxPacketsServiced[i][1]=0;
708 + HalDev->Stats.TxMaxServiced[i][0]=0;
709 + HalDev->Stats.TxMaxServiced[i][1]=0;
711 + HalDev->Stats.RxTotal=0;
712 + HalDev->Stats.TxTotal=0;
713 + HalDev->Stats.RxMaxServiced=0;
714 + return (EC_NO_ERRORS);
718 + * Returns statistics information.
720 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
725 +static STAT_INFO* StatsGet(HAL_DEVICE *HalDev)
727 + STAT_INFO* MyStats = &HalDev->Stats;
728 +#ifdef __CPHAL_DEBUG
731 + dbgPrintf("[aal5]StatsGet(HalDev:%08x)\n", (bit32u)HalDev);
736 + dbgPrintf("HAL Stats:\n");
737 + DispStat(HalDev, "Rx Total",MyStats->RxTotal);
738 + DispStat(HalDev, "Tx Total",MyStats->TxTotal);
739 + DispStat(HalDev, "Rx Peak",MyStats->RxMaxServiced);
740 + DispStat(HalDev, "TxH Peak",MyStats->TxMaxServiced[0][0]);
741 + DispStat(HalDev, "TxL Peak",MyStats->TxMaxServiced[0][1]);
742 + DispChStat(HalDev, "CrcErr",&MyStats->CrcErrors[0],1);
743 + DispChStat(HalDev, "LenErr",&MyStats->LenErrors[0],1);
744 + DispChStat(HalDev, "DmaLenErr",&MyStats->DmaLenErrors[0],1);
745 + DispChStat(HalDev, "AbortErr",&MyStats->AbortErrors[0],1);
746 + DispChStat(HalDev, "StarvErr",&MyStats->StarvErrors[0],1);
747 + DispChStat(HalDev, "TxH MisQ Cnt",&MyStats->TxMisQCnt[0][0],2);
748 + DispChStat(HalDev, "TxL MisQ Cnt",&MyStats->TxMisQCnt[0][1],2);
749 + DispChStat(HalDev, "Rx MisQ Cnt",&MyStats->RxMisQCnt[0],1);
750 + DispChStat(HalDev, "Rx EOQ Cnt",&MyStats->RxEOQCnt[0],1);
751 + DispChStat(HalDev, "TxH EOQ Cnt",&MyStats->TxEOQCnt[0][0],2);
752 + DispChStat(HalDev, "TxL EOQ Cnt",&MyStats->TxEOQCnt[0][1],2);
753 + DispChStat(HalDev, "Rx Pkts",&MyStats->RxPacketsServiced[0],1);
754 + DispChStat(HalDev, "TxH Pkts",&MyStats->TxPacketsServiced[0][0],2);
755 + DispChStat(HalDev, "TxL Pkts",&MyStats->TxPacketsServiced[0][1],2);
757 + return (&HalDev->Stats);
761 +#ifdef __CPHAL_DEBUG
762 +void dbgChannelConfigDump(HAL_DEVICE *HalDev, int Ch)
764 + CHANNEL_INFO *HalCh = &HalDev->ChData[Ch];
765 + dbgPrintf(" [aal5 Inst %d, Ch %d] Config Dump:\n", HalDev->Inst, Ch);
766 + dbgPrintf(" TxNumBuffers :%08d, TxNumQueues :%08d\n",
767 + HalCh->TxNumBuffers, HalCh->TxNumQueues);
768 + dbgPrintf(" RxNumBuffers :%08d, RxBufSize :%08d\n",
769 + HalCh->RxNumBuffers, HalCh->RxBufSize);
770 + dbgPrintf(" TxServiceMax :%08d, RxServiceMax:%08d\n",
771 + HalCh->TxServiceMax, HalCh->RxServiceMax);
772 + dbgPrintf(" RxBufferOffset:%08d, DaMask :%08d\n",
773 + HalCh->RxBufferOffset, HalCh->DaMask);
774 + dbgPrintf(" CpcsUU :%08d, Gfc :%08d\n",
775 + HalCh->CpcsUU, HalCh->Gfc);
776 + dbgPrintf(" Clp :%08d, Pti :%08d\n",
777 + HalCh->Clp, HalCh->Pti);
778 + dbgPrintf(" Priority :%08d, PktType :%08d\n",
779 + HalCh->Priority, HalCh->PktType);
780 + dbgPrintf(" Vci :%08d, Vpi :%08d\n",
781 + HalCh->Vci, HalCh->Vpi);
782 + dbgPrintf(" TxVc_CellRate :%08d, TxVc_QosType:%08d\n",
783 + HalCh->TxVc_CellRate, HalCh->TxVc_QosType);
784 + dbgPrintf(" TxVc_Mbs :%08d, TxVc_Pcr :%08d\n",
785 + HalCh->TxVc_Mbs, HalCh->TxVc_Pcr);
786 + dbgPrintf(" TxVc_AtmHeader:%08d\n",
787 + HalCh->TxVc_AtmHeader);
793 + * Retrieves channel parameters from configuration file. Any parameters
794 + * which are not found are ignored, and the HAL default value will apply,
795 + * unless a new value is given through the channel structure in the call
798 +static int ChannelConfigGet(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn)
800 + unsigned int Ret, Value, Ch = HalChn->Channel;
801 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
804 +#ifdef __CPHAL_DEBUG
807 + dbgPrintf("[aal5]ChannelConfigGet(HalDev:%08x, HalChn:%08x)\n", (bit32u)HalDev,
813 + Ret=OsFunc->DeviceFindParmValue(HalDev->DeviceInfo, channel_names[Ch], &ChInfo);
814 + if (Ret) return (EC_AAL5|EC_FUNC_CHSETUP|EC_VAL_CH_INFO_NOT_FOUND);
816 + /* i don't care if a value is not found because they are optional */
817 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "TxNumBuffers", &Value);
818 + if (!Ret) HalDev->ChData[Ch].TxNumBuffers = Value;
820 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "TxNumQueues", &Value);
821 + if (!Ret) HalDev->ChData[Ch].TxNumQueues = Value;
823 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "TxServiceMax", &Value);
824 + if (!Ret) HalDev->ChData[Ch].TxServiceMax = Value;
826 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "RxNumBuffers", &Value);
827 + if (!Ret) HalDev->ChData[Ch].RxNumBuffers = Value;
829 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "RxBufferOffset", &Value);
830 + if (!Ret) HalDev->ChData[Ch].RxBufferOffset = Value;
832 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "RxBufSize", &Value);
833 + if (!Ret) HalDev->ChData[Ch].RxBufSize = Value;
835 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "RxServiceMax", &Value);
836 + if (!Ret) HalDev->ChData[Ch].RxServiceMax = Value;
838 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "CpcsUU", &Value);
839 + if (!Ret) HalDev->ChData[Ch].CpcsUU = Value;
841 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "Gfc", &Value);
842 + if (!Ret) HalDev->ChData[Ch].Gfc = Value;
844 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "Clp", &Value);
845 + if (!Ret) HalDev->ChData[Ch].Clp = Value;
847 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "Pti", &Value);
848 + if (!Ret) HalDev->ChData[Ch].Pti = Value;
850 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "DaMask", &Value);
851 + if (!Ret) HalDev->ChData[Ch].DaMask = Value;
853 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "Priority", &Value);
854 + if (!Ret) HalDev->ChData[Ch].Priority = Value;
856 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "PktType", &Value);
857 + if (!Ret) HalDev->ChData[Ch].PktType = Value;
859 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "Vci", &Value);
860 + if (!Ret) HalDev->ChData[Ch].Vci = Value;
862 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "Vpi", &Value);
863 + if (!Ret) HalDev->ChData[Ch].Vpi = Value;
865 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "TxVc_CellRate", &Value);
866 + if (!Ret) HalDev->ChData[Ch].TxVc_CellRate = Value;
868 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "TxVc_QosType", &Value);
869 + if (!Ret) HalDev->ChData[Ch].TxVc_QosType = Value;
871 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "TxVc_Mbs", &Value);
872 + if (!Ret) HalDev->ChData[Ch].TxVc_Mbs = Value;
874 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "TxVc_Pcr", &Value);
875 + if (!Ret) HalDev->ChData[Ch].TxVc_Pcr = Value;
877 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "TxVc_AtmHeader", &Value);
878 + if (!Ret) HalDev->ChData[Ch].TxVc_AtmHeader = Value;
880 + return (EC_NO_ERRORS);
884 + * Sets up channel parameters in the hardware, and initializes the CPPI
885 + * TX and RX buffer descriptors and buffers.
887 +static int ChannelConfigApply(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn)
889 + int j, Ch = HalChn->Channel;
890 + volatile bit32u *pTmp;
891 + int Ret; /* +GSG 030410 */
893 +#ifdef __CPHAL_DEBUG
896 + dbgPrintf("[aal5]ChannelConfigApply(HalDev:%08x, HalChn:%08x)\n", (bit32u)HalDev,
902 + if ((HalDev->ChIsOpen[Ch][DIRECTION_TX] == TRUE) || (HalDev->ChIsOpen[Ch][DIRECTION_RX] == TRUE))
904 + return(EC_AAL5|EC_FUNC_CHSETUP|EC_VAL_CH_ALREADY_OPEN);
907 + HalDev->InRxInt[Ch]=FALSE;
909 + /* Initialize Queue Data */
910 + HalDev->RxActQueueHead[Ch]=0;
911 + HalDev->RxActQueueCount[Ch]=0;
912 + HalDev->TxActQueueHead[Ch][0]=0;
913 + HalDev->TxActQueueHead[Ch][1]=0;
914 + HalDev->TxActQueueCount[Ch][0]=0;
915 + HalDev->TxActQueueCount[Ch][1]=0;
916 + HalDev->RxActive[Ch] = FALSE;
917 + HalDev->TxActive[Ch][0] = FALSE;
918 + HalDev->TxActive[Ch][1] = FALSE;
920 + /* Clear Rx State RAM */
921 + pTmp = pRX_DMA_STATE_WORD_0(HalDev->dev_base) + (Ch*64);
922 + for (j=0; j<NUM_RX_STATE_WORDS; j++)
925 + /* Check that Rx DMA State RAM was cleared */
926 + pTmp -= NUM_RX_STATE_WORDS;
927 + for (j=0; j<NUM_RX_STATE_WORDS; j++)
931 + return(EC_AAL5|EC_FUNC_CHSETUP|EC_VAL_RX_STATE_RAM_NOT_CLEARED);
935 + /* Clear Tx State RAM */
936 + pTmp = pTX_DMA_STATE_WORD_0(HalDev->dev_base) + (Ch*64);
937 + for (j=0; j<NUM_TX_STATE_WORDS; j++)
940 + /* Check that Tx DMA State RAM was cleared */
941 + pTmp -= NUM_TX_STATE_WORDS;
942 + for (j=0; j<NUM_TX_STATE_WORDS; j++)
946 + return(EC_AAL5|EC_FUNC_CHSETUP|EC_VAL_TX_STATE_RAM_NOT_CLEARED);
950 + /* Initialize Tx State RAM (Nothing to do) */
952 + /* Initialize Rx State RAM */
953 + /* Configure the Rx buffer offset */
954 + pTmp=(pRX_DMA_STATE_WORD_0(HalDev->dev_base) + (Ch*64));
955 + *pTmp |= (HalDev->ChData[Ch].RxBufferOffset & 0xFF);
957 + /* Initialize buffer memory for the channel */
958 + Ret = InitTcb(HalDev, Ch);
959 + if (Ret) return (Ret);
961 + Ret = InitRcb(HalDev, Ch);
962 + if (Ret) return (Ret);
964 + /* setup interrupt mask/enable for the channel */
965 + SAR_TX_MASK_SET(HalDev->dev_base) = (1<<Ch);
967 + /* if using the low priority queue, set up mask for it */
968 + if (HalDev->ChData[Ch].TxNumQueues == 2) /* +GSG 030421 */
969 + SAR_TX_MASK_SET(HalDev->dev_base) = (1<<Ch)<<16; /* +GSG 030421 */
971 + SAR_RX_MASK_SET(HalDev->dev_base) = (1<<Ch);
973 + /* call SAR layer to complete the channel setup - hardware configuration of ch */
974 + Ret = HalDev->SarFunc->ChannelSetup(HalDev->SarDev, &HalDev->ChData[Ch]); /* ~GSG 030410 */
975 + if (Ret) /* +GSG 030410 */
976 + return (Ret); /* +GSG 030410 */
978 + /* channel officially open for business */
979 + HalDev->ChIsOpen[Ch][DIRECTION_TX] = TRUE;
980 + HalDev->ChIsOpen[Ch][DIRECTION_RX] = TRUE;
982 + return (EC_NO_ERRORS);
986 + * Sets up HAL default channel configuration parameter values.
988 +static void ChannelConfigInit(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn)
990 + int Ch = HalChn->Channel;
992 +#ifdef __CPHAL_DEBUG
995 + dbgPrintf("[aal5]ChannelConfigInit(HalDev:%08x, HalChn:%08x)\n", (bit32u)HalDev,
1001 + HalDev->ChData[Ch].Channel = Ch;
1002 + HalDev->ChData[Ch].TxNumBuffers = cfg_tx_num_bufs[Ch];
1003 + HalDev->ChData[Ch].RxNumBuffers = cfg_rx_num_bufs[Ch];
1004 + HalDev->ChData[Ch].RxBufSize = cfg_rx_buf_size[Ch];
1005 + HalDev->ChData[Ch].RxBufferOffset = cfg_rx_buf_offset[Ch];
1006 + HalDev->ChData[Ch].TxNumQueues = cfg_tx_num_queues[Ch];
1007 + HalDev->ChData[Ch].CpcsUU = cfg_cpcs_uu[Ch];
1008 + HalDev->ChData[Ch].DaMask = cfg_da_mask[Ch];
1009 + HalDev->ChData[Ch].Priority = cfg_priority[Ch];
1010 + HalDev->ChData[Ch].PktType = cfg_pkt_type[Ch];
1011 + HalDev->ChData[Ch].Vci = cfg_vci[Ch];
1012 + HalDev->ChData[Ch].Vpi = cfg_vpi[Ch];
1013 + HalDev->ChData[Ch].TxVc_CellRate = cfg_cell_rate[Ch];
1014 + HalDev->ChData[Ch].TxVc_QosType = cfg_qos_type[Ch];
1015 + HalDev->ChData[Ch].TxVc_Mbs = cfg_mbs[Ch];
1016 + HalDev->ChData[Ch].TxVc_Pcr = cfg_pcr[Ch];
1017 + HalDev->ChData[Ch].Gfc = cfg_gfc[Ch];
1018 + HalDev->ChData[Ch].Clp = cfg_clp[Ch];
1019 + HalDev->ChData[Ch].Pti = cfg_pti[Ch];
1020 + HalDev->ChData[Ch].RxServiceMax = cfg_rx_max_service[Ch];
1021 + HalDev->ChData[Ch].TxServiceMax = cfg_tx_max_service[Ch];
1025 + * Update per channel data in the HalDev based channel structure.
1026 + * If a certain channel parameter has been passed with the HAL_DEFAULT
1027 + * value (0xFFFFFFFF), then do not copy it.
1029 +static void ChannelConfigUpdate(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn)
1031 + int Ch = HalChn->Channel;
1033 +#ifdef __CPHAL_DEBUG
1036 + dbgPrintf("[aal5]ChannelConfigUpdate(HalDev:%08x, HalChn:%08x)\n", (bit32u)HalDev,
1042 + HalDev->ChData[Ch].Channel = Ch;
1044 + /* ChannelUpdate is a macro defined in cpcommon.h. It requires
1045 + the presence of the variables named 'Ch' and 'HalChn'.*/
1046 + ChannelUpdate(DaMask);
1047 + ChannelUpdate(Priority);
1048 + ChannelUpdate(PktType);
1049 + ChannelUpdate(Vci);
1050 + ChannelUpdate(Vpi);
1051 + ChannelUpdate(CpcsUU);
1052 + ChannelUpdate(Gfc);
1053 + ChannelUpdate(Clp);
1054 + ChannelUpdate(Pti);
1056 + ChannelUpdate(TxNumBuffers);
1057 + ChannelUpdate(RxNumBuffers);
1058 + ChannelUpdate(RxBufSize);
1059 + ChannelUpdate(RxBufferOffset);
1060 + ChannelUpdate(TxNumQueues);
1061 + ChannelUpdate(TxServiceMax);
1062 + ChannelUpdate(RxServiceMax);
1063 + /* PDSP STATE RAM */
1064 + ChannelUpdate(TxVc_CellRate);
1065 + ChannelUpdate(TxVc_QosType);
1066 + ChannelUpdate(TxVc_Mbs);
1067 + ChannelUpdate(TxVc_Pcr);
1069 + ChannelUpdate(TxVc_AtmHeader);
1070 + ChannelUpdate(TxVc_OamTc);
1071 + ChannelUpdate(TxVc_VpOffset);
1072 + ChannelUpdate(RxVc_OamCh);
1073 + ChannelUpdate(RxVc_OamToHost);
1074 + ChannelUpdate(RxVc_AtmHeader);
1075 + ChannelUpdate(RxVc_VpOffset);
1076 + ChannelUpdate(RxVc_OamTc);
1077 + ChannelUpdate(TxVp_AtmHeader);
1078 + ChannelUpdate(TxVp_OamTc);
1079 + ChannelUpdate(RxVp_AtmHeader);
1080 + ChannelUpdate(RxVp_OamCh);
1081 + ChannelUpdate(RxVp_OamTc);
1082 + ChannelUpdate(RxVp_OamToHost);
1083 + ChannelUpdate(RxVp_OamVcList);
1084 + ChannelUpdate(FwdUnkVc);
1088 + * @ingroup CPHAL_Functions
1089 + * This function opens the specified channel. The caller must populate
1090 + * the @p HalCh structure. CPHAL default values may be requested for any or all
1091 + * members of the @p HalCh structure by supplying a value of 0xFFFFFFFF for the
1092 + * given member. The @p OsSetup parameter is a pointer to an OS defined
1093 + * data structure. If the CPHAL later calls @c MallocRxBuffer(), this pointer
1094 + * is returned in that call.
1096 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
1097 + * @param HalCh Per channel information structure. Implementation specific.
1098 + * @param OsSetup Pointer to an OS-defined data structure.
1100 + * @return EC_NO_ERRORS (ok). <BR>
1101 + * Possible Error Codes:<BR>
1102 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
1103 + * @ref EC_VAL_NULL_CH_STRUCT "EC_VAL_NULL_CH_STRUCT"<BR>
1104 + * @ref EC_VAL_INVALID_CH "EC_VAL_INVALID_CH"<BR>
1105 + * @ref EC_VAL_CH_ALREADY_OPEN "EC_VAL_CH_ALREADY_OPEN"<BR>
1106 + * @ref EC_VAL_RX_STATE_RAM_NOT_CLEARED "EC_VAL_RX_STATE_RAM_NOT_CLEARED"<BR>
1107 + * @ref EC_VAL_TX_STATE_RAM_NOT_CLEARED "EC_VAL_TX_STATE_RAM_NOT_CLEARED"<BR>
1108 + * @ref EC_VAL_TCB_MALLOC_FAILED "EC_VAL_TCB_MALLOC_FAILED"<BR>
1109 + * @ref EC_VAL_RCB_MALLOC_FAILED "EC_VAL_RCB_MALLOC_FAILED"<BR>
1110 + * @ref EC_VAL_RX_BUFFER_MALLOC_FAILED "EC_VAL_RX_BUFFER_MALLOC_FAILED"<BR>
1111 + * @ref EC_VAL_LUT_NOT_READY "EC_VAL_LUT_NOT_READY"<BR>
1113 +static int halChannelSetup(HAL_DEVICE *HalDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup)
1117 +#ifdef __CPHAL_DEBUG
1120 + dbgPrintf("[aal5]halChannelSetup(HalDev:%08x, HalCh:%08x, OsSetup:%08x)\n", (bit32u)HalDev,
1121 + (bit32u)HalCh, (bit32u)OsSetup);
1126 + /* Verify proper device state */
1127 + if (HalDev->State < enInitialized)
1128 + return (EC_AAL5|EC_FUNC_CHSETUP|EC_VAL_INVALID_STATE);
1130 + /* We require the channel structure to be passed, even if it only contains
1131 + the channel number */
1132 + if (HalCh == NULL)
1134 + return(EC_AAL5|EC_FUNC_CHSETUP|EC_VAL_NULL_CH_STRUCT);
1137 + Ch = HalCh->Channel;
1139 + if ((Ch < 0) || (Ch > MAX_AAL5_CHAN))
1141 + return(EC_AAL5|EC_FUNC_CHSETUP|EC_VAL_INVALID_CH);
1144 + /* if channel is already open, this call is invalid */
1145 + if ((HalDev->ChIsOpen[Ch][DIRECTION_TX] == TRUE) || (HalDev->ChIsOpen[Ch][DIRECTION_RX] == TRUE))
1147 + return(EC_AAL5|EC_FUNC_CHSETUP|EC_VAL_CH_ALREADY_OPEN);
1150 + /* channel is closed, but might be setup. If so, reopen the hardware channel. */
1151 + if ((HalDev->ChIsSetup[Ch][DIRECTION_TX] == FALSE) && (HalDev->ChIsSetup[Ch][DIRECTION_RX] == FALSE))
1153 + /* Setup channel configuration */
1154 + /* Store OS_SETUP */
1155 + HalDev->ChData[Ch].OsSetup = OsSetup; /* ~GSG 030508 */
1157 + /* setup HAL default values for this channel first */
1158 + ChannelConfigInit(HalDev, HalCh);
1160 + /* retrieve options.conf channel parameters */
1161 + /* currently ignoring return value, making the choice that it's okay if
1162 + the user does not supply channel configuration in the data store */
1163 + ChannelConfigGet(HalDev, HalCh);
1165 + /* update HalDev with data given in HalCh */
1166 + ChannelConfigUpdate(HalDev, HalCh);
1168 +#ifdef __CPHAL_DEBUG
1171 + dbgChannelConfigDump(HalDev, Ch);
1175 + /* HalDev->ChIsSetup[Ch][0] = TRUE; */
1176 + HalDev->ChIsSetup[Ch][DIRECTION_TX] = TRUE;
1177 + HalDev->ChIsSetup[Ch][DIRECTION_RX] = TRUE;
1179 + /* I don't initialize RcbStart or TcbStart here because their values may be
1180 + reused across several Setup/Teardown calls */
1183 + /* If the hardware has been opened (is out of reset), then configure the channel
1184 + in the hardware. NOTE: ChannelConfigApply calls the CPSAR ChannelSetup()! */
1185 + if (HalDev->State == enOpened)
1187 + Ret = ChannelConfigApply(HalDev, HalCh);
1188 + if (Ret) return (Ret);
1191 + return (EC_NO_ERRORS);
1195 + * This function configures the rate at which the OAM timer scheduler
1196 + * channels will be scheduled. The value of OamRate is the number of
1197 + * clock ticks between cell transmissions (if OAM function is sourcing
1198 + * cells), or the number of clock ticks between events or absence of events
1199 + * (if OAM function is sinking cells). The value of i indicates
1200 + * which OAM function to apply the rate to. A list is given below.
1202 + * @par Oam Function Values
1203 + * - 0 : Loopback source
1204 + * - 1 : F4 CC source
1205 + * - 2 : F5 CC source
1206 + * - 3 : F4 CC sink
1207 + * - 4 : F5 CC sink
1208 + * - 5 : F4 TX AIS source
1209 + * - 6 : F5 TX AIS source
1210 + * - 7 : F4 RX RDI source
1211 + * - 8 : F5 RX RDI source
1212 + * - 9 : F4 AIS monitor
1213 + * - 10 : F5 AIS monitor
1215 + * The following is information on how to calculate the OAM rate. There
1216 + * is only one OAM timer that is shared among all channels. Therefore, if
1217 + * you wanted an OAM source function (ex. F4 CC source) to generate 1 cell/sec
1218 + * across 8 channels, you would need to configure the OAM timer to schedule 8
1219 + * cells/sec. In addition, the credits are shared between segment and end-to-end
1220 + * type OAM cells, so if you were sending both types of cells, you would
1221 + * need to configure the OAM timer for 16 cells/sec. However, the clock
1222 + * rate must be specified in clock ticks between events. Using an example
1223 + * clock rate of 125 MHz, the rate in clock ticks can be calculated by
1224 + * dividing 125 Mhz by 16 cells/sec. The results is 7812500 ticks. Thus,
1225 + * every 7812500 clock cycles, an OAM cell will be generated for the F4 CC
1226 + * Source function.
1228 +static void OamRateConfig(HAL_DEVICE *HalDev)
1231 + bit32u OamRate, Freq = HalDev->SarFrequency;
1233 + /* Configure OAM Timer State Block */
1234 + for (i=0; i<NUM_OAM_RATES; i++)
1238 + case 0: OamRate = ((Freq/1000)*HalDev->OamLbTimeout);
1245 + case 8: OamRate = (Freq/38);
1248 + case 4: OamRate = ((Freq*3) + (Freq/2))/38;
1251 + case 10: OamRate = ((Freq*2) + (Freq/2))/38;
1253 + default: OamRate = (Freq*5);
1257 + *(pOAM_TIMER_STATE_WORD_0(HalDev->dev_base) + (i*64) + 1) = OamRate;
1262 + * @ingroup AAL5_Functions
1263 + * This function is used to enable OAM functions (other than loopback) for a
1264 + * particular channel. The channel (embedded within OamConfig - see below) must
1265 + * have been configured for firmware OAM (not host OAM) for these configurations
1266 + * to take effect. More than one function may be enabled at one time.
1267 + * If more than one function is enabled, they must all be of the same level, all
1268 + * F4(VP) or all F5(VC).
1270 + * The usage of the OamConfig parameter is described through the table below. To
1271 + * initiate firmware OAM, set one or more bits in OamConfig corresponding to the
1272 + * various OAM functions. To disable firmware OAM functions, set bit 30 along
1273 + * with any other combination of bits to shutdown various OAM functions at once.
1276 + * e2e - end to end, seg - segment, CC - continuity check,
1277 + * AIS - Alarm Indication Signal
1279 + * @par Bit: Function: Description
1281 + * - 30: Setup/Teardown: 0 - enable, 1 - disable (Note 1)
1282 + * - 29: F4 CC Source seg: 0 - no action, 1 - configure
1283 + * - 28: F4 CC Source e2e: 0 - no action, 1 - configure
1284 + * - 27: F4 AIS Source seg: 0 - no action, 1 - configure
1285 + * - 26: F4 AIS Source e2e: 0 - no action, 1 - configure
1286 + * - 25: F5 CC Source seg: 0 - no action, 1 - configure
1287 + * - 24: F5 CC Source e2e: 0 - no action, 1 - configure
1288 + * - 23: F5 AIS Source seg: 0 - no action, 1 - configure
1289 + * - 22: F5 AIS Source e2e: 0 - no action, 1 - configure
1290 + * - 21: F4 CC Sink seg: 0 - no action, 1 - configure
1291 + * - 20: F4 CC Sink e2e: 0 - no action, 1 - configure
1292 + * - 19: F5 CC Sink seg: 0 - no action, 1 - configure
1293 + * - 18: F5 CC Sink e2e: 0 - no action, 1 - configure
1294 + * - 17:8: Reserved:
1295 + * - 7:0: Channel: AAL5/AAL2 VC/VP channel (Note 2)
1298 + * Note 1: This bit must be clear to enable the specified OAM function.
1299 + * Note 2: This must specify the VC channel for F5 functions, and the VP
1300 + * channel for F4 functions.
1302 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
1303 + * @param OamConfig A 32-bit integer field defined as follows:
1305 +static void halOamFuncConfig(HAL_DEVICE *HalDev, unsigned int OamConfig)
1308 + SAR_PDSP_HOST_OAM_CONFIG_REG(HalDev->dev_base) = OamConfig;
1312 + * @ingroup AAL5_Functions
1313 + * This function is used to enable OAM loopback functions for a particular
1314 + * channel. The channel (embedded within OamConfig - see below) must have been
1315 + * configured for firmware OAM (not host OAM) for these configurations to take
1316 + * effect. Only one loopback function can be enabled at a time.
1318 + * The LLID is inserted into to the OAM cell's LLID field, and it specifies the
1319 + * LLID of the connection point in the network where the generated loopback cell
1320 + * should be turned around. The LLID is composed of 4 32-bit words, and this
1321 + * function expects the caller to pass an array of 4 words in the LLID field.
1322 + * The CorrelationTag is a 32-bit word that the PDSP uses to correlate loopback
1323 + * commands with loopback responses. It should simply be changed for each
1324 + * call, and there is no restriction on the value used for CorrelationTag.
1326 + * The usage of the OamConfig parameter is described through the table below. To
1327 + * initiate firmware OAM, set one of the bits corresponding to the
1328 + * various loopback OAM functions. Note that only one loopback source may be
1329 + * commanded at a time.
1332 + * e2e - end to end, seg - segment, LB - loopback
1334 + * @par Bit: Function: Description
1335 + * - 31:16: Reserved:
1336 + * - 15: F4 LB Source seg: 0 - no action, 1 - configure (Note 1)
1337 + * - 14: F4 LB Source seg: 0 - no action, 1 - configure (Note 1)
1338 + * - 13: F4 LB Source e2e: 0 - no action, 1 - configure (Note 1)
1339 + * - 12: F4 LB Source e2e: 0 - no action, 1 - configure (Note 1)
1340 + * - 11:8: Reserved:
1341 + * - 7:0: Channel: AAL5/AAL2 VC/VP channel (Note 2)
1344 + * Note 1: Only one LB function may be enabled at one time. Once enabled,
1345 + * the PDSP will time out after 5 seconds. The host must wait until it
1346 + * has received the result of the current LB request before initiating
1347 + * a new request. <BR>
1348 + * Note 2: This must specify the VC channel for F5 functions, and the VP
1349 + * channel for F4 functions.
1351 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
1352 + * @param OamConfig A 32-bit integer field defined as follows:
1353 + * @param LLID Loopback Location Identifier (passed as 4 word array).
1354 + * Must be configured in big endian format.
1355 + * @param CorrelationTag 32-bit tag correlates loopback commands with loopback
1356 + * responses. Must be configured in big endian format.
1359 +static void halOamLoopbackConfig(HAL_DEVICE *HalDev, unsigned int OamConfig, unsigned int *LLID, unsigned int CorrelationTag)
1361 + volatile bit32u *tmp;
1363 + /* test to see if this is a loopback command */
1364 + if (OamConfig & 0xf000)
1366 + /* write the OAM correlation tag (GPR 1) */
1367 + SAR_PDSP_OAM_CORR_REG(HalDev->dev_base) = CorrelationTag;
1369 + /* write the LLID */
1370 + tmp = pOAM_CONFIG_BLOCK_WORD_0(HalDev->dev_base);
1372 + /* advance past the CPID */
1381 + SAR_PDSP_HOST_OAM_CONFIG_REG(HalDev->dev_base) = OamConfig;
1386 + * This function allows the host software to access any register directly.
1387 + * Primarily used for debug.
1389 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
1390 + * @param RegOffset Hexadecimal offset to desired register (from device base addr)
1392 + * @return Volatile pointer to desired register.
1394 +static volatile bit32u* halRegAccess(HAL_DEVICE *HalDev, bit32u RegOffset)
1396 + /* compute the register address */
1397 + return ((volatile bit32u *)(HalDev->dev_base + RegOffset));
1400 +#ifdef __CPHAL_DEBUG
1401 +static void dbgConfigDump(HAL_DEVICE *HalDev)
1403 + dbgPrintf(" AAL5 Inst %d Config Dump:\n", HalDev->Inst);
1404 + dbgPrintf(" Base :%08x, offset:%08d\n",
1405 + HalDev->dev_base, HalDev->offset);
1406 + dbgPrintf(" Interrupt:%08d, debug :%08d\n",
1407 + HalDev->interrupt, HalDev->debug);
1413 + * @ingroup CPHAL_Functions
1414 + * Performs a variety of control functions on the CPHAL module. It is used to
1415 + * modify/read configuration parameters and to initiate internal functions.
1416 + * The @p Key indicates the function to perform or the parameter to access (note
1417 + * that these Keys are identical to those used in accessing the configuration data
1418 + * store). @p Action is applicable to parameters only, and indicates what the
1419 + * CPHAL should do with the parameter (i.e. "Set", "Get", etc..). The actions
1420 + * for each parameter are defined in the module specific documentation.
1422 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
1423 + * @param Key Key specifying the parameter to change or internal function to initiate. See module specific documentation for available keys.
1424 + * @param Action Specifies the action to take. See module specific documentation for available actions.
1425 + * @param Value Pointer to new value for given @p Key parameter ("Set"), or returned value of Key ("Get").
1427 + * @return EC_NO_ERRORS (ok).<BR>
1428 + * Possible Error Codes:<BR>
1429 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
1430 + * @ref EC_VAL_KEY_NOT_FOUND "EC_VAL_KEY_NOT_FOUND"<BR>
1431 + * @ref EC_VAL_ACTION_NOT_FOUND "EC_VAL_ACTION_NOT_FOUND"<BR>
1433 +static int halControl(HAL_DEVICE *HalDev, const char *Key, const char *Action, void *Value)
1435 + int Level, Ch, KeyFound=0, ActionFound=0, rc=EC_NO_ERRORS, Queue;
1436 + char *TmpKey = (char *)Key;
1438 +#ifdef __CPHAL_DEBUG
1441 + dbgPrintf("[aal5]halControl(HalDev:%08x, Key:%s, Action:%s, Value:%08x)\n", (bit32u)HalDev,
1442 + Key, Action, (bit32u)Value);
1447 + /* Verify proper device state */
1448 + if (HalDev->State < enInitialized)
1449 + return (EC_AAL5|EC_FUNC_CONTROL|EC_VAL_INVALID_STATE);
1451 + if (HalDev->OsFunc->Strcmpi(Key, "Debug") == 0)
1454 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1457 + HalDev->debug = *(int *)Value;
1458 + /* also setup debug variable in CPSAR module */
1459 + rc = HalDev->SarFunc->Control(HalDev->SarDev, "Debug", "Set", Value);
1463 + if (HalDev->OsFunc->Strstr(Key, "FwdUnkVc.") != 0)
1466 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1470 + /* extract channel number */
1471 + TmpKey += HalDev->OsFunc->Strlen("FwdUnkVc.");
1472 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1474 + HalDev->ChData[Ch].FwdUnkVc = *(int *)Value;
1476 + if ((HalDev->State == enOpened) && (HalDev->ChData[Ch].PktType == 3))
1477 + rc = HalDev->SarFunc->Control(HalDev->SarDev, Key, Action, Value);
1482 + if (HalDev->OsFunc->Strcmpi(Key, "OamMode") == 0)
1485 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1488 + rc = HalDev->SarFunc->Control(HalDev->SarDev, Key, Action, Value);
1491 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1494 + rc = HalDev->SarFunc->Control(HalDev->SarDev, Key, Action, Value);
1499 + if (HalDev->OsFunc->Strcmpi(Key, "Version") == 0)
1502 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1505 + *(const char **)Value = pszVersion_CPAAL5;
1510 + if (HalDev->OsFunc->Strcmpi(Key, "TurboDslErrors") == 0)
1513 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1516 + *(int *)Value = HalDev->TurboDslErrors;
1521 + if (HalDev->OsFunc->Strcmpi(Key, "F4_LB_Counter") == 0)
1524 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1527 + *(int *)Value = SAR_PDSP_OAM_F4_LB_COUNT_REG(HalDev->dev_base);
1532 + if (HalDev->OsFunc->Strcmpi(Key, "F5_LB_Counter") == 0)
1535 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1538 + *(int *)Value = SAR_PDSP_OAM_F5_LB_COUNT_REG(HalDev->dev_base);
1542 + if (HalDev->OsFunc->Strstr(Key, "Stats;") != 0)
1545 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1548 + TmpKey += HalDev->OsFunc->Strlen("Stats;");
1549 + Level = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1551 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1553 + Queue = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1555 + StatsGet(HalDev, (void **)Value, Level, Ch, Queue);
1560 + /* Fixes PITS #100 */
1561 + if (HalDev->OsFunc->Strstr(Key, "Gfc.") != 0)
1564 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1567 + /* extract channel number */
1568 + TmpKey += HalDev->OsFunc->Strlen("Gfc.");
1569 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1571 + /* first, store new value in our channel structure */
1572 + HalDev->ChData[Ch].Gfc = *(int *)Value;
1577 + /* Fixes PITS #100 */
1578 + if (HalDev->OsFunc->Strstr(Key, "Clp.") != 0)
1581 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1584 + /* extract channel number */
1585 + TmpKey += HalDev->OsFunc->Strlen("Clp.");
1586 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1588 + /* first, store new value in our channel structure */
1589 + HalDev->ChData[Ch].Clp = *(int *)Value;
1594 + /* Fixes PITS #100 */
1595 + if (HalDev->OsFunc->Strstr(Key, "Pti.") != 0)
1598 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1601 + /* extract channel number */
1602 + TmpKey += HalDev->OsFunc->Strlen("Pti.");
1603 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1605 + /* first, store new value in our channel structure */
1606 + HalDev->ChData[Ch].Pti = *(int *)Value;
1611 + /* Fixes PITS #100 */
1612 + if (HalDev->OsFunc->Strstr(Key, "CpcsUU.") != 0)
1615 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1618 + /* extract channel number */
1619 + TmpKey += HalDev->OsFunc->Strlen("CpcsUU.");
1620 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1622 + /* first, store new value in our channel structure */
1623 + HalDev->ChData[Ch].CpcsUU = *(int *)Value;
1628 + /* Fixes PITS #100 */
1629 + if (HalDev->OsFunc->Strstr(Key, "TxVc_CellRate.") != 0)
1632 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1635 + /* extract channel number */
1636 + TmpKey += HalDev->OsFunc->Strlen("TxVc_CellRate.");
1637 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1639 + /* first, store new value in our channel structure */
1640 + HalDev->ChData[Ch].TxVc_CellRate = *(int *)Value;
1642 + /* now, apply to PDSP state RAM */
1643 + if (HalDev->State == enOpened)
1644 + *(pPDSP_AAL5_TX_STATE_WORD_0(HalDev->dev_base)+(Ch*64))= HalDev->ChData[Ch].TxVc_CellRate;
1649 + /* Fixes PITS #100 */
1650 + if (HalDev->OsFunc->Strstr(Key, "TxVc_Mbs.") != 0)
1653 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1656 + /* extract channel number */
1657 + TmpKey += HalDev->OsFunc->Strlen("TxVc_Mbs.");
1658 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1660 + /* first, store new value in our channel structure */
1661 + HalDev->ChData[Ch].TxVc_Mbs = *(int *)Value;
1663 + /* now, apply to PDSP state RAM */
1664 + if (HalDev->State == enOpened)
1665 + *(pPDSP_AAL5_TX_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+2)= HalDev->ChData[Ch].TxVc_Mbs;
1669 + if (HalDev->OsFunc->Strstr(Key, "TxVc_AtmHeader.") != 0)
1672 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1675 + /* extract channel number */
1676 + TmpKey += HalDev->OsFunc->Strlen("TxVc_AtmHeader.");
1677 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1679 + /* first, store new value in our channel structure */
1680 + HalDev->ChData[Ch].TxVc_AtmHeader = *(int *)Value;
1682 + /* now, apply to PDSP state RAM */
1683 + if (HalDev->State == enOpened)
1684 + *(pPDSP_AAL5_TX_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+6)= HalDev->ChData[Ch].TxVc_AtmHeader;
1688 + if (HalDev->OsFunc->Strstr(Key, "TxVp_AtmHeader.") != 0)
1691 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1694 + /* extract channel number */
1695 + TmpKey += HalDev->OsFunc->Strlen("TxVp_AtmHeader.");
1696 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1698 + /* first, store new value in our channel structure */
1699 + HalDev->ChData[Ch].TxVp_AtmHeader = *(int *)Value;
1701 + /* now, apply to PDSP state RAM */
1702 + if (HalDev->State == enOpened)
1703 + *(pPDSP_AAL5_TX_VP_STATE_WORD_0(HalDev->dev_base)+(Ch*64))= HalDev->ChData[Ch].TxVp_AtmHeader;
1708 + /* Fixes PITS #100 */
1709 + if (HalDev->OsFunc->Strstr(Key, "TxVc_Pcr.") != 0)
1712 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1715 + /* extract channel number */
1716 + TmpKey += HalDev->OsFunc->Strlen("TxVc_Pcr.");
1717 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1719 + /* first, store new value in our channel structure */
1720 + HalDev->ChData[Ch].TxVc_Pcr = *(int *)Value;
1722 + /* now, apply to PDSP state RAM */
1723 + if (HalDev->State == enOpened)
1724 + *(pPDSP_AAL5_TX_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+4)= HalDev->ChData[Ch].TxVc_Pcr;
1729 + if (HalDev->OsFunc->Strstr(Key, "RxVc_OamCh.") != 0)
1732 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1735 + /* extract channel number */
1736 + TmpKey += HalDev->OsFunc->Strlen("RxVc_OamCh.");
1737 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1739 + /* first, store new value in our channel structure */
1740 + HalDev->ChData[Ch].RxVc_OamCh = (*(int *)Value) & 0xff;
1742 + /* now, apply to PDSP state RAM */
1743 + if (HalDev->State == enOpened)
1744 + *(pPDSP_AAL5_RX_STATE_WORD_0(HalDev->dev_base)+(Ch*64)) |= HalDev->ChData[Ch].RxVc_OamCh;
1749 + if (HalDev->OsFunc->Strstr(Key, "RxVp_OamCh.") != 0)
1752 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1755 + /* extract channel number */
1756 + TmpKey += HalDev->OsFunc->Strlen("RxVp_OamCh.");
1757 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1759 + /* first, store new value in our channel structure */
1760 + HalDev->ChData[Ch].RxVp_OamCh = (*(int *)Value) & 0xff;
1762 + /* now, apply to PDSP state RAM */
1763 + if (HalDev->State == enOpened)
1764 + *(pPDSP_AAL5_RX_VP_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+1) |= HalDev->ChData[Ch].RxVp_OamCh;
1769 + /* Fixes PITS #98 */
1770 + if (HalDev->OsFunc->Strstr(Key, "PdspEnable") != 0)
1773 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1777 + /* this variable is controlled by the CPSAR module */
1778 + if (HalDev->State == enOpened)
1780 + rc=HalDev->SarFunc->Control(HalDev->SarDev, "PdspEnable", "Set", Value);
1785 + if (HalDev->OsFunc->Strstr(Key, "OamLbTimeout") != 0)
1788 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1792 + HalDev->OamLbTimeout = *(int *)Value;
1793 + /* this variable is controlled by the CPSAR module */
1794 + if (HalDev->State == enOpened)
1796 + *(pOAM_TIMER_STATE_WORD_0(HalDev->dev_base) + 1) =
1797 + ((HalDev->SarFrequency/1000) * HalDev->OamLbTimeout);
1802 + /* +GSG 030306 (PITS #114) */
1803 + if (HalDev->OsFunc->Strstr(Key, "DeviceCPID") != 0)
1806 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1808 + unsigned int* local = (unsigned int *)Value;
1810 + /* first, store new value in our hal structure */
1811 + HalDev->DeviceCPID[0] = local[0];
1812 + HalDev->DeviceCPID[1] = local[1];
1813 + HalDev->DeviceCPID[2] = local[2];
1814 + HalDev->DeviceCPID[3] = local[3];
1816 + /* now, apply to PDSP state RAM */
1817 + if (HalDev->State == enOpened)
1819 + *(bit32u *)(pOAM_CONFIG_BLOCK_WORD_0(HalDev->dev_base) + 0) = HalDev->DeviceCPID[0];
1820 + *(bit32u *)(pOAM_CONFIG_BLOCK_WORD_0(HalDev->dev_base) + 1) = HalDev->DeviceCPID[1];
1821 + *(bit32u *)(pOAM_CONFIG_BLOCK_WORD_0(HalDev->dev_base) + 2) = HalDev->DeviceCPID[2];
1822 + *(bit32u *)(pOAM_CONFIG_BLOCK_WORD_0(HalDev->dev_base) + 3) = HalDev->DeviceCPID[3];
1828 + /* Fixes PITS #99 */
1829 + if (HalDev->OsFunc->Strstr(Key, "StrictPriority") != 0)
1832 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1836 + /* used in halOpen to decide which interrupt handler to use */
1837 + HalDev->StrictPriority = *(int *)Value;
1841 + if (HalDev->OsFunc->Strstr(Key, hcMaxFrags) != 0)
1844 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1848 + if ((*(int *)Value) > 0)
1849 + HalDev->MaxFrags = *(int *)Value;
1851 + rc = (EC_AAL5|EC_FUNC_CONTROL|EC_VAL_INVALID_VALUE);
1854 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1858 + *(int *)Value = HalDev->MaxFrags;
1863 + /* Fixes PITS #103 */
1864 + if (HalDev->OsFunc->Strstr(Key, "RxVc_RDICount.") != 0)
1867 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1871 + /* extract channel number */
1872 + TmpKey += HalDev->OsFunc->Strlen("RxVc_RDICount.");
1873 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1875 + /* PDSP's Rx VC State word 3 contains the value */
1876 + if (HalDev->State == enOpened)
1878 + *(int *)Value = (((*(pPDSP_AAL5_RX_STATE_WORD_0(HalDev->dev_base)+(Ch*64))) & RDI_CNT_MASK)>>RDI_CNT_SHIFT);
1881 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1885 + /* extract channel number */
1886 + TmpKey += HalDev->OsFunc->Strlen("RxVc_RDICount.");
1887 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1889 + /* All sets write 0, this action is a clear only */
1890 + if (HalDev->State == enOpened)
1892 + (*(pPDSP_AAL5_RX_STATE_WORD_0(HalDev->dev_base)+(Ch*64))) &=~ RDI_CNT_MASK;
1898 + /* Fixes PITS #103 */
1899 + if (HalDev->OsFunc->Strstr(Key, "RxVc_AISseg.") != 0)
1902 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1906 + /* extract channel number */
1907 + TmpKey += HalDev->OsFunc->Strlen("RxVc_AISseg.");
1908 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1910 + /* PDSP's Rx VC State word 3 contains the value */
1911 + if (HalDev->State == enOpened)
1913 + *(int *)Value = (((*(pPDSP_AAL5_RX_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+3)) & AIS_SEG_MASK)>>AIS_SEG_SHIFT);
1919 + /* Fixes PITS #103 */
1920 + if (HalDev->OsFunc->Strstr(Key, "RxVc_AISetoe.") != 0)
1923 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1927 + /* extract channel number */
1928 + TmpKey += HalDev->OsFunc->Strlen("RxVc_AISetoe.");
1929 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1931 + /* PDSP's Rx VC State word 3 contains the value */
1932 + if (HalDev->State == enOpened)
1934 + *(int *)Value = (((*(pPDSP_AAL5_RX_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+3)) & AIS_ETOE_MASK)>>AIS_ETOE_SHIFT);
1940 + /* Fixes PITS #103 */
1941 + if (HalDev->OsFunc->Strstr(Key, "RxVp_RDICount.") != 0)
1944 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1948 + /* extract channel number */
1949 + TmpKey += HalDev->OsFunc->Strlen("RxVp_RDICount.");
1950 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1952 + /* PDSP's Rx VC State word 3 contains the value */
1953 + if (HalDev->State == enOpened)
1955 + *(int *)Value = (((*(pPDSP_AAL5_RX_VP_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+1)) & RDI_CNT_MASK)>>RDI_CNT_SHIFT);
1958 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1962 + /* extract channel number */
1963 + TmpKey += HalDev->OsFunc->Strlen("RxVp_RDICount.");
1964 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1966 + /* All sets write 0, this action is a clear only */
1967 + if (HalDev->State == enOpened)
1969 + (*(pPDSP_AAL5_RX_VP_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+1)) &=~ RDI_CNT_MASK;
1975 + /* Fixes PITS #103 */
1976 + if (HalDev->OsFunc->Strstr(Key, "RxVp_AISseg.") != 0)
1979 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1983 + /* extract channel number */
1984 + TmpKey += HalDev->OsFunc->Strlen("RxVp_AISseg.");
1985 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1987 + /* PDSP's Rx VC State word 3 contains the value */
1988 + if (HalDev->State == enOpened)
1990 + *(int *)Value = (((*(pPDSP_AAL5_RX_VP_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+2)) & AIS_SEG_MASK)>>AIS_SEG_SHIFT);
1996 + /* Fixes PITS #103 */
1997 + if (HalDev->OsFunc->Strstr(Key, "RxVp_AISetoe.") != 0)
2000 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
2004 + /* extract channel number */
2005 + TmpKey += HalDev->OsFunc->Strlen("RxVp_AISetoe.");
2006 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
2008 + /* PDSP's Rx VC State word 3 contains the value */
2009 + if (HalDev->State == enOpened)
2011 + *(int *)Value = (((*(pPDSP_AAL5_RX_VP_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+2)) & AIS_ETOE_MASK)>>AIS_ETOE_SHIFT);
2016 + if (KeyFound == 0)
2017 + rc = (EC_AAL5|EC_FUNC_CONTROL|EC_VAL_KEY_NOT_FOUND);
2019 + if (ActionFound == 0)
2020 + rc = (EC_AAL5|EC_FUNC_CONTROL|EC_VAL_ACTION_NOT_FOUND);
2026 + * Sets up HAL default configuration parameter values.
2028 +static void ConfigInit(HAL_DEVICE *HalDev)
2030 +#ifdef __CPHAL_DEBUG
2033 + dbgPrintf("[aal5]ConfigInit(HalDev:%08x)\n", (bit32u)HalDev);
2038 + /* configure some defaults with tnetx7300 values */
2039 + HalDev->dev_base = 0xa3000000;
2040 + HalDev->offset = 0;
2041 + HalDev->interrupt = 15;
2042 + HalDev->debug = 0;
2043 + HalDev->MaxFrags = 46;
2044 + HalDev->OamLbTimeout = 5000;
2048 + * Retrieve HAL configuration parameter values.
2050 +static bit32u ConfigGet(HAL_DEVICE *HalDev)
2054 +#ifdef __CPHAL_DEBUG
2057 + dbgPrintf("[aal5]ConfigGet(HalDev:%08x)\n", (bit32u)HalDev);
2062 + /* get the configuration parameters common to all modules */
2063 + Ret = ConfigGetCommon(HalDev);
2064 + if (Ret) return (EC_AAL5|Ret);
2066 + /* get AAL5 specific configuration parameters here */
2067 + Ret = HalDev->OsFunc->Control(HalDev->OsDev, hcSarFrequency, pszGET, &HalDev->SarFrequency); /* GSG +030416*/
2068 + if (Ret) /* GSG +030416*/
2069 + HalDev->SarFrequency = 200000000; /* 200 Mhz default */ /* GSG +030416*/
2071 + return (EC_NO_ERRORS);
2075 + * @ingroup CPHAL_Functions
2076 + * This function initializes the CPHAL module. It gathers all
2077 + * necessary global configuration info from the configuration file, and
2078 + * performs initialization and configuration of the device. Note that
2079 + * the device operation is not started until the OS calls @c Open().
2081 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2083 + * @return EC_NO_ERRORS (ok). <BR>
2084 + * Possible Error Codes:<BR>
2085 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
2086 + * @ref EC_VAL_BASE_ADDR_NOT_FOUND "EC_VAL_BASE_ADDR_NOT_FOUND"<BR>
2087 + * @ref EC_VAL_RESET_BIT_NOT_FOUND "EC_VAL_RESET_BIT_NOT_FOUND"<BR>
2088 + * @ref EC_VAL_INTERRUPT_NOT_FOUND "EC_VAL_INTERRUPT_NOT_FOUND"<BR>
2089 + * @ref EC_VAL_OFFSET_NOT_FOUND "EC_VAL_OFFSET_NOT_FOUND"<BR>
2091 +static int halInit(HAL_DEVICE *HalDev)
2094 + bit32u error_code;
2096 +#ifdef __CPHAL_DEBUG
2099 + dbgPrintf("[aal5]halInit(HalDev:%08x)\n", (bit32u)HalDev);
2104 + /* Verify proper device state */
2105 + if (HalDev->State != enDevFound)
2106 + return(EC_AAL5|EC_FUNC_HAL_INIT|EC_VAL_INVALID_STATE);
2108 + /* Configure HAL defaults */
2109 + ConfigInit(HalDev);
2111 + /* Retrieve HAL configuration parameters from data store */
2112 + error_code = ConfigGet(HalDev);
2113 + if (error_code) return (error_code);
2115 + /* Other items (OAM related) that need to be passed in somehow */
2116 + HalDev->DeviceCPID[0] = 0xffffffff;
2117 + HalDev->DeviceCPID[1] = 0xffffffff;
2118 + HalDev->DeviceCPID[2] = 0xffffffff;
2119 + HalDev->DeviceCPID[3] = 0xffffffff;
2120 + HalDev->LBSourceLLID[0] = 0xffffffff;
2121 + HalDev->LBSourceLLID[1] = 0xffffffff;
2122 + HalDev->LBSourceLLID[2] = 0xffffffff;
2123 + HalDev->LBSourceLLID[3] = 0xffffffff;
2125 + /* Initialize SAR layer*/
2126 + error_code = HalDev->SarFunc->Init(HalDev->SarDev);
2127 + if (error_code) return (error_code);
2129 + /* Initialize various HalDev members. This is probably overkill, since these
2130 + are initialized in ChannelSetup() and HalDev is cleared in InitModule(). */
2131 + for (i=0; i<NUM_AAL5_CHAN; i++)
2133 + HalDev->InRxInt[i]=FALSE;
2134 + HalDev->ChIsOpen[i][DIRECTION_TX] = FALSE;
2135 + HalDev->ChIsOpen[i][DIRECTION_RX] = FALSE;
2136 + HalDev->TcbStart[i][0] = 0;
2137 + HalDev->TcbStart[i][1] = 0;
2138 + HalDev->RcbStart[i] = 0;
2141 + /* initialize SAR stats */
2142 + StatsClear(HalDev);
2144 + /* init Stat pointers */
2146 + /* even though these statistics may be for multiple channels/queues, i need
2147 + only configure the pointer to the beginning of the array, and I can index
2148 + from there if necessary */
2149 + StatsTable0[0].StatPtr = &HalDev->Stats.CrcErrors[0];
2150 + StatsTable0[1].StatPtr = &HalDev->Stats.LenErrors[0];
2151 + StatsTable0[2].StatPtr = &HalDev->Stats.AbortErrors[0];
2152 + StatsTable0[3].StatPtr = &HalDev->Stats.StarvErrors[0];
2154 + StatsTable1[0].StatPtr = &HalDev->Stats.DmaLenErrors[0];
2155 + StatsTable1[1].StatPtr = &HalDev->Stats.TxMisQCnt[0][0];
2156 + StatsTable1[2].StatPtr = &HalDev->Stats.RxMisQCnt[0];
2157 + StatsTable1[3].StatPtr = &HalDev->Stats.TxEOQCnt[0][0];
2158 + StatsTable1[4].StatPtr = &HalDev->Stats.RxEOQCnt[0];
2159 + StatsTable1[5].StatPtr = &HalDev->Stats.RxPacketsServiced[0];
2160 + StatsTable1[6].StatPtr = &HalDev->Stats.TxPacketsServiced[0][0];
2161 + StatsTable1[7].StatPtr = &HalDev->Stats.RxMaxServiced;
2162 + StatsTable1[8].StatPtr = &HalDev->Stats.TxMaxServiced[0][0];
2163 + StatsTable1[9].StatPtr = &HalDev->Stats.RxTotal;
2164 + StatsTable1[10].StatPtr = &HalDev->Stats.TxTotal;
2166 + StatsTable2[0].StatPtr = (bit32u *)&HalDev->RcbPool[0];
2167 + StatsTable2[1].StatPtr = &HalDev->RxActQueueCount[0];
2168 + StatsTable2[2].StatPtr = (bit32u *)&HalDev->RxActQueueHead[0];
2169 + StatsTable2[3].StatPtr = (bit32u *)&HalDev->RxActQueueTail[0];
2170 + StatsTable2[4].StatPtr = &HalDev->RxActive[0];
2171 + StatsTable2[5].StatPtr = (bit32u *)&HalDev->RcbStart[0];
2172 + StatsTable2[6].StatPtr = &HalDev->RxTeardownPending[0];
2173 + StatsTable2[7].StatPtr = (bit32u *)&HalDev->TcbPool[0][0];
2174 + StatsTable2[8].StatPtr = &HalDev->TxActQueueCount[0][0];
2175 + StatsTable2[9].StatPtr = (bit32u *)&HalDev->TxActQueueHead[0][0];
2176 + StatsTable2[10].StatPtr = (bit32u *)&HalDev->TxActQueueTail[0][0];
2177 + StatsTable2[11].StatPtr = &HalDev->TxActive[0][0];
2178 + StatsTable2[12].StatPtr = (bit32u *)&HalDev->TcbStart[0][0];
2179 + StatsTable2[13].StatPtr = &HalDev->TxTeardownPending[0];
2181 + StatsTable4[0].StatPtr = &HalDev->dev_base;
2182 + StatsTable4[1].StatPtr = &HalDev->offset;
2183 + StatsTable4[2].StatPtr = &HalDev->interrupt;
2184 + StatsTable4[3].StatPtr = &HalDev->debug;
2185 + StatsTable4[4].StatPtr = &HalDev->Inst;
2187 + StatsTable3[0].StatPtr = &HalDev->ChData[0].RxBufSize;
2188 + StatsTable3[1].StatPtr = &HalDev->ChData[0].RxBufferOffset;
2189 + StatsTable3[2].StatPtr = &HalDev->ChData[0].RxNumBuffers;
2190 + StatsTable3[3].StatPtr = &HalDev->ChData[0].RxServiceMax;
2191 + StatsTable3[4].StatPtr = &HalDev->ChData[0].TxNumBuffers;
2192 + StatsTable3[5].StatPtr = &HalDev->ChData[0].TxNumQueues;
2193 + StatsTable3[6].StatPtr = &HalDev->ChData[0].TxServiceMax;
2194 + StatsTable3[7].StatPtr = &HalDev->ChData[0].CpcsUU;
2195 + StatsTable3[8].StatPtr = &HalDev->ChData[0].Gfc;
2196 + StatsTable3[9].StatPtr = &HalDev->ChData[0].Clp;
2197 + StatsTable3[10].StatPtr = &HalDev->ChData[0].Pti;
2198 + StatsTable3[11].StatPtr = &HalDev->ChData[0].DaMask;
2199 + StatsTable3[12].StatPtr = &HalDev->ChData[0].Priority;
2200 + StatsTable3[13].StatPtr = &HalDev->ChData[0].PktType;
2201 + StatsTable3[14].StatPtr = &HalDev->ChData[0].Vci;
2202 + StatsTable3[15].StatPtr = &HalDev->ChData[0].Vpi;
2203 + StatsTable3[16].StatPtr = &HalDev->ChData[0].TxVc_CellRate;
2204 + StatsTable3[17].StatPtr = &HalDev->ChData[0].TxVc_QosType;
2205 + StatsTable3[18].StatPtr = &HalDev->ChData[0].TxVc_Mbs;
2206 + StatsTable3[19].StatPtr = &HalDev->ChData[0].TxVc_Pcr;
2208 + /* update device state */
2209 + HalDev->State = enInitialized;
2211 +#ifdef __CPHAL_DEBUG
2213 + dbgConfigDump(HalDev);
2216 + return(EC_NO_ERRORS);
2220 + * Use this function to actually send after queuing multiple packets using
2221 + * Send(). This is a debug only function that should be removed - it was
2222 + * necessary to properly implement my loopback tests.
2224 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2225 + * @param Queue Queue number to kick.
2227 + * @return 0 OK, Non-Zero Not OK
2229 +static int halKick(HAL_DEVICE *HalDev, int Queue)
2233 +#ifdef __CPHAL_DEBUG
2236 + dbgPrintf("[aal5]halKick(HalDev:%08x. Queue:%d)\n", (bit32u)HalDev, Queue);
2241 + for (Ch = 0; Ch < 16; Ch ++)
2243 + if ((!HalDev->TxActive[Ch][Queue]) && (HalDev->TxActQueueHead[Ch][Queue] != 0))
2245 + *(pTX_DMA_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+Queue)=
2246 + VirtToPhys(HalDev->TxActQueueHead[Ch][Queue]);
2247 + HalDev->TxActive[Ch][Queue]=TRUE;
2251 + return (EC_NO_ERRORS);
2254 +/* +GSG 030305 For PITS #99
2255 + * Alternate interrupt handler that uses the INT_VECTOR in order to
2256 + * provide strict priority handling among channels, beginning with Ch 0.
2258 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2259 + * @param MoreWork (Output) When set to 1, indicates that there is more work to do.
2260 + * Caller should ensure that the value pointed at is set to 0
2261 + * prior to the call.
2262 + * @return 0 OK, non-zero error.
2264 +static int DeviceIntAlt(HAL_DEVICE *HalDev, int *MoreWork)
2266 + int tmp, Ch, WorkFlag;
2269 +#ifdef __CPHAL_DEBUG
2272 + dbgPrintf("[aal5]DeviceIntAlt(HalDev:%08x, MoreWork:%08x)\n", (bit32u)HalDev, (bit32u)MoreWork);
2277 + /* Verify proper device state - important because a call prior to Open would
2278 + result in a lockup */
2279 + if (HalDev->State != enOpened)
2280 + return(EC_AAL5|EC_FUNC_DEVICE_INT_ALT|EC_VAL_INVALID_STATE);
2282 + if ((tmp=SAR_INTR_VECTOR(HalDev->dev_base))&INT_PENDING)
2284 + /*printf("\015 %d RxQ",HalDev->RxActQueueCount[0]);
2285 + HalDev->OsFunc->Control(HalDev->OsDev, enSIO_FLUSH, enNULL, 0); */
2289 + /* decide which channel to service */
2290 + Ch = (SAR_INTR_VECTOR(HalDev->dev_base) & TXH_PEND_INVEC);
2292 + rc = TxInt(HalDev,Ch,0,&WorkFlag);
2293 + if (rc) return (rc);
2295 + if (WorkFlag == 1)
2301 + /* decide which channel to service */
2302 + Ch = ((SAR_INTR_VECTOR(HalDev->dev_base) & TXL_PEND_INVEC) >> 4);
2304 + rc = TxInt(HalDev,Ch,1,&WorkFlag);
2305 + if (rc) return (rc);
2307 + if (WorkFlag == 1)
2313 + /* decide which channel to service */
2314 + Ch = ((SAR_INTR_VECTOR(HalDev->dev_base) & RX_PEND_INVEC) >> 8);
2316 + rc = RxInt(HalDev,Ch,&WorkFlag);
2317 + if (rc) return (rc);
2319 + if (WorkFlag == 1)
2325 + /* GPR 2 code added for PITS 103 */
2326 + /* determine interrupt source */
2327 + Ch = ((SAR_INTR_VECTOR(HalDev->dev_base) & STS_PEND_INVEC) >> 12);
2329 + /* only if this is GPR 2 interrupt do we take action */
2332 + /* pass loopback result back to OS */
2333 + HalDev->OsFunc->Control(HalDev->OsDev, "OamLbResult", "Set",
2334 + (bit32u *)pSAR_PDSP_OAM_LB_RESULT_REG(HalDev->dev_base));
2337 + /* clear the interrupt */
2338 + SAR_STATUS_CLR_REG(HalDev->dev_base) |= 0x04000000;
2341 + if (tmp&AAL2_PEND)
2343 + /* no action defined */
2346 + SAR_INTR_VECTOR(HalDev->dev_base) = 0;
2349 + return (EC_NO_ERRORS);
2353 + * Called to service a module interrupt. This function determines
2354 + * what type of interrupt occurred and dispatches the correct handler.
2356 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2357 + * @param MoreWork (Output) When set to 1, indicates that there is more work to do.
2358 + * Caller should ensure that the value pointed at is set to 0
2359 + * prior to the call.
2360 + * @return 0 OK, non-zero error.
2362 +static int DeviceInt(HAL_DEVICE *HalDev, int *MoreWork)
2364 + /*static int NextRxCh=0;
2365 + static int NextTxCh[2]={0,0};*/
2367 + int tmp, Ch, FirstCh, WorkFlag;
2368 + int NextTxLCh, NextTxHCh, NextRxCh;
2371 +#ifdef __CPHAL_DEBUG
2374 + dbgPrintf("[aal5]DeviceInt(HalDev:%08x, MoreWork:%08x)\n", (bit32u)HalDev, (bit32u)MoreWork);
2379 + /* Verify proper device state - important because a call prior to Open would
2380 + result in a lockup */
2381 + if (HalDev->State != enOpened)
2382 + return(EC_AAL5|EC_FUNC_DEVICE_INT|EC_VAL_INVALID_STATE);
2384 + NextTxHCh = HalDev->NextTxCh[0];
2385 + NextTxLCh = HalDev->NextTxCh[1];
2386 + NextRxCh = HalDev->NextRxCh;
2388 + /* service interrupts while there is more work to do */
2389 + /*while (((tmp=SAR_INTR_VECTOR(HalDev->dev_base))&INT_PENDING) && (TotalPkts < 500))*/
2390 + if ((tmp=SAR_INTR_VECTOR(HalDev->dev_base))&INT_PENDING)
2392 + /*printf("\015 %d RxQ",HalDev->RxActQueueCount[0]);
2393 + HalDev->OsFunc->Control(HalDev->OsDev, enSIO_FLUSH, enNULL, 0); */
2397 + /* decide which channel to service */
2398 + FirstCh = NextTxHCh;
2402 + if (NextTxHCh == 16)
2404 + if (SAR_TX_MASKED_STATUS(HalDev->dev_base) & (1<<Ch))
2406 + if (FirstCh == NextTxHCh)
2408 + /* we checked every channel and still haven't found anything to do */
2409 + return (EC_AAL5|EC_FUNC_DEVICE_INT|EC_VAL_NO_TXH_WORK_TO_DO);
2413 + rc = TxInt(HalDev,Ch,0,&WorkFlag);
2414 + if (rc) return (rc);
2416 + if (WorkFlag == 1)
2422 + /* decide which channel to service */
2423 + FirstCh = NextTxLCh;
2427 + if (NextTxLCh == 16)
2429 + if (SAR_TX_MASKED_STATUS(HalDev->dev_base) & (1<<(Ch+16)))
2431 + if (FirstCh == NextTxLCh)
2433 + /* we checked every channel and still haven't found anything to do */
2434 + return (EC_AAL5|EC_FUNC_DEVICE_INT|EC_VAL_NO_TXL_WORK_TO_DO);
2438 + rc = TxInt(HalDev,Ch,1,&WorkFlag);
2439 + if (rc) return (rc);
2441 + if (WorkFlag == 1)
2447 + FirstCh = NextRxCh;
2451 + if (NextRxCh == 16)
2453 + if (SAR_RX_MASKED_STATUS(HalDev->dev_base) & (1 << Ch))
2454 + break; /* found a channel to service */
2455 + if (FirstCh == NextRxCh)
2457 + /* we checked every channel and still haven't found anything to do */
2458 + return (EC_AAL5|EC_FUNC_DEVICE_INT|EC_VAL_NO_RX_WORK_TO_DO);
2462 + rc = RxInt(HalDev,Ch, &WorkFlag);
2463 + if (rc) return (rc);
2465 + if (WorkFlag == 1)
2472 + /* GPR 2 code added for PITS 103 */
2473 + /* determine interrupt source */
2474 + Ch = ((SAR_INTR_VECTOR(HalDev->dev_base) & STS_PEND_INVEC) >> 12);
2476 + /* only if this is GPR 2 interrupt do we take action */
2479 + /* pass loopback result back to OS */
2480 + HalDev->OsFunc->Control(HalDev->OsDev, "OamLbResult", "Set",
2481 + (bit32u *)pSAR_PDSP_OAM_LB_RESULT_REG(HalDev->dev_base));
2484 + /* clear the interrupt */
2485 + SAR_STATUS_CLR_REG(HalDev->dev_base) |= 0x04000000;
2488 + if (tmp&AAL2_PEND)
2490 + /* no action defined */
2493 + SAR_INTR_VECTOR(HalDev->dev_base) = 0;
2496 + HalDev->NextTxCh[0] = NextTxHCh;
2497 + HalDev->NextTxCh[1] = NextTxLCh;
2498 + HalDev->NextRxCh = NextRxCh;
2500 + /* This must be done by the upper layer */
2501 + /* SAR_EOI(HalDev->dev_base) = 0; */
2503 + return (EC_NO_ERRORS);
2507 + * @ingroup CPHAL_Functions
2508 + * This function starts the operation of the CPHAL device. It takes the device
2509 + * out of reset, and calls @c IsrRegister(). This function should be called after
2510 + * calling the @c Init() function.
2512 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2514 + * @return EC_NO_ERRORS (ok).<BR>
2515 + * Possible Error Codes:<BR>
2516 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
2517 + * @ref EC_VAL_KEY_NOT_FOUND "EC_VAL_KEY_NOT_FOUND"<BR>
2518 + * @ref EC_VAL_FIRMWARE_TOO_LARGE "EC_VAL_FIRMWARE_TOO_LARGE"<BR>
2519 + * @ref EC_VAL_PDSP_LOAD_FAIL "EC_VAL_PDSP_LOAD_FAIL"<BR>
2520 + * @ref EC_VAL_RX_STATE_RAM_NOT_CLEARED "EC_VAL_RX_STATE_RAM_NOT_CLEARED"<BR>
2521 + * @ref EC_VAL_TX_STATE_RAM_NOT_CLEARED "EC_VAL_TX_STATE_RAM_NOT_CLEARED"<BR>
2522 + * @ref EC_VAL_TCB_MALLOC_FAILED "EC_VAL_TCB_MALLOC_FAILED"<BR>
2523 + * @ref EC_VAL_RCB_MALLOC_FAILED "EC_VAL_RCB_MALLOC_FAILED"<BR>
2524 + * @ref EC_VAL_RX_BUFFER_MALLOC_FAILED "EC_VAL_RX_BUFFER_MALLOC_FAILED"<BR>
2525 + * @ref EC_VAL_LUT_NOT_READY "EC_VAL_LUT_NOT_READY"<BR>
2527 +static int halOpen(HAL_DEVICE *HalDev)
2530 + bit32 SarBase = HalDev->dev_base;
2532 +#ifdef __CPHAL_DEBUG
2535 + dbgPrintf("[aal5]halOpen(HalDev:%08x)\n", (bit32u)HalDev);
2540 + /* Verify proper device state */
2541 + if (HalDev->State < enInitialized)
2542 + return (EC_AAL5|EC_FUNC_OPEN|EC_VAL_INVALID_STATE);
2544 + /* Open the SAR (this brings the whole device out of reset */
2545 + Ret = HalDev->SarFunc->Open(HalDev->SarDev); /* ~GSG 030410 */
2546 + if (Ret) /* +GSG 030410 */
2547 + return (Ret); /* +GSG 030410 */
2549 + /* Change device state */
2550 + HalDev->State = enOpened;
2553 +#ifdef __CPHAL_DEBUG
2554 + /* print out the version information */
2557 + dbgPrintf("[aal5 halOpen()]Module ID(AAL5-CPSAR):%d, Version:%2d.%02d\n",
2558 + (SAR_ID_REG(SarBase)&0xffff0000)>>16,
2559 + (SAR_ID_REG(SarBase)&0xff00)>>8,
2560 + SAR_ID_REG(SarBase)&0xff);
2565 + /* GREG 11/1/02: The State RAM clearing code was previously in cpsar.c,
2566 + directly after device reset. I moved it here because I believe it is
2567 + AAL5 specific code. Also the MAX_CHAN was set to 19 in cpsar.c, which
2568 + would have caused this code to clear too much memory! */
2570 + /* NOTE: State RAM must be cleared prior to initializing the PDSP!! */
2572 + /* GSG 030416: Removed all of this. All PDSP State RAM is cleared
2573 + in CPSAR Open(). On Close(), all channels are torndown, thus all
2574 + AAL5 channel state RAM is cleared. */
2576 + /* Clear Rx State RAM */
2577 + /*for (i=0; i<NUM_AAL5_CHAN; i++)
2578 + for (j=0; j<NUM_RX_STATE_WORDS; j++)
2579 + *(pRX_DMA_STATE_WORD_0(SarBase) + (i*64) + j) = 0; */
2581 + /* Check that Rx DMA State RAM was cleared */
2582 + /*for (i=0; i<NUM_AAL5_CHAN; i++)
2583 + for (j=0; j<NUM_RX_STATE_WORDS; j++)
2585 + if (*(pRX_DMA_STATE_WORD_0(SarBase) + (i*64) + j) != 0)
2587 + return(EC_AAL5|EC_FUNC_HAL_INIT|EC_VAL_RX_STATE_RAM_NOT_CLEARED);
2591 + /* Clear Tx State RAM */
2592 + /*for (i=0; i<NUM_AAL5_CHAN; i++)
2593 + for (j=0; j<NUM_TX_STATE_WORDS; j++)
2595 + *(pTX_DMA_STATE_WORD_0(SarBase) + (i*64) + j) = 0;
2598 + /* Check that Tx DMA State RAM was cleared */
2599 + /*for (i=0; i<NUM_AAL5_CHAN; i++)
2600 + for (j=0; j<NUM_TX_STATE_WORDS; j++)
2602 + if (*(pTX_DMA_STATE_WORD_0(SarBase) + (i*64) + j) != 0)
2604 + return(EC_AAL5|EC_FUNC_HAL_INIT|EC_VAL_TX_STATE_RAM_NOT_CLEARED);
2608 + /* GSG +030523 Malloc space for the Rx fraglist */
2609 + HalDev->fraglist = HalDev->OsFunc->Malloc(HalDev->MaxFrags * sizeof(FRAGLIST));
2611 + /* For any channels that have been pre-initialized, set them up now */
2612 + for (i=0; i<NUM_AAL5_CHAN; i++)
2614 + if ((HalDev->ChIsSetup[i][0]==TRUE) && (HalDev->ChIsOpen[i][0]==FALSE))
2616 + CHANNEL_INFO HalChn;
2617 + HalChn.Channel = i;
2618 + Ret = ChannelConfigApply(HalDev, &HalChn);
2619 + if (Ret) return (Ret);
2623 + /* OAM code would be a candidate to go into ConfigApply */
2625 + /* Configure OAM Timer State Block */
2626 + OamRateConfig(HalDev); /* +GSG 030416 */
2628 + /* Setup OAM Configuration Block */
2629 + for (i=0; i<8; i++) /* ~GSG 030603 4->8 */
2632 + *(pOAM_CONFIG_BLOCK_WORD_0(SarBase) + i) = HalDev->DeviceCPID[i];
2634 + *(pOAM_CONFIG_BLOCK_WORD_0(SarBase) + i) = HalDev->LBSourceLLID[i-4];
2637 + /* Setup OAM Padding Block */
2638 + for (i=0; i<12; i++)
2640 + *(pOAM_PADDING_BLOCK_WORD_0(SarBase) + i) = ((i==11)?0x6a6a0000:0x6a6a6a6a);
2643 + /* Enable Tx CPPI DMA */
2644 + TX_CPPI_CTL_REG(HalDev->dev_base) = 1;
2646 + /* Enable Rx CPPI DMA */
2647 + RX_CPPI_CTL_REG(HalDev->dev_base) = 1;
2650 + /* Fix for PITS 103 */
2651 + /* Enable Host Interrupt for GPR 2 (OAM LB result register) */
2652 + SAR_HOST_INT_EN_SET_REG(HalDev->dev_base) |= 0x04000000;
2654 + /* +GSG 030304 to fix PITS 99 (if block is new)*/
2655 + if (HalDev->StrictPriority == 1)
2657 +#ifdef __CPHAL_DEBUG
2660 + dbgPrintf("[aal5->os]IsrRegister(OsDev:%08x, halIsr:%08x, Interrupt:%d)\n",
2661 + (bit32u)HalDev->OsDev, (bit32u)DeviceIntAlt, HalDev->interrupt);
2666 + /* "register" the interrupt handler */
2667 + HalDev->OsFunc->IsrRegister(HalDev->OsDev, DeviceIntAlt, HalDev->interrupt);
2669 + else /* +GSG 030306 */
2670 + { /* +GSG 030306 */
2671 +#ifdef __CPHAL_DEBUG
2674 + dbgPrintf("[aal5->os]IsrRegister(OsDev:%08x, halIsr:%08x, Interrupt:%d)\n",
2675 + (bit32u)HalDev->OsDev, (bit32u)DeviceInt, HalDev->interrupt);
2680 + /* "register" the interrupt handler */
2681 + HalDev->OsFunc->IsrRegister(HalDev->OsDev, DeviceInt, HalDev->interrupt);
2682 + } /* +GSG 030306 */
2684 + return(EC_NO_ERRORS);
2688 + * @ingroup CPHAL_Functions
2689 + * Called to retrigger the interrupt mechanism after packets have been
2690 + * processed. Call this function when the HalISR function indicates that
2691 + * there is no more work to do. Proper use of this function will guarantee
2692 + * that interrupts are never missed.
2694 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2696 + * @return EC_NO_ERRORS (ok). <BR>
2698 +static int halPacketProcessEnd(HAL_DEVICE *HalDev)
2700 +#ifdef __CPHAL_DEBUG
2703 + dbgPrintf("[aal5]halPacketProcessEnd(HalDev:%08x)\n", (bit32u)HalDev);
2708 + SAR_EOI(HalDev->dev_base) = 0;
2709 + return (EC_NO_ERRORS);
2713 + * @ingroup CPHAL_Functions
2714 + * This function probes for the instance of the CPHAL module. It will call
2715 + * the OS function @c DeviceFindInfo() to get the information required.
2717 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2719 + * @return EC_NO_ERRORS (ok). <BR>
2720 + * Possible Error Codes:<BR>
2721 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
2722 + * @ref EC_VAL_DEVICE_NOT_FOUND "EC_VAL_DEVICE_NOT_FOUND"<BR>
2724 +static int halProbe(HAL_DEVICE *HalDev)
2728 +#ifdef __CPHAL_DEBUG
2731 + dbgPrintf("[aal5]halProbe(HalDev:%08x)\n", (bit32u)HalDev);
2736 + /* Verify hardware state is "enConnected */
2737 + if (HalDev->State != enConnected)
2738 + return (EC_AAL5|EC_FUNC_PROBE|EC_VAL_INVALID_STATE);
2740 +#ifdef __CPHAL_DEBUG
2743 + dbgPrintf("[aal5->os]DeviceFindInfo(Inst:%d, DeviceName:%s, DeviceInfo:%08x)\n",
2744 + HalDev->Inst, "aal5", (bit32u)&HalDev->DeviceInfo);
2749 + /* Attempt to find the device information */
2750 + Ret = HalDev->OsFunc->DeviceFindInfo(HalDev->Inst, "aal5", &HalDev->DeviceInfo);
2752 + return(EC_AAL5|EC_FUNC_PROBE|EC_VAL_DEVICE_NOT_FOUND);
2754 + /* Call Probe for supporting CPSAR layer */
2755 + Ret = HalDev->SarFunc->Probe(HalDev->SarDev);
2759 + /* Set device state to DevFound */
2760 + HalDev->State = enDevFound;
2762 + return(EC_NO_ERRORS);
2766 + * @ingroup CPHAL_Functions
2767 + * This function shuts down the CPHAL module completely. The caller must call
2768 + * Close() to put the device in reset prior shutting down. This call will free
2769 + * the HalDev and the HAL function pointer structure, effectively ending
2770 + * communications between the driver and the CPHAL. Further use of the module
2771 + * must be initiated by a call to xxxInitModule(), which starts the entire process
2774 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2776 + * @return EC_NO_ERRORS (ok). <BR>
2777 + * Possible Error Codes:<BR>
2778 + * Any error code from halClose().<BR>
2780 +static int halShutdown(HAL_DEVICE *HalDev)
2782 + int Ch, Queue; /*GSG+030514*/
2784 +#ifdef __CPHAL_DEBUG
2787 + dbgPrintf("[aal5]halShutdown(HalDev:%08x)\n", (bit32u)HalDev);
2792 + /* Verify proper device state */
2793 + if (HalDev->State == enOpened)
2794 + halClose(HalDev, 3); /*GSG+030429*/
2796 + /* Buffer/descriptor resources may still need to be freed if a Close
2797 + Mode 1 was performed prior to Shutdown - clean up here */ /*GSG+030514*/
2798 + for (Ch=0; Ch<NUM_AAL5_CHAN; Ch++)
2800 + if (HalDev->RcbStart[Ch] != 0)
2801 + FreeRx(HalDev,Ch);
2803 + for(Queue=0; Queue<MAX_QUEUE; Queue++)
2805 + if (HalDev->TcbStart[Ch][Queue] != 0)
2806 + FreeTx(HalDev,Ch,Queue);
2810 + /* shutdown the CPSAR layer */
2811 + HalDev->SarFunc->Shutdown(HalDev->SarDev);
2813 +#ifdef __CPHAL_DEBUG
2816 + dbgPrintf(" [aal5 halShutdown()]Free AAL5 function pointers\n");
2819 + if (DBG(1)||DBG(3))
2821 + dbgPrintf("[aal5->os]Free(MemPtr:%08x)\n", (bit32u)HalDev->HalFuncPtr);
2825 + /* free the HalFunc */
2826 + HalDev->OsFunc->Free(HalDev->HalFuncPtr);
2828 +#ifdef __CPHAL_DEBUG
2831 + dbgPrintf(" [aal5 halShutdown]Free HalDev\n");
2834 + if (DBG(1)||DBG(3))
2836 + dbgPrintf("[aal5->os]Free(MemPtr:%08x)\n", (bit32u)HalDev);
2840 + /* free the HAL device */
2841 + HalDev->OsFunc->FreeDev(HalDev);
2843 + return(EC_NO_ERRORS);
2847 + * @ingroup CPHAL_Functions
2848 + * Used to perform regular checks on the device. This function should be
2849 + * called at a regular interval specified by the @c Tick parameter.
2851 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2853 + * @return EC_NO_ERRORS (ok).<BR>
2854 + * Possible Error Codes:<BR>
2855 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
2857 +static int halTick(HAL_DEVICE *HalDev)
2859 +#ifdef __CPHAL_DEBUG
2862 + dbgPrintf("[aal5]halTick(HalDev:%08x)\n", (bit32u)HalDev);
2867 + if (HalDev->State != enOpened)
2868 + return(EC_AAL5|EC_FUNC_TICK|EC_VAL_INVALID_STATE);
2870 + return(EC_NO_ERRORS);
2874 + * @ingroup CPHAL_Functions
2876 + * This function will:
2877 + * -# allocate a HalDev that will be used by the OS for future communications with the device
2878 + * -# save OsDev for use when calling OS functions
2879 + * -# allocate and populate HalFunc with the addresses of CPHAL functions.
2880 + * -# check OsFuncSize to see if it meets the minimum requirement.
2881 + * -# return the size of the HAL_FUNCTIONS structure through the HalFuncSize pointer. The OS
2882 + * should check this value to ensure that the HAL meets its minimum requirement.
2884 + * Version checking between the OS and the CPHAL is done using the OsFuncSize and
2885 + * HalFuncSize. Future versions of the CPHAL may add new functions to either
2886 + * HAL_FUNCTIONS or OS_FUNCTIONS, but will never remove functionality. This enables
2887 + * both the HAL and OS to check the size of the function structure to ensure that
2888 + * the current OS and CPHAL are compatible.
2890 + * Note: This is the only function exported by a CPHAL module.
2892 + * Please refer to the section "@ref hal_init" for example code.
2894 + * @param HalDev Pointer to pointer to CPHAL module information. This will
2895 + * be used by the OS when communicating to this module via
2896 + * CPHAL. Allocated during the call.
2897 + * @param OsDev Pointer to OS device information. This will be saved by
2898 + * the CPHAL and returned to the OS when required.
2899 + * @param HalFunc Pointer to pointer to structure containing function pointers for all CPHAL
2900 + * interfaces. Allocated during the call.
2901 + * @param OsFunc Pointer to structure containing function pointers for all OS
2902 + * provided interfaces. Must be allocated by OS prior to call.
2903 + * @param OsFuncSize Size of OS_FUNCTIONS structure.
2904 + * @param HalFuncSize Pointer to the size of the HAL_FUNCTIONS structure.
2905 + * @param Inst The instance number of the module to initialize. (start at
2908 + * @return EC_NO_ERRORS (ok). <BR>
2909 + * Possible Error Codes:<BR>
2910 + * @ref EC_VAL_OS_VERSION_NOT_SUPPORTED "EC_VAL_OS_VERSION_NOT_SUPPORTED"<BR>
2911 + * @ref EC_VAL_MALLOC_DEV_FAILED "EC_VAL_MALLOC_DEV_FAILED"<BR>
2912 + * @ref EC_VAL_MALLOC_FAILED "EC_VAL_MALLOC_FAILED"<BR>
2914 +int xxxInitModule(HAL_DEVICE **HalDev,
2916 + HAL_FUNCTIONS **HalFunc,
2917 + OS_FUNCTIONS *OsFunc,
2922 +int cpaal5InitModule(HAL_DEVICE **HalDev,
2924 + HAL_FUNCTIONS **HalFunc,
2925 + OS_FUNCTIONS *OsFunc,
2930 + int rc, SarFuncSize;
2931 + HAL_DEVICE *HalPtr;
2932 + HAL_FUNCTIONS *HalFuncPtr;
2935 + if (OsFuncSize < sizeof(OS_FUNCTIONS))
2936 + return (EC_AAL5|EC_FUNC_HAL_INIT|EC_VAL_OS_VERSION_NOT_SUPPORTED);
2938 + HalPtr = (HAL_DEVICE *) OsFunc->MallocDev(sizeof(HAL_DEVICE));
2940 + return (EC_AAL5|EC_FUNC_HAL_INIT|EC_VAL_MALLOC_DEV_FAILED);
2942 + HalFuncPtr = (HAL_FUNCTIONS *) OsFunc->Malloc(sizeof(HAL_FUNCTIONS));
2944 + return (EC_AAL5|EC_FUNC_HAL_INIT|EC_VAL_MALLOC_FAILED);
2946 + /* Initialize the size of hal functions */
2947 + *HalFuncSize = sizeof (HAL_FUNCTIONS);
2949 + /* clear the device structure */
2950 + OsFunc->Memset(HalPtr, 0, sizeof(HAL_DEVICE));
2952 + /* clear the function pointers */
2953 + OsFunc->Memset(HalFuncPtr, 0, sizeof(HAL_FUNCTIONS));
2955 + /* initialize the HAL_DEVICE structure */
2956 + HalPtr->OsDev = OsDev;
2957 + /*HalPtr->OsOpen = OsDev;*/
2958 + HalPtr->Inst = Inst;
2959 + HalPtr->OsFunc = OsFunc;
2961 + /* Supply pointers for the CPHAL API functions */
2962 + HalFuncPtr->RxReturn = halRxReturn;
2963 + HalFuncPtr->Init = halInit;
2964 + HalFuncPtr->Close = halClose;
2965 + HalFuncPtr->Send = halSend;
2966 + HalFuncPtr->ChannelSetup = halChannelSetup;
2967 + HalFuncPtr->ChannelTeardown = halChannelTeardown;
2968 + HalFuncPtr->Open = halOpen;
2969 + HalFuncPtr->Kick = halKick;
2970 + HalFuncPtr->RegAccess = halRegAccess;
2971 + HalFuncPtr->Probe = halProbe;
2972 + HalFuncPtr->Control = halControl;
2973 + HalFuncPtr->Tick = halTick;
2974 + HalFuncPtr->Shutdown = halShutdown;
2975 + HalFuncPtr->OamFuncConfig = halOamFuncConfig; /* +GSG 030306 */
2976 + HalFuncPtr->OamLoopbackConfig = halOamLoopbackConfig; /* ~GSG 030416 */
2979 + /*HalFuncPtr->StatsGetOld = StatsGet;*/
2980 + HalFuncPtr->PacketProcessEnd = halPacketProcessEnd;
2982 + /* Now, AAL5 must connect to the CPSAR layer */
2984 + /* Attach to SAR HAL Functions */
2986 + cpsarInitModule(NULL, NULL, 0, NULL, &SarFuncSize, Inst);
2988 + if (SarFuncSize!=sizeof(CPSAR_FUNCTIONS))
2989 + return(EC_AAL5|EC_FUNC_HAL_INIT|EC_VAL_CPSAR_VERSION_NOT_SUPPORTED);
2991 + HalPtr->SarFunc = (CPSAR_FUNCTIONS *) OsFunc->Malloc(SarFuncSize);
2994 + rc = cpsarInitModule(&HalPtr->SarDev, OsDev, &HalPtr->SarFunc, OsFunc, sizeof(OS_FUNCTIONS), &SarFuncSize, Inst);
2996 + /* pass back the error value from the CPSAR layer if necessary */
3001 + if (!HalPtr->SarDev)
3002 + return(EC_AAL5|EC_FUNC_HAL_INIT|EC_VAL_NULL_CPSAR_DEV);
3005 + /* Initialize the hardware state */
3006 + HalPtr->State = enConnected;
3008 + /* keep a reference to HalFuncPtr so I can free it later */
3009 + HalPtr->HalFuncPtr = HalFuncPtr;
3011 + /* pass the HalPtr back to the caller */
3013 + *HalFunc = HalFuncPtr;
3015 + return(EC_NO_ERRORS);
3017 diff -urN linux.old/drivers/atm/sangam_atm/aal5sar.h linux.dev/drivers/atm/sangam_atm/aal5sar.h
3018 --- linux.old/drivers/atm/sangam_atm/aal5sar.h 1970-01-01 01:00:00.000000000 +0100
3019 +++ linux.dev/drivers/atm/sangam_atm/aal5sar.h 2005-07-10 08:02:01.421114856 +0200
3021 +/**@file************************************************************************
3022 + * TNETDxxxx Software Support
3023 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
3028 + * This file contains data structure definitions for the AAL5 HAL SAR.
3031 + * 28Feb02 Greg 1.00 Original Version created.
3032 + * 06Mar02 Greg 1.01 Documented structures.
3033 + * 18Jul02 Greg 1.02 Major reorganization
3035 + *****************************************************************************/
3036 +#ifndef _INC_AAL5SAR
3037 +#define _INC_AAL5SAR
3039 +/** \namespace AAL5_Version
3040 +This documents version 01.06.06 of the AAL5 CPHAL.
3042 +const char *pszVersion_CPAAL5="CPAAL5 01.06.06 "__DATE__" "__TIME__;
3044 +#include "cpsar_cpaal5.h"
3046 +#define NUM_AAL5_CHAN 16
3047 +#define MAX_AAL5_CHAN 15
3048 +#define MAX_QUEUE 2
3049 +#define MAX_DIRECTION 2
3051 +#define PKT_TYPE_AAL5 0 /* +GSG 030508 */
3052 +#define PKT_TYPE_NULL 1 /* +GSG 030508 */
3053 +#define PKT_TYPE_OAM 2 /* +GSG 030508 */
3054 +#define PKT_TYPE_TRANS 3 /* +GSG 030508 */
3055 +#define ATM_HEADER_SIZE 4 /* +GSG 030508 */
3058 + * HAL Default Parameter Values
3060 +#define CFG_TX_NUM_BUFS {256,256,256,256,256,256,256,256, 256,256,256,256,256,256,256,256}
3061 +#define CFG_RX_NUM_BUFS {256,256,256,256,256,256,256,256, 256,256,256,256,256,256,256,256}
3062 +#define CFG_RX_BUF_SIZE {1518,1518,1518,1518,1518,1518,1518,1518, 1518,1518,1518,1518,1518,1518,1518,1518}
3063 +#define CFG_RX_BUF_OFFSET {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3064 +#define CFG_TX_NUM_QUEUES {1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1}
3065 +#define CFG_CPCS_UU {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3066 +#define CFG_DA_MASK {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3067 +#define CFG_PRIORITY {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3068 +#define CFG_PKT_TYPE {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3069 +#define CFG_VCI {100,101,102,103,104,105,106,107, 108,109,110,111,112,113,114,115}
3070 +#define CFG_VPI {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3071 +#define CFG_CELL_RATE {0x30d4,0x30d4,0x30d4,0x30d4,0x30d4,0x30d4,0x30d4,0x30d4, 0x30d4,0x30d4,0x30d4,0x30d4,0x30d4,0x30d4,0x30d4,0x30d4}
3072 +#define CFG_QOS_TYPE {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3073 +#define CFG_MBS {8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8}
3074 +#define CFG_PCR {1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1}
3075 +#define CFG_GFC {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3076 +#define CFG_CLP {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3077 +#define CFG_PTI {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3078 +#define CFG_RX_MAX_SERVICE {170,170,170,170,170,170,170,170, 170,170,170,170,170,170,170,170}
3079 +#define CFG_TX_MAX_SERVICE {170,170,170,170,170,170,170,170, 170,170,170,170,170,170,170,170}
3081 +static int cfg_tx_num_bufs[NUM_AAL5_CHAN] = CFG_TX_NUM_BUFS;
3082 +static int cfg_rx_num_bufs[NUM_AAL5_CHAN] = CFG_RX_NUM_BUFS;
3083 +static int cfg_rx_buf_size[NUM_AAL5_CHAN] = CFG_RX_BUF_SIZE;
3084 +static int cfg_rx_buf_offset[NUM_AAL5_CHAN] = CFG_RX_BUF_OFFSET;
3085 +static int cfg_tx_num_queues[NUM_AAL5_CHAN] = CFG_TX_NUM_QUEUES;
3086 +static bit32u cfg_cpcs_uu[NUM_AAL5_CHAN] = CFG_CPCS_UU;
3087 +static int cfg_da_mask[NUM_AAL5_CHAN] = CFG_DA_MASK;
3088 +static int cfg_priority[NUM_AAL5_CHAN] = CFG_PRIORITY;
3089 +static int cfg_pkt_type[NUM_AAL5_CHAN] = CFG_PKT_TYPE;
3090 +static int cfg_vci[NUM_AAL5_CHAN] = CFG_VCI;
3091 +static int cfg_vpi[NUM_AAL5_CHAN] = CFG_VPI;
3092 +static bit32u cfg_cell_rate[NUM_AAL5_CHAN] = CFG_CELL_RATE;
3093 +static int cfg_qos_type[NUM_AAL5_CHAN] = CFG_QOS_TYPE;
3094 +static int cfg_mbs[NUM_AAL5_CHAN] = CFG_MBS;
3095 +static int cfg_pcr[NUM_AAL5_CHAN] = CFG_PCR;
3096 +static int cfg_gfc[NUM_AAL5_CHAN] = CFG_GFC;
3097 +static int cfg_clp[NUM_AAL5_CHAN] = CFG_CLP;
3098 +static int cfg_pti[NUM_AAL5_CHAN] = CFG_PTI;
3099 +static int cfg_rx_max_service[NUM_AAL5_CHAN]= CFG_RX_MAX_SERVICE;
3100 +static int cfg_tx_max_service[NUM_AAL5_CHAN]= CFG_TX_MAX_SERVICE;
3101 +static char *channel_names[] = CHANNEL_NAMES;
3104 + * The HAL_FUNCTIONS struct defines the function pointers for all HAL functions
3105 + * accessible to upper layer software. It is populated by calling
3106 + * halInitModules().
3108 + * Note that this list is still under definition.
3112 + * This is the data structure for a transmit buffer descriptor. The first
3113 + * four 32-bit words of the BD represent the CPPI 3.0 defined buffer descriptor
3114 + * words. The other words are SAR/HAL implementation specific.
3118 + bit32 HNext; /**< Hardware's pointer to next buffer descriptor */
3119 + bit32 BufPtr; /**< Pointer to the data buffer */
3120 + bit32 Off_BLen; /**< Contains buffer offset and buffer length */
3121 + bit32 mode; /**< SOP, EOP, Ownership, EOQ, Teardown Complete bits */
3122 + bit32 AtmHeader; /**< Atm Header to be used for each fragment */
3123 + bit32 Word5; /**< General control information for the packet */
3128 +#ifdef __CPHAL_DEBUG
3131 + bit32 DbgFraglist;
3137 + * This is the data structure for a receive buffer descriptor. The first
3138 + * six 32-bit words of the BD represent the CPPI 3.0 defined buffer descriptor
3139 + * words. The other words are HAL implementation specific.
3141 +typedef volatile struct hal_private
3143 + bit32 HNext; /**< Hardware's pointer to next buffer descriptor */
3144 + bit32 BufPtr; /**< Pointer to the data buffer */
3145 + bit32 Off_BLen; /**< Contains buffer offset and buffer length */
3146 + bit32 mode; /**< SOP, EOP, Ownership, EOQ, Teardown, Q Starv, Length */
3157 + HAL_DEVICE *HalDev;
3161 +#define MAX_NEEDS 512 /*MJH+030409*/
3163 + * This is the data structure for a generic HAL device. It contains all device
3164 + * specific data for a single instance of that device. This includes Rx/Tx
3165 + * buffer queues, device base address, reset bit, and other information.
3167 +typedef struct hal_device
3169 + HAL_RCB *RcbPool[NUM_AAL5_CHAN];
3171 + bit32 RxActQueueCount[NUM_AAL5_CHAN];
3172 + HAL_RCB *RxActQueueHead[NUM_AAL5_CHAN];
3173 + HAL_RCB *RxActQueueTail[NUM_AAL5_CHAN];
3174 + bit32 RxActive[NUM_AAL5_CHAN];
3176 + HAL_TCB *TcbPool[NUM_AAL5_CHAN][MAX_QUEUE];
3178 + bit32 TxActQueueCount[NUM_AAL5_CHAN][MAX_QUEUE];
3179 + HAL_TCB *TxActQueueHead[NUM_AAL5_CHAN][MAX_QUEUE];
3180 + HAL_TCB *TxActQueueTail[NUM_AAL5_CHAN][MAX_QUEUE];
3181 + bit32 TxActive[NUM_AAL5_CHAN][MAX_QUEUE];
3182 + bit32 TxTeardownPending[NUM_AAL5_CHAN];
3183 + bit32 RxTeardownPending[NUM_AAL5_CHAN];
3184 + bit32 ChIsOpen[NUM_AAL5_CHAN][MAX_DIRECTION];
3185 + bit32 ChIsSetup[NUM_AAL5_CHAN][MAX_DIRECTION];
3189 + OS_FUNCTIONS *OsFunc;
3190 + CPSAR_FUNCTIONS *SarFunc;
3191 + CPSAR_DEVICE *SarDev;
3193 + /*FRAGLIST fraglist[MAX_FRAG];*/
3194 + FRAGLIST *fraglist;
3195 + char *TcbStart[NUM_AAL5_CHAN][MAX_QUEUE];
3196 + char *RcbStart[NUM_AAL5_CHAN];
3197 + /*bit32 RcbSize[NUM_AAL5_CHAN];*/
3198 + bit32 InRxInt[NUM_AAL5_CHAN];
3201 + bit32u DeviceCPID[4];
3202 + bit32u LBSourceLLID[4];
3203 + CHANNEL_INFO ChData[NUM_AAL5_CHAN];
3204 + DEVICE_STATE State;
3206 + HAL_FUNCTIONS *HalFuncPtr;
3209 + int StrictPriority; /* +GSG 030304 */
3210 + bit32u NeedsCount; /*MJH+030409*/
3211 + HAL_RECEIVEINFO *Needs[MAX_NEEDS]; /*MJH+030409*/
3212 + bit32u SarFrequency; /* +GSG 030416 */
3214 + bit32u TurboDslErrors;
3215 + bit32u OamLbTimeout;
3219 diff -urN linux.old/drivers/atm/sangam_atm/cpcommon_cpaal5.c linux.dev/drivers/atm/sangam_atm/cpcommon_cpaal5.c
3220 --- linux.old/drivers/atm/sangam_atm/cpcommon_cpaal5.c 1970-01-01 01:00:00.000000000 +0100
3221 +++ linux.dev/drivers/atm/sangam_atm/cpcommon_cpaal5.c 2005-07-10 08:02:01.422114704 +0200
3223 +#ifndef _INC_CPCOMMON_C
3224 +#define _INC_CPCOMMON_C
3226 +#ifdef _CPHAL_CPMAC
3227 +#include "cpremap_cpmac.c"
3231 +#include "cpremap_cpaal5.c"
3234 +#ifdef _CPHAL_CPSAR
3235 +#include "cpremap_cpsar.c"
3239 +#include "cpremap_cpaal2.c"
3243 +@defgroup Common_Config_Params Common Configuration Parameters
3245 +This section documents the configuration parameters that are valid across
3249 +/** This is the debug level. The field is bit defined, such that the user
3250 +should set to 1 all the bits corresponding to desired debug outputs. The following
3251 +are the meanings for each debug bit:
3252 +- bit0 (LSB): CPHAL Function Trace
3253 +- b1 : OS Function call trace
3254 +- b2 : Critical section entry/exit
3255 +- b3 : Memory allocation/destruction
3256 +- b4 : Detailed information in Rx path
3257 +- b5 : Detailed information in Tx path
3258 +- b6 : Extended error information
3259 +- b7 : General info
3261 +static const char pszDebug[] = "debug";
3262 +/** CPU Frequency. */
3263 +/*static const char pszCpuFreq[] = "CpuFreq";*/ /*MJH-030403*/
3264 +/** Base address for the module. */
3265 +static const char pszBase[] = "base";
3266 +/** Reset bit for the module. */
3267 +static const char pszResetBit[] = "reset_bit";
3268 +/** Reset base address for the module. */
3269 +static const char pszResetBase[] = "ResetBase";
3270 +/** Interrupt line for the module. */
3271 +static const char pszIntLine[] = "int_line";
3272 +/** VLYNQ offset for the module. Disregard if not using VLYNQ. */
3273 +static const char pszOffset[] = "offset";
3274 +/** The OS may "Get" this parameter, which is a pointer
3275 + to a character string that indicates the version of CPHAL. */
3276 +static const char pszVer[] = "Version";
3280 +@defgroup Common_Control_Params Common Keys for [os]Control()
3282 +This section documents the keys used with the OS @c Control() interface that
3283 +are required by CPHAL devices.
3287 +/** Used to wait for an integer number of clock ticks, given as an integer
3288 + pointer in the @p Value parameter. No actions are defined. */
3289 +static const char pszSleep[] = "Sleep";
3290 +/** Requests the OS to flush it's IO buffers. No actions are defined. */
3291 +static const char pszSioFlush[] = "SioFlush";
3294 +static const char pszStateChange[] = "StateChange";
3295 +static const char pszStatus[] = "Status";
3297 +static const char pszGET[] = "Get";
3298 +static const char pszSET[] = "Set";
3299 +static const char pszCLEAR[] = "Clear";
3300 +static const char pszNULL[] = "";
3301 +static const char pszLocator[] = "Locator";
3302 +static const char pszOff[] = "Off";
3303 +static const char pszOn[] = "On";
3304 +static const char hcMaxFrags[] = "MaxFrags";
3306 +#ifdef _CPHAL_CPMAC
3308 +/* New method for string constants */
3309 +const char hcClear[] = "Clear";
3310 +const char hcGet[] = "Get";
3311 +const char hcSet[] = "Set";
3313 +const char hcTick[] = "Tick";
3315 +static const CONTROL_KEY KeyCommon[] =
3317 + {"" , enCommonStart},
3318 + {pszStatus , enStatus},
3321 + {pszDebug , enDebug},
3322 + {hcCpuFrequency , enCpuFreq}, /*MJH~030403*/
3323 + {"" , enCommonEnd}
3328 +@defgroup Common_Statistics Statistics
3330 +A broad array of module statistics is available. Statistics values are accessed
3331 +through the @c Control() interface of the CPHAL. There are 5 different levels
3332 +of statistics, each of which correspond to a unique set of data. Furthermore,
3333 +certain statistics data is indexed by using a channel number and Tx queue number.
3334 +The following is a brief description of each statistics level, along with the
3335 +indexes used for the level:
3337 +- Level 0: Hardware Statistics (index with channel)
3338 +- Level 1: CPHAL Software Statistics (channel, queue)
3339 +- Level 2: CPHAL Flags (channel, queue)
3340 +- Level 3: CPHAL Channel Configuration (channel)
3341 +- Level 4: CPHAL General Configuration (no index)
3343 +The caller requests statistics information by providing a Key string to the
3344 +@c Control() API in the following format: "Stats;[Level #];[Ch #];[Queue #]".
3345 +The only valid Action parameter for statistics usage is "Get".
3349 +unsigned int *StatsData;
3351 +# Get Level 0 stats for Channel 1
3352 +HalFunc->Control(OsDev->HalDev, "Stats;0;1", "Get", &StatsData);
3354 +# Get Level 2 stats for Channel 0, Queue 0
3355 +HalFunc->Control(OsDev->HalDev, "Stats;2;0;0", "Get", &StatsData);
3357 +# Get Level 4 stats
3358 +HalFunc->Control(OsDev->HalDev, "Stats;4", "Get", &StatsData);
3361 +The information returned in the Value parameter of @c Control() is an
3362 +array of pointers to strings. The pointers are arranged in pairs.
3363 +The first pointer is a pointer to a name string for a particular statistic.
3364 +The next pointer is a pointer to a string containing the representation of
3365 +the integer statistic value corresponding to the first pointer. This is followed
3366 +by another pair of pointers, and so on, until a NULL pointer is encountered. The
3367 +following is example code for processing the statistics data. Note that the OS
3368 +is responsible for freeing the memory passed back through the Value parameter of
3372 +unsigned int *StatsData;
3374 +# Get Level 0 stats for Channel 1
3375 +HalFunc->Control(OsDev->HalDev, "Stats;0;1", "Get", &StatsData);
3377 +# output Statistics data
3378 +PrintStats(StatsData);
3380 +# the upper layer is responsible for freeing stats info
3385 +void PrintStats(unsigned int *StatsPtr)
3389 + printf("%20s:", (char *)*StatsPtr);
3391 + printf("%11s\n", (char *)*StatsPtr);
3398 +Within each statistics level, there are several statistics defined. The statistics that
3399 +are common to every CPPI module are listed below. In addition, each module may define
3400 +extra statistics in each level, which will be documented within the module-specific
3401 +documentation appendices.
3403 +- Level 0 Statistics
3404 + - All level 0 statistics are module-specific.
3405 +- Level 1 Statistics (CPHAL Software Statistics)
3406 + - DmaLenErrors: Incremented when the port DMA's more data than expected (per channel). (AAL5 Only)
3407 + - TxMisQCnt: Incremented when host queues a packet for transmission as the port finishes
3408 +transmitting the previous last packet in the queue (per channel and queue).
3409 + - RxMisQCnt: Incremented when host queues adds buffers to a queue as the port finished the
3410 +reception of the previous last packet in the queue (per channel).
3411 + - TxEOQCnt: Number of times the port has reached the end of the transmit queue (per channel and queue).
3412 + - RxEOQCnt: Number of times the port has reached the end of the receive queue (per channel).
3413 + - RxPacketsServiced: Number of received packets (per channel).
3414 + - TxPacketsServiced: Number of transmitted packets (per channel and queue).
3415 + - RxMaxServiced: Maximum number of packets that the CPHAL receive interrupt has serviced at a time (per channel).
3416 + - TxMaxServiced: Maximum number of packets that the CPHAL transmit interrupt has serviced at a time (per channel and queue).
3417 + - RxTotal: Total number of received packets, all channels.
3418 + - TxTotal: Total number of transmitted packets, all channels and queues.
3419 +- Level 2 Statistics (CPHAL Flags)
3420 + - RcbPool: Pointer to receive descriptor pool (per channel).
3421 + - RxActQueueCount: Number of buffers currently available for receive (per channel).
3422 + - RxActQueueHead: Pointer to first buffer in receive queue (per channel).
3423 + - RxActQueueTail: Pointer to last buffer in receive queue (per channel).
3424 + - RxActive: 0 if inactive (no buffers available), or 1 if active (buffers available).
3425 + - RcbStart: Pointer to block of receive descriptors.
3426 + - RxTeardownPending: 1 if Rx teardown is pending but incomplete, 0 otherwise.
3427 + - TcbPool: Pointer to transmit descriptor pool (per channel and queue).
3428 + - TxActQueueCount: Number of buffers currently queued to be transmitted (per channel and queue).
3429 + - TxActQueueHead: Pointer to first buffer in transmit queue (per channel and queue).
3430 + - TxActQueueTail: Pointer to last buffer in transmit queue (per channel and queue).
3431 + - TxActive: 0 if inactive (no buffers to send), or 1 if active (buffers queued to send).
3432 + - TcbStart: Pointer to block of transmit descriptors.
3433 + - TxTeardownPending: 1 if Tx teardown is pending but incomplete, 0 otherwise.
3434 +- Level 3 Statistics (CPHAL Channel Configuration)
3435 + - RxBufSize: Rx buffer size.
3436 + - RxBufferOffset: Rx buffer offset.
3437 + - RxNumBuffers: Number of Rx buffers.
3438 + - RxServiceMax: Maximum number of receive packets to service at a time.
3439 + - TxNumBuffers: Number of Tx buffer descriptors.
3440 + - TxNumQueues: Number of Tx queues to use.
3441 + - TxServiceMax: Maximum number of transmit packets to service at a time.
3442 +- Level 4 Statistics (CPHAL General Configuration)
3443 + - Base Address: Base address of the module.
3444 + - Offset (VLYNQ): VLYNQ relative module offset.
3445 + - Interrupt Line: Interrupt number.
3446 + - Debug: Debug flag, 1 to enable debug.
3447 + - Inst: Instance number.
3451 + Data Type 0 = int display
3452 + Data Type 1 = hex display
3453 + Data Type 2 = channel structure, int display
3454 + Data Type 3 = queue index and int display
3455 + Data Type 4 = queue index and hex display
3457 +#if (defined(_CPHAL_AAL5) || defined(_CPHAL_CPMAC)) /* +GSG 030307 */
3458 +static STATS_TABLE StatsTable0[] =
3461 + /* Name , Data Ptr, Data Type */
3462 + {"Crc Errors", 0, 0},
3463 + {"Len Errors", 0, 0},
3464 + {"Abort Errors", 0, 0},
3465 + {"Starv Errors", 0, 0}
3467 +#ifdef _CPHAL_CPMAC
3468 + {"Rx Good Frames", 0, 0}
3472 +static STATS_TABLE StatsTable1[] =
3474 + /* Name , Data Ptr, Data Type */
3475 + {"DmaLenErrors", 0, 0},
3476 + {"TxMisQCnt", 0, 3},
3477 + {"RxMisQCnt", 0, 0},
3478 + {"TxEOQCnt", 0, 3},
3479 + {"RxEOQCnt", 0, 0},
3480 + {"RxPacketsServiced", 0, 0},
3481 + {"TxPacketsServiced", 0, 3},
3482 + {"RxMaxServiced", 0, 0},
3483 + {"TxMaxServiced", 0, 3},
3484 + {"RxTotal", 0, 0},
3485 + {"TxTotal", 0, 0},
3488 +static STATS_TABLE StatsTable2[] =
3490 + /* Name , Data Ptr, Data Type */
3491 + {"RcbPool", 0, 1},
3492 + {"RxActQueueCount", 0, 0},
3493 + {"RxActQueueHead", 0, 1},
3494 + {"RxActQueueTail", 0, 1},
3495 + {"RxActive", 0, 0},
3496 + {"RcbStart", 0, 1},
3497 + {"RxTeardownPending", 0, 0},
3498 + {"TcbPool", 0, 4},
3499 + {"TxActQueueCount", 0, 3},
3500 + {"TxActQueueHead", 0, 4},
3501 + {"TxActQueueTail", 0, 4},
3502 + {"TxActive", 0, 3},
3503 + {"TcbStart", 0, 4},
3504 + {"TxTeardownPending", 0, 0}
3507 +static STATS_TABLE StatsTable3[] =
3509 + /* Name , Data Ptr, Data Type */
3510 + {"RxBufSize", 0, 2},
3511 + {"RxBufferOffset", 0, 2},
3512 + {"RxNumBuffers", 0, 2},
3513 + {"RxServiceMax", 0, 2},
3514 + {"TxNumBuffers", 0, 2},
3515 + {"TxNumQueues", 0, 2},
3516 + {"TxServiceMax", 0, 2},
3523 + {"Priority", 0, 2},
3524 + {"PktType", 0, 2},
3527 + {"CellRate", 0, 2},
3528 + {"QosType", 0, 2},
3534 +static STATS_TABLE StatsTable4[] =
3536 + {"Base Address", 0, 1},
3537 + {"Offset (VLYNQ)", 0, 0},
3538 + {"Interrupt Line", 0, 0},
3540 + {"Instance", 0, 0},
3546 +static STATS_DB StatsDb[] =
3548 + {(sizeof(StatsTable0)/sizeof(STATS_TABLE)), StatsTable0},
3549 + {(sizeof(StatsTable1)/sizeof(STATS_TABLE)), StatsTable1},
3550 + {(sizeof(StatsTable2)/sizeof(STATS_TABLE)), StatsTable2},
3551 + {(sizeof(StatsTable3)/sizeof(STATS_TABLE)), StatsTable3},
3552 + {(sizeof(StatsTable4)/sizeof(STATS_TABLE)), StatsTable4}
3554 +#endif /* +GSG 030307 */
3556 +#ifdef _CPHAL_CPMAC /* +RC 3.02 */
3557 +static void resetWait(HAL_DEVICE *HalDev)
3559 + const int TickReset=64;
3560 + osfuncSleep((int*)&TickReset);
3562 +#endif /* +RC 3.02 */
3564 +/* I only define the reset base function for the modules
3565 + that can perform a reset. The AAL5 and AAL2 modules
3566 + do not perform a reset, that is done by the shared module
3568 +#if defined(_CPHAL_CPSAR) || defined(_CPHAL_CPMAC) || defined(_CPHAL_VDMAVT)
3570 + * Determines the reset register address to be used for a particular device.
3571 + * It will search the current device entry for Locator information. If the
3572 + * device is a root device, there will be no Locator information, and the
3573 + * function will find and return the root reset register. If a Locator value
3574 + * is found, the function will search each VLYNQ device entry in the system
3575 + * looking for a matching Locator. Once it finds a VLYNQ device entry with
3576 + * a matching Locator, it will extract the "ResetBase" parameter from that
3577 + * VLYNQ device entry (thus every VLYNQ entry must have the ResetBase parameter).
3579 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
3580 + * @param ResetBase Pointer to integer address of reset register.
3582 + * @return 0 OK, Non-zero not OK
3584 +static int ResetBaseGet(HAL_DEVICE *HalDev, bit32u *ResetBase)
3586 + char *DeviceInfo = HalDev->DeviceInfo;
3587 + char *MyLocator, *NextLocator;
3589 + bit32u error_code;
3591 +#ifdef __CPHAL_DEBUG
3594 + dbgPrintf("[cpcommon]ResetBaseGet(HalDev:%08x, ResetBase:%08x)\n", (bit32u)HalDev, ResetBase);
3599 + error_code = HalDev->OsFunc->DeviceFindParmValue(DeviceInfo, "Locator", &MyLocator);
3602 + /* if no Locator value, device is on the root, so get the "reset" device */
3603 + error_code = HalDev->OsFunc->DeviceFindInfo(0, "reset", &DeviceInfo);
3606 + return(EC_VAL_DEVICE_NOT_FOUND);
3609 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, "base", ResetBase);
3612 + return(EC_VAL_BASE_ADDR_NOT_FOUND);
3615 + *ResetBase = ((bit32u)PhysToVirtNoCache(*ResetBase));
3617 + /* found base address for root device, so we're done */
3618 + return (EC_NO_ERRORS);
3622 + /* we have a Locator value, so the device is remote */
3624 + /* Find a vlynq device with a matching locator value */
3625 + while ((HalDev->OsFunc->DeviceFindInfo(Inst, "vlynq", &DeviceInfo)) == EC_NO_ERRORS)
3627 + error_code = HalDev->OsFunc->DeviceFindParmValue(DeviceInfo, "Locator", &NextLocator);
3630 + /* no Locator value for this VLYNQ, so move on */
3633 + if (HalDev->OsFunc->Strcmpi(MyLocator, NextLocator)==0)
3635 + /* we have found a VLYNQ with a matching Locator, so extract the ResetBase */
3636 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, "ResetBase", ResetBase);
3639 + return(EC_VAL_BASE_ADDR_NOT_FOUND);
3641 + *ResetBase = ((bit32u)PhysToVirtNoCache(*ResetBase));
3643 + /* found base address for root device, so we're done */
3644 + return (EC_NO_ERRORS);
3650 + return (EC_NO_ERRORS);
3654 +#ifndef _CPHAL_AAL2 /* + RC 3.02 */
3655 +static bit32u ConfigGetCommon(HAL_DEVICE *HalDev)
3659 + char *DeviceInfo = HalDev->DeviceInfo;
3661 +#ifdef __CPHAL_DEBUG
3664 + dbgPrintf("[cpcommon]ConfigGetCommon(HalDev:%08x)\n", (bit32u)HalDev);
3669 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszBase, &ParmValue);
3672 + return(EC_FUNC_HAL_INIT|EC_VAL_BASE_ADDR_NOT_FOUND);
3674 + HalDev->dev_base = ((bit32u)PhysToVirtNoCache(ParmValue));
3676 +#ifndef _CPHAL_AAL5
3677 +#ifndef _CPHAL_AAL2
3678 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszResetBit, &ParmValue);
3681 + return(EC_FUNC_HAL_INIT|EC_VAL_RESET_BIT_NOT_FOUND);
3683 + HalDev->ResetBit = ParmValue;
3685 + /* Get reset base address */
3686 + error_code = ResetBaseGet(HalDev, &ParmValue);
3688 + return(EC_FUNC_HAL_INIT|EC_VAL_RESET_BASE_NOT_FOUND);
3689 + HalDev->ResetBase = ParmValue;
3693 +#ifndef _CPHAL_CPSAR
3694 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszIntLine,&ParmValue);
3697 + return(EC_FUNC_HAL_INIT|EC_VAL_INTERRUPT_NOT_FOUND);
3699 + HalDev->interrupt = ParmValue;
3702 + /* only look for the offset if there is a Locator field, which indicates that
3703 + the module is a VLYNQ module */
3704 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszLocator,&ParmValue);
3707 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszOffset,&ParmValue);
3710 + return(EC_FUNC_HAL_INIT|EC_VAL_OFFSET_NOT_FOUND);
3712 + HalDev->offset = ParmValue;
3715 + HalDev->offset = 0;
3717 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszDebug, &ParmValue);
3718 + if (!error_code) HalDev->debug = ParmValue;
3720 + return (EC_NO_ERRORS);
3722 +#endif /* +RC 3.02 */
3724 +#ifdef _CPHAL_CPMAC /* +RC 3.02 */
3725 +static void StatsInit(HAL_DEVICE *HalDev) /* +() RC3.02 */
3727 + /* even though these statistics may be for multiple channels and
3728 + queues, i need only configure the pointer to the beginning
3729 + of the array, and I can index from there if necessary */
3732 + StatsTable0[0].StatPtr = &HalDev->Stats.CrcErrors[0];
3733 + StatsTable0[1].StatPtr = &HalDev->Stats.LenErrors[0];
3734 + StatsTable0[2].StatPtr = &HalDev->Stats.AbortErrors[0];
3735 + StatsTable0[3].StatPtr = &HalDev->Stats.StarvErrors[0];
3737 + StatsTable1[0].StatPtr = &HalDev->Stats.DmaLenErrors[0];
3738 + StatsTable1[1].StatPtr = &HalDev->Stats.TxMisQCnt[0][0];
3739 + StatsTable1[2].StatPtr = &HalDev->Stats.RxMisQCnt[0];
3740 + StatsTable1[3].StatPtr = &HalDev->Stats.TxEOQCnt[0][0];
3741 + StatsTable1[4].StatPtr = &HalDev->Stats.RxEOQCnt[0];
3742 + StatsTable1[5].StatPtr = &HalDev->Stats.RxPacketsServiced[0];
3743 + StatsTable1[6].StatPtr = &HalDev->Stats.TxPacketsServiced[0][0];
3744 + StatsTable1[7].StatPtr = &HalDev->Stats.RxMaxServiced;
3745 + StatsTable1[8].StatPtr = &HalDev->Stats.TxMaxServiced[0][0];
3746 + StatsTable1[9].StatPtr = &HalDev->Stats.RxTotal;
3747 + StatsTable1[10].StatPtr = &HalDev->Stats.TxTotal;
3750 +#if (defined(_CPHAL_AAL5) || defined(_CPHAL_CPMAC))
3751 + StatsTable2[0].StatPtr = (bit32u *)&HalDev->RcbPool[0];
3752 + StatsTable2[1].StatPtr = &HalDev->RxActQueueCount[0];
3753 + StatsTable2[2].StatPtr = (bit32u *)&HalDev->RxActQueueHead[0];
3754 + StatsTable2[3].StatPtr = (bit32u *)&HalDev->RxActQueueTail[0];
3755 + StatsTable2[4].StatPtr = &HalDev->RxActive[0];
3756 + StatsTable2[5].StatPtr = (bit32u *)&HalDev->RcbStart[0];
3757 + StatsTable2[6].StatPtr = &HalDev->RxTeardownPending[0];
3758 + StatsTable2[7].StatPtr = (bit32u *)&HalDev->TcbPool[0][0];
3759 + StatsTable2[8].StatPtr = &HalDev->TxActQueueCount[0][0];
3760 + StatsTable2[9].StatPtr = (bit32u *)&HalDev->TxActQueueHead[0][0];
3761 + StatsTable2[10].StatPtr = (bit32u *)&HalDev->TxActQueueTail[0][0];
3762 + StatsTable2[11].StatPtr = &HalDev->TxActive[0][0];
3763 + StatsTable2[12].StatPtr = (bit32u *)&HalDev->TcbStart[0][0];
3764 + StatsTable2[13].StatPtr = &HalDev->TxTeardownPending[0];
3766 + StatsTable3[0].StatPtr = &HalDev->ChData[0].RxBufSize;
3767 + StatsTable3[1].StatPtr = &HalDev->ChData[0].RxBufferOffset;
3768 + StatsTable3[2].StatPtr = &HalDev->ChData[0].RxNumBuffers;
3769 + StatsTable3[3].StatPtr = &HalDev->ChData[0].RxServiceMax;
3770 + StatsTable3[4].StatPtr = &HalDev->ChData[0].TxNumBuffers;
3771 + StatsTable3[5].StatPtr = &HalDev->ChData[0].TxNumQueues;
3772 + StatsTable3[6].StatPtr = &HalDev->ChData[0].TxServiceMax;
3774 + StatsTable3[7].StatPtr = &HalDev->ChData[0].CpcsUU;
3775 + StatsTable3[8].StatPtr = &HalDev->ChData[0].Gfc;
3776 + StatsTable3[9].StatPtr = &HalDev->ChData[0].Clp;
3777 + StatsTable3[10].StatPtr = &HalDev->ChData[0].Pti;
3778 + StatsTable3[11].StatPtr = &HalDev->ChData[0].DaMask;
3779 + StatsTable3[12].StatPtr = &HalDev->ChData[0].Priority;
3780 + StatsTable3[13].StatPtr = &HalDev->ChData[0].PktType;
3781 + StatsTable3[14].StatPtr = &HalDev->ChData[0].Vci;
3782 + StatsTable3[15].StatPtr = &HalDev->ChData[0].Vpi;
3783 + StatsTable3[16].StatPtr = &HalDev->ChData[0].TxVc_CellRate;
3784 + StatsTable3[17].StatPtr = &HalDev->ChData[0].TxVc_QosType;
3785 + StatsTable3[18].StatPtr = &HalDev->ChData[0].TxVc_Mbs;
3786 + StatsTable3[19].StatPtr = &HalDev->ChData[0].TxVc_Pcr;
3790 + StatsTable4[0].StatPtr = &HalDev->dev_base;
3791 + StatsTable4[1].StatPtr = &HalDev->offset;
3792 + StatsTable4[2].StatPtr = &HalDev->interrupt;
3793 + StatsTable4[3].StatPtr = &HalDev->debug;
3794 + StatsTable4[4].StatPtr = &HalDev->Inst;
3796 +#endif /* +RC 3.02 */
3798 +#ifndef _CPHAL_CPSAR /* +RC 3.02 */
3799 +#ifndef _CPHAL_AAL2 /* +RC 3.02 */
3801 + * Returns statistics information.
3803 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
3807 +static int StatsGet(HAL_DEVICE *HalDev, void **StatPtr, int Index, int Ch, int Queue)
3812 + STATS_TABLE *StatsTable;
3813 + int i, NumberOfStats;
3815 +#ifdef __CPHAL_DEBUG
3818 + dbgPrintf("[cpcommon]StatsGet(HalDev:%08x, StatPtr:%08x)\n",
3819 + (bit32u)HalDev, (bit32u)StatPtr);
3824 + StatsTable = StatsDb[Index].StatTable;
3825 + NumberOfStats = StatsDb[Index].NumberOfStats;
3827 + Size = sizeof(bit32u)*((NumberOfStats*2)+1);
3828 + Size += (NumberOfStats*11);
3829 + *StatPtr = (bit32u *)HalDev->OsFunc->Malloc(Size);
3831 + AddrPtr = (bit32u *) *StatPtr;
3832 + DataPtr = (char *)AddrPtr;
3833 + DataPtr += sizeof(bit32u)*((NumberOfStats*2)+1);
3835 + for (i=0; i<NumberOfStats; i++)
3837 + *AddrPtr++ = (bit32u)StatsTable[i].StatName;
3838 + *AddrPtr++ = (bit32u)DataPtr;
3839 + if (&StatsTable[i].StatPtr[Ch] != 0)
3841 + switch(StatsTable[i].DataType)
3844 + HalDev->OsFunc->Sprintf(DataPtr, "%d", (bit32u *)StatsTable[i].StatPtr[Ch]);
3847 + HalDev->OsFunc->Sprintf(DataPtr, "0x%x", (bit32u *)StatsTable[i].StatPtr[Ch]);
3850 + HalDev->OsFunc->Sprintf(DataPtr, "%d", *((bit32u *)StatsTable[i].StatPtr + (Ch * (sizeof(CHANNEL_INFO)/4))));
3853 + HalDev->OsFunc->Sprintf(DataPtr, "%d", *((bit32u *)StatsTable[i].StatPtr + (Ch*MAX_QUEUE)+Queue));
3856 + HalDev->OsFunc->Sprintf(DataPtr, "0x%x", *((bit32u *)StatsTable[i].StatPtr + (Ch*MAX_QUEUE)+Queue));
3859 + /* invalid data type, due to CPHAL programming error */
3865 + /* invalid statistics pointer, probably was not initialized */
3867 + DataPtr += HalDev->OsFunc->Strlen(DataPtr) + 1;
3870 + *AddrPtr = (bit32u) 0;
3872 + return (EC_NO_ERRORS);
3874 +#endif /* +RC 3.02 */
3875 +#endif /* +RC 3.02 */
3877 +#ifdef _CPHAL_CPMAC
3878 +static void gpioFunctional(int base, int bit)
3880 + bit32u GpioEnr = base + 0xC;
3881 + /* To make functional, set to zero */
3882 + *(volatile bit32u *)(GpioEnr) &= ~(1 << bit); /*+RC3.02*/
3887 +/* Common function, Checks to see if GPIO should be in functional mode */
3888 +static void gpioCheck(HAL_DEVICE *HalDev, void *moduleDeviceInfo)
3893 + char pszMuxBit[20];
3895 + char szMuxBit[20];
3900 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
3902 + rc = OsFunc->DeviceFindParmValue(moduleDeviceInfo, "gpio_mux",&pszTmp);
3904 + /* gpio entry found, get GPIO register info and make functional */
3906 + /* temp copy until FinParmValue fixed */
3907 + ptr = &szMuxBit[0];
3908 + while ((*ptr++ = *pszTmp++));
3910 + pszMuxBits = &szMuxBit[0];
3912 + rc = OsFunc->DeviceFindInfo(0,"gpio",&DeviceInfo);
3915 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "base",&base);
3918 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "reset_bit",&reset_bit);
3921 + /* If GPIO still in reset, then exit */
3922 + if((VOLATILE32(HalDev->ResetBase) & (1 << reset_bit)) == 0)
3924 + /* format for gpio_mux is gpio_mux = <int>;<int>;<int>...*/
3925 + while (*pszMuxBits)
3927 + pszTmp = &pszMuxBit[0];
3928 + if(*pszMuxBits == ';') pszMuxBits++;
3929 + while ((*pszMuxBits != ';') && (*pszMuxBits != '\0'))
3932 + /*If value not a number, skip */
3933 + if((*pszMuxBits < '0') || (*pszMuxBits > '9'))
3936 + *pszTmp++ = *pszMuxBits++;
3939 + bit = OsFunc->Strtoul(pszMuxBit, &pszTmp, 10);
3940 + gpioFunctional(base, bit);
3941 + resetWait(HalDev); /* not sure if this is needed */
3947 +const char hcSarFrequency[] = "SarFreq";
3951 diff -urN linux.old/drivers/atm/sangam_atm/cpcommon_cpaal5.h linux.dev/drivers/atm/sangam_atm/cpcommon_cpaal5.h
3952 --- linux.old/drivers/atm/sangam_atm/cpcommon_cpaal5.h 1970-01-01 01:00:00.000000000 +0100
3953 +++ linux.dev/drivers/atm/sangam_atm/cpcommon_cpaal5.h 2005-07-10 08:02:01.422114704 +0200
3955 +#ifndef _INC_CPCOMMON_H
3956 +#define _INC_CPCOMMON_H
3958 +#define VOLATILE32(addr) (*(volatile bit32u *)(addr))
3960 +#define dbgPrintf HalDev->OsFunc->Printf
3963 +#define ChannelUpdate(Field) if(HalChn->Field != 0xFFFFFFFF) HalDev->ChData[Ch].Field = HalChn->Field
3965 +#define DBG(level) (HalDev->debug & (1<<(level)))
3967 +#define DBG0() DBG(0)
3968 +#define DBG1() DBG(1)
3969 +#define DBG2() DBG(2)
3970 +#define DBG3() DBG(3)
3971 +#define DBG4() DBG(4)
3972 +#define DBG5() DBG(5)
3973 +#define DBG6() DBG(6)
3974 +#define DBG7() DBG(7)
3978 + * List of defined actions for use with Control().
3982 + enGET=0, /**< Get the value associated with a key */
3983 + enSET, /**< Set the value associates with a key */
3984 + enCLEAR, /**<Clear the value */
3985 + enNULL /**< No data action, used to initiate a service or send a message */
3989 + * Enumerated hardware states.
3993 + enConnected=1, enDevFound, enInitialized, enOpened
4000 + enOff, enOn, enDebug,
4001 + /* Module General */
4009 + const char *strKey;
4016 + unsigned int *StatPtr;
4017 + int DataType; /* 0: int, 1: hex int, 2:channel data */
4022 + int NumberOfStats;
4023 + STATS_TABLE *StatTable;
4026 +#define osfuncSioFlush() HalDev->OsFunc->Control(HalDev->OsDev,"SioFlush",pszNULL,0)
4027 +#define osfuncSleep(Ticks) HalDev->OsFunc->Control(HalDev->OsDev,pszSleep,pszNULL,Ticks)
4028 +#define osfuncStateChange() HalDev->OsFunc->Control(HalDev->OsDev,pszStateChange,pszNULL,0)
4030 +#define CHANNEL_NAMES {"Ch0","Ch1","Ch2","Ch3","Ch4","Ch5","Ch6","Ch7","Ch8","Ch9","Ch10","Ch11","Ch12","Ch13","Ch14","Ch15"}
4034 diff -urN linux.old/drivers/atm/sangam_atm/cpcommon_cpsar.c linux.dev/drivers/atm/sangam_atm/cpcommon_cpsar.c
4035 --- linux.old/drivers/atm/sangam_atm/cpcommon_cpsar.c 1970-01-01 01:00:00.000000000 +0100
4036 +++ linux.dev/drivers/atm/sangam_atm/cpcommon_cpsar.c 2005-07-10 08:02:01.423114552 +0200
4038 +#ifndef _INC_CPCOMMON_C
4039 +#define _INC_CPCOMMON_C
4041 +#ifdef _CPHAL_CPMAC
4042 +#include "cpremap_cpmac.c"
4046 +#include "cpremap_cpaal5.c"
4049 +#ifdef _CPHAL_CPSAR
4050 +#include "cpremap_cpsar.c"
4054 +#include "cpremap_cpaal2.c"
4058 +@defgroup Common_Config_Params Common Configuration Parameters
4060 +This section documents the configuration parameters that are valid across
4064 +/** This is the debug level. The field is bit defined, such that the user
4065 +should set to 1 all the bits corresponding to desired debug outputs. The following
4066 +are the meanings for each debug bit:
4067 +- bit0 (LSB): CPHAL Function Trace
4068 +- b1 : OS Function call trace
4069 +- b2 : Critical section entry/exit
4070 +- b3 : Memory allocation/destruction
4071 +- b4 : Detailed information in Rx path
4072 +- b5 : Detailed information in Tx path
4073 +- b6 : Extended error information
4074 +- b7 : General info
4076 +static const char pszDebug[] = "debug";
4077 +/** CPU Frequency. */
4078 +/*static const char pszCpuFreq[] = "CpuFreq";*/ /*MJH-030403*/
4079 +/** Base address for the module. */
4080 +static const char pszBase[] = "base";
4081 +/** Reset bit for the module. */
4082 +static const char pszResetBit[] = "reset_bit";
4083 +/** Reset base address for the module. */
4084 +static const char pszResetBase[] = "ResetBase";
4085 +/** Interrupt line for the module. */
4086 +static const char pszIntLine[] = "int_line";
4087 +/** VLYNQ offset for the module. Disregard if not using VLYNQ. */
4088 +static const char pszOffset[] = "offset";
4089 +/** The OS may "Get" this parameter, which is a pointer
4090 + to a character string that indicates the version of CPHAL. */
4091 +static const char pszVer[] = "Version";
4095 +@defgroup Common_Control_Params Common Keys for [os]Control()
4097 +This section documents the keys used with the OS @c Control() interface that
4098 +are required by CPHAL devices.
4102 +/** Used to wait for an integer number of clock ticks, given as an integer
4103 + pointer in the @p Value parameter. No actions are defined. */
4104 +static const char pszSleep[] = "Sleep";
4105 +/** Requests the OS to flush it's IO buffers. No actions are defined. */
4106 +static const char pszSioFlush[] = "SioFlush";
4109 +static const char pszStateChange[] = "StateChange";
4110 +static const char pszStatus[] = "Status";
4112 +static const char pszGET[] = "Get";
4113 +static const char pszSET[] = "Set";
4114 +static const char pszCLEAR[] = "Clear";
4115 +static const char pszNULL[] = "";
4116 +static const char pszLocator[] = "Locator";
4117 +static const char pszOff[] = "Off";
4118 +static const char pszOn[] = "On";
4119 +static const char hcMaxFrags[] = "MaxFrags";
4121 +#ifdef _CPHAL_CPMAC
4123 +/* New method for string constants */
4124 +const char hcClear[] = "Clear";
4125 +const char hcGet[] = "Get";
4126 +const char hcSet[] = "Set";
4128 +const char hcTick[] = "Tick";
4130 +static const CONTROL_KEY KeyCommon[] =
4132 + {"" , enCommonStart},
4133 + {pszStatus , enStatus},
4136 + {pszDebug , enDebug},
4137 + {hcCpuFrequency , enCpuFreq}, /*MJH~030403*/
4138 + {"" , enCommonEnd}
4143 +@defgroup Common_Statistics Statistics
4145 +A broad array of module statistics is available. Statistics values are accessed
4146 +through the @c Control() interface of the CPHAL. There are 5 different levels
4147 +of statistics, each of which correspond to a unique set of data. Furthermore,
4148 +certain statistics data is indexed by using a channel number and Tx queue number.
4149 +The following is a brief description of each statistics level, along with the
4150 +indexes used for the level:
4152 +- Level 0: Hardware Statistics (index with channel)
4153 +- Level 1: CPHAL Software Statistics (channel, queue)
4154 +- Level 2: CPHAL Flags (channel, queue)
4155 +- Level 3: CPHAL Channel Configuration (channel)
4156 +- Level 4: CPHAL General Configuration (no index)
4158 +The caller requests statistics information by providing a Key string to the
4159 +@c Control() API in the following format: "Stats;[Level #];[Ch #];[Queue #]".
4160 +The only valid Action parameter for statistics usage is "Get".
4164 +unsigned int *StatsData;
4166 +# Get Level 0 stats for Channel 1
4167 +HalFunc->Control(OsDev->HalDev, "Stats;0;1", "Get", &StatsData);
4169 +# Get Level 2 stats for Channel 0, Queue 0
4170 +HalFunc->Control(OsDev->HalDev, "Stats;2;0;0", "Get", &StatsData);
4172 +# Get Level 4 stats
4173 +HalFunc->Control(OsDev->HalDev, "Stats;4", "Get", &StatsData);
4176 +The information returned in the Value parameter of @c Control() is an
4177 +array of pointers to strings. The pointers are arranged in pairs.
4178 +The first pointer is a pointer to a name string for a particular statistic.
4179 +The next pointer is a pointer to a string containing the representation of
4180 +the integer statistic value corresponding to the first pointer. This is followed
4181 +by another pair of pointers, and so on, until a NULL pointer is encountered. The
4182 +following is example code for processing the statistics data. Note that the OS
4183 +is responsible for freeing the memory passed back through the Value parameter of
4187 +unsigned int *StatsData;
4189 +# Get Level 0 stats for Channel 1
4190 +HalFunc->Control(OsDev->HalDev, "Stats;0;1", "Get", &StatsData);
4192 +# output Statistics data
4193 +PrintStats(StatsData);
4195 +# the upper layer is responsible for freeing stats info
4200 +void PrintStats(unsigned int *StatsPtr)
4204 + printf("%20s:", (char *)*StatsPtr);
4206 + printf("%11s\n", (char *)*StatsPtr);
4213 +Within each statistics level, there are several statistics defined. The statistics that
4214 +are common to every CPPI module are listed below. In addition, each module may define
4215 +extra statistics in each level, which will be documented within the module-specific
4216 +documentation appendices.
4218 +- Level 0 Statistics
4219 + - All level 0 statistics are module-specific.
4220 +- Level 1 Statistics (CPHAL Software Statistics)
4221 + - DmaLenErrors: Incremented when the port DMA's more data than expected (per channel). (AAL5 Only)
4222 + - TxMisQCnt: Incremented when host queues a packet for transmission as the port finishes
4223 +transmitting the previous last packet in the queue (per channel and queue).
4224 + - RxMisQCnt: Incremented when host queues adds buffers to a queue as the port finished the
4225 +reception of the previous last packet in the queue (per channel).
4226 + - TxEOQCnt: Number of times the port has reached the end of the transmit queue (per channel and queue).
4227 + - RxEOQCnt: Number of times the port has reached the end of the receive queue (per channel).
4228 + - RxPacketsServiced: Number of received packets (per channel).
4229 + - TxPacketsServiced: Number of transmitted packets (per channel and queue).
4230 + - RxMaxServiced: Maximum number of packets that the CPHAL receive interrupt has serviced at a time (per channel).
4231 + - TxMaxServiced: Maximum number of packets that the CPHAL transmit interrupt has serviced at a time (per channel and queue).
4232 + - RxTotal: Total number of received packets, all channels.
4233 + - TxTotal: Total number of transmitted packets, all channels and queues.
4234 +- Level 2 Statistics (CPHAL Flags)
4235 + - RcbPool: Pointer to receive descriptor pool (per channel).
4236 + - RxActQueueCount: Number of buffers currently available for receive (per channel).
4237 + - RxActQueueHead: Pointer to first buffer in receive queue (per channel).
4238 + - RxActQueueTail: Pointer to last buffer in receive queue (per channel).
4239 + - RxActive: 0 if inactive (no buffers available), or 1 if active (buffers available).
4240 + - RcbStart: Pointer to block of receive descriptors.
4241 + - RxTeardownPending: 1 if Rx teardown is pending but incomplete, 0 otherwise.
4242 + - TcbPool: Pointer to transmit descriptor pool (per channel and queue).
4243 + - TxActQueueCount: Number of buffers currently queued to be transmitted (per channel and queue).
4244 + - TxActQueueHead: Pointer to first buffer in transmit queue (per channel and queue).
4245 + - TxActQueueTail: Pointer to last buffer in transmit queue (per channel and queue).
4246 + - TxActive: 0 if inactive (no buffers to send), or 1 if active (buffers queued to send).
4247 + - TcbStart: Pointer to block of transmit descriptors.
4248 + - TxTeardownPending: 1 if Tx teardown is pending but incomplete, 0 otherwise.
4249 +- Level 3 Statistics (CPHAL Channel Configuration)
4250 + - RxBufSize: Rx buffer size.
4251 + - RxBufferOffset: Rx buffer offset.
4252 + - RxNumBuffers: Number of Rx buffers.
4253 + - RxServiceMax: Maximum number of receive packets to service at a time.
4254 + - TxNumBuffers: Number of Tx buffer descriptors.
4255 + - TxNumQueues: Number of Tx queues to use.
4256 + - TxServiceMax: Maximum number of transmit packets to service at a time.
4257 +- Level 4 Statistics (CPHAL General Configuration)
4258 + - Base Address: Base address of the module.
4259 + - Offset (VLYNQ): VLYNQ relative module offset.
4260 + - Interrupt Line: Interrupt number.
4261 + - Debug: Debug flag, 1 to enable debug.
4262 + - Inst: Instance number.
4266 + Data Type 0 = int display
4267 + Data Type 1 = hex display
4268 + Data Type 2 = channel structure, int display
4269 + Data Type 3 = queue index and int display
4270 + Data Type 4 = queue index and hex display
4272 +#if (defined(_CPHAL_AAL5) || defined(_CPHAL_CPMAC)) /* +GSG 030307 */
4273 +static STATS_TABLE StatsTable0[] =
4276 + /* Name , Data Ptr, Data Type */
4277 + {"Crc Errors", 0, 0},
4278 + {"Len Errors", 0, 0},
4279 + {"Abort Errors", 0, 0},
4280 + {"Starv Errors", 0, 0}
4282 +#ifdef _CPHAL_CPMAC
4283 + {"Rx Good Frames", 0, 0}
4287 +static STATS_TABLE StatsTable1[] =
4289 + /* Name , Data Ptr, Data Type */
4290 + {"DmaLenErrors", 0, 0},
4291 + {"TxMisQCnt", 0, 3},
4292 + {"RxMisQCnt", 0, 0},
4293 + {"TxEOQCnt", 0, 3},
4294 + {"RxEOQCnt", 0, 0},
4295 + {"RxPacketsServiced", 0, 0},
4296 + {"TxPacketsServiced", 0, 3},
4297 + {"RxMaxServiced", 0, 0},
4298 + {"TxMaxServiced", 0, 3},
4299 + {"RxTotal", 0, 0},
4300 + {"TxTotal", 0, 0},
4303 +static STATS_TABLE StatsTable2[] =
4305 + /* Name , Data Ptr, Data Type */
4306 + {"RcbPool", 0, 1},
4307 + {"RxActQueueCount", 0, 0},
4308 + {"RxActQueueHead", 0, 1},
4309 + {"RxActQueueTail", 0, 1},
4310 + {"RxActive", 0, 0},
4311 + {"RcbStart", 0, 1},
4312 + {"RxTeardownPending", 0, 0},
4313 + {"TcbPool", 0, 4},
4314 + {"TxActQueueCount", 0, 3},
4315 + {"TxActQueueHead", 0, 4},
4316 + {"TxActQueueTail", 0, 4},
4317 + {"TxActive", 0, 3},
4318 + {"TcbStart", 0, 4},
4319 + {"TxTeardownPending", 0, 0}
4322 +static STATS_TABLE StatsTable3[] =
4324 + /* Name , Data Ptr, Data Type */
4325 + {"RxBufSize", 0, 2},
4326 + {"RxBufferOffset", 0, 2},
4327 + {"RxNumBuffers", 0, 2},
4328 + {"RxServiceMax", 0, 2},
4329 + {"TxNumBuffers", 0, 2},
4330 + {"TxNumQueues", 0, 2},
4331 + {"TxServiceMax", 0, 2},
4338 + {"Priority", 0, 2},
4339 + {"PktType", 0, 2},
4342 + {"CellRate", 0, 2},
4343 + {"QosType", 0, 2},
4349 +static STATS_TABLE StatsTable4[] =
4351 + {"Base Address", 0, 1},
4352 + {"Offset (VLYNQ)", 0, 0},
4353 + {"Interrupt Line", 0, 0},
4355 + {"Instance", 0, 0},
4361 +static STATS_DB StatsDb[] =
4363 + {(sizeof(StatsTable0)/sizeof(STATS_TABLE)), StatsTable0},
4364 + {(sizeof(StatsTable1)/sizeof(STATS_TABLE)), StatsTable1},
4365 + {(sizeof(StatsTable2)/sizeof(STATS_TABLE)), StatsTable2},
4366 + {(sizeof(StatsTable3)/sizeof(STATS_TABLE)), StatsTable3},
4367 + {(sizeof(StatsTable4)/sizeof(STATS_TABLE)), StatsTable4}
4369 +#endif /* +GSG 030307 */
4371 +#ifdef _CPHAL_CPMAC /* +RC 3.02 */
4372 +static void resetWait(HAL_DEVICE *HalDev)
4374 + const int TickReset=64;
4375 + osfuncSleep((int*)&TickReset);
4377 +#endif /* +RC 3.02 */
4379 +/* I only define the reset base function for the modules
4380 + that can perform a reset. The AAL5 and AAL2 modules
4381 + do not perform a reset, that is done by the shared module
4383 +#if defined(_CPHAL_CPSAR) || defined(_CPHAL_CPMAC) || defined(_CPHAL_VDMAVT)
4385 + * Determines the reset register address to be used for a particular device.
4386 + * It will search the current device entry for Locator information. If the
4387 + * device is a root device, there will be no Locator information, and the
4388 + * function will find and return the root reset register. If a Locator value
4389 + * is found, the function will search each VLYNQ device entry in the system
4390 + * looking for a matching Locator. Once it finds a VLYNQ device entry with
4391 + * a matching Locator, it will extract the "ResetBase" parameter from that
4392 + * VLYNQ device entry (thus every VLYNQ entry must have the ResetBase parameter).
4394 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
4395 + * @param ResetBase Pointer to integer address of reset register.
4397 + * @return 0 OK, Non-zero not OK
4399 +static int ResetBaseGet(HAL_DEVICE *HalDev, bit32u *ResetBase)
4401 + char *DeviceInfo = HalDev->DeviceInfo;
4402 + char *MyLocator, *NextLocator;
4404 + bit32u error_code;
4406 +#ifdef __CPHAL_DEBUG
4409 + dbgPrintf("[cpcommon]ResetBaseGet(HalDev:%08x, ResetBase:%08x)\n", (bit32u)HalDev, ResetBase);
4414 + error_code = HalDev->OsFunc->DeviceFindParmValue(DeviceInfo, "Locator", &MyLocator);
4417 + /* if no Locator value, device is on the root, so get the "reset" device */
4418 + error_code = HalDev->OsFunc->DeviceFindInfo(0, "reset", &DeviceInfo);
4421 + return(EC_VAL_DEVICE_NOT_FOUND);
4424 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, "base", ResetBase);
4427 + return(EC_VAL_BASE_ADDR_NOT_FOUND);
4430 + *ResetBase = ((bit32u)PhysToVirtNoCache(*ResetBase));
4432 + /* found base address for root device, so we're done */
4433 + return (EC_NO_ERRORS);
4437 + /* we have a Locator value, so the device is remote */
4439 + /* Find a vlynq device with a matching locator value */
4440 + while ((HalDev->OsFunc->DeviceFindInfo(Inst, "vlynq", &DeviceInfo)) == EC_NO_ERRORS)
4442 + error_code = HalDev->OsFunc->DeviceFindParmValue(DeviceInfo, "Locator", &NextLocator);
4445 + /* no Locator value for this VLYNQ, so move on */
4448 + if (HalDev->OsFunc->Strcmpi(MyLocator, NextLocator)==0)
4450 + /* we have found a VLYNQ with a matching Locator, so extract the ResetBase */
4451 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, "ResetBase", ResetBase);
4454 + return(EC_VAL_BASE_ADDR_NOT_FOUND);
4456 + *ResetBase = ((bit32u)PhysToVirtNoCache(*ResetBase));
4458 + /* found base address for root device, so we're done */
4459 + return (EC_NO_ERRORS);
4465 + return (EC_NO_ERRORS);
4469 +#ifndef _CPHAL_AAL2 /* + RC 3.02 */
4470 +static bit32u ConfigGetCommon(HAL_DEVICE *HalDev)
4474 + char *DeviceInfo = HalDev->DeviceInfo;
4476 +#ifdef __CPHAL_DEBUG
4479 + dbgPrintf("[cpcommon]ConfigGetCommon(HalDev:%08x)\n", (bit32u)HalDev);
4484 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszBase, &ParmValue);
4487 + return(EC_FUNC_HAL_INIT|EC_VAL_BASE_ADDR_NOT_FOUND);
4489 + HalDev->dev_base = ((bit32u)PhysToVirtNoCache(ParmValue));
4491 +#ifndef _CPHAL_AAL5
4492 +#ifndef _CPHAL_AAL2
4493 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszResetBit, &ParmValue);
4496 + return(EC_FUNC_HAL_INIT|EC_VAL_RESET_BIT_NOT_FOUND);
4498 + HalDev->ResetBit = ParmValue;
4500 + /* Get reset base address */
4501 + error_code = ResetBaseGet(HalDev, &ParmValue);
4503 + return(EC_FUNC_HAL_INIT|EC_VAL_RESET_BASE_NOT_FOUND);
4504 + HalDev->ResetBase = ParmValue;
4508 +#ifndef _CPHAL_CPSAR
4509 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszIntLine,&ParmValue);
4512 + return(EC_FUNC_HAL_INIT|EC_VAL_INTERRUPT_NOT_FOUND);
4514 + HalDev->interrupt = ParmValue;
4517 + /* only look for the offset if there is a Locator field, which indicates that
4518 + the module is a VLYNQ module */
4519 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszLocator,&ParmValue);
4522 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszOffset,&ParmValue);
4525 + return(EC_FUNC_HAL_INIT|EC_VAL_OFFSET_NOT_FOUND);
4527 + HalDev->offset = ParmValue;
4530 + HalDev->offset = 0;
4532 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszDebug, &ParmValue);
4533 + if (!error_code) HalDev->debug = ParmValue;
4535 + return (EC_NO_ERRORS);
4537 +#endif /* +RC 3.02 */
4539 +#ifdef _CPHAL_CPMAC /* +RC 3.02 */
4540 +static void StatsInit(HAL_DEVICE *HalDev) /* +() RC3.02 */
4542 + /* even though these statistics may be for multiple channels and
4543 + queues, i need only configure the pointer to the beginning
4544 + of the array, and I can index from there if necessary */
4547 + StatsTable0[0].StatPtr = &HalDev->Stats.CrcErrors[0];
4548 + StatsTable0[1].StatPtr = &HalDev->Stats.LenErrors[0];
4549 + StatsTable0[2].StatPtr = &HalDev->Stats.AbortErrors[0];
4550 + StatsTable0[3].StatPtr = &HalDev->Stats.StarvErrors[0];
4552 + StatsTable1[0].StatPtr = &HalDev->Stats.DmaLenErrors[0];
4553 + StatsTable1[1].StatPtr = &HalDev->Stats.TxMisQCnt[0][0];
4554 + StatsTable1[2].StatPtr = &HalDev->Stats.RxMisQCnt[0];
4555 + StatsTable1[3].StatPtr = &HalDev->Stats.TxEOQCnt[0][0];
4556 + StatsTable1[4].StatPtr = &HalDev->Stats.RxEOQCnt[0];
4557 + StatsTable1[5].StatPtr = &HalDev->Stats.RxPacketsServiced[0];
4558 + StatsTable1[6].StatPtr = &HalDev->Stats.TxPacketsServiced[0][0];
4559 + StatsTable1[7].StatPtr = &HalDev->Stats.RxMaxServiced;
4560 + StatsTable1[8].StatPtr = &HalDev->Stats.TxMaxServiced[0][0];
4561 + StatsTable1[9].StatPtr = &HalDev->Stats.RxTotal;
4562 + StatsTable1[10].StatPtr = &HalDev->Stats.TxTotal;
4565 +#if (defined(_CPHAL_AAL5) || defined(_CPHAL_CPMAC))
4566 + StatsTable2[0].StatPtr = (bit32u *)&HalDev->RcbPool[0];
4567 + StatsTable2[1].StatPtr = &HalDev->RxActQueueCount[0];
4568 + StatsTable2[2].StatPtr = (bit32u *)&HalDev->RxActQueueHead[0];
4569 + StatsTable2[3].StatPtr = (bit32u *)&HalDev->RxActQueueTail[0];
4570 + StatsTable2[4].StatPtr = &HalDev->RxActive[0];
4571 + StatsTable2[5].StatPtr = (bit32u *)&HalDev->RcbStart[0];
4572 + StatsTable2[6].StatPtr = &HalDev->RxTeardownPending[0];
4573 + StatsTable2[7].StatPtr = (bit32u *)&HalDev->TcbPool[0][0];
4574 + StatsTable2[8].StatPtr = &HalDev->TxActQueueCount[0][0];
4575 + StatsTable2[9].StatPtr = (bit32u *)&HalDev->TxActQueueHead[0][0];
4576 + StatsTable2[10].StatPtr = (bit32u *)&HalDev->TxActQueueTail[0][0];
4577 + StatsTable2[11].StatPtr = &HalDev->TxActive[0][0];
4578 + StatsTable2[12].StatPtr = (bit32u *)&HalDev->TcbStart[0][0];
4579 + StatsTable2[13].StatPtr = &HalDev->TxTeardownPending[0];
4581 + StatsTable3[0].StatPtr = &HalDev->ChData[0].RxBufSize;
4582 + StatsTable3[1].StatPtr = &HalDev->ChData[0].RxBufferOffset;
4583 + StatsTable3[2].StatPtr = &HalDev->ChData[0].RxNumBuffers;
4584 + StatsTable3[3].StatPtr = &HalDev->ChData[0].RxServiceMax;
4585 + StatsTable3[4].StatPtr = &HalDev->ChData[0].TxNumBuffers;
4586 + StatsTable3[5].StatPtr = &HalDev->ChData[0].TxNumQueues;
4587 + StatsTable3[6].StatPtr = &HalDev->ChData[0].TxServiceMax;
4589 + StatsTable3[7].StatPtr = &HalDev->ChData[0].CpcsUU;
4590 + StatsTable3[8].StatPtr = &HalDev->ChData[0].Gfc;
4591 + StatsTable3[9].StatPtr = &HalDev->ChData[0].Clp;
4592 + StatsTable3[10].StatPtr = &HalDev->ChData[0].Pti;
4593 + StatsTable3[11].StatPtr = &HalDev->ChData[0].DaMask;
4594 + StatsTable3[12].StatPtr = &HalDev->ChData[0].Priority;
4595 + StatsTable3[13].StatPtr = &HalDev->ChData[0].PktType;
4596 + StatsTable3[14].StatPtr = &HalDev->ChData[0].Vci;
4597 + StatsTable3[15].StatPtr = &HalDev->ChData[0].Vpi;
4598 + StatsTable3[16].StatPtr = &HalDev->ChData[0].TxVc_CellRate;
4599 + StatsTable3[17].StatPtr = &HalDev->ChData[0].TxVc_QosType;
4600 + StatsTable3[18].StatPtr = &HalDev->ChData[0].TxVc_Mbs;
4601 + StatsTable3[19].StatPtr = &HalDev->ChData[0].TxVc_Pcr;
4605 + StatsTable4[0].StatPtr = &HalDev->dev_base;
4606 + StatsTable4[1].StatPtr = &HalDev->offset;
4607 + StatsTable4[2].StatPtr = &HalDev->interrupt;
4608 + StatsTable4[3].StatPtr = &HalDev->debug;
4609 + StatsTable4[4].StatPtr = &HalDev->Inst;
4611 +#endif /* +RC 3.02 */
4613 +#ifndef _CPHAL_CPSAR /* +RC 3.02 */
4614 +#ifndef _CPHAL_AAL2 /* +RC 3.02 */
4616 + * Returns statistics information.
4618 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
4622 +static int StatsGet(HAL_DEVICE *HalDev, void **StatPtr, int Index, int Ch, int Queue)
4627 + STATS_TABLE *StatsTable;
4628 + int i, NumberOfStats;
4630 +#ifdef __CPHAL_DEBUG
4633 + dbgPrintf("[cpcommon]StatsGet(HalDev:%08x, StatPtr:%08x)\n",
4634 + (bit32u)HalDev, (bit32u)StatPtr);
4639 + StatsTable = StatsDb[Index].StatTable;
4640 + NumberOfStats = StatsDb[Index].NumberOfStats;
4642 + Size = sizeof(bit32u)*((NumberOfStats*2)+1);
4643 + Size += (NumberOfStats*11);
4644 + *StatPtr = (bit32u *)HalDev->OsFunc->Malloc(Size);
4646 + AddrPtr = (bit32u *) *StatPtr;
4647 + DataPtr = (char *)AddrPtr;
4648 + DataPtr += sizeof(bit32u)*((NumberOfStats*2)+1);
4650 + for (i=0; i<NumberOfStats; i++)
4652 + *AddrPtr++ = (bit32u)StatsTable[i].StatName;
4653 + *AddrPtr++ = (bit32u)DataPtr;
4654 + if (&StatsTable[i].StatPtr[Ch] != 0)
4656 + switch(StatsTable[i].DataType)
4659 + HalDev->OsFunc->Sprintf(DataPtr, "%d", (bit32u *)StatsTable[i].StatPtr[Ch]);
4662 + HalDev->OsFunc->Sprintf(DataPtr, "0x%x", (bit32u *)StatsTable[i].StatPtr[Ch]);
4665 + HalDev->OsFunc->Sprintf(DataPtr, "%d", *((bit32u *)StatsTable[i].StatPtr + (Ch * (sizeof(CHANNEL_INFO)/4))));
4668 + HalDev->OsFunc->Sprintf(DataPtr, "%d", *((bit32u *)StatsTable[i].StatPtr + (Ch*MAX_QUEUE)+Queue));
4671 + HalDev->OsFunc->Sprintf(DataPtr, "0x%x", *((bit32u *)StatsTable[i].StatPtr + (Ch*MAX_QUEUE)+Queue));
4674 + /* invalid data type, due to CPHAL programming error */
4680 + /* invalid statistics pointer, probably was not initialized */
4682 + DataPtr += HalDev->OsFunc->Strlen(DataPtr) + 1;
4685 + *AddrPtr = (bit32u) 0;
4687 + return (EC_NO_ERRORS);
4689 +#endif /* +RC 3.02 */
4690 +#endif /* +RC 3.02 */
4692 +#ifdef _CPHAL_CPMAC
4693 +static void gpioFunctional(int base, int bit)
4695 + bit32u GpioEnr = base + 0xC;
4696 + /* To make functional, set to zero */
4697 + *(volatile bit32u *)(GpioEnr) &= ~(1 << bit); /*+RC3.02*/
4702 +/* Common function, Checks to see if GPIO should be in functional mode */
4703 +static void gpioCheck(HAL_DEVICE *HalDev, void *moduleDeviceInfo)
4708 + char pszMuxBit[20];
4710 + char szMuxBit[20];
4715 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
4717 + rc = OsFunc->DeviceFindParmValue(moduleDeviceInfo, "gpio_mux",&pszTmp);
4719 + /* gpio entry found, get GPIO register info and make functional */
4721 + /* temp copy until FinParmValue fixed */
4722 + ptr = &szMuxBit[0];
4723 + while ((*ptr++ = *pszTmp++));
4725 + pszMuxBits = &szMuxBit[0];
4727 + rc = OsFunc->DeviceFindInfo(0,"gpio",&DeviceInfo);
4730 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "base",&base);
4733 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "reset_bit",&reset_bit);
4736 + /* If GPIO still in reset, then exit */
4737 + if((VOLATILE32(HalDev->ResetBase) & (1 << reset_bit)) == 0)
4739 + /* format for gpio_mux is gpio_mux = <int>;<int>;<int>...*/
4740 + while (*pszMuxBits)
4742 + pszTmp = &pszMuxBit[0];
4743 + if(*pszMuxBits == ';') pszMuxBits++;
4744 + while ((*pszMuxBits != ';') && (*pszMuxBits != '\0'))
4747 + /*If value not a number, skip */
4748 + if((*pszMuxBits < '0') || (*pszMuxBits > '9'))
4751 + *pszTmp++ = *pszMuxBits++;
4754 + bit = OsFunc->Strtoul(pszMuxBit, &pszTmp, 10);
4755 + gpioFunctional(base, bit);
4756 + resetWait(HalDev); /* not sure if this is needed */
4762 +const char hcSarFrequency[] = "SarFreq";
4766 diff -urN linux.old/drivers/atm/sangam_atm/cpcommon_cpsar.h linux.dev/drivers/atm/sangam_atm/cpcommon_cpsar.h
4767 --- linux.old/drivers/atm/sangam_atm/cpcommon_cpsar.h 1970-01-01 01:00:00.000000000 +0100
4768 +++ linux.dev/drivers/atm/sangam_atm/cpcommon_cpsar.h 2005-07-10 08:02:01.423114552 +0200
4770 +#ifndef _INC_CPCOMMON_H
4771 +#define _INC_CPCOMMON_H
4773 +#define VOLATILE32(addr) (*(volatile bit32u *)(addr))
4775 +#define dbgPrintf HalDev->OsFunc->Printf
4778 +#define ChannelUpdate(Field) if(HalChn->Field != 0xFFFFFFFF) HalDev->ChData[Ch].Field = HalChn->Field
4780 +#define DBG(level) (HalDev->debug & (1<<(level)))
4782 +#define DBG0() DBG(0)
4783 +#define DBG1() DBG(1)
4784 +#define DBG2() DBG(2)
4785 +#define DBG3() DBG(3)
4786 +#define DBG4() DBG(4)
4787 +#define DBG5() DBG(5)
4788 +#define DBG6() DBG(6)
4789 +#define DBG7() DBG(7)
4793 + * List of defined actions for use with Control().
4797 + enGET=0, /**< Get the value associated with a key */
4798 + enSET, /**< Set the value associates with a key */
4799 + enCLEAR, /**<Clear the value */
4800 + enNULL /**< No data action, used to initiate a service or send a message */
4804 + * Enumerated hardware states.
4808 + enConnected=1, enDevFound, enInitialized, enOpened
4815 + enOff, enOn, enDebug,
4816 + /* Module General */
4824 + const char *strKey;
4831 + unsigned int *StatPtr;
4832 + int DataType; /* 0: int, 1: hex int, 2:channel data */
4837 + int NumberOfStats;
4838 + STATS_TABLE *StatTable;
4841 +#define osfuncSioFlush() HalDev->OsFunc->Control(HalDev->OsDev,"SioFlush",pszNULL,0)
4842 +#define osfuncSleep(Ticks) HalDev->OsFunc->Control(HalDev->OsDev,pszSleep,pszNULL,Ticks)
4843 +#define osfuncStateChange() HalDev->OsFunc->Control(HalDev->OsDev,pszStateChange,pszNULL,0)
4845 +#define CHANNEL_NAMES {"Ch0","Ch1","Ch2","Ch3","Ch4","Ch5","Ch6","Ch7","Ch8","Ch9","Ch10","Ch11","Ch12","Ch13","Ch14","Ch15"}
4849 diff -urN linux.old/drivers/atm/sangam_atm/cppi_cpaal5.c linux.dev/drivers/atm/sangam_atm/cppi_cpaal5.c
4850 --- linux.old/drivers/atm/sangam_atm/cppi_cpaal5.c 1970-01-01 01:00:00.000000000 +0100
4851 +++ linux.dev/drivers/atm/sangam_atm/cppi_cpaal5.c 2005-07-10 08:02:01.425114248 +0200
4853 +/*************************************************************************
4854 + * TNETDxxxx Software Support
4855 + * Copyright (c) 2002,2003 Texas Instruments Incorporated. All Rights Reserved.
4860 + * This file contains shared code for all CPPI modules.
4863 + * 7Aug02 Greg RC1.00 Original Version created.
4864 + * 27Sep02 Mick RC1.01 Merged for use by CPMAC/CPSAR
4865 + * 16Oct02 Mick RC1.02 Performance Tweaks (see cppihist.txt)
4866 + * 12Nov02 Mick RC1.02 Updated to use cpmac_reg.h
4867 + * 09Jan03 Mick RC3.01 Removed modification to RxBuffer ptr
4868 + * 28Mar03 Mick 1.03 RxReturn now returns error if Malloc Fails
4869 + * 10Apr03 Mick 1.03.02 Added Needs Buffer Support
4870 + * 11Jun03 Mick 1.06.02 halSend() errors corrected
4872 + * @author Greg Guyotte
4874 + * @date 7-Aug-2002
4875 + *****************************************************************************/
4876 +/* each CPPI module must modify this file, the rest of the
4877 + code in cppi.c should be totally shared *//* Each CPPI module MUST properly define all constants shown below */
4879 +/* CPPI registers */
4881 +/* the following defines are not CPPI specific, but still used by cppi.c */
4883 +static void FreeRx(HAL_DEVICE *HalDev, int Ch)
4885 + HAL_RCB *rcb_ptr; /*+GSG 030303*/
4886 + int rcbSize = (sizeof(HAL_RCB)+0xf)&~0xf; /*+GSG 030303*/
4887 + int Num = HalDev->ChData[Ch].RxNumBuffers, i; /*+GSG 030303*/
4889 + /* Free Rx data buffers attached to descriptors, if necessary */
4890 + if (HalDev->RcbStart[Ch] != 0) /*+GSG 030303*/
4892 + for(i=0;i<Num;i++) /*+GSG 030303*/
4894 + rcb_ptr = (HAL_RCB *)(HalDev->RcbStart[Ch] + (i*rcbSize)); /*+GSG 030303*/
4896 + /* free the data buffer */
4897 + if (rcb_ptr->DatPtr != 0)
4900 + HalDev->OsFunc->FreeRxBuffer((void *)rcb_ptr->OsInfo, (void *)rcb_ptr->DatPtr);
4901 + rcb_ptr->OsInfo=0; /*MJH+030522*/
4902 + rcb_ptr->DatPtr=0; /*MJH+030522*/
4907 + /* free up all desciptors at once */
4908 + HalDev->OsFunc->FreeDmaXfer(HalDev->RcbStart[Ch]);
4910 + /* mark buffers as freed */
4911 + HalDev->RcbStart[Ch] = 0;
4914 +static void FreeTx(HAL_DEVICE *HalDev, int Ch, int Queue)
4919 + /* free all descriptors at once */
4920 + HalDev->OsFunc->FreeDmaXfer(HalDev->TcbStart[Ch][Queue]);
4922 + HalDev->TcbStart[Ch][Queue] = 0;
4925 +/* return of 0 means that this code executed, -1 means the interrupt was not
4926 + a teardown interrupt */
4927 +static int RxTeardownInt(HAL_DEVICE *HalDev, int Ch)
4929 + bit32u base = HalDev->dev_base;
4932 + volatile bit32u *pTmp;
4934 + /* check to see if the interrupt is a teardown interrupt */
4935 + if (((*(pRX_CPPI_COMP_PTR( base )+( Ch *64))) & TEARDOWN_VAL) == TEARDOWN_VAL)
4937 + /* finish channel teardown */
4939 + /* Free channel resources on a FULL teardown */
4940 + if (HalDev->RxTeardownPending[Ch] & FULL_TEARDOWN)
4942 + FreeRx(HalDev, Ch);
4945 + /* bug fix - clear Rx channel pointers on teardown */
4946 + HalDev->RcbPool[Ch] = 0;
4947 + HalDev->RxActQueueHead[Ch] = 0;
4948 + HalDev->RxActQueueCount[Ch] = 0;
4949 + HalDev->RxActive[Ch] = FALSE;
4951 + /* write completion pointer */
4952 + (*(pRX_CPPI_COMP_PTR( base )+( Ch *64))) = TEARDOWN_VAL;
4954 + /* use direction bit as a teardown pending bit! May be able to
4955 + use only one teardown pending integer in HalDev */
4957 + HalDev->RxTeardownPending[Ch] &= ~RX_TEARDOWN;
4959 + HalDev->ChIsOpen[Ch][DIRECTION_RX] = 0;
4961 + /* call OS Teardown Complete (if TX is also done) */
4962 + if ((HalDev->TxTeardownPending[Ch] & TX_TEARDOWN) == 0)
4964 + /* mark channel as closed */
4965 + HalDev->ChIsOpen[Ch][DIRECTION_TX] = 0;
4967 + /* disable channel interrupt */
4968 + SAR_TX_MASK_CLR(HalDev->dev_base) = (1<<Ch);
4969 + SAR_TX_MASK_CLR(HalDev->dev_base) = (1<<(Ch+16)); /* +GSG 030307 */
4970 + SAR_RX_MASK_CLR(HalDev->dev_base) = (1<<Ch);
4972 + /* Clear PDSP Channel State RAM */
4973 + pTmp = (pPDSP_BLOCK_0(HalDev->dev_base)+(Ch*64));
4974 + for (i=0; i<NUM_PDSP_AAL5_STATE_WORDS; i++)
4977 + if ((HalDev->RxTeardownPending[Ch] & BLOCKING_TEARDOWN) == 0)
4980 + HalDev->OsFunc->TeardownComplete(HalDev->OsDev, Ch, DIRECTION_TX|DIRECTION_RX);
4982 + /* clear all teardown pending information for this channel */
4983 + HalDev->RxTeardownPending[Ch] = 0;
4984 + HalDev->TxTeardownPending[Ch] = 0;
4987 + return (EC_NO_ERRORS);
4992 +/* return of 0 means that this code executed, -1 means the interrupt was not
4993 + a teardown interrupt */
4994 +static int TxTeardownInt(HAL_DEVICE *HalDev, int Ch, int Queue)
4996 + bit32u base = HalDev->dev_base;
4997 + HAL_TCB *Last, *Curr, *First; /*+GSG 030303*/
5000 + volatile bit32u *pTmp;
5002 + if (((*(pTXH_CPPI_COMP_PTR( base )+( Ch *64)+( Queue ))) & TEARDOWN_VAL) == TEARDOWN_VAL)
5004 + /* return outstanding buffers to OS +RC3.02*/
5005 + Curr = HalDev->TxActQueueHead[Ch][Queue]; /*+GSG 030303*/
5006 + First = Curr; /*+GSG 030303*/
5007 + while (Curr) /*+GSG 030303*/
5009 + /* Pop TCB(s) for packet from the stack */ /*+GSG 030303*/
5010 + Last = Curr->Eop; /*+GSG 030303*/
5011 + HalDev->TxActQueueHead[Ch][Queue] = Last->Next; /*+GSG 030303*/
5013 + /* return to OS */ /*+GSG 030303*/
5014 + HalDev->OsFunc->SendComplete(Curr->OsInfo); /*+GSG 030303*/
5016 + /* Push Tcb(s) back onto the stack */ /*+GSG 030303*/
5017 + Curr = Last->Next; /*+GSG 030303*/
5018 + Last->Next = HalDev->TcbPool[Ch][Queue]; /*+GSG 030303*/
5019 + HalDev->TcbPool[Ch][Queue] = First; /*+GSG 030303*/
5021 + /* set the first(SOP) pointer for the next packet */ /*+GSG 030303*/
5022 + First = Curr; /*+GSG 030303*/
5025 + /* finish channel teardown */
5027 + /* save the OsInfo to pass to upper layer
5028 + THIS WAS CRASHING - because it's possible that I get the teardown
5029 + notification and the TcbHPool is null. In this case, the buffers
5030 + to free can be found in the TxHActiveQueue. If I need to get OsInfo
5031 + in the future, I can get it from one of those buffers.
5032 + OsInfo = HalDev->TcbHPool[Ch]->OsInfo; */
5034 + if (HalDev->TxTeardownPending[Ch] & FULL_TEARDOWN)
5036 + FreeTx(HalDev, Ch, Queue);
5037 + } /* if FULL teardown */
5039 + /* bug fix - clear Tx channel pointers on teardown */
5040 + HalDev->TcbPool[Ch][Queue] = 0;
5041 + HalDev->TxActQueueHead[Ch][Queue] = 0;
5042 + HalDev->TxActQueueCount[Ch][Queue] = 0;
5043 + HalDev->TxActive[Ch][Queue] = FALSE;
5045 + /* write completion pointer */
5046 + (*(pTXH_CPPI_COMP_PTR( base )+( Ch *64)+( Queue ))) = TEARDOWN_VAL;
5048 + /* no longer pending teardown */
5049 + HalDev->TxTeardownPending[Ch] &= ~TX_TEARDOWN;
5051 + HalDev->ChIsOpen[Ch][DIRECTION_TX] = 0;
5053 + /* call OS Teardown Complete (if Rx is also done) */
5054 + if ((HalDev->RxTeardownPending[Ch] & RX_TEARDOWN) == 0)
5056 + /* mark channel as closed */
5057 + HalDev->ChIsOpen[Ch][DIRECTION_RX] = 0;
5059 + /* disable channel interrupt */
5060 + SAR_TX_MASK_CLR(HalDev->dev_base) = (1<<Ch);
5061 + SAR_TX_MASK_CLR(HalDev->dev_base) = (1<<(Ch+16)); /* +GSG 030307 */
5062 + SAR_RX_MASK_CLR(HalDev->dev_base) = (1<<Ch);
5064 + /* Clear PDSP Channel State RAM */
5065 + pTmp = (pPDSP_BLOCK_0(HalDev->dev_base)+(Ch*64));
5066 + for (i=0; i<NUM_PDSP_AAL5_STATE_WORDS; i++)
5069 + if ((HalDev->TxTeardownPending[Ch] & BLOCKING_TEARDOWN) == 0)
5072 + HalDev->OsFunc->TeardownComplete(HalDev->OsDev, Ch, DIRECTION_TX|DIRECTION_RX);
5075 + /* clear all teardown pending information for this channel */
5076 + HalDev->RxTeardownPending[Ch] = 0;
5077 + HalDev->TxTeardownPending[Ch] = 0;
5080 + return (EC_NO_ERRORS);
5086 +static void AddToRxQueue(HAL_DEVICE *HalDev, HAL_RCB *FirstRcb, HAL_RCB *LastRcb, int FragCount, int Ch)
5088 + HAL_RCB *OldTailRcb;
5090 + if (HalDev->RxActQueueCount[Ch]==0)
5093 + HalDev->RxActQueueHead[Ch]=FirstRcb;
5094 + HalDev->RxActQueueTail[Ch]=LastRcb;
5095 + HalDev->RxActQueueCount[Ch]=FragCount;
5096 + if ((!HalDev->InRxInt[Ch])&&(!HalDev->RxActive[Ch]))
5098 + /* write Rx Queue Head Descriptor Pointer */
5099 + (*(pRX_DMA_STATE_WORD_1( HalDev->dev_base )+( Ch *64))) = VirtToPhys(FirstRcb) - HalDev->offset;
5100 + HalDev->RxActive[Ch]=TRUE;
5106 + OldTailRcb=HalDev->RxActQueueTail[Ch];
5107 + OldTailRcb->Next=(void *)FirstRcb;
5109 + /* Emerald fix 10/29 (Denis) */
5110 + *((bit32u *) VirtToVirtNoCache(&OldTailRcb->HNext))=VirtToPhys(FirstRcb) - HalDev->offset;
5112 + HalDev->RxActQueueTail[Ch]=LastRcb;
5113 + HalDev->RxActQueueCount[Ch]+=FragCount;
5118 + * @ingroup CPHAL_Functions
5119 + * This function is called to indicate to the CPHAL that the upper layer
5120 + * software has finished processing the receive data (given to it by
5121 + * osReceive()). The CPHAL will then return the appropriate receive buffers
5122 + * and buffer descriptors to the available pool.
5124 + * @param HalReceiveInfo Start of receive buffer descriptor chain returned to
5126 + * @param StripFlag Flag indicating whether the upper layer software has
5127 + * retained ownership of the receive data buffers.
5129 + * 'FALSE' means that the CPHAL can reuse the receive data buffers.
5131 + * 'TRUE' : indicates the data buffers were retained by the OS
5133 + * NOTE: If StripFlag is TRUE, it is the responsibility of the upper layer software to free the buffers when they are no longer needed.
5135 + * @return EC_NO_ERRORS (ok). <BR>
5136 + * Possible Error Codes:<BR>
5137 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
5138 + * @ref EC_VAL_RCB_NEEDS_BUFFER "EC_VAL_RCB_NEEDS_BUFFER"<BR>
5139 + * @ref EC_VAL_RCB_DROPPED "EC_VAL_RCB_DROPPED"<BR>
5141 +static int halRxReturn(HAL_RECEIVEINFO *HalReceiveInfo,
5144 + int Ch = HalReceiveInfo->Ch, i;
5145 + HAL_RCB *LastRcb, *TempRcb;
5147 + HAL_RCB *CurrHeadRcb = HalReceiveInfo, *LastGoodRcb=0; /* +GSG 030421 */
5148 + HAL_DEVICE *HalDev = HalReceiveInfo->HalDev;
5149 + int RcbSize = HalDev->ChData[Ch].RxBufSize;
5150 + int FragCount = HalReceiveInfo->FragCount;
5151 + int rc=0; /*MJH+030417*/
5152 + int GoodCount=0; /*GSG+030421*/
5154 + if (HalDev->State != enOpened)
5155 + return(EC_AAL5 |EC_FUNC_RXRETURN|EC_VAL_INVALID_STATE);
5157 + LastRcb=(HAL_RCB *)HalReceiveInfo->Eop;
5163 + LastRcb->Off_BLen=RcbSize;
5164 + LastRcb->mode=CB_OWNERSHIP_BIT;
5167 + HalReceiveInfo->Off_BLen=RcbSize;
5168 + HalReceiveInfo->mode=CB_OWNERSHIP_BIT;
5170 + /* If OS has kept the buffers for this packet, attempt to alloc new buffers */
5173 + TempRcb = HalReceiveInfo;
5174 + for (i=0; i<FragCount; i++)
5178 + dbgPrintf("Rx Return error while allocating new buffers\n");
5179 + dbgPrintf("Rcb = %08x, Rcb->Eop = %08x, FragCount = %d:%d\n",
5180 + (bit32u)HalReceiveInfo, (bit32u)HalReceiveInfo->Eop, FragCount,i);
5183 + return(EC_CPPI|EC_FUNC_RXRETURN|EC_VAL_CORRUPT_RCB_CHAIN);
5186 + /* size = ((RcbSize+15) & ~15) + 15;*/ /*-3.01b*/
5187 + /*size = RcbSize + 15;*/ /* -GSG 030421 */
5188 + pBuf= (char *) HalDev->OsFunc->MallocRxBuffer(RcbSize,0,
5189 + 0xF,HalDev->ChData[Ch].OsSetup,
5191 + (void *)&TempRcb->OsInfo,
5192 + (void *) HalDev->OsDev);
5195 + /* malloc failed, add this RCB to Needs Buffer List */
5196 + TempRcb->FragCount = 1; /*MJH+030417*/
5197 + (HAL_RCB *)TempRcb->Eop = TempRcb; /* GSG +030430 */
5199 + if(HalDev->NeedsCount < MAX_NEEDS) /* +MJH 030410 */
5200 + { /* +MJH 030410 */
5201 + HalDev->Needs[HalDev->NeedsCount] = (HAL_RECEIVEINFO *) TempRcb; /* +MJH 030410 */
5202 + HalDev->NeedsCount++; /* +MJH 030410 */
5203 + rc = (EC_CPPI|EC_FUNC_RXRETURN|EC_VAL_RCB_NEEDS_BUFFER); /* ~MJH 030417 */
5204 + } /* +MJH 030410 */
5205 + else /* +MJH 030410 */
5206 + rc = (EC_CPPI|EC_FUNC_RXRETURN|EC_VAL_RCB_DROPPED); /* ~MJH 030417 */
5208 + /* requeue any previous RCB's that were ready to go before this one */
5209 + if (GoodCount > 0) /* +GSG 030421 */
5210 + { /* +GSG 030421 */
5211 + LastGoodRcb->HNext=0; /* +GSG 030430 */
5212 + LastGoodRcb->Next=0; /* +GSG 030430 */
5213 + osfuncDataCacheHitWriteback((void *)LastGoodRcb, 16); /* +GSG 030430 */
5215 + AddToRxQueue(HalDev, CurrHeadRcb, LastGoodRcb, GoodCount, Ch); /* +GSG 030421 */
5216 + GoodCount = 0; /* +GSG 030421 */
5217 + } /* +GSG 030421 */
5219 + CurrHeadRcb = TempRcb->Next; /* +GSG 030421 */
5221 + else /* +GSG 030421 */
5222 + { /* +GSG 030421 */
5223 + /* malloc succeeded, requeue the RCB to the hardware */
5224 + TempRcb->BufPtr=VirtToPhys(pBuf) - HalDev->offset;
5225 + TempRcb->DatPtr=pBuf;
5226 + /* Emerald fix 10/29 */
5227 + osfuncDataCacheHitWriteback((void *)TempRcb, 16);
5229 + /* i store the last good RCB in case the malloc fails for the
5230 + next fragment. This ensures that I can go ahead and return
5231 + a partial chain of RCB's to the hardware */
5232 + LastGoodRcb = TempRcb; /* +GSG 030421 */
5233 + GoodCount++; /* +GSG 030421 */
5234 + } /* +GSG 030421 */
5235 + TempRcb = TempRcb->Next;
5236 + } /* end of Frag loop */
5237 + /* if there any good RCB's to requeue, do so here */
5238 + if (GoodCount > 0) /* +GSG 030421 */
5240 + AddToRxQueue(HalDev, CurrHeadRcb, LastGoodRcb, GoodCount, Ch); /* +GSG 030421 */
5242 + return(rc); /* ~GSG 030421 */
5246 + /* Not Stripping */
5248 + /* Write Back SOP and last RCB */
5249 + osfuncDataCacheHitWriteback((void *)HalReceiveInfo, 16);
5251 + if (FragCount > 1)
5253 + osfuncDataCacheHitWriteback((void *)LastRcb, 16);
5255 + /* if not stripping buffers, always add to queue */
5256 + AddToRxQueue(HalDev, HalReceiveInfo, LastRcb, FragCount, Ch); /*MJH~030520*/
5259 + return(EC_NO_ERRORS);
5263 + Trys to liberate an RCB until liberation fails.
5264 + Note: If liberation fails then RxReturn will re-add the RCB to the
5267 +static void NeedsCheck(HAL_DEVICE *HalDev)
5269 + HAL_RECEIVEINFO* HalRcb;
5271 + HalDev->OsFunc->CriticalOn();
5272 + while(HalDev->NeedsCount)
5274 + HalDev->NeedsCount--;
5275 + HalRcb = HalDev->Needs[HalDev->NeedsCount];
5276 + rc = halRxReturn(HalRcb, 1);
5277 + /* short circuit if RxReturn starts to fail */
5281 + HalDev->OsFunc->CriticalOff();
5285 + * This function allocates transmit buffer descriptors (internal CPHAL function).
5286 + * It creates a high priority transmit queue by default for a single Tx
5287 + * channel. If QoS is enabled for the given CPHAL device, this function
5288 + * will also allocate a low priority transmit queue.
5290 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
5291 + * @param Ch Channel number.
5293 + * @return 0 OK, Non-Zero Not OK
5295 +static int InitTcb(HAL_DEVICE *HalDev, int Ch)
5297 + int i, Num = HalDev->ChData[Ch].TxNumBuffers;
5300 + int tcbSize, Queue;
5303 + tcbSize = (sizeof(HAL_TCB)+0xf)&~0xf;
5304 + SizeMalloc = (tcbSize*Num)+0xf;
5306 + for (Queue=0; Queue < HalDev->ChData[Ch].TxNumQueues; Queue++)
5308 + if (HalDev->TcbStart[Ch][Queue] == 0)
5311 + /* malloc all TCBs at once */
5312 + AllTcb = (char *)HalDev->OsFunc->MallocDmaXfer(SizeMalloc,0,0xffffffff);
5315 + return(EC_CPPI|EC_FUNC_HAL_INIT|EC_VAL_TCB_MALLOC_FAILED);
5318 + HalDev->OsFunc->Memset(AllTcb, 0, SizeMalloc);
5320 + /* keep this address for freeing later */
5321 + HalDev->TcbStart[Ch][Queue] = AllTcb;
5325 + /* if the memory has already been allocated, simply reuse it! */
5326 + AllTcb = HalDev->TcbStart[Ch][Queue];
5329 + /* align to cache line */
5330 + AllTcb = (char *)(((bit32u)AllTcb + 0xf) &~ 0xf); /*PITS #143 MJH~030522*/
5332 + /* default High priority transmit queue */
5333 + HalDev->TcbPool[Ch][Queue]=0;
5334 + for(i=0;i<Num;i++)
5336 + /*pTcb=(HAL_TCB *) OsFunc->MallocDmaXfer(sizeof(HAL_TCB),0,0xffffffff); */
5337 + pTcb= (HAL_TCB *)(AllTcb + (i*tcbSize));
5340 + pTcb->Next=HalDev->TcbPool[Ch][Queue];
5342 + HalDev->TcbPool[Ch][Queue]=pTcb;
5344 + /*HalDev->TcbEnd = pTcb;*/
5347 + return(EC_NO_ERRORS);
5351 + * This function allocates receive buffer descriptors (internal CPHAL function).
5352 + * After allocation, the function 'queues' (gives to the hardware) the newly
5353 + * created receive buffers to enable packet reception.
5355 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
5356 + * @param Ch Channel number.
5358 + * @return 0 OK, Non-Zero Not OK
5360 +static int InitRcb(HAL_DEVICE *HalDev, int Ch)
5362 + int i, Num = HalDev->ChData[Ch].RxNumBuffers;
5363 + int Size = HalDev->ChData[Ch].RxBufSize;
5372 + rcbSize = (sizeof(HAL_RCB)+0xf)&~0xf;
5373 + SizeMalloc = (rcbSize*Num)+0xf;
5375 + if (HalDev->RcbStart[Ch] == 0)
5379 + /* malloc all RCBs at once */
5380 + AllRcb= (char *)HalDev->OsFunc->MallocDmaXfer(SizeMalloc,0,0xffffffff);
5383 + return(EC_CPPI|EC_FUNC_HAL_INIT|EC_VAL_RCB_MALLOC_FAILED);
5386 + HalDev->OsFunc->Memset(AllRcb, 0, SizeMalloc);
5388 + /* keep this address for freeing later */
5389 + HalDev->RcbStart[Ch] = AllRcb;
5393 + /* if the memory has already been allocated, simply reuse it! */
5394 + AllRcb = HalDev->RcbStart[Ch];
5397 + /* align to cache line */
5398 + AllRcb = (char *)(((bit32u)AllRcb + 0xf)&~0xf); /*PITS #143 MJH~030522*/
5400 + HalDev->RcbPool[Ch]=0;
5401 + for(i=0;i<Num;i++)
5403 + pRcb = (HAL_RCB *)(AllRcb + (i*rcbSize));
5405 + if (DoMalloc == 1)
5408 + MallocSize = Size; /*~3.01 */
5409 + pBuf= (char *) HalDev->OsFunc->MallocRxBuffer(MallocSize,0,0xF,HalDev->ChData[Ch].OsSetup, (void *)pRcb, (void *)&pRcb->OsInfo, (void *) HalDev->OsDev);
5412 + return(EC_CPPI|EC_FUNC_HAL_INIT|EC_VAL_RX_BUFFER_MALLOC_FAILED);
5414 + /* -RC3.01 pBuf = (char *)(((bit32u)pBuf+0xF) & ~0xF); */
5415 + pRcb->BufPtr=VirtToPhys(pBuf) - HalDev->offset;
5416 + pRcb->DatPtr=pBuf;
5417 + /*pRcb->BufSize=Size;*/
5421 + pRcb->Next=(void *)HalDev->RcbPool[Ch];
5423 + pRcb->HalDev = HalDev;
5424 + HalDev->RcbPool[Ch]=pRcb;
5427 + /* Give all of the Rx buffers to hardware */
5429 + while(HalDev->RcbPool[Ch])
5431 + pRcb=HalDev->RcbPool[Ch];
5432 + HalDev->RcbPool[Ch]=pRcb->Next;
5433 + pRcb->Eop=(void*)pRcb;
5434 + pRcb->FragCount=1;
5435 + halRxReturn((HAL_RECEIVEINFO *)pRcb, 0);
5438 + return(EC_NO_ERRORS);
5442 + * @ingroup CPHAL_Functions
5443 + * This function transmits the data in FragList using available transmit
5444 + * buffer descriptors. More information on the use of the Mode parameter
5445 + * is available in the module-specific appendices. Note: The OS should
5446 + * not call Send() for a channel that has been requested to be torndown.
5448 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
5449 + * @param FragList Fragment List structure.
5450 + * @param FragCount Number of fragments in FragList.
5451 + * @param PacketSize Number of bytes to transmit.
5452 + * @param OsSendInfo OS Send Information structure. <BR>
5453 + * @param Mode 32-bit value with the following bit fields: <BR>
5454 + * 31-16: Mode (used for module specific data). <BR>
5455 + * 15-08: Queue (transmit queue to send on). <BR>
5456 + * 07-00: Channel (channel number to send on).
5458 + * @return EC_NO_ERRORS (ok). <BR>
5459 + * Possible Error Codes:<BR>
5460 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
5461 + * @ref EC_VAL_NOT_LINKED "EC_VAL_NOT_LINKED"<BR>
5462 + * @ref EC_VAL_INVALID_CH "EC_VAL_INVALID_CH"<BR>
5463 + * @ref EC_VAL_OUT_OF_TCBS "EC_VAL_OUT_OF_TCBS"<BR>
5464 + * @ref EC_VAL_NO_TCBS "EC_VAL_NO_TCBS"<BR>
5466 +static int halSend(HAL_DEVICE *HalDev,FRAGLIST *FragList,
5467 + int FragCount,int PacketSize, OS_SENDINFO *OsSendInfo,
5470 + HAL_TCB *tcb_ptr, *head;
5472 + bit32u base = HalDev->dev_base;
5473 + int rc = EC_NO_ERRORS;
5474 + int Ch = Mode & 0xFF;
5475 + int Queue = (Mode>>8)&0xFF;
5477 + int WaitFlag = (Mode>>30)&1; /* This is for AAL5 testing only */ /* ~GSG 030508 */
5478 + int Offset = (FragList[0].len >> 16);
5479 + int PktType = (Mode>>16)&3; /* 0=AAL5, 1=Null AAL, 2=OAM, 3=Transparent */ /* +GSG 030508 */
5480 + int AtmHeaderInData = (Mode>>31)&1; /* +GSG 030508 */
5481 + int FragIndex = 0;
5483 + if (HalDev->State != enOpened)
5484 + return(EC_CPPI|EC_FUNC_SEND|EC_VAL_INVALID_STATE);
5486 + if (HalDev->ChIsOpen[Ch][DIRECTION_TX] == 0) /*MJH~030611*/ /*PITS 148*/
5487 + return(EC_AAL5 |EC_FUNC_SEND|EC_VAL_INVALID_CH); /*+GSG 030303*/
5489 + HalDev->OsFunc->CriticalOn();
5491 + tcb_ptr = head = HalDev->TcbPool[Ch][Queue];
5496 + /* these two TCB words are only valid on SOP */
5497 + if (AtmHeaderInData == 1)
5499 + tcb_ptr->AtmHeader = 0; /* bug fix for transparent mode PTI problem */
5500 + /* Expect AtmHeader in the data */
5501 + tcb_ptr->AtmHeader |= *((bit8u *)FragList[FragIndex].data++) << 24;
5502 + tcb_ptr->AtmHeader |= *((bit8u *)FragList[FragIndex].data++) << 16;
5503 + tcb_ptr->AtmHeader |= *((bit8u *)FragList[FragIndex].data++) << 8;
5504 + tcb_ptr->AtmHeader |= *((bit8u *)FragList[FragIndex].data++);
5506 + /* decrement data buffer length accordingly */
5507 + FragList[FragIndex].len -= ATM_HEADER_SIZE;
5509 + /* if the first fragment was ATM Header only, go to next fragment for loop */
5510 + if (FragList[FragIndex].len == 0)
5513 + /* No CPCS_UU/CPI if not AAL5 */
5514 + tcb_ptr->Word5 = ((PktType & 0x3)<<16);
5518 + /* calculate AtmHeader from fields */
5519 + tcb_ptr->AtmHeader = atmheader(HalDev->ChData[Ch].Gfc, /* ~GSG 030306 */
5520 + HalDev->ChData[Ch].Vpi, HalDev->ChData[Ch].Vci,
5521 + HalDev->ChData[Ch].Pti, HalDev->ChData[Ch].Clp);
5523 + tcb_ptr->Word5 = HalDev->ChData[Ch].CpcsUU | ((HalDev->ChData[Ch].PktType &0x3)<<16);
5526 + for (i=FragIndex; i<FragCount; i++)
5529 + /* Setup Tx mode and size */
5530 + tcb_ptr->HNext = VirtToPhys((bit32 *)tcb_ptr->Next) - HalDev->offset;
5531 + tcb_ptr->Off_BLen = FragList[i].len;
5534 + tcb_ptr->Off_BLen |= (Offset << 16);
5536 + tcb_ptr->mode = 0; /* MUST clear this for each frag !!! */
5537 + tcb_ptr->BufPtr = VirtToPhys((bit32 *)FragList[i].data) -
5540 + /* first fragment */
5543 + tcb_ptr->mode |= CB_SOF_BIT;
5547 + tcb_ptr->mode |= (PacketSize | CB_OWNERSHIP_BIT);
5548 + tcb_ptr->OsInfo = OsSendInfo;
5550 + if (i == (FragCount - 1))
5552 + /* last fragment */
5553 + tcb_ptr->mode |= CB_EOF_BIT;
5555 + /* since this is the last fragment, set the TcbPool pointer before
5556 + nulling out the Next pointers */
5558 + HalDev->TcbPool[Ch][Queue] = tcb_ptr->Next;
5560 + tcb_ptr->Next = 0;
5561 + tcb_ptr->HNext = 0;
5563 + /* In the Tx Interrupt handler, we will need to know which TCB is EOP,
5564 + so we can save that information in the SOP */
5565 + head->Eop = tcb_ptr;
5567 + /* Emerald fix 10/29 */
5568 + osfuncDataCacheHitWriteback((void *)tcb_ptr, 16);
5570 + osfuncDataCacheHitWriteback((void *)((bit32u)tcb_ptr + 16), 16);
5575 + /* Emerald fix 10/29 */
5576 + osfuncDataCacheHitWriteback((void *)tcb_ptr, 16);
5578 + osfuncDataCacheHitWriteback((void *)((bit32u)tcb_ptr + 16), 16);
5580 + tcb_ptr = tcb_ptr->Next; /* what about the end of TCB list?? */
5584 + rc = EC_CPPI|EC_FUNC_SEND|EC_VAL_OUT_OF_TCBS;
5590 + /* put it on the high priority queue */
5591 + if (HalDev->TxActQueueHead[Ch][Queue] == 0)
5593 + HalDev->TxActQueueHead[Ch][Queue]=head;
5594 + HalDev->TxActQueueTail[Ch][Queue]=tcb_ptr;
5595 +/*+GSG 030303*//*+GSG 030303*/
5596 + if (!HalDev->TxActive[Ch][Queue])
5602 + /* write CPPI TX HDP */
5603 + (*(pTX_DMA_STATE_WORD_0( base )+( Ch *64)+( Queue ))) = VirtToPhys(head) - HalDev->offset;
5604 + HalDev->TxActive[Ch][Queue]=TRUE;
5612 + HalDev->TxActQueueTail[Ch][Queue]->Next=head;
5613 + /* Emerald fix 10/29 */
5614 + *((bit32u *) VirtToVirtNoCache(&HalDev->TxActQueueTail[Ch][Queue]->HNext))=VirtToPhys(head) - HalDev->offset;
5615 + HalDev->TxActQueueTail[Ch][Queue]=tcb_ptr;
5616 +/*+GSG 030303*//*+GSG 030303*/
5618 + rc = EC_NO_ERRORS;
5620 + } /* if (tcb_ptr) */
5623 + rc = EC_CPPI|EC_FUNC_SEND|EC_VAL_NO_TCBS;
5628 + HalDev->OsFunc->CriticalOff();
5633 + * This function processes receive interrupts. It traverses the receive
5634 + * buffer queue, extracting the data and passing it to the upper layer software via
5635 + * osReceive(). It handles all error conditions and fragments without valid data by
5636 + * immediately returning the RCB's to the RCB pool.
5638 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
5639 + * @param Ch Channel Number.
5640 + * @param MoreWork Flag that indicates that there is more work to do when set to 1.
5642 + * @return 0 if OK, non-zero otherwise.
5644 +static int RxInt(HAL_DEVICE *HalDev, int Ch, int *MoreWork)
5646 + HAL_RCB *CurrentRcb, *LastRcb=0, *SopRcb, *EofRcb, *EopRcb;
5647 + bit32u RxBufStatus,PacketsServiced, RxPktLen = 0, RxSopStatus,
5648 + FrmFrags, TotalFrags, CurrDmaLen, DmaLen, FrmLen;
5649 + int base = HalDev->dev_base, Ret;
5650 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
5651 + int RxServiceMax = HalDev->ChData[Ch].RxServiceMax;
5652 + int FragIndex; /* +GSG 030508 */
5653 + int EarlyReturn = 0; /* +GSG 030521 */
5655 + bit32u PktType, ExpDmaSize, Cells;
5662 + if(HalDev->NeedsCount) /* +MJH 030410 */
5663 + NeedsCheck(HalDev); /* +MJH 030410 */
5665 + /* Handle case of teardown interrupt */
5666 + if (HalDev->RxTeardownPending[Ch] != 0)
5668 + Ret = RxTeardownInt(HalDev, Ch);
5671 + *MoreWork = 0; /* bug fix 1/6 */ /*+GSG 030303*/
5672 + return (EC_NO_ERRORS);
5676 + CurrentRcb=HalDev->RxActQueueHead[Ch];
5678 + osfuncDataCacheHitInvalidate((void*)CurrentRcb, 16);
5680 + RxBufStatus=CurrentRcb->mode;
5682 + /* I think I need to do this to ensure that i read UuCpi properly,
5683 + which is on the second cache line of the Rcb */
5684 + osfuncDataCacheHitInvalidate((void*)((bit32u)CurrentRcb+16), 16);
5686 + PacketsServiced=0;
5687 + HalDev->InRxInt[Ch]=TRUE;
5689 + while((CurrentRcb)&&((RxBufStatus&CB_OWNERSHIP_BIT)==0)&&
5690 + (PacketsServiced<RxServiceMax)) /* ~GSG 030307 */
5693 + PacketsServiced++; /* ~GSG 030307 */
5694 + SopRcb=CurrentRcb;
5695 + RxSopStatus=RxBufStatus;
5697 + RxPktLen = RxSopStatus&CB_SIZE_MASK;
5698 + /* Not sure what MAC needs to do for next block */
5700 + PktType=((SopRcb->UuCpi & 0x00030000) >> 16); /* GSG ~030508 */
5701 + /* Calculate the expected DMA length */
5702 + if (RxPktLen != 0)
5704 + Cells=RxPktLen/48;
5705 + if ((RxPktLen%48) > 40)
5707 + if (PktType == PKT_TYPE_AAL5) /* ~GSG 030508 */
5709 + ExpDmaSize=Cells*48;
5716 + SopOffset=(SopRcb->Off_BLen&CB_OFFSET_MASK)>>16;
5726 + if ((PktType == PKT_TYPE_OAM) || (PktType == PKT_TYPE_TRANS)) /* +GSG 030508 */
5727 + { /* +GSG 030508 */
5728 + /* first frag is ATM Header */ /* +GSG 030508 */
5729 + PassHeader = 1; /* +GSG 030508 */
5730 + HalDev->fraglist[FragIndex].data = (void *)&SopRcb->AtmHeader; /* +GSG 030508 */
5731 + HalDev->fraglist[FragIndex].len = 4; /* +GSG 030508 */
5732 + HalDev->fraglist[FragIndex].OsInfo = SopRcb->OsInfo; /* +GSG 030701 */
5733 + FragIndex++; /* +GSG 030508 */
5734 + } /* +GSG 030508 */
5740 + DmaLen=CurrentRcb->Off_BLen&CB_SIZE_MASK;
5742 + CurrDmaLen+=DmaLen;
5747 + HalDev->fraglist[FragIndex].data=((char *)CurrentRcb->DatPtr); /* ~GSG 030508 */
5749 + HalDev->fraglist[FragIndex].data+=((FrmFrags==0)?SopOffset:0); /* ~GSG 030508 */
5751 + HalDev->fraglist[FragIndex].len=DmaLen; /* ~GSG 030508 */
5754 + HalDev->fraglist[FragIndex].OsInfo = CurrentRcb->OsInfo; /* ~GSG 030508 */
5756 + /* Upper layer must do the data invalidate */
5759 + FragIndex++; /* ~GSG 030508 */
5760 + if (FrmLen>=RxPktLen)
5761 + EofRcb=CurrentRcb;
5763 + LastRcb=CurrentRcb;
5764 + CurrentRcb=LastRcb->Next;
5767 + osfuncDataCacheHitInvalidate((void*)CurrentRcb,16);
5768 + /* RxBufStatus=CurrentRcb->mode; */ /*DRB~030522*/
5770 + }while(((LastRcb->mode&CB_EOF_BIT)==0)&&(CurrentRcb));
5772 + /* New location for interrupt acknowledge */
5773 + /* Write the completion pointer */
5774 + (*(pRX_CPPI_COMP_PTR( base )+( Ch *64))) = VirtToPhys(LastRcb) - HalDev->offset;
5777 + HalDev->RxActQueueHead[Ch]=CurrentRcb;
5778 + HalDev->RxActQueueCount[Ch]-=TotalFrags;
5780 + if (LastRcb->mode&CB_EOQ_BIT)
5785 + HalDev->Stats.RxMisQCnt[Ch]++;
5787 + (*(pRX_DMA_STATE_WORD_1( base )+( Ch *64))) = LastRcb->HNext;
5793 + HalDev->Stats.RxMisQCnt[Ch]++;
5795 + HalDev->RxActive[Ch]=FALSE;
5801 + /* setup SopRcb for the packet */
5802 + SopRcb->Eop=(void*)EopRcb;
5803 + SopRcb->FragCount=TotalFrags;
5805 + if ((ExpDmaSize!=CurrDmaLen)||(RxSopStatus&RX_ERROR_MASK))
5807 + /* check for Rx errors (only valid on SOP) */
5808 + if (RxSopStatus & RX_ERROR_MASK)
5810 + if (RxSopStatus & CRC_ERROR_MASK)
5811 + HalDev->Stats.CrcErrors[Ch]++;
5813 + if (RxSopStatus & LENGTH_ERROR_MASK)
5814 + HalDev->Stats.LenErrors[Ch]++;
5816 + if (RxSopStatus & ABORT_ERROR_MASK)
5817 + HalDev->Stats.AbortErrors[Ch]++;
5819 + if (RxSopStatus & STARV_ERROR_MASK)
5820 + HalDev->Stats.StarvErrors[Ch]++;
5824 + HalDev->Stats.DmaLenErrors[Ch]++; /* different type of length error */
5830 + /* do not pass up the packet if we're out of RCB's (or have an errored packet)*/
5831 + if ((CurrentRcb == 0) || (EarlyReturn == 1))
5833 + halRxReturn((HAL_RECEIVEINFO *)SopRcb,0);
5838 + if (EopRcb!=EofRcb)
5840 + HAL_RCB *FirstEmptyRcb;
5842 + FirstEmptyRcb = EofRcb->Next;
5843 + FirstEmptyRcb->Eop = (void*)EopRcb;
5844 + FirstEmptyRcb->FragCount = TotalFrags-FrmFrags;
5846 + halRxReturn((HAL_RECEIVEINFO *)FirstEmptyRcb,0);
5847 + SopRcb->Eop=(void*)EofRcb;
5848 + SopRcb->FragCount=FrmFrags;
5849 + EofRcb->Next=0; /* Optional */
5852 + mode = Ch | (PktType << 16) | (PassHeader << 31); /* ~GSG 030508 */
5854 + OsFunc->Receive(HalDev->OsDev,HalDev->fraglist,FragIndex,RxPktLen, /* ~GSG 030508 */
5855 + (HAL_RECEIVEINFO *)SopRcb,mode);
5858 + if (CurrentRcb) /*MJH+030522*/
5860 + RxBufStatus=CurrentRcb->mode;
5864 + if ((CurrentRcb)&&((RxBufStatus&CB_OWNERSHIP_BIT)==0)) /*~GSG 030307*/
5873 + if (PacketsServiced != 0)
5875 + /* REMOVED when removing InRxInt */
5876 + if ((!HalDev->RxActive[Ch]) && (HalDev->RxActQueueCount[Ch]))
5878 + (*(pRX_DMA_STATE_WORD_1( base )+( Ch *64))) = VirtToPhys(HalDev->RxActQueueHead[Ch]);
5879 + HalDev->RxActive[Ch]=TRUE;
5883 + HalDev->InRxInt[Ch]=FALSE;
5885 + /* update stats */
5886 + HalDev->Stats.RxPacketsServiced[Ch] += PacketsServiced;
5887 + HalDev->Stats.RxTotal += PacketsServiced;
5888 + if (HalDev->Stats.RxMaxServiced < PacketsServiced)
5889 + HalDev->Stats.RxMaxServiced = PacketsServiced;
5891 + return (EC_NO_ERRORS);
5895 + * This function processes transmit interrupts. It traverses the
5896 + * transmit buffer queue, detecting sent data buffers and notifying the upper
5897 + * layer software via osSendComplete(). (for SAR, i originally had this split
5898 + * into two functions, one for each queue, but joined them on 8/8/02)
5900 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
5901 + * @param Queue Queue number to service (always 0 for MAC, Choose 1 for SAR to service low priority queue)
5902 + * @param MoreWork Flag that indicates that there is more work to do when set to 1.
5904 + * @return 0 if OK, non-zero otherwise.
5906 +static int TxInt(HAL_DEVICE *HalDev, int Ch, int Queue, int *MoreWork)
5908 + HAL_TCB *CurrentTcb,*LastTcbProcessed,*FirstTcbProcessed;
5909 + int PacketsServiced;
5910 + bit32u TxFrameStatus;
5911 + int base = HalDev->dev_base, Ret;
5912 + int TxServiceMax = HalDev->ChData[Ch].TxServiceMax;
5913 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
5915 + int OtherQueue = Queue^1;
5917 +/*+GSG 030303*//*+GSG 030303*/
5919 + /* Handle case of teardown interrupt. This must be checked at
5920 + the top of the function rather than the bottom, because
5921 + the normal data processing can wipe out the completion
5922 + pointer which is used to determine teardown complete. */
5923 + if (HalDev->TxTeardownPending[Ch] != 0)
5925 + Ret = TxTeardownInt(HalDev, Ch, Queue);
5928 + *MoreWork = 0; /* bug fix 1/6 */ /*+GSG 030303*/
5929 + return (EC_NO_ERRORS);
5933 + CurrentTcb = HalDev->TxActQueueHead[Ch][Queue];
5934 + FirstTcbProcessed=CurrentTcb;
5936 + if (CurrentTcb==0)
5938 + /* I saw this error a couple of times when multi-channels were added */
5939 + dbgPrintf("[cppi TxInt()]TxH int with no TCB in queue!\n");
5940 + dbgPrintf(" Ch=%d, CurrentTcb = 0x%08x\n", Ch, (bit32u)CurrentTcb);
5941 + dbgPrintf(" HalDev = 0x%08x\n", (bit32u)HalDev);
5943 + return(EC_CPPI|EC_FUNC_TXINT|EC_VAL_NULL_TCB);
5946 + osfuncDataCacheHitInvalidate((void *)CurrentTcb, 16);
5947 + TxFrameStatus=CurrentTcb->mode;
5948 + PacketsServiced=0;
5950 + /* should the ownership bit check be inside of the loop?? could make it a
5951 + while-do loop and take this check away */
5952 + if ((TxFrameStatus&CB_OWNERSHIP_BIT)==0)
5954 + OsFunc->CriticalOn(); /* +GSG 030307 */
5957 + /* Pop TCB(s) for packet from the stack */
5958 + LastTcbProcessed=CurrentTcb->Eop;
5960 + /* new location for acknowledge */
5961 + /* Write the completion pointer */
5962 + (*(pTXH_CPPI_COMP_PTR( base )+( Ch *64)+( Queue ))) = VirtToPhys(LastTcbProcessed);
5964 + HalDev->TxActQueueHead[Ch][Queue] = LastTcbProcessed->Next;
5966 +/*+GSG 030303*//*+GSG 030303*/
5968 + osfuncDataCacheHitInvalidate((void *)LastTcbProcessed, 16);
5970 + if (LastTcbProcessed->mode&CB_EOQ_BIT)
5972 + if (LastTcbProcessed->Next)
5974 + /* Misqueued packet */
5976 + HalDev->Stats.TxMisQCnt[Ch][Queue]++;
5978 + (*(pTX_DMA_STATE_WORD_0( base )+( Ch *64)+( Queue ))) = LastTcbProcessed->HNext;
5982 + /* Tx End of Queue */
5984 + HalDev->Stats.TxEOQCnt[Ch][Queue]++;
5986 + HalDev->TxActive[Ch][Queue]=FALSE;
5990 + OsFunc->SendComplete(CurrentTcb->OsInfo);
5992 + /* Push Tcb(s) back onto the stack */
5993 + CurrentTcb = LastTcbProcessed->Next;
5995 + LastTcbProcessed->Next=HalDev->TcbPool[Ch][Queue];
5997 + HalDev->TcbPool[Ch][Queue]=FirstTcbProcessed;
5999 + PacketsServiced++;
6001 + TxFrameStatus=CB_OWNERSHIP_BIT;
6002 + /* set the first(SOP) pointer for the next packet */
6003 + FirstTcbProcessed = CurrentTcb;
6006 + osfuncDataCacheHitInvalidate((void *)CurrentTcb, 16);
6007 + TxFrameStatus=CurrentTcb->mode;
6010 + }while(((TxFrameStatus&CB_OWNERSHIP_BIT)==0)
6011 + &&(PacketsServiced<TxServiceMax));
6013 + /* this fixes the SAR TurboDSL hardware bug (multiple queue failure) */
6014 + if (HalDev->TxActive[Ch][OtherQueue])
6015 + if (HalDev->TxActQueueHead[Ch][OtherQueue])
6016 + if ((*(pTX_DMA_STATE_WORD_0( base )+( Ch *64)+( OtherQueue ))) == 0)
6018 + osfuncDataCacheHitInvalidate(HalDev->TxActQueueHead[Ch][OtherQueue],16);
6019 + if ((HalDev->TxActQueueHead[Ch][OtherQueue]->mode) & CB_OWNERSHIP_BIT)
6021 + HalDev->TurboDslErrors++;
6022 + (*(pTX_DMA_STATE_WORD_0( base )+( Ch *64)+( OtherQueue ))) =
6023 + VirtToPhys(HalDev->TxActQueueHead[Ch][OtherQueue]);
6027 + OsFunc->CriticalOff(); /* +GSG 030307 */
6028 + if (((TxFrameStatus&CB_OWNERSHIP_BIT)==0)
6029 + &&(PacketsServiced==TxServiceMax))
6039 + /* update stats */
6040 + HalDev->Stats.TxPacketsServiced[Ch][Queue] += PacketsServiced;
6041 + HalDev->Stats.TxTotal += PacketsServiced;
6042 + if (HalDev->Stats.TxMaxServiced[Ch][Queue] < PacketsServiced)
6043 + HalDev->Stats.TxMaxServiced[Ch][Queue] = PacketsServiced;
6045 + return(EC_NO_ERRORS);
6049 + * @ingroup CPHAL_Functions
6050 + * This function performs a teardown for the given channel. The value of the
6051 + * Mode parameter controls the operation of the function, as documented below.
6053 + * Note: If bit 3 of Mode is set, this call is blocking, and will not return
6054 + * until the teardown interrupt has occurred and been processed. While waiting
6055 + * for a blocking teardown to complete, ChannelTeardown() will signal the OS
6056 + * (via Control(.."Sleep"..)) to allow the OS to perform other tasks if
6057 + * necessary. If and only if bit 3 of Mode is clear, the CPHAL will call the
6058 + * OS TeardownComplete() function to indicate that the teardown has completed.
6060 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
6061 + * @param Ch Channel number.
6062 + * @param Mode Bit 0 (LSB): Perform Tx teardown (if set).<BR>
6063 + * Bit 1: Perform Rx teardown (if set). <BR>
6064 + * Bit 2: If set, perform full teardown (free buffers/descriptors).
6065 + * If clear, perform partial teardown (keep buffers). <BR>
6066 + * Bit 3 (MSB): If set, call is blocking.
6067 + * If clear, call is non-blocking.
6069 + * @return EC_NO_ERRORS (ok). <BR>
6070 + * Possible Error Codes:<BR>
6071 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
6072 + * @ref EC_VAL_INVALID_CH "EC_VAL_INVALID_CH"<BR>
6073 + * @ref EC_VAL_TX_TEARDOWN_ALREADY_PEND "EC_VAL_TX_TEARDOWN_ALREADY_PEND"<BR>
6074 + * @ref EC_VAL_RX_TEARDOWN_ALREADY_PEND "EC_VAL_RX_TEARDOWN_ALREADY_PEND"<BR>
6075 + * @ref EC_VAL_TX_CH_ALREADY_TORNDOWN "EC_VAL_TX_CH_ALREADY_TORNDOWN"<BR>
6076 + * @ref EC_VAL_RX_CH_ALREADY_TORNDOWN "EC_VAL_RX_CH_ALREADY_TORNDOWN"<BR>
6077 + * @ref EC_VAL_TX_TEARDOWN_TIMEOUT "EC_VAL_TX_TEARDOWN_TIMEOUT"<BR>
6078 + * @ref EC_VAL_RX_TEARDOWN_TIMEOUT "EC_VAL_RX_TEARDOWN_TIMEOUT"<BR>
6079 + * @ref EC_VAL_LUT_NOT_READY "EC_VAL_LUT_NOT_READY"<BR>
6081 +static int halChannelTeardown(HAL_DEVICE *HalDev, int Ch, bit32 Mode)
6083 + int DoTx, DoRx, Sleep=2048, timeout=0; /*MJH~030306*/
6084 + bit32u base = HalDev->dev_base;
6086 +/* Set the module, used for error returns */
6090 + /* AAL5 only supports tearing down both sides at once (currently)*/
6091 + Mode = (Mode | TX_TEARDOWN | RX_TEARDOWN);
6093 + DoTx = (Mode & TX_TEARDOWN);
6094 + DoRx = (Mode & RX_TEARDOWN);
6096 + if (HalDev->State < enInitialized)
6097 + return(EC_AAL5 |EC_FUNC_CHTEARDOWN|EC_VAL_INVALID_STATE);
6099 + if ((Ch < 0) || (Ch > MAX_AAL5_CHAN ))
6101 + return(EC_AAL5 |EC_FUNC_CHTEARDOWN|EC_VAL_INVALID_CH);
6104 + /* set teardown pending bits before performing the teardown, because they
6105 + will be used in the int handler (this is done for AAL5) */
6108 + if (HalDev->TxTeardownPending[Ch] != 0)
6109 + return(EC_AAL5 |EC_FUNC_CHTEARDOWN|EC_VAL_TX_TEARDOWN_ALREADY_PEND);
6111 + /* If a full teardown, this also means that the user must
6112 + setup all channels again to use them */
6113 + if (Mode & FULL_TEARDOWN)
6114 + HalDev->ChIsSetup[Ch][DIRECTION_TX] = 0;
6116 + if (HalDev->State < enOpened)
6118 + /* if the hardware has never been opened, the channel has never actually
6119 + been setup in the hardware, so I just need to reset the software flag
6121 + HalDev->ChIsSetup[Ch][DIRECTION_TX] = 0;
6122 + return (EC_NO_ERRORS);
6126 + if (HalDev->ChIsOpen[Ch][DIRECTION_TX] == 0)
6128 + return(EC_AAL5 |EC_FUNC_CHTEARDOWN|EC_VAL_TX_CH_ALREADY_TORNDOWN);
6131 + /* set teardown flag */
6132 + HalDev->TxTeardownPending[Ch] = Mode;
6138 + if (HalDev->RxTeardownPending[Ch] != 0)
6139 + return(EC_AAL5 |EC_FUNC_CHTEARDOWN|EC_VAL_RX_TEARDOWN_ALREADY_PEND);
6141 + if (Mode & FULL_TEARDOWN)
6142 + HalDev->ChIsSetup[Ch][DIRECTION_RX] = 0;
6144 + if (HalDev->State < enOpened)
6146 + HalDev->ChIsSetup[Ch][DIRECTION_RX] = 0;
6147 + return (EC_NO_ERRORS);
6151 + if (HalDev->ChIsOpen[Ch][DIRECTION_RX] == 0)
6152 + return(EC_AAL5 |EC_FUNC_CHTEARDOWN|EC_VAL_RX_CH_ALREADY_TORNDOWN);
6154 + HalDev->RxTeardownPending[Ch] = Mode;
6158 + /* Perform Tx Teardown Duties */
6159 + if ((DoTx) && (HalDev->State == enOpened))
6161 + /* Request TX channel teardown */
6162 + (TX_CPPI_TEARDOWN_REG( base )) = Ch;
6164 + /* wait until teardown has completed */
6165 + if (Mode & BLOCKING_TEARDOWN)
6168 + while (HalDev->ChIsOpen[Ch][DIRECTION_TX] == TRUE)
6170 + osfuncSleep(&Sleep);
6173 + if (timeout > 100000)
6175 + return(EC_AAL5 |EC_FUNC_CHTEARDOWN|EC_VAL_TX_TEARDOWN_TIMEOUT);
6181 + /* Perform Rx Teardown Duties */
6182 + if ((DoRx) && (HalDev->State == enOpened))
6185 + /* call main teardown routine for Rx */
6186 + Ret = HalDev->SarFunc->ChannelTeardown(HalDev->SarDev, Ch, Mode);
6187 + if (Ret) return (Ret);
6189 + if (Mode & BLOCKING_TEARDOWN)
6192 + while (HalDev->ChIsOpen[Ch][DIRECTION_RX] == TRUE)
6194 + osfuncSleep(&Sleep);
6197 + if (timeout > 100000)
6199 + return(EC_AAL5 |EC_FUNC_CHTEARDOWN|EC_VAL_RX_TEARDOWN_TIMEOUT);
6205 + return (EC_NO_ERRORS);
6209 + * @ingroup CPHAL_Functions
6210 + * This function closes the CPHAL module. The module will be reset.
6211 + * The Mode parameter should be used to determine the actions taken by
6214 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
6215 + * @param Mode Indicates actions to take on close. The following integer
6216 + * values are valid: <BR>
6217 + * 1: Does not free buffer resources, init parameters remain
6218 + * intact. User can then call Open() without calling Init()
6219 + * to attempt to reset the device and bring it back to the
6220 + * last known state.<BR>
6221 + * 2: Frees the buffer resources, but keeps init parameters. This
6222 + * option is a more aggressive means of attempting a device reset.
6223 + * 3: Frees the buffer resources, and clears all init parameters. <BR>
6224 + * At this point, the caller would have to call to completely
6225 + * reinitialize the device (Init()) before being able to call
6226 + * Open(). Use this mode if you are shutting down the module
6227 + * and do not plan to restart.
6229 + * @return EC_NO_ERRORS (ok).<BR>
6230 + * Possible Error Codes:<BR>
6231 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
6232 + * Any error code from halChannelTeardown().<BR>
6234 +static int halClose(HAL_DEVICE *HalDev, bit32 Mode)
6236 + int Ch, Inst, Ret;
6237 + OS_DEVICE *TmpOsDev;
6238 + OS_FUNCTIONS *TmpOsFunc;
6239 + HAL_FUNCTIONS *TmpHalFunc;
6240 + char *TmpDeviceInfo;
6242 + CPSAR_FUNCTIONS *TmpSarFunc;
6243 + CPSAR_DEVICE *TmpSarDev;
6245 + /* Verify proper device state */
6246 + if (HalDev->State != enOpened)
6247 + return (EC_AAL5 | EC_FUNC_CLOSE|EC_VAL_INVALID_STATE);
6249 + /* Teardown all open channels */
6250 + for (Ch = 0; Ch <= MAX_AAL5_CHAN ; Ch++)
6252 + if (HalDev->ChIsOpen[Ch][DIRECTION_TX] == TRUE)
6256 + Ret = halChannelTeardown(HalDev, Ch, TX_TEARDOWN | PARTIAL_TEARDOWN | BLOCKING_TEARDOWN);
6257 + if (Ret) return (Ret);
6261 + Ret = halChannelTeardown(HalDev, Ch, TX_TEARDOWN | FULL_TEARDOWN | BLOCKING_TEARDOWN);
6262 + if (Ret) return (Ret);
6266 + if (HalDev->ChIsOpen[Ch][DIRECTION_RX] == TRUE)
6270 + Ret = halChannelTeardown(HalDev, Ch, RX_TEARDOWN | PARTIAL_TEARDOWN | BLOCKING_TEARDOWN);
6271 + if (Ret) return (Ret);
6275 + Ret = halChannelTeardown(HalDev, Ch, RX_TEARDOWN | FULL_TEARDOWN | BLOCKING_TEARDOWN);
6276 + if (Ret) return (Ret);
6281 + /* free fraglist in HalDev */
6282 + HalDev->OsFunc->Free(HalDev->fraglist);
6283 + HalDev->fraglist = 0;
6285 + /* unregister the interrupt */
6286 + HalDev->OsFunc->IsrUnRegister(HalDev->OsDev, HalDev->interrupt);
6288 + /* Disable the Tx CPPI DMA */
6289 + TX_CPPI_CTL_REG(HalDev->dev_base) = 0;
6291 + /* Disable the Rx CPPI DMA */
6292 + RX_CPPI_CTL_REG(HalDev->dev_base) = 0;
6294 + /* Close the SAR hardware - puts the device in reset if this module is the
6296 + HalDev->SarFunc->Close(HalDev->SarDev, Mode);
6298 + /* If mode is 3, than clear the HalDev and set next state to DevFound*/
6301 + /* I need to keep the HalDev parameters that were setup in InitModule */
6302 + TmpOsDev = HalDev->OsDev;
6303 + TmpOsFunc = HalDev->OsFunc;
6304 + TmpDeviceInfo = HalDev->DeviceInfo;
6306 + TmpSarFunc = HalDev->SarFunc;
6307 + TmpSarDev = HalDev->SarDev;
6309 + TmpHalFunc = HalDev->HalFuncPtr;
6310 + Inst = HalDev->Inst;
6312 + /* Clear HalDev */
6314 + HalDev->OsFunc->Memset(HalDev, 0, sizeof(HAL_DEVICE));
6316 + /* Restore key parameters */
6317 + HalDev->OsDev = TmpOsDev;
6318 + HalDev->OsFunc = TmpOsFunc;
6319 + HalDev->DeviceInfo = TmpDeviceInfo;
6321 + HalDev->SarFunc = TmpSarFunc;
6322 + HalDev->SarDev = TmpSarDev;
6324 + HalDev->HalFuncPtr = TmpHalFunc;
6325 + HalDev->Inst = Inst;
6327 + HalDev->State = enDevFound;
6331 + HalDev->State = enInitialized;
6334 + return(EC_NO_ERRORS);
6336 diff -urN linux.old/drivers/atm/sangam_atm/cpremap_cpaal5.c linux.dev/drivers/atm/sangam_atm/cpremap_cpaal5.c
6337 --- linux.old/drivers/atm/sangam_atm/cpremap_cpaal5.c 1970-01-01 01:00:00.000000000 +0100
6338 +++ linux.dev/drivers/atm/sangam_atm/cpremap_cpaal5.c 2005-07-10 08:02:01.425114248 +0200
6340 +#ifndef _INC_CPREMAP_C
6341 +#define _INC_CPREMAP_C
6344 +static inline void osfuncDataCacheHitInvalidate(void *ptr, int Size)
6346 + asm(" cache 17, (%0)" : : "r" (ptr));
6349 +static inline void osfuncDataCacheHitWriteback(void *ptr, int Size)
6351 + asm(" cache 25, (%0)" : : "r" (ptr));
6355 + #define osfuncDataCacheHitInvalidate(MemPtr, Size) HalDev->OsFunc->DataCacheHitInvalidate(MemPtr, Size)
6356 + #define osfuncDataCacheHitWriteback(MemPtr, Size) HalDev->OsFunc->DataCacheHitWriteback(MemPtr, Size)
6360 +#define osfuncDataCacheHitInvalidate(ptr, Size) asm(" cache 17, (%0)" : : "r" (ptr))
6361 +#define osfuncDataCacheHitWriteback(ptr, Size) asm(" cache 25, (%0)" : : "r" (ptr))
6367 diff -urN linux.old/drivers/atm/sangam_atm/cpremap_cpsar.c linux.dev/drivers/atm/sangam_atm/cpremap_cpsar.c
6368 --- linux.old/drivers/atm/sangam_atm/cpremap_cpsar.c 1970-01-01 01:00:00.000000000 +0100
6369 +++ linux.dev/drivers/atm/sangam_atm/cpremap_cpsar.c 2005-07-10 08:02:01.426114096 +0200
6371 +#ifndef _INC_CPREMAP_C
6372 +#define _INC_CPREMAP_C
6375 +static inline void osfuncDataCacheHitInvalidate(void *ptr, int Size)
6377 + asm(" cache 17, (%0)" : : "r" (ptr));
6380 +static inline void osfuncDataCacheHitWriteback(void *ptr, int Size)
6382 + asm(" cache 25, (%0)" : : "r" (ptr));
6386 + #define osfuncDataCacheHitInvalidate(MemPtr, Size) HalDev->OsFunc->DataCacheHitInvalidate(MemPtr, Size)
6387 + #define osfuncDataCacheHitWriteback(MemPtr, Size) HalDev->OsFunc->DataCacheHitWriteback(MemPtr, Size)
6391 +#define osfuncDataCacheHitInvalidate(ptr, Size) asm(" cache 17, (%0)" : : "r" (ptr))
6392 +#define osfuncDataCacheHitWriteback(ptr, Size) asm(" cache 25, (%0)" : : "r" (ptr))
6398 diff -urN linux.old/drivers/atm/sangam_atm/cpsar.c linux.dev/drivers/atm/sangam_atm/cpsar.c
6399 --- linux.old/drivers/atm/sangam_atm/cpsar.c 1970-01-01 01:00:00.000000000 +0100
6400 +++ linux.dev/drivers/atm/sangam_atm/cpsar.c 2005-07-10 08:02:01.427113944 +0200
6405 + * TNETDxxxx Software Support\n
6406 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
6408 + * This file contains the HAL for the CPSAR module. In the software
6409 + * architecture, the CPSAR module is used exclusively by the AAL5 and AAL2
6410 + * CPHAL modules. AAL5 and AAL2 may utilize the same CPSAR instance
6411 + * simulataneously.
6414 + * 5Sep02 Greg 1.00 Original Version created.
6417 +/* register files */
6418 +#include "cp_sar_reg.h"
6420 +#define _CPHAL_CPSAR
6423 +#define WAIT_THRESH 200000
6424 +#define IRAM_SIZE 1536
6427 +/* OS Data Structure definition */
6429 +typedef void OS_PRIVATE;
6430 +typedef void OS_DEVICE;
6431 +typedef void OS_SENDINFO;
6432 +typedef void OS_RECEIVEINFO;
6433 +typedef void OS_SETUP;
6435 +/* CPHAL Data Structure definitions */
6437 +typedef struct cpsar_device CPSAR_DEVICE;
6438 +typedef struct cpsar_device HAL_DEVICE;
6439 +typedef void HAL_RECEIVEINFO;
6441 +#define MAX_QUEUE 2
6442 +#define MAX_CHAN 19
6444 +#include "cpcommon_cpsar.h"
6445 +#include "cpswhal_cpsar.h"
6447 +#include "cpcommon_cpsar.c"
6449 +static CPSAR_DEVICE *CpsarDev[MAX_INST]= {0,0};
6452 + * Returns statistics information.
6454 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
6458 +static int StatsGet3(CPSAR_DEVICE *HalDev)
6461 +#ifdef __CPHAL_DEBUG
6464 + dbgPrintf("[cpsar]StatsGet3(HalDev:%08x)\n", (bit32u)HalDev);
6469 + dbgPrintf("CPSAR General Stats:\n");
6470 + DispHexStat(HalDev, "Base Address",HalDev->dev_base);
6471 + DispStat(HalDev, "Offset (VLYNQ)",HalDev->offset);
6472 + DispStat(HalDev, "Debug Level",HalDev->debug);
6473 + DispStat(HalDev, "Instance",HalDev->Inst);
6474 + DispHexStat(HalDev, "Reset Address",HalDev->ResetBase);
6475 + DispStat(HalDev, "Reset Bit",HalDev->ResetBit);
6477 + return (EC_NO_ERRORS);
6481 +static void SetOamMode(HAL_DEVICE *HalDev)
6484 + volatile bit32u *pTmp;
6485 + int OamMode = (1<<8);
6487 + /* any configuration of OamMode affects all VC's, including AAL2 */
6488 + for (Ch = 0; Ch < MAX_CHAN; Ch++)
6491 + pTmp = (pPDSP_AAL5_RX_STATE_WORD_0(HalDev->dev_base) + (Ch*64));
6493 + pTmp = (pPDSP_AAL2_RX_STATE_WORD_0(HalDev->dev_base) + ((Ch-16)*64));
6495 + if (HalDev->OamMode == 0)
6497 + *pTmp &=~ OamMode;
6506 +static int halControl(CPSAR_DEVICE *HalDev, const char *Key, const char *Action, void *Value)
6508 + int KeyFound=0, ActionFound=0, rc=EC_NO_ERRORS, Ch; /* +RC3.02*/
6509 + char *TmpKey = (char *)Key;
6511 +#ifdef __CPHAL_DEBUG
6514 + dbgPrintf("[cpsar]halControl(HalDev:%08x, Key:%s, Action:%s, Value:%08x)\n", (bit32u)HalDev,
6515 + Key, Action, (bit32u)Value);
6520 + if (HalDev->OsFunc->Strcmpi(Key, "Debug") == 0)
6522 + KeyFound=1; /* +RC3.02*/
6523 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
6525 + ActionFound=1; /* +RC3.02*/
6526 + HalDev->debug = *(int *)Value;
6531 + if (HalDev->OsFunc->Strcmpi(Key, "OamMode") == 0)
6534 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
6537 + HalDev->OamMode = *(int *)Value;
6539 + /* only do this if we're open */
6540 + if (HalDev->OpenCount > 0)
6541 + SetOamMode(HalDev);
6544 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
6547 + *(int *)Value = HalDev->OamMode;
6551 + if (HalDev->OsFunc->Strcmpi(Key, "Stats3") == 0)
6553 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
6554 + StatsGet3(HalDev);
6557 + /* +RC3.02 (if statement) */
6558 + /* Fixes PITS #98 */
6559 + if (HalDev->OsFunc->Strstr(Key, "PdspEnable") != 0)
6562 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
6566 + /* Configure PDSP enable bit based on Value*/
6567 + if (*(int *)Value & 1)
6570 + PDSP_CTRL_REG(HalDev->dev_base) |= 0x2;
6574 + /* disable PDSP */
6575 + PDSP_CTRL_REG(HalDev->dev_base) &=~ 0x2;
6580 + if (HalDev->OsFunc->Strstr(Key, "FwdUnkVc.") != 0)
6583 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
6587 + /* extract channel number */
6588 + TmpKey += HalDev->OsFunc->Strlen("FwdUnkVc.");
6589 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
6591 + /* Configure forwarding of unknown VCI/VPI cells */
6592 + SAR_PDSP_FWD_UNK_VC_REG(HalDev->dev_base) = (((*(int*)Value)<<31) | Ch);
6596 + if (KeyFound == 0) /* +RC3.02 */
6597 + rc = (EC_CPSAR|EC_FUNC_CONTROL|EC_VAL_KEY_NOT_FOUND); /* +RC3.02 */
6599 + if (ActionFound == 0) /* +RC3.02 */
6600 + rc = (EC_CPSAR|EC_FUNC_CONTROL|EC_VAL_ACTION_NOT_FOUND); /* +RC3.02 */
6602 + return(rc); /* ~RC3.02 */
6606 + * This function opens the specified channel.
6608 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
6609 + * @param Ch Channel number.
6611 + * @return 0 OK, Non-zero Not OK
6613 +static int halChannelSetup(CPSAR_DEVICE *HalDev, CHANNEL_INFO *HalCh)
6616 + int Ch = HalCh->Channel;
6617 + int PdspChBlock = Ch;
6618 + int PdspBlockOffset = 0;
6619 + volatile bit32u *pTmp;
6621 +#ifdef __CPHAL_DEBUG
6624 + dbgPrintf("[cpsar]halChannelSetup(HalDev:%08x, HalCh:%08x)\n", (bit32u)HalDev,
6630 + /* Figure out the correct offset from the start of the PDSP
6631 + Scratchpad RAM (starting at 0x8050 in the SAR) */
6634 + /* this is an AAL2 channel, which are channels 16-18 */
6635 + PdspChBlock = Ch - 16;
6636 + /* Get the offset to the AAL2 portion of the block (in words) */
6637 + PdspBlockOffset = NUM_PDSP_AAL5_STATE_WORDS + (PdspChBlock*64);
6638 + /* Clear PDSP State RAM */
6639 + /*pTmp = (pPDSP_BLOCK_0(HalDev->dev_base)+PdspBlockOffset);
6640 + for (i=0; i<NUM_PDSP_AAL2_STATE_WORDS; i++)
6645 + /* Get the offset to the AAL5 portion of the block (in words) */
6646 + PdspBlockOffset = (PdspChBlock*64);
6647 + /* Clear PDSP State RAM */
6648 + /*pTmp = (pPDSP_BLOCK_0(HalDev->dev_base)+PdspBlockOffset);
6649 + for (i=0; i<NUM_PDSP_AAL5_STATE_WORDS; i++)
6653 + /* Configure PDSP State RAM */
6655 + /* Setup TX PDSP State RAM */
6656 + pTmp = (pPDSP_BLOCK_0(HalDev->dev_base)+PdspBlockOffset);
6657 + *pTmp++ = HalCh->TxVc_CellRate; /* Set the cell rate in cells/sec */
6658 + *pTmp++ = HalCh->TxVc_QosType; /* Configure the QoS Type */
6659 + *pTmp++ = HalCh->TxVc_Mbs; /* Set minimum burst size */
6660 + *pTmp++ = 0; /* (skip a register) */
6661 + *pTmp++ = HalCh->TxVc_Pcr; /* set the peak cell rate */
6662 + *pTmp++ = 0; /* new addition 4.9.02 */
6663 + *pTmp++ = HalCh->TxVc_AtmHeader; /* give the ATM header */
6664 + *pTmp++ = (HalCh->TxVc_OamTc << 8)
6665 + |(HalCh->TxVc_VpOffset); /* Set the OAM TC Path and VP Offset */
6667 + /* Setup RX PDSP State RAM */
6668 + *pTmp++ = (HalCh->RxVc_OamCh)|
6669 + (HalDev->OamMode << 8) |
6670 + (HalCh->RxVc_OamToHost<<9); /* Set OAM Channel, Mode, and ToHost options */
6671 + *pTmp++ = HalCh->RxVc_AtmHeader; /* ATM hdr put on firmware generated OAM */
6672 + *pTmp++ = (HalCh->RxVc_VpOffset)| /* Set Rx OAM TC Path and VP Offset */
6673 + (HalCh->RxVc_OamTc<<8);
6675 + /* Setup TX VP PDSP State RAM */
6676 + pTmp = (pPDSP_BLOCK_0(HalDev->dev_base)+PdspBlockOffset+16); /*GSG~030703 12->16 */
6677 + *pTmp++ = HalCh->TxVp_AtmHeader;
6678 + *pTmp++ = (HalCh->TxVp_OamTc << 8);
6680 + /* Setup RX VP PDSP State RAM */
6681 + pTmp = (pPDSP_BLOCK_0(HalDev->dev_base)+PdspBlockOffset+20); /*GSG~030703 16->20 */
6682 + *pTmp++ = HalCh->RxVp_AtmHeader;
6683 + *pTmp++ = (HalCh->RxVp_OamCh)|
6684 + (HalCh->RxVp_OamTc<<8)|
6685 + (HalCh->RxVp_OamToHost<<9); /* Set OAM Channel, Mode, and ToHost options */
6687 + *pTmp++ = HalCh->RxVp_OamVcList;
6689 + /* Configure forwarding of unknown VCI/VPI cells */
6690 + if (HalCh->PktType == 3)
6691 + SAR_PDSP_FWD_UNK_VC_REG(HalDev->dev_base) = ((HalCh->FwdUnkVc<<31)|Ch);
6693 + /* Configure Tx Channel Mapping Register (turn channel "ON") */
6694 + TX_CH_MAPPING_REG(HalDev->dev_base) = 0x80000000 |
6695 + (HalCh->DaMask << 30)
6696 + | (HalCh->Priority << 24) | Ch;
6698 + /* Setup Rx Channel in the LUT */
6700 + while (!(RX_LUT_CH_SETUP_REQ_REG(HalDev->dev_base) & 0x80000000))
6702 + if (i > WAIT_THRESH)
6704 + return(EC_CPSAR|EC_FUNC_CHSETUP|EC_VAL_LUT_NOT_READY);
6710 + /* RX LUT is ready */
6711 + RX_LUT_CH_SETUP_REQ_REG(HalDev->dev_base) = (HalCh->PktType << 24) | Ch;
6712 + RX_LUT_CH_SETUP_REQ_VC_REG(HalDev->dev_base) = ((HalCh->Vpi << 20) |
6713 + (HalCh->Vci << 4));
6715 + return (EC_NO_ERRORS);
6718 +static int halChannelTeardown(CPSAR_DEVICE *HalDev, int Ch, bit32 Mode)
6721 + int PdspBlockOffset = 0, i;
6722 + volatile bit32u *pTmp;
6724 +#ifdef __CPHAL_DEBUG
6727 + dbgPrintf("[cpsar]halChannelTeardown(HalDev:%08x, Ch:%d, Mode:%d\n",
6728 + (bit32u)HalDev, Ch, Mode);
6733 + if ((Ch < 0) || (Ch > MAX_CHAN))
6734 + return(EC_CPSAR|EC_FUNC_CHTEARDOWN|EC_VAL_INVALID_CH);
6736 + /* Request RX channel teardown through LUT */
6737 + while ((RX_LUT_CH_TEARDOWN_REQ_REG(HalDev->dev_base) & 0x80000000) == 0)
6740 + if (waitcnt == WAIT_THRESH)
6742 + return(EC_CPSAR|EC_FUNC_CHTEARDOWN|EC_VAL_LUT_NOT_READY);
6746 + RX_LUT_CH_TEARDOWN_REQ_REG(HalDev->dev_base) = (Ch & 0xffff);
6748 + /* for AAL2, clear channel PDSP RAM here. AAL5 does it when the teardown
6749 + has completed (which is asynchronous)*/
6752 + /* Get the offset to the AAL2 portion of the block (in words) */
6753 + PdspBlockOffset = NUM_PDSP_AAL5_STATE_WORDS + ((Ch-16)*64);
6754 + /* Clear PDSP State RAM */
6755 + pTmp = (pPDSP_BLOCK_0(HalDev->dev_base)+PdspBlockOffset);
6756 + for (i=0; i<NUM_PDSP_AAL2_STATE_WORDS; i++)
6760 + return (EC_NO_ERRORS);
6763 +int InitPdsp(CPSAR_DEVICE *HalDev)
6765 + bit32u NumOfEntries,i,IRamAddress,iTmp;
6766 + int *SarPdspFirmware; /* ~GSG 030403 */
6767 + int FirmwareSize, rc; /* ~GSG 030403 */
6769 +#ifdef __CPHAL_DEBUG
6772 + dbgPrintf("[cpsar]InitPdsp(HalDev:%08x)\n", (bit32u)HalDev);
6777 + /* Get firmware */
6778 + rc = HalDev->OsFunc->Control(HalDev->OsDev, "Firmware", "Get", &SarPdspFirmware); /* ~GSG 030403 */
6779 + if (rc) /* +GSG 030403 */
6780 + return (EC_CPSAR|EC_FUNC_OPEN|EC_VAL_KEY_NOT_FOUND); /* +GSG 030403 */
6782 + /* Get firmware size */
6783 + rc = HalDev->OsFunc->Control(HalDev->OsDev, "FirmwareSize", "Get", &FirmwareSize); /* ~GSG 030403 */
6784 + if (rc) /* +GSG 030403 */
6785 + return (EC_CPSAR|EC_FUNC_OPEN|EC_VAL_KEY_NOT_FOUND); /* +GSG 030403 */
6787 + IRamAddress = (bit32u) pPDSP_CTRL_REG(HalDev->dev_base);
6789 + NumOfEntries = (FirmwareSize)/4; /* ~GSG 030403 */
6790 + if (NumOfEntries > IRAM_SIZE)
6792 + /* Note: On Avalanche, they truncated the PDSP firmware and warned */
6793 + /* NumOfEntries = IRAM_SIZE; */
6794 + return(EC_CPSAR|EC_FUNC_INIT|EC_VAL_FIRMWARE_TOO_LARGE);
6796 + for(i=8;i<NumOfEntries;i++)
6797 + (*((bit32 *) (IRamAddress+(i*4))))=SarPdspFirmware[i]; /* ~GSG 030403 */
6800 + for(i=8;i<NumOfEntries;i++)
6802 + iTmp=(*((bit32 *) (IRamAddress+(i*4))));
6803 + if (iTmp != SarPdspFirmware[i]) /* ~GSG 030403 */
6805 + return(EC_CPSAR|EC_FUNC_OPEN|EC_VAL_PDSP_LOAD_FAIL);
6809 + return(EC_NO_ERRORS);
6813 + * This function probes for the instance of the CPHAL module. It will call
6814 + * the OS function @c DeviceFindInfo() to get the information required.
6816 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
6818 + * @return 0 OK, Otherwise error.
6820 +static int halProbe(CPSAR_DEVICE *HalDev)
6824 +#ifdef __CPHAL_DEBUG
6827 + dbgPrintf("[cpsar]halProbe(HalDev:%08x)\n", (bit32u)HalDev);
6832 +#ifdef __CPHAL_DEBUG
6835 + dbgPrintf("[os]DeviceFindInfo(Inst:%d, DeviceName:%s, DeviceInfo:%08x)\n",
6836 + HalDev->Inst, "sar", (bit32u)&HalDev->DeviceInfo);
6841 + /* Attempt to find the device information */
6842 + Ret = HalDev->OsFunc->DeviceFindInfo(HalDev->Inst, "sar", &HalDev->DeviceInfo);
6844 + return(EC_CPSAR|EC_FUNC_PROBE|EC_VAL_DEVICE_NOT_FOUND);
6846 + return(EC_NO_ERRORS);
6849 +#ifdef __CPHAL_DEBUG
6850 +static void dbgConfigDump(HAL_DEVICE *HalDev)
6852 + dbgPrintf(" [cpsar Inst %d] Config Dump:\n", HalDev->Inst);
6853 + dbgPrintf(" Base :%08x, offset :%08d\n",
6854 + HalDev->dev_base, HalDev->offset);
6855 + dbgPrintf(" ResetBit:%08d, ResetBase:%08x\n",
6856 + HalDev->ResetBit, HalDev->ResetBase);
6857 + dbgPrintf(" UniNni :%08d, debug :%08d\n",
6858 + HalDev->ResetBit, HalDev->debug);
6864 + * Sets up HAL default configuration parameter values.
6866 +static void ConfigInit(CPSAR_DEVICE *HalDev)
6868 +#ifdef __CPHAL_DEBUG
6871 + dbgPrintf("[cpsar]ConfigInit(HalDev:%08x)\n", (bit32u)HalDev);
6875 + /* configure some defaults with tnetd7300 values */
6876 + HalDev->dev_base = 0xa3000000;
6877 + HalDev->offset = 0;
6878 + HalDev->UniNni = CFG_UNI_NNI;
6879 + HalDev->ResetBit = 9;
6880 + HalDev->debug = 0;
6881 + HalDev->ResetBase = 0xa8611600;
6885 + * Retrieve HAL configuration parameter values.
6887 +static bit32u ConfigGet(HAL_DEVICE *HalDev)
6889 + bit32u ParmValue, error_code;
6890 + char *DeviceInfo = HalDev->DeviceInfo;
6892 +#ifdef __CPHAL_DEBUG
6895 + dbgPrintf("[cpsar]ConfigGet(HalDev:%08x)\n", (bit32u)HalDev);
6900 + /* get the configuration parameters common to all modules */
6901 + error_code = ConfigGetCommon(HalDev);
6902 + if (error_code) return (EC_CPSAR|error_code);
6904 + /* get SAR specific configuration parameters */
6905 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo,"UniNni",&ParmValue);
6906 + if (!error_code) HalDev->UniNni = ParmValue;
6908 + return (EC_NO_ERRORS);
6911 +static int halInit(CPSAR_DEVICE *HalDev)
6915 +#ifdef __CPHAL_DEBUG
6918 + dbgPrintf("[cpsar]halInit(HalDev:%08x)\n", (bit32u)HalDev);
6923 +#ifdef __CPHAL_DEBUG
6926 + dbgPrintf("[cpsar halInit()]InitCount = %d\n", HalDev->InitCount);
6931 + /* Only run the init code for the first calling module per instance */
6932 + if (HalDev->InitCount > 1)
6934 + return (EC_NO_ERRORS);
6937 + /* Configure HAL defaults */
6938 + ConfigInit(HalDev);
6940 + /* Retrieve HAL configuration parameters from data store */
6941 + Ret = ConfigGet(HalDev);
6942 + if (Ret) return (Ret);
6944 +#ifdef __CPHAL_DEBUG
6946 + dbgConfigDump(HalDev);
6949 + return(EC_NO_ERRORS);
6952 +static int halOpen(CPSAR_DEVICE *HalDev)
6954 + int Ret, Ticks=64;
6955 + int i; /*+GSG 030407*/
6956 + volatile int *pTmp; /*+GSG 030407*/
6958 +#ifdef __CPHAL_DEBUG
6961 + dbgPrintf("[cpsar]halOpen(HalDev:%08x)\n", (bit32u)HalDev);
6966 +#ifdef __CPHAL_DEBUG
6969 + dbgPrintf("[cpsar halOpen()]OpenCount = %d\n", HalDev->OpenCount);
6974 + /* Only run the open code for the first calling module per instance */
6975 + if (HalDev->OpenCount++ > 0)
6977 + return (EC_NO_ERRORS);
6980 + /* Take SAR out of reset */
6981 + if (((*(volatile bit32u *)(HalDev->ResetBase)) & (1<<HalDev->ResetBit)) != 0)
6983 + /** @todo Should I somehow call AAL5/AAL2 Close() here? All I've done
6984 + here is copy the Close code from each and paste it here. */
6986 +#ifdef __CPHAL_DEBUG
6989 + dbgPrintf("[cpsar halOpen()]Module was already out of reset.\n");
6990 + dbgPrintf(" Closing module and resetting.\n");
6995 + /* Disable the Tx CPPI DMA */
6996 + TX_CPPI_CTL_REG(HalDev->dev_base) = 0;
6998 + /* Disable the Rx CPPI DMA */
6999 + RX_CPPI_CTL_REG(HalDev->dev_base) = 0;
7001 + /* Disable the PDSP */
7002 + PDSP_CTRL_REG(HalDev->dev_base) &=~ 0x00000002;
7004 + /* disable interrupt masks */
7005 + SAR_TX_MASK_CLR(HalDev->dev_base) = 0xffffffff;
7006 + SAR_RX_MASK_CLR(HalDev->dev_base) = 0xffffffff;
7008 +#ifndef NO_RESET /* GSG+ 030428 */
7009 + /* clear reset bit */
7010 + (*(volatile bit32u *)(HalDev->ResetBase)) &=~ (1<<HalDev->ResetBit); /* ~GSG 030307 */
7011 + HalDev->OsFunc->Control(HalDev->OsDev, "Sleep", "", &Ticks);
7013 + /* set reset bit */
7014 + (*(volatile bit32u *)(HalDev->ResetBase)) |= (1<<HalDev->ResetBit); /* ~GSG 030307 */
7015 + HalDev->OsFunc->Control(HalDev->OsDev, "Sleep", "", &Ticks);
7016 +#endif /* GSG+ 030428 */
7020 + (*(volatile bit32u *)(HalDev->ResetBase)) |= (1<<HalDev->ResetBit); /* ~GSG 030307 */
7021 + HalDev->OsFunc->Control(HalDev->OsDev, "Sleep", "", &Ticks);
7024 + /* Configure UNI/NNI */
7025 + RX_LUT_GLOBAL_CFG_REG(HalDev->dev_base) |= (HalDev->UniNni & 0x1);
7027 + /* Clear entire PDSP state RAM */ /*+GSG 030407*/
7028 + pTmp = (pTX_DMA_STATE_WORD_0(HalDev->dev_base)); /*+GSG 030407*/
7029 + for (i=0; i<PDSP_STATE_RAM_SIZE; i++) /*+GSG 030407*/
7030 + *pTmp++ = 0; /*+GSG 030407*/
7032 + /* Configure Oam Mode */ /*+GSG 030407*/
7033 + SetOamMode(HalDev); /*+GSG 030407*/
7035 + /* Initialize PDSP */
7036 + Ret=InitPdsp(HalDev);
7040 + /* Reset and Enable the PDSP */
7041 + PDSP_CTRL_REG(HalDev->dev_base) = 0x00080003;
7043 + return(EC_NO_ERRORS);
7046 +static int halClose(CPSAR_DEVICE *HalDev, int Mode)
7050 +#ifdef __CPHAL_DEBUG
7053 + dbgPrintf("[cpsar]halClose(HalDev:%08x, Mode:%d)\n", (bit32u)HalDev, Mode);
7058 + /* handle the error case if there is nothing open */
7059 + if (HalDev->OpenCount == 0)
7061 + return(EC_CPSAR|EC_FUNC_CLOSE|EC_VAL_MODULE_ALREADY_CLOSED);
7064 +#ifdef __CPHAL_DEBUG
7067 + dbgPrintf("[cpsar halClose()]OpenCount = %d\n", HalDev->OpenCount);
7072 + /* Only run the close code for the last calling module per instance */
7073 + if (HalDev->OpenCount-- > 1)
7075 + return (EC_NO_ERRORS);
7078 + /* Disable the PDSP */
7079 + PDSP_CTRL_REG(HalDev->dev_base) &=~ 0x00000002;
7081 +#ifndef NO_RESET /* GSG +030428 */
7082 + /* put device back into reset */
7083 + (*(volatile bit32u *)(HalDev->ResetBase)) &=~ (1<<HalDev->ResetBit); /* ~GSG 030307 */
7084 + HalDev->OsFunc->Control(HalDev->OsDev, "Sleep", "", &Ticks);
7085 +#endif /* GSG +030428 */
7087 + return(EC_NO_ERRORS);
7090 +static int halShutdown(CPSAR_DEVICE *HalDev)
7092 +#ifdef __CPHAL_DEBUG
7095 + dbgPrintf("[cpsar]halShutdown(HalDev:%08x)\n", (bit32u)HalDev);
7100 + /* handle the error case */
7101 + if (HalDev->InitCount == 0)
7103 + return(EC_CPSAR|EC_FUNC_CLOSE|EC_VAL_MODULE_ALREADY_SHUTDOWN);
7106 +#ifdef __CPHAL_DEBUG
7109 + dbgPrintf("[cpsar halShutdown()]InitCount = %d\n", HalDev->InitCount);
7114 + /* Only run the shutdown code for the last calling module per instance */
7115 + if (HalDev->InitCount-- > 1)
7117 + return (EC_NO_ERRORS);
7120 + /* free the SAR functions */
7121 +#ifdef __CPHAL_DEBUG
7124 + dbgPrintf(" [cpsar halShutdown()]: Free CPSAR function pointers\n");
7127 + if (DBG(1)||DBG(3))
7129 + dbgPrintf("[os]Free(MemPtr:%08x)\n", (bit32u)HalDev->HalFuncPtr);
7133 + /* free the HalFunc */
7134 + HalDev->OsFunc->Free(HalDev->HalFuncPtr);
7136 + /* we have a static global, so I should clear it's value as well */
7137 + CpsarDev[HalDev->Inst] = 0;
7139 +#ifdef __CPHAL_DEBUG
7142 + dbgPrintf(" [cpsar halShutdown()]Free HalDev\n");
7145 + if (DBG(1)||DBG(3))
7147 + dbgPrintf("[os]Free(MemPtr:%08x)\n", (bit32u)HalDev);
7151 + /* free the CPSAR device */
7152 + HalDev->OsFunc->Free(HalDev);
7154 + return(EC_NO_ERRORS);
7157 +static int halTick(CPSAR_DEVICE *HalDev)
7159 +#ifdef __CPHAL_DEBUG
7162 + dbgPrintf("[cpsar]halTick(HalDev:%08x)\n", (bit32u)HalDev);
7167 + return(EC_NO_ERRORS);
7171 + * The CPSAR version of InitModule() should be passed the OS_FUNCTIONS pointer,
7172 + * and will return the HalDev pointer.
7174 + * @param HalDev Pointer to CPSAR module information. This will
7175 + * be used by the OS when communicating to this module via
7177 + * @param OsDev Pointer to OS device information. This will be saved by
7178 + * the CPSAR and returned to the OS when required.
7179 + * @param HalFunc HAL_FUNCTIONS pointer.
7180 + * @param Size Pointer to the size of the HAL_FUNCTIONS structure. (If
7181 + * HalFunc is 0, the value will be set by CPSAR, otherwise
7183 + * @param Inst The instance number of the module to initialize. (start at
7186 + * @return 0 OK, Nonzero - error.
7189 +int cpsarInitModule(CPSAR_DEVICE **HalDev,
7191 + CPSAR_FUNCTIONS *HalFunc,
7192 + OS_FUNCTIONS *OsFunc,
7196 +int cpsarInitModule(CPSAR_DEVICE **HalDev,
7198 + CPSAR_FUNCTIONS **HalFunc,
7199 + OS_FUNCTIONS *OsFunc,
7204 + CPSAR_DEVICE *HalPtr;
7205 + CPSAR_FUNCTIONS *HalFuncPtr;
7208 + if ( HalFunc == 0 )
7210 + *Size = sizeof(CPSAR_FUNCTIONS);
7211 + return(EC_NO_ERRORS);
7215 + if (CpsarDev[Inst] != 0)
7217 + /* this SAR module has been connected to before, so do not
7218 + allocate another CPSAR_DEVICE */
7219 + HalPtr = CpsarDev[Inst];
7221 + /* increase count of attached modules */
7222 + HalPtr->InitCount++;
7226 + /* allocate the CPSAR_DEVICE structure */
7227 + HalPtr = (CPSAR_DEVICE *) OsFunc->MallocDev(sizeof(CPSAR_DEVICE));
7229 + return(EC_CPSAR|EC_FUNC_HAL_INIT|EC_VAL_MALLOC_DEV_FAILED);
7231 + HalFuncPtr = (CPSAR_FUNCTIONS *) OsFunc->Malloc(sizeof(CPSAR_FUNCTIONS));
7233 + return (EC_CPSAR|EC_FUNC_HAL_INIT|EC_VAL_MALLOC_FAILED);
7235 + /* Initialize the size of hal functions */
7236 + *HalFuncSize = sizeof (CPSAR_FUNCTIONS);
7238 + /* ensure the device structure is cleared */
7239 + OsFunc->Memset(HalPtr, 0, sizeof(CPSAR_DEVICE));
7241 + /* clear the function pointers */
7242 + OsFunc->Memset(HalFuncPtr, 0, sizeof(CPSAR_FUNCTIONS));
7244 + /* Supply pointers for the CPSAR API functions */
7245 + HalFuncPtr->ChannelSetup = halChannelSetup;
7246 + HalFuncPtr->ChannelTeardown = halChannelTeardown;
7247 + HalFuncPtr->Close = halClose;
7248 + HalFuncPtr->Control = halControl;
7249 + HalFuncPtr->Init = halInit;
7250 + HalFuncPtr->Open = halOpen;
7251 + HalFuncPtr->Probe = halProbe;
7252 + HalFuncPtr->Shutdown = halShutdown;
7253 + HalFuncPtr->Tick = halTick;
7255 + /* keep a reference to HalFuncPtr so I can free it later */
7256 + HalPtr->HalFuncPtr = HalFuncPtr;
7258 + /* store the CPSAR_DEVICE, so the CPSAR module will know whether
7259 + it is in use for the given instance */
7260 + CpsarDev[Inst] = HalPtr;
7262 + /* increase count of attached modules */
7263 + HalPtr->InitCount++;
7266 + /* @todo Does this need modification to deal with multiple callers/
7267 + drivers? If different callers will use different OsDev/OsFunc,
7268 + then the current code will not work.
7271 + /* initialize the CPSAR_DEVICE structure */
7272 + HalPtr->OsDev = OsDev;
7273 + /*HalPtr->OsOpen = OsDev;*/
7274 + HalPtr->Inst = Inst;
7275 + HalPtr->OsFunc = OsFunc;
7277 + /* pass the HalPtr back to the caller */
7279 + *HalFunc = HalPtr->HalFuncPtr;
7281 + return (EC_NO_ERRORS);
7283 diff -urN linux.old/drivers/atm/sangam_atm/cpsar_cpaal5.h linux.dev/drivers/atm/sangam_atm/cpsar_cpaal5.h
7284 --- linux.old/drivers/atm/sangam_atm/cpsar_cpaal5.h 1970-01-01 01:00:00.000000000 +0100
7285 +++ linux.dev/drivers/atm/sangam_atm/cpsar_cpaal5.h 2005-07-10 08:02:01.427113944 +0200
7287 +/*******************************************************************************
7288 + * TNETDxxxx Software Support
7289 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
7294 + * This file contains data structure definitions for the CPSAR HAL.
7297 + * 6Sep02 Greg 1.00 Original Version created.
7299 + *****************************************************************************/
7303 +#define NUM_RX_STATE_WORDS 7
7304 +#define NUM_TX_STATE_WORDS 9
7305 +#define MAX_CHAN 19
7308 +#ifndef _CPHAL_CPSAR
7309 +typedef void CPSAR_DEVICE;
7313 + * HAL Default Parameter Values
7315 +#define CFG_UNI_NNI 0
7318 + * @ingroup shared_data
7320 + * List of defined keys for use with Control().
7325 + enGET_FIRMWARE, /**< Used by the SAR to request a pointer to firmware */
7326 + enGET_FIRMWARE_SIZE, /**< Used by the SAR to request the size of the firmware */
7327 + enEND=9999 /* Last entry */
7331 + * The CPHAL_FUNCTIONS struct defines the CPHAL function pointers used by upper layer
7332 + * software. The upper layer software receives these pointers through the
7333 + * call to cphalInitModule().
7337 + int (*ChannelSetup)(CPSAR_DEVICE *HalDev, CHANNEL_INFO *HalCh);
7338 + int (*ChannelTeardown)(CPSAR_DEVICE *HalDev, int Ch, int Mode);
7339 + int (*Close)(CPSAR_DEVICE *HalDev, int Mode);
7340 + int (*Control)(CPSAR_DEVICE *HalDev, const char *Key, const char *Action, void *Value);
7341 + int (*Init)(CPSAR_DEVICE *HalDev);
7342 + int (*ModeChange)(CPSAR_DEVICE *HalDev, char *DeviceParms);
7343 + int (*Open)(CPSAR_DEVICE *HalDev);
7344 + int (*Probe)(CPSAR_DEVICE *HalDev);
7345 + int (*Shutdown)(CPSAR_DEVICE *HalDev);
7346 + int (*Tick)(CPSAR_DEVICE *HalDev);
7347 + } CPSAR_FUNCTIONS;
7350 + * This is the data structure for a generic HAL device. It contains all device
7351 + * specific data for a single instance of that device. This includes Rx/Tx
7352 + * buffer queues, device base address, reset bit, and other information.
7354 +typedef struct cpsar_device
7358 + bit32 TxTeardownPending[MAX_CHAN];
7359 + bit32 RxTeardownPending[MAX_CHAN];
7360 + bit32 ChIsOpen[MAX_CHAN];
7364 + OS_FUNCTIONS *OsFunc;
7368 + bit32u DeviceCPID[4];
7369 + bit32u LBSourceLLID[4];
7370 + bit32u OamRate[11];
7371 + CHANNEL_INFO ChData[MAX_CHAN];
7376 + DEVICE_STATE State;
7377 + CPSAR_FUNCTIONS *HalFuncPtr;
7378 + int OamMode; /* +GSG 030407 */
7381 +extern int cpsarInitModule(CPSAR_DEVICE **HalDev,
7383 + CPSAR_FUNCTIONS **HalFunc,
7384 + OS_FUNCTIONS *OsFunc,
7390 diff -urN linux.old/drivers/atm/sangam_atm/cpsar.h linux.dev/drivers/atm/sangam_atm/cpsar.h
7391 --- linux.old/drivers/atm/sangam_atm/cpsar.h 1970-01-01 01:00:00.000000000 +0100
7392 +++ linux.dev/drivers/atm/sangam_atm/cpsar.h 2005-07-10 08:02:01.427113944 +0200
7394 +/*******************************************************************************
7395 + * TNETDxxxx Software Support
7396 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
7401 + * This file contains data structure definitions for the CPSAR HAL.
7404 + * 6Sep02 Greg 1.00 Original Version created.
7406 + *****************************************************************************/
7410 +#define NUM_RX_STATE_WORDS 7
7411 +#define NUM_TX_STATE_WORDS 9
7412 +#define MAX_CHAN 19
7415 +#ifndef _CPHAL_CPSAR
7416 +typedef void CPSAR_DEVICE;
7420 + * HAL Default Parameter Values
7422 +#define CFG_UNI_NNI 0
7425 + * @ingroup shared_data
7427 + * List of defined keys for use with Control().
7432 + enGET_FIRMWARE, /**< Used by the SAR to request a pointer to firmware */
7433 + enGET_FIRMWARE_SIZE, /**< Used by the SAR to request the size of the firmware */
7434 + enEND=9999 /* Last entry */
7438 + * The CPHAL_FUNCTIONS struct defines the CPHAL function pointers used by upper layer
7439 + * software. The upper layer software receives these pointers through the
7440 + * call to cphalInitModule().
7444 + int (*ChannelSetup)(CPSAR_DEVICE *HalDev, CHANNEL_INFO *HalCh);
7445 + int (*ChannelTeardown)(CPSAR_DEVICE *HalDev, int Ch, int Mode);
7446 + int (*Close)(CPSAR_DEVICE *HalDev, int Mode);
7447 + int (*Control)(CPSAR_DEVICE *HalDev, const char *Key, const char *Action, void *Value);
7448 + int (*Init)(CPSAR_DEVICE *HalDev);
7449 + int (*ModeChange)(CPSAR_DEVICE *HalDev, char *DeviceParms);
7450 + int (*Open)(CPSAR_DEVICE *HalDev);
7451 + int (*Probe)(CPSAR_DEVICE *HalDev);
7452 + int (*Shutdown)(CPSAR_DEVICE *HalDev);
7453 + int (*Tick)(CPSAR_DEVICE *HalDev);
7454 + } CPSAR_FUNCTIONS;
7457 + * This is the data structure for a generic HAL device. It contains all device
7458 + * specific data for a single instance of that device. This includes Rx/Tx
7459 + * buffer queues, device base address, reset bit, and other information.
7461 +typedef struct cpsar_device
7465 + bit32 TxTeardownPending[MAX_CHAN];
7466 + bit32 RxTeardownPending[MAX_CHAN];
7467 + bit32 ChIsOpen[MAX_CHAN];
7471 + OS_FUNCTIONS *OsFunc;
7475 + bit32u DeviceCPID[4];
7476 + bit32u LBSourceLLID[4];
7477 + bit32u OamRate[11];
7478 + CHANNEL_INFO ChData[MAX_CHAN];
7483 + DEVICE_STATE State;
7484 + CPSAR_FUNCTIONS *HalFuncPtr;
7485 + int OamMode; /* +GSG 030407 */
7488 +extern int cpsarInitModule(CPSAR_DEVICE **HalDev,
7490 + CPSAR_FUNCTIONS **HalFunc,
7491 + OS_FUNCTIONS *OsFunc,
7497 diff -urN linux.old/drivers/atm/sangam_atm/cp_sar_reg.h linux.dev/drivers/atm/sangam_atm/cp_sar_reg.h
7498 --- linux.old/drivers/atm/sangam_atm/cp_sar_reg.h 1970-01-01 01:00:00.000000000 +0100
7499 +++ linux.dev/drivers/atm/sangam_atm/cp_sar_reg.h 2005-07-10 08:02:01.428113792 +0200
7501 +/***************************************************************************
7502 + TNETD73xx Software Support
7503 + Copyright(c) 2000, Texas Instruments Incorporated. All Rights Reserved.
7505 + FILE: cp_sar_reg.h Register definitions for the SAR module
7508 + This include file contains register definitions for the
7512 + 15 Jan 02 G. Guyotte Original version written
7513 + 03 Oct 02 G. Guyotte C++ style comments removed
7514 +****************************************************************************/
7515 +#ifndef _INC_SAR_REG
7516 +#define _INC_SAR_REG
7518 +/* Global Registers */
7519 +#define pSAR_ID_REG(base) ((volatile bit32u *)(base+0x0000))
7520 +#define SAR_ID_REG(base) (*pSAR_ID_REG(base))
7521 +#define pSAR_STATUS_SET_REG(base) ((volatile bit32u *)(base+0x0008))
7522 +#define SAR_STATUS_SET_REG(base) (*pSAR_STATUS_SET_REG(base))
7523 +#define pSAR_STATUS_CLR_REG(base) ((volatile bit32u *)(base+0x000C))
7524 +#define SAR_STATUS_CLR_REG(base) (*pSAR_STATUS_CLR_REG(base))
7525 +#define pSAR_HOST_INT_EN_SET_REG(base) ((volatile bit32u *)(base+0x0010))
7526 +#define SAR_HOST_INT_EN_SET_REG(base) (*pSAR_HOST_INT_EN_SET_REG(base))
7527 +#define pSAR_HOST_INT_EN_CLR_REG(base) ((volatile bit32u *)(base+0x0014))
7528 +#define SAR_HOST_INT_EN_CLR_REG(base) (*pSAR_HOST_INT_EN_CLR_REG(base))
7529 +#define pSAR_PDSP_INT_EN_SET_REG(base) ((volatile bit32u *)(base+0x0018))
7530 +#define SAR_PDSP_INT_EN_SET_REG(base) (*pSAR_PDSP_INT_EN_SET_REG(base))
7531 +#define pSAR_PDSP_INT_EN_CLR_REG(base) ((volatile bit32u *)(base+0x001C))
7532 +#define SAR_PDSP_INT_EN_CLR_REG(base) (*pSAR_PDSP_INT_EN_CLR_REG(base))
7534 +/* PDSP OAM General Purpose Registers */
7535 +#define pSAR_PDSP_HOST_OAM_CONFIG_REG(base) ((volatile bit32u *)(base+0x0020))
7536 +#define SAR_PDSP_HOST_OAM_CONFIG_REG(base) (*pSAR_PDSP_HOST_OAM_CONFIG_REG(base))
7537 +#define pSAR_PDSP_OAM_CORR_REG(base) ((volatile bit32u *)(base+0x0024))
7538 +#define SAR_PDSP_OAM_CORR_REG(base) (*pSAR_PDSP_OAM_CORR_REG(base))
7539 +#define pSAR_PDSP_OAM_LB_RESULT_REG(base) ((volatile bit32u *)(base+0x0028))
7540 +#define SAR_PDSP_OAM_LB_RESULT_REG(base) (*pSAR_PDSP_OAM_LB_RESULT_REG(base))
7541 +#define pSAR_PDSP_OAM_F5_LB_COUNT_REG(base) ((volatile bit32u *)(base+0x002c)) /* +GSG 030416 */
7542 +#define SAR_PDSP_OAM_F5_LB_COUNT_REG(base) (*pSAR_PDSP_OAM_F5_LB_COUNT_REG(base)) /* +GSG 030416 */
7543 +#define pSAR_PDSP_OAM_F4_LB_COUNT_REG(base) ((volatile bit32u *)(base+0x0030)) /* +GSG 030416 */
7544 +#define SAR_PDSP_OAM_F4_LB_COUNT_REG(base) (*pSAR_PDSP_OAM_F4_LB_COUNT_REG(base)) /* +GSG 030416 */
7545 +#define pSAR_PDSP_FWD_UNK_VC_REG(base) ((volatile bit32u *)(base+0x0034)) /* +GSG 030701 */
7546 +#define SAR_PDSP_FWD_UNK_VC_REG(base) (*pSAR_PDSP_FWD_UNK_VC_REG(base)) /* +GSG 030701 */
7549 +/* Rx Lookup Table Registers */
7550 +#define pRX_LUT_GLOBAL_CFG_REG(base) ((volatile bit32u *)(base+0x0080))
7551 +#define RX_LUT_GLOBAL_CFG_REG(base) (*pRX_LUT_GLOBAL_CFG_REG(base))
7552 +#define pRX_LUT_CH_SETUP_REQ_REG(base) ((volatile bit32u *)(base+0x0090))
7553 +#define RX_LUT_CH_SETUP_REQ_REG(base) (*pRX_LUT_CH_SETUP_REQ_REG(base))
7554 +#define pRX_LUT_CH_SETUP_REQ_VC_REG(base) ((volatile bit32u *)(base+0x0094))
7555 +#define RX_LUT_CH_SETUP_REQ_VC_REG(base) (*pRX_LUT_CH_SETUP_REQ_VC_REG(base))
7556 +#define pRX_LUT_CH_TEARDOWN_REQ_REG(base) ((volatile bit32u *)(base+0x009C))
7557 +#define RX_LUT_CH_TEARDOWN_REQ_REG(base) (*pRX_LUT_CH_TEARDOWN_REQ_REG(base))
7559 +/* Tx Scheduler Registers */
7560 +#define pTX_CH_MAPPING_REG(base) ((volatile bit32u *)(base+0x0170))
7561 +#define TX_CH_MAPPING_REG(base) (*pTX_CH_MAPPING_REG(base))
7563 +/* Tx CPPI DMA Controller Registers */
7564 +#define pTX_CPPI_CTL_REG(base) ((volatile bit32u *)(base+0x0700))
7565 +#define TX_CPPI_CTL_REG(base) (*pTX_CPPI_CTL_REG(base))
7566 +#define pTX_CPPI_TEARDOWN_REG(base) ((volatile bit32u *)(base+0x0704))
7567 +#define TX_CPPI_TEARDOWN_REG(base) (*pTX_CPPI_TEARDOWN_REG(base))
7569 +/* EOI Interrupt Additions */
7570 +#define pSAR_EOI(base) ((volatile bit32u *)(base+0x0708))
7571 +#define SAR_EOI(base) (*pSAR_EOI(base))
7572 +#define pSAR_INTR_VECTOR(base) ((volatile bit32u *)(base+0x070c))
7573 +#define SAR_INTR_VECTOR(base) (*pSAR_INTR_VECTOR(base))
7574 +#define pSAR_TX_MASKED_STATUS(base) ((volatile bit32u *)(base+0x0710))
7575 +#define SAR_TX_MASKED_STATUS(base) (*pSAR_TX_MASKED_STATUS(base))
7576 +#define pSAR_TX_RAW_STATUS(base) ((volatile bit32u *)(base+0x0714))
7577 +#define SAR_TX_RAW_STATUS(base) (*pSAR_TX_RAW_STATUS(base))
7578 +#define pSAR_TX_MASK_SET(base) ((volatile bit32u *)(base+0x0718))
7579 +#define SAR_TX_MASK_SET(base) (*pSAR_TX_MASK_SET(base))
7580 +#define pSAR_TX_MASK_CLR(base) ((volatile bit32u *)(base+0x071c))
7581 +#define SAR_TX_MASK_CLR(base) (*pSAR_TX_MASK_CLR(base))
7583 +/* Rx CPPI DMA Controller Registers */
7584 +#define pRX_CPPI_CTL_REG(base) ((volatile bit32u *)(base+0x0780))
7585 +#define RX_CPPI_CTL_REG(base) (*pRX_CPPI_CTL_REG(base))
7586 +#define pSAR_RX_MASKED_STATUS(base) ((volatile bit32u *)(base+0x0790))
7587 +#define SAR_RX_MASKED_STATUS(base) (*pSAR_RX_MASKED_STATUS(base))
7588 +#define pSAR_RX_RAW_STATUS(base) ((volatile bit32u *)(base+0x0794))
7589 +#define SAR_RX_RAW_STATUS(base) (*pSAR_RX_RAW_STATUS(base))
7590 +#define pSAR_RX_MASK_SET(base) ((volatile bit32u *)(base+0x0798))
7591 +#define SAR_RX_MASK_SET(base) (*pSAR_RX_MASK_SET(base))
7592 +#define pSAR_RX_MASK_CLR(base) ((volatile bit32u *)(base+0x079c))
7593 +#define SAR_RX_MASK_CLR(base) (*pSAR_RX_MASK_CLR(base))
7595 +/* PDSP Control/Status Registers */
7596 +#define pPDSP_CTRL_REG(base) ((volatile bit32u *)(base+0x4000))
7597 +#define PDSP_CTRL_REG(base) (*pPDSP_CTRL_REG(base))
7599 +/* PDSP Instruction RAM */
7600 +#define pPDSP_IRAM(base) ((volatile bit32u *)(base+0x4020))
7601 +#define PDSP_IRAM(base) (*pPDSP_IRAM(base))
7604 + * Channel 0 State/Scratchpad RAM Block
7606 + * The following registers (Tx DMA State, Rx DMA State, CPPI Completion PTR,
7607 + * and PDSP Data) have been given the correct address for channel 0. To
7608 + * reach the registers for channel X, add (X * 0x100) to the pointer address.
7612 +#define PDSP_STATE_RAM_SIZE 1024
7614 +/* Tx DMA State RAM */
7615 +#define pTX_DMA_STATE_WORD_0(base) ((volatile bit32u *)(base+0x8000))
7616 +#define TX_DMA_STATE_WORD_0(base) (*pTX_DMA_STATE_WORD_0(base))
7617 +#define pTX_DMA_STATE_WORD_1(base) ((volatile bit32u *)(base+0x8004))
7618 +#define TX_DMA_STATE_WORD_1(base) (*pTX_DMA_STATE_WORD_1(base))
7619 +#define pTX_DMA_STATE_WORD_2(base) ((volatile bit32u *)(base+0x8008))
7620 +#define TX_DMA_STATE_WORD_2(base) (*pTX_DMA_STATE_WORD_2(base))
7621 +#define pTX_DMA_STATE_WORD_3(base) ((volatile bit32u *)(base+0x800C))
7622 +#define TX_DMA_STATE_WORD_3(base) (*pTX_DMA_STATE_WORD_3(base))
7623 +#define pTX_DMA_STATE_WORD_4(base) ((volatile bit32u *)(base+0x8010))
7624 +#define TX_DMA_STATE_WORD_4(base) (*pTX_DMA_STATE_WORD_4(base))
7625 +#define pTX_DMA_STATE_WORD_5(base) ((volatile bit32u *)(base+0x8014))
7626 +#define TX_DMA_STATE_WORD_5(base) (*pTX_DMA_STATE_WORD_5(base))
7627 +#define pTX_DMA_STATE_WORD_6(base) ((volatile bit32u *)(base+0x8018))
7628 +#define TX_DMA_STATE_WORD_6(base) (*pTX_DMA_STATE_WORD_6(base))
7629 +#define pTX_DMA_STATE_WORD_7(base) ((volatile bit32u *)(base+0x801C))
7630 +#define TX_DMA_STATE_WORD_7(base) (*pTX_DMA_STATE_WORD_7(base))
7631 +#define pTX_DMA_STATE_WORD_8(base) ((volatile bit32u *)(base+0x8020))
7632 +#define TX_DMA_STATE_WORD_8(base) (*pTX_DMA_STATE_WORD_8(base))
7634 +/* Rx DMA State RAM */
7635 +#define pRX_DMA_STATE_WORD_0(base) ((volatile bit32u *)(base+0x8024))
7636 +#define RX_DMA_STATE_WORD_0(base) (*pRX_DMA_STATE_WORD_0(base))
7637 +#define pRX_DMA_STATE_WORD_1(base) ((volatile bit32u *)(base+0x8028))
7638 +#define RX_DMA_STATE_WORD_1(base) (*pRX_DMA_STATE_WORD_1(base))
7639 +#define pRX_DMA_STATE_WORD_2(base) ((volatile bit32u *)(base+0x802C))
7640 +#define RX_DMA_STATE_WORD_2(base) (*pRX_DMA_STATE_WORD_2(base))
7641 +#define pRX_DMA_STATE_WORD_3(base) ((volatile bit32u *)(base+0x8030))
7642 +#define RX_DMA_STATE_WORD_3(base) (*pRX_DMA_STATE_WORD_3(base))
7643 +#define pRX_DMA_STATE_WORD_4(base) ((volatile bit32u *)(base+0x8034))
7644 +#define RX_DMA_STATE_WORD_4(base) (*pRX_DMA_STATE_WORD_4(base))
7645 +#define pRX_DMA_STATE_WORD_5(base) ((volatile bit32u *)(base+0x8038))
7646 +#define RX_DMA_STATE_WORD_5(base) (*pRX_DMA_STATE_WORD_5(base))
7647 +#define pRX_DMA_STATE_WORD_6(base) ((volatile bit32u *)(base+0x803C))
7648 +#define RX_DMA_STATE_WORD_6(base) (*pRX_DMA_STATE_WORD_6(base))
7650 +/* Tx CPPI Completion Pointers */
7651 +#define pTXH_CPPI_COMP_PTR(base) ((volatile bit32u *)(base+0x8040))
7652 +#define TXH_CPPI_COMP_PTR(base) (*pTXH_CPPI_COMP_PTR(base))
7653 +#define pTXL_CPPI_COMP_PTR(base) ((volatile bit32u *)(base+0x8044))
7654 +#define TXL_CPPI_COMP_PTR(base) (*pTXL_CPPI_COMP_PTR(base))
7656 +/* Rx CPPI Completion Pointer */
7657 +#define pRX_CPPI_COMP_PTR(base) ((volatile bit32u *)(base+0x8048))
7658 +#define RX_CPPI_COMP_PTR(base) (*pRX_CPPI_COMP_PTR(base))
7660 +/* Tx PDSP Defines */
7661 +#define NUM_PDSP_AAL5_STATE_WORDS 24
7662 +#define NUM_PDSP_AAL2_STATE_WORDS 20
7664 +/* PDSP State RAM Block 0 */
7665 +#define pPDSP_BLOCK_0(base) ((volatile bit32u *)(base+0x8050))
7666 +#define PDSP_BLOCK_0(base) (*pPDSP_BLOCK_0(base))
7668 +/* AAL5 Tx PDSP State RAM */
7669 +#define pPDSP_AAL5_TX_STATE_WORD_0(base) ((volatile bit32u *)(base+0x8050))
7670 +#define PDSP_AAL5_TX_STATE_WORD_0(base) (*pPDSP_AAL5_TX_STATE_WORD_0(base))
7672 +/* AAL5 Rx PDSP State RAM */
7673 +#define pPDSP_AAL5_RX_STATE_WORD_0(base) ((volatile bit32u *)(base+0x8070))
7674 +#define PDSP_AAL5_RX_STATE_WORD_0(base) (*pPDSP_AAL5_RX_STATE_WORD_0(base))
7676 +/* AAL5 Tx VP PDSP State RAM */
7677 +#define pPDSP_AAL5_TX_VP_STATE_WORD_0(base) ((volatile bit32u *)(base+0x8090))
7678 +#define PDSP_AAL5_TX_VP_STATE_WORD_0(base) (*pPDSP_AAL5_TX_VP_STATE_WORD_0(base))
7680 +/* AAL5 Rx VP PDSP State RAM */
7681 +#define pPDSP_AAL5_RX_VP_STATE_WORD_0(base) ((volatile bit32u *)(base+0x80A0))
7682 +#define PDSP_AAL5_RX_VP_STATE_WORD_0(base) (*pPDSP_AAL5_RX_VP_STATE_WORD_0(base))
7684 +/* AAL2 Tx PDSP State RAM */
7685 +#define pPDSP_AAL2_TX_STATE_WORD_0(base) ((volatile bit32u *)(base+0x80B0))
7686 +#define PDSP_AAL2_TX_STATE_WORD_0(base) (*pPDSP_AAL2_TX_STATE_WORD_0(base))
7688 +/* AAL2 Rx PDSP State RAM */
7689 +#define pPDSP_AAL2_RX_STATE_WORD_0(base) ((volatile bit32u *)(base+0x80D0))
7690 +#define PDSP_AAL2_RX_STATE_WORD_0(base) (*pPDSP_AAL2_RX_STATE_WORD_0(base))
7692 +/* AAL2 Tx VP PDSP State RAM */
7693 +#define pPDSP_AAL2_TX_VP_STATE_WORD_0(base) ((volatile bit32u *)(base+0x80E0))
7694 +#define PDSP_AAL2_TX_VP_STATE_WORD_0(base) (*pPDSP_AAL2_TX_VP_STATE_WORD_0(base))
7696 +/* AAL2 Rx VP PDSP State RAM */
7697 +#define pPDSP_AAL2_RX_VP_STATE_WORD_0(base) ((volatile bit32u *)(base+0x80F0))
7698 +#define PDSP_AAL2_RX_VP_STATE_WORD_0(base) (*pPDSP_AAL2_RX_VP_STATE_WORD_0(base))
7700 +/* PDSP OAM Configuration Block */
7701 +#define pOAM_CONFIG_BLOCK_WORD_0(base) ((volatile bit32u *)(base+0x83C0))
7702 +#define OAM_CONFIG_BLOCK_WORD_0(base) (*pOAM_CONFIG_BLOCK_WORD_0(base))
7704 +/* PDSP OAM Padding Block */
7705 +#define pOAM_PADDING_BLOCK_WORD_0(base) ((volatile bit32u *)(base+0x84C0))
7706 +#define OAM_PADDING_BLOCK_WORD_0(base) (*pOAM_PADDING_BLOCK_WORD_0(base))
7708 +#define NUM_OAM_RATES 11
7710 +/* PDSP OAM Timer State RAM */
7711 +#define pOAM_TIMER_STATE_WORD_0(base) ((volatile bit32u *)(base+0x85B0))
7712 +#define OAM_TIMER_STATE_WORD_0(base) (*pOAM_TIMER_STATE_WORD_0(base))
7717 +#endif _INC_SAR_REG
7718 diff -urN linux.old/drivers/atm/sangam_atm/cpswhal_cpaal5.h linux.dev/drivers/atm/sangam_atm/cpswhal_cpaal5.h
7719 --- linux.old/drivers/atm/sangam_atm/cpswhal_cpaal5.h 1970-01-01 01:00:00.000000000 +0100
7720 +++ linux.dev/drivers/atm/sangam_atm/cpswhal_cpaal5.h 2005-07-10 08:02:01.429113640 +0200
7722 +/************************************************************************
7723 + * TNETDxxxx Software Support
7724 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
7729 + * User include file, contains data definitions shared between the CPHAL
7730 + * and the upper-layer software.
7733 + * Date Modifier Ver Notes
7734 + * 28Feb02 Greg 1.00 Original
7735 + * 06Mar02 Greg 1.01 Documentation enhanced
7736 + * 18Jul02 Greg 1.02 Many updates (OAM additions, general reorg)
7737 + * 22Nov02 Mick RC2 Additions from Denis' input on Control
7739 + * author Greg Guyotte
7741 + * date 18-Jul-2002
7742 + *****************************************************************************/
7743 +#ifndef _INC_CPHAL_H
7744 +#define _INC_CPHAL_H
7746 +#ifdef _CPHAL_CPMAC
7747 +#include "ec_errors_cpmac.h"
7751 +#include "ec_errors_cpaal5.h"
7754 +#ifdef _CPHAL_CPSAR
7755 +#include "ec_errors_cpsar.h"
7759 +#include "ec_errors_cpaal2.h"
7764 +typedef short bit16;
7767 +typedef unsigned char bit8u;
7768 +typedef unsigned short bit16u;
7769 +typedef unsigned int bit32u;
7773 +typedef short INT16;
7775 +typedef unsigned char UINT8;
7776 +typedef unsigned short UINT16;
7777 +typedef unsigned int UINT32;
7779 +/*typedef unsigned int size_t;*/
7785 +#define TRUE (1==1)
7789 +#define FALSE (1==2)
7798 +#define VirtToPhys(a) (((int)a)&~0xe0000000)
7799 +#define VirtToVirtNoCache(a) ((void*)((VirtToPhys(a))|0xa0000000))
7800 +#define VirtToVirtCache(a) ((void*)((VirtToPhys(a))|0x80000000))
7801 +#define PhysToVirtNoCache(a) ((void*)(((int)a)|0xa0000000))
7802 +#define PhysToVirtCache(a) ((void*)(((int)a)|0x80000000))
7804 +#define DataCacheHitInvalidate(a) {__asm__(" cache 17, (%0)" : : "r" (a));}
7805 +#define DataCacheHitWriteback(a) {__asm__(" cache 25, (%0)" : : "r" (a));}
7808 +#define PARTIAL 1 /**< Used in @c Close() and @c ChannelTeardown() */
7809 +#define FULL 2 /**< Used in @c Close() and @c ChannelTeardown() */
7811 +/* Channel Teardown Defines */
7812 +#define RX_TEARDOWN 2
7813 +#define TX_TEARDOWN 1
7814 +#define BLOCKING_TEARDOWN 8
7815 +#define FULL_TEARDOWN 4
7816 +#define PARTIAL_TEARDOWN 0
7819 +#define DIRECTION_TX 0
7820 +#define DIRECTION_RX 1
7823 +#define HAL_ERROR_DEVICE_NOT_FOUND 1
7824 +#define HAL_ERROR_FAILED_MALLOC 2
7825 +#define HAL_ERROR_OSFUNC_SIZE 3
7826 +#define HAL_DEFAULT 0xFFFFFFFF
7827 +#define VALID(val) (val!=HAL_DEFAULT)
7832 +HAL Module Codes. Each HAL module reporting an error code
7833 +should OR the error code with the respective Module error code
7834 +from the list below.
7836 +#define EC_AAL5 EC_HAL|EC_DEV_AAL5
7837 +#define EC_AAL2 EC_HAL|EC_DEV_AAL2
7838 +#define EC_CPSAR EC_HAL|EC_DEV_CPSAR
7839 +#define EC_CPMAC EC_HAL|EC_DEV_CPMAC
7840 +#define EC_VDMA EC_HAL|EC_DEV_VDMA
7841 +#define EC_VLYNQ EC_HAL|EC_DEV_VLYNQ
7842 +#define EC_CPPI EC_HAL|EC_DEV_CPPI
7845 +HAL Function Codes. Each HAL module reporting an error code
7846 +should OR the error code with one of the function codes from
7849 +#define EC_FUNC_HAL_INIT EC_FUNC(1)
7850 +#define EC_FUNC_CHSETUP EC_FUNC(2)
7851 +#define EC_FUNC_CHTEARDOWN EC_FUNC(3)
7852 +#define EC_FUNC_RXRETURN EC_FUNC(4)
7853 +#define EC_FUNC_SEND EC_FUNC(5)
7854 +#define EC_FUNC_RXINT EC_FUNC(6)
7855 +#define EC_FUNC_TXINT EC_FUNC(7)
7856 +#define EC_FUNC_AAL2_VDMA EC_FUNC(8)
7857 +#define EC_FUNC_OPTIONS EC_FUNC(9)
7858 +#define EC_FUNC_PROBE EC_FUNC(10)
7859 +#define EC_FUNC_OPEN EC_FUNC(11)
7860 +#define EC_FUNC_CONTROL EC_FUNC(12)
7861 +#define EC_FUNC_DEVICE_INT EC_FUNC(13)
7862 +#define EC_FUNC_STATUS EC_FUNC(14)
7863 +#define EC_FUNC_TICK EC_FUNC(15)
7864 +#define EC_FUNC_CLOSE EC_FUNC(16)
7865 +#define EC_FUNC_SHUTDOWN EC_FUNC(17)
7866 +#define EC_FUNC_DEVICE_INT_ALT EC_FUNC(18) /* +GSG 030306 */
7869 +HAL Error Codes. The list below defines every type of error
7870 +used in all HAL modules. DO NOT CHANGE THESE VALUES! Add new
7871 +values in integer order to the bottom of the list.
7873 +#define EC_VAL_PDSP_LOAD_FAIL EC_ERR(0x01)|EC_CRITICAL
7874 +#define EC_VAL_FIRMWARE_TOO_LARGE EC_ERR(0x02)|EC_CRITICAL
7875 +#define EC_VAL_DEVICE_NOT_FOUND EC_ERR(0x03)|EC_CRITICAL
7876 +#define EC_VAL_BASE_ADDR_NOT_FOUND EC_ERR(0x04)|EC_CRITICAL
7877 +#define EC_VAL_RESET_BIT_NOT_FOUND EC_ERR(0x05)|EC_CRITICAL
7878 +#define EC_VAL_CH_INFO_NOT_FOUND EC_ERR(0x06)
7879 +#define EC_VAL_RX_STATE_RAM_NOT_CLEARED EC_ERR(0x07)|EC_CRITICAL
7880 +#define EC_VAL_TX_STATE_RAM_NOT_CLEARED EC_ERR(0x08)|EC_CRITICAL
7881 +#define EC_VAL_MALLOC_DEV_FAILED EC_ERR(0x09)
7882 +#define EC_VAL_OS_VERSION_NOT_SUPPORTED EC_ERR(0x0A)|EC_CRITICAL
7883 +#define EC_VAL_CPSAR_VERSION_NOT_SUPPORTED EC_ERR(0x0B)|EC_CRITICAL
7884 +#define EC_VAL_NULL_CPSAR_DEV EC_ERR(0x0C)|EC_CRITICAL
7886 +#define EC_VAL_LUT_NOT_READY EC_ERR(0x0D)
7887 +#define EC_VAL_INVALID_CH EC_ERR(0x0E)
7888 +#define EC_VAL_NULL_CH_STRUCT EC_ERR(0x0F)
7889 +#define EC_VAL_RX_TEARDOWN_ALREADY_PEND EC_ERR(0x10)
7890 +#define EC_VAL_TX_TEARDOWN_ALREADY_PEND EC_ERR(0x11)
7891 +#define EC_VAL_RX_CH_ALREADY_TORNDOWN EC_ERR(0x12)
7892 +#define EC_VAL_TX_CH_ALREADY_TORNDOWN EC_ERR(0x13)
7893 +#define EC_VAL_TX_TEARDOWN_TIMEOUT EC_ERR(0x14)
7894 +#define EC_VAL_RX_TEARDOWN_TIMEOUT EC_ERR(0x15)
7895 +#define EC_VAL_CH_ALREADY_TORNDOWN EC_ERR(0x16)
7896 +#define EC_VAL_VC_SETUP_NOT_READY EC_ERR(0x17)
7897 +#define EC_VAL_VC_TEARDOWN_NOT_READY EC_ERR(0x18)
7898 +#define EC_VAL_INVALID_VC EC_ERR(0x19)
7899 +#define EC_VAL_INVALID_LC EC_ERR(0x20)
7900 +#define EC_VAL_INVALID_VDMA_CH EC_ERR(0x21)
7901 +#define EC_VAL_INVALID_CID EC_ERR(0x22)
7902 +#define EC_VAL_INVALID_UUI EC_ERR(0x23)
7903 +#define EC_VAL_INVALID_UUI_DISCARD EC_ERR(0x24)
7904 +#define EC_VAL_CH_ALREADY_OPEN EC_ERR(0x25)
7906 +#define EC_VAL_RCB_MALLOC_FAILED EC_ERR(0x26)
7907 +#define EC_VAL_RX_BUFFER_MALLOC_FAILED EC_ERR(0x27)
7908 +#define EC_VAL_OUT_OF_TCBS EC_ERR(0x28)
7909 +#define EC_VAL_NO_TCBS EC_ERR(0x29)
7910 +#define EC_VAL_NULL_RCB EC_ERR(0x30)|EC_CRITICAL
7911 +#define EC_VAL_SOP_ERROR EC_ERR(0x31)|EC_CRITICAL
7912 +#define EC_VAL_EOP_ERROR EC_ERR(0x32)|EC_CRITICAL
7913 +#define EC_VAL_NULL_TCB EC_ERR(0x33)|EC_CRITICAL
7914 +#define EC_VAL_CORRUPT_RCB_CHAIN EC_ERR(0x34)|EC_CRITICAL
7915 +#define EC_VAL_TCB_MALLOC_FAILED EC_ERR(0x35)
7917 +#define EC_VAL_DISABLE_POLLING_FAILED EC_ERR(0x36)
7918 +#define EC_VAL_KEY_NOT_FOUND EC_ERR(0x37)
7919 +#define EC_VAL_MALLOC_FAILED EC_ERR(0x38)
7920 +#define EC_VAL_RESET_BASE_NOT_FOUND EC_ERR(0x39)|EC_CRITICAL
7921 +#define EC_VAL_INVALID_STATE EC_ERR(0x40)
7922 +#define EC_VAL_NO_TXH_WORK_TO_DO EC_ERR(0x41)
7923 +#define EC_VAL_NO_TXL_WORK_TO_DO EC_ERR(0x42)
7924 +#define EC_VAL_NO_RX_WORK_TO_DO EC_ERR(0x43)
7925 +#define EC_VAL_NOT_LINKED EC_ERR(0x44)
7926 +#define EC_VAL_INTERRUPT_NOT_FOUND EC_ERR(0x45)
7927 +#define EC_VAL_OFFSET_NOT_FOUND EC_ERR(0x46)
7928 +#define EC_VAL_MODULE_ALREADY_CLOSED EC_ERR(0x47)
7929 +#define EC_VAL_MODULE_ALREADY_SHUTDOWN EC_ERR(0x48)
7930 +#define EC_VAL_ACTION_NOT_FOUND EC_ERR(0x49)
7931 +#define EC_VAL_RX_CH_ALREADY_SETUP EC_ERR(0x50)
7932 +#define EC_VAL_TX_CH_ALREADY_SETUP EC_ERR(0x51)
7933 +#define EC_VAL_RX_CH_ALREADY_OPEN EC_ERR(0x52)
7934 +#define EC_VAL_TX_CH_ALREADY_OPEN EC_ERR(0x53)
7935 +#define EC_VAL_CH_ALREADY_SETUP EC_ERR(0x54)
7936 +#define EC_VAL_RCB_NEEDS_BUFFER EC_ERR(0x55) /* +GSG 030410 */
7937 +#define EC_VAL_RCB_DROPPED EC_ERR(0x56) /* +GSG 030410 */
7938 +#define EC_VAL_INVALID_VALUE EC_ERR(0x57)
7941 +@defgroup shared_data Shared Data Structures
7943 +The data structures documented here are shared by all modules.
7947 + * @ingroup shared_data
7948 + * This is the fragment list structure. Each fragment list entry contains a
7949 + * length and a data buffer.
7953 + bit32u len; /**< Length of the fragment in bytes (lower 16 bits are valid). For SOP, upper 16 bits is the buffer offset. */
7954 + void *data; /**< Pointer to fragment data. */
7955 + void *OsInfo; /**< Pointer to OS defined data. */
7958 +#if defined (_CPHAL_CPMAC)
7959 +#define CB_PASSCRC_BIT (1<<26)
7961 +/* CPMAC CPHAL STATUS */
7962 +#define CPMAC_STATUS_LINK (1 << 0)
7963 +#define CPMAC_STATUS_LINK_DUPLEX (1 << 1) /* 0 - HD, 1 - FD */
7964 +#define CPMAC_STATUS_LINK_SPEED (1 << 2) /* 0 - 10, 1 - 100 */
7966 +/* ADAPTER CHECK Codes */
7968 +#define CPMAC_STATUS_ADAPTER_CHECK (1 << 7)
7969 +#define CPMAC_STATUS_HOST_ERR_DIRECTION (1 << 8)
7970 +#define CPMAC_STATUS_HOST_ERR_CODE (0xF << 9)
7971 +#define CPMAC_STATUS_HOST_ERR_CH (0x7 << 13)
7973 +#define _CPMDIO_DISABLE (1 << 0)
7974 +#define _CPMDIO_HD (1 << 1)
7975 +#define _CPMDIO_FD (1 << 2)
7976 +#define _CPMDIO_10 (1 << 3)
7977 +#define _CPMDIO_100 (1 << 4)
7978 +#define _CPMDIO_NEG_OFF (1 << 5)
7979 +#define _CPMDIO_LOOPBK (1 << 16)
7980 +#define _CPMDIO_NOPHY (1 << 20)
7984 + * @ingroup shared_data
7985 + * Channel specific configuration information. This structure should be
7986 + * populated by upper-layer software prior to calling @c ChannelSetup(). Any
7987 + * configuration item that can be changed on a per channel basis should
7988 + * be represented here. Each module may define this structure with additional
7989 + * module-specific members.
7993 + int Channel; /**< Channel number. */
7994 + int Direction; /**< DIRECTION_RX(1) or DIRECTION_TX(0). */
7995 + OS_SETUP *OsSetup; /**< OS defined information associated with this channel. */
7997 +#if defined(_CPHAL_AAL5) || defined (_CPHAL_CPSAR) || defined (_CPHAL_CPMAC)
7998 + int RxBufSize; /**< Size (in bytes) for each Rx buffer.*/
7999 + int RxBufferOffset; /**< Number of bytes to offset rx data from start of buffer (must be less than buffer size). */
8000 + int RxNumBuffers; /**< The number of Rx buffer descriptors to allocate for Ch. */
8001 + int RxServiceMax; /**< Maximum number of packets to service at one time. */
8003 + int TxNumBuffers; /**< The number of Tx buffer descriptors to allocate for Ch. */
8004 + int TxNumQueues; /**< Number of Tx queues for this channel (1-2). Choosing 2 enables a low priority SAR queue. */
8005 + int TxServiceMax; /**< Maximum number of packets to service at one time. */
8008 +#if defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
8009 + int CpcsUU; /**< The 2-byte CPCS UU and CPI information. */
8010 + int Gfc; /**< Generic Flow Control. */
8011 + int Clp; /**< Cell Loss Priority. */
8012 + int Pti; /**< Payload Type Indication. */
8015 +#if defined(_CPHAL_AAL2) || defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
8016 + int DaMask; /**< Specifies whether credit issuance is paused when Tx data not available. */
8017 + int Priority; /**< Priority bin this channel will be scheduled within. */
8018 + int PktType; /**< 0=AAL5,1=Null AAL,2=OAM,3=Transparent,4=AAL2. */
8019 + int Vci; /**< Virtual Channel Identifier. */
8020 + int Vpi; /**< Virtual Path Identifier. */
8021 + int FwdUnkVc; /**< Enables forwarding of unknown VCI/VPI cells to host. 1=enable, 0=disable. */
8024 + int TxVc_CellRate; /**< Tx rate, set as clock ticks between transmissions (SCR for VBR, CBR for CBR). */
8025 + int TxVc_QosType; /**< 0=CBR,1=VBR,2=UBR,3=UBRmcr. */
8026 + int TxVc_Mbs; /**< Min Burst Size in cells.*/
8027 + int TxVc_Pcr; /**< Peak Cell Rate for VBR in clock ticks between transmissions. */
8029 + bit32 TxVc_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Tx Ch (must be big endian with 0 PTI). */
8030 + int TxVc_OamTc; /**< TC Path to transmit OAM cells for TX connection (0,1). */
8031 + int TxVc_VpOffset; /**< Offset to the OAM VP state table. */
8033 + int RxVc_OamCh; /**< Ch to terminate rx'd OAM cells to be forwarded to the host. */
8034 + int RxVc_OamToHost; /**< 0=do not pass, 1=pass. */
8035 + bit32 RxVc_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Rx conn (must be big endian with 0 PTI). */
8036 + int RxVc_OamTc; /**< TC Path to transmit OAM cells for RX connection (0,1). */
8037 + int RxVc_VpOffset; /**< Offset to the OAM VP state table. */
8039 + int TxVp_OamTc; /**< TC Path to transmit OAM cells for TX VP connection (0,1). */
8040 + bit32 TxVp_AtmHeader; /**< ATM Header placed on firmware gen'd VP OAM cells for this Tx VP conn (must be big endian with 0 VCI). */
8042 + int RxVp_OamCh; /**< Ch to terminate rx'd OAM cells to be forwarded to the host. */
8043 + int RxVp_OamToHost; /**< 0=do not pass, 1=pass. */
8044 + bit32 RxVp_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Rx VP conn (must be big endian with 0 VCI). */
8045 + int RxVp_OamTc; /**< TC Path to transmit OAM cells for RX VP connection (0,1). */
8046 + int RxVp_OamVcList; /**< Indicates all VC channels associated with this VP channel (one-hot encoded). */
8050 +#ifdef _CPHAL_VDMAVT
8051 + bit32u RemFifoAddr; /* Mirror mode only. */
8061 + * This structure contains each statistic value gathered by the CPHAL.
8062 + * Applications may access statistics data by using the @c StatsGet() routine.
8065 +#if defined(_CPHAL_AAL2) || defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
8068 + bit32u CrcErrors[16];
8069 + bit32u LenErrors[16];
8070 + bit32u DmaLenErrors[16];
8071 + bit32u AbortErrors[16];
8072 + bit32u StarvErrors[16];
8073 + bit32u TxMisQCnt[16][2];
8074 + bit32u RxMisQCnt[16];
8075 + bit32u RxEOQCnt[16];
8076 + bit32u TxEOQCnt[16][2];
8077 + bit32u RxPacketsServiced[16];
8078 + bit32u TxPacketsServiced[16][2];
8079 + bit32u RxMaxServiced;
8080 + bit32u TxMaxServiced[16][2];
8087 + * VDMA Channel specific configuration information
8092 + int Ch; /**< Channel Number */
8093 + int RemoteEndian; /**< Endianness of remote VDMA-VT device */
8094 + int CpsSwap; /**< When 0, octet 0 in CPS pkt located in LS byte of 16-bit word sent to rem VDMA device. When 1, in MS byte. */
8099 + typedef void HAL_DEVICE;
8100 + typedef void HAL_PRIVATE;
8101 + typedef void HAL_RCB;
8102 + typedef void HAL_RECEIVEINFO;
8106 + * @ingroup shared_data
8107 + * The HAL_FUNCTIONS struct defines the function pointers used by upper layer
8108 + * software. The upper layer software receives these pointers through the
8109 + * call to xxxInitModule().
8113 + int (*ChannelSetup) (HAL_DEVICE *HalDev, CHANNEL_INFO *Channel, OS_SETUP *OsSetup);
8114 + int (*ChannelTeardown) (HAL_DEVICE *HalDev, int Channel, int Mode);
8115 + int (*Close) (HAL_DEVICE *HalDev, int Mode);
8116 + int (*Control) (HAL_DEVICE *HalDev, const char *Key, const char *Action, void *Value);
8117 + int (*Init) (HAL_DEVICE *HalDev);
8118 + int (*Open) (HAL_DEVICE *HalDev);
8119 + int (*PacketProcessEnd) (HAL_DEVICE *HalDev);
8120 + int (*Probe) (HAL_DEVICE *HalDev);
8121 + int (*RxReturn) (HAL_RECEIVEINFO *HalReceiveInfo, int StripFlag);
8122 + int (*Send) (HAL_DEVICE *HalDev, FRAGLIST *FragList, int FragCount, int PacketSize, OS_SENDINFO *OsSendInfo, bit32u Mode);
8123 + int (*Shutdown) (HAL_DEVICE *HalDev);
8124 + int (*Tick) (HAL_DEVICE *HalDev);
8127 + int (*Kick) (HAL_DEVICE *HalDev, int Queue);
8128 + void (*OamFuncConfig) (HAL_DEVICE *HalDev, unsigned int OamConfig);
8129 + void (*OamLoopbackConfig) (HAL_DEVICE *HalDev, unsigned int OamConfig, unsigned int *LLID, unsigned int CorrelationTag);
8130 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
8131 + STAT_INFO* (*StatsGetOld)(HAL_DEVICE *HalDev);
8136 + * @ingroup shared_data
8137 + * The OS_FUNCTIONS struct defines the function pointers for all upper layer
8138 + * functions accessible to the CPHAL. The upper layer software is responsible
8139 + * for providing the correct OS-specific implementations for the following
8140 + * functions. It is populated by calling InitModule() (done by the CPHAL in
8141 + * xxxInitModule().
8145 + int (*Control)(OS_DEVICE *OsDev, const char *Key, const char *Action, void *Value);
8146 + void (*CriticalOn)(void);
8147 + void (*CriticalOff)(void);
8148 + void (*DataCacheHitInvalidate)(void *MemPtr, int Size);
8149 + void (*DataCacheHitWriteback)(void *MemPtr, int Size);
8150 + int (*DeviceFindInfo)(int Inst, const char *DeviceName, void *DeviceInfo);
8151 + int (*DeviceFindParmUint)(void *DeviceInfo, const char *Parm, bit32u *Value);
8152 + int (*DeviceFindParmValue)(void *DeviceInfo, const char *Parm, void *Value);
8153 + void (*Free)(void *MemPtr);
8154 + void (*FreeRxBuffer)(OS_RECEIVEINFO *OsReceiveInfo, void *MemPtr);
8155 + void (*FreeDev)(void *MemPtr);
8156 + void (*FreeDmaXfer)(void *MemPtr);
8157 + void (*IsrRegister)(OS_DEVICE *OsDev, int (*halISR)(HAL_DEVICE*, int*), int InterruptBit);
8158 + void (*IsrUnRegister)(OS_DEVICE *OsDev, int InterruptBit);
8159 + void* (*Malloc)(bit32u size);
8160 + void* (*MallocDev)(bit32u Size);
8161 + void* (*MallocDmaXfer)(bit32u size, void *MemBase, bit32u MemRange);
8162 + void* (*MallocRxBuffer)(bit32u size, void *MemBase, bit32u MemRange,
8163 + OS_SETUP *OsSetup, HAL_RECEIVEINFO *HalReceiveInfo,
8164 + OS_RECEIVEINFO **OsReceiveInfo, OS_DEVICE *OsDev);
8165 + void* (*Memset)(void *Dest, int C, bit32u N);
8166 + int (*Printf)(const char *Format, ...);
8167 + int (*Receive)(OS_DEVICE *OsDev,FRAGLIST *FragList,bit32u FragCount,
8168 + bit32u PacketSize,HAL_RECEIVEINFO *HalReceiveInfo, bit32u Mode);
8169 + int (*SendComplete)(OS_SENDINFO *OsSendInfo);
8170 + int (*Sprintf)(char *S, const char *Format, ...);
8171 + int (*Strcmpi)(const char *Str1, const char *Str2);
8172 + unsigned int (*Strlen)(const char *S);
8173 + char* (*Strstr)(const char *S1, const char *S2);
8174 + unsigned long (*Strtoul)(const char *Str, char **Endptr, int Base);
8175 + void (*TeardownComplete)(OS_DEVICE *OsDev, int Ch, int Direction);
8178 +/************** MODULE SPECIFIC STUFF BELOW **************/
8180 +#ifdef _CPHAL_CPMAC
8183 +int halCpmacInitModule(HAL_DEVICE **HalDev, OS_DEVICE *OsDev, HAL_FUNCTIONS *HalFunc, int (*osBridgeInitModule)(OS_FUNCTIONS *), void* (*osMallocDev) (bit32u), int *Size, int inst);
8186 +int halCpmacInitModule(HAL_DEVICE **HalDev,
8188 + HAL_FUNCTIONS **HalFunc,
8189 + OS_FUNCTIONS *OsFunc,
8197 + * @ingroup shared_data
8198 + * The AAL5_FUNCTIONS struct defines the AAL5 function pointers used by upper layer
8199 + * software. The upper layer software receives these pointers through the
8200 + * call to cphalInitModule().
8205 + int (*ChannelSetup)(HAL_DEVICE *HalDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
8206 + int (*ChannelTeardown)(HAL_DEVICE *HalDev, int Ch, int Mode);
8207 + int (*Close)(HAL_DEVICE *HalDev, int Mode);
8208 + int (*Init)(HAL_DEVICE *HalDev);
8209 + int (*ModeChange)(HAL_DEVICE *HalDev, char *DeviceParms);
8210 + int (*Open)(HAL_DEVICE *HalDev);
8211 + int (*InfoGet)(HAL_DEVICE *HalDev, int Key, void *Value);
8212 + int (*Probe)(HAL_DEVICE *HalDev);
8213 + int (*RxReturn)(HAL_RECEIVEINFO *HalReceiveInfo, int StripFlag);
8214 + int (*Send)(HAL_DEVICE *HalDev,FRAGLIST *FragList,int FragCount,
8215 + int PacketSize,OS_SENDINFO *OsSendInfo,int Ch, int Queue,
8217 + int (*StatsClear)(HAL_DEVICE *HalDev);
8218 + STAT_INFO* (*StatsGet)(HAL_DEVICE *HalDev);
8219 + int (*Status)(HAL_DEVICE *HalDev);
8220 + void (*Tick)(HAL_DEVICE *HalDev);
8221 + int (*Kick)(HAL_DEVICE *HalDev, int Queue);
8222 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
8226 +int cpaal5InitModule(HAL_DEVICE **HalDev,
8228 + HAL_FUNCTIONS **HalFunc,
8229 + OS_FUNCTIONS *OsFunc,
8237 + * @ingroup shared_data
8238 + * The AAL2_FUNCTIONS struct defines the AAL2 function pointers used by upper layer
8239 + * software. The upper layer software receives these pointers through the
8240 + * call to cphalInitModule().
8244 + int (*ChannelSetup)(HAL_DEVICE *HalDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
8245 + int (*ChannelTeardown)(HAL_DEVICE *HalDev, int Ch, int Mode);
8246 + int (*Close)(HAL_DEVICE *HalDev, int Mode);
8247 + int (*Init)(HAL_DEVICE *HalDev);
8248 + int (*ModeChange)(HAL_DEVICE *HalDev, char *DeviceParms);
8249 + int (*Open)(HAL_DEVICE *HalDev);
8250 + int (*OptionsGet)(HAL_DEVICE *HalDev, char *Key, bit32u *Value);
8251 + int (*Probe)(HAL_DEVICE *HalDev);
8253 + int (*StatsClear)(HAL_DEVICE *HalDev);
8254 + STAT_INFO* (*StatsGet)(HAL_DEVICE *HalDev);
8255 + int (*Status)(HAL_DEVICE *HalDev);
8256 + void (*Tick)(HAL_DEVICE *HalDev);
8257 + int (*Aal2UuiMappingSetup)(HAL_DEVICE *HalDev, int VC, int UUI,
8258 + int VdmaCh, int UUIDiscard);
8259 + int (*Aal2RxMappingSetup)(HAL_DEVICE *HalDev, int VC, int CID,
8261 + int (*Aal2TxMappingSetup)(HAL_DEVICE *HalDev, int VC, int LC, int VdmaCh);
8262 + int (*Aal2VdmaChSetup)(HAL_DEVICE *HalDev, bit32u RemVdmaVtAddr,
8263 + VdmaChInfo *VdmaCh);
8264 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
8265 + int (*Aal2ModeChange)(HAL_DEVICE *HalDev, int Vc, int RxCrossMode,
8266 + int RxMultiMode, int TxMultiMode, int SchedMode,
8268 + void (*Aal2VdmaEnable)(HAL_DEVICE *HalDev, int Ch);
8269 + int (*Aal2VdmaDisable)(HAL_DEVICE *HalDev, int Ch);
8272 +int cpaal2InitModule(HAL_DEVICE **HalDev,
8274 + AAL2_FUNCTIONS **HalFunc,
8275 + OS_FUNCTIONS *OsFunc,
8281 +#ifdef _CPHAL_VDMAVT
8283 + * @ingroup shared_data
8284 + * The VDMA_FUNCTIONS struct defines the HAL function pointers used by upper layer
8285 + * software. The upper layer software receives these pointers through the
8286 + * call to InitModule().
8288 + * Note that this list is still under definition.
8292 + bit32 (*Init)( HAL_DEVICE *VdmaVtDev);
8293 + /* bit32 (*SetupTxFifo)(HAL_DEVICE *VdmaVtDev, bit32u LclRem,
8294 + bit32u Addr, bit32u Size, bit32u PollInt);
8295 + bit32 (*SetupRxFifo)(HAL_DEVICE *VdmaVtDev, bit32u LclRem,
8296 + bit32u Addr, bit32u Size, bit32u PollInt); */
8297 + bit32 (*Tx)(HAL_DEVICE *VdmaVtDev);
8298 + bit32 (*Rx)(HAL_DEVICE *VdmaVtDev);
8299 + bit32 (*SetRemoteChannel)(HAL_DEVICE *VdmaVtDev, bit32u RemAddr,
8301 + bit32 (*ClearRxInt)(HAL_DEVICE *VdmaVtDev);
8302 + bit32 (*ClearTxInt)(HAL_DEVICE *VdmaVtDev);
8303 + bit32 (*Open)(HAL_DEVICE *VdmaVtDev);
8304 + bit32 (*Close)(HAL_DEVICE *VdmaVtDev);
8305 + int (*Control) (HAL_DEVICE *HalDev, const char *Key, const char *Action, void *Value);
8306 + int (*ChannelSetup)(HAL_DEVICE *VdmaVtDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
8307 + int (*ChannelTeardown)(HAL_DEVICE *VdmaVtDev, int Ch, int Mode);
8308 + int (*Send)(HAL_DEVICE *VdmaVtDev,FRAGLIST *FragList,int FragCount,
8309 + int PacketSize,OS_SENDINFO *OsSendInfo,bit32u Mode);
8312 +int VdmaInitModule(HAL_DEVICE **VdmaVt,
8314 + VDMA_FUNCTIONS **VdmaVtFunc,
8315 + OS_FUNCTIONS *OsFunc,
8322 +extern int cphalInitModule(MODULE_TYPE ModuleType, HAL_DEVICE **HalDev, OS_DEVICE *OsDev, HAL_FUNCTIONS *HalFunc,
8323 + int (*osInitModule)(OS_FUNCTIONS *), void* (*osMallocDev)(bit32u),
8324 + int *Size, int Inst);
8329 +extern const char hcSarFrequency[];
8332 +#ifdef _CPHAL_CPMAC
8333 +/* following will be common, once 'utl' added */
8334 +extern const char hcClear[];
8335 +extern const char hcGet[];
8336 +extern const char hcSet[];
8337 +extern const char hcTick[];
8339 +extern const char hcCpuFrequency[];
8340 +extern const char hcCpmacFrequency[];
8341 +extern const char hcMdioBusFrequency[];
8342 +extern const char hcMdioClockFrequency[];
8343 +extern const char hcCpmacBase[];
8344 +extern const char hcPhyNum[];
8345 +extern const char hcSize[];
8346 +extern const char hcCpmacSize[];
8347 +extern const char hcPhyAccess[];
8350 +#endif /* end of _INC_ */
8351 diff -urN linux.old/drivers/atm/sangam_atm/cpswhal_cpsar.h linux.dev/drivers/atm/sangam_atm/cpswhal_cpsar.h
8352 --- linux.old/drivers/atm/sangam_atm/cpswhal_cpsar.h 1970-01-01 01:00:00.000000000 +0100
8353 +++ linux.dev/drivers/atm/sangam_atm/cpswhal_cpsar.h 2005-07-10 08:02:01.430113488 +0200
8355 +/************************************************************************
8356 + * TNETDxxxx Software Support
8357 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
8362 + * User include file, contains data definitions shared between the CPHAL
8363 + * and the upper-layer software.
8366 + * Date Modifier Ver Notes
8367 + * 28Feb02 Greg 1.00 Original
8368 + * 06Mar02 Greg 1.01 Documentation enhanced
8369 + * 18Jul02 Greg 1.02 Many updates (OAM additions, general reorg)
8370 + * 22Nov02 Mick RC2 Additions from Denis' input on Control
8372 + * author Greg Guyotte
8374 + * date 18-Jul-2002
8375 + *****************************************************************************/
8376 +#ifndef _INC_CPHAL_H
8377 +#define _INC_CPHAL_H
8379 +#ifdef _CPHAL_CPMAC
8380 +#include "ec_errors_cpmac.h"
8384 +#include "ec_errors_cpaal5.h"
8387 +#ifdef _CPHAL_CPSAR
8388 +#include "ec_errors_cpsar.h"
8392 +#include "ec_errors_cpaal2.h"
8397 +typedef short bit16;
8400 +typedef unsigned char bit8u;
8401 +typedef unsigned short bit16u;
8402 +typedef unsigned int bit32u;
8406 +typedef short INT16;
8408 +typedef unsigned char UINT8;
8409 +typedef unsigned short UINT16;
8410 +typedef unsigned int UINT32;
8412 +/*typedef unsigned int size_t;*/
8418 +#define TRUE (1==1)
8422 +#define FALSE (1==2)
8431 +#define VirtToPhys(a) (((int)a)&~0xe0000000)
8432 +#define VirtToVirtNoCache(a) ((void*)((VirtToPhys(a))|0xa0000000))
8433 +#define VirtToVirtCache(a) ((void*)((VirtToPhys(a))|0x80000000))
8434 +#define PhysToVirtNoCache(a) ((void*)(((int)a)|0xa0000000))
8435 +#define PhysToVirtCache(a) ((void*)(((int)a)|0x80000000))
8437 +#define DataCacheHitInvalidate(a) {__asm__(" cache 17, (%0)" : : "r" (a));}
8438 +#define DataCacheHitWriteback(a) {__asm__(" cache 25, (%0)" : : "r" (a));}
8441 +#define PARTIAL 1 /**< Used in @c Close() and @c ChannelTeardown() */
8442 +#define FULL 2 /**< Used in @c Close() and @c ChannelTeardown() */
8444 +/* Channel Teardown Defines */
8445 +#define RX_TEARDOWN 2
8446 +#define TX_TEARDOWN 1
8447 +#define BLOCKING_TEARDOWN 8
8448 +#define FULL_TEARDOWN 4
8449 +#define PARTIAL_TEARDOWN 0
8452 +#define DIRECTION_TX 0
8453 +#define DIRECTION_RX 1
8456 +#define HAL_ERROR_DEVICE_NOT_FOUND 1
8457 +#define HAL_ERROR_FAILED_MALLOC 2
8458 +#define HAL_ERROR_OSFUNC_SIZE 3
8459 +#define HAL_DEFAULT 0xFFFFFFFF
8460 +#define VALID(val) (val!=HAL_DEFAULT)
8465 +HAL Module Codes. Each HAL module reporting an error code
8466 +should OR the error code with the respective Module error code
8467 +from the list below.
8469 +#define EC_AAL5 EC_HAL|EC_DEV_AAL5
8470 +#define EC_AAL2 EC_HAL|EC_DEV_AAL2
8471 +#define EC_CPSAR EC_HAL|EC_DEV_CPSAR
8472 +#define EC_CPMAC EC_HAL|EC_DEV_CPMAC
8473 +#define EC_VDMA EC_HAL|EC_DEV_VDMA
8474 +#define EC_VLYNQ EC_HAL|EC_DEV_VLYNQ
8475 +#define EC_CPPI EC_HAL|EC_DEV_CPPI
8478 +HAL Function Codes. Each HAL module reporting an error code
8479 +should OR the error code with one of the function codes from
8482 +#define EC_FUNC_HAL_INIT EC_FUNC(1)
8483 +#define EC_FUNC_CHSETUP EC_FUNC(2)
8484 +#define EC_FUNC_CHTEARDOWN EC_FUNC(3)
8485 +#define EC_FUNC_RXRETURN EC_FUNC(4)
8486 +#define EC_FUNC_SEND EC_FUNC(5)
8487 +#define EC_FUNC_RXINT EC_FUNC(6)
8488 +#define EC_FUNC_TXINT EC_FUNC(7)
8489 +#define EC_FUNC_AAL2_VDMA EC_FUNC(8)
8490 +#define EC_FUNC_OPTIONS EC_FUNC(9)
8491 +#define EC_FUNC_PROBE EC_FUNC(10)
8492 +#define EC_FUNC_OPEN EC_FUNC(11)
8493 +#define EC_FUNC_CONTROL EC_FUNC(12)
8494 +#define EC_FUNC_DEVICE_INT EC_FUNC(13)
8495 +#define EC_FUNC_STATUS EC_FUNC(14)
8496 +#define EC_FUNC_TICK EC_FUNC(15)
8497 +#define EC_FUNC_CLOSE EC_FUNC(16)
8498 +#define EC_FUNC_SHUTDOWN EC_FUNC(17)
8499 +#define EC_FUNC_DEVICE_INT_ALT EC_FUNC(18) /* +GSG 030306 */
8502 +HAL Error Codes. The list below defines every type of error
8503 +used in all HAL modules. DO NOT CHANGE THESE VALUES! Add new
8504 +values in integer order to the bottom of the list.
8506 +#define EC_VAL_PDSP_LOAD_FAIL EC_ERR(0x01)|EC_CRITICAL
8507 +#define EC_VAL_FIRMWARE_TOO_LARGE EC_ERR(0x02)|EC_CRITICAL
8508 +#define EC_VAL_DEVICE_NOT_FOUND EC_ERR(0x03)|EC_CRITICAL
8509 +#define EC_VAL_BASE_ADDR_NOT_FOUND EC_ERR(0x04)|EC_CRITICAL
8510 +#define EC_VAL_RESET_BIT_NOT_FOUND EC_ERR(0x05)|EC_CRITICAL
8511 +#define EC_VAL_CH_INFO_NOT_FOUND EC_ERR(0x06)
8512 +#define EC_VAL_RX_STATE_RAM_NOT_CLEARED EC_ERR(0x07)|EC_CRITICAL
8513 +#define EC_VAL_TX_STATE_RAM_NOT_CLEARED EC_ERR(0x08)|EC_CRITICAL
8514 +#define EC_VAL_MALLOC_DEV_FAILED EC_ERR(0x09)
8515 +#define EC_VAL_OS_VERSION_NOT_SUPPORTED EC_ERR(0x0A)|EC_CRITICAL
8516 +#define EC_VAL_CPSAR_VERSION_NOT_SUPPORTED EC_ERR(0x0B)|EC_CRITICAL
8517 +#define EC_VAL_NULL_CPSAR_DEV EC_ERR(0x0C)|EC_CRITICAL
8519 +#define EC_VAL_LUT_NOT_READY EC_ERR(0x0D)
8520 +#define EC_VAL_INVALID_CH EC_ERR(0x0E)
8521 +#define EC_VAL_NULL_CH_STRUCT EC_ERR(0x0F)
8522 +#define EC_VAL_RX_TEARDOWN_ALREADY_PEND EC_ERR(0x10)
8523 +#define EC_VAL_TX_TEARDOWN_ALREADY_PEND EC_ERR(0x11)
8524 +#define EC_VAL_RX_CH_ALREADY_TORNDOWN EC_ERR(0x12)
8525 +#define EC_VAL_TX_CH_ALREADY_TORNDOWN EC_ERR(0x13)
8526 +#define EC_VAL_TX_TEARDOWN_TIMEOUT EC_ERR(0x14)
8527 +#define EC_VAL_RX_TEARDOWN_TIMEOUT EC_ERR(0x15)
8528 +#define EC_VAL_CH_ALREADY_TORNDOWN EC_ERR(0x16)
8529 +#define EC_VAL_VC_SETUP_NOT_READY EC_ERR(0x17)
8530 +#define EC_VAL_VC_TEARDOWN_NOT_READY EC_ERR(0x18)
8531 +#define EC_VAL_INVALID_VC EC_ERR(0x19)
8532 +#define EC_VAL_INVALID_LC EC_ERR(0x20)
8533 +#define EC_VAL_INVALID_VDMA_CH EC_ERR(0x21)
8534 +#define EC_VAL_INVALID_CID EC_ERR(0x22)
8535 +#define EC_VAL_INVALID_UUI EC_ERR(0x23)
8536 +#define EC_VAL_INVALID_UUI_DISCARD EC_ERR(0x24)
8537 +#define EC_VAL_CH_ALREADY_OPEN EC_ERR(0x25)
8539 +#define EC_VAL_RCB_MALLOC_FAILED EC_ERR(0x26)
8540 +#define EC_VAL_RX_BUFFER_MALLOC_FAILED EC_ERR(0x27)
8541 +#define EC_VAL_OUT_OF_TCBS EC_ERR(0x28)
8542 +#define EC_VAL_NO_TCBS EC_ERR(0x29)
8543 +#define EC_VAL_NULL_RCB EC_ERR(0x30)|EC_CRITICAL
8544 +#define EC_VAL_SOP_ERROR EC_ERR(0x31)|EC_CRITICAL
8545 +#define EC_VAL_EOP_ERROR EC_ERR(0x32)|EC_CRITICAL
8546 +#define EC_VAL_NULL_TCB EC_ERR(0x33)|EC_CRITICAL
8547 +#define EC_VAL_CORRUPT_RCB_CHAIN EC_ERR(0x34)|EC_CRITICAL
8548 +#define EC_VAL_TCB_MALLOC_FAILED EC_ERR(0x35)
8550 +#define EC_VAL_DISABLE_POLLING_FAILED EC_ERR(0x36)
8551 +#define EC_VAL_KEY_NOT_FOUND EC_ERR(0x37)
8552 +#define EC_VAL_MALLOC_FAILED EC_ERR(0x38)
8553 +#define EC_VAL_RESET_BASE_NOT_FOUND EC_ERR(0x39)|EC_CRITICAL
8554 +#define EC_VAL_INVALID_STATE EC_ERR(0x40)
8555 +#define EC_VAL_NO_TXH_WORK_TO_DO EC_ERR(0x41)
8556 +#define EC_VAL_NO_TXL_WORK_TO_DO EC_ERR(0x42)
8557 +#define EC_VAL_NO_RX_WORK_TO_DO EC_ERR(0x43)
8558 +#define EC_VAL_NOT_LINKED EC_ERR(0x44)
8559 +#define EC_VAL_INTERRUPT_NOT_FOUND EC_ERR(0x45)
8560 +#define EC_VAL_OFFSET_NOT_FOUND EC_ERR(0x46)
8561 +#define EC_VAL_MODULE_ALREADY_CLOSED EC_ERR(0x47)
8562 +#define EC_VAL_MODULE_ALREADY_SHUTDOWN EC_ERR(0x48)
8563 +#define EC_VAL_ACTION_NOT_FOUND EC_ERR(0x49)
8564 +#define EC_VAL_RX_CH_ALREADY_SETUP EC_ERR(0x50)
8565 +#define EC_VAL_TX_CH_ALREADY_SETUP EC_ERR(0x51)
8566 +#define EC_VAL_RX_CH_ALREADY_OPEN EC_ERR(0x52)
8567 +#define EC_VAL_TX_CH_ALREADY_OPEN EC_ERR(0x53)
8568 +#define EC_VAL_CH_ALREADY_SETUP EC_ERR(0x54)
8569 +#define EC_VAL_RCB_NEEDS_BUFFER EC_ERR(0x55) /* +GSG 030410 */
8570 +#define EC_VAL_RCB_DROPPED EC_ERR(0x56) /* +GSG 030410 */
8571 +#define EC_VAL_INVALID_VALUE EC_ERR(0x57)
8574 +@defgroup shared_data Shared Data Structures
8576 +The data structures documented here are shared by all modules.
8580 + * @ingroup shared_data
8581 + * This is the fragment list structure. Each fragment list entry contains a
8582 + * length and a data buffer.
8586 + bit32u len; /**< Length of the fragment in bytes (lower 16 bits are valid). For SOP, upper 16 bits is the buffer offset. */
8587 + void *data; /**< Pointer to fragment data. */
8588 + void *OsInfo; /**< Pointer to OS defined data. */
8591 +#if defined (_CPHAL_CPMAC)
8592 +#define CB_PASSCRC_BIT (1<<26)
8594 +/* CPMAC CPHAL STATUS */
8595 +#define CPMAC_STATUS_LINK (1 << 0)
8596 +#define CPMAC_STATUS_LINK_DUPLEX (1 << 1) /* 0 - HD, 1 - FD */
8597 +#define CPMAC_STATUS_LINK_SPEED (1 << 2) /* 0 - 10, 1 - 100 */
8599 +/* ADAPTER CHECK Codes */
8601 +#define CPMAC_STATUS_ADAPTER_CHECK (1 << 7)
8602 +#define CPMAC_STATUS_HOST_ERR_DIRECTION (1 << 8)
8603 +#define CPMAC_STATUS_HOST_ERR_CODE (0xF << 9)
8604 +#define CPMAC_STATUS_HOST_ERR_CH (0x7 << 13)
8606 +#define _CPMDIO_DISABLE (1 << 0)
8607 +#define _CPMDIO_HD (1 << 1)
8608 +#define _CPMDIO_FD (1 << 2)
8609 +#define _CPMDIO_10 (1 << 3)
8610 +#define _CPMDIO_100 (1 << 4)
8611 +#define _CPMDIO_NEG_OFF (1 << 5)
8612 +#define _CPMDIO_LOOPBK (1 << 16)
8613 +#define _CPMDIO_NOPHY (1 << 20)
8617 + * @ingroup shared_data
8618 + * Channel specific configuration information. This structure should be
8619 + * populated by upper-layer software prior to calling @c ChannelSetup(). Any
8620 + * configuration item that can be changed on a per channel basis should
8621 + * be represented here. Each module may define this structure with additional
8622 + * module-specific members.
8626 + int Channel; /**< Channel number. */
8627 + int Direction; /**< DIRECTION_RX(1) or DIRECTION_TX(0). */
8628 + OS_SETUP *OsSetup; /**< OS defined information associated with this channel. */
8630 +#if defined(_CPHAL_AAL5) || defined (_CPHAL_CPSAR) || defined (_CPHAL_CPMAC)
8631 + int RxBufSize; /**< Size (in bytes) for each Rx buffer.*/
8632 + int RxBufferOffset; /**< Number of bytes to offset rx data from start of buffer (must be less than buffer size). */
8633 + int RxNumBuffers; /**< The number of Rx buffer descriptors to allocate for Ch. */
8634 + int RxServiceMax; /**< Maximum number of packets to service at one time. */
8636 + int TxNumBuffers; /**< The number of Tx buffer descriptors to allocate for Ch. */
8637 + int TxNumQueues; /**< Number of Tx queues for this channel (1-2). Choosing 2 enables a low priority SAR queue. */
8638 + int TxServiceMax; /**< Maximum number of packets to service at one time. */
8641 +#if defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
8642 + int CpcsUU; /**< The 2-byte CPCS UU and CPI information. */
8643 + int Gfc; /**< Generic Flow Control. */
8644 + int Clp; /**< Cell Loss Priority. */
8645 + int Pti; /**< Payload Type Indication. */
8648 +#if defined(_CPHAL_AAL2) || defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
8649 + int DaMask; /**< Specifies whether credit issuance is paused when Tx data not available. */
8650 + int Priority; /**< Priority bin this channel will be scheduled within. */
8651 + int PktType; /**< 0=AAL5,1=Null AAL,2=OAM,3=Transparent,4=AAL2. */
8652 + int Vci; /**< Virtual Channel Identifier. */
8653 + int Vpi; /**< Virtual Path Identifier. */
8654 + int FwdUnkVc; /**< Enables forwarding of unknown VCI/VPI cells to host. 1=enable, 0=disable. */
8657 + int TxVc_CellRate; /**< Tx rate, set as clock ticks between transmissions (SCR for VBR, CBR for CBR). */
8658 + int TxVc_QosType; /**< 0=CBR,1=VBR,2=UBR,3=UBRmcr. */
8659 + int TxVc_Mbs; /**< Min Burst Size in cells.*/
8660 + int TxVc_Pcr; /**< Peak Cell Rate for VBR in clock ticks between transmissions. */
8662 + bit32 TxVc_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Tx Ch (must be big endian with 0 PTI). */
8663 + int TxVc_OamTc; /**< TC Path to transmit OAM cells for TX connection (0,1). */
8664 + int TxVc_VpOffset; /**< Offset to the OAM VP state table. */
8666 + int RxVc_OamCh; /**< Ch to terminate rx'd OAM cells to be forwarded to the host. */
8667 + int RxVc_OamToHost; /**< 0=do not pass, 1=pass. */
8668 + bit32 RxVc_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Rx conn (must be big endian with 0 PTI). */
8669 + int RxVc_OamTc; /**< TC Path to transmit OAM cells for RX connection (0,1). */
8670 + int RxVc_VpOffset; /**< Offset to the OAM VP state table. */
8672 + int TxVp_OamTc; /**< TC Path to transmit OAM cells for TX VP connection (0,1). */
8673 + bit32 TxVp_AtmHeader; /**< ATM Header placed on firmware gen'd VP OAM cells for this Tx VP conn (must be big endian with 0 VCI). */
8675 + int RxVp_OamCh; /**< Ch to terminate rx'd OAM cells to be forwarded to the host. */
8676 + int RxVp_OamToHost; /**< 0=do not pass, 1=pass. */
8677 + bit32 RxVp_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Rx VP conn (must be big endian with 0 VCI). */
8678 + int RxVp_OamTc; /**< TC Path to transmit OAM cells for RX VP connection (0,1). */
8679 + int RxVp_OamVcList; /**< Indicates all VC channels associated with this VP channel (one-hot encoded). */
8683 +#ifdef _CPHAL_VDMAVT
8684 + bit32u RemFifoAddr; /* Mirror mode only. */
8694 + * This structure contains each statistic value gathered by the CPHAL.
8695 + * Applications may access statistics data by using the @c StatsGet() routine.
8698 +#if defined(_CPHAL_AAL2) || defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
8701 + bit32u CrcErrors[16];
8702 + bit32u LenErrors[16];
8703 + bit32u DmaLenErrors[16];
8704 + bit32u AbortErrors[16];
8705 + bit32u StarvErrors[16];
8706 + bit32u TxMisQCnt[16][2];
8707 + bit32u RxMisQCnt[16];
8708 + bit32u RxEOQCnt[16];
8709 + bit32u TxEOQCnt[16][2];
8710 + bit32u RxPacketsServiced[16];
8711 + bit32u TxPacketsServiced[16][2];
8712 + bit32u RxMaxServiced;
8713 + bit32u TxMaxServiced[16][2];
8720 + * VDMA Channel specific configuration information
8725 + int Ch; /**< Channel Number */
8726 + int RemoteEndian; /**< Endianness of remote VDMA-VT device */
8727 + int CpsSwap; /**< When 0, octet 0 in CPS pkt located in LS byte of 16-bit word sent to rem VDMA device. When 1, in MS byte. */
8732 + typedef void HAL_DEVICE;
8733 + typedef void HAL_PRIVATE;
8734 + typedef void HAL_RCB;
8735 + typedef void HAL_RECEIVEINFO;
8739 + * @ingroup shared_data
8740 + * The HAL_FUNCTIONS struct defines the function pointers used by upper layer
8741 + * software. The upper layer software receives these pointers through the
8742 + * call to xxxInitModule().
8746 + int (*ChannelSetup) (HAL_DEVICE *HalDev, CHANNEL_INFO *Channel, OS_SETUP *OsSetup);
8747 + int (*ChannelTeardown) (HAL_DEVICE *HalDev, int Channel, int Mode);
8748 + int (*Close) (HAL_DEVICE *HalDev, int Mode);
8749 + int (*Control) (HAL_DEVICE *HalDev, const char *Key, const char *Action, void *Value);
8750 + int (*Init) (HAL_DEVICE *HalDev);
8751 + int (*Open) (HAL_DEVICE *HalDev);
8752 + int (*PacketProcessEnd) (HAL_DEVICE *HalDev);
8753 + int (*Probe) (HAL_DEVICE *HalDev);
8754 + int (*RxReturn) (HAL_RECEIVEINFO *HalReceiveInfo, int StripFlag);
8755 + int (*Send) (HAL_DEVICE *HalDev, FRAGLIST *FragList, int FragCount, int PacketSize, OS_SENDINFO *OsSendInfo, bit32u Mode);
8756 + int (*Shutdown) (HAL_DEVICE *HalDev);
8757 + int (*Tick) (HAL_DEVICE *HalDev);
8760 + int (*Kick) (HAL_DEVICE *HalDev, int Queue);
8761 + void (*OamFuncConfig) (HAL_DEVICE *HalDev, unsigned int OamConfig);
8762 + void (*OamLoopbackConfig) (HAL_DEVICE *HalDev, unsigned int OamConfig, unsigned int *LLID, unsigned int CorrelationTag);
8763 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
8764 + STAT_INFO* (*StatsGetOld)(HAL_DEVICE *HalDev);
8769 + * @ingroup shared_data
8770 + * The OS_FUNCTIONS struct defines the function pointers for all upper layer
8771 + * functions accessible to the CPHAL. The upper layer software is responsible
8772 + * for providing the correct OS-specific implementations for the following
8773 + * functions. It is populated by calling InitModule() (done by the CPHAL in
8774 + * xxxInitModule().
8778 + int (*Control)(OS_DEVICE *OsDev, const char *Key, const char *Action, void *Value);
8779 + void (*CriticalOn)(void);
8780 + void (*CriticalOff)(void);
8781 + void (*DataCacheHitInvalidate)(void *MemPtr, int Size);
8782 + void (*DataCacheHitWriteback)(void *MemPtr, int Size);
8783 + int (*DeviceFindInfo)(int Inst, const char *DeviceName, void *DeviceInfo);
8784 + int (*DeviceFindParmUint)(void *DeviceInfo, const char *Parm, bit32u *Value);
8785 + int (*DeviceFindParmValue)(void *DeviceInfo, const char *Parm, void *Value);
8786 + void (*Free)(void *MemPtr);
8787 + void (*FreeRxBuffer)(OS_RECEIVEINFO *OsReceiveInfo, void *MemPtr);
8788 + void (*FreeDev)(void *MemPtr);
8789 + void (*FreeDmaXfer)(void *MemPtr);
8790 + void (*IsrRegister)(OS_DEVICE *OsDev, int (*halISR)(HAL_DEVICE*, int*), int InterruptBit);
8791 + void (*IsrUnRegister)(OS_DEVICE *OsDev, int InterruptBit);
8792 + void* (*Malloc)(bit32u size);
8793 + void* (*MallocDev)(bit32u Size);
8794 + void* (*MallocDmaXfer)(bit32u size, void *MemBase, bit32u MemRange);
8795 + void* (*MallocRxBuffer)(bit32u size, void *MemBase, bit32u MemRange,
8796 + OS_SETUP *OsSetup, HAL_RECEIVEINFO *HalReceiveInfo,
8797 + OS_RECEIVEINFO **OsReceiveInfo, OS_DEVICE *OsDev);
8798 + void* (*Memset)(void *Dest, int C, bit32u N);
8799 + int (*Printf)(const char *Format, ...);
8800 + int (*Receive)(OS_DEVICE *OsDev,FRAGLIST *FragList,bit32u FragCount,
8801 + bit32u PacketSize,HAL_RECEIVEINFO *HalReceiveInfo, bit32u Mode);
8802 + int (*SendComplete)(OS_SENDINFO *OsSendInfo);
8803 + int (*Sprintf)(char *S, const char *Format, ...);
8804 + int (*Strcmpi)(const char *Str1, const char *Str2);
8805 + unsigned int (*Strlen)(const char *S);
8806 + char* (*Strstr)(const char *S1, const char *S2);
8807 + unsigned long (*Strtoul)(const char *Str, char **Endptr, int Base);
8808 + void (*TeardownComplete)(OS_DEVICE *OsDev, int Ch, int Direction);
8811 +/************** MODULE SPECIFIC STUFF BELOW **************/
8813 +#ifdef _CPHAL_CPMAC
8816 +int halCpmacInitModule(HAL_DEVICE **HalDev, OS_DEVICE *OsDev, HAL_FUNCTIONS *HalFunc, int (*osBridgeInitModule)(OS_FUNCTIONS *), void* (*osMallocDev) (bit32u), int *Size, int inst);
8819 +int halCpmacInitModule(HAL_DEVICE **HalDev,
8821 + HAL_FUNCTIONS **HalFunc,
8822 + OS_FUNCTIONS *OsFunc,
8830 + * @ingroup shared_data
8831 + * The AAL5_FUNCTIONS struct defines the AAL5 function pointers used by upper layer
8832 + * software. The upper layer software receives these pointers through the
8833 + * call to cphalInitModule().
8838 + int (*ChannelSetup)(HAL_DEVICE *HalDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
8839 + int (*ChannelTeardown)(HAL_DEVICE *HalDev, int Ch, int Mode);
8840 + int (*Close)(HAL_DEVICE *HalDev, int Mode);
8841 + int (*Init)(HAL_DEVICE *HalDev);
8842 + int (*ModeChange)(HAL_DEVICE *HalDev, char *DeviceParms);
8843 + int (*Open)(HAL_DEVICE *HalDev);
8844 + int (*InfoGet)(HAL_DEVICE *HalDev, int Key, void *Value);
8845 + int (*Probe)(HAL_DEVICE *HalDev);
8846 + int (*RxReturn)(HAL_RECEIVEINFO *HalReceiveInfo, int StripFlag);
8847 + int (*Send)(HAL_DEVICE *HalDev,FRAGLIST *FragList,int FragCount,
8848 + int PacketSize,OS_SENDINFO *OsSendInfo,int Ch, int Queue,
8850 + int (*StatsClear)(HAL_DEVICE *HalDev);
8851 + STAT_INFO* (*StatsGet)(HAL_DEVICE *HalDev);
8852 + int (*Status)(HAL_DEVICE *HalDev);
8853 + void (*Tick)(HAL_DEVICE *HalDev);
8854 + int (*Kick)(HAL_DEVICE *HalDev, int Queue);
8855 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
8859 +int cpaal5InitModule(HAL_DEVICE **HalDev,
8861 + HAL_FUNCTIONS **HalFunc,
8862 + OS_FUNCTIONS *OsFunc,
8870 + * @ingroup shared_data
8871 + * The AAL2_FUNCTIONS struct defines the AAL2 function pointers used by upper layer
8872 + * software. The upper layer software receives these pointers through the
8873 + * call to cphalInitModule().
8877 + int (*ChannelSetup)(HAL_DEVICE *HalDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
8878 + int (*ChannelTeardown)(HAL_DEVICE *HalDev, int Ch, int Mode);
8879 + int (*Close)(HAL_DEVICE *HalDev, int Mode);
8880 + int (*Init)(HAL_DEVICE *HalDev);
8881 + int (*ModeChange)(HAL_DEVICE *HalDev, char *DeviceParms);
8882 + int (*Open)(HAL_DEVICE *HalDev);
8883 + int (*OptionsGet)(HAL_DEVICE *HalDev, char *Key, bit32u *Value);
8884 + int (*Probe)(HAL_DEVICE *HalDev);
8886 + int (*StatsClear)(HAL_DEVICE *HalDev);
8887 + STAT_INFO* (*StatsGet)(HAL_DEVICE *HalDev);
8888 + int (*Status)(HAL_DEVICE *HalDev);
8889 + void (*Tick)(HAL_DEVICE *HalDev);
8890 + int (*Aal2UuiMappingSetup)(HAL_DEVICE *HalDev, int VC, int UUI,
8891 + int VdmaCh, int UUIDiscard);
8892 + int (*Aal2RxMappingSetup)(HAL_DEVICE *HalDev, int VC, int CID,
8894 + int (*Aal2TxMappingSetup)(HAL_DEVICE *HalDev, int VC, int LC, int VdmaCh);
8895 + int (*Aal2VdmaChSetup)(HAL_DEVICE *HalDev, bit32u RemVdmaVtAddr,
8896 + VdmaChInfo *VdmaCh);
8897 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
8898 + int (*Aal2ModeChange)(HAL_DEVICE *HalDev, int Vc, int RxCrossMode,
8899 + int RxMultiMode, int TxMultiMode, int SchedMode,
8901 + void (*Aal2VdmaEnable)(HAL_DEVICE *HalDev, int Ch);
8902 + int (*Aal2VdmaDisable)(HAL_DEVICE *HalDev, int Ch);
8905 +int cpaal2InitModule(HAL_DEVICE **HalDev,
8907 + AAL2_FUNCTIONS **HalFunc,
8908 + OS_FUNCTIONS *OsFunc,
8914 +#ifdef _CPHAL_VDMAVT
8916 + * @ingroup shared_data
8917 + * The VDMA_FUNCTIONS struct defines the HAL function pointers used by upper layer
8918 + * software. The upper layer software receives these pointers through the
8919 + * call to InitModule().
8921 + * Note that this list is still under definition.
8925 + bit32 (*Init)( HAL_DEVICE *VdmaVtDev);
8926 + /* bit32 (*SetupTxFifo)(HAL_DEVICE *VdmaVtDev, bit32u LclRem,
8927 + bit32u Addr, bit32u Size, bit32u PollInt);
8928 + bit32 (*SetupRxFifo)(HAL_DEVICE *VdmaVtDev, bit32u LclRem,
8929 + bit32u Addr, bit32u Size, bit32u PollInt); */
8930 + bit32 (*Tx)(HAL_DEVICE *VdmaVtDev);
8931 + bit32 (*Rx)(HAL_DEVICE *VdmaVtDev);
8932 + bit32 (*SetRemoteChannel)(HAL_DEVICE *VdmaVtDev, bit32u RemAddr,
8934 + bit32 (*ClearRxInt)(HAL_DEVICE *VdmaVtDev);
8935 + bit32 (*ClearTxInt)(HAL_DEVICE *VdmaVtDev);
8936 + bit32 (*Open)(HAL_DEVICE *VdmaVtDev);
8937 + bit32 (*Close)(HAL_DEVICE *VdmaVtDev);
8938 + int (*Control) (HAL_DEVICE *HalDev, const char *Key, const char *Action, void *Value);
8939 + int (*ChannelSetup)(HAL_DEVICE *VdmaVtDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
8940 + int (*ChannelTeardown)(HAL_DEVICE *VdmaVtDev, int Ch, int Mode);
8941 + int (*Send)(HAL_DEVICE *VdmaVtDev,FRAGLIST *FragList,int FragCount,
8942 + int PacketSize,OS_SENDINFO *OsSendInfo,bit32u Mode);
8945 +int VdmaInitModule(HAL_DEVICE **VdmaVt,
8947 + VDMA_FUNCTIONS **VdmaVtFunc,
8948 + OS_FUNCTIONS *OsFunc,
8955 +extern int cphalInitModule(MODULE_TYPE ModuleType, HAL_DEVICE **HalDev, OS_DEVICE *OsDev, HAL_FUNCTIONS *HalFunc,
8956 + int (*osInitModule)(OS_FUNCTIONS *), void* (*osMallocDev)(bit32u),
8957 + int *Size, int Inst);
8962 +extern const char hcSarFrequency[];
8965 +#ifdef _CPHAL_CPMAC
8966 +/* following will be common, once 'utl' added */
8967 +extern const char hcClear[];
8968 +extern const char hcGet[];
8969 +extern const char hcSet[];
8970 +extern const char hcTick[];
8972 +extern const char hcCpuFrequency[];
8973 +extern const char hcCpmacFrequency[];
8974 +extern const char hcMdioBusFrequency[];
8975 +extern const char hcMdioClockFrequency[];
8976 +extern const char hcCpmacBase[];
8977 +extern const char hcPhyNum[];
8978 +extern const char hcSize[];
8979 +extern const char hcCpmacSize[];
8980 +extern const char hcPhyAccess[];
8983 +#endif /* end of _INC_ */
8984 diff -urN linux.old/drivers/atm/sangam_atm/dev_host_interface.h linux.dev/drivers/atm/sangam_atm/dev_host_interface.h
8985 --- linux.old/drivers/atm/sangam_atm/dev_host_interface.h 1970-01-01 01:00:00.000000000 +0100
8986 +++ linux.dev/drivers/atm/sangam_atm/dev_host_interface.h 2005-07-10 08:02:01.432113184 +0200
8988 +#ifndef __DEV_HOST_INTERFACE_H__
8989 +#define __DEV_HOST_INTERFACE_H__ 1
8991 +/*******************************************************************************
8992 +* FILE PURPOSE: Public header file for the Host-to-DSP interface
8993 +********************************************************************************
8995 +* TEXAS INSTRUMENTS PROPRIETARTY INFORMATION
8997 +* (C) Copyright Texas Instruments Inc. 2002. All rights reserved.
8999 +* Property of Texas Instruments Incorporated
9001 +* Restricted Rights - Use, duplication, or disclosure is subject to
9002 +* restrictions set forth in TI's program license agreement and
9003 +* associated documentation
9006 +* FILE NAME: dev_host_interface.h
9009 +* This header file defines the variables and parameters used between the
9010 +* host processor and the DSP. This file is included in both the DSP
9011 +* software and the host software.
9013 +* RULES FOR MODIFICATION AND USE OF THIS FILE:
9015 +* --The main pointer to the struct of pointers will always be at the same fixed
9016 +* location (0x80000000).
9018 +* --Each pointer element in the struct of pointers (indicated by the main pointer)
9019 +* will always point to a struct only.
9021 +* --Any new structures added to the host interface in subsequent versions must
9022 +* each have a corresponding new pointer element added to the END of the struct
9023 +* of pointers. Other than this, there will never be any moving or rearranging
9024 +* of the pointer elements in the struct of pointers.
9026 +* --Any new elements added to existing structures will be added at the END of the
9027 +* structure. Other than this, there will never be any moving or rearranging
9028 +* of structure elements.
9030 +* --A new structure will never be added as a new element in an old structure.
9031 +* New structures must be added separately with a new entry in the struct of
9032 +* pointers, as noted above.
9034 +* --Also, the sizes of existing arrays within old structures will never be changed.
9036 +* --The modem code in the DSP will never reference the struct of pointers in order
9037 +* to avoid aliasing issues in the DSP code. The modem code will only use the
9038 +* specific structures directly.
9040 +* --The host processor never accesses the DSP side of the ATM-TC hardware directly.
9041 +* The DSP interfaces directly to the ATM-TC hardware and relays information to
9042 +* the host processor through the host interface.
9044 +* --The host processor can track the modem's transition through important states
9045 +* by accessing the Modem State Bit Field in the host interface. Each bit in
9046 +* the bit field represents an important state to track in the modem. As the
9047 +* modem transitions through each important state, the corresponding bit will
9048 +* change from a zero to a one. Each bit in the bit field will only be reset to
9049 +* zero if the modem retrains. If new states need to be tracked and are added
9050 +* in subsequent versions of the host interface, a corresponding bit will be
9051 +* added at the END of the bit field to ensure backwards compatibility. The
9052 +* Modem State Bit Field is reset if the modem retrains or falls out of Showtime.
9054 +* --An interrupt will be sent to the host processor when a change occurs in the
9055 +* Modem State Bit Field. There is an interrupt masking register which can mask
9056 +* specific interrupts corresponding to the bits of the Modem State Bit Field.
9057 +* This allows the host to keep an interrupt from being generated for those
9058 +* states that are masked.
9062 +* 11/20/02 J. Bergsagel Written from the previous host interface file
9063 +* 11/27/02 J. Bergsagel Added comments for mailbox control struct and
9064 +* fixed a couple items for overlay page stuff.
9065 +* Also, added temporary elements for SWTC code.
9066 +* 12/04/02 J. Bergsagel Added extra dummy byte to DEV_HOST_eocVarDef_t
9067 +* for proper word alignment.
9068 +* 12/12/02 J. Bergsagel Changed initial states in the modem state bit field
9069 +* and added more instructions for adding more states.
9070 +* 12/16/02 J. Bergsagel Changed name "hostVersion_p" to "hostIntfcVersion_p".
9071 +* Removed dspAturState from DEV_HOST_modemStateBitField_t.
9072 +* Reorganized several struct elements to clean up the
9074 +* 12/27/02 Sameer V Added missing channel 0 statistics for TC. Added
9075 +* ocd error information.
9076 +* 12/27/02 Sameer V Added overlayState to OlayDP_Parms to indicate whether
9077 +* overlays are being executed in current state.
9078 +* 01/06/03 J. Bergsagel Added maxAllowedMargin and minRequiredMargin to
9080 +* Renamed TC chan 1 items to be chan 0 items to start out.
9081 +* 01/17/03 Sameer V Moved delineationState to atmStats structure.
9082 +* 01/21/03 Barnett Implemented Ax7 UNIT-MODULE modular software framework.
9083 +* 01/22/03 J. Bergsagel Added warning comments for certain struct typedefs.
9084 +* 01/23/03 C. Perez-N. Removed old AX5-only diags. command/response entries in the
9085 +* HOST and DSP ennumerations, and added the AX7 new ones
9086 +* Added pointer entries in the DEV_HOST_dspOamSharedInterface_t
9087 +* structure pointing to the analog diags. input/output/options
9089 +* 01/29/03 Sameer V Removed TC_IDLE in enum for delineation state. Hardware
9090 +* only reports TC_HUNT, TC_PRESYNC and TC_SYNC.
9091 +* 03/07/03 Sameer/Jonathan Put SWTC token around structs and elements only used by SWTC
9092 +* 03/12/03 Mannering Add CO profile data structures
9093 +* 03/18/03 J. Bergsagel Removed the obsolete DSP_CHECK_TC response message.
9094 +* 03/24/03 J. Bergsagel Added DEV_HOST_hostInterruptMask_t for masking DSP interrupt sources
9095 +* 03/28/03 C. Perez-N Changed the C-style comments and made them C++ sytle instead.
9096 +* Replaced the occurrences of "SINT32 *" pointer declarations with
9098 +* 03/28/03 Mannering Update CO profile data structures
9099 +* 04/04/03 S. Yim Add host I/F hooks for switchable hybrid and RJ11
9100 +* inner/outer pair selection
9101 +* 04/11/03 J. Bergsagel Changed modem state bit field struct types to enums instead and used
9102 +* a single integer variable for each "bitfield".
9103 +* Changed bit field for host interrupt masks to an integer value also.
9104 +* 04/14/03 J. Bergsagel Changed name of table pointer "meanSquareTblDstrm_p" to "marginTblDstrm_p".
9105 +* 04/03/03 Umesh Iyer CMsg1 and RMsg1 use the same storage as CMSGPCB and RMSGPCB.
9106 +* The string lengths for these have been adjusted to hold the longest
9107 +* message in each case. The PCB messages from ADSL2 are longer.
9108 +* 04/21/03 Sameeer V Added new host mailbox message for shutting down the DSLSS peripherals.
9109 +* 04/23/03 J. Bergsagel Fixed comments for overlay mailbox messages and for losErrors.
9110 +* 04/28/03 Mannering Added skip phase op flag to CO profile data structure
9111 +* 05/05/03 Mannering Review Comments - Removed "#if CO_PROFILE" from around structure
9112 +* definitions and define the number of profiles (DEV_HOST_LIST_ENTRIES)
9113 +* 05/13/03 J. Bergsagel Added new elements to DEV_HOST_phyPerf_t for host control of hybrid.
9114 +* 05/15/03 J. Bergsagel Added "farEndLosErrors" and "farEndRdiErrors" to DEV_HOST_modemStatsDef_t.
9115 +* 05/16/03 Mannering Updated CO profile structure to support updated bit allocation and
9117 +* 05/20/03 Sameer V Added DSP message to inicate DYING GASP.
9118 +* 05/22/03 J. Bergsagel Added a new struct typedef "DEV_HOST_hostInterruptSource_t".
9119 +* Added "atucGhsRevisionNum" to "DEV_HOST_dspWrNegoParaDef_t".
9120 +* Moved the following struct typedef's here to the public host interface:
9121 +* DEV_HOST_dspBitSwapDef_t
9122 +* DEV_HOST_atmDsBert_t
9123 +* 05/28/03 A. Redfern Changed pointer type and location for margin reporting.
9124 +* 05/28/03 Mannering Moved CO profile defines to dev_host_interface_pvt.h
9125 +* 05/28/03 J. Bergsagel Moved subStateIndex and STM BERT controls into new struct "DEV_HOST_modemEnvPublic_t"
9126 +* 05/29/03 J. Bergsagel Added elements to "DEV_HOST_modemEnvPublic_t" for host control of DSLSS LED's.
9127 +* 06/10/03 Umesh Iyer Modified trainMode check to be compliant with the new host i/f mods.
9128 +* 06/05/03 J. Bergsagel Added enum that will eventually replace the bitfield: DEV_HOST_diagAnlgOptionsVar_t.
9129 +* Added new element "currentHybridNumUsed" in the DEV_HOST_phyPerf_t typedef
9130 +* Added new host control flags for LPR signal detection on GPIO[0].
9131 +* 06/06/03 A. Redfern Removed fine gain scale from the CO profile and added max downstream power cutback.
9132 +* Changed "test1" in CO profile struct to "phyEcDelayAdjustment".
9133 +* 06/26/03 J. Bergsagel Added genericStructure typedef and two pointer elements of this type in the big table.
9134 +* 07/03/03 Jack Huang Renamed test2 to bSwapThresholdUpdate
9135 +* 07/07/03 Mallesh Changed phySigTxPowerCutback_f flag to a variable phySigTxGainReductionAt0kft which indicates the
9136 +* amount of gain reduction in linear scale.
9137 +* 07/15/03 Sameer V Changed DEV_HOST_diagAnlgOptionsVar_t to be an enum instead of a bit field. Host code
9138 +* does not support setting bit fields.
9139 +* 07/22/03 Jack Huang Added bitswap control flag in host i/f for API calls
9140 +* 08/06/03 Sameer V Added missingToneDs_p to the DEV_HOST_oamWrNegoParaDef_t to enable host to switch off
9141 +* DS tones on specified bins
9142 +* 08/21/03 Jack Huang Added pcbEnabled flag in the DEV_HOST_modemEnvPublic_t structure
9143 +* Added g.hs buffer definitions to DEV_HOST_dspOamSharedInterface_t
9144 +* Added DEV_HOST_consBufDef_t to the DEV_HOST_dspOamSharedInterface_t structure
9145 +* 08/26/03 J. Bergsagel Fixed name of "missingToneDs_p" to be "missingToneDsAddr" instead (since it is
9146 +* not really used as a pointer).
9147 +* 09/11/03 Mallesh Added a flag "usPilotInT1413ModeInMedley" to determine the need to send Upstream Pilot
9148 +* in medley in T1.413 mode.
9149 +* 09/12/03 J. Bergsagel Changed "test3" to "phyBitaFastPathExcessFineGainBump" in CO profile struct.
9150 +* Changed "test4" to "phyBitaSkipGapAdjustment" in CO profile struct.
9151 +* 09/23/03 J. Bergsagel Changed "T1413vendorRevisionNumber" to "vendorRevisionNumber" in DEV_HOST_msg_t.
9152 +* Added ADSL2 and ADSL2 diag. states to the modem state bit field.
9153 +* 10/01/03 J. Bergsagel Changed define of "MULTI_MODE" to be 255 to indicate that all possible bits
9154 +* in the 8-bit bit field are turned on for any current and future training modes.
9155 +* 10/09/03 M. Turkboylari Added DSP_TRAINING_MSGS and adsl2DeltMsgs_p, which is a pointer to a pointer,
9156 +* in order to pass the ADSL2 training and DELT messages to the host side. This is for ACT.
9157 +* 10/20/03 Mallesh Added a GHS state enumerator for cleardown
9158 +* 10/20/03 Xiaohui Li Add definition for READSL2_MODE and READSL2_DELT
9159 +* 11/07/03 J. Bergsagel Removed all code for when SWTC==1, which therefore allows removal of include of
9160 +* "env_def_defines.h". We shouldn't have any compile tokens used in this file.
9161 +* (the SWTC token is always off in any Ax7 code).
9162 +* 11/14/03 J. Bergsagel Also removed READSL2_ENABLE token (no more compile tokens to be used in this .h file).
9163 +* 12/12/03 Sameer/Ram Added DEV_HOST_EOCAOC_INTERRUPT_MASK to enable host to disable response code for AOC/EOC
9165 +* 12/09/03 Jack Huang Changed G.hs txbuf size from 60 to 64 to fit the max segment size
9166 +* 12/15/03 Mallesh Changed vendor ID type defenition from SINT16 to UINT16
9167 +* 12/23/03 Sameer V Added ability to turn off constellation display reporting to host using oamFeature bit field.
9168 +* 12/24/03 Sameer V Changed comment for Constellation Display Current Address to Host Write instead of DSP Write.
9169 +* 12/26/03 Sameer/Ram Added DEV_HOST_GHSMSG_INTERRUPT_MASK to enable host to disable response code for GHS Messages
9170 +* (C) Copyright Texas Instruments Inc. 2002. All rights reserved.
9171 +*******************************************************************************/
9173 +#include "dev_host_verdef.h"
9175 +// ---------------------------------------------------------------------------------
9176 +// Address of the pointer to the DEV_HOST_dspOamSharedInterface_s struct of pointers
9177 +// This is where it all starts.
9178 +// ---------------------------------------------------------------------------------
9179 +#define DEV_HOST_DSP_OAM_POINTER_LOCATION 0x80000000
9181 +// The define "MAX_NUM_UPBINS" is used in "DEV_HOST_diagAnlgInputVar_t" below.
9182 +// This value can never be changed (for host intf. backwards compatibility)
9183 +#define MAX_NUM_UPBINS 64
9185 +// -----------------------------------------------
9186 +// Begin common enumerations between DSP and host.
9187 +// -----------------------------------------------
9189 +// These Host-to-DSP commands are organized into two groups:
9190 +// immediate state change commands and status affecting commands.
9191 +// Do not add or remove commands except at the bottom since the DSP assumes this sequence.
9195 + HOST_ACTREQ, // Send R-ACKREQ and monitor for C-ACKx
9196 + HOST_QUIET, // Sit quietly doing nothing for about 60 seconds, DEFAULT STATE; R_IDLE
9197 + HOST_XMITBITSWAP, // Perform upstream bitswap - FOR INTERNAL USE ONLY
9198 + HOST_RCVBITSWAP, // Perform downstream bitswap - FOR INTERNAL USE ONLY
9199 + HOST_RTDLPKT, // Send a remote download packet - FOR INTERNAL USE ONLY
9200 + HOST_CHANGELED, // Read the LED settings and change accordingly
9201 + HOST_IDLE, // Sit quiet
9202 + HOST_REVERBTEST, // Generate REVERB for manufacturing test
9203 + HOST_CAGCTEST, // Set coarse receive gain for manufacturing test
9204 + HOST_DGASP, // send Dying Gasp messages through EOC channel
9205 + HOST_GHSREQ, // G.hs - FOR INTERNAL USE ONLY
9206 + HOST_GHSMSG, // G.hs - FOR INTERNAL USE ONLY
9207 + HOST_GHS_SENDGALF, // G.hs - FOR INTERNAL USE ONLY
9208 + HOST_GHSEXIT, // G.hs - FOR INTERNAL USE ONLY
9209 + HOST_GHSMSG1, // G.hs - FOR INTERNAL USE ONLY
9210 + HOST_HYBRID, // Enable/Disable automatic hybrid switch
9211 + HOST_RJ11SELECT, // RJ11 inner/outer pair select
9212 + HOST_DIGITAL_MEM, // Digital Diags: run external memory tests
9213 + HOST_TXREVERB, // AFE Diags: TX path Reverb
9214 + HOST_TXMEDLEY, // AFE Diags: TX path Medley
9215 + HOST_RXNOISEPOWER, // AFE Diags: RX noise power
9216 + HOST_ECPOWER, // AFE Diags: RX eco power
9217 + HOST_ALL_ADIAG, // AFE Diags: all major analog diagnostic modes. Host is responsible to initiate each diagnostic sessions
9218 + HOST_USER_ADIAG, // AFE Diags: Host fills in analog diagnostic input data structure as specified and requests DSP to perform measurements as specified
9219 + HOST_QUIT_ADIAG, // AFE Diags: Host requests DSP to quit current diagnostic session. This is used for stopping the transmit REVERB/MEDLEY
9220 + HOST_NO_CMD, // All others - G.hs - FOR INTERNAL USE ONLY
9221 + HOST_DSLSS_SHUTDOWN, // Host initiated DSLSS shutdown message
9222 + HOST_SET_GENERIC, // Set generic CO profile
9223 + HOST_UNDO_GENERIC, // Set profile previous to Generic
9224 + HOST_GHS_CLEARDOWN // G.hs - FOR INTERNAL USE ONLY to start cleardown
9227 +// These DSP-to-Host responses are organized into two groups:
9228 +// responses to commands and requests for OAM services.
9232 + DSP_IDLE, // R_IDLE state entered
9233 + DSP_ACTMON, // R_ACTMON state entered
9234 + DSP_TRAIN, // R_TRAIN state entered
9235 + DSP_ACTIVE, // R_ACTIVE state entered
9236 + DSP_XMITBITSWAP, // Upstream bitswap complete - FOR INTERNAL USE ONLY
9237 + DSP_RCVBITSWAP, // Downstream bitswap complete - FOR INTERNAL USE ONLY
9238 + DSP_RTDL, // R_RTDL state entered - FOR INTERNAL USE ONLY
9239 + DSP_RRTDLPKT, // RTDL packet received - FOR INTERNAL USE ONLY
9240 + DSP_XRTDLPKT, // RTDL packet transmitted - FOR INTERNAL USE ONLY
9241 + DSP_ERROR, // Command rejected, wrong state for this command
9242 + DSP_REVERBTEST, // Manufacturing REVERB test mode entered
9243 + DSP_CAGCTEST, // Manufacturing receive gain test done
9244 + DSP_OVERLAY_START, // Notify host that page overlay has started - overlay number indicated by "tag"
9245 + DSP_OVERLAY_END, // Notify host that page overlay has ended - overlay number indicated by "tag"
9246 + DSP_CRATES1, // CRATES1 message is valid and should be copied to host memory now
9247 + DSP_SNR, // SNR calculations are ready and should be copied to host memory now
9248 + DSP_GHSMSG, // G.hs - FOR INTERNAL USE ONLY
9249 + DSP_RCVBITSWAP_TIMEOUT, // Acknowledge Message was not received within ~500 msec (26 Superframes).
9250 + DSP_ATM_TC_SYNC, // Indicates true TC sync on both the upstream and downstream. Phy layer ready for data xfer.
9251 + DSP_ATM_NO_TC_SYNC, // Indicates loss of sync on phy layer on either US or DS.
9252 + DSP_HYBRID, // DSP completed hybrid switch
9253 + DSP_RJ11SELECT, // DSP completed RJ11 inner/outer pair select
9254 + DSP_INVALID_CMD, // Manufacturing (Digital and AFE) diags: CMD received not recognized
9255 + DSP_TEST_PASSED, // Manufacturing diags: test passed
9256 + DSP_TEST_FAILED, // Manufacturing diags: test failed
9257 + DSP_TXREVERB, // Manufacturing AFE diags: Response to HOST_TXREVERB
9258 + DSP_TXMEDLEY, // Manufacturing AFE diags: Response to HOST_TXMEDLEY
9259 + DSP_RXNOISEPOWER, // Manufacturing AFE diags: Response to HOST_RXNOISEPOWER
9260 + DSP_ECPOWER, // Manufacturing AFE diags: Response to HOST_ECPOWER
9261 + DSP_ALL_ADIAG, // Manufacturing AFE diags: Response to HOST_ALL_ADIAG
9262 + DSP_USER_ADIAG, // Manufacturing AFE diags: Response to HOST_USER_ADIAG
9263 + DSP_QUIT_ADIAG, // Manufacturing AFE diags: Response to HOST_QUIT_ADIAG
9264 + DSP_DGASP, // DSP Message to indicate dying gasp
9265 + DSP_EOC, // DSP Message to indicate that DSP sent an EOC message to CO
9266 + DSP_TRAINING_MSGS // DSP Message to indicate that host has to copy the training message specified in the tag field.
9269 +// Define different ADSL training modes.
9270 +//Defintions as per new host interface.
9272 +#define GDMT_MODE 2
9273 +#define GLITE_MODE 4
9274 +#define ADSL2_MODE 8
9275 +#define ADSL2_DELT (ADSL2_MODE+1)
9276 +#define ADSL2PLUS_MODE 16
9277 +#define ADSL2PLUS_DELT (ADSL2PLUS_MODE+1)
9278 +#define READSL2_MODE 32
9279 +#define READSL2_DELT (READSL2_MODE+1)
9280 +#define T1413_MODE 128
9281 +#define MULTI_MODE 255 // all possible bits are set in the bit field
9283 +// Define the reason for dropping the connection
9287 + REASON_LOS = 0x01,
9288 + REASON_DYING_GASP = 0x02,
9289 + REASON_USCRCERR = 0x04,
9290 + REASON_MARGIN_DROP = 0x08
9294 +// ----------------------------------------------------
9295 +// Begin modem state bit field definitions - DSP write.
9296 +// ----------------------------------------------------
9298 +// BitField1 for initial states and G.hs states.
9299 +// If more values need to be added, they will be added at the end (up to 32 total entries). However, if this causes
9300 +// the state transitions to tick off out of normal bit order, then the C code will have to be re-written
9301 +// that causes the proper values to be entered into the modem state bit fields.
9316 +} DEV_HOST_stateBitField1_t; // this enum should only have 32 bit entries in it. Add another enum if you need more.
9318 +// BitField2 for T1.413 states and for the rest of the modem states (so far)
9319 +// If more values need to be added, they will be added at the end (up to 32 total entries). However, if this causes
9320 +// the state transitions to tick off out of normal bit order, then the C code will have to be re-written
9321 +// that causes the proper values to be entered into the modem state bit fields.
9337 + RREVERB3 = 0x1000,
9341 + RMEDLEY = 0x10000,
9342 + RREVERB4 = 0x20000,
9343 + RSEGUE3 = 0x40000,
9344 + RMSGSRA = 0x80000,
9345 + RRATESRA = 0x100000,
9346 + RREVERBRA = 0x200000,
9347 + RSEGUERA = 0x400000,
9348 + RMSGS2 = 0x800000,
9349 + RRATES2 = 0x1000000,
9350 + RREVERB5 = 0x2000000,
9351 + RSEGUE4 = 0x4000000,
9353 + RREVERB6 = 0x10000000,
9354 + RSHOWTIME = 0x20000000
9355 +} DEV_HOST_stateBitField2_t; // this enum should only have 32 bit entries in it. Add another enum if you need more.
9357 +// BitField3 for ADSL2 states
9358 +// If more values need to be added, they will be added at the end (up to 32 total entries). However, if this causes
9359 +// the state transitions to tick off out of normal bit order, then the C code will have to be re-written
9360 +// that causes the proper values to be entered into the modem state bit fields.
9369 + G2LINEPROBE = 0x20,
9373 + G2RMSGFMT = 0x200,
9374 + G2RMSGPCB = 0x400,
9375 + G2REVERB1 = 0x800,
9376 + G2QUIET4 = 0x1000,
9377 + G2REVERB2 = 0x2000,
9378 + G2QUIET5 = 0x4000,
9379 + G2REVERB3 = 0x8000,
9381 + G2REVERB4 = 0x20000,
9382 + G2SEGUE1 = 0x40000,
9383 + G2REVERB5 = 0x80000,
9384 + G2SEGUE2 = 0x100000,
9385 + G2RMSG1 = 0x200000,
9386 + G2MEDLEY = 0x400000,
9387 + G2EXCHANGE = 0x800000,
9388 + G2RMSG2 = 0x1000000,
9389 + G2REVERB6 = 0x2000000,
9390 + G2SEGUE3 = 0x4000000,
9391 + G2RPARAMS = 0x8000000,
9392 + G2REVERB7 = 0x10000000,
9393 + G2SEGUE4 = 0x20000000
9394 +} DEV_HOST_stateBitField3_t; // this enum should only have 32 bit entries in it. Add another enum if you need more.
9396 +// BitField4 for ADSL2 diag. states
9397 +// If more values need to be added, they will be added at the end (up to 32 total entries). However, if this causes
9398 +// the state transitions to tick off out of normal bit order, then the C code will have to be re-written
9399 +// that causes the proper values to be entered into the modem state bit fields.
9409 + GDQUIET1LD = 0x40,
9410 + GDQUIET2LD = 0x80,
9413 + GDQUIETLAST = 0x400
9414 +} DEV_HOST_stateBitField4_t; // this enum should only have 32 bit entries in it. Add another enum if you need more.
9416 +// This struct collects all of the bitfield types listed above for the modem state bit field(s)
9419 + DEV_HOST_stateBitField1_t bitField1; // this is the first modem state bit field (mostly init. and G.hs)
9420 + DEV_HOST_stateBitField2_t bitField2; // this is the second modem state bit field (T1.413 and G.dmt)
9421 + DEV_HOST_stateBitField3_t bitField3; // this is the third modem state bit field (ADSL2)
9422 + DEV_HOST_stateBitField4_t bitField4; // this is the fourth modem state bit field (ADSL2 diag.)
9423 +} DEV_HOST_modemStateBitField_t;
9426 +// -----------------------------------------------
9427 +// Begin NegoPara message definitions - DSP write.
9428 +// -----------------------------------------------
9432 + UINT8 trainMode; // Train mode selected. See training modes defined above.
9433 + UINT8 bDummy1; // dummy byte for explicit 32-bit alignment
9434 + UINT16 lineLength; // Contains loop length estimate. Accuracy w/i 500 ft. LSbit = 1 for straight loop, = 0 for bridge tap
9435 + UINT32 atucVendorId; // Pass the vendor id of the CO to the host
9436 + UINT8 cMsgs1[8]; // CMsgs1 and CMSGPCB
9437 + UINT16 adsl2DSRate; //
9440 + UINT8 rRates1[4][11]; //
9441 + UINT8 cMsgs2[4]; //
9442 + UINT8 cRates1[4][30]; //
9443 + UINT8 rMsgs2[4]; //
9444 + UINT16 adsl2USRate; //
9445 + UINT8 atucGhsRevisionNum; // Pass the G.hs Revision number of the CO to the host
9446 + UINT8 reserved1; //
9447 + PUINT8 *adsl2DeltMsgs_p; // This pointer to a pointer passes the address of the globalvar.pString, which is also
9448 + // a pointer list of pointers. It will be used to pass all the new ADSL2 DELT messages to
9449 + // host side. This is for ACT.
9450 +} DEV_HOST_dspWrNegoParaDef_t;
9453 +// ----------------------------------------------------
9454 +// Begin OAM NegoPara message definitions - Host write.
9455 +// ----------------------------------------------------
9457 +// OAM Feature bit fields.
9459 +// Bit 0 - Enable auto retrain of modem
9460 +// Bit 1 - Detect and report TC sync to host
9461 +// Bit 2-31 - Reserved
9463 +#define DEV_HOST_AUTORETRAIN_ON 0x00000001
9464 +#define DEV_HOST_TC_SYNC_DETECT_ON 0x00000002
9466 +#define DEV_HOST_AUTORETRAIN_MASK 0x00000001
9467 +#define DEV_HOST_TC_SYNC_DETECT_MASK 0x00000002
9468 +#define DEV_HOST_EOCAOC_INTERRUPT_MASK 0x00000004
9469 +#define DEV_HOST_CONS_DISP_DISABLE_MASK 0x00000008
9470 +#define DEV_HOST_GHSMSG_INTERRUPT_MASK 0x00000010
9474 + UINT8 stdMode; // Desired train mode. See training modes defined above.
9475 + UINT8 ghsSequence; // Selected G.hs session as shown in Appendix 1
9476 + UINT8 usPilotFlag; // Value of 1 indicates transmit an upstream pilot on bin 16
9477 + UINT8 bDummy1; // dummy byte for 32-bit alignment
9478 + UINT8 rMsgs1[38]; // RMSG-1(6) and RMSG_PCB (38)
9479 + UINT8 bDummy2[2]; // dummy bytes for 32-bit alignment
9480 + UINT32 oamFeature; // 32 bit wide bit field to set OAM-specific features.
9481 + SINT8 marginThreshold; // Threshold for margin reporting
9482 + UINT8 hostFixAgc; // flag to force datapump to bypass AGC training and use the following values
9483 + UINT8 hostFixEqualizer; // forced analog equalizer value used during AGC training when hostfix_agc is on
9484 + UINT8 hostFixPga1; // forced pga1 value used during AGC training when hostFixAgc is on
9485 + UINT8 hostFixPga2; // forced pga2 value used during AGC training when hostFixAgc is on
9486 + UINT8 hostFixPga3; // forced pga3 value used during AGC training when hostFixAgc is on
9487 + UINT8 marginMonitorShwtme; // margin monitoring flag (during showtime)
9488 + UINT8 marginMonitorTrning; // margin monitoring flag (during training)
9489 + UINT8 disableLosAlarm; // flag to disable training based on los
9490 + UINT8 usCrcRetrain; // flag to disable retrain due to excessive USCRC
9491 + UINT8 t1413VendorId[2]; // Vendor ID used for T1.413 trainings
9492 + UINT8 gdmtVendorId[8]; // Vendor ID used for G.dmt trainings (ITU VendorID)
9493 + UINT8 missingTones[64]; // 64 element array to define missing tones for TX_MEDLEY and TX REVERB tests
9494 + UINT32 missingToneDsAddr; // Address given to DSP for tones to be switched off in DS direction
9495 + UINT8 dsToneTurnoff_f; // This flag controls the DS tone turn off logic
9496 + UINT8 reserved1; // Dummy bytes
9497 + UINT8 reserved2; // Dummy bytes
9498 + UINT8 reserved3; // Dummy bytes
9499 +} DEV_HOST_oamWrNegoParaDef_t;
9502 +// ----------------------------------------
9503 +// Begin Rate-adaptive message definitions.
9504 +// ----------------------------------------
9506 +// The four values below can never be changed (for host intf. backwards compatibility)
9507 +#define DEV_HOST_RMSGSRA_LENGTH 10
9508 +#define DEV_HOST_RRATESRA_LENGTH 1
9509 +#define DEV_HOST_CRATESRA_LENGTH 120
9510 +#define DEV_HOST_CMSGSRA_LENGTH 6
9514 + UINT8 rRatesRaString[DEV_HOST_RRATESRA_LENGTH+3];
9515 + UINT8 rMsgsRaString[DEV_HOST_RMSGSRA_LENGTH+2];
9516 + UINT8 cMsgsRaString[DEV_HOST_CMSGSRA_LENGTH+2];
9517 +} DEV_HOST_raMsgsDef_t;
9520 +// ----------------------------------------------
9521 +// Begin superframe cnts definitions - DSP write.
9522 +// ----------------------------------------------
9524 +#define DEV_HOST_FRAMES_PER_SUPER 68
9525 +#define DEV_HOST_SUPERFRAMECNTDSTRM 0
9526 +#define DEV_HOST_SUPERFRAMECNTUSTRM 4
9528 +// Although only the least significant 8 bits should be used as an
9529 +// unsigned char for computing the bitswap superframe number, a
9530 +// full 32 bit counter is provided here in order to have an
9531 +// accurate indicator of the length of time that the modem has
9532 +// been connected. This counter will overflow after 2.35 years
9533 +// of connect time.
9537 + UINT32 wSuperFrameCntDstrm;
9538 + UINT32 wSuperFrameCntUstrm;
9539 +} DEV_HOST_dspWrSuperFrameCntDef_t;
9542 +// --------------------------------
9543 +// Begin ATUR/ATUC msg definitions.
9544 +// --------------------------------
9546 +// Grouping used by the DSP to simplify parameter passing.
9547 +// All of these are written by the DSP.
9551 + UINT16 vendorId; // TI's vendor ID = 0x0004; Amati's vendor ID = 0x0006
9552 + UINT8 versionNum; // T1.413 issue number
9553 + UINT8 rateAdapt; // 0 = fix rate (Default); 1= adaptive rate
9554 + UINT8 trellis; // 0 = disable trellis(default); 1 = enable trellis
9555 + UINT8 echoCancelling; // 0 = disable echo cancelling; 1 = enable echo cancelling(default)
9556 + UINT8 maxBits; // value range: 0-15; default = 15
9558 + UINT8 actualPsd; //
9559 + UINT8 maxIntlvDepth; // 0, 1, 2, or 3 for 64, 128, 256, or 512 max depth
9560 + UINT8 framingMode; // 0 for asynchronous, 1 for synchronous full overhead
9561 + // 2 for reduced overhead, 3 for merged reduced overhead DSP write.
9562 + UINT8 maxFrameMode; // maximum framing mode desired. Nor 0 or 3.
9563 + SINT16 targetMargin; //
9564 + SINT16 maxAllowedMargin; //
9565 + SINT16 minRequiredMargin; //
9566 + SINT16 maxTotBits; //
9567 + UINT8 grossGain; //
9568 + UINT8 ntr; // Enable/disable NTR support
9569 + SINT16 loopAttn; // Loop Attenuation
9570 + UINT8 vendorRevisionNumber; // Reported Vendor Revision Number
9571 + UINT8 reserved1; // for 32-bit alignment
9572 + UINT8 reserved2; // for 32-bit alignment
9573 + UINT8 reserved3; // for 32-bit alignment
9577 +// --------------------------------------
9578 +// Begin bits and gains table definitions
9579 +// --------------------------------------
9583 + PUINT8 aturBng_p; // pointer to ATU-R bits and gains table
9584 + PUINT8 atucBng_p; // pointer to ATU-C bits and gains table
9585 + PUINT8 bitAllocTblDstrm_p; // pointer to Downstream Bit Allocation table
9586 + PUINT8 bitAllocTblUstrm_p; // pointer to Upstream Bit Allocation table
9587 + PSINT8 marginTblDstrm_p; // pointer to Downstream Margin table
9588 +} DEV_HOST_dspWrSharedTables_t;
9591 +// ----------------------------------------
9592 +// Begin datapump code overlay definitions.
9593 +// ----------------------------------------
9595 +#define DEV_HOST_PAGE_NUM 4 // number of overlay pages
9597 +// Never access a struct of this typedef directly. Always go through the DEV_HOST_olayDpDef_t struct
9600 + UINT32 overlayHostAddr; // source address in host memory
9601 + UINT32 overlayXferCount; // number of 32bit words to be transfered
9602 + UINT32 overlayDspAddr; // destination address in DSP's PMEM
9603 +} DEV_HOST_olayDpPageDef_t;
9608 + UINT32 overlayStatus; // Status of current overlay to DSP PMEM
9609 + UINT32 overlayNumber; // DSP PMEM overlay page number
9610 + UINT32 overlayState; // Indicates whether current state is an overlay state
9611 + DEV_HOST_olayDpPageDef_t *olayDpPage_p[DEV_HOST_PAGE_NUM]; // Def's for the Pages
9612 +} DEV_HOST_olayDpDef_t;
9615 +// -------------------------
9616 +// Begin ATM-TC definitions.
9617 +// -------------------------
9625 +} DEV_HOST_cellDelinState_t;
9628 +// --------------------------------------------
9629 +// Begin datapump error/statistics definitions.
9630 +// --------------------------------------------
9632 +// Never access a struct of this typedef directly. Always go through the DEV_HOST_modemStatsDef_t struct.
9635 + UINT32 crcErrors; // Num of CRC errored ADSL frames
9636 + UINT32 fecErrors; // Num of FEC errored (corrected) ADSL frames
9637 + UINT32 ocdErrors; // Out of Cell Delineation
9638 + UINT32 ncdError; // No Cell Delineation
9639 + UINT32 lcdErrors; // Loss of Cell Delineation (within the same connection)
9640 + UINT32 hecErrors; // Num of HEC errored ADSL frames
9641 +} DEV_HOST_errorStats_t;
9646 + DEV_HOST_errorStats_t *usErrorStatsIntlv_p; // us error stats - interleave path
9647 + DEV_HOST_errorStats_t *dsErrorStatsIntlv_p; // ds error stats - interleave path
9648 + DEV_HOST_errorStats_t *usErrorStatsFast_p; // us error stats - fast path
9649 + DEV_HOST_errorStats_t *dsErrorStatsFast_p; // ds error stats - fast path
9650 + UINT32 losErrors; // Num of ADSL frames where loss-of-signal
9651 + UINT32 sefErrors; // Num of severly errored ADSL frames - LOS > MAXBADSYNC ADSL frames
9652 + UINT32 farEndLosErrors; // Number of reported LOS defects by the CO.
9653 + UINT32 farEndRdiErrors; // Number of reported RDI defects by the CO.
9654 +} DEV_HOST_modemStatsDef_t;
9656 +// Never access a struct of this typedef directly. Always go through the DEV_HOST_atmStats_t struct.
9659 + UINT32 goodCount; // Upstream Good Cell Count
9660 + UINT32 idleCount; // Upstream Idle Cell Count
9661 +} DEV_HOST_usAtmStats_t;
9663 +// Never access a struct of this typedef directly. Always go through the DEV_HOST_atmStats_t struct.
9666 + UINT32 goodCount; // Downstream Good Cell Count
9667 + UINT32 idleCount; // Downstream Idle Cell Count
9668 + UINT32 badHecCount; // Downstream Bad Hec Cell Count
9669 + UINT32 ovflwDropCount; // Downstream Overflow Dropped Cell Count
9670 + DEV_HOST_cellDelinState_t delineationState; // Indicates current delineation state
9671 +} DEV_HOST_dsAtmStats_t;
9676 + DEV_HOST_usAtmStats_t *us0_p; // US ATM stats for TC channel 0
9677 + DEV_HOST_dsAtmStats_t *ds0_p; // DS ATM stats for TC channel 0
9678 + DEV_HOST_usAtmStats_t *us1_p; // US ATM stats for TC channel 1
9679 + DEV_HOST_dsAtmStats_t *ds1_p; // DS ATM stats for TC channel 1
9680 +} DEV_HOST_atmStats_t;
9683 +// ----------------------
9684 +// Begin EOC definitions.
9685 +// ----------------------
9687 +// The two values below can never change (for backwards compatibility of host intf.)
9688 +#define DEV_HOST_EOCREG4LENGTH 32
9689 +#define DEV_HOST_EOCREG5LENGTH 32
9693 + UINT8 eocReg4[DEV_HOST_EOCREG4LENGTH]; // Host/Dsp Write, vendor specific EOC Register 4
9694 + UINT8 eocReg5[DEV_HOST_EOCREG5LENGTH]; // Host/Dsp Write, vendor specific EOC Register 5
9695 + UINT8 vendorId[8]; // Host write
9696 + UINT8 revNumber[4]; // Host, ATU-R Revision Number
9697 + UINT8 serialNumber[32]; // Host write
9698 + UINT8 eocReg4Length; // Host Write, valid length for EOC register 4
9699 + UINT8 eocReg5Length; // Host Write, valid length for EOC register 5
9700 + UINT8 dummy[2]; // dummy bytes for 32-bit alignment
9701 + UINT32 eocModemStatusReg; // Dsp Write, status bits to host
9702 + UINT8 lineAtten; // Dsp Write, line attenuation in 0.5 db step
9703 + SINT8 dsMargin; // DSP Write, measured DS margin
9704 + UINT8 aturConfig[30]; // Dsp Write, also used by EOC for ATUR Configuration
9705 +} DEV_HOST_eocVarDef_t;
9709 + UINT16 endEocThresh; // Host Write, end of Clear EOC stream threshold
9710 + UINT16 dummy; // dummy value to fill gap
9711 + UINT32 dropEocCount; // Dsp Write, counter of dropped Clear EOC bytes
9712 + UINT16 eocRxLength; // Host/DSP write, number of valid Rx Clear EOC bytes
9713 + UINT16 eocTxLength; // Host/DSP write, number of valid Tx Clear EOC bytes
9714 + UINT8 eocRxBuf[64]; // Dsp Write, Buffer for receiving Rx Clear EOC bytes
9715 + UINT8 eocTxBuf[64]; // Host Write, Buffer for writing Tx Clear EOC bytes
9716 +} DEV_HOST_clearEocVarDef_t;
9719 +// -----------------------------------
9720 +// Begin CO profile Definitions.
9721 +// -----------------------------------
9723 +/* struct size must be a word size */
9727 + SINT16 devCodecRxdf4Coeff[12] ; // (BOTH) IIR Coefficients
9728 + SINT16 devCodecTxdf2aCoeff[64] ; // (BOTH) FIR filter coefficients
9729 + SINT16 devCodecTxdf2bCoeff[64] ; // (BOTH) FIR filter coefficients
9730 + SINT16 devCodecTxdf1Coeff[12] ; // (BOTH) IIR filter coefficients
9731 + UINT16 devCodecTxDf2aDen; // (BOTH) denominator for IIR filter
9732 + UINT16 devCodecTxDf2bDen; // (BOTH) denominator for IIR filter
9733 + SINT16 ctrlMsmSpecGain[32]; // (BOTH)
9735 + SINT16 phyBitaRateNegIntNoTrellis ; // (BOTH) value to set
9736 + SINT16 phyBitaRateNegIntTrellis ; // (BOTH) value to set
9737 + SINT16 phyBitaRateNegFastNoTrellis ; // (BOTH) value to set
9738 + SINT16 phyBitaRateNegFastTrellis ; // (BOTH) value to set
9739 + SINT16 phyBitaRsFlag ; // (BOTH)
9740 + SINT16 phyBitaFirstSubChannel ; // (BOTH)
9741 + SINT16 phyBitaMaxFineGainBump; // max fine gain bump
9742 + SINT16 phyBitaFineGainReduction; // fine gain reduction
9743 + SINT16 phyBitaMaxDownstreamPowerCutback; // max downstream power cutback
9745 + SINT16 phySigTxGainReductionAt0kft; // upstream power reduction at 0 kft.
9747 + SINT16 phyAgcPgaTarget ; // (BOTH) compare value
9749 + UINT16 imsg413TxRate ; // (BOTH) Tx rate
9750 + SINT16 imsg413RsBytesAdjust ; // (BOTH) subtract value
9751 + UINT16 imsg413PstringMask ; // (POTS) Or'ed into pString[RMSGS1_INDEX][1]
9752 + SINT16 imsg413UsPilot ; // (BOTH)??
9753 + UINT16 imsg413SkipPhaseOp ; // (POTS)
9755 + UINT16 ctrlMsmSensitivity1 ; // (BOTH) value to set
9756 + UINT16 ctrlMsmTxPsdShape_f; // (BOTH) upstream spectral shaping flag
9758 + UINT16 ovhdAocUsBswapReq_f ; // (BOTH)value to set
9759 + UINT16 ovhdAocScanMse_f ; // (BOTH)value to set
9761 + SINT16 phyRevFullFirstBin ; //
9762 + SINT16 phyRevFullLastBin ; //
9763 + SINT16 phyRevFirstBin ; //
9764 + SINT16 phyRevLastBin ; //
9765 + SINT16 phyMedFirstBin ; //
9766 + SINT16 phyMedLastBin ; //
9767 + SINT16 phyMedOptionalLastBin; // Medley last bin - optional
9769 + SINT16 phyEcDelayAdjustment; // Echo delay adjustment
9770 + SINT16 bSwapThresholdUpdate; // bSwapThresholdUpdate
9771 + SINT16 phyBitaFastPathExcessFineGainBump; // Used in phy_bita.c
9772 + SINT16 phyBitaSkipGapAdjustment; // Used in phy_bita.c
9773 + SINT16 usPilotInT1413ModeInMedley; // To send Upstream Pilot in medley in T1.413 mode.
9775 + UINT32 profileVendorId ; // vendor id
9777 +} DEV_HOST_coData_t ;
9781 + DEV_HOST_coData_t * hostProfileBase_p; // base address of profile list
9782 +} DEV_HOST_profileBase_t ;
9786 +// -----------------------------------
9787 +// Begin DSP/Host Mailbox Definitions.
9788 +// -----------------------------------
9790 +// The 3 values below can never be decreased, only increased.
9791 +// If you increase one of the values, you must add more to the
9792 +// initializers in "dev_host_interface.c".
9793 +#define DEV_HOST_HOSTQUEUE_LENGTH 8
9794 +#define DEV_HOST_DSPQUEUE_LENGTH 8
9795 +#define DEV_HOST_TEXTQUEUE_LENGTH 8
9797 +// Never access a struct of this typedef directly. Always go through the DEV_HOST_mailboxControl_t struct.
9804 +} DEV_HOST_dspHostMsg_t;
9806 +// Never access a struct of this typedef directly. Always go through the DEV_HOST_mailboxControl_t struct.
9811 +} DEV_HOST_textMsg_t;
9813 +// The structure below has been ordered so that the Host need only write to
9814 +// even byte locations to update the indices.
9816 +// The Buffer pointers in the struct below each point to a different
9817 +// struct array that has an array size of one of the matching Queue Length
9818 +// values defined above (DEV_HOST_HOSTQUEUE_LENGTH, DEV_HOST_DSPQUEUE_LENGTH,
9819 +// and DEV_HOST_TEXTQUEUE_LENGTH).
9823 + UINT8 hostInInx; // Host write, DSP must never write except for init
9824 + UINT8 bDummy0[3]; // dummy bytes for explicit 32-bit alignment
9825 + UINT8 hostOutInx; // DSP write, Host must never write
9826 + UINT8 bDummy1[3]; // dummy bytes for explicit 32-bit alignment
9827 + UINT8 dspOutInx; // Host write, DSP must never write except for init
9828 + UINT8 bDummy2[3]; // dummy bytes for explicit 32-bit alignment
9829 + UINT8 dspInInx; // DSP write, Host must never write
9830 + UINT8 bDummy3[3]; // dummy bytes for explicit 32-bit alignment
9831 + UINT8 textInInx; // DSP write, Host must never write
9832 + UINT8 bDummy4[3]; // dummy bytes for explicit 32-bit alignment
9833 + UINT8 textOutInx; // Host write, DSP must never write except for init
9834 + UINT8 bDummy5[3]; // dummy bytes for explicit 32-bit alignment
9835 + DEV_HOST_dspHostMsg_t *hostMsgBuf_p; // pointer to Host Mailbox Buffer (Host writes the buffer)
9836 + DEV_HOST_dspHostMsg_t *dspMsgBuf_p; // pointer to DSP Mailbox Buffer (DSP writes the buffer)
9837 + DEV_HOST_textMsg_t *textMsgBuf_p; // pointer to Text Mailbox Buffer (DSP writes the buffer)
9838 +} DEV_HOST_mailboxControl_t;
9841 +//-----------------------------------------
9842 +// Physical layer performance parameter
9843 +//-----------------------------------------
9846 + SINT32 hybridCost[5]; // Cost functions for hybrids (0: none, 1-4 hybrid options)
9847 + SINT32 usAvgGain; // upstream average gain in 20log10 (Q8)
9848 + SINT32 dsAvgGain; // downstream average gain in 20log10 (Q8)
9849 + UINT8 disableDspHybridSelect_f; // Allows host to disable the automatic hybrid selection by the DSP
9850 + UINT8 hostSelectHybridNum; // DSP will use this hybrid number only if DSP Select is disabled (values: 1-4)
9851 + UINT8 currentHybridNumUsed; // DSP indicates to the host the current hybrid number in use
9852 + UINT8 reserved1; // reserved for future use
9853 +} DEV_HOST_phyPerf_t;
9856 +/***********************************************************
9857 + * The 3 structures below are used only for analog
9858 + * diagnostic functions originally defined in diag.h
9859 + * Moved here by Carlos A. Perez under J. Bergsagel request
9860 + ***********************************************************/
9862 +/****************************************************************************/
9863 +/* Options for the Analog Diagnostic user input data structure */
9864 +/* (MUST be word aligned) */
9865 +/****************************************************************************/
9868 + ZERO_DIAG_OPT = 0, // dummy value for zero place-holder
9869 + NOISE_ONLY = 0x1, // diagnostic in noise only mode (on=1, off=0), disregard diagMode 0-4
9870 + EXTERNAL_CO = 0x2, // operates against external CO (external=1, internal=0)
9871 + DIAG_AGC = 0x4, // agc selects gains control (agc=1, manual=0)
9872 + CROSSTALK_TEQ = 0x8, // crosstalk selects teq (crosstalk=1, manual=0)
9873 + LEAKY_TEQ = 0x10, // use leaky teq (on=1, off=0)
9874 + AUX_AMPS = 0x20, // auxamps (on=1, off=0)
9875 + BW_SELECT = 0x40, // change rxhpf/txlpf fc (modify=1, default=0)
9876 + DIAG_HYB_SELECT = 0x80, // change hybrid (modify=1, default=0)
9877 + POWER_DOWN_CDC = 0x100, // power down codec (power down=1, no power down=0)
9878 + ISDN_OP_MODE = 0x200, // operation mode (pots=0, isdn=1)
9879 + BYPASS_RXAF2 = 0x400, // Bypass except RXAF2 (on=1, off = 0)
9880 + TX_TEST_CONT = 0x800, // Continuous tx test (on=1, off=0)
9881 + TX_SCALE_MTT = 0x1000 // Scale tx signal for Mtt test (on=1, off=0)
9882 +} DEV_HOST_diagAnlgOptionsVar_t;
9884 +/****************************************************************************/
9885 +/* Analog Diagnostic user input data structure (MUST be word align) */
9886 +/****************************************************************************/
9890 + DEV_HOST_diagAnlgOptionsVar_t diagOption; // Other diagnostic optional settings
9892 + UINT8 diagMode; // Performance diagnostic mode
9893 + UINT8 txMode; // transmit mode
9894 + UINT8 rxMode; // receive mode
9895 + UINT8 teqSp; // Select teq starting pt
9896 + UINT8 txDf1; // see dev_codec_filters.c and
9897 + UINT8 txDf2a; // dev_codec.h for filter coefficients
9901 + UINT16 codingGain256Log2; // 256*Log2(coding gain)
9902 + UINT16 noiseMargin256Log2; // 256*Log2(noise margin)
9904 + UINT16 rxPga1; // PGA1
9905 + UINT16 rxPga2; // PGA2
9906 + UINT16 rxPga3; // PGA3
9907 + UINT16 anlgEq; // AEQ settings (dB/MHz)
9909 + SINT8 pilotBin; // Select pilot subchannel
9910 + SINT8 txSwGain; // manual set for bridge tap loop
9911 + SINT8 tdw1Len; // TDW1 length - 0,2,4,8,16
9912 + SINT8 tdw2Len; // TDW2 length - 0,2,4,8,16
9914 + UINT8 teqEcMode; // TEQ/EC mode
9916 + UINT8 txAttn; // Codec Tx attenuation
9917 + UINT8 txGain; // Codec Tx gain (Sangam only)
9919 + SINT16 txPda; //Codec Tx Digital gain/attn
9920 + UINT8 txTone[MAX_NUM_UPBINS]; // Turning tones on/off
9921 + // Still govern by lastbin
9922 + UINT16 rsvd; //for 32 bits alignment
9923 +}DEV_HOST_diagAnlgInputVar_t;
9925 +/****************************************************************************/
9926 +/* Analog diagnostic output data structure */
9927 +/****************************************************************************/
9930 + PSINT32 rxSnr_p[2]; // Pointer to estimated snr
9931 + PSINT32 rxSubChannelCapacity_p[2]; // Pointer to estimated subchan capacity
9932 + PSINT32 rxSignalPower_p[2]; // Pointer to estimated signal power
9933 + PSINT32 rxNoisePower_p[2]; // Pointer to estimated noise power
9934 + PSINT32 rxAvg_p; // Pointer to average of rcvd signal
9935 + SINT32 chanCapacity[2] ; // Channel total capacity
9936 + SINT32 dataRate[2]; // Modem data rate (SNR)
9937 + SINT32 avgNoiseFloor; // Average noise floor
9938 + SINT16 snrGap256Log2; // 256*Log2(snr gap)
9939 + SINT16 rxPga1; // PGA1
9940 + SINT16 rxPga2; // PGA2
9941 + SINT16 rxPga3; // PGA3
9942 + SINT16 anlgEq; // AEQ settings (dB/MHz)
9944 +}DEV_HOST_diagAnlgOutputVar_t;
9947 +// Bit field structure that allows the host to mask off interrupt sources for possible DSP-to-Host interrupts.
9948 +// Each bit represents a possible source of interrupts in the DSP code that might cause a DSP-to-Host
9949 +// interrupt to occur.
9950 +// This mask structure is not intended to show how interrupt sources in the DSP code correspond to the actual
9951 +// DSP-to-Host interrupts. There could be multiple ways to cause an interrupt in the DSP code, but they all
9952 +// eventually tie into one of the three possible DSP-to-Host interrupts.
9953 +// The host should write a "1" to an individual bit when it wants to mask possible interrupts from that source.
9955 +// enum that represents individual bits in maskBitField1
9958 + ZERO_MASK1 = 0, // dummy value for zero place-holder
9959 + DSP_MSG_BUF = 0x1, // mask interrupts due to DSP-to-Host message mailbox updates
9960 + STATE_BIT_FIELD = 0x2, // mask interrupts due to changes in the modem state bit fields
9961 + DSP_HEARTBEAT = 0x4 // mask interrupts for the DSP hearbeat
9962 +} DEV_HOST_intMask1_t; // this enum should only have 32 values in it (maximum).
9964 +// Add more "mask bit fields" at the end of this struct if you need more mask values
9967 + DEV_HOST_intMask1_t maskBitField1;
9968 +} DEV_HOST_hostInterruptMask_t; // this struct should only have 32 bits in it.
9970 +// Bit field structure that allows the host to determine the source(s) of DSP-to-Host interrupts in case
9971 +// several of the interrupt sources get combined onto a single DSP-to-Host interrupt.
9972 +// DSP will set each bit to a "1"as an interrupt occurs.
9973 +// Host has the reponsibility to clear each bit to a "0" after it has determined the source(s) of interrupts.
9974 +// Each source bit field in this struct will use the same enum typedef that matches the corresponding mask
9975 +// bit field in "DEV_HOST_hostInterruptMask_t"
9978 + DEV_HOST_intMask1_t sourceBitField1;
9979 +} DEV_HOST_hostInterruptSource_t;
9982 +// --------------------------
9983 +// Begin bitswap definitions.
9984 +// --------------------------
9986 +// bitSwapSCnt contains the superframe to perform bit swap
9987 +// The entries must be ordered so that the first group only contains bit change commands
9988 +// The other entries may contain power adjustment instructions and must be
9989 +// written with something. NOP (0) is an available instruction.
9992 + PUINT8 fineGains_p; // pointer to bng string, needed to check fine gains for powerswap
9993 + UINT8 bitSwapNewIndices[6]; // Bin before bitSwapBin to process
9994 + UINT8 bitSwapCmd[6]; // Bitswap command for bitSwapBin
9995 + UINT8 bitSwapBin[6]; // bin to modify
9996 + UINT8 bitSwapSCnt; // Superframe count on which to perform bitswap
9997 + UINT8 bitSwapEnabled; // bitSwapEnabled
9998 +} DEV_HOST_dspBitSwapDef_t;
10001 +// ---------------------------
10002 +// Begin ATM BERT definitions.
10003 +// ---------------------------
10005 +// Structure used for ATM Idle Cells based bit error rate computation.
10008 + UINT8 atmBertFlag; // Feature enable/disable flag (Host write)
10010 + UINT8 dummy[2]; // Dummy bytes for 32-bit alignment
10011 + UINT32 bitCountLow; // Low part of 64-bit BERT bit count (DSP write)
10012 + UINT32 bitCountHigh; // High part of 64-bit BERT bit count (DSP write)
10013 + UINT32 bitErrorCountLow; // Low part of 64-bit BERT bit count (DSP write)
10014 + UINT32 bitErrorCountHigh;// High part of 64-bit BERT bit count (DSP write)
10015 +} DEV_HOST_atmDsBert_t;
10018 +// ------------------------------------
10019 +// Misc. modem environment definitions.
10020 +// ------------------------------------
10025 + SINT16 subStateIndex; // Index that signifies datapump substate. (DSP write)
10026 + UINT8 externalBert; // Turn on/off external BERT interface. 0 = OFF; 1 = ON. (Host write)
10027 + UINT8 usBertPattern; // BERT pattern for US TX data. 0 = 2^15-1; 1 = 2^23-1. (Host write)
10028 + UINT8 overrideDslLinkLed_f; // Overrides DSP operation of the DSL_LINK LED. (Host write)
10029 + // 0 = DSP is in control; 1 = Host is in control.
10030 + UINT8 dslLinkLedState_f; // DSL_LINK LED state when override flag has been set. (Host write)
10031 + // DSL_LINK LED will be updated with this value once per frame.
10032 + // LED is active-low: 0 = ON, 1 = OFF.
10033 + UINT8 overrideDslActLed_f; // Overrides DSP operation of the DSL_ACT LED. (Host write)
10034 + // 0 = DSP is in control; 1 = Host is in control.
10035 + UINT8 dslActLedState_f; // DSL_ACT LED state when override flag has been set. (Host write)
10036 + // DSL_ACT LED will be updated with this value once per frame.
10037 + // LED is active-low: 0 = ON, 1 = OFF.
10038 + UINT8 dGaspLprIndicator_f; // How LPR signal (GPIO[0]) is to be interpreted. (Host write)
10039 + // 0 = LPR is active-low; 1 = LPR is active-high.
10040 + UINT8 overrideDspLprGasp_f; // Overrides DSP detection of LPR signal to send out DGASP. (Host write)
10041 + // 0 = DSP detects LPR; 1 = Host detects LPR and sends "HOST_DGASP" to DSP.
10042 + UINT8 pcbEnabled; // DS power cut back
10043 + UINT8 maxAvgFineGainCtrl_f; // If maxAvgFineGainCtrl_f == 0, then the datapump controls the maximum average fine gain value.
10044 + // If maxAvgFineGainCtrl_f == 1, then the host controls the maximum average fine gain value.
10045 + UINT32 reasonForDrop; // This field will tell the host what might be the reason for a dropped connection.
10046 + SINT16 maxAverageFineGain; // When maxAvgFineGainCtrl_f == 1, the value in maxAverageFineGain is the maximum average fine gain level in 256log2 units.
10047 + UINT8 reserved1; // These are for 32-bit alignment.
10048 + UINT8 reserved2; // These are for 32-bit alignment.
10049 +} DEV_HOST_modemEnvPublic_t;
10052 +// -----------------------------
10053 +// Generic structure definition.
10054 +// -----------------------------
10058 + PSINT8 parameter1_p;
10059 + PSINT16 parameter2_p;
10060 + PSINT32 parameter3_p;
10061 + PUINT8 parameter4_p;
10062 + PUINT16 parameter5_p;
10063 + PUINT32 parameter6_p;
10064 +} DEV_HOST_genericStructure_t;
10067 +// ------------------------------
10068 +// Begin G.hs buffer definitions.
10069 +// ------------------------------
10073 + UINT8 txBuf[64]; // G.hs xmt buffer
10074 +} DEV_HOST_ghsDspTxBufDef_t;
10079 + UINT8 rxBuf[80]; // G.hs rcv buffer
10080 +} DEV_HOST_ghsDspRxBufDef_t;
10082 +// -----------------------------------------
10083 +// Begin Constellation Display definitions.
10084 +// -----------------------------------------
10088 + UINT32 consDispStartAddr; // Host write
10089 + UINT32 consDispCurrentAddr; // Host write
10090 + UINT32 consDispBufLen; // Constellation Buffer Length
10091 + UINT32 consDispBin; // Host write, DS band only
10092 +} DEV_HOST_consBufDef_t;
10096 + PSINT16 buffer1_p; //DSP write
10097 + PSINT16 buffer2_p; //DSP write
10098 +} DEV_HOST_snrBuffer_t;
10100 +// --------------------------------------------------------------------------------------
10101 +// Typedef to be used for the DEV_HOST_dspOamSharedInterface_s struct of pointers
10102 +// (this is used in dev_host_interface.c).
10103 +// NOTE: This struct of pointers is NEVER to be referenced anywhere else in the DSP code.
10104 +// IMPORTANT: Only pointers to other structs go into this struct !!
10105 +// --------------------------------------------------------------------------------------
10108 + DEV_HOST_hostIntfcVersionDef_t *hostIntfcVersion_p;
10109 + DEV_HOST_dspVersionDef_t *datapumpVersion_p;
10110 + DEV_HOST_modemStateBitField_t *modemStateBitField_p;
10111 + DEV_HOST_dspWrNegoParaDef_t *dspWriteNegoParams_p;
10112 + DEV_HOST_oamWrNegoParaDef_t *oamWriteNegoParams_p;
10113 + DEV_HOST_raMsgsDef_t *raMsgs_p;
10114 + DEV_HOST_dspWrSuperFrameCntDef_t *dspWriteSuperFrameCnt_p;
10115 + DEV_HOST_msg_t *atucMsg_p;
10116 + DEV_HOST_msg_t *aturMsg_p;
10117 + DEV_HOST_dspWrSharedTables_t *dspWrSharedTables_p;
10118 + DEV_HOST_olayDpDef_t *olayDpParms_p;
10119 + DEV_HOST_eocVarDef_t *eocVar_p;
10120 + DEV_HOST_clearEocVarDef_t *clearEocVar_p;
10121 + DEV_HOST_modemStatsDef_t *modemStats_p;
10122 + DEV_HOST_atmStats_t *atmStats_p;
10123 + DEV_HOST_mailboxControl_t *dspHostMailboxControl_p;
10124 + DEV_HOST_phyPerf_t *phyPerf_p;
10125 + DEV_HOST_diagAnlgInputVar_t *analogInputVar_p;
10126 + DEV_HOST_diagAnlgOutputVar_t *analogOutputVar_p;
10127 + DEV_HOST_hostInterruptMask_t *hostInterruptMask_p;
10128 + DEV_HOST_profileBase_t *profileList_p;
10129 + DEV_HOST_hostInterruptSource_t *hostInterruptSource_p;
10130 + DEV_HOST_dspBitSwapDef_t *dspBitSwapDstrm_p;
10131 + DEV_HOST_dspBitSwapDef_t *dspBitSwapUstrm_p;
10132 + DEV_HOST_atmDsBert_t *atmDsBert_p;
10133 + DEV_HOST_modemEnvPublic_t *modemEnvPublic_p;
10134 + DEV_HOST_genericStructure_t *genericStructure1_p;
10135 + DEV_HOST_genericStructure_t *genericStructure2_p;
10136 + DEV_HOST_ghsDspTxBufDef_t *ghsDspTxBuf_p;
10137 + DEV_HOST_ghsDspRxBufDef_t *ghsDspRxBuf_p;
10138 + DEV_HOST_consBufDef_t *consDispVar_p;
10139 + DEV_HOST_snrBuffer_t *snrBuffer_p;
10140 +} DEV_HOST_dspOamSharedInterface_t;
10143 +// ---------------------------------------------------------------------------------
10144 +// Typedef to be used for the pointer to the DEV_HOST_dspOamSharedInterface_s struct
10145 +// of pointers (this is used in dev_host_interface.c).
10146 +// ---------------------------------------------------------------------------------
10147 +typedef DEV_HOST_dspOamSharedInterface_t *DEV_HOST_dspOamSharedInterfacePtr_t;
10150 diff -urN linux.old/drivers/atm/sangam_atm/dev_host_verdef.h linux.dev/drivers/atm/sangam_atm/dev_host_verdef.h
10151 --- linux.old/drivers/atm/sangam_atm/dev_host_verdef.h 1970-01-01 01:00:00.000000000 +0100
10152 +++ linux.dev/drivers/atm/sangam_atm/dev_host_verdef.h 2005-07-10 08:02:01.432113184 +0200
10154 +#ifndef __DEV_HOST_VERDEF_H__
10155 +#define __DEV_HOST_VERDEF_H__ 1
10157 +//********************************************************************
10159 +//* DMT-BASE ADSL MODEM PROGRAM
10160 +//* TEXAS INSTRUMENTS PROPRIETARTY INFORMATION
10161 +//* AMATI CONFIDENTIAL PROPRIETARY
10163 +//* (c) Copyright April 1999, Texas Instruments Incorporated.
10164 +//* All Rights Reserved.
10166 +//* Property of Texas Instruments Incorporated and Amati Communications Corp.
10168 +//* Restricted Rights - Use, duplication, or disclosure is subject to
10169 +//* restrictions set forth in TI's and Amati program license agreement and
10170 +//* associated documentation
10172 +//*********************************************************************
10174 +//* FILENAME: dev_host_verdef.h
10176 +//* ABSTRACT: This file defines the version structure
10178 +//* TARGET: Non specific.
10180 +//* TOOLSET: Non specific.
10184 +//* HISTORY: DATE AUTHOR DESCRIPTION
10185 +//* 04/29/99 FLW Created
10186 +//* 01/17/00 Barnett Mod's in support of merging NIC
10187 +//* hardware rev 6/7 T1.413 codebases.
10188 +//* 01/21/00 Wagner derfmake mods
10189 +//* 05/11/00 Barnett hardware_rev is a 2 char string.
10190 +//* 07/24/00 Barnett Rework as part of host interface redesign.
10191 +//* 11/29/00 Hunt added chipset_id2
10192 +//* 03/30/01 Barnett Prefixed all public elements with DSPDP_.
10193 +//* This insures uniqueness of names that might
10194 +//* match host names by coincidence.
10195 +//* 03/30/01 Barnett Added DSPDP_Host_VersionDef to facilitate
10196 +//* representing a version id for the host i/f
10197 +//* separate from the firmware version id as
10198 +//* a courtesy to the host.
10199 +//* 07/23/01 JEB Changed name from verdef_u.h to dpsys_verdef.h
10200 +//* 04/12/02 Barnett Make timestamp unsigned 32-bit field.
10201 +//* Generalizes for all kinds of hosts.
10202 +//* 11/15/02 JEB Changed name from dpsys_verdef.h to dev_host_verdef.h
10203 +//* Updated structs according to coding guidelines
10204 +//* 12/16/02 JEB Renamed some struct elements for new usage in Ax7
10205 +//* 01/21/03 MCB Implemented Ax7 UNIT-MODULE modular software framework.
10206 +//* 03/19/03 JEB Added back in "bugFix" elements into each struct type.
10207 +//* Rearranged elements.
10209 +//********************************************************************
10211 +#include "env_def_typedefs.h"
10213 +#define DSPDP_FLAVOR_NEWCODES 0xFF // Other values are valid old-style flavors
10215 +// ------------------------------
10216 +// ------------------------------
10217 +// Begin DSP version definitions.
10218 +// ------------------------------
10219 +// ------------------------------
10223 + UINT32 timestamp; // Number of seconds since 01/01/1970
10224 + UINT8 major; // Major "00".00.00.00 revision nomenclature
10225 + UINT8 minor; // Minor 00."00".00.00 revision nomenclature
10226 + UINT8 bugFix; // Bug Fix 00.00."00".00 revision nomenclature
10227 + UINT8 buildNum; // Build Number 00.00.00."00" revision nomenclature
10228 + UINT8 netService; // Network service identifier
10229 + UINT8 chipsetGen; // chipset generation
10230 + UINT8 chipsetId; // chipset identifier
10231 + UINT8 chipsetId2; // second byte for "RV" chipset et al.
10232 + UINT8 hardwareRev1; // hardware revision, 1st char
10233 + UINT8 hardwareRev2; // hardware revision, 2nd char
10234 + UINT8 featureCode; // feature code
10235 + UINT8 dummy1; // dummy byte for explicit 32-bit alignment
10236 +} DEV_HOST_dspVersionDef_t;
10238 +// -------------------------------
10239 +// -------------------------------
10240 +// Begin host version definitions.
10241 +// -------------------------------
10242 +// -------------------------------
10246 + UINT8 major; // Major "00".00.00.00 revision nomenclature
10247 + UINT8 minor; // Minor 00."00".00.00 revision nomenclature
10248 + UINT8 bugFix; // Bug Fix 00.00."00".00 revision nomenclature
10249 + UINT8 buildNum; // Build Number 00.00.00."00" revision nomenclature
10250 + UINT8 netService; // Network service identifier
10251 + UINT8 dummy[3]; // dummy bytes for explicit 32-bit alignment
10252 +} DEV_HOST_hostIntfcVersionDef_t;
10255 +#endif // __DEV_HOST_VERDEF_H__
10256 diff -urN linux.old/drivers/atm/sangam_atm/dsl_hal_api.c linux.dev/drivers/atm/sangam_atm/dsl_hal_api.c
10257 --- linux.old/drivers/atm/sangam_atm/dsl_hal_api.c 1970-01-01 01:00:00.000000000 +0100
10258 +++ linux.dev/drivers/atm/sangam_atm/dsl_hal_api.c 2005-07-10 08:02:01.436112576 +0200
10260 +/*******************************************************************************
10261 +* FILE PURPOSE: DSL Driver API functions for Sangam
10263 +********************************************************************************
10264 +* FILE NAME: dsl_hal_basicapi.c
10267 +* Contains basic DSL HAL APIs for Sangam
10270 +* (C) Copyright 2001-02, Texas Instruments, Inc.
10272 +* Date Version Notes
10273 +* 06Feb03 0.00.00 RamP Original Version Created
10274 +* 10Mar03 0.00.01 RamP Initial Revision for Modular Code Branch
10275 +* 19Mar03 0.00.02 RamP Fixed DSL and DSP Version API Structures
10276 +* 20Mar03 0.00.03 RamP Changed byteswap function names
10277 +* 21Mar03 0.00.03 RamP/ZT Malloc for DSP f/w done in dslStartup
10278 +* 25Mar03 0.00.04 RamP Removed statistics used only by SWTC
10279 +* Created Checkpoint 3
10280 +* 26Mar03 0.00.05 RamP Added Memory allocation for fwimage in
10281 +* dslStartup function.
10282 +* 07Apr03 0.00.06 RamP Implemented new error reporting scheme
10283 +* Changed Commenting to C style only
10284 +* 09Apr03 0.00.07 RamP Reorganized code to delete POST_SILICON
10285 +* 10Apr03 0.00.08 RamP Removed ptidsl from loadFWImage function
10286 +* moved size and fwimage initialization to
10287 +* dslStartup function
10288 +* 14Apr03 0.00.09 RamP Moved modemStateBitField processing to a
10289 +* support function; deleted stateHistory
10290 +* renamed the REG32 macro
10291 +* 15Apr03 0.00.10 RamP Changed firmware allocate to shim_
10292 +* osAllocateVMemory function
10293 +* 15Apr03 0.00.11 RamP Changed host version number to 07.00.00.01
10294 +* 16Apr03 0.00.12 RamP Modified return condition on dslShutdown
10295 +* 16Apr03 0.00.13 RamP Changed host version number to 07.00.00.02
10296 +* 21Apr03 0.01.00 RamP Cleaned up dslShutdown function
10297 +* Added new function calls to allocate
10298 +* (Alpha) /free overlay pages for different OS
10299 +* Fixed typecasting for allocate/free fxns
10300 +* Added Interrupt Acknowledge logic
10301 +* 22Apr03 0.01.01 RamP Moved acknowledgeInterrupt into api
10302 +* Added static global for intr source
10303 +* 24Apr03 0.01.02 RamP Added processing for OVERLAY_END in
10304 +* DSP message handlers, verified crc32
10305 +* recovery for overlays
10306 +* 28Apr03 0.01.03 RamP Removed global variable intrSource
10307 +* Added parameter to handleInterrupt fxn
10308 +* (Alpha Plus) to indicate interrupt source
10309 +* Changed version number to 01.00.01.00
10310 +* Fixed setTrainingMode function problem
10311 +* 07May03 0.01.04 RamP Removed delineation state check in
10312 +* message handling functions, added more
10313 +* safety for setting lConnected in TC_SYNC
10314 +* Changed version number to 01.00.01.01
10315 +* 14May03 0.01.05 RamP Added 3 Switchable Hybrid APIs
10316 +* Added additional statistics us/ds TxPower,
10317 +* us margin,attenuation, us/ds bitallocation
10318 +* moved versioning to dsl_hal_version.h
10319 +* 14May03 0.01.06 RamP Fixed problem with CMsgs2 parsing
10320 +* 20May03 0.01.07 RamP Added Inner/Outer pair API support. Added
10321 +* dying gasp message.
10322 +* 29May03 0.01.08 ZT/RamP Added memory optimizations for overlay pages
10323 +* and coProfiles; added functions to free,
10324 +* reload overlays and profiles
10325 +* 04Jun03 0.01.09 RamP Added tick counters, fail states reporting
10326 +* Made statistics fixes for higher data rates
10327 +* Added Margin per tone to statistics
10328 +* Added configuration checks for trellis/FEC
10329 +* 06Jun03 0.01.10 RamP Added LED, STM Bert, dGasp LPR Config APIs
10330 +* Modified interrupt acknowledge logic
10331 +* Added current hybrid flag as statistic
10332 +* 09Jun03 0.01.11 RamP Added function to send dying Gasp to Modem
10333 +* fixed problem with reading OamNegoPara var
10334 +* (Beta) fixed problem with reading current config
10335 +* Added function to configure ATM Bert
10336 +* fixed memory leak due to coProfiles
10337 +* Added us/ds R/S FEC statistics
10338 +* Added additional config capability for LED
10339 +* fixed problem in free memory for CO profiles
10340 +* 18Jul03 0.01.12 RamP Fixed problem with reading modemEnv structure
10341 +* affects LED, DGaspLpr APIs
10342 +* Sending Dying Gasp from shutdown function
10343 +* 01Aug03 0.01.13 RamP Added preferred training mode to statistics
10344 +* 13Aug03 0.01.14 MCB Set rev id for D3/R1.1 (ADSL2).
10345 +* 21Aug03 0.01.15 RamP Added g.hs and aoc bitswap message gathering
10346 +* Added new references to bits n gains table
10347 +* Decoupled modem idle/retrain from pair select
10348 +* Added line length and gross gain to statistics
10349 +* 29Sep03 0.01.16 RamP Replaced advcfg function calls with support
10350 +* module function switches
10351 +* 01Oct03 0.01.17 RamP Added enum translation to set training mode
10352 +* & to read statistics
10353 +* 08Oct03 0.01.18 RamP Fixed problems with usTxPower statistic in
10354 +* Annex B target, fixed problem with Trellis
10355 +* 12Oct03 0.01.19 RamP Added API calls to gather ADSL2 Messages
10356 +* 29Oct03 0.01.20 RamP Restored TC_SYNC detect logic
10357 +* 30Oct03 0.01.21 RamP Removed Scaling factor for adsl2DSConRate
10358 +* Setting Showtime state upon DSP_ACTIVE
10359 +* 14Nov03 0.01.22 RamP Fixed scaling for usTxPower & dsTxPower
10360 +* 14Nov03 0.01.23 RamP Added logic to gather CRates1/RRates1
10361 +* by parsing DSP_CRATES1
10362 +* 20Nov03 0.01.24 RamP Added generic & interface Read
10363 +* and Write functions to read from
10364 +* DSP - Host Interface
10365 +* 24Nov03 0.01.25 RamP Modified interface Read/Write functions
10366 +* to seperate element offsets from pointers
10367 +* 19Dec03 0.01.26 RamP Modified pointer accessing problems with
10368 +* block read functions
10369 +* 26Dec03 0.01.27 RamP Made ghsIndex a local variable & added
10370 +* check to avoid buffer overflow
10371 +* 30Dec03 0.01.28 RamP Added generic mailbox command function
10372 +*******************************************************************************/
10373 +#include "dsl_hal_register.h"
10374 +#include "dsl_hal_support.h"
10375 +#include "dsl_hal_logtable.h"
10376 +#include "dsl_hal_version.h"
10378 +static unsigned int hybrid_selected;
10379 +static unsigned int showtimeFlag = FALSE;
10381 +#ifdef PRE_SILICON
10382 +/*********************************************/
10383 +/* Base Addresses */
10384 +/*********************************************/
10385 +#define DEV_MDMA_BASE 0x02000500
10387 +/*********************************************/
10388 +/* MC DMA Control Registers in DSL */
10389 +/*********************************************/
10391 +#define DEV_MDMA0_SRC_ADDR (DEV_MDMA_BASE + 0x00000000)
10392 +#define DEV_MDMA0_DST_ADDR (DEV_MDMA_BASE + 0x00000004)
10393 +#define DEV_MDMA0_CTL_ADDR (DEV_MDMA_BASE + 0x00000008)
10394 +#define DEV_MDMA1_SRC_ADDR (DEV_MDMA_BASE + 0x00000040)
10395 +#define DEV_MDMA1_DST_ADDR (DEV_MDMA_BASE + 0x00000044)
10396 +#define DEV_MDMA1_CTL_ADDR (DEV_MDMA_BASE + 0x00000048)
10397 +#define DEV_MDMA2_SRC_ADDR (DEV_MDMA_BASE + 0x00000080)
10398 +#define DEV_MDMA2_DST_ADDR (DEV_MDMA_BASE + 0x00000084)
10399 +#define DEV_MDMA2_CTL_ADDR (DEV_MDMA_BASE + 0x00000088)
10400 +#define DEV_MDMA3_SRC_ADDR (DEV_MDMA_BASE + 0x000000C0)
10401 +#define DEV_MDMA3_DST_ADDR (DEV_MDMA_BASE + 0x000000C4)
10402 +#define DEV_MDMA3_CTL_ADDR (DEV_MDMA_BASE + 0x000000C8)
10404 +#define DEV_MDMA0_SRC (*((volatile UINT32 *) DEV_MDMA0_SRC_ADDR))
10405 +#define DEV_MDMA0_DST (*((volatile UINT32 *) DEV_MDMA0_DST_ADDR))
10406 +#define DEV_MDMA0_CTL (*((volatile UINT32 *) DEV_MDMA0_CTL_ADDR))
10407 +#define DEV_MDMA1_SRC (*((volatile UINT32 *) DEV_MDMA1_SRC_ADDR))
10408 +#define DEV_MDMA1_DST (*((volatile UINT32 *) DEV_MDMA1_DST_ADDR))
10409 +#define DEV_MDMA1_CTL (*((volatile UINT32 *) DEV_MDMA1_CTL_ADDR))
10410 +#define DEV_MDMA2_SRC (*((volatile UINT32 *) DEV_MDMA2_SRC_ADDR))
10411 +#define DEV_MDMA2_DST (*((volatile UINT32 *) DEV_MDMA2_DST_ADDR))
10412 +#define DEV_MDMA2_CTL (*((volatile UINT32 *) DEV_MDMA2_CTL_ADDR))
10413 +#define DEV_MDMA3_SRC (*((volatile UINT32 *) DEV_MDMA3_SRC_ADDR))
10414 +#define DEV_MDMA3_DST (*((volatile UINT32 *) DEV_MDMA3_DST_ADDR))
10415 +#define DEV_MDMA3_CTL (*((volatile UINT32 *) DEV_MDMA3_CTL_ADDR))
10417 +/* MDMA control bits */
10419 +#define DEV_MDMA_START 0x80000000
10420 +#define DEV_MDMA_STOP 0x00000000
10421 +#define DEV_MDMA_STATUS 0x40000000
10422 +#define DEV_MDMA_DST_INC 0x00000000
10423 +#define DEV_MDMA_DST_FIX 0x02000000
10424 +#define DEV_MDMA_SRC_INC 0x00000000
10425 +#define DEV_MDMA_SRC_FIX 0x00800000
10426 +#define DEV_MDMA_BURST1 0x00000000
10427 +#define DEV_MDMA_BURST2 0x00100000
10428 +#define DEV_MDMA_BURST4 0x00200000
10430 +#define DEV_MDMA_LEN_SHF 2
10431 +#define DEV_MDMA_LEN_MASK 0x0000FFFF
10439 +SINT32 getDmaStatus(UINT32 mask)
10441 + if(!(IFR & mask))
10443 + return DSLHAL_ERROR_NO_ERRORS;
10452 +void programMdma(UINT32 dma, UINT32 source, UINT32 destination, UINT32 length, UINT32 wait)
10454 + volatile UINT32 statusMask ;
10460 + DEV_MDMA0_SRC = source ;
10461 + DEV_MDMA0_DST = destination ;
10462 + DEV_MDMA0_CTL = (DEV_MDMA_START | DEV_MDMA_DST_INC | DEV_MDMA_SRC_INC |
10463 + DEV_MDMA_BURST1 | (length << DEV_MDMA_LEN_SHF)) ;
10464 + statusMask = 0x00000010 ;
10469 + DEV_MDMA1_SRC = source ;
10470 + DEV_MDMA1_DST = destination ;
10471 + DEV_MDMA1_CTL = (DEV_MDMA_START | DEV_MDMA_DST_INC | DEV_MDMA_SRC_INC |
10472 + DEV_MDMA_BURST1 | (length << DEV_MDMA_LEN_SHF)) ;
10473 + statusMask = 0x00000020 ;
10478 + DEV_MDMA2_SRC = source ;
10479 + DEV_MDMA2_DST = destination ;
10480 + DEV_MDMA2_CTL = (DEV_MDMA_START | DEV_MDMA_DST_INC | DEV_MDMA_SRC_INC |
10481 + DEV_MDMA_BURST1 | (length << DEV_MDMA_LEN_SHF)) ;
10482 + statusMask = 0x00000040 ;
10487 + DEV_MDMA3_SRC = source ;
10488 + DEV_MDMA3_DST = destination ;
10489 + DEV_MDMA3_CTL = (DEV_MDMA_START | DEV_MDMA_DST_INC | DEV_MDMA_SRC_INC |
10490 + DEV_MDMA_BURST1 | (length << DEV_MDMA_LEN_SHF)) ;
10491 + statusMask = 0x00000080 ;
10499 + while(!(getDmaStatus(statusMask))) ;
10507 +/******************************************************************************************
10508 +* FUNCTION NAME: dslhal_api_dslStartup
10510 +*******************************************************************************************
10511 +* DESCRIPTION: Entry point to initialize and load ax5 daughter board
10513 +* INPUT: PITIDSLHW_T *ppIHw
10515 +* RETURN: 0 --succeeded
10518 +*****************************************************************************************/
10520 +int dslhal_api_dslStartup(PITIDSLHW_T *ppIHw)
10523 + ITIDSLHW_T *ptidsl;
10526 + dprintf(4,"dslhal_api_dslStartup() NEW 1\n");
10528 + ptidsl=(ITIDSLHW_T *)shim_osAllocateMemory(sizeof(ITIDSLHW_T));
10531 + dprintf(1, "unable to allocate memory for ptidsl\n");
10535 + shim_osZeroMemory((char *) ptidsl, sizeof(ITIDSLHW_T));
10537 + /* Unreset the ADSL Subsystem */
10538 + rc=dslhal_support_unresetDslSubsystem();
10541 + dprintf(1, "unable to reset ADSL Subsystem \n");
10542 + shim_osFreeMemory((void *) ptidsl, sizeof(ITIDSLHW_T));
10543 + return DSLHAL_ERROR_UNRESET_ADSLSS;
10545 + ptidsl->fwimage = shim_osAllocateVMemory(DSP_FIRMWARE_MALLOC_SIZE);
10546 + if(!ptidsl->fwimage)
10548 + dprintf(1,"Failed to Allocate Memory for DSP firmware binary \n");
10549 + return DSLHAL_ERROR_FIRMWARE_MALLOC;
10551 + /* read firmware file from flash */
10552 + rc=shim_osLoadFWImage(ptidsl->fwimage);
10555 + dprintf(1, "unable to get fw image\n");
10556 + shim_osFreeVMemory((void *)ptidsl->fwimage,DSP_FIRMWARE_MALLOC_SIZE);
10557 + shim_osFreeMemory((void *) ptidsl, sizeof(ITIDSLHW_T));
10558 + return DSLHAL_ERROR_NO_FIRMWARE_IMAGE;
10562 + ptidsl->imagesize = rc;
10564 + /* Compute the CRC checksum on the image and validate the image */
10566 + /* Validate the image in the RAM */
10568 + /* load fw to DSP */
10570 + if(dslhal_support_hostDspCodeDownload(ptidsl))
10572 + dprintf(0,"dsp load error\n");
10573 + for(i=0; i<NUM_PAGES; i++)
10575 + if(ptidsl->olayDpPage[i].PmemStartWtAddr !=NULL)
10577 + shim_osFreeDmaMemory((void *) ptidsl->olayDpPage[i].PmemStartWtAddr,
10578 + ptidsl->olayDpPage[i].OverlayXferCount);
10581 + if(ptidsl->coProfiles.PmemStartWtAddr != NULL)
10582 + shim_osFreeDmaMemory((void *)ptidsl->coProfiles.PmemStartWtAddr, ptidsl->coProfiles.OverlayXferCount);
10583 + if(ptidsl->constDisplay.PmemStartWtAddr != NULL)
10584 + shim_osFreeDmaMemory((void *)ptidsl->constDisplay.PmemStartWtAddr, ptidsl->constDisplay.OverlayXferCount);
10585 + shim_osFreeVMemory((void *)ptidsl->fwimage,DSP_FIRMWARE_MALLOC_SIZE);
10586 + shim_osFreeMemory((void *) ptidsl, sizeof(ITIDSLHW_T));
10587 + return DSLHAL_ERROR_CODE_DOWNLOAD;
10590 + /* set flag to indicated overlay pages are loaded */
10591 + ptidsl->bOverlayPageLoaded = 1;
10592 + /* set auto retrain to 1 to disble the overlay page reload */
10593 + ptidsl->bAutoRetrain = 1;
10595 + /* unreset Raptor */
10596 + /* change this to new function */
10597 + /* This function should basically bring DSP out of reset bit 23 of PRCR */
10598 + /* Function is ready but bypassed for Pre-Silicon */
10600 + rc=dslhal_support_unresetDsp();
10603 + dprintf(0,"unable to bring DSP out of Reset\n");
10604 + for(i=0; i<NUM_PAGES; i++)
10606 + if(ptidsl->olayDpPage[i].PmemStartWtAddr !=NULL)
10608 + shim_osFreeDmaMemory((void *) ptidsl->olayDpPage[i].PmemStartWtAddr,
10609 + ptidsl->olayDpPage[i].OverlayXferCount);
10612 + if(ptidsl->coProfiles.PmemStartWtAddr != NULL)
10613 + shim_osFreeDmaMemory((void *)ptidsl->coProfiles.PmemStartWtAddr, ptidsl->coProfiles.OverlayXferCount);
10614 + if(ptidsl->constDisplay.PmemStartWtAddr != NULL)
10615 + shim_osFreeDmaMemory((void *)ptidsl->constDisplay.PmemStartWtAddr, ptidsl->constDisplay.OverlayXferCount);
10616 + shim_osFreeVMemory((void *)ptidsl->fwimage,DSP_FIRMWARE_MALLOC_SIZE);
10617 + shim_osFreeMemory((void *) ptidsl, sizeof(ITIDSLHW_T));
10618 + return DSLHAL_ERROR_UNRESET_DSP;
10620 + shim_osFreeVMemory((void *)ptidsl->fwimage,DSP_FIRMWARE_MALLOC_SIZE);
10621 + dprintf(4,"dslhal_api_dslStartup() done\n");
10623 + /* Add the code to initialize the host interface variables */
10624 + /* Add code to tickle the host interface */
10625 + return DSLHAL_ERROR_NO_ERRORS;
10629 +/******************************************************************************************
10630 + * FUNCTION NAME: dslhal_api_dslShutdown
10632 + *******************************************************************************************
10633 + * DESCRIPTION: routine to shutdown ax5 modem and free the resource
10635 + * INPUT: tidsl_t *ptidsl
10640 + *****************************************************************************************/
10642 +int dslhal_api_dslShutdown(tidsl_t *ptidsl)
10644 + int rc= DSLHAL_ERROR_NO_ERRORS;
10647 + dprintf(5, "dslhal_api_dslShutdown\n");
10648 + rc = dslhal_support_writeHostMailbox(ptidsl, HOST_DSLSS_SHUTDOWN, 0, 0, 0);
10651 + dprintf(1, " unable to reset DSP \n");
10652 + rc = DSLHAL_ERROR_RESET_DSP;
10654 + /* DSP need 50 ms to send out the message*/
10656 + shim_osClockWait(60 * 1000);
10658 + rc = dslhal_support_writeHostMailbox(ptidsl, HOST_DGASP, 0, 0, 0);
10660 + /* free memory allocated*/
10662 + for(i=0; i<NUM_PAGES; i++)
10664 + if(ptidsl->olayDpPage[i].PmemStartWtAddr !=NULL)
10666 + shim_osFreeDmaMemory((void *) ptidsl->olayDpPage[i].PmemStartWtAddr,
10667 + ptidsl->olayDpPage[i].OverlayXferCount);
10670 + if(ptidsl->coProfiles.PmemStartWtAddr != NULL)
10671 + shim_osFreeDmaMemory((void *)ptidsl->coProfiles.PmemStartWtAddr, ptidsl->coProfiles.OverlayXferCount);
10672 + if(ptidsl->constDisplay.PmemStartWtAddr != NULL)
10673 + shim_osFreeDmaMemory((void *)ptidsl->constDisplay.PmemStartWtAddr, ptidsl->constDisplay.OverlayXferCount);
10674 + shim_osFreeMemory((void *)ptidsl, sizeof(tidsl_t));
10675 + rc = dslhal_support_resetDsp();
10678 + dprintf(1, " unable to reset ADSL subsystem \n");
10679 + rc = DSLHAL_ERROR_RESET_DSP;
10681 + rc = dslhal_support_resetDslSubsystem();
10684 + dprintf(1, " unable to reset ADSL subsystem \n");
10685 + rc = DSLHAL_ERROR_RESET_ADSLSS;
10691 +/******************************************************************************************
10692 +* FUNCTION NAME: dslhal_api_getDslHalVersion
10694 +*******************************************************************************************
10695 +* DESCRIPTION: This routine supply DSL Driver version.
10697 +* INPUT: tidsl_t * ptidsl
10698 +* void *pVer, DSP Driver Version Pointer
10700 +* RETURN: 0 --succeeded
10702 +* Note: See verdef_u.h for version structure definition.
10703 +*****************************************************************************************/
10705 +void dslhal_api_getDslHalVersion(void *pVer)
10707 + dslVer *pVersion;
10708 + pVersion = (dslVer *)pVer;
10709 + pVersion->major = (unsigned char) DSLHAL_VERSION_MAJOR;
10710 + pVersion->minor = (unsigned char) DSLHAL_VERSION_MINOR;
10711 + pVersion->bugfix = (unsigned char) DSLHAL_VERSION_BUGFIX;
10712 + pVersion->buildNum = (unsigned char) DSLHAL_VERSION_BUILDNUM;
10713 + pVersion->timeStamp = (unsigned char) DSLHAL_VERSION_TIMESTAMP;
10716 +/********************************************************************************************
10717 + * FUNCTION NAME: dslhal_api_pollTrainingStatus()
10719 + *********************************************************************************************
10720 + * DESCRIPTION: code to decode modem status and to start modem training
10721 + * Input: tidsl_t *ptidsl
10723 + * Return: modem status
10726 + ********************************************************************************************/
10728 +int dslhal_api_pollTrainingStatus(tidsl_t *ptidsl)
10734 + unsigned int failState;
10735 + static unsigned int pollGhsIndex=0;
10738 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
10740 + DEV_HOST_tcHostCommDef_t TCHostCommDef;
10743 + dprintf(5,"dslhal_api_pollTrainingStatus\n");
10744 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterface_t *) ptidsl->pmainAddr;
10745 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
10746 + sizeof(DEV_HOST_dspOamSharedInterface_t));
10749 + dprintf(1,"dslhal_support_blockRead failed\n");
10750 + return DSLHAL_ERROR_BLOCK_READ;
10753 + dspOamSharedInterface.tcHostComm_p =(DEV_HOST_tcHostCommDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.tcHostComm_p);
10755 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.tcHostComm_p,
10756 + &TCHostCommDef, sizeof(DEV_HOST_tcHostCommDef_t));
10759 + dprintf(1,"dslhal_support_blockRead failed\n");
10760 + return DSLHAL_ERROR_BLOCK_READ;
10764 + rc = dslhal_support_processTrainingState(ptidsl);
10767 + dprintf(0,"Error Reading Modem Training State \n");
10768 + return DSLHAL_ERROR_MODEMSTATE;
10770 + rc = dslhal_support_processModemStateBitField(ptidsl);
10773 + dprintf(0,"Error Reading Modem Training State \n");
10774 + return DSLHAL_ERROR_MODEMSTATE;
10777 + rc = dslhal_support_readDelineationState(ptidsl);
10780 + dprintf(0,"Error Reading Delineation State \n");
10781 + return DSLHAL_ERROR_MODEMSTATE;
10784 + while (dslhal_support_readDspMailbox(ptidsl,&cmd, &tag, &parm1, &parm2) == DSLHAL_ERROR_NO_ERRORS )
10786 + dprintf(4,"mailbox message: 0x%x\n", cmd);
10788 + for(rc=0;rc<8;rc++)
10790 + dslhal_support_readTextMailbox(ptidsl,&msg1, &msg2);
10794 + if (cmd == DSP_IDLE)
10796 + dprintf(4,"DSP_IDLE\n");
10797 + ptidsl->lConnected=0;
10798 + hybrid_selected=888;
10799 + /* add code for reload overlay pages */
10800 + if(ptidsl->bAutoRetrain == 0)
10802 + while(ptidsl->bOverlayPageLoaded == 0)
10804 + shim_osClockWait(6400);
10806 + //dslhal_support_restoreTrainingInfo(ptidsl);
10807 + //ptidsl->bOverlayPageLoaded = 1;
10809 + /* command DSP to ACTREQ */
10810 + if(showtimeFlag == TRUE)
10812 + dslhal_api_resetTrainFailureLog(ptidsl);
10813 + dslhal_support_advancedIdleProcessing(ptidsl);
10814 + showtimeFlag = FALSE;
10816 + failState = (unsigned int)parm1;
10819 + ptidsl->AppData.trainFailStates[ptidsl->AppData.trainFails]=failState;
10820 + ptidsl->AppData.trainFails++;
10821 + if(ptidsl->AppData.trainFails > 30)
10822 + ptidsl->AppData.trainFails=0;
10824 + for(pollGhsIndex=0;pollGhsIndex<10;pollGhsIndex++)
10826 + for(rc=0;rc<62;rc++)
10827 + ptidsl->AppData.dsl_ghsRxBuf[pollGhsIndex][rc]=0;
10830 + rc = dslhal_support_writeHostMailbox(ptidsl,HOST_ACTREQ, 0, 0, 0);
10832 + return DSLHAL_ERROR_MAILBOX_WRITE;
10835 + if(cmd == DSP_ATM_TC_SYNC)
10837 + dprintf(4,"\nTC_SYNC\n");
10838 + showtimeFlag = TRUE;
10839 + ptidsl->lConnected=1;
10840 + if(ptidsl->bAutoRetrain == 0 && ptidsl->bOverlayPageLoaded == 1)
10842 + dslhal_support_clearTrainingInfo(ptidsl);
10843 + ptidsl->bOverlayPageLoaded = 0;
10846 + if(cmd == DSP_ACTIVE)
10848 + dprintf(4,"DSP_ACTIVE");
10849 + ptidsl->lConnected=0;
10850 + ptidsl->AppData.bState = RSTATE_SHOWTIME;
10851 + dprintf(4,"US Connect Rate: %u \n",ptidsl->AppData.USConRate);
10852 + dprintf(4,"DS Connect Rate: %u \n",ptidsl->AppData.DSConRate);
10854 + if(cmd == DSP_ATM_NO_TC_SYNC)
10856 + dprintf(4,"\nTC_NOSYNC\n");
10857 + ptidsl->lConnected=0;
10859 + if(cmd == DSP_DGASP)
10861 + dprintf(0,"\n GASP!!! \n");
10863 + if(cmd == DSP_OVERLAY_END)
10865 + dprintf(4,"Overlay Page Done %d \n",tag);
10866 + rc = dslhal_support_checkOverlayPage(ptidsl,tag);
10867 + if(rc == DSLHAL_ERROR_OVERLAY_CORRUPTED)
10869 + dprintf(0,"Overlay Page: %d CORRUPTED \n",tag);
10870 + return (0-DSLHAL_ERROR_OVERLAY_CORRUPTED);
10873 + if(cmd == DSP_HYBRID)
10875 + dprintf(2,"Hybrid Metrics Available: %d\n",tag);
10876 + hybrid_selected = tag;
10878 + if(cmd == DSP_DGASP)
10880 + dprintf(0,"\n GASP!!! \n");
10882 + if(cmd == DSP_XMITBITSWAP)
10884 + dslhal_support_aocBitSwapProcessing(ptidsl,0);
10886 + if(cmd == DSP_RCVBITSWAP)
10888 + dslhal_support_aocBitSwapProcessing(ptidsl,1);
10890 + if(cmd == DSP_GHSMSG)
10892 + dprintf(3,"Ghs Message Received, bytes: %d \n",tag);
10893 + dprintf(3,"Addr: 0x%x\n",dspOamSharedInterface.ghsDspRxBuf_p);
10894 + if(pollGhsIndex > 9)
10896 + rc = dslhal_support_blockRead((void *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.ghsDspRxBuf_p), &ptidsl->AppData.dsl_ghsRxBuf[pollGhsIndex++][0], tag);
10898 + if(cmd == DSP_CRATES1)
10900 + dprintf(3,"DSP C-Rates1 Data Ready \n");
10901 + rc = dslhal_support_gatherRateMessages(ptidsl);
10903 + if(cmd == DSP_SNR)
10905 + dprintf(3,"DSP SNR Data Ready \n");
10906 + rc = dslhal_support_gatherSnrPerBin(ptidsl,tag);
10908 + if(cmd == DSP_EOC)
10910 + dprintf(3,"DSP_EOC message \n");
10911 + rc = dslhal_support_gatherEocMessages(ptidsl,tag,parm1,parm2);
10914 + if(cmd == DSP_TRAINING_MSGS)
10916 + dprintf(3,"DSP_TRAINING_MSGS \n");
10917 + rc = dslhal_support_gatherAdsl2Messages(ptidsl,tag,parm1,parm2);
10920 + dprintf(6,"dslhal_api_pollTrainingStatus done\n");
10921 + return(ptidsl->AppData.bState);
10923 +} /* end of dslhal_api_pollTrainingStatus() */
10925 +/********************************************************************************************
10926 +* FUNCTION NAME: dslhal_api_handleTrainingInterrupt()
10928 +*********************************************************************************************
10929 +* DESCRIPTION: Code to handle ax5 hardware interrupts
10931 +* Input: tidsl_t *ptidsl
10932 +* int *pMsg, pointer to returned hardware messages. Each byte represent a messge
10933 +* int *pTag, pointer to returned hardware message tags. Each byte represent a tag.
10934 +* Return: 0 success
10937 +********************************************************************************************/
10938 +int dslhal_api_handleTrainingInterrupt(tidsl_t *ptidsl, int intrSource)
10943 + unsigned int msg1;
10944 + unsigned int msg2;
10946 + unsigned int failState;
10947 + static unsigned int interruptGhsIndex=0;
10949 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
10951 + DEV_HOST_tcHostCommDef_t TCHostCommDef;
10953 + dprintf(6,"dslhal_api_handleTrainingInterrupt\n");
10954 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterface_t *) ptidsl->pmainAddr;
10955 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
10956 + sizeof(DEV_HOST_dspOamSharedInterface_t));
10959 + dprintf(1,"dslhal_support_blockRead failed\n");
10960 + return DSLHAL_ERROR_BLOCK_READ;
10963 + dspOamSharedInterface.tcHostComm_p =(DEV_HOST_tcHostCommDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.tcHostComm_p);
10965 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.tcHostComm_p,
10966 + &TCHostCommDef, sizeof(DEV_HOST_tcHostCommDef_t));
10969 + dprintf(1,"dslhal_support_blockRead failed\n");
10970 + return DSLHAL_ERROR_BLOCK_READ;
10974 + if(intrSource & MASK_BITFIELD_INTERRUPTS)
10976 + dspOamSharedInterface.modemStateBitField_p =(DEV_HOST_modemStateBitField_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.modemStateBitField_p);
10977 + rc = dslhal_support_processTrainingState(ptidsl);
10980 + dprintf(0,"Error Reading Modem Training State \n");
10981 + return DSLHAL_ERROR_MODEMSTATE;
10983 + rc = dslhal_support_processModemStateBitField(ptidsl);
10986 + dprintf(0,"Error Reading Modem Training State \n");
10987 + return DSLHAL_ERROR_MODEMSTATE;
10990 + if(intrSource & MASK_MAILBOX_INTERRUPTS)
10993 + rc = dslhal_support_readDelineationState(ptidsl);
10996 + dprintf(0,"Error Reading Delineation State \n");
10997 + return DSLHAL_ERROR_MODEMSTATE;
11000 + while (dslhal_support_readDspMailbox(ptidsl,&cmd, &tag, &parm1, &parm2) == DSLHAL_ERROR_NO_ERRORS )
11002 + dprintf(4,"mailbox message: 0x%x\n", cmd);
11004 + for(rc=0;rc<8;rc++)
11006 + dslhal_support_readTextMailbox(ptidsl,&msg1, &msg2);
11009 + if (cmd == DSP_IDLE)
11011 + dprintf(4,"DSP_IDLE\n");
11012 + ptidsl->lConnected=0;
11013 + hybrid_selected=888;
11014 + if(showtimeFlag == TRUE)
11016 + dslhal_api_resetTrainFailureLog(ptidsl);
11017 + dslhal_support_advancedIdleProcessing(ptidsl);
11018 + showtimeFlag = FALSE;
11020 + failState = (unsigned int)parm1;
11023 + ptidsl->AppData.trainFailStates[ptidsl->AppData.trainFails]=failState;
11024 + ptidsl->AppData.trainFails++;
11025 + if(ptidsl->AppData.trainFails > 30)
11026 + ptidsl->AppData.trainFails=0;
11028 + for(interruptGhsIndex=0;interruptGhsIndex<10;interruptGhsIndex++)
11030 + for(rc=0;rc<62;rc++)
11031 + ptidsl->AppData.dsl_ghsRxBuf[interruptGhsIndex][rc]=0;
11033 + interruptGhsIndex=0;
11035 + /* add code for reload overlay pages */
11036 + if(ptidsl->bAutoRetrain == 0 && ptidsl->bOverlayPageLoaded == 0)
11038 + dslhal_support_restoreTrainingInfo(ptidsl);
11039 + ptidsl->bOverlayPageLoaded = 1;
11041 + /* command DSP to ACTREQ */
11042 + rc = dslhal_support_writeHostMailbox(ptidsl, HOST_ACTREQ, 0, 0, 0);
11044 + return DSLHAL_ERROR_MAILBOX_WRITE;
11046 + if(cmd == DSP_ATM_TC_SYNC)
11048 + dprintf(4,"\nTC_SYNC\n");
11049 + showtimeFlag = TRUE;
11050 + ptidsl->lConnected=1;
11051 + if(ptidsl->bAutoRetrain == 0 && ptidsl->bOverlayPageLoaded == 1)
11053 + dslhal_support_clearTrainingInfo(ptidsl);
11054 + ptidsl->bOverlayPageLoaded = 0;
11057 + if(cmd == DSP_ACTIVE)
11059 + ptidsl->lConnected=0;
11060 + ptidsl->AppData.bState = RSTATE_SHOWTIME;
11061 + dprintf(4,"DSP_ACTIVE");
11062 + dprintf(4,"US Connect Rate: %u \n",ptidsl->AppData.USConRate);
11063 + dprintf(4,"DS Connect Rate: %u \n",ptidsl->AppData.DSConRate);
11065 + if(cmd == DSP_ATM_NO_TC_SYNC)
11067 + dprintf(4,"\nTC_NOSYNC\n");
11068 + ptidsl->lConnected=0;
11069 + /* add code for reload overlay pages */
11071 + if(cmd == DSP_OVERLAY_END)
11073 + dprintf(4,"Overlay Page Done %d \n",tag);
11074 + rc = dslhal_support_checkOverlayPage(ptidsl,tag);
11075 + if(rc == DSLHAL_ERROR_OVERLAY_CORRUPTED)
11077 + dprintf(4,"Overlay Page: %d CORRUPTED \n",tag);
11078 + return(0-DSLHAL_ERROR_OVERLAY_CORRUPTED);
11081 + if(cmd == DSP_HYBRID)
11083 + dprintf(2,"Hybrid Metrics Available\n");
11084 + hybrid_selected = tag;
11086 + if(cmd == DSP_XMITBITSWAP)
11088 + rc = dslhal_support_aocBitSwapProcessing(ptidsl,0);
11090 + if(cmd == DSP_RCVBITSWAP)
11092 + rc = dslhal_support_aocBitSwapProcessing(ptidsl,1);
11094 + if(cmd == DSP_GHSMSG)
11096 + dprintf(3,"Ghs Message Received, bytes: %d \n",tag);
11097 + dprintf(3,"Addr: 0x%x\n",dspOamSharedInterface.ghsDspRxBuf_p);
11098 + if(interruptGhsIndex > 9)
11099 + interruptGhsIndex=0;
11100 + rc = dslhal_support_blockRead((void *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.ghsDspRxBuf_p), &ptidsl->AppData.dsl_ghsRxBuf[interruptGhsIndex++][0], tag);
11102 + if(cmd == DSP_CRATES1)
11104 + dprintf(3,"DSP C-Rates1 Data Ready \n");
11105 + rc = dslhal_support_gatherRateMessages(ptidsl);
11107 + if(cmd == DSP_SNR)
11109 + dprintf(3,"DSP SNR Data Ready \n");
11110 + rc = dslhal_support_gatherSnrPerBin(ptidsl,tag);
11112 + if(cmd == DSP_EOC)
11114 + dprintf(3,"DSP_EOC message \n");
11115 + rc = dslhal_support_gatherEocMessages(ptidsl,tag,parm1,parm2);
11117 + if(cmd == DSP_TRAINING_MSGS)
11119 + dprintf(3,"DSP_TRAINING_MSGS \n");
11120 + rc = dslhal_support_gatherAdsl2Messages(ptidsl,tag,parm1,parm2);
11124 + dslhal_support_readTextMailbox(ptidsl,&msg1, &msg2);
11125 + dprintf(5,"Text Message Part1: 0x%x \t Text Message Part2: 0x%x \n",msg1,msg2);
11127 + dprintf(6,"dslhal_api_handleTrainingInterrupt done\n");
11128 + return(ptidsl->AppData.bState);
11129 +} /* end of dslhal_api_handleTrainingInterrupt() */
11134 +/******************************************************************************************
11135 + * FUNCTION NAME: dslhal_api_dslRetrain(tidsl_t *ptidsl)
11137 + *******************************************************************************************
11138 + * DESCRIPTION: This fuction sends CMD_ACTREQ to the DSP to issue a retrain
11140 + * INPUT: PITIDSLHW_T *ptidsl
11142 + * RETURN: 0 SUCCESS
11145 + *****************************************************************************************/
11146 +unsigned int dslhal_api_dslRetrain(tidsl_t *ptidsl)
11150 + dprintf(5, "dslhal_cfg_dslRetrain \n");
11151 + rc = dslhal_support_writeHostMailbox(ptidsl, HOST_QUIET, 0, 0, 0);
11154 + dprintf(1,"dslhal_cfg_dslRetrain failed\n");
11155 + return DSLHAL_ERROR_CTRL_API_FAILURE;
11157 + return DSLHAL_ERROR_NO_ERRORS;
11160 +/******************************************************************************************
11161 + * FUNCTION NAME: dslhal_api_sendQuiet(tidsl_t *ptidsl)
11163 + *******************************************************************************************
11164 + * DESCRIPTION: This fuction sends the CMD_QUIET message to the DSP
11166 + * INPUT: PITIDSLHW_T *ptidsl
11168 + * RETURN: 0 SUCCESS
11171 + *****************************************************************************************/
11172 +unsigned int dslhal_api_sendQuiet(tidsl_t *ptidsl)
11176 + dprintf(5, "dslhal_api_sendQuiet\n");
11177 + rc = dslhal_support_writeHostMailbox(ptidsl, HOST_QUIET, 0, 0, 0);
11180 + dprintf(1,"dslhal_api_sendQuiet failed\n");
11181 + return DSLHAL_ERROR_CTRL_API_FAILURE;
11183 + return DSLHAL_ERROR_NO_ERRORS;
11186 +/******************************************************************************************
11187 + * FUNCTION NAME: dslhal_api_sendIdle(tidsl_t *ptidsl)
11189 + *******************************************************************************************
11190 + * DESCRIPTION: This fuction sends the CMD_IDLE message to the DSP
11192 + * INPUT: PITIDSLHW_T *ptidsl
11194 + * RETURN: 0 SUCCESS
11197 + *****************************************************************************************/
11198 +unsigned int dslhal_api_sendIdle(tidsl_t *ptidsl)
11202 + dprintf(5, "dslhal_api_sendIdle\n");
11203 + rc = dslhal_support_writeHostMailbox(ptidsl, HOST_IDLE, 0, 0, 0);
11206 + dprintf(1,"dslhal_api_sendIdle failed\n");
11207 + return DSLHAL_ERROR_CTRL_API_FAILURE;
11209 + return DSLHAL_ERROR_NO_ERRORS;
11212 +/******************************************************************************************
11213 + * FUNCTION NAME: dslhal_api_sendDgasp(tidsl_t *ptidsl)
11215 + *******************************************************************************************
11216 + * DESCRIPTION: This fuction sends the HOST_DGASP message to the DSP
11218 + * INPUT: PITIDSLHW_T *ptidsl
11220 + * RETURN: 0 SUCCESS
11223 + *****************************************************************************************/
11224 +unsigned int dslhal_api_sendDgasp(tidsl_t *ptidsl)
11228 + dprintf(5, "dslhal_api_sendDgasp\n");
11229 + rc = dslhal_support_writeHostMailbox(ptidsl, HOST_DGASP, 0, 0, 0);
11232 + dprintf(1,"dslhal_api_sendDgasp failed\n");
11233 + return DSLHAL_ERROR_CTRL_API_FAILURE;
11235 + return DSLHAL_ERROR_NO_ERRORS;
11238 +/******************************************************************************************
11239 +* FUNCTION NAME: dslhal_api_setTrainingMode(tidsl_t *ptidsl,unsigned int trainmode)
11241 +*******************************************************************************************
11242 +* DESCRIPTION: This fuction Sets the Desired Training Mode {None/Multimode/G.dmt/lite
11244 +* INPUT: PITIDSLHW_T *ptidsl
11245 +* unsigned int trainmode :Should be between 0 and 4; 0:No Mode 1:Multimode
11246 +* 2: T1.413, 3:G.dmt, 4: G.lite
11247 +* RETURN: 0 SUCCESS
11250 +*****************************************************************************************/
11251 +unsigned int dslhal_api_setTrainingMode(tidsl_t *ptidsl,unsigned int trainmode)
11253 + DEV_HOST_oamWrNegoParaDef_t NegoPara;
11254 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
11256 + dprintf(5," dslhal_api_setTrainingMode()\n");
11257 + if(trainmode>255)
11259 + dprintf(3,"Invalid Value for Desired Training Mode (must be <255)\n");
11260 + return DSLHAL_ERROR_INVALID_PARAM;
11265 + dprintf(3, "Error: PTIDSL pointer invalid\n");
11266 + return DSLHAL_ERROR_INVALID_PARAM;
11269 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
11270 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
11271 + sizeof(DEV_HOST_dspOamSharedInterface_t));
11274 + dprintf(1,"dslhal_support_blockRead failed\n");
11275 + return DSLHAL_ERROR_BLOCK_READ;
11278 + dspOamSharedInterface.oamWriteNegoParams_p = (DEV_HOST_oamWrNegoParaDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.oamWriteNegoParams_p);
11280 + rc = dslhal_support_blockRead((PVOID) dspOamSharedInterface.oamWriteNegoParams_p,&NegoPara, sizeof(DEV_HOST_oamWrNegoParaDef_t));
11283 + dprintf(1,"dslhal_support_blockRead failed\n");
11284 + return DSLHAL_ERROR_BLOCK_READ;
11286 + /* Enum Translation to maintain backwards compatibility for train modes */
11287 + if(trainmode == DSLTRAIN_MULTI_MODE)
11288 + trainmode = MULTI_MODE;
11289 + if(trainmode == DSLTRAIN_T1413_MODE)
11290 + trainmode = T1413_MODE;
11291 + if(trainmode == DSLTRAIN_GDMT_MODE)
11292 + trainmode = GDMT_MODE;
11294 + NegoPara.stdMode = trainmode;
11295 + dprintf(5,"Train Mode: 0x%x\n",trainmode);
11296 + rc = dslhal_support_blockWrite(&NegoPara,(PVOID)dspOamSharedInterface.oamWriteNegoParams_p, sizeof(DEV_HOST_oamWrNegoParaDef_t));
11298 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
11300 + dprintf(5," dslhal_api_setTrainingMode() Done\n");
11301 + return DSLHAL_ERROR_NO_ERRORS;
11304 +/******************************************************************************************
11305 +* FUNCTION NAME: dslhal_api_getDspVersion
11307 +*******************************************************************************************
11308 +* DESCRIPTION: This routine supply AX5 daugther card DSP version.
11310 +* INPUT: tidsl_t * ptidsl
11311 +* void *pVer, DSP version struct is returned starting at this pointer
11313 +* RETURN: 0 --succeeded
11315 +* Note: See verdef_u.h for version structure definition.
11316 +*****************************************************************************************/
11317 +int dslhal_api_getDspVersion(tidsl_t *ptidsl, void *pVer)
11319 + /* DEV_HOST_dspVersionDef_t dspVersion; */
11320 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
11322 + dprintf(5, "dslhal_api_getDspVersion\n");
11325 + dprintf(3, "Error: PTIDSL pointer invalid\n");
11326 + return DSLHAL_ERROR_INVALID_PARAM;
11329 + return DSLHAL_ERROR_INVALID_PARAM;
11331 + *(unsigned int *) pVer = 0;
11333 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
11335 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
11338 + dprintf(1,"dslhal_support_blockRead failed\n");
11339 + return DSLHAL_ERROR_BLOCK_READ;
11342 + dspOamSharedInterface.datapumpVersion_p = (DEV_HOST_dspVersionDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.datapumpVersion_p);
11343 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.datapumpVersion_p,
11344 + pVer, sizeof(dspVer));
11347 + dprintf(1,"dslhal_support_blockRead failed\n");
11348 + return DSLHAL_ERROR_BLOCK_READ;
11350 + pVer = (DEV_HOST_dspVersionDef_t *)(dslhal_support_byteSwap32((unsigned int)pVer));
11351 + return DSLHAL_ERROR_NO_ERRORS;
11354 +/********************************************************************************************
11355 +* FUNCTION NAME: dslhal_api_gatherStatistics()
11357 +*********************************************************************************************
11358 +* DESCRIPTION: Read statistical infromation from ax5 modem daugter card.
11359 +* Input: tidsl_t *ptidsl
11361 +* Return: 0 success
11364 +********************************************************************************************/
11365 +void dslhal_api_gatherStatistics(tidsl_t * ptidsl)
11367 + int rc,optIdxU,optIdxD,i;
11368 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
11369 + DEV_HOST_dspWrNegoParaDef_t rateparms;
11370 + DEV_HOST_oamWrNegoParaDef_t configParms;
11371 + DEV_HOST_modemStatsDef_t StatisticsDef;
11372 + DEV_HOST_errorStats_t usIntlvError, usFastError, dsIntlvError, dsFastError;
11373 + DEV_HOST_atmStats_t atmStats;
11374 + DEV_HOST_usAtmStats_t usAtmStats0, usAtmStats1;
11375 + DEV_HOST_dsAtmStats_t dsAtmStats0,dsAtmStats1;
11376 + DEV_HOST_dspWrSuperFrameCntDef_t SuperFrameCnt;
11377 + DEV_HOST_msg_t atuc_msg, aturMsg;
11378 + DEV_HOST_eocVarDef_t eocVar;
11379 + DEV_HOST_dspWrSharedTables_t sharedTables;
11380 + DEV_HOST_phyPerf_t phyPerf;
11381 + unsigned char usBits[64],dsBits[256];
11382 + unsigned char dsPowerCutBack;
11383 + int usNumLoadedTones=0, dsNumLoadedTones=0;
11385 + dprintf(5, "dslhal_api_gatherStatistics\n");
11387 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
11389 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
11390 + sizeof(DEV_HOST_dspOamSharedInterface_t));
11393 + dprintf(1,"dslhal_support_blockRead failed\n");
11396 + if(!ptidsl->bStatisticsInitialized && ptidsl->lConnected == LINE_CONNECTED)
11398 + dslhal_api_initStatistics(ptidsl);
11399 + ptidsl->bStatisticsInitialized = TRUE;
11402 + dspOamSharedInterface.dspWriteNegoParams_p = (DEV_HOST_dspWrNegoParaDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspWriteNegoParams_p);
11404 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspWriteNegoParams_p,
11405 + &rateparms, sizeof(DEV_HOST_dspWrNegoParaDef_t));
11409 + dprintf(1,"dslhal_support_blockRead failed\n");
11414 + /* trained mode */
11415 + ptidsl->AppData.dsl_modulation = (unsigned int)rateparms.trainMode;
11416 + if(rateparms.trainMode == T1413_MODE)
11417 + ptidsl->AppData.dsl_modulation = DSLTRAIN_T1413_MODE;
11418 + if(rateparms.trainMode == GDMT_MODE)
11419 + ptidsl->AppData.dsl_modulation = DSLTRAIN_GDMT_MODE;
11421 + /* shim_osMoveMemory((void *)ptidsl->AppData.bCRates1, (void *)rateparms.cRates1, 120); */
11422 + ptidsl->AppData.bCRates2 = rateparms.cRates2;
11423 + /* shim_osMoveMemory((void *)ptidsl->AppData.bRRates1, (void *)rateparms.rRates1, 44); */
11424 + ptidsl->AppData.bRRates2 = rateparms.rRates2;
11425 + shim_osMoveMemory((void *)ptidsl->AppData.bCMsgs1, (void *)rateparms.cMsgs1, 6);
11426 + shim_osMoveMemory((void *)ptidsl->AppData.bCMsgs2, (void *)rateparms.cMsgs2, 4);
11427 + shim_osMoveMemory((void *)ptidsl->AppData.bRMsgs2, (void *)rateparms.rMsgs2, 4);
11428 + ptidsl->AppData.atucVendorId = (unsigned int)rateparms.atucVendorId;
11429 + ptidsl->AppData.lineLength = (unsigned int)dslhal_support_byteSwap16((unsigned short)rateparms.lineLength);
11430 + ptidsl->AppData.atucRevisionNum = (unsigned int)rateparms.atucGhsRevisionNum;
11431 + ptidsl->AppData.usLineAttn = (ptidsl->AppData.bCMsgs2[3] >>2)&0x003f;
11432 + ptidsl->AppData.usMargin = (ptidsl->AppData.bCMsgs2[2])&0x001f;
11434 + if((rateparms.cRates2 & 0x0f) == 0x01)
11436 + else if((rateparms.cRates2 & 0x0f) == 0x02)
11438 + else if((rateparms.cRates2 & 0x0f) == 0x04)
11440 + else if((rateparms.cRates2 & 0x0f) == 0x08)
11445 + dprintf(5, "optIdxU=%d\n", optIdxU);
11447 + /* Obtain the US Rates using Opt# and CRates1 Table */
11448 + /* Rate(US) = [Bf(LS0) + Bi(LS0)]*32 */
11449 + if(ptidsl->AppData.dsl_modulation <= DSLTRAIN_GLITE_MODE)
11450 + ptidsl->AppData.USConRate = ((rateparms.cRates1[optIdxU][CRATES1_BF_LS0] + rateparms.cRates1[optIdxU][CRATES1_BI_LS0]) * 32);
11452 + ptidsl->AppData.USConRate = 32 * dslhal_support_byteSwap16((unsigned short)rateparms.adsl2USRate);
11454 + ptidsl->AppData.USPeakCellRate = ptidsl->AppData.USConRate;
11456 + if(((rateparms.cRates2 >> 4) & 0x0f) == 0x01)
11458 + else if(((rateparms.cRates2 >> 4) & 0x0f) == 0x02)
11460 + else if(((rateparms.cRates2 >> 4) & 0x0f) == 0x04)
11462 + else if(((rateparms.cRates2 >> 4) & 0x0f) == 0x08)
11466 + /* Obtain the DS Rates using Opt# and CRates1 Table */
11467 + /* Rate(DS) = [Bf(AS0) + Bi(AS0)]*32 */
11468 + if(ptidsl->AppData.dsl_modulation <= DSLTRAIN_GLITE_MODE)
11469 + ptidsl->AppData.DSConRate = (((rateparms.cRates1[optIdxD][CRATES1_BF_AS0]|((rateparms.cRates1[optIdxD][CRATES1_BF_DSRS]&0x80)<<1))+ (rateparms.cRates1[optIdxD][CRATES1_BI_AS0]|((rateparms.cRates1[optIdxD][CRATES1_BI_DSRS]&0x80)<<1)))* 32);
11471 + ptidsl->AppData.DSConRate = dslhal_support_byteSwap16((unsigned short)rateparms.adsl2DSRate);
11473 + dprintf(5, "ptidsl->AppData.wDSConRate=%d\n", ptidsl->AppData.DSConRate);
11474 + /* Determine which Path has Modem Trained with */
11475 + if((rateparms.cRates1[optIdxU][CRATES1_BF_LS0]) && (rateparms.cRates1[optIdxD][CRATES1_BF_AS0]))
11476 + ptidsl->AppData.TrainedPath = FAST_PATH;
11478 + ptidsl->AppData.TrainedPath = INTERLEAVED_PATH;
11480 + /* Set the mode in which the modem is trained */
11481 + ptidsl->AppData.TrainedMode = (unsigned int)rateparms.trainMode;
11482 + if(rateparms.trainMode == T1413_MODE)
11483 + ptidsl->AppData.TrainedMode = DSLTRAIN_T1413_MODE;
11484 + if(rateparms.trainMode == GDMT_MODE)
11485 + ptidsl->AppData.TrainedMode = DSLTRAIN_GDMT_MODE;
11487 + if(ptidsl->AppData.TrainedPath == FAST_PATH)
11488 + ptidsl->AppData.dsFastParityBytesPerSymbol = (rateparms.cRates1[optIdxU][CRATES1_BF_DSRS]&0x1f);
11490 + ptidsl->AppData.dsIntlvParityBytesPerSymbol = (rateparms.cRates1[optIdxU][CRATES1_BI_DSRS]&0x1f);
11491 + ptidsl->AppData.dsSymbolsPerCodeWord = (rateparms.cRates1[optIdxU][CRATES1_BFI_DSS]&0x1f);
11492 + ptidsl->AppData.dsInterleaverDepth = ((rateparms.cRates1[optIdxU][CRATES1_BFI_DSI])|((rateparms.cRates1[optIdxU][CRATES1_BFI_DSS]&0xc0)<<2));
11494 + if(ptidsl->AppData.TrainedPath == FAST_PATH)
11495 + ptidsl->AppData.usFastParityBytesPerSymbol = (rateparms.cRates1[optIdxU][CRATES1_BF_USRS]&0x1f);
11497 + ptidsl->AppData.usIntlvParityBytesPerSymbol = (rateparms.cRates1[optIdxU][CRATES1_BI_USRS]&0x1f);
11498 + ptidsl->AppData.usSymbolsPerCodeWord = (rateparms.cRates1[optIdxU][CRATES1_BFI_USS]&0x1f);
11499 + ptidsl->AppData.usInterleaverDepth = ((rateparms.cRates1[optIdxU][CRATES1_BFI_USI])|((rateparms.cRates1[optIdxU][CRATES1_BFI_USS]&0xc0)<<2));
11502 + dspOamSharedInterface.modemStats_p = (DEV_HOST_modemStatsDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.modemStats_p);
11504 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.modemStats_p,&StatisticsDef, sizeof(DEV_HOST_modemStatsDef_t));
11508 + dprintf(1,"dslhal_support_blockRead failed\n");
11511 + /* Populate the Error Structure Variables */
11513 + /* US Interleave Path Error Statistics */
11515 + /* Change the endianness of the Pointer */
11516 + StatisticsDef.usErrorStatsIntlv_p = (DEV_HOST_errorStats_t *) dslhal_support_byteSwap32((unsigned int)StatisticsDef.usErrorStatsIntlv_p);
11518 + rc = dslhal_support_blockRead((PVOID)StatisticsDef.usErrorStatsIntlv_p,&usIntlvError, (sizeof(DEV_HOST_errorStats_t)));
11523 + /* DS Interleave Path Error Statistics */
11525 + /* Change the endianness of the Pointer */
11526 + StatisticsDef.dsErrorStatsIntlv_p = (DEV_HOST_errorStats_t *) dslhal_support_byteSwap32((unsigned int)StatisticsDef.dsErrorStatsIntlv_p);
11528 + rc = dslhal_support_blockRead((PVOID)StatisticsDef.dsErrorStatsIntlv_p,&dsIntlvError, (sizeof(DEV_HOST_errorStats_t)));
11533 + /* US Fast Path Error Statistics */
11535 + /* Change the endianness of the Pointer */
11536 + StatisticsDef.usErrorStatsFast_p = (DEV_HOST_errorStats_t *) dslhal_support_byteSwap32((unsigned int)StatisticsDef.usErrorStatsFast_p);
11538 + rc = dslhal_support_blockRead((PVOID)StatisticsDef.usErrorStatsFast_p,&usFastError, (sizeof(DEV_HOST_errorStats_t)));
11543 + /* DS Fast Path Error Statistics */
11545 + /* Change the endianness of the Pointer */
11546 + StatisticsDef.dsErrorStatsFast_p = (DEV_HOST_errorStats_t *) dslhal_support_byteSwap32((unsigned int)StatisticsDef.dsErrorStatsFast_p);
11548 + rc = dslhal_support_blockRead((PVOID)StatisticsDef.dsErrorStatsFast_p,&dsFastError, (sizeof(DEV_HOST_errorStats_t)));
11554 + if(ptidsl->AppData.bState > 2)
11556 + /* Get CRC Errors Stats for both US and DS */
11557 + ptidsl->AppData.dsICRC_errors = dslhal_support_byteSwap32((unsigned int)dsIntlvError.crcErrors);
11558 + ptidsl->AppData.dsFCRC_errors = dslhal_support_byteSwap32((unsigned int)dsFastError.crcErrors);
11559 + ptidsl->AppData.usICRC_errors = dslhal_support_byteSwap32((unsigned int)usIntlvError.crcErrors);
11560 + ptidsl->AppData.usFCRC_errors = dslhal_support_byteSwap32((unsigned int)usFastError.crcErrors);
11561 + /* Get FEC Errors Stats for both US and DS */
11562 + ptidsl->AppData.dsIFEC_errors = dslhal_support_byteSwap32((unsigned int)dsIntlvError.fecErrors);
11563 + ptidsl->AppData.dsFFEC_errors = dslhal_support_byteSwap32((unsigned int)dsFastError.fecErrors);
11564 + ptidsl->AppData.usIFEC_errors = dslhal_support_byteSwap32((unsigned int)usIntlvError.fecErrors);
11565 + ptidsl->AppData.usFFEC_errors = dslhal_support_byteSwap32((unsigned int)usFastError.fecErrors);
11566 + /* Get NCD Errors Stats for both US and DS */
11567 + ptidsl->AppData.dsINCD_error = dslhal_support_byteSwap32((unsigned int)dsIntlvError.ncdError);
11568 + ptidsl->AppData.dsFNCD_error = dslhal_support_byteSwap32((unsigned int)dsFastError.ncdError);
11569 + ptidsl->AppData.usINCD_error = dslhal_support_byteSwap32((unsigned int)usIntlvError.ncdError);
11570 + ptidsl->AppData.usFNCD_error = dslhal_support_byteSwap32((unsigned int)usFastError.ncdError);
11571 + /* Get LCD Errors Stats for both US and DS */
11572 + ptidsl->AppData.dsILCD_errors = dslhal_support_byteSwap32((unsigned int)dsIntlvError.lcdErrors);
11573 + ptidsl->AppData.dsFLCD_errors = dslhal_support_byteSwap32((unsigned int)dsFastError.lcdErrors);
11574 + ptidsl->AppData.usILCD_errors = dslhal_support_byteSwap32((unsigned int)usIntlvError.lcdErrors);
11575 + ptidsl->AppData.usFLCD_errors = dslhal_support_byteSwap32((unsigned int)usFastError.lcdErrors);
11576 + /*Get HEC Errors Stats for both US and DS */
11577 + ptidsl->AppData.dsIHEC_errors = dslhal_support_byteSwap32((unsigned int)dsIntlvError.hecErrors);
11578 + ptidsl->AppData.dsFHEC_errors = dslhal_support_byteSwap32((unsigned int)dsFastError.hecErrors);
11579 + ptidsl->AppData.usIHEC_errors = dslhal_support_byteSwap32((unsigned int)usIntlvError.hecErrors);
11580 + ptidsl->AppData.usFHEC_errors = dslhal_support_byteSwap32((unsigned int)usFastError.hecErrors);
11582 + /* Get LOS and SEF error Stats */
11583 + ptidsl->AppData.LOS_errors = dslhal_support_byteSwap32(StatisticsDef.losErrors);
11584 + ptidsl->AppData.SEF_errors = dslhal_support_byteSwap32(StatisticsDef.sefErrors);
11585 + ptidsl->AppData.coLosErrors = dslhal_support_byteSwap32(StatisticsDef.farEndLosErrors);
11586 + ptidsl->AppData.coRdiErrors = dslhal_support_byteSwap32(StatisticsDef.farEndRdiErrors);
11588 + dspOamSharedInterface.atmStats_p = (DEV_HOST_atmStats_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.atmStats_p);
11590 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.atmStats_p,&atmStats, sizeof(DEV_HOST_atmStats_t));
11594 + dprintf(1,"dslhal_support_blockRead failed\n");
11598 + /* Populate the US/DS ATM Stats Variables */
11600 + /* US ATM Statistics */
11602 + /* Change the endianness of the Pointer */
11603 + atmStats.us0_p = (DEV_HOST_usAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.us0_p);
11605 + rc = dslhal_support_blockRead((PVOID)atmStats.us0_p,&usAtmStats0, (sizeof(DEV_HOST_usAtmStats_t)));
11610 + atmStats.us1_p = (DEV_HOST_usAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.us1_p);
11612 + rc = dslhal_support_blockRead((PVOID)atmStats.us1_p,&usAtmStats1, (sizeof(DEV_HOST_usAtmStats_t)));
11617 + /* DS ATM Statistics */
11619 + /* Change the endianness of the Pointer */
11620 + atmStats.ds0_p = (DEV_HOST_dsAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.ds0_p);
11622 + rc = dslhal_support_blockRead((PVOID)atmStats.ds0_p,&dsAtmStats0, (sizeof(DEV_HOST_dsAtmStats_t)));
11626 + atmStats.ds1_p = (DEV_HOST_dsAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.ds1_p);
11628 + rc = dslhal_support_blockRead((PVOID)atmStats.ds1_p,&dsAtmStats1, (sizeof(DEV_HOST_dsAtmStats_t)));
11633 + /* Get ATM Stats for both US and DS for Channel 0*/
11634 + ptidsl->AppData.usAtm_count[0] = dslhal_support_byteSwap32(usAtmStats0.goodCount);
11635 + ptidsl->AppData.usIdle_count[0] = dslhal_support_byteSwap32(usAtmStats0.idleCount);
11637 + ptidsl->AppData.usPdu_count[0] = dslhal_support_byteSwap32(usAtmStats0.pduCount);
11639 + ptidsl->AppData.dsGood_count[0] = dslhal_support_byteSwap32(dsAtmStats0.goodCount);
11640 + ptidsl->AppData.dsIdle_count[0] = dslhal_support_byteSwap32(dsAtmStats0.idleCount);
11642 + ptidsl->AppData.dsPdu_count[0] = dslhal_support_byteSwap32(dsAtmStats0.pduCount);
11644 + ptidsl->AppData.dsBadHec_count[0] = dslhal_support_byteSwap32((dsAtmStats0.badHecCount));
11645 + ptidsl->AppData.dsOVFDrop_count[0] = dslhal_support_byteSwap32((dsAtmStats0.ovflwDropCount));
11646 + /* Get ATM Stats for both US and DS for Channel 1*/
11647 + ptidsl->AppData.usAtm_count[1] = dslhal_support_byteSwap32(usAtmStats1.goodCount);
11648 + ptidsl->AppData.usIdle_count[1] = dslhal_support_byteSwap32(usAtmStats1.idleCount);
11650 + ptidsl->AppData.usPdu_count[1] = dslhal_support_byteSwap32(usAtmStats1.pduCount);
11652 + ptidsl->AppData.dsGood_count[1] = dslhal_support_byteSwap32(dsAtmStats1.goodCount);
11653 + ptidsl->AppData.dsIdle_count[1] = dslhal_support_byteSwap32(dsAtmStats1.idleCount);
11655 + ptidsl->AppData.dsPdu_count[1] = dslhal_support_byteSwap32(dsAtmStats1.pduCount);
11657 + ptidsl->AppData.dsBadHec_count[1] = dslhal_support_byteSwap32((dsAtmStats1.badHecCount));
11658 + ptidsl->AppData.dsOVFDrop_count[1] = dslhal_support_byteSwap32((dsAtmStats1.ovflwDropCount));
11660 + /* Determine the US and DS Superframe Count */
11662 + dspOamSharedInterface.dspWriteSuperFrameCnt_p = (DEV_HOST_dspWrSuperFrameCntDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspWriteSuperFrameCnt_p);
11664 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspWriteSuperFrameCnt_p,&SuperFrameCnt, sizeof(DEV_HOST_dspWrSuperFrameCntDef_t));
11668 + dprintf(1,"dslhal_support_blockRead failed\n");
11671 + ptidsl->AppData.usSuperFrmCnt = dslhal_support_byteSwap32(SuperFrameCnt.wSuperFrameCntUstrm);
11672 + ptidsl->AppData.dsSuperFrmCnt = dslhal_support_byteSwap32(SuperFrameCnt.wSuperFrameCntDstrm);
11674 + /* Determine Frame Mode and Max Frame Mode */
11676 + dspOamSharedInterface.atucMsg_p = (DEV_HOST_msg_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.atucMsg_p);
11678 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.atucMsg_p,&atuc_msg, sizeof(DEV_HOST_msg_t));
11682 + dprintf(1,"dslhal_support_blockRead failed\n");
11686 + ptidsl->AppData.FrmMode = (unsigned int)atuc_msg.framingMode;
11687 + ptidsl->AppData.MaxFrmMode = (unsigned int)atuc_msg.maxFrameMode;
11689 + /* Determine Gross Gain */
11691 + dspOamSharedInterface.aturMsg_p = (DEV_HOST_msg_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.aturMsg_p);
11693 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.aturMsg_p,&aturMsg, sizeof(DEV_HOST_msg_t));
11697 + dprintf(1,"dslhal_support_blockRead failed\n");
11700 + ptidsl->AppData.grossGain = (unsigned int)aturMsg.grossGain;
11702 + /* Determine DS Line Attenuation & Margin */
11703 + dspOamSharedInterface.eocVar_p = (DEV_HOST_eocVarDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.eocVar_p);
11705 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.eocVar_p,&eocVar, sizeof(DEV_HOST_eocVarDef_t));
11709 + dprintf(1,"dslhal_support_blockRead failed\n");
11712 + ptidsl->AppData.dsLineAttn = (unsigned int)eocVar.lineAtten;
11713 + ptidsl->AppData.dsMargin = (unsigned int)eocVar.dsMargin;
11717 + /* Read in the Shared Tables structure */
11718 + dspOamSharedInterface.dspWrSharedTables_p = (DEV_HOST_dspWrSharedTables_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspWrSharedTables_p);
11720 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspWrSharedTables_p,&sharedTables, sizeof(DEV_HOST_dspWrSharedTables_t));
11724 + dprintf(1,"dslhal_support_blockRead failed\n");
11728 + /* Read the ATU-R Bits and Gains Table */
11729 + sharedTables.aturBng_p = (unsigned char *)dslhal_support_byteSwap32((unsigned int)sharedTables.aturBng_p);
11730 + rc = dslhal_support_blockRead((PVOID)sharedTables.aturBng_p,ptidsl->AppData.rBng,255*2*sizeof(unsigned char));
11733 + dprintf(1,"dslhal_support_blockRead failed\n");
11736 + /* Read the ATU-C Bits and Gains Table */
11737 + sharedTables.atucBng_p = (unsigned char *)dslhal_support_byteSwap32((unsigned int)sharedTables.atucBng_p);
11738 + if(ptidsl->netService == 2) /* for Annex_B */
11740 + rc = dslhal_support_blockRead((PVOID)sharedTables.atucBng_p,ptidsl->AppData.cBng,126*sizeof(unsigned char));
11743 + dprintf(1,"dslhal_support_blockRead failed\n");
11746 + for(i=0;i<US_BNG_LENGTH*2;i++)
11748 + for(i=1;i<US_BNG_LENGTH*2;i++)
11750 + usBits[i]=((ptidsl->AppData.cBng[(i-1)*2])&0xf);
11751 + dprintf(5,"Bit #%d : 0x%x\n",i,usBits[i]);
11753 + for(i=1;i<US_BNG_LENGTH*2;i++)
11756 + usNumLoadedTones++;
11761 + rc = dslhal_support_blockRead((PVOID)sharedTables.atucBng_p,ptidsl->AppData.cBng,62*sizeof(unsigned char));
11764 + dprintf(1,"dslhal_support_blockRead failed\n");
11767 + for(i=0;i<US_BNG_LENGTH;i++)
11769 + for(i=1;i<US_BNG_LENGTH;i++)
11771 + usBits[i]=((ptidsl->AppData.cBng[(i-1)*2])&0xf);
11772 + dprintf(5,"Bit #%d : 0x%x\n",i,usBits[i]);
11774 + for(i=1;i<US_BNG_LENGTH;i++)
11777 + usNumLoadedTones++;
11781 + /* Determine Number U/S of Loaded Tones */
11783 + /* U/S Power Computation */
11784 + dspOamSharedInterface.phyPerf_p = (DEV_HOST_phyPerf_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.phyPerf_p);
11785 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.phyPerf_p,
11786 + &phyPerf, sizeof(DEV_HOST_phyPerf_t));
11789 + dprintf(1,"dslhal_support_blockRead failed\n");
11792 + ptidsl->AppData.currentHybridNum = phyPerf.currentHybridNumUsed;
11793 + phyPerf.usAvgGain = dslhal_support_byteSwap32(phyPerf.usAvgGain);
11794 + ptidsl->AppData.usTxPower = LOG43125 + phyPerf.usAvgGain + (256*US_NOMINAL_POWER)+log10[usNumLoadedTones-1];
11795 + dprintf(7,"Avg Gain: 0x%x usNumLoadedTones: 0x%x log: 0x%x\n",phyPerf.usAvgGain, usNumLoadedTones, log10[usNumLoadedTones-1]);
11797 + /* Determine Number D/S of Loaded Tones */
11799 + for(i=0;i<DS_BNG_LENGTH;i++)
11802 + /* ptidsl->AppData.rBng[i-1]=dslhal_support_byteSwap32((unsigned int)ptidsl->AppData.rBng[i-1]);*/
11804 + for(i=1;i<DS_BNG_LENGTH;i++)
11806 + dsBits[i]=((ptidsl->AppData.rBng[(i-1)*2])&0xf);
11807 + dprintf(5,"Bit #%d : 0x%x\n",i,dsBits[i]);
11809 + for(i=1;i<DS_BNG_LENGTH;i++)
11812 + dsNumLoadedTones++;
11814 + /* D/S Power Computation */
11815 + dspOamSharedInterface.phyPerf_p = (DEV_HOST_phyPerf_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.phyPerf_p);
11816 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.phyPerf_p,
11817 + &phyPerf, sizeof(DEV_HOST_phyPerf_t));
11820 + dprintf(1,"dslhal_support_blockRead failed\n");
11823 + /* D/S Power Cutback */
11824 + dsPowerCutBack = (unsigned char)((((ptidsl->AppData.bCMsgs1[0]) >>6) &0x3)+(((ptidsl->AppData.bCMsgs1[1]) &0x1) <<2));
11825 + phyPerf.dsAvgGain = dslhal_support_byteSwap32(phyPerf.dsAvgGain);
11826 + ptidsl->AppData.dsTxPower = LOG43125 + phyPerf.dsAvgGain + (256*((2*(dsPowerCutBack-1))-52)) + log10[dsNumLoadedTones-1];
11827 + dprintf(7,"Avg Gain: %d dsNumLoadedTones: %d log: %d pcb: %d \n",phyPerf.dsAvgGain, dsNumLoadedTones, log10[dsNumLoadedTones-1], dsPowerCutBack);
11828 + /* ds bit allocation */
11829 + sharedTables.bitAllocTblDstrm_p = (unsigned char *)dslhal_support_byteSwap32((unsigned int)sharedTables.bitAllocTblDstrm_p);
11830 + rc = dslhal_support_blockRead((PVOID)sharedTables.bitAllocTblDstrm_p,ptidsl->AppData.BitAllocTblDstrm, 256*sizeof(unsigned char));
11833 + dprintf(1,"dslhal_support_blockRead failed \n");
11837 + /* us bit allocation */
11838 + sharedTables.bitAllocTblUstrm_p = (unsigned char *)dslhal_support_byteSwap32((unsigned int)sharedTables.bitAllocTblUstrm_p);
11839 + rc = dslhal_support_blockRead((PVOID)sharedTables.bitAllocTblUstrm_p,ptidsl->AppData.BitAllocTblUstrm, 32*sizeof(unsigned char));
11842 + dprintf(1,"dslhal_support_blockRead failed \n");
11845 + /* margin per tone */
11846 + sharedTables.marginTblDstrm_p = (signed char *)dslhal_support_byteSwap32((unsigned int)sharedTables.marginTblDstrm_p);
11847 + rc = dslhal_support_blockRead((PVOID)sharedTables.marginTblDstrm_p,ptidsl->AppData.marginTblDstrm, 256*sizeof(signed char));
11850 + dprintf(1,"dslhal_support_blockRead failed \n");
11853 + /* Read Configured Options */
11854 + dspOamSharedInterface.oamWriteNegoParams_p = (DEV_HOST_oamWrNegoParaDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.oamWriteNegoParams_p);
11856 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.oamWriteNegoParams_p,
11857 + &configParms, sizeof(DEV_HOST_oamWrNegoParaDef_t));
11861 + dprintf(1,"dslhal_support_blockRead failed\n");
11867 + ptidsl->AppData.StdMode = (unsigned int)configParms.stdMode;
11868 + if(configParms.stdMode == T1413_MODE)
11869 + ptidsl->AppData.StdMode = DSLTRAIN_T1413_MODE;
11870 + if(configParms.stdMode == GDMT_MODE)
11871 + ptidsl->AppData.StdMode = DSLTRAIN_GDMT_MODE;
11872 + if(configParms.stdMode == MULTI_MODE)
11873 + ptidsl->AppData.StdMode = DSLTRAIN_MULTI_MODE;
11875 + shim_osMoveMemory((void *)ptidsl->AppData.bRMsgs1, (void *)configParms.rMsgs1, 6*sizeof(char));
11876 + if((ptidsl->AppData.bRMsgs1[2] & 0x02) == 0x02)
11878 + dprintf(7,"Trellis!\n");
11879 + ptidsl->configFlag |= CONFIG_FLAG_TRELLIS;
11882 + ptidsl->configFlag &= ~CONFIG_FLAG_TRELLIS;
11883 + if(ptidsl->AppData.bRMsgs1[2]&0x01)
11884 + ptidsl->configFlag |= CONFIG_FLAG_EC;
11886 + ptidsl->configFlag &= ~CONFIG_FLAG_EC;
11892 +/********************************************************************************************
11893 +* FUNCTION NAME: dslhal_api_initStatistics()
11895 +*********************************************************************************************
11896 +* DESCRIPTION: init statistical information of ax5 modem daugter card.
11898 +* Input: tidsl_t *ptidsl
11902 +********************************************************************************************/
11903 +void dslhal_api_initStatistics(tidsl_t * ptidsl)
11906 + /*TCHostCommDef TCHostCommParms; */
11907 + int optIdxU, optIdxD;
11908 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
11909 + DEV_HOST_dspWrNegoParaDef_t rateparms;
11910 + DEV_HOST_modemStatsDef_t StatisticsDef;
11911 + DEV_HOST_errorStats_t usIntlvError, usFastError, dsIntlvError, dsFastError;
11912 + DEV_HOST_atmStats_t atmStats;
11913 + DEV_HOST_usAtmStats_t usAtmStats0, usAtmStats1;
11914 + DEV_HOST_dsAtmStats_t dsAtmStats0,dsAtmStats1;
11915 + DEV_HOST_dspWrSuperFrameCntDef_t SuperFrameCnt;
11916 + DEV_HOST_msg_t atuc_msg, aturMsg;
11917 + DEV_HOST_eocVarDef_t eocVar;
11919 + dprintf(5, "dslhal_api_initStatistics\n");
11921 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterface_t *) ptidsl->pmainAddr;
11922 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
11925 + dprintf(1,"dslhal_support_blockRead failed\n");
11928 + dspOamSharedInterface.dspWriteNegoParams_p = (DEV_HOST_dspWrNegoParaDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspWriteNegoParams_p);
11930 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspWriteNegoParams_p,&rateparms, sizeof(DEV_HOST_dspWrNegoParaDef_t));
11934 + dprintf(1,"dslhal_support_blockRead failed\n");
11939 + /* shim_osMoveMemory((void *)ptidsl->AppData.bCRates1, (void *)rateparms.cRates1, SIZE_OF_CRATES1_TABLE); */
11940 + ptidsl->AppData.bCRates2 = rateparms.cRates2;
11941 + /* shim_osMoveMemory((void *)ptidsl->AppData.bRRates1, (void *)rateparms.rRates1, 44); */
11942 + ptidsl->AppData.bRRates2 = rateparms.rRates2;
11943 + shim_osMoveMemory((void *)ptidsl->AppData.bCMsgs1, (void *)rateparms.cMsgs1, 6);
11944 + shim_osMoveMemory((void *)ptidsl->AppData.bCMsgs2, (void *)rateparms.cMsgs2, 4);
11945 + shim_osMoveMemory((void *)ptidsl->AppData.bRMsgs2, (void *)rateparms.rMsgs2, 4);
11947 + ptidsl->AppData.atucVendorId = dslhal_support_byteSwap32((unsigned int)rateparms.atucVendorId);
11948 + ptidsl->AppData.lineLength = (unsigned int)dslhal_support_byteSwap16((unsigned short)rateparms.lineLength);
11949 + ptidsl->AppData.atucRevisionNum = rateparms.atucGhsRevisionNum;
11950 + ptidsl->AppData.usLineAttn = (ptidsl->AppData.bCMsgs2[3] >>2)&0x003f;
11951 + ptidsl->AppData.usMargin = (ptidsl->AppData.bCMsgs2[2])&0x001f;
11953 + /* Get the UpStream Connection Rate */
11954 + /* Based on the Bit Pattern Get the Opt# */
11955 + if((rateparms.cRates2 & 0x0f) == 0x01)
11957 + else if((rateparms.cRates2 & 0x0f) == 0x02)
11959 + else if((rateparms.cRates2 & 0x0f) == 0x04)
11961 + else if((rateparms.cRates2 & 0x0f) == 0x08)
11965 + dprintf(5, "optIdxU=%d\n", optIdxU);
11966 + /* Obtain the US Rates using Opt# and CRates1 Table */
11967 + /* Rate(US) = [Bf(LS0) + Bi(LS0)]*32 */
11968 + if(ptidsl->AppData.dsl_modulation <= DSLTRAIN_GLITE_MODE)
11969 + ptidsl->AppData.USConRate = ((rateparms.cRates1[optIdxU][CRATES1_BF_LS0] + rateparms.cRates1[optIdxU][CRATES1_BI_LS0]) * 32);
11971 + ptidsl->AppData.USConRate = dslhal_support_byteSwap16((unsigned short)rateparms.adsl2USRate);
11972 + ptidsl->AppData.USPeakCellRate = ptidsl->AppData.USConRate;
11974 + /* Get the DownStream Connection Rate */
11975 + /* Based on the Bit Pattern Get the Opt# */
11976 + if(((rateparms.cRates2 >> 4) & 0x0f) == 0x01)
11978 + else if(((rateparms.cRates2 >> 4) & 0x0f) == 0x02)
11980 + else if(((rateparms.cRates2 >> 4) & 0x0f) == 0x04)
11982 + else if(((rateparms.cRates2 >> 4) & 0x0f) == 0x08)
11986 + /* Obtain the DS Rates using Opt# and CRates1 Table */
11987 + /* Rate(DS) = [Bf(AS0) + Bi(AS0)]*32 */
11988 + if(ptidsl->AppData.dsl_modulation <= DSLTRAIN_GLITE_MODE)
11989 + ptidsl->AppData.DSConRate = (((rateparms.cRates1[optIdxD][CRATES1_BF_AS0]|((rateparms.cRates1[optIdxD][CRATES1_BF_DSRS]&0x80)<<1))+ (rateparms.cRates1[optIdxD][CRATES1_BI_AS0]|((rateparms.cRates1[optIdxD][CRATES1_BI_DSRS]&0x80)<<1)))* 32);
11991 + ptidsl->AppData.DSConRate = dslhal_support_byteSwap16((unsigned short)rateparms.adsl2DSRate);
11992 + dprintf(5, "ptidsl->AppData.wDSConRate=%d\n", ptidsl->AppData.DSConRate);
11993 + /* Determine which Path has Modem Trained with */
11994 + if((rateparms.cRates1[optIdxU][CRATES1_BF_LS0]) && (rateparms.cRates1[optIdxD][CRATES1_BF_AS0]))
11995 + ptidsl->AppData.TrainedPath = FAST_PATH;
11997 + ptidsl->AppData.TrainedPath = INTERLEAVED_PATH;
11999 + /* Set the mode in which the modem is trained */
12000 + ptidsl->AppData.TrainedMode = (unsigned int)rateparms.trainMode;
12001 + if(rateparms.trainMode == T1413_MODE)
12002 + ptidsl->AppData.TrainedMode = DSLTRAIN_T1413_MODE;
12003 + if(rateparms.trainMode == GDMT_MODE)
12004 + ptidsl->AppData.TrainedMode = DSLTRAIN_GDMT_MODE;
12006 + if(ptidsl->AppData.TrainedPath == FAST_PATH)
12007 + ptidsl->AppData.dsFastParityBytesPerSymbol = (rateparms.cRates1[optIdxU][CRATES1_BF_DSRS]&0x1f);
12009 + ptidsl->AppData.dsIntlvParityBytesPerSymbol = (rateparms.cRates1[optIdxU][CRATES1_BI_DSRS]&0x1f);
12010 + ptidsl->AppData.dsSymbolsPerCodeWord = (rateparms.cRates1[optIdxU][CRATES1_BFI_DSS]&0x1f);
12011 + ptidsl->AppData.dsInterleaverDepth = ((rateparms.cRates1[optIdxU][CRATES1_BFI_DSI])|((rateparms.cRates1[optIdxU][CRATES1_BFI_DSS]&0xc0)<<2));
12013 + if(ptidsl->AppData.TrainedPath == FAST_PATH)
12014 + ptidsl->AppData.usFastParityBytesPerSymbol = (rateparms.cRates1[optIdxU][CRATES1_BF_USRS]&0x1f);
12016 + ptidsl->AppData.usIntlvParityBytesPerSymbol = (rateparms.cRates1[optIdxU][CRATES1_BI_USRS]&0x1f);
12017 + ptidsl->AppData.usSymbolsPerCodeWord = (rateparms.cRates1[optIdxU][CRATES1_BFI_USS]&0x1f);
12018 + ptidsl->AppData.usInterleaverDepth = ((rateparms.cRates1[optIdxU][CRATES1_BFI_USI])|((rateparms.cRates1[optIdxU][CRATES1_BFI_USS]&0xc0)<<2));
12021 + /* get the Statistics itself */
12023 + dspOamSharedInterface.modemStats_p = (DEV_HOST_modemStatsDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.modemStats_p);
12025 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.modemStats_p,&StatisticsDef, sizeof(DEV_HOST_modemStatsDef_t));
12029 + dprintf(1,"dslhal_support_blockRead failed\n");
12033 + /* Populate the Error Structure Variables */
12035 + /* US Interleave Path Error Statistics */
12037 + /* Change the endianness of the Pointer */
12038 + StatisticsDef.usErrorStatsIntlv_p = (DEV_HOST_errorStats_t *) dslhal_support_byteSwap32((unsigned int)StatisticsDef.usErrorStatsIntlv_p);
12040 + rc = dslhal_support_blockRead((PVOID)StatisticsDef.usErrorStatsIntlv_p,&usIntlvError, (sizeof(DEV_HOST_errorStats_t)));
12045 + /* DS Interleave Path Error Statistics */
12047 + /* Change the endianness of the Pointer */
12048 + StatisticsDef.dsErrorStatsIntlv_p = (DEV_HOST_errorStats_t *) dslhal_support_byteSwap32((unsigned int)StatisticsDef.dsErrorStatsIntlv_p);
12050 + rc = dslhal_support_blockRead((PVOID)StatisticsDef.dsErrorStatsIntlv_p,&dsIntlvError, (sizeof(DEV_HOST_errorStats_t)));
12055 + /* US Fast Path Error Statistics */
12057 + /* Change the endianness of the Pointer */
12058 + StatisticsDef.usErrorStatsFast_p = (DEV_HOST_errorStats_t *) dslhal_support_byteSwap32((unsigned int)StatisticsDef.usErrorStatsFast_p);
12060 + rc = dslhal_support_blockRead((PVOID)StatisticsDef.usErrorStatsFast_p,&usFastError, (sizeof(DEV_HOST_errorStats_t)));
12066 + /* DS Fast Path Error Statistics */
12068 + /* Change the endianness of the Pointer */
12069 + StatisticsDef.dsErrorStatsFast_p = (DEV_HOST_errorStats_t *) dslhal_support_byteSwap32((unsigned int)StatisticsDef.dsErrorStatsFast_p);
12071 + rc = dslhal_support_blockRead((PVOID)StatisticsDef.dsErrorStatsFast_p,&dsFastError, (sizeof(DEV_HOST_errorStats_t)));
12076 + if(ptidsl->AppData.bState > 2)
12078 + /* Get CRC Errors Stats for both US and DS */
12079 + ptidsl->AppData.dsICRC_errors = dslhal_support_byteSwap32((unsigned int)dsIntlvError.crcErrors);
12080 + ptidsl->AppData.dsFCRC_errors = dslhal_support_byteSwap32((unsigned int)dsFastError.crcErrors);
12081 + ptidsl->AppData.usICRC_errors = dslhal_support_byteSwap32((unsigned int)usIntlvError.crcErrors);
12082 + ptidsl->AppData.usFCRC_errors = dslhal_support_byteSwap32((unsigned int)usFastError.crcErrors);
12083 + /* Get FEC Errors Stats for both US and DS */
12084 + ptidsl->AppData.dsIFEC_errors = dslhal_support_byteSwap32((unsigned int)dsIntlvError.fecErrors);
12085 + ptidsl->AppData.dsFFEC_errors = dslhal_support_byteSwap32((unsigned int)dsFastError.fecErrors);
12086 + ptidsl->AppData.usIFEC_errors = dslhal_support_byteSwap32((unsigned int)usIntlvError.fecErrors);
12087 + ptidsl->AppData.usFFEC_errors = dslhal_support_byteSwap32((unsigned int)usFastError.fecErrors);
12088 + /* Get NCD Errors Stats for both US and DS */
12089 + ptidsl->AppData.dsINCD_error = dslhal_support_byteSwap32((unsigned int)dsIntlvError.ncdError);
12090 + ptidsl->AppData.dsFNCD_error = dslhal_support_byteSwap32((unsigned int)dsFastError.ncdError);
12091 + ptidsl->AppData.usINCD_error = dslhal_support_byteSwap32((unsigned int)usIntlvError.ncdError);
12092 + ptidsl->AppData.usFNCD_error = dslhal_support_byteSwap32((unsigned int)usFastError.ncdError);
12093 + /* Get LCD Errors Stats for both US and DS */
12094 + ptidsl->AppData.dsILCD_errors = dslhal_support_byteSwap32((unsigned int)dsIntlvError.lcdErrors);
12095 + ptidsl->AppData.dsFLCD_errors = dslhal_support_byteSwap32((unsigned int)dsFastError.lcdErrors);
12096 + ptidsl->AppData.usILCD_errors = dslhal_support_byteSwap32((unsigned int)usIntlvError.lcdErrors);
12097 + ptidsl->AppData.usFLCD_errors = dslhal_support_byteSwap32((unsigned int)usFastError.lcdErrors);
12098 + /*Get HEC Errors Stats for both US and DS */
12099 + ptidsl->AppData.dsIHEC_errors = dslhal_support_byteSwap32((unsigned int)dsIntlvError.hecErrors);
12100 + ptidsl->AppData.dsFHEC_errors = dslhal_support_byteSwap32((unsigned int)dsFastError.hecErrors);
12101 + ptidsl->AppData.usIHEC_errors = dslhal_support_byteSwap32((unsigned int)usIntlvError.hecErrors);
12102 + ptidsl->AppData.usFHEC_errors = dslhal_support_byteSwap32((unsigned int)usFastError.hecErrors);
12104 + /* Get LOS and SEF error Stats */
12105 + ptidsl->AppData.LOS_errors = dslhal_support_byteSwap32(StatisticsDef.losErrors);
12106 + ptidsl->AppData.SEF_errors = dslhal_support_byteSwap32(StatisticsDef.sefErrors);
12107 + ptidsl->AppData.coLosErrors = dslhal_support_byteSwap32(StatisticsDef.farEndLosErrors);
12108 + ptidsl->AppData.coRdiErrors = dslhal_support_byteSwap32(StatisticsDef.farEndRdiErrors);
12110 + dspOamSharedInterface.atmStats_p = (DEV_HOST_atmStats_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.atmStats_p);
12112 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.atmStats_p,&atmStats, sizeof(DEV_HOST_atmStats_t));
12116 + dprintf(1,"dslhal_support_blockRead failed\n");
12120 + /* Populate the US/DS ATM Stats Variables */
12122 + /* US ATM Statistics */
12124 + /* Change the endianness of the Pointer */
12125 + atmStats.us0_p = (DEV_HOST_usAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.us0_p);
12127 + rc = dslhal_support_blockRead((PVOID)atmStats.us0_p,&usAtmStats0, (sizeof(DEV_HOST_usAtmStats_t)));
12132 + /* Change the endianness of the Pointer */
12133 + atmStats.us1_p = (DEV_HOST_usAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.us1_p);
12135 + rc = dslhal_support_blockRead((PVOID)atmStats.us1_p,&usAtmStats1, (sizeof(DEV_HOST_usAtmStats_t)));
12141 + /* DS ATM Statistics */
12143 + /* Change the endianness of the Pointer */
12144 + atmStats.ds0_p = (DEV_HOST_dsAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.ds0_p);
12146 + rc = dslhal_support_blockRead((PVOID)atmStats.ds0_p,&dsAtmStats0, (sizeof(DEV_HOST_dsAtmStats_t)));
12151 + /* Change the endianness of the Pointer */
12152 + atmStats.ds1_p = (DEV_HOST_dsAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.ds1_p);
12154 + rc = dslhal_support_blockRead((PVOID)atmStats.ds1_p,&dsAtmStats1, (sizeof(DEV_HOST_dsAtmStats_t)));
12158 + /* Get ATM Stats for both US and DS Channel 0*/
12159 + ptidsl->AppData.usAtm_count[0] = dslhal_support_byteSwap32(usAtmStats0.goodCount);
12160 + ptidsl->AppData.usIdle_count[0] = dslhal_support_byteSwap32(usAtmStats0.idleCount);
12162 + ptidsl->AppData.usPdu_count[0] = dslhal_support_byteSwap32(usAtmStats0.pduCount);
12164 + ptidsl->AppData.dsGood_count[0] = dslhal_support_byteSwap32(dsAtmStats0.goodCount);
12165 + ptidsl->AppData.dsIdle_count[0] = dslhal_support_byteSwap32(dsAtmStats0.idleCount);
12167 + ptidsl->AppData.dsPdu_count[0] = dslhal_support_byteSwap32(dsAtmStats0.pduCount);
12169 + ptidsl->AppData.dsBadHec_count[0] = dslhal_support_byteSwap32((dsAtmStats0.badHecCount));
12170 + ptidsl->AppData.dsOVFDrop_count[0] = dslhal_support_byteSwap32((dsAtmStats0.ovflwDropCount));
12172 + /* Get ATM Stats for both US and DS Channel 1*/
12173 + ptidsl->AppData.usAtm_count[1] = dslhal_support_byteSwap32(usAtmStats1.goodCount);
12174 + ptidsl->AppData.usIdle_count[1] = dslhal_support_byteSwap32(usAtmStats1.idleCount);
12176 + ptidsl->AppData.usPdu_count[1] = dslhal_support_byteSwap32(usAtmStats1.pduCount);
12178 + ptidsl->AppData.dsGood_count[1] = dslhal_support_byteSwap32(dsAtmStats1.goodCount);
12179 + ptidsl->AppData.dsIdle_count[1] = dslhal_support_byteSwap32(dsAtmStats1.idleCount);
12181 + ptidsl->AppData.dsPdu_count[1] = dslhal_support_byteSwap32(dsAtmStats1.pduCount);
12183 + ptidsl->AppData.dsBadHec_count[1] = dslhal_support_byteSwap32((dsAtmStats1.badHecCount));
12184 + ptidsl->AppData.dsOVFDrop_count[1] = dslhal_support_byteSwap32((dsAtmStats1.ovflwDropCount));
12187 + /* Determine the US and DS Superframe Count */
12189 + dspOamSharedInterface.dspWriteSuperFrameCnt_p = (DEV_HOST_dspWrSuperFrameCntDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspWriteSuperFrameCnt_p);
12191 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspWriteSuperFrameCnt_p,&SuperFrameCnt, sizeof(DEV_HOST_dspWrSuperFrameCntDef_t));
12195 + dprintf(1,"dslhal_support_blockRead failed\n");
12199 + ptidsl->AppData.usSuperFrmCnt = dslhal_support_byteSwap32(SuperFrameCnt.wSuperFrameCntUstrm);
12200 + ptidsl->AppData.dsSuperFrmCnt = dslhal_support_byteSwap32(SuperFrameCnt.wSuperFrameCntDstrm);
12202 + /* Determine Frame Mode and Max Frame Mode */
12204 + dspOamSharedInterface.atucMsg_p = (DEV_HOST_msg_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.atucMsg_p);
12206 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.atucMsg_p,&atuc_msg, sizeof(DEV_HOST_msg_t));
12210 + dprintf(1,"dslhal_support_blockRead failed\n");
12214 + ptidsl->AppData.FrmMode = (unsigned int)atuc_msg.framingMode;
12215 + ptidsl->AppData.MaxFrmMode = (unsigned int)atuc_msg.maxFrameMode;
12217 + /* Determine Gross Gain */
12219 + dspOamSharedInterface.aturMsg_p = (DEV_HOST_msg_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.aturMsg_p);
12221 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.aturMsg_p,&aturMsg, sizeof(DEV_HOST_msg_t));
12225 + dprintf(1,"dslhal_support_blockRead failed\n");
12228 + ptidsl->AppData.grossGain = (unsigned int)aturMsg.grossGain;
12229 + /* Determine DS Line Attenuation & Margin */
12230 + dspOamSharedInterface.eocVar_p = (DEV_HOST_eocVarDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.eocVar_p);
12232 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.eocVar_p,&eocVar, sizeof(DEV_HOST_eocVarDef_t));
12236 + dprintf(1,"dslhal_support_blockRead failed\n");
12240 + ptidsl->AppData.dsLineAttn = (unsigned int)eocVar.lineAtten;
12241 + ptidsl->AppData.dsMargin = (unsigned int)eocVar.dsMargin;
12244 +#if __HOST_FORINTERNALUSEONLY_R_H__
12245 + ptidsl->AppData.BER = dslhal_INTERNAL_computeAtmBitErrorRate(ptidsl);
12247 + dprintf(5, "initstatistics done\n");
12251 +/******************************************************************************************
12252 + * FUNCTION NAME: dslhal_api_disableLosAlarm(tidsl_t *ptidsl,unsigned int set)
12254 + *******************************************************************************************
12255 + * DESCRIPTION: This fuction enables/disables all the LOS alarms
12257 + * INPUT: PITIDSLHW_T *ptidsl
12258 + * unsigned int set; //if set is TRUE: LOS Alarms are disabled else enabled
12259 + * RETURN: 0 SUCCESS
12261 + * NOTES: Currently not supported in any version other than MR4 Patch release..
12262 + *****************************************************************************************/
12263 +unsigned int dslhal_api_disableLosAlarm(tidsl_t *ptidsl,unsigned int set)
12265 + DEV_HOST_oamWrNegoParaDef_t NegoPara;
12266 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12268 + dprintf(5," dslhal_api_setTrainingMode()\n");
12271 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12272 + return DSLHAL_ERROR_INVALID_PARAM;
12275 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12276 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
12277 + sizeof(DEV_HOST_dspOamSharedInterface_t));
12280 + dprintf(1,"dslhal_support_blockRead failed\n");
12281 + return DSLHAL_ERROR_BLOCK_READ;
12284 + dspOamSharedInterface.oamWriteNegoParams_p = (DEV_HOST_oamWrNegoParaDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.oamWriteNegoParams_p);
12286 + rc = dslhal_support_blockRead((PVOID) dspOamSharedInterface.oamWriteNegoParams_p,&NegoPara, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12289 + dprintf(1,"dslhal_support_blockRead failed\n");
12290 + return DSLHAL_ERROR_BLOCK_READ;
12294 + NegoPara.disableLosAlarm = TRUE;
12295 + /* NegoPara.marginMonitorTrning = TRUE;
12296 + NegoPara.marginMonitorShwtme = TRUE;*/
12300 + NegoPara.disableLosAlarm = FALSE;
12301 + /* NegoPara.marginMonitorTrning = FALSE;
12302 + NegoPara.marginMonitorShwtme = FALSE;*/
12305 + rc = dslhal_support_blockWrite(&NegoPara,(PVOID)dspOamSharedInterface.oamWriteNegoParams_p, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12307 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
12308 + dprintf(5," dslhal_api_disableLosAlarm() Done\n");
12309 + return DSLHAL_ERROR_NO_ERRORS;
12312 +/******************************************************************************************
12313 + * FUNCTION NAME: dslhal_api_setMarginThreshold(tidsl_t *ptidsl,int threshold)
12315 + *******************************************************************************************
12316 + * DESCRIPTION: This fuction does sets the Margin threshold
12318 + * INPUT: PITIDSLHW_T *ptidsl
12322 + * RETURN: 0 SUCCESS
12325 + *****************************************************************************************/
12326 +unsigned int dslhal_api_setMarginThreshold(tidsl_t *ptidsl, int threshold)
12328 + DEV_HOST_oamWrNegoParaDef_t NegoPara;
12329 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12332 + dprintf(5," dslhal_ctrl_setThreshold()\n");
12336 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12337 + return DSLHAL_ERROR_INVALID_PARAM;
12340 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12342 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12345 + dprintf(1,"dslhal_support_blockRead failed\n");
12346 + return DSLHAL_ERROR_BLOCK_READ;
12349 + dspOamSharedInterface.oamWriteNegoParams_p = (DEV_HOST_oamWrNegoParaDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.oamWriteNegoParams_p);
12352 + rc = dslhal_support_blockRead((PVOID) dspOamSharedInterface.oamWriteNegoParams_p,&NegoPara, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12355 + dprintf(1,"dslhal_support_blockRead failed\n");
12356 + return DSLHAL_ERROR_BLOCK_READ;
12359 + NegoPara.marginThreshold = threshold;
12361 + rc = dslhal_support_blockWrite(&NegoPara,dspOamSharedInterface.oamWriteNegoParams_p, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12364 + return DSLHAL_ERROR_MARGIN_API_FAILURE;
12366 + dprintf(5," dslhal_api_setThreshold() Done\n");
12367 + return DSLHAL_ERROR_NO_ERRORS;
12371 +/******************************************************************************************
12372 + * FUNCTION NAME: dslhal_api_setMonitorFlags(tidsl_t *ptidsl, unsigned int trainflag,unsigned int shwtflag)
12374 + *******************************************************************************************
12375 + * DESCRIPTION: This fuction does sets the Margin monitoring flag
12377 + * INPUT: PITIDSLHW_T *ptidsl
12378 + * unsigned int trainflag
12379 + * unsigned int shwtflag
12381 + * RETURN: 0 SUCCESS
12384 + *****************************************************************************************/
12385 +unsigned int dslhal_api_setMarginMonitorFlags(tidsl_t *ptidsl,unsigned int trainflag,unsigned int shwtflag)
12387 + DEV_HOST_oamWrNegoParaDef_t NegoPara;
12388 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12391 + dprintf(5," dslhal_ctrl_setMonitorFlags()\n");
12395 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12396 + return DSLHAL_ERROR_INVALID_PARAM;
12399 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12401 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12404 + dprintf(1,"dslhal_support_blockRead failed\n");
12405 + return DSLHAL_ERROR_BLOCK_READ;
12408 + dspOamSharedInterface.oamWriteNegoParams_p = (DEV_HOST_oamWrNegoParaDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.oamWriteNegoParams_p);
12411 + rc = dslhal_support_blockRead((PVOID) dspOamSharedInterface.oamWriteNegoParams_p,&NegoPara, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12414 + dprintf(1,"dslhal_support_blockRead failed\n");
12415 + return DSLHAL_ERROR_BLOCK_READ;
12420 + NegoPara.marginMonitorTrning = TRUE;
12424 + NegoPara.marginMonitorTrning = FALSE;
12428 + NegoPara.marginMonitorShwtme = TRUE;
12432 + NegoPara.marginMonitorShwtme = FALSE;
12435 + rc = dslhal_support_blockWrite(&NegoPara,dspOamSharedInterface.oamWriteNegoParams_p, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12437 + return DSLHAL_ERROR_MARGIN_API_FAILURE;
12438 + dprintf(5," dslhal_api_setMonitorFlags() Done\n");
12439 + return DSLHAL_ERROR_NO_ERRORS;
12442 +/******************************************************************************************
12443 + * FUNCTION NAME: dslhal_api_setEocSerialNumber(tidsl_t *ptidsl,char *SerialNum)
12445 + *******************************************************************************************
12446 + * DESCRIPTION: This fuction Sets the eoc Serial Number
12448 + * INPUT: PITIDSLHW_T *ptidsl
12449 + * char *SerialNum : Input eoc Serial Number
12451 + * RETURN: 0 SUCCESS
12454 + *****************************************************************************************/
12455 +unsigned int dslhal_api_setEocSerialNumber(tidsl_t *ptidsl,char *SerialNumber)
12457 + DEV_HOST_eocVarDef_t eocVar;
12458 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12460 + dprintf(5," dslhal_api_setEocSerialNumber()\n");
12464 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12465 + return DSLHAL_ERROR_INVALID_PARAM;
12468 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12470 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12473 + dprintf(1,"dslhal_support_blockRead failed\n");
12474 + return DSLHAL_ERROR_BLOCK_READ;
12477 + dspOamSharedInterface.eocVar_p = (DEV_HOST_eocVarDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.eocVar_p);
12479 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.eocVar_p,
12480 + &eocVar, sizeof(DEV_HOST_eocVarDef_t));
12484 + dprintf(1,"dslhal_support_blockRead failed\n");
12485 + return DSLHAL_ERROR_BLOCK_READ;
12488 + shim_osMoveMemory(eocVar.serialNumber,SerialNumber,32);
12490 + rc= dslhal_support_blockWrite(&eocVar,dspOamSharedInterface.eocVar_p,sizeof(DEV_HOST_eocVarDef_t));
12492 + return DSLHAL_ERROR_EOCREG_API_FAILURE;
12493 + dprintf(5," dslhal_api_setEocSerialNumber() Done\n");
12495 + return DSLHAL_ERROR_NO_ERRORS;
12500 +/******************************************************************************************
12501 + * FUNCTION NAME: dslhal_api_setEocVendorId(tidsl_t *ptidsl,char *VendorID)
12503 + *******************************************************************************************
12504 + * DESCRIPTION: This fuction Sets the eoc Vendor ID
12506 + * INPUT: PITIDSLHW_T *ptidsl
12507 + * char *VendorID : Input eoc Vendor ID
12509 + * RETURN: 0 SUCCESS
12512 + *****************************************************************************************/
12513 +unsigned int dslhal_api_setEocVendorId(tidsl_t *ptidsl,char *VendorID)
12515 + DEV_HOST_oamWrNegoParaDef_t NegoPara;
12516 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12518 + dprintf(5," dslhal_api_setEocVendorId()\n");
12522 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12523 + return DSLHAL_ERROR_INVALID_PARAM;
12526 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12528 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12531 + dprintf(1,"dslhal_support_blockRead failed\n");
12532 + return DSLHAL_ERROR_BLOCK_READ;
12535 + dspOamSharedInterface.oamWriteNegoParams_p = (DEV_HOST_oamWrNegoParaDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.oamWriteNegoParams_p);
12538 + rc = dslhal_support_blockRead((PVOID) dspOamSharedInterface.oamWriteNegoParams_p,&NegoPara, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12541 + dprintf(1,"dslhal_support_blockRead failed\n");
12542 + return DSLHAL_ERROR_BLOCK_READ;
12545 + shim_osMoveMemory(NegoPara.gdmtVendorId,VendorID,8);
12546 + rc= dslhal_support_blockWrite(&NegoPara,dspOamSharedInterface.oamWriteNegoParams_p, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12548 + return DSLHAL_ERROR_EOCREG_API_FAILURE;
12550 + dprintf(5," dslhal_api_setEocVendorId() Done\n");
12551 + return DSLHAL_ERROR_NO_ERRORS;
12554 +/******************************************************************************************
12555 + * FUNCTION NAME: dslhal_api_setEocRevisionNumber(tidsl_t *ptidsl,char *RevNum)
12557 + *******************************************************************************************
12558 + * DESCRIPTION: This fuction Sets the eoc Revision Number
12560 + * INPUT: PITIDSLHW_T *ptidsl
12561 + * char *RevNum : Input eoc Revision Number
12563 + * RETURN: 0 SUCCESS
12566 + *****************************************************************************************/
12567 +unsigned int dslhal_api_setEocRevisionNumber(tidsl_t *ptidsl,char *RevNumber)
12570 + DEV_HOST_eocVarDef_t eocVar;
12571 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12573 + /*add for UR2 test */
12574 + UINT8 selfTestResults[2];
12575 + memset(selfTestResults,0x00,sizeof(selfTestResults));
12576 + /* add for UR2 test */
12577 + dprintf(5," dslhal_api_setEocRevisionNumber()\n");
12581 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12582 + return DSLHAL_ERROR_INVALID_PARAM;
12585 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12587 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12590 + dprintf(1,"dslhal_support_blockRead failed\n");
12591 + return DSLHAL_ERROR_BLOCK_READ;
12594 + dspOamSharedInterface.eocVar_p = (DEV_HOST_eocVarDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.eocVar_p);
12596 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.eocVar_p,
12597 + &eocVar, sizeof(DEV_HOST_eocVarDef_t));
12601 + dprintf(1,"dslhal_support_blockRead failed\n");
12602 + return DSLHAL_ERROR_BLOCK_READ;
12604 + shim_osMoveMemory(eocVar.revNumber,RevNumber,4);
12605 + /* add for UR2 test */
12606 + shim_osMoveMemory(eocVar.dummy,selfTestResults,2);
12607 + /* add for UR2 test */
12608 + rc=dslhal_support_blockWrite(&eocVar,dspOamSharedInterface.eocVar_p,sizeof(DEV_HOST_eocVarDef_t));
12610 + return DSLHAL_ERROR_EOCREG_API_FAILURE;
12611 + dprintf(5," dslhal_api_setEocRevisionNumber Done\n");
12612 + return DSLHAL_ERROR_NO_ERRORS;
12615 +/******************************************************************************************
12616 + * FUNCTION NAME: dslhal_api_setAturConfig(tidsl_t *ptidsl,char *ATURConfig)
12618 + *******************************************************************************************
12619 + * DESCRIPTION: This fuction Sets the eoc ATUR Config Register
12621 + * INPUT: PITIDSLHW_T *ptidsl
12622 + * char *ATURConfig : Input eoc ATUR Config Register
12624 + * RETURN: 0 SUCCESS
12627 + *****************************************************************************************/
12628 +unsigned int dslhal_api_setAturConfig(tidsl_t *ptidsl,char *ATURConfig)
12631 + DEV_HOST_eocVarDef_t eocVar;
12632 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12634 + dprintf(5," dslhal_api_setAturConfig()\n");
12638 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12639 + return DSLHAL_ERROR_INVALID_PARAM;
12642 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12644 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12647 + dprintf(1,"dslhal_support_blockRead failed\n");
12648 + return DSLHAL_ERROR_BLOCK_READ;
12651 + dspOamSharedInterface.eocVar_p = (DEV_HOST_eocVarDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.eocVar_p);
12653 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.eocVar_p,
12654 + &eocVar, sizeof(DEV_HOST_eocVarDef_t));
12658 + dprintf(1,"dslhal_support_blockRead failed\n");
12659 + return DSLHAL_ERROR_BLOCK_READ;
12661 + shim_osMoveMemory(eocVar.aturConfig,ATURConfig,30);
12662 + rc= dslhal_support_blockWrite(&eocVar,dspOamSharedInterface.eocVar_p,sizeof(DEV_HOST_eocVarDef_t));
12664 + return DSLHAL_ERROR_EOCREG_API_FAILURE;
12665 + dprintf(5," dslhal_api_setAturConfig() Done\n");
12666 + return DSLHAL_ERROR_NO_ERRORS;
12670 +/******************************************************************************************
12671 +* FUNCTION NAME: dslhal_api_setRateAdaptFlag(tidsl_t *ptidsl,unsigned int flag)
12673 +*******************************************************************************************
12674 +* DESCRIPTION: This fuction Sets the Rate Adapt Enable Flag
12676 +* INPUT: PITIDSLHW_T *ptidsl
12677 +* unsigned int flag; //if flag = TRUE set rateadapt flag else reset it
12678 +* RETURN: 0 SUCCESS
12681 +*****************************************************************************************/
12682 +unsigned int dslhal_api_setRateAdaptFlag(tidsl_t *ptidsl,unsigned int flag)
12684 + DEV_HOST_msg_t aturMsg;
12685 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12687 + dprintf(5," dslhal_api_setRateAdaptFlag()\n");
12691 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12692 + return DSLHAL_ERROR_INVALID_PARAM;
12695 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12697 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12700 + dprintf(1,"dslhal_support_blockRead failed\n");
12701 + return DSLHAL_ERROR_BLOCK_READ;
12704 + dspOamSharedInterface.aturMsg_p = (DEV_HOST_msg_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.aturMsg_p);
12705 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.aturMsg_p,
12706 + &aturMsg, sizeof(DEV_HOST_msg_t));
12709 + dprintf(1,"dslhal_support_blockRead failed\n");
12710 + return DSLHAL_ERROR_BLOCK_READ;
12714 + aturMsg.rateAdapt = TRUE;
12716 + aturMsg.rateAdapt = FALSE;
12718 + rc= dslhal_support_blockWrite(&aturMsg,dspOamSharedInterface.aturMsg_p,sizeof(DEV_HOST_msg_t));
12720 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
12721 + dprintf(5," dslhal_api_setRateAdaptFlag() Done\n");
12722 + return DSLHAL_ERROR_NO_ERRORS;
12725 +/******************************************************************************************
12726 +* FUNCTION NAME: dslhal_api_setTrellisFlag(tidsl_t *ptidsl,unsigned int flag)
12728 +*******************************************************************************************
12729 +* DESCRIPTION: This fuction Sets the Trellis Coding Enable Flag
12731 +* INPUT: PITIDSLHW_T *ptidsl
12732 +* unsigned int flag; // if flag = TRUE, set trellis flag else reset
12733 +* RETURN: 0 SUCCESS
12736 +*****************************************************************************************/
12737 +unsigned int dslhal_api_setTrellisFlag(tidsl_t *ptidsl,unsigned int flag)
12740 + DEV_HOST_msg_t aturMsg;
12741 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12742 + DEV_HOST_oamWrNegoParaDef_t negoPara;
12744 + dprintf(5," dslhal_api_setTrellisFlag()\n");
12747 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12748 + return DSLHAL_ERROR_INVALID_PARAM;
12750 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12752 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12755 + dprintf(1,"dslhal_support_blockRead failed\n");
12756 + return DSLHAL_ERROR_BLOCK_READ;
12759 + dspOamSharedInterface.aturMsg_p = (DEV_HOST_msg_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.aturMsg_p);
12760 + rc += dslhal_support_blockRead((PVOID)dspOamSharedInterface.aturMsg_p,&aturMsg, sizeof(DEV_HOST_msg_t));
12761 + dspOamSharedInterface.oamWriteNegoParams_p = (DEV_HOST_oamWrNegoParaDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.oamWriteNegoParams_p);
12762 + rc += dslhal_support_blockRead((PVOID) dspOamSharedInterface.oamWriteNegoParams_p,&negoPara, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12765 + dprintf(1,"dslhal_support_blockRead failed\n");
12766 + return DSLHAL_ERROR_BLOCK_READ;
12771 + aturMsg.trellis = TRUE;
12772 + negoPara.rMsgs1[2] |= 0x02;
12776 + aturMsg.trellis = FALSE;
12777 + negoPara.rMsgs1[2] &= 0xFD;
12780 + rc+=dslhal_support_blockWrite(&aturMsg,dspOamSharedInterface.aturMsg_p,sizeof(DEV_HOST_msg_t));
12781 + rc+= dslhal_support_blockWrite(&negoPara,dspOamSharedInterface.oamWriteNegoParams_p, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12783 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
12785 + dprintf(5," dslhal_api_setTrellisFlag() Done\n");
12786 + return DSLHAL_ERROR_NO_ERRORS;
12789 +/******************************************************************************************
12790 +* FUNCTION NAME: dslhal_api_setMaxBitsPerCarrier(tidsl_t *ptidsl,unsigned int maxbits)
12792 +*******************************************************************************************
12793 +* DESCRIPTION: This fuction Sets the Maximum bits per carrier value
12795 +* INPUT: PITIDSLHW_T *ptidsl
12796 +* unsigned int maxbits : should be a value between 0-15
12798 +* RETURN: 0 SUCCESS
12801 +*****************************************************************************************/
12802 +unsigned int dslhal_api_setMaxBitsPerCarrier(tidsl_t *ptidsl,unsigned int maxbits)
12805 + DEV_HOST_msg_t aturMsg;
12806 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12809 + dprintf(5," dslhal_api_setMaxBitsPerCarrier()\n");
12812 + dprintf(3,"Maximum Number of Bits per carrier cannot exceed 15!\n");
12813 + return DSLHAL_ERROR_INVALID_PARAM;
12818 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12819 + return DSLHAL_ERROR_INVALID_PARAM;
12821 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12823 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12826 + dprintf(1,"dslhal_support_blockRead failed\n");
12827 + return DSLHAL_ERROR_BLOCK_READ;
12830 + dspOamSharedInterface.aturMsg_p = (DEV_HOST_msg_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.aturMsg_p);
12831 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.aturMsg_p,
12832 + &aturMsg, sizeof(DEV_HOST_msg_t));
12835 + dprintf(1,"dslhal_support_blockRead failed\n");
12836 + return DSLHAL_ERROR_BLOCK_READ;
12839 + aturMsg.maxBits = maxbits;
12841 + rc=dslhal_support_blockWrite(&aturMsg,dspOamSharedInterface.aturMsg_p,sizeof(DEV_HOST_msg_t));
12843 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
12844 + dprintf(5," dslhal_api_setMaxBitsPerCarrier() Done\n");
12845 + return DSLHAL_ERROR_NO_ERRORS;
12849 +/******************************************************************************************
12850 +* FUNCTION NAME: dslhal_api_setMaxInterleaverDepth(tidsl_t *ptidsl,unsigned int maxdepth)
12852 +*******************************************************************************************
12853 +* DESCRIPTION: This fuction Sets the Maximum Interleave Depth Supported
12855 +* INPUT: PITIDSLHW_T *ptidsl
12856 +* unsigned int maxdepth : Should be between 0 and 3 depending on intlv buffer
12858 +* RETURN: 0 SUCCESS
12861 +*****************************************************************************************/
12862 +unsigned int dslhal_api_setMaxInterleaverDepth(tidsl_t *ptidsl,unsigned int maxdepth)
12864 + DEV_HOST_msg_t aturMsg;
12865 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12867 + dprintf(5," dslhal_api_setMaxInterleaverDepth()\n");
12870 + dprintf(3,"Invalid Value for maximum interleave depth (must be <3)\n");
12871 + return DSLHAL_ERROR_INVALID_PARAM;
12876 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12877 + return DSLHAL_ERROR_INVALID_PARAM;
12879 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12881 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12884 + dprintf(1,"dslhal_support_blockRead failed\n");
12885 + return DSLHAL_ERROR_BLOCK_READ;
12888 + dspOamSharedInterface.aturMsg_p = (DEV_HOST_msg_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.aturMsg_p);
12889 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.aturMsg_p,
12890 + &aturMsg, sizeof(DEV_HOST_msg_t));
12893 + dprintf(1,"dslhal_support_blockRead failed\n");
12894 + return DSLHAL_ERROR_BLOCK_READ;
12897 + aturMsg.maxIntlvDepth = maxdepth;
12899 + rc=dslhal_support_blockWrite(&aturMsg,dspOamSharedInterface.aturMsg_p,sizeof(DEV_HOST_msg_t));
12901 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
12902 + dprintf(5," dslhal_api_setMaxInterleaverDepth() Done\n");
12903 + return DSLHAL_ERROR_NO_ERRORS;
12906 +/********************************************************************************************
12907 +* FUNCTION NAME: dslhal_api_acknowledgeInterrupt()
12909 +*********************************************************************************************
12911 +* Sets the host interrupt bit masks
12913 +* Return: 0 success
12917 +* DSP image is based on LITTLE endian
12919 +********************************************************************************************/
12920 +unsigned int dslhal_api_acknowledgeInterrupt(tidsl_t * ptidsl)
12922 + unsigned int interruptSources=0;
12923 + /* Clear out the DSLSS Interrupt Registers to acknowledge Interrupt */
12924 + if(DSLHAL_REG32(dslhal_support_hostDspAddressTranslate(DSP_INTERRUPT_SOURCE_REGISTER))&MASK_MAILBOX_INTERRUPTS)
12926 + DSLHAL_REG32(dslhal_support_hostDspAddressTranslate(DSP_INTERRUPT_CLEAR_REGISTER))|=MASK_MAILBOX_INTERRUPTS;
12927 + dprintf(5,"Mailbox Interrupt \n");
12929 + if(DSLHAL_REG32(dslhal_support_hostDspAddressTranslate(DSP_INTERRUPT_SOURCE_REGISTER))&MASK_BITFIELD_INTERRUPTS)
12931 + DSLHAL_REG32(dslhal_support_hostDspAddressTranslate(DSP_INTERRUPT_CLEAR_REGISTER))|=MASK_BITFIELD_INTERRUPTS;
12932 + dprintf(5,"Bitfield Interrupt \n");
12934 + if(DSLHAL_REG32(dslhal_support_hostDspAddressTranslate(DSP_INTERRUPT_SOURCE_REGISTER))&MASK_HEARTBEAT_INTERRUPTS)
12936 + DSLHAL_REG32(dslhal_support_hostDspAddressTranslate(DSP_INTERRUPT_CLEAR_REGISTER))|=MASK_HEARTBEAT_INTERRUPTS;
12937 + dprintf(5,"HeartBeat Interrupt \n");
12939 + interruptSources = dslhal_support_parseInterruptSource(ptidsl);
12940 + if(interruptSources < 0)
12941 + return DSLHAL_ERROR_INTERRUPT_FAILURE;
12943 + return interruptSources;
12946 +/********************************************************************************************
12947 +* FUNCTION NAME: dslhal_api_disableDspHybridSelect()
12949 +*********************************************************************************************
12951 +* Sets the host interrupt bit masks
12953 +* Return: 0 success
12957 +* DSP image is based on LITTLE endian
12959 +********************************************************************************************/
12960 +unsigned int dslhal_api_disableDspHybridSelect(tidsl_t * ptidsl,unsigned int disable)
12963 + DEV_HOST_phyPerf_t phyPerf;
12964 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12965 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12967 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12970 + dprintf(1,"dslhal_support_blockRead failed\n");
12971 + return DSLHAL_ERROR_BLOCK_READ;
12974 + dspOamSharedInterface.phyPerf_p = (DEV_HOST_phyPerf_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.phyPerf_p);
12975 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.phyPerf_p,
12976 + &phyPerf, sizeof(DEV_HOST_phyPerf_t));
12979 + dprintf(1,"dslhal_support_blockRead failed\n");
12980 + return DSLHAL_ERROR_BLOCK_READ;
12984 + phyPerf.disableDspHybridSelect_f = TRUE;
12985 + // hybrid_selected = 888;
12989 + phyPerf.disableDspHybridSelect_f = FALSE;
12990 + // hybrid_selected = 888;
12992 + rc=dslhal_support_blockWrite(&phyPerf,dspOamSharedInterface.phyPerf_p,sizeof(DEV_HOST_phyPerf_t));
12994 + return DSLHAL_ERROR_HYBRID_API_FAILURE;
12996 + return DSLHAL_ERROR_NO_ERRORS;
12999 +/********************************************************************************************
13000 +* FUNCTION NAME: dslhal_api_selectHybrid()
13002 +*********************************************************************************************
13004 +* Sets the host interrupt bit masks
13006 +* Return: 0 success
13010 +* DSP image is based on LITTLE endian
13012 +********************************************************************************************/
13013 +unsigned int dslhal_api_selectHybrid(tidsl_t * ptidsl,unsigned int hybridNum)
13016 + DEV_HOST_phyPerf_t phyPerf;
13017 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
13018 + if(hybridNum<1||hybridNum>4)
13020 + dprintf(3,"Invalid Value for Hybrid Number \n");
13021 + return DSLHAL_ERROR_INVALID_PARAM;
13026 + dprintf(3, "Error: PTIDSL pointer invalid\n");
13027 + return DSLHAL_ERROR_INVALID_PARAM;
13029 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
13031 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
13034 + dprintf(1,"dslhal_support_blockRead failed\n");
13035 + return DSLHAL_ERROR_BLOCK_READ;
13038 + dspOamSharedInterface.phyPerf_p = (DEV_HOST_phyPerf_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.phyPerf_p);
13039 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.phyPerf_p,
13040 + &phyPerf, sizeof(DEV_HOST_phyPerf_t));
13043 + dprintf(1,"dslhal_support_blockRead failed\n");
13044 + return DSLHAL_ERROR_BLOCK_READ;
13046 + phyPerf.hostSelectHybridNum = hybridNum;
13047 + rc=dslhal_support_blockWrite(&phyPerf,dspOamSharedInterface.phyPerf_p,sizeof(DEV_HOST_phyPerf_t));
13049 + return DSLHAL_ERROR_HYBRID_API_FAILURE;
13051 + return DSLHAL_ERROR_NO_ERRORS;
13054 +/********************************************************************************************
13055 +* FUNCTION NAME: dslhal_api_reportHybridMetrics()
13057 +*********************************************************************************************
13059 +* Sets the host interrupt bit masks
13061 +* Return: 0 success
13065 +* DSP image is based on LITTLE endian
13067 +********************************************************************************************/
13068 +unsigned int dslhal_api_reportHybridMetrics(tidsl_t * ptidsl,int *metric)
13071 + DEV_HOST_phyPerf_t phyPerf;
13072 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
13073 + if(hybrid_selected>5)
13075 + dprintf(4,"Hybrid Metrics Not Yet Available \n");
13079 + dprintf(3, "Error: PTIDSL pointer invalid\n");
13080 + return (0-DSLHAL_ERROR_INVALID_PARAM);
13082 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
13084 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
13087 + dprintf(1,"dslhal_support_blockRead failed\n");
13088 + return (0-DSLHAL_ERROR_BLOCK_READ);
13091 + dspOamSharedInterface.phyPerf_p = (DEV_HOST_phyPerf_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.phyPerf_p);
13092 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.phyPerf_p,
13093 + &phyPerf, sizeof(DEV_HOST_phyPerf_t));
13096 + dprintf(1,"dslhal_support_blockRead failed\n");
13097 + return (0-DSLHAL_ERROR_BLOCK_READ);
13099 + rc = sizeof(phyPerf.hybridCost);
13100 + for(i=0;i<(rc/4);i++)
13102 + metric[i] = dslhal_support_byteSwap32(phyPerf.hybridCost[i]);
13104 + return hybrid_selected;
13107 +/******************************************************************************************
13108 + * FUNCTION NAME: dslhal_api_selectInnerOuterPair(tidsl_t *ptidsl,unsigned int pairSelect)
13110 + *******************************************************************************************
13111 + * DESCRIPTION: This fuction selects inner/outer pair on RJ11.
13113 + * INPUT: PITIDSLHW_T *ptidsl , unsigned int pairSelect
13115 + * RETURN: 0 SUCCESS
13118 + *****************************************************************************************/
13119 +unsigned int dslhal_api_selectInnerOuterPair(tidsl_t *ptidsl,unsigned int pairSelect)
13123 + dprintf(5, "dslhal_api_sendQuiet\n");
13124 + rc = dslhal_support_writeHostMailbox(ptidsl, HOST_RJ11SELECT, (unsigned int)pairSelect, 0, 0);
13127 + dprintf(1,"dslhal_api_sendQuiet failed\n");
13128 + return DSLHAL_ERROR_CTRL_API_FAILURE;
13130 + return DSLHAL_ERROR_NO_ERRORS;
13133 +/******************************************************************************************
13134 + * FUNCTION NAME: dslhal_api_resetTrainFailureLog(tidsl_t *ptidsl)
13136 + *******************************************************************************************
13137 + * DESCRIPTION: This fuction resets the failed state log stored
13139 + * INPUT: PITIDSLHW_T *ptidsl
13141 + * RETURN: 0 SUCCESS
13144 + *****************************************************************************************/
13145 +unsigned int dslhal_api_resetTrainFailureLog(tidsl_t *ptidsl)
13149 + dprintf(5, "dslhal_api_resetTrainFailureLog \n");
13150 + for(rc=0;rc<ptidsl->AppData.trainFails;rc++)
13152 + ptidsl->AppData.trainFailStates[rc]=0;
13154 + ptidsl->AppData.trainFails = 0;
13155 + return DSLHAL_ERROR_NO_ERRORS;
13158 +/********************************************************************************************
13159 +* FUNCTION NAME: dslhal_api_configureLed()
13161 +*********************************************************************************************
13163 +* Sets the host interrupt bit masks
13165 +* Return: 0 success
13169 +* DSP image is based on LITTLE endian
13171 +********************************************************************************************/
13172 +unsigned int dslhal_api_configureLed(tidsl_t * ptidsl,unsigned int idLed, unsigned int onOff)
13175 + DEV_HOST_modemEnvPublic_t modemEnv;
13176 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
13177 + if(idLed>2 || onOff>2)
13179 + dprintf(3,"Invalid input parameter \n");
13180 + return DSLHAL_ERROR_INVALID_PARAM;
13185 + dprintf(3, "Error: PTIDSL pointer invalid\n");
13186 + return DSLHAL_ERROR_INVALID_PARAM;
13188 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
13190 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
13193 + dprintf(1,"dslhal_support_blockRead failed\n");
13194 + return DSLHAL_ERROR_BLOCK_READ;
13197 + dspOamSharedInterface.modemEnvPublic_p = (DEV_HOST_modemEnvPublic_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.modemEnvPublic_p);
13198 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.modemEnvPublic_p,
13199 + &modemEnv, sizeof(DEV_HOST_modemEnvPublic_t));
13202 + dprintf(1,"dslhal_support_blockRead failed\n");
13203 + return DSLHAL_ERROR_BLOCK_READ;
13205 + if(idLed==ID_DSL_LINK_LED)
13207 + modemEnv.overrideDslLinkLed_f = TRUE;
13209 + modemEnv.dslLinkLedState_f = onOff;
13211 + if(idLed==ID_DSL_ACT_LED)
13213 + modemEnv.overrideDslLinkLed_f = TRUE;
13215 + modemEnv.dslLinkLedState_f = onOff;
13217 + if(idLed==ID_RESTORE_DEFAULT_LED)
13219 + modemEnv.overrideDslLinkLed_f = FALSE;
13220 + modemEnv.overrideDslActLed_f = FALSE;
13222 + rc=dslhal_support_blockWrite(&modemEnv,dspOamSharedInterface.modemEnvPublic_p,sizeof(DEV_HOST_modemEnvPublic_t));
13224 + return DSLHAL_ERROR_MODEMENV_API_FAILURE;
13226 + return DSLHAL_ERROR_NO_ERRORS;
13229 +/********************************************************************************************
13230 +* FUNCTION NAME: dslhal_api_configureExternBert()
13232 +*********************************************************************************************
13234 +* Sets the host interrupt bit masks
13236 +* Return: 0 success
13240 +* DSP image is based on LITTLE endian
13242 +********************************************************************************************/
13243 +unsigned int dslhal_api_configureExternBert(tidsl_t * ptidsl,unsigned int configParm, unsigned int parmVal)
13246 + DEV_HOST_modemEnvPublic_t modemEnv;
13247 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
13248 + if(configParm>1 || parmVal>1)
13250 + dprintf(3,"Invalid input parameter \n");
13251 + return DSLHAL_ERROR_INVALID_PARAM;
13256 + dprintf(3, "Error: PTIDSL pointer invalid\n");
13257 + return DSLHAL_ERROR_INVALID_PARAM;
13259 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
13261 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
13264 + dprintf(1,"dslhal_support_blockRead failed\n");
13265 + return DSLHAL_ERROR_BLOCK_READ;
13268 + dspOamSharedInterface.modemEnvPublic_p = (DEV_HOST_modemEnvPublic_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.modemEnvPublic_p);
13269 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.modemEnvPublic_p,
13270 + &modemEnv, sizeof(DEV_HOST_modemEnvPublic_t));
13273 + dprintf(1,"dslhal_support_blockRead failed\n");
13274 + return DSLHAL_ERROR_BLOCK_READ;
13276 + if(configParm==0)
13278 + modemEnv.externalBert = parmVal;
13280 + if(configParm==1)
13282 + modemEnv.usBertPattern = parmVal;
13284 + rc=dslhal_support_blockWrite(&modemEnv,dspOamSharedInterface.modemEnvPublic_p,sizeof(DEV_HOST_modemEnvPublic_t));
13286 + return DSLHAL_ERROR_MODEMENV_API_FAILURE;
13288 + return DSLHAL_ERROR_NO_ERRORS;
13291 +/********************************************************************************************
13292 +* FUNCTION NAME: dslhal_api_configureAtmBert()
13294 +*********************************************************************************************
13296 +* Sets the host interrupt bit masks
13298 +* Return: 0 success
13302 +* DSP image is based on LITTLE endian
13304 +********************************************************************************************/
13305 +unsigned int dslhal_api_configureAtmBert(tidsl_t * ptidsl,unsigned int configParm, unsigned int parmVal)
13308 + DEV_HOST_atmDsBert_t atmDsBert;
13309 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
13310 + if(configParm>1 || parmVal>1)
13312 + dprintf(3,"Invalid input parameter \n");
13313 + return DSLHAL_ERROR_INVALID_PARAM;
13318 + dprintf(3, "Error: PTIDSL pointer invalid\n");
13319 + return DSLHAL_ERROR_INVALID_PARAM;
13321 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
13323 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
13326 + dprintf(1,"dslhal_support_blockRead failed\n");
13327 + return DSLHAL_ERROR_BLOCK_READ;
13330 + dspOamSharedInterface.atmDsBert_p = (DEV_HOST_atmDsBert_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.atmDsBert_p);
13331 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.atmDsBert_p,
13332 + &atmDsBert, sizeof(DEV_HOST_atmDsBert_t));
13335 + dprintf(1,"dslhal_support_blockRead failed\n");
13336 + return DSLHAL_ERROR_BLOCK_READ;
13338 + if(configParm==0)
13340 + atmDsBert.atmBertFlag = parmVal;
13341 + rc=dslhal_support_blockWrite(&atmDsBert,dspOamSharedInterface.atmDsBert_p,sizeof(DEV_HOST_atmDsBert_t));
13343 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
13345 + if(configParm==1)
13347 + ptidsl->AppData.atmBertBitCountLow = atmDsBert.bitCountLow;
13348 + ptidsl->AppData.atmBertBitCountHigh = atmDsBert.bitCountHigh;
13349 + ptidsl->AppData.atmBertBitErrorCountLow = atmDsBert.bitErrorCountLow;
13350 + ptidsl->AppData.atmBertBitErrorCountHigh = atmDsBert.bitErrorCountHigh;
13352 + return DSLHAL_ERROR_NO_ERRORS;
13355 +/********************************************************************************************
13356 +* FUNCTION NAME: dslhal_api_configureDgaspLpr()
13358 +*********************************************************************************************
13360 +* Configures dying gasp LPR signal
13362 +* Return: 0 success
13366 +* DSP image is based on LITTLE endian
13368 +********************************************************************************************/
13369 +unsigned int dslhal_api_configureDgaspLpr(tidsl_t * ptidsl,unsigned int configParm, unsigned int parmVal)
13372 + DEV_HOST_modemEnvPublic_t modemEnv;
13373 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
13374 + if(configParm>1 || parmVal>1)
13376 + dprintf(3,"Invalid input parameter \n");
13377 + return DSLHAL_ERROR_INVALID_PARAM;
13382 + dprintf(3, "Error: PTIDSL pointer invalid\n");
13383 + return DSLHAL_ERROR_INVALID_PARAM;
13385 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
13387 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
13390 + dprintf(1,"dslhal_support_blockRead failed\n");
13391 + return DSLHAL_ERROR_BLOCK_READ;
13394 + dspOamSharedInterface.modemEnvPublic_p = (DEV_HOST_modemEnvPublic_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.modemEnvPublic_p);
13395 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.modemEnvPublic_p,
13396 + &modemEnv, sizeof(DEV_HOST_modemEnvPublic_t));
13399 + dprintf(1,"dslhal_support_blockRead failed\n");
13400 + return DSLHAL_ERROR_BLOCK_READ;
13402 + if(configParm==0)
13404 + modemEnv.dGaspLprIndicator_f = parmVal;
13406 + if(configParm==1)
13408 + modemEnv.overrideDspLprGasp_f = parmVal;
13410 + rc=dslhal_support_blockWrite(&modemEnv,dspOamSharedInterface.modemEnvPublic_p,sizeof(DEV_HOST_modemEnvPublic_t));
13412 + return DSLHAL_ERROR_MODEMENV_API_FAILURE;
13414 + return DSLHAL_ERROR_NO_ERRORS;
13417 +/********************************************************************************************
13418 +* FUNCTION NAME: dslhal_api_genericDspRead()
13420 +*********************************************************************************************
13422 +* Reads from a Generic Location in the DSP Host Interface
13424 +* Return: 0 success
13428 +* DSP image is based on LITTLE endian
13430 +********************************************************************************************/
13431 +unsigned int dslhal_api_genericDspRead(tidsl_t * ptidsl,unsigned int offset1, unsigned int offset2,
13432 + unsigned int offset3, unsigned char *localBuffer, unsigned int numBytes)
13435 + unsigned int hostIfLoc,structLoc,elementLoc;
13436 + hostIfLoc = (unsigned int)ptidsl->pmainAddr;
13437 + if(numBytes<=0 || !localBuffer || !ptidsl)
13439 + dprintf(3,"Invalid input parameter \n");
13440 + return DSLHAL_ERROR_INVALID_PARAM;
13442 + rc += dslhal_support_blockRead((PVOID)(hostIfLoc+sizeof(int)*offset1), &structLoc,sizeof(int));
13443 + structLoc = dslhal_support_byteSwap32(structLoc);
13444 + rc += dslhal_support_blockRead((PVOID)(structLoc+sizeof(int)*offset2), &elementLoc,sizeof(int));
13445 + elementLoc = dslhal_support_byteSwap32(elementLoc);
13446 + dprintf(3,"Host IF Location: 0x%x Struct1 Location: 0x%x Element Location: 0x%x \n",hostIfLoc, structLoc, elementLoc);
13447 + rc += dslhal_support_blockRead((PVOID)(elementLoc+(offset3*4)), localBuffer,numBytes);
13449 + return DSLHAL_ERROR_BLOCK_READ;
13450 + return DSLHAL_ERROR_NO_ERRORS;
13453 +/********************************************************************************************
13454 +* FUNCTION NAME: dslhal_api_genericDspWrite()
13456 +*********************************************************************************************
13458 +* Writes to a Generic Location in the DSP Host Interface
13460 +* Return: 0 success
13464 +* DSP image is based on LITTLE endian
13466 +********************************************************************************************/
13467 +unsigned int dslhal_api_genericDspWrite(tidsl_t * ptidsl,unsigned int offset1, unsigned int offset2,
13468 + unsigned int offset3, unsigned char *localBuffer, unsigned int numBytes)
13472 + unsigned int hostIfLoc,structLoc,elementLoc;
13473 + hostIfLoc = (unsigned int)ptidsl->pmainAddr;
13474 + if(numBytes<=0 || !localBuffer || !ptidsl)
13476 + dprintf(3,"Invalid input parameter \n");
13477 + return DSLHAL_ERROR_INVALID_PARAM;
13479 + rc += dslhal_support_blockRead((PVOID)(hostIfLoc+(offset1*4)), &structLoc,4);
13480 + structLoc = dslhal_support_byteSwap32(structLoc);
13481 + rc += dslhal_support_blockRead((PVOID)(structLoc+(offset2*4)), &elementLoc,4);
13482 + elementLoc = dslhal_support_byteSwap32(elementLoc);
13483 + dprintf(3,"Host IF Location: 0x%x Struct1 Location: 0x%x Element Location: 0x%x \n",hostIfLoc, structLoc, elementLoc);
13484 + rc += dslhal_support_blockWrite(localBuffer,(PVOID)(elementLoc+(offset3*4)),numBytes);
13486 + return DSLHAL_ERROR_BLOCK_READ;
13487 + return DSLHAL_ERROR_NO_ERRORS;
13490 +/********************************************************************************************
13491 +* FUNCTION NAME: dslhal_api_dspInterfaceRead()
13493 +*********************************************************************************************
13495 +* Reads from a Generic Location in the DSP Host Interface
13497 +* Return: 0 success
13501 +* DSP image is based on LITTLE endian
13503 +********************************************************************************************/
13504 +unsigned int dslhal_api_dspInterfaceRead(tidsl_t * ptidsl,unsigned int baseAddr, unsigned int numOffsets,
13505 + unsigned int *offsets, unsigned char *localBuffer, unsigned int numBytes)
13508 + unsigned int prevAddr,currAddr;
13509 + prevAddr = baseAddr;
13510 + if(numBytes<=0 || !localBuffer || !ptidsl || !offsets)
13512 + dprintf(3,"Invalid input parameter \n");
13513 + return DSLHAL_ERROR_INVALID_PARAM;
13515 + for(off=0;off<numOffsets-1;off++)
13517 + rc += dslhal_support_blockRead((PVOID)(prevAddr+(4*offsets[off])), &currAddr,4);
13518 + currAddr = dslhal_support_byteSwap32(currAddr);
13519 + prevAddr = currAddr;
13520 + dprintf(5,"Curr Addr = 0x%x Current Level: %d \n",currAddr,off);
13522 + currAddr = currAddr + offsets[numOffsets-1]*4;
13523 + rc += dslhal_support_blockRead((PVOID)(currAddr),localBuffer,numBytes);
13525 + return DSLHAL_ERROR_BLOCK_READ;
13526 + return DSLHAL_ERROR_NO_ERRORS;
13529 +/********************************************************************************************
13530 +* FUNCTION NAME: dslhal_api_dspInterfaceWrite()
13532 +*********************************************************************************************
13534 +* Writes to a Generic Location in the DSP Host Interface
13536 +* Return: 0 success
13540 +* DSP image is based on LITTLE endian
13542 +********************************************************************************************/
13543 +unsigned int dslhal_api_dspInterfaceWrite(tidsl_t * ptidsl,unsigned int baseAddr, unsigned int numOffsets,
13544 + unsigned int *offsets,unsigned char *localBuffer, unsigned int numBytes)
13548 + unsigned int prevAddr,currAddr;
13549 + prevAddr = baseAddr;
13550 + if(numBytes<=0 || !localBuffer || !ptidsl || !offsets)
13552 + dprintf(3,"Invalid input parameter \n");
13553 + return DSLHAL_ERROR_INVALID_PARAM;
13555 + for(off=0;off<numOffsets-1;off++)
13557 + rc += dslhal_support_blockRead((PVOID)(prevAddr+(4*offsets[off])), &currAddr,4);
13558 + currAddr = dslhal_support_byteSwap32(currAddr);
13559 + prevAddr = currAddr;
13560 + dprintf(5,"Curr Addr = 0x%x Current Level: %d \n",currAddr,off);
13562 + currAddr = currAddr + offsets[numOffsets-1]*4;
13563 + rc += dslhal_support_blockWrite(localBuffer,(PVOID)(currAddr),numBytes);
13565 + return DSLHAL_ERROR_BLOCK_READ;
13566 + return DSLHAL_ERROR_NO_ERRORS;
13570 +/******************************************************************************************
13571 + * FUNCTION NAME: dslhal_api_sendMailboxCommand(tidsl_t *ptidsl, unsigned int cmd)
13573 + *******************************************************************************************
13574 + * DESCRIPTION: This fuction sends the passed mailbox command to the DSP
13576 + * INPUT: PITIDSLHW_T *ptidsl
13577 + * unsigned int cmd
13579 + * RETURN: 0 SUCCESS
13582 + *****************************************************************************************/
13583 +/* Function is commented out for now since, its not tested */
13584 + /*unsigned int dslhal_api_sendMailboxCommand(tidsl_t *ptidsl, unsigned int cmd)
13588 + dprintf(5, "dslhal_api_sendMailboxCommand\n");
13589 + rc = dslhal_support_writeHostMailbox(ptidsl, cmd, 0, 0, 0);
13592 + dprintf(1,"dslhal_api_sendMailboxCommand failed\n");
13593 + return DSLHAL_ERROR_CTRL_API_FAILURE;
13595 + return DSLHAL_ERROR_NO_ERRORS;
13599 diff -urN linux.old/drivers/atm/sangam_atm/dsl_hal_api.h linux.dev/drivers/atm/sangam_atm/dsl_hal_api.h
13600 --- linux.old/drivers/atm/sangam_atm/dsl_hal_api.h 1970-01-01 01:00:00.000000000 +0100
13601 +++ linux.dev/drivers/atm/sangam_atm/dsl_hal_api.h 2005-07-10 08:02:01.438112272 +0200
13603 +#ifndef __DSL_HAL_API_H__
13604 +#define __DSL_HAL_API_H__ 1
13605 +/*******************************************************************************
13606 +* FILE PURPOSE: DSL HAL to Application Interface for Sangam
13608 +********************************************************************************
13609 +* FILE NAME: dsl_application_interface.h
13612 +* DSL-Application Interface Structures
13615 +* By: Ramakrishnan Parasuraman
13617 +* (C) Copyright 2003, Texas Instruments, Inc.
13619 +* Data Version By Notes
13620 +* 06Feb03 0.00 RamP Initial Version Written
13621 +* 07Apr03 0.01 RamP Commented out typedefs
13622 +* 09Apr03 0.02 RamP Added deviceContext and extended
13623 +* dspVer to include bugfixes
13624 +* 14Apr03 0.03 RamP Added stateTransition to structure
13625 +* 16Apr03 0.04 RamP Removed typedefs; changed dspVer
13626 +* 22Apr03 0.05 RamP Moved acknowledgeInterrupt from
13627 +* (alpha) support module into this
13628 +* 24Apr03 0.06 RamP Moved the RSTATE enum from register
13630 +* 28Apr03 0.07 RamP Added additional parameter to the
13631 +* (alpha +) handleInterrupt function for intrSrc
13632 +* 14May03 0.08 RamP Added hybrid switching APIs
13633 +* (alpha ++) Added statistics fields in AppData
13634 +* Added netService identifier
13635 +* 20May03 0.09 RamP Added Inner/Outer pair API support.
13636 +* Added dying gasp message.
13637 +* 29May03 0.10 RamP Added coProfile structure
13638 +* 04Jun03 0.11 RamP Added margin per tone statistics,
13639 +* Added timing counters, added train
13640 +* failure functions,added config flags
13641 +* 06Jun03 0.12 RamP Added LED, STM Bert, dGasp LPR
13642 +* config API functions
13643 +* 09Jun03 0.13 RamP Added ATM Bert function, CO stats
13644 +* Moved stateTransition to ITIDSLHW
13645 +* (Beta) Moved configFlag to ITIDSLHW,
13646 +* Cleaned up fifoInfo structure
13647 +* Added US/DS R/S FEC parameters
13648 +* 21Aug03 0.14 RamP Added g.hs message buffer, us/ds
13649 +* bits n gains table, negoMsgs struct
13650 +* (act) bitswap stucts/indices, trainstate,
13651 +* Added functions for advanced config
13652 +* Added gross gain and line length
13653 +* 29Sep03 0.15 RamP Added tokens for advanced config
13654 +* module api functions
13655 +* 12Oct03 0.16 RamP Added adsl2Msgs structure with worst
13656 +* case size for variable length msgs
13657 +* Added API function prototypes
13658 +* 21Oct03 0.17 RamP Added typedef for current modem
13660 +* 28Oct03 0.18 RamP Added function to config blackout
13661 +* bitmap in the RMSGPCB message
13662 +* 20Nov03 0.19 RamP Added functions for generic and
13663 +* host interface read - write
13664 +* 24Nov03 0.20 RamP Added enum for detailed state track
13665 +* Added element for state bit fields
13666 +* Addded rState for encoded main state
13667 +* Added blackout valid flag
13668 +* 26Dec03 0.21 RamP Added defines for oamFeature masks
13669 +* 30Dec03 0.22 RamP Increased sizes for cMsgPcb,RMsgPcb
13670 +* to incorporate DELT mode messages
13671 +* 30Dec03 0.23 RamP Added generic mailbox command fxn
13672 +*******************************************************************************/
13674 +#ifdef INTERNAL_BUILD
13675 +#include <dsl_hal_api_pvt.h>
13678 +#define NUM_PAGES 4
13679 +#define OAMFEATURE_AUTORETRAIN_MASK 0x00000001
13680 +#define OAMFEATURE_TC_SYNC_DETECT_MASK 0x00000002
13681 +#define OAMFEATURE_EOCAOC_INTERRUPT_MASK 0x00000004
13682 +#define OAMFEATURE_CONS_DISP_DISABLE_MASK 0x00000008
13683 +#define OAMFEATURE_GHSMSG_INTERRUPT_MASK 0x00000010
13685 +typedef struct tagTIOIDINFO
13687 + unsigned int bState; /* addr->bDSPATURState */
13688 + unsigned int USConRate; /* US Conection Rates */
13689 + unsigned int DSConRate; /* DS Connection Rates */
13690 + unsigned int USPayload; /* ennic_tx_pullup*/
13691 + unsigned int DSPayload; /* ennic_indicate_receive_packet*/
13692 + unsigned int FrmMode; /* addr->atur_msg.framing_mode*/
13693 + unsigned int MaxFrmMode;
13694 + unsigned int TrainedPath; /* Status of the Modem in which trained (Fast or Interleaved Path) */
13695 + unsigned int TrainedMode; /* Status of the mode in which the modem is trained (G.dmt, T1.413, etc) */
13697 + /* Superframe Count */
13698 + unsigned int usSuperFrmCnt; /* Num of US Superframes */
13699 + unsigned int dsSuperFrmCnt; /* Num of DS Superframes */
13701 + /* LOS & SEF Stats */
13702 + unsigned int LOS_errors; /* Num of ADSL frames where loss-of-sync */
13703 + unsigned int SEF_errors; /* Num of severly errored ADSL frames - LOS > MAXBADSYNC ADSL frames */
13704 + unsigned int coLosErrors; /* CO LOS Defects */
13705 + unsigned int coRdiErrors; /* CO RDI defects */
13707 + unsigned int usICRC_errors; /* Num of Upstream CRC errored ADSL frames on Interleaved Path */
13708 + unsigned int usFCRC_errors; /* Num of Upstream CRC errored ADSL frames on Fast Path */
13709 + unsigned int dsICRC_errors; /* Num of Downstream CRC errored ADSL frames on Interleaved Path */
13710 + unsigned int dsFCRC_errors; /* Num of Downstream CRC errored ADSL frames on Fast Path */
13713 + unsigned int usIFEC_errors; /* Num of Upstream FEC errored (corrected) ADSL frames on Interleaved Path */
13714 + unsigned int usFFEC_errors; /* Num of Upstream FEC errored (corrected) ADSL frames on Fast Path */
13715 + unsigned int dsIFEC_errors; /* Num of Downstream FEC errored (corrected) ADSL frames on Interleaved Path */
13716 + unsigned int dsFFEC_errors; /* Num of Downstream FEC errored (corrected) ADSL frames on Fast Path */
13719 + unsigned int usINCD_error; /* UpStream No Cell Delineation on Interleaved Path */
13720 + unsigned int usFNCD_error; /* UpStream No Cell Delineation on Fast Path */
13721 + unsigned int dsINCD_error; /* Downstream No Cell Delineation on Interleaved Path */
13722 + unsigned int dsFNCD_error; /* Downstream No Cell Delineation on Fast Path */
13725 + unsigned int usILCD_errors; /* UpStream Loss of Cell Delineation (within the same connection) on Interleaved Path */
13726 + unsigned int usFLCD_errors; /* UpStream Loss of Cell Delineation (within the same connection) on Fast Path */
13727 + unsigned int dsILCD_errors; /* Downstream Loss of Cell Delineation (within the same connection) on Interleaved Path */
13728 + unsigned int dsFLCD_errors; /* Downstream Loss of Cell Delineation (within the same connection) on Fast Path */
13731 + unsigned int usIHEC_errors; /* Num of Upstream HEC errored ADSL frames on Interleaved Path */
13732 + unsigned int usFHEC_errors; /* Num of Upstream HEC errored ADSL frames on Fast Path */
13733 + unsigned int dsIHEC_errors; /* Num of Downstream HEC errored ADSL frames on Interleaved Path */
13734 + unsigned int dsFHEC_errors; /* Num of Downstream HEC errored ADSL frames on Fast Path */
13736 + /* Upstream ATM Stats */
13737 + unsigned int usAtm_count[2]; /* Upstream Good Cell Count */
13738 + unsigned int usIdle_count[2]; /* Upstream Idle Cell Count */
13739 + unsigned int usPdu_count[2]; /* UpStream PDU Count */
13741 + /* Downstream ATM Stats */
13742 + unsigned int dsGood_count[2]; /* Downstream Good Cell Count */
13743 + unsigned int dsIdle_count[2]; /* Downstream Idle Cell Count */
13744 + unsigned int dsBadHec_count[2]; /* Downstream Bad Hec Cell Count */
13745 + unsigned int dsOVFDrop_count[2]; /* Downstream Overflow Dropped Cell Count */
13746 + unsigned int dsPdu_count[2]; /* Downstream PDU Count */
13747 + /* (only looks for end of pdu on good atm cells received, */
13748 + /* not on Bad_Hec or Overflow cell) */
13750 + unsigned int dsLineAttn; /* DS Line Attenuation */
13751 + unsigned int dsMargin; /* Measured DS MArgin */
13753 + unsigned int usLineAttn;
13754 + unsigned int usMargin;
13756 + unsigned char bCMsgs1[6];
13757 + unsigned char bRMsgs1[6];
13758 + unsigned char bCRates2;
13759 + unsigned char bRRates2;
13760 + unsigned char bRRates1[4][11];
13761 + unsigned char bCMsgs2[4];
13762 + unsigned char bCRates1[4][30];
13763 + unsigned char bRMsgs2[4];
13765 + unsigned int USPeakCellRate;
13767 + unsigned int dsl_status;
13768 + unsigned int dsl_modulation;
13769 + unsigned char dsl_ghsRxBuf[10][64];
13770 + unsigned char dsl_GHS_msg_type[2];
13775 + unsigned int vci_vpi_val;
13777 + unsigned char BitAllocTblDstrm[256];
13778 + unsigned char BitAllocTblUstrm[32];
13779 + signed char marginTblDstrm[256];
13780 + unsigned char rBng[512];
13781 + unsigned char cBng[126];
13784 + short rxSnrPerBin0[256];
13785 + short rxSnrPerBin1[256];
13786 + short rxSnrPerBin2[256];
13788 + unsigned int StdMode;
13789 + unsigned int atucVendorId;
13790 + unsigned char currentHybridNum;
13791 + unsigned char atucRevisionNum;
13792 + unsigned int trainFails;
13793 + unsigned int trainFailStates[30];
13794 + unsigned int idleTick;
13795 + unsigned int initTick;
13796 + unsigned int showtimeTick;
13797 + unsigned char dsFastParityBytesPerSymbol;
13798 + unsigned char dsIntlvParityBytesPerSymbol;
13799 + unsigned char dsSymbolsPerCodeWord;
13800 + unsigned int dsInterleaverDepth;
13801 + unsigned char usFastParityBytesPerSymbol;
13802 + unsigned char usIntlvParityBytesPerSymbol;
13803 + unsigned char usSymbolsPerCodeWord;
13804 + unsigned int usInterleaverDepth;
13805 + unsigned int atmBertBitCountLow;
13806 + unsigned int atmBertBitCountHigh;
13807 + unsigned int atmBertBitErrorCountLow;
13808 + unsigned int atmBertBitErrorCountHigh;
13809 + unsigned int lineLength;
13810 + unsigned int grossGain;
13811 + int rxNoisePower0[256];
13812 + int rxNoisePower1[256];
13813 +}TIOIDINFO,*PTIOIDINFO;
13816 + unsigned char bCMsgs1[6];
13817 + unsigned char bCRates2;
13818 + unsigned char bRRates2;
13819 + unsigned char bRRates1[4][11];
13820 + unsigned char bCMsgs2[4];
13821 + unsigned char bCRates1[4][30];
13822 + unsigned char bCRatesRA[4][30];
13823 + unsigned char bRMsgs2[4];
13824 + unsigned char bRRatesRA[4];
13825 + unsigned char bRMsgsRA[12];
13826 + unsigned char bCMsgsRA[6];
13830 + unsigned char cMsgFmt[2];
13831 + unsigned char rMsgFmt[2];
13832 + unsigned char cMsgPcb[12];
13833 + unsigned char rMsgPcb[70];
13834 + unsigned char dummy1[2];
13835 + unsigned char cMsg1[40];
13836 + unsigned char rMsg1[4];
13837 + unsigned char cMsg2[8];
13838 + unsigned char rMsg2[64];
13839 + unsigned char cParams[264];
13840 + unsigned char rParams[2088];
13841 + unsigned short cMsgPcbLen;
13842 + unsigned short rMsgPcbLen;
13843 + unsigned short cMsg1Len;
13844 + unsigned short rMsg1Len;
13845 + unsigned short cMsg2Len;
13846 + unsigned short rMsg2Len;
13847 + unsigned short cParamsLen;
13848 + unsigned short rParamsLen;
13852 + unsigned char rMsg1Ld[16];
13853 + unsigned char rMsg2Ld[260];
13854 + unsigned char rMsg3Ld[260];
13855 + unsigned char rMsg4Ld[260];
13856 + unsigned char rMsg5Ld[260];
13857 + unsigned char rMsg6Ld[260];
13858 + unsigned char rMsg7Ld[260];
13859 + unsigned char rMsg8Ld[260];
13860 + unsigned char rMsg9Ld[260];
13861 + unsigned char cMsg1Ld[16];
13862 + unsigned char cMsg2Ld[260];
13863 + unsigned char cMsg3Ld[132];
13864 + unsigned char cMsg4Ld[68];
13865 + unsigned char cMsg5Ld[68];
13866 + unsigned short rMsg1LdLen;
13867 + unsigned short rMsgxLdLen;
13868 + unsigned short cMsg1LdLen;
13869 + unsigned short cMsg2LdLen;
13870 + unsigned short cMsg3LdLen;
13871 + unsigned short cMsg4LdLen;
13872 + unsigned short cMsg5LdLen;
13873 + unsigned short dummy8;
13877 + unsigned char trellisFlag;
13878 + unsigned char rateAdaptFlag;
13879 + unsigned char marginMonitorTraining;
13880 + unsigned char marginMonitorShowtime;
13881 + signed char marginThreshold;
13882 + unsigned char disableLosFlag;
13883 + unsigned char aturConfig[30];
13884 + unsigned char eocVendorId[8];
13885 + unsigned char eocSerialNumber[32];
13886 + unsigned char eocRevisionNumber[4];
13887 +}currentPhySettings;
13892 + unsigned int PmemStartWtAddr; /* source address in host memory */
13893 + unsigned int OverlayXferCount; /* number of 32bit words to be transfered */
13894 + unsigned int BinAddr; /* destination address in dsp's pmem */
13895 + unsigned int overlayHostAddr;
13896 + unsigned int olayPageCrc32;
13897 + unsigned int SecOffset;
13902 + unsigned int timeStamp; /* TimeStp revision */
13903 + unsigned char major; /* Major revision */
13904 + unsigned char minor; /* Minor revision */
13905 + unsigned char bugFix; /* BugFix revision */
13906 + unsigned char buildNum; /* BuildNum revision */
13907 + unsigned char reserved; /* for future use */
13911 + unsigned char major;
13912 + unsigned char minor;
13913 + unsigned char bugfix;
13914 + unsigned char buildNum;
13915 + unsigned int timeStamp;
13919 + unsigned char bitSwapCommand[6];
13920 + unsigned char bitSwapBinNum[6];
13921 + unsigned char bitSwapSFrmCnt;
13925 + unsigned int aturState;
13926 + unsigned int subStateIndex;
13927 + unsigned int timeStamp;
13931 + unsigned char ctrlBits;
13932 + unsigned char infoBits;
13947 + ATU_RZERO1 = 100,
13951 + ATU_RRESET = 104,
13952 + GDMT_NSFLR = 105,
13954 + GDMT_SILENT = 107,
13958 + GDMT_QUIET2 = 111,
13959 + ATU_RZERO2 = 200,
13960 + T1413_NSFLR = 201,
13961 + T1413_ACTREQ = 202,
13962 + T1413_ACTMON = 203,
13963 + T1413_FAIL = 204,
13964 + T1413_ACKX = 205,
13965 + T1413_QUIET2 = 206,
13966 + ATU_RQUIET2 = 207,
13967 + ATU_RREVERB1 = 208,
13968 + ATU_RQUIET3 = 209,
13970 + ATU_RREVERB2 = 211,
13971 + ATU_RSEGUE1 = 212,
13972 + ATU_RREVERB3 = 213,
13973 + ATU_RSEGUE2 = 214,
13974 + ATU_RRATES1 = 215,
13975 + ATU_RMSGS1 = 216,
13976 + ATU_RMEDLEY = 217,
13977 + ATU_RREVERB4 = 218,
13978 + ATU_RSEGUE3 = 219,
13979 + ATU_RMSGSRA = 220,
13980 + ATU_RRATESRA = 221,
13981 + ATU_RREVERBRA = 222,
13982 + ATU_RSEGUERA = 223,
13983 + ATU_RMSGS2 = 224,
13984 + ATU_RRATES2 = 225,
13985 + ATU_RREVERB5 = 226,
13986 + ATU_RSEGUE4 = 227,
13988 + ATU_RREVERB6 = 229,
13989 + ATU_RSHOWTIME = 230,
13990 + ATU_RZERO3 = 300,
13991 + ADSL2_QUIET1 = 301,
13992 + ADSL2_COMB1 = 302,
13993 + ADSL2_QUIET2 = 303,
13994 + ADSL2_COMB2 = 304,
13995 + ADSL2_ICOMB1 = 305,
13996 + ADSL2_LINEPROBE = 306,
13997 + ADSL2_QUIET3 = 307,
13998 + ADSL2_COMB3 = 308,
13999 + ADSL2_ICOMB2 = 309,
14000 + ADSL2_RMSGFMT = 310,
14001 + ADSL2_RMSGPCB = 311,
14002 + ADSL2_REVERB1 = 312,
14003 + ADSL2_QUIET4 = 313,
14004 + ADSL2_REVERB2 = 314,
14005 + ADSL2_QUIET5 = 315,
14006 + ADSL2_REVERB3 = 316,
14008 + ADSL2_REVERB4 = 318,
14009 + ADSL2_SEGUE1 = 319,
14010 + ADSL2_REVERB5 = 320,
14011 + ADSL2_SEGUE2 = 321,
14012 + ADSL2_RMSG1 = 322,
14013 + ADSL2_MEDLEY = 323,
14014 + ADSL2_EXCHANGE = 324,
14015 + ADSL2_RMSG2 = 325,
14016 + ADSL2_REVERB6 = 326,
14017 + ADSL2_SEGUE3 = 327,
14018 + ADSL2_RPARAMS = 328,
14019 + ADSL2_REVERB7 = 329,
14020 + ADSL2_SEGUE4 = 330,
14021 + ATU_RZERO4 = 400,
14022 + DELT_SEGUE1 = 401,
14023 + DELT_REVERB5 = 402,
14024 + DELT_SEGUE2 = 403,
14025 + DELT_EXCHANGE = 404,
14026 + DELT_SEGUELD = 405,
14027 + DELT_RMSGLD = 406,
14028 + DELT_QUIET1LD = 407,
14029 + DELT_QUIET2LD = 408,
14030 + DELT_RACK1 = 409,
14031 + DELT_RNACK1 = 410,
14032 + DELT_QUIETLAST = 411
14037 + DSLTRAIN_NO_MODE,
14038 + DSLTRAIN_MULTI_MODE,
14039 + DSLTRAIN_T1413_MODE,
14040 + DSLTRAIN_GDMT_MODE,
14041 + DSLTRAIN_GLITE_MODE
14046 + ID_RESTORE_DEFAULT_LED,
14051 +typedef struct _ITIDSLHW
14053 + /* struct _TIDSL_IHwVtbl * pVtbl; */
14054 + unsigned char* fwimage;
14056 + void* pOsContext;
14057 + unsigned int ReferenceCount;
14058 + unsigned int netService;
14064 + unsigned int lConnected;
14065 + unsigned int bStatisticsInitialized;
14066 + unsigned int rState;
14067 + unsigned int bShutdown;
14068 + unsigned int blackOutValid_f;
14069 + unsigned char blackOutBits[64];
14070 + unsigned int bAutoRetrain;
14071 + volatile unsigned int bOverlayPageLoaded;
14072 + unsigned int stateTransition;
14073 + unsigned int configFlag;
14074 + unsigned int dsBitSwapInx;
14075 + unsigned int usBitSwapInx;
14076 + unsigned int trainStateInx;
14077 + unsigned int usEocMsgInx;
14078 + unsigned int dsEocMsgInx;
14079 + unsigned int reasonForDrop;
14080 + TIOIDINFO AppData;
14083 + OlayDP_Def olayDpPage[NUM_PAGES];
14084 + OlayDP_Def coProfiles;
14085 + OlayDP_Def constDisplay;
14086 + dslBitSwapDef dsBitSwap[30];
14087 + dslBitSwapDef usBitSwap[30];
14088 + trainStateInfo trainHistory[120];
14089 + eocMessageDef usEocMsgBuf[30];
14090 + eocMessageDef dsEocMsgBuf[30];
14091 + adsl2Msgs adsl2TrainingMessages;
14092 + adsl2DeltMsgs adsl2DiagnosticMessages;
14093 + unsigned int modemStateBitField[4];
14094 +#ifdef INTERNAL_BUILD
14095 + internalParameters internalVars;
14097 +} ITIDSLHW_T, *PITIDSLHW_T, tidsl_t;
14100 +/**********************************************************************************
14101 +* API proto type defines
14102 +**********************************************************************************/
14104 +/******************************************************************************************
14105 +* FUNCTION NAME: dslhal_api_dslStartup
14107 +*******************************************************************************************
14108 +* DESCRIPTION: Entry point to initialize and load ax5 daughter board
14110 +* INPUT: PITIDSLHW_T *ppIHw
14112 +* RETURN: 0 --succeeded
14115 +* Notes: external function osAllocateMemory(), osZeroMemory(), osLoadFWImage() are required
14116 +*****************************************************************************************/
14117 +int dslhal_api_dslStartup
14119 + PITIDSLHW_T *ppIHw
14123 +/********************************************************************************************
14124 +* FUNCTION NAME: dslhal_api_gatherStatistics
14126 +*********************************************************************************************
14127 +* DESCRIPTION: Read statistical infromation from ax5 modem daugter card.
14128 +* Input: tidsl_t *ptidsl
14130 +* Return: 0 success
14133 +********************************************************************************************/
14135 +void dslhal_api_gatherStatistics
14141 +/********************************************************************************************
14142 +* FUNCTION NAME: dslhal_api_initStatistics
14144 +*********************************************************************************************
14145 +* DESCRIPTION: init statistical infromation of ax5 modem daugter card.
14147 +* Input: tidsl_t *ptidsl
14151 +********************************************************************************************/
14153 +void dslhal_api_initStatistics
14160 +/******************************************************************************************
14161 +* FUNCTION NAME: dslhal_api_getDslDriverVersion
14163 +*******************************************************************************************
14164 +* DESCRIPTION: This routine supply DSL Driver version.
14166 +* INPUT: tidsl_t * ptidsl
14167 +* void *pVer, DSP Driver Version Pointer
14169 +* RETURN: 0 --succeeded
14171 +* Note: See verdef_u.h for version structure definition.
14172 +*****************************************************************************************/
14174 +void dslhal_api_getDslHalVersion
14179 +/******************************************************************************************
14180 +* FUNCTION NAME: dslhal_api_dslShutdown
14182 +*******************************************************************************************
14183 +* DESCRIPTION: routine to shutdown ax5 modem and free the resource
14185 +* INPUT: tidsl_t *ptidsl
14189 +* Notes: external function osFreeMemory() is required.
14190 +*****************************************************************************************/
14192 +int dslhal_api_dslShutdown
14198 +/******************************************************************************************
14199 +* FUNCTION NAME: dslhal_api_getDspVersion
14201 +*******************************************************************************************
14202 +* DESCRIPTION: This routine supply AX5 daugther card DSP version.
14204 +* INPUT: tidsl_t * ptidsl
14205 +* void *pVer, DSP version struct is returned starting at this pointer
14207 +* RETURN: 0 --succeeded
14210 +*****************************************************************************************/
14212 +int dslhal_api_getDspVersion
14219 +/********************************************************************************************
14220 +* FUNCTION NAME: dslhal_diags_digi_memTestA()
14222 +*********************************************************************************************
14223 +* DESCRIPTION: This function does the digital tests on the DSP. It does the DSP ID test,
14224 +* memory tests on the external and internal memories of DSP, Codec Interconnect
14225 +* test and Interrupt Test.
14227 +* Input: Test selects the test to be performed based on the elements set of 9 element
14228 +* array passed the the parameter.
14230 +* Return: Status of the Tests Failed
14232 +********************************************************************************************/
14234 +unsigned int dslhal_diags_digi_memTestA
14236 +unsigned int* Test
14240 +/********************************************************************************************
14241 +* FUNCTION NAME: dslhal_diags_digi_memTestB()
14243 +*********************************************************************************************
14244 +* DESCRIPTION: This function does the digital tests on the DSP. It does the DSP ID test,
14245 +* memory tests on the external and internal memories of DSP, Codec Interconnect
14246 +* test and Interrupt Test.
14248 +* Input: Test selects the digital test to be performed.
14250 +* Return: Status of the Tests Failed
14252 +********************************************************************************************/
14254 +unsigned int dslhal_diags_digi_memTestB
14256 +unsigned int Test,
14257 +unsigned int *Status
14261 +/********************************************************************************************
14262 +* FUNCTION NAME: dslhal_diags_anlg_tonesTestA()
14264 +*********************************************************************************************
14265 +* DESCRIPTION: This function instructs the Transciever to transmit the Reverb with missing
14266 +* tones and Medley's with missing tones. These signals are defined in ITU
14267 +* G.992.1 ADSL Standards.
14269 +* Input: Test selects between the Reverb or Medley tests. 0 - Reverb, 1 - Medley
14270 +* Array is a 64 element unsigned integer type array. The element of this array
14271 +* describe which tones are to be generated by selecting the element of
14272 +* the array to be non zero.
14275 +********************************************************************************************/
14277 +void dslhal_diags_anlg_tonesTestA
14279 +unsigned int Test,
14280 +unsigned int* Array
14284 +/********************************************************************************************
14285 +* FUNCTION NAME: dslhal_diags_anlg_tonesTestB()
14287 +*********************************************************************************************
14288 +* DESCRIPTION: This function instructs the Transciever to transmit the Reverb with missing
14289 +* tones and Medley's with missing tones. These signals are defined in ITU
14290 +* G.992.1 ADSL Standards.
14292 +* Input: Test selects between the Reverb or Medley tests. 0 - Reverb, 1 - Medley
14293 +* Array is a 64 element unsigned integer type array. The element of this array
14294 +* describe which tones are to be generated by selecting the element of
14295 +* the array to be non zero.
14298 +********************************************************************************************/
14300 +void dslhal_diags_anlg_tonesTestB
14302 +unsigned int Test,
14303 +unsigned int Tones
14306 +/********************************************************************************************
14307 +* FUNCTION NAME: dslhal_diags_anlg_rxNoiseTest()
14309 +*********************************************************************************************
14310 +* DESCRIPTION: This function instructs the Transciever to transmit the Reverb with missing
14311 +* tones and Medley's with missing tones. These signals are defined in ITU
14312 +* G.992.1 ADSL Standards.
14314 +* Input: Test selects between the Reverb or Medley tests. 0 - Reverb, 1 - Medley
14315 +* Tones selects the .
14318 +********************************************************************************************/
14320 +void dslhal_diags_anlg_rxNoiseTest
14328 +/********************************************************************************************
14329 +* FUNCTION NAME: dslhal_diags_anlg_ecNoiseTest()
14331 +*********************************************************************************************
14332 +* DESCRIPTION: This function instructs the Transciever to transmit the Reverb with missing
14333 +* tones and Medley's with missing tones. These signals are defined in ITU
14334 +* G.992.1 ADSL Standards.
14336 +* Input: Test selects between the Reverb or Medley tests. 0 - Reverb, 1 - Medley
14337 +* Tones selects the .
14340 +********************************************************************************************/
14342 +void dslhal_diags_anlg_ecNoiseTest
14351 +/********************************************************************************************
14352 +* FUNCTION NAME: dslhal_api_pollTrainingStatus()
14354 +*********************************************************************************************
14355 +* DESCRIPTION: code to decode modem status and to start modem training
14357 +* Input: tidsl_t *ptidsl
14359 +* Return: 0-? status mode training
14362 +********************************************************************************************/
14363 +int dslhal_api_pollTrainingStatus
14370 +/********************************************************************************************
14371 +* FUNCTION NAME: dslhal_api_handleTrainingInterrupt()
14373 +*********************************************************************************************
14374 +* DESCRIPTION: Code to handle ax5 hardware interrupts
14376 +* Input: tidsl_t *ptidsl
14377 +* int *pMsg, pointer to returned hardware messages. Each byte represent a messge
14378 +* int *pTag, pointer to returned hardware message tags. Each byte represent a tag.
14379 +* Return: 0 success
14382 +********************************************************************************************/
14383 +int dslhal_api_handleTrainingInterrupt
14389 +/******************************************************************************************
14390 + * FUNCTION NAME: dslhal_api_setEocSerialNumber(tidsl_t *ptidsl,char *SerialNumber)
14392 + *******************************************************************************************
14393 + * DESCRIPTION: This fuction Sets the EOC Serial Number
14395 + * INPUT: PITIDSLHW_T *ptidsl
14396 + * char *SerialNumber : Input EOC Serial Number
14398 + * RETURN: 0 SUCCESS
14401 + *****************************************************************************************/
14402 +unsigned int dslhal_api_setEocSerialNumber
14405 +char *SerialNumber
14408 +/******************************************************************************************
14409 + * FUNCTION NAME: dslhal_api_setEocVendorId(tidsl_t *ptidsl,char *VendorID)
14411 + *******************************************************************************************
14412 + * DESCRIPTION: This fuction Sets the EOC Serial Number
14414 + * INPUT: PITIDSLHW_T *ptidsl
14415 + * char *VendorID : EOC Vendor ID
14417 + * RETURN: 0 SUCCESS
14420 + *****************************************************************************************/
14421 +unsigned int dslhal_api_setEocVendorId
14427 +/******************************************************************************************
14428 + * FUNCTION NAME: dslhal_api_setEocRevisionNumber(tidsl_t *ptidsl,char *RevNum)
14430 + *******************************************************************************************
14431 + * DESCRIPTION: This fuction Sets the EOC Revision Number
14433 + * INPUT: PITIDSLHW_T *ptidsl
14434 + * char *RevNum : Input EOC Revision Number
14436 + * RETURN: 0 SUCCESS
14439 + *****************************************************************************************/
14440 +unsigned int dslhal_api_setEocRevisionNumber
14446 +/******************************************************************************************
14447 + * FUNCTION NAME: dslhal_api_setAturConfig(tidsl_t *ptidsl,char *ATURConfig)
14449 + *******************************************************************************************
14450 + * DESCRIPTION: This fuction Sets the EOC ATUR Config Register
14452 + * INPUT: PITIDSLHW_T *ptidsl
14453 + * char *RevNum : Input EOC ATUR Config Register
14455 + * RETURN: 0 SUCCESS
14458 + *****************************************************************************************/
14459 +unsigned int dslhal_api_setAturConfig
14465 +/******************************************************************************************
14466 + * FUNCTION NAME: dslhal_api_disableLosAlarm(tidsl_t *ptidsl, unsigned int set)
14468 + *******************************************************************************************
14469 + * DESCRIPTION: This fuction disables all the LOS alarms
14471 + * INPUT: PITIDSLHW_T *ptidsl
14472 + * unsigned int set // if set == TRUE : Disable LOS alarms, else enable
14474 + * RETURN: 0 SUCCESS
14476 + * NOTES: Currently not supported in any version other than MR4 Patch release..
14477 + *****************************************************************************************/
14478 +unsigned int dslhal_api_disableLosAlarm
14484 +/******************************************************************************************
14485 + * FUNCTION NAME: dslhal_api_sendIdle(tidsl_t *ptidsl)
14487 + *******************************************************************************************
14488 + * DESCRIPTION: This fuction sends the CMD_IDLE message to the DSP
14490 + * INPUT: PITIDSLHW_T *ptidsl
14492 + * RETURN: 0 SUCCESS
14495 + *****************************************************************************************/
14496 +unsigned int dslhal_api_sendIdle
14501 +/******************************************************************************************
14502 + * FUNCTION NAME: dslhal_api_sendQuiet(tidsl_t *ptidsl)
14504 + *******************************************************************************************
14505 + * DESCRIPTION: This fuction sends the CMD_QUIET message to the DSP
14507 + * INPUT: PITIDSLHW_T *ptidsl
14509 + * RETURN: 0 SUCCESS
14512 + *****************************************************************************************/
14513 +unsigned int dslhal_api_sendQuiet
14518 +/******************************************************************************************
14519 + * FUNCTION NAME: dslhal_api_sendDgasp(tidsl_t *ptidsl)
14521 + *******************************************************************************************
14522 + * DESCRIPTION: This fuction sends the HOST_DGASP message to the DSP
14524 + * INPUT: PITIDSLHW_T *ptidsl
14526 + * RETURN: 0 SUCCESS
14529 + *****************************************************************************************/
14530 +unsigned int dslhal_api_sendDgasp
14535 +/******************************************************************************************
14536 + * FUNCTION NAME: dslhal_api_setMarginThreshold(tidsl_t *ptidsl, int threshold)
14538 + *******************************************************************************************
14539 + * DESCRIPTION: This fuction does sets the Margin threshold
14541 + * INPUT: PITIDSLHW_T *ptidsl
14545 + * RETURN: 0 SUCCESS
14548 + *****************************************************************************************/
14549 +unsigned int dslhal_api_setMarginThreshold
14556 +/******************************************************************************************
14557 + * FUNCTION NAME: dslhal_api_setMarginMonitorFlags(tidsl_t *ptidsl, unsigned int trainflag,unsigned int shwtflag)
14559 + *******************************************************************************************
14560 + * DESCRIPTION: This fuction does sets the Margin monitoring flag
14562 + * INPUT: PITIDSLHW_T *ptidsl
14563 + * unsigned int trainflag
14564 + * unsigned int shwtflag
14566 + * RETURN: 0 SUCCESS
14569 + *****************************************************************************************/
14570 +unsigned int dslhal_api_setMarginMonitorFlags
14573 +unsigned int trainflag,
14574 +unsigned int shwtflag
14577 +/******************************************************************************************
14578 +* FUNCTION NAME: dslhal_api_setRateAdaptFlag(tidsl_t *ptidsl)
14580 +*******************************************************************************************
14581 +* DESCRIPTION: This fuction Sets the Rate Adapt Enable Flag
14583 +* INPUT: PITIDSLHW_T *ptidsl
14584 +* unsigned int flag //if flag = TRUE set flag else reset
14585 +* RETURN: 0 SUCCESS
14588 +*****************************************************************************************/
14589 +unsigned int dslhal_api_setRateAdaptFlag
14595 +/******************************************************************************************
14596 +* FUNCTION NAME: dslhal_api_setTrellisFlag(tidsl_t *ptidsl, unsigned int flag)
14598 +*******************************************************************************************
14599 +* DESCRIPTION: This fuction Sets the Trellis Coding Enable Flag
14601 +* INPUT: PITIDSLHW_T *ptidsl
14602 +* unsigned int flag //if flag = TRUE set flag else reset
14603 +* RETURN: 0 SUCCESS
14606 +*****************************************************************************************/
14607 +unsigned int dslhal_api_setTrellisFlag
14613 +/******************************************************************************************
14614 +* FUNCTION NAME: dslhal_api_setMaxBitsPerCarrier(tidsl_t *ptidsl,unsigned int maxbits)
14616 +*******************************************************************************************
14617 +* DESCRIPTION: This fuction Sets the Maximum bits per carrier value
14619 +* INPUT: PITIDSLHW_T *ptidsl
14620 +* unsigned int maxbits : should be a value between 0-15
14622 +* RETURN: 0 SUCCESS
14625 +*****************************************************************************************/
14626 +unsigned int dslhal_api_setMaxBitsPerCarrier
14629 +unsigned int maxbits
14632 +/******************************************************************************************
14633 +* FUNCTION NAME: dslhal_api_setMaxInterleaverDepth(tidsl_t *ptidsl,unsigned int maxdepth)
14635 +*******************************************************************************************
14636 +* DESCRIPTION: This fuction Sets the Maximum Interleave Depth Supported
14638 +* INPUT: PITIDSLHW_T *ptidsl
14639 +* unsigned int maxdepth : Should be between 0 and 3 depending on intlv buffer
14641 +* RETURN: 0 SUCCESS
14644 +*****************************************************************************************/
14645 +unsigned int dslhal_api_setMaxInterleaverDepth
14648 +unsigned int maxdepth
14651 +/******************************************************************************************
14652 +* FUNCTION NAME: dslhal_api_setTrainingMode(tidsl_t *ptidsl,unsigned int trainmode)
14654 +*******************************************************************************************
14655 +* DESCRIPTION: This fuction Sets the desired training mode(none/T1.413/G.dmt/G.lite)
14657 +* INPUT: PITIDSLHW_T *ptidsl
14658 +* unsigned int trainmode :Should be between 0 and 4; 0:No Mode 1:Multimode
14659 +* 2: T1.413, 3:G.dmt, 4: G.lite
14660 +* RETURN: 0 SUCCESS
14663 +*****************************************************************************************/
14665 +unsigned int dslhal_api_setTrainingMode
14668 +unsigned int trainmode
14671 +/******************************************************************************************
14672 + * FUNCTION NAME: dslhal_api_dslRetrain(tidsl_t *ptidsl)
14674 + *******************************************************************************************
14675 + * DESCRIPTION: This fuction sends the CMD_QUIET message to the DSP
14677 + * INPUT: PITIDSLHW_T *ptidsl
14679 + * RETURN: 0 SUCCESS
14682 + *****************************************************************************************/
14683 +unsigned int dslhal_api_dslRetrain
14688 +/********************************************************************************************
14689 +* FUNCTION NAME: dslhal_api_acknowledgeInterrupt()
14691 +*********************************************************************************************
14693 +* Sets the host interrupt bit masks
14695 +* Return: 0 success
14699 +* DSP image is based on LITTLE endian
14701 +********************************************************************************************/
14702 +unsigned int dslhal_api_acknowledgeInterrupt
14706 +/********************************************************************************************
14707 +* FUNCTION NAME: dslhal_api_disableDspHybridSelect()
14709 +*********************************************************************************************
14711 +* Sets the host interrupt bit masks
14713 +* Return: 0 success
14717 +* DSP image is based on LITTLE endian
14719 +********************************************************************************************/
14720 +unsigned int dslhal_api_disableDspHybridSelect
14721 +(tidsl_t * ptidsl,
14722 + unsigned int disable
14725 +/********************************************************************************************
14726 +* FUNCTION NAME: dslhal_api_disableDspHybridSelect()
14728 +*********************************************************************************************
14730 +* Sets the host interrupt bit masks
14732 +* Return: 0 success
14736 +* DSP image is based on LITTLE endian
14738 +********************************************************************************************/
14739 +unsigned int dslhal_api_selectHybrid
14740 +(tidsl_t * ptidsl,
14741 + unsigned int hybridNum
14744 +/********************************************************************************************
14745 +* FUNCTION NAME: dslhal_api_reportHybridMetrics()
14747 +*********************************************************************************************
14749 +* Sets the host interrupt bit masks
14751 +* Return: 0 success
14755 +* DSP image is based on LITTLE endian
14757 +********************************************************************************************/
14758 +unsigned int dslhal_api_reportHybridMetrics
14759 +(tidsl_t * ptidsl,
14763 +/******************************************************************************************
14764 + * FUNCTION NAME: dslhal_api_selectInnerOuterPair(tidsl_t *ptidsl, unsigned int pairSelect)
14766 + *******************************************************************************************
14767 + * DESCRIPTION: This fuction sends the CMD_QUIET message to the DSP
14769 + * INPUT: PITIDSLHW_T *ptidsl
14771 + * RETURN: 0 SUCCESS
14774 + *****************************************************************************************/
14776 +unsigned int dslhal_api_selectInnerOuterPair
14778 +unsigned int pairSelect
14781 +/******************************************************************************************
14782 + * FUNCTION NAME: dslhal_api_resetTrainFailureLog(tidsl_t *ptidsl, unsigned int pairSelect)
14784 + *******************************************************************************************
14785 + * DESCRIPTION: This fuction sends the CMD_QUIET message to the DSP
14787 + * INPUT: PITIDSLHW_T *ptidsl
14789 + * RETURN: 0 SUCCESS
14792 + *****************************************************************************************/
14794 +unsigned int dslhal_api_resetTrainFailureLog
14798 +/********************************************************************************************
14799 +* FUNCTION NAME: dslhal_api_controlLed()
14801 +*********************************************************************************************
14803 +* Sets the host interrupt bit masks
14805 +* Return: 0 success
14809 +* DSP image is based on LITTLE endian
14811 +********************************************************************************************/
14812 +unsigned int dslhal_api_configureLed
14813 +(tidsl_t * ptidsl,
14814 +unsigned int idLed,
14815 +unsigned int onOff
14818 +/********************************************************************************************
14819 +* FUNCTION NAME: dslhal_api_configureExternBert()
14821 +*********************************************************************************************
14823 +* Sets the host interrupt bit masks
14825 +* Return: 0 success
14829 +* DSP image is based on LITTLE endian
14831 +********************************************************************************************/
14832 +unsigned int dslhal_api_configureExternBert
14833 +(tidsl_t * ptidsl,
14834 +unsigned int configParm,
14835 +unsigned int parmVal
14838 +/********************************************************************************************
14839 +* FUNCTION NAME: dslhal_api_configureAtmBert()
14841 +*********************************************************************************************
14843 +* Sets the host interrupt bit masks
14845 +* Return: 0 success
14849 +* DSP image is based on LITTLE endian
14851 +********************************************************************************************/
14852 +unsigned int dslhal_api_configureAtmBert
14853 +(tidsl_t * ptidsl,
14854 +unsigned int configParm,
14855 +unsigned int parmVal
14858 +/********************************************************************************************
14859 +* FUNCTION NAME: dslhal_api_configureDgaspLpr()
14861 +*********************************************************************************************
14863 +* Sets the host interrupt bit masks
14865 +* Return: 0 success
14869 +* DSP image is based on LITTLE endian
14871 +********************************************************************************************/
14872 +unsigned int dslhal_api_configureDgaspLpr
14873 +(tidsl_t * ptidsl,
14874 +unsigned int configParm,
14875 +unsigned int parmVal
14878 +/********************************************************************************************
14879 +* FUNCTION NAME: dslhal_advcfg_onOffPcb()
14881 +*********************************************************************************************
14883 +* Sets the host interrupt bit masks
14885 +* Return: 0 success
14889 +* DSP image is based on LITTLE endian
14891 +********************************************************************************************/
14892 +unsigned int dslhal_advcfg_onOffPcb
14893 +(tidsl_t * ptidsl,
14894 +unsigned int onOff
14897 +/********************************************************************************************
14898 +* FUNCTION NAME: dslhal_advcfg_onOffBitSwap()
14900 +*********************************************************************************************
14902 +* Turns on / off the power cutback feature;
14904 +* usDs; 0 = us and 1 = ds;
14905 +* onOff; 0 = OFF and 1 = ON
14907 +* Return: 0 success
14911 +* DSP image is based on LITTLE endian
14913 +********************************************************************************************/
14914 +unsigned int dslhal_advcfg_onOffBitSwap
14915 +(tidsl_t * ptidsl,
14916 + unsigned int usDs,
14917 + unsigned int onOff
14920 +/********************************************************************************************
14921 +* FUNCTION NAME: dslhal_advcfg_configDsTones()
14923 +*********************************************************************************************
14925 +* Turns on / off specific tones in the downstream direction;
14927 +* pointer to the array specifying the tones to be turned on/off
14930 +* Return: 0 success
14934 +* DSP image is based on LITTLE endian
14936 +********************************************************************************************/
14937 +unsigned int dslhal_advcfg_configDsTones
14938 +(tidsl_t * ptidsl,
14939 + unsigned int *dsTones
14942 +/********************************************************************************************
14943 +* FUNCTION NAME: dslhal_advcfg_getAocBitSwapBuffer()
14945 +*********************************************************************************************
14947 +* Fetches the Tx/Rx AOC bitswap Buffer;
14949 +* Transmit / Receive buffer to be fetched
14952 +* Return: 0 success
14956 +* DSP image is based on LITTLE endian
14958 +********************************************************************************************/
14959 +unsigned int dslhal_advcfg_getAocBitswapBuffer
14960 +(tidsl_t * ptidsl,
14964 +/********************************************************************************************
14965 +* FUNCTION NAME: dslhal_advcfg_readTrainingMessages()
14967 +*********************************************************************************************
14969 +* Reads all the training messages on demand;
14971 +* tidsl_t *ptidsl : Pointer to application structure
14972 +* void *msgStruct : Pointer to Message Structure
14975 +* Return: 0 success
14979 +* DSP image is based on LITTLE endian
14981 +********************************************************************************************/
14982 +unsigned int dslhal_advcfg_readTrainingMessages
14983 +(tidsl_t * ptidsl,
14987 +/********************************************************************************************
14988 +* FUNCTION NAME: dslhal_advcfg_getTrainingState()
14990 +*********************************************************************************************
14992 +* Reads all the training messages on demand;
14994 +* tidsl_t *ptidsl : Pointer to application structure
14995 +* void *msgStruct : Pointer to training state structure
14998 +* Return: 0 success
15002 +* DSP image is based on LITTLE endian
15004 +********************************************************************************************/
15005 +unsigned int dslhal_advcfg_getTrainingState
15006 +(tidsl_t * ptidsl,
15010 +/********************************************************************************************
15011 +* FUNCTION NAME: dslhal_advcfg_resetBitSwapMessageLog()
15013 +*********************************************************************************************
15015 +* Clears the Aoc Bitswap Message Log
15017 +* tidsl_t *ptidsl : Pointer to application structure
15018 +* unsigned int usDs ; Upstream=0, Downstream=1
15020 +* Return: 0 success
15023 +********************************************************************************************/
15024 +unsigned int dslhal_advcfg_resetBitSwapMessageLog
15025 +(tidsl_t * ptidsl,
15026 + unsigned int usDs
15029 +/********************************************************************************************
15030 +* FUNCTION NAME: dslhal_advcfg_setConstellationBinNumber()
15032 +*********************************************************************************************
15034 +* Specifies the bin number for which constellation data should be fetched
15036 +* tidsl_t *ptidsl : Pointer to application structure
15037 +* unsigned int binNum : constellation bin number whose data is required
15039 +* Return: 0 success
15042 +********************************************************************************************/
15043 +unsigned int dslhal_advcfg_setConstellationBinNumber
15044 +(tidsl_t * ptidsl,
15045 + unsigned int binNum
15048 +/********************************************************************************************
15049 +* FUNCTION NAME: dslhal_advcfg_resetTrainStateHistory()
15051 +*********************************************************************************************
15053 +* Clears the Training State History Log
15055 +* tidsl_t *ptidsl : Pointer to application structure
15058 +* Return: 0 success
15061 +********************************************************************************************/
15062 +unsigned int dslhal_advcfg_resetTrainStateHistory
15066 +/********************************************************************************************
15067 +* FUNCTION NAME: dslhal_advcfg_getSnrPerBin()
15069 +*********************************************************************************************
15071 +* Get SNR data per bin
15073 +* tidsl_t *ptidsl : Pointer to application structure
15076 +* Return: 0 success
15079 +********************************************************************************************/
15080 +unsigned int dslhal_advcfg_getSnrPerBin
15081 +(tidsl_t * ptidsl,
15082 + unsigned int snrBufferOpt
15085 +/********************************************************************************************
15086 +* FUNCTION NAME: dslhal_advcfg_logEocMessages()
15088 +*********************************************************************************************
15090 +* Logs EOC messages sent by the Modem to the CO
15092 +* tidsl_t *ptidsl : Pointer to application structure
15093 +* unsigned int eocLowerBytes : Lower [1-5] bits of EOC Message
15094 +* unsigned int eocUpperBytes : Upper [6-13] bits of EOC Message
15096 +* Return: 0 success
15099 +********************************************************************************************/
15100 +unsigned int dslhal_advcfg_logEocMessages
15101 +(tidsl_t * ptidsl,
15102 + unsigned int usDs,
15103 + unsigned int eocLowerBytes,
15104 + unsigned int eocUpperBytes
15107 +/********************************************************************************************
15108 +* FUNCTION NAME: dslhal_advcfg_getReasonForDrop()
15110 +*********************************************************************************************
15112 +* Reads the reason for dropping DSL connection;
15114 +* tidsl_t *ptidsl : Pointer to application structure
15118 +* Return: 0 success
15122 +* DSP image is based on LITTLE endian
15124 +********************************************************************************************/
15125 +unsigned int dslhal_advcfg_getReasonForDrop
15129 +/********************************************************************************************
15130 +* FUNCTION NAME: dslhal_advcfg_ctrlMaxAvgFineGains()
15132 +*********************************************************************************************
15134 +* Turns on / off the host control for Max Avg Fine Gains; 0 = OFF and 1 = ON
15136 +* Return: 0 success
15140 +* DSP image is based on LITTLE endian
15142 +********************************************************************************************/
15143 +unsigned int dslhal_advcfg_ctrlMaxAvgFineGains
15144 +(tidsl_t * ptidsl,
15145 +unsigned int onOff
15149 +/********************************************************************************************
15150 +* FUNCTION NAME: dslhal_advcfg_setMaxAvgFineGain()
15152 +*********************************************************************************************
15154 +* Set the Maximum Average Fine Gain Value
15156 +* Return: 0 success
15160 +* DSP image is based on LITTLE endian
15162 +********************************************************************************************/
15163 +unsigned int dslhal_advcfg_setMaxAvgFineGain
15164 +(tidsl_t * ptidsl,
15167 +/********************************************************************************************
15168 +* FUNCTION NAME: dslhal_advcfg_readPhySettings()
15170 +*********************************************************************************************
15172 +* Reads the advanced Phy layer settings on demand;
15174 +* tidsl_t *ptidsl : Pointer to application structure
15175 +* void *cfgStruct : Pointer to Phy Config Structure
15178 +* Return: 0 success
15182 +* DSP image is based on LITTLE endian
15184 +********************************************************************************************/
15185 +unsigned int dslhal_advcfg_readPhySettings
15186 +(tidsl_t * ptidsl,
15190 +/********************************************************************************************
15191 +* FUNCTION NAME: dslhal_advcfg_setBlackOutBits()
15193 +*********************************************************************************************
15195 +* Sets the Blackout Bits in the RMSGPCB message
15197 +* Return: 0 success
15201 +* DSP image is based on LITTLE endian
15203 +********************************************************************************************/
15204 +unsigned int dslhal_advcfg_setBlackOutBits
15208 +/********************************************************************************************
15209 +* FUNCTION NAME: dslhal_api_genericDspRead()
15211 +*********************************************************************************************
15213 +* Reads from a generic location in the host interface
15215 +* Return: 0 success
15219 +* DSP image is based on LITTLE endian
15221 +********************************************************************************************/
15222 +unsigned int dslhal_api_genericDspRead
15223 +(tidsl_t * ptidsl,
15224 + unsigned int offset1,
15225 + unsigned int offset2,
15226 + unsigned int offset3,
15227 + unsigned char* localBuffer,
15228 + unsigned int numBytes
15231 +/********************************************************************************************
15232 +* FUNCTION NAME: dslhal_api_genericDspWrite()
15234 +*********************************************************************************************
15236 +* Writes to a generic location in the host interface
15238 +* Return: 0 success
15242 +* DSP image is based on LITTLE endian
15244 +********************************************************************************************/
15245 +unsigned int dslhal_api_genericDspWrite
15246 +(tidsl_t * ptidsl,
15247 + unsigned int offset1,
15248 + unsigned int offset2,
15249 + unsigned int offset3,
15250 + unsigned char* localBuffer,
15251 + unsigned int numBytes
15254 +/********************************************************************************************
15255 +* FUNCTION NAME: dslhal_api_dspInterfaceRead()
15257 +*********************************************************************************************
15259 +* Reads from a generic location in the host interface
15261 +* Return: 0 success
15265 +* DSP image is based on LITTLE endian
15267 +********************************************************************************************/
15268 +unsigned int dslhal_api_dspInterfaceRead
15269 +(tidsl_t * ptidsl,
15270 + unsigned int baseAddr,
15271 + unsigned int numOffsets,
15272 + unsigned int *offsets,
15273 + unsigned char* localBuffer,
15274 + unsigned int numBytes
15277 +/********************************************************************************************
15278 +* FUNCTION NAME: dslhal_api_dspInterfaceWrite()
15280 +*********************************************************************************************
15282 +* Writes to a generic location in the host interface
15284 +* Return: 0 success
15288 +* DSP image is based on LITTLE endian
15290 +********************************************************************************************/
15291 +unsigned int dslhal_api_dspInterfaceWrite
15292 +(tidsl_t * ptidsl,
15293 + unsigned int baseAddr,
15294 + unsigned int numOffsets,
15295 + unsigned int *offsets,
15296 + unsigned char* localBuffer,
15297 + unsigned int numBytes
15300 +/******************************************************************************************
15301 + * FUNCTION NAME: dslhal_api_sendMailboxCommand(tidsl_t *ptidsl, unsigned int cmd)
15303 + *******************************************************************************************
15304 + * DESCRIPTION: This fuction sends the passed mailbox command to the DSP
15306 + * INPUT: PITIDSLHW_T *ptidsl
15307 + * unsigned int cmd
15309 + * RETURN: 0 SUCCESS
15312 + *****************************************************************************************/
15313 +unsigned int dslhal_api_sendMailboxCommand
15318 +#ifdef INTERNAL_BUILD
15319 +#include <dsl_hal_internal_api.h>
15323 +#endif /* pairs #ifndef __DSL_APPLICATION_INTERFACE_H__ */
15324 diff -urN linux.old/drivers/atm/sangam_atm/dsl_hal_logtable.h linux.dev/drivers/atm/sangam_atm/dsl_hal_logtable.h
15325 --- linux.old/drivers/atm/sangam_atm/dsl_hal_logtable.h 1970-01-01 01:00:00.000000000 +0100
15326 +++ linux.dev/drivers/atm/sangam_atm/dsl_hal_logtable.h 2005-07-10 08:02:01.439112120 +0200
15328 +unsigned int log10[]=
15587 diff -urN linux.old/drivers/atm/sangam_atm/dsl_hal_register.h linux.dev/drivers/atm/sangam_atm/dsl_hal_register.h
15588 --- linux.old/drivers/atm/sangam_atm/dsl_hal_register.h 1970-01-01 01:00:00.000000000 +0100
15589 +++ linux.dev/drivers/atm/sangam_atm/dsl_hal_register.h 2005-07-10 08:02:01.440111968 +0200
15591 +#ifndef ___DSL_REGISTER_DEFINES_H___
15592 +#define ___DSL_REGISTER_DEFINES_H___ 1
15594 +/*******************************************************************************
15595 +* FILE PURPOSE: DSL HAL H/W Registers and Constant Declarations for Sangam
15597 +********************************************************************************
15598 +* FILE NAME: dsl_hal_register.h
15601 +* Contains DSL HAL APIs for Adam2 OS functions
15604 +* (C) Copyright 2001-02, Texas Instruments, Inc.
15606 +* Date Version Notes
15607 +* 06Feb03 0.00.00 RamP Created
15608 +* 21Mar03 0.00.01 RamP Changed header files for Modular
15610 +* 21Mar03 0.00.02 RamP Introduced malloc size for DSP f/w
15611 +* 07Apr03 0.00.03 RamP Implemented new error reporting scheme
15612 +* Changed Commenting to C style only
15613 +* 12Apr03 0.00.04 RamP Added Interrupt Mask defines
15614 +* 14Apr03 0.00.05 RamP Renamed macros for REG8, REG16 & REG32
15615 +* 21Apr03 0.01.00 RamP Added Interrupt source/clear registers
15616 +* Changed enum RSTATE_SHOWTIME to 5
15617 +* 24Apr03 0.01.01 RamP Moved the RSTATE enum to api.h
15618 +* Added olay recovery error condition
15619 +* 14May03 0.01.02 RamP Added defines for power computation
15620 +* Added error condition for hybrids
15621 +* 04Jun03 0.01.03 RamP Added enum for config flags,
15622 +* Cleaned up AR5 register defines
15623 +* Added defines for higher data rate
15624 +* 06Jun03 0.01.04 RamP Added error & interrupt defines
15625 +* 09Jun03 0.01.05 RamP Modified enum for current config
15626 +* Added additional C-Rates defines
15627 +* 18Jul03 0.01.06 RamP Modified internal build flow
15628 +* 21Aug03 0.01.07 RamP Added constellation buffer size
15629 +* 08Oct03 0.01.08 RamP Added us/ds Bits n gains size
15630 +* 12Oct03 0.01.08 RamP Added ADSL2 Message sizes, lengths
15631 +* and offsets for various formats
15632 +* 29Oct03 0.01.09 RamP Added ADSL2 Delt offsets & sizes
15633 +* 24Nov03 0.01.10 RamP Added bit field number, scan vector
15634 +* 26Dec03 0.01.11 RamP Removed the oamFeature masks to api.h
15635 +*******************************************************************************/
15637 +#include "env_def_typedefs.h"
15638 +#ifdef INTERNAL_BUILD
15639 +#include "dev_host_internalinterface.h"
15641 +#include "dev_host_interface.h"
15642 +#include "dsl_hal_api.h"
15644 +#define ADSLSS_BASE 0x01000000
15645 +#define BBIF_BASE 0x02000000
15647 +#define ADSLSSADR (BBIF_BASE+0x0000)
15648 +#define ADSLSSADRMASK 0xff000000
15649 +#define WAKEUP_DSP 0x00000001
15651 +/* Ax7 Reset Control */
15653 +#define RST_CNTRL_BASE 0x8611600
15654 +#define RST_CNTRL_PRCR (RST_CNTRL_BASE + 0x00 )
15656 +#define RST_CNTRL_PRCR_GPIO 0x00000040
15657 +#define RST_CNTRL_PRCR_ADSLSS 0x00000080
15658 +#define RST_CNTRL_PRCR_USB 0x00000100
15659 +#define RST_CNTRL_PRCR_SAR 0x00000200
15660 +#define RST_CNTRL_PRCR_DSP 0x00800000
15661 +#define RST_CNTRL_PRCR_EMAC1 0x00200000 /* EMAC1 reset */
15663 +#define RST_CNTRL_SWRCR (RST_CNTRL_BASE + 0x04 )
15664 +#define RST_SWRCR_SWR0 0x00000001
15665 +#define RST_SWRCR_SWR1 0x00000002
15667 +#define RST_CNTRL_RSR (TNETD53XX_RST_CNTRL_BASE + 0x08 )
15668 +#define RST_RSR_RSCAUSE 0x00000003 /* Software Reset Caused by writing to SWR1 bit */
15671 +/* ******************************************************
15672 +Interrupt sources on Ax7 interrupt controller.
15673 +The reserved sources are noted.
15674 +********************************************************* */
15676 +#define INTR_CNTRL_SRC_SECOND 0
15677 +#define INTR_CNTRL_SRC_EXTERNAL0 1
15678 +#define INTR_CNTRL_SRC_EXTERNAL1 2
15679 +/* reserved sources ... */
15680 +#define INTR_CNTRL_SRC_TIMER0 5
15681 +#define INTR_CNTRL_SRC_TIMER1 6
15682 +#define INTR_CNTRL_SRC_UART0 7
15683 +#define INTR_CNTRL_SRC_UART1 8
15684 +#define INTR_CNTRL_SRC_DMA0 9
15685 +#define INTR_CNTRL_SRC_DMA1 10
15686 +/* reserved sources ... */
15687 +#define INTR_CNTRL_SRC_SAR 15
15688 +/* reserved sources ... */
15689 +#define INTR_CNTRL_SRC_EMAC0 19
15690 +/* reserved sources ... */
15691 +#define INTR_CNTRL_SRC_VLYNQ0 21
15692 +#define INTR_CNTRL_SRC_CODEC_WAKE 22
15693 +/* reserved sources ... */
15694 +#define INTR_CNTRL_SRC_USB 24
15695 +#define INTR_CNTRL_SRC_VLYNQ1 25
15696 +/* reserved sources ... */
15697 +#define INTR_CNTRL_SRC_EMAC1 28
15698 +#define INTR_CNTRL_SRC_I2C 29
15699 +#define INTR_CNTRL_SRC_DMA2 30
15700 +#define INTR_CNTRL_SRC_DMA3 31
15701 +/* reserved sources ... */
15702 +#define INTR_CNTRL_SRC_VDMA_RX 37
15703 +#define INTR_CNTRL_SRC_VDMA_TX 38
15704 +#define INTR_CNTRL_SRC_ADSLSS 39
15707 +#define K0BASE 0x80000000
15711 +#define K1BASE 0xA0000000
15715 +#define PHYS_ADDR(X) ((X) & 0X1FFFFFFF)
15718 +#ifndef PHYS_TO_K0
15719 +#define PHYS_TO_K0(X) (PHYS_ADDR(X)|K0BASE)
15722 +#ifndef PHYS_TO_K1
15723 +#define PHYS_TO_K1(X) (PHYS_ADDR(X)|K1BASE)
15726 +#ifndef DSLHAL_REG8
15727 +#define DSLHAL_REG8( addr ) (*(volatile unsigned short *) PHYS_TO_K1(addr))
15730 +#ifndef DSLHAL_REG16
15731 +#define DSLHAL_REG16( addr ) (*(volatile unsigned short *)PHYS_TO_K1(addr))
15734 +#ifndef DSLHAL_REG32
15735 +#define DSLHAL_REG32( addr ) (*(volatile unsigned int *)PHYS_TO_K1(addr))
15743 +#define TRUE (1==1)
15747 +#define FALSE (1==2)
15750 +/*******************************************************************************
15751 +* Type Defines for Library
15752 +********************************************************************************/
15753 +typedef unsigned int size_t;
15755 +#define TIDSL_HW_CREATED 0x00000001
15756 +#define TIDSL_HW_OPENED 0x00000002
15757 +#define TIDSL_HW_STARTED 0x00000004
15758 +#define TIDSL_OS_INITIALIZED 0x00000008
15760 +/* Data Pump CRATES Table Defines */
15761 +#define SIZE_OF_CRATES1_TABLE 120
15762 +#define CRATES1_BF_LS0 7
15763 +#define CRATES1_BI_LS0 17
15764 +#define CRATES1_BF_AS0 0
15765 +#define CRATES1_BI_AS0 10
15766 +#define CRATES1_BF_DSRS 20
15767 +#define CRATES1_BI_DSRS 21
15768 +#define CRATES1_BFI_DSS 22
15769 +#define CRATES1_BFI_DSI 23
15770 +#define CRATES1_BF_USRS 25
15771 +#define CRATES1_BI_USRS 26
15772 +#define CRATES1_BFI_USS 27
15773 +#define CRATES1_BFI_USI 28
15775 +#define FAST_PATH 0
15776 +#define INTERLEAVED_PATH 1
15778 +#define LINE_NOT_CONNECTED 0
15779 +#define LINE_CONNECTED 1
15780 +#define LINE_DISCONNECTED 2
15781 +#define LINE_NOT_TO_CONNECT 3
15783 +#define MAXSECTIONS 125
15785 +/*****************************************************************************************
15786 + * Localstructure declarations
15788 + ****************************************************************************************/
15791 + DSLHAL_ERROR_NO_ERRORS, /* 00 */
15792 + DSLHAL_ERROR_UNRESET_ADSLSS, /* 01 */
15793 + DSLHAL_ERROR_RESET_ADSLSS, /* 02 */
15794 + DSLHAL_ERROR_UNRESET_DSP, /* 03 */
15795 + DSLHAL_ERROR_RESET_DSP, /* 04 */
15796 + DSLHAL_ERROR_NO_FIRMWARE_IMAGE, /* 05 */
15797 + DSLHAL_ERROR_MALLOC, /* 06 */
15798 + DSLHAL_ERROR_FIRMWARE_MALLOC, /* 07 */
15799 + DSLHAL_ERROR_DIAG_MALLOC, /* 08 */
15800 + DSLHAL_ERROR_OVERLAY_MALLOC, /* 09 */
15801 + DSLHAL_ERROR_CODE_DOWNLOAD, /* 10 */
15802 + DSLHAL_ERROR_DIAGCODE_DOWNLOAD, /* 11 */
15803 + DSLHAL_ERROR_BLOCK_READ, /* 12 */
15804 + DSLHAL_ERROR_BLOCK_WRITE, /* 13 */
15805 + DSLHAL_ERROR_MAILBOX_READ, /* 14 */
15806 + DSLHAL_ERROR_MAILBOX_WRITE, /* 15 */
15807 + DSLHAL_ERROR_MAILBOX_NOMAIL, /* 16 */
15808 + DSLHAL_ERROR_MAILBOX_OVERFLOW, /* 17 */
15809 + DSLHAL_ERROR_INVALID_PARAM, /* 18 */
15810 + DSLHAL_ERROR_ADDRESS_TRANSLATE, /* 19 */
15811 + DSLHAL_ERROR_FIRMWARE_CRC, /* 20 */
15812 + DSLHAL_ERROR_FIRMWARE_OFFSET, /* 21 */
15813 + DSLHAL_ERROR_CONFIG_API_FAILURE, /* 22 */
15814 + DSLHAL_ERROR_EOCREG_API_FAILURE, /* 23 */
15815 + DSLHAL_ERROR_VERSION_API_FAILURE, /* 24 */
15816 + DSLHAL_ERROR_STATS_API_FAILURE, /* 25 */
15817 + DSLHAL_ERROR_MARGIN_API_FAILURE, /* 26 */
15818 + DSLHAL_ERROR_CTRL_API_FAILURE, /* 27 */
15819 + DSLHAL_ERROR_HYBRID_API_FAILURE, /* 28 */
15820 + DSLHAL_ERROR_MODEMENV_API_FAILURE, /* 29 */
15821 + DSLHAL_ERROR_INTERRUPT_FAILURE, /* 30 */
15822 + DSLHAL_ERROR_INTERNAL_API_FAILURE, /* 31 */
15823 + DSLHAL_ERROR_DIGIDIAG_FAILURE, /* 32 */
15824 + DSLHAL_ERROR_TONETEST_FAILURE, /* 33 */
15825 + DSLHAL_ERROR_NOISETEST_FAILURE, /* 34 */
15826 + DSLHAL_ERROR_MODEMSTATE, /* 35 */
15827 + DSLHAL_ERROR_OVERLAY_CORRUPTED /* 36 */
15832 + CONFIG_FLAG_NOFLAG, /* 00 */
15833 + CONFIG_FLAG_TRELLIS, /* 01 */
15834 + CONFIG_FLAG_EC, /* 02 */
15835 + CONFIG_FLAG_RS /* 03 */
15838 +#define USE_EMIF_REV 0
15839 +#define USE_CVR_REV 1
15840 +#define TNETD53XX_MAXLOOP 10000
15843 +#define NONINTENSE 0
15844 +#define slavespace0 0xa1000000
15846 +#define MASK_MAILBOX_INTERRUPTS 0x00000001
15847 +#define MASK_BITFIELD_INTERRUPTS 0x00000002
15848 +#define MASK_HEARTBEAT_INTERRUPTS 0x00000004
15849 +#define DSP_INTERRUPT_SOURCE_REGISTER 0x020007A0
15850 +#define DSP_INTERRUPT_CLEAR_REGISTER 0x020007A4
15852 +#define DIGITAL_DIAG_MEMSIZE 1048576
15853 +#define CRC32_QUOTIENT 0x04c11db7
15854 +#define DSP_FIRMWARE_MALLOC_SIZE 0x7ffff
15855 +#define DSP_CONSTELLATION_BUFFER_SIZE 1024*4
15856 +#define LOG43125 9303
15857 +#define US_NOMINAL_POWER (-38)
15858 +#define US_BNG_LENGTH 32
15859 +#define DS_BNG_LENGTH 256
15860 +#define NUMBER_OF_BITFIELDS 4
15861 +#define BITFIELD_SCAN 0x80000000
15863 +/* ADSL Message offsets from Host Interface Pointer */
15865 +/* ADSL2 Messages Index and Length defines */
15867 +#define CMSGFMT_INDEX 0
15868 +#define CMSGPCB_INDEX 1
15869 +#define RMSGFMT_INDEX 2
15870 +#define RMSGPCB_INDEX 3
15871 +#define RMSG1LD_INDEX 13
15872 +#define RMSG2LD_INDEX 14
15873 +#define RMSG3LD_INDEX 15
15874 +#define RMSG4LD_INDEX 16
15875 +#define RMSG5LD_INDEX 17
15876 +#define RMSG6LD_INDEX 18
15877 +#define RMSG7LD_INDEX 19
15878 +#define RMSG8LD_INDEX 20
15879 +#define RMSG9LD_INDEX 21
15880 +#define CMSG1LD_INDEX 22
15881 +#define CMSG2LD_INDEX 23
15882 +#define CMSG3LD_INDEX 24
15883 +#define CMSG4LD_INDEX 25
15884 +#define CMSG5LD_INDEX 26
15885 +#define CMSGPCB2_INDEX 28
15886 +#define CMSGPCB2L_INDEX 29
15887 +#define RMSGFMT2_INDEX 30
15888 +#define RMSGPCB2L_INDEX 31
15889 +#define CMSG1ADSL2_INDEX 32
15890 +#define RMSG1ADSL2_INDEX 33
15891 +#define CMSG2ADSL2_INDEX 34
15892 +#define RMSG2ADSL2_INDEX 35
15893 +#define CPARAMS_INDEX 36
15894 +#define RPARAMS_INDEX 37
15896 +/* ADSL2 Message Sizes */
15898 +#define CMSGFMT_SIZE 2
15899 +#define RMSGFMT_SIZE 2
15900 +#define CMSGPCB_SIZE 2
15901 +#define CMSGPCB2_SIZE 6 /* Annex A with Blackout */
15902 +#define CMSGPCB2L_SIZE 10 /* Annex B with Blackout */
15903 +#define RMSGPCB_SIZE 36
15904 +#define RMSG1LD_SIZE 16
15905 +#define RMSGxLD_SIZE 258
15906 +#define CMSG1LD_SIZE 16
15907 +#define CMSG2LD_SIZE 130
15908 +#define CMSG3LD_SIZE 66
15909 +#define CMSG4LD_SIZE 34
15910 +#define CMSG5LD_SIZE 34
15911 +#define CMSG1ADSL2_SIZE 24
15912 +#define RMSG1ADSL2_SIZE 4
15913 +#define CMSG2ADSL2_SIZE 4
15914 +#define RMSG2ADSL2_SIZE 32
15915 +#define CPARAMS_SIZE 136
15916 +#define RPARAMS_SIZE 808
15918 +/* ADSL2 Plus Message Sizes (if Different from ADSL2) */
15920 +#define RMSGPCB_P_SIZE 68
15921 +#define CMSG1ADSL2P_SIZE 40 /* With Blackout */
15922 +#define CPARAMS_PA_SIZE 168
15923 +#define RPARAMS_PA_SIZE 2088
15924 +#define CPARAMS_PB_SIZE 296
15925 +#define RPARAMS_PB_SIZE 2088
15927 +#endif /* pairs #ifndef ___DSL_REGISTER_DEFINES_H___ */
15928 diff -urN linux.old/drivers/atm/sangam_atm/dsl_hal_support.c linux.dev/drivers/atm/sangam_atm/dsl_hal_support.c
15929 --- linux.old/drivers/atm/sangam_atm/dsl_hal_support.c 1970-01-01 01:00:00.000000000 +0100
15930 +++ linux.dev/drivers/atm/sangam_atm/dsl_hal_support.c 2005-07-10 08:02:01.443111512 +0200
15932 +/*******************************************************************************
15933 +* FILE PURPOSE: DSL Driver API functions for Sangam
15934 +*********************************************************************************
15935 +* FILE NAME: dsl_hal_support.c
15938 +* Contains DSL HAL APIs for Modem Control
15941 +* (C) Copyright 2001-02, Texas Instruments, Inc.
15943 +* Date Version Notes
15944 +* 06Feb03 0.00.00 RamP Created
15945 +* 21Mar03 0.00.01 RamP Inserted byteswap functions
15946 +* 07Apr03 0.00.02 RamP Implemented new error reporting scheme
15947 +* Changed Commenting to C style only
15948 +* 12Apr03 0.00.03 RamP Added function to set Interrupt Bit
15949 +* Masks for bitfield & Mailboxes
15950 +* 14Apr03 0.00.04 RamP Added function to process modem state
15951 +* bit fields; renamed REG32 macros
15952 +* Changed interrupt bit field settings
15953 +* 15Apr03 0.00.05 RamP Fixed exit condition on dslShutdown
15954 +* 21Apr03 0.01.00 RamP Fixed dslShutdown function & changed
15955 +* loop counter for overlay byteswaps
15956 +* (Alpha) Added cache writeback for overlays
15957 +* Added function acknowledgeInterrupt
15958 +* 22Apr03 0.01.01 RamP Moved acknowledgeInterrupt into api
15959 +* 24Apr03 0.01.02 RamP Added function to compare crc32 with
15960 +* pre-computed value as a recovery
15961 +* scheme for corrupt overlay pages
15962 +* 28Apr03 0.01.03 RamP Fixed a parameter in crc32 fxn call
15963 +* 05May03 0.01.04 RamP Fixed Message structure access in
15964 +* writeHostMailbox function
15965 +* 14May03 0.01.05 RamP Lookup to netService of dsp version
15966 +* (alpha ++) to determine pots/isdn service
15967 +* 21May03 0.01.06 RamP Added support for CO profiles
15968 +* 29May03 0.01.07 RamP Added critical section tabs for block
15969 +* read/write operations
15970 +* Added functions to reload overlay pages
15972 +* 04Jun03 0.01.08 RamP Added state transition timing counters
15973 +* 06Jun03 0.01.09 RamP Added Interrupt source parsing function
15974 +* Interrupt masking for heartbeat added
15975 +* 09Jun03 0.01.10 RamP Modified modem state bit field processing
15976 +* for structure changes in ITIDSLHW
15977 +* fixed problem in free memory for CO prof
15978 +* 18Jul03 0.01.11 RamP Optimized free memory for CO profiles &
15979 +* overlay pages in the supporting APIs
15980 +* 28Jul03 0.02.00 RamP Modified the process bitfield functn
15981 +* for LED & Application State report
15982 +* 21Aug03 0.03.00 RamP Added logic to allocate & communicate
15983 +* memory for constellation buffer display
15984 +* 29Sep03 0.03.01 RamP Added API switch calls to advcfg module
15985 +* to abstract them from the API module
15986 +* 12Oct03 0.03.02 RamP Added API to gather ADSL2 Messages
15987 +* 14Oct03 0.03.03 RamP Added function to read CMsgsRA
15988 +* 23Oct03 0.03.04 RamP Changed train history index to circular
15989 +* buffer upon rollover
15990 +* 29Oct03 0.03.05 RamP Added Adsl2 Delt Message Parsing
15991 +* 12Nov03 0.03.06 RamP Fixed endianness issues with
15992 +* Constellation Display
15993 +* 14Nov03 0.03.07 RamP Added function to gather CRates1/RRates1
15994 +* before they get overwritten by CRatesRA
15995 +* 19Nov03 0.03.08 JohnP Revised dslhal_support_aocBitSwapProcessing to
15996 +* prevent duplicate ATU-R bitswaps going to ACT
15997 +* 24Nov03 0.03.09 RamP Implemented detailed State Tracking through
15998 +* Modem State bit fields for ADSL/2
15999 +* 12Dec03 0.03.10 RamP Tokenized advanced configuration code
16000 +* 12Dec03 0.03.11 RamP Added state reset upon IDLE
16001 +* 19Dec03 0.03.12 RamP Added static adsl2 byteswap function for
16002 +* handling pointer to pointer cases
16003 +* Changed adsl2 messages to correct pointer to
16004 +* pointer dereferencing problems in some OS
16005 +* 26Dec03 0.03.13 RamP Setting Current Address for Constellation
16006 +* buffer in addition to start address
16007 +* Added additional check to overlay page malloc
16008 +*******************************************************************************/
16009 +#include "dsl_hal_register.h"
16010 +#include "dsl_hal_support.h"
16012 +static unsigned int dslhal_support_adsl2ByteSwap32(unsigned int in32Bits);
16014 +/******************************************************************************************
16015 +* FUNCTION NAME: dslhal_support_unresetDslSubsystem
16017 +*******************************************************************************************
16018 +* DESCRIPTION: This function unreset Dsl Subsystem
16022 +* RETURN: 0 if Pass; 1 if Fail
16024 +*****************************************************************************************/
16025 +int dslhal_support_unresetDslSubsystem(void)
16027 + dprintf(4," dslhal_support_unresetDslSubsystem()\n");
16028 + /* Put ADSLSS in to reset */
16029 + DSLHAL_REG32(0xa8611a10) = 0x1;
16030 + shim_osClockWait(64);
16031 + dprintf(5,"Selected APLL Reg \n");
16033 + DSLHAL_REG32(0xa8610a90) = 0x4;
16034 + shim_osClockWait(64);
16035 + dprintf(5,"Enable Analog PLL \n");
16037 + DSLHAL_REG32(0xa8610a90) = 0x77fe;
16038 + shim_osClockWait(64);
16039 + dprintf(5,"Set PLL for DSP\n");
16041 + /* DSLHAL_REG32(0xa8611600) = 0x007f1bdf;*/
16042 + DSLHAL_REG32(0xa8611600) |= RST_CNTRL_PRCR_ADSLSS;
16043 + shim_osClockWait(64);
16044 + dprintf(5,"Brought ADSLSS out of Reset \n");
16046 + DSLHAL_REG32(0xa861090c) &= ~((1<<20)|(1<<21)|(1<<22)|(1<<23)|(1<<24)|(1<<25));
16047 + shim_osClockWait(64);
16048 + dprintf(5,"Configured GPIO 20-25 for McBSP \n");
16050 + /*DSLHAL_REG32(0xa8611600) |= RST_CNTRL_PRCR_ADSLSS;*/
16053 + /* DSLHAL_REG32(0xa8611a04) = 0x00000001;
16054 + shim_osClockWait(64); */
16056 + dprintf(4," dslhal_support_unresetDslSubsystem done\n");
16057 + return DSLHAL_ERROR_NO_ERRORS;
16061 +/******************************************************************************************
16062 +* FUNCTION NAME: dslhal_support_resetDslSubsystem
16064 +*******************************************************************************************
16065 +* DESCRIPTION: This function unreset Dsl Subsystem
16069 +* RETURN: 0 if Pass; 1 if Fail
16071 +*****************************************************************************************/
16072 +int dslhal_support_resetDslSubsystem(void)
16074 + dprintf(4, "dslhal_support_resetDslSubsystem \n");
16075 + /* Put ADSLSS into reset */
16076 + DSLHAL_REG32(0xa8611600) &= ~RST_CNTRL_PRCR_ADSLSS;
16077 + shim_osClockWait(64);
16078 + /* DSLHAL_REG32(0xa8611a04) = 0x00000000;
16079 + shim_osClockWait(64); */
16080 + dprintf(4, "dslhal_support_resetDslSubsystem Done \n");
16081 + return DSLHAL_ERROR_NO_ERRORS;
16084 +/******************************************************************************************
16085 +* FUNCTION NAME: dslhal_support_unresetDsp()
16087 +*******************************************************************************************
16088 +* DESCRIPTION: This fuction takes ax5 daugter board out of reset.
16092 +* RETURN: 0 --successful.
16095 +*****************************************************************************************/
16096 +int dslhal_support_unresetDsp(void)
16098 +#ifdef PRE_SILICON
16099 + /* unsigned char value; */
16102 + rc=dslhal_support_hostDspAddressTranslate((unsigned int)DEV_MDMA0_SRC_ADDR);
16103 + if(rc==DSLHAL_ERROR_ADDRESS_TRANSLATE)
16105 + dprintf(1, "dslhal_support_hostDspAddressTranslate failed\n");
16106 + return DSLHAL_ERROR_ADDRESS_TRANSLATE;
16108 + dprintf(5,"MDMA SRC: %08x\n", rc);
16109 + DSLHAL_REG32(rc) = 0x80000001;
16110 + rc=dslhal_support_hostDspAddressTranslate((unsigned int)DEV_MDMA0_DST_ADDR);
16111 + if(rc==DSLHAL_ERROR_ADDRESS_TRANSLATE)
16113 + dprintf(1, "dslhal_support_hostDspAddressTranslate failed\n");
16114 + return DSLHAL_ERROR_ADDRESS_TRANSLATE;
16116 + dprintf(5,"MDMA DST: %08x\n", rc);
16117 + DSLHAL_REG32(rc) = 0x02090001;
16118 + rc=dslhal_support_hostDspAddressTranslate((unsigned int)DEV_MDMA0_CTL_ADDR);
16119 + if(rc== DSLHAL_ERROR_ADDRESS_TRANSLATE)
16121 + dprintf(1, "dslhal_support_hostDspAddressTranslate failed\n");
16122 + return DSLHAL_ERROR_ADDRESS_TRANSLATE;
16124 + dprintf(5,"MDMA CTL: %08x\n", rc);
16125 + DSLHAL_REG32(rc) = (DEV_MDMA_START | DEV_MDMA_DST_INC | DEV_MDMA_SRC_INC |
16126 + DEV_MDMA_BURST1 | (1 << DEV_MDMA_LEN_SHF));
16127 + /* statusMask = 0x00000010;*/
16129 + dprintf(4, "dslhal_support_unresetDsp()\n");
16131 + /* Bring the DSP core out of reset */
16132 + /* DSLHAL_REG32(0xa8611600) = 0x00ff1bdf; */
16133 + DSLHAL_REG32(0xa8611600) |= RST_CNTRL_PRCR_DSP;
16134 + shim_osClockWait(64);
16135 + dprintf(5,"Brought DSP out of Reset \n");
16136 + dprintf(6,"Current Contents of PRCR: 0x%x\n",(unsigned int)DSLHAL_REG32(0xa8611600));
16137 + /* DSLHAL_REG32(0xa8611a0c) = 0x00000007;
16138 + shim_osClockWait(64); */
16141 + dprintf(4, "dslhal_support_unresetDsp() done\n");
16142 + return DSLHAL_ERROR_NO_ERRORS;
16145 +/******************************************************************************************
16146 +* FUNCTION NAME: dslhal_support_resetDsp()
16148 +*******************************************************************************************
16149 +* DESCRIPTION: This fuction takes ax5 daugter board into reset.
16153 +* RETURN: 0 --successful.
16156 +*****************************************************************************************/
16157 +int dslhal_support_resetDsp(void)
16159 + dprintf(4, "dslhal_support_resetDsp \n");
16160 + /* Put ADSLSS into reset */
16161 + DSLHAL_REG32(0xa8611600) &= ~RST_CNTRL_PRCR_DSP;
16162 + shim_osClockWait(64);
16163 + dprintf(4, "dslhal_support_resetDsp Done \n");
16164 + return DSLHAL_ERROR_NO_ERRORS;
16167 +/********************************************************************************************
16168 +* FUNCTION NAME: dslhal_support_hostDspAddressTranslate()
16170 +*********************************************************************************************
16172 +* Maps ax5 daugter card dsp memory address to avalanche memory space
16174 +* Input: unsigned int addr, dsp memory address.
16176 +* Return: >=0, unsigned int, mapped Avalanche address(VBUS address).
16177 +* -1, mapping failed
16180 +********************************************************************************************/
16181 +/* static unsigned int bbifmap0,bbifmap1; */
16183 +unsigned int dslhal_support_hostDspAddressTranslate( unsigned int addr )
16185 + unsigned int addrMap;
16186 + /* This function should just be used to move the memory window of the ADSLSS */
16187 + dprintf(5, "dslhal_support_hostDspAddressTranslate()\n");
16189 + /* select vbus to xbus memory */
16190 + /* addrMap = addr & 0xff000000; */
16191 + addrMap = addr & ADSLSSADRMASK;
16193 + DSLHAL_REG32(ADSLSSADR) = addrMap;
16195 + dprintf(6, "dslhal_support_hostDspAddressTranslate() done\n");
16196 +#ifdef PRE_SILICON
16197 + return ((ADSLSS_BASE | (~ADSLSSADRMASK & addr))+ 0x00000100);
16198 + /* Added 0x100 for Pre-Silicon VLNQ offset.. to be removed for Silicon */
16200 + return ((ADSLSS_BASE | (~ADSLSSADRMASK & addr)));
16201 + /* Added 0x100 for Pre-Silicon VLNQ offset.. to be removed for Silicon */
16207 +/******************************************************************************************
16208 +* FUNCTION NAME: dslhal_support_blockWrite
16210 +*******************************************************************************************
16211 +* DESCRIPTION: This rouin simulates DSP memory write as done in ax5 pci nic card
16213 +* INPUT: void *buffer, data need to written
16214 +* void *adde, memory address to be written
16215 +* size_t count, number of bytes to be written
16217 +* RETURN: 0 --succeeded
16220 +*****************************************************************************************/
16222 +int dslhal_support_blockWrite(void *buffer, void *addr, size_t count)
16224 + int rc, byteCnt=0;
16225 + unsigned char* ptr;
16228 + unsigned char *cptr;
16234 + int anint; /* DSP location */
16235 + unsigned char *cptr; /* to avoid casts */
16239 + unsigned int anint;
16240 + unsigned char byte[4];
16241 + }data,dword,sword;
16243 + /* Enter Critical Section */
16244 + shim_osCriticalEnter();
16246 + dprintf(6, "dslhal_support_blockWrite\n");
16248 + dprintf(6,"addr=0x%X, length=0x%X, buffer=0x%X\n", (unsigned int) addr, (unsigned int) count, (unsigned int)buffer);
16250 + src.cptr = (unsigned char*) buffer; /* local buffer */
16251 + dst.cptr = addr; /* DSP memory location */
16253 + /*Maps address first*/
16254 + rc=dslhal_support_hostDspAddressTranslate((unsigned int)addr);
16255 + dprintf(5, "NewAddr: %08x\n", rc);
16256 + if(rc== DSLHAL_ERROR_ADDRESS_TRANSLATE)
16258 + dprintf(1, "dslhal_support_hostDspAddressTranslate failed\n");
16259 + return DSLHAL_ERROR_ADDRESS_TRANSLATE;
16262 + dst.cptr=(unsigned char *)rc;
16264 + /* check wether address is at 32bits boundary */
16266 + if ((dst.anint & 0x3) && count)
16268 + sword.anint = *(unsigned int*)((unsigned int)src.cptr & 0xfffffffc);
16269 + dword.anint = DSLHAL_REG32((unsigned int)dst.cptr & 0xfffffffc);
16270 + sword.anint = (unsigned int) dslhal_support_byteSwap32(sword.anint);
16271 + dword.anint = (unsigned int) dslhal_support_byteSwap32(dword.anint);
16272 + ptr = (unsigned char *)((unsigned int)dst.cptr & 0xfffffffc);
16274 + if((dst.anint & 3) ==3) /* last byte of a dword */
16276 + dword.byte[3] = sword.byte[3];
16277 + dst.anint++; /* bump the address by one */
16282 + if((dst.anint & 3) ==1) /* second byte */
16286 + dword.byte[3] = sword.byte[3];
16293 + dword.byte[2] = sword.byte[2];
16300 + dword.byte[1] = sword.byte[1];
16307 + if((dst.anint & 3) && (count >1))
16309 + dword.byte[2] = sword.byte[2];
16310 + dword.byte[3] = sword.byte[3];
16312 + dst.anint += 2; /* bump the address by two */
16313 + count -= 2; /* decrement the byte count by two */
16316 + if((dst.anint & 3) && (count==1))
16318 + dword.byte[2] = sword.byte[2];
16323 + src.cptr = (char *)((unsigned int)src.cptr & 0xfffffffc); /* fix 032802 */
16324 + dword.anint = dslhal_support_byteSwap32(dword.anint);
16325 + DSLHAL_REG32((unsigned int)ptr) = dword.anint;
16327 + for(rc=0;rc<count;rc++)
16329 + *ptr = *(ptr+byteCnt);
16334 + /* the dst pointer should now be on a 32-bit boundary */
16336 + while (count > 3)
16338 + DSLHAL_REG32((unsigned int)dst.cptr) = dslhal_support_byteSwap32(*src.iptr);
16339 + src.iptr++; /* bump the data pointer by four */
16340 + dst.anint += 4; /* bump the address by four */
16341 + count -= 4; /* decrement the byte count by four */
16344 + /* write remaining bytes */
16349 + data.anint= DSLHAL_REG32((unsigned int)dst.cptr);
16350 + data.anint=dslhal_support_byteSwap32(data.anint);
16351 + for (i=0; i< count; i++)
16353 + data.byte[i]=*(src.cptr+i);
16355 + data.anint=dslhal_support_byteSwap32(data.anint);
16356 + DSLHAL_REG32((unsigned int)dst.cptr) = data.anint;
16357 + src.cptr +=count;
16358 + dst.anint +=count;
16361 + dprintf(6, "dslhal_support_blockWrite done\n");
16362 + /* Exit Critical Section */
16363 + shim_osCriticalExit();
16364 + return DSLHAL_ERROR_NO_ERRORS;
16365 +} /* end of dslhal_support_blockWrite() */
16368 +/******************************************************************************************
16369 +* FUNCTION NAME: dslhal_support_blockRead
16371 +*********************************************************************************************
16372 +* DESCRIPTION: This rouin simulates DSP memory read as done in ax5 pci nic card
16374 +* INPUT: void *addr, memory address to be read
16375 +* void *buffer, dat buffer to be filled with from memmory
16376 +* size_t count, number of bytes to be written
16378 +* RETURN: 0 --succeeded
16381 +*****************************************************************************************/
16383 +int dslhal_support_blockRead(void *addr, void *buffer, size_t count)
16388 + int anint; /* DSP location */
16389 + char *cptr; /* to avoid casts */
16394 + int anint; /* DSP data */
16402 + /* Enter Critical Section */
16403 + shim_osCriticalEnter();
16405 + dprintf(6,"dslhal_support_blockRead\n");
16408 + src.cptr = addr; /* DSP memory location */
16409 + dst.cptr = buffer; /* local buffer */
16411 + dprintf(6, "Read addr=0x%X, size=0x%X\n", (unsigned int)addr, count);
16414 + /*Maps address first*/
16415 + rc=dslhal_support_hostDspAddressTranslate((unsigned int)addr);
16416 + if(rc== DSLHAL_ERROR_ADDRESS_TRANSLATE)
16418 + dprintf(1, "dslhal_support_hostDspAddressTranslate failed\n");
16419 + return DSLHAL_ERROR_ADDRESS_TRANSLATE;
16422 + src.cptr=(unsigned char *)rc;
16424 + /**********************************************
16425 + * if the source is NOT on a 32-bit boundary *
16426 + * then we read the full word *
16427 + * and ignore the first part of it *
16428 + **********************************************/
16430 + if ((src.anint & 3) && count)
16432 + unsigned int anword;
16434 + anword = DSLHAL_REG32((unsigned int)src.cptr & 0xfffffffc);
16435 + data.anint = dslhal_support_byteSwap32(anword);
16437 + /************************************
16438 + * there is no need for case 0 *
16439 + * notice that there are no breaks *
16440 + * each falls through to the next *
16441 + ************************************/
16443 + switch (src.anint & 3)
16446 + /* use only byte[1-3] */
16447 + *(dst.cptr++) = data.byte[1];
16451 + /* use byte[2-3] */
16454 + *(dst.cptr++) = data.byte[2];
16459 + /* use byte[3] */
16462 + *(dst.cptr++) = data.byte[3];
16469 + /* the src pointer should now be on a 32-bit boundary */
16470 + while (count > 3)
16472 + unsigned int anword;
16474 + anword=DSLHAL_REG32((unsigned int)src.cptr);
16476 + *dst.iptr = dslhal_support_byteSwap32(anword);
16477 + src.anint += 4; /* bump the address by four */
16478 + dst.iptr++; /* bump the data pointer by four */
16479 + count -= 4; /* decrement the byte count by four */
16482 + /*******************************
16483 + * if there's any count left *
16484 + * then we read the next word *
16485 + * and ignore the end of it *
16486 + *******************************/
16489 + unsigned int anword;
16491 + anword= DSLHAL_REG32((unsigned int)src.cptr);
16492 + data.anint = dslhal_support_byteSwap32(anword);
16494 + /************************************
16495 + * there is no need for case 0 *
16496 + * notice that there are no breaks *
16497 + * each falls through to the next *
16498 + ************************************/
16502 + /* use byte[0] */
16503 + *(dst.cptr++) = data.byte[0];
16508 + /* use byte[0-1] */
16509 + *(dst.cptr++) = data.byte[0];
16510 + *(dst.cptr++) = data.byte[1];
16515 + /* use only byte[0-2] */
16516 + *(dst.cptr++) = data.byte[0];
16517 + *(dst.cptr++) = data.byte[1];
16518 + *(dst.cptr++) = data.byte[2];
16524 + /* Exit Critical Section */
16525 + shim_osCriticalExit();
16527 + return DSLHAL_ERROR_NO_ERRORS;
16529 +} /* end of dslhal_support_blockRead() */
16532 +/********************************************************************************************
16533 +* FUNCTION NAME: dslhal_support_readDspMailbox
16535 +*********************************************************************************************
16536 +* DESCRIPTION: Reads a message from the mailbox
16538 +* ARGUMENTS: int *pcmd Pointer to command read
16540 +* RETURNS: 0 if successful
16544 +*****************************************************************************************/
16546 +int dslhal_support_readDspMailbox(tidsl_t *ptidsl, int *pcmd, int *ptag, int *pprm1, int *pprm2)
16553 + unsigned char dspOutInx;
16554 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
16555 + DEV_HOST_mailboxControl_t mailboxControl;
16556 + DEV_HOST_dspHostMsg_t dspMailboxMsg[DEV_HOST_DSPQUEUE_LENGTH];
16558 + dprintf(6,"dslhal_support_readDspMailbox\n");
16560 + /* get the DSP main pointer */
16562 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
16564 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
16565 + sizeof(DEV_HOST_dspOamSharedInterface_t));
16568 + dprintf(1,"dslhal_support_blockRead failed\n");
16569 + return DSLHAL_ERROR_BLOCK_READ;
16572 + /* Read in the command/response buffer */
16573 + dspOamSharedInterface.dspHostMailboxControl_p = (DEV_HOST_mailboxControl_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspHostMailboxControl_p);
16576 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspHostMailboxControl_p,
16577 + &mailboxControl, sizeof(DEV_HOST_mailboxControl_t));
16581 + dprintf(1,"dslhal_support_blockRead failed\n");
16582 + return DSLHAL_ERROR_BLOCK_READ;
16585 + /* Change the endianness of the Mailbox Pointer */
16586 + mailboxControl.dspMsgBuf_p = (DEV_HOST_dspHostMsg_t *) dslhal_support_byteSwap32((unsigned int)mailboxControl.dspMsgBuf_p);
16588 + rc = dslhal_support_blockRead((PVOID)mailboxControl.dspMsgBuf_p,
16589 + &dspMailboxMsg, (sizeof(DEV_HOST_dspHostMsg_t)*DEV_HOST_DSPQUEUE_LENGTH));
16592 + return DSLHAL_ERROR_BLOCK_READ;
16593 + /* Extract the command/response message index */
16594 + mailboxControl.hostInInx &= 7;
16595 + mailboxControl.hostOutInx &= 7;
16596 + mailboxControl.dspOutInx &= 7;
16597 + mailboxControl.dspInInx &= 7;
16600 + /* check for messages in the mailbox */
16602 + if (mailboxControl.dspOutInx == mailboxControl.dspInInx)
16604 + return DSLHAL_ERROR_MAILBOX_NOMAIL;
16605 + /* no messages to read */
16608 + /* use bDRESPOutInx as index to DRESPMsgBuf */
16610 + cmd = dspMailboxMsg[mailboxControl.dspOutInx].cmd;
16611 + tag = dspMailboxMsg[mailboxControl.dspOutInx].tag;
16612 + prm1= dspMailboxMsg[mailboxControl.dspOutInx].param1;
16613 + prm2= dspMailboxMsg[mailboxControl.dspOutInx].param2;
16615 + mailboxControl.dspOutInx++; /* increment count */
16616 + mailboxControl.dspOutInx &= 7; /* only two bits */
16618 + dspOutInx = mailboxControl.dspOutInx;
16620 + /* Read in the command response buffer again to take care of changes */
16621 + mailboxControl.dspOutInx = dspOutInx;
16622 + rc = dslhal_support_blockWrite(&mailboxControl.dspOutInx,
16623 + &dspOamSharedInterface.dspHostMailboxControl_p->dspOutInx, sizeof(BYTE));
16626 + return DSLHAL_ERROR_BLOCK_WRITE;
16628 + /* Is the input parameter address non-zero*/
16647 + dprintf(6,"dslhal_support_readDspMailbox done\n");
16648 + dprintf(6,"cmd=%d, tag=%d\n", cmd, tag);
16649 + dprintf(6,"dslhal_support_readDspMailbox:cmd: 0x%x, tag=%d\n", cmd, tag);
16650 + return DSLHAL_ERROR_NO_ERRORS;
16652 +} /* end of dslhal_support_readDspMailbox() */
16654 +/*******************************************************************************************
16655 +* FUNCTION NAME: dslhal_support_writeHostMailbox
16657 +********************************************************************************************
16658 +* DESCRIPTION: Send a message to a mailbox
16660 +* ARGUMENTS: int cmd command to write
16661 +* int tag tag (currently unused)
16662 +* int p1 parameter 1 (currently unused)
16663 +* int p2 parameter 2 (currently unused)
16665 +* RETURNS: 0 if successful
16668 +*******************************************************************************************/
16670 +int dslhal_support_writeHostMailbox(tidsl_t *ptidsl, int cmd, int tag, int p1, int p2)
16674 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
16675 + DEV_HOST_mailboxControl_t mailboxControl;
16676 + DEV_HOST_dspHostMsg_t hostMailboxMsg[DEV_HOST_HOSTQUEUE_LENGTH];
16677 + unsigned char hostInInx;
16679 + dprintf(6,"dslhal_support_writeHostMailbox:cmd: 0x%x, tag=%d\n", cmd, tag);
16681 + dprintf(6,"cmd=%d, tag=%d\n", cmd, tag);
16683 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
16685 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
16686 + sizeof(DEV_HOST_dspOamSharedInterface_t));
16689 + dprintf(1,"dslhal_support_blockRead failed\n");
16690 + return DSLHAL_ERROR_BLOCK_READ;
16692 + /* Read in the command/response buffer */
16693 + dspOamSharedInterface.dspHostMailboxControl_p = (DEV_HOST_mailboxControl_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspHostMailboxControl_p);
16695 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspHostMailboxControl_p,
16696 + &mailboxControl, sizeof(DEV_HOST_mailboxControl_t));
16700 + dprintf(1,"dslhal_support_blockRead failed\n");
16701 + return DSLHAL_ERROR_BLOCK_READ;
16703 + /* Change the endianness of the Mailbox Control Pointer */
16704 + mailboxControl.hostMsgBuf_p = (DEV_HOST_dspHostMsg_t *) dslhal_support_byteSwap32((unsigned int)mailboxControl.hostMsgBuf_p);
16705 + rc = dslhal_support_blockRead((PVOID)mailboxControl.hostMsgBuf_p,
16706 + &hostMailboxMsg, (sizeof(DEV_HOST_dspHostMsg_t)*DEV_HOST_HOSTQUEUE_LENGTH));
16709 + return DSLHAL_ERROR_BLOCK_READ;
16710 + /* Extract the command/response message index */
16711 + mailboxControl.hostInInx &= 7;
16712 + mailboxControl.hostOutInx &= 7;
16713 + mailboxControl.dspOutInx &= 7;
16714 + mailboxControl.dspInInx &= 7;
16716 + /* make sure there's room in the mailbox */
16718 + index = mailboxControl.hostInInx;
16719 + mailboxControl.hostInInx++;
16720 + mailboxControl.hostInInx &= 7;
16721 + hostInInx = mailboxControl.hostInInx;
16722 + if (mailboxControl.hostInInx == mailboxControl.hostOutInx)
16724 + /* mailbox is full */
16725 + return DSLHAL_ERROR_MAILBOX_OVERFLOW;
16728 + /* use bOCMDInInx as index to OCMDMsgBuf */
16729 + hostMailboxMsg[index].cmd = (BYTE) cmd;
16730 + hostMailboxMsg[index].tag = (BYTE) tag;
16731 + hostMailboxMsg[index].param1 = (BYTE) p1;
16732 + hostMailboxMsg[index].param2 = (BYTE) p2;
16733 + rc = dslhal_support_blockWrite(&hostMailboxMsg,
16734 + (PVOID)mailboxControl.hostMsgBuf_p,
16735 + sizeof(DEV_HOST_dspHostMsg_t)*DEV_HOST_HOSTQUEUE_LENGTH);
16738 + dprintf(1,"dslhal_support_blockWrite failed\n");
16739 + return DSLHAL_ERROR_BLOCK_READ;
16741 + rc = dslhal_support_blockWrite(&mailboxControl,
16742 + &dspOamSharedInterface.dspHostMailboxControl_p,
16743 + sizeof(DEV_HOST_mailboxControl_t));
16745 + return DSLHAL_ERROR_BLOCK_WRITE;
16746 + /* update the index */
16747 + mailboxControl.hostInInx = hostInInx;
16748 + rc = dslhal_support_blockWrite(&mailboxControl.hostInInx,
16749 + &dspOamSharedInterface.dspHostMailboxControl_p->hostInInx,
16752 + return DSLHAL_ERROR_BLOCK_WRITE;
16754 + dprintf(6,"dslhal_support_writeHostMailbox done\n");
16755 + return DSLHAL_ERROR_NO_ERRORS;
16758 +/* end of dslhal_support_writeHostMailbox() */
16761 +/********************************************************************************************
16762 +* FUNCTION NAME: dslhal_support_readTextMailbox
16764 +*********************************************************************************************
16765 +* DESCRIPTION: Reads a message from the mailbox
16767 +* ARGUMENTS: int *pcmd Pointer to command read
16769 +* RETURNS: 0 if successful
16773 +*****************************************************************************************/
16775 +int dslhal_support_readTextMailbox(tidsl_t *ptidsl, int *pmsg1, int *pmsg2)
16778 + unsigned int msg1;
16779 + unsigned int msg2;
16780 + unsigned char textOutInx;
16781 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
16782 + DEV_HOST_mailboxControl_t mailboxControl;
16783 + DEV_HOST_textMsg_t textMailboxMsg[DEV_HOST_TEXTQUEUE_LENGTH];
16785 + dprintf(6,"dslhal_support_readTextMailbox\n");
16787 + /* get the DSP main pointer */
16789 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
16791 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
16792 + sizeof(DEV_HOST_dspOamSharedInterface_t));
16795 + dprintf(1,"dslhal_support_blockRead failed\n");
16796 + return DSLHAL_ERROR_BLOCK_READ;
16799 + /* Read in the command/response buffer */
16800 + dspOamSharedInterface.dspHostMailboxControl_p = (DEV_HOST_mailboxControl_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspHostMailboxControl_p);
16803 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspHostMailboxControl_p,
16804 + &mailboxControl, sizeof(DEV_HOST_mailboxControl_t));
16808 + dprintf(1,"dslhal_support_blockRead failed\n");
16809 + return DSLHAL_ERROR_BLOCK_READ;
16812 + /* Change the endianness of the Mailbox Pointer */
16813 + mailboxControl.textMsgBuf_p = (DEV_HOST_textMsg_t *) dslhal_support_byteSwap32((unsigned int)mailboxControl.textMsgBuf_p);
16815 + rc = dslhal_support_blockRead((PVOID)mailboxControl.textMsgBuf_p,
16816 + &textMailboxMsg, (sizeof(DEV_HOST_textMsg_t)*DEV_HOST_DSPQUEUE_LENGTH));
16819 + return DSLHAL_ERROR_BLOCK_READ;
16820 + /* Extract the command/response message index */
16822 + mailboxControl.textInInx &= 7;
16823 + mailboxControl.textOutInx &= 7;
16825 + /* check for messages in the mailbox */
16827 + if (mailboxControl.textOutInx == mailboxControl.textInInx)
16829 + return DSLHAL_ERROR_MAILBOX_NOMAIL;
16830 + /* no messages to read */
16833 + /* use bDRESPOutInx as index to DRESPMsgBuf */
16835 + msg1 = textMailboxMsg[mailboxControl.textOutInx].msgPart1;
16836 + msg2 = textMailboxMsg[mailboxControl.textOutInx].msgPart2;
16837 + msg1 = (unsigned int) dslhal_support_byteSwap32((unsigned int)msg1);
16838 + msg2 = (unsigned int) dslhal_support_byteSwap32((unsigned int)msg2);
16840 + mailboxControl.textOutInx++; /* increment count */
16841 + mailboxControl.textOutInx &= 7; /* only two bits */
16843 + textOutInx = mailboxControl.textOutInx;
16845 + /* Read in the command response buffer again to take care of changes */
16847 + mailboxControl.textOutInx = textOutInx;
16849 + rc = dslhal_support_blockWrite(&mailboxControl.textOutInx,
16850 + &dspOamSharedInterface.dspHostMailboxControl_p->textOutInx, sizeof(BYTE));
16853 + return DSLHAL_ERROR_BLOCK_WRITE;
16855 + /* Is the input parameter address non-zero*/
16866 + dprintf(6,"dslhal_support_readTextMailbox done\n");
16867 + dprintf(6,"msgPart1=%d, msgPart2=%d\n", msg1, msg2);
16868 + dprintf(6,"dslhal_support_readTextMailbox:Message Part1: 0x%x, tag=0x%x\n", msg1, msg2);
16869 + return DSLHAL_ERROR_NO_ERRORS;
16871 +} /* end of dslhal_support_readTextMailbox() */
16875 +/********************************************************************************************
16876 +* FUNCTION NAME: dslhal_support_hostDspCodeDownload()
16878 +*********************************************************************************************
16880 +* download DSP image from host memory to dsp memory
16882 +* Return: 0 success
16886 +* DSP image is based on LITTLE endian
16888 +********************************************************************************************/
16890 +int dslhal_support_hostDspCodeDownload(tidsl_t * ptidsl)
16893 + unsigned int index;
16895 + unsigned char *iptr; /* image pointer */
16896 + unsigned int numbytes,olayXfer,olayStore;
16897 + /* unsigned int holdSecPhyAddr=0,holdSecVirtAddr; */
16898 + unsigned int *olayStart;
16899 + size_t len; /* size of the file */
16900 + size_t expoffset; /* expected offset for next section header */
16901 + unsigned short checksum;
16902 + unsigned int crc32;
16903 + unsigned char * image;
16904 + char *tmp = (char *)DEV_HOST_DSP_OAM_POINTER_LOCATION;
16905 + DEV_HOST_dspVersionDef_t dspVersion;
16907 + DEV_HOST_tcHostCommDef_t TCHostCommDef;
16909 + DEV_HOST_oamWrNegoParaDef_t OamWrNegoParaDef;
16910 + DEV_HOST_dspOamSharedInterface_t dspOamSharedInterface, *pdspOamSharedInterface;
16911 + DEV_HOST_olayDpDef_t olayDpParms;
16912 + DEV_HOST_profileBase_t profileList;
16914 + DEV_HOST_consBufDef_t constDisp;
16917 + DEV_HOST_coData_t coData;
16919 + DEV_HOST_olayDpPageDef_t olayDpPageDef[NUM_PAGES];
16923 + unsigned short hword[2];
16924 + unsigned int aword;
16929 + char signature[6];
16930 + unsigned short sectcount;
16931 + unsigned int length;
16936 + unsigned int addr;
16937 + unsigned int length;
16938 + unsigned int offset;
16939 + unsigned int page;
16940 + };/* section[MAXSECTIONS]; */
16942 + struct _section *sptr;
16943 + unsigned int secAddr, secLength, secOffset, secPage;
16946 + dprintf(5,"dslhal_support_hostDspCodeDownload\n");
16947 + image = ptidsl->fwimage;
16951 + dprintf(1,"no image file\n");
16952 + return DSLHAL_ERROR_NO_FIRMWARE_IMAGE;
16957 + numbytes = sizeof(header);
16959 + shim_osMoveMemory((char *) &header, (char *)iptr, numbytes);
16960 + header.length = dslhal_support_byteSwap32(header.length);
16961 + header.sectcount = dslhal_support_byteSwap16(header.sectcount);
16963 + crc32 = dslhal_support_computeCrc32((unsigned char*)&crcTest[0],20);
16964 + dprintf(6,"CRC-32 for the crcTest: 0x%x",crc32);
16965 + dprintf(4,"header.length=%d, header.sectcount=0x%X\n", header.length, header.sectcount);
16967 + /* point to the checksum */
16968 + /* compute the checksum on CRC32 here */
16969 + iptr = image + header.length-4;
16970 + numbytes = sizeof(data.aword);
16972 + dprintf(5,"tiload: check checksum\n");
16973 + shim_osMoveMemory((char *)&(data.byte), (char *)iptr, numbytes);
16975 + crc32 = dslhal_support_computeCrc32(image,ptidsl->imagesize);
16976 + dprintf(5,"CRC-32 for the Binary: 0x%x",crc32);
16977 + /* CRC currently not added to the DSP binary, so this code is commented out */
16979 + data.aword = dslhal_support_byteSwap32(data.aword);
16980 + if (data.aword != crc32)
16982 + dprintf(1,"Checksum error\n");
16985 + /* Verify signature - Changed from "320C6x" to "TIDSL" for load 80 */
16987 + header.signature[5]='\0';
16988 + dprintf(5, "signature=%s\n", header.signature);
16990 + if (shim_osStringCmp(header.signature, "TIDSL"))
16992 + dprintf(1,"Signature not match\n");
16993 + return DSLHAL_ERROR_FIRMWARE_OFFSET;
16996 + dprintf(5,"tiload: check sect count\n");
16997 + /* check section count */
16999 + if (header.sectcount > MAXSECTIONS)
17001 + dprintf(1,"Section # %d exceeds max %d\n", header.sectcount, MAXSECTIONS);
17002 + return DSLHAL_ERROR_FIRMWARE_OFFSET;
17006 + dprintf(5,"found %d sections\n", header.sectcount);
17009 + /* Validation of Section offsets */
17011 + /* point to the first section */
17012 + len = header.length; /* file size in bytes */
17013 + expoffset = sizeof(struct _header) + header.sectcount * sizeof(struct _section);
17015 + dprintf(5,"tiload: check offset\n");
17016 + for (index=0; index<header.sectcount; index++) /* parse the sections one by one */
17018 + numbytes = sizeof(struct _header) + index * sizeof(struct _section); /* Compute Section Offset */
17019 + sptr = (struct _section *)(image + numbytes); /* Section Pointer to beginning of the section */
17021 + secAddr = dslhal_support_byteSwap32(sptr->addr);
17022 + secOffset = dslhal_support_byteSwap32(sptr->offset);
17023 + secLength = dslhal_support_byteSwap32(sptr->length);
17024 + secPage = dslhal_support_byteSwap32(sptr->page);
17026 + /* validate offset */
17027 + if ( secOffset== 0xffffffff)
17029 + /* special case: zero fill */
17030 + /* offset is valid, don't change expoffset */
17034 + if (secOffset > len-4)
17036 + dprintf(5,"Offset error\n");
17037 + return DSLHAL_ERROR_FIRMWARE_OFFSET;
17040 + /* determine expected offset of NEXT section */
17041 + expoffset = secLength + secOffset;
17043 + /* all addresses must be on word boundaries */
17051 + /* check final offset - should just be a checksum left */
17052 +/* IMPORTANT 11/24/02 --> Got this error... but bypassed for Pf of Concept*/
17054 + if (expoffset != len-4)
17056 + dprintf(5,"Final offset error\n");
17057 + return DSLHAL_ERROR_FIRMWARE_OFFSET;
17061 + /* Actual Code loading to DSP Memory */
17063 + /* Initialize DSP Data Memory before code load*/
17064 + dprintf(5,"Zero Prefill DSP DMEM\n");
17065 + DSLHAL_REG32(ADSLSSADR)=0x80000000;
17066 + shim_osZeroMemory((char *)0xa1000000, 0x10000);
17067 + /* Load sections from the image */
17068 + for (index=0; index<header.sectcount; index++) /* Parse each section */
17070 + numbytes = sizeof(header) + index * sizeof(struct _section); /* Compute offset to next section */
17071 + sptr = (struct _section *)(image + numbytes); /* Point to next section */
17073 + secAddr = dslhal_support_byteSwap32(sptr->addr);
17074 + secOffset = dslhal_support_byteSwap32(sptr->offset);
17075 + secLength = dslhal_support_byteSwap32(sptr->length);
17076 + secPage = dslhal_support_byteSwap32(sptr->page);
17078 + data.aword = secAddr;
17079 + checksum += data.byte[0] + data.byte[1] + data.byte[2] + data.byte[3];
17081 + data.aword = secLength;
17082 + checksum += data.byte[0] + data.byte[1] + data.byte[2] + data.byte[3];
17084 + data.aword = secOffset;
17085 + checksum += data.byte[0] + data.byte[1] + data.byte[2] + data.byte[3];
17087 + data.aword = secPage;
17088 + checksum += data.byte[0] + data.byte[1] + data.byte[2] + data.byte[3];
17091 + /* validate offset */
17092 + if (secOffset == 0xffffffff)
17094 + /* special case: zero fill */
17095 + /* offset is valid, don't change expoffset */
17099 + /* real offset */
17100 + if(secOffset > len-4)
17102 + dprintf(5,"section[%u] offset too big (%X/%X)\n", index,
17103 + secOffset, len-4);
17105 + return DSLHAL_ERROR_FIRMWARE_OFFSET;
17108 + /* determine expected offset of NEXT section */
17109 + expoffset = secLength + secOffset;
17115 + /* check final offset - should just be a checksum left */
17117 + if(expoffset != len-4)
17119 + dprintf(1,"sections don't span full file (%X/%X)\n",expoffset,len-2);
17120 + return DSLHAL_ERROR_FIRMWARE_OFFSET;
17123 + dprintf(5,"tiload: load binary\n");
17125 + for (index=0; index<header.sectcount; index++)
17127 + numbytes = sizeof(header) + index * sizeof(struct _section);
17128 + sptr = (struct _section *)(image + numbytes);
17130 + secAddr = dslhal_support_byteSwap32(sptr->addr);
17131 + secOffset = dslhal_support_byteSwap32(sptr->offset);
17132 + secLength = dslhal_support_byteSwap32(sptr->length);
17133 + secPage = dslhal_support_byteSwap32(sptr->page);
17134 + dprintf(5,"loading section %u\n", index);
17135 + dprintf(5,"section %u: addr: %X\n", index, secAddr);
17136 + dprintf(5,"section %u: length: %X\n", index, secLength);
17137 + dprintf(5,"section %u: offset: %X\n", index, secOffset);
17138 + dprintf(5,"section %u: page: %X\n", index, secPage);
17140 + /* point to the section's data */
17141 + if(secOffset != 0xffffffff)
17143 + /* Load this section of data */
17144 + iptr = image + secOffset;
17145 + dprintf(6, "iptr %8x\n", (unsigned int)iptr);
17150 + dprintf(6,"OVERLAY PAGE #%d\n",secPage);
17151 + /* overlay page, don't write to dsp yet, save into host memory*/
17153 + dprintf(6,"Section Length: %d \n",secLength);
17154 + ptidsl->olayDpPage[secPage].PmemStartWtAddr = (unsigned int) shim_osAllocateDmaMemory(secLength);
17155 + if(ptidsl->olayDpPage[secPage].PmemStartWtAddr == NULL)
17157 + dprintf(1, "overlay page allocate error\n");
17158 + return DSLHAL_ERROR_OVERLAY_MALLOC;
17160 +#ifdef PRE_SILICON
17161 + ptidsl->olayDpPage[secPage].overlayHostAddr = ((((ptidsl->olayDpPage[secPage].PmemStartWtAddr)-0x84000000)-0x10000000)+0x030b0000);
17163 + /* ptidsl->olayDpPage[secPage].overlayHostAddr = ((unsigned int)(ptidsl->olayDpPage[secPage].PmemStartWtAddr)&~0xe0000000); */
17164 + ptidsl->olayDpPage[secPage].overlayHostAddr = virtual2Physical((unsigned int)ptidsl->olayDpPage[secPage].PmemStartWtAddr);
17166 + dprintf(6,"Allocated Addr: 0x%x \t Xlated Addr: 0x%x \n",ptidsl->olayDpPage[secPage].PmemStartWtAddr,ptidsl->olayDpPage[secPage].overlayHostAddr);
17168 + ptidsl->olayDpPage[secPage].overlayHostAddr = (unsigned int)dslhal_support_byteSwap32(ptidsl->olayDpPage[secPage].overlayHostAddr);
17169 + ptidsl->olayDpPage[secPage].OverlayXferCount = secLength;
17170 + ptidsl->olayDpPage[secPage].BinAddr = secAddr;
17171 + ptidsl->olayDpPage[secPage].SecOffset = secOffset;
17172 + shim_osMoveMemory((char *)ptidsl->olayDpPage[secPage].PmemStartWtAddr, (char *)iptr, secLength);
17173 + /* RamP Image ByteSwap test */
17174 + olayStart = (unsigned int *)ptidsl->olayDpPage[secPage].PmemStartWtAddr;
17176 + for(olayXfer=0;olayXfer< secLength/4;olayXfer++)
17178 + olayStore = *(unsigned int *)olayStart;
17179 + olayStore = (unsigned int)dslhal_support_byteSwap32(olayStore);
17180 + *(unsigned int*)olayStart = olayStore;
17181 + dprintf(5, "Addr:0x%x \t Content: 0x%x \n",olayStart,olayStore);
17185 + /* RamP Image ByteSwap test */
17186 + /* compute the CRC of each overlay page and Store the Checksum in a local global variable */
17187 + /* This Value of CRC is to be compared with the header where all the CRC bytes are lumped together */
17188 + ptidsl->olayDpPage[secPage].olayPageCrc32 = dslhal_support_computeCrc32((char *)ptidsl->olayDpPage[secPage].PmemStartWtAddr, ptidsl->olayDpPage[secPage].OverlayXferCount);
17190 + shim_osWriteBackCache((void *)ptidsl->olayDpPage[secPage].PmemStartWtAddr, secLength);
17194 + rc = secAddr&0xff000000;
17195 + if(rc && rc!=0x80000000)
17197 + dprintf(4,"Not DSP PMEM/DMEM\n");
17198 + /* don't write to dsp, save into host memory*/
17199 + dprintf(4,"Section Addr: %x Section Length: %d \n",secAddr,secLength);
17200 + ptidsl->coProfiles.PmemStartWtAddr = (unsigned int) shim_osAllocateDmaMemory(secLength);
17201 + if(ptidsl->coProfiles.PmemStartWtAddr == NULL)
17203 + dprintf(1, "memory allocate error\n");
17204 + return DSLHAL_ERROR_OVERLAY_MALLOC;
17206 + ptidsl->coProfiles.overlayHostAddr = virtual2Physical((unsigned int)ptidsl->coProfiles.PmemStartWtAddr);
17207 + dprintf(4,"Allocated Addr: 0x%x \t Xlated Addr: 0x%x \n",ptidsl->coProfiles.PmemStartWtAddr, ptidsl->coProfiles.overlayHostAddr);
17208 + ptidsl->coProfiles.overlayHostAddr = (unsigned int)dslhal_support_byteSwap32(ptidsl->coProfiles.overlayHostAddr);
17209 + ptidsl->coProfiles.OverlayXferCount = secLength;
17210 + ptidsl->coProfiles.BinAddr = secAddr;
17211 + ptidsl->coProfiles.SecOffset = secOffset;
17213 + shim_osMoveMemory((char *)ptidsl->coProfiles.PmemStartWtAddr, (char *)iptr, secLength);
17214 + /* RamP Image ByteSwap test */
17215 + olayStart = (unsigned int *)ptidsl->coProfiles.PmemStartWtAddr;
17217 + for(olayXfer=0;olayXfer< secLength/4;olayXfer++)
17219 + olayStore = *(unsigned int *)olayStart;
17220 + olayStore = (unsigned int)dslhal_support_byteSwap32(olayStore);
17221 + *(unsigned int*)olayStart = olayStore;
17222 + dprintf(5, "Addr:0x%x \t Content: 0x%x \n",olayStart,olayStore);
17226 + shim_osWriteBackCache((void *)ptidsl->coProfiles.PmemStartWtAddr, secLength);
17230 + /* IMPORTANT: write image to DSP memory */
17231 + rc=dslhal_support_blockWrite((void *)iptr, (void *)secAddr, secLength);
17234 + dprintf(1,"dslhal_support_blockRead failed\n");
17235 + return DSLHAL_ERROR_BLOCK_READ;
17237 + shim_osClockWait(0x50000);
17239 + rc=dslhal_support_blockRead((void*)secAddr, (void*)tmpBuffer, secLength);
17242 + dprintf(1,"dslhal_support_blockRead failed\n");
17243 + return DSLHAL_ERROR_BLOCK_READ;
17245 + for(i=0;i<secLength;i++)
17251 + } /* end of write dsp image */
17253 + /***********************************************************************************
17254 + * Start to fillup various values to our hardware structure for late use
17255 + ************************************************************************************/
17257 + /* get main pointer for data */
17259 + rc = dslhal_support_blockRead(tmp, &pdspOamSharedInterface, sizeof(unsigned int));
17260 + dprintf(5, "tmp=0x%X, addr=0x%X\n", (unsigned int)tmp, (unsigned int)pdspOamSharedInterface);
17261 + pdspOamSharedInterface= (DEV_HOST_dspOamSharedInterface_t *)dslhal_support_byteSwap32((unsigned int)pdspOamSharedInterface);
17262 + dprintf(5, "tmp=0x%X, addr=0x%X\n", (unsigned int)tmp, (unsigned int)pdspOamSharedInterface);
17265 + dprintf(1,"dslhal_support_blockRead failed\n");
17266 + return DSLHAL_ERROR_BLOCK_READ;
17269 + if(!pdspOamSharedInterface)
17271 + dprintf(1,"Couldn't read main pointer\n");
17272 + return DSLHAL_ERROR_INVALID_PARAM;
17275 + ptidsl->pmainAddr=pdspOamSharedInterface;
17277 + /* read the OamSharedInterfaceStructure */
17279 + dprintf(5,"ptidsl->hostIf.mainAddr=0x%X\n", (unsigned int)ptidsl->pmainAddr);
17281 + /* get the pointer to DSP-OAM Shared Interface */
17282 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
17283 + sizeof(DEV_HOST_dspOamSharedInterface_t));
17286 + dprintf(1,"dslhal_support_blockRead failed\n");
17287 + return DSLHAL_ERROR_BLOCK_READ;
17289 + /* Communicate the Allocated Memory Address to DSP to choose CO Profiles */
17291 + /* Change the Endianness of the profileList pointer */
17292 + dspOamSharedInterface.profileList_p = (DEV_HOST_profileBase_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.profileList_p);
17293 + /* Access the profileList Structure */
17294 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.profileList_p,&profileList, sizeof(DEV_HOST_profileBase_t));
17298 + dprintf(1,"dslhal_support_blockRead failed\n");
17299 + return DSLHAL_ERROR_BLOCK_READ;
17301 + dprintf(2,"Old Addr:%x New: %x \n",profileList.hostProfileBase_p,ptidsl->coProfiles.overlayHostAddr);
17302 + profileList.hostProfileBase_p = (DEV_HOST_coData_t *)ptidsl->coProfiles.overlayHostAddr;
17303 + rc = dslhal_support_blockWrite(&profileList,(PVOID)dspOamSharedInterface.profileList_p,sizeof(DEV_HOST_profileBase_t));
17305 + return DSLHAL_ERROR_BLOCK_WRITE;
17307 + /* Communicate the Allocated Memory Address to DSP to do overlays */
17309 + /* Change the Endianness of the olayDpDef pointer */
17310 + dspOamSharedInterface.olayDpParms_p = (DEV_HOST_olayDpDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.olayDpParms_p);
17311 + /* Access the olayDpDef Structure */
17312 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.olayDpParms_p,&olayDpParms, sizeof(DEV_HOST_olayDpDef_t));
17316 + dprintf(1,"dslhal_support_blockRead failed\n");
17317 + return DSLHAL_ERROR_BLOCK_READ;
17321 + for(i=1;i<NUM_PAGES;i++)
17323 + /* Change the endianness of the olayDpPageDef Pointer */
17324 + olayDpParms.olayDpPage_p[i] = (DEV_HOST_olayDpPageDef_t *) dslhal_support_byteSwap32((unsigned int)olayDpParms.olayDpPage_p[i]);
17325 + /* Access the olayDpPageDef Structure */
17326 + rc = dslhal_support_blockRead((PVOID)olayDpParms.olayDpPage_p[i],&olayDpPageDef[i],sizeof(DEV_HOST_olayDpPageDef_t));
17328 + return DSLHAL_ERROR_BLOCK_READ;
17329 + olayDpPageDef[i].overlayHostAddr = ptidsl->olayDpPage[i].overlayHostAddr;
17330 + rc = dslhal_support_blockWrite(&olayDpPageDef[i],(PVOID)olayDpParms.olayDpPage_p[i],sizeof(DEV_HOST_olayDpPageDef_t));
17332 + return DSLHAL_ERROR_BLOCK_WRITE;
17335 + /* Change the endianness of the Datapump Version Pointer */
17336 + dspOamSharedInterface.datapumpVersion_p = (DEV_HOST_dspVersionDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.datapumpVersion_p);
17338 + /* get DSPVersion itself */
17340 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.datapumpVersion_p,&dspVersion, sizeof(DEV_HOST_dspVersionDef_t));
17344 + dprintf(1,"dslhal_support_blockRead failed\n");
17345 + return DSLHAL_ERROR_BLOCK_READ;
17348 + /* table_dsp info */
17350 + dspOamSharedInterface.tcHostComm_p = (DEV_HOST_tcHostCommDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.tcHostComm_p);
17351 + rc = dslhal_support_blockRead(&pdspOamSharedInterface->tcHostComm_p,
17352 + &pTCHostCommDef, 4);
17355 + dprintf(1,"dslhal_support_blockRead failed\n");
17356 + return DSLHAL_ERROR_BLOCK_READ;
17359 + pTCHostCommDef=(DEV_HOST_tcHostCommDef_t *) dslhal_support_byteSwap32((unsigned int)pTCHostCommDef);
17361 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.tcHostComm_p,
17362 + &TCHostCommDef, sizeof(DEV_HOST_tcHostCommDef_t));
17365 + dprintf(1,"dslhal_support_blockRead failed\n");
17366 + return DSLHAL_ERROR_BLOCK_READ;
17369 + /* Select the Multimode Training */
17370 + dspOamSharedInterface.oamWriteNegoParams_p = (DEV_HOST_oamWrNegoParaDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.oamWriteNegoParams_p);
17371 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.oamWriteNegoParams_p, &OamWrNegoParaDef, sizeof(DEV_HOST_oamWrNegoParaDef_t));
17374 + dprintf(1,"dslhal_support_blockRead failed\n");
17375 + return DSLHAL_ERROR_BLOCK_READ;
17377 +switch(dspVersion.netService)
17379 + case 1: OamWrNegoParaDef.stdMode = MULTI_MODE;
17380 + dprintf(5,"POTS Service \n");
17381 + ptidsl->netService = 1;
17383 + case 2: OamWrNegoParaDef.stdMode = GDMT_MODE;
17384 + dprintf(5,"ISDN Service \n");
17385 + ptidsl->netService = 2;
17387 + default: OamWrNegoParaDef.stdMode = T1413_MODE;
17388 + dprintf(5,"Default Service \n");
17392 + ptidsl->AppData.StdMode = (unsigned int)OamWrNegoParaDef.stdMode;
17394 + OamWrNegoParaDef.oamFeature = dslhal_support_byteSwap32((OAMFEATURE_TC_SYNC_DETECT_MASK));
17395 + /* Set the flag to start retraining if the margin of the modem drops below
17396 + default margin during showtime */
17398 + OamWrNegoParaDef.marginMonitorShwtme = FALSE;
17399 + /* Set the flag to start retraining if the margin of the modem drops below default margin during training */
17401 + OamWrNegoParaDef.marginMonitorTrning = FALSE;
17402 + OamWrNegoParaDef.dsToneTurnoff_f = 0;
17403 + dslhal_support_blockWrite(&OamWrNegoParaDef,
17404 + (PVOID)dspOamSharedInterface.oamWriteNegoParams_p, sizeof(DEV_HOST_oamWrNegoParaDef_t));
17405 + rc=dslhal_support_setInterruptMask(ptidsl,0);
17406 + if(rc!=DSLHAL_ERROR_NO_ERRORS)
17408 + /* Co Profile Test */
17410 + dspOamSharedInterface.profileList_p = (DEV_HOST_profileBase_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.profileList_p);
17411 + /* Access the profileList Structure */
17412 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.profileList_p,&profileList, sizeof(DEV_HOST_profileBase_t));
17415 + dprintf(1,"dslhal_support_blockRead failed\n");
17416 + return DSLHAL_ERROR_BLOCK_READ;
17418 + profileList.hostProfileBase_p = (DEV_HOST_coData_t *)dslhal_support_byteSwap32((unsigned int)profileList.hostProfileBase_p);
17419 + rc = dslhal_support_blockRead((PVOID)profileList.hostProfileBase_p,&coData, sizeof(DEV_HOST_coData_t));
17422 + dprintf(1,"dslhal_support_blockRead failed\n");
17423 + return DSLHAL_ERROR_BLOCK_READ;
17425 + dprintf(2,"Current Profile Vendor Id: %x \n",coData.phyAgcPgaTarget);
17426 + coData.phyAgcPgaTarget = 0xcaba;
17427 + rc = dslhal_support_blockWrite(&coData,(PVOID)profileList.hostProfileBase_p,sizeof(DEV_HOST_coData_t));
17429 + return DSLHAL_ERROR_BLOCK_WRITE;
17431 + /* End of CO Profile Test */
17434 + /* Constellation Display Buffer Allocate */
17435 + ptidsl->constDisplay.PmemStartWtAddr = (unsigned int) shim_osAllocateDmaMemory(DSP_CONSTELLATION_BUFFER_SIZE);
17436 + if(ptidsl->constDisplay.PmemStartWtAddr == NULL)
17438 + dprintf(1, "memory allocate error\n");
17439 + return DSLHAL_ERROR_OVERLAY_MALLOC;
17441 + shim_osZeroMemory((void*)ptidsl->constDisplay.PmemStartWtAddr,DSP_CONSTELLATION_BUFFER_SIZE);
17442 + ptidsl->constDisplay.overlayHostAddr = virtual2Physical((unsigned int)ptidsl->constDisplay.PmemStartWtAddr);
17443 + dprintf(4,"Allocated Addr: 0x%x \t Xlated Addr: 0x%x \n",ptidsl->constDisplay.PmemStartWtAddr, ptidsl->constDisplay.overlayHostAddr);
17444 + ptidsl->constDisplay.OverlayXferCount = DSP_CONSTELLATION_BUFFER_SIZE;
17446 + /* Communicate the Allocated Buffer for DSP load Constellation Data */
17448 + /* Change the Endianness of the profileList pointer */
17449 + dspOamSharedInterface.consDispVar_p = (DEV_HOST_consBufDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.consDispVar_p);
17450 + /* Access the profileList Structure */
17451 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.consDispVar_p,&constDisp, sizeof(DEV_HOST_consBufDef_t));
17455 + dprintf(1,"dslhal_support_blockRead failed\n");
17456 + return DSLHAL_ERROR_BLOCK_READ;
17458 + dprintf(2,"Constellation Old Addr:%x New: %x \n",constDisp.consDispStartAddr,ptidsl->constDisplay.overlayHostAddr);
17459 + constDisp.consDispStartAddr = (unsigned int)dslhal_support_byteSwap32(ptidsl->constDisplay.overlayHostAddr);
17460 + constDisp.consDispCurrentAddr = constDisp.consDispStartAddr;
17461 + constDisp.consDispBufLen = (unsigned int)dslhal_support_byteSwap32(DSP_CONSTELLATION_BUFFER_SIZE);
17462 + rc = dslhal_support_blockWrite(&constDisp,(PVOID)dspOamSharedInterface.consDispVar_p,sizeof(DEV_HOST_consBufDef_t));
17464 + return DSLHAL_ERROR_BLOCK_WRITE;
17466 + dprintf(5,"dslhal_support_hostDspCodeDownload() completed.\n");
17467 + return DSLHAL_ERROR_NO_ERRORS;
17469 +} /* end of dslhal_support_hostDspCodeDownload() */
17471 +/********************************************************************************************
17472 +* FUNCTION NAME: dslhal_support_readDelineationState()
17474 +*********************************************************************************************
17476 +* download DSP image from host memory to dsp memory
17478 +* Return: 0 success
17482 +* DSP image is based on LITTLE endian
17484 +********************************************************************************************/
17486 +unsigned int dslhal_support_readDelineationState(tidsl_t * ptidsl)
17488 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
17489 + DEV_HOST_atmStats_t atmStats;
17490 + DEV_HOST_dsAtmStats_t dsAtmStats0;
17491 + unsigned int rc=0, delinState=0;
17492 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterface_t *) ptidsl->pmainAddr;
17493 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
17496 + dprintf(1,"dslhal_support_blockRead failed\n");
17497 + return DSLHAL_ERROR_BLOCK_READ;
17500 + dspOamSharedInterface.atmStats_p = (DEV_HOST_atmStats_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.atmStats_p);
17502 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.atmStats_p,&atmStats, sizeof(DEV_HOST_atmStats_t));
17506 + dprintf(1,"dslhal_support_blockRead failed\n");
17507 + return DSLHAL_ERROR_BLOCK_READ;
17510 + atmStats.ds0_p = (DEV_HOST_dsAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.ds0_p);
17512 + rc = dslhal_support_blockRead((PVOID)atmStats.ds0_p,&dsAtmStats0, (sizeof(DEV_HOST_dsAtmStats_t)));
17516 + delinState = dslhal_support_byteSwap32(dsAtmStats0.delineationState);
17517 + if(delinState == TC_SYNC)
17518 + ptidsl->lConnected = 1;
17520 + ptidsl->lConnected = 0;
17521 + return DSLHAL_ERROR_NO_ERRORS;
17524 +/********************************************************************************************
17525 +* FUNCTION NAME: dslhal_support_processModemStateBitField()
17527 +*********************************************************************************************
17529 +* download DSP image from host memory to dsp memory
17531 +* Return: 0 success
17535 +* DSP image is based on LITTLE endian
17537 +********************************************************************************************/
17539 +unsigned int dslhal_support_processModemStateBitField(tidsl_t * ptidsl)
17541 + int rc, offset[2]={2,0};
17542 + int modemStateBitFields[NUMBER_OF_BITFIELDS],changedField=0;
17543 + rc = dslhal_api_dspInterfaceRead(ptidsl,(unsigned int)ptidsl->pmainAddr,2,(unsigned int *)&offset,
17544 + (unsigned char *)&modemStateBitFields,NUMBER_OF_BITFIELDS*sizeof(int));
17546 + return DSLHAL_ERROR_BLOCK_READ;
17547 + for(rc=0;rc<NUMBER_OF_BITFIELDS;rc++)
17548 + dprintf(4,"Bit Field %d: 0x%x \n",rc+1,dslhal_support_byteSwap32((unsigned int)modemStateBitFields[rc]));
17550 + for(rc=NUMBER_OF_BITFIELDS;rc>0;rc--)
17552 + if(ptidsl->modemStateBitField[rc-1]!=modemStateBitFields[rc-1])
17554 + changedField = rc;
17560 + for(rc=0;rc<32;rc++)
17562 + if(modemStateBitFields[changedField-1] & dslhal_support_byteSwap32((BITFIELD_SCAN >> rc)))
17565 + dprintf(5,"Changed Field : %d Changed Bit : %d \n",changedField,(31-rc));
17566 + ptidsl->rState = ((changedField*100) + (31-rc));
17567 + dprintf(5,"Modem State : %d \n",ptidsl->rState);
17568 + shim_osMoveMemory((void *)ptidsl->modemStateBitField,(void *)modemStateBitFields, 4*NUMBER_OF_BITFIELDS);
17571 + switch(changedField)
17573 + case 1: if((ptidsl->rState >= ATU_RIDLE) && (ptidsl->AppData.bState < RSTATE_IDLE))
17574 + ptidsl->AppData.bState = RSTATE_IDLE;
17575 + if((ptidsl->rState >= GDMT_NSFLR) && (ptidsl->AppData.bState < RSTATE_INIT))
17576 + ptidsl->AppData.bState = RSTATE_INIT;
17577 + if((ptidsl->rState >= GDMT_ACKX) && (ptidsl->AppData.bState < RSTATE_HS))
17578 + ptidsl->AppData.bState = RSTATE_HS;
17581 + case 2: if((ptidsl->rState >= T1413_NSFLR) && (ptidsl->AppData.bState < RSTATE_INIT))
17582 + ptidsl->AppData.bState = RSTATE_INIT;
17583 + if((ptidsl->rState >= T1413_ACKX) && (ptidsl->AppData.bState < RSTATE_HS))
17584 + ptidsl->AppData.bState = RSTATE_HS;
17585 + if((ptidsl->rState == ATU_RSHOWTIME) && (ptidsl->AppData.bState < RSTATE_SHOWTIME))
17586 + ptidsl->AppData.bState = RSTATE_SHOWTIME;
17589 + case 3: if((ptidsl->rState >= ADSL2_COMB3) && (ptidsl->AppData.bState < RSTATE_INIT))
17590 + ptidsl->AppData.bState = RSTATE_INIT;
17591 + if((ptidsl->rState >= ADSL2_RPARAMS) && (ptidsl->AppData.bState < RSTATE_HS))
17592 + ptidsl->AppData.bState = RSTATE_HS;
17599 + ptidsl->stateTransition = modemStateBitFields[1];
17600 + switch(ptidsl->AppData.bState)
17602 + case RSTATE_IDLE: ptidsl->AppData.idleTick=shim_osClockTick();
17603 + ptidsl->AppData.initTick=0;
17604 + ptidsl->AppData.showtimeTick=0;
17606 + case RSTATE_HS: if(!ptidsl->AppData.initTick)
17608 + ptidsl->AppData.initTick=shim_osClockTick();
17610 + ptidsl->AppData.showtimeTick=0;
17612 + case RSTATE_SHOWTIME: if(!ptidsl->AppData.showtimeTick)
17613 + ptidsl->AppData.showtimeTick=shim_osClockTick();
17617 + return DSLHAL_ERROR_NO_ERRORS;
17620 +/********************************************************************************************
17621 +* FUNCTION NAME: dslhal_support_setInterruptMask()
17623 +*********************************************************************************************
17625 +* Sets the host interrupt bit masks
17627 +* Return: 0 success
17631 +* DSP image is based on LITTLE endian
17633 +********************************************************************************************/
17635 +unsigned int dslhal_support_setInterruptMask(tidsl_t * ptidsl,unsigned int inputMask)
17637 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
17638 + DEV_HOST_hostInterruptMask_t interruptMask;
17639 + unsigned int rc=0;
17640 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterface_t *) ptidsl->pmainAddr;
17641 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
17644 + dprintf(1,"dslhal_support_blockRead failed\n");
17645 + return DSLHAL_ERROR_BLOCK_READ;
17647 + dspOamSharedInterface.hostInterruptMask_p =(DEV_HOST_hostInterruptMask_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.hostInterruptMask_p);
17649 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.hostInterruptMask_p,
17650 + &interruptMask, sizeof(DEV_HOST_hostInterruptMask_t));
17653 + dprintf(1,"dslhal_support_blockRead failed\n");
17654 + return DSLHAL_ERROR_BLOCK_READ;
17656 + if(inputMask & MASK_MAILBOX_INTERRUPTS)
17658 + dprintf(7,"Mailbox Interrupts Masked \n");
17659 + dprintf(7,"interruptMask.maskBitField1 = %d \n",dslhal_support_byteSwap32(interruptMask.maskBitField1));
17660 + interruptMask.maskBitField1 |= dslhal_support_byteSwap32(MASK_MAILBOX_INTERRUPTS);
17661 + dprintf(7,"interruptMask.maskBitField1 = %d \n",dslhal_support_byteSwap32(interruptMask.maskBitField1));
17663 + if(inputMask & MASK_BITFIELD_INTERRUPTS)
17665 + dprintf(7,"Bit field Interrupts Masked \n");
17666 + dprintf(7,"interruptMask.maskBitField1 = %d \n",dslhal_support_byteSwap32(interruptMask.maskBitField1));
17667 + interruptMask.maskBitField1 |= dslhal_support_byteSwap32(MASK_BITFIELD_INTERRUPTS);
17668 + dprintf(7,"interruptMask.maskBitField1 = %d \n",dslhal_support_byteSwap32(interruptMask.maskBitField1));
17670 + if(inputMask & MASK_HEARTBEAT_INTERRUPTS)
17672 + dprintf(7,"Bit field Interrupts Masked \n");
17673 + dprintf(7,"interruptMask.maskBitField1 = %d \n",dslhal_support_byteSwap32(interruptMask.maskBitField1));
17674 + interruptMask.maskBitField1 |= dslhal_support_byteSwap32(MASK_HEARTBEAT_INTERRUPTS);
17675 + dprintf(7,"interruptMask.maskBitField1 = %d \n",dslhal_support_byteSwap32(interruptMask.maskBitField1));
17677 + dslhal_support_blockWrite(&interruptMask,
17678 + dspOamSharedInterface.hostInterruptMask_p, sizeof(DEV_HOST_hostInterruptMask_t));
17679 + dprintf(5,"dslhal_support_setInterruptMask() completed.\n");
17680 + return DSLHAL_ERROR_NO_ERRORS;
17683 +/********************************************************************************************
17684 +* FUNCTION NAME: dslhal_support_parseInterruptSource()
17686 +*********************************************************************************************
17688 +* Parses the Interrupt Source Bit Field
17690 +* Return: interrupt Code if successful
17691 +* negative error code if failed
17694 +* DSP image is based on LITTLE endian
17696 +********************************************************************************************/
17698 +unsigned int dslhal_support_parseInterruptSource(tidsl_t * ptidsl)
17700 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
17701 + DEV_HOST_hostInterruptSource_t interruptSource;
17702 + unsigned int rc=0,intrCode=0;
17703 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterface_t *) ptidsl->pmainAddr;
17704 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
17707 + dprintf(1,"dslhal_support_blockRead failed\n");
17708 + return (0-DSLHAL_ERROR_BLOCK_READ);
17710 + dspOamSharedInterface.hostInterruptSource_p =(DEV_HOST_hostInterruptSource_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.hostInterruptSource_p);
17712 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.hostInterruptSource_p,
17713 + &interruptSource, sizeof(DEV_HOST_hostInterruptSource_t));
17716 + dprintf(1,"dslhal_support_blockRead failed\n");
17717 + return (0-DSLHAL_ERROR_BLOCK_READ);
17719 + if(interruptSource.sourceBitField1 & dslhal_support_byteSwap32(MASK_MAILBOX_INTERRUPTS))
17721 + dprintf(7,"Mailbox Interrupts Acknowledge \n");
17722 + intrCode |= 0x00000011;
17724 + if(interruptSource.sourceBitField1 & dslhal_support_byteSwap32(MASK_BITFIELD_INTERRUPTS))
17726 + dprintf(7,"Bit field Interrupt Acknowledge \n");
17727 + intrCode |= 0x00001002;
17729 + if(interruptSource.sourceBitField1 & dslhal_support_byteSwap32(MASK_HEARTBEAT_INTERRUPTS))
17731 + dprintf(7,"HeartBeat Interrupt Acknowledge \n");
17732 + intrCode |= 0x00100004;
17735 + interruptSource.sourceBitField1 &=0x0;
17736 + rc=dslhal_support_blockWrite(&interruptSource,
17737 + dspOamSharedInterface.hostInterruptSource_p, sizeof(DEV_HOST_hostInterruptSource_t));
17739 + return (0-DSLHAL_ERROR_BLOCK_WRITE);
17740 + dprintf(5,"dslhal_support_parseInterruptSource() completed.\n");
17744 +/********************************************************************************************
17745 +* FUNCTION NAME: dslhal_support_byteSwap16()
17747 +*********************************************************************************************
17749 +* input 16 bit short, byte swap from little endian to big endian or vise versa
17751 +********************************************************************************************/
17753 +unsigned short dslhal_support_byteSwap16(unsigned short in16Bits)
17755 + unsigned short out16Bits;
17758 + unsigned char *pchar;
17759 + unsigned char tmp;
17762 + out16Bits = in16Bits;
17765 + pchar = (unsigned char *)(&out16Bits);
17768 + *pchar = *(pchar + 1);
17769 + *(pchar + 1) = tmp;
17772 + return out16Bits;
17774 +} /* end of dslhal_support_byteSwap16() */
17776 +/********************************************************************************************
17777 +* FUNCTION NAME: dslhal_support_byteSwap32()
17779 +*********************************************************************************************
17781 +* input 32 bit int, byte swap from little endian to big endian or vise versa
17783 +********************************************************************************************/
17785 +unsigned int dslhal_support_byteSwap32(unsigned int in32Bits)
17790 + unsigned char tmp;
17791 + unsigned char *pchar;
17794 + out32Bits = in32Bits;
17797 + pchar = (unsigned char *)(&out32Bits);
17800 + *pchar = *(pchar + 3);
17801 + *(pchar + 3) = tmp;
17803 + tmp = *(pchar + 1);
17804 + *(pchar + 1) = *(pchar + 2);
17805 + *(pchar + 2) = tmp;
17808 + return out32Bits;
17810 +} /* end of dslhal_support_byteSwap32() */
17813 +/********************************************************************************************
17814 +* FUNCTION NAME: dslhal_support_computeCrc32()
17816 +*********************************************************************************************
17818 +* Computes the CRC-32 for the input data
17820 +* Return: 32 bit CRC of the input data
17824 +* DSP image is based on LITTLE endian
17826 +********************************************************************************************/
17827 +unsigned int dslhal_support_computeCrc32(unsigned char *data, int len)
17829 + unsigned int result;
17831 + unsigned char octet;
17833 + if ((len < 4) || (data==NULL))
17834 + return(0xdeaddead);
17835 + result = *data++ << 24;
17836 + result |= *data++ << 16;
17837 + result |= *data++ << 8;
17838 + result |= *data++;
17839 + result = ~ result;
17843 + for (i=0; i<len; i++)
17845 + octet = *(data++);
17846 + for (j=0; j<8; j++)
17848 + if (result & 0x80000000)
17850 + result = (result << 1) ^ CRC32_QUOTIENT ^ (octet >> 7);
17854 + result = (result << 1) ^ (octet >> 7);
17859 + return ~result; /* The complement of the remainder */
17862 +/********************************************************************************************
17863 +* FUNCTION NAME: dslhal_support_checkOverlayPage()
17865 +*********************************************************************************************
17867 +* Computes the CRC-32 for the input data and compares it with reference
17869 +* Return: Error Condition (if any)
17873 +* DSP image is based on LITTLE endian
17875 +********************************************************************************************/
17876 +unsigned int dslhal_support_checkOverlayPage(tidsl_t *ptidsl, unsigned int tag)
17878 + unsigned int computedCrc;
17879 + if((unsigned char *)ptidsl->olayDpPage[tag].PmemStartWtAddr == NULL)
17881 + dprintf(5,"Null Address for Page: %d\n",tag);
17882 + return DSLHAL_ERROR_OVERLAY_MALLOC;
17884 + computedCrc = dslhal_support_computeCrc32((unsigned char *)ptidsl->olayDpPage[tag].PmemStartWtAddr, ptidsl->olayDpPage[tag].OverlayXferCount);
17885 + dprintf(6,"\n Pre-Computed CRC32 = 0x%x \t Current CRC32 = 0x%x \n",ptidsl->olayDpPage[tag].olayPageCrc32,computedCrc);
17886 + if(computedCrc != ptidsl->olayDpPage[tag].olayPageCrc32)
17887 + return DSLHAL_ERROR_OVERLAY_CORRUPTED;
17889 + return DSLHAL_ERROR_NO_ERRORS;
17892 +/********************************************************************************************
17893 +* FUNCTION NAME: dslhal_support_clearTrainingInfo()
17895 +*********************************************************************************************
17897 +* Computes the CRC-32 for the input data and compares it with reference
17899 +* Return: Error Condition (if any)
17903 +* DSP image is based on LITTLE endian
17905 +********************************************************************************************/
17907 +int dslhal_support_clearTrainingInfo(tidsl_t *ptidsl)
17911 + for(i=0; i<NUM_PAGES; i++)
17913 + if(ptidsl->olayDpPage[i].PmemStartWtAddr !=NULL)
17915 + shim_osFreeDmaMemory((void *) ptidsl->olayDpPage[i].PmemStartWtAddr,
17916 + ptidsl->olayDpPage[i].OverlayXferCount);
17917 + ptidsl->olayDpPage[i].PmemStartWtAddr =NULL;
17920 + if(ptidsl->coProfiles.PmemStartWtAddr != NULL)
17922 + shim_osFreeDmaMemory((void *)ptidsl->coProfiles.PmemStartWtAddr, ptidsl->coProfiles.OverlayXferCount);
17923 + ptidsl->coProfiles.PmemStartWtAddr = NULL;
17929 +/********************************************************************************************
17930 +* FUNCTION NAME: dslhal_support_reloadTrainingInfo()
17932 +*********************************************************************************************
17934 +* Reload overlay pages from flash or memory
17936 +* Return: 0 success
17940 +* DSP image is based on LITTLE endian
17942 +********************************************************************************************/
17944 +int dslhal_support_reloadTrainingInfo(tidsl_t * ptidsl)
17948 + unsigned int olayXfer,olayStore;
17949 + unsigned int *olayStart;
17951 + unsigned int crc32;
17952 + DEV_HOST_dspOamSharedInterface_t dspOamSharedInterface;
17953 + DEV_HOST_olayDpDef_t olayDpParms;
17954 + DEV_HOST_olayDpPageDef_t olayDpPageDef[NUM_PAGES];
17955 + DEV_HOST_profileBase_t profileList;
17957 + unsigned int secLength, secOffset, secPage;
17960 + secLength = ptidsl->coProfiles.OverlayXferCount;
17961 + secOffset = ptidsl->coProfiles.SecOffset;
17962 + ptidsl->coProfiles.PmemStartWtAddr = (unsigned int) shim_osAllocateDmaMemory(secLength);
17963 + if(ptidsl->coProfiles.PmemStartWtAddr == NULL)
17965 + dprintf(1, "memory allocate error\n");
17966 + return DSLHAL_ERROR_OVERLAY_MALLOC;
17968 + /* holdSecPhyAddr = virtual2Physical((unsigned int)holdSecVirtAddr); */
17969 + ptidsl->coProfiles.overlayHostAddr = virtual2Physical((unsigned int)ptidsl->coProfiles.PmemStartWtAddr);
17970 + dprintf(4,"Allocated Addr: 0x%x \t Xlated Addr: 0x%x \n",ptidsl->coProfiles.PmemStartWtAddr, ptidsl->coProfiles.overlayHostAddr);
17971 + ptidsl->coProfiles.overlayHostAddr = (unsigned int)dslhal_support_byteSwap32(ptidsl->coProfiles.overlayHostAddr);
17973 + rc = shim_read_overlay_page((void *)ptidsl->coProfiles.PmemStartWtAddr, secOffset, secLength);
17974 + if(rc != secLength)
17976 + dprintf(1, "shim_read_overlay_page failed\n");
17977 + return DSLHAL_ERROR_OVERLAY_MALLOC;
17980 + /*shim_osMoveMemory((char *)ptidsl->coProfiles.PmemStartWtAddr, (char *)iptr, secLength);*/
17981 + /* RamP Image ByteSwap test */
17982 + olayStart = (unsigned int *)ptidsl->coProfiles.PmemStartWtAddr;
17984 + for(olayXfer=0;olayXfer< secLength/4;olayXfer++)
17986 + olayStore = *(unsigned int *)olayStart;
17987 + olayStore = (unsigned int)dslhal_support_byteSwap32(olayStore);
17988 + *(unsigned int*)olayStart = olayStore;
17989 + dprintf(5, "Addr:0x%x \t Content: 0x%x \n",olayStart,olayStore);
17993 + shim_osWriteBackCache((void *)ptidsl->coProfiles.PmemStartWtAddr, secLength);
17996 + for (secPage=1;secPage<NUM_PAGES; secPage++)
17999 + dprintf(6,"OVERLAY PAGE #%d\n",secPage);
18001 + secLength = ptidsl->olayDpPage[secPage].OverlayXferCount;
18003 + dprintf(4,"Section[%d] Length: %d \n",secPage, secLength);
18005 + secOffset = ptidsl->olayDpPage[secPage].SecOffset;
18006 + ptidsl->olayDpPage[secPage].PmemStartWtAddr = (unsigned int) shim_osAllocateDmaMemory(secLength);
18007 + if(ptidsl->olayDpPage[secPage].PmemStartWtAddr == NULL)
18009 + dprintf(1, "overlay page allocate error\n");
18010 + return DSLHAL_ERROR_OVERLAY_MALLOC;
18013 + rc = shim_read_overlay_page((void *)ptidsl->olayDpPage[secPage].PmemStartWtAddr,secOffset, secLength);
18014 + if(rc != secLength)
18016 + dprintf(1, "overlay page read error\n");
18017 + return DSLHAL_ERROR_OVERLAY_MALLOC;
18020 + /* ptidsl->olayDpPage[secPage].overlayHostAddr = ((unsigned int)(ptidsl->olayDpPage[secPage].PmemStartWtAddr)&~0xe0000000); */
18021 + ptidsl->olayDpPage[secPage].overlayHostAddr = virtual2Physical((unsigned int)ptidsl->olayDpPage[secPage].PmemStartWtAddr);
18022 + dprintf(6,"Allocated Addr: 0x%x \t Xlated Addr: 0x%x \n",ptidsl->olayDpPage[secPage].PmemStartWtAddr,ptidsl->olayDpPage[secPage].overlayHostAddr);
18024 + ptidsl->olayDpPage[secPage].overlayHostAddr = (unsigned int)dslhal_support_byteSwap32(ptidsl->olayDpPage[secPage].overlayHostAddr);
18025 + /*ptidsl->olayDpPage[secPage].OverlayXferCount = secLength;
18026 + ptidsl->olayDpPage[secPage].BinAddr = secAddr;
18027 + shim_osMoveMemory((char *)ptidsl->olayDpPage[secPage].PmemStartWtAddr, (char *)iptr, secLength);
18029 + olayStart = (unsigned int *)ptidsl->olayDpPage[secPage].PmemStartWtAddr;
18031 + for(olayXfer=0;olayXfer< secLength/4;olayXfer++)
18033 + olayStore = *(unsigned int *)olayStart;
18034 + olayStore = (unsigned int)dslhal_support_byteSwap32(olayStore);
18035 + *(unsigned int*)olayStart = olayStore;
18036 + dprintf(5, "Addr:0x%x \t Content: 0x%x \n",olayStart,olayStore);
18040 + /* RamP Image ByteSwap test */
18041 + /* compute the CRC of each overlay page and Store the Checksum in a local global variable */
18042 + /* This Value of CRC is to be compared with the header where all the CRC bytes are lumped together */
18043 + crc32 = dslhal_support_computeCrc32((char *)ptidsl->olayDpPage[secPage].PmemStartWtAddr, ptidsl->olayDpPage[secPage].OverlayXferCount);
18044 + if(crc32 != ptidsl->olayDpPage[secPage].olayPageCrc32)
18045 + return DSLHAL_ERROR_OVERLAY_MALLOC;
18047 + shim_osWriteBackCache((void *)ptidsl->olayDpPage[secPage].PmemStartWtAddr, secLength);
18051 + dprintf(5,"ptidsl->hostIf.mainAddr=0x%X\n", (unsigned int)ptidsl->pmainAddr);
18053 + /* get the pointer to DSP-OAM Shared Interface */
18054 + rc = dslhal_support_blockRead(ptidsl->pmainAddr, &dspOamSharedInterface,
18055 + sizeof(DEV_HOST_dspOamSharedInterface_t));
18058 + dprintf(1,"dslhal_support_blockRead failed\n");
18059 + return DSLHAL_ERROR_BLOCK_READ;
18062 + /* Communicate the Allocated Memory Address to DSP to choose CO Profiles */
18064 + /* Change the Endianness of the profileList pointer */
18065 + dspOamSharedInterface.profileList_p = (DEV_HOST_profileBase_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.profileList_p);
18066 + /* Access the profileList Structure */
18067 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.profileList_p,&profileList, sizeof(DEV_HOST_profileBase_t));
18071 + dprintf(1,"dslhal_support_blockRead failed\n");
18072 + return DSLHAL_ERROR_BLOCK_READ;
18074 + dprintf(2,"Old Addr:%x New: %x \n",profileList.hostProfileBase_p,ptidsl->coProfiles.overlayHostAddr);
18075 + profileList.hostProfileBase_p = (DEV_HOST_coData_t *)ptidsl->coProfiles.overlayHostAddr;
18076 + rc = dslhal_support_blockWrite(&profileList,(PVOID)dspOamSharedInterface.profileList_p,sizeof(DEV_HOST_profileBase_t));
18078 + return DSLHAL_ERROR_BLOCK_WRITE;
18080 + /* Communicate the Allocated Memory Address to DSP to do overlays */
18082 + /* Change the Endianness of the olayDpDef pointer */
18083 + dspOamSharedInterface.olayDpParms_p = (DEV_HOST_olayDpDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.olayDpParms_p);
18084 + /* Access the olayDpDef Structure */
18085 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.olayDpParms_p,&olayDpParms, sizeof(DEV_HOST_olayDpDef_t));
18089 + dprintf(1,"dslhal_support_blockRead failed\n");
18090 + return DSLHAL_ERROR_BLOCK_READ;
18094 + for(i=1;i<NUM_PAGES;i++)
18096 + /* Change the endianness of the olayDpPageDef Pointer */
18097 + olayDpParms.olayDpPage_p[i] = (DEV_HOST_olayDpPageDef_t *) dslhal_support_byteSwap32((unsigned int)olayDpParms.olayDpPage_p[i]);
18098 + /* Access the olayDpPageDef Structure */
18099 + rc = dslhal_support_blockRead((PVOID)olayDpParms.olayDpPage_p[i],&olayDpPageDef[i],sizeof(DEV_HOST_olayDpPageDef_t));
18101 + return DSLHAL_ERROR_BLOCK_READ;
18102 + olayDpPageDef[i].overlayHostAddr = ptidsl->olayDpPage[i].overlayHostAddr;
18103 + rc = dslhal_support_blockWrite(&olayDpPageDef[i],(PVOID)olayDpParms.olayDpPage_p[i],sizeof(DEV_HOST_olayDpPageDef_t));
18105 + return DSLHAL_ERROR_BLOCK_WRITE;
18108 + ptidsl->bOverlayPageLoaded = 1;
18109 + return DSLHAL_ERROR_NO_ERRORS;
18111 + /* end of dslhal_support_reloadTrainingInfo() */
18114 +/********************************************************************************************
18115 +* FUNCTION NAME: dslhal_support_restoreTrainingInfo()
18117 +*********************************************************************************************
18119 +* Computes the CRC-32 for the input data and compares it with reference
18121 +* Return: Error Condition (if any)
18125 +* DSP image is based on LITTLE endian
18127 +********************************************************************************************/
18130 +int dslhal_support_restoreTrainingInfo(tidsl_t *ptidsl)
18137 + dslhal_support_clearTrainingInfo(ptidsl);
18138 + //shim_osCriticalEnter();
18139 + rc = dslhal_support_reloadTrainingInfo(ptidsl);
18140 + //shim_osCriticalExit();
18141 + shim_osClockWait(6400);
18146 +/********************************************************************************************
18147 +* FUNCTION NAME: dslhal_support_advancedIdleProcessing()
18149 +*********************************************************************************************
18151 +* Calls Advanced Idle State Processing Functions
18153 +* Return: Error Condition (if any)
18157 +* DSP image is based on LITTLE endian
18159 +********************************************************************************************/
18160 +unsigned int dslhal_support_advancedIdleProcessing(tidsl_t *ptidsl)
18163 + ptidsl->AppData.bState = RSTATE_IDLE;
18165 + rc += dslhal_advcfg_resetBitSwapMessageLog(ptidsl,0);
18166 + rc += dslhal_advcfg_resetBitSwapMessageLog(ptidsl,1);
18167 + rc += dslhal_advcfg_resetTrainStateHistory(ptidsl);
18168 + rc += dslhal_advcfg_getReasonForDrop(ptidsl);
18171 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
18173 + return DSLHAL_ERROR_NO_ERRORS;
18176 +/********************************************************************************************
18177 +* FUNCTION NAME: dslhal_support_aocBitSwapProcessing()
18179 +*********************************************************************************************
18181 +* Calls Advanced Idle State Processing Functions
18183 +* Return: Error Condition (if any)
18187 +* DSP image is based on LITTLE endian
18189 +********************************************************************************************/
18190 +unsigned int dslhal_support_aocBitSwapProcessing(tidsl_t *ptidsl,unsigned int usDs)
18195 + int differentCmd_f;
18196 + unsigned int dsSwapInx;
18198 + static UINT8 lastAturBitSwapCommands[6] = {0, 0, 0, 0, 0, 0};
18199 + static UINT8 lastAturBitSwapBinNum[6] = {0, 0, 0, 0, 0, 0};
18203 + dprintf(4," DSP_XMITBITSWAP\n");
18204 + rc += dslhal_advcfg_getAocBitswapBuffer(ptidsl,0);
18205 + ptidsl->usBitSwapInx++;
18206 + if (ptidsl->usBitSwapInx > 29)
18207 + ptidsl->usBitSwapInx=0;
18212 + dprintf(4," DSP_RCVBITSWAP\n");
18213 + rc += dslhal_advcfg_getAocBitswapBuffer(ptidsl,1);
18214 + differentCmd_f = FALSE;
18215 + dsSwapInx = ptidsl->dsBitSwapInx;
18218 + for (i = 0; i < 6; i++)
18220 + if (lastAturBitSwapCommands[i] != ptidsl->dsBitSwap[dsSwapInx].bitSwapCommand[i])
18222 + differentCmd_f = TRUE;
18226 + if (! differentCmd_f)
18228 + for (i = 0; i < 6; i++)
18230 + if (lastAturBitSwapBinNum[i] != ptidsl->dsBitSwap[dsSwapInx].bitSwapBinNum[i])
18232 + differentCmd_f = TRUE;
18237 + //CPE data pump seems to occasionally send us the same bit swap twice in a row with different sframe counter.
18238 + //Since these are never counted twice by the debug output of AC5, we should not count them twice either.
18239 + //So, we ignore the sframe_counter in determining whether the most recent bitswap is a duplicate.
18240 + if (differentCmd_f)
18242 + shim_osMoveMemory((void *)lastAturBitSwapCommands, (void *)ptidsl->dsBitSwap[dsSwapInx].bitSwapCommand, 6);
18243 + shim_osMoveMemory((void *)lastAturBitSwapBinNum, (void *)ptidsl->dsBitSwap[dsSwapInx].bitSwapBinNum, 6);
18244 + ptidsl->dsBitSwapInx++;
18245 + if (ptidsl->dsBitSwapInx > 29)
18246 + ptidsl->dsBitSwapInx = 0;
18252 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
18254 + return DSLHAL_ERROR_NO_ERRORS;
18257 +/********************************************************************************************
18258 +* FUNCTION NAME: dslhal_support_gatherEocMessages()
18260 +*********************************************************************************************
18262 +* Calls Advanced EOC Buffering functions
18264 +* Return: Error Condition (if any)
18268 +* DSP image is based on LITTLE endian
18270 +********************************************************************************************/
18271 +unsigned int dslhal_support_gatherEocMessages(tidsl_t *ptidsl,int usDs, int msgPart1, int msgPart2)
18275 + rc = dslhal_advcfg_logEocMessages(ptidsl,usDs, msgPart1, msgPart2);
18278 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
18280 + return DSLHAL_ERROR_NO_ERRORS;
18282 +/********************************************************************************************
18283 +* FUNCTION NAME: dslhal_support_gatherSnrPerBin()
18285 +*********************************************************************************************
18287 +* Calls Advanced Snr per bin buffering Functions
18289 +* Return: Error Condition (if any)
18293 +* DSP image is based on LITTLE endian
18295 +********************************************************************************************/
18296 +unsigned int dslhal_support_gatherSnrPerBin(tidsl_t *ptidsl,unsigned int snrParam)
18300 + rc = dslhal_advcfg_getSnrPerBin(ptidsl,snrParam);
18303 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
18305 + return DSLHAL_ERROR_NO_ERRORS;
18308 +/********************************************************************************************
18309 +* FUNCTION NAME: dslhal_support_processTrainingState()
18311 +*********************************************************************************************
18313 +* Calls Advanced Training State Processing Functions
18315 +* Return: Error Condition (if any)
18319 +* DSP image is based on LITTLE endian
18321 +********************************************************************************************/
18322 +unsigned int dslhal_support_processTrainingState(tidsl_t *ptidsl)
18327 + if(ptidsl->trainStateInx<120)
18329 + rc = dslhal_advcfg_getTrainingState(ptidsl,(void *)&ptidsl->trainHistory[ptidsl->trainStateInx++]);
18330 + if(ptidsl->trainHistory[(ptidsl->trainStateInx-1)].subStateIndex ==
18331 + ptidsl->trainHistory[(ptidsl->trainStateInx-2)].subStateIndex)
18332 + ptidsl->trainStateInx--;
18335 + ptidsl->trainStateInx = 0;
18338 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
18340 + return DSLHAL_ERROR_NO_ERRORS;
18343 +/********************************************************************************************
18344 +* FUNCTION NAME: dslhal_support_gatherAdsl2Messages()
18346 +*********************************************************************************************
18348 +* Gathers ADSL2 Training Messages
18350 +* Return: Error Condition (if any)
18354 +* DSP image is based on LITTLE endian
18356 +********************************************************************************************/
18357 +unsigned int dslhal_support_gatherAdsl2Messages(tidsl_t *ptidsl,int tag, int param1, int param2)
18360 + unsigned int adsl2MsgLoc;
18363 + case CMSGFMT_INDEX:
18364 + dprintf(5,"C-Msg-FMT rec'd\n");
18365 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18366 + (ptidsl, CMSGFMT_INDEX);
18367 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18368 + ptidsl->adsl2TrainingMessages.cMsgFmt,CMSGFMT_SIZE);
18370 + case RMSGFMT_INDEX:
18371 + case RMSGFMT2_INDEX:
18372 + dprintf(5,"R-Msg-FMT rec'd\n");
18373 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18374 + (ptidsl, RMSGFMT_INDEX);
18375 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18376 + ptidsl->adsl2TrainingMessages.rMsgFmt,RMSGFMT_SIZE);
18378 + case CMSGPCB_INDEX:
18379 + dprintf(5,"C-Msg-PCB rec'd\n");
18380 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18381 + (ptidsl, CMSGPCB_INDEX);
18382 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18383 + ptidsl->adsl2TrainingMessages.cMsgPcb,CMSGPCB_SIZE);
18384 + ptidsl->adsl2TrainingMessages.cMsgPcbLen = CMSGPCB_SIZE;
18386 + case CMSGPCB2_INDEX:
18387 + dprintf(5,"C-Msg-PCB2 rec'd\n");
18388 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18389 + (ptidsl, CMSGPCB2_INDEX);
18390 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18391 + ptidsl->adsl2TrainingMessages.cMsgPcb,CMSGPCB2_SIZE);
18392 + ptidsl->adsl2TrainingMessages.cMsgPcbLen = CMSGPCB2_SIZE;
18394 + rc += dslhal_advcfg_setBlackOutBits(ptidsl);
18397 + case CMSGPCB2L_INDEX:
18398 + dprintf(5,"C-Msg-PCB2L rec'd\n");
18399 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18400 + (ptidsl, CMSGPCB2L_INDEX);
18401 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18402 + ptidsl->adsl2TrainingMessages.cMsgPcb,CMSGPCB2L_SIZE);
18403 + ptidsl->adsl2TrainingMessages.cMsgPcbLen = CMSGPCB2L_SIZE;
18405 + case RMSGPCB_INDEX:
18406 + case RMSGPCB2L_INDEX:
18407 + dprintf(5,"R-Msg-PCB rec'd\n");
18408 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18409 + (ptidsl, RMSGPCB_INDEX);
18410 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18411 + ptidsl->adsl2TrainingMessages.rMsgPcb,RMSGPCB_SIZE);
18412 + ptidsl->adsl2TrainingMessages.rMsgPcbLen = RMSGPCB_SIZE;
18415 + case CMSG1ADSL2_INDEX:
18416 + dprintf(5,"C-Msg1 rec'd\n");
18417 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18418 + (ptidsl, CMSG1ADSL2_INDEX);
18419 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18420 + ptidsl->adsl2TrainingMessages.cMsg1,CMSG1ADSL2_SIZE);
18421 + ptidsl->adsl2TrainingMessages.cMsg1Len = CMSG1ADSL2_SIZE;
18423 + case CMSG2ADSL2_INDEX:
18424 + dprintf(5,"C-Msg2 rec'd\n");
18425 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18426 + (ptidsl, CMSG2ADSL2_INDEX);
18427 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18428 + ptidsl->adsl2TrainingMessages.cMsg2,CMSG2ADSL2_SIZE);
18429 + ptidsl->adsl2TrainingMessages.cMsg2Len = CMSG2ADSL2_SIZE;
18431 + case RMSG1ADSL2_INDEX:
18432 + dprintf(5,"R-Msg1 rec'd\n");
18433 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18434 + (ptidsl, RMSG1ADSL2_INDEX);
18435 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18436 + ptidsl->adsl2TrainingMessages.rMsg1,RMSG1ADSL2_SIZE);
18437 + ptidsl->adsl2TrainingMessages.rMsg1Len = RMSG1ADSL2_SIZE;
18439 + case RMSG2ADSL2_INDEX:
18440 + dprintf(5,"R-Msg2 rec'd\n");
18441 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18442 + (ptidsl, RMSG2ADSL2_INDEX);
18443 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18444 + ptidsl->adsl2TrainingMessages.rMsg2,RMSG2ADSL2_SIZE);
18445 + ptidsl->adsl2TrainingMessages.rMsg2Len = RMSG2ADSL2_SIZE;
18447 + case CPARAMS_INDEX:
18448 + dprintf(5,"C-Params rec'd\n");
18449 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18450 + (ptidsl, CPARAMS_INDEX);
18451 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18452 + ptidsl->adsl2TrainingMessages.cParams,CPARAMS_SIZE);
18453 + ptidsl->adsl2TrainingMessages.cParamsLen = CPARAMS_SIZE;
18455 + case RPARAMS_INDEX:
18456 + dprintf(5,"R-Params rec'd\n");
18457 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18458 + (ptidsl, RPARAMS_INDEX);
18459 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18460 + ptidsl->adsl2TrainingMessages.rParams,RPARAMS_SIZE);
18461 + ptidsl->adsl2TrainingMessages.rParamsLen = RPARAMS_SIZE;
18463 + case RMSG1LD_INDEX:
18464 + dprintf(5,"R-Msg1 LD rec'd\n");
18465 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18466 + (ptidsl, RMSG1LD_INDEX);
18467 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18468 + ptidsl->adsl2DiagnosticMessages.rMsg1Ld,RMSG1LD_SIZE);
18469 + ptidsl->adsl2DiagnosticMessages.rMsg1LdLen = RMSG1LD_SIZE;
18471 + case RMSG2LD_INDEX:
18472 + dprintf(5,"R-Msg2 LD rec'd\n");
18473 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18474 + (ptidsl, RMSG2LD_INDEX);
18475 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18476 + ptidsl->adsl2DiagnosticMessages.rMsg2Ld,RMSGxLD_SIZE);
18477 + ptidsl->adsl2DiagnosticMessages.rMsgxLdLen = RMSGxLD_SIZE;
18479 + case RMSG3LD_INDEX:
18480 + dprintf(5,"R-Msg3 LD rec'd\n");
18481 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18482 + (ptidsl, RMSG3LD_INDEX);
18483 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18484 + ptidsl->adsl2DiagnosticMessages.rMsg3Ld,RMSGxLD_SIZE);
18485 + ptidsl->adsl2DiagnosticMessages.rMsgxLdLen = RMSGxLD_SIZE;
18487 + case RMSG4LD_INDEX:
18488 + dprintf(5,"R-Msg4 LD rec'd\n");
18489 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18490 + (ptidsl, RMSG4LD_INDEX);
18491 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18492 + ptidsl->adsl2DiagnosticMessages.rMsg4Ld,RMSGxLD_SIZE);
18493 + ptidsl->adsl2DiagnosticMessages.rMsgxLdLen = RMSGxLD_SIZE;
18495 + case RMSG5LD_INDEX:
18496 + dprintf(5,"R-Msg5 LD rec'd\n");
18497 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18498 + (ptidsl, RMSG5LD_INDEX);
18499 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18500 + ptidsl->adsl2DiagnosticMessages.rMsg5Ld,RMSGxLD_SIZE);
18501 + ptidsl->adsl2DiagnosticMessages.rMsgxLdLen = RMSGxLD_SIZE;
18503 + case RMSG6LD_INDEX:
18504 + dprintf(5,"R-Msg6 LD rec'd\n");
18505 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18506 + (ptidsl, RMSG6LD_INDEX);
18507 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18508 + ptidsl->adsl2DiagnosticMessages.rMsg6Ld,RMSGxLD_SIZE);
18509 + ptidsl->adsl2DiagnosticMessages.rMsgxLdLen = RMSGxLD_SIZE;
18511 + case RMSG7LD_INDEX:
18512 + dprintf(5,"R-Msg7 LD rec'd\n");
18513 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18514 + (ptidsl, RMSG7LD_INDEX);
18515 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18516 + ptidsl->adsl2DiagnosticMessages.rMsg7Ld,RMSGxLD_SIZE);
18517 + ptidsl->adsl2DiagnosticMessages.rMsgxLdLen = RMSGxLD_SIZE;
18519 + case RMSG8LD_INDEX:
18520 + dprintf(5,"R-Msg8 LD rec'd\n");
18521 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18522 + (ptidsl, RMSG8LD_INDEX);
18523 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18524 + ptidsl->adsl2DiagnosticMessages.rMsg8Ld,RMSGxLD_SIZE);
18525 + ptidsl->adsl2DiagnosticMessages.rMsgxLdLen = RMSGxLD_SIZE;
18527 + case RMSG9LD_INDEX:
18528 + dprintf(5,"R-Msg9 LD rec'd\n");
18529 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18530 + (ptidsl, RMSG9LD_INDEX);
18531 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18532 + ptidsl->adsl2DiagnosticMessages.rMsg9Ld,RMSGxLD_SIZE);
18533 + ptidsl->adsl2DiagnosticMessages.rMsgxLdLen = RMSGxLD_SIZE;
18535 + case CMSG1LD_INDEX:
18536 + dprintf(5,"C-Msg1 LD rec'd\n");
18537 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18538 + (ptidsl, CMSG1LD_INDEX);
18539 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18540 + ptidsl->adsl2DiagnosticMessages.cMsg1Ld,CMSG1LD_SIZE);
18541 + ptidsl->adsl2DiagnosticMessages.cMsg1LdLen = CMSG1LD_SIZE;
18543 + case CMSG2LD_INDEX:
18544 + dprintf(5,"C-Msg2 LD rec'd\n");
18545 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18546 + (ptidsl, CMSG2LD_INDEX);
18547 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18548 + ptidsl->adsl2DiagnosticMessages.cMsg2Ld,CMSG2LD_SIZE);
18549 + ptidsl->adsl2DiagnosticMessages.cMsg2LdLen = CMSG2LD_SIZE;
18551 + case CMSG3LD_INDEX:
18552 + dprintf(5,"C-Msg3 LD rec'd\n");
18553 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18554 + (ptidsl, CMSG3LD_INDEX);
18555 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18556 + ptidsl->adsl2DiagnosticMessages.cMsg3Ld,CMSG3LD_SIZE);
18557 + ptidsl->adsl2DiagnosticMessages.cMsg3LdLen = CMSG3LD_SIZE;
18559 + case CMSG4LD_INDEX:
18560 + dprintf(5,"C-Msg4 LD rec'd\n");
18561 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18562 + (ptidsl, CMSG4LD_INDEX);
18563 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18564 + ptidsl->adsl2DiagnosticMessages.cMsg4Ld,CMSG4LD_SIZE);
18565 + ptidsl->adsl2DiagnosticMessages.cMsg4LdLen = CMSG4LD_SIZE;
18567 + case CMSG5LD_INDEX:
18568 + dprintf(5,"C-Msg5 LD rec'd\n");
18569 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18570 + (ptidsl, CMSG5LD_INDEX);
18571 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18572 + ptidsl->adsl2DiagnosticMessages.cMsg5Ld,CMSG5LD_SIZE);
18573 + ptidsl->adsl2DiagnosticMessages.cMsg5LdLen = CMSG5LD_SIZE;
18576 + dprintf(5,"Unknown ADSL2 Message rec'd\n");
18580 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
18582 + return DSLHAL_ERROR_NO_ERRORS;
18585 +/********************************************************************************************
18586 +* FUNCTION NAME: dslhal_support_getAdsl2MessageLocation()
18588 +*********************************************************************************************
18590 +* Gets the address to the ADSL2 Message being looked up
18592 +* Return: Error Condition (if any)
18596 +* DSP image is based on LITTLE endian
18598 +********************************************************************************************/
18599 +unsigned int dslhal_support_getAdsl2MessageLocation(tidsl_t *ptidsl,int msgOffset)
18603 + DEV_HOST_dspOamSharedInterface_t *pSharedInterface, sharedInterface;
18604 + DEV_HOST_dspWrNegoParaDef_t dspNegoPara;
18605 + int adsl2MsgString, adsl2MsgAddr;
18607 + pSharedInterface = (DEV_HOST_dspOamSharedInterface_t *) ptidsl->pmainAddr;
18608 + rc += dslhal_support_blockRead(pSharedInterface, &sharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
18609 + sharedInterface.dspWriteNegoParams_p = (DEV_HOST_dspWrNegoParaDef_t *) dslhal_support_adsl2ByteSwap32((unsigned int)sharedInterface.dspWriteNegoParams_p);
18610 + rc += dslhal_support_blockRead((PVOID)sharedInterface.dspWriteNegoParams_p,&dspNegoPara, sizeof(DEV_HOST_dspWrNegoParaDef_t));
18614 + dprintf(1,"dslhal_support_blockRead failed\n");
18615 + return DSLHAL_ERROR_BLOCK_READ;
18618 + adsl2MsgString = dslhal_support_adsl2ByteSwap32((unsigned int)dspNegoPara.adsl2DeltMsgs_p);
18619 + dprintf(5,"ADSL2 Message String Address: 0x%x\n",adsl2MsgString);
18620 + rc += dslhal_support_blockRead((PVOID)(adsl2MsgString +
18621 + ((sizeof(unsigned char *)*msgOffset))),
18622 + &adsl2MsgAddr, sizeof(int));
18623 + adsl2MsgAddr = dslhal_support_adsl2ByteSwap32((unsigned int)adsl2MsgAddr);
18624 + dprintf(5," Message Address: 0x%x\n",adsl2MsgAddr);
18627 + return DSLHAL_ERROR_BLOCK_READ;
18629 + return adsl2MsgAddr;
18632 +/********************************************************************************************
18633 +* FUNCTION NAME: dslhal_support_getCMsgsRa()
18635 +*********************************************************************************************
18637 +* Calls Advanced Training Message functions
18639 +* Return: Error Condition (if any)
18643 +* DSP image is based on LITTLE endian
18645 +********************************************************************************************/
18646 +unsigned int dslhal_support_getCMsgsRa(tidsl_t *ptidsl,void *cMsg)
18649 + DEV_HOST_raMsgsDef_t raMsgParms;
18650 + DEV_HOST_dspOamSharedInterface_t dspOamSharedInterface;
18651 + rc += dslhal_support_blockRead(ptidsl->pmainAddr, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
18653 + dspOamSharedInterface.raMsgs_p = (DEV_HOST_raMsgsDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.raMsgs_p);
18655 + rc += dslhal_support_blockRead((PVOID)dspOamSharedInterface.raMsgs_p,
18656 + &raMsgParms, sizeof(DEV_HOST_raMsgsDef_t));
18657 + shim_osMoveMemory((void *)cMsg,(void *)raMsgParms.cMsgsRaString,6);
18660 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
18662 + return DSLHAL_ERROR_NO_ERRORS;
18665 +/********************************************************************************************
18666 +* FUNCTION NAME: dslhal_support_gatherRateMessages()
18668 +*********************************************************************************************
18670 +* Gathers Rate Training Messages
18672 +* tidsl_t *ptidsl : Pointer to application structure
18675 +* Return: 0 success
18679 +* DSP image is based on LITTLE endian
18681 +********************************************************************************************/
18682 +unsigned int dslhal_support_gatherRateMessages(tidsl_t * ptidsl)
18685 + DEV_HOST_dspWrNegoParaDef_t negoParms;
18686 + DEV_HOST_dspOamSharedInterface_t dspOamSharedInterface;
18688 + dprintf(1, "dslhal_support_gatherRateMessages\n");
18690 + rc += dslhal_support_blockRead(ptidsl->pmainAddr, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
18691 + dspOamSharedInterface.dspWriteNegoParams_p = (DEV_HOST_dspWrNegoParaDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspWriteNegoParams_p);
18693 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspWriteNegoParams_p, &negoParms, sizeof(DEV_HOST_dspWrNegoParaDef_t));
18695 + return DSLHAL_ERROR_BLOCK_READ;
18698 + shim_osMoveMemory((void *)ptidsl->AppData.bCRates1, (void *)negoParms.cRates1, 120);
18699 + shim_osMoveMemory((void *)ptidsl->AppData.bRRates1, (void *)negoParms.rRates1, 44);
18701 +return DSLHAL_ERROR_NO_ERRORS;
18704 +static unsigned int dslhal_support_adsl2ByteSwap32(unsigned int in32Bits)
18709 + out32Bits = (in32Bits << 24);
18710 + out32Bits |=((in32Bits & 0x0000ff00) << 8);
18711 + out32Bits |=((in32Bits & 0xff000000) >> 24);
18712 + out32Bits |=((in32Bits & 0x00ff0000) >> 8);
18714 + out32Bits = in32Bits;
18717 + return out32Bits;
18719 +} /* end of dslhal_support_byteSwap32() */
18720 diff -urN linux.old/drivers/atm/sangam_atm/dsl_hal_support.h linux.dev/drivers/atm/sangam_atm/dsl_hal_support.h
18721 --- linux.old/drivers/atm/sangam_atm/dsl_hal_support.h 1970-01-01 01:00:00.000000000 +0100
18722 +++ linux.dev/drivers/atm/sangam_atm/dsl_hal_support.h 2005-07-10 08:02:01.444111360 +0200
18724 +#ifndef DSL_HAL_SUPPORT_H__
18725 +#define DSL_HAL_SUPPORT_H__ 1
18727 +/*******************************************************************************
18728 +* FILE PURPOSE: DSL Driver API functions for Sangam
18730 +********************************************************************************
18731 +* FILE NAME: dsl_hal_functiondefines.c
18734 +* Contains basic DSL HAL API declarations for Sangam
18737 +* (C) Copyright 2001-02, Texas Instruments, Inc.
18739 +* Date Version Notes
18740 +* 06Feb03 0.00.00 RamP Created
18741 +* 21Mar03 0.00.01 RamP Removed byteswap functions
18742 +* 21Mar03 0.00.02 RamP Added extern osFreeVMemory declaration
18743 +* 10Apr03 0.00.03 RamP Changed declaration for loadFWImage &
18744 +* loadDebugFWImage to remove ptidsl param
18745 +* 12Apr03 0.00.04 RamP Added function to set Interrupt Bit
18746 +* Masks for bitfield & Mailboxes
18747 +* 14Apr03 0.00.05 RamP Added modem state bit field processing
18748 +* 15Apr03 0.00.06 RamP Added function osAllocateVMemory
18749 +* 21Apr03 0.01.00 RamP Added function osAllocateDmaMemory
18750 +* Added function osFreeDmaMemory
18751 +* (Alpha) Added macro virtual2Physical,
18752 +* 22Apr03 0.01.01 RamP Moved acknowledgeInterrupt to api.h
18753 +* 24Apr03 0.01.02 RamP Added checkOvelayPage function
18754 +* 29May03 0.01.03 RamP Added critical enter/exit function decl
18755 +* 06Jun03 0.01.04 RamP Added Interrupt source parsing function
18756 +* 06Oct03 0.01.05 RamP Added function abstraction switches
18757 +* 12Oct03 0.01.06 RamP Added ADSL2 Message function prototypes
18758 +* 14Nov03 0.03.07 RamP Added function to gather Rate Messages
18759 +*******************************************************************************/
18761 +#include "dsl_hal_api.h"
18763 +#define virtual2Physical(a) (((int)a)&~0xe0000000)
18764 +/* External Function Prototype Declarations */
18766 +extern unsigned int shim_osGetCpuFrequency(void);
18767 +extern void shim_osClockWait(int val);
18768 +extern unsigned int shim_osClockTick(void);
18770 +extern int shim_osStringCmp(const char *s1, const char *s2);
18772 +extern void dprintf( int uDbgLevel, char * szFmt, ...);
18774 +extern int shim_osLoadFWImage(unsigned char *firmwareImage);
18775 +extern int shim_osLoadDebugFWImage(unsigned char *debugFirmwareImage);
18776 +extern unsigned int shim_read_overlay_page(void *ptr, unsigned int secOffset, unsigned int secLength);
18777 +extern void shim_osMoveMemory(char *dst, char *src, unsigned int numBytes);
18778 +extern void shim_osZeroMemory(char *dst, unsigned int numBytes);
18780 +extern void *shim_osAllocateMemory(unsigned int size);
18781 +extern void *shim_osAllocateVMemory(unsigned int size);
18782 +extern void *shim_osAllocateDmaMemory(unsigned int size);
18784 +extern void shim_osFreeMemory(void *ptr, unsigned int size);
18785 +extern void shim_osFreeVMemory(void *ptr, unsigned int size);
18786 +extern void shim_osFreeDmaMemory(void *ptr, unsigned int size);
18788 +extern void shim_osWriteBackCache(void *pMem, unsigned int size);
18789 +extern void shim_osCriticalEnter(void);
18790 +extern void shim_osCriticalExit(void);
18793 +/*******************************************************************************************
18794 +* FUNCTION NAME: dslhal_support_writeHostMailbox
18796 +********************************************************************************************
18797 +* DESCRIPTION: Send a message to a mailbox
18799 +* ARGUMENTS: int cmd command to write
18800 +* int tag tag (currently unused)
18801 +* int p1 parameter 1 (currently unused)
18802 +* int p2 parameter 2 (currently unused)
18804 +* RETURNS: 0 if successful
18807 +*******************************************************************************************/
18809 +int dslhal_support_writeHostMailbox
18816 +/********************************************************************************************
18817 +* FUNCTION NAME: dslhal_support_readDspMailbox
18819 +*********************************************************************************************
18820 +* DESCRIPTION: Reads a message from the mailbox
18822 +* ARGUMENTS: int *pcmd Pointer to command read
18824 +* RETURNS: 0 if successful
18828 +*****************************************************************************************/
18830 +int dslhal_support_readDspMailbox
18837 +/********************************************************************************************
18838 +* FUNCTION NAME: dslhal_support_readTextMailbox
18840 +*********************************************************************************************
18841 +* DESCRIPTION: Reads a message from the mailbox
18843 +* ARGUMENTS: int *pcmd Pointer to command read
18845 +* RETURNS: 0 if successful
18849 +*****************************************************************************************/
18851 +int dslhal_support_readTextMailbox
18856 +/******************************************************************************************
18857 +* FUNCTION NAME: dslhal_support_blockRead
18859 +*********************************************************************************************
18860 +* DESCRIPTION: This rouin simulates DSP memory read as done in ax5 pci nic card
18862 +* INPUT: void *addr, memory address to be read
18863 +* void *buffer, dat buffer to be filled with from memmory
18864 +* size_t count, number of bytes to be written
18866 +* RETURN: 0 --succeeded
18869 +*****************************************************************************************/
18871 +int dslhal_support_blockRead
18876 +/******************************************************************************************
18877 +* FUNCTION NAME: dslhal_support_blockWrite
18879 +*******************************************************************************************
18880 +* DESCRIPTION: This rouin simulates DSP memory write as done in ax5 pci nic card
18882 +* INPUT: void *buffer, data need to written
18883 +* void *adde, memory address to be written
18884 +* size_t count, number of bytes to be written
18886 +* RETURN: 0 --succeeded
18889 +*****************************************************************************************/
18891 +int dslhal_support_blockWrite
18896 +/******************************************************************************************
18897 +* FUNCTION NAME: dslhal_support_hostDspAddressTranslate
18899 +*******************************************************************************************
18900 +* DESCRIPTION: This function moves the address window to translate physical address
18902 +* INPUT: unsigned int addr : address that requires translation
18904 +* RETURN: Translated address or error condition
18907 +*****************************************************************************************/
18909 +unsigned int dslhal_support_hostDspAddressTranslate
18910 +( unsigned int addr
18913 +/******************************************************************************************
18914 +* FUNCTION NAME: dslhal_support_unresetDslSubsystem
18916 +*******************************************************************************************
18917 +* DESCRIPTION: This function unreset Dsl Subsystem
18921 +* RETURN: 0 if Pass; 1 if Fail
18923 +*****************************************************************************************/
18924 +int dslhal_support_unresetDslSubsystem
18928 +/******************************************************************************************
18929 +* FUNCTION NAME: dslhal_support_unresetDsp()
18931 +*******************************************************************************************
18932 +* DESCRIPTION: This fuction takes ax5 daugter board out of reset.
18936 +* RETURN: 0 --successful.
18939 +*****************************************************************************************/
18940 +int dslhal_support_unresetDsp
18945 +/******************************************************************************************
18946 +* FUNCTION NAME: dslhal_support_resetDslSubsystem
18948 +*******************************************************************************************
18949 +* DESCRIPTION: This function unreset Dsl Subsystem
18953 +* RETURN: 0 if Pass; 1 if Fail
18955 +*****************************************************************************************/
18956 +int dslhal_support_resetDslSubsystem
18960 +/******************************************************************************************
18961 +* FUNCTION NAME: dslhal_support_resetDsp()
18963 +*******************************************************************************************
18964 +* DESCRIPTION: This fuction takes ax5 daugter board out of reset.
18968 +* RETURN: 0 --successful.
18971 +*****************************************************************************************/
18972 +int dslhal_support_resetDsp
18977 +/********************************************************************************************
18978 +* FUNCTION NAME: dslhal_support_hostDspCodeDownload()
18980 +*********************************************************************************************
18982 +* download DSP image from host memory to dsp memory
18984 +* Return: 0 success
18988 +* DSP image is based on LITTLE endian
18990 +********************************************************************************************/
18992 +int dslhal_support_hostDspCodeDownload
18996 +/********************************************************************************************
18997 +* FUNCTION NAME: dslhal_diags_digi_assignMemTestSpace()
18999 +*********************************************************************************************
19000 +* DESCRIPTION: Assigns Memory Space in SDRAM for External Memory Test
19001 +* Input: tidsl_t *ptidsl
19003 +* Return: 0 success
19006 +********************************************************************************************/
19008 +unsigned int dslhal_diags_digi_assignMemTestSpace
19012 +/********************************************************************************************
19013 +* FUNCTION NAME: dslhal_diags_digi_readMemTestResult()
19015 +*********************************************************************************************
19016 +* DESCRIPTION: Reads Results of External Memory Test
19017 +* Input: tidsl_t *ptidsl
19019 +* Return: 0 success
19022 +********************************************************************************************/
19024 +unsigned int dslhal_diags_digi_readMemTestResult
19026 +unsigned int testResult
19030 +/********************************************************************************************
19031 +* FUNCTION NAME: dslhal_diags_codeDownload()
19033 +*********************************************************************************************
19034 +* DESCRIPTION: Brings DSLSS out of Reset, Downloads Diag Firmware,
19035 +* brings DSP out of Reset
19036 +* Input: tidsl_t *ptidsl
19038 +* Return: 0 success
19041 +********************************************************************************************/
19043 +unsigned int dslhal_diags_codeDownload
19045 +unsigned char* missingTones
19048 +/********************************************************************************************
19049 +* FUNCTION NAME: dslhal_diags_anlg_setPgaParams()
19051 +*********************************************************************************************
19052 +* DESCRIPTION: This function instructs the Transciever to transmit the Reverb with missing
19053 +* tones and Medley's with missing tones. These signals are defined in ITU
19054 +* G.992.1 ADSL Standards.
19056 +* Input: Test selects between the Reverb or Medley tests. 0 - Reverb, 1 - Medley
19057 +* Tones selects the .
19060 +********************************************************************************************/
19062 +unsigned int dslhal_diags_anlg_setPgaParams
19071 +/********************************************************************************************
19072 +* FUNCTION NAME: dslhal_diags_anlg_getRxNoisePower()
19074 +*********************************************************************************************
19075 +* DESCRIPTION: This function instructs the Transciever to transmit the Reverb with missing
19076 +* tones and Medley's with missing tones. These signals are defined in ITU
19077 +* G.992.1 ADSL Standards.
19079 +* Input: Test selects between the Reverb or Medley tests. 0 - Reverb, 1 - Medley
19080 +* Tones selects the .
19083 +********************************************************************************************/
19085 +unsigned int dslhal_diags_anlg_getRxNoisePower
19089 +/********************************************************************************************
19090 +* FUNCTION NAME: dslhal_diags_anlg_setMissingTones()
19092 +*********************************************************************************************
19093 +* DESCRIPTION: This function instructs the Transciever to transmit the Reverb with missing
19094 +* tones and Medley's with missing tones. These signals are defined in ITU
19095 +* G.992.1 ADSL Standards.
19097 +* Input: Test selects between the Reverb or Medley tests. 0 - Reverb, 1 - Medley
19098 +* Tones selects the .
19101 +********************************************************************************************/
19103 +unsigned int dslhal_diags_anlg_setMissingTones
19105 +unsigned char* missingTones
19108 +/********************************************************************************************
19109 +* FUNCTION NAME: dslhal_support_readDelineationState()
19111 +*********************************************************************************************
19113 +* download DSP image from host memory to dsp memory
19115 +* Return: 0 success
19119 +* DSP image is based on LITTLE endian
19121 +********************************************************************************************/
19122 +unsigned int dslhal_support_readDelineationState
19126 +/********************************************************************************************
19127 +* FUNCTION NAME: dslhal_support_processModemStateBitField()
19129 +*********************************************************************************************
19131 +* download DSP image from host memory to dsp memory
19133 +* Return: 0 success
19137 +* DSP image is based on LITTLE endian
19139 +********************************************************************************************/
19140 +unsigned int dslhal_support_processModemStateBitField
19144 +/********************************************************************************************
19145 +* FUNCTION NAME: dslhal_support_setInterruptMask()
19147 +*********************************************************************************************
19149 +* Sets the host interrupt bit masks
19151 +* Return: 0 success
19155 +* DSP image is based on LITTLE endian
19157 +********************************************************************************************/
19159 +unsigned int dslhal_support_setInterruptMask
19160 +(tidsl_t * ptidsl,
19161 +unsigned int inputMask
19164 +/********************************************************************************************
19165 +* FUNCTION NAME: dslhal_support_computeCrc32()
19167 +*********************************************************************************************
19169 +* Computes the CRC-32 for the input data
19171 +* Return: 32 bit CRC of the input data
19175 +* DSP image is based on LITTLE endian
19177 +********************************************************************************************/
19178 +unsigned int dslhal_support_computeCrc32
19179 +(unsigned char *data,
19183 +/********************************************************************************************
19184 +* FUNCTION NAME: dslhal_support_checkOverlayPage()
19186 +*********************************************************************************************
19188 +* Computes the CRC-32 for the input data and compares it with reference
19190 +* Return: Error Condition (if any)
19194 +* DSP image is based on LITTLE endian
19196 +********************************************************************************************/
19197 +unsigned int dslhal_support_checkOverlayPage
19202 +/********************************************************************************************
19203 +* FUNCTION NAME: dslhal_support_restoreTrainingInfo()
19205 +*********************************************************************************************
19207 +* Computes the CRC-32 for the input data and compares it with reference
19209 +* Return: Error Condition (if any)
19213 +* DSP image is based on LITTLE endian
19215 +********************************************************************************************/
19217 +int dslhal_support_restoreTrainingInfo(tidsl_t * ptidsl);
19219 +/********************************************************************************************
19220 +* FUNCTION NAME: dslhal_support_reloadTrainingInfo()
19222 +*********************************************************************************************
19224 +* Computes the CRC-32 for the input data and compares it with reference
19226 +* Return: Error Condition (if any)
19230 +* DSP image is based on LITTLE endian
19232 +********************************************************************************************/
19234 +int dslhal_support_reloadTrainingInfo(tidsl_t * ptidsl);
19236 +/********************************************************************************************
19237 +* FUNCTION NAME: dslhal_support_clearTrainingInfo()
19239 +*********************************************************************************************
19241 +* Computes the CRC-32 for the input data and compares it with reference
19243 +* Return: Error Condition (if any)
19247 +* DSP image is based on LITTLE endian
19249 +********************************************************************************************/
19251 +int dslhal_support_clearTrainingInfo(tidsl_t * ptidsl);
19253 +/********************************************************************************************
19254 +* FUNCTION NAME: dslhal_support_parseInterruptSource()
19256 +*********************************************************************************************
19258 +* Sets the host interrupt bit masks
19260 +* Return: 0 success
19264 +* DSP image is based on LITTLE endian
19266 +********************************************************************************************/
19268 +unsigned int dslhal_support_parseInterruptSource(tidsl_t * ptidsl);
19269 +/********************************************************************************************
19270 +* FUNCTION NAME: dslhal_support_advancedIdleProcessing()
19272 +*********************************************************************************************
19274 +* Calls Advanced Idle State Processing Functions
19276 +* Return: Error Condition (if any)
19280 +* DSP image is based on LITTLE endian
19282 +********************************************************************************************/
19283 +unsigned int dslhal_support_advancedIdleProcessing(tidsl_t *ptidsl);
19285 +/********************************************************************************************
19286 +* FUNCTION NAME: dslhal_support_aocBitSwapProcessing()
19288 +*********************************************************************************************
19290 +* Calls Advanced Bitswap buffer Processing Functions
19292 +* Return: Error Condition (if any)
19296 +* DSP image is based on LITTLE endian
19298 +********************************************************************************************/
19299 +unsigned int dslhal_support_aocBitSwapProcessing(tidsl_t *ptidsl,unsigned int usDs);
19301 +/********************************************************************************************
19302 +* FUNCTION NAME: dslhal_support_gatherEocMessages()
19304 +*********************************************************************************************
19306 +* Calls Advanced EOC Buffering functions
19308 +* Return: Error Condition (if any)
19312 +* DSP image is based on LITTLE endian
19314 +********************************************************************************************/
19315 +unsigned int dslhal_support_gatherEocMessages(tidsl_t *ptidsl,int usDs, int msgPart1, int msgPart2);
19317 +/********************************************************************************************
19318 +* FUNCTION NAME: dslhal_support_gatherSnrPerBin()
19320 +*********************************************************************************************
19322 +* Calls Advanced Snr per bin buffering Functions
19324 +* Return: Error Condition (if any)
19328 +* DSP image is based on LITTLE endian
19330 +********************************************************************************************/
19331 +unsigned int dslhal_support_gatherSnrPerBin(tidsl_t *ptidsl,unsigned int snrParm);
19333 +/********************************************************************************************
19334 +* FUNCTION NAME: dslhal_support_processTrainingState()
19336 +*********************************************************************************************
19338 +* Calls Advanced Training State Processing Functions
19340 +* Return: Error Condition (if any)
19344 +* DSP image is based on LITTLE endian
19346 +********************************************************************************************/
19347 +unsigned int dslhal_support_processTrainingState(tidsl_t *ptidsl);
19349 +/********************************************************************************************
19350 +* FUNCTION NAME: dslhal_support_gatherAdsl2Messages()
19352 +*********************************************************************************************
19354 +* Calls Advanced EOC Buffering functions
19356 +* Return: Error Condition (if any)
19360 +* DSP image is based on LITTLE endian
19362 +********************************************************************************************/
19363 +unsigned int dslhal_support_gatherAdsl2Messages(tidsl_t *ptidsl,int msgTag, int param1, int param2);
19365 +/********************************************************************************************
19366 +* FUNCTION NAME: dslhal_support_getAdsl2MsgLocation()
19368 +*********************************************************************************************
19370 +* Gets the address to the ADSL2 Message being looked up
19372 +* Return: Error Condition (if any)
19376 +* DSP image is based on LITTLE endian
19378 +********************************************************************************************/
19379 +unsigned int dslhal_support_getAdsl2MessageLocation(tidsl_t *ptidsl,int msgOffset);
19381 +/********************************************************************************************
19382 +* FUNCTION NAME: dslhal_support_getCMsgsRa()
19384 +*********************************************************************************************
19386 +* Calls Advanced Training Message functions
19388 +* Return: Error Condition (if any)
19392 +* DSP image is based on LITTLE endian
19394 +********************************************************************************************/
19395 +unsigned int dslhal_support_getCMsgsRa(tidsl_t *ptidsl,void *cMsg);
19397 +/********************************************************************************************
19398 +* FUNCTION NAME: dslhal_support_gatherRateMessages()
19400 +*********************************************************************************************
19402 +* Gathers Advanced Training Messages
19404 +* Return: Error Condition (if any)
19408 +* DSP image is based on LITTLE endian
19410 +********************************************************************************************/
19411 +unsigned int dslhal_support_gatherRateMessages(tidsl_t *ptidsl);
19413 +/********************************************************************************************
19414 +* FUNCTION NAME: dslhal_support_byteSwap16()
19416 +*********************************************************************************************
19418 +* byteswap a short
19423 +********************************************************************************************/
19425 +unsigned short dslhal_support_byteSwap16(unsigned short in16Bits);
19427 +/********************************************************************************************
19428 +* FUNCTION NAME: dslhal_support_byteSwap32()
19430 +*********************************************************************************************
19437 +********************************************************************************************/
19439 +unsigned int dslhal_support_byteSwap32(unsigned int in32Bits);
19441 +#endif /* Pairs #ifndef DSL_HAL_FUNCTIONDEFINES_H__ */
19442 diff -urN linux.old/drivers/atm/sangam_atm/dsl_hal_version.h linux.dev/drivers/atm/sangam_atm/dsl_hal_version.h
19443 --- linux.old/drivers/atm/sangam_atm/dsl_hal_version.h 1970-01-01 01:00:00.000000000 +0100
19444 +++ linux.dev/drivers/atm/sangam_atm/dsl_hal_version.h 2005-07-10 08:02:01.444111360 +0200
19446 +#ifndef __SYSSW_VERSION_H__
19447 +#define __SYSSW_VERSION_H__ 1
19449 +/*******************************************************************************
19450 +* FILE PURPOSE: DSL Driver API functions for Sangam
19452 +********************************************************************************
19453 +* FILE NAME: dsl_hal_basicapi.c
19456 +* Contains basic DSL HAL APIs for Sangam
19458 +* (C) Copyright 2003-04, Texas Instruments, Inc.
19460 +* Date Version Notes
19461 +* 14May03 0.00.00 RamP Original Version Created
19462 +* 14May03 0.00.01 RamP Initial Rev numbers inserted
19463 +* 14May03 0.00.02 RamP Bumped version numbers for Dsl Hal
19464 +* & dhalapp for alpha plus
19465 +* 19May03 0.00.03 MCB Bumped dslhal version number
19466 +* because of dependant changes
19467 +* wrt. linux-nsp atm drivers.
19468 +* 22May03 0.00.04 RamP Bumped dslhal & dhalapp buildnum
19469 +* for inner/outer pair & DGASP code
19470 +* 06Jun03 0.00.05 RamP Bumped up buildnum for LED, STM,
19471 +* interrupt processing, statistics
19472 +* and other pre-beta features
19473 +* 09Jun03 0.00.06 JEB Fixed error in DHALAPP bugfix/buildnum
19474 +* 09Jun03 0.00.07 RamP Bumped up buildnum for incremental
19475 +* changes to apis, statistics, memory
19476 +* fixes, parameter configurations
19477 +* 11Jun03 0.00.08 RamP Bumped up buildnum for Co profile
19479 +* 12Jun03 0.00.09 JEB Bumped version numbers for AR7 1.00 Beta
19480 +* 02Jul03 0.00.10 ZT Bumped HAL version for overlay page
19481 +* 18Jul03 0.00.11 RamP Bumped HAL version for analog diags
19482 +* 22Jul03 0.00.12 JEB Bumped DHALAPP buildnum for analog diags
19483 +* 31Jul03 0.00.13 RamP Bumped HAL version for engr. drop
19484 +* 04Aug03 0.00.14 JEB Bumped HAL version buildnum for CHECKPOINT65 changes
19485 +* Bumped LINUX version buildnum for CHECKPOINT65 changes
19486 +* 06Aug03 0.00.15 MCB Bumped all version numbers in prep for AR7 1.0 R2 release for POTS.
19487 +* 13Aug03 0.00.16 MCB Set rev id's for D3/R1.1 (ADSL2).
19488 +* 21Aug03 0.00.17 JEB Bumped up build numbers for merge of code additions from D1
19489 +* 26Sep03 0.00.18 JEB Set rev id's for another D3/R1 (ADSL2).
19490 +* 14Oct03 0.00.19 JEB Bumped Linux minor number and reset bugfix number for release.
19491 +* Bumped build numbers on DSLHAL and DHALAPP for this checkpoint.
19492 +* 14Oct03 0.00.20 JEB Bumped build numbers on DSLHAL and DHALAPP for CHECKPOINT15.
19493 +* 21Oct03 0.00.21 JEB Bumped build number on DSLHAL for CHECKPOINT16.
19494 +* 22Oct03 0.00.22 MCB Bumped all version numbers in support of D3R1 release.
19495 +* 27Oct03 0.00.23 JEB Bumped build numbers on DSLHAL and DHALAPP for CHECKPOINT19.
19496 +* Updated version for DSLAGENT to be 02.01.00.01 for ACT 2.1 R0.
19497 +* 30Oct03 0.00.24 JEB Bumped bugfix number on LINUXATM Version for next release.
19498 +* Bumped build numbers on DSLHAL and DHALAPP
19499 +* 31Oct03 0.00.25 MCB Bumped all version numbers in support of D3R2 release.
19500 +* 14Nov03 0.00.26 JEB Bumped build numbers on DSLHAL and DHALAPP
19501 +* Changed version for DSLAGENT to be 02.00.01.01 for an ACT 2.0 R0
19502 +* 20Nov03 0.00.27 JEB Bumped build number on DSLHAL.
19503 +* Changed version for DSLAGENT to be 02.00.02.00 for the next ACT 2.0 R2
19504 +* 21Nov03 0.00.28 MCB Bumped all version numbers in support of D3R2 release.
19505 +* 21Nov03 0.00.29 JEB Bumped build numbers on DSLHAL and DHALAPP for D3-R0 drop on 11/21.
19506 +* 16Dec03 0.00.30 JEB Bumped build numbers on DSLHAL and DHALAPP for CHECKPOINT31.
19507 +* 21Dec03 0.00.31 MCB Bumped all version numbers in support of D3R2 release.
19508 +* 05Jan04 0.00.32 JEB Bumped build numbers on DSLHAL and Linux ATM for CHECKPOINT 34.
19509 +* 15Jan04 0.00.33 JEB Bumped build numbers on DSLHAL and Linux ATM for CHECKPOINT 36.
19510 +* 26Jan04 0.00.34 JEB Changed Linux ATM version number to be 04.02.03.00.
19511 +* 27Jan04 0.00.35 MCB Bumped all version numbers in support of D3R2 release.
19512 +*******************************************************************************/
19514 +/* Dsl Hal API Version Numbers */
19515 +#define DSLHAL_VERSION_MAJOR 03
19516 +#define DSLHAL_VERSION_MINOR 00
19517 +#define DSLHAL_VERSION_BUGFIX 06
19518 +#define DSLHAL_VERSION_BUILDNUM 00
19519 +#define DSLHAL_VERSION_TIMESTAMP 00
19521 +/* dhalapp Adam2 Application Version Numbers */
19522 +#define DHALAPP_VERSION_MAJOR 03
19523 +#define DHALAPP_VERSION_MINOR 00
19524 +#define DHALAPP_VERSION_BUGFIX 05
19525 +#define DHALAPP_VERSION_BUILDNUM 00
19527 +/* Linux ATM Driver Version Numbers */
19528 +#define LINUXATM_VERSION_MAJOR 04
19529 +#define LINUXATM_VERSION_MINOR 02
19530 +#define LINUXATM_VERSION_BUGFIX 04
19531 +#define LINUXATM_VERSION_BUILDNUM 00
19533 +/* DSL Agent Version Numbers */
19534 +#define DSLAGENT_VERSION_MAJOR 02
19535 +#define DSLAGENT_VERSION_MINOR 00
19536 +#define DSLAGENT_VERSION_BUGFIX 02
19537 +#define DSLAGENT_VERSION_BUILDNUM 00
19539 +#endif /* pairs with #ifndef __SYSSW_VERSION_H__ */
19540 diff -urN linux.old/drivers/atm/sangam_atm/ec_errors_cpaal5.h linux.dev/drivers/atm/sangam_atm/ec_errors_cpaal5.h
19541 --- linux.old/drivers/atm/sangam_atm/ec_errors_cpaal5.h 1970-01-01 01:00:00.000000000 +0100
19542 +++ linux.dev/drivers/atm/sangam_atm/ec_errors_cpaal5.h 2005-07-10 08:02:01.445111208 +0200
19544 +/***************************************************************************
19545 + Copyright(c) 2001, Texas Instruments Incorporated. All Rights Reserved.
19547 + FILE: ec_errors.h
19550 + This file contains definitions and function declarations for
19551 + error code support.
19554 + 14Dec00 MJH Added masking to EC_CLASS etc macros
19555 + 17Sep02 GSG Added HAL support (new class&devices)
19556 + 03Oct02 GSG Removed C++ style comments
19557 +***************************************************************************/
19558 +#ifndef _INC_EC_ERRORS
19559 +#define _INC_EC_ERRORS
19563 + 30-28 - CLASS (ie. DIAG, KERNEL, FLASH, etc)
19564 + 27-24 - INSTANCE (ie. 1, 2, 3, etc )
19565 + 23-16 - DEVICE (ie. EMAC, IIC, etc)
19566 + 15-08 - FUNCTION (ie. RX, TX, INIT, etc)
19567 + 07-00 - ERROR CODE (ie. NO_BASE, FILE_NOT_FOUND, etc )
19570 +/*---------------------------------------------------------------------------
19571 + Useful defines for accessing fields within error code
19572 +---------------------------------------------------------------------------*/
19573 +#define CRITICAL_SHIFT 31
19574 +#define CLASS_SHIFT 28
19575 +#define INST_SHIFT 24
19576 +#define DEVICE_SHIFT 16
19577 +#define FUNCTION_SHIFT 8
19578 +#define ERROR_CODE_SHIFT 0
19580 +#define CRITICAL_MASK 1
19581 +#define CLASS_MASK 0x07
19582 +#define DEVICE_MASK 0xFF
19583 +#define INST_MASK 0x0F
19584 +#define FUNCTION_MASK 0xFF
19585 +#define ERROR_CODE_MASK 0xFF
19587 +#define EC_CLASS(val) ((val&CLASS_MASK) << CLASS_SHIFT)
19588 +#define EC_DEVICE(val) ((val&DEVICE_MASK) << DEVICE_SHIFT)
19589 +#define EC_INST(val) ((val&INST_MASK) << INST_SHIFT)
19590 +#define EC_FUNC(val) ((val&FUNCTION_MASK) << FUNCTION_SHIFT)
19591 +#define EC_ERR(val) ((val&ERROR_CODE_MASK) << ERROR_CODE_SHIFT)
19593 +/*---------------------------------------------------------------------------
19594 + Operation classes
19595 +---------------------------------------------------------------------------*/
19596 +#define EC_HAL EC_CLASS(0)
19597 +#define EC_DIAG EC_CLASS(8)
19599 +/*---------------------------------------------------------------------------
19601 +---------------------------------------------------------------------------*/
19602 +#define EC_DEV_EMAC EC_DEVICE(1)
19603 +#define EC_DEV_IIC EC_DEVICE(2)
19604 +#define EC_DEV_RESET EC_DEVICE(3)
19605 +#define EC_DEV_ATMSAR EC_DEVICE(4)
19606 +#define EC_DEV_MEM EC_DEVICE(5)
19607 +#define EC_DEV_DES EC_DEVICE(6)
19608 +#define EC_DEV_DMA EC_DEVICE(7)
19609 +#define EC_DEV_DSP EC_DEVICE(8)
19610 +#define EC_DEV_TMR EC_DEVICE(9)
19611 +#define EC_DEV_WDT EC_DEVICE(10)
19612 +#define EC_DEV_DCL EC_DEVICE(11)
19613 +#define EC_DEV_BBIF EC_DEVICE(12)
19614 +#define EC_DEV_PCI EC_DEVICE(13)
19615 +#define EC_DEV_XBUS EC_DEVICE(14)
19616 +#define EC_DEV_DSLIF EC_DEVICE(15)
19617 +#define EC_DEV_USB EC_DEVICE(16)
19618 +#define EC_DEV_CLKC EC_DEVICE(17)
19619 +#define EC_DEV_RAPTOR EC_DEVICE(18)
19620 +#define EC_DEV_DSPC EC_DEVICE(19)
19621 +#define EC_DEV_INTC EC_DEVICE(20)
19622 +#define EC_DEV_GPIO EC_DEVICE(21)
19623 +#define EC_DEV_BIST EC_DEVICE(22)
19624 +#define EC_DEV_HDLC EC_DEVICE(23)
19625 +#define EC_DEV_UART EC_DEVICE(24)
19626 +#define EC_DEV_VOIC EC_DEVICE(25)
19627 +/* 9.17.02 (new HAL modules) */
19628 +#define EC_DEV_CPSAR EC_DEVICE(0x1A)
19629 +#define EC_DEV_AAL5 EC_DEVICE(0x1B)
19630 +#define EC_DEV_AAL2 EC_DEVICE(0x1C)
19631 +#define EC_DEV_CPMAC EC_DEVICE(0x1D)
19632 +#define EC_DEV_VDMA EC_DEVICE(0x1E)
19633 +#define EC_DEV_VLYNQ EC_DEVICE(0x1F)
19634 +#define EC_DEV_CPPI EC_DEVICE(0x20)
19635 +#define EC_DEV_CPMDIO EC_DEVICE(0x21)
19637 +/*---------------------------------------------------------------------------
19639 +---------------------------------------------------------------------------*/
19640 +#define EC_FUNC_READ_CONF EC_FUNC(1)
19641 +#define EC_FUNC_INIT EC_FUNC(2)
19643 +/*---------------------------------------------------------------------------
19645 +---------------------------------------------------------------------------*/
19646 +#define EC_CRITICAL (1<<CRITICAL_SHIFT)
19647 +#define EC_NO_ERRORS 0
19648 +#define EC_VAL_NO_BASE EC_ERR(1)
19649 +#define EC_VAL_NO_RESET_BIT EC_ERR(2)
19650 +#define EC_VAL_NO_RESET EC_ERR(3)
19651 +#define EC_VAL_BAD_BASE EC_ERR(4)
19652 +#define EC_VAL_MALLOCFAILED EC_ERR(5)
19653 +#define EC_VAL_NO_RESETBASE EC_ERR(6)
19654 +#define EC_DEVICE_NOT_FOUND EC_ERR(7)
19656 +/*---------------------------------------------------------------------------
19657 + Function declarations
19658 +---------------------------------------------------------------------------*/
19659 +extern void ec_log_error( unsigned int );
19661 +#endif /* _INC_EC_ERRORS */
19662 diff -urN linux.old/drivers/atm/sangam_atm/ec_errors_cpsar.h linux.dev/drivers/atm/sangam_atm/ec_errors_cpsar.h
19663 --- linux.old/drivers/atm/sangam_atm/ec_errors_cpsar.h 1970-01-01 01:00:00.000000000 +0100
19664 +++ linux.dev/drivers/atm/sangam_atm/ec_errors_cpsar.h 2005-07-10 08:02:01.445111208 +0200
19666 +/***************************************************************************
19667 + Copyright(c) 2001, Texas Instruments Incorporated. All Rights Reserved.
19669 + FILE: ec_errors.h
19672 + This file contains definitions and function declarations for
19673 + error code support.
19676 + 14Dec00 MJH Added masking to EC_CLASS etc macros
19677 + 17Sep02 GSG Added HAL support (new class&devices)
19678 + 03Oct02 GSG Removed C++ style comments
19679 +***************************************************************************/
19680 +#ifndef _INC_EC_ERRORS
19681 +#define _INC_EC_ERRORS
19685 + 30-28 - CLASS (ie. DIAG, KERNEL, FLASH, etc)
19686 + 27-24 - INSTANCE (ie. 1, 2, 3, etc )
19687 + 23-16 - DEVICE (ie. EMAC, IIC, etc)
19688 + 15-08 - FUNCTION (ie. RX, TX, INIT, etc)
19689 + 07-00 - ERROR CODE (ie. NO_BASE, FILE_NOT_FOUND, etc )
19692 +/*---------------------------------------------------------------------------
19693 + Useful defines for accessing fields within error code
19694 +---------------------------------------------------------------------------*/
19695 +#define CRITICAL_SHIFT 31
19696 +#define CLASS_SHIFT 28
19697 +#define INST_SHIFT 24
19698 +#define DEVICE_SHIFT 16
19699 +#define FUNCTION_SHIFT 8
19700 +#define ERROR_CODE_SHIFT 0
19702 +#define CRITICAL_MASK 1
19703 +#define CLASS_MASK 0x07
19704 +#define DEVICE_MASK 0xFF
19705 +#define INST_MASK 0x0F
19706 +#define FUNCTION_MASK 0xFF
19707 +#define ERROR_CODE_MASK 0xFF
19709 +#define EC_CLASS(val) ((val&CLASS_MASK) << CLASS_SHIFT)
19710 +#define EC_DEVICE(val) ((val&DEVICE_MASK) << DEVICE_SHIFT)
19711 +#define EC_INST(val) ((val&INST_MASK) << INST_SHIFT)
19712 +#define EC_FUNC(val) ((val&FUNCTION_MASK) << FUNCTION_SHIFT)
19713 +#define EC_ERR(val) ((val&ERROR_CODE_MASK) << ERROR_CODE_SHIFT)
19715 +/*---------------------------------------------------------------------------
19716 + Operation classes
19717 +---------------------------------------------------------------------------*/
19718 +#define EC_HAL EC_CLASS(0)
19719 +#define EC_DIAG EC_CLASS(8)
19721 +/*---------------------------------------------------------------------------
19723 +---------------------------------------------------------------------------*/
19724 +#define EC_DEV_EMAC EC_DEVICE(1)
19725 +#define EC_DEV_IIC EC_DEVICE(2)
19726 +#define EC_DEV_RESET EC_DEVICE(3)
19727 +#define EC_DEV_ATMSAR EC_DEVICE(4)
19728 +#define EC_DEV_MEM EC_DEVICE(5)
19729 +#define EC_DEV_DES EC_DEVICE(6)
19730 +#define EC_DEV_DMA EC_DEVICE(7)
19731 +#define EC_DEV_DSP EC_DEVICE(8)
19732 +#define EC_DEV_TMR EC_DEVICE(9)
19733 +#define EC_DEV_WDT EC_DEVICE(10)
19734 +#define EC_DEV_DCL EC_DEVICE(11)
19735 +#define EC_DEV_BBIF EC_DEVICE(12)
19736 +#define EC_DEV_PCI EC_DEVICE(13)
19737 +#define EC_DEV_XBUS EC_DEVICE(14)
19738 +#define EC_DEV_DSLIF EC_DEVICE(15)
19739 +#define EC_DEV_USB EC_DEVICE(16)
19740 +#define EC_DEV_CLKC EC_DEVICE(17)
19741 +#define EC_DEV_RAPTOR EC_DEVICE(18)
19742 +#define EC_DEV_DSPC EC_DEVICE(19)
19743 +#define EC_DEV_INTC EC_DEVICE(20)
19744 +#define EC_DEV_GPIO EC_DEVICE(21)
19745 +#define EC_DEV_BIST EC_DEVICE(22)
19746 +#define EC_DEV_HDLC EC_DEVICE(23)
19747 +#define EC_DEV_UART EC_DEVICE(24)
19748 +#define EC_DEV_VOIC EC_DEVICE(25)
19749 +/* 9.17.02 (new HAL modules) */
19750 +#define EC_DEV_CPSAR EC_DEVICE(0x1A)
19751 +#define EC_DEV_AAL5 EC_DEVICE(0x1B)
19752 +#define EC_DEV_AAL2 EC_DEVICE(0x1C)
19753 +#define EC_DEV_CPMAC EC_DEVICE(0x1D)
19754 +#define EC_DEV_VDMA EC_DEVICE(0x1E)
19755 +#define EC_DEV_VLYNQ EC_DEVICE(0x1F)
19756 +#define EC_DEV_CPPI EC_DEVICE(0x20)
19757 +#define EC_DEV_CPMDIO EC_DEVICE(0x21)
19759 +/*---------------------------------------------------------------------------
19761 +---------------------------------------------------------------------------*/
19762 +#define EC_FUNC_READ_CONF EC_FUNC(1)
19763 +#define EC_FUNC_INIT EC_FUNC(2)
19765 +/*---------------------------------------------------------------------------
19767 +---------------------------------------------------------------------------*/
19768 +#define EC_CRITICAL (1<<CRITICAL_SHIFT)
19769 +#define EC_NO_ERRORS 0
19770 +#define EC_VAL_NO_BASE EC_ERR(1)
19771 +#define EC_VAL_NO_RESET_BIT EC_ERR(2)
19772 +#define EC_VAL_NO_RESET EC_ERR(3)
19773 +#define EC_VAL_BAD_BASE EC_ERR(4)
19774 +#define EC_VAL_MALLOCFAILED EC_ERR(5)
19775 +#define EC_VAL_NO_RESETBASE EC_ERR(6)
19776 +#define EC_DEVICE_NOT_FOUND EC_ERR(7)
19778 +/*---------------------------------------------------------------------------
19779 + Function declarations
19780 +---------------------------------------------------------------------------*/
19781 +extern void ec_log_error( unsigned int );
19783 +#endif /* _INC_EC_ERRORS */
19784 diff -urN linux.old/drivers/atm/sangam_atm/env_def_defines.h linux.dev/drivers/atm/sangam_atm/env_def_defines.h
19785 --- linux.old/drivers/atm/sangam_atm/env_def_defines.h 1970-01-01 01:00:00.000000000 +0100
19786 +++ linux.dev/drivers/atm/sangam_atm/env_def_defines.h 2005-07-10 08:02:01.446111056 +0200
19788 +#ifndef __ENV_DEF_DEFINES_H__
19789 +#define __ENV_DEF_DEFINES_H__ 1
19791 +//********************************************************************
19792 +//* DMT-BASE ADSL MODEM PROGRAM
19793 +//* TEXAS INSTRUMENTS PROPRIETARTY INFORMATION
19794 +//* AMATI CONFIDENTIAL PROPRIETARY
19796 +//* (c) Copyright May 1999, Texas Instruments Incorporated.
19797 +//* All Rights Reserved.
19799 +//* Property of Texas Instruments Incorporated and Amati Communications Corp.
19801 +//* Restricted Rights - Use, duplication, or disclosure is subject to
19802 +//* restrictions set forth in TI's and Amati program license agreement and
19803 +//* associated documentation
19805 +//*********************************************************************
19807 +//* FILENAME: dpsys_defines.h
19809 +//* ABSTRACT: This file provides a mechanism for defining standard
19810 +//* preprocessor flag sets for datapump.
19812 +//* TARGET: Non specific.
19814 +//* TOOLSET: Non specific.
19818 +//* HISTORY: DATE AUTHOR DESCRIPTION
19819 +//* 05/11/99 FLW Created
19820 +//* 01/21/00 FLW derfmake changes
19821 +//* 02/07/00 FLW/M.Seidl added _debug targets
19822 +//* 02/23/00 FLW/M.Barnett merged in from G.lite branch
19823 +//* 03/03/00 FLW/M.Barnett added TRELLIS token
19824 +//* 05/11/00 Barnett Added ap036btp & ap037btp support.
19825 +//* 02/07/00 M.Seidl added HW_TEQ, HW_DEC and DC_BIAS tokens
19826 +//* 02/28/00 Derf/Seidl Mod's in support of suppressing compiler warnings for empty source files
19827 +//* 02/28/00 M. Seidl added SWTC token
19828 +//* 02/28/00 M. Seidl added ap0501tp and its _debug target
19829 +//* 03/03/00 M. Seidl added MODPILOT token, ap0307tp_debug has SWDI and FDD enabled
19830 +//* 03/08/00 Jack Huang Added HWRSDEC token
19831 +//* 03/29/00 Derf/Seidl Mod's in support Soft-TC and derfmake
19832 +//* 04/10/00 Jack Huang Added PCIMASTER token
19833 +//* 04/11/00 Jack Huang Added STBFIX token
19834 +//* 04/24/00 M. Seidl ap0500tp has OLAYDP turned on, ap0500tp_debug has OLAYDP turned off now
19835 +//* 04/28/00 M.Seidl added KAPIL token for ap0501tp targets
19836 +//* 06/02/00 P.Sexton Added OAM_EOC token
19837 +//* 06/06/00 M. Seidl added au0501tp target
19838 +//* 06/12/00 Michael Seidl activated h/w TEQ for KAPIL targets, disabled STBFIX for all targets
19839 +//* 06/14/00 Derf added ap0308tp, alphabetized token lists
19840 +//* 06/16/00 Jack Huang added au0501tp_debug target
19841 +//* 06/22/00 M. Seidl Enabled code overlays through EMIF from external memory. Now there are 3
19842 +//* different code overlay schemes that are differentiated by the following tokens:
19843 +//* OLAYDP_PCI: uses PCI DMA in PCI Master Mode
19844 +//* OLAYDP_HOST: Host downloads overlay code into DMEM upon request from DSP
19845 +//* OLAYDP_EMIF: Host downloads overlay code into ext. mem at boot-time. DSP uses
19846 +//* DMA channel 0 to load code into on-chip PMEM
19847 +//* OLAYDP: turns overlays generally on or off
19848 +//* 07/15/00 B.Srinivasan Cleaned up default tokens and tokens for au0501tp, au0501tp_debug,
19849 +//* ap0501tp and ap0501tp_debug targets as well
19850 +//* 07/19/00 B.Srinivasan Made changes w.r.t cleaning/fixing Rufus Interrupt related code
19851 +//* (changed token TC_INTRPT_RUFUS to INTRPT_RUFUS
19852 +//* 06/14/00 Derf added au0501cp
19853 +//* 08/12/00 Yinong Ding Added DPLL_MODE token.
19854 +//* 08/16/00 F. Mujica Moved DOUBLE_XMT_RATE, RX_HPF, and LEAKY_LMS tokens here.
19855 +//* 09/05/00 M. Seidl Changed ap0501tp back to do overlay through PCI (OLAY_PCI = 1)
19856 +//* 09/11/00 M. Seidl moved USB and OLAYDP_HOST definitions to be CHIPSET specific, not target specific
19857 +//* 09/21/00 U.Dasgupta/ Added a token for separate transmit and receive buffers.
19858 +//* F.Mujica (SEPARATE_TX_RX_BUFFERS).
19859 +//* 10/02/00 U.Dasgupta/ Added DPLL and SEPARATE_TX_RX_BUFFER tokens for au0502 target.
19861 +//* 10/02/00 M. Castellano Added new tokens for new Host/EMIF DSP code overlay.
19862 +//* OLAYDP_2STEP: Host downloads overlay code into ext. mem upon DSP request. DSP
19863 +//* DMA channel 0 to load code into on-chip PMEM. It is a somewhat hybrid version
19864 +//* of OLAYDP_HOST and OLAYDP_EMIF. The test target is ap0502tp.
19865 +//* 10/25/00 Balaji Added tokens for arv500tp target
19866 +//* 10/31/00 U. Iyer Added TEQ_AVG token and set it one for Ax5
19867 +//* 11/02/00 Barnett Added OAM_EOC=0 in defaults at bottom of file.
19868 +//* 11/21/00 M. Seidl turned OLAYDP and AOC off for ap0307tp to make binary compatible w. whql'ed driver
19869 +//* 11/28/00 Paul Hunt added FASTRETRAIN token for fast retrain specific code
19870 +//* 11/28/00 Paul Hunt added PILOTDATA token to control channel estimation and transmission
19871 +//* of data on the upstream pilot tone for ITU standard code loads
19872 +//* 12/20/00 Jack Huang added EIGHTBITSRAM toekn for the targets that use 8-bit SRAM for
19873 +//* interleaver/deinterleaver
19874 +//* 01/11/01 U.Dasgupta Added mp targets and cleaned up GHS/PILOTDATA variables
19875 +//* 01/23/01 U.Dasgupta Cleaned up code within GLITE tokens
19876 +//* 01/23/00 Barnett Added in full EOC support for AP3/Ax5. Got rid of UTC. No longer needed.
19877 +//* 02/08/01 Barnett Added DDC token.
19878 +//* 03/09/01 Nirmal Warke Added in TOKEN definition for line diagnostics (LINE_DIAG): IMP DEPENDENCIES -
19879 +//* TEQ_AVG must be off when LINE_DIAG is on (since they share a union buffer at the same time)
19880 +//* 03/13/01 M. Seidl Recovered ap0500tp target. Added GHS token as PMEM saving option
19881 +//* 03/14/01 Barnett Added ap0500mb target support. Look-and-feel is similar to ap0500tp.
19882 +//* Added seperate-but-equal def's wrt. ISDN Annex B, Annex C, and PROP.
19883 +//* 03/14/01 J. Bergsagel Added EXTERNBERT token.
19884 +//* 03/15/01 Barnett/Balaji Merged AR5(H) -> 03.00.00 datapump.
19885 +//* 03/16/01 Nirmal Warke Added in TOKEN definition for crosstalk performance mods (CROSSTALK): IMP DEPENDENCIES -
19886 +//* TEQ_AVG must be off and LEAKY_LMS must be on when CROSSTALK is on
19887 +//* 03/21/01 Barnett Added support for ar0500lp, ar0500mp, ar0500dp, arv500lp, arv500mp, and arv500dp.
19888 +//* 03/26/01 M. Seidl enabled 64pt IFFT for ap0500mb (Raptor+AD11, FDM)
19889 +//* 03/28/01 J. Bergsagel Removed EXTERNBERT token (now use host intf. var. instead)
19890 +//* 04/03/01 J. Bergsagel Removed condition of DSPDP_CHIPSET_GEN==5 for default defines
19891 +//* Removed LEAKY_LMS token (assumed always 1)
19892 +//* Removed OLAYDP_HOST token (assumed always 0)
19893 +//* Removed RX_HPF token (assumed always 1)
19894 +//* Removed TRIBRID token (not used any more)
19895 +//* Removed FDD token (assumed always 1)
19896 +//* Removed HW_DEC token (assumed always 1)
19897 +//* Removed HW_TEQ token (assumed always 1)
19898 +//* Removed HWRSDEC token (assumed always 1)
19899 +//* Removed ILEC_AD11_ALCATEL337 token (assumed always 0)
19900 +//* Removed ILEC_AD11_HDSLNOISEFIX token (assumed always 0)
19901 +//* Removed ILEC_AD11_MODULATEPILOT token (assumed always 0)
19902 +//* Removed ILEC_AD11_NEWINTERPOLATE token (assumed always 0)
19903 +//* Removed ILEC_AD11_USTXHPF token (assumed always 0)
19904 +//* Removed SWDI token (assumed always 1)
19905 +//* Removed TD_AGC token (assumed always 1)
19906 +//* Removed DSPDP_LEGACY_TARGET token (assumed always 0)
19907 +//* Removed AD11_20, AD11_20NL and AD11_20_NEWPREC token (always 1)
19908 +//* Removed AI token (assumed always 1)
19909 +//* Removed ATUC token (assumed always 0)
19910 +//* Removed EU token (assumed always 0)
19911 +//* Removed EVM2 token (assumed always 0)
19912 +//* Removed INTRPT_RUFUS token (assumed always 0)
19913 +//* Removed MODPILOT token (assumed always 0)
19914 +//* Removed SL and SL_EVM tokens (assumed always 0)
19915 +//* Removed STBIFX token (assumed always 0)
19916 +//* Removed STD token (assumed always 1)
19917 +//* Removed SWDI_LOOPBACK token (assumed always 0)
19918 +//* Removed TID token (assumed always 0)
19919 +//* Removed TII token (assumed always 1)
19920 +//* Removed TIPCI token (assumed always 1)
19921 +//* Removed UDI token (assumed always 1)
19922 +//* Removed DC_BIAS token (assumed always 1)
19923 +//* 04/05/01 Barnett Added DSPDP_ prefix to tokens that originate
19924 +//* in the public interface.
19925 +//* 05/07/01 Jack Huang Removed DOUBLE_XMT_RATE token.
19926 +//* 05/16/01 Barnett Added back in EXTERNBERT token in support
19927 +//* of saving PMEM.
19928 +//* 06/05/01 Jack Huang Fixed the rules for ar0500mp_debug target
19929 +//* 04/23/01 M. Halleck Merge Astro Wu's DDC enhancements
19930 +//* 06/05/01 M. Capps Changed DSP_DEBUG to ENHANCED_SERIAL_DEBUG
19931 +//* 07/03/01 M. Capps Replaced ESD token with !DDC, added DEV_DEBUG
19932 +//* 06/26/01 J. Bergsagel Removed all the old ap03... stuff
19933 +//* Removed OLAYDP_HOST token (again)
19934 +//* Removed CROSSTALK token (assumed always 1)
19935 +//* Removed TEQ_AVG token (assumed always 0)
19936 +//* Removed DE token (assumed always 1)
19937 +//* Removed PVAT token and au0501cp target
19938 +//* Removed FASTRETRAIN token (assumed always 0)
19939 +//* 07/05/01 J. Bergsagel Changed PCIMASTER token to TC_ATM_PCIMASTER
19940 +//* 07/20/01 Umesh Iyer Added ATMBERT token. ATMBERT is conditional on SWTC definition. if SWTC is 0
19941 +//* ATMBERT should be 0. Else it can be 0/1. Default 0.
19942 +//* 07/23/01 J. Bergsagel Changed name from defines_u.h to dpsys_defines.h
19943 +//* 07/24/01 Barnett Added support for build of $(TARGET)_diag mfgr'ing targets.
19944 +//* 08/02/01 Michael Seidl renamed KAPIL token to !AD1X
19945 +//* 08/02/01 Michael Seidl renamed GHS token to PMEMSAVE_GHS
19946 +//* 08/03/01 S.Yim Added MFGR_DIAG token for afe diagnostic
19947 +//* Added AFEDEV token for afe device driver
19948 +//* Added DSPBIOSII token for dsp bios
19949 +//* 09/21/01 Sameer Enable EXTERNBERT. Disable ATMBERT.
19950 +//* 10/01/01 U.Dasgupta Turned off SMART_MARGIN for ap0500mb because of FECs/CRCs;
19951 +//* 10/09/01 Barnett Added support for ar0500db.
19952 +//* 10/12/01 Barnett Disable EXTERNBERT.
19953 +//* 10/15/01 Barnett Turn off SMART_MARGIN.
19954 +//* 11/07/01 Barnett Def'ed ISDN_DEBUG for all targets to avoid compiler warnings.
19955 +//* Assumed defaul value is zero.
19956 +//* 11/13/01 Barnett Reworked ar0500db_debug to build JTAG-bootable load.
19957 +//* The equivalent production target should only be flash-bootable.
19958 +//* 01/11/02 Yim Added TOKEN JTAG to build JTAG load ar0500db_diag.
19959 +//* 01/23/02 U Iyer Added DEBUG_LOG token. Default value 0
19960 +//* 01/31/02 Barnett Added support for ar0700mp target.
19961 +//* 02/04/02 S.Yim Added TOKEN JTAG to build JTAG load ar0500mp_diag
19962 +//* 02/11/02 U Iyer Added MARGIN_DELTA_RETRAIN token. Default value 1
19963 +//* 05/15/02 Sameer V Enabled EXTERNBERT token for AR5 and AU5 platforms. EXTERNBERT is
19964 +//* not supported on AR5H.
19965 +//* 02/14/02 Barnett Don't ref the SWTC feature token if mfgr'ing diag target.
19966 +//* 02/19/02 Yim Added support to build au0502db_diag target.
19967 +//* 03/08/02 Nirmal Warke Added feature token HYBRID_SWITCH
19968 +//* 03/15/02 U G Jani Turned ON Bitswap support for AU5I (au0502db) targets.
19969 +//* 04/08/02 U G Jani Enabled NLNOISEADJSNR token for AU5I targets.
19970 +//* 06/24/02 Seungmok Oh Added PERTONE_EQ token support for those targets:
19971 +//* (ar0500mp_debug, au0502mp_debug, ar0500mp, au0502mp)
19972 +//* 06/26/02 Mallesh Added DS_PWR_CUTBACK token. Default value 1.
19973 +//* 06/27/02 Mallesh Changed default value of DS_PWR_CUTBACK token to 0.
19974 +//* 06/29/02 U.Dasgupta Token cleanup: Removed ISDN_DEBUG token
19975 +//* 04/29/02 Mannering Remove EIGHTBITSRAM, Combined DOUBLEBUFFER with
19976 +//* BITSWAP, added FPGA token
19977 +//* 05/03/02 Mannering cleanup token changed by the new routine names
19978 +//* 05/06/02 Mannering Add tokens OUTBAND and INBAND for codec commands
19979 +//* If both OUTBAND and INBAND are 0 codec register are
19980 +//* memory mapped.
19981 +//* 05/29/2002 S.Yim Removed AD1X, AFEDEV
19982 +//* 08/31/2002 Paul Hunt Added PERTONE_EQ and HYBRID_SWITCH for ar0700mp
19983 +//* 09/12/2002 Paul Hunt Added support for ar0700db target.
19984 +//* 08/07/2002 U.Dasgupta Turned off MARGIN_DELTA_RETRAIN feature for ISDN platforms
19985 +//* 11/14/2002 Paul Hunt Merged AX5 MR6 PC modifications into AR7 codebase, specifically
19986 +//* turned off MARGIN_DELTA_RETRAIN feature for ar0700db target
19987 +//* 08/26/2002 N. Warke Added DUAL_TEQ token. Active only for Ax7 target
19988 +//* 09/26/2002 Mannering Add token CODEC_EMU for codec emulator board
19989 +//* 10/15/2002 Iyer/Molla Added DMT_BIS token for DELT support
19990 +//* 10/21/2002 A. Redfern Added PHY_EC_ENABLE and PHY_PATH_ENABLE tokens
19991 +//* 10/23/2002 A. Redfern Removed LINE_DIAG token
19992 +//* 10/28/2002 J. Bergsagel Cleaned up old targets and cleaned up the token list
19993 +//* 10/30/2002 A. Redfern Added PHY_TDW_ENABLE
19994 +//* 11/01/2002 A. Redfern Removed SMART_MARGIN token
19995 +//* 11/01/2002 Mustafa Turned on SPECTRAL_SHAPING features for Lucent AnyMedia O.69 Interop.
19996 +//* 11/15/2002 Yim/Mannering Added CODEC_EMU token for analog emulation board specifics
19997 +//* 11/15/2002 Iyer/Molla Added DEBUG_DELT and MEM_STR token to support DELT debug
19998 +//* 12/27/2002 Sameer V Added ATM_TC_HW token for Sangam.
19999 +//* 01/06/2003 J. Bergsagel Added default values for NLNOISEADJSNR, ARTT and DS_PWR_CUTBACK
20000 +//* 01/07/2003 S.Yim Modified ar0700db_diag target to turn on ISDN token
20001 +//* 01/22/2003 J. Bergsagel Added back in defines for the debug targets.
20002 +//* 01/21/2003 MCB Implemented Ax7 UNIT-MODULE modular software framework.
20003 +//* 01/31/2003 J. Bergsagel Made debug targets to be for the FPGA platform; non-debug for Sangam.
20004 +//* Turned off DUAL_TEQ, PHY_EC_ENABLE and PHY_PATH_ENABLE by default
20005 +//* for the Sangam (non-debug) targets.
20006 +//* Turned off OLAYDP token by default.
20007 +//* Turned off SWTC and turned on ATM_TC_HW by default for Sangam targets.
20008 +//* 01/29/2003 Sameer V Added ATMBERT_HW token for Sangam.
20009 +//* 02/04/2003 D. Mannering Added CO_PROFILE token
20010 +//* 02/19/2003 Sameer V Added back EXTERNBERT token for ar0700mp_dp and ar0700db_dp targets.
20011 +//* Disabled EXTERNBERT for debug target since it is not supported on the
20012 +//* FPGA platform.
20013 +//* 02/21/2003 A. Redfern Turned off OAM_EOC, AOC and BITSWAP (until memory issues are resolved).
20014 +//* Turned on DUAL_TEQ, PHY_PATH_ENABLE and PHY_EC_ENABLE.
20015 +//* 02/21/2003 D. Mannering Added DEBUG_DUMP.
20016 +//* 03/06/2003 J. Bergsagel Cleaned up tokens for each target and switched diag targets
20017 +//* over to the Sangam platform (instead of the FPGA platform).
20018 +//* 03/07/2003 J. Bergsagel Cleaned up TC and BERT tokens
20019 +//* 03/11/2003 J. Bergsagel Turned on AOC and BITSWAP for Sangam POTS and ISDN targets.
20020 +//* 03/20/2003 Mallesh Added SHALF token.
20021 +//* 03/24/2003 F. Mujica Enable hybrid selection
20022 +//* 03/26/2003 A. Redfern Removed PMEMSAVE_GHS (always = 1).
20023 +//* 04/08/2003 F. Mujica Renamed HYBRID_SWITCH token to PHY_HYB_ENABLE
20024 +//* 04/08/2003 J. Bergsagel Turned off PHY_HYB_ENABLE for _debug targets (FPGA board builds)
20025 +//* 04/09/2003 J. Bergsagel Turned on OLAYDP only for ar0700mp and ar0700db.
20026 +//* Turned on AOC, BITSWAP, and OAM_EOC for ar0700mp and ar0700db.
20027 +//* 04/09/2003 J. Bergsagel Corrected name "PHY_HYB_SELECT" to "PHY_HYB_ENABLE"
20028 +//* 04/15/2003 A. Redfern Turned on ECI_PULSECOM_INTEROP because phase optimization was enabled.
20029 +//* 05/05/2003 D. Mannering Review Comments - turn on AOC, EXTERNBERT, SHALF, for ar0700mp; amd
20030 +//* turn on AOC for ar0700db
20031 +//* 05/11/2003 Prashant S Added DMT_BIS token for AR7 Soft DI work
20032 +//* 05/13/2003 J. Bergsagel Turned on IMPROVED_STAT_SUPPORT_06_03_00 by default for necessary statistics
20033 +//* 05/15/2003 J. Bergsagel Turned off CO_PROFILE for diag targets.
20034 +//* 05/27/2003 U.Dasgupta Added NLNOISEADJSNR_EC token for ISDN - to take care of non-linear noise
20035 +//* (from ISDN splitter) compensation.
20036 +//* 06/02/2003 Z. Yang Added PHY_NDIAG_ENABLE token.
20037 +//* 06/02/2003 Z. Yang Added COMB_LINEDIAG_ENABLE token.
20038 +//* 06/05/2003 P. Hunt Turned on ATUC_CLEARDOWN_CHANGE token for all targets.
20039 +//* 06/05/2003 Mallesh Turned on CENTILLIUM_VENDORID_AND_TXRATE_CHNG to enable logging the vendor ID
20040 +//* for centillium and litespan
20041 +//* 06/05/2003 U.Dasgupta Turned on SHALF token for ISDN.
20042 +//* 06/06/2003 U.Dasgupta Turned on G.hs nonstandard field token for ar0700db target.
20043 +//* 06/12/2003 J. Bergsagel Changed *_debug targets to be for JTAG=1 instead of FPGA targets
20044 +//* IMPORTANT: For non-JTAG cases, "JTAG" should be undefined.
20045 +//* Therefore, "JTAG" should not have a default case at the bottom (JTAG 0)
20046 +//* 06/18/2003 A. Redfern Turned on spectral shaping token for all targets.
20047 +//* 06/23/2003 J. Bergsagel Turned off GHS_NON_STD_FIELD token for ar0700db until bugs are fixed.
20048 +//* 06/23/2003 U G Jani Undid the above change since the bug is fixed.
20049 +//* 06/27/2003 Mallesh Removed all the interop tokens which are no longer required.
20050 +//* 08/20/2003 J. Bergsagel Added default value for OVHD_PMDTEST_PARA and put default section
20051 +//* tokens in alphabetical order.
20052 +//* 10/09/2003 Hanyu Liu Defined token ADSL2_1BIT_TONE to support Rx one bit constellation.
20053 +//* 10/12/2003 Hanyu Liu Defined token ADSL2_BSWP for bitswap.
20054 +//* 10/20/2003 Xiaohui Li Added READSL2_ENABLE token.
20055 +//* 12/01/2003 Seungmok Oh Added TXDF2B_PROFILING token, which is active only for POTS target.
20056 +//* 12/09/2003 Jack Huang Turned on GHS_NON_STD_FIELD support for AR7 POTS targets
20057 +//* 12/16/2003 Mustafa T. Added the necessary definitions for diag target.
20058 +//*****************************************************************************************************
20060 +//* The default flag settings are:
20062 +//* -dATUC=1 -dSTD=0 -dISDN=0 -dTIPCI=0 -dTID=0 -dTII=0 -dAI=0
20063 +//* -dEVM2=0 -dEU=0 -dSL=0 -dSL_EVM=1 -dGLITE=0
20065 +//* and are set after all the per-suffix options have had a chance to
20066 +//* set them. Each flag is only set if it has not previously been set, so
20067 +//* per-suffix settings can override defaults, and command-line defines can
20068 +//* override per-suffix settings.
20070 +//*****************************************************************************
20073 +//* ===========================================================================
20075 +//* The command-line can include -dOBJSFX_xxx to get a flag set
20076 +//* instead of explicitly setting each flag on each CC/ASM command-line.
20077 +//* and the object suffix will control the settings of "feature" constants.
20078 +//* ===========================================================================
20080 +//* ===========================================================================
20081 +// Flag settings for new suffixes (in alphabetical order of suffix)
20082 +// Each suffix has to specify only those flags which differ from the
20083 +// default settings.
20084 +//* ===========================================================================
20085 +// NOTE: Try to keep feature flags in alphabetical order to ease maintenance.
20086 +//* ===========================================================================
20089 +#define CHIPSET_ID_UNKN '?'
20090 +#define CHIPSET_ID_AH 'H'
20091 +#define CHIPSET_ID_AP 'P'
20092 +#define CHIPSET_ID_AR 'R'
20093 +#define CHIPSET_ID_ARV 'R'
20094 +#define CHIPSET_ID_AT 'T'
20095 +#define CHIPSET_ID_AU 'U'
20097 +#define CHIPSET_ID2_GENERIC '0'
20098 +#define CHIPSET_ID2_ARV 'R'
20100 + #define DSPDP_IMAGE_ID_STANDARD(code) ( \
20101 + STANDARD_is_MULTIMODE(code) ? "M" : \
20102 + STANDARD_is_GDMT(code) ? "D" : \
20103 + STANDARD_is_GLITE(code) ? "L" : \
20104 + STANDARD_is_T1413(code) ? "T" : "_")
20106 + #define DSPDP_IMAGE_ID_SERVICE(code) ( \
20107 + SERVICE_is_POTS(code) ? "P" : \
20108 + SERVICE_is_ISDN_ANNEXB(code) ? "B" : \
20109 + SERVICE_is_ISDN_ANNEXC(code) ? "C" : \
20110 + SERVICE_is_ISDN_PROP(code) ? "I" : "")
20112 +// Bit-codes for feature byte in new version.
20116 +// |||| |||+ -- POTS
20117 +// |||| ||+---- ISDN_ANNEXB
20118 +// |||| |+----- ISDN_ANNEXC
20119 +// |||| +------ ISDN_PROP
20121 +// ||+--------- GHS
20122 +// |+---------- GLITE
20123 +// +----------- T1413
20126 +#define FEATURE_BIT_T1413 0x80
20127 +#define FEATURE_BIT_GLITE 0x40
20128 +#define FEATURE_BIT_GHS 0x20
20129 +#define FEATURE_BIT_ISDN_PROP 0x08
20130 +#define FEATURE_BIT_ISDN_ANNEXC 0x04
20131 +#define FEATURE_BIT_ISDN_ANNEXB 0x02
20132 +#define FEATURE_BIT_POTS 0x01
20134 +#define STANDARD_BITS_MASK (FEATURE_BIT_T1413 | FEATURE_BIT_GLITE | FEATURE_BIT_GHS)
20135 +#define STANDARD_BITS_T1413 FEATURE_BIT_T1413
20136 +#define STANDARD_BITS_GHS FEATURE_BIT_GHS
20137 +#define STANDARD_BITS_GLITE (FEATURE_BIT_GLITE | FEATURE_BIT_GHS)
20138 +#define STANDARD_BITS_GDMT (STANDARD_BITS_T1413 | STANDARD_BITS_GHS)
20139 +#define STANDARD_BITS_MULTIMODE (STANDARD_BITS_T1413 | STANDARD_BITS_GLITE | STANDARD_BITS_GDMT)
20141 +#define SERVICE_BIT_ISDN_ANNEXB FEATURE_BIT_ISDN_ANNEXB
20142 +#define SERVICE_BIT_ISDN_ANNEXC FEATURE_BIT_ISDN_ANNEXC
20143 +#define SERVICE_BIT_ISDN_PROP FEATURE_BIT_ISDN_PROP
20144 +#define SERVICE_BIT_POTS FEATURE_BIT_POTS
20147 +// Debug new-style suffixes
20151 +#if defined(OBJSFX_ar0700db_debugobj)
20152 +#ifndef OBJSFX_ar0700dbobj
20153 +#define OBJSFX_ar0700dbobj 1
20155 +// Here, in alphabetic order, are the feature tokens that
20156 +// distinguish this suffix from its non-_debug partner:
20157 +// (All other tokens from the non-_debug partner that are non-conflicting will also be picked up)
20163 +#elif defined(OBJSFX_ar0700mp_debugobj)
20164 +#ifndef OBJSFX_ar0700mpobj
20165 +#define OBJSFX_ar0700mpobj 1
20167 +// Here, in alphabetic order, are the feature tokens that
20168 +// distinguish this suffix from its non-_debug partner:
20169 +// (All other tokens from the non-_debug partner that are non-conflicting will also be picked up)
20171 +#ifndef ADSL2_BSWP
20172 +#define ADSL2_BSWP 1
20180 +#ifndef DEBUG_ADSL2
20181 +#define DEBUG_ADSL2 0
20184 +#define DEBUG_LOG 0
20186 +#ifndef GHS_NON_STD_FIELD
20187 +#define GHS_NON_STD_FIELD 1
20192 +#endif // end of the series of "#elif defined" for debug targets
20196 +// Standard new-style suffixes for operational and mfgr'ing diag.
20199 +#if defined(OBJSFX_ar0700dbobj)
20200 +#define CHIPSET_AR07 1
20201 +#define PLATFORM_AR0700 1
20202 +#define DSPDP_CHIPSET_ID CHIPSET_ID_AR
20203 +#define DSPDP_CHIPSET_ID2 CHIPSET_ID2_GENERIC
20204 +#define DSPDP_CHIPSET_GEN 7
20205 +#define DSPDP_HARDWARE_REV1 '0'
20206 +#define DSPDP_HARDWARE_REV2 '0'
20207 +#define DSPDP_FEATURE_CODE (STANDARD_BITS_GDMT|SERVICE_BIT_ISDN_ANNEXB)
20211 +// ATM_TC_HW and SWTC are mutually exclusive
20213 +#define ATM_TC_HW 1
20221 +#ifndef EXTERNBERT
20222 +#define EXTERNBERT 0
20224 +#ifndef GHS_NON_STD_FIELD
20225 +#define GHS_NON_STD_FIELD 1
20227 +#ifndef MARGIN_DELTA_RETRAIN
20228 +#define MARGIN_DELTA_RETRAIN 0
20230 +#ifndef NLNOISEADJSNR_EC
20231 +#define NLNOISEADJSNR_EC 1
20241 +#elif defined(OBJSFX_ar0700db_diagobj)
20242 +#define CHIPSET_AR07 1
20243 +#define PLATFORM_AR0700 1
20244 +#define DSPDP_CHIPSET_ID CHIPSET_ID_AR
20245 +#define DSPDP_CHIPSET_ID2 CHIPSET_ID2_GENERIC
20246 +#define DSPDP_CHIPSET_GEN 7
20247 +#define DSPDP_HARDWARE_REV1 '0'
20248 +#define DSPDP_HARDWARE_REV2 '0'
20249 +#define DSPDP_FEATURE_CODE (STANDARD_BITS_GDMT|SERVICE_BIT_ISDN_ANNEXB)
20253 +// ATM_TC_HW and SWTC are mutually exclusive (or both must be off)
20255 +#define ATM_TC_HW 0
20263 +#ifndef CO_PROFILE
20264 +#define CO_PROFILE 0
20266 +#ifndef MARGIN_DELTA_RETRAIN
20267 +#define MARGIN_DELTA_RETRAIN 0
20270 +#define MFGR_DIAG 1
20278 +#ifndef SNR_UPDATE
20279 +#define SNR_UPDATE 0
20282 +#elif defined(OBJSFX_ar0700mpobj)
20283 +#define CHIPSET_AR07 1
20284 +#define PLATFORM_AR0700 1
20285 +#define DSPDP_CHIPSET_ID CHIPSET_ID_AR
20286 +#define DSPDP_CHIPSET_ID2 CHIPSET_ID2_GENERIC
20287 +#define DSPDP_CHIPSET_GEN 7
20288 +#define DSPDP_HARDWARE_REV1 '0'
20289 +#define DSPDP_HARDWARE_REV2 '0'
20290 +#define DSPDP_FEATURE_CODE (STANDARD_BITS_MULTIMODE|SERVICE_BIT_POTS)
20294 +// ATM_TC_HW and SWTC are mutually exclusive
20295 +#ifndef ADSL2_1BIT_TONE
20296 +#define ADSL2_1BIT_TONE 0
20298 +#ifndef ADSL2_BSWP
20299 +#define ADSL2_BSWP 1
20302 +#define ATM_TC_HW 1
20310 +#ifndef EXTERNBERT
20311 +#define EXTERNBERT 0
20325 +#ifndef DS_LOOP_BACK
20326 +#define DS_LOOP_BACK 0
20328 +#ifndef LOOP_BACK_DEBUG
20329 +#define LOOP_BACK_DEBUG 0
20331 +#ifndef US_LOOP_BACK
20332 +#define US_LOOP_BACK 0
20334 +#ifndef OVHD_PMDTEST_PARA
20335 +#define OVHD_PMDTEST_PARA 0
20337 +#ifndef DS_RX_CODEWORD
20338 +#define DS_RX_CODEWORD 1
20340 +#ifndef READSL2_ENABLE
20341 +#define READSL2_ENABLE 1
20343 +#ifndef GHS_NON_STD_FIELD
20344 +#define GHS_NON_STD_FIELD 1
20347 +#elif defined(OBJSFX_ar0700mp_diagobj)
20348 +#define CHIPSET_AR07 1
20349 +#define PLATFORM_AR0700 1
20350 +#define DSPDP_CHIPSET_ID CHIPSET_ID_AR
20351 +#define DSPDP_CHIPSET_ID2 CHIPSET_ID2_GENERIC
20352 +#define DSPDP_CHIPSET_GEN 7
20353 +#define DSPDP_HARDWARE_REV1 '0'
20354 +#define DSPDP_HARDWARE_REV2 '0'
20355 +#define DSPDP_FEATURE_CODE (STANDARD_BITS_MULTIMODE|SERVICE_BIT_POTS)
20356 +#ifndef ADSL2_BSWP
20357 +#define ADSL2_BSWP 0
20362 +// ATM_TC_HW and SWTC are mutually exclusive (or both must be off)
20364 +#define ATM_TC_HW 0
20372 +#ifndef CO_PROFILE
20373 +#define CO_PROFILE 0
20378 +#ifndef MARGIN_DELTA_RETRAIN
20379 +#define MARGIN_DELTA_RETRAIN 0
20382 +#define MFGR_DIAG 1
20390 +#ifndef SNR_UPDATE
20391 +#define SNR_UPDATE 0
20393 +#ifndef US_CRC_RETRAIN
20394 +#define US_CRC_RETRAIN 0
20396 +#ifndef ADSL2_BSWP
20397 +#define ADSL2_BSWP 0
20402 +#ifndef DS_RX_CODEWORD
20403 +#define DS_RX_CODEWORD 0
20407 +#define DSPDP_CHIPSET_ID CHIPSET_ID_UNKN
20408 +#define DSPDP_CHIPSET_ID2 CHIPSET_ID2_GENERIC
20409 +#define DSPDP_CHIPSET_GEN 0
20410 +#define DSPDP_HARDWARE_REV1 '0'
20411 +#define DSPDP_HARDWARE_REV2 '0'
20412 +#define DSPDP_FEATURE_CODE 0
20415 +// For use in checking the code in drivers -- indented to avoid .h->.ah
20416 + #define STANDARD_is_T1413(code) (!(((code) & STANDARD_BITS_MASK) ^ STANDARD_BITS_T1413))
20417 + #define STANDARD_is_GLITE(code) (!(((code) & STANDARD_BITS_MASK) ^ STANDARD_BITS_GLITE))
20418 + #define STANDARD_is_GHS(code) (((code) & STANDARD_BITS_MASK) & STANDARD_BITS_GHS)
20419 + #define STANDARD_is_GDMT(code) (!(((code) & STANDARD_BITS_MASK) ^ (STANDARD_BITS_T1413 | STANDARD_BITS_GHS)))
20420 + #define STANDARD_is_MULTIMODE(code) (!(((code) & STANDARD_BITS_MASK) ^ (STANDARD_BITS_T1413 | STANDARD_BITS_GLITE | STANDARD_BITS_GDMT)))
20421 + #define SERVICE_is_POTS(code) ((code) & SERVICE_BIT_POTS)
20422 + #define SERVICE_is_ISDN_ANNEXB(code) ((code) & SERVICE_BIT_ISDN_ANNEXB)
20423 + #define SERVICE_is_ISDN_ANNEXC(code) ((code) & SERVICE_BIT_ISDN_ANNEXC)
20424 + #define SERVICE_is_ISDN_PROP(code) ((code) & SERVICE_BIT_ISDN_PROP)
20426 +#define STANDARD_T1413 (!((DSPDP_FEATURE_CODE & STANDARD_BITS_MASK) ^ STANDARD_BITS_T1413))
20427 +#define STANDARD_GLITE (!((DSPDP_FEATURE_CODE & STANDARD_BITS_MASK) ^ STANDARD_BITS_GLITE))
20428 +#define STANDARD_GHS ((DSPDP_FEATURE_CODE & STANDARD_BITS_MASK) & STANDARD_BITS_GHS)
20429 +#define STANDARD_GDMT (!((DSPDP_FEATURE_CODE & STANDARD_BITS_MASK) ^ (STANDARD_BITS_T1413 | STANDARD_BITS_GHS)))
20430 +#define STANDARD_MULTIMODE (!((DSPDP_FEATURE_CODE & STANDARD_BITS_MASK) ^ (STANDARD_BITS_T1413 | STANDARD_BITS_GLITE | STANDARD_BITS_GDMT)))
20432 +#define SERVICE_POTS (DSPDP_FEATURE_CODE & SERVICE_BIT_POTS)
20433 +#define SERVICE_ISDN_ANNEXB (DSPDP_FEATURE_CODE & SERVICE_BIT_ISDN_ANNEXB)
20434 +#define SERVICE_ISDN_ANNEXC (DSPDP_FEATURE_CODE & SERVICE_BIT_ISDN_ANNEXC)
20435 +#define SERVICE_ISDN_PROP (DSPDP_FEATURE_CODE & SERVICE_BIT_ISDN_PROP)
20436 +#define SERVICE_ISDN (SERVICE_ISDN_ANNEXB | SERVICE_ISDN_ANNEXC | SERVICE_ISDN_PROP)
20440 +// Backwards compatibility with old tokens
20443 +#if (SERVICE_POTS)
20449 +#if (SERVICE_ISDN_ANNEXB | SERVICE_ISDN_PROP)
20457 +//* ===========================================================================
20458 +// More Default settings
20459 +//* ===========================================================================
20463 +// BEGIN Could automatically generate showdefs code
20474 +// ATM_TC_HW and SWTC are mutually exclusive
20476 +#define ATM_TC_HW 1
20479 +#ifndef ATMBERT_HW
20480 +#define ATMBERT_HW 1
20485 +#else // else case for #if ATM_TC_HW
20486 +#ifndef ATMBERT_HW
20487 +#define ATMBERT_HW 0
20492 +#endif // end of #if ATM_TC_HW
20493 +#ifndef ATM_TC_PATH1_ON
20494 +#define ATM_TC_PATH1_ON 0
20499 +#ifndef COMB_LINEDIAG_ENABLE
20500 +#define COMB_LINEDIAG_ENABLE 0
20503 +#define CODEC_EMU 0
20505 +#ifndef CO_PROFILE
20506 +#define CO_PROFILE 1
20511 +#ifndef DEBUG_ADSL2
20512 +#define DEBUG_ADSL2 0
20514 +#ifndef DEBUG_DUMP
20515 +#define DEBUG_DUMP 0
20518 +#define DEBUG_LOG 0
20521 +#define DEV_DEBUG 0
20523 +#ifndef DS_LOOP_BACK
20524 +#define DS_LOOP_BACK 0
20526 +#ifndef DS_RX_CODEWORD
20527 +#define DS_RX_CODEWORD 1
20529 +#ifndef LOOP_BACK_DEBUG
20530 +#define LOOP_BACK_DEBUG 0
20532 +#ifndef US_LOOP_BACK
20533 +#define US_LOOP_BACK 0
20536 +#define DPLL_MODE 0
20539 +#define DSPBIOSII 0
20544 +#ifndef ADSL2_1BIT_TONE
20545 +#define ADSL2_1BIT_TONE 0
20547 +#ifndef ADSL2_BSWP
20548 +#define ADSL2_BSWP 1
20553 +#ifndef DS_PWR_CUTBACK
20554 +#define DS_PWR_CUTBACK 0
20557 +#define DUAL_TEQ 1
20559 +#ifndef EXTERNBERT
20560 +#define EXTERNBERT 0
20571 +#ifndef ISDN_DEBUG
20572 +#define ISDN_DEBUG 0
20575 +#define LINE_DIAG 1
20577 +#ifndef LOOP_BACK_DEBUG
20578 +#define LOOP_BACK_DEBUG 0
20580 +#ifndef MANUFACTURING_TESTS
20581 +#define MANUFACTURING_TESTS 0
20583 +#ifndef MARGIN_DELTA_RETRAIN
20584 +#define MARGIN_DELTA_RETRAIN 1
20590 +#define MFGR_DIAG 0
20592 +#ifndef NLNOISEADJSNR
20593 +#define NLNOISEADJSNR 0
20595 +#ifndef NLNOISEADJSNR_EC
20596 +#define NLNOISEADJSNR_EC 0
20599 +#define NTR_MODE 0
20607 +#ifndef OLAYDP_EMIF
20608 +#define OLAYDP_EMIF 0
20610 +#ifndef OLAYDP_2STEP
20611 +#define OLAYDP_2STEP 0
20613 +#ifndef OLAYDP_PCI
20614 +#define OLAYDP_PCI 0
20619 +#ifndef OVHD_PMDTEST_PARA
20620 +#define OVHD_PMDTEST_PARA 0
20622 +#ifndef PERTONE_EQ
20623 +#define PERTONE_EQ 0
20625 +#ifndef PHY_EC_ENABLE
20626 +#define PHY_EC_ENABLE 1
20628 +#ifndef PHY_HYB_ENABLE
20629 +#define PHY_HYB_ENABLE 1
20631 +#ifndef PHY_NDIAG_ENABLE
20632 +#define PHY_NDIAG_ENABLE 0
20634 +#ifndef PHY_PATH_ENABLE
20635 +#define PHY_PATH_ENABLE 1
20637 +#ifndef PHY_TDW_ENABLE
20638 +#define PHY_TDW_ENABLE 0
20640 +#ifndef TC_ATM_PCIMASTER
20641 +#define TC_ATM_PCIMASTER 0
20643 +#ifndef SEPARATE_TX_RX_BUFFERS
20644 +#define SEPARATE_TX_RX_BUFFERS 0
20649 +#ifndef SPECTRAL_SHAPING
20650 +#define SPECTRAL_SHAPING 1
20652 +#ifndef SNR_UPDATE
20653 +#define SNR_UPDATE 1
20656 +#define TC_DEBUG 0
20658 +#ifndef TC_LOOPBACK
20659 +#define TC_LOOPBACK 0
20662 +#define TESTMODE 0
20667 +#ifndef TXDF2B_PROFILING
20668 +#if (SERVICE_POTS & (!MFGR_DIAG) & (CO_PROFILE))
20669 +#define TXDF2B_PROFILING 1
20671 +#define TXDF2B_PROFILING 0
20674 +#ifndef US_CRC_RETRAIN
20675 +#define US_CRC_RETRAIN 1
20677 +#ifndef US_LOOP_BACK
20678 +#define US_LOOP_BACK 0
20683 +#ifndef READSL2_ENABLE
20684 +#define READSL2_ENABLE 1
20688 +#ifndef GHS_NON_STD_FIELD
20689 +#define GHS_NON_STD_FIELD 0
20691 +#ifndef LUCENT_ANYMEDIA_ENIATT_INTEROP
20692 +#define LUCENT_ANYMEDIA_ENIATT_INTEROP 0
20697 +// END Could automatically generate showdefs code
20699 +#if DSPDP_FEATURE_CODE
20701 +// Unrecognized_suffix____check_spelling
20704 +// LNK_CMD is set when running CPP to generate lnk_cpe.cmd file
20705 +// -- the linker is not happy when it sees C code show up in the
20709 +extern int compile_happy; // Keep the compiler from complaining about an empty file
20714 diff -urN linux.old/drivers/atm/sangam_atm/env_def_typedefs.h linux.dev/drivers/atm/sangam_atm/env_def_typedefs.h
20715 --- linux.old/drivers/atm/sangam_atm/env_def_typedefs.h 1970-01-01 01:00:00.000000000 +0100
20716 +++ linux.dev/drivers/atm/sangam_atm/env_def_typedefs.h 2005-07-10 08:02:01.447110904 +0200
20718 +#ifndef __ENV_DEF_TYPEDEFS_H__
20719 +#define __ENV_DEF_TYPEDEFS_H__ 1
20721 +/*******************************************************************************
20722 +* FILE PURPOSE: Define data types for C and TMS320C6x C compilers
20723 +********************************************************************************
20725 +* FILE NAME: dpsys_typedefs.h
20728 +* This file contains the main typedefs that we need.
20732 +* 03/11/97 Bob Lee Created
20733 +* 03/13/97 Chishtie
20734 +* 03/14/97 Bob Lee Format change to meet "Engineering Model
20735 +* - System Architucture Specification"
20736 +* Rev AP3. Jan. 29, 1997
20737 +* 07/21/00 Barnett Moved many common typedefs from
20738 +* host i/f header file to here.
20739 +* 03/30/01 Barnett Mod's per driver team feedback.
20740 +* Some tokens cannot be def'ed
20741 +* if _WINDEF_ is def'ed.
20742 +* 04/05/01 Barnett Added DSPDP_ prefix to tokens that originate
20743 +* in the public interface.
20744 +* 06/01/01 J. Bergsagel Modified to add standard typedefs
20745 +* 07/25/01 J. Bergsagel Changed name from typedefs.h to dpsys_typedefs.h
20746 +* 07/30/01 J. Bergsagel Moved typedefs that were conflicting with Windows
20747 +* driver software to the "#ifndef _WINDEF_" section.
20748 +* 08/09/01 S. Yim Moved FALSE/TRUE definitions from ctl_interface_u.h
20749 +* (conflict with BIOS/std.h)
20750 +* 09/03/01 S. Yim Do not include typedef char and float if _STD defined
20751 +* (conflict with BIOS/std.h)
20752 +* 01/21/03 MCB Implemented Ax7 UNIT-MODULE modular software framework.
20753 +* 03/20/03 Mallesh Defined size of basic variables
20754 +* 03/27/03 F. Mujica Added SINT40 and UINT40 definitions.
20756 +* (C) Copyright Texas Instruments Inc. 1997-2001. All rights reserved.
20757 +*******************************************************************************/
20759 +// Common type definitions
20761 +// Basic constants needed everywhere
20767 +// Read-Write Data Types
20768 +typedef signed char SINT8; // Signed 8-bit integer (7-bit magnitude)
20769 +typedef unsigned char UINT8; // Unsigned 8-bit integer
20770 +typedef signed short SINT16; // Signed 16-bit integer (15-bit magnitude)
20771 +typedef unsigned short UINT16; // Unsigned 16-bit integer
20772 +typedef signed int SINT32; // Signed 32-bit integer (31-bit magnitude)
20773 +typedef unsigned int UINT32; // Unsigned 32-bit integer
20774 +typedef long signed int SINT40; // Long signed 40-bit integer
20775 +typedef long unsigned int UINT40; // Long unsigned 40-bit integer
20777 +// All pointers are 32 bits long
20778 +typedef SINT8 *PSINT8; // Pointer to SINT8
20779 +typedef UINT8 *PUINT8; // Pointer to UINT8
20780 +typedef SINT16 *PSINT16; // Pointer to SINT16
20781 +typedef UINT16 *PUINT16; // Pointer to UINT16
20782 +typedef SINT32 *PSINT32; // Pointer to SINT32
20783 +typedef UINT32 *PUINT32; // Pointer to UINT32
20785 +#define SIZEOF_SINT8 1
20786 +#define SIZEOF_UINT8 1
20787 +#define SIZEOF_SINT16 2
20788 +#define SIZEOF_UINT16 2
20789 +#define SIZEOF_SINT32 4
20790 +#define SIZEOF_UINT32 4
20791 +#define SIZEOF_SINT40 8
20792 +#define SIZEOF_UINT40 8
20794 +// Size of Read-Write Data Types - in bytes
20795 +#define SIZEOF_char 1
20796 +#define SIZEOF_Int8 1
20797 +#define SIZEOF_UChar 1
20798 +#define SIZEOF_UInt8 1
20799 +#define SIZEOF_Float 4
20800 +#define SIZEOF_Double 8
20801 +#define SIZEOF_byte 1
20803 +// Read-Only Data Types - should be only used for ROM code
20804 +typedef const char CharRom; // 8 bit signed character
20805 +typedef const signed char Int8Rom; // 8 bit signed integer
20806 +typedef const unsigned char UCharRom; // 8 bit unsigned character
20807 +typedef const unsigned char UInt8Rom; // 8 bit unsigned integer
20808 +typedef const float FloatRom; // IEEE 32-bit
20809 +typedef const double DoubleRom; // IEEE 64-bit
20813 +// Read-Write Data Types
20814 +typedef signed char Int8; // 8 bit signed integer
20815 +typedef unsigned char UChar; // 8 bit unsigned character
20816 +typedef unsigned char UInt8; // 8 bit unsigned integer
20818 +typedef char Char; // 8 bit signed character
20819 +typedef float Float; // IEEE 32-bit
20821 +typedef double Double; // IEEE 64-bit
20822 +typedef signed char byte; // 8 bit signed integer
20825 +// These typedefs collide with those in Win2k DDK inc\WINDEF.H
20827 +// common type definition
20828 +typedef unsigned char BYTE; // 8-bit
20829 +typedef signed short SHORT; // 16-bit signed
20830 +typedef unsigned short WORD; // 16-bit
20831 +typedef unsigned int DWORD; // 32-bit, TI DSP has 40 bit longs
20833 +// All pointers are 32 bits long
20834 +typedef BYTE *PBYTE; // pointer to 8 bit data
20835 +typedef unsigned char *PCHAR; // pointer to 8 bit data
20836 +typedef SHORT *PSHORT; // pointer to 16 bit data
20837 +typedef WORD *PWORD; // pointer to 16 bit data
20838 +typedef DWORD *PDWORD; // pointer to 32 bit data
20840 +#endif // #ifndef _WINDEF_
20843 +#define SIZEOF_BYTE 1
20844 +#define SIZEOF_SHORT 2
20845 +#define SIZEOF_WORD 2
20846 +#define SIZEOF_DWORD 4
20847 +#define SIZEOF_PCHAR 4
20848 +#define SIZEOF_PWORD 4
20849 +#define SIZEOF_PDWORD 4
20851 +// Size of Read-Only Data Types - in bytes
20852 +#define SIZEOF_CharRom 1
20853 +#define SIZEOF_Int8Rom 1
20854 +#define SIZEOF_UCharRom 1
20855 +#define SIZEOF_UInt8Rom 1
20856 +#define SIZEOF_FloatRom 4
20857 +#define SIZEOF_DoubleRom 8
20859 +#define SIZEOF_complex_byte (2*SIZEOF_byte)
20860 +#define SIZEOF_PTR_complex_byte 4
20864 +} complex_byte, *PTR_complex_byte;
20866 +#define SIZEOF_complex_short 4
20867 +#define SIZEOF_PTR_complex_short 4
20871 +} complex_short, *PTR_complex_short;
20873 +#define SIZEOF_complex_int 8
20874 +#define SIZEOF_PTR_complex_int 4
20878 +} complex_int, *PTR_complex_int;
20882 + unsigned int low;
20890 +#define SIZEOF_PVOID 4
20891 +typedef void *PVOID; // pointer to void
20893 +//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
20895 +#if defined(_TMS320C6X) // TMS320C6xx type definitions
20897 +// Read-Write Data Types
20898 +typedef short Int16; // 16 bit signed integer
20899 +typedef unsigned short UInt16; // 16 bit unsigned integer
20900 +typedef int Int32; // 32 bit signed integer
20901 +typedef unsigned int UInt32; // 32 bit unsigned signed integer
20902 +typedef long Long40; // 40 bit signed integer
20903 +typedef unsigned long ULong40; // 40 bit unsigned signed integer
20905 +// Size of Read-Write Data Types - in bytes
20906 +#define SIZEOF_Int16 2
20907 +#define SIZEOF_UInt16 2
20908 +#define SIZEOF_Int32 4
20909 +#define SIZEOF_UInt32 4
20910 +#define SIZEOF_Long40 5
20911 +#define SIZEOF_ULong40 5
20913 +// Read-Only Data Types - should be only used for ROM code
20914 +typedef const short Int16Rom; // 16 bit signed integer
20915 +typedef const unsigned short UInt16Rom; // 16 bit unsigned integer
20916 +typedef const int Int32Rom; // 32 bit signed integer
20917 +typedef const unsigned int UInt32Rom; // 32 bit unsigned signed integer
20918 +typedef const long Long40Rom; // 40 bit signed integer
20919 +typedef const unsigned long ULong40Rom; // 40 bit unsigned signed integer
20921 +// Size of Read-Only Data Types - in bytes
20922 +#define SIZEOF_Int16Rom 2
20923 +#define SIZEOF_UInt16Rom 2
20924 +#define SIZEOF_Int32Rom 4
20925 +#define SIZEOF_UInt32Rom 4
20926 +#define SIZEOF_Long40Rom 5
20927 +#define SIZEOF_ULong40Rom 5
20929 +#else // 32 bits PC Host type definitions
20931 +// Read-Write Data Types
20932 +typedef short Int16; // 16 bit signed integer
20933 +typedef unsigned short UInt16; // 16 bit unsigned integer
20934 +typedef int Int32; // 32 bit signed integer
20935 +typedef unsigned int UInt32; // 32 bit unsigned integer
20937 +// Read-Only Data Types - should be only used for ROM code
20938 +typedef const short Int16Rom; // 16 bit signed integer
20939 +typedef const unsigned short UInt16Rom; // 16 bit unsigned integer
20940 +typedef const int Int32Rom; // 32 bit signed integer
20941 +typedef const unsigned int UInt32Rom; // 32 bit unsigned integer
20946 diff -urN linux.old/drivers/atm/sangam_atm/Makefile linux.dev/drivers/atm/sangam_atm/Makefile
20947 --- linux.old/drivers/atm/sangam_atm/Makefile 1970-01-01 01:00:00.000000000 +0100
20948 +++ linux.dev/drivers/atm/sangam_atm/Makefile 2005-07-10 08:02:01.448110752 +0200
20950 +# File: drivers/net/avalanche_cpmac/Makefile
20952 +# Makefile for the Linux network (CPMAC) device drivers.
20956 +O_TARGET := tiatm.o
20957 +obj-$(CONFIG_MIPS_SANGAM_ATM) += tiatm.o
20958 +list-multi := tiatm.o
20960 +tiatm-objs := tn7atm.o tn7dsl.o tn7sar.o dsl_hal_api.o dsl_hal_support.o cpsar.o aal5sar.o
20962 +EXTRA_CFLAGS += -DEL -I$(TOPDIR)/drivers/atm/sangam_atm -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
20965 +EXTRA_CFLAGS += -DANNEX_B -DB
20968 +EXTRA_CFLAGS += -DANNEX_C -DC
20970 +EXTRA_CFLAGS += -DANNEX_A -DP
20975 +include $(TOPDIR)/Rules.make
20977 +tiatm.o: $(tiatm-objs)
20978 + $(LD) -r -o $@ $(tiatm-objs)
20980 +#avalanche_cpmac.o: $(avalanche_cpmac-objs)
20981 +# $(LD) -r -o $@ $(avalanche_cpmac-objs)
20984 + rm -f core *.o *.a *.s
20985 diff -urN linux.old/drivers/atm/sangam_atm/queue.h linux.dev/drivers/atm/sangam_atm/queue.h
20986 --- linux.old/drivers/atm/sangam_atm/queue.h 1970-01-01 01:00:00.000000000 +0100
20987 +++ linux.dev/drivers/atm/sangam_atm/queue.h 2005-07-10 08:02:01.448110752 +0200
20990 +#if !defined( __QUEUE_H__ )
20991 +#define __QUEUE_H__
20993 +typedef spinlock_t OS_SPIN_LOCK;
20994 +#define osFreeSpinLock(pLock) while(0)
20995 +void osAcquireSpinLock(OS_SPIN_LOCK *pLock);
20996 +void osReleaseSpinLock(OS_SPIN_LOCK *pLock);
20997 +void osAllocateSpinLock(OS_SPIN_LOCK *pLock);
20999 +//#define osAcquireSpinLock(pLock) spin_lock(pLock)
21000 +//#define osReleaseSpinLock(pLock) spin_unlock(pLock)
21001 +//#define osAllocateSpinLock(pLock) spin_lock_init(pLock)
21004 +typedef struct _TI_LIST_ENTRY {
21005 + struct _TI_LIST_ENTRY *Flink;
21006 + struct _TI_LIST_ENTRY *Blink;
21007 +} TI_LIST_ENTRY, *PTI_LIST_ENTRY, TQE, *PTQE;
21009 +typedef struct _TIATM_LIST_ENTRY
21011 + TI_LIST_ENTRY Link;
21012 +} TIATM_LIST_ENTRY, *PTIATM_LIST_ENTRY;
21014 +//-------------------------------------------------------------------------
21015 +// QueueInitList -- Macro which will initialize a queue to NULL.
21016 +//-------------------------------------------------------------------------
21017 +#define QueueInitList(_L) (_L)->Link.Flink = (_L)->Link.Blink = (PTI_LIST_ENTRY)0;
21019 +//-------------------------------------------------------------------------
21020 +// QueueEmpty -- Macro which checks to see if a queue is empty.
21021 +//-------------------------------------------------------------------------
21022 +#define QueueEmpty(_L) (QueueGetHead((_L)) == (PTIATM_LIST_ENTRY)0)
21024 +//-------------------------------------------------------------------------
21025 +// QueueGetHead -- Macro which returns the head of the queue, but does not
21026 +// remove the head from the queue.
21027 +//-------------------------------------------------------------------------
21028 +#define QueueGetHead(_L) ((PTIATM_LIST_ENTRY)((_L)->Link.Flink))
21030 +#define QueueGetNext(Elem) ((PTIATM_LIST_ENTRY)((Elem)->Link.Flink))
21032 +//-------------------------------------------------------------------------
21033 +// QueuePushHead -- Macro which puts an element at the head of the queue.
21034 +//-------------------------------------------------------------------------
21035 +#define QueuePushHead(_L,_E) \
21036 + if (!((_E)->Link.Flink = (_L)->Link.Flink)) \
21038 + (_L)->Link.Blink = (PTI_LIST_ENTRY)(_E); \
21040 +(_L)->Link.Flink = (PTI_LIST_ENTRY)(_E);
21042 +//-------------------------------------------------------------------------
21043 +// QueueRemoveHead -- Macro which removes the head of the head of queue.
21044 +//-------------------------------------------------------------------------
21045 +#define QueueRemoveHead(_L) \
21047 + PTIATM_LIST_ENTRY ListElem; \
21048 + if (ListElem = (PTIATM_LIST_ENTRY)(_L)->Link.Flink) \
21050 + if(!((_L)->Link.Flink = ListElem->Link.Flink)) \
21051 + (_L)->Link.Blink = (PTI_LIST_ENTRY) 0; \
21055 +//-------------------------------------------------------------------------
21056 +// QueuePutTail -- Macro which puts an element at the tail (end) of the queue.
21057 +//-------------------------------------------------------------------------
21058 +#define QueuePutTail(_L,_E) \
21060 + if ((_L)->Link.Blink) \
21062 + ((PTIATM_LIST_ENTRY)(_L)->Link.Blink)->Link.Flink = (PTI_LIST_ENTRY)(_E); \
21063 + (_L)->Link.Blink = (PTI_LIST_ENTRY)(_E); \
21067 + (_L)->Link.Flink = \
21068 + (_L)->Link.Blink = (PTI_LIST_ENTRY)(_E); \
21070 + (_E)->Link.Flink = (PTI_LIST_ENTRY)0; \
21073 +//-------------------------------------------------------------------------
21074 +// QueuePutTailWithLock -- Macro which puts an element at the tail (end) of
21075 +// the queue, using spin lock.
21076 +//-------------------------------------------------------------------------
21077 +#define QueuePutTailWithLock(_L,_E, pLock) \
21079 + osAcquireSpinLock(pLock); \
21080 + if ((_L)->Link.Blink) \
21082 + ((PTIATM_LIST_ENTRY)(_L)->Link.Blink)->Link.Flink = (PTI_LIST_ENTRY)(_E); \
21083 + (_L)->Link.Blink = (PTI_LIST_ENTRY)(_E); \
21087 + (_L)->Link.Flink = \
21088 + (_L)->Link.Blink = (PTI_LIST_ENTRY)(_E); \
21090 + (_E)->Link.Flink = (PTI_LIST_ENTRY)0; \
21091 + osReleaseSpinLock(pLock); \
21094 +//-------------------------------------------------------------------------
21095 +// QueueGetTail -- Macro which returns the tail of the queue, but does not
21096 +// remove the tail from the queue.
21097 +//-------------------------------------------------------------------------
21098 +#define QueueGetTail(_L) ((PTIATM_LIST_ENTRY)((_L)->Link.Blink))
21100 +//-------------------------------------------------------------------------
21101 +// QueuePopHead -- Macro which will pop the head off of a queue (list), and
21102 +// return it (this differs only from queueremovehead only in
21104 +//-------------------------------------------------------------------------
21105 +#define QueuePopHead(_L) \
21106 +(PTIATM_LIST_ENTRY) (_L)->Link.Flink; QueueRemoveHead(_L);
21108 +#define QueueRemoveTail(_L) \
21110 + PTIATM_LIST_ENTRY ListElem; \
21111 + ListElem = (PTIATM_LIST_ENTRY)(_L)->Link.Flink; \
21112 + if(ListElem == (PTIATM_LIST_ENTRY)(_L)->Link.Blink) \
21114 + (_L)->Link.Flink = (_L)->Link.Blink = (PTI_LIST_ENTRY) 0; \
21118 + while(ListElem->Link.Flink != (PTI_LIST_ENTRY)(_L)->Link.Blink) \
21120 + ListElem = (PTIATM_LIST_ENTRY)ListElem->Link.Flink; \
21122 + (_L)->Link.Blink = (PTI_LIST_ENTRY) ListElem; \
21123 + ListElem->Link.Flink = (PTI_LIST_ENTRY)0; \
21127 +#define QueueRemoveItem(_L, Elem) \
21129 + PTIATM_LIST_ENTRY ListElem; \
21130 + ListElem = (PTIATM_LIST_ENTRY)(_L)->Link.Flink; \
21131 + if(ListElem == Elem) \
21133 + QueueRemoveHead(_L); \
21137 + while(ListElem) \
21139 + if(Elem == (PTIATM_LIST_ENTRY)ListElem->Link.Flink) \
21141 + ListElem->Link.Flink = ((PTIATM_LIST_ENTRY)Elem)->Link.Flink; \
21142 + if(Elem == (PTIATM_LIST_ENTRY)(_L)->Link.Blink) \
21143 + (_L)->Link.Blink = (PTI_LIST_ENTRY) 0; \
21146 + ListElem = (PTIATM_LIST_ENTRY)ListElem->Link.Flink; \
21149 + ((PTIATM_LIST_ENTRY)Elem)->Link.Flink = (PTI_LIST_ENTRY) 0; \
21152 +#define QueuePopTail(_L) \
21153 +((PTIATM_LIST_ENTRY)((_L)->Link.Blink)); QueueRemoveTail(_L);
21156 diff -urN linux.old/drivers/atm/sangam_atm/release.txt linux.dev/drivers/atm/sangam_atm/release.txt
21157 --- linux.old/drivers/atm/sangam_atm/release.txt 1970-01-01 01:00:00.000000000 +0100
21158 +++ linux.dev/drivers/atm/sangam_atm/release.txt 2005-07-10 08:02:01.449110600 +0200
21160 +This is release notes for AR7 Linux ATM driver.
21162 +version 04.02.04.00
21163 +-------------------
21165 +1. Corrected the conditional logic from logical AND to logical OR in the case
21166 + of check for DSL line down condition. This is to fix PPPoA crashing
21167 + problem when DSL line is unplugged.
21169 +version 04.02.03.00
21170 +-------------------
21171 +1. Changed overlay page to static allocation.
21172 +2. Added flag to stop TX during channel closing.
21173 +3. Changed DMA memory allocation back to "GFP_ATOMIC" flag.
21175 +version 04.02.02.00
21176 +-------------------
21177 +1. Changed DMA memory allocation from "GFP_ATOMIC" to "GFP_KERNEL" flag.
21178 +2. Added "DoMask" setting for VBR channel setup.
21180 +version 04.02.01.01
21181 +-------------------
21182 +1. Modified priority check scheme per SPTC request.
21184 +Version 04.02.01.00
21185 +-------------------
21186 +1. Add check to skb->priority to place packets to either normal or priority queue.
21187 +2. Add spin lock to increment and decrement of queued buffer number.
21189 +Version 04.02.00.00
21190 +-------------------
21192 +1. Add MBS and CDVT QoS support for ATM driver.
21193 +2. Add "stop/start queue" for ToS application.
21194 +3. Add Showtime margin retrain based on EOC message.
21195 +4. Add EOC vendor ID customalization logic for Annex B.
21196 +5. Supports D3 datapump.
21198 +Version 04.01.00.00
21199 +-------------------
21200 +Re-release of 04.00.07.00 for D1.1 datapump.
21202 +Version 04.00.07.00
21203 +-------------------
21205 +1. Add marging retrain capability by setting following Adam2 Env.
21206 + setenv enable_margin_retrain 1
21207 + setenv margin_threshold xx, xx is in half db, i.e., 10 means 5db.
21210 +1. New PDSP firmware that fix the F5 OAM cell loopback probelm in Cisco DSLAM.
21212 +Version 04.00.06.00
21213 +-------------------
21214 +1. ATM interrupt pacing is defauted to 2 interrupts/s.
21215 +2. Rx Service MAX changed ftom 16 to 8.
21217 +Version 04.00.05.00
21218 +-------------------
21220 +1. Add Adam2 env to disable the TurboDSL by entering "setenv TurboDSL 0".
21221 +2. Add ability to set interrupt pacing for ATM driver.
21224 +1. Fixed the RFC2684 and CLIP problems for Cisco router.
21225 +2. Fixed LED blinking problem when DSL cable is unplugged.
21226 +3. Fixed problem that "selected mode" is not updated.
21228 +Version 04.00.04.00
21229 +-------------------
21231 +1. Added feature so OAM F5 ping will not require a corresponding PVC channel to
21233 +2. Added timeout value for F5 OAM ping. The new command are "exxxpyyycdzzzt" for
21234 + end-to-end and "sxxxpyyycdzzzt" for segment. "zzz" is timeout value in milli-second.
21235 +3. Added proc entry "avsar_pvc_table" to record received VPIs and VCIs. The format is
21237 + seperated by new line. To search for PVCs, an application can do the following.
21238 + i) Send a (or several) F5 OAM cell on a VPI/VPI pairs with command
21239 + echo exxxpyyycd2t > /proc/sys/dev/dslmod
21240 + ii) Wait >2ms or poll proc entry /proc/avalanche/avsar_oam_ping until the result
21241 + indicates a failure. (It will be failed all the time with 2ms timeout.)
21242 + iii) Repeat above two steps for new VPI/VCI pairs.
21243 + iv) Check proc entry /proc/avalanche/avsar_pvc_table any time for PVCs that responded.
21245 +Version 04.00.03.00
21246 +-------------------
21248 +1. Fixed bug that caused crash when phone cable is unplugged.
21249 +2. Fixed LED operation for "flexible LEDs".
21252 +1. Added the proc entry "avsar_oam_ping" to signal oam ping result.
21253 + 0 - failed; 1 - success; 2 - in progress.
21254 +2. Added oam ping timeout env variable. The timeout can be specified by
21255 + adding Adam2 env "oam_lb_timeout". The value is in millisecond.
21257 +Version 04.00.02.00
21258 +-------------------
21259 +1. The driver uses hardware queue for Turbo DSL.
21260 +2. Added new modem statistics listed below:
21261 + US and DS TX powers, atuc Vendor ID and revision, training mode selected,
21262 + Hybrid Selected, and etc.
21264 +Version 04.00.01.00
21265 +-------------------
21267 +1. This driver release contains all the features that exists in AR5 Linux ATM
21270 +2. F4 OAM generation is added.
21272 +3. Software queuing is used for TURBO DSL.
21274 +4. Porting guide "is created. Please look into that document for detailed
21278 diff -urN linux.old/drivers/atm/sangam_atm/syssw_version.h linux.dev/drivers/atm/sangam_atm/syssw_version.h
21279 --- linux.old/drivers/atm/sangam_atm/syssw_version.h 1970-01-01 01:00:00.000000000 +0100
21280 +++ linux.dev/drivers/atm/sangam_atm/syssw_version.h 2005-07-10 08:02:01.449110600 +0200
21282 +#ifndef __SYSSW_VERSION_H__
21283 +#define __SYSSW_VERSION_H__ 1
21285 +/*******************************************************************************
21286 +* FILE PURPOSE: DSL Driver API functions for Sangam
21288 +********************************************************************************
21289 +* FILE NAME: dsl_hal_basicapi.c
21292 +* Contains basic DSL HAL APIs for Sangam
21294 +* (C) Copyright 2003-04, Texas Instruments, Inc.
21296 +* Date Version Notes
21297 +* 14May03 0.00.00 RamP Original Version Created
21298 +* 14May03 0.00.01 RamP Initial Rev numbers inserted
21299 +* 14May03 0.00.02 RamP Bumped version numbers for Dsl Hal
21300 +* & dhalapp for alpha plus
21301 +* 19May03 0.00.03 MCB Bumped dslhal version number
21302 +* because of dependant changes
21303 +* wrt. linux-nsp atm drivers.
21304 +* 22May03 0.00.04 RamP Bumped dslhal & dhalapp buildnum
21305 +* for inner/outer pair & DGASP code
21306 +* 06Jun03 0.00.05 RamP Bumped up buildnum for LED, STM,
21307 +* interrupt processing, statistics
21308 +* and other pre-beta features
21309 +* 09Jun03 0.00.06 JEB Fixed error in DHALAPP bugfix/buildnum
21310 +* 09Jun03 0.00.07 RamP Bumped up buildnum for incremental
21311 +* changes to apis, statistics, memory
21312 +* fixes, parameter configurations
21313 +* 11Jun03 0.00.08 RamP Bumped up buildnum for Co profile
21315 +* 12Jun03 0.00.09 JEB Bumped version numbers for AR7 1.00 Beta
21316 +* 02Jul03 0.00.10 ZT Bumped HAL version for overlay page
21317 +* 18Jul03 0.00.11 RamP Bumped HAL version for analog diags
21318 +* 22Jul03 0.00.12 JEB Bumped DHALAPP buildnum for analog diags
21319 +* 31Jul03 0.00.13 RamP Bumped HAL version for engr. drop
21320 +* 04Aug03 0.00.14 JEB Bumped HAL version buildnum for CHECKPOINT65 changes
21321 +* Bumped LINUX version buildnum for CHECKPOINT65 changes
21322 +* 06Aug03 0.00.15 MCB Bumped all version numbers in prep for AR7 1.0 R2 release for POTS.
21323 +* 13Aug03 0.00.16 MCB Set rev id's for D3/R1.1 (ADSL2).
21324 +* 21Aug03 0.00.17 JEB Bumped up build numbers for merge of code additions from D1
21325 +* 26Sep03 0.00.18 JEB Set rev id's for another D3/R1 (ADSL2).
21326 +* 14Oct03 0.00.19 JEB Bumped Linux minor number and reset bugfix number for release.
21327 +* Bumped build numbers on DSLHAL and DHALAPP for this checkpoint.
21328 +* 14Oct03 0.00.20 JEB Bumped build numbers on DSLHAL and DHALAPP for CHECKPOINT15.
21329 +* 21Oct03 0.00.21 JEB Bumped build number on DSLHAL for CHECKPOINT16.
21330 +* 22Oct03 0.00.22 MCB Bumped all version numbers in support of D3R1 release.
21331 +* 27Oct03 0.00.23 JEB Bumped build numbers on DSLHAL and DHALAPP for CHECKPOINT19.
21332 +* Updated version for DSLAGENT to be 02.01.00.01 for ACT 2.1 R0.
21333 +* 30Oct03 0.00.24 JEB Bumped bugfix number on LINUXATM Version for next release.
21334 +* Bumped build numbers on DSLHAL and DHALAPP
21335 +* 31Oct03 0.00.25 MCB Bumped all version numbers in support of D3R2 release.
21336 +* 14Nov03 0.00.26 JEB Bumped build numbers on DSLHAL and DHALAPP
21337 +* Changed version for DSLAGENT to be 02.00.01.01 for an ACT 2.0 R0
21338 +* 20Nov03 0.00.27 JEB Bumped build number on DSLHAL.
21339 +* Changed version for DSLAGENT to be 02.00.02.00 for the next ACT 2.0 R2
21340 +* 21Nov03 0.00.28 MCB Bumped all version numbers in support of D3R2 release.
21341 +* 21Nov03 0.00.29 JEB Bumped build numbers on DSLHAL and DHALAPP for D3-R0 drop on 11/21.
21342 +* 16Dec03 0.00.30 JEB Bumped build numbers on DSLHAL and DHALAPP for CHECKPOINT31.
21343 +* 21Dec03 0.00.31 MCB Bumped all version numbers in support of D3R2 release.
21344 +* 05Jan04 0.00.32 JEB Bumped build numbers on DSLHAL and Linux ATM for CHECKPOINT 34.
21345 +* 15Jan04 0.00.33 JEB Bumped build numbers on DSLHAL and Linux ATM for CHECKPOINT 36.
21346 +* 26Jan04 0.00.34 JEB Changed Linux ATM version number to be 04.02.03.00.
21347 +* 27Jan04 0.00.35 MCB Bumped all version numbers in support of D3R2 release.
21348 +*******************************************************************************/
21350 +/* Dsl Hal API Version Numbers */
21351 +#define DSLHAL_VERSION_MAJOR 03
21352 +#define DSLHAL_VERSION_MINOR 00
21353 +#define DSLHAL_VERSION_BUGFIX 06
21354 +#define DSLHAL_VERSION_BUILDNUM 00
21355 +#define DSLHAL_VERSION_TIMESTAMP 00
21357 +/* dhalapp Adam2 Application Version Numbers */
21358 +#define DHALAPP_VERSION_MAJOR 03
21359 +#define DHALAPP_VERSION_MINOR 00
21360 +#define DHALAPP_VERSION_BUGFIX 05
21361 +#define DHALAPP_VERSION_BUILDNUM 00
21363 +/* Linux ATM Driver Version Numbers */
21364 +#define LINUXATM_VERSION_MAJOR 04
21365 +#define LINUXATM_VERSION_MINOR 02
21366 +#define LINUXATM_VERSION_BUGFIX 04
21367 +#define LINUXATM_VERSION_BUILDNUM 00
21369 +/* DSL Agent Version Numbers */
21370 +#define DSLAGENT_VERSION_MAJOR 02
21371 +#define DSLAGENT_VERSION_MINOR 00
21372 +#define DSLAGENT_VERSION_BUGFIX 02
21373 +#define DSLAGENT_VERSION_BUILDNUM 00
21375 +#endif /* pairs with #ifndef __SYSSW_VERSION_H__ */
21376 diff -urN linux.old/drivers/atm/sangam_atm/tn7api.h linux.dev/drivers/atm/sangam_atm/tn7api.h
21377 --- linux.old/drivers/atm/sangam_atm/tn7api.h 1970-01-01 01:00:00.000000000 +0100
21378 +++ linux.dev/drivers/atm/sangam_atm/tn7api.h 2005-07-10 08:02:01.450110448 +0200
21381 + * Tnetd73xx ATM driver.
21382 + * by Zhicheng Tang, ztang@ti.com
21383 + * 2000 (c) Texas Instruments Inc.
21392 +void xdump(unsigned char *buff, int len, int debugLev);
21393 +int tn7atm_receive(void *os_dev, int ch, unsigned int packet_size, void *os_receive_info, void *data);
21394 +void *tn7atm_allocate_rx_skb(void *os_dev, void **os_receive_info, unsigned int size);
21395 +void tn7atm_free_rx_skb(void *skb);
21396 +void tn7atm_sarhal_isr_register(void *os_dev, void *hal_isr, int interrupt_num);
21397 +int tn7atm_send_complete(void *osSendInfo);
21398 +int tn7atm_device_connect_status(void *priv, int state);
21399 +int tn7atm_lut_find(short vpi, int vci);
21402 +void tn7dsl_exit(void);
21403 +int tn7dsl_init(void *priv);
21404 +int tn7dsl_proc_stats(char* buf, char **start, off_t offset, int count,int *eof, void *data);
21405 +int tn7dsl_proc_modem(char* buf, char **start, off_t offset, int count,int *eof, void *data);
21406 +int tn7dsl_handle_interrupt(void);
21407 +void dprintf( int uDbgLevel, char * szFmt, ...);
21408 +void tn7dsl_dslmod_sysctl_register(void);
21409 +void tn7dsl_dslmod_sysctl_unregister(void);
21410 +int tn7dsl_get_dslhal_version(char *pVer);
21411 +int tn7dsl_get_dsp_version(char *pVer);
21413 +int os_atoi(const char *pStr);
21414 +int os_atoh(const char *pStr);
21415 +unsigned long os_atoul(const char *pStr);
21418 +int tn7sar_activate_vc(Tn7AtmPrivate *priv, short vpi, int vci, int pcr, int scr, int mbs, int cdvt, int chan, int qos);
21419 +int tn7sar_init(struct atm_dev *dev, Tn7AtmPrivate *priv);
21420 +int tn7sar_register_interrupt_handle(void *os_dev, void *hal_isr, int *interrupt_num);
21421 +void tn7sar_exit(struct atm_dev *dev, Tn7AtmPrivate *priv);
21422 +int tn7sar_deactivate_vc(Tn7AtmPrivate *priv, int chan);
21423 +int tn7sar_handle_interrupt(struct atm_dev *dev, Tn7AtmPrivate *priv);
21424 +int tn7sar_send_packet(Tn7AtmPrivate *priv, int chan, void *new_skb, void *data,unsigned int len, int priority);
21425 +void tn7sar_get_sar_version(Tn7AtmPrivate *priv, char **pVer);
21426 +int tn7sar_get_near_end_loopback_count(unsigned int *pF4count, unsigned int *pF5count);
21427 +int tn7sar_oam_generation(void *privContext, int chan, int type, int vpi, int vci, int timeout);
21428 +int tn7sar_get_stats(void *priv1);
21429 +int tn7sar_proc_sar_stat(char* buf, char **start, off_t offset, int count,int *eof, void *data);
21430 +void tn7sar_get_sar_firmware_version(unsigned int *pdsp_version_ms, unsigned int *pdsp_version_ls);
21431 +int tn7sar_proc_oam_ping(char* buf, char **start, off_t offset, int count,int *eof, void *data);
21432 +int tn7sar_proc_pvc_table(char* buf, char **start, off_t offset, int count,int *eof, void *data);
21434 diff -urN linux.old/drivers/atm/sangam_atm/tn7atm.c linux.dev/drivers/atm/sangam_atm/tn7atm.c
21435 --- linux.old/drivers/atm/sangam_atm/tn7atm.c 1970-01-01 01:00:00.000000000 +0100
21436 +++ linux.dev/drivers/atm/sangam_atm/tn7atm.c 2005-07-10 19:35:40.033466344 +0200
21440 + * Linux atm module implementation.
21441 + * Zhicheng Tang 01/08/2003
21442 + * 2003 (c) Texas Instruments Inc.
21447 +#include <linux/config.h>
21448 +#include <linux/kernel.h>
21449 +#include <linux/module.h>
21450 +#include <linux/init.h>
21451 +#include <linux/atmdev.h>
21452 +#include <linux/delay.h>
21453 +#include <linux/spinlock.h>
21454 +#include <linux/smp_lock.h>
21455 +#include <asm/io.h>
21456 +#include <asm/mips-boards/prom.h>
21457 +#include <linux/proc_fs.h>
21458 +#include <linux/string.h>
21459 +#include <linux/ctype.h>
21460 +#include "tn7atm.h"
21461 +#include "tn7api.h"
21462 +#include "syssw_version.h"
21464 +#ifdef CONFIG_LED_MODULE
21465 +#include <asm/ar7/ledapp.h>
21469 +MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
21470 +MODULE_AUTHOR ("Zhicheng Tang");
21473 +/* Version Information */
21474 +//static char atm_version[] ="1.0.0.1";
21480 +#define STOP_EMPTY_BUFF 2
21481 +#define START_EMPTY_BUFF 3
21484 +/*end of externs */
21486 +#define tn7atm_kfree_skb(x) dev_kfree_skb(x)
21489 +int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci);
21491 +void tn7atm_close (struct atm_vcc *vcc);
21493 +static int tn7atm_ioctl (struct atm_dev *dev, unsigned int cmd, void *arg);
21495 +int tn7atm_send (struct atm_vcc *vcc, struct sk_buff *skb);
21497 +static int tn7atm_change_qos (struct atm_vcc *vcc, struct atm_qos *qos,int flags);
21499 +static int tn7atm_detect(void);
21500 +static int tn7atm_init(struct atm_dev* dev);
21501 +//static int tn7atm_reset(void);
21502 +static int tn7atm_irq_request(struct atm_dev* dev);
21503 +static int tn7atm_proc_version(char* buf, char **start, off_t offset, int count,int *eof, void *data);
21504 +static void tn7atm_exit(void);
21505 +static int tn7atm_proc_channels(char* buf, char **start, off_t offset, int count,int *eof, void *data);
21506 +static int tn7atm_proc_private(char* buf, char **start, off_t offset, int count,int *eof,void *data);
21507 +//static void tn7atm_free_packet(void *vcc1, void *priv, void *skb1);
21508 +static int tn7atm_queue_packet_to_sar(void *vcc1, void *skb1);
21510 +#include "turbodsl.c"
21512 +/* ATM device operations */
21514 +struct atm_dev *mydev;
21516 +static const struct atmdev_ops tn7atm_ops = {
21517 + open: tn7atm_open,
21518 + close: tn7atm_close,
21519 + ioctl: tn7atm_ioctl,
21520 + getsockopt: NULL,
21521 + setsockopt: NULL,
21522 + send: tn7atm_send,
21526 + change_qos: tn7atm_change_qos,
21530 +int __guDbgLevel = 1;
21533 +void xdump(unsigned char *buff, int len, int debugLev)
21535 +#ifdef DEBUG_BUILD
21537 + if( __guDbgLevel < debugLev)
21541 + for(i=0;i<len;i++)
21543 + printk("%02x ", buff[i]);
21556 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21558 + * Function: int tn7atm_walk_vccs(struct atm_dev *dev, short *vcc, int *vci)
21560 + * Description: retrieve VPI/VCI for connection
21562 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
21564 +tn7atm_walk_vccs(struct atm_vcc *vcc, short *vpi, int *vci)
21566 + struct atm_vcc* walk;
21568 + // printk(tn7 "tn7atm_walk_vccs\n");
21569 + /* find a free VPI */
21570 + if (*vpi == ATM_VPI_ANY) {
21572 + for (*vpi = 0, walk = vcc->dev->vccs; walk; walk = walk->next) {
21574 + if ((walk->vci == *vci) && (walk->vpi == *vpi)) {
21576 + walk = vcc->dev->vccs;
21581 + /* find a free VCI */
21582 + if (*vci == ATM_VCI_ANY) {
21584 + for (*vci = ATM_NOT_RSV_VCI, walk = vcc->dev->vccs; walk; walk = walk->next) {
21586 + if ((walk->vpi = *vpi) && (walk->vci == *vci)) {
21587 + *vci = walk->vci + 1;
21588 + walk = vcc->dev->vccs;
21597 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21599 + * Function: int tn7atm_sar_irq(void)
21601 + * Description: tnetd73xx SAR interrupt.
21603 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
21605 +tn7atm_sar_irq(int irq , void *voiddev , struct pt_regs *regs)
21607 + struct atm_dev *atmdev;
21608 + Tn7AtmPrivate *priv;
21610 + dprintf(6, "tn7atm_sar_irq\n");
21611 + atmdev = (struct atm_dev *) voiddev;
21612 + priv = (Tn7AtmPrivate *)atmdev->dev_data;
21614 + tn7sar_handle_interrupt(atmdev, priv);
21616 + dprintf(6, "Leaving tn7atm_sar_irq\n");
21619 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21621 + * Function: int tn7atm_dsl_irq(void)
21623 + * Description: tnetd73xx DSL interrupt.
21625 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
21627 +tn7atm_dsl_irq(int irq , void *voiddev , struct pt_regs *regs)
21629 + struct atm_dev *atmdev;
21630 + Tn7AtmPrivate *priv;
21632 + dprintf(4, "tn7atm_dsl_irq\n");
21633 + atmdev = (struct atm_dev *) voiddev;
21634 + priv = (Tn7AtmPrivate *)atmdev->dev_data;
21636 + tn7dsl_handle_interrupt();
21638 + dprintf(4, "Leaving tn7atm_dsl_irq\n");
21641 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21643 + * Function: int tn7atm_Inittxcomp(struct tn7* tn7)
21645 + * Description: Initialize Interrupt handler
21647 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
21649 +tn7atm_irq_request (struct atm_dev *dev)
21651 + Tn7AtmPrivate *priv;
21655 + dprintf(4, "tn7atm_irq_request()\n");
21656 + priv = (Tn7AtmPrivate *) dev->dev_data;
21658 + /* Register SAR interrupt */
21659 + priv->sar_irq = LNXINTNUM(ATM_SAR_INT); /* Interrupt line # */
21660 + if (request_irq(priv->sar_irq, tn7atm_sar_irq, SA_INTERRUPT, "SAR ", dev))
21661 + printk ("Could not register tn7atm_sar_irq\n");
21663 + /* interrupt pacing */
21664 + ptr= prom_getenv("sar_ipacemax");
21667 + ipace=os_atoi(ptr);
21669 + avalanche_request_pacing(priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM, ipace);
21671 + /* Reigster Receive interrupt A */
21672 + priv->dsl_irq = LNXINTNUM(ATM_DSL_INT); /* Interrupt line # */
21673 + if (request_irq(priv->dsl_irq, tn7atm_dsl_irq, SA_INTERRUPT, "DSL ", dev))
21674 + printk ("Could not register tn7atm_dsl_irq\n");
21679 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21681 + * Function: int tn7atm_lut_find(struct atm_vcc *vcc)
21683 + * Description: find an TX DMA channel
21684 + * that matches a vpi/vci pair
21685 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
21687 +tn7atm_lut_find(short vpi, int vci)
21690 + Tn7AtmPrivate *priv;
21692 + priv = (Tn7AtmPrivate *)mydev->dev_data;
21694 + if(vci==0) // find first vpi channel
21696 + for(i=0; i< MAX_DMA_CHAN; i++)
21698 + if((priv->lut[i].vpi == vpi))
21703 + dprintf(4, "vpi=%d, vci=%d\n", vpi, vci);
21704 + for(i=0; i< MAX_DMA_CHAN; i++)
21706 + if((priv->lut[i].vpi == vpi) && (priv->lut[i].vci == vci))
21712 + return ATM_NO_DMA_CHAN;
21715 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21717 + * Function: int tn7atm_lut_clear(struct atm_vcc *vcc,int chan)
21719 + * Description: find an TX DMA channel
21720 + * that matches a vpi/vci pair
21721 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
21723 +tn7atm_lut_clear(struct atm_vcc *vcc, int chan)
21725 + Tn7AtmPrivate *priv;
21727 + priv = (Tn7AtmPrivate *)vcc->dev->dev_data;
21729 + memset(&priv->lut[chan], 0, sizeof(priv->lut[chan]));
21734 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21736 + * Function: int tn7atm_walk_lut(void)
21738 + * Description: find an available TX DMA channel
21739 + * and initialize LUT
21740 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
21742 +tn7atm_walk_lut(Tn7AtmPrivate *priv)
21746 + for(i=0; i< MAX_DMA_CHAN; i++){
21747 + if(!priv->lut[i].inuse)
21749 + return i; /* return available dma channel number */
21752 + return ATM_NO_DMA_CHAN; /* no tx dma channels available */
21756 +tn7atm_set_lut(Tn7AtmPrivate *priv, struct atm_vcc *vcc, int chan)
21759 + if(!priv->lut[chan].inuse)
21761 + priv->lut[chan].vpi = (int)vcc->vpi;
21762 + priv->lut[chan].vci = vcc->vci;
21763 + priv->lut[chan].chanid = chan;
21764 + priv->lut[chan].inuse = 1; /* claim the channel */
21765 + priv->lut[chan].vcc = (void *)vcc;
21766 + priv->lut[chan].bClosing = 0;
21767 + priv->lut[chan].ready = 0;
21768 + priv->lut[chan].tx_total_bufs = TX_BUFFER_NUM;
21769 + priv->lut[chan].tx_used_bufs[0] = 0;
21770 + priv->lut[chan].tx_used_bufs[1] = 0;
21773 + return -1; /* no tx dma channels available */
21777 +static void tn7atm_free_packet(void *pVc, void *pDev, void *pPacket)
21779 + Tn7AtmPrivate *priv;
21780 + struct atm_vcc *vcc;
21781 + struct sk_buff *skb;
21783 + vcc = (struct atm_vcc *)pVc;
21784 + priv = (Tn7AtmPrivate *)pDev;
21785 + skb = (struct sk_buff *) pPacket;
21788 + vcc->pop(vcc, skb);
21790 + tn7atm_kfree_skb(skb);
21794 +static void str2eaddr(char *pMac, char *pStr)
21801 + tmp[0]=pStr[i*3];
21802 + tmp[1]=pStr[i*3+1];
21804 + pMac[i]=os_atoh(tmp);
21809 +tn7atm_get_ESI(struct atm_dev *dev)
21812 + char esi_addr[ESI_LEN]={0x00,0x00,0x11,0x22,0x33,0x44};
21813 + char *esiaddr_str = NULL;
21815 + esiaddr_str = prom_getenv("macc");
21817 + if (!esiaddr_str) {
21818 + //printk("macc address not set in adam2 environment space\n");
21819 + //printk("Using default macc address = 00:01:02:03:04:05\n");
21820 + esiaddr_str = "00:00:02:03:04:05";
21822 + str2eaddr(esi_addr, esiaddr_str);
21824 + for(i=0; i < ESI_LEN; i++)
21825 + dev->esi[i] = esi_addr[i];
21830 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21832 + * Function: int tn7atm_open(struct atm_vcc *vcc, short vpi, int vci)
21834 + * Description: Device operation: open
21836 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
21838 +int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci)
21840 + Tn7AtmPrivate *priv;
21843 + int traffic_type;
21844 + int pcr = 0x20000;
21845 + int scr = 0x20000;
21846 + int mbs = 0x20000;
21847 + int cdvt = 10000;
21849 + dprintf(1, "tn7atm_open()\n");
21851 + priv = (Tn7AtmPrivate *)vcc->dev->dev_data;
21854 + printk("null priv\n");
21858 + MOD_INC_USE_COUNT;
21860 + /* find a free VPI/VCI */
21861 + tn7atm_walk_vccs(vcc, &vpi, &vci);
21866 + if (vci == ATM_VCI_UNSPEC || vpi == ATM_VCI_UNSPEC)
21868 + MOD_DEC_USE_COUNT;
21872 + /* check to see whether PVC is opened or not */
21873 + if((dmachan = tn7atm_lut_find(vcc->vpi, vcc->vci)) != ATM_NO_DMA_CHAN)
21875 + MOD_DEC_USE_COUNT;
21876 + printk("PVC already opened. dmachan = %d\n", dmachan);
21879 + /*check for available channel */
21880 + if((dmachan = tn7atm_walk_lut(priv)) == ATM_NO_DMA_CHAN)
21882 + printk("No TX DMA channels available\n");
21886 + set_bit(ATM_VF_ADDR, &vcc->flags); /* claim address */
21888 + vcc->itf = vcc->dev->number; /* interface number */
21890 + switch(vcc->qos.txtp.traffic_class)
21892 + case ATM_CBR: /* Constant Bit Rate */
21893 + traffic_type = 0;
21894 + pcr = vcc->qos.txtp.pcr;
21895 + scr = vcc->qos.txtp.pcr;
21896 + cdvt = vcc->qos.txtp.max_cdv;
21897 + printk("cdvt=%d\n", cdvt);
21899 + case ATM_UBR: /* Unspecified Bit Rate */
21900 + traffic_type = 2;
21902 + case ATM_VBR: /* Variable Bit Rate */
21903 + traffic_type = 1;
21904 + pcr = vcc->qos.txtp.pcr;
21905 + scr = vcc->qos.txtp.scr;
21906 + if(vcc->qos.txtp.max_pcr >= 0)
21907 + mbs = vcc->qos.txtp.max_pcr;
21908 + cdvt = vcc->qos.txtp.max_cdv;
21909 + printk("cdvt=%d\n", cdvt);
21910 + printk("mbs=%d\n", mbs);
21913 + traffic_type = 2;
21916 + dprintf(4, "vpi=%d, vci=%d, pcr=%d, dmachan=%d, qos=%d\n", vpi,vci,pcr,dmachan,traffic_type);
21917 + /* Activate SAR channel */
21918 + rc = tn7sar_activate_vc(priv, vpi, vci, pcr, scr, mbs, cdvt, dmachan, traffic_type);
21922 + MOD_DEC_USE_COUNT;
21926 + /* insure that the the vcc struct points to the correct entry
21927 + in the lookup table */
21929 + tn7atm_set_lut(priv,vcc, dmachan);
21930 + vcc->dev_data = (void *)&priv->lut[dmachan];
21931 + set_bit(ATM_VF_READY, &vcc->flags);
21934 + priv->lut[dmachan].ready = 1;
21935 + dprintf (1, "Leave tn7atm_open\n");
21941 +void tn7atm_close (struct atm_vcc *vcc)
21943 + Tn7AtmPrivate *priv;
21946 + priv = (Tn7AtmPrivate *)vcc->dev->dev_data;
21947 + dprintf(4, "closing %d.%d.%d.%d\n", vcc->itf, vcc->vpi, vcc->vci, vcc->qos.aal);
21949 + clear_bit(ATM_VF_READY, &vcc->flags); /* ATM_VF_READY: channel is ready to transfer data */
21951 + dmachan = tn7atm_lut_find(vcc->vpi, vcc->vci);
21952 + printk("closing channel: %d\n", dmachan);
21953 + if(dmachan == ATM_NO_DMA_CHAN)
21955 + printk("Closing channel not found.\n");
21958 + priv->lut[dmachan].bClosing = 1;
21959 + priv->lut[dmachan].ready = 0;
21960 + if(tn7sar_deactivate_vc(priv,dmachan)) /* tear down channel */
21962 + printk("failed to close channel %d.\n", dmachan);
21965 + clear_bit(ATM_VF_READY, &vcc->flags); /* ATM_VF_READY: channel is ready to transfer data */
21966 + tn7atm_lut_clear(vcc, dmachan);
21968 + MOD_DEC_USE_COUNT;
21970 + dprintf (1, "Leave tn7atm_close\n");
21973 +#define ATM_TXSTOP 0x800c61f4
21975 +tn7atm_ioctl (struct atm_dev *dev, unsigned int cmd, void *arg)
21977 + Tn7AtmPrivate *priv;
21978 + priv = (Tn7AtmPrivate *) dev->dev_data;
21980 + //printk("tn7atm_ioctl\n");
21981 + //printk("arg = %x\n", *(int *)arg);
21982 + //printk("cmd =%x\n", cmd);
21986 + case ATM_TXSTOP: /*temp fix for SAR tear down problem */
21987 +// printk("ioctl cmd = 0x%x (%u), arg = 0x%p (%lu)\n", cmd, cmd, arg, (unsigned long)arg);
21988 +// printk("arg = %d\n", *(int*)arg);
21989 + priv->xmitStop = *(int *)arg;
21990 + //printk("Executing ATM_SETLOOP for tn7 \n");
21991 + //printk("Stop variable = :%d: \n",priv->xmitStop);
21994 + //case SAR_DSL_RESET_SOFTBOOT:
21995 + // return tn7atm_dsl_clean_reboot();
22005 +tn7atm_change_qos (struct atm_vcc *vcc, struct atm_qos *qos,int flags)
22007 + dprintf (1, "Enter tn7atm_change_qos\n");
22008 + dprintf (1, "Leave tn7atm_change_qos\n");
22013 +int tn7atm_send (struct atm_vcc *vcc, struct sk_buff *skb)
22016 + Tn7AtmPrivate *priv;
22020 + dprintf(4, "tn7atm_send()\n");
22022 + priv = (Tn7AtmPrivate*)vcc->dev->dev_data;
22024 + //if(skb->len < 64)
22025 + //xdump((unsigned char *)skb->data, skb->len, 1);
22027 + //xdump((unsigned char *)skb->data, 64, 1);
22028 + /* check for dsl line connection */
22030 + /* add vcc field in skb for clip inATMARP fix */
22031 + ATM_SKB(skb)->vcc = vcc;
22032 + /* Ron change 2.3 -> 2.4 ??*/
22033 + //if(priv->lConnected != 1 || priv->xmitStop == 1)
22034 + if(priv->lConnected != 1 && priv->xmitStop == 1)
22036 + dprintf(4,"dsl line down\n");
22038 + vcc->pop(vcc, skb);
22040 + tn7atm_kfree_skb(skb);
22044 + /* check whether PVC is closing */
22045 + chan = tn7atm_lut_find(vcc->vpi, vcc->vci);
22046 + /* set br2684 dev pointer */
22047 + priv->lut[chan].net_device = skb->dev;
22048 + if(chan == ATM_NO_DMA_CHAN || priv->lut[chan].bClosing == 1)
22050 + dprintf(4, "can find sar channel\n");
22052 + vcc->pop(vcc, skb);
22054 + tn7atm_kfree_skb(skb);
22058 + bret=tn7atm_queue_packet_to_sar(vcc, skb);
22064 +static int tn7atm_queue_packet_to_sar(void *vcc1, void *skb1)
22066 + struct atm_vcc *vcc;
22067 + struct sk_buff *skb;
22068 + int priority = 1;
22069 + Tn7AtmPrivate *priv;
22072 + vcc = (struct atm_vcc *)vcc1;
22073 + skb = (struct sk_buff *)skb1;
22075 + priv = (Tn7AtmPrivate*)vcc->dev->dev_data;
22077 + dprintf(4, "vcc->vci=%d\n", vcc->vci);
22078 + dmachan = tn7atm_lut_find(vcc->vpi, vcc->vci);
22079 + if(dmachan == ATM_NO_DMA_CHAN)
22081 + dprintf(4, "can find sar channel\n");
22083 + vcc->pop(vcc, skb);
22085 + tn7atm_kfree_skb(skb);
22089 + // turbo dsl TCP ack check
22090 + if(priv->bTurboDsl)
22091 + priority = turbodsl_check_priority_type(skb->data);
22093 + //skb priority check
22094 + if(priority != 0)
22096 + if((skb->cb[47])>>1)
22102 + /* add queue info here */
22103 + skb->cb[47] = (char)priority;
22104 + spin_lock_irqsave(&priv->netifqueueLock, priv->netifqueueLockFlag);
22105 + priv->lut[dmachan].tx_used_bufs[priority]++;
22106 + spin_unlock_irqrestore(&priv->netifqueueLock, priv->netifqueueLockFlag);
22108 + if(tn7sar_send_packet(priv,dmachan, skb, skb->data, skb->len, priority) != 0)
22110 + dprintf(1, "failed to send packet\n");
22112 + vcc->pop(vcc, skb);
22114 + tn7atm_kfree_skb(skb);
22116 + spin_lock_irqsave(&priv->netifqueueLock, priv->netifqueueLockFlag);
22117 + priv->lut[dmachan].tx_used_bufs[priority]--;
22118 + spin_unlock_irqrestore(&priv->netifqueueLock, priv->netifqueueLockFlag);
22122 + /* check for whether tx queue is full or not */
22123 + //printk("bufs used = %d\n", priv->lut[dmachan].tx_used_bufs[1]);
22124 + spin_lock_irqsave(&priv->netifqueueLock, priv->netifqueueLockFlag);
22125 + if(priv->lut[dmachan].tx_used_bufs[1] >= (priv->lut[dmachan].tx_total_bufs - STOP_EMPTY_BUFF) ||
22126 + priv->lut[dmachan].tx_used_bufs[0] >= (priv->lut[dmachan].tx_total_bufs - STOP_EMPTY_BUFF))
22128 + //printk("net queue stoped\n");
22129 + netif_stop_queue(priv->lut[dmachan].net_device);
22130 + priv->lut[dmachan].netqueue_stop = 1;
22132 + spin_unlock_irqrestore(&priv->netifqueueLock, priv->netifqueueLockFlag);
22137 +/* functions needed by SAR HAL */
22139 +int tn7atm_send_complete(void *osSendInfo)
22141 + Tn7AtmPrivate *priv;
22142 + //struct atm_dev *dev;
22143 + struct sk_buff *skb;
22144 + struct atm_vcc *vcc;
22147 + dprintf(4, "tn7atm_send_complete()\n");
22150 + skb = (struct sk_buff *)osSendInfo;
22151 + //dev = (struct atm_dev *) (skb->dev);
22152 + priv = (Tn7AtmPrivate *)mydev->dev_data;
22153 + vcc =ATM_SKB(skb)->vcc;
22156 + dprintf(4, "vcc->vci=%d\n",vcc->vci );
22157 + chan = tn7atm_lut_find(vcc->vpi, vcc->vci);
22158 + if(chan==ATM_NO_DMA_CHAN)
22161 + /*decreament packet queued number */
22162 + spin_lock_irqsave(&priv->netifqueueLock, priv->netifqueueLockFlag);
22163 + priv->lut[chan].tx_used_bufs[(int)skb->cb[47]] --;
22164 + if(priv->lut[chan].tx_used_bufs[1] < priv->lut[chan].tx_total_bufs - START_EMPTY_BUFF &&
22165 + priv->lut[chan].tx_used_bufs[0] < priv->lut[chan].tx_total_bufs - START_EMPTY_BUFF)
22167 + if(priv->lut[chan].netqueue_stop)
22169 + //printk("net queue restarted\n");
22170 + netif_wake_queue(priv->lut[chan].net_device);
22171 + priv->lut[chan].netqueue_stop = 0;
22174 + spin_unlock_irqrestore(&priv->netifqueueLock, priv->netifqueueLockFlag);
22178 + dprintf(5, "free packet\n");
22179 + vcc->pop(vcc, skb);
22187 + /* Update Stats: There may be a better place to do this, but this is a start */
22188 + priv->stats.tx_packets++;
22189 +#ifdef CONFIG_LED_MODULE
22190 +// led_operation(MOD_ADSL, DEF_ADSL_ACTIVITY);
22193 + /* track number of buffer used */
22195 + dprintf(4, "tn7atm_send_complete() done\n");
22200 +void *tn7atm_allocate_rx_skb(void *os_dev, void **os_receive_info, unsigned int size)
22202 + struct sk_buff *skb;
22203 + dprintf(4, "tn7atm_allocate_rx_skb size=%d\n", size);
22204 + size = ((size+3)&0xfffffffc);
22205 + skb = dev_alloc_skb(size);
22208 + //printk("rx allocate skb failed\n");
22211 + *os_receive_info = (void *)skb;
22212 + return (skb->data);
22215 +void tn7atm_free_rx_skb(void *skb)
22217 + dprintf(4, "tn7atm_free_rx_skb\n");
22218 + tn7atm_kfree_skb((struct sk_buff *)skb);
22222 +int tn7atm_receive(void *os_dev, int ch, unsigned int packet_size, void *os_receive_info, void *data)
22224 + Tn7AtmPrivate *priv;
22225 + struct atm_dev *dev;
22226 + struct sk_buff *skb;
22227 + struct atm_vcc *vcc;
22230 + dprintf(4, "tn7atm_receive()\n");
22231 + dev = (struct atm_dev *)os_dev;
22233 + priv = (Tn7AtmPrivate *)dev->dev_data;
22235 + if(priv->lConnected != 1 || priv->lut[ch].ready == 0)
22237 + //printk("channel not ready\n");
22241 + vcc = (struct atm_vcc *)priv->lut[ch].vcc;
22244 + printk("vcc=Null");
22249 + /* assume no fragment packet for now */
22250 + skb = (struct sk_buff *)os_receive_info;
22254 + dprintf(1, "received empty skb.\n");
22257 + /* see skbuff->cb definition in include/linux/skbuff.h */
22258 + ATM_SKB(skb)->vcc = vcc;
22260 + skb->len = packet_size;
22261 + dprintf(3, "skb:[0x%p]:0x%x pdu_len: 0x%04x\n",skb,skb->len,packet_size);
22262 + dprintf(3, "data location: 0x%x, 0x%x\n", (unsigned int)skb->data, (unsigned int)data);
22264 + /*skb_trim(skb,skb->len); */ /* skb size is incorrect for large packets > 1428 bytes ?? */
22265 + __skb_trim(skb,skb->len); /* change to correct > 1500 ping when firewall is on */
22267 + dprintf(3, "pushing the skb...\n");
22268 + skb->stamp = vcc->timestamp = xtime;
22270 + xdump((unsigned char *)skb->data, skb->len, 5);
22272 + if(atm_charge(vcc, skb->truesize) == 0)
22274 + dprintf(1,"Receive buffers saturated for %d.%d.%d - PDU dropped\n", vcc->itf, vcc->vci, vcc->vpi);
22278 + /*pass it up to kernel networking layer and update stats*/
22279 + vcc->push(vcc,skb);
22281 + /* Update receive packet stats */
22282 + priv->stats.rx_packets++;
22283 + atomic_inc(&vcc->stats->rx);
22285 +#ifdef CONFIG_LED_MODULE
22286 +// led_operation(MOD_ADSL, DEF_ADSL_ACTIVITY);
22288 + dprintf(3, "(a) Receiving:vpi/vci[%d/%d] chan_id: %d skb len:0x%x skb truesize:0x%x\n",
22289 + vcc->vpi,vcc->vci,ch,skb->len, skb->truesize);
22295 +tn7atm_proc_channels(char* buf, char **start, off_t offset, int count,int *eof, void *data)
22298 + int limit = count - 80;
22301 + struct atm_dev *dev;
22302 + Tn7AtmPrivate *priv;
22304 + dev = (struct atm_dev *)data;
22305 + priv = (Tn7AtmPrivate *)dev->dev_data;
22308 + len += sprintf(buf+len,"Chan Inuse ChanID VPI VCI \n");
22310 + len += sprintf(buf+len,"------------------------------------------------------------------\n");
22312 + for(i=0; i < MAX_DMA_CHAN; i++)
22316 + len += sprintf(buf+len,
22317 + " %02d %05d %05d %05d %05d \n",
22318 + i,priv->lut[i].inuse,priv->lut[i].chanid,
22319 + priv->lut[i].vpi,priv->lut[i].vci);
22327 +tn7atm_proc_private(char* buf, char **start, off_t offset, int count,int *eof, void *data)
22330 + int limit = count - 80;
22331 + struct atm_dev *dev;
22332 + Tn7AtmPrivate *priv;
22334 + dev = (struct atm_dev *)data;
22335 + priv = (Tn7AtmPrivate *)dev->dev_data;
22338 + len += sprintf(buf+len, "\nPrivate Data Structure(%s):\n",priv->name);
22340 + len += sprintf(buf+len, "----------------------------------------\n");
22342 + len += sprintf(buf+len, "priv: 0x%p\n",priv);
22344 + len += sprintf(buf+len, "next: 0x%p",priv->next);
22346 + len += sprintf(buf+len, "\tdev: 0x%p\n",priv->dev);
22349 + len += sprintf(buf+len, "tx_irq: %02d",priv->sar_irq);
22351 + len += sprintf(buf+len, "rx_irq: %02d",priv->dsl_irq);
22357 +void tn7atm_sarhal_isr_register(void *os_dev, void *hal_isr, int interrupt_num)
22359 + struct atm_dev *dev;
22360 + Tn7AtmPrivate *priv;
22362 + dprintf(4, "tn7atm_sarhal_isr_register()\n");
22364 + dev = (struct atm_dev *)os_dev;
22365 + priv = (Tn7AtmPrivate *)dev->dev_data;
22366 + priv->halIsr = (void *)hal_isr;
22367 + priv->int_num = interrupt_num;
22371 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22373 + * Function: int tn7atm_exit(void)
22375 + * Description: Avalanche SAR exit function
22377 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
22380 +tn7atm_exit (void)
22383 + struct atm_dev *dev;
22385 + Tn7AtmPrivate *priv;
22387 + dprintf(4, "tn7atm_exit()\n");
22390 + priv = (Tn7AtmPrivate *)dev->dev_data;
22391 + priv->lConnected = 0;
22394 + tn7sar_exit(dev, priv);
22396 + /* freeup irq's */
22397 + free_irq(priv->dsl_irq,priv->dev);
22398 + free_irq(priv->sar_irq,priv->dev);
22400 + kfree (dev->dev_data);
22402 + // atm_dev_deregister (dev);
22403 + shutdown_atm_dev(dev);
22405 + /* remove proc entries */
22406 + remove_proc_entry("tiatm/avsar_ver",NULL);
22407 + remove_proc_entry("tiatm/avsar_modem_stats",NULL);
22408 + remove_proc_entry("tiatm/avsar_modem_training",NULL);
22409 + remove_proc_entry("tiatm/avsar_channels",NULL);
22410 + remove_proc_entry("tiatm/avsar_private",NULL);
22411 + remove_proc_entry("tiatm/avsar_sarhal_stats",NULL);
22412 + remove_proc_entry("tiatm/avsar_oam_ping",NULL);
22413 + remove_proc_entry("tiatm/avsar_pvc_table",NULL);
22414 + remove_proc_entry("tiatm",NULL);
22415 + tn7dsl_dslmod_sysctl_unregister();
22417 + printk ("Module Removed\n");
22423 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22425 + * Function: int tn7atm_registration(struct tn7* tn7)
22427 + * Description: ATM driver registration
22429 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
22432 +tn7atm_register (Tn7AtmPrivate * priv)
22434 + /* allocate memory for the device */
22436 + dprintf(4,"device %s being registered\n", priv->name);
22438 + mydev = atm_dev_register (priv->proc_name, &tn7atm_ops, -1, NULL);
22440 + if (mydev == NULL)
22442 + printk ("atm_dev_register returning NULL\n");
22443 + return ATM_REG_FAILED;
22446 + printk ("registered device %s\n", priv->name);
22448 + mydev->dev_data = priv; /* setup device data in atm_dev struct */
22449 + priv->dev = mydev; /* setup atm_device in avalanche sar struct */
22451 + mydev->ci_range.vpi_bits = ATM_CI_MAX; /* atm supports 11 bits */
22452 + mydev->ci_range.vci_bits = 16; /* atm VCI max = 16 bits */
22455 + return ATM_REG_OK;
22459 +tn7atm_proc_version(char* buf, char **start, off_t offset, int count,int *eof, void *data)
22465 + Tn7AtmPrivate *priv;
22467 + unsigned int pdspV1, pdspV2;
22469 + priv = mydev->dev_data;
22471 + len += sprintf(buf+len, "ATM Driver version:[%d.%02d.%02d.%02d]\n",LINUXATM_VERSION_MAJOR, LINUXATM_VERSION_MINOR,
22472 + LINUXATM_VERSION_BUGFIX, LINUXATM_VERSION_BUILDNUM);
22474 + tn7dsl_get_dslhal_version(dslVer);
22476 + len += sprintf(buf+len, "DSL HAL version: [%d.%02d.%02d.%02d]\n", dslVer[0], dslVer[1], dslVer[2],
22478 + tn7dsl_get_dsp_version(dspVer);
22480 + len += sprintf(buf+len, "DSP Datapump version: [%d.%02d.%02d.%02d] ", dspVer[4], dspVer[5], dspVer[6],
22482 + if(dspVer[8]==2) // annex B
22483 + len += sprintf(buf+len, "Annex B\n");
22484 + else if(dspVer[8]==3) //annex c
22485 + len += sprintf(buf+len, "Annex c\n");
22487 + len += sprintf(buf+len, "Annex A\n");
22489 + tn7sar_get_sar_version(priv, &pSarVer);
22491 + len += sprintf(buf+len, "SAR HAL version: [");
22494 + len += sprintf(buf+len, "%c", pSarVer[i+7]);
22496 + len += sprintf(buf+len, "]\n");
22498 + tn7sar_get_sar_firmware_version(&pdspV1, &pdspV2);
22499 + len += sprintf(buf+len, "PDSP Firmware version:[%01x.%02x]\n",
22506 +static struct net_device_stats
22507 +*tn7atm_get_stats(struct atm_dev *dev)
22509 + Tn7AtmPrivate *priv;
22510 + //unsigned long flags;
22512 + //spin_lock_irqsave(&priv->stats_lock,flags);
22513 + priv= (Tn7AtmPrivate *)dev->dev_data;
22514 + //spin_unlock_irqrestore(&priv->stats_lock,flags);
22516 + return &priv->stats;
22520 +/* Device detection */
22523 +tn7atm_detect (void)
22525 + Tn7AtmPrivate *priv;
22526 + //static struct proc_dir_entry *proc_dir;
22528 + dprintf(4, "tn7atm_detect().\n");
22529 + /* Device allocated as a global static structure at top of code "mydev" */
22531 + /* Alloc priv struct */
22532 + priv=kmalloc(sizeof(Tn7AtmPrivate),GFP_KERNEL);
22535 + printk("unable to kmalloc priv structure. Killing autoprobe.\n");
22538 + memset(priv, 0, sizeof(Tn7AtmPrivate));
22540 + priv->name = "TI Avalanche SAR";
22541 + priv->proc_name = "avsar";
22543 + priv->name = "TI tnetd73xx ATM Driver";
22544 + priv->proc_name = "tn7";
22547 + if ((tn7atm_register (priv)) == ATM_REG_FAILED)
22550 + tn7atm_init(mydev);
22552 + /* Set up proc entry for atm stats */
22553 + proc_mkdir("tiatm", NULL);
22554 + create_proc_read_entry("tiatm/avsar_modem_stats",0,NULL,tn7dsl_proc_stats,NULL);
22555 + create_proc_read_entry("tiatm/avsar_modem_training",0,NULL,tn7dsl_proc_modem,NULL);
22556 + create_proc_read_entry("tiatm/avsar_ver",0,NULL,tn7atm_proc_version,NULL);
22557 + create_proc_read_entry("tiatm/avsar_channels",0,NULL,tn7atm_proc_channels,mydev);
22558 + create_proc_read_entry("tiatm/avsar_private",0,NULL,tn7atm_proc_private,mydev);
22559 + create_proc_read_entry("tiatm/avsar_sarhal_stats",0,NULL,tn7sar_proc_sar_stat,mydev);
22560 + create_proc_read_entry("tiatm/avsar_oam_ping",0,NULL,tn7sar_proc_oam_ping,mydev);
22561 + create_proc_read_entry("tiatm/avsar_pvc_table",0,NULL,tn7sar_proc_pvc_table,mydev);
22563 + tn7dsl_dslmod_sysctl_register();
22565 + printk("Texas Instruments ATM driver: version:[%d.%02d.%02d.%02d]\n",LINUXATM_VERSION_MAJOR, LINUXATM_VERSION_MINOR,
22566 + LINUXATM_VERSION_BUGFIX, LINUXATM_VERSION_BUILDNUM);
22571 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22573 + * Function: int tn7atm_probe(void)
22575 + * Description: Avalanche SAR driver probe (see net/atm/pvc.c)
22576 + * this is utilized when the SAR driver is built
22577 + * into the kernel and needs to be configured.
22579 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
22580 +int __init tn7atm_probe(void)
22587 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22589 + * Function: int tn7atm_init(struct atm_dev *dev)
22591 + * Description: Device Initialization
22593 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
22595 +tn7atm_init(struct atm_dev *dev)
22597 + Tn7AtmPrivate *priv;
22600 + dprintf(4, "tn7atm_init()\n");
22602 + priv = (Tn7AtmPrivate *)dev->dev_data;
22604 + if(tn7sar_init(dev, priv) != 0)
22606 + printk("Failed to init SAR.\n");
22610 + if(tn7dsl_init(priv) < 0)
22612 + printk("Failed to init DSL.\n");
22616 + if(tn7atm_get_ESI(dev) < 0) /* set ESI */
22619 + if(tn7atm_irq_request(dev) < 0)
22622 + priv->bTurboDsl = 1;
22623 + // read config for turbo dsl
22624 + ptr = prom_getenv("TurboDSL");
22627 + priv->bTurboDsl = os_atoi(ptr);
22633 +int tn7atm_device_connect_status(void *priv, int state)
22635 + Tn7AtmPrivate *priv1;
22637 + dprintf(5, "tn7atm_device_connect_status()\n");
22638 + priv1 = (Tn7AtmPrivate *)priv;
22640 + priv1->lConnected = state;
22641 + dprintf(5, "priv1->lConnected=%d\n", priv1->lConnected);
22647 +module_init (tn7atm_detect);
22648 +module_exit (tn7atm_exit);
22649 +#endif /* MODULE */
22650 diff -urN linux.old/drivers/atm/sangam_atm/tn7atm.h linux.dev/drivers/atm/sangam_atm/tn7atm.h
22651 --- linux.old/drivers/atm/sangam_atm/tn7atm.h 1970-01-01 01:00:00.000000000 +0100
22652 +++ linux.dev/drivers/atm/sangam_atm/tn7atm.h 2005-07-10 08:02:01.452110144 +0200
22655 + * Tnetd73xx ATM driver.
22656 + * by Zhicheng Tang, ztang@ti.com
22657 + * 2000 (c) Texas Instruments Inc.
22662 +#ifndef __TN7ATM_H
22663 +#define __TN7ATM_H
22665 +//#include "mips_support.h"
22666 +#include <linux/list.h>
22668 +#define ATM_REG_OK 1
22669 +#define ATM_REG_FAILED 0
22671 +#define TX_SERVICE_MAX 32
22672 +#define RX_SERVICE_MAX 20
22673 +#define TX_BUFFER_NUM 64
22674 +#define RX_BUFFER_NUM 28
22675 +#define TX_QUEUE_NUM 2
22676 +#define RX_BUFFER_SIZE 1582
22678 +#define TX_DMA_CHAN 16 /* number of tx dma channels available */
22679 +#define MAX_DMA_CHAN 16
22680 +#define ATM_NO_DMA_CHAN MAX_DMA_CHAN + 1 /* no tx dma channels available */
22681 +#define ATM_SAR_INT 15
22682 +#define ATM_SAR_INT_PACING_BLOCK_NUM 2
22683 +#define ATM_DSL_INT 39
22685 +#define CONFIG_ATM_TN7ATM_DEBUG 0 /* Debug level (0=no mtn7s 5=verbose) */
22687 +#define TN7ATM_DEV(d) ((struct tn7atm*)((d)->dev_data))
22690 +/* Avalanche SAR state information */
22692 +typedef enum tn7atm_state
22694 + TN7ATM_STATE_REGISTER /* device registered */
22697 +typedef struct _sar_stat
22699 + unsigned int txErrors;
22700 + unsigned int rxErrors;
22701 + unsigned int rxPktCnt;
22702 + unsigned int txPktCnt;
22703 + unsigned int rxBytes;
22704 + unsigned int txBytes;
22707 +/* Host based look up table to xref Channel Id's, VPI/VCI, LC, CID, packet type */
22708 +typedef struct _tn7atm_tx_lut
22710 + int inuse; /* is DMA channel available (1=y) */
22711 + int chanid; /* DMA channel ID (0-0x1f) This corresponds to the Channel ID
22712 + that is used in the connection config reg (TN7ATM_CONN_CONFIG) */
22713 + int vpi; /* Virtual path identifier */
22714 + int vci; /* Virtual channel identifier */
22718 + void *net_device;
22719 + int tx_total_bufs;
22720 + int tx_used_bufs[2];
22721 + int netqueue_stop;
22724 +/* per device data */
22726 +typedef struct _tn7atm_private
22728 + struct _tn7atm_private *next; /* next device */
22729 + struct atm_dev *dev; /* ATM device */
22730 + struct net_device_stats stats; /* Used to report Tx/Rx frames from ifconfig */
22731 + tn7atm_lut_t lut[MAX_DMA_CHAN]; /* Tx DMA look up table (LUT) */
22732 + int dsl_irq; /* ATM SAR TransmitA interrupt number */
22733 + int sar_irq; /* ATM SAR ReceiveA interrupt number */
22734 + char* name; /* device name */
22735 + char* proc_name; /* board name under /proc/atm */
22736 + unsigned int available_cell_rate; /* cell rate */
22737 + unsigned int connection_cell_rate; /* cell rate */
22740 + /* Tnetd73xx CPHAL */
22741 + void *pSarHalDev;
22742 + void *pSarHalFunc;
22743 + void *pSarOsFunc;
22750 + /* spin lock for netifqueue */
22751 + spinlock_t netifqueueLock;
22752 + int netifqueueLockFlag;
22753 + int xmitStop; /* temp fix for SAR problem */
22754 +}tn7atm_private_t, Tn7AtmPrivate;
22758 +/* ATM adaptation layer id */
22759 +typedef enum tn7atm_aal {
22769 diff -urN linux.old/drivers/atm/sangam_atm/tn7dsl.c linux.dev/drivers/atm/sangam_atm/tn7dsl.c
22770 --- linux.old/drivers/atm/sangam_atm/tn7dsl.c 1970-01-01 01:00:00.000000000 +0100
22771 +++ linux.dev/drivers/atm/sangam_atm/tn7dsl.c 2005-07-10 08:27:39.683263464 +0200
22776 + * Avalanche SAR driver
22778 + * Zhicheng Tang, ztang@ti.com
22779 + * 2000 (c) Texas Instruments Inc.
22783 +#include <linux/config.h>
22784 +#include <linux/kernel.h>
22785 +#include <linux/module.h>
22786 +#include <linux/init.h>
22787 +#include <linux/atmdev.h>
22788 +#include <linux/delay.h>
22789 +#include <linux/spinlock.h>
22790 +#include <linux/smp_lock.h>
22791 +#include <asm/io.h>
22792 +#include <asm/mips-boards/prom.h>
22793 +#include <linux/proc_fs.h>
22794 +#include <linux/string.h>
22795 +#include <linux/ctype.h>
22796 +#include <linux/sysctl.h>
22797 +#include <linux/timer.h>
22798 +#include <linux/vmalloc.h>
22800 +#include "tn7atm.h"
22801 +#include "tn7api.h"
22802 +#include "dsl_hal_api.h"
22804 +#ifdef CONFIG_LED_MODULE
22805 +#include <asm/ar7/ledapp.h>
22806 +#define MOD_ADSL 1
22807 +#define DEF_ADSL_IDLE 1
22808 +#define DEF_ADSL_TRAINING 2
22809 +#define DEF_ADSL_SYNC 3
22810 +#define DEF_ADSL_ACTIVITY 4
22812 +#define LED_NUM_1 3
22813 +#define LED_NUM_2 4
22815 +led_reg_t ledreg[2];
22817 +static int led_on;
22820 +extern int __guDbgLevel;
22821 +extern sar_stat_t sarStat;
22822 +static int dslInSync = 0;
22823 +static int bMarginThConfig;
22824 +static int bMarginRetrainEnable;
22825 +static char EOCVendorID[8]= {0xb5, 0x00, 0x54, 0x53, 0x54, 0x43, 0x00, 0x00};
22828 +#define SYNC_TIME_DELAY 500000
22831 +#define DEV_DSLMOD 1
22832 +#define MAX_STR_SIZE 256
22833 +#define DSL_MOD_SIZE 256
22850 +/* a structure to store all information we need
22851 + for our thread */
22852 +typedef struct kthread_struct
22854 + /* private data */
22856 + /* Linux task structure of thread */
22857 + struct task_struct *thread;
22858 + /* Task queue need to launch thread */
22859 + struct tq_struct tq;
22860 + /* function to be started as thread */
22861 + void (*function) (struct kthread_struct *kthread);
22862 + /* semaphore needed on start and creation of thread. */
22863 + struct semaphore startstop_sem;
22865 + /* public data */
22867 + /* queue thread is waiting on. Gets initialized by
22868 + init_kthread, can be used by thread itself.
22870 + wait_queue_head_t queue;
22871 + /* flag to tell thread whether to die or not.
22872 + When the thread receives a signal, it must check
22873 + the value of terminate and call exit_kthread and terminate
22877 + /* additional data to pass to kernel thread */
22882 +#define DSP_FIRMWARE_PATH "/lib/modules/ar0700xx.bin"
22884 +#define DSP_FIRMWARE_PATH "/var/tmp/ar0700xx_diag.bin"
22888 +extern struct atm_dev *mydev;
22889 +extern unsigned int oamFarLBCount[4];
22890 +extern int dslhal_support_restoreTrainingInfo(PITIDSLHW_T pIhw);
22891 +/* gloabal functions */
22893 +/* end of global functions */
22895 +/* module wide declars */
22896 +static PITIDSLHW_T pIhw;
22897 +static char mod_req[16]={'\t'};
22898 +static volatile int bshutdown;
22899 +static char info[MAX_STR_SIZE];
22900 +static DECLARE_MUTEX_LOCKED(adsl_sem_overlay); /* Used for DSL Polling enable */
22901 +kthread_t overlay_thread;
22902 +/* end of module wide declars */
22904 +/* Internal Functions */
22905 +static void tn7dsl_chng_modulation(void* data);
22906 +static void tn7dsl_set_modulation(void* data);
22907 +static int tn7dsl_reload_overlay(void);
22908 +static int dslmod_sysctl(ctl_table *ctl, int write, struct file * filp, void *buffer, size_t *lenp);
22909 +static void tn7dsl_register_dslss_led(void);
22910 +void tn7dsl_dslmod_sysctl_register(void);
22911 +void tn7dsl_dslmod_sysctl_unregister(void);
22912 +/* end of internal functions */
22920 +/* start new kthread (called by creator) */
22921 +void start_kthread(void (*func)(kthread_t *), kthread_t *kthread);
22923 +/* stop a running thread (called by "killer") */
22924 +void stop_kthread(kthread_t *kthread);
22926 +/* setup thread environment (called by new thread) */
22927 +void init_kthread(kthread_t *kthread, char *name);
22929 +/* cleanup thread environment (called by thread upon receiving termination signal) */
22930 +void exit_kthread(kthread_t *kthread);
22934 +/* private functions */
22935 +static void kthread_launcher(void *data)
22937 + kthread_t *kthread = data;
22938 + kernel_thread((int (*)(void *))kthread->function, (void *)kthread, 0);
22942 +/* public functions */
22944 +/* create a new kernel thread. Called by the creator. */
22945 +void start_kthread(void (*func)(kthread_t *), kthread_t *kthread)
22947 + /* initialize the semaphore:
22948 + we start with the semaphore locked. The new kernel
22949 + thread will setup its stuff and unlock it. This
22950 + control flow (the one that creates the thread) blocks
22951 + in the down operation below until the thread has reached
22952 + the up() operation.
22954 + //init_MUTEX_LOCKED(&kthread->startstop_sem);
22956 + /* store the function to be executed in the data passed to
22958 + kthread->function=func;
22960 + /* create the new thread my running a task through keventd */
22962 + /* initialize the task queue structure */
22963 + kthread->tq.sync = 0;
22964 + INIT_LIST_HEAD(&kthread->tq.list);
22965 + kthread->tq.routine = kthread_launcher;
22966 + kthread->tq.data = kthread;
22968 + /* and schedule it for execution */
22969 + schedule_task(&kthread->tq);
22971 + /* wait till it has reached the setup_thread routine */
22972 + //down(&kthread->startstop_sem);
22976 +/* stop a kernel thread. Called by the removing instance */
22977 +void stop_kthread(kthread_t *kthread)
22979 + if (kthread->thread == NULL)
22981 + printk("stop_kthread: killing non existing thread!\n");
22985 + /* this function needs to be protected with the big
22986 + kernel lock (lock_kernel()). The lock must be
22987 + grabbed before changing the terminate
22988 + flag and released after the down() call. */
22991 + /* initialize the semaphore. We lock it here, the
22992 + leave_thread call of the thread to be terminated
22993 + will unlock it. As soon as we see the semaphore
22994 + unlocked, we know that the thread has exited.
22996 + //init_MUTEX_LOCKED(&kthread->startstop_sem);
22998 + /* We need to do a memory barrier here to be sure that
22999 + the flags are visible on all CPUs.
23003 + /* set flag to request thread termination */
23004 + kthread->terminate = 1;
23006 + /* We need to do a memory barrier here to be sure that
23007 + the flags are visible on all CPUs.
23010 + kill_proc(kthread->thread->pid, SIGKILL, 1);
23012 + /* block till thread terminated */
23013 + //down(&kthread->startstop_sem);
23015 + /* release the big kernel lock */
23018 + /* now we are sure the thread is in zombie state. We
23019 + notify keventd to clean the process up.
23021 + kill_proc(2, SIGCHLD, 1);
23025 +/* initialize new created thread. Called by the new thread. */
23026 +void init_kthread(kthread_t *kthread, char *name)
23028 + /* lock the kernel. A new kernel thread starts without
23029 + the big kernel lock, regardless of the lock state
23030 + of the creator (the lock level is *not* inheritated)
23034 + /* fill in thread structure */
23035 + kthread->thread = current;
23037 + /* set signal mask to what we want to respond */
23038 + siginitsetinv(¤t->blocked, sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGTERM));
23040 + /* initialise wait queue */
23041 + init_waitqueue_head(&kthread->queue);
23043 + /* initialise termination flag */
23044 + kthread->terminate = 0;
23046 + /* set name of this process (max 15 chars + 0 !) */
23047 + sprintf(current->comm, name);
23049 + /* let others run */
23052 + /* tell the creator that we are ready and let him continue */
23053 + //up(&kthread->startstop_sem);
23057 +/* cleanup of thread. Called by the exiting thread. */
23058 +void exit_kthread(kthread_t *kthread)
23060 + /* we are terminating */
23062 + /* lock the kernel, the exit will unlock it */
23064 + kthread->thread = NULL;
23067 + /* notify the stop_kthread() routine that we are terminating. */
23068 + //up(&kthread->startstop_sem);
23069 + /* the kernel_thread that called clone() does a do_exit here. */
23071 + /* there is no race here between execution of the "killer" and real termination
23072 + of the thread (race window between up and do_exit), since both the
23073 + thread and the "killer" function are running with the kernel lock held.
23074 + The kernel lock will be freed after the thread exited, so the code
23075 + is really not executed anymore as soon as the unload functions gets
23076 + the kernel lock back.
23077 + The init process may not have made the cleanup of the process here,
23078 + but the cleanup can be done safely with the module unloaded.
23085 +int os_atoi(const char *pStr)
23090 + retVal = -simple_strtoul(pStr+1, (char **)NULL, 10);
23092 + retVal = simple_strtoul(pStr, (char **)NULL, 10);
23097 +int os_atoh(const char *pStr)
23102 + retVal = -simple_strtoul(pStr+1, (char **)NULL, 16);
23104 + retVal = simple_strtoul(pStr, (char **)NULL, 16);
23108 +unsigned long os_atoul(const char *pStr)
23110 + unsigned long retVal = -1;
23112 + retVal = simple_strtoul(pStr, (char **)NULL, 10);
23116 +void dprintf( int uDbgLevel, char * szFmt, ...)
23118 +#ifdef DEBUG_BUILD
23119 + static char buff[256];
23122 + if( __guDbgLevel < uDbgLevel)
23125 + va_start( ap, szFmt);
23126 + vsprintf((char *)buff, szFmt, ap);
23128 + printk("%s", buff);
23132 +/*int strcmp(const char *s1, const char *s2)
23141 + if(s1[i] != s2[i])
23151 +int shim_osLoadFWImage(char *ptr)
23153 + unsigned int bytesRead;
23154 + mm_segment_t oldfs;
23155 + static struct file *filp;
23156 + unsigned int imageLength=0x4ffff;
23159 + dprintf(4, "tn7dsl_read_dsp()\n");
23161 + dprintf(4,"open file %s\n", DSP_FIRMWARE_PATH);
23163 + filp=filp_open(DSP_FIRMWARE_PATH
23168 + printk("Failed: Could not open DSP binary file\n");
23172 + if (filp->f_op->read==NULL)
23173 + return -1; /* File(system) doesn't allow reads */
23175 + /* Now read bytes from postion "StartPos" */
23177 + oldfs = get_fs();
23178 + set_fs(KERNEL_DS);
23179 + bytesRead = filp->f_op->read(filp,ptr,imageLength,&filp->f_pos);
23181 + dprintf(4,"file length = %d\n", bytesRead);
23185 + /* Close the file */
23188 + return bytesRead;
23191 +unsigned int shim_read_overlay_page(void *ptr, unsigned int secOffset, unsigned int secLength)
23193 + unsigned int bytesRead;
23194 + mm_segment_t oldfs;
23195 + struct file *filp;
23197 + dprintf(4,"shim_read_overlay_page\n");
23198 + //dprintf(4,"sec offset=%d, sec length =%d\n", secOffset, secLength);
23200 + filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
23203 + printk("Failed: Could not open DSP binary file\n");
23207 + if (filp->f_op->read==NULL)
23208 + return -1; /* File(system) doesn't allow reads */
23210 + /* Now read bytes from postion "StartPos" */
23212 + if(filp->f_op->llseek)
23213 + filp->f_op->llseek(filp,secOffset, 0);
23214 + oldfs = get_fs();
23215 + set_fs(KERNEL_DS);
23216 + filp->f_pos = secOffset;
23217 + bytesRead = filp->f_op->read(filp,ptr,secLength,&filp->f_pos);
23220 + /* Close the file */
23222 + return bytesRead;
23225 +int shim_osLoadDebugFWImage(char *ptr)
23229 +int shim_osStringCmp(const char *s1, const char *s2)
23231 + return strcmp(s1, s2);
23234 +void *shim_osAllocateMemory(unsigned int size)
23236 + return ((void *)kmalloc(size, GFP_KERNEL));
23239 +void *shim_osAllocateDmaMemory(unsigned int size)
23252 + return ( (void *)__get_free_pages(GFP_ATOMIC, order));
23254 + //return ((void *)kmalloc(size, GFP_ATOMIC));
23255 + //return ((void *)kmalloc(size, GFP_KERNEL));
23258 + ptr = kmalloc(size, GFP_ATOMIC);
23261 + printk("failed atomic\n");
23262 + ptr = kmalloc(size, GFP_KERNEL);
23265 + printk("failed kernel\n");
23266 + ptr = kmalloc(size, GFP_KERNEL|GFP_DMA);
23269 + printk("size=%d\n", size);
23275 +void shim_osFreeMemory(void *ptr, unsigned int size)
23281 +void shim_osFreeDmaMemory(void *ptr, unsigned int size)
23293 + free_pages(ptr, order);
23298 +void *shim_osAllocateVMemory(unsigned int size)
23301 + return ((void *)vmalloc(size));
23304 +void shim_osFreeVMemory(void *ptr, unsigned int size)
23309 +void shim_osMoveMemory(char *dst, char *src, unsigned int numBytes)
23311 + memcpy(dst, src, numBytes);
23314 +void shim_osZeroMemory(char *dst, unsigned int numBytes)
23316 + memset(dst, 0, numBytes);
23319 +void shim_osWriteBackCache(void *addr, unsigned int size)
23321 + unsigned int i,Size=(((unsigned int)addr)&0xf)+size;
23323 + for (i=0;i<Size;i+=16,addr+=16)
23325 + __asm__(" .set mips3 ");
23326 + __asm__(" cache 25, (%0)" : : "r" (addr));
23327 + __asm__(" .set mips0 ");
23331 +void shim_osInvalidateCache(void *addr, unsigned int size)
23333 + unsigned int i,Size=(((unsigned int)addr)&0xf)+size;
23335 + for (i=0;i<Size;i+=16,addr+=16)
23337 + __asm__(" .set mips3 ");
23338 + __asm__("cache 17, (%0)" : : "r" (addr));
23339 + __asm__(" .set mips0 ");
23343 +void shim_osClockWait(int val)
23345 + unsigned int chkvalue;
23348 + if(chkvalue > 1000)
23350 + mdelay(chkvalue/1000);
23355 +} /* end of cwait() */
23357 +unsigned int shim_osClockTick(int val)
23363 +spinlock_t shimLock;
23365 +void shim_osCriticalEnter(void)
23367 + spin_lock_irqsave(&shimLock, flags);
23372 +void shim_osCriticalExit(void)
23374 + spin_unlock_irqrestore(&shimLock, flags);
23378 +int tn7dsl_proc_stats(char* buf, char **start, off_t offset, int count,
23379 + int *eof, void *data)
23383 + int limit = count - 80;
23384 + int F4count, F5count;
23387 + /* Read Ax5 Stats */
23388 + dslhal_api_gatherStatistics(pIhw);
23391 + len += sprintf(buf+len, "\nAR7 DSL Modem Statistics:\n");
23393 + len += sprintf(buf+len, "--------------------------------\n");
23394 + /* us and ds Connection Rates */
23396 + len += sprintf(buf+len, "[DSL Modem Stats]\n");
23401 + if(pIhw->lConnected != 1)
23403 + pIhw->AppData.USConRate = 0;
23404 + pIhw->AppData.DSConRate = 0;
23406 + len += sprintf(buf+len, "\tUS Connection Rate:\t%u\tDS Connection Rate:\t%u\n",
23407 + (unsigned int)pIhw->AppData.USConRate,
23408 + (unsigned int)pIhw->AppData.DSConRate );
23411 + len += sprintf(buf+len, "\tDS Line Attenuation:\t%u\tDS Margin:\t\t%u\n",
23412 + (unsigned int)pIhw->AppData.dsLineAttn/2,
23413 + (unsigned int)pIhw->AppData.dsMargin/2 );
23415 + len += sprintf(buf+len, "\tUS Line Attenuation:\t%u\tUS Margin:\t\t%u\n",
23416 + (unsigned int)pIhw->AppData.usLineAttn,
23417 + (unsigned int)pIhw->AppData.usMargin );
23419 + len += sprintf(buf+len, "\tUS Payload :\t\t%u\tDS Payload:\t\t%u\n",
23420 + ((unsigned int)pIhw->AppData.usAtm_count[0] + (unsigned int)pIhw->AppData.usAtm_count[1])*48,
23421 + ((unsigned int)pIhw->AppData.dsGood_count[0] + (unsigned int)pIhw->AppData.dsGood_count[1])*48);
23422 + /* Superframe Count */
23424 + len += sprintf(buf+len, "\tUS Superframe Cnt :\t%u\tDS Superframe Cnt:\t%u\n",
23425 + (unsigned int)pIhw->AppData.usSuperFrmCnt,
23426 + (unsigned int)pIhw->AppData.dsSuperFrmCnt );
23428 + /* US and DS power */
23430 + len += sprintf(buf+len, "\tUS Transmit Power :\t%u\tDS Transmit Power:\t%u\n",
23431 + (unsigned int)pIhw->AppData.usTxPower/256,
23432 + (unsigned int)pIhw->AppData.dsTxPower/256 );
23433 + /* DSL Stats Errors*/
23435 + len += sprintf(buf+len, "\tLOS errors:\t\t%u\tSEF errors:\t\t%u\n",
23436 + (unsigned int)pIhw->AppData.LOS_errors,
23437 + (unsigned int)pIhw->AppData.SEF_errors );
23439 + len += sprintf(buf+len, "\tFrame mode:\t\t%u\tMax Frame mode:\t\t%u\n",
23440 + (unsigned int)pIhw->AppData.FrmMode,
23441 + (unsigned int)pIhw->AppData.MaxFrmMode );
23443 + len += sprintf(buf+len, "\tTrained Path:\t\t%u\tUS Peak Cell Rate:\t%u\n",
23444 + (unsigned int)pIhw->AppData.TrainedPath,
23445 + (unsigned int)pIhw->AppData.USConRate*1000/8/53 );
23447 + len += sprintf(buf+len, "\tTrained Mode:\t\t%u\tSelected Mode:\t\t%u\n",
23448 + (unsigned int)pIhw->AppData.TrainedMode, (unsigned int)pIhw->AppData.StdMode );
23451 + len += sprintf(buf+len, "\tATUC Vendor ID:\t%u\tATUC Revision:\t\t%u\n",
23452 + (unsigned int)pIhw->AppData.atucVendorId, pIhw->AppData.atucRevisionNum);
23454 + len += sprintf(buf+len, "\tHybrid Selected:\t%u\n",
23455 + (unsigned int)pIhw->AppData.currentHybridNum);
23457 + /* Upstream Interleaved Errors */
23459 + len += sprintf(buf+len, "\n\t[Upstream (TX) Interleave path]\n");
23461 + len += sprintf(buf+len, "\tCRC: \t%u\tFEC: \t%u\tNCD: \t%u\n",
23462 + (unsigned int)pIhw->AppData.usICRC_errors,
23463 + (unsigned int)pIhw->AppData.usIFEC_errors,
23464 + (unsigned int)pIhw->AppData.usINCD_error);
23466 + len += sprintf(buf+len, "\tLCD: \t%u\tHEC: \t%u\n",
23467 + (unsigned int)pIhw->AppData.usILCD_errors,
23468 + (unsigned int)pIhw->AppData.usIHEC_errors);
23469 + /* Downstream Interleaved Errors */
23471 + len += sprintf(buf+len, "\n\t[Downstream (RX) Interleave path]\n");
23473 + len += sprintf(buf+len, "\tCRC: \t%u\tFEC: \t%u\tNCD: \t%u\n",
23474 + (unsigned int)pIhw->AppData.dsICRC_errors,
23475 + (unsigned int)pIhw->AppData.dsIFEC_errors,
23476 + (unsigned int)pIhw->AppData.dsINCD_error);
23478 + len += sprintf(buf+len, "\tLCD: \t%u\tHEC: \t%u\n",
23479 + (unsigned int)pIhw->AppData.dsILCD_errors,
23480 + (unsigned int)pIhw->AppData.dsIHEC_errors);
23481 + /* Upstream Fast Errors */
23483 + len += sprintf(buf+len, "\n\t[Upstream (TX) Fast path]\n");
23485 + len += sprintf(buf+len, "\tCRC: \t%u\tFEC: \t%u\tNCD: \t%u\n",
23486 + (unsigned int)pIhw->AppData.usFCRC_errors,
23487 + (unsigned int)pIhw->AppData.usFFEC_errors,
23488 + (unsigned int)pIhw->AppData.usFNCD_error);
23490 + len += sprintf(buf+len, "\tLCD: \t%u\tHEC: \t%u\n",
23491 + (unsigned int)pIhw->AppData.usFLCD_errors,
23492 + (unsigned int)pIhw->AppData.usFHEC_errors);
23493 + /* Downstream Fast Errors */
23495 + len += sprintf(buf+len, "\n\t[Downstream (RX) Fast path]\n");
23497 + len += sprintf(buf+len, "\tCRC: \t%u\tFEC: \t%u\tNCD: \t%u\n",
23498 + (unsigned int)pIhw->AppData.dsFCRC_errors,
23499 + (unsigned int)pIhw->AppData.dsFFEC_errors,
23500 + (unsigned int)pIhw->AppData.dsFNCD_error);
23502 + len += sprintf(buf+len, "\tLCD: \t%u\tHEC: \t%u\n",
23503 + (unsigned int)pIhw->AppData.dsFLCD_errors,
23504 + (unsigned int)pIhw->AppData.dsFHEC_errors);
23505 + /* ATM stats upstream */
23507 + len += sprintf(buf+len, "\n[ATM Stats]");
23509 + len += sprintf(buf+len, "\n\t[Upstream/TX]\n");
23511 + len += sprintf(buf+len, "\tGood Cell Cnt:\t%u\n\tIdle Cell Cnt:\t%u\n\n",
23512 + (unsigned int)pIhw->AppData.usAtm_count[0] + (unsigned int)pIhw->AppData.usAtm_count[1],
23513 + (unsigned int)pIhw->AppData.usIdle_count[0] + (unsigned int)pIhw->AppData.usIdle_count[1]);
23514 + /* ATM stats downstream */
23516 + len += sprintf(buf+len, "\n\t[Downstream/RX)]\n");
23518 + len += sprintf(buf+len, "\tGood Cell Cnt:\t%u\n\tIdle Cell Cnt:\t%u\n\tBad Hec Cell Cnt:\t%u\n",
23519 + (unsigned int)pIhw->AppData.dsGood_count[0] + (unsigned int)pIhw->AppData.dsGood_count[1],
23520 + (unsigned int)pIhw->AppData.dsIdle_count[0] + (unsigned int)pIhw->AppData.dsIdle_count[1],
23521 + (unsigned int)pIhw->AppData.dsBadHec_count[0] + (unsigned int)pIhw->AppData.dsBadHec_count[1]);
23523 + len += sprintf(buf+len, "\tOverflow Dropped Cell Cnt:\t%u\n",
23524 + (unsigned int)pIhw->AppData.dsOVFDrop_count[0] + (unsigned int)pIhw->AppData.dsOVFDrop_count[1]);
23525 + tn7sar_get_stats(pIhw->pOsContext);
23527 + len += sprintf(buf+len, "\n[SAR AAL5 Stats]\n");
23529 + len += sprintf(buf+len, "\tTx PDU's:\t%u\n\tRx PDU's:\t%u\n",
23530 + sarStat.txPktCnt,
23531 + sarStat.rxPktCnt);
23533 + len += sprintf(buf+len, "\tTx Total Bytes:\t%u\n\tRx Total Bytes:\t%u\n",
23535 + sarStat.rxBytes);
23537 + len += sprintf(buf+len, "\tTx Total Error Counts:\t%u\n\tRx Total Error Counts:\t%u\n\n",
23538 + sarStat.txErrors,
23539 + sarStat.rxErrors);
23541 + /* oam loopback info */
23543 + len += sprintf(buf+len, "\n[OAM Stats]\n");
23545 + tn7sar_get_near_end_loopback_count(&F4count, &F5count);
23549 + len += sprintf(buf+len, "\tNear End F5 Loop Back Count:\t%u\n\tNear End F4 Loop Back Count:\t%u\n\tFar End F5 Loop Back Count:\t%u\n\tFar End F4 Loop Back Count:\t%u\n",
23552 + oamFarLBCount[0] + oamFarLBCount[2],
23553 + oamFarLBCount[1] + oamFarLBCount[3]);
23559 +tn7dsl_proc_modem(char* buf, char **start, off_t offset, int count,
23560 + int *eof, void *data)
23564 + int limit = count - 80;
23569 + tag= dslhal_api_pollTrainingStatus(pIhw);
23570 + tag = pIhw->AppData.bState;
23573 + case 0: state = "ACTREQ"; break;
23574 + case 1: state = "QUIET1"; break;
23575 + case 2: state = "IDLE"; break;
23576 + case 3: state = "INIT"; break;
23577 + case 4: state = "RTDL"; break;
23578 + case 5: state = "SHOWTIME"; break;
23579 + default: state = "unknown"; break;
23582 + if(pIhw->lConnected == 1)
23583 + state = "SHOWTIME";
23585 + len += sprintf(buf+len,"%s\n",state);
23592 +int tn7dsl_handle_interrupt(void)
23595 + unsigned char cMsgRa[6];
23598 + dprintf(4, "tn7dsl_handle_dsl_interrupt()\n");
23601 + intsrc=dslhal_api_acknowledgeInterrupt(pIhw);
23602 + dslhal_api_handleTrainingInterrupt(pIhw, intsrc);
23604 + if(pIhw->lConnected == TC_SYNC)
23607 + if(dslInSync == 0)
23609 + printk("DSL in Sync\n");
23610 + tn7atm_device_connect_status(pIhw->pOsContext, 1);
23611 + dslhal_api_initStatistics(pIhw);
23612 + dslhal_api_gatherStatistics(pIhw);
23613 +#ifdef CONFIG_LED_MODULE
23614 +// led_operation(MOD_ADSL, DEF_ADSL_SYNC);
23615 + led_on = DEF_ADSL_SYNC;
23617 + /* add auto margin retrain */
23618 + if(pIhw->AppData.TrainedMode < 5)
23620 + if(bMarginRetrainEnable && bMarginThConfig == 0)
23622 + dslhal_support_getCMsgsRa(pIhw, cMsgRa);
23623 + margin = *(unsigned short *)&cMsgRa[4];
23624 + margin = (margin >> 6) & 0x3f;
23625 + if(margin & 0x20) // highest bit is 1
23627 + margin = -(margin & 0x1f);
23630 + //printk("margin = %d, cmsg-ra = %02x %02x %02x %02x %02x %02x\n", margin, cMsgRa[0],cMsgRa[1],cMsgRa[2],cMsgRa[3],cMsgRa[4],cMsgRa[5]);
23631 + dslhal_api_setMarginThreshold(pIhw, margin*2); /* DSL margin is in 0.5db */
23640 + if(dslInSync == 1)
23643 + tn7atm_device_connect_status(pIhw->pOsContext, 0);
23644 + up(&adsl_sem_overlay);
23645 + printk("DSL out of syn\n");
23647 +#ifdef CONFIG_LED_MODULE
23648 + if(pIhw->AppData.bState < RSTATE_INIT)
23650 + if(led_on != DEF_ADSL_IDLE)
23652 +// led_operation(MOD_ADSL, DEF_ADSL_IDLE);
23653 + led_on = DEF_ADSL_IDLE;
23658 + if(led_on != DEF_ADSL_TRAINING)
23660 +// led_operation(MOD_ADSL, DEF_ADSL_TRAINING);
23661 + led_on = DEF_ADSL_TRAINING;
23674 +int tn7dsl_get_dslhal_version(char *pVer)
23678 + dslhal_api_getDslHalVersion(&ver);
23680 + memcpy(pVer,&ver,8);
23684 +int tn7dsl_get_dsp_version(char *pVer)
23687 + dslhal_api_getDspVersion(pIhw, &ver);
23688 + memcpy(pVer, &ver, 9);
23694 +tn7dsl_get_modulation(void)
23696 + char *ptr = NULL;
23698 + dprintf(4, "tn7dsl_get_modulation\n");
23699 + //printk("tn7dsl_get_modulation\n");
23700 + ptr = prom_getenv("modulation");
23703 + //printk("modulation is not set in adam2 env\n");
23704 + //printk("Using multimode\n");
23707 + printk("dsl modulation = %s\n", ptr);
23709 + tn7dsl_set_modulation(ptr);
23715 +static int tn7dsl_set_dsl(void)
23718 + char *ptr = NULL;
23720 + int i, offset[2]={4,11},oamFeature=0;
23724 + // OAM Feature Configuration
23725 + dslhal_api_dspInterfaceRead(pIhw,(unsigned int)pIhw->pmainAddr, 2, (unsigned int *)&offset, (unsigned char *)&oamFeature, 4);
23726 + oamFeature |= dslhal_support_byteSwap32(0x0000000C);
23727 + dslhal_api_dspInterfaceWrite(pIhw,(unsigned int)pIhw->pmainAddr, 2, (unsigned int *)&offset, (unsigned char *)&oamFeature, 4);
23730 + ptr = prom_getenv("modulation");
23733 + printk("dsl modulation = %s\n", ptr);
23734 + tn7dsl_set_modulation(ptr);
23737 + // margin retrain
23739 + ptr = prom_getenv("enable_margin_retrain");
23742 + value = os_atoi(ptr);
23745 + dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
23746 + bMarginRetrainEnable = 1;
23747 + printk("enable showtime margin monitor.\n");
23749 + ptr = prom_getenv("margin_threshold");
23752 + value = os_atoi(ptr);
23753 + printk("Set margin threshold to %d x 0.5 db\n",value);
23756 + dslhal_api_setMarginThreshold(pIhw, value);
23757 + bMarginThConfig=1;
23765 + ptr = prom_getenv("enable_rate_adapt");
23768 + dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
23773 + ptr = prom_getenv("enable_trellis");
23776 + dslhal_api_setTrellisFlag(pIhw, os_atoi(ptr));
23779 + // maximum bits per carrier
23781 + ptr = prom_getenv("maximum_bits_per_carrier");
23784 + dslhal_api_setMaxBitsPerCarrier(pIhw, os_atoi(ptr));
23787 + // maximum interleave depth
23789 + ptr = prom_getenv("maximum_interleave_depth");
23792 + dslhal_api_setMaxInterleaverDepth(pIhw, os_atoi(ptr));
23795 + // inner and outer pairs
23797 + ptr = prom_getenv("pair_selection");
23800 + dslhal_api_selectInnerOuterPair(pIhw, os_atoi(ptr));
23804 + ptr = prom_getenv("dgas_polarity");
23807 + dslhal_api_configureDgaspLpr(pIhw, 1, 1);
23808 + dslhal_api_configureDgaspLpr(pIhw, 0, os_atoi(ptr));
23812 + ptr = prom_getenv("los_alarm");
23815 + dslhal_api_disableLosAlarm(pIhw, os_atoi(ptr));
23819 + ptr = prom_getenv("eoc_vendor_id");
23825 + tmp[1]=ptr[i*2+1];
23827 + EOCVendorID[i] = os_atoh(tmp);
23828 + //printk("tmp=%s--", tmp);
23829 + //printk("ID[%d]=0x%02x ", i, (unsigned char)EOCVendorID[i]);
23831 + tn7dsl_get_dsp_version(dspVer);
23832 + //printk("Annex =%d\n", dspVer[8]);
23833 + if(dspVer[8]==2) // annex b
23835 + //printk("EOCVendorID=%02x %02x %02x %02x %02x %02x %02x %02x\n", EOCVendorID[0], EOCVendorID[1], EOCVendorID[2], EOCVendorID[3],
23836 + // EOCVendorID[4], EOCVendorID[5], EOCVendorID[6], EOCVendorID[7]);
23837 + dslhal_api_setEocVendorId(pIhw, EOCVendorID);
23849 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23851 + * Function: static void tn7dsl_init(void)
23853 + * Description: This function initializes
23854 + * Ar7 DSL interface
23855 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
23857 +int tn7dsl_init(void *priv)
23860 + printk("Initializing DSL interface\n");
23864 + if(dslhal_api_dslStartup(&pIhw) !=0 )
23866 + printk("DSL start failed.\n");
23870 + // set dsl into overlay page reload mode
23871 + pIhw->bAutoRetrain = 1;
23873 + // set default training properties
23874 + tn7dsl_set_dsl();
23876 + pIhw->pOsContext = priv;
23878 + //start_kthread(tn7dsl_reload_overlay, &overlay_thread);
23880 + /*register dslss LED with led module */
23881 +#ifdef CONFIG_LED_MODULE
23882 + tn7dsl_register_dslss_led();
23886 + return 0; /* What do we return here? */
23889 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23891 + * Function: int avsar_exit(void)
23893 + * Description: Avalanche SAR exit function
23895 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
23897 +void tn7dsl_exit (void)
23901 +#ifdef CONFIG_LED_MODULE
23902 +#ifdef DEREGISTER_LED
23903 + //down(&adsl_sem_overlay);
23904 + deregister_led_drv(LED_NUM_1);
23905 + deregister_led_drv(LED_NUM_2);
23907 +// led_operation(MOD_ADSL,DEF_ADSL_IDLE);
23910 + stop_kthread(&overlay_thread);
23911 + dslhal_api_dslShutdown(pIhw);
23916 +static int tn7dsl_process_oam_string(int *type, int *pvpi, int *pvci, int *pdelay)
23927 + tmp[j] = mod_req[i];
23928 + //printk("tmp[%d]=%c, %d\n", j, tmp[j], tmp[j]);
23929 + if(tmp[j] == 0x50 || tmp[j] == 0x70)
23936 + vpi = os_atoi(tmp);
23942 + tmp[j] = mod_req[i];
23943 + //printk("tmp[%d]=%c, %d\n", j, tmp[j], tmp[j]);
23944 + if(tmp[j] == 0x43 || tmp[j] == 0x63)
23951 + vci = os_atoi(tmp);
23953 + if(vci==0) // f4 oam
23962 + tmp[j] = mod_req[i];
23963 + if(tmp[j]==0x44 || tmp[j]==0x64)
23968 + tmp[j] = mod_req[i];
23970 + //printk("tmp[%d]=%c, %d\n", j, tmp[j], tmp[j]);
23971 + if(tmp[j] == 0x54 || tmp[j] == 0x74)
23977 + tt = os_atoi(tmp);
23980 + chan = tn7atm_lut_find(vpi, vci);
23985 + dprintf(2, "oam chan=%d, type =%d\n", chan, *type);
23990 +static void tn7dsl_dump_memory(void)
23992 + unsigned int *pUi;
24001 + tmp[j] = mod_req[i];
24008 + addr = os_atoh(tmp);
24010 + printk("start dump address =0x%x\n", addr);
24011 + pUi = (unsigned int *)addr;
24016 + tmp[j] = mod_req[i];
24017 + //printk("tmp[%d]=%c, %d\n", j, tmp[j], tmp[j]);
24018 + if(tmp[j] == 0x43 || tmp[j] == 0x63)
24025 + len = os_atoi(tmp);
24027 + for(i=0; i<len; i++)
24030 + printk("0x%08x: ", (unsigned int)pUi);
24031 + printk("%08x ", *pUi);
24045 +static int dslmod_sysctl(ctl_table *ctl, int write, struct file * filp,
24046 + void *buffer, size_t *lenp)
24049 + int ret, len = 0;
24052 + int vpi,vci,timeout;
24054 + if (!*lenp || (filp->f_pos && !write)) {
24058 + /* DSL MODULATION is changed */
24061 + ret = proc_dostring(ctl, write, filp, buffer, lenp);
24063 + switch (ctl->ctl_name)
24066 + ptr = strpbrk(info, " \t");
24067 + strcpy(mod_req, info);
24069 + /* parse the string to determine the action */
24070 + if(mod_req[0] == 0x45 || mod_req[0] == 0x65 ) // 'e', or 'E' f5 end to end
24072 + chan = tn7dsl_process_oam_string(&type, &vpi, &vci, &timeout);
24073 + tn7sar_oam_generation(pIhw->pOsContext, chan, type, vpi, vci, timeout);
24075 + else if(mod_req[0] == 0x53 || mod_req[0] == 0x73 ) // 's', or 'S' f5 seg to seg
24077 + chan=tn7dsl_process_oam_string(&type, &vpi, &vci,&timeout);
24078 + type = type | (1<<1);
24079 + tn7sar_oam_generation(pIhw->pOsContext, chan, type, vpi, vci,timeout);
24081 + //debug only. Dump memory
24082 + else if(mod_req[0] == 0x44 || mod_req[0] == 0x64 ) // 'd' or 'D'
24083 + tn7dsl_dump_memory();
24085 + tn7dsl_chng_modulation(info);
24091 + len += sprintf(info+len, mod_req);
24092 + ret = proc_dostring(ctl, write, filp, buffer, lenp);
24098 +ctl_table dslmod_table[] = {
24099 + {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, &dslmod_sysctl},
24103 +/* Make sure that /proc/sys/dev is there */
24104 +ctl_table dslmod_root_table[] = {
24105 +#ifdef CONFIG_PROC_FS
24106 + {CTL_DEV, "dev", NULL, 0, 0555, dslmod_table},
24107 +#endif /* CONFIG_PROC_FS */
24111 +static struct ctl_table_header *dslmod_sysctl_header;
24113 +void tn7dsl_dslmod_sysctl_register(void)
24115 + static int initialized;
24117 + if (initialized == 1)
24120 + dslmod_sysctl_header = register_sysctl_table(dslmod_root_table, 1);
24121 + dslmod_root_table->child->de->owner = THIS_MODULE;
24123 + /* set the defaults */
24129 +void tn7dsl_dslmod_sysctl_unregister(void)
24131 + unregister_sysctl_table(dslmod_sysctl_header);
24135 +tn7dsl_set_modulation(void* data)
24137 + dprintf(4,"tn7dsl_set_modulation\n");
24139 + if(!strcmp(data, "T1413"))
24141 + printk("retraining in T1413 mode\n");
24142 + dslhal_api_setTrainingMode(pIhw, T1413_MODE);
24145 + if(!strcmp(data, "GDMT"))
24147 + dslhal_api_setTrainingMode(pIhw, GDMT_MODE);
24150 + if(!strcmp(data, "GLITE"))
24152 + dslhal_api_setTrainingMode(pIhw, GLITE_MODE);
24155 + if(!strcmp(data, "MMODE"))
24157 + dslhal_api_setTrainingMode(pIhw, MULTI_MODE);
24160 + if(!strcmp(data, "NMODE"))
24162 + dslhal_api_setTrainingMode(pIhw, NO_MODE);
24170 +/* Codes added for compiling tiadiag.o for Analog Diagnostic tests */
24175 + HOST_ACTREQ, // Send R-ACKREQ and monitor for C-ACKx
24176 + HOST_QUIET, // Sit quietly doing nothing for about 60 seconds, DEFAULT STATE; R_IDLE
24177 + HOST_XMITBITSWAP, // Perform upstream bitswap - FOR INTERNAL USE ONLY
24178 + HOST_RCVBITSWAP, // Perform downstream bitswap - FOR INTERNAL USE ONLY
24179 + HOST_RTDLPKT, // Send a remote download packet - FOR INTERNAL USE ONLY
24180 + HOST_CHANGELED, // Read the LED settings and change accordingly
24181 + HOST_IDLE, // Sit quiet
24182 + HOST_REVERBTEST, // Generate REVERB for manufacturing test
24183 + HOST_CAGCTEST, // Set coarse receive gain for manufacturing test
24184 + HOST_DGASP, // send Dying Gasp messages through EOC channel
24185 + HOST_GHSREQ, // G.hs - FOR INTERNAL USE ONLY
24186 + HOST_GHSMSG, // G.hs - FOR INTERNAL USE ONLY
24187 + HOST_GHS_SENDGALF, // G.hs - FOR INTERNAL USE ONLY
24188 + HOST_GHSEXIT, // G.hs - FOR INTERNAL USE ONLY
24189 + HOST_GHSMSG1, // G.hs - FOR INTERNAL USE ONLY
24190 + HOST_HYBRID, // Enable/Disable automatic hybrid switch
24191 + HOST_RJ11SELECT, // RJ11 inner/outer pair select
24192 + HOST_DIGITAL_MEM, // Digital Diags: run external memory tests
24193 + HOST_TXREVERB, // AFE Diags: TX path Reverb
24194 + HOST_TXMEDLEY, // AFE Diags: TX path Medley
24195 + HOST_RXNOISEPOWER, // AFE Diags: RX noise power
24196 + HOST_ECPOWER, // AFE Diags: RX eco power
24197 + HOST_ALL_ADIAG, // AFE Diags: all major analog diagnostic modes. Host is responsible to initiate each diagnostic sessions
24198 + HOST_USER_ADIAG, // AFE Diags: Host fills in analog diagnostic input data structure as specified and requests DSP to perform measurements as specified
24199 + HOST_QUIT_ADIAG, // AFE Diags: Host requests DSP to quit current diagnostic session. This is used for stopping the transmit REVERB/MEDLEY
24200 + HOST_NO_CMD, // All others - G.hs - FOR INTERNAL USE ONLY
24201 + HOST_DSLSS_SHUTDOWN, // Host initiated DSLSS shutdown message
24202 + HOST_SET_GENERIC, // Set generic CO profile
24203 + HOST_UNDO_GENERIC // Set profile previous to Generic
24208 + DSP_IDLE, // R_IDLE state entered
24209 + DSP_ACTMON, // R_ACTMON state entered
24210 + DSP_TRAIN, // R_TRAIN state entered
24211 + DSP_ACTIVE, // R_ACTIVE state entered
24212 + DSP_XMITBITSWAP, // Upstream bitswap complete - FOR INTERNAL USE ONLY
24213 + DSP_RCVBITSWAP, // Downstream bitswap complete - FOR INTERNAL USE ONLY
24214 + DSP_RTDL, // R_RTDL state entered - FOR INTERNAL USE ONLY
24215 + DSP_RRTDLPKT, // RTDL packet received - FOR INTERNAL USE ONLY
24216 + DSP_XRTDLPKT, // RTDL packet transmitted - FOR INTERNAL USE ONLY
24217 + DSP_ERROR, // Command rejected, wrong state for this command
24218 + DSP_REVERBTEST, // Manufacturing REVERB test mode entered
24219 + DSP_CAGCTEST, // Manufacturing receive gain test done
24220 + DSP_OVERLAY_START, // Notify host that page overlay has started - overlay number indicated by "tag"
24221 + DSP_OVERLAY_END, // Notify host that page overlay has ended - overlay number indicated by "tag"
24222 + DSP_CRATES1, // CRATES1 message is valid and should be copied to host memory now
24223 + DSP_SNR, // SNR calculations are ready and should be copied to host memory now
24224 + DSP_GHSMSG, // G.hs - FOR INTERNAL USE ONLY
24225 + DSP_RCVBITSWAP_TIMEOUT, // Acknowledge Message was not received within ~500 msec (26 Superframes).
24226 + DSP_ATM_TC_SYNC, // Indicates true TC sync on both the upstream and downstream. Phy layer ready for data xfer.
24227 + DSP_ATM_NO_TC_SYNC, // Indicates loss of sync on phy layer on either US or DS.
24228 + DSP_HYBRID, // DSP completed hybrid switch
24229 + DSP_RJ11SELECT, // DSP completed RJ11 inner/outer pair select
24230 + DSP_INVALID_CMD, // Manufacturing (Digital and AFE) diags: CMD received not recognized
24231 + DSP_TEST_PASSED, // Manufacturing diags: test passed
24232 + DSP_TEST_FAILED, // Manufacturing diags: test failed
24233 + DSP_TXREVERB, // Manufacturing AFE diags: Response to HOST_TXREVERB
24234 + DSP_TXMEDLEY, // Manufacturing AFE diags: Response to HOST_TXMEDLEY
24235 + DSP_RXNOISEPOWER, // Manufacturing AFE diags: Response to HOST_RXNOISEPOWER
24236 + DSP_ECPOWER, // Manufacturing AFE diags: Response to HOST_ECPOWER
24237 + DSP_ALL_ADIAG, // Manufacturing AFE diags: Response to HOST_ALL_ADIAG
24238 + DSP_USER_ADIAG, // Manufacturing AFE diags: Response to HOST_USER_ADIAG
24239 + DSP_QUIT_ADIAG, // Manufacturing AFE diags: Response to HOST_QUIT_ADIAG
24240 + DSP_DGASP // DSP Message to indicate dying gasp
24243 +static unsigned char analogNoTonesTestArray[64]=
24245 + 0,0,0,0,0,0,0,0, // Tones 01-08
24246 + 0,0,0,0,0,0,0,0, // Tones 09-16
24247 + 0,0,0,0,0,0,0,0, // Tones 17-24
24248 + 0,0,0,0,0,0,0,0, // Tones 25-32
24249 + 0,0,0,0,0,0,0,0, // Tones 33-40
24250 + 0,0,0,0,0,0,0,0, // Tones 41-48
24251 + 0,0,0,0,0,0,0,0, // Tones 49-56
24252 + 0,0,0,0,0,0,0,0 // Tones 57-64
24255 +static unsigned char analogAllTonesTestArray[64]=
24257 + 1,1,1,1,1,1,1,1, // Tones 01-08
24258 + 1,1,1,1,1,1,1,1, // Tones 09-16
24259 + 1,1,1,1,1,1,1,1, // Tones 17-24
24260 + 1,1,1,1,1,1,1,1, // Tones 25-32
24261 + 1,1,1,1,1,1,1,1, // Tones 33-40
24262 + 1,1,1,1,1,1,1,1, // Tones 41-48
24263 + 1,1,1,1,1,1,1,1, // Tones 49-56
24264 + 1,1,1,1,1,1,1,1 // Tones 57-64
24267 +static unsigned char analogEvenTonesTestArray[64]=
24269 + 0,1,0,1,0,1,0,1, // Tones 01-08
24270 + 0,1,0,1,0,1,0,1, // Tones 09-16
24271 + 0,1,0,1,0,1,0,1, // Tones 17-24
24272 + 0,1,0,1,0,1,0,1, // Tones 25-32
24273 + 0,1,0,1,0,1,0,1, // Tones 33-40
24274 + 0,1,0,1,0,1,0,1, // Tones 41-48
24275 + 0,1,0,1,0,1,0,1, // Tones 49-56
24276 + 0,1,0,1,0,1,0,1 // Tones 57-64
24279 +static unsigned char analogOddTonesTestArray[64]=
24281 + 1,0,1,0,1,0,1,0, // Tones 01-08
24282 + 1,0,1,0,1,0,1,0, // Tones 09-16
24283 + 1,0,1,0,1,0,1,0, // Tones 17-24
24284 + 1,0,1,0,1,0,1,0, // Tones 25-32
24285 + 1,0,1,0,1,0,1,0, // Tones 33-40
24286 + 1,0,1,0,1,0,1,0, // Tones 41-48
24287 + 1,0,1,0,1,0,1,0, // Tones 49-56
24288 + 1,0,1,0,1,0,1,0 // Tones 57-64
24291 +int shim_osGetCpuFrequency(void)
24296 +static void tn7dsl_adiag(int Test, unsigned char *missingTones)
24300 + rc = dslhal_diags_anlg_setMissingTones(pIhw,missingTones);
24303 + printk(" failed to set Missing town\n");
24307 +/*********** Start the actual test **********************/
24311 + printk("TX REVERB Test\n");
24312 + rc = dslhal_support_writeHostMailbox(pIhw, HOST_TXREVERB, 0, 0, 0);
24315 + printk("HOST_TXREVERB failed\n");
24322 + dprintf(0,"TX MEDLEY Test\n");
24323 + rc = dslhal_support_writeHostMailbox(pIhw, HOST_TXMEDLEY, 0, 0, 0);
24327 + dprintf(4,"dslhal_diags_anlg_testA() done\n");
24332 +static void tn7dsl_diagnostic_test(char *data)
24334 + if(!strcmp(data, "ADIAGRALL"))
24336 + printk("TX Reverb All tone\n");
24337 + tn7dsl_adiag(0,analogAllTonesTestArray);
24340 + if(!strcmp(data, "ADIAGRNONE"))
24342 + printk("TX Reverb No tone\n");
24343 + tn7dsl_adiag(0,analogNoTonesTestArray);
24346 + if(!strcmp(data, "ADIAGREVEN"))
24348 + printk("TX Reverb Even tone\n");
24349 + tn7dsl_adiag(0,analogEvenTonesTestArray);
24352 + if(!strcmp(data, "ADIAGRODD"))
24354 + printk("TX Reverb Odd tone\n");
24355 + tn7dsl_adiag(0,analogOddTonesTestArray);
24358 + if(!strcmp(data, "ADIAGMALL"))
24360 + printk("TX Mdelay All tone\n");
24361 + tn7dsl_adiag(1,analogAllTonesTestArray);
24364 + if(!strcmp(data, "ADIAGMNONE"))
24366 + printk("TX Mdelay No tone\n");
24367 + tn7dsl_adiag(1,analogNoTonesTestArray);
24370 + if(!strcmp(data, "ADIAGMEVEN"))
24372 + printk("TX Mdelay Even tone\n");
24373 + tn7dsl_adiag(1,analogEvenTonesTestArray);
24376 + if(!strcmp(data, "ADIAGMODD"))
24378 + printk("TX Mdelay Odd tone\n");
24379 + tn7dsl_adiag(1,analogOddTonesTestArray);
24382 + if(!strcmp(data, "ADIAGQUIET"))
24384 + dslhal_api_sendIdle(pIhw);
24387 + if(!strncmp(data, "ADIAGRN", 7))
24389 + char tones[64], tmp[4];
24396 + nth = os_atoi(tmp);
24398 + for(i=0;i<64;i++)
24400 + if(((i+1)% nth)==0)
24409 + printk("TX Reverb with %dth tones missing.\n", nth);
24410 + tn7dsl_adiag(0,tones);
24413 + if(!strncmp(data, "ADIAGMN", 7))
24415 + char tones[64], tmp[4];
24421 + nth = os_atoi(tmp);
24423 + for(i=0;i<64;i++)
24425 + if(((i+1)% nth)==0)
24434 + printk("TX Mdelay with %dth tones missing.\n", nth);
24435 + tn7dsl_adiag(1,tones);
24445 +tn7dsl_chng_modulation(void* data)
24447 + //printk("DSL Modem Retraining\n");
24449 + if(!strcmp(data, "T1413"))
24451 + printk("retraining in T1413 mode\n");
24452 + dslhal_api_setTrainingMode(pIhw, T1413_MODE);
24453 + dslhal_api_sendQuiet(pIhw);
24456 + if(!strcmp(data, "GDMT"))
24458 + dslhal_api_setTrainingMode(pIhw, GDMT_MODE);
24459 + dslhal_api_sendQuiet(pIhw);
24462 + if(!strcmp(data, "GLITE"))
24464 + dslhal_api_setTrainingMode(pIhw, GLITE_MODE);
24465 + dslhal_api_sendQuiet(pIhw);
24468 + if(!strcmp(data, "MMODE"))
24470 + dslhal_api_setTrainingMode(pIhw, MULTI_MODE);
24471 + dslhal_api_sendQuiet(pIhw);
24474 + if(!strcmp(data, "NMODE"))
24476 + dslhal_api_setTrainingMode(pIhw, NO_MODE);
24477 + dslhal_api_sendQuiet(pIhw);
24482 + tn7dsl_diagnostic_test(data);
24489 +#ifdef CONFIG_LED_MODULE
24490 +static void tn7dsl_led_on(unsigned long parm)
24492 + dslhal_api_configureLed(pIhw,parm, 0);
24496 +static void tn7dsl_led_off(unsigned long parm)
24498 + dslhal_api_configureLed(pIhw,parm, 1);
24501 +static void tn7dsl_led_init(unsigned long parm)
24503 + dslhal_api_configureLed(pIhw,parm, 2);
24507 +static void tn7dsl_register_dslss_led(void)
24509 +#ifdef CONFIG_LED_MODULE
24511 + // register led0 with led module
24512 + ledreg[0].param = 0;
24513 + ledreg[0].init = (void *)tn7dsl_led_init;
24514 + ledreg[0].onfunc = (void *)tn7dsl_led_on;
24515 + ledreg[0].offfunc = (void *)tn7dsl_led_off;
24516 + register_led_drv(LED_NUM_1, &ledreg[0]);
24518 + // register led1 output with led module
24519 + ledreg[1].param = 1;
24520 + ledreg[1].init = (void *)tn7dsl_led_init;
24521 + ledreg[1].onfunc = (void *)tn7dsl_led_on;
24522 + ledreg[1].offfunc = (void *)tn7dsl_led_off;
24523 + register_led_drv(LED_NUM_2, &ledreg[1]);
24527 +static int tn7dsl_reload_overlay(void)
24530 + spinlock_t overlayLock;
24532 + init_kthread(&overlay_thread, "adsl");
24533 + down(&adsl_sem_overlay);
24537 + if(pIhw->lConnected == 0)
24539 + spin_lock_irqsave(&overlayLock, overlayFlag);
24540 + dslhal_support_restoreTrainingInfo(pIhw);
24541 + spin_unlock_irqrestore(&overlayLock, overlayFlag);
24543 + down(&adsl_sem_overlay);
24551 diff -urN linux.old/drivers/atm/sangam_atm/tn7sar.c linux.dev/drivers/atm/sangam_atm/tn7sar.c
24552 --- linux.old/drivers/atm/sangam_atm/tn7sar.c 1970-01-01 01:00:00.000000000 +0100
24553 +++ linux.dev/drivers/atm/sangam_atm/tn7sar.c 2005-07-10 08:02:01.454109840 +0200
24555 +/******************************************************************************
24556 + * FILE PURPOSE: OS files for CPSAR
24557 + ******************************************************************************
24558 + * FILE NAME: tn7sar.c
24560 + * DESCRIPTION: This file contains source for required os files for CPSAR
24562 + * (C) Copyright 2002, Texas Instruments Inc
24565 + * Revision History:
24566 + * 0/11/02 Zhicheng Tang, created.
24568 + *******************************************************************************/
24570 +#include <linux/config.h>
24571 +#include <linux/kernel.h>
24572 +#include <linux/module.h>
24573 +#include <linux/init.h>
24574 +#include <linux/atmdev.h>
24575 +#include <linux/delay.h>
24576 +#include <linux/spinlock.h>
24577 +#include <linux/smp_lock.h>
24578 +#include <asm/io.h>
24579 +#include <asm/mips-boards/prom.h>
24580 +#include <linux/proc_fs.h>
24581 +#include <linux/string.h>
24582 +#include <linux/ctype.h>
24585 +#define _CPHAL_AAL5
24586 +#define _CPHAL_SAR
24587 +#define _CPHAL_HAL
24588 +typedef void OS_PRIVATE;
24589 +typedef void OS_DEVICE;
24590 +typedef void OS_SENDINFO;
24591 +typedef void OS_RECEIVEINFO;
24592 +typedef void OS_SETUP;
24594 +#include "cpswhal_cpsar.h"
24595 +#include "tn7atm.h"
24596 +#include "tn7api.h"
24599 +/* PDSP Firmware files */
24600 +#include "tnetd7300_sar_firm.h"
24605 + PACKET_TYPE_AAL5,
24606 + PACKET_TYPE_NULL,
24608 + PACKET_TYPE_TRANS,
24615 + OAM_PING_SUCCESS,
24616 + OAM_PING_PENDING,
24617 + OAM_PING_NOT_STARTED
24620 +/* PDSP OAM General Purpose Registers (@todo: These need to be used in the HAL!) */
24622 +#define SAR_PDSP_HOST_OAM_CONFIG_REG_ADDR 0xa3000020
24623 +#define SAR_PDSP_OAM_CORR_REG_ADDR 0xa3000024
24624 +#define SAR_PDSP_OAM_LB_RESULT_REG_ADDR 0xa3000028
24625 +#define SAR_PDSP_OAM_F5LB_COUNT_REG_ADDR 0xa300002c
24626 +#define SAR_PDSP_OAM_F4LB_COUNT_REG_ADDR 0xa3000030
24628 +#define SAR_FREQUNCY 50000000
24630 +#define AAL5_PARM "id=aal5, base = 0x03000000, offset = 0, int_line=15, ch0=[RxBufSize=1522; RxNumBuffers = 32; RxServiceMax = 50; TxServiceMax=50; TxNumBuffers=32; CpcsUU=0x5aa5; TxVc_CellRate=0x3000; TxVc_AtmHeader=0x00000640]"
24631 +#define SAR_PARM "id=sar,base = 0x03000000, reset_bit = 9, offset = 0; UniNni = 0, PdspEnable = 1"
24632 +#define RESET_PARM "id=ResetControl, base=0xA8611600"
24633 +#define CH0_PARM "RxBufSize=1522, RxNumBuffers = 32, RxServiceMax = 50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
24635 +#define MAX_PVC_TABLE_ENTRY 16
24637 +sar_stat_t sarStat;
24639 +typedef struct _channel_parm
24641 + unsigned int RxBufSize;
24642 + unsigned int RxNumBuffers;
24643 + unsigned int RxServiceMax;
24644 + unsigned int TxServiceMax;
24645 + unsigned int TxNumBuffers;
24646 + unsigned int CpcsUU;
24647 + unsigned int TxVc_CellRate;
24648 + unsigned int TxVc_AtmHeader;
24651 +typedef struct _aal5_parm
24653 + unsigned int base;
24654 + unsigned int offset;
24655 + unsigned int int_line;
24656 + channel_parm_t chan[8];
24660 +typedef struct _sar_parm
24662 + unsigned int base;
24663 + unsigned int reset_bit;
24664 + unsigned int offset;
24665 + unsigned int UniNni;
24668 +typedef struct _pvc_table
24675 +static aal5_parm_t aal5Parm;
24676 +static sar_parm_t sarParm;
24677 +static char *pAal5, *pSar, *pReset;
24678 +static int oam_type;
24679 +static unsigned int oamPingStatus;
24680 +static int oamAtmHdr;
24681 +static int oamLbTimeout;
24682 +static char parm_data[1024];
24683 +static char aal5Data[1024];
24684 +static char sarData[1024];
24685 +static char resetData[256];
24686 +static pvc_table pvc_result[MAX_PVC_TABLE_ENTRY];
24688 +/* external function */
24689 +extern int __guDbgLevel;
24691 +/* gloabal function */
24692 +unsigned int oamFarLBCount[4];
24693 +/* end of gloabal function */
24695 +/* internal APIs */
24696 +static int tn7sar_atm_header(int vpi, int vci);
24697 +static void tn7sar_record_pvc(int atmheader);
24699 +/*end of internal APIs */
24700 +spinlock_t sar_lock;
24702 +/* HAL OS support functions */
24705 +unsigned long tn7sar_strtoul(const char *str, char **endptr, int base)
24707 + unsigned long ret;
24709 + ret= simple_strtoul(str, endptr, base);
24713 +static void *tn7sar_malloc(unsigned int size)
24715 + return(kmalloc(size, GFP_KERNEL));
24718 +static unsigned long lockflags;
24719 +static void tn7sar_critical_on(void)
24721 + spin_lock_irqsave(&sar_lock,lockflags);
24724 +static void tn7sar_critical_off(void)
24726 + spin_unlock_irqrestore(&sar_lock,lockflags);
24729 +static void tn7sar_data_invalidate(void *pmem, int size)
24731 + unsigned int i,Size=(((unsigned int)pmem)&0xf)+size;
24733 + for (i=0;i<Size;i+=16,pmem+=16)
24735 + __asm__(" .set mips3 ");
24736 + __asm__("cache 17, (%0)" : : "r" (pmem));
24737 + __asm__(" .set mips0 ");
24742 +static void tn7sar_data_writeback(void *pmem, int size)
24744 + unsigned int i,Size=(((unsigned int)pmem)&0xf)+size;
24746 + for (i=0;i<Size;i+=16,pmem+=16)
24748 + __asm__(" .set mips3 ");
24749 + __asm__(" cache 25, (%0)" : : "r" (pmem));
24750 + __asm__(" .set mips0 ");
24756 +tn7sar_find_device(int unit, const char *find_name, void *device_info)
24761 + ptr = (char **)device_info;
24762 + dprintf(3,"tn7sar_find_device\n");
24763 + if(strcmp(find_name, "aal5")==0)
24765 + //dprintf(4,"pAal5=%s\n", pAal5);
24768 + else if(strcmp(find_name, "sar")==0)
24770 + dprintf(3, "pSar=%s\n", pSar);
24773 + else if(strcmp(find_name, "reset")==0)
24775 + dprintf(3, "pReset=%s\n", pReset);
24779 + device_info = NULL;
24785 +tn7sar_get_device_parm_uint(void *dev_info, const char *param, unsigned int *value)
24790 + char val_str[64];
24791 + unsigned int val;
24794 + dprintf(6, "tn7sar_get_device_parm_uint()\n");
24796 + dev_str = (char *)dev_info;
24797 + dprintf(3, "parm=%s\n", param);
24798 + pMatch = strstr(dev_str, param);
24799 + //dprintf(4, "pMatch=%s\n", pMatch);
24802 + //get "=" position
24803 + while(pMatch[i] != 0x3d)
24808 + // get rid of spaces
24809 + while(pMatch[i]==0x20)
24814 + if(pMatch[i]==0x30)
24816 + if(pMatch[i+1] == 0x58 || pMatch[i+1] == 0x78)
24823 + // get next delineator
24824 + while(pMatch[i] != 0x2c && pMatch[i] != 0x0)
24826 + val_str[j]=pMatch[i];
24831 + //dprintf(4, "val_str=\n%s\n", val_str);
24832 + //xdump(val_str, strlen(val_str) + 1, 4);
24833 + val = simple_strtoul(val_str, (char **)NULL, base);
24834 + dprintf(4, "val =%d\n", val);
24840 + dprintf(3, "match not found.\n");
24841 + if(strcmp(dev_str, "debug")==0)
24843 + dprintf(6,"debug..\n");
24850 +static int tn7sar_get_device_parm_value(void *dev_info, const char *param, void *value)
24858 + dprintf(3, "tn7sar_get_device_parm_value().\n");
24860 + pVal = (char *) parm_data;
24861 + dev_str = (char *)dev_info;
24862 + dprintf(3, "dev_info: \n%s\n", dev_str);
24863 + dprintf(3, "param=%s\n", param);
24864 + if(strcmp(param, "Ch0")==0)
24866 + *(char **)value = CH0_PARM;
24867 + dprintf(3, "value =%s\n", *(char **)value);
24871 + pMatch = strstr(dev_str, param);
24874 + //get "=" position
24875 + while(pMatch[i] != 0x3d)
24880 + // get rid of spaces
24881 + while(pMatch[i]==0x20)
24886 + if(pMatch[i] != 0x5b) //"["
24888 + // get next delineator
24889 + while(pMatch[i] != 0x2c && pMatch[i] != 0x0)
24891 + pVal[j] = pMatch[i];
24897 + *(char **)value = pVal;
24903 + while(pMatch[i] != 0x5d)
24905 + if(pMatch[i] == 0x3b) //";"
24908 + pVal[j] = pMatch[i];
24913 + *(char **)value = pVal;
24922 +static void tn7sar_free(void *pmem)
24928 +tn7sar_free_buffer(OS_RECEIVEINFO *os_receive_info, void *pmem)
24930 + tn7atm_free_rx_skb(os_receive_info);
24933 +static void tn7sar_free_dev(void *pmem)
24938 +static void tn7sar_free_dma_xfer(void *pmem)
24945 +tn7sar_control(void *dev_info, const char *key, const char *action, void *value)
24947 + int ret_val = -1;
24949 + if (strcmp(key, "Firmware") == 0)
24951 + if (strcmp(action, "Get") == 0)
24953 + *(int **)value = &SarPdspFirmware[0];
24958 + if (strcmp(key, "FirmwareSize") == 0)
24960 + if (strcmp(action, "Get") == 0)
24962 + *(int *)value = sizeof(SarPdspFirmware);
24967 + if (strcmp(key, "OamLbResult") == 0)
24969 + dprintf(2, "get looback source call back\n");
24970 + if (strcmp(action, "Set") == 0)
24972 + dprintf(2, "oam result = %d\n", *(unsigned int *)value);
24973 + oamFarLBCount[oam_type] = oamFarLBCount[oam_type] + *(unsigned int *)value;
24974 + if(oamPingStatus == OAM_PING_PENDING)
24976 + oamPingStatus = *(unsigned int *)value;
24977 + if(oamPingStatus == OAM_PING_SUCCESS)
24980 + tn7sar_record_pvc(oamAtmHdr);
24988 + if (strcmp(key, "SarFreq") == 0)
24990 + if (strcmp(action, "Get") == 0)
24992 + *(int *)value = SAR_FREQUNCY;
25001 +tn7sar_sarhal_isr_register(OS_DEVICE *os_dev, int(*hal_isr)(HAL_DEVICE *, int *), int interrupt_num)
25003 + tn7atm_sarhal_isr_register(os_dev, hal_isr, interrupt_num);
25007 +tn7sar_isr_unregister(OS_DEVICE *os_dev, int interrupt_num)
25014 +tn7sar_malloc_rxbuffer(unsigned int size, void *mem_base, unsigned int mem_range, HAL_DEVICE *hal_dev,
25015 + HAL_RECEIVEINFO *hal_info, OS_RECEIVEINFO **os_receive_info, OS_DEVICE *os_dev)
25017 + return tn7atm_allocate_rx_skb(os_dev, os_receive_info, size);
25021 +tn7sar_malloc_dev(unsigned int size)
25023 + return(kmalloc(size, GFP_KERNEL));
25027 +tn7sar_malloc_dma_xfer(unsigned int size, void *mem_base, unsigned int mem_range)
25029 + dprintf(4, "tn7sar_malloc_dma_xfer, size =%d\n", size);
25031 + return (kmalloc(size, GFP_DMA |GFP_KERNEL));
25036 +tn7sar_memset(void *dst, int set_char, size_t count)
25038 + return (memset(dst, set_char, count));
25041 +static int tn7sar_printf(const char *format, ...)
25043 + /* TODO: add debug levels */
25044 + static char buff[256];
25047 + va_start( ap, format);
25048 + vsprintf((char *)buff, format, ap);
25051 + printk("SAR HAL: %s\n", buff);
25055 +static void tn7sar_record_pvc(int atmheader)
25060 + vci = 0xffff & (atmheader >> 4);
25061 + vpi = 0xff & (atmheader >> 20);
25062 + for(i=0;i<MAX_PVC_TABLE_ENTRY;i++)
25064 + if(pvc_result[i].bInUse)
25066 + if(pvc_result[i].vpi == vpi && pvc_result[i].vci == vci)
25072 + for(i=0;i<MAX_PVC_TABLE_ENTRY;i++)
25074 + if(pvc_result[i].bInUse == 0)
25076 + pvc_result[i].bInUse = 1;
25077 + pvc_result[i].vpi = vpi;
25078 + pvc_result[i].vci = vci;
25085 +static void tn7sar_clear_pvc_table(void)
25089 + for(i=0;i<MAX_PVC_TABLE_ENTRY; i++)
25091 + pvc_result[i].bInUse = 0;
25092 + pvc_result[i].vpi = 0;
25093 + pvc_result[i].vci = 0;
25097 +int tn7sar_process_unmatched_oam(FRAGLIST *frag_list, unsigned int frag_count, unsigned int packet_size, unsigned int mode)
25100 + FRAGLIST *local_list;
25102 + unsigned int atmHdr;
25104 + local_list = frag_list;
25106 + for(i=0;i<(int)frag_count;i++)
25108 + tn7sar_data_invalidate(local_list->data, (int)local_list->len);
25111 + local_list = frag_list;
25112 + if((mode>>31)) /*vci, vpi is attached */
25114 + atmHdr = *(unsigned int *)frag_list->data;
25115 + tn7sar_record_pvc(atmHdr);
25116 + if(atmHdr & 0x8) //oam cell
25118 + atmHdr &= 0xfffffff0;
25119 + if(atmHdr == oamAtmHdr)
25121 + if(oamPingStatus == OAM_PING_PENDING)
25123 + oamPingStatus = OAM_PING_SUCCESS;
25124 + oamFarLBCount[oam_type] = oamFarLBCount[oam_type] + 1;
25136 +tn7sar_receive(OS_DEVICE *os_dev,FRAGLIST *frag_list, unsigned int frag_count, unsigned int packet_size,
25137 + HAL_RECEIVEINFO *hal_receive_info, unsigned int mode)
25140 + struct atm_dev *dev;
25141 + Tn7AtmPrivate *priv;
25142 + HAL_FUNCTIONS *pHalFunc;
25143 + HAL_DEVICE *pHalDev;
25147 + dprintf(4, "tn7sar_receive\n");
25149 + dev = (struct atm_dev *)os_dev;
25150 + priv= (Tn7AtmPrivate *)dev->dev_data;
25151 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25152 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25155 + /* Mode contains channel info */
25156 + ch = (mode & 0xFF);
25160 + tn7sar_process_unmatched_oam(frag_list, frag_count, packet_size, mode);
25161 + pHalFunc->RxReturn(hal_receive_info, 0);
25165 + if(frag_count > 1 || frag_list->len == 0)
25167 + printk("Packet fragment count > 1, not handdle.\n");
25171 + tn7sar_data_invalidate(frag_list->data, (int)frag_list->len);
25172 + bRet=tn7atm_receive(os_dev, ch, packet_size, frag_list->OsInfo, frag_list->data);
25176 + sarStat.rxPktCnt++;
25177 + sarStat.rxBytes += packet_size;
25178 + pHalFunc->RxReturn(hal_receive_info, 1);
25182 + pHalFunc->RxReturn(hal_receive_info, 0);
25189 +tn7sar_send_complete(OS_SENDINFO *osSendInfo)
25191 + return (tn7atm_send_complete(osSendInfo));
25195 +tn7sar_teardown_complete(OS_DEVICE *OsDev, int ch, int Dir)
25202 +unsigned int tn7sar_virt(unsigned int address)
25204 + return phys_to_virt(address);
25208 +int tn7sar_init_module(OS_FUNCTIONS *os_funcs)
25210 + dprintf(4, "tn7sar_init_module\n");
25211 + if( os_funcs == 0 )
25215 + os_funcs->Control = tn7sar_control;
25216 + os_funcs->CriticalOn = tn7sar_critical_on;
25217 + os_funcs->CriticalOff = tn7sar_critical_off;
25218 + os_funcs->DataCacheHitInvalidate = tn7sar_data_invalidate;
25219 + os_funcs->DataCacheHitWriteback = tn7sar_data_writeback;
25220 + os_funcs->DeviceFindInfo = tn7sar_find_device;
25221 + os_funcs->DeviceFindParmUint = tn7sar_get_device_parm_uint;
25222 + os_funcs->DeviceFindParmValue = tn7sar_get_device_parm_value;
25223 + os_funcs->Free = tn7sar_free;
25224 + os_funcs->FreeRxBuffer = tn7sar_free_buffer;
25225 + os_funcs->FreeDev = tn7sar_free_dev;
25226 + os_funcs->FreeDmaXfer = tn7sar_free_dma_xfer;
25227 + os_funcs->IsrRegister = tn7sar_sarhal_isr_register;
25228 + os_funcs->IsrUnRegister = tn7sar_isr_unregister;
25229 + os_funcs->Malloc = tn7sar_malloc;
25230 + os_funcs->MallocRxBuffer = tn7sar_malloc_rxbuffer;
25231 + os_funcs->MallocDev = tn7sar_malloc_dev;
25232 + os_funcs->MallocDmaXfer = tn7sar_malloc_dma_xfer;
25233 + os_funcs->Memset = tn7sar_memset;
25234 + os_funcs->Printf = tn7sar_printf;
25235 + os_funcs->Receive = tn7sar_receive;
25236 + os_funcs->SendComplete = tn7sar_send_complete;
25237 + os_funcs->Strcmpi = strcmp;
25238 + os_funcs->Sprintf = sprintf;
25239 + os_funcs->Strlen = strlen;
25240 + os_funcs->Strstr = strstr;
25241 + os_funcs->Strtoul = tn7sar_strtoul;
25242 + os_funcs->TeardownComplete = tn7sar_teardown_complete;
25248 +static void tn7sar_init_dev_parm(void)
25254 + //strcpy(aal5Parm.id, "aal5");
25255 + aal5Parm.base = 0x03000000;
25256 + aal5Parm.offset = 0;
25257 + aal5Parm.int_line=15;
25258 + aal5Parm.chan[0].RxBufSize=1600;
25259 + aal5Parm.chan[0].RxNumBuffers = 32;
25260 + aal5Parm.chan[0].RxServiceMax = 50;
25261 + aal5Parm.chan[0].TxServiceMax=50;
25262 + aal5Parm.chan[0].TxNumBuffers=32;
25263 + aal5Parm.chan[0].CpcsUU=0x5aa5;
25264 + aal5Parm.chan[0].TxVc_CellRate=0x3000;
25265 + aal5Parm.chan[0].TxVc_AtmHeader=0x00000640;
25268 + memcpy(&aal5Parm.chan[i], &aal5Parm.chan[0], sizeof(aal5Parm.chan[0]));
25273 + //strcpy(sarParm.id, "sar");
25274 + sarParm.base = 0x03000000;
25275 + sarParm.reset_bit = 9;
25276 + sarParm.offset = 0;
25277 + sarParm.UniNni = 0;
25279 + pAal5 = aal5Data;
25281 + pReset = resetData;
25282 + strcpy(pAal5, AAL5_PARM);
25283 + strcpy(pSar, SAR_PARM);
25284 + strcpy(pReset, RESET_PARM);
25289 +int tn7sar_get_stats(void *priv1)
25291 + HAL_FUNCTIONS *pHalFunc;
25292 + HAL_DEVICE *pHalDev;
25293 + Tn7AtmPrivate *priv;
25295 + unsigned int *pSarStat, *pStateBase;
25296 + char statString[64];
25299 + dprintf(2, "tn7sar_get_stats\n");
25301 + priv = (Tn7AtmPrivate *)priv1;
25302 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25303 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25305 + //memset(&sarStat, 0, sizeof(sarStat));
25306 + sarStat.txErrors = 0;
25307 + sarStat.rxErrors = 0;
25308 + for(i=0;i<MAX_DMA_CHAN;i++)
25310 + if(priv->lut[i].inuse)
25314 + len=sprintf(statString, "Stats;0;%d", priv->lut[i].chanid);
25315 + statString[len]=0;
25316 + dprintf(2, "statString=%s\n",statString);
25317 + pHalFunc->Control(pHalDev, statString, "Get", &pSarStat);
25318 + pStateBase = pSarStat;
25321 + if((char *)*pSarStat == NULL)
25323 + dprintf(2, "%s\n", (char *) *pSarStat);
25325 + dprintf(2, "%s\n", (char *) *pSarStat);
25326 + sarStat.rxErrors += os_atoul((char *) *pSarStat);
25330 + kfree(pStateBase);
25337 +int tn7sar_setup_oam_channel(Tn7AtmPrivate *priv)
25340 + CHANNEL_INFO chInfo;
25341 + HAL_FUNCTIONS *pHalFunc;
25342 + HAL_DEVICE *pHalDev;
25344 + dprintf(4, "tn7sar_setup_oam_channel\n");
25346 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25347 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25349 + memset(&chInfo, 0xff, sizeof(chInfo));
25351 + /* channel specific */
25352 + chInfo.Channel = 15; /* hardcoded for last channel */
25353 + chInfo.Direction = 0;
25354 + chInfo.Vci = 30; /* just need below 32 */
25356 + chInfo.TxVc_QosType = 2;
25359 + chInfo.PktType = PACKET_TYPE_TRANS;
25360 + chInfo.TxServiceMax = 2;
25361 + chInfo.RxServiceMax = 2;
25362 + chInfo.TxNumQueues = 1;
25363 + chInfo.TxNumBuffers = 4;
25364 + chInfo.RxNumBuffers = 4;
25365 + chInfo.RxBufSize = 256;
25366 + chInfo.RxVc_OamToHost = 0;
25367 + chInfo.RxVp_OamToHost = 0;
25368 + chInfo.FwdUnkVc = 1; //enable forwarding of unknown vc
25369 + chInfo.TxVc_AtmHeader = tn7sar_atm_header((int)chInfo.Vpi, chInfo.Vci);
25370 + chInfo.RxVc_AtmHeader = tn7sar_atm_header((int)chInfo.Vpi, chInfo.Vci);
25371 + chInfo.TxVp_AtmHeader = tn7sar_atm_header((int)chInfo.Vpi, 0);
25372 + chInfo.RxVp_AtmHeader = tn7sar_atm_header((int)chInfo.Vpi, 0);
25374 + dprintf(4, "TxVc_AtmHeader=0x%x\n", chInfo.TxVc_AtmHeader);
25376 + if(pHalFunc->ChannelSetup(pHalDev, &chInfo, NULL))
25378 + printk("failed to setup channel =%d.\n", chan);
25382 + // claiming the channel
25383 + priv->lut[chan].vpi = 0;
25384 + priv->lut[chan].vci = 30;
25385 + priv->lut[chan].chanid = chan;
25386 + priv->lut[chan].inuse = 1;
25390 +int tn7sar_init(struct atm_dev *dev, Tn7AtmPrivate *priv)
25393 + int hal_funcs_size;
25395 + HAL_FUNCTIONS *pHalFunc;
25396 + HAL_DEVICE *pHalDev;
25397 + OS_FUNCTIONS *pOsFunc;
25399 + char *pLbTimeout;
25403 + dprintf(4, "tn7sar_init\n");
25405 + pOsFunc = (OS_FUNCTIONS *)kmalloc(sizeof(OS_FUNCTIONS), GFP_KERNEL);
25408 + priv->pSarOsFunc = ( void *)pOsFunc;
25410 + /* init boot parms */
25411 + tn7sar_init_dev_parm();
25413 + /* init sar os call back functions */
25414 + retCode = tn7sar_init_module(pOsFunc);
25415 + if (retCode != 0) /* error */
25417 + printk("Failed to init SAR OS Functions\n");
25421 + /* Init sar hal */
25422 + retCode = cpaal5InitModule(&pHalDev, (OS_DEVICE*) dev, &pHalFunc,
25423 + pOsFunc, sizeof(OS_FUNCTIONS), &hal_funcs_size, 0);
25424 + if (retCode != 0) /* error */
25426 + printk("Failed to init SAR HAL\n");
25430 + /* sanity check */
25431 + if (pHalDev == NULL || pHalFunc == NULL || hal_funcs_size != sizeof(HAL_FUNCTIONS) )
25433 + printk("Invalid SAR hal and/or functions.\n");
25437 + /* remeber HAL pointers */
25438 + priv->pSarHalDev = (void *)pHalDev;
25439 + priv->pSarHalFunc = (void *)pHalFunc;
25441 + /* Probe for the Device to get hardware info from driver */
25442 + retCode = pHalFunc->Probe(pHalDev);
25445 + printk("SAR hal probing error.\n");
25449 + /* init sar hal */
25450 + retCode = pHalFunc->Init(pHalDev);
25451 + if (retCode != 0) /* error */
25454 + printk("pHalFunc->Init failed. err code =%d\n", retCode);
25458 + /* open hal module */
25459 + retCode = pHalFunc->Open(pHalDev);
25460 + if (retCode != 0) /* error */
25462 + printk("pHalFunc->open failed, err code: %d\n",retCode );
25466 + /* init sar for firmware oam */
25468 + pHalFunc->Control(pHalDev,"OamMode", "Set", &oamMod);
25470 + /* read in oam lb timeout value */
25471 + pLbTimeout = prom_getenv("oam_lb_timeout");
25474 + lbTimeout =tn7sar_strtoul(pLbTimeout, NULL, 10);
25475 + oamLbTimeout = lbTimeout;
25476 + pHalFunc->Control(pHalDev,"OamLbTimeout", "Set", &lbTimeout);
25480 + oamLbTimeout = 5000;
25483 + oamFarLBCount[0]=0;
25484 + oamFarLBCount[1]=0;
25485 + oamFarLBCount[2]=0;
25486 + oamFarLBCount[3]=0;
25488 + memset(&sarStat, 0 , sizeof(sarStat));
25490 + /* setup channel 15 for oam operation */
25491 + tn7sar_setup_oam_channel(priv);
25492 + dprintf(4, "tn7sar_init done");
25497 +tn7sar_atm_header(int vpi, int vci)
25501 + unsigned char byte[4];
25502 + unsigned int dword;
25508 + atm_h.byte[0] = 0;
25509 + atm_h.byte[0] |= (itmp << 4);
25510 + atm_h.byte[1] = ((vci & 0xff0) >> 4);
25511 + atm_h.byte[2] = 0;
25512 + atm_h.byte[2] |= ((vci & 0xf000) >>12);;
25513 + atm_h.byte[2] |= ((vpi & 0xf) << 4);
25514 + atm_h.byte[3] = 0;
25515 + atm_h.byte[3] = ((vpi & 0xff0) >> 4);
25516 + return atm_h.dword;
25519 +int tn7sar_activate_vc(Tn7AtmPrivate *priv, short vpi, int vci, int pcr, int scr, int mbs, int cdvt, int chan, int qos)
25521 + CHANNEL_INFO chInfo;
25522 + HAL_FUNCTIONS *pHalFunc;
25523 + HAL_DEVICE *pHalDev;
25525 + dprintf(4, "tn7sar_activate_vc\n");
25527 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25528 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25530 + memset(&chInfo, 0xff, sizeof(chInfo));
25532 + /* channel specific */
25533 + chInfo.Channel = chan;
25534 + chInfo.Direction = 0;
25535 + chInfo.Vci = vci;
25536 + chInfo.Vpi = vpi;
25537 + chInfo.TxVc_QosType = qos;
25538 + chInfo.Priority = qos;
25540 + if(chInfo.TxVc_QosType == 1) /* if the connection is VBR than set the DaMask value to tell the schedular to accumalte the credit */
25542 + chInfo.DaMask = 1;
25544 + chInfo.TxVc_Mbs = mbs; /* use pcr as MBS */
25545 + pcr = SAR_FREQUNCY/pcr;
25546 + scr = SAR_FREQUNCY/scr;
25547 + chInfo.TxVc_CellRate = scr;
25548 + chInfo.TxVc_Pcr = pcr;
25551 + chInfo.PktType = PACKET_TYPE_AAL5;
25552 + chInfo.TxServiceMax = TX_SERVICE_MAX;
25553 + chInfo.RxServiceMax = RX_SERVICE_MAX;
25554 + chInfo.TxNumQueues = TX_QUEUE_NUM;
25555 + chInfo.TxNumBuffers = TX_BUFFER_NUM;
25556 + chInfo.RxNumBuffers = RX_BUFFER_NUM;
25557 + chInfo.RxBufSize = RX_BUFFER_SIZE;
25558 + chInfo.RxVc_OamToHost = 0;
25559 + chInfo.RxVp_OamToHost = 0;
25560 + chInfo.TxVc_AtmHeader = tn7sar_atm_header((int)vpi, vci);
25561 + chInfo.RxVc_AtmHeader = tn7sar_atm_header((int)vpi, vci);
25562 + chInfo.TxVp_AtmHeader = tn7sar_atm_header((int)vpi, 0);
25563 + chInfo.RxVp_AtmHeader = tn7sar_atm_header((int)vpi, 0);
25564 + chInfo.CpcsUU = 0;
25566 + dprintf(4, "TxVc_AtmHeader=0x%x\n", chInfo.TxVc_AtmHeader);
25568 + if(pHalFunc->ChannelSetup(pHalDev, &chInfo, NULL))
25570 + printk("failed to setup channel =%d.\n", chan);
25578 +int tn7sar_send_packet(Tn7AtmPrivate *priv, int chan, void *new_skb, void *data,unsigned int len, int priority)
25580 + FRAGLIST fragList;
25581 + unsigned int mode;
25582 + HAL_FUNCTIONS *pHalFunc;
25583 + HAL_DEVICE *pHalDev;
25585 + dprintf(4, "tn7sar_send_packet\n");
25586 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25587 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25589 + fragList.len = len;
25590 + fragList.data = (void *)data;
25592 + xdump((char *)fragList.data , fragList.len, 6);
25596 + 18 oam cell, 1 = true, 0=false
25597 + 17-16 oam type, 0=F4 seg, 1=F4 End, 2=F5 seg, 3=F5 end
25598 + 15-08 transimit queue, current, 0=priority queue, 1=normal queue
25599 + 07-00 channel number
25602 + mode |= (0xff & chan);
25603 + mode |= ((0xff & priority) << 8);
25605 + dprintf(4, "mode = %d\n", mode);
25607 + tn7sar_data_writeback(fragList.data, len);
25608 + if(pHalFunc->Send(pHalDev, &fragList, 1, len, new_skb, mode) != 0)
25610 + dprintf(1, "SAR hal failed to send packet.\n");
25613 + //tn7sar_get_stats(priv);
25614 + sarStat.txPktCnt++;
25615 + sarStat.txBytes +=len;
25621 +int tn7sar_handle_interrupt(struct atm_dev *dev, Tn7AtmPrivate *priv)
25625 + HAL_FUNCTIONS *pHalFunc;
25626 + HAL_DEVICE *pHalDev;
25627 + int (*halIsr)(HAL_DEVICE *halDev, int *work);
25629 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25630 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25631 + halIsr = priv->halIsr;
25633 + rc = halIsr(pHalDev, &more);
25635 + pHalFunc->PacketProcessEnd(pHalDev);
25641 +int tn7sar_deactivate_vc(Tn7AtmPrivate *priv, int chan)
25643 + unsigned int mode;
25644 + HAL_FUNCTIONS *pHalFunc;
25645 + HAL_DEVICE *pHalDev;
25647 + dprintf(4, "tn7sar_deactivate_vc\n");
25648 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25649 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25651 + mode = 0xf; //tear down everything, wait for return;
25653 + pHalFunc->ChannelTeardown(pHalDev, chan, mode);
25657 +void tn7sar_exit(struct atm_dev *dev, Tn7AtmPrivate *priv)
25659 + HAL_FUNCTIONS *pHalFunc;
25660 + HAL_DEVICE *pHalDev;
25662 + dprintf(4, "tn7sar_exit()\n");
25664 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25665 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25667 + tn7sar_deactivate_vc(priv, 15); // de-activate oam channel
25669 + pHalFunc->Close(pHalDev, 2);
25670 + pHalFunc->Shutdown(pHalDev);
25672 + kfree(priv->pSarOsFunc);
25676 +void tn7sar_get_sar_version(Tn7AtmPrivate *priv, char **pVer)
25678 + HAL_FUNCTIONS *pHalFunc;
25679 + HAL_DEVICE *pHalDev;
25681 + dprintf(4, "tn7sar_get_sar_version()\n");
25683 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25684 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25685 + pHalFunc->Control(pHalDev, "Version", "Get", pVer);
25689 +int tn7sar_get_near_end_loopback_count(unsigned int *pF4count, unsigned int *pF5count)
25691 + unsigned int f4c, f5c;
25693 + f4c = *(volatile unsigned int *)SAR_PDSP_OAM_F4LB_COUNT_REG_ADDR;
25694 + f5c = *(volatile unsigned int *)SAR_PDSP_OAM_F5LB_COUNT_REG_ADDR;
25702 +int tn7sar_unmatched_oam_generation(void *privContext, int vpi, int vci, int type)
25705 + unsigned int regv = 0;
25707 + static unsigned int tag;
25708 + HAL_FUNCTIONS *pHalFunc;
25709 + HAL_DEVICE *pHalDev;
25710 + Tn7AtmPrivate *priv;
25711 + unsigned int llid[4]={0xffffffff,0xffffffff,0xffffffff,0xffffffff};
25713 + dprintf(4, "tn7sar_unknow_oam_generation()\n");
25715 + priv = (Tn7AtmPrivate *)privContext;
25716 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25717 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25721 + oamPingStatus = OAM_PING_FAILED;
25724 + /* calculate atm header */
25725 + oamAtmHdr = tn7sar_atm_header(vpi,vci);
25727 + /* config the atm header */
25728 + pHalFunc->Control(pHalDev,"TxVc_AtmHeader.15", "Set", &oamAtmHdr);
25730 + /*record oam type */
25733 + regv = (0xff & chan);
25738 + regv |= (1<<12); //f5 end
25739 + dprintf(2, "f5 loop back\n");
25742 + regv |= (1<<13); // f4 end
25745 + regv |= (1<<14); //f5 seg
25748 + regv |= (1<<15); //f4 seg
25753 + oamPingStatus = OAM_PING_PENDING;
25754 + pHalFunc->OamLoopbackConfig(pHalDev, regv, llid, tag);
25760 +int tn7sar_oam_generation(void *privContext, int chan, int type, int vpi, int vci, int timeout)
25762 + unsigned int regv = 0;
25763 + static unsigned int tag;
25764 + HAL_FUNCTIONS *pHalFunc;
25765 + HAL_DEVICE *pHalDev;
25766 + Tn7AtmPrivate *priv;
25767 + unsigned int llid[4]={0xffffffff,0xffffffff,0xffffffff,0xffffffff};
25769 + dprintf(2, "tn7sar_oam_generation()\n");
25771 + priv = (Tn7AtmPrivate *)privContext;
25772 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25773 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25775 + if(timeout >= 5000)
25777 + if(timeout == 6000)
25779 + tn7sar_clear_pvc_table();
25782 + timeout = oamLbTimeout;
25786 + pHalFunc->Control(pHalDev,"OamLbTimeout", "Set", &timeout);
25788 + if(chan == ATM_NO_DMA_CHAN)
25790 + tn7sar_unmatched_oam_generation(priv, vpi, vci, type);
25794 + /* calculate atm header */
25795 + oamAtmHdr = tn7sar_atm_header(vpi,vci);
25799 + regv = (0xff & chan);
25803 + regv |= (1<<12); //f5 end
25804 + dprintf(2, "f5 loop back\n");
25807 + regv |= (1<<13); // f4 end
25810 + regv |= (1<<14); //f5 seg
25813 + regv |= (1<<15); //f4 seg
25818 + oamPingStatus = OAM_PING_PENDING;
25819 + pHalFunc->OamLoopbackConfig(pHalDev, regv, llid, tag);
25825 +int tn7sar_proc_oam_ping(char* buf, char **start, off_t offset, int count,int *eof, void *data)
25829 + len += sprintf(buf+len, "%d\n", oamPingStatus);
25834 +int tn7sar_proc_pvc_table(char* buf, char **start, off_t offset, int count,int *eof, void *data)
25839 + for(i=0;i<16;i++)
25841 + if(pvc_result[i].bInUse)
25843 + len += sprintf(buf+len, "%d,%d\n", pvc_result[i].vpi,pvc_result[i].vci);
25847 + len += sprintf(buf+len, "0,0\n");
25855 +int tn7sar_proc_sar_stat(char* buf, char **start, off_t offset, int count,int *eof, void *data)
25858 + int limit = count - 80;
25859 + struct atm_dev *dev;
25860 + Tn7AtmPrivate *priv;
25863 + char statString[32];
25864 + unsigned int *pStateBase, *pSarStat;
25865 + HAL_FUNCTIONS *pHalFunc;
25866 + HAL_DEVICE *pHalDev;
25869 + dev = (struct atm_dev *)data;
25870 + priv = (Tn7AtmPrivate *)dev->dev_data;
25872 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25873 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25875 + len += sprintf(buf+len, "SAR HAL Statistics\n");
25876 + for(i=0;i<MAX_DMA_CHAN;i++)
25878 + if(priv->lut[i].inuse)
25881 + len += sprintf(buf+len, "\nChannel %d:\n",priv->lut[i].chanid);
25885 + stat_len =sprintf(statString, "Stats;%d;%d", j,priv->lut[i].chanid);
25886 + statString[stat_len]=0;
25887 + pHalFunc->Control(pHalDev, statString, "Get", &pSarStat);
25888 + pStateBase = pSarStat;
25891 + if((char *)*pSarStat == NULL)
25895 + dBytes = sprintf(buf+len, "%s: ",(char *) *pSarStat);
25902 + dBytes = sprintf(buf+len, "%s; ",(char *) *pSarStat);
25912 + len += sprintf(buf+len, "\n");
25916 + kfree(pStateBase);
25924 +void tn7sar_get_sar_firmware_version(unsigned int *pdsp_version_ms, unsigned int *pdsp_version_ls)
25927 + *pdsp_version_ms = (SarPdspFirmware[9]>>20) & 0xF;
25928 + *pdsp_version_ls = (SarPdspFirmware[9]>>12) & 0xFF;
25931 diff -urN linux.old/drivers/atm/sangam_atm/tnetd7300_sar_firm.h linux.dev/drivers/atm/sangam_atm/tnetd7300_sar_firm.h
25932 --- linux.old/drivers/atm/sangam_atm/tnetd7300_sar_firm.h 1970-01-01 01:00:00.000000000 +0100
25933 +++ linux.dev/drivers/atm/sangam_atm/tnetd7300_sar_firm.h 2005-07-10 08:02:01.456109536 +0200
25935 +//SarPdspFirmware Revision: 49
25937 +static int SarPdspFirmware[] = {
26923 diff -urN linux.old/drivers/atm/sangam_atm/turbodsl.c linux.dev/drivers/atm/sangam_atm/turbodsl.c
26924 --- linux.old/drivers/atm/sangam_atm/turbodsl.c 1970-01-01 01:00:00.000000000 +0100
26925 +++ linux.dev/drivers/atm/sangam_atm/turbodsl.c 2005-07-10 08:02:01.456109536 +0200
26931 + * Turbo DSL Implementaion
26933 + * Zhicheng Tang ztang@ti.com
26935 + * 2002 (c) Texas Instruments Inc.
26939 +/* defines and variables */
26940 +#define RFC2684_BRIDGED_HDR_SIZE 10
26941 +unsigned char LLC_BRIDGED_HEADER_2684[RFC2684_BRIDGED_HDR_SIZE] =
26942 + {0xAA, 0xAA, 0x03, 0x00, 0x80, 0xC2, 0x00, 0x07, 0x00, 0x00};
26944 +#define RFC2684_ROUTED_HDR_SIZE 6
26945 +unsigned char LLC_ROUTED_HEADER_2684[6] ={0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
26947 +unsigned long PPP_LLC_HEADER = 0xCF03FEFE;
26949 +/* struct definition */
26952 + AAL5_ENCAP_PPP_LLC,
26953 + AAL5_ENCAP_PPP_VCMUX,
26954 + AAL5_ENCAP_RFC2684_LLC_BRIDGED,
26955 + AAL5_ENCAP_RFC2684_LLC_ROUTED
26958 +/* Etherent header */
26959 +typedef struct _turbodsl_ether_header
26961 + unsigned char dst_mac_addr[6];
26962 + unsigned char src_mac_addr[6];
26963 + unsigned short ether_type;
26964 +} turbodsl_ether_header_t;
26967 +/* Ip header define */
26968 +typedef struct _turbodsl_ip_header
26971 + unsigned short vit;
26972 + unsigned short total_length;
26973 + unsigned short ip_id;
26974 + unsigned char flag; /* bit 0 = 0, bit1 = don't fragment, bit2=more frag */
26975 + unsigned char fragment_offset; /* offset include remaining 5 bits above, which make it 13 bits */
26976 + unsigned char time_to_live;
26977 + unsigned char protocol;
26978 + unsigned short checksum;
26979 + unsigned int src_ip;
26980 + unsigned int dst_ip;
26981 +} turbodsl_ip_header_t;
26983 +/* Arp packet define */
26984 +typedef struct _turbodsl_arp_header
26986 + unsigned short hardware_type;
26987 + unsigned short protocol_type;
26988 + unsigned char h_len;
26989 + unsigned char p_len;
26990 + unsigned short operation ;
26991 + unsigned char snd_hw_address[6];
26992 + unsigned char snd_pt_address[4];
26993 + unsigned char dst_hw_address[6];
26994 + unsigned char dst_pt_address[4];
26995 +} turbodsl_arp_header_t;
26997 +#define FIN_FLAG 1
26998 +#define SYN_FLAG 1<<1
26999 +#define RST_FLAG 1<<2
27000 +#define PSH_FLAG 1<<3
27001 +#define ACK_FLAG 1<<4
27002 +#define URG_FLAG 1<<5
27004 +typedef struct _turbodsl_tcp_header
27006 + unsigned short src_port;
27007 + unsigned short dst_port;
27008 + unsigned int seq_num;
27009 + unsigned int ack_num;
27010 + unsigned char offset; /* only bits 4-7 are for offset */
27011 + unsigned char flags; /* bits: 0-FIN, 1-SYN, 2-RST, 3-PSH, 4-ACK, 5-URG */
27012 + unsigned short windows;
27013 + unsigned short checksum;
27014 + unsigned short urgent_ptr;
27015 +} turbodsl_tcp_header_t;
27019 +/***************************************************************************
27020 + * Function: turbodsl_memory_compare
27021 + * Descripation: Memory compare
27022 + ****************************************************************************/
27023 +int turbodsl_memory_compare(unsigned char *pIn, unsigned char *pOut, unsigned int len)
27027 + for(i=0;i<(int)len; i++)
27029 + if(pIn[i] != pOut[i])
27035 +/***************************************************************************
27036 + * Function: turbodsl_check_aal5_encap_type
27037 + * Descripation: Determine AAL5 Encapsulation type
27039 + * unsigned char *pData, AAL5 Packet buffer pointer
27040 + ****************************************************************************/
27041 +int turbodsl_check_aal5_encap_type(unsigned char *pData)
27044 + if(turbodsl_memory_compare(pData, LLC_BRIDGED_HEADER_2684, 6))
27045 + return AAL5_ENCAP_RFC2684_LLC_BRIDGED;
27046 + if(turbodsl_memory_compare(pData, LLC_ROUTED_HEADER_2684, 6))
27047 + return AAL5_ENCAP_RFC2684_LLC_ROUTED;
27048 + if(turbodsl_memory_compare(pData, (unsigned char *)&PPP_LLC_HEADER, sizeof(PPP_LLC_HEADER)))
27049 + return AAL5_ENCAP_PPP_LLC;
27051 + return AAL5_ENCAP_PPP_VCMUX;
27054 +/***************************************************************************
27055 + * Function: turbodsl_check_priority_type
27056 + * Descripation: Determine AAL5 Encapsulation type
27058 + * unsigned char *pData, AAL5 Packet buffer pointer.
27059 + * short vpi, VPI.
27061 + ****************************************************************************/
27062 +int turbodsl_check_priority_type(unsigned char *pData)
27065 + unsigned char *pP;
27066 + unsigned short etherType;
27067 + turbodsl_ip_header_t *pIp;
27068 + turbodsl_tcp_header_t *pTcp;
27069 + unsigned short ip_length;
27071 + dprintf(2, "turbodsl_check_priority_type ==>\n");
27073 + encap = turbodsl_check_aal5_encap_type(pData);
27078 + case AAL5_ENCAP_RFC2684_LLC_BRIDGED:
27079 + pP += RFC2684_BRIDGED_HDR_SIZE; //skip off aal5 encap
27080 + pP += 12; //skip of mac address
27081 + etherType = *(unsigned short *)pP;
27082 + if(etherType != 0x6488 && etherType != 0x0008)
27084 + //Not an IP packet
27088 + pP +=2; //skip ether type
27089 + if(etherType == 0x6488)
27094 + case AAL5_ENCAP_RFC2684_LLC_ROUTED:
27095 + pP += RFC2684_ROUTED_HDR_SIZE; //skip of encap
27096 + pP += 2; //skip ether type
27098 + case AAL5_ENCAP_PPP_LLC:
27099 + pP += sizeof(PPP_LLC_HEADER);
27100 + if(*pP == 0xff && *(pP+1) == 0x03) //ppp hdlc header
27103 + case AAL5_ENCAP_PPP_VCMUX:
27104 + if(*pP == 0xff && *(pP+1) == 0x03) //ppp hdlc header
27111 + pIp = (turbodsl_ip_header_t *)pP;
27112 + if(pIp->vit != 0x0045)
27114 + //Not a IP packet
27118 + if(pIp->protocol != 0x06)
27124 + pTcp = (turbodsl_tcp_header_t *)(pP + sizeof(turbodsl_ip_header_t));
27126 + ip_length = (pIp->total_length>>8) + (pIp->total_length<<8);
27128 + if((pTcp->flags & ACK_FLAG) && ip_length <=40)
27150 diff -urN linux.old/include/linux/atmdev.h linux.dev/include/linux/atmdev.h
27151 --- linux.old/include/linux/atmdev.h 2004-08-08 01:26:06.000000000 +0200
27152 +++ linux.dev/include/linux/atmdev.h 2005-07-10 08:02:01.476106496 +0200
27154 #define ATM_DS3_PCR (8000*12)
27155 /* DS3: 12 cells in a 125 usec time slot */
27157 +#define ATM_PDU_OVHD 0 /* number of bytes to charge against buffer
27160 #define ATM_SD(s) ((s)->sk->protinfo.af_atm)
27164 /* set backend handler */
27165 #define ATM_NEWBACKENDIF _IOW('a',ATMIOC_SPECIAL+3,atm_backend_t)
27166 /* use backend to make new if */
27168 +#define ATM_STOPTX _IOW('a',ATMIOC_SPECIAL+4,struct atmif_sioc)
27169 + /* Stop Tx on Sangam DSL */
27171 * These are backend handkers that can be set via the ATM_SETBACKEND call
27172 * above. In the future we may support dynamic loading of these - for now,
27173 @@ -199,7 +203,9 @@
27174 "SESSION", "HASSAP", "BOUND", "CLOSE"
27178 +#ifndef __KERNEL__
27179 +#undef __AAL_STAT_ITEMS
27182 #include <linux/sched.h> /* wait_queue_head_t */
27183 #include <linux/time.h> /* struct timeval */
27184 @@ -277,6 +283,7 @@
27187 atm_vcc_flags_t flags; /* VCC flags (ATM_VF_*) */
27188 + unsigned char family; /* address family; 0 if unused */
27189 short vpi; /* VPI and VCI (types must be equal */
27190 /* with sockaddr) */
27192 @@ -285,20 +292,31 @@
27193 struct atm_dev *dev; /* device back pointer */
27194 struct atm_qos qos; /* QOS */
27195 struct atm_sap sap; /* SAP */
27196 + atomic_t tx_inuse,rx_inuse; /* buffer space in use */
27197 void (*push)(struct atm_vcc *vcc,struct sk_buff *skb);
27198 void (*pop)(struct atm_vcc *vcc,struct sk_buff *skb); /* optional */
27199 + struct sk_buff *(*alloc_tx)(struct atm_vcc *vcc,unsigned int size);
27200 + /* TX allocation routine - can be */
27201 + /* modified by protocol or by driver.*/
27202 + /* NOTE: this interface will change */
27203 int (*push_oam)(struct atm_vcc *vcc,void *cell);
27204 int (*send)(struct atm_vcc *vcc,struct sk_buff *skb);
27205 void *dev_data; /* per-device data */
27206 void *proto_data; /* per-protocol data */
27207 + struct timeval timestamp; /* AAL timestamps */
27208 + struct sk_buff_head recvq; /* receive queue */
27209 struct k_atm_aal_stats *stats; /* pointer to AAL stats group */
27210 wait_queue_head_t sleep; /* if socket is busy */
27211 struct sock *sk; /* socket backpointer */
27212 + struct atm_vcc *prev,*next;
27213 /* SVC part --- may move later ------------------------------------- */
27214 short itf; /* interface number */
27215 struct sockaddr_atmsvc local;
27216 struct sockaddr_atmsvc remote;
27217 void (*callback)(struct atm_vcc *vcc);
27218 + struct sk_buff_head listenq;
27219 + int backlog_quota; /* number of connection requests we */
27220 + /* can still accept */
27221 int reply; /* also used by ATMTCP */
27222 /* Multipoint part ------------------------------------------------- */
27223 struct atm_vcc *session; /* session VCC descriptor */
27224 @@ -324,6 +342,8 @@
27226 const char *type; /* device type name */
27227 int number; /* device index */
27228 + struct atm_vcc *vccs; /* VCC table (or NULL) */
27229 + struct atm_vcc *last; /* last VCC (or undefined) */
27230 void *dev_data; /* per-device data */
27231 void *phy_data; /* private PHY date */
27232 atm_dev_flags_t flags; /* device flags (ATM_DF_*) */
27233 @@ -333,13 +353,15 @@
27234 struct k_atm_dev_stats stats; /* statistics */
27235 char signal; /* signal status (ATM_PHY_SIG_*) */
27236 int link_rate; /* link rate (default: OC3) */
27237 - atomic_t refcnt; /* reference count */
27238 - spinlock_t lock; /* protect internal members */
27239 + atomic_t refcnt; /* reference count */
27240 + spinlock_t lock; /* protect internal members */
27241 #ifdef CONFIG_PROC_FS
27242 struct proc_dir_entry *proc_entry; /* proc entry */
27243 char *proc_name; /* proc entry name */
27245 - struct list_head dev_list; /* linkage */
27246 + struct atm_dev *prev,*next; /* linkage */
27247 + struct list_head dev_list; /* linkage */
27252 @@ -375,6 +397,8 @@
27253 void (*feedback)(struct atm_vcc *vcc,struct sk_buff *skb,
27254 unsigned long start,unsigned long dest,int len);
27255 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
27256 + void (*free_rx_skb)(struct atm_vcc *vcc, struct sk_buff *skb);
27257 + /* @@@ temporary hack */
27258 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
27259 struct module *owner;
27261 @@ -389,6 +413,7 @@
27263 struct atm_skb_data {
27264 struct atm_vcc *vcc; /* ATM VCC */
27265 + int iovcnt; /* 0 for "normal" operation */
27266 unsigned long atm_options; /* ATM layer options */
27269 @@ -399,11 +424,10 @@
27271 struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops,
27272 int number,atm_dev_flags_t *flags); /* number == -1: pick first available */
27273 -struct atm_dev *atm_dev_lookup(int number);
27274 +struct atm_dev *atm_find_dev(int number);
27275 void atm_dev_deregister(struct atm_dev *dev);
27276 void shutdown_atm_dev(struct atm_dev *dev);
27277 -void vcc_insert_socket(struct sock *sk);
27278 -void vcc_remove_socket(struct sock *sk);
27279 +void bind_vcc(struct atm_vcc *vcc,struct atm_dev *dev);
27283 @@ -411,54 +435,52 @@
27287 -static inline int atm_guess_pdu2truesize(int size)
27288 +static __inline__ int atm_guess_pdu2truesize(int pdu_size)
27290 - return (SKB_DATA_ALIGN(size) + sizeof(struct skb_shared_info));
27291 + return ((pdu_size+15) & ~15) + sizeof(struct sk_buff);
27295 -static inline void atm_force_charge(struct atm_vcc *vcc,int truesize)
27296 +static __inline__ void atm_force_charge(struct atm_vcc *vcc,int truesize)
27298 - atomic_add(truesize, &vcc->sk->rmem_alloc);
27299 + atomic_add(truesize+ATM_PDU_OVHD,&vcc->rx_inuse);
27303 -static inline void atm_return(struct atm_vcc *vcc,int truesize)
27304 +static __inline__ void atm_return(struct atm_vcc *vcc,int truesize)
27306 - atomic_sub(truesize, &vcc->sk->rmem_alloc);
27307 + atomic_sub(truesize+ATM_PDU_OVHD,&vcc->rx_inuse);
27311 -static inline int atm_may_send(struct atm_vcc *vcc,unsigned int size)
27312 +static __inline__ int atm_may_send(struct atm_vcc *vcc,unsigned int size)
27314 - return (size + atomic_read(&vcc->sk->wmem_alloc)) < vcc->sk->sndbuf;
27315 + return size+atomic_read(&vcc->tx_inuse)+ATM_PDU_OVHD < vcc->sk->sndbuf;
27319 +int atm_charge(struct atm_vcc *vcc,int truesize);
27320 +struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size,
27322 +int atm_find_ci(struct atm_vcc *vcc,short *vpi,int *vci);
27323 +int atm_pcr_goal(struct atm_trafprm *tp);
27325 +void atm_async_release_vcc(struct atm_vcc *vcc,int reply);
27327 static inline void atm_dev_hold(struct atm_dev *dev)
27329 - atomic_inc(&dev->refcnt);
27330 + atomic_inc(&dev->refcnt);
27334 static inline void atm_dev_put(struct atm_dev *dev)
27336 - atomic_dec(&dev->refcnt);
27337 + atomic_dec(&dev->refcnt);
27339 - if ((atomic_read(&dev->refcnt) == 1) &&
27340 - test_bit(ATM_DF_CLOSE,&dev->flags))
27341 - shutdown_atm_dev(dev);
27342 + if ((atomic_read(&dev->refcnt) == 1) &&
27343 + test_bit(ATM_DF_CLOSE,&dev->flags))
27344 + shutdown_atm_dev(dev);
27348 -int atm_charge(struct atm_vcc *vcc,int truesize);
27349 -struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size,
27351 -int atm_find_ci(struct atm_vcc *vcc,short *vpi,int *vci);
27352 -int atm_pcr_goal(struct atm_trafprm *tp);
27354 -void vcc_release_async(struct atm_vcc *vcc, int reply);
27356 #endif /* __KERNEL__ */
27359 diff -urN linux.old/include/linux/atm.h linux.dev/include/linux/atm.h
27360 --- linux.old/include/linux/atm.h 2001-11-22 20:48:41.000000000 +0100
27361 +++ linux.dev/include/linux/atm.h 2005-07-10 08:02:01.476106496 +0200
27362 @@ -135,9 +135,12 @@
27363 unsigned char traffic_class; /* traffic class (ATM_UBR, ...) */
27364 int max_pcr; /* maximum PCR in cells per second */
27365 int pcr; /* desired PCR in cells per second */
27366 + int scr; /* desired SCR in cells per second */
27367 int min_pcr; /* minimum PCR in cells per second */
27368 int max_cdv; /* maximum CDV in microseconds */
27369 int max_sdu; /* maximum SDU in bytes */
27370 + /* Ron remove for old tiatm driver 1.00.09 */
27371 + //int mbs; /* Maximum Burst size */
27372 /* extra params for ABR */
27373 unsigned int icr; /* Initial Cell Rate (24-bit) */
27374 unsigned int tbe; /* Transient Buffer Exposure (24-bit) */