[PATCH v7 2/3] leds: pwm: add support for default-state device property

2020-07-31 Thread Denis Osterland-Heim
This patch adds support for "default-state" devicetree property, which
allows to defer pwm init to first use of led.

This allows to configure the PWM early in bootloader to let the LED
blink until an application in Linux userspace sets something different.

Signed-off-by: Denis Osterland-Heim 
Acked-by: Jacek Anaszewski 
---
 drivers/leds/leds-pwm.c | 49 -
 1 file changed, 43 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index ef7b91bd2064..0c0470c90d5d 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -17,11 +17,13 @@
 #include 
 #include 
 #include 
+#include "leds.h"
 
 struct led_pwm {
const char  *name;
const char  *default_trigger;
u8  active_low;
+   u8  default_state;
unsigned intmax_brightness;
 };
 
@@ -88,7 +90,38 @@ static int led_pwm_add(struct device *dev, struct 
led_pwm_priv *priv,
 
led_data->cdev.brightness_set_blocking = led_pwm_set;
 
-   pwm_init_state(led_data->pwm, _data->pwmstate);
+   /* init PWM state */
+   switch (led->default_state) {
+   case LEDS_DEFSTATE_KEEP:
+   pwm_get_state(led_data->pwm, _data->pwmstate);
+   if (led_data->pwmstate.period)
+   break;
+   led->default_state = LEDS_DEFSTATE_OFF;
+   dev_warn(dev,
+   "failed to read period for %s, default to off",
+   led->name);
+   fallthrough;
+   default:
+   pwm_init_state(led_data->pwm, _data->pwmstate);
+   break;
+   }
+
+   /* set brightness */
+   switch (led->default_state) {
+   case LEDS_DEFSTATE_ON:
+   led_data->cdev.brightness = led->max_brightness;
+   break;
+   case LEDS_DEFSTATE_KEEP:
+   {
+   uint64_t brightness;
+
+   brightness = led->max_brightness;
+   brightness *= led_data->pwmstate.duty_cycle;
+   do_div(brightness, led_data->pwmstate.period);
+   led_data->cdev.brightness = brightness;
+   }
+   break;
+   }
 
ret = devm_led_classdev_register(dev, _data->cdev);
if (ret) {
@@ -97,11 +130,13 @@ static int led_pwm_add(struct device *dev, struct 
led_pwm_priv *priv,
return ret;
}
 
-   ret = led_pwm_set(_data->cdev, led_data->cdev.brightness);
-   if (ret) {
-   dev_err(dev, "failed to set led PWM value for %s: %d",
-   led->name, ret);
-   return ret;
+   if (led->default_state != LEDS_DEFSTATE_KEEP) {
+   ret = led_pwm_set(_data->cdev, led_data->cdev.brightness);
+   if (ret) {
+   dev_err(dev, "failed to set led PWM value for %s: %d",
+   led->name, ret);
+   return ret;
+   }
}
 
priv->num_leds++;
@@ -134,6 +169,8 @@ static int led_pwm_create_fwnode(struct device *dev, struct 
led_pwm_priv *priv)
fwnode_property_read_u32(fwnode, "max-brightness",
 _brightness);
 
+   led.default_state = led_init_default_state_get(fwnode);
+
ret = led_pwm_add(dev, priv, , fwnode);
if (ret) {
fwnode_handle_put(fwnode);
-- 
2.28.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
- Informationen zum Datenschutz, insbesondere zu Ihren Rechten, erhalten Sie 
unter https://www.diehl.com/group/de/transparenz-und-informationspflichten/

The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 
- For general information on data protection and your respective rights please 
visit https://www.diehl.com/group/en/transparency-and-information-obligations/


[PATCH v7 3/3] leds: pwm: add reference to common leds for default-state

2020-07-31 Thread Denis Osterland-Heim
The default-state is now supported for PWM leds.

Signed-off-by: Denis Osterland-Heim 
Acked-by: Jacek Anaszewski 
Acked-by: Pavel Machek 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/leds/leds-pwm.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/leds-pwm.txt 
b/Documentation/devicetree/bindings/leds/leds-pwm.txt
index 6c6583c35f2f..d0f489680594 100644
--- a/Documentation/devicetree/bindings/leds/leds-pwm.txt
+++ b/Documentation/devicetree/bindings/leds/leds-pwm.txt
@@ -19,6 +19,8 @@ LED sub-node properties:
   see Documentation/devicetree/bindings/leds/common.txt
 - linux,default-trigger :  (optional)
   see Documentation/devicetree/bindings/leds/common.txt
+- default-state : (optional)
+  see Documentation/devicetree/bindings/leds/common.yaml
 
 Example:
 
-- 
2.28.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
- Informationen zum Datenschutz, insbesondere zu Ihren Rechten, erhalten Sie 
unter https://www.diehl.com/group/de/transparenz-und-informationspflichten/

The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 
- For general information on data protection and your respective rights please 
visit https://www.diehl.com/group/en/transparency-and-information-obligations/


[PATCH v7 0/3] leds: pwm: add support for default-state device

2020-07-31 Thread Denis Osterland-Heim
v6 -> v7: apply comments from Jacek
   refactore default state read to separate function
   and use it in leds-gpio and leds-pwm

@Pavel I hope that it is okay to keep your acked-by on 2/3,
   the logic is the same but with switch, in favour of if

 .../devicetree/bindings/leds/leds-pwm.txt  |  2 +
 drivers/leds/led-core.c| 15 +++
 drivers/leds/leds-gpio.c   | 12 +-
 drivers/leds/leds-pwm.c| 49 +++---
 drivers/leds/leds.h|  1 +
 include/linux/leds.h   | 12 --
 6 files changed, 72 insertions(+), 19 deletions(-)

Message-Id: <20200713054259.7608-1-denis.osterl...@diehl.com>
base-commit: 2742b4192a279c6ec72e55d5474c4c07756c7845




Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
- Informationen zum Datenschutz, insbesondere zu Ihren Rechten, erhalten Sie 
unter https://www.diehl.com/group/de/transparenz-und-informationspflichten/

The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 
- For general information on data protection and your respective rights please 
visit https://www.diehl.com/group/en/transparency-and-information-obligations/


[PATCH v7 1/3] leds: move default_state read from fwnode to core

2020-07-31 Thread Denis Osterland-Heim
This patch introduces a new function to read initial
default_state from fwnode.

Signed-off-by: Denis Osterland-Heim 
---
 drivers/leds/led-core.c  | 15 +++
 drivers/leds/leds-gpio.c | 12 ++--
 drivers/leds/leds.h  |  1 +
 include/linux/leds.h | 12 +---
 4 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 846248a0693d..0ef220c154e4 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -478,3 +478,18 @@ int led_compose_name(struct device *dev, struct 
led_init_data *init_data,
return 0;
 }
 EXPORT_SYMBOL_GPL(led_compose_name);
+
+enum led_default_state led_init_default_state_get(struct fwnode_handle *fwnode)
+{
+   const char *state = NULL;
+
+   if (!fwnode_property_read_string(fwnode, "default-state", )) {
+   if (!strcmp(state, "keep"))
+   return LEDS_DEFSTATE_KEEP;
+   if (!strcmp(state, "on"))
+   return LEDS_DEFSTATE_ON;
+   }
+
+   return LEDS_DEFSTATE_OFF;
+}
+EXPORT_SYMBOL_GPL(led_init_default_state_get);
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index cf84096d88ce..564a7f497ac0 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include "leds.h"
 
 struct gpio_led_data {
struct led_classdev cdev;
@@ -143,7 +144,6 @@ static struct gpio_leds_priv *gpio_leds_create(struct 
platform_device *pdev)
device_for_each_child_node(dev, child) {
struct gpio_led_data *led_dat = >leds[priv->num_leds];
struct gpio_led led = {};
-   const char *state = NULL;
 
/*
 * Acquire gpiod from DT with uninitialized label, which
@@ -163,15 +163,7 @@ static struct gpio_leds_priv *gpio_leds_create(struct 
platform_device *pdev)
fwnode_property_read_string(child, "linux,default-trigger",
_trigger);
 
-   if (!fwnode_property_read_string(child, "default-state",
-)) {
-   if (!strcmp(state, "keep"))
-   led.default_state = LEDS_GPIO_DEFSTATE_KEEP;
-   else if (!strcmp(state, "on"))
-   led.default_state = LEDS_GPIO_DEFSTATE_ON;
-   else
-   led.default_state = LEDS_GPIO_DEFSTATE_OFF;
-   }
+   led.default_state = led_init_default_state_get(child);
 
if (fwnode_property_present(child, "retain-state-suspended"))
led.retain_state_suspended = 1;
diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h
index 2d9eb48bbed9..73451f64e916 100644
--- a/drivers/leds/leds.h
+++ b/drivers/leds/leds.h
@@ -29,6 +29,7 @@ ssize_t led_trigger_read(struct file *filp, struct kobject 
*kobj,
 ssize_t led_trigger_write(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr, char *buf,
loff_t pos, size_t count);
+enum led_default_state led_init_default_state_get(struct fwnode_handle 
*fwnode);
 
 extern struct rw_semaphore leds_list_lock;
 extern struct list_head leds_list;
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 6a8d6409c993..db16c3ebc6b4 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -33,6 +33,12 @@ enum led_brightness {
LED_FULL= 255,
 };
 
+enum led_default_state {
+   LEDS_DEFSTATE_OFF   = 0,
+   LEDS_DEFSTATE_ON= 1,
+   LEDS_DEFSTATE_KEEP  = 2,
+};
+
 struct led_init_data {
/* device fwnode handle */
struct fwnode_handle *fwnode;
@@ -522,9 +528,9 @@ struct gpio_led {
/* default_state should be one of LEDS_GPIO_DEFSTATE_(ON|OFF|KEEP) */
struct gpio_desc *gpiod;
 };
-#define LEDS_GPIO_DEFSTATE_OFF 0
-#define LEDS_GPIO_DEFSTATE_ON  1
-#define LEDS_GPIO_DEFSTATE_KEEP2
+#define LEDS_GPIO_DEFSTATE_OFF LEDS_DEFSTATE_OFF
+#define LEDS_GPIO_DEFSTATE_ON  LEDS_DEFSTATE_ON
+#define LEDS_GPIO_DEFSTATE_KEEPLEDS_DEFSTATE_KEEP
 
 struct gpio_led_platform_data {
int num_leds;
-- 
2.28.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall di

Re: [PATCH v6 1/2] leds: pwm: add support for default-state device property

2020-07-22 Thread Denis Osterland-Heim
Hi Pavel,

Am Mittwoch, den 22.07.2020, 16:04 +0200 schrieb Pavel Machek:
> > This patch adds support for "default-state" devicetree property, which
> > allows to defer pwm init to first use of led.
> > 
> > This allows to configure the PWM early in bootloader to let the LED
> > blink until an application in Linux userspace sets something different.
> > 
> > Signed-off-by: Denis Osterland-Heim 
> > Acked-by: Jacek Anaszewski 
> > +#define LEDS_PWM_DEFSTATE_OFF  0
> > +#define LEDS_PWM_DEFSTATE_ON   1
> > +#define LEDS_PWM_DEFSTATE_KEEP 2
> 
> Turn this into enum; no need for prefix as this is private to the driver.
> 
> >  struct led_pwm {
> > const char  *name;
> > const char  *default_trigger;
> > u8  active_low;
> > +   u8  default_state;
> > unsigned intmax_brightness;
> >  };
> >  
> > @@ -88,7 +93,30 @@ static int led_pwm_add(struct device *dev, struct 
> > led_pwm_priv *priv,
> >  
> > led_data->cdev.brightness_set_blocking = led_pwm_set;
> >  
> > -   pwm_init_state(led_data->pwm, _data->pwmstate);
> > +   /* init PWM state */
> > +   if (led->default_state == LEDS_PWM_DEFSTATE_KEEP) {
> > +   pwm_get_state(led_data->pwm, _data->pwmstate);
> > +   if (!led_data->pwmstate.period) {
> > +   led->default_state = LEDS_PWM_DEFSTATE_OFF;
> > +   dev_warn(dev,
> > +   "failed to read period for %s, default to off",
> > +   led->name);
> > +   }
> > +   }
> > +   if (led->default_state != LEDS_PWM_DEFSTATE_KEEP)
> > +   pwm_init_state(led_data->pwm, _data->pwmstate);
> > +
> > +   /* set brightness */
> > +   if (led->default_state == LEDS_PWM_DEFSTATE_ON)
> > +   led_data->cdev.brightness = led->max_brightness;
> > +   else if (led->default_state == LEDS_PWM_DEFSTATE_KEEP) {
> > +   uint64_t brightness;
> > +
> > +   brightness = led->max_brightness;
> > +   brightness *= led_data->pwmstate.duty_cycle;
> > +   do_div(brightness, led_data->pwmstate.period);
> > +   led_data->cdev.brightness = brightness;
> > +   }
> 
> Try to clean this up... switch() might help. Maybe two of them.
looks possible, lets see if it improves readability

> 
> > @@ -134,6 +166,16 @@ static int led_pwm_create_fwnode(struct device *dev, 
> > struct led_pwm_priv *priv)
> > fwnode_property_read_u32(fwnode, "max-brightness",
> >  _brightness);
> >  
> > +   if (!fwnode_property_read_string(fwnode, "default-state",
> > +)) {
> > +   if (!strcmp(state, "keep"))
> > +   led.default_state = LEDS_PWM_DEFSTATE_KEEP;
> > +   else if (!strcmp(state, "on"))
> > +   led.default_state = LEDS_PWM_DEFSTATE_ON;
> > +   else
> > +   led.default_state = LEDS_PWM_DEFSTATE_OFF;
> > +   }
> 
> Actually... Move the enum to core, and add helper for this. We don't
> want to see this duplicated.
I think I should put the refactoring into a separate patch.

This code duplicates leds-gpio, which uses the LEDS_GPIO_DEFSTATE_* defines,
defined in include/linux/leds.h.
The I idea was to let gpio its defines and add dt compatible defines for 
leds-pwm.
But it would be useful to have a common function, yes.

It looks like a enum leds_default_state with the define for leds-gpio changed
to the new enum in linux/leds.h and a new function declaration 
leds_defstate_get()
in leds/leds.h, with the implementation led-core.c. And leds-gpio and leds-pwm
will then include leds/leds.h to use leds_defstate_get().

> 
> > The contents of the above mentioned e-mail is not legally binding. This 
> > e-mail contains confidential and/or legally protected information. Please 
> > inform us if you have received this e-mail by
> > mistake and delete it in such a case. Each unauthorized reproduction, 
> > disclosure, alteration, distribution and/or publication of this e-mail is 
> > strictly prohibited. 
> > - For general information on data protection and your respective rights 
> > please visit 
> > https://www.diehl.com/group/en/transparency-and-information-obligations/
> 
> Get rid of this.
my force is not strong enough..

[PATCH v6 0/2] leds: pwm: add support for default-state device

2020-07-12 Thread Denis Osterland-Heim
v5 -> v6: tested the rebase to v5.8-rc2 based for-next

 .../devicetree/bindings/leds/leds-pwm.txt  |  2 +
 drivers/leds/leds-pwm.c| 54 +++---
 2 files changed, 50 insertions(+), 6 deletions(-)

Message-Id: <20200421130644.16059-1-denis.osterl...@diehl.com>
base-commit: cf1a1a6a7d81d73bcb5568b23572d6fd593add87





Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
- Informationen zum Datenschutz, insbesondere zu Ihren Rechten, erhalten Sie 
unter https://www.diehl.com/group/de/transparenz-und-informationspflichten/

The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 
- For general information on data protection and your respective rights please 
visit https://www.diehl.com/group/en/transparency-and-information-obligations/


[PATCH v6 2/2] leds: pwm: add reference to common leds for default-state

2020-07-12 Thread Denis Osterland-Heim
The default-state is now supported for PWM leds.

Signed-off-by: Denis Osterland-Heim 
Acked-by: Jacek Anaszewski 
Acked-by: Pavel Machek 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/leds/leds-pwm.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/leds-pwm.txt 
b/Documentation/devicetree/bindings/leds/leds-pwm.txt
index 6c6583c35f2f..d0f489680594 100644
--- a/Documentation/devicetree/bindings/leds/leds-pwm.txt
+++ b/Documentation/devicetree/bindings/leds/leds-pwm.txt
@@ -19,6 +19,8 @@ LED sub-node properties:
   see Documentation/devicetree/bindings/leds/common.txt
 - linux,default-trigger :  (optional)
   see Documentation/devicetree/bindings/leds/common.txt
+- default-state : (optional)
+  see Documentation/devicetree/bindings/leds/common.yaml
 
 Example:
 
-- 
2.27.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
- Informationen zum Datenschutz, insbesondere zu Ihren Rechten, erhalten Sie 
unter https://www.diehl.com/group/de/transparenz-und-informationspflichten/

The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 
- For general information on data protection and your respective rights please 
visit https://www.diehl.com/group/en/transparency-and-information-obligations/


[PATCH v6 1/2] leds: pwm: add support for default-state device property

2020-07-12 Thread Denis Osterland-Heim
This patch adds support for "default-state" devicetree property, which
allows to defer pwm init to first use of led.

This allows to configure the PWM early in bootloader to let the LED
blink until an application in Linux userspace sets something different.

Signed-off-by: Denis Osterland-Heim 
Acked-by: Jacek Anaszewski 
---
 drivers/leds/leds-pwm.c | 54 -
 1 file changed, 48 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index ef7b91bd2064..7b199c151768 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -18,10 +18,15 @@
 #include 
 #include 
 
+#define LEDS_PWM_DEFSTATE_OFF  0
+#define LEDS_PWM_DEFSTATE_ON   1
+#define LEDS_PWM_DEFSTATE_KEEP 2
+
 struct led_pwm {
const char  *name;
const char  *default_trigger;
u8  active_low;
+   u8  default_state;
unsigned intmax_brightness;
 };
 
@@ -88,7 +93,30 @@ static int led_pwm_add(struct device *dev, struct 
led_pwm_priv *priv,
 
led_data->cdev.brightness_set_blocking = led_pwm_set;
 
-   pwm_init_state(led_data->pwm, _data->pwmstate);
+   /* init PWM state */
+   if (led->default_state == LEDS_PWM_DEFSTATE_KEEP) {
+   pwm_get_state(led_data->pwm, _data->pwmstate);
+   if (!led_data->pwmstate.period) {
+   led->default_state = LEDS_PWM_DEFSTATE_OFF;
+   dev_warn(dev,
+   "failed to read period for %s, default to off",
+   led->name);
+   }
+   }
+   if (led->default_state != LEDS_PWM_DEFSTATE_KEEP)
+   pwm_init_state(led_data->pwm, _data->pwmstate);
+
+   /* set brightness */
+   if (led->default_state == LEDS_PWM_DEFSTATE_ON)
+   led_data->cdev.brightness = led->max_brightness;
+   else if (led->default_state == LEDS_PWM_DEFSTATE_KEEP) {
+   uint64_t brightness;
+
+   brightness = led->max_brightness;
+   brightness *= led_data->pwmstate.duty_cycle;
+   do_div(brightness, led_data->pwmstate.period);
+   led_data->cdev.brightness = brightness;
+   }
 
ret = devm_led_classdev_register(dev, _data->cdev);
if (ret) {
@@ -97,11 +125,13 @@ static int led_pwm_add(struct device *dev, struct 
led_pwm_priv *priv,
return ret;
}
 
-   ret = led_pwm_set(_data->cdev, led_data->cdev.brightness);
-   if (ret) {
-   dev_err(dev, "failed to set led PWM value for %s: %d",
-   led->name, ret);
-   return ret;
+   if (led->default_state != LEDS_PWM_DEFSTATE_KEEP) {
+   ret = led_pwm_set(_data->cdev, led_data->cdev.brightness);
+   if (ret) {
+   dev_err(dev, "failed to set led PWM value for %s: %d",
+   led->name, ret);
+   return ret;
+   }
}
 
priv->num_leds++;
@@ -117,6 +147,8 @@ static int led_pwm_create_fwnode(struct device *dev, struct 
led_pwm_priv *priv)
memset(, 0, sizeof(led));
 
device_for_each_child_node(dev, fwnode) {
+   const char *state = NULL;
+
ret = fwnode_property_read_string(fwnode, "label", );
if (ret && is_of_node(fwnode))
led.name = to_of_node(fwnode)->name;
@@ -134,6 +166,16 @@ static int led_pwm_create_fwnode(struct device *dev, 
struct led_pwm_priv *priv)
fwnode_property_read_u32(fwnode, "max-brightness",
 _brightness);
 
+   if (!fwnode_property_read_string(fwnode, "default-state",
+)) {
+   if (!strcmp(state, "keep"))
+   led.default_state = LEDS_PWM_DEFSTATE_KEEP;
+   else if (!strcmp(state, "on"))
+   led.default_state = LEDS_PWM_DEFSTATE_ON;
+   else
+   led.default_state = LEDS_PWM_DEFSTATE_OFF;
+   }
+
ret = led_pwm_add(dev, priv, , fwnode);
if (ret) {
fwnode_handle_put(fwnode);
-- 
2.27.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, we

Re: [PATCH v3 2/3] leds: pwm: add support for default-state device property

2020-06-08 Thread Denis Osterland-Heim
Hi Jacek,

is your ack still valid for the new versions of the patch-set?
Due to the changes I made, I am not sure.

Regards, Denis

Am Dienstag, den 17.03.2020, 21:43 +0100 schrieb Jacek Anaszewski:
> Hi Denis,
> 
> On 3/16/20 9:24 PM, Denis Osterland-Heim wrote:
> > Hi Jacek,
> > 
> > Am Montag, den 16.03.2020, 19:36 +0100 schrieb Jacek Anaszewski:
> > > Hi Denis,
> > > 
> > > On 3/16/20 1:53 PM, Denis Osterland-Heim wrote:
> > 
> > ...
> > > >  
> > > > @@ -92,13 +96,27 @@ static int led_pwm_add(struct device *dev, struct 
> > > > led_pwm_priv *priv,
> > > >  
> > > > pwm_init_state(led_data->pwm, _data->pwmstate);
> > > >  
> > > > +   if (led->default_state == LEDS_PWM_DEFSTATE_ON)
> > > > +   led_data->cdev.brightness = led->max_brightness;
> > > > +   else if (led->default_state == LEDS_PWM_DEFSTATE_KEEP) {
> > > > +   uint64_t brightness;
> > > > +
> > > > +   pwm_get_state(led_data->pwm, _data->pwmstate);
> > > 
> > > This seems to not be reading the device state, i.e. what you tried
> > > to address by direct call to pwm->chip->ops->get_state() before.
> > > 
> > > Am I missing something?
> > > 
> > 
> > well, not you, but I missed cfc4c189bc70b1acc17e6f1abf1dc1c0ae890bd8.
> > Since this commit pwm_get_state() is sufficient.
> 
> I assume you tested it?
> 
> With that, for the whole set:
> 
> Acked-by: Jacek Anaszewski 
> 


Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
- Informationen zum Datenschutz, insbesondere zu Ihren Rechten, erhalten Sie 
unter https://www.diehl.com/group/de/transparenz-und-informationspflichten/

The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 
- For general information on data protection and your respective rights please 
visit https://www.diehl.com/group/en/transparency-and-information-obligations/


Re: [PATCH] rtc: isl1208: access i2c client via rtc parent

2018-09-28 Thread Denis OSTERLAND
Am Freitag, den 28.09.2018, 14:04 +0200 schrieb Alexandre Belloni:
> Hello,
> 
> Oh right, I actually had that but somehow, I stashed the patch instead
> of squashing it.
> 
> If that is fine for you, I'll fold that in the original patch (I'll ad
> your SoB).
> 
> 
Sounds good.

Regards Denis

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


Re: [PATCH] rtc: isl1208: access i2c client via rtc parent

2018-09-28 Thread Denis OSTERLAND
Am Freitag, den 28.09.2018, 14:04 +0200 schrieb Alexandre Belloni:
> Hello,
> 
> Oh right, I actually had that but somehow, I stashed the patch instead
> of squashing it.
> 
> If that is fine for you, I'll fold that in the original patch (I'll ad
> your SoB).
> 
> 
Sounds good.

Regards Denis

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH] rtc: isl1208: access i2c client via rtc parent

2018-09-28 Thread Denis OSTERLAND
From: Denis Osterland 

The move of atrim, dtrim usr sysfs properties from i2c device
to rtc device require to access them via dev->parent.
This patch also aligns timestamp0.

Fixes: 03df75dd03301307ec578ccd4e8c1c0117b8e65c
Signed-off-by: Denis Osterland 
---
 drivers/rtc/rtc-isl1208.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 15094df12985..ec5ef518a09b 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -517,7 +517,7 @@ static ssize_t timestamp0_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
 {
-   struct i2c_client *client = dev_get_drvdata(dev);
+   struct i2c_client *client = to_i2c_client(dev->parent);
int sr;
 
sr = isl1208_i2c_get_sr(client);
@@ -539,7 +539,7 @@ static ssize_t timestamp0_store(struct device *dev,
 static ssize_t timestamp0_show(struct device *dev,
   struct device_attribute *attr, char *buf)
 {
-   struct i2c_client *client = dev_get_drvdata(dev);
+   struct i2c_client *client = to_i2c_client(dev->parent);
u8 regs[ISL1219_EVT_SECTION_LEN] = { 0, };
struct rtc_time tm;
int sr;
@@ -649,7 +649,7 @@ static ssize_t
 isl1208_sysfs_show_atrim(struct device *dev,
 struct device_attribute *attr, char *buf)
 {
-   int atr = isl1208_i2c_get_atr(to_i2c_client(dev));
+   int atr = isl1208_i2c_get_atr(to_i2c_client(dev->parent));
if (atr < 0)
return atr;
 
@@ -662,7 +662,7 @@ static ssize_t
 isl1208_sysfs_show_dtrim(struct device *dev,
 struct device_attribute *attr, char *buf)
 {
-   int dtr = isl1208_i2c_get_dtr(to_i2c_client(dev));
+   int dtr = isl1208_i2c_get_dtr(to_i2c_client(dev->parent));
if (dtr < 0)
return dtr;
 
@@ -675,7 +675,7 @@ static ssize_t
 isl1208_sysfs_show_usr(struct device *dev,
   struct device_attribute *attr, char *buf)
 {
-   int usr = isl1208_i2c_get_usr(to_i2c_client(dev));
+   int usr = isl1208_i2c_get_usr(to_i2c_client(dev->parent));
if (usr < 0)
return usr;
 
@@ -700,7 +700,10 @@ isl1208_sysfs_store_usr(struct device *dev,
if (usr < 0 || usr > 0x)
return -EINVAL;
 
-   return isl1208_i2c_set_usr(to_i2c_client(dev), usr) ? -EIO : count;
+   if (isl1208_i2c_set_usr(to_i2c_client(dev->parent), usr))
+   return -EIO;
+
+   return count;
 }
 
 static DEVICE_ATTR(usr, S_IRUGO | S_IWUSR, isl1208_sysfs_show_usr,
@@ -764,7 +767,6 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
rtc->ops = _rtc_ops;
 
i2c_set_clientdata(client, rtc);
-   dev_set_drvdata(>dev, client);
 
rc = isl1208_i2c_get_sr(client);
if (rc < 0) {
-- 
2.19.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH] rtc: isl1208: access i2c client via rtc parent

2018-09-28 Thread Denis OSTERLAND
From: Denis Osterland 

The move of atrim, dtrim usr sysfs properties from i2c device
to rtc device require to access them via dev->parent.
This patch also aligns timestamp0.

Fixes: 03df75dd03301307ec578ccd4e8c1c0117b8e65c
Signed-off-by: Denis Osterland 
---
 drivers/rtc/rtc-isl1208.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 15094df12985..ec5ef518a09b 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -517,7 +517,7 @@ static ssize_t timestamp0_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
 {
-   struct i2c_client *client = dev_get_drvdata(dev);
+   struct i2c_client *client = to_i2c_client(dev->parent);
int sr;
 
sr = isl1208_i2c_get_sr(client);
@@ -539,7 +539,7 @@ static ssize_t timestamp0_store(struct device *dev,
 static ssize_t timestamp0_show(struct device *dev,
   struct device_attribute *attr, char *buf)
 {
-   struct i2c_client *client = dev_get_drvdata(dev);
+   struct i2c_client *client = to_i2c_client(dev->parent);
u8 regs[ISL1219_EVT_SECTION_LEN] = { 0, };
struct rtc_time tm;
int sr;
@@ -649,7 +649,7 @@ static ssize_t
 isl1208_sysfs_show_atrim(struct device *dev,
 struct device_attribute *attr, char *buf)
 {
-   int atr = isl1208_i2c_get_atr(to_i2c_client(dev));
+   int atr = isl1208_i2c_get_atr(to_i2c_client(dev->parent));
if (atr < 0)
return atr;
 
@@ -662,7 +662,7 @@ static ssize_t
 isl1208_sysfs_show_dtrim(struct device *dev,
 struct device_attribute *attr, char *buf)
 {
-   int dtr = isl1208_i2c_get_dtr(to_i2c_client(dev));
+   int dtr = isl1208_i2c_get_dtr(to_i2c_client(dev->parent));
if (dtr < 0)
return dtr;
 
@@ -675,7 +675,7 @@ static ssize_t
 isl1208_sysfs_show_usr(struct device *dev,
   struct device_attribute *attr, char *buf)
 {
-   int usr = isl1208_i2c_get_usr(to_i2c_client(dev));
+   int usr = isl1208_i2c_get_usr(to_i2c_client(dev->parent));
if (usr < 0)
return usr;
 
@@ -700,7 +700,10 @@ isl1208_sysfs_store_usr(struct device *dev,
if (usr < 0 || usr > 0x)
return -EINVAL;
 
-   return isl1208_i2c_set_usr(to_i2c_client(dev), usr) ? -EIO : count;
+   if (isl1208_i2c_set_usr(to_i2c_client(dev->parent), usr))
+   return -EIO;
+
+   return count;
 }
 
 static DEVICE_ATTR(usr, S_IRUGO | S_IWUSR, isl1208_sysfs_show_usr,
@@ -764,7 +767,6 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
rtc->ops = _rtc_ops;
 
i2c_set_clientdata(client, rtc);
-   dev_set_drvdata(>dev, client);
 
rc = isl1208_i2c_get_sr(client);
if (rc < 0) {
-- 
2.19.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


Re: rtc: isl1208: avoid possible sysfs race

2018-09-25 Thread Denis OSTERLAND
Hi,

just for clarification:
This changes user-space representation from
/sys/class/rtc/rtcN/device/{atrim,dtrim,usr}
to
/sys/class/rtc/rtcN/{atrim,dtrim,usr}
and fixes the "mistake made back in 2006" you mention in
https://patchwork.ozlabs.org/patch/881397/
correct?

Regards Denis

Am Samstag, den 15.09.2018, 13:43 +0200 schrieb Alexandre Belloni:
> Use rtc_add_group to add the common sysfs group to avoid a possible race
> condition.
> 
> Signed-off-by: Alexandre Belloni 
> ---
>  drivers/rtc/rtc-isl1208.c | 11 +--
>  1 file changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
> index ea18a8f4bce0..e1e9434c9972 100644
> --- a/drivers/rtc/rtc-isl1208.c
> +++ b/drivers/rtc/rtc-isl1208.c
> @@ -804,7 +804,7 @@ isl1208_probe(struct i2c_client *client, const struct 
> i2c_device_id *id)
>   evdet_irq = of_irq_get_byname(np, "evdet");
>   }
>  
> - rc = sysfs_create_group(>dev.kobj, _rtc_sysfs_files);
> + rc = rtc_add_group(rtc, _rtc_sysfs_files);
>   if (rc)
>   return rc;
>  
> @@ -821,14 +821,6 @@ isl1208_probe(struct i2c_client *client, const struct 
> i2c_device_id *id)
>   return rtc_register_device(rtc);
>  }
>  
> -static int
> -isl1208_remove(struct i2c_client *client)
> -{
> - sysfs_remove_group(>dev.kobj, _rtc_sysfs_files);
> -
> - return 0;
> -}
> -
>  static const struct i2c_device_id isl1208_id[] = {
>   { "isl1208", TYPE_ISL1208 },
>   { "isl1218", TYPE_ISL1218 },
> @@ -851,7 +843,6 @@ static struct i2c_driver isl1208_driver = {
>   .of_match_table = of_match_ptr(isl1208_of_match),
>   },
>   .probe = isl1208_probe,
> - .remove = isl1208_remove,
>   .id_table = isl1208_id,
>  };
>  

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


Re: rtc: isl1208: avoid possible sysfs race

2018-09-25 Thread Denis OSTERLAND
Hi,

just for clarification:
This changes user-space representation from
/sys/class/rtc/rtcN/device/{atrim,dtrim,usr}
to
/sys/class/rtc/rtcN/{atrim,dtrim,usr}
and fixes the "mistake made back in 2006" you mention in
https://patchwork.ozlabs.org/patch/881397/
correct?

Regards Denis

Am Samstag, den 15.09.2018, 13:43 +0200 schrieb Alexandre Belloni:
> Use rtc_add_group to add the common sysfs group to avoid a possible race
> condition.
> 
> Signed-off-by: Alexandre Belloni 
> ---
>  drivers/rtc/rtc-isl1208.c | 11 +--
>  1 file changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
> index ea18a8f4bce0..e1e9434c9972 100644
> --- a/drivers/rtc/rtc-isl1208.c
> +++ b/drivers/rtc/rtc-isl1208.c
> @@ -804,7 +804,7 @@ isl1208_probe(struct i2c_client *client, const struct 
> i2c_device_id *id)
>   evdet_irq = of_irq_get_byname(np, "evdet");
>   }
>  
> - rc = sysfs_create_group(>dev.kobj, _rtc_sysfs_files);
> + rc = rtc_add_group(rtc, _rtc_sysfs_files);
>   if (rc)
>   return rc;
>  
> @@ -821,14 +821,6 @@ isl1208_probe(struct i2c_client *client, const struct 
> i2c_device_id *id)
>   return rtc_register_device(rtc);
>  }
>  
> -static int
> -isl1208_remove(struct i2c_client *client)
> -{
> - sysfs_remove_group(>dev.kobj, _rtc_sysfs_files);
> -
> - return 0;
> -}
> -
>  static const struct i2c_device_id isl1208_id[] = {
>   { "isl1208", TYPE_ISL1208 },
>   { "isl1218", TYPE_ISL1218 },
> @@ -851,7 +843,6 @@ static struct i2c_driver isl1208_driver = {
>   .of_match_table = of_match_ptr(isl1208_of_match),
>   },
>   .probe = isl1208_probe,
> - .remove = isl1208_remove,
>   .id_table = isl1208_id,
>  };
>  

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v5 2/5] rtc: isl1208: add support for isl1219 with tamper detection

2018-07-24 Thread Denis OSTERLAND
From: Michael Grzeschik 

We add support for the ISL1219 chip that got an integrated tamper
detection function. This patch implements the feature by adding
an additional timestamp0 file to sysfs device path.
This file contains seconds since epoch, if an event occurred,
or is empty, if none occurred.

Signed-off-by: Michael Grzeschik 
Signed-off-by: Denis Osterland 
---
 drivers/rtc/rtc-isl1208.c | 131 --
 1 file changed, 124 insertions(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 1a2c38cc0178..3150ebdcb179 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include "rtc-core.h"
 
 /* Register map */
 /* rtc section */
@@ -33,13 +34,15 @@
 #define ISL1208_REG_SR_ARST(1<<7)  /* auto reset */
 #define ISL1208_REG_SR_XTOSCB  (1<<6)  /* crystal oscillator */
 #define ISL1208_REG_SR_WRTC(1<<4)  /* write rtc */
+#define ISL1208_REG_SR_EVT (1<<3)  /* event */
 #define ISL1208_REG_SR_ALM (1<<2)  /* alarm */
 #define ISL1208_REG_SR_BAT (1<<1)  /* battery */
 #define ISL1208_REG_SR_RTCF(1<<0)  /* rtc fail */
 #define ISL1208_REG_INT 0x08
 #define ISL1208_REG_INT_ALME   (1<<6)   /* alarm enable */
 #define ISL1208_REG_INT_IM (1<<7)   /* interrupt/alarm mode */
-#define ISL1208_REG_09  0x09   /* reserved */
+#define ISL1219_REG_EV  0x09
+#define ISL1219_REG_EV_EVEN(1<<4)   /* event detection enable */
 #define ISL1208_REG_ATR 0x0a
 #define ISL1208_REG_DTR 0x0b
 
@@ -57,8 +60,24 @@
 #define ISL1208_REG_USR2 0x13
 #define ISL1208_USR_SECTION_LEN 2
 
+/* event section */
+#define ISL1219_REG_SCT 0x14
+#define ISL1219_REG_MNT 0x15
+#define ISL1219_REG_HRT 0x16
+#define ISL1219_REG_DTT 0x17
+#define ISL1219_REG_MOT 0x18
+#define ISL1219_REG_YRT 0x19
+#define ISL1219_EVT_SECTION_LEN 6
+
 static struct i2c_driver isl1208_driver;
 
+/* ISL1208 various variants */
+enum {
+   TYPE_ISL1208 = 0,
+   TYPE_ISL1218,
+   TYPE_ISL1219,
+};
+
 /* block read */
 static int
 isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[],
@@ -80,8 +99,8 @@ isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 
buf[],
};
int ret;
 
-   BUG_ON(reg > ISL1208_REG_USR2);
-   BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
+   WARN_ON(reg > ISL1219_REG_YRT);
+   WARN_ON(reg + len > ISL1219_REG_YRT + 1);
 
ret = i2c_transfer(client->adapter, msgs, 2);
if (ret > 0)
@@ -104,8 +123,8 @@ isl1208_i2c_set_regs(struct i2c_client *client, u8 reg, u8 
const buf[],
};
int ret;
 
-   BUG_ON(reg > ISL1208_REG_USR2);
-   BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
+   WARN_ON(reg > ISL1219_REG_YRT);
+   WARN_ON(reg + len > ISL1219_REG_YRT + 1);
 
i2c_buf[0] = reg;
memcpy(_buf[1], [0], len);
@@ -493,6 +512,73 @@ isl1208_rtc_set_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
return isl1208_i2c_set_alarm(to_i2c_client(dev), alarm);
 }
 
+static ssize_t timestamp0_store(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct i2c_client *client = dev_get_drvdata(dev);
+   int sr;
+
+   sr = isl1208_i2c_get_sr(client);
+   if (sr < 0) {
+   dev_err(dev, "%s: reading SR failed\n", __func__);
+   return sr;
+   }
+
+   sr &= ~ISL1208_REG_SR_EVT;
+
+   sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr);
+   if (sr < 0)
+   dev_err(dev, "%s: writing SR failed\n",
+   __func__);
+
+   return count;
+};
+
+static ssize_t timestamp0_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct i2c_client *client = dev_get_drvdata(dev);
+   u8 regs[ISL1219_EVT_SECTION_LEN] = { 0, };
+   struct rtc_time tm;
+   int sr;
+
+   sr = isl1208_i2c_get_sr(client);
+   if (sr < 0) {
+   dev_err(dev, "%s: reading SR failed\n", __func__);
+   return sr;
+   }
+
+   if (!(sr & ISL1208_REG_SR_EVT))
+   return 0;
+
+   sr = isl1208_i2c_read_regs(client, ISL1219_REG_SCT, regs,
+  ISL1219_EVT_SECTION_LEN);
+   if (sr < 0) {
+   dev_err(dev, "%s: reading event section failed\n",
+   __func__);
+   return 0;
+   }
+
+   /* MSB of each alarm register is an enable bit */
+   tm.tm_sec = bcd2bin(regs[ISL1219_REG_SCT - ISL1219_REG_SCT] & 0x7f);
+   tm.tm_min = bcd2bin(regs[ISL1219_REG_MNT - ISL1219_REG_SCT] & 0x7f);
+   tm.tm_hour = bcd2bin(regs[ISL1219_REG_HRT - ISL1219_REG_SCT] & 0x3f);
+   tm.tm_mday = bcd2bin(regs[IS

[PATCH v5 2/5] rtc: isl1208: add support for isl1219 with tamper detection

2018-07-24 Thread Denis OSTERLAND
From: Michael Grzeschik 

We add support for the ISL1219 chip that got an integrated tamper
detection function. This patch implements the feature by adding
an additional timestamp0 file to sysfs device path.
This file contains seconds since epoch, if an event occurred,
or is empty, if none occurred.

Signed-off-by: Michael Grzeschik 
Signed-off-by: Denis Osterland 
---
 drivers/rtc/rtc-isl1208.c | 131 --
 1 file changed, 124 insertions(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 1a2c38cc0178..3150ebdcb179 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include "rtc-core.h"
 
 /* Register map */
 /* rtc section */
@@ -33,13 +34,15 @@
 #define ISL1208_REG_SR_ARST(1<<7)  /* auto reset */
 #define ISL1208_REG_SR_XTOSCB  (1<<6)  /* crystal oscillator */
 #define ISL1208_REG_SR_WRTC(1<<4)  /* write rtc */
+#define ISL1208_REG_SR_EVT (1<<3)  /* event */
 #define ISL1208_REG_SR_ALM (1<<2)  /* alarm */
 #define ISL1208_REG_SR_BAT (1<<1)  /* battery */
 #define ISL1208_REG_SR_RTCF(1<<0)  /* rtc fail */
 #define ISL1208_REG_INT 0x08
 #define ISL1208_REG_INT_ALME   (1<<6)   /* alarm enable */
 #define ISL1208_REG_INT_IM (1<<7)   /* interrupt/alarm mode */
-#define ISL1208_REG_09  0x09   /* reserved */
+#define ISL1219_REG_EV  0x09
+#define ISL1219_REG_EV_EVEN(1<<4)   /* event detection enable */
 #define ISL1208_REG_ATR 0x0a
 #define ISL1208_REG_DTR 0x0b
 
@@ -57,8 +60,24 @@
 #define ISL1208_REG_USR2 0x13
 #define ISL1208_USR_SECTION_LEN 2
 
+/* event section */
+#define ISL1219_REG_SCT 0x14
+#define ISL1219_REG_MNT 0x15
+#define ISL1219_REG_HRT 0x16
+#define ISL1219_REG_DTT 0x17
+#define ISL1219_REG_MOT 0x18
+#define ISL1219_REG_YRT 0x19
+#define ISL1219_EVT_SECTION_LEN 6
+
 static struct i2c_driver isl1208_driver;
 
+/* ISL1208 various variants */
+enum {
+   TYPE_ISL1208 = 0,
+   TYPE_ISL1218,
+   TYPE_ISL1219,
+};
+
 /* block read */
 static int
 isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[],
@@ -80,8 +99,8 @@ isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 
buf[],
};
int ret;
 
-   BUG_ON(reg > ISL1208_REG_USR2);
-   BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
+   WARN_ON(reg > ISL1219_REG_YRT);
+   WARN_ON(reg + len > ISL1219_REG_YRT + 1);
 
ret = i2c_transfer(client->adapter, msgs, 2);
if (ret > 0)
@@ -104,8 +123,8 @@ isl1208_i2c_set_regs(struct i2c_client *client, u8 reg, u8 
const buf[],
};
int ret;
 
-   BUG_ON(reg > ISL1208_REG_USR2);
-   BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
+   WARN_ON(reg > ISL1219_REG_YRT);
+   WARN_ON(reg + len > ISL1219_REG_YRT + 1);
 
i2c_buf[0] = reg;
memcpy(_buf[1], [0], len);
@@ -493,6 +512,73 @@ isl1208_rtc_set_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
return isl1208_i2c_set_alarm(to_i2c_client(dev), alarm);
 }
 
+static ssize_t timestamp0_store(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct i2c_client *client = dev_get_drvdata(dev);
+   int sr;
+
+   sr = isl1208_i2c_get_sr(client);
+   if (sr < 0) {
+   dev_err(dev, "%s: reading SR failed\n", __func__);
+   return sr;
+   }
+
+   sr &= ~ISL1208_REG_SR_EVT;
+
+   sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr);
+   if (sr < 0)
+   dev_err(dev, "%s: writing SR failed\n",
+   __func__);
+
+   return count;
+};
+
+static ssize_t timestamp0_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct i2c_client *client = dev_get_drvdata(dev);
+   u8 regs[ISL1219_EVT_SECTION_LEN] = { 0, };
+   struct rtc_time tm;
+   int sr;
+
+   sr = isl1208_i2c_get_sr(client);
+   if (sr < 0) {
+   dev_err(dev, "%s: reading SR failed\n", __func__);
+   return sr;
+   }
+
+   if (!(sr & ISL1208_REG_SR_EVT))
+   return 0;
+
+   sr = isl1208_i2c_read_regs(client, ISL1219_REG_SCT, regs,
+  ISL1219_EVT_SECTION_LEN);
+   if (sr < 0) {
+   dev_err(dev, "%s: reading event section failed\n",
+   __func__);
+   return 0;
+   }
+
+   /* MSB of each alarm register is an enable bit */
+   tm.tm_sec = bcd2bin(regs[ISL1219_REG_SCT - ISL1219_REG_SCT] & 0x7f);
+   tm.tm_min = bcd2bin(regs[ISL1219_REG_MNT - ISL1219_REG_SCT] & 0x7f);
+   tm.tm_hour = bcd2bin(regs[ISL1219_REG_HRT - ISL1219_REG_SCT] & 0x3f);
+   tm.tm_mday = bcd2bin(regs[IS

[PATCH v5 3/5] rtc: isl1208: Add "evdet" interrupt source for isl1219.

2018-07-24 Thread Denis OSTERLAND
From: Denis Osterland 

Add support for "evdet" named interrupt source.

The check if i2c client irq matches evdet irq is needed
for the case that there is only one interrupt named "evdet".
In this case i2c client code handles this like an unnamed
interrupt souce and assigns the value.

Signed-off-by: Denis Osterland 
Reviewed-by: Michael Grzeschik 
---
 drivers/rtc/rtc-isl1208.c | 46 +--
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 3150ebdcb179..0812a14c2d5c 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include "rtc-core.h"
+#include 
 
 /* Register map */
 /* rtc section */
@@ -725,11 +726,30 @@ static const struct attribute_group 
isl1219_rtc_sysfs_files = {
.attrs  = isl1219_rtc_attrs,
 };
 
+static int isl1208_setup_irq(struct i2c_client *client, int irq)
+{
+   int rc = devm_request_threaded_irq(>dev, irq, NULL,
+   isl1208_rtc_interrupt,
+   IRQF_SHARED | IRQF_ONESHOT,
+   isl1208_driver.driver.name,
+   client);
+   if (!rc) {
+   device_init_wakeup(>dev, 1);
+   enable_irq_wake(irq);
+   } else {
+   dev_err(>dev,
+   "Unable to request irq %d, no alarm support\n",
+   irq);
+   }
+   return rc;
+}
+
 static int
 isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
int rc = 0;
struct rtc_device *rtc;
+   int evdet_irq = -1;
 
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -ENODEV;
@@ -766,28 +786,22 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
rc = rtc_add_group(rtc, _rtc_sysfs_files);
if (rc)
return rc;
+   evdet_irq = of_irq_get_byname(client->dev.of_node, "evdet");
}
 
rc = sysfs_create_group(>dev.kobj, _rtc_sysfs_files);
if (rc)
return rc;
 
-   if (client->irq > 0) {
-   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
-  isl1208_rtc_interrupt,
-  IRQF_SHARED | IRQF_ONESHOT,
-  isl1208_driver.driver.name,
-  client);
-   if (!rc) {
-   device_init_wakeup(>dev, 1);
-   enable_irq_wake(client->irq);
-   } else {
-   dev_err(>dev,
-   "Unable to request irq %d, no alarm support\n",
-   client->irq);
-   client->irq = 0;
-   }
-   }
+   if (client->irq > 0)
+   rc = isl1208_setup_irq(client, client->irq);
+   if (rc)
+   return rc;
+
+   if (evdet_irq > 0 && evdet_irq != client->irq)
+   rc = isl1208_setup_irq(client, evdet_irq);
+   if (rc)
+   return rc;
 
return rtc_register_device(rtc);
 }
-- 
2.18.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v5 5/5] rtc: isl1219: add device tree docu

2018-07-24 Thread Denis OSTERLAND
From: Denis Osterland 

The devicetree documentation for the ISL1219 device tree
binding is added with an short example. It is not a trivial
device, because it supports two interrupt sources.

Signed-off-by: Denis Osterland 
---
 .../devicetree/bindings/rtc/isil,isl1219.txt  | 29 +++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/isil,isl1219.txt

diff --git a/Documentation/devicetree/bindings/rtc/isil,isl1219.txt 
b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
new file mode 100644
index ..c3efd48e91c2
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
@@ -0,0 +1,29 @@
+Intersil ISL1219 I2C RTC/Alarm chip with event in
+
+ISL1219 has additional pins EVIN and #EVDET for tamper detection.
+
+Required properties supported by the device:
+
+ - "compatible": must be "isil,isl1219"
+ - "reg": I2C bus address of the device
+
+Optional properties:
+
+ - "interrupt-names": list which may contains "irq" and "evdet"
+ - "interrupts": list of interrupts for "irq" and "evdet"
+ - "isil,ev-evienb": if present EV.EVIENB bit is set to the specified
+ value for proper operation.
+
+
+Example isl1219 node with #IRQ pin connected to SoC gpio1 pin12
+ and #EVDET pin connected to SoC gpio2 pin 24:
+
+   isl1219: rtc@68 {
+   compatible = "isil,isl1219";
+   reg = <0x68>;
+   interrupt-names = "irq", "evdet";
+   interrupts-extended = < 12 IRQ_TYPE_EDGE_FALLING>,
+   < 24 IRQ_TYPE_EDGE_FALLING>;
+   isil,ev-evienb = <1>;
+   };
+
-- 
2.18.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v5 3/5] rtc: isl1208: Add "evdet" interrupt source for isl1219.

2018-07-24 Thread Denis OSTERLAND
From: Denis Osterland 

Add support for "evdet" named interrupt source.

The check if i2c client irq matches evdet irq is needed
for the case that there is only one interrupt named "evdet".
In this case i2c client code handles this like an unnamed
interrupt souce and assigns the value.

Signed-off-by: Denis Osterland 
Reviewed-by: Michael Grzeschik 
---
 drivers/rtc/rtc-isl1208.c | 46 +--
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 3150ebdcb179..0812a14c2d5c 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include "rtc-core.h"
+#include 
 
 /* Register map */
 /* rtc section */
@@ -725,11 +726,30 @@ static const struct attribute_group 
isl1219_rtc_sysfs_files = {
.attrs  = isl1219_rtc_attrs,
 };
 
+static int isl1208_setup_irq(struct i2c_client *client, int irq)
+{
+   int rc = devm_request_threaded_irq(>dev, irq, NULL,
+   isl1208_rtc_interrupt,
+   IRQF_SHARED | IRQF_ONESHOT,
+   isl1208_driver.driver.name,
+   client);
+   if (!rc) {
+   device_init_wakeup(>dev, 1);
+   enable_irq_wake(irq);
+   } else {
+   dev_err(>dev,
+   "Unable to request irq %d, no alarm support\n",
+   irq);
+   }
+   return rc;
+}
+
 static int
 isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
int rc = 0;
struct rtc_device *rtc;
+   int evdet_irq = -1;
 
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -ENODEV;
@@ -766,28 +786,22 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
rc = rtc_add_group(rtc, _rtc_sysfs_files);
if (rc)
return rc;
+   evdet_irq = of_irq_get_byname(client->dev.of_node, "evdet");
}
 
rc = sysfs_create_group(>dev.kobj, _rtc_sysfs_files);
if (rc)
return rc;
 
-   if (client->irq > 0) {
-   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
-  isl1208_rtc_interrupt,
-  IRQF_SHARED | IRQF_ONESHOT,
-  isl1208_driver.driver.name,
-  client);
-   if (!rc) {
-   device_init_wakeup(>dev, 1);
-   enable_irq_wake(client->irq);
-   } else {
-   dev_err(>dev,
-   "Unable to request irq %d, no alarm support\n",
-   client->irq);
-   client->irq = 0;
-   }
-   }
+   if (client->irq > 0)
+   rc = isl1208_setup_irq(client, client->irq);
+   if (rc)
+   return rc;
+
+   if (evdet_irq > 0 && evdet_irq != client->irq)
+   rc = isl1208_setup_irq(client, evdet_irq);
+   if (rc)
+   return rc;
 
return rtc_register_device(rtc);
 }
-- 
2.18.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v5 5/5] rtc: isl1219: add device tree docu

2018-07-24 Thread Denis OSTERLAND
From: Denis Osterland 

The devicetree documentation for the ISL1219 device tree
binding is added with an short example. It is not a trivial
device, because it supports two interrupt sources.

Signed-off-by: Denis Osterland 
---
 .../devicetree/bindings/rtc/isil,isl1219.txt  | 29 +++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/isil,isl1219.txt

diff --git a/Documentation/devicetree/bindings/rtc/isil,isl1219.txt 
b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
new file mode 100644
index ..c3efd48e91c2
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
@@ -0,0 +1,29 @@
+Intersil ISL1219 I2C RTC/Alarm chip with event in
+
+ISL1219 has additional pins EVIN and #EVDET for tamper detection.
+
+Required properties supported by the device:
+
+ - "compatible": must be "isil,isl1219"
+ - "reg": I2C bus address of the device
+
+Optional properties:
+
+ - "interrupt-names": list which may contains "irq" and "evdet"
+ - "interrupts": list of interrupts for "irq" and "evdet"
+ - "isil,ev-evienb": if present EV.EVIENB bit is set to the specified
+ value for proper operation.
+
+
+Example isl1219 node with #IRQ pin connected to SoC gpio1 pin12
+ and #EVDET pin connected to SoC gpio2 pin 24:
+
+   isl1219: rtc@68 {
+   compatible = "isil,isl1219";
+   reg = <0x68>;
+   interrupt-names = "irq", "evdet";
+   interrupts-extended = < 12 IRQ_TYPE_EDGE_FALLING>,
+   < 24 IRQ_TYPE_EDGE_FALLING>;
+   isil,ev-evienb = <1>;
+   };
+
-- 
2.18.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v5 1/5] rtc: sysfs: facilitate attribute add to rtc device

2018-07-24 Thread Denis OSTERLAND
From: Denis Osterland 

This patches addresses following problem:
rtc_allocate_device
devm_device_add_group  <-- kernel oops / null pointer, because
sysfs entry does not yet exist
rtc_register_device
rc = devm_device_add_group
if (rc)
return rc; <-- forbidden to return error code
after device register

This patch adds rtc_add_group(s) functions.
The functions store the sum of attribute groups as device resource.

Signed-off-by: Denis Osterland 
---
 drivers/rtc/rtc-core.h  | 13 +
 drivers/rtc/rtc-sysfs.c | 43 +
 2 files changed, 56 insertions(+)

diff --git a/drivers/rtc/rtc-core.h b/drivers/rtc/rtc-core.h
index 0abf98983e13..c74537d03644 100644
--- a/drivers/rtc/rtc-core.h
+++ b/drivers/rtc/rtc-core.h
@@ -40,9 +40,22 @@ static inline void rtc_proc_del_device(struct rtc_device 
*rtc)
 
 #ifdef CONFIG_RTC_INTF_SYSFS
 const struct attribute_group **rtc_get_dev_attribute_groups(void);
+int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp);
+int rtc_add_groups(struct rtc_device *rtc,
+   const struct attribute_group **grps);
 #else
 static inline const struct attribute_group **rtc_get_dev_attribute_groups(void)
 {
return NULL;
 }
+static inline
+int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp)
+{
+   return 0;
+}
+static inline
+int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps)
+{
+   return 0;
+}
 #endif
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index 454da38c6012..498e65f13686 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -317,3 +317,46 @@ const struct attribute_group 
**rtc_get_dev_attribute_groups(void)
 {
return rtc_attr_groups;
 }
+
+int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps)
+{
+   size_t old_cnt = 0, add_cnt = 0, new_cnt;
+   const struct attribute_group **groups, **old;
+
+   if (rtc->registered)
+   return -EINVAL;
+   if (!grps)
+   return -EINVAL;
+
+   groups = rtc->dev.groups;
+   if (groups)
+   for (; *groups; groups++)
+   old_cnt++;
+
+   for (groups = grps; *groups; groups++)
+   add_cnt++;
+
+   new_cnt = old_cnt + add_cnt + 1;
+   groups = devm_kcalloc(>dev, new_cnt, sizeof(*groups), GFP_KERNEL);
+   if (IS_ERR_OR_NULL(groups))
+   return PTR_ERR(groups);
+   memcpy(groups, rtc->dev.groups, old_cnt*sizeof(*groups));
+   memcpy(groups+old_cnt, grps, add_cnt*sizeof(*groups));
+   groups[old_cnt+add_cnt] = NULL;
+
+   old = rtc->dev.groups;
+   rtc->dev.groups = groups;
+   if (old && old != rtc_attr_groups)
+   devm_kfree(>dev, old);
+
+   return 0;
+}
+EXPORT_SYMBOL(rtc_add_groups);
+
+int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp)
+{
+   const struct attribute_group *groups[] = { grp, NULL };
+
+   return rtc_add_groups(rtc, groups);
+}
+EXPORT_SYMBOL(rtc_add_group);
-- 
2.18.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v5 0/5] rtc: isl1208: fixes, documentation and isl1219 support

2018-07-24 Thread Denis OSTERLAND
changes since v4:
 - fix 'souces' typo and change interrupt documentation
 - change "isil,ev-evienb" type to int and do not touch bit if not present
 - pass ISL1219_REG_EV_EVEN directly instead of assigning it to rc
 - fix module build by adding EXPORT_SYMBOL to rtc_add_group(s)
 - use kcalloc
 - return error if device is already registered
 - include helper functions into rtc_add_groups

Michael Grzeschik (1):
rtc: isl1208: add support for isl1219 with tamper detection

Denis Osterland (4):
rtc: sysfs: facilitate attribute add to rtc device
rtc: isl1208: Add "evdet" interrupt source for isl1219.
rtc: isl1208: set ev-evienb bit from device tree
rtc: isl1219: add device tree docu

 .../devicetree/bindings/rtc/isil,isl1219.txt   |  29 
 drivers/rtc/rtc-core.h |  13 ++
 drivers/rtc/rtc-isl1208.c  | 192 ++---
 drivers/rtc/rtc-sysfs.c|  43 +
 4 files changed, 254 insertions(+), 23 deletions(-)

Message-Id: 20180710090710.9066-1-denis.osterl...@diehl.com





Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v5 4/5] rtc: isl1208: set ev-evienb bit from device tree

2018-07-24 Thread Denis OSTERLAND
From: Denis Osterland 

Add support to disable event in pull-up.

Signed-off-by: Denis Osterland 
---
 drivers/rtc/rtc-isl1208.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 0812a14c2d5c..fa744c7ad5b3 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -44,6 +44,7 @@
 #define ISL1208_REG_INT_IM (1<<7)   /* interrupt/alarm mode */
 #define ISL1219_REG_EV  0x09
 #define ISL1219_REG_EV_EVEN(1<<4)   /* event detection enable */
+#define ISL1219_REG_EV_EVIENB  (1<<7)   /* event in pull-up disable */
 #define ISL1208_REG_ATR 0x0a
 #define ISL1208_REG_DTR 0x0b
 
@@ -777,8 +778,22 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
 "please set clock.\n");
 
if (id->driver_data == TYPE_ISL1219) {
-   rc = i2c_smbus_write_byte_data(client, ISL1219_REG_EV,
-   ISL1219_REG_EV_EVEN);
+   struct device_node *np = client->dev.of_node;
+   u32 evienb;
+
+   rc = i2c_smbus_read_byte_data(client, ISL1219_REG_EV);
+   if (rc < 0) {
+   dev_err(>dev, "failed to read EV reg\n");
+   return rc;
+   }
+   rc |= ISL1219_REG_EV_EVEN;
+   if (!of_property_read_u32(np, "isil,ev-evienb", )) {
+   if (evienb)
+   rc |= ISL1219_REG_EV_EVIENB;
+   else
+   rc &= ~ISL1219_REG_EV_EVIENB;
+   }
+   rc = i2c_smbus_write_byte_data(client, ISL1219_REG_EV, rc);
if (rc < 0) {
dev_err(>dev, "could not enable tamper 
detection\n");
return rc;
@@ -786,7 +801,7 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
rc = rtc_add_group(rtc, _rtc_sysfs_files);
if (rc)
return rc;
-   evdet_irq = of_irq_get_byname(client->dev.of_node, "evdet");
+   evdet_irq = of_irq_get_byname(np, "evdet");
}
 
rc = sysfs_create_group(>dev.kobj, _rtc_sysfs_files);
-- 
2.18.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v5 1/5] rtc: sysfs: facilitate attribute add to rtc device

2018-07-24 Thread Denis OSTERLAND
From: Denis Osterland 

This patches addresses following problem:
rtc_allocate_device
devm_device_add_group  <-- kernel oops / null pointer, because
sysfs entry does not yet exist
rtc_register_device
rc = devm_device_add_group
if (rc)
return rc; <-- forbidden to return error code
after device register

This patch adds rtc_add_group(s) functions.
The functions store the sum of attribute groups as device resource.

Signed-off-by: Denis Osterland 
---
 drivers/rtc/rtc-core.h  | 13 +
 drivers/rtc/rtc-sysfs.c | 43 +
 2 files changed, 56 insertions(+)

diff --git a/drivers/rtc/rtc-core.h b/drivers/rtc/rtc-core.h
index 0abf98983e13..c74537d03644 100644
--- a/drivers/rtc/rtc-core.h
+++ b/drivers/rtc/rtc-core.h
@@ -40,9 +40,22 @@ static inline void rtc_proc_del_device(struct rtc_device 
*rtc)
 
 #ifdef CONFIG_RTC_INTF_SYSFS
 const struct attribute_group **rtc_get_dev_attribute_groups(void);
+int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp);
+int rtc_add_groups(struct rtc_device *rtc,
+   const struct attribute_group **grps);
 #else
 static inline const struct attribute_group **rtc_get_dev_attribute_groups(void)
 {
return NULL;
 }
+static inline
+int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp)
+{
+   return 0;
+}
+static inline
+int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps)
+{
+   return 0;
+}
 #endif
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index 454da38c6012..498e65f13686 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -317,3 +317,46 @@ const struct attribute_group 
**rtc_get_dev_attribute_groups(void)
 {
return rtc_attr_groups;
 }
+
+int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps)
+{
+   size_t old_cnt = 0, add_cnt = 0, new_cnt;
+   const struct attribute_group **groups, **old;
+
+   if (rtc->registered)
+   return -EINVAL;
+   if (!grps)
+   return -EINVAL;
+
+   groups = rtc->dev.groups;
+   if (groups)
+   for (; *groups; groups++)
+   old_cnt++;
+
+   for (groups = grps; *groups; groups++)
+   add_cnt++;
+
+   new_cnt = old_cnt + add_cnt + 1;
+   groups = devm_kcalloc(>dev, new_cnt, sizeof(*groups), GFP_KERNEL);
+   if (IS_ERR_OR_NULL(groups))
+   return PTR_ERR(groups);
+   memcpy(groups, rtc->dev.groups, old_cnt*sizeof(*groups));
+   memcpy(groups+old_cnt, grps, add_cnt*sizeof(*groups));
+   groups[old_cnt+add_cnt] = NULL;
+
+   old = rtc->dev.groups;
+   rtc->dev.groups = groups;
+   if (old && old != rtc_attr_groups)
+   devm_kfree(>dev, old);
+
+   return 0;
+}
+EXPORT_SYMBOL(rtc_add_groups);
+
+int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp)
+{
+   const struct attribute_group *groups[] = { grp, NULL };
+
+   return rtc_add_groups(rtc, groups);
+}
+EXPORT_SYMBOL(rtc_add_group);
-- 
2.18.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v5 0/5] rtc: isl1208: fixes, documentation and isl1219 support

