Revert "unicode: Don't special case ignorable code points"
[linux.git] / drivers / mfd / vx855.c
blob985f81c1739c62c6e8be0d08cb6907d8c29136e8
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Linux multi-function-device driver (MFD) for the integrated peripherals
4 * of the VIA VX855 chipset
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.
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>
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
23 /* ACPI I/O Space registers */
24 #define VX855_PMIO_ACPI 0x00
25 #define VX855_PMIO_ACPI_LEN 0x0b
27 /* Processor Power Management */
28 #define VX855_PMIO_PPM 0x10
29 #define VX855_PMIO_PPM_LEN 0x08
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
37 #define VSPIC_MMIO_SIZE 0x1000
39 static struct resource vx855_gpio_resources[] = {
41 .flags = IORESOURCE_IO,
44 .flags = IORESOURCE_IO,
48 static const struct mfd_cell vx855_cells[] = {
50 .name = "vx855_gpio",
51 .num_resources = ARRAY_SIZE(vx855_gpio_resources),
52 .resources = vx855_gpio_resources,
54 /* we must ignore resource conflicts, for reasons outlined in
55 * the vx855_gpio driver */
56 .ignore_resource_conflicts = true,
60 static int vx855_probe(struct pci_dev *pdev,
61 const struct pci_device_id *id)
63 int ret;
64 u16 gpio_io_offset;
66 ret = pci_enable_device(pdev);
67 if (ret)
68 return -ENODEV;
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;
78 /* mask out the lowest seven bits, as they are always zero, but
79 * hardware returns them as 0x01 */
80 gpio_io_offset &= 0xff80;
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;
89 ret = mfd_add_devices(&pdev->dev, -1, vx855_cells, ARRAY_SIZE(vx855_cells),
90 NULL, 0, NULL);
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;
95 out:
96 pci_disable_device(pdev);
97 return ret;
100 static void vx855_remove(struct pci_dev *pdev)
102 mfd_remove_devices(&pdev->dev);
103 pci_disable_device(pdev);
106 static const struct pci_device_id vx855_pci_tbl[] = {
107 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855) },
108 { 0, }
110 MODULE_DEVICE_TABLE(pci, vx855_pci_tbl);
112 static struct pci_driver vx855_pci_driver = {
113 .name = "vx855",
114 .id_table = vx855_pci_tbl,
115 .probe = vx855_probe,
116 .remove = vx855_remove,
119 module_pci_driver(vx855_pci_driver);
121 MODULE_LICENSE("GPL");
122 MODULE_AUTHOR("Harald Welte <HaraldWelte@viatech.com>");
123 MODULE_DESCRIPTION("Driver for the VIA VX855 chipset");