Devicetree
 help / color / mirror / Atom feed
* Re: [PATCH V7 0/7] dmaengine: qcom_hidma: add support for bugfixed HW
From: Vinod Koul @ 2017-12-10 16:39 UTC (permalink / raw)
  To: Sinan Kaya
  Cc: Rafael J. Wysocki, dmaengine, Timur Tabi,
	devicetree@vger.kernel.org, ACPI Devel Maling List, Sakari Ailus,
	linux-arm-msm, linux-arm-kernel@lists.infradead.org
In-Reply-To: <bad52be7-4ff8-4f06-4bd0-83e97701f495@codeaurora.org>

On Fri, Dec 08, 2017 at 09:44:46AM -0500, Sinan Kaya wrote:
> On 12/8/2017 8:48 AM, Rafael J. Wysocki wrote:
> > The series is fine by me, by how do you want to route it?
> 
> Probably through the DMA engine route as it has pieces that didn't get any
> review from Vinod yet.
> 
> Vinod,
> 
> Do you have any preference?

Yeah sure sounds okay to me as DMA parts are dependent on these.
Rafael if you need an immutable tag to pull this, let me know.

Thanks
-- 
~Vinod

^ permalink raw reply

* Re: [linux-sunxi] [PATCH 1/8] iio: adc: axp20x_adc: put ADC rate setting in a per-variant function
From: Jonathan Cameron @ 2017-12-10 16:37 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Quentin Schulz, Sebastian Reichel, Rob Herring, Mark Rutland,
	Russell King, Maxime Ripard, Lee Jones, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, open list:THERMAL,
	devicetree, linux-kernel, linux-arm-kernel,
	linux-iio-u79uwXL29TY76Z2rM5mHXA, Icenowy Zheng, linux-sunxi,
	Thomas Petazzoni
In-Reply-To: <CAGb2v64er1xMXCFDfNKqGjGN-TysQyjK+vfHdx0t+kaCchQfCg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Tue, 5 Dec 2017 11:35:49 +0800
Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org> wrote:

> On Mon, Dec 4, 2017 at 10:12 PM, Quentin Schulz
> <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> wrote:
> > To prepare for a new comer that set a different register with different
> > values, move rate setting in a function that is specific to each AXP
> > variant.
> >
> > Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> > ---
> >  drivers/iio/adc/axp20x_adc.c | 17 ++++++++++-------
> >  1 file changed, 10 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/iio/adc/axp20x_adc.c b/drivers/iio/adc/axp20x_adc.c
> > index a30a972..7274f4f 100644
> > --- a/drivers/iio/adc/axp20x_adc.c
> > +++ b/drivers/iio/adc/axp20x_adc.c
> > @@ -470,14 +470,18 @@ static const struct iio_info axp22x_adc_iio_info = {
> >         .read_raw = axp22x_read_raw,
> >  };
> >
> > -static int axp20x_adc_rate(int rate)
> > +static int axp20x_adc_rate(struct axp20x_adc_iio *info, int rate)
> >  {
> > -       return AXP20X_ADC_RATE_HZ(rate);
> > +       return regmap_update_bits(info->regmap, AXP20X_ADC_RATE,
> > +                                 AXP20X_ADC_RATE_MASK,
> > +                                 AXP20X_ADC_RATE_HZ(rate));
> >  }
> >
> > -static int axp22x_adc_rate(int rate)
> > +static int axp22x_adc_rate(struct axp20x_adc_iio *info, int rate)
> >  {
> > -       return AXP22X_ADC_RATE_HZ(rate);
> > +       return regmap_update_bits(info->regmap, AXP20X_ADC_RATE,
> > +                                 AXP20X_ADC_RATE_MASK,
> > +                                 AXP22X_ADC_RATE_HZ(rate));
> >  }
> >
> >  struct axp_data {
> > @@ -485,7 +489,7 @@ struct axp_data {
> >         int                             num_channels;
> >         struct iio_chan_spec const      *channels;
> >         unsigned long                   adc_en1_mask;
> > -       int                             (*adc_rate)(int rate);
> > +       int                             (*adc_rate)(struct axp20x_adc_iio *info, int rate);  
> 
> Could you also change the name of the callback, to say, adc_set_rate?
> This would make it much clearer what the callback does. Previously
> it was just a conversion helper.
> 
Agreed.

With that change you can add my
Acked-by: Jonathan Cameron <Jonathan.Cameron-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

Thanks,

Jonathan

> ChenYu
> 
> >         bool                            adc_en2;
> >         struct iio_map                  *maps;
> >  };
> > @@ -554,8 +558,7 @@ static int axp20x_probe(struct platform_device *pdev)
> >                                    AXP20X_ADC_EN2_MASK, AXP20X_ADC_EN2_MASK);
> >
> >         /* Configure ADCs rate */
> > -       regmap_update_bits(info->regmap, AXP20X_ADC_RATE, AXP20X_ADC_RATE_MASK,
> > -                          info->data->adc_rate(100));
> > +       info->data->adc_rate(info, 100);
> >
> >         ret = iio_map_array_register(indio_dev, info->data->maps);
> >         if (ret < 0) {
> > --
> > git-series 0.9.1
> >
> > --
> > You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > For more options, visit https://groups.google.com/d/optout.  
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 2/8] iio: adc: axp20x_adc: add support for AXP813 ADC
From: Jonathan Cameron @ 2017-12-10 16:36 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: sre-DgEjT+Ai2ygdnm+yROfE0A, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	mark.rutland-5wv7dgnIgG8, wens-jdAy2FN1RRM,
	linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	linux-pm-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-iio-u79uwXL29TY76Z2rM5mHXA, icenowy-h8G6r0blFSE,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
In-Reply-To: <ef830ce470a4f0f4be6040a776b6928bf89c0143.1512396054.git-series.quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

On Mon,  4 Dec 2017 15:12:48 +0100
Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> wrote:

> The X-Powers AXP813 PMIC is really close to what is already done for
> AXP20X/AXP22X.
> 
> There are two pairs of bits to set the rate (one for Voltage and Current
> measurements and one for TS/GPIO0 voltage measurements) instead of one.

This would normally imply we need to split the device into two logical
IIO devices.  However, that only becomes relevant if we are using
buffered output which this driver doesn't support.

It'll be nasty to deal with this if we add that support down the line
though.  Up to you though as it's more likely to be your problem than
anyone else's :)

For now you could elect to support the different sampling frequencies
if you wanted to but just providing controls for each channel.

Given the driver doesn't currently expose these at all (I think)
this is all rather immaterial ;)
> 
> The register to set the ADC rates is different from the one for
> AXP20X/AXP22X.
> 
> GPIO0 can be used as an ADC (measuring Volts) unlike for AXP22X.
> 
> The scales to apply to the different inputs are unlike the ones from
> AXP20X and AXP22X.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Looks good to me.

Acked-by: Jonathan Cameron <Jonathan.Cameron-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

I'm assuming these will probably go via MFD..

