Commit | Line | Data |
---|---|---|
58862699 | 1 | /*arch/powerpc/platforms/8xx/mpc86xads_setup.c |
29f1530f VB |
2 | * |
3 | * Platform setup for the Freescale mpc86xads board | |
4 | * | |
5 | * Vitaly Bordug <vbordug@ru.mvista.com> | |
6 | * | |
7 | * Copyright 2005 MontaVista Software Inc. | |
8 | * | |
0b5cf106 SW |
9 | * Heavily modified by Scott Wood <scottwood@freescale.com> |
10 | * Copyright 2007 Freescale Semiconductor, Inc. | |
11 | * | |
29f1530f VB |
12 | * This file is licensed under the terms of the GNU General Public License |
13 | * version 2. This program is licensed "as is" without any warranty of any | |
14 | * kind, whether express or implied. | |
15 | */ | |
16 | ||
17 | #include <linux/init.h> | |
0b5cf106 | 18 | #include <linux/of_platform.h> |
29f1530f | 19 | |
29f1530f VB |
20 | #include <asm/io.h> |
21 | #include <asm/machdep.h> | |
29f1530f VB |
22 | #include <asm/system.h> |
23 | #include <asm/time.h> | |
29f1530f | 24 | #include <asm/8xx_immap.h> |
b5677d84 | 25 | #include <asm/cpm1.h> |
29f1530f | 26 | #include <asm/fs_pd.h> |
0b5cf106 | 27 | #include <asm/udbg.h> |
29f1530f | 28 | |
0b5cf106 | 29 | #include "mpc86xads.h" |
49b51545 | 30 | #include "mpc8xx.h" |
29f1530f | 31 | |
0b5cf106 SW |
32 | struct cpm_pin { |
33 | int port, pin, flags; | |
34 | }; | |
29f1530f | 35 | |
0b5cf106 SW |
36 | static struct cpm_pin mpc866ads_pins[] = { |
37 | /* SMC1 */ | |
38 | {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */ | |
39 | {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */ | |
40 | ||
41 | /* SMC2 */ | |
42 | {CPM_PORTB, 21, CPM_PIN_INPUT}, /* RX */ | |
43 | {CPM_PORTB, 20, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */ | |
44 | ||
45 | /* SCC1 */ | |
46 | {CPM_PORTA, 6, CPM_PIN_INPUT}, /* CLK1 */ | |
47 | {CPM_PORTA, 7, CPM_PIN_INPUT}, /* CLK2 */ | |
48 | {CPM_PORTA, 14, CPM_PIN_INPUT}, /* TX */ | |
49 | {CPM_PORTA, 15, CPM_PIN_INPUT}, /* RX */ | |
50 | {CPM_PORTB, 19, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TENA */ | |
51 | {CPM_PORTC, 10, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* RENA */ | |
52 | {CPM_PORTC, 11, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* CLSN */ | |
53 | ||
54 | /* MII */ | |
55 | {CPM_PORTD, 3, CPM_PIN_OUTPUT}, | |
56 | {CPM_PORTD, 4, CPM_PIN_OUTPUT}, | |
57 | {CPM_PORTD, 5, CPM_PIN_OUTPUT}, | |
58 | {CPM_PORTD, 6, CPM_PIN_OUTPUT}, | |
59 | {CPM_PORTD, 7, CPM_PIN_OUTPUT}, | |
60 | {CPM_PORTD, 8, CPM_PIN_OUTPUT}, | |
61 | {CPM_PORTD, 9, CPM_PIN_OUTPUT}, | |
62 | {CPM_PORTD, 10, CPM_PIN_OUTPUT}, | |
63 | {CPM_PORTD, 11, CPM_PIN_OUTPUT}, | |
64 | {CPM_PORTD, 12, CPM_PIN_OUTPUT}, | |
65 | {CPM_PORTD, 13, CPM_PIN_OUTPUT}, | |
66 | {CPM_PORTD, 14, CPM_PIN_OUTPUT}, | |
67 | {CPM_PORTD, 15, CPM_PIN_OUTPUT}, | |
a5d28c8e JF |
68 | |
69 | /* I2C */ | |
70 | {CPM_PORTB, 26, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN}, | |
71 | {CPM_PORTB, 27, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN}, | |
0b5cf106 | 72 | }; |
29f1530f | 73 | |
0b5cf106 | 74 | static void __init init_ioports(void) |
29f1530f | 75 | { |
0b5cf106 | 76 | int i; |
29f1530f | 77 | |
0b5cf106 SW |
78 | for (i = 0; i < ARRAY_SIZE(mpc866ads_pins); i++) { |
79 | struct cpm_pin *pin = &mpc866ads_pins[i]; | |
80 | cpm1_set_pin(pin->port, pin->pin, pin->flags); | |
81 | } | |
29f1530f | 82 | |
0b5cf106 SW |
83 | cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX); |
84 | cpm1_clk_setup(CPM_CLK_SMC2, CPM_BRG2, CPM_CLK_RTX); | |
85 | cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK1, CPM_CLK_TX); | |
86 | cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK2, CPM_CLK_RX); | |
29f1530f | 87 | |
0b5cf106 SW |
88 | /* Set FEC1 and FEC2 to MII mode */ |
89 | clrbits32(&mpc8xx_immr->im_cpm.cp_cptr, 0x00000180); | |
29f1530f VB |
90 | } |
91 | ||
0b5cf106 | 92 | static void __init mpc86xads_setup_arch(void) |
29f1530f | 93 | { |
0b5cf106 SW |
94 | struct device_node *np; |
95 | u32 __iomem *bcsr_io; | |
96 | ||
97 | cpm_reset(); | |
98 | init_ioports(); | |
29f1530f | 99 | |
0b5cf106 SW |
100 | np = of_find_compatible_node(NULL, NULL, "fsl,mpc866ads-bcsr"); |
101 | if (!np) { | |
102 | printk(KERN_CRIT "Could not find fsl,mpc866ads-bcsr node\n"); | |
29f1530f VB |
103 | return; |
104 | } | |
29f1530f | 105 | |
0b5cf106 SW |
106 | bcsr_io = of_iomap(np, 0); |
107 | of_node_put(np); | |
29f1530f VB |
108 | |
109 | if (bcsr_io == NULL) { | |
110 | printk(KERN_CRIT "Could not remap BCSR\n"); | |
111 | return; | |
112 | } | |
113 | ||
0b5cf106 | 114 | clrbits32(bcsr_io, BCSR1_RS232EN_1 | BCSR1_RS232EN_2 | BCSR1_ETHEN); |
29f1530f | 115 | iounmap(bcsr_io); |
29f1530f VB |
116 | } |
117 | ||
0b5cf106 | 118 | static int __init mpc86xads_probe(void) |
29f1530f | 119 | { |
0b5cf106 SW |
120 | unsigned long root = of_get_flat_dt_root(); |
121 | return of_flat_dt_is_compatible(root, "fsl,mpc866ads"); | |
29f1530f VB |
122 | } |
123 | ||
0b5cf106 SW |
124 | static struct of_device_id __initdata of_bus_ids[] = { |
125 | { .name = "soc", }, | |
126 | { .name = "cpm", }, | |
127 | { .name = "localbus", }, | |
128 | {}, | |
129 | }; | |
29f1530f | 130 | |
0b5cf106 | 131 | static int __init declare_of_platform_devices(void) |
29f1530f | 132 | { |
6869e4ad | 133 | of_platform_bus_probe(NULL, of_bus_ids, NULL); |
29f1530f | 134 | |
29f1530f VB |
135 | return 0; |
136 | } | |
6869e4ad | 137 | machine_device_initcall(mpc86x_ads, declare_of_platform_devices); |
29f1530f VB |
138 | |
139 | define_machine(mpc86x_ads) { | |
140 | .name = "MPC86x ADS", | |
141 | .probe = mpc86xads_probe, | |
142 | .setup_arch = mpc86xads_setup_arch, | |
d0a02a06 | 143 | .init_IRQ = mpc8xx_pics_init, |
29f1530f VB |
144 | .get_irq = mpc8xx_get_irq, |
145 | .restart = mpc8xx_restart, | |
146 | .calibrate_decr = mpc8xx_calibrate_decr, | |
147 | .set_rtc_time = mpc8xx_set_rtc_time, | |
148 | .get_rtc_time = mpc8xx_get_rtc_time, | |
0b5cf106 | 149 | .progress = udbg_progress, |
29f1530f | 150 | }; |