Re: [PATCH/RFC 6/8] leds: Add support for max77693 mfd flash cell

2014-03-21 Thread Jacek Anaszewski

On 03/20/2014 04:34 PM, Lee Jones wrote:

On Thu, 20 Mar 2014, Jacek Anaszewski wrote:


This patch adds led-flash support to Maxim max77693 chipset.
Device can be exposed to user space through LED subsystem
sysfs interface or through V4L2 subdevice when the support
for Multimedia Framework is enabled. Device supports up to
two leds which can work in flash and torch mode. Leds can
be triggered externally or by software.

Signed-off-by: Andrzej Hajda a.ha...@samsung.com
Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Bryan Wu coolo...@gmail.com
Cc: Richard Purdie rpur...@rpsys.net
Cc: SangYoung Son hello@smasung.com
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Lee Jones lee.jo...@linaro.org
---
  drivers/leds/Kconfig |9 +
  drivers/leds/Makefile|1 +
  drivers/leds/leds-max77693.c |  768 ++
  drivers/mfd/max77693.c   |   21 +-
  include/linux/mfd/max77693.h |   32 ++
  5 files changed, 825 insertions(+), 6 deletions(-)
  create mode 100644 drivers/leds/leds-max77693.c


[...]


diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c
index c5535f0..6fa92d3 100644
--- a/drivers/mfd/max77693.c
+++ b/drivers/mfd/max77693.c
@@ -41,12 +41,21 @@
  #define I2C_ADDR_MUIC (0x4A  1)
  #define I2C_ADDR_HAPTIC   (0x90  1)

-static const struct mfd_cell max77693_devs[] = {
-   { .name = max77693-pmic, },
-   { .name = max77693-charger, },
-   { .name = max77693-flash, },
-   { .name = max77693-muic, },
-   { .name = max77693-haptic, },
+enum mfd_devs_idx {
+   IDX_PMIC,
+   IDX_CHARGER,
+   IDX_LED,
+   IDX_MUIC,
+   IDX_HAPTIC,
+};
+
+static struct mfd_cell max77693_devs[] = {
+   [IDX_PMIC]  = { .name = max77693-pmic, },
+   [IDX_CHARGER]   = { .name = max77693-charger, },
+   [IDX_LED]   = { .name = max77693-led,
+   .of_compatible = maxim,max77693-led},
+   [IDX_MUIC]  = { .name = max77693-muic, },
+   [IDX_HAPTIC]= { .name = max77693-haptic, },
  };


What is the purpose of this change?



Introducing mfd_devs_idx itself is a cosmetic change, which
actually could be avoided. Initialization of the of_compatible field
is required for the led driver to get matched properly. And as I've
just realized also max77693-flash name should be preserved.
I will fix this in the next version of the patch.

Thanks,
Jacek Anaszewski
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFC 6/8] leds: Add support for max77693 mfd flash cell

2014-03-21 Thread Lee Jones
 This patch adds led-flash support to Maxim max77693 chipset.
 Device can be exposed to user space through LED subsystem
 sysfs interface or through V4L2 subdevice when the support
 for Multimedia Framework is enabled. Device supports up to
 two leds which can work in flash and torch mode. Leds can
 be triggered externally or by software.
 
 Signed-off-by: Andrzej Hajda a.ha...@samsung.com
 Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
 Acked-by: Kyungmin Park kyungmin.p...@samsung.com
 Cc: Bryan Wu coolo...@gmail.com
 Cc: Richard Purdie rpur...@rpsys.net
 Cc: SangYoung Son hello@smasung.com
 Cc: Samuel Ortiz sa...@linux.intel.com
 Cc: Lee Jones lee.jo...@linaro.org
 ---
   drivers/leds/Kconfig |9 +
   drivers/leds/Makefile|1 +
   drivers/leds/leds-max77693.c |  768 
  ++
   drivers/mfd/max77693.c   |   21 +-
   include/linux/mfd/max77693.h |   32 ++
   5 files changed, 825 insertions(+), 6 deletions(-)
   create mode 100644 drivers/leds/leds-max77693.c
 
 [...]
 -static const struct mfd_cell max77693_devs[] = {
 -   { .name = max77693-pmic, },
 -   { .name = max77693-charger, },
 -   { .name = max77693-flash, },
 -   { .name = max77693-muic, },
 -   { .name = max77693-haptic, },
 +enum mfd_devs_idx {
 +   IDX_PMIC,
 +   IDX_CHARGER,
 +   IDX_LED,
 +   IDX_MUIC,
 +   IDX_HAPTIC,
 +};
 +
 +static struct mfd_cell max77693_devs[] = {
 +   [IDX_PMIC]  = { .name = max77693-pmic, },
 +   [IDX_CHARGER]   = { .name = max77693-charger, },
 +   [IDX_LED]   = { .name = max77693-led,
 +   .of_compatible = maxim,max77693-led},
 +   [IDX_MUIC]  = { .name = max77693-muic, },
 +   [IDX_HAPTIC]= { .name = max77693-haptic, },
   };
 
 What is the purpose of this change?
 
 Introducing mfd_devs_idx itself is a cosmetic change, which
 actually could be avoided. Initialization of the of_compatible field
 is required for the led driver to get matched properly. And as I've
 just realized also max77693-flash name should be preserved.
 I will fix this in the next version of the patch.

I'm happy with the addition of any .of_compatible strings, however
please leave out the IDXs in your next version(s).

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH/RFC 6/8] leds: Add support for max77693 mfd flash cell

