Topcliff: Update PCH_I2C driver to 2.6.35
PATCH 1/1 Topcliff: Update PCH_I2C driver to 2.6.35
Hi Joe,
We have updated for your comments.
Please confirm below.
Thanks, Ohtake(OKISemi)
---
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 | 943 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 962 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 +943 -0
943 lines not on this page · raw message
Signature · 1 line
1.6.0.6
On Fri, 2010-09-03 at 16:15 +0900, Masayuki Ohtak wrote:
[]
drivers/i2c/busses/i2c-pch.c line 133
Quoted 10 lines
drivers/i2c/busses/i2c-pch.c new file +10
-0+#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_pci_err(pdev, fmt, arg...) \ + dev_err(&pdev->dev, "%s :"fmt, __func__, ##arg) +#define pch_pci_dbg(pdev, fmt, arg...) \ + dev_dbg(&pdev->dev, "%s :"fmt, __func__, ##arg)
OK, but it seems careless because the two types are not uniformly indented, there's a blank line between pch_dbg and pch_err, and the two pch_pci_<level> defines are in the reverse order without a blank line between them.
I think it's better to use separate multiple strings that are concatentated by the preprocessor like:
"%s :" fmt not "%s :"fmt
Almost all code in kernel uses "%s: " to format __func__. Some use "%s(): ". I think "%s :" is unique.
The rest of the logging messages look good.
Some other comments:
Review
Quoted 2 lines
(quoted diff) +2
-0+ if ((pch_wait_for_xfer_complete(adap) == 0) && + (pch_getack(adap) == 0)) {
This would look better as:
if ((pch_wait_for_xfer_complete(adap) == 0) &&
(pch_getack(adap) == 0)) {drivers/i2c/busses/i2c-pch.c line 524
Quoted 2 lines
drivers/i2c/busses/i2c-pch.c new file +2
-0+if ((pch_wait_for_xfer_complete (adap) ==0 ) + && (pch_getack (adap) ==0 )) {
Here too.
drivers/i2c/busses/i2c-pch.c line 872
Quoted 8 lines
drivers/i2c/busses/i2c-pch.c new file +8
-0+for (i =0 ; i <PCH_MAX_CHN ; i++) { +while ((adap_info->pch_data[i].pch_xfer_in_progress)) { +/* Wait until all channel transfers are completed */ +msleep (1 ); + } +/* Disable the i2c interrupts */ +pch_disbl_int (&adap_info->pch_data[i]); + }
Would it be better to disable all possible interrupts first or do you need to disable them in order?
Something like:
bool *disabled = kzalloc(PCH_MAX_CHN * sizeof(bool), GFP_KERNEL);
/*
* or a static with a memset, or check something
* like pch_is_int_enabled(&adap_info->pch_data[i])
* then remove the else because the kzalloc couldn't fail. */
if (disabled) {
bool alldone;
do {
alldone = true;
for (i = 0; i < PCH_MAX_CHN; i++) {
if (!adap_info->pch_data[i].pch_xfer_in_progress &&
!disabled[i])) {
pch_disbl_int(&adap_info->pch_data[i]);
disabled[i] = true;
} else
alldone = false;
}
if (!alldone) {
/* Wait until all channel transfers are completed */
msleep(1);
}
} while (!alldone);
kfree(disabled);/* remove the else if there's a static etc */
} else {
for (i = 0; i < PCH_MAX_CHN; i++) {
while ((adap_info->pch_data[i].pch_xfer_in_progress)) {
/* Wait until all channel transfers are completed */
msleep(1);
}
/* Disable the i2c interrupts */
pch_disbl_int(&adap_info->pch_data[i]);
}
}cheers, Joe
----- Original Message -----
From: "Joe Perches" <[email protected]>
To: "Masayuki Ohtak" <masa-korg-ECg8zkTtlr0C6LszWs/[email protected]>
Cc: "Jean Delvare (PC drivers, core)" <[email protected]>; "Ben Dooks (embedded platforms)" <[email protected]>;
"Crane Cai" <[email protected]>; "Samuel Ortiz" <sameo-VuQAYsv1563Yd54FQh9/[email protected]>; "Linus Walleij" <linus.walleij-0IS4wlFg1OjSUeElwK9/[email protected]>; "Ralf Baechle" <ralf-6z/[email protected]>; "srinidhi kasagar" <srinidhi.kasagar-0IS4wlFg1OjSUeElwK9/[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>; <arjan-VuQAYsv1563Yd54FQh9/[email protected]>; "Tomoya MORINAGA" <morinaga526-ECg8zkTtlr0C6LszWs/[email protected]>; "Arnd Bergmann" <[email protected]>
Sent: Friday, September 03, 2010 5:10 PM
Subject: Re: [MeeGo-Dev][PATCH] Topcliff: Update PCH_I2C driver to 2.6.35
Quoted 54 lines · Masayuki Ohtak
[]
drivers/i2c/busses/i2c-pch.c line 133
Quoted 10 lines
drivers/i2c/busses/i2c-pch.c new file +10
-0+#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_pci_err(pdev, fmt, arg...) \ + dev_err(&pdev->dev, "%s :"fmt, __func__, ##arg) +#define pch_pci_dbg(pdev, fmt, arg...) \ + dev_dbg(&pdev->dev, "%s :"fmt, __func__, ##arg)OK, but it seems careless because the two types are not uniformly indented, there's a blank line between
pch_dbgandpch_err, and the two pch_pci_<level> defines are in the reverse order without a blank line between them.I think it's better to use separate multiple strings that are concatentated by the preprocessor like:
"%s :" fmt
not
"%s :"fmtAlmost all code in kernel uses "%s: " to format
__func__. Some use "%s(): ". I think "%s :" is unique.The rest of the logging messages look good.
Some other comments:
Quoted 2 lines
+ if ((
pch_wait_for_xfer_complete(adap)== 0) &&
+ (pch_getack(adap)== 0)) {This would look better as:
if ((
pch_wait_for_xfer_complete(adap)== 0) &&(pch_getack(adap) == 0)) {Quoted 2 lines
+ if ((
pch_wait_for_xfer_complete(adap)== 0)
+ && (pch_getack(adap)== 0)) {Here too.
Quoted 8 lines
+ for (i = 0; i <
PCH_MAX_CHN; i++) {
+ while ((adap_info->pch_data[i].pch_xfer_in_progress)) {
+ /* Wait until all channel transfers are completed */
+ msleep(1);
+ }
+ /* Disable the i2c interrupts */
+pch_disbl_int(&adap_info->pch_data[i]);
+ }
Quoted 2 lines
Would it be better to disable all possible interrupts first or do you need to disable them in order?
* Your proposal
If pch_disbl_int is executed firstly,
queued data is destroyed.
* Current spec
If checking status firstly,
all data can be sent.
Thus, I think current spec is better than yours.
Quoted 41 lines
Something like:
bool *disabled =
kzalloc(PCH_MAX_CHN * sizeof(bool), GFP_KERNEL); /*
* or a static with a memset, or check something
* likepch_is_int_enabled(&adap_info->pch_data[i])
* then remove the else because the kzalloc couldn't fail. */
if (disabled) {
bool alldone;
do {
alldone = true;
for (i = 0; i <PCH_MAX_CHN; i++) {
if (!adap_info->pch_data[i].pch_xfer_in_progress &&!disabled[i])) {
pch_disbl_int(&adap_info->pch_data[i]); disabled[i] = true;
} else
alldone = false;
}
if (!alldone) {
/* Wait until all channel transfers are completed */ msleep(1);
}
} while (!alldone);
kfree(disabled);/* remove the else if there's a static etc */
} else {
for (i = 0; i <PCH_MAX_CHN; i++) {
while ((adap_info->pch_data[i].pch_xfer_in_progress)) { /* Wait until all channel transfers are completed */ msleep(1);
}
/* Disable the i2c interrupts */pch_disbl_int(&adap_info->pch_data[i]);
}
}
Quoted 2 lines
cheers, Joe
I will resubmit modified patch soon.
Thanks, Ohtake(OKISemi)