From: Lee Jones <lee.jones@linaro.org>
To: Robert Marko <robert.marko@sartura.hr>
Cc: robh+dt@kernel.org, linus.walleij@linaro.org,
bgolaszewski@baylibre.com, jdelvare@suse.com, linux@roeck-us.net,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-hwmon@vger.kernel.org,
luka.perkov@sartura.hr, jmp@epiphyte.org, pmenzel@molgen.mpg.de,
buczek@molgen.mpg.de
Subject: Re: [PATCH 1/6] mfd: Add Delta TN48M CPLD driver
Date: Wed, 19 May 2021 12:11:25 +0100 [thread overview]
Message-ID: <20210519111125.GD2403908@dell> (raw)
In-Reply-To: <20210430123511.116057-1-robert.marko@sartura.hr>
On Fri, 30 Apr 2021, Robert Marko wrote:
> Delta TN48M switches have a Lattice CPLD that serves
> multiple purposes including being a GPIO expander.
> So lets add the MFD core driver for it.
>
> Signed-off-by: Robert Marko <robert.marko@sartura.hr>
> ---
> drivers/mfd/Kconfig | 13 +++
> drivers/mfd/Makefile | 1 +
> drivers/mfd/tn48m-cpld.c | 181 ++++++++++++++++++++++++++++++++++++++
> include/linux/mfd/tn48m.h | 30 +++++++
> 4 files changed, 225 insertions(+)
> create mode 100644 drivers/mfd/tn48m-cpld.c
> create mode 100644 include/linux/mfd/tn48m.h
>
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index b74efa469e90..809041f98d71 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -297,6 +297,19 @@ config MFD_ASIC3
> This driver supports the ASIC3 multifunction chip found on many
> PDAs (mainly iPAQ and HTC based ones)
>
> +config MFD_TN48M_CPLD
> + tristate "Delta Networks TN48M switch CPLD driver"
> + depends on I2C
> + select MFD_CORE
> + select REGMAP_I2C
> + help
> + Select this option to enable support for Delta Networks TN48M switch
> + CPLD. It consists of GPIO and hwmon drivers.
> + CPLD provides GPIOS-s for the SFP slots as well as power supply
> + related information.
> + Driver provides debugfs information about the board model as
> + well as hardware and CPLD revision information.
No need for every sentence to be it's own paragraphs.
Please re-align to be a single chunk.
> config PMIC_DA903X
> bool "Dialog Semiconductor DA9030/DA9034 PMIC Support"
> depends on I2C=y
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index 834f5463af28..974663341f08 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -27,6 +27,7 @@ obj-$(CONFIG_MFD_TI_LP87565) += lp87565.o
> obj-$(CONFIG_MFD_DAVINCI_VOICECODEC) += davinci_voicecodec.o
> obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o
> obj-$(CONFIG_MFD_TI_AM335X_TSCADC) += ti_am335x_tscadc.o
> +obj-$(CONFIG_MFD_TN48M_CPLD) += tn48m-cpld.o
>
> obj-$(CONFIG_MFD_STA2X11) += sta2x11-mfd.o
> obj-$(CONFIG_MFD_STMPE) += stmpe.o
> diff --git a/drivers/mfd/tn48m-cpld.c b/drivers/mfd/tn48m-cpld.c
> new file mode 100644
> index 000000000000..b84510fb630a
> --- /dev/null
> +++ b/drivers/mfd/tn48m-cpld.c
> @@ -0,0 +1,181 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Delta TN48M CPLD parent driver
> + *
> + * Copyright 2020 Sartura Ltd
This is out of date.
> + * Author: Robert Marko <robert.marko@sartura.hr>
> + */
> +
> +#include <linux/debugfs.h>
> +#include <linux/i2c.h>
> +#include <linux/kernel.h>
> +#include <linux/mfd/core.h>
> +#include <linux/mfd/tn48m.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +#include <linux/slab.h>
> +
> +static const struct mfd_cell tn48m_cell[] = {};
Please populate this.
Without it, this is not an MFD.
> +static const struct regmap_config tn48m_regmap_config = {
> + .reg_bits = 8,
> + .val_bits = 8,
> + .max_register = 0x40,
> +};
> +
> +static int hardware_version_show(struct seq_file *s, void *data)
> +{
> + struct tn48m_data *priv = s->private;
> + unsigned int regval;
> + char *buf;
> +
> + regmap_read(priv->regmap, HARDWARE_VERSION_ID, ®val);
> +
> + switch (FIELD_GET(HARDWARE_VERSION_MASK, regval)) {
> + case HARDWARE_VERSION_EVT1:
> + buf = "EVT1";
> + break;
> + case HARDWARE_VERSION_EVT2:
> + buf = "EVT2";
> + break;
> + case HARDWARE_VERSION_DVT:
> + buf = "DVT";
> + break;
> + case HARDWARE_VERSION_PVT:
> + buf = "PVT";
> + break;
> + default:
> + buf = "Unknown";
> + break;
> + }
> +
> + seq_printf(s, "%s\n", buf);
> +
> + return 0;
> +}
> +
Please drop this '\n'.
> +DEFINE_SHOW_ATTRIBUTE(hardware_version);
> +
> +static int board_id_show(struct seq_file *s, void *data)
> +{
> + struct tn48m_data *priv = s->private;
> + unsigned int regval;
> + char *buf;
> +
> + regmap_read(priv->regmap, BOARD_ID, ®val);
> +
> + switch (regval) {
> + case BOARD_ID_TN48M:
> + buf = "TN48M";
> + break;
> + case BOARD_ID_TN48M_P:
> + buf = "TN48-P";
> + break;
> + default:
> + buf = "Unknown";
> + break;
> + }
> +
> + seq_printf(s, "%s\n", buf);
> +
> + return 0;
> +}
> +
Please drop this '\n'.
> +DEFINE_SHOW_ATTRIBUTE(board_id);
> +
> +static int code_version_show(struct seq_file *s, void *data)
> +{
> + struct tn48m_data *priv = s->private;
> + unsigned int regval;
> +
> + regmap_read(priv->regmap, CPLD_CODE_VERSION, ®val);
> +
> + seq_printf(s, "%d\n", regval);
> +
> + return 0;
> +}
> +
Please drop this '\n'.
> +DEFINE_SHOW_ATTRIBUTE(code_version);
> +
> +static void tn48m_init_debugfs(struct tn48m_data *data)
> +{
> + data->debugfs_dir = debugfs_create_dir(data->client->name, NULL);
> +
> + debugfs_create_file("hardware_version",
> + 0400,
> + data->debugfs_dir,
> + data,
> + &hardware_version_fops);
> +
> + debugfs_create_file("board_id",
> + 0400,
> + data->debugfs_dir,
> + data,
> + &board_id_fops);
> +
> + debugfs_create_file("code_version",
> + 0400,
> + data->debugfs_dir,
> + data,
> + &code_version_fops);
> +}
Does S/W actually do anything useful with these files?
Or are they just there for the sake of it?
If the latter, just print them to the kernel log and have done.
> +static int tn48m_probe(struct i2c_client *client)
> +{
> + struct tn48m_data *data;
'ddata' for both please.
> + int ret;
> +
> + data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
> + if (!data)
> + return -ENOMEM;
> +
> + data->client = client;
> + data->dev = &client->dev;
> + i2c_set_clientdata(client, data);
> +
> + data->regmap = devm_regmap_init_i2c(client, &tn48m_regmap_config);
> + if (IS_ERR(data->regmap)) {
> + dev_err(data->dev, "Failed to allocate regmap\n");
> + return PTR_ERR(data->regmap);
> + }
> +
> + ret = devm_mfd_add_devices(data->dev, PLATFORM_DEVID_AUTO, tn48m_cell,
> + ARRAY_SIZE(tn48m_cell), NULL, 0, NULL);
> + if (ret)
> + dev_err(data->dev, "Failed to register sub-devices %d\n", ret);
> +
> + tn48m_init_debugfs(data);
> +
> + return ret;
> +}
> +
> +static int tn48m_remove(struct i2c_client *client)
> +{
> + struct tn48m_data *data = i2c_get_clientdata(client);
> +
> + debugfs_remove_recursive(data->debugfs_dir);
> +
> + return 0;
> +}
> +
> +static const struct of_device_id tn48m_of_match[] = {
> + { .compatible = "delta,tn48m-cpld"},
Missing ' ' before the '}'.
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, tn48m_of_match);
> +
> +static struct i2c_driver tn48m_driver = {
> + .driver = {
> + .name = "tn48m-cpld",
> + .of_match_table = tn48m_of_match,
> + },
> + .probe_new = tn48m_probe,
> + .remove = tn48m_remove,
> +};
> +module_i2c_driver(tn48m_driver);
> +
> +MODULE_AUTHOR("Robert Marko <robert.marko@sartura.hr>");
> +MODULE_DESCRIPTION("Delta TN48M CPLD parent driver");
> +MODULE_LICENSE("GPL");
> diff --git a/include/linux/mfd/tn48m.h b/include/linux/mfd/tn48m.h
> new file mode 100644
> index 000000000000..551c550efa54
> --- /dev/null
> +++ b/include/linux/mfd/tn48m.h
> @@ -0,0 +1,30 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright 2020 Sartura Ltd
Out of date.
> + */
> +
> +#ifndef __TN48M_H__
> +#define __TN48M_H__
Better prefix with MFD.
> +#include <linux/device.h>
> +#include <linux/regmap.h>
> +
> +#define HARDWARE_VERSION_ID 0x0
> +#define HARDWARE_VERSION_MASK GENMASK(3, 0)
> +#define HARDWARE_VERSION_EVT1 0
> +#define HARDWARE_VERSION_EVT2 1
> +#define HARDWARE_VERSION_DVT 2
> +#define HARDWARE_VERSION_PVT 3
> +#define BOARD_ID 0x1
> +#define BOARD_ID_TN48M 0xa
> +#define BOARD_ID_TN48M_P 0xb
> +#define CPLD_CODE_VERSION 0x2
> +
> +struct tn48m_data {
> + struct device *dev;
> + struct regmap *regmap;
> + struct i2c_client *client;
You don't need both 'dev' and 'client'.
> + struct dentry *debugfs_dir;
> +};
> +
> +#endif
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
prev parent reply other threads:[~2021-05-19 11:11 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-30 12:35 [PATCH 1/6] mfd: Add Delta TN48M CPLD driver Robert Marko
2021-04-30 12:35 ` [PATCH 2/6] dt-bindings: gpio: Add Delta TN48M CPLD GPIO bindings Robert Marko
2021-05-06 13:57 ` Rob Herring
2021-04-30 12:35 ` [PATCH 3/6] gpio: Add Delta TN48M CPLD GPIO driver Robert Marko
2021-05-06 14:00 ` Rob Herring
2021-05-06 16:40 ` Michael Walle
2021-05-06 17:21 ` Luka Perkov
2021-05-21 13:22 ` Robert Marko
2021-05-06 16:38 ` Michael Walle
2021-05-21 13:21 ` Robert Marko
2021-04-30 12:35 ` [PATCH 4/6] hwmon: Add Delta TN48M CPLD HWMON driver Robert Marko
2021-04-30 13:12 ` Guenter Roeck
2021-05-19 12:01 ` Robert Marko
2021-05-19 13:40 ` Guenter Roeck
2021-04-30 12:35 ` [PATCH 5/6] dt-bindings: mfd: Add Delta TN48M CPLD drivers bindings Robert Marko
2021-05-06 14:01 ` Rob Herring
2021-04-30 12:35 ` [PATCH 6/6] MAINTAINERS: Add Delta Networks TN48M CPLD drivers Robert Marko
2021-05-06 16:34 ` [PATCH 1/6] mfd: Add Delta TN48M CPLD driver Michael Walle
2021-05-19 11:53 ` Robert Marko
2021-05-19 19:42 ` Michael Walle
2021-05-20 6:49 ` Lee Jones
2021-05-21 8:19 ` Robert Marko
2021-05-21 9:03 ` Lee Jones
2021-05-21 9:06 ` Robert Marko
2021-05-06 16:50 ` kernel test robot
2021-05-19 11:11 ` Lee Jones [this message]
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=20210519111125.GD2403908@dell \
--to=lee.jones@linaro.org \
--cc=bgolaszewski@baylibre.com \
--cc=buczek@molgen.mpg.de \
--cc=devicetree@vger.kernel.org \
--cc=jdelvare@suse.com \
--cc=jmp@epiphyte.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=luka.perkov@sartura.hr \
--cc=pmenzel@molgen.mpg.de \
--cc=robert.marko@sartura.hr \
--cc=robh+dt@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).