Commit ef6d2bd3 authored by Samuel Ortiz's avatar Samuel Ortiz Committed by Juha Yrjola

OMAP: McSPI: Start using resources to pass the base address

Signed-off-by: default avatarSamuel Ortiz <samuel.ortiz@solidboot.com>
Signed-off-by: default avatarJuha Yrjola <juha.yrjola@solidboot.com>
parent a69b346d
...@@ -112,29 +112,45 @@ static inline void omap_init_sti(void) {} ...@@ -112,29 +112,45 @@ static inline void omap_init_sti(void) {}
#define OMAP2_MCSPI1_BASE 0x48098000 #define OMAP2_MCSPI1_BASE 0x48098000
#define OMAP2_MCSPI2_BASE 0x4809a000 #define OMAP2_MCSPI2_BASE 0x4809a000
/* FIXME: use resources instead */
static struct omap2_mcspi_platform_config omap2_mcspi1_config = { static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
.base = io_p2v(OMAP2_MCSPI1_BASE),
.num_cs = 4, .num_cs = 4,
}; };
static struct resource omap2_mcspi1_resources[] = {
{
.start = OMAP2_MCSPI1_BASE,
.end = OMAP2_MCSPI1_BASE + 0xff,
.flags = IORESOURCE_MEM,
},
};
struct platform_device omap2_mcspi1 = { struct platform_device omap2_mcspi1 = {
.name = "omap2_mcspi", .name = "omap2_mcspi",
.id = 1, .id = 1,
.num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
.resource = omap2_mcspi1_resources,
.dev = { .dev = {
.platform_data = &omap2_mcspi1_config, .platform_data = &omap2_mcspi1_config,
}, },
}; };
static struct omap2_mcspi_platform_config omap2_mcspi2_config = { static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
.base = io_p2v(OMAP2_MCSPI2_BASE),
.num_cs = 2, .num_cs = 2,
}; };
static struct resource omap2_mcspi2_resources[] = {
{
.start = OMAP2_MCSPI2_BASE,
.end = OMAP2_MCSPI2_BASE + 0xff,
.flags = IORESOURCE_MEM,
},
};
struct platform_device omap2_mcspi2 = { struct platform_device omap2_mcspi2 = {
.name = "omap2_mcspi", .name = "omap2_mcspi",
.id = 2, .id = 2,
.num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
.resource = omap2_mcspi2_resources,
.dev = { .dev = {
.platform_data = &omap2_mcspi2_config, .platform_data = &omap2_mcspi2_config,
}, },
......
...@@ -88,6 +88,8 @@ struct omap2_mcspi { ...@@ -88,6 +88,8 @@ struct omap2_mcspi {
struct spi_master *master; struct spi_master *master;
struct clk *ick; struct clk *ick;
struct clk *fck; struct clk *fck;
/* This is the virtual base address of the module */
unsigned long base;
}; };
struct omap2_mcspi_cs { struct omap2_mcspi_cs {
...@@ -102,39 +104,38 @@ struct omap2_mcspi_cs { ...@@ -102,39 +104,38 @@ struct omap2_mcspi_cs {
val &= ~mask; \ val &= ~mask; \
} while(0) } while(0)
static inline void mcspi_write_reg(struct spi_master *master,
#define MASTER_PDATA(master) (struct omap2_mcspi_platform_config *)((master)->cdev.dev->platform_data)
static inline void mcspi_write_reg(const struct spi_master *master,
int idx, u32 val) int idx, u32 val)
{ {
struct omap2_mcspi_platform_config *pdata = MASTER_PDATA(master); struct omap2_mcspi * mcspi = class_get_devdata(&master->cdev);
__raw_writel(val, pdata->base + idx); __raw_writel(val, mcspi->base + idx);
} }
static inline u32 mcspi_read_reg(const struct spi_master *master, static inline u32 mcspi_read_reg(struct spi_master *master,
int idx) int idx)
{ {
struct omap2_mcspi_platform_config *pdata = MASTER_PDATA(master); struct omap2_mcspi * mcspi = class_get_devdata(&master->cdev);
return __raw_readl(pdata->base + idx); return __raw_readl(mcspi->base + idx);
} }
static inline void mcspi_write_cs_reg(const struct spi_device *spi, static inline void mcspi_write_cs_reg(const struct spi_device *spi,
int idx, u32 val) int idx, u32 val)
{ {
struct omap2_mcspi_platform_config *pdata = MASTER_PDATA(spi->master); struct omap2_mcspi * mcspi = class_get_devdata(&spi->master->cdev);
__raw_writel(val, pdata->base + spi->chip_select * 0x14 + idx); __raw_writel(val,
mcspi->base + spi->chip_select * 0x14 + idx);
} }
static inline u32 mcspi_read_cs_reg(const struct spi_device *spi, static inline u32 mcspi_read_cs_reg(const struct spi_device *spi,
int idx) int idx)
{ {
struct omap2_mcspi_platform_config *pdata = MASTER_PDATA(spi->master); struct omap2_mcspi * mcspi = class_get_devdata(&spi->master->cdev);
return __raw_readl(pdata->base + spi->chip_select * 0x14 + idx); return __raw_readl(mcspi->base
+ spi->chip_select * 0x14 + idx);
} }
static void omap2_mcspi_set_enable(const struct spi_device *spi, int enable) static void omap2_mcspi_set_enable(const struct spi_device *spi, int enable)
...@@ -169,12 +170,14 @@ static void omap2_mcspi_set_master_mode(struct spi_device *spi, int single_chann ...@@ -169,12 +170,14 @@ static void omap2_mcspi_set_master_mode(struct spi_device *spi, int single_chann
static void omap2_mcspi_txrx(struct spi_device *spi, struct spi_transfer *xfer) static void omap2_mcspi_txrx(struct spi_device *spi, struct spi_transfer *xfer)
{ {
struct omap2_mcspi * mcspi;
struct omap2_mcspi_cs *cs = spi->controller_state; struct omap2_mcspi_cs *cs = spi->controller_state;
unsigned int count, c; unsigned int count, c;
u32 l; u32 l;
unsigned long base, tx_reg, rx_reg, chstat_reg; unsigned long base, tx_reg, rx_reg, chstat_reg;
int word_len; int word_len;
mcspi = class_get_devdata(&spi->master->cdev);
count = xfer->len; count = xfer->len;
c = count; c = count;
word_len = cs->word_len; word_len = cs->word_len;
...@@ -191,7 +194,7 @@ static void omap2_mcspi_txrx(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -191,7 +194,7 @@ static void omap2_mcspi_txrx(struct spi_device *spi, struct spi_transfer *xfer)
/* We store the pre-calculated register addresses on stack to speed /* We store the pre-calculated register addresses on stack to speed
* up the transfer loop. */ * up the transfer loop. */
base = (MASTER_PDATA(spi->master))->base + spi->chip_select * 0x14; base = mcspi->base + spi->chip_select * 0x14;
tx_reg = base + OMAP2_MCSPI_TX0; tx_reg = base + OMAP2_MCSPI_TX0;
rx_reg = base + OMAP2_MCSPI_RX0; rx_reg = base + OMAP2_MCSPI_RX0;
chstat_reg = base + OMAP2_MCSPI_CHSTAT0; chstat_reg = base + OMAP2_MCSPI_CHSTAT0;
...@@ -486,6 +489,7 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev) ...@@ -486,6 +489,7 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
struct spi_master *master; struct spi_master *master;
struct omap2_mcspi_platform_config *pdata = pdev->dev.platform_data; struct omap2_mcspi_platform_config *pdata = pdev->dev.platform_data;
struct omap2_mcspi *mcspi; struct omap2_mcspi *mcspi;
struct resource *r;
int status = 0; int status = 0;
if (!pdata) if (!pdata)
...@@ -516,6 +520,14 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev) ...@@ -516,6 +520,14 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
mcspi = class_get_devdata(&master->cdev); mcspi = class_get_devdata(&master->cdev);
mcspi->master = master; mcspi->master = master;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (r == NULL) {
status = -ENODEV;
goto err1;
}
mcspi->base = io_p2v(r->start);
tasklet_init(&mcspi->tasklet, omap2_mcspi_work, (unsigned long) mcspi); tasklet_init(&mcspi->tasklet, omap2_mcspi_work, (unsigned long) mcspi);
spin_lock_init(&mcspi->lock); spin_lock_init(&mcspi->lock);
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#define _OMAP2_MCSPI_H #define _OMAP2_MCSPI_H
struct omap2_mcspi_platform_config { struct omap2_mcspi_platform_config {
unsigned long base;
unsigned short num_cs; unsigned short num_cs;
}; };
......
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