aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2010-09-30 16:55:41 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2010-10-28 18:29:49 -0400
commit375fc77ba950e388f29d11cb3279ada5e5c1580c (patch)
tree09269b97938cac25d8c27f4fd94ce5b66bae258d /drivers/mfd
parent5f2545fa156f3d4d327038d7664608e146809a3c (diff)
mfd: Add VIA VX855 multi-function device support
This device has GPIO, SPI and I2C capabilities. The hardware can be found in the OLPC XO-1.5 laptop. Based on earlier work by Harald Welte. Signed-off-by: Daniel Drake <dsd@laptop.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/Kconfig9
-rw-r--r--drivers/mfd/Makefile1
-rw-r--r--drivers/mfd/vx855.c147
3 files changed, 157 insertions, 0 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 256fabd7d65..9735f581574 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -576,6 +576,15 @@ config MFD_TPS6586X
576 This driver can also be built as a module. If so, the module 576 This driver can also be built as a module. If so, the module
577 will be called tps6586x. 577 will be called tps6586x.
578 578
579config MFD_VX855
580 tristate "Support for VIA VX855/VX875 integrated south bridge"
581 depends on PCI
582 select MFD_CORE
583 help
584 Say yes here to enable support for various functions of the
585 VIA VX855/VX875 south bridge. You will need to enable the vx855_spi
586 and/or vx855_gpio drivers for this to do anything useful.
587
579endif # MFD_SUPPORT 588endif # MFD_SUPPORT
580 589
581menu "Multimedia Capabilities Port drivers" 590menu "Multimedia Capabilities Port drivers"
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index d5968cd9304..d18a6ab2ab5 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -78,3 +78,4 @@ obj-$(CONFIG_MFD_RDC321X) += rdc321x-southbridge.o
78obj-$(CONFIG_MFD_JANZ_CMODIO) += janz-cmodio.o 78obj-$(CONFIG_MFD_JANZ_CMODIO) += janz-cmodio.o
79obj-$(CONFIG_MFD_JZ4740_ADC) += jz4740-adc.o 79obj-$(CONFIG_MFD_JZ4740_ADC) += jz4740-adc.o
80obj-$(CONFIG_MFD_TPS6586X) += tps6586x.o 80obj-$(CONFIG_MFD_TPS6586X) += tps6586x.o
81obj-$(CONFIG_MFD_VX855) += vx855.o
diff --git a/drivers/mfd/vx855.c b/drivers/mfd/vx855.c
new file mode 100644
index 00000000000..ebb059765ed
--- /dev/null
+++ b/drivers/mfd/vx855.c
@@ -0,0 +1,147 @@
1/*
2 * Linux multi-function-device driver (MFD) for the integrated peripherals
3 * of the VIA VX855 chipset
4 *
5 * Copyright (C) 2009 VIA Technologies, Inc.
6 * Copyright (C) 2010 One Laptop per Child
7 * Author: Harald Welte <HaraldWelte@viatech.com>
8 * All rights reserved.
9 *
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.
14 *
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.
19 *
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,
23 * MA 02111-1307 USA
24 *
25 */
26
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>
33
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
37
38/* ACPI I/O Space registers */
39#define VX855_PMIO_ACPI 0x00
40#define VX855_PMIO_ACPI_LEN 0x0b
41
42/* Processor Power Management */
43#define VX855_PMIO_PPM 0x10
44#define VX855_PMIO_PPM_LEN 0x08
45
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
51
52#define VSPIC_MMIO_SIZE 0x1000
53
54static struct resource vx855_gpio_resources[] = {
55 {
56 .flags = IORESOURCE_IO,
57 },
58 {
59 .flags = IORESOURCE_IO,
60 },
61};
62
63static struct mfd_cell vx855_cells[] = {
64 {
65 .name = "vx855_gpio",
66 .num_resources = ARRAY_SIZE(vx855_gpio_resources),
67 .resources = vx855_gpio_resources,
68
69 /* we must ignore resource conflicts, for reasons outlined in
70 * the vx855_gpio driver */
71 .ignore_resource_conflicts = true,
72 },
73};
74
75static __devinit int vx855_probe(struct pci_dev *pdev,
76 const struct pci_device_id *id)
77{
78 int ret;
79 u16 gpio_io_offset;
80
81 ret = pci_enable_device(pdev);
82 if (ret)
83 return -ENODEV;
84
85 pci_read_config_word(pdev, VX855_CFG_PMIO_OFFSET, &gpio_io_offset);
86 if (!gpio_io_offset) {
87 dev_warn(&pdev->dev,
88 "BIOS did not assign PMIO base offset?!?\n");
89 ret = -ENODEV;
90 goto out;
91 }
92
93 /* mask out the lowest seven bits, as they are always zero, but
94 * hardware returns them as 0x01 */
95 gpio_io_offset &= 0xff80;
96
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;
103
104 ret = mfd_add_devices(&pdev->dev, -1, vx855_cells, ARRAY_SIZE(vx855_cells),
105 NULL, 0);
106
107 /* we always return -ENODEV here in order to enable other
108 * drivers like old, not-yet-platform_device ported i2c-viapro */
109 return -ENODEV;
110out:
111 pci_disable_device(pdev);
112 return ret;
113}
114
115static void vx855_remove(struct pci_dev *pdev)
116{
117 mfd_remove_devices(&pdev->dev);
118 pci_disable_device(pdev);
119}
120
121static struct pci_device_id vx855_pci_tbl[] = {
122 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855) },
123 { 0, }
124};
125
126static struct pci_driver vx855_pci_driver = {
127 .name = "vx855",
128 .id_table = vx855_pci_tbl,
129 .probe = vx855_probe,
130 .remove = __devexit_p(vx855_remove),
131};
132
133static int vx855_init(void)
134{
135 return pci_register_driver(&vx855_pci_driver);
136}
137module_init(vx855_init);
138
139static void vx855_exit(void)
140{
141 pci_unregister_driver(&vx855_pci_driver);
142}
143module_exit(vx855_exit);
144
145MODULE_LICENSE("GPL");
146MODULE_AUTHOR("Harald Welte <HaraldWelte@viatech.com>");
147MODULE_DESCRIPTION("Driver for the VIA VX855 chipset");