Skip to content

Commit

Permalink
Add support for Cheshire (CVA6), refactored Ariane to share CVA6
Browse files Browse the repository at this point in the history
Added support for Cheshire (CVA6). Refactored Ariane and Cheshire to use a shared mach definition since they both implement the CVA6 core and have common code.

Signed-off-by: Matt Rossouw <matthew.rossouw@unsw.edu.au>
  • Loading branch information
omeh-a committed Jan 23, 2025
1 parent f98dad1 commit cbbfb74
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libplatsupport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ config_choice(
set(LibPlatSupportMach "")
if(KernelPlatformRpi3 OR KernelPlatformRpi4)
set(LibPlatSupportMach "bcm")
elseif(KernelPlatformCheshire OR KernelPlatformAriane)
set(LibPlatSupportMach "cva6")
elseif(NOT ${KernelArmMach} STREQUAL "")
# falling back to kernel settings is done to keep legacy compatibility
set(LibPlatSupportMach "${KernelArmMach}")
Expand Down
53 changes: 53 additions & 0 deletions libplatsupport/plat_include/cheshire/platsupport/plat/apb_timer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2019, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#pragma once

#include <platsupport/timer.h>

#include <utils/util.h>
#include <stdint.h>
#include <stdbool.h>

/* The input frequence is the CPU frequency which is 50MHz by default */
#define APB_TIMER_INPUT_FREQ (50*1000*1000)
#define APB_TIMER_PADDR 0x18000000

/* Multiple timers */
#define APB_TIMER_DIST 0x10
#define APB_TIMER_NUM 2
#define APB_TIMER_BASE(n) APB_TIMER_DIST * n

#define CMP_WIDTH 32
#define APB_TIMER_CTRL_ENABLE BIT(0);
#define CMP_MASK MASK(CMP_WIDTH)

/* Timer IRQs */
#define APB_TIMER_PLIC_BASE 4
#define APB_TIMER_IRQ_OVF(n) APB_TIMER_PLIC_BASE + 2*n + 0x0
#define APB_TIMER_IRQ_CMP(n) APB_TIMER_PLIC_BASE + 2*n + 0x1

typedef struct {
/* vaddr apb_timer is mapped to */
void *vaddr;
} apb_timer_config_t;

typedef struct apb_timer {
volatile struct apb_timer_map *apb_timer_map;
uint64_t time_h;
} apb_timer_t;

struct apb_timer_map {
uint32_t time;
uint32_t ctrl;
uint32_t cmp;
};

int apb_timer_start(apb_timer_t *apb_timer);
int apb_timer_stop(apb_timer_t *apb_timer);
uint64_t apb_timer_get_time(apb_timer_t *apb_timer);
int apb_timer_set_timeout(apb_timer_t *apb_timer, uint64_t ns);
int apb_timer_init(apb_timer_t *apb_timer, apb_timer_config_t config);
19 changes: 19 additions & 0 deletions libplatsupport/plat_include/cheshire/platsupport/plat/serial.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2019, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#pragma once
#include <autoconf.h>

enum chardev_id {
PS_SERIAL0,
/* defaults */
PS_SERIAL_DEFAULT = PS_SERIAL0
};

#define PS_SERIAL_DEFAULT 0

#define DEFAULT_SERIAL_PADDR NULL
#define DEFAULT_SERIAL_INTERRUPT 0
16 changes: 16 additions & 0 deletions libplatsupport/src/mach/cva6/chardev.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright 2019, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include "../../chardev.h"
#include "../../common.h"
#include <utils/util.h>

struct ps_chardevice *
ps_cdev_init(enum chardev_id id, const ps_io_ops_t *o, struct ps_chardevice *d)
{
return NULL;
}

17 changes: 17 additions & 0 deletions libplatsupport/src/mach/cva6/serial.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright 2019, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include <stdlib.h>
#include <platsupport/serial.h>
#include <platsupport/plat/serial.h>
#include <string.h>

int uart_init(const struct dev_defn *defn,
const ps_io_ops_t *ops,
ps_chardevice_t *dev)
{
return 0;
}

0 comments on commit cbbfb74

Please sign in to comment.