From: Piotr Dymacz Date: Tue, 1 Mar 2016 10:45:27 +0000 (+0100) Subject: Move reset_button_status function to common qca file X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=451a70f44e3738996fdf0c8a11a0a4ba2fb66836;p=oweals%2Fu-boot_mod.git Move reset_button_status function to common qca file --- diff --git a/u-boot/board/ar7240/ap121/ap121.c b/u-boot/board/ar7240/ap121/ap121.c index c1e5bb0..5c4ea5c 100644 --- a/u-boot/board/ar7240/ap121/ap121.c +++ b/u-boot/board/ar7240/ap121/ap121.c @@ -13,31 +13,6 @@ extern void ar933x_ddr_init(void); extern int ar7240_ddr_find_size(void); extern void ar933x_ddr_tap_init(void); -// get button status -#ifndef GPIO_RST_BUTTON_BIT - #error "GPIO_RST_BUTTON_BIT not defined!" -#endif -int reset_button_status(void) -{ - unsigned int gpio; - - gpio = ar7240_reg_rd(AR7240_GPIO_IN); - - if(gpio & (1 << GPIO_RST_BUTTON_BIT)){ -#if defined(GPIO_RST_BUTTON_IS_ACTIVE_LOW) - return(0); -#else - return(1); -#endif - } else { -#if defined(GPIO_RST_BUTTON_IS_ACTIVE_LOW) - return(1); -#else - return(0); -#endif - } -} - int ar7240_mem_config(void) { #ifndef CONFIG_SKIP_LOWLEVEL_INIT diff --git a/u-boot/board/ar7240/ap143/ap143.c b/u-boot/board/ar7240/ap143/ap143.c index 2ec2b4b..a4fba51 100644 --- a/u-boot/board/ar7240/ap143/ap143.c +++ b/u-boot/board/ar7240/ap143/ap143.c @@ -10,29 +10,6 @@ extern int ath_ddr_initial_config(uint32_t refresh); extern int ath_ddr_find_size(void); -int reset_button_status(void) -{ -#ifndef GPIO_RST_BUTTON_BIT - return 0; -#else - u32 gpio = qca_soc_reg_read(QCA_GPIO_IN_REG); - - if(gpio & (1 << GPIO_RST_BUTTON_BIT)){ - #if defined(GPIO_RST_BUTTON_IS_ACTIVE_LOW) - return 0 ; - #else - return 1 ; - #endif - } else { - #if defined(GPIO_RST_BUTTON_IS_ACTIVE_LOW) - return 1; - #else - return 0; - #endif - } -#endif -} - void ath_set_tuning_caps(void) { typedef struct { diff --git a/u-boot/board/ar7240/common/common.c b/u-boot/board/ar7240/common/common.c index 8dd0aae..e525e72 100644 --- a/u-boot/board/ar7240/common/common.c +++ b/u-boot/board/ar7240/common/common.c @@ -1,7 +1,8 @@ /* - * Copyright (C) 2015 Piotr Dymacz + * Common functions for QC/A WiSoCs support + * Copyright (C) 2016 Piotr Dymacz * - * SPDX-License-Identifier:GPL-2.0 + * SPDX-License-Identifier: GPL-2.0 */ #include @@ -138,6 +139,36 @@ void macaddr_init(u8 *mac_addr) memcpy(mac_addr, buffer, 6); } +/* + * Returns "reset button" status: + * 1 -> button is pressed + * 0 -> button is not pressed + */ +int reset_button_status(void) +{ +#ifdef GPIO_RST_BUTTON_BIT + u32 gpio; + + gpio = qca_soc_reg_read(QCA_GPIO_IN_REG); + + if (gpio & (1 << GPIO_RST_BUTTON_BIT)) { + #if defined(GPIO_RST_BUTTON_IS_ACTIVE_LOW) + return 0; + #else + return 1; + #endif + } else { + #if defined(GPIO_RST_BUTTON_IS_ACTIVE_LOW) + return 1; + #else + return 0; + #endif + } +#else + return 0; +#endif +} + /* * Returns main CPU clock in Hz */ diff --git a/u-boot/board/ar7240/db12x/db12x.c b/u-boot/board/ar7240/db12x/db12x.c index 0f05dc1..ab556e3 100644 --- a/u-boot/board/ar7240/db12x/db12x.c +++ b/u-boot/board/ar7240/db12x/db12x.c @@ -9,31 +9,6 @@ extern int wasp_ddr_initial_config(uint32_t refresh); extern int ar7240_ddr_find_size(void); -// get button status -#ifndef GPIO_RST_BUTTON_BIT - #error "GPIO_RST_BUTTON_BIT not defined!" -#endif -int reset_button_status(void) -{ - unsigned int gpio; - - gpio = ar7240_reg_rd(AR934X_GPIO_IN); - - if(gpio & (1 << GPIO_RST_BUTTON_BIT)){ -#if defined(GPIO_RST_BUTTON_IS_ACTIVE_LOW) - return 0; -#else - return 1; -#endif - } else { -#if defined(GPIO_RST_BUTTON_IS_ACTIVE_LOW) - return 1; -#else - return 0; -#endif - } -} - void ath_set_tuning_caps(void) { typedef struct {