Topcliff: Update PCH_I2C driver to 2.6.35
PATCH 1/1 Topcliff: Update PCH_I2C driver to 2.6.35
Hi Linus Walleij
We have updated for your comments.
Please confirm below.
---
I2C driver of Topcliff PCH
Topcliff PCH is the platform controller hub that is going to be used in Intel's upcoming general embedded platform. All IO peripherals in Topcliff PCH are actually devices sitting on AMBA bus. Topcliff PCH has I2C I/F. Using this I/F, it is able to access system devices connected to I2C.
--- drivers/i2c/busses/Kconfig | 18 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-pch.c | 951 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 970 insertions(+), 0 deletions(-) create mode 100644 drivers/i2c/busses/i2c-pch.c
drivers/i2c/busses/Kconfig +18 -0
@@ -613,6 +613,24 @@ config I2C_XILINX This driver can also be built as a module. If so, the module will be called xilinx_i2c. +config PCH_I2C + tristate "PCH I2C of Intel Topcliff" + depends on PCI + help + This driver is for PCH(Platform controller Hub) I2C of Topcliff which + is an IOH(Input/Output Hub) for x86 embedded processor. + This driver can access PCH I2C bus device. + +config PCH_I2C_CH_COUNT + int "PCH I2C the number of channel count" + range 1 2 + depends on PCH_I2C + help + This driver is for PCH(Platform controller Hub) I2C of Topcliff which + is an IOH(Input/Output Hub) for x86 embedded processor. + The number of I2C buses/channels supported by the PCH I2C controller. + PCH I2C of Topcliff supports only one channel. + comment "External I2C/SMBus adapter drivers" config I2C_PARPORT
drivers/i2c/busses/Makefile +1 -0
@@ -59,6 +59,7 @@ obj-$(CONFIG_I2C_STU300) += i2c-stu300.o obj-$(CONFIG_I2C_VERSATILE) += i2c-versatile.o obj-$(CONFIG_I2C_OCTEON) += i2c-octeon.o obj-$(CONFIG_I2C_XILINX) += i2c-xiic.o +obj-$(CONFIG_PCH_I2C) += i2c-pch.o # External I2C/SMBus adapter drivers obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o
drivers/i2c/busses/i2c-pch.c new file +951 -0
951 lines not on this page · raw message
Signature · 1 line
1.6.0.6
I suggest these logging message changes and bug fixes:
Add pch_pci_dbg.
Rename 1st argument to pch_pci_dbg to pdev.
Add trailing "\n" to formats missing them.
Add "%s:" fmt, __func__, args to pch_<level> and pch_pci_<level> logging macros.
Remove __func__ and inconsistent use of "%s : " and "%s:" prefix from logging macro uses.
Fix misspelling of Enterred to Entered.
Use "FAILED" consistently.
There's an odd use that is still questionable:
pch_pci_dbg(pdev, "request_irq returns %d pch_probe returns\n", ret);
--- drivers/i2c/busses/i2c-pch.c | 103 ++++++++++++++++++++---------------------- 1 files changed, 49 insertions(+), 54 deletions(-)
drivers/i2c/busses/i2c-pch.c +49 -54
@@ -121,13 +121,15 @@#define I2CESRTO_EVENT 0x0100#define PCI_DEVICE_ID_PCH_I2C 0x8817 -#define pch_dbg(adap, fmt, arg...) \ - dev_dbg(adap->pch_adapter.dev.parent, fmt, ##arg) +#define pch_dbg(adap, fmt, arg...) \ + dev_dbg(adap->pch_adapter.dev.parent, "%s: " fmt, __func__, ##arg) +#define pch_err(adap, fmt, arg...) \ + dev_err(adap->pch_adapter.dev.parent, "%s: " fmt, __func__, ##arg) -#define pch_err(adap, fmt, arg...) \ - dev_err(adap->pch_adapter.dev.parent, fmt, ##arg) - -#define pch_pci_err(adap, fmt, arg...) dev_err(&adap->dev, fmt, ##arg) +#define pch_pci_dbg(pdev, fmt, arg...) \ + dev_dbg(&pdev->dev, "%s: " fmt, __func__, ##arg) +#define pch_pci_err(pdev, fmt, arg...) \ + dev_err(&pdev->dev, "%s: " fmt, __func__, ##arg)/** * struct i2c_algo_pch_data - for I2C driver functionalities
@@ -243,9 +245,8 @@ static void pch_init(struct i2c_algo_pch_data *adap) reg_value |=NORMAL_INTR_ENBL ;/* Enable interrupts in normal mode */ iowrite32 (reg_value, p +PCH_I2CCTL ); -pch_dbg (adap, -"%s: I2CCTL=%x pch_i2cbc=%x pch_i2ctmr=%x Enable interrupts\n" , - __func__,ioread32 (p +PCH_I2CCTL ), pch_i2cbc, pch_i2ctmr); +pch_dbg (adap,"I2CCTL=%x pch_i2cbc=%x pch_i2ctmr=%x Enable interrupts\n" , +ioread32 (p +PCH_I2CCTL ), pch_i2cbc, pch_i2ctmr);init_waitqueue_head (&pch_event); }
@@ -273,10 +274,10 @@ static s32 pch_wait_for_bus_idle(struct i2c_algo_pch_data *adap,msleep (1 ); }while (ktime_lt (ktime_get (), ns_val)); -pch_dbg (adap,"%s : I2CSR = %x\n" , __func__,ioread32 (p +PCH_I2CSR )); +pch_dbg (adap,"I2CSR = %x\n" ,ioread32 (p +PCH_I2CSR ));if (timeout ==0 ) { -pch_err (adap,"%s :return%d\n" , __func__, -ETIME ); +pch_err (adap,"return: %d\n" , -ETIME );return -ETIME ; }
@@ -292,8 +293,7 @@ static s32 pch_wait_for_bus_idle(struct i2c_algo_pch_data *adap,static void pch_start (struct i2c_algo_pch_data *adap) {void __iomem *p = adap->pch_base_address; -pch_dbg (adap,"In %s : I2CCTL = %x\n" , - __func__,ioread32 (p +PCH_I2CCTL )); +pch_dbg (adap,"I2CCTL = %x\n" ,ioread32 (p +PCH_I2CCTL ));pch_setbit ((adap->pch_base_address),PCH_I2CCTL ,PCH_START ); }
@@ -307,20 +307,17 @@ static s32 pch_wait_for_xfer_complete(struct i2c_algo_pch_data *adap) ret =wait_event_interruptible_timeout (pch_event, (adap->pch_event_flag !=0 ),msecs_to_jiffies (50 ));if (ret <0 ) { -pch_err (adap,"%s :timeout: %x\n" , - __func__, adap->pch_event_flag); +pch_err (adap,"timeout: %x\n" , adap->pch_event_flag);return ret; }if (ret ==0 ) { -pch_err (adap,"%s :timeout: %x\n" , - __func__, adap->pch_event_flag); +pch_err (adap,"timeout: %x\n" , adap->pch_event_flag);return -ETIMEDOUT ; }if (adap->pch_event_flag &I2C_ERROR_MASK ) { -pch_err (adap,"%s :error bits set: %x\n" , - __func__, adap->pch_event_flag); +pch_err (adap,"error bits set: %x\n" , adap->pch_event_flag);return -EIO ; }
@@ -341,7 +338,7 @@ static s32 pch_getack(struct i2c_algo_pch_data *adap) reg_val =ioread32 (p +PCH_I2CSR ) &PCH_GETACK ;if (reg_val !=0 ) { -pch_err (adap,"%s : return%d\n" , __func__, -EPROTO ); +pch_err (adap,"return: %d\n" , -EPROTO );return -EPROTO ; }
@@ -355,7 +352,7 @@ static s32 pch_getack(struct i2c_algo_pch_data *adap)static void pch_stop (struct i2c_algo_pch_data *adap) {void __iomem *p = adap->pch_base_address; -pch_dbg (adap,"%s : I2CCTL = %x\n" , __func__,ioread32 (p +PCH_I2CCTL )); +pch_dbg (adap,"I2CCTL = %x\n" ,ioread32 (p +PCH_I2CCTL ));/* clear the start bit */ pch_clrbit ((adap->pch_base_address),PCH_I2CCTL ,PCH_START ); }
@@ -367,8 +364,7 @@ static void pch_stop(struct i2c_algo_pch_data *adap)static void pch_repstart (struct i2c_algo_pch_data *adap) {void __iomem *p = adap->pch_base_address; -pch_dbg (adap,"In %s : I2CCTL = %x\n" , - __func__,ioread32 (p +PCH_I2CCTL )); +pch_dbg (adap,"I2CCTL = %x\n" ,ioread32 (p +PCH_I2CCTL ));pch_setbit ((adap->pch_base_address),PCH_I2CCTL ,PCH_REPSTART ); }
@@ -398,7 +394,7 @@ static s32 pch_writebytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs,/* enable master tx */ pch_setbit ((adap->pch_base_address),PCH_I2CCTL ,I2C_TX_MODE ); -pch_dbg (adap,"%s : I2CCTL = %x msgs->len = %d\n" , __func__, +pch_dbg (adap,"I2CCTL = %x msgs->len = %d\n" ,ioread32 (p +PCH_I2CCTL ), length);if (first) {
@@ -431,13 +427,13 @@ static s32 pch_writebytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs,for (wrcount =0 ; wrcount < length; ++wrcount) {/* write buffer value to I2C data register */ iowrite32 (buf[wrcount], p +PCH_I2CDR ); -pch_dbg (adap,"%s : writing %x to Data register\n" , - __func__, buf[wrcount]); +pch_dbg (adap,"writing %x to Data register\n" , + buf[wrcount]);if (pch_wait_for_xfer_complete (adap) !=0 )return -ETIME ; -pch_dbg (adap,"%s return %d" , __func__,0 ); +pch_dbg (adap,"return %d" ,0 );if (pch_getack (adap))return -ETIME ;
@@ -453,7 +449,7 @@ static s32 pch_writebytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs,return -EIO ; } -pch_dbg (adap,"%s return=%d\n" , __func__, wrcount); +pch_dbg (adap,"return=%d\n" , wrcount);return wrcount; }
@@ -465,7 +461,7 @@ static s32 pch_writebytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs,static void pch_sendack (struct i2c_algo_pch_data *adap) {void __iomem *p = adap->pch_base_address; -pch_dbg (adap,"%s : I2CCTL = %x\n" , __func__,ioread32 (p +PCH_I2CCTL )); +pch_dbg (adap,"I2CCTL = %x\n" ,ioread32 (p +PCH_I2CCTL ));pch_clrbit ((adap->pch_base_address),PCH_I2CCTL ,PCH_ACK ); }
@@ -476,7 +472,7 @@ static void pch_sendack(struct i2c_algo_pch_data *adap)static void pch_sendnack (struct i2c_algo_pch_data *adap) {void __iomem *p = adap->pch_base_address; -pch_dbg (adap,"%s : I2CCTL = %x\n" , __func__,ioread32 (p +PCH_I2CCTL )); +pch_dbg (adap,"I2CCTL = %x\n" ,ioread32 (p +PCH_I2CCTL ));pch_setbit ((adap->pch_base_address),PCH_I2CCTL ,PCH_ACK ); }
@@ -526,7 +522,7 @@ s32 pch_readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs,if ((pch_wait_for_xfer_complete (adap) ==0 ) && (pch_getack (adap) ==0 )) { -pch_dbg (adap,"%s return %d" , __func__,0 ); +pch_dbg (adap,"return %d" ,0 );if (length ==0 ) {pch_stop (adap);
@@ -599,8 +595,7 @@ static void pch_cb_ch0(struct i2c_algo_pch_data *adap)/* clear the applicable bits */ pch_clrbit ((adap->pch_base_address),PCH_I2CSR , sts); -pch_dbg (adap,"%s : PCH_I2CSR = %x\n" , - __func__,ioread32 (p +PCH_I2CSR )); +pch_dbg (adap,"PCH_I2CSR = %x\n" ,ioread32 (p +PCH_I2CSR ));wake_up_interruptible (&pch_event); }
@@ -619,7 +614,7 @@ static irqreturn_t pch_handler_ch0(int irq, void *pData)u32 mode =ioread32 (p +PCH_I2CMOD ) & (BUFFER_MODE |EEPROM_SR_MODE );if (mode !=NORMAL_MODE ) { -pch_err (adap_data,"%s I2C mode is not supported\n" , __func__); +pch_err (adap_data,"I2C mode is not supported\n" );return IRQ_NONE ; }
@@ -639,7 +634,7 @@ static irqreturn_t pch_handler_ch0(int irq, void *pData)else goto err_out; }else { -pch_err (adap_data,"%s I2C mode is not supported\n" , __func__); +pch_err (adap_data,"I2C mode is not supported\n" ); goto err_out; }return IRQ_HANDLED ;
@@ -675,8 +670,8 @@ static s32 pch_xfer(struct i2c_adapter *i2c_adap,return -EBUSY ; } -pch_dbg (adap,"%s adap->p_adapter_info->pch_suspended is %d\n" , - __func__, adap->p_adapter_info->pch_suspended); +pch_dbg (adap,"adap->p_adapter_info->pch_suspended is %d\n" , + adap->p_adapter_info->pch_suspended);/* transfer not completed */ adap->pch_xfer_in_progress = true;
@@ -685,7 +680,7 @@ static s32 pch_xfer(struct i2c_adapter *i2c_adap, pmsg->flags |= adap->pch_buff_mode_en; status = pmsg->flags;pch_dbg (adap, -"After invoking I2C_MODE_SEL :flag= 0x%x\n" , status); +"After invoking I2C_MODE_SEL: flag=0x%x\n" , status);/* calculate sub address length and message length */ /* these are applicable only for buffer mode */ subaddrlen = pmsg->buf[0 ];
@@ -693,11 +688,11 @@ static s32 pch_xfer(struct i2c_adapter *i2c_adap,* the sub address fields */ msglen = (pmsg->len) - (subaddrlen +1 );if (status & (I2C_M_RD )) { -pch_dbg (adap,"%s invoking pch_readbytes\n" , __func__); +pch_dbg (adap,"invoking pch_readbytes\n" ); ret =pch_readbytes (i2c_adap, pmsg, (i +1 == num), (i ==0 )); }else { -pch_dbg (adap,"%s invoking pch_writebytes\n" , __func__); +pch_dbg (adap,"invoking pch_writebytes\n" ); ret =pch_writebytes (i2c_adap, pmsg, (i +1 == num), (i ==0 )); }
@@ -752,29 +747,29 @@ static int __devinit pch_probe(struct pci_dev *pdev,struct adapter_info *adap_info =kzalloc ((sizeof (struct adapter_info )),GFP_KERNEL ); -dev_dbg (&pdev->dev,"Enterred in %s\n" , __func__); +pch_pci_dbg (pdev,"Entered\n" );if (adap_info ==NULL ) { -pch_pci_err (pdev,"Memory allocation failed FAILED" ); +pch_pci_err (pdev,"Memory allocation failed FAILED\n" );return -ENOMEM ; } ret =pci_enable_device (pdev);if (ret) { -pch_pci_err (pdev,"%s : pci_enable_device FAILED" , __func__); +pch_pci_err (pdev,"pci_enable_device FAILED\n" ); goto err_pci_enable; } ret =pci_request_regions (pdev,KBUILD_MODNAME );if (ret) { -pch_pci_err (pdev,"pci_request_regions FAILED" ); +pch_pci_err (pdev,"pci_request_regions FAILED\n" ); goto err_pci_req; } base_addr =pci_iomap (pdev,1 ,0 );if (base_addr ==0 ) { -pch_pci_err (pdev,"pci_iomap FAILED" ); +pch_pci_err (pdev,"pci_iomap FAILED\n" ); ret = -ENOMEM ; goto err_pci_iomap; }
@@ -799,7 +794,7 @@ static int __devinit pch_probe(struct pci_dev *pdev, ret =i2c_add_adapter (&(adap_info->pch_data[i].pch_adapter));if (ret) { -pch_pci_err (pdev,"i2c_add_adapter FAILED" ); +pch_pci_err (pdev,"i2c_add_adapter FAILED\n" ); goto err_i2c_add_adapter; }
@@ -807,12 +802,12 @@ static int __devinit pch_probe(struct pci_dev *pdev, ret =request_irq (pdev->irq, pch_handler_list[i],IRQF_SHARED ,KBUILD_MODNAME , &adap_info->pch_data[i]);if (ret) { -pch_pci_err (pdev,"request_irq Failed\n" ); +pch_pci_err (pdev,"request_irq FAILED\n" ); goto err_request_irq; } } -dev_dbg (&pdev->dev,"request_irq returns %d pch_probe returns.\n" , ret); +pch_pci_dbg (pdev,"request_irq returns %d pch_probe returns\n" , ret);pci_set_drvdata (pdev, adap_info);return 0 ;
@@ -876,12 +871,12 @@ static int pch_suspend(struct pci_dev *pdev, pm_message_t state)pch_disbl_int (&adap_info->pch_data[i]); } -dev_dbg (&pdev->dev, -"I2CSR = %x I2CBUFSTA = %x I2CESRSTA = %x " -"invoked function pch_disbl_int successfully\n" , -ioread32 (p +0x08 ), -ioread32 (p +0x30 ), -ioread32 (p +0x44 )); +pch_pci_dbg (pdev, +"I2CSR = %x I2CBUFSTA = %x I2CESRSTA = %x " +"invoked function pch_disbl_int successfully\n" , +ioread32 (p +0x08 ), +ioread32 (p +0x30 ), +ioread32 (p +0x44 )); ret =pci_save_state (pdev);
A message that is not in the archive (sent off-list or not yet received): 4C80692E.80004-ECg8zkTtlr0C6LszWs/[email protected]
Linus WALLEIJ
Reviewed-by[Masayuki]
Quoted 2 lines
We have updated for your comments.
Please confirm below.
It's really looking good now! :-)
Yours,
Linus Walleij
[Masayuki]
Quoted 2 lines
We have updated for your comments.
Please confirm below.
It's really looking good now! :-)
Yours,
Linus Walleij