2 * cs5535-mfd.c - core MFD driver for CS5535/CS5536 southbridges
4 * The CS5535 and CS5536 has an ISA bridge on the PCI bus that is
5 * used for accessing GPIOs, MFGPTs, ACPI, etc. Each subdevice has
6 * an IO range that's specified in a single BAR. The BAR order is
7 * hardcoded in the CS553x specifications.
9 * Copyright (c) 2010 Andres Salomon <dilinger@queued.net>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include <linux/kernel.h>
26 #include <linux/init.h>
27 #include <linux/mfd/core.h>
28 #include <linux/module.h>
29 #include <linux/pci.h>
31 #define DRV_NAME "cs5535-mfd"
33 enum cs5535_mfd_bars
{
42 static __devinitdata
struct resource cs5535_mfd_resources
[NR_BARS
];
44 static __devinitdata
struct mfd_cell cs5535_mfd_cells
[] = {
49 .resources
= &cs5535_mfd_resources
[SMB_BAR
],
53 .name
= "cs5535-gpio",
55 .resources
= &cs5535_mfd_resources
[GPIO_BAR
],
59 .name
= "cs5535-mfgpt",
61 .resources
= &cs5535_mfd_resources
[MFGPT_BAR
],
67 .resources
= &cs5535_mfd_resources
[PMS_BAR
],
71 .name
= "cs5535-acpi",
73 .resources
= &cs5535_mfd_resources
[ACPI_BAR
],
77 static int __devinit
cs5535_mfd_probe(struct pci_dev
*pdev
,
78 const struct pci_device_id
*id
)
82 err
= pci_enable_device(pdev
);
86 /* fill in IO range for each cell; subdrivers handle the region */
87 for (i
= 0; i
< ARRAY_SIZE(cs5535_mfd_cells
); i
++) {
88 int bar
= cs5535_mfd_cells
[i
].id
;
89 struct resource
*r
= &cs5535_mfd_resources
[bar
];
91 r
->flags
= IORESOURCE_IO
;
92 r
->start
= pci_resource_start(pdev
, bar
);
93 r
->end
= pci_resource_end(pdev
, bar
);
95 /* id is used for temporarily storing BAR; unset it now */
96 cs5535_mfd_cells
[i
].id
= 0;
99 err
= mfd_add_devices(&pdev
->dev
, -1, cs5535_mfd_cells
,
100 ARRAY_SIZE(cs5535_mfd_cells
), NULL
, 0);
102 dev_err(&pdev
->dev
, "MFD add devices failed: %d\n", err
);
106 dev_info(&pdev
->dev
, "%zu devices registered.\n",
107 ARRAY_SIZE(cs5535_mfd_cells
));
112 pci_disable_device(pdev
);
116 static void __devexit
cs5535_mfd_remove(struct pci_dev
*pdev
)
118 mfd_remove_devices(&pdev
->dev
);
119 pci_disable_device(pdev
);
122 static struct pci_device_id cs5535_mfd_pci_tbl
[] = {
123 { PCI_DEVICE(PCI_VENDOR_ID_NS
, PCI_DEVICE_ID_NS_CS5535_ISA
) },
124 { PCI_DEVICE(PCI_VENDOR_ID_AMD
, PCI_DEVICE_ID_AMD_CS5536_ISA
) },
127 MODULE_DEVICE_TABLE(pci
, cs5535_mfd_pci_tbl
);
129 static struct pci_driver cs5535_mfd_drv
= {
131 .id_table
= cs5535_mfd_pci_tbl
,
132 .probe
= cs5535_mfd_probe
,
133 .remove
= __devexit_p(cs5535_mfd_remove
),
136 static int __init
cs5535_mfd_init(void)
138 return pci_register_driver(&cs5535_mfd_drv
);
141 static void __exit
cs5535_mfd_exit(void)
143 pci_unregister_driver(&cs5535_mfd_drv
);
146 module_init(cs5535_mfd_init
);
147 module_exit(cs5535_mfd_exit
);
149 MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>");
150 MODULE_DESCRIPTION("MFD driver for CS5535/CS5536 southbridge's ISA PCI device");
151 MODULE_LICENSE("GPL");