summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plat/sun50iw1p1/drivers/gpio/gpio.c228
-rw-r--r--plat/sun50iw1p1/drivers/uart/uart.c1
-rw-r--r--plat/sun50iw1p1/include/gpio.h69
-rw-r--r--plat/sun50iw1p1/platform.mk4
4 files changed, 1 insertions, 301 deletions
diff --git a/plat/sun50iw1p1/drivers/gpio/gpio.c b/plat/sun50iw1p1/drivers/gpio/gpio.c
deleted file mode 100644
index f741041..0000000
--- a/plat/sun50iw1p1/drivers/gpio/gpio.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
-**********************************************************************************************************************
-*
-* the Embedded Secure Bootloader System
-*
-*
-* Copyright(C), 2006-2014, Allwinnertech Co., Ltd.
-* All Rights Reserved
-*
-* File :
-*
-* By :
-*
-* Version : V2.00
-*
-* Date :
-*
-* Descript:
-**********************************************************************************************************************
-*/
-
-
-#include "../../sunxi_def.h"
-#include <gpio.h>
-
-#define GPIO_REG_READ(reg) mmio_read_32((reg))
-#define GPIO_REG_WRITE(reg, value) mmio_write_32((reg),(value))
-
-/*
-************************************************************************************************************
-*
-* normal_gpio_cfg
-*
-* 函数名称:
-*
-* 参数列表:
-*
-*
-*
-* 返回值 :
-*
-* 说明 :
-*
-*
-************************************************************************************************************
-*/
-int32_t boot_set_gpio(void *user_gpio_list, uint32_t group_count_max, int32_t set_gpio)
-{
- normal_gpio_set_t *tmp_user_gpio_data, *gpio_list;
- uint32_t first_port; //保存真正有效的GPIO的个数
- uint32_t tmp_group_func_data;
- uint32_t tmp_group_pull_data;
- uint32_t tmp_group_dlevel_data;
- uint32_t tmp_group_data_data;
- uint32_t data_change = 0;
- uint32_t tmp_group_func_addr, tmp_group_pull_addr;
- uint32_t tmp_group_dlevel_addr, tmp_group_data_addr;
- uint32_t port, port_num, port_num_func, port_num_pull;
- uint32_t pre_port, pre_port_num_func;
- uint32_t pre_port_num_pull;
- int32_t i, tmp_val;
-
-
- gpio_list = (normal_gpio_set_t *)user_gpio_list;
-
- for(first_port = 0; first_port < group_count_max; first_port++)
- {
- tmp_user_gpio_data = gpio_list + first_port;
- port = tmp_user_gpio_data->port; //读出端口数值
- port_num = tmp_user_gpio_data->port_num; //读出端口中的某一个GPIO
- if(!port)
- {
- continue;
- }
- port_num_func = (port_num >> 3);
- port_num_pull = (port_num >> 4);
-
- tmp_group_func_addr = PIO_REG_CFG(port, port_num_func); //更新功能寄存器地址
- tmp_group_pull_addr = PIO_REG_PULL(port, port_num_pull); //更新pull寄存器
- tmp_group_dlevel_addr = PIO_REG_DLEVEL(port, port_num_pull);//更新level寄存器
- tmp_group_data_addr = PIO_REG_DATA(port); //更新data寄存器
-
- tmp_group_func_data = GPIO_REG_READ(tmp_group_func_addr);
- tmp_group_pull_data = GPIO_REG_READ(tmp_group_pull_addr);
- tmp_group_dlevel_data = GPIO_REG_READ(tmp_group_dlevel_addr);
- tmp_group_data_data = GPIO_REG_READ(tmp_group_data_addr);
-
- pre_port = port;
- pre_port_num_func = port_num_func;
- pre_port_num_pull = port_num_pull;
- //更新功能寄存器
- tmp_val = (port_num - (port_num_func << 3)) << 2;
- tmp_group_func_data &= ~(0x07 << tmp_val);
- if(set_gpio)
- {
- tmp_group_func_data |= (tmp_user_gpio_data->mul_sel & 0x07) << tmp_val;
- }
- //根据pull的值决定是否更新pull寄存器
- tmp_val = (port_num - (port_num_pull << 4)) << 1;
- if(tmp_user_gpio_data->pull >= 0)
- {
- tmp_group_pull_data &= ~( 0x03 << tmp_val);
- tmp_group_pull_data |= (tmp_user_gpio_data->pull & 0x03) << tmp_val;
- }
- //根据driver level的值决定是否更新driver level寄存器
- if(tmp_user_gpio_data->drv_level >= 0)
- {
- tmp_group_dlevel_data &= ~( 0x03 << tmp_val);
- tmp_group_dlevel_data |= (tmp_user_gpio_data->drv_level & 0x03) << tmp_val;
- }
- //根据用户输入,以及功能分配决定是否更新data寄存器
- if(tmp_user_gpio_data->mul_sel == 1)
- {
- if(tmp_user_gpio_data->data >= 0)
- {
- tmp_val = tmp_user_gpio_data->data & 1;
- tmp_group_data_data &= ~(1 << port_num);
- tmp_group_data_data |= tmp_val << port_num;
- data_change = 1;
- }
- }
-
- break;
- }
- //检查是否有数据存在
- if(first_port >= group_count_max)
- {
- return -1;
- }
- //保存用户数据
- for(i = first_port + 1; i < group_count_max; i++)
- {
- tmp_user_gpio_data = gpio_list + i; //gpio_set依次指向用户的每个GPIO数组成员
- port = tmp_user_gpio_data->port; //读出端口数值
- port_num = tmp_user_gpio_data->port_num; //读出端口中的某一个GPIO
- if(!port)
- {
- break;
- }
- port_num_func = (port_num >> 3);
- port_num_pull = (port_num >> 4);
-
- if((port_num_pull != pre_port_num_pull) || (port != pre_port)) //如果发现当前引脚的端口不一致,或者所在的pull寄存器不一致
- {
- GPIO_REG_WRITE(tmp_group_func_addr, tmp_group_func_data); //回写功能寄存器
- GPIO_REG_WRITE(tmp_group_pull_addr, tmp_group_pull_data); //回写pull寄存器
- GPIO_REG_WRITE(tmp_group_dlevel_addr, tmp_group_dlevel_data); //回写driver level寄存器
- if(data_change)
- {
- data_change = 0;
- GPIO_REG_WRITE(tmp_group_data_addr, tmp_group_data_data); //回写data寄存器
- }
-
- tmp_group_func_addr = PIO_REG_CFG(port, port_num_func); //更新功能寄存器地址
- tmp_group_pull_addr = PIO_REG_PULL(port, port_num_pull); //更新pull寄存器
- tmp_group_dlevel_addr = PIO_REG_DLEVEL(port, port_num_pull);//更新level寄存器
- tmp_group_data_addr = PIO_REG_DATA(port); //更新data寄存器
-
- tmp_group_func_data = GPIO_REG_READ(tmp_group_func_addr);
- tmp_group_pull_data = GPIO_REG_READ(tmp_group_pull_addr);
- tmp_group_dlevel_data = GPIO_REG_READ(tmp_group_dlevel_addr);
- tmp_group_data_data = GPIO_REG_READ(tmp_group_data_addr);
- }
- else if(pre_port_num_func != port_num_func) //如果发现当前引脚的功能寄存器不一致
- {
- GPIO_REG_WRITE(tmp_group_func_addr, tmp_group_func_data); //则只回写功能寄存器
- tmp_group_func_addr = PIO_REG_CFG(port, port_num_func); //更新功能寄存器地址
-
- tmp_group_func_data = GPIO_REG_READ(tmp_group_func_addr);
- }
- //保存当前硬件寄存器数据
- pre_port_num_pull = port_num_pull; //设置当前GPIO成为前一个GPIO
- pre_port_num_func = port_num_func;
- pre_port = port;
-
- //更新功能寄存器
- tmp_val = (port_num - (port_num_func << 3)) << 2;
- if(tmp_user_gpio_data->mul_sel >= 0)
- {
- tmp_group_func_data &= ~( 0x07 << tmp_val);
- if(set_gpio)
- {
- tmp_group_func_data |= (tmp_user_gpio_data->mul_sel & 0x07) << tmp_val;
- }
- }
- //根据pull的值决定是否更新pull寄存器
- tmp_val = (port_num - (port_num_pull << 4)) << 1;
- if(tmp_user_gpio_data->pull >= 0)
- {
- tmp_group_pull_data &= ~( 0x03 << tmp_val);
- tmp_group_pull_data |= (tmp_user_gpio_data->pull & 0x03) << tmp_val;
- }
- //根据driver level的值决定是否更新driver level寄存器
- if(tmp_user_gpio_data->drv_level >= 0)
- {
- tmp_group_dlevel_data &= ~( 0x03 << tmp_val);
- tmp_group_dlevel_data |= (tmp_user_gpio_data->drv_level & 0x03) << tmp_val;
- }
- //根据用户输入,以及功能分配决定是否更新data寄存器
- if(tmp_user_gpio_data->mul_sel == 1)
- {
- if(tmp_user_gpio_data->data >= 0)
- {
- tmp_val = tmp_user_gpio_data->data & 1;
- tmp_group_data_data &= ~(1 << port_num);
- tmp_group_data_data |= tmp_val << port_num;
- data_change = 1;
- }
- }
- }
- //for循环结束,如果存在还没有回写的寄存器,这里写回到硬件当中
- if(tmp_group_func_addr) //只要更新过寄存器地址,就可以对硬件赋值
- { //那么把所有的值全部回写到硬件寄存器
- GPIO_REG_WRITE(tmp_group_func_addr, tmp_group_func_data); //回写功能寄存器
- GPIO_REG_WRITE(tmp_group_pull_addr, tmp_group_pull_data); //回写pull寄存器
- GPIO_REG_WRITE(tmp_group_dlevel_addr, tmp_group_dlevel_data); //回写driver level寄存器
- if(data_change)
- {
- GPIO_REG_WRITE(tmp_group_data_addr, tmp_group_data_data); //回写data寄存器
- }
- }
-
- return 0;
-}
-
-
-
-
diff --git a/plat/sun50iw1p1/drivers/uart/uart.c b/plat/sun50iw1p1/drivers/uart/uart.c
index bd1e7ff..466e329 100644
--- a/plat/sun50iw1p1/drivers/uart/uart.c
+++ b/plat/sun50iw1p1/drivers/uart/uart.c
@@ -31,7 +31,6 @@
#include <stdint.h>
#include <mmio.h>
#include <uart.h>
-#include <gpio.h>
#include <ccmu.h>
#if DEBUG
diff --git a/plat/sun50iw1p1/include/gpio.h b/plat/sun50iw1p1/include/gpio.h
deleted file mode 100644
index 7cab9c9..0000000
--- a/plat/sun50iw1p1/include/gpio.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * (C) Copyright 2007-2013
- * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
- * Jerry Wang <wangflord@allwinnertech.com>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * 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 _SUNXI_GPIO_H
-#define _SUNXI_GPIO_H
-
-#include <mmio.h>
-
-
-#define PIOC_REG_o_CFG0 0x00
-#define PIOC_REG_o_CFG1 0x04
-#define PIOC_REG_o_CFG2 0x08
-#define PIOC_REG_o_CFG3 0x0C
-#define PIOC_REG_o_DATA 0x10
-#define PIOC_REG_o_DRV0 0x14
-#define PIOC_REG_o_DRV1 0x18
-#define PIOC_REG_o_PUL0 0x1C
-#define PIOC_REG_o_PUL1 0x20
-
-
-
-/**#############################################################################################################
- *
- * GPIO(PIN) Operations
- *
--##############################################################################################################*/
-#define PIO_REG_CFG(n, i) (( SUNXI_PIO_BASE + ((n)-1)*0x24 + ((i)<<2) + 0x00))
-#define PIO_REG_DLEVEL(n, i) (( SUNXI_PIO_BASE + ((n)-1)*0x24 + ((i)<<2) + 0x14))
-#define PIO_REG_PULL(n, i) (( SUNXI_PIO_BASE + ((n)-1)*0x24 + ((i)<<2) + 0x1C))
-#define PIO_REG_DATA(n) (( SUNXI_PIO_BASE + ((n)-1)*0x24 + 0x10))
-
-
-//struct for gpio
-typedef struct
-{
- unsigned char port; //端口号
- unsigned char port_num; //端口内编号
- char mul_sel; //功能编号
- char pull; //电阻状态
- char drv_level; //驱动驱动能力
- char data; //输出电平
- unsigned char reserved[2]; //保留位,保证对齐
-}
-normal_gpio_set_t;
-
-int32_t boot_set_gpio(void *user_gpio_list, uint32_t group_count_max, int32_t set_gpio);
-
-#endif /* _SUNXI_GPIO_H */
diff --git a/plat/sun50iw1p1/platform.mk b/plat/sun50iw1p1/platform.mk
index 34fa2b1..b788f81 100644
--- a/plat/sun50iw1p1/platform.mk
+++ b/plat/sun50iw1p1/platform.mk
@@ -33,9 +33,7 @@ PLAT_INCLUDES := -Iplat/sun50iw1p1/include/
PLAT_BL_COMMON_SOURCES := lib/aarch64/xlat_tables.c \
plat/common/aarch64/plat_common.c \
- plat/sun50iw1p1/drivers/uart/uart.c \
- plat/sun50iw1p1/drivers/gpio/gpio.c
-
+ plat/sun50iw1p1/drivers/uart/uart.c
BL31_SOURCES += drivers/arm/gic/arm_gic.c \