Path: blob/master/arch/powerpc/platforms/52xx/lite5200.c
10818 views
/*1* Freescale Lite5200 board support2*3* Written by: Grant Likely <[email protected]>4*5* Copyright (C) Secret Lab Technologies Ltd. 2006. All rights reserved.6* Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved.7*8* Description: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#undef DEBUG1617#include <linux/init.h>18#include <linux/pci.h>19#include <linux/of.h>20#include <linux/of_address.h>21#include <linux/root_dev.h>22#include <linux/initrd.h>23#include <asm/time.h>24#include <asm/io.h>25#include <asm/machdep.h>26#include <asm/prom.h>27#include <asm/mpc52xx.h>2829/* ************************************************************************30*31* Setup the architecture32*33*/3435/* mpc5200 device tree match tables */36static struct of_device_id mpc5200_cdm_ids[] __initdata = {37{ .compatible = "fsl,mpc5200-cdm", },38{ .compatible = "mpc5200-cdm", },39{}40};4142static struct of_device_id mpc5200_gpio_ids[] __initdata = {43{ .compatible = "fsl,mpc5200-gpio", },44{ .compatible = "mpc5200-gpio", },45{}46};4748/*49* Fix clock configuration.50*51* Firmware is supposed to be responsible for this. If you are creating a52* new board port, do *NOT* duplicate this code. Fix your boot firmware53* to set it correctly in the first place54*/55static void __init56lite5200_fix_clock_config(void)57{58struct device_node *np;59struct mpc52xx_cdm __iomem *cdm;60/* Map zones */61np = of_find_matching_node(NULL, mpc5200_cdm_ids);62cdm = of_iomap(np, 0);63of_node_put(np);64if (!cdm) {65printk(KERN_ERR "%s() failed; expect abnormal behaviour\n",66__func__);67return;68}6970/* Use internal 48 Mhz */71out_8(&cdm->ext_48mhz_en, 0x00);72out_8(&cdm->fd_enable, 0x01);73if (in_be32(&cdm->rstcfg) & 0x40) /* Assumes 33Mhz clock */74out_be16(&cdm->fd_counters, 0x0001);75else76out_be16(&cdm->fd_counters, 0x5555);7778/* Unmap the regs */79iounmap(cdm);80}8182/*83* Fix setting of port_config register.84*85* Firmware is supposed to be responsible for this. If you are creating a86* new board port, do *NOT* duplicate this code. Fix your boot firmware87* to set it correctly in the first place88*/89static void __init90lite5200_fix_port_config(void)91{92struct device_node *np;93struct mpc52xx_gpio __iomem *gpio;94u32 port_config;9596np = of_find_matching_node(NULL, mpc5200_gpio_ids);97gpio = of_iomap(np, 0);98of_node_put(np);99if (!gpio) {100printk(KERN_ERR "%s() failed. expect abnormal behavior\n",101__func__);102return;103}104105/* Set port config */106port_config = in_be32(&gpio->port_config);107108port_config &= ~0x00800000; /* 48Mhz internal, pin is GPIO */109110port_config &= ~0x00007000; /* USB port : Differential mode */111port_config |= 0x00001000; /* USB 1 only */112113port_config &= ~0x03000000; /* ATA CS is on csb_4/5 */114port_config |= 0x01000000;115116pr_debug("port_config: old:%x new:%x\n",117in_be32(&gpio->port_config), port_config);118out_be32(&gpio->port_config, port_config);119120/* Unmap zone */121iounmap(gpio);122}123124#ifdef CONFIG_PM125static void lite5200_suspend_prepare(void __iomem *mbar)126{127u8 pin = 1; /* GPIO_WKUP_1 (GPIO_PSC2_4) */128u8 level = 0; /* wakeup on low level */129mpc52xx_set_wakeup_gpio(pin, level);130131/*132* power down usb port133* this needs to be called before of-ohci suspend code134*/135136/* set ports to "power switched" and "powered at the same time"137* USB Rh descriptor A: NPS = 0, PSM = 0 */138out_be32(mbar + 0x1048, in_be32(mbar + 0x1048) & ~0x300);139/* USB Rh status: LPS = 1 - turn off power */140out_be32(mbar + 0x1050, 0x00000001);141}142143static void lite5200_resume_finish(void __iomem *mbar)144{145/* USB Rh status: LPSC = 1 - turn on power */146out_be32(mbar + 0x1050, 0x00010000);147}148#endif149150static void __init lite5200_setup_arch(void)151{152if (ppc_md.progress)153ppc_md.progress("lite5200_setup_arch()", 0);154155/* Map important registers from the internal memory map */156mpc52xx_map_common_devices();157158/* Some mpc5200 & mpc5200b related configuration */159mpc5200_setup_xlb_arbiter();160161/* Fix things that firmware should have done. */162lite5200_fix_clock_config();163lite5200_fix_port_config();164165#ifdef CONFIG_PM166mpc52xx_suspend.board_suspend_prepare = lite5200_suspend_prepare;167mpc52xx_suspend.board_resume_finish = lite5200_resume_finish;168lite5200_pm_init();169#endif170171mpc52xx_setup_pci();172}173174static const char *board[] __initdata = {175"fsl,lite5200",176"fsl,lite5200b",177NULL,178};179180/*181* Called very early, MMU is off, device-tree isn't unflattened182*/183static int __init lite5200_probe(void)184{185return of_flat_dt_match(of_get_flat_dt_root(), board);186}187188define_machine(lite5200) {189.name = "lite5200",190.probe = lite5200_probe,191.setup_arch = lite5200_setup_arch,192.init = mpc52xx_declare_of_platform_devices,193.init_IRQ = mpc52xx_init_irq,194.get_irq = mpc52xx_get_irq,195.restart = mpc52xx_restart,196.calibrate_decr = generic_calibrate_decr,197};198199200