olpc.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /* OLPC machine specific definitions */
  2. #ifndef _ASM_X86_OLPC_H
  3. #define _ASM_X86_OLPC_H
  4. #include <asm/geode.h>
  5. struct olpc_platform_t {
  6. int flags;
  7. uint32_t boardrev;
  8. int ecver;
  9. };
  10. #define OLPC_F_PRESENT 0x01
  11. #define OLPC_F_DCON 0x02
  12. #define OLPC_F_EC_WIDE_SCI 0x04
  13. #ifdef CONFIG_OLPC
  14. extern struct olpc_platform_t olpc_platform_info;
  15. /*
  16. * OLPC board IDs contain the major build number within the mask 0x0ff0,
  17. * and the minor build number within 0x000f. Pre-builds have a minor
  18. * number less than 8, and normal builds start at 8. For example, 0x0B10
  19. * is a PreB1, and 0x0C18 is a C1.
  20. */
  21. static inline uint32_t olpc_board(uint8_t id)
  22. {
  23. return (id << 4) | 0x8;
  24. }
  25. static inline uint32_t olpc_board_pre(uint8_t id)
  26. {
  27. return id << 4;
  28. }
  29. static inline int machine_is_olpc(void)
  30. {
  31. return (olpc_platform_info.flags & OLPC_F_PRESENT) ? 1 : 0;
  32. }
  33. /*
  34. * The DCON is OLPC's Display Controller. It has a number of unique
  35. * features that we might want to take advantage of..
  36. */
  37. static inline int olpc_has_dcon(void)
  38. {
  39. return (olpc_platform_info.flags & OLPC_F_DCON) ? 1 : 0;
  40. }
  41. /*
  42. * The "Mass Production" version of OLPC's XO is identified as being model
  43. * C2. During the prototype phase, the following models (in chronological
  44. * order) were created: A1, B1, B2, B3, B4, C1. The A1 through B2 models
  45. * were based on Geode GX CPUs, and models after that were based upon
  46. * Geode LX CPUs. There were also some hand-assembled models floating
  47. * around, referred to as PreB1, PreB2, etc.
  48. */
  49. static inline int olpc_board_at_least(uint32_t rev)
  50. {
  51. return olpc_platform_info.boardrev >= rev;
  52. }
  53. extern void olpc_ec_wakeup_set(u16 value);
  54. extern void olpc_ec_wakeup_clear(u16 value);
  55. extern bool olpc_ec_wakeup_available(void);
  56. extern int olpc_ec_mask_write(u16 bits);
  57. extern int olpc_ec_sci_query(u16 *sci_value);
  58. #else
  59. static inline int machine_is_olpc(void)
  60. {
  61. return 0;
  62. }
  63. static inline int olpc_has_dcon(void)
  64. {
  65. return 0;
  66. }
  67. static inline void olpc_ec_wakeup_set(u16 value) { }
  68. static inline void olpc_ec_wakeup_clear(u16 value) { }
  69. static inline bool olpc_ec_wakeup_available(void)
  70. {
  71. return false;
  72. }
  73. #endif
  74. #ifdef CONFIG_OLPC_XO1_PM
  75. extern void do_olpc_suspend_lowlevel(void);
  76. extern void olpc_xo1_pm_wakeup_set(u16 value);
  77. extern void olpc_xo1_pm_wakeup_clear(u16 value);
  78. #endif
  79. extern int pci_olpc_init(void);
  80. /* EC related functions */
  81. extern int olpc_ec_cmd(unsigned char cmd, unsigned char *inbuf, size_t inlen,
  82. unsigned char *outbuf, size_t outlen);
  83. /* EC commands */
  84. #define EC_FIRMWARE_REV 0x08
  85. #define EC_WRITE_SCI_MASK 0x1b
  86. #define EC_WAKE_UP_WLAN 0x24
  87. #define EC_WLAN_LEAVE_RESET 0x25
  88. #define EC_READ_EB_MODE 0x2a
  89. #define EC_SET_SCI_INHIBIT 0x32
  90. #define EC_SET_SCI_INHIBIT_RELEASE 0x34
  91. #define EC_WLAN_ENTER_RESET 0x35
  92. #define EC_WRITE_EXT_SCI_MASK 0x38
  93. #define EC_SCI_QUERY 0x84
  94. #define EC_EXT_SCI_QUERY 0x85
  95. /* SCI source values */
  96. #define EC_SCI_SRC_EMPTY 0x00
  97. #define EC_SCI_SRC_GAME 0x01
  98. #define EC_SCI_SRC_BATTERY 0x02
  99. #define EC_SCI_SRC_BATSOC 0x04
  100. #define EC_SCI_SRC_BATERR 0x08
  101. #define EC_SCI_SRC_EBOOK 0x10 /* XO-1 only */
  102. #define EC_SCI_SRC_WLAN 0x20 /* XO-1 only */
  103. #define EC_SCI_SRC_ACPWR 0x40
  104. #define EC_SCI_SRC_BATCRIT 0x80
  105. #define EC_SCI_SRC_GPWAKE 0x100 /* XO-1.5 only */
  106. #define EC_SCI_SRC_ALL 0x1FF
  107. /* GPIO assignments */
  108. #define OLPC_GPIO_MIC_AC 1
  109. #define OLPC_GPIO_DCON_STAT0 5
  110. #define OLPC_GPIO_DCON_STAT1 6
  111. #define OLPC_GPIO_DCON_IRQ 7
  112. #define OLPC_GPIO_THRM_ALRM geode_gpio(10)
  113. #define OLPC_GPIO_DCON_LOAD 11
  114. #define OLPC_GPIO_DCON_BLANK 12
  115. #define OLPC_GPIO_SMB_CLK 14
  116. #define OLPC_GPIO_SMB_DATA 15
  117. #define OLPC_GPIO_WORKAUX geode_gpio(24)
  118. #define OLPC_GPIO_LID 26
  119. #define OLPC_GPIO_ECSCI 27
  120. #endif /* _ASM_X86_OLPC_H */