Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * KB3310B Embedded Controller
0004  *
0005  *  Copyright (C) 2008 Lemote Inc.
0006  *  Author: liujl <liujl@lemote.com>, 2008-03-14
0007  */
0008 
0009 #ifndef _EC_KB3310B_H
0010 #define _EC_KB3310B_H
0011 
0012 extern unsigned char ec_read(unsigned short addr);
0013 extern void ec_write(unsigned short addr, unsigned char val);
0014 extern int ec_query_seq(unsigned char cmd);
0015 extern int ec_query_event_num(void);
0016 extern int ec_get_event_num(void);
0017 
0018 typedef int (*sci_handler) (int status);
0019 extern sci_handler yeeloong_report_lid_status;
0020 
0021 #define SCI_IRQ_NUM 0x0A
0022 
0023 /*
0024  * The following registers are determined by the EC index configuration.
0025  * 1, fill the PORT_HIGH as EC register high part.
0026  * 2, fill the PORT_LOW as EC register low part.
0027  * 3, fill the PORT_DATA as EC register write data or get the data from it.
0028  */
0029 #define EC_IO_PORT_HIGH 0x0381
0030 #define EC_IO_PORT_LOW  0x0382
0031 #define EC_IO_PORT_DATA 0x0383
0032 
0033 /*
0034  * EC delay time is 500us for register and status access
0035  */
0036 #define EC_REG_DELAY    500 /* unit : us */
0037 #define EC_CMD_TIMEOUT  0x1000
0038 
0039 /*
0040  * EC access port for SCI communication
0041  */
0042 #define EC_CMD_PORT     0x66
0043 #define EC_STS_PORT     0x66
0044 #define EC_DAT_PORT     0x62
0045 #define CMD_INIT_IDLE_MODE  0xdd
0046 #define CMD_EXIT_IDLE_MODE  0xdf
0047 #define CMD_INIT_RESET_MODE 0xd8
0048 #define CMD_REBOOT_SYSTEM   0x8c
0049 #define CMD_GET_EVENT_NUM   0x84
0050 #define CMD_PROGRAM_PIECE   0xda
0051 
0052 /* temperature & fan registers */
0053 #define REG_TEMPERATURE_VALUE   0xF458
0054 #define REG_FAN_AUTO_MAN_SWITCH 0xF459
0055 #define BIT_FAN_AUTO        0
0056 #define BIT_FAN_MANUAL      1
0057 #define REG_FAN_CONTROL     0xF4D2
0058 #define BIT_FAN_CONTROL_ON  (1 << 0)
0059 #define BIT_FAN_CONTROL_OFF (0 << 0)
0060 #define REG_FAN_STATUS      0xF4DA
0061 #define BIT_FAN_STATUS_ON   (1 << 0)
0062 #define BIT_FAN_STATUS_OFF  (0 << 0)
0063 #define REG_FAN_SPEED_HIGH  0xFE22
0064 #define REG_FAN_SPEED_LOW   0xFE23
0065 #define REG_FAN_SPEED_LEVEL 0xF4CC
0066 /* fan speed divider */
0067 #define FAN_SPEED_DIVIDER   480000  /* (60*1000*1000/62.5/2)*/
0068 
0069 /* battery registers */
0070 #define REG_BAT_DESIGN_CAP_HIGH     0xF77D
0071 #define REG_BAT_DESIGN_CAP_LOW      0xF77E
0072 #define REG_BAT_FULLCHG_CAP_HIGH    0xF780
0073 #define REG_BAT_FULLCHG_CAP_LOW     0xF781
0074 #define REG_BAT_DESIGN_VOL_HIGH     0xF782
0075 #define REG_BAT_DESIGN_VOL_LOW      0xF783
0076 #define REG_BAT_CURRENT_HIGH        0xF784
0077 #define REG_BAT_CURRENT_LOW     0xF785
0078 #define REG_BAT_VOLTAGE_HIGH        0xF786
0079 #define REG_BAT_VOLTAGE_LOW     0xF787
0080 #define REG_BAT_TEMPERATURE_HIGH    0xF788
0081 #define REG_BAT_TEMPERATURE_LOW     0xF789
0082 #define REG_BAT_RELATIVE_CAP_HIGH   0xF492
0083 #define REG_BAT_RELATIVE_CAP_LOW    0xF493
0084 #define REG_BAT_VENDOR          0xF4C4
0085 #define FLAG_BAT_VENDOR_SANYO       0x01
0086 #define FLAG_BAT_VENDOR_SIMPLO      0x02
0087 #define REG_BAT_CELL_COUNT      0xF4C6
0088 #define FLAG_BAT_CELL_3S1P      0x03
0089 #define FLAG_BAT_CELL_3S2P      0x06
0090 #define REG_BAT_CHARGE          0xF4A2
0091 #define FLAG_BAT_CHARGE_DISCHARGE   0x01
0092 #define FLAG_BAT_CHARGE_CHARGE      0x02
0093 #define FLAG_BAT_CHARGE_ACPOWER     0x00
0094 #define REG_BAT_STATUS          0xF4B0
0095 #define BIT_BAT_STATUS_LOW      (1 << 5)
0096 #define BIT_BAT_STATUS_DESTROY      (1 << 2)
0097 #define BIT_BAT_STATUS_FULL     (1 << 1)
0098 #define BIT_BAT_STATUS_IN       (1 << 0)
0099 #define REG_BAT_CHARGE_STATUS       0xF4B1
0100 #define BIT_BAT_CHARGE_STATUS_OVERTEMP  (1 << 2)
0101 #define BIT_BAT_CHARGE_STATUS_PRECHG    (1 << 1)
0102 #define REG_BAT_STATE           0xF482
0103 #define BIT_BAT_STATE_CHARGING      (1 << 1)
0104 #define BIT_BAT_STATE_DISCHARGING   (1 << 0)
0105 #define REG_BAT_POWER           0xF440
0106 #define BIT_BAT_POWER_S3        (1 << 2)
0107 #define BIT_BAT_POWER_ON        (1 << 1)
0108 #define BIT_BAT_POWER_ACIN      (1 << 0)
0109 
0110 /* other registers */
0111 /* Audio: rd/wr */
0112 #define REG_AUDIO_VOLUME    0xF46C
0113 #define REG_AUDIO_MUTE      0xF4E7
0114 #define REG_AUDIO_BEEP      0xF4D0
0115 /* USB port power or not: rd/wr */
0116 #define REG_USB0_FLAG       0xF461
0117 #define REG_USB1_FLAG       0xF462
0118 #define REG_USB2_FLAG       0xF463
0119 #define BIT_USB_FLAG_ON     1
0120 #define BIT_USB_FLAG_OFF    0
0121 /* LID */
0122 #define REG_LID_DETECT      0xF4BD
0123 #define BIT_LID_DETECT_ON   1
0124 #define BIT_LID_DETECT_OFF  0
0125 /* CRT */
0126 #define REG_CRT_DETECT      0xF4AD
0127 #define BIT_CRT_DETECT_PLUG 1
0128 #define BIT_CRT_DETECT_UNPLUG   0
0129 /* LCD backlight brightness adjust: 9 levels */
0130 #define REG_DISPLAY_BRIGHTNESS  0xF4F5
0131 /* Black screen Status */
0132 #define BIT_DISPLAY_LCD_ON  1
0133 #define BIT_DISPLAY_LCD_OFF 0
0134 /* LCD backlight control: off/restore */
0135 #define REG_BACKLIGHT_CTRL  0xF7BD
0136 #define BIT_BACKLIGHT_ON    1
0137 #define BIT_BACKLIGHT_OFF   0
0138 /* Reset the machine auto-clear: rd/wr */
0139 #define REG_RESET       0xF4EC
0140 #define BIT_RESET_ON        1
0141 /* Light the led: rd/wr */
0142 #define REG_LED         0xF4C8
0143 #define BIT_LED_RED_POWER   (1 << 0)
0144 #define BIT_LED_ORANGE_POWER    (1 << 1)
0145 #define BIT_LED_GREEN_CHARGE    (1 << 2)
0146 #define BIT_LED_RED_CHARGE  (1 << 3)
0147 #define BIT_LED_NUMLOCK     (1 << 4)
0148 /* Test led mode, all led on/off */
0149 #define REG_LED_TEST        0xF4C2
0150 #define BIT_LED_TEST_IN     1
0151 #define BIT_LED_TEST_OUT    0
0152 /* Camera on/off */
0153 #define REG_CAMERA_STATUS   0xF46A
0154 #define BIT_CAMERA_STATUS_ON    1
0155 #define BIT_CAMERA_STATUS_OFF   0
0156 #define REG_CAMERA_CONTROL  0xF7B7
0157 #define BIT_CAMERA_CONTROL_OFF  0
0158 #define BIT_CAMERA_CONTROL_ON   1
0159 /* Wlan Status */
0160 #define REG_WLAN        0xF4FA
0161 #define BIT_WLAN_ON     1
0162 #define BIT_WLAN_OFF        0
0163 #define REG_DISPLAY_LCD     0xF79F
0164 
0165 /* SCI Event Number from EC */
0166 enum {
0167     EVENT_LID = 0x23,   /*  LID open/close */
0168     EVENT_DISPLAY_TOGGLE,   /*  Fn+F3 for display switch */
0169     EVENT_SLEEP,        /*  Fn+F1 for entering sleep mode */
0170     EVENT_OVERTEMP,     /*  Over-temperature happened */
0171     EVENT_CRT_DETECT,   /*  CRT is connected */
0172     EVENT_CAMERA,       /*  Camera on/off */
0173     EVENT_USB_OC2,      /*  USB2 Over Current occurred */
0174     EVENT_USB_OC0,      /*  USB0 Over Current occurred */
0175     EVENT_BLACK_SCREEN, /*  Turn on/off backlight */
0176     EVENT_AUDIO_MUTE,   /*  Mute on/off */
0177     EVENT_DISPLAY_BRIGHTNESS,/* LCD backlight brightness adjust */
0178     EVENT_AC_BAT,       /*  AC & Battery relative issue */
0179     EVENT_AUDIO_VOLUME, /*  Volume adjust */
0180     EVENT_WLAN,     /*  Wlan on/off */
0181     EVENT_END
0182 };
0183 
0184 #endif /* !_EC_KB3310B_H */