mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-01 08:59:33 +00:00
* Patch by Anders Larsen, 18 Sep 2003:
allow mkimage to build and run on Cygwin-hosted systems * Patch by Frank Mller, 18 Sep 2003: use bi_intfreq instead of bi_busfreq to compute fec_mii_speed in cpu/mpc8xx/fec.c * Patch by Pantelis Antoniou, 16 Sep 2003: add tool to compute fileds in the PLPRCR register for MPC86x
This commit is contained in:
parent
d9a405aaf6
commit
ef1464cc01
7 changed files with 245 additions and 16 deletions
10
CHANGELOG
10
CHANGELOG
|
@ -2,6 +2,16 @@
|
||||||
Changes for U-Boot 1.0.0:
|
Changes for U-Boot 1.0.0:
|
||||||
======================================================================
|
======================================================================
|
||||||
|
|
||||||
|
* Patch by Anders Larsen, 18 Sep 2003:
|
||||||
|
allow mkimage to build and run on Cygwin-hosted systems
|
||||||
|
|
||||||
|
* Patch by Frank Müller, 18 Sep 2003:
|
||||||
|
use bi_intfreq instead of bi_busfreq to compute fec_mii_speed in
|
||||||
|
cpu/mpc8xx/fec.c
|
||||||
|
|
||||||
|
* Patch by Pantelis Antoniou, 16 Sep 2003:
|
||||||
|
add tool to compute fileds in the PLPRCR register for MPC86x
|
||||||
|
|
||||||
* Use IH_TYPE_FILESYSTEM for TRAB "disk" images.
|
* Use IH_TYPE_FILESYSTEM for TRAB "disk" images.
|
||||||
|
|
||||||
* Fix build problems under FreeBSD
|
* Fix build problems under FreeBSD
|
||||||
|
|
|
@ -348,7 +348,7 @@ static int fec_init(struct eth_device* dev, bd_t * bd)
|
||||||
* This MDC frequency is equal to system clock / (2 * MII_SPEED).
|
* This MDC frequency is equal to system clock / (2 * MII_SPEED).
|
||||||
* Then MII_SPEED = system_clock / 2 * 2,5 Mhz.
|
* Then MII_SPEED = system_clock / 2 * 2,5 Mhz.
|
||||||
*/
|
*/
|
||||||
fecp->fec_mii_speed = ((bd->bi_busfreq + 4999999) / 5000000) << 1;
|
fecp->fec_mii_speed = ((bd->bi_intfreq + 4999999) / 5000000) << 1;
|
||||||
|
|
||||||
#if !defined(CONFIG_ICU862) && !defined(CONFIG_IAD210)
|
#if !defined(CONFIG_ICU862) && !defined(CONFIG_IAD210)
|
||||||
/* Configure all of port D for MII.
|
/* Configure all of port D for MII.
|
||||||
|
@ -612,7 +612,7 @@ void mii_init (void)
|
||||||
* This MDC frequency is equal to system clock / (2 * MII_SPEED).
|
* This MDC frequency is equal to system clock / (2 * MII_SPEED).
|
||||||
* Then MII_SPEED = system_clock / 2 * 2,5 Mhz.
|
* Then MII_SPEED = system_clock / 2 * 2,5 Mhz.
|
||||||
*/
|
*/
|
||||||
fecp->fec_mii_speed = ((bd->bi_busfreq + 4999999) / 5000000) << 1;
|
fecp->fec_mii_speed = ((bd->bi_intfreq + 4999999) / 5000000) << 1;
|
||||||
|
|
||||||
#if !defined(CONFIG_ICU862) && !defined(CONFIG_IAD210)
|
#if !defined(CONFIG_ICU862) && !defined(CONFIG_IAD210)
|
||||||
/* Configure all of port D for MII.
|
/* Configure all of port D for MII.
|
||||||
|
|
|
@ -43,13 +43,6 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
|
||||||
#include <sys/types.h>
|
|
||||||
typedef unsigned long int uint32_t;
|
|
||||||
typedef unsigned short uint16_t;
|
|
||||||
typedef unsigned char uint8_t;
|
|
||||||
#endif /* __CYGWIN__ */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This version doesn't work for 64-bit ABIs - Erik.
|
* This version doesn't work for 64-bit ABIs - Erik.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -124,11 +124,6 @@
|
||||||
#define IH_MAGIC 0x27051956 /* Image Magic Number */
|
#define IH_MAGIC 0x27051956 /* Image Magic Number */
|
||||||
#define IH_NMLEN 32 /* Image Name Length */
|
#define IH_NMLEN 32 /* Image Name Length */
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
|
||||||
typedef unsigned long uint32_t;
|
|
||||||
typedef unsigned char uint8_t;
|
|
||||||
#endif /* __CYGWIN__ */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* all data in network byte order (aka natural aka bigendian)
|
* all data in network byte order (aka natural aka bigendian)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,6 +30,12 @@ BINS += inca-swap-bytes$(SFX)
|
||||||
OBJS += inca-swap-bytes.o
|
OBJS += inca-swap-bytes.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Don't build by default
|
||||||
|
#ifeq ($(ARCH),ppc)
|
||||||
|
#BINS += mpc86x_clk$(SFX)
|
||||||
|
#OBJS += mpc86x_clk.o
|
||||||
|
#endif
|
||||||
|
|
||||||
LOGO_H = $(TOPDIR)/include/bmp_logo.h
|
LOGO_H = $(TOPDIR)/include/bmp_logo.h
|
||||||
|
|
||||||
ifeq ($(LOGO_BMP),)
|
ifeq ($(LOGO_BMP),)
|
||||||
|
@ -136,6 +142,10 @@ inca-swap-bytes$(SFX): inca-swap-bytes.o
|
||||||
$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
|
||||||
$(STRIP) $@
|
$(STRIP) $@
|
||||||
|
|
||||||
|
mpc86x_clk$(SFX): mpc86x_clk.o
|
||||||
|
$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
|
||||||
|
$(STRIP) $@
|
||||||
|
|
||||||
envcrc.o: envcrc.c
|
envcrc.o: envcrc.c
|
||||||
$(CC) -g $(CFLAGS) -c $<
|
$(CC) -g $(CFLAGS) -c $<
|
||||||
|
|
||||||
|
@ -151,6 +161,9 @@ gen_eth_addr.o: gen_eth_addr.c
|
||||||
inca-swap-bytes.o: inca-swap-bytes.c
|
inca-swap-bytes.o: inca-swap-bytes.c
|
||||||
$(CC) -g $(CFLAGS) -c $<
|
$(CC) -g $(CFLAGS) -c $<
|
||||||
|
|
||||||
|
mpc86x_clk.o: mpc86x_clk.c
|
||||||
|
$(CC) -g $(CFLAGS) -c $<
|
||||||
|
|
||||||
subdirs:
|
subdirs:
|
||||||
ifeq ($(TOOLSUBDIRS),)
|
ifeq ($(TOOLSUBDIRS),)
|
||||||
@:
|
@:
|
||||||
|
|
|
@ -268,7 +268,7 @@ NXTARG: ;
|
||||||
imagefile = *argv;
|
imagefile = *argv;
|
||||||
|
|
||||||
if (lflag) {
|
if (lflag) {
|
||||||
ifd = open(imagefile, O_RDONLY);
|
ifd = open(imagefile, O_RDONLY|O_BINARY);
|
||||||
} else {
|
} else {
|
||||||
ifd = open(imagefile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666);
|
ifd = open(imagefile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666);
|
||||||
}
|
}
|
||||||
|
@ -502,7 +502,7 @@ copy_file (int ifd, const char *datafile, int pad)
|
||||||
fprintf (stderr, "Adding Image %s\n", datafile);
|
fprintf (stderr, "Adding Image %s\n", datafile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((dfd = open(datafile, O_RDONLY)) < 0) {
|
if ((dfd = open(datafile, O_RDONLY|O_BINARY)) < 0) {
|
||||||
fprintf (stderr, "%s: Can't open %s: %s\n",
|
fprintf (stderr, "%s: Can't open %s: %s\n",
|
||||||
cmdname, datafile, strerror(errno));
|
cmdname, datafile, strerror(errno));
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
|
|
218
tools/mpc86x_clk.c
Normal file
218
tools/mpc86x_clk.c
Normal file
|
@ -0,0 +1,218 @@
|
||||||
|
/*
|
||||||
|
* (C) Copyright 2003 Intracom S.A.
|
||||||
|
* Pantelis Antoniou <panto@intracom.gr>
|
||||||
|
*
|
||||||
|
* This little program makes an exhaustive search for the
|
||||||
|
* correct terms of pdf, mfi, mfn, mfd, s, dbrmo, in PLPRCR.
|
||||||
|
* The goal is to produce a gclk2 from a xin input, while respecting
|
||||||
|
* all the restrictions on their combination.
|
||||||
|
*
|
||||||
|
* Generaly you select the first row of the produced table.
|
||||||
|
*
|
||||||
|
* See file CREDITS for list of people who contributed to this
|
||||||
|
* project.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||||
|
* MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define DPREF_MIN 10000000
|
||||||
|
#define DPREF_MAX 32000000
|
||||||
|
|
||||||
|
#define DPGDCK_MAX 320000000
|
||||||
|
#define DPGDCK_MIN 160000000
|
||||||
|
|
||||||
|
#define S_MIN 0
|
||||||
|
#define S_MAX 2
|
||||||
|
|
||||||
|
#define MFI_MIN 5
|
||||||
|
#define MFI_MAX 15
|
||||||
|
|
||||||
|
#define MFN_MIN 0
|
||||||
|
#define MFN_MAX 15
|
||||||
|
|
||||||
|
#define MFD_MIN 0
|
||||||
|
#define MFD_MAX 31
|
||||||
|
|
||||||
|
#define MF_MIN 5
|
||||||
|
#define MF_MAX 15
|
||||||
|
|
||||||
|
#define PDF_MIN 0
|
||||||
|
#define PDF_MAX 15
|
||||||
|
|
||||||
|
#define GCLK2_MAX 150000000
|
||||||
|
|
||||||
|
static int calculate (int xin, int target_clock,
|
||||||
|
int ppm, int pdf, int mfi, int mfn, int mfd, int s,
|
||||||
|
int *dprefp, int *dpgdckp, int *jdbckp,
|
||||||
|
int *gclk2p, int *dbrmop)
|
||||||
|
{
|
||||||
|
unsigned int dpref, dpgdck, jdbck, gclk2, t1, t2, dbrmo;
|
||||||
|
|
||||||
|
/* valid MFI? */
|
||||||
|
if (mfi < MFI_MIN)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* valid num, denum? */
|
||||||
|
if (mfn > 0 && mfn >= mfd)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
dpref = xin / (pdf + 1);
|
||||||
|
|
||||||
|
/* valid dpef? */
|
||||||
|
if (dpref < DPREF_MIN || dpref > DPREF_MAX)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (mfn == 0) {
|
||||||
|
dpgdck = (2 * mfi * xin) / (pdf + 1) ;
|
||||||
|
dbrmo = 0;
|
||||||
|
} else {
|
||||||
|
/* 5 <= mfi + (mfn / mfd + 1) <= 15 */
|
||||||
|
t1 = mfd + 1;
|
||||||
|
t2 = mfi * t1 + mfn;
|
||||||
|
if ( MF_MIN * t1 > t2 || MF_MAX * t1 < t2)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
dpgdck = (unsigned int)(2 * (mfi * mfd + mfi + mfn) *
|
||||||
|
(unsigned int)xin) /
|
||||||
|
((mfd + 1) * (pdf + 1));
|
||||||
|
|
||||||
|
dbrmo = 10 * mfn < (mfd + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* valid dpgclk? */
|
||||||
|
if (dpgdck < DPGDCK_MIN || dpgdck > DPGDCK_MAX)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
jdbck = dpgdck >> s;
|
||||||
|
gclk2 = jdbck / 2;
|
||||||
|
|
||||||
|
/* valid gclk2 */
|
||||||
|
if (gclk2 > GCLK2_MAX)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
t1 = abs(gclk2 - target_clock);
|
||||||
|
|
||||||
|
/* XXX max 1MHz dev. in clock */
|
||||||
|
if (t1 > 1000000)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* dev within range (XXX gclk2 scaled to avoid overflow) */
|
||||||
|
if (t1 * 1000 > (unsigned int)ppm * (gclk2 / 1000))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
*dprefp = dpref;
|
||||||
|
*dpgdckp = dpgdck;
|
||||||
|
*jdbckp = jdbck;
|
||||||
|
*gclk2p = gclk2;
|
||||||
|
*dbrmop = dbrmo;
|
||||||
|
|
||||||
|
return gclk2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int conf_clock(int xin, int target_clock, int ppm)
|
||||||
|
{
|
||||||
|
int pdf, s, mfn, mfd, mfi;
|
||||||
|
int dpref, dpgdck, jdbck, gclk2, xout, dbrmo;
|
||||||
|
int found = 0;
|
||||||
|
|
||||||
|
/* integer multipliers */
|
||||||
|
for (pdf = PDF_MIN; pdf <= PDF_MAX; pdf++) {
|
||||||
|
for (mfi = MFI_MIN; mfi <= MFI_MAX; mfi++) {
|
||||||
|
for (s = 0; s <= S_MAX; s++) {
|
||||||
|
xout = calculate(xin, target_clock,
|
||||||
|
ppm, pdf, mfi, 0, 0, s,
|
||||||
|
&dpref, &dpgdck, &jdbck,
|
||||||
|
&gclk2, &dbrmo);
|
||||||
|
if (xout < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (found == 0) {
|
||||||
|
printf("pdf mfi mfn mfd s dbrmo dpref dpgdck jdbck gclk2 exact?\n");
|
||||||
|
printf("--- --- --- --- - ----- ----- ------ ----- ----- ------\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%3d %3d --- --- %1d %5d %9d %9d %9d %9d%s\n",
|
||||||
|
pdf, mfi, s, dbrmo,
|
||||||
|
dpref, dpgdck, jdbck, gclk2,
|
||||||
|
gclk2 == target_clock ? " YES" : "");
|
||||||
|
|
||||||
|
found++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* fractional multipliers */
|
||||||
|
for (pdf = PDF_MIN; pdf <= PDF_MAX; pdf++) {
|
||||||
|
for (mfi = MFI_MIN; mfi <= MFI_MAX; mfi++) {
|
||||||
|
for (mfn = 1; mfn <= MFN_MAX; mfn++) {
|
||||||
|
for (mfd = 1; mfd <= MFD_MAX; mfd++) {
|
||||||
|
for (s = 0; s <= S_MAX; s++) {
|
||||||
|
xout = calculate(xin, target_clock,
|
||||||
|
ppm, pdf, mfi, mfn, mfd, s,
|
||||||
|
&dpref, &dpgdck, &jdbck,
|
||||||
|
&gclk2, &dbrmo);
|
||||||
|
if (xout < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (found == 0) {
|
||||||
|
printf("pdf mfi mfn mfd s dbrmo dpref dpgdck jdbck gclk2 exact?\n");
|
||||||
|
printf("--- --- --- --- - ----- ----- ------ ----- ----- ------\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%3d %3d %3d %3d %1d %5d %9d %9d %9d %9d%s\n",
|
||||||
|
pdf, mfi, mfn, mfd, s,
|
||||||
|
dbrmo, dpref, dpgdck, jdbck, gclk2,
|
||||||
|
gclk2 == target_clock ? " YES" : "");
|
||||||
|
|
||||||
|
found++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int xin, want_gclk2, found, ppm = 100;
|
||||||
|
|
||||||
|
if (argc < 3) {
|
||||||
|
fprintf(stderr, "usage: mpc86x_clk <xin> <want_gclk2> [ppm]\n");
|
||||||
|
fprintf(stderr, " default ppm is 100\n");
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
xin = atoi(argv[1]);
|
||||||
|
want_gclk2 = atoi(argv[2]);
|
||||||
|
if (argc >= 4)
|
||||||
|
ppm = atoi(argv[3]);
|
||||||
|
|
||||||
|
found = conf_clock(xin, want_gclk2, ppm);
|
||||||
|
if (found <= 0) {
|
||||||
|
fprintf(stderr, "cannot produce gclk2 %d from xin %d\n",
|
||||||
|
want_gclk2, xin);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
Loading…
Reference in a new issue