1*873e65bcSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 274e95d5dSGeoff Levand /* 374e95d5dSGeoff Levand * PS3 virtual uart 474e95d5dSGeoff Levand * 574e95d5dSGeoff Levand * Copyright (C) 2006 Sony Computer Entertainment Inc. 674e95d5dSGeoff Levand * Copyright 2006 Sony Corp. 774e95d5dSGeoff Levand */ 874e95d5dSGeoff Levand 974e95d5dSGeoff Levand #if !defined(_PS3_VUART_H) 1074e95d5dSGeoff Levand #define _PS3_VUART_H 1174e95d5dSGeoff Levand 1275c86e74SGeoff Levand #include <asm/ps3.h> 1375c86e74SGeoff Levand 1475c86e74SGeoff Levand struct ps3_vuart_stats { 1575c86e74SGeoff Levand unsigned long bytes_written; 1675c86e74SGeoff Levand unsigned long bytes_read; 1775c86e74SGeoff Levand unsigned long tx_interrupts; 1875c86e74SGeoff Levand unsigned long rx_interrupts; 1975c86e74SGeoff Levand unsigned long disconnect_interrupts; 2075c86e74SGeoff Levand }; 2175c86e74SGeoff Levand 22ea1547d3SGeoff Levand struct ps3_vuart_work { 23ea1547d3SGeoff Levand struct work_struct work; 24ea1547d3SGeoff Levand unsigned long trigger; 257626e78dSGeoff Levand struct ps3_system_bus_device *dev; /* to convert work to device */ 2675c86e74SGeoff Levand }; 2775c86e74SGeoff Levand 2874e95d5dSGeoff Levand /** 2974e95d5dSGeoff Levand * struct ps3_vuart_port_driver - a driver for a device on a vuart port 3074e95d5dSGeoff Levand */ 3174e95d5dSGeoff Levand 3274e95d5dSGeoff Levand struct ps3_vuart_port_driver { 337626e78dSGeoff Levand struct ps3_system_bus_driver core; 347626e78dSGeoff Levand int (*probe)(struct ps3_system_bus_device *); 357626e78dSGeoff Levand int (*remove)(struct ps3_system_bus_device *); 367626e78dSGeoff Levand void (*shutdown)(struct ps3_system_bus_device *); 377626e78dSGeoff Levand void (*work)(struct ps3_system_bus_device *); 387626e78dSGeoff Levand /* int (*tx_event)(struct ps3_system_bus_device *dev); */ 397626e78dSGeoff Levand /* int (*rx_event)(struct ps3_system_bus_device *dev); */ 407626e78dSGeoff Levand /* int (*disconnect_event)(struct ps3_system_bus_device *dev); */ 417626e78dSGeoff Levand /* int (*suspend)(struct ps3_system_bus_device *, pm_message_t); */ 427626e78dSGeoff Levand /* int (*resume)(struct ps3_system_bus_device *); */ 4374e95d5dSGeoff Levand }; 4474e95d5dSGeoff Levand 4574e95d5dSGeoff Levand int ps3_vuart_port_driver_register(struct ps3_vuart_port_driver *drv); 4674e95d5dSGeoff Levand void ps3_vuart_port_driver_unregister(struct ps3_vuart_port_driver *drv); 4797ec1675SGeoff Levand 487626e78dSGeoff Levand static inline struct ps3_vuart_port_driver * 497626e78dSGeoff Levand ps3_system_bus_dev_to_vuart_drv(struct ps3_system_bus_device *_dev) 5074e95d5dSGeoff Levand { 517626e78dSGeoff Levand struct ps3_system_bus_driver *sbd = 527626e78dSGeoff Levand ps3_system_bus_dev_to_system_bus_drv(_dev); 537626e78dSGeoff Levand BUG_ON(!sbd); 547626e78dSGeoff Levand return container_of(sbd, struct ps3_vuart_port_driver, core); 5574e95d5dSGeoff Levand } 567626e78dSGeoff Levand static inline struct ps3_system_bus_device *ps3_vuart_work_to_system_bus_dev( 57ea1547d3SGeoff Levand struct work_struct *_work) 58ea1547d3SGeoff Levand { 59ea1547d3SGeoff Levand struct ps3_vuart_work *vw = container_of(_work, struct ps3_vuart_work, 60ea1547d3SGeoff Levand work); 61ea1547d3SGeoff Levand return vw->dev; 62ea1547d3SGeoff Levand } 63ea1547d3SGeoff Levand 647626e78dSGeoff Levand int ps3_vuart_write(struct ps3_system_bus_device *dev, const void *buf, 65ea1547d3SGeoff Levand unsigned int bytes); 667626e78dSGeoff Levand int ps3_vuart_read(struct ps3_system_bus_device *dev, void *buf, 67ea1547d3SGeoff Levand unsigned int bytes); 687626e78dSGeoff Levand int ps3_vuart_read_async(struct ps3_system_bus_device *dev, unsigned int bytes); 697626e78dSGeoff Levand void ps3_vuart_cancel_async(struct ps3_system_bus_device *dev); 707626e78dSGeoff Levand void ps3_vuart_clear_rx_bytes(struct ps3_system_bus_device *dev, 71ea1547d3SGeoff Levand unsigned int bytes); 7274e95d5dSGeoff Levand 736baa5ecdSGeoff Levand struct vuart_triggers { 746baa5ecdSGeoff Levand unsigned long rx; 756baa5ecdSGeoff Levand unsigned long tx; 766baa5ecdSGeoff Levand }; 776baa5ecdSGeoff Levand 786baa5ecdSGeoff Levand int ps3_vuart_get_triggers(struct ps3_system_bus_device *dev, 796baa5ecdSGeoff Levand struct vuart_triggers *trig); 806baa5ecdSGeoff Levand int ps3_vuart_set_triggers(struct ps3_system_bus_device *dev, unsigned int tx, 816baa5ecdSGeoff Levand unsigned int rx); 826baa5ecdSGeoff Levand int ps3_vuart_enable_interrupt_tx(struct ps3_system_bus_device *dev); 836baa5ecdSGeoff Levand int ps3_vuart_disable_interrupt_tx(struct ps3_system_bus_device *dev); 846baa5ecdSGeoff Levand int ps3_vuart_enable_interrupt_rx(struct ps3_system_bus_device *dev); 856baa5ecdSGeoff Levand int ps3_vuart_disable_interrupt_rx(struct ps3_system_bus_device *dev); 866baa5ecdSGeoff Levand int ps3_vuart_enable_interrupt_disconnect(struct ps3_system_bus_device *dev); 876baa5ecdSGeoff Levand int ps3_vuart_disable_interrupt_disconnect(struct ps3_system_bus_device *dev); 886baa5ecdSGeoff Levand 8974e95d5dSGeoff Levand #endif 90