* Re: [PATCH v2 1/2] staging: iio: frequency: ad9833: Get frequency value statically [not found] <20190201150138.31481-1-biabeniamin@outlook.com> @ 2019-02-02 17:05 ` Jonathan Cameron [not found] ` <20190201150138.31481-2-biabeniamin@outlook.com> 1 sibling, 0 replies; 2+ messages in thread From: Jonathan Cameron @ 2019-02-02 17:05 UTC (permalink / raw) To: Beniamin Bia Cc: lars, Michael.Hennerich, knaack.h, pmeerw, gregkh, linux-iio, devel, linux-kernel, Beniamin Bia, Beniamin Bia On Fri, 1 Feb 2019 17:01:37 +0200 Beniamin Bia <biabeniamin@outlook.com> wrote: > From: Beniamin Bia <biabeniamin@gmail.com> > > The values from platform data were replaced by statically values. > This was just a intermediate step of taking this driver out of staging and > load data from device tree. > > Signed-off-by: Beniamin Bia <beniamin.bia@analog.com> Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > --- > Changes in v2: > - The platform data structure was removed and the values are > written directly > drivers/staging/iio/frequency/ad9834.c | 21 +++++++------------ > drivers/staging/iio/frequency/ad9834.h | 28 -------------------------- > 2 files changed, 7 insertions(+), 42 deletions(-) > > diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c > index 995acdd7c942..f4f5eaa15e30 100644 > --- a/drivers/staging/iio/frequency/ad9834.c > +++ b/drivers/staging/iio/frequency/ad9834.c > @@ -391,16 +391,11 @@ static const struct iio_info ad9833_info = { > > static int ad9834_probe(struct spi_device *spi) > { > - struct ad9834_platform_data *pdata = dev_get_platdata(&spi->dev); > struct ad9834_state *st; > struct iio_dev *indio_dev; > struct regulator *reg; > int ret; > > - if (!pdata) { > - dev_dbg(&spi->dev, "no platform data?\n"); > - return -ENODEV; > - } > > reg = devm_regulator_get(&spi->dev, "avdd"); > if (IS_ERR(reg)) > @@ -420,7 +415,7 @@ static int ad9834_probe(struct spi_device *spi) > spi_set_drvdata(spi, indio_dev); > st = iio_priv(indio_dev); > mutex_init(&st->lock); > - st->mclk = pdata->mclk; > + st->mclk = 25000000; > st->spi = spi; > st->devid = spi_get_device_id(spi)->driver_data; > st->reg = reg; > @@ -456,11 +451,9 @@ static int ad9834_probe(struct spi_device *spi) > spi_message_add_tail(&st->freq_xfer[1], &st->freq_msg); > > st->control = AD9834_B28 | AD9834_RESET; > + st->control |= AD9834_DIV2; > > - if (!pdata->en_div2) > - st->control |= AD9834_DIV2; > - > - if (!pdata->en_signbit_msb_out && (st->devid == ID_AD9834)) > + if (st->devid == ID_AD9834) > st->control |= AD9834_SIGN_PIB; > > st->data = cpu_to_be16(AD9834_REG_CMD | st->control); > @@ -470,19 +463,19 @@ static int ad9834_probe(struct spi_device *spi) > goto error_disable_reg; > } > > - ret = ad9834_write_frequency(st, AD9834_REG_FREQ0, pdata->freq0); > + ret = ad9834_write_frequency(st, AD9834_REG_FREQ0, 1000000); > if (ret) > goto error_disable_reg; > > - ret = ad9834_write_frequency(st, AD9834_REG_FREQ1, pdata->freq1); > + ret = ad9834_write_frequency(st, AD9834_REG_FREQ1, 5000000); > if (ret) > goto error_disable_reg; > > - ret = ad9834_write_phase(st, AD9834_REG_PHASE0, pdata->phase0); > + ret = ad9834_write_phase(st, AD9834_REG_PHASE0, 512); > if (ret) > goto error_disable_reg; > > - ret = ad9834_write_phase(st, AD9834_REG_PHASE1, pdata->phase1); > + ret = ad9834_write_phase(st, AD9834_REG_PHASE1, 1024); > if (ret) > goto error_disable_reg; > > diff --git a/drivers/staging/iio/frequency/ad9834.h b/drivers/staging/iio/frequency/ad9834.h > index ae620f38eb49..da7e83ceedad 100644 > --- a/drivers/staging/iio/frequency/ad9834.h > +++ b/drivers/staging/iio/frequency/ad9834.h > @@ -8,32 +8,4 @@ > #ifndef IIO_DDS_AD9834_H_ > #define IIO_DDS_AD9834_H_ > > -/* > - * TODO: struct ad7887_platform_data needs to go into include/linux/iio > - */ > - > -/** > - * struct ad9834_platform_data - platform specific information > - * @mclk: master clock in Hz > - * @freq0: power up freq0 tuning word in Hz > - * @freq1: power up freq1 tuning word in Hz > - * @phase0: power up phase0 value [0..4095] correlates with 0..2PI > - * @phase1: power up phase1 value [0..4095] correlates with 0..2PI > - * @en_div2: digital output/2 is passed to the SIGN BIT OUT pin > - * @en_signbit_msb_out: the MSB (or MSB/2) of the DAC data is connected to the > - * SIGN BIT OUT pin. en_div2 controls whether it is the MSB > - * or MSB/2 that is output. if en_signbit_msb_out=false, > - * the on-board comparator is connected to SIGN BIT OUT > - */ > - > -struct ad9834_platform_data { > - unsigned int mclk; > - unsigned int freq0; > - unsigned int freq1; > - unsigned short phase0; > - unsigned short phase1; > - bool en_div2; > - bool en_signbit_msb_out; > -}; > - > #endif /* IIO_DDS_AD9834_H_ */ ^ permalink raw reply [flat|nested] 2+ messages in thread
[parent not found: <20190201150138.31481-2-biabeniamin@outlook.com>]
* Re: [PATCH v2 2/2] staging: iio: frequency: ad9833: Load clock using clock framework [not found] ` <20190201150138.31481-2-biabeniamin@outlook.com> @ 2019-02-02 17:07 ` Jonathan Cameron 0 siblings, 0 replies; 2+ messages in thread From: Jonathan Cameron @ 2019-02-02 17:07 UTC (permalink / raw) To: Beniamin Bia Cc: lars, Michael.Hennerich, knaack.h, pmeerw, gregkh, linux-iio, devel, linux-kernel, Beniamin Bia, Beniamin Bia On Fri, 1 Feb 2019 17:01:38 +0200 Beniamin Bia <biabeniamin@outlook.com> wrote: > From: Beniamin Bia <biabeniamin@gmail.com> > > The clock frequency is loaded from device-tree using clock framework > instead of statically value. The change allow configuration of > the device via device-trees and better initialization sequence. > This is part of broader effort to add device-tree support to this driver > and take it out from staging. > > Signed-off-by: Beniamin Bia <beniamin.bia@analog.com> Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > --- > Changes in v2: > -the intermidiate clk variable was replaced by the variable in > device state > -st variable may be uninitialized warning was fixed by adding a new > error label > drivers/staging/iio/frequency/ad9834.c | 35 ++++++++++++++++++-------- > 1 file changed, 24 insertions(+), 11 deletions(-) > > diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c > index f4f5eaa15e30..f036f75d1f22 100644 > --- a/drivers/staging/iio/frequency/ad9834.c > +++ b/drivers/staging/iio/frequency/ad9834.c > @@ -6,6 +6,7 @@ > * Licensed under the GPL-2. > */ > > +#include <linux/clk.h> > #include <linux/interrupt.h> > #include <linux/workqueue.h> > #include <linux/device.h> > @@ -71,7 +72,7 @@ > struct ad9834_state { > struct spi_device *spi; > struct regulator *reg; > - unsigned int mclk; > + struct clk *mclk; > unsigned short control; > unsigned short devid; > struct spi_transfer xfer; > @@ -110,12 +111,15 @@ static unsigned int ad9834_calc_freqreg(unsigned long mclk, unsigned long fout) > static int ad9834_write_frequency(struct ad9834_state *st, > unsigned long addr, unsigned long fout) > { > + unsigned long clk_freq; > unsigned long regval; > > - if (fout > (st->mclk / 2)) > + clk_freq = clk_get_rate(st->mclk); > + > + if (fout > (clk_freq / 2)) > return -EINVAL; > > - regval = ad9834_calc_freqreg(st->mclk, fout); > + regval = ad9834_calc_freqreg(clk_freq, fout); > > st->freq_data[0] = cpu_to_be16(addr | (regval & > RES_MASK(AD9834_FREQ_BITS / 2))); > @@ -415,7 +419,14 @@ static int ad9834_probe(struct spi_device *spi) > spi_set_drvdata(spi, indio_dev); > st = iio_priv(indio_dev); > mutex_init(&st->lock); > - st->mclk = 25000000; > + st->mclk = devm_clk_get(&spi->dev, NULL); > + > + ret = clk_prepare_enable(st->mclk); > + if (ret) { > + dev_err(&spi->dev, "Failed to enable master clock\n"); > + goto error_disable_reg; > + } > + > st->spi = spi; > st->devid = spi_get_device_id(spi)->driver_data; > st->reg = reg; > @@ -460,31 +471,32 @@ static int ad9834_probe(struct spi_device *spi) > ret = spi_sync(st->spi, &st->msg); > if (ret) { > dev_err(&spi->dev, "device init failed\n"); > - goto error_disable_reg; > + goto error_clock_unprepare; > } > > ret = ad9834_write_frequency(st, AD9834_REG_FREQ0, 1000000); > if (ret) > - goto error_disable_reg; > + goto error_clock_unprepare; > > ret = ad9834_write_frequency(st, AD9834_REG_FREQ1, 5000000); > if (ret) > - goto error_disable_reg; > + goto error_clock_unprepare; > > ret = ad9834_write_phase(st, AD9834_REG_PHASE0, 512); > if (ret) > - goto error_disable_reg; > + goto error_clock_unprepare; > > ret = ad9834_write_phase(st, AD9834_REG_PHASE1, 1024); > if (ret) > - goto error_disable_reg; > + goto error_clock_unprepare; > > ret = iio_device_register(indio_dev); > if (ret) > - goto error_disable_reg; > + goto error_clock_unprepare; > > return 0; > - > +error_clock_unprepare: > + clk_disable_unprepare(st->mclk); > error_disable_reg: > regulator_disable(reg); > > @@ -497,6 +509,7 @@ static int ad9834_remove(struct spi_device *spi) > struct ad9834_state *st = iio_priv(indio_dev); > > iio_device_unregister(indio_dev); > + clk_disable_unprepare(st->mclk); > regulator_disable(st->reg); > > return 0; ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-02 17:07 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20190201150138.31481-1-biabeniamin@outlook.com> 2019-02-02 17:05 ` [PATCH v2 1/2] staging: iio: frequency: ad9833: Get frequency value statically Jonathan Cameron [not found] ` <20190201150138.31481-2-biabeniamin@outlook.com> 2019-02-02 17:07 ` [PATCH v2 2/2] staging: iio: frequency: ad9833: Load clock using clock framework Jonathan Cameron
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).