Greg Kroah-Hartman | e1308c1 | 2014-12-24 13:01:43 -0800 | [diff] [blame] | 1 | /* |
| 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" |
| 20 | |
| 21 | |
| 22 | static 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-Hartman | 2c07817 | 2014-12-24 13:01:44 -0800 | [diff] [blame] | 44 | if (gb_i2c_protocol_init()) { |
Viresh Kumar | b908dec4 | 2015-03-10 14:41:12 +0530 | [diff] [blame] | 45 | pr_err("error initializing i2c protocol\n"); |
Greg Kroah-Hartman | 2c07817 | 2014-12-24 13:01:44 -0800 | [diff] [blame] | 46 | goto error_i2c; |
| 47 | } |
Viresh Kumar | 15d651b | 2015-01-23 13:07:45 +0530 | [diff] [blame] | 48 | if (gb_spi_protocol_init()) { |
Viresh Kumar | b908dec4 | 2015-03-10 14:41:12 +0530 | [diff] [blame] | 49 | pr_err("error initializing spi protocol\n"); |
Viresh Kumar | 15d651b | 2015-01-23 13:07:45 +0530 | [diff] [blame] | 50 | goto error_spi; |
| 51 | } |
Viresh Kumar | 96eab77 | 2015-03-16 16:49:37 +0530 | [diff] [blame] | 52 | if (gb_hid_protocol_init()) { |
| 53 | pr_err("error initializing hid protocol\n"); |
| 54 | goto error_hid; |
| 55 | } |
Greg Kroah-Hartman | e1308c1 | 2014-12-24 13:01:43 -0800 | [diff] [blame] | 56 | return 0; |
| 57 | |
Viresh Kumar | 96eab77 | 2015-03-16 16:49:37 +0530 | [diff] [blame] | 58 | error_hid: |
| 59 | gb_spi_protocol_exit(); |
Viresh Kumar | 15d651b | 2015-01-23 13:07:45 +0530 | [diff] [blame] | 60 | error_spi: |
| 61 | gb_i2c_protocol_exit(); |
Greg Kroah-Hartman | 2c07817 | 2014-12-24 13:01:44 -0800 | [diff] [blame] | 62 | error_i2c: |
| 63 | gb_usb_protocol_exit(); |
Greg Kroah-Hartman | e1308c1 | 2014-12-24 13:01:43 -0800 | [diff] [blame] | 64 | error_usb: |
| 65 | gb_sdio_protocol_exit(); |
| 66 | error_sdio: |
| 67 | gb_uart_protocol_exit(); |
| 68 | error_uart: |
| 69 | gb_pwm_protocol_exit(); |
| 70 | error_pwm: |
| 71 | gb_gpio_protocol_exit(); |
| 72 | error_gpio: |
| 73 | return -EPROTO; |
| 74 | } |
Viresh Kumar | 0d34be7 | 2015-03-24 20:14:28 +0530 | [diff] [blame^] | 75 | module_init(gpbridge_init); |
Greg Kroah-Hartman | e1308c1 | 2014-12-24 13:01:43 -0800 | [diff] [blame] | 76 | |
| 77 | static void __exit gpbridge_exit(void) |
| 78 | { |
Viresh Kumar | 96eab77 | 2015-03-16 16:49:37 +0530 | [diff] [blame] | 79 | gb_hid_protocol_exit(); |
Viresh Kumar | 15d651b | 2015-01-23 13:07:45 +0530 | [diff] [blame] | 80 | gb_spi_protocol_exit(); |
Greg Kroah-Hartman | 2c07817 | 2014-12-24 13:01:44 -0800 | [diff] [blame] | 81 | gb_i2c_protocol_exit(); |
Greg Kroah-Hartman | e1308c1 | 2014-12-24 13:01:43 -0800 | [diff] [blame] | 82 | gb_usb_protocol_exit(); |
| 83 | gb_sdio_protocol_exit(); |
| 84 | gb_uart_protocol_exit(); |
| 85 | gb_pwm_protocol_exit(); |
| 86 | gb_gpio_protocol_exit(); |
| 87 | } |
Greg Kroah-Hartman | e1308c1 | 2014-12-24 13:01:43 -0800 | [diff] [blame] | 88 | module_exit(gpbridge_exit); |
| 89 | |
| 90 | MODULE_LICENSE("GPL"); |