linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Quan Nguyen <quan@os.amperecomputing.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: macro@orcam.me.uk, Lee Jones <lee@kernel.org>,
	Bagas Sanjaya <bagasdotme@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Jean Delvare <jdelvare@suse.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Jonathan Corbet <corbet@lwn.net>,
	Derek Kiernan <derek.kiernan@xilinx.com>,
	Dragan Cvetic <dragan.cvetic@xilinx.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Thu Nguyen <thu@os.amperecomputing.com>,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org,
	OpenBMC Maillist <openbmc@lists.ozlabs.org>,
	Open Source Submission <patches@amperecomputing.com>,
	Phong Vo <phong@os.amperecomputing.com>,
	thang@os.amperecomputing.com
Subject: Re: [PATCH v9 5/9] misc: smpro-misc: Add Ampere's Altra SMpro misc driver
Date: Thu, 6 Oct 2022 14:45:03 +0700	[thread overview]
Message-ID: <dfeba303-9fdc-00b9-2ec6-6433041173b9@os.amperecomputing.com> (raw)
In-Reply-To: <YzVrpT6BD6qmu5ZG@kroah.com>



On 29/09/2022 16:55, Greg Kroah-Hartman wrote:
> On Thu, Sep 29, 2022 at 04:43:17PM +0700, Quan Nguyen wrote:
>> This commit adds driver support for accessing various information
>> reported by Ampere's SMpro co-processor such as Boot Progress and
>> other miscellaneous data.
>>
>> Signed-off-by: Quan Nguyen <quan@os.amperecomputing.com>
>> ---
>> Changes in v9:
>>    + Update SPDX licence                                     [Greg]
>>    + Use ATTRIBUTE_GROUPS()                                  [Greg]
>>    + Use dev_groups instead of sysfs_create_group() to avoid
>>    racing issue with user space                              [Greg]
>>    + Refactor code to avoid clever encoding issue            [Quan]
>>
>> Changes in v8:
>>    + Update wording for SMPRO_MISC in Kconfig file           [Quan]
>>    + Switch to use sysfs_emit()                              [Quan]
>>
>> Changes in v7:
>>    + Fix wrong return type of *_show/store()
>>    functions                                    [kernel robot test]
>>    + Adjust patch order to remove dependence with
>>    smpro-mfd                                            [Lee Jones]
>>
>> Changes in v6:
>>    + First introduced in v6 [Quan]
>>
>>   drivers/misc/Kconfig      |  10 +++
>>   drivers/misc/Makefile     |   1 +
>>   drivers/misc/smpro-misc.c | 145 ++++++++++++++++++++++++++++++++++++++
>>   3 files changed, 156 insertions(+)
>>   create mode 100644 drivers/misc/smpro-misc.c
>>
>> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
>> index b9ceee949dab..9947b7892bd5 100644
>> --- a/drivers/misc/Kconfig
>> +++ b/drivers/misc/Kconfig
>> @@ -188,6 +188,16 @@ config SMPRO_ERRMON
>>   	  To compile this driver as a module, say M here. The driver will be
>>   	  called smpro-errmon.
>>   
>> +config SMPRO_MISC
>> +	tristate "Ampere Computing SMPro miscellaneous driver"
>> +	depends on MFD_SMPRO || COMPILE_TEST
>> +	help
>> +	  Say Y here to get support for the SMpro error miscellalenous function
>> +	  provided by Ampere Computing's Altra and Altra Max SoCs.
>> +
>> +	  To compile this driver as a module, say M here. The driver will be
>> +	  called smpro-misc.
>> +
>>   config CS5535_MFGPT
>>   	tristate "CS5535/CS5536 Geode Multi-Function General Purpose Timer (MFGPT) support"
>>   	depends on MFD_CS5535
>> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
>> index bbe24d4511a3..87b54a4a4422 100644
>> --- a/drivers/misc/Makefile
>> +++ b/drivers/misc/Makefile
>> @@ -24,6 +24,7 @@ obj-$(CONFIG_KGDB_TESTS)	+= kgdbts.o
>>   obj-$(CONFIG_SGI_XP)		+= sgi-xp/
>>   obj-$(CONFIG_SGI_GRU)		+= sgi-gru/
>>   obj-$(CONFIG_SMPRO_ERRMON)	+= smpro-errmon.o
>> +obj-$(CONFIG_SMPRO_MISC)	+= smpro-misc.o
>>   obj-$(CONFIG_CS5535_MFGPT)	+= cs5535-mfgpt.o
>>   obj-$(CONFIG_GEHC_ACHC)		+= gehc-achc.o
>>   obj-$(CONFIG_HP_ILO)		+= hpilo.o
>> diff --git a/drivers/misc/smpro-misc.c b/drivers/misc/smpro-misc.c
>> new file mode 100644
>> index 000000000000..6c427141e51b
>> --- /dev/null
>> +++ b/drivers/misc/smpro-misc.c
>> @@ -0,0 +1,145 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/*
>> + * Ampere Computing SoC's SMpro Misc Driver
>> + *
>> + * Copyright (c) 2022, Ampere Computing LLC
>> + */
>> +#include <linux/mod_devicetable.h>
>> +#include <linux/module.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/regmap.h>
>> +
>> +/* Boot Stage/Progress Registers */
>> +#define BOOTSTAGE	0xB0
>> +#define BOOTSTAGE_LO	0xB1
>> +#define CUR_BOOTSTAGE	0xB2
>> +#define BOOTSTAGE_HI	0xB3
>> +
>> +/* SOC State Registers */
>> +#define SOC_POWER_LIMIT		0xE5
>> +
>> +struct smpro_misc {
>> +	struct regmap *regmap;
>> +};
>> +
>> +static ssize_t boot_progress_show(struct device *dev, struct device_attribute *da, char *buf)
>> +{
>> +	struct smpro_misc *misc = dev_get_drvdata(dev);
>> +	u16 boot_progress[3] = { 0 };
>> +	u32 bootstage;
>> +	u8 boot_stage;
>> +	u8 cur_stage;
>> +	u32 reg_lo;
>> +	u32 reg;
>> +	int ret;
>> +
>> +	/* Read current boot stage */
>> +	ret = regmap_read(misc->regmap, CUR_BOOTSTAGE, &reg);
>> +	if (ret)
>> +		return ret;
>> +
>> +	cur_stage = reg & 0xff;
>> +
>> +	ret = regmap_read(misc->regmap, BOOTSTAGE, &bootstage);
>> +	if (ret)
>> +		return ret;
>> +
>> +	boot_stage = (bootstage >> 8) & 0xff;
>> +
>> +	if (boot_stage > cur_stage)
>> +		return -EINVAL;
>> +
>> +	ret = regmap_read(misc->regmap,	BOOTSTAGE_LO, &reg_lo);
>> +	if (!ret)
>> +		ret = regmap_read(misc->regmap, BOOTSTAGE_HI, &reg);
>> +	if (ret)
>> +		return ret;
>> +
>> +	/* Firmware to report new boot stage next time */
>> +	if (boot_stage < cur_stage) {
>> +		ret = regmap_write(misc->regmap, BOOTSTAGE, ((bootstage & 0xff00) | 0x1));
>> +		if (ret)
>> +			return ret;
>> +	}
>> +
>> +	boot_progress[0] = bootstage;
>> +	boot_progress[1] = swab16(reg);
>> +	boot_progress[2] = swab16(reg_lo);
>> +
>> +	return sysfs_emit(buf, "%*phN\n", (int)sizeof(boot_progress), boot_progress);
>> +}
> 
> Again, please put the Documentation/ABI/ entries in this commit so that
> we can verify they are all correct.  Putting them at the end of the
> series makes it pretty impossible to review.  Would you want to have to
> match them all up the way you sent them?
> 
Will do in next version.

