From: Philipp Zabel <philipp.zabel@gmail.com>
To: Paul Parsons <lost.distance@yahoo.com>
Cc: linux-kernel@vger.kernel.org, sameo@linux.intel.com
Subject: Re: [PATCH 1/2] mfd: Add ASIC3 LED support
Date: Tue, 03 May 2011 12:46:50 +0200 [thread overview]
Message-ID: <1304419612.13769.17.camel@flow> (raw)
In-Reply-To: <1304419293.13769.13.camel@flow>
Hi Paul,
This patch reverts your ASIC3_GPIOC?_LED? changes to keep the gpios as
outputs and informs the led driver via struct asic3_led of the gpio to
toggle in the brightness_set and blink_set callbacks.
Does this work for you?
regards
Philipp
---
drivers/leds/leds-asic3.c | 19 +++++++++++++++++++
drivers/mfd/asic3.c | 3 +++
include/linux/mfd/asic3.h | 8 +++++---
3 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/drivers/leds/leds-asic3.c b/drivers/leds/leds-asic3.c
index abda364..62b35dc 100644
--- a/drivers/leds/leds-asic3.c
+++ b/drivers/leds/leds-asic3.c
@@ -9,6 +9,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
+#include <linux/gpio.h>
#include <linux/leds.h>
#include <linux/slab.h>
@@ -41,10 +42,14 @@ static void brightness_set(struct led_classdev *cdev,
{
struct platform_device *pdev = to_platform_device(cdev->dev->parent);
const struct mfd_cell *cell = mfd_get_cell(pdev);
+ struct asic3_led *led = mfd_get_data(pdev);
struct asic3 *asic = dev_get_drvdata(pdev->dev.parent);
u32 timebase;
unsigned int base;
+ if (value != LED_OFF)
+ gpio_set_value(led->gpio, 1);
+
timebase = (value == LED_OFF) ? 0 : (LED_EN|0x4);
base = led_n_base[cell->id];
@@ -52,6 +57,9 @@ static void brightness_set(struct led_classdev *cdev,
asic3_write_register(asic, (base + ASIC3_LED_DutyTime), 32);
asic3_write_register(asic, (base + ASIC3_LED_AutoStopCount), 0);
asic3_write_register(asic, (base + ASIC3_LED_TimeBase), timebase);
+
+ if (value == LED_OFF)
+ gpio_set_value(led->gpio, 0);
}
static int blink_set(struct led_classdev *cdev,
@@ -60,6 +68,7 @@ static int blink_set(struct led_classdev *cdev,
{
struct platform_device *pdev = to_platform_device(cdev->dev->parent);
const struct mfd_cell *cell = mfd_get_cell(pdev);
+ struct asic3_led *led = mfd_get_data(pdev);
struct asic3 *asic = dev_get_drvdata(pdev->dev.parent);
u32 on;
u32 off;
@@ -79,6 +88,8 @@ static int blink_set(struct led_classdev *cdev,
return -EINVAL;
}
+ gpio_set_value(led->gpio, 1);
+
base = led_n_base[cell->id];
asic3_write_register(asic, (base + ASIC3_LED_PeriodTime), (on + off));
asic3_write_register(asic, (base + ASIC3_LED_DutyTime), on);
@@ -96,6 +107,10 @@ static int __devinit asic3_led_probe(struct platform_device *pdev)
struct asic3_led *led = mfd_get_data(pdev);
int ret;
+ ret = gpio_request(led->gpio, "leds-asic3");
+ if (ret < 0)
+ goto ret_gpio;
+
ret = mfd_cell_enable(pdev);
if (ret < 0)
goto ret0;
@@ -122,6 +137,8 @@ ret2:
ret1:
(void) mfd_cell_disable(pdev);
ret0:
+ gpio_free(led->gpio);
+ret_gpio:
return ret;
}
@@ -135,6 +152,8 @@ static int __devexit asic3_led_remove(struct platform_device *pdev)
(void) mfd_cell_disable(pdev);
+ gpio_free(led->gpio);
+
return 0;
}
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
index 77c10b7..5e6758d 100644
--- a/drivers/mfd/asic3.c
+++ b/drivers/mfd/asic3.c
@@ -889,6 +889,9 @@ static int __init asic3_mfd_probe(struct platform_device *pdev,
}
if (pdata->leds) {
+ pdata->leds[0].gpio = asic->gpio.base + 32; /* ASIC3_GPIOC0_LED0 */
+ pdata->leds[1].gpio = asic->gpio.base + 33; /* ASIC3_GPIOC1_LED1 */
+ pdata->leds[2].gpio = asic->gpio.base + 34; /* ASIC3_GPIOC2_LED2 */
asic3_cell_leds[0].mfd_data = &pdata->leds[0];
asic3_cell_leds[1].mfd_data = &pdata->leds[1];
asic3_cell_leds[2].mfd_data = &pdata->leds[2];
diff --git a/include/linux/mfd/asic3.h b/include/linux/mfd/asic3.h
index d0dd3eb..f1944ef 100644
--- a/include/linux/mfd/asic3.h
+++ b/include/linux/mfd/asic3.h
@@ -21,6 +21,8 @@ struct asic3_led {
const char *name;
const char *default_trigger;
struct led_classdev *cdev;
+
+ int gpio; /* set by the asic3 mfd driver itself */
};
struct asic3_platform_data {
@@ -120,9 +122,9 @@ struct asic3_platform_data {
#define ASIC3_GPIOA11_PWM0 ASIC3_CONFIG_GPIO(11, 1, 1, 0)
#define ASIC3_GPIOA12_PWM1 ASIC3_CONFIG_GPIO(12, 1, 1, 0)
#define ASIC3_GPIOA15_CONTROL_CX ASIC3_CONFIG_GPIO(15, 1, 1, 0)
-#define ASIC3_GPIOC0_LED0 ASIC3_CONFIG_GPIO(32, 1, 0, 0)
-#define ASIC3_GPIOC1_LED1 ASIC3_CONFIG_GPIO(33, 1, 0, 0)
-#define ASIC3_GPIOC2_LED2 ASIC3_CONFIG_GPIO(34, 1, 0, 0)
+#define ASIC3_GPIOC0_LED0 ASIC3_CONFIG_GPIO(32, 1, 1, 0)
+#define ASIC3_GPIOC1_LED1 ASIC3_CONFIG_GPIO(33, 1, 1, 0)
+#define ASIC3_GPIOC2_LED2 ASIC3_CONFIG_GPIO(34, 1, 1, 0)
#define ASIC3_GPIOC3_SPI_RXD ASIC3_CONFIG_GPIO(35, 1, 0, 0)
#define ASIC3_GPIOC4_CF_nCD ASIC3_CONFIG_GPIO(36, 1, 0, 0)
#define ASIC3_GPIOC4_SPI_TXD ASIC3_CONFIG_GPIO(36, 1, 1, 0)
--
1.7.4.4
next prev parent reply other threads:[~2011-05-03 10:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-30 17:59 [PATCH 1/2] mfd: Add ASIC3 LED support Paul Parsons
2011-05-02 15:39 ` Samuel Ortiz
2011-05-02 22:16 ` Paul Parsons
2011-05-03 8:33 ` Samuel Ortiz
2011-05-03 10:41 ` Philipp Zabel
2011-05-03 10:46 ` Philipp Zabel [this message]
2011-05-03 15:38 ` Paul Parsons
2011-05-03 19:46 ` Paul Parsons
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1304419612.13769.17.camel@flow \
--to=philipp.zabel@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lost.distance@yahoo.com \
--cc=sameo@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.