Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 1 | /* |
| 2 | * PS3 System Manager. |
| 3 | * |
| 4 | * Copyright (C) 2007 Sony Computer Entertainment Inc. |
| 5 | * Copyright 2007 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 | #include <linux/kernel.h> |
| 22 | #include <linux/module.h> |
| 23 | #include <linux/workqueue.h> |
| 24 | #include <linux/reboot.h> |
Ingo Molnar | 3f07c01 | 2017-02-08 18:51:30 +0100 | [diff] [blame] | 25 | #include <linux/sched/signal.h> |
Geert Uytterhoeven | ef596c6 | 2007-03-10 00:05:38 +0100 | [diff] [blame] | 26 | |
| 27 | #include <asm/firmware.h> |
Geert Uytterhoeven | ca052f7 | 2008-03-27 11:38:31 +1100 | [diff] [blame] | 28 | #include <asm/lv1call.h> |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 29 | #include <asm/ps3.h> |
Geert Uytterhoeven | ef596c6 | 2007-03-10 00:05:38 +0100 | [diff] [blame] | 30 | |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 31 | #include "vuart.h" |
| 32 | |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 33 | /** |
| 34 | * ps3_sys_manager - PS3 system manager driver. |
| 35 | * |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 36 | * The system manager provides an asynchronous system event notification |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 37 | * mechanism for reporting events like thermal alert and button presses to |
| 38 | * guests. It also provides support to control system shutdown and startup. |
| 39 | * |
| 40 | * The actual system manager is implemented as an application running in the |
| 41 | * system policy module in lpar_1. Guests communicate with the system manager |
| 42 | * through port 2 of the vuart using a simple packet message protocol. |
| 43 | * Messages are comprised of a fixed field header followed by a message |
| 44 | * specific payload. |
| 45 | */ |
| 46 | |
| 47 | /** |
| 48 | * struct ps3_sys_manager_header - System manager message header. |
| 49 | * @version: Header version, currently 1. |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 50 | * @size: Header size in bytes, currently 16. |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 51 | * @payload_size: Message payload size in bytes. |
| 52 | * @service_id: Message type, one of enum ps3_sys_manager_service_id. |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 53 | * @request_tag: Unique number to identify reply. |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 54 | */ |
| 55 | |
| 56 | struct ps3_sys_manager_header { |
| 57 | /* version 1 */ |
| 58 | u8 version; |
| 59 | u8 size; |
| 60 | u16 reserved_1; |
| 61 | u32 payload_size; |
| 62 | u16 service_id; |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 63 | u16 reserved_2; |
| 64 | u32 request_tag; |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 65 | }; |
| 66 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 67 | #define dump_sm_header(_h) _dump_sm_header(_h, __func__, __LINE__) |
| 68 | static void __maybe_unused _dump_sm_header( |
| 69 | const struct ps3_sys_manager_header *h, const char *func, int line) |
| 70 | { |
| 71 | pr_debug("%s:%d: version: %xh\n", func, line, h->version); |
| 72 | pr_debug("%s:%d: size: %xh\n", func, line, h->size); |
| 73 | pr_debug("%s:%d: payload_size: %xh\n", func, line, h->payload_size); |
| 74 | pr_debug("%s:%d: service_id: %xh\n", func, line, h->service_id); |
| 75 | pr_debug("%s:%d: request_tag: %xh\n", func, line, h->request_tag); |
| 76 | } |
| 77 | |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 78 | /** |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 79 | * @PS3_SM_RX_MSG_LEN_MIN - Shortest received message length. |
| 80 | * @PS3_SM_RX_MSG_LEN_MAX - Longest received message length. |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 81 | * |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 82 | * Currently all messages received from the system manager are either |
| 83 | * (16 bytes header + 8 bytes payload = 24 bytes) or (16 bytes header |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 84 | * + 16 bytes payload = 32 bytes). This knowledge is used to simplify |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 85 | * the logic. |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 86 | */ |
| 87 | |
| 88 | enum { |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 89 | PS3_SM_RX_MSG_LEN_MIN = 24, |
| 90 | PS3_SM_RX_MSG_LEN_MAX = 32, |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | /** |
| 94 | * enum ps3_sys_manager_service_id - Message header service_id. |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 95 | * @PS3_SM_SERVICE_ID_REQUEST: guest --> sys_manager. |
| 96 | * @PS3_SM_SERVICE_ID_REQUEST_ERROR: guest <-- sys_manager. |
| 97 | * @PS3_SM_SERVICE_ID_COMMAND: guest <-- sys_manager. |
| 98 | * @PS3_SM_SERVICE_ID_RESPONSE: guest --> sys_manager. |
| 99 | * @PS3_SM_SERVICE_ID_SET_ATTR: guest --> sys_manager. |
| 100 | * @PS3_SM_SERVICE_ID_EXTERN_EVENT: guest <-- sys_manager. |
| 101 | * @PS3_SM_SERVICE_ID_SET_NEXT_OP: guest --> sys_manager. |
| 102 | * |
| 103 | * PS3_SM_SERVICE_ID_REQUEST_ERROR is returned for invalid data values in a |
| 104 | * a PS3_SM_SERVICE_ID_REQUEST message. It also seems to be returned when |
| 105 | * a REQUEST message is sent at the wrong time. |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 106 | */ |
| 107 | |
| 108 | enum ps3_sys_manager_service_id { |
| 109 | /* version 1 */ |
| 110 | PS3_SM_SERVICE_ID_REQUEST = 1, |
| 111 | PS3_SM_SERVICE_ID_RESPONSE = 2, |
| 112 | PS3_SM_SERVICE_ID_COMMAND = 3, |
| 113 | PS3_SM_SERVICE_ID_EXTERN_EVENT = 4, |
| 114 | PS3_SM_SERVICE_ID_SET_NEXT_OP = 5, |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 115 | PS3_SM_SERVICE_ID_REQUEST_ERROR = 6, |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 116 | PS3_SM_SERVICE_ID_SET_ATTR = 8, |
| 117 | }; |
| 118 | |
| 119 | /** |
| 120 | * enum ps3_sys_manager_attr - Notification attribute (bit position mask). |
| 121 | * @PS3_SM_ATTR_POWER: Power button. |
| 122 | * @PS3_SM_ATTR_RESET: Reset button, not available on retail console. |
Thomas Weber | 8839316 | 2010-03-16 11:47:56 +0100 | [diff] [blame] | 123 | * @PS3_SM_ATTR_THERMAL: System thermal alert. |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 124 | * @PS3_SM_ATTR_CONTROLLER: Remote controller event. |
| 125 | * @PS3_SM_ATTR_ALL: Logical OR of all. |
| 126 | * |
| 127 | * The guest tells the system manager which events it is interested in receiving |
| 128 | * notice of by sending the system manager a logical OR of notification |
| 129 | * attributes via the ps3_sys_manager_send_attr() routine. |
| 130 | */ |
| 131 | |
| 132 | enum ps3_sys_manager_attr { |
| 133 | /* version 1 */ |
| 134 | PS3_SM_ATTR_POWER = 1, |
| 135 | PS3_SM_ATTR_RESET = 2, |
| 136 | PS3_SM_ATTR_THERMAL = 4, |
| 137 | PS3_SM_ATTR_CONTROLLER = 8, /* bogus? */ |
| 138 | PS3_SM_ATTR_ALL = 0x0f, |
| 139 | }; |
| 140 | |
| 141 | /** |
| 142 | * enum ps3_sys_manager_event - External event type, reported by system manager. |
Geoff Levand | ea24608 | 2008-02-09 09:53:07 +1100 | [diff] [blame] | 143 | * @PS3_SM_EVENT_POWER_PRESSED: payload.value = |
| 144 | * enum ps3_sys_manager_button_event. |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 145 | * @PS3_SM_EVENT_POWER_RELEASED: payload.value = time pressed in millisec. |
Geoff Levand | ea24608 | 2008-02-09 09:53:07 +1100 | [diff] [blame] | 146 | * @PS3_SM_EVENT_RESET_PRESSED: payload.value = |
| 147 | * enum ps3_sys_manager_button_event. |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 148 | * @PS3_SM_EVENT_RESET_RELEASED: payload.value = time pressed in millisec. |
| 149 | * @PS3_SM_EVENT_THERMAL_ALERT: payload.value = thermal zone id. |
| 150 | * @PS3_SM_EVENT_THERMAL_CLEARED: payload.value = thermal zone id. |
| 151 | */ |
| 152 | |
| 153 | enum ps3_sys_manager_event { |
| 154 | /* version 1 */ |
| 155 | PS3_SM_EVENT_POWER_PRESSED = 3, |
| 156 | PS3_SM_EVENT_POWER_RELEASED = 4, |
| 157 | PS3_SM_EVENT_RESET_PRESSED = 5, |
| 158 | PS3_SM_EVENT_RESET_RELEASED = 6, |
| 159 | PS3_SM_EVENT_THERMAL_ALERT = 7, |
| 160 | PS3_SM_EVENT_THERMAL_CLEARED = 8, |
| 161 | /* no info on controller events */ |
| 162 | }; |
| 163 | |
| 164 | /** |
Geoff Levand | ea24608 | 2008-02-09 09:53:07 +1100 | [diff] [blame] | 165 | * enum ps3_sys_manager_button_event - Button event payload values. |
| 166 | * @PS3_SM_BUTTON_EVENT_HARD: Hardware generated event. |
| 167 | * @PS3_SM_BUTTON_EVENT_SOFT: Software generated event. |
| 168 | */ |
| 169 | |
| 170 | enum ps3_sys_manager_button_event { |
| 171 | PS3_SM_BUTTON_EVENT_HARD = 0, |
| 172 | PS3_SM_BUTTON_EVENT_SOFT = 1, |
| 173 | }; |
| 174 | |
| 175 | /** |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 176 | * enum ps3_sys_manager_next_op - Operation to perform after lpar is destroyed. |
| 177 | */ |
| 178 | |
| 179 | enum ps3_sys_manager_next_op { |
| 180 | /* version 3 */ |
| 181 | PS3_SM_NEXT_OP_SYS_SHUTDOWN = 1, |
| 182 | PS3_SM_NEXT_OP_SYS_REBOOT = 2, |
| 183 | PS3_SM_NEXT_OP_LPAR_REBOOT = 0x82, |
| 184 | }; |
| 185 | |
| 186 | /** |
| 187 | * enum ps3_sys_manager_wake_source - Next-op wakeup source (bit position mask). |
Geoff Levand | 5442381 | 2008-05-01 08:25:30 +1000 | [diff] [blame] | 188 | * @PS3_SM_WAKE_DEFAULT: Disk insert, power button, eject button. |
Geoff Levand | 1c43d26 | 2008-03-27 11:39:04 +1100 | [diff] [blame] | 189 | * @PS3_SM_WAKE_W_O_L: Ether or wireless LAN. |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 190 | * @PS3_SM_WAKE_P_O_R: Power on reset. |
| 191 | * |
| 192 | * Additional wakeup sources when specifying PS3_SM_NEXT_OP_SYS_SHUTDOWN. |
Geoff Levand | 50dad90 | 2008-02-09 09:53:01 +1100 | [diff] [blame] | 193 | * The system will always wake from the PS3_SM_WAKE_DEFAULT sources. |
| 194 | * Sources listed here are the only ones available to guests in the |
| 195 | * other-os lpar. |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 196 | */ |
| 197 | |
| 198 | enum ps3_sys_manager_wake_source { |
| 199 | /* version 3 */ |
| 200 | PS3_SM_WAKE_DEFAULT = 0, |
Geoff Levand | 1c43d26 | 2008-03-27 11:39:04 +1100 | [diff] [blame] | 201 | PS3_SM_WAKE_W_O_L = 0x00000400, |
Geoff Levand | 50dad90 | 2008-02-09 09:53:01 +1100 | [diff] [blame] | 202 | PS3_SM_WAKE_P_O_R = 0x80000000, |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 203 | }; |
| 204 | |
| 205 | /** |
Geoff Levand | 1c43d26 | 2008-03-27 11:39:04 +1100 | [diff] [blame] | 206 | * user_wake_sources - User specified wakeup sources. |
| 207 | * |
| 208 | * Logical OR of enum ps3_sys_manager_wake_source types. |
| 209 | */ |
| 210 | |
| 211 | static u32 user_wake_sources = PS3_SM_WAKE_DEFAULT; |
| 212 | |
| 213 | /** |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 214 | * enum ps3_sys_manager_cmd - Command from system manager to guest. |
| 215 | * |
| 216 | * The guest completes the actions needed, then acks or naks the command via |
| 217 | * ps3_sys_manager_send_response(). In the case of @PS3_SM_CMD_SHUTDOWN, |
| 218 | * the guest must be fully prepared for a system poweroff prior to acking the |
| 219 | * command. |
| 220 | */ |
| 221 | |
| 222 | enum ps3_sys_manager_cmd { |
| 223 | /* version 1 */ |
| 224 | PS3_SM_CMD_SHUTDOWN = 1, /* shutdown guest OS */ |
| 225 | }; |
| 226 | |
| 227 | /** |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 228 | * ps3_sm_force_power_off - Poweroff helper. |
| 229 | * |
| 230 | * A global variable used to force a poweroff when the power button has |
| 231 | * been pressed irrespective of how init handles the ctrl_alt_del signal. |
| 232 | * |
| 233 | */ |
| 234 | |
| 235 | static unsigned int ps3_sm_force_power_off; |
| 236 | |
| 237 | /** |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 238 | * ps3_sys_manager_write - Helper to write a two part message to the vuart. |
| 239 | * |
| 240 | */ |
| 241 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 242 | static int ps3_sys_manager_write(struct ps3_system_bus_device *dev, |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 243 | const struct ps3_sys_manager_header *header, const void *payload) |
| 244 | { |
| 245 | int result; |
| 246 | |
| 247 | BUG_ON(header->version != 1); |
| 248 | BUG_ON(header->size != 16); |
| 249 | BUG_ON(header->payload_size != 8 && header->payload_size != 16); |
| 250 | BUG_ON(header->service_id > 8); |
| 251 | |
| 252 | result = ps3_vuart_write(dev, header, |
| 253 | sizeof(struct ps3_sys_manager_header)); |
| 254 | |
| 255 | if (!result) |
| 256 | result = ps3_vuart_write(dev, payload, header->payload_size); |
| 257 | |
| 258 | return result; |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * ps3_sys_manager_send_attr - Send a 'set attribute' to the system manager. |
| 263 | * |
| 264 | */ |
| 265 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 266 | static int ps3_sys_manager_send_attr(struct ps3_system_bus_device *dev, |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 267 | enum ps3_sys_manager_attr attr) |
| 268 | { |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 269 | struct ps3_sys_manager_header header; |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 270 | struct { |
| 271 | u8 version; |
| 272 | u8 reserved_1[3]; |
| 273 | u32 attribute; |
| 274 | } payload; |
| 275 | |
| 276 | BUILD_BUG_ON(sizeof(payload) != 8); |
| 277 | |
| 278 | dev_dbg(&dev->core, "%s:%d: %xh\n", __func__, __LINE__, attr); |
| 279 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 280 | memset(&header, 0, sizeof(header)); |
| 281 | header.version = 1; |
| 282 | header.size = 16; |
| 283 | header.payload_size = 16; |
| 284 | header.service_id = PS3_SM_SERVICE_ID_SET_ATTR; |
| 285 | |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 286 | memset(&payload, 0, sizeof(payload)); |
| 287 | payload.version = 1; |
| 288 | payload.attribute = attr; |
| 289 | |
| 290 | return ps3_sys_manager_write(dev, &header, &payload); |
| 291 | } |
| 292 | |
| 293 | /** |
| 294 | * ps3_sys_manager_send_next_op - Send a 'set next op' to the system manager. |
| 295 | * |
| 296 | * Tell the system manager what to do after this lpar is destroyed. |
| 297 | */ |
| 298 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 299 | static int ps3_sys_manager_send_next_op(struct ps3_system_bus_device *dev, |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 300 | enum ps3_sys_manager_next_op op, |
| 301 | enum ps3_sys_manager_wake_source wake_source) |
| 302 | { |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 303 | struct ps3_sys_manager_header header; |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 304 | struct { |
| 305 | u8 version; |
| 306 | u8 type; |
| 307 | u8 gos_id; |
| 308 | u8 reserved_1; |
| 309 | u32 wake_source; |
| 310 | u8 reserved_2[8]; |
| 311 | } payload; |
| 312 | |
| 313 | BUILD_BUG_ON(sizeof(payload) != 16); |
| 314 | |
| 315 | dev_dbg(&dev->core, "%s:%d: (%xh)\n", __func__, __LINE__, op); |
| 316 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 317 | memset(&header, 0, sizeof(header)); |
| 318 | header.version = 1; |
| 319 | header.size = 16; |
| 320 | header.payload_size = 16; |
| 321 | header.service_id = PS3_SM_SERVICE_ID_SET_NEXT_OP; |
| 322 | |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 323 | memset(&payload, 0, sizeof(payload)); |
| 324 | payload.version = 3; |
| 325 | payload.type = op; |
| 326 | payload.gos_id = 3; /* other os */ |
| 327 | payload.wake_source = wake_source; |
| 328 | |
| 329 | return ps3_sys_manager_write(dev, &header, &payload); |
| 330 | } |
| 331 | |
| 332 | /** |
| 333 | * ps3_sys_manager_send_request_shutdown - Send 'request' to the system manager. |
| 334 | * |
| 335 | * The guest sends this message to request an operation or action of the system |
| 336 | * manager. The reply is a command message from the system manager. In the |
| 337 | * command handler the guest performs the requested operation. The result of |
| 338 | * the command is then communicated back to the system manager with a response |
| 339 | * message. |
| 340 | * |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 341 | * Currently, the only supported request is the 'shutdown self' request. |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 342 | */ |
| 343 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 344 | static int ps3_sys_manager_send_request_shutdown( |
| 345 | struct ps3_system_bus_device *dev) |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 346 | { |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 347 | struct ps3_sys_manager_header header; |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 348 | struct { |
| 349 | u8 version; |
| 350 | u8 type; |
| 351 | u8 gos_id; |
| 352 | u8 reserved_1[13]; |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 353 | } payload; |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 354 | |
| 355 | BUILD_BUG_ON(sizeof(payload) != 16); |
| 356 | |
| 357 | dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); |
| 358 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 359 | memset(&header, 0, sizeof(header)); |
| 360 | header.version = 1; |
| 361 | header.size = 16; |
| 362 | header.payload_size = 16; |
| 363 | header.service_id = PS3_SM_SERVICE_ID_REQUEST; |
| 364 | |
| 365 | memset(&payload, 0, sizeof(payload)); |
| 366 | payload.version = 1; |
| 367 | payload.type = 1; /* shutdown */ |
| 368 | payload.gos_id = 0; /* self */ |
| 369 | |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 370 | return ps3_sys_manager_write(dev, &header, &payload); |
| 371 | } |
| 372 | |
| 373 | /** |
| 374 | * ps3_sys_manager_send_response - Send a 'response' to the system manager. |
| 375 | * @status: zero = success, others fail. |
| 376 | * |
| 377 | * The guest sends this message to the system manager to acnowledge success or |
| 378 | * failure of a command sent by the system manager. |
| 379 | */ |
| 380 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 381 | static int ps3_sys_manager_send_response(struct ps3_system_bus_device *dev, |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 382 | u64 status) |
| 383 | { |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 384 | struct ps3_sys_manager_header header; |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 385 | struct { |
| 386 | u8 version; |
| 387 | u8 reserved_1[3]; |
| 388 | u8 status; |
| 389 | u8 reserved_2[11]; |
| 390 | } payload; |
| 391 | |
| 392 | BUILD_BUG_ON(sizeof(payload) != 16); |
| 393 | |
| 394 | dev_dbg(&dev->core, "%s:%d: (%s)\n", __func__, __LINE__, |
| 395 | (status ? "nak" : "ack")); |
| 396 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 397 | memset(&header, 0, sizeof(header)); |
| 398 | header.version = 1; |
| 399 | header.size = 16; |
| 400 | header.payload_size = 16; |
| 401 | header.service_id = PS3_SM_SERVICE_ID_RESPONSE; |
| 402 | |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 403 | memset(&payload, 0, sizeof(payload)); |
| 404 | payload.version = 1; |
| 405 | payload.status = status; |
| 406 | |
| 407 | return ps3_sys_manager_write(dev, &header, &payload); |
| 408 | } |
| 409 | |
| 410 | /** |
| 411 | * ps3_sys_manager_handle_event - Second stage event msg handler. |
| 412 | * |
| 413 | */ |
| 414 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 415 | static int ps3_sys_manager_handle_event(struct ps3_system_bus_device *dev) |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 416 | { |
| 417 | int result; |
| 418 | struct { |
| 419 | u8 version; |
| 420 | u8 type; |
| 421 | u8 reserved_1[2]; |
| 422 | u32 value; |
| 423 | u8 reserved_2[8]; |
| 424 | } event; |
| 425 | |
| 426 | BUILD_BUG_ON(sizeof(event) != 16); |
| 427 | |
| 428 | result = ps3_vuart_read(dev, &event, sizeof(event)); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 429 | BUG_ON(result && "need to retry here"); |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 430 | |
| 431 | if (event.version != 1) { |
| 432 | dev_dbg(&dev->core, "%s:%d: unsupported event version (%u)\n", |
| 433 | __func__, __LINE__, event.version); |
| 434 | return -EIO; |
| 435 | } |
| 436 | |
| 437 | switch (event.type) { |
| 438 | case PS3_SM_EVENT_POWER_PRESSED: |
Geoff Levand | ea24608 | 2008-02-09 09:53:07 +1100 | [diff] [blame] | 439 | dev_dbg(&dev->core, "%s:%d: POWER_PRESSED (%s)\n", |
| 440 | __func__, __LINE__, |
| 441 | (event.value == PS3_SM_BUTTON_EVENT_SOFT ? "soft" |
| 442 | : "hard")); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 443 | ps3_sm_force_power_off = 1; |
| 444 | /* |
| 445 | * A memory barrier is use here to sync memory since |
| 446 | * ps3_sys_manager_final_restart() could be called on |
| 447 | * another cpu. |
| 448 | */ |
| 449 | wmb(); |
| 450 | kill_cad_pid(SIGINT, 1); /* ctrl_alt_del */ |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 451 | break; |
| 452 | case PS3_SM_EVENT_POWER_RELEASED: |
| 453 | dev_dbg(&dev->core, "%s:%d: POWER_RELEASED (%u ms)\n", |
| 454 | __func__, __LINE__, event.value); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 455 | break; |
| 456 | case PS3_SM_EVENT_RESET_PRESSED: |
Geoff Levand | ea24608 | 2008-02-09 09:53:07 +1100 | [diff] [blame] | 457 | dev_dbg(&dev->core, "%s:%d: RESET_PRESSED (%s)\n", |
| 458 | __func__, __LINE__, |
| 459 | (event.value == PS3_SM_BUTTON_EVENT_SOFT ? "soft" |
| 460 | : "hard")); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 461 | ps3_sm_force_power_off = 0; |
| 462 | /* |
| 463 | * A memory barrier is use here to sync memory since |
| 464 | * ps3_sys_manager_final_restart() could be called on |
| 465 | * another cpu. |
| 466 | */ |
| 467 | wmb(); |
| 468 | kill_cad_pid(SIGINT, 1); /* ctrl_alt_del */ |
| 469 | break; |
| 470 | case PS3_SM_EVENT_RESET_RELEASED: |
| 471 | dev_dbg(&dev->core, "%s:%d: RESET_RELEASED (%u ms)\n", |
| 472 | __func__, __LINE__, event.value); |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 473 | break; |
| 474 | case PS3_SM_EVENT_THERMAL_ALERT: |
| 475 | dev_dbg(&dev->core, "%s:%d: THERMAL_ALERT (zone %u)\n", |
| 476 | __func__, __LINE__, event.value); |
Geert Uytterhoeven | eff56c9 | 2008-01-19 07:32:14 +1100 | [diff] [blame] | 477 | pr_info("PS3 Thermal Alert Zone %u\n", event.value); |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 478 | break; |
| 479 | case PS3_SM_EVENT_THERMAL_CLEARED: |
| 480 | dev_dbg(&dev->core, "%s:%d: THERMAL_CLEARED (zone %u)\n", |
| 481 | __func__, __LINE__, event.value); |
| 482 | break; |
| 483 | default: |
| 484 | dev_dbg(&dev->core, "%s:%d: unknown event (%u)\n", |
| 485 | __func__, __LINE__, event.type); |
| 486 | return -EIO; |
| 487 | } |
| 488 | |
| 489 | return 0; |
| 490 | } |
| 491 | /** |
| 492 | * ps3_sys_manager_handle_cmd - Second stage command msg handler. |
| 493 | * |
| 494 | * The system manager sends this in reply to a 'request' message from the guest. |
| 495 | */ |
| 496 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 497 | static int ps3_sys_manager_handle_cmd(struct ps3_system_bus_device *dev) |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 498 | { |
| 499 | int result; |
| 500 | struct { |
| 501 | u8 version; |
| 502 | u8 type; |
| 503 | u8 reserved_1[14]; |
| 504 | } cmd; |
| 505 | |
| 506 | BUILD_BUG_ON(sizeof(cmd) != 16); |
| 507 | |
| 508 | dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); |
| 509 | |
| 510 | result = ps3_vuart_read(dev, &cmd, sizeof(cmd)); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 511 | BUG_ON(result && "need to retry here"); |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 512 | |
Geert Uytterhoeven | eff56c9 | 2008-01-19 07:32:14 +1100 | [diff] [blame] | 513 | if (result) |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 514 | return result; |
| 515 | |
| 516 | if (cmd.version != 1) { |
| 517 | dev_dbg(&dev->core, "%s:%d: unsupported cmd version (%u)\n", |
| 518 | __func__, __LINE__, cmd.version); |
| 519 | return -EIO; |
| 520 | } |
| 521 | |
| 522 | if (cmd.type != PS3_SM_CMD_SHUTDOWN) { |
| 523 | dev_dbg(&dev->core, "%s:%d: unknown cmd (%u)\n", |
| 524 | __func__, __LINE__, cmd.type); |
| 525 | return -EIO; |
| 526 | } |
| 527 | |
| 528 | ps3_sys_manager_send_response(dev, 0); |
| 529 | return 0; |
| 530 | } |
| 531 | |
| 532 | /** |
| 533 | * ps3_sys_manager_handle_msg - First stage msg handler. |
| 534 | * |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 535 | * Can be called directly to manually poll vuart and pump message handler. |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 536 | */ |
| 537 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 538 | static int ps3_sys_manager_handle_msg(struct ps3_system_bus_device *dev) |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 539 | { |
| 540 | int result; |
| 541 | struct ps3_sys_manager_header header; |
| 542 | |
| 543 | result = ps3_vuart_read(dev, &header, |
| 544 | sizeof(struct ps3_sys_manager_header)); |
| 545 | |
Geert Uytterhoeven | eff56c9 | 2008-01-19 07:32:14 +1100 | [diff] [blame] | 546 | if (result) |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 547 | return result; |
| 548 | |
| 549 | if (header.version != 1) { |
| 550 | dev_dbg(&dev->core, "%s:%d: unsupported header version (%u)\n", |
| 551 | __func__, __LINE__, header.version); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 552 | dump_sm_header(&header); |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 553 | goto fail_header; |
| 554 | } |
| 555 | |
| 556 | BUILD_BUG_ON(sizeof(header) != 16); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 557 | |
| 558 | if (header.size != 16 || (header.payload_size != 8 |
| 559 | && header.payload_size != 16)) { |
| 560 | dump_sm_header(&header); |
| 561 | BUG(); |
| 562 | } |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 563 | |
| 564 | switch (header.service_id) { |
| 565 | case PS3_SM_SERVICE_ID_EXTERN_EVENT: |
| 566 | dev_dbg(&dev->core, "%s:%d: EVENT\n", __func__, __LINE__); |
| 567 | return ps3_sys_manager_handle_event(dev); |
| 568 | case PS3_SM_SERVICE_ID_COMMAND: |
| 569 | dev_dbg(&dev->core, "%s:%d: COMMAND\n", __func__, __LINE__); |
| 570 | return ps3_sys_manager_handle_cmd(dev); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 571 | case PS3_SM_SERVICE_ID_REQUEST_ERROR: |
| 572 | dev_dbg(&dev->core, "%s:%d: REQUEST_ERROR\n", __func__, |
| 573 | __LINE__); |
| 574 | dump_sm_header(&header); |
| 575 | break; |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 576 | default: |
| 577 | dev_dbg(&dev->core, "%s:%d: unknown service_id (%u)\n", |
| 578 | __func__, __LINE__, header.service_id); |
| 579 | break; |
| 580 | } |
| 581 | goto fail_id; |
| 582 | |
| 583 | fail_header: |
| 584 | ps3_vuart_clear_rx_bytes(dev, 0); |
| 585 | return -EIO; |
| 586 | fail_id: |
| 587 | ps3_vuart_clear_rx_bytes(dev, header.payload_size); |
| 588 | return -EIO; |
| 589 | } |
| 590 | |
Geert Uytterhoeven | ca052f7 | 2008-03-27 11:38:31 +1100 | [diff] [blame] | 591 | static void ps3_sys_manager_fin(struct ps3_system_bus_device *dev) |
| 592 | { |
| 593 | ps3_sys_manager_send_request_shutdown(dev); |
| 594 | |
| 595 | pr_emerg("System Halted, OK to turn off power\n"); |
| 596 | |
| 597 | while (ps3_sys_manager_handle_msg(dev)) { |
| 598 | /* pause until next DEC interrupt */ |
| 599 | lv1_pause(0); |
| 600 | } |
| 601 | |
| 602 | while (1) { |
| 603 | /* pause, ignoring DEC interrupt */ |
| 604 | lv1_pause(1); |
| 605 | } |
| 606 | } |
| 607 | |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 608 | /** |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 609 | * ps3_sys_manager_final_power_off - The final platform machine_power_off routine. |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 610 | * |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 611 | * This routine never returns. The routine disables asynchronous vuart reads |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 612 | * then spins calling ps3_sys_manager_handle_msg() to receive and acknowledge |
| 613 | * the shutdown command sent from the system manager. Soon after the |
| 614 | * acknowledgement is sent the lpar is destroyed by the HV. This routine |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 615 | * should only be called from ps3_power_off() through |
| 616 | * ps3_sys_manager_ops.power_off. |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 617 | */ |
| 618 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 619 | static void ps3_sys_manager_final_power_off(struct ps3_system_bus_device *dev) |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 620 | { |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 621 | BUG_ON(!dev); |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 622 | |
| 623 | dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); |
| 624 | |
| 625 | ps3_vuart_cancel_async(dev); |
| 626 | |
| 627 | ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_SHUTDOWN, |
Geoff Levand | 1c43d26 | 2008-03-27 11:39:04 +1100 | [diff] [blame] | 628 | user_wake_sources); |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 629 | |
Geert Uytterhoeven | ca052f7 | 2008-03-27 11:38:31 +1100 | [diff] [blame] | 630 | ps3_sys_manager_fin(dev); |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 631 | } |
| 632 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 633 | /** |
| 634 | * ps3_sys_manager_final_restart - The final platform machine_restart routine. |
| 635 | * |
| 636 | * This routine never returns. The routine disables asynchronous vuart reads |
| 637 | * then spins calling ps3_sys_manager_handle_msg() to receive and acknowledge |
| 638 | * the shutdown command sent from the system manager. Soon after the |
| 639 | * acknowledgement is sent the lpar is destroyed by the HV. This routine |
| 640 | * should only be called from ps3_restart() through ps3_sys_manager_ops.restart. |
| 641 | */ |
| 642 | |
| 643 | static void ps3_sys_manager_final_restart(struct ps3_system_bus_device *dev) |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 644 | { |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 645 | BUG_ON(!dev); |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 646 | |
| 647 | dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); |
| 648 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 649 | /* Check if we got here via a power button event. */ |
| 650 | |
| 651 | if (ps3_sm_force_power_off) { |
| 652 | dev_dbg(&dev->core, "%s:%d: forcing poweroff\n", |
| 653 | __func__, __LINE__); |
| 654 | ps3_sys_manager_final_power_off(dev); |
| 655 | } |
| 656 | |
| 657 | ps3_vuart_cancel_async(dev); |
| 658 | |
| 659 | ps3_sys_manager_send_attr(dev, 0); |
Geoff Levand | 75ffe88 | 2008-02-09 09:52:55 +1100 | [diff] [blame] | 660 | ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_REBOOT, |
Geoff Levand | 1c43d26 | 2008-03-27 11:39:04 +1100 | [diff] [blame] | 661 | user_wake_sources); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 662 | |
Geert Uytterhoeven | ca052f7 | 2008-03-27 11:38:31 +1100 | [diff] [blame] | 663 | ps3_sys_manager_fin(dev); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 664 | } |
| 665 | |
| 666 | /** |
Geoff Levand | 1c43d26 | 2008-03-27 11:39:04 +1100 | [diff] [blame] | 667 | * ps3_sys_manager_get_wol - Get wake-on-lan setting. |
| 668 | */ |
| 669 | |
| 670 | int ps3_sys_manager_get_wol(void) |
| 671 | { |
| 672 | pr_debug("%s:%d\n", __func__, __LINE__); |
| 673 | |
| 674 | return (user_wake_sources & PS3_SM_WAKE_W_O_L) != 0; |
| 675 | } |
| 676 | EXPORT_SYMBOL_GPL(ps3_sys_manager_get_wol); |
| 677 | |
| 678 | /** |
| 679 | * ps3_sys_manager_set_wol - Set wake-on-lan setting. |
| 680 | */ |
| 681 | |
| 682 | void ps3_sys_manager_set_wol(int state) |
| 683 | { |
| 684 | static DEFINE_MUTEX(mutex); |
| 685 | |
| 686 | mutex_lock(&mutex); |
| 687 | |
| 688 | pr_debug("%s:%d: %d\n", __func__, __LINE__, state); |
| 689 | |
| 690 | if (state) |
| 691 | user_wake_sources |= PS3_SM_WAKE_W_O_L; |
| 692 | else |
| 693 | user_wake_sources &= ~PS3_SM_WAKE_W_O_L; |
| 694 | mutex_unlock(&mutex); |
| 695 | } |
| 696 | EXPORT_SYMBOL_GPL(ps3_sys_manager_set_wol); |
| 697 | |
| 698 | /** |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 699 | * ps3_sys_manager_work - Asynchronous read handler. |
| 700 | * |
| 701 | * Signaled when PS3_SM_RX_MSG_LEN_MIN bytes arrive at the vuart port. |
| 702 | */ |
| 703 | |
| 704 | static void ps3_sys_manager_work(struct ps3_system_bus_device *dev) |
| 705 | { |
| 706 | ps3_sys_manager_handle_msg(dev); |
| 707 | ps3_vuart_read_async(dev, PS3_SM_RX_MSG_LEN_MIN); |
| 708 | } |
| 709 | |
Greg Kroah-Hartman | 0fe763c | 2012-12-21 15:14:44 -0800 | [diff] [blame] | 710 | static int ps3_sys_manager_probe(struct ps3_system_bus_device *dev) |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 711 | { |
| 712 | int result; |
| 713 | struct ps3_sys_manager_ops ops; |
| 714 | |
| 715 | dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); |
| 716 | |
| 717 | ops.power_off = ps3_sys_manager_final_power_off; |
| 718 | ops.restart = ps3_sys_manager_final_restart; |
| 719 | ops.dev = dev; |
| 720 | |
| 721 | /* ps3_sys_manager_register_ops copies ops. */ |
| 722 | |
| 723 | ps3_sys_manager_register_ops(&ops); |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 724 | |
| 725 | result = ps3_sys_manager_send_attr(dev, PS3_SM_ATTR_ALL); |
| 726 | BUG_ON(result); |
| 727 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 728 | result = ps3_vuart_read_async(dev, PS3_SM_RX_MSG_LEN_MIN); |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 729 | BUG_ON(result); |
| 730 | |
| 731 | return result; |
| 732 | } |
| 733 | |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 734 | static int ps3_sys_manager_remove(struct ps3_system_bus_device *dev) |
| 735 | { |
| 736 | dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); |
| 737 | return 0; |
| 738 | } |
| 739 | |
| 740 | static void ps3_sys_manager_shutdown(struct ps3_system_bus_device *dev) |
| 741 | { |
| 742 | dev_dbg(&dev->core, "%s:%d\n", __func__, __LINE__); |
| 743 | } |
| 744 | |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 745 | static struct ps3_vuart_port_driver ps3_sys_manager = { |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 746 | .core.match_id = PS3_MATCH_ID_SYSTEM_MANAGER, |
| 747 | .core.core.name = "ps3_sys_manager", |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 748 | .probe = ps3_sys_manager_probe, |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 749 | .remove = ps3_sys_manager_remove, |
| 750 | .shutdown = ps3_sys_manager_shutdown, |
| 751 | .work = ps3_sys_manager_work, |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 752 | }; |
| 753 | |
| 754 | static int __init ps3_sys_manager_init(void) |
| 755 | { |
Geert Uytterhoeven | ef596c6 | 2007-03-10 00:05:38 +0100 | [diff] [blame] | 756 | if (!firmware_has_feature(FW_FEATURE_PS3_LV1)) |
| 757 | return -ENODEV; |
| 758 | |
Geoff Levand | fde5efd | 2007-02-07 12:20:01 -0800 | [diff] [blame] | 759 | return ps3_vuart_port_driver_register(&ps3_sys_manager); |
| 760 | } |
| 761 | |
| 762 | module_init(ps3_sys_manager_init); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 763 | /* Module remove not supported. */ |
| 764 | |
Geoff Levand | 50dad90 | 2008-02-09 09:53:01 +1100 | [diff] [blame] | 765 | MODULE_AUTHOR("Sony Corporation"); |
| 766 | MODULE_LICENSE("GPL v2"); |
| 767 | MODULE_DESCRIPTION("PS3 System Manager"); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 768 | MODULE_ALIAS(PS3_MODULE_ALIAS_SYSTEM_MANAGER); |