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