[PATCH 07/15] HiFive1: add PRCI support files
Gedare Bloom
gedare at rtems.org
Thu Aug 17 15:07:27 UTC 2017
On Wed, Aug 16, 2017 at 11:12 AM, Denis Obrezkov
<denisobrezkov at gmail.com> wrote:
> ---
> c/src/lib/libbsp/riscv32/hifive1/include/prci.h | 74 +++++++++++++++++++++++++
> c/src/lib/libbsp/riscv32/hifive1/start/prci.c | 33 +++++++++++
> 2 files changed, 107 insertions(+)
> create mode 100644 c/src/lib/libbsp/riscv32/hifive1/include/prci.h
> create mode 100644 c/src/lib/libbsp/riscv32/hifive1/start/prci.c
>
> diff --git a/c/src/lib/libbsp/riscv32/hifive1/include/prci.h b/c/src/lib/libbsp/riscv32/hifive1/include/prci.h
> new file mode 100644
> index 0000000..a3432a8
> --- /dev/null
> +++ b/c/src/lib/libbsp/riscv32/hifive1/include/prci.h
> @@ -0,0 +1,74 @@
> +/*
> + *
> + * Copyright (c) 2017
> + * Denis Obrezkov <denisobrezkov at gmail.com>
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + * notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + * notice, this list of conditions and the following disclaimer in the
> + * documentation and/or other materials provided with the distribution.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> + * SUCH DAMAGE.
> + */
> +
> +#ifndef PRCI_H
> +#define PRCI_H
> +
> +/*
> + * PRCI description for HiFive1 system
> + */
> +#define PRCI_BASE 0x10008000
> +#define PRCI_HFROSCCFG 0x10008000
> +#define PRCI_HFXOSCCFG 0x10008004
> +#define PRCI_PLLCFG 0x10008008
> +#define PRCI_PLLOUTDIV 0x1000800C
> +#define PRCI_CORECLKCFG 0x10008010
> +
> +//16 MHz from external crystall oscillator
Prefer to use /* */ comments. Typo: crystal
> +#define hifive1_default_freq 16000000
> +
> +/*
> + * HFROSCCFG configuration register values
> + */
> +#define HFROSC_DIV_VAL 4
> +#define HFROSC_TRIM_VAL 16
> +#define HFROSC_EN_VAL 1
> +#define HFROSC_RDY_VAL 1
> +#define HFROSC_DIV_OFFSET 0
> +#define HFROSC_TRIM_OFFSET 16
> +#define HFROSC_EN_OFFSET 30
> +#define HFROSC_RDY_OFFSET 31
> +
> +/*
> + * HFXOSCCFG configuration register values
> + */
> +#define HFXOSC_EN_VAL 1
> +#define HFXOSC_RDY_VAL 1
> +#define HFXOSC_EN_OFFSET 30
> +#define HFXOSC_RDY_OFFSET 31
> +
> +
> +
Avoid more than 1 blank line in a row.
> +/*
> + * PLLCFG configuration register
> + */
> +#define PLL_SEL_OFFSET 16
> +
> +
> +static int hifive1_current_freq();
I'm not sure what the point of a static function prototype in a header
file is. this should probably be removed, or made non-static.
> +
> +#endif /* PRCI_H */
> diff --git a/c/src/lib/libbsp/riscv32/hifive1/start/prci.c b/c/src/lib/libbsp/riscv32/hifive1/start/prci.c
> new file mode 100644
> index 0000000..7e5237f
> --- /dev/null
> +++ b/c/src/lib/libbsp/riscv32/hifive1/start/prci.c
> @@ -0,0 +1,33 @@
> +/*
> + *
> + * Copyright (c) 2017
> + * Denis Obrezkov <denisobrezkov at gmail.com>
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + * notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + * notice, this list of conditions and the following disclaimer in the
> + * documentation and/or other materials provided with the distribution.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> + * SUCH DAMAGE.
> + */
> +
> +#include <bsp/prci.h>
> +
> +
> +static int hifive1_current_freq() {
> + return hifive1_default_freq;
> +}
Or you can make this static inline in the header file since it is rather simple.
> --
> 2.1.4
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
More information about the devel
mailing list