Skip to content

Commit 51804c2

Browse files
rpi: add uart device_path
Currently there is no device_path registered for UART in Raspberry Pi source. This will hinder the working of UART driver in mraa. So, register the device_path with '/dev/ttyS0' for all the raspberry pi models except Rpi3. For Rpi3 'dev/serial0' is used as most of the raspbian images make this as a symlink to _real_ UART port by default. Tested-on: Raspberry pi 3 model B Signed-off-by: Manivannan Sadhasivam <[email protected]>
1 parent 02963b7 commit 51804c2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/arm/raspberry_pi.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,52 +469,63 @@ mraa_raspberry_pi()
469469
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1;
470470
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1;
471471
b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT;
472+
b->uart_dev[0].device_path = "/dev/ttyS0";
472473
} else if (strstr(line, "0004") || strstr(line, "0005") || strstr(line, "0006") ||
473474
strstr(line, "000d") || strstr(line, "000e") || strstr(line, "000f")) {
474475
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_2;
475476
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_2;
476477
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT;
478+
b->uart_dev[0].device_path = "/dev/ttyS0";
477479
} else if (strstr(line, "900092") || strstr(line, "900093") || strstr(line, "920093")) {
478480
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_ZERO;
479481
platform_detected = PLATFORM_RASPBERRY_PI_ZERO;
480482
b->phy_pin_count = MRAA_RASPBERRY_PI_ZERO_PINCOUNT;
483+
b->uart_dev[0].device_path = "/dev/ttyS0";
481484
} else if (strstr(line, "0007") || strstr(line, "0008") || strstr(line, "0009")) {
482485
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_REV_2;
483486
platform_detected = PLATFORM_RASPBERRY_PI_A_REV_2;
484487
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT;
488+
b->uart_dev[0].device_path = "/dev/ttyS0";
485489
} else if (strstr(line, "0010")) {
486490
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_PLUS_REV_1;
487491
platform_detected = PLATFORM_RASPBERRY_PI_B_PLUS_REV_1;
488492
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT;
493+
b->uart_dev[0].device_path = "/dev/ttyS0";
489494
} else if (strstr(line, "0011")) {
490495
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_COMPUTE_MODULE_REV_1;
491496
platform_detected = PLATFORM_RASPBERRY_PI_COMPUTE_MODULE_REV_1;
492497
b->phy_pin_count = MRAA_RASPBERRY_PI_COMPUTE_MODULE_PINCOUNT;
498+
b->uart_dev[0].device_path = "/dev/ttyS0";
493499
} else if (strstr(line, "0012")) {
494500
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_PLUS_REV_1;
495501
platform_detected = PLATFORM_RASPBERRY_PI_A_PLUS_REV_1;
496502
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT;
503+
b->uart_dev[0].device_path = "/dev/ttyS0";
497504
} else if (strstr(line, "a01041") || strstr(line, "a21041")) {
498505
b->platform_name = PLATFORM_NAME_RASPBERRY_PI2_B_REV_1;
499506
platform_detected = PLATFORM_RASPBERRY_PI2_B_REV_1;
500507
b->phy_pin_count = MRAA_RASPBERRY_PI2_B_REV_1_PINCOUNT;
508+
b->uart_dev[0].device_path = "/dev/ttyS0";
501509
peripheral_base = BCM2836_PERI_BASE;
502510
block_size = BCM2836_BLOCK_SIZE;
503511
} else if (strstr(line, "a02082") || strstr(line, "a020a0") ||
504512
strstr(line, "a22082") || strstr(line, "a32082")) {
505513
b->platform_name = PLATFORM_NAME_RASPBERRY_PI3_B;
506514
platform_detected = PLATFORM_RASPBERRY_PI3_B;
507515
b->phy_pin_count = MRAA_RASPBERRY_PI3_B_PINCOUNT;
516+
b->uart_dev[0].device_path = "/dev/serial0";
508517
peripheral_base = BCM2837_PERI_BASE;
509518
block_size = BCM2837_BLOCK_SIZE;
510519
} else if (strstr(line, "9000c1")) {
511520
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_ZERO_W;
512521
platform_detected = PLATFORM_RASPBERRY_PI_ZERO_W;
513522
b->phy_pin_count = MRAA_RASPBERRY_PI_ZERO_W_PINCOUNT;
523+
b->uart_dev[0].device_path = "/dev/ttyS0";
514524
} else {
515525
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1;
516526
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1;
517527
b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT;
528+
b->uart_dev[0].device_path = "/dev/ttyS0";
518529
}
519530
}
520531
}
@@ -533,46 +544,57 @@ mraa_raspberry_pi()
533544
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1;
534545
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1;
535546
b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT;
547+
b->uart_dev[0].device_path = "/dev/ttyS0";
536548
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-b-rev2")) {
537549
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_2;
538550
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_2;
539551
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT;
552+
b->uart_dev[0].device_path = "/dev/ttyS0";
540553
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-zero")) {
541554
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_ZERO;
542555
platform_detected = PLATFORM_RASPBERRY_PI_ZERO;
543556
b->phy_pin_count = MRAA_RASPBERRY_PI_ZERO_PINCOUNT;
557+
b->uart_dev[0].device_path = "/dev/ttyS0";
544558
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-a")) {
545559
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_REV_2;
546560
platform_detected = PLATFORM_RASPBERRY_PI_A_REV_2;
547561
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT;
562+
b->uart_dev[0].device_path = "/dev/ttyS0";
548563
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-b-plus")) {
549564
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_PLUS_REV_1;
550565
platform_detected = PLATFORM_RASPBERRY_PI_B_PLUS_REV_1;
551566
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT;
567+
b->uart_dev[0].device_path = "/dev/ttyS0";
552568
} else if (mraa_file_contains(compatible_path, "raspberrypi,compute-module")) {
553569
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_COMPUTE_MODULE_REV_1;
554570
platform_detected = PLATFORM_RASPBERRY_PI_COMPUTE_MODULE_REV_1;
555571
b->phy_pin_count = MRAA_RASPBERRY_PI_COMPUTE_MODULE_PINCOUNT;
572+
b->uart_dev[0].device_path = "/dev/ttyS0";
556573
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-a-plus")) {
557574
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_PLUS_REV_1;
558575
platform_detected = PLATFORM_RASPBERRY_PI_A_PLUS_REV_1;
559576
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT;
577+
b->uart_dev[0].device_path = "/dev/ttyS0";
560578
} else if (mraa_file_contains(compatible_path, "raspberrypi,2-model-b")) {
561579
b->platform_name = PLATFORM_NAME_RASPBERRY_PI2_B_REV_1;
562580
platform_detected = PLATFORM_RASPBERRY_PI2_B_REV_1;
563581
b->phy_pin_count = MRAA_RASPBERRY_PI2_B_REV_1_PINCOUNT;
582+
b->uart_dev[0].device_path = "/dev/ttyS0";
564583
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-b")) {
565584
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1;
566585
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1;
567586
b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT;
587+
b->uart_dev[0].device_path = "/dev/ttyS0";
568588
} else if (mraa_file_contains(compatible_path, "raspberrypi,3-model-b")) {
569589
b->platform_name = PLATFORM_NAME_RASPBERRY_PI3_B;
570590
platform_detected = PLATFORM_RASPBERRY_PI3_B;
571591
b->phy_pin_count = MRAA_RASPBERRY_PI3_B_PINCOUNT;
592+
b->uart_dev[0].device_path = "/dev/serial0";
572593
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-zero-w")) {
573594
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_ZERO_W;
574595
platform_detected = PLATFORM_RASPBERRY_PI_ZERO_W;
575596
b->phy_pin_count = MRAA_RASPBERRY_PI_ZERO_W_PINCOUNT;
597+
b->uart_dev[0].device_path = "/dev/ttyS0";
576598
}
577599
}
578600

0 commit comments

Comments
 (0)