blob: 985f81c1739c62c6e8be0d08cb6907d8c29136e8 [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Daniel Drake375fc772010-09-30 21:55:41 +01002/*
3 * Linux multi-function-device driver (MFD) for the integrated peripherals
4 * of the VIA VX855 chipset
5 *
6 * Copyright (C) 2009 VIA Technologies, Inc.
7 * Copyright (C) 2010 One Laptop per Child
8 * Author: Harald Welte <HaraldWelte@viatech.com>
9 * All rights reserved.
Daniel Drake375fc772010-09-30 21:55:41 +010010 */
11
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/device.h>
15#include <linux/platform_device.h>
16#include <linux/pci.h>
17#include <linux/mfd/core.h>
18
19/* offset into pci config space indicating the 16bit register containing
20 * the power management IO space base */
21#define VX855_CFG_PMIO_OFFSET 0x88
22
23/* ACPI I/O Space registers */
24#define VX855_PMIO_ACPI 0x00
25#define VX855_PMIO_ACPI_LEN 0x0b
26
27/* Processor Power Management */
28#define VX855_PMIO_PPM 0x10
29#define VX855_PMIO_PPM_LEN 0x08
30
31/* General Purpose Power Management */
32#define VX855_PMIO_GPPM 0x20
33#define VX855_PMIO_R_GPI 0x48
34#define VX855_PMIO_R_GPO 0x4c
35#define VX855_PMIO_GPPM_LEN 0x33
36
37#define VSPIC_MMIO_SIZE 0x1000
38
39static struct resource vx855_gpio_resources[] = {
40 {
41 .flags = IORESOURCE_IO,
42 },
43 {
44 .flags = IORESOURCE_IO,
45 },
46};
47
Geert Uytterhoeven5ac98552013-11-18 14:33:06 +010048static const struct mfd_cell vx855_cells[] = {
Daniel Drake375fc772010-09-30 21:55:41 +010049 {
50 .name = "vx855_gpio",
51 .num_resources = ARRAY_SIZE(vx855_gpio_resources),
52 .resources = vx855_gpio_resources,
53
54 /* we must ignore resource conflicts, for reasons outlined in
55 * the vx855_gpio driver */
56 .ignore_resource_conflicts = true,
57 },
58};
59
Bill Pembertonf791be42012-11-19 13:23:04 -050060static int vx855_probe(struct pci_dev *pdev,
Daniel Drake375fc772010-09-30 21:55:41 +010061 const struct pci_device_id *id)
62{
63 int ret;
64 u16 gpio_io_offset;
65
66 ret = pci_enable_device(pdev);
67 if (ret)
68 return -ENODEV;
69
70 pci_read_config_word(pdev, VX855_CFG_PMIO_OFFSET, &gpio_io_offset);
71 if (!gpio_io_offset) {
72 dev_warn(&pdev->dev,
73 "BIOS did not assign PMIO base offset?!?\n");
74 ret = -ENODEV;
75 goto out;
76 }
77
78 /* mask out the lowest seven bits, as they are always zero, but
79 * hardware returns them as 0x01 */
80 gpio_io_offset &= 0xff80;
81
82 /* As the region identified here includes many non-GPIO things, we
83 * only work with the specific registers that concern us. */
84 vx855_gpio_resources[0].start = gpio_io_offset + VX855_PMIO_R_GPI;
85 vx855_gpio_resources[0].end = vx855_gpio_resources[0].start + 3;
86 vx855_gpio_resources[1].start = gpio_io_offset + VX855_PMIO_R_GPO;
87 vx855_gpio_resources[1].end = vx855_gpio_resources[1].start + 3;
88
89 ret = mfd_add_devices(&pdev->dev, -1, vx855_cells, ARRAY_SIZE(vx855_cells),
Mark Brown0848c942012-09-11 15:16:36 +080090 NULL, 0, NULL);
Daniel Drake375fc772010-09-30 21:55:41 +010091
92 /* we always return -ENODEV here in order to enable other
93 * drivers like old, not-yet-platform_device ported i2c-viapro */
94 return -ENODEV;
95out:
96 pci_disable_device(pdev);
97 return ret;
98}
99
Bill Pemberton4740f732012-11-19 13:26:01 -0500100static void vx855_remove(struct pci_dev *pdev)
Daniel Drake375fc772010-09-30 21:55:41 +0100101{
102 mfd_remove_devices(&pdev->dev);
103 pci_disable_device(pdev);
104}
105
Jingoo Han36fcd062013-12-03 08:15:39 +0900106static const struct pci_device_id vx855_pci_tbl[] = {
Daniel Drake375fc772010-09-30 21:55:41 +0100107 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855) },
108 { 0, }
109};
Axel Linbcd2f632011-02-28 14:34:27 +0800110MODULE_DEVICE_TABLE(pci, vx855_pci_tbl);
Daniel Drake375fc772010-09-30 21:55:41 +0100111
112static struct pci_driver vx855_pci_driver = {
113 .name = "vx855",
114 .id_table = vx855_pci_tbl,
115 .probe = vx855_probe,
Bill Pemberton84449212012-11-19 13:20:24 -0500116 .remove = vx855_remove,
Daniel Drake375fc772010-09-30 21:55:41 +0100117};
118
Axel Lin38a36f52012-04-03 09:09:19 +0800119module_pci_driver(vx855_pci_driver);
Daniel Drake375fc772010-09-30 21:55:41 +0100120
121MODULE_LICENSE("GPL");
122MODULE_AUTHOR("Harald Welte <HaraldWelte@viatech.com>");
123MODULE_DESCRIPTION("Driver for the VIA VX855 chipset");