blob: 34b360da9ff9ca76f9b2b617210d67356750a14f [file] [log] [blame]
Geoff Levand74e95d5d2006-12-08 18:27:47 -08001/*
2 * PS3 virtual uart
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#if !defined(_PS3_VUART_H)
22#define _PS3_VUART_H
23
Geoff Levand75c86e72007-02-13 17:37:28 -080024#include <asm/ps3.h>
25
26struct ps3_vuart_stats {
27 unsigned long bytes_written;
28 unsigned long bytes_read;
29 unsigned long tx_interrupts;
30 unsigned long rx_interrupts;
31 unsigned long disconnect_interrupts;
32};
33
34/**
35 * struct ps3_vuart_port_priv - private vuart device data.
36 */
37
38struct ps3_vuart_port_priv {
39 unsigned int port_number;
40 u64 interrupt_mask;
41
42 struct {
43 spinlock_t lock;
44 struct list_head head;
45 } tx_list;
46 struct {
47 unsigned long bytes_held;
48 spinlock_t lock;
49 struct list_head head;
50 } rx_list;
51 struct ps3_vuart_stats stats;
52};
53
Geoff Levand74e95d5d2006-12-08 18:27:47 -080054/**
55 * struct ps3_vuart_port_driver - a driver for a device on a vuart port
56 */
57
58struct ps3_vuart_port_driver {
59 enum ps3_match_id match_id;
60 struct device_driver core;
61 int (*probe)(struct ps3_vuart_port_device *);
62 int (*remove)(struct ps3_vuart_port_device *);
Geert Uytterhoeven5b8e8ee2007-02-12 00:55:15 -080063 void (*shutdown)(struct ps3_vuart_port_device *);
Geoff Levand74e95d5d2006-12-08 18:27:47 -080064 int (*tx_event)(struct ps3_vuart_port_device *dev);
65 int (*rx_event)(struct ps3_vuart_port_device *dev);
66 int (*disconnect_event)(struct ps3_vuart_port_device *dev);
67 /* int (*suspend)(struct ps3_vuart_port_device *, pm_message_t); */
68 /* int (*resume)(struct ps3_vuart_port_device *); */
69};
70
Geoff Levand74e95d5d2006-12-08 18:27:47 -080071int ps3_vuart_port_driver_register(struct ps3_vuart_port_driver *drv);
72void ps3_vuart_port_driver_unregister(struct ps3_vuart_port_driver *drv);
Geoff Levand97ec1672007-01-30 15:20:30 -080073
Geoff Levand74e95d5d2006-12-08 18:27:47 -080074int ps3_vuart_write(struct ps3_vuart_port_device *dev,
75 const void* buf, unsigned int bytes);
76int ps3_vuart_read(struct ps3_vuart_port_device *dev, void* buf,
77 unsigned int bytes);
78static inline struct ps3_vuart_port_driver *to_ps3_vuart_port_driver(
79 struct device_driver *_drv)
80{
81 return container_of(_drv, struct ps3_vuart_port_driver, core);
82}
83static inline struct ps3_vuart_port_device *to_ps3_vuart_port_device(
84 struct device *_dev)
85{
86 return container_of(_dev, struct ps3_vuart_port_device, core);
87}
88
Geoff Levand74e95d5d2006-12-08 18:27:47 -080089#endif