Source
x
/*
* i.MX IIM driver
*
* Copyright (c) 2017 Pengutronix, Michael Grzeschik <m.grzeschik@pengutronix.de>
*
* Based on the barebox iim driver,
* Copyright (c) 2010 Baruch Siach <baruch@tkos.co.il>,
* Orex Computed Radiography
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* http://www.opensource.org/licenses/gpl-license.html
* http://www.gnu.org/copyleft/gpl.html
*/
struct imx_iim_drvdata {
unsigned int nregs;
};
struct iim_priv {
void __iomem *base;
struct clk *clk;
};
static int imx_iim_read(void *context, unsigned int offset,
void *buf, size_t bytes)
{
struct iim_priv *iim = context;
int i, ret;
u8 *buf8 = buf;
ret = clk_prepare_enable(iim->clk);
if (ret)
return ret;
for (i = offset; i < offset + bytes; i++) {
int bank = i >> 5;
int reg = i & 0x1f;
*buf8++ = readl(iim->base + IIM_BANK_BASE(bank) + reg * 4);
}
clk_disable_unprepare(iim->clk);
return 0;
}
static struct imx_iim_drvdata imx27_drvdata = {
.nregs = 2 * 32,
};
static struct imx_iim_drvdata imx25_imx31_imx35_drvdata = {
.nregs = 3 * 32,
};
static struct imx_iim_drvdata imx51_drvdata = {
.nregs = 4 * 32,
};
static struct imx_iim_drvdata imx53_drvdata = {
.nregs = 4 * 32 + 16,
};
static const struct of_device_id imx_iim_dt_ids[] = {
{
.compatible = "fsl,imx25-iim",
.data = &imx25_imx31_imx35_drvdata,
}, {
.compatible = "fsl,imx27-iim",
.data = &imx27_drvdata,
}, {
.compatible = "fsl,imx31-iim",
.data = &imx25_imx31_imx35_drvdata,
}, {
.compatible = "fsl,imx35-iim",
.data = &imx25_imx31_imx35_drvdata,
}, {
.compatible = "fsl,imx51-iim",