via686a.c (fde0950903ce8cc38a91dd095280decceda2ff82) via686a.c (2d8672c5a6ba0d3f1d8d3ad61ef67868941364f0)
1/*
2 via686a.c - Part of lm_sensors, Linux kernel modules
3 for hardware monitoring
4
5 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
6 Ky�sti M�lkki <kmalkki@cc.hut.fi>,
7 Mark Studebaker <mdsxyz123@yahoo.com>,
8 and Bob Dougherty <bobd@stanford.edu>

--- 36 unchanged lines hidden (view full) ---

45
46/* If force_addr is set to anything different from 0, we forcibly enable
47 the device at the given address. */
48static unsigned short force_addr = 0;
49module_param(force_addr, ushort, 0);
50MODULE_PARM_DESC(force_addr,
51 "Initialize the base address of the sensors");
52
1/*
2 via686a.c - Part of lm_sensors, Linux kernel modules
3 for hardware monitoring
4
5 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
6 Ky�sti M�lkki <kmalkki@cc.hut.fi>,
7 Mark Studebaker <mdsxyz123@yahoo.com>,
8 and Bob Dougherty <bobd@stanford.edu>

--- 36 unchanged lines hidden (view full) ---

45
46/* If force_addr is set to anything different from 0, we forcibly enable
47 the device at the given address. */
48static unsigned short force_addr = 0;
49module_param(force_addr, ushort, 0);
50MODULE_PARM_DESC(force_addr,
51 "Initialize the base address of the sensors");
52
53/* Addresses to scan.
53/* Device address
54 Note that we can't determine the ISA address until we have initialized
55 our module */
54 Note that we can't determine the ISA address until we have initialized
55 our module */
56static unsigned short normal_i2c[] = { I2C_CLIENT_END };
57static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
56static unsigned short address;
58
57
59/* Insmod parameters */
60SENSORS_INSMOD_1(via686a);
61
62/*
63 The Via 686a southbridge has a LM78-like chip integrated on the same IC.
64 This driver is a customized copy of lm78.c
65*/
66
67/* Many VIA686A constants specified below */
68
69/* Length of ISA address segment */

--- 244 unchanged lines hidden (view full) ---

314 u8 temp_over[3]; /* Register value */
315 u8 temp_hyst[3]; /* Register value */
316 u8 fan_div[2]; /* Register encoding, shifted right */
317 u16 alarms; /* Register encoding, combined */
318};
319
320static struct pci_dev *s_bridge; /* pointer to the (only) via686a */
321
58/*
59 The Via 686a southbridge has a LM78-like chip integrated on the same IC.
60 This driver is a customized copy of lm78.c
61*/
62
63/* Many VIA686A constants specified below */
64
65/* Length of ISA address segment */

--- 244 unchanged lines hidden (view full) ---

