[U-Boot-Users] [PATCH 4/4] PPC4xx: Add support for Korat PPC440EPx board
Larry Johnson
lrj at arlinx.com
Fri Nov 2 16:08:55 CET 2007
Stefan Roese wrote:
> On Friday 02 November 2007, Larry Johnson wrote:
[...]
>> diff --git a/board/korat/init.S b/board/korat/init.S
>> new file mode 100644
>> index 0000000..f44db6c
>> --- /dev/null
>> +++ b/board/korat/init.S
>> @@ -0,0 +1,123 @@
>> +/*
>> + *
>> + * 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 <ppc_asm.tmpl>
>> +#include <config.h>
>
> Please add #include <asm-ppc/mmu.h> here and remove all the following defines.
>
>> +/* General */
>> +#define TLB_VALID 0x00000200
>> +#define _256M 0x10000000
>> +
>> +/* Supported page sizes */
>> +
>> +#define SZ_1K 0x00000000
>> +#define SZ_4K 0x00000010
>> +#define SZ_16K 0x00000020
>> +#define SZ_64K 0x00000030
>> +#define SZ_256K 0x00000040
>> +#define SZ_1M 0x00000050
>> +#define SZ_8M 0x00000060
>> +#define SZ_16M 0x00000070
>> +#define SZ_256M 0x00000090
>> +
>> +/* Storage attributes */
>> +#define SA_W 0x00000800 /* Write-through */
>> +#define SA_I 0x00000400 /* Caching inhibited */
>> +#define SA_M 0x00000200 /* Memory coherence */
>> +#define SA_G 0x00000100 /* Guarded */
>> +#define SA_E 0x00000080 /* Endian */
>> +
>> +/* Access control */
>> +#define AC_X 0x00000024 /* Execute */
>> +#define AC_W 0x00000012 /* Write */
>> +#define AC_R 0x00000009 /* Read */
>> +
>> +/* Some handy macros */
>> +
>> +#define EPN(e) ((e) & 0xfffffc00)
>> +#define TLB0(epn,sz) ( (EPN((epn)) | (sz) | TLB_VALID ) )
>> +#define TLB1(rpn,erpn) ( ((rpn)&0xfffffc00) | (erpn) )
>> +#define TLB2(a) ( (a)&0x00000fbf )
>> +
>> +#define tlbtab_start\
>> + mflr r1 ;\
>> + bl 0f ;
>> +
>> +#define tlbtab_end\
>> + .long 0, 0, 0 ; \
>> +0: mflr r0 ; \
>> + mtlr r1 ; \
>> + blr ;
>> +
>> +#define tlbentry(epn,sz,rpn,erpn,attr)\
>> + .long TLB0(epn,sz),TLB1(rpn,erpn),TLB2(attr)
>> +
[...]
>> +
>> + /* take sim card reader and CF controller out of reset */
>> + *(unsigned char *)(CFG_CPLD_BASE + 0x04) = 0x80;
>
> Don't use volatile pointer access for peripheral access. Use in_be32() and
> friends instead.
>
>> + /* Configure the two Ethernet PHYs. For each PHY, configure for fiber
>> + * if the SFP module is present, and for copper if it is not present.
>> + */
>> + gpio0_ir = in32(GPIO0_IR);
>> + for (eth = 0; eth < 2; ++eth) {
>> + if (gpio0_ir & (0x00000001 << (1 - eth))) {
>> + /* SFP module not present: configure PHY for copper. */
>> + /* Set PHY to autonegotate 10 MB, 100MB, or 1 GB */
>> + *(unsigned char *)(CFG_CPLD_BASE + 0x06) |=
>> + 0x06 << (4 * eth);
>
> out_8()
>
>> + } else {
>> + /* SFP module present: configure PHY for fiber and
>> + enable output */
>> + out32(GPIO0_OR,
>> + in32(GPIO0_OR) | (0x00000001 << (4 - eth)));
>> + out32(GPIO1_OR,
>> + in32(GPIO1_OR) & ~(0x00000001 << (31 - eth)));
>
> out_be32()
>
>> + }
>> + }
>> + /* enable Ethernet: set GPIO45 and GPIO46 to 1 */
>> + out32(GPIO1_OR, in32(GPIO1_OR) | 0x00060000);
>
> out_b32()
>
>> + /* select Ethernet pins */
>> + mfsdr(SDR0_PFC1, sdr0_pfc1);
>> + sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SELECT_MASK) |
>> + SDR0_PFC1_SELECT_CONFIG_4;
>> + mfsdr(SDR0_PFC2, sdr0_pfc2);
>> + sdr0_pfc2 = (sdr0_pfc2 & ~SDR0_PFC2_SELECT_MASK) |
>> + SDR0_PFC2_SELECT_CONFIG_4;
>> + mtsdr(SDR0_PFC2, sdr0_pfc2);
>> + mtsdr(SDR0_PFC1, sdr0_pfc1);
>> +
>> + /* PCI arbiter enabled */
>> + mfsdr(sdr_pci0, reg);
>> + mtsdr(sdr_pci0, 0x80000000 | reg);
>> +
>> + return 0;
>> +}
>> +
>> +static int man_data_read(unsigned int addr)
>> +{
>> + /*
>> + * Read an octet of data from address "addr" in the manufacturer's
>> + * information serial EEPROM, or -1 on error.
>> + */
>> + u8 data[2];
>> +
>> + if (0 != i2c_probe(MAN_DATA_EEPROM_ADDR) ||
>> + 0 != i2c_read(MAN_DATA_EEPROM_ADDR, addr, 1, data, 1)) {
>> + debug("man_data_read(0x%02X) failed\n", addr);
>> + return -1;
>> + }
>> + debug("man_info_read(0x%02X) returned 0x%02X\n", addr, data[0]);
>> + return data[0];
>> +}
>> +
>> +static unsigned int man_data_field_addr(unsigned int const field)
>> +{
>> + /*
>> + * The manufacturer's information serial EEPROM contains a sequence of
>> + * zero-delimited fields. Return the starting address of field "field",
>> + * or 0 on error.
>> + */
>> + unsigned addr, i;
>> +
>> + if (0 == field || 'A' != man_data_read(0) || '\0' != man_data_read(1)) {
>> + /* Only format "A" is currently supported */
>> + return 0;
>> + }
>> + for (addr = 2, i = 1; i < field && addr < 256; ++addr) {
>> + if ('\0' == man_data_read(addr)) {
>> + ++i;
>> + }
>> + }
>> + return (addr < 256) ? addr : 0;
>> +}
>> +
>> +static char *man_data_read_field(char s[], unsigned const field,
>> + unsigned const length)
>> +{
>> + /*
>> + * Place the null-terminated contents of field "field" of length
>> + * "length" from the manufacturer's information serial EEPROM into
>> + * string "s[length + 1]" and return a pointer to s, or return 0 on
>> + * error. In either case the original contents of s[] is not preserved.
>> + */
>> + unsigned addr, i;
>> +
>> + addr = man_data_field_addr(field);
>> + if (0 == addr || addr + length >= 255) {
>> + return 0;
>> + }
>> + for (i = 0; i < length; ++i) {
>> + int const c = man_data_read(addr++);
>> +
>> + if (c <= 0) {
>> + return 0;
>> + }
>> + s[i] = (char)c;
>> + }
>> + if (0 != man_data_read(addr)) {
>> + return 0;
>> + }
>> + s[i] = '\0';
>> + return s;
>> +}
>> +
>> +static void set_serial_number(void)
>> +{
>> + /*
>> + * If the environmental variable "serial#" is not set, try to set it
>> + * from the manufacturer's information serial EEPROM.
>> + */
>> + char s[MAN_SERIAL_NO_LENGTH + 1];
>> +
>> + if (0 == getenv("serial#") &&
>> + 0 != man_data_read_field(s, MAN_SERIAL_NO_FIELD,
>> + MAN_SERIAL_NO_LENGTH)) {
>> + setenv("serial#", s);
>> + }
>> +}
>> +
>> +static void set_mac_addresses(void)
>> +{
>> + /*
>> + * If the environmental variables "ethaddr" and/or "eth1addr" are not
>> + * set, try to set them from the manufacturer's information serial
>> + * EEPROM.
>> + */
>> + char s[MAN_MAC_ADDR_LENGTH + 1];
>> +
>> + if (0 != getenv("ethaddr") && 0 != getenv("eth1addr")) {
>> + return;
>> + }
>> + if (0 == man_data_read_field(s, MAN_MAC_ADDR_FIELD,
>> + MAN_MAC_ADDR_LENGTH)) {
>> + return;
>> + }
>> + if (0 == getenv("ethaddr")) {
>> + setenv("ethaddr", s);
>> + }
>> + if (0 == getenv("eth1addr")) {
>> + ++s[MAN_MAC_ADDR_LENGTH - 1];
>> + setenv("eth1addr", s);
>> + }
>
> Single line statements without braces (as mentioned earlier).
>
>> +}
>> +
[...]
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc.
>> Still grepping through log files to find problems? Stop.
>> Now Search log events and configuration files using AJAX and a browser.
>> Download your FREE copy of Splunk now >> http://get.splunk.com/
>> _______________________________________________
>> U-Boot-Users mailing list
>> U-Boot-Users at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/u-boot-users
>
> Looks good. Thanks.
>
> Best regards,
> Stefan
>
> =====================================================================
> DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
> =====================================================================
>
Hi Stefan,
I looks like your e-mail was too long for the mailing list (my original
was close to the limit) so I've edited it down and left it above for
record.
Thanks for your comments. I'll be posting updated patches soon.
-- Larry
More information about the U-Boot
mailing list