Re: [PATCH 3/8] [media] v4l: rcar_fdp1: Change platform dependency to ARCH_RENESAS
Hi Geert, On Saturday, 21 April 2018 11:07:11 EEST Laurent Pinchart wrote: > On Friday, 20 April 2018 16:28:29 EEST Geert Uytterhoeven wrote: > > The Renesas Fine Display Processor driver is used on Renesas R-Car SoCs > > only. Since commit 9b5ba0df4ea4f940 ("ARM: shmobile: Introduce > > ARCH_RENESAS") is ARCH_RENESAS a more appropriate platform dependency > > than the legacy ARCH_SHMOBILE, hence use the former. > > > > This will allow to drop ARCH_SHMOBILE on ARM and ARM64 in the near > > future. > > > > Signed-off-by: Geert Uytterhoeven > > Acked-by: Laurent Pinchart > > How would you like to get this merged ? Unless you would like to merge the whole series in one go, I'll take this in my tree as I have a conflicting patch I would like to submit for v4.18. > > --- > > > > drivers/media/platform/Kconfig | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/media/platform/Kconfig > > b/drivers/media/platform/Kconfig index f9235e8f8e962d2e..7ad4725f9d1f9627 > > 100644 > > --- a/drivers/media/platform/Kconfig > > +++ b/drivers/media/platform/Kconfig > > @@ -396,7 +396,7 @@ config VIDEO_SH_VEU > > config VIDEO_RENESAS_FDP1 > > tristate "Renesas Fine Display Processor" > > depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA > > - depends on ARCH_SHMOBILE || COMPILE_TEST > > + depends on ARCH_RENESAS || COMPILE_TEST > > depends on (!ARCH_RENESAS && !VIDEO_RENESAS_FCP) || VIDEO_RENESAS_FCP > > select VIDEOBUF2_DMA_CONTIG > > select V4L2_MEM2MEM_DEV -- Regards, Laurent Pinchart ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 15/39] acpi/battery: simplify procfs code
On Thu, Apr 19, 2018 at 2:41 PM, Christoph Hellwig wrote: > Use remove_proc_subtree to remove the whole subtree on cleanup, and > unwind the registration loop into individual calls. Switch to use > proc_create_seq where applicable. > > Signed-off-by: Christoph Hellwig It is OK AFAICS. Reviewed-by: Rafael J. Wysocki ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 04/15] media: pxa_camera: remove the dmaengine compat need
On 04/02/2018 04:26 PM, Robert Jarzmik wrote: > From: Robert Jarzmik > > As the pxa architecture switched towards the dmaengine slave map, the > old compatibility mechanism to acquire the dma requestor line number and > priority are not needed anymore. > > This patch simplifies the dma resource acquisition, using the more > generic function dma_request_slave_channel(). > > Signed-off-by: Robert Jarzmik Acked-by: Hans Verkuil Regards, Hans > --- > drivers/media/platform/pxa_camera.c | 22 +++--- > 1 file changed, 3 insertions(+), 19 deletions(-) > > diff --git a/drivers/media/platform/pxa_camera.c > b/drivers/media/platform/pxa_camera.c > index c71a00736541..4c82d1880753 100644 > --- a/drivers/media/platform/pxa_camera.c > +++ b/drivers/media/platform/pxa_camera.c > @@ -2357,8 +2357,6 @@ static int pxa_camera_probe(struct platform_device > *pdev) > .src_maxburst = 8, > .direction = DMA_DEV_TO_MEM, > }; > - dma_cap_mask_t mask; > - struct pxad_param params; > char clk_name[V4L2_CLK_NAME_SIZE]; > int irq; > int err = 0, i; > @@ -2432,34 +2430,20 @@ static int pxa_camera_probe(struct platform_device > *pdev) > pcdev->base = base; > > /* request dma */ > - dma_cap_zero(mask); > - dma_cap_set(DMA_SLAVE, mask); > - dma_cap_set(DMA_PRIVATE, mask); > - > - params.prio = 0; > - params.drcmr = 68; > - pcdev->dma_chans[0] = > - dma_request_slave_channel_compat(mask, pxad_filter_fn, > - ¶ms, &pdev->dev, "CI_Y"); > + pcdev->dma_chans[0] = dma_request_slave_channel(&pdev->dev, "CI_Y"); > if (!pcdev->dma_chans[0]) { > dev_err(&pdev->dev, "Can't request DMA for Y\n"); > return -ENODEV; > } > > - params.drcmr = 69; > - pcdev->dma_chans[1] = > - dma_request_slave_channel_compat(mask, pxad_filter_fn, > - ¶ms, &pdev->dev, "CI_U"); > + pcdev->dma_chans[1] = dma_request_slave_channel(&pdev->dev, "CI_U"); > if (!pcdev->dma_chans[1]) { > dev_err(&pdev->dev, "Can't request DMA for Y\n"); > err = -ENODEV; > goto exit_free_dma_y; > } > > - params.drcmr = 70; > - pcdev->dma_chans[2] = > - dma_request_slave_channel_compat(mask, pxad_filter_fn, > - ¶ms, &pdev->dev, "CI_V"); > + pcdev->dma_chans[2] = dma_request_slave_channel(&pdev->dev, "CI_V"); > if (!pcdev->dma_chans[2]) { > dev_err(&pdev->dev, "Can't request DMA for V\n"); > err = -ENODEV; > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 05/13] staging: iio: ad2s1200: Add kernel docs to driver state
On 21, April 2018 18:49, Jonathan Cameron wrote: > On Fri, 20 Apr 2018 21:30:03 +0200 > David Veenstra wrote: > >> Add missing kernel docs to the ad2s1200 driver state. >> >> Signed-off-by: David Veenstra >> --- >> drivers/staging/iio/resolver/ad2s1200.c | 8 >> 1 file changed, 8 insertions(+) >> >> diff --git a/drivers/staging/iio/resolver/ad2s1200.c >> b/drivers/staging/iio/resolver/ad2s1200.c >> index 357fe3c382b3..f07aab7e7a35 100644 >> --- a/drivers/staging/iio/resolver/ad2s1200.c >> +++ b/drivers/staging/iio/resolver/ad2s1200.c >> @@ -33,6 +33,14 @@ >> /* clock period in nano second */ >> #define AD2S1200_TSCLK (10 / AD2S1200_HZ) >> >> +/** >> + * struct ad2s1200_state - driver instance specific data >> + * @lock: protect driver state > > This doc for locks needs to be more specific. From a quick > glance I think it does two things. > 1) Ensures that we don't have concurrent accesses changing the > gpio control lines. > 2) Protects the rx buffer against concurrent accesses. > > It doesn't have anything much to do with the rest of this state > structure. You're right. The lock is to prevent concurrent spi reads. I'll add additional explanation in v3. Best regards, David Veenstra > >> + * @sdev: spi device >> + * @sample: GPIO pin SAMPLE >> + * @rdvel: GPIO pin RDVEL >> + * @rx: buffer for spi transfers >> + */ >> struct ad2s1200_state { >> struct mutex lock; >> struct spi_device *sdev; ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 06/13] staging: iio: ad2s1200: Introduce variable for repeated value
On 21, April 2018 18:50, Jonathan Cameron wrote: > On Fri, 20 Apr 2018 21:30:19 +0200 > David Veenstra wrote: > >> Add variable to hold &spi->dev in ad2s1200_probe. This value is repeatedly >> used in ad2s1200_probe. >> >> Signed-off-by: David Veenstra > No significant gain in readability. Perhaps even a slight lost I'm > going to say no to this one. We discussed this in [1]. But after removal of platform data it will be even less worth it. I'll remove this patch in v3. Best regards, David Veenstra [1] https://marc.info/?l=linux-iio&m=152190029808229&w=2 > > Jonathan > >> --- >> drivers/staging/iio/resolver/ad2s1200.c | 13 - >> 1 file changed, 8 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/staging/iio/resolver/ad2s1200.c >> b/drivers/staging/iio/resolver/ad2s1200.c >> index f07aab7e7a35..0a5fc9917e32 100644 >> --- a/drivers/staging/iio/resolver/ad2s1200.c >> +++ b/drivers/staging/iio/resolver/ad2s1200.c >> @@ -117,19 +117,22 @@ static int ad2s1200_probe(struct spi_device *spi) >> unsigned short *pins = spi->dev.platform_data; >> struct ad2s1200_state *st; >> struct iio_dev *indio_dev; >> +struct device *dev; >> int pn, ret = 0; >> >> +dev = &spi->dev; >> + >> for (pn = 0; pn < AD2S1200_PN; pn++) { >> -ret = devm_gpio_request_one(&spi->dev, pins[pn], GPIOF_DIR_OUT, >> +ret = devm_gpio_request_one(dev, pins[pn], GPIOF_DIR_OUT, >> DRV_NAME); >> if (ret) { >> -dev_err(&spi->dev, "request gpio pin %d failed\n", >> +dev_err(dev, "request gpio pin %d failed\n", >> pins[pn]); >> return ret; >> } >> } >> >> -indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); >> +indio_dev = devm_iio_device_alloc(dev, sizeof(*st)); >> if (!indio_dev) >> return -ENOMEM; >> >> @@ -140,14 +143,14 @@ static int ad2s1200_probe(struct spi_device *spi) >> st->sample = pins[0]; >> st->rdvel = pins[1]; >> >> -indio_dev->dev.parent = &spi->dev; >> +indio_dev->dev.parent = dev; >> indio_dev->info = &ad2s1200_info; >> indio_dev->modes = INDIO_DIRECT_MODE; >> indio_dev->channels = ad2s1200_channels; >> indio_dev->num_channels = ARRAY_SIZE(ad2s1200_channels); >> indio_dev->name = spi_get_device_id(spi)->name; >> >> -ret = devm_iio_device_register(&spi->dev, indio_dev); >> +ret = devm_iio_device_register(dev, indio_dev); >> if (ret) >> return ret; >> ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 07/13] staging: iio: ad2s1200: Improve readability with be16_to_cpup
On 21, April 2018 18:55, Jonathan Cameron wrote: > On Fri, 20 Apr 2018 21:30:32 +0200 > David Veenstra wrote: > >> The manual states that the data is contained in the upper 12 bits >> of the 16 bits read by spi. The code that extracts these 12 bits >> is correct for both be and le machines, but this is not clear >> from a first glance. >> >> To improve readability the relevant expressions are replaced >> with equivalent expressions that use be16_to_cpup. >> >> Signed-off-by: David Veenstra >> --- >> drivers/staging/iio/resolver/ad2s1200.c | 9 - >> 1 file changed, 4 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/staging/iio/resolver/ad2s1200.c >> b/drivers/staging/iio/resolver/ad2s1200.c >> index 0a5fc9917e32..11ed9c7332e6 100644 >> --- a/drivers/staging/iio/resolver/ad2s1200.c >> +++ b/drivers/staging/iio/resolver/ad2s1200.c >> @@ -57,7 +57,7 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, >> { >> struct ad2s1200_state *st = iio_priv(indio_dev); >> int ret = 0; >> -s16 vel; >> +u16 vel; >> >> mutex_lock(&st->lock); >> gpio_set_value(st->sample, 0); >> @@ -73,14 +73,13 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, >> return ret; >> } >> >> +vel = be16_to_cpup((__be16 *)st->rx); > Well it isn't vel (velocity) in one case so now the name is misleading. > > Also that type cast suggests a fairly obvious cleanup associated with this > one. > Why not make st->rx a __be16 in the first pace avoiding the need to cast at > all? > > Then you could just have *val = be16_to_cpu(st->rx) >> 4 and similar. Agreed on naming of vel, and type of st-rx. I'll change this for v3. Best regards, David Veenstra > >> switch (chan->type) { >> case IIO_ANGL: >> -*val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); >> +*val = vel >> 4; >> break; >> case IIO_ANGL_VEL: >> -vel = (((s16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); >> -vel = sign_extend32(vel, 11); >> -*val = vel; >> +*val = sign_extend32((s16)vel >> 4, 11); > If you were to use an intermediate that was s16 then the sign extend would > be automatic. Perhaps it is clear to do it like this though.. > Up to you. > >> break; >> default: >> mutex_unlock(&st->lock); ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 08/13] staging: iio: ad2s1200: Replace legacy gpio API with modern API
On 21, April 2018 18:58, Jonathan Cameron wrote: > On Fri, 20 Apr 2018 21:30:44 +0200 > David Veenstra wrote: > >> The legacy, integer based gpio API is replaced with the descriptor >> based API. >> >> For compatibility, it is first tried to use the platform data to >> request the gpio's. Otherwise, it looks for the "sample" and "rdvel" >> gpio function. >> >> Signed-off-by: David Veenstra > I would suggest that we simply force any out of tree users of the > platform data to update the platform data. Drop the the old > versions entirely.. > > We can be mean to out of tree board files so let us make our own > lives easy. Alright, I'll remove usage of platform data for v3. Best regards, David Veenstra > > Jonathan > >> --- >> drivers/staging/iio/resolver/ad2s1200.c | 51 >> - >> 1 file changed, 37 insertions(+), 14 deletions(-) >> >> diff --git a/drivers/staging/iio/resolver/ad2s1200.c >> b/drivers/staging/iio/resolver/ad2s1200.c >> index 11ed9c7332e6..29a9bb666e7b 100644 >> --- a/drivers/staging/iio/resolver/ad2s1200.c >> +++ b/drivers/staging/iio/resolver/ad2s1200.c >> @@ -14,6 +14,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -44,8 +45,8 @@ >> struct ad2s1200_state { >> struct mutex lock; >> struct spi_device *sdev; >> -int sample; >> -int rdvel; >> +struct gpio_desc *sample; >> +struct gpio_desc *rdvel; >> u8 rx[2] cacheline_aligned; >> }; >> >> @@ -60,12 +61,12 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, >> u16 vel; >> >> mutex_lock(&st->lock); >> -gpio_set_value(st->sample, 0); >> +gpiod_set_value(st->sample, 0); >> >> /* delay (6 * AD2S1200_TSCLK + 20) nano seconds */ >> udelay(1); >> -gpio_set_value(st->sample, 1); >> -gpio_set_value(st->rdvel, !!(chan->type == IIO_ANGL)); >> +gpiod_set_value(st->sample, 1); >> +gpiod_set_value(st->rdvel, !!(chan->type == IIO_ANGL)); >> >> ret = spi_read(st->sdev, st->rx, 2); >> if (ret < 0) { >> @@ -121,13 +122,18 @@ static int ad2s1200_probe(struct spi_device *spi) >> >> dev = &spi->dev; >> >> -for (pn = 0; pn < AD2S1200_PN; pn++) { >> -ret = devm_gpio_request_one(dev, pins[pn], GPIOF_DIR_OUT, >> -DRV_NAME); >> -if (ret) { >> -dev_err(dev, "request gpio pin %d failed\n", >> -pins[pn]); >> -return ret; >> +if (pins) { >> +for (pn = 0; pn < AD2S1200_PN; pn++) { >> +ret = devm_gpio_request_one(dev, pins[pn], >> +GPIOF_DIR_OUT, >> +DRV_NAME); >> +if (ret) { >> +dev_err(dev, >> +"Failed to claim gpio %d\n: err=%d", >> +pins[pn], >> +ret); >> +return ret; >> +} >> } >> } >> >> @@ -139,8 +145,25 @@ static int ad2s1200_probe(struct spi_device *spi) >> st = iio_priv(indio_dev); >> mutex_init(&st->lock); >> st->sdev = spi; >> -st->sample = pins[0]; >> -st->rdvel = pins[1]; >> + >> +if (pins) { >> +st->sample = gpio_to_desc(pins[0]); >> +st->rdvel = gpio_to_desc(pins[1]); >> +} else { >> +st->sample = devm_gpiod_get(dev, "sample", GPIOD_OUT_LOW); >> +if (IS_ERR(st->sample)) { >> +dev_err(dev, "Failed to claim SAMPLE gpio: err=%ld\n", >> +PTR_ERR(st->sample)); >> +return PTR_ERR(st->sample); >> +} >> + >> +st->rdvel = devm_gpiod_get(dev, "rdvel", GPIOD_OUT_LOW); >> +if (IS_ERR(st->rdvel)) { >> +dev_err(dev, "Failed to claim RDVEL gpio: err=%ld\n", >> +PTR_ERR(st->rdvel)); >> +return PTR_ERR(st->rdvel); >> +} >> +} >> >> indio_dev->dev.parent = dev; >> indio_dev->info = &ad2s1200_info; ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 10/13] staging: iio: ad2s1200: Add scaling factor for angular velocity channel
On 21, April 2018 19:07, Jonathan Cameron wrote: > On Fri, 20 Apr 2018 21:31:09 +0200 > David Veenstra wrote: > >> The sysfs iio ABI states radians per second is expected as the unit for >> angular velocity, but the 12-bit angular velocity register has rps >> as its unit. So a fractional scaling factor of approximately 2 * Pi is >> added to the angular velocity channel. >> >> The added comments will also be relevant for the scaling factor of >> the angle channel. >> >> Signed-off-by: David Veenstra > Comment inline. The function you are talking about isn't used > in the majority of likely use cases for this part. The maths will actually > be done in userspace (which can use floating point). > > Thanks, > > Jonathan > >> --- >> Changes in v2: >> - Move explanation of Pi approximation to top of switch statement, >> as this will also be relevant to angle channel. >> - Replaced 33102 / 2 with 16551 on line 84. >> >> drivers/staging/iio/resolver/ad2s1200.c | 84 >> +++-- >> 1 file changed, 59 insertions(+), 25 deletions(-) >> >> diff --git a/drivers/staging/iio/resolver/ad2s1200.c >> b/drivers/staging/iio/resolver/ad2s1200.c >> index 29a9bb666e7b..6c56257be3b1 100644 >> --- a/drivers/staging/iio/resolver/ad2s1200.c >> +++ b/drivers/staging/iio/resolver/ad2s1200.c >> @@ -60,38 +60,71 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, >> int ret = 0; >> u16 vel; >> >> -mutex_lock(&st->lock); >> -gpiod_set_value(st->sample, 0); >> +/* >> + * Below a fractional approximation of Pi is needed. >> + * The following approximation will be used: 103993 / 33102. >> + * This is accurate in 9 decimals places. >> + * >> + * This fraction is based on OEIS series of nominator/denominator >> + * of convergents to Pi (A002485 and A002486). >> + */ >> +switch (m) { >> +case IIO_CHAN_INFO_SCALE: >> +switch (chan->type) { >> +case IIO_ANGL_VEL: >> +/* >> + * 2 * Pi ~= 2 * 103993 / 33102 >> + * >> + * iio_convert_raw_to_processed uses integer >> + * division. This will cause at most 5% error >> + * (for very small values). But for 99.5% of the values >> + * it will cause less that 1% error. > This is an interesting comment, but relies on anyone actually > using iio_convert_raw_to_processed with this device. > > I would imagine that 'in kernel' users of a resolver (who would use > that function) will be few and far between. Mostly this will just > get passed to userspace. That involves this being converted to > a decimal. I would just specify it as one in the first place. Hmm, I didn't realize that it might never be used in kernel. A decimal representation is indeed a lot more clear. I'll change scale value type to IIO_VAL_INT_PLUS_MICRO for both the angular velocity and angel channel. Best regards, David Veenstra > >> + */ >> +*val = 103993; >> +*val2 = 16551; >> +return IIO_VAL_FRACTIONAL; >> +default: >> +return -EINVAL; >> +} >> +break; >> +case IIO_CHAN_INFO_RAW: >> +mutex_lock(&st->lock); >> +gpiod_set_value(st->sample, 0); >> + >> +/* delay (6 * AD2S1200_TSCLK + 20) nano seconds */ >> +udelay(1); >> +gpiod_set_value(st->sample, 1); >> +gpiod_set_value(st->rdvel, !!(chan->type == IIO_ANGL)); >> + >> +ret = spi_read(st->sdev, st->rx, 2); >> +if (ret < 0) { >> +mutex_unlock(&st->lock); >> +return ret; >> +} >> >> -/* delay (6 * AD2S1200_TSCLK + 20) nano seconds */ >> -udelay(1); >> -gpiod_set_value(st->sample, 1); >> -gpiod_set_value(st->rdvel, !!(chan->type == IIO_ANGL)); >> +vel = be16_to_cpup((__be16 *)st->rx); >> +switch (chan->type) { >> +case IIO_ANGL: >> +*val = vel >> 4; >> +break; >> +case IIO_ANGL_VEL: >> +*val = sign_extend32((s16)vel >> 4, 11); >> +break; >> +default: >> +mutex_unlock(&st->lock); >> +return -EINVAL; >> +} >> >> -ret = spi_read(st->sdev, st->rx, 2); >> -if (ret < 0) { >> +/* delay (2 * AD2S1200_TSCLK + 20) ns for sample pulse */ >> +udelay(1); >> mutex_unlock(&st->lock); >> -return ret; >> -} >> >> -vel = be16_to_cpup((__be16 *)st->rx); >> -switch (chan->type) { >> -case IIO_ANGL: >> -*val = vel >> 4; >> -break; >> -case IIO_ANGL_VEL: >> -*val = sign_extend32((s16)vel >> 4, 11); >> -break; >> +
Re: [PATCH v2 11/13] staging: iio: Documentation: Add missing sysfs docs for angle channel
On 21, April 2018 19:08, Jonathan Cameron wrote: > On Fri, 20 Apr 2018 21:31:37 +0200 > David Veenstra wrote: > >> The iio resolver drivers in staging use angle channels. This patch >> add missing documentation for this type of channel. >> >> As was discussed in [1], radians is chosen as the unit, to match the >> unit of angular velocity. >> >> [1] https://marc.info/?l=linux-driver-devel&m=152190078308330&w=2 >> >> Signed-off-by: David Veenstra >> --- >> Change in v2: >> - Introduces in this version. >> >> Documentation/ABI/testing/sysfs-bus-iio | 11 +++ >> 1 file changed, 11 insertions(+) >> >> diff --git a/Documentation/ABI/testing/sysfs-bus-iio >> b/Documentation/ABI/testing/sysfs-bus-iio >> index 6a5f34b4d5b9..8ad0e55f99ee 100644 >> --- a/Documentation/ABI/testing/sysfs-bus-iio >> +++ b/Documentation/ABI/testing/sysfs-bus-iio >> @@ -190,6 +190,15 @@ Description: >> but should match other such assignments on device). >> Units after application of scale and offset are m/s^2. >> >> +What: /sys/bus/iio/devices/iio:deviceX/in_angl_x_raw >> +What: /sys/bus/iio/devices/iio:deviceX/in_angl_y_raw >> +What: /sys/bus/iio/devices/iio:deviceX/in_angl_z_raw > This surprised me. A resolver is not going to inherently have any > notion of a particular axis. > Would expect. > in_angl_raw For the attributes that were added, I tried to match it with the angular velocity counterpart. But it indeed doesn't make much sense to have an axis for a resolver. I'll remove axis modifier for v3. Best regards, David Veenstra > > Jonathan > >> +KernelVersion: 4.17 >> +Contact:linux-...@vger.kernel.org >> +Description: >> +Angle about axis x, y or z (may be arbitrarily assigned). Units >> +after application of scale and offset are radians. >> + >> What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_x_raw >> What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_y_raw >> What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_z_raw >> @@ -297,6 +306,7 @@ What: >> /sys/bus/iio/devices/iio:deviceX/in_pressure_offset >> What: >> /sys/bus/iio/devices/iio:deviceX/in_humidityrelative_offset >> What: /sys/bus/iio/devices/iio:deviceX/in_magn_offset >> What: /sys/bus/iio/devices/iio:deviceX/in_rot_offset >> +What: /sys/bus/iio/devices/iio:deviceX/in_angl_offset >> KernelVersion: 2.6.35 >> Contact:linux-...@vger.kernel.org >> Description: >> @@ -350,6 +360,7 @@ What: >> /sys/bus/iio/devices/iio:deviceX/in_humidityrelative_scale >> What: >> /sys/bus/iio/devices/iio:deviceX/in_velocity_sqrt(x^2+y^2+z^2)_scale >> What: /sys/bus/iio/devices/iio:deviceX/in_illuminance_scale >> What: /sys/bus/iio/devices/iio:deviceX/in_countY_scale >> +What: /sys/bus/iio/devices/iio:deviceX/in_angl_scale >> KernelVersion: 2.6.35 >> Contact:linux-...@vger.kernel.org >> Description: ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3 14/20] mtd: Remove depends on HAS_DMA in case of platform dependency
On Tue, 17 Apr 2018 19:49:14 +0200 Geert Uytterhoeven wrote: > Remove dependencies on HAS_DMA where a Kconfig symbol depends on another > symbol that implies HAS_DMA, and, optionally, on "|| COMPILE_TEST". > In most cases this other symbol is an architecture or platform specific > symbol, or PCI. > > Generic symbols and drivers without platform dependencies keep their > dependencies on HAS_DMA, to prevent compiling subsystems or drivers that > cannot work anyway. > > This simplifies the dependencies, and allows to improve compile-testing. > > Signed-off-by: Geert Uytterhoeven > Reviewed-by: Mark Brown > Acked-by: Robin Murphy Applied to mtd/next. Thanks, Boris > --- > v3: > - Rebase to v4.17-rc1, > > v2: > - Add Reviewed-by, Acked-by, > - Drop RFC state, > - Drop new dependency of MTD_NAND_MARVELL on HAS_DMA, > - Split per subsystem. > --- > drivers/mtd/nand/raw/Kconfig | 8 ++-- > drivers/mtd/spi-nor/Kconfig | 2 +- > 2 files changed, 3 insertions(+), 7 deletions(-) > > diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig > index 19a2b283fbbe627e..6871ff0fd300bb81 100644 > --- a/drivers/mtd/nand/raw/Kconfig > +++ b/drivers/mtd/nand/raw/Kconfig > @@ -46,7 +46,7 @@ config MTD_NAND_DENALI > config MTD_NAND_DENALI_PCI > tristate "Support Denali NAND controller on Intel Moorestown" > select MTD_NAND_DENALI > - depends on HAS_DMA && PCI > + depends on PCI > help >Enable the driver for NAND flash on Intel Moorestown, using the >Denali NAND controller core. > @@ -152,7 +152,6 @@ config MTD_NAND_S3C2410_CLKSTOP > config MTD_NAND_TANGO > tristate "NAND Flash support for Tango chips" > depends on ARCH_TANGO || COMPILE_TEST > - depends on HAS_DMA > help > Enables the NAND Flash controller on Tango chips. > > @@ -285,7 +284,7 @@ config MTD_NAND_MARVELL > tristate "NAND controller support on Marvell boards" > depends on PXA3xx || ARCH_MMP || PLAT_ORION || ARCH_MVEBU || \ > COMPILE_TEST > - depends on HAS_IOMEM && HAS_DMA > + depends on HAS_IOMEM > help > This enables the NAND flash controller driver for Marvell boards, > including: > @@ -447,7 +446,6 @@ config MTD_NAND_SH_FLCTL > tristate "Support for NAND on Renesas SuperH FLCTL" > depends on SUPERH || COMPILE_TEST > depends on HAS_IOMEM > - depends on HAS_DMA > help > Several Renesas SuperH CPU has FLCTL. This option enables support > for NAND Flash using FLCTL. > @@ -515,7 +513,6 @@ config MTD_NAND_SUNXI > config MTD_NAND_HISI504 > tristate "Support for NAND controller on Hisilicon SoC Hip04" > depends on ARCH_HISI || COMPILE_TEST > - depends on HAS_DMA > help > Enables support for NAND controller on Hisilicon SoC Hip04. > > @@ -529,7 +526,6 @@ config MTD_NAND_QCOM > config MTD_NAND_MTK > tristate "Support for NAND controller on MTK SoCs" > depends on ARCH_MEDIATEK || COMPILE_TEST > - depends on HAS_DMA > help > Enables support for NAND controller on MTK SoCs. > This controller is found on mt27xx, mt81xx, mt65xx SoCs. > diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig > index 89da88e591215db1..c493b8230a38c059 100644 > --- a/drivers/mtd/spi-nor/Kconfig > +++ b/drivers/mtd/spi-nor/Kconfig > @@ -71,7 +71,7 @@ config SPI_FSL_QUADSPI > config SPI_HISI_SFC > tristate "Hisilicon SPI-NOR Flash Controller(SFC)" > depends on ARCH_HISI || COMPILE_TEST > - depends on HAS_IOMEM && HAS_DMA > + depends on HAS_IOMEM > help > This enables support for hisilicon SPI-NOR flash controller. > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [Patch v2] Storvsc: Select channel based on available percentage of ring buffer to write
> -Original Message- > From: linux-kernel-ow...@vger.kernel.org > On Behalf > Of Long Li > Sent: Thursday, April 19, 2018 2:54 PM > To: KY Srinivasan ; Haiyang Zhang > ; Stephen > Hemminger ; James E . J . Bottomley > ; > Martin K . Petersen ; > de...@linuxdriverproject.org; linux- > s...@vger.kernel.org; linux-ker...@vger.kernel.org > Cc: Long Li > Subject: [Patch v2] Storvsc: Select channel based on available percentage of > ring buffer to > write > > From: Long Li > > This is a best effort for estimating on how busy the ring buffer is for > that channel, based on available buffer to write in percentage. It is still > possible that at the time of actual ring buffer write, the space may not be > available due to other processes may be writing at the time. > > Selecting a channel based on how full it is can reduce the possibility that > a ring buffer write will fail, and avoid the situation a channel is over > busy. > > Now it's possible that storvsc can use a smaller ring buffer size > (e.g. 40k bytes) to take advantage of cache locality. > > Changes. > v2: Pre-allocate struct cpumask on the heap. > Struct cpumask is a big structure (1k bytes) when CONFIG_NR_CPUS=8192 (default > value when CONFIG_MAXSMP=y). Don't use kernel stack for it by pre-allocating > them using kmalloc when channels are first initialized. > > Signed-off-by: Long Li > --- > drivers/scsi/storvsc_drv.c | 90 > -- > 1 file changed, 72 insertions(+), 18 deletions(-) > > diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c > index a2ec0bc9e9fa..2a9fff94dd1a 100644 > --- a/drivers/scsi/storvsc_drv.c > +++ b/drivers/scsi/storvsc_drv.c > @@ -395,6 +395,12 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer > size > (bytes)"); > > module_param(storvsc_vcpus_per_sub_channel, int, S_IRUGO); > MODULE_PARM_DESC(storvsc_vcpus_per_sub_channel, "Ratio of VCPUs to > subchannels"); > + > +static int ring_avail_percent_lowater = 10; > +module_param(ring_avail_percent_lowater, int, S_IRUGO); > +MODULE_PARM_DESC(ring_avail_percent_lowater, > + "Select a channel if available ring size > this in percent"); > + > /* > * Timeout in seconds for all devices managed by this driver. > */ > @@ -468,6 +474,13 @@ struct storvsc_device { >* Mask of CPUs bound to subchannels. >*/ > struct cpumask alloced_cpus; > + /* > + * Pre-allocated struct cpumask for each hardware queue. > + * struct cpumask is used by selecting out-going channels. It is a > + * big structure, default to 1024k bytes when CONFIG_MAXSMP=y. I think you mean "1024 bytes" or "1k bytes" in the above comment. > + * Pre-allocate it to avoid allocation on the kernel stack. > + */ > + struct cpumask *cpumask_chns; > /* Used for vsc/vsp channel reset process */ > struct storvsc_cmd_request init_request; > struct storvsc_cmd_request reset_request; > @@ -872,6 +885,13 @@ static int storvsc_channel_init(struct hv_device > *device, bool is_fc) > if (stor_device->stor_chns == NULL) > return -ENOMEM; > > + stor_device->cpumask_chns = kcalloc(num_possible_cpus(), > + sizeof(struct cpumask), GFP_KERNEL); Note that num_possible_cpus() is 240 for a Hyper-V 2016 guest unless overridden on the kernel boot line, so this is going to allocate 240 Kbytes for each synthetic SCSI controller. On an Azure VM, which has two IDE and two SCSI controllers, this is nearly 1 Mbyte. It's unfortunate to have to allocate this much memory for a what is essentially a temporary variable. Further down in these comments, I've proposed an alternate implementation of the code that avoids the need for the temporary variable, and hence avoids the need for this allocation. > + if (stor_device->cpumask_chns == NULL) { > + kfree(stor_device->stor_chns); > + return -ENOMEM; > + } > + > stor_device->stor_chns[device->channel->target_cpu] = device->channel; > cpumask_set_cpu(device->channel->target_cpu, > &stor_device->alloced_cpus); > @@ -1232,6 +1252,7 @@ static int storvsc_dev_remove(struct hv_device *device) > vmbus_close(device->channel); > > kfree(stor_device->stor_chns); > + kfree(stor_device->cpumask_chns); > kfree(stor_device); > return 0; > } > @@ -1241,7 +1262,7 @@ static struct vmbus_channel *get_og_chn(struct > storvsc_device > *stor_device, > {1G/ > u16 slot = 0; > u16 hash_qnum; > - struct cpumask alloced_mask; > + struct cpumask *alloced_mask = &stor_device->cpumask_chns[q_num]; > int num_channels, tgt_cpu; > > if (stor_device->num_sc == 0) > @@ -1257,10 +1278,10 @@ static struct vmbus_channel *get_og_chn(struct > storvsc_device > *stor_device, >* III. Mapping is persistent. >*/ > > - cpumask_and(&alloced_mask, &stor_device->alloced_cpus, > +
[PATCH v3 0/9] staging: iio: ad2s1200: Driver clean up
For v1 see [1], for v2 see [2]. A summary of this patch: 1. Clean up of minor code style issues. 2. Replace legacy GPIO ABI with modern ABI and remove usage of. platform data. 4. Add scaling factor for angular position and angular velocity to match the sysfs IIO ABI. 5. Add documentation for device tree binding, and angle channel 6. Move driver to main line. Changes in v3: - Improved documentation about used mutex lock. - Improved readability of read_raw. - Remove usage of platform data. - Add dt binding documentation to Documentation/devicetree/bindings/iio/ instead of staging folder. - Change return type of scale for angle and angular velocity channel. - Remove axis modifier from documentation of angle channel. - Add missing references to ad2s1205. Best regards, David Veenstra [1] https://marc.info/?l=linux-iio&m=152137920426820&w=2 [2] https://marc.info/?l=linux-iio&m=152425250915148&w=2 David Veenstra (9): staging: iio: ad2s1200: Add kernel docs to driver state staging: iio: ad2s1200: Improve readability with be16_to_cpup staging: iio: ad2s1200: Replace legacy gpio API with modern API staging: iio: ad2s1200: Replace platform data with dt bindings staging: iio: ad2s1200: Add documentation for device tree binding staging: iio: ad2s1200: Add scaling factor for angular velocity channel staging: iio: Documentation: Add missing sysfs docs for angle channel staging: iio: ad2s1200: Add scaling factor for angle channel staging: iio: ad2s1200: Move driver out of staging Documentation/ABI/testing/sysfs-bus-iio| 9 + .../devicetree/bindings/iio/resolver/ad2s1200.txt | 16 ++ drivers/iio/Kconfig| 1 + drivers/iio/Makefile | 1 + drivers/iio/resolver/Kconfig | 17 ++ drivers/iio/resolver/Makefile | 5 + drivers/iio/resolver/ad2s1200.c| 201 + drivers/staging/iio/resolver/Kconfig | 12 -- drivers/staging/iio/resolver/Makefile | 1 - drivers/staging/iio/resolver/ad2s1200.c| 171 -- 10 files changed, 250 insertions(+), 184 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt create mode 100644 drivers/iio/resolver/Kconfig create mode 100644 drivers/iio/resolver/Makefile create mode 100644 drivers/iio/resolver/ad2s1200.c delete mode 100644 drivers/staging/iio/resolver/ad2s1200.c -- 2.16.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 2/9] staging: iio: ad2s1200: Improve readability with be16_to_cpup
The manual states that the data is contained in the upper 12 bits of the 16 bits read by spi. The code that extracts these 12 bits is correct for both be and le machines, but this is not clear from a first glance. To improve readability the relevant expressions are replaced with equivalent expressions that use be16_to_cpup. Signed-off-by: David Veenstra --- Changes in v3: - change type of rx to __be16. - remove unneeded variable vel. - remove unneeded type cast to s16 (patch line 79). drivers/staging/iio/resolver/ad2s1200.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c index 17d65cb437fd..998f458dc1bd 100644 --- a/drivers/staging/iio/resolver/ad2s1200.c +++ b/drivers/staging/iio/resolver/ad2s1200.c @@ -47,7 +47,7 @@ struct ad2s1200_state { struct spi_device *sdev; int sample; int rdvel; - u8 rx[2] cacheline_aligned; + __be16 rx cacheline_aligned; }; static int ad2s1200_read_raw(struct iio_dev *indio_dev, @@ -58,7 +58,6 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, { struct ad2s1200_state *st = iio_priv(indio_dev); int ret = 0; - s16 vel; mutex_lock(&st->lock); gpio_set_value(st->sample, 0); @@ -68,7 +67,7 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, gpio_set_value(st->sample, 1); gpio_set_value(st->rdvel, !!(chan->type == IIO_ANGL)); - ret = spi_read(st->sdev, st->rx, 2); + ret = spi_read(st->sdev, &st->rx, 2); if (ret < 0) { mutex_unlock(&st->lock); return ret; @@ -76,12 +75,10 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, switch (chan->type) { case IIO_ANGL: - *val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); + *val = be16_to_cpup(&st->rx) >> 4; break; case IIO_ANGL_VEL: - vel = (((s16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); - vel = sign_extend32(vel, 11); - *val = vel; + *val = sign_extend32(be16_to_cpup(&st->rx) >> 4, 11); break; default: mutex_unlock(&st->lock); -- 2.16.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 1/9] staging: iio: ad2s1200: Add kernel docs to driver state
Add missing kernel docs to the ad2s1200 driver state. Signed-off-by: David Veenstra --- Changes in v3: - Added more explanation to mutex lock. drivers/staging/iio/resolver/ad2s1200.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c index 357fe3c382b3..17d65cb437fd 100644 --- a/drivers/staging/iio/resolver/ad2s1200.c +++ b/drivers/staging/iio/resolver/ad2s1200.c @@ -33,6 +33,15 @@ /* clock period in nano second */ #define AD2S1200_TSCLK (10 / AD2S1200_HZ) +/** + * struct ad2s1200_state - driver instance specific data. + * @lock: protects both the GPIO pins and the rx buffer, to prevent + * concurrent spi transactions. + * @sdev: spi device. + * @sample:GPIO pin SAMPLE. + * @rdvel: GPIO pin RDVEL. + * @rx:buffer for spi transfers. + */ struct ad2s1200_state { struct mutex lock; struct spi_device *sdev; -- 2.16.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 4/9] staging: iio: ad2s1200: Replace platform data with dt bindings
Remove usage of platform data, and replace it with device tree facilities. Signed-off-by: David Veenstra --- Changes in v3: - Introduced in this version. drivers/staging/iio/resolver/ad2s1200.c | 32 +++- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c index e7bfe5aa4c45..3c7163610ff6 100644 --- a/drivers/staging/iio/resolver/ad2s1200.c +++ b/drivers/staging/iio/resolver/ad2s1200.c @@ -26,9 +26,6 @@ #define DRV_NAME "ad2s1200" -/* input pin sample and rdvel is controlled by driver */ -#define AD2S1200_PN2 - /* input clock on serial interface */ #define AD2S1200_HZ8192000 /* clock period in nano second */ @@ -113,20 +110,9 @@ static const struct iio_info ad2s1200_info = { static int ad2s1200_probe(struct spi_device *spi) { - unsigned short *pins = spi->dev.platform_data; struct ad2s1200_state *st; struct iio_dev *indio_dev; - int pn, ret = 0; - - for (pn = 0; pn < AD2S1200_PN; pn++) { - ret = devm_gpio_request_one(&spi->dev, pins[pn], GPIOF_DIR_OUT, - DRV_NAME); - if (ret) { - dev_err(&spi->dev, "request gpio pin %d failed\n", - pins[pn]); - return ret; - } - } + int ret = 0; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (!indio_dev) @@ -136,8 +122,20 @@ static int ad2s1200_probe(struct spi_device *spi) st = iio_priv(indio_dev); mutex_init(&st->lock); st->sdev = spi; - st->sample = gpio_to_desc(pins[0]); - st->rdvel = gpio_to_desc(pins[1]); + + st->sample = devm_gpiod_get(&spi->dev, "sample", GPIOD_OUT_LOW); + if (IS_ERR(st->sample)) { + dev_err(&spi->dev, "Failed to claim SAMPLE gpio: err=%ld\n", + PTR_ERR(st->sample)); + return PTR_ERR(st->sample); + } + + st->rdvel = devm_gpiod_get(&spi->dev, "rdvel", GPIOD_OUT_LOW); + if (IS_ERR(st->rdvel)) { + dev_err(&spi->dev, "Failed to claim RDVEL gpio: err=%ld\n", + PTR_ERR(st->rdvel)); + return PTR_ERR(st->rdvel); + } indio_dev->dev.parent = &spi->dev; indio_dev->info = &ad2s1200_info; -- 2.16.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 7/9] staging: iio: Documentation: Add missing sysfs docs for angle channel
The iio resolver drivers in staging use angle channels. This patch add missing documentation for this type of channel. As was discussed in [1], radians is chosen as the unit, to match the unit of angular velocity. [1] https://marc.info/?l=linux-driver-devel&m=152190078308330&w=2 Signed-off-by: David Veenstra --- Changes in v3: - Remove axis modifier on in_angle. Documentation/ABI/testing/sysfs-bus-iio | 9 + 1 file changed, 9 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 6a5f34b4d5b9..240287e2343a 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -190,6 +190,13 @@ Description: but should match other such assignments on device). Units after application of scale and offset are m/s^2. +What: /sys/bus/iio/devices/iio:deviceX/in_angl_raw +KernelVersion: 4.17 +Contact: linux-...@vger.kernel.org +Description: + Angle of rotation. Units after application of scale and offset + are radians. + What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_x_raw What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_y_raw What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_z_raw @@ -297,6 +304,7 @@ What: /sys/bus/iio/devices/iio:deviceX/in_pressure_offset What: /sys/bus/iio/devices/iio:deviceX/in_humidityrelative_offset What: /sys/bus/iio/devices/iio:deviceX/in_magn_offset What: /sys/bus/iio/devices/iio:deviceX/in_rot_offset +What: /sys/bus/iio/devices/iio:deviceX/in_angl_offset KernelVersion: 2.6.35 Contact: linux-...@vger.kernel.org Description: @@ -350,6 +358,7 @@ What: /sys/bus/iio/devices/iio:deviceX/in_humidityrelative_scale What: /sys/bus/iio/devices/iio:deviceX/in_velocity_sqrt(x^2+y^2+z^2)_scale What: /sys/bus/iio/devices/iio:deviceX/in_illuminance_scale What: /sys/bus/iio/devices/iio:deviceX/in_countY_scale +What: /sys/bus/iio/devices/iio:deviceX/in_angl_scale KernelVersion: 2.6.35 Contact: linux-...@vger.kernel.org Description: -- 2.16.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 6/9] staging: iio: ad2s1200: Add scaling factor for angular velocity channel
The sysfs iio ABI states radians per second is expected as the unit for angular velocity, but the 12-bit angular velocity register has rps as its unit. So a scaling factor of approximately 2 * Pi is added to the angular velocity channel. Signed-off-by: David Veenstra --- Changes in v3: - A decimal approximation of the scale is used, instead of a fractional approximation. - Remove unneeded explanation of iio_convert_raw_to_processed. drivers/staging/iio/resolver/ad2s1200.c | 71 + 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c index 3c7163610ff6..3e1696e52c38 100644 --- a/drivers/staging/iio/resolver/ad2s1200.c +++ b/drivers/staging/iio/resolver/ad2s1200.c @@ -57,37 +57,55 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, struct ad2s1200_state *st = iio_priv(indio_dev); int ret = 0; - mutex_lock(&st->lock); - gpiod_set_value(st->sample, 0); - - /* delay (6 * AD2S1200_TSCLK + 20) nano seconds */ - udelay(1); - gpiod_set_value(st->sample, 1); - gpiod_set_value(st->rdvel, !!(chan->type == IIO_ANGL)); - - ret = spi_read(st->sdev, &st->rx, 2); - if (ret < 0) { + switch (m) { + case IIO_CHAN_INFO_SCALE: + switch (chan->type) { + case IIO_ANGL_VEL: + /* 2 * Pi ~= 6.283185 */ + *val = 6; + *val2 = 283185; + return IIO_VAL_INT_PLUS_MICRO; + default: + return -EINVAL; + } + break; + case IIO_CHAN_INFO_RAW: + mutex_lock(&st->lock); + gpiod_set_value(st->sample, 0); + + /* delay (6 * AD2S1200_TSCLK + 20) nano seconds */ + udelay(1); + gpiod_set_value(st->sample, 1); + gpiod_set_value(st->rdvel, !!(chan->type == IIO_ANGL)); + + ret = spi_read(st->sdev, &st->rx, 2); + if (ret < 0) { + mutex_unlock(&st->lock); + return ret; + } + + switch (chan->type) { + case IIO_ANGL: + *val = be16_to_cpup(&st->rx) >> 4; + break; + case IIO_ANGL_VEL: + *val = sign_extend32(be16_to_cpup(&st->rx) >> 4, 11); + break; + default: + mutex_unlock(&st->lock); + return -EINVAL; + } + + /* delay (2 * AD2S1200_TSCLK + 20) ns for sample pulse */ + udelay(1); mutex_unlock(&st->lock); - return ret; - } - switch (chan->type) { - case IIO_ANGL: - *val = be16_to_cpup(&st->rx) >> 4; - break; - case IIO_ANGL_VEL: - *val = sign_extend32(be16_to_cpup(&st->rx) >> 4, 11); - break; + return IIO_VAL_INT; default: - mutex_unlock(&st->lock); - return -EINVAL; + break; } - /* delay (2 * AD2S1200_TSCLK + 20) ns for sample pulse */ - udelay(1); - mutex_unlock(&st->lock); - - return IIO_VAL_INT; + return -EINVAL; } static const struct iio_chan_spec ad2s1200_channels[] = { @@ -101,6 +119,7 @@ static const struct iio_chan_spec ad2s1200_channels[] = { .indexed = 1, .channel = 0, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), } }; -- 2.16.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 3/9] staging: iio: ad2s1200: Replace legacy gpio API with modern API
The legacy, integer based gpio API is replaced with the modern descriptor based API. Signed-off-by: David Veenstra --- Changes in v3: - This patch no longer deals with dt bindings. See the next patch. drivers/staging/iio/resolver/ad2s1200.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c index 998f458dc1bd..e7bfe5aa4c45 100644 --- a/drivers/staging/iio/resolver/ad2s1200.c +++ b/drivers/staging/iio/resolver/ad2s1200.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -45,8 +46,8 @@ struct ad2s1200_state { struct mutex lock; struct spi_device *sdev; - int sample; - int rdvel; + struct gpio_desc *sample; + struct gpio_desc *rdvel; __be16 rx cacheline_aligned; }; @@ -60,12 +61,12 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, int ret = 0; mutex_lock(&st->lock); - gpio_set_value(st->sample, 0); + gpiod_set_value(st->sample, 0); /* delay (6 * AD2S1200_TSCLK + 20) nano seconds */ udelay(1); - gpio_set_value(st->sample, 1); - gpio_set_value(st->rdvel, !!(chan->type == IIO_ANGL)); + gpiod_set_value(st->sample, 1); + gpiod_set_value(st->rdvel, !!(chan->type == IIO_ANGL)); ret = spi_read(st->sdev, &st->rx, 2); if (ret < 0) { @@ -135,8 +136,8 @@ static int ad2s1200_probe(struct spi_device *spi) st = iio_priv(indio_dev); mutex_init(&st->lock); st->sdev = spi; - st->sample = pins[0]; - st->rdvel = pins[1]; + st->sample = gpio_to_desc(pins[0]); + st->rdvel = gpio_to_desc(pins[1]); indio_dev->dev.parent = &spi->dev; indio_dev->info = &ad2s1200_info; -- 2.16.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 5/9] staging: iio: ad2s1200: Add documentation for device tree binding
Add documentation for the added device tree bindings. Signed-off-by: David Veenstra --- Changes in v3: - Documentation is added to Documentation/devicetree/bindings/iio/resolver instead of staging directory. - Add mention to ad2s1205 device. .../devicetree/bindings/iio/resolver/ad2s1200.txt| 16 1 file changed, 16 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt diff --git a/Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt b/Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt new file mode 100644 index ..46b51db38368 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt @@ -0,0 +1,16 @@ +Analog Devices AD2S1200 and AD2S1205 Resolver-to-Digital Converter + +Required properties: + - compatible : should be "adi,ad2s1200" or "adi,ad2s1205" + - reg : the SPI chip select number of the device + - sample-gpios : The GPIO pin connected to the SAMPLE line of the AD2S1200 + - rdvel-gpios : The GPIO pin connected to the RDVEL line of the AD2S1200 + +Example: + + resolver { + compatible = "adi,ad2s1200"; + reg = <4>; + sample-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; + rdvel-gpios = <&gpio 6 GPIO_ACTIVE_HIGH>; + }; -- 2.16.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 8/9] staging: iio: ad2s1200: Add scaling factor for angle channel
A scaling factor of approximately 2 * Pi / (2^12 -1) is added, to scale the 12-bits angular position to radians. A return type of IIO_VAL_INT_PLUS_NANO is used, so that the scale of both the angle channel and angular velocity channel has 7 significant digits. Signed-off-by: David Veenstra --- Changes in v3: - A decimal approximation of the scale is used, instead of a fractional approximation. - Remove unneeded explanation of iio_convert_raw_to_processed. drivers/staging/iio/resolver/ad2s1200.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c index 3e1696e52c38..d2b62308b31d 100644 --- a/drivers/staging/iio/resolver/ad2s1200.c +++ b/drivers/staging/iio/resolver/ad2s1200.c @@ -60,6 +60,11 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, switch (m) { case IIO_CHAN_INFO_SCALE: switch (chan->type) { + case IIO_ANGL: + /* 2 * Pi / (2^12 - 1) ~= 0.001534355 */ + *val = 0; + *val2 = 1534355; + return IIO_VAL_INT_PLUS_NANO; case IIO_ANGL_VEL: /* 2 * Pi ~= 6.283185 */ *val = 6; @@ -114,6 +119,7 @@ static const struct iio_chan_spec ad2s1200_channels[] = { .indexed = 1, .channel = 0, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), }, { .type = IIO_ANGL_VEL, .indexed = 1, -- 2.16.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 9/9] staging: iio: ad2s1200: Move driver out of staging
Move the iio driver for the ad2s1200 and ad2s1205 resolver-to-digital converter out of staging, into mainline iio subsystems. Signed-off-by: David Veenstra --- Changes in v3: - Add mention of ad2s1205 in commit message. drivers/iio/Kconfig | 1 + drivers/iio/Makefile| 1 + drivers/iio/resolver/Kconfig| 17 +++ drivers/iio/resolver/Makefile | 5 + drivers/iio/resolver/ad2s1200.c | 201 drivers/staging/iio/resolver/Kconfig| 12 -- drivers/staging/iio/resolver/Makefile | 1 - drivers/staging/iio/resolver/ad2s1200.c | 201 8 files changed, 225 insertions(+), 214 deletions(-) create mode 100644 drivers/iio/resolver/Kconfig create mode 100644 drivers/iio/resolver/Makefile create mode 100644 drivers/iio/resolver/ad2s1200.c delete mode 100644 drivers/staging/iio/resolver/ad2s1200.c diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig index b3c8c6ef0dff..4bec3ccbf4a1 100644 --- a/drivers/iio/Kconfig +++ b/drivers/iio/Kconfig @@ -92,6 +92,7 @@ source "drivers/iio/potentiometer/Kconfig" source "drivers/iio/potentiostat/Kconfig" source "drivers/iio/pressure/Kconfig" source "drivers/iio/proximity/Kconfig" +source "drivers/iio/resolver/Kconfig" source "drivers/iio/temperature/Kconfig" endif # IIO diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile index b16b2e9ddc40..1865361b8714 100644 --- a/drivers/iio/Makefile +++ b/drivers/iio/Makefile @@ -35,5 +35,6 @@ obj-y += potentiometer/ obj-y += potentiostat/ obj-y += pressure/ obj-y += proximity/ +obj-y += resolver/ obj-y += temperature/ obj-y += trigger/ diff --git a/drivers/iio/resolver/Kconfig b/drivers/iio/resolver/Kconfig new file mode 100644 index ..2ced9f22aa70 --- /dev/null +++ b/drivers/iio/resolver/Kconfig @@ -0,0 +1,17 @@ +# +# Resolver/Synchro drivers +# +menu "Resolver to digital converters" + +config AD2S1200 + tristate "Analog Devices ad2s1200/ad2s1205 driver" + depends on SPI + depends on GPIOLIB || COMPILE_TEST + help + Say yes here to build support for Analog Devices spi resolver + to digital converters, ad2s1200 and ad2s1205, provides direct access + via sysfs. + + To compile this driver as a module, choose M here: the + module will be called ad2s1200. +endmenu diff --git a/drivers/iio/resolver/Makefile b/drivers/iio/resolver/Makefile new file mode 100644 index ..4e1dccae07e7 --- /dev/null +++ b/drivers/iio/resolver/Makefile @@ -0,0 +1,5 @@ +# +# Makefile for Resolver/Synchro drivers +# + +obj-$(CONFIG_AD2S1200) += ad2s1200.o diff --git a/drivers/iio/resolver/ad2s1200.c b/drivers/iio/resolver/ad2s1200.c new file mode 100644 index ..d2b62308b31d --- /dev/null +++ b/drivers/iio/resolver/ad2s1200.c @@ -0,0 +1,201 @@ +/* + * ad2s1200.c simple support for the ADI Resolver to Digital Converters: + * AD2S1200/1205 + * + * Copyright (c) 2010-2010 Analog Devices Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define DRV_NAME "ad2s1200" + +/* input clock on serial interface */ +#define AD2S1200_HZ8192000 +/* clock period in nano second */ +#define AD2S1200_TSCLK (10 / AD2S1200_HZ) + +/** + * struct ad2s1200_state - driver instance specific data. + * @lock: protects both the GPIO pins and the rx buffer, to prevent + * concurrent spi transactions. + * @sdev: spi device. + * @sample:GPIO pin SAMPLE. + * @rdvel: GPIO pin RDVEL. + * @rx:buffer for spi transfers. + */ +struct ad2s1200_state { + struct mutex lock; + struct spi_device *sdev; + struct gpio_desc *sample; + struct gpio_desc *rdvel; + __be16 rx cacheline_aligned; +}; + +static int ad2s1200_read_raw(struct iio_dev *indio_dev, +struct iio_chan_spec const *chan, +int *val, +int *val2, +long m) +{ + struct ad2s1200_state *st = iio_priv(indio_dev); + int ret = 0; + + switch (m) { + case IIO_CHAN_INFO_SCALE: + switch (chan->type) { + case IIO_ANGL: + /* 2 * Pi / (2^12 - 1) ~= 0.001534355 */ + *val = 0; + *val2 = 1534355; + return IIO_VAL_INT_PLUS_NANO; + case IIO_ANGL_VEL: + /* 2 * Pi ~= 6.283185 */ + *val = 6; + *val2 = 283185; + return IIO_VAL_INT_PLUS_MICRO; + default: +
Re: [PATCH 1/2] staging: fsl-dpaa2/rtc: add rtc driver
On Mon, Apr 23, 2018 at 02:28:09AM +, Y.b. Lu wrote: > Actually I will send the timestamping support patch for > drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c. > Since the 1588 timer module had been initialized in MC firmware, the > timestamping support and the clock driver will not depend on each other in > code. > I'm not sure whether it's proper to put this driver in staging/fsl-dpaa2/, > but the rtc is the component of dpaa2. > Hope your suggestion where we should put it, where is the normal part? The PHC belongs near to the MAC driver. So drivers/staging/fsl-dpaa2/rtc seems logical to me. Thanks, Richard ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH 1/2] staging: fsl-dpaa2/rtc: add rtc driver
Hi Richard and Dan, > -Original Message- > From: Richard Cochran [mailto:richardcoch...@gmail.com] > Sent: Saturday, April 21, 2018 1:31 PM > To: Dan Carpenter > Cc: Y.b. Lu ; de...@driverdev.osuosl.org; Greg > Kroah-Hartman > Subject: Re: [PATCH 1/2] staging: fsl-dpaa2/rtc: add rtc driver > > On Sat, Apr 21, 2018 at 07:41:35AM +0300, Dan Carpenter wrote: > > On Fri, Apr 20, 2018 at 02:01:25PM -0700, Richard Cochran wrote: > > > On Thu, Apr 19, 2018 at 01:40:08PM +0300, Dan Carpenter wrote: > > > > This driver seems nice and so far as I can see it doesn't need to > > > > be in staging once we get the other parts merged. > > > > > > Please explain how this unit ties in with the MAC units. > > > > > > > I have no idea. I assumed there were some dependencies which > > prevented this code from being merged into the normal part of the > > kernel. From what I can see the code looks nice so if there aren't > > dependencies then we should put it in the normal part instead of in staging. > > My question is really for Yangbo... > > If the driver can't work without out-of-tree hacks, then it shouldn't be > merged > (but I wouldn't object in that case for inclusion in staging just so users can > integrate it). > > So we need to understand how this clock driver will be connected to the time > stamping MAC drivers. [Y.b. Lu] Sorry for forgetting to explain that. Actually I will send the timestamping support patch for drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c. Since the 1588 timer module had been initialized in MC firmware, the timestamping support and the clock driver will not depend on each other in code. I'm not sure whether it's proper to put this driver in staging/fsl-dpaa2/, but the rtc is the component of dpaa2. Hope your suggestion where we should put it, where is the normal part? Thank you very much. > > Thanks, > Richard ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[v3, 1/2] staging: fsl-dpaa2/rtc: add rtc driver
This patch is to add driver for the DPAA2 1588 timer module (RTC) which interfaces to up to an unlimited number of 10/100/1000 or 10G ethernet MACs, providing current time, alarm, and fiper support. The 1588 IP control block includes these distinctive features. - External GPIO trigger for time-stamping - 2 Time-stamp alarms - 3 FIPER pulse generators - Phase adjusted output timer clock Currently this driver only supports basic functions like settime/gettime/adjtime/adjfreq. Signed-off-by: Yangbo Lu --- Changes for v2: - Removed some comments. - Fixed a return value. Changes for v3: - Fixed auto build warning/error. --- drivers/staging/fsl-dpaa2/Kconfig |8 + drivers/staging/fsl-dpaa2/Makefile|5 +- drivers/staging/fsl-dpaa2/rtc/Makefile|7 + drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h | 137 ++ drivers/staging/fsl-dpaa2/rtc/dprtc.c | 701 + drivers/staging/fsl-dpaa2/rtc/dprtc.h | 164 +++ drivers/staging/fsl-dpaa2/rtc/rtc.c | 231 ++ 7 files changed, 1251 insertions(+), 2 deletions(-) create mode 100644 drivers/staging/fsl-dpaa2/rtc/Makefile create mode 100644 drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h create mode 100644 drivers/staging/fsl-dpaa2/rtc/dprtc.c create mode 100644 drivers/staging/fsl-dpaa2/rtc/dprtc.h create mode 100644 drivers/staging/fsl-dpaa2/rtc/rtc.c diff --git a/drivers/staging/fsl-dpaa2/Kconfig b/drivers/staging/fsl-dpaa2/Kconfig index bbb7af5..ea2d4aa 100644 --- a/drivers/staging/fsl-dpaa2/Kconfig +++ b/drivers/staging/fsl-dpaa2/Kconfig @@ -24,3 +24,11 @@ config FSL_DPAA2_ETHSW ---help--- Driver for Freescale DPAA2 Ethernet Switch. Select BRIDGE to have support for bridge tools. + +config FSL_DPAA2_PTP_CLOCK + tristate "Freescale DPAA2 PTP Clock" + depends on FSL_DPAA2 + select PTP_1588_CLOCK + help + This driver adds support for using the DPAA2 1588 timer module + as a PTP clock. diff --git a/drivers/staging/fsl-dpaa2/Makefile b/drivers/staging/fsl-dpaa2/Makefile index 6cfd76b..9c70629 100644 --- a/drivers/staging/fsl-dpaa2/Makefile +++ b/drivers/staging/fsl-dpaa2/Makefile @@ -2,5 +2,6 @@ # Freescale DataPath Acceleration Architecture Gen2 (DPAA2) drivers # -obj-$(CONFIG_FSL_DPAA2_ETH)+= ethernet/ -obj-$(CONFIG_FSL_DPAA2_ETHSW) += ethsw/ +obj-$(CONFIG_FSL_DPAA2_ETH)+= ethernet/ +obj-$(CONFIG_FSL_DPAA2_ETHSW) += ethsw/ +obj-$(CONFIG_FSL_DPAA2_PTP_CLOCK) += rtc/ diff --git a/drivers/staging/fsl-dpaa2/rtc/Makefile b/drivers/staging/fsl-dpaa2/rtc/Makefile new file mode 100644 index 000..5468da0 --- /dev/null +++ b/drivers/staging/fsl-dpaa2/rtc/Makefile @@ -0,0 +1,7 @@ +# +# Makefile for the Freescale DPAA2 PTP clock +# + +obj-$(CONFIG_FSL_DPAA2_PTP_CLOCK) += dpaa2-rtc.o + +dpaa2-rtc-objs := rtc.o dprtc.o diff --git a/drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h b/drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h new file mode 100644 index 000..db6a473 --- /dev/null +++ b/drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h @@ -0,0 +1,137 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2013-2016 Freescale Semiconductor Inc. + * Copyright 2016-2018 NXP + */ + +#ifndef _FSL_DPRTC_CMD_H +#define _FSL_DPRTC_CMD_H + +/* DPRTC Version */ +#define DPRTC_VER_MAJOR2 +#define DPRTC_VER_MINOR0 + +/* Command versioning */ +#define DPRTC_CMD_BASE_VERSION 1 +#define DPRTC_CMD_ID_OFFSET4 + +#define DPRTC_CMD(id) (((id) << DPRTC_CMD_ID_OFFSET) | DPRTC_CMD_BASE_VERSION) + +/* Command IDs */ +#define DPRTC_CMDID_CLOSE DPRTC_CMD(0x800) +#define DPRTC_CMDID_OPEN DPRTC_CMD(0x810) +#define DPRTC_CMDID_CREATE DPRTC_CMD(0x910) +#define DPRTC_CMDID_DESTROYDPRTC_CMD(0x990) +#define DPRTC_CMDID_GET_API_VERSIONDPRTC_CMD(0xa10) + +#define DPRTC_CMDID_ENABLE DPRTC_CMD(0x002) +#define DPRTC_CMDID_DISABLEDPRTC_CMD(0x003) +#define DPRTC_CMDID_GET_ATTR DPRTC_CMD(0x004) +#define DPRTC_CMDID_RESET DPRTC_CMD(0x005) +#define DPRTC_CMDID_IS_ENABLED DPRTC_CMD(0x006) + +#define DPRTC_CMDID_SET_IRQ_ENABLE DPRTC_CMD(0x012) +#define DPRTC_CMDID_GET_IRQ_ENABLE DPRTC_CMD(0x013) +#define DPRTC_CMDID_SET_IRQ_MASK DPRTC_CMD(0x014) +#define DPRTC_CMDID_GET_IRQ_MASK DPRTC_CMD(0x015) +#define DPRTC_CMDID_GET_IRQ_STATUS DPRTC_CMD(0x016) +#define DPRTC_CMDID_CLEAR_IRQ_STATUS DPRTC_CMD(0x017) + +#define DPRTC_CMDID_SET_CLOCK_OFFSET DPRTC_CMD(0x1d0) +#define DPRTC_CMDID_SET_FREQ_COMPENSATION DPRTC_CMD(0x1d1) +#define DPRTC_CMDID_GET_FREQ_COMPENSATION DPRTC_CMD(0x1d2) +#define DPRTC_CMDID_GET_TIME DPRTC_CMD(0x1d3) +#define DPRTC_CMDID_SET_TIME
[v3, 2/2] MAINTAINERS: add maintainer for the DPAA2 PTP clock driver
This patch is to add maintainer for the DPAA2 PTP clock driver. Signed-off-by: Yangbo Lu --- Changes for v2: - None. Changes for v3: - None. --- MAINTAINERS |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 0a1410d..7733efa 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4395,6 +4395,12 @@ L: linux-ker...@vger.kernel.org S: Maintained F: drivers/staging/fsl-dpaa2/ethsw +DPAA2 PTP CLOCK DRIVER +M: Yangbo Lu +L: linux-ker...@vger.kernel.org +S: Maintained +F: drivers/staging/fsl-dpaa2/rtc + DPT_I2O SCSI RAID DRIVER M: Adaptec OEM Raid Solutions L: linux-s...@vger.kernel.org -- 1.7.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel