S3C2443/S3C2416: Implement support for ADC
Subsystems (3)
v2 cover S3C2443/S3C2416: Implement support for ADC
The adc blocks of S3C2443 and S3C2416/2450 differ in some regards from previous (S3C2410, etc) and later (S3C64XX, S5P) SoCs.
Defining more TYPE_ADCVx types for these SoCs would complicate the necessary checks a lot. Therefore I opted for the use of quirk constants which can describe the features of the respective adc block and can be tested directly against.
This patch series replaces the type checks with checks for specific quirks and adds support for S3C2443 and S3C2416/2450 on top of this.
Each patch was compile tested, and I tried to only do "equivalent transforms" for the stuff on lower levels. But as I have only access to S3C2416 hardware, real life testing happened only there.
Changes since v1:
added a wrap for a line over 80 and moved the adc_setname call to the s3c24XX.c files where all the other names are set.
Heiko Stuebner (7):
S3C2443/S3C2416: Add adc registers
s3c-adc: describe features via quirk constants
s3c-adc: Replace TYPE_ADCVx conditionals with quirks
s3c-adc: Fix mux bit modification in s3c_adc_select
S3C24XX: Allow overriding of adc device name
s3c-adc: Add support for S3C2443
s3c-adc: Add support for S3C2416/S3C2450
arch/arm/mach-s3c2416/s3c2416.c | 3 + arch/arm/mach-s3c2443/s3c2443.c | 3 + arch/arm/plat-samsung/adc.c | 90 +++++++++++++++++++----- arch/arm/plat-samsung/include/plat/adc-core.h | 2 +- arch/arm/plat-samsung/include/plat/regs-adc.h | 3 + 5 files changed, 80 insertions(+), 20 deletions(-)
Signature · 1 line
1.7.2.3
PATCH v2 1/7 S3C2443/S3C2416: Add adc registers
The adc blocks of the S3C2443 and S3C2416 define some additional registers and bits.
--- arch/arm/plat-samsung/include/plat/regs-adc.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
arch/arm/plat-samsung/include/plat/regs-adc.h +3 -0
@@ -20,6 +20,7 @@#define S3C2410_ADCDAT0 S3C2410_ADCREG(0x0C)#define S3C2410_ADCDAT1 S3C2410_ADCREG(0x10)#define S3C64XX_ADCUPDN S3C2410_ADCREG(0x14) +#define S3C2443_ADCMUX S3C2410_ADCREG(0x18)#define S3C64XX_ADCCLRINT S3C2410_ADCREG(0x18)#define S5P_ADCMUX S3C2410_ADCREG(0x1C)#define S3C64XX_ADCCLRINTPNDNUP S3C2410_ADCREG(0x20)
@@ -33,6 +34,7 @@#define S3C2410_ADCCON_PRSCVLMASK (0xFF<<6)#define S3C2410_ADCCON_SELMUX (x) (((x)&0x7)<<3)#define S3C2410_ADCCON_MUXMASK (0x7<<3) +#define S3C2416_ADCCON_RESSEL (1<<3)#define S3C2410_ADCCON_STDBM (1<<2)#define S3C2410_ADCCON_READ_START (1<<1)#define S3C2410_ADCCON_ENABLE_START (1<<0)
@@ -40,6 +42,7 @@/* ADCTSC Register Bits */ +#define S3C2443_ADCTSC_UD_SEN (1<<8)#define S3C2410_ADCTSC_YM_SEN (1<<7)#define S3C2410_ADCTSC_YP_SEN (1<<6)#define S3C2410_ADCTSC_XM_SEN (1<<5)
Signature · 1 line
1.7.2.3
PATCH v2 1/2 S3C2443/S3C2416: Add adc registers
The adc blocks of the S3C2443 and S3C2416 define some additional registers and bits.
---
changes since v1: add spaces around <<
arch/arm/plat-samsung/include/plat/regs-adc.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
arch/arm/plat-samsung/include/plat/regs-adc.h +3 -0
@@ -20,6 +20,7 @@#define S3C2410_ADCDAT0 S3C2410_ADCREG(0x0C)#define S3C2410_ADCDAT1 S3C2410_ADCREG(0x10)#define S3C64XX_ADCUPDN S3C2410_ADCREG(0x14) +#define S3C2443_ADCMUX S3C2410_ADCREG(0x18)#define S3C64XX_ADCCLRINT S3C2410_ADCREG(0x18)#define S5P_ADCMUX S3C2410_ADCREG(0x1C)#define S3C64XX_ADCCLRINTPNDNUP S3C2410_ADCREG(0x20)
@@ -33,6 +34,7 @@#define S3C2410_ADCCON_PRSCVLMASK (0xFF<<6)#define S3C2410_ADCCON_SELMUX (x) (((x)&0x7)<<3)#define S3C2410_ADCCON_MUXMASK (0x7<<3) +#define S3C2416_ADCCON_RESSEL (1 << 3)#define S3C2410_ADCCON_STDBM (1<<2)#define S3C2410_ADCCON_READ_START (1<<1)#define S3C2410_ADCCON_ENABLE_START (1<<0)
@@ -40,6 +42,7 @@/* ADCTSC Register Bits */ +#define S3C2443_ADCTSC_UD_SEN (1 << 8)#define S3C2410_ADCTSC_YM_SEN (1<<7)#define S3C2410_ADCTSC_YP_SEN (1<<6)#define S3C2410_ADCTSC_XM_SEN (1<<5)
Signature · 1 line
1.7.5.4
PATCH v2 2/7 s3c-adc: describe features via quirk constants
In reply to Heiko StübnerThe adc blocks of S3C2410 through S5P have a multitude of quirks, i.e. moved bits or whole new registers.
This patch tries to describe these individual features through constants which can be used to describe an adc.
As SoCs sometimes share only some of these quirks defining TYPE_ADCVx values for each one wouldn't scale well when adding more variants.
--- arch/arm/plat-samsung/adc.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)
arch/arm/plat-samsung/adc.c +29 -0
@@ -45,6 +45,35 @@ enum s3c_cpu_type { TYPE_ADCV3, /* S5PV210, S5PC110, EXYNOS4210 */ }; +/* +* Resolution of the ADC - 10 or 12 bit +*/ +#define S3C_ADC_QUIRK_10BIT 0 +#define S3C_ADC_QUIRK_12BIT (1<<0) + +/* +* 12bit ADC can switch resolution between 10 bit and 12 bit +* ADCCON bit 03 for S3C2416 +* ADCCON bit 16 for S3C64XX and up +*/ +#define S3C_ADC_QUIRK_RESSEL03 (1<<1) +#define S3C_ADC_QUIRK_RESSEL16 (1<<2) + +/* +* Input channel select can either be in +* - reg ADCCON, bit for S3C24XX and S3C64XX +* - reg base+0x18 for 2443/2416/2450 +* - reg base+0x1C for S5P +*/ +#define S3C_ADC_QUIRK_MUXADCCON (1<<3) +#define S3C_ADC_QUIRK_MUX18 (1<<4) +#define S3C_ADC_QUIRK_MUX1C (1<<5) + +/* +* CLRINT register on S3C64xx +*/ +#define S3C_ADC_QUIRK_CLRINT (1<<6) +struct s3c_adc_client {struct platform_device *pdev;struct list_head pend;
Signature · 1 line
1.7.2.3
PATCH 2/7 s3c-adc: describe features via quirk constants
Quoted 11 lines · Heiko St?bner
The adc blocks of S3C2410 through S5P have a multitude of quirks, i.e. moved bits or whole new registers.
This patch tries to describe these individual features through constants which can be used to describe an adc.
As SoCs sometimes share only some of these quirks defining
TYPE_ADCVxvalues for each one wouldn't scale well when adding more variants.
Hi Heiko,
I don't have idea we really need to use QUIRK in this case...as I know, the QUIRK is used on other situation...
In addition, the TYPE_ADCVx can support each Samsung SoCs' ADC...but I need to check again.
Quoted 10 lines
Signed-off-by Heiko Stuebner <[email protected]>--- arch/arm/plat-samsung/adc.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)arch/arm/plat-samsung/adc.c +0
-0
arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 50
Quoted 6 lines
arch/arm/plat-samsung/adc.c +3
-0@@ -45,6 +45,35 @@ enum s3c_cpu_type { TYPE_ADCV3, /* S5PV210, S5PC110, EXYNOS4210 */ }; +/* +* Resolution of the ADC - 10 or 12 bit +*/
/* ... */
arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 52
Quoted 2 lines
arch/arm/plat-samsung/adc.c +2
-0+#define S3C_ADC_QUIRK_10BIT 0 +#define S3C_ADC_QUIRK_12BIT (1<<0)
According to coding style, should be added blank around <<.
arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 60
Quoted 8 lines
arch/arm/plat-samsung/adc.c +8
-0+ +/* +* 12bit ADC can switch resolution between 10 bit and 12 bit +* ADCCON bit 03 for S3C2416 +* ADCCON bit 16 for S3C64XX and up +*/ +#define S3C_ADC_QUIRK_RESSEL03 (1<<1) +#define S3C_ADC_QUIRK_RESSEL16 (1<<2)
Same as above.
arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 70
Quoted 10 lines
arch/arm/plat-samsung/adc.c +10
-0+ +/* +* Input channel select can either be in +* - reg ADCCON, bit for S3C24XX and S3C64XX +* - reg base+0x18 for 2443/2416/2450 +* - reg base+0x1C for S5P +*/ +#define S3C_ADC_QUIRK_MUXADCCON (1<<3) +#define S3C_ADC_QUIRK_MUX18 (1<<4) +#define S3C_ADC_QUIRK_MUX1C (1<<5)
Same.
arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 74
Quoted 4 lines
arch/arm/plat-samsung/adc.c +4
-0+ +/* +* CLRINT register on S3C64xx +*/
/* ... */
arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 75
Quoted 1 line
arch/arm/plat-samsung/adc.c +1
-0+#define S3C_ADC_QUIRK_CLRINT (1<<6)
Same.
Quoted 6 lines
arch/arm/plat-samsung/adc.c +1
-1+struct s3c_adc_client {struct platform_device *pdev;struct list_head pend; --1.7.2.3
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
PATCH v2 2/7 s3c-adc: describe features via quirk constants
Hi,
Am Mittwoch, 21. September 2011, 14:32:14 schrieben Sie:
Quoted 11 lines
Quoted 9 lines · Heiko St?bner
The adc blocks of S3C2410 through S5P have a multitude of quirks, i.e. moved bits or whole new registers.
This patch tries to describe these individual features through constants which can be used to describe an adc.
As SoCs sometimes share only some of these quirks defining
TYPE_ADCVxvalues for each one wouldn't scale well when adding more variants.
Quoted 7 lines
Hi Heiko,
I don't have idea we really need to use QUIRK in this case...as I know, the QUIRK is used on other situation...
In addition, the
TYPE_ADCVxcan support each Samsung SoCs' ADC...but I need to check again.
The current types could not support the features of the 2443 and 2416/2450 - I checked the datasheets.
The mux register in base+0x18 does not exist on any of the current platforms. Also the bit 3 in ADCCON to select the resolution is specific to the 2416/2450 (see comments above constants and quirk definitions in patches 6 and 7).
So to support these SoCs would require the definition of two new types. Including these new types in the existing conditionals would introduce a lot of statements like
if ( (TYPE_X || TYPE_Y) && !TYPE_Z)
In my opinion testing for specific features also describes the difference between implementations better if one reads the code later on.
I will change the styling of the "<<"s but am wondering why checkpatch did not complain, i.e. it complains for all other whitespace mistakes one can make but not these.
Heiko
Quoted 80 lines
Quoted 12 lines
Signed-off-by Heiko Stuebner <[email protected]>---
arch/arm/plat-samsung/adc.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)arch/arm/plat-samsung/adc.c +0
-0arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 52
Quoted 8 lines
arch/arm/plat-samsung/adc.c +3
-0@@ -45,6 +45,35 @@ enum s3c_cpu_type { TYPE_ADCV3, /* S5PV210, S5PC110, EXYNOS4210 */ }; +/* +* Resolution of the ADC - 10 or 12 bit +*/ /* ... */
arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 52
Quoted 2 lines
arch/arm/plat-samsung/adc.c +2
-0+#define S3C_ADC_QUIRK_10BIT 0 +#define S3C_ADC_QUIRK_12BIT (1<<0)According to coding style, should be added blank around <<.
arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 60
Quoted 8 lines
arch/arm/plat-samsung/adc.c +8
-0+ +/* +* 12bit ADC can switch resolution between 10 bit and 12 bit +* ADCCON bit 03 for S3C2416 +* ADCCON bit 16 for S3C64XX and up +*/ +#define S3C_ADC_QUIRK_RESSEL03 (1<<1) +#define S3C_ADC_QUIRK_RESSEL16 (1<<2)Same as above.
arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 70
Quoted 10 lines
arch/arm/plat-samsung/adc.c +10
-0+ +/* +* Input channel select can either be in +* - reg ADCCON, bit for S3C24XX and S3C64XX +* - reg base+0x18 for 2443/2416/2450 +* - reg base+0x1C for S5P +*/ +#define S3C_ADC_QUIRK_MUXADCCON (1<<3) +#define S3C_ADC_QUIRK_MUX18 (1<<4) +#define S3C_ADC_QUIRK_MUX1C (1<<5)Same.
arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 74
Quoted 4 lines
arch/arm/plat-samsung/adc.c +4
-0+ +/* +* CLRINT register on S3C64xx +*/ /* ... */
arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 75
Quoted 1 line
arch/arm/plat-samsung/adc.c +1
-0+#define S3C_ADC_QUIRK_CLRINT (1<<6)Same.
Quoted 9 lines
arch/arm/plat-samsung/adc.c +1
-0+struct
s3c_adc_client{arch/arm/plat-samsung/adc.c +0
-1struct platform_device *pdev;struct list_head pend; --1.7.2.3
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
PATCH 2/7 s3c-adc: describe features via quirk constants
Quoted 18 lines · Heiko St?bner
Hi,
Am Mittwoch, 21. September 2011, 14:32:14 schrieben Sie:
Quoted 14 lines
Quoted 9 lines · Heiko St?bner
The adc blocks of S3C2410 through S5P have a multitude of quirks, i.e. moved bits or whole new registers.
This patch tries to describe these individual features through constants which can be used to describe an adc.
As SoCs sometimes share only some of these quirks defining
TYPE_ADCVxvalues for each one wouldn't scale well when adding more variants.Hi Heiko,
I don't have idea we really need to use QUIRK in this case...as I know,
the
Quoted 6 lines
Quoted 3 lines
QUIRK is used on other situation...
In addition, the
TYPE_ADCVxcan support each Samsung SoCs' ADC...but Ineed
Quoted 1 line
to check again.
The current types could not support the features of the 2443 and 2416/2450
- I
Quoted 3 lines
checked the datasheets.
The mux register in
base+0x18does not exist on any of the current
platforms.
Quoted 1 line
Also the bit 3 in ADCCON to select the resolution is specific to the
2416/2450
Quoted 4 lines
(see comments above constants and quirk definitions in patches 6 and 7).
So to support these SoCs would require the definition of two new types. Including these new types in the existing conditionals would introduce a
lot
Quoted 8 lines
of statements like
if ( (TYPE_X || TYPE_Y) && !TYPE_Z)In my opinion testing for specific features also describes the difference between implementations better if one reads the code later on.
I will change the styling of the "<<"s but am wondering why checkpatch did
not
Quoted 1 line
complain, i.e. it complains for all other whitespace mistakes one can make
but
Quoted 2 lines
not these.
Hi Heiko,
How about following? I think following is also not bad...
arch/arm/plat-samsung/adc.c +2 -0
@@ -41,6 +41,8 @@enum s3c_cpu_type {TYPE_ADCV1 ,/* S3C24XX */ +TYPE_ADCV11 ,/* S3C2416 */ +TYPE_ADCV12 ,/* S3C2443 */ TYPE_ADCV2 ,/* S3C64XX, S5P64X0, S5PC100 */ TYPE_ADCV3 ,/* S5PV210, S5PC110, EXYNOS4210 */ };
@@ -98,13 +100,17 @@ static inline void s3c_adc_select(struct adc_device
*adc,
client->select_cb(client, 1);
- con &= ~S3C2410_ADCCON_MUXMASK;
+ if (cpu == TYPE_ADCV1 || cpu == TYPE_ADCV2)
+ con &= ~S3C2410_ADCCON_MUXMASK;
con &= ~S3C2410_ADCCON_STDBM;
con &= ~S3C2410_ADCCON_STARTMASK;
if (!client->is_ts) {
if (cpu == TYPE_ADCV3)
writel(client->channel & 0xf, adc->regs +S5P_ADCMUX);
+ elif (cpu == TYPE_ADCV12)
+ writel(client->channel & 0xf,
+ adc->regs + S3C2443_ADCMUX);
else
con |= S3C2410_ADCCON_SELMUX(client->channel);
}
@@ -293,13 +299,13 @@ static irqreturn_t s3c_adc_irq(int irq, void *pw)
client->nr_samples--;
- if (cpu != TYPE_ADCV1) {
- /* S3C64XX/S5P ADC resolution is 12-bit */
- data0 &= 0xfff;
- data1 &= 0xfff;
- } else {
+ if (cpu == TYPE_ADCV1 || cpu == TYPE_ADCV12) {
data0 &= 0x3ff;
data1 &= 0x3ff;
+ } else {
+ /* S3C2416, S3C64XX/S5P ADC resolution is 12-bit */
+ data0 &= 0xfff;
+ data1 &= 0xfff;
}
if (client->convert_cb)
@@ -320,7 +326,7 @@ static irqreturn_t s3c_adc_irq(int irq, void *pw)
}
exit:
- if (cpu != TYPE_ADCV1) {
+ if (cpu == TYPE_ADCV2 || cpu == TYPE_ADCV3) {
/* Clear ADC interrupt */
writel(0, adc->regs + S3C64XX_ADCCLRINT);
}
@@ -332,6 +338,7 @@ static int s3c_adc_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct adc_device *adc;
struct resource *regs;
+ enum s3c_cpu_type cpu = platform_get_device_id(pdev)->driver_data;
int ret;
unsigned tmp;
@@ -394,10 +401,13 @@ static int s3c_adc_probe(struct platform_device *pdev)
clk_enable(adc->clk);
tmp = adc->prescale | S3C2410_ADCCON_PRSCEN;
- if (platform_get_device_id(pdev)->driver_data != TYPE_ADCV1) {
- /* Enable 12-bit ADC resolution */
+
+ /* Enable 12-bit ADC resolution */
+ if (cpu == TYPE_ADCV11)
+ tmp |= S3C2416_ADCCON_RESSEL;
+ if (cpu == TYPE_ADCV2 || cpu == TYPE_ADCV3)
tmp |= S3C64XX_ADCCON_RESSEL;
- }
+
writel(tmp, adc->regs + S3C2410_ADCCON);
dev_info(dev, "attached adc driver\n");
@@ -464,6 +474,7 @@ static int s3c_adc_resume(struct device *dev)
struct platform_device *pdev = container_of(dev,
struct platform_device, dev);
struct adc_device *adc = platform_get_drvdata(pdev);
+ enum s3c_cpu_type cpu = platform_get_device_id(pdev)->driver_data;
int ret;
unsigned long tmp;
@@ -474,9 +485,13 @@ static int s3c_adc_resume(struct device *dev)
enable_irq(adc->irq);
tmp = adc->prescale | S3C2410_ADCCON_PRSCEN;
+
/* Enable 12-bit ADC resolution */
- if (platform_get_device_id(pdev)->driver_data != TYPE_ADCV1)
+ if (cpu == TYPE_ADCV11)
+ tmp |= S3C2416_ADCCON_RESSEL;
+ if (cpu == TYPE_ADCV2 || cpu == TYPE_ADCV3)
tmp |= S3C64XX_ADCCON_RESSEL;
+
writel(tmp, adc->regs + S3C2410_ADCCON);
return 0;
@@ -492,6 +507,12 @@ static struct platform_device_id s3c_adc_driver_ids[] = {
.name = "s3c24xx-adc",
.driver_data = TYPE_ADCV1,
}, {
+ .name = "s3c2416-adc",
+ .driver_data = TYPE_ADCV11
+ }, {
+ .name = "s3c2443-adc",
+ .driver_data = TYPE_ADCV12
+ }, {
.name = "s3c64xx-adc",
.driver_data = TYPE_ADCV2,
}, {
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
Quoted 82 lines
Heiko
Quoted 80 lines
Quoted 12 lines
Signed-off-by Heiko Stuebner <[email protected]>---
arch/arm/plat-samsung/adc.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)arch/arm/plat-samsung/adc.c +0
-0arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 52
Quoted 8 lines
arch/arm/plat-samsung/adc.c +3
-0@@ -45,6 +45,35 @@ enum s3c_cpu_type { TYPE_ADCV3, /* S5PV210, S5PC110, EXYNOS4210 */ }; +/* +* Resolution of the ADC - 10 or 12 bit +*/ /* ... */
arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 54
Quoted 2 lines
arch/arm/plat-samsung/adc.c +2
-0+#define S3C_ADC_QUIRK_10BIT 0 +#define S3C_ADC_QUIRK_12BIT (1<<0)According to coding style, should be added blank around <<.
arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 62
Quoted 8 lines
arch/arm/plat-samsung/adc.c +8
-0+ +/* +* 12bit ADC can switch resolution between 10 bit and 12 bit +* ADCCON bit 03 for S3C2416 +* ADCCON bit 16 for S3C64XX and up +*/ +#define S3C_ADC_QUIRK_RESSEL03 (1<<1) +#define S3C_ADC_QUIRK_RESSEL16 (1<<2)Same as above.
arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 72
Quoted 10 lines
arch/arm/plat-samsung/adc.c +10
-0+ +/* +* Input channel select can either be in +* - reg ADCCON, bit for S3C24XX and S3C64XX +* - reg base+0x18 for 2443/2416/2450 +* - reg base+0x1C for S5P +*/ +#define S3C_ADC_QUIRK_MUXADCCON (1<<3) +#define S3C_ADC_QUIRK_MUX18 (1<<4) +#define S3C_ADC_QUIRK_MUX1C (1<<5)Same.
arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 76
Quoted 4 lines
arch/arm/plat-samsung/adc.c +4
-0+ +/* +* CLRINT register on S3C64xx +*/ /* ... */
arch/arm/plat-samsung/adc.c enum s3c_cpu_type { · line 77
Quoted 1 line
arch/arm/plat-samsung/adc.c +1
-0+#define S3C_ADC_QUIRK_CLRINT (1<<6)Same.
Quoted 9 lines
arch/arm/plat-samsung/adc.c +1
-0+struct
s3c_adc_client{arch/arm/plat-samsung/adc.c +0
-1struct platform_device *pdev;struct list_head pend; --1.7.2.3
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
PATCH v2 2/7 s3c-adc: describe features via quirk constants
Hi Kgene,
Am Sonntag 02 Oktober 2011, 09:38:18 schrieb Kukjin Kim:
Quoted 1 line
How about following? I think following is also not bad...
ok, I don't claim to have the right solution, so if keeping the TYPE_xxx enum is better, I will do a rework of the series according to your solution and resend it.
Could I meanwhile interest you in the patches for the S3C2416 armclk and hsmmc (from 28 Sep 2011) :-) ?
Thanks
Heiko
Quoted 129 lines
arch/arm/plat-samsung/adc.c +7
-1@@ -41,6 +41,8 @@enum s3c_cpu_type {TYPE_ADCV1 ,/* S3C24XX */ +TYPE_ADCV11 ,/* S3C2416 */ +TYPE_ADCV12 ,/* S3C2443 */ TYPE_ADCV2 ,/* S3C64XX, S5P64X0, S5PC100 */ TYPE_ADCV3 ,/* S5PV210, S5PC110, EXYNOS4210 */ };@@ -98,13 +100,17 @@ static inline void s3c_adc_select(struct adc_device *adc, client->select_cb (client,1 ); - con &= ~S3C2410_ADCCON_MUXMASK ; +if (cpu ==TYPE_ADCV1 || cpu ==TYPE_ADCV2 ) + con &= ~S3C2410_ADCCON_MUXMASK ; con &= ~S3C2410_ADCCON_STDBM ; con &= ~S3C2410_ADCCON_STARTMASK ;if (!client->is_ts) {if (cpu ==TYPE_ADCV3 )writel (client->channel &0xf , adc->regs +S5P_ADCMUX ); + elif (cpu == TYPE_ADCV12) +writel (client->channel &0xf , + adc->regs +S3C2443_ADCMUX ); elsearch/arm/plat-samsung/adc.c +25
-10con |=S3C2410_ADCCON_SELMUX (client->channel); }@@ -293,13 +299,13 @@ static irqreturn_t s3c_adc_irq(int irq, void *pw) client->nr_samples--; -if (cpu !=TYPE_ADCV1 ) { -/* S3C64XX/S5P ADC resolution is 12-bit */ - data0 &=0xfff ; - data1 &=0xfff ; - }else { +if (cpu ==TYPE_ADCV1 || cpu ==TYPE_ADCV12 ) { data0 &=0x3ff ; data1 &=0x3ff ; + }else { +/* S3C2416, S3C64XX/S5P ADC resolution is 12-bit */ + data0 &=0xfff ; + data1 &=0xfff ; }if (client->convert_cb)@@ -320,7 +326,7 @@ static irqreturn_t s3c_adc_irq(int irq, void *pw) } exit: -if (cpu !=TYPE_ADCV1 ) { +if (cpu ==TYPE_ADCV2 || cpu ==TYPE_ADCV3 ) {/* Clear ADC interrupt */ writel (0 , adc->regs +S3C64XX_ADCCLRINT ); }@@ -332,6 +338,7 @@ static int s3c_adc_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct adc_device *adc;struct resource *regs; +enum s3c_cpu_type cpu =platform_get_device_id (pdev)->driver_data;int ret;unsigned tmp;@@ -394,10 +401,13 @@ static int s3c_adc_probe(struct platform_device *pdev) clk_enable(adc->clk); tmp = adc->prescale |S3C2410_ADCCON_PRSCEN ; -if (platform_get_device_id (pdev)->driver_data !=TYPE_ADCV1 ) { -/* Enable 12-bit ADC resolution */ + +/* Enable 12-bit ADC resolution */ +if (cpu ==TYPE_ADCV11 ) + tmp |=S3C2416_ADCCON_RESSEL ; +if (cpu ==TYPE_ADCV2 || cpu ==TYPE_ADCV3 ) tmp |=S3C64XX_ADCCON_RESSEL ; - } +writel (tmp, adc->regs +S3C2410_ADCCON );dev_info (dev,"attached adc driver\n" );@@ -464,6 +474,7 @@ static int s3c_adc_resume(struct device *dev)struct platform_device *pdev =container_of (dev, struct platform_device, dev);struct adc_device *adc =platform_get_drvdata (pdev); +enum s3c_cpu_type cpu =platform_get_device_id (pdev)->driver_data;int ret;unsigned long tmp;@@ -474,9 +485,13 @@ static int s3c_adc_resume(struct device *dev)enable_irq (adc->irq); tmp = adc->prescale |S3C2410_ADCCON_PRSCEN ; +/* Enable 12-bit ADC resolution */ -if (platform_get_device_id (pdev)->driver_data !=TYPE_ADCV1 ) +if (cpu ==TYPE_ADCV11 ) + tmp |=S3C2416_ADCCON_RESSEL ; +if (cpu ==TYPE_ADCV2 || cpu ==TYPE_ADCV3 ) tmp |=S3C64XX_ADCCON_RESSEL ; +writel (tmp, adc->regs +S3C2410_ADCCON );return 0 ;@@ -492,6 +507,12 @@ static struct platform_device_id s3c_adc_driver_ids[] = { .name = "s3c24xx-adc", .driver_data = TYPE_ADCV1, }, { + .name = "s3c2416-adc", + .driver_data =TYPE_ADCV11 + }, { + .name = "s3c2443-adc", + .driver_data =TYPE_ADCV12 + }, { .name = "s3c64xx-adc", .driver_data = TYPE_ADCV2,}, {
Thanks.
Best regards,
Kgene.
PATCH 2/7 s3c-adc: describe features via quirk constants
Quoted 6 lines · Heiko St?bner
Hi Kgene,
Am Sonntag 02 Oktober 2011, 09:38:18 schrieb Kukjin Kim:
Quoted 1 line
How about following? I think following is also not bad...
ok, I don't claim to have the right solution, so if keeping the
TYPE_xxx
enum
Quoted 3 lines
is better, I will do a rework of the series according to your solution and resend it.
Thanks for your understanding and please re-send it :)
Quoted 1 line
Could I meanwhile interest you in the patches for the S3C2416 armclk and
hsmmc
Quoted 2 lines
(from 28 Sep 2011) :-) ?
Sure, will check it soon, maybe tomorrow?
Anyway, if any problems, let you know.
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
PATCH 2/7 s3c-adc: describe features via quirk constants
In reply to Heiko StübnerQuoted 8 lines · Kukjin Kim
Quoted 6 lines · Heiko St?bner
Hi Kgene,
Am Sonntag 02 Oktober 2011, 09:38:18 schrieb Kukjin Kim:
Quoted 1 line
How about following? I think following is also not bad...
ok, I don't claim to have the right solution, so if keeping the
TYPE_xxx
enum
Quoted 1 line
Quoted 1 line
is better, I will do a rework of the series according to your solution
and
Quoted 4 lines
Quoted 2 lines
resend it.
Thanks for your understanding and please re-send it :)
Any re-sending?
Quoted 6 lines
Quoted 1 line
Could I meanwhile interest you in the patches for the S3C2416 armclk and
hsmmc
Quoted 2 lines
(from 28 Sep 2011) :-) ?
Sure, will check it soon, maybe tomorrow?
Anyway, if any problems, let you know.
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
PATCH v2 2/7 s3c-adc: describe features via quirk constants
Hi Kgene,
Am Montag, 10. Oktober 2011, 06:28:19 schrieb Kukjin Kim:
Quoted 14 lines
Quoted 8 lines · Kukjin Kim
Quoted 7 lines · Heiko St?bner
Hi Kgene,
Am Sonntag 02 Oktober 2011, 09:38:18 schrieb Kukjin Kim:
Quoted 1 line
How about following? I think following is also not bad...
ok, I don't claim to have the right solution, so if keeping the
TYPE_xxxenum
Quoted 1 line
Quoted 1 line
is better, I will do a rework of the series according to your solution
Quoted 7 lines
and
Quoted 3 lines
Quoted 1 line
resend it.
Thanks for your understanding and please re-send it :)
Any re-sending?
as I'm this in my spare time I'm not sure I will make your "deadline" for the merge-window, but will try to get it sorted today or tomorrow.
Meanwhile please take a look at the armclk series and the hsmmc devname patch.
Heiko
PATCH 2/7 s3c-adc: describe features via quirk constants
Quoted 3 lines · Heiko St?bner
Hi Kgene,
Hi,
(snip)
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
Thanks for your understanding and please re-send it :)
Any re-sending?
as I'm this in my spare time I'm not sure I will make your "deadline" for
the
Quoted 2 lines
merge-window, but will try to get it sorted today or tomorrow.
OK. I cannot promise now but I think you can do it for upcoming merge window :)
Quoted 1 line
Meanwhile please take a look at the armclk series and the hsmmc devname
patch.
Quoted 1 line
OK, sorry still missing.
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
PATCH v2 2/2 s3c-adc: describe features via quirk constants
In reply to Kukjin KimThe adc blocks of S3C2410 through S5P have a multitude of quirks, i.e. moved bits or whole new registers.
This patch tries to describe these individual features through constants which can be used to describe an adc.
As SoCs sometimes share only some of these quirks defining TYPE_ADCVx values for each one wouldn't scale well when adding more variants.
---
changes since v1: add spaces around <<
arch/arm/plat-samsung/adc.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)
arch/arm/plat-samsung/adc.c +29 -0
@@ -45,6 +45,35 @@ enum s3c_cpu_type { TYPE_ADCV3, /* S5PV210, S5PC110, EXYNOS4210 */ }; +/* +* Resolution of the ADC - 10 or 12 bit +*/ +#define S3C_ADC_QUIRK_10BIT 0 +#define S3C_ADC_QUIRK_12BIT (1 << 0) + +/* +* 12bit ADC can switch resolution between 10 bit and 12 bit +* ADCCON bit 03 for S3C2416 +* ADCCON bit 16 for S3C64XX and up +*/ +#define S3C_ADC_QUIRK_RESSEL03 (1 << 1) +#define S3C_ADC_QUIRK_RESSEL16 (1 << 2) + +/* +* Input channel select can either be in +* - reg ADCCON, bit for S3C24XX and S3C64XX +* - reg base+0x18 for 2443/2416/2450 +* - reg base+0x1C for S5P +*/ +#define S3C_ADC_QUIRK_MUXADCCON (1 << 3) +#define S3C_ADC_QUIRK_MUX18 (1 << 4) +#define S3C_ADC_QUIRK_MUX1C (1 << 5) + +/* +* CLRINT register on S3C64xx +*/ +#define S3C_ADC_QUIRK_CLRINT (1 << 6) +struct s3c_adc_client {struct platform_device *pdev;struct list_head pend;
Signature · 1 line
1.7.5.4
PATCH v2 3/7 s3c-adc: Replace TYPE_ADCVx conditionals with quirks
In reply to Heiko StübnerThis patch replaces the static TYPE_ADCVs checks with checks for specific features of an adc block. For this the s3c_cpu_type enum in driver_data ist int containing containing the bit values describing the indivial adc block.
This patch contains no functional changes, it merely replaces the type checks with checks for indidual quirks.
--- arch/arm/plat-samsung/adc.c | 33 +++++++++++++++++---------------- 1 files changed, 17 insertions(+), 16 deletions(-)
arch/arm/plat-samsung/adc.c +17 -16
@@ -39,12 +39,6 @@* action is required. */ -enum s3c_cpu_type { -TYPE_ADCV1 ,/* S3C24XX */ -TYPE_ADCV2 ,/* S3C64XX, S5P64X0, S5PC100 */ -TYPE_ADCV3 ,/* S5PV210, S5PC110, EXYNOS4210 */ -}; -/* * Resolution of the ADC - 10 or 12 bit */
@@ -123,7 +117,7 @@ static inline void s3c_adc_select(struct adc_device *adc, struct s3c_adc_client *client) {unsigned con =readl (adc->regs +S3C2410_ADCCON ); -enum s3c_cpu_type cpu =platform_get_device_id (adc->pdev)->driver_data; +int cpu =platform_get_device_id (adc->pdev)->driver_data; client->select_cb (client,1 );
@@ -132,7 +126,7 @@ static inline void s3c_adc_select(struct adc_device *adc, con &= ~S3C2410_ADCCON_STARTMASK ;if (!client->is_ts) { -if (cpu ==TYPE_ADCV3 ) +if (cpu &S3C_ADC_QUIRK_MUX1C )writel (client->channel &0xf , adc->regs +S5P_ADCMUX );else con |=S3C2410_ADCCON_SELMUX (client->channel);
@@ -308,7 +302,7 @@ static irqreturn_t s3c_adc_irq(int irq, void *pw) {struct adc_device *adc = pw;struct s3c_adc_client *client = adc->cur; -enum s3c_cpu_type cpu =platform_get_device_id (adc->pdev)->driver_data; +int cpu =platform_get_device_id (adc->pdev)->driver_data;unsigned data0, data1;if (!client) {
@@ -322,7 +316,7 @@ static irqreturn_t s3c_adc_irq(int irq, void *pw) client->nr_samples--; -if (cpu !=TYPE_ADCV1 ) { +if (cpu &S3C_ADC_QUIRK_12BIT ) {/* S3C64XX/S5P ADC resolution is 12-bit */ data0 &=0xfff ; data1 &=0xfff ;
@@ -349,7 +343,7 @@ static irqreturn_t s3c_adc_irq(int irq, void *pw) } exit: -if (cpu !=TYPE_ADCV1 ) { +if (cpu &S3C_ADC_QUIRK_CLRINT ) {/* Clear ADC interrupt */ writel (0 , adc->regs +S3C64XX_ADCCLRINT ); }
@@ -423,7 +417,7 @@ static int s3c_adc_probe(struct platform_device *pdev)clk_enable (adc->clk); tmp = adc->prescale |S3C2410_ADCCON_PRSCEN ; -if (platform_get_device_id (pdev)->driver_data !=TYPE_ADCV1 ) { +if (platform_get_device_id (pdev)->driver_data &S3C_ADC_QUIRK_12BIT ) {/* Enable 12-bit ADC resolution */ tmp |=S3C64XX_ADCCON_RESSEL ; }
@@ -504,7 +498,7 @@ static int s3c_adc_resume(struct device *dev) tmp = adc->prescale |S3C2410_ADCCON_PRSCEN ;/* Enable 12-bit ADC resolution */ -if (platform_get_device_id (pdev)->driver_data !=TYPE_ADCV1 ) +if (platform_get_device_id (pdev)->driver_data &S3C_ADC_QUIRK_12BIT ) tmp |=S3C64XX_ADCCON_RESSEL ;writel (tmp, adc->regs +S3C2410_ADCCON );
@@ -519,13 +513,20 @@ static int s3c_adc_resume(struct device *dev)static struct platform_device_id s3c_adc_driver_ids[] = { { .name ="s3c24xx-adc" , - .driver_data =TYPE_ADCV1 , + .driver_data =S3C_ADC_QUIRK_10BIT | +S3C_ADC_QUIRK_MUXADCCON , }, { .name ="s3c64xx-adc" , - .driver_data =TYPE_ADCV2 , + .driver_data =S3C_ADC_QUIRK_12BIT | +S3C_ADC_QUIRK_MUXADCCON | +S3C_ADC_QUIRK_RESSEL16 | +S3C_ADC_QUIRK_CLRINT , }, { .name ="samsung-adc-v3" , - .driver_data =TYPE_ADCV3 , + .driver_data =S3C_ADC_QUIRK_12BIT | +S3C_ADC_QUIRK_MUX1C | +S3C_ADC_QUIRK_RESSEL16 | +S3C_ADC_QUIRK_CLRINT , }, { } };
Signature · 1 line
1.7.2.3
PATCH v2 4/7 s3c-adc: Fix mux bit modification in s3c_adc_select
In reply to Heiko StübnerThe mux bits in the adccon register should be cleared only if muxing is really done in ADCCON and not another register.
This patch introduces a conditional for this.
--- arch/arm/plat-samsung/adc.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
arch/arm/plat-samsung/adc.c +2 -1
@@ -121,7 +121,8 @@ static inline void s3c_adc_select(struct adc_device *adc, client->select_cb (client,1 ); - con &= ~S3C2410_ADCCON_MUXMASK ; +if (cpu &S3C_ADC_QUIRK_MUXADCCON ) + con &= ~S3C2410_ADCCON_MUXMASK ; con &= ~S3C2410_ADCCON_STDBM ; con &= ~S3C2410_ADCCON_STARTMASK ;
Signature · 1 line
1.7.2.3
PATCH v2 5/7 S3C24XX: Allow overriding of adc device name
In reply to Heiko StübnerThe adc blocks of S3C2443 and S3C2416 contain quirks not present in the stock S3C24xx adc. Therefore allow them to alter the device name via s3c_adc_setname.
--- arch/arm/plat-samsung/include/plat/adc-core.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/plat-samsung/include/plat/adc-core.h +1 -1
@@ -20,7 +20,7 @@/* re-define device name depending on support. */ static inline void s3c_adc_setname (char *name) { -#ifdef CONFIG_SAMSUNG_DEV_ADC +#if defined(CONFIG_SAMSUNG_DEV_ADC ) || defined(CONFIG_PLAT_S3C24XX ) s3c_device_adc.name = name;#endif }
Signature · 1 line
1.7.2.3
PATCH v2 6/7 s3c-adc: Add support for S3C2443
In reply to Heiko StübnerThe S3C2443-adc is 10 bit wide and has its mux-select in an extra register at base+0x18
---
changes since v1:
wrap line over 80 chars and move setname call
arch/arm/mach-s3c2443/s3c2443.c | 3 +++ arch/arm/plat-samsung/adc.c | 7 +++++++ 2 files changed, 10 insertions(+), 0 deletions(-)
arch/arm/mach-s3c2443/s3c2443.c +3 -0
@@ -41,6 +41,7 @@#include <plat/cpu.h> #include <plat/fb-core.h> #include <plat/nand-core.h> +#include <plat/adc-core.h> static struct map_desc s3c2443_iodesc[]__initdata = {IODESC_ENT (WATCHDOG ),
@@ -70,6 +71,8 @@ int __init s3c2443_init(void)s3c_nand_setname ("s3c2412-nand" );s3c_fb_setname ("s3c2443-fb" ); +s3c_adc_setname ("s3c2443-adc" ); +/* change WDT IRQ number */ s3c_device_wdt.resource[1 ].start =IRQ_S3C2443_WDT ; s3c_device_wdt.resource[1 ].end =IRQ_S3C2443_WDT ;
arch/arm/plat-samsung/adc.c +7 -0
@@ -129,6 +129,9 @@ static inline void s3c_adc_select(struct adc_device *adc,if (!client->is_ts) {if (cpu &S3C_ADC_QUIRK_MUX1C )writel (client->channel &0xf , adc->regs +S5P_ADCMUX ); +else if (cpu &S3C_ADC_QUIRK_MUX18 ) +writel (client->channel &0xf , + adc->regs +S3C2443_ADCMUX );else con |=S3C2410_ADCCON_SELMUX (client->channel); }
@@ -517,6 +520,10 @@ static struct platform_device_id s3c_adc_driver_ids[] = { .driver_data = S3C_ADC_QUIRK_10BIT | S3C_ADC_QUIRK_MUXADCCON, }, { + .name = "s3c2443-adc", + .driver_data = S3C_ADC_QUIRK_10BIT | + S3C_ADC_QUIRK_MUX18, + }, { .name = "s3c64xx-adc", .driver_data =S3C_ADC_QUIRK_12BIT | S3C_ADC_QUIRK_MUXADCCON |
Signature · 1 line
1.7.2.3
PATCH v2 7/7 s3c-adc: Add support for S3C2416/S3C2450
In reply to Heiko StübnerThe ADC of the S3C2416/2450 SoC is 10 or 12 bit wide, has its source selection in the register base+0x18 and its width selection in bit 03 of the ADCCON register.
---
changes since v1:
move setname call
arch/arm/mach-s3c2416/s3c2416.c | 3 +++ arch/arm/plat-samsung/adc.c | 24 +++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-)
arch/arm/mach-s3c2416/s3c2416.c +3 -0
@@ -60,6 +60,7 @@#include <plat/iic-core.h> #include <plat/fb-core.h> #include <plat/nand-core.h> +#include <plat/adc-core.h> static struct map_desc s3c2416_iodesc[]__initdata = {IODESC_ENT (WATCHDOG ),
@@ -97,6 +98,8 @@ int __init s3c2416_init(void)s3c_fb_setname ("s3c2443-fb" ); +s3c_adc_setname ("s3c2416-adc" ); +register_syscore_ops (&s3c2416_pm_syscore_ops);register_syscore_ops (&s3c24xx_irq_syscore_ops);
arch/arm/plat-samsung/adc.c +19 -5
@@ -358,6 +358,7 @@ static int s3c_adc_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct adc_device *adc; +int cpu =platform_get_device_id (pdev)->driver_data;struct resource *regs;int ret;unsigned tmp;
@@ -421,9 +422,12 @@ static int s3c_adc_probe(struct platform_device *pdev)clk_enable (adc->clk); tmp = adc->prescale |S3C2410_ADCCON_PRSCEN ; -if (platform_get_device_id (pdev)->driver_data &S3C_ADC_QUIRK_12BIT ) { -/* Enable 12-bit ADC resolution */ - tmp |=S3C64XX_ADCCON_RESSEL ; +/* Enable 12-bit ADC resolution */ +if (cpu &S3C_ADC_QUIRK_12BIT ) { +if (cpu &S3C_ADC_QUIRK_RESSEL03 ) + tmp |=S3C2416_ADCCON_RESSEL ; +else + tmp |=S3C64XX_ADCCON_RESSEL ; }writel (tmp, adc->regs +S3C2410_ADCCON );
@@ -491,6 +495,7 @@ static int s3c_adc_resume(struct device *dev)struct platform_device *pdev =container_of (dev, struct platform_device, dev);struct adc_device *adc =platform_get_drvdata (pdev); +int cpu =platform_get_device_id (pdev)->driver_data;int ret;unsigned long tmp;
@@ -502,8 +507,12 @@ static int s3c_adc_resume(struct device *dev) tmp = adc->prescale |S3C2410_ADCCON_PRSCEN ;/* Enable 12-bit ADC resolution */ -if (platform_get_device_id (pdev)->driver_data &S3C_ADC_QUIRK_12BIT ) - tmp |=S3C64XX_ADCCON_RESSEL ; +if (cpu &S3C_ADC_QUIRK_12BIT ) { +if (cpu &S3C_ADC_QUIRK_RESSEL03 ) + tmp |=S3C2416_ADCCON_RESSEL ; +else + tmp |=S3C64XX_ADCCON_RESSEL ; + }writel (tmp, adc->regs +S3C2410_ADCCON );return 0 ;
@@ -524,6 +533,11 @@ static struct platform_device_id s3c_adc_driver_ids[] = { .driver_data = S3C_ADC_QUIRK_10BIT | S3C_ADC_QUIRK_MUX18, }, { + .name = "s3c2416-adc", + .driver_data = S3C_ADC_QUIRK_12BIT | + S3C_ADC_QUIRK_MUX18 | + S3C_ADC_QUIRK_RESSEL03, + }, { .name = "s3c64xx-adc", .driver_data =S3C_ADC_QUIRK_12BIT | S3C_ADC_QUIRK_MUXADCCON |
Signature · 1 line
1.7.2.3