2018-07-24 Thread Denis OSTERLAND
changes since v4:
 - fix 'souces' typo and change interrupt documentation
 - change "isil,ev-evienb" type to int and do not touch bit if not present
 - pass ISL1219_REG_EV_EVEN directly instead of assigning it to rc
 - fix module build by adding EXPORT_SYMBOL to rtc_add_group(s)
 - use kcalloc
 - return error if device is already registered
 - include helper functions into rtc_add_groups

Michael Grzeschik (1):
rtc: isl1208: add support for isl1219 with tamper detection

Denis Osterland (4):
rtc: sysfs: facilitate attribute add to rtc device
rtc: isl1208: Add "evdet" interrupt source for isl1219.
rtc: isl1208: set ev-evienb bit from device tree
rtc: isl1219: add device tree docu

 .../devicetree/bindings/rtc/isil,isl1219.txt   |  29 
 drivers/rtc/rtc-core.h |  13 ++
 drivers/rtc/rtc-isl1208.c  | 192 ++---
 drivers/rtc/rtc-sysfs.c|  43 +
 4 files changed, 254 insertions(+), 23 deletions(-)

Message-Id: 20180710090710.9066-1-denis.osterl...@diehl.com





Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v5 4/5] rtc: isl1208: set ev-evienb bit from device tree

2018-07-24 Thread Denis OSTERLAND
From: Denis Osterland 

Add support to disable event in pull-up.

Signed-off-by: Denis Osterland 
---
 drivers/rtc/rtc-isl1208.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 0812a14c2d5c..fa744c7ad5b3 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -44,6 +44,7 @@
 #define ISL1208_REG_INT_IM (1<<7)   /* interrupt/alarm mode */
 #define ISL1219_REG_EV  0x09
 #define ISL1219_REG_EV_EVEN(1<<4)   /* event detection enable */
+#define ISL1219_REG_EV_EVIENB  (1<<7)   /* event in pull-up disable */
 #define ISL1208_REG_ATR 0x0a
 #define ISL1208_REG_DTR 0x0b
 
@@ -777,8 +778,22 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
 "please set clock.\n");
 
if (id->driver_data == TYPE_ISL1219) {
-   rc = i2c_smbus_write_byte_data(client, ISL1219_REG_EV,
-   ISL1219_REG_EV_EVEN);
+   struct device_node *np = client->dev.of_node;
+   u32 evienb;
+
+   rc = i2c_smbus_read_byte_data(client, ISL1219_REG_EV);
+   if (rc < 0) {
+   dev_err(>dev, "failed to read EV reg\n");
+   return rc;
+   }
+   rc |= ISL1219_REG_EV_EVEN;
+   if (!of_property_read_u32(np, "isil,ev-evienb", )) {
+   if (evienb)
+   rc |= ISL1219_REG_EV_EVIENB;
+   else
+   rc &= ~ISL1219_REG_EV_EVIENB;
+   }
+   rc = i2c_smbus_write_byte_data(client, ISL1219_REG_EV, rc);
if (rc < 0) {
dev_err(>dev, "could not enable tamper 
detection\n");
return rc;
@@ -786,7 +801,7 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
rc = rtc_add_group(rtc, _rtc_sysfs_files);
if (rc)
return rc;
-   evdet_irq = of_irq_get_byname(client->dev.of_node, "evdet");
+   evdet_irq = of_irq_get_byname(np, "evdet");
}
 
rc = sysfs_create_group(>dev.kobj, _rtc_sysfs_files);
-- 
2.18.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


Re: [PATCH v4 2/5] rtc: isl1208: add support for isl1219 with tamper detection

2018-07-18 Thread Denis OSTERLAND
Hi,

Am Mittwoch, den 18.07.2018, 10:13 +0200 schrieb Alexandre Belloni:
> On 10/07/2018 09:44:15+0000, Denis OSTERLAND wrote:
> > 
> > +   if (id->driver_data == TYPE_ISL1219) {
> > +   rc = ISL1219_REG_EV_EVEN;
> > +   rc = i2c_smbus_write_byte_data(client, ISL1219_REG_EV, rc);
> I'd pass ISL1219_REG_EV_EVEN directly instead of assigning it to rc.
> 
Because of the 80 character limit per row, I thought this:
rc = ISL1219_REG_EV_EVEN;
rc = i2c_smbus_write_byte_data(client, ISL1219_REG_EV, rc);
would look nicer than that:
rc = i2c_smbus_write_byte_data(client, ISL1219_REG_EV,
ISL1219_REG_EV_EVEN);
Are there any reasons why I should prefer the second one?

Regards Denis

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


Re: [PATCH v4 2/5] rtc: isl1208: add support for isl1219 with tamper detection

2018-07-18 Thread Denis OSTERLAND
Hi,

Am Mittwoch, den 18.07.2018, 10:13 +0200 schrieb Alexandre Belloni:
> On 10/07/2018 09:44:15+0000, Denis OSTERLAND wrote:
> > 
> > +   if (id->driver_data == TYPE_ISL1219) {
> > +   rc = ISL1219_REG_EV_EVEN;
> > +   rc = i2c_smbus_write_byte_data(client, ISL1219_REG_EV, rc);
> I'd pass ISL1219_REG_EV_EVEN directly instead of assigning it to rc.
> 
Because of the 80 character limit per row, I thought this:
rc = ISL1219_REG_EV_EVEN;
rc = i2c_smbus_write_byte_data(client, ISL1219_REG_EV, rc);
would look nicer than that:
rc = i2c_smbus_write_byte_data(client, ISL1219_REG_EV,
ISL1219_REG_EV_EVEN);
Are there any reasons why I should prefer the second one?

Regards Denis

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


Re: [PATCH v4 5/5] rtc: isl1219: add device tree docu

2018-07-18 Thread Denis OSTERLAND
Hello,

Am Mittwoch, den 18.07.2018, 09:38 +0200 schrieb Alexandre Belloni:
> Hi,
> 
> On 10/07/2018 09:44:15+0000, Denis OSTERLAND wrote:
> > 
> > +
> > +Optional properties:
> > +
> > + - "interrupt-names": list which may contains "irq" and "evdet"
> > + - "interrupt-parent", "interrupts", "interrupts-extended":
> > +   for passing the interrupt line of the SoC connected to #IRQ pin
> > +   and #EVDET pin of the RTC chip.
> > + - "isil,ev-evienb": if present bit can be set to disable event input 
> > pull-up
> I would use a clearer name for that property like isil,ev-pull-up-enabled.
> 
> Also make it an int so 0 is disabling the pull-up (EVIENB set to 1) 1 is
> enabling the pull-up (EVIENB set to 0) and do nothing when the property
> is not present.
It is designed like Documentation/devicetree/bindings/rtc/isil,isl12026.txt,
which uses the bit name from Documentation as well.
I will change to integer type.
> 
> 
Regards Denis

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


Re: [PATCH v4 5/5] rtc: isl1219: add device tree docu

2018-07-18 Thread Denis OSTERLAND
Hello,

Am Mittwoch, den 18.07.2018, 09:38 +0200 schrieb Alexandre Belloni:
> Hi,
> 
> On 10/07/2018 09:44:15+0000, Denis OSTERLAND wrote:
> > 
> > +
> > +Optional properties:
> > +
> > + - "interrupt-names": list which may contains "irq" and "evdet"
> > + - "interrupt-parent", "interrupts", "interrupts-extended":
> > +   for passing the interrupt line of the SoC connected to #IRQ pin
> > +   and #EVDET pin of the RTC chip.
> > + - "isil,ev-evienb": if present bit can be set to disable event input 
> > pull-up
> I would use a clearer name for that property like isil,ev-pull-up-enabled.
> 
> Also make it an int so 0 is disabling the pull-up (EVIENB set to 1) 1 is
> enabling the pull-up (EVIENB set to 0) and do nothing when the property
> is not present.
It is designed like Documentation/devicetree/bindings/rtc/isil,isl12026.txt,
which uses the bit name from Documentation as well.
I will change to integer type.
> 
> 
Regards Denis

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


Re: [PATCH v4 1/5] rtc: sysfs: facilitate attribute add to rtc device

2018-07-18 Thread Denis OSTERLAND
Hello,

thanks for your comments.

Am Mittwoch, den 18.07.2018, 09:25 +0200 schrieb Alexandre Belloni:
> Hello,
> 
> On 10/07/2018 09:44:15+0000, Denis OSTERLAND wrote:
> > 
> > +
> > +static size_t rtc_group_count(struct rtc_device *rtc)
> > +{
> I don't feel this function is necessary, you can include it in __rtc_add_group
I think that it is easier to read, but sure I can include it.
> 
> > 
> > +
> > +static inline int
> > +__rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp)
> > +{
> > +   size_t cnt = rtc_group_count(rtc);
> > +   const struct attribute_group **groups, **old;
> > +
> > +   groups = devm_kzalloc(>dev, (cnt+2)*sizeof(*groups), GFP_KERNEL);
> Please use devm_kcalloc
okay
> 
> > 
> > +   if (IS_ERR_OR_NULL(groups))
> > +   return PTR_ERR(groups);
> > +   memcpy(groups, rtc->dev.groups, cnt*sizeof(*groups));
> > +   groups[cnt] = grp;
> > +
> > +   old = rtc->dev.groups;
> > +   rtc->dev.groups = groups;
> > +   if (old != rtc_attr_groups)
> > +   devm_kfree(>dev, old);
> > +
> > +   return 0;
> > +}
> > +
> > +int rtc_add_group(struct rtc_device *rtc, const struct attribute_group 
> > *grp)
> > +{
> > +   return rtc->dev.kobj.state_in_sysfs ?
> > +   devm_device_add_group(>dev, grp) :
> > +   __rtc_add_group(rtc, grp);
> Using devm_device_add_group after RTC registration is racy and should
> not be allowed. I would merge __rtc_add_group in rtc_add_group and
> return an error if rtc->registered is true.
You are right. An error in this case is better.
> 
> 

Regards Denis

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


Re: [PATCH v4 1/5] rtc: sysfs: facilitate attribute add to rtc device

2018-07-18 Thread Denis OSTERLAND
Hello,

thanks for your comments.

Am Mittwoch, den 18.07.2018, 09:25 +0200 schrieb Alexandre Belloni:
> Hello,
> 
> On 10/07/2018 09:44:15+0000, Denis OSTERLAND wrote:
> > 
> > +
> > +static size_t rtc_group_count(struct rtc_device *rtc)
> > +{
> I don't feel this function is necessary, you can include it in __rtc_add_group
I think that it is easier to read, but sure I can include it.
> 
> > 
> > +
> > +static inline int
> > +__rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp)
> > +{
> > +   size_t cnt = rtc_group_count(rtc);
> > +   const struct attribute_group **groups, **old;
> > +
> > +   groups = devm_kzalloc(>dev, (cnt+2)*sizeof(*groups), GFP_KERNEL);
> Please use devm_kcalloc
okay
> 
> > 
> > +   if (IS_ERR_OR_NULL(groups))
> > +   return PTR_ERR(groups);
> > +   memcpy(groups, rtc->dev.groups, cnt*sizeof(*groups));
> > +   groups[cnt] = grp;
> > +
> > +   old = rtc->dev.groups;
> > +   rtc->dev.groups = groups;
> > +   if (old != rtc_attr_groups)
> > +   devm_kfree(>dev, old);
> > +
> > +   return 0;
> > +}
> > +
> > +int rtc_add_group(struct rtc_device *rtc, const struct attribute_group 
> > *grp)
> > +{
> > +   return rtc->dev.kobj.state_in_sysfs ?
> > +   devm_device_add_group(>dev, grp) :
> > +   __rtc_add_group(rtc, grp);
> Using devm_device_add_group after RTC registration is racy and should
> not be allowed. I would merge __rtc_add_group in rtc_add_group and
> return an error if rtc->registered is true.
You are right. An error in this case is better.
> 
> 

Regards Denis

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


Re: [PATCH v4 5/5] rtc: isl1219: add device tree docu

2018-07-12 Thread Denis OSTERLAND
Am Mittwoch, den 11.07.2018, 09:16 -0600 schrieb Rob Herring:
> On Tue, Jul 10, 2018 at 09:44:15AM +0000, Denis OSTERLAND wrote:
> > 
> > From: Denis Osterland 
> > 
> > The devicetree documentation for the ISL1219 device tree
> > binding is added with an short example. It is not a trivial
> > device, because it supports two interrupt souces.
> s/souces/sources/
OK
> 
> > 
> > 
> > Signed-off-by: Denis Osterland 
> > ---
> >  .../devicetree/bindings/rtc/isil,isl1219.txt  | 29 +++
> >  1 file changed, 29 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/rtc/isil,isl1219.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/rtc/isil,isl1219.txt 
> > b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
> > new file mode 100644
> > index ..f26f1e9d4bde
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
> > @@ -0,0 +1,29 @@
> > +Intersil ISL1219 I2C RTC/Alarm chip with event in
> > +
> > +ISL1219 has additional pins EVIN and #EVDET for tamper detection.
> > +
> > +Required properties supported by the device:
> > +
> > + - "compatible": must be "isil,isl1219"
> > + - "reg": I2C bus address of the device
> > +
> > +Optional properties:
> > +
> > + - "interrupt-names": list which may contains "irq" and "evdet"
> > + - "interrupt-parent", "interrupts", "interrupts-extended":
> > +   for passing the interrupt line of the SoC connected to #IRQ pin
> > +   and #EVDET pin of the RTC chip.
> Just list 'interrupts' and how many there are. interrupt-parent is 
> implied and may be in a parent node. interrupts-extended is also 
> implicitly allowed as needed.
Will change to: "interrupts": list of interrupts for "irq" and "evdet"
> 
> > 
> > + - "isil,ev-evienb": if present bit can be set to disable event input 
> > pull-up
> > +
> > +
> > +Example isl1219 node with #IRQ pin connected to SoC gpio1 pin12
> > + and #EVDET pin connected to SoC gpio2 pin 24:
> > +
> > +   isl1219: rtc@68 {
> > +   compatible = "isil,isl1219";
> > +   reg = <0x68>;
> > +   interrupt-names = "irq", "evdet";
> > +   interrupts-extended = < 12 IRQ_TYPE_EDGE_FALLING>,
> > +   < 24 IRQ_TYPE_EDGE_FALLING>;
> > +   };
> > +
> > --
> > 2.18.0
> > 
> > 
> > 
> > Diehl Connectivity Solutions GmbH
> > Geschäftsführung: Horst Leonberger
> > Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
> > Nürnberg: HRB 32315
> > ___
> > 
> > Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese 
> > E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
> > Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise 
> > erhalten haben. Bitte loeschen Sie in diesem Fall die Nachricht.
> > Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
> > und/oder Publikation dieser E-Mail ist strengstens untersagt.
> > The contents of the above mentioned e-mail is not legally binding. This 
> > e-mail contains confidential and/or legally protected information. Please 
> > inform us if you have received this e-mail by
> > mistake and delete it in such a case. Each unauthorized reproduction, 
> > disclosure, alteration, distribution and/or publication of this e-mail is 
> > strictly prohibited.

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


Re: [PATCH v4 5/5] rtc: isl1219: add device tree docu

2018-07-12 Thread Denis OSTERLAND
Am Mittwoch, den 11.07.2018, 09:16 -0600 schrieb Rob Herring:
> On Tue, Jul 10, 2018 at 09:44:15AM +0000, Denis OSTERLAND wrote:
> > 
> > From: Denis Osterland 
> > 
> > The devicetree documentation for the ISL1219 device tree
> > binding is added with an short example. It is not a trivial
> > device, because it supports two interrupt souces.
> s/souces/sources/
OK
> 
> > 
> > 
> > Signed-off-by: Denis Osterland 
> > ---
> >  .../devicetree/bindings/rtc/isil,isl1219.txt  | 29 +++
> >  1 file changed, 29 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/rtc/isil,isl1219.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/rtc/isil,isl1219.txt 
> > b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
> > new file mode 100644
> > index ..f26f1e9d4bde
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
> > @@ -0,0 +1,29 @@
> > +Intersil ISL1219 I2C RTC/Alarm chip with event in
> > +
> > +ISL1219 has additional pins EVIN and #EVDET for tamper detection.
> > +
> > +Required properties supported by the device:
> > +
> > + - "compatible": must be "isil,isl1219"
> > + - "reg": I2C bus address of the device
> > +
> > +Optional properties:
> > +
> > + - "interrupt-names": list which may contains "irq" and "evdet"
> > + - "interrupt-parent", "interrupts", "interrupts-extended":
> > +   for passing the interrupt line of the SoC connected to #IRQ pin
> > +   and #EVDET pin of the RTC chip.
> Just list 'interrupts' and how many there are. interrupt-parent is 
> implied and may be in a parent node. interrupts-extended is also 
> implicitly allowed as needed.
Will change to: "interrupts": list of interrupts for "irq" and "evdet"
> 
> > 
> > + - "isil,ev-evienb": if present bit can be set to disable event input 
> > pull-up
> > +
> > +
> > +Example isl1219 node with #IRQ pin connected to SoC gpio1 pin12
> > + and #EVDET pin connected to SoC gpio2 pin 24:
> > +
> > +   isl1219: rtc@68 {
> > +   compatible = "isil,isl1219";
> > +   reg = <0x68>;
> > +   interrupt-names = "irq", "evdet";
> > +   interrupts-extended = < 12 IRQ_TYPE_EDGE_FALLING>,
> > +   < 24 IRQ_TYPE_EDGE_FALLING>;
> > +   };
> > +
> > --
> > 2.18.0
> > 
> > 
> > 
> > Diehl Connectivity Solutions GmbH
> > Geschäftsführung: Horst Leonberger
> > Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
> > Nürnberg: HRB 32315
> > ___
> > 
> > Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese 
> > E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
> > Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise 
> > erhalten haben. Bitte loeschen Sie in diesem Fall die Nachricht.
> > Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
> > und/oder Publikation dieser E-Mail ist strengstens untersagt.
> > The contents of the above mentioned e-mail is not legally binding. This 
> > e-mail contains confidential and/or legally protected information. Please 
> > inform us if you have received this e-mail by
> > mistake and delete it in such a case. Each unauthorized reproduction, 
> > disclosure, alteration, distribution and/or publication of this e-mail is 
> > strictly prohibited.

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


Re: [PATCH v4 2/5] rtc: isl1208: add support for isl1219 with tamper detection

2018-07-10 Thread Denis OSTERLAND
Hi,

seems 2/5 was applied before 1/5.
1/5 introduces rtc_add_group.

Regards Denis

Am Dienstag, den 10.07.2018, 21:20 +0800 schrieb kbuild test robot:
> Hi Michael,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on abelloni/rtc-next]
> [also build test ERROR on v4.18-rc4 next-20180709]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Denis-OSTERLAND/rtc-isl1208-fixes-documentation-and-isl1219-support/20180710-181709
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git 
> rtc-next
> config: x86_64-randconfig-s4-07101857 (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=x86_64 
> 
> All errors (new ones prefixed by >>):
> 
> > 
> > > 
> > > ERROR: "rtc_add_group" [drivers/rtc/rtc-isl1208.ko] undefined!
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


Re: [PATCH v4 2/5] rtc: isl1208: add support for isl1219 with tamper detection

2018-07-10 Thread Denis OSTERLAND
Hi,

seems 2/5 was applied before 1/5.
1/5 introduces rtc_add_group.

Regards Denis

Am Dienstag, den 10.07.2018, 21:20 +0800 schrieb kbuild test robot:
> Hi Michael,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on abelloni/rtc-next]
> [also build test ERROR on v4.18-rc4 next-20180709]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Denis-OSTERLAND/rtc-isl1208-fixes-documentation-and-isl1219-support/20180710-181709
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git 
> rtc-next
> config: x86_64-randconfig-s4-07101857 (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=x86_64 
> 
> All errors (new ones prefixed by >>):
> 
> > 
> > > 
> > > ERROR: "rtc_add_group" [drivers/rtc/rtc-isl1208.ko] undefined!
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v4 5/5] rtc: isl1219: add device tree docu

2018-07-10 Thread Denis OSTERLAND
From: Denis Osterland 

The devicetree documentation for the ISL1219 device tree
binding is added with an short example. It is not a trivial
device, because it supports two interrupt souces.

Signed-off-by: Denis Osterland 
---
 .../devicetree/bindings/rtc/isil,isl1219.txt  | 29 +++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/isil,isl1219.txt

diff --git a/Documentation/devicetree/bindings/rtc/isil,isl1219.txt 
b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
new file mode 100644
index ..f26f1e9d4bde
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
@@ -0,0 +1,29 @@
+Intersil ISL1219 I2C RTC/Alarm chip with event in
+
+ISL1219 has additional pins EVIN and #EVDET for tamper detection.
+
+Required properties supported by the device:
+
+ - "compatible": must be "isil,isl1219"
+ - "reg": I2C bus address of the device
+
+Optional properties:
+
+ - "interrupt-names": list which may contains "irq" and "evdet"
+ - "interrupt-parent", "interrupts", "interrupts-extended":
+   for passing the interrupt line of the SoC connected to #IRQ pin
+   and #EVDET pin of the RTC chip.
+ - "isil,ev-evienb": if present bit can be set to disable event input pull-up
+
+
+Example isl1219 node with #IRQ pin connected to SoC gpio1 pin12
+ and #EVDET pin connected to SoC gpio2 pin 24:
+
+   isl1219: rtc@68 {
+   compatible = "isil,isl1219";
+   reg = <0x68>;
+   interrupt-names = "irq", "evdet";
+   interrupts-extended = < 12 IRQ_TYPE_EDGE_FALLING>,
+   < 24 IRQ_TYPE_EDGE_FALLING>;
+   };
+
-- 
2.18.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v4 5/5] rtc: isl1219: add device tree docu

2018-07-10 Thread Denis OSTERLAND
From: Denis Osterland 

The devicetree documentation for the ISL1219 device tree
binding is added with an short example. It is not a trivial
device, because it supports two interrupt souces.

Signed-off-by: Denis Osterland 
---
 .../devicetree/bindings/rtc/isil,isl1219.txt  | 29 +++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/isil,isl1219.txt

diff --git a/Documentation/devicetree/bindings/rtc/isil,isl1219.txt 
b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
new file mode 100644
index ..f26f1e9d4bde
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
@@ -0,0 +1,29 @@
+Intersil ISL1219 I2C RTC/Alarm chip with event in
+
+ISL1219 has additional pins EVIN and #EVDET for tamper detection.
+
+Required properties supported by the device:
+
+ - "compatible": must be "isil,isl1219"
+ - "reg": I2C bus address of the device
+
+Optional properties:
+
+ - "interrupt-names": list which may contains "irq" and "evdet"
+ - "interrupt-parent", "interrupts", "interrupts-extended":
+   for passing the interrupt line of the SoC connected to #IRQ pin
+   and #EVDET pin of the RTC chip.
+ - "isil,ev-evienb": if present bit can be set to disable event input pull-up
+
+
+Example isl1219 node with #IRQ pin connected to SoC gpio1 pin12
+ and #EVDET pin connected to SoC gpio2 pin 24:
+
+   isl1219: rtc@68 {
+   compatible = "isil,isl1219";
+   reg = <0x68>;
+   interrupt-names = "irq", "evdet";
+   interrupts-extended = < 12 IRQ_TYPE_EDGE_FALLING>,
+   < 24 IRQ_TYPE_EDGE_FALLING>;
+   };
+
-- 
2.18.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v4 1/5] rtc: sysfs: facilitate attribute add to rtc device

2018-07-10 Thread Denis OSTERLAND
From: Denis Osterland 

This patches addresses following problem:
rtc_allocate_device
devm_device_add_group  <-- kernel oops / null pointer, because
sysfs entry does not yet exist
rtc_register_device
rc = devm_device_add_group
if (rc)
return rc; <-- forbidden to return error code
after device register

In case groups were not yet registered (kobj.state_in_sysfs == 0)
rtc_add_group just addes given group to dev.groups,
otherwise it uses devm_device_add_group.

Signed-off-by: Denis Osterland 
---
 drivers/rtc/rtc-core.h  |  6 ++
 drivers/rtc/rtc-sysfs.c | 39 +++
 2 files changed, 45 insertions(+)

diff --git a/drivers/rtc/rtc-core.h b/drivers/rtc/rtc-core.h
index 0abf98983e13..81d1c3ce7a96 100644
--- a/drivers/rtc/rtc-core.h
+++ b/drivers/rtc/rtc-core.h
@@ -40,9 +40,15 @@ static inline void rtc_proc_del_device(struct rtc_device 
*rtc)
 
 #ifdef CONFIG_RTC_INTF_SYSFS
 const struct attribute_group **rtc_get_dev_attribute_groups(void);
+int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp);
 #else
 static inline const struct attribute_group **rtc_get_dev_attribute_groups(void)
 {
return NULL;
 }
+static inline
+int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp)
+{
+   return 0;
+}
 #endif
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index 454da38c6012..9a177b8f761b 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -317,3 +317,42 @@ const struct attribute_group 
**rtc_get_dev_attribute_groups(void)
 {
return rtc_attr_groups;
 }
+
+static size_t rtc_group_count(struct rtc_device *rtc)
+{
+   const struct attribute_group **groups = rtc->dev.groups;
+   size_t cnt = 0;
+
+   if (groups)
+   for (; *groups; groups++)
+   cnt++;
+
+   return cnt;
+}
+
+static inline int
+__rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp)
+{
+   size_t cnt = rtc_group_count(rtc);
+   const struct attribute_group **groups, **old;
+
+   groups = devm_kzalloc(>dev, (cnt+2)*sizeof(*groups), GFP_KERNEL);
+   if (IS_ERR_OR_NULL(groups))
+   return PTR_ERR(groups);
+   memcpy(groups, rtc->dev.groups, cnt*sizeof(*groups));
+   groups[cnt] = grp;
+
+   old = rtc->dev.groups;
+   rtc->dev.groups = groups;
+   if (old != rtc_attr_groups)
+   devm_kfree(>dev, old);
+
+   return 0;
+}
+
+int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp)
+{
+   return rtc->dev.kobj.state_in_sysfs ?
+   devm_device_add_group(>dev, grp) :
+   __rtc_add_group(rtc, grp);
+}
-- 
2.18.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v4 1/5] rtc: sysfs: facilitate attribute add to rtc device

