22
22
#define INT_STATUS_NUM 3
24
static struct resource bk_resources[] __initdata = {
24
static struct resource bk_resources[] __devinitdata = {
25
25
{PM8606_BACKLIGHT1, PM8606_BACKLIGHT1, "backlight-0", IORESOURCE_IO,},
26
26
{PM8606_BACKLIGHT2, PM8606_BACKLIGHT2, "backlight-1", IORESOURCE_IO,},
27
27
{PM8606_BACKLIGHT3, PM8606_BACKLIGHT3, "backlight-2", IORESOURCE_IO,},
30
static struct resource led_resources[] __initdata = {
30
static struct resource led_resources[] __devinitdata = {
31
31
{PM8606_LED1_RED, PM8606_LED1_RED, "led0-red", IORESOURCE_IO,},
32
32
{PM8606_LED1_GREEN, PM8606_LED1_GREEN, "led0-green", IORESOURCE_IO,},
33
33
{PM8606_LED1_BLUE, PM8606_LED1_BLUE, "led0-blue", IORESOURCE_IO,},
36
36
{PM8606_LED2_BLUE, PM8606_LED2_BLUE, "led1-blue", IORESOURCE_IO,},
39
static struct resource regulator_resources[] __initdata = {
39
static struct resource regulator_resources[] __devinitdata = {
40
40
{PM8607_ID_BUCK1, PM8607_ID_BUCK1, "buck-1", IORESOURCE_IO,},
41
41
{PM8607_ID_BUCK2, PM8607_ID_BUCK2, "buck-2", IORESOURCE_IO,},
42
42
{PM8607_ID_BUCK3, PM8607_ID_BUCK3, "buck-3", IORESOURCE_IO,},
57
57
{PM8607_ID_LDO15, PM8607_ID_LDO15, "ldo-15", IORESOURCE_IO,},
60
static struct resource touch_resources[] __initdata = {
60
static struct resource touch_resources[] __devinitdata = {
61
61
{PM8607_IRQ_PEN, PM8607_IRQ_PEN, "touch", IORESOURCE_IRQ,},
64
static struct resource onkey_resources[] __initdata = {
64
static struct resource onkey_resources[] __devinitdata = {
65
65
{PM8607_IRQ_ONKEY, PM8607_IRQ_ONKEY, "onkey", IORESOURCE_IRQ,},
68
static struct resource codec_resources[] __initdata = {
68
static struct resource codec_resources[] __devinitdata = {
69
69
/* Headset microphone insertion or removal */
70
70
{PM8607_IRQ_MICIN, PM8607_IRQ_MICIN, "micin", IORESOURCE_IRQ,},
71
71
/* Hook-switch press or release */
76
76
{PM8607_IRQ_AUDIO_SHORT, PM8607_IRQ_AUDIO_SHORT, "audio-short", IORESOURCE_IRQ,},
79
static struct resource battery_resources[] __initdata = {
79
static struct resource battery_resources[] __devinitdata = {
80
80
{PM8607_IRQ_CC, PM8607_IRQ_CC, "columb counter", IORESOURCE_IRQ,},
81
81
{PM8607_IRQ_BAT, PM8607_IRQ_BAT, "battery", IORESOURCE_IRQ,},
84
static struct resource charger_resources[] __initdata = {
84
static struct resource charger_resources[] __devinitdata = {
85
85
{PM8607_IRQ_CHG, PM8607_IRQ_CHG, "charger detect", IORESOURCE_IRQ,},
86
86
{PM8607_IRQ_CHG_DONE, PM8607_IRQ_CHG_DONE, "charging done", IORESOURCE_IRQ,},
87
87
{PM8607_IRQ_CHG_FAULT, PM8607_IRQ_CHG_FAULT, "charging timeout", IORESOURCE_IRQ,},
90
90
{PM8607_IRQ_VCHG, PM8607_IRQ_VCHG, "vchg voltage", IORESOURCE_IRQ,},
93
static struct mfd_cell bk_devs[] __initdata = {
93
static struct resource rtc_resources[] __devinitdata = {
94
{PM8607_IRQ_RTC, PM8607_IRQ_RTC, "rtc", IORESOURCE_IRQ,},
97
static struct mfd_cell bk_devs[] = {
94
98
{"88pm860x-backlight", 0,},
95
99
{"88pm860x-backlight", 1,},
96
100
{"88pm860x-backlight", 2,},
99
static struct mfd_cell led_devs[] __initdata = {
103
static struct mfd_cell led_devs[] = {
100
104
{"88pm860x-led", 0,},
101
105
{"88pm860x-led", 1,},
102
106
{"88pm860x-led", 2,},
105
109
{"88pm860x-led", 5,},
108
static struct mfd_cell regulator_devs[] __initdata = {
112
static struct mfd_cell regulator_devs[] = {
109
113
{"88pm860x-regulator", 0,},
110
114
{"88pm860x-regulator", 1,},
111
115
{"88pm860x-regulator", 2,},
126
130
{"88pm860x-regulator", 17,},
129
static struct mfd_cell touch_devs[] __initdata = {
133
static struct mfd_cell touch_devs[] = {
130
134
{"88pm860x-touch", -1,},
133
static struct mfd_cell onkey_devs[] __initdata = {
137
static struct mfd_cell onkey_devs[] = {
134
138
{"88pm860x-onkey", -1,},
137
static struct mfd_cell codec_devs[] __initdata = {
141
static struct mfd_cell codec_devs[] = {
138
142
{"88pm860x-codec", -1,},
143
147
{"88pm860x-charger", -1,},
146
static struct pm860x_backlight_pdata bk_pdata[ARRAY_SIZE(bk_devs)];
147
static struct pm860x_led_pdata led_pdata[ARRAY_SIZE(led_devs)];
148
static struct regulator_init_data regulator_pdata[ARRAY_SIZE(regulator_devs)];
149
static struct pm860x_touch_pdata touch_pdata;
150
static struct pm860x_power_pdata power_pdata;
150
static struct mfd_cell rtc_devs[] = {
151
{"88pm860x-rtc", -1,},
152
155
struct pm860x_irq_data {
468
470
if (!chip->core_irq)
471
desc = irq_to_desc(chip->core_irq);
473
473
/* register IRQ by genirq */
474
474
for (i = 0; i < ARRAY_SIZE(pm860x_irqs); i++) {
475
475
__irq = i + chip->irq_base;
476
set_irq_chip_data(__irq, chip);
477
set_irq_chip_and_handler(__irq, &pm860x_irq_chip,
476
irq_set_chip_data(__irq, chip);
477
irq_set_chip_and_handler(__irq, &pm860x_irq_chip,
478
478
handle_edge_irq);
479
set_irq_nested_thread(__irq, 1);
479
irq_set_nested_thread(__irq, 1);
480
480
#ifdef CONFIG_ARM
481
481
set_irq_flags(__irq, IRQF_VALID);
483
set_irq_noprobe(__irq);
483
irq_set_noprobe(__irq);
517
516
pdata->num_backlights = ARRAY_SIZE(bk_devs);
519
518
for (i = 0; i < pdata->num_backlights; i++) {
520
memcpy(&bk_pdata[i], &pdata->backlight[i],
521
sizeof(struct pm860x_backlight_pdata));
522
bk_devs[i].mfd_data = &bk_pdata[i];
519
bk_devs[i].platform_data = &pdata->backlight[i];
520
bk_devs[i].pdata_size = sizeof(struct pm860x_backlight_pdata);
524
522
for (j = 0; j < ARRAY_SIZE(bk_devs); j++) {
525
523
id = bk_resources[j].start;
526
if (bk_pdata[i].flags != id)
524
if (pdata->backlight[i].flags != id)
529
527
bk_devs[i].num_resources = 1;
554
551
pdata->num_leds = ARRAY_SIZE(led_devs);
556
553
for (i = 0; i < pdata->num_leds; i++) {
557
memcpy(&led_pdata[i], &pdata->led[i],
558
sizeof(struct pm860x_led_pdata));
559
led_devs[i].mfd_data = &led_pdata[i];
554
led_devs[i].platform_data = &pdata->led[i];
555
led_devs[i].pdata_size = sizeof(struct pm860x_led_pdata);
561
557
for (j = 0; j < ARRAY_SIZE(led_devs); j++) {
562
558
id = led_resources[j].start;
563
if (led_pdata[i].flags != id)
559
if (pdata->led[i].flags != id)
566
562
led_devs[i].num_resources = 1;
591
586
if (pdata->num_regulators > ARRAY_SIZE(regulator_devs))
592
587
pdata->num_regulators = ARRAY_SIZE(regulator_devs);
594
for (i = 0, j = -1; i < pdata->num_regulators; i++) {
589
for (i = 0, seq = -1; i < pdata->num_regulators; i++) {
595
590
initdata = &pdata->regulator[i];
596
if (strstr(initdata->constraints.name, "BUCK")) {
597
sscanf(initdata->constraints.name, "BUCK%d", &j);
599
if ((j < 1) || (j > 3)) {
600
dev_err(chip->dev, "Failed to add constraint "
601
"(%s)\n", initdata->constraints.name);
604
j = (j - 1) + PM8607_ID_BUCK1;
606
if (strstr(initdata->constraints.name, "LDO")) {
607
sscanf(initdata->constraints.name, "LDO%d", &j);
609
if ((j < 1) || (j > 15)) {
610
dev_err(chip->dev, "Failed to add constraint "
611
"(%s)\n", initdata->constraints.name);
614
j = (j - 1) + PM8607_ID_LDO1;
617
dev_err(chip->dev, "Failed to add constraint (%s)\n",
618
initdata->constraints.name);
591
seq = *(unsigned int *)initdata->driver_data;
592
if ((seq < 0) || (seq > PM8607_ID_RG_MAX)) {
593
dev_err(chip->dev, "Wrong ID(%d) on regulator(%s)\n",
594
seq, initdata->constraints.name);
621
memcpy(®ulator_pdata[i], &pdata->regulator[i],
622
sizeof(struct regulator_init_data));
623
regulator_devs[i].mfd_data = ®ulator_pdata[i];
597
regulator_devs[i].platform_data = &pdata->regulator[i];
598
regulator_devs[i].pdata_size = sizeof(struct regulator_init_data);
624
599
regulator_devs[i].num_resources = 1;
625
regulator_devs[i].resources = ®ulator_resources[j];
600
regulator_devs[i].resources = ®ulator_resources[seq];
627
602
ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[i], 1,
628
®ulator_resources[j], 0);
603
®ulator_resources[seq], 0);
630
605
dev_err(chip->dev, "Failed to add regulator subdev\n");
613
static void __devinit device_rtc_init(struct pm860x_chip *chip,
614
struct pm860x_platform_data *pdata)
621
rtc_devs[0].platform_data = pdata->rtc;
622
rtc_devs[0].pdata_size = sizeof(struct pm860x_rtc_pdata);
623
rtc_devs[0].num_resources = ARRAY_SIZE(rtc_resources);
624
rtc_devs[0].resources = &rtc_resources[0];
625
ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
626
ARRAY_SIZE(rtc_devs), &rtc_resources[0],
629
dev_err(chip->dev, "Failed to add rtc subdev\n");
638
632
static void __devinit device_touch_init(struct pm860x_chip *chip,
639
struct i2c_client *i2c,
640
633
struct pm860x_platform_data *pdata)
644
if ((pdata == NULL) || (pdata->touch == NULL))
647
memcpy(&touch_pdata, pdata->touch, sizeof(struct pm860x_touch_pdata));
648
touch_devs[0].mfd_data = &touch_pdata;
640
touch_devs[0].platform_data = pdata->touch;
641
touch_devs[0].pdata_size = sizeof(struct pm860x_touch_pdata);
649
642
touch_devs[0].num_resources = ARRAY_SIZE(touch_resources);
650
643
touch_devs[0].resources = &touch_resources[0];
651
644
ret = mfd_add_devices(chip->dev, 0, &touch_devs[0],
658
651
static void __devinit device_power_init(struct pm860x_chip *chip,
659
struct i2c_client *i2c,
660
652
struct pm860x_platform_data *pdata)
664
if ((pdata == NULL) || (pdata->power == NULL))
667
memcpy(&power_pdata, pdata->power, sizeof(struct pm860x_power_pdata));
668
power_devs[0].mfd_data = &power_pdata;
659
power_devs[0].platform_data = pdata->power;
660
power_devs[0].pdata_size = sizeof(struct pm860x_power_pdata);
669
661
power_devs[0].num_resources = ARRAY_SIZE(battery_resources);
670
662
power_devs[0].resources = &battery_resources[0],
671
663
ret = mfd_add_devices(chip->dev, 0, &power_devs[0], 1,
674
666
dev_err(chip->dev, "Failed to add battery subdev\n");
676
power_devs[1].mfd_data = &power_pdata;
668
power_devs[1].platform_data = pdata->power;
669
power_devs[1].pdata_size = sizeof(struct pm860x_power_pdata);
677
670
power_devs[1].num_resources = ARRAY_SIZE(charger_resources);
678
671
power_devs[1].resources = &charger_resources[0],
679
672
ret = mfd_add_devices(chip->dev, 0, &power_devs[1], 1,
769
device_regulator_init(chip, i2c, pdata);
770
device_onkey_init(chip, i2c, pdata);
771
device_touch_init(chip, i2c, pdata);
772
device_power_init(chip, i2c, pdata);
773
device_codec_init(chip, i2c, pdata);
760
device_regulator_init(chip, pdata);
761
device_rtc_init(chip, pdata);
762
device_onkey_init(chip, pdata);
763
device_touch_init(chip, pdata);
764
device_power_init(chip, pdata);
765
device_codec_init(chip, pdata);
783
775
switch (chip->id) {
784
776
case CHIP_PM8606:
785
device_bk_init(chip, chip->client, pdata);
786
device_led_init(chip, chip->client, pdata);
777
device_bk_init(chip, pdata);
778
device_led_init(chip, pdata);
788
780
case CHIP_PM8607:
789
781
device_8607_init(chip, chip->client, pdata);
793
785
if (chip->companion) {
794
786
switch (chip->id) {
795
787
case CHIP_PM8607:
796
device_bk_init(chip, chip->companion, pdata);
797
device_led_init(chip, chip->companion, pdata);
788
device_bk_init(chip, pdata);
789
device_led_init(chip, pdata);
799
791
case CHIP_PM8606:
800
792
device_8607_init(chip, chip->companion, pdata);