Commit eafcaf8a authored by Tom Rini's avatar Tom Rini
Browse files

Merge branch '2021-09-09-finish-pre-DM_PCI-removal'

- Finish removing the non-DM_PCI legacy code.
parents 7958292f 3232bdf0
......@@ -2776,9 +2776,6 @@ Low Level (hardware related) configuration options:
CONFIG_SYS_OR3_PRELIM, CONFIG_SYS_BR3_PRELIM:
Memory Controller Definitions: BR2/3 and OR2/3 (SDRAM)
- CONFIG_PCI_INDIRECT_BRIDGE:
Enable support for indirect PCI bridges.
- CONFIG_SYS_SRIO:
Chip has SRIO or not
......
......@@ -182,7 +182,6 @@ config X86
select SUPPORT_TPL
select CREATE_ARCH_SYMLINK
select DM
select DM_PCI
select HAVE_ARCH_IOMAP
select HAVE_PRIVATE_LIBGCC
select OF_CONTROL
......
......@@ -1681,7 +1681,7 @@ config TARGET_SL28
select DM_SPI_FLASH
select DM_ETH
select DM_MDIO
select DM_PCI
select PCI
select DM_RNG
select DM_RTC
select DM_SCSI
......
......@@ -237,7 +237,7 @@ config TARGET_KOSAGI_NOVENA
select DM_ETH
select DM_GPIO
select DM_MMC
select DM_PCI
select PCI
select DM_SCSI
select DM_VIDEO
select OF_CONTROL
......
......@@ -17,7 +17,7 @@ config TARGET_MALTA
select BOARD_EARLY_INIT_R
select DM
select DM_SERIAL
select DM_PCI
select PCI
select DM_ETH
select DYNAMIC_IO_PORT_BASE
select MIPS_CM
......
......@@ -178,12 +178,6 @@ config TARGET_KMCENT2
bool "Support kmcent2"
select VENDOR_KM
config TARGET_UCP1020
bool "Support uCP1020"
select ARCH_P1020
imply CMD_SATA
imply PANIC_HANG
endchoice
config ARCH_B4420
......@@ -1147,6 +1141,5 @@ source "board/freescale/t208xrdb/Kconfig"
source "board/freescale/t4rdb/Kconfig"
source "board/keymile/Kconfig"
source "board/socrates/Kconfig"
source "board/Arcturus/ucp1020/Kconfig"
endmenu
if TARGET_UCP1020
config SYS_BOARD
string
default "ucp1020"
config SYS_VENDOR
string
default "Arcturus"
config SYS_CONFIG_NAME
string
default "UCP1020"
choice
prompt "Target image select"
config TARGET_UCP1020_NOR
bool "NOR flash u-boot image"
config TARGET_UCP1020_SPIFLASH
bool "SPI flash u-boot image"
endchoice
if TARGET_UCP1020_SPIFLASH
config UCBOOT
bool
default y
config SPIFLASH
bool
default y
endif
endif
UCP1020 BOARD
M: Oleksandr Zhadan and Michael Durrant <arcsupport@arcturusnetworks.com>
S: Maintained
F: board/Arcturus/ucp1020/
F: include/configs/UCP1020.h
F: configs/UCP1020_defconfig
F: configs/UCP1020_SPIFLASH_defconfig
# SPDX-License-Identifier: GPL-2.0+
#
# Copyright 2013-2015 Arcturus Networks, Inc.
# based on board/freescale/p1_p2_rdb_pc/Makefile
# original copyright follows:
# Copyright 2010-2011 Freescale Semiconductor, Inc.
MINIMAL=
ifdef CONFIG_SPL_BUILD
ifdef CONFIG_SPL_INIT_MINIMAL
MINIMAL=y
endif
endif
ifdef MINIMAL
obj-y += spl_minimal.o tlb.o law.o
else
ifdef CONFIG_SPL_BUILD
obj-y += spl.o
endif
obj-y += ucp1020.o
obj-y += ddr.o
obj-y += law.o
obj-y += tlb.o
obj-y += cmd_arc.o
endif
The uCP1020 product family (ucp1020) is an Arcturus Networks Inc. System on Modules
product featuring a Freescale P1020 CPU, optionally populated with 1, 2 or 3 Gig-Ethernet PHYs,
DDR3, NOR Flash, eMMC NAND Flash and/or SPI Flash.
Information on the generic product family can be found here:
http://www.arcturusnetworks.com/products/ucp1020
The UCP1020 several configurable options
========================================
- the selection of populated phy(s):
KSZ9031 (current default for eTSEC 1 and 3)
- the selection of boot location:
SPI Flash or NOR flash
The UCP1020 includes 2 default configurations
=============================================
NOR boot image:
configs/UCP1020_defconfig
SPI boot image:
configs/UCP1020_SPIFLASH_defconfig
The UCP1020 adds an additional command in cmd_arc.c to access and program
SPI resident factory defaults for serial number, and 1, 2 or 3 Ethernet
HW Addresses.
Build example
=============
make distclean
make UCP1020_defconfig
make
Default Scripts
===============
A default upgrade scripts is included in the default environment variable example:
B$ run tftpflash
Dual Environment
================
This build enables dual / failover environment environment.
NOR Flash Partition declarations and scripts
============================================
Several scripts are available to allow TFTP of images and programming directly
into defined NOR flash partitions. Examples:
B$ run program0
B$ run program1
B$ run program2
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
/*
* Command for accessing Arcturus factory environment.
*
* Copyright 2013-2019 Arcturus Networks Inc.
* https://www.arcturusnetworks.com/products/
* by Oleksandr G Zhadan et al.
*
*/
#include <common.h>
#include <command.h>
#include <cpu_func.h>
#include <div64.h>
#include <env.h>
#include <flash.h>
#include <malloc.h>
#include <spi_flash.h>
#include <mmc.h>
#include <version.h>
#include <asm/io.h>
#include <linux/stringify.h>
static ulong fwenv_addr[MAX_FWENV_ADDR];
const char mystrerr[] = "ERROR: Failed to save factory info";
static int ishwaddr(char *hwaddr)
{
if (strlen(hwaddr) == MAX_HWADDR_SIZE)
if (hwaddr[2] == ':' &&
hwaddr[5] == ':' &&
hwaddr[8] == ':' &&
hwaddr[11] == ':' &&
hwaddr[14] == ':')
return 0;
return -1;
}
#if (FWENV_TYPE == FWENV_MMC)
static char smac[29][18] __attribute__ ((aligned(0x200))); /* 1 MMC block is 512 bytes */
int set_mmc_arc_product(int argc, char *const argv[])
{
struct mmc *mmc;
u32 blk, cnt, n;
int i, err = 1;
void *addr;
const u8 mmc_dev_num = CONFIG_SYS_MMC_ENV_DEV;
mmc = find_mmc_device(mmc_dev_num);
if (!mmc) {
printf("No SD/MMC/eMMC card found\n");
return 0;
}
if (mmc_init(mmc)) {
printf("%s(%d) init failed\n", IS_SD(mmc) ? "SD" : "MMC",
mmc_dev_num);
return 0;
}
if (mmc_getwp(mmc) == 1) {
printf("Error: card is write protected!\n");
return CMD_RET_FAILURE;
}
/* Save factory defaults */
addr = (void *)smac;
cnt = 1; /* One 512 bytes block */
for (i = 0; i < MAX_FWENV_ADDR; i++)
if (fwenv_addr[i] != -1) {
blk = fwenv_addr[i] / 512;
n = blk_dwrite(mmc_get_blk_desc(mmc), blk, cnt, addr);
if (n != cnt)
printf("%s: %s [%d]\n", __func__, mystrerr, i);
else
err = 0;
}
if (err)
return -2;
return err;
}
static int read_mmc_arc_info(void)
{
struct mmc *mmc;
u32 blk, cnt, n;
int i;
void *addr;
const u8 mmc_dev_num = CONFIG_SYS_MMC_ENV_DEV;
mmc = find_mmc_device(mmc_dev_num);
if (!mmc) {
printf("No SD/MMC/eMMC card found\n");
return 0;
}
if (mmc_init(mmc)) {
printf("%s(%d) init failed\n", IS_SD(mmc) ? "SD" : "MMC",
mmc_dev_num);
return 0;
}
addr = (void *)smac;
cnt = 1; /* One 512 bytes block */
for (i = 0; i < MAX_FWENV_ADDR; i++)
if (fwenv_addr[i] != -1) {
blk = fwenv_addr[i] / 512;
n = blk_dread(mmc_get_blk_desc(mmc), blk, cnt, addr);
flush_cache((ulong) addr, 512);
if (n == cnt)
return (i + 1);
}
return 0;
}
#endif
#if (FWENV_TYPE == FWENV_SPI_FLASH)
static struct spi_flash *flash;
static char smac[4][18];
int set_spi_arc_product(int argc, char *const argv[])
{
int i, err = 1;
flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
if (!flash) {
printf("Failed to initialize SPI flash at %u:%u\n",
CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS);
return -1;
}
/* Save factory defaults */
for (i = 0; i < MAX_FWENV_ADDR; i++)
if (fwenv_addr[i] != -1)
if (spi_flash_write
(flash, fwenv_addr[i], sizeof(smac), smac))
printf("%s: %s [%d]\n", __func__, mystrerr, i);
else
err = 0;
if (err)
return -2;
return err;
}
static int read_spi_arc_info(void)
{
int i;
flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
if (!flash) {
printf("Failed to initialize SPI flash at %u:%u\n",
CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS);
return 0;
}
for (i = 0; i < MAX_FWENV_ADDR; i++)
if (fwenv_addr[i] != -1)
if (!spi_flash_read
(flash, fwenv_addr[i], sizeof(smac), smac))
return (i + 1);
return 0;
}
#endif
#if (FWENV_TYPE == FWENV_NOR_FLASH)
static char smac[4][18];
int set_nor_arc_product(int argc, char *const argv[])
{
int i, err = 1;
/* Save factory defaults */
for (i = 0; i < MAX_FWENV_ADDR; i++)
if (fwenv_addr[i] != -1) {
ulong fwenv_end = fwenv_addr[i] + 4;
flash_sect_roundb(&fwenv_end);
flash_sect_protect(0, fwenv_addr[i], fwenv_end);
if (flash_write
((char *)smac, fwenv_addr[i], sizeof(smac)))
printf("%s: %s [%d]\n", __func__, mystrerr, i);
else
err = 0;
flash_sect_protect(1, fwenv_addr[i], fwenv_end);
}
if (err)
return -2;
return err;
}
static int read_nor_arc_info(void)
{
int i;
for (i = 0; i < MAX_FWENV_ADDR; i++)
if (fwenv_addr[i] != -1) {
memcpy(smac, (void *)fwenv_addr[i], sizeof(smac));
return (i + 1);
}
return 0;
}
#endif
int set_arc_product(int argc, char *const argv[])
{
if (argc != 5)
return -1;
/* Check serial number */
if (strlen(argv[1]) != MAX_SERIAL_SIZE)
return -1;
/* Check HWaddrs */
if (ishwaddr(argv[2]) || ishwaddr(argv[3]) || ishwaddr(argv[4]))
return -1;
strcpy(smac[0], argv[1]);
strcpy(smac[1], argv[2]);
strcpy(smac[2], argv[3]);
strcpy(smac[3], argv[4]);
#if (FWENV_TYPE == FWENV_NOR_FLASH)
return set_nor_arc_product(argc, argv);
#endif
#if (FWENV_TYPE == FWENV_SPI_FLASH)
return set_spi_arc_product(argc, argv);
#endif
#if (FWENV_TYPE == FWENV_MMC)
return set_mmc_arc_product(argc, argv);
#endif
return -2;
}
static int read_arc_info(void)
{
#if (FWENV_TYPE == FWENV_NOR_FLASH)
return read_nor_arc_info();
#endif
#if (FWENV_TYPE == FWENV_SPI_FLASH)
return read_spi_arc_info();
#endif
#if (FWENV_TYPE == FWENV_MMC)
return read_mmc_arc_info();
#endif
return 0;
}
static int do_get_arc_info(void)
{
int l = read_arc_info();
char *oldserial = env_get("SERIAL");
char *oldversion = env_get("VERSION");
if (oldversion != NULL)
if (strcmp(oldversion, U_BOOT_VERSION) != 0)
oldversion = NULL;
if (l == 0) {
printf("%s: failed to read factory info\n", __func__);
return -2;
}
printf("\rSERIAL: ");
if (smac[0][0] == EMPY_CHAR) {
printf("<not found>\n");
} else {
printf("%s\n", smac[0]);
env_set("SERIAL", smac[0]);
}
if (strcmp(smac[1], "00:00:00:00:00:00") == 0) {
env_set("ethaddr", NULL);
env_set("eth1addr", NULL);
env_set("eth2addr", NULL);
goto done;
}
printf("HWADDR0: ");
if (smac[1][0] == EMPY_CHAR) {
printf("<not found>\n");
} else {
char *ret = env_get("ethaddr");
if (ret == NULL) {
env_set("ethaddr", smac[1]);
printf("%s\n", smac[1]);
} else if (strcmp(ret, __stringify(CONFIG_ETHADDR)) == 0) {
env_set("ethaddr", smac[1]);
printf("%s (factory)\n", smac[1]);
} else {
printf("%s\n", ret);
}
}
if (strcmp(smac[2], "00:00:00:00:00:00") == 0) {
env_set("eth1addr", NULL);
env_set("eth2addr", NULL);
goto done;
}
printf("HWADDR1: ");
if (smac[2][0] == EMPY_CHAR) {
printf("<not found>\n");
} else {
char *ret = env_get("eth1addr");
if (ret == NULL) {
env_set("ethaddr", smac[2]);
printf("%s\n", smac[2]);
} else if (strcmp(ret, __stringify(CONFIG_ETH1ADDR)) == 0) {
env_set("eth1addr", smac[2]);
printf("%s (factory)\n", smac[2]);
} else {
printf("%s\n", ret);
}
}
if (strcmp(smac[3], "00:00:00:00:00:00") == 0) {
env_set("eth2addr", NULL);
goto done;
}
printf("HWADDR2: ");
if (smac[3][0] == EMPY_CHAR) {
printf("<not found>\n");
} else {
char *ret = env_get("eth2addr");
if (ret == NULL) {
env_set("ethaddr", smac[3]);
printf("%s\n", smac[3]);
} else if (strcmp(ret, __stringify(CONFIG_ETH2ADDR)) == 0) {
env_set("eth2addr", smac[3]);
printf("%s (factory)\n", smac[3]);
} else {
printf("%s\n", ret);
}
}
done:
if (oldserial == NULL || oldversion == NULL) {
if (oldversion == NULL)
env_set("VERSION", U_BOOT_VERSION);
env_save();
}
return 0;
}
static int init_fwenv(void)
{
int i, ret = -1;
fwenv_addr[0] = FWENV_ADDR1;
fwenv_addr[1] = FWENV_ADDR2;
fwenv_addr[2] = FWENV_ADDR3;
fwenv_addr[3] = FWENV_ADDR4;
for (i = 0; i < MAX_FWENV_ADDR; i++)
if (fwenv_addr[i] != -1)
ret = 0;
if (ret)
printf("%s: No firmfare info storage address is defined\n",
__func__);
return ret;
}
void get_arc_info(void)
{
if (!init_fwenv())
do_get_arc_info();
}
static int do_arc_cmd(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
const char *cmd;
int ret = -1;
cmd = argv[1];
--argc;
++argv;
if (init_fwenv())
return ret;
if (strcmp(cmd, "product") == 0)
ret = set_arc_product(argc, argv);
else if (strcmp(cmd, "info") == 0)
ret = do_get_arc_info();
if (ret == -1)
return CMD_RET_USAGE;
return ret;
}
U_BOOT_CMD(arc, 6, 1, do_arc_cmd,
"Arcturus product command sub-system",
"product serial hwaddr0 hwaddr1 hwaddr2 - save Arcturus factory env\n"
"info - show Arcturus factory env\n\n");
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2013-2015 Arcturus Networks, Inc.
* http://www.arcturusnetworks.com/products/ucp1020/
* based on board/freescale/p1_p2_rdb_pc/spl.c
* original copyright follows:
* Copyright 2013 Freescale Semiconductor, Inc.
*/
#include <common.h>
#include <vsprintf.h>
#include <asm/mmu.h>