From: Mark Brown <broonie(a)linaro.org>
Currently regulator drivers which support DT all repeat very similar code
to supply a list of known regulator identifiers to be matched with DT,
convert that to platform data which is then matched up with the regulators
as they are registered. This is both fiddly to get right and for devices
which can use the standard helpers to provide their operations is the main
source of code in the driver.
Since this code is essentially identical for most drivers we can factor it
out into the core, moving the identifiers in the match table into the
regulator descriptors and also allowing drivers to pass in the name of the
subnode to search. When a driver provides an of_match string for the
regulator the core will attempt to use that to obtain init_data, allowing
the driver to remove all explicit code for DT parsing and simply provide
data instead.
The current code leaks the phandles for the child nodes, this will be
addressed incrementally and makes no practical difference for FDT anyway
as the DT data structures are never freed.
Signed-off-by: Mark Brown <broonie(a)linaro.org>
---
drivers/regulator/core.c | 10 +++++---
drivers/regulator/internal.h | 4 ++++
drivers/regulator/of_regulator.c | 51 ++++++++++++++++++++++++++++++++++++++++
include/linux/regulator/driver.h | 4 ++++
4 files changed, 66 insertions(+), 3 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index b31d706..cd87c0c 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3602,12 +3602,17 @@ regulator_register(const struct regulator_desc *regulator_desc,
return ERR_PTR(-EINVAL);
}
- init_data = config->init_data;
-
rdev = kzalloc(sizeof(struct regulator_dev), GFP_KERNEL);
if (rdev == NULL)
return ERR_PTR(-ENOMEM);
+ init_data = regulator_of_get_init_data(dev, regulator_desc,
+ &rdev->dev.of_node);
+ if (!init_data) {
+ init_data = config->init_data;
+ rdev->dev.of_node = of_node_get(config->of_node);
+ }
+
mutex_lock(®ulator_list_mutex);
mutex_init(&rdev->mutex);
@@ -3634,7 +3639,6 @@ regulator_register(const struct regulator_desc *regulator_desc,
/* register with sysfs */
rdev->dev.class = ®ulator_class;
- rdev->dev.of_node = of_node_get(config->of_node);
rdev->dev.parent = dev;
dev_set_name(&rdev->dev, "regulator.%d",
atomic_inc_return(®ulator_no) - 1);
diff --git a/drivers/regulator/internal.h b/drivers/regulator/internal.h
index 84bbda1..a6043ad 100644
--- a/drivers/regulator/internal.h
+++ b/drivers/regulator/internal.h
@@ -35,4 +35,8 @@ struct regulator {
struct dentry *debugfs;
};
+struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
+ const struct regulator_desc *desc,
+ struct device_node **node);
+
#endif
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index ee5e67b..7a51814 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -14,8 +14,11 @@
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/regulator/machine.h>
+#include <linux/regulator/driver.h>
#include <linux/regulator/of_regulator.h>
+#include "internal.h"
+
static void of_get_regulation_constraints(struct device_node *np,
struct regulator_init_data **init_data)
{
@@ -189,3 +192,51 @@ int of_regulator_match(struct device *dev, struct device_node *node,
return count;
}
EXPORT_SYMBOL_GPL(of_regulator_match);
+
+struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
+ const struct regulator_desc *desc,
+ struct device_node **node)
+{
+ struct device_node *search, *child;
+ struct regulator_init_data *init_data = NULL;
+ const char *name;
+
+ if (!dev->of_node || !desc->of_match)
+ return NULL;
+
+ if (desc->regulators_node)
+ search = of_get_child_by_name(dev->of_node,
+ desc->regulators_node);
+ else
+ search = dev->of_node;
+
+ if (!search) {
+ dev_err(dev, "Failed to find regulator container node\n");
+ return NULL;
+ }
+
+ for_each_child_of_node(search, child) {
+ name = of_get_property(child, "regulator-compatible", NULL);
+ if (!name)
+ name = child->name;
+
+ if (strcmp(desc->of_match, name))
+ continue;
+
+ init_data = of_get_regulator_init_data(dev, child);
+ if (!init_data) {
+ dev_err(dev,
+ "failed to parse DT for regulator %s\n",
+ child->name);
+ break;
+ }
+
+ of_node_get(child);
+ *node = child;
+ break;
+ }
+
+ of_node_put(search);
+
+ return init_data;
+}
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 38b2f1a..fc0ee0c 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -203,6 +203,8 @@ enum regulator_type {
*
* @name: Identifying name for the regulator.
* @supply_name: Identifying the regulator supply
+ * @of_match: Name used to identify regulator in DT.
+ * @regulators_node: Name of node containing regulator definitions in DT.
* @id: Numerical identifier for the regulator.
* @ops: Regulator operations table.
* @irq: Interrupt number for the regulator.
@@ -245,6 +247,8 @@ enum regulator_type {
struct regulator_desc {
const char *name;
const char *supply_name;
+ const char *of_match;
+ const char *regulators_node;
int id;
bool continuous_voltage_range;
unsigned n_voltages;
--
2.1.0
On Tue, Sep 9, 2014 at 11:10 AM, Kevin's boot bot <khilman(a)ished.com> wrote:
> Status report database: http://status.armcloud.us/boot/all/job/arm-soc/kernel/v3.17-rc4-381-g8224b1…
>
> Tree/Branch: arm-soc
> Git describe: v3.17-rc4-381-g8224b1f
> Offline boards (unable to connect to serial console)
> ====================================================
> exynos5410-smdk5410: OFFLINE: arm-multi_v7_defconfig+CONFIG_ARM_LPAE=y
> exynos5410-smdk5410: OFFLINE: arm-multi_v7_defconfig
> exynos5410-smdk5410: OFFLINE: arm-exynos_defconfig
-ESERIAL_CABLE
Re-ran the boot for these and everything is passing.
Kevin
Tree/Branch: master
Git describe: v3.17-rc4-146-g619df5d
Commit: 619df5d287 Merge tag 'microblaze-3.17-rc5' of git://git.monstr.eu/linux-2.6-microblaze
Build Time: 23 min 14 sec
Passed: 6 / 6 (100.00 %)
Failed: 0 / 6 ( 0.00 %)
Errors: 0
Warnings: 28
Section Mismatches: 0
-------------------------------------------------------------------------------
defconfigs with issues (other than build errors):
2 warnings 0 mismatches : arm64-allnoconfig
18 warnings 0 mismatches : arm-allmodconfig
1 warnings 0 mismatches : arm-multi_v7_defconfig
7 warnings 0 mismatches : arm64-allmodconfig
-------------------------------------------------------------------------------
Warnings Summary: 28
1 ../sound/soc/fsl/fsl_sai.c:337:7: warning: large integer implicitly truncated to unsigned type [-Woverflow]
1 ../net/rds/iw_rdma.c:200:1: warning: the frame size of 1056 bytes is larger than 1024 bytes [-Wframe-larger-than=]
1 ../drivers/tty/isicom.c:1058:240: warning: integer overflow in expression [-Woverflow]
1 ../drivers/staging/wlan-ng/prism2fw.c:792:1: warning: the frame size of 1072 bytes is larger than 1024 bytes [-Wframe-larger-than=]
1 ../drivers/staging/vt6655/device_main.c:3091:1: warning: the frame size of 1296 bytes is larger than 1024 bytes [-Wframe-larger-than=]
1 ../drivers/staging/rtl8192ee/pci.c:885:5: warning: format '%d' expects argument of type 'int', but argument 3 has type 'sk_buff_data_t' [-Wformat=]
1 ../drivers/staging/rtl8192ee/pci.c:885:5: warning: format '%d' expects argument of type 'int', but argument 2 has type 'sk_buff_data_t' [-Wformat=]
1 ../drivers/staging/dgnc/dgnc_tty.c:572:1: warning: the frame size of 1048 bytes is larger than 1024 bytes [-Wframe-larger-than=]
1 ../drivers/staging/bcm/CmHost.c:1564:3: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
1 ../drivers/staging/bcm/CmHost.c:1546:3: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
1 ../drivers/staging/bcm/CmHost.c:1503:3: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
1 ../drivers/scsi/ips.c:210:2: warning: #warning "This driver has only been tested on the x86/ia64/x86_64 platforms" [-Wcpp]
1 ../drivers/power/reset/xgene-reboot.c:80:17: warning: assignment from incompatible pointer type [enabled by default]
1 ../drivers/pci/host/pci-mvebu.c:887:39: warning: 'rtype' may be used uninitialized in this function [-Wmaybe-uninitialized]
1 ../drivers/net/ethernet/mellanox/mlx5/core/debugfs.c:467:46: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
1 ../drivers/net/ethernet/mellanox/mlx5/core/debugfs.c:307:11: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1 ../drivers/net/ethernet/mellanox/mlx5/core/debugfs.c:303:11: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1 ../drivers/net/ethernet/dec/tulip/winbond-840.c:910:2: warning: #warning Processor architecture undefined [-Wcpp]
1 ../drivers/net/ethernet/amd/nmclan_cs.c:624:3: warning: 'pcmcia_request_exclusive_irq' is deprecated (declared at ../include/pcmcia/ds.h:213) [-Wdeprecated-declarations]
1 ../drivers/mtd/chips/cfi_cmdset_0020.c:651:1: warning: the frame size of 1192 bytes is larger than 1024 bytes [-Wframe-larger-than=]
1 ../drivers/isdn/hardware/mISDN/w6692.c:1181:75: warning: unsupported argument to '__builtin_return_address'
1 ../drivers/isdn/hardware/mISDN/mISDNipac.c:759:75: warning: unsupported argument to '__builtin_return_address'
1 ../drivers/irqchip/irq-gic-v3.c:203:12: warning: 'gic_peek_irq' defined but not used [-Wunused-function]
1 ../drivers/irqchip/irq-gic-v3.c:132:13: warning: 'gic_write_sgi1r' defined but not used [-Wunused-function]
1 ../drivers/infiniband/hw/mlx5/mem.c:71:143: warning: comparison of distinct pointer types lacks a cast
1 ../drivers/block/drbd/drbd_bitmap.c:483:0: warning: "BITS_PER_PAGE_MASK" redefined [enabled by default]
1 ../drivers/block/drbd/drbd_bitmap.c:482:0: warning: "BITS_PER_PAGE" redefined [enabled by default]
1 ../arch/arm/mach-cns3xxx/pcie.c:311:1: warning: the frame size of 1072 bytes is larger than 1024 bytes [-Wframe-larger-than=]
===============================================================================
Detailed per-defconfig build reports below:
-------------------------------------------------------------------------------
arm64-allnoconfig : PASS, 0 errors, 2 warnings, 0 section mismatches
Warnings:
../drivers/irqchip/irq-gic-v3.c:132:13: warning: 'gic_write_sgi1r' defined but not used [-Wunused-function]
../drivers/irqchip/irq-gic-v3.c:203:12: warning: 'gic_peek_irq' defined but not used [-Wunused-function]
-------------------------------------------------------------------------------
arm-allmodconfig : PASS, 0 errors, 18 warnings, 0 section mismatches
Warnings:
../arch/arm/mach-cns3xxx/pcie.c:311:1: warning: the frame size of 1072 bytes is larger than 1024 bytes [-Wframe-larger-than=]
../net/rds/iw_rdma.c:200:1: warning: the frame size of 1056 bytes is larger than 1024 bytes [-Wframe-larger-than=]
../drivers/infiniband/hw/mlx5/mem.c:71:143: warning: comparison of distinct pointer types lacks a cast
../drivers/isdn/hardware/mISDN/w6692.c:1181:75: warning: unsupported argument to '__builtin_return_address'
../drivers/isdn/hardware/mISDN/mISDNipac.c:759:75: warning: unsupported argument to '__builtin_return_address'
../drivers/mtd/chips/cfi_cmdset_0020.c:651:1: warning: the frame size of 1192 bytes is larger than 1024 bytes [-Wframe-larger-than=]
../drivers/net/ethernet/amd/nmclan_cs.c:624:3: warning: 'pcmcia_request_exclusive_irq' is deprecated (declared at ../include/pcmcia/ds.h:213) [-Wdeprecated-declarations]
../drivers/net/ethernet/dec/tulip/winbond-840.c:910:2: warning: #warning Processor architecture undefined [-Wcpp]
../drivers/net/ethernet/mellanox/mlx5/core/debugfs.c:303:11: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
../drivers/net/ethernet/mellanox/mlx5/core/debugfs.c:307:11: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
../drivers/net/ethernet/mellanox/mlx5/core/debugfs.c:467:46: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
../drivers/staging/dgnc/dgnc_tty.c:572:1: warning: the frame size of 1048 bytes is larger than 1024 bytes [-Wframe-larger-than=]
../drivers/tty/isicom.c:1058:240: warning: integer overflow in expression [-Woverflow]
../drivers/scsi/ips.c:210:2: warning: #warning "This driver has only been tested on the x86/ia64/x86_64 platforms" [-Wcpp]
../drivers/staging/rtl8192ee/pci.c:885:5: warning: format '%d' expects argument of type 'int', but argument 2 has type 'sk_buff_data_t' [-Wformat=]
../drivers/staging/rtl8192ee/pci.c:885:5: warning: format '%d' expects argument of type 'int', but argument 3 has type 'sk_buff_data_t' [-Wformat=]
../drivers/staging/vt6655/device_main.c:3091:1: warning: the frame size of 1296 bytes is larger than 1024 bytes [-Wframe-larger-than=]
../drivers/staging/wlan-ng/prism2fw.c:792:1: warning: the frame size of 1072 bytes is larger than 1024 bytes [-Wframe-larger-than=]
-------------------------------------------------------------------------------
arm-multi_v7_defconfig : PASS, 0 errors, 1 warnings, 0 section mismatches
Warnings:
../drivers/pci/host/pci-mvebu.c:887:39: warning: 'rtype' may be used uninitialized in this function [-Wmaybe-uninitialized]
-------------------------------------------------------------------------------
arm64-allmodconfig : PASS, 0 errors, 7 warnings, 0 section mismatches
Warnings:
../drivers/block/drbd/drbd_bitmap.c:482:0: warning: "BITS_PER_PAGE" redefined [enabled by default]
../drivers/block/drbd/drbd_bitmap.c:483:0: warning: "BITS_PER_PAGE_MASK" redefined [enabled by default]
../sound/soc/fsl/fsl_sai.c:337:7: warning: large integer implicitly truncated to unsigned type [-Woverflow]
../drivers/power/reset/xgene-reboot.c:80:17: warning: assignment from incompatible pointer type [enabled by default]
../drivers/staging/bcm/CmHost.c:1503:3: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
../drivers/staging/bcm/CmHost.c:1546:3: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
../drivers/staging/bcm/CmHost.c:1564:3: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
-------------------------------------------------------------------------------
Passed with no errors, warnings or mismatches:
arm-allnoconfig
arm64-defconfig
Currently the read[bwlq]_relaxed() family are implemented on every
architecture except blackfin, m68k[1], metag, openrisc, s390[2] and
score. Increasingly drivers are being optimized to exploit relaxed
reads putting these architectures at risk of compilation failures for
shared drivers.
This patch addresses this by providing implementations of
read[bwlq]_relaxed() that are identical to the equivalent read[bwlq]().
All the above architectures include asm-generic/io.h .
Note that currently only eight architectures (alpha, arm, arm64, avr32,
hexagon, microblaze, mips and sh) implement write[bwlq]_relaxed() meaning
these functions are deliberately not included in this patch.
[1] m68k includes the relaxed family only when configured *without* MMU.
[2] s390 requires CONFIG_PCI to include the relaxed family.
Signed-off-by: Daniel Thompson <daniel.thompson(a)linaro.org>
Cc: Will Deacon <will.deacon(a)arm.com>
Cc: Arnd Bergmann <arnd(a)arndb.de>
Cc: linux-arch(a)vger.kernel.org
---
include/asm-generic/io.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 975e1cc..85ea117 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -66,6 +66,16 @@ static inline u32 readl(const volatile void __iomem *addr)
return __le32_to_cpu(__raw_readl(addr));
}
+#ifndef readb_relaxed
+#define readb_relaxed __raw_readb
+#endif
+#ifndef readw_relaxed
+#define readw_relaxed readw
+#endif
+#ifndef readl_relaxed
+#define readl_relaxed readl
+#endif
+
#ifndef __raw_writeb
static inline void __raw_writeb(u8 b, volatile void __iomem *addr)
{
@@ -105,6 +115,10 @@ static inline u64 readq(const volatile void __iomem *addr)
return __le64_to_cpu(__raw_readq(addr));
}
+#ifndef readq_relaxed
+#define readq_relaxed readq
+#endif
+
#ifndef __raw_writeq
static inline void __raw_writeq(u64 b, volatile void __iomem *addr)
{
--
1.9.3
Hi Rafael,
I am sending this again, but without the controversial part this time. I have
dropped last two patches which were about detecting clock sharing among CPUs.
Would fix up that later once other Maintainers get in sync about the bindings.
So, what's left here ? These are mostly updates/reorders which can be applied
the patches which I have dropped now. These are all well reviewed and tested
by others. Getting them in shouldn't break anything, I believe. Its better
people start using the updates we already have, otherwise they will keep on
sending fixes they get (The way Pramod Gurav tried it today).
Can we please get them in 3.17 if its still allowed? Or -next otherwise.
V2: https://lkml.org/lkml/2014/7/1/358
Rebased over: 3.17-rc2
git://git.linaro.org/people/viresh.kumar/linux.git cpufreq/cpu0-updates-v3
V2->V3: Dropped few patches, nothing much.
--
Thanks
Viresh
Viresh Kumar (10):
cpufreq: Add support for per-policy driver data
cpufreq: cpu0: Update Module Author
cpufreq: cpu0: don't validate clock on clk_put()
cpufreq: cpu0: print relevant error when we defer probe
cpufreq: cpu0: use dev_{err|warn|dbg} instead of pr_{err|warn|debug}
cpufreq: cpu0: Move per-cluster initialization code to ->init()
cpufreq: cpu0: try regulators with name "cpu-supply"
cpufreq: cpu0: Make allocate_resources() work for any CPU
cpufreq: cpu0: rename driver and internals to 'cpufreq_generic'
cpufreq: generic: set platform_{driver|device} '.name' to
'cpufreq-generic'
.../{cpufreq-cpu0.txt => cpufreq-generic.txt} | 8 +-
arch/arm/mach-imx/imx27-dt.c | 2 +-
arch/arm/mach-imx/mach-imx51.c | 2 +-
arch/arm/mach-omap2/pm.c | 2 +-
arch/arm/mach-shmobile/board-ape6evm-reference.c | 2 +-
arch/arm/mach-shmobile/cpufreq.c | 2 +-
arch/arm/mach-shmobile/setup-sh73a0.c | 4 +-
arch/arm/mach-zynq/common.c | 2 +-
drivers/cpufreq/Kconfig | 10 +-
drivers/cpufreq/Kconfig.arm | 2 +-
drivers/cpufreq/Makefile | 2 +-
drivers/cpufreq/cpufreq-cpu0.c | 248 --------------
drivers/cpufreq/cpufreq-generic.c | 363 +++++++++++++++++++++
drivers/cpufreq/exynos4210-cpufreq.c | 2 +-
drivers/cpufreq/exynos4x12-cpufreq.c | 2 +-
drivers/cpufreq/exynos5250-cpufreq.c | 2 +-
drivers/cpufreq/highbank-cpufreq.c | 6 +-
drivers/cpufreq/s5pv210-cpufreq.c | 2 +-
include/linux/cpufreq.h | 3 +
19 files changed, 392 insertions(+), 274 deletions(-)
rename Documentation/devicetree/bindings/cpufreq/{cpufreq-cpu0.txt => cpufreq-generic.txt} (85%)
delete mode 100644 drivers/cpufreq/cpufreq-cpu0.c
create mode 100644 drivers/cpufreq/cpufreq-generic.c
--
2.0.3.693.g996b0fd
The architectures where this peripheral exists (ARM and SH) have expensive
implementations of writel(), reliant on spin locks and explicit L2 cache
management. These architectures provide a cheaper writel_relaxed() which
is much better suited to peripherals that do not perform DMA. The
situation with readl()/readl_relaxed()is similar although less acute.
This driver does not use DMA and will be more power efficient and more
robust (due to absense of spin locks during console I/O) if it uses the
relaxed variants.
This change means the driver is no longer portable and therefore no
longer suitable for compile testing.
Signed-off-by: Daniel Thompson <daniel.thompson(a)linaro.org>
Cc: Srinivas Kandagatla <srinivas.kandagatla(a)gmail.com>
Cc: Patrice Chotard <patrice.chotard(a)st.com>
Cc: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Cc: Jiri Slaby <jslaby(a)suse.cz>
Cc: kernel(a)stlinux.com
Cc: linux-serial(a)vger.kernel.org
Acked-by: Maxime Coquelin <maxime.coquelin(a)st.com>
Acked-by: Peter Griffin <peter.griffin(a)linaro.org>
---
drivers/tty/serial/Kconfig | 2 +-
drivers/tty/serial/st-asc.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 26cec64d..e9b1735 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1527,7 +1527,7 @@ config SERIAL_FSL_LPUART_CONSOLE
config SERIAL_ST_ASC
tristate "ST ASC serial port support"
select SERIAL_CORE
- depends on ARM || COMPILE_TEST
+ depends on ARM
help
This driver is for the on-chip Asychronous Serial Controller on
STMicroelectronics STi SoCs.
diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c
index 8b2d735..adadbc1 100644
--- a/drivers/tty/serial/st-asc.c
+++ b/drivers/tty/serial/st-asc.c
@@ -151,12 +151,12 @@ static inline struct asc_port *to_asc_port(struct uart_port *port)
static inline u32 asc_in(struct uart_port *port, u32 offset)
{
- return readl(port->membase + offset);
+ return readl_relaxed(port->membase + offset);
}
static inline void asc_out(struct uart_port *port, u32 offset, u32 value)
{
- writel(value, port->membase + offset);
+ writel_relaxed(value, port->membase + offset);
}
/*
--
1.9.3