aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorPaul Parsons <lost.distance@yahoo.com>2011-05-13 14:53:03 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2011-05-26 13:45:47 -0400
commit13ca4f66108188231f9ef0358449f4543a0b84a1 (patch)
tree2c3ae1715e5582cb7f331e076ae98453c6cb77b4 /drivers/mfd
parent7d9e7e9fbd3041a0596394579d800788bbf94939 (diff)
mfd: Add ASIC3 LED support
Add LED support for the HTC ASIC3. Underlying support is provided by the mfd/asic3 and leds/leds-asic3 drivers. An example configuration is provided by the pxa/hx4700 platform. Signed-off-by: Paul Parsons <lost.distance@yahoo.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/asic3.c74
1 files changed, 68 insertions, 6 deletions
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
index 77a3971e00bd..52e56ea43a85 100644
--- a/drivers/mfd/asic3.c
+++ b/drivers/mfd/asic3.c
@@ -88,19 +88,19 @@ struct asic3 {
88 88
89static int asic3_gpio_get(struct gpio_chip *chip, unsigned offset); 89static int asic3_gpio_get(struct gpio_chip *chip, unsigned offset);
90 90
91static inline void asic3_write_register(struct asic3 *asic, 91void asic3_write_register(struct asic3 *asic, unsigned int reg, u32 value)
92 unsigned int reg, u32 value)
93{ 92{
94 iowrite16(value, asic->mapping + 93 iowrite16(value, asic->mapping +
95 (reg >> asic->bus_shift)); 94 (reg >> asic->bus_shift));
96} 95}
96EXPORT_SYMBOL_GPL(asic3_write_register);
97 97
98static inline u32 asic3_read_register(struct asic3 *asic, 98u32 asic3_read_register(struct asic3 *asic, unsigned int reg)
99 unsigned int reg)
100{ 99{
101 return ioread16(asic->mapping + 100 return ioread16(asic->mapping +
102 (reg >> asic->bus_shift)); 101 (reg >> asic->bus_shift));
103} 102}
103EXPORT_SYMBOL_GPL(asic3_read_register);
104 104
105static void asic3_set_register(struct asic3 *asic, u32 reg, u32 bits, bool set) 105static void asic3_set_register(struct asic3 *asic, u32 reg, u32 bits, bool set)
106{ 106{
@@ -784,7 +784,55 @@ static struct mfd_cell asic3_cell_mmc = {
784 .resources = asic3_mmc_resources, 784 .resources = asic3_mmc_resources,
785}; 785};
786 786
787static const int clock_ledn[ASIC3_NUM_LEDS] = {
788 [0] = ASIC3_CLOCK_LED0,
789 [1] = ASIC3_CLOCK_LED1,
790 [2] = ASIC3_CLOCK_LED2,
791};
792
793static int asic3_leds_enable(struct platform_device *pdev)
794{
795 const struct mfd_cell *cell = mfd_get_cell(pdev);
796 struct asic3 *asic = dev_get_drvdata(pdev->dev.parent);
797
798 asic3_clk_enable(asic, &asic->clocks[clock_ledn[cell->id]]);
799
800 return 0;
801}
802
803static int asic3_leds_disable(struct platform_device *pdev)
804{
805 const struct mfd_cell *cell = mfd_get_cell(pdev);
806 struct asic3 *asic = dev_get_drvdata(pdev->dev.parent);
807
808 asic3_clk_disable(asic, &asic->clocks[clock_ledn[cell->id]]);
809
810 return 0;
811}
812
813static struct mfd_cell asic3_cell_leds[ASIC3_NUM_LEDS] = {
814 [0] = {
815 .name = "leds-asic3",
816 .id = 0,
817 .enable = asic3_leds_enable,
818 .disable = asic3_leds_disable,
819 },
820 [1] = {
821 .name = "leds-asic3",
822 .id = 1,
823 .enable = asic3_leds_enable,
824 .disable = asic3_leds_disable,
825 },
826 [2] = {
827 .name = "leds-asic3",
828 .id = 2,
829 .enable = asic3_leds_enable,
830 .disable = asic3_leds_disable,
831 },
832};
833
787static int __init asic3_mfd_probe(struct platform_device *pdev, 834static int __init asic3_mfd_probe(struct platform_device *pdev,
835 struct asic3_platform_data *pdata,
788 struct resource *mem) 836 struct resource *mem)
789{ 837{
790 struct asic3 *asic = platform_get_drvdata(pdev); 838 struct asic3 *asic = platform_get_drvdata(pdev);
@@ -822,9 +870,23 @@ static int __init asic3_mfd_probe(struct platform_device *pdev,
822 if (ret < 0) 870 if (ret < 0)
823 goto out; 871 goto out;
824 872
825 if (mem_sdio && (irq >= 0)) 873 if (mem_sdio && (irq >= 0)) {
826 ret = mfd_add_devices(&pdev->dev, pdev->id, 874 ret = mfd_add_devices(&pdev->dev, pdev->id,
827 &asic3_cell_mmc, 1, mem_sdio, irq); 875 &asic3_cell_mmc, 1, mem_sdio, irq);
876 if (ret < 0)
877 goto out;
878 }
879
880 if (pdata->leds) {
881 int i;
882
883 for (i = 0; i < ASIC3_NUM_LEDS; ++i) {
884 asic3_cell_leds[i].platform_data = &pdata->leds[i];
885 asic3_cell_leds[i].pdata_size = sizeof(pdata->leds[i]);
886 }
887 ret = mfd_add_devices(&pdev->dev, 0,
888 asic3_cell_leds, ASIC3_NUM_LEDS, NULL, 0);
889 }
828 890
829 out: 891 out:
830 return ret; 892 return ret;
@@ -905,7 +967,7 @@ static int __init asic3_probe(struct platform_device *pdev)
905 */ 967 */
906 memcpy(asic->clocks, asic3_clk_init, sizeof(asic3_clk_init)); 968 memcpy(asic->clocks, asic3_clk_init, sizeof(asic3_clk_init));
907 969
908 asic3_mfd_probe(pdev, mem); 970 asic3_mfd_probe(pdev, pdata, mem);
909 971
910 dev_info(asic->dev, "ASIC3 Core driver\n"); 972 dev_info(asic->dev, "ASIC3 Core driver\n");
911 973