intr.c 18.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635
/*
 * SBE 2T3E3 synchronous serial card driver for Linux
 *
 * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License
 * as published by the Free Software Foundation.
 *
 * This code is based on a driver written by SBE Inc.
 */

#include <linux/hdlc.h>
#include <linux/interrupt.h>
#include <linux/netdevice.h>
#include "2t3e3.h"

irqreturn_t t3e3_intr(int irq, void *dev_instance)
{
	struct channel *sc = dev_to_priv(dev_instance);
	u32 val;
	irqreturn_t ret = IRQ_NONE;

	sc->interrupt_active = 1;

	val = cpld_read(sc, SBE_2T3E3_CPLD_REG_PICSR);

	if (val & SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_CHANGE) {
		dev_dbg(&sc->pdev->dev,
			"Rx LOS Chng Int r=%02x (LOS|OOF=%02x)\n",
			val, (sc->s.LOS << 4) | sc->s.OOF);
		cpld_LOS_update(sc);
		ret = IRQ_HANDLED;
	}

	if (val & SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_ETHERNET_ASSERTED) {
		dc_intr(sc);
		ret = IRQ_HANDLED;
	}

	if (val & SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_FRAMER_ASSERTED) {
		exar7250_intr(sc);
		ret = IRQ_HANDLED;
	}

	/*
	  we don't care about other interrupt sources (DMO, LOS, LCV) because
	  they are handled by Framer too
	*/

	sc->interrupt_active = 0;
	return ret;
}

void dc_intr(struct channel *sc)
{
	u32 val;

	/* disable ethernet interrupts */
	/* grrr this clears interrupt summary bits !!! */
	dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE, 0);

	while ((val = dc_read(sc->addr, SBE_2T3E3_21143_REG_STATUS)) &
	       (SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STOPPED |
		SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE |
		SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT |
		SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW |
		SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE |
		SBE_2T3E3_21143_VAL_TRANSMIT_PROCESS_STOPPED |
		SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT)) {
		dc_write(sc->addr, SBE_2T3E3_21143_REG_STATUS, val);

		dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Ethernet controller interrupt! (CSR5 = %08X)\n",
			val);

		if (val & (SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT |
			   SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE |
			   SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STOPPED)) {
			if (val & SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT)
				dev_dbg(&sc->pdev->dev,
					"Receive interrupt (LOS=%d, OOF=%d)\n",
					sc->s.LOS, sc->s.OOF);
			if (val & SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE)
				dev_dbg(&sc->pdev->dev,
					"Receive buffer unavailable\n");
			if (val & SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STOPPED)
				dev_dbg(&sc->pdev->dev,
					"Receive process stopped\n");
			dc_intr_rx(sc);
		}

		if (val & SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW) {
			dev_dbg(&sc->pdev->dev, "Transmit underflow\n");
			dc_intr_tx_underflow(sc);
		}

		if (val & (SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE |
			   SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT |
			   SBE_2T3E3_21143_VAL_TRANSMIT_PROCESS_STOPPED)) {
			if (val & SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT)
				dev_dbg(&sc->pdev->dev, "Transmit interrupt\n");
			if (val & SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE)
				dev_dbg(&sc->pdev->dev,
					"Transmit buffer unavailable\n");
			if (val & SBE_2T3E3_21143_VAL_TRANSMIT_PROCESS_STOPPED)
				dev_dbg(&sc->pdev->dev,
					"Transmit process stopped\n");
			dc_intr_tx(sc);
		}
	}

	/* enable ethernet interrupts */
	dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE,
		 sc->ether.interrupt_enable_mask);
}

