stm32f7: use stm32f7 gpio driver supporting driver model

With this gpio driver supporting DM, there is no need to enable clocks
for different gpios (for pin muxing) in the board specific code.

Need to increase the allocatable area required before relocation from 0x400 to
0xC00 becuase of 10 new gpio devices(& new gpio class) added in device tree.

Signed-off-by: Vikas Manocha <vikas.manocha@st.com>
cc: Christophe KERELLO <christophe.kerello@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
master
Vikas Manocha 8 years ago committed by Tom Rini
parent d33a6a2f06
commit 280057bd7d
  1. 1
      arch/arm/include/asm/arch-stm32f7/gpio.h
  2. 70
      board/st/stm32f746-disco/stm32f746-disco.c
  3. 4
      configs/stm32f746-disco_defconfig
  4. 39
      drivers/clk/clk_stm32f7.c
  5. 9
      drivers/pinctrl/pinctrl_stm32.c
  6. 1
      include/configs/stm32f746-disco.h

@ -7,6 +7,7 @@
#ifndef _STM32_GPIO_H_ #ifndef _STM32_GPIO_H_
#define _STM32_GPIO_H_ #define _STM32_GPIO_H_
#include <asm/gpio.h>
enum stm32_gpio_port { enum stm32_gpio_port {
STM32_GPIO_PORT_A = 0, STM32_GPIO_PORT_A = 0,

@ -20,37 +20,12 @@
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
const struct stm32_gpio_ctl gpio_ctl_gpout = {
.mode = STM32_GPIO_MODE_OUT,
.otype = STM32_GPIO_OTYPE_PP,
.speed = STM32_GPIO_SPEED_50M,
.pupd = STM32_GPIO_PUPD_NO,
.af = STM32_GPIO_AF0
};
static int fmc_setup_gpio(void)
{
clock_setup(GPIO_B_CLOCK_CFG);
clock_setup(GPIO_C_CLOCK_CFG);
clock_setup(GPIO_D_CLOCK_CFG);
clock_setup(GPIO_E_CLOCK_CFG);
clock_setup(GPIO_F_CLOCK_CFG);
clock_setup(GPIO_G_CLOCK_CFG);
clock_setup(GPIO_H_CLOCK_CFG);
return 0;
}
int dram_init(void) int dram_init(void)
{ {
struct udevice *dev; struct udevice *dev;
struct ram_info ram; struct ram_info ram;
int rv; int rv;
rv = fmc_setup_gpio();
if (rv)
return rv;
rv = uclass_get_device(UCLASS_RAM, 0, &dev); rv = uclass_get_device(UCLASS_RAM, 0, &dev);
if (rv) { if (rv) {
debug("DRAM init failed: %d\n", rv); debug("DRAM init failed: %d\n", rv);
@ -73,37 +48,21 @@ int dram_init(void)
return rv; return rv;
} }
int uart_setup_gpio(void)
{
clock_setup(GPIO_A_CLOCK_CFG);
clock_setup(GPIO_B_CLOCK_CFG);
return 0;
}
#ifdef CONFIG_ETH_DESIGNWARE #ifdef CONFIG_ETH_DESIGNWARE
static int stmmac_setup(void) static int stmmac_setup(void)
{ {
clock_setup(SYSCFG_CLOCK_CFG); clock_setup(SYSCFG_CLOCK_CFG);
/* Set >RMII mode */ /* Set >RMII mode */
STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL; STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL;
clock_setup(GPIO_A_CLOCK_CFG);
clock_setup(GPIO_C_CLOCK_CFG);
clock_setup(GPIO_G_CLOCK_CFG);
clock_setup(STMMAC_CLOCK_CFG); clock_setup(STMMAC_CLOCK_CFG);
return 0; return 0;
} }
#endif
#ifdef CONFIG_STM32_QSPI int board_early_init_f(void)
static int qspi_setup(void)
{ {
clock_setup(GPIO_B_CLOCK_CFG); stmmac_setup();
clock_setup(GPIO_D_CLOCK_CFG);
clock_setup(GPIO_E_CLOCK_CFG);
return 0; return 0;
} }
#endif #endif
@ -113,29 +72,6 @@ u32 get_board_rev(void)
return 0; return 0;
} }
int board_early_init_f(void)
{
int res;
res = uart_setup_gpio();
if (res)
return res;
#ifdef CONFIG_ETH_DESIGNWARE
res = stmmac_setup();
if (res)
return res;
#endif
#ifdef CONFIG_STM32_QSPI
res = qspi_setup();
if (res)
return res;
#endif
return 0;
}
int board_init(void) int board_init(void)
{ {
gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;

@ -24,6 +24,7 @@ CONFIG_CMD_DNS=y
CONFIG_CMD_LINK_LOCAL=y CONFIG_CMD_LINK_LOCAL=y
CONFIG_CMD_TIMER=y CONFIG_CMD_TIMER=y
CONFIG_OF_CONTROL=y CONFIG_OF_CONTROL=y
CONFIG_DM_SEQ_ALIAS=y
CONFIG_NET_RANDOM_ETHADDR=y CONFIG_NET_RANDOM_ETHADDR=y
CONFIG_NETCONSOLE=y CONFIG_NETCONSOLE=y
CONFIG_CLK=y CONFIG_CLK=y
@ -49,3 +50,6 @@ CONFIG_PINCTRL=y
CONFIG_PINCTRL_STM32=y CONFIG_PINCTRL_STM32=y
CONFIG_RAM=y CONFIG_RAM=y
CONFIG_STM32_SDRAM=y CONFIG_STM32_SDRAM=y
CONFIG_DM_GPIO=y
CONFIG_STM32F7_GPIO=y
CONFIG_SYS_MALLOC_F_LEN=0xC00

@ -228,56 +228,17 @@ static int stm32_clk_enable(struct clk *clk)
void clock_setup(int peripheral) void clock_setup(int peripheral)
{ {
switch (peripheral) { switch (peripheral) {
case GPIO_A_CLOCK_CFG:
setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_GPIO_A_EN);
break;
case GPIO_B_CLOCK_CFG:
setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_GPIO_B_EN);
break;
case GPIO_C_CLOCK_CFG:
setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_GPIO_C_EN);
break;
case GPIO_D_CLOCK_CFG:
setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_GPIO_D_EN);
break;
case GPIO_E_CLOCK_CFG:
setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_GPIO_E_EN);
break;
case GPIO_F_CLOCK_CFG:
setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_GPIO_F_EN);
break;
case GPIO_G_CLOCK_CFG:
setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_GPIO_G_EN);
break;
case GPIO_H_CLOCK_CFG:
setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_GPIO_H_EN);
break;
case GPIO_I_CLOCK_CFG:
setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_GPIO_I_EN);
break;
case GPIO_J_CLOCK_CFG:
setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_GPIO_J_EN);
break;
case GPIO_K_CLOCK_CFG:
setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_GPIO_K_EN);
break;
case SYSCFG_CLOCK_CFG: case SYSCFG_CLOCK_CFG:
setbits_le32(&STM32_RCC->apb2enr, RCC_APB2ENR_SYSCFGEN); setbits_le32(&STM32_RCC->apb2enr, RCC_APB2ENR_SYSCFGEN);
break; break;
case TIMER2_CLOCK_CFG: case TIMER2_CLOCK_CFG:
setbits_le32(&STM32_RCC->apb1enr, RCC_APB1ENR_TIM2EN); setbits_le32(&STM32_RCC->apb1enr, RCC_APB1ENR_TIM2EN);
break; break;
case FMC_CLOCK_CFG:
setbits_le32(&STM32_RCC->ahb3enr, RCC_AHB3ENR_FMC_EN);
break;
case STMMAC_CLOCK_CFG: case STMMAC_CLOCK_CFG:
setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_ETHMAC_EN); setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_ETHMAC_EN);
setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_ETHMAC_RX_EN); setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_ETHMAC_RX_EN);
setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_ETHMAC_TX_EN); setbits_le32(&STM32_RCC->ahb1enr, RCC_AHB1ENR_ETHMAC_TX_EN);
break; break;
case QSPI_CLOCK_CFG:
setbits_le32(&STM32_RCC->ahb3enr, RCC_AHB3ENR_QSPI_EN);
break;
default: default:
break; break;
} }

