leds-net5501.c 1.9 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 <asm/geode.h>
  19. static const struct gpio_led net5501_leds[] = {
  20. {
  21. .name = "error",
  22. .gpio = 6,
  23. .default_trigger = "default-on",
  24. },
  25. };
  26. static struct gpio_led_platform_data net5501_leds_data = {
  27. .num_leds = ARRAY_SIZE(net5501_leds),
  28. .leds = net5501_leds,
  29. };
  30. static struct platform_device net5501_leds_dev = {
  31. .name = "leds-gpio",
  32. .id = -1,
  33. .dev.platform_data = &net5501_leds_data,
  34. };
  35. static void __init init_net5501(void)
  36. {
  37. platform_device_register(&net5501_leds_dev);
  38. }
  39. struct soekris_board {
  40. u16 offset;
  41. char *sig;
  42. u8 len;
  43. void (*init)(void);
  44. };
  45. static struct soekris_board __initdata boards[] = {
  46. { 0xb7b, "net5501", 7, init_net5501 }, /* net5501 v1.33/1.33c */
  47. { 0xb1f, "net5501", 7, init_net5501 }, /* net5501 v1.32i */
  48. };
  49. static int __init soekris_init(void)
  50. {
  51. int i;
  52. unsigned char *rombase, *bios;
  53. if (!is_geode())
  54. return 0;
  55. rombase = ioremap(0xffff0000, 0xffff);
  56. if (!rombase) {
  57. printk(KERN_INFO "Soekris net5501 LED driver failed to get rombase");
  58. return 0;
  59. }
  60. bios = rombase + 0x20; /* null terminated */
  61. if (strncmp(bios, "comBIOS", 7))
  62. goto unmap;
  63. for (i = 0; i < ARRAY_SIZE(boards); i++) {
  64. unsigned char *model = rombase + boards[i].offset;
  65. if (strncmp(model, boards[i].sig, boards[i].len) == 0) {
  66. printk(KERN_INFO "Soekris %s: %s\n", model, bios);
  67. if (boards[i].init)
  68. boards[i].init();
  69. break;
  70. }
  71. }
  72. unmap:
  73. iounmap(rombase);
  74. return 0;
  75. }
  76. arch_initcall(soekris_init);
  77. MODULE_LICENSE("GPL");