0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <linux/init.h>
0021 #include <linux/param.h>
0022 #include <linux/string.h>
0023 #include <linux/ioport.h>
0024 #include <linux/device.h>
0025 #include <linux/delay.h>
0026
0027 #include <linux/fs_enet_pd.h>
0028 #include <linux/fs_uart_pd.h>
0029 #include <linux/fsl_devices.h>
0030 #include <linux/mii.h>
0031 #include <linux/of_fdt.h>
0032 #include <linux/of_platform.h>
0033
0034 #include <asm/delay.h>
0035 #include <asm/io.h>
0036 #include <asm/machdep.h>
0037 #include <asm/page.h>
0038 #include <asm/processor.h>
0039 #include <asm/time.h>
0040 #include <asm/8xx_immap.h>
0041 #include <asm/cpm1.h>
0042 #include <asm/fs_pd.h>
0043 #include <asm/udbg.h>
0044
0045 #include "mpc8xx.h"
0046 #include "pic.h"
0047
0048 struct cpm_pin {
0049 int port, pin, flags;
0050 };
0051
0052 static struct cpm_pin tqm8xx_pins[] __initdata = {
0053
0054 {CPM_PORTB, 24, CPM_PIN_INPUT},
0055 {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
0056
0057
0058 {CPM_PORTA, 5, CPM_PIN_INPUT},
0059 {CPM_PORTA, 7, CPM_PIN_INPUT},
0060 {CPM_PORTA, 14, CPM_PIN_INPUT},
0061 {CPM_PORTA, 15, CPM_PIN_INPUT},
0062 {CPM_PORTC, 15, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
0063 {CPM_PORTC, 10, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO},
0064 {CPM_PORTC, 11, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO},
0065 };
0066
0067 static struct cpm_pin tqm8xx_fec_pins[] __initdata = {
0068
0069 {CPM_PORTD, 3, CPM_PIN_OUTPUT},
0070 {CPM_PORTD, 4, CPM_PIN_OUTPUT},
0071 {CPM_PORTD, 5, CPM_PIN_OUTPUT},
0072 {CPM_PORTD, 6, CPM_PIN_OUTPUT},
0073 {CPM_PORTD, 7, CPM_PIN_OUTPUT},
0074 {CPM_PORTD, 8, CPM_PIN_OUTPUT},
0075 {CPM_PORTD, 9, CPM_PIN_OUTPUT},
0076 {CPM_PORTD, 10, CPM_PIN_OUTPUT},
0077 {CPM_PORTD, 11, CPM_PIN_OUTPUT},
0078 {CPM_PORTD, 12, CPM_PIN_OUTPUT},
0079 {CPM_PORTD, 13, CPM_PIN_OUTPUT},
0080 {CPM_PORTD, 14, CPM_PIN_OUTPUT},
0081 {CPM_PORTD, 15, CPM_PIN_OUTPUT},
0082 };
0083
0084 static void __init init_pins(int n, struct cpm_pin *pin)
0085 {
0086 int i;
0087
0088 for (i = 0; i < n; i++) {
0089 cpm1_set_pin(pin->port, pin->pin, pin->flags);
0090 pin++;
0091 }
0092 }
0093
0094 static void __init init_ioports(void)
0095 {
0096 struct device_node *dnode;
0097 struct property *prop;
0098 int len;
0099
0100 init_pins(ARRAY_SIZE(tqm8xx_pins), &tqm8xx_pins[0]);
0101
0102 cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX);
0103
0104 dnode = of_find_node_by_name(NULL, "aliases");
0105 if (dnode == NULL)
0106 return;
0107 prop = of_find_property(dnode, "ethernet1", &len);
0108 if (prop == NULL)
0109 return;
0110
0111
0112 init_pins(ARRAY_SIZE(tqm8xx_fec_pins), &tqm8xx_fec_pins[0]);
0113 }
0114
0115 static void __init tqm8xx_setup_arch(void)
0116 {
0117 cpm_reset();
0118 init_ioports();
0119 }
0120
0121 static int __init tqm8xx_probe(void)
0122 {
0123 return of_machine_is_compatible("tqc,tqm8xx");
0124 }
0125
0126 static const struct of_device_id of_bus_ids[] __initconst = {
0127 { .name = "soc", },
0128 { .name = "cpm", },
0129 { .name = "localbus", },
0130 { .compatible = "simple-bus" },
0131 {},
0132 };
0133
0134 static int __init declare_of_platform_devices(void)
0135 {
0136 of_platform_bus_probe(NULL, of_bus_ids, NULL);
0137
0138 return 0;
0139 }
0140 machine_device_initcall(tqm8xx, declare_of_platform_devices);
0141
0142 define_machine(tqm8xx) {
0143 .name = "TQM8xx",
0144 .probe = tqm8xx_probe,
0145 .setup_arch = tqm8xx_setup_arch,
0146 .init_IRQ = mpc8xx_pic_init,
0147 .get_irq = mpc8xx_get_irq,
0148 .restart = mpc8xx_restart,
0149 .calibrate_decr = mpc8xx_calibrate_decr,
0150 .set_rtc_time = mpc8xx_set_rtc_time,
0151 .get_rtc_time = mpc8xx_get_rtc_time,
0152 .progress = udbg_progress,
0153 };