spi i.MX: Switch to clk support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
e3bc3f751d
commit
2155161eca
|
@ -21,10 +21,13 @@
|
|||
#include <xfuncs.h>
|
||||
#include <io.h>
|
||||
#include <errno.h>
|
||||
#include <malloc.h>
|
||||
#include <gpio.h>
|
||||
#include <mach/spi.h>
|
||||
#include <mach/generic.h>
|
||||
#include <mach/clock.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/err.h>
|
||||
|
||||
#define CSPI_0_0_RXDATA 0x00
|
||||
#define CSPI_0_0_TXDATA 0x04
|
||||
|
@ -128,6 +131,7 @@ struct imx_spi {
|
|||
struct spi_master master;
|
||||
int *cs_array;
|
||||
void __iomem *regs;
|
||||
struct clk *clk;
|
||||
|
||||
unsigned int (*xchg_single)(struct imx_spi *imx, u32 data);
|
||||
void (*chipselect)(struct spi_device *spi, int active);
|
||||
|
@ -276,7 +280,7 @@ static void cspi_0_7_chipselect(struct spi_device *spi, int is_active)
|
|||
return;
|
||||
}
|
||||
|
||||
reg |= spi_imx_clkdiv_2(imx_get_cspiclk(), spi->max_speed_hz) <<
|
||||
reg |= spi_imx_clkdiv_2(clk_get_rate(imx->clk), spi->max_speed_hz) <<
|
||||
CSPI_0_7_CTRL_DR_SHIFT;
|
||||
|
||||
reg |= (spi->bits_per_word - 1) << CSPI_0_7_CTRL_BL_SHIFT;
|
||||
|
@ -381,7 +385,7 @@ static void cspi_2_3_chipselect(struct spi_device *spi, int is_active)
|
|||
ctrl |= CSPI_2_3_CTRL_MODE(cs);
|
||||
|
||||
/* set clock speed */
|
||||
ctrl |= cspi_2_3_clkdiv(imx_get_cspiclk(), spi->max_speed_hz);
|
||||
ctrl |= cspi_2_3_clkdiv(clk_get_rate(imx->clk), spi->max_speed_hz);
|
||||
|
||||
/* set chip select to use */
|
||||
ctrl |= CSPI_2_3_CTRL_CS(cs);
|
||||
|
@ -524,6 +528,7 @@ static int imx_spi_probe(struct device_d *dev)
|
|||
struct imx_spi *imx;
|
||||
struct spi_imx_master *pdata = dev->platform_data;
|
||||
enum imx_spi_devtype version;
|
||||
int ret;
|
||||
|
||||
imx = xzalloc(sizeof(*imx));
|
||||
|
||||
|
@ -532,6 +537,7 @@ static int imx_spi_probe(struct device_d *dev)
|
|||
|
||||
master->setup = imx_spi_setup;
|
||||
master->transfer = imx_spi_transfer;
|
||||
|
||||
if (pdata) {
|
||||
master->num_chipselect = pdata->num_chipselect;
|
||||
imx->cs_array = pdata->chipselect;
|
||||
|
@ -540,6 +546,12 @@ static int imx_spi_probe(struct device_d *dev)
|
|||
imx_spi_dt_probe(imx);
|
||||
}
|
||||
|
||||
imx->clk = clk_get(dev, NULL);
|
||||
if (IS_ERR(imx->clk)) {
|
||||
ret = PTR_ERR(imx->clk);
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DRIVER_SPI_IMX_0_0
|
||||
if (cpu_is_mx27())
|
||||
version = SPI_IMX_VER_0_0;
|
||||
|
@ -562,6 +574,11 @@ static int imx_spi_probe(struct device_d *dev)
|
|||
spi_register_master(master);
|
||||
|
||||
return 0;
|
||||
|
||||
err_free:
|
||||
free(imx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __maybe_unused struct of_device_id imx_spi_dt_ids[] = {
|
||||
|
|
Loading…
Reference in New Issue