Skip to contentSkip to conversation

ishtp: Add support for Intel ishtp eclite driver

PATCH Superseded [email protected] 2 participants 2 messages Jul 8, 2021 x86 platform drivers

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ishtp: Add support for Intel ishtp eclite driver

From: "K Naduvalath, Sumesh" <[email protected]>

This driver is for accessing the PSE (Programmable Service Engine), an Embedded Controller like IP, using ISHTP (Integratd Sensor Hub Transport Protocol) to get battery, thermal and UCSI (USB Type-C Connector System Software Interface) related data from the platform.

---
Changes:

v2:
-Decoupled ACPI device search with acpi_find_device and cache acpi_handler -Opregion context is protected with lock for both cmd and data handlers -Opregion length check added in various functions -ishtp_get_device and ishtp_put_device are removed
-Kconfig text, cosmetic and minor corrections

v1:
-Initial Version

 MAINTAINERS                               |   6 +
 drivers/platform/x86/Kconfig              |  16 +
 drivers/platform/x86/Makefile             |   1 +
 drivers/platform/x86/intel_ishtp_eclite.c | 703 ++++++++++++++++++++++
 4 files changed, 726 insertions(+)
 create mode 100644 drivers/platform/x86/intel_ishtp_eclite.c
MAINTAINERS +6 -0
index 3298f4592ce7..d2bdb20c416f 100644
@@ -9361,6 +9361,12 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/crypto/ixp4xx_crypto.c
 
+INTEL ISHTP ECLITE DRIVER
+M:	Sumesh K Naduvalath <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/platform/x86/intel_ishtp_eclite.c
+
 INTEL IXP4XX QMGR, NPE, ETHERNET and HSS SUPPORT
 M:	Krzysztof Halasa <[email protected]>
 S:	Maintained
drivers/platform/x86/Kconfig +16 -0
index 7d385c3b2239..ee5fe5e52033 100644
@@ -1173,6 +1173,22 @@ config INTEL_CHTDC_TI_PWRBTN
 	  To compile this driver as a module, choose M here: the module
 	  will be called intel_chtdc_ti_pwrbtn.
 
+config INTEL_ISHTP_ECLITE
+	tristate "Intel ISHTP eclite controller"
+	depends on INTEL_ISH_HID
+	depends on ACPI
+	help
+	  This driver is for accessing the PSE (Programmable Service Engine),
+	  an Embedded Controller like IP, using ISHTP (Integrated Sensor Hub
+	  Transport Protocol) to get battery, thermal and UCSI (USB Type-C
+          Connector System Software Interface) related data from the platform.
+	  Users who don't want to use discrete Embedded Controller on Intel's
+	  Elkhartlake platform, can leverage this integrated solution of
+	  ECLite which is part of PSE subsystem.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called intel_ishtp_eclite
+
 config INTEL_MRFLD_PWRBTN
 	tristate "Intel Merrifield Basin Cove power button driver"
 	depends on INTEL_SOC_PMIC_MRFLD
drivers/platform/x86/Makefile +1 -0
index 7ee369aab10d..568c9c7d4173 100644
@@ -75,6 +75,7 @@ obj-$(CONFIG_INTEL_INT0002_VGPIO)	+= intel_int0002_vgpio.o
 obj-$(CONFIG_INTEL_MENLOW)		+= intel_menlow.o
 obj-$(CONFIG_INTEL_OAKTRAIL)		+= intel_oaktrail.o
 obj-$(CONFIG_INTEL_VBTN)		+= intel-vbtn.o
+obj-$(CONFIG_INTEL_ISHTP_ECLITE)	+= intel_ishtp_eclite.o
 
 # MSI
 obj-$(CONFIG_MSI_LAPTOP)	+= msi-laptop.o
drivers/platform/x86/intel_ishtp_eclite.c new file +703 -0

703 lines not on this page · raw message

Signature · 1 line
2.31.1
#1 lore raw
Thank you for the patch! Yet something to improve:

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on next-20210708]
[cannot apply to v5.13]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/sumesh-k-naduvalath-intel-com/ishtp-Add-support-for-Intel-ishtp-eclite-driver/20210708-192016
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git e9f1cbc0c4114880090c7a578117d3b9cf184ad4
config: x86_64-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/0360e181285d78d02e2d8bfd8bcf73b0d61268dd
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review sumesh-k-naduvalath-intel-com/ishtp-Add-support-for-Intel-ishtp-eclite-driver/20210708-192016
        git checkout 0360e181285d78d02e2d8bfd8bcf73b0d61268dd
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

drivers/platform/x86/intel_ishtp_eclite.c: In function 'ecl_ishtp_cl_probe':

>> drivers/platform/x86/intel_ishtp_eclite.c:606:2: error: implicit declaration of function 'acpi_walk_dep_device_list' [-Werror=implicit-function-declaration]
     606 |  acpi_walk_dep_device_list(opr_dev->acpi_handle);
         |  ^~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/platform/x86/intel_ishtp_eclite.c: At top level:
>> drivers/platform/x86/intel_ishtp_eclite.c:681:12: error: initialization of 'void (*)(struct ishtp_cl_device *)' from incompatible pointer type 'int (*)(struct ishtp_cl_device *)' [-Werror=incompatible-pointer-types]
     681 |  .remove = ecl_ishtp_cl_remove,
         |            ^~~~~~~~~~~~~~~~~~~

drivers/platform/x86/intel_ishtp_eclite.c:681:12: note: (near initialization for 'ecl_ishtp_cl_driver.remove')
cc1: some warnings being treated as errors

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for PHY_SPARX5_SERDES
Depends on (ARCH_SPARX5 || COMPILE_TEST && OF && HAS_IOMEM
Selected by
- SPARX5_SWITCH && NETDEVICES && ETHERNET && NET_VENDOR_MICROCHIP && NET_SWITCHDEV && HAS_IOMEM

vim +/acpi_walk_dep_device_list +606 drivers/platform/x86/intel_ishtp_eclite.c

551
552 static int ecl_ishtp_cl_probe(struct ishtp_cl_device *cl_device)
553 {
554 struct ishtp_cl *ecl_ishtp_cl;
555 struct ishtp_opregion_dev *opr_dev;
556 int rv;
557
558 opr_dev = devm_kzalloc(ishtp_device(cl_device), sizeof(*opr_dev),
559 GFP_KERNEL);
560 if (!opr_dev)
561 return -ENOMEM;
562
563 ecl_ishtp_cl = ishtp_cl_allocate(cl_device);
564 if (!ecl_ishtp_cl)
565 return -ENOMEM;
566
567 ishtp_set_drvdata(cl_device, ecl_ishtp_cl);
568 ishtp_set_client_data(ecl_ishtp_cl, opr_dev);
569 opr_dev->ecl_ishtp_cl = ecl_ishtp_cl;
570 opr_dev->cl_device = cl_device;
571
572 init_waitqueue_head(&opr_dev->read_wait);
573 INIT_WORK(&opr_dev->event_work, ecl_acpi_invoke_dsm);
574 INIT_WORK(&opr_dev->reset_work, ecl_ishtp_cl_reset_handler);
575
576 /* Initialize ish client device */
577 rv = ecl_ishtp_cl_init(ecl_ishtp_cl);
578 if (rv) {
579 dev_err(cl_data_to_dev(opr_dev), "Client init failed\n");
580 goto err_exit;
581 }
582
583 dev_dbg(cl_data_to_dev(opr_dev), "eclite-ishtp client initialised\n");
584
585 /* Register a handler for eclite fw events */
586 ishtp_register_event_cb(cl_device, ecl_ishtp_cl_event_cb);
587
588 opr_dev->ish_link_ready = true;
589 mutex_init(&opr_dev->lock);
590
591 /* Now find ACPI device and init opregion handlers */
592 rv = acpi_find_eclite_device(opr_dev);
593 if (rv) {
594 dev_err(cl_data_to_dev(opr_dev), "ECLite ACPI ID not found\n");
595
596 goto err_exit;
597 }
598 rv = acpi_opregion_init(opr_dev);
599 if (rv) {
600 dev_err(cl_data_to_dev(opr_dev), "ACPI opregion init failed\n");
601
602 goto err_exit;
603 }
604
605 /* Reprobe devices depending on ECLite - battery, fan, etc. */

 > 606		acpi_walk_dep_device_list(opr_dev->acpi_handle);
   607	
   608		return 0;
   609	err_exit:
   610		ishtp_set_connection_state(ecl_ishtp_cl, ISHTP_CL_DISCONNECTING);
   611		ishtp_cl_disconnect(ecl_ishtp_cl);
   612		ecl_ishtp_cl_deinit(ecl_ishtp_cl);
   613	
   614		return rv;
   615	}
   616	
   617	static int ecl_ishtp_cl_remove(struct ishtp_cl_device *cl_device)
   618	{
   619		struct ishtp_cl *ecl_ishtp_cl = ishtp_get_drvdata(cl_device);
   620		struct ishtp_opregion_dev *opr_dev =
   621			ishtp_get_client_data(ecl_ishtp_cl);
   622	
   623		if (opr_dev->acpi_init_done)
   624			acpi_opregion_deinit(opr_dev);
   625	
   626		cancel_work_sync(&opr_dev->reset_work);
   627		cancel_work_sync(&opr_dev->event_work);
   628	
   629		ishtp_set_connection_state(ecl_ishtp_cl, ISHTP_CL_DISCONNECTING);
   630		ishtp_cl_disconnect(ecl_ishtp_cl);
   631		ecl_ishtp_cl_deinit(ecl_ishtp_cl);
   632	
   633		return 0;
   634	}
   635	
   636	static int ecl_ishtp_cl_reset(struct ishtp_cl_device *cl_device)
   637	{
   638		struct ishtp_cl *ecl_ishtp_cl = ishtp_get_drvdata(cl_device);
   639		struct ishtp_opregion_dev *opr_dev =
   640			ishtp_get_client_data(ecl_ishtp_cl);
   641	
   642		schedule_work(&opr_dev->reset_work);
   643	
   644		return 0;
   645	}
   646	
   647	static int ecl_ishtp_cl_suspend(struct device *device)
   648	{
   649		struct ishtp_cl_device *cl_device = ishtp_dev_to_cl_device(device);
   650		struct ishtp_cl *ecl_ishtp_cl = ishtp_get_drvdata(cl_device);
   651		struct ishtp_opregion_dev *opr_dev =
   652			ishtp_get_client_data(ecl_ishtp_cl);
   653	
   654		if (acpi_target_system_state() == ACPI_STATE_S0)
   655			return 0;
   656	
   657		acpi_opregion_deinit(opr_dev);
   658		ecl_ish_cl_enable_events(opr_dev, false);
   659	
   660		return 0;
   661	}
   662	
   663	static int ecl_ishtp_cl_resume(struct device *device)
   664	{
   665		/* A reset is expected to call after an Sx. At this point
   666		 * we are not sure if the link is up or not to restore anything,
   667		 * so do nothing in resume path
   668		 */
   669		return 0;
   670	}
   671	
   672	static const struct dev_pm_ops ecl_ishtp_pm_ops = {
   673		.suspend = ecl_ishtp_cl_suspend,
   674		.resume = ecl_ishtp_cl_resume,
   675	};
   676	
   677	static struct ishtp_cl_driver ecl_ishtp_cl_driver = {
   678		.name = "ishtp-eclite",
   679		.guid = &ecl_ishtp_guid,
   680		.probe = ecl_ishtp_cl_probe,
 > 681		.remove = ecl_ishtp_cl_remove,

682 .reset = ecl_ishtp_cl_reset,
683 .driver.pm = &ecl_ishtp_pm_ops,
684 };
685

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org