Marvell mv64xxx i2c driver
PATCH 1/1 Marvell mv64xxx i2c driver
Marvell makes a line of host bridge for PPC and MIPS systems. On those bridges is an i2c controller. This patch adds the driver for that i2c controller.
Please apply.
Depends on patch submitted by Jean Delvare: http://archives.andrew.net.au/lm-sensors/msg29405.html
[Note: This patch is a *replacement* patch]
--
drivers/i2c/busses/Kconfig +10 -0
@@ -486,4 +486,14 @@ This driver can also be built as a module. If so, the module will be called i2c-pca-isa. +config I2C_MV64XXX + tristate "Marvell mv64xxx I2C Controller" + depends on I2C && MV64X60 && EXPERIMENTAL + help + If you say yes to this option, support will be included for the + built-in I2C interface on the Marvell 64xxx line of host bridges. + + This driver can also be built as a module. If so, the module + will be called i2c-mv64xxx. + endmenu
drivers/i2c/busses/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_I2C_IXP4XX) += i2c-ixp4xx.o obj-$(CONFIG_I2C_KEYWEST) += i2c-keywest.o obj-$(CONFIG_I2C_MPC) += i2c-mpc.o +obj-$(CONFIG_I2C_MV64XXX) += i2c-mv64xxx.o obj-$(CONFIG_I2C_NFORCE2) += i2c-nforce2.o obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o
drivers/i2c/busses/i2c-mv64xxx.c new file +606 -0
606 lines not on this page · raw message
include/linux/i2c-id.h +3 -0
@@ -311,4 +311,7 @@/* --- MCP107 adapter */ #define I2C_HW_MPC107 0x00 +/* --- Marvell mv64xxx i2c adapter */ +#define I2C_HW_MV64XXX 0x00 +#endif /* LINUX_I2C_ID_H */
include/linux/mv643xx.h +11 -6
@@ -977,12 +977,9 @@/* I2C Registers */ /****************************************/ -#define MV64340_I2C_SLAVE_ADDR 0xc000 -#define MV64340_I2C_EXTENDED_SLAVE_ADDR 0xc010 -#define MV64340_I2C_DATA 0xc004 -#define MV64340_I2C_CONTROL 0xc008 -#define MV64340_I2C_STATUS_BAUDE_RATE 0xc00C -#define MV64340_I2C_SOFT_RESET 0xc01c +#define MV64XXX_I2C_CTLR_NAME "mv64xxx i2c" +#define MV64XXX_I2C_OFFSET 0xc000 +#define MV64XXX_I2C_REG_BLOCK_SIZE 0x0020/****************************************/ /* GPP Interface Registers */
@@ -1083,6 +1080,14 @@u8 brg_can_tune;u8 brg_clk_src; u32 brg_clk_freq; +}; + +/* i2c Platform Device, Driver Data */ +struct mv64xxx_i2c_pdata { +u32 freq_m; +u32 freq_n; +u32 timeout;/* In milliseconds */ +u32 retries; };#endif /* __ASM_MV64340_H */
Hi,
just a minor thing
drivers/i2c/busses/i2c-mv64xxx.c line 592
Quoted 5 lines
drivers/i2c/busses/i2c-mv64xxx.c new file +5
-0+static int __devinit +mv64xxx_i2c_init (void ) +{ +return driver_register (&mv64xxx_i2c_driver); +}
__init
drivers/i2c/busses/i2c-mv64xxx.c line 599
Quoted 6 lines
drivers/i2c/busses/i2c-mv64xxx.c new file +6
-0+static void __devexit +mv64xxx_i2c_exit (void ) +{ +driver_unregister (&mv64xxx_i2c_driver); +return ; +}
__exit
these functions relate to module not device
Quoted 2 lines
drivers/i2c/busses/i2c-mv64xxx.c new file +2
-0+module_init (mv64xxx_i2c_init); +module_exit (mv64xxx_i2c_exit);
Quoted 29 lines · Bartlomiej Zolnierkiewicz
Hi,
just a minor thing
Review
Quoted 7 lines
(quoted diff) +5
-0+static int __devinit +mv64xxx_i2c_init(void) +{ + return driver_register(&mv64xxx_i2c_driver); +}
__initReview
Quoted 8 lines
(quoted diff) +6
-0+static void __devexit +mv64xxx_i2c_exit(void) +{ + driver_unregister(&mv64xxx_i2c_driver); + return; +}
__exit
Quoted 2 lines
these functions relate to module not device
Gahhh. Thanks Bartlomiej.
Below is yet another replacement patch
--
Marvell makes a line of host bridge for PPC and MIPS systems. On those bridges is an i2c controller. This patch adds the driver for that i2c controller.
Please apply.
Depends on patch submitted by Jean Delvare: http://archives.andrew.net.au/lm-sensors/msg29405.html
--
drivers/i2c/busses/Kconfig +10 -0
@@ -486,4 +486,14 @@ This driver can also be built as a module. If so, the module will be called i2c-pca-isa. +config I2C_MV64XXX + tristate "Marvell mv64xxx I2C Controller" + depends on I2C && MV64X60 && EXPERIMENTAL + help + If you say yes to this option, support will be included for the + built-in I2C interface on the Marvell 64xxx line of host bridges. + + This driver can also be built as a module. If so, the module + will be called i2c-mv64xxx. + endmenu
drivers/i2c/busses/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_I2C_IXP4XX) += i2c-ixp4xx.o obj-$(CONFIG_I2C_KEYWEST) += i2c-keywest.o obj-$(CONFIG_I2C_MPC) += i2c-mpc.o +obj-$(CONFIG_I2C_MV64XXX) += i2c-mv64xxx.o obj-$(CONFIG_I2C_NFORCE2) += i2c-nforce2.o obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o
drivers/i2c/busses/i2c-mv64xxx.c new file +606 -0
606 lines not on this page · raw message
include/linux/i2c-id.h +3 -0
@@ -311,4 +311,7 @@/* --- MCP107 adapter */ #define I2C_HW_MPC107 0x00 +/* --- Marvell mv64xxx i2c adapter */ +#define I2C_HW_MV64XXX 0x00 +#endif /* LINUX_I2C_ID_H */
include/linux/mv643xx.h +11 -6
@@ -977,12 +977,9 @@/* I2C Registers */ /****************************************/ -#define MV64340_I2C_SLAVE_ADDR 0xc000 -#define MV64340_I2C_EXTENDED_SLAVE_ADDR 0xc010 -#define MV64340_I2C_DATA 0xc004 -#define MV64340_I2C_CONTROL 0xc008 -#define MV64340_I2C_STATUS_BAUDE_RATE 0xc00C -#define MV64340_I2C_SOFT_RESET 0xc01c +#define MV64XXX_I2C_CTLR_NAME "mv64xxx i2c" +#define MV64XXX_I2C_OFFSET 0xc000 +#define MV64XXX_I2C_REG_BLOCK_SIZE 0x0020/****************************************/ /* GPP Interface Registers */
@@ -1083,6 +1080,14 @@u8 brg_can_tune;u8 brg_clk_src; u32 brg_clk_freq; +}; + +/* i2c Platform Device, Driver Data */ +struct mv64xxx_i2c_pdata { +u32 freq_m; +u32 freq_n; +u32 timeout;/* In milliseconds */ +u32 retries; };#endif /* __ASM_MV64340_H */
Quoted 31 lines · Mark A. Greer
Quoted 29 lines · Bartlomiej Zolnierkiewicz
Hi,
just a minor thing
drivers/i2c/busses/i2c-mv64xxx.c line 592
Quoted 7 lines
drivers/i2c/busses/i2c-mv64xxx.c new file +5
-0+static int __devinit +mv64xxx_i2c_init (void ) +{ +return driver_register (&mv64xxx_i2c_driver); +}
__initdrivers/i2c/busses/i2c-mv64xxx.c line 599
Quoted 8 lines
drivers/i2c/busses/i2c-mv64xxx.c new file +6
-0+static void __devexit +mv64xxx_i2c_exit (void ) +{ +driver_unregister (&mv64xxx_i2c_driver); +return ; +}
__exit
Quoted 6 lines
Quoted 2 lines
these functions relate to module not device
Gahhh. Thanks Bartlomiej.
Below is yet another replacement patch
Thanks, I see that you did global replacement of __devinit by __init and __devexit by __exit - it seems correct *only* if:
- there can be only one i2c controller in the system
- there can be only one host bridge in the system
- i2c core calls ->probe only once during driver init and ->remove only once during driver exit
If all conditions are really true some comment about this in the code would still be be nice.
While at it more silly, minor nitpicking ;)
drivers/i2c/busses/i2c-mv64xxx.c line 349
Quoted 4 lines
drivers/i2c/busses/i2c-mv64xxx.c new file +4
-0+static void +mv64xxx_i2c_wait_for_completion (struct mv64xxx_i2c_data *drv_data) +{ +long flags, time_left;
'flags' are of 'unsigned long' not 'long' type
Quoted 21 lines
drivers/i2c/busses/i2c-mv64xxx.c new file +21
-0+char abort =0 ; + + time_left =wait_event_interruptible_timeout (drv_data->waitq, + !drv_data->block,msecs_to_jiffies (drv_data->adapter.timeout)); + +spin_lock_irqsave (&drv_data->lock, flags); +if (!time_left) {/* Timed out */ + drv_data->rc = -ETIMEDOUT ; + abort =1 ; + }else if (time_left <0 ) {/* Interrupted/Error */ + drv_data->rc = time_left;/* errno value */ + abort =1 ; + } + +if (abort && drv_data->block) { + drv_data->state =MV64XXX_I2C_STATE_ABORTING ; +spin_unlock_irqrestore (&drv_data->lock, flags); + + time_left =wait_event_timeout (drv_data->waitq, + !drv_data->block, +msecs_to_jiffies (drv_data->adapter.timeout));
drivers/i2c/busses/i2c-mv64xxx.c line 380
Quoted 10 lines
drivers/i2c/busses/i2c-mv64xxx.c new file +10
-0+ +if (time_left <=0 ) { + drv_data->state =MV64XXX_I2C_STATE_IDLE ; +dev_err (&drv_data->adapter.dev, +"mv64xxx: I2C bus locked\n" ); + } + }else +spin_unlock_irqrestore (&drv_data->lock, flags); + +return ;
there is no need for explicit return in void functions
[ These two comments also apply to other code in the driver. ]
Thanks,
Bartlomiej
Quoted 10 lines · Bartlomiej Zolnierkiewicz
Thanks, I see that you did global replacement of
__devinitby__initand__devexitby__exit- it seems correct *only* if:
- there can be only one i2c controller in the system
- there can be only one host bridge in the system
- i2c core calls ->probe only once during driver init and ->remove only once during driver exitIf all conditions are really true some comment about this in the code would still be be nice.
You're right. The 'dev' is back except on the module_init/exit routines.
Quoted 4 lines
While at it more silly, minor nitpicking ;)
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +4
-0+static void +mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data) +{ + long flags, time_left;'flags' are of 'unsigned long' not 'long' type
Fixed.
Quoted 2 lines
there is no need for explicit return in void functions
I can't find any definitive policy on this. I kind of like the explicit return, I don't know why. I've had others make the same comment, though, so I'll remove them since it obviously bothers people.
Attached is a replacement patch.
Thanks again, Bartlomiej.
Mark
--
Marvell makes a line of host bridge for PPC and MIPS systems. On those bridges is an i2c controller. This patch adds the driver for that i2c controller.
Please apply.
Depends on patch submitted by Jean Delvare: http://archives.andrew.net.au/lm-sensors/msg29405.html
drivers/i2c/busses/Kconfig +10 -0
@@ -486,4 +486,14 @@ This driver can also be built as a module. If so, the module will be called i2c-pca-isa. +config I2C_MV64XXX + tristate "Marvell mv64xxx I2C Controller" + depends on I2C && MV64X60 && EXPERIMENTAL + help + If you say yes to this option, support will be included for the + built-in I2C interface on the Marvell 64xxx line of host bridges. + + This driver can also be built as a module. If so, the module + will be called i2c-mv64xxx. + endmenu
drivers/i2c/busses/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_I2C_IXP4XX) += i2c-ixp4xx.o obj-$(CONFIG_I2C_KEYWEST) += i2c-keywest.o obj-$(CONFIG_I2C_MPC) += i2c-mpc.o +obj-$(CONFIG_I2C_MV64XXX) += i2c-mv64xxx.o obj-$(CONFIG_I2C_NFORCE2) += i2c-nforce2.o obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o
drivers/i2c/busses/i2c-mv64xxx.c new file +596 -0
596 lines not on this page · raw message
include/linux/i2c-id.h +3 -0
@@ -311,4 +311,7 @@/* --- MCP107 adapter */ #define I2C_HW_MPC107 0x00 +/* --- Marvell mv64xxx i2c adapter */ +#define I2C_HW_MV64XXX 0x00 +#endif /* LINUX_I2C_ID_H */
include/linux/mv643xx.h +11 -6
@@ -977,12 +977,9 @@/* I2C Registers */ /****************************************/ -#define MV64340_I2C_SLAVE_ADDR 0xc000 -#define MV64340_I2C_EXTENDED_SLAVE_ADDR 0xc010 -#define MV64340_I2C_DATA 0xc004 -#define MV64340_I2C_CONTROL 0xc008 -#define MV64340_I2C_STATUS_BAUDE_RATE 0xc00C -#define MV64340_I2C_SOFT_RESET 0xc01c +#define MV64XXX_I2C_CTLR_NAME "mv64xxx i2c" +#define MV64XXX_I2C_OFFSET 0xc000 +#define MV64XXX_I2C_REG_BLOCK_SIZE 0x0020/****************************************/ /* GPP Interface Registers */
@@ -1083,6 +1080,14 @@u8 brg_can_tune;u8 brg_clk_src; u32 brg_clk_freq; +}; + +/* i2c Platform Device, Driver Data */ +struct mv64xxx_i2c_pdata { +u32 freq_m; +u32 freq_n; +u32 timeout;/* In milliseconds */ +u32 retries; };#endif /* __ASM_MV64340_H */
Greg KH
AppliedQuoted 15 lines · Mark A. Greer
I can't find any definitive policy on this. I kind of like the explicit return, I don't know why. I've had others make the same comment, though, so I'll remove them since it obviously bothers people.
Attached is a replacement patch.
Thanks again, Bartlomiej.
Mark
--
Marvell makes a line of host bridge for PPC and MIPS systems. On those bridges is an i2c controller. This patch adds the driver for that i2c controller.
Quoted 6 lines
Please apply.
Depends on patch submitted by Jean Delvare:
http://archives.andrew.net.au/lm-sensors/msg29405.htmlSigned-off-by Mark A. Greer <[email protected]>
Applied, thanks.
greg k-h