Skip to content

Commit

Permalink
rpi: add uart device_path
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Mani-Sadhasivam committed Nov 15, 2017
1 parent 02963b7 commit 51804c2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/arm/raspberry_pi.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,52 +469,63 @@ mraa_raspberry_pi()
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else if (strstr(line, "0004") || strstr(line, "0005") || strstr(line, "0006") ||
strstr(line, "000d") || strstr(line, "000e") || strstr(line, "000f")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_2;
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_2;
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else if (strstr(line, "900092") || strstr(line, "900093") || strstr(line, "920093")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_ZERO;
platform_detected = PLATFORM_RASPBERRY_PI_ZERO;
b->phy_pin_count = MRAA_RASPBERRY_PI_ZERO_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else if (strstr(line, "0007") || strstr(line, "0008") || strstr(line, "0009")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_REV_2;
platform_detected = PLATFORM_RASPBERRY_PI_A_REV_2;
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else if (strstr(line, "0010")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_PLUS_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI_B_PLUS_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else if (strstr(line, "0011")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_COMPUTE_MODULE_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI_COMPUTE_MODULE_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI_COMPUTE_MODULE_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else if (strstr(line, "0012")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_PLUS_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI_A_PLUS_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else if (strstr(line, "a01041") || strstr(line, "a21041")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI2_B_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI2_B_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI2_B_REV_1_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
peripheral_base = BCM2836_PERI_BASE;
block_size = BCM2836_BLOCK_SIZE;
} else if (strstr(line, "a02082") || strstr(line, "a020a0") ||
strstr(line, "a22082") || strstr(line, "a32082")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI3_B;
platform_detected = PLATFORM_RASPBERRY_PI3_B;
b->phy_pin_count = MRAA_RASPBERRY_PI3_B_PINCOUNT;
b->uart_dev[0].device_path = "/dev/serial0";
peripheral_base = BCM2837_PERI_BASE;
block_size = BCM2837_BLOCK_SIZE;
} else if (strstr(line, "9000c1")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_ZERO_W;
platform_detected = PLATFORM_RASPBERRY_PI_ZERO_W;
b->phy_pin_count = MRAA_RASPBERRY_PI_ZERO_W_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
}
}
}
Expand All @@ -533,46 +544,57 @@ mraa_raspberry_pi()
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-b-rev2")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_2;
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_2;
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-zero")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_ZERO;
platform_detected = PLATFORM_RASPBERRY_PI_ZERO;
b->phy_pin_count = MRAA_RASPBERRY_PI_ZERO_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-a")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_REV_2;
platform_detected = PLATFORM_RASPBERRY_PI_A_REV_2;
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_REV_2_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-b-plus")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_PLUS_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI_B_PLUS_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else if (mraa_file_contains(compatible_path, "raspberrypi,compute-module")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_COMPUTE_MODULE_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI_COMPUTE_MODULE_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI_COMPUTE_MODULE_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-a-plus")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_A_PLUS_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI_A_PLUS_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI_AB_PLUS_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else if (mraa_file_contains(compatible_path, "raspberrypi,2-model-b")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI2_B_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI2_B_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI2_B_REV_1_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-b")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_B_REV_1;
platform_detected = PLATFORM_RASPBERRY_PI_B_REV_1;
b->phy_pin_count = MRAA_RASPBERRY_PI_B_REV_1_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
} else if (mraa_file_contains(compatible_path, "raspberrypi,3-model-b")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI3_B;
platform_detected = PLATFORM_RASPBERRY_PI3_B;
b->phy_pin_count = MRAA_RASPBERRY_PI3_B_PINCOUNT;
b->uart_dev[0].device_path = "/dev/serial0";
} else if (mraa_file_contains(compatible_path, "raspberrypi,model-zero-w")) {
b->platform_name = PLATFORM_NAME_RASPBERRY_PI_ZERO_W;
platform_detected = PLATFORM_RASPBERRY_PI_ZERO_W;
b->phy_pin_count = MRAA_RASPBERRY_PI_ZERO_W_PINCOUNT;
b->uart_dev[0].device_path = "/dev/ttyS0";
}
}

Expand Down

0 comments on commit 51804c2

Please sign in to comment.