Skip to content

Commit

Permalink
Implement config_table
Browse files Browse the repository at this point in the history
A section of config symbols for firmware to read and apply.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
  • Loading branch information
FlyGoat committed Feb 11, 2020
1 parent b3b64af commit 72a1a37
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 36 deletions.
2 changes: 1 addition & 1 deletion core/applications/SConscript
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from building import *

cwd = GetCurrentDir()
src = Glob('*.c')
src = Glob('*.c') + Glob('*.S')

group = DefineGroup('Applications', src, depend = [''])

Expand Down
25 changes: 25 additions & 0 deletions core/applications/config_table.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* SPDX-License-Identifier: MIT OR Apache-2.0 */
/*
* Copyright (C) 2019, 2020 Jiaxun Yang <jiaxun.yang@flygoat.com>
*/


#ifndef __ASSEMBLY__
#define __ASSEMBLY__
#endif

#include "miku_config.h"

.section ".config_table", "ax"
.set noreorder
config_table_entry: /* RAM_BASE + 0x800 */
.word(MIKU_MODEL_MAGIG) /* Magic Number + 0x0 */
.word(MIKU_CURRENT_VERSION) /* Version + 0x4 */
.word(0x1) /* Config Table Version + 0x8 */
.word(25000000) /* CCFreq + 0xc */ /* FIXME: Coule be other vallues */
.word(BASEFREQ / 25 | (1 << 16)) /* CFD and CFM + 0x10 */ /* FIXME: Coule be other vallues */
.word(BOOT_DIV | (BOOT_LOOPC << 8) | (BOOT_REFC << 24)) /* PLL CFG + 0x14 */ /* [7:0]: DIV, [8:23]: LOOPC, [24:31]: REFC */
.word(BOOT_VID) /* BOOT_VID mV + 0x18 */
.word(BOOSTFREQ) /* BOOSTFREQ + 0x1c */
config_table_end:
.ascii "MikuMikuMiku"
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
* Copyright (C) 2019, 2020 Jiaxun Yang <jiaxun.yang@flygoat.com>
*/

#include "miku.h"
#define BASEFREQ 1500
#define BOOT_VID 1150
#define BOOT_DIV 1
#define BOOT_LOOPC 15
#define BOOT_REFC 1
#define BOOSTFREQ 2000

#if defined(MIKU_INDVFS) && !defined(__ASSEMBLY__)
#define NUM_PLL_LEVEL 3

