mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-28 23:50:26 +09:00
ARM: uniphier: detect the base of micro support card at run-time
The base address 0x43f00000 is no longer true for the future SoC. Extract the base address from the device tree. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
This commit is contained in:
parent
1320fa2e55
commit
2ba1d398d7
@ -1,39 +1,58 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0+
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2012-2015 Panasonic Corporation
|
* Copyright (C) 2012-2015 Panasonic Corporation
|
||||||
* Copyright (C) 2015-2016 Socionext Inc.
|
* Copyright (C) 2015-2020 Socionext Inc.
|
||||||
* Author: Masahiro Yamada <yamada.masahiro@socionext.com>
|
* Author: Masahiro Yamada <yamada.masahiro@socionext.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
#include <dm/of.h>
|
||||||
|
#include <fdt_support.h>
|
||||||
#include <linux/ctype.h>
|
#include <linux/ctype.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
|
|
||||||
#include "micro-support-card.h"
|
#include "micro-support-card.h"
|
||||||
|
|
||||||
#define MICRO_SUPPORT_CARD_BASE 0x43f00000
|
#define SMC911X_OFFSET 0x00000
|
||||||
#define SMC911X_BASE ((MICRO_SUPPORT_CARD_BASE) + 0x00000)
|
#define LED_OFFSET 0x90000
|
||||||
#define LED_BASE ((MICRO_SUPPORT_CARD_BASE) + 0x90000)
|
#define NS16550A_OFFSET 0xb0000
|
||||||
#define NS16550A_BASE ((MICRO_SUPPORT_CARD_BASE) + 0xb0000)
|
#define MICRO_SUPPORT_CARD_RESET 0xd0034
|
||||||
#define MICRO_SUPPORT_CARD_RESET ((MICRO_SUPPORT_CARD_BASE) + 0xd0034)
|
#define MICRO_SUPPORT_CARD_REVISION 0xd00e0
|
||||||
#define MICRO_SUPPORT_CARD_REVISION ((MICRO_SUPPORT_CARD_BASE) + 0xd00E0)
|
|
||||||
|
|
||||||
static bool support_card_found;
|
static bool support_card_found;
|
||||||
|
static void __iomem *support_card_base;
|
||||||
|
|
||||||
static void support_card_detect(void)
|
static void support_card_detect(void)
|
||||||
{
|
{
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
const void *fdt = gd->fdt_blob;
|
const void *fdt = gd->fdt_blob;
|
||||||
int offset;
|
int offset;
|
||||||
|
u64 addr, addr2;
|
||||||
|
|
||||||
offset = fdt_node_offset_by_compatible(fdt, 0, "smsc,lan9118");
|
offset = fdt_node_offset_by_compatible(fdt, 0, "smsc,lan9118");
|
||||||
if (offset < 0)
|
if (offset < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
addr = fdt_get_base_address(fdt, offset);
|
||||||
|
if (addr == OF_BAD_ADDR)
|
||||||
|
return;
|
||||||
|
addr -= SMC911X_OFFSET;
|
||||||
|
|
||||||
offset = fdt_node_offset_by_compatible(fdt, 0, "ns16550a");
|
offset = fdt_node_offset_by_compatible(fdt, 0, "ns16550a");
|
||||||
if (offset < 0)
|
if (offset < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
addr2 = fdt_get_base_address(fdt, offset);
|
||||||
|
if (addr2 == OF_BAD_ADDR)
|
||||||
|
return;
|
||||||
|
addr2 -= NS16550A_OFFSET;
|
||||||
|
|
||||||
|
/* sanity check */
|
||||||
|
if (addr != addr2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
support_card_base = ioremap(addr, 0x100000);
|
||||||
|
|
||||||
support_card_found = true;
|
support_card_found = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,19 +64,19 @@ static void support_card_detect(void)
|
|||||||
*/
|
*/
|
||||||
static void support_card_reset_deassert(void)
|
static void support_card_reset_deassert(void)
|
||||||
{
|
{
|
||||||
writel(0x00010000, MICRO_SUPPORT_CARD_RESET);
|
writel(0x00010000, support_card_base + MICRO_SUPPORT_CARD_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void support_card_reset(void)
|
static void support_card_reset(void)
|
||||||
{
|
{
|
||||||
writel(0x00020003, MICRO_SUPPORT_CARD_RESET);
|
writel(0x00020003, support_card_base + MICRO_SUPPORT_CARD_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int support_card_show_revision(void)
|
static int support_card_show_revision(void)
|
||||||
{
|
{
|
||||||
u32 revision;
|
u32 revision;
|
||||||
|
|
||||||
revision = readl(MICRO_SUPPORT_CARD_REVISION);
|
revision = readl(support_card_base + MICRO_SUPPORT_CARD_REVISION);
|
||||||
revision &= 0xff;
|
revision &= 0xff;
|
||||||
|
|
||||||
/* revision 3.6.x card changed the revision format */
|
/* revision 3.6.x card changed the revision format */
|
||||||
@ -94,7 +113,7 @@ int board_eth_init(bd_t *bis)
|
|||||||
if (!support_card_found)
|
if (!support_card_found)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return smc911x_initialize(0, SMC911X_BASE);
|
return smc911x_initialize(0, (unsigned long)support_card_base + SMC911X_OFFSET);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -264,5 +283,5 @@ void led_puts(const char *s)
|
|||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
|
|
||||||
writel(~val, LED_BASE);
|
writel(~val, support_card_base + LED_OFFSET);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user