Linux Audio

Check our new training course

Real-Time Linux with PREEMPT_RT training

Feb 18-20, 2025
Register
Loading...
v3.1
 
  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 __devexit 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};
125MODULE_DEVICE_TABLE(pci, vx855_pci_tbl);
126
127static struct pci_driver vx855_pci_driver = {
128	.name		= "vx855",
129	.id_table	= vx855_pci_tbl,
130	.probe		= vx855_probe,
131	.remove		= __devexit_p(vx855_remove),
132};
133
134static int vx855_init(void)
135{
136	return pci_register_driver(&vx855_pci_driver);
137}
138module_init(vx855_init);
139
140static void vx855_exit(void)
141{
142	pci_unregister_driver(&vx855_pci_driver);
143}
144module_exit(vx855_exit);
145
146MODULE_LICENSE("GPL");
147MODULE_AUTHOR("Harald Welte <HaraldWelte@viatech.com>");
148MODULE_DESCRIPTION("Driver for the VIA VX855 chipset");
v5.14.15
  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
  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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 10 */
 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
 48static const struct mfd_cell vx855_cells[] = {
 49	{
 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
 60static int vx855_probe(struct pci_dev *pdev,
 61				 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),
 90			NULL, 0, NULL);
 91
 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
100static void vx855_remove(struct pci_dev *pdev)
101{
102	mfd_remove_devices(&pdev->dev);
103	pci_disable_device(pdev);
104}
105
106static const struct pci_device_id vx855_pci_tbl[] = {
107	{ PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855) },
108	{ 0, }
109};
110MODULE_DEVICE_TABLE(pci, vx855_pci_tbl);
111
112static struct pci_driver vx855_pci_driver = {
113	.name		= "vx855",
114	.id_table	= vx855_pci_tbl,
115	.probe		= vx855_probe,
116	.remove		= vx855_remove,
117};
118
119module_pci_driver(vx855_pci_driver);
 
 
 
 
 
 
 
 
 
 
120
121MODULE_LICENSE("GPL");
122MODULE_AUTHOR("Harald Welte <HaraldWelte@viatech.com>");
123MODULE_DESCRIPTION("Driver for the VIA VX855 chipset");