@@ -162,8 +162,11 @@ static inline void superio_exit(int ioreg, bool noexit)
162162#define IT8623E_DEVID 0x8623
163163#define IT8628E_DEVID 0x8628
164164#define IT87952E_DEVID 0x8695
165- #define IT87_ACT_REG 0x30
166- #define IT87_BASE_REG 0x60
165+
166+ /* Logical device 4 (Environmental Monitor) registers */
167+ #define IT87_ACT_REG 0x30
168+ #define IT87_BASE_REG 0x60
169+ #define IT87_SPECIAL_CFG_REG 0xf3 /* special configuration register */
167170
168171/* Logical device 7 registers (IT8712F and later) */
169172#define IT87_SIO_GPIO1_REG 0x25
@@ -284,6 +287,8 @@ struct it87_devices {
284287 u32 features ;
285288 u8 peci_mask ;
286289 u8 old_peci_mask ;
290+ u8 smbus_bitmap ; /* SMBus enable bits in extra config register */
291+ u8 ec_special_config ;
287292};
288293
289294#define FEAT_12MV_ADC BIT(0)
@@ -533,6 +538,8 @@ struct it87_sio_data {
533538 u8 skip_fan ;
534539 u8 skip_pwm ;
535540 u8 skip_temp ;
541+ u8 smbus_bitmap ;
542+ u8 ec_special_config ;
536543};
537544
538545/*
@@ -547,6 +554,9 @@ struct it87_data {
547554 u8 peci_mask ;
548555 u8 old_peci_mask ;
549556
557+ u8 smbus_bitmap ; /* !=0 if SMBus needs to be disabled */
558+ u8 ec_special_config ; /* EC special config register restore value */
559+
550560 unsigned short addr ;
551561 const char * name ;
552562 struct mutex update_lock ;
@@ -701,6 +711,39 @@ static const unsigned int pwm_freq[8] = {
701711 750000 ,
702712};
703713
714+ static int smbus_disable (struct it87_data * data )
715+ {
716+ int err ;
717+
718+ if (data -> smbus_bitmap ) {
719+ err = superio_enter (data -> sioaddr );
720+ if (err )
721+ return err ;
722+ superio_select (data -> sioaddr , PME );
723+ superio_outb (data -> sioaddr , IT87_SPECIAL_CFG_REG ,
724+ data -> ec_special_config & ~data -> smbus_bitmap );
725+ superio_exit (data -> sioaddr , has_conf_noexit (data ));
726+ }
727+ return 0 ;
728+ }
729+
730+ static int smbus_enable (struct it87_data * data )
731+ {
732+ int err ;
733+
734+ if (data -> smbus_bitmap ) {
735+ err = superio_enter (data -> sioaddr );
736+ if (err )
737+ return err ;
738+
739+ superio_select (data -> sioaddr , PME );
740+ superio_outb (data -> sioaddr , IT87_SPECIAL_CFG_REG ,
741+ data -> ec_special_config );
742+ superio_exit (data -> sioaddr , has_conf_noexit (data ));
743+ }
744+ return 0 ;
745+ }
746+
704747/*
705748 * Must be called with data->update_lock held, except during initialization.
706749 * We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks,
@@ -2859,6 +2902,15 @@ static int __init it87_find(int sioaddr, unsigned short *address,
28592902 if (dmi_data )
28602903 sio_data -> skip_pwm |= dmi_data -> skip_pwm ;
28612904
2905+ if (config -> smbus_bitmap ) {
2906+ u8 reg ;
2907+
2908+ superio_select (sioaddr , PME );
2909+ reg = superio_inb (sioaddr , IT87_SPECIAL_CFG_REG );
2910+ sio_data -> ec_special_config = reg ;
2911+ sio_data -> smbus_bitmap = reg & config -> smbus_bitmap ;
2912+ }
2913+
28622914exit :
28632915 superio_exit (sioaddr , config ? has_conf_noexit (config ) : false);
28642916 return err ;
@@ -3094,6 +3146,8 @@ static int it87_probe(struct platform_device *pdev)
30943146 data -> addr = res -> start ;
30953147 data -> sioaddr = sio_data -> sioaddr ;
30963148 data -> type = sio_data -> type ;
3149+ data -> smbus_bitmap = sio_data -> smbus_bitmap ;
3150+ data -> ec_special_config = sio_data -> ec_special_config ;
30973151 data -> features = it87_devices [sio_data -> type ].features ;
30983152 data -> peci_mask = it87_devices [sio_data -> type ].peci_mask ;
30993153 data -> old_peci_mask = it87_devices [sio_data -> type ].old_peci_mask ;
0 commit comments