Commit 299c2e86 authored by Russell King's avatar Russell King

[ARM] Convert ecard to allow use of ioremap + {read,write}[bwl]

parent a7c4fb64
......@@ -881,6 +881,90 @@ static void ecard_proc_init(void)
get_ecard_dev_info);
}
#define ec_set_resource(ec,nr,st,sz,flg) \
do { \
(ec)->resource[nr].name = ec->dev.name; \
(ec)->resource[nr].start = st; \
(ec)->resource[nr].end = (st) + (sz) - 1; \
(ec)->resource[nr].flags = flg; \
} while (0)
static void __init ecard_init_resources(struct expansion_card *ec)
{
unsigned long base = PODSLOT_IOC4_BASE;
unsigned int slot = ec->slot_no;
int i;
if (slot < 4) {
ec_set_resource(ec, ECARD_RES_MEMC,
PODSLOT_MEMC_BASE + (slot << 14),
PODSLOT_MEMC_SIZE, IORESOURCE_MEM);
base = PODSLOT_IOC0_BASE;
}
#ifdef CONFIG_ARCH_RPC
if (slot < 8) {
ec_set_resource(ec, ECARD_RES_EASI,
PODSLOT_EASI_BASE + (slot << 24),
PODSLOT_EASI_SIZE, IORESOURCE_MEM);
}
if (slot == 8) {
ec_set_resource(ec, ECARD_RES_MEMC, NETSLOT_BASE,
NETSLOT_SIZE, IORESOURCE_MEM);
} else
#endif
for (i = 0; i < ECARD_RES_IOCSYNC - ECARD_RES_IOCSLOW; i++) {
ec_set_resource(ec, i + ECARD_RES_IOCSLOW,
base + (slot << 14) + (i << 19),
PODSLOT_IOC_SIZE, IORESOURCE_MEM);
}
for (i = 0; i < ECARD_NUM_RESOURCES; i++) {
if (ec->resource[i].start &&
request_resource(&iomem_resource, &ec->resource[i])) {
printk(KERN_ERR "%s: resource(s) not available\n",
ec->dev.bus_id);
ec->resource[i].end -= ec->resource[i].start;
ec->resource[i].start = 0;
}
}
}
static ssize_t ecard_show_irq(struct device *dev, char *buf)
{
struct expansion_card *ec = ECARD_DEV(dev);
return sprintf(buf, "%u\n", ec->irq);
}
static DEVICE_ATTR(irq, S_IRUGO, ecard_show_irq, NULL);
static ssize_t ecard_show_dma(struct device *dev, char *buf)
{
struct expansion_card *ec = ECARD_DEV(dev);
return sprintf(buf, "%u\n", ec->dma);
}
static DEVICE_ATTR(dma, S_IRUGO, ecard_show_dma, NULL);
static ssize_t ecard_show_resources(struct device *dev, char *buf)
{
struct expansion_card *ec = ECARD_DEV(dev);
char *str = buf;
int i;
for (i = 0; i < ECARD_NUM_RESOURCES; i++)
str += sprintf(str, "%08lx %08lx %08lx\n",
ec->resource[i].start,
ec->resource[i].end,
ec->resource[i].flags);
return str - buf;
}
static DEVICE_ATTR(resource, S_IRUGO, ecard_show_resources, NULL);
/*
* Probe for an expansion card.
*
......@@ -949,6 +1033,16 @@ ecard_probe(int slot, card_type_t type)
break;
}
snprintf(ec->dev.bus_id, sizeof(ec->dev.bus_id), "ecard%d", slot);
snprintf(ec->dev.name, sizeof(ec->dev.name), "ecard %04x:%04x",
ec->cid.manufacturer, ec->cid.product);
ec->dev.parent = NULL;
ec->dev.bus = &ecard_bus_type;
ec->dev.dma_mask = &ec->dma_mask;
ec->dma_mask = (u64)0xffffffff;
ecard_init_resources(ec);
/*
* hook the interrupt handlers
*/
......@@ -974,14 +1068,10 @@ ecard_probe(int slot, card_type_t type)
*ecp = ec;
slot_to_expcard[slot] = ec;
snprintf(ec->dev.bus_id, sizeof(ec->dev.bus_id), "ecard%d", slot);
strcpy(ec->dev.name, "fixme!");
ec->dev.parent = NULL;
ec->dev.bus = &ecard_bus_type;
ec->dev.dma_mask = &ec->dma_mask;
ec->dma_mask = (u64)0xffffffff;
device_register(&ec->dev);
device_create_file(&ec->dev, &dev_attr_dma);
device_create_file(&ec->dev, &dev_attr_irq);
device_create_file(&ec->dev, &dev_attr_resource);
return 0;
......
......@@ -63,6 +63,17 @@
#define IO_EC_MEMC8_BASE 0x8000ac00
#define IO_EC_MEMC_BASE 0x80000000
#define NETSLOT_BASE 0x0302b000
#define NETSLOT_SIZE 0x00001000
#define PODSLOT_IOC0_BASE 0x03240000
#define PODSLOT_IOC4_BASE 0x03270000
#define PODSLOT_IOC_SIZE (1 << 14)
#define PODSLOT_MEMC_BASE 0x03000000
#define PODSLOT_MEMC_SIZE (1 << 14)
#define PODSLOT_EASI_BASE 0x08000000
#define PODSLOT_EASI_SIZE (1 << 24)
#define EXPMASK_STATUS (EXPMASK_BASE + 0x00)
#define EXPMASK_ENABLE (EXPMASK_BASE + 0x04)
......
......@@ -130,6 +130,20 @@ typedef struct { /* Card handler routines */
int (*fiqpending)(ecard_t *ec);
} expansioncard_ops_t;
#define ECARD_NUM_RESOURCES (6)
#define ECARD_RES_IOCSLOW (0)
#define ECARD_RES_IOCMEDIUM (1)
#define ECARD_RES_IOCFAST (2)
#define ECARD_RES_IOCSYNC (3)
#define ECARD_RES_MEMC (4)
#define ECARD_RES_EASI (5)
#define ecard_resource_start(ec,nr) ((ec)->resource[nr].start)
#define ecard_resource_end(ec,nr) ((ec)->resource[nr].end)
#define ecard_resource_len(ec,nr) ((ec)->resource[nr].end - \
(ec)->resource[nr].start + 1)
/*
* This contains all the info needed on an expansion card
*/
......@@ -137,6 +151,7 @@ struct expansion_card {
struct expansion_card *next;
struct device dev;
struct resource resource[ECARD_NUM_RESOURCES];
/* Public data */
volatile unsigned char *irqaddr; /* address of IRQ register */
......@@ -147,7 +162,7 @@ struct expansion_card {
void *irq_data; /* Data for use for IRQ by card */
void *fiq_data; /* Data for use for FIQ by card */
expansioncard_ops_t *ops; /* Enable/Disable Ops for card */
const expansioncard_ops_t *ops; /* Enable/Disable Ops for card */
CONST unsigned int slot_no; /* Slot number */
CONST unsigned int dma; /* DMA number (for request_dma) */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment