Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 17 Jul 2019 17:07:48 +0000 (10:07 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 17 Jul 2019 17:07:48 +0000 (10:07 -0700)
Pull clk updates from Stephen Boyd:
 "This round of clk driver and framework updates is heavy on the driver
  update side. The two main highlights in the core framework are the
  addition of an bulk clk_get API that handles optional clks and an
  extra debugfs file that tells the developer about the current parent
  of a clk.

  The driver updates are dominated by i.MX in the diffstat, but that is
  mostly because that SoC has started converting to the clk_hw style of
  clk registration. The next big update is in the Amlogic meson clk
  driver that gained some support for audio, cpu, and temperature clks
  while fixing some PLL issues. Finally, the biggest thing that stands
  out is the conversion of a large part of the Allwinner sunxi-ng driver
  to the new clk parent scheme that uses less strings and more pointer
  comparisons to match clk parents and children up.

  In general, it looks like we have a lot of little fixes and tweaks
  here and there to clk data along with the normal addition of a handful
  of new drivers and a couple new core framework features.

  Core:
   - Add a 'clk_parent' file in clk debugfs
   - Add a clk_bulk_get_optional() API (with devm too)

  New Drivers:
   - Support gated clk controller on MIPS based BCM63XX SoCs
   - Support SiLabs Si5341 and Si5340 chips
   - Support for CPU clks on Raspberry Pi devices
   - Audsys clock driver for MediaTek MT8516 SoCs

  Updates:
   - Convert a large portion of the Allwinner sunxi-ng driver to new clk parent scheme
   - Small frequency support for SiLabs Si544 chips
   - Slow clk support for AT91 SAM9X60 SoCs
   - Remove dead code in various clk drivers (-Wunused)
   - Support for Marvell 98DX1135 SoCs
   - Get duty cycle of generic pwm clks
   - Improvement in mmc phase calculation and cleanup of some rate defintions
   - Switch i.MX6 and i.MX7 clock drivers to clk_hw based APIs
   - Add GPIO, SNVS and GIC clocks for i.MX8 drivers
   - Mark imx6sx/ul/ull/sll MMDC_P1_IPG and imx8mm DRAM_APB as critical clock
   - Correct imx7ulp nic1_bus_clk and imx8mm audio_pll2_clk clock setting
   - Add clks for new Exynos5422 Dynamic Memory Controller driver
   - Clock definition for Exynos4412 Mali
   - Add CMM (Color Management Module) clocks on Renesas R-Car H3, M3-N, E3, and D3
   - Add TPU (Timer Pulse Unit / PWM) clocks on Renesas RZ/G2M
   - Support for 32 bit clock IDs in TI's sci-clks for J721e SoCs
   - TI clock probing done from DT by default instead of firmware
   - Fix Amlogic Meson mpll fractional part and spread sprectrum issues
   - Add Amlogic meson8 audio clocks
   - Add Amlogic g12a temperature sensors clocks
   - Add Amlogic g12a and g12b cpu clocks
   - Add TPU (Timer Pulse Unit / PWM) clocks on Renesas R-Car H3, M3-W, and M3-N
   - Add CMM (Color Management Module) clocks on Renesas R-Car M3-W
   - Add Clock Domain support on Renesas RZ/N1"

* tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux: (190 commits)
  clk: consoldiate the __clk_get_hw() declarations
  clk: sprd: Add check for return value of sprd_clk_regmap_init()
  clk: lochnagar: Update DT binding doc to include the primary SPDIF MCLK
  clk: Add Si5341/Si5340 driver
  dt-bindings: clock: Add silabs,si5341
  clk: clk-si544: Implement small frequency change support
  clk: add BCM63XX gated clock controller driver
  devicetree: document the BCM63XX gated clock bindings
  clk: at91: sckc: use dedicated functions to unregister clock
  clk: at91: sckc: improve error path for sama5d4 sck registration
  clk: at91: sckc: remove unnecessary line
  clk: at91: sckc: improve error path for sam9x5 sck register
  clk: at91: sckc: add support to free slow clock osclillator
  clk: at91: sckc: add support to free slow rc oscillator
  clk: at91: sckc: add support to free slow oscillator
  clk: rockchip: export HDMIPHY clock on rk3228
  clk: rockchip: add watchdog pclk on rk3328
  clk: rockchip: add clock id for hdmi_phy special clock on rk3228
  clk: rockchip: add clock id for watchdog pclk on rk3328
  clk: at91: sckc: add support for SAM9X60
  ...

65 files changed:
1  2 
Documentation/driver-api/driver-model/devres.rst
arch/mips/jz4740/board-qi_lb60.c
arch/mips/jz4740/platform.c
arch/mips/jz4740/pm.c
arch/mips/jz4740/time.c
drivers/clk/Kconfig
drivers/clk/at91/sckc.c
drivers/clk/bcm/Kconfig
drivers/clk/clk-cdce706.c
drivers/clk/clk-pwm.c
drivers/clk/clk-qoriq.c
drivers/clk/clk.c
drivers/clk/imx/clk-busy.c
drivers/clk/imx/clk-cpu.c
drivers/clk/imx/clk-fixup-div.c
drivers/clk/imx/clk-fixup-mux.c
drivers/clk/imx/clk-gate-exclusive.c
drivers/clk/imx/clk-gate2.c
drivers/clk/imx/clk-imx6q.c
drivers/clk/imx/clk-imx6sl.c
drivers/clk/imx/clk-imx6sx.c
drivers/clk/imx/clk-imx6ul.c
drivers/clk/imx/clk-imx7d.c
drivers/clk/imx/clk-imx8mm.c
drivers/clk/imx/clk-pfd.c
drivers/clk/imx/clk-pllv3.c
drivers/clk/ingenic/Makefile
drivers/clk/ingenic/cgu.c
drivers/clk/ingenic/cgu.h
drivers/clk/ingenic/jz4740-cgu.c
drivers/clk/ingenic/jz4780-cgu.c
drivers/clk/keystone/Kconfig
drivers/clk/mediatek/Kconfig
drivers/clk/qcom/gcc-msm8996.c
drivers/clk/qcom/gdsc.c
drivers/clk/rockchip/clk-mmc-phase.c
drivers/clk/rockchip/clk-px30.c
drivers/clk/rockchip/clk-rk3228.c
drivers/clk/rockchip/clk-rk3288.c
drivers/clk/rockchip/clk-rk3328.c
drivers/clk/rockchip/clk-rk3368.c
drivers/clk/rockchip/clk-rk3399.c
drivers/clk/rockchip/clk.h
drivers/clk/samsung/clk-exynos4.c
drivers/clk/samsung/clk-exynos5420.c
drivers/clk/samsung/clk-exynos5433.c
drivers/clk/sunxi-ng/ccu-sun4i-a10.c
drivers/clk/sunxi-ng/ccu-sun50i-a64.c
drivers/clk/sunxi-ng/ccu-sun5i.c
drivers/clk/sunxi-ng/ccu-sun6i-a31.c
drivers/clk/sunxi-ng/ccu-sun8i-a23.c
drivers/clk/sunxi-ng/ccu-sun8i-a33.c
drivers/clk/sunxi-ng/ccu-sun8i-h3.c
drivers/clk/sunxi-ng/ccu-sun8i-r.c
drivers/clk/sunxi-ng/ccu-sun8i-r40.c
drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c
drivers/clk/sunxi-ng/ccu_common.c
drivers/clk/sunxi-ng/ccu_gate.h
drivers/clk/sunxi/clk-sunxi.c
drivers/clk/tegra/clk-tegra210.c
drivers/firmware/ti_sci.h
include/dt-bindings/clock/rk3228-cru.h
include/dt-bindings/clock/rk3328-cru.h
include/linux/clk.h

index 4ac9912,0000000..a100bef
mode 100644,000000..100644
--- /dev/null
@@@ -1,414 -1,0 +1,418 @@@
 +================================
 +Devres - Managed Device Resource
 +================================
 +
 +Tejun Heo     <teheo@suse.de>
 +
 +First draft   10 January 2007
 +
 +.. contents
 +
 +   1. Intro                   : Huh? Devres?
 +   2. Devres                  : Devres in a nutshell
 +   3. Devres Group            : Group devres'es and release them together
 +   4. Details                 : Life time rules, calling context, ...
 +   5. Overhead                        : How much do we have to pay for this?
 +   6. List of managed interfaces: Currently implemented managed interfaces
 +
 +
 +1. Intro
 +--------
 +
 +devres came up while trying to convert libata to use iomap.  Each
 +iomapped address should be kept and unmapped on driver detach.  For
 +example, a plain SFF ATA controller (that is, good old PCI IDE) in
 +native mode makes use of 5 PCI BARs and all of them should be
 +maintained.
 +
 +As with many other device drivers, libata low level drivers have
 +sufficient bugs in ->remove and ->probe failure path.  Well, yes,
 +that's probably because libata low level driver developers are lazy
 +bunch, but aren't all low level driver developers?  After spending a
 +day fiddling with braindamaged hardware with no document or
 +braindamaged document, if it's finally working, well, it's working.
 +
 +For one reason or another, low level drivers don't receive as much
 +attention or testing as core code, and bugs on driver detach or
 +initialization failure don't happen often enough to be noticeable.
 +Init failure path is worse because it's much less travelled while
 +needs to handle multiple entry points.
 +
 +So, many low level drivers end up leaking resources on driver detach
 +and having half broken failure path implementation in ->probe() which
 +would leak resources or even cause oops when failure occurs.  iomap
 +adds more to this mix.  So do msi and msix.
 +
 +
 +2. Devres
 +---------
 +
 +devres is basically linked list of arbitrarily sized memory areas
 +associated with a struct device.  Each devres entry is associated with
 +a release function.  A devres can be released in several ways.  No
 +matter what, all devres entries are released on driver detach.  On
 +release, the associated release function is invoked and then the
 +devres entry is freed.
 +
 +Managed interface is created for resources commonly used by device
 +drivers using devres.  For example, coherent DMA memory is acquired
 +using dma_alloc_coherent().  The managed version is called
 +dmam_alloc_coherent().  It is identical to dma_alloc_coherent() except
 +for the DMA memory allocated using it is managed and will be
 +automatically released on driver detach.  Implementation looks like
 +the following::
 +
 +  struct dma_devres {
 +      size_t          size;
 +      void            *vaddr;
 +      dma_addr_t      dma_handle;
 +  };
 +
 +  static void dmam_coherent_release(struct device *dev, void *res)
 +  {
 +      struct dma_devres *this = res;
 +
 +      dma_free_coherent(dev, this->size, this->vaddr, this->dma_handle);
 +  }
 +
 +  dmam_alloc_coherent(dev, size, dma_handle, gfp)
 +  {
 +      struct dma_devres *dr;
 +      void *vaddr;
 +
 +      dr = devres_alloc(dmam_coherent_release, sizeof(*dr), gfp);
 +      ...
 +
 +      /* alloc DMA memory as usual */
 +      vaddr = dma_alloc_coherent(...);
 +      ...
 +
 +      /* record size, vaddr, dma_handle in dr */
 +      dr->vaddr = vaddr;
 +      ...
 +
 +      devres_add(dev, dr);
 +
 +      return vaddr;
 +  }
 +
 +If a driver uses dmam_alloc_coherent(), the area is guaranteed to be
 +freed whether initialization fails half-way or the device gets
 +detached.  If most resources are acquired using managed interface, a
 +driver can have much simpler init and exit code.  Init path basically
 +looks like the following::
 +
 +  my_init_one()
 +  {
 +      struct mydev *d;
 +
 +      d = devm_kzalloc(dev, sizeof(*d), GFP_KERNEL);
 +      if (!d)
 +              return -ENOMEM;
 +
 +      d->ring = dmam_alloc_coherent(...);
 +      if (!d->ring)
 +              return -ENOMEM;
 +
 +      if (check something)
 +              return -EINVAL;
 +      ...
 +
 +      return register_to_upper_layer(d);
 +  }
 +
 +And exit path::
 +
 +  my_remove_one()
 +  {
 +      unregister_from_upper_layer(d);
 +      shutdown_my_hardware();
 +  }
 +
 +As shown above, low level drivers can be simplified a lot by using
 +devres.  Complexity is shifted from less maintained low level drivers
 +to better maintained higher layer.  Also, as init failure path is
 +shared with exit path, both can get more testing.
 +
 +Note though that when converting current calls or assignments to
 +managed devm_* versions it is up to you to check if internal operations
 +like allocating memory, have failed. Managed resources pertains to the
 +freeing of these resources *only* - all other checks needed are still
 +on you. In some cases this may mean introducing checks that were not
 +necessary before moving to the managed devm_* calls.
 +
 +
 +3. Devres group
 +---------------
 +
 +Devres entries can be grouped using devres group.  When a group is
 +released, all contained normal devres entries and properly nested
 +groups are released.  One usage is to rollback series of acquired
 +resources on failure.  For example::
 +
 +  if (!devres_open_group(dev, NULL, GFP_KERNEL))
 +      return -ENOMEM;
 +
 +  acquire A;
 +  if (failed)
 +      goto err;
 +
 +  acquire B;
 +  if (failed)
 +      goto err;
 +  ...
 +
 +  devres_remove_group(dev, NULL);
 +  return 0;
 +
 + err:
 +  devres_release_group(dev, NULL);
 +  return err_code;
 +
 +As resource acquisition failure usually means probe failure, constructs
 +like above are usually useful in midlayer driver (e.g. libata core
 +layer) where interface function shouldn't have side effect on failure.
 +For LLDs, just returning error code suffices in most cases.
 +
 +Each group is identified by `void *id`.  It can either be explicitly
 +specified by @id argument to devres_open_group() or automatically
 +created by passing NULL as @id as in the above example.  In both
 +cases, devres_open_group() returns the group's id.  The returned id
 +can be passed to other devres functions to select the target group.
 +If NULL is given to those functions, the latest open group is
 +selected.
 +
 +For example, you can do something like the following::
 +
 +  int my_midlayer_create_something()
 +  {
 +      if (!devres_open_group(dev, my_midlayer_create_something, GFP_KERNEL))
 +              return -ENOMEM;
 +
 +      ...
 +
 +      devres_close_group(dev, my_midlayer_create_something);
 +      return 0;
 +  }
 +
 +  void my_midlayer_destroy_something()
 +  {
 +      devres_release_group(dev, my_midlayer_create_something);
 +  }
 +
 +
 +4. Details
 +----------
 +
 +Lifetime of a devres entry begins on devres allocation and finishes
 +when it is released or destroyed (removed and freed) - no reference
 +counting.
 +
 +devres core guarantees atomicity to all basic devres operations and
 +has support for single-instance devres types (atomic
 +lookup-and-add-if-not-found).  Other than that, synchronizing
 +concurrent accesses to allocated devres data is caller's
 +responsibility.  This is usually non-issue because bus ops and
 +resource allocations already do the job.
 +
 +For an example of single-instance devres type, read pcim_iomap_table()
 +in lib/devres.c.
 +
 +All devres interface functions can be called without context if the
 +right gfp mask is given.
 +
 +
 +5. Overhead
 +-----------
 +
 +Each devres bookkeeping info is allocated together with requested data
 +area.  With debug option turned off, bookkeeping info occupies 16
 +bytes on 32bit machines and 24 bytes on 64bit (three pointers rounded
 +up to ull alignment).  If singly linked list is used, it can be
 +reduced to two pointers (8 bytes on 32bit, 16 bytes on 64bit).
 +
 +Each devres group occupies 8 pointers.  It can be reduced to 6 if
 +singly linked list is used.
 +
 +Memory space overhead on ahci controller with two ports is between 300
 +and 400 bytes on 32bit machine after naive conversion (we can
 +certainly invest a bit more effort into libata core layer).
 +
 +
 +6. List of managed interfaces
 +-----------------------------
 +
 +CLOCK
 +  devm_clk_get()
 +  devm_clk_get_optional()
 +  devm_clk_put()
++  devm_clk_bulk_get()
++  devm_clk_bulk_get_all()
++  devm_clk_bulk_get_optional()
++  devm_get_clk_from_childl()
 +  devm_clk_hw_register()
 +  devm_of_clk_add_hw_provider()
 +  devm_clk_hw_register_clkdev()
 +
 +DMA
 +  dmaenginem_async_device_register()
 +  dmam_alloc_coherent()
 +  dmam_alloc_attrs()
 +  dmam_free_coherent()
 +  dmam_pool_create()
 +  dmam_pool_destroy()
 +
 +DRM
 +  devm_drm_dev_init()
 +
 +GPIO
 +  devm_gpiod_get()
 +  devm_gpiod_get_index()
 +  devm_gpiod_get_index_optional()
 +  devm_gpiod_get_optional()
 +  devm_gpiod_put()
 +  devm_gpiod_unhinge()
 +  devm_gpiochip_add_data()
 +  devm_gpio_request()
 +  devm_gpio_request_one()
 +  devm_gpio_free()
 +
 +I2C
 +  devm_i2c_new_dummy_device()
 +
 +IIO
 +  devm_iio_device_alloc()
 +  devm_iio_device_free()
 +  devm_iio_device_register()
 +  devm_iio_device_unregister()
 +  devm_iio_kfifo_allocate()
 +  devm_iio_kfifo_free()
 +  devm_iio_triggered_buffer_setup()
 +  devm_iio_triggered_buffer_cleanup()
 +  devm_iio_trigger_alloc()
 +  devm_iio_trigger_free()
 +  devm_iio_trigger_register()
 +  devm_iio_trigger_unregister()
 +  devm_iio_channel_get()
 +  devm_iio_channel_release()
 +  devm_iio_channel_get_all()
 +  devm_iio_channel_release_all()
 +
 +INPUT
 +  devm_input_allocate_device()
 +
 +IO region
 +  devm_release_mem_region()
 +  devm_release_region()
 +  devm_release_resource()
 +  devm_request_mem_region()
 +  devm_request_region()
 +  devm_request_resource()
 +
 +IOMAP
 +  devm_ioport_map()
 +  devm_ioport_unmap()
 +  devm_ioremap()
 +  devm_ioremap_nocache()
 +  devm_ioremap_wc()
 +  devm_ioremap_resource() : checks resource, requests memory region, ioremaps
 +  devm_iounmap()
 +  pcim_iomap()
 +  pcim_iomap_regions()        : do request_region() and iomap() on multiple BARs
 +  pcim_iomap_table()  : array of mapped addresses indexed by BAR
 +  pcim_iounmap()
 +
 +IRQ
 +  devm_free_irq()
 +  devm_request_any_context_irq()
 +  devm_request_irq()
 +  devm_request_threaded_irq()
 +  devm_irq_alloc_descs()
 +  devm_irq_alloc_desc()
 +  devm_irq_alloc_desc_at()
 +  devm_irq_alloc_desc_from()
 +  devm_irq_alloc_descs_from()
 +  devm_irq_alloc_generic_chip()
 +  devm_irq_setup_generic_chip()
 +  devm_irq_sim_init()
 +
 +LED
 +  devm_led_classdev_register()
 +  devm_led_classdev_unregister()
 +
 +MDIO
 +  devm_mdiobus_alloc()
 +  devm_mdiobus_alloc_size()
 +  devm_mdiobus_free()
 +
 +MEM
 +  devm_free_pages()
 +  devm_get_free_pages()
 +  devm_kasprintf()
 +  devm_kcalloc()
 +  devm_kfree()
 +  devm_kmalloc()
 +  devm_kmalloc_array()
 +  devm_kmemdup()
 +  devm_kstrdup()
 +  devm_kvasprintf()
 +  devm_kzalloc()
 +
 +MFD
 +  devm_mfd_add_devices()
 +
 +MUX
 +  devm_mux_chip_alloc()
 +  devm_mux_chip_register()
 +  devm_mux_control_get()
 +
 +PER-CPU MEM
 +  devm_alloc_percpu()
 +  devm_free_percpu()
 +
 +PCI
 +  devm_pci_alloc_host_bridge()  : managed PCI host bridge allocation
 +  devm_pci_remap_cfgspace()   : ioremap PCI configuration space
 +  devm_pci_remap_cfg_resource()       : ioremap PCI configuration space resource
 +  pcim_enable_device()                : after success, all PCI ops become managed
 +  pcim_pin_device()           : keep PCI device enabled after release
 +
 +PHY
 +  devm_usb_get_phy()
 +  devm_usb_put_phy()
 +
 +PINCTRL
 +  devm_pinctrl_get()
 +  devm_pinctrl_put()
 +  devm_pinctrl_register()
 +  devm_pinctrl_unregister()
 +
 +POWER
 +  devm_reboot_mode_register()
 +  devm_reboot_mode_unregister()
 +
 +PWM
 +  devm_pwm_get()
 +  devm_pwm_put()
 +
 +REGULATOR
 +  devm_regulator_bulk_get()
 +  devm_regulator_get()
 +  devm_regulator_put()
 +  devm_regulator_register()
 +
 +RESET
 +  devm_reset_control_get()
 +  devm_reset_controller_register()
 +
 +SERDEV
 +  devm_serdev_device_open()
 +
 +SLAVE DMA ENGINE
 +  devm_acpi_dma_controller_register()
 +
 +SPI
 +  devm_spi_register_master()
 +
 +WATCHDOG
 +  devm_watchdog_register_device()
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -1,4 -1,12 +1,13 @@@
 +# SPDX-License-Identifier: GPL-2.0-only
+ config CLK_BCM2835
+       bool "Broadcom BCM2835 clock support"
+       depends on ARCH_BCM2835 || ARCH_BRCMSTB || COMPILE_TEST
+       depends on COMMON_CLK
+       default ARCH_BCM2835 || ARCH_BRCMSTB
+       help
+         Enable common clock framework support for Broadcom BCM2835
+         SoCs.
  config CLK_BCM_63XX
        bool "Broadcom BCM63xx clock support"
        depends on ARCH_BCM_63XX || COMPILE_TEST
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -1,5 -1,4 +1,5 @@@
- obj-$(CONFIG_INGENIC_CGU_COMMON)      += cgu.o
 +# SPDX-License-Identifier: GPL-2.0-only
+ obj-$(CONFIG_INGENIC_CGU_COMMON)      += cgu.o pm.o
  obj-$(CONFIG_INGENIC_CGU_JZ4740)      += jz4740-cgu.o
  obj-$(CONFIG_INGENIC_CGU_JZ4725B)     += jz4725b-cgu.o
  obj-$(CONFIG_INGENIC_CGU_JZ4770)      += jz4770-cgu.o
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge