diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2012-04-23 05:23:38 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-05-14 00:02:37 -0400 |
commit | 5e05a2d695f920209991b7a097c2e4ad4d1cdf9e (patch) | |
tree | 935b01fc2b7f4b68bf472d34f8a4625dc5a85794 | |
parent | 6dcdf99dfab15bebf71ae66ed04cdce05b20779c (diff) |
mtd: mxc_nand: split chip_select function and put it into devtype struct
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r-- | drivers/mtd/nand/mxc_nand.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index e02d27a937c8..03664d5742d9 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c | |||
@@ -153,6 +153,7 @@ struct mxc_nand_devtype_data { | |||
153 | void (*irq_control)(struct mxc_nand_host *, int); | 153 | void (*irq_control)(struct mxc_nand_host *, int); |
154 | u32 (*get_ecc_status)(struct mxc_nand_host *); | 154 | u32 (*get_ecc_status)(struct mxc_nand_host *); |
155 | struct nand_ecclayout *ecclayout_512, *ecclayout_2k, *ecclayout_4k; | 155 | struct nand_ecclayout *ecclayout_512, *ecclayout_2k, *ecclayout_4k; |
156 | void (*select_chip)(struct mtd_info *mtd, int chip); | ||
156 | }; | 157 | }; |
157 | 158 | ||
158 | struct mxc_nand_host { | 159 | struct mxc_nand_host { |
@@ -721,7 +722,7 @@ static int mxc_nand_verify_buf(struct mtd_info *mtd, | |||
721 | 722 | ||
722 | /* This function is used by upper layer for select and | 723 | /* This function is used by upper layer for select and |
723 | * deselect of the NAND chip */ | 724 | * deselect of the NAND chip */ |
724 | static void mxc_nand_select_chip(struct mtd_info *mtd, int chip) | 725 | static void mxc_nand_select_chip_v1_v3(struct mtd_info *mtd, int chip) |
725 | { | 726 | { |
726 | struct nand_chip *nand_chip = mtd->priv; | 727 | struct nand_chip *nand_chip = mtd->priv; |
727 | struct mxc_nand_host *host = nand_chip->priv; | 728 | struct mxc_nand_host *host = nand_chip->priv; |
@@ -740,11 +741,30 @@ static void mxc_nand_select_chip(struct mtd_info *mtd, int chip) | |||
740 | clk_enable(host->clk); | 741 | clk_enable(host->clk); |
741 | host->clk_act = 1; | 742 | host->clk_act = 1; |
742 | } | 743 | } |
744 | } | ||
745 | |||
746 | static void mxc_nand_select_chip_v2(struct mtd_info *mtd, int chip) | ||
747 | { | ||
748 | struct nand_chip *nand_chip = mtd->priv; | ||
749 | struct mxc_nand_host *host = nand_chip->priv; | ||
750 | |||
751 | if (chip == -1) { | ||
752 | /* Disable the NFC clock */ | ||
753 | if (host->clk_act) { | ||
754 | clk_disable(host->clk); | ||
755 | host->clk_act = 0; | ||
756 | } | ||
757 | return; | ||
758 | } | ||
743 | 759 | ||
744 | if (nfc_is_v21()) { | 760 | if (!host->clk_act) { |
745 | host->active_cs = chip; | 761 | /* Enable the NFC clock */ |
746 | writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR); | 762 | clk_enable(host->clk); |
763 | host->clk_act = 1; | ||
747 | } | 764 | } |
765 | |||
766 | host->active_cs = chip; | ||
767 | writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR); | ||
748 | } | 768 | } |
749 | 769 | ||
750 | /* | 770 | /* |
@@ -1117,6 +1137,7 @@ static const struct mxc_nand_devtype_data imx21_nand_devtype_data = { | |||
1117 | .ecclayout_512 = &nandv1_hw_eccoob_smallpage, | 1137 | .ecclayout_512 = &nandv1_hw_eccoob_smallpage, |
1118 | .ecclayout_2k = &nandv1_hw_eccoob_largepage, | 1138 | .ecclayout_2k = &nandv1_hw_eccoob_largepage, |
1119 | .ecclayout_4k = &nandv1_hw_eccoob_smallpage, /* XXX: needs fix */ | 1139 | .ecclayout_4k = &nandv1_hw_eccoob_smallpage, /* XXX: needs fix */ |
1140 | .select_chip = mxc_nand_select_chip_v1_v3, | ||
1120 | }; | 1141 | }; |
1121 | 1142 | ||
1122 | /* v21: i.MX25, i.MX35 */ | 1143 | /* v21: i.MX25, i.MX35 */ |
@@ -1133,6 +1154,7 @@ static const struct mxc_nand_devtype_data imx25_nand_devtype_data = { | |||
1133 | .ecclayout_512 = &nandv2_hw_eccoob_smallpage, | 1154 | .ecclayout_512 = &nandv2_hw_eccoob_smallpage, |
1134 | .ecclayout_2k = &nandv2_hw_eccoob_largepage, | 1155 | .ecclayout_2k = &nandv2_hw_eccoob_largepage, |
1135 | .ecclayout_4k = &nandv2_hw_eccoob_4k, | 1156 | .ecclayout_4k = &nandv2_hw_eccoob_4k, |
1157 | .select_chip = mxc_nand_select_chip_v2, | ||
1136 | }; | 1158 | }; |
1137 | 1159 | ||
1138 | /* v3: i.MX51, i.MX53 */ | 1160 | /* v3: i.MX51, i.MX53 */ |
@@ -1149,6 +1171,7 @@ static const struct mxc_nand_devtype_data imx51_nand_devtype_data = { | |||
1149 | .ecclayout_512 = &nandv2_hw_eccoob_smallpage, | 1171 | .ecclayout_512 = &nandv2_hw_eccoob_smallpage, |
1150 | .ecclayout_2k = &nandv2_hw_eccoob_largepage, | 1172 | .ecclayout_2k = &nandv2_hw_eccoob_largepage, |
1151 | .ecclayout_4k = &nandv2_hw_eccoob_smallpage, /* XXX: needs fix */ | 1173 | .ecclayout_4k = &nandv2_hw_eccoob_smallpage, /* XXX: needs fix */ |
1174 | .select_chip = mxc_nand_select_chip_v1_v3, | ||
1152 | }; | 1175 | }; |
1153 | 1176 | ||
1154 | static int __init mxcnd_probe(struct platform_device *pdev) | 1177 | static int __init mxcnd_probe(struct platform_device *pdev) |
@@ -1183,7 +1206,6 @@ static int __init mxcnd_probe(struct platform_device *pdev) | |||
1183 | this->priv = host; | 1206 | this->priv = host; |
1184 | this->dev_ready = mxc_nand_dev_ready; | 1207 | this->dev_ready = mxc_nand_dev_ready; |
1185 | this->cmdfunc = mxc_nand_command; | 1208 | this->cmdfunc = mxc_nand_command; |
1186 | this->select_chip = mxc_nand_select_chip; | ||
1187 | this->read_byte = mxc_nand_read_byte; | 1209 | this->read_byte = mxc_nand_read_byte; |
1188 | this->read_word = mxc_nand_read_word; | 1210 | this->read_word = mxc_nand_read_word; |
1189 | this->write_buf = mxc_nand_write_buf; | 1211 | this->write_buf = mxc_nand_write_buf; |
@@ -1246,6 +1268,7 @@ static int __init mxcnd_probe(struct platform_device *pdev) | |||
1246 | } else | 1268 | } else |
1247 | BUG(); | 1269 | BUG(); |
1248 | 1270 | ||
1271 | this->select_chip = host->devtype_data->select_chip; | ||
1249 | this->ecc.size = 512; | 1272 | this->ecc.size = 512; |
1250 | this->ecc.layout = host->devtype_data->ecclayout_512; | 1273 | this->ecc.layout = host->devtype_data->ecclayout_512; |
1251 | 1274 | ||