2323#include <linux/of.h>
2424#include <linux/regmap.h>
2525#include <linux/version.h>
26- #include <linux/amd-apml.h>
2726
28- #include "sbtsi-common.h"
27+ #include <linux/amd-apml.h>
28+ #include "apml_common.h"
29+
2930/*
3031 * SB-TSI registers only support SMBus byte data access. "_INT" registers are
3132 * the integer part of a temperature value or limit, and "_DEC" registers are
@@ -475,6 +476,7 @@ static int sbtsi_i3c_probe(struct i3c_device *i3cdev)
475476 };
476477 struct regmap * regmap ;
477478 const char * hwmon_dev_name ;
479+ int ret = 0 ;
478480
479481 dev_err (dev , "SBTSI: PID: %llx\n" , i3cdev -> desc -> info .pid );
480482 if (!(I3C_PID_INSTANCE_ID (i3cdev -> desc -> info .pid ) == 0 ||
@@ -524,7 +526,16 @@ static int sbtsi_i3c_probe(struct i3c_device *i3cdev)
524526 return PTR_ERR_OR_ZERO (hwmon_dev );
525527 }
526528
527- return create_misc_tsi_device (tsi_dev , dev );
529+ ret = create_misc_tsi_device (tsi_dev , dev );
530+ if (ret )
531+ return ret ;
532+
533+ /* Register with ALERT_L common system */
534+ ret = apml_register_sbtsi_device (tsi_dev );
535+ if (ret )
536+ dev_warn (dev , "Failed to register with ALERT_L common system: %d\n" , ret );
537+
538+ return 0 ;
528539}
529540
530541#if LINUX_VERSION_CODE < KERNEL_VERSION (6 , 3 , 0 )
@@ -542,6 +553,7 @@ static int sbtsi_i2c_probe(struct i2c_client *client)
542553 .val_bits = 8 ,
543554 };
544555 const char * hwmon_dev_name ;
556+ int ret ;
545557
546558 tsi_dev = devm_kzalloc (dev , sizeof (struct apml_sbtsi_device ), GFP_KERNEL );
547559 if (!tsi_dev )
@@ -568,7 +580,16 @@ static int sbtsi_i2c_probe(struct i2c_client *client)
568580 if (!hwmon_dev )
569581 return PTR_ERR_OR_ZERO (hwmon_dev );
570582
571- return create_misc_tsi_device (tsi_dev , dev );
583+ ret = create_misc_tsi_device (tsi_dev , dev );
584+ if (ret )
585+ return ret ;
586+
587+ /* Register with ALERT_L common system */
588+ ret = apml_register_sbtsi_device (tsi_dev );
589+ if (ret )
590+ dev_warn (dev , "Failed to register with ALERT_L common system: %d\n" , ret );
591+
592+ return 0 ;
572593}
573594
574595#if LINUX_VERSION_CODE < KERNEL_VERSION (5 , 12 , 0 )
@@ -579,8 +600,10 @@ static void sbtsi_i3c_remove(struct i3c_device *i3cdev)
579600{
580601 struct apml_sbtsi_device * tsi_dev = dev_get_drvdata (& i3cdev -> dev );
581602
582- if (tsi_dev )
603+ if (tsi_dev ) {
604+ apml_unregister_sbtsi_device (tsi_dev );
583605 misc_deregister (& tsi_dev -> sbtsi_misc_dev );
606+ }
584607
585608 dev_info (& i3cdev -> dev , "Removed sbtsi-i3c driver\n" );
586609#if LINUX_VERSION_CODE < KERNEL_VERSION (5 , 12 , 0 )
@@ -596,8 +619,10 @@ static void sbtsi_i2c_remove(struct i2c_client *client)
596619{
597620 struct apml_sbtsi_device * tsi_dev = dev_get_drvdata (& client -> dev );
598621
599- if (tsi_dev )
622+ if (tsi_dev ) {
623+ apml_unregister_sbtsi_device (tsi_dev );
600624 misc_deregister (& tsi_dev -> sbtsi_misc_dev );
625+ }
601626
602627 dev_info (& client -> dev , "Removed sbtsi driver\n" );
603628#if LINUX_VERSION_CODE < KERNEL_VERSION (6 , 1 , 0 )
0 commit comments