RE: [PATCH v2] mfd: ADP5520 Multifunction LCD Backlight and Keypad Input Device Driver

Hennerich, Michael
2009-10-02T14:39:10Z

>With 2 of those devices, your board file would look like that:
>
>static struct i2c_board_info __initdata board_i2c_board_info[] = {
> { /* APD5520 #1 */
> I2C_BOARD_INFO("pmic-adp5520", SLAVE_ADDR_1),
> .platform_data = &apd5520_platform_1,
> },
> { /* APD5520 #2 */
> I2C_BOARD_INFO("pmic-adp5520", SLAVE_ADDR_2),
> .platform_data = &apd5520_platform_2,
> },
>};
>
>and your platform data would be an aggregation of all subdevices
platform data
>structures:
>
>struct adp5520_platform_data {
> struct adp5520_leds_platfrom_data *leds;
> struct adp5520_keys_platfrom_data *keyp;
> struct adp5520_gpio_platfrom_data *gpio;
>}
>
>Then, your mfd/adp5520.c will have that piece of code:
>
>static struct platform_device adp5520_gpio_device = {
> .name = "adp5520-gpio",
> .id = -1,
>}
>
>static struct platform_device *adp5520_subdevs[] = {
> &adp5520_gpio_device,
> &adp5520_leds_device,
> &adp5520_keyp_device,
>}
>
>Finally, your i2c probe routine would assign platform_data pointers to
te
>right devices:
>
>static int __devinit adp5520_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
>{
> struct adp5520_platform_data *pdata = client->dev.platform_data;
>[...]
> for (i = 0; i < ARRAY_SIZE(adp5520_subdevs); i++) {
> adp5520_subdevs[i]->dev.parent = &client->dev;
> adp5520_assign_pdata(&adp5520_subdevs[i], pdata);
> }
>
> platform_add_devices(adp5520_subdevs,
> ARRAY_SIZE(adp5520_subdevs));
>}
>
>Where adp5520_assign_pdata() is a routine setting the platform_device's
>platform_data pointer according e.g. to the platform_device name field.
>
>Would that make sense to you ?
>
>Cheers,
>Samuel.

I think that should work.
Thanks,

Michael