| Roland Stigge | 8b7c3b6 | 2012-04-29 16:47:04 +0200 | [diff] [blame] | 1 | /* | 
|  | 2 | * NXP ISP1301 USB transceiver driver | 
|  | 3 | * | 
|  | 4 | * Copyright (C) 2012 Roland Stigge | 
|  | 5 | * | 
|  | 6 | * Author: Roland Stigge <stigge@antcom.de> | 
|  | 7 | * | 
|  | 8 | * This program is free software; you can redistribute it and/or modify | 
|  | 9 | * it under the terms of the GNU General Public License version 2 as | 
|  | 10 | * published by the Free Software Foundation. | 
|  | 11 | */ | 
|  | 12 |  | 
|  | 13 | #include <linux/module.h> | 
|  | 14 | #include <linux/i2c.h> | 
|  | 15 |  | 
|  | 16 | #define DRV_NAME		"isp1301" | 
|  | 17 |  | 
| Roland Stigge | 8b7c3b6 | 2012-04-29 16:47:04 +0200 | [diff] [blame] | 18 | static const struct i2c_device_id isp1301_id[] = { | 
|  | 19 | { "isp1301", 0 }, | 
|  | 20 | { } | 
|  | 21 | }; | 
|  | 22 |  | 
|  | 23 | static struct i2c_client *isp1301_i2c_client; | 
|  | 24 |  | 
|  | 25 | static int isp1301_probe(struct i2c_client *client, | 
|  | 26 | const struct i2c_device_id *i2c_id) | 
|  | 27 | { | 
|  | 28 | isp1301_i2c_client = client; | 
|  | 29 | return 0; | 
|  | 30 | } | 
|  | 31 |  | 
|  | 32 | static int isp1301_remove(struct i2c_client *client) | 
|  | 33 | { | 
|  | 34 | return 0; | 
|  | 35 | } | 
|  | 36 |  | 
|  | 37 | static struct i2c_driver isp1301_driver = { | 
|  | 38 | .driver = { | 
|  | 39 | .name = DRV_NAME, | 
|  | 40 | }, | 
|  | 41 | .probe = isp1301_probe, | 
|  | 42 | .remove = isp1301_remove, | 
|  | 43 | .id_table = isp1301_id, | 
|  | 44 | }; | 
|  | 45 |  | 
|  | 46 | module_i2c_driver(isp1301_driver); | 
|  | 47 |  | 
|  | 48 | static int match(struct device *dev, void *data) | 
|  | 49 | { | 
|  | 50 | struct device_node *node = (struct device_node *)data; | 
|  | 51 | return (dev->of_node == node) && | 
|  | 52 | (dev->driver == &isp1301_driver.driver); | 
|  | 53 | } | 
|  | 54 |  | 
|  | 55 | struct i2c_client *isp1301_get_client(struct device_node *node) | 
|  | 56 | { | 
|  | 57 | if (node) { /* reference of ISP1301 I2C node via DT */ | 
|  | 58 | struct device *dev = bus_find_device(&i2c_bus_type, NULL, | 
|  | 59 | node, match); | 
|  | 60 | if (!dev) | 
|  | 61 | return NULL; | 
|  | 62 | return to_i2c_client(dev); | 
|  | 63 | } else { /* non-DT: only one ISP1301 chip supported */ | 
|  | 64 | return isp1301_i2c_client; | 
|  | 65 | } | 
|  | 66 | } | 
|  | 67 | EXPORT_SYMBOL_GPL(isp1301_get_client); | 
|  | 68 |  | 
|  | 69 | MODULE_AUTHOR("Roland Stigge <stigge@antcom.de>"); | 
|  | 70 | MODULE_DESCRIPTION("NXP ISP1301 USB transceiver driver"); | 
|  | 71 | MODULE_LICENSE("GPL"); |