2 * Platform device setup for Marvell mv64360/mv64460 host bridges (Discovery)
4 * Author: Dale Farnsworth <dale@farnsworth.org>
6 * 2007 (c) MontaVista, Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
12 #include <linux/stddef.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/mv643xx.h>
16 #include <linux/platform_device.h>
21 * These functions provide the necessary setup for the mv64x60 drivers.
22 * These drivers are unusual in that they work on both the MIPS and PowerPC
23 * architectures. Because of that, the drivers do not support the normal
24 * PowerPC of_platform_bus_type. They support platform_bus_type instead.
28 * Create MPSC platform devices
30 static int __init mv64x60_mpsc_register_shared_pdev(struct device_node *np)
32 struct platform_device *pdev;
34 struct mpsc_shared_pdata pdata;
36 struct device_node *mpscrouting, *mpscintr;
39 ph = of_get_property(np, "mpscrouting", NULL);
40 mpscrouting = of_find_node_by_phandle(*ph);
44 err = of_address_to_resource(mpscrouting, 0, &r[0]);
45 of_node_put(mpscrouting);
49 ph = of_get_property(np, "mpscintr", NULL);
50 mpscintr = of_find_node_by_phandle(*ph);
54 err = of_address_to_resource(mpscintr, 0, &r[1]);
55 of_node_put(mpscintr);
59 memset(&pdata, 0, sizeof(pdata));
61 pdev = platform_device_alloc(MPSC_SHARED_NAME, 0);
65 err = platform_device_add_resources(pdev, r, 2);
69 err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
73 err = platform_device_add(pdev);
80 platform_device_put(pdev);
85 static int __init mv64x60_mpsc_device_setup(struct device_node *np, int id)
88 struct mpsc_pdata pdata;
89 struct platform_device *pdev;
90 const unsigned int *prop;
92 struct device_node *sdma, *brg;
96 /* only register the shared platform device the first time through */
97 if (id == 0 && (err = mv64x60_mpsc_register_shared_pdev(np)))
100 memset(r, 0, sizeof(r));
102 err = of_address_to_resource(np, 0, &r[0]);
106 of_irq_to_resource(np, 0, &r[4]);
108 ph = of_get_property(np, "sdma", NULL);
109 sdma = of_find_node_by_phandle(*ph);
113 of_irq_to_resource(sdma, 0, &r[3]);
114 err = of_address_to_resource(sdma, 0, &r[1]);
119 ph = of_get_property(np, "brg", NULL);
120 brg = of_find_node_by_phandle(*ph);
124 err = of_address_to_resource(brg, 0, &r[2]);
129 prop = of_get_property(np, "block-index", NULL);
132 port_number = *(int *)prop;
134 memset(&pdata, 0, sizeof(pdata));
136 pdata.cache_mgmt = 1; /* All current revs need this set */
138 prop = of_get_property(np, "max_idle", NULL);
140 pdata.max_idle = *prop;
142 prop = of_get_property(brg, "current-speed", NULL);
144 pdata.default_baud = *prop;
146 /* Default is 8 bits, no parity, no flow control */
147 pdata.default_bits = 8;
148 pdata.default_parity = 'n';
149 pdata.default_flow = 'n';
151 prop = of_get_property(np, "chr_1", NULL);
153 pdata.chr_1_val = *prop;
155 prop = of_get_property(np, "chr_2", NULL);
157 pdata.chr_2_val = *prop;
159 prop = of_get_property(np, "chr_10", NULL);
161 pdata.chr_10_val = *prop;
163 prop = of_get_property(np, "mpcr", NULL);
165 pdata.mpcr_val = *prop;
167 prop = of_get_property(brg, "bcr", NULL);
169 pdata.bcr_val = *prop;
171 pdata.brg_can_tune = 1; /* All current revs need this set */
173 prop = of_get_property(brg, "clock-src", NULL);
175 pdata.brg_clk_src = *prop;
177 prop = of_get_property(brg, "clock-frequency", NULL);
179 pdata.brg_clk_freq = *prop;
181 pdev = platform_device_alloc(MPSC_CTLR_NAME, port_number);
185 err = platform_device_add_resources(pdev, r, 5);
189 err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
193 err = platform_device_add(pdev);
200 platform_device_put(pdev);
204 static int __init mv64x60_device_setup(void)
206 struct device_node *np = NULL;
211 (np = of_find_compatible_node(np, "serial", "marvell,mpsc")); id++)
212 if ((err = mv64x60_mpsc_device_setup(np, id)))
221 arch_initcall(mv64x60_device_setup);