* [PATCH 0/4] MIPS: XBurst: fix the JZ4755's clocksource @ 2012-06-28 9:44 Antony Pavlov 2012-06-28 9:44 ` [PATCH 1/4] byteorder: fix {BIG,LITTLE}_ENDIAN defines Antony Pavlov ` (3 more replies) 0 siblings, 4 replies; 7+ messages in thread From: Antony Pavlov @ 2012-06-28 9:44 UTC (permalink / raw) To: barebox This patch series fixes error in JZ4755's clocksource code. First, it fixes common {BIG,LITTLE}_ENDIAN defines to make work MIPS little-endian clocksource code. Next, the patch series fixes the JZ4755's clocksource code itself. [PATCH 1/4] byteorder: fix {BIG,LITTLE}_ENDIAN defines [PATCH 2/4] clocksource: move the NSEC_PER_SEC constant to common [PATCH 3/4] MIPS: XBurst: fix the JZ4755's clocksource input [PATCH 4/4] MIPS: XBurst: use clocks_calc_mult_shift() for JZ4755's _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/4] byteorder: fix {BIG,LITTLE}_ENDIAN defines 2012-06-28 9:44 [PATCH 0/4] MIPS: XBurst: fix the JZ4755's clocksource Antony Pavlov @ 2012-06-28 9:44 ` Antony Pavlov 2012-06-28 10:19 ` Sascha Hauer 2012-06-28 9:44 ` [PATCH 2/4] clocksource: move the NSEC_PER_SEC constant to common header Antony Pavlov ` (2 subsequent siblings) 3 siblings, 1 reply; 7+ messages in thread From: Antony Pavlov @ 2012-06-28 9:44 UTC (permalink / raw) To: barebox In the Linux kernel sources the only one byteorder macro can be defined (__BIG_ENDIAN or __LITTLE_ENDIAN) at a time. In barebox we have the __BIG_ENDIAN and __LITTLE_ENDIAN macros defined simultaneously introduced in commit 9ad1fe64abb12baac918ec177d9a52bbf2980d16 Author: Baruch Siach <baruch@tkos.co.il> Date: Sun Jun 27 08:46:05 2010 +0300 byteorder: add missing {BIG,LITTLE}_ENDIAN defines This fixes build warnings when testing __BYTE_ORDER of the other kin But in arch/mips/lib/libgcc.h (from Linux) we have #ifdef __BIG_ENDIAN struct DWstruct { int high, low; }; #elif defined(__LITTLE_ENDIAN) struct DWstruct { int low, high; }; #else #error I feel sick. #endif This means that regardless of current byteorder the big-endian DWstruct will be selected. By turn this breaks the __lshrdi3() function and the clocksource code on little-endian MIPS. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> --- drivers/ata/disk_ata_drive.c | 2 +- drivers/nor/cfi_flash.c | 6 +++--- include/cramfs/cramfs_fs.h | 4 ++-- include/envfs.h | 4 ++-- include/linux/byteorder/generic.h | 7 ------- include/usb/usb.h | 2 +- scripts/compiler.h | 2 +- scripts/setupmbr/arch.h | 2 +- 8 files changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/ata/disk_ata_drive.c b/drivers/ata/disk_ata_drive.c index 4602af3..d5c5837 100644 --- a/drivers/ata/disk_ata_drive.c +++ b/drivers/ata/disk_ata_drive.c @@ -231,7 +231,7 @@ static void __maybe_unused ata_dump_id(uint16_t *id) */ static void ata_fix_endianess(uint16_t *buf, unsigned wds) { -#if __BYTE_ORDER == __BIG_ENDIAN +#ifdef __BIG_ENDIAN unsigned u; for (u = 0; u < wds; u++) diff --git a/drivers/nor/cfi_flash.c b/drivers/nor/cfi_flash.c index 654e647..02340e6 100644 --- a/drivers/nor/cfi_flash.c +++ b/drivers/nor/cfi_flash.c @@ -82,7 +82,7 @@ static void flash_add_byte (struct flash_info *info, cfiword_t * cword, uchar c) return; } -#if __BYTE_ORDER == __BIG_ENDIAN +#ifdef __BIG_ENDIAN *cword = (*cword << 8) | c; #else @@ -167,7 +167,7 @@ static void flash_printqry (struct cfi_qry *qry) uchar flash_read_uchar (struct flash_info *info, uint offset) { uchar *cp = flash_make_addr(info, 0, offset); -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifdef __LITTLE_ENDIAN return flash_read8(cp); #else return flash_read8(cp + info->portwidth - 1); @@ -195,7 +195,7 @@ static ulong flash_read_long (struct flash_info *info, flash_sect_t sect, uint o debug ("addr[%x] = 0x%x\n", x, flash_read8(addr + x)); } #endif -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifdef __LITTLE_ENDIAN retval = ((flash_read8(addr) << 16) | (flash_read8(addr + info->portwidth) << 24) | (flash_read8(addr + 2 * info->portwidth)) | diff --git a/include/cramfs/cramfs_fs.h b/include/cramfs/cramfs_fs.h index af2940b..a7e9504 100644 --- a/include/cramfs/cramfs_fs.h +++ b/include/cramfs/cramfs_fs.h @@ -88,7 +88,7 @@ struct cramfs_super { #error "No byte order defined in __BYTE_ORDER" #endif -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifdef __LITTLE_ENDIAN #define CRAMFS_16(x) (x) #define CRAMFS_24(x) (x) #define CRAMFS_32(x) (x) @@ -96,7 +96,7 @@ struct cramfs_super { #define CRAMFS_GET_OFFSET(x) ((x)->offset) #define CRAMFS_SET_OFFSET(x,y) ((x)->offset = (y)) #define CRAMFS_SET_NAMELEN(x,y) ((x)->namelen = (y)) -#elif __BYTE_ORDER ==__BIG_ENDIAN +#elif defined(__BIG_ENDIAN) #ifdef __KERNEL__ #define CRAMFS_16(x) swab16(x) #define CRAMFS_24(x) ((swab32(x)) >> 8) diff --git a/include/envfs.h b/include/envfs.h index 67b8902..c053f19 100644 --- a/include/envfs.h +++ b/include/envfs.h @@ -38,7 +38,7 @@ struct envfs_super { #error "No byte order defined in __BYTE_ORDER" #endif -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifdef __LITTLE_ENDIAN #define ENVFS_16(x) (x) #define ENVFS_24(x) (x) #define ENVFS_32(x) (x) @@ -46,7 +46,7 @@ struct envfs_super { #define ENVFS_GET_OFFSET(x) ((x)->offset) #define ENVFS_SET_OFFSET(x,y) ((x)->offset = (y)) #define ENVFS_SET_NAMELEN(x,y) ((x)->namelen = (y)) -#elif __BYTE_ORDER == __BIG_ENDIAN +#elif defined(__BIG_ENDIAN) #ifdef __KERNEL__ #define ENVFS_16(x) swab16(x) #define ENVFS_24(x) ((swab32(x)) >> 8) diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/generic.h index aab8f4b..2d68d99 100644 --- a/include/linux/byteorder/generic.h +++ b/include/linux/byteorder/generic.h @@ -78,13 +78,6 @@ * */ -#ifndef __LITTLE_ENDIAN -#define __LITTLE_ENDIAN 1234 -#endif -#ifndef __BIG_ENDIAN -#define __BIG_ENDIAN 4321 -#endif - #if defined(__KERNEL__) /* * inside the kernel, we can use nicknames; diff --git a/include/usb/usb.h b/include/usb/usb.h index f273983..e13d549 100644 --- a/include/usb/usb.h +++ b/include/usb/usb.h @@ -271,7 +271,7 @@ void usb_rescan(void); ((x_ & 0xFF000000UL) >> 24)); \ }) -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifdef __LITTLE_ENDIAN # define swap_16(x) (x) # define swap_32(x) (x) #else diff --git a/scripts/compiler.h b/scripts/compiler.h index 53f84b6..dac7d46 100644 --- a/scripts/compiler.h +++ b/scripts/compiler.h @@ -79,7 +79,7 @@ typedef uint32_t __u32; # define uswap_64(x) _uswap_64(x, ) #endif -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifdef __LITTLE_ENDIAN # define cpu_to_le16(x) (x) # define cpu_to_le32(x) (x) # define cpu_to_le64(x) (x) diff --git a/scripts/setupmbr/arch.h b/scripts/setupmbr/arch.h index a720dfe..1dc3f50 100644 --- a/scripts/setupmbr/arch.h +++ b/scripts/setupmbr/arch.h @@ -32,7 +32,7 @@ | (_x >> 56)); \ }) -#if __BYTE_ORDER == __BIG_ENDIAN +#ifdef __BIG_ENDIAN /* Our target is a ia32 machine, always little endian */ -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/4] byteorder: fix {BIG,LITTLE}_ENDIAN defines 2012-06-28 9:44 ` [PATCH 1/4] byteorder: fix {BIG,LITTLE}_ENDIAN defines Antony Pavlov @ 2012-06-28 10:19 ` Sascha Hauer 0 siblings, 0 replies; 7+ messages in thread From: Sascha Hauer @ 2012-06-28 10:19 UTC (permalink / raw) To: Antony Pavlov; +Cc: barebox Hi Antony, On Thu, Jun 28, 2012 at 01:44:46PM +0400, Antony Pavlov wrote: > In the Linux kernel sources the only one byteorder macro > can be defined (__BIG_ENDIAN or __LITTLE_ENDIAN) at a time. > > In barebox we have the __BIG_ENDIAN and __LITTLE_ENDIAN macros > defined simultaneously introduced in > > commit 9ad1fe64abb12baac918ec177d9a52bbf2980d16 > Author: Baruch Siach <baruch@tkos.co.il> > Date: Sun Jun 27 08:46:05 2010 +0300 > > byteorder: add missing {BIG,LITTLE}_ENDIAN defines > > This fixes build warnings when testing __BYTE_ORDER > of the other kin > > But in arch/mips/lib/libgcc.h (from Linux) we have > > #ifdef __BIG_ENDIAN > struct DWstruct { > int high, low; > }; > #elif defined(__LITTLE_ENDIAN) > struct DWstruct { > int low, high; > }; > #else > #error I feel sick. > #endif > > This means that regardless of current byteorder the big-endian > DWstruct will be selected. By turn this breaks the __lshrdi3() > function and the clocksource code on little-endian MIPS. Additionally I suggest to add the following to include/common.h: /* * sanity check. The Linux Kernel defines only one of __LITTLE_ENDIAN and * __BIG_ENDIAN. Endianess can then be tested with #ifdef __xx_ENDIAN. Userspace * always defined both __LITTLE_ENDIAN and __BIG_ENDIAN and byteorder can then * be tested with #if __BYTE_ORDER == __xx_ENDIAN. * * As we tend to use a lot of Kernel code in barebox we use the kernel way of * determing the byte order. Make sure here that architecture code properly * defines it. */ #include <asm/byteorder.h> #if defined __LITTLE_ENDIAN && defined __BIG_ENDIAN #error "both __LITTLE_ENDIAN and __BIG_ENDIAN are defined" #endif #if !defined __LITTLE_ENDIAN && !defined __BIG_ENDIAN #error "None of __LITTLE_ENDIAN and __BIG_ENDIAN are defined" #endif > #define CRAMFS_24(x) ((swab32(x)) >> 8) > diff --git a/include/envfs.h b/include/envfs.h > index 67b8902..c053f19 100644 > --- a/include/envfs.h > +++ b/include/envfs.h > @@ -38,7 +38,7 @@ struct envfs_super { > #error "No byte order defined in __BYTE_ORDER" > #endif > > -#if __BYTE_ORDER == __LITTLE_ENDIAN > +#ifdef __LITTLE_ENDIAN Be careful. This is also included when building the barebox env tool. Getting the endianess right is tricky. As mentioned above in Userspace we have: #define __LITTLE_ENDIAN 1234 #define __BIG_ENDIAN 4321 #define __BYTE_ORDER [__LITTLE_ENDIAN|__BIG_ENDIAN] Whereas the kernel only defines either __LITTLE_ENDIAN or __BIG_ENDIAN This means that #ifdef __LITTLE_ENDIAN in userspace will always be true regardless of the endianess. > diff --git a/scripts/compiler.h b/scripts/compiler.h > index 53f84b6..dac7d46 100644 > --- a/scripts/compiler.h > +++ b/scripts/compiler.h > @@ -79,7 +79,7 @@ typedef uint32_t __u32; > # define uswap_64(x) _uswap_64(x, ) > #endif > > -#if __BYTE_ORDER == __LITTLE_ENDIAN > +#ifdef __LITTLE_ENDIAN So this is also wrong. > # define cpu_to_le16(x) (x) > # define cpu_to_le32(x) (x) > # define cpu_to_le64(x) (x) > diff --git a/scripts/setupmbr/arch.h b/scripts/setupmbr/arch.h > index a720dfe..1dc3f50 100644 > --- a/scripts/setupmbr/arch.h > +++ b/scripts/setupmbr/arch.h > @@ -32,7 +32,7 @@ > | (_x >> 56)); \ > }) > > -#if __BYTE_ORDER == __BIG_ENDIAN > +#ifdef __BIG_ENDIAN ditto. I suggest using the following patch which should do the things I mentioned right. Sascha 8<---------------------------------------------------------- Change byte order detection mechanism to kernel style The Linux Kernel defines only one of __LITTLE_ENDIAN and __BIG_ENDIAN. Endianess can then be tested with #ifdef __xx_ENDIAN. Userspace always defined both __LITTLE_ENDIAN and __BIG_ENDIAN and byteorder can then be tested with #if __BYTE_ORDER == __xx_ENDIAN. As we tend to use a lot of Kernel code in barebox we switch to use the kernel way of determing the byte order. As this always causes a lot of confusion add a check to include/common.h to make sure only one of __LITTLE_ENDIAN and __BIG_ENDIAN is defined. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> --- drivers/ata/disk_ata_drive.c | 2 +- drivers/nor/cfi_flash.c | 10 ++++++---- include/common.h | 18 ++++++++++++++++++ include/cramfs/cramfs_fs.h | 8 ++------ include/envfs.h | 22 ++++++++++++++++++---- include/linux/byteorder/generic.h | 7 ------- include/usb/usb.h | 6 ++++-- 7 files changed, 49 insertions(+), 24 deletions(-) diff --git a/drivers/ata/disk_ata_drive.c b/drivers/ata/disk_ata_drive.c index 4602af3..d5c5837 100644 --- a/drivers/ata/disk_ata_drive.c +++ b/drivers/ata/disk_ata_drive.c @@ -231,7 +231,7 @@ static void __maybe_unused ata_dump_id(uint16_t *id) */ static void ata_fix_endianess(uint16_t *buf, unsigned wds) { -#if __BYTE_ORDER == __BIG_ENDIAN +#ifdef __BIG_ENDIAN unsigned u; for (u = 0; u < wds; u++) diff --git a/drivers/nor/cfi_flash.c b/drivers/nor/cfi_flash.c index 654e647..82c1cae 100644 --- a/drivers/nor/cfi_flash.c +++ b/drivers/nor/cfi_flash.c @@ -82,9 +82,9 @@ static void flash_add_byte (struct flash_info *info, cfiword_t * cword, uchar c) return; } -#if __BYTE_ORDER == __BIG_ENDIAN +#ifdef __BIG_ENDIAN *cword = (*cword << 8) | c; -#else +#elif defined __LITTLE_ENDIAN if (bankwidth_is_2(info)) *cword = (*cword >> 8) | (u16)c << 8; @@ -92,6 +92,8 @@ static void flash_add_byte (struct flash_info *info, cfiword_t * cword, uchar c) *cword = (*cword >> 8) | (u32)c << 24; else if (bankwidth_is_8(info)) *cword = (*cword >> 8) | (u64)c << 56; +#else +#error "could not determine byte order" #endif } @@ -167,7 +169,7 @@ static void flash_printqry (struct cfi_qry *qry) uchar flash_read_uchar (struct flash_info *info, uint offset) { uchar *cp = flash_make_addr(info, 0, offset); -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if defined __LITTLE_ENDIAN return flash_read8(cp); #else return flash_read8(cp + info->portwidth - 1); @@ -195,7 +197,7 @@ static ulong flash_read_long (struct flash_info *info, flash_sect_t sect, uint o debug ("addr[%x] = 0x%x\n", x, flash_read8(addr + x)); } #endif -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if defined __LITTLE_ENDIAN retval = ((flash_read8(addr) << 16) | (flash_read8(addr + info->portwidth) << 24) | (flash_read8(addr + 2 * info->portwidth)) | diff --git a/include/common.h b/include/common.h index d2347f8..9287a7d 100644 --- a/include/common.h +++ b/include/common.h @@ -34,6 +34,24 @@ #include <linux/stddef.h> #include <asm/common.h> +/* + * sanity check. The Linux Kernel defines only one of __LITTLE_ENDIAN and + * __BIG_ENDIAN. Endianess can then be tested with #ifdef __xx_ENDIAN. Userspace + * always defined both __LITTLE_ENDIAN and __BIG_ENDIAN and byteorder can then + * be tested with #if __BYTE_ORDER == __xx_ENDIAN. + * + * As we tend to use a lot of Kernel code in barebox we use the kernel way of + * determing the byte order. Make sure here that architecture code properly + * defines it. + */ +#include <asm/byteorder.h> +#if defined __LITTLE_ENDIAN && defined __BIG_ENDIAN +#error "both __LITTLE_ENDIAN and __BIG_ENDIAN are defined" +#endif +#if !defined __LITTLE_ENDIAN && !defined __BIG_ENDIAN +#error "None of __LITTLE_ENDIAN and __BIG_ENDIAN are defined" +#endif + #define pr_info(fmt, arg...) printf(fmt, ##arg) #define pr_notice(fmt, arg...) printf(fmt, ##arg) #define pr_err(fmt, arg...) printf(fmt, ##arg) diff --git a/include/cramfs/cramfs_fs.h b/include/cramfs/cramfs_fs.h index af2940b..8c53fc7 100644 --- a/include/cramfs/cramfs_fs.h +++ b/include/cramfs/cramfs_fs.h @@ -84,11 +84,7 @@ struct cramfs_super { | CRAMFS_FLAG_WRONG_SIGNATURE \ | CRAMFS_FLAG_SHIFTED_ROOT_OFFSET ) -#ifndef __BYTE_ORDER -#error "No byte order defined in __BYTE_ORDER" -#endif - -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifdef __LITTLE_ENDIAN #define CRAMFS_16(x) (x) #define CRAMFS_24(x) (x) #define CRAMFS_32(x) (x) @@ -96,7 +92,7 @@ struct cramfs_super { #define CRAMFS_GET_OFFSET(x) ((x)->offset) #define CRAMFS_SET_OFFSET(x,y) ((x)->offset = (y)) #define CRAMFS_SET_NAMELEN(x,y) ((x)->namelen = (y)) -#elif __BYTE_ORDER ==__BIG_ENDIAN +#elif defined __BIG_ENDIAN #ifdef __KERNEL__ #define CRAMFS_16(x) swab16(x) #define CRAMFS_24(x) ((swab32(x)) >> 8) diff --git a/include/envfs.h b/include/envfs.h index 67b8902..ba976d6 100644 --- a/include/envfs.h +++ b/include/envfs.h @@ -34,11 +34,25 @@ struct envfs_super { uint32_t sb_crc; /* crc for the superblock */ }; -#ifndef __BYTE_ORDER -#error "No byte order defined in __BYTE_ORDER" +#ifdef __BAREBOX__ +# ifdef __LITTLE_ENDIAN +# define ENVFS_ORDER_LITTLE +# elif defined __BIG_ENDIAN +# define ENVFS_ORDER_BIG +# else +# error "could not determine byte order" +# endif +#else +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define ENVFS_ORDER_LITTLE +# elif __BYTE_ORDER == __BIG_ENDIAN +# define ENVFS_ORDER_BIG +# else +# error "could not determine byte order" +# endif #endif -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifdef ENVFS_ORDER_LITTLE #define ENVFS_16(x) (x) #define ENVFS_24(x) (x) #define ENVFS_32(x) (x) @@ -46,7 +60,7 @@ struct envfs_super { #define ENVFS_GET_OFFSET(x) ((x)->offset) #define ENVFS_SET_OFFSET(x,y) ((x)->offset = (y)) #define ENVFS_SET_NAMELEN(x,y) ((x)->namelen = (y)) -#elif __BYTE_ORDER == __BIG_ENDIAN +#elif defined ENVFS_ORDER_BIG #ifdef __KERNEL__ #define ENVFS_16(x) swab16(x) #define ENVFS_24(x) ((swab32(x)) >> 8) diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/generic.h index aab8f4b..2d68d99 100644 --- a/include/linux/byteorder/generic.h +++ b/include/linux/byteorder/generic.h @@ -78,13 +78,6 @@ * */ -#ifndef __LITTLE_ENDIAN -#define __LITTLE_ENDIAN 1234 -#endif -#ifndef __BIG_ENDIAN -#define __BIG_ENDIAN 4321 -#endif - #if defined(__KERNEL__) /* * inside the kernel, we can use nicknames; diff --git a/include/usb/usb.h b/include/usb/usb.h index 296e4e8..8691400 100644 --- a/include/usb/usb.h +++ b/include/usb/usb.h @@ -270,12 +270,14 @@ void usb_rescan(void); ((x_ & 0xFF000000UL) >> 24)); \ }) -#if __BYTE_ORDER == __LITTLE_ENDIAN +#ifdef __LITTLE_ENDIAN # define swap_16(x) (x) # define swap_32(x) (x) -#else +#elif defined BIG_ENDIAN # define swap_16(x) __swap_16(x) # define swap_32(x) __swap_32(x) +#else +#error "could not determine byte order" #endif /* -- 1.7.10 -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/4] clocksource: move the NSEC_PER_SEC constant to common header 2012-06-28 9:44 [PATCH 0/4] MIPS: XBurst: fix the JZ4755's clocksource Antony Pavlov 2012-06-28 9:44 ` [PATCH 1/4] byteorder: fix {BIG,LITTLE}_ENDIAN defines Antony Pavlov @ 2012-06-28 9:44 ` Antony Pavlov 2012-06-28 9:44 ` [PATCH 3/4] MIPS: XBurst: fix the JZ4755's clocksource input frequency value Antony Pavlov 2012-06-28 9:44 ` [PATCH 4/4] MIPS: XBurst: use clocks_calc_mult_shift() for JZ4755's clocksource Antony Pavlov 3 siblings, 0 replies; 7+ messages in thread From: Antony Pavlov @ 2012-06-28 9:44 UTC (permalink / raw) To: barebox Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> --- arch/ppc/mach-mpc85xx/include/mach/clocks.h | 2 -- include/clock.h | 2 ++ include/linux/time.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/ppc/mach-mpc85xx/include/mach/clocks.h b/arch/ppc/mach-mpc85xx/include/mach/clocks.h index 9477168..2ab367b 100644 --- a/arch/ppc/mach-mpc85xx/include/mach/clocks.h +++ b/arch/ppc/mach-mpc85xx/include/mach/clocks.h @@ -10,8 +10,6 @@ struct sys_info { unsigned long freqLocalBus; }; -#define NSEC_PER_SEC 1000000000L - unsigned long fsl_get_bus_freq(ulong dummy); unsigned long fsl_get_timebase_clock(void); void fsl_get_sys_info(struct sys_info *sysInfo); diff --git a/include/clock.h b/include/clock.h index 123f874..c01a8d0 100644 --- a/include/clock.h +++ b/include/clock.h @@ -3,6 +3,8 @@ #ifndef CLOCK_H #define CLOCK_H +#include <linux/time.h> + #define CLOCKSOURCE_MASK(bits) (uint64_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1) struct clocksource { diff --git a/include/linux/time.h b/include/linux/time.h index bf12b99..a1be8fe 100644 --- a/include/linux/time.h +++ b/include/linux/time.h @@ -9,6 +9,7 @@ #define _REENT_ONLY +#define NSEC_PER_SEC 1000000000L #define SECSPERMIN 60L #define MINSPERHOUR 60L #define HOURSPERDAY 24L -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/4] MIPS: XBurst: fix the JZ4755's clocksource input frequency value 2012-06-28 9:44 [PATCH 0/4] MIPS: XBurst: fix the JZ4755's clocksource Antony Pavlov 2012-06-28 9:44 ` [PATCH 1/4] byteorder: fix {BIG,LITTLE}_ENDIAN defines Antony Pavlov 2012-06-28 9:44 ` [PATCH 2/4] clocksource: move the NSEC_PER_SEC constant to common header Antony Pavlov @ 2012-06-28 9:44 ` Antony Pavlov 2012-06-28 10:33 ` Sascha Hauer 2012-06-28 9:44 ` [PATCH 4/4] MIPS: XBurst: use clocks_calc_mult_shift() for JZ4755's clocksource Antony Pavlov 3 siblings, 1 reply; 7+ messages in thread From: Antony Pavlov @ 2012-06-28 9:44 UTC (permalink / raw) To: barebox The 40 KHz frequency value was used to parry __lshrdi3() error on little-endian MIPS because the __lshrdi3() function is used in clocksource code. The true value of the JZ4755's external clock frequency is 12 MHz. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> --- arch/mips/mach-xburst/csrc-jz4750.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/mach-xburst/csrc-jz4750.c b/arch/mips/mach-xburst/csrc-jz4750.c index f625b70..dc7135a 100644 --- a/arch/mips/mach-xburst/csrc-jz4750.c +++ b/arch/mips/mach-xburst/csrc-jz4750.c @@ -28,7 +28,7 @@ #include <io.h> #include <mach/jz4750d_regs.h> -#define JZ_TIMER_CLOCK 40000 +#define JZ_TIMER_CLOCK 24000000 static uint64_t jz4750_cs_read(void) { -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/4] MIPS: XBurst: fix the JZ4755's clocksource input frequency value 2012-06-28 9:44 ` [PATCH 3/4] MIPS: XBurst: fix the JZ4755's clocksource input frequency value Antony Pavlov @ 2012-06-28 10:33 ` Sascha Hauer 0 siblings, 0 replies; 7+ messages in thread From: Sascha Hauer @ 2012-06-28 10:33 UTC (permalink / raw) To: Antony Pavlov; +Cc: barebox On Thu, Jun 28, 2012 at 01:44:48PM +0400, Antony Pavlov wrote: > The 40 KHz frequency value was used to parry > __lshrdi3() error on little-endian MIPS because > the __lshrdi3() function is used in clocksource code. > > The true value of the JZ4755's external clock frequency is 12 MHz. 12MHz... > > -#define JZ_TIMER_CLOCK 40000 > +#define JZ_TIMER_CLOCK 24000000 or 24MHz? Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 4/4] MIPS: XBurst: use clocks_calc_mult_shift() for JZ4755's clocksource 2012-06-28 9:44 [PATCH 0/4] MIPS: XBurst: fix the JZ4755's clocksource Antony Pavlov ` (2 preceding siblings ...) 2012-06-28 9:44 ` [PATCH 3/4] MIPS: XBurst: fix the JZ4755's clocksource input frequency value Antony Pavlov @ 2012-06-28 9:44 ` Antony Pavlov 3 siblings, 0 replies; 7+ messages in thread From: Antony Pavlov @ 2012-06-28 9:44 UTC (permalink / raw) To: barebox Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> --- arch/mips/mach-xburst/csrc-jz4750.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/mips/mach-xburst/csrc-jz4750.c b/arch/mips/mach-xburst/csrc-jz4750.c index dc7135a..36e401e 100644 --- a/arch/mips/mach-xburst/csrc-jz4750.c +++ b/arch/mips/mach-xburst/csrc-jz4750.c @@ -38,12 +38,13 @@ static uint64_t jz4750_cs_read(void) static struct clocksource jz4750_cs = { .read = jz4750_cs_read, .mask = CLOCKSOURCE_MASK(32), - .shift = 10, }; static int clocksource_init(void) { - jz4750_cs.mult = clocksource_hz2mult(JZ_TIMER_CLOCK, jz4750_cs.shift); + clocks_calc_mult_shift(&jz4750_cs.mult, &jz4750_cs.shift, + JZ_TIMER_CLOCK, NSEC_PER_SEC, 10); + init_clock(&jz4750_cs); __raw_writel(TCU_OSTCSR_PRESCALE1 | TCU_OSTCSR_EXT_EN, -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-06-28 10:33 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-06-28 9:44 [PATCH 0/4] MIPS: XBurst: fix the JZ4755's clocksource Antony Pavlov 2012-06-28 9:44 ` [PATCH 1/4] byteorder: fix {BIG,LITTLE}_ENDIAN defines Antony Pavlov 2012-06-28 10:19 ` Sascha Hauer 2012-06-28 9:44 ` [PATCH 2/4] clocksource: move the NSEC_PER_SEC constant to common header Antony Pavlov 2012-06-28 9:44 ` [PATCH 3/4] MIPS: XBurst: fix the JZ4755's clocksource input frequency value Antony Pavlov 2012-06-28 10:33 ` Sascha Hauer 2012-06-28 9:44 ` [PATCH 4/4] MIPS: XBurst: use clocks_calc_mult_shift() for JZ4755's clocksource Antony Pavlov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox