Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Scott Wood | 2fa1391 | 2007-04-16 14:34:21 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) Freescale Semiconductor, Inc. 2007 |
| 4 | * |
| 5 | * Author: Scott Wood <scottwood@freescale.com>, |
| 6 | * with some bits from older board-specific PCI initialization. |
Scott Wood | 2fa1391 | 2007-04-16 14:34:21 -0500 | [diff] [blame] | 7 | */ |
| 8 | |
Tom Rini | abb9a04 | 2024-05-18 20:20:43 -0600 | [diff] [blame] | 9 | #include <common.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 10 | #include <init.h> |
Scott Wood | 2fa1391 | 2007-04-16 14:34:21 -0500 | [diff] [blame] | 11 | #include <pci.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 12 | #include <asm/bitops.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 13 | #include <asm/global_data.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 14 | #include <linux/delay.h> |
Kim Phillips | 3c6f3b7 | 2007-07-25 19:25:28 -0500 | [diff] [blame] | 15 | |
| 16 | #if defined(CONFIG_OF_LIBFDT) |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 17 | #include <linux/libfdt.h> |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 18 | #include <fdt_support.h> |
Kim Phillips | 3c6f3b7 | 2007-07-25 19:25:28 -0500 | [diff] [blame] | 19 | #endif |
| 20 | |
Scott Wood | 2fa1391 | 2007-04-16 14:34:21 -0500 | [diff] [blame] | 21 | #include <asm/mpc8349_pci.h> |
| 22 | |
Scott Wood | 2fa1391 | 2007-04-16 14:34:21 -0500 | [diff] [blame] | 23 | #define MAX_BUSES 2 |
| 24 | |
| 25 | DECLARE_GLOBAL_DATA_PTR; |
| 26 | |
| 27 | static struct pci_controller pci_hose[MAX_BUSES]; |
| 28 | static int pci_num_buses; |
| 29 | |
Kim Phillips | 3c6f3b7 | 2007-07-25 19:25:28 -0500 | [diff] [blame] | 30 | #if defined(CONFIG_OF_LIBFDT) |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 31 | void ft_pci_setup(void *blob, struct bd_info *bd) |
Kim Phillips | 3c6f3b7 | 2007-07-25 19:25:28 -0500 | [diff] [blame] | 32 | { |
| 33 | int nodeoffset; |
Kim Phillips | 3c6f3b7 | 2007-07-25 19:25:28 -0500 | [diff] [blame] | 34 | int tmp[2]; |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 35 | const char *path; |
Kim Phillips | 3c6f3b7 | 2007-07-25 19:25:28 -0500 | [diff] [blame] | 36 | |
| 37 | if (pci_num_buses < 1) |
| 38 | return; |
| 39 | |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 40 | nodeoffset = fdt_path_offset(blob, "/aliases"); |
Kim Phillips | 3c6f3b7 | 2007-07-25 19:25:28 -0500 | [diff] [blame] | 41 | if (nodeoffset >= 0) { |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 42 | path = fdt_getprop(blob, nodeoffset, "pci0", NULL); |
| 43 | if (path) { |
| 44 | tmp[0] = cpu_to_be32(pci_hose[0].first_busno); |
| 45 | tmp[1] = cpu_to_be32(pci_hose[0].last_busno); |
| 46 | do_fixup_by_path(blob, path, "bus-range", |
| 47 | &tmp, sizeof(tmp), 1); |
Kim Phillips | 2141681 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 48 | |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 49 | tmp[0] = cpu_to_be32(gd->pci_clk); |
| 50 | do_fixup_by_path(blob, path, "clock-frequency", |
| 51 | &tmp, sizeof(tmp[0]), 1); |
| 52 | } |
Scott Wood | 2fa1391 | 2007-04-16 14:34:21 -0500 | [diff] [blame] | 53 | |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 54 | if (pci_num_buses < 2) |
| 55 | return; |
Scott Wood | 2fa1391 | 2007-04-16 14:34:21 -0500 | [diff] [blame] | 56 | |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 57 | path = fdt_getprop(blob, nodeoffset, "pci1", NULL); |
| 58 | if (path) { |
Anton Vorontsov | 7c78547 | 2009-02-19 18:20:46 +0300 | [diff] [blame] | 59 | tmp[0] = cpu_to_be32(pci_hose[1].first_busno); |
| 60 | tmp[1] = cpu_to_be32(pci_hose[1].last_busno); |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 61 | do_fixup_by_path(blob, path, "bus-range", |
| 62 | &tmp, sizeof(tmp), 1); |
Scott Wood | 2fa1391 | 2007-04-16 14:34:21 -0500 | [diff] [blame] | 63 | |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 64 | tmp[0] = cpu_to_be32(gd->pci_clk); |
| 65 | do_fixup_by_path(blob, path, "clock-frequency", |
| 66 | &tmp, sizeof(tmp[0]), 1); |
| 67 | } |
Scott Wood | 2fa1391 | 2007-04-16 14:34:21 -0500 | [diff] [blame] | 68 | } |
| 69 | } |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 70 | #endif /* CONFIG_OF_LIBFDT */ |