Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <f.fainelli@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220107184614.2670254-7-f.fainelli@gmail.com

authored by

Florian Fainelli and committed by
Miquel Raynal
02d1d0e4 f5619f37

+37 -1
+1
MAINTAINERS
··· 4021 4021 L: bcm-kernel-feedback-list@broadcom.com 4022 4022 S: Maintained 4023 4023 F: drivers/mtd/nand/raw/brcmnand/ 4024 + F: include/linux/platform_data/brcmnand.h 4024 4025 4025 4026 BROADCOM STB PCIE DRIVER 4026 4027 M: Jim Quinlan <jim2101024@gmail.com>
+19 -1
drivers/bcma/driver_chipcommon_nflash.c
··· 7 7 8 8 #include "bcma_private.h" 9 9 10 + #include <linux/bitops.h> 10 11 #include <linux/platform_device.h> 12 + #include <linux/platform_data/brcmnand.h> 11 13 #include <linux/bcma/bcma.h> 14 + 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"; 12 19 13 20 struct platform_device bcma_nflash_dev = { 14 21 .name = "bcma_nflash", 15 22 .num_resources = 0, 16 23 }; 17 24 25 + static const char *probes[] = { "bcm47xxpart", NULL }; 26 + 18 27 /* Initialize NAND flash access */ 19 28 int bcma_nflash_init(struct bcma_drv_cc *cc) 20 29 { 21 30 struct bcma_bus *bus = cc->core->bus; 31 + u32 reg; 22 32 23 33 if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4706 && 24 34 cc->core->id.rev != 38) { ··· 43 33 44 34 cc->nflash.present = true; 45 35 if (cc->core->id.rev == 38 && 46 - (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT)) 36 + (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT)) { 47 37 cc->nflash.boot = true; 38 + /* Determine the chip select that is being used */ 39 + reg = bcma_cc_read32(cc, BCMA_CC_NAND_CS_NAND_SELECT) & 0xff; 40 + cc->nflash.brcmnand_info.chip_select = ffs(reg) - 1; 41 + cc->nflash.brcmnand_info.part_probe_types = probes; 42 + cc->nflash.brcmnand_info.ecc_stepsize = 512; 43 + cc->nflash.brcmnand_info.ecc_strength = 1; 44 + bcma_nflash_dev.name = bcma_nflash_alt_name; 45 + } 48 46 49 47 /* Prepare platform device, but don't register it yet. It's too early, 50 48 * malloc (required by device_private_init) is not available yet. */
+5
include/linux/bcma/bcma_driver_chipcommon.h
··· 3 3 #define LINUX_BCMA_DRIVER_CC_H_ 4 4 5 5 #include <linux/platform_device.h> 6 + #include <linux/platform_data/brcmnand.h> 6 7 #include <linux/gpio.h> 7 8 8 9 /** ChipCommon core registers. **/ ··· 600 599 601 600 #ifdef CONFIG_BCMA_NFLASH 602 601 struct bcma_nflash { 602 + /* Must be the fist member for the brcmnand driver to 603 + * de-reference that structure. 604 + */ 605 + struct brcmnand_platform_data brcmnand_info; 603 606 bool present; 604 607 bool boot; /* This is the flash the SoC boots from */ 605 608 };
+12
include/linux/platform_data/brcmnand.h
··· 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 */