2018-07-10 Thread Denis OSTERLAND
From: Denis Osterland 

This patches addresses following problem:
rtc_allocate_device
devm_device_add_group  <-- kernel oops / null pointer, because
sysfs entry does not yet exist
rtc_register_device
rc = devm_device_add_group
if (rc)
return rc; <-- forbidden to return error code
after device register

In case groups were not yet registered (kobj.state_in_sysfs == 0)
rtc_add_group just addes given group to dev.groups,
otherwise it uses devm_device_add_group.

Signed-off-by: Denis Osterland 
---
 drivers/rtc/rtc-core.h  |  6 ++
 drivers/rtc/rtc-sysfs.c | 39 +++
 2 files changed, 45 insertions(+)

diff --git a/drivers/rtc/rtc-core.h b/drivers/rtc/rtc-core.h
index 0abf98983e13..81d1c3ce7a96 100644
--- a/drivers/rtc/rtc-core.h
+++ b/drivers/rtc/rtc-core.h
@@ -40,9 +40,15 @@ static inline void rtc_proc_del_device(struct rtc_device 
*rtc)
 
 #ifdef CONFIG_RTC_INTF_SYSFS
 const struct attribute_group **rtc_get_dev_attribute_groups(void);
+int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp);
 #else
 static inline const struct attribute_group **rtc_get_dev_attribute_groups(void)
 {
return NULL;
 }
+static inline
+int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp)
+{
+   return 0;
+}
 #endif
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index 454da38c6012..9a177b8f761b 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -317,3 +317,42 @@ const struct attribute_group 
**rtc_get_dev_attribute_groups(void)
 {
return rtc_attr_groups;
 }
+
+static size_t rtc_group_count(struct rtc_device *rtc)
+{
+   const struct attribute_group **groups = rtc->dev.groups;
+   size_t cnt = 0;
+
+   if (groups)
+   for (; *groups; groups++)
+   cnt++;
+
+   return cnt;
+}
+
+static inline int
+__rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp)
+{
+   size_t cnt = rtc_group_count(rtc);
+   const struct attribute_group **groups, **old;
+
+   groups = devm_kzalloc(>dev, (cnt+2)*sizeof(*groups), GFP_KERNEL);
+   if (IS_ERR_OR_NULL(groups))
+   return PTR_ERR(groups);
+   memcpy(groups, rtc->dev.groups, cnt*sizeof(*groups));
+   groups[cnt] = grp;
+
+   old = rtc->dev.groups;
+   rtc->dev.groups = groups;
+   if (old != rtc_attr_groups)
+   devm_kfree(>dev, old);
+
+   return 0;
+}
+
+int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp)
+{
+   return rtc->dev.kobj.state_in_sysfs ?
+   devm_device_add_group(>dev, grp) :
+   __rtc_add_group(rtc, grp);
+}
-- 
2.18.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v4 2/5] rtc: isl1208: add support for isl1219 with tamper detection

2018-07-10 Thread Denis OSTERLAND
From: Michael Grzeschik 

We add support for the ISL1219 chip that got an integrated tamper
detection function. This patch implements the feature by adding
an additional timestamp0 file to sysfs device path.
This file contains seconds since epoch, if an event occurred,
or is empty, if none occurred.

Signed-off-by: Michael Grzeschik 
Signed-off-by: Denis Osterland 
---
 drivers/rtc/rtc-isl1208.c | 131 --
 1 file changed, 124 insertions(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 1a2c38cc0178..bb189fe6744a 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include "rtc-core.h"
 
 /* Register map */
 /* rtc section */
@@ -33,13 +34,15 @@
 #define ISL1208_REG_SR_ARST(1<<7)  /* auto reset */
 #define ISL1208_REG_SR_XTOSCB  (1<<6)  /* crystal oscillator */
 #define ISL1208_REG_SR_WRTC(1<<4)  /* write rtc */
+#define ISL1208_REG_SR_EVT (1<<3)  /* event */
 #define ISL1208_REG_SR_ALM (1<<2)  /* alarm */
 #define ISL1208_REG_SR_BAT (1<<1)  /* battery */
 #define ISL1208_REG_SR_RTCF(1<<0)  /* rtc fail */
 #define ISL1208_REG_INT 0x08
 #define ISL1208_REG_INT_ALME   (1<<6)   /* alarm enable */
 #define ISL1208_REG_INT_IM (1<<7)   /* interrupt/alarm mode */
-#define ISL1208_REG_09  0x09   /* reserved */
+#define ISL1219_REG_EV  0x09
+#define ISL1219_REG_EV_EVEN(1<<4)   /* event detection enable */
 #define ISL1208_REG_ATR 0x0a
 #define ISL1208_REG_DTR 0x0b
 
@@ -57,8 +60,24 @@
 #define ISL1208_REG_USR2 0x13
 #define ISL1208_USR_SECTION_LEN 2
 
+/* event section */
+#define ISL1219_REG_SCT 0x14
+#define ISL1219_REG_MNT 0x15
+#define ISL1219_REG_HRT 0x16
+#define ISL1219_REG_DTT 0x17
+#define ISL1219_REG_MOT 0x18
+#define ISL1219_REG_YRT 0x19
+#define ISL1219_EVT_SECTION_LEN 6
+
 static struct i2c_driver isl1208_driver;
 
+/* ISL1208 various variants */
+enum {
+   TYPE_ISL1208 = 0,
+   TYPE_ISL1218,
+   TYPE_ISL1219,
+};
+
 /* block read */
 static int
 isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[],
@@ -80,8 +99,8 @@ isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 
buf[],
};
int ret;
 
-   BUG_ON(reg > ISL1208_REG_USR2);
-   BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
+   WARN_ON(reg > ISL1219_REG_YRT);
+   WARN_ON(reg + len > ISL1219_REG_YRT + 1);
 
ret = i2c_transfer(client->adapter, msgs, 2);
if (ret > 0)
@@ -104,8 +123,8 @@ isl1208_i2c_set_regs(struct i2c_client *client, u8 reg, u8 
const buf[],
};
int ret;
 
-   BUG_ON(reg > ISL1208_REG_USR2);
-   BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
+   WARN_ON(reg > ISL1219_REG_YRT);
+   WARN_ON(reg + len > ISL1219_REG_YRT + 1);
 
i2c_buf[0] = reg;
memcpy(_buf[1], [0], len);
@@ -493,6 +512,73 @@ isl1208_rtc_set_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
return isl1208_i2c_set_alarm(to_i2c_client(dev), alarm);
 }
 
+static ssize_t timestamp0_store(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct i2c_client *client = dev_get_drvdata(dev);
+   int sr;
+
+   sr = isl1208_i2c_get_sr(client);
+   if (sr < 0) {
+   dev_err(dev, "%s: reading SR failed\n", __func__);
+   return sr;
+   }
+
+   sr &= ~ISL1208_REG_SR_EVT;
+
+   sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr);
+   if (sr < 0)
+   dev_err(dev, "%s: writing SR failed\n",
+   __func__);
+
+   return count;
+};
+
+static ssize_t timestamp0_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct i2c_client *client = dev_get_drvdata(dev);
+   u8 regs[ISL1219_EVT_SECTION_LEN] = { 0, };
+   struct rtc_time tm;
+   int sr;
+
+   sr = isl1208_i2c_get_sr(client);
+   if (sr < 0) {
+   dev_err(dev, "%s: reading SR failed\n", __func__);
+   return sr;
+   }
+
+   if (!(sr & ISL1208_REG_SR_EVT))
+   return 0;
+
+   sr = isl1208_i2c_read_regs(client, ISL1219_REG_SCT, regs,
+  ISL1219_EVT_SECTION_LEN);
+   if (sr < 0) {
+   dev_err(dev, "%s: reading event section failed\n",
+   __func__);
+   return 0;
+   }
+
+   /* MSB of each alarm register is an enable bit */
+   tm.tm_sec = bcd2bin(regs[ISL1219_REG_SCT - ISL1219_REG_SCT] & 0x7f);
+   tm.tm_min = bcd2bin(regs[ISL1219_REG_MNT - ISL1219_REG_SCT] & 0x7f);
+   tm.tm_hour = bcd2bin(regs[ISL1219_REG_HRT - ISL1219_REG_SCT] & 0x3f);
+   tm.tm_mday = bcd2bin(regs[IS

[PATCH v4 3/5] rtc: isl1208: Add "evdet" interrupt source for isl1219.

2018-07-10 Thread Denis OSTERLAND
From: Denis Osterland 

Add support for "evdet" named interrupt source.

The check if i2c client irq matches evdet irq is needed
for the case that there is only one interrupt named "evdet".
In this case i2c client code handles this like an unnamed
interrupt souce and assigns the value.

Signed-off-by: Denis Osterland 
Reviewed-by: Michael Grzeschik 
---
 drivers/rtc/rtc-isl1208.c | 46 +--
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index bb189fe6744a..bbe08c1ab9f3 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include "rtc-core.h"
+#include 
 
 /* Register map */
 /* rtc section */
@@ -725,11 +726,30 @@ static const struct attribute_group 
isl1219_rtc_sysfs_files = {
.attrs  = isl1219_rtc_attrs,
 };
 
+static int isl1208_setup_irq(struct i2c_client *client, int irq)
+{
+   int rc = devm_request_threaded_irq(>dev, irq, NULL,
+   isl1208_rtc_interrupt,
+   IRQF_SHARED | IRQF_ONESHOT,
+   isl1208_driver.driver.name,
+   client);
+   if (!rc) {
+   device_init_wakeup(>dev, 1);
+   enable_irq_wake(irq);
+   } else {
+   dev_err(>dev,
+   "Unable to request irq %d, no alarm support\n",
+   irq);
+   }
+   return rc;
+}
+
 static int
 isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
int rc = 0;
struct rtc_device *rtc;
+   int evdet_irq = -1;
 
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -ENODEV;
@@ -766,28 +786,22 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
rc = rtc_add_group(rtc, _rtc_sysfs_files);
if (rc)
return rc;
+   evdet_irq = of_irq_get_byname(client->dev.of_node, "evdet");
}
 
rc = sysfs_create_group(>dev.kobj, _rtc_sysfs_files);
if (rc)
return rc;
 
-   if (client->irq > 0) {
-   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
-  isl1208_rtc_interrupt,
-  IRQF_SHARED | IRQF_ONESHOT,
-  isl1208_driver.driver.name,
-  client);
-   if (!rc) {
-   device_init_wakeup(>dev, 1);
-   enable_irq_wake(client->irq);
-   } else {
-   dev_err(>dev,
-   "Unable to request irq %d, no alarm support\n",
-   client->irq);
-   client->irq = 0;
-   }
-   }
+   if (client->irq > 0)
+   rc = isl1208_setup_irq(client, client->irq);
+   if (rc)
+   return rc;
+
+   if (evdet_irq > 0 && evdet_irq != client->irq)
+   rc = isl1208_setup_irq(client, evdet_irq);
+   if (rc)
+   return rc;
 
return rtc_register_device(rtc);
 }
-- 
2.18.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v4 2/5] rtc: isl1208: add support for isl1219 with tamper detection

2018-07-10 Thread Denis OSTERLAND
From: Michael Grzeschik 

We add support for the ISL1219 chip that got an integrated tamper
detection function. This patch implements the feature by adding
an additional timestamp0 file to sysfs device path.
This file contains seconds since epoch, if an event occurred,
or is empty, if none occurred.

Signed-off-by: Michael Grzeschik 
Signed-off-by: Denis Osterland 
---
 drivers/rtc/rtc-isl1208.c | 131 --
 1 file changed, 124 insertions(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 1a2c38cc0178..bb189fe6744a 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include "rtc-core.h"
 
 /* Register map */
 /* rtc section */
@@ -33,13 +34,15 @@
 #define ISL1208_REG_SR_ARST(1<<7)  /* auto reset */
 #define ISL1208_REG_SR_XTOSCB  (1<<6)  /* crystal oscillator */
 #define ISL1208_REG_SR_WRTC(1<<4)  /* write rtc */
+#define ISL1208_REG_SR_EVT (1<<3)  /* event */
 #define ISL1208_REG_SR_ALM (1<<2)  /* alarm */
 #define ISL1208_REG_SR_BAT (1<<1)  /* battery */
 #define ISL1208_REG_SR_RTCF(1<<0)  /* rtc fail */
 #define ISL1208_REG_INT 0x08
 #define ISL1208_REG_INT_ALME   (1<<6)   /* alarm enable */
 #define ISL1208_REG_INT_IM (1<<7)   /* interrupt/alarm mode */
-#define ISL1208_REG_09  0x09   /* reserved */
+#define ISL1219_REG_EV  0x09
+#define ISL1219_REG_EV_EVEN(1<<4)   /* event detection enable */
 #define ISL1208_REG_ATR 0x0a
 #define ISL1208_REG_DTR 0x0b
 
@@ -57,8 +60,24 @@
 #define ISL1208_REG_USR2 0x13
 #define ISL1208_USR_SECTION_LEN 2
 
+/* event section */
+#define ISL1219_REG_SCT 0x14
+#define ISL1219_REG_MNT 0x15
+#define ISL1219_REG_HRT 0x16
+#define ISL1219_REG_DTT 0x17
+#define ISL1219_REG_MOT 0x18
+#define ISL1219_REG_YRT 0x19
+#define ISL1219_EVT_SECTION_LEN 6
+
 static struct i2c_driver isl1208_driver;
 
+/* ISL1208 various variants */
+enum {
+   TYPE_ISL1208 = 0,
+   TYPE_ISL1218,
+   TYPE_ISL1219,
+};
+
 /* block read */
 static int
 isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[],
@@ -80,8 +99,8 @@ isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 
buf[],
};
int ret;
 
-   BUG_ON(reg > ISL1208_REG_USR2);
-   BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
+   WARN_ON(reg > ISL1219_REG_YRT);
+   WARN_ON(reg + len > ISL1219_REG_YRT + 1);
 
ret = i2c_transfer(client->adapter, msgs, 2);
if (ret > 0)
@@ -104,8 +123,8 @@ isl1208_i2c_set_regs(struct i2c_client *client, u8 reg, u8 
const buf[],
};
int ret;
 
-   BUG_ON(reg > ISL1208_REG_USR2);
-   BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
+   WARN_ON(reg > ISL1219_REG_YRT);
+   WARN_ON(reg + len > ISL1219_REG_YRT + 1);
 
i2c_buf[0] = reg;
memcpy(_buf[1], [0], len);
@@ -493,6 +512,73 @@ isl1208_rtc_set_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
return isl1208_i2c_set_alarm(to_i2c_client(dev), alarm);
 }
 
+static ssize_t timestamp0_store(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct i2c_client *client = dev_get_drvdata(dev);
+   int sr;
+
+   sr = isl1208_i2c_get_sr(client);
+   if (sr < 0) {
+   dev_err(dev, "%s: reading SR failed\n", __func__);
+   return sr;
+   }
+
+   sr &= ~ISL1208_REG_SR_EVT;
+
+   sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr);
+   if (sr < 0)
+   dev_err(dev, "%s: writing SR failed\n",
+   __func__);
+
+   return count;
+};
+
+static ssize_t timestamp0_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct i2c_client *client = dev_get_drvdata(dev);
+   u8 regs[ISL1219_EVT_SECTION_LEN] = { 0, };
+   struct rtc_time tm;
+   int sr;
+
+   sr = isl1208_i2c_get_sr(client);
+   if (sr < 0) {
+   dev_err(dev, "%s: reading SR failed\n", __func__);
+   return sr;
+   }
+
+   if (!(sr & ISL1208_REG_SR_EVT))
+   return 0;
+
+   sr = isl1208_i2c_read_regs(client, ISL1219_REG_SCT, regs,
+  ISL1219_EVT_SECTION_LEN);
+   if (sr < 0) {
+   dev_err(dev, "%s: reading event section failed\n",
+   __func__);
+   return 0;
+   }
+
+   /* MSB of each alarm register is an enable bit */
+   tm.tm_sec = bcd2bin(regs[ISL1219_REG_SCT - ISL1219_REG_SCT] & 0x7f);
+   tm.tm_min = bcd2bin(regs[ISL1219_REG_MNT - ISL1219_REG_SCT] & 0x7f);
+   tm.tm_hour = bcd2bin(regs[ISL1219_REG_HRT - ISL1219_REG_SCT] & 0x3f);
+   tm.tm_mday = bcd2bin(regs[IS

[PATCH v4 3/5] rtc: isl1208: Add "evdet" interrupt source for isl1219.

2018-07-10 Thread Denis OSTERLAND
From: Denis Osterland 

Add support for "evdet" named interrupt source.

The check if i2c client irq matches evdet irq is needed
for the case that there is only one interrupt named "evdet".
In this case i2c client code handles this like an unnamed
interrupt souce and assigns the value.

Signed-off-by: Denis Osterland 
Reviewed-by: Michael Grzeschik 
---
 drivers/rtc/rtc-isl1208.c | 46 +--
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index bb189fe6744a..bbe08c1ab9f3 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include "rtc-core.h"
+#include 
 
 /* Register map */
 /* rtc section */
@@ -725,11 +726,30 @@ static const struct attribute_group 
isl1219_rtc_sysfs_files = {
.attrs  = isl1219_rtc_attrs,
 };
 
+static int isl1208_setup_irq(struct i2c_client *client, int irq)
+{
+   int rc = devm_request_threaded_irq(>dev, irq, NULL,
+   isl1208_rtc_interrupt,
+   IRQF_SHARED | IRQF_ONESHOT,
+   isl1208_driver.driver.name,
+   client);
+   if (!rc) {
+   device_init_wakeup(>dev, 1);
+   enable_irq_wake(irq);
+   } else {
+   dev_err(>dev,
+   "Unable to request irq %d, no alarm support\n",
+   irq);
+   }
+   return rc;
+}
+
 static int
 isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
int rc = 0;
struct rtc_device *rtc;
+   int evdet_irq = -1;
 
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -ENODEV;
@@ -766,28 +786,22 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
rc = rtc_add_group(rtc, _rtc_sysfs_files);
if (rc)
return rc;
+   evdet_irq = of_irq_get_byname(client->dev.of_node, "evdet");
}
 
rc = sysfs_create_group(>dev.kobj, _rtc_sysfs_files);
if (rc)
return rc;
 
-   if (client->irq > 0) {
-   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
-  isl1208_rtc_interrupt,
-  IRQF_SHARED | IRQF_ONESHOT,
-  isl1208_driver.driver.name,
-  client);
-   if (!rc) {
-   device_init_wakeup(>dev, 1);
-   enable_irq_wake(client->irq);
-   } else {
-   dev_err(>dev,
-   "Unable to request irq %d, no alarm support\n",
-   client->irq);
-   client->irq = 0;
-   }
-   }
+   if (client->irq > 0)
+   rc = isl1208_setup_irq(client, client->irq);
+   if (rc)
+   return rc;
+
+   if (evdet_irq > 0 && evdet_irq != client->irq)
+   rc = isl1208_setup_irq(client, evdet_irq);
+   if (rc)
+   return rc;
 
return rtc_register_device(rtc);
 }
-- 
2.18.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v4 0/5] rtc: isl1208: fixes, documentation and isl1219 support

2018-07-10 Thread Denis OSTERLAND
changes since v3:
Add function to rtc-sysfs to add a group to device groups field,
between alloc and register calls.
Remove isl1208 struct to reduce patch footprint.
Change prefix of defines and functions only available on isl1219.
Use DEVICE_ATTR_RW macro for timestamp0 attribute.
Call validate tm before convert and use unsigned long long cased value.
Add device-tree flag to disable event in pull-up to maximize battery
life time.


Michael Grzeschik (1):
rtc: isl1208: add support for isl1219 with tamper detection

Denis Osterland (4):
rtc: sysfs: facilitate attribute add to rtc device
rtc: isl1208: Add "evdet" interrupt source for isl1219.
rtc: isl1208: set ev-evienb bit from device tree
rtc: isl1219: add device tree docu

 .../devicetree/bindings/rtc/isil,isl1219.txt   |  29 
 drivers/rtc/rtc-core.h |   6 +
 drivers/rtc/rtc-isl1208.c  | 181 ++---
 drivers/rtc/rtc-sysfs.c|  39 +
 4 files changed, 232 insertions(+), 23 deletions(-)

Message-Id: 1520246373-19023-1-git-send-email-denis.osterl...@diehl.com





Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v4 0/5] rtc: isl1208: fixes, documentation and isl1219 support

2018-07-10 Thread Denis OSTERLAND
changes since v3:
Add function to rtc-sysfs to add a group to device groups field,
between alloc and register calls.
Remove isl1208 struct to reduce patch footprint.
Change prefix of defines and functions only available on isl1219.
Use DEVICE_ATTR_RW macro for timestamp0 attribute.
Call validate tm before convert and use unsigned long long cased value.
Add device-tree flag to disable event in pull-up to maximize battery
life time.


Michael Grzeschik (1):
rtc: isl1208: add support for isl1219 with tamper detection

Denis Osterland (4):
rtc: sysfs: facilitate attribute add to rtc device
rtc: isl1208: Add "evdet" interrupt source for isl1219.
rtc: isl1208: set ev-evienb bit from device tree
rtc: isl1219: add device tree docu

 .../devicetree/bindings/rtc/isil,isl1219.txt   |  29 
 drivers/rtc/rtc-core.h |   6 +
 drivers/rtc/rtc-isl1208.c  | 181 ++---
 drivers/rtc/rtc-sysfs.c|  39 +
 4 files changed, 232 insertions(+), 23 deletions(-)

Message-Id: 1520246373-19023-1-git-send-email-denis.osterl...@diehl.com





Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v4 4/5] rtc: isl1208: set ev-evienb bit from device tree

2018-07-10 Thread Denis OSTERLAND
From: Denis Osterland 

Add support to disable event in pull-up.

Signed-off-by: Denis Osterland 
---
 drivers/rtc/rtc-isl1208.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index bbe08c1ab9f3..2f18ee3c615a 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -44,6 +44,7 @@
 #define ISL1208_REG_INT_IM (1<<7)   /* interrupt/alarm mode */
 #define ISL1219_REG_EV  0x09
 #define ISL1219_REG_EV_EVEN(1<<4)   /* event detection enable */
+#define ISL1219_REG_EV_EVIENB  (1<<7)   /* event in pull-up disable */
 #define ISL1208_REG_ATR 0x0a
 #define ISL1208_REG_DTR 0x0b
 
@@ -777,7 +778,10 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
 "please set clock.\n");
 
if (id->driver_data == TYPE_ISL1219) {
+   struct device_node *np = client->dev.of_node;
rc = ISL1219_REG_EV_EVEN;
+   if (of_get_property(np, "isil,ev-evienb", NULL))
+   rc |= ISL1219_REG_EV_EVIENB;
rc = i2c_smbus_write_byte_data(client, ISL1219_REG_EV, rc);
if (rc < 0) {
dev_err(>dev, "could not enable tamper 
detection\n");
@@ -786,7 +790,7 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
rc = rtc_add_group(rtc, _rtc_sysfs_files);
if (rc)
return rc;
-   evdet_irq = of_irq_get_byname(client->dev.of_node, "evdet");
+   evdet_irq = of_irq_get_byname(np, "evdet");
}
 
rc = sysfs_create_group(>dev.kobj, _rtc_sysfs_files);
-- 
2.18.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


[PATCH v4 4/5] rtc: isl1208: set ev-evienb bit from device tree

2018-07-10 Thread Denis OSTERLAND
From: Denis Osterland 

Add support to disable event in pull-up.

Signed-off-by: Denis Osterland 
---
 drivers/rtc/rtc-isl1208.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index bbe08c1ab9f3..2f18ee3c615a 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -44,6 +44,7 @@
 #define ISL1208_REG_INT_IM (1<<7)   /* interrupt/alarm mode */
 #define ISL1219_REG_EV  0x09
 #define ISL1219_REG_EV_EVEN(1<<4)   /* event detection enable */
+#define ISL1219_REG_EV_EVIENB  (1<<7)   /* event in pull-up disable */
 #define ISL1208_REG_ATR 0x0a
 #define ISL1208_REG_DTR 0x0b
 
@@ -777,7 +778,10 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
 "please set clock.\n");
 
if (id->driver_data == TYPE_ISL1219) {
+   struct device_node *np = client->dev.of_node;
rc = ISL1219_REG_EV_EVEN;
+   if (of_get_property(np, "isil,ev-evienb", NULL))
+   rc |= ISL1219_REG_EV_EVIENB;
rc = i2c_smbus_write_byte_data(client, ISL1219_REG_EV, rc);
if (rc < 0) {
dev_err(>dev, "could not enable tamper 
detection\n");
@@ -786,7 +790,7 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
rc = rtc_add_group(rtc, _rtc_sysfs_files);
if (rc)
return rc;
-   evdet_irq = of_irq_get_byname(client->dev.of_node, "evdet");
+   evdet_irq = of_irq_get_byname(np, "evdet");
}
 
rc = sysfs_create_group(>dev.kobj, _rtc_sysfs_files);
-- 
2.18.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


Re: [PATCH v3 3/4] rtc: isl1208: add support for isl1219 with tamper detection

2018-03-08 Thread Denis OSTERLAND
Am Mittwoch, den 07.03.2018, 11:47 +0100 schrieb Alexandre Belloni:
> > > > +
> > > > +   tv64.tv_sec = rtc_tm_to_time64();
> > > Why not using an unsigned long long directly here? time64_t is not the
> > > correct type.
> > Do you mean timespec64 is not the correct type here?
> > Then yes, sould be time64_t.
> > If you mean time64_t is not the correct type here,
> > then can you give me some detail why there is no rtc_tm_to_u64,
> > or something like that?
> The rtc subsystem forbids negative times, the proper type should be
> unsigned.
I will add rtc_vaild_tm check.

Which sequence for time conversion would you expect?

time64_t secs = rtc_tm_to_time64();
BUG_ON(secs < 0);
return sprintf(buf, "%llu\n", (unsigned long long)secs);

or

return sprintf(buf, "%llu\n", (unsigned long long)rtc_tm_to_time64());
> 
> > 
> > sprintf(buf, "%lld\n", rtc_tm_to_time64()) seems correct to me.
> > By the way, is it needed to check for seconds < 0 and return error?
> Indeed, you shoud check the tm with rtc_valid_tm before calling
> rtc_tm_to_time64.
> 
> > 
> > > 
> > > > 
> > > > -   rc = sysfs_create_group(>dev.kobj, 
> > > > _rtc_sysfs_files);
> > > > +   if (id->driver_data == TYPE_ISL1219) {
> > > > +   rc = i2c_smbus_write_byte_data(client, ISL1208_REG_09, 
> > > > 0x10);
> > > > +   if (rc < 0) {
> > > > +   dev_err(>dev, "could not enable tamper 
> > > > detection\n");
> > > > +   return rc;
> > > > +   }
> > > > +   isl1208->sysfs_files = _rtc_sysfs_files;
> > > > +   } else {
> > > > +   isl1208->sysfs_files = _rtc_sysfs_files;
> > > > +   }
> > > > +
> > > I don't think the whole isl1208 is necessary. You should probably use
> > > the .is_visible callback of isl1219_rtc_sysfs_files. This will make the
> > > changelog quite smaller.
> > > 
> > Well, I don´t know how to access i2c_device_id from kobject.
> > rtc_attr_is_visible shows how to convert kobject to device and rtc_device,
> > but how to do (id->driver_data == TYPE_ISL1219) here?
> I'd use i2c_set_clientdata/i2c_get_clientdata but I agree that then it
> is basically the same as having isl1208->sysfs_files.
> 
> but this makes me realize that the timestamp file doesn't end up at the
> correct location. What you do now is placing it under the i2c device
> while it should be placed under the rtc device (i.e. in
> /sys/class/rtc/rtcX/). This was a mistake made back in 2006.
> 
> I guess you'll have to add a new group instead of adding to the current
> one.
I guess I found a way to do it.

static struct attribute *isl1219_rtc_attrs[] = {
_attr_timestamp0.attr,
NULL
};

in probe
if (id->driver_data == TYPE_ISL1219) {
sysfs_merge_group(>kobj, _rtc_sysfs_files);

in remove
struct rtc_device *rtc = i2c_get_clientdata(client);
sysfs_unmerge_group(>kobj, _rtc_sysfs_files);

As far as I got it, I can call unmerge even if group was not merged before.
If it works I don´t need struct isl1208 at all.
> 
Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.

Re: [PATCH v3 3/4] rtc: isl1208: add support for isl1219 with tamper detection

2018-03-08 Thread Denis OSTERLAND
Am Mittwoch, den 07.03.2018, 11:47 +0100 schrieb Alexandre Belloni:
> > > > +
> > > > +   tv64.tv_sec = rtc_tm_to_time64();
> > > Why not using an unsigned long long directly here? time64_t is not the
> > > correct type.
> > Do you mean timespec64 is not the correct type here?
> > Then yes, sould be time64_t.
> > If you mean time64_t is not the correct type here,
> > then can you give me some detail why there is no rtc_tm_to_u64,
> > or something like that?
> The rtc subsystem forbids negative times, the proper type should be
> unsigned.
I will add rtc_vaild_tm check.

Which sequence for time conversion would you expect?

time64_t secs = rtc_tm_to_time64();
BUG_ON(secs < 0);
return sprintf(buf, "%llu\n", (unsigned long long)secs);

or

return sprintf(buf, "%llu\n", (unsigned long long)rtc_tm_to_time64());
> 
> > 
> > sprintf(buf, "%lld\n", rtc_tm_to_time64()) seems correct to me.
> > By the way, is it needed to check for seconds < 0 and return error?
> Indeed, you shoud check the tm with rtc_valid_tm before calling
> rtc_tm_to_time64.
> 
> > 
> > > 
> > > > 
> > > > -   rc = sysfs_create_group(>dev.kobj, 
> > > > _rtc_sysfs_files);
> > > > +   if (id->driver_data == TYPE_ISL1219) {
> > > > +   rc = i2c_smbus_write_byte_data(client, ISL1208_REG_09, 
> > > > 0x10);
> > > > +   if (rc < 0) {
> > > > +   dev_err(>dev, "could not enable tamper 
> > > > detection\n");
> > > > +   return rc;
> > > > +   }
> > > > +   isl1208->sysfs_files = _rtc_sysfs_files;
> > > > +   } else {
> > > > +   isl1208->sysfs_files = _rtc_sysfs_files;
> > > > +   }
> > > > +
> > > I don't think the whole isl1208 is necessary. You should probably use
> > > the .is_visible callback of isl1219_rtc_sysfs_files. This will make the
> > > changelog quite smaller.
> > > 
> > Well, I don´t know how to access i2c_device_id from kobject.
> > rtc_attr_is_visible shows how to convert kobject to device and rtc_device,
> > but how to do (id->driver_data == TYPE_ISL1219) here?
> I'd use i2c_set_clientdata/i2c_get_clientdata but I agree that then it
> is basically the same as having isl1208->sysfs_files.
> 
> but this makes me realize that the timestamp file doesn't end up at the
> correct location. What you do now is placing it under the i2c device
> while it should be placed under the rtc device (i.e. in
> /sys/class/rtc/rtcX/). This was a mistake made back in 2006.
> 
> I guess you'll have to add a new group instead of adding to the current
> one.
I guess I found a way to do it.

static struct attribute *isl1219_rtc_attrs[] = {
_attr_timestamp0.attr,
NULL
};

in probe
if (id->driver_data == TYPE_ISL1219) {
sysfs_merge_group(>kobj, _rtc_sysfs_files);

in remove
struct rtc_device *rtc = i2c_get_clientdata(client);
sysfs_unmerge_group(>kobj, _rtc_sysfs_files);

As far as I got it, I can call unmerge even if group was not merged before.
If it works I don´t need struct isl1208 at all.
> 
Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.

Re: [PATCH v3 3/4] rtc: isl1208: add support for isl1219 with tamper detection

2018-03-07 Thread Denis OSTERLAND
Am Dienstag, den 06.03.2018, 21:42 +0100 schrieb Alexandre Belloni:
> On 05/03/2018 at 10:43:52 +0000, Denis OSTERLAND wrote:
> > 
> > diff --git a/Documentation/devicetree/bindings/rtc/isil,isl1219.txt 
> > b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
> > new file mode 100644
> > index 000..7937c13
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
> If you want that file to be reviewed by Rob (DT maintainer), you should
> probably separate it from that patch and copy his email. The bindings
> seem fine to me though.
OK
> 
> > 
> > diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
> > index 1a2c38c..164371b 100644
> > --- a/drivers/rtc/rtc-isl1208.c
> > +++ b/drivers/rtc/rtc-isl1208.c
> > @@ -33,6 +33,7 @@
> >  #define ISL1208_REG_SR_ARST(1<<7)  /* auto reset */
> >  #define ISL1208_REG_SR_XTOSCB  (1<<6)  /* crystal oscillator */
> >  #define ISL1208_REG_SR_WRTC(1<<4)  /* write rtc */
> > +#define ISL1208_REG_SR_EVT (1<<3)  /* event */
> >  #define ISL1208_REG_SR_ALM (1<<2)  /* alarm */
> >  #define ISL1208_REG_SR_BAT (1<<1)  /* battery */
> >  #define ISL1208_REG_SR_RTCF(1<<0)  /* rtc fail */
> > @@ -57,8 +58,29 @@
> >  #define ISL1208_REG_USR2 0x13
> >  #define ISL1208_USR_SECTION_LEN 2
> > 
> > +/* event section */
> > +#define ISL1208_REG_SCT 0x14
> > +#define ISL1208_REG_MNT 0x15
> > +#define ISL1208_REG_HRT 0x16
> > +#define ISL1208_REG_DTT 0x17
> > +#define ISL1208_REG_MOT 0x18
> > +#define ISL1208_REG_YRT 0x19
> > +#define ISL1208_EVT_SECTION_LEN 6
> > +
> Because they are not available on ISL1208, maybe it would be better to
> prefix them with ISL1219.
I see. Yes, this would clarify that they are only available on isl1219.
Shall we rename isl1208_rtc_event_show_timestamp/isl1208_rtc_event_clear
to isl1219_rtc_event_show_timestamp/isl1219_rtc_event_clear, too?
> 
> > 
> > +
> > +   tv64.tv_sec = rtc_tm_to_time64();
> Why not using an unsigned long long directly here? time64_t is not the
> correct type.
Do you mean timespec64 is not the correct type here?
Then yes, sould be time64_t.
If you mean time64_t is not the correct type here,
then can you give me some detail why there is no rtc_tm_to_u64,
or something like that?
sprintf(buf, "%lld\n", rtc_tm_to_time64()) seems correct to me.
By the way, is it needed to check for seconds < 0 and return error?
> 
> > 
> > +
> > +   return sprintf(buf, "%lld\n", (long long) tv64.tv_sec);
> And this should become %llu
> 
> > 
> > +};
> > +
> > +static DEVICE_ATTR(timestamp0, 0640,
> Shouldn't the permissions be 644?
644 is OK
> 
> > 
> > +   isl1208_rtc_event_show_timestamp, isl1208_rtc_event_clear);
> > +
> >  static irqreturn_t
> >  isl1208_rtc_interrupt(int irq, void *data)
> >  {
> >     unsigned long timeout = jiffies + msecs_to_jiffies(1000);
> >     struct i2c_client *client = data;
> > -   struct rtc_device *rtc = i2c_get_clientdata(client);
> > +   struct isl1208 *isl1208 = i2c_get_clientdata(client);
> >     int handled = 0, sr, err;
> > 
> >     /*
> > @@ -521,7 +609,7 @@ isl1208_rtc_interrupt(int irq, void *data)
> >     if (sr & ISL1208_REG_SR_ALM) {
> >     dev_dbg(>dev, "alarm!\n");
> > 
> > -   rtc_update_irq(rtc, 1, RTC_IRQF | RTC_AF);
> > +   rtc_update_irq(isl1208->rtc, 1, RTC_IRQF | RTC_AF);
> > 
> >     /* Clear the alarm */
> >     sr &= ~ISL1208_REG_SR_ALM;
> > @@ -538,6 +626,13 @@ isl1208_rtc_interrupt(int irq, void *data)
> >     return err;
> >     }
> > 
> > +   if (sr & ISL1208_REG_SR_EVT) {
> > +   sysfs_notify(>dev.kobj, NULL,
> > +   dev_attr_timestamp0.attr.name);
> > +   dev_warn(>dev, "event detected");
> > +   handled = 1;
> > +   }
> > +
> >     return handled ? IRQ_HANDLED : IRQ_NONE;
> >  }
> > 
> > @@ -623,11 +718,23 @@ static const struct attribute_group 
> > isl1208_rtc_sysfs_files = {
> >     .attrs  = isl1208_rtc_attrs,
> >  };
> > 
> > +static struct attribute *isl1219_rtc_attrs[] = {
> > +   _attr_atrim.attr,
> > +   _attr_dtrim.attr,
> > +   _attr_usr.attr,
> > +   _attr_timestamp0.attr,
> > +   NULL
> > +};
> > +
> > +static const struct attribute_group isl1219_rtc_sysfs_f

Re: [PATCH v3 3/4] rtc: isl1208: add support for isl1219 with tamper detection

2018-03-07 Thread Denis OSTERLAND
Am Dienstag, den 06.03.2018, 21:42 +0100 schrieb Alexandre Belloni:
> On 05/03/2018 at 10:43:52 +0000, Denis OSTERLAND wrote:
> > 
> > diff --git a/Documentation/devicetree/bindings/rtc/isil,isl1219.txt 
> > b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
> > new file mode 100644
> > index 000..7937c13
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
> If you want that file to be reviewed by Rob (DT maintainer), you should
> probably separate it from that patch and copy his email. The bindings
> seem fine to me though.
OK
> 
> > 
> > diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
> > index 1a2c38c..164371b 100644
> > --- a/drivers/rtc/rtc-isl1208.c
> > +++ b/drivers/rtc/rtc-isl1208.c
> > @@ -33,6 +33,7 @@
> >  #define ISL1208_REG_SR_ARST(1<<7)  /* auto reset */
> >  #define ISL1208_REG_SR_XTOSCB  (1<<6)  /* crystal oscillator */
> >  #define ISL1208_REG_SR_WRTC(1<<4)  /* write rtc */
> > +#define ISL1208_REG_SR_EVT (1<<3)  /* event */
> >  #define ISL1208_REG_SR_ALM (1<<2)  /* alarm */
> >  #define ISL1208_REG_SR_BAT (1<<1)  /* battery */
> >  #define ISL1208_REG_SR_RTCF(1<<0)  /* rtc fail */
> > @@ -57,8 +58,29 @@
> >  #define ISL1208_REG_USR2 0x13
> >  #define ISL1208_USR_SECTION_LEN 2
> > 
> > +/* event section */
> > +#define ISL1208_REG_SCT 0x14
> > +#define ISL1208_REG_MNT 0x15
> > +#define ISL1208_REG_HRT 0x16
> > +#define ISL1208_REG_DTT 0x17
> > +#define ISL1208_REG_MOT 0x18
> > +#define ISL1208_REG_YRT 0x19
> > +#define ISL1208_EVT_SECTION_LEN 6
> > +
> Because they are not available on ISL1208, maybe it would be better to
> prefix them with ISL1219.
I see. Yes, this would clarify that they are only available on isl1219.
Shall we rename isl1208_rtc_event_show_timestamp/isl1208_rtc_event_clear
to isl1219_rtc_event_show_timestamp/isl1219_rtc_event_clear, too?
> 
> > 
> > +
> > +   tv64.tv_sec = rtc_tm_to_time64();
> Why not using an unsigned long long directly here? time64_t is not the
> correct type.
Do you mean timespec64 is not the correct type here?
Then yes, sould be time64_t.
If you mean time64_t is not the correct type here,
then can you give me some detail why there is no rtc_tm_to_u64,
or something like that?
sprintf(buf, "%lld\n", rtc_tm_to_time64()) seems correct to me.
By the way, is it needed to check for seconds < 0 and return error?
> 
> > 
> > +
> > +   return sprintf(buf, "%lld\n", (long long) tv64.tv_sec);
> And this should become %llu
> 
> > 
> > +};
> > +
> > +static DEVICE_ATTR(timestamp0, 0640,
> Shouldn't the permissions be 644?
644 is OK
> 
> > 
> > +   isl1208_rtc_event_show_timestamp, isl1208_rtc_event_clear);
> > +
> >  static irqreturn_t
> >  isl1208_rtc_interrupt(int irq, void *data)
> >  {
> >     unsigned long timeout = jiffies + msecs_to_jiffies(1000);
> >     struct i2c_client *client = data;
> > -   struct rtc_device *rtc = i2c_get_clientdata(client);
> > +   struct isl1208 *isl1208 = i2c_get_clientdata(client);
> >     int handled = 0, sr, err;
> > 
> >     /*
> > @@ -521,7 +609,7 @@ isl1208_rtc_interrupt(int irq, void *data)
> >     if (sr & ISL1208_REG_SR_ALM) {
> >     dev_dbg(>dev, "alarm!\n");
> > 
> > -   rtc_update_irq(rtc, 1, RTC_IRQF | RTC_AF);
> > +   rtc_update_irq(isl1208->rtc, 1, RTC_IRQF | RTC_AF);
> > 
> >     /* Clear the alarm */
> >     sr &= ~ISL1208_REG_SR_ALM;
> > @@ -538,6 +626,13 @@ isl1208_rtc_interrupt(int irq, void *data)
> >     return err;
> >     }
> > 
> > +   if (sr & ISL1208_REG_SR_EVT) {
> > +   sysfs_notify(>dev.kobj, NULL,
> > +   dev_attr_timestamp0.attr.name);
> > +   dev_warn(>dev, "event detected");
> > +   handled = 1;
> > +   }
> > +
> >     return handled ? IRQ_HANDLED : IRQ_NONE;
> >  }
> > 
> > @@ -623,11 +718,23 @@ static const struct attribute_group 
> > isl1208_rtc_sysfs_files = {
> >     .attrs  = isl1208_rtc_attrs,
> >  };
> > 
> > +static struct attribute *isl1219_rtc_attrs[] = {
> > +   _attr_atrim.attr,
> > +   _attr_dtrim.attr,
> > +   _attr_usr.attr,
> > +   _attr_timestamp0.attr,
> > +   NULL
> > +};
> > +
> > +static const struct attribute_group isl1219_rtc_sysfs_f

[PATCH v3 3/4] rtc: isl1208: add support for isl1219 with tamper detection

2018-03-05 Thread Denis OSTERLAND
From: Michael Grzeschik <m.grzesc...@pengutronix.de>

We add support for the ISL1219 chip that got an integrated tamper
detection function. This patch implements the feature by adding
an additional timestamp0 file to sysfs device path.
This file contains seconds since epoch, if an event occurred,
or is empty, if none occurred.

The devicetree documentation for the ISL1219 device tree
binding is added with an short example. It is not a trivial
device, because it supports two interrupt souces.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
Signed-off-by: Denis Osterland <denis.osterl...@diehl.com>
---
 .../devicetree/bindings/rtc/isil,isl1219.txt   |  28 
 drivers/rtc/rtc-isl1208.c  | 160 ++---
 2 files changed, 171 insertions(+), 17 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/isil,isl1219.txt

diff --git a/Documentation/devicetree/bindings/rtc/isil,isl1219.txt 
b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
new file mode 100644
index 000..7937c13
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
@@ -0,0 +1,28 @@
+Intersil ISL1219 I2C RTC/Alarm chip with event in
+
+ISL1219 has additional pins EVIN and #EVDET for tamper detection.
+
+Required properties supported by the device:
+
+ - "compatible": must be "isil,isl1219"
+ - "reg": I2C bus address of the device
+
+Optional properties:
+
+ - "interrupt-names": list which may contains "irq" and "evdet"
+ - "interrupt-parent", "interrupts", "interrupts-extended":
+   for passing the interrupt line of the SoC connected to #IRQ pin
+   and #EVDET pin of the RTC chip.
+
+
+Example isl1219 node with #IRQ pin connected to SoC gpio1 pin12
+ and #EVDET pin connected to SoC gpio2 pin 24:
+
+   isl1219: rtc@68 {
+   compatible = "isil,isl1219";
+   reg = <0x68>;
+   interrupt-names = "irq", "evdet";
+   interrupts-extended = < 12 IRQ_TYPE_EDGE_FALLING>,
+   < 24 IRQ_TYPE_EDGE_FALLING>;
+   };
+
diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 1a2c38c..164371b 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -33,6 +33,7 @@
 #define ISL1208_REG_SR_ARST(1<<7)  /* auto reset */
 #define ISL1208_REG_SR_XTOSCB  (1<<6)  /* crystal oscillator */
 #define ISL1208_REG_SR_WRTC(1<<4)  /* write rtc */
+#define ISL1208_REG_SR_EVT (1<<3)  /* event */
 #define ISL1208_REG_SR_ALM (1<<2)  /* alarm */
 #define ISL1208_REG_SR_BAT (1<<1)  /* battery */
 #define ISL1208_REG_SR_RTCF(1<<0)  /* rtc fail */
@@ -57,8 +58,29 @@
 #define ISL1208_REG_USR2 0x13
 #define ISL1208_USR_SECTION_LEN 2
 
+/* event section */
+#define ISL1208_REG_SCT 0x14
+#define ISL1208_REG_MNT 0x15
+#define ISL1208_REG_HRT 0x16
+#define ISL1208_REG_DTT 0x17
+#define ISL1208_REG_MOT 0x18
+#define ISL1208_REG_YRT 0x19
+#define ISL1208_EVT_SECTION_LEN 6
+
 static struct i2c_driver isl1208_driver;
 
+/* ISL1208 various variants */
+enum {
+   TYPE_ISL1208 = 0,
+   TYPE_ISL1218,
+   TYPE_ISL1219,
+};
+
+struct isl1208 {
+   struct rtc_device *rtc;
+   const struct attribute_group *sysfs_files;
+};
+
 /* block read */
 static int
 isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[],
@@ -80,8 +102,8 @@ isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 
buf[],
};
int ret;
 
-   BUG_ON(reg > ISL1208_REG_USR2);
-   BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
+   WARN_ON(reg > ISL1208_REG_YRT);
+   WARN_ON(reg + len > ISL1208_REG_YRT + 1);
 
ret = i2c_transfer(client->adapter, msgs, 2);
if (ret > 0)
@@ -104,8 +126,8 @@ isl1208_i2c_set_regs(struct i2c_client *client, u8 reg, u8 
const buf[],
};
int ret;
 
-   BUG_ON(reg > ISL1208_REG_USR2);
-   BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
+   WARN_ON(reg > ISL1208_REG_YRT);
+   WARN_ON(reg + len > ISL1208_REG_YRT + 1);
 
i2c_buf[0] = reg;
memcpy(_buf[1], [0], len);
@@ -493,12 +515,78 @@ isl1208_rtc_set_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
return isl1208_i2c_set_alarm(to_i2c_client(dev), alarm);
 }
 
+static ssize_t isl1208_rtc_event_clear(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct i2c_client *client = to_i2c_client(dev);
+   int sr;
+
+   sr = isl1208_i2c_get_sr(client);
+   if (sr < 0) {
+   dev_err(dev, "%s: reading SR failed\n", __func__);
+   return sr;
+   }
+
+   sr &= ~ISL1208_REG_SR_EVT;
+
+   sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr);
+  

[PATCH v3 3/4] rtc: isl1208: add support for isl1219 with tamper detection

2018-03-05 Thread Denis OSTERLAND
From: Michael Grzeschik 

We add support for the ISL1219 chip that got an integrated tamper
detection function. This patch implements the feature by adding
an additional timestamp0 file to sysfs device path.
This file contains seconds since epoch, if an event occurred,
or is empty, if none occurred.

The devicetree documentation for the ISL1219 device tree
binding is added with an short example. It is not a trivial
device, because it supports two interrupt souces.

Signed-off-by: Michael Grzeschik 
Signed-off-by: Denis Osterland 
---
 .../devicetree/bindings/rtc/isil,isl1219.txt   |  28 
 drivers/rtc/rtc-isl1208.c  | 160 ++---
 2 files changed, 171 insertions(+), 17 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/isil,isl1219.txt

diff --git a/Documentation/devicetree/bindings/rtc/isil,isl1219.txt 
b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
new file mode 100644
index 000..7937c13
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
@@ -0,0 +1,28 @@
+Intersil ISL1219 I2C RTC/Alarm chip with event in
+
+ISL1219 has additional pins EVIN and #EVDET for tamper detection.
+
+Required properties supported by the device:
+
+ - "compatible": must be "isil,isl1219"
+ - "reg": I2C bus address of the device
+
+Optional properties:
+
+ - "interrupt-names": list which may contains "irq" and "evdet"
+ - "interrupt-parent", "interrupts", "interrupts-extended":
+   for passing the interrupt line of the SoC connected to #IRQ pin
+   and #EVDET pin of the RTC chip.
+
+
+Example isl1219 node with #IRQ pin connected to SoC gpio1 pin12
+ and #EVDET pin connected to SoC gpio2 pin 24:
+
+   isl1219: rtc@68 {
+   compatible = "isil,isl1219";
+   reg = <0x68>;
+   interrupt-names = "irq", "evdet";
+   interrupts-extended = < 12 IRQ_TYPE_EDGE_FALLING>,
+   < 24 IRQ_TYPE_EDGE_FALLING>;
+   };
+
diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 1a2c38c..164371b 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -33,6 +33,7 @@
 #define ISL1208_REG_SR_ARST(1<<7)  /* auto reset */
 #define ISL1208_REG_SR_XTOSCB  (1<<6)  /* crystal oscillator */
 #define ISL1208_REG_SR_WRTC(1<<4)  /* write rtc */
+#define ISL1208_REG_SR_EVT (1<<3)  /* event */
 #define ISL1208_REG_SR_ALM (1<<2)  /* alarm */
 #define ISL1208_REG_SR_BAT (1<<1)  /* battery */
 #define ISL1208_REG_SR_RTCF(1<<0)  /* rtc fail */
@@ -57,8 +58,29 @@
 #define ISL1208_REG_USR2 0x13
 #define ISL1208_USR_SECTION_LEN 2
 
+/* event section */
+#define ISL1208_REG_SCT 0x14
+#define ISL1208_REG_MNT 0x15
+#define ISL1208_REG_HRT 0x16
+#define ISL1208_REG_DTT 0x17
+#define ISL1208_REG_MOT 0x18
+#define ISL1208_REG_YRT 0x19
+#define ISL1208_EVT_SECTION_LEN 6
+
 static struct i2c_driver isl1208_driver;
 
+/* ISL1208 various variants */
+enum {
+   TYPE_ISL1208 = 0,
+   TYPE_ISL1218,
+   TYPE_ISL1219,
+};
+
+struct isl1208 {
+   struct rtc_device *rtc;
+   const struct attribute_group *sysfs_files;
+};
+
 /* block read */
 static int
 isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[],
@@ -80,8 +102,8 @@ isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 
buf[],
};
int ret;
 