Thanks,
- Quan

  reply	other threads:[~2022-10-06  7:45 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-29  9:43 [PATCH v9 0/9] Add Ampere's Altra SMPro MFD and its child drivers Quan Nguyen
2022-09-29  9:43 ` [PATCH v9 1/9] hwmon: smpro: Add Ampere's Altra smpro-hwmon driver Quan Nguyen
2022-10-01 12:59   ` Bagas Sanjaya
2022-10-06  7:47     ` Quan Nguyen
2022-10-26 15:00   ` Guenter Roeck
2022-10-27  3:39     ` Quan Nguyen
2022-09-29  9:43 ` [PATCH v9 2/9] docs: hwmon: (smpro-hwmon) Add documentation Quan Nguyen
2022-10-01 12:56   ` Bagas Sanjaya
2022-10-06  7:47     ` Quan Nguyen
2022-09-29  9:43 ` [PATCH v9 3/9] misc: smpro-errmon: Add Ampere's SMpro error monitor driver Quan Nguyen
2022-09-29  9:53   ` Greg Kroah-Hartman
2022-10-06  7:44     ` Quan Nguyen
2022-09-29  9:43 ` [PATCH v9 4/9] docs: misc-devices: (smpro-errmon) Add documentation Quan Nguyen
2022-09-29  9:56   ` Greg Kroah-Hartman
2022-10-06  7:46     ` Quan Nguyen
2022-09-30  6:07   ` kernel test robot
2022-09-30 13:13   ` Bagas Sanjaya
2022-10-06  7:46     ` Quan Nguyen
2022-09-29  9:43 ` [PATCH v9 5/9] misc: smpro-misc: Add Ampere's Altra SMpro misc driver Quan Nguyen
2022-09-29  9:55   ` Greg Kroah-Hartman
2022-10-06  7:45     ` Quan Nguyen [this message]
2022-09-29  9:43 ` [PATCH v9 6/9] docs: misc-devices: (smpro-misc) Add documentation Quan Nguyen
2022-09-29  9:56   ` Greg Kroah-Hartman
2022-10-06  7:45     ` Quan Nguyen
2022-10-01  4:11   ` Bagas Sanjaya
2022-10-06  7:47     ` Quan Nguyen
2022-09-29  9:43 ` [PATCH v9 7/9] dt-bindings: mfd: Add bindings for Ampere Altra SMPro MFD driver Quan Nguyen
2022-09-29  9:43 ` [PATCH v9 8/9] mfd: Add Ampere's Altra SMpro " Quan Nguyen
2022-10-01 10:11   ` kernel test robot
2022-10-24 12:39   ` Lee Jones
2022-10-27  3:39     ` Quan Nguyen
2022-09-29  9:43 ` [PATCH v9 9/9] docs: ABI: testing: Document the Ampere Altra Family's SMpro sysfs interfaces Quan Nguyen
2022-09-30  9:38   ` Bagas Sanjaya
2022-10-06  7:46     ` Quan Nguyen
2022-09-30 19:41   ` kernel test robot

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=dfeba303-9fdc-00b9-2ec6-6433041173b9@os.amperecomputing.com \
    --to=quan@os.amperecomputing.com \
    --cc=arnd@arndb.de \
    --cc=bagasdotme@gmail.com \
    --cc=corbet@lwn.net \
    --cc=derek.kiernan@xilinx.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dragan.cvetic@xilinx.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jdelvare@suse.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lee@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=macro@orcam.me.uk \
    --cc=openbmc@lists.ozlabs.org \
    --cc=patches@amperecomputing.com \
    --cc=phong@os.amperecomputing.com \
    --cc=robh+dt@kernel.org \
    --cc=thang@os.amperecomputing.com \
    --cc=thu@os.amperecomputing.com \
    /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).