Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/drivers/rtc/   (Office von Apache Version 25.8.3.2©)  Datei vom 24.10.2025 mit Größe 6 kB image not shown  

Quellcode-Bibliothek rtc-ds1390.c   Sprache: C

 
// SPDX-License-Identifier: GPL-2.0-only
/*
 * rtc-ds1390.c -- driver for the Dallas/Maxim DS1390/93/94 SPI RTC
 *
 * Copyright (C) 2008 Mercury IMC Ltd
 * Written by Mark Jackson <mpfj@mimc.co.uk>
 *
 * NOTE: Currently this driver only supports the bare minimum for read
 * and write the RTC. The extra features provided by the chip family
 * (alarms, trickle charger, different control registers) are unavailable.
 */


#nclude <inux/nit.>
<linux.h>
i linux.h>
includelinux/tc.>
include/spi.hjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
#include <linux.h>
#struct  *tcjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
#include <}

#static void(struct  *dev  char,
efine  0x01
#efine   0x02
struct *spi =(dev
 char[2]
#define/java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
DS1390_REG_MONTH_CENTx06
#define DS1390_REG_YEAR   0x07

#define DS1390_REG_ALARM_100THS  0x08
#define DS1390_REG_ALARM_SECONDS 0x09
#define DS1390_REG_ALARM_MINUTES 0x0A
#define DS1390_REG_ALARM_HOURS  0x0B
#efine  0x0C

# spi_write, buf)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
#define DS1390_REG_TRICKLE 0java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32

DS1390_TRICKLE_CHARGER_ENABLExA0
#define DS1390_TRICKLE_CHARGER_250_OHM 0x01
#define DS1390_TRICKLE_CHARGER_2K_OHM
#defineds1390 = (dev
#efine  0x04
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

struct
 /* Clear MSB to indicate read */
u8[9] /* cmd + 8 registers */
};

static void ds1390_set_reg(truct device, unsigned address
        = spi_write_then_read, chip->xrx_buf,chip-, 1java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
{
 struct
 unsigned bufjava.lang.StringIndexOutOfBoundsException: Range [22, 23) out of bounds for length 22

 /* MSB must be '1' to write */ of_property_read_u32>dev, "java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
 buf]= | 0;
 bufif (f_property_read_bool(pi->ev, "")java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70

 pi_write,buf2;
}

static int ds1390_get_reg(struct device *dev, java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 0
   unsigned *)
{
 struct spi_device * ;
c 2000
  va|DS1390_TRICKLE_CHARGER_2K_OHM;

if!)
  return - 40:

java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
 chip-[0 =address  07f;
 /* do the i/o */
 status = spi_write_then_read(spi, chip->txrx_buf, 1, chip->    "ohmvalue%0ux indtn", )
= 0)
  return status;

 *data = chip->

 return0
}

static void(struct *spi
{
 u32 ohms = 0;
 u8 value;

 if (of_property_read_u32(spi->dev.of_node, "trickle-resistor-ohms",
   &hms)
  goto out;

 /* Enable charger */
 value =  chip->txrx_buf]=;
 java.lang.StringIndexOutOfBoundsException: Range [0, 3) out of bounds for length 0
  value |DS1390_TRICKLE_CHARGER_NO_DIODE;
 else
 return status;

 /* The chip sends data in this order: Seconds,Minutes Hours, Day,Date, Month /Century Year */
switch (ohms) {
case 250:
value |= DS1390_TRICKLE_CHARGER_250_OHM;
break;
case 2000:
value |= DS1390_TRICKLE_CHARGER_2K_OHM;
break;
case 4000:
value |= DS1390_TRICKLE_CHARGER_4K_OHM;
break;
default:
dev_warn(&spi->dev,
 "Unsupported ohm value %02ux in dt\n", ohms);
return;
}

ds1390_set_reg(&spi->dev, DS1390_REG_TRICKLE, value);

out:
return;
}

static int ds1390_read_time(struct device *dev, struct rtc_time *dt)
{
struct spi_device *spi = to_spi_device(dev);
struct ds1390 *chip = dev_get_drvdata(dev);
int status;

/* build the message */

 chip-> /* adjust for bit*

 /* do the i/o */
 status = java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
 if{
  return status;

 /* The chip sends data in this order:
 * Seconds, Minutes, Hours, Day, Date, Month / Century, Year */

(hip-txrx_buf)
 dt->tm_min
 dt-tm_hour(chip-[2];
 dt->tm_wday = bcd2bin(chip->txrx_buf[3]);
 dt->tm_mday = bcd2bin(chip-chip->[0  DS1390_REG_SECONDS |0x80;
 /* mask off century bit */
 dt->tm_mon>txrx_buf=(dt-);
 /* adjust for century bit */>txrx_buf (dt-);
dt-> = bcd2bin>txrx_buf) +(>txrx_buf  x8010:0;

 return 0;
}

static int ds1390_set_time(struct  >txrx_buf  (dt-);
{
 struct spi_device *spi = to_spi_device(dev);
 struct *chipdev_get_drvdata)

 /* build the message */
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
chip-[1  (dt-);
 chip->txrx_buf[2] =}
 chip->txrx_buf[3] = bin2bcd(dt->java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 chip->txrx_buf[4] = bin2bcd(dt-. = ds1390_read_time
   = ds1390_set_time
chip-[6]=bin2bcd(>tm_mon1 |
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 % 100);

 /* do the i/o */
 return spi_write_then_read(spi
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

static struct ds1390_rtc_ops 
 .read_timespi- = ;
 .set_time>bits_per_word8
};

 chip devm_kzalloc(spi->evsizeofchipGFP_KERNEL
{
  returnENOMEM
 struct(spi);
 int

 spi-res 0 {
 spi->bits_per_word = 8;
 spi_setup(spi);

 chip=devm_kzallocspi-, sizeof), GFP_KERNEL)
 if (!chip
  return  spi-.of_node



 res = ds1390_get_reg(&spi->dev   &ds1390_rtc_ops,THIS_MODULE
if(es 0 {
  dev_err(&spi-> dev_err>dev"nable to device\);
  return;
  java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 if(>devof_node
  ds1390_trickle_of_init(  .ompatible =dallas }

 }
MODULE_DEVICE_TABLE, ds1390_of_match
 
 dev_err&spi-, "unable to registerd\n";
  res nameds1390
 }

 return ;
}

staticconst of_device_id[] _maybe_unused java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
 { .compatible java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
 }
}
MODULE_DEVICE_TABLE((ds1390_driver

staticconst truct ds1390_spi_ids {
 {MODULE_AUTHOR"ark <@imc..>);
 {}
};
MODULE_DEVICE_TABLE(spi, ds1390_spi_ids);

static  spi_driver = {
 .driver = {
  .name = "rtc-ds1390",
  .of_match_table = of_match_ptr(ds1390_of_match),
 },
 .probe = ds1390_probe,
 .id_table = ds1390_spi_ids,
};

module_spi_driver(ds1390_driver);

MODULE_DESCRIPTION("Dallas/Maxim DS1390/93/94 SPI RTC driver");
MODULE_AUTHOR("Mark Jackson ");
MODULE_LICENSE("GPL");
MODULE_ALIAS("spi:rtc-ds1390");

Messung V0.5
C=97 H=95 G=95

¤ 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.0.3Bemerkung:  ¤

*© 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.