提交 0b591386 编写于 作者: T Tom Rini

Merge branch '2020-07-07-misc-new-features'

- Improve s700 SoC support
- Fix building with clang on ARM.
- Juno platform updates
- fs/dm cmd improvements
- Other assorted improvements / fixes
......@@ -908,6 +908,7 @@ config ARCH_MX5
config ARCH_OWL
bool "Actions Semi OWL SoCs"
select DM
select DM_ETH
select DM_SERIAL
select OWL_SERIAL
select CLK
......@@ -1179,7 +1180,7 @@ config TARGET_VEXPRESS64_JUNO
select DM_SERIAL
select ARM_PSCI_FW
select PSCI_RESET
select DM
select DM_ETH
select BLK
select USB
select DM_USB
......
......@@ -6,6 +6,19 @@
/{
soc {
u-boot,dm-pre-reloc;
gmac: ethernet@e0220000 {
compatible = "actions,s700-ethernet";
reg = <0 0xe0220000 0 0x2000>;
interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "macirq";
local-mac-address = [ 00 18 fe 66 66 66 ];
clocks = <&cmu CLK_ETHERNET>, <&cmu CLK_RMII_REF>;
clock-names = "ethernet", "rmii_ref";
phy-mode = "rmii";
status = "okay";
};
};
};
......
......@@ -53,4 +53,12 @@
#define CMU_CVBSPLL 0x00B8
#define CMU_SSTSCLK 0x00C0
#define CMU_DEVCLKEN1_ETH BIT(23)
#define GPIO_MFP_PWM (0xE01B0000)
#define MFP_CTL0 (GPIO_MFP_PWM + 0x40)
#define MFP_CTL1 (GPIO_MFP_PWM + 0x44)
#define MFP_CTL2 (GPIO_MFP_PWM + 0x48)
#define MFP_CTL3 (GPIO_MFP_PWM + 0x4C)
#endif
......@@ -61,4 +61,8 @@
#define CMU_TVOUTPLLDEBUG0 (0x00EC)
#define CMU_TVOUTPLLDEBUG1 (0x00FC)
#define CMU_DEVCLKEN1_ETH BIT(22)
#define CLK_ETHERNET CLK_ETH_MAC
#define CMU_ETHERNETPLL CMU_ASSISTPLL
#endif
......@@ -96,10 +96,6 @@ static inline gd_t *get_gd(void)
gd_t *gd_ptr;
#ifdef CONFIG_ARM64
/*
* Make will already error that reserving x18 is not supported at the
* time of writing, clang: error: unknown argument: '-ffixed-x18'
*/
__asm__ volatile("mov %0, x18\n" : "=r" (gd_ptr));
#else
__asm__ volatile("mov %0, r9\n" : "=r" (gd_ptr));
......
......@@ -133,14 +133,16 @@ enum dcache_option {
static inline unsigned int current_el(void)
{
unsigned int el;
unsigned long el;
asm volatile("mrs %0, CurrentEL" : "=r" (el) : : "cc");
return el >> 2;
return 3 & (el >> 2);
}
static inline unsigned int get_sctlr(void)
{
unsigned int el, val;
unsigned int el;
unsigned long val;
el = current_el();
if (el == 1)
......@@ -153,7 +155,7 @@ static inline unsigned int get_sctlr(void)
return val;
}
static inline void set_sctlr(unsigned int val)
static inline void set_sctlr(unsigned long val)
{
unsigned int el;
......
......@@ -15,14 +15,34 @@
#include <asm/mach-types.h>
#include <asm/psci.h>
#define DMM_INTERLEAVE_PER_CH_CFG 0xe0290028
DECLARE_GLOBAL_DATA_PTR;
unsigned int owl_get_ddrcap(void)
{
unsigned int val, cap;
/* ddr capacity register initialized by ddr driver
* in early bootloader
*/
#if defined(CONFIG_MACH_S700)
val = (readl(DMM_INTERLEAVE_PER_CH_CFG) >> 8) & 0x7;
cap = (val + 1) * 256;
#elif defined(CONFIG_MACH_S900)
val = (readl(DMM_INTERLEAVE_PER_CH_CFG) >> 8) & 0xf;
cap = 64 * (1 << val);
#endif
return cap;
}
/*
* dram_init - sets uboots idea of sdram size
*/
int dram_init(void)
{
gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
gd->ram_size = owl_get_ddrcap() * 1024 * 1024;
return 0;
}
......
......@@ -72,9 +72,9 @@
JUNO_RESET_STATUS_PHY | \
JUNO_RESET_STATUS_RC)
void xr3pci_set_atr_entry(unsigned long base, unsigned long src_addr,
unsigned long trsl_addr, int window_size,
int trsl_param)
static void xr3pci_set_atr_entry(unsigned long base, unsigned long src_addr,
unsigned long trsl_addr, int window_size,
int trsl_param)
{
/* X3PCI_ATR_SRC_ADDR_LOW:
- bit 0: enable entry,
......@@ -94,7 +94,7 @@ void xr3pci_set_atr_entry(unsigned long base, unsigned long src_addr,
((u64)1) << window_size, trsl_param);
}
void xr3pci_setup_atr(void)
static void xr3pci_setup_atr(void)
{
/* setup PCIe to CPU address translation tables */
unsigned long base = XR3_CONFIG_BASE + XR3PCI_ATR_PCIE_WIN0;
......@@ -141,7 +141,7 @@ void xr3pci_setup_atr(void)
XR3_PCI_MEMSPACE64_SIZE, XR3PCI_ATR_TRSLID_PCIE_MEMORY);
}
void xr3pci_init(void)
static void xr3pci_init(void)
{
u32 val;
int timeout = 200;
......@@ -193,5 +193,9 @@ void xr3pci_init(void)
void vexpress64_pcie_init(void)
{
/* Initialise and configure the PCIe host bridge. */
xr3pci_init();
/* Register the now ECAM complaint PCIe host controller with U-Boot. */
pci_init();
}
......@@ -152,11 +152,13 @@ void reset_cpu(ulong addr)
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifndef CONFIG_DM_ETH
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
#ifdef CONFIG_SMC911X
rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
#endif
#endif
return rc;
}
......@@ -1088,6 +1088,13 @@ config CMD_LOADS
help
Load an S-Record file over serial line
config CMD_LSBLK
depends on BLK
bool "lsblk - list block drivers and devices"
help
Print list of available block device drivers, and for each, the list
of known block devices.
config CMD_MMC
bool "mmc"
help
......
......@@ -84,6 +84,7 @@ obj-$(CONFIG_CMD_LED) += led.o
obj-$(CONFIG_CMD_LICENSE) += license.o
obj-y += load.o
obj-$(CONFIG_CMD_LOG) += log.o
obj-$(CONFIG_CMD_LSBLK) += lsblk.o
obj-$(CONFIG_ID_EEPROM) += mac.o
obj-$(CONFIG_CMD_MD5SUM) += md5sum.o
obj-$(CONFIG_CMD_MEMORY) += mem.o
......
......@@ -48,11 +48,29 @@ static int do_dm_dump_drivers(struct cmd_tbl *cmdtp, int flag, int argc,
return 0;
}
static int do_dm_dump_driver_compat(struct cmd_tbl *cmdtp, int flag, int argc,
char * const argv[])
{
dm_dump_driver_compat();
return 0;
}
static int do_dm_dump_static_driver_info(struct cmd_tbl *cmdtp, int flag, int argc,
char * const argv[])
{
dm_dump_static_driver_info();
return 0;
}
static struct cmd_tbl test_commands[] = {
U_BOOT_CMD_MKENT(tree, 0, 1, do_dm_dump_all, "", ""),
U_BOOT_CMD_MKENT(uclass, 1, 1, do_dm_dump_uclass, "", ""),
U_BOOT_CMD_MKENT(devres, 1, 1, do_dm_dump_devres, "", ""),
U_BOOT_CMD_MKENT(drivers, 1, 1, do_dm_dump_drivers, "", ""),
U_BOOT_CMD_MKENT(compat, 1, 1, do_dm_dump_driver_compat, "", ""),
U_BOOT_CMD_MKENT(static, 1, 1, do_dm_dump_static_driver_info, "", ""),
};
static __maybe_unused void dm_reloc(void)
......@@ -94,5 +112,7 @@ U_BOOT_CMD(
"tree Dump driver model tree ('*' = activated)\n"
"dm uclass Dump list of instances for each uclass\n"
"dm devres Dump list of device resources for each device\n"
"dm drivers Dump list of drivers and their compatible strings"
"dm drivers Dump list of drivers with uclass and instances\n"
"dm compat Dump list of drivers with compatibility strings\n"
"dm static Dump list of drivers with static platform data"
);
......@@ -100,3 +100,14 @@ U_BOOT_CMD(
"fstype <interface> <dev>:<part> <varname>\n"
"- set environment variable to filesystem type\n"
);
static int do_fstypes_wrapper(struct cmd_tbl *cmdtp, int flag, int argc,
char * const argv[])
{
return do_fs_types(cmdtp, flag, argc, argv);
}
U_BOOT_CMD(
fstypes, 1, 1, do_fstypes_wrapper,
"List supported filesystem types", ""
);
// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2020
* Niel Fourie, DENX Software Engineering, lusus@denx.de.
*/
#include <common.h>
#include <dm.h>
static int do_lsblk(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
{
struct driver *d = ll_entry_start(struct driver, driver);
const int n_ents = ll_entry_count(struct driver, driver);
struct driver *entry;
struct udevice *udev;
struct uclass *uc;
struct blk_desc *desc;
int ret, i;
ret = uclass_get(UCLASS_BLK, &uc);
if (ret) {
puts("Could not get BLK uclass.\n");
return CMD_RET_FAILURE;
}
puts("Block Driver Devices\n");
puts("-----------------------------\n");
for (entry = d; entry < d + n_ents; entry++) {
if (entry->id != UCLASS_BLK)
continue;
i = 0;
printf("%-20.20s", entry->name);
uclass_foreach_dev(udev, uc) {
if (udev->driver != entry)
continue;
desc = dev_get_uclass_platdata(udev);
printf("%c %s %u", i ? ',' : ':',
blk_get_if_type_name(desc->if_type),
desc->devnum);
i++;
}
if (!i)
puts(": <none>");
puts("\n");
}
return CMD_RET_SUCCESS;
}
U_BOOT_CMD(lsblk, 1, 0, do_lsblk, "list block drivers and devices",
"- display list of block device drivers and attached block devices"
);
......@@ -182,6 +182,26 @@ static int do_part_number(int argc, char *const argv[])
return do_part_info(argc, argv, CMD_PART_INFO_NUMBER);
}
static int do_part_types(int argc, char * const argv[])
{
struct part_driver *drv = ll_entry_start(struct part_driver,
part_driver);
const int n_ents = ll_entry_count(struct part_driver, part_driver);
struct part_driver *entry;
int i = 0;
puts("Supported partition tables");
for (entry = drv; entry != drv + n_ents; entry++) {
printf("%c %s", i ? ',' : ':', entry->name);
i++;
}
if (!i)
puts(": <none>");
puts("\n");
return CMD_RET_SUCCESS;
}
static int do_part(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
......@@ -198,7 +218,8 @@ static int do_part(struct cmd_tbl *cmdtp, int flag, int argc,
return do_part_size(argc - 2, argv + 2);
else if (!strcmp(argv[1], "number"))
return do_part_number(argc - 2, argv + 2);
else if (!strcmp(argv[1], "types"))
return do_part_types(argc - 2, argv + 2);
return CMD_RET_USAGE;
}
......@@ -222,5 +243,7 @@ U_BOOT_CMD(
" part can be either partition number or partition name\n"
"part number <interface> <dev> <part> <varname>\n"
" - set environment variable to the partition number using the partition name\n"
" part must be specified as partition name"
" part must be specified as partition name\n"
"part types\n"
" - list supported partition table types"
);
......@@ -46,6 +46,7 @@
#include <lzma/LzmaTypes.h>
#include <lzma/LzmaDec.h>
#include <lzma/LzmaTools.h>
#include <linux/zstd.h>
#ifdef CONFIG_CMD_BDI
extern int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc,
......@@ -198,6 +199,7 @@ static const table_entry_t uimage_comp[] = {
{ IH_COMP_LZMA, "lzma", "lzma compressed", },
{ IH_COMP_LZO, "lzo", "lzo compressed", },
{ IH_COMP_LZ4, "lz4", "lz4 compressed", },
{ IH_COMP_ZSTD, "zstd", "zstd compressed", },
{ -1, "", "", },
};
......@@ -508,6 +510,56 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
break;
}
#endif /* CONFIG_LZ4 */
#ifdef CONFIG_ZSTD
case IH_COMP_ZSTD: {
size_t size = unc_len;
ZSTD_DStream *dstream;
ZSTD_inBuffer in_buf;
ZSTD_outBuffer out_buf;
void *workspace;
size_t wsize;
wsize = ZSTD_DStreamWorkspaceBound(image_len);
workspace = malloc(wsize);
if (!workspace) {
debug("%s: cannot allocate workspace of size %zu\n", __func__,
wsize);
return -1;
}
dstream = ZSTD_initDStream(image_len, workspace, wsize);
if (!dstream) {
printf("%s: ZSTD_initDStream failed\n", __func__);
return ZSTD_getErrorCode(ret);
}
in_buf.src = image_buf;
in_buf.pos = 0;
in_buf.size = image_len;
out_buf.dst = load_buf;
out_buf.pos = 0;
out_buf.size = size;
while (1) {
size_t ret;
ret = ZSTD_decompressStream(dstream, &out_buf, &in_buf);
if (ZSTD_isError(ret)) {
printf("%s: ZSTD_decompressStream error %d\n", __func__,
ZSTD_getErrorCode(ret));
return ZSTD_getErrorCode(ret);
}
if (in_buf.pos >= image_len || !ret)
break;
}
image_len = out_buf.pos;
break;
}
#endif /* CONFIG_ZSTD */
default:
printf("Unimplemented compression type %d\n", comp);
return -ENOSYS;
......
......@@ -10,3 +10,7 @@ CONFIG_BOOTARGS="console=ttyOWL3,115200n8"
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_SYS_PROMPT="U-Boot => "
CONFIG_DEFAULT_DEVICE_TREE="s700-cubieboard7"
CONFIG_ETH_DESIGNWARE_S700=y
CONFIG_ETH_DESIGNWARE=y
CONFIG_PHY_REALTEK=y
CONFIG_RTL8201F_PHY_S700_RMII_TIMINGS=y
......@@ -29,9 +29,15 @@ CONFIG_CMD_USB=y
CONFIG_CMD_CACHE=y
# CONFIG_CMD_MISC is not set
CONFIG_CMD_UBI=y
# CONFIG_ISO_PARTITION is not set
# CONFIG_EFI_PARTITION is not set
CONFIG_OF_BOARD=y
CONFIG_PCI=y
CONFIG_DM_PCI=y
CONFIG_PCIE_ECAM_GENERIC=y
CONFIG_DM_PCI_COMPAT=y
CONFIG_CMD_PCI=y
CONFIG_LIBATA=y
CONFIG_SATA_SIL=y
CONFIG_CMD_SATA=y
CONFIG_ENV_IS_IN_FLASH=y
CONFIG_ENV_ADDR=0xBFC0000
# CONFIG_MMC is not set
......
......@@ -27,7 +27,11 @@
#include "sata_sil.h"
#ifdef CONFIG_DM_PCI
#define virt_to_bus(devno, v) dm_pci_virt_to_mem(devno, (void *) (v))
#else
#define virt_to_bus(devno, v) pci_virt_to_mem(devno, (void *) (v))
#endif
/* just compatible ahci_ops */
struct sil_ops {
......@@ -608,13 +612,18 @@ static int sil_init_sata(struct udevice *uc_dev, int dev)
/* Save the private struct to block device struct */
#if !CONFIG_IS_ENABLED(BLK)
sata_dev_desc[dev].priv = (void *)sata;
sata->devno = sata_info.devno;
#else
priv->sil_sata_desc[dev] = sata;
priv->port_num = dev;
#ifdef CONFIG_DM_PCI
sata->devno = uc_dev->parent;
#else
sata->devno = sata_info.devno;
#endif /* CONFIG_DM_PCI */
#endif
sata->id = dev;
sata->port = port;
sata->devno = sata_info.devno;
sprintf(sata->name, "SATA#%d", dev);
sil_cmd_soft_reset(sata);
tmp = readl(port + PORT_SSTATUS);
......
......@@ -21,7 +21,11 @@ struct sil_sata {
u16 pio;
u16 mwdma;
u16 udma;
pci_dev_t devno;
#ifdef CONFIG_DM_PCI
struct udevice *devno;
#else
pci_dev_t devno;
#endif
int wcache;
int flush;
int flush_ext;
......
......@@ -87,6 +87,11 @@ int owl_clk_enable(struct clk *clk)
/* Enable UART3 interface clock */
setbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_UART3);
break;
case CLK_RMII_REF:
case CLK_ETHERNET:
setbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_ETH);
setbits_le32(priv->base + CMU_ETHERNETPLL, 5);
break;
default:
return -EINVAL;
}
......@@ -112,6 +117,10 @@ int owl_clk_disable(struct clk *clk)
/* Disable UART3 interface clock */
clrbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_UART3);
break;
case CLK_RMII_REF:
case CLK_ETHERNET:
clrbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_ETH);
break;
default:
return -EINVAL;
}
......
......@@ -62,6 +62,4 @@ struct owl_clk_priv {
#define CMU_DEVCLKEN1_UART5 BIT(21)
#define CMU_DEVCLKEN1_UART3 BIT(11)
#define CMU_DEVCLKEN1_ETH_S700 BIT(23)
#endif
......@@ -97,7 +97,7 @@ void dm_dump_uclass(void)
}
}
void dm_dump_drivers(void)
void dm_dump_driver_compat(void)
{
struct driver *d = ll_entry_start(struct driver, driver);
const int n_ents = ll_entry_count(struct driver, driver);
......@@ -120,3 +120,56 @@ void dm_dump_drivers(void)
printf("%-20.20s %s\n", "", match->compatible);
}
}
void dm_dump_drivers(void)
{
struct driver *d = ll_entry_start(struct driver, driver);
const int n_ents = ll_entry_count(struct driver, driver);
struct driver *entry;
struct udevice *udev;
struct uclass *uc;
int i;
puts("Driver uid uclass Devices\n");
puts("----------------------------------------------------------\n");
for (entry = d; entry < d + n_ents; entry++) {
uclass_get(entry->id, &uc);
printf("%-25.25s %-3.3d %-20.20s ", entry->name, entry->id,
uc ? uc->uc_drv->name : "<no uclass>");
if (!uc) {
puts("\n");
continue;
}
i = 0;
uclass_foreach_dev(udev, uc) {
if (udev->driver != entry)
continue;
if (i)
printf("%-51.51s", "");
printf("%-25.25s\n", udev->name);
i++;
}
if (!i)
puts("<none>\n");
}
}
void dm_dump_static_driver_info(void)
{
struct driver_info *drv = ll_entry_start(struct driver_info,
driver_info);
const int n_ents = ll_entry_count(struct driver_info, driver_info);
struct driver_info *entry;
puts("Driver Address\n");
puts("---------------------------------\n");
for (entry = drv; entry != drv + n_ents; entry++) {
printf("%-25.25s @%08lx\n", entry->name,
(ulong)map_to_sysmem(entry->platdata));
}
}
......@@ -46,6 +46,26 @@ config GPIO_HOG
is a mechanism providing automatic GPIO request and config-
uration as part of the gpio-controller's driver probe function.
config DM_GPIO_LOOKUP_LABEL
bool "Enable searching for gpio labelnames"
depends on DM_GPIO
help
This option enables searching for gpio names in
the defined gpio labels, if the search for the
gpio bank name failed. This makes sense if you use
different gpios on different hardware versions
for the same functionality in board code.
config SPL_DM_GPIO_LOOKUP_LABEL
bool "Enable searching for gpio labelnames"
depends on DM_GPIO && SPL_DM && SPL_GPIO_SUPPORT
help
This option enables searching for gpio names in
the defined gpio labels, if the search for the
gpio bank name failed. This makes sense if you use
different gpios on different hardware versions
for the same functionality in board code.
config ALTERA_PIO
bool "Altera PIO driver"
depends on DM_GPIO
......
......@@ -68,6 +68,45 @@ static int gpio_to_device(unsigned int gpio, struct gpio_desc *desc)
return ret ? ret : -ENOENT;
}
#if CONFIG_IS_ENABLED(DM_GPIO_LOOKUP_LABEL)
/**
* dm_gpio_lookup_label() - look for name in gpio device
*
* search in uc_priv, if there is a gpio with labelname same
* as name.
*
* @name: name which is searched
* @uc_priv: gpio_dev_priv pointer.
* @offset: gpio offset within the device
* @return: 0 if found, -ENOENT if not.
*/
static int dm_gpio_lookup_label(const char *name,
struct gpio_dev_priv *uc_priv, ulong *offset)
{
int len;
int i;
*offset = -1;
len = strlen(name);
for (i = 0; i < uc_priv->gpio_count; i++) {
if (!uc_priv->name[i])
continue;
if (!strncmp(name, uc_priv->name[i], len)) {
*offset = i;
return 0;
}
}
return -ENOENT;
}
#else
static int
dm_gpio_lookup_label(const char *name, struct gpio_dev_priv *uc_priv,
ulong *offset)
{
return -ENOENT;
}
#endif
int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc)
{
struct gpio_dev_priv *uc_priv = NULL;
......@@ -96,6 +135,13 @@ int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc)
if (!strict_strtoul(name + len, 10, &offset))
break;
}
/*
* if we did not found a gpio through its bank
* name, we search for a valid gpio label.
*/
if (!dm_gpio_lookup_label(name, uc_priv, &offset))
break;
}
if (!dev)
......
......@@ -238,6 +238,13 @@ config ETH_DESIGNWARE_SOCFPGA
Altera system manager to correctly interface with the PHY.
This code handles those SoC specifics.
config ETH_DESIGNWARE_S700
bool "Actins S700 glue driver for Synopsys Designware Ethernet MAC"
depends on DM_ETH && ETH_DESIGNWARE
help
This provides glue layer to use Synopsys Designware Ethernet MAC
present on Actions S700 SoC.
config ETHOC
bool "OpenCores 10/100 Mbps Ethernet MAC"
help
......
......@@ -18,6 +18,7 @@ obj-$(CONFIG_CS8900) += cs8900.o
obj-$(CONFIG_TULIP) += dc2114x.o
obj-$(CONFIG_ETH_DESIGNWARE) += designware.o
obj-$(CONFIG_ETH_DESIGNWARE_SOCFPGA) += dwmac_socfpga.o
obj-$(CONFIG_ETH_DESIGNWARE_S700) += dwmac_s700.o
obj-$(CONFIG_DRIVER_DM9000) += dm9000x.o
obj-$(CONFIG_DNET) += dnet.o
obj-$(CONFIG_DM_ETH_PHY) += eth-phy-uclass.o
......
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2020 Amit Singh Tomar <amittomer25@gmail.com>
*
* Actions DWMAC specific glue layer
*/
#include <common.h>
#include <asm/io.h>
#include <dm.h>
#include <clk.h>
#include <phy.h>
#include <regmap.h>
#include <reset.h>
#include <syscon.h>
#include "designware.h"
#include <asm/arch-owl/regs_s700.h>
#include <linux/bitops.h>
/* pin control for MAC */
#define RMII_TXD01_MFP_CTL0 (0x0 << 16)
#define RMII_RXD01_MFP_CTL0 (0x0 << 8)
#define RMII_TXEN_TXER_MFP_CTL0 (0x0 << 13)
#define RMII_REF_CLK_MFP_CTL0 (0x0 << 6)
#define CLKO_25M_EN_MFP_CTL3 BIT(30)
DECLARE_GLOBAL_DATA_PTR;
static void dwmac_board_setup(void)
{
clrbits_le32(MFP_CTL0, (RMII_TXD01_MFP_CTL0 | RMII_RXD01_MFP_CTL0 |
RMII_TXEN_TXER_MFP_CTL0 | RMII_REF_CLK_MFP_CTL0));
setbits_le32(MFP_CTL3, CLKO_25M_EN_MFP_CTL3);
}
static int dwmac_s700_probe(struct udevice *dev)
{
dwmac_board_setup();
/* This is undocumented, phy interface select register */
writel(0x4, 0xe024c0a0);
return designware_eth_probe(dev);
}
static int dwmac_s700_ofdata_to_platdata(struct udevice *dev)
{
return designware_eth_ofdata_to_platdata(dev);
}
static const struct udevice_id dwmac_s700_ids[] = {
{.compatible = "actions,s700-ethernet"},
{ }
};
U_BOOT_DRIVER(dwmac_s700) = {
.name = "dwmac_s700",
.id = UCLASS_ETH,
.of_match = dwmac_s700_ids,
.ofdata_to_platdata = dwmac_s700_ofdata_to_platdata,
.probe = dwmac_s700_probe,
.ops = &designware_eth_ops,
.priv_auto_alloc_size = sizeof(struct dw_eth_dev),
.platdata_auto_alloc_size = sizeof(struct eth_pdata),
.flags = DM_FLAG_ALLOC_PRIV_DMA,
};
......@@ -235,6 +235,15 @@ config RTL8211F_PHY_FORCE_EEE_RXC_ON
Default n, which means that the PHY state is not changed. To work
around the issues, change this setting to y.
config RTL8201F_PHY_S700_RMII_TIMINGS
bool "Ethernet PHY RTL8201F: adjust RMII Tx Interface timings"
depends on PHY_REALTEK
help
This provides an option to configure specific timing requirements (needed
for proper PHY operations) for the PHY module present on ACTION SEMI S700
based cubieboard7. Exact timing requiremnets seems to be SoC specific
(and it's undocumented) that comes from vendor code itself.
config PHY_SMSC
bool "Microchip(SMSC) Ethernet PHYs support"
......
......@@ -14,6 +14,7 @@
#define PHY_RTL8211x_FORCE_MASTER BIT(1)
#define PHY_RTL8211E_PINE64_GIGABIT_FIX BIT(2)
#define PHY_RTL8211F_FORCE_EEE_RXC_ON BIT(3)
#define PHY_RTL8201F_S700_RMII_TIMINGS BIT(4)
#define PHY_AUTONEGOTIATE_TIMEOUT 5000
......@@ -60,6 +61,15 @@
#define MIIM_RTL8211F_RX_DELAY 0x8
#define MIIM_RTL8211F_LCR 0x10
#define RTL8201F_RMSR 0x10
#define RMSR_RX_TIMING_SHIFT BIT(2)
#define RMSR_RX_TIMING_MASK GENMASK(7, 4)
#define RMSR_RX_TIMING_VAL 0x4
#define RMSR_TX_TIMING_SHIFT BIT(3)
#define RMSR_TX_TIMING_MASK GENMASK(11, 8)
#define RMSR_TX_TIMING_VAL 0x5
static int rtl8211f_phy_extread(struct phy_device *phydev, int addr,
int devaddr, int regnum)
{
......@@ -114,6 +124,15 @@ static int rtl8211f_probe(struct phy_device *phydev)
return 0;
}
static int rtl8210f_probe(struct phy_device *phydev)
{
#ifdef CONFIG_RTL8201F_PHY_S700_RMII_TIMINGS
phydev->flags |= PHY_RTL8201F_S700_RMII_TIMINGS;
#endif
return 0;
}
/* RealTek RTL8211x */
static int rtl8211x_config(struct phy_device *phydev)
{
......@@ -159,6 +178,29 @@ static int rtl8211x_config(struct phy_device *phydev)
return 0;
}
/* RealTek RTL8201F */
static int rtl8201f_config(struct phy_device *phydev)
{
unsigned int reg;
if (phydev->flags & PHY_RTL8201F_S700_RMII_TIMINGS) {
phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT,
7);
reg = phy_read(phydev, MDIO_DEVAD_NONE, RTL8201F_RMSR);
reg &= ~(RMSR_RX_TIMING_MASK | RMSR_TX_TIMING_MASK);
/* Set the needed Rx/Tx Timings for proper PHY operation */
reg |= (RMSR_RX_TIMING_VAL << RMSR_RX_TIMING_SHIFT)
| (RMSR_TX_TIMING_VAL << RMSR_TX_TIMING_SHIFT);
phy_write(phydev, MDIO_DEVAD_NONE, RTL8201F_RMSR, reg);
phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT,
0);
}
genphy_config_aneg(phydev);
return 0;
}
static int rtl8211f_config(struct phy_device *phydev)
{
u16 reg;
......@@ -398,12 +440,25 @@ static struct phy_driver RTL8211F_driver = {
.writeext = &rtl8211f_phy_extwrite,
};
/* Support for RTL8201F PHY */
static struct phy_driver RTL8201F_driver = {
.name = "RealTek RTL8201F 10/100Mbps Ethernet",
.uid = 0x1cc816,
.mask = 0xffffff,
.features = PHY_BASIC_FEATURES,
.probe = &rtl8210f_probe,
.config = &rtl8201f_config,
.startup = &rtl8211e_startup,
.shutdown = &genphy_shutdown,
};
int phy_realtek_init(void)
{
phy_register(&RTL8211B_driver);
phy_register(&RTL8211E_driver);
phy_register(&RTL8211F_driver);
phy_register(&RTL8211DN_driver);
phy_register(&RTL8201F_driver);
return 0;
}
......@@ -187,6 +187,26 @@ static void smc911x_handle_mac_address(struct smc911x_priv *priv)
printf(DRIVERNAME ": MAC %pM\n", m);
}
static bool smc911x_read_mac_address(struct smc911x_priv *priv)
{
u32 addrh, addrl;
/* address is obtained from optional eeprom */
addrh = smc911x_get_mac_csr(priv, ADDRH);
addrl = smc911x_get_mac_csr(priv, ADDRL);
if (addrl == 0xffffffff && addrh == 0x0000ffff)
return false;
priv->enetaddr[0] = addrl;
priv->enetaddr[1] = addrl >> 8;
priv->enetaddr[2] = addrl >> 16;
priv->enetaddr[3] = addrl >> 24;
priv->enetaddr[4] = addrh;
priv->enetaddr[5] = addrh >> 8;
return true;
}
static int smc911x_eth_phy_read(struct smc911x_priv *priv,
u8 phy, u8 reg, u16 *val)
{
......@@ -471,7 +491,6 @@ static int smc911x_recv(struct eth_device *dev)
int smc911x_initialize(u8 dev_num, int base_addr)
{
unsigned long addrl, addrh;
struct smc911x_priv *priv;
int ret;
......@@ -489,18 +508,8 @@ int smc911x_initialize(u8 dev_num, int base_addr)
goto err_detect;
}
addrh = smc911x_get_mac_csr(priv, ADDRH);
addrl = smc911x_get_mac_csr(priv, ADDRL);
if (!(addrl == 0xffffffff && addrh == 0x0000ffff)) {
/* address is obtained from optional eeprom */
priv->enetaddr[0] = addrl;
priv->enetaddr[1] = addrl >> 8;
priv->enetaddr[2] = addrl >> 16;
priv->enetaddr[3] = addrl >> 24;
priv->enetaddr[4] = addrh;
priv->enetaddr[5] = addrh >> 8;
if (smc911x_read_mac_address(priv))
memcpy(priv->dev.enetaddr, priv->enetaddr, 6);
}
priv->dev.init = smc911x_init;
priv->dev.halt = smc911x_halt;
......@@ -565,6 +574,19 @@ static int smc911x_recv(struct udevice *dev, int flags, uchar **packetp)
return ret ? ret : -EAGAIN;
}
static int smc911x_read_rom_hwaddr(struct udevice *dev)
{
struct smc911x_priv *priv = dev_get_priv(dev);
struct eth_pdata *pdata = dev_get_platdata(dev);
if (!smc911x_read_mac_address(priv))
return -ENODEV;
memcpy(pdata->enetaddr, priv->enetaddr, sizeof(pdata->enetaddr));
return 0;
}
static int smc911x_bind(struct udevice *dev)
{
return device_set_name(dev, dev->name);
......@@ -573,7 +595,6 @@ static int smc911x_bind(struct udevice *dev)
static int smc911x_probe(struct udevice *dev)
{
struct smc911x_priv *priv = dev_get_priv(dev);
unsigned long addrh, addrl;
int ret;
/* Try to detect chip. Will fail if not present. */
......@@ -581,17 +602,7 @@ static int smc911x_probe(struct udevice *dev)
if (ret)
return ret;
addrh = smc911x_get_mac_csr(priv, ADDRH);
addrl = smc911x_get_mac_csr(priv, ADDRL);
if (!(addrl == 0xffffffff && addrh == 0x0000ffff)) {
/* address is obtained from optional eeprom */
priv->enetaddr[0] = addrl;
priv->enetaddr[1] = addrl >> 8;
priv->enetaddr[2] = addrl >> 16;
priv->enetaddr[3] = addrl >> 24;
priv->enetaddr[4] = addrh;
priv->enetaddr[5] = addrh >> 8;
}
smc911x_read_rom_hwaddr(dev);
return 0;
}
......@@ -612,6 +623,7 @@ static const struct eth_ops smc911x_ops = {
.send = smc911x_send,
.recv = smc911x_recv,
.stop = smc911x_stop,
.read_rom_hwaddr = smc911x_read_rom_hwaddr,
};
static const struct udevice_id smc911x_ids[] = {
......
......@@ -50,8 +50,11 @@ static int disk_write(__u32 block, __u32 nr_blocks, void *buf)
return ret;
}
/*
* Set short name in directory entry
/**
* set_name() - set short name in directory entry
*
* @dirent: directory entry
* @filename: long file name
*/
static void set_name(dir_entry *dirent, const char *filename)
{
......@@ -66,7 +69,8 @@ static void set_name(dir_entry *dirent, const char *filename)
if (len == 0)
return;
strcpy(s_name, filename);
strncpy(s_name, filename, VFAT_MAXLEN_BYTES - 1);
s_name[VFAT_MAXLEN_BYTES - 1] = '\0';
uppercase(s_name, len);
period = strchr(s_name, '.');
......@@ -87,6 +91,11 @@ static void set_name(dir_entry *dirent, const char *filename)
memcpy(dirent->name, s_name, period_location);
} else {
memcpy(dirent->name, s_name, 6);
/*
* TODO: Translating two long names with the same first six
* characters to the same short name is utterly wrong.
* Short names must be unique.
*/
dirent->name[6] = '~';
dirent->name[7] = '1';
}
......
......@@ -903,3 +903,23 @@ int do_ln(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
return 0;
}
int do_fs_types(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
{
struct fstype_info *drv = fstypes;
const int n_ents = ARRAY_SIZE(fstypes);
struct fstype_info *entry;
int i = 0;
puts("Supported filesystems");
for (entry = drv; entry != drv + n_ents; entry++) {
if (entry->fstype != FS_TYPE_ANY) {
printf("%c %s", i ? ',' : ':', entry->name);
i++;
}
}
if (!i)
puts(": <none>");
puts("\n");
return CMD_RET_SUCCESS;
}
......@@ -12,7 +12,6 @@
/* SDRAM Definitions */
#define CONFIG_SYS_SDRAM_BASE 0x0
#define CONFIG_SYS_SDRAM_SIZE 0x80000000
/* Generic Timer Definitions */
#define COUNTER_FREQUENCY (24000000) /* 24MHz */
......
......@@ -68,7 +68,7 @@
#define V2M_SYS_CFGSTAT (V2M_SYSREGS + 0x0a8)
/* Generic Timer Definitions */
#define COUNTER_FREQUENCY (0x1800000) /* 24MHz */
#define COUNTER_FREQUENCY 24000000 /* 24MHz */
/* Generic Interrupt Controller Definitions */
#ifdef CONFIG_GICV3
......
......@@ -42,4 +42,10 @@ static inline void dm_dump_devres(void)
/* Dump out a list of drivers */
void dm_dump_drivers(void);
/* Dump out a list with each driver's compatibility strings */
void dm_dump_driver_compat(void);
/* Dump out a list of drivers with static platform data */
void dm_dump_static_driver_info(void);
#endif
......@@ -259,4 +259,15 @@ int do_fs_uuid(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
*/
int do_fs_type(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
/**
* do_fs_types - List supported filesystems.
*
* @cmdtp: Command information for fstypes
* @flag: Command flags (CMD_FLAG_...)
* @argc: Number of arguments
* @argv: List of arguments
* @return result (see enum command_ret_t)
*/
int do_fs_types(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
#endif /* _FS_H */
......@@ -326,6 +326,7 @@ enum {
IH_COMP_LZMA, /* lzma Compression Used */
IH_COMP_LZO, /* lzo Compression Used */
IH_COMP_LZ4, /* lz4 Compression Used */
IH_COMP_ZSTD, /* zstd Compression Used */
IH_COMP_COUNT,
};
......
......@@ -57,12 +57,12 @@ static inline uintptr_t __attribute__((no_instrument_function))
return offset / FUNC_SITE_SIZE;
}
#ifdef CONFIG_EFI_LOADER
#if defined(CONFIG_EFI_LOADER) && defined(CONFIG_ARM)
/**
* trace_gd - the value of the gd register
*/
static volatile void *trace_gd;
static volatile gd_t *trace_gd;
/**
* trace_save_gd() - save the value of the gd register
......@@ -82,10 +82,10 @@ static void __attribute__((no_instrument_function)) trace_save_gd(void)
*/
static void __attribute__((no_instrument_function)) trace_swap_gd(void)
{
volatile void *temp_gd = trace_gd;
volatile gd_t *temp_gd = trace_gd;
trace_gd = gd;
gd = temp_gd;
set_gd(temp_gd);
}
#else
......
......@@ -560,8 +560,6 @@ static int eth_post_probe(struct udevice *dev)
memcpy(pdata->enetaddr, env_enetaddr, ARP_HLEN);
} else if (is_valid_ethaddr(pdata->enetaddr)) {
eth_env_set_enetaddr_by_index("eth", dev->seq, pdata->enetaddr);
printf("\nWarning: %s using MAC address from %s\n",
dev->name, source);
} else if (is_zero_ethaddr(pdata->enetaddr) ||
!is_valid_ethaddr(pdata->enetaddr)) {
#ifdef CONFIG_NET_RANDOM_ETHADDR
......
......@@ -132,6 +132,15 @@ static int dm_test_gpio(struct unit_test_state *uts)
ut_assertok(dm_gpio_set_value(desc, 0));
ut_asserteq(0, dm_gpio_get_value(desc));
/* Check if lookup for labels work */
ut_assertok(gpio_lookup_name("hog_input_active_low", &dev, &offset,
&gpio));
ut_asserteq_str(dev->name, "base-gpios");
ut_asserteq(0, offset);
ut_asserteq(CONFIG_SANDBOX_GPIO_COUNT + 0, gpio);
ut_assert(gpio_lookup_name("hog_not_exist", &dev, &offset,
&gpio));
return 0;
}
DM_TEST(dm_test_gpio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
......
......@@ -4,14 +4,32 @@
import pytest
@pytest.mark.buildconfigspec('cmd_dm')
def test_dm_drivers(u_boot_console):
"""Test that each driver in `dm tree` is also listed in `dm drivers`."""
def test_dm_compat(u_boot_console):
"""Test that each driver in `dm tree` is also listed in `dm compat`."""
response = u_boot_console.run_command('dm tree')
driver_index = response.find('Driver')
assert driver_index != -1
drivers = (line[driver_index:].split()[0]
for line in response[:-1].split('\n')[2:])
response = u_boot_console.run_command('dm compat')
for driver in drivers:
assert driver in response
@pytest.mark.buildconfigspec('cmd_dm')
def test_dm_drivers(u_boot_console):
"""Test that each driver in `dm compat` is also listed in `dm drivers`."""
response = u_boot_console.run_command('dm compat')
drivers = (line[:20].rstrip() for line in response[:-1].split('\n')[2:])
response = u_boot_console.run_command('dm drivers')
for driver in drivers:
assert driver in response
@pytest.mark.buildconfigspec('cmd_dm')
def test_dm_static(u_boot_console):
"""Test that each driver in `dm static` is also listed in `dm drivers`."""
response = u_boot_console.run_command('dm static')
drivers = (line[:25].rstrip() for line in response[:-1].split('\n')[2:])
response = u_boot_console.run_command('dm drivers')
for driver in drivers:
assert driver in response
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2020
# Niel Fourie, DENX Software Engineering, lusus@denx.de
import pytest
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_fs_generic')
def test_dm_compat(u_boot_console):
"""Test that `fstypes` prints a result which includes `sandbox`."""
output = u_boot_console.run_command('fstypes')
assert "Supported filesystems:" in output
assert "sandbox" in output
# SPDX-License-Identifier: GPL-2.0+
# Copyright (C) 2020
# Niel Fourie, DENX Software Engineering, lusus@denx.de
import pytest
@pytest.mark.buildconfigspec('blk')
@pytest.mark.buildconfigspec('cmd_lsblk')
def test_lsblk(u_boot_console):
"""Test that `lsblk` prints a result which includes `host`."""
output = u_boot_console.run_command('lsblk')
assert "Block Driver" in output
assert "sandbox_host_blk" in output
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2020
# Niel Fourie, DENX Software Engineering, lusus@denx.de
import pytest
@pytest.mark.buildconfigspec('cmd_part')
@pytest.mark.buildconfigspec('partitions')
@pytest.mark.buildconfigspec('efi_partition')
def test_dm_compat(u_boot_console):
"""Test that `part types` prints a result which includes `EFI`."""
output = u_boot_console.run_command('part types')
assert "Supported partition tables:" in output
assert "EFI" in output
......@@ -11,6 +11,12 @@ change test behavior.
# Setup env__sleep_accurate to False if time is not accurate on your platform
env__sleep_accurate = False
# Setup env__sleep_time time in seconds board is set to sleep
env__sleep_time = 3
# Setup env__sleep_margin set a margin for any system overhead
env__sleep_margin = 0.25
"""
def test_sleep(u_boot_console):
......@@ -23,13 +29,15 @@ def test_sleep(u_boot_console):
if u_boot_console.config.buildconfig.get('config_cmd_misc', 'n') != 'y':
pytest.skip('sleep command not supported')
# 3s isn't too long, but is enough to cross a few second boundaries.
sleep_time = 3
sleep_time = u_boot_console.config.env.get('env__sleep_time', 3)
sleep_margin = u_boot_console.config.env.get('env__sleep_margin', 0.25)
tstart = time.time()
u_boot_console.run_command('sleep %d' % sleep_time)
tend = time.time()
elapsed = tend - tstart
assert elapsed >= (sleep_time - 0.01)
if not u_boot_console.config.gdbserver:
# 0.25s margin is hopefully enough to account for any system overhead.
assert elapsed < (sleep_time + 0.25)
# margin is hopefully enough to account for any system overhead.
assert elapsed < (sleep_time + sleep_margin)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册