@ -121,11 +121,16 @@ static int stm32_pinctrl_set_state_simple(struct udevice *dev,
if (len < 0) if (len < 0)
return -EINVAL; return -EINVAL;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
struct gpio_desc desc;
debug("%s: pinmux = %x\n", __func__, *(pin_mux + i)); debug("%s: pinmux = %x\n", __func__, *(pin_mux + i));
prep_gpio_dsc(&gpio_dsc, *(pin_mux + i)); prep_gpio_dsc(&gpio_dsc, *(pin_mux + i));
prep_gpio_ctl(&gpio_ctl, *(pin_mux + i), args.node); prep_gpio_ctl(&gpio_ctl, *(pin_mux + i), args.node);
rv = uclass_get_device_by_seq(UCLASS_GPIO,
rv = stm32_gpio_config(&gpio_dsc, &gpio_ctl); gpio_dsc.port, &desc.dev);
if (rv)
return rv;
desc.offset = gpio_dsc.pin;
rv = stm32_gpio_config(&desc, &gpio_ctl);
debug("%s: rv = %d\n\n", __func__, rv); debug("%s: rv = %d\n\n", __func__, rv);
if (rv) if (rv)
return rv; return rv;

@ -30,7 +30,6 @@
#define CONFIG_ENV_IS_NOWHERE #define CONFIG_ENV_IS_NOWHERE
#define CONFIG_ENV_SIZE (8 << 10) #define CONFIG_ENV_SIZE (8 << 10)
#define CONFIG_STM32_GPIO
#define CONFIG_STM32_FLASH #define CONFIG_STM32_FLASH
#define CONFIG_STM32X7_SERIAL #define CONFIG_STM32X7_SERIAL

Loading…
Cancel
Save