2023-02-22 14:43:35

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 00/17] powerpc/85xx: p2020: Create one unified machine description

This patch series unifies all P2020 boards and machine descriptions into
one generic unified P2020 machine description. With this generic machine
description, kernel can boot on any P2020-based board with correct DTS
file.

Tested on CZ.NIC Turris 1.1 board with has Freescale P2020 processor.
Kernel during booting correctly detects P2020 and prints:
[ 0.000000] Using Freescale P2020 machine description

Changes in v4:
* Added several preparatory cleanup patchs
* Minimised churn by not duplicating helpers at the first place
* Split main patch in two
* Dropped patchs 1 and 2
* Untested beyond basic build test

Changes in v3:
* Use 'if (IS_ENABLED(CONFIG_PPC_I8259))' instead of '#ifdef CONFIG_PPC_I8259'
* Simplify p2020_probe()
* Patches generated by -M and -C git options

Link to v2: https://lore.kernel.org/linuxppc-dev/[email protected]/

Changes in v2:
* Added patch "p2020: Move i8259 code into own function" (separated from the next one)
* Renamed CONFIG_P2020 to CONFIG_PPC_P2020
* Fixed descriptions

Link to v1: https://lore.kernel.org/linuxppc-dev/[email protected]/

Christophe Leroy (9):
powerpc/fsl_uli1575: Misc cleanup
powerpc/85xx: Rename setup_arch and pic_init on p1023
powerpc/85xx: Remove DBG() macro
powerpc/85xx: Remove #ifdefs CONFIG_PCI in mpc85xx_ds
powerpc/85xx: mpc85xx_{ds/rdb} compact the call to mpic_alloc()
powerpc/85xx: mpc85xx_{ds/rdb} replace BUG_ON() by WARN_ON()
powerpc/85xx: mpc85xx_{ds/rdb} replace prink by pr_xxx macro
powerpc/85xx: Remove #ifdefs CONFIG_PPC_I8259 in mpc85xx_ds
powerpc/85xx: Remove #ifdef CONFIG_QUICC_ENGINE in mpc85xx_rdb

Pali Rohár (8):
powerpc/85xx: p2020: Move all P2020 DS machine descriptions to p2020.c
powerpc/85xx: p2020: Move all P2020 RDB machine descriptions to
p2020.c
powerpc/85xx: p2020: Move i8259 code into own function
powerpc/85xx: mpc85xx_ds: Move PCI code into own file
powerpc/85xx: p2020: Unify .setup_arch and .init_IRQ callbacks
powerpc/85xx: p2020: Define just one machine description
powerpc/85xx: p2020: Enable boards by new config option
CONFIG_PPC_P2020
powerpc: dts: turris1x.dts: Remove "fsl,P2020RDB-PC" compatible string

arch/powerpc/boot/dts/turris1x.dts | 2 +-
arch/powerpc/include/asm/ppc-pci.h | 2 +
arch/powerpc/platforms/85xx/Kconfig | 22 +++-
arch/powerpc/platforms/85xx/Makefile | 5 +-
arch/powerpc/platforms/85xx/mpc85xx.h | 12 ++
arch/powerpc/platforms/85xx/mpc85xx_8259.c | 78 ++++++++++++
arch/powerpc/platforms/85xx/mpc85xx_ds.c | 133 ++-------------------
arch/powerpc/platforms/85xx/mpc85xx_mds.c | 7 --
arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 79 ++----------
arch/powerpc/platforms/85xx/mpc85xx_uli.c | 64 ++++++++++
arch/powerpc/platforms/85xx/p1023_rdb.c | 8 +-
arch/powerpc/platforms/85xx/p2020.c | 95 +++++++++++++++
arch/powerpc/platforms/fsl_uli1575.c | 6 +-
13 files changed, 301 insertions(+), 212 deletions(-)
create mode 100644 arch/powerpc/platforms/85xx/mpc85xx_8259.c
create mode 100644 arch/powerpc/platforms/85xx/mpc85xx_uli.c
create mode 100644 arch/powerpc/platforms/85xx/p2020.c

--
2.39.1



2023-02-22 14:43:50

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 07/17] powerpc/85xx: mpc85xx_{ds/rdb} replace prink by pr_xxx macro

Use pr_debug() instead of printk(KERN_DEBUG
Use pr_err() instead of printk(KERN_ERR
Use pr_info() instead of printk(KERN_INFO or printk("

Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/platforms/85xx/mpc85xx_ds.c | 6 +++---
arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 60d473d9b8ee..e995c939c14d 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -76,13 +76,13 @@ void __init mpc85xx_ds_pic_init(void)
}

if (cascade_node == NULL) {
- printk(KERN_DEBUG "Could not find i8259 PIC\n");
+ pr_debug("Could not find i8259 PIC\n");
return;
}

cascade_irq = irq_of_parse_and_map(cascade_node, 0);
if (!cascade_irq) {
- printk(KERN_ERR "Failed to map cascade interrupt\n");
+ pr_err("Failed to map cascade interrupt\n");
return;
}

@@ -140,7 +140,7 @@ static void __init mpc85xx_ds_setup_arch(void)
mpc85xx_ds_uli_init();
mpc85xx_smp_init();

- printk("MPC85xx DS board from Freescale Semiconductor\n");
+ pr_info("MPC85xx DS board from Freescale Semiconductor\n");
}

/*
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index 34b65441661e..8b0d81f0e1c9 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -92,7 +92,7 @@ static void __init mpc85xx_rdb_setup_arch(void)
#endif
#endif /* CONFIG_QUICC_ENGINE */

- printk(KERN_INFO "MPC85xx RDB board from Freescale Semiconductor\n");
+ pr_info("MPC85xx RDB board from Freescale Semiconductor\n");
}

machine_arch_initcall(p2020_rdb, mpc85xx_common_publish_devices);
--
2.39.1


2023-02-22 14:43:54

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 16/17] powerpc/85xx: p2020: Enable boards by new config option CONFIG_PPC_P2020

From: Pali Rohár <[email protected]>

Generic unified P2020 machine description which supports all P2020-based
boards is now in separate file p2020.c. So create a separate config option
CONFIG_PPC_P2020 for it.

Previously machine descriptions for P2020 boards were enabled by
CONFIG_MPC85xx_DS or CONFIG_MPC85xx_RDB option. So set CONFIG_PPC_P2020 to
be enabled by default when one of those option is enabled.

This allows to compile support for P2020 boards without need to have
enabled support for older mpc85xx boards. And to compile kernel for old
mpc85xx boards without having enabled support for new P2020 boards.

Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/platforms/85xx/Kconfig | 22 ++++++++++++++++++----
arch/powerpc/platforms/85xx/Makefile | 5 +++--
2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
index b92cb2b4d54d..90665882143b 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -78,16 +78,16 @@ config MPC8536_DS
This option enables support for the MPC8536 DS board

config MPC85xx_DS
- bool "Freescale MPC8544 DS / MPC8572 DS / P2020 DS"
+ bool "Freescale MPC8544 DS / MPC8572 DS"
select PPC_I8259
select DEFAULT_UIMAGE
select FSL_ULI1575 if PCI
select SWIOTLB
help
- This option enables support for the MPC8544 DS, MPC8572 DS and P2020 DS boards
+ This option enables support for the MPC8544 DS and MPC8572 DS boards

config MPC85xx_RDB
- bool "Freescale P102x MBG/UTM/RDB and P2020 RDB"
+ bool "Freescale P102x MBG/UTM/RDB"
select PPC_I8259
select DEFAULT_UIMAGE
select FSL_ULI1575 if PCI
@@ -95,7 +95,21 @@ config MPC85xx_RDB
help
This option enables support for the P1020 MBG PC, P1020 UTM PC,
P1020 RDB PC, P1020 RDB PD, P1020 RDB, P1021 RDB PC, P1024 RDB,
- P1025 RDB, P2020 RDB and P2020 RDB PC boards
+ and P1025 RDB boards
+
+config PPC_P2020
+ bool "Freescale P2020"
+ default y if MPC85xx_DS || MPC85xx_RDB
+ select DEFAULT_UIMAGE
+ select SWIOTLB
+ imply PPC_I8259
+ imply FSL_ULI1575 if PCI
+ help
+ This option enables generic unified support for any board with the
+ Freescale P2020 processor.
+
+ For example: P2020 DS board, P2020 RDB board, P2020 RDB PC board or
+ CZ.NIC Turris 1.x boards.

