Skip to content

Commit

Permalink
Add SMI NAND driver
Browse files Browse the repository at this point in the history
Signed-off-by: Luke Wren <wren6991@gmail.com>
  • Loading branch information
Wren6991 authored and popcornmix committed Sep 22, 2015
1 parent 0815226 commit fda45e5
Show file tree
Hide file tree
Showing 8 changed files with 402 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Documentation/devicetree/bindings/mtd/brcm,bcm2835-smi-nand.txt
@@ -0,0 +1,42 @@
* BCM2835 SMI NAND flash

This driver is a shim between the BCM2835 SMI driver (SMI is a peripheral for
talking to parallel register interfaces) and Linux's MTD layer.

Required properties:
- compatible: "brcm,bcm2835-smi-nand"
- status: "okay"

Optional properties:
- partition@n, where n is an integer from a consecutive sequence starting at 0
- Difficult to store partition table on NAND device - normally put it
in the source code, kernel bootparams, or device tree (the best way!)
- Sub-properties:
- label: the partition name, as shown by mtdinfo /dev/mtd*
- reg: the size and offset of this partition.
- (optional) read-only: an empty property flagging as read only

Example:

nand: flash@0 {
compatible = "brcm,bcm2835-smi-nand";
status = "okay";

partition@0 {
label = "stage2";
// 128k
reg = <0 0x20000>;
read-only;
};
partition@1 {
label = "firmware";
// 16M
reg = <0x20000 0x1000000>;
read-only;
};
partition@2 {
label = "root";
// 2G
reg = <0x1020000 0x80000000>;
};
};
1 change: 1 addition & 0 deletions arch/arm/boot/dts/overlays/Makefile
Expand Up @@ -15,6 +15,7 @@ endif
dtb-$(RPI_DT_OVERLAYS) += ads7846-overlay.dtb
dtb-$(RPI_DT_OVERLAYS) += smi-overlay.dtb
dtb-$(RPI_DT_OVERLAYS) += smi-dev-overlay.dtb
dtb-$(RPI_DT_OVERLAYS) += smi-nand-overlay.dtb
dtb-$(RPI_DT_OVERLAYS) += bmp085_i2c-sensor-overlay.dtb
dtb-$(RPI_DT_OVERLAYS) += dht11-overlay.dtb
dtb-$(RPI_DT_OVERLAYS) += enc28j60-overlay.dtb
Expand Down
69 changes: 69 additions & 0 deletions arch/arm/boot/dts/overlays/smi-nand-overlay.dts
@@ -0,0 +1,69 @@
// Description: Overlay to enable NAND flash through
// the secondary memory interface
// Author: Luke Wren

/dts-v1/;
/plugin/;

/{
compatible = "brcm,bcm2708";

fragment@0 {
target = <&smi>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&smi_pins>;
status = "okay";
};
};

fragment@1 {
target = <&soc>;
__overlay__ {
#address-cells = <1>;
#size-cells = <1>;

nand: flash@0 {
compatible = "brcm,bcm2835-smi-nand";
smi_handle = <&smi>;
#address-cells = <1>;
#size-cells = <1>;
status = "okay";

partition@0 {
label = "stage2";
// 128k
reg = <0 0x20000>;
read-only;
};
partition@1 {
label = "firmware";
// 16M
reg = <0x20000 0x1000000>;
read-only;
};
partition@2 {
label = "root";
// 2G (will need to use 64 bit for >=4G)
reg = <0x1020000 0x80000000>;
};
};
};
};

