greybus: spi: Separate out spilib from spi bridged PHY bundle driver
spilib can be used by multiple bridge drivers implementing different bundle classes. Separate out bridged PHY bundle drivers parts. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
parent
4c412921c7
commit
8888b96374
|
@ -40,6 +40,7 @@ gb-pwm-y := pwm.o
|
||||||
gb-gpio-y := gpio.o
|
gb-gpio-y := gpio.o
|
||||||
gb-i2c-y := i2c.o
|
gb-i2c-y := i2c.o
|
||||||
gb-usb-y := usb.o
|
gb-usb-y := usb.o
|
||||||
|
gb-spi-y := spi.o
|
||||||
|
|
||||||
obj-m += greybus.o
|
obj-m += greybus.o
|
||||||
obj-m += gb-gpbridge.o
|
obj-m += gb-gpbridge.o
|
||||||
|
@ -69,6 +70,7 @@ obj-m += gb-pwm.o
|
||||||
obj-m += gb-gpio.o
|
obj-m += gb-gpio.o
|
||||||
obj-m += gb-i2c.o
|
obj-m += gb-i2c.o
|
||||||
obj-m += gb-usb.o
|
obj-m += gb-usb.o
|
||||||
|
obj-m += gb-spi.o
|
||||||
|
|
||||||
KERNELVER ?= $(shell uname -r)
|
KERNELVER ?= $(shell uname -r)
|
||||||
KERNELDIR ?= /lib/modules/$(KERNELVER)/build
|
KERNELDIR ?= /lib/modules/$(KERNELVER)/build
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* SPI bridge PHY driver.
|
||||||
|
*
|
||||||
|
* Copyright 2014-2016 Google Inc.
|
||||||
|
* Copyright 2014-2016 Linaro Ltd.
|
||||||
|
*
|
||||||
|
* Released under the GPLv2 only.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linux/module.h>
|
||||||
|
|
||||||
|
#include "greybus.h"
|
||||||
|
#include "gpbridge.h"
|
||||||
|
#include "spilib.h"
|
||||||
|
|
||||||
|
static int gb_spi_probe(struct gpbridge_device *gpbdev,
|
||||||
|
const struct gpbridge_device_id *id)
|
||||||
|
{
|
||||||
|
struct gb_connection *connection;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
connection = gb_connection_create(gpbdev->bundle,
|
||||||
|
le16_to_cpu(gpbdev->cport_desc->id),
|
||||||
|
NULL);
|
||||||
|
if (IS_ERR(connection))
|
||||||
|
return PTR_ERR(connection);
|
||||||
|
|
||||||
|
ret = gb_connection_enable(connection);
|
||||||
|
if (ret)
|
||||||
|
goto exit_connection_destroy;
|
||||||
|
|
||||||
|
ret = gb_gpbridge_get_version(connection);
|
||||||
|
if (ret)
|
||||||
|
goto exit_connection_disable;
|
||||||
|
|
||||||
|
ret = gb_spilib_master_init(connection, &gpbdev->dev);
|
||||||
|
if (ret)
|
||||||
|
goto exit_connection_disable;
|
||||||
|
|
||||||
|
gb_gpbridge_set_data(gpbdev, connection);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
exit_connection_disable:
|
||||||
|
gb_connection_disable(connection);
|
||||||
|
exit_connection_destroy:
|
||||||
|
gb_connection_destroy(connection);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gb_spi_remove(struct gpbridge_device *gpbdev)
|
||||||
|
{
|
||||||
|
struct gb_connection *connection = gb_gpbridge_get_data(gpbdev);
|
||||||
|
|
||||||
|
gb_spilib_master_exit(connection);
|
||||||
|
gb_connection_disable(connection);
|
||||||
|
gb_connection_destroy(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct gpbridge_device_id gb_spi_id_table[] = {
|
||||||
|
{ GPBRIDGE_PROTOCOL(GREYBUS_PROTOCOL_SPI) },
|
||||||
|
{ },
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(gpbridge, gb_spi_id_table);
|
||||||
|
|
||||||
|
static struct gpbridge_driver spi_driver = {
|
||||||
|
.name = "spi",
|
||||||
|
.probe = gb_spi_probe,
|
||||||
|
.remove = gb_spi_remove,
|
||||||
|
.id_table = gb_spi_id_table,
|
||||||
|
};
|
||||||
|
|
||||||
|
module_gpbridge_driver(spi_driver);
|
||||||
|
MODULE_LICENSE("GPL v2");
|
|
@ -14,7 +14,6 @@
|
||||||
#include <linux/spi/spi.h>
|
#include <linux/spi/spi.h>
|
||||||
|
|
||||||
#include "greybus.h"
|
#include "greybus.h"
|
||||||
#include "gpbridge.h"
|
|
||||||
#include "spilib.h"
|
#include "spilib.h"
|
||||||
|
|
||||||
struct gb_spilib {
|
struct gb_spilib {
|
||||||
|
@ -521,63 +520,4 @@ void gb_spilib_master_exit(struct gb_connection *connection)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(gb_spilib_master_exit);
|
EXPORT_SYMBOL_GPL(gb_spilib_master_exit);
|
||||||
|
|
||||||
static int gb_spi_probe(struct gpbridge_device *gpbdev,
|
|
||||||
const struct gpbridge_device_id *id)
|
|
||||||
{
|
|
||||||
struct gb_connection *connection;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
connection = gb_connection_create(gpbdev->bundle,
|
|
||||||
le16_to_cpu(gpbdev->cport_desc->id),
|
|
||||||
NULL);
|
|
||||||
if (IS_ERR(connection))
|
|
||||||
return PTR_ERR(connection);
|
|
||||||
|
|
||||||
ret = gb_connection_enable(connection);
|
|
||||||
if (ret)
|
|
||||||
goto exit_connection_destroy;
|
|
||||||
|
|
||||||
ret = gb_gpbridge_get_version(connection);
|
|
||||||
if (ret)
|
|
||||||
goto exit_connection_disable;
|
|
||||||
|
|
||||||
ret = gb_spilib_master_init(connection, &gpbdev->dev);
|
|
||||||
if (ret)
|
|
||||||
goto exit_connection_disable;
|
|
||||||
|
|
||||||
gb_gpbridge_set_data(gpbdev, connection);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
exit_connection_disable:
|
|
||||||
gb_connection_disable(connection);
|
|
||||||
exit_connection_destroy:
|
|
||||||
gb_connection_destroy(connection);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void gb_spi_remove(struct gpbridge_device *gpbdev)
|
|
||||||
{
|
|
||||||
struct gb_connection *connection = gb_gpbridge_get_data(gpbdev);
|
|
||||||
|
|
||||||
gb_spilib_master_exit(connection);
|
|
||||||
gb_connection_disable(connection);
|
|
||||||
gb_connection_destroy(connection);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct gpbridge_device_id gb_spi_id_table[] = {
|
|
||||||
{ GPBRIDGE_PROTOCOL(GREYBUS_PROTOCOL_SPI) },
|
|
||||||
{ },
|
|
||||||
};
|
|
||||||
MODULE_DEVICE_TABLE(gpbridge, gb_spi_id_table);
|
|
||||||
|
|
||||||
static struct gpbridge_driver spi_driver = {
|
|
||||||
.name = "spi",
|
|
||||||
.probe = gb_spi_probe,
|
|
||||||
.remove = gb_spi_remove,
|
|
||||||
.id_table = gb_spi_id_table,
|
|
||||||
};
|
|
||||||
|
|
||||||
module_gpbridge_driver(spi_driver);
|
|
||||||
MODULE_LICENSE("GPL v2");
|
MODULE_LICENSE("GPL v2");
|
||||||
|
|
Loading…
Reference in New Issue