MIPS: Alchemy: Basic support for the DB1300 board.
[linux-2.6.git] / drivers / pcmcia / ds.c
index 0bb780c..749c2a1 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/dma-mapping.h>
 #include <linux/slab.h>
 
-#include <pcmcia/cs.h>
 #include <pcmcia/cistpl.h>
 #include <pcmcia/ds.h>
 #include <pcmcia/ss.h>
@@ -46,13 +45,13 @@ MODULE_LICENSE("GPL");
 
 static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
 {
-       struct pcmcia_device_id *did = p_drv->id_table;
+       const struct pcmcia_device_id *did = p_drv->id_table;
        unsigned int i;
        u32 hash;
 
        if (!p_drv->probe || !p_drv->remove)
                printk(KERN_DEBUG "pcmcia: %s lacks a requisite callback "
-                      "function\n", p_drv->drv.name);
+                      "function\n", p_drv->name);
 
        while (did && did->match_flags) {
                for (i = 0; i < 4; i++) {
@@ -65,7 +64,7 @@ static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
 
                        printk(KERN_DEBUG "pcmcia: %s: invalid hash for "
                               "product string \"%s\": is 0x%x, should "
-                              "be 0x%x\n", p_drv->drv.name, did->prod_id[i],
+                              "be 0x%x\n", p_drv->name, did->prod_id[i],
                               did->prod_id_hash[i], hash);
                        printk(KERN_DEBUG "pcmcia: see "
                                "Documentation/pcmcia/devicetable.txt for "
@@ -180,10 +179,11 @@ int pcmcia_register_driver(struct pcmcia_driver *driver)
        /* initialize common fields */
        driver->drv.bus = &pcmcia_bus_type;
        driver->drv.owner = driver->owner;
+       driver->drv.name = driver->name;
        mutex_init(&driver->dynids.lock);
        INIT_LIST_HEAD(&driver->dynids.list);
 
-       pr_debug("registering driver %s\n", driver->drv.name);
+       pr_debug("registering driver %s\n", driver->name);
 
        error = driver_register(&driver->drv);
        if (error < 0)
@@ -203,7 +203,7 @@ EXPORT_SYMBOL(pcmcia_register_driver);
  */
 void pcmcia_unregister_driver(struct pcmcia_driver *driver)
 {
-       pr_debug("unregistering driver %s\n", driver->drv.name);
+       pr_debug("unregistering driver %s\n", driver->name);
        driver_unregister(&driver->drv);
        pcmcia_free_dynids(driver);
 }
@@ -264,7 +264,7 @@ static int pcmcia_device_probe(struct device *dev)
        p_drv = to_pcmcia_drv(dev->driver);
        s = p_dev->socket;
 
-       dev_dbg(dev, "trying to bind to %s\n", p_drv->drv.name);
+       dev_dbg(dev, "trying to bind to %s\n", p_drv->name);
 
        if ((!p_drv->probe) || (!p_dev->function_config) ||
            (!try_module_get(p_drv->owner))) {
@@ -276,21 +276,28 @@ static int pcmcia_device_probe(struct device *dev)
        ret = pccard_read_tuple(p_dev->socket, p_dev->func, CISTPL_CONFIG,
                                &cis_config);
        if (!ret) {
-               p_dev->conf.ConfigBase = cis_config.base;
-               p_dev->conf.Present = cis_config.rmask[0];
+               p_dev->config_base = cis_config.base;
+               p_dev->config_regs = cis_config.rmask[0];
+               dev_dbg(dev, "base %x, regs %x", p_dev->config_base,
+                       p_dev->config_regs);
        } else {
                dev_printk(KERN_INFO, dev,
                           "pcmcia: could not parse base and rmask0 of CIS\n");
-               p_dev->conf.ConfigBase = 0;
-               p_dev->conf.Present = 0;
+               p_dev->config_base = 0;
+               p_dev->config_regs = 0;
        }
 
        ret = p_drv->probe(p_dev);
        if (ret) {
                dev_dbg(dev, "binding to %s failed with %d\n",
-                          p_drv->drv.name, ret);
+                          p_drv->name, ret);
                goto put_module;
        }
+       dev_dbg(dev, "%s bound: Vpp %d.%d, idx %x, IRQ %d", p_drv->name,
+               p_dev->vpp/10, p_dev->vpp%10, p_dev->config_index, p_dev->irq);
+       dev_dbg(dev, "resources: ioport %pR %pR iomem %pR %pR %pR",
+               p_dev->resource[0], p_dev->resource[1], p_dev->resource[2],
+               p_dev->resource[3], p_dev->resource[4]);
 
        mutex_lock(&s->ops_mutex);
        if ((s->pcmcia_pfc) &&
@@ -374,13 +381,13 @@ static int pcmcia_device_remove(struct device *dev)
        if (p_dev->_irq || p_dev->_io || p_dev->_locked)
                dev_printk(KERN_INFO, dev,
                        "pcmcia: driver %s did not release config properly\n",
-                       p_drv->drv.name);
+                       p_drv->name);
 
        for (i = 0; i < MAX_WIN; i++)
                if (p_dev->_win & CLIENT_WIN_REQ(i))
                        dev_printk(KERN_INFO, dev,
                          "pcmcia: driver %s did not release window properly\n",
-                          p_drv->drv.name);
+                          p_drv->name);
 
        /* references from pcmcia_probe_device */
        pcmcia_put_dev(p_dev);
@@ -553,11 +560,11 @@ static struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s,
                p_dev->function_config = c;
                kref_init(&c->ref);
                for (i = 0; i < MAX_IO_WIN; i++) {
-                       c->io[i].name = dev_name(&p_dev->dev);
+                       c->io[i].name = p_dev->devname;
                        c->io[i].flags = IORESOURCE_IO;
                }
                for (i = 0; i< MAX_WIN; i++) {
-                       c->mem[i].name = dev_name(&p_dev->dev);
+                       c->mem[i].name = p_dev->devname;
                        c->mem[i].flags = IORESOURCE_MEM;
                }
        }
@@ -777,7 +784,7 @@ static inline int pcmcia_load_firmware(struct pcmcia_device *dev, char * filenam
 
 
 static inline int pcmcia_devmatch(struct pcmcia_device *dev,
-                                 struct pcmcia_device_id *did)
+                                 const struct pcmcia_device_id *did)
 {
        if (did->match_flags & PCMCIA_DEV_ID_MATCH_MANF_ID) {
                if ((!dev->has_manf_id) || (dev->manf_id != did->manf_id))
@@ -883,7 +890,7 @@ static int pcmcia_bus_match(struct device *dev, struct device_driver *drv)
 {
        struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
        struct pcmcia_driver *p_drv = to_pcmcia_drv(drv);
-       struct pcmcia_device_id *did = p_drv->id_table;
+       const struct pcmcia_device_id *did = p_drv->id_table;
        struct pcmcia_dynid *dynid;
 
        /* match dynamic devices first */
@@ -1011,6 +1018,18 @@ pcmcia_device_stringattr(prod_id2, prod_id[1]);
 pcmcia_device_stringattr(prod_id3, prod_id[2]);
 pcmcia_device_stringattr(prod_id4, prod_id[3]);
 
+static ssize_t pcmcia_show_resources(struct device *dev,
+                                    struct device_attribute *attr, char *buf)
+{
+       struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
+       char *str = buf;
+       int i;
+
+       for (i = 0; i < PCMCIA_NUM_RESOURCES; i++)
+               str += sprintf(str, "%pr\n", p_dev->resource[i]);
+
+       return str - buf;
+}
 
 static ssize_t pcmcia_show_pm_state(struct device *dev, struct device_attribute *attr, char *buf)
 {
@@ -1081,6 +1100,7 @@ static ssize_t pcmcia_store_allow_func_id_match(struct device *dev,
 static struct device_attribute pcmcia_dev_attrs[] = {
        __ATTR(function, 0444, func_show, NULL),
        __ATTR(pm_state, 0644, pcmcia_show_pm_state, pcmcia_store_pm_state),
+       __ATTR(resources, 0444, pcmcia_show_resources, NULL),
        __ATTR_RO(func_id),
        __ATTR_RO(manf_id),
        __ATTR_RO(card_id),
@@ -1123,7 +1143,7 @@ static int pcmcia_dev_suspend(struct device *dev, pm_message_t state)
                        dev_printk(KERN_ERR, dev,
                                   "pcmcia: device %s (driver %s) did "
                                   "not want to go to sleep (%d)\n",
-                                  p_dev->devname, p_drv->drv.name, ret);
+                                  p_dev->devname, p_drv->name, ret);
                        mutex_lock(&p_dev->socket->ops_mutex);
                        p_dev->suspended = 0;
                        mutex_unlock(&p_dev->socket->ops_mutex);
@@ -1165,7 +1185,7 @@ static int pcmcia_dev_resume(struct device *dev)
 
        if (p_dev->device_no == p_dev->func) {
                dev_dbg(dev, "requesting configuration\n");
-               ret = pcmcia_request_configuration(p_dev, &p_dev->conf);
+               ret = pcmcia_enable_device(p_dev);
                if (ret)
                        goto out;
        }