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