config P1010_RDB
bool "Freescale P1010 RDB"
diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index 65abd5a161c0..82cf7d5b4913 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -18,13 +18,14 @@ obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o
obj-$(CONFIG_MPC8536_DS) += mpc8536_ds.o
obj8259-$(CONFIG_PPC_I8259) += mpc85xx_8259.o
objpci-$(CONFIG_PCI) += mpc85xx_uli.o
-obj-$(CONFIG_MPC85xx_DS) += mpc85xx_ds.o p2020.o $(obj8259-y) $(objpci-y)
+obj-$(CONFIG_MPC85xx_DS) += mpc85xx_ds.o $(obj8259-y) $(objpci-y)
obj-$(CONFIG_MPC85xx_MDS) += mpc85xx_mds.o
-obj-$(CONFIG_MPC85xx_RDB) += mpc85xx_rdb.o p2020.o
+obj-$(CONFIG_MPC85xx_RDB) += mpc85xx_rdb.o
obj-$(CONFIG_P1010_RDB) += p1010rdb.o
obj-$(CONFIG_P1022_DS) += p1022_ds.o
obj-$(CONFIG_P1022_RDK) += p1022_rdk.o
obj-$(CONFIG_P1023_RDB) += p1023_rdb.o
+obj-$(CONFIG_PPC_P2020) += p2020.o $(obj8259-y) $(objpci-y)
obj-$(CONFIG_TWR_P102x) += twr_p102x.o
obj-$(CONFIG_CORENET_GENERIC) += corenet_generic.o
obj-$(CONFIG_FB_FSL_DIU) += t1042rdb_diu.o
--
2.39.1


2023-02-22 14:43:57

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 04/17] powerpc/85xx: Remove #ifdefs CONFIG_PCI in mpc85xx_ds

All necessary items are declared all the time, no need to use
a #ifdef CONFIG_PCI.

Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/platforms/85xx/mpc85xx_ds.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 26257509aabf..f385cd288a76 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -99,7 +99,6 @@ void __init mpc85xx_ds_pic_init(void)
#endif /* CONFIG_PPC_I8259 */
}

-#ifdef CONFIG_PCI
static struct device_node *pci_with_uli;

static int mpc85xx_exclude_device(struct pci_controller *hose,
@@ -110,13 +109,14 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,

return PCIBIOS_SUCCESSFUL;
}
-#endif /* CONFIG_PCI */

static void __init mpc85xx_ds_uli_init(void)
{
-#ifdef CONFIG_PCI
struct device_node *node;

+ if (!IS_ENABLED(CONFIG_PCI))
+ return;
+
/* See if we have a ULI under the primary */

node = of_find_node_by_name(NULL, "uli1575");
@@ -129,7 +129,6 @@ static void __init mpc85xx_ds_uli_init(void)
break;
}
}
-#endif
}

/*
--
2.39.1


2023-02-22 14:44:03

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 10/17] powerpc/85xx: p2020: Move all P2020 DS machine descriptions to p2020.c

From: Pali Rohár <[email protected]>

This moves machine descriptions and all related code for all P2020 boards
into new p2020.c source file.
This is preparation for code de-duplication and
providing one unified machine description for all P2020 boards. In
follow-up patches would be copied functions refactored and simplified to be
specific just for P2020 boards.

Signed-off-by: Pali Rohár <[email protected]>
[chleroy: Split in two patches: one for DS, one for RDB and keep helpers out]
Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/platforms/85xx/Makefile | 2 +-
arch/powerpc/platforms/85xx/mpc85xx.h | 3 ++
arch/powerpc/platforms/85xx/mpc85xx_ds.c | 25 +---------
arch/powerpc/platforms/85xx/p2020.c | 59 ++++++++++++++++++++++++
4 files changed, 64 insertions(+), 25 deletions(-)
create mode 100644 arch/powerpc/platforms/85xx/p2020.c

diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index 260fbad7967b..1f54623db9b7 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -16,7 +16,7 @@ obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o
obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o
obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o
obj-$(CONFIG_MPC8536_DS) += mpc8536_ds.o
-obj-$(CONFIG_MPC85xx_DS) += mpc85xx_ds.o
+obj-$(CONFIG_MPC85xx_DS) += mpc85xx_ds.o p2020.o
obj-$(CONFIG_MPC85xx_MDS) += mpc85xx_mds.o
obj-$(CONFIG_MPC85xx_RDB) += mpc85xx_rdb.o
obj-$(CONFIG_P1010_RDB) += p1010rdb.o
diff --git a/arch/powerpc/platforms/85xx/mpc85xx.h b/arch/powerpc/platforms/85xx/mpc85xx.h
index cb84c5c56c36..ca8b39e6b05a 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx.h
+++ b/arch/powerpc/platforms/85xx/mpc85xx.h
@@ -15,4 +15,7 @@ extern void mpc85xx_qe_par_io_init(void);
static inline void __init mpc85xx_qe_par_io_init(void) {}
#endif

+void __init mpc85xx_ds_pic_init(void);
+void __init mpc85xx_ds_setup_arch(void);
+
#endif
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 2b3e9aecb3ad..8594862ab3a4 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -133,7 +133,7 @@ static void __init mpc85xx_ds_uli_init(void)
/*
* Setup the architecture
*/
-static void __init mpc85xx_ds_setup_arch(void)
+void __init mpc85xx_ds_setup_arch(void)
{
if (ppc_md.progress)
ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
@@ -156,7 +156,6 @@ static int __init mpc8544_ds_probe(void)

machine_arch_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
machine_arch_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
-machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices);

/*
* Called very early, device-tree isn't unflattened
@@ -166,14 +165,6 @@ static int __init mpc8572_ds_probe(void)
return !!of_machine_is_compatible("fsl,MPC8572DS");
}

-/*
- * Called very early, device-tree isn't unflattened
- */
-static int __init p2020_ds_probe(void)
-{
- return !!of_machine_is_compatible("fsl,P2020DS");
-}
-
define_machine(mpc8544_ds) {
.name = "MPC8544 DS",
.probe = mpc8544_ds_probe,
@@ -201,17 +192,3 @@ define_machine(mpc8572_ds) {
.calibrate_decr = generic_calibrate_decr,
.progress = udbg_progress,
};
-
-define_machine(p2020_ds) {
- .name = "P2020 DS",
- .probe = p2020_ds_probe,
- .setup_arch = mpc85xx_ds_setup_arch,
- .init_IRQ = mpc85xx_ds_pic_init,
-#ifdef CONFIG_PCI
- .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
- .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
-#endif
- .get_irq = mpic_get_irq,
- .calibrate_decr = generic_calibrate_decr,
- .progress = udbg_progress,
-};
diff --git a/arch/powerpc/platforms/85xx/p2020.c b/arch/powerpc/platforms/85xx/p2020.c
new file mode 100644
index 000000000000..2dfd150c6375
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/p2020.c
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Freescale P2020 board Setup
+ *
+ * Copyright 2007,2009,2012-2013 Freescale Semiconductor Inc.
+ * Copyright 2022 Pali Rohár <[email protected]>
+ */
+
+#include <linux/stddef.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/kdev_t.h>
+#include <linux/delay.h>
+#include <linux/seq_file.h>
+#include <linux/interrupt.h>
+#include <linux/of_irq.h>
+#include <linux/of_platform.h>
+#include <linux/fsl/guts.h>
+
+#include <asm/time.h>
+#include <asm/machdep.h>
+#include <asm/pci-bridge.h>
+#include <mm/mmu_decl.h>
+#include <asm/udbg.h>
+#include <asm/mpic.h>
+#include <asm/i8259.h>
+#include <asm/swiotlb.h>
+
+#include <soc/fsl/qe/qe.h>
+
+#include <sysdev/fsl_soc.h>
+#include <sysdev/fsl_pci.h>
+#include "smp.h"
+
+#include "mpc85xx.h"
+
+machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices);
+
+/*
+ * Called very early, device-tree isn't unflattened
+ */
+static int __init p2020_ds_probe(void)
+{
+ return !!of_machine_is_compatible("fsl,P2020DS");
+}
+
+define_machine(p2020_ds) {
+ .name = "P2020 DS",
+ .probe = p2020_ds_probe,
+ .setup_arch = mpc85xx_ds_setup_arch,
+ .init_IRQ = mpc85xx_ds_pic_init,
+#ifdef CONFIG_PCI
+ .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
+ .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
+#endif
+ .get_irq = mpic_get_irq,
+ .calibrate_decr = generic_calibrate_decr,
+ .progress = udbg_progress,
+};
--
2.39.1


2023-02-22 14:44:23

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 01/17] powerpc/fsl_uli1575: Misc cleanup

Use a single line for uli_exclude_device()

Add uli_exclude_device() prototype in ppc-pci.h

Remove that prototype from mpc85xx_ds.c

Make uli_pirq_to_irq[] static as it is used only in that file.

Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/include/asm/ppc-pci.h | 2 ++
arch/powerpc/platforms/85xx/mpc85xx_ds.c | 4 +---
arch/powerpc/platforms/fsl_uli1575.c | 6 +++---
3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/ppc-pci.h b/arch/powerpc/include/asm/ppc-pci.h
index f6cf0159024e..1e9a7f8b05c9 100644
--- a/arch/powerpc/include/asm/ppc-pci.h
+++ b/arch/powerpc/include/asm/ppc-pci.h
@@ -57,6 +57,8 @@ void eeh_sysfs_remove_device(struct pci_dev *pdev);

#endif /* CONFIG_EEH */

+int uli_exclude_device(struct pci_controller *hose, u_char bus, u_char devfn);
+
#define PCI_BUSNO(bdfn) ((bdfn >> 8) & 0xff)

