diff options
| -rw-r--r-- | drivers/Kconfig | 2 | ||||
| -rw-r--r-- | drivers/Makefile | 1 | ||||
| -rw-r--r-- | drivers/hsi/Kconfig | 17 | ||||
| -rw-r--r-- | drivers/hsi/Makefile | 5 | ||||
| -rw-r--r-- | drivers/hsi/hsi.c | 494 | ||||
| -rw-r--r-- | drivers/hsi/hsi_boardinfo.c | 62 | ||||
| -rw-r--r-- | drivers/hsi/hsi_core.h | 35 | ||||
| -rw-r--r-- | include/linux/hsi/hsi.h | 410 |
8 files changed, 1026 insertions, 0 deletions
diff --git a/drivers/Kconfig b/drivers/Kconfig index b5e6f243f749..52895081db0b 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig | |||
| @@ -52,6 +52,8 @@ source "drivers/i2c/Kconfig" | |||
| 52 | 52 | ||
| 53 | source "drivers/spi/Kconfig" | 53 | source "drivers/spi/Kconfig" |
| 54 | 54 | ||
| 55 | source "drivers/hsi/Kconfig" | ||
| 56 | |||
| 55 | source "drivers/pps/Kconfig" | 57 | source "drivers/pps/Kconfig" |
| 56 | 58 | ||
| 57 | source "drivers/ptp/Kconfig" | 59 | source "drivers/ptp/Kconfig" |
diff --git a/drivers/Makefile b/drivers/Makefile index 1b3142127bf5..91077ac6b156 100644 --- a/drivers/Makefile +++ b/drivers/Makefile | |||
| @@ -53,6 +53,7 @@ obj-$(CONFIG_ATA) += ata/ | |||
| 53 | obj-$(CONFIG_TARGET_CORE) += target/ | 53 | obj-$(CONFIG_TARGET_CORE) += target/ |
| 54 | obj-$(CONFIG_MTD) += mtd/ | 54 | obj-$(CONFIG_MTD) += mtd/ |
| 55 | obj-$(CONFIG_SPI) += spi/ | 55 | obj-$(CONFIG_SPI) += spi/ |
| 56 | obj-y += hsi/ | ||
| 56 | obj-y += net/ | 57 | obj-y += net/ |
| 57 | obj-$(CONFIG_ATM) += atm/ | 58 | obj-$(CONFIG_ATM) += atm/ |
| 58 | obj-$(CONFIG_FUSION) += message/ | 59 | obj-$(CONFIG_FUSION) += message/ |
diff --git a/drivers/hsi/Kconfig b/drivers/hsi/Kconfig new file mode 100644 index 000000000000..937062e8bcd0 --- /dev/null +++ b/drivers/hsi/Kconfig | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | # | ||
| 2 | # HSI driver configuration | ||
| 3 | # | ||
| 4 | menuconfig HSI | ||
| 5 | tristate "HSI support" | ||
| 6 | ---help--- | ||
| 7 | The "High speed synchronous Serial Interface" is | ||
| 8 | synchronous serial interface used mainly to connect | ||
| 9 | application engines and cellular modems. | ||
| 10 | |||
| 11 | if HSI | ||
| 12 | |||
| 13 | config HSI_BOARDINFO | ||
| 14 | bool | ||
| 15 | default y | ||
| 16 | |||
| 17 | endif # HSI | ||
diff --git a/drivers/hsi/Makefile b/drivers/hsi/Makefile new file mode 100644 index 000000000000..ed94a3a334a4 --- /dev/null +++ b/drivers/hsi/Makefile | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | # | ||
| 2 | # Makefile for HSI | ||
| 3 | # | ||
| 4 | obj-$(CONFIG_HSI_BOARDINFO) += hsi_boardinfo.o | ||
| 5 | obj-$(CONFIG_HSI) += hsi.o | ||
diff --git a/drivers/hsi/hsi.c b/drivers/hsi/hsi.c new file mode 100644 index 000000000000..4e2d79b79334 --- /dev/null +++ b/drivers/hsi/hsi.c | |||
| @@ -0,0 +1,494 @@ | |||
| 1 | /* | ||
| 2 | * HSI core. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2010 Nokia Corporation. All rights reserved. | ||
| 5 | * | ||
| 6 | * Contact: Carlos Chinea <carlos.chinea@nokia.com> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or | ||
| 9 | * modify it under the terms of the GNU General Public License | ||
| 10 | * version 2 as published by the Free Software Foundation. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, but | ||
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| 20 | * 02110-1301 USA | ||
| 21 | */ | ||
| 22 | #include <linux/hsi/hsi.h> | ||
| 23 | #include <linux/compiler.h> | ||
| 24 | #include <linux/rwsem.h> | ||
| 25 | #include <linux/list.h> | ||
| 26 | #include <linux/spinlock.h> | ||
| 27 | #include <linux/kobject.h> | ||
| 28 | #include <linux/slab.h> | ||
| 29 | #include <linux/string.h> | ||
| 30 | #include "hsi_core.h" | ||
| 31 | |||
| 32 | static struct device_type hsi_ctrl = { | ||
| 33 | .name = "hsi_controller", | ||
| 34 | }; | ||
| 35 | |||
| 36 | static struct device_type hsi_cl = { | ||
| 37 | .name = "hsi_client", | ||
| 38 | }; | ||
| 39 | |||
| 40 | static struct device_type hsi_port = { | ||
| 41 | .name = "hsi_port", | ||
| 42 | }; | ||
| 43 | |||
| 44 | static ssize_t modalias_show(struct device *dev, | ||
| 45 | struct device_attribute *a __maybe_unused, char *buf) | ||
| 46 | { | ||
| 47 | return sprintf(buf, "hsi:%s\n", dev_name(dev)); | ||
| 48 | } | ||
| 49 | |||
| 50 | static struct device_attribute hsi_bus_dev_attrs[] = { | ||
| 51 | __ATTR_RO(modalias), | ||
| 52 | __ATTR_NULL, | ||
| 53 | }; | ||
| 54 | |||
| 55 | static int hsi_bus_uevent(struct device *dev, struct kobj_uevent_env *env) | ||
| 56 | { | ||
| 57 | if (dev->type == &hsi_cl) | ||
| 58 | add_uevent_var(env, "MODALIAS=hsi:%s", dev_name(dev)); | ||
| 59 | |||
| 60 | return 0; | ||
| 61 | } | ||
| 62 | |||
| 63 | static int hsi_bus_match(struct device *dev, struct device_driver *driver) | ||
| 64 | { | ||
| 65 | return strcmp(dev_name(dev), driver->name) == 0; | ||
| 66 | } | ||
| 67 | |||
| 68 | static struct bus_type hsi_bus_type = { | ||
| 69 | .name = "hsi", | ||
| 70 | .dev_attrs = hsi_bus_dev_attrs, | ||
| 71 | .match = hsi_bus_match, | ||
| 72 | .uevent = hsi_bus_uevent, | ||
| 73 | }; | ||
| 74 | |||
| 75 | static void hsi_client_release(struct device *dev) | ||
| 76 | { | ||
| 77 | kfree(to_hsi_client(dev)); | ||
| 78 | } | ||
| 79 | |||
| 80 | static void hsi_new_client(struct hsi_port *port, struct hsi_board_info *info) | ||
| 81 | { | ||
| 82 | struct hsi_client *cl; | ||
| 83 | unsigned long flags; | ||
| 84 | |||
| 85 | cl = kzalloc(sizeof(*cl), GFP_KERNEL); | ||
| 86 | if (!cl) | ||
| 87 | return; | ||
| 88 | cl->device.type = &hsi_cl; | ||
| 89 | cl->tx_cfg = info->tx_cfg; | ||
| 90 | cl->rx_cfg = info->rx_cfg; | ||
| 91 | cl->device.bus = &hsi_bus_type; | ||
| 92 | cl->device.parent = &port->device; | ||
| 93 | cl->device.release = hsi_client_release; | ||
| 94 | dev_set_name(&cl->device, info->name); | ||
| 95 | cl->device.platform_data = info->platform_data; | ||
| 96 | spin_lock_irqsave(&port->clock, flags); | ||
| 97 | list_add_tail(&cl->link, &port->clients); | ||
| 98 | spin_unlock_irqrestore(&port->clock, flags); | ||
| 99 | if (info->archdata) | ||
| 100 | cl->device.archdata = *info->archdata; | ||
| 101 | if (device_register(&cl->device) < 0) { | ||
| 102 | pr_err("hsi: failed to register client: %s\n", info->name); | ||
| 103 | kfree(cl); | ||
| 104 | } | ||
| 105 | } | ||
| 106 | |||
| 107 | static void hsi_scan_board_info(struct hsi_controller *hsi) | ||
| 108 | { | ||
| 109 | struct hsi_cl_info *cl_info; | ||
| 110 | struct hsi_port *p; | ||
| 111 | |||
| 112 | list_for_each_entry(cl_info, &hsi_board_list, list) | ||
| 113 | if (cl_info->info.hsi_id == hsi->id) { | ||
| 114 | p = hsi_find_port_num(hsi, cl_info->info.port); | ||
| 115 | if (!p) | ||
| 116 | continue; | ||
| 117 | hsi_new_client(p, &cl_info->info); | ||
| 118 | } | ||
| 119 | } | ||
| 120 | |||
| 121 | static int hsi_remove_client(struct device *dev, void *data __maybe_unused) | ||
| 122 | { | ||
| 123 | struct hsi_client *cl = to_hsi_client(dev); | ||
| 124 | struct hsi_port *port = to_hsi_port(dev->parent); | ||
| 125 | unsigned long flags; | ||
| 126 | |||
| 127 | spin_lock_irqsave(&port->clock, flags); | ||
| 128 | list_del(&cl->link); | ||
| 129 | spin_unlock_irqrestore(&port->clock, flags); | ||
| 130 | device_unregister(dev); | ||
| 131 | |||
| 132 | return 0; | ||
| 133 | } | ||
| 134 | |||
| 135 | static int hsi_remove_port(struct device *dev, void *data __maybe_unused) | ||
| 136 | { | ||
| 137 | device_for_each_child(dev, NULL, hsi_remove_client); | ||
| 138 | device_unregister(dev); | ||
| 139 | |||
| 140 | return 0; | ||
| 141 | } | ||
| 142 | |||
| 143 | static void hsi_controller_release(struct device *dev __maybe_unused) | ||
| 144 | { | ||
| 145 | } | ||
| 146 | |||
| 147 | static void hsi_port_release(struct device *dev __maybe_unused) | ||
| 148 | { | ||
| 149 | } | ||
| 150 | |||
| 151 | /** | ||
| 152 | * hsi_unregister_controller - Unregister an HSI controller | <||
