Skip to contentSkip to conversation

ARM: S3C2443: Workaround for 2443 EXTINT error

PATCH Superseded Alexander Varnin 2 participants 3 messages Nov 22, 2012 – Nov 24, 2012 1 message not in the archive

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: S3C2443: Workaround for 2443 EXTINT error

S3C2443 CPU has a problem with incorrect reading from EXTINTn registers. So s3c_irqext_type function wrongly modifies them. So add special function for s3c2443, to handle this case.

---
 arch/arm/mach-s3c24xx/s3c2443.c |    8 ++++
 arch/arm/plat-s3c24xx/irq.c     |   89 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 97 insertions(+), 0 deletions(-)
arch/arm/mach-s3c24xx/s3c2443.c +8 -0
index ab648ad..99eef31 100644
@@ -67,8 +67,11 @@ void s3c2443_restart(char mode, const char *cmd)
 	__raw_writel(S3C2443_SWRST_RESET, S3C2443_SWRST);
 }
 
+extern int s3c2443_irqext_type(struct irq_data *data, unsigned int type);
+
 int __init s3c2443_init(void)
 {
+	struct irq_chip * chip;
 	printk("S3C2443: Initialising architecture\n");
 
 	s3c_nand_setname("s3c2412-nand");
@@ -81,6 +84,11 @@ int __init s3c2443_init(void)
 	s3c_device_wdt.resource[1].start = IRQ_S3C2443_WDT;
 	s3c_device_wdt.resource[1].end   = IRQ_S3C2443_WDT;
 
+	chip = irq_get_chip(IRQ_EINT0);
+	chip->irq_set_type=s3c2443_irqext_type;
+	chip = irq_get_chip(IRQ_EINT4);
+	chip->irq_set_type=s3c2443_irqext_type;
+
 	return device_register(&s3c2443_dev);
 }
 
arch/arm/plat-s3c24xx/irq.c +89 -0

96 lines not on this page · raw message

Signature · 1 line
1.7.2.5
#1 lore raw

Hi Alexander,

first of all could you elaborate a bit more on the error you experience, because I currently have problems to understand it from the code alone :-) .

More inline.

Am Donnerstag, 22. November 2012, 14:00:01 schrieb Alexander Varnin:

Quoted 28 lines

S3C2443 CPU has a problem with incorrect reading from EXTINTn registers. So s3c_irqext_type function wrongly modifies them. So add special function for s3c2443, to handle this case.

---
 arch/arm/mach-s3c24xx/s3c2443.c |    8 ++++
 arch/arm/plat-s3c24xx/irq.c     |   89

+++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 0 deletions(-)

(quoted diff) +0 -0

b/arch/arm/mach-s3c24xx/s3c2443.c index ab648ad..99eef31 100644

arch/arm/mach-s3c24xx/s3c2443.c +3 -0
@@ -67,8 +67,11 @@ void s3c2443_restart(char mode, const char *cmd)
 	__raw_writel(S3C2443_SWRST_RESET, S3C2443_SWRST);
 }
 
+extern int s3c2443_irqext_type(struct irq_data *data, unsigned int type);
+
 int __init s3c2443_init(void)
 {
+	struct irq_chip * chip;
 	printk("S3C2443: Initialising architecture\n");
 
 	s3c_nand_setname("s3c2412-nand");

arch/arm/mach-s3c24xx/s3c2443.c int __init s3c2443_init(void) · line 93

Quoted 10 lines
arch/arm/mach-s3c24xx/s3c2443.c +5 -0
@@ -81,6 +84,11 @@ int __init s3c2443_init(void)
 	s3c_device_wdt.resource[1].start = IRQ_S3C2443_WDT;
 	s3c_device_wdt.resource[1].end   = IRQ_S3C2443_WDT;
 
+	chip = irq_get_chip(IRQ_EINT0);
+	chip->irq_set_type=s3c2443_irqext_type;
+	chip = irq_get_chip(IRQ_EINT4);
+	chip->irq_set_type=s3c2443_irqext_type;
+
 	return device_register(&s3c2443_dev);
 }

