提交 c7e9c7e7 编写于 作者: E Ezequiel Garcia 提交者: Brian Norris

mtd: nand: pxa3xx: Early variant detection

In order to customize early settings depending on the detected SoC variant,
move the detection to be before the nand_chip struct filling.

In a follow-up patch, this change is needed to detect the variant *before*
the call to alloc_nand_resource(), which allows to set a different cmdfunc()
for each variant.
Signed-off-by: NEzequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-by: NDaniel Mack <zonque@gmail.com>
Signed-off-by: NBrian Norris <computersforpeace@gmail.com>
上级 4e86fd22
...@@ -258,6 +258,25 @@ static struct pxa3xx_nand_flash builtin_flash_types[] = { ...@@ -258,6 +258,25 @@ static struct pxa3xx_nand_flash builtin_flash_types[] = {
/* convert nano-seconds to nand flash controller clock cycles */ /* convert nano-seconds to nand flash controller clock cycles */
#define ns2cycle(ns, clk) (int)((ns) * (clk / 1000000) / 1000) #define ns2cycle(ns, clk) (int)((ns) * (clk / 1000000) / 1000)
static struct of_device_id pxa3xx_nand_dt_ids[] = {
{
.compatible = "marvell,pxa3xx-nand",
.data = (void *)PXA3XX_NAND_VARIANT_PXA,
},
{}
};
MODULE_DEVICE_TABLE(of, pxa3xx_nand_dt_ids);
static enum pxa3xx_nand_variant
pxa3xx_nand_get_variant(struct platform_device *pdev)
{
const struct of_device_id *of_id =
of_match_device(pxa3xx_nand_dt_ids, &pdev->dev);
if (!of_id)
return PXA3XX_NAND_VARIANT_PXA;
return (enum pxa3xx_nand_variant)of_id->data;
}
static void pxa3xx_nand_set_timing(struct pxa3xx_nand_host *host, static void pxa3xx_nand_set_timing(struct pxa3xx_nand_host *host,
const struct pxa3xx_nand_timing *t) const struct pxa3xx_nand_timing *t)
{ {
...@@ -1125,6 +1144,7 @@ static int alloc_nand_resource(struct platform_device *pdev) ...@@ -1125,6 +1144,7 @@ static int alloc_nand_resource(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
info->pdev = pdev; info->pdev = pdev;
info->variant = pxa3xx_nand_get_variant(pdev);
for (cs = 0; cs < pdata->num_cs; cs++) { for (cs = 0; cs < pdata->num_cs; cs++) {
mtd = (struct mtd_info *)((unsigned int)&info[1] + mtd = (struct mtd_info *)((unsigned int)&info[1] +
(sizeof(*mtd) + sizeof(*host)) * cs); (sizeof(*mtd) + sizeof(*host)) * cs);
...@@ -1259,25 +1279,6 @@ static int pxa3xx_nand_remove(struct platform_device *pdev) ...@@ -1259,25 +1279,6 @@ static int pxa3xx_nand_remove(struct platform_device *pdev)
return 0; return 0;
} }
static struct of_device_id pxa3xx_nand_dt_ids[] = {
{
.compatible = "marvell,pxa3xx-nand",
.data = (void *)PXA3XX_NAND_VARIANT_PXA,
},
{}
};
MODULE_DEVICE_TABLE(of, pxa3xx_nand_dt_ids);
static enum pxa3xx_nand_variant
pxa3xx_nand_get_variant(struct platform_device *pdev)
{
const struct of_device_id *of_id =
of_match_device(pxa3xx_nand_dt_ids, &pdev->dev);
if (!of_id)
return PXA3XX_NAND_VARIANT_PXA;
return (enum pxa3xx_nand_variant)of_id->data;
}
static int pxa3xx_nand_probe_dt(struct platform_device *pdev) static int pxa3xx_nand_probe_dt(struct platform_device *pdev)
{ {
struct pxa3xx_nand_platform_data *pdata; struct pxa3xx_nand_platform_data *pdata;
...@@ -1334,7 +1335,6 @@ static int pxa3xx_nand_probe(struct platform_device *pdev) ...@@ -1334,7 +1335,6 @@ static int pxa3xx_nand_probe(struct platform_device *pdev)
} }
info = platform_get_drvdata(pdev); info = platform_get_drvdata(pdev);
info->variant = pxa3xx_nand_get_variant(pdev);
probe_success = 0; probe_success = 0;
for (cs = 0; cs < pdata->num_cs; cs++) { for (cs = 0; cs < pdata->num_cs; cs++) {
struct mtd_info *mtd = info->host[cs]->mtd; struct mtd_info *mtd = info->host[cs]->mtd;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册