Now it's ok.
patch inline.
======================== CUT HERE =====================
>From 779861bf9c1efdf7eec7da541ce0d2771be6e620 Mon Sep 17 00:00:00 2001
From: Felipe Balbi <[EMAIL PROTECTED]>
Date: Tue, 1 Jan 2008 23:00:18 -0500
Subject: [PATCH] I2C: ISP1301_OMAP: New-style i2c driver updates, part 2
Based on David Brownell's patch for tps65010, this patch
finish conversting isp1301_omap.c to new-style i2c driver.
Signed-off-by: Felipe Balbi <[EMAIL PROTECTED]>
---
arch/arm/mach-omap1/board-h2.c | 1 +
arch/arm/mach-omap1/board-h3.c | 6 ++
arch/arm/mach-omap2/board-h4.c | 12 +++
drivers/i2c/chips/isp1301_omap.c | 140 ++++++++++----------------------------
4 files changed, 56 insertions(+), 103 deletions(-)
diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index 5079877..81a8c87 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -357,6 +357,7 @@ static struct i2c_board_info __initdata h2_i2c_board_info[]
= {
I2C_BOARD_INFO("isp1301_omap", 0x2d),
.type = "isp1301_omap",
.irq = OMAP_GPIO_IRQ(2),
+ .irq_flags = IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_FALLING,
},
};
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index c3ef1ee..474921f 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -477,6 +477,12 @@ static struct i2c_board_info __initdata
h3_i2c_board_info[] = {
.type = "tps65013",
/* .irq = OMAP_GPIO_IRQ(??), */
},
+ {
+ I2C_BOARD_INFO("isp1301_omap", 0x2d),
+ .type = "isp1301_omap",
+ .irq = OMAP_GPIO_IRQ(14),
+ .irq_flags = IRQF_SAMPLE_RANDOM,
+ },
};
static struct omap_gpio_switch h3_gpio_switches[] __initdata = {
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c
index f125f43..6e57021 100644
--- a/arch/arm/mach-omap2/board-h4.c
+++ b/arch/arm/mach-omap2/board-h4.c
@@ -301,6 +301,15 @@ static struct omap_board_config_kernel h4_config[] = {
{ OMAP_TAG_LCD, &h4_lcd_config },
};
+static struct i2c_board_info __initdata h4_i2c_board_info[] = {
+ {
+ I2C_BOARD_INFO("isp1301_omap", 0x2d),
+ .type = "isp1301_omap",
+ .irq = OMAP_GPIO_IRQ(125),
+ .irq_flags = IRQF_SAMPLE_RANDOM,
+ },
+};
+
static void __init omap_h4_init(void)
{
/*
@@ -321,6 +330,9 @@ static void __init omap_h4_init(void)
}
#endif
+ i2c_register_board_info(1, h4_i2c_board_info,
+ ARRAY_SIZE(h4_i2c_board_info));
+
platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
omap_board_config = h4_config;
omap_board_config_size = ARRAY_SIZE(h4_config);
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c
index d094b99..0f5a2ae 100644
--- a/drivers/i2c/chips/isp1301_omap.c
+++ b/drivers/i2c/chips/isp1301_omap.c
@@ -25,17 +25,10 @@
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
-#include <linux/usb/ch9.h>
-#include <linux/usb/gadget.h>
-#include <linux/usb.h>
-#include <linux/usb/otg.h>
#include <linux/i2c.h>
#include <linux/workqueue.h>
-
-#include <asm/irq.h>
#include <asm/arch/usb.h>
-
#ifndef DEBUG
#undef VERBOSE
#endif
@@ -50,12 +43,8 @@ MODULE_LICENSE("GPL");
struct isp1301 {
struct otg_transceiver otg;
struct i2c_client *client;
- struct i2c_client c;
void (*i2c_release)(struct device *dev);
- int irq;
- int irq_type;
-
u32 last_otg_ctrl;
unsigned working:1;
@@ -140,13 +129,6 @@ static inline void notresponding(struct isp1301 *isp)
/*-------------------------------------------------------------------------*/
/* only two addresses possible */
-#define ISP_BASE 0x2c
-static unsigned short normal_i2c[] = {
- ISP_BASE, ISP_BASE + 1,
- I2C_CLIENT_END };
-
-I2C_CLIENT_INSMOD;
-
static struct i2c_driver isp1301_driver;
/* smbus apis are used for portability */
@@ -1190,9 +1172,7 @@ static void isp1301_timer(unsigned long _isp)
static void isp1301_release(struct device *dev)
{
- struct isp1301 *isp;
-
- isp = container_of(dev, struct isp1301, c.dev);
+ struct isp1301 *isp = dev_get_drvdata(dev);
/* ugly -- i2c hijacks our memory hook to wait_for_completion() */
if (isp->i2c_release)
@@ -1202,30 +1182,27 @@ static void isp1301_release(struct device *dev)
static struct isp1301 *the_transceiver;
-static int isp1301_detach_client(struct i2c_client *i2c)
+static int __exit isp1301_remove(struct i2c_client *client)
{
- struct isp1301 *isp;
-
- isp = container_of(i2c, struct isp1301, c);
+ struct isp1301 *isp = i2c_get_clientdata(client);
isp1301_clear_bits(isp, ISP1301_INTERRUPT_FALLING, ~0);
isp1301_clear_bits(isp, ISP1301_INTERRUPT_RISING, ~0);
- free_irq(isp->irq, isp);
+
+ if (client->irq > 0)
+ free_irq(client->irq, isp);
#ifdef CONFIG_USB_OTG
otg_unbind(isp);
#endif
- if (machine_is_omap_h2())
- omap_free_gpio(2);
-
isp->timer.data = 0;
set_bit(WORK_STOP, &isp->todo);
del_timer_sync(&isp->timer);
flush_scheduled_work();
- put_device(&i2c->dev);
+ put_device(&client->dev);
the_transceiver = 0;
- return i2c_detach_client(i2c);
+ return 0;
}
/*-------------------------------------------------------------------------*/
@@ -1295,9 +1272,6 @@ isp1301_set_host(struct otg_transceiver *otg, struct
usb_bus *host)
power_up(isp);
- if (machine_is_omap_h2())
- isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_DAT_SE0);
-
dev_info(&isp->client->dev, "A-Host sessions ok\n");
isp1301_set_bits(isp, ISP1301_INTERRUPT_RISING,
INTR_ID_GND);
@@ -1475,11 +1449,10 @@ isp1301_start_hnp(struct otg_transceiver *dev)
/*-------------------------------------------------------------------------*/
/* no error returns, they'd just make bus scanning stop */
-static int isp1301_probe(struct i2c_adapter *bus, int address, int kind)
+static int __init isp1301_probe(struct i2c_client *client)
{
int status;
struct isp1301 *isp;
- struct i2c_client *i2c;
if (the_transceiver)
return 0;
@@ -1492,45 +1465,29 @@ static int isp1301_probe(struct i2c_adapter *bus, int
address, int kind)
init_timer(&isp->timer);
isp->timer.function = isp1301_timer;
isp->timer.data = (unsigned long) isp;
-
- isp->irq = -1;
- isp->c.addr = address;
- i2c_set_clientdata(&isp->c, isp);
- isp->c.adapter = bus;
- isp->c.driver = &isp1301_driver;
- strlcpy(isp->c.name, DRIVER_NAME, I2C_NAME_SIZE);
- isp->client = i2c = &isp->c;
+ isp->client = client;
/* if this is a true probe, verify the chip ... */
- if (kind < 0) {
- status = isp1301_get_u16(isp, ISP1301_VENDOR_ID);
- if (status != I2C_VENDOR_ID_PHILIPS) {
- dev_dbg(&bus->dev, "addr %d not philips id: %d\n",
- address, status);
- goto fail1;
- }
- status = isp1301_get_u16(isp, ISP1301_PRODUCT_ID);
- if (status != I2C_PRODUCT_ID_PHILIPS_1301) {
- dev_dbg(&bus->dev, "%d not isp1301, %d\n",
- address, status);
- goto fail1;
- }
+ status = isp1301_get_u16(isp, ISP1301_VENDOR_ID);
+ if (status != I2C_VENDOR_ID_PHILIPS) {
+ dev_dbg(&client->dev, "not philips id: %d\n", status);
+ goto fail1;
+ }
+ status = isp1301_get_u16(isp, ISP1301_PRODUCT_ID);
+ if (status != I2C_PRODUCT_ID_PHILIPS_1301) {
+ dev_dbg(&client->dev, "not isp1301, %d\n", status);
+ goto fail1;
}
- status = i2c_attach_client(i2c);
- if (status < 0) {
- dev_dbg(&bus->dev, "can't attach %s to device %d, err %d\n",
- DRIVER_NAME, address, status);
fail1:
kfree(isp);
return 0;
- }
- isp->i2c_release = i2c->dev.release;
- i2c->dev.release = isp1301_release;
+
+ isp->i2c_release = client->dev.release = isp1301_release;
/* initial development used chiprev 2.00 */
- status = i2c_smbus_read_word_data(i2c, ISP1301_BCD_DEVICE);
- dev_info(&i2c->dev, "chiprev %x.%02x, driver " DRIVER_VERSION "\n",
+ status = i2c_smbus_read_word_data(client, ISP1301_BCD_DEVICE);
+ dev_info(&client->dev, "chiprev %x.%02x, driver " DRIVER_VERSION "\n",
status >> 8, status & 0xff);
/* make like power-on reset */
@@ -1551,40 +1508,25 @@ fail1:
#ifdef CONFIG_USB_OTG
status = otg_bind(isp);
if (status < 0) {
- dev_dbg(&i2c->dev, "can't bind OTG\n");
+ dev_dbg(&client->dev, "can't bind OTG\n");
goto fail2;
}
#endif
- if (machine_is_omap_h2()) {
- /* full speed signaling by default */
- isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1,
- MC1_SPEED_REG);
- isp1301_set_bits(isp, ISP1301_MODE_CONTROL_2,
- MC2_SPD_SUSP_CTRL);
-
- /* IRQ wired at M14 */
- omap_cfg_reg(M14_1510_GPIO2);
- isp->irq = OMAP_GPIO_IRQ(2);
- if (gpio_request(2, "isp1301") == 0)
- gpio_direction_input(2);
- isp->irq_type = IRQF_TRIGGER_FALLING;
- }
-
- isp->irq_type |= IRQF_SAMPLE_RANDOM;
- status = request_irq(isp->irq, isp1301_irq,
- isp->irq_type, DRIVER_NAME, isp);
- if (status < 0) {
- dev_dbg(&i2c->dev, "can't get IRQ %d, err %d\n",
- isp->irq, status);
+ if (client->irq > 0) {
+ status = request_irq(client->irq, isp1301_irq,
+ client->irq_flags, DRIVER_NAME, isp);
+ if (status < 0) {
+ dev_dbg(&client->dev, "can't get IRQ %d, err %d\n",
+ client->irq, status);
#ifdef CONFIG_USB_OTG
fail2:
#endif
- i2c_detach_client(i2c);
- goto fail1;
+ goto fail1;
+ }
}
- isp->otg.dev = &isp->client->dev;
+ isp->otg.dev = &client->dev;
isp->otg.label = DRIVER_NAME;
isp->otg.set_host = isp1301_set_host,
@@ -1606,31 +1548,23 @@ fail2:
#ifdef VERBOSE
mod_timer(&isp->timer, jiffies + TIMER_JIFFIES);
- dev_dbg(&i2c->dev, "scheduled timer, %d min\n", TIMER_MINUTES);
+ dev_dbg(&client->dev, "scheduled timer, %d min\n", TIMER_MINUTES);
#endif
status = otg_set_transceiver(&isp->otg);
if (status < 0)
- dev_err(&i2c->dev, "can't register transceiver, %d\n",
+ dev_err(&client->dev, "can't register transceiver, %d\n",
status);
return 0;
}
-static int isp1301_scan_bus(struct i2c_adapter *bus)
-{
- if (!i2c_check_functionality(bus, I2C_FUNC_SMBUS_BYTE_DATA
- | I2C_FUNC_SMBUS_READ_WORD_DATA))
- return -EINVAL;
- return i2c_probe(bus, &addr_data, isp1301_probe);
-}
-
static struct i2c_driver isp1301_driver = {
.driver = {
.name = "isp1301_omap",
},
- .attach_adapter = isp1301_scan_bus,
- .detach_client = isp1301_detach_client,
+ .probe = isp1301_probe,
+ .remove = __exit_p(isp1301_remove),
};
/*-------------------------------------------------------------------------*/
--
1.5.4.3.447.gc95b3
--
Best Regards,
Felipe Balbi
[EMAIL PROTECTED]
http://blog.felipebalbi.com
_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c