Skip to content

Commit e24eb5e

Browse files
committed
Merge tag 'at91-5.5-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/at91/linux into arm/drivers
AT91 drivers for 5.5 - a new driver exposing the serial number registers through nvmem - a few documentation and definition changes * tag 'at91-5.5-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/at91/linux: soc: at91: Add Atmel SFR SN (Serial Number) support memory: atmel-ebi: switch to SPDX license identifiers memory: atmel-ebi: move NUM_CS definition inside EBI driver ARM: at91: Documentation: update the sama5d3 and armv7m datasheets Link: https://lore.kernel.org/r/20191107221644.GA201884@piout.net Signed-off-by: Olof Johansson <olof@lixom.net>
2 parents 44a3984 + c3277f8 commit e24eb5e

6 files changed

Lines changed: 118 additions & 9 deletions

File tree

‎Documentation/arm/microchip.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ the Microchip website: http://www.microchip.com.
103103

104104
* Datasheet
105105

106-
http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-11121-32-bit-Cortex-A5-Microcontroller-SAMA5D3_Datasheet.pdf
106+
http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-11121-32-bit-Cortex-A5-Microcontroller-SAMA5D3_Datasheet_B.pdf
107107

108108
* ARM Cortex-A5 + NEON based SoCs
109109
- sama5d4 family
@@ -167,7 +167,7 @@ the Microchip website: http://www.microchip.com.
167167

168168
* Datasheet
169169

170-
http://ww1.microchip.com/downloads/en/DeviceDoc/60001527A.pdf
170+
http://ww1.microchip.com/downloads/en/DeviceDoc/SAM-E70-S70-V70-V71-Family-Data-Sheet-DS60001527D.pdf
171171

172172

173173
Linux kernel information

‎drivers/memory/atmel-ebi.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1+
// SPDX-License-Identifier: GPL-2.0
12
/*
23
* EBI driver for Atmel chips
34
* inspired by the fsl weim bus driver
45
*
56
* Copyright (C) 2013 Jean-Jacques Hiblot <jjhiblot@traphandler.com>
6-
*
7-
* This file is licensed under the terms of the GNU General Public
8-
* License version 2. This program is licensed "as is" without any
9-
* warranty of any kind, whether express or implied.
107
*/
118

129
#include <linux/clk.h>
@@ -19,6 +16,8 @@
1916
#include <linux/regmap.h>
2017
#include <soc/at91/atmel-sfr.h>
2118

