Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Freescale Lite5200 board support |
| 3 | * |
| 4 | * Written by: Grant Likely <grant.likely@secretlab.ca> |
| 5 | * |
| 6 | * Copyright (C) Secret Lab Technologies Ltd. 2006. All rights reserved. |
| 7 | * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved. |
| 8 | * |
| 9 | * Description: |
| 10 | * This program is free software; you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public License as published by the |
| 12 | * Free Software Foundation; either version 2 of the License, or (at your |
| 13 | * option) any later version. |
| 14 | */ |
| 15 | |
| 16 | #undef DEBUG |
| 17 | |
| 18 | #include <linux/stddef.h> |
| 19 | #include <linux/kernel.h> |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/errno.h> |
| 22 | #include <linux/reboot.h> |
| 23 | #include <linux/pci.h> |
| 24 | #include <linux/kdev_t.h> |
| 25 | #include <linux/major.h> |
| 26 | #include <linux/console.h> |
| 27 | #include <linux/delay.h> |
| 28 | #include <linux/seq_file.h> |
| 29 | #include <linux/root_dev.h> |
| 30 | #include <linux/initrd.h> |
| 31 | |
| 32 | #include <asm/system.h> |
| 33 | #include <asm/atomic.h> |
| 34 | #include <asm/time.h> |
| 35 | #include <asm/io.h> |
| 36 | #include <asm/machdep.h> |
| 37 | #include <asm/ipic.h> |
| 38 | #include <asm/bootinfo.h> |
| 39 | #include <asm/irq.h> |
| 40 | #include <asm/prom.h> |
| 41 | #include <asm/udbg.h> |
| 42 | #include <sysdev/fsl_soc.h> |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 43 | #include <asm/of_platform.h> |
| 44 | |
| 45 | #include <asm/mpc52xx.h> |
| 46 | |
| 47 | /* ************************************************************************ |
| 48 | * |
| 49 | * Setup the architecture |
| 50 | * |
| 51 | */ |
| 52 | |
| 53 | static void __init |
Grant Likely | e3aba81 | 2007-02-12 13:36:55 -0700 | [diff] [blame] | 54 | lite5200_setup_cpu(void) |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 55 | { |
| 56 | struct mpc52xx_gpio __iomem *gpio; |
| 57 | u32 port_config; |
| 58 | |
| 59 | /* Map zones */ |
Grant Likely | e3aba81 | 2007-02-12 13:36:55 -0700 | [diff] [blame] | 60 | gpio = mpc52xx_find_and_map("mpc5200-gpio"); |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 61 | if (!gpio) { |
| 62 | printk(KERN_ERR __FILE__ ": " |
| 63 | "Error while mapping GPIO register for port config. " |
| 64 | "Expect some abnormal behavior\n"); |
| 65 | goto error; |
| 66 | } |
| 67 | |
| 68 | /* Set port config */ |
| 69 | port_config = in_be32(&gpio->port_config); |
| 70 | |
| 71 | port_config &= ~0x00800000; /* 48Mhz internal, pin is GPIO */ |
| 72 | |
| 73 | port_config &= ~0x00007000; /* USB port : Differential mode */ |
| 74 | port_config |= 0x00001000; /* USB 1 only */ |
| 75 | |
| 76 | port_config &= ~0x03000000; /* ATA CS is on csb_4/5 */ |
| 77 | port_config |= 0x01000000; |
| 78 | |
| 79 | pr_debug("port_config: old:%x new:%x\n", |
| 80 | in_be32(&gpio->port_config), port_config); |
| 81 | out_be32(&gpio->port_config, port_config); |
| 82 | |
| 83 | /* Unmap zone */ |
| 84 | error: |
| 85 | iounmap(gpio); |
| 86 | } |
| 87 | |
Domen Puncer | 2e1ee1f | 2007-05-07 01:38:52 +1000 | [diff] [blame] | 88 | #ifdef CONFIG_PM |
| 89 | static u32 descr_a; |
| 90 | static void lite5200_suspend_prepare(void __iomem *mbar) |
| 91 | { |
| 92 | u8 pin = 1; /* GPIO_WKUP_1 (GPIO_PSC2_4) */ |
| 93 | u8 level = 0; /* wakeup on low level */ |
| 94 | mpc52xx_set_wakeup_gpio(pin, level); |
| 95 | |
| 96 | /* |
| 97 | * power down usb port |
| 98 | * this needs to be called before of-ohci suspend code |
| 99 | */ |
| 100 | descr_a = in_be32(mbar + 0x1048); |
| 101 | out_be32(mbar + 0x1048, (descr_a & ~0x200) | 0x100); |
| 102 | } |
| 103 | |
| 104 | static void lite5200_resume_finish(void __iomem *mbar) |
| 105 | { |
| 106 | out_be32(mbar + 0x1048, descr_a); |
| 107 | } |
| 108 | #endif |
| 109 | |
Grant Likely | e3aba81 | 2007-02-12 13:36:55 -0700 | [diff] [blame] | 110 | static void __init lite5200_setup_arch(void) |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 111 | { |
Jon Loeliger | 7888fbf | 2007-07-28 04:24:52 +1000 | [diff] [blame^] | 112 | #ifdef CONFIG_PCI |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 113 | struct device_node *np; |
Jon Loeliger | 7888fbf | 2007-07-28 04:24:52 +1000 | [diff] [blame^] | 114 | #endif |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 115 | |
| 116 | if (ppc_md.progress) |
Grant Likely | e3aba81 | 2007-02-12 13:36:55 -0700 | [diff] [blame] | 117 | ppc_md.progress("lite5200_setup_arch()", 0); |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 118 | |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 119 | /* CPU & Port mux setup */ |
| 120 | mpc52xx_setup_cpu(); /* Generic */ |
Grant Likely | e3aba81 | 2007-02-12 13:36:55 -0700 | [diff] [blame] | 121 | lite5200_setup_cpu(); /* Platorm specific */ |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 122 | |
Domen Puncer | 2e1ee1f | 2007-05-07 01:38:52 +1000 | [diff] [blame] | 123 | #ifdef CONFIG_PM |
| 124 | mpc52xx_suspend.board_suspend_prepare = lite5200_suspend_prepare; |
| 125 | mpc52xx_suspend.board_resume_finish = lite5200_resume_finish; |
| 126 | mpc52xx_pm_init(); |
| 127 | #endif |
| 128 | |
Grant Likely | f42963f | 2006-12-12 15:13:19 -0700 | [diff] [blame] | 129 | #ifdef CONFIG_PCI |
John Rigby | 6ec3670 | 2007-04-07 08:57:37 +1000 | [diff] [blame] | 130 | np = of_find_node_by_type(NULL, "pci"); |
| 131 | if (np) { |
Grant Likely | f42963f | 2006-12-12 15:13:19 -0700 | [diff] [blame] | 132 | mpc52xx_add_bridge(np); |
John Rigby | 6ec3670 | 2007-04-07 08:57:37 +1000 | [diff] [blame] | 133 | of_node_put(np); |
| 134 | } |
Grant Likely | f42963f | 2006-12-12 15:13:19 -0700 | [diff] [blame] | 135 | #endif |
| 136 | |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 137 | #ifdef CONFIG_BLK_DEV_INITRD |
| 138 | if (initrd_start) |
| 139 | ROOT_DEV = Root_RAM0; |
| 140 | else |
| 141 | #endif |
| 142 | #ifdef CONFIG_ROOT_NFS |
| 143 | ROOT_DEV = Root_NFS; |
| 144 | #else |
| 145 | ROOT_DEV = Root_HDA1; |
| 146 | #endif |
| 147 | |
| 148 | } |
| 149 | |
Domen Puncer | d3e0e02 | 2007-07-09 09:52:03 +0200 | [diff] [blame] | 150 | static void lite5200_show_cpuinfo(struct seq_file *m) |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 151 | { |
| 152 | struct device_node* np = of_find_all_nodes(NULL); |
| 153 | const char *model = NULL; |
| 154 | |
| 155 | if (np) |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 156 | model = of_get_property(np, "model", NULL); |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 157 | |
| 158 | seq_printf(m, "vendor\t\t: Freescale Semiconductor\n"); |
| 159 | seq_printf(m, "machine\t\t: %s\n", model ? model : "unknown"); |
| 160 | |
| 161 | of_node_put(np); |
| 162 | } |
| 163 | |
| 164 | /* |
| 165 | * Called very early, MMU is off, device-tree isn't unflattened |
| 166 | */ |
Grant Likely | e3aba81 | 2007-02-12 13:36:55 -0700 | [diff] [blame] | 167 | static int __init lite5200_probe(void) |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 168 | { |
| 169 | unsigned long node = of_get_flat_dt_root(); |
| 170 | const char *model = of_get_flat_dt_prop(node, "model", NULL); |
| 171 | |
Grant Likely | e3aba81 | 2007-02-12 13:36:55 -0700 | [diff] [blame] | 172 | if (!of_flat_dt_is_compatible(node, "fsl,lite5200") && |
| 173 | !of_flat_dt_is_compatible(node, "fsl,lite5200b")) |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 174 | return 0; |
Grant Likely | e3aba81 | 2007-02-12 13:36:55 -0700 | [diff] [blame] | 175 | pr_debug("%s board found\n", model ? model : "unknown"); |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 176 | |
| 177 | return 1; |
| 178 | } |
| 179 | |
Grant Likely | e3aba81 | 2007-02-12 13:36:55 -0700 | [diff] [blame] | 180 | define_machine(lite5200) { |
| 181 | .name = "lite5200", |
| 182 | .probe = lite5200_probe, |
| 183 | .setup_arch = lite5200_setup_arch, |
Sylvain Munaut | 5c334ee | 2007-01-02 23:29:53 +0100 | [diff] [blame] | 184 | .init = mpc52xx_declare_of_platform_devices, |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 185 | .init_IRQ = mpc52xx_init_irq, |
| 186 | .get_irq = mpc52xx_get_irq, |
Grant Likely | e3aba81 | 2007-02-12 13:36:55 -0700 | [diff] [blame] | 187 | .show_cpuinfo = lite5200_show_cpuinfo, |
Grant Likely | 6b64253 | 2006-11-27 14:16:28 -0700 | [diff] [blame] | 188 | .calibrate_decr = generic_calibrate_decr, |
| 189 | }; |