2005-04-17 02:20:36 +04:00
|
|
|
#ifndef _IEEE1394_CORE_H
|
|
|
|
#define _IEEE1394_CORE_H
|
|
|
|
|
2006-07-03 20:02:29 +04:00
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/types.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <asm/atomic.h>
|
|
|
|
|
2006-07-03 20:02:29 +04:00
|
|
|
#include "hosts.h"
|
|
|
|
#include "ieee1394_types.h"
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
struct hpsb_packet {
|
2005-12-02 02:52:03 +03:00
|
|
|
/* This struct is basically read-only for hosts with the exception of
|
2007-03-26 00:22:40 +04:00
|
|
|
* the data buffer contents and driver_list. */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* This can be used for host driver internal linking.
|
|
|
|
*
|
|
|
|
* NOTE: This must be left in init state when the driver is done
|
|
|
|
* with it (e.g. by using list_del_init()), since the core does
|
|
|
|
* some sanity checks to make sure the packet is not on a
|
|
|
|
* driver_list when free'ing it. */
|
|
|
|
struct list_head driver_list;
|
|
|
|
|
2005-12-02 02:52:03 +03:00
|
|
|
nodeid_t node_id;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-06-24 17:31:54 +04:00
|
|
|
/* hpsb_raw = send as-is, do not CRC (but still byte-swap it) */
|
|
|
|
enum { hpsb_async, hpsb_raw } __attribute__((packed)) type;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-12-02 02:52:03 +03:00
|
|
|
/* Okay, this is core internal and a no care for hosts.
|
|
|
|
* queued = queued for sending
|
|
|
|
* pending = sent, waiting for response
|
|
|
|
* complete = processing completed, successful or not
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
hpsb_unused, hpsb_queued, hpsb_pending, hpsb_complete
|
|
|
|
} __attribute__((packed)) state;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-05-19 14:29:37 +04:00
|
|
|
/* These are core-internal. */
|
2005-12-02 02:52:03 +03:00
|
|
|
signed char tlabel;
|
2005-07-07 00:05:50 +04:00
|
|
|
signed char ack_code;
|
|
|
|
unsigned char tcode;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-12-02 02:52:03 +03:00
|
|
|
unsigned expect_response:1;
|
|
|
|
unsigned no_waiter:1;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-12-02 02:52:03 +03:00
|
|
|
/* Speed to transmit with: 0 = 100Mbps, 1 = 200Mbps, 2 = 400Mbps */
|
|
|
|
unsigned speed_code:2;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-12-02 02:52:03 +03:00
|
|
|
struct hpsb_host *host;
|
|
|
|
unsigned int generation;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
atomic_t refcnt;
|
2007-03-26 00:22:40 +04:00
|
|
|
struct list_head queue;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* Function (and possible data to pass to it) to call when this
|
|
|
|
* packet is completed. */
|
|
|
|
void (*complete_routine)(void *);
|
|
|
|
void *complete_data;
|
|
|
|
|
2005-12-02 02:52:03 +03:00
|
|
|
/* Store jiffies for implementing bus timeouts. */
|
|
|
|
unsigned long sendtime;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-05-19 14:29:37 +04:00
|
|
|
/* Core-internal. */
|
2007-03-26 00:22:40 +04:00
|
|
|
size_t allocated_data_size; /* as allocated */
|
2007-05-19 14:29:37 +04:00
|
|
|
|
|
|
|
/* Sizes are in bytes. To be set by caller of hpsb_alloc_packet. */
|
2007-03-26 00:22:40 +04:00
|
|
|
size_t data_size; /* as filled in */
|
|
|
|
size_t header_size; /* as filled in, not counting the CRC */
|
2007-05-19 14:29:37 +04:00
|
|
|
|
|
|
|
/* Buffers */
|
|
|
|
quadlet_t *data; /* can be DMA-mapped */
|
2007-03-26 00:22:40 +04:00
|
|
|
quadlet_t header[5];
|
|
|
|
quadlet_t embedded_data[0]; /* keep as last member */
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
void hpsb_set_packet_complete_task(struct hpsb_packet *packet,
|
2006-07-03 20:02:28 +04:00
|
|
|
void (*routine)(void *), void *data);
|
2005-04-17 02:20:36 +04:00
|
|
|
static inline struct hpsb_packet *driver_packet(struct list_head *l)
|
|
|
|
{
|
|
|
|
return list_entry(l, struct hpsb_packet, driver_list);
|
|
|
|
}
|
|
|
|
void abort_timedouts(unsigned long __opaque);
|
|
|
|
struct hpsb_packet *hpsb_alloc_packet(size_t data_size);
|
|
|
|
void hpsb_free_packet(struct hpsb_packet *packet);
|
|
|
|
|
2007-03-05 05:06:23 +03:00
|
|
|
/**
|
|
|
|
* get_hpsb_generation - generation counter for the complete 1394 subsystem
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
2007-03-05 05:06:23 +03:00
|
|
|
* Generation gets incremented on every change in the subsystem (notably on bus
|
|
|
|
* resets). Use the functions, not the variable.
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
static inline unsigned int get_hpsb_generation(struct hpsb_host *host)
|
|
|
|
{
|
2005-12-02 02:52:03 +03:00
|
|
|
return atomic_read(&host->generation);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt);
|
|
|
|
int hpsb_send_packet(struct hpsb_packet *packet);
|
|
|
|
int hpsb_send_packet_and_wait(struct hpsb_packet *packet);
|
|
|
|
int hpsb_reset_bus(struct hpsb_host *host, int type);
|
2007-02-03 19:44:39 +03:00
|
|
|
int hpsb_read_cycle_timer(struct hpsb_host *host, u32 *cycle_timer,
|
|
|
|
u64 *local_time);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
int hpsb_bus_reset(struct hpsb_host *host);
|
|
|
|
void hpsb_selfid_received(struct hpsb_host *host, quadlet_t sid);
|
|
|
|
void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot);
|
|
|
|
void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet,
|
2005-12-02 02:52:03 +03:00
|
|
|
int ackcode);
|
2005-04-17 02:20:36 +04:00
|
|
|
void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
|
2005-12-02 02:52:03 +03:00
|
|
|
int write_acked);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CHARACTER DEVICE DISPATCHING
|
|
|
|
*
|
|
|
|
* All ieee1394 character device drivers share the same major number
|
|
|
|
* (major 171). The 256 minor numbers are allocated to the various
|
|
|
|
* task-specific interfaces (raw1394, video1394, dv1394, etc) in
|
|
|
|
* blocks of 16.
|
|
|
|
*
|
|
|
|
* The core ieee1394.o module allocates the device number region
|
|
|
|
* 171:0-255, the various drivers must then cdev_add() their cdev
|
|
|
|
* objects to handle their respective sub-regions.
|
|
|
|
*
|
|
|
|
* Minor device number block allocations:
|
|
|
|
*
|
|
|
|
* Block 0 ( 0- 15) raw1394
|
|
|
|
* Block 1 ( 16- 31) video1394
|
|
|
|
* Block 2 ( 32- 47) dv1394
|
|
|
|
*
|
|
|
|
* Blocks 3-14 free for future allocation
|
|
|
|
*
|
|
|
|
* Block 15 (240-255) reserved for drivers under development, etc.
|
|
|
|
*/
|
|
|
|
|
2005-12-02 02:52:03 +03:00
|
|
|
#define IEEE1394_MAJOR 171
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-12-02 02:52:03 +03:00
|
|
|
#define IEEE1394_MINOR_BLOCK_RAW1394 0
|
|
|
|
#define IEEE1394_MINOR_BLOCK_VIDEO1394 1
|
|
|
|
#define IEEE1394_MINOR_BLOCK_DV1394 2
|
2005-04-17 02:20:36 +04:00
|
|
|
#define IEEE1394_MINOR_BLOCK_EXPERIMENTAL 15
|
|
|
|
|
2005-12-02 02:52:03 +03:00
|
|
|
#define IEEE1394_CORE_DEV MKDEV(IEEE1394_MAJOR, 0)
|
2006-07-03 20:02:28 +04:00
|
|
|
#define IEEE1394_RAW1394_DEV MKDEV(IEEE1394_MAJOR, \
|
|
|
|
IEEE1394_MINOR_BLOCK_RAW1394 * 16)
|
|
|
|
#define IEEE1394_VIDEO1394_DEV MKDEV(IEEE1394_MAJOR, \
|
|
|
|
IEEE1394_MINOR_BLOCK_VIDEO1394 * 16)
|
|
|
|
#define IEEE1394_DV1394_DEV MKDEV(IEEE1394_MAJOR, \
|
|
|
|
IEEE1394_MINOR_BLOCK_DV1394 * 16)
|
|
|
|
#define IEEE1394_EXPERIMENTAL_DEV MKDEV(IEEE1394_MAJOR, \
|
|
|
|
IEEE1394_MINOR_BLOCK_EXPERIMENTAL * 16)
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-03-05 05:06:23 +03:00
|
|
|
/**
|
|
|
|
* ieee1394_file_to_instance - get the index within a minor number block
|
|
|
|
*/
|
2005-04-17 02:20:36 +04:00
|
|
|
static inline unsigned char ieee1394_file_to_instance(struct file *file)
|
|
|
|
{
|
2006-12-08 13:37:10 +03:00
|
|
|
return file->f_path.dentry->d_inode->i_cindex;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
extern int hpsb_disable_irm;
|
|
|
|
|
|
|
|
/* Our sysfs bus entry */
|
|
|
|
extern struct bus_type ieee1394_bus_type;
|
|
|
|
extern struct class hpsb_host_class;
|
2005-03-23 20:53:36 +03:00
|
|
|
extern struct class *hpsb_protocol_class;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#endif /* _IEEE1394_CORE_H */
|