intel-pinctrl for v6.7-1

* Merge "Drop runtime PM support for Baytrail and Lynxpoint pinctrl" (Raag)
 * Small improvements here and there in the Intel pin control drivers (Raag)
 * Switch to RAII for locking in the Intel core and Cherry View drivers
 * Enable non-ACPI enumeration in the Intel Denverton driver
 * Use MODULE_DEVICE_TABLE() instead of MODULE_ALIAS() in a couple of drivers
 * Introduce array_size.h and use in in the Intel pin control drivers
 
 The following is an automated git shortlog grouped by driver:
 
 baytrail:
  -  Replace kernel.h by what is actually being used
  -  drop runtime PM support
  -  fix debounce disable case
 
 broxton:
  -  Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE()
 
 cherryview:
  -  reduce scope of PIN_CONFIG_BIAS_HIGH_IMPEDANCE case
  -  Convert to platform remove callback returning void
  -  Simplify code with cleanup helpers
  -  Avoid duplicated I/O
  -  Replace kernel.h by what is actually being used
 
 denverton:
  -  Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE()
  -  Enable platform device in the absence of ACPI enumeration
 
 intel:
  -  fetch community only when we need it
  -  refine intel_config_set_pull() function
  -  Replace kernel.h by what is actually being used
  -  Simplify code with cleanup helpers
 
 lynxpoint:
  -  Replace kernel.h by what is actually being used
  -  drop runtime PM support
 
 merrifield:
  -  Replace kernel.h by what is actually being used
 
 moorefield:
  -  Replace kernel.h by what is actually being used
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEqaflIX74DDDzMJJtb7wzTHR8rCgFAmUtPmkACgkQb7wzTHR8
 rCjQ2Q/+MdyxO1vlv2ZN6xpY25lpzELfRs6S2EHcrnRMoONjH6t1k6yh2Xmnlmte
 byMFggOSDoyZAmqzmQioWo6e8tO9zme17mAhNOnmNpZ4luyPOhgCp0SF61UpOrl/
 r2MBJyhFfCyI/7aXQ8p0+tVX988CgezYWEhfeXP2Xt10o90eK+fbks8bBW5a3gZ5
 Gpx3L3EXkBBIpW4ec1ji4vXNKiKVvePZZWIb612KZ3ttfk7jGqaC3kJXFFGGWO2z
 eKxuuDo5oNbYocS+/jNxSCBBoqKw50r507sqireQ/cV3H22wOK/OmejKJzSPszqB
 tQnvafqx8EaNLajhDW9EG1nzexeYbT6jHaNg/b2y0rSPWNSwi5zXgL2lEaPo+c5N
 Pv9Ys6dp+ftfM/zO8fjKWOYyjo0zqTRAB/yxTwfw+hXUvMQuzbHOaoMnVpmj+7he
 GqRbjyM5thWYFTFIz7Hearq12a9csvJPNKWz4ClPey4/AEkMyR0csvIgkmh8GZu+
 ORPwKmGIqQWC1JkJKMsmLx4j92JPN0xaIf6ILTMwgnzYihhPeCfIFMv1VbXZCaZA
 SfdbwK2f4cGMUS2s16Zf3Dl79jSrJ140igmCvsz8HDBZrz2C6Bey0qnWF4tQEy1Q
 NVGpyYpDTNtLZxelDZfB6bezyYoX7TLlCoTUvcYxbMIF7ax4QYI=
 =o8D/
 -----END PGP SIGNATURE-----

Merge tag 'intel-pinctrl-v6.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pinctrl/intel into devel

intel-pinctrl for v6.7-1

* Merge "Drop runtime PM support for Baytrail and Lynxpoint pinctrl" (Raag)
* Small improvements here and there in the Intel pin control drivers (Raag)
* Switch to RAII for locking in the Intel core and Cherry View drivers
* Enable non-ACPI enumeration in the Intel Denverton driver
* Use MODULE_DEVICE_TABLE() instead of MODULE_ALIAS() in a couple of drivers
* Introduce array_size.h and use in in the Intel pin control drivers

The following is an automated git shortlog grouped by driver:

baytrail:
 -  Replace kernel.h by what is actually being used
 -  drop runtime PM support
 -  fix debounce disable case

broxton:
 -  Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE()

cherryview:
 -  reduce scope of PIN_CONFIG_BIAS_HIGH_IMPEDANCE case
 -  Convert to platform remove callback returning void
 -  Simplify code with cleanup helpers
 -  Avoid duplicated I/O
 -  Replace kernel.h by what is actually being used

denverton:
 -  Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE()
 -  Enable platform device in the absence of ACPI enumeration

intel:
 -  fetch community only when we need it
 -  refine intel_config_set_pull() function
 -  Replace kernel.h by what is actually being used
 -  Simplify code with cleanup helpers

lynxpoint:
 -  Replace kernel.h by what is actually being used
 -  drop runtime PM support

merrifield:
 -  Replace kernel.h by what is actually being used

moorefield:
 -  Replace kernel.h by what is actually being used
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Linus Walleij 2023-10-16 22:00:13 +02:00
commit 593bcf6889
18 changed files with 208 additions and 296 deletions

View File

@ -12,12 +12,12 @@
*/ */
#define pr_fmt(fmt) "pinctrl core: " fmt #define pr_fmt(fmt) "pinctrl core: " fmt
#include <linux/array_size.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h>
#include <linux/kref.h> #include <linux/kref.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>

View File

@ -7,16 +7,16 @@
*/ */
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/array_size.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/gpio/driver.h> #include <linux/gpio/driver.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm.h>
#include <linux/property.h> #include <linux/property.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/string_helpers.h> #include <linux/string_helpers.h>
@ -722,8 +722,6 @@ static int byt_gpio_request_enable(struct pinctrl_dev *pctl_dev,
raw_spin_unlock_irqrestore(&byt_lock, flags); raw_spin_unlock_irqrestore(&byt_lock, flags);
pm_runtime_get(vg->dev);
return 0; return 0;
} }
@ -734,7 +732,6 @@ static void byt_gpio_disable_free(struct pinctrl_dev *pctl_dev,
struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctl_dev); struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctl_dev);
byt_gpio_clear_triggering(vg, offset); byt_gpio_clear_triggering(vg, offset);
pm_runtime_put(vg->dev);
} }
static void byt_gpio_direct_irq_check(struct intel_pinctrl *vg, static void byt_gpio_direct_irq_check(struct intel_pinctrl *vg,
@ -983,11 +980,18 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev,
break; break;
case PIN_CONFIG_INPUT_DEBOUNCE: case PIN_CONFIG_INPUT_DEBOUNCE:
if (arg) if (arg) {
conf |= BYT_DEBOUNCE_EN; conf |= BYT_DEBOUNCE_EN;
else } else {
conf &= ~BYT_DEBOUNCE_EN; conf &= ~BYT_DEBOUNCE_EN;
/*
* No need to update the pulse value.
* Debounce is going to be disabled.
*/
break;
}
switch (arg) { switch (arg) {
case 375: case 375:
db_pulse = BYT_DEBOUNCE_PULSE_375US; db_pulse = BYT_DEBOUNCE_PULSE_375US;
@ -1654,7 +1658,6 @@ static int byt_pinctrl_probe(struct platform_device *pdev)
return ret; return ret;
platform_set_drvdata(pdev, vg); platform_set_drvdata(pdev, vg);
pm_runtime_enable(dev);
return 0; return 0;
} }
@ -1743,26 +1746,15 @@ static int byt_gpio_resume(struct device *dev)
return 0; return 0;
} }
static int byt_gpio_runtime_suspend(struct device *dev)
{
return 0;
}
static int byt_gpio_runtime_resume(struct device *dev)
{
return 0;
}
static const struct dev_pm_ops byt_gpio_pm_ops = { static const struct dev_pm_ops byt_gpio_pm_ops = {
LATE_SYSTEM_SLEEP_PM_OPS(byt_gpio_suspend, byt_gpio_resume) LATE_SYSTEM_SLEEP_PM_OPS(byt_gpio_suspend, byt_gpio_resume)
RUNTIME_PM_OPS(byt_gpio_runtime_suspend, byt_gpio_runtime_resume, NULL)
}; };
static struct platform_driver byt_gpio_driver = { static struct platform_driver byt_gpio_driver = {
.probe = byt_pinctrl_probe, .probe = byt_pinctrl_probe,
.driver = { .driver = {
.name = "byt_gpio", .name = "byt_gpio",
.pm = pm_ptr(&byt_gpio_pm_ops), .pm = pm_sleep_ptr(&byt_gpio_pm_ops),
.acpi_match_table = byt_gpio_acpi_match, .acpi_match_table = byt_gpio_acpi_match,
.suppress_bind_attrs = true, .suppress_bind_attrs = true,
}, },

View File

@ -998,6 +998,7 @@ static const struct platform_device_id bxt_pinctrl_platform_ids[] = {
{ "broxton-pinctrl", (kernel_ulong_t)bxt_pinctrl_soc_data }, { "broxton-pinctrl", (kernel_ulong_t)bxt_pinctrl_soc_data },
{ } { }
}; };
MODULE_DEVICE_TABLE(platform, bxt_pinctrl_platform_ids);
static INTEL_PINCTRL_PM_OPS(bxt_pinctrl_pm_ops); static INTEL_PINCTRL_PM_OPS(bxt_pinctrl_pm_ops);
@ -1026,6 +1027,4 @@ module_exit(bxt_pinctrl_exit);
MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>"); MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
MODULE_DESCRIPTION("Intel Broxton SoC pinctrl/GPIO driver"); MODULE_DESCRIPTION("Intel Broxton SoC pinctrl/GPIO driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:apollolake-pinctrl");
MODULE_ALIAS("platform:broxton-pinctrl");
MODULE_IMPORT_NS(PINCTRL_INTEL); MODULE_IMPORT_NS(PINCTRL_INTEL);

View File

@ -11,9 +11,10 @@
*/ */
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/array_size.h>
#include <linux/cleanup.h>
#include <linux/dmi.h> #include <linux/dmi.h>
#include <linux/gpio/driver.h> #include <linux/gpio/driver.h>
#include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
@ -612,26 +613,26 @@ static void chv_writel(struct intel_pinctrl *pctrl, unsigned int pin, unsigned i
} }
/* When Pad Cfg is locked, driver can only change GPIOTXState or GPIORXState */ /* When Pad Cfg is locked, driver can only change GPIOTXState or GPIORXState */
static bool chv_pad_is_locked(u32 ctrl1)
{
return ctrl1 & CHV_PADCTRL1_CFGLOCK;
}
static bool chv_pad_locked(struct intel_pinctrl *pctrl, unsigned int offset) static bool chv_pad_locked(struct intel_pinctrl *pctrl, unsigned int offset)
{ {
return chv_readl(pctrl, offset, CHV_PADCTRL1) & CHV_PADCTRL1_CFGLOCK; return chv_pad_is_locked(chv_readl(pctrl, offset, CHV_PADCTRL1));
} }
static void chv_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, static void chv_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
unsigned int offset) unsigned int offset)
{ {
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
unsigned long flags;
u32 ctrl0, ctrl1; u32 ctrl0, ctrl1;
bool locked;
raw_spin_lock_irqsave(&chv_lock, flags); scoped_guard(raw_spinlock_irqsave, &chv_lock) {
ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0);
ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0); ctrl1 = chv_readl(pctrl, offset, CHV_PADCTRL1);
ctrl1 = chv_readl(pctrl, offset, CHV_PADCTRL1); }
locked = chv_pad_locked(pctrl, offset);
raw_spin_unlock_irqrestore(&chv_lock, flags);
if (ctrl0 & CHV_PADCTRL0_GPIOEN) { if (ctrl0 & CHV_PADCTRL0_GPIOEN) {
seq_puts(s, "GPIO "); seq_puts(s, "GPIO ");
@ -646,7 +647,7 @@ static void chv_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
seq_printf(s, "0x%08x 0x%08x", ctrl0, ctrl1); seq_printf(s, "0x%08x 0x%08x", ctrl0, ctrl1);
if (locked) if (chv_pad_is_locked(ctrl1))
seq_puts(s, " [LOCKED]"); seq_puts(s, " [LOCKED]");
} }
@ -663,17 +664,15 @@ static int chv_pinmux_set_mux(struct pinctrl_dev *pctldev,
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
struct device *dev = pctrl->dev; struct device *dev = pctrl->dev;
const struct intel_pingroup *grp; const struct intel_pingroup *grp;
unsigned long flags;
int i; int i;
grp = &pctrl->soc->groups[group]; grp = &pctrl->soc->groups[group];
raw_spin_lock_irqsave(&chv_lock, flags); guard(raw_spinlock_irqsave)(&chv_lock);
/* Check first that the pad is not locked */ /* Check first that the pad is not locked */
for (i = 0; i < grp->grp.npins; i++) { for (i = 0; i < grp->grp.npins; i++) {
if (chv_pad_locked(pctrl, grp->grp.pins[i])) { if (chv_pad_locked(pctrl, grp->grp.pins[i])) {
raw_spin_unlock_irqrestore(&chv_lock, flags);
dev_warn(dev, "unable to set mode for locked pin %u\n", grp->grp.pins[i]); dev_warn(dev, "unable to set mode for locked pin %u\n", grp->grp.pins[i]);
return -EBUSY; return -EBUSY;
} }
@ -713,8 +712,6 @@ static int chv_pinmux_set_mux(struct pinctrl_dev *pctldev,
invert_oe ? "" : "not "); invert_oe ? "" : "not ");
} }
raw_spin_unlock_irqrestore(&chv_lock, flags);
return 0; return 0;
} }
@ -745,16 +742,14 @@ static int chv_gpio_request_enable(struct pinctrl_dev *pctldev,
unsigned int offset) unsigned int offset)
{ {
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
unsigned long flags;
u32 value; u32 value;
raw_spin_lock_irqsave(&chv_lock, flags); guard(raw_spinlock_irqsave)(&chv_lock);
if (chv_pad_locked(pctrl, offset)) { if (chv_pad_locked(pctrl, offset)) {
value = chv_readl(pctrl, offset, CHV_PADCTRL0); value = chv_readl(pctrl, offset, CHV_PADCTRL0);
if (!(value & CHV_PADCTRL0_GPIOEN)) { if (!(value & CHV_PADCTRL0_GPIOEN)) {
/* Locked so cannot enable */ /* Locked so cannot enable */
raw_spin_unlock_irqrestore(&chv_lock, flags);
return -EBUSY; return -EBUSY;
} }
} else { } else {
@ -789,8 +784,6 @@ static int chv_gpio_request_enable(struct pinctrl_dev *pctldev,
chv_writel(pctrl, offset, CHV_PADCTRL0, value); chv_writel(pctrl, offset, CHV_PADCTRL0, value);
} }
raw_spin_unlock_irqrestore(&chv_lock, flags);
return 0; return 0;
} }
@ -799,14 +792,13 @@ static void chv_gpio_disable_free(struct pinctrl_dev *pctldev,
unsigned int offset) unsigned int offset)
{ {
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
unsigned long flags;
raw_spin_lock_irqsave(&chv_lock, flags); guard(raw_spinlock_irqsave)(&chv_lock);
if (!chv_pad_locked(pctrl, offset)) if (chv_pad_locked(pctrl, offset))
chv_gpio_clear_triggering(pctrl, offset); return;
raw_spin_unlock_irqrestore(&chv_lock, flags); chv_gpio_clear_triggering(pctrl, offset);
} }
static int chv_gpio_set_direction(struct pinctrl_dev *pctldev, static int chv_gpio_set_direction(struct pinctrl_dev *pctldev,
@ -814,10 +806,9 @@ static int chv_gpio_set_direction(struct pinctrl_dev *pctldev,
unsigned int offset, bool input) unsigned int offset, bool input)
{ {
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
unsigned long flags;
u32 ctrl0; u32 ctrl0;
raw_spin_lock_irqsave(&chv_lock, flags); guard(raw_spinlock_irqsave)(&chv_lock);
ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0) & ~CHV_PADCTRL0_GPIOCFG_MASK; ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0) & ~CHV_PADCTRL0_GPIOCFG_MASK;
if (input) if (input)
@ -826,8 +817,6 @@ static int chv_gpio_set_direction(struct pinctrl_dev *pctldev,
ctrl0 |= CHV_PADCTRL0_GPIOCFG_GPO << CHV_PADCTRL0_GPIOCFG_SHIFT; ctrl0 |= CHV_PADCTRL0_GPIOCFG_GPO << CHV_PADCTRL0_GPIOCFG_SHIFT;
chv_writel(pctrl, offset, CHV_PADCTRL0, ctrl0); chv_writel(pctrl, offset, CHV_PADCTRL0, ctrl0);
raw_spin_unlock_irqrestore(&chv_lock, flags);
return 0; return 0;
} }
@ -846,15 +835,14 @@ static int chv_config_get(struct pinctrl_dev *pctldev, unsigned int pin,
{ {
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
enum pin_config_param param = pinconf_to_config_param(*config); enum pin_config_param param = pinconf_to_config_param(*config);
unsigned long flags;
u32 ctrl0, ctrl1; u32 ctrl0, ctrl1;
u16 arg = 0; u16 arg = 0;
u32 term; u32 term;
raw_spin_lock_irqsave(&chv_lock, flags); scoped_guard(raw_spinlock_irqsave, &chv_lock) {
ctrl0 = chv_readl(pctrl, pin, CHV_PADCTRL0); ctrl0 = chv_readl(pctrl, pin, CHV_PADCTRL0);
ctrl1 = chv_readl(pctrl, pin, CHV_PADCTRL1); ctrl1 = chv_readl(pctrl, pin, CHV_PADCTRL1);
raw_spin_unlock_irqrestore(&chv_lock, flags); }
term = (ctrl0 & CHV_PADCTRL0_TERM_MASK) >> CHV_PADCTRL0_TERM_SHIFT; term = (ctrl0 & CHV_PADCTRL0_TERM_MASK) >> CHV_PADCTRL0_TERM_SHIFT;
@ -906,6 +894,7 @@ static int chv_config_get(struct pinctrl_dev *pctldev, unsigned int pin,
return -EINVAL; return -EINVAL;
break; break;
}
case PIN_CONFIG_DRIVE_PUSH_PULL: case PIN_CONFIG_DRIVE_PUSH_PULL:
if (ctrl1 & CHV_PADCTRL1_ODEN) if (ctrl1 & CHV_PADCTRL1_ODEN)
@ -916,7 +905,6 @@ static int chv_config_get(struct pinctrl_dev *pctldev, unsigned int pin,
if (!(ctrl1 & CHV_PADCTRL1_ODEN)) if (!(ctrl1 & CHV_PADCTRL1_ODEN))
return -EINVAL; return -EINVAL;
break; break;
}
default: default:
return -ENOTSUPP; return -ENOTSUPP;
@ -929,10 +917,10 @@ static int chv_config_get(struct pinctrl_dev *pctldev, unsigned int pin,
static int chv_config_set_pull(struct intel_pinctrl *pctrl, unsigned int pin, static int chv_config_set_pull(struct intel_pinctrl *pctrl, unsigned int pin,
enum pin_config_param param, u32 arg) enum pin_config_param param, u32 arg)
{ {
unsigned long flags;
u32 ctrl0, pull; u32 ctrl0, pull;
raw_spin_lock_irqsave(&chv_lock, flags); guard(raw_spinlock_irqsave)(&chv_lock);
ctrl0 = chv_readl(pctrl, pin, CHV_PADCTRL0); ctrl0 = chv_readl(pctrl, pin, CHV_PADCTRL0);
switch (param) { switch (param) {
@ -955,7 +943,6 @@ static int chv_config_set_pull(struct intel_pinctrl *pctrl, unsigned int pin,
pull = CHV_PADCTRL0_TERM_20K << CHV_PADCTRL0_TERM_SHIFT; pull = CHV_PADCTRL0_TERM_20K << CHV_PADCTRL0_TERM_SHIFT;
break; break;
default: default:
raw_spin_unlock_irqrestore(&chv_lock, flags);
return -EINVAL; return -EINVAL;
} }
@ -973,7 +960,6 @@ static int chv_config_set_pull(struct intel_pinctrl *pctrl, unsigned int pin,
pull = CHV_PADCTRL0_TERM_20K << CHV_PADCTRL0_TERM_SHIFT; pull = CHV_PADCTRL0_TERM_20K << CHV_PADCTRL0_TERM_SHIFT;
break; break;
default: default:
raw_spin_unlock_irqrestore(&chv_lock, flags);
return -EINVAL; return -EINVAL;
} }
@ -981,12 +967,10 @@ static int chv_config_set_pull(struct intel_pinctrl *pctrl, unsigned int pin,
break; break;
default: default:
raw_spin_unlock_irqrestore(&chv_lock, flags);
return -EINVAL; return -EINVAL;
} }
chv_writel(pctrl, pin, CHV_PADCTRL0, ctrl0); chv_writel(pctrl, pin, CHV_PADCTRL0, ctrl0);
raw_spin_unlock_irqrestore(&chv_lock, flags);
return 0; return 0;
} }
@ -994,10 +978,10 @@ static int chv_config_set_pull(struct intel_pinctrl *pctrl, unsigned int pin,
static int chv_config_set_oden(struct intel_pinctrl *pctrl, unsigned int pin, static int chv_config_set_oden(struct intel_pinctrl *pctrl, unsigned int pin,
bool enable) bool enable)
{ {
unsigned long flags;
u32 ctrl1; u32 ctrl1;
raw_spin_lock_irqsave(&chv_lock, flags); guard(raw_spinlock_irqsave)(&chv_lock);
ctrl1 = chv_readl(pctrl, pin, CHV_PADCTRL1); ctrl1 = chv_readl(pctrl, pin, CHV_PADCTRL1);
if (enable) if (enable)
@ -1006,7 +990,6 @@ static int chv_config_set_oden(struct intel_pinctrl *pctrl, unsigned int pin,
ctrl1 &= ~CHV_PADCTRL1_ODEN; ctrl1 &= ~CHV_PADCTRL1_ODEN;
chv_writel(pctrl, pin, CHV_PADCTRL1, ctrl1); chv_writel(pctrl, pin, CHV_PADCTRL1, ctrl1);
raw_spin_unlock_irqrestore(&chv_lock, flags);
return 0; return 0;
} }
@ -1116,12 +1099,10 @@ static struct pinctrl_desc chv_pinctrl_desc = {
static int chv_gpio_get(struct gpio_chip *chip, unsigned int offset) static int chv_gpio_get(struct gpio_chip *chip, unsigned int offset)
{ {
struct intel_pinctrl *pctrl = gpiochip_get_data(chip); struct intel_pinctrl *pctrl = gpiochip_get_data(chip);
unsigned long flags;
u32 ctrl0, cfg; u32 ctrl0, cfg;
raw_spin_lock_irqsave(&chv_lock, flags); scoped_guard(raw_spinlock_irqsave, &chv_lock)
ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0); ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0);
raw_spin_unlock_irqrestore(&chv_lock, flags);
cfg = ctrl0 & CHV_PADCTRL0_GPIOCFG_MASK; cfg = ctrl0 & CHV_PADCTRL0_GPIOCFG_MASK;
cfg >>= CHV_PADCTRL0_GPIOCFG_SHIFT; cfg >>= CHV_PADCTRL0_GPIOCFG_SHIFT;
@ -1134,10 +1115,9 @@ static int chv_gpio_get(struct gpio_chip *chip, unsigned int offset)
static void chv_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) static void chv_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
{ {
struct intel_pinctrl *pctrl = gpiochip_get_data(chip); struct intel_pinctrl *pctrl = gpiochip_get_data(chip);
unsigned long flags;
u32 ctrl0; u32 ctrl0;
raw_spin_lock_irqsave(&chv_lock, flags); guard(raw_spinlock_irqsave)(&chv_lock);
ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0); ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0);
@ -1147,19 +1127,15 @@ static void chv_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
ctrl0 &= ~CHV_PADCTRL0_GPIOTXSTATE; ctrl0 &= ~CHV_PADCTRL0_GPIOTXSTATE;
chv_writel(pctrl, offset, CHV_PADCTRL0, ctrl0); chv_writel(pctrl, offset, CHV_PADCTRL0, ctrl0);
raw_spin_unlock_irqrestore(&chv_lock, flags);
} }
static int chv_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) static int chv_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
{ {
struct intel_pinctrl *pctrl = gpiochip_get_data(chip); struct intel_pinctrl *pctrl = gpiochip_get_data(chip);
u32 ctrl0, direction; u32 ctrl0, direction;
unsigned long flags;
raw_spin_lock_irqsave(&chv_lock, flags); scoped_guard(raw_spinlock_irqsave, &chv_lock)
ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0); ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0);
raw_spin_unlock_irqrestore(&chv_lock, flags);
direction = ctrl0 & CHV_PADCTRL0_GPIOCFG_MASK; direction = ctrl0 & CHV_PADCTRL0_GPIOCFG_MASK;
direction >>= CHV_PADCTRL0_GPIOCFG_SHIFT; direction >>= CHV_PADCTRL0_GPIOCFG_SHIFT;
@ -1200,23 +1176,20 @@ static void chv_gpio_irq_ack(struct irq_data *d)
irq_hw_number_t hwirq = irqd_to_hwirq(d); irq_hw_number_t hwirq = irqd_to_hwirq(d);
u32 intr_line; u32 intr_line;
raw_spin_lock(&chv_lock); guard(raw_spinlock)(&chv_lock);
intr_line = chv_readl(pctrl, hwirq, CHV_PADCTRL0); intr_line = chv_readl(pctrl, hwirq, CHV_PADCTRL0);
intr_line &= CHV_PADCTRL0_INTSEL_MASK; intr_line &= CHV_PADCTRL0_INTSEL_MASK;
intr_line >>= CHV_PADCTRL0_INTSEL_SHIFT; intr_line >>= CHV_PADCTRL0_INTSEL_SHIFT;
chv_pctrl_writel(pctrl, CHV_INTSTAT, BIT(intr_line)); chv_pctrl_writel(pctrl, CHV_INTSTAT, BIT(intr_line));
raw_spin_unlock(&chv_lock);
} }
static void chv_gpio_irq_mask_unmask(struct gpio_chip *gc, irq_hw_number_t hwirq, bool mask) static void chv_gpio_irq_mask_unmask(struct gpio_chip *gc, irq_hw_number_t hwirq, bool mask)
{ {
struct intel_pinctrl *pctrl = gpiochip_get_data(gc); struct intel_pinctrl *pctrl = gpiochip_get_data(gc);
u32 value, intr_line; u32 value, intr_line;
unsigned long flags;
raw_spin_lock_irqsave(&chv_lock, flags); guard(raw_spinlock_irqsave)(&chv_lock);
intr_line = chv_readl(pctrl, hwirq, CHV_PADCTRL0); intr_line = chv_readl(pctrl, hwirq, CHV_PADCTRL0);
intr_line &= CHV_PADCTRL0_INTSEL_MASK; intr_line &= CHV_PADCTRL0_INTSEL_MASK;
@ -1228,8 +1201,6 @@ static void chv_gpio_irq_mask_unmask(struct gpio_chip *gc, irq_hw_number_t hwirq
else else
value |= BIT(intr_line); value |= BIT(intr_line);
chv_pctrl_writel(pctrl, CHV_INTMASK, value); chv_pctrl_writel(pctrl, CHV_INTMASK, value);
raw_spin_unlock_irqrestore(&chv_lock, flags);
} }
static void chv_gpio_irq_mask(struct irq_data *d) static void chv_gpio_irq_mask(struct irq_data *d)
@ -1254,7 +1225,15 @@ static unsigned chv_gpio_irq_startup(struct irq_data *d)
{ {
/* /*
* Check if the interrupt has been requested with 0 as triggering * Check if the interrupt has been requested with 0 as triggering
* type. In that case it is assumed that the current values * type. If not, bail out, ...
*/
if (irqd_get_trigger_type(d) != IRQ_TYPE_NONE) {
chv_gpio_irq_unmask(d);
return 0;
}
/*
* ...otherwise it is assumed that the current values
* programmed to the hardware are used (e.g BIOS configured * programmed to the hardware are used (e.g BIOS configured
* defaults). * defaults).
* *
@ -1262,17 +1241,15 @@ static unsigned chv_gpio_irq_startup(struct irq_data *d)
* read back the values from hardware now, set correct flow handler * read back the values from hardware now, set correct flow handler
* and update mappings before the interrupt is being used. * and update mappings before the interrupt is being used.
*/ */
if (irqd_get_trigger_type(d) == IRQ_TYPE_NONE) { scoped_guard(raw_spinlock_irqsave, &chv_lock) {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct intel_pinctrl *pctrl = gpiochip_get_data(gc); struct intel_pinctrl *pctrl = gpiochip_get_data(gc);
struct device *dev = pctrl->dev; struct device *dev = pctrl->dev;
struct intel_community_context *cctx = &pctrl->context.communities[0]; struct intel_community_context *cctx = &pctrl->context.communities[0];
irq_hw_number_t hwirq = irqd_to_hwirq(d); irq_hw_number_t hwirq = irqd_to_hwirq(d);
irq_flow_handler_t handler; irq_flow_handler_t handler;
unsigned long flags;
u32 intsel, value; u32 intsel, value;
raw_spin_lock_irqsave(&chv_lock, flags);
intsel = chv_readl(pctrl, hwirq, CHV_PADCTRL0); intsel = chv_readl(pctrl, hwirq, CHV_PADCTRL0);
intsel &= CHV_PADCTRL0_INTSEL_MASK; intsel &= CHV_PADCTRL0_INTSEL_MASK;
intsel >>= CHV_PADCTRL0_INTSEL_SHIFT; intsel >>= CHV_PADCTRL0_INTSEL_SHIFT;
@ -1289,7 +1266,6 @@ static unsigned chv_gpio_irq_startup(struct irq_data *d)
intsel, hwirq); intsel, hwirq);
cctx->intr_lines[intsel] = hwirq; cctx->intr_lines[intsel] = hwirq;
} }
raw_spin_unlock_irqrestore(&chv_lock, flags);
} }
chv_gpio_irq_unmask(d); chv_gpio_irq_unmask(d);
@ -1354,17 +1330,14 @@ static int chv_gpio_irq_type(struct irq_data *d, unsigned int type)
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct intel_pinctrl *pctrl = gpiochip_get_data(gc); struct intel_pinctrl *pctrl = gpiochip_get_data(gc);
irq_hw_number_t hwirq = irqd_to_hwirq(d); irq_hw_number_t hwirq = irqd_to_hwirq(d);
unsigned long flags;
u32 value; u32 value;
int ret; int ret;
raw_spin_lock_irqsave(&chv_lock, flags); guard(raw_spinlock_irqsave)(&chv_lock);
ret = chv_gpio_set_intr_line(pctrl, hwirq); ret = chv_gpio_set_intr_line(pctrl, hwirq);
if (ret) { if (ret)
raw_spin_unlock_irqrestore(&chv_lock, flags);
return ret; return ret;
}
/* /*
* Pins which can be used as shared interrupt are configured in * Pins which can be used as shared interrupt are configured in
@ -1405,8 +1378,6 @@ static int chv_gpio_irq_type(struct irq_data *d, unsigned int type)
else if (type & IRQ_TYPE_LEVEL_MASK) else if (type & IRQ_TYPE_LEVEL_MASK)
irq_set_handler_locked(d, handle_level_irq); irq_set_handler_locked(d, handle_level_irq);
raw_spin_unlock_irqrestore(&chv_lock, flags);
return 0; return 0;
} }
@ -1430,14 +1401,12 @@ static void chv_gpio_irq_handler(struct irq_desc *desc)
struct intel_community_context *cctx = &pctrl->context.communities[0]; struct intel_community_context *cctx = &pctrl->context.communities[0];
struct irq_chip *chip = irq_desc_get_chip(desc); struct irq_chip *chip = irq_desc_get_chip(desc);
unsigned long pending; unsigned long pending;
unsigned long flags;
u32 intr_line; u32 intr_line;
chained_irq_enter(chip, desc); chained_irq_enter(chip, desc);
raw_spin_lock_irqsave(&chv_lock, flags); scoped_guard(raw_spinlock_irqsave, &chv_lock)
pending = chv_pctrl_readl(pctrl, CHV_INTSTAT); pending = chv_pctrl_readl(pctrl, CHV_INTSTAT);
raw_spin_unlock_irqrestore(&chv_lock, flags);
for_each_set_bit(intr_line, &pending, community->nirqs) { for_each_set_bit(intr_line, &pending, community->nirqs) {
unsigned int offset; unsigned int offset;
@ -1626,21 +1595,17 @@ static acpi_status chv_pinctrl_mmio_access_handler(u32 function,
void *handler_context, void *region_context) void *handler_context, void *region_context)
{ {
struct intel_pinctrl *pctrl = region_context; struct intel_pinctrl *pctrl = region_context;
unsigned long flags;
acpi_status ret = AE_OK;
raw_spin_lock_irqsave(&chv_lock, flags); guard(raw_spinlock_irqsave)(&chv_lock);
if (function == ACPI_WRITE) if (function == ACPI_WRITE)
chv_pctrl_writel(pctrl, address, *value); chv_pctrl_writel(pctrl, address, *value);
else if (function == ACPI_READ) else if (function == ACPI_READ)
*value = chv_pctrl_readl(pctrl, address); *value = chv_pctrl_readl(pctrl, address);
else else
ret = AE_BAD_PARAMETER; return AE_BAD_PARAMETER;
raw_spin_unlock_irqrestore(&chv_lock, flags); return AE_OK;
return ret;
} }
static int chv_pinctrl_probe(struct platform_device *pdev) static int chv_pinctrl_probe(struct platform_device *pdev)
@ -1728,7 +1693,7 @@ static int chv_pinctrl_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int chv_pinctrl_remove(struct platform_device *pdev) static void chv_pinctrl_remove(struct platform_device *pdev)
{ {
struct intel_pinctrl *pctrl = platform_get_drvdata(pdev); struct intel_pinctrl *pctrl = platform_get_drvdata(pdev);
const struct intel_community *community = &pctrl->communities[0]; const struct intel_community *community = &pctrl->communities[0];
@ -1736,18 +1701,15 @@ static int chv_pinctrl_remove(struct platform_device *pdev)
acpi_remove_address_space_handler(ACPI_HANDLE(&pdev->dev), acpi_remove_address_space_handler(ACPI_HANDLE(&pdev->dev),
community->acpi_space_id, community->acpi_space_id,
chv_pinctrl_mmio_access_handler); chv_pinctrl_mmio_access_handler);
return 0;
} }
static int chv_pinctrl_suspend_noirq(struct device *dev) static int chv_pinctrl_suspend_noirq(struct device *dev)
{ {
struct intel_pinctrl *pctrl = dev_get_drvdata(dev); struct intel_pinctrl *pctrl = dev_get_drvdata(dev);
struct intel_community_context *cctx = &pctrl->context.communities[0]; struct intel_community_context *cctx = &pctrl->context.communities[0];
unsigned long flags;
int i; int i;
raw_spin_lock_irqsave(&chv_lock, flags); guard(raw_spinlock_irqsave)(&chv_lock);
cctx->saved_intmask = chv_pctrl_readl(pctrl, CHV_INTMASK); cctx->saved_intmask = chv_pctrl_readl(pctrl, CHV_INTMASK);
@ -1765,8 +1727,6 @@ static int chv_pinctrl_suspend_noirq(struct device *dev)
ctx->padctrl1 = chv_readl(pctrl, desc->number, CHV_PADCTRL1); ctx->padctrl1 = chv_readl(pctrl, desc->number, CHV_PADCTRL1);
} }
raw_spin_unlock_irqrestore(&chv_lock, flags);
return 0; return 0;
} }
@ -1774,10 +1734,9 @@ static int chv_pinctrl_resume_noirq(struct device *dev)
{ {
struct intel_pinctrl *pctrl = dev_get_drvdata(dev); struct intel_pinctrl *pctrl = dev_get_drvdata(dev);
struct intel_community_context *cctx = &pctrl->context.communities[0]; struct intel_community_context *cctx = &pctrl->context.communities[0];
unsigned long flags;
int i; int i;
raw_spin_lock_irqsave(&chv_lock, flags); guard(raw_spinlock_irqsave)(&chv_lock);
/* /*
* Mask all interrupts before restoring per-pin configuration * Mask all interrupts before restoring per-pin configuration
@ -1819,8 +1778,6 @@ static int chv_pinctrl_resume_noirq(struct device *dev)
chv_pctrl_writel(pctrl, CHV_INTSTAT, 0xffff); chv_pctrl_writel(pctrl, CHV_INTSTAT, 0xffff);
chv_pctrl_writel(pctrl, CHV_INTMASK, cctx->saved_intmask); chv_pctrl_writel(pctrl, CHV_INTMASK, cctx->saved_intmask);
raw_spin_unlock_irqrestore(&chv_lock, flags);
return 0; return 0;
} }
@ -1835,7 +1792,7 @@ MODULE_DEVICE_TABLE(acpi, chv_pinctrl_acpi_match);
static struct platform_driver chv_pinctrl_driver = { static struct platform_driver chv_pinctrl_driver = {
.probe = chv_pinctrl_probe, .probe = chv_pinctrl_probe,
.remove = chv_pinctrl_remove, .remove_new = chv_pinctrl_remove,
.driver = { .driver = {
.name = "cherryview-pinctrl", .name = "cherryview-pinctrl",
.pm = pm_sleep_ptr(&chv_pinctrl_pm_ops), .pm = pm_sleep_ptr(&chv_pinctrl_pm_ops),

View File

@ -257,6 +257,12 @@ static const struct acpi_device_id dnv_pinctrl_acpi_match[] = {
}; };
MODULE_DEVICE_TABLE(acpi, dnv_pinctrl_acpi_match); MODULE_DEVICE_TABLE(acpi, dnv_pinctrl_acpi_match);
static const struct platform_device_id dnv_pinctrl_platform_ids[] = {
{ "denverton-pinctrl", (kernel_ulong_t)&dnv_soc_data },
{ }
};
MODULE_DEVICE_TABLE(platform, dnv_pinctrl_platform_ids);
static struct platform_driver dnv_pinctrl_driver = { static struct platform_driver dnv_pinctrl_driver = {
.probe = intel_pinctrl_probe_by_hid, .probe = intel_pinctrl_probe_by_hid,
.driver = { .driver = {
@ -264,6 +270,7 @@ static struct platform_driver dnv_pinctrl_driver = {
.acpi_match_table = dnv_pinctrl_acpi_match, .acpi_match_table = dnv_pinctrl_acpi_match,
.pm = &dnv_pinctrl_pm_ops, .pm = &dnv_pinctrl_pm_ops,
}, },
.id_table = dnv_pinctrl_platform_ids,
}; };
static int __init dnv_pinctrl_init(void) static int __init dnv_pinctrl_init(void)

View File

@ -8,6 +8,7 @@
*/ */
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/cleanup.h>
#include <linux/gpio/driver.h> #include <linux/gpio/driver.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/log2.h> #include <linux/log2.h>
@ -393,20 +394,17 @@ static int intel_pinmux_set_mux(struct pinctrl_dev *pctldev,
{ {
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
const struct intel_pingroup *grp = &pctrl->soc->groups[group]; const struct intel_pingroup *grp = &pctrl->soc->groups[group];
unsigned long flags;
int i; int i;
raw_spin_lock_irqsave(&pctrl->lock, flags); guard(raw_spinlock_irqsave)(&pctrl->lock);
/* /*
* All pins in the groups needs to be accessible and writable * All pins in the groups needs to be accessible and writable
* before we can enable the mux for this group. * before we can enable the mux for this group.
*/ */
for (i = 0; i < grp->grp.npins; i++) { for (i = 0; i < grp->grp.npins; i++) {
if (!intel_pad_usable(pctrl, grp->grp.pins[i])) { if (!intel_pad_usable(pctrl, grp->grp.pins[i]))
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
return -EBUSY; return -EBUSY;
}
} }
/* Now enable the mux setting for each pin in the group */ /* Now enable the mux setting for each pin in the group */
@ -428,8 +426,6 @@ static int intel_pinmux_set_mux(struct pinctrl_dev *pctldev,
writel(value, padcfg0); writel(value, padcfg0);
} }
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
return 0; return 0;
} }
@ -485,21 +481,16 @@ static int intel_gpio_request_enable(struct pinctrl_dev *pctldev,
{ {
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
void __iomem *padcfg0; void __iomem *padcfg0;
unsigned long flags;
padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0); padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0);
raw_spin_lock_irqsave(&pctrl->lock, flags); guard(raw_spinlock_irqsave)(&pctrl->lock);
if (!intel_pad_owned_by_host(pctrl, pin)) { if (!intel_pad_owned_by_host(pctrl, pin))
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
return -EBUSY; return -EBUSY;
}
if (!intel_pad_is_unlocked(pctrl, pin)) { if (!intel_pad_is_unlocked(pctrl, pin))
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
return 0; return 0;
}
/* /*
* If pin is already configured in GPIO mode, we assume that * If pin is already configured in GPIO mode, we assume that
@ -507,15 +498,11 @@ static int intel_gpio_request_enable(struct pinctrl_dev *pctldev,
* potential glitches on the pin. Otherwise, for the pin in * potential glitches on the pin. Otherwise, for the pin in
* alternative mode, consumer has to supply respective flags. * alternative mode, consumer has to supply respective flags.
*/ */
if (intel_gpio_get_gpio_mode(padcfg0) == PADCFG0_PMODE_GPIO) { if (intel_gpio_get_gpio_mode(padcfg0) == PADCFG0_PMODE_GPIO)
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
return 0; return 0;
}
intel_gpio_set_gpio_mode(padcfg0); intel_gpio_set_gpio_mode(padcfg0);
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
return 0; return 0;
} }
@ -525,13 +512,12 @@ static int intel_gpio_set_direction(struct pinctrl_dev *pctldev,
{ {
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
void __iomem *padcfg0; void __iomem *padcfg0;
unsigned long flags;
padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0); padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0);
raw_spin_lock_irqsave(&pctrl->lock, flags); guard(raw_spinlock_irqsave)(&pctrl->lock);
__intel_gpio_set_direction(padcfg0, input); __intel_gpio_set_direction(padcfg0, input);
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
return 0; return 0;
} }
@ -548,17 +534,13 @@ static const struct pinmux_ops intel_pinmux_ops = {
static int intel_config_get_pull(struct intel_pinctrl *pctrl, unsigned int pin, static int intel_config_get_pull(struct intel_pinctrl *pctrl, unsigned int pin,
enum pin_config_param param, u32 *arg) enum pin_config_param param, u32 *arg)
{ {
const struct intel_community *community;
void __iomem *padcfg1; void __iomem *padcfg1;
unsigned long flags;
u32 value, term; u32 value, term;
community = intel_get_community(pctrl, pin);
padcfg1 = intel_get_padcfg(pctrl, pin, PADCFG1); padcfg1 = intel_get_padcfg(pctrl, pin, PADCFG1);
raw_spin_lock_irqsave(&pctrl->lock, flags); scoped_guard(raw_spinlock_irqsave, &pctrl->lock)
value = readl(padcfg1); value = readl(padcfg1);
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
term = (value & PADCFG1_TERM_MASK) >> PADCFG1_TERM_SHIFT; term = (value & PADCFG1_TERM_MASK) >> PADCFG1_TERM_SHIFT;
@ -592,7 +574,9 @@ static int intel_config_get_pull(struct intel_pinctrl *pctrl, unsigned int pin,
break; break;
case PIN_CONFIG_BIAS_PULL_DOWN: case PIN_CONFIG_BIAS_PULL_DOWN: {
const struct intel_community *community = intel_get_community(pctrl, pin);
if (!term || value & PADCFG1_TERM_UP) if (!term || value & PADCFG1_TERM_UP)
return -EINVAL; return -EINVAL;
@ -619,6 +603,7 @@ static int intel_config_get_pull(struct intel_pinctrl *pctrl, unsigned int pin,
} }
break; break;
}
default: default:
return -EINVAL; return -EINVAL;
@ -631,7 +616,6 @@ static int intel_config_get_debounce(struct intel_pinctrl *pctrl, unsigned int p
enum pin_config_param param, u32 *arg) enum pin_config_param param, u32 *arg)
{ {
void __iomem *padcfg2; void __iomem *padcfg2;
unsigned long flags;
unsigned long v; unsigned long v;
u32 value2; u32 value2;
@ -639,9 +623,9 @@ static int intel_config_get_debounce(struct intel_pinctrl *pctrl, unsigned int p
if (!padcfg2) if (!padcfg2)
return -ENOTSUPP; return -ENOTSUPP;
raw_spin_lock_irqsave(&pctrl->lock, flags); scoped_guard(raw_spinlock_irqsave, &pctrl->lock)
value2 = readl(padcfg2); value2 = readl(padcfg2);
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
if (!(value2 & PADCFG2_DEBEN)) if (!(value2 & PADCFG2_DEBEN))
return -EINVAL; return -EINVAL;
@ -690,19 +674,8 @@ static int intel_config_set_pull(struct intel_pinctrl *pctrl, unsigned int pin,
{ {
unsigned int param = pinconf_to_config_param(config); unsigned int param = pinconf_to_config_param(config);
unsigned int arg = pinconf_to_config_argument(config); unsigned int arg = pinconf_to_config_argument(config);
const struct intel_community *community; u32 term = 0, up = 0, value;
void __iomem *padcfg1; void __iomem *padcfg1;
unsigned long flags;
int ret = 0;
u32 value;
community = intel_get_community(pctrl, pin);
padcfg1 = intel_get_padcfg(pctrl, pin, PADCFG1);
raw_spin_lock_irqsave(&pctrl->lock, flags);
value = readl(padcfg1);
value &= ~(PADCFG1_TERM_MASK | PADCFG1_TERM_UP);
/* Set default strength value in case none is given */ /* Set default strength value in case none is given */
if (arg == 1) if (arg == 1)
@ -715,78 +688,77 @@ static int intel_config_set_pull(struct intel_pinctrl *pctrl, unsigned int pin,
case PIN_CONFIG_BIAS_PULL_UP: case PIN_CONFIG_BIAS_PULL_UP:
switch (arg) { switch (arg) {
case 20000: case 20000:
value |= PADCFG1_TERM_20K << PADCFG1_TERM_SHIFT; term = PADCFG1_TERM_20K;
break; break;
case 5000: case 5000:
value |= PADCFG1_TERM_5K << PADCFG1_TERM_SHIFT; term = PADCFG1_TERM_5K;
break; break;
case 4000: case 4000:
value |= PADCFG1_TERM_4K << PADCFG1_TERM_SHIFT; term = PADCFG1_TERM_4K;
break; break;
case 1000: case 1000:
value |= PADCFG1_TERM_1K << PADCFG1_TERM_SHIFT; term = PADCFG1_TERM_1K;
break; break;
case 833: case 833:
value |= PADCFG1_TERM_833 << PADCFG1_TERM_SHIFT; term = PADCFG1_TERM_833;
break; break;
default: default:
ret = -EINVAL; return -EINVAL;
break;
} }
value |= PADCFG1_TERM_UP; up = PADCFG1_TERM_UP;
break; break;
case PIN_CONFIG_BIAS_PULL_DOWN: case PIN_CONFIG_BIAS_PULL_DOWN: {
const struct intel_community *community = intel_get_community(pctrl, pin);
switch (arg) { switch (arg) {
case 20000: case 20000:
value |= PADCFG1_TERM_20K << PADCFG1_TERM_SHIFT; term = PADCFG1_TERM_20K;
break; break;
case 5000: case 5000:
value |= PADCFG1_TERM_5K << PADCFG1_TERM_SHIFT; term = PADCFG1_TERM_5K;
break; break;
case 4000: case 4000:
value |= PADCFG1_TERM_4K << PADCFG1_TERM_SHIFT; term = PADCFG1_TERM_4K;
break; break;
case 1000: case 1000:
if (!(community->features & PINCTRL_FEATURE_1K_PD)) { if (!(community->features & PINCTRL_FEATURE_1K_PD))
ret = -EINVAL; return -EINVAL;
break; term = PADCFG1_TERM_1K;
}
value |= PADCFG1_TERM_1K << PADCFG1_TERM_SHIFT;
break; break;
case 833: case 833:
if (!(community->features & PINCTRL_FEATURE_1K_PD)) { if (!(community->features & PINCTRL_FEATURE_1K_PD))
ret = -EINVAL; return -EINVAL;
break; term = PADCFG1_TERM_833;
}
value |= PADCFG1_TERM_833 << PADCFG1_TERM_SHIFT;
break; break;
default: default:
ret = -EINVAL; return -EINVAL;
break;
} }
break; break;
default:
ret = -EINVAL;
break;
} }
if (!ret) default:
writel(value, padcfg1); return -EINVAL;
}
raw_spin_unlock_irqrestore(&pctrl->lock, flags); padcfg1 = intel_get_padcfg(pctrl, pin, PADCFG1);
return ret; guard(raw_spinlock_irqsave)(&pctrl->lock);
value = readl(padcfg1);
value = (value & ~PADCFG1_TERM_MASK) | (term << PADCFG1_TERM_SHIFT);
value = (value & ~PADCFG1_TERM_UP) | up;
writel(value, padcfg1);
return 0;
} }
static int intel_config_set_debounce(struct intel_pinctrl *pctrl, static int intel_config_set_debounce(struct intel_pinctrl *pctrl,
unsigned int pin, unsigned int debounce) unsigned int pin, unsigned int debounce)
{ {
void __iomem *padcfg0, *padcfg2; void __iomem *padcfg0, *padcfg2;
unsigned long flags;
u32 value0, value2; u32 value0, value2;
padcfg2 = intel_get_padcfg(pctrl, pin, PADCFG2); padcfg2 = intel_get_padcfg(pctrl, pin, PADCFG2);
@ -795,7 +767,7 @@ static int intel_config_set_debounce(struct intel_pinctrl *pctrl,
padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0); padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0);
raw_spin_lock_irqsave(&pctrl->lock, flags); guard(raw_spinlock_irqsave)(&pctrl->lock);
value0 = readl(padcfg0); value0 = readl(padcfg0);
value2 = readl(padcfg2); value2 = readl(padcfg2);
@ -808,10 +780,8 @@ static int intel_config_set_debounce(struct intel_pinctrl *pctrl,
unsigned long v; unsigned long v;
v = order_base_2(debounce * NSEC_PER_USEC / DEBOUNCE_PERIOD_NSEC); v = order_base_2(debounce * NSEC_PER_USEC / DEBOUNCE_PERIOD_NSEC);
if (v < 3 || v > 15) { if (v < 3 || v > 15)
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
return -EINVAL; return -EINVAL;
}
/* Enable glitch filter and debouncer */ /* Enable glitch filter and debouncer */
value0 |= PADCFG0_PREGFRXSEL; value0 |= PADCFG0_PREGFRXSEL;
@ -822,8 +792,6 @@ static int intel_config_set_debounce(struct intel_pinctrl *pctrl,
writel(value0, padcfg0); writel(value0, padcfg0);
writel(value2, padcfg2); writel(value2, padcfg2);
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
return 0; return 0;
} }
@ -973,7 +941,6 @@ static void intel_gpio_set(struct gpio_chip *chip, unsigned int offset,
int value) int value)
{ {
struct intel_pinctrl *pctrl = gpiochip_get_data(chip); struct intel_pinctrl *pctrl = gpiochip_get_data(chip);
unsigned long flags;
void __iomem *reg; void __iomem *reg;
u32 padcfg0; u32 padcfg0;
int pin; int pin;
@ -986,20 +953,19 @@ static void intel_gpio_set(struct gpio_chip *chip, unsigned int offset,
if (!reg) if (!reg)
return; return;
raw_spin_lock_irqsave(&pctrl->lock, flags); guard(raw_spinlock_irqsave)(&pctrl->lock);
padcfg0 = readl(reg); padcfg0 = readl(reg);
if (value) if (value)
padcfg0 |= PADCFG0_GPIOTXSTATE; padcfg0 |= PADCFG0_GPIOTXSTATE;
else else
padcfg0 &= ~PADCFG0_GPIOTXSTATE; padcfg0 &= ~PADCFG0_GPIOTXSTATE;
writel(padcfg0, reg); writel(padcfg0, reg);
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
} }
static int intel_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) static int intel_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
{ {
struct intel_pinctrl *pctrl = gpiochip_get_data(chip); struct intel_pinctrl *pctrl = gpiochip_get_data(chip);
unsigned long flags;
void __iomem *reg; void __iomem *reg;
u32 padcfg0; u32 padcfg0;
int pin; int pin;
@ -1012,9 +978,9 @@ static int intel_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
if (!reg) if (!reg)
return -EINVAL; return -EINVAL;
raw_spin_lock_irqsave(&pctrl->lock, flags); scoped_guard(raw_spinlock_irqsave, &pctrl->lock)
padcfg0 = readl(reg); padcfg0 = readl(reg);
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
if (padcfg0 & PADCFG0_PMODE_MASK) if (padcfg0 & PADCFG0_PMODE_MASK)
return -EINVAL; return -EINVAL;
@ -1058,15 +1024,17 @@ static void intel_gpio_irq_ack(struct irq_data *d)
pin = intel_gpio_to_pin(pctrl, irqd_to_hwirq(d), &community, &padgrp); pin = intel_gpio_to_pin(pctrl, irqd_to_hwirq(d), &community, &padgrp);
if (pin >= 0) { if (pin >= 0) {
unsigned int gpp, gpp_offset, is_offset; unsigned int gpp, gpp_offset;
void __iomem *is;
gpp = padgrp->reg_num; gpp = padgrp->reg_num;
gpp_offset = padgroup_offset(padgrp, pin); gpp_offset = padgroup_offset(padgrp, pin);
is_offset = community->is_offset + gpp * 4;
raw_spin_lock(&pctrl->lock); is = community->regs + community->is_offset + gpp * 4;
writel(BIT(gpp_offset), community->regs + is_offset);
raw_spin_unlock(&pctrl->lock); guard(raw_spinlock)(&pctrl->lock);
writel(BIT(gpp_offset), is);
} }
} }
@ -1080,7 +1048,6 @@ static void intel_gpio_irq_mask_unmask(struct gpio_chip *gc, irq_hw_number_t hwi
pin = intel_gpio_to_pin(pctrl, hwirq, &community, &padgrp); pin = intel_gpio_to_pin(pctrl, hwirq, &community, &padgrp);
if (pin >= 0) { if (pin >= 0) {
unsigned int gpp, gpp_offset; unsigned int gpp, gpp_offset;
unsigned long flags;
void __iomem *reg, *is; void __iomem *reg, *is;
u32 value; u32 value;
@ -1090,7 +1057,7 @@ static void intel_gpio_irq_mask_unmask(struct gpio_chip *gc, irq_hw_number_t hwi
reg = community->regs + community->ie_offset + gpp * 4; reg = community->regs + community->ie_offset + gpp * 4;
is = community->regs + community->is_offset + gpp * 4; is = community->regs + community->is_offset + gpp * 4;
raw_spin_lock_irqsave(&pctrl->lock, flags); guard(raw_spinlock_irqsave)(&pctrl->lock);
/* Clear interrupt status first to avoid unexpected interrupt */ /* Clear interrupt status first to avoid unexpected interrupt */
writel(BIT(gpp_offset), is); writel(BIT(gpp_offset), is);
@ -1101,7 +1068,6 @@ static void intel_gpio_irq_mask_unmask(struct gpio_chip *gc, irq_hw_number_t hwi
else else
value |= BIT(gpp_offset); value |= BIT(gpp_offset);
writel(value, reg); writel(value, reg);
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
} }
} }
@ -1129,7 +1095,6 @@ static int intel_gpio_irq_type(struct irq_data *d, unsigned int type)
struct intel_pinctrl *pctrl = gpiochip_get_data(gc); struct intel_pinctrl *pctrl = gpiochip_get_data(gc);
unsigned int pin = intel_gpio_to_pin(pctrl, irqd_to_hwirq(d), NULL, NULL); unsigned int pin = intel_gpio_to_pin(pctrl, irqd_to_hwirq(d), NULL, NULL);
u32 rxevcfg, rxinv, value; u32 rxevcfg, rxinv, value;
unsigned long flags;
void __iomem *reg; void __iomem *reg;
reg = intel_get_padcfg(pctrl, pin, PADCFG0); reg = intel_get_padcfg(pctrl, pin, PADCFG0);
@ -1163,7 +1128,7 @@ static int intel_gpio_irq_type(struct irq_data *d, unsigned int type)
else else
rxinv = 0; rxinv = 0;
raw_spin_lock_irqsave(&pctrl->lock, flags); guard(raw_spinlock_irqsave)(&pctrl->lock);
intel_gpio_set_gpio_mode(reg); intel_gpio_set_gpio_mode(reg);
@ -1179,8 +1144,6 @@ static int intel_gpio_irq_type(struct irq_data *d, unsigned int type)
else if (type & IRQ_TYPE_LEVEL_MASK) else if (type & IRQ_TYPE_LEVEL_MASK)
irq_set_handler_locked(d, handle_level_irq); irq_set_handler_locked(d, handle_level_irq);
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
return 0; return 0;
} }
@ -1219,16 +1182,19 @@ static int intel_gpio_community_irq_handler(struct intel_pinctrl *pctrl,
for (gpp = 0; gpp < community->ngpps; gpp++) { for (gpp = 0; gpp < community->ngpps; gpp++) {
const struct intel_padgroup *padgrp = &community->gpps[gpp]; const struct intel_padgroup *padgrp = &community->gpps[gpp];
unsigned long pending, enabled, gpp_offset; unsigned long pending, enabled;
unsigned int gpp, gpp_offset;
void __iomem *reg, *is;
raw_spin_lock(&pctrl->lock); gpp = padgrp->reg_num;
pending = readl(community->regs + community->is_offset + reg = community->regs + community->ie_offset + gpp * 4;
padgrp->reg_num * 4); is = community->regs + community->is_offset + gpp * 4;
enabled = readl(community->regs + community->ie_offset +
padgrp->reg_num * 4);
raw_spin_unlock(&pctrl->lock); scoped_guard(raw_spinlock, &pctrl->lock) {
pending = readl(is);
enabled = readl(reg);
}
/* Only interrupts that are enabled */ /* Only interrupts that are enabled */
pending &= enabled; pending &= enabled;
@ -1264,16 +1230,18 @@ static void intel_gpio_irq_init(struct intel_pinctrl *pctrl)
for (i = 0; i < pctrl->ncommunities; i++) { for (i = 0; i < pctrl->ncommunities; i++) {
const struct intel_community *community; const struct intel_community *community;
void __iomem *base; void __iomem *reg, *is;
unsigned int gpp; unsigned int gpp;
community = &pctrl->communities[i]; community = &pctrl->communities[i];
base = community->regs;
for (gpp = 0; gpp < community->ngpps; gpp++) { for (gpp = 0; gpp < community->ngpps; gpp++) {
reg = community->regs + community->ie_offset + gpp * 4;
is = community->regs + community->is_offset + gpp * 4;
/* Mask and clear all interrupts */ /* Mask and clear all interrupts */
writel(0, base + community->ie_offset + gpp * 4); writel(0, reg);
writel(0xffff, base + community->is_offset + gpp * 4); writel(0xffff, is);
} }
} }
} }

View File

@ -10,11 +10,11 @@
#ifndef PINCTRL_INTEL_H #ifndef PINCTRL_INTEL_H
#define PINCTRL_INTEL_H #define PINCTRL_INTEL_H
#include <linux/array_size.h>
#include <linux/bits.h> #include <linux/bits.h>
#include <linux/compiler_types.h> #include <linux/compiler_types.h>
#include <linux/gpio/driver.h> #include <linux/gpio/driver.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/kernel.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/pinctrl/pinctrl.h> #include <linux/pinctrl/pinctrl.h>
#include <linux/spinlock_types.h> #include <linux/spinlock_types.h>

View File

@ -8,14 +8,14 @@
*/ */
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/array_size.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/gpio/driver.h> #include <linux/gpio/driver.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/types.h> #include <linux/types.h>
@ -337,8 +337,6 @@ static int lp_gpio_request_enable(struct pinctrl_dev *pctldev,
unsigned long flags; unsigned long flags;
u32 value; u32 value;
pm_runtime_get(lg->dev);
raw_spin_lock_irqsave(&lg->lock, flags); raw_spin_lock_irqsave(&lg->lock, flags);
/* /*
@ -373,8 +371,6 @@ static void lp_gpio_disable_free(struct pinctrl_dev *pctldev,
lp_gpio_disable_input(conf2); lp_gpio_disable_input(conf2);
raw_spin_unlock_irqrestore(&lg->lock, flags); raw_spin_unlock_irqrestore(&lg->lock, flags);
pm_runtime_put(lg->dev);
} }
static int lp_gpio_set_direction(struct pinctrl_dev *pctldev, static int lp_gpio_set_direction(struct pinctrl_dev *pctldev,
@ -841,24 +837,6 @@ static int lp_gpio_probe(struct platform_device *pdev)
return ret; return ret;
} }
pm_runtime_enable(dev);
return 0;
}
static int lp_gpio_remove(struct platform_device *pdev)
{
pm_runtime_disable(&pdev->dev);
return 0;
}
static int lp_gpio_runtime_suspend(struct device *dev)
{
return 0;
}
static int lp_gpio_runtime_resume(struct device *dev)
{
return 0; return 0;
} }
@ -876,10 +854,7 @@ static int lp_gpio_resume(struct device *dev)
return 0; return 0;
} }
static const struct dev_pm_ops lp_gpio_pm_ops = { static DEFINE_SIMPLE_DEV_PM_OPS(lp_gpio_pm_ops, NULL, lp_gpio_resume);
SYSTEM_SLEEP_PM_OPS(NULL, lp_gpio_resume)
RUNTIME_PM_OPS(lp_gpio_runtime_suspend, lp_gpio_runtime_resume, NULL)
};
static const struct acpi_device_id lynxpoint_gpio_acpi_match[] = { static const struct acpi_device_id lynxpoint_gpio_acpi_match[] = {
{ "INT33C7", (kernel_ulong_t)&lptlp_soc_data }, { "INT33C7", (kernel_ulong_t)&lptlp_soc_data },
@ -890,10 +865,9 @@ MODULE_DEVICE_TABLE(acpi, lynxpoint_gpio_acpi_match);
static struct platform_driver lp_gpio_driver = { static struct platform_driver lp_gpio_driver = {
.probe = lp_gpio_probe, .probe = lp_gpio_probe,
.remove = lp_gpio_remove,
.driver = { .driver = {
.name = "lp_gpio", .name = "lp_gpio",
.pm = pm_ptr(&lp_gpio_pm_ops), .pm = pm_sleep_ptr(&lp_gpio_pm_ops),
.acpi_match_table = lynxpoint_gpio_acpi_match, .acpi_match_table = lynxpoint_gpio_acpi_match,
}, },
}; };

View File

@ -6,8 +6,8 @@
* Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com> * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
*/ */
#include <linux/array_size.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h>
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>

View File

@ -6,8 +6,8 @@
* Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com> * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
*/ */
#include <linux/array_size.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h>
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>

View File

@ -10,17 +10,19 @@
#define pr_fmt(fmt) "generic pinconfig core: " fmt #define pr_fmt(fmt) "generic pinconfig core: " fmt
#include <linux/kernel.h> #include <linux/array_size.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/slab.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/seq_file.h> #include <linux/device.h>
#include <linux/pinctrl/pinctrl.h> #include <linux/init.h>
#include <linux/pinctrl/pinconf.h> #include <linux/module.h>
#include <linux/pinctrl/pinconf-generic.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/slab.h>
#include <linux/seq_file.h>
#include <linux/pinctrl/pinconf-generic.h>
#include <linux/pinctrl/pinconf.h>
#include <linux/pinctrl/pinctrl.h>
#include "core.h" #include "core.h"
#include "pinconf.h" #include "pinconf.h"
#include "pinctrl-utils.h" #include "pinctrl-utils.h"

View File

@ -9,16 +9,18 @@
*/ */
#define pr_fmt(fmt) "pinconfig core: " fmt #define pr_fmt(fmt) "pinconfig core: " fmt
#include <linux/kernel.h> #include <linux/array_size.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/slab.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/pinctrl/machine.h> #include <linux/pinctrl/machine.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinconf.h> #include <linux/pinctrl/pinconf.h>
#include <linux/pinctrl/pinctrl.h>
#include "core.h" #include "core.h"
#include "pinconf.h" #include "pinconf.h"

View File

@ -6,12 +6,14 @@
* *
* Author: Laxman Dewangan <ldewangan@nvidia.com> * Author: Laxman Dewangan <ldewangan@nvidia.com>
*/ */
#include <linux/array_size.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/kernel.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pinctrl/pinctrl.h>
#include "core.h" #include "core.h"
#include "pinctrl-utils.h" #include "pinctrl-utils.h"

View File

@ -12,12 +12,12 @@
*/ */
#define pr_fmt(fmt) "pinmux core: " fmt #define pr_fmt(fmt) "pinmux core: " fmt
#include <linux/array_size.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/radix-tree.h> #include <linux/radix-tree.h>

View File

@ -0,0 +1,13 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_ARRAY_SIZE_H
#define _LINUX_ARRAY_SIZE_H
#include <linux/compiler.h>
/**
* ARRAY_SIZE - get the number of elements in array @arr
* @arr: array to be sized
*/
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
#endif /* _LINUX_ARRAY_SIZE_H */

View File

@ -13,6 +13,7 @@
#include <linux/stdarg.h> #include <linux/stdarg.h>
#include <linux/align.h> #include <linux/align.h>
#include <linux/array_size.h>
#include <linux/limits.h> #include <linux/limits.h>
#include <linux/linkage.h> #include <linux/linkage.h>
#include <linux/stddef.h> #include <linux/stddef.h>
@ -50,12 +51,6 @@
#define READ 0 #define READ 0
#define WRITE 1 #define WRITE 1
/**
* ARRAY_SIZE - get the number of elements in array @arr
* @arr: array to be sized
*/
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
#define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL) #define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL)
#define u64_to_user_ptr(x) ( \ #define u64_to_user_ptr(x) ( \

View File

@ -11,7 +11,7 @@
#ifndef __LINUX_PINCTRL_MACHINE_H #ifndef __LINUX_PINCTRL_MACHINE_H
#define __LINUX_PINCTRL_MACHINE_H #define __LINUX_PINCTRL_MACHINE_H
#include <linux/kernel.h> /* ARRAY_SIZE() */ #include <linux/array_size.h>
#include <linux/pinctrl/pinctrl-state.h> #include <linux/pinctrl/pinctrl-state.h>

View File

@ -2,6 +2,7 @@
#ifndef _LINUX_STRING_H_ #ifndef _LINUX_STRING_H_
#define _LINUX_STRING_H_ #define _LINUX_STRING_H_
#include <linux/array_size.h>
#include <linux/compiler.h> /* for inline */ #include <linux/compiler.h> /* for inline */
#include <linux/types.h> /* for size_t */ #include <linux/types.h> /* for size_t */
#include <linux/stddef.h> /* for NULL */ #include <linux/stddef.h> /* for NULL */