source: rtems/bsps/powerpc/gen5200/rtc/todcfg.c @ 3fb2a815

Last change on this file since 3fb2a815 was 3fb2a815, checked in by Christian Mauderer <christian.mauderer@…>, on 03/03/22 at 08:17:22

bsps/powerpc/gen5200: Manual file header clean up

Updates #4625.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 * RTEMS generic MPC5200 BSP
3 *
4 * This file configures the pcf8563 RTC for a PM520 board.
5 *
6 * Based on:
7 * This file contains the RTC driver table for Motorola MCF5206eLITE
8 * ColdFire evaluation board.
9 */
10
11/*
12 * Copyright (C) 2000 OKTET Ltd., St.-Petersburg, Russia
13 * Author: Victor V. Vengerov <vvv@oktet.ru>
14 * Copyright (c) 2005 embedded brains GmbH. All rights reserved.
15 *
16 * The license and distribution terms for this file may be
17 * found in the file LICENSE in this distribution or at
18 * http://www.rtems.org/license/LICENSE.
19 */
20
21#include <bsp.h>
22#include <bsp/i2c.h>
23#include <libchip/rtc.h>
24#include "pcf8563.h"
25
26/* Forward function declaration */
27bool mpc5200_pcf8563_probe(int minor);
28
29extern rtc_fns pcf8563_fns;
30
31/* The following table configures the RTC drivers used in this BSP */
32rtc_tbl RTC_Table[] = {
33    {
34        "/dev/rtc",                /* sDeviceName */
35        RTC_CUSTOM,                /* deviceType */
36        &pcf8563_fns,              /* pDeviceFns */
37        mpc5200_pcf8563_probe,     /* deviceProbe */
38        NULL,                      /* pDeviceParams */
39        0x01,                      /* ulCtrlPort1, for PCF8563-I2C bus number */
40        PCF8563_I2C_ADDRESS,       /* ulDataPort, for PCF8563-I2C device addr */
41        NULL,                      /* getRegister - not applicable to PCF8563 */
42        NULL                       /* setRegister - not applicable to PCF8563 */
43    }
44};
45
46/* Some information used by the RTC driver */
47
48#define NUM_RTCS (sizeof(RTC_Table)/sizeof(rtc_tbl))
49
50size_t RTC_Count = NUM_RTCS;
51
52/* mpc5200_pcf8563_probe --
53 *     RTC presence probe function. Return TRUE, if device is present.
54 *     Device presence checked by probe access to RTC device over I2C bus.
55 *
56 * PARAMETERS:
57 *     minor - minor RTC device number
58 *
59 * RETURNS:
60 *     TRUE, if RTC device is present
61 */
62bool
63mpc5200_pcf8563_probe(int minor)
64{
65    int try = 0;
66    i2c_message_status status;
67    rtc_tbl *rtc;
68    i2c_bus_number bus;
69    i2c_address addr;
70
71    if (minor >= NUM_RTCS)
72        return false;
73
74    rtc = RTC_Table + minor;
75
76    bus = rtc->ulCtrlPort1;
77    addr = rtc->ulDataPort;
78    do {
79        status = i2c_wrbyte(bus, addr, 0);
80        if (status == I2C_NO_DEVICE)
81            return false;
82        try++;
83    } while ((try < 15) && (status != I2C_SUCCESSFUL));
84    if (status == I2C_SUCCESSFUL)
85        return true;
86    else
87        return false;
88}
Note: See TracBrowser for help on using the repository browser.