void dc_intr_rx(struct channel *sc)
{
	u32 current_read;
	u32 error_mask, error;
	t3e3_rx_desc_t *current_desc;
	struct sk_buff *m, *m2;
	unsigned rcv_len;

	sc->rcv_count++; /* for the activity LED */

	current_read = sc->ether.rx_ring_current_read;
	dev_dbg(&sc->pdev->dev, "intr_rx current_read = %d\n", current_read);

	/* when ethernet loopback is set, ignore framer signals */
	if ((sc->p.loopback != SBE_2T3E3_LOOPBACK_ETHERNET) && sc->s.OOF) {
		while (!(sc->ether.rx_ring[current_read].rdes0 &
			 SBE_2T3E3_RX_DESC_21143_OWN)) {
			current_desc = &sc->ether.rx_ring[current_read];
			current_desc->rdes1 &= SBE_2T3E3_RX_DESC_END_OF_RING |
				SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED;
			current_desc->rdes1 |= SBE_2T3E3_MTU;
			current_desc->rdes0 = SBE_2T3E3_RX_DESC_21143_OWN;
			current_read = (current_read + 1) % SBE_2T3E3_RX_DESC_RING_SIZE;
		}
		sc->ether.rx_ring_current_read = current_read;
		return;
	}

	while (!(sc->ether.rx_ring[current_read].rdes0 &
		 SBE_2T3E3_RX_DESC_21143_OWN)) {
		current_desc = &sc->ether.rx_ring[current_read];

		dev_dbg(&sc->pdev->dev, "rdes0: %08X        rdes1: %08X\n",
			current_desc->rdes0, current_desc->rdes1);

		m = sc->ether.rx_data[current_read];
		rcv_len = (current_desc->rdes0 & SBE_2T3E3_RX_DESC_FRAME_LENGTH) >>
			SBE_2T3E3_RX_DESC_FRAME_LENGTH_SHIFT;

		dev_dbg(&sc->pdev->dev, "mbuf was received (mbuf len = %d)\n",
			rcv_len);

		switch (sc->p.crc) {
		case SBE_2T3E3_CRC_16:
			rcv_len -= SBE_2T3E3_CRC16_LENGTH;
			break;
		case SBE_2T3E3_CRC_32:
			rcv_len -= SBE_2T3E3_CRC32_LENGTH;
			break;
		default:
			break;
		}

		if (current_desc->rdes0 & SBE_2T3E3_RX_DESC_LAST_DESC) {

			/* TODO: is collision possible? */
			error_mask = SBE_2T3E3_RX_DESC_DESC_ERROR |
				SBE_2T3E3_RX_DESC_COLLISION_SEEN |
				SBE_2T3E3_RX_DESC_DRIBBLING_BIT;

			switch (sc->p.frame_mode) {
			case SBE_2T3E3_FRAME_MODE_HDLC:
				error_mask |= SBE_2T3E3_RX_DESC_MII_ERROR;
				if (sc->p.crc == SBE_2T3E3_CRC_32)
					error_mask |= SBE_2T3E3_RX_DESC_CRC_ERROR;
				break;
			case SBE_2T3E3_FRAME_MODE_TRANSPARENT:
			case SBE_2T3E3_FRAME_MODE_RAW:
				break;
			default:
				error_mask = 0;
			}

			if (sc->s.LOS) {
				error_mask &= ~(SBE_2T3E3_RX_DESC_DRIBBLING_BIT ||
						SBE_2T3E3_RX_DESC_MII_ERROR);
			}

			error = current_desc->rdes0 & error_mask;
			if (error) {
				sc->s.in_errors++;
				dev_dbg(&sc->pdev->dev,
					"error interrupt: NO_ERROR_MESSAGE = %d\n",
					sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES ? 1 : 0);

				current_desc->rdes1 &= SBE_2T3E3_RX_DESC_END_OF_RING |
					SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED;
				current_desc->rdes1 |= SBE_2T3E3_MTU;
				current_desc->rdes0 = SBE_2T3E3_RX_DESC_21143_OWN;

				if (error & SBE_2T3E3_RX_DESC_DESC_ERROR) {
					if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
						dev_err(&sc->pdev->dev,
							"SBE 2T3E3: descriptor error\n");
					sc->s.in_error_desc++;
				}

				if (error & SBE_2T3E3_RX_DESC_COLLISION_SEEN) {
					if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
						dev_err(&sc->pdev->dev,
							"SBE 2T3E3: collision seen\n");
					sc->s.in_error_coll++;
				} else {
					if (error & SBE_2T3E3_RX_DESC_DRIBBLING_BIT) {
						if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
							dev_err(&sc->pdev->dev,
								"SBE 2T3E3: dribbling bits error\n");
						sc->s.in_error_drib++;
					}

					if (error & SBE_2T3E3_RX_DESC_CRC_ERROR) {
						if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
							dev_err(&sc->pdev->dev,
								"SBE 2T3E3: crc error\n");
						sc->s.in_error_crc++;
					}
				}

				if (error & SBE_2T3E3_RX_DESC_MII_ERROR) {
					if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
						dev_err(&sc->pdev->dev, "SBE 2T3E3: mii error\n");
					sc->s.in_error_mii++;
				}

				current_read = (current_read + 1) % SBE_2T3E3_RX_DESC_RING_SIZE;
				sc->r.flags |= SBE_2T3E3_FLAG_NO_ERROR_MESSAGES;
				continue;
			}
		}

		current_desc->rdes1 &= SBE_2T3E3_RX_DESC_END_OF_RING |
			SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED;
		current_desc->rdes1 |= SBE_2T3E3_MTU;

		if (rcv_len > 1600) {
			sc->s.in_errors++;
			sc->s.in_dropped++;
			if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
				dev_err(&sc->pdev->dev, "SBE 2T3E3: oversized rx: rdes0 = %08X\n",
					current_desc->rdes0);
		} else {
			m2 = dev_alloc_skb(MCLBYTES);
			if (m2 != NULL) {
				current_desc->rdes2 = virt_to_phys(m2->data);
				sc->ether.rx_data[current_read] = m2;
				sc->s.in_packets++;
				sc->s.in_bytes += rcv_len;
				m->dev = sc->dev;
				skb_put(m, rcv_len);
				skb_reset_mac_header(m);
				m->protocol = hdlc_type_trans(m, m->dev);
				netif_rx(m);

				/* good packet was received so we will show error messages again... */
				if (sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES) {
					dev_dbg(&sc->pdev->dev,
						"setting ERROR_MESSAGES->0\n");
					sc->r.flags &= ~SBE_2T3E3_FLAG_NO_ERROR_MESSAGES;
				}

			} else {
				sc->s.in_errors++;
				sc->s.in_dropped++;
			}
		}
		current_desc->rdes0 = SBE_2T3E3_RX_DESC_21143_OWN;
		current_read = (current_read + 1) % SBE_2T3E3_RX_DESC_RING_SIZE;
	}

	sc->ether.rx_ring_current_read = current_read;

	dc_write(sc->addr, SBE_2T3E3_21143_REG_RECEIVE_POLL_DEMAND, 0xFFFFFFFF);
}

