aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-11-12 00:34:19 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-12 00:34:19 -0500
commit66a173b926891023e34e78cb32f4681d19777e01 (patch)
treee6018f50fbceea7c07e6e27368ee817f9adb34f2 /drivers/char
parent11db81a59d0b2e563e30512cd76f23d0db384780 (diff)
parent0c4888ef1d8a8b82c29075ce7e257ff795af15c7 (diff)
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
Pull powerpc updates from Benjamin Herrenschmidt: "The bulk of this is LE updates. One should now be able to build an LE kernel and even run some things in it. I'm still sitting on a handful of patches to enable the new ABI that I *might* still send this merge window around, but due to the incertainty (they are pretty fresh) I want to keep them separate. Other notable changes are some infrastructure bits to better handle PCI pass-through under KVM, some bits and pieces added to the new PowerNV platform support such as access to the CPU SCOM bus via sysfs, and support for EEH error handling on PHB3 (Power8 PCIe). We also grew arch_get_random_long() for both pseries and powernv when running on P7+ and P8, exploiting the HW rng. And finally various embedded updates from freescale" * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc: (154 commits) powerpc: Fix fatal SLB miss when restoring PPR powerpc/powernv: Reserve the correct PE number powerpc/powernv: Add PE to its own PELTV powerpc/powernv: Add support for indirect XSCOM via debugfs powerpc/scom: Improve debugfs interface powerpc/scom: Enable 64-bit addresses powerpc/boot: Properly handle the base "of" boot wrapper powerpc/bpf: Support MOD operation powerpc/bpf: Fix DIVWU instruction opcode of: Move definition of of_find_next_cache_node into common code. powerpc: Remove big endianness assumption in of_find_next_cache_node powerpc/tm: Remove interrupt disable in __switch_to() powerpc: word-at-a-time optimization for 64-bit Little Endian powerpc/bpf: BPF JIT compiler for 64-bit Little Endian powerpc: Only save/restore SDR1 if in hypervisor mode powerpc/pmu: Fix ADB_PMU_LED_IDE dependencies powerpc/nvram: Fix endian issue when using the partition length powerpc/nvram: Fix endian issue when reading the NVRAM size powerpc/nvram: Scan partitions only once powerpc/mpc512x: remove unnecessary #if ...
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/hw_random/Kconfig13
-rw-r--r--drivers/char/hw_random/Makefile1
-rw-r--r--drivers/char/hw_random/powernv-rng.c81
-rw-r--r--drivers/char/hw_random/pseries-rng.c14
4 files changed, 106 insertions, 3 deletions
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 0aa9d91daef5..c206de2951f2 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -290,6 +290,19 @@ config HW_RANDOM_PSERIES
290 290
291 If unsure, say Y. 291 If unsure, say Y.
292 292
293config HW_RANDOM_POWERNV
294 tristate "PowerNV Random Number Generator support"
295 depends on HW_RANDOM && PPC_POWERNV
296 default HW_RANDOM
297 ---help---
298 This is the driver for Random Number Generator hardware found
299 in POWER7+ and above machines for PowerNV platform.
300
301 To compile this driver as a module, choose M here: the
302 module will be called powernv-rng.
303
304 If unsure, say Y.
305
293config HW_RANDOM_EXYNOS 306config HW_RANDOM_EXYNOS
294 tristate "EXYNOS HW random number generator support" 307 tristate "EXYNOS HW random number generator support"
295 depends on HW_RANDOM && HAS_IOMEM && HAVE_CLK 308 depends on HW_RANDOM && HAS_IOMEM && HAVE_CLK
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile
index bed467c9300e..d7d2435ff7fa 100644
--- a/drivers/char/hw_random/Makefile
+++ b/drivers/char/hw_random/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_HW_RANDOM_NOMADIK) += nomadik-rng.o
24obj-$(CONFIG_HW_RANDOM_PICOXCELL) += picoxcell-rng.o 24obj-$(CONFIG_HW_RANDOM_PICOXCELL) += picoxcell-rng.o
25obj-$(CONFIG_HW_RANDOM_PPC4XX) += ppc4xx-rng.o 25obj-$(CONFIG_HW_RANDOM_PPC4XX) += ppc4xx-rng.o
26obj-$(CONFIG_HW_RANDOM_PSERIES) += pseries-rng.o 26obj-$(CONFIG_HW_RANDOM_PSERIES) += pseries-rng.o
27obj-$(CONFIG_HW_RANDOM_POWERNV) += powernv-rng.o
27obj-$(CONFIG_HW_RANDOM_EXYNOS) += exynos-rng.o 28obj-$(CONFIG_HW_RANDOM_EXYNOS) += exynos-rng.o
28obj-$(CONFIG_HW_RANDOM_TPM) += tpm-rng.o 29obj-$(CONFIG_HW_RANDOM_TPM) += tpm-rng.o
29obj-$(CONFIG_HW_RANDOM_BCM2835) += bcm2835-rng.o 30obj-$(CONFIG_HW_RANDOM_BCM2835) += bcm2835-rng.o
diff --git a/drivers/char/hw_random/powernv-rng.c b/drivers/char/hw_random/powernv-rng.c
new file mode 100644
index 000000000000..3f4f63204560
--- /dev/null
+++ b/drivers/char/hw_random/powernv-rng.c
@@ -0,0 +1,81 @@
1/*
2 * Copyright 2013 Michael Ellerman, Guo Chao, IBM Corp.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
12#include <linux/module.h>
13#include <linux/kernel.h>
14#include <linux/platform_device.h>
15#include <linux/random.h>
16#include <linux/hw_random.h>
17
18static int powernv_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
19{
20 unsigned long *buf;
21 int i, len;
22
23 /* We rely on rng_buffer_size() being >= sizeof(unsigned long) */
24 len = max / sizeof(unsigned long);
25
26 buf = (unsigned long *)data;
27
28 for (i = 0; i < len; i++)
29 powernv_get_random_long(buf++);
30
31 return len * sizeof(unsigned long);
32}
33
34static struct hwrng powernv_hwrng = {
35 .name = "powernv-rng",
36 .read = powernv_rng_read,
37};
38
39static int powernv_rng_remove(struct platform_device *pdev)
40{
41 hwrng_unregister(&powernv_hwrng);
42
43 return 0;
44}
45
46static int powernv_rng_probe(struct platform_device *pdev)
47{
48 int rc;
49
50 rc = hwrng_register(&powernv_hwrng);
51 if (rc) {
52 /* We only register one device, ignore any others */
53 if (rc == -EEXIST)
54 rc = -ENODEV;
55
56 return rc;
57 }
58
59 pr_info("Registered powernv hwrng.\n");
60
61 return 0;
62}
63
64static struct of_device_id powernv_rng_match[] = {
65 { .compatible = "ibm,power-rng",},
66 {},
67};
68MODULE_DEVICE_TABLE(of, powernv_rng_match);
69
70static struct platform_driver powernv_rng_driver = {
71 .driver = {
72 .name = "powernv_rng",
73 .of_match_table = powernv_rng_match,
74 },
75 .probe = powernv_rng_probe,
76 .remove = powernv_rng_remove,
77};
78module_platform_driver(powernv_rng_driver);
79
80MODULE_LICENSE("GPL");
81MODULE_DESCRIPTION("Bare metal HWRNG driver for POWER7+ and above");
diff --git a/drivers/char/hw_random/pseries-rng.c b/drivers/char/hw_random/pseries-rng.c
index 5f1197929f0c..b761459a3436 100644
--- a/drivers/char/hw_random/pseries-rng.c
+++ b/drivers/char/hw_random/pseries-rng.c
@@ -17,6 +17,9 @@
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 18 */
19 19
20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
21
22#include <linux/kernel.h>
20#include <linux/module.h> 23#include <linux/module.h>
21#include <linux/hw_random.h> 24#include <linux/hw_random.h>
22#include <asm/vio.h> 25#include <asm/vio.h>
@@ -25,10 +28,15 @@
25 28
26static int pseries_rng_data_read(struct hwrng *rng, u32 *data) 29static int pseries_rng_data_read(struct hwrng *rng, u32 *data)
27{ 30{
28 if (plpar_hcall(H_RANDOM, (unsigned long *)data) != H_SUCCESS) { 31 int rc;
29 printk(KERN_ERR "pseries rng hcall error\n"); 32
30 return 0; 33 rc = plpar_hcall(H_RANDOM, (unsigned long *)data);
34 if (rc != H_SUCCESS) {
35 pr_err_ratelimited("H_RANDOM call failed %d\n", rc);
36 return -EIO;
31 } 37 }
38
39 /* The hypervisor interface returns 64 bits */
32 return 8; 40 return 8;
33} 41}
34 42