linux/drivers/mfd/syscon.c
Linus Torvalds 1fe9eb1847 Changes to existing drivers:
- Increase DT coverage - arizona, mc13xxx, stmpe-i2c, syscon, sun6i-prcm
  - Regmap use of and/or clean-up - tps65090, twl6040
  - Basic renaming - max14577
  - Use new cpufreq helpers -  db8500-prcmu
  - Increase regulator support - stmpe, arizona, wm5102
  - Reduce legacy GPIO overhead - stmpe
  - Provide necessary remove path - bcm590xx
  - Expand sysfs presence - kempld
  - Move driver specific code out to drivers - rtc-s5m, arizona
  - Clk handling - twl6040
  - Use managed (devm_*) resources - ipaq-micro
  - Clean-up/remove unused/duplicated code - tps65218, sec, pm8921, abx500-core
    		   		     	    db8500-prcmu, menelaus
  - Build/boot/sematic bug fixes - rtsx_usb, stmpe, bcm590xx, abx500, mc13xxx
                                   rdc321x-southbridge, mfd-core, sec, max14577
 				  syscon, cros_ec_spi
  - Constify stuff 		- sm501, tps65910, tps6507x, tps6586x, max77686,
    	    	  		  max8997, kempld, max77693, max8907, rtsx_usb
 				  db8500-prcmu, max8998, wm8400, sec, lp3943,
 				  max14577, as3711, omap-usb-host, ipaq-micro
 Support for new devices:
  - Add support for max77836 into max14577
  - Add support for tps658640 into tps6586x
  - Add support for cros-ec-i2c-tunnel into cros_ec
  - Add new driver for rtsx_usb_sdmmc and rtsx_usb_ms
  - Add new driver for axp20x
  - Add new driver for sun6i-prcm
  - Add new driver for ipaq-micro
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.14 (GNU/Linux)
 
 iQIcBAABAgAGBQJTkEAyAAoJEFGvii+H/HdhYdMP/j0MCmbORM9mr84Uuhi0PfBZ
 yE1zlhLQHtqQEcp4Ih6vWxIbgdhyHy3CqIiCKkhSTH0TWfreBX7DmlSc1QAKazpy
 sXeD/pB5TSIIfAHVh4NXF51WMzZ8OvQrmJQwdjUY1Sal2tlDCUdc84qtnn+3/J9N
 JIKpf4E1IeWojE8F3koKBcyE6ZzkAthIzWNDU9/y+sIZZEqPVRu9Y3mpdhPo6P3I
 9TboZ/s2cAwad56iArFMOCvtg1xpn0WyS0HgAxpSa9X5qLRjYPX5GnBBz8zKJYm3
 xHCiD6SgN29xX9W+MkcvtgEghhMfOkPgwF69u2/eagbtNEOm50cyLrvAe+SKjRvE
 pODs5yvHJap29cbVafHSdzV+zLZ51J/Oi/TFsG8/VBbd4DyW7oSM4juT20TFSiNt
 Edwzd4gicg/NxA7TupFCRQLgwAa3fnpPeCtsIims7LU7SclPuwNgS31isOGAkOvd
 mMaBa1clZb50Dy2iL8m1ugyqdOZXs9S24j3u+B0TTJyabMbNhDTGUwBG4/PrlJHq
 fIysx6CdNUGLikG2PybFvhCf3+FkEoPPtkloM1sblkhPHVunVlhXPRYAE90W2jUA
 dDQ2Aco/idWSGRZ5t7kA8OBN3+PwiIpxTt/D4eDmS7Qe/v3KXvhUYuKl2mD5+IfC
 StFiP5cd3zyJvWTeexuW
 =GYTU
 -----END PGP SIGNATURE-----

Merge tag 'mfd-for-linus-3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd into next

Pull MFD updates from Lee Jones:
 "Changes to existing drivers:
   - increase DT coverage: arizona, mc13xxx, stmpe-i2c, syscon,
     sun6i-prcm
   - regmap use of and/or clean-up: tps65090, twl6040
   - basic renaming: max14577
   - use new cpufreq helpers: db8500-prcmu
   - increase regulator support: stmpe, arizona, wm5102
   - reduce legacy GPIO overhead: stmpe
   - provide necessary remove path: bcm590xx
   - expand sysfs presence: kempld
   - move driver specific code out to drivers: rtc-s5m, arizona
   - clk handling: twl6040
   - use managed (devm_*) resources: ipaq-micro
   - clean-up/remove unused/duplicated code: tps65218, sec, pm8921,
     abx500-core, db8500-prcmu, menelaus
   - build/boot/sematic bug fixes: rtsx_usb, stmpe, bcm590xx, abx500,
     mc13xxx, rdc321x-southbridge, mfd-core, sec, max14577, syscon,
     cros_ec_spi
   - constify stuff: sm501, tps65910, tps6507x, tps6586x, max77686,
     max8997, kempld, max77693, max8907, rtsx_usb, db8500-prcmu,
     max8998, wm8400, sec, lp3943, max14577, as3711, omap-usb-host,
     ipaq-micro

  Support for new devices:
   - add support for max77836 into max14577
   - add support for tps658640 into tps6586x
   - add support for cros-ec-i2c-tunnel into cros_ec
   - add new driver for rtsx_usb_sdmmc and rtsx_usb_ms
   - add new driver for axp20x
   - add new driver for sun6i-prcm
   - add new driver for ipaq-micro"

