9
0
Fork 0
barebox/arch/arm/boards/highbank/init.c

146 lines
3.2 KiB
C
Raw Normal View History

/*
* Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
*
* GPLv2 only
*/
#include <common.h>
#include <init.h>
#include <asm/armlinux.h>
#include <asm/system_info.h>
#include <generated/mach-types.h>
#include <mach/devices.h>
#include <mach/hardware.h>
#include <mach/sysregs.h>
#include <environment.h>
#include <partition.h>
#include <sizes.h>
#include <io.h>
#include <of.h>
highbank: use the provided dtb by the firmware to probe barebox device and mem size the dtb is at 0x1000 if no dtb present use C code device keep in C the timer/gpio/uart have a nice tree barebox 2013.02.0-00294-g6802ddf #124 Wed Feb 13 02:31:01 CST 2013 Board: Calxeda Highbank memory: ram0: 0xff900000@0x0 highbank: dtb probed memory size registered netconsole as cs1 malloc space: 0x03500000 -> 0x03efffff (size 10 MiB) Open /dev/env0 No such file or directory no valid environment found on /dev/env0. Using default environment running /env/bin/init... ahci ffe08000.sata: port 0: SATA link ok ahci ffe08000.sata: port 0: Spinning up device... ahci ffe08000.sata: port 0: ok. ahci ffe08000.sata: registered /dev/ata0 eth0: got preset MAC address: 52:54:00:12:34:56 eth1: got preset MAC address: 52:54:00:12:34:57 Hit any key to stop autoboot: 3 [barebox@Calxeda Highbank]:/ # devinfo devices: `---- platform `---- mem0 `---- 0x00000000-0x3fffffff: /dev/ram0 `---- 0x00001000-0x00010fff: /dev/dtb `---- mem1 `---- 0x00000000-0x000051af: /dev/defaultenv `---- mem2 `---- 0x00000000-0xfffffffe: /dev/mem `---- cs1 `---- fff10600.timer `---- fff10620.watchdog `---- fff11000.interrupt-controller `---- l2-cache `---- ffe08000.sata `---- 0x00000000-0x3fffffff: /dev/ata0 `---- 0x00100000-0x014fffff: /dev/ata0.0 `---- 0x01500000-0x3fffffff: /dev/ata0.1 `---- ffe0e000.sdhci `---- fff00000.memory-controller `---- mem3 `---- fff3c000.sregs `---- fff3c200.sregs `---- fff50000.ethernet `---- eth0 `---- fff51000.ethernet `---- eth1 `---- amba `---- sp804 `---- uart-pl011 `---- cs0 `---- fff30000.gpio `---- fff31000.gpio `---- fff32000.gpio `---- fff33000.gpio `---- fff35000.rtc `---- fs `---- ramfs0 `---- devfs0 `---- net `---- global drivers: uart-pl011 sp804 pl061_gpio ramfs devfs tftp hb-xgmac ahci mem [barebox@Calxeda Highbank]:/ # Cc: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-02-13 10:06:44 +00:00
#define FIRMWARE_DTB_BASE 0x1000
#define HB_OPP_VERSION 0
highbank: use the provided dtb by the firmware to probe barebox device and mem size the dtb is at 0x1000 if no dtb present use C code device keep in C the timer/gpio/uart have a nice tree barebox 2013.02.0-00294-g6802ddf #124 Wed Feb 13 02:31:01 CST 2013 Board: Calxeda Highbank memory: ram0: 0xff900000@0x0 highbank: dtb probed memory size registered netconsole as cs1 malloc space: 0x03500000 -> 0x03efffff (size 10 MiB) Open /dev/env0 No such file or directory no valid environment found on /dev/env0. Using default environment running /env/bin/init... ahci ffe08000.sata: port 0: SATA link ok ahci ffe08000.sata: port 0: Spinning up device... ahci ffe08000.sata: port 0: ok. ahci ffe08000.sata: registered /dev/ata0 eth0: got preset MAC address: 52:54:00:12:34:56 eth1: got preset MAC address: 52:54:00:12:34:57 Hit any key to stop autoboot: 3 [barebox@Calxeda Highbank]:/ # devinfo devices: `---- platform `---- mem0 `---- 0x00000000-0x3fffffff: /dev/ram0 `---- 0x00001000-0x00010fff: /dev/dtb `---- mem1 `---- 0x00000000-0x000051af: /dev/defaultenv `---- mem2 `---- 0x00000000-0xfffffffe: /dev/mem `---- cs1 `---- fff10600.timer `---- fff10620.watchdog `---- fff11000.interrupt-controller `---- l2-cache `---- ffe08000.sata `---- 0x00000000-0x3fffffff: /dev/ata0 `---- 0x00100000-0x014fffff: /dev/ata0.0 `---- 0x01500000-0x3fffffff: /dev/ata0.1 `---- ffe0e000.sdhci `---- fff00000.memory-controller `---- mem3 `---- fff3c000.sregs `---- fff3c200.sregs `---- fff50000.ethernet `---- eth0 `---- fff51000.ethernet `---- eth1 `---- amba `---- sp804 `---- uart-pl011 `---- cs0 `---- fff30000.gpio `---- fff31000.gpio `---- fff32000.gpio `---- fff33000.gpio `---- fff35000.rtc `---- fs `---- ramfs0 `---- devfs0 `---- net `---- global drivers: uart-pl011 sp804 pl061_gpio ramfs devfs tftp hb-xgmac ahci mem [barebox@Calxeda Highbank]:/ # Cc: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-02-13 10:06:44 +00:00
struct fdt_header *fdt = NULL;
static int hb_fixup(struct device_node *root)
{
struct device_node *node;
u32 reg = readl(sregs_base + HB_SREG_A9_PWRDOM_DATA);
u32 *opp_table = (u32 *)HB_SYSRAM_OPP_TABLE_BASE;
u32 dtb_table[2*10];
u32 i;
u32 num_opps;
__be32 latency;
if (!(reg & HB_PWRDOM_STAT_SATA)) {
of_tree_for_each_node(node, root) {
if (of_device_is_compatible(node, "calxeda,hb-ahci"))
of_set_property(node, "status", "disabled",
sizeof("disabled"), 1);
}
}
if (!(reg & HB_PWRDOM_STAT_EMMC)) {
of_tree_for_each_node(node, root) {
if (of_device_is_compatible(node, "calxeda,hb-sdhci"))
of_set_property(node, "status", "disabled",
sizeof("disabled"), 1);
}
}
if ((opp_table[0] >> 16) != HB_OPP_VERSION)
return 0;
node = of_find_node_by_path(root, "/cpus/cpu@0");
if (!node)
return 0;
num_opps = opp_table[0] & 0xff;
for (i = 0; i < num_opps; i++) {
dtb_table[2 * i] = cpu_to_be32(opp_table[3 + 3 * i]);
dtb_table[2 * i + 1] = cpu_to_be32(opp_table[2 + 3 * i]);
}
latency = cpu_to_be32(opp_table[1]);
of_set_property(node, "transition-latency", &latency, 4, 1);
of_set_property(node, "operating-points", dtb_table, 8 * num_opps, 1);
return 0;
}
static int highbank_mem_init(void)
{
struct device_node *root, *np;
highbank: use the provided dtb by the firmware to probe barebox device and mem size the dtb is at 0x1000 if no dtb present use C code device keep in C the timer/gpio/uart have a nice tree barebox 2013.02.0-00294-g6802ddf #124 Wed Feb 13 02:31:01 CST 2013 Board: Calxeda Highbank memory: ram0: 0xff900000@0x0 highbank: dtb probed memory size registered netconsole as cs1 malloc space: 0x03500000 -> 0x03efffff (size 10 MiB) Open /dev/env0 No such file or directory no valid environment found on /dev/env0. Using default environment running /env/bin/init... ahci ffe08000.sata: port 0: SATA link ok ahci ffe08000.sata: port 0: Spinning up device... ahci ffe08000.sata: port 0: ok. ahci ffe08000.sata: registered /dev/ata0 eth0: got preset MAC address: 52:54:00:12:34:56 eth1: got preset MAC address: 52:54:00:12:34:57 Hit any key to stop autoboot: 3 [barebox@Calxeda Highbank]:/ # devinfo devices: `---- platform `---- mem0 `---- 0x00000000-0x3fffffff: /dev/ram0 `---- 0x00001000-0x00010fff: /dev/dtb `---- mem1 `---- 0x00000000-0x000051af: /dev/defaultenv `---- mem2 `---- 0x00000000-0xfffffffe: /dev/mem `---- cs1 `---- fff10600.timer `---- fff10620.watchdog `---- fff11000.interrupt-controller `---- l2-cache `---- ffe08000.sata `---- 0x00000000-0x3fffffff: /dev/ata0 `---- 0x00100000-0x014fffff: /dev/ata0.0 `---- 0x01500000-0x3fffffff: /dev/ata0.1 `---- ffe0e000.sdhci `---- fff00000.memory-controller `---- mem3 `---- fff3c000.sregs `---- fff3c200.sregs `---- fff50000.ethernet `---- eth0 `---- fff51000.ethernet `---- eth1 `---- amba `---- sp804 `---- uart-pl011 `---- cs0 `---- fff30000.gpio `---- fff31000.gpio `---- fff32000.gpio `---- fff33000.gpio `---- fff35000.rtc `---- fs `---- ramfs0 `---- devfs0 `---- net `---- global drivers: uart-pl011 sp804 pl061_gpio ramfs devfs tftp hb-xgmac ahci mem [barebox@Calxeda Highbank]:/ # Cc: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-02-13 10:06:44 +00:00
int ret;
/* load by the firmware at 0x1000 */
fdt = IOMEM(FIRMWARE_DTB_BASE);
root = of_unflatten_dtb(NULL, fdt);
if (!root) {
highbank: use the provided dtb by the firmware to probe barebox device and mem size the dtb is at 0x1000 if no dtb present use C code device keep in C the timer/gpio/uart have a nice tree barebox 2013.02.0-00294-g6802ddf #124 Wed Feb 13 02:31:01 CST 2013 Board: Calxeda Highbank memory: ram0: 0xff900000@0x0 highbank: dtb probed memory size registered netconsole as cs1 malloc space: 0x03500000 -> 0x03efffff (size 10 MiB) Open /dev/env0 No such file or directory no valid environment found on /dev/env0. Using default environment running /env/bin/init... ahci ffe08000.sata: port 0: SATA link ok ahci ffe08000.sata: port 0: Spinning up device... ahci ffe08000.sata: port 0: ok. ahci ffe08000.sata: registered /dev/ata0 eth0: got preset MAC address: 52:54:00:12:34:56 eth1: got preset MAC address: 52:54:00:12:34:57 Hit any key to stop autoboot: 3 [barebox@Calxeda Highbank]:/ # devinfo devices: `---- platform `---- mem0 `---- 0x00000000-0x3fffffff: /dev/ram0 `---- 0x00001000-0x00010fff: /dev/dtb `---- mem1 `---- 0x00000000-0x000051af: /dev/defaultenv `---- mem2 `---- 0x00000000-0xfffffffe: /dev/mem `---- cs1 `---- fff10600.timer `---- fff10620.watchdog `---- fff11000.interrupt-controller `---- l2-cache `---- ffe08000.sata `---- 0x00000000-0x3fffffff: /dev/ata0 `---- 0x00100000-0x014fffff: /dev/ata0.0 `---- 0x01500000-0x3fffffff: /dev/ata0.1 `---- ffe0e000.sdhci `---- fff00000.memory-controller `---- mem3 `---- fff3c000.sregs `---- fff3c200.sregs `---- fff50000.ethernet `---- eth0 `---- fff51000.ethernet `---- eth1 `---- amba `---- sp804 `---- uart-pl011 `---- cs0 `---- fff30000.gpio `---- fff31000.gpio `---- fff32000.gpio `---- fff33000.gpio `---- fff35000.rtc `---- fs `---- ramfs0 `---- devfs0 `---- net `---- global drivers: uart-pl011 sp804 pl061_gpio ramfs devfs tftp hb-xgmac ahci mem [barebox@Calxeda Highbank]:/ # Cc: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-02-13 10:06:44 +00:00
pr_warn("no dtb found at 0x1000 use default configuration\n");
fdt = NULL;
goto not_found;
}
of_set_root_node(root);
np = of_find_node_by_path(root, "/memory");
highbank: use the provided dtb by the firmware to probe barebox device and mem size the dtb is at 0x1000 if no dtb present use C code device keep in C the timer/gpio/uart have a nice tree barebox 2013.02.0-00294-g6802ddf #124 Wed Feb 13 02:31:01 CST 2013 Board: Calxeda Highbank memory: ram0: 0xff900000@0x0 highbank: dtb probed memory size registered netconsole as cs1 malloc space: 0x03500000 -> 0x03efffff (size 10 MiB) Open /dev/env0 No such file or directory no valid environment found on /dev/env0. Using default environment running /env/bin/init... ahci ffe08000.sata: port 0: SATA link ok ahci ffe08000.sata: port 0: Spinning up device... ahci ffe08000.sata: port 0: ok. ahci ffe08000.sata: registered /dev/ata0 eth0: got preset MAC address: 52:54:00:12:34:56 eth1: got preset MAC address: 52:54:00:12:34:57 Hit any key to stop autoboot: 3 [barebox@Calxeda Highbank]:/ # devinfo devices: `---- platform `---- mem0 `---- 0x00000000-0x3fffffff: /dev/ram0 `---- 0x00001000-0x00010fff: /dev/dtb `---- mem1 `---- 0x00000000-0x000051af: /dev/defaultenv `---- mem2 `---- 0x00000000-0xfffffffe: /dev/mem `---- cs1 `---- fff10600.timer `---- fff10620.watchdog `---- fff11000.interrupt-controller `---- l2-cache `---- ffe08000.sata `---- 0x00000000-0x3fffffff: /dev/ata0 `---- 0x00100000-0x014fffff: /dev/ata0.0 `---- 0x01500000-0x3fffffff: /dev/ata0.1 `---- ffe0e000.sdhci `---- fff00000.memory-controller `---- mem3 `---- fff3c000.sregs `---- fff3c200.sregs `---- fff50000.ethernet `---- eth0 `---- fff51000.ethernet `---- eth1 `---- amba `---- sp804 `---- uart-pl011 `---- cs0 `---- fff30000.gpio `---- fff31000.gpio `---- fff32000.gpio `---- fff33000.gpio `---- fff35000.rtc `---- fs `---- ramfs0 `---- devfs0 `---- net `---- global drivers: uart-pl011 sp804 pl061_gpio ramfs devfs tftp hb-xgmac ahci mem [barebox@Calxeda Highbank]:/ # Cc: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-02-13 10:06:44 +00:00
if (!np) {
pr_warn("no memory node use default configuration\n");
goto not_found;
}
ret = of_add_memory(np, true);
if (ret) {
pr_warn("memory node: probe failed use default configuration\n");
goto not_found;
}
pr_info("highbank: dtb probed memory size\n");
return 0;
not_found:
highbank_add_ddram(4089 << 20);
return 0;
}
mem_initcall(highbank_mem_init);
static int highbank_devices_init(void)
{
of_register_fixup(hb_fixup);
highbank: use the provided dtb by the firmware to probe barebox device and mem size the dtb is at 0x1000 if no dtb present use C code device keep in C the timer/gpio/uart have a nice tree barebox 2013.02.0-00294-g6802ddf #124 Wed Feb 13 02:31:01 CST 2013 Board: Calxeda Highbank memory: ram0: 0xff900000@0x0 highbank: dtb probed memory size registered netconsole as cs1 malloc space: 0x03500000 -> 0x03efffff (size 10 MiB) Open /dev/env0 No such file or directory no valid environment found on /dev/env0. Using default environment running /env/bin/init... ahci ffe08000.sata: port 0: SATA link ok ahci ffe08000.sata: port 0: Spinning up device... ahci ffe08000.sata: port 0: ok. ahci ffe08000.sata: registered /dev/ata0 eth0: got preset MAC address: 52:54:00:12:34:56 eth1: got preset MAC address: 52:54:00:12:34:57 Hit any key to stop autoboot: 3 [barebox@Calxeda Highbank]:/ # devinfo devices: `---- platform `---- mem0 `---- 0x00000000-0x3fffffff: /dev/ram0 `---- 0x00001000-0x00010fff: /dev/dtb `---- mem1 `---- 0x00000000-0x000051af: /dev/defaultenv `---- mem2 `---- 0x00000000-0xfffffffe: /dev/mem `---- cs1 `---- fff10600.timer `---- fff10620.watchdog `---- fff11000.interrupt-controller `---- l2-cache `---- ffe08000.sata `---- 0x00000000-0x3fffffff: /dev/ata0 `---- 0x00100000-0x014fffff: /dev/ata0.0 `---- 0x01500000-0x3fffffff: /dev/ata0.1 `---- ffe0e000.sdhci `---- fff00000.memory-controller `---- mem3 `---- fff3c000.sregs `---- fff3c200.sregs `---- fff50000.ethernet `---- eth0 `---- fff51000.ethernet `---- eth1 `---- amba `---- sp804 `---- uart-pl011 `---- cs0 `---- fff30000.gpio `---- fff31000.gpio `---- fff32000.gpio `---- fff33000.gpio `---- fff35000.rtc `---- fs `---- ramfs0 `---- devfs0 `---- net `---- global drivers: uart-pl011 sp804 pl061_gpio ramfs devfs tftp hb-xgmac ahci mem [barebox@Calxeda Highbank]:/ # Cc: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-02-13 10:06:44 +00:00
if (!fdt) {
highbank_register_gpio(0);
highbank_register_gpio(1);
highbank_register_gpio(2);
highbank_register_gpio(3);
highbank_register_ahci();
highbank_register_xgmac(0);
highbank_register_xgmac(1);
} else {
fdt = of_get_fixed_tree(NULL);
add_mem_device("dtb", (unsigned long)fdt, be32_to_cpu(fdt->totalsize),
IORESOURCE_MEM_WRITEABLE);
devfs_add_partition("ram0", FIRMWARE_DTB_BASE, SZ_64K, DEVFS_PARTITION_FIXED, "firmware-dtb");
highbank: use the provided dtb by the firmware to probe barebox device and mem size the dtb is at 0x1000 if no dtb present use C code device keep in C the timer/gpio/uart have a nice tree barebox 2013.02.0-00294-g6802ddf #124 Wed Feb 13 02:31:01 CST 2013 Board: Calxeda Highbank memory: ram0: 0xff900000@0x0 highbank: dtb probed memory size registered netconsole as cs1 malloc space: 0x03500000 -> 0x03efffff (size 10 MiB) Open /dev/env0 No such file or directory no valid environment found on /dev/env0. Using default environment running /env/bin/init... ahci ffe08000.sata: port 0: SATA link ok ahci ffe08000.sata: port 0: Spinning up device... ahci ffe08000.sata: port 0: ok. ahci ffe08000.sata: registered /dev/ata0 eth0: got preset MAC address: 52:54:00:12:34:56 eth1: got preset MAC address: 52:54:00:12:34:57 Hit any key to stop autoboot: 3 [barebox@Calxeda Highbank]:/ # devinfo devices: `---- platform `---- mem0 `---- 0x00000000-0x3fffffff: /dev/ram0 `---- 0x00001000-0x00010fff: /dev/dtb `---- mem1 `---- 0x00000000-0x000051af: /dev/defaultenv `---- mem2 `---- 0x00000000-0xfffffffe: /dev/mem `---- cs1 `---- fff10600.timer `---- fff10620.watchdog `---- fff11000.interrupt-controller `---- l2-cache `---- ffe08000.sata `---- 0x00000000-0x3fffffff: /dev/ata0 `---- 0x00100000-0x014fffff: /dev/ata0.0 `---- 0x01500000-0x3fffffff: /dev/ata0.1 `---- ffe0e000.sdhci `---- fff00000.memory-controller `---- mem3 `---- fff3c000.sregs `---- fff3c200.sregs `---- fff50000.ethernet `---- eth0 `---- fff51000.ethernet `---- eth1 `---- amba `---- sp804 `---- uart-pl011 `---- cs0 `---- fff30000.gpio `---- fff31000.gpio `---- fff32000.gpio `---- fff33000.gpio `---- fff35000.rtc `---- fs `---- ramfs0 `---- devfs0 `---- net `---- global drivers: uart-pl011 sp804 pl061_gpio ramfs devfs tftp hb-xgmac ahci mem [barebox@Calxeda Highbank]:/ # Cc: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-02-13 10:06:44 +00:00
}
armlinux_set_bootparams((void *)(0x00000100));
devfs_add_partition("nvram", 0x00000, SZ_16K, DEVFS_PARTITION_FIXED, "env0");
return 0;
}
device_initcall(highbank_devices_init);
static int highbank_console_init(void)
{
highbank_register_uart();
return 0;
}
console_initcall(highbank_console_init);