struct pll_level pll_levels[NUM_PLL_LEVEL] =
{{/* Idle: Max 725MHz */
.refc = 1,
.loopc = 15,
.div = 1,
.refc = BOOT_REFC,
.loopc = BOOT_LOOPC,
.div = BOOT_DIV,
.vid = 1000, /* FIXME: Low down it later */
.highest_scale = (4 - 1), /* 4 / 8 */
.lowest_scale = 0, /* 1 / 8 */
Expand All @@ -22,10 +28,10 @@ struct pll_level pll_levels[NUM_PLL_LEVEL] =
.max_temp = 120,
.sram_val = 0x1f156f
},{/* Normal: Max 1500MHz */
.refc = 1,
.loopc = 15,
.div = 1,
.vid = 1150,
.refc = BOOT_REFC,
.loopc = BOOT_LOOPC,
.div = BOOT_DIV,
.vid = BOOT_VID,
.highest_scale = (8 - 1), /* 8 / 8 */
.lowest_scale = (5 - 1), /* 5 / 8 */
.stable_scale = (8 - 1), /* 8/8, 1500MHz */
Expand All @@ -37,8 +43,8 @@ struct pll_level pll_levels[NUM_PLL_LEVEL] =
},{/* Boost: Max 2000MHz */
.refc = 1,
.loopc = 20,
.div = 1400,
.vid = 100,
.div = 1,
.vid = 1400,
.highest_scale = (8 - 1), /* 8 / 8 */
.lowest_scale = (5 - 1), /* 5 / 8 */
.stable_scale = (6 - 1), /* 6/8, 1500MHz */
Expand All @@ -52,6 +58,6 @@ struct pll_level pll_levels[NUM_PLL_LEVEL] =
/* Shadow means what we tell kernel */
#define SHADOW_LEVEL_NUM 10
#define BASEFREQ_SHADOW_LEVEL 7
#define BASEFREQ 1500
rt_uint16_t shadow_level_freq[SHADOW_LEVEL_NUM] = {187, 375, 562, 750, 937, 1312, BASEFREQ, 1750, 2000};
rt_uint32_t core_scale_min = 3000;
#endif
25 changes: 16 additions & 9 deletions core/applications/dvfs_policy_2200.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
* Copyright (C) 2019, 2020 Jiaxun Yang <jiaxun.yang@flygoat.com>
*/

#include "miku.h"
#define BASEFREQ 1650
#define BOOT_VID 1150
#define BOOT_DIV 1
#define BOOT_LOOPC 33
#define BOOT_REFC 2
#define BOOSTFREQ 2200

#if defined(MIKU_INDVFS) && !defined(__ASSEMBLY__)
#define NUM_PLL_LEVEL 3

struct pll_level pll_levels[NUM_PLL_LEVEL] =
{{/* Idle: Max 825MHz */
.refc = 2,
.loopc = 33,
.div = 1,
.refc = BOOT_REFC,
.loopc = BOOT_LOOPC,
.div = BOOT_DIV,
.vid = 1000, /* FIXME: Low down it later */
.highest_scale = (4 - 1), /* 4 / 8 */
.lowest_scale = 0, /* 1 / 8 */
Expand All @@ -22,10 +28,10 @@ struct pll_level pll_levels[NUM_PLL_LEVEL] =
.max_temp = 120,
.sram_val = 0x1f156f
},{/* Normal: Max 1650MHz */
.refc = 2,
.loopc = 33,
.div = 1,
.vid = 1150,
.refc = BOOT_REFC,
.loopc = BOOT_LOOPC,
.div = BOOT_DIV,
.vid = BOOT_VID,
.highest_scale = (8 - 1), /* 8 / 8 */
.lowest_scale = (5 - 1), /* 5 / 8 */
.stable_scale = (8 - 1), /* 8/8, 1650MHz */
Expand Down Expand Up @@ -53,5 +59,6 @@ struct pll_level pll_levels[NUM_PLL_LEVEL] =
#define SHADOW_LEVEL_NUM 10
#define BASEFREQ_SHADOW_LEVEL 7
#define BASEFREQ 1650
rt_uint16_t shadow_level_freq[SHADOW_LEVEL_NUM] = {200, 410, 618, 825, 1030, 1237, 1443, BASEFREQ, 1925, 2200};
rt_uint16_t shadow_level_freq[SHADOW_LEVEL_NUM] = {200, 410, 618, 825, 1030, 1237, 1443, BASEFREQ, 1925, BOOSTFREQ};
rt_uint32_t core_scale_min = 3000;
#endif
2 changes: 1 addition & 1 deletion core/applications/miku.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
#include <rtthread.h>
#include <mips.h>
#include <ls3-smc.h>
#include "miku_dvfs.h"
#include "miku_config.h"
#include "miku_cmd.h"
#include "miku_features.h"
#include "miku_sensors.h"
#include "miku_threads.h"
#include "miku_fan.h"
#include "miku_dvfs.h"

#ifdef MIKU_DEBUG
#define DBG_TAG "Miku"
Expand Down
8 changes: 6 additions & 2 deletions core/applications/miku_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#ifndef _MIKU_CONFIG_H__
#define _MIKU_CONFIG_H__


#define MIKU_MODEL_MAGIG 0xbcda1901
#define MIKU_CURRENT_VERSION 0x1

#define MIKU_DEBUG 1
#define MIKU_HAVE_SENSORS 1
#define MIKU_SENSORS_HAVE_PACKAGE 1
Expand All @@ -14,7 +18,7 @@
#define MIKU_FAN_HAVE_PACKAGE 1
#define MIKU_HAVE_DVFS 1

#define MIKU_DVFS_POLICY_2200 1
//#define MIKU_DVFS_POLICY_2000 1
#include "dvfs_policy_2200.h"
//#include "dvfs_policy_2000.h"

#endif
9 changes: 1 addition & 8 deletions core/applications/miku_dvfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@
* Copyright (C) 2019, 2020 Jiaxun Yang <jiaxun.yang@flygoat.com>
*/

#define MIKU_INDVFS 1
#include "miku.h"

#if defined(MIKU_DVFS_POLICY_2200)
#include "dvfs_policy_2200.h"
#elif defined(MIKU_DVFS_POLICY_2000)
#include "dvfs_policy_2200.h"
#else
#error "No DVFS policy supplied"
#endif

rt_uint16_t target_shadow_freq[NUM_CORE];
rt_uint8_t current_core_scale[NUM_CORE];
rt_uint32_t core_scale_last_bump[NUM_CORE];
Expand Down
2 changes: 0 additions & 2 deletions core/applications/miku_features.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

#include "miku.h"

#define MIKU_CURRENT_VERSION 0x1

static rt_uint32_t implemented_feature[MIKU_FEATURE_SET_END];
static rt_uint32_t enabled_feature[MIKU_FEATURE_SET_END];

Expand Down
2 changes: 0 additions & 2 deletions core/applications/miku_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#ifndef _MIKU_FEATURES_H__
#define _MIKU_FEATURES_H__

#include <mips.h>

void miku_features_init(void);

#define CMD_GET_VERSION 0x1
Expand Down
2 changes: 2 additions & 0 deletions core/ls3-smc_rom.lds
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ SECTIONS
.text :
{
*(.start);
. = ALIGN(0x800);
KEEP(*(.config_table))
. = ALIGN(0x1000);
__ebase_entry = .;
KEEP(*(.exc_vectors))
Expand Down

0 comments on commit 72a1a37

Please sign in to comment.