-   BUG_ON(reg > ISL1208_REG_USR2);
-   BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
+   WARN_ON(reg > ISL1208_REG_YRT);
+   WARN_ON(reg + len > ISL1208_REG_YRT + 1);
 
ret = i2c_transfer(client->adapter, msgs, 2);
if (ret > 0)
@@ -104,8 +126,8 @@ isl1208_i2c_set_regs(struct i2c_client *client, u8 reg, u8 
const buf[],
};
int ret;
 
-   BUG_ON(reg > ISL1208_REG_USR2);
-   BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
+   WARN_ON(reg > ISL1208_REG_YRT);
+   WARN_ON(reg + len > ISL1208_REG_YRT + 1);
 
i2c_buf[0] = reg;
memcpy(_buf[1], [0], len);
@@ -493,12 +515,78 @@ isl1208_rtc_set_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
return isl1208_i2c_set_alarm(to_i2c_client(dev), alarm);
 }
 
+static ssize_t isl1208_rtc_event_clear(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct i2c_client *client = to_i2c_client(dev);
+   int sr;
+
+   sr = isl1208_i2c_get_sr(client);
+   if (sr < 0) {
+   dev_err(dev, "%s: reading SR failed\n", __func__);
+   return sr;
+   }
+
+   sr &= ~ISL1208_REG_SR_EVT;
+
+   sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr);
+   if (sr < 0)
+   dev_err(dev, "%s: writing SR failed\n",
+   

[PATCH v3 0/4] rtc: isl1208: fixes, documentation and isl1219 support

2018-03-05 Thread Denis OSTERLAND
changes since v2:
Fix rebase issue in 2/4 and 3/4, where 2/4 uses a data type declared 3/4.

changes since v1:
Represent isl1219 tamper detection as RTC timestamp event,
instead of hwmon intrusion sensor.
Switch to rtc_register_device, to fix possible race conditions in probe.
Add documentation of the two possible interrupt sources for isl1219.
Support "evdet" named interrupt souce.

Michael Grzeschik (2):
  rtc: isl1208: enable interrupt after context preparation
  rtc: isl1208: add support for isl1219 with tamper detection

Denis Osterland (2):
  rtc: isl1208: switch to rtc_register_device
  rtc: isl1208: Add "evdet" interrupt source for isl1219.

 .../devicetree/bindings/rtc/isil,isl1219.txt   |  28 +++
 drivers/rtc/rtc-isl1208.c  | 209 +
 2 files changed, 203 insertions(+), 34 deletions(-)

Message-Id: 1519821214-22379-1-git-send-email-denis.osterl...@diehl.com
Message-Id: 20180123121801.4214-1-m.grzesc...@pengutronix.de


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.


[PATCH v3 2/4] rtc: isl1208: switch to rtc_register_device

2018-03-05 Thread Denis OSTERLAND
From: Denis Osterland <denis.osterl...@diehl.com>

Fix possible race condition.
It is not allowed to return with an error code after RTC is registered.

Suggested-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>
Signed-off-by: Denis Osterland <denis.osterl...@diehl.com>
Reviewed-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/rtc/rtc-isl1208.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index a13a4ba..1a2c38c 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -635,12 +635,12 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (isl1208_i2c_validate_client(client) < 0)
return -ENODEV;
 
-   rtc = devm_rtc_device_register(>dev, isl1208_driver.driver.name,
- _rtc_ops,
- THIS_MODULE);
+   rtc = devm_rtc_allocate_device(>dev);
if (IS_ERR(rtc))
return PTR_ERR(rtc);
 
+   rtc->ops = _rtc_ops;
+
i2c_set_clientdata(client, rtc);
 
rc = isl1208_i2c_get_sr(client);
@@ -674,7 +674,7 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
}
}
 
-   return 0;
+   return rtc_register_device(rtc);
 }
 
 static int
-- 
2.7.4


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.


[PATCH v3 0/4] rtc: isl1208: fixes, documentation and isl1219 support

2018-03-05 Thread Denis OSTERLAND
changes since v2:
Fix rebase issue in 2/4 and 3/4, where 2/4 uses a data type declared 3/4.

changes since v1:
Represent isl1219 tamper detection as RTC timestamp event,
instead of hwmon intrusion sensor.
Switch to rtc_register_device, to fix possible race conditions in probe.
Add documentation of the two possible interrupt sources for isl1219.
Support "evdet" named interrupt souce.

Michael Grzeschik (2):
  rtc: isl1208: enable interrupt after context preparation
  rtc: isl1208: add support for isl1219 with tamper detection

Denis Osterland (2):
  rtc: isl1208: switch to rtc_register_device
  rtc: isl1208: Add "evdet" interrupt source for isl1219.

 .../devicetree/bindings/rtc/isil,isl1219.txt   |  28 +++
 drivers/rtc/rtc-isl1208.c  | 209 +
 2 files changed, 203 insertions(+), 34 deletions(-)

Message-Id: 1519821214-22379-1-git-send-email-denis.osterl...@diehl.com
Message-Id: 20180123121801.4214-1-m.grzesc...@pengutronix.de


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.


[PATCH v3 2/4] rtc: isl1208: switch to rtc_register_device

2018-03-05 Thread Denis OSTERLAND
From: Denis Osterland 

Fix possible race condition.
It is not allowed to return with an error code after RTC is registered.

Suggested-by: Alexandre Belloni 
Signed-off-by: Denis Osterland 
Reviewed-by: Michael Grzeschik 
---
 drivers/rtc/rtc-isl1208.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index a13a4ba..1a2c38c 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -635,12 +635,12 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (isl1208_i2c_validate_client(client) < 0)
return -ENODEV;
 
-   rtc = devm_rtc_device_register(>dev, isl1208_driver.driver.name,
- _rtc_ops,
- THIS_MODULE);
+   rtc = devm_rtc_allocate_device(>dev);
if (IS_ERR(rtc))
return PTR_ERR(rtc);
 
+   rtc->ops = _rtc_ops;
+
i2c_set_clientdata(client, rtc);
 
rc = isl1208_i2c_get_sr(client);
@@ -674,7 +674,7 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
}
}
 
-   return 0;
+   return rtc_register_device(rtc);
 }
 
 static int
-- 
2.7.4


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.


[PATCH v3 1/4] rtc: isl1208: enable interrupt after context preparation

2018-03-05 Thread Denis OSTERLAND
From: Michael Grzeschik <m.grzesc...@pengutronix.de>

The interrupt handler got enabled very early. If the interrupt cause is
triggering immediately before the context is fully prepared. This can
lead to undefined behaviour. Therefor we move the interrupt enable code
to the end of the probe function.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
Signed-off-by: Denis Osterland <denis.osterl...@diehl.com>
---
 drivers/rtc/rtc-isl1208.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index c8b4953..a13a4ba 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -635,23 +635,6 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (isl1208_i2c_validate_client(client) < 0)
return -ENODEV;
 
-   if (client->irq > 0) {
-   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
-  isl1208_rtc_interrupt,
-  IRQF_SHARED | IRQF_ONESHOT,
-  isl1208_driver.driver.name,
-  client);
-   if (!rc) {
-   device_init_wakeup(>dev, 1);
-   enable_irq_wake(client->irq);
-   } else {
-   dev_err(>dev,
-   "Unable to request irq %d, no alarm support\n",
-   client->irq);
-   client->irq = 0;
-   }
-   }
-
rtc = devm_rtc_device_register(>dev, isl1208_driver.driver.name,
  _rtc_ops,
  THIS_MODULE);
@@ -674,6 +657,23 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (rc)
return rc;
 
+   if (client->irq > 0) {
+   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
+  isl1208_rtc_interrupt,
+  IRQF_SHARED | IRQF_ONESHOT,
+  isl1208_driver.driver.name,
+  client);
+   if (!rc) {
+   device_init_wakeup(>dev, 1);
+   enable_irq_wake(client->irq);
+   } else {
+   dev_err(>dev,
+   "Unable to request irq %d, no alarm support\n",
+   client->irq);
+   client->irq = 0;
+   }
+   }
+
return 0;
 }
 
-- 
2.7.4


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.


[PATCH v3 1/4] rtc: isl1208: enable interrupt after context preparation

2018-03-05 Thread Denis OSTERLAND
From: Michael Grzeschik 

The interrupt handler got enabled very early. If the interrupt cause is
triggering immediately before the context is fully prepared. This can
lead to undefined behaviour. Therefor we move the interrupt enable code
to the end of the probe function.

Signed-off-by: Michael Grzeschik 
Signed-off-by: Denis Osterland 
---
 drivers/rtc/rtc-isl1208.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index c8b4953..a13a4ba 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -635,23 +635,6 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (isl1208_i2c_validate_client(client) < 0)
return -ENODEV;
 
-   if (client->irq > 0) {
-   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
-  isl1208_rtc_interrupt,
-  IRQF_SHARED | IRQF_ONESHOT,
-  isl1208_driver.driver.name,
-  client);
-   if (!rc) {
-   device_init_wakeup(>dev, 1);
-   enable_irq_wake(client->irq);
-   } else {
-   dev_err(>dev,
-   "Unable to request irq %d, no alarm support\n",
-   client->irq);
-   client->irq = 0;
-   }
-   }
-
rtc = devm_rtc_device_register(>dev, isl1208_driver.driver.name,
  _rtc_ops,
  THIS_MODULE);
@@ -674,6 +657,23 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (rc)
return rc;
 
+   if (client->irq > 0) {
+   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
+  isl1208_rtc_interrupt,
+  IRQF_SHARED | IRQF_ONESHOT,
+  isl1208_driver.driver.name,
+  client);
+   if (!rc) {
+   device_init_wakeup(>dev, 1);
+   enable_irq_wake(client->irq);
+   } else {
+   dev_err(>dev,
+   "Unable to request irq %d, no alarm support\n",
+   client->irq);
+   client->irq = 0;
+   }
+   }
+
return 0;
 }
 
-- 
2.7.4


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.


[PATCH v3 4/4] rtc: isl1208: Add "evdet" interrupt source for isl1219.

2018-03-05 Thread Denis OSTERLAND
From: Denis Osterland <denis.osterl...@diehl.com>

Add support for "evdet" named interrupt source.

The check if i2c client irq matches evdet irq is needed
for the case that there is only one interrupt named "evdet".
In this case i2c client code handles this like an unnamed
interrupt souce and assigns the value.

Signed-off-by: Denis Osterland <denis.osterl...@diehl.com>
Reviewed-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/rtc/rtc-isl1208.c | 47 +++
 1 file changed, 31 insertions(+), 16 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 164371b..f2f148b 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* Register map */
 /* rtc section */
@@ -79,6 +80,7 @@ enum {
 struct isl1208 {
struct rtc_device *rtc;
const struct attribute_group *sysfs_files;
+   int evdet_irq;
 };
 
 /* block read */
@@ -730,6 +732,24 @@ static const struct attribute_group 
isl1219_rtc_sysfs_files = {
.attrs  = isl1219_rtc_attrs,
 };
 
+static int isl1208_setup_irq(struct i2c_client *client, int irq)
+{
+   int rc = devm_request_threaded_irq(>dev, irq, NULL,
+   isl1208_rtc_interrupt,
+   IRQF_SHARED | IRQF_ONESHOT,
+   isl1208_driver.driver.name,
+   client);
+   if (!rc) {
+   device_init_wakeup(>dev, 1);
+   enable_irq_wake(irq);
+   } else {
+   dev_err(>dev,
+   "Unable to request irq %d, no alarm support\n",
+   irq);
+   }
+   return rc;
+}
+
 static int
 isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
@@ -772,6 +792,8 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
return rc;
}
isl1208->sysfs_files = _rtc_sysfs_files;
+   isl1208->evdet_irq = of_irq_get_byname(client->dev.of_node,
+   "evdet");
} else {
isl1208->sysfs_files = _rtc_sysfs_files;
}
@@ -780,22 +802,15 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (rc)
return rc;
 
-   if (client->irq > 0) {
-   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
-  isl1208_rtc_interrupt,
-  IRQF_SHARED | IRQF_ONESHOT,
-  isl1208_driver.driver.name,
-  client);
-   if (!rc) {
-   device_init_wakeup(>dev, 1);
-   enable_irq_wake(client->irq);
-   } else {
-   dev_err(>dev,
-   "Unable to request irq %d, no alarm support\n",
-   client->irq);
-   client->irq = 0;
-   }
-   }
+   if (client->irq > 0)
+   rc = isl1208_setup_irq(client, client->irq);
+   if (rc)
+   return rc;
+
+   if (isl1208->evdet_irq > 0 && isl1208->evdet_irq != client->irq)
+   rc = isl1208_setup_irq(client, isl1208->evdet_irq);
+   if (rc)
+   return rc;
 
return rtc_register_device(isl1208->rtc);
 }
-- 
2.7.4


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
di

[PATCH v3 4/4] rtc: isl1208: Add "evdet" interrupt source for isl1219.

2018-03-05 Thread Denis OSTERLAND
From: Denis Osterland 

Add support for "evdet" named interrupt source.

The check if i2c client irq matches evdet irq is needed
for the case that there is only one interrupt named "evdet".
In this case i2c client code handles this like an unnamed
interrupt souce and assigns the value.

Signed-off-by: Denis Osterland 
Reviewed-by: Michael Grzeschik 
---
 drivers/rtc/rtc-isl1208.c | 47 +++
 1 file changed, 31 insertions(+), 16 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 164371b..f2f148b 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* Register map */
 /* rtc section */
