]> Git Repo - linux.git/commitdiff
Merge tag 'soundwire-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul...
authorLinus Torvalds <[email protected]>
Sun, 3 Sep 2023 17:20:57 +0000 (10:20 -0700)
committerLinus Torvalds <[email protected]>
Sun, 3 Sep 2023 17:20:57 +0000 (10:20 -0700)
Pull soundwire updates from Vinod Koul:
 "Device numbering and intel driver changes are main features:

   - Core support for soundwire device number allocation

   - intel driver updates for adding hw_params for DAI ops, hybrid
     number allocation and power managemnt callback updates

   - DT header include changes for subsystem"

* tag 'soundwire-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire:
  soundwire: intel_ace2x: add DAI hw_params/prepare/hw_free callbacks
  soundwire: intel_auxdevice: add hybrid IDA-based device_number allocation
  soundwire: bus: add callbacks for device_number allocation
  soundwire: extend parameters of new_peripheral_assigned() callback
  soundWire: intel_auxdevice: resume 'sdw-master' on startup and system resume
  soundwire: intel_auxdevice: enable pm_runtime earlier on startup
  soundwire: Explicitly include correct DT includes

1  2 
drivers/soundwire/bus.c
drivers/soundwire/qcom.c
include/linux/soundwire/sdw.h
include/linux/soundwire/sdw_intel.h

diff --combined drivers/soundwire/bus.c
index 1cc2281cb37059544c3b02b3f31ce7862e6ad9c2,0e1e4bedc708e8eb5e41665e165344481c95073f..1720031f35a358a1defeddc656b6cc20035d38d2
@@@ -3,7 -3,6 +3,7 @@@
  
  #include <linux/acpi.h>
  #include <linux/delay.h>
 +#include <linux/irq.h>
  #include <linux/mod_devicetable.h>
  #include <linux/pm_runtime.h>
  #include <linux/soundwire/sdw_registers.h>
@@@ -13,7 -12,6 +13,6 @@@
  #include "sysfs_local.h"
  
  static DEFINE_IDA(sdw_bus_ida);
- static DEFINE_IDA(sdw_peripheral_ida);
  
  static int sdw_get_id(struct sdw_bus *bus)
  {
        return 0;
  }
  
 +static int sdw_irq_map(struct irq_domain *h, unsigned int virq,
 +                     irq_hw_number_t hw)
 +{
 +      struct sdw_bus *bus = h->host_data;
 +
 +      irq_set_chip_data(virq, bus);
 +      irq_set_chip(virq, &bus->irq_chip);
 +      irq_set_nested_thread(virq, 1);
 +      irq_set_noprobe(virq);
 +
 +      return 0;
 +}
 +
 +static const struct irq_domain_ops sdw_domain_ops = {
 +      .map    = sdw_irq_map,
 +};
 +
  /**
   * sdw_bus_master_add() - add a bus Master instance
   * @bus: bus instance
@@@ -169,14 -150,6 +168,14 @@@ int sdw_bus_master_add(struct sdw_bus *
        bus->params.curr_bank = SDW_BANK0;
        bus->params.next_bank = SDW_BANK1;
  
 +      bus->irq_chip.name = dev_name(bus->dev);
 +      bus->domain = irq_domain_create_linear(fwnode, SDW_MAX_DEVICES,
 +                                             &sdw_domain_ops, bus);
 +      if (!bus->domain) {
 +              dev_err(bus->dev, "Failed to add IRQ domain\n");
 +              return -EINVAL;
 +      }
 +
        return 0;
  }
  EXPORT_SYMBOL(sdw_bus_master_add);
@@@ -194,8 -167,8 +193,8 @@@ static int sdw_delete_slave(struct devi
  
        if (slave->dev_num) { /* clear dev_num if assigned */
                clear_bit(slave->dev_num, bus->assigned);
