~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise-security

« back to all changes in this revision

Viewing changes to drivers/media/video/s5p-fimc/mipi-csis.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati
  • Date: 2011-12-06 15:56:07 UTC
  • Revision ID: package-import@ubuntu.com-20111206155607-pcf44kv5fmhk564f
Tags: 3.2.0-1401.1
[ Paolo Pisati ]

* Rebased on top of Ubuntu-3.2.0-3.8
* Tilt-tracking @ ef2487af4bb15bdd0689631774b5a5e3a59f74e2
* Delete debian.ti-omap4/control, it shoudln't be tracked
* Fix architecture spelling (s/armel/armhf/)
* [Config] Update configs following 3.2 import
* [Config] Fix compilation: disable CODA and ARCH_OMAP3
* [Config] Fix compilation: disable Ethernet Faraday
* Update series to precise

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
};
82
82
#define NUM_CSIS_CLOCKS ARRAY_SIZE(csi_clock_name)
83
83
 
 
84
static const char * const csis_supply_name[] = {
 
85
        "vdd11", /* 1.1V or 1.2V (s5pc100) MIPI CSI suppply */
 
86
        "vdd18", /* VDD 1.8V and MIPI CSI PLL supply */
 
87
};
 
88
#define CSIS_NUM_SUPPLIES ARRAY_SIZE(csis_supply_name)
 
89
 
84
90
enum {
85
91
        ST_POWERED      = 1,
86
92
        ST_STREAMING    = 2,
109
115
        struct platform_device *pdev;
110
116
        struct resource *regs_res;
111
117
        void __iomem *regs;
 
118
        struct regulator_bulk_data supplies[CSIS_NUM_SUPPLIES];
112
119
        struct clk *clock[NUM_CSIS_CLOCKS];
113
120
        int irq;
114
 
        struct regulator *supply;
115
121
        u32 flags;
116
122
        const struct csis_pix_format *csis_fmt;
117
123
        struct v4l2_mbus_framefmt format;
460
466
        struct resource *regs_res;
461
467
        struct csis_state *state;
462
468
        int ret = -ENOMEM;
 
469
        int i;
463
470
 
464
471
        state = kzalloc(sizeof(*state), GFP_KERNEL);
465
472
        if (!state)
519
526
                goto e_clkput;
520
527
        }
521
528
 
522
 
        if (!pdata->fixed_phy_vdd) {
523
 
                state->supply = regulator_get(&pdev->dev, "vdd");
524
 
                if (IS_ERR(state->supply)) {
525
 
                        ret = PTR_ERR(state->supply);
526
 
                        state->supply = NULL;
527
 
                        goto e_clkput;
528
 
                }
529
 
        }
 
529
        for (i = 0; i < CSIS_NUM_SUPPLIES; i++)
 
530
                state->supplies[i].supply = csis_supply_name[i];
 
531
 
 
532
        ret = regulator_bulk_get(&pdev->dev, CSIS_NUM_SUPPLIES,
 
533
                                 state->supplies);
 
534
        if (ret)
 
535
                goto e_clkput;
530
536
 
531
537
        ret = request_irq(state->irq, s5pcsis_irq_handler, 0,
532
538
                          dev_name(&pdev->dev), state);
553
559
        /* .. and a pointer to the subdev. */
554
560
        platform_set_drvdata(pdev, &state->sd);
555
561
 
556
 
        state->flags = ST_SUSPENDED;
557
562
        pm_runtime_enable(&pdev->dev);
558
563
 
559
564
        return 0;
561
566
e_irqfree:
562
567
        free_irq(state->irq, state);
563
568
e_regput:
564
 
        if (state->supply)
565
 
                regulator_put(state->supply);
 
569
        regulator_bulk_free(CSIS_NUM_SUPPLIES, state->supplies);
566
570
e_clkput:
567
571
        clk_disable(state->clock[CSIS_CLK_MUX]);
568
572
        s5pcsis_clk_put(state);
575
579
        return ret;
576
580
}
577
581
 
578
 
static int s5pcsis_suspend(struct device *dev)
 
582
static int s5pcsis_pm_suspend(struct device *dev, bool runtime)
579
583
{
580
584
        struct s5p_platform_mipi_csis *pdata = dev->platform_data;
581
585
        struct platform_device *pdev = to_platform_device(dev);
592
596
                ret = pdata->phy_enable(state->pdev, false);
593
597
                if (ret)
594
598
                        goto unlock;
595
 
                if (state->supply) {
596
 
                        ret = regulator_disable(state->supply);
597
 
                        if (ret)
598
 
                                goto unlock;
599
 
                }
 
599
                ret = regulator_bulk_disable(CSIS_NUM_SUPPLIES,
 
600
                                             state->supplies);
 
601
                if (ret)
 
602
                        goto unlock;
600
603
                clk_disable(state->clock[CSIS_CLK_GATE]);
601
604
                state->flags &= ~ST_POWERED;
 
605
                if (!runtime)
 
606
                        state->flags |= ST_SUSPENDED;
602
607
        }
