Re: [PATCH 2/2] iio: adc: Add Spreadtrum SC27XX PMICs ADC support
Hi Peter, On 13 June 2018 at 17:17, Baolin Wang wrote: > Hi Peter, > > On 13 June 2018 at 16:53, Peter Meerwald-Stadler wrote: >> >>> From: Freeman Liu >> >> some comments below >> >>> The Spreadtrum SC27XX PMICs ADC controller contains 32 channels, >>> which is used to sample voltages with 12 bits conversion. >>> >>> Signed-off-by: Freeman Liu >>> Signed-off-by: Baolin Wang >>> --- >>> drivers/iio/adc/Kconfig | 10 + >>> drivers/iio/adc/Makefile |1 + >>> drivers/iio/adc/sc27xx_adc.c | 558 >>> ++ >>> 3 files changed, 569 insertions(+) >>> create mode 100644 drivers/iio/adc/sc27xx_adc.c >>> >>> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig >>> index 9da7907..985b73e 100644 >>> --- a/drivers/iio/adc/Kconfig >>> +++ b/drivers/iio/adc/Kconfig >>> @@ -621,6 +621,16 @@ config ROCKCHIP_SARADC >>> To compile this driver as a module, choose M here: the >>> module will be called rockchip_saradc. >>> >>> +config SC27XX_ADC >>> + tristate "Spreadtrum SC27xx series PMICs ADC" >>> + depends on MFD_SC27XX_PMIC || COMPILE_TEST >>> + help >>> + Say yes here to build support for the integrated ADC inside the >>> + Spreadtrum SC27xx series PMICs. >>> + >>> + This driver can also be built as a module. If so, the module >>> + will be called sc27xx_adc. >>> + >>> config SPEAR_ADC >>> tristate "ST SPEAr ADC" >>> depends on PLAT_SPEAR || COMPILE_TEST >>> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile >>> index 28a9423..03db7b5 100644 >>> --- a/drivers/iio/adc/Makefile >>> +++ b/drivers/iio/adc/Makefile >>> @@ -59,6 +59,7 @@ obj-$(CONFIG_QCOM_SPMI_VADC) += qcom-spmi-vadc.o >>> obj-$(CONFIG_QCOM_PM8XXX_XOADC) += qcom-pm8xxx-xoadc.o >>> obj-$(CONFIG_RCAR_GYRO_ADC) += rcar-gyroadc.o >>> obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o >>> +obj-$(CONFIG_SC27XX_ADC) += sc27xx_adc.o >>> obj-$(CONFIG_SPEAR_ADC) += spear_adc.o >>> obj-$(CONFIG_STX104) += stx104.o >>> obj-$(CONFIG_SUN4I_GPADC) += sun4i-gpadc-iio.o >>> diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c >>> new file mode 100644 >>> index 000..d74310a >>> --- /dev/null >>> +++ b/drivers/iio/adc/sc27xx_adc.c >>> @@ -0,0 +1,558 @@ >>> +// SPDX-License-Identifier: GPL-2.0 >>> +// Copyright (C) 2018 Spreadtrum Communications Inc. >>> + >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +/* PMIC global registers definition */ >>> +#define SC27XX_MODULE_EN 0xc08 >>> +#define SC27XX_MODULE_ADC_EN BIT(5) >>> +#define SC27XX_ARM_CLK_EN0xc10 >>> +#define SC27XX_CLK_ADC_ENBIT(5) >>> +#define SC27XX_CLK_ADC_CLK_ENBIT(6) >>> + >>> +/* ADC controller registers definition */ >>> +#define SC27XX_ADC_CTL 0x0 >>> +#define SC27XX_ADC_CH_CFG0x4 >>> +#define SC27XX_ADC_DATA 0x4c >>> +#define SC27XX_ADC_INT_EN0x50 >>> +#define SC27XX_ADC_INT_CLR 0x54 >>> +#define SC27XX_ADC_INT_STS 0x58 >>> +#define SC27XX_ADC_INT_RAW 0x5c >>> + >>> +/* Bits and mask definition for SC27XX_ADC_CTL register */ >>> +#define SC27XX_ADC_ENBIT(0) >>> +#define SC27XX_ADC_CHN_RUN BIT(1) >>> +#define SC27XX_ADC_12BIT_MODEBIT(2) >>> +#define SC27XX_ADC_RUN_NUM_MASK GENMASK(7, 4) >>> +#define SC27XX_ADC_RUN_NUM_SHIFT 4 >>> + >>> +/* Bits and mask definition for SC27XX_ADC_CH_CFG register */ >>> +#define SC27XX_ADC_CHN_ID_MASK GENMASK(4, 0) >>> +#define SC27XX_ADC_SCALE_MASKGENMASK(10, 8) >>> +#define SC27XX_ADC_SCALE_SHIFT 8 >>> + >>> +/* Bits definitions for SC27XX_ADC_INT_EN registers */ >>> +#define SC27XX_ADC_IRQ_ENBIT(0) >>> + >>> +/* Bits definitions for SC27XX_ADC_INT_CLR registers */ >>> +#define SC27XX_ADC_IRQ_CLR BIT(0) >>> + >>> +/* Mask definition for SC27XX_ADC_DATA register */ >>> +#define SC27XX_ADC_DATA_MASK GENMASK(11, 0) >>> + >>> +/* Timeout (ms) for the trylock of hardware spinlocks */ >>> +#define SC27XX_ADC_HWLOCK_TIMEOUT5000 >>> + >>> +/* Maximum ADC channel number */ >>> +#define SC27XX_ADC_CHANNEL_MAX 32 >>> + >>> +/* ADC voltage ratio definition */ >>> +#define SC27XX_VOLT_RATIO(n, d) \ >>> + (((n) << SC27XX_RATIO_NUMERATOR_OFFSET) | (d)) >>> +#define SC27XX_RATIO_NUMERATOR_OFFSET16 >>> +#define SC27XX_RATIO_DENOMINATOR_MASKGENMASK(15, 0) >>> + >>> +/* Covert ADC values to voltage values */ >> >> Convert > > Sorry for typo and will fix in next version. > >> >>> +#define SC27XX_ADC_TO_VOLTAGE(volt0, volt1, adc0, adc1, value) \ >> >> I'd rather define a function than a macro for this > > Sure. > >> >>> + ({ \ >>> +
Re: [PATCH 2/2] iio: adc: Add Spreadtrum SC27XX PMICs ADC support
Hi Peter, On 13 June 2018 at 17:17, Baolin Wang wrote: > Hi Peter, > > On 13 June 2018 at 16:53, Peter Meerwald-Stadler wrote: >> >>> From: Freeman Liu >> >> some comments below >> >>> The Spreadtrum SC27XX PMICs ADC controller contains 32 channels, >>> which is used to sample voltages with 12 bits conversion. >>> >>> Signed-off-by: Freeman Liu >>> Signed-off-by: Baolin Wang >>> --- >>> drivers/iio/adc/Kconfig | 10 + >>> drivers/iio/adc/Makefile |1 + >>> drivers/iio/adc/sc27xx_adc.c | 558 >>> ++ >>> 3 files changed, 569 insertions(+) >>> create mode 100644 drivers/iio/adc/sc27xx_adc.c >>> >>> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig >>> index 9da7907..985b73e 100644 >>> --- a/drivers/iio/adc/Kconfig >>> +++ b/drivers/iio/adc/Kconfig >>> @@ -621,6 +621,16 @@ config ROCKCHIP_SARADC >>> To compile this driver as a module, choose M here: the >>> module will be called rockchip_saradc. >>> >>> +config SC27XX_ADC >>> + tristate "Spreadtrum SC27xx series PMICs ADC" >>> + depends on MFD_SC27XX_PMIC || COMPILE_TEST >>> + help >>> + Say yes here to build support for the integrated ADC inside the >>> + Spreadtrum SC27xx series PMICs. >>> + >>> + This driver can also be built as a module. If so, the module >>> + will be called sc27xx_adc. >>> + >>> config SPEAR_ADC >>> tristate "ST SPEAr ADC" >>> depends on PLAT_SPEAR || COMPILE_TEST >>> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile >>> index 28a9423..03db7b5 100644 >>> --- a/drivers/iio/adc/Makefile >>> +++ b/drivers/iio/adc/Makefile >>> @@ -59,6 +59,7 @@ obj-$(CONFIG_QCOM_SPMI_VADC) += qcom-spmi-vadc.o >>> obj-$(CONFIG_QCOM_PM8XXX_XOADC) += qcom-pm8xxx-xoadc.o >>> obj-$(CONFIG_RCAR_GYRO_ADC) += rcar-gyroadc.o >>> obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o >>> +obj-$(CONFIG_SC27XX_ADC) += sc27xx_adc.o >>> obj-$(CONFIG_SPEAR_ADC) += spear_adc.o >>> obj-$(CONFIG_STX104) += stx104.o >>> obj-$(CONFIG_SUN4I_GPADC) += sun4i-gpadc-iio.o >>> diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c >>> new file mode 100644 >>> index 000..d74310a >>> --- /dev/null >>> +++ b/drivers/iio/adc/sc27xx_adc.c >>> @@ -0,0 +1,558 @@ >>> +// SPDX-License-Identifier: GPL-2.0 >>> +// Copyright (C) 2018 Spreadtrum Communications Inc. >>> + >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +/* PMIC global registers definition */ >>> +#define SC27XX_MODULE_EN 0xc08 >>> +#define SC27XX_MODULE_ADC_EN BIT(5) >>> +#define SC27XX_ARM_CLK_EN0xc10 >>> +#define SC27XX_CLK_ADC_ENBIT(5) >>> +#define SC27XX_CLK_ADC_CLK_ENBIT(6) >>> + >>> +/* ADC controller registers definition */ >>> +#define SC27XX_ADC_CTL 0x0 >>> +#define SC27XX_ADC_CH_CFG0x4 >>> +#define SC27XX_ADC_DATA 0x4c >>> +#define SC27XX_ADC_INT_EN0x50 >>> +#define SC27XX_ADC_INT_CLR 0x54 >>> +#define SC27XX_ADC_INT_STS 0x58 >>> +#define SC27XX_ADC_INT_RAW 0x5c >>> + >>> +/* Bits and mask definition for SC27XX_ADC_CTL register */ >>> +#define SC27XX_ADC_ENBIT(0) >>> +#define SC27XX_ADC_CHN_RUN BIT(1) >>> +#define SC27XX_ADC_12BIT_MODEBIT(2) >>> +#define SC27XX_ADC_RUN_NUM_MASK GENMASK(7, 4) >>> +#define SC27XX_ADC_RUN_NUM_SHIFT 4 >>> + >>> +/* Bits and mask definition for SC27XX_ADC_CH_CFG register */ >>> +#define SC27XX_ADC_CHN_ID_MASK GENMASK(4, 0) >>> +#define SC27XX_ADC_SCALE_MASKGENMASK(10, 8) >>> +#define SC27XX_ADC_SCALE_SHIFT 8 >>> + >>> +/* Bits definitions for SC27XX_ADC_INT_EN registers */ >>> +#define SC27XX_ADC_IRQ_ENBIT(0) >>> + >>> +/* Bits definitions for SC27XX_ADC_INT_CLR registers */ >>> +#define SC27XX_ADC_IRQ_CLR BIT(0) >>> + >>> +/* Mask definition for SC27XX_ADC_DATA register */ >>> +#define SC27XX_ADC_DATA_MASK GENMASK(11, 0) >>> + >>> +/* Timeout (ms) for the trylock of hardware spinlocks */ >>> +#define SC27XX_ADC_HWLOCK_TIMEOUT5000 >>> + >>> +/* Maximum ADC channel number */ >>> +#define SC27XX_ADC_CHANNEL_MAX 32 >>> + >>> +/* ADC voltage ratio definition */ >>> +#define SC27XX_VOLT_RATIO(n, d) \ >>> + (((n) << SC27XX_RATIO_NUMERATOR_OFFSET) | (d)) >>> +#define SC27XX_RATIO_NUMERATOR_OFFSET16 >>> +#define SC27XX_RATIO_DENOMINATOR_MASKGENMASK(15, 0) >>> + >>> +/* Covert ADC values to voltage values */ >> >> Convert > > Sorry for typo and will fix in next version. > >> >>> +#define SC27XX_ADC_TO_VOLTAGE(volt0, volt1, adc0, adc1, value) \ >> >> I'd rather define a function than a macro for this > > Sure. > >> >>> + ({ \ >>> +
Re: [PATCH 2/2] iio: adc: Add Spreadtrum SC27XX PMICs ADC support
Hi Peter, On 13 June 2018 at 16:53, Peter Meerwald-Stadler wrote: > >> From: Freeman Liu > > some comments below > >> The Spreadtrum SC27XX PMICs ADC controller contains 32 channels, >> which is used to sample voltages with 12 bits conversion. >> >> Signed-off-by: Freeman Liu >> Signed-off-by: Baolin Wang >> --- >> drivers/iio/adc/Kconfig | 10 + >> drivers/iio/adc/Makefile |1 + >> drivers/iio/adc/sc27xx_adc.c | 558 >> ++ >> 3 files changed, 569 insertions(+) >> create mode 100644 drivers/iio/adc/sc27xx_adc.c >> >> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig >> index 9da7907..985b73e 100644 >> --- a/drivers/iio/adc/Kconfig >> +++ b/drivers/iio/adc/Kconfig >> @@ -621,6 +621,16 @@ config ROCKCHIP_SARADC >> To compile this driver as a module, choose M here: the >> module will be called rockchip_saradc. >> >> +config SC27XX_ADC >> + tristate "Spreadtrum SC27xx series PMICs ADC" >> + depends on MFD_SC27XX_PMIC || COMPILE_TEST >> + help >> + Say yes here to build support for the integrated ADC inside the >> + Spreadtrum SC27xx series PMICs. >> + >> + This driver can also be built as a module. If so, the module >> + will be called sc27xx_adc. >> + >> config SPEAR_ADC >> tristate "ST SPEAr ADC" >> depends on PLAT_SPEAR || COMPILE_TEST >> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile >> index 28a9423..03db7b5 100644 >> --- a/drivers/iio/adc/Makefile >> +++ b/drivers/iio/adc/Makefile >> @@ -59,6 +59,7 @@ obj-$(CONFIG_QCOM_SPMI_VADC) += qcom-spmi-vadc.o >> obj-$(CONFIG_QCOM_PM8XXX_XOADC) += qcom-pm8xxx-xoadc.o >> obj-$(CONFIG_RCAR_GYRO_ADC) += rcar-gyroadc.o >> obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o >> +obj-$(CONFIG_SC27XX_ADC) += sc27xx_adc.o >> obj-$(CONFIG_SPEAR_ADC) += spear_adc.o >> obj-$(CONFIG_STX104) += stx104.o >> obj-$(CONFIG_SUN4I_GPADC) += sun4i-gpadc-iio.o >> diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c >> new file mode 100644 >> index 000..d74310a >> --- /dev/null >> +++ b/drivers/iio/adc/sc27xx_adc.c >> @@ -0,0 +1,558 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +// Copyright (C) 2018 Spreadtrum Communications Inc. >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +/* PMIC global registers definition */ >> +#define SC27XX_MODULE_EN 0xc08 >> +#define SC27XX_MODULE_ADC_EN BIT(5) >> +#define SC27XX_ARM_CLK_EN0xc10 >> +#define SC27XX_CLK_ADC_ENBIT(5) >> +#define SC27XX_CLK_ADC_CLK_ENBIT(6) >> + >> +/* ADC controller registers definition */ >> +#define SC27XX_ADC_CTL 0x0 >> +#define SC27XX_ADC_CH_CFG0x4 >> +#define SC27XX_ADC_DATA 0x4c >> +#define SC27XX_ADC_INT_EN0x50 >> +#define SC27XX_ADC_INT_CLR 0x54 >> +#define SC27XX_ADC_INT_STS 0x58 >> +#define SC27XX_ADC_INT_RAW 0x5c >> + >> +/* Bits and mask definition for SC27XX_ADC_CTL register */ >> +#define SC27XX_ADC_ENBIT(0) >> +#define SC27XX_ADC_CHN_RUN BIT(1) >> +#define SC27XX_ADC_12BIT_MODEBIT(2) >> +#define SC27XX_ADC_RUN_NUM_MASK GENMASK(7, 4) >> +#define SC27XX_ADC_RUN_NUM_SHIFT 4 >> + >> +/* Bits and mask definition for SC27XX_ADC_CH_CFG register */ >> +#define SC27XX_ADC_CHN_ID_MASK GENMASK(4, 0) >> +#define SC27XX_ADC_SCALE_MASKGENMASK(10, 8) >> +#define SC27XX_ADC_SCALE_SHIFT 8 >> + >> +/* Bits definitions for SC27XX_ADC_INT_EN registers */ >> +#define SC27XX_ADC_IRQ_ENBIT(0) >> + >> +/* Bits definitions for SC27XX_ADC_INT_CLR registers */ >> +#define SC27XX_ADC_IRQ_CLR BIT(0) >> + >> +/* Mask definition for SC27XX_ADC_DATA register */ >> +#define SC27XX_ADC_DATA_MASK GENMASK(11, 0) >> + >> +/* Timeout (ms) for the trylock of hardware spinlocks */ >> +#define SC27XX_ADC_HWLOCK_TIMEOUT5000 >> + >> +/* Maximum ADC channel number */ >> +#define SC27XX_ADC_CHANNEL_MAX 32 >> + >> +/* ADC voltage ratio definition */ >> +#define SC27XX_VOLT_RATIO(n, d) \ >> + (((n) << SC27XX_RATIO_NUMERATOR_OFFSET) | (d)) >> +#define SC27XX_RATIO_NUMERATOR_OFFSET16 >> +#define SC27XX_RATIO_DENOMINATOR_MASKGENMASK(15, 0) >> + >> +/* Covert ADC values to voltage values */ > > Convert Sorry for typo and will fix in next version. > >> +#define SC27XX_ADC_TO_VOLTAGE(volt0, volt1, adc0, adc1, value) \ > > I'd rather define a function than a macro for this Sure. > >> + ({ \ >> + int tmp;\ >> + tmp = (volt0) - (volt1);\ >> + tmp = tmp * ((value) - (adc1)); \ >> +
Re: [PATCH 2/2] iio: adc: Add Spreadtrum SC27XX PMICs ADC support
Hi Peter, On 13 June 2018 at 16:53, Peter Meerwald-Stadler wrote: > >> From: Freeman Liu > > some comments below > >> The Spreadtrum SC27XX PMICs ADC controller contains 32 channels, >> which is used to sample voltages with 12 bits conversion. >> >> Signed-off-by: Freeman Liu >> Signed-off-by: Baolin Wang >> --- >> drivers/iio/adc/Kconfig | 10 + >> drivers/iio/adc/Makefile |1 + >> drivers/iio/adc/sc27xx_adc.c | 558 >> ++ >> 3 files changed, 569 insertions(+) >> create mode 100644 drivers/iio/adc/sc27xx_adc.c >> >> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig >> index 9da7907..985b73e 100644 >> --- a/drivers/iio/adc/Kconfig >> +++ b/drivers/iio/adc/Kconfig >> @@ -621,6 +621,16 @@ config ROCKCHIP_SARADC >> To compile this driver as a module, choose M here: the >> module will be called rockchip_saradc. >> >> +config SC27XX_ADC >> + tristate "Spreadtrum SC27xx series PMICs ADC" >> + depends on MFD_SC27XX_PMIC || COMPILE_TEST >> + help >> + Say yes here to build support for the integrated ADC inside the >> + Spreadtrum SC27xx series PMICs. >> + >> + This driver can also be built as a module. If so, the module >> + will be called sc27xx_adc. >> + >> config SPEAR_ADC >> tristate "ST SPEAr ADC" >> depends on PLAT_SPEAR || COMPILE_TEST >> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile >> index 28a9423..03db7b5 100644 >> --- a/drivers/iio/adc/Makefile >> +++ b/drivers/iio/adc/Makefile >> @@ -59,6 +59,7 @@ obj-$(CONFIG_QCOM_SPMI_VADC) += qcom-spmi-vadc.o >> obj-$(CONFIG_QCOM_PM8XXX_XOADC) += qcom-pm8xxx-xoadc.o >> obj-$(CONFIG_RCAR_GYRO_ADC) += rcar-gyroadc.o >> obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o >> +obj-$(CONFIG_SC27XX_ADC) += sc27xx_adc.o >> obj-$(CONFIG_SPEAR_ADC) += spear_adc.o >> obj-$(CONFIG_STX104) += stx104.o >> obj-$(CONFIG_SUN4I_GPADC) += sun4i-gpadc-iio.o >> diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c >> new file mode 100644 >> index 000..d74310a >> --- /dev/null >> +++ b/drivers/iio/adc/sc27xx_adc.c >> @@ -0,0 +1,558 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +// Copyright (C) 2018 Spreadtrum Communications Inc. >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +/* PMIC global registers definition */ >> +#define SC27XX_MODULE_EN 0xc08 >> +#define SC27XX_MODULE_ADC_EN BIT(5) >> +#define SC27XX_ARM_CLK_EN0xc10 >> +#define SC27XX_CLK_ADC_ENBIT(5) >> +#define SC27XX_CLK_ADC_CLK_ENBIT(6) >> + >> +/* ADC controller registers definition */ >> +#define SC27XX_ADC_CTL 0x0 >> +#define SC27XX_ADC_CH_CFG0x4 >> +#define SC27XX_ADC_DATA 0x4c >> +#define SC27XX_ADC_INT_EN0x50 >> +#define SC27XX_ADC_INT_CLR 0x54 >> +#define SC27XX_ADC_INT_STS 0x58 >> +#define SC27XX_ADC_INT_RAW 0x5c >> + >> +/* Bits and mask definition for SC27XX_ADC_CTL register */ >> +#define SC27XX_ADC_ENBIT(0) >> +#define SC27XX_ADC_CHN_RUN BIT(1) >> +#define SC27XX_ADC_12BIT_MODEBIT(2) >> +#define SC27XX_ADC_RUN_NUM_MASK GENMASK(7, 4) >> +#define SC27XX_ADC_RUN_NUM_SHIFT 4 >> + >> +/* Bits and mask definition for SC27XX_ADC_CH_CFG register */ >> +#define SC27XX_ADC_CHN_ID_MASK GENMASK(4, 0) >> +#define SC27XX_ADC_SCALE_MASKGENMASK(10, 8) >> +#define SC27XX_ADC_SCALE_SHIFT 8 >> + >> +/* Bits definitions for SC27XX_ADC_INT_EN registers */ >> +#define SC27XX_ADC_IRQ_ENBIT(0) >> + >> +/* Bits definitions for SC27XX_ADC_INT_CLR registers */ >> +#define SC27XX_ADC_IRQ_CLR BIT(0) >> + >> +/* Mask definition for SC27XX_ADC_DATA register */ >> +#define SC27XX_ADC_DATA_MASK GENMASK(11, 0) >> + >> +/* Timeout (ms) for the trylock of hardware spinlocks */ >> +#define SC27XX_ADC_HWLOCK_TIMEOUT5000 >> + >> +/* Maximum ADC channel number */ >> +#define SC27XX_ADC_CHANNEL_MAX 32 >> + >> +/* ADC voltage ratio definition */ >> +#define SC27XX_VOLT_RATIO(n, d) \ >> + (((n) << SC27XX_RATIO_NUMERATOR_OFFSET) | (d)) >> +#define SC27XX_RATIO_NUMERATOR_OFFSET16 >> +#define SC27XX_RATIO_DENOMINATOR_MASKGENMASK(15, 0) >> + >> +/* Covert ADC values to voltage values */ > > Convert Sorry for typo and will fix in next version. > >> +#define SC27XX_ADC_TO_VOLTAGE(volt0, volt1, adc0, adc1, value) \ > > I'd rather define a function than a macro for this Sure. > >> + ({ \ >> + int tmp;\ >> + tmp = (volt0) - (volt1);\ >> + tmp = tmp * ((value) - (adc1)); \ >> +
Re: [PATCH 2/2] iio: adc: Add Spreadtrum SC27XX PMICs ADC support
> From: Freeman Liu some comments below > The Spreadtrum SC27XX PMICs ADC controller contains 32 channels, > which is used to sample voltages with 12 bits conversion. > > Signed-off-by: Freeman Liu > Signed-off-by: Baolin Wang > --- > drivers/iio/adc/Kconfig | 10 + > drivers/iio/adc/Makefile |1 + > drivers/iio/adc/sc27xx_adc.c | 558 > ++ > 3 files changed, 569 insertions(+) > create mode 100644 drivers/iio/adc/sc27xx_adc.c > > diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig > index 9da7907..985b73e 100644 > --- a/drivers/iio/adc/Kconfig > +++ b/drivers/iio/adc/Kconfig > @@ -621,6 +621,16 @@ config ROCKCHIP_SARADC > To compile this driver as a module, choose M here: the > module will be called rockchip_saradc. > > +config SC27XX_ADC > + tristate "Spreadtrum SC27xx series PMICs ADC" > + depends on MFD_SC27XX_PMIC || COMPILE_TEST > + help > + Say yes here to build support for the integrated ADC inside the > + Spreadtrum SC27xx series PMICs. > + > + This driver can also be built as a module. If so, the module > + will be called sc27xx_adc. > + > config SPEAR_ADC > tristate "ST SPEAr ADC" > depends on PLAT_SPEAR || COMPILE_TEST > diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile > index 28a9423..03db7b5 100644 > --- a/drivers/iio/adc/Makefile > +++ b/drivers/iio/adc/Makefile > @@ -59,6 +59,7 @@ obj-$(CONFIG_QCOM_SPMI_VADC) += qcom-spmi-vadc.o > obj-$(CONFIG_QCOM_PM8XXX_XOADC) += qcom-pm8xxx-xoadc.o > obj-$(CONFIG_RCAR_GYRO_ADC) += rcar-gyroadc.o > obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o > +obj-$(CONFIG_SC27XX_ADC) += sc27xx_adc.o > obj-$(CONFIG_SPEAR_ADC) += spear_adc.o > obj-$(CONFIG_STX104) += stx104.o > obj-$(CONFIG_SUN4I_GPADC) += sun4i-gpadc-iio.o > diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c > new file mode 100644 > index 000..d74310a > --- /dev/null > +++ b/drivers/iio/adc/sc27xx_adc.c > @@ -0,0 +1,558 @@ > +// SPDX-License-Identifier: GPL-2.0 > +// Copyright (C) 2018 Spreadtrum Communications Inc. > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* PMIC global registers definition */ > +#define SC27XX_MODULE_EN 0xc08 > +#define SC27XX_MODULE_ADC_EN BIT(5) > +#define SC27XX_ARM_CLK_EN0xc10 > +#define SC27XX_CLK_ADC_ENBIT(5) > +#define SC27XX_CLK_ADC_CLK_ENBIT(6) > + > +/* ADC controller registers definition */ > +#define SC27XX_ADC_CTL 0x0 > +#define SC27XX_ADC_CH_CFG0x4 > +#define SC27XX_ADC_DATA 0x4c > +#define SC27XX_ADC_INT_EN0x50 > +#define SC27XX_ADC_INT_CLR 0x54 > +#define SC27XX_ADC_INT_STS 0x58 > +#define SC27XX_ADC_INT_RAW 0x5c > + > +/* Bits and mask definition for SC27XX_ADC_CTL register */ > +#define SC27XX_ADC_ENBIT(0) > +#define SC27XX_ADC_CHN_RUN BIT(1) > +#define SC27XX_ADC_12BIT_MODEBIT(2) > +#define SC27XX_ADC_RUN_NUM_MASK GENMASK(7, 4) > +#define SC27XX_ADC_RUN_NUM_SHIFT 4 > + > +/* Bits and mask definition for SC27XX_ADC_CH_CFG register */ > +#define SC27XX_ADC_CHN_ID_MASK GENMASK(4, 0) > +#define SC27XX_ADC_SCALE_MASKGENMASK(10, 8) > +#define SC27XX_ADC_SCALE_SHIFT 8 > + > +/* Bits definitions for SC27XX_ADC_INT_EN registers */ > +#define SC27XX_ADC_IRQ_ENBIT(0) > + > +/* Bits definitions for SC27XX_ADC_INT_CLR registers */ > +#define SC27XX_ADC_IRQ_CLR BIT(0) > + > +/* Mask definition for SC27XX_ADC_DATA register */ > +#define SC27XX_ADC_DATA_MASK GENMASK(11, 0) > + > +/* Timeout (ms) for the trylock of hardware spinlocks */ > +#define SC27XX_ADC_HWLOCK_TIMEOUT5000 > + > +/* Maximum ADC channel number */ > +#define SC27XX_ADC_CHANNEL_MAX 32 > + > +/* ADC voltage ratio definition */ > +#define SC27XX_VOLT_RATIO(n, d) \ > + (((n) << SC27XX_RATIO_NUMERATOR_OFFSET) | (d)) > +#define SC27XX_RATIO_NUMERATOR_OFFSET16 > +#define SC27XX_RATIO_DENOMINATOR_MASKGENMASK(15, 0) > + > +/* Covert ADC values to voltage values */ Convert > +#define SC27XX_ADC_TO_VOLTAGE(volt0, volt1, adc0, adc1, value) \ I'd rather define a function than a macro for this > + ({ \ > + int tmp;\ > + tmp = (volt0) - (volt1);\ > + tmp = tmp * ((value) - (adc1)); \ > + tmp = tmp / ((adc0) - (adc1)); \ > + tmp = tmp + (volt1);\ > + if (tmp < 0)\ > + tmp = 0;
Re: [PATCH 2/2] iio: adc: Add Spreadtrum SC27XX PMICs ADC support
> From: Freeman Liu some comments below > The Spreadtrum SC27XX PMICs ADC controller contains 32 channels, > which is used to sample voltages with 12 bits conversion. > > Signed-off-by: Freeman Liu > Signed-off-by: Baolin Wang > --- > drivers/iio/adc/Kconfig | 10 + > drivers/iio/adc/Makefile |1 + > drivers/iio/adc/sc27xx_adc.c | 558 > ++ > 3 files changed, 569 insertions(+) > create mode 100644 drivers/iio/adc/sc27xx_adc.c > > diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig > index 9da7907..985b73e 100644 > --- a/drivers/iio/adc/Kconfig > +++ b/drivers/iio/adc/Kconfig > @@ -621,6 +621,16 @@ config ROCKCHIP_SARADC > To compile this driver as a module, choose M here: the > module will be called rockchip_saradc. > > +config SC27XX_ADC > + tristate "Spreadtrum SC27xx series PMICs ADC" > + depends on MFD_SC27XX_PMIC || COMPILE_TEST > + help > + Say yes here to build support for the integrated ADC inside the > + Spreadtrum SC27xx series PMICs. > + > + This driver can also be built as a module. If so, the module > + will be called sc27xx_adc. > + > config SPEAR_ADC > tristate "ST SPEAr ADC" > depends on PLAT_SPEAR || COMPILE_TEST > diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile > index 28a9423..03db7b5 100644 > --- a/drivers/iio/adc/Makefile > +++ b/drivers/iio/adc/Makefile > @@ -59,6 +59,7 @@ obj-$(CONFIG_QCOM_SPMI_VADC) += qcom-spmi-vadc.o > obj-$(CONFIG_QCOM_PM8XXX_XOADC) += qcom-pm8xxx-xoadc.o > obj-$(CONFIG_RCAR_GYRO_ADC) += rcar-gyroadc.o > obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o > +obj-$(CONFIG_SC27XX_ADC) += sc27xx_adc.o > obj-$(CONFIG_SPEAR_ADC) += spear_adc.o > obj-$(CONFIG_STX104) += stx104.o > obj-$(CONFIG_SUN4I_GPADC) += sun4i-gpadc-iio.o > diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c > new file mode 100644 > index 000..d74310a > --- /dev/null > +++ b/drivers/iio/adc/sc27xx_adc.c > @@ -0,0 +1,558 @@ > +// SPDX-License-Identifier: GPL-2.0 > +// Copyright (C) 2018 Spreadtrum Communications Inc. > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* PMIC global registers definition */ > +#define SC27XX_MODULE_EN 0xc08 > +#define SC27XX_MODULE_ADC_EN BIT(5) > +#define SC27XX_ARM_CLK_EN0xc10 > +#define SC27XX_CLK_ADC_ENBIT(5) > +#define SC27XX_CLK_ADC_CLK_ENBIT(6) > + > +/* ADC controller registers definition */ > +#define SC27XX_ADC_CTL 0x0 > +#define SC27XX_ADC_CH_CFG0x4 > +#define SC27XX_ADC_DATA 0x4c > +#define SC27XX_ADC_INT_EN0x50 > +#define SC27XX_ADC_INT_CLR 0x54 > +#define SC27XX_ADC_INT_STS 0x58 > +#define SC27XX_ADC_INT_RAW 0x5c > + > +/* Bits and mask definition for SC27XX_ADC_CTL register */ > +#define SC27XX_ADC_ENBIT(0) > +#define SC27XX_ADC_CHN_RUN BIT(1) > +#define SC27XX_ADC_12BIT_MODEBIT(2) > +#define SC27XX_ADC_RUN_NUM_MASK GENMASK(7, 4) > +#define SC27XX_ADC_RUN_NUM_SHIFT 4 > + > +/* Bits and mask definition for SC27XX_ADC_CH_CFG register */ > +#define SC27XX_ADC_CHN_ID_MASK GENMASK(4, 0) > +#define SC27XX_ADC_SCALE_MASKGENMASK(10, 8) > +#define SC27XX_ADC_SCALE_SHIFT 8 > + > +/* Bits definitions for SC27XX_ADC_INT_EN registers */ > +#define SC27XX_ADC_IRQ_ENBIT(0) > + > +/* Bits definitions for SC27XX_ADC_INT_CLR registers */ > +#define SC27XX_ADC_IRQ_CLR BIT(0) > + > +/* Mask definition for SC27XX_ADC_DATA register */ > +#define SC27XX_ADC_DATA_MASK GENMASK(11, 0) > + > +/* Timeout (ms) for the trylock of hardware spinlocks */ > +#define SC27XX_ADC_HWLOCK_TIMEOUT5000 > + > +/* Maximum ADC channel number */ > +#define SC27XX_ADC_CHANNEL_MAX 32 > + > +/* ADC voltage ratio definition */ > +#define SC27XX_VOLT_RATIO(n, d) \ > + (((n) << SC27XX_RATIO_NUMERATOR_OFFSET) | (d)) > +#define SC27XX_RATIO_NUMERATOR_OFFSET16 > +#define SC27XX_RATIO_DENOMINATOR_MASKGENMASK(15, 0) > + > +/* Covert ADC values to voltage values */ Convert > +#define SC27XX_ADC_TO_VOLTAGE(volt0, volt1, adc0, adc1, value) \ I'd rather define a function than a macro for this > + ({ \ > + int tmp;\ > + tmp = (volt0) - (volt1);\ > + tmp = tmp * ((value) - (adc1)); \ > + tmp = tmp / ((adc0) - (adc1)); \ > + tmp = tmp + (volt1);\ > + if (tmp < 0)\ > + tmp = 0;
[PATCH 2/2] iio: adc: Add Spreadtrum SC27XX PMICs ADC support
From: Freeman Liu The Spreadtrum SC27XX PMICs ADC controller contains 32 channels, which is used to sample voltages with 12 bits conversion. Signed-off-by: Freeman Liu Signed-off-by: Baolin Wang --- drivers/iio/adc/Kconfig | 10 + drivers/iio/adc/Makefile |1 + drivers/iio/adc/sc27xx_adc.c | 558 ++ 3 files changed, 569 insertions(+) create mode 100644 drivers/iio/adc/sc27xx_adc.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 9da7907..985b73e 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -621,6 +621,16 @@ config ROCKCHIP_SARADC To compile this driver as a module, choose M here: the module will be called rockchip_saradc. +config SC27XX_ADC + tristate "Spreadtrum SC27xx series PMICs ADC" + depends on MFD_SC27XX_PMIC || COMPILE_TEST + help + Say yes here to build support for the integrated ADC inside the + Spreadtrum SC27xx series PMICs. + + This driver can also be built as a module. If so, the module + will be called sc27xx_adc. + config SPEAR_ADC tristate "ST SPEAr ADC" depends on PLAT_SPEAR || COMPILE_TEST diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 28a9423..03db7b5 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -59,6 +59,7 @@ obj-$(CONFIG_QCOM_SPMI_VADC) += qcom-spmi-vadc.o obj-$(CONFIG_QCOM_PM8XXX_XOADC) += qcom-pm8xxx-xoadc.o obj-$(CONFIG_RCAR_GYRO_ADC) += rcar-gyroadc.o obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o +obj-$(CONFIG_SC27XX_ADC) += sc27xx_adc.o obj-$(CONFIG_SPEAR_ADC) += spear_adc.o obj-$(CONFIG_STX104) += stx104.o obj-$(CONFIG_SUN4I_GPADC) += sun4i-gpadc-iio.o diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c new file mode 100644 index 000..d74310a --- /dev/null +++ b/drivers/iio/adc/sc27xx_adc.c @@ -0,0 +1,558 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2018 Spreadtrum Communications Inc. + +#include +#include +#include +#include +#include +#include +#include +#include + +/* PMIC global registers definition */ +#define SC27XX_MODULE_EN 0xc08 +#define SC27XX_MODULE_ADC_EN BIT(5) +#define SC27XX_ARM_CLK_EN 0xc10 +#define SC27XX_CLK_ADC_EN BIT(5) +#define SC27XX_CLK_ADC_CLK_EN BIT(6) + +/* ADC controller registers definition */ +#define SC27XX_ADC_CTL 0x0 +#define SC27XX_ADC_CH_CFG 0x4 +#define SC27XX_ADC_DATA0x4c +#define SC27XX_ADC_INT_EN 0x50 +#define SC27XX_ADC_INT_CLR 0x54 +#define SC27XX_ADC_INT_STS 0x58 +#define SC27XX_ADC_INT_RAW 0x5c + +/* Bits and mask definition for SC27XX_ADC_CTL register */ +#define SC27XX_ADC_EN BIT(0) +#define SC27XX_ADC_CHN_RUN BIT(1) +#define SC27XX_ADC_12BIT_MODE BIT(2) +#define SC27XX_ADC_RUN_NUM_MASKGENMASK(7, 4) +#define SC27XX_ADC_RUN_NUM_SHIFT 4 + +/* Bits and mask definition for SC27XX_ADC_CH_CFG register */ +#define SC27XX_ADC_CHN_ID_MASK GENMASK(4, 0) +#define SC27XX_ADC_SCALE_MASK GENMASK(10, 8) +#define SC27XX_ADC_SCALE_SHIFT 8 + +/* Bits definitions for SC27XX_ADC_INT_EN registers */ +#define SC27XX_ADC_IRQ_EN BIT(0) + +/* Bits definitions for SC27XX_ADC_INT_CLR registers */ +#define SC27XX_ADC_IRQ_CLR BIT(0) + +/* Mask definition for SC27XX_ADC_DATA register */ +#define SC27XX_ADC_DATA_MASK GENMASK(11, 0) + +/* Timeout (ms) for the trylock of hardware spinlocks */ +#define SC27XX_ADC_HWLOCK_TIMEOUT 5000 + +/* Maximum ADC channel number */ +#define SC27XX_ADC_CHANNEL_MAX 32 + +/* ADC voltage ratio definition */ +#define SC27XX_VOLT_RATIO(n, d)\ + (((n) << SC27XX_RATIO_NUMERATOR_OFFSET) | (d)) +#define SC27XX_RATIO_NUMERATOR_OFFSET 16 +#define SC27XX_RATIO_DENOMINATOR_MASK GENMASK(15, 0) + +/* Covert ADC values to voltage values */ +#define SC27XX_ADC_TO_VOLTAGE(volt0, volt1, adc0, adc1, value) \ + ({ \ + int tmp;\ + tmp = (volt0) - (volt1);\ + tmp = tmp * ((value) - (adc1)); \ + tmp = tmp / ((adc0) - (adc1)); \ + tmp = tmp + (volt1);\ + if (tmp < 0)\ + tmp = 0;\ + \ + tmp;\ + }) + +struct sc27xx_adc_data { + struct device *dev; + struct regmap *regmap; + /* +* One hardware spinlock to synchronize between the multiple +*
[PATCH 2/2] iio: adc: Add Spreadtrum SC27XX PMICs ADC support
From: Freeman Liu The Spreadtrum SC27XX PMICs ADC controller contains 32 channels, which is used to sample voltages with 12 bits conversion. Signed-off-by: Freeman Liu Signed-off-by: Baolin Wang --- drivers/iio/adc/Kconfig | 10 + drivers/iio/adc/Makefile |1 + drivers/iio/adc/sc27xx_adc.c | 558 ++ 3 files changed, 569 insertions(+) create mode 100644 drivers/iio/adc/sc27xx_adc.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 9da7907..985b73e 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -621,6 +621,16 @@ config ROCKCHIP_SARADC To compile this driver as a module, choose M here: the module will be called rockchip_saradc. +config SC27XX_ADC + tristate "Spreadtrum SC27xx series PMICs ADC" + depends on MFD_SC27XX_PMIC || COMPILE_TEST + help + Say yes here to build support for the integrated ADC inside the + Spreadtrum SC27xx series PMICs. + + This driver can also be built as a module. If so, the module + will be called sc27xx_adc. + config SPEAR_ADC tristate "ST SPEAr ADC" depends on PLAT_SPEAR || COMPILE_TEST diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 28a9423..03db7b5 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -59,6 +59,7 @@ obj-$(CONFIG_QCOM_SPMI_VADC) += qcom-spmi-vadc.o obj-$(CONFIG_QCOM_PM8XXX_XOADC) += qcom-pm8xxx-xoadc.o obj-$(CONFIG_RCAR_GYRO_ADC) += rcar-gyroadc.o obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o +obj-$(CONFIG_SC27XX_ADC) += sc27xx_adc.o obj-$(CONFIG_SPEAR_ADC) += spear_adc.o obj-$(CONFIG_STX104) += stx104.o obj-$(CONFIG_SUN4I_GPADC) += sun4i-gpadc-iio.o diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c new file mode 100644 index 000..d74310a --- /dev/null +++ b/drivers/iio/adc/sc27xx_adc.c @@ -0,0 +1,558 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2018 Spreadtrum Communications Inc. + +#include +#include +#include +#include +#include +#include +#include +#include + +/* PMIC global registers definition */ +#define SC27XX_MODULE_EN 0xc08 +#define SC27XX_MODULE_ADC_EN BIT(5) +#define SC27XX_ARM_CLK_EN 0xc10 +#define SC27XX_CLK_ADC_EN BIT(5) +#define SC27XX_CLK_ADC_CLK_EN BIT(6) + +/* ADC controller registers definition */ +#define SC27XX_ADC_CTL 0x0 +#define SC27XX_ADC_CH_CFG 0x4 +#define SC27XX_ADC_DATA0x4c +#define SC27XX_ADC_INT_EN 0x50 +#define SC27XX_ADC_INT_CLR 0x54 +#define SC27XX_ADC_INT_STS 0x58 +#define SC27XX_ADC_INT_RAW 0x5c + +/* Bits and mask definition for SC27XX_ADC_CTL register */ +#define SC27XX_ADC_EN BIT(0) +#define SC27XX_ADC_CHN_RUN BIT(1) +#define SC27XX_ADC_12BIT_MODE BIT(2) +#define SC27XX_ADC_RUN_NUM_MASKGENMASK(7, 4) +#define SC27XX_ADC_RUN_NUM_SHIFT 4 + +/* Bits and mask definition for SC27XX_ADC_CH_CFG register */ +#define SC27XX_ADC_CHN_ID_MASK GENMASK(4, 0) +#define SC27XX_ADC_SCALE_MASK GENMASK(10, 8) +#define SC27XX_ADC_SCALE_SHIFT 8 + +/* Bits definitions for SC27XX_ADC_INT_EN registers */ +#define SC27XX_ADC_IRQ_EN BIT(0) + +/* Bits definitions for SC27XX_ADC_INT_CLR registers */ +#define SC27XX_ADC_IRQ_CLR BIT(0) + +/* Mask definition for SC27XX_ADC_DATA register */ +#define SC27XX_ADC_DATA_MASK GENMASK(11, 0) + +/* Timeout (ms) for the trylock of hardware spinlocks */ +#define SC27XX_ADC_HWLOCK_TIMEOUT 5000 + +/* Maximum ADC channel number */ +#define SC27XX_ADC_CHANNEL_MAX 32 + +/* ADC voltage ratio definition */ +#define SC27XX_VOLT_RATIO(n, d)\ + (((n) << SC27XX_RATIO_NUMERATOR_OFFSET) | (d)) +#define SC27XX_RATIO_NUMERATOR_OFFSET 16 +#define SC27XX_RATIO_DENOMINATOR_MASK GENMASK(15, 0) + +/* Covert ADC values to voltage values */ +#define SC27XX_ADC_TO_VOLTAGE(volt0, volt1, adc0, adc1, value) \ + ({ \ + int tmp;\ + tmp = (volt0) - (volt1);\ + tmp = tmp * ((value) - (adc1)); \ + tmp = tmp / ((adc0) - (adc1)); \ + tmp = tmp + (volt1);\ + if (tmp < 0)\ + tmp = 0;\ + \ + tmp;\ + }) + +struct sc27xx_adc_data { + struct device *dev; + struct regmap *regmap; + /* +* One hardware spinlock to synchronize between the multiple +*