blob: 9be936cb422f9a117ef7eb484280c7bb6bf6e4e9 [file] [log] [blame]
Greg Kroah-Hartmane1308c12014-12-24 13:01:43 -08001/*
2 * Greybus GP Bridge driver
3 *
4 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */
9
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
12#include <linux/types.h>
13#include <linux/module.h>
14#include <linux/moduleparam.h>
15#include <linux/kernel.h>
16#include <linux/slab.h>
17#include <linux/device.h>
18
19#include "greybus.h"
Greg Kroah-Hartmanc7b07262016-02-28 14:42:54 -080020#include "gpbridge.h"
Greg Kroah-Hartmane1308c12014-12-24 13:01:43 -080021
22static int __init gpbridge_init(void)
23{
24 if (gb_gpio_protocol_init()) {
25 pr_err("error initializing gpio protocol\n");
26 goto error_gpio;
27 }
28 if (gb_pwm_protocol_init()) {
29 pr_err("error initializing pwm protocol\n");
30 goto error_pwm;
31 }
32 if (gb_uart_protocol_init()) {
33 pr_err("error initializing uart protocol\n");
34 goto error_uart;
35 }
36 if (gb_sdio_protocol_init()) {
37 pr_err("error initializing sdio protocol\n");
38 goto error_sdio;
39 }
40 if (gb_usb_protocol_init()) {
41 pr_err("error initializing usb protocol\n");
42 goto error_usb;
43 }
Greg Kroah-Hartman2c078172014-12-24 13:01:44 -080044 if (gb_i2c_protocol_init()) {
Viresh Kumarb908dec42015-03-10 14:41:12 +053045 pr_err("error initializing i2c protocol\n");
Greg Kroah-Hartman2c078172014-12-24 13:01:44 -080046 goto error_i2c;
47 }
Viresh Kumar15d651b2015-01-23 13:07:45 +053048 if (gb_spi_protocol_init()) {
Viresh Kumarb908dec42015-03-10 14:41:12 +053049 pr_err("error initializing spi protocol\n");
Viresh Kumar15d651b2015-01-23 13:07:45 +053050 goto error_spi;
51 }
John Stultza4749bb2015-05-08 12:57:36 -070052
Greg Kroah-Hartmane1308c12014-12-24 13:01:43 -080053 return 0;
54
Viresh Kumar15d651b2015-01-23 13:07:45 +053055error_spi:
56 gb_i2c_protocol_exit();
Greg Kroah-Hartman2c078172014-12-24 13:01:44 -080057error_i2c:
58 gb_usb_protocol_exit();
Greg Kroah-Hartmane1308c12014-12-24 13:01:43 -080059error_usb:
60 gb_sdio_protocol_exit();
61error_sdio:
62 gb_uart_protocol_exit();
63error_uart:
64 gb_pwm_protocol_exit();
65error_pwm:
66 gb_gpio_protocol_exit();
67error_gpio:
68 return -EPROTO;
69}
Viresh Kumar0d34be72015-03-24 20:14:28 +053070module_init(gpbridge_init);
Greg Kroah-Hartmane1308c12014-12-24 13:01:43 -080071
72static void __exit gpbridge_exit(void)
73{
Viresh Kumar15d651b2015-01-23 13:07:45 +053074 gb_spi_protocol_exit();
Greg Kroah-Hartman2c078172014-12-24 13:01:44 -080075 gb_i2c_protocol_exit();
Greg Kroah-Hartmane1308c12014-12-24 13:01:43 -080076 gb_usb_protocol_exit();
77 gb_sdio_protocol_exit();
78 gb_uart_protocol_exit();
79 gb_pwm_protocol_exit();
80 gb_gpio_protocol_exit();
81}
Greg Kroah-Hartmane1308c12014-12-24 13:01:43 -080082module_exit(gpbridge_exit);
83
Greg Kroah-Hartmand6fefbe2016-02-28 14:13:27 -080084/*
85 * One large list of all classes we support in the gpbridge.ko module.
86 *
87 * Due to limitations in older kernels, the different phy .c files can not
88 * contain their own MODULE_DEVICE_TABLE(), so put them all here for now.
89 */
90static const struct greybus_bundle_id bridged_phy_id_table[] = {
91 { GREYBUS_DEVICE_CLASS(GREYBUS_CLASS_BRIDGED_PHY) },
92 { },
93};
94MODULE_DEVICE_TABLE(greybus, bridged_phy_id_table);
95
Greg Kroah-Hartman6cf42a42015-04-13 19:51:33 +020096MODULE_LICENSE("GPL v2");