2 * Linux multi-function-device driver (MFD) for the integrated peripherals
3 * of the VIA VX855 chipset
5 * Copyright (C) 2009 VIA Technologies, Inc.
6 * Copyright (C) 2010 One Laptop per Child
7 * Author: Harald Welte <HaraldWelte@viatech.com>
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
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., 59 Temple Place, Suite 330, Boston,
27 #include <linux/kernel.h>
28 #include <linux/module.h>
29 #include <linux/device.h>
30 #include <linux/platform_device.h>
31 #include <linux/pci.h>
32 #include <linux/mfd/core.h>
34 /* offset into pci config space indicating the 16bit register containing
35 * the power management IO space base */
36 #define VX855_CFG_PMIO_OFFSET 0x88
38 /* ACPI I/O Space registers */
39 #define VX855_PMIO_ACPI 0x00
40 #define VX855_PMIO_ACPI_LEN 0x0b
42 /* Processor Power Management */
43 #define VX855_PMIO_PPM 0x10
44 #define VX855_PMIO_PPM_LEN 0x08
46 /* General Purpose Power Management */
47 #define VX855_PMIO_GPPM 0x20
48 #define VX855_PMIO_R_GPI 0x48
49 #define VX855_PMIO_R_GPO 0x4c
50 #define VX855_PMIO_GPPM_LEN 0x33
52 #define VSPIC_MMIO_SIZE 0x1000
54 static struct resource vx855_gpio_resources[] = {
56 .flags = IORESOURCE_IO,
59 .flags = IORESOURCE_IO,
63 static struct mfd_cell vx855_cells[] = {
66 .num_resources = ARRAY_SIZE(vx855_gpio_resources),
67 .resources = vx855_gpio_resources,
69 /* we must ignore resource conflicts, for reasons outlined in
70 * the vx855_gpio driver */
71 .ignore_resource_conflicts = true,
75 static __devinit int vx855_probe(struct pci_dev *pdev,
76 const struct pci_device_id *id)
81 ret = pci_enable_device(pdev);
85 pci_read_config_word(pdev, VX855_CFG_PMIO_OFFSET, &gpio_io_offset);
86 if (!gpio_io_offset) {
88 "BIOS did not assign PMIO base offset?!?\n");
93 /* mask out the lowest seven bits, as they are always zero, but
94 * hardware returns them as 0x01 */
95 gpio_io_offset &= 0xff80;
97 /* As the region identified here includes many non-GPIO things, we
98 * only work with the specific registers that concern us. */
99 vx855_gpio_resources[0].start = gpio_io_offset + VX855_PMIO_R_GPI;
100 vx855_gpio_resources[0].end = vx855_gpio_resources[0].start + 3;
101 vx855_gpio_resources[1].start = gpio_io_offset + VX855_PMIO_R_GPO;
102 vx855_gpio_resources[1].end = vx855_gpio_resources[1].start + 3;
104 ret = mfd_add_devices(&pdev->dev, -1, vx855_cells, ARRAY_SIZE(vx855_cells),
107 /* we always return -ENODEV here in order to enable other
108 * drivers like old, not-yet-platform_device ported i2c-viapro */
111 pci_disable_device(pdev);
115 static void __devexit vx855_remove(struct pci_dev *pdev)
117 mfd_remove_devices(&pdev->dev);
118 pci_disable_device(pdev);
121 static struct pci_device_id vx855_pci_tbl[] = {
122 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855) },
125 MODULE_DEVICE_TABLE(pci, vx855_pci_tbl);
127 static struct pci_driver vx855_pci_driver = {
129 .id_table = vx855_pci_tbl,
130 .probe = vx855_probe,
131 .remove = __devexit_p(vx855_remove),
134 static int vx855_init(void)
136 return pci_register_driver(&vx855_pci_driver);
138 module_init(vx855_init);
140 static void vx855_exit(void)
142 pci_unregister_driver(&vx855_pci_driver);
144 module_exit(vx855_exit);
146 MODULE_LICENSE("GPL");
147 MODULE_AUTHOR("Harald Welte <HaraldWelte@viatech.com>");
148 MODULE_DESCRIPTION("Driver for the VIA VX855 chipset");