Commit 7f65e583 authored by Yuri Tikhonov's avatar Yuri Tikhonov
Browse files

RT72064. stm32f2_gpio: minor clean-ups


Signed-off-by: default avatarYuri Tikhonov <yur@emcraft.com>
parent 69926ab1
......@@ -32,8 +32,8 @@ COBJS-$(CONFIG_PCA953X) += pca953x.o
COBJS-$(CONFIG_STM32F2_GPIO) += stm32f2_gpio.o
COBJS := $(COBJS-y)
SRCS := $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(COBJS))
SRCS := $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(COBJS))
all: $(LIB)
......
......@@ -20,13 +20,15 @@
*/
/*
* STM32 F2 GPIO driver. Used just for setting Alternative functions
* STM32 F2 GPIO driver. Used for instance for setting Alternative functions
* for GPIOs utilized for USART or Ethernet communications
*/
#include <common.h>
#include <asm/errno.h>
#include <asm/arch/stm32f2.h>
#include <asm/arch/stm32f2_gpio.h>
/*
* GPIO registers bases
......@@ -89,6 +91,22 @@
*/
#define STM32F2_GPIO_AF_MAC 0x0B
/*
* GPIO register map
*/
struct stm32f2_gpio_regs {
u32 moder; /* GPIO port mode */
u32 otyper; /* GPIO port output type */
u32 ospeedr; /* GPIO port output speed */
u32 pupdr; /* GPIO port pull-up/pull-down */
u32 idr; /* GPIO port input data */
u32 odr; /* GPIO port output data */
u16 bsrrl; /* GPIO port bit set/reset low */
u16 bsrrh; /* GPIO port bit set/reset high */
u32 lckr; /* GPIO port configuration lock */
u32 afr[2]; /* GPIO alternate function */
};
/*
* Register map bases
*/
......@@ -123,8 +141,8 @@ int stm32f2_gpio_config(unsigned int port, unsigned int pin,
* Check params
*/
if (port > 8 || pin > 15) {
printf("%s: bad params %d.%d.\n", __func__, port, pin);
rv = -1;
printf("%s: incorrect params %d.%d.\n", __func__, port, pin);
rv = -EINVAL;
goto out;
}
......@@ -148,8 +166,8 @@ int stm32f2_gpio_config(unsigned int port, unsigned int pin,
pupd = STM32F2_GPIO_PUPD_NO;
break;
default:
printf("%s: bad role %d.\n", __func__, role);
rv = -1;
printf("%s: incorrect role %d.\n", __func__, role);
rv = -EINVAL;
goto out;
}
......
......@@ -32,6 +32,7 @@
#include <common.h>
#include <asm/arch/stm32f2.h>
#include <asm/arch/stm32f2_gpio.h>
/*
* Set up configuration
......
......@@ -115,49 +115,10 @@ enum clock {
*/
#define STM32F2_RCC_BASE (STM32F2_AHB1PERITH_BASE + 0x3800)
/******************************************************************************
* General Purpose I/O
******************************************************************************/
/*
* GPIO register map
*/
struct stm32f2_gpio_regs {
u32 moder; /* GPIO port mode */
u32 otyper; /* GPIO port output type */
u32 ospeedr; /* GPIO port output speed */
u32 pupdr; /* GPIO port pull-up/pull-down */
u32 idr; /* GPIO port input data */
u32 odr; /* GPIO port output data */
u16 bsrrl; /* GPIO port bit set/reset low */
u16 bsrrh; /* GPIO port bit set/reset high */
u32 lckr; /* GPIO port configuration lock */
u32 afr[2]; /* GPIO alternate function */
};
/*
* GPIO roles (alternative functions)
*/
enum stm32f2_gpio_role {
STM32F2_GPIO_ROLE_USART1, /* GPIO is used by USART1 */
STM32F2_GPIO_ROLE_USART2, /* GPIO is used by USART2 */
STM32F2_GPIO_ROLE_USART3, /* GPIO is used by USART3 */
STM32F2_GPIO_ROLE_USART4, /* GPIO is used by USART4 */
STM32F2_GPIO_ROLE_USART5, /* GPIO is used by USART5 */
STM32F2_GPIO_ROLE_USART6, /* GPIO is used by USART6 */
STM32F2_GPIO_ROLE_ETHERNET /* GPIO is used by MAC */
};
/******************************************************************************
* FIXME: get rid of this
******************************************************************************/
/*
* Configure the specified GPIO for the specified role
*/
int stm32f2_gpio_config(unsigned int port, unsigned int pin,
enum stm32f2_gpio_role role);
/*
* Return a clock value for the specified clock.
* Note that we need this function in RAM because it will be used
......
/*
* (C) Copyright 2011
*
* Yuri Tikhonov, Emcraft Systems, yur@emcraft.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#ifndef _STM32F2_GPIO_H_
#define _STM32F2_GPIO_H_
/*
* GPIO roles (alternative functions)
*/
enum stm32f2_gpio_role {
STM32F2_GPIO_ROLE_USART1, /* GPIO is used by USART1 */
STM32F2_GPIO_ROLE_USART2, /* GPIO is used by USART2 */
STM32F2_GPIO_ROLE_USART3, /* GPIO is used by USART3 */
STM32F2_GPIO_ROLE_USART4, /* GPIO is used by USART4 */
STM32F2_GPIO_ROLE_USART5, /* GPIO is used by USART5 */
STM32F2_GPIO_ROLE_USART6, /* GPIO is used by USART6 */
STM32F2_GPIO_ROLE_ETHERNET /* GPIO is used by MAC */
};
/*
* Configure the specified GPIO for the specified role
*/
int stm32f2_gpio_config(unsigned int port, unsigned int pin,
enum stm32f2_gpio_role role);
#endif /* _STM32F2_GPIO_H_ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment