]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
microblaze: Add support for little-endian Microblaze
authorMichal Simek <monstr@monstr.eu>
Tue, 28 Sep 2010 06:04:14 +0000 (16:04 +1000)
committerMichal Simek <monstr@monstr.eu>
Thu, 21 Oct 2010 05:51:59 +0000 (15:51 +1000)
Microblaze little-endian toolchain exports __MICROBLAZEEL__
which is used in the kernel to identify little/big endian.

The most of the changes are in loading values from DTB which
is always big endian.

Little endian platforms are based on new AXI bus which has
impact to early uartlite initialization.

Signed-off-by: Michal Simek <monstr@monstr.eu>
arch/microblaze/include/asm/byteorder.h
arch/microblaze/include/asm/checksum.h
arch/microblaze/include/asm/cpuinfo.h
arch/microblaze/include/asm/elf.h
arch/microblaze/include/asm/unaligned.h
arch/microblaze/kernel/heartbeat.c
arch/microblaze/kernel/intc.c
arch/microblaze/kernel/prom.c
arch/microblaze/kernel/timer.c
arch/microblaze/kernel/vmlinux.lds.S

index ce9c58732ffcdec6888854e4f33a7c81a75b12da..31902762a42699079fd1d40d0a3416a0e4d4d1c0 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef _ASM_MICROBLAZE_BYTEORDER_H
 #define _ASM_MICROBLAZE_BYTEORDER_H
 
+#ifdef __MICROBLAZEEL__
+#include <linux/byteorder/little_endian.h>
+#else
 #include <linux/byteorder/big_endian.h>
+#endif
 
 #endif /* _ASM_MICROBLAZE_BYTEORDER_H */
index 128bf03b54b7e9435abe99f8af19ef4eae91b611..0185cbefdda48a2770703709ed1d9701208362a0 100644 (file)
@@ -24,8 +24,13 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
                "addc %0, %0, %3\n\t"
                "addc %0, %0, r0\n\t"
                : "+&d" (sum)
-               : "d" (saddr), "d" (daddr), "d" (len + proto));
-
+               : "d" (saddr), "d" (daddr),
+#ifdef __MICROBLAZEEL__
+       "d" ((len + proto) << 8)
+#else
+       "d" (len + proto)
+#endif
+);
        return sum;
 }
 
index 0d4f0ce3ff7c6a5d4846ac8135f17a6499f95c6f..7fab800496ae27baae2fa3b78d5c2ae26ae73694 100644 (file)
@@ -98,7 +98,8 @@ void set_cpuinfo_pvr_full(struct cpuinfo *ci, struct device_node *cpu);
 static inline unsigned int fcpu(struct device_node *cpu, char *n)
 {
        int *val;
-       return (val = (int *) of_get_property(cpu, n, NULL)) ? *val : 0;
+       return (val = (int *) of_get_property(cpu, n, NULL)) ?
+                                                       be32_to_cpup(val) : 0;
 }
 
 #endif /* _ASM_MICROBLAZE_CPUINFO_H */
index 732caf1be741fc1ede77bbfe14972a19c3044eb0..098dfdde4b061e067c56ad2a5ce0016a98fa8ff1 100644 (file)
@@ -71,7 +71,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
 
 #define ELF_ET_DYN_BASE         (0x08000000)
 
-#ifdef __LITTLE_ENDIAN__
+#ifdef __MICROBLAZEEL__
 #define ELF_DATA       ELFDATA2LSB
 #else
 #define ELF_DATA       ELFDATA2MSB
index 3658d91ac0fb95ead00dbc3bca4fd9e0b8d36457..2b97cbe500e9a4e92dc6f556129dc7d8b630d8fe 100644 (file)
 
 # ifdef __KERNEL__
 
-# include <linux/unaligned/be_struct.h>
+# include <linux/unaligned/be_byteshift.h>
 # include <linux/unaligned/le_byteshift.h>
 # include <linux/unaligned/generic.h>
 
-# define get_unaligned __get_unaligned_be
-# define put_unaligned __put_unaligned_be
+
+#  ifdef __MICROBLAZEEL__
+#   define get_unaligned       __get_unaligned_le
+#   define put_unaligned       __put_unaligned_le
+#  else
+#   define get_unaligned       __get_unaligned_be
+#   define put_unaligned       __put_unaligned_be
+#  endif
 
 # endif        /* __KERNEL__ */
 #endif /* _ASM_MICROBLAZE_UNALIGNED_H */
