Re: [U-Boot] [PATCH 01/22] dm: rtc: Add 16-bit read/write support

2017-03-31 Thread Bin Meng
On Fri, Mar 17, 2017 at 11:26 AM, Simon Glass  wrote:
> On 16 March 2017 at 08:26, Bin Meng  wrote:
>> At present there are only 8-bit and 32-bit read/write routines in
>> the rtc uclass driver. This adds the 16-bit support.
>>
>> Signed-off-by: Bin Meng 
>> ---
>>
>>  drivers/rtc/rtc-uclass.c | 30 ++
>>  include/rtc.h| 20 
>>  2 files changed, 50 insertions(+)
>
> Reviewed-by: Simon Glass 

applied to u-boot-x86, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 01/22] dm: rtc: Add 16-bit read/write support

2017-03-16 Thread Simon Glass
On 16 March 2017 at 08:26, Bin Meng  wrote:
> At present there are only 8-bit and 32-bit read/write routines in
> the rtc uclass driver. This adds the 16-bit support.
>
> Signed-off-by: Bin Meng 
> ---
>
>  drivers/rtc/rtc-uclass.c | 30 ++
>  include/rtc.h| 20 
>  2 files changed, 50 insertions(+)

Reviewed-by: Simon Glass 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 01/22] dm: rtc: Add 16-bit read/write support

2017-03-16 Thread Bin Meng
At present there are only 8-bit and 32-bit read/write routines in
the rtc uclass driver. This adds the 16-bit support.

Signed-off-by: Bin Meng 
---

 drivers/rtc/rtc-uclass.c | 30 ++
 include/rtc.h| 20 
 2 files changed, 50 insertions(+)

diff --git a/drivers/rtc/rtc-uclass.c b/drivers/rtc/rtc-uclass.c
index 300e9b3..89312c5 100644
--- a/drivers/rtc/rtc-uclass.c
+++ b/drivers/rtc/rtc-uclass.c
@@ -60,6 +60,36 @@ int rtc_write8(struct udevice *dev, unsigned int reg, int 
val)
return ops->write8(dev, reg, val);
 }
 
+int rtc_read16(struct udevice *dev, unsigned int reg, u16 *valuep)
+{
+   u16 value = 0;
+   int ret;
+   int i;
+
+   for (i = 0; i < sizeof(value); i++) {
+   ret = rtc_read8(dev, reg + i);
+   if (ret < 0)
+   return ret;
+   value |= ret << (i << 3);
+   }
+
+   *valuep = value;
+   return 0;
+}
+
+int rtc_write16(struct udevice *dev, unsigned int reg, u16 value)
+{
+   int i, ret;
+
+   for (i = 0; i < sizeof(value); i++) {
+   ret = rtc_write8(dev, reg + i, (value >> (i << 3)) & 0xff);
+   if (ret)
+   return ret;
+   }
+
+   return 0;
+}
+
 int rtc_read32(struct udevice *dev, unsigned int reg, u32 *valuep)
 {
u32 value = 0;
diff --git a/include/rtc.h b/include/rtc.h
index 69fe8d4..49142b6 100644
--- a/include/rtc.h
+++ b/include/rtc.h
@@ -128,6 +128,26 @@ int rtc_read8(struct udevice *dev, unsigned int reg);
 int rtc_write8(struct udevice *dev, unsigned int reg, int val);
 
 /**
+ * rtc_read16() - Read a 16-bit value from the RTC
+ *
+ * @dev:   Device to read from
+ * @reg:   Offset to start reading from
+ * @valuep:Place to put the value that is read
+ * @return 0 if OK, -ve on error
+ */
+int rtc_read16(struct udevice *dev, unsigned int reg, u16 *valuep);
+
+/**
+ * rtc_write16() - Write a 16-bit value to the RTC
+ *
+ * @dev:   Device to write to
+ * @reg:   Register to start writing to
+ * @value: Value to write
+ * @return 0 if OK, -ve on error
+ */
+int rtc_write16(struct udevice *dev, unsigned int reg, u16 value);
+
+/**
  * rtc_read32() - Read a 32-bit value from the RTC
  *
  * @dev:   Device to read from
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot