summaryrefstree
path: root/kernel/drivers/misc/modem_v1/modem_ctrl_ss333.c
blob: 7703b0fbe4ccda2df9596fe58456bec62b8c3742 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
/*
 * Copyright (C) 2010 Samsung Electronics.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include <linux/init.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/gpio.h>
#include <linux/delay.h>
#include <linux/platform_device.h>

#include <linux/mipi-lli.h>
#include "modem_prj.h"
#include "modem_utils.h"

#include <linux/modem_notifier.h>

#include <linux/of_gpio.h>

#define MIF_INIT_TIMEOUT	(30 * HZ)

enum crash_reason_event
{
	CRASH_REASON_RESET = 0,
	CRASH_REASON_EXIT,
	CRASH_REASON_AT_RX,
	CRASH_REASON_AT_TX,
	CRASH_REASON_AP_PM,
	CRASH_REASON_CP_PM,
	CRASH_REASON_MAX_CNT
};

static const char const *cp_crash_reason[] = {
	[CRASH_REASON_RESET] = "CP_CRASH_RESET\n",
	[CRASH_REASON_EXIT] = "CP_CRASH_EXIT\n",
	[CRASH_REASON_AT_RX] = "abnormal RX. contact to CP team\n",
	[CRASH_REASON_AT_TX] = "abnormal TX. contack to AP team\n",
	[CRASH_REASON_AP_PM] = "PM TIMEOUT. contact to AP team\n",
	[CRASH_REASON_CP_PM] = "PM failed. CP team needs to investigate on their improper PM operations\n"
};

static struct wake_lock mc_wake_lock;

static void print_mc_state(struct modem_ctl *mc)
{
	int cp_on = gpio_get_value(mc->gpio_cp_on);
	int cp_reset  = gpio_get_value(mc->gpio_cp_reset);
	int cp_active = gpio_get_value(mc->gpio_phone_active);
	int cp_status = gpio_get_value(mc->gpio_cp_status);
	unsigned int event = mc->crash_info;
	int cp_dump_int = gpio_get_value(mc->gpio_cp_dump_int);

	mif_info("%s: %pf: MC state:%s "
		"on:%d reset:%d active:%d status:%d cp_dump_int:%d reason:%d\n",
		mc->name, CALLER, mc_state(mc), cp_on, cp_reset, cp_active,
		cp_status, cp_dump_int, event);
}

void modem_state_change(struct modem_ctl *mc, enum modem_state new_state)
{
	if (mc->iod && mc->iod->modem_state_changed)
		mc->iod->modem_state_changed(mc->iod, new_state);

	if (mc->iod_ds && mc->iod_ds->modem_state_changed)
		mc->iod_ds->modem_state_changed(mc->iod_ds, new_state);

	if (mc->bootd && mc->bootd->modem_state_changed)
		mc->bootd->modem_state_changed(mc->bootd, new_state);

	modem_notify_event(new_state);
}

static irqreturn_t cp_active_handler(int irq, void *arg)
{
	struct modem_ctl *mc = (struct modem_ctl *)arg;
	struct link_device *ld;
	enum modem_state old_state;
	enum modem_state new_state;
	unsigned long flags;

	if (!cp_online(mc))
		goto exit;

	print_mc_state(mc);

	if (gpio_get_value(mc->gpio_cp_reset) == 0)
		goto exit;

	ld = get_current_link(mc->iod);

	spin_lock_irqsave(&mc->lock, flags);

	old_state = mc->phone_state;
	new_state = mc->phone_state;

	if (gpio_get_value(mc->gpio_phone_active) != 0) {
		if (gpio_get_value(mc->gpio_cp_on) == 0) {
			new_state = STATE_OFFLINE;
		} else if (gpio_get_value(mc->gpio_cp_dump_int) == 0) {
			new_state = STATE_CRASH_RESET;
		} else if (old_state == STATE_ONLINE) {
			new_state = STATE_CRASH_EXIT;
		} else {
			mif_err("%s: %s: don't care!!!\n", mc->name, FUNC);
		}
	}

	if (new_state != old_state)
		modem_state_change(mc, new_state);

	spin_unlock_irqrestore(&mc->lock, flags);

	if ((old_state == STATE_ONLINE) &&
	    ((new_state == STATE_CRASH_EXIT) ||
	     (new_state == STATE_CRASH_RESET))) {
		if (timer_pending(&mc->crash_ack_timer))
			del_timer(&mc->crash_ack_timer);

		if (ld->close_tx)
			ld->close_tx(ld);
	}

exit:
	return IRQ_HANDLED;
}

static int unmount_noti_cb(struct notifier_block *nb, unsigned long event,
			   void *data)
{
	struct modem_link_pm *pm;
	struct link_device *ld;
	struct modem_ctl *mc;

	if (!nb)
		return 0;

	/* If we aren't interested in this event, skip it immediately ... */
	if (event != PM_EVENT_LINK_UNMOUNTED)
		return 0;

	/* @data can be NULL if CP crash occurs during phone booting */
	if (!data)
		return 0;

	pm = (struct modem_link_pm *)data;
	ld = pm_to_link_device(pm);
	mc = ld->mc;

	complete_all(&mc->off_cmpl);

	return 0;
}

