* [PATCH 1/2] Use common cpu_is_xxx() macros on AT91 and AVR32
@ 2007-05-07 8:48 Haavard Skinnemoen
2007-05-07 8:48 ` [PATCH 2/2] atmel_spi: Remove unnecessary (and wrong) #ifdefs Haavard Skinnemoen
2007-05-07 10:43 ` [PATCH 1/2] Use common cpu_is_xxx() macros on AT91 and AVR32 Andrew Victor
0 siblings, 2 replies; 3+ messages in thread
From: Haavard Skinnemoen @ 2007-05-07 8:48 UTC (permalink / raw)
To: akpm
Cc: David Brownell, Andrew Victor, Nicolas Ferre, linux-kernel,
Haavard Skinnemoen
Several drivers shared between AT91 and AVR32 chips use cpu_is_xxx()
to handle CPU-specific differences. Currently, such code needs to be
inside #ifdef CONFIG_ARCH_AT91 because the macros don't exist on AVR32.
By defining the same macros on both AT91 and AVR32, these #ifdefs can
be eliminated. Since the macros will evaluate to a constant value for
CPUs that aren't supported by the current architecture, any code that
is only needed on AT91 will be optimized away on AVR32 and vice versa.
Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
---
include/asm-arm/arch-at91/cpu.h | 6 ++++++
include/asm-avr32/arch-at32ap/cpu.h | 33 +++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/include/asm-arm/arch-at91/cpu.h b/include/asm-arm/arch-at91/cpu.h
index d464ca5..7ef4eeb 100644
--- a/include/asm-arm/arch-at91/cpu.h
+++ b/include/asm-arm/arch-at91/cpu.h
@@ -68,4 +68,10 @@ static inline unsigned long at91_arch_identify(void)
#define cpu_is_at91sam9263() (0)
#endif
+/*
+ * Since this is ARM, we will never run on any AVR32 CPU. But these
+ * definitions may reduce clutter in common drivers.
+ */
+#define cpu_is_at32ap7000() (0)
+
#endif
diff --git a/include/asm-avr32/arch-at32ap/cpu.h b/include/asm-avr32/arch-at32ap/cpu.h
new file mode 100644
index 0000000..2bdc5bd
--- /dev/null
+++ b/include/asm-avr32/arch-at32ap/cpu.h
@@ -0,0 +1,33 @@
+/*
+ * AVR32 and (fake) AT91 CPU identification
+ *
+ * Copyright (C) 2007 Atmel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __ASM_ARCH_CPU_H
+#define __ASM_ARCH_CPU_H
+
+/*
+ * Only AT32AP7000 is defined for now. We can identify the specific
+ * chip at runtime, but I'm not sure if it's really worth it.
+ */
+#ifdef CONFIG_CPU_AT32AP7000
+# define cpu_is_at32ap7000() (1)
+#else
+# define cpu_is_at32ap7000() (0)
+#endif
+
+/*
+ * Since this is AVR32, we will never run on any AT91 CPU. But these
+ * definitions may reduce clutter in common drivers.
+ */
+#define cpu_is_at91rm9200() (0)
+#define cpu_is_at91sam9xe() (0)
+#define cpu_is_at91sam9260() (0)
+#define cpu_is_at91sam9261() (0)
+#define cpu_is_at91sam9263() (0)
+
+#endif /* __ASM_ARCH_CPU_H */
--
1.4.4.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] atmel_spi: Remove unnecessary (and wrong) #ifdefs
2007-05-07 8:48 [PATCH 1/2] Use common cpu_is_xxx() macros on AT91 and AVR32 Haavard Skinnemoen
@ 2007-05-07 8:48 ` Haavard Skinnemoen
2007-05-07 10:43 ` [PATCH 1/2] Use common cpu_is_xxx() macros on AT91 and AVR32 Andrew Victor
1 sibling, 0 replies; 3+ messages in thread
From: Haavard Skinnemoen @ 2007-05-07 8:48 UTC (permalink / raw)
To: akpm
Cc: David Brownell, Andrew Victor, Nicolas Ferre, linux-kernel,
Haavard Skinnemoen
Now that the cpu_is_xxx() macros are available both on AVR32 and AT91,
we can remove a couple of #ifdefs from this driver. One of them is
actually wrong -- new_1 should be set on AVR32 but isn't. This causes
the bus clock to run at twice the speed it is configured to.
Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
---
drivers/spi/atmel_spi.c | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 66e7bc9..1d8a2f6 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -22,10 +22,7 @@
#include <asm/io.h>
#include <asm/arch/board.h>
#include <asm/arch/gpio.h>
-
-#ifdef CONFIG_ARCH_AT91
#include <asm/arch/cpu.h>
-#endif
#include "atmel_spi.h"
@@ -552,10 +549,8 @@ static int __init atmel_spi_probe(struct platform_device *pdev)
goto out_free_buffer;
as->irq = irq;
as->clk = clk;
-#ifdef CONFIG_ARCH_AT91
if (!cpu_is_at91rm9200())
as->new_1 = 1;
-#endif
ret = request_irq(irq, atmel_spi_interrupt, 0,
pdev->dev.bus_id, master);
--
1.4.4.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] Use common cpu_is_xxx() macros on AT91 and AVR32
2007-05-07 8:48 [PATCH 1/2] Use common cpu_is_xxx() macros on AT91 and AVR32 Haavard Skinnemoen
2007-05-07 8:48 ` [PATCH 2/2] atmel_spi: Remove unnecessary (and wrong) #ifdefs Haavard Skinnemoen
@ 2007-05-07 10:43 ` Andrew Victor
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Victor @ 2007-05-07 10:43 UTC (permalink / raw)
To: Haavard Skinnemoen; +Cc: akpm, David Brownell, Nicolas Ferre, linux-kernel
> Several drivers shared between AT91 and AVR32 chips use cpu_is_xxx()
> to handle CPU-specific differences. Currently, such code needs to be
> inside #ifdef CONFIG_ARCH_AT91 because the macros don't exist on AVR32.
>
> By defining the same macros on both AT91 and AVR32, these #ifdefs can
> be eliminated. Since the macros will evaluate to a constant value for
> CPUs that aren't supported by the current architecture, any code that
> is only needed on AT91 will be optimized away on AVR32 and vice versa.
>
> Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Acked-by: Andrew Victor <andrew@sanpeople.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-05-07 11:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-07 8:48 [PATCH 1/2] Use common cpu_is_xxx() macros on AT91 and AVR32 Haavard Skinnemoen
2007-05-07 8:48 ` [PATCH 2/2] atmel_spi: Remove unnecessary (and wrong) #ifdefs Haavard Skinnemoen
2007-05-07 10:43 ` [PATCH 1/2] Use common cpu_is_xxx() macros on AT91 and AVR32 Andrew Victor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®