Advertisement
Guest User

Untitled

a guest
Jun 17th, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.49 KB | None | 0 0
  1. --- /dev/null   2015-06-10 22:09:58.297974446 +0200
  2. +++ linux-4.0.5/include/misc/sunxi_sid.h    2015-06-17 13:27:01.572876169 +0200
  3. @@ -0,0 +1,19 @@
  4. +#ifndef _MISC_SUNXI_H
  5. +#define _MISC_SUNXI_H
  6. +
  7. +#include <linux/types.h>
  8. +
  9. +/* This enables drivers/misc/eeprom/sunxi_sid.c to provide a chip ID
  10. + * for supported sunxi platforms. It gets set to the 16-byte "root"
  11. + * SID present on most Allwinner SoCs.
  12. + * The c_show() function in arch/arm/kernel/setup.c may display this
  13. + * chip_id as part of the /proc/cpuinfo information.
  14. + */
  15. +
  16. +typedef u32 chip_id_t[4];
  17. +
  18. +#if defined(CONFIG_EEPROM_SUNXI_SID)
  19. +   extern chip_id_t chip_id;
  20. +#endif
  21. +
  22. +#endif
  23. --- linux-4.0.5.orig/drivers/misc/eeprom/sunxi_sid.c    2015-06-06 17:21:22.000000000 +0200
  24. +++ linux-4.0.5/drivers/misc/eeprom/sunxi_sid.c 2015-06-17 12:25:15.369171717 +0200
  25. @@ -33,6 +33,8 @@
  26.  #include <linux/sysfs.h>
  27.  #include <linux/types.h>
  28.  
  29. +#include <misc/sunxi_sid.h>
  30. +
  31.  #define DRV_NAME "sunxi-sid"
  32.  
  33.  struct sunxi_sid_data {
  34. @@ -40,6 +42,9 @@
  35.     unsigned int keysize;
  36.  };
  37.  
  38. +// variable to hold chip ID. gets initialized once in sunxi_sid_probe()
  39. +chip_id_t chip_id = {0};
  40. +
  41.  /* We read the entire key, due to a 32 bit read alignment requirement. Since we
  42.   * want to return the requested byte, this results in somewhat slower code and
  43.   * uses 4 times more reads as needed but keeps code simpler. Since the SID is
  44. @@ -130,6 +135,12 @@
  45.     if (device_create_bin_file(&pdev->dev, &sid_bin_attr))
  46.         return -ENODEV;
  47.  
  48. +   // initialize chip_id from "root" key (first 16 SID bytes)
  49. +   chip_id[0] = ioread32(sid_data->reg_base + 0);
  50. +   chip_id[1] = ioread32(sid_data->reg_base + 4);
  51. +   chip_id[2] = ioread32(sid_data->reg_base + 8);
  52. +   chip_id[3] = ioread32(sid_data->reg_base + 12);
  53. +
  54.     entropy = kzalloc(sizeof(u8) * sid_data->keysize, GFP_KERNEL);
  55.     for (i = 0; i < sid_data->keysize; i++)
  56.         entropy[i] = sunxi_sid_read_byte(sid_data, i);
  57. --- linux-4.0.5.orig/arch/arm/kernel/setup.c    2015-06-06 17:21:22.000000000 +0200
  58. +++ linux-4.0.5/arch/arm/kernel/setup.c 2015-06-17 11:55:49.842106578 +0200
  59. @@ -58,6 +58,7 @@
  60.  #include <asm/memblock.h>
  61.  #include <asm/virt.h>
  62.  
  63. +#include <misc/sunxi_sid.h>
  64.  #include "atags.h"
  65.  
  66.  
  67. @@ -1094,6 +1095,12 @@
  68.     seq_printf(m, "Serial\t\t: %08x%08x\n",
  69.            system_serial_high, system_serial_low);
  70.  
  71. +#if defined(CONFIG_EEPROM_SUNXI_SID)
  72. +   if (chip_id[0] != 0)
  73. +       seq_printf(m, "Chipid\t\t: %08x-%08x-%08x-%08x\n",
  74. +           chip_id[0], chip_id[1], chip_id[2], chip_id[3]);
  75. +#endif
  76. +
  77.     return 0;
  78.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement