Commit f47c4bbf authored by Shawn Guo's avatar Shawn Guo Committed by Chris Ball

mmc: sdhci-esdhc-imx: create struct esdhc_soc_data

Create a struct esdhc_soc_data with moving 'flags' field from
pltfm_imx_data into it, and pass the pointer of this SoC specific data
structure through of_device_id.data directly, so that the translation
from enum imx_esdhc_type to flags can be saved.

With the change, enum imx_esdhc_type can be eliminated, since we can
implement the is_imx*_esdhc() by checking the esdhc_soc_data pointer.
The unused is_imx35_esdhc() and is_imx51_esdhc() are also removed, and the
others are kept there as we will need to use them to handle some small
register differences later, where use of new flags might be a little
overkilled.
Signed-off-by: default avatarShawn Guo <shawn.guo@linaro.org>
Acked-by: default avatarDong Aisheng <b29396@freescale.com>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent 3770ee8f
...@@ -95,22 +95,37 @@ ...@@ -95,22 +95,37 @@
*/ */
#define ESDHC_FLAG_USDHC BIT(3) #define ESDHC_FLAG_USDHC BIT(3)
enum imx_esdhc_type { struct esdhc_soc_data {
IMX25_ESDHC, u32 flags;
IMX35_ESDHC, };
IMX51_ESDHC,
IMX53_ESDHC, static struct esdhc_soc_data esdhc_imx25_data = {
IMX6Q_USDHC, .flags = ESDHC_FLAG_ENGCM07207,
};
static struct esdhc_soc_data esdhc_imx35_data = {
.flags = ESDHC_FLAG_ENGCM07207,
};
static struct esdhc_soc_data esdhc_imx51_data = {
.flags = 0,
};
static struct esdhc_soc_data esdhc_imx53_data = {
.flags = ESDHC_FLAG_MULTIBLK_NO_INT,
};
static struct esdhc_soc_data usdhc_imx6q_data = {
.flags = ESDHC_FLAG_USDHC,
}; };
struct pltfm_imx_data { struct pltfm_imx_data {
int flags;
u32 scratchpad; u32 scratchpad;
enum imx_esdhc_type devtype;
struct pinctrl *pinctrl; struct pinctrl *pinctrl;
struct pinctrl_state *pins_default; struct pinctrl_state *pins_default;
struct pinctrl_state *pins_100mhz; struct pinctrl_state *pins_100mhz;
struct pinctrl_state *pins_200mhz; struct pinctrl_state *pins_200mhz;
const struct esdhc_soc_data *socdata;
struct esdhc_platform_data boarddata; struct esdhc_platform_data boarddata;
struct clk *clk_ipg; struct clk *clk_ipg;
struct clk *clk_ahb; struct clk *clk_ahb;
...@@ -126,13 +141,13 @@ struct pltfm_imx_data { ...@@ -126,13 +141,13 @@ struct pltfm_imx_data {
static struct platform_device_id imx_esdhc_devtype[] = { static struct platform_device_id imx_esdhc_devtype[] = {
{ {
.name = "sdhci-esdhc-imx25", .name = "sdhci-esdhc-imx25",
.driver_data = IMX25_ESDHC, .driver_data = (kernel_ulong_t) &esdhc_imx25_data,
}, { }, {
.name = "sdhci-esdhc-imx35", .name = "sdhci-esdhc-imx35",
.driver_data = IMX35_ESDHC, .driver_data = (kernel_ulong_t) &esdhc_imx35_data,
}, { }, {
.name = "sdhci-esdhc-imx51", .name = "sdhci-esdhc-imx51",
.driver_data = IMX51_ESDHC, .driver_data = (kernel_ulong_t) &esdhc_imx51_data,
}, { }, {
/* sentinel */ /* sentinel */
} }
...@@ -140,43 +155,33 @@ static struct platform_device_id imx_esdhc_devtype[] = { ...@@ -140,43 +155,33 @@ static struct platform_device_id imx_esdhc_devtype[] = {
MODULE_DEVICE_TABLE(platform, imx_esdhc_devtype); MODULE_DEVICE_TABLE(platform, imx_esdhc_devtype);
static const struct of_device_id imx_esdhc_dt_ids[] = { static const struct of_device_id imx_esdhc_dt_ids[] = {
{ .compatible = "fsl,imx25-esdhc", .data = (void *) IMX25_ESDHC, }, { .compatible = "fsl,imx25-esdhc", .data = &esdhc_imx25_data, },
{ .compatible = "fsl,imx35-esdhc", .data = (void *) IMX35_ESDHC, }, { .compatible = "fsl,imx35-esdhc", .data = &esdhc_imx35_data, },
{ .compatible = "fsl,imx51-esdhc", .data = (void *) IMX51_ESDHC, }, { .compatible = "fsl,imx51-esdhc", .data = &esdhc_imx51_data, },
{ .compatible = "fsl,imx53-esdhc", .data = (void *) IMX53_ESDHC, }, { .compatible = "fsl,imx53-esdhc", .data = &esdhc_imx53_data, },
{ .compatible = "fsl,imx6q-usdhc", .data = (void *) IMX6Q_USDHC, }, { .compatible = "fsl,imx6q-usdhc", .data = &usdhc_imx6q_data, },
{ /* sentinel */ } { /* sentinel */ }
}; };
MODULE_DEVICE_TABLE(of, imx_esdhc_dt_ids); MODULE_DEVICE_TABLE(of, imx_esdhc_dt_ids);
static inline int is_imx25_esdhc(struct pltfm_imx_data *data) static inline int is_imx25_esdhc(struct pltfm_imx_data *data)
{ {
return data->devtype == IMX25_ESDHC; return data->socdata == &esdhc_imx25_data;
}
static inline int is_imx35_esdhc(struct pltfm_imx_data *data)
{
return data->devtype == IMX35_ESDHC;
}
static inline int is_imx51_esdhc(struct pltfm_imx_data *data)
{
return data->devtype == IMX51_ESDHC;
} }
static inline int is_imx53_esdhc(struct pltfm_imx_data *data) static inline int is_imx53_esdhc(struct pltfm_imx_data *data)
{ {
return data->devtype == IMX53_ESDHC; return data->socdata == &esdhc_imx53_data;
} }
static inline int is_imx6q_usdhc(struct pltfm_imx_data *data) static inline int is_imx6q_usdhc(struct pltfm_imx_data *data)
{ {
return data->devtype == IMX6Q_USDHC; return data->socdata == &usdhc_imx6q_data;
} }
static inline int esdhc_is_usdhc(struct pltfm_imx_data *data) static inline int esdhc_is_usdhc(struct pltfm_imx_data *data)
{ {
return !!(data->flags & ESDHC_FLAG_USDHC); return !!(data->socdata->flags & ESDHC_FLAG_USDHC);
} }
static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, int reg) static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, int reg)
...@@ -274,7 +279,7 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg) ...@@ -274,7 +279,7 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg)
} }
} }
if (unlikely((imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT) if (unlikely((imx_data->socdata->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
&& (reg == SDHCI_INT_STATUS) && (reg == SDHCI_INT_STATUS)
&& (val & SDHCI_INT_DATA_END))) { && (val & SDHCI_INT_DATA_END))) {
u32 v; u32 v;
...@@ -373,7 +378,7 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg) ...@@ -373,7 +378,7 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
writel(new_val , host->ioaddr + ESDHC_MIX_CTRL); writel(new_val , host->ioaddr + ESDHC_MIX_CTRL);
return; return;
case SDHCI_TRANSFER_MODE: case SDHCI_TRANSFER_MODE:
if ((imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT) if ((imx_data->socdata->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
&& (host->cmd->opcode == SD_IO_RW_EXTENDED) && (host->cmd->opcode == SD_IO_RW_EXTENDED)
&& (host->cmd->data->blocks > 1) && (host->cmd->data->blocks > 1)
&& (host->cmd->data->flags & MMC_DATA_READ)) { && (host->cmd->data->flags & MMC_DATA_READ)) {
...@@ -405,7 +410,7 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg) ...@@ -405,7 +410,7 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
val |= SDHCI_CMD_ABORTCMD; val |= SDHCI_CMD_ABORTCMD;
if ((host->cmd->opcode == MMC_SET_BLOCK_COUNT) && if ((host->cmd->opcode == MMC_SET_BLOCK_COUNT) &&
(imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT)) (imx_data->socdata->flags & ESDHC_FLAG_MULTIBLK_NO_INT))
imx_data->multiblock_status = MULTIBLK_IN_PROCESS; imx_data->multiblock_status = MULTIBLK_IN_PROCESS;
if (esdhc_is_usdhc(imx_data)) if (esdhc_is_usdhc(imx_data))
...@@ -861,16 +866,10 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) ...@@ -861,16 +866,10 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
goto free_sdhci; goto free_sdhci;
} }
imx_data->devtype = of_id ? (enum imx_esdhc_type) of_id->data : imx_data->socdata = of_id ? of_id->data : (struct esdhc_soc_data *)
pdev->id_entry->driver_data; pdev->id_entry->driver_data;
pltfm_host->priv = imx_data; pltfm_host->priv = imx_data;
if (is_imx25_esdhc(imx_data) || is_imx35_esdhc(imx_data))
imx_data->flags |= ESDHC_FLAG_ENGCM07207;
if (is_imx6q_usdhc(imx_data))
imx_data->flags |= ESDHC_FLAG_USDHC;
imx_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); imx_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
if (IS_ERR(imx_data->clk_ipg)) { if (IS_ERR(imx_data->clk_ipg)) {
err = PTR_ERR(imx_data->clk_ipg); err = PTR_ERR(imx_data->clk_ipg);
...@@ -911,14 +910,11 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) ...@@ -911,14 +910,11 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
if (imx_data->flags & ESDHC_FLAG_ENGCM07207) if (imx_data->socdata->flags & ESDHC_FLAG_ENGCM07207)
/* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */ /* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */
host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK
| SDHCI_QUIRK_BROKEN_ADMA; | SDHCI_QUIRK_BROKEN_ADMA;
if (is_imx53_esdhc(imx_data))
imx_data->flags |= ESDHC_FLAG_MULTIBLK_NO_INT;
/* /*
* The imx6q ROM code will change the default watermark level setting * The imx6q ROM code will change the default watermark level setting
* to something insane. Change it back here. * to something insane. Change it back here.
......
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