Skip to content

Commit 13ca4f6

Browse files
lostdistanceSamuel Ortiz
authored andcommitted
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 <[email protected]> Signed-off-by: Samuel Ortiz <[email protected]>
1 parent 7d9e7e9 commit 13ca4f6

File tree

1 file changed

+68
-6
lines changed

1 file changed

+68
-6
lines changed

drivers/mfd/asic3.c

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,19 @@ struct asic3 {
8888

8989
static int asic3_gpio_get(struct gpio_chip *chip, unsigned offset);
9090

91-
static inline void asic3_write_register(struct asic3 *asic,
92-
unsigned int reg, u32 value)
91+
void asic3_write_register(struct asic3 *asic, unsigned int reg, u32 value)
9392
{
9493
iowrite16(value, asic->mapping +
9594
(reg >> asic->bus_shift));
9695
}
96+
EXPORT_SYMBOL_GPL(asic3_write_register);
9797

98-
static inline u32 asic3_read_register(struct asic3 *asic,
99-
unsigned int reg)
98+
u32 asic3_read_register(struct asic3 *asic, unsigned int reg)
10099
{
101100
return ioread16(asic->mapping +
102101
(reg >> asic->bus_shift));
103102
}
103+
EXPORT_SYMBOL_GPL(asic3_read_register);
104104

105105
static void asic3_set_register(struct asic3 *asic, u32 reg, u32 bits, bool set)
106106
{
@@ -784,7 +784,55 @@ static struct mfd_cell asic3_cell_mmc = {
784784
.resources = asic3_mmc_resources,
785785
};
786786

787+
static const int clock_ledn[ASIC3_NUM_LEDS] = {
788+
[0] = ASIC3_CLOCK_LED0,
789+
[1] = ASIC3_CLOCK_LED1,
790+
[2] = ASIC3_CLOCK_LED2,
791+
};
792+
793+
static 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+
803+
static 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+
813+
static 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+
787834
static int __init asic3_mfd_probe(struct platform_device *pdev,
835+
struct asic3_platform_data *pdata,
788836
struct resource *mem)
789837
{
790838
struct asic3 *asic = platform_get_drvdata(pdev);
@@ -822,9 +870,23 @@ static int __init asic3_mfd_probe(struct platform_device *pdev,
822870
if (ret < 0)
823871
goto out;
824872

825-
if (mem_sdio && (irq >= 0))
873+
if (mem_sdio && (irq >= 0)) {
826874
ret = mfd_add_devices(&pdev->dev, pdev->id,
827875
&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+
}
828890

829891
out:
830892
return ret;
@@ -905,7 +967,7 @@ static int __init asic3_probe(struct platform_device *pdev)
905967
*/
906968
memcpy(asic->clocks, asic3_clk_init, sizeof(asic3_clk_init));
907969

908-
asic3_mfd_probe(pdev, mem);
970+
asic3_mfd_probe(pdev, pdata, mem);
909971

910972
dev_info(asic->dev, "ASIC3 Core driver\n");
911973

0 commit comments

Comments
 (0)