Merge branch 'device-properties'
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 11 Nov 2016 22:23:02 +0000 (23:23 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 11 Nov 2016 22:23:02 +0000 (23:23 +0100)
* device-properties:
  ACPI / platform: Add support for build-in properties

1  2 
drivers/acpi/acpi_apd.c
drivers/acpi/acpi_platform.c
drivers/acpi/scan.c
include/linux/acpi.h

diff --combined drivers/acpi/acpi_apd.c
index d58fbf7f04e6c7f4d901f648d9f26a0708cc6f15,5959ed996a752ff59146241d0be70f53fa7d4905..7dd70927991e7e9e0de14a3af89db442eca8d175
@@@ -72,7 -72,7 +72,7 @@@ static int acpi_apd_setup(struct apd_pr
  }
  
  #ifdef CONFIG_X86_AMD_PLATFORM_DEVICE
 -static struct apd_device_desc cz_i2c_desc = {
 +static const struct apd_device_desc cz_i2c_desc = {
        .setup = acpi_apd_setup,
        .fixed_clk_rate = 133000000,
  };
@@@ -84,7 -84,7 +84,7 @@@ static struct property_entry uart_prope
        { },
  };
  
 -static struct apd_device_desc cz_uart_desc = {
 +static const struct apd_device_desc cz_uart_desc = {
        .setup = acpi_apd_setup,
        .fixed_clk_rate = 48000000,
        .properties = uart_properties,
  #endif
  
  #ifdef CONFIG_ARM64
 -static struct apd_device_desc xgene_i2c_desc = {
 +static const struct apd_device_desc xgene_i2c_desc = {
        .setup = acpi_apd_setup,
        .fixed_clk_rate = 100000000,
  };
 +
 +static const struct apd_device_desc vulcan_spi_desc = {
 +      .setup = acpi_apd_setup,
 +      .fixed_clk_rate = 133000000,
 +};
  #endif
  
  #else
@@@ -122,7 -117,7 +122,7 @@@ static int acpi_apd_create_device(struc
        int ret;
  
        if (!dev_desc) {
-               pdev = acpi_create_platform_device(adev);
+               pdev = acpi_create_platform_device(adev, NULL);
                return IS_ERR_OR_NULL(pdev) ? PTR_ERR(pdev) : 1;
        }
  
                        goto err_out;
        }
  
-       if (dev_desc->properties) {
-               ret = device_add_properties(&adev->dev, dev_desc->properties);
-               if (ret)
-                       goto err_out;
-       }
        adev->driver_data = pdata;
-       pdev = acpi_create_platform_device(adev);
+       pdev = acpi_create_platform_device(adev, dev_desc->properties);
        if (!IS_ERR_OR_NULL(pdev))
                return 1;
  
@@@ -169,7 -158,6 +163,7 @@@ static const struct acpi_device_id acpi
  #endif
  #ifdef CONFIG_ARM64
        { "APMC0D0F", APD_ADDR(xgene_i2c_desc) },
 +      { "BRCM900D", APD_ADDR(vulcan_spi_desc) },
  #endif
        { }
  };
index b200ae1f3c6fb0fbef0a38135fd0b27e6da45041,56e70da83c6cef503fbbaaf38f715ad7993c285a..b4c1a6a51da482a953051959279fc9d39cd29d49
@@@ -17,7 -17,6 +17,7 @@@
  #include <linux/kernel.h>
  #include <linux/module.h>
  #include <linux/dma-mapping.h>
 +#include <linux/pci.h>
  #include <linux/platform_device.h>
  
  #include "internal.h"
@@@ -31,25 -30,10 +31,26 @@@ static const struct acpi_device_id forb
        {"", 0},
  };
  
 +static void acpi_platform_fill_resource(struct acpi_device *adev,
 +      const struct resource *src, struct resource *dest)
 +{
 +      struct device *parent;
 +
 +      *dest = *src;
 +
 +      /*
 +       * If the device has parent we need to take its resources into
 +       * account as well because this device might consume part of those.
 +       */
 +      parent = acpi_get_first_physical_node(adev->parent);
 +      if (parent && dev_is_pci(parent))
 +              dest->parent = pci_find_resource(to_pci_dev(parent), dest);
 +}
 +
  /**
   * acpi_create_platform_device - Create platform device for ACPI device node
   * @adev: ACPI device node to create a platform device for.
+  * @properties: Optional collection of build-in properties.
   *
   * Check if the given @adev can be represented as a platform device and, if
   * that's the case, create and register a platform device, populate its common
@@@ -57,7 -41,8 +58,8 @@@
   *
   * Name of the platform device will be the same as @adev's.
   */
- struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
+ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
+                                       struct property_entry *properties)
  {
        struct platform_device *pdev = NULL;
        struct platform_device_info pdevinfo;
@@@ -87,8 -72,7 +89,8 @@@
                }
                count = 0;
                list_for_each_entry(rentry, &resource_list, node)
 -                      resources[count++] = *rentry->res;
 +                      acpi_platform_fill_resource(adev, rentry->res,
 +                                                  &resources[count++]);
  
                acpi_dev_free_resource_list(&resource_list);
        }
        pdevinfo.res = resources;
        pdevinfo.num_res = count;
        pdevinfo.fwnode = acpi_fwnode_handle(adev);
