mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-23 18:07:03 +00:00
b668422872
Allow more than one viperboard to be connected by registering with PLATFORM_DEVID_AUTO instead of PLATFORM_DEVID_NONE. The subdevices are currently registered with PLATFORM_DEVID_NONE, which will cause a name collision on the platform bus when a second viperboard is plugged in: viperboard 1-2.4:1.0: version 0.00 found at bus 001 address 004 ------------[ cut here ]------------ WARNING: CPU: 0 PID: 181 at /home/johan/work/omicron/src/linux/fs/sysfs/dir.c:31 sysfs_warn_dup+0x74/0x84() sysfs: cannot create duplicate filename '/bus/platform/devices/viperboard-gpio' Modules linked in: i2c_viperboard viperboard netconsole [last unloaded: viperboard] CPU: 0 PID: 181 Comm: bash Tainted: G W 3.17.0-rc6 #1 [<c0016bf4>] (unwind_backtrace) from [<c0013860>] (show_stack+0x20/0x24) [<c0013860>] (show_stack) from [<c04305f8>] (dump_stack+0x24/0x28) [<c04305f8>] (dump_stack) from [<c0040fb4>] (warn_slowpath_common+0x80/0x98) [<c0040fb4>] (warn_slowpath_common) from [<c004100c>] (warn_slowpath_fmt+0x40/0x48) [<c004100c>] (warn_slowpath_fmt) from [<c016f1bc>] (sysfs_warn_dup+0x74/0x84) [<c016f1bc>] (sysfs_warn_dup) from [<c016f548>] (sysfs_do_create_link_sd.isra.2+0xcc/0xd0) [<c016f548>] (sysfs_do_create_link_sd.isra.2) from [<c016f588>] (sysfs_create_link+0x3c/0x48) [<c016f588>] (sysfs_create_link) from [<c02867ec>] (bus_add_device+0x12c/0x1e0) [<c02867ec>] (bus_add_device) from [<c0284820>] (device_add+0x410/0x584) [<c0284820>] (device_add) from [<c0289440>] (platform_device_add+0xd8/0x26c) [<c0289440>] (platform_device_add) from [<c02a5ae4>] (mfd_add_device+0x240/0x344) [<c02a5ae4>] (mfd_add_device) from [<c02a5ce0>] (mfd_add_devices+0xb8/0x110) [<c02a5ce0>] (mfd_add_devices) from [<bf00d1c8>] (vprbrd_probe+0x160/0x1b0 [viperboard]) [<bf00d1c8>] (vprbrd_probe [viperboard]) from [<c030c000>] (usb_probe_interface+0x1bc/0x2a8) [<c030c000>] (usb_probe_interface) from [<c028768c>] (driver_probe_device+0x14c/0x3ac) [<c028768c>] (driver_probe_device) from [<c02879e4>] (__driver_attach+0xa4/0xa8) [<c02879e4>] (__driver_attach) from [<c0285698>] (bus_for_each_dev+0x70/0xa4) [<c0285698>] (bus_for_each_dev) from [<c0287030>] (driver_attach+0x2c/0x30) [<c0287030>] (driver_attach) from [<c030a288>] (usb_store_new_id+0x170/0x1ac) [<c030a288>] (usb_store_new_id) from [<c030a2f8>] (new_id_store+0x34/0x3c) [<c030a2f8>] (new_id_store) from [<c02853ec>] (drv_attr_store+0x30/0x3c) [<c02853ec>] (drv_attr_store) from [<c016eaa8>] (sysfs_kf_write+0x5c/0x60) [<c016eaa8>] (sysfs_kf_write) from [<c016dc68>] (kernfs_fop_write+0xd4/0x194) [<c016dc68>] (kernfs_fop_write) from [<c010fe40>] (vfs_write+0xb4/0x1c0) [<c010fe40>] (vfs_write) from [<c01104a8>] (SyS_write+0x4c/0xa0) [<c01104a8>] (SyS_write) from [<c000f900>] (ret_fast_syscall+0x0/0x48) ---[ end trace 98e8603c22d65817 ]--- viperboard 1-2.4:1.0: Failed to add mfd devices to core. viperboard: probe of 1-2.4:1.0 failed with error -17 Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
139 lines
3.4 KiB
C
139 lines
3.4 KiB
C
/*
|
|
* Nano River Technologies viperboard driver
|
|
*
|
|
* This is the core driver for the viperboard. There are cell drivers
|
|
* available for I2C, ADC and both GPIOs. SPI is not yet supported.
|
|
* The drivers do not support all features the board exposes. See user
|
|
* manual of the viperboard.
|
|
*
|
|
* (C) 2012 by Lemonage GmbH
|
|
* Author: Lars Poeschel <poeschel@lemonage.de>
|
|
* All rights reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
* option) any later version.
|
|
*
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/module.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/types.h>
|
|
#include <linux/mutex.h>
|
|
|
|
#include <linux/mfd/core.h>
|
|
#include <linux/mfd/viperboard.h>
|
|
|
|
#include <linux/usb.h>
|
|
|
|
|
|
static const struct usb_device_id vprbrd_table[] = {
|
|
{ USB_DEVICE(0x2058, 0x1005) }, /* Nano River Technologies */
|
|
{ } /* Terminating entry */
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(usb, vprbrd_table);
|
|
|
|
static const struct mfd_cell vprbrd_devs[] = {
|
|
{
|
|
.name = "viperboard-gpio",
|
|
},
|
|
{
|
|
.name = "viperboard-i2c",
|
|
},
|
|
{
|
|
.name = "viperboard-adc",
|
|
},
|
|
};
|
|
|
|
static int vprbrd_probe(struct usb_interface *interface,
|
|
const struct usb_device_id *id)
|
|
{
|
|
struct vprbrd *vb;
|
|
|
|
u16 version = 0;
|
|
int pipe, ret;
|
|
|
|
/* allocate memory for our device state and initialize it */
|
|
vb = kzalloc(sizeof(*vb), GFP_KERNEL);
|
|
if (vb == NULL) {
|
|
dev_err(&interface->dev, "Out of memory\n");
|
|
return -ENOMEM;
|
|
}
|
|
|
|
mutex_init(&vb->lock);
|
|
|
|
vb->usb_dev = usb_get_dev(interface_to_usbdev(interface));
|
|
|
|
/* save our data pointer in this interface device */
|
|
usb_set_intfdata(interface, vb);
|
|
dev_set_drvdata(&vb->pdev.dev, vb);
|
|
|
|
/* get version information, major first, minor then */
|
|
pipe = usb_rcvctrlpipe(vb->usb_dev, 0);
|
|
ret = usb_control_msg(vb->usb_dev, pipe, VPRBRD_USB_REQUEST_MAJOR,
|
|
VPRBRD_USB_TYPE_IN, 0x0000, 0x0000, vb->buf, 1,
|
|
VPRBRD_USB_TIMEOUT_MS);
|
|
if (ret == 1)
|
|
version = vb->buf[0];
|
|
|
|
ret = usb_control_msg(vb->usb_dev, pipe, VPRBRD_USB_REQUEST_MINOR,
|
|
VPRBRD_USB_TYPE_IN, 0x0000, 0x0000, vb->buf, 1,
|
|
VPRBRD_USB_TIMEOUT_MS);
|
|
if (ret == 1) {
|
|
version <<= 8;
|
|
version = version | vb->buf[0];
|
|
}
|
|
|
|
dev_info(&interface->dev,
|
|
"version %x.%02x found at bus %03d address %03d\n",
|
|
version >> 8, version & 0xff,
|
|
vb->usb_dev->bus->busnum, vb->usb_dev->devnum);
|
|
|
|
ret = mfd_add_devices(&interface->dev, PLATFORM_DEVID_AUTO,
|
|
vprbrd_devs, ARRAY_SIZE(vprbrd_devs), NULL, 0,
|
|
NULL);
|
|
if (ret != 0) {
|
|
dev_err(&interface->dev, "Failed to add mfd devices to core.");
|
|
goto error;
|
|
}
|
|
|
|
return 0;
|
|
|
|
error:
|
|
if (vb) {
|
|
usb_put_dev(vb->usb_dev);
|
|
kfree(vb);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
static void vprbrd_disconnect(struct usb_interface *interface)
|
|
{
|
|
struct vprbrd *vb = usb_get_intfdata(interface);
|
|
|
|
mfd_remove_devices(&interface->dev);
|
|
usb_set_intfdata(interface, NULL);
|
|
usb_put_dev(vb->usb_dev);
|
|
kfree(vb);
|
|
|
|
dev_dbg(&interface->dev, "disconnected\n");
|
|
}
|
|
|
|
static struct usb_driver vprbrd_driver = {
|
|
.name = "viperboard",
|
|
.probe = vprbrd_probe,
|
|
.disconnect = vprbrd_disconnect,
|
|
.id_table = vprbrd_table,
|
|
};
|
|
|
|
module_usb_driver(vprbrd_driver);
|
|
|
|
MODULE_DESCRIPTION("Nano River Technologies viperboard mfd core driver");
|
|
MODULE_AUTHOR("Lars Poeschel <poeschel@lemonage.de>");
|
|
MODULE_LICENSE("GPL");
|