Commit be72a4aa authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Boris Brezillon

mtd: nand: denali: introduce capability flag

The Denali NAND controller IP has various customizable features.
SoC vendors can choose desired functions when a delivery RTL is
created.  It means there are several variants for this IP.  For
example, the Intel version is equipped with 32bit DMA, whereas the
IP for UniPhier SoC family with 64bit DMA.

This driver was originally written for some Intel platforms with
Intel specific things hard-coded.  What is worse, the revision
register of this IP does not work to distinguish such features.
We need to do something to make the driver available for other SoCs.

Let's introduce a caps member to the denali_nand_info structure to
switch on/off various features.  Also, add struct denali_dt_data to
store the capability associated with compatible string.

Boris suggested this approach in discussion [1] instead of a new DT
property for every feature.

[1] https://lkml.org/lkml/2016/3/29/142Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
parent 1aded58a
...@@ -338,6 +338,7 @@ struct denali_nand_info { ...@@ -338,6 +338,7 @@ struct denali_nand_info {
uint32_t devnum; /* represent how many nands connected */ uint32_t devnum; /* represent how many nands connected */
uint32_t bbtskipbytes; uint32_t bbtskipbytes;
uint32_t max_banks; uint32_t max_banks;
unsigned int caps;
}; };
extern int denali_init(struct denali_nand_info *denali); extern int denali_init(struct denali_nand_info *denali);
......
...@@ -29,6 +29,10 @@ struct denali_dt { ...@@ -29,6 +29,10 @@ struct denali_dt {
struct clk *clk; struct clk *clk;
}; };
struct denali_dt_data {
unsigned int caps;
};
static const struct of_device_id denali_nand_dt_ids[] = { static const struct of_device_id denali_nand_dt_ids[] = {
{ .compatible = "denali,denali-nand-dt" }, { .compatible = "denali,denali-nand-dt" },
{ /* sentinel */ } { /* sentinel */ }
...@@ -42,23 +46,19 @@ static int denali_dt_probe(struct platform_device *ofdev) ...@@ -42,23 +46,19 @@ static int denali_dt_probe(struct platform_device *ofdev)
{ {
struct resource *denali_reg, *nand_data; struct resource *denali_reg, *nand_data;
struct denali_dt *dt; struct denali_dt *dt;
const struct denali_dt_data *data;
struct denali_nand_info *denali; struct denali_nand_info *denali;
int ret; int ret;
const struct of_device_id *of_id;
of_id = of_match_device(denali_nand_dt_ids, &ofdev->dev);
if (of_id) {
ofdev->id_entry = of_id->data;
} else {
pr_err("Failed to find the right device id.\n");
return -ENOMEM;
}
dt = devm_kzalloc(&ofdev->dev, sizeof(*dt), GFP_KERNEL); dt = devm_kzalloc(&ofdev->dev, sizeof(*dt), GFP_KERNEL);
if (!dt) if (!dt)
return -ENOMEM; return -ENOMEM;
denali = &dt->denali; denali = &dt->denali;
data = of_device_get_match_data(&ofdev->dev);
if (data)
denali->caps = data->caps;
denali->platform = DT; denali->platform = DT;
denali->dev = &ofdev->dev; denali->dev = &ofdev->dev;
denali->irq = platform_get_irq(ofdev, 0); denali->irq = platform_get_irq(ofdev, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment