From: Samuel Ortiz Date: Wed, 28 Jun 2006 09:27:05 +0000 (+0300) Subject: OMAP: McSPI: Start using resources to pass the base address X-Git-Tag: v2.6.17-omap1^2~3 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=ef6d2bd327914a209cd7642ac10750aa4d772cc3;p=linux-2.6-omap-h63xx.git OMAP: McSPI: Start using resources to pass the base address Signed-off-by: Samuel Ortiz Signed-off-by: Juha Yrjola --- diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index 5139677e426..6b2b3c3ddea 100644 --- a/arch/arm/mach-omap2/devices.c +++ b/arch/arm/mach-omap2/devices.c @@ -112,29 +112,45 @@ static inline void omap_init_sti(void) {} #define OMAP2_MCSPI1_BASE 0x48098000 #define OMAP2_MCSPI2_BASE 0x4809a000 -/* FIXME: use resources instead */ - static struct omap2_mcspi_platform_config omap2_mcspi1_config = { - .base = io_p2v(OMAP2_MCSPI1_BASE), .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 = { .name = "omap2_mcspi", .id = 1, + .num_resources = ARRAY_SIZE(omap2_mcspi1_resources), + .resource = omap2_mcspi1_resources, .dev = { .platform_data = &omap2_mcspi1_config, }, }; static struct omap2_mcspi_platform_config omap2_mcspi2_config = { - .base = io_p2v(OMAP2_MCSPI2_BASE), .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 = { .name = "omap2_mcspi", .id = 2, + .num_resources = ARRAY_SIZE(omap2_mcspi2_resources), + .resource = omap2_mcspi2_resources, .dev = { .platform_data = &omap2_mcspi2_config, }, diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c index 1a72872d695..aeda4f4d1ae 100644 --- a/drivers/spi/omap2_mcspi.c +++ b/drivers/spi/omap2_mcspi.c @@ -88,6 +88,8 @@ struct omap2_mcspi { struct spi_master *master; struct clk *ick; struct clk *fck; + /* This is the virtual base address of the module */ + unsigned long base; }; struct omap2_mcspi_cs { @@ -102,39 +104,38 @@ struct omap2_mcspi_cs { val &= ~mask; \ } while(0) - -#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, +static inline void mcspi_write_reg(struct spi_master *master, 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) { - 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, 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, 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) @@ -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) { + struct omap2_mcspi * mcspi; struct omap2_mcspi_cs *cs = spi->controller_state; unsigned int count, c; u32 l; unsigned long base, tx_reg, rx_reg, chstat_reg; int word_len; + mcspi = class_get_devdata(&spi->master->cdev); count = xfer->len; c = count; word_len = cs->word_len; @@ -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 * 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; rx_reg = base + OMAP2_MCSPI_RX0; chstat_reg = base + OMAP2_MCSPI_CHSTAT0; @@ -486,6 +489,7 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev) struct spi_master *master; struct omap2_mcspi_platform_config *pdata = pdev->dev.platform_data; struct omap2_mcspi *mcspi; + struct resource *r; int status = 0; if (!pdata) @@ -516,6 +520,14 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev) mcspi = class_get_devdata(&master->cdev); 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); spin_lock_init(&mcspi->lock); diff --git a/include/asm-arm/arch-omap/mcspi.h b/include/asm-arm/arch-omap/mcspi.h index 9e7f40a88e1..1254e4945b6 100644 --- a/include/asm-arm/arch-omap/mcspi.h +++ b/include/asm-arm/arch-omap/mcspi.h @@ -2,7 +2,6 @@ #define _OMAP2_MCSPI_H struct omap2_mcspi_platform_config { - unsigned long base; unsigned short num_cs; };