setup.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Carsten Langgaard, carstenl@mips.com
  3. * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
  4. *
  5. * This program is free software; you can distribute it and/or modify it
  6. * under the terms of the GNU General Public License (Version 2) as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  17. */
  18. #include <linux/init.h>
  19. #include <linux/ioport.h>
  20. #include <linux/pm.h>
  21. #include <linux/time.h>
  22. #include <asm/reboot.h>
  23. #include <asm/mach-ar7/ar7.h>
  24. #include <asm/mach-ar7/prom.h>
  25. static void ar7_machine_restart(char *command)
  26. {
  27. u32 *softres_reg = ioremap(AR7_REGS_RESET + AR7_RESET_SOFTWARE, 1);
  28. writel(1, softres_reg);
  29. }
  30. static void ar7_machine_halt(void)
  31. {
  32. while (1)
  33. ;
  34. }
  35. static void ar7_machine_power_off(void)
  36. {
  37. u32 *power_reg = (u32 *)ioremap(AR7_REGS_POWER, 1);
  38. u32 power_state = readl(power_reg) | (3 << 30);
  39. writel(power_state, power_reg);
  40. ar7_machine_halt();
  41. }
  42. const char *get_system_type(void)
  43. {
  44. u16 chip_id = ar7_chip_id();
  45. switch (chip_id) {
  46. case AR7_CHIP_7100:
  47. return "TI AR7 (TNETD7100)";
  48. case AR7_CHIP_7200:
  49. return "TI AR7 (TNETD7200)";
  50. case AR7_CHIP_7300:
  51. return "TI AR7 (TNETD7300)";
  52. default:
  53. return "TI AR7 (unknown)";
  54. }
  55. }
  56. static int __init ar7_init_console(void)
  57. {
  58. return 0;
  59. }
  60. console_initcall(ar7_init_console);
  61. /*
  62. * Initializes basic routines and structures pointers, memory size (as
  63. * given by the bios and saves the command line.
  64. */
  65. void __init plat_mem_setup(void)
  66. {
  67. unsigned long io_base;
  68. _machine_restart = ar7_machine_restart;
  69. _machine_halt = ar7_machine_halt;
  70. pm_power_off = ar7_machine_power_off;
  71. panic_timeout = 3;
  72. io_base = (unsigned long)ioremap(AR7_REGS_BASE, 0x10000);
  73. if (!io_base)
  74. panic("Can't remap IO base!\n");
  75. set_io_port_base(io_base);
  76. prom_meminit();
  77. printk(KERN_INFO "%s, ID: 0x%04x, Revision: 0x%02x\n",
  78. get_system_type(), ar7_chip_id(), ar7_chip_rev());
  79. }