Linux Audio

Check our new training course

Loading...
Note: File does not exist in v4.6.
 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
18#define ISP1301_I2C_ADDR	0x2C
19
20static const unsigned short normal_i2c[] = {
21	ISP1301_I2C_ADDR, ISP1301_I2C_ADDR + 1, I2C_CLIENT_END
22};
23
24static const struct i2c_device_id isp1301_id[] = {
25	{ "isp1301", 0 },
26	{ }
27};
28
29static struct i2c_client *isp1301_i2c_client;
30
31static int isp1301_probe(struct i2c_client *client,
32			 const struct i2c_device_id *i2c_id)
33{
34	isp1301_i2c_client = client;
35	return 0;
36}
37
38static int isp1301_remove(struct i2c_client *client)
39{
40	return 0;
41}
42
43static struct i2c_driver isp1301_driver = {
44	.driver = {
45		.name = DRV_NAME,
46	},
47	.probe = isp1301_probe,
48	.remove = isp1301_remove,
49	.id_table = isp1301_id,
50};
51
52module_i2c_driver(isp1301_driver);
53
54static int match(struct device *dev, void *data)
55{
56	struct device_node *node = (struct device_node *)data;
57	return (dev->of_node == node) &&
58		(dev->driver == &isp1301_driver.driver);
59}
60
61struct i2c_client *isp1301_get_client(struct device_node *node)
62{
63	if (node) { /* reference of ISP1301 I2C node via DT */
64		struct device *dev = bus_find_device(&i2c_bus_type, NULL,
65						     node, match);
66		if (!dev)
67			return NULL;
68		return to_i2c_client(dev);
69	} else { /* non-DT: only one ISP1301 chip supported */
70		return isp1301_i2c_client;
71	}
72}
73EXPORT_SYMBOL_GPL(isp1301_get_client);
74
75MODULE_AUTHOR("Roland Stigge <stigge@antcom.de>");
76MODULE_DESCRIPTION("NXP ISP1301 USB transceiver driver");
77MODULE_LICENSE("GPL");