Skip to content

Commit

Permalink
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…git/sameo/mfd-2.6

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6: (59 commits)
  mfd: ab8500-core chip version cut 2.0 support
  mfd: Flag WM831x /IRQ as a wake source
  mfd: Convert WM831x away from legacy I2C PM operations
  regulator: Support MAX8998/LP3974 DVS-GPIO
  mfd: Support LP3974 RTC
  i2c: Convert SCx200 driver from using raw PCI to platform device
  x86: OLPC: convert olpc-xo1 driver from pci device to platform device
  mfd: MAX8998/LP3974 hibernation support
  mfd/ab8500: remove spi support
  mfd: Remove ARCH_U8500 dependency from AB8500
  misc: Make AB8500_PWM driver depend on U8500 due to PWM breakage
  mfd: Add __devexit annotation for vx855_remove
  mfd: twl6030 irq_data conversion.
  gpio: Fix cs5535 printk warnings
  misc: Fix cs5535 printk warnings
  mfd: Convert Wolfson MFD drivers to use irq_data accessor function
  mfd: Convert TWL4030 to new irq_ APIs
  mfd: Convert tps6586x driver to new irq_ API
  mfd: Convert tc6393xb driver to new irq_ APIs
  mfd: Convert t7166xb driver to new irq_ API
  ...
  • Loading branch information
Linus Torvalds committed Jan 14, 2011
2 parents c1e0d97 + 92d50a4 commit 822e521
Show file tree
Hide file tree
Showing 48 changed files with 1,806 additions and 1,354 deletions.
2 changes: 1 addition & 1 deletion arch/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2068,7 +2068,7 @@ config OLPC

config OLPC_XO1
tristate "OLPC XO-1 support"
depends on OLPC && PCI
depends on OLPC && MFD_CS5535
---help---
Add support for non-essential features of the OLPC XO-1 laptop.

Expand Down
101 changes: 55 additions & 46 deletions arch/x86/platform/olpc/olpc-xo1.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Support for features of the OLPC XO-1 laptop
*
* Copyright (C) 2010 Andres Salomon <dilinger@queued.net>
* Copyright (C) 2010 One Laptop per Child
* Copyright (C) 2006 Red Hat, Inc.
* Copyright (C) 2006 Advanced Micro Devices, Inc.
Expand All @@ -12,8 +13,6 @@
*/

#include <linux/module.h>
#include <linux/pci.h>
#include <linux/pci_ids.h>
#include <linux/platform_device.h>
#include <linux/pm.h>

Expand All @@ -22,9 +21,6 @@

#define DRV_NAME "olpc-xo1"

#define PMS_BAR 4
#define ACPI_BAR 5

/* PMC registers (PMS block) */
#define PM_SCLK 0x10
#define PM_IN_SLPCTL 0x20
Expand Down Expand Up @@ -57,65 +53,67 @@ static void xo1_power_off(void)
outl(0x00002000, acpi_base + PM1_CNT);
}