both this and your new exttype function would be more suitable for irq-s3c2443.c .

Quoted 82 lines
arch/arm/plat-s3c24xx/irq.c +72 -0
index fe57bbb..9c815f3 100644
@@ -224,7 +224,96 @@ s3c_irqext_type(struct irq_data *data, unsigned int
 type)
 
 	return 0;
 }
+#if defined(CONFIG_CPU_S3C2443)
+int
+s3c2443_irqext_type(struct irq_data *data, unsigned int type)
+{
+	int i;
+	int fixed;
+	void __iomem *extint_reg;
+	void __iomem *gpcon_reg;
+	unsigned long gpcon_offset, extint_offset;
+	unsigned long newvalue = 0, value;
+
+	if ((data->irq >= IRQ_EINT0) && (data->irq <= IRQ_EINT3)) {
+		gpcon_reg = S3C2410_GPFCON;
+		extint_reg = S3C24XX_EXTINT0;
+		gpcon_offset = (data->irq - IRQ_EINT0) * 2;
+		extint_offset = (data->irq - IRQ_EINT0) * 4;
+	} else if ((data->irq >= IRQ_EINT4) && (data->irq <= IRQ_EINT7)) {
+		gpcon_reg = S3C2410_GPFCON;
+		extint_reg = S3C24XX_EXTINT0;
+		gpcon_offset = (data->irq - (EXTINT_OFF)) * 2;
+		extint_offset = (data->irq - (EXTINT_OFF)) * 4;
+	} else if ((data->irq >= IRQ_EINT8) && (data->irq <= IRQ_EINT15)) {
+		gpcon_reg = S3C2410_GPGCON;
+		extint_reg = S3C24XX_EXTINT1;
+		gpcon_offset = (data->irq - IRQ_EINT8) * 2;
+		extint_offset = (data->irq - IRQ_EINT8) * 4;
+	} else if ((data->irq >= IRQ_EINT16) && (data->irq <= IRQ_EINT23)) {
+		gpcon_reg = S3C2410_GPGCON;
+		extint_reg = S3C24XX_EXTINT2;
+		gpcon_offset = (data->irq - IRQ_EINT8) * 2;
+		extint_offset = (data->irq - IRQ_EINT16) * 4;
+	} else {
+		return -1;
+	}
 
+	/* Set the GPIO to external interrupt mode */
+	value = __raw_readl(gpcon_reg);
+	value = (value & ~(3 << gpcon_offset)) | (0x02 << gpcon_offset);
+	__raw_writel(value, gpcon_reg);
+
+	/* Set the external interrupt to pointed trigger type */
+	switch (type)
+	{
+		case IRQ_TYPE_NONE:
+			printk(KERN_WARNING "No edge setting!\n");
+			break;
+
+		case IRQ_TYPE_EDGE_RISING:
+			newvalue = S3C2410_EXTINT_RISEEDGE;
+			break;
+
+		case IRQ_TYPE_EDGE_FALLING:
+			newvalue = S3C2410_EXTINT_FALLEDGE;
+			break;
+
+		case IRQ_TYPE_EDGE_BOTH:
+			newvalue = S3C2410_EXTINT_BOTHEDGE;
+			break;
+
+		case IRQ_TYPE_LEVEL_LOW:
+			newvalue = S3C2410_EXTINT_LOWLEV;
+			break;
+
+		case IRQ_TYPE_LEVEL_HIGH:
+			newvalue = S3C2410_EXTINT_HILEV;
+			break;
+
+		default:
+			printk(KERN_ERR "No such irq type %d", type);
+			return -1;
+	}
+
+	value = __raw_readl(extint_reg);

arch/arm/plat-s3c24xx/irq.c s3c_irqext_type(struct irq_data *data, unsigned int · line 310

Quoted 10 lines
arch/arm/plat-s3c24xx/irq.c +10 -0
+	//Hack for 2443 error workaround
+	fixed = 0;
+	if(extint_reg == S3C24XX_EXTINT1 || extint_reg == S3C24XX_EXTINT2)
+		for(i=0; i<7;i++)
+		    	fixed |= (((value >> ((7-i)*4+1)) & 7) | ((value >> ((7-i)*4-3)) & 8)) << i*4;
+	else
+		for(i=0; i<7;i++)
+		    	fixed |= ( (value >> (7-i)*4) & 0xf )  << i*4;
+        fixed |= (((value>>1) & 7) | ((value<<3) & 8)) << 27;
+	value = fixed;

What does this do or what should it do? Also it gets calculated but never used?

And please use scripts/checkpatch.pl to verify your patch follows coding guidelines, as this block is especially hard to read.

Quoted 9 lines
arch/arm/plat-s3c24xx/irq.c +6 -0
+	value = (value & ~(7 << extint_offset)) | (newvalue << extint_offset);
+	__raw_writel(value, extint_reg);
+
+	return 0;
+}
+#endif //defined(CONFIG_CPU_S3C2443)
 static struct irq_chip s3c_irqext_chip = {
 	.name		= "s3c-ext",
 	.irq_mask	= s3c_irqext_mask,

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Am Freitag, 23. November 2012, 08:10:15 schrieb Alexander Varnin:

Quoted 4 lines

Please take a look at this document. It describes the problem with EXTINTn registers on 2443.
In fact, the irqext_set function for s3c2443 differs from common starting from "//Hack for 2443 error workaround" comment.

wow ... this is a crazy bug :-)

[...]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
(quoted diff) +0 -0

b/arch/arm/mach-s3c24xx/s3c2443.c index ab648ad..99eef31 100644

arch/arm/mach-s3c24xx/s3c2443.c +0 -0

[...]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
arch/arm/mach-s3c24xx/s3c2443.c +4 -0
+#if defined(CONFIG_CPU_S3C2443)
+int
+s3c2443_irqext_type(struct irq_data *data, unsigned int type)
+{

[...]

Quoted 6 lines
Quoted 6 lines

arch/arm/mach-s3c24xx/s3c2443.c

Quoted 6 lines
arch/arm/mach-s3c24xx/s3c2443.c +6 -0
+	value = __raw_readl(extint_reg);
+	//Hack for 2443 error workaround
+	fixed = 0;
+	if(extint_reg == S3C24XX_EXTINT1 || extint_reg == S3C24XX_EXTINT2)
+		for(i=0; i<7;i++)
+		    	fixed |= (((value >> ((7-i)*4+1)) & 7) | ((value >> ((7-

i)*4-3))

Quoted 9 lines
Quoted 9 lines

arch/arm/mach-s3c24xx/s3c2443.c

Quoted 5 lines

& 8)) << i*4; + else

arch/arm/mach-s3c24xx/s3c2443.c +4 -0
+		for(i=0; i<7;i++)
+		    	fixed |= ( (value >> (7-i)*4) & 0xf )  << i*4;
+        fixed |= (((value>>1) & 7) | ((value<<3) & 8)) << 27;
+	value = fixed;

What does this do or what should it do? Also it gets calculated but never used?

Quoted 6 lines
Quoted 6 lines

And please use scripts/checkpatch.pl to verify your patch follows coding guidelines, as this block is especially hard to read.

arch/arm/mach-s3c24xx/s3c2443.c

Quoted 1 line
arch/arm/mach-s3c24xx/s3c2443.c +1 -0
+	value = (value & ~(7 << extint_offset)) | (newvalue << 

extint_offset);

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
arch/arm/mach-s3c24xx/s3c2443.c +5 -0
+	__raw_writel(value, extint_reg);
+
+	return 0;
+}
+#endif //defined(CONFIG_CPU_S3C2443)
 
  static struct irq_chip s3c_irqext_chip = {
 
  	.name		= "s3c-ext",
  	.irq_mask	= s3c_irqext_mask,