diff options
author | Jonathan Cameron <jic23@kernel.org> | 2014-05-04 16:45:00 (GMT) |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2014-04-07 17:54:15 (GMT) |
commit | b64aef7034572b1f669bf295b88332ea0b149050 (patch) | |
tree | 76c032b1d92d0673ec0717deb5bfd90d95c81dac /drivers/staging/iio/adc | |
parent | 6f174fd312d50abf3e98c0c5f7adf0cf434ae705 (diff) | |
download | linux-b64aef7034572b1f669bf295b88332ea0b149050.tar.xz |
staging:iio:adc:spear adc - prefix defines to avoid namespace clashes.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Stefan Roese <sr@denx.de>
Acked-by: Hartmut Knaack <knaack.h@gmx.de>
Diffstat (limited to 'drivers/staging/iio/adc')
-rw-r--r-- | drivers/staging/iio/adc/spear_adc.c | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index 970d9ed..49293f9 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -22,39 +22,36 @@ #include <linux/iio/iio.h> #include <linux/iio/sysfs.h> -/* - * SPEAR registers definitions - */ - -#define SCAN_RATE_LO(x) ((x) & 0xFFFF) -#define SCAN_RATE_HI(x) (((x) >> 0x10) & 0xFFFF) -#define CLK_LOW(x) (((x) & 0xf) << 0) -#define CLK_HIGH(x) (((x) & 0xf) << 4) +/* SPEAR registers definitions */ +#define SPEAR600_ADC_SCAN_RATE_LO(x) ((x) & 0xFFFF) +#define SPEAR600_ADC_SCAN_RATE_HI(x) (((x) >> 0x10) & 0xFFFF) +#define SPEAR_ADC_CLK_LOW(x) (((x) & 0xf) << 0) +#define SPEAR_ADC_CLK_HIGH(x) (((x) & 0xf) << 4) /* Bit definitions for SPEAR_ADC_STATUS */ -#define START_CONVERSION (1 << 0) -#define CHANNEL_NUM(x) ((x) << 1) -#define ADC_ENABLE (1 << 4) -#define AVG_SAMPLE(x) ((x) << 5) -#define VREF_INTERNAL (1 << 9) +#define SPEAR_ADC_STATUS_START_CONVERSION (1 << 0) +#define SPEAR_ADC_STATUS_CHANNEL_NUM(x) ((x) << 1) +#define SPEAR_ADC_STATUS_ADC_ENABLE (1 << 4) +#define SPEAR_ADC_STATUS_AVG_SAMPLE(x) ((x) << 5) +#define SPEAR_ADC_STATUS_VREF_INTERNAL (1 << 9) -#define DATA_MASK 0x03ff -#define DATA_BITS 10 +#define SPEAR_ADC_DATA_MASK 0x03ff +#define SPEAR_ADC_DATA_BITS 10 -#define MOD_NAME "spear-adc" +#define SPEAR_ADC_MOD_NAME "spear-adc" -#define ADC_CHANNEL_NUM 8 +#define SPEAR_ADC_CHANNEL_NUM 8 -#define CLK_MIN 2500000 -#define CLK_MAX 20000000 +#define SPEAR_ADC_CLK_MIN 2500000 +#define SPEAR_ADC_CLK_MAX 20000000 struct adc_regs_spear3xx { u32 status; u32 average; u32 scan_rate; u32 clk; /* Not avail for 1340 & 1310 */ - u32 ch_ctrl[ADC_CHANNEL_NUM]; - u32 ch_data[ADC_CHANNEL_NUM]; + u32 ch_ctrl[SPEAR_ADC_CHANNEL_NUM]; + u32 ch_data[SPEAR_ADC_CHANNEL_NUM]; }; struct chan_data { @@ -66,8 +63,8 @@ struct adc_regs_spear6xx { u32 status; u32 pad[2]; u32 clk; - u32 ch_ctrl[ADC_CHANNEL_NUM]; - struct chan_data ch_data[ADC_CHANNEL_NUM]; + u32 ch_ctrl[SPEAR_ADC_CHANNEL_NUM]; + struct chan_data ch_data[SPEAR_ADC_CHANNEL_NUM]; u32 scan_rate_lo; u32 scan_rate_hi; struct chan_data average; @@ -106,7 +103,7 @@ static void spear_adc_set_clk(struct spear_adc_info *info, u32 val) clk_high = count - clk_low; info->current_clk = apb_clk / count; - __raw_writel(CLK_LOW(clk_low) | CLK_HIGH(clk_high), + __raw_writel(SPEAR_ADC_CLK_LOW(clk_low) | SPEAR_ADC_CLK_HIGH(clk_high), &info->adc_base_spear6xx->clk); } @@ -120,19 +117,19 @@ static u32 spear_adc_get_average(struct spear_adc_info *info) { if (of_device_is_compatible(info->np, "st,spear600-adc")) { return __raw_readl(&info->adc_base_spear6xx->average.msb) & - DATA_MASK; + SPEAR_ADC_DATA_MASK; } else { return __raw_readl(&info->adc_base_spear3xx->average) & - DATA_MASK; + SPEAR_ADC_DATA_MASK; } } static void spear_adc_set_scanrate(struct spear_adc_info *info, u32 rate) { if (of_device_is_compatible(info->np, "st,spear600-adc")) { - __raw_writel(SCAN_RATE_LO(rate), + __raw_writel(SPEAR600_ADC_SCAN_RATE_LO(rate), &info->adc_base_spear6xx->scan_rate_lo); - __raw_writel(SCAN_RATE_HI(rate), + __raw_writel(SPEAR600_ADC_SCAN_RATE_HI(rate), &info->adc_base_spear6xx->scan_rate_hi); } else { __raw_writel(rate, &info->adc_base_spear3xx->scan_rate); @@ -152,11 +149,12 @@ static int spear_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_RAW: mutex_lock(&indio_dev->mlock); - status = CHANNEL_NUM(chan->channel) | - AVG_SAMPLE(info->avg_samples) | - START_CONVERSION | ADC_ENABLE; + status = SPEAR_ADC_STATUS_CHANNEL_NUM(chan->channel) | + SPEAR_ADC_STATUS_AVG_SAMPLE(info->avg_samples) | + SPEAR_ADC_STATUS_START_CONVERSION | + SPEAR_ADC_STATUS_ADC_ENABLE; if (info->vref_external == 0) - status |= VREF_INTERNAL; + status |= SPEAR_ADC_STATUS_VREF_INTERNAL; spear_adc_set_status(info, status); wait_for_completion(&info->completion); /* set by ISR */ @@ -168,7 +166,7 @@ static int spear_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: *val = info->vref_external; - *val2 = DATA_BITS; + *val2 = SPEAR_ADC_DATA_BITS; return IIO_VAL_FRACTIONAL_LOG2; } @@ -253,7 +251,7 @@ static ssize_t spear_adc_write_frequency(struct device *dev, mutex_lock(&indio_dev->mlock); - if ((lval < CLK_MIN) || (lval > CLK_MAX)) { + if ((lval < SPEAR_ADC_CLK_MIN) || (lval > SPEAR_ADC_CLK_MAX)) { ret = -EINVAL; goto out; } @@ -339,7 +337,8 @@ static int spear_adc_probe(struct platform_device *pdev) goto errout3; } - ret = devm_request_irq(dev, irq, spear_adc_isr, 0, MOD_NAME, info); + ret = devm_request_irq(dev, irq, spear_adc_isr, 0, SPEAR_ADC_MOD_NAME, + info); if (ret < 0) { dev_err(dev, "failed requesting interrupt\n"); goto errout3; @@ -370,7 +369,7 @@ static int spear_adc_probe(struct platform_device *pdev) init_completion(&info->completion); - iodev->name = MOD_NAME; + iodev->name = SPEAR_ADC_MOD_NAME; iodev->dev.parent = dev; iodev->info = &spear_adc_iio_info; iodev->modes = INDIO_DIRECT_MODE; @@ -419,7 +418,7 @@ static struct platform_driver spear_adc_driver = { .probe = spear_adc_probe, .remove = spear_adc_remove, .driver = { - .name = MOD_NAME, + .name = SPEAR_ADC_MOD_NAME, .owner = THIS_MODULE, .of_match_table = of_match_ptr(spear_adc_dt_ids), }, |