linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>,
	markgross@kernel.org, ilpo.jarvinen@linux.intel.com,
	basavaraj.natikar@amd.com, jikos@kernel.org,
	benjamin.tissoires@redhat.com
Cc: Patil.Reddy@amd.com, mario.limonciello@amd.com,
	platform-driver-x86@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH v6 14/15] platform/x86/amd/pmf: Add PMF-AMDSFH interface for HPD
Date: Mon, 11 Dec 2023 10:07:23 +0100	[thread overview]
Message-ID: <f4c8a150-1504-4fa9-86bf-7400b8fea884@redhat.com> (raw)
In-Reply-To: <20231204101548.1458499-15-Shyam-sundar.S-k@amd.com>

Hi,

On 12/4/23 11:15, Shyam Sundar S K wrote:
> From: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
> 
> AMDSFH has information about the User presence information via the Human
> Presence Detection (HPD) sensor which is part of the AMD sensor fusion hub.
> Add PMF and AMDSFH interface to get this information.
> 
> Co-developed-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
> ---
>  drivers/hid/amd-sfh-hid/amd_sfh_common.h      |  5 ++
>  drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c | 14 ++++++
>  .../amd-sfh-hid/sfh1_1/amd_sfh_interface.c    | 33 +++++++++++++
>  .../amd-sfh-hid/sfh1_1/amd_sfh_interface.h    |  1 +
>  drivers/platform/x86/amd/pmf/Kconfig          |  1 +
>  drivers/platform/x86/amd/pmf/spc.c            | 22 +++++++++
>  include/linux/amd-pmf-io.h                    | 46 +++++++++++++++++++
>  7 files changed, 122 insertions(+)
>  create mode 100644 include/linux/amd-pmf-io.h

<snip>


> diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c
> index 4f81ef2d4f56..f8758fb70b1a 100644
> --- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c
> +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c
> @@ -7,11 +7,14 @@
>   *
>   * Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
>   */
> +#include <linux/amd-pmf-io.h>
>  #include <linux/io-64-nonatomic-lo-hi.h>
>  #include <linux/iopoll.h>
>  
>  #include "amd_sfh_interface.h"
>  
> +static struct amd_mp2_dev *emp2;
> +
>  static int amd_sfh_wait_response(struct amd_mp2_dev *mp2, u8 sid, u32 cmd_id)
>  {
>  	struct sfh_cmd_response cmd_resp;
> @@ -73,7 +76,37 @@ static struct amd_mp2_ops amd_sfh_ops = {
>  	.response = amd_sfh_wait_response,
>  };
>  
> +void sfh_deinit_emp2(void)
> +{
> +	emp2 = NULL;
> +}
> +
>  void sfh_interface_init(struct amd_mp2_dev *mp2)
>  {
>  	mp2->mp2_ops = &amd_sfh_ops;
> +	emp2 = mp2;
> +}
> +
> +static int amd_sfh_hpd_info(u8 *user_present)
> +{
> +	struct hpd_status hpdstatus;
> +
> +	if (!emp2 || !emp2->dev_en.is_hpd_present)
> +		return -ENODEV;
> +
> +	hpdstatus.val = readl(emp2->mmio + AMD_C2P_MSG(4));
> +	*user_present = hpdstatus.shpd.presence;
> +	return 0;
> +}
> +
> +int amd_get_sfh_info(struct amd_sfh_info *sfh_info, enum sfh_message_type op)
> +{
> +	if (sfh_info) {
> +		switch (op) {
> +		case MT_HPD:
> +			return amd_sfh_hpd_info(&sfh_info->user_present);
> +		}
> +	}
> +	return -EINVAL;
>  }
> +EXPORT_SYMBOL_GPL(amd_get_sfh_info);

This whole amd_get_sfh_info() interface seems over engineered
why not just export amd_sfh_hpd_info() itself and directly
use that in the pmf code ?  That seems a whole lot simpler to me.

Also this patch MUST be split into 2 separate patches
for the HID and the PMF changes.

<snip>


> diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
> index a0423942f771..5e769dcb075a 100644
> --- a/drivers/platform/x86/amd/pmf/spc.c
> +++ b/drivers/platform/x86/amd/pmf/spc.c
> @@ -10,6 +10,7 @@
>   */
>  
>  #include <acpi/button.h>
> +#include <linux/amd-pmf-io.h>
>  #include <linux/power_supply.h>
>  #include <linux/units.h>
>  #include "pmf.h"
> @@ -44,6 +45,7 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *
>  	dev_dbg(dev->dev, "Max C0 Residency: %u\n", in->ev_info.max_c0residency);
>  	dev_dbg(dev->dev, "GFX Busy: %u\n", in->ev_info.gfx_busy);
>  	dev_dbg(dev->dev, "LID State: %s\n", in->ev_info.lid_state ? "close" : "open");
> +	dev_dbg(dev->dev, "User Presence: %s\n", in->ev_info.user_present ? "Present" : "Away");
>  	dev_dbg(dev->dev, "==== TA inputs END ====\n");
>  }
>  #else
> @@ -147,6 +149,25 @@ static int amd_pmf_get_slider_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_
>  	return 0;
>  }
>  
> +static void amd_pmf_get_sensor_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
> +{
> +	struct amd_sfh_info sfh_info;
> +
> +	/* get HPD data */
> +	amd_get_sfh_info(&sfh_info, MT_HPD);

As Mario also pointed out, this needs to be error checked.

Regards,

Hans



  parent reply	other threads:[~2023-12-11  9:07 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-04 10:15 [PATCH v6 00/15] Introduce PMF Smart PC Solution Builder Feature Shyam Sundar S K
2023-12-04 10:15 ` [PATCH v6 01/15] platform/x86/amd/pmf: Add PMF TEE interface Shyam Sundar S K
2023-12-04 10:15 ` [PATCH v6 02/15] platform/x86/amd/pmf: Add support for PMF-TA interaction Shyam Sundar S K
2023-12-04 10:15 ` [PATCH v6 03/15] platform/x86/amd/pmf: Change return type of amd_pmf_set_dram_addr() Shyam Sundar S K
2023-12-11  8:40   ` Hans de Goede
2023-12-11 15:15     ` Shyam Sundar S K
2023-12-11 15:55       ` Hans de Goede
2023-12-11 16:35         ` Shyam Sundar S K
2023-12-04 10:15 ` [PATCH v6 04/15] platform/x86/amd/pmf: Add support for PMF Policy Binary Shyam Sundar S K
2023-12-04 19:05   ` Mario Limonciello
2023-12-11  8:53   ` Hans de Goede
2023-12-04 10:15 ` [PATCH v6 05/15] platform/x86/amd/pmf: change amd_pmf_init_features() call sequence Shyam Sundar S K
2023-12-04 10:15 ` [PATCH v6 06/15] platform/x86/amd/pmf: Add support to get inputs from other subsystems Shyam Sundar S K
2023-12-04 19:03   ` Mario Limonciello
2023-12-04 10:15 ` [PATCH v6 07/15] platform/x86/amd/pmf: Add support update p3t limit Shyam Sundar S K
2023-12-04 10:15 ` [PATCH v6 08/15] platform/x86/amd/pmf: Add support to update system state Shyam Sundar S K
2023-12-04 10:15 ` [PATCH v6 09/15] platform/x86/amd/pmf: Make source_as_str() as non-static Shyam Sundar S K
2023-12-04 10:15 ` [PATCH v6 10/15] platform/x86/amd/pmf: Add facility to dump TA inputs Shyam Sundar S K
2023-12-04 10:15 ` [PATCH v6 11/15] platform/x86/amd/pmf: Add capability to sideload of policy binary Shyam Sundar S K
2023-12-11  8:59   ` Hans de Goede
2023-12-04 10:15 ` [PATCH v6 12/15] platform/x86/amd/pmf: dump policy binary data Shyam Sundar S K
2023-12-04 10:15 ` [PATCH v6 13/15] HID: amd_sfh: rename float_to_int() to amd_sfh_float_to_int() Shyam Sundar S K
2023-12-04 19:02   ` Mario Limonciello
2023-12-04 10:15 ` [PATCH v6 14/15] platform/x86/amd/pmf: Add PMF-AMDSFH interface for HPD Shyam Sundar S K
2023-12-04 19:02   ` Mario Limonciello
2023-12-11  9:07   ` Hans de Goede [this message]
2023-12-04 10:15 ` [PATCH v6 15/15] platform/x86/amd/pmf: Add PMF-AMDSFH interface for ALS Shyam Sundar S K
2023-12-11  9:15   ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f4c8a150-1504-4fa9-86bf-7400b8fea884@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=Patil.Reddy@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=basavaraj.natikar@amd.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=markgross@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).