#else /* CONFIG_PCI */
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index f8d2c97f39bd..97e441878409 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -26,6 +26,7 @@
#include <asm/mpic.h>
#include <asm/i8259.h>
#include <asm/swiotlb.h>
+#include <asm/ppc-pci.h>

#include <sysdev/fsl_soc.h>
#include <sysdev/fsl_pci.h>
@@ -107,9 +108,6 @@ void __init mpc85xx_ds_pic_init(void)
}

#ifdef CONFIG_PCI
-extern int uli_exclude_device(struct pci_controller *hose,
- u_char bus, u_char devfn);
-
static struct device_node *pci_with_uli;

static int mpc85xx_exclude_device(struct pci_controller *hose,
diff --git a/arch/powerpc/platforms/fsl_uli1575.c b/arch/powerpc/platforms/fsl_uli1575.c
index 84afae7a2561..a32f9cef7845 100644
--- a/arch/powerpc/platforms/fsl_uli1575.c
+++ b/arch/powerpc/platforms/fsl_uli1575.c
@@ -13,6 +13,7 @@
#include <linux/of_irq.h>

#include <asm/pci-bridge.h>
+#include <asm/ppc-pci.h>

#define ULI_PIRQA 0x08
#define ULI_PIRQB 0x09
@@ -36,7 +37,7 @@
#define ULI_8259_IRQ14 0x0d
#define ULI_8259_IRQ15 0x0f

-u8 uli_pirq_to_irq[8] = {
+static u8 uli_pirq_to_irq[8] = {
ULI_8259_IRQ9, /* PIRQA */
ULI_8259_IRQ10, /* PIRQB */
ULI_8259_IRQ11, /* PIRQC */
@@ -341,8 +342,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5288, hpcd_quirk_uli5288);
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5229, hpcd_quirk_uli5229);
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, 0x5288, hpcd_final_uli5288);

-int uli_exclude_device(struct pci_controller *hose,
- u_char bus, u_char devfn)
+int uli_exclude_device(struct pci_controller *hose, u_char bus, u_char devfn)
{
if (bus == (hose->first_busno + 2)) {
/* exclude Modem controller */
--
2.39.1


2023-02-22 14:45:14

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 08/17] powerpc/85xx: Remove #ifdefs CONFIG_PPC_I8259 in mpc85xx_ds

All necessary items are declared all the time, no need to use
a #ifdef CONFIG_PPC_I8259.

Refactor CONFIG_PPC_I8259 actions into a dedicated init function.

Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/platforms/85xx/mpc85xx_ds.c | 37 +++++++++++++-----------
1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index e995c939c14d..2b3e9aecb3ad 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -34,7 +34,6 @@

#include "mpc85xx.h"

-#ifdef CONFIG_PPC_I8259
static void mpc85xx_8259_cascade(struct irq_desc *desc)
{
struct irq_chip *chip = irq_desc_get_chip(desc);
@@ -45,29 +44,16 @@ static void mpc85xx_8259_cascade(struct irq_desc *desc)
}
chip->irq_eoi(&desc->irq_data);
}
-#endif /* CONFIG_PPC_I8259 */

-void __init mpc85xx_ds_pic_init(void)
+static void __init mpc85xx_8259_init(void)
{
- struct mpic *mpic;
- int flags = MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU;
-#ifdef CONFIG_PPC_I8259
struct device_node *np;
struct device_node *cascade_node = NULL;
int cascade_irq;
-#endif

- if (of_machine_is_compatible("fsl,MPC8572DS-CAMP"))
- flags |= MPIC_NO_RESET;
-
- mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC ");
-
- if (WARN_ON(!mpic))
+ if (!IS_ENABLED(CONFIG_PPC_I8259))
return;

- mpic_init(mpic);
-
-#ifdef CONFIG_PPC_I8259
/* Initialize the i8259 controller */
for_each_node_by_type(np, "interrupt-controller")
if (of_device_is_compatible(np, "chrp,iic")) {
@@ -92,7 +78,24 @@ void __init mpc85xx_ds_pic_init(void)
of_node_put(cascade_node);

irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade);
-#endif /* CONFIG_PPC_I8259 */
+}
+
+void __init mpc85xx_ds_pic_init(void)
+{
+ struct mpic *mpic;
+ int flags = MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU;
+
+ if (of_machine_is_compatible("fsl,MPC8572DS-CAMP"))
+ flags |= MPIC_NO_RESET;
+
+ mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC ");
+
+ if (WARN_ON(!mpic))
+ return;
+
+ mpic_init(mpic);
+
+ mpc85xx_8259_init();
}

static struct device_node *pci_with_uli;
--
2.39.1


2023-02-22 14:45:45

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 17/17] powerpc: dts: turris1x.dts: Remove "fsl,P2020RDB-PC" compatible string

From: Pali Rohár <[email protected]>

"fsl,P2020RDB-PC" compatible string was present in Turris 1.x DTS file just
because Linux kernel required it for proper detection of P2020 processor
during boot.

This was quite a hack as CZ.NIC Turris 1.x is not compatible with
Freescale P2020-RDB-PC board.

Now when kernel has generic unified support for boards with P2020
processors, there is no need to have this "hack" in turris1x.dts file.

So remove incorrect "fsl,P2020RDB-PC" compatible string from turris1x.dts.

Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/boot/dts/turris1x.dts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/boot/dts/turris1x.dts b/arch/powerpc/boot/dts/turris1x.dts
index e9cda34a140e..a95857de6858 100644
--- a/arch/powerpc/boot/dts/turris1x.dts
+++ b/arch/powerpc/boot/dts/turris1x.dts
@@ -15,7 +15,7 @@

/ {
model = "Turris 1.x";
- compatible = "cznic,turris1x", "fsl,P2020RDB-PC"; /* fsl,P2020RDB-PC is required for booting Linux */
+ compatible = "cznic,turris1x";

aliases {
ethernet0 = &enet0;
--
2.39.1


2023-02-22 14:46:19

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 14/17] powerpc/85xx: p2020: Unify .setup_arch and .init_IRQ callbacks

From: Pali Rohár <[email protected]>

Make just one .setup_arch and one .init_IRQ callback implementation for all
P2020 board code. This deduplicate repeated and same code.

Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/platforms/85xx/mpc85xx.h | 5 ---
arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 4 +--
arch/powerpc/platforms/85xx/p2020.c | 38 +++++++++++++++++++----
3 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/mpc85xx.h b/arch/powerpc/platforms/85xx/mpc85xx.h
index b77bb9e7e79c..0be681526a1a 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx.h
+++ b/arch/powerpc/platforms/85xx/mpc85xx.h
@@ -27,9 +27,4 @@ void __init mpc85xx_ds_uli_init(void);
static inline void __init mpc85xx_ds_uli_init(void) {}
#endif

-void __init mpc85xx_ds_pic_init(void);
-void __init mpc85xx_ds_setup_arch(void);
-void __init mpc85xx_rdb_setup_arch(void);
-void __init mpc85xx_rdb_pic_init(void);
-
#endif
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index d1f497e086ed..aee12e68e46d 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -29,7 +29,7 @@

#include "mpc85xx.h"

-void __init mpc85xx_rdb_pic_init(void)
+static void __init mpc85xx_rdb_pic_init(void)
{
struct mpic *mpic;
int flags = MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU;
@@ -48,7 +48,7 @@ void __init mpc85xx_rdb_pic_init(void)
/*
* Setup the architecture
*/
-void __init mpc85xx_rdb_setup_arch(void)
+static void __init mpc85xx_rdb_setup_arch(void)
{
if (ppc_md.progress)
ppc_md.progress("mpc85xx_rdb_setup_arch()", 0);
diff --git a/arch/powerpc/platforms/85xx/p2020.c b/arch/powerpc/platforms/85xx/p2020.c
index 1b0def607749..684ad1ea7362 100644
--- a/arch/powerpc/platforms/85xx/p2020.c
+++ b/arch/powerpc/platforms/85xx/p2020.c
@@ -34,6 +34,32 @@

#include "mpc85xx.h"

+static void __init p2020_pic_init(void)
+{
+ struct mpic *mpic;
+ int flags = MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU;
+
+ mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC ");
+
+ if (WARN_ON(!mpic))
+ return;
+
+ mpic_init(mpic);
+ mpc85xx_8259_init();
+}
+
+/*
+ * Setup the architecture
+ */
+static void __init p2020_setup_arch(void)
+{
+ swiotlb_detect_4g();
+ fsl_pci_assign_primary();
+ mpc85xx_ds_uli_init();
+ mpc85xx_smp_init();
+ mpc85xx_qe_par_io_init();
+}
+
#ifdef CONFIG_MPC85xx_DS
machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices);
#endif /* CONFIG_MPC85xx_DS */
@@ -73,8 +99,8 @@ static int __init p2020_rdb_pc_probe(void)
define_machine(p2020_ds) {
.name = "P2020 DS",
.probe = p2020_ds_probe,
- .setup_arch = mpc85xx_ds_setup_arch,
- .init_IRQ = mpc85xx_ds_pic_init,
+ .setup_arch = p2020_setup_arch,
+ .init_IRQ = p2020_pic_init,
#ifdef CONFIG_PCI
.pcibios_fixup_bus = fsl_pcibios_fixup_bus,
.pcibios_fixup_phb = fsl_pcibios_fixup_phb,
@@ -89,8 +115,8 @@ define_machine(p2020_ds) {
define_machine(p2020_rdb) {
.name = "P2020 RDB",
.probe = p2020_rdb_probe,
- .setup_arch = mpc85xx_rdb_setup_arch,
- .init_IRQ = mpc85xx_rdb_pic_init,
+ .setup_arch = p2020_setup_arch,
+ .init_IRQ = p2020_pic_init,
#ifdef CONFIG_PCI
.pcibios_fixup_bus = fsl_pcibios_fixup_bus,
.pcibios_fixup_phb = fsl_pcibios_fixup_phb,
@@ -103,8 +129,8 @@ define_machine(p2020_rdb) {
define_machine(p2020_rdb_pc) {
.name = "P2020RDB-PC",
.probe = p2020_rdb_pc_probe,
- .setup_arch = mpc85xx_rdb_setup_arch,
- .init_IRQ = mpc85xx_rdb_pic_init,
+ .setup_arch = p2020_setup_arch,
+ .init_IRQ = p2020_pic_init,
#ifdef CONFIG_PCI
.pcibios_fixup_bus = fsl_pcibios_fixup_bus,
.pcibios_fixup_phb = fsl_pcibios_fixup_phb,
--
2.39.1


2023-02-22 14:47:00

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 06/17] powerpc/85xx: mpc85xx_{ds/rdb} replace BUG_ON() by WARN_ON()

No need to BUG() in case mpic_alloc() fails. Use WARN_ON().

Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/platforms/85xx/mpc85xx_ds.c | 4 +++-
arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 1e6e89136948..60d473d9b8ee 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -62,7 +62,9 @@ void __init mpc85xx_ds_pic_init(void)

mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC ");

- BUG_ON(mpic == NULL);
+ if (WARN_ON(!mpic))
+ return;
+
mpic_init(mpic);

#ifdef CONFIG_PPC_I8259
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index 110365d7b997..34b65441661e 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -39,7 +39,9 @@ void __init mpc85xx_rdb_pic_init(void)

mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC ");

- BUG_ON(mpic == NULL);
+ if (WARN_ON(!mpic))
+ return;
+
mpic_init(mpic);
}

--
2.39.1


2023-02-22 14:47:41

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 03/17] powerpc/85xx: Remove DBG() macro

DBG() macro is defined at three places while used only
one time at one place.

Replace its only use by a pr_debug() and remove the macro.

Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/platforms/85xx/mpc85xx_ds.c | 10 +---------
arch/powerpc/platforms/85xx/mpc85xx_mds.c | 7 -------
arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 9 ---------
3 files changed, 1 insertion(+), 25 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 97e441878409..26257509aabf 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -34,14 +34,6 @@

#include "mpc85xx.h"

-#undef DEBUG
-
-#ifdef DEBUG
-#define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
-#else
-#define DBG(fmt, args...)
-#endif
-
#ifdef CONFIG_PPC_I8259
static void mpc85xx_8259_cascade(struct irq_desc *desc)
{
@@ -98,7 +90,7 @@ void __init mpc85xx_ds_pic_init(void)
return;
}

- DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
+ pr_debug("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);

i8259_init(cascade_node, 0);
of_node_put(cascade_node);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 3a2ac410af18..540ce17f0577 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -49,13 +49,6 @@

#include "mpc85xx.h"

-#undef DEBUG
-#ifdef DEBUG
-#define DBG(fmt...) udbg_printf(fmt)
-#else
-#define DBG(fmt...)
-#endif
-
#if IS_BUILTIN(CONFIG_PHYLIB)

#define MV88E1111_SCR 0x10
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index d99aba158235..b5e9a6374edb 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -29,15 +29,6 @@

#include "mpc85xx.h"

-#undef DEBUG
-
-#ifdef DEBUG
-#define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
-#else
-#define DBG(fmt, args...)
-#endif
-
-
void __init mpc85xx_rdb_pic_init(void)
{
struct mpic *mpic;
--
2.39.1


2023-02-22 14:48:30

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 02/17] powerpc/85xx: Rename setup_arch and pic_init on p1023

Avoid conflict with other functions, rename mpc85xx_rdb_setup_arch()
to p1023_rdb_setup_arch(), same for mpc85xx_rdb_pic_init().

Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/platforms/85xx/p1023_rdb.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/p1023_rdb.c b/arch/powerpc/platforms/85xx/p1023_rdb.c
index c04868eb2eb1..5d434ee96445 100644
--- a/arch/powerpc/platforms/85xx/p1023_rdb.c
+++ b/arch/powerpc/platforms/85xx/p1023_rdb.c
@@ -37,7 +37,7 @@
* Setup the architecture
*
*/
-static void __init mpc85xx_rdb_setup_arch(void)
+static void __init p1023_rdb_setup_arch(void)
{
struct device_node *np;

@@ -83,7 +83,7 @@ static void __init mpc85xx_rdb_setup_arch(void)

machine_arch_initcall(p1023_rdb, mpc85xx_common_publish_devices);

-static void __init mpc85xx_rdb_pic_init(void)
+static void __init p1023_rdb_pic_init(void)
{
struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
MPIC_SINGLE_DEST_CPU,
@@ -103,8 +103,8 @@ static int __init p1023_rdb_probe(void)
define_machine(p1023_rdb) {
.name = "P1023 RDB",
.probe = p1023_rdb_probe,
- .setup_arch = mpc85xx_rdb_setup_arch,
- .init_IRQ = mpc85xx_rdb_pic_init,
+ .setup_arch = p1023_rdb_setup_arch,
+ .init_IRQ = p1023_rdb_pic_init,
.get_irq = mpic_get_irq,
.calibrate_decr = generic_calibrate_decr,
.progress = udbg_progress,
--
2.39.1


2023-02-22 14:50:02

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 15/17] powerpc/85xx: p2020: Define just one machine description

From: Pali Rohár <[email protected]>

Combine machine descriptions and code of all P2020 boards into just one
generic unified P2020 machine description. This allows kernel to boot on
any P2020-based board with P2020 DTS file without need to patch kernel and
define a new machine description in 85xx powerpc platform directory.

Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/platforms/85xx/p2020.c | 77 ++++++-----------------------
1 file changed, 15 insertions(+), 62 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/p2020.c b/arch/powerpc/platforms/85xx/p2020.c
index 684ad1ea7362..21584d81f3d9 100644
--- a/arch/powerpc/platforms/85xx/p2020.c
+++ b/arch/powerpc/platforms/85xx/p2020.c
@@ -60,83 +60,36 @@ static void __init p2020_setup_arch(void)
mpc85xx_qe_par_io_init();
}

-#ifdef CONFIG_MPC85xx_DS
-machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices);
-#endif /* CONFIG_MPC85xx_DS */
-
-#ifdef CONFIG_MPC85xx_RDB
-machine_arch_initcall(p2020_rdb, mpc85xx_common_publish_devices);
-machine_arch_initcall(p2020_rdb_pc, mpc85xx_common_publish_devices);
-#endif /* CONFIG_MPC85xx_RDB */
+machine_arch_initcall(p2020, mpc85xx_common_publish_devices);

/*
* Called very early, device-tree isn't unflattened
*/
-#ifdef CONFIG_MPC85xx_DS
-static int __init p2020_ds_probe(void)
+static int __init p2020_probe(void)
{
- return !!of_machine_is_compatible("fsl,P2020DS");
-}
-#endif /* CONFIG_MPC85xx_DS */
+ struct device_node *p2020_cpu;

-#ifdef CONFIG_MPC85xx_RDB
-static int __init p2020_rdb_probe(void)
-{
- if (of_machine_is_compatible("fsl,P2020RDB"))
- return 1;
- return 0;
-}
+ /*
+ * There is no common compatible string for all P2020 boards.
+ * The only common thing is "PowerPC,P2020@0" cpu node.
+ * So check for P2020 board via this cpu node.
+ */
+ p2020_cpu = of_find_node_by_path("/cpus/PowerPC,P2020@0");
+ of_node_put(p2020_cpu);

-static int __init p2020_rdb_pc_probe(void)
-{
- if (of_machine_is_compatible("fsl,P2020RDB-PC"))
- return 1;
- return 0;
+ return !!p2020_cpu;
}
-#endif /* CONFIG_MPC85xx_RDB */
-
-#ifdef CONFIG_MPC85xx_DS
-define_machine(p2020_ds) {
- .name = "P2020 DS",
- .probe = p2020_ds_probe,
- .setup_arch = p2020_setup_arch,
- .init_IRQ = p2020_pic_init,
-#ifdef CONFIG_PCI
- .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
- .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
-#endif
- .get_irq = mpic_get_irq,
- .calibrate_decr = generic_calibrate_decr,
- .progress = udbg_progress,
-};
-#endif /* CONFIG_MPC85xx_DS */
-
-#ifdef CONFIG_MPC85xx_RDB
-define_machine(p2020_rdb) {
- .name = "P2020 RDB",
- .probe = p2020_rdb_probe,
- .setup_arch = p2020_setup_arch,
- .init_IRQ = p2020_pic_init,
-#ifdef CONFIG_PCI
- .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
- .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
-#endif
- .get_irq = mpic_get_irq,
- .calibrate_decr = generic_calibrate_decr,
- .progress = udbg_progress,
-};

-define_machine(p2020_rdb_pc) {
- .name = "P2020RDB-PC",
- .probe = p2020_rdb_pc_probe,
+define_machine(p2020) {
+ .name = "Freescale P2020",
+ .probe = p2020_probe,
.setup_arch = p2020_setup_arch,
.init_IRQ = p2020_pic_init,
#ifdef CONFIG_PCI
.pcibios_fixup_bus = fsl_pcibios_fixup_bus,
- .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
+ .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
#endif
.get_irq = mpic_get_irq,
.calibrate_decr = generic_calibrate_decr,
.progress = udbg_progress,
};
-#endif /* CONFIG_MPC85xx_RDB */
--
2.39.1


2023-02-22 14:50:58

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 13/17] powerpc/85xx: mpc85xx_ds: Move PCI code into own file

From: Pali Rohár <[email protected]>

In order to share between DS and P2020.

Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/platforms/85xx/Makefile | 3 +-
arch/powerpc/platforms/85xx/mpc85xx.h | 6 +++
arch/powerpc/platforms/85xx/mpc85xx_ds.c | 32 ------------
arch/powerpc/platforms/85xx/mpc85xx_uli.c | 64 +++++++++++++++++++++++
4 files changed, 72 insertions(+), 33 deletions(-)
create mode 100644 arch/powerpc/platforms/85xx/mpc85xx_uli.c

diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index 0a0011e8c63c..65abd5a161c0 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -17,7 +17,8 @@ obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o
obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o
obj-$(CONFIG_MPC8536_DS) += mpc8536_ds.o
obj8259-$(CONFIG_PPC_I8259) += mpc85xx_8259.o
-obj-$(CONFIG_MPC85xx_DS) += mpc85xx_ds.o p2020.o $(obj8259-y)
+objpci-$(CONFIG_PCI) += mpc85xx_uli.o
+obj-$(CONFIG_MPC85xx_DS) += mpc85xx_ds.o p2020.o $(obj8259-y) $(objpci-y)
obj-$(CONFIG_MPC85xx_MDS) += mpc85xx_mds.o
obj-$(CONFIG_MPC85xx_RDB) += mpc85xx_rdb.o p2020.o
obj-$(CONFIG_P1010_RDB) += p1010rdb.o
diff --git a/arch/powerpc/platforms/85xx/mpc85xx.h b/arch/powerpc/platforms/85xx/mpc85xx.h
index e792907ee3d5..b77bb9e7e79c 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx.h
+++ b/arch/powerpc/platforms/85xx/mpc85xx.h
@@ -21,6 +21,12 @@ void __init mpc85xx_8259_init(void);
static inline void __init mpc85xx_8259_init(void) {}
#endif

+#ifdef CONFIG_PCI
+void __init mpc85xx_ds_uli_init(void);
+#else
+static inline void __init mpc85xx_ds_uli_init(void) {}
+#endif
+
void __init mpc85xx_ds_pic_init(void);
void __init mpc85xx_ds_setup_arch(void);
void __init mpc85xx_rdb_setup_arch(void);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 011ae86d72f4..f9ac0b6022b1 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -52,38 +52,6 @@ void __init mpc85xx_ds_pic_init(void)
mpc85xx_8259_init();
}

-static struct device_node *pci_with_uli;
-
-static int mpc85xx_exclude_device(struct pci_controller *hose,
- u_char bus, u_char devfn)
-{
- if (hose->dn == pci_with_uli)
- return uli_exclude_device(hose, bus, devfn);
-
- return PCIBIOS_SUCCESSFUL;
-}
-
-static void __init mpc85xx_ds_uli_init(void)
-{
- struct device_node *node;
-
- if (!IS_ENABLED(CONFIG_PCI))
- return;
-
- /* See if we have a ULI under the primary */
-
- node = of_find_node_by_name(NULL, "uli1575");
- while ((pci_with_uli = of_get_parent(node))) {
- of_node_put(node);
- node = pci_with_uli;
-
- if (pci_with_uli == fsl_pci_primary) {
- ppc_md.pci_exclude_device = mpc85xx_exclude_device;
- break;
- }
- }
-}
-
/*
* Setup the architecture
*/
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_uli.c b/arch/powerpc/platforms/85xx/mpc85xx_uli.c
new file mode 100644
index 000000000000..f91fe860985b
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/mpc85xx_uli.c
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * MPC85xx PCI functions for DS Board Setup
+ *
+ * Author Xianghua Xiao ([email protected])
+ * Roy Zang <[email protected]>
+ * - Add PCI/PCI Exprees support
+ * Copyright 2007 Freescale Semiconductor Inc.
+ */
+
+#include <linux/stddef.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/kdev_t.h>
+#include <linux/delay.h>
+#include <linux/seq_file.h>
+#include <linux/interrupt.h>
+#include <linux/of_irq.h>
+#include <linux/of_platform.h>
+
+#include <asm/time.h>
+#include <asm/machdep.h>
+#include <asm/pci-bridge.h>
+#include <mm/mmu_decl.h>
+#include <asm/udbg.h>
+#include <asm/mpic.h>
+#include <asm/i8259.h>
+#include <asm/swiotlb.h>
+#include <asm/ppc-pci.h>
+
+#include <sysdev/fsl_soc.h>
+#include <sysdev/fsl_pci.h>
+#include "smp.h"
+
+#include "mpc85xx.h"
+
+static struct device_node *pci_with_uli;
+
+static int mpc85xx_exclude_device(struct pci_controller *hose,
+ u_char bus, u_char devfn)
+{
+ if (hose->dn == pci_with_uli)
+ return uli_exclude_device(hose, bus, devfn);
+
+ return PCIBIOS_SUCCESSFUL;
+}
+
+void __init mpc85xx_ds_uli_init(void)
+{
+ struct device_node *node;
+
+ /* See if we have a ULI under the primary */
+
+ node = of_find_node_by_name(NULL, "uli1575");
+ while ((pci_with_uli = of_get_parent(node))) {
+ of_node_put(node);
+ node = pci_with_uli;
+
+ if (pci_with_uli == fsl_pci_primary) {
+ ppc_md.pci_exclude_device = mpc85xx_exclude_device;
+ break;
+ }
+ }
+}
--
2.39.1


2023-02-22 15:20:17

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 05/17] powerpc/85xx: mpc85xx_{ds/rdb} compact the call to mpic_alloc()

Reduce number of lines in the call to mpic_alloc().

Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/platforms/85xx/mpc85xx_ds.c | 18 ++++++------------
arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 16 +++++-----------
2 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index f385cd288a76..1e6e89136948 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -50,23 +50,17 @@ static void mpc85xx_8259_cascade(struct irq_desc *desc)
void __init mpc85xx_ds_pic_init(void)
{
struct mpic *mpic;
+ int flags = MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU;
#ifdef CONFIG_PPC_I8259
struct device_node *np;
struct device_node *cascade_node = NULL;
int cascade_irq;
#endif
- if (of_machine_is_compatible("fsl,MPC8572DS-CAMP")) {
- mpic = mpic_alloc(NULL, 0,
- MPIC_NO_RESET |
- MPIC_BIG_ENDIAN |
- MPIC_SINGLE_DEST_CPU,
- 0, 256, " OpenPIC ");
- } else {
- mpic = mpic_alloc(NULL, 0,
- MPIC_BIG_ENDIAN |
- MPIC_SINGLE_DEST_CPU,
- 0, 256, " OpenPIC ");
- }
+
+ if (of_machine_is_compatible("fsl,MPC8572DS-CAMP"))
+ flags |= MPIC_NO_RESET;
+
+ mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC ");

BUG_ON(mpic == NULL);
mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index b5e9a6374edb..110365d7b997 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -32,18 +32,12 @@
void __init mpc85xx_rdb_pic_init(void)
{
struct mpic *mpic;
+ int flags = MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU;

- if (of_machine_is_compatible("fsl,MPC85XXRDB-CAMP")) {
- mpic = mpic_alloc(NULL, 0, MPIC_NO_RESET |
- MPIC_BIG_ENDIAN |
- MPIC_SINGLE_DEST_CPU,
- 0, 256, " OpenPIC ");
- } else {
- mpic = mpic_alloc(NULL, 0,
- MPIC_BIG_ENDIAN |
- MPIC_SINGLE_DEST_CPU,
- 0, 256, " OpenPIC ");
- }
+ if (of_machine_is_compatible("fsl,MPC85XXRDB-CAMP"))
+ flags |= MPIC_NO_RESET;
+
+ mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC ");

BUG_ON(mpic == NULL);
mpic_init(mpic);
--
2.39.1


2023-02-22 15:20:27

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 09/17] powerpc/85xx: Remove #ifdef CONFIG_QUICC_ENGINE in mpc85xx_rdb

mpc85xx_qe_par_io_init() is a stub when CONFIG_QUICC_ENGINE is not set.

CONFIG_UCC_GETH and CONFIG_SERIAL_QE depend on CONFIG_QUICC_ENGINE.

Remove #ifdef CONFIG_QUICC_ENGINE

Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index 8b0d81f0e1c9..b23f826339b5 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -57,7 +57,6 @@ static void __init mpc85xx_rdb_setup_arch(void)

fsl_pci_assign_primary();

-#ifdef CONFIG_QUICC_ENGINE
mpc85xx_qe_par_io_init();
#if defined(CONFIG_UCC_GETH) || defined(CONFIG_SERIAL_QE)
if (machine_is(p1025_rdb)) {
@@ -90,7 +89,6 @@ static void __init mpc85xx_rdb_setup_arch(void)

}
#endif
-#endif /* CONFIG_QUICC_ENGINE */

pr_info("MPC85xx RDB board from Freescale Semiconductor\n");
}
--
2.39.1


2023-02-22 15:20:30

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 11/17] powerpc/85xx: p2020: Move all P2020 RDB machine descriptions to p2020.c

From: Pali Rohár <[email protected]>

This moves machine descriptions and all related code for all P2020 boards
into new p2020.c source file.
This is preparation for code de-duplication and
providing one unified machine description for all P2020 boards. In
follow-up patches would be copied functions refactored and simplified to be
specific just for P2020 boards.

Signed-off-by: Pali Rohár <[email protected]>
[chleroy: Split in two patches: one for DS, one for RDB and keep helpers out]
Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/platforms/85xx/Makefile | 2 +-
arch/powerpc/platforms/85xx/mpc85xx.h | 2 +
arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 46 +-----------------
arch/powerpc/platforms/85xx/p2020.c | 57 +++++++++++++++++++++++
4 files changed, 61 insertions(+), 46 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index 1f54623db9b7..93451850ed83 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -18,7 +18,7 @@ obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o
obj-$(CONFIG_MPC8536_DS) += mpc8536_ds.o
obj-$(CONFIG_MPC85xx_DS) += mpc85xx_ds.o p2020.o
obj-$(CONFIG_MPC85xx_MDS) += mpc85xx_mds.o
-obj-$(CONFIG_MPC85xx_RDB) += mpc85xx_rdb.o
+obj-$(CONFIG_MPC85xx_RDB) += mpc85xx_rdb.o p2020.o
obj-$(CONFIG_P1010_RDB) += p1010rdb.o
obj-$(CONFIG_P1022_DS) += p1022_ds.o
obj-$(CONFIG_P1022_RDK) += p1022_rdk.o
diff --git a/arch/powerpc/platforms/85xx/mpc85xx.h b/arch/powerpc/platforms/85xx/mpc85xx.h
index ca8b39e6b05a..8f7b37c1de87 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx.h
+++ b/arch/powerpc/platforms/85xx/mpc85xx.h
@@ -17,5 +17,7 @@ static inline void __init mpc85xx_qe_par_io_init(void) {}

void __init mpc85xx_ds_pic_init(void);
void __init mpc85xx_ds_setup_arch(void);
+void __init mpc85xx_rdb_setup_arch(void);
+void __init mpc85xx_rdb_pic_init(void);

#endif
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index b23f826339b5..d1f497e086ed 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -48,7 +48,7 @@ void __init mpc85xx_rdb_pic_init(void)
/*
* Setup the architecture
*/
-static void __init mpc85xx_rdb_setup_arch(void)
+void __init mpc85xx_rdb_setup_arch(void)
{
if (ppc_md.progress)
ppc_md.progress("mpc85xx_rdb_setup_arch()", 0);
@@ -93,8 +93,6 @@ static void __init mpc85xx_rdb_setup_arch(void)
pr_info("MPC85xx RDB board from Freescale Semiconductor\n");
}

-machine_arch_initcall(p2020_rdb, mpc85xx_common_publish_devices);
-machine_arch_initcall(p2020_rdb_pc, mpc85xx_common_publish_devices);
machine_arch_initcall(p1020_mbg_pc, mpc85xx_common_publish_devices);
machine_arch_initcall(p1020_rdb, mpc85xx_common_publish_devices);
machine_arch_initcall(p1020_rdb_pc, mpc85xx_common_publish_devices);
@@ -107,13 +105,6 @@ machine_arch_initcall(p1024_rdb, mpc85xx_common_publish_devices);
/*
* Called very early, device-tree isn't unflattened
*/
-static int __init p2020_rdb_probe(void)
-{
- if (of_machine_is_compatible("fsl,P2020RDB"))
- return 1;
- return 0;
-}
-
static int __init p1020_rdb_probe(void)
{
if (of_machine_is_compatible("fsl,P1020RDB"))
@@ -138,13 +129,6 @@ static int __init p1021_rdb_pc_probe(void)
return 0;
}

-static int __init p2020_rdb_pc_probe(void)
-{
- if (of_machine_is_compatible("fsl,P2020RDB-PC"))
- return 1;
- return 0;
-}
-
static int __init p1025_rdb_probe(void)
{
return of_machine_is_compatible("fsl,P1025RDB");
@@ -165,20 +149,6 @@ static int __init p1024_rdb_probe(void)
return of_machine_is_compatible("fsl,P1024RDB");
}

-define_machine(p2020_rdb) {
- .name = "P2020 RDB",
- .probe = p2020_rdb_probe,
- .setup_arch = mpc85xx_rdb_setup_arch,
- .init_IRQ = mpc85xx_rdb_pic_init,
-#ifdef CONFIG_PCI
- .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
- .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
-#endif
- .get_irq = mpic_get_irq,
- .calibrate_decr = generic_calibrate_decr,
- .progress = udbg_progress,
-};
-
define_machine(p1020_rdb) {
.name = "P1020 RDB",
.probe = p1020_rdb_probe,
@@ -207,20 +177,6 @@ define_machine(p1021_rdb_pc) {
.progress = udbg_progress,
};

-define_machine(p2020_rdb_pc) {
- .name = "P2020RDB-PC",
- .probe = p2020_rdb_pc_probe,
- .setup_arch = mpc85xx_rdb_setup_arch,
- .init_IRQ = mpc85xx_rdb_pic_init,
-#ifdef CONFIG_PCI
- .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
- .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
-#endif
- .get_irq = mpic_get_irq,
- .calibrate_decr = generic_calibrate_decr,
- .progress = udbg_progress,
-};
-
define_machine(p1025_rdb) {
.name = "P1025 RDB",
.probe = p1025_rdb_probe,
diff --git a/arch/powerpc/platforms/85xx/p2020.c b/arch/powerpc/platforms/85xx/p2020.c
index 2dfd150c6375..1b0def607749 100644
--- a/arch/powerpc/platforms/85xx/p2020.c
+++ b/arch/powerpc/platforms/85xx/p2020.c
@@ -34,16 +34,42 @@

#include "mpc85xx.h"

+#ifdef CONFIG_MPC85xx_DS
machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices);
+#endif /* CONFIG_MPC85xx_DS */
+
+#ifdef CONFIG_MPC85xx_RDB
+machine_arch_initcall(p2020_rdb, mpc85xx_common_publish_devices);
+machine_arch_initcall(p2020_rdb_pc, mpc85xx_common_publish_devices);
+#endif /* CONFIG_MPC85xx_RDB */

/*
* Called very early, device-tree isn't unflattened
*/
+#ifdef CONFIG_MPC85xx_DS
static int __init p2020_ds_probe(void)
{
return !!of_machine_is_compatible("fsl,P2020DS");
}
+#endif /* CONFIG_MPC85xx_DS */
+
+#ifdef CONFIG_MPC85xx_RDB
+static int __init p2020_rdb_probe(void)
+{
+ if (of_machine_is_compatible("fsl,P2020RDB"))
+ return 1;
+ return 0;
+}
+
+static int __init p2020_rdb_pc_probe(void)
+{
+ if (of_machine_is_compatible("fsl,P2020RDB-PC"))
+ return 1;
+ return 0;
+}
+#endif /* CONFIG_MPC85xx_RDB */

+#ifdef CONFIG_MPC85xx_DS
define_machine(p2020_ds) {
.name = "P2020 DS",
.probe = p2020_ds_probe,
@@ -57,3 +83,34 @@ define_machine(p2020_ds) {
.calibrate_decr = generic_calibrate_decr,
.progress = udbg_progress,
};
+#endif /* CONFIG_MPC85xx_DS */
+
+#ifdef CONFIG_MPC85xx_RDB
+define_machine(p2020_rdb) {
+ .name = "P2020 RDB",
+ .probe = p2020_rdb_probe,
+ .setup_arch = mpc85xx_rdb_setup_arch,
+ .init_IRQ = mpc85xx_rdb_pic_init,
+#ifdef CONFIG_PCI
+ .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
+ .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
+#endif
+ .get_irq = mpic_get_irq,
+ .calibrate_decr = generic_calibrate_decr,
+ .progress = udbg_progress,
+};
+
+define_machine(p2020_rdb_pc) {
+ .name = "P2020RDB-PC",
+ .probe = p2020_rdb_pc_probe,
+ .setup_arch = mpc85xx_rdb_setup_arch,
+ .init_IRQ = mpc85xx_rdb_pic_init,
+#ifdef CONFIG_PCI
+ .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
+ .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
+#endif
+ .get_irq = mpic_get_irq,
+ .calibrate_decr = generic_calibrate_decr,
+ .progress = udbg_progress,
+};
+#endif /* CONFIG_MPC85xx_RDB */
--
2.39.1


2023-02-22 15:20:46

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v4 12/17] powerpc/85xx: p2020: Move i8259 code into own function

From: Pali Rohár <[email protected]>

Splits mpic and i8259 initialization codes into separate functions.
Use 'if (IS_ENABLED(CONFIG_PPC_I8259))' instead of '#ifdef CONFIG_PPC_I8259'.

Signed-off-by: Pali Rohár <[email protected]>
[chleroy: Put into own C file]
Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/platforms/85xx/Makefile | 3 +-
arch/powerpc/platforms/85xx/mpc85xx.h | 6 ++
arch/powerpc/platforms/85xx/mpc85xx_8259.c | 78 ++++++++++++++++++++++
arch/powerpc/platforms/85xx/mpc85xx_ds.c | 46 -------------
4 files changed, 86 insertions(+), 47 deletions(-)
create mode 100644 arch/powerpc/platforms/85xx/mpc85xx_8259.c

diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index 93451850ed83..0a0011e8c63c 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -16,7 +16,8 @@ obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o
obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o
obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o
obj-$(CONFIG_MPC8536_DS) += mpc8536_ds.o
-obj-$(CONFIG_MPC85xx_DS) += mpc85xx_ds.o p2020.o
+obj8259-$(CONFIG_PPC_I8259) += mpc85xx_8259.o
+obj-$(CONFIG_MPC85xx_DS) += mpc85xx_ds.o p2020.o $(obj8259-y)
obj-$(CONFIG_MPC85xx_MDS) += mpc85xx_mds.o
obj-$(CONFIG_MPC85xx_RDB) += mpc85xx_rdb.o p2020.o
obj-$(CONFIG_P1010_RDB) += p1010rdb.o
diff --git a/arch/powerpc/platforms/85xx/mpc85xx.h b/arch/powerpc/platforms/85xx/mpc85xx.h
index 8f7b37c1de87..e792907ee3d5 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx.h
+++ b/arch/powerpc/platforms/85xx/mpc85xx.h
@@ -15,6 +15,12 @@ extern void mpc85xx_qe_par_io_init(void);
static inline void __init mpc85xx_qe_par_io_init(void) {}
#endif

+#ifdef CONFIG_PPC_I8259
+void __init mpc85xx_8259_init(void);
+#else
+static inline void __init mpc85xx_8259_init(void) {}
+#endif
+
void __init mpc85xx_ds_pic_init(void);
void __init mpc85xx_ds_setup_arch(void);
void __init mpc85xx_rdb_setup_arch(void);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_8259.c b/arch/powerpc/platforms/85xx/mpc85xx_8259.c
new file mode 100644
index 000000000000..eeb541b9f4bd
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/mpc85xx_8259.c
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * MPC85xx 8259 functions for DS Board Setup
+ *
+ * Author Xianghua Xiao ([email protected])
+ * Roy Zang <[email protected]>
+ * - Add PCI/PCI Exprees support
+ * Copyright 2007 Freescale Semiconductor Inc.
+ */
+
+#include <linux/stddef.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/kdev_t.h>
+#include <linux/delay.h>
+#include <linux/seq_file.h>
+#include <linux/interrupt.h>
+#include <linux/of_irq.h>
+#include <linux/of_platform.h>
+
+#include <asm/time.h>
+#include <asm/machdep.h>
+#include <asm/pci-bridge.h>
+#include <mm/mmu_decl.h>
+#include <asm/udbg.h>
+#include <asm/mpic.h>
+#include <asm/i8259.h>
+#include <asm/swiotlb.h>
+#include <asm/ppc-pci.h>
+
+#include <sysdev/fsl_soc.h>
+#include <sysdev/fsl_pci.h>
+#include "smp.h"
+
+#include "mpc85xx.h"
+
+static void mpc85xx_8259_cascade(struct irq_desc *desc)
+{
+ struct irq_chip *chip = irq_desc_get_chip(desc);
+ unsigned int cascade_irq = i8259_irq();
+
+ if (cascade_irq) {
+ generic_handle_irq(cascade_irq);
+ }
+ chip->irq_eoi(&desc->irq_data);
+}
+
+void __init mpc85xx_8259_init(void)
+{
+ struct device_node *np;
+ struct device_node *cascade_node = NULL;
+ int cascade_irq;
+
+ /* Initialize the i8259 controller */
+ for_each_node_by_type(np, "interrupt-controller")
+ if (of_device_is_compatible(np, "chrp,iic")) {
+ cascade_node = np;
+ break;
+ }
+
+ if (cascade_node == NULL) {
+ pr_debug("Could not find i8259 PIC\n");
+ return;
+ }
+
+ cascade_irq = irq_of_parse_and_map(cascade_node, 0);
+ if (!cascade_irq) {
+ pr_err("Failed to map cascade interrupt\n");
+ return;
+ }
+
+ pr_debug("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
+
+ i8259_init(cascade_node, 0);
+ of_node_put(cascade_node);
+
+ irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade);
+}
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 8594862ab3a4..011ae86d72f4 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -34,52 +34,6 @@

#include "mpc85xx.h"

-static void mpc85xx_8259_cascade(struct irq_desc *desc)
-{
- struct irq_chip *chip = irq_desc_get_chip(desc);
- unsigned int cascade_irq = i8259_irq();
-
- if (cascade_irq) {
- generic_handle_irq(cascade_irq);
- }
- chip->irq_eoi(&desc->irq_data);
-}
-
-static void __init mpc85xx_8259_init(void)
-{
- struct device_node *np;
- struct device_node *cascade_node = NULL;
- int cascade_irq;
-
- if (!IS_ENABLED(CONFIG_PPC_I8259))
- return;
-
- /* Initialize the i8259 controller */
- for_each_node_by_type(np, "interrupt-controller")
- if (of_device_is_compatible(np, "chrp,iic")) {
- cascade_node = np;
- break;
- }
-
- if (cascade_node == NULL) {
- pr_debug("Could not find i8259 PIC\n");
- return;
- }
-
- cascade_irq = irq_of_parse_and_map(cascade_node, 0);
- if (!cascade_irq) {
- pr_err("Failed to map cascade interrupt\n");
- return;
- }
-
- pr_debug("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
-
- i8259_init(cascade_node, 0);
- of_node_put(cascade_node);
-
- irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade);
-}
-
void __init mpc85xx_ds_pic_init(void)
{
struct mpic *mpic;
--
2.39.1


2023-02-22 18:22:41

by Pali Rohár

[permalink] [raw]
Subject: Re: [PATCH v4 00/17] powerpc/85xx: p2020: Create one unified machine description

On Wednesday 22 February 2023 15:42:47 Christophe Leroy wrote:
> This patch series unifies all P2020 boards and machine descriptions into
> one generic unified P2020 machine description. With this generic machine
> description, kernel can boot on any P2020-based board with correct DTS
> file.
>
> Tested on CZ.NIC Turris 1.1 board with has Freescale P2020 processor.
> Kernel during booting correctly detects P2020 and prints:
> [ 0.000000] Using Freescale P2020 machine description
>
> Changes in v4:
> * Added several preparatory cleanup patchs
> * Minimised churn by not duplicating helpers at the first place
> * Split main patch in two
> * Dropped patchs 1 and 2
> * Untested beyond basic build test

Changes looks good. I'm happy with them. You can add my:

Reviewed-by: Pali Rohár <[email protected]>

> Changes in v3:
> * Use 'if (IS_ENABLED(CONFIG_PPC_I8259))' instead of '#ifdef CONFIG_PPC_I8259'
> * Simplify p2020_probe()
> * Patches generated by -M and -C git options
>
> Link to v2: https://lore.kernel.org/linuxppc-dev/[email protected]/
>
> Changes in v2:
> * Added patch "p2020: Move i8259 code into own function" (separated from the next one)
> * Renamed CONFIG_P2020 to CONFIG_PPC_P2020
> * Fixed descriptions
>
> Link to v1: https://lore.kernel.org/linuxppc-dev/[email protected]/
>
> Christophe Leroy (9):
> powerpc/fsl_uli1575: Misc cleanup
> powerpc/85xx: Rename setup_arch and pic_init on p1023
> powerpc/85xx: Remove DBG() macro
> powerpc/85xx: Remove #ifdefs CONFIG_PCI in mpc85xx_ds
> powerpc/85xx: mpc85xx_{ds/rdb} compact the call to mpic_alloc()
> powerpc/85xx: mpc85xx_{ds/rdb} replace BUG_ON() by WARN_ON()
> powerpc/85xx: mpc85xx_{ds/rdb} replace prink by pr_xxx macro
> powerpc/85xx: Remove #ifdefs CONFIG_PPC_I8259 in mpc85xx_ds
> powerpc/85xx: Remove #ifdef CONFIG_QUICC_ENGINE in mpc85xx_rdb
>
> Pali Rohár (8):
> powerpc/85xx: p2020: Move all P2020 DS machine descriptions to p2020.c
> powerpc/85xx: p2020: Move all P2020 RDB machine descriptions to
> p2020.c
> powerpc/85xx: p2020: Move i8259 code into own function
> powerpc/85xx: mpc85xx_ds: Move PCI code into own file
> powerpc/85xx: p2020: Unify .setup_arch and .init_IRQ callbacks
> powerpc/85xx: p2020: Define just one machine description
> powerpc/85xx: p2020: Enable boards by new config option
> CONFIG_PPC_P2020
> powerpc: dts: turris1x.dts: Remove "fsl,P2020RDB-PC" compatible string
>
> arch/powerpc/boot/dts/turris1x.dts | 2 +-
> arch/powerpc/include/asm/ppc-pci.h | 2 +
> arch/powerpc/platforms/85xx/Kconfig | 22 +++-
> arch/powerpc/platforms/85xx/Makefile | 5 +-
> arch/powerpc/platforms/85xx/mpc85xx.h | 12 ++
> arch/powerpc/platforms/85xx/mpc85xx_8259.c | 78 ++++++++++++
> arch/powerpc/platforms/85xx/mpc85xx_ds.c | 133 ++-------------------
> arch/powerpc/platforms/85xx/mpc85xx_mds.c | 7 --
> arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 79 ++----------
> arch/powerpc/platforms/85xx/mpc85xx_uli.c | 64 ++++++++++
> arch/powerpc/platforms/85xx/p1023_rdb.c | 8 +-
> arch/powerpc/platforms/85xx/p2020.c | 95 +++++++++++++++
> arch/powerpc/platforms/fsl_uli1575.c | 6 +-
> 13 files changed, 301 insertions(+), 212 deletions(-)
> create mode 100644 arch/powerpc/platforms/85xx/mpc85xx_8259.c
> create mode 100644 arch/powerpc/platforms/85xx/mpc85xx_uli.c
> create mode 100644 arch/powerpc/platforms/85xx/p2020.c
>
> --
> 2.39.1
>

2023-02-23 08:38:07

by Christophe Leroy

[permalink] [raw]
Subject: Re: [PATCH v4 00/17] powerpc/85xx: p2020: Create one unified machine description



Le 22/02/2023 à 19:22, Pali Rohár a écrit :
> On Wednesday 22 February 2023 15:42:47 Christophe Leroy wrote:
>> This patch series unifies all P2020 boards and machine descriptions into
>> one generic unified P2020 machine description. With this generic machine
>> description, kernel can boot on any P2020-based board with correct DTS
>> file.
>>
>> Tested on CZ.NIC Turris 1.1 board with has Freescale P2020 processor.
>> Kernel during booting correctly detects P2020 and prints:
>> [ 0.000000] Using Freescale P2020 machine description
>>
>> Changes in v4:
>> * Added several preparatory cleanup patchs
>> * Minimised churn by not duplicating helpers at the first place
>> * Split main patch in two
>> * Dropped patchs 1 and 2
>> * Untested beyond basic build test
>
> Changes looks good. I'm happy with them. You can add my:
>
> Reviewed-by: Pali Rohár <[email protected]>

Thanks.

However this series doesn't have the shape for getting merged yet, I've
been very quick with the additional patches descriptions and I have not
revisited the descriptions of pre-existing patches.

I was expecting you to take over. By the way there's no hurry I guess,
we are already in the middle of the merge window, Michael usually
doesn't take any more non-fixes patches once the merge window is open,
so that series will go in 6.4

Christophe

>
>> Changes in v3:
>> * Use 'if (IS_ENABLED(CONFIG_PPC_I8259))' instead of '#ifdef CONFIG_PPC_I8259'
>> * Simplify p2020_probe()
>> * Patches generated by -M and -C git options
>>
>> Link to v2: https://lore.kernel.org/linuxppc-dev/[email protected]/
>>
>> Changes in v2:
>> * Added patch "p2020: Move i8259 code into own function" (separated from the next one)
>> * Renamed CONFIG_P2020 to CONFIG_PPC_P2020
>> * Fixed descriptions
>>
>> Link to v1: https://lore.kernel.org/linuxppc-dev/[email protected]/
>>
>> Christophe Leroy (9):
>> powerpc/fsl_uli1575: Misc cleanup
>> powerpc/85xx: Rename setup_arch and pic_init on p1023
>> powerpc/85xx: Remove DBG() macro
>> powerpc/85xx: Remove #ifdefs CONFIG_PCI in mpc85xx_ds
>> powerpc/85xx: mpc85xx_{ds/rdb} compact the call to mpic_alloc()
>> powerpc/85xx: mpc85xx_{ds/rdb} replace BUG_ON() by WARN_ON()
>> powerpc/85xx: mpc85xx_{ds/rdb} replace prink by pr_xxx macro
>> powerpc/85xx: Remove #ifdefs CONFIG_PPC_I8259 in mpc85xx_ds
>> powerpc/85xx: Remove #ifdef CONFIG_QUICC_ENGINE in mpc85xx_rdb
>>
>> Pali Rohár (8):
>> powerpc/85xx: p2020: Move all P2020 DS machine descriptions to p2020.c
>> powerpc/85xx: p2020: Move all P2020 RDB machine descriptions to
>> p2020.c
>> powerpc/85xx: p2020: Move i8259 code into own function
>> powerpc/85xx: mpc85xx_ds: Move PCI code into own file
>> powerpc/85xx: p2020: Unify .setup_arch and .init_IRQ callbacks
>> powerpc/85xx: p2020: Define just one machine description
>> powerpc/85xx: p2020: Enable boards by new config option
>> CONFIG_PPC_P2020
>> powerpc: dts: turris1x.dts: Remove "fsl,P2020RDB-PC" compatible string
>>
>> arch/powerpc/boot/dts/turris1x.dts | 2 +-
>> arch/powerpc/include/asm/ppc-pci.h | 2 +
>> arch/powerpc/platforms/85xx/Kconfig | 22 +++-
>> arch/powerpc/platforms/85xx/Makefile | 5 +-
>> arch/powerpc/platforms/85xx/mpc85xx.h | 12 ++
>> arch/powerpc/platforms/85xx/mpc85xx_8259.c | 78 ++++++++++++
>> arch/powerpc/platforms/85xx/mpc85xx_ds.c | 133 ++-------------------
>> arch/powerpc/platforms/85xx/mpc85xx_mds.c | 7 --
>> arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 79 ++----------
>> arch/powerpc/platforms/85xx/mpc85xx_uli.c | 64 ++++++++++
>> arch/powerpc/platforms/85xx/p1023_rdb.c | 8 +-
>> arch/powerpc/platforms/85xx/p2020.c | 95 +++++++++++++++
>> arch/powerpc/platforms/fsl_uli1575.c | 6 +-
>> 13 files changed, 301 insertions(+), 212 deletions(-)
>> create mode 100644 arch/powerpc/platforms/85xx/mpc85xx_8259.c
>> create mode 100644 arch/powerpc/platforms/85xx/mpc85xx_uli.c
>> create mode 100644 arch/powerpc/platforms/85xx/p2020.c
>>
>> --
>> 2.39.1
>>

2023-02-23 08:58:22

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH v4 00/17] powerpc/85xx: p2020: Create one unified machine description

Christophe Leroy <[email protected]> writes:
> Le 22/02/2023 à 19:22, Pali Rohár a écrit :
>> On Wednesday 22 February 2023 15:42:47 Christophe Leroy wrote:
>>> This patch series unifies all P2020 boards and machine descriptions into
>>> one generic unified P2020 machine description. With this generic machine
>>> description, kernel can boot on any P2020-based board with correct DTS
>>> file.
>>>
>>> Tested on CZ.NIC Turris 1.1 board with has Freescale P2020 processor.
>>> Kernel during booting correctly detects P2020 and prints:
>>> [ 0.000000] Using Freescale P2020 machine description
>>>
>>> Changes in v4:
>>> * Added several preparatory cleanup patchs
>>> * Minimised churn by not duplicating helpers at the first place
>>> * Split main patch in two
>>> * Dropped patchs 1 and 2
>>> * Untested beyond basic build test
>>
>> Changes looks good. I'm happy with them. You can add my:
>>
>> Reviewed-by: Pali Rohár <[email protected]>
>
> Thanks.
>
> However this series doesn't have the shape for getting merged yet, I've
> been very quick with the additional patches descriptions and I have not
> revisited the descriptions of pre-existing patches.
>
> I was expecting you to take over. By the way there's no hurry I guess,
> we are already in the middle of the merge window, Michael usually
> doesn't take any more non-fixes patches once the merge window is open,
> so that series will go in 6.4

Correct.

I'll open next for new patches around 6.3-rc2, so in ~2.5 weeks from now.

cheers