* tag 'mfd-for-linus-3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (77 commits)
  mfd: wm5102: Correct default for LDO Control 2 register
  mfd: menelaus: Use module_i2c_driver
  mfd: tps65218: Terminate of match table
  mfd: db8500-prcmu: Remove check for CONFIG_DBX500_PRCMU_DEBUG
  mfd: ti-keystone-devctrl: Add bindings for device state control
  mfd: palmas: Format the header file
  mfd: abx500-core: Remove unused function abx500_dump_all_banks()
  mfd: arizona: Correct addresses of always-on trigger registers
  mfd: max14577: Cast to architecture agnostic data type
  i2c: ChromeOS EC tunnel driver
  mfd: cros_ec: Sync to the latest cros_ec_commands.h from EC sources
  mfd: cros_ec: spi: Increase cros_ec_spi deadline from 5ms to 100ms
  mfd: cros_ec: spi: Make the cros_ec_spi timeout more reliable
  mfd: cros_ec: spi: Add mutex to cros_ec_spi
  mfd: cros_ec: spi: Calculate delay between transfers correctly
  mfd: arizona: Correct error message for addition of main IRQ chip
  mfd: wm8997: Add registers for high power mode
  mfd: arizona: Add MICVDD to mapped regulators
  mfd: ipaq-micro: Make mfd_cell array const
  mfd: ipaq-micro: Use devm_ioremap_resource()
  ...
2014-06-06 12:08:39 -07:00

191 lines
4.2 KiB
C

/*
* System Control Driver
*
* Copyright (C) 2012 Freescale Semiconductor, Inc.
* Copyright (C) 2012 Linaro Ltd.
*
* Author: Dong Aisheng <dong.aisheng@linaro.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <linux/err.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <linux/platform_data/syscon.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/mfd/syscon.h>
static struct platform_driver syscon_driver;
struct syscon {
struct regmap *regmap;
};
static int syscon_match_node(struct device *dev, void *data)
{
struct device_node *dn = data;
return (dev->of_node == dn) ? 1 : 0;
}
struct regmap *syscon_node_to_regmap(struct device_node *np)
{
struct syscon *syscon;
struct device *dev;
dev = driver_find_device(&syscon_driver.driver, NULL, np,
syscon_match_node);
if (!dev)
return ERR_PTR(-EPROBE_DEFER);
syscon = dev_get_drvdata(dev);
return syscon->regmap;
}
EXPORT_SYMBOL_GPL(syscon_node_to_regmap);
struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
{
struct device_node *syscon_np;
struct regmap *regmap;
syscon_np = of_find_compatible_node(NULL, NULL, s);
if (!syscon_np)
return ERR_PTR(-ENODEV);
regmap = syscon_node_to_regmap(syscon_np);
of_node_put(syscon_np);
return regmap;
}
EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_compatible);
static int syscon_match_pdevname(struct device *dev, void *data)
{
return !strcmp(dev_name(dev), (const char *)data);
}
struct regmap *syscon_regmap_lookup_by_pdevname(const char *s)
{
struct device *dev;
struct syscon *syscon;
dev = driver_find_device(&syscon_driver.driver, NULL, (void *)s,
syscon_match_pdevname);
if (!dev)
return ERR_PTR(-EPROBE_DEFER);
syscon = dev_get_drvdata(dev);
return syscon->regmap;
}
EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_pdevname);
struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np,
const char *property)
{
struct device_node *syscon_np;
struct regmap *regmap;
if (property)
syscon_np = of_parse_phandle(np, property, 0);
else
syscon_np = np;
if (!syscon_np)
return ERR_PTR(-ENODEV);
regmap = syscon_node_to_regmap(syscon_np);
of_node_put(syscon_np);
return regmap;
}
EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_phandle);
static const struct of_device_id of_syscon_match[] = {
{ .compatible = "syscon", },
{ },
};
static struct regmap_config syscon_regmap_config = {
.reg_bits = 32,
.val_bits = 32,
.reg_stride = 4,
};
static int syscon_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct syscon_platform_data *pdata = dev_get_platdata(dev);
struct syscon *syscon;
struct resource *res;
void __iomem *base;
syscon = devm_kzalloc(dev, sizeof(*syscon), GFP_KERNEL);
if (!syscon)
return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
return -ENOENT;
base = devm_ioremap(dev, res->start, resource_size(res));
if (!base)
return -ENOMEM;
syscon_regmap_config.max_register = res->end - res->start - 3;
if (pdata)
syscon_regmap_config.name = pdata->label;
syscon->regmap = devm_regmap_init_mmio(dev, base,
&syscon_regmap_config);
if (IS_ERR(syscon->regmap)) {
dev_err(dev, "regmap init failed\n");
return PTR_ERR(syscon->regmap);
}
platform_set_drvdata(pdev, syscon);
dev_dbg(dev, "regmap %pR registered\n", res);
return 0;
}
static const struct platform_device_id syscon_ids[] = {
{ "syscon", },
{ }
};
static struct platform_driver syscon_driver = {
.driver = {
.name = "syscon",
.owner = THIS_MODULE,
.of_match_table = of_syscon_match,
},
.probe = syscon_probe,
.id_table = syscon_ids,
};
static int __init syscon_init(void)
{
return platform_driver_register(&syscon_driver);
}
postcore_initcall(syscon_init);
static void __exit syscon_exit(void)
{
platform_driver_unregister(&syscon_driver);
}
module_exit(syscon_exit);
MODULE_AUTHOR("Dong Aisheng <dong.aisheng@linaro.org>");
MODULE_DESCRIPTION("System Control driver");
MODULE_LICENSE("GPL v2");