Skip to content

Commit 02d1d0e

Browse files
ffainellimiquelraynal
authored andcommitted
mtd: rawnand: brcmnand: Add platform data structure for BCMA
Update the BCMA's chipcommon nand flash driver to detect which chip-select is used and pass that information via platform data to the brcmnand driver. Make sure that the brcmnand platform data structure is always at the beginning of the platform data of the "nflash" device created by BCMA to allow brcmnand to safely de-reference it. Signed-off-by: Florian Fainelli <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent f5619f3 commit 02d1d0e

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4021,6 +4021,7 @@ L: [email protected]
40214021
40224022
S: Maintained
40234023
F: drivers/mtd/nand/raw/brcmnand/
4024+
F: include/linux/platform_data/brcmnand.h
40244025

40254026
BROADCOM STB PCIE DRIVER
40264027
M: Jim Quinlan <[email protected]>

drivers/bcma/driver_chipcommon_nflash.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,28 @@
77

88
#include "bcma_private.h"
99

10+
#include <linux/bitops.h>
1011
#include <linux/platform_device.h>
12+
#include <linux/platform_data/brcmnand.h>
1113
#include <linux/bcma/bcma.h>
1214

15+
/* Alternate NAND controller driver name in order to allow both bcm47xxnflash
16+
* and bcma_brcmnand to be built into the same kernel image.
17+
*/
18+
static const char *bcma_nflash_alt_name = "bcma_brcmnand";
19+
1320
struct platform_device bcma_nflash_dev = {
1421
.name = "bcma_nflash",
1522
.num_resources = 0,
1623
};
1724

25+
static const char *probes[] = { "bcm47xxpart", NULL };
26+
1827
/* Initialize NAND flash access */
1928
int bcma_nflash_init(struct bcma_drv_cc *cc)
2029
{
2130
struct bcma_bus *bus = cc->core->bus;
31+
u32 reg;
2232

2333
if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4706 &&
2434
cc->core->id.rev != 38) {
@@ -33,8 +43,16 @@ int bcma_nflash_init(struct bcma_drv_cc *cc)
3343

3444
cc->nflash.present = true;
3545
if (cc->core->id.rev == 38 &&
36-
(cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT))
46+
(cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT)) {
3747
cc->nflash.boot = true;
48+
/* Determine the chip select that is being used */
49+
reg = bcma_cc_read32(cc, BCMA_CC_NAND_CS_NAND_SELECT) & 0xff;
50+
cc->nflash.brcmnand_info.chip_select = ffs(reg) - 1;
51+
cc->nflash.brcmnand_info.part_probe_types = probes;
52+
cc->nflash.brcmnand_info.ecc_stepsize = 512;
53+
cc->nflash.brcmnand_info.ecc_strength = 1;
54+
bcma_nflash_dev.name = bcma_nflash_alt_name;
55+
}
3856

3957
/* Prepare platform device, but don't register it yet. It's too early,
4058
* malloc (required by device_private_init) is not available yet. */

include/linux/bcma/bcma_driver_chipcommon.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define LINUX_BCMA_DRIVER_CC_H_
44

55
#include <linux/platform_device.h>
6+
#include <linux/platform_data/brcmnand.h>
67
#include <linux/gpio.h>
78

89
/** ChipCommon core registers. **/
@@ -599,6 +600,10 @@ struct bcma_sflash {
599600

600601
#ifdef CONFIG_BCMA_NFLASH
601602
struct bcma_nflash {
603+
/* Must be the fist member for the brcmnand driver to
604+
* de-reference that structure.
605+
*/
606+
struct brcmnand_platform_data brcmnand_info;
602607
bool present;
603608
bool boot; /* This is the flash the SoC boots from */
604609
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
#ifndef BRCMNAND_PLAT_DATA_H
3+
#define BRCMNAND_PLAT_DATA_H
4+
5+
struct brcmnand_platform_data {
6+
int chip_select;
7+
const char * const *part_probe_types;
8+
unsigned int ecc_stepsize;
9+
unsigned int ecc_strength;
10+
};
11+
12+
#endif /* BRCMNAND_PLAT_DATA_H */

0 commit comments

Comments
 (0)