View | Details | Raw Unified | Return to bug 247576 | Differences between
and this patch

Collapse All | Expand All

(-)b/sys/dev/iicbus/twsi/twsi.c (-12 / +33 lines)
Lines 499-504 twsi_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) Link Here
499
	sc->msg_idx = 0;
499
	sc->msg_idx = 0;
500
	sc->transfer = 1;
500
	sc->transfer = 1;
501
501
502
#ifdef TWSI_DEBUG
503
	for (int i = 0; i < nmsgs; i++)
504
		debugf(sc->dev, "msg %d is %d bytes long\n", i, msgs[i].len);
505
#endif
502
	/* Send start and re-enable interrupts */
506
	/* Send start and re-enable interrupts */
503
	sc->control_val = TWSI_CONTROL_TWSIEN |
507
	sc->control_val = TWSI_CONTROL_TWSIEN |
504
		TWSI_CONTROL_INTEN | TWSI_CONTROL_ACK;
508
		TWSI_CONTROL_INTEN | TWSI_CONTROL_ACK;
Lines 535-547 twsi_intr(void *arg) Link Here
535
	debugf(sc->dev, "Got interrupt Current msg=%x\n", sc->msg_idx);
539
	debugf(sc->dev, "Got interrupt Current msg=%x\n", sc->msg_idx);
536
540
537
	status = TWSI_READ(sc, sc->reg_status);
541
	status = TWSI_READ(sc, sc->reg_status);
538
	debugf(sc->dev, "initial status=%x\n", status);
542
	debugf(sc->dev, "reg control=%x\n", TWSI_READ(sc, sc->reg_control));
539
543
540
	switch (status) {
544
	switch (status) {
541
	case TWSI_STATUS_START:
545
	case TWSI_STATUS_START:
542
	case TWSI_STATUS_RPTD_START:
546
	case TWSI_STATUS_RPTD_START:
543
		/* Transmit the address */
547
		/* Transmit the address */
544
		debugf(sc->dev, "Send the address\n");
548
		debugf(sc->dev, "Send the address (%x)", sc->msgs[sc->msg_idx].slave);
545
549
546
		if (sc->msgs[sc->msg_idx].flags & IIC_M_RD)
550
		if (sc->msgs[sc->msg_idx].flags & IIC_M_RD)
547
			TWSI_WRITE(sc, sc->reg_data,
551
			TWSI_WRITE(sc, sc->reg_data,
Lines 555-562 twsi_intr(void *arg) Link Here
555
	case TWSI_STATUS_ADDR_W_ACK:
559
	case TWSI_STATUS_ADDR_W_ACK:
556
		debugf(sc->dev, "Ack received after transmitting the address (write)\n");
560
		debugf(sc->dev, "Ack received after transmitting the address (write)\n");
557
		/* Directly send the first byte */
561
		/* Directly send the first byte */
558
		sc->sent_bytes = 0;
562
		sc->sent_bytes = 1;
559
		debugf(sc->dev, "Sending byte 0 = %x\n", sc->msgs[sc->msg_idx].buf[0]);
563
		debugf(sc->dev, "Sending byte 0 (of %d) = %x\n",
564
		    sc->msgs[sc->msg_idx].len,
565
		    sc->msgs[sc->msg_idx].buf[0]);
560
		TWSI_WRITE(sc, sc->reg_data, sc->msgs[sc->msg_idx].buf[0]);
566
		TWSI_WRITE(sc, sc->reg_data, sc->msgs[sc->msg_idx].buf[0]);
561
567
562
		TWSI_WRITE(sc, sc->reg_control, sc->control_val);
568
		TWSI_WRITE(sc, sc->reg_control, sc->control_val);
Lines 580-586 twsi_intr(void *arg) Link Here
580
586
581
	case TWSI_STATUS_DATA_WR_ACK:
587
	case TWSI_STATUS_DATA_WR_ACK:
582
		debugf(sc->dev, "Ack received after transmitting data\n");
588
		debugf(sc->dev, "Ack received after transmitting data\n");
583
		if (sc->sent_bytes++ == (sc->msgs[sc->msg_idx].len - 1)) {
589
		if (sc->sent_bytes == sc->msgs[sc->msg_idx].len) {
584
			debugf(sc->dev, "Done sending all the bytes for msg %d\n", sc->msg_idx);
590
			debugf(sc->dev, "Done sending all the bytes for msg %d\n", sc->msg_idx);
585
			/* Send stop, no interrupts on stop */
591
			/* Send stop, no interrupts on stop */
586
			if (!(sc->msgs[sc->msg_idx].flags & IIC_M_NOSTOP)) {
592
			if (!(sc->msgs[sc->msg_idx].flags & IIC_M_NOSTOP)) {
Lines 595-624 twsi_intr(void *arg) Link Here
595
			if (sc->msg_idx == sc->nmsgs) {
601
			if (sc->msg_idx == sc->nmsgs) {
596
				debugf(sc->dev, "transfer_done=1\n");
602
				debugf(sc->dev, "transfer_done=1\n");
597
				transfer_done = 1;
603
				transfer_done = 1;
604
				sc->error = 0;
605
			} else {
606
				debugf(sc->dev, "Send repeated start\n");
607
				TWSI_WRITE(sc, sc->reg_control, sc->control_val | TWSI_CONTROL_START);
598
			}
608
			}
599
		} else {
609
		} else {
600
			debugf(sc->dev, "Sending byte %d = %x\n",
610
			debugf(sc->dev, "Sending byte %d (of %d) = %x\n",
601
			    sc->sent_bytes,
611
			    sc->sent_bytes,
612
			    sc->msgs[sc->msg_idx].len,
602
			    sc->msgs[sc->msg_idx].buf[sc->sent_bytes]);
613
			    sc->msgs[sc->msg_idx].buf[sc->sent_bytes]);
603
			TWSI_WRITE(sc, sc->reg_data,
614
			TWSI_WRITE(sc, sc->reg_data,
604
			    sc->msgs[sc->msg_idx].buf[sc->sent_bytes]);
615
			    sc->msgs[sc->msg_idx].buf[sc->sent_bytes]);
605
			TWSI_WRITE(sc, sc->reg_control,
616
			TWSI_WRITE(sc, sc->reg_control,
606
			    sc->control_val);
617
			    sc->control_val);
618
			sc->sent_bytes++;
607
		}
619
		}
608
		break;
620
		break;
609
621
610
	case TWSI_STATUS_DATA_RD_ACK:
622
	case TWSI_STATUS_DATA_RD_ACK:
611
		debugf(sc->dev, "Ack received after receiving data\n");
623
		debugf(sc->dev, "Ack received after receiving data\n");
612
		debugf(sc->dev, "msg_len=%d recv_bytes=%d\n", sc->msgs[sc->msg_idx].len, sc->recv_bytes);
613
		sc->msgs[sc->msg_idx].buf[sc->recv_bytes++] = TWSI_READ(sc, sc->reg_data);
624
		sc->msgs[sc->msg_idx].buf[sc->recv_bytes++] = TWSI_READ(sc, sc->reg_data);
625
		debugf(sc->dev, "msg_len=%d recv_bytes=%d\n", sc->msgs[sc->msg_idx].len, sc->recv_bytes);
614
626
615
		/* If we only have one byte left, disable ACK */
627
		/* If we only have one byte left, disable ACK */
616
		if (sc->msgs[sc->msg_idx].len - sc->recv_bytes == 1)
628
		if (sc->msgs[sc->msg_idx].len - sc->recv_bytes == 1)
617
			sc->control_val &= ~TWSI_CONTROL_ACK;
629
			sc->control_val &= ~TWSI_CONTROL_ACK;
618
		if (sc->msgs[sc->msg_idx].len - sc->recv_bytes) {
630
		if (sc->msgs[sc->msg_idx].len == sc->recv_bytes) {
631
			debugf(sc->dev, "Done with msg %d\n", sc->msg_idx);
619
			sc->msg_idx++;
632
			sc->msg_idx++;
620
			if (sc->msg_idx == sc->nmsgs - 1)
633
			if (sc->msg_idx == sc->nmsgs - 1) {
634
				debugf(sc->dev, "No more msgs\n");
621
				transfer_done = 1;
635
				transfer_done = 1;
636
				sc->error = 0;
637
			}
622
		}
638
		}
623
		TWSI_WRITE(sc, sc->reg_control, sc->control_val);
639
		TWSI_WRITE(sc, sc->reg_control, sc->control_val);
624
		break;
640
		break;
Lines 631-642 twsi_intr(void *arg) Link Here
631
				TWSI_WRITE(sc, sc->reg_control,
647
				TWSI_WRITE(sc, sc->reg_control,
632
				    sc->control_val | TWSI_CONTROL_STOP);
648
				    sc->control_val | TWSI_CONTROL_STOP);
633
		} else {
649
		} else {
634
			debugf(sc->dev, "No ack when receiving data\n");
650
			debugf(sc->dev, "No ack when receiving data, sending stop anyway\n");
635
			sc->error = ENXIO;
651
			if (!(sc->msgs[sc->msg_idx].flags & IIC_M_NOSTOP))
636
			sc->control_val = 0;
652
				TWSI_WRITE(sc, sc->reg_control,
653
				    sc->control_val | TWSI_CONTROL_STOP);
637
		}
654
		}
638
		sc->transfer = 0;
655
		sc->transfer = 0;
639
		transfer_done = 1;
656
		transfer_done = 1;
657
		sc->error = 0;
640
		break;
658
		break;
641
659
642
	default:
660
	default:
Lines 647-652 twsi_intr(void *arg) Link Here
647
		wakeup(sc);
665
		wakeup(sc);
648
		break;
666
		break;
649
	}
667
	}
668
	debugf(sc->dev, "Refresh reg_control\n");
669
	TWSI_WRITE(sc, sc->reg_control,
670
	  sc->control_val | TWSI_CONTROL_IFLG);
650
671
651
	debugf(sc->dev, "Done with interrupts\n\n");
672
	debugf(sc->dev, "Done with interrupts\n\n");
652
	if (transfer_done == 1) {
673
	if (transfer_done == 1) {
(-)b/sys/dts/arm/overlays/sun8i-h3-i2c0.dtso (+5 lines)
Lines 9-12 Link Here
9
	status = "okay";
9
	status = "okay";
10
	pinctrl-names = "default";
10
	pinctrl-names = "default";
11
	pinctrl-0 = <&i2c0_pins>;
11
	pinctrl-0 = <&i2c0_pins>;
12
13
	eeprom: eeprom@50 {
14
                compatible = "atmel,24c32";
15
                reg = <0x68>;
16
        };
12
};
17
};
(-)b/sys/modules/dtb/allwinner/Makefile (-1 / +1 lines)
Lines 24-29 DTS= \ Link Here
24
	sun8i-h3-orangepi-plus2e.dts
24
	sun8i-h3-orangepi-plus2e.dts
25
25
26
DTSO=	sun8i-a83t-sid.dtso \
26
DTSO=	sun8i-a83t-sid.dtso \
27
	sun7i-a20-icee.dtso \
27
	sun8i-h3-i2c0.dtso
28
	sun8i-h3-i2c0.dtso
28
29
29
LINKS= \
30
LINKS= \
30
- 

Return to bug 247576