1. 16 5月, 2019 1 次提交
    • S
      clk: Remove io.h from clk-provider.h · 62e59c4e
      Stephen Boyd 提交于
      Now that we've gotten rid of clk_readl() we can remove io.h from the
      clk-provider header and push out the io.h include to any code that isn't
      already including the io.h header but using things like readl/writel,
      etc.
      
      Found with this grep:
      
        git grep -l clk-provider.h | grep '.c$' | xargs git grep -L 'linux/io.h' | \
        	xargs git grep -l \
      	-e '\<__iowrite32_copy\>' --or \
      	-e '\<__ioread32_copy\>' --or \
      	-e '\<__iowrite64_copy\>' --or \
      	-e '\<ioremap_page_range\>' --or \
      	-e '\<ioremap_huge_init\>' --or \
      	-e '\<arch_ioremap_pud_supported\>' --or \
      	-e '\<arch_ioremap_pmd_supported\>' --or \
      	-e '\<devm_ioport_map\>' --or \
      	-e '\<devm_ioport_unmap\>' --or \
      	-e '\<IOMEM_ERR_PTR\>' --or \
      	-e '\<devm_ioremap\>' --or \
      	-e '\<devm_ioremap_nocache\>' --or \
      	-e '\<devm_ioremap_wc\>' --or \
      	-e '\<devm_iounmap\>' --or \
      	-e '\<devm_ioremap_release\>' --or \
      	-e '\<devm_memremap\>' --or \
      	-e '\<devm_memunmap\>' --or \
      	-e '\<__devm_memremap_pages\>' --or \
      	-e '\<pci_remap_cfgspace\>' --or \
      	-e '\<arch_has_dev_port\>' --or \
      	-e '\<arch_phys_wc_add\>' --or \
      	-e '\<arch_phys_wc_del\>' --or \
      	-e '\<memremap\>' --or \
      	-e '\<memunmap\>' --or \
      	-e '\<arch_io_reserve_memtype_wc\>' --or \
      	-e '\<arch_io_free_memtype_wc\>' --or \
      	-e '\<__io_aw\>' --or \
      	-e '\<__io_pbw\>' --or \
      	-e '\<__io_paw\>' --or \
      	-e '\<__io_pbr\>' --or \
      	-e '\<__io_par\>' --or \
      	-e '\<__raw_readb\>' --or \
      	-e '\<__raw_readw\>' --or \
      	-e '\<__raw_readl\>' --or \
      	-e '\<__raw_readq\>' --or \
      	-e '\<__raw_writeb\>' --or \
      	-e '\<__raw_writew\>' --or \
      	-e '\<__raw_writel\>' --or \
      	-e '\<__raw_writeq\>' --or \
      	-e '\<readb\>' --or \
      	-e '\<readw\>' --or \
      	-e '\<readl\>' --or \
      	-e '\<readq\>' --or \
      	-e '\<writeb\>' --or \
      	-e '\<writew\>' --or \
      	-e '\<writel\>' --or \
      	-e '\<writeq\>' --or \
      	-e '\<readb_relaxed\>' --or \
      	-e '\<readw_relaxed\>' --or \
      	-e '\<readl_relaxed\>' --or \
      	-e '\<readq_relaxed\>' --or \
      	-e '\<writeb_relaxed\>' --or \
      	-e '\<writew_relaxed\>' --or \
      	-e '\<writel_relaxed\>' --or \
      	-e '\<writeq_relaxed\>' --or \
      	-e '\<readsb\>' --or \
      	-e '\<readsw\>' --or \
      	-e '\<readsl\>' --or \
      	-e '\<readsq\>' --or \
      	-e '\<writesb\>' --or \
      	-e '\<writesw\>' --or \
      	-e '\<writesl\>' --or \
      	-e '\<writesq\>' --or \
      	-e '\<inb\>' --or \
      	-e '\<inw\>' --or \
      	-e '\<inl\>' --or \
      	-e '\<outb\>' --or \
      	-e '\<outw\>' --or \
      	-e '\<outl\>' --or \
      	-e '\<inb_p\>' --or \
      	-e '\<inw_p\>' --or \
      	-e '\<inl_p\>' --or \
      	-e '\<outb_p\>' --or \
      	-e '\<outw_p\>' --or \
      	-e '\<outl_p\>' --or \
      	-e '\<insb\>' --or \
      	-e '\<insw\>' --or \
      	-e '\<insl\>' --or \
      	-e '\<outsb\>' --or \
      	-e '\<outsw\>' --or \
      	-e '\<outsl\>' --or \
      	-e '\<insb_p\>' --or \
      	-e '\<insw_p\>' --or \
      	-e '\<insl_p\>' --or \
      	-e '\<outsb_p\>' --or \
      	-e '\<outsw_p\>' --or \
      	-e '\<outsl_p\>' --or \
      	-e '\<ioread8\>' --or \
      	-e '\<ioread16\>' --or \
      	-e '\<ioread32\>' --or \
      	-e '\<ioread64\>' --or \
      	-e '\<iowrite8\>' --or \
      	-e '\<iowrite16\>' --or \
      	-e '\<iowrite32\>' --or \
      	-e '\<iowrite64\>' --or \
      	-e '\<ioread16be\>' --or \
      	-e '\<ioread32be\>' --or \
      	-e '\<ioread64be\>' --or \
      	-e '\<iowrite16be\>' --or \
      	-e '\<iowrite32be\>' --or \
      	-e '\<iowrite64be\>' --or \
      	-e '\<ioread8_rep\>' --or \
      	-e '\<ioread16_rep\>' --or \
      	-e '\<ioread32_rep\>' --or \
      	-e '\<ioread64_rep\>' --or \
      	-e '\<iowrite8_rep\>' --or \
      	-e '\<iowrite16_rep\>' --or \
      	-e '\<iowrite32_rep\>' --or \
      	-e '\<iowrite64_rep\>' --or \
      	-e '\<__io_virt\>' --or \
      	-e '\<pci_iounmap\>' --or \
      	-e '\<virt_to_phys\>' --or \
      	-e '\<phys_to_virt\>' --or \
      	-e '\<ioremap_uc\>' --or \
      	-e '\<ioremap\>' --or \
      	-e '\<__ioremap\>' --or \
      	-e '\<iounmap\>' --or \
      	-e '\<ioremap\>' --or \
      	-e '\<ioremap_nocache\>' --or \
      	-e '\<ioremap_uc\>' --or \
      	-e '\<ioremap_wc\>' --or \
      	-e '\<ioremap_wc\>' --or \
      	-e '\<ioremap_wt\>' --or \
      	-e '\<ioport_map\>' --or \
      	-e '\<ioport_unmap\>' --or \
      	-e '\<ioport_map\>' --or \
      	-e '\<ioport_unmap\>' --or \
      	-e '\<xlate_dev_kmem_ptr\>' --or \
      	-e '\<xlate_dev_mem_ptr\>' --or \
      	-e '\<unxlate_dev_mem_ptr\>' --or \
      	-e '\<virt_to_bus\>' --or \
      	-e '\<bus_to_virt\>' --or \
      	-e '\<memset_io\>' --or \
      	-e '\<memcpy_fromio\>' --or \
      	-e '\<memcpy_toio\>'
      
      I also reordered a couple includes when they weren't alphabetical and
      removed clk.h from kona, replacing it with clk-provider.h because
      that driver doesn't use clk consumer APIs.
      Acked-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Cc: Chen-Yu Tsai <wens@csie.org>
      Acked-by: NMaxime Ripard <maxime.ripard@bootlin.com>
      Acked-by: NTero Kristo <t-kristo@ti.com>
      Acked-by: NSekhar Nori <nsekhar@ti.com>
      Cc: Krzysztof Kozlowski <krzk@kernel.org>
      Acked-by: NMark Brown <broonie@kernel.org>
      Cc: Chris Zankel <chris@zankel.net>
      Acked-by: NMax Filippov <jcmvbkbc@gmail.com>
      Acked-by: NJohn Crispin <john@phrozen.org>
      Acked-by: NHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      62e59c4e
  2. 27 4月, 2019 1 次提交
    • S
      clk: Remove CLK_IS_BASIC clk flag · 90b6c5c7
      Stephen Boyd 提交于
      This flag was historically used to indicate that a clk is a "basic" type
      of clk like a mux, divider, gate, etc. This never turned out to be very
      useful though because it was hard to cleanly split "basic" clks from
      other clks in a system. This one flag was a way for type introspection
      and it just didn't scale. If anything, it was used by the TI clk driver
      to indicate that a clk_hw wasn't contained in the SoC specific clk
      structure. We can get rid of this define now that TI is finding those
      clks a different way.
      
      Cc: Tero Kristo <t-kristo@ti.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: <linux-mips@vger.kernel.org>
      Cc: Thierry Reding <thierry.reding@gmail.com>
      Cc: Kevin Hilman <khilman@baylibre.com>
      Cc: <linux-pwm@vger.kernel.org>
      Cc: <linux-amlogic@lists.infradead.org>
      Acked-by: NThierry Reding <treding@nvidia.com>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      90b6c5c7
  3. 24 4月, 2019 7 次提交
  4. 20 4月, 2019 3 次提交
    • S
      clk: Allow parents to be specified via clkspec index · 601b6e93
      Stephen Boyd 提交于
      Some clk providers are simple DT nodes that only have a 'clocks'
      property without having an associated 'clock-names' property. In these
      cases, we want to let these clk providers point to their parent clks
      without having to dereference the 'clocks' property at probe time to
      figure out the parent's globally unique clk name. Let's add an 'index'
      property to the parent_data structure so that clk providers can indicate
      that their parent is a particular index in the 'clocks' DT property.
      
      Cc: Miquel Raynal <miquel.raynal@bootlin.com>
      Cc: Jerome Brunet <jbrunet@baylibre.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Michael Turquette <mturquette@baylibre.com>
      Cc: Jeffrey Hugo <jhugo@codeaurora.org>
      Cc: Chen-Yu Tsai <wens@csie.org>
      Tested-by: NJeffrey Hugo <jhugo@codeaurora.org>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      601b6e93
    • S
      clk: Allow parents to be specified without string names · fc0c209c
      Stephen Boyd 提交于
      The common clk framework is lacking in ability to describe the clk
      topology without specifying strings for every possible parent-child
      link. There are a few drawbacks to the current approach:
      
       1) String comparisons are used for everything, including describing
       topologies that are 'local' to a single clock controller.
      
       2) clk providers (e.g. i2c clk drivers) need to create globally unique
       clk names to avoid collisions in the clk namespace, leading to awkward
       name generation code in various clk drivers.
      
       3) DT bindings may not fully describe the clk topology and linkages
       between clk controllers because drivers can easily rely on globally unique
       strings to describe connections between clks.
      
      This leads to confusing DT bindings, complicated clk name generation
      code, and inefficient string comparisons during clk registration just so
      that the clk framework can detect the topology of the clk tree.
      Furthermore, some drivers call clk_get() and then __clk_get_name() to
      extract the globally unique clk name just so they can specify the parent
      of the clk they're registering. We have of_clk_parent_fill() but that
      mostly only works for single clks registered from a DT node, which isn't
      the norm. Let's simplify this all by introducing two new ways of
      specifying clk parents.
      
      The first method is an array of pointers to clk_hw structures
      corresponding to the parents at that index. This works for clks that are
      registered when we have access to all the clk_hw pointers for the
      parents.
      
      The second method is a mix of clk_hw pointers and strings of local and
      global parent clk names. If the .fw_name member of the map is set we'll
      look for that clk by performing a DT based lookup of the device the clk
      is registered with and the .name specified in the map. If that fails,
      we'll fallback to the .name member and perform a global clk name lookup
      like we've always done before.
      
      Using either one of these new methods is entirely optional. Existing
      drivers will continue to work, and they can migrate to this new approach
      as they see fit. Eventually, we'll want to get rid of the 'parent_names'
      array in struct clk_init_data and use one of these new methods instead.
      
      Cc: Miquel Raynal <miquel.raynal@bootlin.com>
      Cc: Jerome Brunet <jbrunet@baylibre.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Michael Turquette <mturquette@baylibre.com>
      Cc: Jeffrey Hugo <jhugo@codeaurora.org>
      Cc: Chen-Yu Tsai <wens@csie.org>
      Cc: Rob Herring <robh@kernel.org>
      Tested-by: NJeffrey Hugo <jhugo@codeaurora.org>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      fc0c209c
    • S
      clk: Add of_clk_hw_register() API for early clk drivers · 89a5ddcc
      Stephen Boyd 提交于
      In some circumstances drivers register clks early and don't have access
      to a struct device because the device model isn't initialized yet. Add
      an API to let drivers register clks associated with a struct device_node
      so that these drivers can participate in getting parent clks through DT.
      
      Cc: Miquel Raynal <miquel.raynal@bootlin.com>
      Cc: Jerome Brunet <jbrunet@baylibre.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Michael Turquette <mturquette@baylibre.com>
      Cc: Jeffrey Hugo <jhugo@codeaurora.org>
      Cc: Chen-Yu Tsai <wens@csie.org>
      Cc: Rob Herring <robh@kernel.org>
      Tested-by: NJeffrey Hugo <jhugo@codeaurora.org>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      89a5ddcc
  5. 03 4月, 2019 1 次提交
  6. 22 2月, 2019 1 次提交
    • K
      clk: fractional-divider: check parent rate only if flag is set · d13501a2
      Katsuhiro Suzuki 提交于
      Custom approximation of fractional-divider may not need parent clock
      rate checking. For example Rockchip SoCs work fine using grand parent
      clock rate even if target rate is greater than parent.
      
      This patch checks parent clock rate only if CLK_SET_RATE_PARENT flag
      is set.
      
      For detailed example, clock tree of Rockchip I2S audio hardware.
        - Clock rate of CPLL is 1.2GHz, GPLL is 491.52MHz.
        - i2s1_div is integer divider can divide N (N is 1~128).
          Input clock is CPLL or GPLL. Initial divider value is N = 1.
          Ex) PLL = CPLL, N = 10, i2s1_div output rate is
            CPLL / 10 = 1.2GHz / 10 = 120MHz
        - i2s1_frac is fractional divider can divide input to x/y, x and
          y are 16bit integer.
      
      CPLL --> | selector | ---> i2s1_div -+--> | selector | --> I2S1 MCLK
      GPLL --> |          | ,--------------'    |          |
                            `--> i2s1_frac ---> |          |
      
      Clock mux system try to choose suitable one from i2s1_div and
      i2s1_frac for master clock (MCLK) of I2S1.
      
      Bad scenario as follows:
        - Try to set MCLK to 8.192MHz (32kHz audio replay)
          Candidate setting is
          - i2s1_div: GPLL / 60 = 8.192MHz
          i2s1_div candidate is exactly same as target clock rate, so mux
          choose this clock source. i2s1_div output rate is changed
          491.52MHz -> 8.192MHz
      
        - After that try to set to 11.2896MHz (44.1kHz audio replay)
          Candidate settings are
          - i2s1_div : CPLL / 107 = 11.214945MHz
          - i2s1_frac: i2s1_div   = 8.192MHz
            This is because clk_fd_round_rate() thinks target rate
            (11.2896MHz) is higher than parent rate (i2s1_div = 8.192MHz)
            and returns parent clock rate.
      
      Above is current upstreamed behavior. Clock mux system choose
      i2s1_div, but this clock rate is not acceptable for I2S driver, so
      users cannot replay audio.
      
      Expected behavior is:
        - Try to set master clock to 11.2896MHz (44.1kHz audio replay)
          Candidate settings are
          - i2s1_div : CPLL / 107          = 11.214945MHz
          - i2s1_frac: i2s1_div * 147/6400 = 11.2896MHz
                       Change i2s1_div to GPLL / 1 = 491.52MHz at same
                       time.
      
      If apply this commit, clk_fd_round_rate() calls custom approximate
      function of Rockchip even if target rate is higher than parent.
      Custom function changes both grand parent (i2s1_div) and parent
      (i2s_frac) settings at same time. Clock mux system can choose
      i2s1_frac and audio works fine.
      Signed-off-by: NKatsuhiro Suzuki <katsuhiro@katsuster.net>
      Reviewed-by: NHeiko Stuebner <heiko@sntech.de>
      [sboyd@kernel.org: Make function into a macro instead]
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      d13501a2
  7. 25 1月, 2019 4 次提交
  8. 12 12月, 2018 1 次提交
  9. 04 12月, 2018 1 次提交
  10. 03 10月, 2018 2 次提交
  11. 20 6月, 2018 1 次提交
    • J
      clk: add duty cycle support · 9fba738a
      Jerome Brunet 提交于
      Add the possibility to apply and query the clock signal duty cycle ratio.
      
      This is useful when the duty cycle of the clock signal depends on some
      other parameters controlled by the clock framework.
      
      For example, the duty cycle of a divider may depends on the raw divider
      setting (ratio = N / div) , which is controlled by the CCF. In such case,
      going through the pwm framework to control the duty cycle ratio of this
      clock would be a burden.
      
      A clock provider is not required to implement the operation to set and get
      the duty cycle. If it does not implement .get_duty_cycle(), the ratio is
      assumed to be 50%.
      
      This change also adds a new flag, CLK_DUTY_CYCLE_PARENT. This flag should
      be used to indicate that a clock, such as gates and muxes, may inherit
      the duty cycle ratio of its parent clock. If a clock does not provide a
      get_duty_cycle() callback and has CLK_DUTY_CYCLE_PARENT, then the call
      will be directly forwarded to its parent clock, if any. For
      set_duty_cycle(), the clock should also have CLK_SET_RATE_PARENT for the
      call to be forwarded
      Signed-off-by: NJerome Brunet <jbrunet@baylibre.com>
      Signed-off-by: NMichael Turquette <mturquette@baylibre.com>
      Link: lkml.kernel.org/r/20180619144141.8506-1-jbrunet@baylibre.com
      9fba738a
  12. 02 6月, 2018 2 次提交
  13. 02 5月, 2018 1 次提交
  14. 20 4月, 2018 1 次提交
  15. 17 4月, 2018 1 次提交
    • J
      clk: honor CLK_MUX_ROUND_CLOSEST in generic clk mux · 4ad69b80
      Jerome Brunet 提交于
      CLK_MUX_ROUND_CLOSEST is part of the clk_mux documentation but clk_mux
      directly calls __clk_mux_determine_rate(), which overrides the flag.
      As result, if clk_mux is instantiated with CLK_MUX_ROUND_CLOSEST, the
      flag will be ignored and the clock rounded down.
      
      To solve this, this patch expose clk_mux_determine_rate_flags() in the
      clk-provider API and uses it in the determine_rate() callback of clk_mux.
      
      Fixes: 15a02c1f ("clk: Add __clk_mux_determine_rate_closest")
      Signed-off-by: NJerome Brunet <jbrunet@baylibre.com>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      4ad69b80
  16. 13 3月, 2018 4 次提交
  17. 11 1月, 2018 1 次提交
  18. 29 12月, 2017 1 次提交
  19. 22 12月, 2017 1 次提交
  20. 20 12月, 2017 1 次提交
  21. 02 11月, 2017 2 次提交
    • L
      clk: clk-gpio: Make GPIO clock provider use descriptors only · 908a543a
      Linus Walleij 提交于
      After som grep:ing it turns out nothing in the kernel is really calling
      clk_[hw_]_register_gpio_[gate|mux](). All existing instances are just
      created directly from the device tree probe functions at the bottom of
      the clk-gpio.c clock provider file.
      
      This means we can change the signature of the function without any
      consequences! Everyone should be using GPIO descriptors now, so let's
      just go in and enforce that.
      
      This saves a bit of code since GPIO descriptors know inherently if they
      are active low so no need for the code keeping track of that.
      
      We leave it to the caller to come up with the GPIO descriptor. It is
      nowadays possible to do that even without a corresponding device, so
      no excuse not to pass them around. The one in-kernel user lifecycles
      it using devm_gpiod_get() in gpio_clk_driver_probe().
      
      Cc: Sergej Sawazki <ce3a@gmx.de>
      Cc: Jyri Sarha <jsarha@ti.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
      908a543a
    • S
      clk: Add devm_of_clk_add_hw_provider()/del_provider() APIs · aa795c41
      Stephen Boyd 提交于
      Sometimes we only have one of_clk_del_provider() call in driver
      error and remove paths, because we're missing a
      devm_of_clk_add_hw_provider() API. Introduce the API so we can
      convert drivers to use this and potentially reduce the amount of
      code needed to remove providers in drivers.
      Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
      aa795c41
  22. 01 9月, 2017 1 次提交
  23. 08 8月, 2017 1 次提交