void dc_intr_tx(struct channel *sc)
{
	u32 current_read, current_write;
	u32 last_segment, error;
	t3e3_tx_desc_t *current_desc;

	spin_lock(&sc->ether.tx_lock);

	current_read = sc->ether.tx_ring_current_read;
	current_write = sc->ether.tx_ring_current_write;

	while (current_read != current_write) {
		current_desc = &sc->ether.tx_ring[current_read];

		if (current_desc->tdes0 & SBE_2T3E3_RX_DESC_21143_OWN)
			break;

		dev_dbg(&sc->pdev->dev,
			"txeof: tdes0 = %08X        tdes1 = %08X\n",
			current_desc->tdes0, current_desc->tdes1);

		error = current_desc->tdes0 & (SBE_2T3E3_TX_DESC_ERROR_SUMMARY |
					       SBE_2T3E3_TX_DESC_TRANSMIT_JABBER_TIMEOUT |
					       SBE_2T3E3_TX_DESC_LOSS_OF_CARRIER |
					       SBE_2T3E3_TX_DESC_NO_CARRIER |
					       SBE_2T3E3_TX_DESC_LINK_FAIL_REPORT |
					       SBE_2T3E3_TX_DESC_UNDERFLOW_ERROR |
					       SBE_2T3E3_TX_DESC_DEFFERED);

		last_segment = current_desc->tdes1 & SBE_2T3E3_TX_DESC_LAST_SEGMENT;

		current_desc->tdes0 = 0;
		current_desc->tdes1 &= SBE_2T3E3_TX_DESC_END_OF_RING |
			SBE_2T3E3_TX_DESC_SECOND_ADDRESS_CHAINED;
		current_desc->tdes2 = 0;
		sc->ether.tx_free_cnt++;

		if (last_segment != SBE_2T3E3_TX_DESC_LAST_SEGMENT) {
			current_read = (current_read + 1) % SBE_2T3E3_TX_DESC_RING_SIZE;
			continue;
		}


		if (sc->ether.tx_data[current_read]) {
			sc->s.out_packets++;
			sc->s.out_bytes += sc->ether.tx_data[current_read]->len;
			dev_kfree_skb_any(sc->ether.tx_data[current_read]);
			sc->ether.tx_data[current_read] = NULL;
		}

		if (error > 0) {
			sc->s.out_errors++;

			if (error & SBE_2T3E3_TX_DESC_TRANSMIT_JABBER_TIMEOUT) {
				dev_err(&sc->pdev->dev, "SBE 2T3E3: transmit jabber timeout\n");
				sc->s.out_error_jab++;
			}

			if (sc->p.loopback != SBE_2T3E3_LOOPBACK_ETHERNET) {
				if (error & SBE_2T3E3_TX_DESC_LOSS_OF_CARRIER) {
					dev_err(&sc->pdev->dev, "SBE 2T3E3: loss of carrier\n");
					sc->s.out_error_lost_carr++;
				}

				if (error & SBE_2T3E3_TX_DESC_NO_CARRIER) {
					dev_err(&sc->pdev->dev, "SBE 2T3E3: no carrier\n");
					sc->s.out_error_no_carr++;
				}
			}

			if (error & SBE_2T3E3_TX_DESC_LINK_FAIL_REPORT) {
				dev_err(&sc->pdev->dev, "SBE 2T3E3: link fail report\n");
				sc->s.out_error_link_fail++;
			}

			if (error & SBE_2T3E3_TX_DESC_UNDERFLOW_ERROR) {
				dev_err(&sc->pdev->dev, "SBE 2T3E3:"
					" transmission underflow error\n");
				sc->s.out_error_underflow++;
				spin_unlock(&sc->ether.tx_lock);

				dc_restart(sc);
				return;
			}

			if (error & SBE_2T3E3_TX_DESC_DEFFERED) {
				dev_err(&sc->pdev->dev, "SBE 2T3E3: transmission deferred\n");
				sc->s.out_error_dereferred++;
			}
		}

		current_read = (current_read + 1) % SBE_2T3E3_TX_DESC_RING_SIZE;
	}

	sc->ether.tx_ring_current_read = current_read;

	/* Relieve flow control when the TX queue is drained at least half way */
	if (sc->ether.tx_full &&
	    (sc->ether.tx_free_cnt >= (SBE_2T3E3_TX_DESC_RING_SIZE / 2))) {
		sc->ether.tx_full = 0;
		netif_wake_queue(sc->dev);
	}
	spin_unlock(&sc->ether.tx_lock);
}


