I2C bus driver for Philips ARM boards
PATCH 1/1 I2C bus driver for Philips ARM boards
Please find below the I2C bus driver for Philips ARM boards (Philips IP3204 I2C IP block). This I2C controller can be found on PNX010x, PNX52xx and PNX4008 Philips boards. Any comments are welcome.
arch/arm/mach-pnx4008/Makefile | 2 arch/arm/mach-pnx4008/i2c.c | 190 +++++++++ drivers/i2c/busses/Kconfig | 10 drivers/i2c/busses/Makefile | 2 drivers/i2c/busses/i2c-pnx.c | 710 +++++++++++++++++++++++++++++++++++++ include/asm-arm/arch-pnx4008/i2c.h | 86 ++++ include/linux/i2c-pnx.h | 52 ++ 7 files changed, 1051 insertions(+), 1 deletion(-)
drivers/i2c/busses/Kconfig +10 -0
@@ -517,4 +517,14 @@ config I2C_MV64XXX This driver can also be built as a module. If so, the module will be called i2c-mv64xxx. +config I2C_PNX + tristate "I2C bus support for Philips PNX targets" + depends on ARCH_PNX4008 && I2C + help + This driver supports the Philips IP3204 I2C IP block master and/or + slave controller + + This driver can also be built as a module. If so, the module + will be called i2c-pnx. + endmenu
drivers/i2c/busses/Makefile +2 -0
@@ -42,6 +42,8 @@ obj-$(CONFIG_I2C_VIAPRO) += i2c-viapro.o obj-$(CONFIG_I2C_VOODOO3) += i2c-voodoo3.o obj-$(CONFIG_SCx200_ACB) += scx200_acb.o obj-$(CONFIG_SCx200_I2C) += scx200_i2c.o +obj-$(CONFIG_I2C_PNX) += i2c-pnx.o + ifeq ($(CONFIG_I2C_DEBUG_BUS),y) EXTRA_CFLAGS += -DDEBUG
drivers/i2c/busses/i2c-pnx.c new file +710 -0
710 lines not on this page · raw message
include/asm-arm/arch-pnx4008/i2c.h new file +86 -0
86 lines not on this page · raw message
include/linux/i2c-pnx.h new file +52 -0
52 lines not on this page · raw message
arch/arm/mach-pnx4008/Makefile +1 -1
@@ -2,7 +2,7 @@ # Makefile for the linux kernel. # -obj-y := core.o irq.o time.o clock.o gpio.o serial.o dma.o +obj-y := core.o irq.o time.o clock.o gpio.o serial.o dma.o i2c.o obj-m := obj-n := obj- :=
arch/arm/mach-pnx4008/i2c.c new file +190 -0
190 lines not on this page · raw message
Quoted 101 lines · Vitaly Wool
Please find below the I2C bus driver for Philips ARM boards (Philips IP3204 I2C IP block). This I2C controller can be found on PNX010x, PNX52xx and PNX4008 Philips boards. Any comments are welcome.
arch/arm/mach-pnx4008/Makefile | 2 arch/arm/mach-pnx4008/i2c.c | 190 +++++++++ drivers/i2c/busses/Kconfig | 10 drivers/i2c/busses/Makefile | 2 drivers/i2c/busses/i2c-pnx.c | 710 +++++++++++++++++++++++++++++++++++++ include/asm-arm/arch-pnx4008/i2c.h | 86 ++++ include/linux/i2c-pnx.h | 52 ++ 7 files changed, 1051 insertions(+), 1 deletion(-)Signed-off-by Vitaly Wool <[email protected]>Index: linux-2.6.git/drivers/i2c/busses/Kconfig
===================================================================drivers/i2c/busses/Kconfig +10
-0@@ -517,4 +517,14 @@ config I2C_MV64XXX This driver can also be built as a module. If so, the module will be called i2c-mv64xxx. +config I2C_PNX + tristate "I2C bus support for Philips PNX targets" + depends on ARCH_PNX4008 && I2C + help + This driver supports the Philips IP3204 I2C IP block master and/or + slave controller + + This driver can also be built as a module. If so, the module + will be called i2c-pnx. + endmenuIndex: linux-2.6.git/drivers/i2c/busses/Makefile
===================================================================drivers/i2c/busses/Makefile +2
-0@@ -42,6 +42,8 @@ obj-$(CONFIG_I2C_VIAPRO) += i2c-viapro.o obj-$(CONFIG_I2C_VOODOO3) += i2c-voodoo3.o obj-$(CONFIG_SCx200_ACB) += scx200_acb.o obj-$(CONFIG_SCx200_I2C) += scx200_i2c.o +obj-$(CONFIG_I2C_PNX) += i2c-pnx.o + ifeq ($(CONFIG_I2C_DEBUG_BUS),y) EXTRA_CFLAGS += -DDEBUGIndex:
linux-2.6.git/drivers/i2c/busses/i2c-pnx.c
===================================================================drivers/i2c/busses/i2c-pnx.c new file +50
-0@@ -0,0 +1,710 @@ +/* +* drivers/i2c/i2c-pnx.c +* +* Provides i2c support for PNX010x/PNX4008. +* +* Authors: Dennis Kovalev <[email protected]> +* Vitaly Wool <[email protected]> +* +* 2004-2006 (c) MontaVista Software, Inc. This file is licensed under +* the terms of the GNU General Public License version 2. This program +* is licensed "as is" without any warranty of any kind, whether express +* or implied. +*/ + +#include <linux/module.h> +#include <linux/config.h> +#include <linux/interrupt.h> +#include <linux/version.h> +#include <linux/kernel.h> +#include <linux/ioport.h> +#include <linux/pci.h> +#include <linux/types.h> +#include <linux/delay.h> +#include <linux/i2c.h> +#include <linux/fs.h> +#include <linux/init.h> +#include <linux/mm.h> +#include <linux/miscdevice.h> +#include <linux/timer.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/completion.h> +#include <linux/platform_device.h> +#include <asm/hardware.h> +#include <asm/irq.h> +#include <asm/uaccess.h> +#include <linux/i2c-pnx.h> +#include <asm/arch/i2c.h> + +struct pnx_i2c { +int (*suspend) (struct platform_device * pdev,pm_message_t state); +int (*resume) (struct platform_device * pdev); +u32 (*calculate_input_freq) (struct platform_device * pdev); +int (*set_clock_run) (struct platform_device * pdev); +int (*set_clock_stop) (struct platform_device * pdev); +struct i2c_adapter *adapter; +}; + +char *i2c_pnx_modestr[] = { +"Transmit" ,
drivers/i2c/busses/i2c-pnx.c line 60
Quoted 10 lines
drivers/i2c/busses/i2c-pnx.c new file +10
-0+"Receive" , + "No Data", +}; + +static inline void i2c_pnx_arm_timer (struct timer_list *timer,void *data) +{ +del_timer_sync (timer); + +pr_debug ("%s: Timer armed at %lu plus %u jiffies.\n" , + __FUNCTION__, jiffies,TIMEOUT );
how about using the dev_dbg() macros?
Quoted 213 lines
drivers/i2c/busses/i2c-pnx.c new file +143
-0+ timer->expires = jiffies +TIMEOUT ; + timer->data = (unsigned long )data; + +add_timer (timer); +} +static void i2c_pnx_stop (struct i2c_pnx_algo_data *alg_data) +{ +int cnt =10000 ; + +pr_debug ("%s: %s() enter - stat = %04x.\n" , + __FILE__, __FUNCTION__, alg_data->master->sts); + +/* Write a STOP bit to TX FIFO */ + alg_data->master->fifo.tx =0x000000ff | stop_bit; + +/* Wait until the STOP is seen. */ +while (alg_data->master->sts & mstatus_active && cnt--); + +pr_debug ("%s: %s() exit - stat = %04x.\n" , + __FILE__, __FUNCTION__, alg_data->master->sts); +} + +/** +* i2c_pnx_master_xmit - transmit data to slave +* @alg_data: pointer to I2C-PNX algorithm data structure +* +* Sends one byte of data to the slave +*/ + +/* Register I/O resource */ +if (!request_region (alg_data->base,I2C_BLOCK_SIZE ,"i2c-pnx" )) { +printk (KERN_ERR +"I/O region 0x%08x for I2C already in use.\n" , + alg_data->base); + ret = -ENODEV ; + goto out0; + } + + i2c_pnx->set_clock_run (pdev); + +/* Clock Divisor High This value is the number of system clocks +* the serial clock (SCL) will be high. n is defined at compile +* time based on the system clock (PCLK) and minimum serial frequency. +* For example, if the system clock period is 50 ns and the maximum +* desired serial period is 10000 ns (100 kHz), then CLKHI would be +* set to 0.5*(f_sys/f_i2c)-2=0.5*(20e6/100e3)-2=98. The actual value +* programmed into CLKHI will vary from this slightly due to +* variations in the output pad s rise and fall times as well as +* the deglitching filter length. In this example, n = 7, since +* eight bits are needed to hold the clock divider count. +*/ + + tmp = ((freq_mhz *1000 ) /I2C_PNX_SPEED_KHZ ) /2 -2 ; + alg_data->master->ckh = tmp; + alg_data->master->ckl = tmp; + alg_data->master->ctl =0 ; + + alg_data->master->ctl |= mcntrl_reset; +while ((alg_data->master->ctl & mcntrl_reset) && cnt--) ; +if (!cnt) { + ret = -ENODEV ; + goto out1; + } +init_completion (&alg_data->mif.complete); + + ret =request_irq (alg_data->irq, i2c_pnx_interrupt, +0 ,CHIP_NAME , alg_data); +if (ret) + goto out2; + +/* Register this adapter with the I2C subsystem */ + i2c_pnx->adapter->dev.parent = &pdev->dev; + ret =i2c_add_adapter (i2c_pnx->adapter); +if (ret <0 ) { +printk (KERN_INFO "I2C: Failed to add bus\n" ); + goto out3; + } + +printk (KERN_INFO "%s: Master at %#8x, irq %d.\n" , + i2c_pnx->adapter->name, alg_data->base, alg_data->irq); + +return 0 ; + + out3: +free_irq (alg_data->irq, alg_data); + out2: + i2c_pnx->set_clock_stop (pdev); + out1: +release_region (alg_data->base,I2C_BLOCK_SIZE ); + out0: +kfree (i2c_pnx); + out: +return ret; +} + +static int i2c_pnx_remove (struct platform_device *pdev) +{ +struct pnx_i2c *i2c_pnx =platform_get_drvdata (pdev); +struct i2c_adapter *adap = i2c_pnx->adapter; +struct i2c_pnx_algo_data *alg_data = + (struct i2c_pnx_algo_data *)adap->algo_data; +int cnt =10000 ; + +/* Reset the I2C controller. The reset bit is self clearing. */ + alg_data->master->ctl |= mcntrl_reset; +while ((alg_data->master->ctl & mcntrl_reset) && cnt--) ; + +free_irq (alg_data->irq, alg_data); +i2c_del_adapter (adap); + i2c_pnx->set_clock_stop (pdev); +release_region (alg_data->base,I2C_BLOCK_SIZE ); +kfree (i2c_pnx); +platform_set_drvdata (pdev,NULL ); + +return 0 ; +} + +static struct platform_driver i2c_pnx_driver = { + .driver = { + .name ="pnx-i2c" , + }, + .probe = i2c_pnx_probe, + .remove = i2c_pnx_remove, + .suspend = i2c_pnx_controller_suspend, + .resume = i2c_pnx_controller_resume, +}; + +static int __init i2c_adap_pnx_init (void ) +{ +return platform_driver_register (&i2c_pnx_driver); +} + +static void i2c_adap_pnx_exit (void ) +{ +return platform_driver_unregister (&i2c_pnx_driver); +} + +MODULE_AUTHOR ("Dennis Kovalev <[email protected]>" ); +MODULE_DESCRIPTION ("I2C driver for PNX bus" ); +MODULE_LICENSE ("GPL" ); + +subsys_initcall (i2c_adap_pnx_init); +module_exit (i2c_adap_pnx_exit);Index:
linux-2.6.git/include/asm-arm/arch-pnx4008/i2c.h
===================================================================include/asm-arm/arch-pnx4008/i2c.h new file +62
-0@@ -0,0 +1,86 @@ +/* +* include/asm-arm/arch-pnx4008/i2c.h +* +* Author: Vitaly Wool <[email protected]> +* +* PNX4008-specific tweaks for I2C IP3204 block +* +* 2005 (c) MontaVista Software, Inc. This file is licensed under +* the terms of the GNU General Public License version 2. This program +* is licensed "as is" without any warranty of any kind, whether express +* or implied. +*/ + +#ifndef __ASM_ARCH_I2C_H__ +#define __ASM_ARCH_I2C_H__ + +#include <linux/i2c.h> +#include <linux/i2c-pnx.h> +#include <linux/platform_device.h> +#include <asm/irq.h> + +enum { + mstatus_tdi = 0x00000001, + mstatus_afi = 0x00000002, + mstatus_nai = 0x00000004, + mstatus_drmi = 0x00000008, + mstatus_active = 0x00000020, + mstatus_scl = 0x00000040, + mstatus_sda = 0x00000080, + mstatus_rff = 0x00000100, + mstatus_rfe = 0x00000200, + mstatus_tff = 0x00000400, + mstatus_tfe = 0x00000800, +}; + +enum { + mcntrl_tdie = 0x00000001, + mcntrl_afie = 0x00000002, + mcntrl_naie = 0x00000004, + mcntrl_drmie = 0x00000008, + mcntrl_daie = 0x00000020, + mcntrl_rffie = 0x00000040, + mcntrl_tffie = 0x00000080, + mcntrl_reset = 0x00000100, + mcntrl_cdbmode = 0x00000400, +}; + +enum { + rw_bit = 1 << 0, + start_bit = 1 << 8, + stop_bit = 1 << 9, +}; + +struct i2c_regs { + /* LSB */ + union { + const u32 rx; /* Receive FIFO Register - Read Only */ + u32 tx; /* Transmit FIFO Register - Write Only */ + } fifo; + u32 sts; /* Status Register - Read Only */ + u32 ctl; /* Control Register - Read/Write */ + u32 ckl; /* Clock divider low - Read/Write */
include/asm-arm/arch-pnx4008/i2c.h line 72
Quoted 10 lines
include/asm-arm/arch-pnx4008/i2c.h new file +10
-0+u32 ckh;/* Clock divider high - Read/Write */ +u32 adr;/* I2C address (optional) - Read/Write */ +const u32 rfl;/* Rx FIFO level (optional) - Read Only */ +const u32 _unused;/* Tx FIFO level (optional) - Read Only */ +const u32 rxb;/* Number of bytes received (opt.) - Read Only */ +const u32 txb;/* Number of bytes transmitted (opt.) - Read Only */ +u32 txs;/* Tx Slave FIFO register - Write Only */ +const u32 stfl;/* Tx Slave FIFO level - Read Only */ +/* MSB */ +};
ARGH, using structs to represent register sets is not good practice, and worse, you've marked items in there const, so god knows wether the compiler is going to cache results in the cpu registers.
Quoted 107 lines
include/asm-arm/arch-pnx4008/i2c.h new file +13
-0+#define HCLK_MHZ 13 +#define TIMEOUT (2*(HZ)) + +struct i2c_pnx_platform_data { +int (*suspend) (struct platform_device * pdev,pm_message_t state); +int (*resume) (struct platform_device * pdev); +u32 (*calculate_input_freq) (struct platform_device * pdev); +int (*set_clock_run) (struct platform_device * pdev); +int (*set_clock_stop) (struct platform_device * pdev); +struct i2c_adapter *adapter; +}; + +#endif /* __ASM_ARCH_I2C_H___ */ Index:
linux-2.6.git/include/linux/i2c-pnx.h
===================================================================include/linux/i2c-pnx.h new file +52
-0@@ -0,0 +1,52 @@ +/* +* include/linux/i2c-pnx.h +* +* Header file for i2c support for PNX010x/4008. +* +* Author: Dennis Kovalev <[email protected]> +* +* 2004 (c) MontaVista Software, Inc. This file is licensed under +* the terms of the GNU General Public License version 2. This program +* is licensed "as is" without any warranty of any kind, whether express +* or implied. +*/ + +#ifndef _I2C_PNX_H +#define _I2C_PNX_H + +typedef enum { + xmit, + rcv, + nodata, +}i2c_pnx_mode_t ; + +#define I2C_BUFFER_SIZE 0x100 + +struct i2c_pnx_mif { +int ret;/* Return value */ +i2c_pnx_mode_t mode;/* Interface mode */ +struct semaphore sem;/* Mutex for this interface */ +struct completion complete;/* I/O completion */ +struct timer_list timer;/* Timeout */ +char * buf;/* Data buffer */ +int len;/* Length of data buffer */ +}; + +struct i2c_pnx_algo_data { +u32 base; +int irq; +int clock_id; +volatile struct i2c_regs * master; +char buffer [I2C_BUFFER_SIZE ];/* contains data received from I2C bus */ +int buf_index;/* index within I2C buffer (see above) */ +struct i2c_pnx_mif mif; +}; + +#include <asm/arch/platform.h> + +#define TIMEOUT (2*(HZ)) +#define I2C_PNX_SPEED_KHZ 100 +#define I2C_BLOCK_SIZE 0x100 +#define CHIP_NAME "PNX-I2C" + +#endif Index: linux-2.6.git/arch/arm/mach-pnx4008/Makefile
===================================================================arch/arm/mach-pnx4008/Makefile +1
-1@@ -2,7 +2,7 @@ # Makefile for the linux kernel. # -obj-y := core.o irq.o time.o clock.o gpio.o serial.o dma.o +obj-y := core.o irq.o time.o clock.o gpio.o serial.o dma.o i2c.o obj-m := obj-n := obj- :=Index:
linux-2.6.git/arch/arm/mach-pnx4008/i2c.c
===================================================================arch/arm/mach-pnx4008/i2c.c new file +19
-0@@ -0,0 +1,190 @@ +/* +* arch/arm/mach-pnx4008/i2c.c +* +* I2C initialization for PNX4008. +* +* Author: Vitaly Wool <[email protected]> +* +* 2005-2006 (c) MontaVista Software, Inc. This file is licensed under +* the terms of the GNU General Public License version 2. This program +* is licensed "as is" without any warranty of any kind, whether express +* or implied. +*/ + +#include <asm/arch/platform.h> +#include <asm/arch/i2c.h> +#include <linux/clk.h> +#include <linux/config.h> +#include <linux/platform_device.h> +#include <linux/err.h>
arch/arm/mach-pnx4008/i2c.c line 29
Quoted 10 lines
arch/arm/mach-pnx4008/i2c.c new file +10
-0+ +static inline int i2c_pnx_suspend (struct platform_device *pdev, +pm_message_t state) +{ +int retval =0 ; +#ifdef CONFIG_PM +struct clk *clk; +char name[10 ]; + +sprintf (name,"i2c%d_ck" , pdev->id);
abuse of the clock system, you should pass the device as the first argument, so the clk_get() implementor can differentiate between different device's clocks of the same name!
ie:
clk_get(&pdev->dev, "i2c");
Quoted 9 lines
arch/arm/mach-pnx4008/i2c.c new file +9
-0+ clk =clk_get (0 , name); +if (!IS_ERR (clk)) { +clk_set_rate (clk,0 ); +clk_put (clk); + }else + retval = -ENOENT ; +#endif +return retval; +}
arch/arm/mach-pnx4008/i2c.c line 48
Quoted 10 lines
arch/arm/mach-pnx4008/i2c.c new file +10
-0+ +static inline int i2c_pnx_resume (struct platform_device *pdev) +{ +int retval =0 ; +#ifdef CONFIG_PM +struct clk *clk; +char name[10 ]; + +sprintf (name,"i2c%d_ck" , pdev->id); + clk =clk_get (0 , name);
why not keep the struct clk with your adapter? this seems to get re-used in several places, so keep the struct clk * since you've got an implicit ref-lock on it by calling clk_get() it isn't going anywhere!
arch/arm/mach-pnx4008/i2c.c line 57
Quoted 9 lines
arch/arm/mach-pnx4008/i2c.c new file +9
-0+if (!IS_ERR (clk)) { +clk_set_rate (clk,1 ); +clk_put (clk); + }else + retval = -ENOENT ; +#endif +return retval; +} +
These could have easily gone into the main driver, any reason for keeping them seperate?
Signature · 4 lines
Ben Q: What's a light-year? A: One-third less calories than a regular year.
Quoted 4 lines · On Thu, 22 Jun 2006 12:45:06 +0100 Ben Dooks <[email protected]> wrote:
drivers/i2c/busses/i2c-pnx.c line 60
Quoted 3 lines
drivers/i2c/busses/i2c-pnx.c new file +3
-0+ +pr_debug ("%s: Timer armed at %lu plus %u jiffies.\n" , + __FUNCTION__, jiffies,TIMEOUT );how about using the
dev_dbg()macros?
Okay.
Quoted 16 lines
Quoted 16 lines
include/asm-arm/arch-pnx4008/i2c.h new file +16
-0+struct i2c_regs { +/* LSB */ +union { +const u32 rx;/* Receive FIFO Register - Read Only */ +u32 tx;/* Transmit FIFO Register - Write Only */ + } fifo; +u32 sts;/* Status Register - Read Only */ +u32 ctl;/* Control Register - Read/Write */ +u32 ckl;/* Clock divider low - Read/Write */ +u32 ckh;/* Clock divider high - Read/Write */ +u32 adr;/* I2C address (optional) - Read/Write */ +const u32 rfl;/* Rx FIFO level (optional) - Read Only */ +const u32 _unused;/* Tx FIFO level (optional) - Read Only */ +const u32 rxb;/* Number of bytes received (opt.) - Read Only */ +const u32 txb;/* Number of bytes transmitted (opt.) - Read Only */ +u32 txs;/* Tx Slave FIFO register - Write Only */
Quoted 8 lines
include/asm-arm/arch-pnx4008/i2c.h line 72
Quoted 3 lines
include/asm-arm/arch-pnx4008/i2c.h new file +3
-0+const u32 stfl;/* Tx Slave FIFO level - Read Only */ +/* MSB */ +};ARGH, using structs to represent register sets is not good practice, and worse, you've marked items in there const, so god knows wether the compiler is going to cache results in the cpu registers.
The structure is used as volatile throughout.
I personally didn't ever like to use structures for registers, but this is actually an old driver written first at the time ARM compilers produced more optimal code when the registers were accessed through structures.
Quoted 8 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ sprintf(name, "i2c%d_ck", pdev->id);abuse of the clock system, you should pass the device as the first argument, so the
clk_get()implementor can differentiate between different device's clocks of the same name!ie:
clk_get(&pdev->dev, "i2c");
Agreed.
Quoted 8 lines
arch/arm/mach-pnx4008/i2c.c line 30
Quoted 3 lines
arch/arm/mach-pnx4008/i2c.c new file +3
-0+ +sprintf (name,"i2c%d_ck" , pdev->id); + clk =clk_get (0 , name);why not keep the struct clk with your adapter? this seems to get re-used in several places, so keep the
struct clk *since you've got an implicit ref-lock on it by callingclk_get()it isn't going anywhere!
The reason behind that is that the other target which has this bus has absolutely different clock layout so it's hard to combine those. Therefore clock stuff was pus into arch-specific part.
Quoted 4 lines
Quoted 4 lines
arch/arm/mach-pnx4008/i2c.c new file +4
-0+if (!IS_ERR (clk)) { +clk_set_rate (clk,1 ); +clk_put (clk); + }else
Quoted 8 lines
arch/arm/mach-pnx4008/i2c.c line 39
Quoted 5 lines
arch/arm/mach-pnx4008/i2c.c new file +5
-0+ retval = -ENOENT ; +#endif +return retval; +} +These could have easily gone into the main driver, any reason for keeping them seperate?
Well, the reason is the same as mentioned above.
Vitaly
drivers/i2c/busses/i2c-pnx.c line 73
Quoted 6 lines · Vitaly Wool
drivers/i2c/busses/i2c-pnx.c new file +6
-0+static inline int i2c_pnx_bus_busy (volatile struct i2c_regs *master) +{ +long timeout; + + timeout =TIMEOUT *10000 ; +if (timeout >0 && (master->sts & mstatus_active)) {
Please use the proper ioread() function to read from memory, and don't rely on a memory mapped structure. Linux does this in order to work for all platforms.
A big hint about this, if you have volatile in your driver, it's wrong...
thanks,
greg k-h
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 13 lines · Vitaly Wool
Quoted 10 lines · Greg KH
drivers/i2c/busses/i2c-pnx.c line 73
Quoted 7 lines
drivers/i2c/busses/i2c-pnx.c new file +6
-0+static inline int i2c_pnx_bus_busy (volatile struct i2c_regs *master) +{ +long timeout; + + timeout =TIMEOUT *10000 ; +if (timeout >0 && (master->sts & mstatus_active)) {A big hint about this, if you have volatile in your driver, it's wrong...
Quoted 5 lines
Well, I do remember flames on the subject... Still
__raw_readlalso uses volatile.
Anyway, I can't disagree that ioreadX-based register access are better. Greg, is there anything else I should take care of before re-sending the patch, except for the things that you and Ben pointed out?
Not that I can think of, that would be a good starting point :)
thanks,
greg k-h
Quoted 14 lines · --- Greg KH
Quoted 13 lines · Vitaly Wool
Quoted 10 lines · Greg KH
drivers/i2c/busses/i2c-pnx.c line 73
Quoted 7 lines
drivers/i2c/busses/i2c-pnx.c new file +6
-0+static inline int i2c_pnx_bus_busy (volatile struct i2c_regs *master) +{ +long timeout; + + timeout =TIMEOUT *10000 ; +if (timeout >0 && (master->sts & mstatus_active)) {A big hint about this, if you have volatile in your driver, it's wrong...
Quoted 7 lines
Quoted 5 lines
Well, I do remember flames on the subject... Still
__raw_readlalso uses volatile.
Anyway, I can't disagree that ioreadX-based register access are better. Greg, is there anything else I should take care of before re-sending the patch, except for the things that you and Ben pointed out?Not that I can think of, that would be a good starting point :)
Would it not make sense to call this driver ip3204 or ph_ip3204 or some such seeing as you correctly point out that this is a common Philips IP block and is used in other, non pnx, chips?
I'm also not sure why the register map is in the arch-pnx4008 directory as this will require every chip that has this IP block to have a copy of the file.
Mark
Quoted 10 lines
thanks,
greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
___________________________________________________________
Win tickets to the 2006 FIFA World Cup Germany with Yahoo! Messenger. http://advision.webevents.yahoo.com/fifaworldcup_uk/
Quoted 2 lines · On Thu, 22 Jun 2006 23:26:00 +0100 (BST) Mark Underwood <[email protected]>…
Would it not make sense to call this driver ip3204 or
ph_ip3204or some such seeing as you correctly point out that this is a common Philips IP block and is used in other, non pnx, chips?
No I don't think it would -- this is an internal Philips IP block number AFAIK and was given there only for reference.
Funny is that people from Philips Semi asked me about a year ago not to use internal IP block numbers in the code. I know you're also from Philips... Well, what does that prove? It proves that everything can't be in alignment in such a big company. ;-)
Quoted 2 lines
I'm also not sure why the register map is in the arch-pnx4008 directory as this will require every chip that has this IP block to have a copy of the file.
IIRC, PNX5220 has a slightly different register map. Of course the main registers are the same but putting first N regs into common header and putting others into arch header would have made even less sense.
Vitaly
Quoted 5 lines · --- Vitaly Wool
Quoted 2 lines · On Thu, 22 Jun 2006 23:26:00 +0100 (BST) Mark Underwood <[email protected]>…
Would it not make sense to call this driver ip3204 or
ph_ip3204or some such seeing as you correctly point out that this is a common Philips IP block and is used in other, non pnx,
Quoted 7 lines
chips?
No I don't think it would -- this is an internal Philips IP block number AFAIK and was given there only for reference.
Funny is that people from Philips Semi asked me about a year ago not to use internal IP block numbers in the code. I know you're also from Philips... Well, what does that prove? It proves that everything can't be in alignment in such a big company. ;-)
OK.
Quoted 8 lines
Quoted 2 lines
I'm also not sure why the register map is in the arch-pnx4008 directory as this will require
every
Quoted 1 line
chip that has this IP block to have a copy of the file.
IIRC, PNX5220 has a slightly different register map. Of course the main registers are the same but putting first N regs into common header and putting others into arch header would have made even less sense.
I'm not familiar with the PNX5220. What you've done makes sense now :-). Thanks for the explanation.
Mark
Quoted 8 lines
Vitaly
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
___________________________________________________________
Does your mail provider give you FREE antivirus protection? Get Yahoo! Mail http://uk.mail.yahoo.com