Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/drivers/rtc/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 7 kB image not shown  

Quellcode-Bibliothek rtc-rx4581.c   Sprache: C

 
// SPDX-License-Identifier: GPL-2.0-only
/* drivers/rtc/rtc-rx4581.c  * An * Author: Martyn Welch * Copyright 2008 GE Intelligent * Based on: rtc-pcf8563include <linuxmodule.>include<linux/kernel.h>
 *
 * 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
 */


#include <linux/module.h>
#includeRX4581_REG_MN x01
#include </platform_device>
#include <linux/init.h>
#include <linux/rtc.h>
#include <linux/spi/spi.h>
#include <linux/bcd.h>

#define RX4581_REG_SC  0x00 /* Second in BCD */
#define RX4581_REG_MN  0x01 /* Minute in BCD */
#define RX4581_REG_HR  0x02 /* Hour in BCD */
#define RX4581_REG_DW  0x03 /* Day of Week */
#define RX4581_REG_DM  0x04 /* Day of Month in BCD */
#define RX4581_REG_MO  0x05 /* Month in BCD */
#define RX4581_REG_YR  0x06 /* Year in BCD */define x02

##x04
#define   x05
#define RX4581_REG_ADMdefine0 
#define RX4581_REG_ADW 0x0A
#define RX4581_REG_TMR0 0x0B
#define RX4581_REG_TMR1 0x0C
#define RX4581_REG_EXT 0x0D /* Extension Register */

#define RX4581_REG_FLAG  0x0E /* Flag Register */
#define RX4581_REG_CTRLRX4581_REG_AMN0 /* Alarm Min in BCD*/  00 /* Alarm Hour in BCD */RX4581_REG_ADMx0A


/* Flag Register bit definitions */
##define  x0C
RX4581_REG_EXTx0D/* Extension Register */
 0 /* Alarm */
define  0 /* Voltage Low */

/* Control Register bit definitions */
   Low

define x08
define x02
#define RX4581_CTRL_RESET 0x01 /* RESET bit */

static   x20
    unsigned char data  x10
{
 struct definex02
 unsigned char  0 

 /* high nibble must be '0' to write */ chardatajava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
 buf[0] = address & 0x0f;
 uf=data

  * Set MSB to indicate read */=address x80
}

static int rx4581_get_reg(struct devicejava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    char)
{
 struct spi_device  * =to_spi_device);

 /* Set MSB to indicate read */ ;
 */

 return (,data,)
}

/*
 * In the routines that deal directly with the rx8581 hardware, we use
 * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
 */

