brcm63xx: register SPI controllers through DT
[openwrt/openwrt.git] / target / linux / brcm63xx / patches-4.4 / 000-4.5-01-mtd-add-get-set-of_node-flash_node-helpers.patch
1 From 28b8b26b308e656edfa9467867d5f79212da2ec3 Mon Sep 17 00:00:00 2001
2 From: Brian Norris <computersforpeace@gmail.com>
3 Date: Fri, 30 Oct 2015 20:33:20 -0700
4 Subject: [PATCH 01/11] mtd: add get/set of_node/flash_node helpers
5
6 We are going to begin using the mtd->dev.of_node field for MTD device
7 nodes, so let's add helpers for it. Also, we'll be making some
8 conversions on spi_nor (and nand_chip eventually) too, so get that ready
9 with their own helpers.
10
11 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
12 Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
13 ---
14 include/linux/mtd/mtd.h | 11 +++++++++++
15 include/linux/mtd/nand.h | 11 +++++++++++
16 include/linux/mtd/spi-nor.h | 11 +++++++++++
17 3 files changed, 33 insertions(+)
18
19 --- a/include/linux/mtd/mtd.h
20 +++ b/include/linux/mtd/mtd.h
21 @@ -258,6 +258,17 @@ struct mtd_info {
22 int usecount;
23 };
24
25 +static inline void mtd_set_of_node(struct mtd_info *mtd,
26 + struct device_node *np)
27 +{
28 + mtd->dev.of_node = np;
29 +}
30 +
31 +static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)
32 +{
33 + return mtd->dev.of_node;
34 +}
35 +
36 int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
37 int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
38 void **virt, resource_size_t *phys);
39 --- a/include/linux/mtd/nand.h
40 +++ b/include/linux/mtd/nand.h
41 @@ -719,6 +719,17 @@ struct nand_chip {
42 void *priv;
43 };
44
45 +static inline void nand_set_flash_node(struct nand_chip *chip,
46 + struct device_node *np)
47 +{
48 + chip->flash_node = np;
49 +}
50 +
51 +static inline struct device_node *nand_get_flash_node(struct nand_chip *chip)
52 +{
53 + return chip->flash_node;
54 +}
55 +
56 /*
57 * NAND Flash Manufacturer ID Codes
58 */
59 --- a/include/linux/mtd/spi-nor.h
60 +++ b/include/linux/mtd/spi-nor.h
61 @@ -184,6 +184,17 @@ struct spi_nor {
62 void *priv;
63 };
64
65 +static inline void spi_nor_set_flash_node(struct spi_nor *nor,
66 + struct device_node *np)
67 +{
68 + nor->flash_node = np;
69 +}
70 +
71 +static inline struct device_node *spi_nor_get_flash_node(struct spi_nor *nor)
72 +{
73 + return nor->flash_node;
74 +}
75 +
76 /**
77 * spi_nor_scan() - scan the SPI NOR
78 * @nor: the spi_nor structure