9
0
Fork 0

spi: omap: encode register offset into device_id

The omap3 and omap4/am33xx spi cores differ in the offset of the
registers in the address space. Instead of encoding this into the
resources use the platform_device_id mechanism. This is done in
preparation for devicetree probe support where the address space
is in the devicetree and can't be adjusted.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2013-11-19 14:04:12 +01:00
parent 26c725874b
commit 1869803405
3 changed files with 42 additions and 4 deletions

View File

@ -45,7 +45,7 @@ static inline struct device_d *am33xx_add_cpsw(struct cpsw_platform_data *cpsw_d
static inline struct device_d *am33xx_add_spi(int id, resource_size_t start)
{
return add_generic_device("omap3_spi", id, NULL, start + 0x100, SZ_4K - 0x100,
return add_generic_device("omap4-spi", id, NULL, start, SZ_4K,
IORESOURCE_MEM, NULL);
}

View File

@ -49,6 +49,10 @@
#define SPI_XFER_BEGIN 0x01 /* Assert CS before transfer */
#define SPI_XFER_END 0x02 /* Deassert CS after transfer */
struct omap_spi_drvdata {
unsigned register_offset;
};
static void spi_reset(struct spi_master *master)
{
struct omap3_spi_master *omap3_master = container_of(master, struct omap3_spi_master, master);
@ -343,6 +347,12 @@ static int omap3_spi_probe(struct device_d *dev)
{
struct spi_master *master;
struct omap3_spi_master *omap3_master;
struct omap_spi_drvdata *devtype;
int ret;
ret = dev_get_drvdata(dev, (unsigned long *)&devtype);
if (ret)
return ret;
omap3_master = xzalloc(sizeof(*omap3_master));
@ -374,7 +384,10 @@ static int omap3_spi_probe(struct device_d *dev)
master->setup = omap3_spi_setup;
master->transfer = omap3_spi_transfer;
omap3_master->regs = dev_request_mem_region(dev, 0);
omap3_master->base = dev_request_mem_region(dev, 0);
omap3_master->regs = omap3_master->base;
omap3_master->regs += devtype->register_offset;
spi_reset(master);
@ -383,8 +396,29 @@ static int omap3_spi_probe(struct device_d *dev)
return 0;
}
static struct omap_spi_drvdata omap3_data = {
.register_offset = 0x0,
};
static struct omap_spi_drvdata omap4_data = {
.register_offset = 0x100,
};
static struct platform_device_id omap_spi_ids[] = {
{
.name = "omap3-spi",
.driver_data = (unsigned long)&omap3_data,
}, {
.name = "omap4-spi",
.driver_data = (unsigned long)&omap4_data,
}, {
/* sentinel */
},
};
static struct driver_d omap3_spi_driver = {
.name = "omap3_spi",
.name = "omap-spi",
.probe = omap3_spi_probe,
.id_table = omap_spi_ids,
};
device_platform_driver(omap3_spi_driver);

View File

@ -88,7 +88,11 @@
struct omap3_spi_master {
struct spi_master master;
void __iomem *regs;
void __iomem *base; /* base of address space */
void __iomem *regs; /* actual start of registers, omap4/am33xx have an
* offset of 0x100 between start of register space
* and registers
*/
};
#endif /* _OMAP3_SPI_H_ */