Path: blob/master/arch/powerpc/platforms/82xx/mpc8272_ads.c
10820 views
/*1* MPC8272 ADS board support2*3* Copyright 2007 Freescale Semiconductor, Inc.4* Author: Scott Wood <[email protected]>5*6* Based on code by Vitaly Bordug <[email protected]>7* Copyright (c) 2006 MontaVista Software, Inc.8*9* This program is free software; you can redistribute it and/or modify it10* under the terms of the GNU General Public License as published by the11* Free Software Foundation; either version 2 of the License, or (at your12* option) any later version.13*/1415#include <linux/init.h>16#include <linux/interrupt.h>17#include <linux/fsl_devices.h>18#include <linux/of_platform.h>19#include <linux/io.h>2021#include <asm/cpm2.h>22#include <asm/udbg.h>23#include <asm/machdep.h>24#include <asm/time.h>2526#include <platforms/82xx/pq2.h>2728#include <sysdev/fsl_soc.h>29#include <sysdev/cpm2_pic.h>3031#include "pq2.h"3233static void __init mpc8272_ads_pic_init(void)34{35struct device_node *np = of_find_compatible_node(NULL, NULL,36"fsl,cpm2-pic");37if (!np) {38printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");39return;40}4142cpm2_pic_init(np);43of_node_put(np);4445/* Initialize stuff for the 82xx CPLD IC and install demux */46pq2ads_pci_init_irq();47}4849struct cpm_pin {50int port, pin, flags;51};5253static struct cpm_pin mpc8272_ads_pins[] = {54/* SCC1 */55{3, 30, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},56{3, 31, CPM_PIN_INPUT | CPM_PIN_PRIMARY},5758/* SCC4 */59{3, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},60{3, 22, CPM_PIN_INPUT | CPM_PIN_PRIMARY},6162/* FCC1 */63{0, 14, CPM_PIN_INPUT | CPM_PIN_PRIMARY},64{0, 15, CPM_PIN_INPUT | CPM_PIN_PRIMARY},65{0, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},66{0, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},67{0, 18, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},68{0, 19, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},69{0, 20, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},70{0, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},71{0, 26, CPM_PIN_INPUT | CPM_PIN_SECONDARY},72{0, 27, CPM_PIN_INPUT | CPM_PIN_SECONDARY},73{0, 28, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},74{0, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},75{0, 30, CPM_PIN_INPUT | CPM_PIN_SECONDARY},76{0, 31, CPM_PIN_INPUT | CPM_PIN_SECONDARY},77{2, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY},78{2, 22, CPM_PIN_INPUT | CPM_PIN_PRIMARY},7980/* FCC2 */81{1, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},82{1, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},83{1, 20, CPM_PIN_INPUT | CPM_PIN_PRIMARY},84{1, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY},85{1, 22, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},86{1, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},87{1, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},88{1, 25, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},89{1, 26, CPM_PIN_INPUT | CPM_PIN_PRIMARY},90{1, 27, CPM_PIN_INPUT | CPM_PIN_PRIMARY},91{1, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},92{1, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},93{1, 30, CPM_PIN_INPUT | CPM_PIN_PRIMARY},94{1, 31, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},95{2, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},96{2, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},9798/* I2C */99{3, 14, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN},100{3, 15, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN},101102/* USB */103{2, 10, CPM_PIN_INPUT | CPM_PIN_PRIMARY},104{2, 11, CPM_PIN_INPUT | CPM_PIN_PRIMARY},105{2, 20, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},106{2, 24, CPM_PIN_INPUT | CPM_PIN_PRIMARY},107{3, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},108{3, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},109{3, 25, CPM_PIN_INPUT | CPM_PIN_PRIMARY},110};111112static void __init init_ioports(void)113{114int i;115116for (i = 0; i < ARRAY_SIZE(mpc8272_ads_pins); i++) {117struct cpm_pin *pin = &mpc8272_ads_pins[i];118cpm2_set_pin(pin->port, pin->pin, pin->flags);119}120121cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX);122cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX);123cpm2_clk_setup(CPM_CLK_SCC3, CPM_CLK8, CPM_CLK_RX);124cpm2_clk_setup(CPM_CLK_SCC3, CPM_CLK8, CPM_CLK_TX);125cpm2_clk_setup(CPM_CLK_SCC4, CPM_BRG4, CPM_CLK_RX);126cpm2_clk_setup(CPM_CLK_SCC4, CPM_BRG4, CPM_CLK_TX);127cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK11, CPM_CLK_RX);128cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK10, CPM_CLK_TX);129cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK15, CPM_CLK_RX);130cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK16, CPM_CLK_TX);131}132133static void __init mpc8272_ads_setup_arch(void)134{135struct device_node *np;136__be32 __iomem *bcsr;137138if (ppc_md.progress)139ppc_md.progress("mpc8272_ads_setup_arch()", 0);140141cpm2_reset();142143np = of_find_compatible_node(NULL, NULL, "fsl,mpc8272ads-bcsr");144if (!np) {145printk(KERN_ERR "No bcsr in device tree\n");146return;147}148149bcsr = of_iomap(np, 0);150of_node_put(np);151if (!bcsr) {152printk(KERN_ERR "Cannot map BCSR registers\n");153return;154}155156#define BCSR1_FETHIEN 0x08000000157#define BCSR1_FETH_RST 0x04000000158#define BCSR1_RS232_EN1 0x02000000159#define BCSR1_RS232_EN2 0x01000000160#define BCSR3_USB_nEN 0x80000000161#define BCSR3_FETHIEN2 0x10000000162#define BCSR3_FETH2_RST 0x08000000163164clrbits32(&bcsr[1], BCSR1_RS232_EN1 | BCSR1_RS232_EN2 | BCSR1_FETHIEN);165setbits32(&bcsr[1], BCSR1_FETH_RST);166167clrbits32(&bcsr[3], BCSR3_FETHIEN2);168setbits32(&bcsr[3], BCSR3_FETH2_RST);169170clrbits32(&bcsr[3], BCSR3_USB_nEN);171172iounmap(bcsr);173174init_ioports();175pq2_init_pci();176177if (ppc_md.progress)178ppc_md.progress("mpc8272_ads_setup_arch(), finish", 0);179}180181static struct of_device_id __initdata of_bus_ids[] = {182{ .name = "soc", },183{ .name = "cpm", },184{ .name = "localbus", },185{},186};187188static int __init declare_of_platform_devices(void)189{190/* Publish the QE devices */191of_platform_bus_probe(NULL, of_bus_ids, NULL);192return 0;193}194machine_device_initcall(mpc8272_ads, declare_of_platform_devices);195196/*197* Called very early, device-tree isn't unflattened198*/199static int __init mpc8272_ads_probe(void)200{201unsigned long root = of_get_flat_dt_root();202return of_flat_dt_is_compatible(root, "fsl,mpc8272ads");203}204205define_machine(mpc8272_ads)206{207.name = "Freescale MPC8272 ADS",208.probe = mpc8272_ads_probe,209.setup_arch = mpc8272_ads_setup_arch,210.init_IRQ = mpc8272_ads_pic_init,211.get_irq = cpm2_get_irq,212.calibrate_decr = generic_calibrate_decr,213.restart = pq2_restart,214.progress = udbg_progress,215};216217218