+       pdevinfo.properties = properties;
  
        if (acpi_dma_supported(adev))
                pdevinfo.dma_mask = DMA_BIT_MASK(32);
diff --combined drivers/acpi/scan.c
index 035ac646d8db55272bf2182f690e0452b8d7a485,3d31ae3a482d21ce2a80126e9fde875114992b41..3d1856f1f4d03eb8c47e5e4043684d7b5b76b046
@@@ -1734,7 -1734,7 +1734,7 @@@ static void acpi_default_enumeration(st
                               &is_spi_i2c_slave);
        acpi_dev_free_resource_list(&resource_list);
        if (!is_spi_i2c_slave) {
-               acpi_create_platform_device(device);
+               acpi_create_platform_device(device, NULL);
                acpi_device_set_enumerated(device);
        } else {
                blocking_notifier_call_chain(&acpi_reconfig_chain,
@@@ -2002,7 -2002,6 +2002,7 @@@ int __init acpi_scan_init(void
        acpi_pnp_init();
        acpi_int340x_thermal_init();
        acpi_amba_init();
 +      acpi_watchdog_init();
  
        acpi_scan_add_handler(&generic_device_handler);
  
        }
  
        acpi_update_all_gpes();
 +      acpi_ec_ecdt_start();
  
        acpi_scan_initialized = true;
  
  
  static struct acpi_probe_entry *ape;
  static int acpi_probe_count;
 -static DEFINE_SPINLOCK(acpi_probe_lock);
 +static DEFINE_MUTEX(acpi_probe_mutex);
  
  static int __init acpi_match_madt(struct acpi_subtable_header *header,
                                  const unsigned long end)
@@@ -2075,7 -2073,7 +2075,7 @@@ int __init __acpi_probe_device_table(st
        if (acpi_disabled)
                return 0;
  
 -      spin_lock(&acpi_probe_lock);
 +      mutex_lock(&acpi_probe_mutex);
        for (ape = ap_head; nr; ape++, nr--) {
                if (ACPI_COMPARE_NAME(ACPI_SIG_MADT, ape->id)) {
                        acpi_probe_count = 0;
                                count++;
                }
        }
 -      spin_unlock(&acpi_probe_lock);
 +      mutex_unlock(&acpi_probe_mutex);
  
        return count;
  }
diff --combined include/linux/acpi.h
index 689a8b9b9c8fdc985401bf253dfe55ab80aa833f,c09936f55166fafee92a76b81a5ee20c633c5066..61a3d90f32b338a030c3a064b50c403a48464293
@@@ -85,8 -85,6 +85,8 @@@ static inline const char *acpi_dev_name
        return dev_name(&adev->dev);
  }
  
 +struct device *acpi_get_first_physical_node(struct acpi_device *adev);
 +
  enum acpi_irq_model_id {
        ACPI_IRQ_MODEL_PIC = 0,
        ACPI_IRQ_MODEL_IOAPIC,
@@@ -269,18 -267,12 +269,18 @@@ static inline bool invalid_phys_cpuid(p
        return phys_id == PHYS_CPUID_INVALID;
  }
  
 +/* Validate the processor object's proc_id */
 +bool acpi_processor_validate_proc_id(int proc_id);
 +
  #ifdef CONFIG_ACPI_HOTPLUG_CPU
  /* Arch dependent functions for cpu hotplug support */
  int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu);
  int acpi_unmap_cpu(int cpu);
 +int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid);
  #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  
 +void acpi_set_processor_mapping(void);
 +
  #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
  int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
  #endif
