linux/arch/mips/ar7/setup.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0-only
   2/*
   3 * Carsten Langgaard, carstenl@mips.com
   4 * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
   5 */
   6#include <linux/init.h>
   7#include <linux/ioport.h>
   8#include <linux/pm.h>
   9#include <linux/time.h>
  10
  11#include <asm/reboot.h>
  12#include <asm/mach-ar7/ar7.h>
  13#include <asm/mach-ar7/prom.h>
  14
  15static void ar7_machine_restart(char *command)
  16{
  17        u32 *softres_reg = ioremap(AR7_REGS_RESET + AR7_RESET_SOFTWARE, 1);
  18
  19        writel(1, softres_reg);
  20}
  21
  22static void ar7_machine_halt(void)
  23{
  24        while (1)
  25                ;
  26}
  27
  28static void ar7_machine_power_off(void)
  29{
  30        u32 *power_reg = (u32 *)ioremap(AR7_REGS_POWER, 1);
  31        u32 power_state = readl(power_reg) | (3 << 30);
  32
  33        writel(power_state, power_reg);
  34        ar7_machine_halt();
  35}
  36
  37const char *get_system_type(void)
  38{
  39        u16 chip_id = ar7_chip_id();
  40        u16 titan_variant_id = titan_chip_id();
  41
  42        switch (chip_id) {
  43        case AR7_CHIP_7100:
  44                return "TI AR7 (TNETD7100)";
  45        case AR7_CHIP_7200:
  46                return "TI AR7 (TNETD7200)";
  47        case AR7_CHIP_7300:
  48                return "TI AR7 (TNETD7300)";
  49        case AR7_CHIP_TITAN:
  50                switch (titan_variant_id) {
  51                case TITAN_CHIP_1050:
  52                        return "TI AR7 (TNETV1050)";
  53                case TITAN_CHIP_1055:
  54                        return "TI AR7 (TNETV1055)";
  55                case TITAN_CHIP_1056:
  56                        return "TI AR7 (TNETV1056)";
  57                case TITAN_CHIP_1060:
  58                        return "TI AR7 (TNETV1060)";
  59                }
  60                /* fall through */
  61        default:
  62                return "TI AR7 (unknown)";
  63        }
  64}
  65
  66static int __init ar7_init_console(void)
  67{
  68        return 0;
  69}
  70console_initcall(ar7_init_console);
  71
  72/*
  73 * Initializes basic routines and structures pointers, memory size (as
  74 * given by the bios and saves the command line.
  75 */
  76void __init plat_mem_setup(void)
  77{
  78        unsigned long io_base;
  79
  80        _machine_restart = ar7_machine_restart;
  81        _machine_halt = ar7_machine_halt;
  82        pm_power_off = ar7_machine_power_off;
  83
  84        io_base = (unsigned long)ioremap(AR7_REGS_BASE, 0x10000);
  85        if (!io_base)
  86                panic("Can't remap IO base!");
  87        set_io_port_base(io_base);
  88
  89        prom_meminit();
  90
  91        printk(KERN_INFO "%s, ID: 0x%04x, Revision: 0x%02x\n",
  92                        get_system_type(), ar7_chip_id(), ar7_chip_rev());
  93}
  94