@@ -79,6 +80,7 @@ enum {
 struct isl1208 {
struct rtc_device *rtc;
const struct attribute_group *sysfs_files;
+   int evdet_irq;
 };
 
 /* block read */
@@ -730,6 +732,24 @@ static const struct attribute_group 
isl1219_rtc_sysfs_files = {
.attrs  = isl1219_rtc_attrs,
 };
 
+static int isl1208_setup_irq(struct i2c_client *client, int irq)
+{
+   int rc = devm_request_threaded_irq(>dev, irq, NULL,
+   isl1208_rtc_interrupt,
+   IRQF_SHARED | IRQF_ONESHOT,
+   isl1208_driver.driver.name,
+   client);
+   if (!rc) {
+   device_init_wakeup(>dev, 1);
+   enable_irq_wake(irq);
+   } else {
+   dev_err(>dev,
+   "Unable to request irq %d, no alarm support\n",
+   irq);
+   }
+   return rc;
+}
+
 static int
 isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
@@ -772,6 +792,8 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
return rc;
}
isl1208->sysfs_files = _rtc_sysfs_files;
+   isl1208->evdet_irq = of_irq_get_byname(client->dev.of_node,
+   "evdet");
} else {
isl1208->sysfs_files = _rtc_sysfs_files;
}
@@ -780,22 +802,15 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (rc)
return rc;
 
-   if (client->irq > 0) {
-   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
-  isl1208_rtc_interrupt,
-  IRQF_SHARED | IRQF_ONESHOT,
-  isl1208_driver.driver.name,
-  client);
-   if (!rc) {
-   device_init_wakeup(>dev, 1);
-   enable_irq_wake(client->irq);
-   } else {
-   dev_err(>dev,
-   "Unable to request irq %d, no alarm support\n",
-   client->irq);
-   client->irq = 0;
-   }
-   }
+   if (client->irq > 0)
+   rc = isl1208_setup_irq(client, client->irq);
+   if (rc)
+   return rc;
+
+   if (isl1208->evdet_irq > 0 && isl1208->evdet_irq != client->irq)
+   rc = isl1208_setup_irq(client, isl1208->evdet_irq);
+   if (rc)
+   return rc;
 
return rtc_register_device(isl1208->rtc);
 }
-- 
2.7.4


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally bindin

Re: [PATCH v2 2/4] rtc: isl1208: switch to rtc_register_device

2018-03-04 Thread Denis OSTERLAND
Hi,

an obvious mistake by me.
isl1208 is introduced in patch 3/4.
I will send v3.
Sorry for that.

Regards Denis

Am Samstag, den 03.03.2018, 10:35 +0800 schrieb kbuild test robot:
> Hi Denis,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on abelloni/rtc-next]
> [also build test ERROR on v4.16-rc3 next-20180302]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Denis-OSTERLAND/rtc-isl1208-fixes-documentation-and-isl1219-support/20180303-093405
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git 
> rtc-next
> config: x86_64-randconfig-x017-201808 (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
> reproduce:
> # save the attached .config to linux build tree
>     make ARCH=x86_64 
> 
> Note: the 
> linux-review/Denis-OSTERLAND/rtc-isl1208-fixes-documentation-and-isl1219-support/20180303-093405
>  HEAD 1d3cf882ecd061847968da1511ec956b9bf70d33 builds fine.
>   It only hurts bisectibility.
> 
> All error/warnings (new ones prefixed by >>):
> 
>    In file included from drivers/rtc/rtc-isl1208.c:16:0:
>    drivers/rtc/rtc-isl1208.c: In function 'isl1208_probe':
> > 
> > > 
> > > drivers/rtc/rtc-isl1208.c:677:29: error: 'isl1208' undeclared (first use 
> > > in this function)
>  return rtc_register_device(isl1208->rtc);
> ^
>    include/linux/rtc.h:261:37: note: in definition of macro 
> 'rtc_register_device'
>  __rtc_register_device(THIS_MODULE, device)
> ^~
>    drivers/rtc/rtc-isl1208.c:677:29: note: each undeclared identifier is 
> reported only once for each function it appears in
>  return rtc_register_device(isl1208->rtc);
> ^
>    include/linux/rtc.h:261:37: note: in definition of macro 
> 'rtc_register_device'
>  __rtc_register_device(THIS_MODULE, device)
> ^~
> > 
> > > 
> > > drivers/rtc/rtc-isl1208.c:678:1: warning: control reaches end of non-void 
> > > function [-Wreturn-type]
> }
> ^
> 
> vim +/isl1208 +677 drivers/rtc/rtc-isl1208.c
> 
>    625
>    626static int
>    627isl1208_probe(struct i2c_client *client, const struct 
> i2c_device_id *id)
>    628{
>    629int rc = 0;
>    630struct rtc_device *rtc;
>    631
>    632if (!i2c_check_functionality(client->adapter, 
> I2C_FUNC_I2C))
>    633return -ENODEV;
>    634
>    635if (isl1208_i2c_validate_client(client) < 0)
>    636return -ENODEV;
>    637
>    638rtc = devm_rtc_allocate_device(>dev);
>    639if (IS_ERR(rtc))
>    640return PTR_ERR(rtc);
>    641
>    642rtc->ops = _rtc_ops;
>    643
>    644i2c_set_clientdata(client, rtc);
>    645
>    646rc = isl1208_i2c_get_sr(client);
>    647if (rc < 0) {
>    648dev_err(>dev, "reading status 
> failed\n");
>    649return rc;
>    650}
>    651
>    652if (rc & ISL1208_REG_SR_RTCF)
>    653dev_warn(>dev, "rtc power failure 
> detected, "
>    654 "please set clock.\n");
>    655
>    656rc = sysfs_create_group(>dev.kobj, 
> _rtc_sysfs_files);
>    657if (rc)
>    658return rc;
>    659
>    660if (client->irq > 0) {
>    661rc = devm_request_threaded_irq(>dev, 
> client->irq, NULL,
>    662   
> isl1208_rtc_interrupt,
>    663   IRQF_SHARED | 
> IRQF_ONESHOT,
>    664   
> isl1208_driver.driver.name,
>    665   client);
>    666if (!rc) {
>    667device_init_wakeup(>dev, 1);
>    668enable_irq_wake(client->irq);
>    669} else {
>    670dev_err(>dev,
>    671   

Re: [PATCH v2 2/4] rtc: isl1208: switch to rtc_register_device

2018-03-04 Thread Denis OSTERLAND
Hi,

an obvious mistake by me.
isl1208 is introduced in patch 3/4.
I will send v3.
Sorry for that.

Regards Denis

Am Samstag, den 03.03.2018, 10:35 +0800 schrieb kbuild test robot:
> Hi Denis,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on abelloni/rtc-next]
> [also build test ERROR on v4.16-rc3 next-20180302]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Denis-OSTERLAND/rtc-isl1208-fixes-documentation-and-isl1219-support/20180303-093405
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git 
> rtc-next
> config: x86_64-randconfig-x017-201808 (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
> reproduce:
> # save the attached .config to linux build tree
>     make ARCH=x86_64 
> 
> Note: the 
> linux-review/Denis-OSTERLAND/rtc-isl1208-fixes-documentation-and-isl1219-support/20180303-093405
>  HEAD 1d3cf882ecd061847968da1511ec956b9bf70d33 builds fine.
>   It only hurts bisectibility.
> 
> All error/warnings (new ones prefixed by >>):
> 
>    In file included from drivers/rtc/rtc-isl1208.c:16:0:
>    drivers/rtc/rtc-isl1208.c: In function 'isl1208_probe':
> > 
> > > 
> > > drivers/rtc/rtc-isl1208.c:677:29: error: 'isl1208' undeclared (first use 
> > > in this function)
>  return rtc_register_device(isl1208->rtc);
> ^
>    include/linux/rtc.h:261:37: note: in definition of macro 
> 'rtc_register_device'
>  __rtc_register_device(THIS_MODULE, device)
> ^~
>    drivers/rtc/rtc-isl1208.c:677:29: note: each undeclared identifier is 
> reported only once for each function it appears in
>  return rtc_register_device(isl1208->rtc);
> ^
>    include/linux/rtc.h:261:37: note: in definition of macro 
> 'rtc_register_device'
>  __rtc_register_device(THIS_MODULE, device)
> ^~
> > 
> > > 
> > > drivers/rtc/rtc-isl1208.c:678:1: warning: control reaches end of non-void 
> > > function [-Wreturn-type]
> }
> ^
> 
> vim +/isl1208 +677 drivers/rtc/rtc-isl1208.c
> 
>    625
>    626static int
>    627isl1208_probe(struct i2c_client *client, const struct 
> i2c_device_id *id)
>    628{
>    629int rc = 0;
>    630struct rtc_device *rtc;
>    631
>    632if (!i2c_check_functionality(client->adapter, 
> I2C_FUNC_I2C))
>    633return -ENODEV;
>    634
>    635if (isl1208_i2c_validate_client(client) < 0)
>    636return -ENODEV;
>    637
>    638rtc = devm_rtc_allocate_device(>dev);
>    639if (IS_ERR(rtc))
>    640return PTR_ERR(rtc);
>    641
>    642rtc->ops = _rtc_ops;
>    643
>    644i2c_set_clientdata(client, rtc);
>    645
>    646rc = isl1208_i2c_get_sr(client);
>    647if (rc < 0) {
>    648dev_err(>dev, "reading status 
> failed\n");
>    649return rc;
>    650}
>    651
>    652if (rc & ISL1208_REG_SR_RTCF)
>    653dev_warn(>dev, "rtc power failure 
> detected, "
>    654 "please set clock.\n");
>    655
>    656rc = sysfs_create_group(>dev.kobj, 
> _rtc_sysfs_files);
>    657if (rc)
>    658return rc;
>    659
>    660if (client->irq > 0) {
>    661rc = devm_request_threaded_irq(>dev, 
> client->irq, NULL,
>    662   
> isl1208_rtc_interrupt,
>    663   IRQF_SHARED | 
> IRQF_ONESHOT,
>    664   
> isl1208_driver.driver.name,
>    665   client);
>    666if (!rc) {
>    667device_init_wakeup(>dev, 1);
>    668enable_irq_wake(client->irq);
>    669} else {
>    670dev_err(>dev,
>    671   

[PATCH v2 2/4] rtc: isl1208: switch to rtc_register_device

2018-02-28 Thread Denis OSTERLAND
From: Denis Osterland <denis.osterl...@diehl.com>

Fix possible race condition.
It is not allowed to return with an error code after RTC is registered.

Suggested-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>
Signed-off-by: Denis Osterland <denis.osterl...@diehl.com>
Reviewed-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/rtc/rtc-isl1208.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index a13a4ba..908fb4d 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -635,12 +635,12 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (isl1208_i2c_validate_client(client) < 0)
return -ENODEV;
 
-   rtc = devm_rtc_device_register(>dev, isl1208_driver.driver.name,
- _rtc_ops,
- THIS_MODULE);
+   rtc = devm_rtc_allocate_device(>dev);
if (IS_ERR(rtc))
return PTR_ERR(rtc);
 
+   rtc->ops = _rtc_ops;
+
i2c_set_clientdata(client, rtc);
 
rc = isl1208_i2c_get_sr(client);
@@ -674,7 +674,7 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
}
}
 
-   return 0;
+   return rtc_register_device(isl1208->rtc);
 }
 
 static int
-- 
2.7.4


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.


[PATCH v2 1/4] rtc: isl1208: enable interrupt after context preparation

2018-02-28 Thread Denis OSTERLAND
From: Michael Grzeschik <m.grzesc...@pengutronix.de>

The interrupt handler got enabled very early. If the interrupt cause is
triggering immediately before the context is fully prepared. This can
lead to undefined behaviour. Therefor we move the interrupt enable code
to the end of the probe function.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
Signed-off-by: Denis Osterland <denis.osterl...@diehl.com>
---
 drivers/rtc/rtc-isl1208.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index c8b4953..a13a4ba 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -635,23 +635,6 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (isl1208_i2c_validate_client(client) < 0)
return -ENODEV;
 
-   if (client->irq > 0) {
-   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
-  isl1208_rtc_interrupt,
-  IRQF_SHARED | IRQF_ONESHOT,
-  isl1208_driver.driver.name,
-  client);
-   if (!rc) {
-   device_init_wakeup(>dev, 1);
-   enable_irq_wake(client->irq);
-   } else {
-   dev_err(>dev,
-   "Unable to request irq %d, no alarm support\n",
-   client->irq);
-   client->irq = 0;
-   }
-   }
-
rtc = devm_rtc_device_register(>dev, isl1208_driver.driver.name,
  _rtc_ops,
  THIS_MODULE);
@@ -674,6 +657,23 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (rc)
return rc;
 
+   if (client->irq > 0) {
+   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
+  isl1208_rtc_interrupt,
+  IRQF_SHARED | IRQF_ONESHOT,
+  isl1208_driver.driver.name,
+  client);
+   if (!rc) {
+   device_init_wakeup(>dev, 1);
+   enable_irq_wake(client->irq);
+   } else {
+   dev_err(>dev,
+   "Unable to request irq %d, no alarm support\n",
+   client->irq);
+   client->irq = 0;
+   }
+   }
+
return 0;
 }
 
-- 
2.7.4


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.


[PATCH v2 2/4] rtc: isl1208: switch to rtc_register_device

2018-02-28 Thread Denis OSTERLAND
From: Denis Osterland 

Fix possible race condition.
It is not allowed to return with an error code after RTC is registered.

Suggested-by: Alexandre Belloni 
Signed-off-by: Denis Osterland 
Reviewed-by: Michael Grzeschik 
---
 drivers/rtc/rtc-isl1208.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index a13a4ba..908fb4d 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -635,12 +635,12 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (isl1208_i2c_validate_client(client) < 0)
return -ENODEV;
 
-   rtc = devm_rtc_device_register(>dev, isl1208_driver.driver.name,
- _rtc_ops,
- THIS_MODULE);
+   rtc = devm_rtc_allocate_device(>dev);
if (IS_ERR(rtc))
return PTR_ERR(rtc);
 
+   rtc->ops = _rtc_ops;
+
i2c_set_clientdata(client, rtc);
 
rc = isl1208_i2c_get_sr(client);
@@ -674,7 +674,7 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
}
}
 
-   return 0;
+   return rtc_register_device(isl1208->rtc);
 }
 
 static int
-- 
2.7.4


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.


[PATCH v2 1/4] rtc: isl1208: enable interrupt after context preparation

2018-02-28 Thread Denis OSTERLAND
From: Michael Grzeschik 

The interrupt handler got enabled very early. If the interrupt cause is
triggering immediately before the context is fully prepared. This can
lead to undefined behaviour. Therefor we move the interrupt enable code
to the end of the probe function.

Signed-off-by: Michael Grzeschik 
Signed-off-by: Denis Osterland 
---
 drivers/rtc/rtc-isl1208.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index c8b4953..a13a4ba 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -635,23 +635,6 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (isl1208_i2c_validate_client(client) < 0)
return -ENODEV;
 
-   if (client->irq > 0) {
-   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
-  isl1208_rtc_interrupt,
-  IRQF_SHARED | IRQF_ONESHOT,
-  isl1208_driver.driver.name,
-  client);
-   if (!rc) {
-   device_init_wakeup(>dev, 1);
-   enable_irq_wake(client->irq);
-   } else {
-   dev_err(>dev,
-   "Unable to request irq %d, no alarm support\n",
-   client->irq);
-   client->irq = 0;
-   }
-   }
-
rtc = devm_rtc_device_register(>dev, isl1208_driver.driver.name,
  _rtc_ops,
  THIS_MODULE);
@@ -674,6 +657,23 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (rc)
return rc;
 
+   if (client->irq > 0) {
+   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
+  isl1208_rtc_interrupt,
+  IRQF_SHARED | IRQF_ONESHOT,
+  isl1208_driver.driver.name,
+  client);
+   if (!rc) {
+   device_init_wakeup(>dev, 1);
+   enable_irq_wake(client->irq);
+   } else {
+   dev_err(>dev,
+   "Unable to request irq %d, no alarm support\n",
+   client->irq);
+   client->irq = 0;
+   }
+   }
+
return 0;
 }
 
-- 
2.7.4


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.


[PATCH v2 0/4] rtc: isl1208: fixes, documentation and isl1219 support

2018-02-28 Thread Denis OSTERLAND
changes since v1:
Represent isl1219 tamper detection as RTC timestamp event,
instead of hwmon intrusion sensor.
Switch to rtc_register_device, to fix possible race conditions in probe.
Add documentation of the two possible interrupt sources for isl1219.
Support "evdet" named interrupt souce.

Michael Grzeschik (2):
  rtc: isl1208: enable interrupt after context preparation
  rtc: isl1208: add support for isl1219 with tamper detection

Denis Osterland (2):
  rtc: isl1208: switch to rtc_register_device
  rtc: isl1208: Add "evdet" interrupt source for isl1219.

 .../devicetree/bindings/rtc/isil,isl1219.txt   |  28 +++
 drivers/rtc/rtc-isl1208.c  | 209 +
 2 files changed, 203 insertions(+), 34 deletions(-)

Message-Id: 20180123121801.4214-1-m.grzesc...@pengutronix.de


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.


[PATCH v2 0/4] rtc: isl1208: fixes, documentation and isl1219 support

2018-02-28 Thread Denis OSTERLAND
changes since v1:
Represent isl1219 tamper detection as RTC timestamp event,
instead of hwmon intrusion sensor.
Switch to rtc_register_device, to fix possible race conditions in probe.
Add documentation of the two possible interrupt sources for isl1219.
Support "evdet" named interrupt souce.

Michael Grzeschik (2):
  rtc: isl1208: enable interrupt after context preparation
  rtc: isl1208: add support for isl1219 with tamper detection

Denis Osterland (2):
  rtc: isl1208: switch to rtc_register_device
  rtc: isl1208: Add "evdet" interrupt source for isl1219.

 .../devicetree/bindings/rtc/isil,isl1219.txt   |  28 +++
 drivers/rtc/rtc-isl1208.c  | 209 +
 2 files changed, 203 insertions(+), 34 deletions(-)

Message-Id: 20180123121801.4214-1-m.grzesc...@pengutronix.de


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.


[PATCH v2 4/4] rtc: isl1208: Add "evdet" interrupt source for isl1219.

2018-02-28 Thread Denis OSTERLAND
From: Denis Osterland <denis.osterl...@diehl.com>

Add support for "evdet" named interrupt source.

The check if i2c client irq matches evdet irq is needed
for the case that there is only one interrupt named "evdet".
In this case i2c client code handles this like an unnamed
interrupt souce and assigns the value.

Signed-off-by: Denis Osterland <denis.osterl...@diehl.com>
Reviewed-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/rtc/rtc-isl1208.c | 47 +++
 1 file changed, 31 insertions(+), 16 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 164371b..f2f148b 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* Register map */
 /* rtc section */
@@ -79,6 +80,7 @@ enum {
 struct isl1208 {
struct rtc_device *rtc;
const struct attribute_group *sysfs_files;
+   int evdet_irq;
 };
 
 /* block read */
@@ -730,6 +732,24 @@ static const struct attribute_group 
isl1219_rtc_sysfs_files = {
.attrs  = isl1219_rtc_attrs,
 };
 
+static int isl1208_setup_irq(struct i2c_client *client, int irq)
+{
+   int rc = devm_request_threaded_irq(>dev, irq, NULL,
+   isl1208_rtc_interrupt,
+   IRQF_SHARED | IRQF_ONESHOT,
+   isl1208_driver.driver.name,
+   client);
+   if (!rc) {
+   device_init_wakeup(>dev, 1);
+   enable_irq_wake(irq);
+   } else {
+   dev_err(>dev,
+   "Unable to request irq %d, no alarm support\n",
+   irq);
+   }
+   return rc;
+}
+
 static int
 isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
@@ -772,6 +792,8 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
return rc;
}
isl1208->sysfs_files = _rtc_sysfs_files;
+   isl1208->evdet_irq = of_irq_get_byname(client->dev.of_node,
+   "evdet");
} else {
isl1208->sysfs_files = _rtc_sysfs_files;
}
@@ -780,22 +802,15 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (rc)
return rc;
 
-   if (client->irq > 0) {
-   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
-  isl1208_rtc_interrupt,
-  IRQF_SHARED | IRQF_ONESHOT,
-  isl1208_driver.driver.name,
-  client);
-   if (!rc) {
-   device_init_wakeup(>dev, 1);
-   enable_irq_wake(client->irq);
-   } else {
-   dev_err(>dev,
-   "Unable to request irq %d, no alarm support\n",
-   client->irq);
-   client->irq = 0;
-   }
-   }
+   if (client->irq > 0)
+   rc = isl1208_setup_irq(client, client->irq);
+   if (rc)
+   return rc;
+
+   if (isl1208->evdet_irq > 0 && isl1208->evdet_irq != client->irq)
+   rc = isl1208_setup_irq(client, isl1208->evdet_irq);
+   if (rc)
+   return rc;
 
return rtc_register_device(isl1208->rtc);
 }
-- 
2.7.4


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
di

[PATCH v2 4/4] rtc: isl1208: Add "evdet" interrupt source for isl1219.

2018-02-28 Thread Denis OSTERLAND
From: Denis Osterland 

Add support for "evdet" named interrupt source.

The check if i2c client irq matches evdet irq is needed
for the case that there is only one interrupt named "evdet".
In this case i2c client code handles this like an unnamed
interrupt souce and assigns the value.

Signed-off-by: Denis Osterland 
Reviewed-by: Michael Grzeschik 
---
 drivers/rtc/rtc-isl1208.c | 47 +++
 1 file changed, 31 insertions(+), 16 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 164371b..f2f148b 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* Register map */
 /* rtc section */
@@ -79,6 +80,7 @@ enum {
 struct isl1208 {
struct rtc_device *rtc;
const struct attribute_group *sysfs_files;
+   int evdet_irq;
 };
 
 /* block read */
@@ -730,6 +732,24 @@ static const struct attribute_group 
isl1219_rtc_sysfs_files = {
.attrs  = isl1219_rtc_attrs,
 };
 
+static int isl1208_setup_irq(struct i2c_client *client, int irq)
+{
+   int rc = devm_request_threaded_irq(>dev, irq, NULL,
+   isl1208_rtc_interrupt,
+   IRQF_SHARED | IRQF_ONESHOT,
+   isl1208_driver.driver.name,
+   client);
+   if (!rc) {
+   device_init_wakeup(>dev, 1);
+   enable_irq_wake(irq);
+   } else {
+   dev_err(>dev,
+   "Unable to request irq %d, no alarm support\n",
+   irq);
+   }
+   return rc;
+}
+
 static int
 isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
@@ -772,6 +792,8 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
return rc;
}
isl1208->sysfs_files = _rtc_sysfs_files;
+   isl1208->evdet_irq = of_irq_get_byname(client->dev.of_node,
+   "evdet");
} else {
isl1208->sysfs_files = _rtc_sysfs_files;
}
@@ -780,22 +802,15 @@ isl1208_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (rc)
return rc;
 
-   if (client->irq > 0) {
-   rc = devm_request_threaded_irq(>dev, client->irq, NULL,
-  isl1208_rtc_interrupt,
-  IRQF_SHARED | IRQF_ONESHOT,
-  isl1208_driver.driver.name,
-  client);
-   if (!rc) {
-   device_init_wakeup(>dev, 1);
-   enable_irq_wake(client->irq);
-   } else {
-   dev_err(>dev,
-   "Unable to request irq %d, no alarm support\n",
-   client->irq);
-   client->irq = 0;
-   }
-   }
+   if (client->irq > 0)
+   rc = isl1208_setup_irq(client, client->irq);
+   if (rc)
+   return rc;
+
+   if (isl1208->evdet_irq > 0 && isl1208->evdet_irq != client->irq)
+   rc = isl1208_setup_irq(client, isl1208->evdet_irq);
+   if (rc)
+   return rc;
 
return rtc_register_device(isl1208->rtc);
 }
-- 
2.7.4


Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally bindin

[PATCH v2 3/4] rtc: isl1208: add support for isl1219 with tamper detection

2018-02-28 Thread Denis OSTERLAND
From: Michael Grzeschik <m.grzesc...@pengutronix.de>

We add support for the ISL1219 chip that got an integrated tamper
detection function. This patch implements the feature by adding
an additional timestamp0 file to sysfs device path.
This file contains seconds since epoch, if an event occurred,
or is empty, if none occurred.

The devicetree documentation for the ISL1219 device tree
binding is added with an short example. It is not a trivial
device, because it supports two interrupt souces.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
Signed-off-by: Denis Osterland <denis.osterl...@diehl.com>
---
 .../devicetree/bindings/rtc/isil,isl1219.txt   |  28 
 drivers/rtc/rtc-isl1208.c  | 158 ++---
 2 files changed, 170 insertions(+), 16 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/isil,isl1219.txt

diff --git a/Documentation/devicetree/bindings/rtc/isil,isl1219.txt 
b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
new file mode 100644
index 000..7937c13
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
@@ -0,0 +1,28 @@
+Intersil ISL1219 I2C RTC/Alarm chip with event in
+
+ISL1219 has additional pins EVIN and #EVDET for tamper detection.
+
+Required properties supported by the device:
+
+ - "compatible": must be "isil,isl1219"
+ - "reg": I2C bus address of the device
+
+Optional properties:
+
+ - "interrupt-names": list which may contains "irq" and "evdet"
+ - "interrupt-parent", "interrupts", "interrupts-extended":
+   for passing the interrupt line of the SoC connected to #IRQ pin
+   and #EVDET pin of the RTC chip.
+
+
+Example isl1219 node with #IRQ pin connected to SoC gpio1 pin12
+ and #EVDET pin connected to SoC gpio2 pin 24:
+
+   isl1219: rtc@68 {
+   compatible = "isil,isl1219";
+   reg = <0x68>;
+   interrupt-names = "irq", "evdet";
+   interrupts-extended = < 12 IRQ_TYPE_EDGE_FALLING>,
+   < 24 IRQ_TYPE_EDGE_FALLING>;
+   };
+
diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 908fb4d..164371b 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -33,6 +33,7 @@
 #define ISL1208_REG_SR_ARST(1<<7)  /* auto reset */
 #define ISL1208_REG_SR_XTOSCB  (1<<6)  /* crystal oscillator */
 #define ISL1208_REG_SR_WRTC(1<<4)  /* write rtc */
