aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc/platforms/lite5200.c
blob: 77fa7545bb0a5648e6a32433237d457b469b44e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/*
 * arch/ppc/platforms/lite5200.c
 *
 * Platform support file for the Freescale LITE5200 based on MPC52xx.
 * A maximum of this file should be moved to syslib/mpc52xx_?????
 * so that new platform based on MPC52xx need a minimal platform file
 * ( avoid code duplication )
 *
 * 
 * Maintainer : Sylvain Munaut <tnt@246tNt.com>
 *
 * Based on the 2.4 code written by Kent Borg,
 * Dale Farnsworth <dale.farnsworth@mvista.com> and
 * Wolfgang Denk <wd@denx.de>
 * 
 * Copyright 2004 Sylvain Munaut <tnt@246tNt.com>
 * Copyright 2003 Motorola Inc.
 * Copyright 2003 MontaVista Software Inc.
 * Copyright 2003 DENX Software Engineering (wd@denx.de)
 *
 * This file is licensed under the terms of the GNU General Public License
 * version 2. This program is licensed "as is" without any warranty of any
 * kind, whether express or implied.
 */

#include <linux/config.h>
#include <linux/initrd.h>
#include <linux/seq_file.h>
#include <linux/kdev_t.h>
#include <linux/root_dev.h>
#include <linux/console.h>

#include <asm/bootinfo.h>
#include <asm/io.h>
#include <asm/ocp.h>
#include <asm/mpc52xx.h>

#include <syslib/mpc52xx_pci.h>


extern int powersave_nap;

/* Board data given by U-Boot */
bd_t __res;
EXPORT_SYMBOL(__res);	/* For modules */


/* ======================================================================== */
/* OCP device definition                                                    */
/* For board/shared resources like PSCs                                     */
/* ======================================================================== */
/* Be sure not to load conficting devices : e.g. loading the UART drivers for
 * PSC1 and then also loading a AC97 for this same PSC.
 * For details about how to create an entry, look in the doc of the concerned
 * driver ( eg drivers/serial/mpc52xx_uart.c for the PSC in uart mode )
 */

static struct ocp_def board_ocp[] = {
	{
		.vendor		= OCP_VENDOR_FREESCALE,
		.function	= OCP_FUNC_PSC_UART,
		.index		= 0,
		.paddr		= MPC52xx_PSC1,
		.irq		= MPC52xx_PSC1_IRQ,
		.pm		= OCP_CPM_NA,
	},
	{	/* Terminating entry */
		.vendor		= OCP_VENDOR_INVALID
	}
};


/* ======================================================================== */
/* Platform specific code                                                   */
/* ======================================================================== */

static int
lite5200_show_cpuinfo(struct seq_file *m)
{
	seq_printf(m, "machine\t\t: Freescale LITE5200\n");
	return 0;
}

#ifdef CONFIG_PCI
static int
lite5200_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
{
	return (pin == 1) && (idsel==24) ? MPC52xx_IRQ0 : -1;
}
#endif

static void __init
lite5200_setup_cpu(void)
{
	struct mpc52xx_intr __iomem *intr;
	struct mpc52xx_xlb  __iomem *xlb;

	u32 intr_ctrl;

	/* Map zones */
	xlb  = ioremap(MPC52xx_XLB,sizeof(struct mpc52xx_xlb));
	intr = ioremap(MPC52xx_INTR,sizeof(struct mpc52xx_intr));

	if (!xlb || !intr) {
		printk("lite5200.c: Error while mapping XLB/INTR during "
				"lite5200_setup_cpu\n");
		goto unmap_regs;
	}

	/* Configure the XLB Arbiter */
	out_be32(&xlb->master_pri_enable, 0xff);
	out_be32(&xlb->master_priority, 0x11111111);

	/* Enable ram snooping for 1GB window */
	out_be32(&xlb->config, in_be32(&xlb->config) | MPC52xx_XLB_CFG_SNOOP);
	out_be32(&xlb->snoop_window, MPC52xx_PCI_TARGET_MEM | 0x1d);

	/* IRQ[0-3] setup : IRQ0     - Level Active Low  */
	/*                  IRQ[1-3] - Level Active High */
	intr_ctrl = in_be32(&intr->ctrl);
	intr_ctrl &= ~0x00ff0000;
	intr_ctrl |=  0x00c00000;
	out_be32(&intr->ctrl, intr_ctrl);

	/* Unmap reg zone */
unmap_regs:
	if (xlb)  iounmap(xlb);
	if (intr) iounmap(intr);
}

static void __init
lite5200_setup_arch(void)
{
	/* Add board OCP definitions */
	mpc52xx_add_board_devices(board_ocp);

	/* CPU & Port mux setup */
	lite5200_setup_cpu();

#ifdef CONFIG_PCI
	/* PCI Bridge setup */
	mpc52xx_find_bridges();
#endif
}

void __init
platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
              unsigned long r6, unsigned long r7)
{
	/* Generic MPC52xx platform initialization */
	/* TODO Create one and move a max of stuff in it.
	   Put this init in the syslib */

	struct bi_record *bootinfo = find_bootinfo();

	if (bootinfo)
		parse_bootinfo(bootinfo);
	else {
		/* Load the bd_t board info structure */
		if (r3)
			memcpy((void*)&__res,(void*)(r3+KERNELBASE),
					sizeof(bd_t));

#ifdef CONFIG_BLK_DEV_INITRD
		/* Load the initrd */
		if (r4) {
			initrd_start = r4 + KERNELBASE;
			initrd_end = r5 + KERNELBASE;
		}
#endif

		/* Load the command line */
		if (r6) {
			*(char *)(r7+KERNELBASE) = 0;
			strcpy(cmd_line, (char *)(r6+KERNELBASE));
		}
	}

	/* BAT setup */
	mpc52xx_set_bat();

	/* No ISA bus by default */
	isa_io_base		= 0;
	isa_mem_base		= 0;

	/* Powersave */
	powersave_nap = 1;	/* We allow this platform to NAP */

	/* Setup the ppc_md struct */
	ppc_md.setup_arch	= lite5200_setup_arch;
	ppc_md.show_cpuinfo	= lite5200_show_cpuinfo;
	ppc_md.show_percpuinfo	= NULL;
	ppc_md.init_IRQ		= mpc52xx_init_irq;
	ppc_md.get_irq		= mpc52xx_get_irq;

#ifdef CONFIG_PCI
	ppc_md.pci_map_irq	= lite5200_map_irq;
#endif

	ppc_md.find_end_of_memory = mpc52xx_find_end_of_memory;
	ppc_md.setup_io_mappings  = mpc52xx_map_io;

	ppc_md.restart		= mpc52xx_restart;
	ppc_md.power_off	= mpc52xx_power_off;
	ppc_md.halt		= mpc52xx_halt;

		/* No time keeper on the LITE5200 */
	ppc_md.time_init	= NULL;
	ppc_md.get_rtc_time	= NULL;
	ppc_md.set_rtc_time	= NULL;

	ppc_md.calibrate_decr	= mpc52xx_calibrate_decr;
#ifdef CONFIG_SERIAL_TEXT_DEBUG
	ppc_md.progress		= mpc52xx_progress;
#endif
}