platform: kendryte/k210: Simplify sysctl code

Simplify sysctl.c code to only the used CPU freqency function.
This reduces the size of the final firmware by 4KB.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
This commit is contained in:
Damien Le Moal
2019-01-03 14:32:25 +09:00
parent 4079df63a7
commit c37a8508d1
3 changed files with 21 additions and 1910 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -782,164 +782,9 @@ typedef struct _sysctl_general_pll {
} __attribute__((packed, aligned(4))) sysctl_general_pll_t;
/**
* System controller object instanse
* Get frequency of CPU
* @return The frequency of the CPU
*/
extern volatile sysctl_t *const sysctl;
/**
* Enable clock for peripheral
* @param[in] clock The clock to be enable
* @return result
* - 0 Success
* - Other Fail
*/
int sysctl_clock_enable(sysctl_clock_t clock);
/**
* Enable clock for peripheral
* @param[in] clock The clock to be disable
* @return result
* - 0 Success
* - Other Fail
*/
int sysctl_clock_disable(sysctl_clock_t clock);
/**
* Sysctl clock set threshold
* @param[in] which Which threshold to set
* @param[in] threshold The threshold value
* @return result
* - 0 Success
* - Other Fail
*/
int sysctl_clock_set_threshold(sysctl_threshold_t which, int threshold);
/**
* Sysctl clock get threshold
* @param[in] which Which threshold to get
* @return The threshold value
* - Other Value of threshold
* - -1 Fail
*/
int sysctl_clock_get_threshold(sysctl_threshold_t which);
/**
* Sysctl clock set clock select
* @param[in] which Which clock select to set
* @param[in] select The clock select value
* @return result
* - 0 Success
* - Other Fail
*/
int sysctl_clock_set_clock_select(sysctl_clock_select_t which, int select);
/**
* Sysctl clock get clock select
* @param[in] which Which clock select to get
* @return The clock select value
* - Other Value of clock select
* - -1 Fail
*/
int sysctl_clock_get_clock_select(sysctl_clock_select_t which);
/**
* Get PLL frequency
* @param[in] pll The PLL id
* @return The frequency of PLL
*/
u32 sysctl_pll_get_freq(sysctl_pll_t pll);
/**
* Get base clock frequency by clock id
* @param[in] clock The clock id
* @return The clock frequency
*/
u32 sysctl_clock_get_freq(sysctl_clock_t clock);
/**
* Reset device by reset controller
* @param[in] reset The reset signal
*/
void sysctl_reset(sysctl_reset_t reset);
/**
* Enable the PLL and power on with reset
* @param[in] pll The pll id
* @return Result
* - 0 Success
* - Other Fail
*/
int sysctl_pll_enable(sysctl_pll_t pll);
/**
* Disable the PLL and power off
* @param[in] pll The pll id
* @return Result
* - 0 Success
* - Other Fail
*/
int sysctl_pll_disable(sysctl_pll_t pll);
/**
* Select DMA channel handshake peripheral signal
* @param[in] channel The DMA channel
* @param[in] select The peripheral select
* @return Result
* - 0 Success
* - Other Fail
*/
int sysctl_dma_select(sysctl_dma_channel_t channel, sysctl_dma_select_t select);
/**
* Set SPI0_D0-D7 DVP_D0-D7 as spi and dvp data pin
* @param[in] en Enable or not
* @return Result
* - 0 Success
* - Other Fail
*/
u32 sysctl_set_spi0_dvp_data(u8 en);
/**
* Set io power mode
* @param[in] power_bank IO power bank
* @param[in] io_power_mode Set power mode 3.3v or 1.8
* @return Result
* - 0 Success
* - Other Fail
*/
void sysctl_set_power_mode(sysctl_power_bank_t power_bank, sysctl_io_power_mode_t io_power_mode);
/**
* Set frequency of CPU
* @param[in] freq The desired frequency in Hz
* @return The actual frequency of CPU after set
*/
u32 sysctl_cpu_set_freq(u32 freq);
/**
* Init PLL freqency
* @param[in] pll The PLL id
* @param[in] pll_freq The desired frequency in Hz
*/
u32 sysctl_pll_set_freq(sysctl_pll_t pll, u32 pll_freq);
/**
* Enable interrupt
*/
void sysctl_enable_irq(void);
/**
* Disable interrupt
*/
void sysctl_disable_irq(void);
/**
* Get the time start up to now
* @return The time of microsecond
*/
u64 sysctl_get_time_us(void);
void sysctl_usleep(u64 usec);
u32 sysctl_get_cpu_freq(void);
#endif /* _K210_SYSCTL_H_ */

View File

@@ -21,7 +21,7 @@ static volatile struct uarths *const uarths =
void uarths_init(u32 baud_rate, enum uarths_stopbit stopbit)
{
u32 freq = sysctl_clock_get_freq(SYSCTL_CLOCK_CPU);
u32 freq = sysctl_get_cpu_freq();
u16 div = freq / baud_rate - 1;
/* Set UART registers */