+#define ISL1208_REG_SR_EVT (1<<3)  /* event */
 #define ISL1208_REG_SR_ALM (1<<2)  /* alarm */
 #define ISL1208_REG_SR_BAT (1<<1)  /* battery */
 #define ISL1208_REG_SR_RTCF(1<<0)  /* rtc fail */
@@ -57,8 +58,29 @@
 #define ISL1208_REG_USR2 0x13
 #define ISL1208_USR_SECTION_LEN 2
 
+/* event section */
+#define ISL1208_REG_SCT 0x14
+#define ISL1208_REG_MNT 0x15
+#define ISL1208_REG_HRT 0x16
+#define ISL1208_REG_DTT 0x17
+#define ISL1208_REG_MOT 0x18
+#define ISL1208_REG_YRT 0x19
+#define ISL1208_EVT_SECTION_LEN 6
+
 static struct i2c_driver isl1208_driver;
 
+/* ISL1208 various variants */
+enum {
+   TYPE_ISL1208 = 0,
+   TYPE_ISL1218,
+   TYPE_ISL1219,
+};
+
+struct isl1208 {
+   struct rtc_device *rtc;
+   const struct attribute_group *sysfs_files;
+};
+
 /* block read */
 static int
 isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[],
@@ -80,8 +102,8 @@ isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 
buf[],
};
int ret;
 
-   BUG_ON(reg > ISL1208_REG_USR2);
-   BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
+   WARN_ON(reg > ISL1208_REG_YRT);
+   WARN_ON(reg + len > ISL1208_REG_YRT + 1);
 
ret = i2c_transfer(client->adapter, msgs, 2);
if (ret > 0)
@@ -104,8 +126,8 @@ isl1208_i2c_set_regs(struct i2c_client *client, u8 reg, u8 
const buf[],
};
int ret;
 
-   BUG_ON(reg > ISL1208_REG_USR2);
-   BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
+   WARN_ON(reg > ISL1208_REG_YRT);
+   WARN_ON(reg + len > ISL1208_REG_YRT + 1);
 
i2c_buf[0] = reg;
memcpy(_buf[1], [0], len);
@@ -493,12 +515,78 @@ isl1208_rtc_set_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
return isl1208_i2c_set_alarm(to_i2c_client(dev), alarm);
 }
 
+static ssize_t isl1208_rtc_event_clear(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct i2c_client *client = to_i2c_client(dev);
+   int sr;
+
+   sr = isl1208_i2c_get_sr(client);
+   if (sr < 0) {
+   dev_err(dev, "%s: reading SR failed\n", __func__);
+   return sr;
+   }
+
+   sr &= ~ISL1208_REG_SR_EVT;
+
+   sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr);
+  

[PATCH v2 3/4] rtc: isl1208: add support for isl1219 with tamper detection

2018-02-28 Thread Denis OSTERLAND
From: Michael Grzeschik 

We add support for the ISL1219 chip that got an integrated tamper
detection function. This patch implements the feature by adding
an additional timestamp0 file to sysfs device path.
This file contains seconds since epoch, if an event occurred,
or is empty, if none occurred.

The devicetree documentation for the ISL1219 device tree
binding is added with an short example. It is not a trivial
device, because it supports two interrupt souces.

Signed-off-by: Michael Grzeschik 
Signed-off-by: Denis Osterland 
---
 .../devicetree/bindings/rtc/isil,isl1219.txt   |  28 
 drivers/rtc/rtc-isl1208.c  | 158 ++---
 2 files changed, 170 insertions(+), 16 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/isil,isl1219.txt

diff --git a/Documentation/devicetree/bindings/rtc/isil,isl1219.txt 
b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
new file mode 100644
index 000..7937c13
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/isil,isl1219.txt
@@ -0,0 +1,28 @@
+Intersil ISL1219 I2C RTC/Alarm chip with event in
+
+ISL1219 has additional pins EVIN and #EVDET for tamper detection.
+
+Required properties supported by the device:
+
+ - "compatible": must be "isil,isl1219"
+ - "reg": I2C bus address of the device
+
+Optional properties:
+
+ - "interrupt-names": list which may contains "irq" and "evdet"
+ - "interrupt-parent", "interrupts", "interrupts-extended":
+   for passing the interrupt line of the SoC connected to #IRQ pin
+   and #EVDET pin of the RTC chip.
+
+
+Example isl1219 node with #IRQ pin connected to SoC gpio1 pin12
+ and #EVDET pin connected to SoC gpio2 pin 24:
+
+   isl1219: rtc@68 {
+   compatible = "isil,isl1219";
+   reg = <0x68>;
+   interrupt-names = "irq", "evdet";
+   interrupts-extended = < 12 IRQ_TYPE_EDGE_FALLING>,
+   < 24 IRQ_TYPE_EDGE_FALLING>;
+   };
+
diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 908fb4d..164371b 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -33,6 +33,7 @@
 #define ISL1208_REG_SR_ARST(1<<7)  /* auto reset */
 #define ISL1208_REG_SR_XTOSCB  (1<<6)  /* crystal oscillator */
 #define ISL1208_REG_SR_WRTC(1<<4)  /* write rtc */
+#define ISL1208_REG_SR_EVT (1<<3)  /* event */
 #define ISL1208_REG_SR_ALM (1<<2)  /* alarm */
 #define ISL1208_REG_SR_BAT (1<<1)  /* battery */
 #define ISL1208_REG_SR_RTCF(1<<0)  /* rtc fail */
@@ -57,8 +58,29 @@
 #define ISL1208_REG_USR2 0x13
 #define ISL1208_USR_SECTION_LEN 2
 
+/* event section */
+#define ISL1208_REG_SCT 0x14
+#define ISL1208_REG_MNT 0x15
+#define ISL1208_REG_HRT 0x16
+#define ISL1208_REG_DTT 0x17
+#define ISL1208_REG_MOT 0x18
+#define ISL1208_REG_YRT 0x19
+#define ISL1208_EVT_SECTION_LEN 6
+
 static struct i2c_driver isl1208_driver;
 
+/* ISL1208 various variants */
+enum {
+   TYPE_ISL1208 = 0,
+   TYPE_ISL1218,
+   TYPE_ISL1219,
+};
+
+struct isl1208 {
+   struct rtc_device *rtc;
+   const struct attribute_group *sysfs_files;
+};
+
 /* block read */
 static int
 isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[],
@@ -80,8 +102,8 @@ isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 
buf[],
};
int ret;
 
-   BUG_ON(reg > ISL1208_REG_USR2);
-   BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
+   WARN_ON(reg > ISL1208_REG_YRT);
+   WARN_ON(reg + len > ISL1208_REG_YRT + 1);
 
ret = i2c_transfer(client->adapter, msgs, 2);
if (ret > 0)
@@ -104,8 +126,8 @@ isl1208_i2c_set_regs(struct i2c_client *client, u8 reg, u8 
const buf[],
};
int ret;
 
-   BUG_ON(reg > ISL1208_REG_USR2);
-   BUG_ON(reg + len > ISL1208_REG_USR2 + 1);
+   WARN_ON(reg > ISL1208_REG_YRT);
+   WARN_ON(reg + len > ISL1208_REG_YRT + 1);
 
i2c_buf[0] = reg;
memcpy(_buf[1], [0], len);
@@ -493,12 +515,78 @@ isl1208_rtc_set_alarm(struct device *dev, struct 
rtc_wkalrm *alarm)
return isl1208_i2c_set_alarm(to_i2c_client(dev), alarm);
 }
 
+static ssize_t isl1208_rtc_event_clear(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct i2c_client *client = to_i2c_client(dev);
+   int sr;
+
+   sr = isl1208_i2c_get_sr(client);
+   if (sr < 0) {
+   dev_err(dev, "%s: reading SR failed\n", __func__);
+   return sr;
+   }
+
+   sr &= ~ISL1208_REG_SR_EVT;
+
+   sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr);
+   if (sr < 0)
+   dev_err(dev, "%s: writing SR failed\n",
+   

Re: [PATCH 1/4] rtc: isl1208: Fix unintended clear of SR bits

2018-02-14 Thread Denis OSTERLAND
Am Mittwoch, den 14.02.2018, 21:26 +0100 schrieb Alexandre Belloni:
> On 23/01/2018 at 13:17:58 +0100, Michael Grzeschik wrote:
> > 
> > From: Denis Osterland <denis.osterl...@diehl.com>
> > 
> > After successful
> > sr = isl1208_i2c_set_regs(client, 0, regs, ISL1208_RTC_SECTION_LEN);
> > sr will be 0.
> > As a result
> > sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR,
> > sr & ~ISL1208_REG_SR_WRTC);
> > is equal to
> > sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, 0);
> > which clears all flags in SR.
> > 
> > Add an additional read of SR, to have value of SR in sr again.
> > 
> > Signed-off-by: Denis Osterland <denis.osterl...@diehl.com>
> > Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
> > ---
> >  drivers/rtc/rtc-isl1208.c | 5 +
> >  1 file changed, 5 insertions(+)
> > 
> Applied, thanks.
> 
You are welcome.

One question, shall we avoid resent this patch in v2 of this series?
I ask because we are pretty far with the suggested changes.

Regards Denis.
Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.

Re: [PATCH 1/4] rtc: isl1208: Fix unintended clear of SR bits

2018-02-14 Thread Denis OSTERLAND
Am Mittwoch, den 14.02.2018, 21:26 +0100 schrieb Alexandre Belloni:
> On 23/01/2018 at 13:17:58 +0100, Michael Grzeschik wrote:
> > 
> > From: Denis Osterland 
> > 
> > After successful
> > sr = isl1208_i2c_set_regs(client, 0, regs, ISL1208_RTC_SECTION_LEN);
> > sr will be 0.
> > As a result
> > sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR,
> > sr & ~ISL1208_REG_SR_WRTC);
> > is equal to
> > sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, 0);
> > which clears all flags in SR.
> > 
> > Add an additional read of SR, to have value of SR in sr again.
> > 
> > Signed-off-by: Denis Osterland 
> > Signed-off-by: Michael Grzeschik 
> > ---
> >  drivers/rtc/rtc-isl1208.c | 5 +
> >  1 file changed, 5 insertions(+)
> > 
> Applied, thanks.
> 
You are welcome.

One question, shall we avoid resent this patch in v2 of this series?
I ask because we are pretty far with the suggested changes.

Regards Denis.
Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.

Re: [PATCH 4/4] rtc: isl1208: add support for isl1219 with hwmon for tamper detection

2018-01-30 Thread Denis OSTERLAND
Am Dienstag, den 30.01.2018, 11:27 +0100 schrieb Alexandre Belloni:
> On 29/01/2018 at 13:59:19 -0800, Guenter Roeck wrote:
> > 
> > On Wed, Jan 24, 2018 at 10:03:33AM +0100, Michael Grzeschik wrote:
> > [ ... ]
> > > 
> > > > 
> > > > > 
> > > > > +
> > > > > diff --git a/Documentation/hwmon/sysfs-interface 
> > > > > b/Documentation/hwmon/sysfs-interface
> > > > > index fc337c317c673..a12b3c2b2a18c 100644
> > > > > --- a/Documentation/hwmon/sysfs-interface
> > > > > +++ b/Documentation/hwmon/sysfs-interface
> > > > > @@ -702,6 +702,13 @@ intrusion[0-*]_alarm
> > > > >   the user. This is done by writing 0 to the file. Writing
> > > > >   other values is unsupported.
> > > > >  
> > > > > +intrusion[0-*]_timestamp
> > > > > + Chassis intrusion detection
> > > > > + -MM-DD HH:MM:SS UTC (ts.sec): intrusion detected
> > > > > + RO
> > > > > + The corresponding timestamp on which the intrustion
> > > > > + was detected.
> > > > > +
> > > > Sneaky. Nack. You don't just add attributes to the ABI because you want 
> > > > it,
> > > > without serious discussion, and much less so hidden in an RTC driver
> > > > (and even less as unparseable attribute).
> > > Right; but it was not meant to be sneaky. I should have stick to my first
> > > thought and label this patch RFC. Sorry for that.
> > > 
> > > > 
> > > > In addition to that, I consider the attribute unnecessary. The intrusion
> > > > already generates an event which should be sufficient for all practical
> > > > purposes.
> > > Would it make sense in between the other sysfs attributes of this driver?
> > > 
> > I don't understand what you mean with that, sorry.
> > 
> > From an ABI perspective, the attibute doesn't add value since it is
> > highly device specific (or at least it is the only chip I am aware of
> > which reports such a time stamp). Feel free to add the attribute to the
> > driver and document it, but not as part of the hwmon ABI. In that
> > case I would be inclined to accept it. However, keep in mind that
> > your version, reporting a human readable date/time, would effectively
> > preclude it from ever making it into the ABI.
> > 
> Actually, there are many RTCs that are able to register one or more
> timestamps. My plan was to add support for that soon but I was not
> planning to do so in the hwmon ABI as this may be used for something
> that is not intrusion detection (interval timers for example).
What would you suggest?
I think about something like this:
event[0-*]_timestamp: timestamp in seconds since epoch or empty if not triggered
event[0-*]_alarm: 1 if event was triggered, else 0; write 0 to clear event
> 
> 
Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.

Re: [PATCH 4/4] rtc: isl1208: add support for isl1219 with hwmon for tamper detection

2018-01-30 Thread Denis OSTERLAND
Am Dienstag, den 30.01.2018, 11:27 +0100 schrieb Alexandre Belloni:
> On 29/01/2018 at 13:59:19 -0800, Guenter Roeck wrote:
> > 
> > On Wed, Jan 24, 2018 at 10:03:33AM +0100, Michael Grzeschik wrote:
> > [ ... ]
> > > 
> > > > 
> > > > > 
> > > > > +
> > > > > diff --git a/Documentation/hwmon/sysfs-interface 
> > > > > b/Documentation/hwmon/sysfs-interface
> > > > > index fc337c317c673..a12b3c2b2a18c 100644
> > > > > --- a/Documentation/hwmon/sysfs-interface
> > > > > +++ b/Documentation/hwmon/sysfs-interface
> > > > > @@ -702,6 +702,13 @@ intrusion[0-*]_alarm
> > > > >   the user. This is done by writing 0 to the file. Writing
> > > > >   other values is unsupported.
> > > > >  
> > > > > +intrusion[0-*]_timestamp
> > > > > + Chassis intrusion detection
> > > > > + -MM-DD HH:MM:SS UTC (ts.sec): intrusion detected
> > > > > + RO
> > > > > + The corresponding timestamp on which the intrustion
> > > > > + was detected.
> > > > > +
> > > > Sneaky. Nack. You don't just add attributes to the ABI because you want 
> > > > it,
> > > > without serious discussion, and much less so hidden in an RTC driver
> > > > (and even less as unparseable attribute).
> > > Right; but it was not meant to be sneaky. I should have stick to my first
> > > thought and label this patch RFC. Sorry for that.
> > > 
> > > > 
> > > > In addition to that, I consider the attribute unnecessary. The intrusion
> > > > already generates an event which should be sufficient for all practical
> > > > purposes.
> > > Would it make sense in between the other sysfs attributes of this driver?
> > > 
> > I don't understand what you mean with that, sorry.
> > 
> > From an ABI perspective, the attibute doesn't add value since it is
> > highly device specific (or at least it is the only chip I am aware of
> > which reports such a time stamp). Feel free to add the attribute to the
> > driver and document it, but not as part of the hwmon ABI. In that
> > case I would be inclined to accept it. However, keep in mind that
> > your version, reporting a human readable date/time, would effectively
> > preclude it from ever making it into the ABI.
> > 
> Actually, there are many RTCs that are able to register one or more
> timestamps. My plan was to add support for that soon but I was not
> planning to do so in the hwmon ABI as this may be used for something
> that is not intrusion detection (interval timers for example).
What would you suggest?
I think about something like this:
event[0-*]_timestamp: timestamp in seconds since epoch or empty if not triggered
event[0-*]_alarm: 1 if event was triggered, else 0; write 0 to clear event
> 
> 
Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – 
Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr 
Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), 
Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, 
Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) 
Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form 
der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation 
dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by mistake and delete it in such a case. Each 
unauthorized reproduction, disclosure, alteration, distribution and/or 
publication of this e-mail is strictly prohibited.

Re: [PATCH 4/4] rtc: isl1208: add support for isl1219 with hwmon for tamper detection

2018-01-30 Thread Denis OSTERLAND
Am Montag, den 29.01.2018, 17:41 -0600 schrieb Rob Herring:
> On Tue, Jan 23, 2018 at 01:18:01PM +0100, Michael Grzeschik wrote:
> > 
> > We add support for the ISL1219 chip that got an integrated tamper
> > detection function. This patch implements the feature by using an hwmon
> > interface.
> > 
> > The ISL1219 can also describe the timestamp of the intrusion
> > event. For this we add the documentation of the new interface
> > intrusion[0-*]_timestamp.
> > 
> > The devicetree documentation for the ISL1219 device tree
> > binding is added with an short example.
> > 
> > Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
> > Signed-off-by: Denis Osterland <denis.osterl...@diehl.com>
> > ---
> >  .../rtc/{intersil,isl1208.txt => isil,isl1208.txt} |  18 +-
> >  Documentation/hwmon/sysfs-interface|   7 +
> >  drivers/rtc/rtc-isl1208.c  | 190 
> > +++--
> >  3 files changed, 201 insertions(+), 14 deletions(-)
> >  rename Documentation/devicetree/bindings/rtc/{intersil,isl1208.txt => 
> > isil,isl1208.txt} (57%)
> > 
> > diff --git a/Documentation/devicetree/bindings/rtc/intersil,isl1208.txt 
> > b/Documentation/devicetree/bindings/rtc/isil,isl1208.txt
> > similarity index 57%
> > rename from Documentation/devicetree/bindings/rtc/intersil,isl1208.txt
> > rename to Documentation/devicetree/bindings/rtc/isil,isl1208.txt
> > index a54e99feae1ca..d549699e1cfc4 100644
> > --- a/Documentation/devicetree/bindings/rtc/intersil,isl1208.txt
> > +++ b/Documentation/devicetree/bindings/rtc/isil,isl1208.txt
> > @@ -1,14 +1,21 @@
> > -Intersil ISL1208, ISL1218 I2C RTC/Alarm chip
> > +Intersil ISL1208, ISL1218, ISL1219 I2C RTC/Alarm chip
> >  
> >  ISL1208 is a trivial I2C device (it has simple device tree bindings,
> >  consisting of a compatible field, an address and possibly an interrupt
> >  line).
> >  
> > +ISL1219 supports tamper detection user space representation through
> > +case intrusion hwmon sensor.
> User space and hwmon are Linux details not relevant to the binding. Just 
> describe the h/w.
OK.
> 
> > 
> > +ISL1219 has additional pins EVIN and #EVDET for tamper detection.
> > +I2C devices support only one irq. #IRQ and #EVDET are open-drain active 
> > low,
> > +so it is possible layout them to one SoC pin with pull-up.
> > +
> >  Required properties supported by the device:
> >  
> >   - "compatible": must be one of
> >     "isil,isl1208"
> >     "isil,isl1218"
> > +   "isil,isl1219"
> >   - "reg": I2C bus address of the device
> >  
> >  Optional properties:
> > @@ -33,3 +40,12 @@ Example isl1208 node with #IRQ pin connected to SoC 
> > gpio1 pin 12:
> >     interrupt-parent = <>;
> >     interrupts = <12 IRQ_TYPE_EDGE_FALLING>;
> >     };
> > +
> > +Example isl1219 node with #IRQ pin and #EVDET pin connected to SoC gpio1 
> > pin 12:
> > +
> > +   isl1219: isl1219@68 {
> > +   compatible = "intersil,isl1219";
> > +   reg = <0x68>;
> > +   interrupts-extended = < 12 IRQ_TYPE_EDGE_FALLING>;
> With 2 interrupts, you should have 2 values. If they are connected 
> together, just repeat the connection. Otherwise, you can't tell if EVDET 
> is a no connect.
If I got you right, you suggest an additional IRQ entry to parse.
A short example, #IRQ pin connected to gpio1 pin 12 and
#EVDET pin connected to gpio2 pin 24:

isl1219: rtc@68 {
compatible = "intersil,isl1219";
reg = <0x68>;
interrupt-names = "irq", "evdet";
interrupts-extended = < 12 IRQ_TYPE_EDGE_FALLING>,
< 24 IRQ_TYPE_EDGE_FALLING>;
};

In driver implementation we need only one interrupt, because we can
determinate action to take based on value of status register.
In current implementation there was no need to do some additional
OF parsing, everything is done by I2C generic code.
I guess, it is not much additional work to do so, but I am not sure
if it´s worthwhile.
> 
> There's not much point in having an example for every compatible. This 
> binding is simple enough, one should be enough.
Shell we remove the example without an interrupt?
> 
> > 
> > +   };
> > +
Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
62

Re: [PATCH 4/4] rtc: isl1208: add support for isl1219 with hwmon for tamper detection

2018-01-30 Thread Denis OSTERLAND
Am Montag, den 29.01.2018, 17:41 -0600 schrieb Rob Herring:
> On Tue, Jan 23, 2018 at 01:18:01PM +0100, Michael Grzeschik wrote:
> > 
> > We add support for the ISL1219 chip that got an integrated tamper
> > detection function. This patch implements the feature by using an hwmon
> > interface.
> > 
> > The ISL1219 can also describe the timestamp of the intrusion
> > event. For this we add the documentation of the new interface
> > intrusion[0-*]_timestamp.
> > 
> > The devicetree documentation for the ISL1219 device tree
> > binding is added with an short example.
> > 
> > Signed-off-by: Michael Grzeschik 
> > Signed-off-by: Denis Osterland 
> > ---
> >  .../rtc/{intersil,isl1208.txt => isil,isl1208.txt} |  18 +-
> >  Documentation/hwmon/sysfs-interface|   7 +
> >  drivers/rtc/rtc-isl1208.c  | 190 
> > +++--
> >  3 files changed, 201 insertions(+), 14 deletions(-)
> >  rename Documentation/devicetree/bindings/rtc/{intersil,isl1208.txt => 
> > isil,isl1208.txt} (57%)
> > 
> > diff --git a/Documentation/devicetree/bindings/rtc/intersil,isl1208.txt 
> > b/Documentation/devicetree/bindings/rtc/isil,isl1208.txt
> > similarity index 57%
> > rename from Documentation/devicetree/bindings/rtc/intersil,isl1208.txt
> > rename to Documentation/devicetree/bindings/rtc/isil,isl1208.txt
> > index a54e99feae1ca..d549699e1cfc4 100644
> > --- a/Documentation/devicetree/bindings/rtc/intersil,isl1208.txt
> > +++ b/Documentation/devicetree/bindings/rtc/isil,isl1208.txt
> > @@ -1,14 +1,21 @@
> > -Intersil ISL1208, ISL1218 I2C RTC/Alarm chip
> > +Intersil ISL1208, ISL1218, ISL1219 I2C RTC/Alarm chip
> >  
> >  ISL1208 is a trivial I2C device (it has simple device tree bindings,
> >  consisting of a compatible field, an address and possibly an interrupt
> >  line).
> >  
> > +ISL1219 supports tamper detection user space representation through
> > +case intrusion hwmon sensor.
> User space and hwmon are Linux details not relevant to the binding. Just 
> describe the h/w.
OK.
> 
> > 
> > +ISL1219 has additional pins EVIN and #EVDET for tamper detection.
> > +I2C devices support only one irq. #IRQ and #EVDET are open-drain active 
> > low,
> > +so it is possible layout them to one SoC pin with pull-up.
> > +
> >  Required properties supported by the device:
> >  
> >   - "compatible": must be one of
> >     "isil,isl1208"
> >     "isil,isl1218"
> > +   "isil,isl1219"
> >   - "reg": I2C bus address of the device
> >  
> >  Optional properties:
> > @@ -33,3 +40,12 @@ Example isl1208 node with #IRQ pin connected to SoC 
> > gpio1 pin 12:
> >     interrupt-parent = <>;
> >     interrupts = <12 IRQ_TYPE_EDGE_FALLING>;
> >     };
> > +
> > +Example isl1219 node with #IRQ pin and #EVDET pin connected to SoC gpio1 
> > pin 12:
> > +
> > +   isl1219: isl1219@68 {
> > +   compatible = "intersil,isl1219";
> > +   reg = <0x68>;
> > +   interrupts-extended = < 12 IRQ_TYPE_EDGE_FALLING>;
> With 2 interrupts, you should have 2 values. If they are connected 
> together, just repeat the connection. Otherwise, you can't tell if EVDET 
> is a no connect.
If I got you right, you suggest an additional IRQ entry to parse.
A short example, #IRQ pin connected to gpio1 pin 12 and
#EVDET pin connected to gpio2 pin 24:

isl1219: rtc@68 {
compatible = "intersil,isl1219";
reg = <0x68>;
interrupt-names = "irq", "evdet";
interrupts-extended = < 12 IRQ_TYPE_EDGE_FALLING>,
< 24 IRQ_TYPE_EDGE_FALLING>;
};

In driver implementation we need only one interrupt, because we can
determinate action to take based on value of status register.
In current implementation there was no need to do some additional
OF parsing, everything is done by I2C generic code.
I guess, it is not much additional work to do so, but I am not sure
if it´s worthwhile.
> 
> There's not much point in having an example for every compatible. This 
> binding is simple enough, one should be enough.
Shell we remove the example without an interrupt?
> 
> > 
> > +   };
> > +
Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner 
(Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 
620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stif