Jonathan
> ---
>  drivers/iio/adc/axp20x_adc.c | 122 ++++++++++++++++++++++++++++++++++++-
>  include/linux/mfd/axp20x.h   |   2 +-
>  2 files changed, 124 insertions(+)
> 
> diff --git a/drivers/iio/adc/axp20x_adc.c b/drivers/iio/adc/axp20x_adc.c
> index 7274f4f..03d489b 100644
> --- a/drivers/iio/adc/axp20x_adc.c
> +++ b/drivers/iio/adc/axp20x_adc.c
> @@ -35,8 +35,13 @@
>  #define AXP20X_GPIO10_IN_RANGE_GPIO1_VAL(x)	(((x) & BIT(0)) << 1)
>  
>  #define AXP20X_ADC_RATE_MASK			GENMASK(7, 6)
> +#define AXP813_V_I_ADC_RATE_MASK		GENMASK(5, 4)
> +#define AXP813_ADC_RATE_MASK			(AXP20X_ADC_RATE_MASK | AXP813_V_I_ADC_RATE_MASK)
>  #define AXP20X_ADC_RATE_HZ(x)			((ilog2((x) / 25) << 6) & AXP20X_ADC_RATE_MASK)
>  #define AXP22X_ADC_RATE_HZ(x)			((ilog2((x) / 100) << 6) & AXP20X_ADC_RATE_MASK)
> +#define AXP813_TS_GPIO0_ADC_RATE_HZ(x)		AXP20X_ADC_RATE_HZ(x)
> +#define AXP813_V_I_ADC_RATE_HZ(x)		((ilog2((x) / 100) << 4) & AXP813_V_I_ADC_RATE_MASK)
> +#define AXP813_ADC_RATE_HZ(x)			(AXP20X_ADC_RATE_HZ(x) | AXP813_V_I_ADC_RATE_HZ(x))
>  
>  #define AXP20X_ADC_CHANNEL(_channel, _name, _type, _reg)	\
>  	{							\
> @@ -95,6 +100,12 @@ enum axp22x_adc_channel_i {
>  	AXP22X_BATT_DISCHRG_I,
>  };
>  
> +enum axp813_adc_channel_v {
> +	AXP813_TS_IN = 0,
> +	AXP813_GPIO0_V,
> +	AXP813_BATT_V,
> +};
> +
>  static struct iio_map axp20x_maps[] = {
>  	{
>  		.consumer_dev_name = "axp20x-usb-power-supply",
> @@ -197,6 +208,25 @@ static const struct iio_chan_spec axp22x_adc_channels[] = {
>  			   AXP20X_BATT_DISCHRG_I_H),
>  };
>  
> +static const struct iio_chan_spec axp813_adc_channels[] = {
> +	{
> +		.type = IIO_TEMP,
> +		.address = AXP22X_PMIC_TEMP_H,
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +				      BIT(IIO_CHAN_INFO_SCALE) |
> +				      BIT(IIO_CHAN_INFO_OFFSET),
> +		.datasheet_name = "pmic_temp",
> +	},
> +	AXP20X_ADC_CHANNEL(AXP813_GPIO0_V, "gpio0_v", IIO_VOLTAGE,
> +			   AXP288_GP_ADC_H),
> +	AXP20X_ADC_CHANNEL(AXP813_BATT_V, "batt_v", IIO_VOLTAGE,
> +			   AXP20X_BATT_V_H),
> +	AXP20X_ADC_CHANNEL(AXP22X_BATT_CHRG_I, "batt_chrg_i", IIO_CURRENT,
> +			   AXP20X_BATT_CHRG_I_H),
> +	AXP20X_ADC_CHANNEL(AXP22X_BATT_DISCHRG_I, "batt_dischrg_i", IIO_CURRENT,
> +			   AXP20X_BATT_DISCHRG_I_H),
> +};
> +
>  static int axp20x_adc_raw(struct iio_dev *indio_dev,
>  			  struct iio_chan_spec const *chan, int *val)
>  {
> @@ -243,6 +273,18 @@ static int axp22x_adc_raw(struct iio_dev *indio_dev,
>  	return IIO_VAL_INT;
>  }
>  
> +static int axp813_adc_raw(struct iio_dev *indio_dev,
> +			  struct iio_chan_spec const *chan, int *val)
> +{
> +	struct axp20x_adc_iio *info = iio_priv(indio_dev);
> +
> +	*val = axp20x_read_variable_width(info->regmap, chan->address, 12);
> +	if (*val < 0)
> +		return *val;
> +
> +	return IIO_VAL_INT;
> +}
> +
>  static int axp20x_adc_scale_voltage(int channel, int *val, int *val2)
>  {
>  	switch (channel) {
> @@ -273,6 +315,24 @@ static int axp20x_adc_scale_voltage(int channel, int *val, int *val2)
>  	}
>  }
>  
> +static int axp813_adc_scale_voltage(int channel, int *val, int *val2)
> +{
> +	switch (channel) {
> +	case AXP813_GPIO0_V:
> +		*val = 0;
> +		*val2 = 800000;
> +		return IIO_VAL_INT_PLUS_MICRO;
> +
> +	case AXP813_BATT_V:
> +		*val = 1;
> +		*val2 = 100000;
> +		return IIO_VAL_INT_PLUS_MICRO;
> +
> +	default:
> +		return -EINVAL;
> +	}
> +}
> +
>  static int axp20x_adc_scale_current(int channel, int *val, int *val2)
>  {
>  	switch (channel) {
> @@ -342,6 +402,26 @@ static int axp22x_adc_scale(struct iio_chan_spec const *chan, int *val,
>  	}
>  }
>  
> +static int axp813_adc_scale(struct iio_chan_spec const *chan, int *val,
> +			    int *val2)
> +{
> +	switch (chan->type) {
> +	case IIO_VOLTAGE:
> +		return axp813_adc_scale_voltage(chan->channel, val, val2);
> +
> +	case IIO_CURRENT:
> +		*val = 1;
> +		return IIO_VAL_INT;
> +
> +	case IIO_TEMP:
> +		*val = 100;
> +		return IIO_VAL_INT;
> +
> +	default:
> +		return -EINVAL;
> +	}
> +}
> +
>  static int axp20x_adc_offset_voltage(struct iio_dev *indio_dev, int channel,
>  				     int *val)
>  {
> @@ -425,6 +505,26 @@ static int axp22x_read_raw(struct iio_dev *indio_dev,
>  	}
>  }
>  
> +static int axp813_read_raw(struct iio_dev *indio_dev,
> +			   struct iio_chan_spec const *chan, int *val,
> +			   int *val2, long mask)
> +{
> +	switch (mask) {
> +	case IIO_CHAN_INFO_OFFSET:
> +		*val = -2667;
> +		return IIO_VAL_INT;
> +
> +	case IIO_CHAN_INFO_SCALE:
> +		return axp813_adc_scale(chan, val, val2);
> +
> +	case IIO_CHAN_INFO_RAW:
> +		return axp813_adc_raw(indio_dev, chan, val);
> +
> +	default:
> +		return -EINVAL;
> +	}
> +}
> +
>  static int axp20x_write_raw(struct iio_dev *indio_dev,
>  			    struct iio_chan_spec const *chan, int val, int val2,
>  			    long mask)
> @@ -470,6 +570,10 @@ static const struct iio_info axp22x_adc_iio_info = {
>  	.read_raw = axp22x_read_raw,
>  };
>  
> +static const struct iio_info axp813_adc_iio_info = {
> +	.read_raw = axp813_read_raw,
> +};
> +
>  static int axp20x_adc_rate(struct axp20x_adc_iio *info, int rate)
>  {
>  	return regmap_update_bits(info->regmap, AXP20X_ADC_RATE,
> @@ -484,6 +588,13 @@ static int axp22x_adc_rate(struct axp20x_adc_iio *info, int rate)
>  				  AXP22X_ADC_RATE_HZ(rate));
>  }
>  
> +static int axp813_adc_rate(struct axp20x_adc_iio *info, int rate)
> +{
> +	return regmap_update_bits(info->regmap, AXP813_ADC_RATE,
> +				 AXP813_ADC_RATE_MASK,
> +				 AXP813_ADC_RATE_HZ(rate));
> +}
> +
>  struct axp_data {
>  	const struct iio_info		*iio_info;
>  	int				num_channels;
> @@ -514,9 +625,20 @@ static const struct axp_data axp22x_data = {
>  	.maps = axp22x_maps,
>  };
>  
> +static const struct axp_data axp813_data = {
> +	.iio_info = &axp813_adc_iio_info,
> +	.num_channels = ARRAY_SIZE(axp813_adc_channels),
> +	.channels = axp813_adc_channels,
> +	.adc_en1_mask = AXP22X_ADC_EN1_MASK,
> +	.adc_rate = axp813_adc_rate,
> +	.adc_en2 = false,
> +	.maps = axp22x_maps,
> +};
> +
>  static const struct platform_device_id axp20x_adc_id_match[] = {
>  	{ .name = "axp20x-adc", .driver_data = (kernel_ulong_t)&axp20x_data, },
>  	{ .name = "axp22x-adc", .driver_data = (kernel_ulong_t)&axp22x_data, },
> +	{ .name = "axp813-adc", .driver_data = (kernel_ulong_t)&axp813_data, },
>  	{ /* sentinel */ },
>  };
>  MODULE_DEVICE_TABLE(platform, axp20x_adc_id_match);
> diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
> index 78dc853..ff95414 100644
> --- a/include/linux/mfd/axp20x.h
> +++ b/include/linux/mfd/axp20x.h
> @@ -266,6 +266,8 @@ enum axp20x_variants {
>  #define AXP288_RT_BATT_V_H		0xa0
>  #define AXP288_RT_BATT_V_L		0xa1
>  
> +#define AXP813_ADC_RATE			0x85
> +
>  /* Fuel Gauge */
>  #define AXP288_FG_RDC1_REG          0xba
>  #define AXP288_FG_RDC0_REG          0xbb

^ permalink raw reply

* Re: [PATCH] iio: accel: bmc150: Add OF device ID table
From: Jonathan Cameron @ 2017-12-10 16:12 UTC (permalink / raw)
  To: Javier Martinez Canillas
  Cc: Jonathan Cameron, Hans de Goede,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Hartmut Knaack,
	linux-iio-u79uwXL29TY76Z2rM5mHXA, Lars-Peter Clausen,
	Peter Meerwald-Stadler, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Wolfram Sang
In-Reply-To: <337e54d5-7248-9eb2-e0c0-3a8b5443723d-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

On Mon, 4 Dec 2017 11:24:40 +0100
Javier Martinez Canillas <javierm-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:

> Hello Jonathan,
> 
> On 12/04/2017 10:44 AM, Jonathan Cameron wrote:
> > On Mon, 4 Dec 2017 09:29:38 +0100
> > Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> >   
> >> Hi,
> >>
> >> On 01-12-17 12:10, Javier Martinez Canillas wrote:  
> >>> The driver doesn't have a struct of_device_id table but supported devices
> >>> are registered via Device Trees. This is working on the assumption that a
> >>> I2C device registered via OF will always match a legacy I2C device ID and
> >>> that the MODALIAS reported will always be of the form i2c:<device>.
> >>>
> >>> But this could change in the future so the correct approach is to have an
> >>> OF device ID table if the devices are registered via OF.
> >>>
> >>> The I2C device ID table entries have the .driver_data field set, but they
> >>> are not used in the driver so weren't set in the OF device table entries.
> >>>
> >>> Signed-off-by: Javier Martinez Canillas <javierm-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> >>> ---
> >>>
> >>>   drivers/iio/accel/bmc150-accel-i2c.c | 12 ++++++++++++
> >>>   1 file changed, 12 insertions(+)
> >>>
> >>> diff --git a/drivers/iio/accel/bmc150-accel-i2c.c b/drivers/iio/accel/bmc150-accel-i2c.c
> >>> index f85014fbaa12..8ffc308d5fd0 100644
> >>> --- a/drivers/iio/accel/bmc150-accel-i2c.c
> >>> +++ b/drivers/iio/accel/bmc150-accel-i2c.c
> >>> @@ -81,9 +81,21 @@ static const struct i2c_device_id bmc150_accel_id[] = {
> >>>   
> >>>   MODULE_DEVICE_TABLE(i2c, bmc150_accel_id);
> >>>   
> >>> +static const struct of_device_id bmc150_accel_of_match[] = {
> >>> +	{ .compatible = "bosch,bmc150_accel" },
> >>> +	{ .compatible = "bosch,bmi055_accel" },    
> >>
> >> These look a bit weird, there is no reason to mirror the i2c_device_ids  
> > 
> > There has been a steady move for a long time to add these IDs with the plan
> > that we would stop automatically matching against the manufacturer free
> > i2c IDs. Mostly on the basis that was a hack that brought a lot  
> 
> Matching using OF IDs have been working for some time (since v4.10 AFAICT)
> after the following commit:
> 
> da10c06a044b ("i2c: Make I2C ID tables non-mandatory for DT'ed devices").
> 
> The only remaining problem is with module auto-loading.
> 
> > of effectively unreviewed device tree bindings. As I understand it the
> > eventual plan is to be able to get rid of that old path entirely...
> > +CC Wolfram to see what his view is on this.
> >  
> 
> I don't think we can get rid of the old path entirely since are valid use cases
> for it. For example when the I2C devices are registered with the i2c_new_device
> interface where the bus and address are declared in a struct i2c_board_info (ie:
> old platforms that still use board files or devices with an embedded I2C chip).

Agreed. I only meant the use of that path when matching device tree IDs.
There are still reasons to use it otherwise - including the ones you mention
and indeed manually adding the device - commonly done with various sensors
supported by lm-sensors on x86 boards.   These are often not described in
any way at all.

> 
> What I think though is that drivers should only be required to define the device
> table for the firmware interface used to instantiate them. For example, a driver
> for a device that's DT-only should only have an OF device ID table just like a
> driver for an ACPI-only device only requires to have an ACPI ID table.
> 
> Conversely, a driver for a device that's only instantiated using platform data
> should only have an I2C device ID table.
> 

A lot of drivers are used on both ACPI and DT platforms.  For newer cases we
perhaps don't need the i2c table.


> If a driver supports both DT and legacy platforms, then it's OK to have both ID
> tables defined. What is not correct is to require OF-only drivers to have an I2C
> device ID table just as a workaround to have their modules auto-loading working.

Absolutely agree.

Jonathan
> 
> Best regards,

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH v1 6/6] ARM: dts: imx7s: add usb hsic phy domain
From: Fabio Estevam @ 2017-12-10 15:23 UTC (permalink / raw)
  To: tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf
  Cc: Shawn Guo, Sascha Hauer,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, Mark Rutland,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel,
	Fabio Estevam
In-Reply-To: <20171205222707.11302-7-tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org>

On Tue, Dec 5, 2017 at 8:27 PM,  <tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org> wrote:
> From: Tyler Baker <tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org>
>
> The GPCv2 driver should control the MIPI, PCIe,
> and USB HSIC PHY regulators. Add the USB HSIC
> power domain to the GPC node.
>
> Signed-off-by: Tyler Baker <tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org>

Looks good. I am assuming you tested USB HSIC operation on the mx7
compulab board, right?

Reviewed-by: Fabio Estevam <fabio.estevam-3arQi8VN3Tc@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH v1 5/6] ARM: dts: imx7d-sbc-iot: enable PCIe peripheral
From: Fabio Estevam @ 2017-12-10 15:20 UTC (permalink / raw)
  To: tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf
  Cc: Shawn Guo, Sascha Hauer,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, Mark Rutland,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel,
	Fabio Estevam
In-Reply-To: <20171205222707.11302-6-tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org>

On Tue, Dec 5, 2017 at 8:27 PM,  <tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org> wrote:
> From: Tyler Baker <tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org>
>
> Add a PCIe device tree node to enable PCIe support.
>
> Signed-off-by: Tyler Baker <tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org>

Reviewed-by: Fabio Estevam <fabio.estevam-3arQi8VN3Tc@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH v1 4/6] ARM: dts: imx7s: add node and supplies for vdd1p2
From: Fabio Estevam @ 2017-12-10 15:20 UTC (permalink / raw)
  To: tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf
  Cc: Shawn Guo, Sascha Hauer,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, Mark Rutland,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel,
	Fabio Estevam
In-Reply-To: <20171205222707.11302-5-tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org>

On Tue, Dec 5, 2017 at 8:27 PM,  <tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org> wrote:
> From: Tyler Baker <tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org>
>
> Add the regulator nodes and supplies for vdd1p2. This regulator is
> used to power the GPC and USB HSIC PHY.
>
> Signed-off-by: Tyler Baker <tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org>
> ---
>  arch/arm/boot/dts/imx7s.dtsi | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
> index 7b85659..151ab34 100644
> --- a/arch/arm/boot/dts/imx7s.dtsi
> +++ b/arch/arm/boot/dts/imx7s.dtsi
> @@ -522,6 +522,20 @@
>                                         anatop-max-voltage = <1200000>;
>                                         anatop-enable-bit = <0>;
>                                 };
> +
> +                               reg_1p2: regulator-vdd1p2@220 {

Using a unit address without a corresponding reg would give you a
warning with W=1.

Please see the patch I sent with Subject:
ARM: dts: imx7s: Add unit address and reg for the anatop nodes
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH v1 3/6] ARM: dts: imx7s: add dma support
From: Fabio Estevam @ 2017-12-10 15:15 UTC (permalink / raw)
  To: tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf
  Cc: Shawn Guo, Sascha Hauer,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, Mark Rutland,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel,
	Fabio Estevam
In-Reply-To: <20171205222707.11302-4-tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org>

On Tue, Dec 5, 2017 at 8:27 PM,  <tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org> wrote:
> From: Tyler Baker <tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org>
>
> Enable dma on all SPI interfaces.
>
> Signed-off-by: Tyler Baker <tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org>

Reviewed-by: Fabio Estevam <fabio.estevam-3arQi8VN3Tc@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH v1 2/6] ARM: dts: imx7d-cl-som: add nodes for usbh, and usbotg2
From: Fabio Estevam @ 2017-12-10 15:14 UTC (permalink / raw)
  To: tyler
  Cc: Shawn Guo, Sascha Hauer, robh+dt@kernel.org, Mark Rutland,
	linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
	linux-kernel, Fabio Estevam
In-Reply-To: <20171205222707.11302-3-tyler@opensourcefoundries.com>

On Tue, Dec 5, 2017 at 8:27 PM,  <tyler@opensourcefoundries.com> wrote:
> From: Tyler Baker <tyler@opensourcefoundries.com>
>
> Add device tree nodes for the USB hub, and USB OTG. i2c2 on this
> platform supports low state retention power state so lets use it.

Looks like the I2C2 fix should be a separate patch.

^ permalink raw reply

* Re: [PATCH v1 1/6] ARM: dts: imx7d-sbc-iot: add initial iot gateway dts
From: Fabio Estevam @ 2017-12-10 15:10 UTC (permalink / raw)
  To: tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf
  Cc: Shawn Guo, Sascha Hauer,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, Mark Rutland,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel,
	Fabio Estevam, Ilya Ledvich
In-Reply-To: <20171205222707.11302-2-tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org>

On Tue, Dec 5, 2017 at 8:27 PM,  <tyler-yzvPICuk2AAEdKtRPRuaE5USO3DlRtUf@public.gmane.org> wrote:

> +&usdhc1 {
> +       pinctrl-names = "default";
> +       pinctrl-0 = <&pinctrl_usdhc1>;
> +       cd-gpios = <&gpio5 0 GPIO_ACTIVE_LOW>;
> +       wp-gpios = <&gpio5 1 GPIO_ACTIVE_HIGH>;
> +       enable-sdio-wakeup;

This is a deprecated property.

Please use wakeup-source as stated in
Documentation/devicetree/bindings/mmc/mmc.txt
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 00/12] Marvell NAND controller rework with ->exec_op()
From: Ezequiel Garcia @ 2017-12-09 23:27 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: David Woodhouse, Brian Norris, Boris Brezillon, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen, Rob Herring, Mark Rutland,
	Jason Cooper, Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
	Russell King, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Eric Miao, Catalin Marinas
In-Reply-To: <20171207201814.30411-1-miquel.raynal-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Miquel,

On 7 December 2017 at 17:18, Miquel Raynal
<miquel.raynal-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> wrote:
> Hi,
>
> After the addition of the NAND framework ->exec_op() interface (see [1]
> for the series preparing it and [2] for the last version of the
> core-side implementation of ->exec_op() itself), this series replaces
> the current Marvell NAND controller driver pxa3xx_nand.c with a rework
> called marvell_nand.c.
>

Nice to see this effort!

Unfortunately, I don't much time to spend reviewing this, but I'm super
happy to see a new driver fixing all the nasty issues the current one has.

Cheers,
-- 
Ezequiel García, VanguardiaSur
www.vanguardiasur.com.ar
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH 1/2] dt-bindings: Add Infineon TLV493D-A1B6
From: Andreas Färber @ 2017-12-09 23:25 UTC (permalink / raw)
  To: linux-iio-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Andreas Färber,
	Marius Tarcatu, Rob Herring, Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS
In-Reply-To: <20171209232507.18594-1-afaerber-l3A5Bk7waGM@public.gmane.org>

The Infineon TLV493D-A1B6 is an I2C-based 3D Magnetic Sensor.

Cc: Marius Tarcatu <marius.tarcatu-d0qZbvYSIPpWk0Htik3J/w@public.gmane.org>
Signed-off-by: Andreas Färber <afaerber-l3A5Bk7waGM@public.gmane.org>
---
 Documentation/devicetree/bindings/trivial-devices.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/trivial-devices.txt b/Documentation/devicetree/bindings/trivial-devices.txt
index 5f3143f97098..7ad1939cb0d6 100644
--- a/Documentation/devicetree/bindings/trivial-devices.txt
+++ b/Documentation/devicetree/bindings/trivial-devices.txt
@@ -63,6 +63,7 @@ fsl,sgtl5000		SGTL5000: Ultra Low-Power Audio Codec
 gmt,g751		G751: Digital Temperature Sensor and Thermal Watchdog with Two-Wire Interface
 infineon,slb9635tt	Infineon SLB9635 (Soft-) I2C TPM (old protocol, max 100khz)
 infineon,slb9645tt	Infineon SLB9645 I2C TPM (new protocol, max 400khz)
+infineon,tlv493d-a1b6	Infineon TLV493D-A1B6 I2C 3D Magnetic Sensor
 isil,isl1208		Intersil ISL1208 Low Power RTC with Battery Backed SRAM
 isil,isl1218		Intersil ISL1218 Low Power RTC with Battery Backed SRAM
 isil,isl12022		Intersil ISL12022 Real-time Clock
-- 
2.13.6

^ permalink raw reply related

* [PATCH 0/2] iio: magnetometer: Infineon TLV493D-A1B6 support
From: Andreas Färber @ 2017-12-09 23:25 UTC (permalink / raw)
  To: linux-iio-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Andreas Färber,
	Marius Tarcatu, devicetree-u79uwXL29TY76Z2rM5mHXA

Hello,

This mini-series adds initial support for the Infineon TLV493D-A1B6 3D Magnetic
Sensor found on the Infineon 3D Magnetic Sensor 2Go Kit.

Tested on a Raspberry Pi 3 with a DT Overlay.
https://github.com/afaerber/dt-overlays/blob/master/bcm2837-rpi-3-b%2Btlv493d-a1b6.dts

Have a lot of fun!

Cheers,
Andreas

Cc: Marius Tarcatu <marius.tarcatu-d0qZbvYSIPpWk0Htik3J/w@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

Andreas Färber (2):
  dt-bindings: Add Infineon TLV493D-A1B6
  iio: magnetometer: Add Infineon TLV493D-A1B6

 .../devicetree/bindings/trivial-devices.txt        |   1 +
 drivers/iio/magnetometer/Kconfig                   |   9 +
 drivers/iio/magnetometer/Makefile                  |   2 +
 drivers/iio/magnetometer/tlv493d.c                 | 328 +++++++++++++++++++++
 4 files changed, 340 insertions(+)
 create mode 100644 drivers/iio/magnetometer/tlv493d.c

-- 
2.13.6

^ permalink raw reply

* Re: [PATCH v8 1/2] dt: bindings: lm3692x: Add bindings for lm3692x LED driver
From: Jacek Anaszewski @ 2017-12-09 21:21 UTC (permalink / raw)
  To: Dan Murphy, Rob Herring
  Cc: mark.rutland, rpurdie, pavel, devicetree, linux-kernel,
	linux-leds
In-Reply-To: <c354b66d-f501-99bc-5928-efcfe33dbd06@ti.com>

On 12/08/2017 12:04 AM, Dan Murphy wrote:
> Rob
> 
> 
> On 12/07/2017 04:49 PM, Rob Herring wrote:
>> On Tue, Dec 05, 2017 at 02:46:29PM -0600, Dan Murphy wrote:
>>> This adds the devicetree bindings for the LM3692x
>>> I2C LED string driver.
>>>
>>> Acked-by: Pavel Machek <pavel@ucw.cz>
>>> Signed-off-by: Dan Murphy <dmurphy@ti.com>
>>> ---
>>>
>>> v8 - Added address-cells and size-cells as well as child node reg - https://patchwork.kernel.org/patch/10091259/
>>> v7 - No changes - https://patchwork.kernel.org/patch/10087475/
>>> v6 - No changes -https://patchwork.kernel.org/patch/10085567/
>>> v5 - No Changes - https://patchwork.kernel.org/patch/10081071/
>>> v4 - Fix example node, added trigger entry, removed ambiguous x for compatible and
>>> added common.txt pointer for label - https://patchwork.kernel.org/patch/10060107
>>> v3 - No changes
>>> v2 - No changes - https://patchwork.kernel.org/patch/10056677/
>>>
>>>  .../devicetree/bindings/leds/leds-lm3692x.txt      | 47 ++++++++++++++++++++++
>>>  1 file changed, 47 insertions(+)
>>>  create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3692x.txt
>>>
>>> diff --git a/Documentation/devicetree/bindings/leds/leds-lm3692x.txt b/Documentation/devicetree/bindings/leds/leds-lm3692x.txt
>>> new file mode 100644
>>> index 000000000000..84f69342d879
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/leds/leds-lm3692x.txt
>>> @@ -0,0 +1,47 @@
>>> +* Texas Instruments - LM3692x Highly Efficient White LED Driver
>>> +
>>> +The LM3692x is an ultra-compact, highly efficient,
>>> +white-LED driver designed for LCD display backlighting.
>>> +
>>> +The main difference between the LM36922 and LM36923 is the number of
>>> +LED strings it supports.  The LM36922 supports two strings while the LM36923
>>> +supports three strings.
>>> +
>>> +Required properties:
>>> +	- compatible:
>>> +		"ti,lm36922"
>>> +		"ti,lm36923"
>>> +	- reg :  I2C slave address
>>> +	- #address-cells : 1
>>> +	- #size-cells : 0
>>> +
>>> +Optional properties:
>>> +	- label : see Documentation/devicetree/bindings/leds/common.txt
>>
>> Should be a child prop.
> 
> Thanks I forgot to move this to Optional Child Properties.
> 
>>
>>> +	- enable-gpios : gpio pin to enable/disable the device.
>>> +	- vled-supply : LED supply
>>> +	- linux,default-trigger : (optional)
>>> +	   see Documentation/devicetree/bindings/leds/common.txt
>>
>> Ditto.
> 
> Ack
> 
>>
>>> +
>>> +Required child properties:
>>> +	- reg : 0
>>> +
>>> +Example:
>>> +
>>> +lm3692x@36 {
>>
>> leds@36
> 
> Rob why does this need to be leds?  Is this because it would be a child of an I2C node?
> 
> Jacek
> Would this not cause and issue for your proposal to take the parent node name as part of the LED label?

Yes, it would.

Rob, does something prevent us from adding a requirement that
LED controller DT node has to contain the chip name (besides the
unit address)? Many current LED controller nodes apply this pattern.

Also, I would appreciate if you could express your opinion on
the patch [0].

[0] https://patchwork.kernel.org/patch/10089047/

-- 
Best regards,
Jacek Anaszewski

^ permalink raw reply

* [PATCH] dt-bindings: mailbox: ti,message-manager: Fix interrupt name error
From: Nishanth Menon @ 2017-12-09 19:35 UTC (permalink / raw)
  To: Nishanth Menon, Marco Franchi, Mark Rutland, Rob Herring,
	Jassi Brar
  Cc: linux-kernel, devicetree

Message Manager's mailbox interrupts are queue based and not proxy
specific. The interrupt names are wrong in the binding, however
correctly reflected in the example provided. Remove the relation
to proxy ID in the documentation of binding. Existing device tree
descriptions follow the correct conventions already and documentation
update has been missed.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 Documentation/devicetree/bindings/mailbox/ti,message-manager.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/mailbox/ti,message-manager.txt b/Documentation/devicetree/bindings/mailbox/ti,message-manager.txt
index c3b55b3ede8a..ebf0e3710cee 100644
--- a/Documentation/devicetree/bindings/mailbox/ti,message-manager.txt
+++ b/Documentation/devicetree/bindings/mailbox/ti,message-manager.txt
@@ -20,9 +20,9 @@ Required properties:
 		        order referring to the transfer path.
 - interrupt-names:	Contains interrupt names matching the rx transfer path
 			for a given SoC. Receive interrupts shall be of the
-			format: "rx_<QID>_<PID>".
+			format: "rx_<QID>".
 			For ti,k2g-message-manager, this shall contain:
-				"rx_005_002", "rx_057_002"
+				"rx_005", "rx_057"
 - interrupts:		Contains the interrupt information corresponding to
 			interrupt-names property.
 
-- 
2.14.1

^ permalink raw reply related

* [PATCH] dt-bindings: chosen: Document linux,initrd-{start,end}
From: Jonathan Neuschäfer @ 2017-12-09 15:33 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: Jonathan Neuschäfer, Rob Herring, Mark Rutland,
	AKASHI Takahiro, Ard Biesheuvel, Kees Cook, James Morse,
	Frank Rowand, linux-kernel-u79uwXL29TY76Z2rM5mHXA

These properties have been in use for a very long time (at least since
2005), but were never documented in chosen.txt.

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer-hi6Y0CQ0nG0@public.gmane.org>
---
 Documentation/devicetree/bindings/chosen.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/Documentation/devicetree/bindings/chosen.txt b/Documentation/devicetree/bindings/chosen.txt
index e3b13ea7d2ae..45e79172a646 100644
--- a/Documentation/devicetree/bindings/chosen.txt
+++ b/Documentation/devicetree/bindings/chosen.txt
@@ -120,3 +120,18 @@ e.g.
 While this property does not represent a real hardware, the address
 and the size are expressed in #address-cells and #size-cells,
 respectively, of the root node.
+
+linux,initrd-start and linux,initrd-end
+---------------------------------------
+
+These properties hold the physical start and end address of an initrd that's
+loaded by the bootloader. Note that linux,initrd-start is inclusive, but
+linux,initrd-end is exclusive.
+e.g.
+
+/ {
+	chosen {
+		linux,initrd-start = <0x82000000>;
+		linux,initrd-end = <0x82800000>;
+	};
+};
-- 
2.15.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* Re: [PATCH v1 2/2] drm/tinydrm: add driver for ST7735R panels
From: Noralf Trønnes @ 2017-12-09 12:21 UTC (permalink / raw)
  To: David Lechner, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: limor-6aDhHjTmHzzR7s880joybQ, Rob Herring, Mark Rutland,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1511924469-11448-3-git-send-email-david-nq/r/kbU++upp/zk7JDF2g@public.gmane.org>


Den 29.11.2017 04.01, skrev David Lechner:
> This adds a new driver for Sitronix ST7735R display panels.
>
> This has been tested using an Adafruit 1.8" TFT.
>
> Signed-off-by: David Lechner <david-nq/r/kbU++upp/zk7JDF2g@public.gmane.org>
> ---
<snip>
> diff --git a/drivers/gpu/drm/tinydrm/st7735r.c b/drivers/gpu/drm/tinydrm/st7735r.c
<snip>
> +static struct drm_driver st7735r_driver = {
> +	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
> +				  DRIVER_ATOMIC,
> +	.fops			= &st7735r_fops,
> +	TINYDRM_GEM_DRIVER_OPS,
> +	.lastclose		= tinydrm_lastclose,

I was reminded of this since it would have made it easy to turn off the
panel and see if it turned white. Adding this makes it possible to send
commands from userspace for testing:

     .debugfs_init        = mipi_dbi_debugfs_init,

If you do that you have to set this to NULL since it's not possible to
read from the controller in this panel:

     mipi->read_commands = NULL;

Noralf.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 0/2] of: overlay: Crash fix and improvement
From: Geert Uytterhoeven @ 2017-12-09  9:04 UTC (permalink / raw)
  To: Frank Rowand
  Cc: Geert Uytterhoeven, Pantelis Antoniou, Rob Herring,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Linux-Renesas,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <f78620d2-7a6d-b90e-d773-9e3cc3d0cb6a-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Hi Frank,

On Sat, Dec 9, 2017 at 7:01 AM, Frank Rowand <frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> On 12/08/17 05:13, Geert Uytterhoeven wrote:
>> This patch series fixes memory corruption when applying overlays.
>> I first noticed this when using OF configfs.  After lots of failed
>> debugging attempts, I bisected it to "of: overlay: add per overlay sysfs
>> attributes", which is not upstream.  But that was a red herring: that
>> commit enlarged struct fragment to exactly 64-bytes, which just made it
>> more likely to cause random corruption when writing beyond the end of an
>> array of fragment structures.  With the smaller structure size before,
>> such writes usually ended up in the unused holes between allocated
>> blocks, causing no harm.
>>
>> The first patch is the real fix, and applies to both v4.15-rc2 and Rob's
>> for-next branch.
>> The second patch is a small improvement, and applies to Rob's for-next
>> branch only.
>
> Overlay FDT files should not have invalid contents.  But they inevitably
> will, so the code has to handle those cases.  Thanks for finding this
> problem and making the code better!

Sure, people can throw anything at it ;-)

In my case, I'm wondering if the dtbo was actually invalid?
Simplification of the decompiled dtbo:

/dts-v1/;

/ {

        fragment-name {
                target-path = [2f 00];

                __overlay__ {

                        node-name {
                                compatible = "foo,bar";
                                gpios = <0xffffffff 0x0 0x0>;
                        };
                };
        };

        __fixups__ {
                bank0 = "/fragment-name/__overlay__/node-name:gpios:0";
        };
};

So it has __fixup__, but no __symbols__, which looks totally valid to me.

> For the full series:
>
> Reviewed-by: Frank Rowand <frank.rowand-7U/KSKJipcs@public.gmane.org>

Thanks!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH 7/7] arm64: dts: mt8173: add uwk node and remove unused usb property
From: Chunfeng Yun @ 2017-12-09  8:45 UTC (permalink / raw)
  To: Rob Herring, Felipe Balbi, Matthias Brugger, Mathias Nyman
  Cc: Mark Rutland, Greg Kroah-Hartman, Catalin Marinas, Will Deacon,
	Chunfeng Yun, Jean Delvare, Sean Wang, devicetree, linux-kernel,
	linux-usb, linux-arm-kernel, linux-mediatek
In-Reply-To: <1512809136-2779-1-git-send-email-chunfeng.yun@mediatek.com>

Add uwk node for new way of usb remote wakeup instead of old one,
and modify some usb properties according binding documents
of mediatek,mtu3.txt and mediatek,mtk-xhci.txt

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 arch/arm64/boot/dts/mediatek/mt8173-evb.dts | 28 ++++++++++++++++++----------
 arch/arm64/boot/dts/mediatek/mt8173.dtsi    | 16 +++++-----------
 2 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
index 1c3634f..08a323b 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
@@ -14,6 +14,7 @@
 
 /dts-v1/;
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/soc/mediatek,usb-wakeup.h>
 #include "mt8173.dtsi"
 
 / {
@@ -68,6 +69,20 @@
 		gpio = <&pio 9 GPIO_ACTIVE_HIGH>;
 		enable-active-high;
 	};
+
+	usb_wakeup: uwk@0 {
+		compatible = "mediatek,mt8173-uwk","mediatek,usb-wk-v1";
+		mediatek,wkc = <&pericfg>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		status = "okay";
+
+		usb_wk0: uwk@400 {
+			reg = <0x400 0x8>;
+			#mediatek,uwk-cells = <1>;
+			status = "okay";
+		};
+	};
 };
 
 &cec {
@@ -268,12 +283,6 @@
 		};
 	};
 
