Geoff Levand | 74e95d5d | 2006-12-08 18:27:47 -0800 | [diff] [blame] | 1 | /* |
| 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 Levand | 75c86e7 | 2007-02-13 17:37:28 -0800 | [diff] [blame] | 24 | #include <asm/ps3.h> |
| 25 | |
| 26 | struct 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 | |
Geoff Levand | ea1547d | 2007-02-06 14:23:47 -0800 | [diff] [blame] | 34 | struct ps3_vuart_work { |
| 35 | struct work_struct work; |
| 36 | unsigned long trigger; |
Geoff Levand | 7626e78 | 2007-06-16 08:01:06 +1000 | [diff] [blame] | 37 | struct ps3_system_bus_device *dev; /* to convert work to device */ |
Geoff Levand | 75c86e7 | 2007-02-13 17:37:28 -0800 | [diff] [blame] | 38 | }; |
| 39 | |
Geoff Levand | 74e95d5d | 2006-12-08 18:27:47 -0800 | [diff] [blame] | 40 | /** |
| 41 | * struct ps3_vuart_port_driver - a driver for a device on a vuart port |
| 42 | */ |
| 43 | |
| 44 | struct ps3_vuart_port_driver { |
Geoff Levand | 7626e78 | 2007-06-16 08:01:06 +1000 | [diff] [blame] | 45 | struct ps3_system_bus_driver core; |
| 46 | int (*probe)(struct ps3_system_bus_device *); |
| 47 | int (*remove)(struct ps3_system_bus_device *); |
| 48 | void (*shutdown)(struct ps3_system_bus_device *); |
| 49 | void (*work)(struct ps3_system_bus_device *); |
| 50 | /* int (*tx_event)(struct ps3_system_bus_device *dev); */ |
| 51 | /* int (*rx_event)(struct ps3_system_bus_device *dev); */ |
| 52 | /* int (*disconnect_event)(struct ps3_system_bus_device *dev); */ |
| 53 | /* int (*suspend)(struct ps3_system_bus_device *, pm_message_t); */ |
| 54 | /* int (*resume)(struct ps3_system_bus_device *); */ |
Geoff Levand | 74e95d5d | 2006-12-08 18:27:47 -0800 | [diff] [blame] | 55 | }; |
| 56 | |
Geoff Levand | 74e95d5d | 2006-12-08 18:27:47 -0800 | [diff] [blame] | 57 | int ps3_vuart_port_driver_register(struct ps3_vuart_port_driver *drv); |
| 58 | void ps3_vuart_port_driver_unregister(struct ps3_vuart_port_driver *drv); |
Geoff Levand | 97ec167 | 2007-01-30 15:20:30 -0800 | [diff] [blame] | 59 | |
Geoff Levand | 7626e78 | 2007-06-16 08:01:06 +1000 | [diff] [blame] | 60 | static inline struct ps3_vuart_port_driver * |
| 61 | ps3_system_bus_dev_to_vuart_drv(struct ps3_system_bus_device *_dev) |
Geoff Levand | 74e95d5d | 2006-12-08 18:27:47 -0800 | [diff] [blame] | 62 | { |
Geoff Levand | 7626e78 | 2007-06-16 08:01:06 +1000 | [diff] [blame] | 63 | struct ps3_system_bus_driver *sbd = |
| 64 | ps3_system_bus_dev_to_system_bus_drv(_dev); |
| 65 | BUG_ON(!sbd); |
| 66 | return container_of(sbd, struct ps3_vuart_port_driver, core); |
Geoff Levand | 74e95d5d | 2006-12-08 18:27:47 -0800 | [diff] [blame] | 67 | } |
Geoff Levand | 7626e78 | 2007-06-16 08:01:06 +1000 | [diff] [blame] | 68 | static inline struct ps3_system_bus_device *ps3_vuart_work_to_system_bus_dev( |
Geoff Levand | ea1547d | 2007-02-06 14:23:47 -0800 | [diff] [blame] | 69 | struct work_struct *_work) |
| 70 | { |
| 71 | struct ps3_vuart_work *vw = container_of(_work, struct ps3_vuart_work, |
| 72 | work); |
| 73 | return vw->dev; |
| 74 | } |
| 75 | |
Geoff Levand | 7626e78 | 2007-06-16 08:01:06 +1000 | [diff] [blame] | 76 | int ps3_vuart_write(struct ps3_system_bus_device *dev, const void *buf, |
Geoff Levand | ea1547d | 2007-02-06 14:23:47 -0800 | [diff] [blame] | 77 | unsigned int bytes); |
Geoff Levand | 7626e78 | 2007-06-16 08:01:06 +1000 | [diff] [blame] | 78 | int ps3_vuart_read(struct ps3_system_bus_device *dev, void *buf, |
Geoff Levand | ea1547d | 2007-02-06 14:23:47 -0800 | [diff] [blame] | 79 | unsigned int bytes); |
Geoff Levand | 7626e78 | 2007-06-16 08:01:06 +1000 | [diff] [blame] | 80 | int ps3_vuart_read_async(struct ps3_system_bus_device *dev, unsigned int bytes); |
| 81 | void ps3_vuart_cancel_async(struct ps3_system_bus_device *dev); |
| 82 | void ps3_vuart_clear_rx_bytes(struct ps3_system_bus_device *dev, |
Geoff Levand | ea1547d | 2007-02-06 14:23:47 -0800 | [diff] [blame] | 83 | unsigned int bytes); |
Geoff Levand | 74e95d5d | 2006-12-08 18:27:47 -0800 | [diff] [blame] | 84 | |
Geoff Levand | 74e95d5d | 2006-12-08 18:27:47 -0800 | [diff] [blame] | 85 | #endif |