Path: blob/master/arch/powerpc/platforms/82xx/pq2fads.c
10820 views
/*1* PQ2FADS board support2*3* Copyright 2007 Freescale Semiconductor, Inc.4* Author: Scott Wood <[email protected]>5*6* Loosely based on mp82xx ADS support 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 version 2 as published11* by the Free Software Foundation.12*/1314#include <linux/init.h>15#include <linux/interrupt.h>16#include <linux/fsl_devices.h>17#include <linux/of_platform.h>1819#include <asm/io.h>20#include <asm/cpm2.h>21#include <asm/udbg.h>22#include <asm/machdep.h>23#include <asm/time.h>2425#include <sysdev/fsl_soc.h>26#include <sysdev/cpm2_pic.h>2728#include "pq2ads.h"29#include "pq2.h"3031static void __init pq2fads_pic_init(void)32{33struct device_node *np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");34if (!np) {35printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");36return;37}3839cpm2_pic_init(np);40of_node_put(np);4142/* Initialize stuff for the 82xx CPLD IC and install demux */43pq2ads_pci_init_irq();44}4546struct cpm_pin {47int port, pin, flags;48};4950static struct cpm_pin pq2fads_pins[] = {51/* SCC1 */52{3, 30, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},53{3, 31, CPM_PIN_INPUT | CPM_PIN_PRIMARY},5455/* SCC2 */56{3, 27, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},57{3, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},5859/* FCC2 */60{1, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},61{1, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},62{1, 20, CPM_PIN_INPUT | CPM_PIN_PRIMARY},63{1, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY},64{1, 22, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},65{1, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},66{1, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},67{1, 25, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},68{1, 26, CPM_PIN_INPUT | CPM_PIN_PRIMARY},69{1, 27, CPM_PIN_INPUT | CPM_PIN_PRIMARY},70{1, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},71{1, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},72{1, 30, CPM_PIN_INPUT | CPM_PIN_PRIMARY},73{1, 31, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},74{2, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},75{2, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},7677/* FCC3 */78{1, 4, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},79{1, 5, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},80{1, 6, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},81{1, 7, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},82{1, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY},83{1, 9, CPM_PIN_INPUT | CPM_PIN_PRIMARY},84{1, 10, CPM_PIN_INPUT | CPM_PIN_PRIMARY},85{1, 11, CPM_PIN_INPUT | CPM_PIN_PRIMARY},86{1, 12, CPM_PIN_INPUT | CPM_PIN_PRIMARY},87{1, 13, CPM_PIN_INPUT | CPM_PIN_PRIMARY},88{1, 14, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},89{1, 15, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},90{1, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},91{1, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},92{2, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},93{2, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},94};9596static void __init init_ioports(void)97{98int i;99100for (i = 0; i < ARRAY_SIZE(pq2fads_pins); i++) {101struct cpm_pin *pin = &pq2fads_pins[i];102cpm2_set_pin(pin->port, pin->pin, pin->flags);103}104105cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX);106cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX);107cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_RX);108cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_TX);109cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK13, CPM_CLK_RX);110cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK14, CPM_CLK_TX);111cpm2_clk_setup(CPM_CLK_FCC3, CPM_CLK15, CPM_CLK_RX);112cpm2_clk_setup(CPM_CLK_FCC3, CPM_CLK16, CPM_CLK_TX);113}114115static void __init pq2fads_setup_arch(void)116{117struct device_node *np;118__be32 __iomem *bcsr;119120if (ppc_md.progress)121ppc_md.progress("pq2fads_setup_arch()", 0);122123cpm2_reset();124125np = of_find_compatible_node(NULL, NULL, "fsl,pq2fads-bcsr");126if (!np) {127printk(KERN_ERR "No fsl,pq2fads-bcsr in device tree\n");128return;129}130131bcsr = of_iomap(np, 0);132of_node_put(np);133if (!bcsr) {134printk(KERN_ERR "Cannot map BCSR registers\n");135return;136}137138/* Enable the serial and ethernet ports */139140clrbits32(&bcsr[1], BCSR1_RS232_EN1 | BCSR1_RS232_EN2 | BCSR1_FETHIEN);141setbits32(&bcsr[1], BCSR1_FETH_RST);142143clrbits32(&bcsr[3], BCSR3_FETHIEN2);144setbits32(&bcsr[3], BCSR3_FETH2_RST);145146iounmap(bcsr);147148init_ioports();149150/* Enable external IRQs */151clrbits32(&cpm2_immr->im_siu_conf.siu_82xx.sc_siumcr, 0x0c000000);152153pq2_init_pci();154155if (ppc_md.progress)156ppc_md.progress("pq2fads_setup_arch(), finish", 0);157}158159/*160* Called very early, device-tree isn't unflattened161*/162static int __init pq2fads_probe(void)163{164unsigned long root = of_get_flat_dt_root();165return of_flat_dt_is_compatible(root, "fsl,pq2fads");166}167168static struct of_device_id __initdata of_bus_ids[] = {169{ .name = "soc", },170{ .name = "cpm", },171{ .name = "localbus", },172{},173};174175static int __init declare_of_platform_devices(void)176{177/* Publish the QE devices */178of_platform_bus_probe(NULL, of_bus_ids, NULL);179return 0;180}181machine_device_initcall(pq2fads, declare_of_platform_devices);182183define_machine(pq2fads)184{185.name = "Freescale PQ2FADS",186.probe = pq2fads_probe,187.setup_arch = pq2fads_setup_arch,188.init_IRQ = pq2fads_pic_init,189.get_irq = cpm2_get_irq,190.calibrate_decr = generic_calibrate_decr,191.restart = pq2_restart,192.progress = udbg_progress,193};194195196