Skip to content

Commit

Permalink
platform: add Radxa CM3 platform support
Browse files Browse the repository at this point in the history
Signed-off-by: Nascs <nascs@radxa.com>
Co-authored-by: ZHANG Yuntian <yt@radxa.com>
  • Loading branch information
2 people authored and tingleby committed Oct 27, 2023
1 parent 81ece69 commit 651131b
Show file tree
Hide file tree
Showing 10 changed files with 332 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ARM
* [phyBOARD-Wega](../master/docs/phyboard-wega.md)
* [96Boards](../master/docs/96boards.md)
* [ADLINK IPi-SMARC ARM](../master/docs/adlink_ipi_arm.md)
* [Radxa CM3](../master/docs/radxa_cm3.md)
* [Radxa ROCK 3B](../master/docs/radxa_rock_3b.md)
* [Radxa ROCK 3C](../master/docs/radxa_rock_3c.md)
* [Radxa ROCK 5A](../master/docs/radxa_rock_5a.md)
Expand Down
36 changes: 35 additions & 1 deletion api/mraa/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ typedef enum {
MRAA_RADXA_ROCK_5A = 29, /**< Radxa ROCK 5 Model A */
MRAA_RADXA_ROCK_5B = 30, /**< Radxa ROCK 5 Model B */
MRAA_ORANGE_PI_PRIME = 31, /**< Orange Pi Prime board */
MRAA_RADXA_ROCK_3B = 32, /**< Radxa ROCK 3 Model B */
MRAA_RADXA_ROCK_3B = 32, /**< Radxa ROCK 3 Model B */
MRAA_RADXA_CM3 = 33, /**< Radxa CM3 */

// USB platform extenders start at 256
MRAA_FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */
Expand Down Expand Up @@ -316,6 +317,39 @@ typedef enum {
MRAA_RADXA_ROCK_3C_PIN40 = 40
} mraa_radxa_rock_3c_wiring_t;

/**
* Radxa CM3 IO GPIO numbering enum
*/
typedef enum {
MRAA_RADXA_CM3_IO_PIN3 = 3,
MRAA_RADXA_CM3_IO_PIN5 = 5,
MRAA_RADXA_CM3_IO_PIN7 = 7,
MRAA_RADXA_CM3_IO_PIN8 = 8,
MRAA_RADXA_CM3_IO_PIN10 = 10,
MRAA_RADXA_CM3_IO_PIN11 = 11,
MRAA_RADXA_CM3_IO_PIN12 = 12,
MRAA_RADXA_CM3_IO_PIN13 = 13,
MRAA_RADXA_CM3_IO_PIN15 = 15,
MRAA_RADXA_CM3_IO_PIN16 = 16,
MRAA_RADXA_CM3_IO_PIN18 = 18,
MRAA_RADXA_CM3_IO_PIN19 = 19,
MRAA_RADXA_CM3_IO_PIN21 = 21,
MRAA_RADXA_CM3_IO_PIN22 = 22,
MRAA_RADXA_CM3_IO_PIN23 = 23,
MRAA_RADXA_CM3_IO_PIN24 = 24,
MRAA_RADXA_CM3_IO_PIN27 = 27,
MRAA_RADXA_CM3_IO_PIN28 = 28,
MRAA_RADXA_CM3_IO_PIN29 = 29,
MRAA_RADXA_CM3_IO_PIN31 = 31,
MRAA_RADXA_CM3_IO_PIN32 = 32,
MRAA_RADXA_CM3_IO_PIN33 = 33,
MRAA_RADXA_CM3_IO_PIN35 = 35,
MRAA_RADXA_CM3_IO_PIN36 = 36,
MRAA_RADXA_CM3_IO_PIN37 = 37,
MRAA_RADXA_CM3_IO_PIN38 = 38,
MRAA_RADXA_CM3_IO_PIN40 = 40
} mraa_radxa_cm3_io_wiring_t;

/**
* ROCKPI4 GPIO numbering enum
*/
Expand Down
34 changes: 34 additions & 0 deletions api/mraa/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ typedef enum {
RADXA_ROCK_5B = 30, /**< Radxa ROCK 5 Model B */
ORANGE_PI_PRIME = 31, /**< Orange Pi Prime board */
RADXA_ROCK_3B = 32, /**< Radxa ROCK 3 Model B */
RADXA_CM3 = 33, /**< Radxa CM3 */

FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */

Expand Down Expand Up @@ -306,6 +307,39 @@ typedef enum {
RADXA_ROCK_3C_PIN40 = 40
} RadxaRock3CWiring;

/**
* Radxa CM3 IO GPIO numbering enum
*/
typedef enum {
RADXA_CM3_IO_PIN3 = 3,
RADXA_CM3_IO_PIN5 = 5,
RADXA_CM3_IO_PIN7 = 7,
RADXA_CM3_IO_PIN8 = 8,
RADXA_CM3_IO_PIN10 = 10,
RADXA_CM3_IO_PIN11 = 11,
RADXA_CM3_IO_PIN12 = 12,
RADXA_CM3_IO_PIN13 = 13,
RADXA_CM3_IO_PIN15 = 15,
RADXA_CM3_IO_PIN16 = 16,
RADXA_CM3_IO_PIN18 = 18,
RADXA_CM3_IO_PIN19 = 19,
RADXA_CM3_IO_PIN21 = 21,
RADXA_CM3_IO_PIN22 = 22,
RADXA_CM3_IO_PIN23 = 23,
RADXA_CM3_IO_PIN24 = 24,
RADXA_CM3_IO_PIN27 = 27,
RADXA_CM3_IO_PIN28 = 28,
RADXA_CM3_IO_PIN29 = 29,
RADXA_CM3_IO_PIN31 = 31,
RADXA_CM3_IO_PIN32 = 32,
RADXA_CM3_IO_PIN33 = 33,
RADXA_CM3_IO_PIN35 = 35,
RADXA_CM3_IO_PIN36 = 36,
RADXA_CM3_IO_PIN37 = 37,
RADXA_CM3_IO_PIN38 = 38,
RADXA_CM3_IO_PIN40 = 40
} RadxaCM3IOWiring;

/**
* ROCKPI4 GPIO numbering enum
*/
Expand Down
6 changes: 6 additions & 0 deletions docs/index.java.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ Specific platform information for supported platforms is documented here:
- @ref iei-tank
- @ref up-xtreme
- @ref _orange_pi_prime
- @ref radxa_cm3
- @ref radxa_rock_3b
- @ref radxa_rock_3c
- @ref radxa_rock_5a
- @ref radxa_rock_5b
- @ref rockpi4

## DEBUGGING

Expand Down
6 changes: 6 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ Specific platform information for supported platforms is documented here:
- @ref iei-tank
- @ref upXtreme
- @ref _orange_pi_prime
- @ref radxa_cm3
- @ref radxa_rock_3b
- @ref radxa_rock_3c
- @ref radxa_rock_5a
- @ref radxa_rock_5b
- @ref rockpi4

## DEBUGGING

Expand Down
48 changes: 48 additions & 0 deletions docs/radxa_cm3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Radxa CM3 {#_Radxa}
=========

The Radxa CM3 is a System on Module (SoM) based on the Rockchip RK3566 System on Chip (SoC). CM3 integrates the Central Process Unit (CPU), Power Management Unit (PMU), DRAM memory, flash storage and wireless connectivity (WiFi 5 and BT 5.0) in a small form factor of just 55mm x 40mm. CM3 uses 3x 100P 0.4mm-pitch Board-to-Board connectors to export various features, and can be combined with the customer's baseboard to build complete products, thereby speeding up the research and development process.
Currently, CM3 is compatible with Radxa CM3 IO Board and Raspberry Pi CM4 IO Board.

Interface notes
---------------

- UART2 is enabled as the default console.
- All UART ports support baud up to 1500000.

Pin Mapping
-----------

Radxa CM3 IO Board and Raspberry Pi CM4 IO Baseboard's 40-pin expansion header are compatible. The following pinout applies to both products:

| Function3| Function3| Function2| Function1| PIN | PIN | Function1| Function2| Function3|
|-------------|------------|-------------|----------|:------|------:|-----------|-------------|----------|
| | | | 3V3| 1 | 2 | +5.0V| | |
| PWM2_M1|SPI0_MOSI_M0| I2C2_SDA_M0| GPIO0_B6| 3 | 4 | +5.0V| | |
| PWM1_M1| SPI0_CLK_M0| I2C2_SCL_M0| GPIO0_B5| 5 | 6 | GND| | |
| | | | GPIO3_D5| 7 | 8 | GPIO0_D1| UART2_TX_M0| |
| | | | GND| 9 | 10 | GPIO0_D0| UART2_RX_M0| |
| | | PWM0_M1| GPIO0_C7| 11 | 12 | GPIO3_C7| | |
| | | PWM0_M0| GPIO0_B7| 13 | 14 | GND| | |
| | | PWM4| GPIO0_C3| 15 | 16 | GPIO3_D4| | |
| | | | +3.3V| 17 | 18 | GPIO3_D3| | |
| | I2C4_SDA_M0| SPI3_MOSI_M0| GPIO4_B2| 19 | 20 | GND| | |
| | | SPI3_MISO_M0| GPIO4_B0| 21 | 22 | GPIO3_C6| | |
| | I2C4_SCL_M0| SPI3_CLK_M0| GPIO4_B3| 23 | 24 | GPIO4_A6| SPI3_CS0_M0| |
| | | | GND| 25 | 26 |SARADC_VIN3| | |
| | | I2C2_SDA_M1| GPIO4_B4| 27 | 28 | GPIO4_B5| I2C2_SCL_M1| |
| | | | GPIO4_B1| 29 | 30 | GND| | |
| | PWM6| SPI0_MISO_M0| GPIO0_C5| 31 | 32 | GPIO4_C0| UART5_TX_M1| |
| | PWM7_IR| SPI0_CS0_M0| GPIO0_C6| 33 | 34 | GND| | |
| | | | GPIO3_D0| 35 | 36 | GPIO4_A7| SPI3_CS1_M0| |
| | | PWM3_IR| GPIO0_C2| 37 | 38 | GPIO3_D2| | |
| | | | GND| 39 | 40 | GPIO3_D1| | |

Supports
--------

You can find additional product support in the following channels:

- [Product Info](https://docs.radxa.com/en/compute-module/cm3)
- [Forums](https://forum.radxa.com/c/rock3)
- [Github](https://github.com/radxa)
32 changes: 32 additions & 0 deletions include/arm/radxa_cm3.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Author: Nascs <nascs@radxa.com>
* Copyright (c) 2023 Radxa Limited.
*
* SPDX-License-Identifier: MIT
*/

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include "mraa_internal.h"

#define MRAA_RADXA_CM3_GPIO_COUNT 28
#define MRAA_RADXA_CM3_I2C_COUNT 3
#define MRAA_RADXA_CM3_SPI_COUNT 2
#define MRAA_RADXA_CM3_UART_COUNT 1
#define MRAA_RADXA_CM3_PWM_COUNT 9
#define MRAA_RADXA_CM3_AIO_COUNT 1
#define MRAA_RADXA_CM3_PIN_COUNT 40
#define PLATFORM_NAME_RADXA_CM3_IO "Radxa Compute Module 3(CM3) IO Board"
#define PLATFORM_NAME_RADXA_CM3_IO_2 "Radxa CM3 IO Board"
#define PLATFORM_NAME_RADXA_CM3_RPI_CM4_IO "Radxa CM3 RPI CM4 IO" // The core board of the Radxa CM3 is compatible with the RPI CM4 IO backplane.

mraa_board_t *
mraa_radxa_cm3();

#ifdef __cplusplus
}
#endif
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ set (mraa_LIB_ARM_SRCS_NOAUTO
${PROJECT_SOURCE_DIR}/src/arm/de_nano_soc.c
${PROJECT_SOURCE_DIR}/src/arm/radxa_rock_3b.c
${PROJECT_SOURCE_DIR}/src/arm/radxa_rock_3c.c
${PROJECT_SOURCE_DIR}/src/arm/radxa_cm3.c
${PROJECT_SOURCE_DIR}/src/arm/radxa_rock_5a.c
${PROJECT_SOURCE_DIR}/src/arm/radxa_rock_5b.c
${PROJECT_SOURCE_DIR}/src/arm/rockpi4.c
Expand Down
8 changes: 8 additions & 0 deletions src/arm/arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <string.h>

#include "arm/96boards.h"
#include "arm/radxa_cm3.h"
#include "arm/radxa_rock_3b.h"
#include "arm/radxa_rock_3c.h"
#include "arm/radxa_rock_5a.h"
Expand Down Expand Up @@ -96,6 +97,10 @@ mraa_arm_platform()
platform_type = MRAA_96BOARDS;
else if (mraa_file_contains("/proc/device-tree/model", "Avnet Ultra96 Rev1"))
platform_type = MRAA_96BOARDS;
else if (mraa_file_contains("/proc/device-tree/model", PLATFORM_NAME_RADXA_CM3_IO) ||
mraa_file_contains("/proc/device-tree/model", PLATFORM_NAME_RADXA_CM3_IO_2) ||
mraa_file_contains("/proc/device-tree/model", PLATFORM_NAME_RADXA_CM3_RPI_CM4_IO))
platform_type = MRAA_RADXA_CM3;
else if (mraa_file_contains("/proc/device-tree/model", PLATFORM_NAME_RADXA_ROCK_3B))
platform_type = MRAA_RADXA_ROCK_3B;
else if (mraa_file_contains("/proc/device-tree/model", PLATFORM_NAME_RADXA_ROCK_3C))
Expand Down Expand Up @@ -135,6 +140,9 @@ mraa_arm_platform()
case MRAA_96BOARDS:
plat = mraa_96boards();
break;
case MRAA_RADXA_CM3:
plat = mraa_radxa_cm3();
break;
case MRAA_RADXA_ROCK_3B:
plat = mraa_radxa_rock_3b();
break;
Expand Down
Loading

0 comments on commit 651131b

Please sign in to comment.