2 * Support for features of the OLPC XO-1 laptop
4 * Copyright (C) 2010 One Laptop per Child
5 * Copyright (C) 2006 Red Hat, Inc.
6 * Copyright (C) 2006 Advanced Micro Devices, Inc.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
14 #include <linux/module.h>
15 #include <linux/pci.h>
16 #include <linux/pci_ids.h>
17 #include <linux/platform_device.h>
23 #define DRV_NAME "olpc-xo1"
28 /* PMC registers (PMS block) */
30 #define PM_IN_SLPCTL 0x20
35 /* PM registers (ACPI block) */
37 #define PM_GPE0_STS 0x18
39 static unsigned long acpi_base
;
40 static unsigned long pms_base
;
42 static void xo1_power_off(void)
44 printk(KERN_INFO
"OLPC XO-1 power off sequence...\n");
46 /* Enable all of these controls with 0 delay */
47 outl(0x40000000, pms_base
+ PM_SCLK
);
48 outl(0x40000000, pms_base
+ PM_IN_SLPCTL
);
49 outl(0x40000000, pms_base
+ PM_WKXD
);
50 outl(0x40000000, pms_base
+ PM_WKD
);
52 /* Clear status bits (possibly unnecessary) */
53 outl(0x0002ffff, pms_base
+ PM_SSC
);
54 outl(0xffffffff, acpi_base
+ PM_GPE0_STS
);
56 /* Write SLP_EN bit to start the machinery */
57 outl(0x00002000, acpi_base
+ PM1_CNT
);
60 /* Read the base addresses from the PCI BAR info */
61 static int __devinit
setup_bases(struct pci_dev
*pdev
)
65 r
= pci_enable_device_io(pdev
);
67 dev_err(&pdev
->dev
, "can't enable device IO\n");
71 r
= pci_request_region(pdev
, ACPI_BAR
, DRV_NAME
);
73 dev_err(&pdev
->dev
, "can't alloc PCI BAR #%d\n", ACPI_BAR
);
77 r
= pci_request_region(pdev
, PMS_BAR
, DRV_NAME
);
79 dev_err(&pdev
->dev
, "can't alloc PCI BAR #%d\n", PMS_BAR
);
80 pci_release_region(pdev
, ACPI_BAR
);
84 acpi_base
= pci_resource_start(pdev
, ACPI_BAR
);
85 pms_base
= pci_resource_start(pdev
, PMS_BAR
);
90 static int __devinit
olpc_xo1_probe(struct platform_device
*pdev
)
92 struct pci_dev
*pcidev
;
95 pcidev
= pci_get_device(PCI_VENDOR_ID_AMD
, PCI_DEVICE_ID_AMD_CS5536_ISA
,
100 r
= setup_bases(pcidev
);
104 pm_power_off
= xo1_power_off
;
106 printk(KERN_INFO
"OLPC XO-1 support registered\n");
110 static int __devexit
olpc_xo1_remove(struct platform_device
*pdev
)
116 static struct platform_driver olpc_xo1_driver
= {
119 .owner
= THIS_MODULE
,
121 .probe
= olpc_xo1_probe
,
122 .remove
= __devexit_p(olpc_xo1_remove
),
125 static int __init
olpc_xo1_init(void)
127 return platform_driver_register(&olpc_xo1_driver
);
130 static void __exit
olpc_xo1_exit(void)
132 platform_driver_unregister(&olpc_xo1_driver
);
135 MODULE_AUTHOR("Daniel Drake <dsd@laptop.org>");
136 MODULE_LICENSE("GPL");
137 MODULE_ALIAS("platform:olpc-xo1");
139 module_init(olpc_xo1_init
);
140 module_exit(olpc_xo1_exit
);