On Mon, Sep 24, 2012 at 2:53 PM, Peter Meerwald <pmeerw@xxxxxxxxxx> wrote: > From: Peter Meerwald <p.meerwald@xxxxxxxxxxxxxxxxxx> > > the pca9633 leds driver can be used in open-drain or totem pole (a.k.a. > push/pull) output driver mode; default is the later > > the patch allows to set the output driver mode using platform data (similar to > configuration inferface provided by the tca6507 led driver) > > v2: move leds-pca9633.h to include/linux/platform_data/ (Bryan Wu) > Thanks, I applied it to my for-next branch. -Bryan > Signed-off-by: Peter Meerwald <p.meerwald@xxxxxxxxxxxxxxxxxx> > --- > drivers/leds/leds-pca9633.c | 19 +++++++++------ > include/linux/platform_data/leds-pca9633.h | 35 ++++++++++++++++++++++++++++ > 2 files changed, 47 insertions(+), 7 deletions(-) > create mode 100644 include/linux/platform_data/leds-pca9633.h > > diff --git a/drivers/leds/leds-pca9633.c b/drivers/leds/leds-pca9633.c > index edcd706..2f2f9c4 100644 > --- a/drivers/leds/leds-pca9633.c > +++ b/drivers/leds/leds-pca9633.c > @@ -22,6 +22,7 @@ > #include <linux/i2c.h> > #include <linux/workqueue.h> > #include <linux/slab.h> > +#include <linux/platform_data/leds-pca9633.h> > > /* LED select registers determine the source that drives LED outputs */ > #define PCA9633_LED_OFF 0x0 /* LED driver off */ > @@ -96,13 +97,13 @@ static int __devinit pca9633_probe(struct i2c_client *client, > const struct i2c_device_id *id) > { > struct pca9633_led *pca9633; > - struct led_platform_data *pdata; > + struct pca9633_platform_data *pdata; > int i, err; > > pdata = client->dev.platform_data; > > if (pdata) { > - if (pdata->num_leds <= 0 || pdata->num_leds > 4) { > + if (pdata->leds.num_leds <= 0 || pdata->leds.num_leds > 4) { > dev_err(&client->dev, "board info must claim at most 4 LEDs"); > return -EINVAL; > } > @@ -119,14 +120,14 @@ static int __devinit pca9633_probe(struct i2c_client *client, > pca9633[i].led_num = i; > > /* Platform data can specify LED names and default triggers */ > - if (pdata && i < pdata->num_leds) { > - if (pdata->leds[i].name) > + if (pdata && i < pdata->leds.num_leds) { > + if (pdata->leds.leds[i].name) > snprintf(pca9633[i].name, > sizeof(pca9633[i].name), "pca9633:%s", > - pdata->leds[i].name); > - if (pdata->leds[i].default_trigger) > + pdata->leds.leds[i].name); > + if (pdata->leds.leds[i].default_trigger) > pca9633[i].led_cdev.default_trigger = > - pdata->leds[i].default_trigger; > + pdata->leds.leds[i].default_trigger; > } else { > snprintf(pca9633[i].name, sizeof(pca9633[i].name), > "pca9633:%d", i); > @@ -145,6 +146,10 @@ static int __devinit pca9633_probe(struct i2c_client *client, > /* Disable LED all-call address and set normal mode */ > i2c_smbus_write_byte_data(client, PCA9633_MODE1, 0x00); > > + /* Configure output: open-drain or totem pole (push-pull) */ > + if (pdata && pdata->outdrv == PCA9633_OPEN_DRAIN) > + i2c_smbus_write_byte_data(client, PCA9633_MODE2, 0x01); > + > /* Turn off LEDs */ > i2c_smbus_write_byte_data(client, PCA9633_LEDOUT, 0x00); > > diff --git a/include/linux/platform_data/leds-pca9633.h b/include/linux/platform_data/leds-pca9633.h > new file mode 100644 > index 0000000..c5bf29b > --- /dev/null > +++ b/include/linux/platform_data/leds-pca9633.h > @@ -0,0 +1,35 @@ > +/* > + * PCA9633 LED chip driver. > + * > + * Copyright 2012 bct electronic GmbH > + * > + * This program is free software; you can redistribute it and/or > + * modify it under the terms of the GNU General Public License > + * version 2 as published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, but > + * WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA > + * 02110-1301 USA > + */ > + > +#ifndef __LINUX_PCA9633_H > +#define __LINUX_PCA9633_H > +#include <linux/leds.h> > + > +enum pca9633_outdrv { > + PCA9633_OPEN_DRAIN, > + PCA9633_TOTEM_POLE, /* aka push-pull */ > +}; > + > +struct pca9633_platform_data { > + struct led_platform_data leds; > + enum pca9633_outdrv outdrv; > +}; > + > +#endif /* __LINUX_PCA9633_H*/ > -- > 1.7.9.5 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-leds" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Bryan Wu <bryan.wu@xxxxxxxxxxxxx> Kernel Developer +86.186-168-78255 Mobile Canonical Ltd. www.canonical.com Ubuntu - Linux for human beings | www.ubuntu.com -- To unsubscribe from this list: send the line "unsubscribe linux-leds" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html