14
14
#include <linux/init.h>
15
15
#include <linux/module.h>
16
16
#include <linux/delay.h>
17
- #include <linux/spinlock.h>
18
17
#include <linux/io.h>
19
18
#include <linux/string.h>
20
19
#include <linux/platform_device.h>
32
31
struct olpc_platform_t olpc_platform_info ;
33
32
EXPORT_SYMBOL_GPL (olpc_platform_info );
34
33
35
- static DEFINE_SPINLOCK (ec_lock );
36
-
37
34
/* debugfs interface to EC commands */
38
35
#define EC_MAX_CMD_ARGS (5 + 1) /* cmd byte + 5 args */
39
36
#define EC_MAX_CMD_REPLY (8)
@@ -126,16 +123,13 @@ static int __wait_on_obf(unsigned int line, unsigned int port, int desired)
126
123
* <http://wiki.laptop.org/go/Ec_specification>. Unfortunately, while
127
124
* OpenFirmware's source is available, the EC's is not.
128
125
*/
129
- int olpc_ec_cmd_x86 ( unsigned char cmd , unsigned char * inbuf , size_t inlen ,
130
- unsigned char * outbuf , size_t outlen )
126
+ static int olpc_xo1_ec_cmd ( u8 cmd , u8 * inbuf , size_t inlen , u8 * outbuf ,
127
+ size_t outlen , void * arg )
131
128
{
132
- unsigned long flags ;
133
129
int ret = - EIO ;
134
130
int i ;
135
131
int restarts = 0 ;
136
132
137
- spin_lock_irqsave (& ec_lock , flags );
138
-
139
133
/* Clear OBF */
140
134
for (i = 0 ; i < 10 && (obf_status (0x6c ) == 1 ); i ++ )
141
135
inb (0x68 );
@@ -199,10 +193,8 @@ int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf, size_t inlen,
199
193
200
194
ret = 0 ;
201
195
err :
202
- spin_unlock_irqrestore (& ec_lock , flags );
203
196
return ret ;
204
197
}
205
- EXPORT_SYMBOL_GPL (olpc_ec_cmd_x86 );
206
198
207
199
void olpc_ec_wakeup_set (u16 value )
208
200
{
@@ -366,7 +358,7 @@ static void setup_debugfs(void)
366
358
& ec_debugfs_genops );
367
359
}
368
360
369
- static int olpc_ec_suspend (void )
361
+ static int olpc_ec_suspend (struct platform_device * pdev )
370
362
{
371
363
return olpc_ec_mask_write (ec_wakeup_mask );
372
364
}
@@ -425,8 +417,28 @@ static int __init add_xo1_platform_devices(void)
425
417
return 0 ;
426
418
}
427
419
428
- static struct syscore_ops olpc_syscore_ops = {
420
+ static int olpc_xo1_ec_probe (struct platform_device * pdev )
421
+ {
422
+ /* get the EC revision */
423
+ olpc_ec_cmd (EC_FIRMWARE_REV , NULL , 0 ,
424
+ (unsigned char * ) & olpc_platform_info .ecver , 1 );
425
+
426
+ /* EC version 0x5f adds support for wide SCI mask */
427
+ if (olpc_platform_info .ecver >= 0x5f )
428
+ olpc_platform_info .flags |= OLPC_F_EC_WIDE_SCI ;
429
+
430
+ pr_info ("OLPC board revision %s%X (EC=%x)\n" ,
431
+ ((olpc_platform_info .boardrev & 0xf ) < 8 ) ? "pre" : "" ,
432
+ olpc_platform_info .boardrev >> 4 ,
433
+ olpc_platform_info .ecver );
434
+
435
+ return 0 ;
436
+ }
437
+
438
+ static struct olpc_ec_driver ec_xo1_driver = {
429
439
.suspend = olpc_ec_suspend ,
440
+ .probe = olpc_xo1_ec_probe ,
441
+ .ec_cmd = olpc_xo1_ec_cmd ,
430
442
};
431
443
432
444
static int __init olpc_init (void )
@@ -436,39 +448,28 @@ static int __init olpc_init(void)
436
448
if (!olpc_ofw_present () || !platform_detect ())
437
449
return 0 ;
438
450
439
- spin_lock_init (& ec_lock );
451
+ /* register the XO-1 and 1.5-specific EC handler */
452
+ olpc_ec_driver_register (& ec_xo1_driver , NULL );
453
+ platform_device_register_simple ("olpc-ec" , -1 , NULL , 0 );
440
454
441
455
/* assume B1 and above models always have a DCON */
442
456
if (olpc_board_at_least (olpc_board (0xb1 )))
443
457
olpc_platform_info .flags |= OLPC_F_DCON ;
444
458
445
- /* get the EC revision */
446
- olpc_ec_cmd (EC_FIRMWARE_REV , NULL , 0 ,
447
- (unsigned char * ) & olpc_platform_info .ecver , 1 );
448
-
449
459
#ifdef CONFIG_PCI_OLPC
450
460
/* If the VSA exists let it emulate PCI, if not emulate in kernel.
451
461
* XO-1 only. */
452
462
if (olpc_platform_info .boardrev < olpc_board_pre (0xd0 ) &&
453
463
!cs5535_has_vsa2 ())
454
464
x86_init .pci .arch_init = pci_olpc_init ;
455
465
#endif
456
- /* EC version 0x5f adds support for wide SCI mask */
457
- if (olpc_platform_info .ecver >= 0x5f )
458
- olpc_platform_info .flags |= OLPC_F_EC_WIDE_SCI ;
459
-
460
- printk (KERN_INFO "OLPC board revision %s%X (EC=%x)\n" ,
461
- ((olpc_platform_info .boardrev & 0xf ) < 8 ) ? "pre" : "" ,
462
- olpc_platform_info .boardrev >> 4 ,
463
- olpc_platform_info .ecver );
464
466
465
467
if (olpc_platform_info .boardrev < olpc_board_pre (0xd0 )) { /* XO-1 */
466
468
r = add_xo1_platform_devices ();
467
469
if (r )
468
470
return r ;
469
471
}
470
472
471
- register_syscore_ops (& olpc_syscore_ops );
472
473
setup_debugfs ();
473
474
474
475
return 0 ;
0 commit comments