174e95d5dSGeoff Levand /* 274e95d5dSGeoff Levand * PS3 virtual uart 374e95d5dSGeoff Levand * 474e95d5dSGeoff Levand * Copyright (C) 2006 Sony Computer Entertainment Inc. 574e95d5dSGeoff Levand * Copyright 2006 Sony Corp. 674e95d5dSGeoff Levand * 774e95d5dSGeoff Levand * This program is free software; you can redistribute it and/or modify 874e95d5dSGeoff Levand * it under the terms of the GNU General Public License as published by 974e95d5dSGeoff Levand * the Free Software Foundation; version 2 of the License. 1074e95d5dSGeoff Levand * 1174e95d5dSGeoff Levand * This program is distributed in the hope that it will be useful, 1274e95d5dSGeoff Levand * but WITHOUT ANY WARRANTY; without even the implied warranty of 1374e95d5dSGeoff Levand * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1474e95d5dSGeoff Levand * GNU General Public License for more details. 1574e95d5dSGeoff Levand * 1674e95d5dSGeoff Levand * You should have received a copy of the GNU General Public License 1774e95d5dSGeoff Levand * along with this program; if not, write to the Free Software 1874e95d5dSGeoff Levand * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 1974e95d5dSGeoff Levand */ 2074e95d5dSGeoff Levand 2174e95d5dSGeoff Levand #if !defined(_PS3_VUART_H) 2274e95d5dSGeoff Levand #define _PS3_VUART_H 2374e95d5dSGeoff Levand 2475c86e74SGeoff Levand #include <asm/ps3.h> 2575c86e74SGeoff Levand 2675c86e74SGeoff Levand struct ps3_vuart_stats { 2775c86e74SGeoff Levand unsigned long bytes_written; 2875c86e74SGeoff Levand unsigned long bytes_read; 2975c86e74SGeoff Levand unsigned long tx_interrupts; 3075c86e74SGeoff Levand unsigned long rx_interrupts; 3175c86e74SGeoff Levand unsigned long disconnect_interrupts; 3275c86e74SGeoff Levand }; 3375c86e74SGeoff Levand 34ea1547d3SGeoff Levand struct ps3_vuart_work { 35ea1547d3SGeoff Levand struct work_struct work; 36ea1547d3SGeoff Levand unsigned long trigger; 37*7626e78dSGeoff Levand struct ps3_system_bus_device *dev; /* to convert work to device */ 3875c86e74SGeoff Levand }; 3975c86e74SGeoff Levand 4074e95d5dSGeoff Levand /** 4174e95d5dSGeoff Levand * struct ps3_vuart_port_driver - a driver for a device on a vuart port 4274e95d5dSGeoff Levand */ 4374e95d5dSGeoff Levand 4474e95d5dSGeoff Levand struct ps3_vuart_port_driver { 45*7626e78dSGeoff Levand struct ps3_system_bus_driver core; 46*7626e78dSGeoff Levand int (*probe)(struct ps3_system_bus_device *); 47*7626e78dSGeoff Levand int (*remove)(struct ps3_system_bus_device *); 48*7626e78dSGeoff Levand void (*shutdown)(struct ps3_system_bus_device *); 49*7626e78dSGeoff Levand void (*work)(struct ps3_system_bus_device *); 50*7626e78dSGeoff Levand /* int (*tx_event)(struct ps3_system_bus_device *dev); */ 51*7626e78dSGeoff Levand /* int (*rx_event)(struct ps3_system_bus_device *dev); */ 52*7626e78dSGeoff Levand /* int (*disconnect_event)(struct ps3_system_bus_device *dev); */ 53*7626e78dSGeoff Levand /* int (*suspend)(struct ps3_system_bus_device *, pm_message_t); */ 54*7626e78dSGeoff Levand /* int (*resume)(struct ps3_system_bus_device *); */ 5574e95d5dSGeoff Levand }; 5674e95d5dSGeoff Levand 5774e95d5dSGeoff Levand int ps3_vuart_port_driver_register(struct ps3_vuart_port_driver *drv); 5874e95d5dSGeoff Levand void ps3_vuart_port_driver_unregister(struct ps3_vuart_port_driver *drv); 5997ec1675SGeoff Levand 60*7626e78dSGeoff Levand static inline struct ps3_vuart_port_driver * 61*7626e78dSGeoff Levand ps3_system_bus_dev_to_vuart_drv(struct ps3_system_bus_device *_dev) 6274e95d5dSGeoff Levand { 63*7626e78dSGeoff Levand struct ps3_system_bus_driver *sbd = 64*7626e78dSGeoff Levand ps3_system_bus_dev_to_system_bus_drv(_dev); 65*7626e78dSGeoff Levand BUG_ON(!sbd); 66*7626e78dSGeoff Levand return container_of(sbd, struct ps3_vuart_port_driver, core); 6774e95d5dSGeoff Levand } 68*7626e78dSGeoff Levand static inline struct ps3_system_bus_device *ps3_vuart_work_to_system_bus_dev( 69ea1547d3SGeoff Levand struct work_struct *_work) 70ea1547d3SGeoff Levand { 71ea1547d3SGeoff Levand struct ps3_vuart_work *vw = container_of(_work, struct ps3_vuart_work, 72ea1547d3SGeoff Levand work); 73ea1547d3SGeoff Levand return vw->dev; 74ea1547d3SGeoff Levand } 75ea1547d3SGeoff Levand 76*7626e78dSGeoff Levand int ps3_vuart_write(struct ps3_system_bus_device *dev, const void *buf, 77ea1547d3SGeoff Levand unsigned int bytes); 78*7626e78dSGeoff Levand int ps3_vuart_read(struct ps3_system_bus_device *dev, void *buf, 79ea1547d3SGeoff Levand unsigned int bytes); 80*7626e78dSGeoff Levand int ps3_vuart_read_async(struct ps3_system_bus_device *dev, unsigned int bytes); 81*7626e78dSGeoff Levand void ps3_vuart_cancel_async(struct ps3_system_bus_device *dev); 82*7626e78dSGeoff Levand void ps3_vuart_clear_rx_bytes(struct ps3_system_bus_device *dev, 83ea1547d3SGeoff Levand unsigned int bytes); 8474e95d5dSGeoff Levand 8574e95d5dSGeoff Levand #endif 86