xref: /linux/arch/powerpc/platforms/85xx/p1023_rdb.c (revision 2874c5fd284268364ece81a7bd936f3c8168e567)
1*2874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
2fd7e5b7aSLijun Pan /*
3fd7e5b7aSLijun Pan  * Copyright 2010-2011, 2013 Freescale Semiconductor, Inc.
4fd7e5b7aSLijun Pan  *
5fd7e5b7aSLijun Pan  * Author: Roy Zang <tie-fei.zang@freescale.com>
6fd7e5b7aSLijun Pan  *
7fd7e5b7aSLijun Pan  * Description:
8fd7e5b7aSLijun Pan  * P1023 RDB Board Setup
9fd7e5b7aSLijun Pan  */
10fd7e5b7aSLijun Pan 
11fd7e5b7aSLijun Pan #include <linux/kernel.h>
12fd7e5b7aSLijun Pan #include <linux/init.h>
13fd7e5b7aSLijun Pan #include <linux/errno.h>
14fd7e5b7aSLijun Pan #include <linux/pci.h>
15fd7e5b7aSLijun Pan #include <linux/delay.h>
16fd7e5b7aSLijun Pan #include <linux/module.h>
17fd7e5b7aSLijun Pan #include <linux/fsl_devices.h>
18fd7e5b7aSLijun Pan #include <linux/of_platform.h>
19fd7e5b7aSLijun Pan #include <linux/of_device.h>
20fd7e5b7aSLijun Pan 
21fd7e5b7aSLijun Pan #include <asm/time.h>
22fd7e5b7aSLijun Pan #include <asm/machdep.h>
23fd7e5b7aSLijun Pan #include <asm/pci-bridge.h>
24fd7e5b7aSLijun Pan #include <mm/mmu_decl.h>
25fd7e5b7aSLijun Pan #include <asm/prom.h>
26fd7e5b7aSLijun Pan #include <asm/udbg.h>
27fd7e5b7aSLijun Pan #include <asm/mpic.h>
28fd7e5b7aSLijun Pan #include "smp.h"
29fd7e5b7aSLijun Pan 
30fd7e5b7aSLijun Pan #include <sysdev/fsl_soc.h>
31fd7e5b7aSLijun Pan #include <sysdev/fsl_pci.h>
32fd7e5b7aSLijun Pan 
33fd7e5b7aSLijun Pan #include "mpc85xx.h"
34fd7e5b7aSLijun Pan 
35fd7e5b7aSLijun Pan /* ************************************************************************
36fd7e5b7aSLijun Pan  *
37fd7e5b7aSLijun Pan  * Setup the architecture
38fd7e5b7aSLijun Pan  *
39fd7e5b7aSLijun Pan  */
40fd7e5b7aSLijun Pan static void __init mpc85xx_rdb_setup_arch(void)
41fd7e5b7aSLijun Pan {
42fd7e5b7aSLijun Pan 	struct device_node *np;
43fd7e5b7aSLijun Pan 
44fd7e5b7aSLijun Pan 	if (ppc_md.progress)
45fd7e5b7aSLijun Pan 		ppc_md.progress("p1023_rdb_setup_arch()", 0);
46fd7e5b7aSLijun Pan 
47fd7e5b7aSLijun Pan 	/* Map BCSR area */
48fd7e5b7aSLijun Pan 	np = of_find_node_by_name(NULL, "bcsr");
49fd7e5b7aSLijun Pan 	if (np != NULL) {
50fd7e5b7aSLijun Pan 		static u8 __iomem *bcsr_regs;
51fd7e5b7aSLijun Pan 
52fd7e5b7aSLijun Pan 		bcsr_regs = of_iomap(np, 0);
53fd7e5b7aSLijun Pan 		of_node_put(np);
54fd7e5b7aSLijun Pan 
55fd7e5b7aSLijun Pan 		if (!bcsr_regs) {
56fd7e5b7aSLijun Pan 			printk(KERN_ERR
57fd7e5b7aSLijun Pan 			       "BCSR: Failed to map bcsr register space\n");
58fd7e5b7aSLijun Pan 			return;
59fd7e5b7aSLijun Pan 		} else {
60fd7e5b7aSLijun Pan #define BCSR15_I2C_BUS0_SEG_CLR		0x07
61fd7e5b7aSLijun Pan #define BCSR15_I2C_BUS0_SEG2		0x02
62fd7e5b7aSLijun Pan /*
63fd7e5b7aSLijun Pan  * Note: Accessing exclusively i2c devices.
64fd7e5b7aSLijun Pan  *
65fd7e5b7aSLijun Pan  * The i2c controller selects initially ID EEPROM in the u-boot;
66fd7e5b7aSLijun Pan  * but if menu configuration selects RTC support in the kernel,
67fd7e5b7aSLijun Pan  * the i2c controller switches to select RTC chip in the kernel.
68fd7e5b7aSLijun Pan  */
69fd7e5b7aSLijun Pan #ifdef CONFIG_RTC_CLASS
70fd7e5b7aSLijun Pan 			/* Enable RTC chip on the segment #2 of i2c */
71fd7e5b7aSLijun Pan 			clrbits8(&bcsr_regs[15], BCSR15_I2C_BUS0_SEG_CLR);
72fd7e5b7aSLijun Pan 			setbits8(&bcsr_regs[15], BCSR15_I2C_BUS0_SEG2);
73fd7e5b7aSLijun Pan #endif
74fd7e5b7aSLijun Pan 
75fd7e5b7aSLijun Pan 			iounmap(bcsr_regs);
76fd7e5b7aSLijun Pan 		}
77fd7e5b7aSLijun Pan 	}
78fd7e5b7aSLijun Pan 
79fd7e5b7aSLijun Pan 	mpc85xx_smp_init();
80fd7e5b7aSLijun Pan 
81fd7e5b7aSLijun Pan 	fsl_pci_assign_primary();
82fd7e5b7aSLijun Pan }
83fd7e5b7aSLijun Pan 
84fd7e5b7aSLijun Pan machine_arch_initcall(p1023_rdb, mpc85xx_common_publish_devices);
85fd7e5b7aSLijun Pan 
86fd7e5b7aSLijun Pan static void __init mpc85xx_rdb_pic_init(void)
87fd7e5b7aSLijun Pan {
88fd7e5b7aSLijun Pan 	struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
89fd7e5b7aSLijun Pan 		MPIC_SINGLE_DEST_CPU,
90fd7e5b7aSLijun Pan 		0, 256, " OpenPIC  ");
91fd7e5b7aSLijun Pan 
92fd7e5b7aSLijun Pan 	BUG_ON(mpic == NULL);
93fd7e5b7aSLijun Pan 
94fd7e5b7aSLijun Pan 	mpic_init(mpic);
95fd7e5b7aSLijun Pan }
96fd7e5b7aSLijun Pan 
97fd7e5b7aSLijun Pan static int __init p1023_rdb_probe(void)
98fd7e5b7aSLijun Pan {
9956571384SBenjamin Herrenschmidt 	return of_machine_is_compatible("fsl,P1023RDB");
100fd7e5b7aSLijun Pan 
101fd7e5b7aSLijun Pan }
102fd7e5b7aSLijun Pan 
103fd7e5b7aSLijun Pan define_machine(p1023_rdb) {
104fd7e5b7aSLijun Pan 	.name			= "P1023 RDB",
105fd7e5b7aSLijun Pan 	.probe			= p1023_rdb_probe,
106fd7e5b7aSLijun Pan 	.setup_arch		= mpc85xx_rdb_setup_arch,
107fd7e5b7aSLijun Pan 	.init_IRQ		= mpc85xx_rdb_pic_init,
108fd7e5b7aSLijun Pan 	.get_irq		= mpic_get_irq,
109fd7e5b7aSLijun Pan 	.calibrate_decr		= generic_calibrate_decr,
110fd7e5b7aSLijun Pan 	.progress		= udbg_progress,
111fd7e5b7aSLijun Pan #ifdef CONFIG_PCI
112fd7e5b7aSLijun Pan 	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
113fd7e5b7aSLijun Pan 	.pcibios_fixup_phb      = fsl_pcibios_fixup_phb,
114fd7e5b7aSLijun Pan #endif
115fd7e5b7aSLijun Pan };
116