Skip to content

Commit 885f8e0

Browse files
authored
Merge pull request #483 from FrameworkComputer/hx30.fix_touchpad_issue
Hx30.fix touchpad issue
2 parents 847ab5d + 7ade55b commit 885f8e0

5 files changed

Lines changed: 47 additions & 12 deletions

File tree

board/hx30/board.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -827,12 +827,6 @@ void board_hibernate_late(void)
827827
gpio_set_level(GPIO_SYS_RESET_L, 0);
828828
}
829829

830-
void thm_ft5399m_set_timeout_en(void)
831-
{
832-
CPRINTS("%s", __func__);
833-
i2c_write8(I2C_PORT_THERMAL_2, F75303_I2C_ADDR_FLAGS, 0x22, BIT(7));
834-
}
835-
836830
/* according to Panel team suggest, delay 60ms to meet spec */
837831
static void bkoff_on_deferred(void)
838832
{

board/hx30/board.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@
512512
#define I2C_PORT_TCPC MCHP_I2C_PORT3
513513
#define I2C_PORT_BATTERY MCHP_I2C_PORT1
514514
#define I2C_PORT_CHARGER MCHP_I2C_PORT1
515-
#define I2C_PORT_THERMAL_2 MCHP_I2C_PORT1
516515
#define I2C_PORT_THERMAL MCHP_I2C_PORT3
517516
#define I2C_PORT_ALS MCHP_I2C_PORT4
518517

@@ -771,8 +770,6 @@ int get_hardware_id(enum adc_channel channel);
771770

772771
int ac_boot_status(void);
773772

774-
void thm_ft5399m_set_timeout_en(void);
775-
776773
void update_me_change(int change);
777774

778775
int poweron_reason_powerbtn(void);

board/hx30/power_sequence.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ enum power_state power_handle_state(enum power_state state)
526526
gpio_set_level(GPIO_SUSP_L, 1);
527527

528528
msleep(10);
529-
thm_ft5399m_set_timeout_en();
530529
f75303_set_enabled(1);
531530
f75397_set_enabled(1);
532531

board/hx30/ps2mouse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ void setup_touchpad(void)
305305
/* These are touchpad firmware dependent
306306
* They set the touchpad into the mouse device mode, instead of PTP mode
307307
* And are based on the HID descriptor for our unique device */
308-
const static uint16_t cmd[5] = {0x0336, 0x0023, 0x0004, 0x0006};
308+
const static uint16_t cmd[4] = {0x0336, 0x0023, 0x0004, 0x0006};
309309

310310
rv = i2c_write_offset16_block(I2C_PORT_TOUCHPAD,
311311
TOUCHPAD_I2C_HID_EP | I2C_FLAG_ADDR16_LITTLE_ENDIAN,

chip/mchp/i2c.c

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@
8080
#define CFG_ENABLE BIT(10) /* enable controller */
8181
#define CFG_GC_DIS BIT(14) /* disable general call address */
8282
#define CFG_PROM_EN BIT(15) /* enable Promiscuous mode */
83+
#define CFG_FLUSH_SXBUF (16) /* clear slave Tx buffer */
84+
#define CFG_FLUSH_SRBUF (17) /* clear slave Rx buffer */
85+
#define CFG_FLUSH_MXBUF (18) /* clear master Tx buffer */
86+
#define CFG_FLUSH_MRBUF (19) /* clear master Rx buffer */
8387
#define CFG_ENIDI BIT(29) /* Enable I2C idle interrupt */
8488
/* Enable network layer master done interrupt */
8589
#define CFG_ENMI BIT(30)
@@ -619,6 +623,21 @@ static int i2c_mtx(int ctrl)
619623
cdata[ctrl].transaction_state = I2C_TRANSACTION_OPEN;
620624
}
621625

626+
/* Workaround to revocer the LAB flag error */
627+
while (MCHP_I2C_STATUS(ctrl) & STS_LAB) {
628+
CPRINTS("I2C%d wSTS LAB error, doing reset!", ctrl);
629+
MCHP_I2C_CONFIG(ctrl) |= CFG_FLUSH_MRBUF | CFG_FLUSH_MXBUF |
630+
CFG_FLUSH_SRBUF | CFG_FLUSH_SXBUF;
631+
reset_controller(ctrl);
632+
usleep(1000);
633+
634+
MCHP_I2C_DATA(ctrl) = cdata[ctrl].slv_addr_8bit;
635+
/* Clock out the slave address, sending START bit */
636+
MCHP_I2C_CTRL(ctrl) = CTRL_PIN | CTRL_ESO | CTRL_ENI |
637+
CTRL_ACK | CTRL_STA;
638+
cdata[ctrl].transaction_state = I2C_TRANSACTION_OPEN;
639+
}
640+
622641
for (i = 0; i < cdata[ctrl].out_size; ++i) {
623642
rv = wait_byte_done(ctrl, 0xff, 0x00);
624643
if (rv) {
@@ -702,6 +721,30 @@ static int i2c_mrx_start(int ctrl)
702721
/* address then START */
703722
MCHP_I2C_CTRL(ctrl) = u8 | CTRL_PIN;
704723
}
724+
725+
/* Workaround to revocer the LAB flag error */
726+
while (MCHP_I2C_STATUS(ctrl) & STS_LAB) {
727+
CPRINTS("I2C%d rSTS LAB error, doing reset!", ctrl);
728+
MCHP_I2C_CONFIG(ctrl) |= CFG_FLUSH_MRBUF | CFG_FLUSH_MXBUF |
729+
CFG_FLUSH_SRBUF | CFG_FLUSH_SXBUF;
730+
reset_controller(ctrl);
731+
usleep(1000);
732+
733+
if (cdata[ctrl].transaction_state == I2C_TRANSACTION_OPEN) {
734+
cdata[ctrl].flags |= (1ul << 5);
735+
/* Repeated-START then address */
736+
MCHP_I2C_CTRL(ctrl) = u8;
737+
}
738+
739+
MCHP_I2C_DATA(ctrl) = cdata[ctrl].slv_addr_8bit | 0x01;
740+
if (cdata[ctrl].transaction_state == I2C_TRANSACTION_STOPPED) {
741+
cdata[ctrl].flags |= (1ul << 6);
742+
/* address then START */
743+
MCHP_I2C_CTRL(ctrl) = u8 | CTRL_PIN;
744+
}
745+
}
746+
747+
705748
cdata[ctrl].transaction_state = I2C_TRANSACTION_OPEN;
706749
/* Controller generates START, transmits data(address) capturing
707750
* 9-bits from SDA (8-bit address + (N)Ack bit).
@@ -843,8 +886,10 @@ int chip_i2c_xfer(int port, uint16_t slave_addr_flags,
843886

844887
cdata[ctrl].flags |= (1ul << 15);
845888
/* MCHP wait for STOP to complete */
846-
if (cdata[ctrl].xflags & I2C_XFER_STOP)
889+
if (cdata[ctrl].xflags & I2C_XFER_STOP) {
890+
cdata[ctrl].transaction_state = I2C_TRANSACTION_STOPPED;
847891
wait_idle(ctrl);
892+
}
848893

849894
/* Check for error conditions */
850895
if (MCHP_I2C_STATUS(ctrl) & (STS_LAB | STS_BER)) {

0 commit comments

Comments
 (0)