hvc_vio.c (ef8c029fa793423439e67ef0416b220d3fa3321a) | hvc_vio.c (46e99c4a1d57dc73e518466bb3a8da9e7094415e) |
---|---|
1/* 2 * vio driver interface to hvc_console.c 3 * 4 * This code was moved here to allow the remaining code to be reused as a 5 * generic polling mode with semi-reliable transport driver core to the 6 * console and tty subsystems. 7 * 8 * --- 216 unchanged lines hidden (view full) --- 225 .put_chars = hvterm_hvsi_put_chars, 226 .notifier_add = hvterm_hvsi_open, 227 .notifier_del = hvterm_hvsi_close, 228 .notifier_hangup = hvterm_hvsi_hangup, 229 .tiocmget = hvterm_hvsi_tiocmget, 230 .tiocmset = hvterm_hvsi_tiocmset, 231}; 232 | 1/* 2 * vio driver interface to hvc_console.c 3 * 4 * This code was moved here to allow the remaining code to be reused as a 5 * generic polling mode with semi-reliable transport driver core to the 6 * console and tty subsystems. 7 * 8 * --- 216 unchanged lines hidden (view full) --- 225 .put_chars = hvterm_hvsi_put_chars, 226 .notifier_add = hvterm_hvsi_open, 227 .notifier_del = hvterm_hvsi_close, 228 .notifier_hangup = hvterm_hvsi_hangup, 229 .tiocmget = hvterm_hvsi_tiocmget, 230 .tiocmset = hvterm_hvsi_tiocmset, 231}; 232 |
233static void udbg_hvc_putc(char c) 234{ 235 int count = -1; 236 237 if (!hvterm_privs[0]) 238 return; 239 240 if (c == '\n') 241 udbg_hvc_putc('\r'); 242 243 do { 244 switch(hvterm_privs[0]->proto) { 245 case HV_PROTOCOL_RAW: 246 count = hvterm_raw_put_chars(0, &c, 1); 247 break; 248 case HV_PROTOCOL_HVSI: 249 count = hvterm_hvsi_put_chars(0, &c, 1); 250 break; 251 } 252 } while(count == 0); 253} 254 255static int udbg_hvc_getc_poll(void) 256{ 257 int rc = 0; 258 char c; 259 260 if (!hvterm_privs[0]) 261 return -1; 262 263 switch(hvterm_privs[0]->proto) { 264 case HV_PROTOCOL_RAW: 265 rc = hvterm_raw_get_chars(0, &c, 1); 266 break; 267 case HV_PROTOCOL_HVSI: 268 rc = hvterm_hvsi_get_chars(0, &c, 1); 269 break; 270 } 271 if (!rc) 272 return -1; 273 return c; 274} 275 276static int udbg_hvc_getc(void) 277{ 278 int ch; 279 280 if (!hvterm_privs[0]) 281 return -1; 282 283 for (;;) { 284 ch = udbg_hvc_getc_poll(); 285 if (ch == -1) { 286 /* This shouldn't be needed...but... */ 287 volatile unsigned long delay; 288 for (delay=0; delay < 2000000; delay++) 289 ; 290 } else { 291 return ch; 292 } 293 } 294} 295 | |
296static int __devinit hvc_vio_probe(struct vio_dev *vdev, 297 const struct vio_device_id *id) 298{ 299 const struct hv_ops *ops; 300 struct hvc_struct *hp; 301 struct hvterm_priv *pv; 302 hv_protocol_t proto; 303 int i, termno = -1; --- 4 unchanged lines hidden (view full) --- 308 309 if (of_device_is_compatible(vdev->dev.of_node, "hvterm1")) { 310 proto = HV_PROTOCOL_RAW; 311 ops = &hvterm_raw_ops; 312 } else if (of_device_is_compatible(vdev->dev.of_node, "hvterm-protocol")) { 313 proto = HV_PROTOCOL_HVSI; 314 ops = &hvterm_hvsi_ops; 315 } else { | 233static int __devinit hvc_vio_probe(struct vio_dev *vdev, 234 const struct vio_device_id *id) 235{ 236 const struct hv_ops *ops; 237 struct hvc_struct *hp; 238 struct hvterm_priv *pv; 239 hv_protocol_t proto; 240 int i, termno = -1; --- 4 unchanged lines hidden (view full) --- 245 246 if (of_device_is_compatible(vdev->dev.of_node, "hvterm1")) { 247 proto = HV_PROTOCOL_RAW; 248 ops = &hvterm_raw_ops; 249 } else if (of_device_is_compatible(vdev->dev.of_node, "hvterm-protocol")) { 250 proto = HV_PROTOCOL_HVSI; 251 ops = &hvterm_hvsi_ops; 252 } else { |
316 pr_err("hvc_vio: Unkown protocol for %s\n", vdev->dev.of_node->full_name); | 253 pr_err("hvc_vio: Unknown protocol for %s\n", vdev->dev.of_node->full_name); |
317 return -ENXIO; 318 } 319 320 pr_devel("hvc_vio_probe() device %s, using %s protocol\n", 321 vdev->dev.of_node->full_name, 322 proto == HV_PROTOCOL_RAW ? "raw" : "hvsi"); 323 324 /* Is it our boot one ? */ --- 22 unchanged lines hidden (view full) --- 347 pv->termno, 0); 348 } 349 350 hp = hvc_alloc(termno, vdev->irq, ops, MAX_VIO_PUT_CHARS); 351 if (IS_ERR(hp)) 352 return PTR_ERR(hp); 353 dev_set_drvdata(&vdev->dev, hp); 354 | 254 return -ENXIO; 255 } 256 257 pr_devel("hvc_vio_probe() device %s, using %s protocol\n", 258 vdev->dev.of_node->full_name, 259 proto == HV_PROTOCOL_RAW ? "raw" : "hvsi"); 260 261 /* Is it our boot one ? */ --- 22 unchanged lines hidden (view full) --- 284 pv->termno, 0); 285 } 286 287 hp = hvc_alloc(termno, vdev->irq, ops, MAX_VIO_PUT_CHARS); 288 if (IS_ERR(hp)) 289 return PTR_ERR(hp); 290 dev_set_drvdata(&vdev->dev, hp); 291 |
355 /* register udbg if it's not there already for console 0 */ 356 if (hp->index == 0 && !udbg_putc) { 357 udbg_putc = udbg_hvc_putc; 358 udbg_getc = udbg_hvc_getc; 359 udbg_getc_poll = udbg_hvc_getc_poll; 360 } 361 | |
362 return 0; 363} 364 365static int __devexit hvc_vio_remove(struct vio_dev *vdev) 366{ 367 struct hvc_struct *hp = dev_get_drvdata(&vdev->dev); 368 int rc, termno; 369 --- 26 unchanged lines hidden (view full) --- 396module_init(hvc_vio_init); /* after drivers/char/hvc_console.c */ 397 398static void __exit hvc_vio_exit(void) 399{ 400 vio_unregister_driver(&hvc_vio_driver); 401} 402module_exit(hvc_vio_exit); 403 | 292 return 0; 293} 294 295static int __devexit hvc_vio_remove(struct vio_dev *vdev) 296{ 297 struct hvc_struct *hp = dev_get_drvdata(&vdev->dev); 298 int rc, termno; 299 --- 26 unchanged lines hidden (view full) --- 326module_init(hvc_vio_init); /* after drivers/char/hvc_console.c */ 327 328static void __exit hvc_vio_exit(void) 329{ 330 vio_unregister_driver(&hvc_vio_driver); 331} 332module_exit(hvc_vio_exit); 333 |
334static void udbg_hvc_putc(char c) 335{ 336 int count = -1; 337 338 if (c == '\n') 339 udbg_hvc_putc('\r'); 340 341 do { 342 switch(hvterm_priv0.proto) { 343 case HV_PROTOCOL_RAW: 344 count = hvterm_raw_put_chars(0, &c, 1); 345 break; 346 case HV_PROTOCOL_HVSI: 347 count = hvterm_hvsi_put_chars(0, &c, 1); 348 break; 349 } 350 } while(count == 0); 351} 352 353static int udbg_hvc_getc_poll(void) 354{ 355 int rc = 0; 356 char c; 357 358 switch(hvterm_priv0.proto) { 359 case HV_PROTOCOL_RAW: 360 rc = hvterm_raw_get_chars(0, &c, 1); 361 break; 362 case HV_PROTOCOL_HVSI: 363 rc = hvterm_hvsi_get_chars(0, &c, 1); 364 break; 365 } 366 if (!rc) 367 return -1; 368 return c; 369} 370 371static int udbg_hvc_getc(void) 372{ 373 int ch; 374 for (;;) { 375 ch = udbg_hvc_getc_poll(); 376 if (ch == -1) { 377 /* This shouldn't be needed...but... */ 378 volatile unsigned long delay; 379 for (delay=0; delay < 2000000; delay++) 380 ; 381 } else { 382 return ch; 383 } 384 } 385} 386 |
|
404void __init hvc_vio_init_early(void) 405{ 406 struct device_node *stdout_node; 407 const u32 *termno; 408 const char *name; 409 const struct hv_ops *ops; 410 411 /* find the boot console from /chosen/stdout */ --- 85 unchanged lines hidden --- | 387void __init hvc_vio_init_early(void) 388{ 389 struct device_node *stdout_node; 390 const u32 *termno; 391 const char *name; 392 const struct hv_ops *ops; 393 394 /* find the boot console from /chosen/stdout */ --- 85 unchanged lines hidden --- |