diff options
| -rw-r--r-- | drivers/iio/adc/cpcap-adc.c | 2 | ||||
| -rw-r--r-- | drivers/iio/adc/meson_saradc.c | 52 | ||||
| -rw-r--r-- | drivers/iio/health/max30102.c | 2 | ||||
| -rw-r--r-- | drivers/iio/industrialio-core.c | 4 | ||||
| -rw-r--r-- | drivers/iio/proximity/sx9500.c | 9 | ||||
| -rw-r--r-- | include/linux/iio/timer/stm32-lptim-trigger.h | 5 |
6 files changed, 59 insertions, 15 deletions
diff --git a/drivers/iio/adc/cpcap-adc.c b/drivers/iio/adc/cpcap-adc.c index 3576ec73ec23..9ad60421d360 100644 --- a/drivers/iio/adc/cpcap-adc.c +++ b/drivers/iio/adc/cpcap-adc.c | |||
| @@ -1011,7 +1011,7 @@ static int cpcap_adc_probe(struct platform_device *pdev) | |||
| 1011 | platform_set_drvdata(pdev, indio_dev); | 1011 | platform_set_drvdata(pdev, indio_dev); |
| 1012 | 1012 | ||
| 1013 | ddata->irq = platform_get_irq_byname(pdev, "adcdone"); | 1013 | ddata->irq = platform_get_irq_byname(pdev, "adcdone"); |
| 1014 | if (!ddata->irq) | 1014 | if (ddata->irq < 0) |
| 1015 | return -ENODEV; | 1015 | return -ENODEV; |
| 1016 | 1016 | ||
| 1017 | error = devm_request_threaded_irq(&pdev->dev, ddata->irq, NULL, | 1017 | error = devm_request_threaded_irq(&pdev->dev, ddata->irq, NULL, |
diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index 9c6932ffc0af..36047147ce7c 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c | |||
| @@ -221,8 +221,10 @@ enum meson_sar_adc_chan7_mux_sel { | |||
| 221 | 221 | ||
| 222 | struct meson_sar_adc_data { | 222 | struct meson_sar_adc_data { |
| 223 | bool has_bl30_integration; | 223 | bool has_bl30_integration; |
| 224 | u32 bandgap_reg; | ||
| 224 | unsigned int resolution; | 225 | unsigned int resolution; |
| 225 | const char *name; | 226 | const char *name; |
| 227 | const struct regmap_config *regmap_config; | ||
| 226 | }; | 228 | }; |
| 227 | 229 | ||
| 228 | struct meson_sar_adc_priv { | 230 | struct meson_sar_adc_priv { |
| @@ -242,13 +244,20 @@ struct meson_sar_adc_priv { | |||
| 242 | int calibscale; | 244 | int calibscale; |
| 243 | }; | 245 | }; |
| 244 | 246 | ||
| 245 | static const struct regmap_config meson_sar_adc_regmap_config = { | 247 | static const struct regmap_config meson_sar_adc_regmap_config_gxbb = { |
| 246 | .reg_bits = 8, | 248 | .reg_bits = 8, |
| 247 | .val_bits = 32, | 249 | .val_bits = 32, |
| 248 | .reg_stride = 4, | 250 | .reg_stride = 4, |
| 249 | .max_register = MESON_SAR_ADC_REG13, | 251 | .max_register = MESON_SAR_ADC_REG13, |
| 250 | }; | 252 | }; |
| 251 | 253 | ||
| 254 | static const struct regmap_config meson_sar_adc_regmap_config_meson8 = { | ||
| 255 | .reg_bits = 8, | ||
| 256 | .val_bits = 32, | ||
| 257 | .reg_stride = 4, | ||
| 258 | .max_register = MESON_SAR_ADC_DELTA_10, | ||
| 259 | }; | ||
| 260 | |||
| 252 | static unsigned int meson_sar_adc_get_fifo_count(struct iio_dev *indio_dev) | 261 | static unsigned int meson_sar_adc_get_fifo_count(struct iio_dev *indio_dev) |
| 253 | { | 262 | { |
| 254 | struct meson_sar_adc_priv *priv = iio_priv(indio_dev); | 263 | struct meson_sar_adc_priv *priv = iio_priv(indio_dev); |
| @@ -600,7 +609,7 @@ static int meson_sar_adc_clk_init(struct iio_dev *indio_dev, | |||
| 600 | init.num_parents = 1; | 609 | init.num_parents = 1; |
| 601 | 610 | ||
| 602 | priv->clk_gate.reg = base + MESON_SAR_ADC_REG3; | 611 | priv->clk_gate.reg = base + MESON_SAR_ADC_REG3; |
| 603 | priv->clk_gate.bit_idx = fls(MESON_SAR_ADC_REG3_CLK_EN); | 612 | priv->clk_gate.bit_idx = __ffs(MESON_SAR_ADC_REG3_CLK_EN); |
| 604 | priv->clk_gate.hw.init = &init; | 613 | priv->clk_gate.hw.init = &init; |
| 605 | 614 | ||
| 606 | priv->adc_clk = devm_clk_register(&indio_dev->dev, &priv->clk_gate.hw); | 615 | priv->adc_clk = devm_clk_register(&indio_dev->dev, &priv->clk_gate.hw); |
| @@ -685,6 +694,20 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev) | |||
| 685 | return 0; | 694 | return 0; |
| 686 | } | 695 | } |
| 687 | 696 | ||
| 697 | static void meson_sar_adc_set_bandgap(struct iio_dev *indio_dev, bool on_off) | ||
| 698 | { | ||
| 699 | struct meson_sar_adc_priv *priv = iio_priv(indio_dev); | ||
| 700 | u32 enable_mask; | ||
| 701 | |||
| 702 | if (priv->data->bandgap_reg == MESON_SAR_ADC_REG11) | ||
| 703 | enable_mask = MESON_SAR_ADC_REG11_BANDGAP_EN; | ||
| 704 | else | ||
| 705 | enable_mask = MESON_SAR_ADC_DELTA_10_TS_VBG_EN; | ||
| 706 | |||
| 707 | regmap_update_bits(priv->regmap, priv->data->bandgap_reg, enable_mask, | ||
| 708 | on_off ? enable_mask : 0); | ||
| 709 | } | ||
| 710 | |||
| 688 | static int meson_sar_adc_hw_enable(struct iio_dev *indio_dev) | 711 | static int meson_sar_adc_hw_enable(struct iio_dev *indio_dev) |
| 689 | { | 712 | { |
| 690 | struct meson_sar_adc_priv *priv = iio_priv(indio_dev); | 713 | struct meson_sar_adc_priv *priv = iio_priv(indio_dev); |
| @@ -717,9 +740,9 @@ static int meson_sar_adc_hw_enable(struct iio_dev *indio_dev) | |||
| 717 | regval = FIELD_PREP(MESON_SAR_ADC_REG0_FIFO_CNT_IRQ_MASK, 1); | 740 | regval = FIELD_PREP(MESON_SAR_ADC_REG0_FIFO_CNT_IRQ_MASK, 1); |
| 718 | regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG0, | 741 | regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG0, |
| 719 | MESON_SAR_ADC_REG0_FIFO_CNT_IRQ_MASK, regval); | 742 | MESON_SAR_ADC_REG0_FIFO_CNT_IRQ_MASK, regval); |
| 720 | regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG11, | 743 | |
| 721 | MESON_SAR_ADC_REG11_BANDGAP_EN, | 744 | meson_sar_adc_set_bandgap(indio_dev, true); |
| 722 | MESON_SAR_ADC_REG11_BANDGAP_EN); | 745 | |
| 723 | regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3, | 746 | regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3, |
| 724 | MESON_SAR_ADC_REG3_ADC_EN, | 747 | MESON_SAR_ADC_REG3_ADC_EN, |
| 725 | MESON_SAR_ADC_REG3_ADC_EN); | 748 | MESON_SAR_ADC_REG3_ADC_EN); |
| @@ -739,8 +762,7 @@ static int meson_sar_adc_hw_enable(struct iio_dev *indio_dev) | |||
| 739 | err_adc_clk: | 762 | err_adc_clk: |
| 740 | regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3, | 763 | regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3, |
| 741 | MESON_SAR_ADC_REG3_ADC_EN, 0); | 764 | MESON_SAR_ADC_REG3_ADC_EN, 0); |
| 742 | regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG11, | 765 | meson_sar_adc_set_bandgap(indio_dev, false); |
| 743 | MESON_SAR_ADC_REG11_BANDGAP_EN, 0); | ||
| 744 | clk_disable_unprepare(priv->sana_clk); | 766 | clk_disable_unprepare(priv->sana_clk); |
| 745 | err_sana_clk: | 767 | err_sana_clk: |
| 746 | clk_disable_unprepare(priv->core_clk); | 768 | clk_disable_unprepare(priv->core_clk); |
| @@ -765,8 +787,8 @@ static int meson_sar_adc_hw_disable(struct iio_dev *indio_dev) | |||
| 765 | 787 | ||
| 766 | regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3, | 788 | regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3, |
| 767 | MESON_SAR_ADC_REG3_ADC_EN, 0); | 789 | MESON_SAR_ADC_REG3_ADC_EN, 0); |
| 768 | regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG11, | 790 | |
| 769 | MESON_SAR_ADC_REG11_BANDGAP_EN, 0); | 791 | meson_sar_adc_set_bandgap(indio_dev, false); |
| 770 | 792 | ||
| 771 | clk_disable_unprepare(priv->sana_clk); | 793 | clk_disable_unprepare(priv->sana_clk); |
| 772 | clk_disable_unprepare(priv->core_clk); | 794 | clk_disable_unprepare(priv->core_clk); |
| @@ -844,30 +866,40 @@ static const struct iio_info meson_sar_adc_iio_info = { | |||
| 844 | 866 | ||
| 845 | static const struct meson_sar_adc_data meson_sar_adc_meson8_data = { | 867 | static const struct meson_sar_adc_data meson_sar_adc_meson8_data = { |
| 846 | .has_bl30_integration = false, | 868 | .has_bl30_integration = false, |
| 869 | .bandgap_reg = MESON_SAR_ADC_DELTA_10, | ||
| 870 | .regmap_config = &meson_sar_adc_regmap_config_meson8, | ||
| 847 | .resolution = 10, | 871 | .resolution = 10, |
| 848 | .name = "meson-meson8-saradc", | 872 | .name = "meson-meson8-saradc", |
| 849 | }; | 873 | }; |
| 850 | 874 | ||
| 851 | static const struct meson_sar_adc_data meson_sar_adc_meson8b_data = { | 875 | static const struct meson_sar_adc_data meson_sar_adc_meson8b_data = { |
| 852 | .has_bl30_integration = false, | 876 | .has_bl30_integration = false, |
| 877 | .bandgap_reg = MESON_SAR_ADC_DELTA_10, | ||
| 878 | .regmap_config = &meson_sar_adc_regmap_config_meson8, | ||
| 853 | .resolution = 10, | 879 | .resolution = 10, |
| 854 | .name = "meson-meson8b-saradc", | 880 | .name = "meson-meson8b-saradc", |
| 855 | }; | 881 | }; |
| 856 | 882 | ||
| 857 | static const struct meson_sar_adc_data meson_sar_adc_gxbb_data = { | 883 | static const struct meson_sar_adc_data meson_sar_adc_gxbb_data = { |
| 858 | .has_bl30_integration = true, | 884 | .has_bl30_integration = true, |
| 885 | .bandgap_reg = MESON_SAR_ADC_REG11, | ||
| 886 | .regmap_config = &meson_sar_adc_regmap_config_gxbb, | ||
| 859 | .resolution = 10, | 887 | .resolution = 10, |
| 860 | .name = "meson-gxbb-saradc", | 888 | .name = "meson-gxbb-saradc", |
| 861 | }; | 889 | }; |
| 862 | 890 | ||
| 863 | static const struct meson_sar_adc_data meson_sar_adc_gxl_data = { | 891 | static const struct meson_sar_adc_data meson_sar_adc_gxl_data = { |
| 864 | .has_bl30_integration = true, | 892 | .has_bl30_integration = true, |
| 893 | .bandgap_reg = MESON_SAR_ADC_REG11, | ||
| 894 | .regmap_config = &meson_sar_adc_regmap_config_gxbb, | ||
| 865 | .resolution = 12, | 895 | .resolution = 12, |
| 866 | .name = "meson-gxl-saradc", | 896 | .name = "meson-gxl-saradc", |
| 867 | }; | 897 | }; |
| 868 | 898 | ||
| 869 | static const struct meson_sar_adc_data meson_sar_adc_gxm_data = { | 899 | static const struct meson_sar_adc_data meson_sar_adc_gxm_data = { |
| 870 | .has_bl30_integration = true, | 900 | .has_bl30_integration = true, |
| 901 | .bandgap_reg = MESON_SAR_ADC_REG11, | ||
| 902 | .regmap_config = &meson_sar_adc_regmap_config_gxbb, | ||
| 871 | .resolution = 12, | 903 | .resolution = 12, |
| 872 | .name = "meson-gxm-saradc", | 904 | .name = "meson-gxm-saradc", |
| 873 | }; | 905 | }; |
| @@ -945,7 +977,7 @@ static int meson_sar_adc_probe(struct platform_device *pdev) | |||
| 945 | return ret; | 977 | return ret; |
| 946 | 978 | ||
| 947 | priv->regmap = devm_regmap_init_mmio(&pdev->dev, base, | 979 | priv->regmap = devm_regmap_init_mmio(&pdev->dev, base, |
| 948 | &meson_sar_adc_regmap_config); | 980 | priv->data->regmap_config); |
| 949 | if (IS_ERR(priv->regmap)) | 981 | if (IS_ERR(priv->regmap)) |
| 950 | return PTR_ERR(priv->regmap); | 982 | return PTR_ERR(priv->regmap); |
| 951 | 983 | ||
diff --git a/drivers/iio/health/max30102.c b/drivers/iio/health/max30102.c index 203ffb9cad6a..147a8c14235f 100644 --- a/drivers/iio/health/max30102.c +++ b/drivers/iio/health/max30102.c | |||
| @@ -371,7 +371,7 @@ static int max30102_read_raw(struct iio_dev *indio_dev, | |||
| 371 | mutex_unlock(&indio_dev->mlock); | 371 | mutex_unlock(&indio_dev->mlock); |
| 372 | break; | 372 | break; |
| 373 | case IIO_CHAN_INFO_SCALE: | 373 | case IIO_CHAN_INFO_SCALE: |
| 374 | *val = 1; /* 0.0625 */ | 374 | *val = 1000; /* 62.5 */ |
| 375 | *val2 = 16; | 375 | *val2 = 16; |
| 376 | ret = IIO_VAL_FRACTIONAL; | 376 | ret = IIO_VAL_FRACTIONAL; |
| 377 | break; | 377 | break; |
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 9c4cfd19b739..2f0998ebeed2 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c | |||
| @@ -631,7 +631,7 @@ static ssize_t __iio_format_value(char *buf, size_t len, unsigned int type, | |||
| 631 | * iio_format_value() - Formats a IIO value into its string representation | 631 | * iio_format_value() - Formats a IIO value into its string representation |
| 632 | * @buf: The buffer to which the formatted value gets written | 632 | * @buf: The buffer to which the formatted value gets written |
| 633 | * which is assumed to be big enough (i.e. PAGE_SIZE). | 633 | * which is assumed to be big enough (i.e. PAGE_SIZE). |
| 634 | * @type: One of the IIO_VAL_... constants. This decides how the val | 634 | * @type: One of the IIO_VAL_* constants. This decides how the val |
| 635 | * and val2 parameters are formatted. | 635 | * and val2 parameters are formatted. |
| 636 | * @size: Number of IIO value entries contained in vals | 636 | * @size: Number of IIO value entries contained in vals |
| 637 | * @vals: Pointer to the values, exact meaning depends on the | 637 | * @vals: Pointer to the values, exact meaning depends on the |
| @@ -639,7 +639,7 @@ static ssize_t __iio_format_value(char *buf, size_t len, unsigned int type, | |||
| 639 | * | 639 | * |
| 640 | * Return: 0 by default, a negative number on failure or the | 640 | * Return: 0 by default, a negative number on failure or the |
| 641 | * total number of characters written for a type that belongs | 641 | * total number of characters written for a type that belongs |
| 642 | * to the IIO_VAL_... constant. | 642 | * to the IIO_VAL_* constant. |
| 643 | */ | 643 | */ |
| 644 | ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals) | 644 | ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals) |
| 645 | { | 645 | { |
diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c index 53c5d653e780..df23dbcc030a 100644 --- a/drivers/iio/proximity/sx9500.c +++ b/drivers/iio/proximity/sx9500.c | |||
| @@ -869,6 +869,7 @@ static int sx9500_init_device(struct iio_dev *indio_dev) | |||
| 869 | static void sx9500_gpio_probe(struct i2c_client *client, | 869 | static void sx9500_gpio_probe(struct i2c_client *client, |
| 870 | struct sx9500_data *data) | 870 | struct sx9500_data *data) |
| 871 | { | 871 | { |
| 872 | struct gpio_desc *gpiod_int; | ||
| 872 | struct device *dev; | 873 | struct device *dev; |
| 873 | 874 | ||
| 874 | if (!client) | 875 | if (!client) |
| @@ -876,6 +877,14 @@ static void sx9500_gpio_probe(struct i2c_client *client, | |||
| 876 | 877 | ||
| 877 | dev = &client->dev; | 878 | dev = &client->dev; |
| 878 | 879 | ||
| 880 | if (client->irq <= 0) { | ||
| 881 | gpiod_int = devm_gpiod_get(dev, SX9500_GPIO_INT, GPIOD_IN); | ||
| 882 | if (IS_ERR(gpiod_int)) | ||
| 883 | dev_err(dev, "gpio get irq failed\n"); | ||
| 884 | else | ||
| 885 | client->irq = gpiod_to_irq(gpiod_int); | ||
| 886 | } | ||
| 887 | |||
| 879 | data->gpiod_rst = devm_gpiod_get(dev, SX9500_GPIO_RESET, GPIOD_OUT_HIGH); | 888 | data->gpiod_rst = devm_gpiod_get(dev, SX9500_GPIO_RESET, GPIOD_OUT_HIGH); |
| 880 | if (IS_ERR(data->gpiod_rst)) { | 889 | if (IS_ERR(data->gpiod_rst)) { |
| 881 | dev_warn(dev, "gpio get reset pin failed\n"); | 890 | dev_warn(dev, "gpio get reset pin failed\n"); |
diff --git a/include/linux/iio/timer/stm32-lptim-trigger.h b/include/linux/iio/timer/stm32-lptim-trigger.h index 34d59bfdce2d..464458d20b16 100644 --- a/include/linux/iio/timer/stm32-lptim-trigger.h +++ b/include/linux/iio/timer/stm32-lptim-trigger.h | |||
| @@ -16,11 +16,14 @@ | |||
| 16 | #define LPTIM2_OUT "lptim2_out" | 16 | #define LPTIM2_OUT "lptim2_out" |
| 17 | #define LPTIM3_OUT "lptim3_out" | 17 | #define LPTIM3_OUT "lptim3_out" |
| 18 | 18 | ||
| 19 | #if IS_ENABLED(CONFIG_IIO_STM32_LPTIMER_TRIGGER) | 19 | #if IS_REACHABLE(CONFIG_IIO_STM32_LPTIMER_TRIGGER) |
| 20 | bool is_stm32_lptim_trigger(struct iio_trigger *trig); | 20 | bool is_stm32_lptim_trigger(struct iio_trigger *trig); |
| 21 | #else | 21 | #else |
| 22 | static inline bool is_stm32_lptim_trigger(struct iio_trigger *trig) | 22 | static inline bool is_stm32_lptim_trigger(struct iio_trigger *trig) |
| 23 | { | 23 | { |
| 24 | #if IS_ENABLED(CONFIG_IIO_STM32_LPTIMER_TRIGGER) | ||
| 25 | pr_warn_once("stm32 lptim_trigger not linked in\n"); | ||
| 26 | #endif | ||
| 24 | return false; | 27 | return false; |
| 25 | } | 28 | } |
| 26 | #endif | 29 | #endif |
