nvram.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * NVRAM definitions and access functions.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. #ifndef _ASM_POWERPC_NVRAM_H
  10. #define _ASM_POWERPC_NVRAM_H
  11. #define NVRW_CNT 0x20
  12. #define NVRAM_HEADER_LEN 16 /* sizeof(struct nvram_header) */
  13. #define NVRAM_BLOCK_LEN 16
  14. #define NVRAM_MAX_REQ (2080/NVRAM_BLOCK_LEN)
  15. #define NVRAM_MIN_REQ (1056/NVRAM_BLOCK_LEN)
  16. #define NVRAM_AS0 0x74
  17. #define NVRAM_AS1 0x75
  18. #define NVRAM_DATA 0x77
  19. /* RTC Offsets */
  20. #define MOTO_RTC_SECONDS 0x1FF9
  21. #define MOTO_RTC_MINUTES 0x1FFA
  22. #define MOTO_RTC_HOURS 0x1FFB
  23. #define MOTO_RTC_DAY_OF_WEEK 0x1FFC
  24. #define MOTO_RTC_DAY_OF_MONTH 0x1FFD
  25. #define MOTO_RTC_MONTH 0x1FFE
  26. #define MOTO_RTC_YEAR 0x1FFF
  27. #define MOTO_RTC_CONTROLA 0x1FF8
  28. #define MOTO_RTC_CONTROLB 0x1FF9
  29. #define NVRAM_SIG_SP 0x02 /* support processor */
  30. #define NVRAM_SIG_OF 0x50 /* open firmware config */
  31. #define NVRAM_SIG_FW 0x51 /* general firmware */
  32. #define NVRAM_SIG_HW 0x52 /* hardware (VPD) */
  33. #define NVRAM_SIG_FLIP 0x5a /* Apple flip/flop header */
  34. #define NVRAM_SIG_APPL 0x5f /* Apple "system" (???) */
  35. #define NVRAM_SIG_SYS 0x70 /* system env vars */
  36. #define NVRAM_SIG_CFG 0x71 /* config data */
  37. #define NVRAM_SIG_ELOG 0x72 /* error log */
  38. #define NVRAM_SIG_VEND 0x7e /* vendor defined */
  39. #define NVRAM_SIG_FREE 0x7f /* Free space */
  40. #define NVRAM_SIG_OS 0xa0 /* OS defined */
  41. #define NVRAM_SIG_PANIC 0xa1 /* Apple OSX "panic" */
  42. /* If change this size, then change the size of NVNAME_LEN */
  43. struct nvram_header {
  44. unsigned char signature;
  45. unsigned char checksum;
  46. unsigned short length;
  47. char name[12];
  48. };
  49. #ifdef __KERNEL__
  50. struct nvram_partition {
  51. struct list_head partition;
  52. struct nvram_header header;
  53. unsigned int index;
  54. };
  55. extern int nvram_write_error_log(char * buff, int length,
  56. unsigned int err_type, unsigned int err_seq);
  57. extern int nvram_read_error_log(char * buff, int length,
  58. unsigned int * err_type, unsigned int *err_seq);
  59. extern int nvram_clear_error_log(void);
  60. extern struct nvram_partition *nvram_find_partition(int sig, const char *name);
  61. extern int pSeries_nvram_init(void);
  62. extern int mmio_nvram_init(void);
  63. #endif /* __KERNEL__ */
  64. /* PowerMac specific nvram stuffs */
  65. enum {
  66. pmac_nvram_OF, /* Open Firmware partition */
  67. pmac_nvram_XPRAM, /* MacOS XPRAM partition */
  68. pmac_nvram_NR /* MacOS Name Registry partition */
  69. };
  70. #ifdef __KERNEL__
  71. /* Return partition offset in nvram */
  72. extern int pmac_get_partition(int partition);
  73. /* Direct access to XPRAM on PowerMacs */
  74. extern u8 pmac_xpram_read(int xpaddr);
  75. extern void pmac_xpram_write(int xpaddr, u8 data);
  76. /* Synchronize NVRAM */
  77. extern void nvram_sync(void);
  78. /* Normal access to NVRAM */
  79. extern unsigned char nvram_read_byte(int i);
  80. extern void nvram_write_byte(unsigned char c, int i);
  81. #endif
  82. /* Some offsets in XPRAM */
  83. #define PMAC_XPRAM_MACHINE_LOC 0xe4
  84. #define PMAC_XPRAM_SOUND_VOLUME 0x08
  85. /* Machine location structure in PowerMac XPRAM */
  86. struct pmac_machine_location {
  87. unsigned int latitude; /* 2+30 bit Fractional number */
  88. unsigned int longitude; /* 2+30 bit Fractional number */
  89. unsigned int delta; /* mix of GMT delta and DLS */
  90. };
  91. /*
  92. * /dev/nvram ioctls
  93. *
  94. * Note that PMAC_NVRAM_GET_OFFSET is still supported, but is
  95. * definitely obsolete. Do not use it if you can avoid it
  96. */
  97. #define OBSOLETE_PMAC_NVRAM_GET_OFFSET \
  98. _IOWR('p', 0x40, int)
  99. #define IOC_NVRAM_GET_OFFSET _IOWR('p', 0x42, int) /* Get NVRAM partition offset */
  100. #define IOC_NVRAM_SYNC _IO('p', 0x43) /* Sync NVRAM image */
  101. #endif /* _ASM_POWERPC_NVRAM_H */