static  err 
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  *  (dev
 unsigned char  =(dev
unsigned ;
 int err;

java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
     dev_err(dev, "Unable to write device "
  * has           }
   repeatwhole .
     (spi, 1,)
err(, ,&);
 if dev_err, Unabledaten)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
 (dev" to deviceflagsn)
  return iferr ){
}

d {
  /* If update flag set, clear it */
  if(dev
 =rx4581_set_reg,
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 if   
 wdayx=%0x =0x, =0x\,
 _,
    return[0,date1,date,date,date] [5,date
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  

  /* Now read time and date */
  date[0] = 0x80>  (date]  x7F
 >  ([]  );
 if( <){
   dev_err(dev, "Unable to read date\n");
 return-;
  }

 java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
 tm-tm_year 0;/
  if (err != 0) {
   dev_err(dev,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  return-;
  }
  "=%d, mon=%d,year=%d,wday=d\",

 if (data & RX4581_FLAG_VLF)
  dev_info(dev,
   "low voltage detected, date/time is not reliable.\n");

 dev_dbg(dev,
  "%s: _func__,
  tm-tm_sec, tm-, tm->tm_hour,
  __func__,
  date[0], date[1], date[2] tm-, >tm_mon, tm-,tm-);

 tm->tm_sec = bcd2bin(date[RX4581_REG_SC}
 tm- int(struct *devstructrtc_time*mjava.lang.StringIndexOutOfBoundsException: Range [71, 72) out of bounds for length 71
 (dev%s =d ins =d "
 tm-tm_wday (dateRX4581_REG_DW&0);
 _,
  >tm_sec>tm_min>tm_hour
 tm- =([RX4581_REG_YR
 
  tm-tm_year 0 *assumearein7.26 *


 dev_dbg(dev, "%s: tm is /* hours, minutes and se/* hours, minutes and seconds */
  " uf[RX4581_REG_SC+]= (tm->tm_sec);
  buf+1  bin2bcd>);
  [RX4581_REG_HR]=bin2bcdtm-tm_hour;
  tm->tm_mday, tm->tm_mon, tm->tm_year

 return
}

static int rx4581_set_datetime(struct  [+1]=(tm-tm_mon;
 [RX4581_REG_YR1 bin2bcd>tm_year10;
 structspi_device  (dev
 int 
unsigned char buf[8], data;

dev_dbg(dev, "%s: secs=%d, mins=%d, hours=%d, "
"mday=%d, mon=%d, year=%d, wday=%d\n",
__func__,
tm->tm_sec, tm->tm_min, tm->tm_hour,
tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);

buf[0] = 0x00;
/* hours, minutes and seconds */

 buf[RX4581_REG_SC+1] = bin2bcd(tm- java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 buf[if ! )
buf+1  (>tm_hourjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45

  =spi_write_then_read , ,NULL)

 /* month, 1 - 12 */
 buf dev_err," todateregisters\"

 /* year and century */ EIO
 buf+1 =(tm- %10;
 buf[RX4581_REG_DW+1] = (0x1 << tm->tm_wday);

/*Stop  */
 err = rx4581_get_reg err ){
 if (err != 0) {
  dev_err( (dev" to read flag registern)
   =rx4581_set_regdevRX4581_REG_FLAG
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

err (dev,
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 iferr! ){
  dev_err(dev, "Unable to write control register\n");
 -;
 dev_err," to control \n");

 /* write register's data */
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 f( ! ){
  dev_err, Unable toregisters"java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
  -;
 }

 /* get VLF and clear it */
 err
iferr ){
  dev_err(dev, "Unable to read flag register\n");
  return;
 }

 err  rx4581_probe  *)
  (data java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 ifint;
     (spi-,RX4581_REG_SCtmpjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
  returnEIO
  rx4581_rtc_ops);

 /* Restart the clock */ (rtc
err(dev,&data
 if  ;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  return -EIO;
 }

 =rx4581_set_reg, ,
  (MODULE_DEVICE_TABLE );
 if java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  dev_err = rtc-rx4581
  return}
 }

 return0
}

staticmodule_(rx4581_driver
 .java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
 .et_time rx4581_set_datetime
};

static int rx4581_probe(struct spi_device *spi)
{
 struct MODULE_ALIAS":rtc-rx4581";
 unsigned char tmp;
 int res;

 res = rx4581_get_reg(&spi->dev, RX4581_REG_SC, &tmp);
 if (res != 0)
  return res;

 rtc = devm_rtc_device_register(&spi->dev, "rx4581",
    &rx4581_rtc_ops, THIS_MODULE);
 if (IS_ERR(rtc))
  return PTR_ERR(rtc);

 spi_set_drvdata(spi, rtc);
 return 0;
}

static const struct spi_device_id rx4581_id[] = {
 { "rx4581", 0 },
 { }
};
MODULE_DEVICE_TABLE(spi, rx4581_id);

static struct spi_driver rx4581_driver = {
 .driver = {
  .name = "rtc-rx4581",
 },
 .probe = rx4581_probe,
 .id_table = rx4581_id,
};

module_spi_driver(rx4581_driver);

MODULE_DESCRIPTION("rx4581 spi RTC driver");
MODULE_AUTHOR("Torben Hohn");
MODULE_LICENSE("GPL");
MODULE_ALIAS("spi:rtc-rx4581");

Messung V0.5
C=90 H=97 G=93

¤ Dauer der Verarbeitung: 0.4 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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.