Path: blob/master/arch/powerpc/platforms/52xx/lite5200.c
26481 views
// SPDX-License-Identifier: GPL-2.0-or-later1/*2* Freescale Lite5200 board support3*4* Written by: Grant Likely <[email protected]>5*6* Copyright (C) Secret Lab Technologies Ltd. 2006. All rights reserved.7* Copyright 2006 Freescale Semiconductor, Inc. All rights reserved.8*9* Description:10*/1112#undef DEBUG1314#include <linux/init.h>15#include <linux/pci.h>16#include <linux/of.h>17#include <linux/of_address.h>18#include <linux/root_dev.h>19#include <linux/initrd.h>20#include <asm/time.h>21#include <asm/io.h>22#include <asm/machdep.h>23#include <asm/mpc52xx.h>2425/* ************************************************************************26*27* Setup the architecture28*29*/3031/* mpc5200 device tree match tables */32static const struct of_device_id mpc5200_cdm_ids[] __initconst = {33{ .compatible = "fsl,mpc5200-cdm", },34{ .compatible = "mpc5200-cdm", },35{}36};3738static const struct of_device_id mpc5200_gpio_ids[] __initconst = {39{ .compatible = "fsl,mpc5200-gpio", },40{ .compatible = "mpc5200-gpio", },41{}42};4344/*45* Fix clock configuration.46*47* Firmware is supposed to be responsible for this. If you are creating a48* new board port, do *NOT* duplicate this code. Fix your boot firmware49* to set it correctly in the first place50*/51static void __init52lite5200_fix_clock_config(void)53{54struct device_node *np;55struct mpc52xx_cdm __iomem *cdm;56/* Map zones */57np = of_find_matching_node(NULL, mpc5200_cdm_ids);58cdm = of_iomap(np, 0);59of_node_put(np);60if (!cdm) {61printk(KERN_ERR "%s() failed; expect abnormal behaviour\n",62__func__);63return;64}6566/* Use internal 48 Mhz */67out_8(&cdm->ext_48mhz_en, 0x00);68out_8(&cdm->fd_enable, 0x01);69if (in_be32(&cdm->rstcfg) & 0x40) /* Assumes 33Mhz clock */70out_be16(&cdm->fd_counters, 0x0001);71else72out_be16(&cdm->fd_counters, 0x5555);7374/* Unmap the regs */75iounmap(cdm);76}7778/*79* Fix setting of port_config register.80*81* Firmware is supposed to be responsible for this. If you are creating a82* new board port, do *NOT* duplicate this code. Fix your boot firmware83* to set it correctly in the first place84*/85static void __init86lite5200_fix_port_config(void)87{88struct device_node *np;89struct mpc52xx_gpio __iomem *gpio;90u32 port_config;9192np = of_find_matching_node(NULL, mpc5200_gpio_ids);93gpio = of_iomap(np, 0);94of_node_put(np);95if (!gpio) {96printk(KERN_ERR "%s() failed. expect abnormal behavior\n",97__func__);98return;99}100101/* Set port config */102port_config = in_be32(&gpio->port_config);103104port_config &= ~0x00800000; /* 48Mhz internal, pin is GPIO */105106port_config &= ~0x00007000; /* USB port : Differential mode */107port_config |= 0x00001000; /* USB 1 only */108109port_config &= ~0x03000000; /* ATA CS is on csb_4/5 */110port_config |= 0x01000000;111112pr_debug("port_config: old:%x new:%x\n",113in_be32(&gpio->port_config), port_config);114out_be32(&gpio->port_config, port_config);115116/* Unmap zone */117iounmap(gpio);118}119120#ifdef CONFIG_PM121static void lite5200_suspend_prepare(void __iomem *mbar)122{123u8 pin = 1; /* GPIO_WKUP_1 (GPIO_PSC2_4) */124u8 level = 0; /* wakeup on low level */125mpc52xx_set_wakeup_gpio(pin, level);126127/*128* power down usb port129* this needs to be called before of-ohci suspend code130*/131132/* set ports to "power switched" and "powered at the same time"133* USB Rh descriptor A: NPS = 0, PSM = 0 */134out_be32(mbar + 0x1048, in_be32(mbar + 0x1048) & ~0x300);135/* USB Rh status: LPS = 1 - turn off power */136out_be32(mbar + 0x1050, 0x00000001);137}138139static void lite5200_resume_finish(void __iomem *mbar)140{141/* USB Rh status: LPSC = 1 - turn on power */142out_be32(mbar + 0x1050, 0x00010000);143}144#endif145146static void __init lite5200_setup_arch(void)147{148if (ppc_md.progress)149ppc_md.progress("lite5200_setup_arch()", 0);150151/* Map important registers from the internal memory map */152mpc52xx_map_common_devices();153154/* Some mpc5200 & mpc5200b related configuration */155mpc5200_setup_xlb_arbiter();156157/* Fix things that firmware should have done. */158lite5200_fix_clock_config();159lite5200_fix_port_config();160161#ifdef CONFIG_PM162mpc52xx_suspend.board_suspend_prepare = lite5200_suspend_prepare;163mpc52xx_suspend.board_resume_finish = lite5200_resume_finish;164lite5200_pm_init();165#endif166}167168static const char * const board[] __initconst = {169"fsl,lite5200",170"fsl,lite5200b",171NULL,172};173174define_machine(lite5200) {175.name = "lite5200",176.compatibles = board,177.setup_arch = lite5200_setup_arch,178.discover_phbs = mpc52xx_setup_pci,179.init = mpc52xx_declare_of_platform_devices,180.init_IRQ = mpc52xx_init_irq,181.get_irq = mpc52xx_get_irq,182.restart = mpc52xx_restart,183};184185186