summaryrefslogtreecommitdiff
path: root/target/linux/adm5120-2.6/files/drivers
diff options
context:
space:
mode:
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-07-11 13:00:27 +0000
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-07-11 13:00:27 +0000
commit015aed13171ff6201459286e15fc5e0686a46907 (patch)
treea898a3d4793d5b1ece23dce2f4d5ded01d0e5697 /target/linux/adm5120-2.6/files/drivers
parentee0d3e3aaf9c2d586c2147109d30f8b1328ba6ac (diff)
[adm5120] refactor kernel code (part 1), mark it as broken now
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@7916 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/adm5120-2.6/files/drivers')
-rw-r--r--target/linux/adm5120-2.6/files/drivers/leds/leds-adm5120.c4
-rw-r--r--target/linux/adm5120-2.6/files/drivers/mtd/maps/adm5120-flash.c572
-rw-r--r--target/linux/adm5120-2.6/files/drivers/mtd/myloader.c22
-rw-r--r--target/linux/adm5120-2.6/files/drivers/net/adm5120sw.c28
-rw-r--r--target/linux/adm5120-2.6/files/drivers/usb/host/adm5120-hcd.c23
5 files changed, 613 insertions, 36 deletions
diff --git a/target/linux/adm5120-2.6/files/drivers/leds/leds-adm5120.c b/target/linux/adm5120-2.6/files/drivers/leds/leds-adm5120.c
index ba0269d128..e8609d374e 100644
--- a/target/linux/adm5120-2.6/files/drivers/leds/leds-adm5120.c
+++ b/target/linux/adm5120-2.6/files/drivers/leds/leds-adm5120.c
@@ -163,7 +163,7 @@ LED_ARRAY(wp54g) {
LED_INV(ADM5120_GPIO_P1L0, "lan2", NULL ),
};
-LED_ARRAY(unknown) {
+LED_ARRAY(generic) {
#if defined(CONFIG_LEDS_ADM5120_DIAG)
LED_STD(ADM5120_GPIO_PIN0, "gpio0", NULL ),
LED_STD(ADM5120_GPIO_PIN1, "gpio1", NULL ),
@@ -198,7 +198,7 @@ LED_ARRAY(unknown) {
}
static struct mach_data machines[] __initdata = {
- MACH_DATA(MACH_ADM5120_UNKNOWN, unknown),
+ MACH_DATA(MACH_ADM5120_GENERIC, generic),
MACH_DATA(MACH_ADM5120_P334WT, p334wt),
MACH_DATA(MACH_ADM5120_WP54AG, wp54g),
MACH_DATA(MACH_ADM5120_WP54G, wp54g),
diff --git a/target/linux/adm5120-2.6/files/drivers/mtd/maps/adm5120-flash.c b/target/linux/adm5120-2.6/files/drivers/mtd/maps/adm5120-flash.c
new file mode 100644
index 0000000000..a60e6e54bc
--- /dev/null
+++ b/target/linux/adm5120-2.6/files/drivers/mtd/maps/adm5120-flash.c
@@ -0,0 +1,572 @@
+/*
+ * $Id$
+ *
+ * Platform driver for NOR flash devices on ADM5120 based boards
+ *
+ * Copyright (C) 2007 OpenWrt.org
+ * Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
+ *
+ * This file was derived from: drivers/mtd/map/physmap.c
+ * Copyright (C) 2003 MontaVista Software Inc.
+ * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
+ *
+ * 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.
+ *
+ * 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/device.h>
+
+#include <linux/platform_device.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/io.h>
+
+#include <asm/mach-adm5120/adm5120_defs.h>
+#include <asm/mach-adm5120/adm5120_switch.h>
+#include <asm/mach-adm5120/adm5120_mpmc.h>
+#include <asm/mach-adm5120/adm5120_platform.h>
+
+#define DRV_NAME "adm5120-flash"
+#define DRV_DESC "ADM5120 flash MAP driver"
+#define MAX_PARSED_PARTS 8
+
+#define MAP_DBG(m, f, a...) printk(KERN_DEBUG "%s: " f, (m->name) , ## a)
+#define MAP_ERR(m, f, a...) printk(KERN_ERR "%s: " f, (m->name) , ## a)
+#define MAP_INFO(m, f, a...) printk(KERN_INFO "%s: " f, (m->name) , ## a)
+
+struct adm5120_map_info {
+ struct map_info map;
+ void (*switch_bank)(unsigned);
+ unsigned long chip_size;
+};
+
+struct adm5120_flash_info {
+ struct mtd_info *mtd;
+ struct resource *res;
+ struct platform_device *dev;
+ struct adm5120_map_info amap;
+#ifdef CONFIG_MTD_PARTITIONS
+ int nr_parts;
+ struct mtd_partition *parts[MAX_PARSED_PARTS];
+#endif
+};
+
+struct flash_desc {
+ u32 phys;
+ u32 srs_shift;
+ u32 mpmc_reg;
+};
+
+/*
+ * Globals
+ */
+static DEFINE_SPINLOCK(adm5120_flash_spin);
+#define FLASH_LOCK() spin_lock(&adm5120_flash_spin)
+#define FLASH_UNLOCK() spin_unlock(&adm5120_flash_spin)
+
+static u32 flash_bankwidths[4] = { 1, 2, 4, 0 };
+
+static u32 flash_sizes[8] = {
+ 0, 512*1024, 1024*1024, 2*1024*1024,
+ 4*1024*1024, 0, 0, 0
+};
+
+static struct flash_desc flash_descs[2] = {
+ {
+ .phys = ADM5120_SRAM0_BASE,
+ .mpmc_reg = MPMC_REG_SC1,
+ .srs_shift = MEMCTRL_SRS0_SHIFT,
+ }, {
+ .phys = ADM5120_SRAM1_BASE,
+ .mpmc_reg = MPMC_REG_SC0,
+ .srs_shift = MEMCTRL_SRS1_SHIFT,
+ }
+};
+
+static const char *probe_types[] = {
+ "cfi_probe",
+ "jedec_probe",
+ "map_rom",
+ NULL
+};
+
+#ifdef CONFIG_MTD_PARTITIONS
+static const char *parse_types[] = {
+ "cmdlinepart",
+#ifdef CONFIG_MTD_REDBOOT_PARTS
+ "RedBoot",
+#endif
+#ifdef CONFIG_MTD_MYLOADER_PARTS
+ "MyLoader",
+#endif
+};
+#endif
+
+#define BANK_SIZE (2<<20)
+#define BANK_SIZE_MAX (4<<20)
+#define BANK_OFFS_MASK (BANK_SIZE-1)
+#define BANK_START_MASK (~BANK_OFFS_MASK)
+
+static inline struct adm5120_map_info *map_to_amap(struct map_info *map)
+{
+ return (struct adm5120_map_info *)map;
+}
+
+static void adm5120_flash_switchbank(struct map_info *map,
+ unsigned long ofs)
+{
+ struct adm5120_map_info *amap = map_to_amap(map);
+ unsigned bank;
+
+ if (amap->switch_bank == NULL)
+ return;
+
+ bank = (ofs & BANK_START_MASK) >> 21;
+ if (bank > 1)
+ BUG();
+
+ MAP_DBG(map, "ofs=%lu, switching to bank %u\n", ofs, bank);
+ amap->switch_bank(bank);
+}
+
+static map_word adm5120_flash_read(struct map_info *map, unsigned long ofs)
+{
+ struct adm5120_map_info *amap = map_to_amap(map);
+ map_word ret;
+
+ MAP_DBG(map, "reading from ofs %lu\n", ofs);
+
+ if (ofs >= amap->chip_size)
+ return map_word_ff(map);
+
+ FLASH_LOCK();
+ adm5120_flash_switchbank(map, ofs);
+ ret = inline_map_read(map, (ofs & BANK_OFFS_MASK));
+ FLASH_UNLOCK();
+
+ return ret;
+}
+
+static void adm5120_flash_write(struct map_info *map, const map_word datum,
+ unsigned long ofs)
+{
+ struct adm5120_map_info *amap = map_to_amap(map);
+
+ MAP_DBG(map,"writing to ofs %lu\n", ofs);
+
+ if (ofs > amap->chip_size)
+ return;
+
+ FLASH_LOCK();
+ adm5120_flash_switchbank(map, ofs);
+ inline_map_write(map, datum, (ofs & BANK_OFFS_MASK));
+ FLASH_UNLOCK();
+}
+
+static void adm5120_flash_copy_from(struct map_info *map, void *to,
+ unsigned long from, ssize_t len)
+{
+ struct adm5120_map_info *amap = map_to_amap(map);
+ char *p;
+ ssize_t t;
+
+ MAP_DBG(map, "copying %lu byte(s) from %lu to %lX\n",
+ (unsigned long)len, from, (unsigned long)to);
+
+ if (from > amap->chip_size)
+ return;
+
+ p = (char *)to;
+ while (len > 0) {
+ if (len > BANK_SIZE - (from & BANK_OFFS_MASK))
+ t = BANK_SIZE - (from & BANK_OFFS_MASK);
+ else
+ t = len;
+
+ MAP_DBG(map, "copying %lu byte(s) from %lu to %lX\n",
+ (unsigned long)t, (from & BANK_OFFS_MASK),
+ (unsigned long)p);
+
+ FLASH_LOCK();
+ adm5120_flash_switchbank(map, from);
+ inline_map_copy_from(map, to, (from & BANK_OFFS_MASK), t);
+ FLASH_UNLOCK();
+ p += t;
+ from += t;
+ len -= t;
+ }
+}
+
+static int adm5120_flash_initres(struct adm5120_flash_info *info)
+{
+ struct map_info *map = &info->amap.map;
+ int err = 0;
+
+ info->res = request_mem_region(map->phys, map->size, map->name);
+ if (info->res == NULL) {
+ MAP_ERR(map, "could not reserve memory region\n");
+ err = -ENOMEM;
+ goto out;
+ }
+
+ map->virt = ioremap_nocache(map->phys, map->size);
+ if (map->virt == NULL) {
+ MAP_ERR(map, "failed to ioremap flash region\n");
+ err = -ENOMEM;
+ goto out;
+ }
+
+out:
+ return err;
+}
+
+#define SWITCH_READ(r) *(u32 *)(KSEG1ADDR(ADM5120_SWITCH_BASE)+(r))
+#define SWITCH_WRITE(r,v) *(u32 *)(KSEG1ADDR(ADM5120_SWITCH_BASE)+(r))=(v)
+#define MPMC_READ(r) *(u32 *)(KSEG1ADDR(ADM5120_MPMC_BASE)+(r))
+#define MPMC_WRITE(r,v) *(u32 *)(KSEG1ADDR(ADM5120_MPMC_BASE)+(r))=(v)
+
+static int adm5120_flash_initinfo(struct adm5120_flash_info *info,
+ struct platform_device *dev)
+{
+ struct map_info *map = &info->amap.map;
+ struct adm5120_flash_platform_data *pdata = dev->dev.platform_data;
+ struct flash_desc *fdesc;
+ u32 t;
+
+ map->name = dev->dev.bus_id;
+
+ if (dev->id > 1) {
+ MAP_ERR(map, "invalid flash id\n");
+ goto err_out;
+ }
+
+ fdesc = &flash_descs[dev->id];
+
+ /* get memory window size */
+ t = SWITCH_READ(SWITCH_REG_MEMCTRL) >> fdesc->srs_shift;
+ t &= MEMCTRL_SRS_MASK;
+ info->amap.chip_size = flash_sizes[t];
+ if (info->amap.chip_size == 0) {
+ MAP_ERR(map, "invalid flash size detected\n");
+ goto err_out;
+ }
+
+ /* get flash bus width */
+ t = MPMC_READ(fdesc->mpmc_reg) & SC_MW_MASK;
+ map->bankwidth = flash_bankwidths[t];
+ if (map->bankwidth == 0) {
+ MAP_ERR(map, "invalid bus width detected\n");
+ goto err_out;
+ }
+
+ map->phys = fdesc->phys;
+ map->size = BANK_SIZE_MAX;
+
+ simple_map_init(map);
+ map->read = adm5120_flash_read;
+ map->write = adm5120_flash_write;
+ map->copy_from = adm5120_flash_copy_from;
+
+ if (pdata) {
+ map->set_vpp = pdata->set_vpp;
+ info->amap.switch_bank = pdata->switch_bank;
+ }
+
+ info->dev = dev;
+
+ MAP_INFO(map, "probing at 0x%lX, size:%ldKiB, width:%d bits\n",
+ (unsigned long)map->phys,
+ (unsigned long)info->amap.chip_size >> 10,
+ map->bankwidth*8);
+
+ return 0;
+
+err_out:
+ return -ENODEV;
+}
+
+static void adm5120_flash_initbanks(struct adm5120_flash_info *info)
+{
+ struct map_info *map = &info->amap.map;
+
+ if (info->mtd->size <= BANK_SIZE)
+ /* no bank switching needed */
+ return;
+
+ if (info->amap.switch_bank) {
+ info->amap.chip_size = info->mtd->size;
+ return;
+ }
+
+ MAP_ERR(map, "reduce visibility from %ldKiB to %ldKiB\n",
+ (unsigned long)map->size >> 10,
+ (unsigned long)info->mtd->size >> 10);
+
+ info->mtd->size = info->amap.chip_size;
+}
+
+#ifdef CONFIG_MTD_PARTITIONS
+static int adm5120_flash_initparts(struct adm5120_flash_info *info)
+{
+ struct adm5120_flash_platform_data *pdata = info->dev->dev.platform_data;
+ struct map_info *map = &info->amap.map;
+ int num_parsers;
+ const char *parser[2];
+ int err = 0;
+ int nr_parts;
+ int i;
+
+ info->nr_parts = 0;
+
+ if (pdata == NULL)
+ goto out;
+
+ if (pdata->nr_parts) {
+ MAP_INFO(map, "adding static partitions\n");
+ err = add_mtd_partitions(info->mtd, pdata->parts,
+ pdata->nr_parts);
+ if (err == 0) {
+ info->nr_parts += pdata->nr_parts;
+ goto out;
+ }
+ }
+
+ num_parsers = ARRAY_SIZE(parse_types);
+ if (num_parsers > MAX_PARSED_PARTS)
+ num_parsers = MAX_PARSED_PARTS;
+
+ parser[1] = NULL;
+ for (i=0; i<num_parsers; i++) {
+ parser[0] = parse_types[i];
+
+ MAP_INFO(map, "parsing \"%s\" partitions\n",
+ parser[0]);
+ nr_parts = parse_mtd_partitions(info->mtd, parser,
+ &info->parts[i], 0);
+
+ if (nr_parts <= 0)
+ continue;
+
+ MAP_INFO(map, "adding \"%s\" partitions\n",
+ parser[0]);
+
+ err = add_mtd_partitions(info->mtd, info->parts[i], nr_parts);
+ if (err)
+ break;
+
+ info->nr_parts += nr_parts;
+ }
+out:
+ return err;
+}
+#else
+static int adm5120_flash_initparts(struct adm5120_flash_info *info)
+{
+ return 0;
+}
+#endif /* CONFIG_MTD_PARTITIONS */
+
+#ifdef CONFIG_MTD_PARTITIONS
+static void adm5120_flash_remove_mtd(struct adm5120_flash_info *info)
+{
+ int i;
+
+ if (info->nr_parts) {
+ del_mtd_partitions(info->mtd);
+ for (i=0; i<MAX_PARSED_PARTS; i++)
+ if (info->parts[i] != NULL)
+ kfree(info->parts[i]);
+ } else {
+ del_mtd_device(info->mtd);
+ }
+}
+#else
+static void adm5120_flash_remove_mtd(struct adm5120_flash_info *info)
+{
+ del_mtd_device(info->mtd);
+}
+#endif
+
+static int adm5120_flash_remove(struct platform_device *dev)
+{
+ struct adm5120_flash_info *info;
+
+ info = platform_get_drvdata(dev);
+ if (info == NULL)
+ return 0;
+
+ platform_set_drvdata(dev, NULL);
+
+ if (info->mtd != NULL) {
+ adm5120_flash_remove_mtd(info);
+ map_destroy(info->mtd);
+ }
+
+ if (info->amap.map.virt != NULL)
+ iounmap(info->amap.map.virt);
+
+ if (info->res != NULL) {
+ release_resource(info->res);
+ kfree(info->res);
+ }
+
+ return 0;
+}
+
+static int adm5120_flash_probe(struct platform_device *dev)
+{
+ struct adm5120_flash_info *info;
+ struct map_info *map;
+ const char **probe_type;
+ int err;
+
+ info = kzalloc(sizeof(*info), GFP_KERNEL);
+ if (info == NULL) {
+ err = -ENOMEM;
+ goto err_out;
+ }
+
+ platform_set_drvdata(dev, info);
+
+ err = adm5120_flash_initinfo(info, dev);
+ if (err)
+ goto err_out;
+
+ err = adm5120_flash_initres(info);
+ if (err)
+ goto err_out;
+
+ map = &info->amap.map;
+ for (probe_type = probe_types; info->mtd == NULL && *probe_type != NULL;
+ probe_type++)
+ info->mtd = do_map_probe(*probe_type, map);
+
+ if (info->mtd == NULL) {
+ MAP_ERR(map, "map_probe failed\n");
+ err = -ENXIO;
+ goto err_out;
+ }
+
+ adm5120_flash_initbanks(info);
+
+ if (info->mtd->size < info->amap.chip_size) {
+ /* readjust resources */
+ iounmap(map->virt);
+ release_resource(info->res);
+ kfree(info->res);
+
+ info->amap.chip_size = info->mtd->size;
+ map->size = info->mtd->size;
+ MAP_INFO(map, "reducing map size to %ldKiB\n",
+ (unsigned long)map->size >> 10);
+ err = adm5120_flash_initres(info);
+ if (err)
+ goto err_out;
+ }
+
+ MAP_INFO(map, "found at 0x%lX, size:%ldKiB, width:%d bits\n",
+ (unsigned long)map->phys, (unsigned long)map->size >> 10,
+ map->bankwidth*8);
+
+ info->mtd->owner = THIS_MODULE;
+
+ err = adm5120_flash_initparts(info);
+ if (err)
+ goto err_out;
+
+ if (info->nr_parts == 0) {
+ MAP_INFO(map, "no partitions available, registering whole flash\n");
+ add_mtd_device(info->mtd);
+ }
+
+ return 0;
+
+err_out:
+ adm5120_flash_remove(dev);
+ return err;
+}
+
+#ifdef CONFIG_PM
+static int adm5120_flash_suspend(struct platform_device *dev, pm_message_t state)
+{
+ struct adm5120_flash_info *info = platform_get_drvdata(dev);
+ int ret = 0;
+
+ if (info)
+ ret = info->mtd->suspend(info->mtd);
+
+ return ret;
+}
+
+static int adm5120_flash_resume(struct platform_device *dev)
+{
+ struct adm5120_flash_info *info = platform_get_drvdata(dev);
+
+ if (info)
+ info->mtd->resume(info->mtd);
+
+ return 0;
+}
+
+static void adm5120_flash_shutdown(struct platform_device *dev)
+{
+ struct adm5120_flash_info *info = platform_get_drvdata(dev);
+
+ if (info && info->mtd->suspend(info->mtd) == 0)
+ info->mtd->resume(info->mtd);
+}
+#endif
+
+static struct platform_driver adm5120_flash_driver = {
+ .probe = adm5120_flash_probe,
+ .remove = adm5120_flash_remove,
+#ifdef CONFIG_PM
+ .suspend = adm5120_flash_suspend,
+ .resume = adm5120_flash_resume,
+ .shutdown = adm5120_flash_shutdown,
+#endif
+ .driver = {
+ .name = DRV_NAME,
+ },
+};
+
+static int __init adm5120_flash_init(void)
+{
+ int err;
+
+ err = platform_driver_register(&adm5120_flash_driver);
+
+ return err;
+}
+
+static void __exit adm5120_flash_exit(void)
+{
+ platform_driver_unregister(&adm5120_flash_driver);
+}
+
+module_init(adm5120_flash_init);
+module_exit(adm5120_flash_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Gabor Juhos <juhosg@freemail.hu>");
+MODULE_DESCRIPTION(DRV_DESC);
diff --git a/target/linux/adm5120-2.6/files/drivers/mtd/myloader.c b/target/linux/adm5120-2.6/files/drivers/mtd/myloader.c
index ee916d7800..222245cc9c 100644
--- a/target/linux/adm5120-2.6/files/drivers/mtd/myloader.c
+++ b/target/linux/adm5120-2.6/files/drivers/mtd/myloader.c
@@ -1,4 +1,6 @@
/*
+ * $Id$
+ *
* Parse MyLoader-style flash partition tables and produce a Linux partition
* array to match.
*
@@ -33,7 +35,8 @@
#include <linux/mtd/partitions.h>
#include <linux/byteorder/generic.h>
-#include <asm/mach-adm5120/myloader.h>
+
+#include <prom/myloader.h>
#define NAME_LEN_MAX 20
#define NAME_MYLOADER "MyLoader"
@@ -68,12 +71,10 @@ int parse_myloader_partitions(struct mtd_info *master,
/* Partition Table is always located on the second erase block */
offset = blocklen;
- printk(KERN_NOTICE "Searching for MyLoader partition table "
- "in %s at offset 0x%lx\n", master->name, offset);
-
- ret = master->read(master, offset, sizeof(*tab), &retlen,
- (void *)tab);
+ printk(KERN_NOTICE "%s: searching for MyLoader partition table at "
+ "offset 0x%lx\n", master->name, offset);
+ ret = master->read(master, offset, sizeof(*tab), &retlen, (void *)tab);
if (ret)
goto out;
@@ -84,8 +85,8 @@ int parse_myloader_partitions(struct mtd_info *master,
/* Check for Partition Table magic number */
if (tab->magic != le32_to_cpu(MYLO_MAGIC_PARTITIONS)) {
- printk(KERN_NOTICE "No MyLoader partition table detected "
- "in %s\n", master->name);
+ printk(KERN_NOTICE "%s: no MyLoader partition table found\n",
+ master->name);
ret = 0;
goto out_free_buf;
}
@@ -103,7 +104,6 @@ int parse_myloader_partitions(struct mtd_info *master,
num_parts++;
}
-
mtd_parts = kzalloc((num_parts*sizeof(*mtd_part) + num_parts*NAME_LEN_MAX),
GFP_KERNEL);
@@ -119,6 +119,7 @@ int parse_myloader_partitions(struct mtd_info *master,
mtd_part->name = names;
mtd_part->offset = 0;
mtd_part->size = blocklen;
+ mtd_part->mask_flags = MTD_WRITEABLE;
mtd_part++;
names += NAME_LEN_MAX;
@@ -126,6 +127,7 @@ int parse_myloader_partitions(struct mtd_info *master,
mtd_part->name = names;
mtd_part->offset = blocklen;
mtd_part->size = blocklen;
+ mtd_part->mask_flags = MTD_WRITEABLE;
mtd_part++;
names += NAME_LEN_MAX;
@@ -136,9 +138,9 @@ int parse_myloader_partitions(struct mtd_info *master,
continue;
sprintf(names, "partition%d", i);
- mtd_part->name = names;
mtd_part->offset = le32_to_cpu(part->addr);
mtd_part->size = le32_to_cpu(part->size);
+ mtd_part->name = names;
mtd_part++;
names += NAME_LEN_MAX;
}
diff --git a/target/linux/adm5120-2.6/files/drivers/net/adm5120sw.c b/target/linux/adm5120-2.6/files/drivers/net/adm5120sw.c
index dfc030ea1c..6c311bfde6 100644
--- a/target/linux/adm5120-2.6/files/drivers/net/adm5120sw.c
+++ b/target/linux/adm5120-2.6/files/drivers/net/adm5120sw.c
@@ -40,9 +40,9 @@ static unsigned char vlan_matrix[SW_DEVS] = {
0x41, 0x42, 0x44, 0x48, 0x50, 0x60
};
-/* default settings - unlimited TX and RX on all ports, default shaper mode */
+/* default settings - unlimited TX and RX on all ports, default shaper mode */
static unsigned char bw_matrix[SW_DEVS] = {
- 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0
};
static int adm5120_nrdevs;
@@ -373,17 +373,17 @@ static int adm5120_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
break;
case SIOCGETBW:
err = copy_to_user(rq->ifr_data, bw_matrix, sizeof(bw_matrix));
- if (err)
- return -EFAULT;
- break;
+ if (err)
+ return -EFAULT;
+ break;
case SIOCSETBW:
- if (!capable(CAP_NET_ADMIN))
+ if (!capable(CAP_NET_ADMIN))
return -EPERM;
err = copy_from_user(bw_matrix, rq->ifr_data, sizeof(bw_matrix));
- if (err)
+ if (err)
return -EFAULT;
adm5120_set_bw(bw_matrix);
- break;
+ break;
default:
return -EOPNOTSUPP;
}
@@ -428,9 +428,7 @@ static int __init adm5120_sw_init(void)
if (err)
goto out;
- adm5120_nrdevs = adm5120_board.iface_num;
- if (adm5120_nrdevs > 5 && !adm5120_has_gmii())
- adm5120_nrdevs = 5;
+ adm5120_nrdevs = adm5120_eth_num_ports;
adm5120_set_reg(ADM5120_CPUP_CONF,
ADM5120_DISCCPUPORT | ADM5120_CRC_PADDING |
@@ -483,12 +481,8 @@ static int __init adm5120_sw_init(void)
dev->tx_timeout = adm5120_tx_timeout;
dev->watchdog_timeo = ETH_TX_TIMEOUT;
dev->set_mac_address = adm5120_sw_set_mac_address;
- /* HACK alert!!! In the original admtek driver it is asumed
- that you can read the MAC addressess from flash, but edimax
- decided to leave that space intentionally blank...
- */
- memcpy(dev->dev_addr, "\x00\x50\xfc\x11\x22\x01", 6);
- dev->dev_addr[5] += i;
+
+ memcpy(dev->dev_addr, adm5120_eth_macs[i], 6);
adm5120_write_mac(dev);
if ((err = register_netdev(dev))) {
diff --git a/target/linux/adm5120-2.6/files/drivers/usb/host/adm5120-hcd.c b/target/linux/adm5120-2.6/files/drivers/usb/host/adm5120-hcd.c
index 87bfcc6c72..c8be7393f7 100644
--- a/target/linux/adm5120-2.6/files/drivers/usb/host/adm5120-hcd.c
+++ b/target/linux/adm5120-2.6/files/drivers/usb/host/adm5120-hcd.c
@@ -18,6 +18,7 @@
#include <linux/usb.h>
#include <linux/platform_device.h>
+#include <asm/bootinfo.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/system.h>
@@ -751,7 +752,7 @@ static int __init adm5120hcd_probe(struct platform_device *pdev)
err = -ENOMEM;
goto out_mem;
}
-
+
hcd = usb_create_hcd(&adm5120_hc_driver, &pdev->dev, pdev->dev.bus_id);
if (!hcd)
goto out_mem;
@@ -821,22 +822,30 @@ static struct platform_driver adm5120hcd_driver = {
.probe = adm5120hcd_probe,
.remove = adm5120hcd_remove,
.driver = {
- .name = "adm5120-hcd",
+ .name = "adm5120-usbc",
.owner = THIS_MODULE,
},
};
static int __init adm5120hcd_init(void)
{
- if (usb_disabled())
+ int ret;
+
+ if (usb_disabled()) {
+ printk(KERN_DEBUG PFX "USB support is disabled\n");
return -ENODEV;
- if (!adm5120_board.has_usb) {
- printk(KERN_DEBUG PFX "this board does not have USB\n");
+ }
+
+ if (mips_machgroup != MACH_GROUP_ADM5120) {
+ printk(KERN_DEBUG PFX "unsupported machine group\n");
return -ENODEV;
}
- printk(KERN_INFO PFX "registered\n");
- return platform_driver_register(&adm5120hcd_driver);
+ ret = platform_driver_register(&adm5120hcd_driver);
+ if (ret == 0)
+ printk(KERN_INFO PFX "registered\n");
+
+ return ret;
}
static void __exit adm5120hcd_exit(void)