fragment@2 {
target = <&gpio>;
__overlay__ {
smi_pins: smi_pins {
brcm,pins = <0 1 2 3 4 5 6 7 8 9 10 11
12 13 14 15>;
/* Alt 1: SMI */
brcm,function = <5 5 5 5 5 5 5 5 5 5 5
5 5 5 5 5>;
/* /CS, /WE and /OE are pulled high, as they are
generally active low signals */
brcm,pull = <2 2 2 2 2 2 2 2 0 0 0 0 0 0 0 0>;
};
};
};
};
7 changes: 7 additions & 0 deletions arch/arm/configs/bcm2709_defconfig
Expand Up @@ -392,6 +392,10 @@ CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_DMA_CMA=y
CONFIG_CMA_SIZE_MBYTES=5
CONFIG_MTD=m
CONFIG_MTD_BLOCK=m
CONFIG_MTD_NAND=m
CONFIG_MTD_UBI=m
CONFIG_ZRAM=m
CONFIG_ZRAM_LZ4_COMPRESS=y
CONFIG_BLK_DEV_LOOP=y
Expand Down Expand Up @@ -1142,6 +1146,9 @@ CONFIG_CONFIGFS_FS=y
CONFIG_ECRYPT_FS=m
CONFIG_HFS_FS=m
CONFIG_HFSPLUS_FS=m
CONFIG_JFFS2_FS=m
CONFIG_JFFS2_SUMMARY=y
CONFIG_UBIFS_FS=m
CONFIG_SQUASHFS=m
CONFIG_SQUASHFS_XATTR=y
CONFIG_SQUASHFS_LZO=y
Expand Down
7 changes: 7 additions & 0 deletions arch/arm/configs/bcmrpi_defconfig
Expand Up @@ -385,6 +385,10 @@ CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_DMA_CMA=y
CONFIG_CMA_SIZE_MBYTES=5
CONFIG_MTD=m
CONFIG_MTD_BLOCK=m
CONFIG_MTD_NAND=m
CONFIG_MTD_UBI=m
CONFIG_ZRAM=m
CONFIG_ZRAM_LZ4_COMPRESS=y
CONFIG_BLK_DEV_LOOP=y
Expand Down Expand Up @@ -1135,6 +1139,9 @@ CONFIG_CONFIGFS_FS=y
CONFIG_ECRYPT_FS=m
CONFIG_HFS_FS=m
CONFIG_HFSPLUS_FS=m
CONFIG_JFFS2_FS=m
CONFIG_JFFS2_SUMMARY=y
CONFIG_UBIFS_FS=m
CONFIG_SQUASHFS=m
CONFIG_SQUASHFS_XATTR=y
CONFIG_SQUASHFS_LZO=y
Expand Down
7 changes: 7 additions & 0 deletions drivers/mtd/nand/Kconfig
Expand Up @@ -41,6 +41,13 @@ config MTD_SM_COMMON
tristate
default n

config MTD_NAND_BCM2835_SMI
tristate "Use Broadcom's Secondary Memory Interface as a NAND controller (BCM283x)"
depends on (MACH_BCM2708 || MACH_BCM2709 || ARCH_BCM2835) && BCM2835_SMI && MTD_NAND
default m
help
Uses the BCM2835's SMI peripheral as a NAND controller.

config MTD_NAND_DENALI
tristate "Support Denali NAND controller"
depends on HAS_DMA
Expand Down
1 change: 1 addition & 0 deletions drivers/mtd/nand/Makefile
Expand Up @@ -14,6 +14,7 @@ obj-$(CONFIG_MTD_NAND_DENALI) += denali.o
obj-$(CONFIG_MTD_NAND_DENALI_PCI) += denali_pci.o
obj-$(CONFIG_MTD_NAND_DENALI_DT) += denali_dt.o
obj-$(CONFIG_MTD_NAND_AU1550) += au1550nd.o
obj-$(CONFIG_MTD_NAND_BCM2835_SMI) += bcm2835_smi_nand.o
obj-$(CONFIG_MTD_NAND_BF5XX) += bf5xx_nand.o
obj-$(CONFIG_MTD_NAND_S3C2410) += s3c2410.o
obj-$(CONFIG_MTD_NAND_DAVINCI) += davinci_nand.o
Expand Down

0 comments on commit fda45e5

Please sign in to comment.