Lines Matching refs:adap

111 #define pch_dbg(adap, fmt, arg...)  \  argument
112 dev_dbg(adap->pch_adapter.dev.parent, "%s :" fmt, __func__, ##arg)
114 #define pch_err(adap, fmt, arg...) \ argument
115 dev_err(adap->pch_adapter.dev.parent, "%s :" fmt, __func__, ##arg)
207 static void pch_i2c_init(struct i2c_algo_pch_data *adap) in pch_i2c_init() argument
209 void __iomem *p = adap->pch_base_address; in pch_i2c_init()
222 pch_setbit(adap->pch_base_address, PCH_I2CCTL, PCH_I2CCTL_I2CMEN); in pch_i2c_init()
230 pch_dbg(adap, "Fast mode enabled\n"); in pch_i2c_init()
246 pch_dbg(adap, in pch_i2c_init()
258 static s32 pch_i2c_wait_for_bus_idle(struct i2c_algo_pch_data *adap, in pch_i2c_wait_for_bus_idle() argument
261 void __iomem *p = adap->pch_base_address; in pch_i2c_wait_for_bus_idle()
267 pch_dbg(adap, "I2CSR = %x\n", ioread32(p + PCH_I2CSR)); in pch_i2c_wait_for_bus_idle()
268 pch_err(adap, "%s: Timeout Error.return%d\n", in pch_i2c_wait_for_bus_idle()
270 pch_i2c_init(adap); in pch_i2c_wait_for_bus_idle()
294 static void pch_i2c_start(struct i2c_algo_pch_data *adap) in pch_i2c_start() argument
296 void __iomem *p = adap->pch_base_address; in pch_i2c_start()
297 pch_dbg(adap, "I2CCTL = %x\n", ioread32(p + PCH_I2CCTL)); in pch_i2c_start()
298 pch_setbit(adap->pch_base_address, PCH_I2CCTL, PCH_START); in pch_i2c_start()
305 static void pch_i2c_stop(struct i2c_algo_pch_data *adap) in pch_i2c_stop() argument
307 void __iomem *p = adap->pch_base_address; in pch_i2c_stop()
308 pch_dbg(adap, "I2CCTL = %x\n", ioread32(p + PCH_I2CCTL)); in pch_i2c_stop()
310 pch_clrbit(adap->pch_base_address, PCH_I2CCTL, PCH_START); in pch_i2c_stop()
313 static int pch_i2c_wait_for_check_xfer(struct i2c_algo_pch_data *adap) in pch_i2c_wait_for_check_xfer() argument
316 void __iomem *p = adap->pch_base_address; in pch_i2c_wait_for_check_xfer()
319 (adap->pch_event_flag != 0), msecs_to_jiffies(1000)); in pch_i2c_wait_for_check_xfer()
321 pch_err(adap, "%s:wait-event timeout\n", __func__); in pch_i2c_wait_for_check_xfer()
322 adap->pch_event_flag = 0; in pch_i2c_wait_for_check_xfer()
323 pch_i2c_stop(adap); in pch_i2c_wait_for_check_xfer()
324 pch_i2c_init(adap); in pch_i2c_wait_for_check_xfer()
328 if (adap->pch_event_flag & I2C_ERROR_MASK) { in pch_i2c_wait_for_check_xfer()
329 pch_err(adap, "Lost Arbitration\n"); in pch_i2c_wait_for_check_xfer()
330 adap->pch_event_flag = 0; in pch_i2c_wait_for_check_xfer()
331 pch_clrbit(adap->pch_base_address, PCH_I2CSR, I2CMAL_BIT); in pch_i2c_wait_for_check_xfer()
332 pch_clrbit(adap->pch_base_address, PCH_I2CSR, I2CMIF_BIT); in pch_i2c_wait_for_check_xfer()
333 pch_i2c_init(adap); in pch_i2c_wait_for_check_xfer()
337 adap->pch_event_flag = 0; in pch_i2c_wait_for_check_xfer()
340 pch_dbg(adap, "Receive NACK for slave address setting\n"); in pch_i2c_wait_for_check_xfer()
351 static void pch_i2c_repstart(struct i2c_algo_pch_data *adap) in pch_i2c_repstart() argument
353 void __iomem *p = adap->pch_base_address; in pch_i2c_repstart()
354 pch_dbg(adap, "I2CCTL = %x\n", ioread32(p + PCH_I2CCTL)); in pch_i2c_repstart()
355 pch_setbit(adap->pch_base_address, PCH_I2CCTL, PCH_REPSTART); in pch_i2c_repstart()
371 struct i2c_algo_pch_data *adap = i2c_adap->algo_data; in pch_i2c_writebytes() local
379 void __iomem *p = adap->pch_base_address; in pch_i2c_writebytes()
386 pch_setbit(adap->pch_base_address, PCH_I2CCTL, I2C_TX_MODE); in pch_i2c_writebytes()
388 pch_dbg(adap, "I2CCTL = %x msgs->len = %d\n", ioread32(p + PCH_I2CCTL), in pch_i2c_writebytes()
392 if (pch_i2c_wait_for_bus_idle(adap, BUS_IDLE_TIMEOUT) == -ETIME) in pch_i2c_writebytes()
400 pch_i2c_start(adap); in pch_i2c_writebytes()
402 rtn = pch_i2c_wait_for_check_xfer(adap); in pch_i2c_writebytes()
412 pch_i2c_start(adap); in pch_i2c_writebytes()
415 rtn = pch_i2c_wait_for_check_xfer(adap); in pch_i2c_writebytes()
422 pch_dbg(adap, "writing %x to Data register\n", buf[wrcount]); in pch_i2c_writebytes()
424 rtn = pch_i2c_wait_for_check_xfer(adap); in pch_i2c_writebytes()
428 pch_clrbit(adap->pch_base_address, PCH_I2CSR, I2CMCF_BIT); in pch_i2c_writebytes()
429 pch_clrbit(adap->pch_base_address, PCH_I2CSR, I2CMIF_BIT); in pch_i2c_writebytes()
434 pch_i2c_stop(adap); in pch_i2c_writebytes()
436 pch_i2c_repstart(adap); in pch_i2c_writebytes()
438 pch_dbg(adap, "return=%d\n", wrcount); in pch_i2c_writebytes()
447 static void pch_i2c_sendack(struct i2c_algo_pch_data *adap) in pch_i2c_sendack() argument
449 void __iomem *p = adap->pch_base_address; in pch_i2c_sendack()
450 pch_dbg(adap, "I2CCTL = %x\n", ioread32(p + PCH_I2CCTL)); in pch_i2c_sendack()
451 pch_clrbit(adap->pch_base_address, PCH_I2CCTL, PCH_ACK); in pch_i2c_sendack()
458 static void pch_i2c_sendnack(struct i2c_algo_pch_data *adap) in pch_i2c_sendnack() argument
460 void __iomem *p = adap->pch_base_address; in pch_i2c_sendnack()
461 pch_dbg(adap, "I2CCTL = %x\n", ioread32(p + PCH_I2CCTL)); in pch_i2c_sendnack()
462 pch_setbit(adap->pch_base_address, PCH_I2CCTL, PCH_ACK); in pch_i2c_sendnack()
471 static void pch_i2c_restart(struct i2c_algo_pch_data *adap) in pch_i2c_restart() argument
473 void __iomem *p = adap->pch_base_address; in pch_i2c_restart()
474 pch_dbg(adap, "I2CCTL = %x\n", ioread32(p + PCH_I2CCTL)); in pch_i2c_restart()
475 pch_setbit(adap->pch_base_address, PCH_I2CCTL, PCH_RESTART); in pch_i2c_restart()
488 struct i2c_algo_pch_data *adap = i2c_adap->algo_data; in pch_i2c_readbytes() local
496 void __iomem *p = adap->pch_base_address; in pch_i2c_readbytes()
504 pch_clrbit(adap->pch_base_address, PCH_I2CCTL, I2C_TX_MODE); in pch_i2c_readbytes()
507 if (pch_i2c_wait_for_bus_idle(adap, BUS_IDLE_TIMEOUT) == -ETIME) in pch_i2c_readbytes()
515 pch_i2c_start(adap); in pch_i2c_readbytes()
517 rtn = pch_i2c_wait_for_check_xfer(adap); in pch_i2c_readbytes()
524 pch_i2c_restart(adap); in pch_i2c_readbytes()
526 rtn = pch_i2c_wait_for_check_xfer(adap); in pch_i2c_readbytes()
539 pch_i2c_start(adap); in pch_i2c_readbytes()
541 rtn = pch_i2c_wait_for_check_xfer(adap); in pch_i2c_readbytes()
546 pch_i2c_stop(adap); in pch_i2c_readbytes()
553 pch_i2c_sendack(adap); in pch_i2c_readbytes()
562 rtn = pch_i2c_wait_for_check_xfer(adap); in pch_i2c_readbytes()
567 pch_i2c_sendnack(adap); in pch_i2c_readbytes()
574 rtn = pch_i2c_wait_for_check_xfer(adap); in pch_i2c_readbytes()
579 pch_i2c_stop(adap); in pch_i2c_readbytes()
581 pch_i2c_repstart(adap); in pch_i2c_readbytes()
594 static void pch_i2c_cb(struct i2c_algo_pch_data *adap) in pch_i2c_cb() argument
597 void __iomem *p = adap->pch_base_address; in pch_i2c_cb()
602 adap->pch_event_flag |= I2CMAL_EVENT; in pch_i2c_cb()
605 adap->pch_event_flag |= I2CMCF_EVENT; in pch_i2c_cb()
608 pch_clrbit(adap->pch_base_address, PCH_I2CSR, sts); in pch_i2c_cb()
610 pch_dbg(adap, "PCH_I2CSR = %x\n", ioread32(p + PCH_I2CSR)); in pch_i2c_cb()
662 struct i2c_algo_pch_data *adap = i2c_adap->algo_data; in pch_i2c_xfer() local
668 if (adap->p_adapter_info->pch_i2c_suspended) { in pch_i2c_xfer()
673 pch_dbg(adap, "adap->p_adapter_info->pch_i2c_suspended is %d\n", in pch_i2c_xfer()
674 adap->p_adapter_info->pch_i2c_suspended); in pch_i2c_xfer()
676 adap->pch_i2c_xfer_in_progress = true; in pch_i2c_xfer()
680 pmsg->flags |= adap->pch_buff_mode_en; in pch_i2c_xfer()
682 pch_dbg(adap, in pch_i2c_xfer()
694 adap->pch_i2c_xfer_in_progress = false; /* transfer completed */ in pch_i2c_xfer()
705 static u32 pch_i2c_func(struct i2c_adapter *adap) in pch_i2c_func() argument
719 static void pch_i2c_disbl_int(struct i2c_algo_pch_data *adap) in pch_i2c_disbl_int() argument
721 void __iomem *p = adap->pch_base_address; in pch_i2c_disbl_int()
723 pch_clrbit(adap->pch_base_address, PCH_I2CCTL, NORMAL_INTR_ENBL); in pch_i2c_disbl_int()