2014-03-20 Thread Jacek Anaszewski
This patch adds led-flash support to Maxim max77693 chipset.
Device can be exposed to user space through LED subsystem
sysfs interface or through V4L2 subdevice when the support
for Multimedia Framework is enabled. Device supports up to
two leds which can work in flash and torch mode. Leds can
be triggered externally or by software.

Signed-off-by: Andrzej Hajda a.ha...@samsung.com
Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Bryan Wu coolo...@gmail.com
Cc: Richard Purdie rpur...@rpsys.net
Cc: SangYoung Son hello@smasung.com
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Lee Jones lee.jo...@linaro.org
---
 drivers/leds/Kconfig |9 +
 drivers/leds/Makefile|1 +
 drivers/leds/leds-max77693.c |  768 ++
 drivers/mfd/max77693.c   |   21 +-
 include/linux/mfd/max77693.h |   32 ++
 5 files changed, 825 insertions(+), 6 deletions(-)
 create mode 100644 drivers/leds/leds-max77693.c

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 2062682..f2d0e2c 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -454,6 +454,15 @@ config LEDS_TCA6507
  LED driver chips accessed via the I2C bus.
  Driver support brightness control and hardware-assisted blinking.
 
+config LEDS_MAX77693
+   tristate LED support for MAX77693 Flash
+   depends on MFD_MAX77693
+   depends on OF
+   help
+ This option enables support for the flash part of the MAX77693
+ multifunction device. It has build in control for two leds in flash
+ and torch mode.
+
 config LEDS_MAX8997
tristate LED support for MAX8997 PMIC
depends on LEDS_CLASS  MFD_MAX8997
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 3cd76db..597585f 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_LEDS_MC13783)+= leds-mc13783.o
 obj-$(CONFIG_LEDS_NS2) += leds-ns2.o
 obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o
 obj-$(CONFIG_LEDS_ASIC3)   += leds-asic3.o
+obj-$(CONFIG_LEDS_MAX77693)+= leds-max77693.o
 obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o
 obj-$(CONFIG_LEDS_LM355x)  += leds-lm355x.o
 obj-$(CONFIG_LEDS_BLINKM)  += leds-blinkm.o