/* Read the base addresses from the PCI BAR info */
static int __devinit setup_bases(struct pci_dev *pdev)
static int __devinit olpc_xo1_probe(struct platform_device *pdev)
{
int r;
struct resource *res;

r = pci_enable_device_io(pdev);
if (r) {
dev_err(&pdev->dev, "can't enable device IO\n");
return r;
}
/* don't run on non-XOs */
if (!machine_is_olpc())
return -ENODEV;

r = pci_request_region(pdev, ACPI_BAR, DRV_NAME);
if (r) {
dev_err(&pdev->dev, "can't alloc PCI BAR #%d\n", ACPI_BAR);
return r;
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
if (!res) {
dev_err(&pdev->dev, "can't fetch device resource info\n");
return -EIO;
}

r = pci_request_region(pdev, PMS_BAR, DRV_NAME);
if (r) {
dev_err(&pdev->dev, "can't alloc PCI BAR #%d\n", PMS_BAR);
pci_release_region(pdev, ACPI_BAR);
return r;
if (!request_region(res->start, resource_size(res), DRV_NAME)) {
dev_err(&pdev->dev, "can't request region\n");
return -EIO;
}

acpi_base = pci_resource_start(pdev, ACPI_BAR);
pms_base = pci_resource_start(pdev, PMS_BAR);
if (strcmp(pdev->name, "cs5535-pms") == 0)
pms_base = res->start;
else if (strcmp(pdev->name, "cs5535-acpi") == 0)
acpi_base = res->start;

/* If we have both addresses, we can override the poweroff hook */
if (pms_base && acpi_base) {
pm_power_off = xo1_power_off;
printk(KERN_INFO "OLPC XO-1 support registered\n");
}

return 0;
}

static int __devinit olpc_xo1_probe(struct platform_device *pdev)
static int __devexit olpc_xo1_remove(struct platform_device *pdev)
{
struct pci_dev *pcidev;
int r;

pcidev = pci_get_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA,
NULL);
if (!pdev)
return -ENODEV;

r = setup_bases(pcidev);
if (r)
return r;
struct resource *r;

pm_power_off = xo1_power_off;
r = platform_get_resource(pdev, IORESOURCE_IO, 0);
release_region(r->start, resource_size(r));

printk(KERN_INFO "OLPC XO-1 support registered\n");
return 0;
}
if (strcmp(pdev->name, "cs5535-pms") == 0)
pms_base = 0;
else if (strcmp(pdev->name, "cs5535-acpi") == 0)
acpi_base = 0;

static int __devexit olpc_xo1_remove(struct platform_device *pdev)
{
pm_power_off = NULL;
return 0;
}

static struct platform_driver olpc_xo1_driver = {
static struct platform_driver cs5535_pms_drv = {
.driver = {
.name = "cs5535-pms",
.owner = THIS_MODULE,
},
.probe = olpc_xo1_probe,
.remove = __devexit_p(olpc_xo1_remove),
};

static struct platform_driver cs5535_acpi_drv = {
.driver = {
.name = DRV_NAME,
.name = "cs5535-acpi",
.owner = THIS_MODULE,
},
.probe = olpc_xo1_probe,
Expand All @@ -124,12 +122,23 @@ static struct platform_driver olpc_xo1_driver = {

static int __init olpc_xo1_init(void)
{
return platform_driver_register(&olpc_xo1_driver);
int r;

r = platform_driver_register(&cs5535_pms_drv);
if (r)
return r;

r = platform_driver_register(&cs5535_acpi_drv);
if (r)
platform_driver_unregister(&cs5535_pms_drv);

return r;
}

static void __exit olpc_xo1_exit(void)
{
platform_driver_unregister(&olpc_xo1_driver);
platform_driver_unregister(&cs5535_acpi_drv);
platform_driver_unregister(&cs5535_pms_drv);
}

MODULE_AUTHOR("Daniel Drake <dsd@laptop.org>");
Expand Down
93 changes: 31 additions & 62 deletions drivers/gpio/cs5535-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
#include <linux/kernel.h>
#include <linux/spinlock.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <linux/io.h>
#include <linux/cs5535.h>
#include <asm/msr.h>

#define DRV_NAME "cs5535-gpio"
#define GPIO_BAR 1

/*
* Some GPIO pins
Expand Down Expand Up @@ -47,7 +46,7 @@ static struct cs5535_gpio_chip {
struct gpio_chip chip;
resource_size_t base;

struct pci_dev *pdev;
struct platform_device *pdev;
spinlock_t lock;
} cs5535_gpio_chip;

Expand Down Expand Up @@ -301,10 +300,10 @@ static struct cs5535_gpio_chip cs5535_gpio_chip = {
},
};

static int __init cs5535_gpio_probe(struct pci_dev *pdev,
const struct pci_device_id *pci_id)
static int __devinit cs5535_gpio_probe(struct platform_device *pdev)
{
int err;
struct resource *res;
int err = -EIO;
ulong mask_orig = mask;

/* There are two ways to get the GPIO base address; one is by
Expand All @@ -314,25 +313,23 @@ static int __init cs5535_gpio_probe(struct pci_dev *pdev,
* it turns out to be unreliable in the face of crappy BIOSes, we
* can always go back to using MSRs.. */

err = pci_enable_device_io(pdev);
if (err) {
dev_err(&pdev->dev, "can't enable device IO\n");
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
if (!res) {
dev_err(&pdev->dev, "can't fetch device resource info\n");
goto done;
}

err = pci_request_region(pdev, GPIO_BAR, DRV_NAME);
if (err) {
dev_err(&pdev->dev, "can't alloc PCI BAR #%d\n", GPIO_BAR);
if (!request_region(res->start, resource_size(res), pdev->name)) {
dev_err(&pdev->dev, "can't request region\n");
goto done;
}

/* set up the driver-specific struct */
cs5535_gpio_chip.base = pci_resource_start(pdev, GPIO_BAR);
cs5535_gpio_chip.base = res->start;
cs5535_gpio_chip.pdev = pdev;
spin_lock_init(&cs5535_gpio_chip.lock);

dev_info(&pdev->dev, "allocated PCI BAR #%d: base 0x%llx\n", GPIO_BAR,
(unsigned long long) cs5535_gpio_chip.base);
dev_info(&pdev->dev, "reserved resource region %pR\n", res);

/* mask out reserved pins */
mask &= 0x1F7FFFFF;
Expand All @@ -350,78 +347,49 @@ static int __init cs5535_gpio_probe(struct pci_dev *pdev,
if (err)
goto release_region;

dev_info(&pdev->dev, DRV_NAME ": GPIO support successfully loaded.\n");
dev_info(&pdev->dev, "GPIO support successfully loaded.\n");
return 0;

release_region:
pci_release_region(pdev, GPIO_BAR);
release_region(res->start, resource_size(res));
done:
return err;
}

static void __exit cs5535_gpio_remove(struct pci_dev *pdev)
static int __devexit cs5535_gpio_remove(struct platform_device *pdev)
{
struct resource *r;
int err;

err = gpiochip_remove(&cs5535_gpio_chip.chip);
if (err) {
/* uhh? */
dev_err(&pdev->dev, "unable to remove gpio_chip?\n");
return err;
}
pci_release_region(pdev, GPIO_BAR);
}

static struct pci_device_id cs5535_gpio_pci_tbl[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) },
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) },
{ 0, },
};
MODULE_DEVICE_TABLE(pci, cs5535_gpio_pci_tbl);

/*
* We can't use the standard PCI driver registration stuff here, since
* that allows only one driver to bind to each PCI device (and we want
* multiple drivers to be able to bind to the device). Instead, manually
* scan for the PCI device, request a single region, and keep track of the
* devices that we're using.
*/

static int __init cs5535_gpio_scan_pci(void)
{
struct pci_dev *pdev;
int err = -ENODEV;
int i;

for (i = 0; i < ARRAY_SIZE(cs5535_gpio_pci_tbl); i++) {
pdev = pci_get_device(cs5535_gpio_pci_tbl[i].vendor,
cs5535_gpio_pci_tbl[i].device, NULL);
if (pdev) {
err = cs5535_gpio_probe(pdev, &cs5535_gpio_pci_tbl[i]);
if (err)
pci_dev_put(pdev);

/* we only support a single CS5535/6 southbridge */
break;
}
}

return err;
r = platform_get_resource(pdev, IORESOURCE_IO, 0);
release_region(r->start, resource_size(r));
return 0;
}

static void __exit cs5535_gpio_free_pci(void)
{
cs5535_gpio_remove(cs5535_gpio_chip.pdev);
pci_dev_put(cs5535_gpio_chip.pdev);
}
static struct platform_driver cs5535_gpio_drv = {
.driver = {
.name = DRV_NAME,
.owner = THIS_MODULE,
},
.probe = cs5535_gpio_probe,
.remove = __devexit_p(cs5535_gpio_remove),
};

static int __init cs5535_gpio_init(void)
{
return cs5535_gpio_scan_pci();
return platform_driver_register(&cs5535_gpio_drv);
}

static void __exit cs5535_gpio_exit(void)
{
cs5535_gpio_free_pci();
platform_driver_unregister(&cs5535_gpio_drv);
}

module_init(cs5535_gpio_init);
Expand All @@ -430,3 +398,4 @@ module_exit(cs5535_gpio_exit);
MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>");
MODULE_DESCRIPTION("AMD CS5535/CS5536 GPIO driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:" DRV_NAME);
Loading

0 comments on commit 822e521

Please sign in to comment.