1. 13 2月, 2019 3 次提交
  2. 26 1月, 2019 1 次提交
    • M
      clk: meson: meson8b: fix incorrect divider mapping in cpu_scale_table · 5e1be9c7
      Martin Blumenstingl 提交于
      [ Upstream commit ad9b2b8e53af61375322e3c7d624acf3a3ef53b0 ]
      
      The public S805 datasheet only mentions that
      HHI_SYS_CPU_CLK_CNTL1[20:29] contains a divider called "cpu_scale_div".
      Unfortunately it does not mention how to use the register contents.
      
      The Amlogic 3.10 GPL kernel sources are using the following code to
      calculate the CPU clock based on that register (taken from
      arch/arm/mach-meson8/clock.c in the 3.10 Amlogic kernel, shortened to
      make it easier to read):
      N = (aml_read_reg32(P_HHI_SYS_CPU_CLK_CNTL1) >> 20) & 0x3FF;
      if (sel == 3) /* use cpu_scale_div */
        div = 2 * N;
      else
        div = ... /* not relevant for this example */
      cpu_clk = parent_clk / div;
      
      This suggests that the formula is: parent_rate / 2 * register_value
      However, running perf (which can measure the CPU clock rate thanks to
      the ARM PMU) shows that this formula is not correct.
      This can be reproduced with the following steps:
      1. boot into u-boot
      2. let the CPU clock run off the XTAL clock:
         mw.l 0xC110419C 0x30 1
      3. set the cpu_scale_div register:
         to value 0x1: mw.l 0xC110415C 0x801016A2 1
         to value 0x2: mw.l 0xC110415C 0x802016A2 1
         to value 0x5: mw.l 0xC110415C 0x805016A2 1
      4. let the CPU clock run off cpu_scale_div:
         mw.l 0xC110419C 0xbd 1
      5. boot Linux
      6. run: perf stat -aB stress --cpu 4 --timeout 10
      7. check the "cycles" value
      
      I get the following results depending on the cpu_scale_div value:
      - (cpu_in_sel - this is the input clock for cpu_scale_div - runs at
         1.2GHz)
      - 0x1 = 300MHz
      - 0x2 = 200MHz
      - 0x5 = 100MHz
      
      This means that the actual formula to calculate the output of the
      cpu_scale_div clock is: parent_rate / 2 * (register value + 1).
      
      The register value 0x0 is reserved. When letting the CPU clock run off
      the cpu_scale_div while the value is 0x0 the whole board hangs (even in
      u-boot).
      
      I also verified this with the TWD timer: when adding this to the .dts
      without specifying it's clock it will auto-detect the PERIPH (which is
      the input clock of the TWD) clock rate (and the result is shown in the
      kernel log). On Meson8, Meson8b and Meson8m2 the PERIPH clock is CPUCLK
      divided by 4. This also matched for all three test-cases from above (in
      all cases the TWD timer clock rate was approx. one fourth of the CPU
      clock rate).
      
      A small note regarding the "fixes" tag: the original issue seems to
      exist virtually since forever. Even commit 28b9fcd0 ("clk:
      meson8b: Add support for Meson8b clocks") seems to handle this wrong. I
      still decided to use commit 251b6fd3 ("clk: meson: rework meson8b
      cpu clock") because this is the first commit which gets the CPU hiearchy
      correct and thus it's the first commit where the cpu_scale_div register
      is used correctly (apart from the bug in the cpu_scale_table).
      
      Fixes: 251b6fd3 ("clk: meson: rework meson8b cpu clock")
      Signed-off-by: NMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Signed-off-by: NNeil Armstrong <narmstrong@baylibre.com>
      Link: https://lkml.kernel.org/r/20180927085921.24627-2-martin.blumenstingl@googlemail.comSigned-off-by: NSasha Levin <sashal@kernel.org>
      5e1be9c7
  3. 27 11月, 2018 1 次提交
  4. 21 5月, 2018 1 次提交
    • M
      clk: meson: meson8b: mark fclk_div2 gate clocks as CLK_IS_CRITICAL · 72e1f230
      Martin Blumenstingl 提交于
      Until commit 05f81440 ("clk: meson: add fdiv clock gates") we
      relied on the bootloader to enable the fclk_div clock gates. It turns
      out that our clock tree is incomplete at least on Meson8b (tested with
      an Odroid-C1, which uses an RGMII PHY) because after the mentioned
      commit Ethernet is not working anymore (no RX/TX activity can be seen).
      At the same time Ethernet was still working on Meson8m2 with a RMII PHY.
      
      Testing has shown that as soon as "fclk_div2" is disabled Ethernet stops
      working on Odroid-C1. Unfortunately it's currently not clear what the
      Ethernet controller IP block uses the fclk_div2 clock for. Mark the
      clock as CLK_IS_CRITICAL to keep it enabled (as it's already enabled by
      most bootloaders by default, which is why we didn't notice it before).
      
      Fixes: 05f81440 ("clk: meson: add fdiv clock gates")
      Cc: stable@vger.kernel.org
      Signed-off-by: NMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Tested-by: NKevin Hilman <khilman@baylibre.com>
      Signed-off-by: NJerome Brunet <jbrunet@baylibre.com>
      72e1f230
  5. 18 5月, 2018 1 次提交
  6. 15 5月, 2018 1 次提交
    • M
      clk: meson: meson8b: add support for the NAND clocks · b8c1ddad
      Martin Blumenstingl 提交于
      This adds the NAND clocks (from the HHI_NAND_CLK_CNTL register) to the
      Meson8b clock driver. There are three NAND clocks: a gate which enables
      or disables the NAND clock, a mux and a divider (which divides the mux
      output).
      Unfortunately the public S805 datasheet does not document the mux
      parents. However, the vendor kernel has a few hints for us which allows
      us to make an educated guess about the clock parents. To do this we need
      to have a look at set_nand_core_clk() from the vendor's NAND driver (see
      [0]):
      - XTAL = (4<<9) | (1<<8) | 0
      - 160MHz = (0<<9) | (1<<8) | 3)
      - 182MHz = (3<<9) | (1<<8) | 1)
      - 212MHz = (1<<9) | (1<<8) | 3)
      - 255MHz = (2<<9) | (1<<8) | 1)
      
      While there is a comment for the XTAL parent (which indicates that it
      should only be used for debugging) we have to do a bit of math for the
      other parents: target_freq * divider = rate of parent clock
      Bit 8 above is the enable bit, so we can ignore it here. Bits 11:9 are
      the mux index and bits 6:0 are the 0-based divider (so we need to add
      1). This gives us:
      - mux 0 (160MHz * 4) = fclk_div4 (actual rate = 637.5MHz, off by 2.5MHz)
      - mux 1 (212MHz * 4) = fclk_div3 (actual rate = 850MHz, off by 2MHz)
      - mux 2 (255MHz * 2) = fclk_div5 (matches exactly 510MHz)
      - mux 3 (182MHz * 2) = fclk_div7 (actual rate = 346.3MHz, off by 0.3MHz)
      
      [0] https://github.com/khadas/linux/blob/9587681285cb/drivers/amlogic/amlnf/dev/amlnf_ctrl.c#L314Signed-off-by: NMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Signed-off-by: NJerome Brunet <jbrunet@baylibre.com>
      b8c1ddad
  7. 25 4月, 2018 2 次提交
    • M
      clk: meson: meson8b: fix meson8b_cpu_clk parent clock name · 5b33139b
      Martin Blumenstingl 提交于
      meson8b_cpu_clk has two parent clocks:
      - meson8b_xtal
      - meson8b_cpu_scale_out_sel
      
      The name of the "xtal" clock parent is specified correctly. However,
      there is a typo in the name of the second parent clock. The
      meson8b_cpu_scale_out_sel definition uses the name "cpu_scale_out_sel"
      (which matches the name from the datasheet). However, the mux parent
      definition uses the name "cpu_out_sel" which does not match any existing
      clock.
      
      Fixes: 251b6fd3 ("clk: meson: rework meson8b cpu clock")
      Signed-off-by: NMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Signed-off-by: NJerome Brunet <jbrunet@baylibre.com>
      5b33139b
    • M
      clk: meson: meson8b: fix meson8b_fclk_div3_div clock name · b251e4c8
      Martin Blumenstingl 提交于
      The names of all fclk divider gate clocks follow the naming schema
      "fclk_divN" and the name of all fclk fixed dividers follow the naming
      schema "fclk_divN_div".
      There's one exception to this rule: meson8b_fclk_div3_div's name is
      "fclk_div_div3". It's child clock meson8b_fclk_div3 however references
      it as "fclk_div3_div" (following the naming schema explained above).
      
      Fix the naming of the meson8b_fclk_div3_div clock to follow the naming
      schema. This also fixes serial console on my Meson8m2 board because
      "clk81" uses fclk_div3 as parent. However, since the hierarchy stops at
      meson8b_fclk_div3 there's no known parent clock and the rate of "clk81"
      and all of it's children (UART clock, SDIO MMC controller clock, ...)
      are all 0.
      
      Fixes: 05f81440 ("clk: meson: add fdiv clock gates")
      Signed-off-by: NMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Signed-off-by: NJerome Brunet <jbrunet@baylibre.com>
      b251e4c8
  8. 15 3月, 2018 1 次提交
    • S
      clk: meson: Drop unused local variable and add static · 5d1c04dd
      Stephen Boyd 提交于
      Fixes the following warnings:
      
      drivers/clk/meson/meson8b.c:512:19: warning: symbol 'meson8b_mpeg_clk_div' was not declared. Should it be static?
      drivers/clk/meson/meson8b.c:526:19: warning: symbol 'meson8b_clk81' was not declared. Should it be static?
      drivers/clk/meson/meson8b.c:540:19: warning: symbol 'meson8b_cpu_in_sel' was not declared. Should it be static?
      drivers/clk/meson/meson8b.c:591:19: warning: symbol 'meson8b_cpu_scale_div' was not declared. Should it be static?
      drivers/clk/meson/meson8b.c:608:19: warning: symbol 'meson8b_cpu_scale_out_sel' was not declared. Should it be static?
      drivers/clk/meson/meson8b.c:626:19: warning: symbol 'meson8b_cpu_clk' was not declared. Should it be static?
      drivers/clk/meson/gxbb.c:392:27: warning: symbol 'gxbb_gp0_init_regs' was not declared. Should it be static?
      drivers/clk/meson/gxbb.c:439:27: warning: symbol 'gxl_gp0_init_regs' was not declared. Should it be static?
      drivers/clk/meson/axg.c:195:27: warning: symbol 'axg_gp0_init_regs' was not declared. Should it be static?
      drivers/clk/meson/axg.c:248:27: warning: symbol 'axg_hifi_init_regs' was not declared. Should it be static?
      drivers/clk/meson/meson8b.c: In function 'meson8b_clkc_probe':
      drivers/clk/meson/meson8b.c:1052:14: warning: unused variable 'clk' [-Wunused-variable]
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      5d1c04dd
  9. 13 3月, 2018 15 次提交
  10. 14 12月, 2017 1 次提交
  11. 05 8月, 2017 1 次提交
  12. 04 8月, 2017 1 次提交
  13. 01 8月, 2017 1 次提交
  14. 12 6月, 2017 1 次提交
    • M
      clk: meson: meson8b: add compatibles for Meson8 and Meson8m2 · 855f06a1
      Martin Blumenstingl 提交于
      The clock controller on Meson8, Meson8b and Meson8m2 is very similar
      based on the code from the Amlogic GPL kernel sources. Add separate
      compatibles for each SoC to make sure that we can easily implement
      all the small differences for each SoC later on.
      
      In general the Meson8 and Meson8m2 seem to be almost identical as they
      even share the same mach-meson8 directory in Amlogic's GPL kernel
      sources.
      The main clocks on Meson8, Meson8b and Meson8m2 are very similar,
      because they are all using the same PLL values, 90% of the clock gates
      are the same (the actual diffstat of the mach-meson8/clock.c and
      mach-meson8b/clock.c files is around 30 to 40 lines, when excluding
      all commented out code).
      The difference between the Meson8 and Meson8b clock gates seem to be:
      - Meson8 has AIU_PCLK, HDMI_RX, VCLK2_ENCT, VCLK2_ENCL, UART3,
        CSI_DIG_CLKIN gates which don't seem to be available on Meson8b
      - the gate on Meson8 for bit 7 seems to be named "_1200XXX" instead
        of "PERIPHS_TOP" (on Meson8b)
      - Meson8b has a SANA gate which doesn't seem to exist on Meson8 (or
        on Meson8 the same bit is used by the UART3 gate in Amlogic's GPL
        kernel sources)
      None of these gates is added for now, since it's unclear whether these
      definitions are actually correct (the VCLK2_ENCT gate for example is
      defined, but only used in some commented block).
      
      The main difference between all three SoCs seem to be the video (VPU)
      clocks. Apart from different supported clock rates (according to vpu.c
      in mach-meson8 and mach-meson8b from Amlogic's GPL kernel sources) the
      most notable difference is that Meson8m2 has a GP_PLL clock and a mux
      (probably the same as on the Meson GX SoCs) to support glitch-free
      (clock rate) switching.
      None of these VPU clocks are not supported by our mainline meson8b
      clock driver yet though.
      Signed-off-by: NMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Acked-by: NRob Herring <robh@kernel.org>
      Acked-by: NKevin Hilman <khilman@baylibre.com>
      Signed-off-by: NJerome Brunet <jbrunet@baylibre.com>
      855f06a1
  15. 29 5月, 2017 1 次提交
  16. 28 3月, 2017 3 次提交
  17. 27 1月, 2017 1 次提交
  18. 15 9月, 2016 2 次提交
  19. 02 9月, 2016 2 次提交