9
0
Fork 0

Merge branch 'for-next/misc'

This commit is contained in:
Sascha Hauer 2014-02-03 09:55:54 +01:00
commit 601bf0fcc6
30 changed files with 213 additions and 60 deletions

View File

@ -53,13 +53,13 @@ static int gk802_env_init(void)
bootsource_name = "mmc2";
barebox_name = "mmc2.barebox";
default_environment_name = "mmc2.bareboxenv";
default_environment_path = "/dev/mmc2.bareboxenv";
default_environment_path_set("/dev/mmc2.bareboxenv");
break;
case 3:
bootsource_name = "mmc3";
barebox_name = "mmc3.barebox";
default_environment_name = "mmc3.bareboxenv";
default_environment_path = "/dev/mmc3.bareboxenv";
default_environment_path_set("/dev/mmc3.bareboxenv");
break;
default:
return 0;

View File

@ -132,7 +132,7 @@ static int rpi_env_init(void)
return 0;
}
default_environment_path = "/boot/barebox.env";
default_environment_path_set("/boot/barebox.env");
return 0;
}

View File

@ -129,7 +129,7 @@ static int tqma6x_env_init(void)
device_detect_by_name("mmc2");
default_environment_path = "/dev/mmc2.boot1";
default_environment_path_set("/dev/mmc2.boot1");
return 0;
}

View File

@ -46,7 +46,6 @@ static int __attribute__((__used__))
static void __noreturn noinline uncompress_start_payload(uint32_t membase,
uint32_t memsize, uint32_t boarddata)
{
uint32_t offset;
uint32_t pg_len;
void __noreturn (*barebox)(uint32_t, uint32_t, uint32_t);
uint32_t endmem = membase + memsize;
@ -61,9 +60,6 @@ static void __noreturn noinline uncompress_start_payload(uint32_t membase,
if (IS_ENABLED(CONFIG_PBL_RELOCATABLE))
relocate_to_current_adr();
/* Get offset between linked address and runtime address */
offset = get_runtime_offset();
if (IS_ENABLED(CONFIG_RELOCATABLE))
barebox_base = arm_barebox_image_place(membase + memsize);
else

View File

@ -142,7 +142,7 @@ static int omap_env_init(void)
return 0;
}
default_environment_path = "/boot/barebox.env";
default_environment_path_set("/boot/barebox.env");
return 0;
}

View File

@ -103,7 +103,7 @@ static int socfpga_env_init(void)
goto out_free;
}
default_environment_path = "/boot/barebox.env";
default_environment_path_set("/boot/barebox.env");
out_free:
free(partname);

View File

@ -1,7 +0,0 @@
#!/bin/sh
PATH=/env/bin
export PATH
. /env/config

View File

@ -1,8 +0,0 @@
#!/bin/sh
eth0.ipaddr=172.0.0.2
eth0.netmask=255.255.255.0
eth0.gateway=172.0.0.1
eth0.serverip=172.0.0.1
eth0.ethaddr=80:81:82:83:84:85

11
arch/sandbox/board/env/network/eth0 vendored Normal file
View File

@ -0,0 +1,11 @@
#!/bin/sh
# ip setting (static/dhcp)
ip=static
# static setup used if ip=static
ipaddr=172.0.0.2
netmask=255.255.255.0
gateway=172.0.0.1
serverip=172.0.0.1
ethaddr=80:81:82:83:84:85

View File

@ -1,18 +1,20 @@
CONFIG_GLOB=y
CONFIG_HUSH_FANCY_PROMPT=y
CONFIG_CMDLINE_EDITING=y
CONFIG_AUTO_COMPLETE=y
CONFIG_PARTITION=y
CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/sandbox/board/env"
CONFIG_DEBUG_INFO=y
CONFIG_CMD_EDIT=y
CONFIG_CMD_SLEEP=y
CONFIG_CMD_SAVEENV=y
CONFIG_CMD_LOADENV=y
CONFIG_CMD_EXPORT=y
CONFIG_CMD_PRINTENV=y
CONFIG_CMD_READLINE=y
CONFIG_CMD_TFTP=y
CONFIG_CMD_MEMINFO=y
CONFIG_CMD_CRC=y
CONFIG_CMD_FLASH=y
# CONFIG_CMD_BOOTM is not set
CONFIG_CMD_RESET=y
CONFIG_CMD_GO=y
@ -21,8 +23,7 @@ CONFIG_CMD_PARTITION=y
CONFIG_NET=y
CONFIG_NET_DHCP=y
CONFIG_NET_PING=y
CONFIG_CMD_TFTP=y
CONFIG_FS_TFTP=y
CONFIG_DRIVER_NET_TAP=y
# CONFIG_SPI is not set
CONFIG_FS_CRAMFS=y
CONFIG_FS_TFTP=y

