How to add platform specific data to a of_device

Juergen Beisert jbe at pengutronix.de
Sun Jul 15 02:31:03 EST 2007


Hi,

I'm trying to use the drivers/spi/mpc52xx_psc_spi.c as an open firmware device
(ARCH=powerpc). This device needs some platform specific data (the devices
connected to the SPI bus and how to drive the chipselects to these devices).

The driver itself get a "struct of_device *op" in his probe function and
does something like this:

struct fsl_spi_platform_data *pdata = op->dev.platform_data;

My question is: How is the correct way to bring the platform specific data
into this device structure? Is there a way to do it in the OFTree (dts file)?

Or in a way like this?

static struct fsl_spi_platform_data my_spi_master_info = {
[....]
}

static int __init my_platform_register_spi(void)
{
       struct device_node *np = NULL;
       struct of_device *of_dev;

       if ((np = of_find_compatible_node(np, "spi", "mpc5200-psc-spi")) == NULL) {
               printk("couldn't find of tree node\n");
               return -1;
       }
       if ((of_dev = of_find_device_by_node(np)) == NULL) {
               printk("couldn't find device by node\n");
               return -1;
       }

       of_dev->dev.platform_data = &my_spi_master_info;

       return 0;
}

Or is there any other way?

Regards
Juergen



More information about the Linuxppc-dev mailing list