static inline void wait_for_link_unmount(struct modem_ctl *mc,
					 struct link_device *ld)
{
	long result;

	if (!ld->unmounted)
		return;

	if (ld->unmounted(ld))
		return;

	mif_info("%s: wait for %s link unmount ...\n", mc->name, ld->name);

	mc->unmount_nb.notifier_call = unmount_noti_cb;
	pm_register_unmount_notifier(&ld->pm, &mc->unmount_nb);

	result = wait_for_completion_interruptible_timeout(&mc->off_cmpl, 5*HZ);
	if (result <= 0) {
		if (result < 0)
			mif_err("%s: %s link unmount ... INTERRUPTED\n",
				mc->name, ld->name);
		else
			mif_err("%s: %s link unmount ... TIMEOUT\n",
				mc->name, ld->name);
	} else {
		mif_info("%s: %s link unmount ... DONE\n",
			mc->name, ld->name);
	}

	pm_unregister_unmount_notifier(&ld->pm, &mc->unmount_nb);
}

static int ss333_on(struct modem_ctl *mc)
{
	struct io_device *iod = mc->iod;
	struct link_device *ld = get_current_link(iod);
	unsigned long flags;

	mif_disable_irq(&mc->irq_cp_active);

	mif_info("%s: %s: +++\n", mc->name, FUNC);

	print_mc_state(mc);

	spin_lock_irqsave(&mc->lock, flags);

	iod->modem_state_changed(iod, STATE_OFFLINE);

	gpio_set_value(mc->gpio_pda_active, 1);

	if (mc->wake_lock && !wake_lock_active(mc->wake_lock)) {
		wake_lock(mc->wake_lock);
		mif_err("%s->wake_lock locked\n", mc->name);
	}

	if (ld->off)
		ld->off(ld);

	spin_unlock_irqrestore(&mc->lock, flags);

	gpio_set_value(mc->gpio_cp_on, 0);
	msleep(100);

	gpio_set_value(mc->gpio_cp_reset, 0);
	print_mc_state(mc);
	msleep(500);

	gpio_set_value(mc->gpio_cp_on, 1);
	msleep(100);

	if (ld->reset)
		ld->reset(ld);

	if (mc->gpio_ap_dump_int)
		gpio_set_value(mc->gpio_ap_dump_int, 0);

	gpio_set_value(mc->gpio_cp_reset, 1);
	print_mc_state(mc);
	msleep(300);

	mif_info("%s: %s: ---\n", mc->name, FUNC);
	return 0;
}

static int ss333_off(struct modem_ctl *mc)
{
	struct io_device *iod = mc->iod;
	struct link_device *ld = get_current_link(iod);
	unsigned long flags;
	int i;

	mif_disable_irq(&mc->irq_cp_active);

	mif_info("%s: %s: +++\n", mc->name, FUNC);

	print_mc_state(mc);

	spin_lock_irqsave(&mc->lock, flags);

	if (cp_offline(mc)) {
		spin_unlock_irqrestore(&mc->lock, flags);
		mif_err("%s: %s: OFFLINE already!!!\n", mc->name, FUNC);
		goto exit;
	}

	iod->modem_state_changed(iod, STATE_OFFLINE);

	spin_unlock_irqrestore(&mc->lock, flags);

	if (timer_pending(&mc->crash_ack_timer))
		del_timer(&mc->crash_ack_timer);

	if (ld->close_tx)
		ld->close_tx(ld);

#if 0
	wait_for_link_unmount(mc, ld);
#endif

	if (gpio_get_value(mc->gpio_cp_on) == 0) {
		mif_err("%s: cp_on == 0\n", mc->name);
		goto exit;
	}

	/* wait for cp_active for 3 seconds */
	for (i = 0; i < 150; i++) {
		if (gpio_get_value(mc->gpio_phone_active))
			break;
		msleep(20);
	}

	print_mc_state(mc);

	if (ld->off)
		ld->off(ld);

	if (gpio_get_value(mc->gpio_cp_reset)) {
		mif_err("%s: %s: cp_reset -> 0\n", mc->name, FUNC);
		gpio_set_value(mc->gpio_cp_reset, 0);
		print_mc_state(mc);
	}

exit:
	mif_info("%s: %s: ---\n", mc->name, FUNC);
	return 0;
}

