Commit 3038e353 authored by Kristian Høgsberg's avatar Kristian Høgsberg Committed by Stefan Richter

firewire: Add core firewire stack.

Signed-off-by: default avatarKristian Høgsberg <krh@redhat.com>
Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
parent 08e15e81
...@@ -30,6 +30,8 @@ source "drivers/md/Kconfig" ...@@ -30,6 +30,8 @@ source "drivers/md/Kconfig"
source "drivers/message/fusion/Kconfig" source "drivers/message/fusion/Kconfig"
source "drivers/firewire/Kconfig"
source "drivers/ieee1394/Kconfig" source "drivers/ieee1394/Kconfig"
source "drivers/message/i2o/Kconfig" source "drivers/message/i2o/Kconfig"
......
...@@ -36,6 +36,7 @@ obj-$(CONFIG_FC4) += fc4/ ...@@ -36,6 +36,7 @@ obj-$(CONFIG_FC4) += fc4/
obj-$(CONFIG_SCSI) += scsi/ obj-$(CONFIG_SCSI) += scsi/
obj-$(CONFIG_ATA) += ata/ obj-$(CONFIG_ATA) += ata/
obj-$(CONFIG_FUSION) += message/ obj-$(CONFIG_FUSION) += message/
obj-$(CONFIG_FW) += firewire/
obj-$(CONFIG_IEEE1394) += ieee1394/ obj-$(CONFIG_IEEE1394) += ieee1394/
obj-y += cdrom/ obj-y += cdrom/
obj-y += auxdisplay/ obj-y += auxdisplay/
......
# -*- shell-script -*-
menu "IEEE 1394 (FireWire) support (JUJU alternative stack)"
config FW
tristate "IEEE 1394 (FireWire) support (JUJU alternative stack)"
help
IEEE 1394 describes a high performance serial bus, which is also
known as FireWire(tm) or i.Link(tm) and is used for connecting all
sorts of devices (most notably digital video cameras) to your
computer.
If you have FireWire hardware and want to use it, say Y here. This
is the core support only, you will also need to select a driver for
your IEEE 1394 adapter.
This is the "JUJU" firewire stack, an alternative
implementation designed for roboustness and simplicity.
To compile this driver as a module, say M here: the
module will be called fw-core.
endmenu
#
# Makefile for the Linux IEEE 1394 implementation
#
fw-core-objs := fw-card.o fw-topology.o fw-transaction.o fw-iso.o
obj-$(CONFIG_FW) += fw-core.o
This diff is collapsed.
/* -*- c-basic-offset: 8 -*-
*
* fw-iso.c - Isochronous IO
* Copyright (C) 2006 Kristian Hoegsberg <krh@bitplanet.net>
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/dma-mapping.h>
#include <linux/vmalloc.h>
#include <linux/mm.h>
#include "fw-transaction.h"
#include "fw-topology.h"
static int
setup_iso_buffer(struct fw_iso_context *ctx, size_t size,
enum dma_data_direction direction)
{
struct page *page;
int i;
void *p;
ctx->buffer_size = PAGE_ALIGN(size);
if (size == 0)
return 0;
ctx->buffer = vmalloc_32_user(ctx->buffer_size);
if (ctx->buffer == NULL)
return -ENOMEM;
ctx->page_count = ctx->buffer_size >> PAGE_SHIFT;
ctx->pages =
kzalloc(ctx->page_count * sizeof(ctx->pages[0]), GFP_KERNEL);
if (ctx->pages == NULL) {
vfree(ctx->buffer);
return -ENOMEM;
}
p = ctx->buffer;
for (i = 0; i < ctx->page_count; i++, p += PAGE_SIZE) {
page = vmalloc_to_page(p);
ctx->pages[i] = dma_map_page(ctx->card->device,
page, 0, PAGE_SIZE, direction);
}
return 0;
}
static void destroy_iso_buffer(struct fw_iso_context *ctx)
{
int i;
for (i = 0; i < ctx->page_count; i++)
dma_unmap_page(ctx->card->device, ctx->pages[i],
PAGE_SIZE, DMA_TO_DEVICE);
kfree(ctx->pages);
vfree(ctx->buffer);
}
struct fw_iso_context *fw_iso_context_create(struct fw_card *card, int type,
size_t buffer_size,
fw_iso_callback_t callback,
void *callback_data)
{
struct fw_iso_context *ctx;
int retval;
ctx = card->driver->allocate_iso_context(card, type);
if (IS_ERR(ctx))
return ctx;
ctx->card = card;
ctx->type = type;
ctx->callback = callback;
ctx->callback_data = callback_data;
retval = setup_iso_buffer(ctx, buffer_size, DMA_TO_DEVICE);
if (retval < 0) {
card->driver->free_iso_context(ctx);
return ERR_PTR(retval);
}
return ctx;
}
EXPORT_SYMBOL(fw_iso_context_create);
void fw_iso_context_destroy(struct fw_iso_context *ctx)
{
struct fw_card *card = ctx->card;
destroy_iso_buffer(ctx);
card->driver->free_iso_context(ctx);
}
EXPORT_SYMBOL(fw_iso_context_destroy);
int
fw_iso_context_send(struct fw_iso_context *ctx,
int channel, int speed, int cycle)
{
ctx->channel = channel;
ctx->speed = speed;
return ctx->card->driver->send_iso(ctx, cycle);
}
EXPORT_SYMBOL(fw_iso_context_send);
int
fw_iso_context_queue(struct fw_iso_context *ctx,
struct fw_iso_packet *packet, void *payload)
{
struct fw_card *card = ctx->card;
return card->driver->queue_iso(ctx, packet, payload);
}
EXPORT_SYMBOL(fw_iso_context_queue);
This diff is collapsed.
/* -*- c-basic-offset: 8 -*-
*
* fw-topology.h -- Incremental bus scan, based on bus topology
*
* Copyright (C) 2003-2006 Kristian Hoegsberg <krh@bitplanet.net>
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __fw_topology_h
#define __fw_topology_h
enum {
FW_NODE_CREATED = 0x00,
FW_NODE_UPDATED = 0x01,
FW_NODE_DESTROYED = 0x02,
FW_NODE_LINK_ON = 0x03,
FW_NODE_LINK_OFF = 0x04
};
struct fw_port {
struct fw_node *node;
unsigned speed : 3; /* S100, S200, ... S3200 */
};
struct fw_node {
u16 node_id;
u8 color;
u8 port_count;
unsigned link_on : 1;
unsigned initiated_reset : 1;
unsigned b_path : 1;
u8 phy_speed; /* As in the self ID packet. */
u8 max_speed; /* Minimum of all phy-speeds and port speeds on
* the path from the local node to this node. */
atomic_t ref_count;
/* For serializing node topology into a list. */
struct list_head link;
/* Upper layer specific data. */
void *data;
struct fw_port ports[0];
};
extern inline struct fw_node *
fw_node(struct list_head *l)
{
return list_entry (l, struct fw_node, link);
}
extern inline struct fw_node *
fw_node_get(struct fw_node *node)
{
atomic_inc(&node->ref_count);
return node;
}
extern inline void
fw_node_put(struct fw_node *node)
{
if (atomic_dec_and_test(&node->ref_count))
kfree(node);
}
void
fw_destroy_nodes(struct fw_card *card);
#endif
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment