Microblaze little-endian port + driver changes
Subsystems (7)
Michal Simek
maintainerHi everybody,
here is the first bunch of patches which is necessary to apply to get microblaze little-endian AXI version work.
All patches are placed in microblaze-next branch and they are also merged to linux-next branch.
Grant: I would like to ask you if you can please take a look at little-endian driver changes.
Thanks for your review,
Michal
Michal Simek
maintainerPATCH 1/7 of: GPIO: Fix OF probing on little-endian systems
DTB is always big-endian that's why is necessary
to convert it.
--- drivers/gpio/xilinx_gpio.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpio/xilinx_gpio.c +3 -3
@@ -171,13 +171,13 @@ static int __devinit xgpio_of_probe(struct device_node *np)/* Update GPIO state shadow register with default value */ tree_info =of_get_property (np,"xlnx,dout-default" ,NULL );if (tree_info) - chip->gpio_state = *tree_info; + chip->gpio_state =be32_to_cpup (tree_info);/* Update GPIO direction shadow register with default value */ chip->gpio_dir =0xFFFFFFFF ;/* By default, all pins are inputs */ tree_info =of_get_property (np,"xlnx,tri-default" ,NULL );if (tree_info) - chip->gpio_dir = *tree_info; + chip->gpio_dir =be32_to_cpup (tree_info);/* Check device node and parent device node for device width */ chip->mmchip.gc.ngpio =32 ;/* By default assume full GPIO controller */
@@ -186,7 +186,7 @@ static int __devinit xgpio_of_probe(struct device_node *np) tree_info =of_get_property (np->parent,"xlnx,gpio-width" ,NULL );if (tree_info) - chip->mmchip.gc.ngpio = *tree_info; + chip->mmchip.gc.ngpio =be32_to_cpup (tree_info);spin_lock_init (&chip->gpio_lock);
Signature · 1 line
1.5.5.1
Michal Simek
maintainerPATCH 2/7 of: MTD: Fix OF probing on little-endian systems
Convert big-endian DTB to little-endian if necessary.
--- drivers/mtd/maps/physmap_of.c | 2 +- drivers/mtd/ofpart.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/maps/physmap_of.c +1 -1
@@ -294,7 +294,7 @@ static int __devinit of_flash_probe(struct platform_device *dev, info->list[i].map.name =dev_name (&dev->dev); info->list[i].map.phys = res.start; info->list[i].map.size = res_size; - info->list[i].map.bankwidth = *width; + info->list[i].map.bankwidth =be32_to_cpup (width); err = -ENOMEM ; info->list[i].map.virt = ioremap(info->list[i].map.phys,
drivers/mtd/ofpart.c +2 -2
@@ -53,8 +53,8 @@ int __devinit of_mtd_parse_partitions(struct device *dev,continue ; } - (*pparts)[i].offset = reg[0 ]; - (*pparts)[i].size = reg[1 ]; + (*pparts)[i].offset =be32_to_cpu (reg[0 ]); + (*pparts)[i].size =be32_to_cpu (reg[1 ]); partname =of_get_property (pp,"label" , &len);if (!partname)
Signature · 1 line
1.5.5.1
Michal Simek
maintainerPATCH 3/7 of: Fix uart16550 initialization on little-endian systems
Convert values from big-endian to cpu-endian.
--- drivers/serial/of_serial.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-)
drivers/serial/of_serial.c +10 -7
@@ -31,17 +31,19 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev, {struct resource resource;struct device_node *np = ofdev->dev.of_node; -const unsigned int *clk, *spd; +const unsigned int *spd; +unsigned int clk;const u32 *prop;int ret, prop_size;memset (port,0 ,sizeof *port); spd =of_get_property (np,"current-speed" ,NULL ); - clk =of_get_property (np,"clock-frequency" ,NULL ); -if (!clk) { + prop =of_get_property (np,"clock-frequency" ,NULL ); +if (!prop) {dev_warn (&ofdev->dev,"no clock-frequency property set\n" );return -ENODEV ; } + clk =be32_to_cpup (prop); ret =of_address_to_resource (np,0 , &resource);if (ret) {
@@ -55,23 +57,24 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,/* Check for shifted address mapping */ prop =of_get_property (np,"reg-offset" , &prop_size);if (prop && (prop_size ==sizeof (u32))) - port->mapbase += *prop; + port->mapbase +=be32_to_cpup (prop);/* Check for registers offset within the devices address range */ prop =of_get_property (np,"reg-shift" , &prop_size);if (prop && (prop_size ==sizeof (u32))) - port->regshift = *prop; + port->regshift =be32_to_cpup (prop); port->irq =irq_of_parse_and_map (np,0 ); port->iotype =UPIO_MEM ; port->type = type; - port->uartclk = *clk; + port->uartclk = clk; port->flags =UPF_SHARE_IRQ |UPF_BOOT_AUTOCONF |UPF_IOREMAP |UPF_FIXED_PORT |UPF_FIXED_TYPE ; port->dev = &ofdev->dev; +/* If current-speed was set, then try not to change it. */ if (spd) - port->custom_divisor = *clk / (16 * (*spd)); + port->custom_divisor = clk / (16 *be32_to_cpup (spd));return 0 ; }
Signature · 1 line
1.5.5.1
Michal Simek
maintainerPATCH 4/7 net: emaclite: Add support for little-endian platforms
Upcomming Microblaze is little endian that's why is necessary to fix protocol and length loading.
--- drivers/net/xilinx_emaclite.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/xilinx_emaclite.c +4 -4
@@ -430,8 +430,8 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data) }/* Get the protocol type of the ethernet frame that arrived */ - proto_type = ((in_be32 (addr +XEL_HEADER_OFFSET + -XEL_RXBUFF_OFFSET ) >>XEL_HEADER_SHIFT ) & + proto_type = ((ntohl (in_be32 (addr +XEL_HEADER_OFFSET + +XEL_RXBUFF_OFFSET )) >>XEL_HEADER_SHIFT ) &XEL_RPLR_LENGTH_MASK );/* Check if received ethernet frame is a raw ethernet frame
@@ -439,9 +439,9 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)if (proto_type > (ETH_FRAME_LEN +ETH_FCS_LEN )) {if (proto_type ==ETH_P_IP ) { - length = ((in_be32 (addr + + length = ((ntohl (in_be32 (addr +XEL_HEADER_IP_LENGTH_OFFSET + -XEL_RXBUFF_OFFSET ) >> +XEL_RXBUFF_OFFSET )) >>XEL_HEADER_SHIFT ) &XEL_RPLR_LENGTH_MASK ); length +=ETH_HLEN +ETH_FCS_LEN ;
Signature · 1 line
1.5.5.1
Michal Simek
maintainerPATCH 5/7 microblaze: Add PVR for endians plus detection
Upcomming microblaze version will support little-endian.
--- arch/microblaze/include/asm/cpuinfo.h | 1 + arch/microblaze/include/asm/pvr.h | 3 +++ arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c | 1 + arch/microblaze/kernel/cpu/cpuinfo-static.c | 1 + arch/microblaze/kernel/cpu/mb.c | 3 ++- arch/microblaze/platform/generic/system.dts | 1 + 6 files changed, 9 insertions(+), 1 deletions(-)
arch/microblaze/include/asm/cpuinfo.h +1 -0
@@ -38,6 +38,7 @@ struct cpuinfo {u32 use_exc;u32 ver_code;u32 mmu; +u32 endian;/* CPU caches */ u32 use_icache;
arch/microblaze/include/asm/pvr.h +3 -0
@@ -32,6 +32,7 @@ struct pvr_s {#define PVR0_USE_DCACHE_MASK 0x01000000#define PVR0_USE_MMU 0x00800000#define PVR0_USE_BTC 0x00400000 +#define PVR0_ENDI 0x00200000#define PVR0_VERSION_MASK 0x0000FF00#define PVR0_USER1_MASK 0x000000FF
@@ -209,6 +210,8 @@ struct pvr_s {#define PVR_MMU_TLB_ACCESS (pvr) (pvr.pvr[11] & PVR11_MMU_TLB_ACCESS)#define PVR_MMU_ZONES (pvr) (pvr.pvr[11] & PVR11_MMU_ZONES) +/* endian */ +#define PVR_ENDIAN (pvr) (pvr.pvr[0] & PVR0_ENDI)int cpu_has_pvr (void );void get_pvr (struct pvr_s *pvr);
arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c +1 -0
@@ -72,6 +72,7 @@ void set_cpuinfo_pvr_full(struct cpuinfo *ci, struct device_node *cpu)CI (pvr_user2,USER2 );CI (mmu,USE_MMU ); +CI (endian,ENDIAN );CI (use_icache,USE_ICACHE );CI (icache_tagbits,ICACHE_ADDR_TAG_BITS );
arch/microblaze/kernel/cpu/cpuinfo-static.c +1 -0
@@ -119,6 +119,7 @@ void __init set_cpuinfo_static(struct cpuinfo *ci, struct device_node *cpu) ci->pvr_user2 =fcpu (cpu,"xlnx,pvr-user2" ); ci->mmu =fcpu (cpu,"xlnx,use-mmu" ); + ci->endian =fcpu (cpu,"xlnx,endianness" ); ci->ver_code =0 ; ci->fpga_family_code =0 ;
arch/microblaze/kernel/cpu/mb.c +2 -1
@@ -51,11 +51,12 @@ static int show_cpuinfo(struct seq_file *m, void *v) count = seq_printf(m, "CPU-Family: MicroBlaze\n" "FPGA-Arch: %s\n" - "CPU-Ver: %s\n" + "CPU-Ver: %s, %s endian\n" "CPU-MHz: %d.%02d\n" "BogoMips: %lu.%02lu\n", fpga_family, cpu_ver, + cpuinfo.endian ? "little" : "big", cpuinfo.cpu_clock_freq / 1000000, cpuinfo.cpu_clock_freq %
arch/microblaze/platform/generic/system.dts +1 -0
@@ -85,6 +85,7 @@ xlnx,dynamic-bus-sizing = <0x1>; xlnx,edge-is-positive = <0x1>; xlnx,family = "virtex5"; + xlnx,endianness = <0x1>; xlnx,fpu-exception = <0x1>; xlnx,fsl-data-size = <0x20>; xlnx,fsl-exception = <0x0>;
Signature · 1 line
1.5.5.1
Michal Simek
maintainerPATCH 6/7 microblaze: KGDB little endian support
Just need to use little-endian opcode for brki r16, 0x18
--- arch/microblaze/kernel/kgdb.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
arch/microblaze/kernel/kgdb.c +4 -0
@@ -142,5 +142,9 @@ void kgdb_arch_exit(void)* Global data */ struct kgdb_arch arch_kgdb_ops = { +#ifdef __MICROBLAZEEL__ + .gdb_bpt_instr = {0x18, 0x00, 0x0c, 0xba}, /* brki r16, 0x18 */ +#else .gdb_bpt_instr = {0xba ,0x0c ,0x00 ,0x18 },/* brki r16, 0x18 */ +#endif };
Signature · 1 line
1.5.5.1
Michal Simek
maintainerPATCH 7/7 microblaze: Add support for little-endian Microblaze
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.
--- arch/microblaze/include/asm/byteorder.h | 4 ++++ arch/microblaze/include/asm/checksum.h | 9 +++++++-- arch/microblaze/include/asm/cpuinfo.h | 3 ++- arch/microblaze/include/asm/elf.h | 2 +- arch/microblaze/include/asm/unaligned.h | 12 +++++++++--- arch/microblaze/kernel/heartbeat.c | 3 ++- arch/microblaze/kernel/intc.c | 9 ++++++--- arch/microblaze/kernel/prom.c | 7 ++++--- arch/microblaze/kernel/timer.c | 8 +++++--- arch/microblaze/kernel/vmlinux.lds.S | 4 ++++ 10 files changed, 44 insertions(+), 17 deletions(-)
arch/microblaze/include/asm/byteorder.h +4 -0
@@ -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 */
arch/microblaze/include/asm/checksum.h +7 -2
@@ -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; }
arch/microblaze/include/asm/cpuinfo.h +2 -1
@@ -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 */
arch/microblaze/include/asm/elf.h +1 -1
@@ -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
arch/microblaze/include/asm/unaligned.h +9 -3
@@ -12,12 +12,18 @@# 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 */
arch/microblaze/kernel/heartbeat.c +2 -1
@@ -59,7 +59,8 @@ void setup_heartbeat(void) }if (gpio) { - base_addr = *(int *)of_get_property (gpio,"reg" ,NULL ); + base_addr =be32_to_cpup ((int *)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);
arch/microblaze/kernel/intc.c +6 -3
@@ -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 ((int *)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 ((int *)of_get_property (intc, +"xlnx,num-intr-inputs" ,NULL )); intr_type = - *(int *)of_get_property (intc,"xlnx,kind-of-intr" ,NULL ); +be32_to_cpup ((int *)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" );
arch/microblaze/kernel/prom.c +4 -3
@@ -77,7 +77,8 @@ 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);
@@ -87,7 +88,7 @@ static int __init early_init_dt_scan_serial(unsigned long node,/* this function is looking for early uartlite console - Microblaze specific */ int __init early_uartlite_console (void ) { -return of_scan_flat_dt (early_init_dt_scan_serial,NULL ); +return be32_to_cpu (of_scan_flat_dt (early_init_dt_scan_serial,NULL )); }/* MS this is Microblaze specifig function */
@@ -121,7 +122,7 @@ static int __init early_init_dt_scan_serial2(unsigned long node,/* this function is looking for early uartlite console - Microblaze specific */ int __init early_uart16550_console (void ) { -return of_scan_flat_dt (early_init_dt_scan_serial2,NULL ); +return be32_to_cpu (of_scan_flat_dt (early_init_dt_scan_serial2,NULL )); }#endif
arch/microblaze/kernel/timer.c +5 -3
@@ -270,11 +270,13 @@ void __init time_init(void) }BUG_ON (!timer); - timer_baseaddr = *(int *)of_get_property (timer,"reg" ,NULL ); + timer_baseaddr =be32_to_cpup ((int *)of_get_property (timer, +"reg" ,NULL )); timer_baseaddr = (unsigned long )ioremap (timer_baseaddr,PAGE_SIZE ); - irq = *(int *)of_get_property (timer,"interrupts" ,NULL ); + irq =be32_to_cpup ((int *)of_get_property (timer,"interrupts" ,NULL )); timer_num = - *(int *)of_get_property (timer,"xlnx,one-timer-only" ,NULL ); +be32_to_cpup ((int *)of_get_property (timer, +"xlnx,one-timer-only" ,NULL ));if (timer_num) {eprintk (KERN_EMERG "Please enable two timers in HW\n" );BUG ();
arch/microblaze/kernel/vmlinux.lds.S +4 -0
@@ -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;
Signature · 1 line
1.5.5.1
Re: [PATCH 7/7] microblaze: Add support for little-endian Microblaze
Quoted 10 lines · Michal Simek
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 <[email protected]>
Hi Michal,
Looks pretty good, but a few comments below.
Quoted 125 lines
--- arch/microblaze/include/asm/byteorder.h | 4 ++++ arch/microblaze/include/asm/checksum.h | 9 +++++++-- arch/microblaze/include/asm/cpuinfo.h | 3 ++- arch/microblaze/include/asm/elf.h | 2 +- arch/microblaze/include/asm/unaligned.h | 12 +++++++++--- arch/microblaze/kernel/heartbeat.c | 3 ++- arch/microblaze/kernel/intc.c | 9 ++++++--- arch/microblaze/kernel/prom.c | 7 ++++--- arch/microblaze/kernel/timer.c | 8 +++++--- arch/microblaze/kernel/vmlinux.lds.S | 4 ++++ 10 files changed, 44 insertions(+), 17 deletions(-)arch/microblaze/include/asm/byteorder.h +4
-0@@ -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 */ arch/microblaze/include/asm/checksum.h +7
-2@@ -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; }arch/microblaze/include/asm/cpuinfo.h +2
-1@@ -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 */ arch/microblaze/include/asm/elf.h +1
-1@@ -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 ELFDATA2MSBarch/microblaze/include/asm/unaligned.h +9
-3@@ -12,12 +12,18 @@# 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 */ arch/microblaze/kernel/heartbeat.c +2
-1@@ -59,7 +59,8 @@ void setup_heartbeat(void) }if (gpio) { - base_addr = *(int *)of_get_property (gpio,"reg" ,NULL ); + base_addr =be32_to_cpup ((int *)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);arch/microblaze/kernel/intc.c +1
-1@@ -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((int *) of_get_property(intc,
arch/microblaze/kernel/intc.c void __init init_IRQ(void) · line 149
Quoted 10 lines
arch/microblaze/kernel/intc.c +5
-2+ "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 ((int *)of_get_property (intc, +"xlnx,num-intr-inputs" ,NULL )); intr_type = - *(int *)of_get_property (intc,"xlnx,kind-of-intr" ,NULL ); +be32_to_cpup ((int *)of_get_property (intc, +"xlnx,kind-of-intr" ,NULL ));
Unnecessary casts (see comment below)
Quoted 18 lines
arch/microblaze/kernel/intc.c +0
-0if (intr_type >= (1 << (nr_irq +1 )))printk (KERN_INFO " ERROR: Mismatch in kind-of-intr param\n" );arch/microblaze/kernel/prom.c +2
-1@@ -77,7 +77,8 @@ 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);
arch/microblaze/kernel/prom.c static int __init early_init_dt_scan_serial(unsigned long node, · line 91
Quoted 5 lines
arch/microblaze/kernel/prom.c +1
-1@@ -87,7 +88,7 @@ static int __init early_init_dt_scan_serial(unsigned long node,/* this function is looking for early uartlite console - Microblaze specific */ int __init early_uartlite_console (void ) { -return of_scan_flat_dt (early_init_dt_scan_serial,NULL ); +return be32_to_cpu (of_scan_flat_dt (early_init_dt_scan_serial,NULL ));
of_scan_flat_dt returns a rc that should already by in cpu endianess. of_scan_flat_dt needs to be fixed instead.
arch/microblaze/kernel/prom.c static int __init early_init_dt_scan_serial2(unsigned long node, · line 125
Quoted 9 lines
arch/microblaze/kernel/prom.c +1
-1}/* MS this is Microblaze specifig function */ @@ -121,7 +122,7 @@ static int __init early_init_dt_scan_serial2(unsigned long node,/* this function is looking for early uartlite console - Microblaze specific */ int __init early_uart16550_console (void ) { -return of_scan_flat_dt (early_init_dt_scan_serial2,NULL ); +return be32_to_cpu (of_scan_flat_dt (early_init_dt_scan_serial2,NULL ));
Ditto
Quoted 8 lines
arch/microblaze/kernel/prom.c +0
-0}#endif arch/microblaze/kernel/timer.c +0
-0
arch/microblaze/kernel/timer.c void __init time_init(void) · line 274
Quoted 6 lines
arch/microblaze/kernel/timer.c +2
-1@@ -270,11 +270,13 @@ void __init time_init(void) }BUG_ON (!timer); - timer_baseaddr = *(int *)of_get_property (timer,"reg" ,NULL ); + timer_baseaddr =be32_to_cpup ((int *)of_get_property (timer, +"reg" ,NULL ));
The (int*) casting shouldn't be needed. of_get_property returns a 'const void *', and be32_to_cpup accepts a 'const __be32 *'. Ditto through the other instances of this casting.
Quoted 15 lines
arch/microblaze/kernel/timer.c +3
-2timer_baseaddr = (unsigned long )ioremap (timer_baseaddr,PAGE_SIZE ); - irq = *(int *)of_get_property (timer,"interrupts" ,NULL ); + irq =be32_to_cpup ((int *)of_get_property (timer,"interrupts" ,NULL )); timer_num = - *(int *)of_get_property (timer,"xlnx,one-timer-only" ,NULL ); +be32_to_cpup ((int *)of_get_property (timer, +"xlnx,one-timer-only" ,NULL ));if (timer_num) {eprintk (KERN_EMERG "Please enable two timers in HW\n" );BUG ();arch/microblaze/kernel/vmlinux.lds.S +0
-0
arch/microblaze/kernel/vmlinux.lds.S ENTRY(microblaze_start) · line 22
Quoted 8 lines
arch/microblaze/kernel/vmlinux.lds.S +4
-0@@ -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
I comment would go nicely hear to explain to reviewers what this is about.
Cheers,
g.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 7/7] microblaze: Add support for little-endian Microblaze
Quoted 33 lines · Michal Simek
2010/9/29 Grant Likely <[email protected]>
Quoted 17 lines · Michal Simek
Quoted 10 lines
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 <[email protected]>Hi Michal,
Looks pretty good, but a few comments below.
Quoted 12 lines
Quoted 9 lines
(quoted diff) +0
-0@@ -87,7 +88,7 @@ static int __init early_init_dt_scan_serial(unsigned long node, /* this function is looking for early uartlite console - Microblazespecific */
int__initearly_uartlite_console(void)
{
- returnof_scan_flat_dt(early_init_dt_scan_serial, NULL);
+ returnbe32_to_cpu(of_scan_flat_dt(early_init_dt_scan_serial, NULL));
of_scan_flat_dtreturns a rc that should already by in cpu endianess.of_scan_flat_dtneeds to be fixed instead.
Quoted 1 line
It is easy to do it. I will generate patch for it. It is in
drivers/of/fdt.c
Oops, I told you the wrong thing. the fix needs to be made in early_init_dt_scan_serial(). of_scan_flat_dt() is just fine.
Quoted 32 lines
Quoted 15 lines
arch/microblaze/kernel/vmlinux.lds.S +4
-0@@ -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; +#endifQuoted 2 lines
I comment would go nicely hear to explain to reviewers what this is about.
1. It is the same what ARM and MIPS (maybe other) have.
2. Look at this example
Store 64 bit value ("0x1234567890abcdef") on little and big endian.a) big endian
it is just copying values to the memory.0x0=0x123456780x4=0x90abcdefAddress 0 is start of
jiffies_64
and you just want to point on the last (smallest) 32 bit which is on offset0x4- which is jiffies.
Quoted 8 lines
b) little endian
The same case for little endian0x0=0xefcdab900x4=0x78563412Address 0 is start of
jiffies_64
and you just want to point on the last (smallest) 32 bit which is on offset0x0- which is jiffies.
Ah, okay. jiffies_64 is a pointer (I couldn't be bothered to look at the definition of jiffies it in context).
g.
Re: [PATCH 5/7] microblaze: Add PVR for endians plus detection
In reply to Michal SimekQuoted 11 lines · Michal Simek
Upcomming microblaze version will support little-endian.
Signed-off-by Michal Simek <[email protected]>--- arch/microblaze/include/asm/cpuinfo.h | 1 + arch/microblaze/include/asm/pvr.h | 3 +++ arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c | 1 + arch/microblaze/kernel/cpu/cpuinfo-static.c | 1 + arch/microblaze/kernel/cpu/mb.c | 3 ++- arch/microblaze/platform/generic/system.dts | 1 + 6 files changed, 9 insertions(+), 1 deletions(-)
FWIW: Acked-by: Grant Likely <[email protected]>
Quoted 91 lines
arch/microblaze/include/asm/cpuinfo.h +1
-0@@ -38,6 +38,7 @@ struct cpuinfo {u32 use_exc;u32 ver_code;u32 mmu; +u32 endian;/* CPU caches */ u32 use_icache;arch/microblaze/include/asm/pvr.h +3
-0@@ -32,6 +32,7 @@ struct pvr_s {#define PVR0_USE_DCACHE_MASK 0x01000000#define PVR0_USE_MMU 0x00800000#define PVR0_USE_BTC 0x00400000 +#define PVR0_ENDI 0x00200000#define PVR0_VERSION_MASK 0x0000FF00#define PVR0_USER1_MASK 0x000000FF@@ -209,6 +210,8 @@ struct pvr_s {#define PVR_MMU_TLB_ACCESS (pvr) (pvr.pvr[11] & PVR11_MMU_TLB_ACCESS)#define PVR_MMU_ZONES (pvr) (pvr.pvr[11] & PVR11_MMU_ZONES) +/* endian */ +#define PVR_ENDIAN (pvr) (pvr.pvr[0] & PVR0_ENDI)int cpu_has_pvr (void );void get_pvr (struct pvr_s *pvr);arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c +1
-0@@ -72,6 +72,7 @@ void set_cpuinfo_pvr_full(struct cpuinfo *ci, struct device_node *cpu)CI (pvr_user2,USER2 );CI (mmu,USE_MMU ); +CI (endian,ENDIAN );CI (use_icache,USE_ICACHE );CI (icache_tagbits,ICACHE_ADDR_TAG_BITS );arch/microblaze/kernel/cpu/cpuinfo-static.c +1
-0@@ -119,6 +119,7 @@ void __init set_cpuinfo_static(struct cpuinfo *ci, struct device_node *cpu) ci->pvr_user2 =fcpu (cpu,"xlnx,pvr-user2" ); ci->mmu =fcpu (cpu,"xlnx,use-mmu" ); + ci->endian =fcpu (cpu,"xlnx,endianness" ); ci->ver_code =0 ; ci->fpga_family_code =0 ;arch/microblaze/kernel/cpu/mb.c +2
-1@@ -51,11 +51,12 @@ static int show_cpuinfo(struct seq_file *m, void *v) count = seq_printf(m, "CPU-Family: MicroBlaze\n" "FPGA-Arch: %s\n" - "CPU-Ver: %s\n" + "CPU-Ver: %s, %s endian\n" "CPU-MHz: %d.%02d\n" "BogoMips: %lu.%02lu\n", fpga_family, cpu_ver, + cpuinfo.endian ? "little" : "big", cpuinfo.cpu_clock_freq / 1000000, cpuinfo.cpu_clock_freq %arch/microblaze/platform/generic/system.dts +1
-0@@ -85,6 +85,7 @@ xlnx,dynamic-bus-sizing = <0x1>; xlnx,edge-is-positive = <0x1>; xlnx,family = "virtex5"; + xlnx,endianness = <0x1>; xlnx,fpu-exception = <0x1>; xlnx,fsl-data-size = <0x20>; xlnx,fsl-exception = <0x0>;Signature · 1 line
1.5.5.1
Re: [PATCH 4/7] net: emaclite: Add support for little-endian platforms
In reply to Michal SimekQuoted 10 lines · Michal Simek
Upcomming Microblaze is little endian that's why is necessary to fix protocol and length loading.
Signed-off-by Michal Simek <[email protected]>CC "David S. Miller" <[email protected]>CC Grant Likely <[email protected]>CC Eric Dumazet <[email protected]>
This should go via davem, but it looks correct to me.
Quoted 34 lines
--- drivers/net/xilinx_emaclite.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)drivers/net/xilinx_emaclite.c +4
-4@@ -430,8 +430,8 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data) }/* Get the protocol type of the ethernet frame that arrived */ - proto_type = ((in_be32 (addr +XEL_HEADER_OFFSET + -XEL_RXBUFF_OFFSET ) >>XEL_HEADER_SHIFT ) & + proto_type = ((ntohl (in_be32 (addr +XEL_HEADER_OFFSET + +XEL_RXBUFF_OFFSET )) >>XEL_HEADER_SHIFT ) &XEL_RPLR_LENGTH_MASK );/* Check if received ethernet frame is a raw ethernet frame @@ -439,9 +439,9 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)if (proto_type > (ETH_FRAME_LEN +ETH_FCS_LEN )) {if (proto_type ==ETH_P_IP ) { - length = ((in_be32 (addr + + length = ((ntohl (in_be32 (addr +XEL_HEADER_IP_LENGTH_OFFSET + -XEL_RXBUFF_OFFSET ) >> +XEL_RXBUFF_OFFSET )) >>XEL_HEADER_SHIFT ) &XEL_RPLR_LENGTH_MASK ); length +=ETH_HLEN +ETH_FCS_LEN ;Signature · 1 line
1.5.5.1
Re: [PATCH 4/7] net: emaclite: Add support for little-endian platforms
From: Grant Likely <[email protected]>
Date: Wed, 29 Sep 2010 15:11:46 +0900
Quoted 12 lines · Michal Simek
Quoted 10 lines
Upcomming Microblaze is little endian that's why is necessary to fix protocol and length loading.
Signed-off-by Michal Simek <[email protected]>CC "David S. Miller" <[email protected]>CC Grant Likely <[email protected]>CC Eric Dumazet <[email protected]>
Quoted 3 lines
This should go via davem, but it looks correct to me.
Acked-by Grant Likely <[email protected]>
It doesn't need to, the microblaze guys can integrate this directly:
Michal Simek
maintainerRe: [PATCH 4/7] net: emaclite: Add support for little-endian platforms
Quoted 14 lines · David Miller
From: Grant Likely <grant.likely-s3s/[email protected]>
Date: Wed, 29 Sep 2010 15:11:46 +0900Quoted 11 lines · Michal Simek
Quoted 10 lines
Upcomming Microblaze is little endian that's why is necessary to fix protocol and length loading.
Signed-off-by Michal Simek <[email protected]>CC "David S. Miller" <davem-fT/PcQaiUtIeIZ0/[email protected]>CC Grant Likely <grant.likely-s3s/[email protected]>CC Eric Dumazet <[email protected]>CC devicetree-discuss-uLR06cmDAlY/[email protected]
Quoted 7 lines
Quoted 3 lines
This should go via davem, but it looks correct to me.
It doesn't need to, the microblaze guys can integrate this directly:
Thanks for ACKs. I will add them and will take care about it.
Michal
Signature · 4 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/ Microblaze U-BOOT custodian
Grant Likely
AppliedRe: [PATCH 3/7] of: Fix uart16550 initialization on little-endian systems
In reply to Michal SimekQuoted 8 lines · Michal Simek
Convert values from big-endian to cpu-endian.
Signed-off-by Michal Simek <[email protected]>CC Grant Likely <grant.likely-s3s/[email protected]>CC "David S. Miller" <davem-fT/PcQaiUtIeIZ0/[email protected]>CC Tejun Heo <[email protected]>CC devicetree-discuss-uLR06cmDAlY/[email protected]
Applied, thanks.
g.
Quoted 63 lines
--- drivers/serial/of_serial.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-)drivers/serial/of_serial.c +10
-7@@ -31,17 +31,19 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev, {struct resource resource;struct device_node *np = ofdev->dev.of_node; -const unsigned int *clk, *spd; +const unsigned int *spd; +unsigned int clk;const u32 *prop;int ret, prop_size;memset (port,0 ,sizeof *port); spd =of_get_property (np,"current-speed" ,NULL ); - clk =of_get_property (np,"clock-frequency" ,NULL ); -if (!clk) { + prop =of_get_property (np,"clock-frequency" ,NULL ); +if (!prop) {dev_warn (&ofdev->dev,"no clock-frequency property set\n" );return -ENODEV ; } + clk =be32_to_cpup (prop); ret =of_address_to_resource (np,0 , &resource);if (ret) {@@ -55,23 +57,24 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,/* Check for shifted address mapping */ prop =of_get_property (np,"reg-offset" , &prop_size);if (prop && (prop_size ==sizeof (u32))) - port->mapbase += *prop; + port->mapbase +=be32_to_cpup (prop);/* Check for registers offset within the devices address range */ prop =of_get_property (np,"reg-shift" , &prop_size);if (prop && (prop_size ==sizeof (u32))) - port->regshift = *prop; + port->regshift =be32_to_cpup (prop); port->irq =irq_of_parse_and_map (np,0 ); port->iotype =UPIO_MEM ; port->type = type; - port->uartclk = *clk; + port->uartclk = clk; port->flags =UPF_SHARE_IRQ |UPF_BOOT_AUTOCONF |UPF_IOREMAP |UPF_FIXED_PORT |UPF_FIXED_TYPE ; port->dev = &ofdev->dev; +/* If current-speed was set, then try not to change it. */ if (spd) - port->custom_divisor = *clk / (16 * (*spd)); + port->custom_divisor = clk / (16 *be32_to_cpup (spd));return 0 ; }Signature · 1 line
1.5.5.1
Grant Likely
AppliedRe: [PATCH 2/7] of: MTD: Fix OF probing on little-endian systems
In reply to Michal SimekQuoted 9 lines · Michal Simek
Convert big-endian DTB to little-endian if necessary.
Signed-off-by Michal Simek <[email protected]>CC David Woodhouse <[email protected]>CC Tejun Heo <[email protected]>CC Grant Likely <grant.likely-s3s/[email protected]>CC devicetree-discuss-uLR06cmDAlY/[email protected]
Applied, thanks.
g.
Quoted 36 lines
--- drivers/mtd/maps/physmap_of.c | 2 +- drivers/mtd/ofpart.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)drivers/mtd/maps/physmap_of.c +1
-1@@ -294,7 +294,7 @@ static int __devinit of_flash_probe(struct platform_device *dev, info->list[i].map.name =dev_name (&dev->dev); info->list[i].map.phys = res.start; info->list[i].map.size = res_size; - info->list[i].map.bankwidth = *width; + info->list[i].map.bankwidth =be32_to_cpup (width); err = -ENOMEM ; info->list[i].map.virt = ioremap(info->list[i].map.phys,drivers/mtd/ofpart.c +2
-2@@ -53,8 +53,8 @@ int __devinit of_mtd_parse_partitions(struct device *dev,continue ; } - (*pparts)[i].offset = reg[0 ]; - (*pparts)[i].size = reg[1 ]; + (*pparts)[i].offset =be32_to_cpu (reg[0 ]); + (*pparts)[i].size =be32_to_cpu (reg[1 ]); partname =of_get_property (pp,"label" , &len);if (!partname)Signature · 1 line
1.5.5.1
Grant Likely
AppliedRe: [PATCH 1/7] of: GPIO: Fix OF probing on little-endian systems
In reply to Michal SimekQuoted 9 lines · Michal Simek
DTB is always big-endian that's why is necessary
to convert it.Signed-off-by Michal Simek <[email protected]>CC Grant Likely <grant.likely-s3s/[email protected]>CC Tejun Heo <[email protected]>CC Anton Vorontsov <[email protected]>CC devicetree-discuss-uLR06cmDAlY/[email protected]
Applied, thanks.
g.
Quoted 36 lines
--- drivers/gpio/xilinx_gpio.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)drivers/gpio/xilinx_gpio.c +3
-3@@ -171,13 +171,13 @@ static int __devinit xgpio_of_probe(struct device_node *np)/* Update GPIO state shadow register with default value */ tree_info =of_get_property (np,"xlnx,dout-default" ,NULL );if (tree_info) - chip->gpio_state = *tree_info; + chip->gpio_state =be32_to_cpup (tree_info);/* Update GPIO direction shadow register with default value */ chip->gpio_dir =0xFFFFFFFF ;/* By default, all pins are inputs */ tree_info =of_get_property (np,"xlnx,tri-default" ,NULL );if (tree_info) - chip->gpio_dir = *tree_info; + chip->gpio_dir =be32_to_cpup (tree_info);/* Check device node and parent device node for device width */ chip->mmchip.gc.ngpio =32 ;/* By default assume full GPIO controller */ @@ -186,7 +186,7 @@ static int __devinit xgpio_of_probe(struct device_node *np) tree_info =of_get_property (np->parent,"xlnx,gpio-width" ,NULL );if (tree_info) - chip->mmchip.gc.ngpio = *tree_info; + chip->mmchip.gc.ngpio =be32_to_cpup (tree_info);spin_lock_init (&chip->gpio_lock);Signature · 1 line
1.5.5.1
Quoted 10 lines · Michal Simek
Hi everybody,
here is the first bunch of patches which is necessary to apply to get microblaze little-endian AXI version work.
All patches are placed in microblaze-next branch and they are also merged to linux-next branch.
Grant: I would like to ask you if you can please take a look at little-endian driver changes.
[cc'ing sfr re: pending linux-next merge conflict]
Hi Michal,
Can you please remove the following patches from your linux-next branch:
of: GPIO: Fix OF probing on little-endian systems
of: MTD: Fix OF probing on little-endian systems
of: Fix uart16550 initialization on little-endian systems
The emaclite patch can stay since it has a proper acked-by from both davem and I.
I had picked up all three, and then later replaced the of_serial patch with a better one. However, because it is also in your tree it will cause a linux-next conflict when Stephen tries to merge.
For device tree patches that touch code outside of arch/microblaze, I would like them to not show up in linux-next before I've acked them to avoid this exact problem. I don't have a problem with device tree patches going in via another tree, but I need to know about it so that I can keep things coordinated.
Stephen, when/if you see the conflict, please take the copy of of_serial.c from my tree.
Thanks,
g.
Michal Simek
maintainerQuoted 14 lines · Grant Likely
Quoted 10 lines · Michal Simek
Hi everybody,
here is the first bunch of patches which is necessary to apply to get microblaze little-endian AXI version work.
All patches are placed in microblaze-next branch and they are also merged to linux-next branch.
Grant: I would like to ask you if you can please take a look at little-endian driver changes.
[cc'ing sfr re: pending linux-next merge conflict]
Quoted 7 lines
Hi Michal,
Can you please remove the following patches from your linux-next branch:
of: GPIO: Fix OF probing on little-endian systems
of: MTD: Fix OF probing on little-endian systems
of: Fix uart16550 initialization on little-endian systems
Removed from microblaze-next branch.
Regards,
Michal
Signature · 4 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/ Microblaze U-BOOT custodian