static int ss333_reset(struct modem_ctl *mc)
{
	mif_err("+++\n");

	if (mc->phone_state == STATE_ONLINE)
		modem_notify_event(MODEM_EVENT_RESET);

	if (ss333_off(mc))
		return -EIO;

	msleep(100);

	if (ss333_on(mc))
		return -EIO;

	mif_err("---\n");
	return 0;
}

static void handle_no_response_cp_crash(unsigned long arg)
{
	struct modem_ctl *mc = (struct modem_ctl *)arg;
	unsigned long flags;

	if (cp_crashed(mc)) {
		mif_info("%s: STATE_CRASH_EXIT without response from CP\n", mc->name);
		return;
	}

	mif_err("%s: ERR! No response from CP\n", mc->name);

	spin_lock_irqsave(&mc->lock, flags);
	modem_state_change(mc, STATE_CRASH_EXIT);
	spin_unlock_irqrestore(&mc->lock, flags);
}

static int ss333_force_crash_exit(struct modem_ctl *mc)
{
	struct io_device *iod = mc->iod;
	struct link_device *ld = get_current_link(iod);

	mif_err("+++\n");

	mif_add_timer(&mc->crash_ack_timer, FORCE_CRASH_ACK_TIMEOUT,
			      handle_no_response_cp_crash, (unsigned long)mc);

	if (mc->wake_lock && !wake_lock_active(mc->wake_lock)) {
		wake_lock(mc->wake_lock);
		mif_err("%s->wake_lock locked\n", mc->name);
	}

	if (ld->off)
		ld->off(ld);

	gpio_set_value(mc->gpio_ap_dump_int, 1);
	mif_info("set ap_dump_int(%d) to high=%d\n",
		mc->gpio_ap_dump_int, gpio_get_value(mc->gpio_ap_dump_int));

	mif_err("---\n");
	return 0;
}

static int ss333_dump_reset(struct modem_ctl *mc)
{
	struct io_device *iod = mc->iod;
	struct link_device *ld = get_current_link(iod);
	unsigned int gpio_cp_reset = mc->gpio_cp_reset;
	unsigned long flags;

	mif_disable_irq(&mc->irq_cp_active);

	mif_info("%s: %s: +++\n", mc->name, FUNC);

	print_mc_state(mc);

	spin_lock_irqsave(&mc->lock, flags);

	iod->modem_state_changed(iod, STATE_CRASH_EXIT);

	if (mc->wake_lock && !wake_lock_active(mc->wake_lock)) {
		wake_lock(mc->wake_lock);
		mif_err("%s->wake_lock locked\n", mc->name);
	}

	if (ld->off)
		ld->off(ld);

	spin_unlock_irqrestore(&mc->lock, flags);

	gpio_set_value(gpio_cp_reset, 0);
	print_mc_state(mc);
	udelay(200);

	if (ld->reset)
		ld->reset(ld);

	gpio_set_value(gpio_cp_reset, 1);
	print_mc_state(mc);
	msleep(300);

	gpio_set_value(mc->gpio_ap_status, 1);

	mif_info("%s: %s: ---\n", mc->name, FUNC);
	return 0;
}

static int ss333_boot_on(struct modem_ctl *mc)
{
	struct link_device *ld = get_current_link(mc->iod);
	unsigned long flags;
	mif_err("+++\n");

	if (ld->boot_on)
		ld->boot_on(ld, mc->bootd);

	gpio_set_value(mc->gpio_ap_status, 1);

	INIT_COMPLETION(mc->init_cmpl);
	INIT_COMPLETION(mc->off_cmpl);

	spin_lock_irqsave(&mc->lock, flags);
	mc->bootd->modem_state_changed(mc->bootd, STATE_BOOTING);
	mc->iod->modem_state_changed(mc->iod, STATE_BOOTING);
	spin_unlock_irqrestore(&mc->lock, flags);

	mif_err("---\n");
	return 0;
}

