diff options
author | Martin Blumenstingl <martin.blumenstingl@googlemail.com> | 2017-01-19 09:58:20 -0500 |
---|---|---|
committer | Kevin Hilman <khilman@baylibre.com> | 2017-01-23 13:18:21 -0500 |
commit | 33d0fcdfe0e87070d96c678e554d711ae15b9fa6 (patch) | |
tree | 572705e9afdd982329b78e7c592fdc949ddbf3e5 | |
parent | 0264a88d6153e6cd5ee61239058b2002f36dde6b (diff) |
clk: gxbb: add the SAR ADC clocks and expose them
The HHI_SAR_CLK_CNTL contains three SAR ADC specific clocks:
- a mux clock to choose between different ADC reference clocks (this is
2-bit wide, but the datasheet only lists the parents for the first
bit)
- a divider for the input/reference clock
- a gate which enables the ADC clock
Additionally this exposes the ADC core clock (CLKID_SAR_ADC) and
CLKID_SANA (which seems to enable the analog inputs, but unfortunately
there is no documentation for this - we just mimic what the vendor
driver does).
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Tested-by: Neil Armstrong <narmstrong@baylibre.com>
Acked-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
-rw-r--r-- | drivers/clk/meson/gxbb.c | 48 | ||||
-rw-r--r-- | drivers/clk/meson/gxbb.h | 9 | ||||
-rw-r--r-- | include/dt-bindings/clock/gxbb-clkc.h | 4 |
3 files changed, 58 insertions, 3 deletions
diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c index 9d9af446bafc..1c1ec137a3cc 100644 --- a/drivers/clk/meson/gxbb.c +++ b/drivers/clk/meson/gxbb.c | |||
@@ -564,6 +564,46 @@ static struct clk_gate gxbb_clk81 = { | |||
564 | }, | 564 | }, |
565 | }; | 565 | }; |
566 | 566 | ||
567 | static struct clk_mux gxbb_sar_adc_clk_sel = { | ||
568 | .reg = (void *)HHI_SAR_CLK_CNTL, | ||
569 | .mask = 0x3, | ||
570 | .shift = 9, | ||
571 | .lock = &clk_lock, | ||
572 | .hw.init = &(struct clk_init_data){ | ||
573 | .name = "sar_adc_clk_sel", | ||
574 | .ops = &clk_mux_ops, | ||
575 | /* NOTE: The datasheet doesn't list the parents for bit 10 */ | ||
576 | .parent_names = (const char *[]){ "xtal", "clk81", }, | ||
577 | .num_parents = 2, | ||
578 | }, | ||
579 | }; | ||
580 | |||
581 | static struct clk_divider gxbb_sar_adc_clk_div = { | ||
582 | .reg = (void *)HHI_SAR_CLK_CNTL, | ||
583 | .shift = 0, | ||
584 | .width = 8, | ||
585 | .lock = &clk_lock, | ||
586 | .hw.init = &(struct clk_init_data){ | ||
587 | .name = "sar_adc_clk_div", | ||
588 | .ops = &clk_divider_ops, | ||
589 | .parent_names = (const char *[]){ "sar_adc_clk_sel" }, | ||
590 | .num_parents = 1, | ||
591 | }, | ||
592 | }; | ||
593 | |||
594 | static struct clk_gate gxbb_sar_adc_clk = { | ||
595 | .reg = (void *)HHI_SAR_CLK_CNTL, | ||
596 | .bit_idx = 8, | ||
597 | .lock = &clk_lock, | ||
598 | .hw.init = &(struct clk_init_data){ | ||
599 | .name = "sar_adc_clk", | ||
600 | .ops = &clk_gate_ops, | ||
601 | .parent_names = (const char *[]){ "sar_adc_clk_div" }, | ||
602 | .num_parents = 1, | ||
603 | .flags = CLK_SET_RATE_PARENT, | ||
604 | }, | ||
605 | }; | ||
606 | |||
567 | /* Everything Else (EE) domain gates */ | 607 | /* Everything Else (EE) domain gates */ |
568 | static MESON_GATE(gxbb_ddr, HHI_GCLK_MPEG0, 0); | 608 | static MESON_GATE(gxbb_ddr, HHI_GCLK_MPEG0, 0); |
569 | static MESON_GATE(gxbb_dos, HHI_GCLK_MPEG0, 1); | 609 | static MESON_GATE(gxbb_dos, HHI_GCLK_MPEG0, 1); |
@@ -754,6 +794,9 @@ static struct clk_hw_onecell_data gxbb_hw_onecell_data = { | |||
754 | [CLKID_SD_EMMC_A] = &gxbb_emmc_a.hw, | 794 | [CLKID_SD_EMMC_A] = &gxbb_emmc_a.hw, |
755 | [CLKID_SD_EMMC_B] = &gxbb_emmc_b.hw, | 795 | [CLKID_SD_EMMC_B] = &gxbb_emmc_b.hw, |
756 | [CLKID_SD_EMMC_C] = &gxbb_emmc_c.hw, | 796 | [CLKID_SD_EMMC_C] = &gxbb_emmc_c.hw, |
797 | [CLKID_SAR_ADC_CLK] = &gxbb_sar_adc_clk.hw, | ||
798 | [CLKID_SAR_ADC_SEL] = &gxbb_sar_adc_clk_sel.hw, | ||
799 | [CLKID_SAR_ADC_DIV] = &gxbb_sar_adc_clk_div.hw, | ||
757 | }, | 800 | }, |
758 | .num = NR_CLKS, | 801 | .num = NR_CLKS, |
759 | }; | 802 | }; |
@@ -856,6 +899,7 @@ static struct clk_gate *gxbb_clk_gates[] = { | |||
856 | &gxbb_emmc_a, | 899 | &gxbb_emmc_a, |
857 | &gxbb_emmc_b, | 900 | &gxbb_emmc_b, |
858 | &gxbb_emmc_c, | 901 | &gxbb_emmc_c, |
902 | &gxbb_sar_adc_clk, | ||
859 | }; | 903 | }; |
860 | 904 | ||
861 | static int gxbb_clkc_probe(struct platform_device *pdev) | 905 | static int gxbb_clkc_probe(struct platform_device *pdev) |
@@ -888,6 +932,10 @@ static int gxbb_clkc_probe(struct platform_device *pdev) | |||
888 | gxbb_mpeg_clk_sel.reg = clk_base + (u64)gxbb_mpeg_clk_sel.reg; | 932 | gxbb_mpeg_clk_sel.reg = clk_base + (u64)gxbb_mpeg_clk_sel.reg; |
889 | gxbb_mpeg_clk_div.reg = clk_base + (u64)gxbb_mpeg_clk_div.reg; | 933 | gxbb_mpeg_clk_div.reg = clk_base + (u64)gxbb_mpeg_clk_div.reg; |
890 | 934 | ||
935 | /* Populate the base address for the SAR ADC clks */ | ||
936 | gxbb_sar_adc_clk_sel.reg = clk_base + (u64)gxbb_sar_adc_clk_sel.reg; | ||
937 | gxbb_sar_adc_clk_div.reg = clk_base + (u64)gxbb_sar_adc_clk_div.reg; | ||
938 | |||
891 | /* Populate base address for gates */ | 939 | /* Populate base address for gates */ |
892 | for (i = 0; i < ARRAY_SIZE(gxbb_clk_gates); i++) | 940 | for (i = 0; i < ARRAY_SIZE(gxbb_clk_gates); i++) |
893 | gxbb_clk_gates[i]->reg = clk_base + | 941 | gxbb_clk_gates[i]->reg = clk_base + |
diff --git a/drivers/clk/meson/gxbb.h b/drivers/clk/meson/gxbb.h index 2139e97f5e39..dc487180f847 100644 --- a/drivers/clk/meson/gxbb.h +++ b/drivers/clk/meson/gxbb.h | |||
@@ -191,7 +191,7 @@ | |||
191 | #define CLKID_PERIPHS 20 | 191 | #define CLKID_PERIPHS 20 |
192 | #define CLKID_SPICC 21 | 192 | #define CLKID_SPICC 21 |
193 | /* CLKID_I2C */ | 193 | /* CLKID_I2C */ |
194 | #define CLKID_SAR_ADC 23 | 194 | /* #define CLKID_SAR_ADC */ |
195 | #define CLKID_SMART_CARD 24 | 195 | #define CLKID_SMART_CARD 24 |
196 | #define CLKID_RNG0 25 | 196 | #define CLKID_RNG0 25 |
197 | #define CLKID_UART0 26 | 197 | #define CLKID_UART0 26 |
@@ -237,7 +237,7 @@ | |||
237 | #define CLKID_MMC_PCLK 66 | 237 | #define CLKID_MMC_PCLK 66 |
238 | #define CLKID_DVIN 67 | 238 | #define CLKID_DVIN 67 |
239 | #define CLKID_UART2 68 | 239 | #define CLKID_UART2 68 |
240 | #define CLKID_SANA 69 | 240 | /* #define CLKID_SANA */ |
241 | #define CLKID_VPU_INTR 70 | 241 | #define CLKID_VPU_INTR 70 |
242 | #define CLKID_SEC_AHB_AHB3_BRIDGE 71 | 242 | #define CLKID_SEC_AHB_AHB3_BRIDGE 71 |
243 | #define CLKID_CLK81_A53 72 | 243 | #define CLKID_CLK81_A53 72 |
@@ -265,8 +265,11 @@ | |||
265 | /* CLKID_SD_EMMC_A */ | 265 | /* CLKID_SD_EMMC_A */ |
266 | /* CLKID_SD_EMMC_B */ | 266 | /* CLKID_SD_EMMC_B */ |
267 | /* CLKID_SD_EMMC_C */ | 267 | /* CLKID_SD_EMMC_C */ |
268 | /* CLKID_SAR_ADC_CLK */ | ||
269 | /* CLKID_SAR_ADC_SEL */ | ||
270 | #define CLKID_SAR_ADC_DIV 99 | ||
268 | 271 | ||
269 | #define NR_CLKS 97 | 272 | #define NR_CLKS 100 |
270 | 273 | ||
271 | /* include the CLKIDs that have been made part of the stable DT binding */ | 274 | /* include the CLKIDs that have been made part of the stable DT binding */ |
272 | #include <dt-bindings/clock/gxbb-clkc.h> | 275 | #include <dt-bindings/clock/gxbb-clkc.h> |
diff --git a/include/dt-bindings/clock/gxbb-clkc.h b/include/dt-bindings/clock/gxbb-clkc.h index da1d473a5a3a..692846c7941b 100644 --- a/include/dt-bindings/clock/gxbb-clkc.h +++ b/include/dt-bindings/clock/gxbb-clkc.h | |||
@@ -14,6 +14,7 @@ | |||
14 | #define CLKID_MPLL2 15 | 14 | #define CLKID_MPLL2 15 |
15 | #define CLKID_SPI 34 | 15 | #define CLKID_SPI 34 |
16 | #define CLKID_I2C 22 | 16 | #define CLKID_I2C 22 |
17 | #define CLKID_SAR_ADC 23 | ||
17 | #define CLKID_ETH 36 | 18 | #define CLKID_ETH 36 |
18 | #define CLKID_USB0 50 | 19 | #define CLKID_USB0 50 |
19 | #define CLKID_USB1 51 | 20 | #define CLKID_USB1 51 |
@@ -21,10 +22,13 @@ | |||
21 | #define CLKID_HDMI_PCLK 63 | 22 | #define CLKID_HDMI_PCLK 63 |
22 | #define CLKID_USB1_DDR_BRIDGE 64 | 23 | #define CLKID_USB1_DDR_BRIDGE 64 |
23 | #define CLKID_USB0_DDR_BRIDGE 65 | 24 | #define CLKID_USB0_DDR_BRIDGE 65 |
25 | #define CLKID_SANA 69 | ||
24 | #define CLKID_GCLK_VENCI_INT0 77 | 26 | #define CLKID_GCLK_VENCI_INT0 77 |
25 | #define CLKID_AO_I2C 93 | 27 | #define CLKID_AO_I2C 93 |
26 | #define CLKID_SD_EMMC_A 94 | 28 | #define CLKID_SD_EMMC_A 94 |
27 | #define CLKID_SD_EMMC_B 95 | 29 | #define CLKID_SD_EMMC_B 95 |
28 | #define CLKID_SD_EMMC_C 96 | 30 | #define CLKID_SD_EMMC_C 96 |
31 | #define CLKID_SAR_ADC_CLK 97 | ||
32 | #define CLKID_SAR_ADC_SEL 98 | ||
29 | 33 | ||
30 | #endif /* __GXBB_CLKC_H */ | 34 | #endif /* __GXBB_CLKC_H */ |