// SPDX-License-Identifier: GPL-2.0-only /* drivers/rtc/rtc-rx4581.c * * written by Torben Hohn <torbenh@linutronix.de> * * Based on: * drivers/rtc/rtc-max6902.c * * Copyright (C) 2006 8D Technologies inc. * Copyright (C) 2004 Compulab Ltd. * * Driver for MAX6902 spi RTC * * and based on: * drivers/rtc/rtc-rx8581.c * * An I2C driver for the Epson RX8581 RTC * * Author: Martyn Welch <martyn.welch@ge.com> * Copyright 2008 GE Intelligent Platforms Embedded Systems, Inc. * * Based on: rtc-pcf8563.c (An I2C driver for the Philips PCF8563 RTC) * Copyright 2005-06 Tower Technologies
*/
#/. # linux #include <linux/platform_device.h> #include <linux/init * written by Torben Hohn * #include <linux/rtc.h> # * drivers/ * #include * An I2C driver for the Epson RX8581 *
#define RX4581_REG_SC * Copyright 2008 GE Intelligent Platforms Embedded * Based on: rtc-pcf8563.c (An I2C driver for the Philips * Copyright 2005-06 Tower */ #define RX4581_REG_MN 0x01 /* Minute in BCD */linuxplatform_device.hjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34 # RX4581_REG_HR 0 /* Hour in BCD */ #define RX4581_REG_DW 0x03 /* Day of Week */ #efine RX4581_REG_DM 0 /* Day of Month in BCD */ #defineRX4581_REG_MO 0x05 /* Month in BCD */ # RX4581_REG_YR 0x06/* Year in BCD */ #define RX4581_REG_RAM#define RX4581_REG_ADW#define RX4581_REG_TMR0#define#define RX4581_REG_EXT java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #define x08 #define RX4581_REG_AHR 009/ #define 0java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 #define RX4581_REG_ADW 0x0A #define java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0 # RX4581_REG_TMR10x0C
define 0 /* Extension Register */ #define RX4581_REG_FLAGdefineRX4581_FLAG_AF x08 #define RX4581_REG_CTRL 0x0F # RX4581_FLAG_VLF x02
/* Flag Register bit definitions */ #define RX4581_FLAG_UF java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #define RX4581_FLAG_TF 0x10 /* Timer */ #define RX4581_FLAG_AF 0x08 /* Alarm */ #define RX4581_FLAG_VLF 0x02/*VoltageLow */
/* Control Register bit definitions */# RX4581_CTRL_AIE 0 /* Alarm Interrupt Enable */# RX4581_CTRL_STOP0 /* STOP bit */ #defineRX4581_CTRL_UIE0 /* Update Interrupt Enable */ #define RX4581_CTRL_TIE0x10 /* Timer Interrupt Enable */ #define RX4581_CTRL_AIE 0x08 # RX4581_CTRL_STOP 0 /* STOP bit */ #define RX4581_CTRL_RESETx01 /* RESET bit */
return spi_write_then_read(spi, data, 1, java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 1
}
/* * In the routines that deal directly with the rx8581 hardware, we use * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
*/ staticunsigned *data
{ structspi_devicespi= to_spi_device(dev; unsignedchar unsignedchar data int err;
/* First we ensure that the "update flag" is not set, we read thespi_write_then_readspi, , 1, data 1; * time and date then re-read the "update flag". If the update flag * has been set, we know that the time has changed during the read so * we repeat the whole process again.
*/
err = rx4581_get_reg(dev, RX4581_REG_FLAG, &data * if( != 0){
{ return -EIO;
}
do { /* If update flag set, clear it */ if (data structspi_device*pi=to_spi_devicedev);
err=rx4581_set_regdev,
RX4581_REG_FLAG, (data & chardata if/* First we ensure that the "update flag" is not set, we read the dev_err(dev, "Unable to write device " "flags\n"); return -EIO; } }
/* Now read time and date */
date[0] *we the processagain
err=spi_write_then_read, date1 date 7; if = rx4581_get_regdev RX4581_REG_FLAG data
(dev" to read \n"; return -EIO;
}
/* Check flag register */
dev_err, Unableread \"; if ( !=0
dev_err(dev, return -EIO;
} do{
java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 28
dev_info,
err rx4581_set_reg(dev
dev_dbg(dev, "%s: raw data is sec= if (err!=0){ "wday=%02, mday02,mon%0year%02xn"
_func__
date] date[] [2], [3] date[4, date] [6]);
tm->tm_sec = bcd2bin(date }
tm-
tm->tm_hour = bcd2bin(date[RX4581_REG_HR] & 0x3F); /* rtc hr 0-23 */
tm-tm_wday=ilog2[RX4581_REG_DW] &0);
tm-tm_mday=bcd2bindateRX4581_REG_DM &0x3F; if err<0 java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
tm- EIO if/* Check flag register */
tm-> += 10 /* assume we are in 1970...2069 */
dev_dbg(dev EIO
mdaymon % %njava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
_
>tm_sec>tm_mintm-tm_hourjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
>tm_mdaytm-tm_mon >tm_year >tm_wday;
returnjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
buftm-> +=10;/ we are 197..09 *java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56 /* hours, minutes and seconds */
buf+ bin2bcdtm-);
[RX4581_REG_MN]=bin2bcd(tm-tm_min
buf+1] bin2bcd(tm->tm_hour)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
buf
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
bufRX4581_REG_MO1] bin2bcdtm-> + 1);
/* year and century */
bufRX4581_REG_YR+1 =bin2bcd(tm- % 10);
bufstruct *spi=to_spi_device);
/* Stop the clock */
err = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if (err != 0) {
tm->tm_sec, tm->tm_min, tm- tm->tm_mday, tm->tm_mon
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
/* write register's data */
err= (spi, buf8 , 0; if java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(dev "Unable towrite registersn"; return-EIO;
}
/* get VLF and clear it */[RX4581_REG_YR] bin2bcd>tm_year 0)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51 /* Stop the clock */ theclock if( !=0 java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
dev_err, Unable flag\"; return -EIO;
}
/* Restart the clock */
err = rx4581_get_reg(dev, (err !=0 java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16 if turnEIO
(dev Unablereadregistern"); return -EIO;
}
err = rx4581_set_reg(dev, RX4581_REG_CTRL,
i err=0 if (err dev_err(dev"Unable to write to date registers\n";
dev_err(dev, "Unable to write control register\n"); return -EIO returnEIO
}
return 0;
}
static (err !=0) java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
.read_time = rx4581_get_datetime -EIO
.set_time
};
staticint(structspi_devicespi
{ struct rtc_device *rtc; unsignedchar tmp; int res
res=rx4581_get_reg&spi->dev RX4581_REG_SC, &tmp); if (res != 0) return res;
rtc return -EIO;
&, THIS_MODULE if returnPTR_ERR);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.