void dc_intr_tx_underflow(struct channel *sc)
{
	u32 val;

	dc_transmitter_onoff(sc, SBE_2T3E3_OFF);

	val = dc_read(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE);
	dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
		      SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS);

	switch (val & SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS) {
	case SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_1:
		dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
			    SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_2);
		break;
	case SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_2:
		dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
			    SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_3);
		break;
	case SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_3:
		dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
			    SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_4);
		break;
	case SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_4:
	default:
		dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
			    SBE_2T3E3_21143_VAL_STORE_AND_FORWARD);
		break;
	}

	dc_transmitter_onoff(sc, SBE_2T3E3_ON);
}




void exar7250_intr(struct channel *sc)
{
	u32 status, old_OOF;

#if 0
	/* disable interrupts */
	exar7250_write(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE, 0);
#endif

	old_OOF = sc->s.OOF;

	status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS);
	dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Framer interrupt! (REG[0x05] = %02X)\n", status);

	switch (sc->p.frame_type) {
	case SBE_2T3E3_FRAME_TYPE_E3_G751:
	case SBE_2T3E3_FRAME_TYPE_E3_G832:
		exar7250_E3_intr(sc, status);
		break;

	case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
	case SBE_2T3E3_FRAME_TYPE_T3_M13:
		exar7250_T3_intr(sc, status);
		break;

	default:
		break;
	}

	if (sc->s.OOF != old_OOF) {
		if (sc->s.OOF) {
			if (sc->p.loopback == SBE_2T3E3_LOOPBACK_NONE) {
				dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Disabling eth interrupts\n");
				/* turn off ethernet interrupts */
				dc_stop_intr(sc);
			}
		} else if (sc->r.flags & SBE_2T3E3_FLAG_NETWORK_UP) {
			dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Enabling eth interrupts\n");
			/* start interrupts */
			sc->s.OOF = 1;
			dc_intr_rx(sc);
			sc->s.OOF = 0;
			if (sc->p.receiver_on) {
				dc_receiver_onoff(sc, SBE_2T3E3_OFF);
				dc_receiver_onoff(sc, SBE_2T3E3_ON);
			}
			dc_start_intr(sc);
		}
	}
#if 0
	/* reenable interrupts */
	exar7250_write(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE,
		       SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_ENABLE |
		       SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_ENABLE
		);
#endif
}


