
Hello all,
On 10/27/2015 01:08 PM, Przemyslaw Marczak wrote:
This commit adds:
- new uclass id: UCLASS_ADC
- new uclass driver: drivers/adc/adc-uclass.c
The new uclass's API allows for ADC operation on:
- single-channel with channel selection by a number
- multti-channel with channel selection by bit mask
ADC uclass's functions:
- single-channel:
- adc_start_channel() - start channel conversion
- adc_channel_data() - get conversion data
- adc_channel_single_shot() - start/get conversion data
- multi-channel:
- adc_start_channels() - start selected channels conversion
- adc_channels_data() - get conversion data
- adc_channels_single_shot() - start/get conversion data for channels selected by bit mask
- general:
- adc_stop() - stop the conversion
- adc_vdd_value() - positive reference Voltage value with polarity [uV]
- adc_vss_value() - negative reference Voltage value with polarity [uV]
- adc_data_mask() - conversion data bit mask
The device tree can provide below constraints/properties:
- vdd-polarity-negative: if true: Vdd = vdd-microvolts * (-1)
- vss-polarity-negative: if true: Vss = vss-microvolts * (-1)
- vdd-supply: phandle to Vdd regulator's node
- vss-supply: phandle to Vss regulator's node
And optional, checked only if the above corresponding, doesn't exist:
- vdd-microvolts: positive reference Voltage [uV]
- vss-microvolts: negative reference Voltage [uV]
Signed-off-by: Przemyslaw Marczak p.marczak@samsung.com Cc: Simon Glass sjg@chromium.org
Changes V2:
- new commit - introduce ADC uclass driver
Changes V3:
- Add binding info
- ADC uclass's code rework, add single/multi-channel API
- Select single channel by a number and multi, by a bit mask
- Wait for conversion end in uclass's internal function
- Add ADC supply polarity constraint
- Add function for getting supply Voltage with polarity
doc/device-tree-bindings/adc/adc.txt | 62 ++++++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/adc/Kconfig | 12 + drivers/adc/Makefile | 8 + drivers/adc/adc-uclass.c | 409 +++++++++++++++++++++++++++++++++++ include/adc.h | 288 ++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + 8 files changed, 783 insertions(+) create mode 100644 doc/device-tree-bindings/adc/adc.txt create mode 100644 drivers/adc/Kconfig create mode 100644 drivers/adc/Makefile create mode 100644 drivers/adc/adc-uclass.c create mode 100644 include/adc.h
--- cut ---
diff --git a/drivers/adc/adc-uclass.c b/drivers/adc/adc-uclass.c new file mode 100644 index 0000000..9233fcd --- /dev/null +++ b/drivers/adc/adc-uclass.c @@ -0,0 +1,409 @@ +/*
- Copyright (C) 2015 Samsung Electronics
- Przemyslaw Marczak p.marczak@samsung.com
- SPDX-License-Identifier: GPL-2.0+
- */
+#include <common.h> +#include <errno.h> +#include <dm.h> +#include <dm/lists.h> +#include <dm/device-internal.h> +#include <dm/uclass-internal.h> +#include <adc.h> +#include <power/regulator.h>
+DECLARE_GLOBAL_DATA_PTR;
+#define ADC_UCLASS_PLATDATA_SIZE sizeof(struct adc_uclass_platdata) +#define CHECK_NUMBER true +#define CHECK_MASK (!CHECK_NUMBER)
+/* TODO: add support for timer uclass (for early calls) */ +#ifdef CONFIG_SANDBOX_ARCH +#define sdelay(x) udelay(x) +#else +extern void sdelay(unsigned long loops); +#endif
--- cut ---
I would like precise the sdelay() calls in this code.
I didn't make the cleanup for the sdelay(), as Simon requested.
For some architectures it's declared in a different headers, but we have timer uclass now, so this sdelay mess can be used temporary.
Now, I don't have time for moving Exynos timer to driver model. And also it should be done as a separated patch set.
Best regards,