All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Lee Jones <lee.jones@linaro.org>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Rob Herring <robh+dt@kernel.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	bcousson@baylibre.com, Tony Lindgren <tony@atomide.com>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-omap@vger.kernel.org,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Lokesh Vutla <lokeshvutla@ti.com>,
	Tero Kristo <kristo@kernel.org>,
	Ryan Barnett <ryan.barnett@collins.com>,
	Grygorii Strashko <grygorii.strashko@ti.com>,
	Jason Reeder <jreeder@ti.com>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH v3 17/47] mfd: ti_am335x_tscadc: Use driver data
Date: Wed, 22 Sep 2021 17:42:14 +0200	[thread overview]
Message-ID: <20210922174214.7aee560a@xps13> (raw)
In-Reply-To: <YUtFX/6I4VuBHXgf@google.com>

Hi Lee,

lee.jones@linaro.org wrote on Wed, 22 Sep 2021 16:01:51 +0100:

> On Wed, 15 Sep 2021, Miquel Raynal wrote:
> 
> > So far every sub-cell parameter in this driver was hardcoded: cell name,
> > cell compatible, specific clock name and desired clock frequency.
> > 
> > As we are about to introduce support for ADC1/magnetic reader, we need a
> > bit of flexibility. Let's add a driver data structure which will contain
> > these information.
> > 
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > ---
> >  drivers/mfd/ti_am335x_tscadc.c       | 25 +++++++++++++++++++------
> >  include/linux/mfd/ti_am335x_tscadc.h |  9 +++++++++
> >  2 files changed, 28 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> > index ba821109e98b..fbc8e338188a 100644
> > --- a/drivers/mfd/ti_am335x_tscadc.c
> > +++ b/drivers/mfd/ti_am335x_tscadc.c
> > @@ -137,6 +137,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
> >  		return -EINVAL;
> >  	}
> >  
> > +	tscadc->data = of_device_get_match_data(&pdev->dev);
> > +
> >  	node = of_get_child_by_name(pdev->dev.of_node, "tsc");
> >  	of_property_read_u32(node, "ti,wires", &tsc_wires);
> >  	of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
> > @@ -212,7 +214,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
> >  		goto err_disable_clk;
> >  	}
> >  
> > -	tscadc->clk_div = (clk_get_rate(clk) / ADC_CLK) - 1;
> > +	tscadc->clk_div = (clk_get_rate(clk) / tscadc->data->target_clk_rate) - 1;
> >  	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
> >  
> >  	/* Set the control register bits */
> > @@ -241,8 +243,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
> >  	if (tsc_wires > 0) {
> >  		tscadc->tsc_cell = tscadc->used_cells;
> >  		cell = &tscadc->cells[tscadc->used_cells++];
> > -		cell->name = "TI-am335x-tsc";
> > -		cell->of_compatible = "ti,am3359-tsc";
> > +		cell->name = tscadc->data->name_tscmag;
> > +		cell->of_compatible = tscadc->data->compat_tscmag;
> >  		cell->platform_data = &tscadc;
> >  		cell->pdata_size = sizeof(tscadc);
> >  	}
> > @@ -251,8 +253,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
> >  	if (adc_channels > 0) {
> >  		tscadc->adc_cell = tscadc->used_cells;
> >  		cell = &tscadc->cells[tscadc->used_cells++];
> > -		cell->name = "TI-am335x-adc";
> > -		cell->of_compatible = "ti,am3359-adc";
> > +		cell->name = tscadc->data->name_adc;
> > +		cell->of_compatible = tscadc->data->compat_adc;
> >  		cell->platform_data = &tscadc;
> >  		cell->pdata_size = sizeof(tscadc);
> >  	}
> > @@ -338,8 +340,19 @@ static int __maybe_unused tscadc_resume(struct device *dev)
> >  
> >  static SIMPLE_DEV_PM_OPS(tscadc_pm_ops, tscadc_suspend, tscadc_resume);
> >  
> > +static const struct ti_tscadc_data tscdata = {
> > +	.name_tscmag = "TI-am335x-tsc",
> > +	.compat_tscmag = "ti,am3359-tsc",
> > +	.name_adc = "TI-am335x-adc",
> > +	.compat_adc = "ti,am3359-adc",
> > +	.target_clk_rate = ADC_CLK,
> > +};
> > +
> >  static const struct of_device_id ti_tscadc_dt_ids[] = {
> > -	{ .compatible = "ti,am3359-tscadc", },
> > +	{
> > +		.compatible = "ti,am3359-tscadc",
> > +		.data = &tscdata,
> > +	},
> >  	{ }
> >  };
> >  MODULE_DEVICE_TABLE(of, ti_tscadc_dt_ids);
> > diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
> > index ffc091b77633..0f581c15d95a 100644
> > --- a/include/linux/mfd/ti_am335x_tscadc.h
> > +++ b/include/linux/mfd/ti_am335x_tscadc.h
> > @@ -162,11 +162,20 @@
> >  
> >  #define TSCADC_CELLS		2
> >  
> > +struct ti_tscadc_data {
> > +	char *name_tscmag;
> > +	char *compat_tscmag;
> > +	char *name_adc;
> > +	char *compat_adc;  
> 
> I think these names should be improved.
> 
> What is tscmag?
> 
> Does that represent both the Magnetic Reader and the Touchscreen?

Not exactly, it represents *either* the magnetic reader *or* the
touchscreen.

Basically you can have either one version of the hardware which
is a regular ADC that can be also used as a touchscreen controller, or
you can have another version of the hardware which is a regular ADC
that can be also used as a magnetic reader.

Both features can be used as the same time (ts + adc or mag + adc),
hence we need a name for the touchscreen child node and for the adc
child node *or* a name for the magnetic reader chil node and for the adc
child node.

> If so, I'd prefer that you split them.  If not, I need more info.
> 
> For readability, I suggest;
> 
>   touchscreen_name
>   touchscreen_compatible
>   mag_reader_name
>   mag_reader_compatible
>   adc_name
>   adc_compatible
>   etc
> 

I can certainly improve the names though.

> What is a magnetic reader anyway?
> 
> Does it read the magnetic stripe on a payment card?

Yes!

> 
> > +	unsigned int target_clk_rate;
> > +};
> > +
> >  struct ti_tscadc_dev {
> >  	struct device *dev;
> >  	struct regmap *regmap;
> >  	void __iomem *tscadc_base;
> >  	phys_addr_t tscadc_phys_base;
> > +	const struct ti_tscadc_data *data;
> >  	int irq;
> >  	int used_cells;	/* 1-2 */
> >  	int tsc_wires;  
> 


Thanks,
Miquèl

  reply	other threads:[~2021-09-22 15:42 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15 15:58 [PATCH v3 00/47] TI AM437X ADC1 Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 01/47] clk: ti: am43xx: Add clkctrl data for am43xx ADC1 Miquel Raynal
2021-09-21  7:49   ` Tony Lindgren
2021-09-15 15:58 ` [PATCH v3 02/47] dt-bindings: mfd: ti,am3359-tscadc: Add a yaml description for this MFD Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 03/47] dt-bindings: touchscreen: ti,am3359-tsc: New yaml description Miquel Raynal
2021-09-21  3:55   ` Dmitry Torokhov
2021-09-15 15:58 ` [PATCH v3 04/47] dt-bindings: iio: adc: ti,am3359-adc: " Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 05/47] dt-bindings: touchscreen: ti,am3359-tsc: Remove deprecated text file Miquel Raynal
2021-09-21  3:56   ` Dmitry Torokhov
2021-09-15 15:58 ` [PATCH v3 06/47] dt-bindings: mfd: ti,am3359-tscadc: Describe am4372 MFD compatible Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 07/47] dt-bindings: iio: adc: ti,am3359-adc: Describe am4372 ADC compatible Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 08/47] mfd: ti_am335x_tscadc: Ensure a balanced number of node get/put Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 09/47] mfd: ti_am335x_tscadc: Replace license text with SPDX tag Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 10/47] mfd: ti_am335x_tscadc: Fix style Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 11/47] mfd: ti_am335x_tscadc: Drop extra spacing when declaring stack variables Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 12/47] mfd: ti_am335x_tscadc: Get rid of useless gotos Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 13/47] mfd: ti_am335x_tscadc: Reword the comment explaining the dividers Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 14/47] mfd: ti_am335x_tscadc: Don't search the tree for our clock Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 15/47] mfd: ti_am335x_tscadc: Simplify divisor calculation Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 16/47] mfd: ti_am335x_tscadc: Move the driver structure allocation earlier Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 17/47] mfd: ti_am335x_tscadc: Use driver data Miquel Raynal
2021-09-22 15:01   ` Lee Jones
2021-09-22 15:42     ` Miquel Raynal [this message]
2021-09-22 15:54       ` Lee Jones
2021-09-15 15:58 ` [PATCH v3 18/47] mfd: ti_am335x_tscadc: Mimic the probe from resume() Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 19/47] mfd: ti_am335x_tscadc: Drop useless variables from the driver structure Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 20/47] mfd: ti_am335x_tscadc: Always provide an idle configuration Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 21/47] mfd: ti_am335x_tscadc: Reorder the initialization steps Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 22/47] mfd: ti_am335x_tscadc: Gather the ctrl register logic in one place Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 23/47] mfd: ti_am335x_tscadc: Replace the header license text with SPDX tag Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 24/47] mfd: ti_am335x_tscadc: Fix header spacing Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 25/47] mfd: ti_am335x_tscadc: Use the new HZ_PER_MHZ macro Miquel Raynal
2021-09-18 16:02   ` Jonathan Cameron
2021-09-15 15:58 ` [PATCH v3 26/47] mfd: ti_am335x_tscadc: Use BIT(), GENMASK() and FIELD_PREP() when relevant Miquel Raynal
2021-09-18 16:15   ` Jonathan Cameron
2021-09-15 15:58 ` [PATCH v3 27/47] mfd: ti_am335x_tscadc: Clarify the maximum values for DT entries Miquel Raynal
2021-09-18 16:22   ` Jonathan Cameron
2021-09-15 15:58 ` [PATCH v3 28/47] mfd: ti_am335x_tscadc: Drop useless definitions from the header Miquel Raynal
2021-09-18 16:31   ` Jonathan Cameron
2021-09-20 15:21     ` Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 29/47] mfd: ti_am335x_tscadc: Rename the subsystem enable macro Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 30/47] mfd: ti_am335x_tscadc: Add TSC prefix in certain macros Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 31/47] mfd: ti_am335x_tscadc: Rename a variable Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 32/47] mfd: ti_am335x_tscadc: Fix an error message Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 33/47] mfd: ti_am335x_tscadc: Add a boolean to clarify the presence of a touchscreen Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 34/47] mfd: ti_am335x_tscadc: Introduce has_tsc Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 35/47] mfd: ti_am335x_tscadc: Add ADC1/magnetic reader support Miquel Raynal
2021-09-22 16:00   ` Lee Jones
2021-09-23  8:33     ` Miquel Raynal
2021-09-28 10:34     ` Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 36/47] mfd: ti_am335x_tscadc: Support the correctly spelled DT property Miquel Raynal
2021-09-22 15:57   ` Lee Jones
2021-09-23  8:19     ` Miquel Raynal
2021-09-23  9:11       ` Lee Jones
2021-09-23  9:33         ` Miquel Raynal
2021-09-27  8:09           ` Lee Jones
2021-09-27  8:18             ` Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 37/47] iio: adc: ti_am335x_adc: Wait the idle state to avoid stalls Miquel Raynal
2021-09-15 15:58 ` [PATCH v3 38/47] iio: adc: ti_am335x_adc: Replace license text with SPDX tag Miquel Raynal
2021-09-15 15:59 ` [PATCH v3 39/47] iio: adc: ti_am335x_adc: Fix style Miquel Raynal
2021-09-15 15:59 ` [PATCH v3 40/47] iio: adc: ti_am335x_adc: Get rid of useless gotos Miquel Raynal
2021-09-15 15:59 ` [PATCH v3 41/47] iio: adc: ti_am335x_adc: Gather the checks on the delays Miquel Raynal
2021-09-15 15:59 ` [PATCH v3 42/47] iio: adc: ti_am335x_adc: Add a unit to the timeout delay Miquel Raynal
2021-09-15 15:59 ` [PATCH v3 43/47] iio: adc: ti_am335x_adc: Add the scale information Miquel Raynal
2021-09-15 15:59 ` [PATCH v3 44/47] iio: adc: ti_am335x_adc: Add the am437x compatible Miquel Raynal
2021-09-15 15:59 ` [PATCH v3 45/47] ARM: dts: am437x-cm-t43: Use a correctly spelled DT property Miquel Raynal
2021-09-21  7:51   ` Tony Lindgren
2021-09-15 15:59 ` [PATCH v3 46/47] ARM: dts: am43xx: Describe the magnetic reader/ADC1 hardware module Miquel Raynal
2021-09-21  7:51   ` Tony Lindgren
2021-09-15 15:59 ` [PATCH v3 47/47] ARM: dts: am437x-gp-evm: enable ADC1 Miquel Raynal
2021-09-20 15:30 ` [PATCH v3 00/47] TI AM437X ADC1 Miquel Raynal
2021-09-22 16:02 ` Lee Jones
2021-09-23  8:35   ` Miquel Raynal

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=20210922174214.7aee560a@xps13 \
    --to=miquel.raynal@bootlin.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=bcousson@baylibre.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=grygorii.strashko@ti.com \
    --cc=jic23@kernel.org \
    --cc=jreeder@ti.com \
    --cc=kristo@kernel.org \
    --cc=lars@metafoo.de \
    --cc=lee.jones@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=lokeshvutla@ti.com \
    --cc=pmeerw@pmeerw.net \
    --cc=robh+dt@kernel.org \
    --cc=ryan.barnett@collins.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=tony@atomide.com \
    --cc=vigneshr@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.