]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/mtd/nand/gpmi-nand/gpmi-nand.c
mtd: nand: gpmi: Kill gpmi_nand_exit()
[karo-tx-linux.git] / drivers / mtd / nand / gpmi-nand / gpmi-nand.c
index d52139635b67c658a0608f044a67dcd019ae1ff5..50f8d4a1b9832326070045d0c294d22393001fbd 100644 (file)
@@ -82,6 +82,10 @@ static int gpmi_ooblayout_free(struct mtd_info *mtd, int section,
        return 0;
 }
 
+static const char * const gpmi_clks_for_mx2x[] = {
+       "gpmi_io",
+};
+
 static const struct mtd_ooblayout_ops gpmi_ooblayout_ops = {
        .ecc = gpmi_ooblayout_ecc,
        .free = gpmi_ooblayout_free,
@@ -91,24 +95,48 @@ static const struct gpmi_devdata gpmi_devdata_imx23 = {
        .type = IS_MX23,
        .bch_max_ecc_strength = 20,
        .max_chain_delay = 16,
+       .clks = gpmi_clks_for_mx2x,
+       .clks_count = ARRAY_SIZE(gpmi_clks_for_mx2x),
 };
 
 static const struct gpmi_devdata gpmi_devdata_imx28 = {
        .type = IS_MX28,
        .bch_max_ecc_strength = 20,
        .max_chain_delay = 16,
+       .clks = gpmi_clks_for_mx2x,
+       .clks_count = ARRAY_SIZE(gpmi_clks_for_mx2x),
+};
+
+static const char * const gpmi_clks_for_mx6[] = {
+       "gpmi_io", "gpmi_apb", "gpmi_bch", "gpmi_bch_apb", "per1_bch",
 };
 
 static const struct gpmi_devdata gpmi_devdata_imx6q = {
        .type = IS_MX6Q,
        .bch_max_ecc_strength = 40,
        .max_chain_delay = 12,
+       .clks = gpmi_clks_for_mx6,
+       .clks_count = ARRAY_SIZE(gpmi_clks_for_mx6),
 };
 
 static const struct gpmi_devdata gpmi_devdata_imx6sx = {
        .type = IS_MX6SX,
        .bch_max_ecc_strength = 62,
        .max_chain_delay = 12,
+       .clks = gpmi_clks_for_mx6,
+       .clks_count = ARRAY_SIZE(gpmi_clks_for_mx6),
+};
+
+static const char * const gpmi_clks_for_mx7d[] = {
+       "gpmi_io", "gpmi_bch_apb",
+};
+
+static const struct gpmi_devdata gpmi_devdata_imx7d = {
+       .type = IS_MX7D,
+       .bch_max_ecc_strength = 62,
+       .max_chain_delay = 12,
+       .clks = gpmi_clks_for_mx7d,
+       .clks_count = ARRAY_SIZE(gpmi_clks_for_mx7d),
 };
 
 static irqreturn_t bch_irq(int irq, void *cookie)
@@ -599,35 +627,14 @@ acquire_err:
        return -EINVAL;
 }
 
-static char *extra_clks_for_mx6q[GPMI_CLK_MAX] = {
-       "gpmi_apb", "gpmi_bch", "gpmi_bch_apb", "per1_bch",
-};
-
 static int gpmi_get_clks(struct gpmi_nand_data *this)
 {
        struct resources *r = &this->resources;
-       char **extra_clks = NULL;
        struct clk *clk;
        int err, i;
 
-       /* The main clock is stored in the first. */
-       r->clock[0] = devm_clk_get(this->dev, "gpmi_io");
-       if (IS_ERR(r->clock[0])) {
-               err = PTR_ERR(r->clock[0]);
-               goto err_clock;
-       }
-
-       /* Get extra clocks */
-       if (GPMI_IS_MX6(this))
-               extra_clks = extra_clks_for_mx6q;
-       if (!extra_clks)
-               return 0;
-
-       for (i = 1; i < GPMI_CLK_MAX; i++) {
-               if (extra_clks[i - 1] == NULL)
-                       break;
-
-               clk = devm_clk_get(this->dev, extra_clks[i - 1]);
+       for (i = 0; i < this->devdata->clks_count; i++) {
+               clk = devm_clk_get(this->dev, this->devdata->clks[i]);
                if (IS_ERR(clk)) {
                        err = PTR_ERR(clk);
                        goto err_clock;
@@ -1929,12 +1936,6 @@ static int gpmi_set_geometry(struct gpmi_nand_data *this)
        return gpmi_alloc_dma_buffer(this);
 }
 
-static void gpmi_nand_exit(struct gpmi_nand_data *this)
-{
-       nand_release(nand_to_mtd(&this->nand));
-       gpmi_free_dma_buffer(this);
-}
-
 static int gpmi_init_last(struct gpmi_nand_data *this)
 {
        struct nand_chip *chip = &this->nand;
@@ -2048,18 +2049,20 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
 
        ret = nand_boot_init(this);
        if (ret)
-               goto err_out;
+               goto err_nand_cleanup;
        ret = chip->scan_bbt(mtd);
        if (ret)
-               goto err_out;
+               goto err_nand_cleanup;
 
        ret = mtd_device_register(mtd, NULL, 0);
        if (ret)
-               goto err_out;
+               goto err_nand_cleanup;
        return 0;
 
+err_nand_cleanup:
+       nand_cleanup(chip);
 err_out:
-       gpmi_nand_exit(this);
+       gpmi_free_dma_buffer(this);
        return ret;
 }
 
@@ -2076,6 +2079,9 @@ static const struct of_device_id gpmi_nand_id_table[] = {
        }, {
                .compatible = "fsl,imx6sx-gpmi-nand",
                .data = &gpmi_devdata_imx6sx,
+       }, {
+               .compatible = "fsl,imx7d-gpmi-nand",
+               .data = &gpmi_devdata_imx7d,
        }, {}
 };
 MODULE_DEVICE_TABLE(of, gpmi_nand_id_table);
@@ -2129,7 +2135,8 @@ static int gpmi_nand_remove(struct platform_device *pdev)
 {
        struct gpmi_nand_data *this = platform_get_drvdata(pdev);
 
-       gpmi_nand_exit(this);
+       nand_release(nand_to_mtd(&this->nand));
+       gpmi_free_dma_buffer(this);
        release_resources(this);
        return 0;
 }