19+
#define AT91_EBI_NUM_CS 8
20+
2221
struct atmel_ebi_dev_config {
2322
int cs;
2423
struct atmel_smc_cs_conf smcconf;
@@ -314,7 +313,7 @@ static int atmel_ebi_dev_setup(struct atmel_ebi *ebi, struct device_node *np,
314313
if (ret)
315314
return ret;
316315

317-
if (cs >= AT91_MATRIX_EBI_NUM_CS ||
316+
if (cs >= AT91_EBI_NUM_CS ||
318317
!(ebi->caps->available_cs & BIT(cs))) {
319318
dev_err(dev, "invalid reg property in %pOF\n", np);
320319
return -EINVAL;
@@ -344,7 +343,7 @@ static int atmel_ebi_dev_setup(struct atmel_ebi *ebi, struct device_node *np,
344343
apply = true;
345344

346345
i = 0;
347-
for_each_set_bit(cs, &cslines, AT91_MATRIX_EBI_NUM_CS) {
346+
for_each_set_bit(cs, &cslines, AT91_EBI_NUM_CS) {
348347
ebid->configs[i].cs = cs;
349348

350349
if (apply) {

‎drivers/soc/atmel/Kconfig‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,14 @@ config AT91_SOC_ID
55
default ARCH_AT91
66
help
77
Include support for the SoC bus on the Atmel ARM SoCs.
8+
9+
config AT91_SOC_SFR
10+
tristate "Special Function Registers support"
11+
depends on ARCH_AT91 || COMPILE_TEST
12+
help
13+
This is a driver for the Special Function Registers available on
14+
Atmel SAMA5Dx SoCs, providing access to specific aspects of the
15+
integrated memory, bridge implementations, processor etc.
16+
17+
This driver can also be built as a module. If so, the module
18+
will be called sfr.

‎drivers/soc/atmel/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
obj-$(CONFIG_AT91_SOC_ID) += soc.o
3+
obj-$(CONFIG_AT91_SOC_SFR) += sfr.o

‎drivers/soc/atmel/sfr.c‎

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* sfr.c - driver for special function registers
4+
*
5+
* Copyright (C) 2019 Bootlin.
6+
*
7+
*/
8+
#include <linux/mfd/syscon.h>
9+
#include <linux/module.h>
10+
#include <linux/nvmem-provider.h>
11+
#include <linux/random.h>
12+
#include <linux/of.h>
13+
#include <linux/of_device.h>
14+
#include <linux/platform_device.h>
15+
#include <linux/regmap.h>
16+
17+
#define SFR_SN0 0x4c
18+
#define SFR_SN_SIZE 8
19+
20+
struct atmel_sfr_priv {
21+
struct regmap *regmap;
22+
};
23+
24+
static int atmel_sfr_read(void *context, unsigned int offset,
25+
void *buf, size_t bytes)
26+
{
27+
struct atmel_sfr_priv *priv = context;
28+
29+
return regmap_bulk_read(priv->regmap, SFR_SN0 + offset,
30+
buf, bytes / 4);
31+
}
32+
33+
static struct nvmem_config atmel_sfr_nvmem_config = {
34+
.name = "atmel-sfr",
35+
.read_only = true,
36+
.word_size = 4,
37+
.stride = 4,
38+
.size = SFR_SN_SIZE,
39+
.reg_read = atmel_sfr_read,
40+
};
41+
42+
static int atmel_sfr_probe(struct platform_device *pdev)
43+
{
44+
struct device *dev = &pdev->dev;
45+
struct device_node *np = dev->of_node;
46+
struct nvmem_device *nvmem;
47+
struct atmel_sfr_priv *priv;
48+
u8 sn[SFR_SN_SIZE];
49+
int ret;
50+
51+
priv = devm_kmalloc(dev, sizeof(*priv), GFP_KERNEL);
52+
if (!priv)
53+
return -ENOMEM;
54+
55+
priv->regmap = syscon_node_to_regmap(np);
56+
if (IS_ERR(priv->regmap)) {
57+
dev_err(dev, "cannot get parent's regmap\n");
58+
return PTR_ERR(priv->regmap);
59+
}
60+
61+
atmel_sfr_nvmem_config.dev = dev;
62+
atmel_sfr_nvmem_config.priv = priv;
63+
64+
nvmem = devm_nvmem_register(dev, &atmel_sfr_nvmem_config);
65+
if (IS_ERR(nvmem)) {
66+
dev_err(dev, "error registering nvmem config\n");
67+
return PTR_ERR(nvmem);
68+
}
69+
70+
ret = atmel_sfr_read(priv, 0, sn, SFR_SN_SIZE);
71+
if (ret == 0)
72+
add_device_randomness(sn, SFR_SN_SIZE);
73+
74+
return ret;
75+
}
76+
77+
static const struct of_device_id atmel_sfr_dt_ids[] = {
78+
{
79+
.compatible = "atmel,sama5d2-sfr",
80+
}, {
81+
.compatible = "atmel,sama5d4-sfr",
82+
}, {
83+
/* sentinel */
84+
},
85+
};
86+
MODULE_DEVICE_TABLE(of, atmel_sfr_dt_ids);
87+
88+
static struct platform_driver atmel_sfr_driver = {
89+
.probe = atmel_sfr_probe,
90+
.driver = {
91+
.name = "atmel-sfr",
92+
.of_match_table = atmel_sfr_dt_ids,
93+
},
94+
};
95+
module_platform_driver(atmel_sfr_driver);
96+
97+
MODULE_AUTHOR("Kamel Bouhara <kamel.bouhara@bootlin.com>");
98+
MODULE_DESCRIPTION("Atmel SFR SN driver for SAMA5D2/4 SoC family");
99+
MODULE_LICENSE("GPL v2");

‎include/linux/mfd/syscon/atmel-matrix.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@
106106
#define AT91_MATRIX_DDR_IOSR BIT(18)
107107
#define AT91_MATRIX_NFD0_SELECT BIT(24)
108108
#define AT91_MATRIX_DDR_MP_EN BIT(25)
109-
#define AT91_MATRIX_EBI_NUM_CS 8
110109

111110
#define AT91_MATRIX_USBPUCR_PUON BIT(30)
112111

0 commit comments

Comments
 (0)