Back to home page

OSCL-LXR

 
 

    


0001 /*arch/powerpc/platforms/8xx/mpc86xads_setup.c
0002  *
0003  * Platform setup for the Freescale mpc86xads board
0004  *
0005  * Vitaly Bordug <vbordug@ru.mvista.com>
0006  *
0007  * Copyright 2005 MontaVista Software Inc.
0008  *
0009  * Heavily modified by Scott Wood <scottwood@freescale.com>
0010  * Copyright 2007 Freescale Semiconductor, Inc.
0011  *
0012  * This file is licensed under the terms of the GNU General Public License
0013  * version 2. This program is licensed "as is" without any warranty of any
0014  * kind, whether express or implied.
0015  */
0016 
0017 #include <linux/init.h>
0018 #include <linux/of_address.h>
0019 #include <linux/of_fdt.h>
0020 #include <linux/of_platform.h>
0021 
0022 #include <asm/io.h>
0023 #include <asm/machdep.h>
0024 #include <asm/time.h>
0025 #include <asm/8xx_immap.h>
0026 #include <asm/cpm1.h>
0027 #include <asm/fs_pd.h>
0028 #include <asm/udbg.h>
0029 
0030 #include "mpc86xads.h"
0031 #include "mpc8xx.h"
0032 #include "pic.h"
0033 
0034 struct cpm_pin {
0035     int port, pin, flags;
0036 };
0037 
0038 static struct cpm_pin mpc866ads_pins[] = {
0039     /* SMC1 */
0040     {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */
0041     {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */
0042 
0043     /* SMC2 */
0044     {CPM_PORTB, 21, CPM_PIN_INPUT}, /* RX */
0045     {CPM_PORTB, 20, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */
0046 
0047     /* SCC1 */
0048     {CPM_PORTA, 6, CPM_PIN_INPUT}, /* CLK1 */
0049     {CPM_PORTA, 7, CPM_PIN_INPUT}, /* CLK2 */
0050     {CPM_PORTA, 14, CPM_PIN_INPUT}, /* TX */
0051     {CPM_PORTA, 15, CPM_PIN_INPUT}, /* RX */
0052     {CPM_PORTB, 19, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TENA */
0053     {CPM_PORTC, 10, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* RENA */
0054     {CPM_PORTC, 11, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* CLSN */
0055 
0056     /* MII */
0057     {CPM_PORTD, 3, CPM_PIN_OUTPUT},
0058     {CPM_PORTD, 4, CPM_PIN_OUTPUT},
0059     {CPM_PORTD, 5, CPM_PIN_OUTPUT},
0060     {CPM_PORTD, 6, CPM_PIN_OUTPUT},
0061     {CPM_PORTD, 7, CPM_PIN_OUTPUT},
0062     {CPM_PORTD, 8, CPM_PIN_OUTPUT},
0063     {CPM_PORTD, 9, CPM_PIN_OUTPUT},
0064     {CPM_PORTD, 10, CPM_PIN_OUTPUT},
0065     {CPM_PORTD, 11, CPM_PIN_OUTPUT},
0066     {CPM_PORTD, 12, CPM_PIN_OUTPUT},
0067     {CPM_PORTD, 13, CPM_PIN_OUTPUT},
0068     {CPM_PORTD, 14, CPM_PIN_OUTPUT},
0069     {CPM_PORTD, 15, CPM_PIN_OUTPUT},
0070 
0071     /* I2C */
0072     {CPM_PORTB, 26, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN},
0073     {CPM_PORTB, 27, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN},
0074 };
0075 
0076 static void __init init_ioports(void)
0077 {
0078     int i;
0079 
0080     for (i = 0; i < ARRAY_SIZE(mpc866ads_pins); i++) {
0081         struct cpm_pin *pin = &mpc866ads_pins[i];
0082         cpm1_set_pin(pin->port, pin->pin, pin->flags);
0083     }
0084 
0085     cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX);
0086     cpm1_clk_setup(CPM_CLK_SMC2, CPM_BRG2, CPM_CLK_RTX);
0087     cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK1, CPM_CLK_TX);
0088     cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK2, CPM_CLK_RX);
0089 
0090     /* Set FEC1 and FEC2 to MII mode */
0091     clrbits32(&mpc8xx_immr->im_cpm.cp_cptr, 0x00000180);
0092 }
0093 
0094 static void __init mpc86xads_setup_arch(void)
0095 {
0096     struct device_node *np;
0097     u32 __iomem *bcsr_io;
0098 
0099     cpm_reset();
0100     init_ioports();
0101 
0102     np = of_find_compatible_node(NULL, NULL, "fsl,mpc866ads-bcsr");
0103     if (!np) {
0104         printk(KERN_CRIT "Could not find fsl,mpc866ads-bcsr node\n");
0105         return;
0106     }
0107 
0108     bcsr_io = of_iomap(np, 0);
0109     of_node_put(np);
0110 
0111     if (bcsr_io == NULL) {
0112         printk(KERN_CRIT "Could not remap BCSR\n");
0113         return;
0114     }
0115 
0116     clrbits32(bcsr_io, BCSR1_RS232EN_1 | BCSR1_RS232EN_2 | BCSR1_ETHEN);
0117     iounmap(bcsr_io);
0118 }
0119 
0120 static int __init mpc86xads_probe(void)
0121 {
0122     return of_machine_is_compatible("fsl,mpc866ads");
0123 }
0124 
0125 static const struct of_device_id of_bus_ids[] __initconst = {
0126     { .name = "soc", },
0127     { .name = "cpm", },
0128     { .name = "localbus", },
0129     {},
0130 };
0131 
0132 static int __init declare_of_platform_devices(void)
0133 {
0134     of_platform_bus_probe(NULL, of_bus_ids, NULL);
0135 
0136     return 0;
0137 }
0138 machine_device_initcall(mpc86x_ads, declare_of_platform_devices);
0139 
0140 define_machine(mpc86x_ads) {
0141     .name           = "MPC86x ADS",
0142     .probe          = mpc86xads_probe,
0143     .setup_arch     = mpc86xads_setup_arch,
0144     .init_IRQ       = mpc8xx_pic_init,
0145     .get_irq        = mpc8xx_get_irq,
0146     .restart        = mpc8xx_restart,
0147     .calibrate_decr     = mpc8xx_calibrate_decr,
0148     .set_rtc_time       = mpc8xx_set_rtc_time,
0149     .get_rtc_time       = mpc8xx_get_rtc_time,
0150     .progress       = udbg_progress,
0151 };