leds-net5501.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Soekris board support code
  3. *
  4. * Copyright (C) 2008-2009 Tower Technologies
  5. * Written by Alessandro Zummo <a.zummo@towertech.it>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2
  9. * as published by the Free Software Foundation.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/io.h>
  14. #include <linux/string.h>
  15. #include <linux/leds.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/gpio.h>
  18. #include <linux/module.h>
  19. #include <asm/geode.h>
  20. static const struct gpio_led net5501_leds[] = {
  21. {
  22. .name = "error",
  23. .gpio = 6,
  24. .default_trigger = "default-on",
  25. },
  26. };
  27. static struct gpio_led_platform_data net5501_leds_data = {
  28. .num_leds = ARRAY_SIZE(net5501_leds),
  29. .leds = net5501_leds,
  30. };
  31. static struct platform_device net5501_leds_dev = {
  32. .name = "leds-gpio",
  33. .id = -1,
  34. .dev.platform_data = &net5501_leds_data,
  35. };
  36. static void __init init_net5501(void)
  37. {
  38. platform_device_register(&net5501_leds_dev);
  39. }
  40. struct soekris_board {
  41. u16 offset;
  42. char *sig;
  43. u8 len;
  44. void (*init)(void);
  45. };
  46. static struct soekris_board __initdata boards[] = {
  47. { 0xb7b, "net5501", 7, init_net5501 }, /* net5501 v1.33/1.33c */
  48. { 0xb1f, "net5501", 7, init_net5501 }, /* net5501 v1.32i */
  49. };
  50. static int __init soekris_init(void)
  51. {
  52. int i;
  53. unsigned char *rombase, *bios;
  54. if (!is_geode())
  55. return 0;
  56. rombase = ioremap(0xffff0000, 0xffff);
  57. if (!rombase) {
  58. printk(KERN_INFO "Soekris net5501 LED driver failed to get rombase");
  59. return 0;
  60. }
  61. bios = rombase + 0x20; /* null terminated */
  62. if (strncmp(bios, "comBIOS", 7))
  63. goto unmap;
  64. for (i = 0; i < ARRAY_SIZE(boards); i++) {
  65. unsigned char *model = rombase + boards[i].offset;
  66. if (strncmp(model, boards[i].sig, boards[i].len) == 0) {
  67. printk(KERN_INFO "Soekris %s: %s\n", model, bios);
  68. if (boards[i].init)
  69. boards[i].init();
  70. break;
  71. }
  72. }
  73. unmap:
  74. iounmap(rombase);
  75. return 0;
  76. }
  77. arch_initcall(soekris_init);
  78. MODULE_LICENSE("GPL");