20 #include <linux/kernel.h>
21 #include <linux/module.h>
23 #include <linux/errno.h>
24 #include <linux/device.h>
25 #include <linux/slab.h>
26 #include <linux/list.h>
29 #include <linux/pci.h>
55 if (!pdev && !list_empty(&sta2x11_mfd_list)) {
57 "using first instance\n", __func__);
82 mfd = kzalloc(
sizeof(*mfd), flags);
85 INIT_LIST_HEAD(&mfd->
list);
88 list_add(&mfd->
list, &sta2x11_mfd_list);
111 dev_warn(&pdev->
dev,
": can't access sctl regs\n");
115 dev_warn(&pdev->
dev,
": system ctl not initialized\n");
124 spin_unlock_irqrestore(&mfd->
lock, flags);
140 dev_warn(&pdev->
dev,
": apb bridge not initialized\n");
149 spin_unlock_irqrestore(&mfd->
lock, flags);
155 #define REG(regname) {.name = #regname, .offset = SCTL_ ## regname}
158 REG(SCRESFRACT),
REG(SCRESCTRL1),
REG(SCRESXTRL2),
REG(SCPEREN0),
159 REG(SCPEREN1),
REG(SCPEREN2),
REG(SCGRST),
REG(SCPCIPMCR1),
160 REG(SCPCIPMCR2),
REG(SCPCIPMSR1),
REG(SCPCIPMSR2),
REG(SCPCIPMSR3),
161 REG(SCINTREN),
REG(SCRISR),
REG(SCCLKSTAT0),
REG(SCCLKSTAT1),
162 REG(SCCLKSTAT2),
REG(SCRSTSTA),
167 .regs = sta2x11_sctl_regs,
171 #define REG(regname) {.name = #regname, .offset = regname}
179 .regs = sta2x11_apbreg_regs,
183 static struct dentry *sta2x11_sctl_debugfs;
184 static struct dentry *sta2x11_apbreg_debugfs;
193 pdev = dev->
dev.platform_data;
194 mfd = sta2x11_mfd_find(*pdev);
212 sta2x11_sctl_debugfs = debugfs_create_regset32(
"sta2x11-sctl",
224 pdev = dev->
dev.platform_data;
225 dev_dbg(&dev->
dev,
"%s: pdata is %p\n", __func__, pdev);
226 dev_dbg(&dev->
dev,
"%s: *pdata is %p\n", __func__, *pdev);
228 mfd = sta2x11_mfd_find(*pdev);
248 sta2x11_apbreg_debugfs = debugfs_create_regset32(
"sta2x11-apbreg",
250 NULL, &apbreg_regset);
257 .name =
"sta2x11-sctl",
260 .probe = sta2x11_sctl_probe,
263 static int __init sta2x11_sctl_init(
void)
271 .name =
"sta2x11-apbreg",
274 .probe = sta2x11_apbreg_probe,
277 static int __init sta2x11_apbreg_init(
void)
302 #define CELL_4K(_name, _cell) { \
304 .start = _cell * 4096, .end = _cell * 4096 + 4095, \
305 .flags = IORESOURCE_MEM, \
310 .name =
"sta2x11_gpio",
312 .end = (4 * 4096) - 1,
330 #define DEV(_name, _r) \
331 { .name = _name, .num_resources = ARRAY_SIZE(_r), .resources = _r, }
334 DEV(
"sta2x11-gpio", gpio_resources),
335 DEV(
"sta2x11-sctl", sctl_resources),
336 DEV(
"sta2x11-scr", scr_resources),
337 DEV(
"sta2x11-time", time_resources),
341 DEV(
"sta2x11-apbreg", apbreg_resources),
353 static int sta2x11_mfd_resume(
struct pci_dev *pdev)
376 dev_err(&pdev->
dev,
"Can't enable device.\n");
380 err = pci_enable_msi(pdev);
385 gpio_data = dev_get_platdata(&pdev->
dev);
389 dev_dbg(&pdev->
dev,
"%s, gpio_data = %p (%p)\n", __func__,
390 gpio_data, &gpio_data);
391 dev_dbg(&pdev->
dev,
"%s, pdev = %p (%p)\n", __func__,
395 for (i = 0; i <
ARRAY_SIZE(sta2x11_mfd_bar0); i++) {
399 sta2x11_mfd_bar1[0].
pdata_size =
sizeof(pdev);
412 dev_err(&pdev->
dev,
"mfd_add_devices[0] failed: %d\n", err);
422 dev_err(&pdev->
dev,
"mfd_add_devices[1] failed: %d\n", err);
440 static struct pci_driver sta2x11_mfd_driver = {
441 .name =
"sta2x11-mfd",
442 .id_table = sta2x11_mfd_tbl,
443 .probe = sta2x11_mfd_probe,
444 .suspend = sta2x11_mfd_suspend,
445 .resume = sta2x11_mfd_resume,
448 static int __init sta2x11_mfd_init(
void)
451 return pci_register_driver(&sta2x11_mfd_driver);