310 u8 temp_over[3]; /* Register value */
311 u8 temp_hyst[3]; /* Register value */
312 u8 fan_div[2]; /* Register encoding, shifted right */
313 u16 alarms; /* Register encoding, combined */
314};
315
316static struct pci_dev *s_bridge; /* pointer to the (only) via686a */
317
322static int via686a_attach_adapter(struct i2c_adapter *adapter);
323static int via686a_detect(struct i2c_adapter *adapter, int address, int kind);
318static int via686a_detect(struct i2c_adapter *adapter);
324static int via686a_detach_client(struct i2c_client *client);
325
326static inline int via686a_read_value(struct i2c_client *client, u8 reg)
327{
328 return (inb_p(client->addr + reg));
329}
330
331static inline void via686a_write_value(struct i2c_client *client, u8 reg,

--- 243 unchanged lines hidden (view full) ---

575}
576static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
577
578/* The driver. I choose to use type i2c_driver, as at is identical to both
579 smbus_driver and isa_driver, and clients could be of either kind */
580static struct i2c_driver via686a_driver = {
581 .owner = THIS_MODULE,
582 .name = "via686a",
319static int via686a_detach_client(struct i2c_client *client);
320
321static inline int via686a_read_value(struct i2c_client *client, u8 reg)
322{
323 return (inb_p(client->addr + reg));
324}
325
326static inline void via686a_write_value(struct i2c_client *client, u8 reg,

--- 243 unchanged lines hidden (view full) ---

570}
571static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
572
573/* The driver. I choose to use type i2c_driver, as at is identical to both
574 smbus_driver and isa_driver, and clients could be of either kind */
575static struct i2c_driver via686a_driver = {
576 .owner = THIS_MODULE,
577 .name = "via686a",
583 .id = I2C_DRIVERID_VIA686A,
584 .flags = I2C_DF_NOTIFY,
585 .attach_adapter = via686a_attach_adapter,
578 .attach_adapter = via686a_detect,
586 .detach_client = via686a_detach_client,
587};
588
589
590/* This is called when the module is loaded */
579 .detach_client = via686a_detach_client,
580};
581
582
583/* This is called when the module is loaded */
591static int via686a_attach_adapter(struct i2c_adapter *adapter)
584static int via686a_detect(struct i2c_adapter *adapter)
592{
585{
593 if (!(adapter->class & I2C_CLASS_HWMON))
594 return 0;
595 return i2c_detect(adapter, &addr_data, via686a_detect);
596}
597
598static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
599{
600 struct i2c_client *new_client;
601 struct via686a_data *data;
602 int err = 0;
603 const char client_name[] = "via686a";
604 u16 val;
605
586 struct i2c_client *new_client;
587 struct via686a_data *data;
588 int err = 0;
589 const char client_name[] = "via686a";
590 u16 val;
591
606 /* Make sure we are probing the ISA bus!! */
607 if (!i2c_is_isa_adapter(adapter)) {
608 dev_err(&adapter->dev,
609 "via686a_detect called for an I2C bus adapter?!?\n");
610 return 0;
611 }
612
613 /* 8231 requires multiple of 256, we enforce that on 686 as well */
614 if (force_addr)
615 address = force_addr & 0xFF00;
616
617 if (force_addr) {
618 dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n",
619 address);
620 if (PCIBIOS_SUCCESSFUL !=

--- 199 unchanged lines hidden (view full) ---

820};
821
822MODULE_DEVICE_TABLE(pci, via686a_pci_ids);
823
824static int __devinit via686a_pci_probe(struct pci_dev *dev,
825 const struct pci_device_id *id)
826{
827 u16 val;
592 /* 8231 requires multiple of 256, we enforce that on 686 as well */
593 if (force_addr)
594 address = force_addr & 0xFF00;
595
596 if (force_addr) {
597 dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n",
598 address);
599 if (PCIBIOS_SUCCESSFUL !=

--- 199 unchanged lines hidden (view full) ---

799};
800
801MODULE_DEVICE_TABLE(pci, via686a_pci_ids);
802
803static int __devinit via686a_pci_probe(struct pci_dev *dev,
804 const struct pci_device_id *id)
805{
806 u16 val;
828 int addr = 0;
829
830 if (PCIBIOS_SUCCESSFUL !=
831 pci_read_config_word(dev, VIA686A_BASE_REG, &val))
832 return -ENODEV;
833
807
808 if (PCIBIOS_SUCCESSFUL !=
809 pci_read_config_word(dev, VIA686A_BASE_REG, &val))
810 return -ENODEV;
811
834 addr = val & ~(VIA686A_EXTENT - 1);
835 if (addr == 0 && force_addr == 0) {
812 address = val & ~(VIA686A_EXTENT - 1);
813 if (address == 0 && force_addr == 0) {
836 dev_err(&dev->dev, "base address not set - upgrade BIOS "
837 "or use force_addr=0xaddr\n");
838 return -ENODEV;
839 }
814 dev_err(&dev->dev, "base address not set - upgrade BIOS "
815 "or use force_addr=0xaddr\n");
816 return -ENODEV;
817 }
840 if (force_addr)
841 addr = force_addr; /* so detect will get called */
842
818
843 if (!addr) {
819 if (!address) {
844 dev_err(&dev->dev, "No Via 686A sensors found.\n");
845 return -ENODEV;
846 }
820 dev_err(&dev->dev, "No Via 686A sensors found.\n");
821 return -ENODEV;
822 }
847 normal_isa[0] = addr;
848
849 s_bridge = pci_dev_get(dev);
850 if (i2c_isa_add_driver(&via686a_driver)) {
851 pci_dev_put(s_bridge);
852 s_bridge = NULL;
853 }
854
855 /* Always return failure here. This is to allow other drivers to bind

--- 35 unchanged lines hidden ---
823
824 s_bridge = pci_dev_get(dev);
825 if (i2c_isa_add_driver(&via686a_driver)) {
826 pci_dev_put(s_bridge);
827 s_bridge = NULL;
828 }
829
830 /* Always return failure here. This is to allow other drivers to bind

--- 35 unchanged lines hidden ---