static int ss333_boot_off(struct modem_ctl *mc)
{
	unsigned long remain;
	unsigned long flags;
	mif_err("+++\n");

	remain = wait_for_completion_timeout(&mc->init_cmpl, MIF_INIT_TIMEOUT);
	if (remain == 0) {
		mif_err("T-I-M-E-O-U-T\n");
		mif_err("xxx\n");
		return -EAGAIN;
	}

	mif_enable_irq(&mc->irq_cp_active);

	spin_lock_irqsave(&mc->lock, flags);
	mc->bootd->modem_state_changed(mc->bootd, STATE_ONLINE);
	mc->iod->modem_state_changed(mc->iod, STATE_ONLINE);
	spin_unlock_irqrestore(&mc->lock, flags);

	atomic_set(&mc->forced_cp_crash, 0);

	modem_notify_event(MODEM_EVENT_ONLINE);

	mif_err("---\n");
	return 0;
}

static int ss333_boot_done(struct modem_ctl *mc)
{
	mif_err("+++\n");

	if (mc->wake_lock && wake_lock_active(mc->wake_lock)) {
		wake_unlock(mc->wake_lock);
		mif_err("%s->wake_lock unlocked\n", mc->name);
	}

	mif_err("---\n");
	return 0;
}

static int ss333_cp_crash_reason(struct modem_ctl *mc, char *buf)
{
	unsigned int log_len = 0;
	int event = 0;

	switch (mc->crash_info) {
	case MDM_EVENT_CP_FORCE_RESET:
	case MDM_CRASH_CMD_RESET:
		event = CRASH_REASON_RESET;
		break;
	case MDM_EVENT_CP_FORCE_CRASH:
	case MDM_CRASH_CMD_EXIT:
		event = CRASH_REASON_EXIT;
		break;
	case MDM_CRASH_INVALID_RB:
	case MDM_CRASH_NO_MEM:
		event = CRASH_REASON_AT_TX;
		break;
	case MDM_CRASH_INVALID_IOD:
	case MDM_CRASH_INVALID_SKBCB:
	case MDM_CRASH_INVALID_SKBIOD:
	case MDM_CRASH_PACKET_CRACKED:
	case MDM_EVENT_CP_ABNORMAL_RX:
		event = CRASH_REASON_AT_RX;
		break;
	case MDM_CRASH_PM_FAIL:
		event = CRASH_REASON_AP_PM;
		break;
	case MDM_CRASH_PM_CP_FAIL:
		event = CRASH_REASON_CP_PM;
		break;
	default:
		return 0;
	}

	strncat(buf,
		cp_crash_reason[event],
		strlen(cp_crash_reason[event]));
	log_len = strlen(cp_crash_reason[event]);

	return log_len;
}

static void ss333_get_ops(struct modem_ctl *mc)
{
	mc->ops.modem_on = ss333_on;
	mc->ops.modem_off = ss333_off;
	mc->ops.modem_reset = ss333_reset;
	mc->ops.modem_boot_on = ss333_boot_on;
	mc->ops.modem_boot_off = ss333_boot_off;
	mc->ops.modem_boot_done = ss333_boot_done;
	mc->ops.modem_force_crash_exit = ss333_force_crash_exit;
	mc->ops.modem_dump_reset = ss333_dump_reset;
	mc->ops.modem_cp_upload = ss333_cp_crash_reason;
}

static int dt_gpio_config(struct modem_ctl *mc, struct modem_data *pdata)
{
	int ret = 0;
	struct device_node *np = mc->dev->of_node;

	/* GPIO_AP_DUMP_INT */
	pdata->gpio_ap_dump_int =
		of_get_named_gpio(np, "mif,gpio_ap_dump_int", 0);
	if (!gpio_is_valid(pdata->gpio_ap_dump_int)) {
		mif_err("ap_dump_int: Invalied gpio pins\n");
		return -EINVAL;
	}

	ret = gpio_request(pdata->gpio_ap_dump_int, "AP_DUMP_INT");
	if (ret)
		mif_err("fail to request gpio %s:%d\n", "AP_DUMP_INT", ret);
	gpio_direction_output(pdata->gpio_ap_dump_int, 0);

	/* GPIO_CP_DUMP_INT */
	pdata->gpio_cp_dump_int =
		of_get_named_gpio(np, "mif,gpio_cp_dump_int", 0);
	if (!gpio_is_valid(pdata->gpio_cp_dump_int)) {
		mif_err("cp_dump_int: Invalied gpio pins\n");
		return -EINVAL;
	}

	ret = gpio_request(pdata->gpio_cp_dump_int, "CP_DUMP_INT");
	if (ret)
		mif_err("fail to request gpio %s:%d\n", "CP_DUMP_INT", ret);
	gpio_direction_input(pdata->gpio_cp_dump_int);

	return ret;
}

