source: rtems/c/src/lib/libbsp/powerpc/gen5200/tod/todcfg.c @ d898f6e

Last change on this file since d898f6e was d898f6e, checked in by Sebastian Huber <sebastian.huber@…>, on Jan 19, 2018 at 2:28:33 PM

bsp/gen5200: Fix i2c.h and i2cdrv.h installation

Install these files only as <bsp/i2c.h> and <bsp/i2cdrv.h>.

Update #3254.

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