-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix milkv duo platform on sophgo cv180x soc
Signed-off-by: carbon <carbon@milkv.io>
- Loading branch information
Showing
9 changed files
with
186 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
Copyright (c) 2024 Shenzhen Milk-V Technology Co., Ltd | ||
Author: William James <willian@milkv.io> | ||
Carbon <carbon@milkv.io> | ||
Zhang Yuntian <zhangyuntian@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 "common.h" | ||
|
||
int milkvValidGPIO(int pin, int *map, int map_count) { | ||
return (pin < 0 || pin >= map_count || map[pin] == -1) ? -1 : 0; | ||
} | ||
|
||
int milkvSetup(struct platform_t *platform, int *map, int map_count) { | ||
int ret = 0; | ||
|
||
ret = platform->soc->setup(); | ||
if(ret == 0) { | ||
platform->soc->setMap(map, map_count); | ||
platform->soc->setIRQ(map, map_count); | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
void milkvInit(struct platform_t *platform) { | ||
platform->digitalRead = platform->soc->digitalRead; | ||
platform->digitalWrite = platform->soc->digitalWrite; | ||
platform->pinMode = platform->soc->pinMode; | ||
|
||
platform->isr = platform->soc->isr; | ||
platform->waitForInterrupt = platform->soc->waitForInterrupt; | ||
|
||
platform->selectableFd = platform->soc->selectableFd; | ||
platform->gc = platform->soc->gc; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
Copyright (c) 2024 Shenzhen Milk-V Technology Co., Ltd | ||
Author: William James <willian@milkv.io> | ||
Carbon <carbon@milkv.io> | ||
Zhang Yuntian <zhangyuntian@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_COMMON_H_ | ||
#define __WIRINGX_MILKV_COMMON_H_ | ||
|
||
#include <sys/mman.h> | ||
#include <unistd.h> | ||
#include <stdio.h> | ||
#include <fcntl.h> | ||
#include <errno.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <sys/ioctl.h> | ||
#include <signal.h> | ||
|
||
#include "../../soc/soc.h" | ||
#include "../../wiringx.h" | ||
#include "../platform.h" | ||
|
||
#define _sizeof(arr) (sizeof(arr) / sizeof(arr[0])) | ||
|
||
int milkvValidGPIO(int pin, int *map, int map_count); | ||
int milkvSetup(struct platform_t *platform, int *map, int map_count); | ||
void milkvInit(struct platform_t *platform); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
Copyright (c) 2024 Shenzhen Milk-V Technology Co., Ltd | ||
Author: William James <willian@milkv.io> | ||
Carbon <carbon@milkv.io> | ||
Zhang Yuntian <zhangyuntian@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_SOPHGO_COMMON_H | ||
#define __WIRINGX_SOPHGO_COMMON_H | ||
|
||
#include <sys/mman.h> | ||
#include <unistd.h> | ||
#include <stdio.h> | ||
#include <fcntl.h> | ||
#include <errno.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <ctype.h> | ||
|
||
#include "../../wiringx.h" | ||
#include "../soc.h" | ||
#include "../../i2c-dev.h" | ||
|
||
// register data currently unavailable. | ||
// Assuming each bank contains 32 GPIO lines, we fill them with placeholder data, in case they become available in the future. | ||
#define GPIO_UNAVAILABLE(x) {(x), 0, 0, {0, 0}, {0, 0}, {0, 0}, FUNCTION_UNKNOWN, 0, 0} | ||
|
||
const static uintptr_t gpio_register_physical_address[MAX_REG_AREA] = {0x03020000, 0x03021000, 0x03022000, 0x05021000}; | ||
#define GPIO_SWPORTA_DR 0x000 | ||
#define GPIO_SWPORTA_DDR 0x004 | ||
#define GPIO_EXT_PORTA 0x050 | ||
|
||
static uintptr_t pinmux_register_virtual_address = NULL; | ||
|
||
#define PINMUX_BASE 0x03001000 // pinmux group 1 | ||
|
||
#define CLEAR_BITS(addr, bit, size) \ | ||
(*addr = *addr & ~(~(-1 << size) << bit) | (~(-1 << size) << bit << REGISTER_WRITE_MASK)) | ||
#define GET_BITS(addr, bit, size) \ | ||
((*addr & ~(-1 << size) << bit) >> (bit - size)) | ||
|
||
#endif |
Oops, something went wrong.