mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 16:52:14 +02:00
stm32: add support for stm32f7 & stm32f746 discovery board
This patch adds support for stm32f7 family & stm32f746 board. Signed-off-by: Vikas Manocha <vikas.manocha@st.com>
This commit is contained in:
8
arch/arm/mach-stm32/stm32f7/Kconfig
Normal file
8
arch/arm/mach-stm32/stm32f7/Kconfig
Normal file
@@ -0,0 +1,8 @@
|
||||
if STM32F7
|
||||
|
||||
config TARGET_STM32F746_DISCO
|
||||
bool "STM32F746 Discovery board"
|
||||
|
||||
source "board/st/stm32f746-disco/Kconfig"
|
||||
|
||||
endif
|
8
arch/arm/mach-stm32/stm32f7/Makefile
Normal file
8
arch/arm/mach-stm32/stm32f7/Makefile
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# (C) Copyright 2016
|
||||
# Vikas Manocha, <vikas.manocha@gmail.com>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
|
||||
obj-y += timer.o clock.o
|
56
arch/arm/mach-stm32/stm32f7/clock.c
Normal file
56
arch/arm/mach-stm32/stm32f7/clock.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* (C) Copyright 2016
|
||||
* Vikas Manocha, <vikas.manocha@st.com>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/arch/rcc.h>
|
||||
#include <asm/arch/stm32.h>
|
||||
#include <asm/arch/stm32_periph.h>
|
||||
|
||||
void clock_setup(int peripheral)
|
||||
{
|
||||
switch (peripheral) {
|
||||
case USART1_CLOCK_CFG:
|
||||
setbits_le32(RCC_BASE + RCC_APB2ENR, RCC_ENR_USART1EN);
|
||||
break;
|
||||
case GPIO_A_CLOCK_CFG:
|
||||
setbits_le32(RCC_BASE + RCC_AHB1ENR, RCC_ENR_GPIO_A_EN);
|
||||
break;
|
||||
case GPIO_B_CLOCK_CFG:
|
||||
setbits_le32(RCC_BASE + RCC_AHB1ENR, RCC_ENR_GPIO_B_EN);
|
||||
break;
|
||||
case GPIO_C_CLOCK_CFG:
|
||||
setbits_le32(RCC_BASE + RCC_AHB1ENR, RCC_ENR_GPIO_C_EN);
|
||||
break;
|
||||
case GPIO_D_CLOCK_CFG:
|
||||
setbits_le32(RCC_BASE + RCC_AHB1ENR, RCC_ENR_GPIO_D_EN);
|
||||
break;
|
||||
case GPIO_E_CLOCK_CFG:
|
||||
setbits_le32(RCC_BASE + RCC_AHB1ENR, RCC_ENR_GPIO_E_EN);
|
||||
break;
|
||||
case GPIO_F_CLOCK_CFG:
|
||||
setbits_le32(RCC_BASE + RCC_AHB1ENR, RCC_ENR_GPIO_F_EN);
|
||||
break;
|
||||
case GPIO_G_CLOCK_CFG:
|
||||
setbits_le32(RCC_BASE + RCC_AHB1ENR, RCC_ENR_GPIO_G_EN);
|
||||
break;
|
||||
case GPIO_H_CLOCK_CFG:
|
||||
setbits_le32(RCC_BASE + RCC_AHB1ENR, RCC_ENR_GPIO_H_EN);
|
||||
break;
|
||||
case GPIO_I_CLOCK_CFG:
|
||||
setbits_le32(RCC_BASE + RCC_AHB1ENR, RCC_ENR_GPIO_I_EN);
|
||||
break;
|
||||
case GPIO_J_CLOCK_CFG:
|
||||
setbits_le32(RCC_BASE + RCC_AHB1ENR, RCC_ENR_GPIO_J_EN);
|
||||
break;
|
||||
case GPIO_K_CLOCK_CFG:
|
||||
setbits_le32(RCC_BASE + RCC_AHB1ENR, RCC_ENR_GPIO_K_EN);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
112
arch/arm/mach-stm32/stm32f7/timer.c
Normal file
112
arch/arm/mach-stm32/stm32f7/timer.c
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* (C) Copyright 2016
|
||||
* Vikas Manocha, ST Micoelectronics, vikas.manocha@st.com.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/arch/stm32.h>
|
||||
#include <asm/arch/gpt.h>
|
||||
#include <asm/arch/rcc.h>
|
||||
|
||||
#define READ_TIMER() (readl(&gpt1_regs_ptr->cnt) & GPT_FREE_RUNNING)
|
||||
#define GPT_RESOLUTION (CONFIG_SYS_HZ_CLOCK/CONFIG_STM32_HZ)
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
#define timestamp gd->arch.tbl
|
||||
#define lastdec gd->arch.lastinc
|
||||
|
||||
int timer_init(void)
|
||||
{
|
||||
/* Timer2 clock configuration */
|
||||
setbits_le32(RCC_BASE + RCC_APB1ENR, RCC_APB1ENR_TIM2EN);
|
||||
/* Stop the timer */
|
||||
writel(readl(&gpt1_regs_ptr->cr1) & ~GPT_CR1_CEN, &gpt1_regs_ptr->cr1);
|
||||
|
||||
writel((CONFIG_SYS_CLK_FREQ/CONFIG_SYS_HZ_CLOCK) - 1,
|
||||
&gpt1_regs_ptr->psc);
|
||||
|
||||
/* Configure timer for auto-reload */
|
||||
writel(readl(&gpt1_regs_ptr->cr1) | GPT_MODE_AUTO_RELOAD,
|
||||
&gpt1_regs_ptr->cr1);
|
||||
|
||||
/* load value for free running */
|
||||
writel(GPT_FREE_RUNNING, &gpt1_regs_ptr->arr);
|
||||
|
||||
/* start timer */
|
||||
writel(readl(&gpt1_regs_ptr->cr1) | GPT_CR1_CEN, &gpt1_regs_ptr->cr1);
|
||||
|
||||
writel(readl(&gpt1_regs_ptr->egr) | TIM_EGR_UG, &gpt1_regs_ptr->egr);
|
||||
|
||||
/* Reset the timer */
|
||||
lastdec = READ_TIMER();
|
||||
timestamp = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* timer without interrupts
|
||||
*/
|
||||
ulong get_timer(ulong base)
|
||||
{
|
||||
return (get_timer_masked() / GPT_RESOLUTION) - base;
|
||||
}
|
||||
|
||||
void __udelay(unsigned long usec)
|
||||
{
|
||||
ulong tmo;
|
||||
ulong start = get_timer_masked();
|
||||
ulong tenudelcnt = CONFIG_SYS_HZ_CLOCK / (1000 * 100);
|
||||
ulong rndoff;
|
||||
|
||||
rndoff = (usec % 10) ? 1 : 0;
|
||||
|
||||
/* tenudelcnt timer tick gives 10 microsecconds delay */
|
||||
tmo = ((usec / 10) + rndoff) * tenudelcnt;
|
||||
|
||||
while ((ulong) (get_timer_masked() - start) < tmo)
|
||||
;
|
||||
}
|
||||
|
||||
ulong get_timer_masked(void)
|
||||
{
|
||||
ulong now = READ_TIMER();
|
||||
|
||||
if (now >= lastdec) {
|
||||
/* normal mode */
|
||||
timestamp += now - lastdec;
|
||||
} else {
|
||||
/* we have an overflow ... */
|
||||
timestamp += now + GPT_FREE_RUNNING - lastdec;
|
||||
}
|
||||
lastdec = now;
|
||||
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
void udelay_masked(unsigned long usec)
|
||||
{
|
||||
return udelay(usec);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is derived from PowerPC code (read timebase as long long).
|
||||
* On ARM it just returns the timer value.
|
||||
*/
|
||||
unsigned long long get_ticks(void)
|
||||
{
|
||||
return get_timer(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is derived from PowerPC code (timebase clock frequency).
|
||||
* On ARM it returns the number of timer ticks per second.
|
||||
*/
|
||||
ulong get_tbclk(void)
|
||||
{
|
||||
return CONFIG_STM32_HZ;
|
||||
}
|
Reference in New Issue
Block a user