603
 
        state->flags |= ST_SUSPENDED;
604
608
 unlock:
605
609
        mutex_unlock(&state->lock);
606
610
        return ret ? -EAGAIN : 0;
607
611
}
608
612
 
609
 
static int s5pcsis_resume(struct device *dev)
 
613
static int s5pcsis_pm_resume(struct device *dev, bool runtime)
610
614
{
611
615
        struct s5p_platform_mipi_csis *pdata = dev->platform_data;
612
616
        struct platform_device *pdev = to_platform_device(dev);
618
622
                 __func__, state->flags);
619
623
 
620
624
        mutex_lock(&state->lock);
621
 
        if (!(state->flags & ST_SUSPENDED))
 
625
        if (!runtime && !(state->flags & ST_SUSPENDED))
622
626
                goto unlock;
623
627
 
624
628
        if (!(state->flags & ST_POWERED)) {
625
 
                if (state->supply)
626
 
                        ret = regulator_enable(state->supply);
 
629
                ret = regulator_bulk_enable(CSIS_NUM_SUPPLIES,
 
630
                                            state->supplies);
627
631
                if (ret)
628
632
                        goto unlock;
629
 
 
630
633
                ret = pdata->phy_enable(state->pdev, true);
631
634
                if (!ret) {
632
635
                        state->flags |= ST_POWERED;
633
 
                } else if (state->supply) {
634
 
                        regulator_disable(state->supply);
 
636
                } else {
 
637
                        regulator_bulk_disable(CSIS_NUM_SUPPLIES,
 
638
                                               state->supplies);
635
639
                        goto unlock;
636
640
                }
637
641
                clk_enable(state->clock[CSIS_CLK_GATE]);
646
650
}
647
651
 
648
652
#ifdef CONFIG_PM_SLEEP
649
 
static int s5pcsis_pm_suspend(struct device *dev)
650
 
{
651
 
        return s5pcsis_suspend(dev);
652
 
}
653
 
 
654
 
static int s5pcsis_pm_resume(struct device *dev)
655
 
{
656
 
        int ret;
657
 
 
658
 
        ret = s5pcsis_resume(dev);
659
 
 
660
 
        if (!ret) {
661
 
                pm_runtime_disable(dev);
662
 
                ret = pm_runtime_set_active(dev);
663
 
                pm_runtime_enable(dev);
664
 
        }
665
 
 
666
 
        return ret;
 
653
static int s5pcsis_suspend(struct device *dev)
 
654
{
 
655
        return s5pcsis_pm_suspend(dev, false);
 
656
}
 
657
 
 
658
static int s5pcsis_resume(struct device *dev)
 
659
{
 
660
        return s5pcsis_pm_resume(dev, false);
 
661
}
 
662
#endif
 
663
 
 
664
#ifdef CONFIG_PM_RUNTIME
 
665
static int s5pcsis_runtime_suspend(struct device *dev)
 
666
{
 
667
        return s5pcsis_pm_suspend(dev, true);
 
668
}
 
669
 
 
670
static int s5pcsis_runtime_resume(struct device *dev)
 
671
{
 
672
        return s5pcsis_pm_resume(dev, true);
667
673
}
668
674
#endif
669
675
 
679
685
        pm_runtime_set_suspended(&pdev->dev);
680
686
 
681
687
        s5pcsis_clk_put(state);
682
 
        if (state->supply)
683
 
                regulator_put(state->supply);
 
688
        regulator_bulk_free(CSIS_NUM_SUPPLIES, state->supplies);
684
689
 
685
690
        media_entity_cleanup(&state->sd.entity);
686
691
        free_irq(state->irq, state);
692
697
}
693
698
 
694
699
static const struct dev_pm_ops s5pcsis_pm_ops = {
695
 
        SET_RUNTIME_PM_OPS(s5pcsis_suspend, s5pcsis_resume, NULL)
696
 
        SET_SYSTEM_SLEEP_PM_OPS(s5pcsis_pm_suspend, s5pcsis_pm_resume)
 
700
        SET_RUNTIME_PM_OPS(s5pcsis_runtime_suspend, s5pcsis_runtime_resume,
 
701
                           NULL)
 
702
        SET_SYSTEM_SLEEP_PM_OPS(s5pcsis_suspend, s5pcsis_resume)
697
703
};
698
704
 
699
705
static struct platform_driver s5pcsis_driver = {