提交 9df013b3 编写于 作者: J Jean Delvare 提交者: Jean Delvare

i2c/isp1301_omap: Convert to a new-style i2c driver, part 2

Based on David Brownell's patch for tps65010 and previous work by
Felipe Balbi, this patch finishes converting isp1301_omap to a
new-style i2c driver.

There's definitely room for further drivers cleanups, but these are
out of the scope of this patch.
Signed-off-by: NJean Delvare <khali@linux-fr.org>
Acked-by: NTony Lindgren <tony@atomide.com>
上级 a5f08a32
...@@ -476,6 +476,10 @@ static struct i2c_board_info __initdata h3_i2c_board_info[] = { ...@@ -476,6 +476,10 @@ static struct i2c_board_info __initdata h3_i2c_board_info[] = {
I2C_BOARD_INFO("tps65013", 0x48), I2C_BOARD_INFO("tps65013", 0x48),
/* .irq = OMAP_GPIO_IRQ(??), */ /* .irq = OMAP_GPIO_IRQ(??), */
}, },
{
I2C_BOARD_INFO("isp1301_omap", 0x2d),
.irq = OMAP_GPIO_IRQ(14),
},
}; };
static struct omap_gpio_switch h3_gpio_switches[] __initdata = { static struct omap_gpio_switch h3_gpio_switches[] __initdata = {
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/i2c.h>
#include <linux/input.h> #include <linux/input.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/clk.h> #include <linux/clk.h>
...@@ -391,6 +392,13 @@ static struct omap_board_config_kernel h4_config[] = { ...@@ -391,6 +392,13 @@ static struct omap_board_config_kernel h4_config[] = {
{ OMAP_TAG_LCD, &h4_lcd_config }, { OMAP_TAG_LCD, &h4_lcd_config },
}; };
static struct i2c_board_info __initdata h4_i2c_board_info[] = {
{
I2C_BOARD_INFO("isp1301_omap", 0x2d),
.irq = OMAP_GPIO_IRQ(125),
},
};
static void __init omap_h4_init(void) static void __init omap_h4_init(void)
{ {
/* /*
...@@ -411,6 +419,9 @@ static void __init omap_h4_init(void) ...@@ -411,6 +419,9 @@ static void __init omap_h4_init(void)
} }
#endif #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)); platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
omap_board_config = h4_config; omap_board_config = h4_config;
omap_board_config_size = ARRAY_SIZE(h4_config); omap_board_config_size = ARRAY_SIZE(h4_config);
......
...@@ -50,10 +50,8 @@ MODULE_LICENSE("GPL"); ...@@ -50,10 +50,8 @@ MODULE_LICENSE("GPL");
struct isp1301 { struct isp1301 {
struct otg_transceiver otg; struct otg_transceiver otg;
struct i2c_client *client; struct i2c_client *client;
struct i2c_client c;
void (*i2c_release)(struct device *dev); void (*i2c_release)(struct device *dev);
int irq;
int irq_type; int irq_type;
u32 last_otg_ctrl; u32 last_otg_ctrl;
...@@ -139,14 +137,6 @@ static inline void notresponding(struct isp1301 *isp) ...@@ -139,14 +137,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; static struct i2c_driver isp1301_driver;
/* smbus apis are used for portability */ /* smbus apis are used for portability */
...@@ -1230,7 +1220,7 @@ static void isp1301_release(struct device *dev) ...@@ -1230,7 +1220,7 @@ static void isp1301_release(struct device *dev)
static struct isp1301 *the_transceiver; static struct isp1301 *the_transceiver;
static int isp1301_detach_client(struct i2c_client *i2c) static int __exit isp1301_remove(struct i2c_client *i2c)
{ {
struct isp1301 *isp; struct isp1301 *isp;
...@@ -1238,7 +1228,7 @@ static int isp1301_detach_client(struct i2c_client *i2c) ...@@ -1238,7 +1228,7 @@ static int isp1301_detach_client(struct i2c_client *i2c)
isp1301_clear_bits(isp, ISP1301_INTERRUPT_FALLING, ~0); isp1301_clear_bits(isp, ISP1301_INTERRUPT_FALLING, ~0);
isp1301_clear_bits(isp, ISP1301_INTERRUPT_RISING, ~0); isp1301_clear_bits(isp, ISP1301_INTERRUPT_RISING, ~0);
free_irq(isp->irq, isp); free_irq(i2c->irq, isp);
#ifdef CONFIG_USB_OTG #ifdef CONFIG_USB_OTG
otg_unbind(isp); otg_unbind(isp);
#endif #endif
...@@ -1253,7 +1243,7 @@ static int isp1301_detach_client(struct i2c_client *i2c) ...@@ -1253,7 +1243,7 @@ static int isp1301_detach_client(struct i2c_client *i2c)
put_device(&i2c->dev); put_device(&i2c->dev);
the_transceiver = 0; the_transceiver = 0;
return i2c_detach_client(i2c); return 0;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -1509,12 +1499,10 @@ isp1301_start_hnp(struct otg_transceiver *dev) ...@@ -1509,12 +1499,10 @@ isp1301_start_hnp(struct otg_transceiver *dev)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/* no error returns, they'd just make bus scanning stop */ static int __init isp1301_probe(struct i2c_client *i2c)
static int isp1301_probe(struct i2c_adapter *bus, int address, int kind)
{ {
int status; int status;
struct isp1301 *isp; struct isp1301 *isp;
struct i2c_client *i2c;
if (the_transceiver) if (the_transceiver)
return 0; return 0;
...@@ -1528,37 +1516,19 @@ static int isp1301_probe(struct i2c_adapter *bus, int address, int kind) ...@@ -1528,37 +1516,19 @@ static int isp1301_probe(struct i2c_adapter *bus, int address, int kind)
isp->timer.function = isp1301_timer; isp->timer.function = isp1301_timer;
isp->timer.data = (unsigned long) isp; isp->timer.data = (unsigned long) isp;
isp->irq = -1; i2c_set_clientdata(i2c, isp);
isp->c.addr = address; isp->client = i2c;
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;
/* 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 = i2c_attach_client(i2c); /* verify the chip (shouldn't be necesary) */
if (status < 0) { status = isp1301_get_u16(isp, ISP1301_VENDOR_ID);
dev_dbg(&bus->dev, "can't attach %s to device %d, err %d\n", if (status != I2C_VENDOR_ID_PHILIPS) {
DRIVER_NAME, address, status); dev_dbg(&i2c->dev, "not philips id: %d\n", status);
fail1: goto fail;
kfree(isp); }
return 0; status = isp1301_get_u16(isp, ISP1301_PRODUCT_ID);
if (status != I2C_PRODUCT_ID_PHILIPS_1301) {
dev_dbg(&i2c->dev, "not isp1301, %d\n", status);
goto fail;
} }
isp->i2c_release = i2c->dev.release; isp->i2c_release = i2c->dev.release;
i2c->dev.release = isp1301_release; i2c->dev.release = isp1301_release;
...@@ -1587,7 +1557,7 @@ static int isp1301_probe(struct i2c_adapter *bus, int address, int kind) ...@@ -1587,7 +1557,7 @@ static int isp1301_probe(struct i2c_adapter *bus, int address, int kind)
status = otg_bind(isp); status = otg_bind(isp);
if (status < 0) { if (status < 0) {
dev_dbg(&i2c->dev, "can't bind OTG\n"); dev_dbg(&i2c->dev, "can't bind OTG\n");
goto fail2; goto fail;
} }
#endif #endif
...@@ -1600,26 +1570,21 @@ static int isp1301_probe(struct i2c_adapter *bus, int address, int kind) ...@@ -1600,26 +1570,21 @@ static int isp1301_probe(struct i2c_adapter *bus, int address, int kind)
/* IRQ wired at M14 */ /* IRQ wired at M14 */
omap_cfg_reg(M14_1510_GPIO2); omap_cfg_reg(M14_1510_GPIO2);
isp->irq = OMAP_GPIO_IRQ(2);
if (gpio_request(2, "isp1301") == 0) if (gpio_request(2, "isp1301") == 0)
gpio_direction_input(2); gpio_direction_input(2);
isp->irq_type = IRQF_TRIGGER_FALLING; isp->irq_type = IRQF_TRIGGER_FALLING;
} }
isp->irq_type |= IRQF_SAMPLE_RANDOM; isp->irq_type |= IRQF_SAMPLE_RANDOM;
status = request_irq(isp->irq, isp1301_irq, status = request_irq(i2c->irq, isp1301_irq,
isp->irq_type, DRIVER_NAME, isp); isp->irq_type, DRIVER_NAME, isp);
if (status < 0) { if (status < 0) {
dev_dbg(&i2c->dev, "can't get IRQ %d, err %d\n", dev_dbg(&i2c->dev, "can't get IRQ %d, err %d\n",
isp->irq, status); i2c->irq, status);
#ifdef CONFIG_USB_OTG goto fail;
fail2:
#endif
i2c_detach_client(i2c);
goto fail1;
} }
isp->otg.dev = &isp->client->dev; isp->otg.dev = &i2c->dev;
isp->otg.label = DRIVER_NAME; isp->otg.label = DRIVER_NAME;
isp->otg.set_host = isp1301_set_host, isp->otg.set_host = isp1301_set_host,
...@@ -1650,22 +1615,25 @@ static int isp1301_probe(struct i2c_adapter *bus, int address, int kind) ...@@ -1650,22 +1615,25 @@ static int isp1301_probe(struct i2c_adapter *bus, int address, int kind)
status); status);
return 0; return 0;
}
static int isp1301_scan_bus(struct i2c_adapter *bus) fail:
{ kfree(isp);
if (!i2c_check_functionality(bus, I2C_FUNC_SMBUS_BYTE_DATA return -ENODEV;
| I2C_FUNC_SMBUS_READ_WORD_DATA))
return -EINVAL;
return i2c_probe(bus, &addr_data, isp1301_probe);
} }
static const struct i2c_device_id isp1301_id[] = {
{ "isp1301_omap", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, isp1301_id);
static struct i2c_driver isp1301_driver = { static struct i2c_driver isp1301_driver = {
.driver = { .driver = {
.name = "isp1301_omap", .name = "isp1301_omap",
}, },
.attach_adapter = isp1301_scan_bus, .probe = isp1301_probe,
.detach_client = isp1301_detach_client, .remove = __exit_p(isp1301_remove),
.id_table = isp1301_id,
}; };
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册