static int modemctl_notify_call(struct notifier_block *nfb,
		unsigned long event, void *arg)
{
	struct modem_ctl *mc = container_of(nfb, struct modem_ctl, event_nfb);
	static int abnormal_rx_cnt = 0;

	mif_info("got event: %ld\n", event);
	mc->crash_info = (unsigned int)event;

	switch (event) {
	case MDM_EVENT_CP_FORCE_RESET:
		modem_state_change(mc, STATE_CRASH_RESET);
		break;
	case MDM_CRASH_PM_FAIL:
	case MDM_CRASH_PM_CP_FAIL:
	case MDM_CRASH_INVALID_RB:
	case MDM_CRASH_INVALID_IOD:
	case MDM_CRASH_INVALID_SKBCB:
	case MDM_CRASH_INVALID_SKBIOD:
	case MDM_CRASH_NO_MEM:
	case MDM_CRASH_CMD_RESET:
	case MDM_CRASH_CMD_EXIT:
	case MDM_EVENT_CP_FORCE_CRASH:
	case MDM_CRASH_BY_IOSM:
		ss333_force_crash_exit(mc);
		break;
	case MDM_EVENT_CP_ABNORMAL_RX:
		if (abnormal_rx_cnt < 5) {
			abnormal_rx_cnt++;
		} else {
			mif_err("abnormal rx count was overflowed.\n");
			abnormal_rx_cnt = 0;
		}
		break;
	}

	modem_notify_event(event);
	return 0;
}

int ss333_init_modemctl_device(struct modem_ctl *mc, struct modem_data *pdata)
{
	int ret = 0;
	unsigned int irq = 0;
	unsigned long flag = 0;
	char name[MAX_NAME_LEN];
	mif_err("+++\n");

	ret = dt_gpio_config(mc, pdata);
	if (ret < 0)
		return ret;

	if (!pdata->gpio_cp_on || !pdata->gpio_cp_reset
	    || !pdata->gpio_pda_active || !pdata->gpio_phone_active
	    || !pdata->gpio_ap_wakeup || !pdata->gpio_ap_status
	    || !pdata->gpio_cp_wakeup || !pdata->gpio_cp_status) {
		mif_err("ERR! no GPIO data\n");
		mif_err("xxx\n");
		return -ENXIO;
	}

	mc->gpio_cp_on = pdata->gpio_cp_on;
	mc->gpio_cp_reset = pdata->gpio_cp_reset;
	mc->gpio_pda_active = pdata->gpio_pda_active;
	mc->gpio_phone_active = pdata->gpio_phone_active;
	mc->gpio_ap_wakeup = pdata->gpio_ap_wakeup;
	mc->gpio_ap_status = pdata->gpio_ap_status;
	mc->gpio_cp_wakeup = pdata->gpio_cp_wakeup;
	mc->gpio_cp_status = pdata->gpio_cp_status;
	mc->gpio_ap_dump_int = pdata->gpio_ap_dump_int;
	mc->gpio_cp_dump_int = pdata->gpio_cp_dump_int;

	gpio_set_value(mc->gpio_cp_reset, 0);
	gpio_set_value(mc->gpio_cp_on, 0);
	print_mc_state(mc);

	ss333_get_ops(mc);
	dev_set_drvdata(mc->dev, mc);

	wake_lock_init(&mc_wake_lock, WAKE_LOCK_SUSPEND, "ss333_wake_lock");
	mc->wake_lock = &mc_wake_lock;

	irq = gpio_to_irq(mc->gpio_phone_active);
	if (!irq) {
		mif_err("ERR! no irq_cp_active\n");
		mif_err("xxx\n");
		return -EINVAL;
	}
	mif_err("PHONE_ACTIVE IRQ# = %d\n", irq);

	mc->event_nfb.notifier_call = modemctl_notify_call;
	register_cp_crash_notifier(&mc->event_nfb);

	flag = IRQF_TRIGGER_RISING | IRQF_NO_THREAD | IRQF_NO_SUSPEND;
	snprintf(name, MAX_NAME_LEN, "%s_active", mc->name);
	mif_init_irq(&mc->irq_cp_active, irq, name, flag);

	ret = mif_request_irq(&mc->irq_cp_active, cp_active_handler, mc);
	if (ret) {
		mif_err("%s: ERR! request_irq(%s#%d) fail (%d)\n",
			mc->name, mc->irq_cp_active.name,
			mc->irq_cp_active.num, ret);
		mif_err("xxx\n");
		return ret;
	}

	mif_err("---\n");
	return 0;
}