/* Switch the clock source to 1GHz PLL from 33.333MHz oscillator on the HiFive Unleashed board.  */
static int fu540_clock_init(void)
/* Switch the clock source to 1GHz PLL from 33.333MHz oscillator on the HiFive Unleashed board.  */
static int fu540_clock_init(void)
{
	PRCI_REG(PRCI_COREPLLCFG0) =
		PLL_R(0) |
		PLL_F(59) |
		PLL_Q(2) |
		PLL_RANGE(PLL_RANGE_33MHZ) |
		PLL_BYPASS(PLL_BYPASS_DISABLE) |
		PLL_FSE(PLL_FSE_INTERNAL);
	while ((PRCI_REG(PRCI_COREPLLCFG0) & PLL_LOCK(1)) == 0)
		;
	PRCI_REG(PRCI_CORECLKSEL) = CORECLKSEL_CORECLKSEL(CORECLKSEL_CORE_PLL);
	return 0;
}