2 * Broadcom 43xx PCMCIA-SSB bridge module
4 * Copyright (c) 2007 Michael Buesch <m@bues.ch>
6 * Licensed under the GNU/GPL. See COPYING for details.
9 #include "ssb_private.h"
11 #include <linux/ssb/ssb.h>
12 #include <linux/slab.h>
13 #include <linux/module.h>
15 #include <pcmcia/cistpl.h>
16 #include <pcmcia/ciscode.h>
17 #include <pcmcia/ds.h>
18 #include <pcmcia/cisreg.h>
20 static const struct pcmcia_device_id ssb_host_pcmcia_tbl[] = {
21 PCMCIA_DEVICE_MANF_CARD(0x2D0, 0x448),
22 PCMCIA_DEVICE_MANF_CARD(0x2D0, 0x476),
26 MODULE_DEVICE_TABLE(pcmcia, ssb_host_pcmcia_tbl);
28 static int ssb_host_pcmcia_probe(struct pcmcia_device *dev)
34 ssb = kzalloc(sizeof(*ssb), GFP_KERNEL);
40 dev->config_flags |= CONF_ENABLE_IRQ;
42 dev->resource[2]->flags |= WIN_ENABLE | WIN_DATA_WIDTH_16 |
44 dev->resource[2]->start = 0;
45 dev->resource[2]->end = SSB_CORE_SIZE;
46 res = pcmcia_request_window(dev, dev->resource[2], 250);
50 res = pcmcia_map_mem_page(dev, dev->resource[2], 0);
57 res = pcmcia_enable_device(dev);
61 err = ssb_bus_pcmciabus_register(ssb, dev, dev->resource[2]->start);
69 pcmcia_disable_device(dev);
73 dev_err(&dev->dev, "Initialization failed (%d, %d)\n", res, err);
77 static void ssb_host_pcmcia_remove(struct pcmcia_device *dev)
79 struct ssb_bus *ssb = dev->priv;
81 ssb_bus_unregister(ssb);
82 pcmcia_disable_device(dev);
88 static int ssb_host_pcmcia_suspend(struct pcmcia_device *dev)
90 struct ssb_bus *ssb = dev->priv;
92 return ssb_bus_suspend(ssb);
95 static int ssb_host_pcmcia_resume(struct pcmcia_device *dev)
97 struct ssb_bus *ssb = dev->priv;
99 return ssb_bus_resume(ssb);
101 #else /* CONFIG_PM */
102 # define ssb_host_pcmcia_suspend NULL
103 # define ssb_host_pcmcia_resume NULL
104 #endif /* CONFIG_PM */
106 static struct pcmcia_driver ssb_host_pcmcia_driver = {
107 .owner = THIS_MODULE,
108 .name = "ssb-pcmcia",
109 .id_table = ssb_host_pcmcia_tbl,
110 .probe = ssb_host_pcmcia_probe,
111 .remove = ssb_host_pcmcia_remove,
112 .suspend = ssb_host_pcmcia_suspend,
113 .resume = ssb_host_pcmcia_resume,
116 static int pcmcia_init_failed;
119 * These are not module init/exit functions!
120 * The module_pcmcia_driver() helper cannot be used here.
122 int ssb_host_pcmcia_init(void)
124 pcmcia_init_failed = pcmcia_register_driver(&ssb_host_pcmcia_driver);
126 return pcmcia_init_failed;
129 void ssb_host_pcmcia_exit(void)
131 if (!pcmcia_init_failed)
132 pcmcia_unregister_driver(&ssb_host_pcmcia_driver);