olpc.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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_VSA 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 withing 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 VSA is software from AMD that typical Geode bioses will include.
  43. * It is used to emulate the PCI bus, VGA, etc. OLPC's Open Firmware does
  44. * not include the VSA; instead, PCI is emulated by the kernel.
  45. *
  46. * The VSA is described further in arch/x86/pci/olpc.c.
  47. */
  48. static inline int olpc_has_vsa(void)
  49. {
  50. return (olpc_platform_info.flags & OLPC_F_VSA) ? 1 : 0;
  51. }
  52. /*
  53. * The "Mass Production" version of OLPC's XO is identified as being model
  54. * C2. During the prototype phase, the following models (in chronological
  55. * order) were created: A1, B1, B2, B3, B4, C1. The A1 through B2 models
  56. * were based on Geode GX CPUs, and models after that were based upon
  57. * Geode LX CPUs. There were also some hand-assembled models floating
  58. * around, referred to as PreB1, PreB2, etc.
  59. */
  60. static inline int olpc_board_at_least(uint32_t rev)
  61. {
  62. return olpc_platform_info.boardrev >= rev;
  63. }
  64. #else
  65. static inline int machine_is_olpc(void)
  66. {
  67. return 0;
  68. }
  69. static inline int olpc_has_dcon(void)
  70. {
  71. return 0;
  72. }
  73. static inline int olpc_has_vsa(void)
  74. {
  75. return 0;
  76. }
  77. #endif
  78. /* EC related functions */
  79. extern int olpc_ec_cmd(unsigned char cmd, unsigned char *inbuf, size_t inlen,
  80. unsigned char *outbuf, size_t outlen);
  81. extern int olpc_ec_mask_set(uint8_t bits);
  82. extern int olpc_ec_mask_unset(uint8_t bits);
  83. /* EC commands */
  84. #define EC_FIRMWARE_REV 0x08
  85. /* SCI source values */
  86. #define EC_SCI_SRC_EMPTY 0x00
  87. #define EC_SCI_SRC_GAME 0x01
  88. #define EC_SCI_SRC_BATTERY 0x02
  89. #define EC_SCI_SRC_BATSOC 0x04
  90. #define EC_SCI_SRC_BATERR 0x08
  91. #define EC_SCI_SRC_EBOOK 0x10
  92. #define EC_SCI_SRC_WLAN 0x20
  93. #define EC_SCI_SRC_ACPWR 0x40
  94. #define EC_SCI_SRC_ALL 0x7F
  95. /* GPIO assignments */
  96. #define OLPC_GPIO_MIC_AC geode_gpio(1)
  97. #define OLPC_GPIO_DCON_IRQ geode_gpio(7)
  98. #define OLPC_GPIO_THRM_ALRM geode_gpio(10)
  99. #define OLPC_GPIO_SMB_CLK geode_gpio(14)
  100. #define OLPC_GPIO_SMB_DATA geode_gpio(15)
  101. #define OLPC_GPIO_WORKAUX geode_gpio(24)
  102. #define OLPC_GPIO_LID geode_gpio(26)
  103. #define OLPC_GPIO_ECSCI geode_gpio(27)
  104. #endif /* _ASM_X86_OLPC_H */