2007-07-05 16:02:19 +00:00
|
|
|
/*
|
2009-12-15 08:11:09 +00:00
|
|
|
* driver.c - barebox driver model
|
2007-07-05 16:02:19 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2007-11-08 11:01:52 +00:00
|
|
|
/**
|
|
|
|
* @file
|
2009-12-15 08:11:09 +00:00
|
|
|
* @brief barebox's driver model, and devinfo command
|
2007-11-08 11:01:52 +00:00
|
|
|
*/
|
|
|
|
|
2007-07-05 16:02:12 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <driver.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fs.h>
|
2009-11-02 13:31:18 +00:00
|
|
|
#include <linux/list.h>
|
2011-06-05 12:58:08 +00:00
|
|
|
#include <complete.h>
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
LIST_HEAD(device_list);
|
|
|
|
EXPORT_SYMBOL(device_list);
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
LIST_HEAD(driver_list);
|
|
|
|
EXPORT_SYMBOL(driver_list);
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2009-02-21 00:17:10 +00:00
|
|
|
static LIST_HEAD(active);
|
|
|
|
|
2009-06-11 13:33:49 +00:00
|
|
|
struct device_d *get_device_by_name(const char *name)
|
2009-04-22 21:39:27 +00:00
|
|
|
{
|
|
|
|
struct device_d *dev;
|
|
|
|
|
|
|
|
for_each_device(dev) {
|
2010-08-29 16:17:52 +00:00
|
|
|
if(!strcmp(dev_name(dev), name))
|
2009-04-22 21:39:27 +00:00
|
|
|
return dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-10-15 07:40:29 +00:00
|
|
|
static struct device_d *get_device_by_name_id(const char *name, int id)
|
2010-09-12 11:19:08 +00:00
|
|
|
{
|
|
|
|
struct device_d *dev;
|
|
|
|
|
|
|
|
for_each_device(dev) {
|
|
|
|
if(!strcmp(dev->name, name) && id == dev->id)
|
|
|
|
return dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-06-11 13:33:49 +00:00
|
|
|
int get_free_deviceid(const char *name_template)
|
2007-07-05 16:02:12 +00:00
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (1) {
|
2010-09-12 11:19:08 +00:00
|
|
|
if (!get_device_by_name_id(name_template, i))
|
2009-06-11 13:33:49 +00:00
|
|
|
return i;
|
2007-07-05 16:02:12 +00:00
|
|
|
i++;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
static int match(struct driver_d *drv, struct device_d *dev)
|
|
|
|
{
|
2009-02-27 17:08:45 +00:00
|
|
|
if (dev->driver)
|
|
|
|
return -1;
|
|
|
|
|
2007-10-11 18:56:18 +00:00
|
|
|
dev->driver = drv;
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2009-02-25 23:51:19 +00:00
|
|
|
if (dev->bus != drv->bus)
|
|
|
|
goto err_out;
|
|
|
|
if (dev->bus->match(dev, drv))
|
|
|
|
goto err_out;
|
|
|
|
if (dev->bus->probe(dev))
|
|
|
|
goto err_out;
|
|
|
|
|
2009-02-21 00:17:10 +00:00
|
|
|
list_add(&dev->active, &active);
|
|
|
|
|
2007-10-11 18:56:18 +00:00
|
|
|
return 0;
|
2009-02-25 23:51:19 +00:00
|
|
|
err_out:
|
|
|
|
dev->driver = NULL;
|
|
|
|
return -1;
|
2007-07-05 16:02:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int register_device(struct device_d *new_device)
|
|
|
|
{
|
|
|
|
struct driver_d *drv;
|
|
|
|
|
2012-04-15 14:02:02 +00:00
|
|
|
if (new_device->id == DEVICE_ID_DYNAMIC) {
|
2010-09-12 11:19:08 +00:00
|
|
|
new_device->id = get_free_deviceid(new_device->name);
|
|
|
|
} else {
|
|
|
|
if (get_device_by_name_id(new_device->name, new_device->id)) {
|
|
|
|
eprintf("register_device: already registered %s\n",
|
|
|
|
dev_name(new_device));
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
2009-06-11 13:33:49 +00:00
|
|
|
|
2010-08-29 16:17:52 +00:00
|
|
|
debug ("register_device: %s\n", dev_name(new_device));
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2009-02-25 23:51:19 +00:00
|
|
|
if (!new_device->bus) {
|
|
|
|
// dev_err(new_device, "no bus type associated. Needs fixup\n");
|
|
|
|
new_device->bus = &platform_bus;
|
|
|
|
}
|
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
list_add_tail(&new_device->list, &device_list);
|
2007-10-19 06:45:57 +00:00
|
|
|
INIT_LIST_HEAD(&new_device->children);
|
2009-06-11 13:33:49 +00:00
|
|
|
INIT_LIST_HEAD(&new_device->cdevs);
|
2010-06-03 08:13:29 +00:00
|
|
|
INIT_LIST_HEAD(&new_device->parameters);
|
2011-08-15 07:18:19 +00:00
|
|
|
INIT_LIST_HEAD(&new_device->active);
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
for_each_driver(drv) {
|
2007-10-11 18:56:18 +00:00
|
|
|
if (!match(drv, new_device))
|
|
|
|
break;
|
|
|
|
}
|
2007-07-05 16:02:12 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-10-07 12:27:24 +00:00
|
|
|
EXPORT_SYMBOL(register_device);
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2007-10-19 06:45:57 +00:00
|
|
|
int unregister_device(struct device_d *old_dev)
|
2007-07-05 16:02:12 +00:00
|
|
|
{
|
2012-02-13 18:46:10 +00:00
|
|
|
struct cdev *cdev, *ct;
|
|
|
|
struct device_d *child, *dt;
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2012-02-13 18:46:10 +00:00
|
|
|
dev_dbg(old_dev, "unregister\n");
|
2007-10-19 06:45:57 +00:00
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
if (old_dev->driver)
|
2009-04-06 17:08:37 +00:00
|
|
|
old_dev->bus->remove(old_dev);
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2012-02-13 18:46:10 +00:00
|
|
|
list_for_each_entry_safe(child, dt, &old_dev->children, sibling) {
|
|
|
|
dev_dbg(old_dev, "unregister child %s\n", dev_name(child));
|
|
|
|
unregister_device(child);
|
|
|
|
}
|
|
|
|
|
|
|
|
list_for_each_entry_safe(cdev, ct, &old_dev->cdevs, devices_list) {
|
|
|
|
if (cdev->flags & DEVFS_IS_PARTITION) {
|
|
|
|
dev_dbg(old_dev, "unregister part %s\n", cdev->name);
|
|
|
|
devfs_del_partition(cdev->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
list_del(&old_dev->list);
|
2011-03-24 17:53:45 +00:00
|
|
|
list_del(&old_dev->active);
|
2007-10-19 06:45:57 +00:00
|
|
|
|
|
|
|
/* remove device from parents child list */
|
|
|
|
if (old_dev->parent)
|
|
|
|
list_del(&old_dev->sibling);
|
|
|
|
|
|
|
|
return 0;
|
2007-07-05 16:02:12 +00:00
|
|
|
}
|
2007-10-07 12:27:24 +00:00
|
|
|
EXPORT_SYMBOL(unregister_device);
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2007-10-19 06:45:57 +00:00
|
|
|
int dev_add_child(struct device_d *dev, struct device_d *child)
|
|
|
|
{
|
|
|
|
child->parent = dev;
|
|
|
|
|
|
|
|
list_add_tail(&child->sibling, &dev->children);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-10-19 11:13:17 +00:00
|
|
|
EXPORT_SYMBOL(dev_add_child);
|
2007-10-19 06:45:57 +00:00
|
|
|
|
2007-07-05 16:02:12 +00:00
|
|
|
struct driver_d *get_driver_by_name(const char *name)
|
|
|
|
{
|
2007-10-11 18:20:36 +00:00
|
|
|
struct driver_d *drv;
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
for_each_driver(drv) {
|
|
|
|
if(!strcmp(name, drv->name))
|
|
|
|
return drv;
|
2007-07-05 16:02:12 +00:00
|
|
|
}
|
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
return NULL;
|
2007-07-05 16:02:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void noinfo(struct device_d *dev)
|
|
|
|
{
|
2010-08-29 16:17:52 +00:00
|
|
|
printf("no info available for %s\n", dev_name(dev));
|
2007-07-05 16:02:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void noshortinfo(struct device_d *dev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
int register_driver(struct driver_d *drv)
|
2007-07-05 16:02:12 +00:00
|
|
|
{
|
2007-10-11 18:56:18 +00:00
|
|
|
struct device_d *dev = NULL;
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2007-10-19 06:45:57 +00:00
|
|
|
debug("register_driver: %s\n", drv->name);
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2009-02-25 23:51:19 +00:00
|
|
|
if (!drv->bus) {
|
|
|
|
// pr_err("driver %s has no bus type associated. Needs fixup\n", drv->name);
|
|
|
|
drv->bus = &platform_bus;
|
|
|
|
}
|
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
list_add_tail(&drv->list, &driver_list);
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2007-10-11 18:56:18 +00:00
|
|
|
if (!drv->info)
|
|
|
|
drv->info = noinfo;
|
|
|
|
if (!drv->shortinfo)
|
|
|
|
drv->shortinfo = noshortinfo;
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
for_each_device(dev)
|
2007-10-11 18:56:18 +00:00
|
|
|
match(drv, dev);
|
2007-07-05 16:02:12 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-10-07 12:27:24 +00:00
|
|
|
EXPORT_SYMBOL(register_driver);
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2011-12-01 21:15:00 +00:00
|
|
|
static struct resource *dev_get_resource(struct device_d *dev, int num)
|
2011-07-19 06:34:33 +00:00
|
|
|
{
|
|
|
|
int i, n = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < dev->num_resources; i++) {
|
|
|
|
struct resource *res = &dev->resource[i];
|
|
|
|
if (resource_type(res) == IORESOURCE_MEM) {
|
|
|
|
if (n == num)
|
2011-12-01 21:15:00 +00:00
|
|
|
return res;
|
2011-07-19 06:34:33 +00:00
|
|
|
n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-12-01 21:15:00 +00:00
|
|
|
|
2012-06-22 10:47:22 +00:00
|
|
|
void *dev_get_mem_region(struct device_d *dev, int num)
|
2011-12-01 21:15:00 +00:00
|
|
|
{
|
|
|
|
struct resource *res;
|
|
|
|
|
|
|
|
res = dev_get_resource(dev, num);
|
|
|
|
if (!res)
|
2012-06-22 10:47:22 +00:00
|
|
|
return NULL;
|
2011-12-01 21:15:00 +00:00
|
|
|
|
2012-06-22 10:47:22 +00:00
|
|
|
return (void __force *)res->start;
|
2011-12-01 21:15:00 +00:00
|
|
|
}
|
2011-07-19 06:34:33 +00:00
|
|
|
EXPORT_SYMBOL(dev_get_mem_region);
|
|
|
|
|
2011-12-01 21:15:00 +00:00
|
|
|
void __iomem *dev_request_mem_region(struct device_d *dev, int num)
|
|
|
|
{
|
|
|
|
struct resource *res;
|
|
|
|
|
|
|
|
res = dev_get_resource(dev, num);
|
|
|
|
if (!res)
|
|
|
|
return NULL;
|
|
|
|
|
2012-05-24 06:52:22 +00:00
|
|
|
res = request_iomem_region(dev_name(dev), res->start, res->end);
|
2012-06-27 13:15:30 +00:00
|
|
|
if (!res)
|
|
|
|
return NULL;
|
2011-12-01 21:15:00 +00:00
|
|
|
|
|
|
|
return (void __force __iomem *)res->start;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(dev_request_mem_region);
|
|
|
|
|
2007-07-16 08:29:28 +00:00
|
|
|
int dev_protect(struct device_d *dev, size_t count, unsigned long offset, int prot)
|
|
|
|
{
|
2009-04-22 21:39:27 +00:00
|
|
|
printf("%s: currently broken\n", __func__);
|
|
|
|
return -EINVAL;
|
2007-07-16 08:29:28 +00:00
|
|
|
}
|
|
|
|
|
2009-04-22 21:39:27 +00:00
|
|
|
int generic_memmap_ro(struct cdev *cdev, void **map, int flags)
|
2007-07-15 11:50:04 +00:00
|
|
|
{
|
2009-04-22 21:39:27 +00:00
|
|
|
if (!cdev->dev)
|
|
|
|
return -EINVAL;
|
2007-07-15 11:50:04 +00:00
|
|
|
|
|
|
|
if (flags & PROT_WRITE)
|
|
|
|
return -EACCES;
|
2011-07-28 21:05:31 +00:00
|
|
|
*map = dev_get_mem_region(cdev->dev, 0);
|
2007-07-15 11:50:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-04-22 21:39:27 +00:00
|
|
|
int generic_memmap_rw(struct cdev *cdev, void **map, int flags)
|
2007-07-15 11:50:04 +00:00
|
|
|
{
|
2009-04-22 21:39:27 +00:00
|
|
|
if (!cdev->dev)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2011-07-28 21:05:31 +00:00
|
|
|
*map = dev_get_mem_region(cdev->dev, 0);
|
2007-07-15 11:50:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-05 16:02:12 +00:00
|
|
|
int dummy_probe(struct device_d *dev)
|
|
|
|
{
|
2007-10-11 18:56:18 +00:00
|
|
|
return 0;
|
2007-07-05 16:02:12 +00:00
|
|
|
}
|
2008-08-15 01:33:16 +00:00
|
|
|
EXPORT_SYMBOL(dummy_probe);
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2010-11-01 08:26:15 +00:00
|
|
|
const char *dev_id(const struct device_d *dev)
|
|
|
|
{
|
2011-07-28 06:33:01 +00:00
|
|
|
static char buf[MAX_DRIVER_NAME + 16];
|
2010-11-01 08:26:15 +00:00
|
|
|
|
2012-04-15 14:02:02 +00:00
|
|
|
if (dev->id != DEVICE_ID_SINGLE)
|
|
|
|
snprintf(buf, sizeof(buf), FORMAT_DRIVER_NAME_ID, dev->name, dev->id);
|
|
|
|
else
|
|
|
|
snprintf(buf, sizeof(buf), "%s", dev->name);
|
2010-11-01 08:26:15 +00:00
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
void devices_shutdown(void)
|
|
|
|
{
|
|
|
|
struct device_d *dev;
|
|
|
|
|
|
|
|
list_for_each_entry(dev, &active, active) {
|
|
|
|
if (dev->driver->remove)
|
|
|
|
dev->driver->remove(dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_CMD_DEVINFO
|
2011-08-10 12:48:18 +00:00
|
|
|
static int do_devinfo_subtree(struct device_d *dev, int depth)
|
2007-10-19 06:45:57 +00:00
|
|
|
{
|
|
|
|
struct device_d *child;
|
2009-06-11 13:33:49 +00:00
|
|
|
struct cdev *cdev;
|
2007-10-19 06:45:57 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < depth; i++)
|
2011-08-10 12:48:18 +00:00
|
|
|
printf(" ");
|
2007-10-19 06:45:57 +00:00
|
|
|
|
2011-08-10 12:48:18 +00:00
|
|
|
printf("`---- %s", dev_name(dev));
|
2009-06-11 13:33:49 +00:00
|
|
|
if (!list_empty(&dev->cdevs)) {
|
2011-08-10 12:48:18 +00:00
|
|
|
printf("\n");
|
2009-06-11 13:33:49 +00:00
|
|
|
list_for_each_entry(cdev, &dev->cdevs, devices_list) {
|
2011-08-10 12:48:18 +00:00
|
|
|
for (i = 0; i < depth + 1; i++)
|
|
|
|
printf(" ");
|
2011-10-19 07:27:47 +00:00
|
|
|
printf("`---- 0x%08llx-0x%08llx: /dev/%s\n",
|
2011-08-10 12:48:18 +00:00
|
|
|
cdev->offset,
|
|
|
|
cdev->offset + cdev->size - 1,
|
|
|
|
cdev->name);
|
2009-06-11 13:33:49 +00:00
|
|
|
}
|
2011-08-10 12:48:18 +00:00
|
|
|
} else {
|
|
|
|
printf("\n");
|
2009-06-11 13:33:49 +00:00
|
|
|
}
|
2007-10-19 06:45:57 +00:00
|
|
|
|
|
|
|
if (!list_empty(&dev->children)) {
|
|
|
|
device_for_each_child(dev, child) {
|
2011-08-10 12:48:18 +00:00
|
|
|
do_devinfo_subtree(child, depth + 1);
|
2007-10-19 06:45:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2008-10-31 13:02:25 +00:00
|
|
|
}
|
|
|
|
|
2011-12-21 13:18:57 +00:00
|
|
|
static int do_devinfo(int argc, char *argv[])
|
2007-07-05 16:02:12 +00:00
|
|
|
{
|
2007-10-11 18:20:36 +00:00
|
|
|
struct device_d *dev;
|
|
|
|
struct driver_d *drv;
|
|
|
|
struct param_d *param;
|
2011-07-28 21:25:32 +00:00
|
|
|
int i;
|
|
|
|
struct resource *res;
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
if (argc == 1) {
|
|
|
|
printf("devices:\n");
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
for_each_device(dev) {
|
2007-10-19 06:45:57 +00:00
|
|
|
if (!dev->parent)
|
2011-08-10 12:48:18 +00:00
|
|
|
do_devinfo_subtree(dev, 0);
|
2007-10-11 18:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
printf("\ndrivers:\n");
|
|
|
|
for_each_driver(drv)
|
|
|
|
printf("%10s\n",drv->name);
|
|
|
|
} else {
|
2010-10-15 07:40:29 +00:00
|
|
|
dev = get_device_by_name(argv[1]);
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
if (!dev) {
|
|
|
|
printf("no such device: %s\n",argv[1]);
|
|
|
|
return -1;
|
|
|
|
}
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2011-07-28 21:25:32 +00:00
|
|
|
printf("resources:\n");
|
|
|
|
for (i = 0; i < dev->num_resources; i++) {
|
|
|
|
res = &dev->resource[i];
|
|
|
|
printf("num : %d\n", i);
|
|
|
|
if (res->name)
|
|
|
|
printf("name : %s\n", res->name);
|
2012-06-25 11:06:03 +00:00
|
|
|
printf("start : " PRINTF_CONVERSION_RESOURCE "\nsize : "
|
|
|
|
PRINTF_CONVERSION_RESOURCE "\n",
|
2012-05-24 06:52:22 +00:00
|
|
|
res->start, resource_size(res));
|
2011-07-28 21:25:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
printf("driver: %s\n\n", dev->driver ?
|
2007-10-19 06:45:57 +00:00
|
|
|
dev->driver->name : "none");
|
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
if (dev->driver)
|
|
|
|
dev->driver->info(dev);
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2010-06-03 08:13:29 +00:00
|
|
|
printf("%s\n", list_empty(&dev->parameters) ?
|
|
|
|
"no parameters available" : "Parameters:");
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2010-06-03 08:13:29 +00:00
|
|
|
list_for_each_entry(param, &dev->parameters, list)
|
2012-04-23 11:02:19 +00:00
|
|
|
printf("%16s = %s\n", param->name, dev_get_param(dev, param->name));
|
2007-10-11 18:20:36 +00:00
|
|
|
}
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
return 0;
|
2007-07-05 16:02:12 +00:00
|
|
|
}
|
|
|
|
|
2010-10-31 19:33:50 +00:00
|
|
|
BAREBOX_CMD_HELP_START(devinfo)
|
|
|
|
BAREBOX_CMD_HELP_USAGE("devinfo [DEVICE]\n")
|
|
|
|
BAREBOX_CMD_HELP_SHORT("Output device information.\n")
|
|
|
|
BAREBOX_CMD_HELP_END
|
2007-07-05 16:02:12 +00:00
|
|
|
|
2010-10-31 19:33:50 +00:00
|
|
|
/**
|
|
|
|
* @page devinfo_command
|
2007-11-08 11:01:52 +00:00
|
|
|
|
2010-10-31 19:33:50 +00:00
|
|
|
If called without arguments, devinfo shows a summary of the known
|
|
|
|
devices and drivers.
|
|
|
|
|
|
|
|
If called with a device path being the argument, devinfo shows more
|
|
|
|
default information about this device and its parameters.
|
|
|
|
|
|
|
|
Example from an MPC5200 based system:
|
2008-08-13 14:04:43 +00:00
|
|
|
|
2007-11-08 11:01:52 +00:00
|
|
|
@verbatim
|
2009-12-15 08:11:09 +00:00
|
|
|
barebox:/ devinfo /dev/eth0
|
2007-11-08 11:01:52 +00:00
|
|
|
base : 0x1002b000
|
|
|
|
size : 0x00000000
|
|
|
|
driver: fec_mpc5xxx
|
|
|
|
|
|
|
|
no info available for eth0
|
|
|
|
Parameters:
|
2007-11-12 11:29:09 +00:00
|
|
|
ipaddr = 192.168.23.197
|
2007-11-08 11:01:52 +00:00
|
|
|
ethaddr = 80:81:82:83:84:86
|
|
|
|
gateway = 192.168.23.1
|
|
|
|
netmask = 255.255.255.0
|
|
|
|
serverip = 192.168.23.2
|
|
|
|
@endverbatim
|
|
|
|
*/
|
2010-10-31 19:33:50 +00:00
|
|
|
|
|
|
|
BAREBOX_CMD_START(devinfo)
|
|
|
|
.cmd = do_devinfo,
|
|
|
|
.usage = "Show information about devices and drivers.",
|
|
|
|
BAREBOX_CMD_HELP(cmd_devinfo_help)
|
2011-06-05 12:58:08 +00:00
|
|
|
BAREBOX_CMD_COMPLETE(device_complete)
|
2010-10-31 19:33:50 +00:00
|
|
|
BAREBOX_CMD_END
|
|
|
|
#endif
|
|
|
|
|