Path: blob/master/arch/powerpc/platforms/8xx/mpc885ads_setup.c
26481 views
/*1* Platform setup for the Freescale mpc885ads board2*3* Vitaly Bordug <[email protected]>4*5* Copyright 2005 MontaVista Software Inc.6*7* Heavily modified by Scott Wood <[email protected]>8* Copyright 2007 Freescale Semiconductor, Inc.9*10* This file is licensed under the terms of the GNU General Public License11* version 2. This program is licensed "as is" without any warranty of any12* kind, whether express or implied.13*/1415#include <linux/init.h>16#include <linux/module.h>17#include <linux/param.h>18#include <linux/string.h>19#include <linux/ioport.h>20#include <linux/device.h>21#include <linux/delay.h>2223#include <linux/fsl_devices.h>24#include <linux/mii.h>25#include <linux/of_address.h>26#include <linux/of_fdt.h>27#include <linux/of_platform.h>2829#include <asm/delay.h>30#include <asm/io.h>31#include <asm/machdep.h>32#include <asm/page.h>33#include <asm/processor.h>34#include <asm/time.h>35#include <asm/8xx_immap.h>36#include <asm/cpm1.h>37#include <asm/udbg.h>3839#include "mpc885ads.h"40#include "mpc8xx.h"41#include "pic.h"4243static u32 __iomem *bcsr, *bcsr5;4445struct cpm_pin {46int port, pin, flags;47};4849static struct cpm_pin mpc885ads_pins[] = {50/* SMC1 */51{CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */52{CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */5354/* SMC2 */55#ifndef CONFIG_MPC8xx_SECOND_ETH_FEC256{CPM_PORTE, 21, CPM_PIN_INPUT}, /* RX */57{CPM_PORTE, 20, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */58#endif5960/* SCC3 */61{CPM_PORTA, 9, CPM_PIN_INPUT}, /* RX */62{CPM_PORTA, 8, CPM_PIN_INPUT}, /* TX */63{CPM_PORTC, 4, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* RENA */64{CPM_PORTC, 5, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* CLSN */65{CPM_PORTE, 27, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TENA */66{CPM_PORTE, 17, CPM_PIN_INPUT}, /* CLK5 */67{CPM_PORTE, 16, CPM_PIN_INPUT}, /* CLK6 */6869/* MII1 */70{CPM_PORTA, 0, CPM_PIN_INPUT},71{CPM_PORTA, 1, CPM_PIN_INPUT},72{CPM_PORTA, 2, CPM_PIN_INPUT},73{CPM_PORTA, 3, CPM_PIN_INPUT},74{CPM_PORTA, 4, CPM_PIN_OUTPUT},75{CPM_PORTA, 10, CPM_PIN_OUTPUT},76{CPM_PORTA, 11, CPM_PIN_OUTPUT},77{CPM_PORTB, 19, CPM_PIN_INPUT},78{CPM_PORTB, 31, CPM_PIN_INPUT},79{CPM_PORTC, 12, CPM_PIN_INPUT},80{CPM_PORTC, 13, CPM_PIN_INPUT},81{CPM_PORTE, 30, CPM_PIN_OUTPUT},82{CPM_PORTE, 31, CPM_PIN_OUTPUT},8384/* MII2 */85#ifdef CONFIG_MPC8xx_SECOND_ETH_FEC286{CPM_PORTE, 14, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},87{CPM_PORTE, 15, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},88{CPM_PORTE, 16, CPM_PIN_OUTPUT},89{CPM_PORTE, 17, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},90{CPM_PORTE, 18, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},91{CPM_PORTE, 19, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},92{CPM_PORTE, 20, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},93{CPM_PORTE, 21, CPM_PIN_OUTPUT},94{CPM_PORTE, 22, CPM_PIN_OUTPUT},95{CPM_PORTE, 23, CPM_PIN_OUTPUT},96{CPM_PORTE, 24, CPM_PIN_OUTPUT},97{CPM_PORTE, 25, CPM_PIN_OUTPUT},98{CPM_PORTE, 26, CPM_PIN_OUTPUT},99{CPM_PORTE, 27, CPM_PIN_OUTPUT},100{CPM_PORTE, 28, CPM_PIN_OUTPUT},101{CPM_PORTE, 29, CPM_PIN_OUTPUT},102#endif103/* I2C */104{CPM_PORTB, 26, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN},105{CPM_PORTB, 27, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN},106};107108static void __init init_ioports(void)109{110int i;111112for (i = 0; i < ARRAY_SIZE(mpc885ads_pins); i++) {113struct cpm_pin *pin = &mpc885ads_pins[i];114cpm1_set_pin(pin->port, pin->pin, pin->flags);115}116117cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX);118cpm1_clk_setup(CPM_CLK_SMC2, CPM_BRG2, CPM_CLK_RTX);119cpm1_clk_setup(CPM_CLK_SCC3, CPM_CLK5, CPM_CLK_TX);120cpm1_clk_setup(CPM_CLK_SCC3, CPM_CLK6, CPM_CLK_RX);121122/* Set FEC1 and FEC2 to MII mode */123clrbits32(&mpc8xx_immr->im_cpm.cp_cptr, 0x00000180);124}125126static void __init mpc885ads_setup_arch(void)127{128struct device_node *np;129130cpm_reset();131init_ioports();132133np = of_find_compatible_node(NULL, NULL, "fsl,mpc885ads-bcsr");134if (!np) {135printk(KERN_CRIT "Could not find fsl,mpc885ads-bcsr node\n");136return;137}138139bcsr = of_iomap(np, 0);140bcsr5 = of_iomap(np, 1);141of_node_put(np);142143if (!bcsr || !bcsr5) {144printk(KERN_CRIT "Could not remap BCSR\n");145return;146}147148clrbits32(&bcsr[1], BCSR1_RS232EN_1);149#ifdef CONFIG_MPC8xx_SECOND_ETH_FEC2150setbits32(&bcsr[1], BCSR1_RS232EN_2);151#else152clrbits32(&bcsr[1], BCSR1_RS232EN_2);153#endif154155clrbits32(bcsr5, BCSR5_MII1_EN);156setbits32(bcsr5, BCSR5_MII1_RST);157udelay(1000);158clrbits32(bcsr5, BCSR5_MII1_RST);159160#ifdef CONFIG_MPC8xx_SECOND_ETH_FEC2161clrbits32(bcsr5, BCSR5_MII2_EN);162setbits32(bcsr5, BCSR5_MII2_RST);163udelay(1000);164clrbits32(bcsr5, BCSR5_MII2_RST);165#else166setbits32(bcsr5, BCSR5_MII2_EN);167#endif168169#ifdef CONFIG_MPC8xx_SECOND_ETH_SCC3170clrbits32(&bcsr[4], BCSR4_ETH10_RST);171udelay(1000);172setbits32(&bcsr[4], BCSR4_ETH10_RST);173174setbits32(&bcsr[1], BCSR1_ETHEN);175176np = of_find_node_by_path("/soc@ff000000/cpm@9c0/serial@a80");177#else178np = of_find_node_by_path("/soc@ff000000/cpm@9c0/ethernet@a40");179#endif180181/* The SCC3 enet registers overlap the SMC1 registers, so182* one of the two must be removed from the device tree.183*/184185if (np) {186of_detach_node(np);187of_node_put(np);188}189}190191static const struct of_device_id of_bus_ids[] __initconst = {192{ .name = "soc", },193{ .name = "cpm", },194{ .name = "localbus", },195{},196};197198static int __init declare_of_platform_devices(void)199{200/* Publish the QE devices */201of_platform_bus_probe(NULL, of_bus_ids, NULL);202203return 0;204}205machine_device_initcall(mpc885_ads, declare_of_platform_devices);206207define_machine(mpc885_ads) {208.name = "Freescale MPC885 ADS",209.compatible = "fsl,mpc885ads",210.setup_arch = mpc885ads_setup_arch,211.init_IRQ = mpc8xx_pic_init,212.get_irq = mpc8xx_get_irq,213.restart = mpc8xx_restart,214.calibrate_decr = mpc8xx_calibrate_decr,215.progress = udbg_progress,216};217218219