dm9000: introduce add_dm9000_device to register dm9000 device
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
This commit is contained in:
parent
3465da7aa8
commit
06c36cf09e
|
@ -89,31 +89,9 @@ static void ek_add_device_nand(void)
|
||||||
*/
|
*/
|
||||||
#if defined(CONFIG_DRIVER_NET_DM9000)
|
#if defined(CONFIG_DRIVER_NET_DM9000)
|
||||||
static struct dm9000_platform_data dm9000_data = {
|
static struct dm9000_platform_data dm9000_data = {
|
||||||
.buswidth = IORESOURCE_MEM_16BIT,
|
|
||||||
.srom = 0,
|
.srom = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct resource dm9000_resources[] = {
|
|
||||||
[0] = {
|
|
||||||
.start = AT91_CHIPSELECT_2,
|
|
||||||
.size = 4,
|
|
||||||
.flags = IORESOURCE_MEM,
|
|
||||||
},
|
|
||||||
[1] = {
|
|
||||||
.start = AT91_CHIPSELECT_2 + 4,
|
|
||||||
.size = 4,
|
|
||||||
.flags = IORESOURCE_MEM,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct device_d dm9000_dev = {
|
|
||||||
.id = 0,
|
|
||||||
.name = "dm9000",
|
|
||||||
.num_resources = ARRAY_SIZE(dm9000_resources),
|
|
||||||
.resource = dm9000_resources,
|
|
||||||
.platform_data = &dm9000_data,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SMC timings for the DM9000.
|
* SMC timings for the DM9000.
|
||||||
* Note: These timings were calculated for MASTER_CLOCK = 100000000 according to the DM9000 timings.
|
* Note: These timings were calculated for MASTER_CLOCK = 100000000 according to the DM9000 timings.
|
||||||
|
@ -147,7 +125,8 @@ static void __init ek_add_device_dm9000(void)
|
||||||
/* Configure Interrupt pin as input, no pull-up */
|
/* Configure Interrupt pin as input, no pull-up */
|
||||||
at91_set_gpio_input(AT91_PIN_PC11, 0);
|
at91_set_gpio_input(AT91_PIN_PC11, 0);
|
||||||
|
|
||||||
register_device(&dm9000_dev);
|
add_dm9000_device(0, AT91_CHIPSELECT_2, AT91_CHIPSELECT_2 + 4,
|
||||||
|
IORESOURCE_MEM_16BIT, &dm9000_data);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static void __init ek_add_device_dm9000(void) {}
|
static void __init ek_add_device_dm9000(void) {}
|
||||||
|
|
|
@ -63,30 +63,9 @@ static struct device_d nand_dev = {
|
||||||
* Area 2: Offset 0x304...0x307
|
* Area 2: Offset 0x304...0x307
|
||||||
*/
|
*/
|
||||||
static struct dm9000_platform_data dm9000_data = {
|
static struct dm9000_platform_data dm9000_data = {
|
||||||
.buswidth = IORESOURCE_MEM_16BIT,
|
|
||||||
.srom = 1,
|
.srom = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct resource dm9000_resources[] = {
|
|
||||||
[0] = {
|
|
||||||
.start = CS4_BASE + 0x300,
|
|
||||||
.size = 4,
|
|
||||||
.flags = IORESOURCE_MEM,
|
|
||||||
},
|
|
||||||
[1] = {
|
|
||||||
.start = CS4_BASE + 0x304,
|
|
||||||
.size = 4,
|
|
||||||
.flags = IORESOURCE_MEM,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct device_d dm9000_dev = {
|
|
||||||
.name = "dm9000",
|
|
||||||
.num_resources = ARRAY_SIZE(dm9000_resources),
|
|
||||||
.resource = dm9000_resources,
|
|
||||||
.platform_data = &dm9000_data,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct s3c_mci_platform_data mci_data = {
|
static struct s3c_mci_platform_data mci_data = {
|
||||||
.caps = MMC_MODE_4BIT | MMC_MODE_HS | MMC_MODE_HS_52MHz,
|
.caps = MMC_MODE_4BIT | MMC_MODE_HS | MMC_MODE_HS_52MHz,
|
||||||
.voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
|
.voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
|
||||||
|
@ -332,7 +311,8 @@ static int mini2440_devices_init(void)
|
||||||
IORESOURCE_MEM_WRITEABLE);
|
IORESOURCE_MEM_WRITEABLE);
|
||||||
armlinux_add_dram(sdram_dev);
|
armlinux_add_dram(sdram_dev);
|
||||||
|
|
||||||
register_device(&dm9000_dev);
|
add_dm9000_device(0, CS4_BASE + 0x300, CS4_BASE + 0x304,
|
||||||
|
IORESOURCE_MEM_16BIT, &dm9000_data);
|
||||||
#ifdef CONFIG_NAND
|
#ifdef CONFIG_NAND
|
||||||
/* ----------- add some vital partitions -------- */
|
/* ----------- add some vital partitions -------- */
|
||||||
devfs_del_partition("self_raw");
|
devfs_del_partition("self_raw");
|
||||||
|
|
|
@ -89,31 +89,9 @@ static void pm_add_device_nand(void)
|
||||||
*/
|
*/
|
||||||
#if defined(CONFIG_DRIVER_NET_DM9000)
|
#if defined(CONFIG_DRIVER_NET_DM9000)
|
||||||
static struct dm9000_platform_data dm9000_data = {
|
static struct dm9000_platform_data dm9000_data = {
|
||||||
.buswidth = IORESOURCE_MEM_16BIT,
|
|
||||||
.srom = 1,
|
.srom = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct resource dm9000_resources[] = {
|
|
||||||
[0] = {
|
|
||||||
.start = AT91_CHIPSELECT_2,
|
|
||||||
.size = 4,
|
|
||||||
.flags = IORESOURCE_MEM,
|
|
||||||
},
|
|
||||||
[1] = {
|
|
||||||
.start = AT91_CHIPSELECT_2 + 4,
|
|
||||||
.size = 4,
|
|
||||||
.flags = IORESOURCE_MEM,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct device_d dm9000_dev = {
|
|
||||||
.id = 0,
|
|
||||||
.name = "dm9000",
|
|
||||||
.num_resources = ARRAY_SIZE(dm9000_resources),
|
|
||||||
.resource = dm9000_resources,
|
|
||||||
.platform_data = &dm9000_data,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SMC timings for the DM9000.
|
* SMC timings for the DM9000.
|
||||||
* Note: These timings were calculated for MASTER_CLOCK = 100000000 according to the DM9000 timings.
|
* Note: These timings were calculated for MASTER_CLOCK = 100000000 according to the DM9000 timings.
|
||||||
|
@ -141,7 +119,8 @@ static void __init pm_add_device_dm9000(void)
|
||||||
/* Configure chip-select 2 (DM9000) */
|
/* Configure chip-select 2 (DM9000) */
|
||||||
sam9_smc_configure(2, &dm9000_smc_config);
|
sam9_smc_configure(2, &dm9000_smc_config);
|
||||||
|
|
||||||
register_device(&dm9000_dev);
|
add_dm9000_device(0, AT91_CHIPSELECT_2, AT91_CHIPSELECT_2 + 4,
|
||||||
|
IORESOURCE_MEM_16BIT, &dm9000_data);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static void __init ek_add_device_dm9000(void) {}
|
static void __init ek_add_device_dm9000(void) {}
|
||||||
|
@ -151,6 +130,7 @@ static int pm9261_devices_init(void)
|
||||||
{
|
{
|
||||||
at91_add_device_sdram(64 * 1024 * 1024);
|
at91_add_device_sdram(64 * 1024 * 1024);
|
||||||
pm_add_device_nand();
|
pm_add_device_nand();
|
||||||
|
pm_add_device_dm9000();
|
||||||
add_cfi_flash_device(0, AT91_CHIPSELECT_0, 4 * 1024 * 1024, 0);
|
add_cfi_flash_device(0, AT91_CHIPSELECT_0, 4 * 1024 * 1024, 0);
|
||||||
|
|
||||||
devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self");
|
devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self");
|
||||||
|
|
|
@ -35,31 +35,9 @@
|
||||||
#include <mach/devices-imx1.h>
|
#include <mach/devices-imx1.h>
|
||||||
|
|
||||||
static struct dm9000_platform_data dm9000_data = {
|
static struct dm9000_platform_data dm9000_data = {
|
||||||
.buswidth = IORESOURCE_MEM_16BIT,
|
|
||||||
.srom = 1,
|
.srom = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct resource dm9000_resources[] = {
|
|
||||||
[0] = {
|
|
||||||
.start = 0x16000000,
|
|
||||||
.size = 4,
|
|
||||||
.flags = IORESOURCE_MEM,
|
|
||||||
},
|
|
||||||
[1] = {
|
|
||||||
.start = 0x16000004,
|
|
||||||
.size = 4,
|
|
||||||
.flags = IORESOURCE_MEM,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct device_d dm9000_dev = {
|
|
||||||
.id = -1,
|
|
||||||
.name = "dm9000",
|
|
||||||
.num_resources = ARRAY_SIZE(dm9000_resources),
|
|
||||||
.resource = dm9000_resources,
|
|
||||||
.platform_data = &dm9000_data,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct gpio_led leds[] = {
|
struct gpio_led leds[] = {
|
||||||
{
|
{
|
||||||
.gpio = 32 + 21,
|
.gpio = 32 + 21,
|
||||||
|
@ -107,7 +85,8 @@ static int scb9328_devices_init(void)
|
||||||
sdram_dev = add_mem_device("ram0", 0x08000000, 16 * 1024 * 1024,
|
sdram_dev = add_mem_device("ram0", 0x08000000, 16 * 1024 * 1024,
|
||||||
IORESOURCE_MEM_WRITEABLE);
|
IORESOURCE_MEM_WRITEABLE);
|
||||||
armlinux_add_dram(sdram_dev);
|
armlinux_add_dram(sdram_dev);
|
||||||
register_device(&dm9000_dev);
|
add_dm9000_device(-1, 0x16000000, 0x16000004,
|
||||||
|
IORESOURCE_MEM_16BIT, &dm9000_data);
|
||||||
|
|
||||||
devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self0");
|
devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self0");
|
||||||
devfs_add_partition("nor0", 0x40000, 0x20000, PARTITION_FIXED, "env0");
|
devfs_add_partition("nor0", 0x40000, 0x20000, PARTITION_FIXED, "env0");
|
||||||
|
|
|
@ -25,15 +25,25 @@
|
||||||
#include <driver.h>
|
#include <driver.h>
|
||||||
#include <xfuncs.h>
|
#include <xfuncs.h>
|
||||||
|
|
||||||
struct device_d *add_generic_device(const char* devname, int id, const char *resname,
|
static struct device_d *alloc_device(const char* devname, int id, void *pdata)
|
||||||
resource_size_t start, resource_size_t size, unsigned int flags,
|
|
||||||
void *pdata)
|
|
||||||
{
|
{
|
||||||
struct device_d *dev;
|
struct device_d *dev;
|
||||||
|
|
||||||
dev = xzalloc(sizeof(*dev));
|
dev = xzalloc(sizeof(*dev));
|
||||||
strcpy(dev->name, devname);
|
strcpy(dev->name, devname);
|
||||||
dev->id = id;
|
dev->id = id;
|
||||||
|
dev->platform_data = pdata;
|
||||||
|
|
||||||
|
return dev;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct device_d *add_generic_device(const char* devname, int id, const char *resname,
|
||||||
|
resource_size_t start, resource_size_t size, unsigned int flags,
|
||||||
|
void *pdata)
|
||||||
|
{
|
||||||
|
struct device_d *dev;
|
||||||
|
|
||||||
|
dev = alloc_device(devname, id, pdata);
|
||||||
dev->resource = xzalloc(sizeof(struct resource));
|
dev->resource = xzalloc(sizeof(struct resource));
|
||||||
dev->num_resources = 1;
|
dev->num_resources = 1;
|
||||||
if (resname)
|
if (resname)
|
||||||
|
@ -41,10 +51,49 @@ struct device_d *add_generic_device(const char* devname, int id, const char *res
|
||||||
dev->resource[0].start = start;
|
dev->resource[0].start = start;
|
||||||
dev->resource[0].size = size;
|
dev->resource[0].size = size;
|
||||||
dev->resource[0].flags = flags;
|
dev->resource[0].flags = flags;
|
||||||
dev->platform_data = pdata;
|
|
||||||
|
|
||||||
register_device(dev);
|
register_device(dev);
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(add_generic_device);
|
EXPORT_SYMBOL(add_generic_device);
|
||||||
|
|
||||||
|
#ifdef CONFIG_DRIVER_NET_DM9000
|
||||||
|
struct device_d *add_dm9000_device(int id, resource_size_t base,
|
||||||
|
resource_size_t data, int flags, void *pdata)
|
||||||
|
{
|
||||||
|
struct device_d *dev;
|
||||||
|
resource_size_t size;
|
||||||
|
|
||||||
|
dev = alloc_device("dm9000", id, pdata);
|
||||||
|
dev->resource = xzalloc(sizeof(struct resource) * 2);
|
||||||
|
dev->num_resources = 2;
|
||||||
|
|
||||||
|
switch (flags) {
|
||||||
|
case IORESOURCE_MEM_32BIT:
|
||||||
|
size = 8;
|
||||||
|
break;
|
||||||
|
case IORESOURCE_MEM_16BIT:
|
||||||
|
size = 4;
|
||||||
|
break;
|
||||||
|
case IORESOURCE_MEM_8BIT:
|
||||||
|
size = 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("dm9000: memory width flag missing\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev->resource[0].start = base;
|
||||||
|
dev->resource[0].size = size;
|
||||||
|
dev->resource[0].flags = IORESOURCE_MEM | flags;
|
||||||
|
dev->resource[1].start = data;
|
||||||
|
dev->resource[1].size = size;
|
||||||
|
dev->resource[1].flags = IORESOURCE_MEM | flags;
|
||||||
|
|
||||||
|
register_device(dev);
|
||||||
|
|
||||||
|
return dev;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(add_dm9000_device);
|
||||||
|
#endif
|
||||||
|
|
|
@ -500,7 +500,8 @@ static int dm9000_probe(struct device_d *dev)
|
||||||
pdata = dev->platform_data;
|
pdata = dev->platform_data;
|
||||||
|
|
||||||
priv = edev->priv;
|
priv = edev->priv;
|
||||||
priv->buswidth = pdata->buswidth;
|
|
||||||
|
priv->buswidth = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
|
||||||
priv->iodata = dev_request_mem_region(dev, 1);
|
priv->iodata = dev_request_mem_region(dev, 1);
|
||||||
priv->iobase = dev_request_mem_region(dev, 0);
|
priv->iobase = dev_request_mem_region(dev, 0);
|
||||||
priv->srom = pdata->srom;
|
priv->srom = pdata->srom;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#define __DM9000_H__
|
#define __DM9000_H__
|
||||||
|
|
||||||
struct dm9000_platform_data {
|
struct dm9000_platform_data {
|
||||||
int buswidth;
|
|
||||||
int srom;
|
int srom;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -235,6 +235,17 @@ static inline struct device_d *add_ns16550_device(int id, resource_size_t start,
|
||||||
IORESOURCE_MEM, pdata);
|
IORESOURCE_MEM, pdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_DRIVER_NET_DM9000
|
||||||
|
struct device_d *add_dm9000_device(int id, resource_size_t base,
|
||||||
|
resource_size_t data, int flags, void *pdata);
|
||||||
|
#else
|
||||||
|
static inline struct device_d *add_dm9000_device(int id, resource_size_t base,
|
||||||
|
resource_size_t data, int flags, void *pdata)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* linear list over all available devices
|
/* linear list over all available devices
|
||||||
*/
|
*/
|
||||||
extern struct list_head device_list;
|
extern struct list_head device_list;
|
||||||
|
|
Loading…
Reference in New Issue