2016-03-09 21:00:40 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Intel Corporation.
|
|
|
|
*
|
2017-01-19 02:01:01 +01:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-03-09 21:00:40 +01:00
|
|
|
*/
|
|
|
|
|
2016-03-21 21:02:03 +01:00
|
|
|
#include <errno.h>
|
|
|
|
|
2016-03-09 21:00:40 +01:00
|
|
|
#include <device.h>
|
|
|
|
#include <init.h>
|
|
|
|
|
|
|
|
#include <counter.h>
|
|
|
|
|
|
|
|
#include "qm_aon_counters.h"
|
|
|
|
|
|
|
|
static int aon_counter_qmsi_start(struct device *dev)
|
|
|
|
{
|
2016-10-14 01:40:51 +02:00
|
|
|
if (qm_aonc_enable(QM_AONC_0)) {
|
2016-03-21 21:02:03 +01:00
|
|
|
return -EIO;
|
2016-03-09 21:00:40 +01:00
|
|
|
}
|
|
|
|
|
2016-03-21 21:02:03 +01:00
|
|
|
return 0;
|
2016-03-09 21:00:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int aon_counter_qmsi_stop(struct device *dev)
|
|
|
|
{
|
2016-10-14 01:40:51 +02:00
|
|
|
qm_aonc_disable(QM_AONC_0);
|
2016-03-09 21:00:40 +01:00
|
|
|
|
2016-03-21 21:02:03 +01:00
|
|
|
return 0;
|
2016-03-09 21:00:40 +01:00
|
|
|
}
|
|
|
|
|
2017-04-21 17:03:20 +02:00
|
|
|
static u32_t aon_counter_qmsi_read(struct device *dev)
|
2016-03-09 21:00:40 +01:00
|
|
|
{
|
2017-04-21 17:03:20 +02:00
|
|
|
u32_t value;
|
2016-05-18 13:09:16 +02:00
|
|
|
|
2016-10-14 01:40:51 +02:00
|
|
|
qm_aonc_get_value(QM_AONC_0, &value);
|
2016-05-18 13:09:16 +02:00
|
|
|
|
|
|
|
return value;
|
2016-03-09 21:00:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int aon_counter_qmsi_set_alarm(struct device *dev,
|
|
|
|
counter_callback_t callback,
|
2017-04-21 17:03:20 +02:00
|
|
|
u32_t count, void *user_data)
|
2016-03-09 21:00:40 +01:00
|
|
|
{
|
2016-03-21 21:02:03 +01:00
|
|
|
return -ENODEV;
|
2016-03-09 21:00:40 +01:00
|
|
|
}
|
|
|
|
|
2016-10-24 09:19:06 +02:00
|
|
|
static const struct counter_driver_api aon_counter_qmsi_api = {
|
2016-03-09 21:00:40 +01:00
|
|
|
.start = aon_counter_qmsi_start,
|
|
|
|
.stop = aon_counter_qmsi_stop,
|
|
|
|
.read = aon_counter_qmsi_read,
|
|
|
|
.set_alarm = aon_counter_qmsi_set_alarm,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int aon_counter_init(struct device *dev)
|
|
|
|
{
|
2016-03-21 21:02:03 +01:00
|
|
|
return 0;
|
2016-03-09 21:00:40 +01:00
|
|
|
}
|
|
|
|
|
2016-04-28 00:30:55 +02:00
|
|
|
DEVICE_AND_API_INIT(aon_counter, CONFIG_AON_COUNTER_QMSI_DEV_NAME,
|
2016-11-08 20:06:55 +01:00
|
|
|
aon_counter_init, NULL, NULL, POST_KERNEL,
|
2016-04-28 00:30:55 +02:00
|
|
|
CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
2016-10-24 09:19:06 +02:00
|
|
|
&aon_counter_qmsi_api);
|