-               if (bus->dev_num_ida_min)
-                       ida_free(&sdw_peripheral_ida, slave->dev_num);
+               if (bus->ops && bus->ops->put_device_num)
+                       bus->ops->put_device_num(bus, slave);
        }
        list_del_init(&slave->node);
        mutex_unlock(&bus->bus_lock);
  void sdw_bus_master_delete(struct sdw_bus *bus)
  {
        device_for_each_child(bus->dev, NULL, sdw_delete_slave);
 +
 +      irq_domain_remove(bus->domain);
 +
        sdw_master_device_del(bus);
  
        sdw_bus_debugfs_exit(bus);
@@@ -739,16 -709,15 +738,15 @@@ EXPORT_SYMBOL(sdw_compare_devid)
  /* called with bus_lock held */
  static int sdw_get_device_num(struct sdw_slave *slave)
  {
+       struct sdw_bus *bus = slave->bus;
        int bit;
  
-       if (slave->bus->dev_num_ida_min) {
-               bit = ida_alloc_range(&sdw_peripheral_ida,
-                                     slave->bus->dev_num_ida_min, SDW_MAX_DEVICES,
-                                     GFP_KERNEL);
+       if (bus->ops && bus->ops->get_device_num) {
+               bit = bus->ops->get_device_num(bus, slave);
                if (bit < 0)
                        goto err;
        } else {
-               bit = find_first_zero_bit(slave->bus->assigned, SDW_MAX_DEVICES);
+               bit = find_first_zero_bit(bus->assigned, SDW_MAX_DEVICES);
                if (bit == SDW_MAX_DEVICES) {
                        bit = -ENODEV;
                        goto err;
         * Do not update dev_num in Slave data structure here,
         * Update once program dev_num is successful
         */
-       set_bit(bit, slave->bus->assigned);
+       set_bit(bit, bus->assigned);
  
  err:
        return bit;
@@@ -810,7 -779,7 +808,7 @@@ static int sdw_assign_device_num(struc
        slave->dev_num = slave->dev_num_sticky;
  
        if (bus->ops && bus->ops->new_peripheral_assigned)
-               bus->ops->new_peripheral_assigned(bus, dev_num);
+               bus->ops->new_peripheral_assigned(bus, slave, dev_num);
  
        return 0;
  }
@@@ -951,8 -920,8 +949,8 @@@ static void sdw_modify_slave_status(str
                        "initializing enumeration and init completion for Slave %d\n",
                        slave->dev_num);
  
 -              init_completion(&slave->enumeration_complete);
 -              init_completion(&slave->initialization_complete);
 +              reinit_completion(&slave->enumeration_complete);
 +              reinit_completion(&slave->initialization_complete);
  
        } else if ((status == SDW_SLAVE_ATTACHED) &&
                   (slave->status == SDW_SLAVE_UNATTACHED)) {
                        "signaling enumeration completion for Slave %d\n",
                        slave->dev_num);
  
 -              complete(&slave->enumeration_complete);
 +              complete_all(&slave->enumeration_complete);
        }
        slave->status = status;
        mutex_unlock(&bus->bus_lock);
@@@ -1754,9 -1723,6 +1752,9 @@@ static int sdw_handle_slave_alerts(stru
                                struct device *dev = &slave->dev;
                                struct sdw_driver *drv = drv_to_sdw_driver(dev->driver);
  
 +                              if (slave->prop.use_domain_irq && slave->irq)
 +                                      handle_nested_irq(slave->irq);
 +
                                if (drv->ops && drv->ops->interrupt_callback) {
                                        slave_intr.sdca_cascade = sdca_cascade;
                                        slave_intr.control_port = clear;
@@@ -1983,7 -1949,7 +1981,7 @@@ int sdw_handle_slave_status(struct sdw_
                                "signaling initialization completion for Slave %d\n",
                                slave->dev_num);
  
 -                      complete(&slave->initialization_complete);
 +                      complete_all(&slave->initialization_complete);
  
                        /*
                         * If the manager became pm_runtime active, the peripherals will be
diff --combined drivers/soundwire/qcom.c
index c029e4d53573eac7a4ea09baa3292924629c8bee,d178a0dc091829389cfec18c51094007bbe8a099..55be9f4b8d59ab0212e6e934e9c50663715f981a
@@@ -10,7 -10,6 +10,6 @@@
  #include <linux/debugfs.h>
  #include <linux/of.h>
  #include <linux/of_irq.h>
- #include <linux/of_device.h>
  #include <linux/pm_runtime.h>
  #include <linux/regmap.h>
  #include <linux/reset.h>
@@@ -540,7 -539,7 +539,7 @@@ static int qcom_swrm_get_alert_slave_de
                status = (val >> (dev_num * SWRM_MCP_SLV_STATUS_SZ));
  
                if ((status & SWRM_MCP_SLV_STATUS_MASK) == SDW_SLAVE_ALERT) {
 -                      ctrl->status[dev_num] = status;
 +                      ctrl->status[dev_num] = status & SWRM_MCP_SLV_STATUS_MASK;
                        return dev_num;
                }
        }
index a388160f4be0d6f174b883981286bd09969e5b7a,bde93ca6aaa6b868d411beb65c4a8377b3fec896..4f3d14bb15385a2860e4e1ee54738f60eb7c1b06
@@@ -6,8 -6,6 +6,8 @@@
  
  #include <linux/bug.h>
  #include <linux/lockdep_types.h>
 +#include <linux/irq.h>
 +#include <linux/irqdomain.h>
  #include <linux/mod_devicetable.h>
  #include <linux/bitfield.h>
  
@@@ -372,7 -370,6 +372,7 @@@ struct sdw_dpn_prop 
   * @clock_reg_supported: the Peripheral implements the clock base and scale
   * registers introduced with the SoundWire 1.2 specification. SDCA devices
   * do not need to set this boolean property as the registers are required.
 + * @use_domain_irq: call actual IRQ handler on slave, as well as callback
   */
  struct sdw_slave_prop {
        u32 mipi_revision;
        u8 scp_int1_mask;
        u32 quirks;
        bool clock_reg_supported;
 +      bool use_domain_irq;
  };
  
  #define SDW_SLAVE_QUIRKS_INVALID_INITIAL_PARITY       BIT(0)
@@@ -486,11 -482,6 +486,11 @@@ struct sdw_slave_id 
        __u8 sdw_version:4;
  };
  
 +struct sdw_extended_slave_id {
 +      int link_id;
 +      struct sdw_slave_id id;
 +};
 +
  /*
   * Helper macros to extract the MIPI-defined IDs
   *
@@@ -650,7 -641,6 +650,7 @@@ struct sdw_slave_ops 
   * struct sdw_slave - SoundWire Slave
   * @id: MIPI device ID
   * @dev: Linux device
 + * @irq: IRQ number
   * @status: Status reported by the Slave
   * @bus: Bus handle
   * @prop: Slave properties
  struct sdw_slave {
        struct sdw_slave_id id;
        struct device dev;
 +      int irq;
        enum sdw_slave_status status;
        struct sdw_bus *bus;
        struct sdw_slave_prop prop;
@@@ -858,6 -847,8 +858,8 @@@ struct sdw_defer 
   * @post_bank_switch: Callback for post bank switch
   * @read_ping_status: Read status from PING frames, reported with two bits per Device.
   * Bits 31:24 are reserved.
+  * @get_device_num: Callback for vendor-specific device_number allocation
+  * @put_device_num: Callback for vendor-specific device_number release
   * @new_peripheral_assigned: Callback to handle enumeration of new peripheral.
   */
  struct sdw_master_ops {
        int (*pre_bank_switch)(struct sdw_bus *bus);
        int (*post_bank_switch)(struct sdw_bus *bus);
        u32 (*read_ping_status)(struct sdw_bus *bus);
-       void (*new_peripheral_assigned)(struct sdw_bus *bus, int dev_num);
+       int (*get_device_num)(struct sdw_bus *bus, struct sdw_slave *slave);
+       void (*put_device_num)(struct sdw_bus *bus, struct sdw_slave *slave);
+       void (*new_peripheral_assigned)(struct sdw_bus *bus,
+                                       struct sdw_slave *slave,
+                                       int dev_num);
  };
  
  /**
   * is used to compute and program bus bandwidth, clock, frame shape,
   * transport and port parameters
   * @debugfs: Bus debugfs
 + * @domain: IRQ domain
   * @defer_msg: Defer message
   * @clk_stop_timeout: Clock stop timeout computed
   * @bank_switch_timeout: Bank switch timeout computed
   * meaningful if multi_link is set. If set to 1, hardware-based
   * synchronization will be used even if a stream only uses a single
   * SoundWire segment.
-  * @dev_num_ida_min: if set, defines the minimum values for the IDA
-  * used to allocate system-unique device numbers. This value needs to be
-  * identical across all SoundWire bus in the system.
   */
  struct sdw_bus {
        struct device *dev;
  #ifdef CONFIG_DEBUG_FS
        struct dentry *debugfs;
  #endif
 +      struct irq_chip irq_chip;
 +      struct irq_domain *domain;
        struct sdw_defer defer_msg;
        unsigned int clk_stop_timeout;
        u32 bank_switch_timeout;
        bool multi_link;
        int hw_sync_min_links;
-       int dev_num_ida_min;
  };
  
  int sdw_bus_master_add(struct sdw_bus *bus, struct device *parent,
index fa67fad4ef51085f6f63895b55ba79c36028dd4e,3a824cae7379cd393905a1a7021f0918b8da987f..00bb22d96ae56744009c8de258d9be6b557986a3
@@@ -264,6 -264,11 +264,6 @@@ struct sdw_intel_link_dev
   */
  #define SDW_INTEL_CLK_STOP_BUS_RESET          BIT(3)
  
 -struct sdw_intel_slave_id {
 -      int link_id;
 -      struct sdw_slave_id id;
 -};
 -
  struct hdac_bus;
  
  /**
@@@ -293,7 -298,7 +293,7 @@@ struct sdw_intel_ctx 
        int num_slaves;
        acpi_handle handle;
        struct sdw_intel_link_dev **ldev;
 -      struct sdw_intel_slave_id *ids;
 +      struct sdw_extended_slave_id *ids;
        struct list_head link_list;
        struct mutex shim_lock; /* lock for access to shared SHIM registers */
        u32 shim_mask;
@@@ -428,4 -433,11 +428,11 @@@ struct sdw_intel_hw_ops 
  extern const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops;
  extern const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops;
  
+ /*
+  * IDA min selected to allow for 5 unconstrained devices per link,
+  * and 6 system-unique Device Numbers for wake-capable devices.
+  */
+ #define SDW_INTEL_DEV_NUM_IDA_MIN           6
  #endif
This page took 0.085509 seconds and 4 git commands to generate.