net5501.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * System Specific setup for Soekris net5501
  4. * At the moment this means setup of GPIO control of LEDs and buttons
  5. * on net5501 boards.
  6. *
  7. * Copyright (C) 2008-2009 Tower Technologies
  8. * Written by Alessandro Zummo <a.zummo@towertech.it>
  9. *
  10. * Copyright (C) 2008 Constantin Baranov <const@mimas.ru>
  11. * Copyright (C) 2011 Ed Wildgoose <kernel@wildgooses.com>
  12. * and Philip Prindeville <philipp@redfish-solutions.com>
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/io.h>
  17. #include <linux/string.h>
  18. #include <linux/input.h>
  19. #include <linux/gpio/machine.h>
  20. #include <linux/gpio/property.h>
  21. #include <asm/geode.h>
  22. #include "geode-common.h"
  23. #define BIOS_REGION_BASE 0xffff0000
  24. #define BIOS_REGION_SIZE 0x00010000
  25. static const struct geode_led net5501_leds[] __initconst = {
  26. { 6, true },
  27. };
  28. static void __init register_net5501(void)
  29. {
  30. geode_create_restart_key(24);
  31. geode_create_leds("net5501", net5501_leds, ARRAY_SIZE(net5501_leds));
  32. }
  33. struct net5501_board {
  34. u16 offset;
  35. u16 len;
  36. char *sig;
  37. };
  38. static struct net5501_board __initdata boards[] = {
  39. { 0xb7b, 7, "net5501" }, /* net5501 v1.33/1.33c */
  40. { 0xb1f, 7, "net5501" }, /* net5501 v1.32i */
  41. };
  42. static bool __init net5501_present(void)
  43. {
  44. int i;
  45. unsigned char *rombase, *bios;
  46. bool found = false;
  47. rombase = ioremap(BIOS_REGION_BASE, BIOS_REGION_SIZE - 1);
  48. if (!rombase) {
  49. printk(KERN_ERR "%s: failed to get rombase\n", KBUILD_MODNAME);
  50. return found;
  51. }
  52. bios = rombase + 0x20; /* null terminated */
  53. if (memcmp(bios, "comBIOS", 7))
  54. goto unmap;
  55. for (i = 0; i < ARRAY_SIZE(boards); i++) {
  56. unsigned char *model = rombase + boards[i].offset;
  57. if (!memcmp(model, boards[i].sig, boards[i].len)) {
  58. printk(KERN_INFO "%s: system is recognized as \"%s\"\n",
  59. KBUILD_MODNAME, model);
  60. found = true;
  61. break;
  62. }
  63. }
  64. unmap:
  65. iounmap(rombase);
  66. return found;
  67. }
  68. static int __init net5501_init(void)
  69. {
  70. if (!is_geode())
  71. return 0;
  72. if (!net5501_present())
  73. return 0;
  74. register_net5501();
  75. return 0;
  76. }
  77. device_initcall(net5501_init);