View File

@ -53,7 +53,7 @@ static int do_loadenv(int argc, char *argv[])
dirname = argv[optind + 1];
if (argc - optind < 1)
filename = default_environment_path;
filename = default_environment_path_get();
else
filename = argv[optind];

View File

@ -38,7 +38,7 @@ static int do_saveenv(int argc, char *argv[])
else
dirname = argv[2];
if (argc < 2)
filename = default_environment_path;
filename = default_environment_path_get();
else
filename = argv[1];

View File

@ -529,7 +529,7 @@ source common/partitions/Kconfig
config DEFAULT_ENVIRONMENT
bool
default y
select CMD_LOADENV
select ENV_HANDLING
prompt "Compile in default environment"
help
Enabling this option will give you a default environment when

View File

@ -110,7 +110,7 @@ targets += barebox_default_env.lzo barebox_default_env.bz2 barebox_default_env.g
quiet_cmd_env_h = ENVH $@
cmd_env_h = cat $< | (cd $(obj) && $(objtree)/scripts/bin2c default_environment) > $@; \
echo "const int default_environment_uncompress_size=`stat -c%s $(obj)/barebox_default_env`;" >> $@
echo "static const int default_environment_uncompress_size=`stat -c%s $(obj)/barebox_default_env`;" >> $@
$(obj)/barebox_default_env.h: $(obj)/barebox_default_env$(barebox_default_env_comp) FORCE
$(call if_changed,env_h)
@ -119,14 +119,14 @@ quiet_cmd_pwd_h = PWDH $@
ifdef CONFIG_PASSWORD
ifneq ($(CONFIG_PASSWORD_DEFAULT),"")
PASSWD_FILE := $(shell cd $(srctree); find $(CONFIG_PASSWORD_DEFAULT) -type f)
cmd_pwd_h = echo -n "const char default_passwd[] = \"" > $@; \
cmd_pwd_h = echo -n "static const char default_passwd[] = \"" > $@; \
cat $< | tr -d '\n' >> $@; \
echo "\";" >> $@
include/generated/passwd.h: $(PASSWD_FILE)
$(call if_changed,pwd_h)
else
cmd_pwd_h = echo "const char default_passwd[] = \"\";" > $@
cmd_pwd_h = echo "static const char default_passwd[] = \"\";" > $@
include/generated/passwd.h: FORCE
$(call if_changed,pwd_h)

View File

@ -31,6 +31,8 @@
#include <kfifo.h>
#include <module.h>
#include <poller.h>
#include <magicvar.h>
#include <globalvar.h>
#include <linux/list.h>
#include <linux/stringify.h>
#include <debug_ll.h>
@ -140,6 +142,26 @@ static void console_init_early(void)
initialized = CONSOLE_INITIALIZED_BUFFER;
}
static void console_set_stdoutpath(struct console_device *cdev)
{
int id;
char *str;
if (!cdev->linux_console_name)
return;
id = of_alias_get_id(cdev->dev->device_node, "serial");
if (id < 0)
return;
str = asprintf("console=%s%d,%dn8", cdev->linux_console_name,
id, cdev->baudrate);
globalvar_add_simple("linux.bootargs.console", str);
free(str);
}
int console_register(struct console_device *newcdev)
{
struct device_d *dev = &newcdev->class_dev;
@ -169,8 +191,10 @@ int console_register(struct console_device *newcdev)
activate = 1;
}
if (newcdev->dev && of_device_is_stdout_path(newcdev->dev))
if (newcdev->dev && of_device_is_stdout_path(newcdev->dev)) {
activate = 1;
console_set_stdoutpath(newcdev);
}
list_add_tail(&newcdev->list, &console_list);
@ -357,3 +381,6 @@ int ctrlc (void)
}
EXPORT_SYMBOL(ctrlc);
#endif /* ARCH_HAS_CTRC */
BAREBOX_MAGICVAR_NAMED(global_linux_bootargs_console, global.linux.bootargs.console,
"console= argument for Linux from the linux,stdout-path property in /chosen node");

View File

@ -48,7 +48,19 @@ struct action_data {
};
#define PAD4(x) ((x + 3) & ~3)
char *default_environment_path = "/dev/env0";
#ifdef __BAREBOX__
static char *default_environment_path = "/dev/env0";
void default_environment_path_set(char *path)
{
default_environment_path = path;
}
char *default_environment_path_get(void)
{
return default_environment_path;
}
#endif
static int file_size_action(const char *filename, struct stat *statbuf,
void *userdata, int depth)
@ -150,7 +162,7 @@ out:
* Note: This function will also be used on the host! See note in the header
* of this file.
*/
int envfs_save(char *filename, char *dirname)
int envfs_save(const char *filename, char *dirname)
{
struct envfs_super *super;
int envfd, size, ret;
@ -215,7 +227,7 @@ EXPORT_SYMBOL(envfs_save);
* Note: This function will also be used on the host! See note in the header
* of this file.
*/
int envfs_load(char *filename, char *dir, unsigned flags)
int envfs_load(const char *filename, char *dir, unsigned flags)
{
struct envfs_super super;
void *buf = NULL, *buf_free = NULL;

View File

@ -121,6 +121,7 @@ void __noreturn start_barebox(void)
if (IS_ENABLED(CONFIG_ENV_HANDLING)) {
int ret;
char *default_environment_path = default_environment_path_get();
ret = envfs_load(default_environment_path, "/env", 0);

View File

@ -8,6 +8,7 @@ global autoboot_timeout
global boot.default
global allow_color
global linux.bootargs.base
global linux.bootargs.console
#linux.bootargs.dyn.* will be cleared at the beginning of boot
global linux.bootargs.dyn.ip
global linux.bootargs.dyn.root

View File

@ -2,12 +2,7 @@
# Misc strange devices
#
menuconfig MISC_DEVICES
bool "Misc devices"
help
Add support for misc strange devices
if MISC_DEVICES
menu "Misc devices"
config JTAG
tristate "JTAG Bitbang driver"
@ -15,4 +10,9 @@ config JTAG
help
Controls JTAG chains connected to I/O pins
endif # MISC_DEVICES
config SRAM
bool "Generic SRAM driver"
help
This driver adds support for memory mapped SRAM.
endmenu

View File

@ -3,3 +3,4 @@
#
obj-$(CONFIG_JTAG) += jtag.o
obj-$(CONFIG_SRAM) += sram.o

75
drivers/misc/sram.c Normal file
View File

@ -0,0 +1,75 @@
/*
* drivers/misc/sram.c - generic memory mapped SRAM driver
*
* 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.
*/
#include <common.h>
#include <errno.h>
#include <driver.h>
#include <malloc.h>
#include <init.h>
struct sram {
struct resource *res;
char *name;
struct cdev cdev;
};
static struct file_operations memops = {
.read = mem_read,
.write = mem_write,
.memmap = generic_memmap_rw,
.lseek = dev_lseek_default,
};
static int sram_probe(struct device_d *dev)
{
struct sram *sram;
struct resource *res;
void __iomem *base;
int ret;
base = dev_request_mem_region(dev, 0);
if (!base)
return -EBUSY;
sram = xzalloc(sizeof(*sram));
sram->cdev.name = asprintf("sram%d",
cdev_find_free_index("sram"));
res = dev_get_resource(dev, 0);
sram->cdev.size = (unsigned long)resource_size(res);
sram->cdev.ops = &memops;
sram->cdev.dev = dev;
ret = devfs_create(&sram->cdev);
if (ret)
return ret;
return 0;
}
static __maybe_unused struct of_device_id sram_dt_ids[] = {
{
.compatible = "mmio-sram",
}, {
},
};
static struct driver_d sram_driver = {
.name = "mmio-sram",
.probe = sram_probe,
.of_compatible = sram_dt_ids,
};
device_platform_driver(sram_driver);

View File

@ -59,7 +59,7 @@ static int environment_probe(struct device_d *dev)
dev_info(dev, "setting default environment path to %s\n", path);
default_environment_path = path;
default_environment_path_set(path);
return 0;
}

View File

@ -1378,11 +1378,32 @@ EXPORT_SYMBOL(of_find_node_by_path);
struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
const char *str)
{
struct device_node *node;
const char *slash;
char *alias;
size_t len = 0;
if (*str == '/')
return of_find_node_by_path_from(root, str);
else
slash = strchr(str, '/');
if (!slash)
return of_find_node_by_alias(root, str);
len = slash - str + 1;
alias = xmalloc(len);
strlcpy(alias, str, len);
node = of_find_node_by_alias(root, alias);
if (!node)
goto out;
node = of_find_node_by_path_from(node, slash);
out:
free(alias);
return node;
}
EXPORT_SYMBOL(of_find_node_by_path_or_alias);

View File

@ -336,6 +336,7 @@ static int imx_serial_probe(struct device_d *dev)
cdev->getc = imx_serial_getc;
cdev->flush = imx_serial_flush;
cdev->setbrg = imx_serial_setbaudrate;
cdev->linux_console_name = "ttymxc";
imx_serial_init_port(cdev);

View File

@ -57,6 +57,7 @@ static inline struct ns16550_priv *to_ns16550_priv(struct console_device *cdev)
struct ns16550_drvdata {
void (*init_port)(struct console_device *cdev);
const char *linux_console_name;
};
/**
@ -251,6 +252,7 @@ static struct ns16550_drvdata ns16550_drvdata = {
static __maybe_unused struct ns16550_drvdata omap_drvdata = {
.init_port = ns16550_omap_init_port,
.linux_console_name = "ttyO",
};
/**
@ -312,6 +314,7 @@ static int ns16550_probe(struct device_d *dev)
cdev->putc = ns16550_putc;
cdev->getc = ns16550_getc;
cdev->setbrg = ns16550_setbaudrate;
cdev->linux_console_name = devtype->linux_console_name;
devtype->init_port(cdev);

View File

@ -89,11 +89,6 @@ suffix_$(CONFIG_IMAGE_COMPRESSION_NONE) = shipped
$(obj)/barebox.z: $(obj)/../barebox.bin FORCE
$(call if_changed,$(suffix_y))
quiet_cmd_selfextract = COMP $@
cmd_selfextract = cat $(obj)/start_uncompress.pblb > $@; \
$(call size_append, $<) >> $@; \
cat $< >> $@
# %.img - create a copy from another file
# ----------------------------------------------------------------
.SECONDEXPANSION:

View File

@ -49,6 +49,8 @@ struct console_device {
unsigned char f_active;
unsigned int baudrate;
const char *linux_console_name;
};
int console_register(struct console_device *cdev);

View File

@ -90,11 +90,23 @@ struct envfs_super {
#endif
#define ENV_FLAG_NO_OVERWRITE (1 << 0)
int envfs_load(char *filename, char *dirname, unsigned flags);
int envfs_save(char *filename, char *dirname);
int envfs_load(const char *filename, char *dirname, unsigned flags);
int envfs_save(const char *filename, char *dirname);
/* defaults to /dev/env0 */
extern char *default_environment_path;
#ifdef CONFIG_ENV_HANDLING
void default_environment_path_set(char *path);
char *default_environment_path_get(void);
#else
static inline void default_environment_path_set(char *path)
{
}
static inline char *default_environment_path_get(void)
{
return NULL;
}
#endif
int envfs_register_partition(const char *devname, unsigned int partnr);

View File

@ -296,13 +296,22 @@ int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
int (*run)(struct phy_device *));
int phy_register_fixup_for_id(const char *bus_id,
int (*run)(struct phy_device *));
int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
int (*run)(struct phy_device *));
int phy_scan_fixups(struct phy_device *phydev);
int phy_read_mmd_indirect(struct phy_device *phydev, int prtad, int devad);
void phy_write_mmd_indirect(struct phy_device *phydev, int prtad, int devad,
u16 data);
#ifdef CONFIG_PHYLIB
int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
int (*run)(struct phy_device *));
#else
static inline int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
int (*run)(struct phy_device *))
{
return -ENOSYS;
}
#endif
extern struct bus_type mdio_bus_type;
#endif /* __PHYDEV_H__ */

View File

@ -14,7 +14,7 @@ int main(int argc, char *argv[])
int ch, total=0;
if (argc > 1)
printf("const char %s[] %s=\n",
printf("static const char %s[] %s=\n",
argv[1], argc > 2 ? argv[2] : "");
do {
@ -30,7 +30,7 @@ int main(int argc, char *argv[])
} while (ch != EOF);
if (argc > 1)
printf("\t;\n\nconst int %s_size = %d;\n", argv[1], total);
printf("\t;\n\nstatic const int %s_size = %d;\n", argv[1], total);
return 0;
}