rtc: dw: Make internal primitives Kconfig based

Base address, IRQ, interrupt priority as well as the instance name: all
are now Kconfig based. Thus Applying the change to quark_se and
quark_d2000 platforms. Sample code is updated as well.

Change-Id: I1c225c1b68d94b22ca10423b50a78a0ba09a27a5
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2015-12-03 11:49:29 +01:00 committed by Anas Nashif
commit 66f05ce4b3
8 changed files with 77 additions and 16 deletions

View file

@ -151,4 +151,15 @@ config WDT_DW_IRQ
endif endif
if RTC
config RTC_DW
def_bool y
config RTC_DW_BASE_ADDR
default 0xB0000400
config RTC_DW_IRQ
default 2
endif
endif endif

View file

@ -134,10 +134,8 @@ struct scss_interrupt {
/* RTC */ /* RTC */
#define RTC_BASE_ADDR 0xB0000400
#define CCU_RTC_CLK_DIV_OFFSET 0x3 #define CCU_RTC_CLK_DIV_OFFSET 0x3
#define INT_RTC_MASK 0x478 #define INT_RTC_MASK 0x478
#define INT_RTC_IRQ 0x2
#define CCU_RTC_PCLK_EN_SW (1 << 11) #define CCU_RTC_PCLK_EN_SW (1 << 11)

View file

@ -176,6 +176,15 @@ config WDT_DW_IRQ
default 12 default 12
endif endif
if RTC
config RTC_DW
def_bool y
config RTC_DW_BASE_ADDR
default 0xB0000400
config RTC_DW_IRQ
default 11
endif
config KERNEL_INIT_PRIORITY_DEFAULT config KERNEL_INIT_PRIORITY_DEFAULT
default 40 default 40

View file

@ -225,11 +225,9 @@ struct scss_interrupt {
#define CCU_WDT_PCLK_EN_SW (1 << 10) #define CCU_WDT_PCLK_EN_SW (1 << 10)
/* RTC */ /* RTC */
#define RTC_BASE_ADDR 0xB0000400
#define CCU_RTC_CLK_DIV_OFFSET (3) #define CCU_RTC_CLK_DIV_OFFSET (3)
#define SCSS_INT_RTC_MASK 0x478 #define SCSS_INT_RTC_MASK 0x478
#define CCU_RTC_PCLK_EN_SW (1 << 11) #define CCU_RTC_PCLK_EN_SW (1 << 11)
#define INT_RTC_IRQ 0xb
/* Clock */ /* Clock */
#define CLOCK_PERIPHERAL_BASE_ADDR (SCSS_REGISTER_BASE + 0x18) #define CLOCK_PERIPHERAL_BASE_ADDR (SCSS_REGISTER_BASE + 0x18)

View file

@ -1,3 +1,24 @@
# Kconfig - RTC configuration options
#
#
# Copyright (c) 2015 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Real-Time Clock (RTC) options
#
menuconfig RTC menuconfig RTC
bool "Real-Time Clock" bool "Real-Time Clock"
default n default n
@ -12,9 +33,31 @@ config RTC_DW
help help
Designware RTC driver. Designware RTC driver.
config RTC_IRQ_PRI config RTC_DW_DRV_NAME
int "RTC Interrupt Priority" string "Driver instance name"
default 2 default "RTC_DW"
depends on RTC_DW
help help
RTC Interrupt Priority. Designware RTC driver instance name
config RTC_DW_BASE_ADDR
hex "Base address"
depends on RTC_DW
default 0x00000000
help
Base address to access RTC DesignWare controller registers
config RTC_DW_IRQ
int "Interrupt number"
default 0
depends on RTC_DW
help
DesignWare RTC interrupt number
config RTC_DW_IRQ_PRI
int "Interrupt priority"
default 2
depends on RTC_DW
help
DesignWare RTC interrupt priority.
endif # RTC endif # RTC

View file

@ -149,24 +149,28 @@ static struct rtc_driver_api funcs = {
}; };
/* IRQ_CONFIG needs the flags variable declared by IRQ_CONNECT_STATIC */ /* IRQ_CONFIG needs the flags variable declared by IRQ_CONNECT_STATIC */
IRQ_CONNECT_STATIC(rtc, INT_RTC_IRQ, CONFIG_RTC_IRQ_PRI, rtc_dw_isr, 0, 0); IRQ_CONNECT_STATIC(rtc, CONFIG_RTC_DW_IRQ,
CONFIG_RTC_DW_IRQ_PRI, rtc_dw_isr, 0, 0);
int rtc_dw_init(struct device *dev) int rtc_dw_init(struct device *dev)
{ {
IRQ_CONFIG(rtc, INT_RTC_IRQ); IRQ_CONFIG(rtc, CONFIG_RTC_DW_IRQ);
irq_enable(INT_RTC_IRQ); irq_enable(CONFIG_RTC_DW_IRQ);
SCSS_INTERRUPT->int_rtc_mask = INT_UNMASK_IA; SCSS_INTERRUPT->int_rtc_mask = INT_UNMASK_IA;
dev->driver_api = &funcs; dev->driver_api = &funcs;
return DEV_OK; return DEV_OK;
} }
struct rtc_dw_runtime rtc_runtime; struct rtc_dw_runtime rtc_runtime;
struct rtc_dw_dev_config rtc_dev = { struct rtc_dw_dev_config rtc_dev = {
.base_address = RTC_BASE_ADDR, .base_address = CONFIG_RTC_DW_BASE_ADDR,
}; };
DECLARE_DEVICE_INIT_CONFIG(rtc, RTC_DRV_NAME, &rtc_dw_init, &rtc_dev); DECLARE_DEVICE_INIT_CONFIG(rtc, CONFIG_RTC_DW_DRV_NAME,
&rtc_dw_init, &rtc_dev);
SYS_DEFINE_DEVICE(rtc, &rtc_runtime, SECONDARY, SYS_DEFINE_DEVICE(rtc, &rtc_runtime, SECONDARY,
CONFIG_KERNEL_INIT_PRIORITY_DEVICE); CONFIG_KERNEL_INIT_PRIORITY_DEVICE);

View file

@ -21,8 +21,6 @@
#include <device.h> #include <device.h>
#include <rtc.h> #include <rtc.h>
#define RTC_DRV_NAME "rtc"
#define RTC_CCVR (0x0) #define RTC_CCVR (0x0)
#define RTC_CMR (0x4) #define RTC_CMR (0x4)
#define RTC_CLR (0x8) #define RTC_CLR (0x8)

View file

@ -22,7 +22,7 @@
#define ALARM (RTC_ALARM_MINUTE / 6) #define ALARM (RTC_ALARM_MINUTE / 6)
#define RTC_DRIVER "rtc" #define RTC_DRIVER CONFIG_RTC_DW_DRV_NAME
void test_rtc_interrupt_fn(struct device *rtc_dev) void test_rtc_interrupt_fn(struct device *rtc_dev)
{ {