base-files: define yes/no as valid boolean options
[openwrt/staging/lynxis/omap.git] / target / linux / mvebu / patches-3.10 / 0135-mtd-nand-pxa3xx-Early-variant-detection.patch
1 From dc333ddda677d416a6726509e144c6dfb93e7e89 Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Thu, 7 Nov 2013 12:17:14 -0300
4 Subject: [PATCH 135/203] mtd: nand: pxa3xx: Early variant detection
5
6 In order to customize early settings depending on the detected SoC variant,
7 move the detection to be before the nand_chip struct filling.
8
9 In a follow-up patch, this change is needed to detect the variant *before*
10 the call to alloc_nand_resource(), which allows to set a different cmdfunc()
11 for each variant.
12
13 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
14 Tested-by: Daniel Mack <zonque@gmail.com>
15 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
16 ---
17 drivers/mtd/nand/pxa3xx_nand.c | 48 +++++++++++++++++++++---------------------
18 1 file changed, 24 insertions(+), 24 deletions(-)
19
20 --- a/drivers/mtd/nand/pxa3xx_nand.c
21 +++ b/drivers/mtd/nand/pxa3xx_nand.c
22 @@ -258,6 +258,29 @@ static struct pxa3xx_nand_flash builtin_
23 /* convert nano-seconds to nand flash controller clock cycles */
24 #define ns2cycle(ns, clk) (int)((ns) * (clk / 1000000) / 1000)
25
26 +static struct of_device_id pxa3xx_nand_dt_ids[] = {
27 + {
28 + .compatible = "marvell,pxa3xx-nand",
29 + .data = (void *)PXA3XX_NAND_VARIANT_PXA,
30 + },
31 + {
32 + .compatible = "marvell,armada370-nand",
33 + .data = (void *)PXA3XX_NAND_VARIANT_ARMADA370,
34 + },
35 + {}
36 +};
37 +MODULE_DEVICE_TABLE(of, pxa3xx_nand_dt_ids);
38 +
39 +static enum pxa3xx_nand_variant
40 +pxa3xx_nand_get_variant(struct platform_device *pdev)
41 +{
42 + const struct of_device_id *of_id =
43 + of_match_device(pxa3xx_nand_dt_ids, &pdev->dev);
44 + if (!of_id)
45 + return PXA3XX_NAND_VARIANT_PXA;
46 + return (enum pxa3xx_nand_variant)of_id->data;
47 +}
48 +
49 static void pxa3xx_nand_set_timing(struct pxa3xx_nand_host *host,
50 const struct pxa3xx_nand_timing *t)
51 {
52 @@ -1125,6 +1148,7 @@ static int alloc_nand_resource(struct pl
53 return -ENOMEM;
54
55 info->pdev = pdev;
56 + info->variant = pxa3xx_nand_get_variant(pdev);
57 for (cs = 0; cs < pdata->num_cs; cs++) {
58 mtd = (struct mtd_info *)((unsigned int)&info[1] +
59 (sizeof(*mtd) + sizeof(*host)) * cs);
60 @@ -1259,29 +1283,6 @@ static int pxa3xx_nand_remove(struct pla
61 return 0;
62 }
63
64 -static struct of_device_id pxa3xx_nand_dt_ids[] = {
65 - {
66 - .compatible = "marvell,pxa3xx-nand",
67 - .data = (void *)PXA3XX_NAND_VARIANT_PXA,
68 - },
69 - {
70 - .compatible = "marvell,armada370-nand",
71 - .data = (void *)PXA3XX_NAND_VARIANT_ARMADA370,
72 - },
73 - {}
74 -};
75 -MODULE_DEVICE_TABLE(of, pxa3xx_nand_dt_ids);
76 -
77 -static enum pxa3xx_nand_variant
78 -pxa3xx_nand_get_variant(struct platform_device *pdev)
79 -{
80 - const struct of_device_id *of_id =
81 - of_match_device(pxa3xx_nand_dt_ids, &pdev->dev);
82 - if (!of_id)
83 - return PXA3XX_NAND_VARIANT_PXA;
84 - return (enum pxa3xx_nand_variant)of_id->data;
85 -}
86 -
87 static int pxa3xx_nand_probe_dt(struct platform_device *pdev)
88 {
89 struct pxa3xx_nand_platform_data *pdata;
90 @@ -1338,7 +1339,6 @@ static int pxa3xx_nand_probe(struct plat
91 }
92
93 info = platform_get_drvdata(pdev);
94 - info->variant = pxa3xx_nand_get_variant(pdev);
95 probe_success = 0;
96 for (cs = 0; cs < pdata->num_cs; cs++) {
97 struct mtd_info *mtd = info->host[cs]->mtd;