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