Thomas Gleixner | 873e65b | 2019-05-27 08:55:15 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Geoff Levand | 74e95d5d | 2006-12-08 18:27:47 -0800 | [diff] [blame] | 2 | /* |
| 3 | * PS3 virtual uart |
| 4 | * |
| 5 | * Copyright (C) 2006 Sony Computer Entertainment Inc. |
| 6 | * Copyright 2006 Sony Corp. |
Geoff Levand | 74e95d5d | 2006-12-08 18:27:47 -0800 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #if !defined(_PS3_VUART_H) |
| 10 | #define _PS3_VUART_H |
| 11 | |
Geoff Levand | 75c86e7 | 2007-02-13 17:37:28 -0800 | [diff] [blame] | 12 | #include <asm/ps3.h> |
| 13 | |
| 14 | struct ps3_vuart_stats { |
| 15 | unsigned long bytes_written; |
| 16 | unsigned long bytes_read; |
| 17 | unsigned long tx_interrupts; |
| 18 | unsigned long rx_interrupts; |
| 19 | unsigned long disconnect_interrupts; |
| 20 | }; |
| 21 | |
Geoff Levand | ea1547d | 2007-02-06 14:23:47 -0800 | [diff] [blame] | 22 | struct ps3_vuart_work { |
| 23 | struct work_struct work; |
| 24 | unsigned long trigger; |
Geoff Levand | 7626e78 | 2007-06-16 08:01:06 +1000 | [diff] [blame] | 25 | struct ps3_system_bus_device *dev; /* to convert work to device */ |
Geoff Levand | 75c86e7 | 2007-02-13 17:37:28 -0800 | [diff] [blame] | 26 | }; |
| 27 | |
Geoff Levand | 74e95d5d | 2006-12-08 18:27:47 -0800 | [diff] [blame] | 28 | /** |
| 29 | * struct ps3_vuart_port_driver - a driver for a device on a vuart port |
| 30 | */ |
| 31 | |
| 32 | struct ps3_vuart_port_driver { |
Geoff Levand | 7626e78 | 2007-06-16 08:01:06 +1000 | [diff] [blame] | 33 | struct ps3_system_bus_driver core; |
| 34 | int (*probe)(struct ps3_system_bus_device *); |
| 35 | int (*remove)(struct ps3_system_bus_device *); |
| 36 | void (*shutdown)(struct ps3_system_bus_device *); |
| 37 | void (*work)(struct ps3_system_bus_device *); |
| 38 | /* int (*tx_event)(struct ps3_system_bus_device *dev); */ |
| 39 | /* int (*rx_event)(struct ps3_system_bus_device *dev); */ |
| 40 | /* int (*disconnect_event)(struct ps3_system_bus_device *dev); */ |
| 41 | /* int (*suspend)(struct ps3_system_bus_device *, pm_message_t); */ |
| 42 | /* int (*resume)(struct ps3_system_bus_device *); */ |
Geoff Levand | 74e95d5d | 2006-12-08 18:27:47 -0800 | [diff] [blame] | 43 | }; |
| 44 | |
Geoff Levand | 74e95d5d | 2006-12-08 18:27:47 -0800 | [diff] [blame] | 45 | int ps3_vuart_port_driver_register(struct ps3_vuart_port_driver *drv); |
| 46 | void ps3_vuart_port_driver_unregister(struct ps3_vuart_port_driver *drv); |
Geoff Levand | 97ec167 | 2007-01-30 15:20:30 -0800 | [diff] [blame] | 47 | |
Geoff Levand | 7626e78 | 2007-06-16 08:01:06 +1000 | [diff] [blame] | 48 | static inline struct ps3_vuart_port_driver * |
| 49 | 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] | 50 | { |
Geoff Levand | 7626e78 | 2007-06-16 08:01:06 +1000 | [diff] [blame] | 51 | struct ps3_system_bus_driver *sbd = |
| 52 | ps3_system_bus_dev_to_system_bus_drv(_dev); |
| 53 | BUG_ON(!sbd); |
| 54 | return container_of(sbd, struct ps3_vuart_port_driver, core); |
Geoff Levand | 74e95d5d | 2006-12-08 18:27:47 -0800 | [diff] [blame] | 55 | } |
Geoff Levand | 7626e78 | 2007-06-16 08:01:06 +1000 | [diff] [blame] | 56 | 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] | 57 | struct work_struct *_work) |
| 58 | { |
| 59 | struct ps3_vuart_work *vw = container_of(_work, struct ps3_vuart_work, |
| 60 | work); |
| 61 | return vw->dev; |
| 62 | } |
| 63 | |
Geoff Levand | 7626e78 | 2007-06-16 08:01:06 +1000 | [diff] [blame] | 64 | 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] | 65 | unsigned int bytes); |
Geoff Levand | 7626e78 | 2007-06-16 08:01:06 +1000 | [diff] [blame] | 66 | int ps3_vuart_read(struct ps3_system_bus_device *dev, void *buf, |
Geoff Levand | ea1547d | 2007-02-06 14:23:47 -0800 | [diff] [blame] | 67 | unsigned int bytes); |
Geoff Levand | 7626e78 | 2007-06-16 08:01:06 +1000 | [diff] [blame] | 68 | int ps3_vuart_read_async(struct ps3_system_bus_device *dev, unsigned int bytes); |
| 69 | void ps3_vuart_cancel_async(struct ps3_system_bus_device *dev); |
| 70 | void ps3_vuart_clear_rx_bytes(struct ps3_system_bus_device *dev, |
Geoff Levand | ea1547d | 2007-02-06 14:23:47 -0800 | [diff] [blame] | 71 | unsigned int bytes); |
Geoff Levand | 74e95d5d | 2006-12-08 18:27:47 -0800 | [diff] [blame] | 72 | |
Geoff Levand | 6baa5ec | 2015-01-13 01:00:20 +0000 | [diff] [blame] | 73 | struct vuart_triggers { |
| 74 | unsigned long rx; |
| 75 | unsigned long tx; |
| 76 | }; |
| 77 | |
| 78 | int ps3_vuart_get_triggers(struct ps3_system_bus_device *dev, |
| 79 | struct vuart_triggers *trig); |
| 80 | int ps3_vuart_set_triggers(struct ps3_system_bus_device *dev, unsigned int tx, |
| 81 | unsigned int rx); |
| 82 | int ps3_vuart_enable_interrupt_tx(struct ps3_system_bus_device *dev); |
| 83 | int ps3_vuart_disable_interrupt_tx(struct ps3_system_bus_device *dev); |
| 84 | int ps3_vuart_enable_interrupt_rx(struct ps3_system_bus_device *dev); |
| 85 | int ps3_vuart_disable_interrupt_rx(struct ps3_system_bus_device *dev); |
| 86 | int ps3_vuart_enable_interrupt_disconnect(struct ps3_system_bus_device *dev); |
| 87 | int ps3_vuart_disable_interrupt_disconnect(struct ps3_system_bus_device *dev); |
| 88 | |
Geoff Levand | 74e95d5d | 2006-12-08 18:27:47 -0800 | [diff] [blame] | 89 | #endif |