Skip to contentSkip to conversation

Add support for hym8563 rtcs

PATCH Superseded Heiko Stübner 2 participants 6 messages Nov 22, 2013 – Nov 25, 2013

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Add support for hym8563 rtcs

This series adds support for the Haoyu Microelectronics HYM8563 rtc. This chip is often used in designs around the Cortex-A9 SoCs from Rockchip to provide rtc functionality and the 32kHz suspend clock the SoC needs.

Heiko Stuebner (2):
Documentation: dt: Add dt hym8563 binding
rtc: add hym8563 rtc-driver

 .../devicetree/bindings/rtc/haoyu,hym8563.txt      |   29 +
 drivers/rtc/Kconfig                                |   11 +
 drivers/rtc/Makefile                               |    1 +
 drivers/rtc/rtc-hym8563.c                          |  619 ++++++++++++++++++++
 4 files changed, 660 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/haoyu,hym8563.txt
 create mode 100644 drivers/rtc/rtc-hym8563.c
Signature · 6 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

PATCH 1/2 dt-bindings: add hym8563 binding

Add binding documentation for the hym8563 rtc chip.

---
 .../devicetree/bindings/rtc/haoyu,hym8563.txt      |   29 ++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/haoyu,hym8563.txt
Documentation/devicetree/bindings/rtc/haoyu,hym8563.txt new file +29 -0
new file mode 100644
index 0000000..2743416
@@ -0,0 +1,29 @@
+Haoyu Microelectronics HYM8563 Real Time Clock
+
+The HYM8563 provides basic rtc and alarm functionality
+as well as a clock output of up to 32kHz.
+
+Required properties:
+- compatible: should be: "haoyu,hym8563"
+- reg: i2c address
+- gpios: interrupt gpio
+- interrupts: rtc alarm/event interrupt
+- #clock-cells: the value should be 0
+
+Example:
+
+hym8563: hym8563@51 {
+	compatible = "haoyu,hym8563";
+	reg = <0x51>;
+
+	gpios = <&gpio0 13 0>;
+	interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
+
+	#clock-cells = <0>;
+};
+
+device {
+...
+	clocks = <&hym8563>;
+...
+};
Signature · 1 line
1.7.10.4
#2 lore raw

Re: [PATCH 1/2] dt-bindings: add hym8563 binding

Quoted 14 lines · Heiko Stübner

Add binding documentation for the hym8563 rtc chip.

---
 .../devicetree/bindings/rtc/haoyu,hym8563.txt      |   29 ++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/haoyu,hym8563.txt
Documentation/devicetree/bindings/rtc/haoyu,hym8563.txt new file +0 -0
new file mode 100644
index 0000000..2743416

Documentation/devicetree/bindings/rtc/haoyu,hym8563.txt line 7

Quoted 7 lines
Documentation/devicetree/bindings/rtc/haoyu,hym8563.txt new file +7 -0
@@ -0,0 +1,29 @@
+Haoyu Microelectronics HYM8563 Real Time Clock
+
+The HYM8563 provides basic rtc and alarm functionality
+as well as a clock output of up to 32kHz.
+
+Required properties:
+- compatible: should be: "haoyu,hym8563"

The "haoyu" vendor prefix will need to be documented (I couldn't spot it in mainline's vendor-refixes.txt).

Documentation/devicetree/bindings/rtc/haoyu,hym8563.txt line 9

Quoted 2 lines
Documentation/devicetree/bindings/rtc/haoyu,hym8563.txt new file +2 -0
+- reg: i2c address
+- gpios: interrupt gpio

What's this used for exactly?

Thanks,
Mark.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

PATCH 2/2 rtc: add hym8563 rtc-driver

In reply to Heiko Stübner

The Haoyu Microelectronics HYM8563 provides rtc- and alarm functions as well as a clock output of up to 32kHz.

---
 drivers/rtc/Kconfig       |   11 +
 drivers/rtc/Makefile      |    1 +
 drivers/rtc/rtc-hym8563.c |  619 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 631 insertions(+)
 create mode 100644 drivers/rtc/rtc-hym8563.c
drivers/rtc/Kconfig +11 -0
index 0077302..4bd489c 100644
@@ -212,6 +212,17 @@ config RTC_DRV_DS3232
 	  This driver can also be built as a module.  If so, the module
 	  will be called rtc-ds3232.
 
+config RTC_DRV_HYM8563
+	tristate "Haoyu Microelectronics HYM8563"
+	depends on I2C && OF
+	help
+	  Say Y to enable support for the HYM8563 I2C RTC chip. Apart
+	  from the usual rtc functions it provides a clock output of
+	  up to 32kHz.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rtc-hym8563.
+
 config RTC_DRV_LP8788
 	tristate "TI LP8788 RTC driver"
 	depends on MFD_LP8788
drivers/rtc/Makefile +1 -0
index 27b4bd8..913c5be 100644
@@ -55,6 +55,7 @@ obj-$(CONFIG_RTC_DRV_EP93XX)	+= rtc-ep93xx.o
 obj-$(CONFIG_RTC_DRV_FM3130)	+= rtc-fm3130.o
 obj-$(CONFIG_RTC_DRV_GENERIC)	+= rtc-generic.o
 obj-$(CONFIG_RTC_DRV_HID_SENSOR_TIME) += rtc-hid-sensor-time.o
+obj-$(CONFIG_RTC_DRV_HYM8563)	+= rtc-hym8563.o
 obj-$(CONFIG_RTC_DRV_IMXDI)	+= rtc-imxdi.o
 obj-$(CONFIG_RTC_DRV_ISL1208)	+= rtc-isl1208.o
 obj-$(CONFIG_RTC_DRV_ISL12022)	+= rtc-isl12022.o
drivers/rtc/rtc-hym8563.c new file +619 -0

619 lines not on this page · raw message

Signature · 6 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

Re: [PATCH 2/2] rtc: add hym8563 rtc-driver

[...]

Quoted 29 lines
drivers/rtc/rtc-hym8563.c new file +28 -0
+static int hym8563_probe(struct i2c_client *client,
+                        const struct i2c_device_id *id)
+{
+       struct hym8563 *hym8563;
+       int ret, gpio_int;
+
+       hym8563 = devm_kzalloc(&client->dev, sizeof(hym8563), GFP_KERNEL);
+       if (!hym8563)
+               return -ENOMEM;
+
+       hym8563->client = client;
+       i2c_set_clientdata(client, hym8563);
+
+       device_set_wakeup_capable(&client->dev, true);
+
+       gpio_int = of_get_gpio(client->dev.of_node, 0);
+       if (!gpio_is_valid(gpio_int)) {
+               dev_err(&client->dev, "failed to get interrupt gpio\n");
+               return -EINVAL;
+       }
+
+       ret = devm_gpio_request_one(&client->dev, gpio_int,
+                                     GPIOF_DIR_IN, "hym8563_int");
+       if (ret) {
+               dev_err(&client->dev, "request of gpio %d failed, %d\n",
+                       gpio_int, ret);
+               return ret;
+       }
Quoted 1 line

From here on the gpio is never used or even stashed away anywhere.

What's the point in requesting it and then leaking it?

Thanks,
Mark.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

Re: [PATCH 2/2] rtc: add hym8563 rtc-driver

Am Montag, 25. November 2013, 13:01:25 schrieb Mark Rutland:

Quoted 25 lines

[...]

Quoted 23 lines
drivers/rtc/rtc-hym8563.c new file +7 -0
+static int hym8563_probe(struct i2c_client *client,
+                        const struct i2c_device_id *id)
+{
+       struct hym8563 *hym8563;
+       int ret, gpio_int;
+
+       hym8563 = devm_kzalloc(&client->dev, sizeof(hym8563),

GFP_KERNEL); + if (!hym8563)

drivers/rtc/rtc-hym8563.c new file +15 -0
+               return -ENOMEM;
+
+       hym8563->client = client;
+       i2c_set_clientdata(client, hym8563);
+
+       device_set_wakeup_capable(&client->dev, true);
+
+       gpio_int = of_get_gpio(client->dev.of_node, 0);
+       if (!gpio_is_valid(gpio_int)) {
+               dev_err(&client->dev, "failed to get interrupt gpio\n");
+               return -EINVAL;
+       }
+
+       ret = devm_gpio_request_one(&client->dev, gpio_int,
+                                     GPIOF_DIR_IN, "hym8563_int");
Quoted 8 lines

drivers/rtc/rtc-hym8563.c line 554

Quoted 5 lines
drivers/rtc/rtc-hym8563.c new file +5 -0
+       if (ret) {
+               dev_err(&client->dev, "request of gpio %d failed, %d\n",
+                       gpio_int, ret);
+               return ret;
+       }

From here on the gpio is never used or even stashed away anywhere. What's the point in requesting it and then leaking it?

As I understand it, requesting gpio also is useful as a mechanism to mark them as used and therefore prevent a gpio from wrongly being used multiple times.

So, I guess it would be better to either ignore client->irq and just use gpio_to_irq or use client->irq alone, without the gpio-functions at all.

But what would be preferrable?