Stefan Roese | 4f14ed6 | 2007-10-05 17:07:50 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2007 |
| 3 | * Stefan Roese, DENX Software Engineering, sr@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
Stefan Roese | 4f14ed6 | 2007-10-05 17:07:50 +0200 | [diff] [blame] | 24 | #include <common.h> |
| 25 | #include <watchdog.h> |
| 26 | #include <command.h> |
| 27 | #include <asm/cache.h> |
| 28 | #include <ppc4xx.h> |
| 29 | |
| 30 | #if defined(CONFIG_OF_LIBFDT) |
| 31 | #include <libfdt.h> |
| 32 | #include <libfdt_env.h> |
Stefan Roese | 1362888 | 2007-12-13 14:52:53 +0100 | [diff] [blame] | 33 | #include <fdt_support.h> |
Stefan Roese | 24bfedb | 2008-04-22 12:20:32 +0200 | [diff] [blame] | 34 | #include <asm/4xx_pcie.h> |
Stefan Roese | 4f14ed6 | 2007-10-05 17:07:50 +0200 | [diff] [blame] | 35 | |
Stefan Roese | f10493c | 2007-10-23 11:31:05 +0200 | [diff] [blame] | 36 | DECLARE_GLOBAL_DATA_PTR; |
| 37 | |
Stefan Roese | 24bfedb | 2008-04-22 12:20:32 +0200 | [diff] [blame] | 38 | /* |
| 39 | * Fixup all PCIe nodes by setting the device_type property |
| 40 | * to "pci-endpoint" instead is "pci" for endpoint ports. |
| 41 | * This property will get checked later by the Linux driver |
| 42 | * to properly configure the PCIe port in Linux (again). |
| 43 | */ |
| 44 | void fdt_pcie_setup(void *blob) |
| 45 | { |
| 46 | const char *compat = "ibm,plb-pciex"; |
| 47 | const char *prop = "device_type"; |
| 48 | const char *prop_val = "pci-endpoint"; |
| 49 | const u32 *port; |
| 50 | int no; |
| 51 | int rc; |
| 52 | |
| 53 | /* Search first PCIe node */ |
| 54 | no = fdt_node_offset_by_compatible(blob, -1, compat); |
| 55 | while (no != -FDT_ERR_NOTFOUND) { |
| 56 | port = fdt_getprop(blob, no, "port", NULL); |
| 57 | if (port == NULL) { |
| 58 | printf("WARNING: could not find port property\n"); |
| 59 | } else { |
| 60 | if (is_end_point(*port)) { |
| 61 | rc = fdt_setprop(blob, no, prop, prop_val, |
| 62 | strlen(prop_val) + 1); |
| 63 | if (rc < 0) |
| 64 | printf("WARNING: could not set %s for %s: %s.\n", |
| 65 | prop, compat, fdt_strerror(rc)); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | /* Jump to next PCIe node */ |
| 70 | no = fdt_node_offset_by_compatible(blob, no, compat); |
| 71 | } |
| 72 | } |
| 73 | |
Stefan Roese | 4f14ed6 | 2007-10-05 17:07:50 +0200 | [diff] [blame] | 74 | void ft_cpu_setup(void *blob, bd_t *bd) |
| 75 | { |
Stefan Roese | 4f14ed6 | 2007-10-05 17:07:50 +0200 | [diff] [blame] | 76 | sys_info_t sys_info; |
Stefan Roese | 4f14ed6 | 2007-10-05 17:07:50 +0200 | [diff] [blame] | 77 | |
Stefan Roese | 1362888 | 2007-12-13 14:52:53 +0100 | [diff] [blame] | 78 | get_sys_info(&sys_info); |
Stefan Roese | 4f14ed6 | 2007-10-05 17:07:50 +0200 | [diff] [blame] | 79 | |
Stefan Roese | 328a340 | 2007-12-18 08:44:51 +0100 | [diff] [blame] | 80 | do_fixup_by_prop_u32(blob, "device_type", "cpu", 4, "timebase-frequency", |
| 81 | bd->bi_intfreq, 1); |
| 82 | do_fixup_by_prop_u32(blob, "device_type", "cpu", 4, "clock-frequency", |
| 83 | bd->bi_intfreq, 1); |
Stefan Roese | 1362888 | 2007-12-13 14:52:53 +0100 | [diff] [blame] | 84 | do_fixup_by_path_u32(blob, "/plb", "clock-frequency", sys_info.freqPLB, 1); |
| 85 | do_fixup_by_path_u32(blob, "/plb/opb", "clock-frequency", sys_info.freqOPB, 1); |
| 86 | do_fixup_by_path_u32(blob, "/plb/opb/ebc", "clock-frequency", |
| 87 | sys_info.freqEBC, 1); |
| 88 | fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize); |
Stefan Roese | 4f14ed6 | 2007-10-05 17:07:50 +0200 | [diff] [blame] | 89 | |
| 90 | /* |
| 91 | * Setup all baudrates for the UARTs |
| 92 | */ |
Stefan Roese | 1362888 | 2007-12-13 14:52:53 +0100 | [diff] [blame] | 93 | do_fixup_by_compat_u32(blob, "ns16550", "clock-frequency", gd->uart_clk, 1); |
Stefan Roese | 4f14ed6 | 2007-10-05 17:07:50 +0200 | [diff] [blame] | 94 | |
Stefan Roese | 4f14ed6 | 2007-10-05 17:07:50 +0200 | [diff] [blame] | 95 | /* |
Stefan Roese | 871e6ce | 2007-12-14 08:41:29 +0100 | [diff] [blame] | 96 | * Fixup all ethernet nodes |
| 97 | * Note: aliases in the dts are required for this |
Stefan Roese | 4f14ed6 | 2007-10-05 17:07:50 +0200 | [diff] [blame] | 98 | */ |
Stefan Roese | 1362888 | 2007-12-13 14:52:53 +0100 | [diff] [blame] | 99 | fdt_fixup_ethernet(blob, bd); |
Stefan Roese | 24bfedb | 2008-04-22 12:20:32 +0200 | [diff] [blame] | 100 | |
| 101 | /* |
| 102 | * Fixup all available PCIe nodes by setting the device_type property |
| 103 | */ |
| 104 | fdt_pcie_setup(blob); |
Stefan Roese | 4f14ed6 | 2007-10-05 17:07:50 +0200 | [diff] [blame] | 105 | } |
| 106 | #endif /* CONFIG_OF_LIBFDT */ |