mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>
Cc: linux-usb@vger.kernel.org,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Sven Peter" <sven@svenpeter.dev>,
	"Guido Günther" <agx@sigxcpu.org>,
	"Angus Ainslie" <angus@akkea.ca>,
	"Hector Martin" <marcan@marcan.st>,
	"Bryan O'Donoghue" <bryan.odonoghue@linaro.org>,
	linux-kernel@vger.kernel.org, kernel@puri.sm
Subject: Re: [PATCH 6/7] usb: typec: tipd: Add debugfs entries for customer use word
Date: Mon, 4 Apr 2022 17:03:51 +0300	[thread overview]
Message-ID: <Ykr6x/YwAwg/KUma@kuha.fi.intel.com> (raw)
In-Reply-To: <20220317154518.4082046-7-sebastian.krzyszkowiak@puri.sm>

On Thu, Mar 17, 2022 at 04:45:17PM +0100, Sebastian Krzyszkowiak wrote:
> From: Guido Günther <agx@sigxcpu.org>
> 
> This allows to verify that a sane firmware is on the device.
> 
> Signed-off-by: Guido Günther <agx@sigxcpu.org>
> Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tipd/core.c | 65 +++++++++++++++++++++++++++++++++++
>  1 file changed, 65 insertions(+)
> 
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index 874528b02a99..d3c70aaf1a0c 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -6,6 +6,7 @@
>   * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
>   */
>  
> +#include <linux/debugfs.h>
>  #include <linux/i2c.h>
>  #include <linux/acpi.h>
>  #include <linux/module.h>
> @@ -22,6 +23,7 @@
>  /* Register offsets */
>  #define TPS_REG_VID			0x00
>  #define TPS_REG_MODE			0x03
> +#define TPS_REG_CUSTOMER_USE		0x06
>  #define TPS_REG_CMD1			0x08
>  #define TPS_REG_DATA1			0x09
>  #define TPS_REG_INT_EVENT1		0x14
> @@ -99,10 +101,15 @@ struct tps6598x {
>  	struct power_supply *psy;
>  	struct power_supply_desc psy_desc;
>  	enum power_supply_usb_type usb_type;
> +
>  	struct tps6598x_pdo terms;
>  
>  	u32 data_status;
>  	u16 pwr_status;
> +#ifdef CONFIG_DEBUG_FS
> +	struct dentry *dev_dentry;
> +	struct dentry *customer_user_dentry;
> +#endif
>  };
>  
>  static enum power_supply_property tps6598x_psy_props[] = {
> @@ -239,6 +246,62 @@ static void tps6598x_set_data_role(struct tps6598x *tps,
>  	typec_set_data_role(tps->port, role);
>  }
>  
> +#ifdef CONFIG_DEBUG_FS
> +static struct dentry *rootdir;
> +
> +static int tps6598x_debug_customer_use_show(struct seq_file *s, void *v)
> +{
> +	struct tps6598x *tps = (struct tps6598x *)s->private;
> +	u64 mode64;
> +	int ret;
> +
> +	mutex_lock(&tps->lock);
> +
> +	ret =  tps6598x_block_read(tps, TPS_REG_CUSTOMER_USE, &mode64, sizeof(mode64));
> +	if (!ret)
> +		seq_printf(s, "0x%016llx\n", mode64);
> +
> +	mutex_unlock(&tps->lock);
> +
> +	return 0;
> +}
> +DEFINE_SHOW_ATTRIBUTE(tps6598x_debug_customer_use);
> +
> +static void tps6598x_debugfs_init(struct tps6598x *tps)
> +{
> +	struct dentry *dentry;
> +
> +	if (!rootdir)
> +		rootdir = debugfs_create_dir("tps6598x", NULL);
> +
> +	dentry = debugfs_create_dir(dev_name(tps->dev), rootdir);
> +	if (IS_ERR(dentry))
> +		return;
> +	tps->dev_dentry = dentry;
> +
> +	dentry = debugfs_create_file("customer_use",
> +				     S_IFREG | 0444, tps->dev_dentry,
> +				     tps, &tps6598x_debug_customer_use_fops);
> +	if (IS_ERR(dentry))
> +		return;
> +	tps->customer_user_dentry = dentry;
> +}
> +
> +static void tps6598x_debugfs_exit(struct tps6598x *tps)
> +{
> +	debugfs_remove(tps->customer_user_dentry);
> +	debugfs_remove(tps->dev_dentry);
> +	debugfs_remove(rootdir);
> +	rootdir = NULL;
> +}
> +
> +#else
> +
> +static void tps6598x_debugfs_init(const struct tps6598x *tps) { }
> +static void tps6598x_debugfs_exit(const struct tps6598x *tps) { }
> +
> +#endif
> +
>  static int tps6598x_connect(struct tps6598x *tps, u32 status)
>  {
>  	struct typec_partner_desc desc;
> @@ -995,6 +1058,7 @@ static int tps6598x_probe(struct i2c_client *client)
>  	}
>  
>  	i2c_set_clientdata(client, tps);
> +	tps6598x_debugfs_init(tps);
>  
>  	return 0;
>  
> @@ -1011,6 +1075,7 @@ static int tps6598x_remove(struct i2c_client *client)
>  {
>  	struct tps6598x *tps = i2c_get_clientdata(client);
>  
> +	tps6598x_debugfs_exit(tps);
>  	tps6598x_disconnect(tps, 0);
>  	typec_unregister_port(tps->port);
>  	usb_role_switch_put(tps->role_sw);
> -- 
> 2.35.1

-- 
heikki

  reply	other threads:[~2022-04-04 14:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-17 15:45 [PATCH 0/7] TPS6598x PD tracing and other improvements Sebastian Krzyszkowiak
2022-03-17 15:45 ` [PATCH 1/7] usb: typec: tipd: Only update power status on IRQ Sebastian Krzyszkowiak
2022-04-04 13:22   ` Heikki Krogerus
2022-03-17 15:45 ` [PATCH 2/7] usb: typec: tipd: set the data role on tps IRQ Sebastian Krzyszkowiak
2022-04-04 13:29   ` Heikki Krogerus
2022-03-17 15:45 ` [PATCH 3/7] usb: typec: tipd: Add trace event for SINK PD contract Sebastian Krzyszkowiak
2022-04-04 13:42   ` Heikki Krogerus
2022-03-17 15:45 ` [PATCH 4/7] usb: typec: tipd: Provide POWER_SUPPLY_PROP_{CURRENT,VOLTAGE}_MAX Sebastian Krzyszkowiak
2022-04-04 13:57   ` Heikki Krogerus
2022-03-17 15:45 ` [PATCH 5/7] usb: typec: tipd: Provide POWER_SUPPLY_PROP_PRESENT Sebastian Krzyszkowiak
2022-04-04 13:59   ` Heikki Krogerus
2022-03-17 15:45 ` [PATCH 6/7] usb: typec: tipd: Add debugfs entries for customer use word Sebastian Krzyszkowiak
2022-04-04 14:03   ` Heikki Krogerus [this message]
2022-03-17 15:45 ` [PATCH 7/7] usb: typec: tipd: Fail probe when the controller is in BOOT mode Sebastian Krzyszkowiak
2022-04-04 14:04   ` Heikki Krogerus
2022-04-01 13:49 ` [PATCH 0/7] TPS6598x PD tracing and other improvements Heikki Krogerus

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=Ykr6x/YwAwg/KUma@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=agx@sigxcpu.org \
    --cc=angus@akkea.ca \
    --cc=bryan.odonoghue@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@puri.sm \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=marcan@marcan.st \
    --cc=sebastian.krzyszkowiak@puri.sm \
    --cc=sven@svenpeter.dev \
    /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

all inboxes | Powered by JetHome®