-	usb_id_pins_ground: usb_iddig_pull_down {
-		pins_iddig {
-			pinmux = <MT8173_PIN_16_IDDIG__FUNC_IDDIG>;
-			bias-pull-down;
-		};
-	};
 };
 
 &pwm0 {
@@ -501,15 +510,14 @@
 };
 
 &ssusb {
+	mediatek,uwks = <&usb_wk0 MTU_WK_IP_SLEEP>;
 	vusb33-supply = <&mt6397_vusb_reg>;
 	vbus-supply = <&usb_p0_vbus>;
 	extcon = <&extcon_usb>;
 	dr_mode = "otg";
-	mediatek,enable-wakeup;
-	pinctrl-names = "default", "id_float", "id_ground";
+	wakeup-source;
+	pinctrl-names = "default";
 	pinctrl-0 = <&usb_id_pins_float>;
-	pinctrl-1 = <&usb_id_pins_float>;
-	pinctrl-2 = <&usb_id_pins_ground>;
 	status = "okay";
 };
 
diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 26396ef..818ead7 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -722,7 +722,7 @@
 		};
 
 		ssusb: usb@11271000 {
-			compatible = "mediatek,mt8173-mtu3";
+			compatible = "mediatek,mt8173-mtu3", "mediatek,mtu3";
 			reg = <0 0x11271000 0 0x3000>,
 			      <0 0x11280700 0 0x0100>;
 			reg-names = "mac", "ippc";
@@ -731,22 +731,16 @@
 			       <&u3port0 PHY_TYPE_USB3>,
 			       <&u2port1 PHY_TYPE_USB2>;
 			power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
-			clocks = <&topckgen CLK_TOP_USB30_SEL>,
-				 <&clk26m>,
-				 <&pericfg CLK_PERI_USB0>,
-				 <&pericfg CLK_PERI_USB1>;
-			clock-names = "sys_ck",
-				      "ref_ck",
-				      "wakeup_deb_p0",
-				      "wakeup_deb_p1";
-			mediatek,syscon-wakeup = <&pericfg>;
+			clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>;
+			clock-names = "sys_ck", "ref_ck";
 			#address-cells = <2>;
 			#size-cells = <2>;
 			ranges;
 			status = "disabled";
 
 			usb_host: xhci@11270000 {
-				compatible = "mediatek,mt8173-xhci";
+				compatible = "mediatek,mt8173-xhci",
+					     "mediatek,mtk-xhci";
 				reg = <0 0x11270000 0 0x1000>;
 				reg-names = "mac";
 				interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
-- 
1.9.1

^ permalink raw reply related

* [PATCH 6/7] dt-bindings: usb: mtu3: add USB wakeup properties
From: Chunfeng Yun @ 2017-12-09  8:45 UTC (permalink / raw)
  To: Rob Herring, Felipe Balbi, Matthias Brugger, Mathias Nyman
  Cc: Mark Rutland, Greg Kroah-Hartman, Catalin Marinas, Will Deacon,
	Chunfeng Yun, Jean Delvare, Sean Wang,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
In-Reply-To: <1512809136-2779-1-git-send-email-chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>

Modify the properties of usb wakeup, and use the new way of mtu_wakeup
which is extracted from SSUSB controller dirver as a new driver.

Signed-off-by: Chunfeng Yun <chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
 Documentation/devicetree/bindings/usb/mediatek,mtu3.txt | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
index b2271d8..2ed546d 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
@@ -42,9 +42,17 @@ Optional properties:
  - enable-manual-drd : supports manual dual-role switch via debugfs; usually
 	used when receptacle is TYPE-A and also wants to support dual-role
 	mode.
- - mediatek,enable-wakeup : supports ip sleep wakeup used by host mode
- - mediatek,syscon-wakeup : phandle to syscon used to access USB wakeup
-	control register, it depends on "mediatek,enable-wakeup".
+ - mediatek,uwks : a phandle to USB-Wakeup node to control the type of wakeup,
+	it's used to replace the old way which is realized by the property of
+	"mediatek,wakeup-wakeup" and "mediatek,syscon-wakeup",
+	see: Documentation/devicetree/bindings/soc/mediatek/usb-wakeup.txt
+ - wakeup-source : Decides if the new way of USB wakeup is supported or
+	not, it depends on "mediatek,uwks" property.
+ - mediatek,enable-wakeup : (deprecated) supports ip sleep wakeup used by
+	host mode, only supports mt8173 platform, use the property of
+	"mediatek,uwks" instead on other SoCs.
+ - mediatek,syscon-wakeup : (deprecated) phandle to syscon used to access
+	USB wakeup control register, it depends on "mediatek,enable-wakeup".
  - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
 	bit1 for u3port1, ... etc;
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 5/7] dt-bindings: usb: mtk-xhci: add USB wakeup properties
From: Chunfeng Yun @ 2017-12-09  8:45 UTC (permalink / raw)
  To: Rob Herring, Felipe Balbi, Matthias Brugger, Mathias Nyman
  Cc: Mark Rutland, Greg Kroah-Hartman, Catalin Marinas, Will Deacon,
	Chunfeng Yun, Jean Delvare, Sean Wang, devicetree, linux-kernel,
	linux-usb, linux-arm-kernel, linux-mediatek
In-Reply-To: <1512809136-2779-1-git-send-email-chunfeng.yun@mediatek.com>

Modify the properties of usb wakeup, and use the new way of mtu_wakeup
which is extracted from SSUSB controller dirver as a new one.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 .../devicetree/bindings/usb/mediatek,mtk-xhci.txt         | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
index 3059596..88984d8 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
@@ -35,10 +35,17 @@ Required properties:
  - phys : a list of phandle + phy specifier pairs
 
 Optional properties:
- - mediatek,wakeup-src : 1: ip sleep wakeup mode; 2: line state wakeup
-	mode;
- - mediatek,syscon-wakeup : phandle to syscon used to access USB wakeup
-	control register, it depends on "mediatek,wakeup-src".
+ - mediatek,uwks : a phandle to USB-Wakeup node to control the type of
+	wakeup, it's used to replace the old way which is realized by the
+	property of "mediatek,wakeup-src" and "mediatek,syscon-wakeup",
+	see: Documentation/devicetree/bindings/soc/mediatek/usb-wakeup.txt
+ - wakeup-source : Decides if the new way of USB wakeup is supported or
+	not, it depends on "mediatek,uwks" property.
+ - mediatek,wakeup-src : (deprecated) 1: ip sleep wakeup mode; 2: line
+	state wakeup mode; only supports mt8173 platform, use the property
+	of "mediatek,uwks" instead on other SoCs.
+ - mediatek,syscon-wakeup : (deprecated) phandle to syscon used to access
+	USB wakeup control register, depends on "mediatek,wakeup-src".
  - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
 	bit1 for u3port1, ... etc;
  - vbus-supply : reference to the VBUS regulator;
-- 
1.9.1

^ permalink raw reply related

* [PATCH 4/7] usb: mtu3: use APIs of mtu_wakeup to support remote wakeup
From: Chunfeng Yun @ 2017-12-09  8:45 UTC (permalink / raw)
  To: Rob Herring, Felipe Balbi, Matthias Brugger, Mathias Nyman
  Cc: Mark Rutland, Greg Kroah-Hartman, Catalin Marinas, Will Deacon,
	Chunfeng Yun, Jean Delvare, Sean Wang, devicetree, linux-kernel,
	linux-usb, linux-arm-kernel, linux-mediatek
In-Reply-To: <1512809136-2779-1-git-send-email-chunfeng.yun@mediatek.com>

On some platforms, there are two SSUSB IPs, but the old way of
usb wakeup doesn't support it, so use the new APIs of mtu_wakeup
to support it.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/usb/mtu3/mtu3.h      |  2 ++
 drivers/usb/mtu3/mtu3_host.c | 39 +++++++++++++++++++++++----------------
 2 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h
index 3c888d9..9f3eb79 100644
--- a/drivers/usb/mtu3/mtu3.h
+++ b/drivers/usb/mtu3/mtu3.h
@@ -255,6 +255,8 @@ struct ssusb_mtk {
 	/* usb wakeup for host mode */
 	bool wakeup_en;
 	struct regmap *pericfg;
+	struct mtu_wakeup *uwk;
+	bool new_wakeup;
 };
 
 /**
diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
index 7e948c0..f769b65 100644
--- a/drivers/usb/mtu3/mtu3_host.c
+++ b/drivers/usb/mtu3/mtu3_host.c
@@ -14,6 +14,7 @@
 #include <linux/mfd/syscon.h>
 #include <linux/of_device.h>
 #include <linux/regmap.h>
+#include <linux/soc/mediatek/usb-wakeup.h>
 
 #include "mtu3.h"
 #include "mtu3_dr.h"
@@ -56,24 +57,26 @@ static void ssusb_wakeup_ip_sleep_dis(struct ssusb_mtk *ssusb)
 int ssusb_wakeup_of_property_parse(struct ssusb_mtk *ssusb,
 				struct device_node *dn)
 {
-	struct device *dev = ssusb->dev;
+	/* try the new way first */
+	ssusb->new_wakeup = of_property_read_bool(dn, "wakeup-source");
+	if (ssusb->new_wakeup) {
+		ssusb->uwk = devm_of_uwk_get_by_index(ssusb->dev, dn, 0);
+		if (IS_ERR(ssusb->uwk))
+			dev_err(ssusb->dev, "fail to get mtu_wakeup\n");
+
+		return PTR_ERR_OR_ZERO(ssusb->uwk);
+	}
 
-	/*
-	 * Wakeup function is optional, so it is not an error if this property
-	 * does not exist, and in such case, no need to get relative
-	 * properties anymore.
-	 */
+	/* Wakeup function is optional. (deprecated, use the new way instead) */
 	ssusb->wakeup_en = of_property_read_bool(dn, "mediatek,enable-wakeup");
-	if (!ssusb->wakeup_en)
-		return 0;
-
-	ssusb->pericfg = syscon_regmap_lookup_by_phandle(dn,
+	if (ssusb->wakeup_en) {
+		ssusb->pericfg = syscon_regmap_lookup_by_phandle(dn,
 						"mediatek,syscon-wakeup");
-	if (IS_ERR(ssusb->pericfg)) {
-		dev_err(dev, "fail to get pericfg regs\n");
-		return PTR_ERR(ssusb->pericfg);
+		if (IS_ERR(ssusb->pericfg)) {
+			dev_err(ssusb->dev, "fail to get pericfg regs\n");
+			return PTR_ERR(ssusb->pericfg);
+		}
 	}
-
 	return 0;
 }
 
@@ -235,7 +238,9 @@ void ssusb_host_exit(struct ssusb_mtk *ssusb)
 
 int ssusb_wakeup_enable(struct ssusb_mtk *ssusb)
 {
-	if (ssusb->wakeup_en)
+	if (ssusb->new_wakeup)
+		mtu_wakeup_enable(ssusb->uwk);
+	else if (ssusb->wakeup_en)
 		ssusb_wakeup_ip_sleep_en(ssusb);
 
 	return 0;
@@ -243,6 +248,8 @@ int ssusb_wakeup_enable(struct ssusb_mtk *ssusb)
 
 void ssusb_wakeup_disable(struct ssusb_mtk *ssusb)
 {
-	if (ssusb->wakeup_en)
+	if (ssusb->new_wakeup)
+		mtu_wakeup_disable(ssusb->uwk);
+	else if (ssusb->wakeup_en)
 		ssusb_wakeup_ip_sleep_dis(ssusb);
 }
-- 
1.9.1

^ permalink raw reply related

* [PATCH 3/7] usb: xhci-mtk: use APIs of mtu_wakeup to support remote wakeup
From: Chunfeng Yun @ 2017-12-09  8:45 UTC (permalink / raw)
  To: Rob Herring, Felipe Balbi, Matthias Brugger, Mathias Nyman
  Cc: Mark Rutland, devicetree, linux-usb, Greg Kroah-Hartman,
	Sean Wang, Will Deacon, linux-kernel, linux-mediatek,
	linux-arm-kernel, Catalin Marinas, Chunfeng Yun, Jean Delvare
In-Reply-To: <1512809136-2779-1-git-send-email-chunfeng.yun@mediatek.com>

On some platforms, there are two xHCI IPs, but the old way of
usb wakeup doesn't support it, so use the new APIs of mtu_wakeup
to support it.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/usb/host/xhci-mtk.c | 39 +++++++++++++++++++++++----------------
 drivers/usb/host/xhci-mtk.h |  2 ++
 2 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index b62a1d2..3176a10 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -19,6 +19,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
+#include <linux/soc/mediatek/usb-wakeup.h>
 
 #include "xhci.h"
 #include "xhci-mtk.h"
@@ -366,7 +367,9 @@ static void usb_wakeup_line_state_dis(struct xhci_hcd_mtk *mtk)
 
 static void usb_wakeup_enable(struct xhci_hcd_mtk *mtk)
 {
-	if (mtk->wakeup_src == SSUSB_WK_IP_SLEEP)
+	if (mtk->wakeup)
+		mtu_wakeup_enable(mtk->uwk);
+	else if (mtk->wakeup_src == SSUSB_WK_IP_SLEEP)
 		usb_wakeup_ip_sleep_en(mtk);
 	else if (mtk->wakeup_src == SSUSB_WK_LINE_STATE)
 		usb_wakeup_line_state_en(mtk);
@@ -374,7 +377,9 @@ static void usb_wakeup_enable(struct xhci_hcd_mtk *mtk)
 
 static void usb_wakeup_disable(struct xhci_hcd_mtk *mtk)
 {
-	if (mtk->wakeup_src == SSUSB_WK_IP_SLEEP)
+	if (mtk->wakeup)
+		mtu_wakeup_disable(mtk->uwk);
+	else if (mtk->wakeup_src == SSUSB_WK_IP_SLEEP)
 		usb_wakeup_ip_sleep_dis(mtk);
 	else if (mtk->wakeup_src == SSUSB_WK_LINE_STATE)
 		usb_wakeup_line_state_dis(mtk);
@@ -383,24 +388,26 @@ static void usb_wakeup_disable(struct xhci_hcd_mtk *mtk)
 static int usb_wakeup_of_property_parse(struct xhci_hcd_mtk *mtk,
 				struct device_node *dn)
 {
-	struct device *dev = mtk->dev;
+	/* try the new way first */
+	mtk->wakeup = of_property_read_bool(dn, "wakeup-source");
+	if (mtk->wakeup) {
+		mtk->uwk = devm_of_uwk_get_by_index(mtk->dev, dn, 0);
+		if (IS_ERR(mtk->uwk))
+			dev_err(mtk->dev, "fail to get uwk\n");
+
+		return PTR_ERR_OR_ZERO(mtk->uwk);
+	}
 
-	/*
-	* wakeup function is optional, so it is not an error if this property
-	* does not exist, and in such case, no need to get relative
-	* properties anymore.
-	*/
+	/* wakeup function is optional (deprecated, use the new way instead) */
 	of_property_read_u32(dn, "mediatek,wakeup-src", &mtk->wakeup_src);
-	if (!mtk->wakeup_src)
-		return 0;
-
-	mtk->pericfg = syscon_regmap_lookup_by_phandle(dn,
+	if (mtk->wakeup_src) {
+		mtk->pericfg = syscon_regmap_lookup_by_phandle(dn,
 						"mediatek,syscon-wakeup");
-	if (IS_ERR(mtk->pericfg)) {
-		dev_err(dev, "fail to get pericfg regs\n");
-		return PTR_ERR(mtk->pericfg);
+		if (IS_ERR(mtk->pericfg)) {
+			dev_err(mtk->dev, "fail to get pericfg regs\n");
+			return PTR_ERR(mtk->pericfg);
+		}
 	}
-
 	return 0;
 }
 
diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index 6b74ce5..95bd6ca 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -124,6 +124,8 @@ struct xhci_hcd_mtk {
 	int num_phys;
 	int wakeup_src;
 	bool lpm_support;
+	struct mtu_wakeup *uwk;
+	bool wakeup;
 };
 
 static inline struct xhci_hcd_mtk *hcd_to_mtk(struct usb_hcd *hcd)
-- 
1.9.1

^ permalink raw reply related

* [PATCH 2/7] dt-bindings: soc: mediatek: add bindings document for USB wakeup
From: Chunfeng Yun @ 2017-12-09  8:45 UTC (permalink / raw)
  To: Rob Herring, Felipe Balbi, Matthias Brugger, Mathias Nyman
  Cc: Mark Rutland, devicetree, linux-usb, Greg Kroah-Hartman,
	Sean Wang, Will Deacon, linux-kernel, linux-mediatek,
	linux-arm-kernel, Catalin Marinas, Chunfeng Yun, Jean Delvare
In-Reply-To: <1512809136-2779-1-git-send-email-chunfeng.yun@mediatek.com>

This adds bindings document for the SSUSB-SPM glue layer driver found
in MediaTek SoCs which is used to support usb remote wakeup.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 .../bindings/soc/mediatek/usb-wakeup.txt           | 77 ++++++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/usb-wakeup.txt

diff --git a/Documentation/devicetree/bindings/soc/mediatek/usb-wakeup.txt b/Documentation/devicetree/bindings/soc/mediatek/usb-wakeup.txt
new file mode 100644
index 0000000..313d927
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/mediatek/usb-wakeup.txt
@@ -0,0 +1,77 @@
+MediaTek USB Wakeup binding
+-----------------------------
+
+The SSUSB-SPM glue layer is used to control some signals of USB
+wakeup, such as IP-SLEEP, LINE-STATE, IDDIG etc, which are mutually
+exclusive.
+
+Required properties (controller (parent) node):
+- compatible: Should be one of:
+	- "mediatek,<soc-model>-uwk","mediatek,usb-wk-v1"
+		soc-model is the name of SoC, supports one of:
+		- mt8173, mt8176
+	- "mediatek,<soc-model>-uwk","mediatek,usb-wk-v2"
+		soc-model is the name of SoC, supports one of:
+		- mt2712
+
+- mediatek,wkc: must contain a syscon phandle, such as pericfg controller
+- #address-cells : should be '1'
+- #size-cells : should be '1'
+
+Required nodes: a sub-node is required for each glue layer provided for
+	each SSUSB IP. Address range information including the usual 'reg'
+	property is used inside these nodes to describe the controller's
+	topology.
+
+Required properties (glue layer (child) node):
+- reg: address and length of the register set within the syscon which is
+	assigned to @mediatek,wkc.
+- #mediatek,uwk-cells: should be 1 (see the second example), cell after
+	glue layer phandle is wakeup type from:
+		- MTU_WK_IP_SLEEP
+		- MTU_WK_LINE_STATE
+	The wakeup types defined in
+		- include/dt-bindings/soc/mediatek,usb-wakeup.h
+
+
+Example:
+
+usb_wakeup: uwk@0 {
+	compatible = "mediatek,mt2712-uwk","mediatek,usb-wk-v2";
+	mediatek,wkc = <&pericfg>;
+	#address-cells = <1>;
+	#size-cells = <1>;
+	status = "okay";
+
+	usb_wk0: uwk@510 {
+		reg = <0x510 0x4>;
+		#mediatek,uwk-cells = <1>;
+		status = "okay";
+	};
+
+	usb_wk1: uwk@514 {
+		reg = <0x514 0x4>;
+		#mediatek,uwk-cells = <1>;
+		status = "okay";
+	};
+};
+
+
+Specifying wakeup control of devices
+---------------------------------
+
+Device nodes should specify the configuration required in their
+"mediatek,uwks" property, containing a phandle to the glue layer
+node and a wakeup type, because each USB controller has just one
+glue layer for wakeup, so only one phandle is supported;
+
+Example:
+
+#include <dt-bindings/soc/mediatek,usb-wakeup.h>
+
+usb_host1: xhci@112c0000 {
+	...
+	mediatek,uwks = <&usb_wk2 MTU_WK_IP_SLEEP>;
+	...
+};
+
-- 
1.9.1

^ permalink raw reply related

* [PATCH 1/7] soc: mediatek: Add USB wakeup driver
From: Chunfeng Yun @ 2017-12-09  8:45 UTC (permalink / raw)
  To: Rob Herring, Felipe Balbi, Matthias Brugger, Mathias Nyman
  Cc: Mark Rutland, Greg Kroah-Hartman, Catalin Marinas, Will Deacon,
	Chunfeng Yun, Jean Delvare, Sean Wang,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
In-Reply-To: <1512809136-2779-1-git-send-email-chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>

This driver is used to support usb wakeup which is controlled by
the glue layer between SSUSB and SPM. Usually the glue layer is put
into a system controller, such as pericfg module, which is
represented by a syscon node in DTS.
Due to the glue layer may vary on different SoCs, it's useful to
extract a separated driver to simplify usb controller drivers.

Signed-off-by: Chunfeng Yun <chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
 drivers/soc/mediatek/Kconfig                  |   8 +
 drivers/soc/mediatek/Makefile                 |   1 +
 drivers/soc/mediatek/mtk-usb-wakeup.c         | 519 ++++++++++++++++++++++++++
 include/dt-bindings/soc/mediatek,usb-wakeup.h |  15 +
 include/linux/soc/mediatek/usb-wakeup.h       |  88 +++++
 5 files changed, 631 insertions(+)
 create mode 100644 drivers/soc/mediatek/mtk-usb-wakeup.c
 create mode 100644 include/dt-bindings/soc/mediatek,usb-wakeup.h
 create mode 100644 include/linux/soc/mediatek/usb-wakeup.h

diff --git a/drivers/soc/mediatek/Kconfig b/drivers/soc/mediatek/Kconfig
index a7d0667..30cd226 100644
--- a/drivers/soc/mediatek/Kconfig
+++ b/drivers/soc/mediatek/Kconfig
@@ -31,4 +31,12 @@ config MTK_SCPSYS
 	  Say yes here to add support for the MediaTek SCPSYS power domain
 	  driver.
 
+config MTK_UWK
+	bool "MediaTek USB Wakeup Support"
+	select REGMAP
+	help
+	  Say yes here to add support for the MediaTek SSUSB-SPM glue layer
+	  which supports some different type of USB wakeup, such as IP-SLEEP,
+	  LINESTATE, IDDIG etc, and it can support multi SSUSB controllers.
+
 endmenu
diff --git a/drivers/soc/mediatek/Makefile b/drivers/soc/mediatek/Makefile
index 12998b0..66fbb54f 100644
--- a/drivers/soc/mediatek/Makefile
+++ b/drivers/soc/mediatek/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_MTK_INFRACFG) += mtk-infracfg.o
 obj-$(CONFIG_MTK_PMIC_WRAP) += mtk-pmic-wrap.o
 obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.o
+obj-$(CONFIG_MTK_UWK) += mtk-usb-wakeup.o
diff --git a/drivers/soc/mediatek/mtk-usb-wakeup.c b/drivers/soc/mediatek/mtk-usb-wakeup.c
new file mode 100644
index 0000000..16539a6
--- /dev/null
+++ b/drivers/soc/mediatek/mtk-usb-wakeup.c
@@ -0,0 +1,519 @@
+/*
+ * Copyright (c) 2017 MediaTek Inc.
+ * Author: Chunfeng Yun <chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ *
+ */
+
+#include <dt-bindings/soc/mediatek,usb-wakeup.h>
+#include <linux/kernel.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+#include <linux/soc/mediatek/usb-wakeup.h>
+
+/* mt8173, mt8176 etc */
+#define PERI_WK_CTRL1	0x4
+#define WC1_IS_C(x)	(((x) & 0xf) << 26) /* cycle debounce */
+#define WC1_IS_EN	BIT(25)
+#define WC1_IS_P	BIT(6)  /* polarity for ip sleep */
+
+/* mt2712 etc */
+#define PERI_SSUSB_SPM_CTRL	0x0
+#define SSC_LINE_STATE_CHG	GENMASK(11, 8)
+#define SSC_LINE_STATE_EN	GENMASK(6, 5)
+#define SSC_IP_SLEEP_EN	BIT(4)
+#define SSC_SPM_INT_EN		BIT(1)
+
+enum mtk_uwk_vers {
+	MTK_UWK_V1 = 1,
+	MTK_UWK_V2,
+};
+
+struct mtk_uwk_pdata {
+	enum mtk_uwk_vers vers;
+};
+
+/**
+ * @reg_base: register offset within a syscon @wkc (e.g. pericfg module)
+ * @type: the types of wakeup, such as IP-SLEEP, LINE-STATE etc
+ */
+struct mtk_uwk_instance {
+	struct mtu_wakeup uwk;
+	u32 reg_base;
+	u32 reg_len;
+	u32 type;
+};
+
+struct mtk_uwk {
+	struct device *dev;
+	struct regmap *wkc;
+	const struct mtk_uwk_pdata *data;
+	struct mtk_uwk_instance **inst;
+	int num_inst;
+};
+
+static LIST_HEAD(of_uwk_providers);
+static DEFINE_MUTEX(of_uwk_mutex);
+
+static struct mtu_wakeup_provider *of_uwk_provider_add(struct device *dev,
+		struct mtu_wakeup *(*of_xlate)(struct device *dev,
+		struct of_phandle_args *args))
+{
+	struct mtu_wakeup_provider *provider;
+
+	provider = kzalloc(sizeof(*provider), GFP_KERNEL);
+	if (!provider)
+		return ERR_PTR(-ENOMEM);
+
+	provider->dev = dev;
+	provider->of_node = of_node_get(dev->of_node);
+	provider->of_xlate = of_xlate;
+
+	mutex_lock(&of_uwk_mutex);
+	list_add_tail(&provider->list, &of_uwk_providers);
+	mutex_unlock(&of_uwk_mutex);
+
+	return provider;
+}
+
+static void of_uwk_provider_del(struct device_node *np)
+{
+	struct mtu_wakeup_provider *provider;
+
+	mutex_lock(&of_uwk_mutex);
+	list_for_each_entry(provider, &of_uwk_providers, list) {
+		if (provider->of_node == np) {
+			list_del(&provider->list);
+			of_node_put(provider->of_node);
+			kfree(provider);
+			break;
+		}
+	}
+	mutex_unlock(&of_uwk_mutex);
+}
+
+static struct mtu_wakeup *of_uwk_get_from_provider(
+		struct of_phandle_args *args)
+{
+	struct mtu_wakeup_provider *provider;
+	struct device_node *child_np;
+	struct mtu_wakeup *uwk;
+
+	mutex_lock(&of_uwk_mutex);
+	list_for_each_entry(provider, &of_uwk_providers, list) {
+		for_each_child_of_node(provider->of_node, child_np) {
+			if (child_np == args->np) {
+				uwk = provider->of_xlate(provider->dev, args);
+				mutex_unlock(&of_uwk_mutex);
+				return uwk;
+			}
+		}
+	}
+	mutex_unlock(&of_uwk_mutex);
+
+	return ERR_PTR(-EPROBE_DEFER);
+}
+
+static struct mtu_wakeup *of_uwk_get(struct device_node *np, int index)
+{
+	struct mtu_wakeup *uwk = NULL;
+	struct of_phandle_args args;
+	int ret;
+
+	ret = of_parse_phandle_with_args(np, "mediatek,uwks",
+				"#mediatek,uwk-cells", index, &args);
+	if (ret)
+		return ERR_PTR(-ENODEV);
+
+	if (!of_device_is_available(args.np)) {
+		dev_warn(uwk->parent, "Requested uwk is disabled\n");
+		uwk = ERR_PTR(-ENODEV);
+		goto put_node;
+	}
+
+	uwk = of_uwk_get_from_provider(&args);
+
+put_node:
+	of_node_put(args.np);
+	return uwk;
+}
+
+static void devm_uwk_release(struct device *dev, void *res)
+{
+	struct mtu_wakeup *uwk = *(struct mtu_wakeup **)res;
+
+	if (IS_ERR_OR_NULL(uwk))
+		return;
+
+	module_put(uwk->ops->owner);
+	put_device(uwk->parent);
+}
+
+struct mtu_wakeup *devm_of_uwk_get_by_index(
+		struct device *dev, struct device_node *np, int index)
+{
+	struct mtu_wakeup **ptr, *uwk;
+
+	ptr = devres_alloc(devm_uwk_release, sizeof(*ptr), GFP_KERNEL);
+	if (!ptr)
+		return ERR_PTR(-ENOMEM);
+
+	uwk = of_uwk_get(np, index);
+	if (IS_ERR(uwk)) {
+		devres_free(ptr);
+		return uwk;
+	}
+
+	if (!try_module_get(uwk->ops->owner)) {
+		devres_free(ptr);
+		return ERR_PTR(-EPROBE_DEFER);
+	}
+
+	get_device(uwk->parent);
+
+	*ptr = uwk;
+	devres_add(dev, ptr);
+
+	return uwk;
+}
+EXPORT_SYMBOL_GPL(devm_of_uwk_get_by_index);
+
+int mtu_wakeup_enable(struct mtu_wakeup *uwk)
+{
+	int ret = 0;
+
+	if (!uwk)
+		return 0;
+
+	mutex_lock(&uwk->mutex);
+	if (uwk->count == 0 && uwk->ops->enable) {
+		ret = uwk->ops->enable(uwk);
+		if (ret) {
+			dev_err(uwk->parent, "uwk enable failed(%d)\n", ret);
+			goto out;
+		}
+	}
+	++uwk->count;
+
+out:
+	mutex_unlock(&uwk->mutex);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(mtu_wakeup_enable);
+
+int mtu_wakeup_disable(struct mtu_wakeup *uwk)
+{
+	int ret = 0;
+
+	if (!uwk)
+		return 0;
+
+	mutex_lock(&uwk->mutex);
+	if (uwk->count == 1 && uwk->ops->disable) {
+		ret =  uwk->ops->disable(uwk);
+		if (ret) {
+			dev_err(uwk->parent, "uwk disable failed(%d)\n", ret);
+			goto out;
+		}
+	}
+	--uwk->count;
+
+out:
+	mutex_unlock(&uwk->mutex);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(mtu_wakeup_disable);
+
+static struct mtk_uwk_instance *to_mwk_inst(struct mtu_wakeup *uwk)
+{
+	return uwk ? container_of(uwk, struct mtk_uwk_instance, uwk) : NULL;
+}
+
+static int mwk_v1_enable(struct mtk_uwk *mwk, struct mtk_uwk_instance *inst)
+{
+	struct regmap *wkc = mwk->wkc;
+	u32 val;
+
+	/* Only IP-SLEEP is supported */
+	if (inst->type != MTU_WK_IP_SLEEP)
+		return 0;
+
+	regmap_read(wkc, PERI_WK_CTRL1, &val);
+	val &= ~(WC1_IS_P | WC1_IS_C(0xf));
+	val |= WC1_IS_EN | WC1_IS_C(0x8);
+	regmap_write(wkc, PERI_WK_CTRL1, val);
+	regmap_read(wkc, PERI_WK_CTRL1, &val);
+	dev_dbg(mwk->dev, "%s: WK_CTRL1=%#x, type=%d\n",
+		__func__, val, inst->type);
+
+	return 0;
+}
+
+static int mwk_v1_disable(struct mtk_uwk *mwk, struct mtk_uwk_instance *inst)
+{
+	if (inst->type == MTU_WK_IP_SLEEP)
+		regmap_update_bits(mwk->wkc, PERI_WK_CTRL1, WC1_IS_EN, 0);
+
+	return 0;
+}
+
+static int mwk_v2_enable(struct mtk_uwk *mwk, struct mtk_uwk_instance *inst)
+{
+	struct regmap *wkc = mwk->wkc;
+	u32 rbase = inst->reg_base;
+	u32 val;
+
+	regmap_read(wkc, rbase + PERI_SSUSB_SPM_CTRL, &val);
+	switch (inst->type) {
+	case MTU_WK_IP_SLEEP:
+		val |= SSC_IP_SLEEP_EN;
+		break;
+	case MTU_WK_LINE_STATE:
+		val |= SSC_LINE_STATE_EN | SSC_LINE_STATE_CHG;
+		break;
+	default:
+		/* checked by xlate, ignore the error */
+		break;
+	}
+	val |= SSC_SPM_INT_EN;
+	regmap_write(wkc, rbase + PERI_SSUSB_SPM_CTRL, val);
+	regmap_read(wkc, rbase + PERI_SSUSB_SPM_CTRL, &val);
+	dev_dbg(mwk->dev, "%s: CTRL=%#x, type=%d\n",
+		__func__, val, inst->type);
+
+	return 0;
+}
+
+static int mwk_v2_disable(struct mtk_uwk *mwk, struct mtk_uwk_instance *inst)
+{
+	struct regmap *wkc = mwk->wkc;
+	u32 rbase = inst->reg_base;
+	u32 val;
+
+	regmap_read(wkc, rbase + PERI_SSUSB_SPM_CTRL, &val);
+	switch (inst->type) {
+	case MTU_WK_IP_SLEEP:
+		val &= ~SSC_IP_SLEEP_EN;
+		break;
+	case MTU_WK_LINE_STATE:
+		val &= ~(SSC_LINE_STATE_EN | SSC_LINE_STATE_CHG);
+		break;
+	default:
+		break;
+	}
+	val &= ~SSC_SPM_INT_EN;
+	regmap_write(wkc, rbase + PERI_SSUSB_SPM_CTRL, val);
+	dev_dbg(mwk->dev, "%s: type=%d\n", __func__, inst->type);
+
+	return 0;
+}
+
+static int mwk_enable(struct mtu_wakeup *uwk)
+{
+	struct mtk_uwk_instance *inst = to_mwk_inst(uwk);
+	struct mtk_uwk *mwk = dev_get_drvdata(uwk->parent);
+	int ret = 0;
+
+	switch (mwk->data->vers) {
+	case MTK_UWK_V1:
+		ret = mwk_v1_enable(mwk, inst);
+		break;
+	case MTK_UWK_V2:
+		ret = mwk_v2_enable(mwk, inst);
+		break;
+	default:
+		break;
+	}
+	return ret;
+}
+
+static int mwk_disable(struct mtu_wakeup *uwk)
+{
+	struct mtk_uwk_instance *inst = to_mwk_inst(uwk);
+	struct mtk_uwk *mwk = dev_get_drvdata(uwk->parent);
+	int ret = 0;
+
+	switch (mwk->data->vers) {
+	case MTK_UWK_V1:
+		ret = mwk_v1_disable(mwk, inst);
+		break;
+	case MTK_UWK_V2:
+		ret = mwk_v2_disable(mwk, inst);
+		break;
+	default:
+		break;
+	}
+	return ret;
+}
+
+static struct mtk_uwk_instance *mwk_inst_create(struct device *dev,
+		struct device_node *np,
+		const struct mtu_wakeup_ops *ops)
+{
+	struct mtk_uwk_instance *inst;
+	struct mtu_wakeup *uwk;
+	u32 buf[2];
+	int ret;
+
+	inst = devm_kzalloc(dev, sizeof(*inst), GFP_KERNEL);
+	if (!inst)
+		return ERR_PTR(-ENOMEM);
+
+	ret = of_property_read_u32_array(np, "reg", buf, ARRAY_SIZE(buf));
+	if (ret) {
+		dev_err(dev, "fail to read reg\n");
+		return ERR_PTR(ret);
+	}
+
+	inst->reg_base = buf[0];
+	inst->reg_len = buf[1];
+	uwk = &inst->uwk;
+	uwk->node = np;
+	uwk->ops = ops;
+	uwk->parent = dev;
+	mutex_init(&uwk->mutex);
+	dev_dbg(dev, "reg: %#x/%#x\n", inst->reg_base, inst->reg_len);
+
+	return inst;
+}
+
+static struct mtu_wakeup *mwk_xlate(struct device *dev,
+		struct of_phandle_args *args)
+{
+	struct mtk_uwk *mwk = dev_get_drvdata(dev);
+	struct mtk_uwk_instance *inst = NULL;
+	struct device_node *uwk_np = args->np;
+	int index;
+
+	if (args->args_count != 1) {
+		dev_err(dev, "invalid number of cells in uwk property\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	for (index = 0; index < mwk->num_inst; index++)
+		if (uwk_np == mwk->inst[index]->uwk.node) {
+			inst = mwk->inst[index];
+			break;
+		}
+
+	if (!inst) {
+		dev_err(dev, "failed to find appropriate uwk\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	inst->type = args->args[0];
+	if (!(inst->type == MTU_WK_IP_SLEEP ||
+	      inst->type == MTU_WK_LINE_STATE)) {
+		dev_err(dev, "unsupported uwk type=%d\n", inst->type);
+		return ERR_PTR(-EINVAL);
+	}
+
+	return &inst->uwk;
+}
+
+static const struct mtu_wakeup_ops mwk_ops = {
+	.enable = mwk_enable,
+	.disable = mwk_disable,
+	.owner = THIS_MODULE,
+};
+
+static const struct mtk_uwk_pdata mwk_v1_pdata = {
+	.vers = MTK_UWK_V1,
+};
+
+static const struct mtk_uwk_pdata mwk_v2_pdata = {
+	.vers = MTK_UWK_V2,
+};
+
+static const struct of_device_id mwk_id_table[] = {
+	{ .compatible = "mediatek,usb-wk-v1", .data = &mwk_v1_pdata },
+	{ .compatible = "mediatek,usb-wk-v2", .data = &mwk_v2_pdata },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, mwk_id_table);
+
+static int mtk_uwk_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
+	struct device_node *child_np;
+	struct mtu_wakeup_provider *provider;
+	struct mtk_uwk *mwk;
+	int index;
+	int ret;
+
+	mwk = devm_kzalloc(dev, sizeof(*mwk), GFP_KERNEL);
+	if (!mwk)
+		return -ENOMEM;
+
+	mwk->data = of_device_get_match_data(dev);
+	if (!mwk->data)
+		return -EINVAL;
+
+	mwk->num_inst = of_get_child_count(np);
+	mwk->inst = devm_kcalloc(dev, mwk->num_inst,
+				  sizeof(*mwk->inst), GFP_KERNEL);
+	if (!mwk->inst)
+		return -ENOMEM;
+
+	mwk->dev = dev;
+	platform_set_drvdata(pdev, mwk);
+
+	mwk->wkc = syscon_regmap_lookup_by_phandle(np, "mediatek,wkc");
+	if (IS_ERR(mwk->wkc)) {
+		dev_err(dev, "fail to get mediatek,wkc syscon\n");
+		return PTR_ERR(mwk->wkc);
+	}
+
+	index = 0;
+	for_each_child_of_node(np, child_np) {
+		struct mtk_uwk_instance *inst;
+
+		inst = mwk_inst_create(dev, child_np, &mwk_ops);
+		if (IS_ERR(inst)) {
+			dev_err(dev, "failed to create mwk instance\n");
+			ret = PTR_ERR(inst);
+			goto put_child;
+		}
+
+		mwk->inst[index] = inst;
+		index++;
+	}
+
+	provider = of_uwk_provider_add(dev, mwk_xlate);
+
+	return PTR_ERR_OR_ZERO(provider);
+
+put_child:
+	of_node_put(child_np);
+	return ret;
+}
+
+static int mtk_uwk_remove(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
+
+	of_uwk_provider_del(np);
+	return 0;
+}
+
+static struct platform_driver mtk_uwk_drv = {
+	.probe = mtk_uwk_probe,
+	.remove = mtk_uwk_remove,
+	.driver = {
+		.name = "mtk_uwk",
+		.owner = THIS_MODULE,
+		.of_match_table = mwk_id_table,
+	},
+};
+
+module_platform_driver(mtk_uwk_drv);
+MODULE_AUTHOR("Chunfeng Yun <chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>");
+MODULE_DESCRIPTION("MediaTek USB Wakeup driver");
+MODULE_LICENSE("GPL v2");
diff --git a/include/dt-bindings/soc/mediatek,usb-wakeup.h b/include/dt-bindings/soc/mediatek,usb-wakeup.h
new file mode 100644
index 0000000..2461795
--- /dev/null
+++ b/include/dt-bindings/soc/mediatek,usb-wakeup.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2017 MediaTek Inc.
+ * Author: Chunfeng Yun <chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ *
+ */
+
+#ifndef __DT_BINDINGS_MTK_USB_WK_H__
+#define __DT_BINDINGS_MTK_USB_WK_H__
+
+#define MTU_WK_IP_SLEEP	1
+#define MTU_WK_LINE_STATE	2
+
+#endif
diff --git a/include/linux/soc/mediatek/usb-wakeup.h b/include/linux/soc/mediatek/usb-wakeup.h
new file mode 100644
index 0000000..5697367
--- /dev/null
+++ b/include/linux/soc/mediatek/usb-wakeup.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2017 MediaTek Inc.
+ * Author: Chunfeng Yun <chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ *
+ */
+
+#ifndef __MTK_USB_WAKEUP_H__
+#define __MTK_USB_WAKEUP_H__
+
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/mutex.h>
+#include <linux/of.h>
+
+struct mtu_wakeup;
+
+/**
+ * struct mtu_wakeup_ops - set of function pointers for performing
+ *    mtu_wakeup operations
+ * @enable: enable a type of usb wakeup when system suspend
+ * @disable: disable a type of usb wakeup when system resume
+ * @owner: the module owner using the ops
+ */
+struct mtu_wakeup_ops {
+	int	(*enable)(struct mtu_wakeup *uwk);
+	int	(*disable)(struct mtu_wakeup *uwk);
+	struct module *owner;
+};
+
+/**
+ * struct mtu_wakeup - represents the MediaTek USB wakeup device
+ * @parent: the parent device of the mtu_wakeup
+ * @node: associated device tree node
+ * @ops: function pointers for performing mtu_wakeup operations
+ * @mutex: mutex to protect @ops
+ * @count: used to protect when the mtu_wakeup is used by multiple consumers
+ */
+struct mtu_wakeup {
+	struct device *parent;
+	struct device_node *node;
+	const struct mtu_wakeup_ops *ops;
+	struct mutex mutex;
+	int count;
+};
+
+/**
+ * struct mtu_wakeup_provider - represents the mtu_wakeup provider
+ * @dev: the parent device of the mtu_wakeup
+ * @list: to maintain a linked list of mtu_wakeup providers
+ * @of_node: associated device tree node
+ * @of_xlate: function pointer to obtain mtu_wakeup instance from
+ *	its tree node
+ */
+struct mtu_wakeup_provider {
+	struct device *dev;
+	struct list_head list;
+	struct device_node *of_node;
+	struct mtu_wakeup *(*of_xlate)(struct device *dev,
+		struct of_phandle_args *args);
+};
+
+#if IS_ENABLED(CONFIG_MTK_UWK)
+struct mtu_wakeup *devm_of_uwk_get_by_index(
+	struct device *dev, struct device_node *np, int index);
+int mtu_wakeup_enable(struct mtu_wakeup *uwk);
+int mtu_wakeup_disable(struct mtu_wakeup *uwk);
+
+#else
+struct mtu_wakeup *devm_of_uwk_get_by_index(
+	struct device *dev, struct device_node *np, int index)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+int mtu_wakeup_enable(struct mtu_wakeup *uwk)
+{
+	return uwk ? -ENODEV : 0;
+}
+
+int mtu_wakeup_disable(struct mtu_wakeup *uwk)
+{
+	return uwk ? -ENODEV : 0;
+}
+#endif
+
+#endif	/* __MTK_USB_WAKEUP_H__ */
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox