Skip to content

Commit

Permalink
add milkv duo256m and duos platforms
Browse files Browse the repository at this point in the history
The soc used by Duo256M and DuoS is Sophgo's sg200x.

Signed-off-by: carbon <carbon@milkv.io>
Co-authored-by: wcl <wangchenlong@milkv.io>
  • Loading branch information
carbonfix and wcl20000313 committed Apr 23, 2024
1 parent 64c581d commit c511029
Show file tree
Hide file tree
Showing 14 changed files with 750 additions and 0 deletions.
Binary file added docs/source/platforms/milkv/duo256m.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions docs/source/platforms/milkv/duo256m.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.. |yes| image:: ../../images/yes.png
.. |no| image:: ../../images/no.png

.. role:: underline
:class: underline

Milk-V Duo256m
==========

+----------------+-----------------+
| System on Chip | Sophgo SG2002 |
+----------------+-----------------+
| Number GPIO | 26 |
+----------------+-----------------+
| Status | Fully supported |
+----------------+-----------------+

Supported Features
------------------

+----------------+-----------------+
| Read / Write | |yes| |
+----------------+-----------------+
| Interrupt | |yes| |
+----------------+-----------------+

GPIO Mapping
------------

.. image:: duo256m.jpg

+----+----+-----+------+------+-----+-----+-----+----+----+-----+----+-----+----+----+----+----+-----+----+----+
| 5V | 5V | GND | 3.3V | 3.3V | N/A | N/A | GND | 27 | 26 | RUN | 22 | GND | 21 | 20 | 19 | 18 | GND | 17 | 16 |
+----+----+-----+------+------+-----+-----+-----+----+----+-----+----+-----+----+----+----+----+-----+----+----+
| 0 | 1 | GND | 2 | 3 | 4 | 5 | GND | 6 | 7 | 8 | 9 | GND | 10 | 11 | 12 | 13 | GND | 14 | 15 |
+----+----+-----+------+------+-----+-----+-----+----+----+-----+----+-----+----+----+----+----+-----+----+----+

Additional
----------

- Blue LED: 25

Note: GPIO 25 is the system status indicator LED of Duo256M.
Before using wiringX to control this LED, its blinking function needs to be disabled in the system.
Otherwise, the control will not take effect and no error message will be returned.
Binary file added docs/source/platforms/milkv/duos.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions docs/source/platforms/milkv/duos.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.. |yes| image:: ../../images/yes.png
.. |no| image:: ../../images/no.png

.. role:: underline
:class: underline

Milk-V Duos
==========

+----------------+-----------------+
| System on Chip | Sophgo SG2002 |
+----------------+-----------------+
| Number GPIO | 39 |
+----------------+-----------------+
| Status | Fully supported |
+----------------+-----------------+

Supported Features
------------------

+----------------+-----------------+
| Read / Write | |yes| |
+----------------+-----------------+
| Interrupt | |yes| |
+----------------+-----------------+

GPIO Mapping
------------

J3:
+------+----+-----+---+-----+----+-----+----+------+-----+----+----+-----+
| 5V | 5V | GND | 8 | 10 | 12 | GND | 16 | 18 | GND | 22 | 24 | 26 |
+------+----+-----+---+-----+----+-----+----+------+-----+----+----+-----+
| 3.3V | 3 | 5 | 7 | GND | 11 | 13 | 15 | 3.3V | 19 | 21 | 23 | GND |
+------+----+-----+---+-----+----+-----+----+------+-----+----+----+-----+

.. image:: duos.jpg

J4:
+-----+-----+-----+-----+------+----+----+-----+----+----+-----+----+----+
| N/A | N/A | N/A | N/A | 3.3V | 41 | 39 | GND | 35 | 33 | GND | 29 | 27 |
+-----+-----+-----+-----+------+----+----+-----+----+----+-----+----+----+
| 5V | 50 | 48 | 46 | 44 | 42 | 40 | GND | 36 | 34 | GND | 30 | 28 |
+-----+-----+-----+-----+------+----+----+-----+----+----+----+----+-----+

