1*07d8ce49Stsutsui /* $NetBSD: maple.h,v 1.12 2010/10/17 14:13:44 tsutsui Exp $ */ 2154b121fSitohy 3154b121fSitohy /*- 4154b121fSitohy * Copyright (c) 2002 The NetBSD Foundation, Inc. 5154b121fSitohy * All rights reserved. 6154b121fSitohy * 7154b121fSitohy * This code is derived from software contributed to The NetBSD Foundation 8154b121fSitohy * by ITOH Yasufumi. 9154b121fSitohy * 10154b121fSitohy * Redistribution and use in source and binary forms, with or without 11154b121fSitohy * modification, are permitted provided that the following conditions 12154b121fSitohy * are met: 13154b121fSitohy * 1. Redistributions of source code must retain the above copyright 14154b121fSitohy * notice, this list of conditions and the following disclaimer. 15154b121fSitohy * 2. Redistributions in binary form must reproduce the above copyright 16154b121fSitohy * notice, this list of conditions and the following disclaimer in the 17154b121fSitohy * documentation and/or other materials provided with the distribution. 18154b121fSitohy * 19154b121fSitohy * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20154b121fSitohy * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21154b121fSitohy * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22154b121fSitohy * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23154b121fSitohy * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24154b121fSitohy * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25154b121fSitohy * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26154b121fSitohy * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27154b121fSitohy * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28154b121fSitohy * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29154b121fSitohy * POSSIBILITY OF SUCH DAMAGE. 30154b121fSitohy */ 31b095a0d0Such 3228f7e6ddSmarcus /*- 33ee6259c5Smarcus * Copyright (c) 2001 Marcus Comstedt 34ee6259c5Smarcus * All rights reserved. 35ee6259c5Smarcus * 36ee6259c5Smarcus * Redistribution and use in source and binary forms, with or without 37ee6259c5Smarcus * modification, are permitted provided that the following conditions 38ee6259c5Smarcus * are met: 39ee6259c5Smarcus * 1. Redistributions of source code must retain the above copyright 40ee6259c5Smarcus * notice, this list of conditions and the following disclaimer. 41ee6259c5Smarcus * 2. Redistributions in binary form must reproduce the above copyright 42ee6259c5Smarcus * notice, this list of conditions and the following disclaimer in the 43ee6259c5Smarcus * documentation and/or other materials provided with the distribution. 44ee6259c5Smarcus * 3. All advertising materials mentioning features or use of this software 45ee6259c5Smarcus * must display the following acknowledgement: 4628f7e6ddSmarcus * This product includes software developed by Marcus Comstedt. 4728f7e6ddSmarcus * 4. Neither the name of The NetBSD Foundation nor the names of its 4828f7e6ddSmarcus * contributors may be used to endorse or promote products derived 4928f7e6ddSmarcus * from this software without specific prior written permission. 50ee6259c5Smarcus * 5128f7e6ddSmarcus * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 5228f7e6ddSmarcus * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 5328f7e6ddSmarcus * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 5428f7e6ddSmarcus * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 5528f7e6ddSmarcus * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 5628f7e6ddSmarcus * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 5728f7e6ddSmarcus * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 5828f7e6ddSmarcus * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 5928f7e6ddSmarcus * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 6028f7e6ddSmarcus * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 6128f7e6ddSmarcus * POSSIBILITY OF SUCH DAMAGE. 62ee6259c5Smarcus */ 63ee6259c5Smarcus 64e90e316bSmarcus #ifndef _DREAMCAST_DEV_MAPLE_MAPLE_H_ 65e90e316bSmarcus #define _DREAMCAST_DEV_MAPLE_MAPLE_H_ 66e90e316bSmarcus 67154b121fSitohy /* signed is more effective than unsigned on SH */ 68154b121fSitohy typedef int8_t maple_response_t; 69ee6259c5Smarcus 70ee6259c5Smarcus /* Maple Bus command and response codes */ 71ee6259c5Smarcus 72154b121fSitohy #define MAPLE_RESPONSE_LCDERR (-6) 73154b121fSitohy #define MAPLE_RESPONSE_FILEERR (-5) 74154b121fSitohy #define MAPLE_RESPONSE_AGAIN (-4) /* request should be retransmitted */ 75154b121fSitohy #define MAPLE_RESPONSE_BADCMD (-3) 76154b121fSitohy #define MAPLE_RESPONSE_BADFUNC (-2) 77154b121fSitohy #define MAPLE_RESPONSE_NONE (-1) /* unit didn't respond at all */ 78ee6259c5Smarcus #define MAPLE_COMMAND_DEVINFO 1 79ee6259c5Smarcus #define MAPLE_COMMAND_ALLINFO 2 80ee6259c5Smarcus #define MAPLE_COMMAND_RESET 3 81ee6259c5Smarcus #define MAPLE_COMMAND_KILL 4 82ee6259c5Smarcus #define MAPLE_RESPONSE_DEVINFO 5 83ee6259c5Smarcus #define MAPLE_RESPONSE_ALLINFO 6 84ee6259c5Smarcus #define MAPLE_RESPONSE_OK 7 85ee6259c5Smarcus #define MAPLE_RESPONSE_DATATRF 8 86ee6259c5Smarcus #define MAPLE_COMMAND_GETCOND 9 87ee6259c5Smarcus #define MAPLE_COMMAND_GETMINFO 10 88ee6259c5Smarcus #define MAPLE_COMMAND_BREAD 11 89ee6259c5Smarcus #define MAPLE_COMMAND_BWRITE 12 90154b121fSitohy #define MAPLE_COMMAND_GETLASTERR 13 91ee6259c5Smarcus #define MAPLE_COMMAND_SETCOND 14 92ee6259c5Smarcus 93ee6259c5Smarcus /* Function codes */ 94154b121fSitohy #define MAPLE_FN_CONTROLLER 0 95154b121fSitohy #define MAPLE_FN_MEMCARD 1 96154b121fSitohy #define MAPLE_FN_LCD 2 97154b121fSitohy #define MAPLE_FN_CLOCK 3 98154b121fSitohy #define MAPLE_FN_MICROPHONE 4 99154b121fSitohy #define MAPLE_FN_ARGUN 5 100154b121fSitohy #define MAPLE_FN_KEYBOARD 6 101154b121fSitohy #define MAPLE_FN_LIGHTGUN 7 102154b121fSitohy #define MAPLE_FN_PURUPURU 8 103154b121fSitohy #define MAPLE_FN_MOUSE 9 104ee6259c5Smarcus 105154b121fSitohy #define MAPLE_FUNC(fn) (1 << (fn)) 106ee6259c5Smarcus 107ee6259c5Smarcus struct maple_devinfo { 108cb6453dbStsutsui uint32_t di_func; /* function code */ 109cb6453dbStsutsui uint32_t di_function_data[3]; /* function data */ 110cb6453dbStsutsui uint8_t di_area_code; /* region settings */ 111cb6453dbStsutsui uint8_t di_connector_direction; /* direction of expansion connector */ 112ee6259c5Smarcus char di_product_name[30]; /* name of the device */ 113ee6259c5Smarcus char di_product_license[60]; /* manufacturer info */ 114cb6453dbStsutsui uint16_t di_standby_power; /* standby power consumption */ 115cb6453dbStsutsui uint16_t di_max_power; /* maximum power consumption */ 116ee6259c5Smarcus }; 117ee6259c5Smarcus 1188f6d7befSitohy #define MAPLE_CONN_TOP 0 /* connector is to the top */ 1198f6d7befSitohy #define MAPLE_CONN_BOTTOM 1 /* connector is to the bottom */ 1208f6d7befSitohy 121154b121fSitohy struct maple_response { 122cb6453dbStsutsui uint32_t response_code; 123cb6453dbStsutsui uint32_t data[1]; /* variable length */ 124ee6259c5Smarcus }; 125ee6259c5Smarcus 126154b121fSitohy #define MAPLE_FLAG_PERIODIC 1 127154b121fSitohy #define MAPLE_FLAG_CMD_PERIODIC_TIMING 2 128154b121fSitohy 129154b121fSitohy struct maple_unit; 130154b121fSitohy 131*07d8ce49Stsutsui void maple_set_callback(device_t, struct maple_unit *, int, 132154b121fSitohy void (*)(void *, struct maple_response *, int, int), 133154b121fSitohy void *); 134*07d8ce49Stsutsui void maple_enable_unit_ping(device_t, struct maple_unit *, 135154b121fSitohy int /*func*/, int /*enable*/); 136*07d8ce49Stsutsui void maple_enable_periodic(device_t, struct maple_unit *, 137154b121fSitohy int /*func*/, int /*on*/); 138*07d8ce49Stsutsui void maple_command(device_t, struct maple_unit *, 139b1f5bd8eSitohy int /*func*/, int /*command*/, int /*datalen*/, 140b1f5bd8eSitohy const void *, int /*flags*/); 141*07d8ce49Stsutsui uint32_t maple_get_function_data(struct maple_devinfo *, int); 142*07d8ce49Stsutsui void maple_run_polling(device_t); 143*07d8ce49Stsutsui int maple_unit_ioctl(device_t, struct maple_unit *, 14453524e44Schristos u_long, void *, int, struct lwp *); 145e90e316bSmarcus 146e90e316bSmarcus #endif /* _DREAMCAST_DEV_MAPLE_MAPLE_H_ */ 147