void exar7250_T3_intr(struct channel *sc, u32 block_status)
{
	u32 status, result;

	if (block_status & SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_STATUS) {
		status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS);

		if (status) {
			dev_dbg(&sc->pdev->dev,
				"Framer interrupt T3 RX (REG[0x13] = %02X)\n",
				status);

			result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS);

#if 0
			if (status & SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_STATUS) {
				dev_dbg(&sc->pdev->dev,
					"Framer interrupt T3: LOS\n");
				sc->s.LOS = result & SBE_2T3E3_FRAMER_VAL_T3_RX_LOS ? 1 : 0;

			}
#else
			cpld_LOS_update(sc);
#endif
			if (status & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_STATUS) {
				sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0;
				dev_dbg(&sc->pdev->dev,
					"Framer interrupt T3: OOF (%d)\n",
					sc->s.OOF);
			}

			exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE,
				       SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE |
				       SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE);
#if 0
			SBE_2T3E3_FRAMER_VAL_T3_RX_CP_BIT_ERROR_INTERRUPT_ENABLE |
				SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE |
				SBE_2T3E3_FRAMER_VAL_T3_RX_AIS_INTERRUPT_ENABLE |
				SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE_INTERRUPT_ENABLE |
				SBE_2T3E3_FRAMER_VAL_T3_RX_FERF_INTERRUPT_ENABLE |
				SBE_2T3E3_FRAMER_VAL_T3_RX_AIC_INTERRUPT_ENABLE |
				SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE |
				SBE_2T3E3_FRAMER_VAL_T3_RX_P_BIT_INTERRUPT_ENABLE
#endif
				}

		status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS);
		if (status) {
			dev_dbg(&sc->pdev->dev,
				"Framer interrupt T3 RX (REG[0x17] = %02X)\n",
				status);
#if 0
			exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS,
				       SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_REMOVE_INTERRUPT_ENABLE |
				       SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_VALID_INTERRUPT_ENABLE
				);
#endif
		}

		status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL);
		if (status)
			dev_dbg(&sc->pdev->dev,
				"Framer interrupt T3 RX (REG[0x18] = %02X)\n",
				status);
	}


	if (block_status & SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_STATUS) {
		status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS);
		dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Framer interrupt T3 TX (REG[0x31] = %02X)\n",
			status);

		status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS);
		dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Framer interrupt T3 TX (REG[0x34] = %02X)\n",
			status);
	}
}


void exar7250_E3_intr(struct channel *sc, u32 block_status)
{
	u32 status, result;

	if (block_status & SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_STATUS) {
		status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1);

		if (status) {
			dev_dbg(&sc->pdev->dev,
				"Framer interrupt E3 RX (REG[0x14] = %02X)\n",
				status);

			result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2);

#if 0
			if (status & SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_STATUS) {
				dev_dbg(&sc->pdev->dev,
					"Framer interrupt E3: LOS\n");
				sc->s.LOS = result & SBE_2T3E3_FRAMER_VAL_E3_RX_LOS ? 1 : 0;
			}
#else
			cpld_LOS_update(sc);
#endif
			if (status & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_STATUS) {
				sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0;
				dev_dbg(&sc->pdev->dev,
					"Framer interrupt E3: OOF (%d)\n",
					sc->s.OOF);
			}

			exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1,
				       SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE |
				       SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE
				);
#if 0
			SBE_2T3E3_FRAMER_VAL_E3_RX_COFA_INTERRUPT_ENABLE |
				SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE |
				SBE_2T3E3_FRAMER_VAL_E3_RX_LOF_INTERRUPT_ENABLE |
				SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE |
				SBE_2T3E3_FRAMER_VAL_E3_RX_AIS_INTERRUPT_ENABLE
#endif
				}

		status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2);
		if (status) {
			dev_dbg(&sc->pdev->dev,
				"Framer interrupt E3 RX (REG[0x15] = %02X)\n",
				status);

#if 0
			exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_2,
				       SBE_2T3E3_FRAMER_VAL_E3_RX_FEBE_INTERRUPT_ENABLE |
				       SBE_2T3E3_FRAMER_VAL_E3_RX_FERF_INTERRUPT_ENABLE |
				       SBE_2T3E3_FRAMER_VAL_E3_RX_FRAMING_BYTE_ERROR_INTERRUPT_ENABLE);
#endif
		}

	}

	if (block_status & SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_STATUS) {
		status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS);
		dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Framer interrupt E3 TX (REG[0x34] = %02X)\n",
			status);
	}
}