[PATCH 10/15] HiFive1: add clock driver support

Gedare Bloom gedare at rtems.org
Thu Aug 17 15:13:31 UTC 2017


On Wed, Aug 16, 2017 at 11:13 AM, Denis Obrezkov
<denisobrezkov at gmail.com> wrote:
> ---
>  c/src/lib/libbsp/riscv32/hifive1/clock/clock.c | 67 ++++++++++++++++++++++++++
>  1 file changed, 67 insertions(+)
>  create mode 100644 c/src/lib/libbsp/riscv32/hifive1/clock/clock.c
>
> diff --git a/c/src/lib/libbsp/riscv32/hifive1/clock/clock.c b/c/src/lib/libbsp/riscv32/hifive1/clock/clock.c
> new file mode 100644
> index 0000000..74132ed
> --- /dev/null
> +++ b/c/src/lib/libbsp/riscv32/hifive1/clock/clock.c
> @@ -0,0 +1,67 @@
> +/*
> + * Copyright (c) 2017 Denis Obrezkov <denisobrezkov at gmail.com>
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.org/license/LICENSE.
> + */
> +
> +
> +#include <bsp/irq.h>
> +#include <bsp/fatal.h>
> +#include <bsp/fe310.h>
> +
> +
> +static void FE310_clock_driver_support_install_isr(
> +  rtems_isr_entry Clock_isr
> +)
> +{
> +  rtems_status_code sc = RTEMS_SUCCESSFUL;
> +
> +  sc = rtems_interrupt_handler_install(
> +    1,
> +    "Clock",
> +    RTEMS_INTERRUPT_UNIQUE,
> +    (rtems_interrupt_handler) Clock_isr,
> +    NULL
> +  );
> +  if ( sc != RTEMS_SUCCESSFUL ) {
> +    rtems_fatal_error_occurred(0xdeadbeef);
> +  }
> +}
> +
> +static void FE310_clock_driver_support_at_tick ( void )
> +{
Does the timer automatically re-load?

> +}
> +
> +static void FE310_clock_init ( void )
> +{
> +  volatile uint64_t * mtime = (volatile uint64_t *)0x0200bff8;
> +  volatile uint64_t * mtimecmp = (volatile uint64_t *)0x02004000;
> +  (*mtimecmp) = (*mtime) + FE310_CLOCK_PERIOD + 0x3000;
> +  asm volatile ("csrci mstatus, 0x8");
> +  asm volatile ("li t0, 0x80\n\t"
> +                "csrs mie, t0");
> +  asm volatile ("csrsi mstatus, 0x8");
It would be good to have inline functions for reading/writing all of
these special purpose registers.

> +}
> +
> +static void FE310_clock_driver_support_shutdown_hardware( void )
> +{
> +}
> +
> +#define Clock_driver_support_initialize_hardware() \
> +  FE310_clock_init()
> +
> +#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
> +
> +#define Clock_driver_support_install_isr(isr,old) \
> +  FE310_clock_driver_support_install_isr ( isr )
> +
> +#define Clock_driver_support_at_tick() \
> +  FE310_clock_driver_support_at_tick()
> +
> +#define Clock_driver_support_shutdown_hardware() \
> +  FE310_clock_driver_support_shutdown_hardware()
> +
> +#include "../../../shared/clockdrv_shell.h"
> +
> --
> 2.1.4
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list