Heiko Schocher | c4b6a77 | 2010-03-23 08:57:01 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Platform setup for the MPC8xx based boards from TQM. |
| 3 | * |
| 4 | * Heiko Schocher <hs@denx.de> |
| 5 | * Copyright 2010 DENX Software Engineering GmbH |
| 6 | * |
| 7 | * based on: |
| 8 | * Vitaly Bordug <vbordug@ru.mvista.com> |
| 9 | * |
| 10 | * Copyright 2005 MontaVista Software Inc. |
| 11 | * |
| 12 | * Heavily modified by Scott Wood <scottwood@freescale.com> |
| 13 | * Copyright 2007 Freescale Semiconductor, Inc. |
| 14 | * |
| 15 | * This file is licensed under the terms of the GNU General Public License |
| 16 | * version 2. This program is licensed "as is" without any warranty of any |
| 17 | * kind, whether express or implied. |
| 18 | */ |
| 19 | |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/module.h> |
| 22 | #include <linux/param.h> |
| 23 | #include <linux/string.h> |
| 24 | #include <linux/ioport.h> |
| 25 | #include <linux/device.h> |
| 26 | #include <linux/delay.h> |
| 27 | |
| 28 | #include <linux/fs_enet_pd.h> |
| 29 | #include <linux/fs_uart_pd.h> |
| 30 | #include <linux/fsl_devices.h> |
| 31 | #include <linux/mii.h> |
| 32 | #include <linux/of_platform.h> |
| 33 | |
| 34 | #include <asm/delay.h> |
| 35 | #include <asm/io.h> |
| 36 | #include <asm/machdep.h> |
| 37 | #include <asm/page.h> |
| 38 | #include <asm/processor.h> |
| 39 | #include <asm/system.h> |
| 40 | #include <asm/time.h> |
| 41 | #include <asm/mpc8xx.h> |
| 42 | #include <asm/8xx_immap.h> |
| 43 | #include <asm/cpm1.h> |
| 44 | #include <asm/fs_pd.h> |
| 45 | #include <asm/udbg.h> |
| 46 | |
| 47 | #include "mpc8xx.h" |
| 48 | |
| 49 | struct cpm_pin { |
| 50 | int port, pin, flags; |
| 51 | }; |
| 52 | |
| 53 | static struct __initdata cpm_pin tqm8xx_pins[] = { |
| 54 | /* SMC1 */ |
| 55 | {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */ |
| 56 | {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */ |
| 57 | |
| 58 | /* SCC1 */ |
| 59 | {CPM_PORTA, 5, CPM_PIN_INPUT}, /* CLK1 */ |
| 60 | {CPM_PORTA, 7, CPM_PIN_INPUT}, /* CLK2 */ |
| 61 | {CPM_PORTA, 14, CPM_PIN_INPUT}, /* TX */ |
| 62 | {CPM_PORTA, 15, CPM_PIN_INPUT}, /* RX */ |
| 63 | {CPM_PORTC, 15, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TENA */ |
| 64 | {CPM_PORTC, 10, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, |
| 65 | {CPM_PORTC, 11, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, |
| 66 | }; |
| 67 | |
| 68 | static struct __initdata cpm_pin tqm8xx_fec_pins[] = { |
| 69 | /* MII */ |
| 70 | {CPM_PORTD, 3, CPM_PIN_OUTPUT}, |
| 71 | {CPM_PORTD, 4, CPM_PIN_OUTPUT}, |
| 72 | {CPM_PORTD, 5, CPM_PIN_OUTPUT}, |
| 73 | {CPM_PORTD, 6, CPM_PIN_OUTPUT}, |
| 74 | {CPM_PORTD, 7, CPM_PIN_OUTPUT}, |
| 75 | {CPM_PORTD, 8, CPM_PIN_OUTPUT}, |
| 76 | {CPM_PORTD, 9, CPM_PIN_OUTPUT}, |
| 77 | {CPM_PORTD, 10, CPM_PIN_OUTPUT}, |
| 78 | {CPM_PORTD, 11, CPM_PIN_OUTPUT}, |
| 79 | {CPM_PORTD, 12, CPM_PIN_OUTPUT}, |
| 80 | {CPM_PORTD, 13, CPM_PIN_OUTPUT}, |
| 81 | {CPM_PORTD, 14, CPM_PIN_OUTPUT}, |
| 82 | {CPM_PORTD, 15, CPM_PIN_OUTPUT}, |
| 83 | }; |
| 84 | |
| 85 | static void __init init_pins(int n, struct cpm_pin *pin) |
| 86 | { |
| 87 | int i; |
| 88 | |
| 89 | for (i = 0; i < n; i++) { |
| 90 | cpm1_set_pin(pin->port, pin->pin, pin->flags); |
| 91 | pin++; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | static void __init init_ioports(void) |
| 96 | { |
| 97 | struct device_node *dnode; |
| 98 | struct property *prop; |
| 99 | int len; |
| 100 | |
| 101 | init_pins(ARRAY_SIZE(tqm8xx_pins), &tqm8xx_pins[0]); |
| 102 | |
| 103 | cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX); |
| 104 | |
| 105 | dnode = of_find_node_by_name(NULL, "aliases"); |
| 106 | if (dnode == NULL) |
| 107 | return; |
| 108 | prop = of_find_property(dnode, "ethernet1", &len); |
| 109 | if (prop == NULL) |
| 110 | return; |
| 111 | |
| 112 | /* init FEC pins */ |
| 113 | init_pins(ARRAY_SIZE(tqm8xx_fec_pins), &tqm8xx_fec_pins[0]); |
| 114 | } |
| 115 | |
| 116 | static void __init tqm8xx_setup_arch(void) |
| 117 | { |
| 118 | cpm_reset(); |
| 119 | init_ioports(); |
| 120 | } |
| 121 | |
| 122 | static int __init tqm8xx_probe(void) |
| 123 | { |
| 124 | unsigned long node = of_get_flat_dt_root(); |
| 125 | |
| 126 | return of_flat_dt_is_compatible(node, "tqc,tqm8xx"); |
| 127 | } |
| 128 | |
| 129 | static struct of_device_id __initdata of_bus_ids[] = { |
| 130 | { .name = "soc", }, |
| 131 | { .name = "cpm", }, |
| 132 | { .name = "localbus", }, |
| 133 | { .compatible = "simple-bus" }, |
| 134 | {}, |
| 135 | }; |
| 136 | |
| 137 | static int __init declare_of_platform_devices(void) |
| 138 | { |
| 139 | of_platform_bus_probe(NULL, of_bus_ids, NULL); |
| 140 | |
| 141 | return 0; |
| 142 | } |
| 143 | machine_device_initcall(tqm8xx, declare_of_platform_devices); |
| 144 | |
| 145 | define_machine(tqm8xx) { |
| 146 | .name = "TQM8xx", |
| 147 | .probe = tqm8xx_probe, |
| 148 | .setup_arch = tqm8xx_setup_arch, |
| 149 | .init_IRQ = mpc8xx_pics_init, |
| 150 | .get_irq = mpc8xx_get_irq, |
| 151 | .restart = mpc8xx_restart, |
| 152 | .calibrate_decr = mpc8xx_calibrate_decr, |
| 153 | .set_rtc_time = mpc8xx_set_rtc_time, |
| 154 | .get_rtc_time = mpc8xx_get_rtc_time, |
| 155 | .progress = udbg_progress, |
| 156 | }; |