summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards/vscom-baltos/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/boards/vscom-baltos/board.c')
-rw-r--r--arch/arm/boards/vscom-baltos/board.c105
1 files changed, 74 insertions, 31 deletions
diff --git a/arch/arm/boards/vscom-baltos/board.c b/arch/arm/boards/vscom-baltos/board.c
index 3f9b7d76bb..85cf241574 100644
--- a/arch/arm/boards/vscom-baltos/board.c
+++ b/arch/arm/boards/vscom-baltos/board.c
@@ -1,20 +1,6 @@
-/*
- * (C) Copyright 2008
- * Texas Instruments, <www.ti.com>
- * Raghavendra KH <r-khandenahally@ti.com>
- *
- * Copyright (C) 2012 Jan Luebbe <j.luebbe@pengutronix.de>
- *
- * 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.
- */
+// SPDX-License-Identifier: GPL-2.0-or-later
+// SPDX-FileCopyrightText: 2008 Raghavendra KH <r-khandenahally@ti.com>, Texas Instruments (http://www.ti.com/)
+// SPDX-FileCopyrightText: 2012 Jan Luebbe <j.luebbe@pengutronix.de>
/**
* @file
@@ -31,14 +17,14 @@
#include <net.h>
#include <bootsource.h>
#include <asm/armlinux.h>
-#include <generated/mach-types.h>
-#include <mach/am33xx-generic.h>
-#include <mach/am33xx-silicon.h>
-#include <mach/sys_info.h>
-#include <mach/syslib.h>
-#include <mach/gpmc.h>
+#include <asm/mach-types.h>
+#include <mach/omap/am33xx-generic.h>
+#include <mach/omap/am33xx-silicon.h>
+#include <mach/omap/sys_info.h>
+#include <mach/omap/syslib.h>
+#include <mach/omap/gpmc.h>
#include <linux/err.h>
-#include <mach/bbu.h>
+#include <mach/omap/bbu.h>
#include <libfile.h>
#include <gpio.h>
@@ -59,19 +45,66 @@ struct bsp_vs_hwparam {
uint8_t MAC3[6];
} __attribute__ ((packed));
+static uint8_t get_dip_switch(uint16_t id, uint32_t rev)
+{
+ uint16_t maj, min;
+ uint8_t dip = 0;
+ int inputs[4];
+
+ maj = rev >> 16;
+ min = rev & 0xffff;
+
+ if ((id == 220 || id == 222) && (maj == 1 && min == 2))
+ id = 214;
+
+ switch(id) {
+ case 214:
+ case 215:
+ inputs[0] = gpio_find_by_name("SW2_0_alt");
+ inputs[1] = gpio_find_by_name("SW2_1_alt");
+ inputs[2] = gpio_find_by_name("SW2_2_alt");
+ inputs[3] = gpio_find_by_name("SW2_3_alt");
+ dip = !gpio_get_value(inputs[0]);
+ dip += !gpio_get_value(inputs[1]) << 1;
+ dip += !gpio_get_value(inputs[2]) << 2;
+ dip += !gpio_get_value(inputs[3]) << 3;
+ break;
+ case 212:
+ case 221:
+ case 223:
+ case 224:
+ case 225:
+ case 226:
+ case 227:
+ case 230:
+ inputs[0] = gpio_find_by_name("SW2_0");
+ inputs[1] = gpio_find_by_name("SW2_1");
+ inputs[2] = gpio_find_by_name("SW2_2");
+ inputs[3] = gpio_find_by_name("SW2_3");
+ dip = !gpio_get_value(inputs[0]);
+ dip += !gpio_get_value(inputs[1]) << 1;
+ dip += !gpio_get_value(inputs[2]) << 2;
+ dip += !gpio_get_value(inputs[3]) << 3;
+ break;
+ }
+
+ return dip;
+}
+
static int baltos_read_eeprom(void)
{
struct bsp_vs_hwparam hw_param;
- size_t size;
char *buf, var_buf[32];
int rc;
unsigned char mac_addr[6];
+ uint8_t dip;
+ int mpcie_pwr_pin;
if (!of_machine_is_compatible("vscom,onrisc"))
return 0;
rc = read_file_2("/dev/eeprom0",
- &size,
+ NULL,
(void *)&buf,
sizeof(hw_param));
if (rc && rc != -EFBIG)
@@ -113,16 +146,26 @@ static int baltos_read_eeprom(void)
globalvar_add_simple("board.id", var_buf);
/* enable mPCIe slot */
- gpio_direction_output(100, 1);
+ mpcie_pwr_pin = gpio_find_by_name("3G_PWR_EN");
+ gpio_direction_output(mpcie_pwr_pin, 1);
/* configure output signals of the external GPIO controller */
if (hw_param.SystemId == 210 || hw_param.SystemId == 211) {
- gpio_direction_output(132, 0);
- gpio_direction_output(133, 0);
- gpio_direction_output(134, 0);
- gpio_direction_output(135, 0);
+ int outs[4];
+ outs[0] = gpio_find_by_name("GP_OUT0");
+ outs[1] = gpio_find_by_name("GP_OUT1");
+ outs[2] = gpio_find_by_name("GP_OUT2");
+ outs[3] = gpio_find_by_name("GP_OUT3");
+ gpio_direction_output(outs[0], 0);
+ gpio_direction_output(outs[1], 0);
+ gpio_direction_output(outs[2], 0);
+ gpio_direction_output(outs[3], 0);
}
+ dip = get_dip_switch(hw_param.SystemId, hw_param.HwRev);
+ sprintf(var_buf, "%02x", dip);
+ globalvar_add_simple("board.dip", var_buf);
+
return 0;
}
environment_initcall(baltos_read_eeprom);