Dale Farnsworth | fd4ba7e | 2007-05-12 10:58:43 +1000 | [diff] [blame^] | 1 | /* |
| 2 | * Board setup routines for the Motorola PrPMC2800 |
| 3 | * |
| 4 | * Author: Dale Farnsworth <dale@farnsworth.org> |
| 5 | * |
| 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 |
| 9 | * or implied. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/stddef.h> |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/delay.h> |
| 15 | #include <linux/interrupt.h> |
| 16 | #include <linux/seq_file.h> |
| 17 | |
| 18 | #include <asm/machdep.h> |
| 19 | #include <asm/prom.h> |
| 20 | #include <asm/system.h> |
| 21 | #include <asm/time.h> |
| 22 | #include <asm/kexec.h> |
| 23 | |
| 24 | #include <mm/mmu_decl.h> |
| 25 | |
| 26 | #include <sysdev/mv64x60.h> |
| 27 | |
| 28 | #define MV64x60_MPP_CNTL_0 0x0000 |
| 29 | #define MV64x60_MPP_CNTL_2 0x0008 |
| 30 | |
| 31 | #define MV64x60_GPP_IO_CNTL 0x0000 |
| 32 | #define MV64x60_GPP_LEVEL_CNTL 0x0010 |
| 33 | #define MV64x60_GPP_VALUE_SET 0x0018 |
| 34 | |
| 35 | #define PLATFORM_NAME_MAX 32 |
| 36 | |
| 37 | static char prpmc2800_platform_name[PLATFORM_NAME_MAX]; |
| 38 | |
| 39 | static void __iomem *mv64x60_mpp_reg_base; |
| 40 | static void __iomem *mv64x60_gpp_reg_base; |
| 41 | |
| 42 | static void __init prpmc2800_setup_arch(void) |
| 43 | { |
| 44 | struct device_node *np; |
| 45 | phys_addr_t paddr; |
| 46 | const unsigned int *reg; |
| 47 | const unsigned int *prop; |
| 48 | |
| 49 | /* |
| 50 | * ioremap mpp and gpp registers in case they are later |
| 51 | * needed by prpmc2800_reset_board(). |
| 52 | */ |
| 53 | np = of_find_compatible_node(NULL, NULL, "marvell,mv64x60-mpp"); |
| 54 | reg = of_get_property(np, "reg", NULL); |
| 55 | paddr = of_translate_address(np, reg); |
| 56 | of_node_put(np); |
| 57 | mv64x60_mpp_reg_base = ioremap(paddr, reg[1]); |
| 58 | |
| 59 | np = of_find_compatible_node(NULL, NULL, "marvell,mv64x60-gpp"); |
| 60 | reg = of_get_property(np, "reg", NULL); |
| 61 | paddr = of_translate_address(np, reg); |
| 62 | of_node_put(np); |
| 63 | mv64x60_gpp_reg_base = ioremap(paddr, reg[1]); |
| 64 | |
| 65 | np = of_find_node_by_type(NULL, "cpu"); |
| 66 | prop = of_get_property(np, "clock-frequency", NULL); |
| 67 | if (prop) |
| 68 | loops_per_jiffy = *prop / HZ; |
| 69 | of_node_put(np); |
| 70 | |
| 71 | #ifdef CONFIG_PCI |
| 72 | mv64x60_pci_init(); |
| 73 | #endif |
| 74 | |
| 75 | printk("Motorola %s\n", prpmc2800_platform_name); |
| 76 | } |
| 77 | |
| 78 | static void prpmc2800_reset_board(void) |
| 79 | { |
| 80 | u32 temp; |
| 81 | |
| 82 | local_irq_disable(); |
| 83 | |
| 84 | temp = in_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_0); |
| 85 | temp &= 0xFFFF0FFF; |
| 86 | out_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_0, temp); |
| 87 | |
| 88 | temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL); |
| 89 | temp |= 0x00000004; |
| 90 | out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL, temp); |
| 91 | |
| 92 | temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL); |
| 93 | temp |= 0x00000004; |
| 94 | out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL, temp); |
| 95 | |
| 96 | temp = in_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_2); |
| 97 | temp &= 0xFFFF0FFF; |
| 98 | out_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_2, temp); |
| 99 | |
| 100 | temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL); |
| 101 | temp |= 0x00080000; |
| 102 | out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL, temp); |
| 103 | |
| 104 | temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL); |
| 105 | temp |= 0x00080000; |
| 106 | out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL, temp); |
| 107 | |
| 108 | out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_VALUE_SET, 0x00080004); |
| 109 | } |
| 110 | |
| 111 | static void prpmc2800_restart(char *cmd) |
| 112 | { |
| 113 | volatile ulong i = 10000000; |
| 114 | |
| 115 | prpmc2800_reset_board(); |
| 116 | |
| 117 | while (i-- > 0); |
| 118 | panic("restart failed\n"); |
| 119 | } |
| 120 | |
| 121 | #ifdef CONFIG_NOT_COHERENT_CACHE |
| 122 | #define PPRPM2800_COHERENCY_SETTING "off" |
| 123 | #else |
| 124 | #define PPRPM2800_COHERENCY_SETTING "on" |
| 125 | #endif |
| 126 | |
| 127 | void prpmc2800_show_cpuinfo(struct seq_file *m) |
| 128 | { |
| 129 | uint memsize = total_memory; |
| 130 | |
| 131 | seq_printf(m, "Vendor\t\t: Motorola\n"); |
| 132 | seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024)); |
| 133 | seq_printf(m, "coherency\t: %s\n", PPRPM2800_COHERENCY_SETTING); |
| 134 | } |
| 135 | |
| 136 | /* |
| 137 | * Called very early, device-tree isn't unflattened |
| 138 | */ |
| 139 | static int __init prpmc2800_probe(void) |
| 140 | { |
| 141 | unsigned long root = of_get_flat_dt_root(); |
| 142 | unsigned long len = PLATFORM_NAME_MAX; |
| 143 | void *m; |
| 144 | |
| 145 | if (!of_flat_dt_is_compatible(root, "motorola,PrPMC2800")) |
| 146 | return 0; |
| 147 | |
| 148 | /* Update ppc_md.name with name from dt */ |
| 149 | m = of_get_flat_dt_prop(root, "model", &len); |
| 150 | if (m) |
| 151 | strncpy(prpmc2800_platform_name, m, |
| 152 | min((int)len, PLATFORM_NAME_MAX - 1)); |
| 153 | |
| 154 | return 1; |
| 155 | } |
| 156 | |
| 157 | define_machine(prpmc2800){ |
| 158 | .name = prpmc2800_platform_name, |
| 159 | .probe = prpmc2800_probe, |
| 160 | .setup_arch = prpmc2800_setup_arch, |
| 161 | .show_cpuinfo = prpmc2800_show_cpuinfo, |
| 162 | .init_IRQ = mv64x60_init_irq, |
| 163 | .get_irq = mv64x60_get_irq, |
| 164 | .restart = prpmc2800_restart, |
| 165 | .calibrate_decr = generic_calibrate_decr, |
| 166 | #ifdef CONFIG_KEXEC |
| 167 | .machine_kexec = default_machine_kexec, |
| 168 | .machine_kexec_prepare = default_machine_kexec_prepare, |
| 169 | .machine_crash_shutdown = default_machine_crash_shutdown, |
| 170 | #endif |
| 171 | }; |