Additional
----------

- Blue LED: 0

Note: GPIO 0 is the system status indicator LED of DuoS.
Before using wiringX to control this LED, its blinking function needs to be disabled in the system.
Otherwise, the control will not take effect and no error message will be returned.
2 changes: 2 additions & 0 deletions docs/source/platforms/milkv/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ Milk-V
:maxdepth: 2

duo
duo256m
duos
3 changes: 3 additions & 0 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'../src/soc/samsung/exynos5422.c',
'../src/soc/rockchip/rk3399.c',
'../src/soc/sophgo/cv180x.c',
'../src/soc/sophgo/sg200x.c',
'../src/platform/platform.c',
'../src/platform/hardkernel/odroidc1.c',
'../src/platform/hardkernel/odroidc2.c',
Expand All @@ -48,6 +49,8 @@
'../src/platform/radxa/rock4.c',
'../src/platform/radxa/rock5b.c',
'../src/platform/milkv/duo.c'
'../src/platform/milkv/duo256m.c'
'../src/platform/milkv/duos.c'
],
include_dirs=['../src/']
),
Expand Down
2 changes: 2 additions & 0 deletions python/wiringX/wiringx.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ PyMODINIT_FUNC initgpio(void) {
PyModule_AddObject(module, "ROCK4", Py_BuildValue("s", "rock4"));
PyModule_AddObject(module, "ROCK5B", Py_BuildValue("s", "rock5b"));
PyModule_AddObject(module, "MILKV_DUO", Py_BuildValue("s", "milkv_duo"));
PyModule_AddObject(module, "MILKV_DUO256M", Py_BuildValue("s", "milkv_duo256m"));
PyModule_AddObject(module, "MILKV_DUOS", Py_BuildValue("s", "milkv_duos"));

#if PY_MAJOR_VERSION >= 3
return module;
Expand Down
58 changes: 58 additions & 0 deletions src/platform/milkv/duo256m.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copyright (c) 2024 Shenzhen Milk-V Technology Co., Ltd
Author: William James <willian@milkv.io>
Carbon <carbon@milkv.io>
Zhang Yuntian <zhangyuntian@milkv.io>
wcl <wangchenlong@milkv.io>
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#include "duo256m.h"

struct platform_t *milkv_duo256m = NULL;

static int map[] = {
/* XGPIOA[28] XGPIOA[29] XGPIOA[19] XGPIOA[18] */
28, 29, 19, 18,

/* PWR_GPIO[19] PWR_GPIO[20] PWR_GPIO[23] PWR_GPIO[22] */
115, 116, 119, 118,

/* PWR_GPIO[21] PWR_GPIO[18] XGPIOC[14] XGPIOC[15] */
117, 114, 78, 79,

/* XGPIOA[16] XGPIOA[17] XGPIOA[14] XGPIOA[15] */
16, 17, 14, 15,

/* XGPIOA[23] XGPIOA[24] XGPIOA[22] XGPIOA[25] */
23, 24, 22, 25,

/* XGPIOA[27] XGPIOA[26] PWR_GPIO[4] N/A */
27, 26, 100, -1,

/* N/A PWR_GPIO[2] XGPIOB[3] XGPIOB[6] */
-1, 98, 35, 38
};

static int milkv_duo256mValidGPIO(int pin) {
return milkvValidGPIO(pin, map, _sizeof(map));
}

static int milkv_duo256mSetup(void) {
return milkvSetup(milkv_duo256m, map, _sizeof(map));
}

void milkv_duo256mInit(void) {
platform_register(&milkv_duo256m, "milkv_duo256m");

milkv_duo256m->soc = soc_get("Sophgo", "SG200X");
milkv_duo256m->soc->setMap(map, _sizeof(map));

milkvInit(milkv_duo256m);

milkv_duo256m->setup = &milkv_duo256mSetup;
milkv_duo256m->validGPIO = &milkv_duo256mValidGPIO;
}
22 changes: 22 additions & 0 deletions src/platform/milkv/duo256m.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright (c) 2024 Shenzhen Milk-V Technology Co., Ltd
Author: William James <willian@milkv.io>
Carbon <carbon@milkv.io>
Zhang Yuntian <zhangyuntian@milkv.io>
wcl <wangchenlong@milkv.io>
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#ifndef __WIRINGX_MILKV_DUO256M_H_
#define __WIRINGX_MILKV_DUO256M_H_

#include "common.h"

extern struct platform_t *milkv_duo256m;

void milkv_duo256mInit(void);

#endif
76 changes: 76 additions & 0 deletions src/platform/milkv/duos.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
Copyright (c) 2024 Shenzhen Milk-V Technology Co., Ltd
Author: William James <willian@milkv.io>
Carbon <carbon@milkv.io>
Zhang Yuntian <zhangyuntian@milkv.io>
wcl <wangchenlong@milkv.io>
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#include "duos.h"

struct platform_t *milkv_duos = NULL;

static int map[] = {
/* XGPIOA[29] 3V3 VSYS XGPIOB[20] */
29, -1, -1, 52,

/* VSYS XGPIOB[21] GND XGPIOB[18] */
-1, 53, -1, 50,

/* XGPIOA[16] XGPIOB[17] XGPIOA[17] XGPIOB[11] */
16, 49, 17, 43,

/* XGPIOB[19] XGPIOB[12] GND XGPIOB[22] */
51, 44, -1, 54,

/* XGPIOA[20] N/A XGPIOA[19] XGPIOB[13] */
20, -1, 19, 45,

/* GND XGPIOB[14] XGPIOA[18] XGPIOB[15] */
-1, 46, 18, 47,

/* XGPIOB[16] GND XGPIOA[28] XGPIOC[13] */
48, -1, 28, 77,

/* XGPIOC[15] XGPIOC[12] XGPIOC[14] GND */
79, 76, 78, -1,

/* GND XGPIOC[17] XGPIOC[21] XGPIOC[16] */
-1, 81, 85, 80,

/* XGPIOC[20] GND GND XGPIOC[19] */
84, -1, -1, 83,

/* PWR_GPIO[0] XGPIOC[18] PWR_GPIO[1] 3V3 */
96, 82, 97, -1,

/* PWR_GPIO[2] AUDIO_IN_L XGPIOB[3] AUDIO_IN_R */
98, -1, 35, -1,

/* XGPIOB[2] AUDIO_OUT_L XGPIOB[1] AUDIO_OUT_R */
34, -1, 33, -1,
};

static int milkv_duosValidGPIO(int pin) {
return milkvValidGPIO(pin, map, _sizeof(map));
}

static int milkv_duosSetup(void) {
return milkvSetup(milkv_duos, map, _sizeof(map));
}

void milkv_duosInit(void) {
platform_register(&milkv_duos, "milkv_duos");

milkv_duos->soc = soc_get("Sophgo", "SG200X");
milkv_duos->soc->setMap(map, _sizeof(map));

milkvInit(milkv_duos);

milkv_duos->setup = &milkv_duosSetup;
milkv_duos->validGPIO = &milkv_duosValidGPIO;
}
22 changes: 22 additions & 0 deletions src/platform/milkv/duos.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright (c) 2024 Shenzhen Milk-V Technology Co., Ltd
Author: William James <willian@milkv.io>
Carbon <carbon@milkv.io>
Zhang Yuntian <zhangyuntian@milkv.io>
wcl <wangchenlong@milkv.io>
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#ifndef __WIRINGX_MILKV_DUOS_H_
#define __WIRINGX_MILKV_DUOS_H_

#include "common.h"

extern struct platform_t *milkv_duos;

void milkv_duosInit(void);

#endif
Loading

0 comments on commit c511029

Please sign in to comment.