Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Platform setup for the MPC8xx based boards from TQM.
0003  *
0004  * Heiko Schocher <hs@denx.de>
0005  * Copyright 2010 DENX Software Engineering GmbH
0006  *
0007  * based on:
0008  * Vitaly Bordug <vbordug@ru.mvista.com>
0009  *
0010  * Copyright 2005 MontaVista Software Inc.
0011  *
0012  * Heavily modified by Scott Wood <scottwood@freescale.com>
0013  * Copyright 2007 Freescale Semiconductor, Inc.
0014  *
0015  * This file is licensed under the terms of the GNU General Public License
0016  * version 2. This program is licensed "as is" without any warranty of any
0017  * kind, whether express or implied.
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     /* SMC1 */
0054     {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */
0055     {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */
0056 
0057     /* SCC1 */
0058     {CPM_PORTA, 5, CPM_PIN_INPUT}, /* CLK1 */
0059     {CPM_PORTA, 7, CPM_PIN_INPUT}, /* CLK2 */
0060     {CPM_PORTA, 14, CPM_PIN_INPUT}, /* TX */
0061     {CPM_PORTA, 15, CPM_PIN_INPUT}, /* RX */
0062     {CPM_PORTC, 15, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TENA */
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     /* MII */
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     /* init FEC pins */
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 };