index 5c24eb8219f133751965a504769aa9a08b712840..154756f3c6945a51eee059ec1b7349c9e326c129 100644 (file)
@@ -59,7 +59,7 @@ void setup_heartbeat(void)
        }
 
        if (gpio) {
-               base_addr = *(int *) of_get_property(gpio, "reg", NULL);
+               base_addr = be32_to_cpup(of_get_property(gpio, "reg", NULL));
                base_addr = (unsigned long) ioremap(base_addr, PAGE_SIZE);
                printk(KERN_NOTICE "Heartbeat GPIO at 0x%x\n", base_addr);
 
index e85bbea1c62bd1b544abdfbc2e33774beec9f17e..d61ea33aff7cd3a9de120710a89cd51e8c03b40d 100644 (file)
@@ -138,12 +138,15 @@ void __init init_IRQ(void)
        }
        BUG_ON(!intc);
 
-       intc_baseaddr = *(int *) of_get_property(intc, "reg", NULL);
+       intc_baseaddr = be32_to_cpup(of_get_property(intc,
+                                                               "reg", NULL));
        intc_baseaddr = (unsigned long) ioremap(intc_baseaddr, PAGE_SIZE);
-       nr_irq = *(int *) of_get_property(intc, "xlnx,num-intr-inputs", NULL);
+       nr_irq = be32_to_cpup(of_get_property(intc,
+                                               "xlnx,num-intr-inputs", NULL));
 
        intr_type =
-               *(int *) of_get_property(intc, "xlnx,kind-of-intr", NULL);
+               be32_to_cpup(of_get_property(intc,
+                                               "xlnx,kind-of-intr", NULL));
        if (intr_type >= (1 << (nr_irq + 1)))
                printk(KERN_INFO " ERROR: Mismatch in kind-of-intr param\n");
 
index 608e5cf2e10ac50453a157897aea4d29d28c8e08..04d3325039d96df1aad875d73ded6d0f0c7f4843 100644 (file)
@@ -77,11 +77,12 @@ static int __init early_init_dt_scan_serial(unsigned long node,
 /* find compatible node with uartlite */
        p = of_get_flat_dt_prop(node, "compatible", &l);
        if ((strncmp(p, "xlnx,xps-uartlite", 17) != 0) &&
-                       (strncmp(p, "xlnx,opb-uartlite", 17) != 0))
+                       (strncmp(p, "xlnx,opb-uartlite", 17) != 0) &&
+                       (strncmp(p, "xlnx,axi-uartlite", 17) != 0))
                return 0;
 
        addr = of_get_flat_dt_prop(node, "reg", &l);
-       return *addr; /* return address */
+       return be32_to_cpup(addr); /* return address */
 }
 
 /* this function is looking for early uartlite console - Microblaze specific */
@@ -115,7 +116,7 @@ static int __init early_init_dt_scan_serial_full(unsigned long node,
 
        addr = *(u32 *)of_get_flat_dt_prop(node, "reg", &l);
        addr += *(u32 *)of_get_flat_dt_prop(node, "reg-offset", &l);
-       return addr; /* return address */
+       return be32_to_cpu(addr); /* return address */
 }
 
 /* this function is looking for early uartlite console - Microblaze specific */
index 64ca14dbac6e9b74b5f04ceeac6fd74723f4db15..fcb97e86003df8634500b181ab84c87ce6dea977 100644 (file)
@@ -270,11 +270,11 @@ void __init time_init(void)
        }
        BUG_ON(!timer);
 
-       timer_baseaddr = *(int *) of_get_property(timer, "reg", NULL);
+       timer_baseaddr = be32_to_cpup(of_get_property(timer, "reg", NULL));
        timer_baseaddr = (unsigned long) ioremap(timer_baseaddr, PAGE_SIZE);
-       irq = *(int *) of_get_property(timer, "interrupts", NULL);
-       timer_num =
-               *(int *) of_get_property(timer, "xlnx,one-timer-only", NULL);
+       irq = be32_to_cpup(of_get_property(timer, "interrupts", NULL));
+       timer_num = be32_to_cpup(of_get_property(timer,
+                                               "xlnx,one-timer-only", NULL));
        if (timer_num) {
                eprintk(KERN_EMERG "Please enable two timers in HW\n");
                BUG();
index 20b0552391d10bc560f41b3526ec02ff6b4c3ef0..96a88c31fe48f412106a7f16780c964fbf0b4e01 100644 (file)
@@ -15,7 +15,11 @@ ENTRY(microblaze_start)
 #include <asm-generic/vmlinux.lds.h>
 #include <asm/thread_info.h>
 
+#ifdef __MICROBLAZEEL__
+jiffies = jiffies_64;
+#else
 jiffies = jiffies_64 + 4;
+#endif
 
 SECTIONS {
        . = CONFIG_KERNEL_START;