diff --git a/drivers/leds/leds-max77693.c b/drivers/leds/leds-max77693.c
new file mode 100644
index 000..8b5daa1
--- /dev/null
+++ b/drivers/leds/leds-max77693.c
@@ -0,0 +1,768 @@
+/*
+ * Copyright (C) 2014, Samsung Electronics Co., Ltd.
+ *
+ * Authors: Andrzej Hajda a.ha...@samsung.com
+ *  Jacek Anaszewski j.anaszew...@samsung.com
+ *
+ * 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.
+ */
+
+#include linux/slab.h
+#include linux/platform_device.h
+#include linux/module.h
+#include linux/leds.h
+#include linux/mfd/max77693.h
+#include linux/mfd/max77693-private.h
+#include linux/mutex.h
+#include linux/workqueue.h
+#include asm/div64.h
+
+#include media/v4l2-flash.h
+
+#define MAX77693_LED_NAME  max77693-led
+
+#define MAX77693_TORCH_IOUT_BITS   4
+
+#define MAX77693_TORCH_NO_TIMER0x40
+#define MAX77693_FLASH_TIMER_LEVEL 0x80
+
+#define MAX77693_FLASH_EN_OFF  0
+#define MAX77693_FLASH_EN_FLASH1
+#define MAX77693_FLASH_EN_TORCH2
+#define MAX77693_FLASH_EN_ON   3
+
+#define MAX77693_FLASH_EN1_SHIFT   6
+#define MAX77693_FLASH_EN2_SHIFT   4
+#define MAX77693_TORCH_EN1_SHIFT   2
+#define MAX77693_TORCH_EN2_SHIFT   0
+
+#define MAX77693_FLASH_LOW_BATTERY_EN  0x80
+
+#define MAX77693_FLASH_BOOST_FIXED 0x04
+#define MAX77693_FLASH_BOOST_LEDNUM_2  0x80
+
+#define MAX77693_FLASH_TIMEOUT_MIN 62500
+#define MAX77693_FLASH_TIMEOUT_MAX 100
+#define MAX77693_FLASH_TIMEOUT_STEP62500
+
+#define MAX77693_TORCH_TIMEOUT_MIN 262000
+#define MAX77693_TORCH_TIMEOUT_MAX 15728000
+
+#define MAX77693_FLASH_IOUT_MIN15625
+#define MAX77693_FLASH_IOUT_MAX_1LED   100
+#define MAX77693_FLASH_IOUT_MAX_2LEDS  625000
+#define MAX77693_FLASH_IOUT_STEP   15625
+
+#define MAX77693_TORCH_IOUT_MIN15625
+#define MAX77693_TORCH_IOUT_MAX25
+#define MAX77693_TORCH_IOUT_STEP   15625
+
+#define MAX77693_FLASH_VSYS_MIN2400
+#define MAX77693_FLASH_VSYS_MAX3400
+#define MAX77693_FLASH_VSYS_STEP   33
+
+#define MAX77693_FLASH_VOUT_MIN3300
+#define MAX77693_FLASH_VOUT_MAX5500
+#define MAX77693_FLASH_VOUT_STEP   25
+#define MAX77693_FLASH_VOUT_RMIN   0x0c
+
+#define MAX77693_LED_STATUS_FLASH_ON   (1  3)
+#define MAX77693_LED_STATUS_TORCH_ON   (1  2)
+
+#define MAX77693_LED_FLASH_INT_FLED2_OPEN  

Re: [PATCH/RFC 6/8] leds: Add support for max77693 mfd flash cell

2014-03-20 Thread Lee Jones
On Thu, 20 Mar 2014, Jacek Anaszewski wrote:

 This patch adds led-flash support to Maxim max77693 chipset.
 Device can be exposed to user space through LED subsystem
 sysfs interface or through V4L2 subdevice when the support
 for Multimedia Framework is enabled. Device supports up to
 two leds which can work in flash and torch mode. Leds can
 be triggered externally or by software.
 
 Signed-off-by: Andrzej Hajda a.ha...@samsung.com
 Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
 Acked-by: Kyungmin Park kyungmin.p...@samsung.com
 Cc: Bryan Wu coolo...@gmail.com
 Cc: Richard Purdie rpur...@rpsys.net
 Cc: SangYoung Son hello@smasung.com
 Cc: Samuel Ortiz sa...@linux.intel.com
 Cc: Lee Jones lee.jo...@linaro.org
 ---
  drivers/leds/Kconfig |9 +
  drivers/leds/Makefile|1 +
  drivers/leds/leds-max77693.c |  768 
 ++
  drivers/mfd/max77693.c   |   21 +-
  include/linux/mfd/max77693.h |   32 ++
  5 files changed, 825 insertions(+), 6 deletions(-)
  create mode 100644 drivers/leds/leds-max77693.c

[...]

 diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c
 index c5535f0..6fa92d3 100644
 --- a/drivers/mfd/max77693.c
 +++ b/drivers/mfd/max77693.c
 @@ -41,12 +41,21 @@
  #define I2C_ADDR_MUIC(0x4A  1)
  #define I2C_ADDR_HAPTIC  (0x90  1)
  
 -static const struct mfd_cell max77693_devs[] = {
 - { .name = max77693-pmic, },
 - { .name = max77693-charger, },
 - { .name = max77693-flash, },
 - { .name = max77693-muic, },
 - { .name = max77693-haptic, },
 +enum mfd_devs_idx {
 + IDX_PMIC,
 + IDX_CHARGER,
 + IDX_LED,
 + IDX_MUIC,
 + IDX_HAPTIC,
 +};
 +
 +static struct mfd_cell max77693_devs[] = {
 + [IDX_PMIC]  = { .name = max77693-pmic, },
 + [IDX_CHARGER]   = { .name = max77693-charger, },
 + [IDX_LED]   = { .name = max77693-led,
 + .of_compatible = maxim,max77693-led},
 + [IDX_MUIC]  = { .name = max77693-muic, },
 + [IDX_HAPTIC]= { .name = max77693-haptic, },
  };

What is the purpose of this change?

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html