973a3e95ee137ff9b0dd4794f831c2bfae239eb6
[openwrt/staging/svanheule.git] /
1 From: Florian Fainelli <f.fainelli@gmail.com>
2 Subject: [PATCH v3 6/9] mtd: rawnand: brcmnand: Add platform data structure for BCMA
3 Date: Fri, 07 Jan 2022 10:46:11 -0800
4 Content-Type: text/plain; charset="utf-8"
5
6 Update the BCMA's chipcommon nand flash driver to detect which
7 chip-select is used and pass that information via platform data to the
8 brcmnand driver. Make sure that the brcmnand platform data structure is
9 always at the beginning of the platform data of the "nflash" device
10 created by BCMA to allow brcmnand to safely de-reference it.
11
12 Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
13 ---
14 MAINTAINERS | 1 +
15 drivers/bcma/driver_chipcommon_nflash.c | 20 +++++++++++++++++++-
16 include/linux/bcma/bcma_driver_chipcommon.h | 5 +++++
17 include/linux/platform_data/brcmnand.h | 12 ++++++++++++
18 4 files changed, 37 insertions(+), 1 deletion(-)
19 create mode 100644 include/linux/platform_data/brcmnand.h
20
21 --- a/MAINTAINERS
22 +++ b/MAINTAINERS
23 @@ -3712,6 +3712,7 @@ L: linux-mtd@lists.infradead.org
24 L: bcm-kernel-feedback-list@broadcom.com
25 S: Maintained
26 F: drivers/mtd/nand/raw/brcmnand/
27 +F: include/linux/platform_data/brcmnand.h
28
29 BROADCOM SYSTEMPORT ETHERNET DRIVER
30 M: Florian Fainelli <f.fainelli@gmail.com>
31 --- a/drivers/bcma/driver_chipcommon_nflash.c
32 +++ b/drivers/bcma/driver_chipcommon_nflash.c
33 @@ -7,18 +7,28 @@
34
35 #include "bcma_private.h"
36
37 +#include <linux/bitops.h>
38 #include <linux/platform_device.h>
39 +#include <linux/platform_data/brcmnand.h>
40 #include <linux/bcma/bcma.h>
41
42 +/* Alternate NAND controller driver name in order to allow both bcm47xxnflash
43 + * and bcma_brcmnand to be built into the same kernel image.
44 + */
45 +static const char *bcma_nflash_alt_name = "bcma_brcmnand";
46 +
47 struct platform_device bcma_nflash_dev = {
48 .name = "bcma_nflash",
49 .num_resources = 0,
50 };
51
52 +static const char *probes[] = { "bcm47xxpart", NULL };
53 +
54 /* Initialize NAND flash access */
55 int bcma_nflash_init(struct bcma_drv_cc *cc)
56 {
57 struct bcma_bus *bus = cc->core->bus;
58 + u32 reg;
59
60 if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4706 &&
61 cc->core->id.rev != 38) {
62 @@ -33,8 +43,16 @@ int bcma_nflash_init(struct bcma_drv_cc
63
64 cc->nflash.present = true;
65 if (cc->core->id.rev == 38 &&
66 - (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT))
67 + (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT)) {
68 cc->nflash.boot = true;
69 + /* Determine the chip select that is being used */
70 + reg = bcma_cc_read32(cc, BCMA_CC_NAND_CS_NAND_SELECT) & 0xff;
71 + cc->nflash.brcmnand_info.chip_select = ffs(reg) - 1;
72 + cc->nflash.brcmnand_info.part_probe_types = probes;
73 + cc->nflash.brcmnand_info.ecc_stepsize = 512;
74 + cc->nflash.brcmnand_info.ecc_strength = 1;
75 + bcma_nflash_dev.name = bcma_nflash_alt_name;
76 + }
77
78 /* Prepare platform device, but don't register it yet. It's too early,
79 * malloc (required by device_private_init) is not available yet. */
80 --- a/include/linux/bcma/bcma_driver_chipcommon.h
81 +++ b/include/linux/bcma/bcma_driver_chipcommon.h
82 @@ -3,6 +3,7 @@
83 #define LINUX_BCMA_DRIVER_CC_H_
84
85 #include <linux/platform_device.h>
86 +#include <linux/platform_data/brcmnand.h>
87 #include <linux/gpio.h>
88
89 /** ChipCommon core registers. **/
90 @@ -599,6 +600,10 @@ struct bcma_sflash {
91
92 #ifdef CONFIG_BCMA_NFLASH
93 struct bcma_nflash {
94 + /* Must be the fist member for the brcmnand driver to
95 + * de-reference that structure.
96 + */
97 + struct brcmnand_platform_data brcmnand_info;
98 bool present;
99 bool boot; /* This is the flash the SoC boots from */
100 };
101 --- /dev/null
102 +++ b/include/linux/platform_data/brcmnand.h
103 @@ -0,0 +1,12 @@
104 +/* SPDX-License-Identifier: GPL-2.0-only */
105 +#ifndef BRCMNAND_PLAT_DATA_H
106 +#define BRCMNAND_PLAT_DATA_H
107 +
108 +struct brcmnand_platform_data {
109 + int chip_select;
110 + const char * const *part_probe_types;
111 + unsigned int ecc_stepsize;
112 + unsigned int ecc_strength;
113 +};
114 +
115 +#endif /* BRCMNAND_PLAT_DATA_H */