nvram.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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, unsigned int err_type);
  56. extern int nvram_read_error_log(char * buff, int length, unsigned int * err_type);
  57. extern int nvram_clear_error_log(void);
  58. extern struct nvram_partition *nvram_find_partition(int sig, const char *name);
  59. extern int pSeries_nvram_init(void);
  60. extern int mmio_nvram_init(void);
  61. #endif /* __KERNEL__ */
  62. /* PowerMac specific nvram stuffs */
  63. enum {
  64. pmac_nvram_OF, /* Open Firmware partition */
  65. pmac_nvram_XPRAM, /* MacOS XPRAM partition */
  66. pmac_nvram_NR /* MacOS Name Registry partition */
  67. };
  68. #ifdef __KERNEL__
  69. /* Return partition offset in nvram */
  70. extern int pmac_get_partition(int partition);
  71. /* Direct access to XPRAM on PowerMacs */
  72. extern u8 pmac_xpram_read(int xpaddr);
  73. extern void pmac_xpram_write(int xpaddr, u8 data);
  74. /* Synchronize NVRAM */
  75. extern void nvram_sync(void);
  76. /* Normal access to NVRAM */
  77. extern unsigned char nvram_read_byte(int i);
  78. extern void nvram_write_byte(unsigned char c, int i);
  79. #endif
  80. /* Some offsets in XPRAM */
  81. #define PMAC_XPRAM_MACHINE_LOC 0xe4
  82. #define PMAC_XPRAM_SOUND_VOLUME 0x08
  83. /* Machine location structure in PowerMac XPRAM */
  84. struct pmac_machine_location {
  85. unsigned int latitude; /* 2+30 bit Fractional number */
  86. unsigned int longitude; /* 2+30 bit Fractional number */
  87. unsigned int delta; /* mix of GMT delta and DLS */
  88. };
  89. /*
  90. * /dev/nvram ioctls
  91. *
  92. * Note that PMAC_NVRAM_GET_OFFSET is still supported, but is
  93. * definitely obsolete. Do not use it if you can avoid it
  94. */
  95. #define OBSOLETE_PMAC_NVRAM_GET_OFFSET \
  96. _IOWR('p', 0x40, int)
  97. #define IOC_NVRAM_GET_OFFSET _IOWR('p', 0x42, int) /* Get NVRAM partition offset */
  98. #define IOC_NVRAM_SYNC _IO('p', 0x43) /* Sync NVRAM image */
  99. #endif /* _ASM_POWERPC_NVRAM_H */