3 * Utility functions for the Freescale MPC52xx.
5 * Copyright (C) 2006 Sylvain Munaut <tnt@246tNt.com>
7 * This file is licensed under the terms of the GNU General Public License
8 * version 2. This program is licensed "as is" without any warranty of any
9 * kind, whether express or implied.
15 #include <linux/kernel.h>
16 #include <linux/of_platform.h>
19 #include <asm/mpc52xx.h>
22 * This variable is mapped in mpc52xx_map_wdt() and used in mpc52xx_restart().
23 * Permanent mapping is required because mpc52xx_restart() can be called
24 * from interrupt context while node mapping (which calls ioremap())
25 * cannot be used at such point.
27 static volatile struct mpc52xx_gpt *mpc52xx_wdt = NULL;
30 * mpc52xx_find_ipb_freq - Find the IPB bus frequency for a device
33 * Returns IPB bus frequency, or 0 if the bus frequency cannot be found.
36 mpc52xx_find_ipb_freq(struct device_node *node)
38 struct device_node *np;
39 const unsigned int *p_ipb_freq = NULL;
43 p_ipb_freq = of_get_property(node, "bus-frequency", NULL);
47 np = of_get_parent(node);
54 return p_ipb_freq ? *p_ipb_freq : 0;
56 EXPORT_SYMBOL(mpc52xx_find_ipb_freq);
60 * Configure the XLB arbiter settings to match what Linux expects.
63 mpc5200_setup_xlb_arbiter(void)
65 struct device_node *np;
66 struct mpc52xx_xlb __iomem *xlb;
68 np = of_find_compatible_node(NULL, NULL, "mpc5200-xlb");
69 xlb = of_iomap(np, 0);
72 printk(KERN_ERR __FILE__ ": "
73 "Error mapping XLB in mpc52xx_setup_cpu(). "
74 "Expect some abnormal behavior\n");
78 /* Configure the XLB Arbiter priorities */
79 out_be32(&xlb->master_pri_enable, 0xff);
80 out_be32(&xlb->master_priority, 0x11111111);
82 /* Disable XLB pipelining
83 * (cfr errate 292. We could do this only just before ATA PIO
84 * transaction and re-enable it afterwards ...)
86 out_be32(&xlb->config, in_be32(&xlb->config) | MPC52xx_XLB_CFG_PLDIS);
91 static struct of_device_id mpc52xx_bus_ids[] __initdata= {
92 { .compatible = "fsl,mpc5200-immr", },
93 { .compatible = "fsl,lpb", },
95 /* depreciated matches; shouldn't be used in new device trees */
96 { .type = "builtin", .compatible = "mpc5200", }, /* efika */
97 { .type = "soc", .compatible = "mpc5200", }, /* lite5200 */
102 mpc52xx_declare_of_platform_devices(void)
104 /* Find every child of the SOC node and add it to of_platform */
105 if (of_platform_bus_probe(NULL, mpc52xx_bus_ids, NULL))
106 printk(KERN_ERR __FILE__ ": "
107 "Error while probing of_platform bus\n");
111 mpc52xx_map_wdt(void)
114 struct device_node *np;
116 /* mpc52xx_wdt is mapped here and used in mpc52xx_restart,
117 * possibly from a interrupt context. wdt is only implement
118 * on a gpt0, so check has-wdt property before mapping.
120 for_each_compatible_node(np, NULL, "fsl,mpc5200-gpt") {
121 has_wdt = of_get_property(np, "fsl,has-wdt", NULL);
123 mpc52xx_wdt = of_iomap(np, 0);
128 for_each_compatible_node(np, NULL, "mpc5200-gpt") {
129 has_wdt = of_get_property(np, "has-wdt", NULL);
131 mpc52xx_wdt = of_iomap(np, 0);
140 mpc52xx_restart(char *cmd)
144 /* Turn on the watchdog and wait for it to expire.
145 * It effectively does a reset. */
147 out_be32(&mpc52xx_wdt->mode, 0x00000000);
148 out_be32(&mpc52xx_wdt->count, 0x000000ff);
149 out_be32(&mpc52xx_wdt->mode, 0x00009004);
151 printk("mpc52xx_restart: Can't access wdt. "
152 "Restart impossible, system halted.\n");