common: Drop linux/delay.h from common header
[oweals/u-boot.git] / board / buffalo / lsxl / lsxl.c
index b3f31d6b697921e5f4ba5a923d9adcf7566ebc93..64daa456b3c7d862124cf8dc341cc965b5e73a05 100644 (file)
@@ -1,39 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (c) 2012 Michael Walle
  * Michael Walle <michael@walle.cc>
  *
  * Based on sheevaplug/sheevaplug.c by
  *   Marvell Semiconductor <www.marvell.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., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
  */
 
 #include <common.h>
+#include <bootstage.h>
+#include <command.h>
+#include <env.h>
+#include <env_internal.h>
+#include <flash.h>
+#include <init.h>
 #include <net.h>
 #include <malloc.h>
 #include <netdev.h>
 #include <miiphy.h>
-#include <asm/arch/kirkwood.h>
+#include <spi.h>
+#include <spi_flash.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/mpp.h>
 #include <asm/arch/gpio.h>
-#include <spi_flash.h>
+#include <linux/delay.h>
 
 #include "lsxl.h"
 
@@ -49,9 +40,8 @@
  * you can do this only with a working network connection. Therefore, a random
  * ethernet address is generated if none is set and a DHCP request is sent.
  * After a successful DHCP response is received, the network settings are
- * configured and the ncip parameter is set to the serverip. Eg. for a working
- * resuce mode, you should set 'next-server' to the host where the netconsole
- * client is started.
+ * configured and the ncip is unset. Therefore, all netconsole packets are
+ * broadcasted.
  * Additionally, the bootsource is set to 'rescue'.
  */
 
@@ -68,15 +58,15 @@ int board_early_init_f(void)
         * There are maximum 64 gpios controlled through 2 sets of registers
         * the below configuration configures mainly initial LED status
         */
-       kw_config_gpio(LSXL_OE_VAL_LOW,
-                       LSXL_OE_VAL_HIGH,
-                       LSXL_OE_LOW, LSXL_OE_HIGH);
+       mvebu_config_gpio(LSXL_OE_VAL_LOW,
+                         LSXL_OE_VAL_HIGH,
+                         LSXL_OE_LOW, LSXL_OE_HIGH);
 
        /*
         * Multi-Purpose Pins Functionality configuration
         * These strappings are taken from the original vendor uboot port.
         */
-       u32 kwmpp_config[] = {
+       static const u32 kwmpp_config[] = {
                MPP0_SPI_SCn,
                MPP1_SPI_MOSI,
                MPP2_SPI_SCK,
@@ -184,7 +174,7 @@ static void set_led(int state)
 int board_init(void)
 {
        /* address of boot parameters */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        set_led(LED_POWER_BLINKING);
 
@@ -195,9 +185,11 @@ int board_init(void)
 static void check_power_switch(void)
 {
        if (kw_gpio_get_value(GPIO_POWER_SWITCH)) {
-               /* turn off HDD and USB power */
+               /* turn off fan, HDD and USB power */
                kw_gpio_set_value(GPIO_HDD_POWER, 0);
                kw_gpio_set_value(GPIO_USB_VBUS, 0);
+               kw_gpio_set_value(GPIO_FAN_HIGH, 1);
+               kw_gpio_set_value(GPIO_FAN_LOW, 1);
                set_led(LED_OFF);
 
                /* loop until released */
@@ -207,6 +199,8 @@ static void check_power_switch(void)
                /* turn power on again */
                kw_gpio_set_value(GPIO_HDD_POWER, 1);
                kw_gpio_set_value(GPIO_USB_VBUS, 1);
+               kw_gpio_set_value(GPIO_FAN_HIGH, 0);
+               kw_gpio_set_value(GPIO_FAN_LOW, 0);
                set_led(LED_POWER_BLINKING);
        }
 }
@@ -215,7 +209,7 @@ void check_enetaddr(void)
 {
        uchar enetaddr[6];
 
-       if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+       if (!eth_env_get_enetaddr("ethaddr", enetaddr)) {
                /* signal unset/invalid ethaddr to user */
                set_led(LED_INFO_BLINKING);
        }
@@ -239,20 +233,8 @@ static void erase_environment(void)
 
 static void rescue_mode(void)
 {
-       uchar enetaddr[6];
-
        printf("Entering rescue mode..\n");
-#ifdef CONFIG_RANDOM_MACADDR
-       if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
-               eth_random_enetaddr(enetaddr);
-               if (eth_setenv_enetaddr("ethaddr", enetaddr)) {
-                       printf("Failed to set ethernet address\n");
-                               set_led(LED_ALARM_BLINKING);
-                       return;
-               }
-       }
-#endif
-       setenv("bootsource", "rescue");
+       env_set("bootsource", "rescue");
 }
 
 static void check_push_button(void)