aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2009-01-07 08:29:17 -0500
committerJean Delvare <khali@linux-fr.org>2009-01-07 08:29:17 -0500
commit1561bfe59ca011d9a749dad4d96c2c22ebc86a4a (patch)
treebb6c1c63c826ea1f71fd3a9ad430d3bab75261a0 /drivers/i2c/busses
parentb305271861219f0ce162eb565f0f28f4c781299d (diff)
Input: apanel - convert to new i2c binding
Convert the apanel driver to the new i2c device driver binding model, as the legacy model is going away soon. In the new model, the apanel driver is no longer scanning all the i2c adapters, instead the relevant bus driver (i2c-i801) is instantiating the device as needed. One side benefit is that the apanel driver will now load automatically on all systems where it is needed. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Stephen Hemminger <shemminger@linux-foundation.org>
Diffstat (limited to 'drivers/i2c/busses')
-rw-r--r--drivers/i2c/busses/i2c-i801.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 5123eb69a971..526625eaa84b 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -64,7 +64,7 @@
64#include <linux/init.h> 64#include <linux/init.h>
65#include <linux/i2c.h> 65#include <linux/i2c.h>
66#include <linux/acpi.h> 66#include <linux/acpi.h>
67#include <asm/io.h> 67#include <linux/io.h>
68 68
69/* I801 SMBus address offsets */ 69/* I801 SMBus address offsets */
70#define SMBHSTSTS (0 + i801_smba) 70#define SMBHSTSTS (0 + i801_smba)
@@ -583,6 +583,40 @@ static struct pci_device_id i801_ids[] = {
583 583
584MODULE_DEVICE_TABLE (pci, i801_ids); 584MODULE_DEVICE_TABLE (pci, i801_ids);
585 585
586#if defined CONFIG_INPUT_APANEL || defined CONFIG_INPUT_APANEL_MODULE
587static unsigned char apanel_addr;
588
589/* Scan the system ROM for the signature "FJKEYINF" */
590static __init const void __iomem *bios_signature(const void __iomem *bios)
591{
592 ssize_t offset;
593 const unsigned char signature[] = "FJKEYINF";
594
595 for (offset = 0; offset < 0x10000; offset += 0x10) {
596 if (check_signature(bios + offset, signature,
597 sizeof(signature)-1))
598 return bios + offset;
599 }
600 return NULL;
601}
602
603static void __init input_apanel_init(void)
604{
605 void __iomem *bios;
606 const void __iomem *p;
607
608 bios = ioremap(0xF0000, 0x10000); /* Can't fail */
609 p = bios_signature(bios);
610 if (p) {
611 /* just use the first address */
612 apanel_addr = readb(p + 8 + 3) >> 1;
613 }
614 iounmap(bios);
615}
616#else
617static void __init input_apanel_init(void) {}
618#endif
619
586static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id *id) 620static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
587{ 621{
588 unsigned char temp; 622 unsigned char temp;
@@ -667,6 +701,19 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
667 dev_err(&dev->dev, "Failed to add SMBus adapter\n"); 701 dev_err(&dev->dev, "Failed to add SMBus adapter\n");
668 goto exit_release; 702 goto exit_release;
669 } 703 }
704
705 /* Register optional slaves */
706#if defined CONFIG_INPUT_APANEL || defined CONFIG_INPUT_APANEL_MODULE
707 if (apanel_addr) {
708 struct i2c_board_info info;
709
710 memset(&info, 0, sizeof(struct i2c_board_info));
711 info.addr = apanel_addr;
712 strlcpy(info.type, "fujitsu_apanel", I2C_NAME_SIZE);
713 i2c_new_device(&i801_adapter, &info);
714 }
715#endif
716
670 return 0; 717 return 0;
671 718
672exit_release: 719exit_release:
@@ -717,6 +764,7 @@ static struct pci_driver i801_driver = {
717 764
718static int __init i2c_i801_init(void) 765static int __init i2c_i801_init(void)
719{ 766{
767 input_apanel_init();
720 return pci_register_driver(&i801_driver); 768 return pci_register_driver(&i801_driver);
721} 769}
722 770