nvram.h 3.8 KB

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