@@@ -326,7 -318,6 +326,7 @@@ struct pci_dev
  int acpi_pci_irq_enable (struct pci_dev *dev);
  void acpi_penalize_isa_irq(int irq, int active);
  bool acpi_isa_irq_available(int irq);
 +void acpi_penalize_sci_irq(int irq, int trigger, int polarity);
  void acpi_pci_irq_disable (struct pci_dev *dev);
  
  extern int ec_read(u8 addr, u8 *val);
@@@ -555,7 -546,8 +555,8 @@@ int acpi_device_uevent_modalias(struct 
  int acpi_device_modalias(struct device *, char *, int);
  void acpi_walk_dep_device_list(acpi_handle handle);
  
- struct platform_device *acpi_create_platform_device(struct acpi_device *);
+ struct platform_device *acpi_create_platform_device(struct acpi_device *,
+                                                   struct property_entry *);
  #define ACPI_PTR(_ptr)        (_ptr)
  
  static inline void acpi_device_set_enumerated(struct acpi_device *adev)
@@@ -643,11 -635,6 +644,11 @@@ static inline const char *acpi_dev_name
        return NULL;
  }
  
 +static inline struct device *acpi_get_first_physical_node(struct acpi_device *adev)
 +{
 +      return NULL;
 +}
 +
  static inline void acpi_early_init(void) { }
  static inline void acpi_subsystem_init(void) { }
  
@@@ -765,12 -752,6 +766,12 @@@ static inline int acpi_reconfig_notifie
  
  #endif        /* !CONFIG_ACPI */
  
 +#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
 +int acpi_ioapic_add(acpi_handle root);
 +#else
 +static inline int acpi_ioapic_add(acpi_handle root) { return 0; }
 +#endif
 +
  #ifdef CONFIG_ACPI
  void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
                               u32 pm1a_ctrl,  u32 pm1b_ctrl));
@@@ -1092,7 -1073,7 +1093,7 @@@ static inline struct fwnode_handle *acp
        return NULL;
  }
  
 -#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, validate, data, fn) \
 +#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \
        static const void * __acpi_table_##name[]                       \
                __attribute__((unused))                                 \
                 = { (void *) table_id,                                 \
@@@ -1110,16 -1091,4 +1111,16 @@@ void acpi_table_upgrade(void)
  static inline void acpi_table_upgrade(void) { }
  #endif
  
 +#if defined(CONFIG_ACPI) && defined(CONFIG_ACPI_WATCHDOG)
 +extern bool acpi_has_watchdog(void);
 +#else
 +static inline bool acpi_has_watchdog(void) { return false; }
 +#endif
 +
 +#ifdef CONFIG_ACPI_SPCR_TABLE
 +int parse_spcr(bool earlycon);
 +#else
 +static inline int parse_spcr(bool earlycon) { return 0; }
 +#endif
 +
  #endif        /*_LINUX_ACPI_H*/